From a516e9199f714a2be5488d2ee4d063c3430f3c80 Mon Sep 17 00:00:00 2001
From: Mike Welsh <mwelsh@gmail.com>
Date: Tue, 5 Mar 2024 23:21:57 -0800
Subject: [PATCH] Remove DynamicTools; fix pause menu on HTML5

Calls intended for `ArrayTools.clone` were being routed to
`DynamicTools.clone` due to the order of `using` statements in
`imports.hx`. This caused the pause menu to break due to arrays
becoming fubar (missing length property).

Using `DynamicTools` is a little dangerous, so remove it in favor
of calling `Reflect.copy` directly.
---
 source/funkin/import.hx                            |  1 -
 .../funkin/ui/debug/charting/ChartEditorState.hx   |  4 ++--
 source/funkin/util/tools/DynamicTools.hx           | 14 --------------
 3 files changed, 2 insertions(+), 17 deletions(-)
 delete mode 100644 source/funkin/util/tools/DynamicTools.hx

diff --git a/source/funkin/import.hx b/source/funkin/import.hx
index 02055d4ed..250de99cb 100644
--- a/source/funkin/import.hx
+++ b/source/funkin/import.hx
@@ -13,7 +13,6 @@ using Lambda;
 using StringTools;
 using funkin.util.tools.ArraySortTools;
 using funkin.util.tools.ArrayTools;
-using funkin.util.tools.DynamicTools;
 using funkin.util.tools.FloatTools;
 using funkin.util.tools.Int64Tools;
 using funkin.util.tools.IntTools;
diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx
index b9e412b36..0e1aa4f4d 100644
--- a/source/funkin/ui/debug/charting/ChartEditorState.hx
+++ b/source/funkin/ui/debug/charting/ChartEditorState.hx
@@ -4530,14 +4530,14 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
                 {
                   // Create an event and place it in the chart.
                   // TODO: Figure out configuring event data.
-                  var newEventData:SongEventData = new SongEventData(cursorSnappedMs, eventKindToPlace, eventDataToPlace.clone());
+                  var newEventData:SongEventData = new SongEventData(cursorSnappedMs, eventKindToPlace, Reflect.copy(eventDataToPlace));
 
                   performCommand(new AddEventsCommand([newEventData], FlxG.keys.pressed.CONTROL));
                 }
                 else
                 {
                   // Create a note and place it in the chart.
-                  var newNoteData:SongNoteData = new SongNoteData(cursorSnappedMs, cursorColumn, 0, noteKindToPlace.clone());
+                  var newNoteData:SongNoteData = new SongNoteData(cursorSnappedMs, cursorColumn, 0, Reflect.copy(noteKindToPlace));
 
                   performCommand(new AddNotesCommand([newNoteData], FlxG.keys.pressed.CONTROL));
 
diff --git a/source/funkin/util/tools/DynamicTools.hx b/source/funkin/util/tools/DynamicTools.hx
deleted file mode 100644
index 47501ea22..000000000
--- a/source/funkin/util/tools/DynamicTools.hx
+++ /dev/null
@@ -1,14 +0,0 @@
-package funkin.util.tools;
-
-class DynamicTools
-{
-  /**
-   * Creates a full clone of the input `Dynamic`. Only guaranteed to work on anonymous structures.
-   * @param input The `Dynamic` to clone.
-   * @return A clone of the input `Dynamic`.
-   */
-  public static function clone(input:Dynamic):Dynamic
-  {
-    return Reflect.copy(input);
-  }
-}