From 1d70ff95f9d2073d8ab761a6bb26771ffc73baa7 Mon Sep 17 00:00:00 2001
From: EliteMasterEric <ericmyllyoja@gmail.com>
Date: Wed, 28 Feb 2024 21:19:21 -0500
Subject: [PATCH 1/3] Several chart editor fixes (more precise playback speed,
 live input mode loads properly from save)

---
 assets                                        |  2 +-
 source/funkin/play/PlayState.hx               | 13 +++++++++---
 source/funkin/play/components/PopUpStuff.hx   | 18 +++--------------
 .../ui/debug/charting/ChartEditorState.hx     | 20 +++++++++++++------
 4 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/assets b/assets
index 84b157429..a1c3d095a 160000
--- a/assets
+++ b/assets
@@ -1 +1 @@
-Subproject commit 84b1574294e7a7af21adf1a0e4894c88431ca43d
+Subproject commit a1c3d095a3c16db88c010267d1a7f9695506c66c
diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx
index 5bbf83e17..07cf6d352 100644
--- a/source/funkin/play/PlayState.hx
+++ b/source/funkin/play/PlayState.hx
@@ -631,8 +631,9 @@ class PlayState extends MusicBeatSubState
 
     // Initialize the judgements and combo meter.
     comboPopUps = new PopUpStuff();
-    comboPopUps.cameras = [camHUD];
+    comboPopUps.zIndex = 900;
     add(comboPopUps);
+    comboPopUps.cameras = [camHUD];
 
     // The little dial that shows up when you hold the Skip Cutscene key.
     skipTimer = new FlxPieDial(16, 16, 32, FlxColor.WHITE, 36, CIRCLE, true, 24);
