From baab8e101f2b2185941d7ce72c6c9ba5275153b7 Mon Sep 17 00:00:00 2001
From: Eric Myllyoja <ericmyllyoja@gmail.com>
Date: Thu, 8 Sep 2022 01:09:22 -0400
Subject: [PATCH] Stage builder improvements, Weekend 1 stage

---
 Project.xml                                   |  4 +-
 source/Main.hx                                | 58 ++++---------------
 .../ui/stageBuildShit/StageOffsetSubstate.hx  |  8 ++-
 3 files changed, 20 insertions(+), 50 deletions(-)

diff --git a/Project.xml b/Project.xml
index 6033fb639..eb3c57169 100644
--- a/Project.xml
+++ b/Project.xml
@@ -200,8 +200,8 @@
 	<haxeflag name="-dce no" />
 	<haxeflag name="--macro" value="include('funkin')" />
 	<!-- Ensure all UI components are available at runtime. -->
-    <haxeflag name="--macro" value="include('haxe.ui.components')" />
-    <haxeflag name="--macro" value="include('haxe.ui.containers')" />
+  <haxeflag name="--macro" value="include('haxe.ui.components')" />
+  <haxeflag name="--macro" value="include('haxe.ui.containers')" />
 
 	<!-- Necessary to provide stack traces for HScript. -->
 	<haxedef name="hscriptPos" />
diff --git a/source/Main.hx b/source/Main.hx
index 4b3adf7ff..4ba00eaad 100644
--- a/source/Main.hx
+++ b/source/Main.hx
@@ -4,6 +4,7 @@ import flixel.FlxGame;
 import flixel.FlxState;
 import funkin.InitState;
 import funkin.MemoryCounter;
+import haxe.ui.Toolkit;
 import openfl.Lib;
 import openfl.display.FPS;
 import openfl.display.Sprite;
@@ -95,6 +96,8 @@ class Main extends Sprite
 		initialState = TitleState;
 		#end
 
+		initHaxeUI();
+
 		addChild(new FlxGame(gameWidth, gameHeight, initialState, framerate, framerate, skipSplash, startFullscreen));
 
 		#if debug
@@ -105,53 +108,14 @@ class Main extends Sprite
 		addChild(memoryCounter);
 		#end
 		#end
-
-		/* 
-			video = new Video();
-			addChild(video);
-
-			var netConnection = new NetConnection();
-			netConnection.connect(null);
-
-			netStream = new NetStream(netConnection);
-			netStream.client = {onMetaData: client_onMetaData};
-			netStream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, netStream_onAsyncError);
-
-			#if (js && html5)
-			overlay = new Sprite();
-			overlay.graphics.beginFill(0, 0.5);
-			overlay.graphics.drawRect(0, 0, 560, 320);
-			overlay.addEventListener(MouseEvent.MOUSE_DOWN, overlay_onMouseDown);
-			overlay.buttonMode = true;
-			addChild(overlay);
-
-			netConnection.addEventListener(NetStatusEvent.NET_STATUS, netConnection_onNetStatus);
-			#else
-			netStream.play("assets/preload/music/dredd.mp4");
-			#end 
-		 */
 	}
-	/* 
-		private function client_onMetaData(metaData:Dynamic)
-		{
-			video.attachNetStream(netStream);
 
-			video.width = video.videoWidth;
-			video.height = video.videoHeight;
-		}
-
-		private function netStream_onAsyncError(event:AsyncErrorEvent):Void
-		{
-			trace("Error loading video");
-		}
-
-		private function netConnection_onNetStatus(event:NetStatusEvent):Void
-		{
-		}
-
-		private function overlay_onMouseDown(event:MouseEvent):Void
-		{
-			netStream.play("assets/preload/music/dredd.mp4");
-		}
-	 */
+	function initHaxeUI()
+	{
+		// Calling this before any HaxeUI components get used is important:
+		// - It initializes the theme styles.
+		// - It scans the class path and registers any HaxeUI components.
+		Toolkit.init();
+		Toolkit.theme = "dark"; // don't be cringe
+	}
 }
diff --git a/source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx b/source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx
index 68549b19e..c5c67f472 100644
--- a/source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx
+++ b/source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx
@@ -4,7 +4,6 @@ import flixel.FlxSprite;
 import flixel.input.mouse.FlxMouseEvent;
 import flixel.math.FlxPoint;
 import funkin.play.PlayState;
-import funkin.play.character.BaseCharacter;
 import funkin.play.stage.StageData;
 import haxe.ui.RuntimeComponentBuilder;
 import haxe.ui.core.Component;
@@ -77,11 +76,18 @@ class StageOffsetSubstate extends MusicBeatSubstate
 			char.y = sprOld.y - (mosPosOld.y - FlxG.mouse.y);
 		}
 
+		FlxG.mouse.visible = true;
+
 		CoolUtil.mouseCamDrag();
 
 		if (FlxG.keys.pressed.CONTROL)
 			CoolUtil.mouseWheelZoom();
 
+		if (FlxG.mouse.wheel != 0)
+		{
+			FlxG.camera.zoom += FlxG.mouse.wheel * 0.1;
+		}
+
 		if (FlxG.keys.justPressed.Y)
 		{
 			for (thing in PlayState.instance.currentStage)