From fb39a7c5fe92a28132fa5bf47ab8d8916aaefee6 Mon Sep 17 00:00:00 2001
From: minenice55 <star.elementa@gmail.com>
Date: Mon, 4 Jul 2022 12:57:19 -0400
Subject: [PATCH] copy entities, prep settings menu

---
 Assets/Scenes/Editor.unity                    | 58 +++++++++++++++----
 Assets/Scripts/LevelEditor/Editor.cs          |  7 ++-
 .../Scripts/LevelEditor/SettingsDialog.meta   |  8 +++
 .../SettingsDialog/SettingsDialog.cs          | 27 +++++++++
 .../SettingsDialog/SettingsDialog.cs.meta     | 11 ++++
 .../Scripts/LevelEditor/Timeline/Timeline.cs  |  8 +++
 .../LevelEditor/Timeline/TimelineEventObj.cs  |  9 +++
 7 files changed, 115 insertions(+), 13 deletions(-)
 create mode 100644 Assets/Scripts/LevelEditor/SettingsDialog.meta
 create mode 100644 Assets/Scripts/LevelEditor/SettingsDialog/SettingsDialog.cs
 create mode 100644 Assets/Scripts/LevelEditor/SettingsDialog/SettingsDialog.cs.meta

diff --git a/Assets/Scenes/Editor.unity b/Assets/Scenes/Editor.unity
index 2827a2537..3c5d47101 100644
--- a/Assets/Scenes/Editor.unity
+++ b/Assets/Scenes/Editor.unity
@@ -205,7 +205,19 @@ MonoBehaviour:
   m_TargetGraphic: {fileID: 3236233}
   m_OnClick:
     m_PersistentCalls:
-      m_Calls: []
+      m_Calls:
+      - m_Target: {fileID: 1946344932}
+        m_TargetAssemblyTypeName: HeavenStudio.Editor.SettingsDialog, Assembly-CSharp
+        m_MethodName: SwitchSettingsDialog
+        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 &3236233
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -12476,8 +12488,8 @@ MonoBehaviour:
   m_TargetGraphic: {fileID: 1589389272}
   m_HandleRect: {fileID: 1589389271}
   m_Direction: 2
-  m_Value: -0.0000011884493
-  m_Size: 0.5289384
+  m_Value: 1
+  m_Size: 0.5293149
   m_NumberOfSteps: 0
   m_OnValueChanged:
     m_PersistentCalls:
@@ -14021,7 +14033,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 1, y: 0}
-  m_AnchoredPosition: {x: -0, y: 28.925}
+  m_AnchoredPosition: {x: 0, y: 28.924988}
   m_SizeDelta: {x: 0, y: 28.927}
   m_Pivot: {x: 0, y: 1}
 --- !u!114 &1037563075
@@ -15595,7 +15607,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0.5}
   m_AnchorMax: {x: 1, y: 0.5}
-  m_AnchoredPosition: {x: 0, y: 361.05347}
+  m_AnchoredPosition: {x: 0, y: 129.94681}
   m_SizeDelta: {x: 0, y: 491}
   m_Pivot: {x: 0.5, y: 1}
 --- !u!114 &1154875944
@@ -18122,11 +18134,11 @@ MonoBehaviour:
   UndoBTN: {fileID: 1747099763}
   RedoBTN: {fileID: 2131880462}
   MusicSelectBTN: {fileID: 1055877579}
-  EditorSettingsBTN: {fileID: 3236232}
-  EditorThemeBTN: {fileID: 528192061}
   FullScreenBTN: {fileID: 151246938}
   TempoFinderBTN: {fileID: 1478799966}
   SnapDiagBTN: {fileID: 1201441977}
+  EditorThemeBTN: {fileID: 528192061}
+  EditorSettingsBTN: {fileID: 3236232}
   tooltipText: {fileID: 1196204504}
   discordDuringTesting: 0
   canSelect: 1
@@ -19752,7 +19764,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: 0, y: -27.594}
+  m_AnchoredPosition: {x: 0, y: -27.593994}
   m_SizeDelta: {x: 1440.022, y: -113.04}
   m_Pivot: {x: 0, y: 0.5}
 --- !u!114 &1527251881
@@ -23422,7 +23434,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: -0, y: -84.09494}
+  m_AnchoredPosition: {x: 0, y: -84.09494}
   m_SizeDelta: {x: 320, y: -113.02}
   m_Pivot: {x: 0, y: 1}
 --- !u!1 &1852819572
@@ -24277,6 +24289,7 @@ GameObject:
   serializedVersion: 6
   m_Component:
   - component: {fileID: 1946344931}
+  - component: {fileID: 1946344932}
   m_Layer: 5
   m_Name: SettingsMenu
   m_TagString: Untagged
@@ -24306,6 +24319,19 @@ RectTransform:
   m_AnchoredPosition: {x: 0, y: 0}
   m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
+--- !u!114 &1946344932
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1946344930}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: d82cc04699de2e54483ca0e0468d9ed2, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  settingsMenu: {fileID: 1946344930}
 --- !u!1 &1946352456
 GameObject:
   m_ObjectHideFlags: 0
@@ -24388,7 +24414,19 @@ MonoBehaviour:
   m_TargetGraphic: {fileID: 1946352459}
   m_OnClick:
     m_PersistentCalls:
-      m_Calls: []
+      m_Calls:
+      - m_Target: {fileID: 1946344932}
+        m_TargetAssemblyTypeName: HeavenStudio.Editor.SettingsDialog, Assembly-CSharp
+        m_MethodName: SwitchSettingsDialog
+        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 &1946352459
 MonoBehaviour:
   m_ObjectHideFlags: 0
diff --git a/Assets/Scripts/LevelEditor/Editor.cs b/Assets/Scripts/LevelEditor/Editor.cs
index fb053576e..b4d70b99f 100644
--- a/Assets/Scripts/LevelEditor/Editor.cs
+++ b/Assets/Scripts/LevelEditor/Editor.cs
@@ -48,12 +48,13 @@ namespace HeavenStudio.Editor
         [SerializeField] private Button UndoBTN;
         [SerializeField] private Button RedoBTN;
         [SerializeField] private Button MusicSelectBTN;
-        [SerializeField] private Button EditorSettingsBTN;
-        [SerializeField] private Button EditorThemeBTN;
         [SerializeField] private Button FullScreenBTN;
         [SerializeField] private Button TempoFinderBTN;
         [SerializeField] private Button SnapDiagBTN;
 
+        [SerializeField] private Button EditorThemeBTN;
+        [SerializeField] private Button EditorSettingsBTN;
+
         [Header("Tooltip")]
         public TMP_Text tooltipText;
 
@@ -102,12 +103,12 @@ namespace HeavenStudio.Editor
             Tooltip.AddTooltip(UndoBTN.gameObject, "Undo <color=#adadad>[Ctrl+Z]</color>");
             Tooltip.AddTooltip(RedoBTN.gameObject, "Redo <color=#adadad>[Ctrl+Y or Ctrl+Shift+Z]</color>");
             Tooltip.AddTooltip(MusicSelectBTN.gameObject, "Music Select");
-            Tooltip.AddTooltip(EditorSettingsBTN.gameObject, "Editor Settings <color=#adadad>[Ctrl+Shift+O]</color>");
             Tooltip.AddTooltip(EditorThemeBTN.gameObject, "Editor Theme");
             Tooltip.AddTooltip(FullScreenBTN.gameObject, "Preview <color=#adadad>[Tab]</color>");
             Tooltip.AddTooltip(TempoFinderBTN.gameObject, "Tempo Finder");
             Tooltip.AddTooltip(SnapDiagBTN.gameObject, "Snap Settings");
 
+            Tooltip.AddTooltip(EditorSettingsBTN.gameObject, "Editor Settings <color=#adadad>[Ctrl+Shift+O]</color>");
             UpdateEditorStatus(true);
         }
 
