creation of Chart Sections (TODO: GO REFERENCE)
This commit is contained in:
parent
a469c4acdd
commit
2f57a4db06
|
@ -0,0 +1,88 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
using TMPro;
|
||||||
|
|
||||||
|
using DG.Tweening;
|
||||||
|
|
||||||
|
namespace HeavenStudio.Editor.Track
|
||||||
|
{
|
||||||
|
public class SectionTimelineObj : SpecialTimelineObj
|
||||||
|
{
|
||||||
|
[Header("Components")]
|
||||||
|
[SerializeField] private TMP_Text sectionLabel;
|
||||||
|
[SerializeField] private GameObject chartLine;
|
||||||
|
|
||||||
|
public DynamicBeatmap.ChartSection chartSection;
|
||||||
|
|
||||||
|
new private void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
if (hovering)
|
||||||
|
{
|
||||||
|
SpecialTimeline.hoveringTypes |= SpecialTimeline.HoveringTypes.SectionChange;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateLabel()
|
||||||
|
{
|
||||||
|
sectionLabel.text = chartSection.sectionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Init()
|
||||||
|
{
|
||||||
|
UpdateLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnLeftClick()
|
||||||
|
{
|
||||||
|
if (Timeline.instance.timelineState.currentState == Timeline.CurrentTimelineState.State.ChartSection)
|
||||||
|
StartMove();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnRightClick()
|
||||||
|
{
|
||||||
|
if (Timeline.instance.timelineState.currentState == Timeline.CurrentTimelineState.State.ChartSection)
|
||||||
|
{
|
||||||
|
GameManager.instance.Beatmap.beatmapSections.Remove(chartSection);
|
||||||
|
DeleteObj();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool OnMove(float beat)
|
||||||
|
{
|
||||||
|
foreach (var sectionChange in GameManager.instance.Beatmap.beatmapSections)
|
||||||
|
{
|
||||||
|
if (this.chartSection == sectionChange)
|
||||||
|
continue;
|
||||||
|
if (beat > sectionChange.beat - Timeline.instance.snapInterval && beat < sectionChange.beat + Timeline.instance.snapInterval)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.chartSection.beat = beat;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetVisibility(Timeline.CurrentTimelineState.State state)
|
||||||
|
{
|
||||||
|
if (state == Timeline.CurrentTimelineState.State.ChartSection || state == Timeline.CurrentTimelineState.State.Selection)
|
||||||
|
{
|
||||||
|
gameObject.SetActive(true);
|
||||||
|
if (state == Timeline.CurrentTimelineState.State.ChartSection)
|
||||||
|
{
|
||||||
|
chartLine.SetActive(true);
|
||||||
|
sectionLabel.gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
chartLine.SetActive(false);
|
||||||
|
sectionLabel.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -52,6 +52,9 @@ namespace HeavenStudio.Editor.Track
|
||||||
foreach (var volumeChange in GameManager.instance.Beatmap.volumeChanges)
|
foreach (var volumeChange in GameManager.instance.Beatmap.volumeChanges)
|
||||||
AddVolumeChange(false, volumeChange);
|
AddVolumeChange(false, volumeChange);
|
||||||
|
|
||||||
|
foreach (var sectionChange in GameManager.instance.Beatmap.beatmapSections)
|
||||||
|
AddChartSection(false, sectionChange);
|
||||||
|
|
||||||
Timeline.instance.timelineState.SetState(Timeline.CurrentTimelineState.State.Selection);
|
Timeline.instance.timelineState.SetState(Timeline.CurrentTimelineState.State.Selection);
|
||||||
FixObjectsVisibility();
|
FixObjectsVisibility();
|
||||||
}
|
}
|
||||||
|
@ -83,6 +86,10 @@ namespace HeavenStudio.Editor.Track
|
||||||
if (!hoveringTypes.HasFlag(HoveringTypes.VolumeChange))
|
if (!hoveringTypes.HasFlag(HoveringTypes.VolumeChange))
|
||||||
AddVolumeChange(true);
|
AddVolumeChange(true);
|
||||||
break;
|
break;
|
||||||
|
case Timeline.CurrentTimelineState.State.ChartSection:
|
||||||
|
if (!hoveringTypes.HasFlag(HoveringTypes.SectionChange))
|
||||||
|
AddChartSection(true);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,5 +185,42 @@ namespace HeavenStudio.Editor.Track
|
||||||
|
|
||||||
specialTimelineObjs.Add(volumeTimelineObj);
|
specialTimelineObjs.Add(volumeTimelineObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddChartSection(bool create, DynamicBeatmap.ChartSection chartSection_ = null)
|
||||||
|
{
|
||||||
|
GameObject chartSection = Instantiate(RefSectionChange.gameObject, this.transform);
|
||||||
|
|
||||||
|
chartSection.transform.GetChild(0).GetComponent<Image>().color = EditorTheme.theme.properties.SectionLayerCol.Hex2RGB();
|
||||||
|
chartSection.transform.GetChild(1).GetComponent<Image>().color = EditorTheme.theme.properties.SectionLayerCol.Hex2RGB();
|
||||||
|
chartSection.transform.GetChild(2).GetComponent<TMP_Text>().color = EditorTheme.theme.properties.SectionLayerCol.Hex2RGB();
|
||||||
|
|
||||||
|
chartSection.SetActive(true);
|
||||||
|
|
||||||
|
SectionTimelineObj sectionTimelineObj = chartSection.GetComponent<SectionTimelineObj>();
|
||||||
|
|
||||||
|
if (create == true)
|
||||||
|
{
|
||||||
|
chartSection.transform.position = new Vector3(Editor.instance.EditorCamera.ScreenToWorldPoint(Input.mousePosition).x + 0.08f, chartSection.transform.position.y);
|
||||||
|
chartSection.transform.localPosition = new Vector3(Starpelly.Mathp.Round2Nearest(chartSection.transform.localPosition.x, Timeline.SnapInterval()), chartSection.transform.localPosition.y);
|
||||||
|
|
||||||
|
DynamicBeatmap.ChartSection sectionC = new DynamicBeatmap.ChartSection();
|
||||||
|
sectionC.beat = chartSection.transform.localPosition.x;
|
||||||
|
sectionC.sectionName = "New Section";
|
||||||
|
sectionC.startPerfect = false;
|
||||||
|
sectionC.isCheckpoint = false;
|
||||||
|
|
||||||
|
sectionTimelineObj.chartSection = sectionC;
|
||||||
|
GameManager.instance.Beatmap.beatmapSections.Add(sectionC);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
chartSection.transform.localPosition = new Vector3(chartSection_.beat, chartSection.transform.localPosition.y);
|
||||||
|
|
||||||
|
sectionTimelineObj.chartSection = chartSection_;
|
||||||
|
}
|
||||||
|
sectionTimelineObj.SetVisibility(Timeline.instance.timelineState.currentState);
|
||||||
|
|
||||||
|
specialTimelineObjs.Add(sectionTimelineObj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue