section edit dialog
This commit is contained in:
parent
c3d67ba382
commit
42e4d36e9b
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,51 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using HeavenStudio;
|
||||
using HeavenStudio.Editor;
|
||||
using HeavenStudio.Editor.Track;
|
||||
using TMPro;
|
||||
|
||||
public class SectionDialog : Dialog
|
||||
{
|
||||
SectionTimelineObj sectionObj;
|
||||
[SerializeField] TMP_InputField sectionName;
|
||||
|
||||
public void SwitchSectionDialog()
|
||||
{
|
||||
if(dialog.activeSelf) {
|
||||
sectionObj = null;
|
||||
dialog.SetActive(false);
|
||||
Editor.instance.inAuthorativeMenu = false;
|
||||
} else {
|
||||
Editor.instance.inAuthorativeMenu = true;
|
||||
ResetAllDialogs();
|
||||
dialog.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSectionObj(SectionTimelineObj sectionObj)
|
||||
{
|
||||
this.sectionObj = sectionObj;
|
||||
sectionName.text = sectionObj.chartSection.sectionName;
|
||||
}
|
||||
|
||||
public void DeleteSection()
|
||||
{
|
||||
if(dialog.activeSelf) {
|
||||
dialog.SetActive(false);
|
||||
Editor.instance.inAuthorativeMenu = false;
|
||||
}
|
||||
if (sectionObj == null) return;
|
||||
GameManager.instance.Beatmap.beatmapSections.Remove(sectionObj.chartSection);
|
||||
sectionObj.DeleteObj();
|
||||
}
|
||||
|
||||
public void ChangeSectionName(string name)
|
||||
{
|
||||
if (sectionObj == null) return;
|
||||
sectionObj.chartSection.sectionName = name;
|
||||
sectionObj.UpdateLabel();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 10dd19278a802c24fbeb39d1ccb23219
|
||||
guid: 7e5d39fb5bc171f44ba013cf8e37fdd2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
|
@ -67,7 +67,7 @@ namespace HeavenStudio.Editor.Track
|
|||
firstUpdate = true;
|
||||
}
|
||||
|
||||
if (Timeline.instance.userIsEditingInputField)
|
||||
if (Timeline.instance.userIsEditingInputField || Editor.instance.inAuthorativeMenu)
|
||||
return;
|
||||
|
||||
if (!Conductor.instance.NotStopped())
|
||||
|
@ -222,6 +222,8 @@ namespace HeavenStudio.Editor.Track
|
|||
sectionTimelineObj.SetVisibility(Timeline.instance.timelineState.currentState);
|
||||
|
||||
specialTimelineObjs.Add(sectionTimelineObj);
|
||||
//auto-open the dialog
|
||||
sectionTimelineObj.OnRightClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,180 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System;
|
||||
|
||||
using TMPro;
|
||||
using Starpelly;
|
||||
|
||||
namespace HeavenStudio.Editor.Track
|
||||
{
|
||||
public class TempoTimeline : MonoBehaviour
|
||||
{
|
||||
[Header("Components")]
|
||||
private RectTransform rectTransform;
|
||||
[SerializeField] private RectTransform RefTempoChange;
|
||||
public TMP_InputField StartingBPM;
|
||||
private RectTransform StartingBPMRect;
|
||||
public TMP_InputField FirstBeatOffset;
|
||||
|
||||
public List<TempoTimelineObj> tempoTimelineObjs = new List<TempoTimelineObj>();
|
||||
|
||||
private bool firstUpdate;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
rectTransform = this.GetComponent<RectTransform>();
|
||||
StartingBPMRect = StartingBPM.GetComponent<RectTransform>();
|
||||
|
||||
for (int i = 0; i < GameManager.instance.Beatmap.tempoChanges.Count; i++)
|
||||
{
|
||||
DynamicBeatmap.TempoChange tempoChange = GameManager.instance.Beatmap.tempoChanges[i];
|
||||
AddTempoChange(false, tempoChange);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!firstUpdate)
|
||||
{
|
||||
UpdateStartingBPMText();
|
||||
UpdateOffsetText();
|
||||
firstUpdate = true;
|
||||
}
|
||||
|
||||
if (Timeline.instance.userIsEditingInputField)
|
||||
return;
|
||||
|
||||
if (Timeline.instance.timelineState.tempoChange && !Conductor.instance.NotStopped())
|
||||
{
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(rectTransform, Input.mousePosition, Editor.instance.EditorCamera))
|
||||
{
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
if (tempoTimelineObjs.FindAll(c => c.hovering == true).Count == 0)
|
||||
{
|
||||
AddTempoChange(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(StartingBPMRect, Input.mousePosition, Editor.instance.EditorCamera))
|
||||
{
|
||||
float increase = Input.mouseScrollDelta.y;
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
increase /= 100f;
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
increase *= 5f;
|
||||
|
||||
if (increase != 0f)
|
||||
{
|
||||
GameManager.instance.Beatmap.bpm += increase;
|
||||
UpdateStartingBPMText();
|
||||
UpdateStartingBPMFromText(); // In case the scrolled-to value is invalid.
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateStartingBPMText()
|
||||
{
|
||||
StartingBPM.text = GameManager.instance.Beatmap.bpm.ToString("G");
|
||||
}
|
||||
|
||||
public void UpdateOffsetText()
|
||||
{
|
||||
FirstBeatOffset.text = (GameManager.instance.Beatmap.firstBeatOffset * 1000f).ToString("G");
|
||||
}
|
||||
|
||||
public void UpdateStartingBPMFromText()
|
||||
{
|
||||
// Failsafe against empty string.
|
||||
if (String.IsNullOrEmpty(StartingBPM.text))
|
||||
StartingBPM.text = "120";
|
||||
|
||||
var newBPM = Convert.ToSingle(StartingBPM.text);
|
||||
|
||||
// Failsafe against negative BPM.
|
||||
if (newBPM < 1f)
|
||||
{
|
||||
StartingBPM.text = "1";
|
||||
newBPM = 1;
|
||||
}
|
||||
|
||||
// Limit decimal places to 4.
|
||||
newBPM = (float)System.Math.Round(newBPM, 4);
|
||||
|
||||
GameManager.instance.Beatmap.bpm = newBPM;
|
||||
|
||||
// In case the newBPM ended up differing from the inputted string.
|
||||
UpdateStartingBPMText();
|
||||
|
||||
Timeline.instance.FitToSong();
|
||||
}
|
||||
|
||||
public void UpdateOffsetFromText()
|
||||
{
|
||||
// Failsafe against empty string.
|
||||
if (String.IsNullOrEmpty(FirstBeatOffset.text))
|
||||
FirstBeatOffset.text = "0";
|
||||
|
||||
// Convert ms to s.
|
||||
var newOffset = Convert.ToSingle(FirstBeatOffset.text) / 1000f;
|
||||
|
||||
// Limit decimal places to 4.
|
||||
newOffset = (float)System.Math.Round(newOffset, 4);
|
||||
|
||||
GameManager.instance.Beatmap.firstBeatOffset = newOffset;
|
||||
|
||||
UpdateOffsetText();
|
||||
}
|
||||
|
||||
public void ClearTempoTimeline()
|
||||
{
|
||||
foreach (TempoTimelineObj tempoTimelineObj in tempoTimelineObjs)
|
||||
{
|
||||
Destroy(tempoTimelineObj.gameObject);
|
||||
}
|
||||
tempoTimelineObjs.Clear();
|
||||
}
|
||||
|
||||
public void AddTempoChange(bool create, DynamicBeatmap.TempoChange tempoChange_ = null)
|
||||
{
|
||||
GameObject tempoChange = Instantiate(RefTempoChange.gameObject, this.transform);
|
||||
|
||||
tempoChange.transform.GetChild(0).GetComponent<Image>().color = EditorTheme.theme.properties.TempoLayerCol.Hex2RGB();
|
||||
tempoChange.transform.GetChild(1).GetComponent<Image>().color = EditorTheme.theme.properties.TempoLayerCol.Hex2RGB();
|
||||
tempoChange.transform.GetChild(2).GetComponent<TMP_Text>().color = EditorTheme.theme.properties.TempoLayerCol.Hex2RGB();
|
||||
|
||||
tempoChange.SetActive(true);
|
||||
|
||||
TempoTimelineObj tempoTimelineObj = tempoChange.GetComponent<TempoTimelineObj>();
|
||||
|
||||
if (create == true)
|
||||
{
|
||||
tempoChange.transform.position = new Vector3(Editor.instance.EditorCamera.ScreenToWorldPoint(Input.mousePosition).x + 0.08f, tempoChange.transform.position.y);
|
||||
tempoChange.transform.localPosition = new Vector3(Starpelly.Mathp.Round2Nearest(tempoChange.transform.localPosition.x, Timeline.SnapInterval()), tempoChange.transform.localPosition.y);
|
||||
|
||||
DynamicBeatmap.TempoChange tempoC = new DynamicBeatmap.TempoChange();
|
||||
tempoC.beat = tempoChange.transform.localPosition.x;
|
||||
tempoC.tempo = GameManager.instance.Beatmap.bpm;
|
||||
|
||||
tempoTimelineObj.tempoChange = tempoC;
|
||||
GameManager.instance.Beatmap.tempoChanges.Add(tempoC);
|
||||
}
|
||||
else
|
||||
{
|
||||
tempoChange.transform.localPosition = new Vector3(tempoChange_.beat, tempoChange.transform.localPosition.y);
|
||||
|
||||
tempoTimelineObj.tempoChange = tempoChange_;
|
||||
}
|
||||
|
||||
tempoTimelineObjs.Add(tempoTimelineObj);
|
||||
|
||||
Timeline.instance.FitToSong();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c80527f878ac1594bb0eedc6884a3a5f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -13,6 +13,7 @@ namespace HeavenStudio.Editor.Track
|
|||
[Header("Components")]
|
||||
[SerializeField] private TMP_Text sectionLabel;
|
||||
[SerializeField] private GameObject chartLine;
|
||||
[SerializeField] private SectionDialog sectionDialog;
|
||||
|
||||
public DynamicBeatmap.ChartSection chartSection;
|
||||
|
||||
|
@ -27,7 +28,7 @@ namespace HeavenStudio.Editor.Track
|
|||
UpdateLabel();
|
||||
}
|
||||
|
||||
private void UpdateLabel()
|
||||
public void UpdateLabel()
|
||||
{
|
||||
sectionLabel.text = chartSection.sectionName;
|
||||
}
|
||||
|
@ -47,8 +48,8 @@ namespace HeavenStudio.Editor.Track
|
|||
{
|
||||
if (Timeline.instance.timelineState.currentState == Timeline.CurrentTimelineState.State.ChartSection)
|
||||
{
|
||||
GameManager.instance.Beatmap.beatmapSections.Remove(chartSection);
|
||||
DeleteObj();
|
||||
sectionDialog.SetSectionObj(this);
|
||||
sectionDialog.SwitchSectionDialog();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,7 +83,10 @@ namespace HeavenStudio.Editor.Track
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue