From a5857313c587a7ad460db1254e3b9ad66f219b74 Mon Sep 17 00:00:00 2001
From: Cameron Taylor <cameron.taylor.ninja@gmail.com>
Date: Sat, 30 Apr 2022 00:37:05 -0400
Subject: [PATCH] prototype character mover thing lol

---
 source/funkin/CoolUtil.hx                     | 10 ++++++++
 .../ui/stageBuildShit/StageOffsetSubstate.hx  | 25 +++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/source/funkin/CoolUtil.hx b/source/funkin/CoolUtil.hx
index 207638cc5..a35364e5f 100644
--- a/source/funkin/CoolUtil.hx
+++ b/source/funkin/CoolUtil.hx
@@ -134,6 +134,16 @@ class CoolUtil
 		FlxG.camera.setFilters([new ShaderFilter(screenWipeShit)]);
 	}
 
+	/**
+	 * Just saves the json with some default values hehe
+	 * @param json 
+	 * @return String
+	 */
+	public static inline function jsonStringify(data:Dynamic):String
+	{
+		return Json.stringify(data, null, "\t");
+	}
+
 	/**
 	 * Hashlink json encoding fix for some wacky bullshit
 	 * https://github.com/HaxeFoundation/haxe/issues/6930#issuecomment-384570392
diff --git a/source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx b/source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx
index b642265e2..f0e620aee 100644
--- a/source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx
+++ b/source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx
@@ -3,6 +3,9 @@ package funkin.ui.stageBuildShit;
 import flixel.math.FlxPoint;
 import flixel.ui.FlxButton;
 import funkin.play.PlayState;
+import funkin.play.stage.StageData;
+import haxe.Json;
+import openfl.Assets;
 
 class StageOffsetSubstate extends MusicBeatSubstate
 {
@@ -15,6 +18,28 @@ class StageOffsetSubstate extends MusicBeatSubstate
 
 		var btn:FlxButton = new FlxButton(10, 10, "SAVE COMPILE", function()
 		{
+			var stageLol:StageData = StageDataParser.parseStageData(PlayState.instance.currentStageId);
+
+			var bfPos = PlayState.instance.currentStage.getBoyfriend().feetPosition;
+			stageLol.characters.bf.position[0] = Std.int(bfPos.x);
+			stageLol.characters.bf.position[1] = Std.int(bfPos.y);
+
+			var dadPos = PlayState.instance.currentStage.getDad().feetPosition;
+
+			stageLol.characters.dad.position[0] = Std.int(dadPos.x);
+			stageLol.characters.dad.position[1] = Std.int(dadPos.y);
+
+			var outputJson = CoolUtil.jsonStringify(stageLol);
+
+			#if sys
+			// save "local" to the current export.
+			sys.io.File.saveContent('./assets/data/stages/' + PlayState.instance.currentStageId + '.json', outputJson);
+
+			// save to the dev version
+			sys.io.File.saveContent('../../../../assets/preload/data/stages/' + PlayState.instance.currentStageId + '.json', outputJson);
+			#end
+			// trace(dipshitJson);
+
 			// put character position data to a file of some sort
 		});
 		btn.scrollFactor.set();