From 4b135e83cea7e17cb7f3522bd17505b913e3dca5 Mon Sep 17 00:00:00 2001 From: Cam the Kirby <92703353+CamtheKirby@users.noreply.github.com> Date: Tue, 4 Jun 2024 21:49:31 -0500 Subject: [PATCH] tried something but :( --- mods/test/data/customStageList.txt | 1 + mods/test/data/stages/not yet.txt | 0 mods/test/data/stages/test.hx | 18 +++++++++++++++++ source/ChartingState.hx | 13 ++++++++++++- source/PlayState.hx | 31 ++++++++++++------------------ 5 files changed, 43 insertions(+), 20 deletions(-) create mode 100644 mods/test/data/customStageList.txt delete mode 100644 mods/test/data/stages/not yet.txt create mode 100644 mods/test/data/stages/test.hx diff --git a/mods/test/data/customStageList.txt b/mods/test/data/customStageList.txt new file mode 100644 index 0000000..30d74d2 --- /dev/null +++ b/mods/test/data/customStageList.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/mods/test/data/stages/not yet.txt b/mods/test/data/stages/not yet.txt deleted file mode 100644 index e69de29..0000000 diff --git a/mods/test/data/stages/test.hx b/mods/test/data/stages/test.hx new file mode 100644 index 0000000..43a9511 --- /dev/null +++ b/mods/test/data/stages/test.hx @@ -0,0 +1,18 @@ +bgZoom = 0.9; +stageName = 'stage'; + +var bg:BGSprite = new BGSprite('bg', -600, -200, Paths.image('backgrounds/stage/stageback'), null, 0.9, 0.9); +sprites.add(bg); +add(bg); + +var stageFront:BGSprite = new BGSprite('stageFront', -650, 600, Paths.image('backgrounds/stage/stagefront'), null, 0.9, 0.9); +stageFront.setGraphicSize(Std.int(stageFront.width * 1.1)); +stageFront.updateHitbox(); +sprites.add(stageFront); +add(stageFront); + +var stageCurtains:BGSprite = new BGSprite('stageCurtains', -500, -300, Paths.image('backgrounds/stage/stagecurtains'), null, 1.3, 1.3); +stageCurtains.setGraphicSize(Std.int(stageCurtains.width * 0.9)); +stageCurtains.updateHitbox(); +sprites.add(stageCurtains); +add(stageCurtains); \ No newline at end of file diff --git a/source/ChartingState.hx b/source/ChartingState.hx index 0c2f2aa..75fdd6f 100644 --- a/source/ChartingState.hx +++ b/source/ChartingState.hx @@ -111,6 +111,9 @@ class ChartingState extends MusicBeatState var c:Array; var cm:Array; + var cStage:Array; + var cmStage:Array; + override function create() { curSection = lastSection; @@ -342,7 +345,15 @@ class ChartingState extends MusicBeatState var characters:Array = c.concat(cm); - var stages:Array = CoolUtil.coolTextFile(Paths.txt('stageList')); +cStage = CoolUtil.coolTextFile(Paths.txt('stageList')); + + if (FileSystem.exists(TitleState.modFolder + '/data/customStageList.txt')) { + cmStage = CoolUtil.coolTextFile(TitleState.modFolder + '/data/customStageList.txt'); + } else { + cmStage = ['']; + } + + var stages:Array = cStage.concat(cmStage); var player1DropDown = new FlxUIDropDownMenu(10, 100, FlxUIDropDownMenu.makeStrIdLabelArray(characters, true), function(character:String) { diff --git a/source/PlayState.hx b/source/PlayState.hx index 165b021..9009ea8 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -17,6 +17,7 @@ import flixel.group.FlxSpriteGroup; import lime.tools.ApplicationData; import flixel.effects.particles.FlxParticle; import hscript.Printer; +import hscript.*; import openfl.desktop.Clipboard; import flixel.system.debug.Window; #if desktop @@ -96,7 +97,7 @@ import vlc.MP4Handler; using StringTools; -typedef StageJson = +/*typedef StageJson = { var bgZoom:Float; var backgrounds:Array; @@ -112,7 +113,7 @@ typedef BackgroundJson = var scrollX:Float; var scrollY:Float; var antialiasing:Bool; -} +} */ typedef Settings = { var songCreators:String; @@ -374,8 +375,8 @@ class PlayState extends MusicBeatState var originBambiPos:FlxPoint; var originBFPos:FlxPoint; - public var rawJsonStage:String; - public var jsonStage:StageJson; + /*public var rawJsonStage:String; + public var jsonStage:StageJson; */ var rawJsonSettings:String; var jsonSettings:Settings; @@ -2208,22 +2209,14 @@ class PlayState extends MusicBeatState sprites.add(stfu); add(stfu); default: - // I don't know how to do this some one help - - /*if (FileSystem.exists(TitleState.modFolder + '/data/stages/' + bgName + '.json')) { - rawJsonStage = File.getContent(TitleState.modFolder + '/data/stages/' + bgName + '.json'); - jsonStage = cast Json.parse(rawJsonStage); + /*if (FileSystem.exists(TitleState.modFolder + '/data/stages/' + bgName + '.hx')) { + // should make a custom stage + var parser = new Parser(); + var interp = new Interp(); - bgZoom = jsonStage.bgZoom; - stageName = bgName; + var expr = parser.parseString(File.getContent(TitleState.modFolder + '/data/stages/' + bgName + '.hx')); - for (i in jsonStage.backgrounds) { - var spriteName:BGSprite = new BGSprite('spriteName', i.posX, i.posY, TitleState.modFolder + '/images/stages/' + bgName + '/' + i.image, null, i.scrollX, i.scrollY, i.antialiasing); - spriteName.setGraphicSize(Std.int(spriteName.width * 0.9)); - spriteName.updateHitbox(); - sprites.add(spriteName); - add(spriteName); - } + interp.execute(expr); } else { */ bgZoom = 0.9; @@ -2244,7 +2237,7 @@ class PlayState extends MusicBeatState stageCurtains.updateHitbox(); sprites.add(stageCurtains); add(stageCurtains); - // } + //} } if (!revertedBG) {