Skip to content

Commit

Permalink
fixes for strums and splashes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortex2Oblivion committed Nov 17, 2023
1 parent b2da885 commit 8ec5447
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 31 deletions.
7 changes: 7 additions & 0 deletions assets/preload/data/ui skins/default/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"values": [
{
"affectedbycolor": true
}
]
}
7 changes: 7 additions & 0 deletions assets/preload/data/ui skins/pixel/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"values": [
{
"affectedbycolor": true
}
]
}
7 changes: 7 additions & 0 deletions source/game/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,10 @@ typedef NoteType = {
var hitDamage:Float;
var missDamage:Float;
}
typedef StrumJson = {
var affectedbycolor:Bool;
}
typedef JsonData = {
var values:Array<StrumJson>;
}

35 changes: 24 additions & 11 deletions source/game/NoteSplash.hx
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -9,8 +12,11 @@ import flixel.FlxSprite;

class NoteSplash extends FlxSprite {
public var target:FlxSprite;

public var colorSwap:ColorSwap;
public var noteColor:Array<Int> = [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;
Expand All @@ -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);
}

Expand All @@ -70,4 +83,4 @@ class NoteSplash extends FlxSprite {

super.update(elapsed);
}
}
}
53 changes: 34 additions & 19 deletions source/game/StrumNote.hx
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -26,11 +29,14 @@ class StrumNote extends FlxSprite
public var keyCount:Int;

public var colorSwap:ColorSwap;

public var noteColor:Array<Int> = [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<String>, ?mania_size:Array<String>, ?keyCount:Int, ?isPlayer:Float, customColors:Bool = false)
{
if (ui_Skin == null)
Expand All @@ -55,31 +61,40 @@ 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();
shader = colorSwap.shader;

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)
Expand Down
20 changes: 19 additions & 1 deletion source/modding/custom/CustomState.hx
Original file line number Diff line number Diff line change
@@ -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<Dynamic>) {
script.call(func, args);
}
}

0 comments on commit 8ec5447

Please sign in to comment.