From 401ed819146e959847cdc867df19c0be71da3a51 Mon Sep 17 00:00:00 2001 From: Cam the Kirby <92703353+CamtheKirby@users.noreply.github.com> Date: Sat, 18 May 2024 22:21:27 -0500 Subject: [PATCH] Softcoding Character select and getting ready for custom characters last thing for today --- Project.xml | 1 + assets/preload/data/characterSelect.json | 130 +++++++++++++++++++++++ mods/test/data/characterSelect.json | 16 +++ skins/characterSelect.json | 16 +++ skins/readme.txt | 0 source/Character.hx | 1 + source/CharacterSelectState.hx | 82 +++++++++++++- 7 files changed, 242 insertions(+), 4 deletions(-) create mode 100644 assets/preload/data/characterSelect.json create mode 100644 mods/test/data/characterSelect.json create mode 100644 skins/characterSelect.json create mode 100644 skins/readme.txt diff --git a/Project.xml b/Project.xml index 9c97815..0c043c5 100644 --- a/Project.xml +++ b/Project.xml @@ -45,6 +45,7 @@ + diff --git a/assets/preload/data/characterSelect.json b/assets/preload/data/characterSelect.json new file mode 100644 index 0000000..6421572 --- /dev/null +++ b/assets/preload/data/characterSelect.json @@ -0,0 +1,130 @@ +{ + "characters": [ + { + "newCharacter": [ + { + "casename": "bf", + "thecharactername": "Boyfriend", + "thenotemsagain": [1, 1, 1, 1], + "notestyle": "" + }, + { + "casename": "bf-pixel", + "thecharactername": "Pixel Boyfriend", + "thenotemsagain": [1, 1, 1, 1], + "notestyle": "" + } + ], + "mainName": "bf", + "thehotemsithink": [1, 1, 1, 1] + }, + { + "newCharacter": [ + { + "casename": "dave", + "thecharactername": "Dave", + "thenotemsagain": [0.25, 0.25, 2, 2], + "notestyle": "" + } + ], + "mainName": "dave", + "thehotemsithink": [0.25, 0.25, 2, 2] + }, + { + "newCharacter": [ + { + "casename": "bambi-new", + "thecharactername": "Bambi", + "thenotemsagain": [0, 0, 3, 0] + } + ], + "mainName": "bambi", + "thehotemsithink": [0, 0, 3, 0] + }, + { + "newCharacter": [ + { + "casename": "tristan", + "thecharactername": "Tristan", + "thenotemsagain": [2, 0.5, 0.5, 0.5], + "notestyle": "" + } + ], + "mainName": "tristan", + "thehotemsithink": [2, 0.5, 0.5, 0.5] + }, + { + "newCharacter": [ + { + "casename": "tristan-golden", + "thecharactername": "Tristan Golden", + "thenotemsagain": [0.25, 0.25, 0.25, 2], + "notestyle": "" + } + ], + "mainName": "tristan-golden", + "thehotemsithink": [0.25, 0.25, 0.25, 2] + }, + { + "newCharacter": [ + { + "casename": "dave-angey", + "thecharactername": "3D Dave", + "thenotemsagain": [2, 2, 0.25, 0.25], + "notestyle": "3D" + }, + { + "casename": "dave-festival-3d", + "thecharactername": "3D Dave Festival", + "thenotemsagain": [2, 2, 0.25, 0.25], + "notestyle": "3D" + } + ], + "mainName": "dave-angey", + "thehotemsithink": [2, 2, 0.25, 0.25] + }, + { + "newCharacter": [ + { + "casename": "bambi-3d", + "thecharactername": "Expunged", + "thenotemsagain": [0, 3, 0, 0], + "notestyle": "3D" + } + ], + "mainName": "bambi-3d", + "thehotemsithink": [0, 3, 0, 0] + + }, + { + "newCharacter": [ + { + "casename": "shaggy", + "thecharactername": "Shaggy", + "thenotemsagain": [1, 1, 1, 1], + "notestyle": "" + }, + { + "casename": "supershaggy", + "thecharactername": "Shaggy (0.001%)", + "thenotemsagain": [1, 1, 1, 1], + "notestyle": "" + }, + { + "casename": "godshaggy", + "thecharactername": "Shaggy (0.002%)", + "thenotemsagain": [1, 1, 1, 1], + "notestyle": "" + }, + { + "casename": "redshaggy", + "thecharactername": "Red Shaggy", + "thenotemsagain": [1, 1, 1, 1], + "notestyle": "" + } + ], + "mainName": "shaggy", + "thehotemsithink": [1, 1, 1, 1] + } + ] + } \ No newline at end of file diff --git a/mods/test/data/characterSelect.json b/mods/test/data/characterSelect.json new file mode 100644 index 0000000..43fdf8d --- /dev/null +++ b/mods/test/data/characterSelect.json @@ -0,0 +1,16 @@ +{ + "characters": [ + { + "newCharacter": [ + { + "casename": "bf-pixel", + "thecharactername": "Test", + "thenotemsagain": [1, 1, 1, 1], + "notestyle": "" + } + ], + "mainName": "testtwo", + "thehotemsithink": [1, 1, 1, 1] + } + ] + } \ No newline at end of file diff --git a/skins/characterSelect.json b/skins/characterSelect.json new file mode 100644 index 0000000..57f5b54 --- /dev/null +++ b/skins/characterSelect.json @@ -0,0 +1,16 @@ +{ + "characters": [ + { + "newCharacter": [ + { + "casename": "bf-pixel", + "thecharactername": "Test", + "thenotemsagain": [1, 1, 1, 1], + "notestyle": "" + } + ], + "mainName": "test", + "thehotemsithink": [1, 1, 1, 1] + } + ] + } \ No newline at end of file diff --git a/skins/readme.txt b/skins/readme.txt new file mode 100644 index 0000000..e69de29 diff --git a/source/Character.hx b/source/Character.hx index 1ce1a9f..b3cd89e 100644 --- a/source/Character.hx +++ b/source/Character.hx @@ -8,6 +8,7 @@ import flixel.FlxG; import flixel.FlxSprite; import flixel.animation.FlxBaseAnimation; import flixel.graphics.frames.FlxAtlasFrames; +import haxe.Json; using StringTools; diff --git a/source/CharacterSelectState.hx b/source/CharacterSelectState.hx index eb5521e..b17fa81 100644 --- a/source/CharacterSelectState.hx +++ b/source/CharacterSelectState.hx @@ -23,6 +23,8 @@ import flixel.FlxSprite; import lime.app.Application; import sys.FileSystem; #end +import haxe.Json; +import haxe.format.JsonParser; /** hey you fun commiting people, @@ -31,6 +33,26 @@ import sys.FileSystem; the secondary dev, ben */ +typedef CharacterSelectFile = +{ + var characters:Array; +} + +typedef CharSelectStuff = +{ + var newCharacter:Array; + var mainName:String; + var thehotemsithink:Array; + +} + +typedef TheActualChar = +{ +var casename:String; +var thecharactername:String; +var thenotemsagain:Array; +var notestyle:String; +} class CharacterInSelect { public var name:String; @@ -85,7 +107,12 @@ class CharacterSelectState extends MusicBeatState private var camTransition:FlxCamera; var currentSelectedCharacter:CharacterInSelect; - + public var rawJson:String; + public var json:CharacterSelectFile; + public var rawJsonCustom:String; + public var jsonCustom:CharacterSelectFile; + public var rawJsonCustom2:String; + public var jsonCustom2:CharacterSelectFile; var noteMsTexts:FlxTypedGroup = new FlxTypedGroup(); var arrows:Array = []; @@ -93,7 +120,7 @@ class CharacterSelectState extends MusicBeatState public var characters:Array = [ - new CharacterInSelect('bf', [1, 1, 1, 1], [ + /*new CharacterInSelect('bf', [1, 1, 1, 1], [ new CharacterForm('bf', 'Boyfriend', [1,1,1,1]), new CharacterForm('bf-pixel', 'Pixel Boyfriend', [1,1,1,1]) ]), @@ -121,6 +148,7 @@ class CharacterSelectState extends MusicBeatState new CharacterForm('godshaggy', 'Shaggy (0.002%)', [1, 1, 1, 1]), new CharacterForm('redshaggy', 'Red Shaggy', [1, 1, 1, 1]), ]), + */ ]; #if SHADERS_ENABLED var bgShader:Shaders.GlitchEffect; @@ -144,7 +172,55 @@ class CharacterSelectState extends MusicBeatState wasInFullscreen = true; } } + rawJson = File.getContent(Paths.json('characterSelect')); + json = cast Json.parse(rawJson); + rawJsonCustom = File.getContent(('Skins/characterSelect.json')); + jsonCustom = cast Json.parse(rawJsonCustom); + if (FileSystem.exists(TitleState.modFolder + '/data/characterSelect.json')) { + rawJsonCustom2 = File.getContent((TitleState.modFolder + '/data/characterSelect.json')); + jsonCustom2 = cast Json.parse(rawJsonCustom2); + } + + var characterInSelectArray:Array = []; + + for (character in json.characters) { // Normal + var mainName:String = character.mainName; + var thehotemsithink:Array = character.thehotemsithink; + + var newCharacterForms:Array = []; + for (newChar in character.newCharacter) { + newCharacterForms.push(new CharacterForm(newChar.casename, newChar.thecharactername, newChar.thenotemsagain, newChar.notestyle)); + } + + characters.push(new CharacterInSelect(mainName, thehotemsithink, newCharacterForms)); + } + + for (character in jsonCustom.characters) { // For Globle Characters + var mainName:String = character.mainName; + var thehotemsithink:Array = character.thehotemsithink; + + var newCharacterForms:Array = []; + for (newChar in character.newCharacter) { + newCharacterForms.push(new CharacterForm(newChar.casename, newChar.thecharactername, newChar.thenotemsagain, newChar.notestyle)); + } + + characters.push(new CharacterInSelect(mainName, thehotemsithink, newCharacterForms)); + } + if (FileSystem.exists(TitleState.modFolder + '/data/characterSelect.json')) { + for (character in jsonCustom2.characters) { // For Characters in Mod Packs + var mainName:String = character.mainName; + var thehotemsithink:Array = character.thehotemsithink; + + var newCharacterForms:Array = []; + for (newChar in character.newCharacter) { + newCharacterForms.push(new CharacterForm(newChar.casename, newChar.thecharactername, newChar.thenotemsagain, newChar.notestyle)); + } + + characters.push(new CharacterInSelect(mainName, thehotemsithink, newCharacterForms)); + } + } + trace(characters); Conductor.changeBPM(110); camGame = new FlxCamera(); @@ -505,7 +581,6 @@ class CharacterSelectState extends MusicBeatState UpdateBF(); FlxG.sound.play(Paths.sound('scrollMenu'), 0.4); } - #if debug if (FlxG.keys.justPressed.R && !selectedCharacter) { reset(); @@ -522,7 +597,6 @@ class CharacterSelectState extends MusicBeatState } } } - #end } public static function unlockCharacter(character:String) {