From 2a8da0a551d852322cd4b151235688732435a625 Mon Sep 17 00:00:00 2001 From: Carson Kompon Date: Fri, 25 Feb 2022 22:41:32 -0500 Subject: [PATCH 1/2] Added New (CTRL+N) Button Allows you to call GameManager.LoadRemix("") to initialize a blank remix at bpm 120. The New button (or CTRL+N) calls Editor.NewRemix(); --- Assets/Scenes/Editor.unity | 14 +++++++++++++- Assets/Scripts/GameManager.cs | 22 +++++++++++++++++----- Assets/Scripts/LevelEditor/Editor.cs | 8 ++++++++ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/Assets/Scenes/Editor.unity b/Assets/Scenes/Editor.unity index 064a71dc..92c808b6 100644 --- a/Assets/Scenes/Editor.unity +++ b/Assets/Scenes/Editor.unity @@ -16383,7 +16383,19 @@ MonoBehaviour: m_TargetGraphic: {fileID: 1683100751} m_OnClick: m_PersistentCalls: - m_Calls: [] + m_Calls: + - m_Target: {fileID: 1423699437} + m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.Editor, Assembly-CSharp + m_MethodName: NewRemix + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 --- !u!114 &1683100751 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 911c2b7b..de6aa917 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -73,9 +73,7 @@ namespace RhythmHeavenMania } else { - Beatmap = new Beatmap(); - Beatmap.bpm = 120f; - Beatmap.firstBeatOffset = 0f; + NewRemix(); } SortEventsList(); @@ -106,11 +104,25 @@ namespace RhythmHeavenMania } } - public void LoadRemix(string json) + public void NewRemix() + { + Beatmap = new Beatmap(); + Beatmap.bpm = 120f; + Beatmap.firstBeatOffset = 0f; + } + + public void LoadRemix(string json = "") { SortEventsList(); - Beatmap = JsonConvert.DeserializeObject(json); + if (json != "") + { + Beatmap = JsonConvert.DeserializeObject(json); + } + else + { + NewRemix(); + } Conductor.instance.SetBpm(Beatmap.bpm); Conductor.instance.firstBeatOffset = Beatmap.firstBeatOffset; Stop(0); diff --git a/Assets/Scripts/LevelEditor/Editor.cs b/Assets/Scripts/LevelEditor/Editor.cs index 792ffd33..26682de1 100644 --- a/Assets/Scripts/LevelEditor/Editor.cs +++ b/Assets/Scripts/LevelEditor/Editor.cs @@ -319,6 +319,14 @@ namespace RhythmHeavenMania.Editor } } + public void NewRemix() + { + GameManager.instance.LoadRemix(""); + Timeline.instance.LoadRemix(); + Timeline.instance.TempoInfo.UpdateStartingBPMText(); + Timeline.instance.TempoInfo.UpdateOffsetText(); + } + public void OpenRemix() { var extensions = new[] From 4ebcdd038dfe5875161d4e4917dda23a53704fbe Mon Sep 17 00:00:00 2001 From: Carson Kompon Date: Fri, 25 Feb 2022 22:48:44 -0500 Subject: [PATCH 2/2] Preventing even more code re-use Editor.NewRemix() from my last commit is now Editor.LoadRemix(json) and is called within Editor.LoadRemix(). The "New" button new calls Editor.LoadRemix(""); --- Assets/Scenes/Editor.unity | 4 ++-- Assets/Scripts/LevelEditor/Editor.cs | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Assets/Scenes/Editor.unity b/Assets/Scenes/Editor.unity index 92c808b6..d10dd0e0 100644 --- a/Assets/Scenes/Editor.unity +++ b/Assets/Scenes/Editor.unity @@ -16386,8 +16386,8 @@ MonoBehaviour: m_Calls: - m_Target: {fileID: 1423699437} m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.Editor, Assembly-CSharp - m_MethodName: NewRemix - m_Mode: 1 + m_MethodName: LoadRemix + m_Mode: 5 m_Arguments: m_ObjectArgument: {fileID: 0} m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine diff --git a/Assets/Scripts/LevelEditor/Editor.cs b/Assets/Scripts/LevelEditor/Editor.cs index 26682de1..11be7854 100644 --- a/Assets/Scripts/LevelEditor/Editor.cs +++ b/Assets/Scripts/LevelEditor/Editor.cs @@ -319,9 +319,9 @@ namespace RhythmHeavenMania.Editor } } - public void NewRemix() + public void LoadRemix(string json = "") { - GameManager.instance.LoadRemix(""); + GameManager.instance.LoadRemix(json); Timeline.instance.LoadRemix(); Timeline.instance.TempoInfo.UpdateStartingBPMText(); Timeline.instance.TempoInfo.UpdateOffsetText(); @@ -356,10 +356,7 @@ namespace RhythmHeavenMania.Editor stream.CopyTo(ms); bytes = ms.ToArray(); string json = Encoding.Default.GetString(bytes); - GameManager.instance.LoadRemix(json); - Timeline.instance.LoadRemix(); - Timeline.instance.TempoInfo.UpdateStartingBPMText(); - Timeline.instance.TempoInfo.UpdateOffsetText(); + LoadRemix(json); } } }