143 lines
4.8 KiB
C#
143 lines
4.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics.Eventing.Reader;
|
|
using System.Linq;
|
|
using Ichni;
|
|
using Ichni.Editor;
|
|
using Ichni.RhythmGame;
|
|
using Sirenix.OdinInspector;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
using UnityEngine.UI;
|
|
|
|
public partial class GraphicalFlexibleFloatWindow : MovableWindow
|
|
{
|
|
public Button addNewUnitButton;
|
|
public FlexibleFloatTab unitPrefab;
|
|
public IBaseElement connectedBaseElement;
|
|
public List<FlexibleFloatTab> unitList;
|
|
public string parameterName;
|
|
public UnityAction ApplyParameters;
|
|
|
|
|
|
public float songTime => EditorManager.instance.songInformation.songTime;
|
|
public float songBeat => EditorManager.instance.songInformation.songBeat;
|
|
public float beatmapStartTime => -EditorManager.instance.songInformation.delay;
|
|
public float timePerBeat => 60f / EditorManager.instance.songInformation.bpm;
|
|
|
|
public int BeatDeviver = 100;
|
|
public void Initialize(IBaseElement baseElement, string title, FlexibleFloat[] FlexibleFloats, string[] Subtitles)
|
|
{
|
|
scalevalue = 5;
|
|
transform.localScale = Vector3.zero;
|
|
this.connectedBaseElement = baseElement;
|
|
this.title.text = title;
|
|
unitList = new List<FlexibleFloatTab>();
|
|
for (int i = 0; i <= FlexibleFloats.Length - 1; i++)
|
|
{
|
|
AddUnit(FlexibleFloats[i], Subtitles[i]);
|
|
}
|
|
|
|
closeButton.onClick.AddListener(Quit);
|
|
StartCoroutine(WindowAnim.ShowPanelOnScale(gameObject));
|
|
ApplyParameters = () =>
|
|
{
|
|
|
|
|
|
for (int i = 0; i <= unitList.Count - 1; i++)
|
|
{
|
|
unitList[i].flexibleFloat.Sort();
|
|
}
|
|
//Dangered
|
|
//connectedBaseElement.SetParameter(parameterName, unitList.Select(unit => unit.flexibleFloat).ToArray());
|
|
};
|
|
}
|
|
public void AddUnit(FlexibleFloat flexibleFloat, string Subtitle)
|
|
{
|
|
flexibleFloat.Sort();
|
|
FlexibleFloatTab flexibleFloatTab = Instantiate(unitPrefab, windowRect);
|
|
flexibleFloatTab.FatherWindow = this;
|
|
unitList.Add(flexibleFloatTab);
|
|
flexibleFloatTab.Initialize(flexibleFloat, Subtitle);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Quit()
|
|
{
|
|
ApplyParameters();
|
|
//StartCoroutine(WindowAnim.HidePanel(gameObject, true));
|
|
Destroy(gameObject);
|
|
}
|
|
public float scalevalue;
|
|
public void CurveScale(string Rawvalue)
|
|
{
|
|
float value = float.Parse(Rawvalue);
|
|
scalevalue = value;
|
|
foreach (FlexibleFloatTab i in unitList)
|
|
{
|
|
i.CurveScale(value);
|
|
}
|
|
}
|
|
}
|
|
|
|
public partial class GraphicalFlexibleFloatWindow
|
|
{
|
|
[Title("AnimEditor")]
|
|
public TMP_InputField StartText;
|
|
public TMP_InputField EndText;
|
|
public TMP_InputField StartValueText;
|
|
public TMP_InputField EndValueText;
|
|
public EventPoint ConnectedPoint;
|
|
public TMP_Dropdown animationCurveTypeDropdown;
|
|
public GameObject VisibleArea;
|
|
|
|
|
|
public void Removed()
|
|
{
|
|
if (ConnectedPoint != null)
|
|
{
|
|
ConnectedPoint.FatherTab.remoceAnim(ConnectedPoint.animatedFloat);
|
|
ConnectedPoint.FatherTab.eventPoints.Remove(ConnectedPoint);
|
|
if (ConnectedPoint.LastEventPoint != null)
|
|
{
|
|
ConnectedPoint.LastEventPoint.NextEventPoint = ConnectedPoint.NextEventPoint;
|
|
if (ConnectedPoint.LastEventPoint.NextEventPoint != null) ConnectedPoint.LastEventPoint.NextEventPoint.ReDraw(scalevalue);
|
|
}
|
|
|
|
if (ConnectedPoint.NextEventPoint != null)
|
|
{
|
|
ConnectedPoint.NextEventPoint.LastEventPoint = ConnectedPoint.LastEventPoint;
|
|
if (ConnectedPoint.NextEventPoint.LastEventPoint != null) ConnectedPoint.NextEventPoint.LastEventPoint.ReDraw(scalevalue);
|
|
}
|
|
|
|
//Destroy(ConnectedPoint.animatedFloat);
|
|
|
|
VisibleArea.SetActive(false);
|
|
|
|
Destroy(ConnectedPoint.gameObject);
|
|
ApplyParameters();
|
|
}
|
|
}
|
|
public void ChangeValue()
|
|
{
|
|
if (ConnectedPoint != null)
|
|
{
|
|
float startTime = float.Parse(StartText.text);
|
|
float endTime = float.Parse(EndText.text);
|
|
float startValue = float.Parse(StartValueText.text);
|
|
float endValue = float.Parse(EndValueText.text);
|
|
|
|
ConnectedPoint.animatedFloat.startTime = startTime;
|
|
ConnectedPoint.animatedFloat.endTime = endTime;
|
|
ConnectedPoint.animatedFloat.startValue = startValue;
|
|
ConnectedPoint.animatedFloat.endValue = endValue;
|
|
ConnectedPoint.animatedFloat.animationCurveType = (AnimationCurveType)animationCurveTypeDropdown.value;
|
|
ConnectedPoint.Initialize(ConnectedPoint.animatedFloat);
|
|
ConnectedPoint.ReDraw(scalevalue);
|
|
}
|
|
}
|
|
} |