From 8ec5447ebaa63af0dd11078e685175bb6c349666 Mon Sep 17 00:00:00 2001 From: Vortex2Oblivion <73261680+Vortex2Oblivion@users.noreply.github.com> Date: Fri, 17 Nov 2023 15:18:35 -0500 Subject: [PATCH] fixes for strums and splashes --- .../preload/data/ui skins/default/config.json | 7 +++ .../preload/data/ui skins/pixel/config.json | 7 +++ source/game/Note.hx | 7 +++ source/game/NoteSplash.hx | 35 ++++++++---- source/game/StrumNote.hx | 53 ++++++++++++------- source/modding/custom/CustomState.hx | 20 ++++++- 6 files changed, 98 insertions(+), 31 deletions(-) create mode 100644 assets/preload/data/ui skins/default/config.json create mode 100644 assets/preload/data/ui skins/pixel/config.json diff --git a/assets/preload/data/ui skins/default/config.json b/assets/preload/data/ui skins/default/config.json new file mode 100644 index 0000000000..f2c2498d77 --- /dev/null +++ b/assets/preload/data/ui skins/default/config.json @@ -0,0 +1,7 @@ +{ + "values": [ + { + "affectedbycolor": true + } + ] +} \ No newline at end of file diff --git a/assets/preload/data/ui skins/pixel/config.json b/assets/preload/data/ui skins/pixel/config.json new file mode 100644 index 0000000000..f2c2498d77 --- /dev/null +++ b/assets/preload/data/ui skins/pixel/config.json @@ -0,0 +1,7 @@ +{ + "values": [ + { + "affectedbycolor": true + } + ] +} \ No newline at end of file diff --git a/source/game/Note.hx b/source/game/Note.hx index c1108d8674..0ffe0135e5 100644 --- a/source/game/Note.hx +++ b/source/game/Note.hx @@ -261,3 +261,10 @@ typedef NoteType = { var hitDamage:Float; var missDamage:Float; } +typedef StrumJson = { + var affectedbycolor:Bool; +} +typedef JsonData = { + var values:Array; +} + diff --git a/source/game/NoteSplash.hx b/source/game/NoteSplash.hx index 6fdcb64cb1..943a2ffab5 100644 --- a/source/game/NoteSplash.hx +++ b/source/game/NoteSplash.hx @@ -1,5 +1,8 @@ package game; +import game.Note.JsonData; +import haxe.Json; +import openfl.Assets; import shaders.NoteColors; import shaders.ColorSwap; import utilities.NoteVariables; @@ -9,8 +12,11 @@ import flixel.FlxSprite; class NoteSplash extends FlxSprite { public var target:FlxSprite; - + public var colorSwap:ColorSwap; + public var noteColor:Array = [255,0,0]; + public var affectedbycolor:Bool = false; + public var jsonData:JsonData; public function setup_splash(noteData:Int, target:FlxSprite, ?isPlayer:Bool = false) { this.target = target; @@ -37,21 +43,28 @@ class NoteSplash extends FlxSprite { updateHitbox(); centerOffsets(); + if(Assets.exists(Paths.json("ui skins/" + PlayState.SONG.ui_Skin + "/config"))){ + jsonData = Json.parse(Assets.getText(Paths.json("ui skins/" + PlayState.SONG.ui_Skin + "/config"))); + for (value in jsonData.values) { + this.affectedbycolor = value.affectedbycolor; + } + } + colorSwap = new ColorSwap(); shader = colorSwap.shader; var charColors = (isPlayer) ? PlayState.boyfriend : PlayState.dad; - var noteColor; - if (!Options.getData("customNoteColors")) - noteColor = charColors.noteColors[localKeyCount - 1][noteData]; - else - noteColor = NoteColors.getNoteColor(NoteVariables.Other_Note_Anim_Stuff[PlayState.SONG.keyCount - 1][noteData]); - - colorSwap.r = noteColor[0]; - colorSwap.g = noteColor[1]; - colorSwap.b = noteColor[2]; + if(affectedbycolor){ + if (!Options.getData("customNoteColors")) + noteColor = charColors.noteColors[localKeyCount - 1][noteData]; + else + noteColor = NoteColors.getNoteColor(NoteVariables.Other_Note_Anim_Stuff[PlayState.SONG.keyCount - 1][noteData]); + colorSwap.r = noteColor[0]; + colorSwap.g = noteColor[1]; + colorSwap.b = noteColor[2]; + } update(0); } @@ -70,4 +83,4 @@ class NoteSplash extends FlxSprite { super.update(elapsed); } -} +} \ No newline at end of file diff --git a/source/game/StrumNote.hx b/source/game/StrumNote.hx index 03b9cc39b1..8591354150 100644 --- a/source/game/StrumNote.hx +++ b/source/game/StrumNote.hx @@ -1,5 +1,8 @@ package game; +import game.Note.JsonData; +import openfl.Assets; +import haxe.Json; import flixel.FlxG; import utilities.NoteVariables; import shaders.ColorSwap; @@ -26,11 +29,14 @@ class StrumNote extends FlxSprite public var keyCount:Int; public var colorSwap:ColorSwap; - public var noteColor:Array = [255,0,0]; + public var affectedbycolor:Bool = false; public var isPlayer:Float; + public var jsonData:JsonData; + + public function new(x:Float, y:Float, leData:Int, ?ui_Skin:String, ?ui_settings:Array, ?mania_size:Array, ?keyCount:Int, ?isPlayer:Float, customColors:Bool = false) { if (ui_Skin == null) @@ -55,6 +61,13 @@ class StrumNote extends FlxSprite this.keyCount = keyCount; this.isPlayer = isPlayer; + if(Assets.exists(Paths.json("ui skins/" + ui_Skin + "/config"))){ + jsonData = Json.parse(Assets.getText(Paths.json("ui skins/" + ui_Skin + "/config"))); + for (value in jsonData.values) { + this.affectedbycolor = value.affectedbycolor; + } + } + super(x, y); colorSwap = new ColorSwap(); @@ -62,24 +75,26 @@ class StrumNote extends FlxSprite var charColors; - if(Options.getData("middlescroll")){ - charColors = (isPlayer == 1) ? PlayState.dad : PlayState.boyfriend; - } - else{ - charColors = (isPlayer == 1) ? PlayState.boyfriend : PlayState.dad; - } - if (!customColors) - noteColor = charColors.noteColors[localKeyCount - 1][noteData]; - else - noteColor = NoteColors.getNoteColor(NoteVariables.Other_Note_Anim_Stuff[keyCount - 1][noteData]); - - //idk why || doesnt work?? - if(Options.getData("customNoteColors")) - noteColor = NoteColors.getNoteColor(NoteVariables.Other_Note_Anim_Stuff[keyCount - 1][noteData]); - - colorSwap.r = noteColor[0]; - colorSwap.g = noteColor[1]; - colorSwap.b = noteColor[2]; + if(affectedbycolor){ + if(Options.getData("middlescroll")){ + charColors = (isPlayer == 1) ? PlayState.dad : PlayState.boyfriend; + } + else{ + charColors = (isPlayer == 1) ? PlayState.boyfriend : PlayState.dad; + } + if (!customColors) + noteColor = charColors.noteColors[localKeyCount - 1][noteData]; + else + noteColor = NoteColors.getNoteColor(NoteVariables.Other_Note_Anim_Stuff[keyCount - 1][noteData]); + + //idk why || doesnt work?? + if(Options.getData("customNoteColors")) + noteColor = NoteColors.getNoteColor(NoteVariables.Other_Note_Anim_Stuff[keyCount - 1][noteData]); + + colorSwap.r = noteColor[0]; + colorSwap.g = noteColor[1]; + colorSwap.b = noteColor[2]; + } } override function update(elapsed:Float) diff --git a/source/modding/custom/CustomState.hx b/source/modding/custom/CustomState.hx index 0b8241ac22..3b56d05f44 100644 --- a/source/modding/custom/CustomState.hx +++ b/source/modding/custom/CustomState.hx @@ -1,7 +1,25 @@ package modding.custom; +import modding.scripts.languages.HScript; import states.MusicBeatState; class CustomState extends MusicBeatState { - + public var script:HScript; + override function new(script:String){ + this.script = new HScript(Paths.hx("classes/states/" + script)); + super(); + } + override function create(){ + allScriptCall("create"); + super.create(); + allScriptCall("createPost"); + } + override function update(elapsed:Float){ + allScriptCall("update", [elapsed]); + super.update(elapsed); + allScriptCall("updatePost", [elapsed]); + } + private function allScriptCall(func:String, ?args:Array) { + script.call(func, args); + } } \ No newline at end of file