@@ -1277,6 +1278,7 @@ class PlayState extends MusicBeatSubState
     {
       var animShit:ComboMilestone = new ComboMilestone(-100, 300, Highscore.tallies.combo);
       animShit.scrollFactor.set(0.6, 0.6);
+      animShit.zIndex = 1100;
       animShit.cameras = [camHUD];
       add(animShit);
 
@@ -1363,18 +1365,21 @@ class PlayState extends MusicBeatSubState
     healthBarBG = FunkinSprite.create(0, healthBarYPos, Paths.image('healthBar'));
     healthBarBG.screenCenter(X);
     healthBarBG.scrollFactor.set(0, 0);
+    healthBarBG.zIndex = 800;
     add(healthBarBG);
 
     healthBar = new FlxBar(healthBarBG.x + 4, healthBarBG.y + 4, RIGHT_TO_LEFT, Std.int(healthBarBG.width - 8), Std.int(healthBarBG.height - 8), this,
       'healthLerp', 0, 2);
     healthBar.scrollFactor.set();
     healthBar.createFilledBar(Constants.COLOR_HEALTH_BAR_RED, Constants.COLOR_HEALTH_BAR_GREEN);
+    healthBar.zIndex = 801;
     add(healthBar);
 
     // The score text below the health bar.
     scoreText = new FlxText(healthBarBG.x + healthBarBG.width - 190, healthBarBG.y + 30, 0, '', 20);
     scoreText.setFormat(Paths.font('vcr.ttf'), 16, FlxColor.WHITE, RIGHT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
     scoreText.scrollFactor.set();
+    scoreText.zIndex = 802;
     add(scoreText);
 
     // Move the health bar to the HUD camera.
@@ -1488,6 +1493,7 @@ class PlayState extends MusicBeatSubState
     iconP2 = new HealthIcon('dad', 1);
     iconP2.y = healthBar.y - (iconP2.height / 2);
     dad.initHealthIcon(true); // Apply the character ID here
+    iconP2.zIndex = 850;
     add(iconP2);
     iconP2.cameras = [camHUD];
 
@@ -1507,6 +1513,7 @@ class PlayState extends MusicBeatSubState
     iconP1 = new HealthIcon('bf', 0);
     iconP1.y = healthBar.y - (iconP1.height / 2);
     boyfriend.initHealthIcon(false); // Apply the character ID here
+    iconP1.zIndex = 850;
     add(iconP1);
     iconP1.cameras = [camHUD];
 
@@ -1574,13 +1581,13 @@ class PlayState extends MusicBeatSubState
     playerStrumline.x = FlxG.width / 2 + Constants.STRUMLINE_X_OFFSET; // Classic style
     // playerStrumline.x = FlxG.width - playerStrumline.width - Constants.STRUMLINE_X_OFFSET; // Centered style
     playerStrumline.y = Preferences.downscroll ? FlxG.height - playerStrumline.height - Constants.STRUMLINE_Y_OFFSET : Constants.STRUMLINE_Y_OFFSET;
-    playerStrumline.zIndex = 200;
+    playerStrumline.zIndex = 1001;
     playerStrumline.cameras = [camHUD];
 
     // Position the opponent strumline on the left half of the screen
     opponentStrumline.x = Constants.STRUMLINE_X_OFFSET;
     opponentStrumline.y = Preferences.downscroll ? FlxG.height - opponentStrumline.height - Constants.STRUMLINE_Y_OFFSET : Constants.STRUMLINE_Y_OFFSET;
-    opponentStrumline.zIndex = 100;
+    opponentStrumline.zIndex = 1000;
     opponentStrumline.cameras = [camHUD];
 
     if (!PlayStatePlaylist.isStoryMode)
diff --git a/source/funkin/play/components/PopUpStuff.hx b/source/funkin/play/components/PopUpStuff.hx
index 88ffa468c..faab5e4dc 100644
--- a/source/funkin/play/components/PopUpStuff.hx
+++ b/source/funkin/play/components/PopUpStuff.hx
@@ -5,6 +5,7 @@ import flixel.group.FlxGroup.FlxTypedGroup;
 import flixel.tweens.FlxTween;
 import funkin.graphics.FunkinSprite;
 import funkin.play.PlayState;
+import flixel.util.FlxDirection;
 
 class PopUpStuff extends FlxTypedGroup<FlxSprite>
 {
@@ -30,14 +31,7 @@ class PopUpStuff extends FlxTypedGroup<FlxSprite>
 
     rating.zIndex = 1000;
     rating.x = FlxG.width * 0.50;
-    rating.x -= FlxG.camera.scroll.x * 0.2;
-    // make sure rating is visible lol!
-    //		if (rating.x < FlxG.camera.scroll.x)
-    //			rating.x = FlxG.camera.scroll.x;
-    //		else if (rating.x > FlxG.camera.scroll.x + FlxG.camera.width - rating.width)
-    //			rating.x = FlxG.camera.scroll.x + FlxG.camera.width - rating.width;
-
-    // FlxG.camera.scroll.y +
+    // rating.x -= FlxG.camera.scroll.x * 0.2;
     rating.y = FlxG.camera.height * 0.4 - 60;
     rating.acceleration.y = 550;
     rating.velocity.y -= FlxG.random.int(140, 175);
@@ -91,13 +85,7 @@ class PopUpStuff extends FlxTypedGroup<FlxSprite>
     var comboSpr:FunkinSprite = FunkinSprite.create(Paths.image(pixelShitPart1 + 'combo' + pixelShitPart2));
     comboSpr.y = FlxG.camera.height * 0.4 + 80;
     comboSpr.x = FlxG.width * 0.50;
-    comboSpr.x -= FlxG.camera.scroll.x * 0.2;
-    // make sure combo is visible lol!
-    // 194 fits 4 combo digits
-    // if (comboSpr.x < FlxG.camera.scroll.x + 194)
-    // 	comboSpr.x = FlxG.camera.scroll.x + 194;
-    // else if (comboSpr.x > FlxG.camera.scroll.x + FlxG.camera.width - comboSpr.width)
-    // 	comboSpr.x = FlxG.camera.scroll.x + FlxG.camera.width - comboSpr.width;
+    // comboSpr.x -= FlxG.camera.scroll.x * 0.2;
 
     comboSpr.acceleration.y = 600;
     comboSpr.velocity.y -= 150;
diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx
index 768ea9e43..e46779483 100644
--- a/source/funkin/ui/debug/charting/ChartEditorState.hx
+++ b/source/funkin/ui/debug/charting/ChartEditorState.hx
@@ -2838,12 +2838,15 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
     menuBarItemInputStyleNone.onClick = function(event:UIEvent) {
       currentLiveInputStyle = None;
     };
+    menuBarItemInputStyleNone.selected = currentLiveInputStyle == None;
     menuBarItemInputStyleNumberKeys.onClick = function(event:UIEvent) {
       currentLiveInputStyle = NumberKeys;
     };
+    menuBarItemInputStyleNumberKeys.selected = currentLiveInputStyle == NumberKeys;
     menuBarItemInputStyleWASD.onClick = function(event:UIEvent) {
-      currentLiveInputStyle = WASD;
+      currentLiveInputStyle = WASDKeys;
     };
+    menuBarItemInputStyleWASD.selected = currentLiveInputStyle == WASDKeys;
 
     menubarItemAbout.onClick = _ -> this.openAboutDialog();
     menubarItemWelcomeDialog.onClick = _ -> this.openWelcomeDialog(true);
@@ -2942,7 +2945,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
 
     menubarItemPlaybackSpeed.onChange = event -> {
       var pitch:Float = (event.value.toFloat() * 2.0) / 100.0;
-      pitch = Math.floor(pitch / 0.25) * 0.25; // Round to nearest 0.25.
+      pitch = Math.floor(pitch / 0.05) * 0.05; // Round to nearest 5%
+      pitch = Math.max(0.05, Math.min(2.0, pitch)); // Clamp to 5% to 200%
       #if FLX_PITCH
       if (audioInstTrack != null) audioInstTrack.pitch = pitch;
       audioVocalTrackGroup.pitch = pitch;
@@ -4933,7 +4937,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
     // Place notes at the playhead.
     switch (currentLiveInputStyle)
     {
-      case ChartEditorLiveInputStyle.WASD:
+      case ChartEditorLiveInputStyle.WASDKeys:
         if (FlxG.keys.justPressed.A) placeNoteAtPlayhead(4);
         if (FlxG.keys.justPressed.S) placeNoteAtPlayhead(5);
         if (FlxG.keys.justPressed.W) placeNoteAtPlayhead(6);
@@ -5236,6 +5240,10 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
       }
       // Would bind Ctrl+A and Ctrl+D here, but they are already bound to Select All and Select None.
     }
+    else
+    {
+      trace('Ignoring keybinds for View menu items because we are in live input mode (${currentLiveInputStyle}).');
+    }
   }
 
   /**
@@ -6125,7 +6133,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
 }
 
 /**
- * Available input modes for the chart editor state.
+ * Available input modes for the chart editor state. Numbers/arrows/WASD available for other keybinds.
  */
 enum ChartEditorLiveInputStyle
 {
@@ -6140,9 +6148,9 @@ enum ChartEditorLiveInputStyle
   NumberKeys;
 
   /**
-   * WASD to place notes on opponent's side, arrow keys to place notes on player's side.
+   * WASD to place notes on opponent's side, Arrow keys to place notes on player's side.
    */
-  WASD;
+  WASDKeys;
 }
 
 typedef ChartEditorParams =

From 0139d5c4f6d941264622e7849c907d4e252cdeca Mon Sep 17 00:00:00 2001
From: EliteMasterEric <ericmyllyoja@gmail.com>
Date: Thu, 29 Feb 2024 01:19:32 -0500
Subject: [PATCH 2/3] Fix a crash on atlas characters.

---
 source/funkin/play/character/AnimateAtlasCharacter.hx | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/source/funkin/play/character/AnimateAtlasCharacter.hx b/source/funkin/play/character/AnimateAtlasCharacter.hx
index f9dc18119..418982bef 100644
--- a/source/funkin/play/character/AnimateAtlasCharacter.hx
+++ b/source/funkin/play/character/AnimateAtlasCharacter.hx
@@ -191,7 +191,11 @@ class AnimateAtlasCharacter extends BaseCharacter
     _skipTransformChildren = true;
     super.kill();
     _skipTransformChildren = false;
-    this.mainSprite.kill();
+    if (this.mainSprite != null)
+    {
+      this.mainSprite.kill();
+      this.mainSprite = null;
+    }
   }
 
   /**

From 1102c483fd265126be77c72ee46619990dc2aea9 Mon Sep 17 00:00:00 2001
From: EliteMasterEric <ericmyllyoja@gmail.com>
Date: Thu, 29 Feb 2024 01:19:51 -0500
Subject: [PATCH 3/3] Update assets submodule.

---
 assets | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/assets b/assets
index a1c3d095a..8b914574f 160000
--- a/assets
+++ b/assets
@@ -1 +1 @@
-Subproject commit a1c3d095a3c16db88c010267d1a7f9695506c66c
+Subproject commit 8b914574fc4724c5fe483f4f9d81081bb1518c12