diff --git a/Assets/Scripts/LevelEditor/SettingsDialog.meta b/Assets/Scripts/LevelEditor/SettingsDialog.meta
new file mode 100644
index 000000000..ae50f8391
--- /dev/null
+++ b/Assets/Scripts/LevelEditor/SettingsDialog.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 907f7d1eb5d90af408aa531ea366e63e
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/Assets/Scripts/LevelEditor/SettingsDialog/SettingsDialog.cs b/Assets/Scripts/LevelEditor/SettingsDialog/SettingsDialog.cs
new file mode 100644
index 000000000..c19c60442
--- /dev/null
+++ b/Assets/Scripts/LevelEditor/SettingsDialog/SettingsDialog.cs
@@ -0,0 +1,27 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using HeavenStudio.Editor.Track;
+
+using TMPro;
+
+namespace HeavenStudio.Editor 
+{
+    public class SettingsDialog : MonoBehaviour
+    {
+        [SerializeField] private GameObject settingsMenu;
+
+        private void Start() {}
+
+        public void SwitchSettingsDialog()
+        {
+            if(settingsMenu.activeSelf) {
+                settingsMenu.SetActive(false);
+            } else {
+                settingsMenu.SetActive(true);
+            }
+        }
+
+        private void Update() {}
+    }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/LevelEditor/SettingsDialog/SettingsDialog.cs.meta b/Assets/Scripts/LevelEditor/SettingsDialog/SettingsDialog.cs.meta
new file mode 100644
index 000000000..90f131b73
--- /dev/null
+++ b/Assets/Scripts/LevelEditor/SettingsDialog/SettingsDialog.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d82cc04699de2e54483ca0e0468d9ed2
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/Assets/Scripts/LevelEditor/Timeline/Timeline.cs b/Assets/Scripts/LevelEditor/Timeline/Timeline.cs
index e1dc268e6..05dc3532a 100644
--- a/Assets/Scripts/LevelEditor/Timeline/Timeline.cs
+++ b/Assets/Scripts/LevelEditor/Timeline/Timeline.cs
@@ -611,6 +611,14 @@ namespace HeavenStudio.Editor.Track
             return eventObj;
         }
 
+        public TimelineEventObj CopyEventObject(Beatmap.Entity e)
+        {
+            Beatmap.Entity clone = (Beatmap.Entity) e.Clone();
+            TimelineEventObj dup = AddEventObject(clone.datamodel, false, new Vector3(clone.beat, -clone.track * Timeline.instance.LayerHeight()), clone, true, RandomID());
+
+            return dup;
+        }
+
         public void DestroyEventObject(Beatmap.Entity entity)
         {
             if (EventParameterManager.instance.entity == entity)
diff --git a/Assets/Scripts/LevelEditor/Timeline/TimelineEventObj.cs b/Assets/Scripts/LevelEditor/Timeline/TimelineEventObj.cs
index 7d736dd19..cbf557fd9 100644
--- a/Assets/Scripts/LevelEditor/Timeline/TimelineEventObj.cs
+++ b/Assets/Scripts/LevelEditor/Timeline/TimelineEventObj.cs
@@ -41,6 +41,7 @@ namespace HeavenStudio.Editor.Track
         private bool resizingLeft;
         private bool resizingRight;
         private bool inResizeRegion;
+        private bool wasDuplicated;
         public Vector2 lastMovePos;
         public bool isCreating;
         public string eventObjID;
@@ -167,6 +168,13 @@ namespace HeavenStudio.Editor.Track
 
                 if (Timeline.instance.eventObjs.FindAll(c => c.moving).Count > 0 && selected)
                 {
+                    //duplicate the entity if holding alt or r-click
+                    if ((!wasDuplicated) && (Input.GetKey(KeyCode.LeftAlt) || Input.GetMouseButton(1)))
+                    {
+                        wasDuplicated = true;
+                        var te = Timeline.instance.CopyEventObject(entity);
+                    }
+
                     Vector3 mousePos = Editor.instance.EditorCamera.ScreenToWorldPoint(Input.mousePosition);
 
                     lastPos_ = transform.localPosition;
@@ -291,6 +299,7 @@ namespace HeavenStudio.Editor.Track
                 }
 
                 moving = false;
+                wasDuplicated = false;
 
                 Cancel();
                 if (isCreating == true)