mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 08:17:38 +02:00
Autoplay began
This commit is contained in:
@ -7,19 +7,31 @@ namespace RhythmHeavenMania.Editor.Commands
|
||||
{
|
||||
public class Selection : IAction
|
||||
{
|
||||
List<TimelineEventObj> eventObjs;
|
||||
|
||||
public Selection(List<TimelineEventObj> eventObjs)
|
||||
{
|
||||
this.eventObjs = eventObjs;
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public void Redo()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
for (int i = 0; i < eventObjs.Count; i++)
|
||||
{
|
||||
Selections.instance.ShiftClickSelect(eventObjs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
for (int i = 0; i < eventObjs.Count; i++)
|
||||
{
|
||||
Selections.instance.ShiftClickSelect(eventObjs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,7 +81,6 @@ namespace RhythmHeavenMania.Editor.Commands
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
|
||||
for (int i = 0; i < pos.Count; i++)
|
||||
{
|
||||
EnsureEventObj(i);
|
||||
@ -86,10 +97,36 @@ namespace RhythmHeavenMania.Editor.Commands
|
||||
}
|
||||
}
|
||||
|
||||
public class Place : IAction
|
||||
{
|
||||
TimelineEventObj eventObj;
|
||||
|
||||
public Place(TimelineEventObj eventObj)
|
||||
{
|
||||
this.eventObj = eventObj;
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
}
|
||||
|
||||
public void Redo()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
Selections.instance.Deselect(eventObj);
|
||||
Timeline.instance.DestroyEventObject(eventObj.entity);
|
||||
// Beatmap.Entity e = deletedObjs[i].entity;
|
||||
// Timeline.instance.AddEventObject(e.datamodel, false, new Vector3(e.beat, -e.track * Timeline.instance.LayerHeight()), e, true, e.eventObj.eventObjID);
|
||||
}
|
||||
}
|
||||
|
||||
public class Deletion : IAction
|
||||
{
|
||||
List<TimelineEventObj> eventObjs;
|
||||
|
||||
List<TimelineEventObj> deletedObjs;
|
||||
|
||||
public Deletion(List<TimelineEventObj> eventObjs)
|
||||
|
@ -60,11 +60,11 @@ namespace RhythmHeavenMania.Editor
|
||||
GameIcon_.name = EventCaller.instance.minigames[i].displayName;
|
||||
}
|
||||
|
||||
Tooltip.AddTooltip(NewBTN.gameObject, "New");
|
||||
Tooltip.AddTooltip(OpenBTN.gameObject, "Open");
|
||||
Tooltip.AddTooltip(SaveBTN.gameObject, "Save");
|
||||
Tooltip.AddTooltip(UndoBTN.gameObject, "Undo");
|
||||
Tooltip.AddTooltip(RedoBTN.gameObject, "Redo");
|
||||
Tooltip.AddTooltip(NewBTN.gameObject, "New <color=#adadad>[Ctrl+N]</color>");
|
||||
Tooltip.AddTooltip(OpenBTN.gameObject, "Open <color=#adadad>[Ctrl+O]</color>");
|
||||
Tooltip.AddTooltip(SaveBTN.gameObject, "Save Project <color=#adadad>[Ctrl+S]</color>\nSave Project As <color=#adadad>[Ctrl+Alt+S]</color>");
|
||||
Tooltip.AddTooltip(UndoBTN.gameObject, "Undo <color=#adadad>[Ctrl+Z]</color>");
|
||||
Tooltip.AddTooltip(RedoBTN.gameObject, "Redo <color=#adadad>[Ctrl+Y or Ctrl+Shift+Z]</color>");
|
||||
}
|
||||
|
||||
public void Update()
|
||||
@ -100,6 +100,21 @@ namespace RhythmHeavenMania.Editor
|
||||
else
|
||||
RedoBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Z))
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
CommandManager.instance.Redo();
|
||||
else
|
||||
CommandManager.instance.Undo();
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Y))
|
||||
{
|
||||
CommandManager.instance.Redo();
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetMouseButtonUp(0) && Timeline.instance.CheckIfMouseInTimeline())
|
||||
{
|
||||
List<TimelineEventObj> selectedEvents = Timeline.instance.eventObjs.FindAll(c => c.selected == true && c.eligibleToMove == true);
|
||||
@ -134,10 +149,12 @@ namespace RhythmHeavenMania.Editor
|
||||
public void DebugSave()
|
||||
{
|
||||
// temp
|
||||
#if UNITY_EDITOR
|
||||
string path = UnityEditor.AssetDatabase.GetAssetPath(GameManager.instance.txt);
|
||||
path = Application.dataPath.Remove(Application.dataPath.Length - 6, 6) + path;
|
||||
System.IO.File.WriteAllText(path, JsonConvert.SerializeObject(GameManager.instance.Beatmap));
|
||||
Debug.Log("Saved to " + path);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void SetGameEventTitle(string txt)
|
||||
|
@ -159,14 +159,18 @@ namespace RhythmHeavenMania.Editor
|
||||
if (Timeline.instance.CheckIfMouseInTimeline() && dragTimes < 1)
|
||||
{
|
||||
dragTimes++;
|
||||
|
||||
TimelineEventObj eventObj = new TimelineEventObj();
|
||||
|
||||
if (currentEventIndex == 0)
|
||||
{
|
||||
Timeline.instance.AddEventObject($"gameManager/switchGame/{mg.name}", true, new Vector3(0, 0), null, true);
|
||||
eventObj = Timeline.instance.AddEventObject($"gameManager/switchGame/{mg.name}", true, new Vector3(0, 0), null, true, Timeline.RandomID());
|
||||
}
|
||||
else
|
||||
{
|
||||
Timeline.instance.AddEventObject(mg.name + "/" + mg.actions[currentEventIndex - 1].actionName, true, new Vector3(0, 0), null, true);
|
||||
eventObj = Timeline.instance.AddEventObject(mg.name + "/" + mg.actions[currentEventIndex - 1].actionName, true, new Vector3(0, 0), null, true, Timeline.RandomID());
|
||||
}
|
||||
CommandManager.instance.Execute(new Commands.Place(eventObj));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,8 @@ namespace RhythmHeavenMania.Editor
|
||||
{
|
||||
DeselectAll();
|
||||
eventsSelected.Add(eventToAdd);
|
||||
|
||||
// CommandManager.instance.Execute(new Commands.Selection(new List<TimelineEventObj>() { eventToAdd } ));
|
||||
}
|
||||
|
||||
public void ShiftClickSelect(TimelineEventObj eventToAdd)
|
||||
|
@ -33,10 +33,11 @@ namespace RhythmHeavenMania.Editor
|
||||
private RectTransform TimelineSongPosLine;
|
||||
|
||||
[Header("Timeline Playbar")]
|
||||
[SerializeField] private Button PlayBTN;
|
||||
[SerializeField] private Button PauseBTN;
|
||||
[SerializeField] private Button StopBTN;
|
||||
[SerializeField] private Button MetronomeBTN;
|
||||
public Button PlayBTN;
|
||||
public Button PauseBTN;
|
||||
public Button StopBTN;
|
||||
public Button MetronomeBTN;
|
||||
public Button AutoplayBTN;
|
||||
|
||||
public static Timeline instance { get; private set; }
|
||||
|
||||
@ -51,7 +52,7 @@ namespace RhythmHeavenMania.Editor
|
||||
var entity = GameManager.instance.Beatmap.entities[i];
|
||||
var e = GameManager.instance.Beatmap.entities[i];
|
||||
|
||||
AddEventObject(e.datamodel, false, new Vector3(e.beat, -e.track * LayerHeight()), e, false, Starpelly.Random.Strings.RandomString(Starpelly.Enums.Strings.StringType.Alphanumeric, 128));
|
||||
AddEventObject(e.datamodel, false, new Vector3(e.beat, -e.track * LayerHeight()), e, false, RandomID());
|
||||
}
|
||||
|
||||
TimelineSlider.GetChild(0).GetComponent<Image>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB();
|
||||
@ -91,16 +92,36 @@ namespace RhythmHeavenMania.Editor
|
||||
Conductor.instance.metronome = false;
|
||||
}
|
||||
});
|
||||
AutoplayBTN.onClick.AddListener(delegate
|
||||
{
|
||||
if (!GameManager.instance.autoplay)
|
||||
{
|
||||
AutoplayBTN.GetComponent<Animator>().Play("Idle", 0, 0);
|
||||
GameManager.instance.autoplay = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoplayBTN.GetComponent<Animator>().Play("Disabled", 0, 0);
|
||||
GameManager.instance.autoplay = false;
|
||||
}
|
||||
});
|
||||
|
||||
Tooltip.AddTooltip(PlayBTN.gameObject, "Play <color=#adadad>[Space]</color>");
|
||||
Tooltip.AddTooltip(PauseBTN.gameObject, "Pause <color=#adadad>[Shift + Space]</color>");
|
||||
Tooltip.AddTooltip(StopBTN.gameObject, "Stop <color=#adadad>[Space]</color>");
|
||||
|
||||
Tooltip.AddTooltip(MetronomeBTN.gameObject, "Metronome");
|
||||
Tooltip.AddTooltip(AutoplayBTN.gameObject, "Autoplay");
|
||||
|
||||
SetTimeButtonColors(true, false, false);
|
||||
MetronomeBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
|
||||
}
|
||||
|
||||
public static string RandomID()
|
||||
{
|
||||
return Starpelly.Random.Strings.RandomString(Starpelly.Enums.Strings.StringType.Alphanumeric, 128);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void Update()
|
||||
|
Reference in New Issue
Block a user