Skip to content

Commit

Permalink
fix some ui skin change stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortex2Oblivion committed Nov 25, 2024
1 parent 13c629f commit 2683c35
Show file tree
Hide file tree
Showing 12 changed files with 147 additions and 79 deletions.
83 changes: 71 additions & 12 deletions source/game/EventHandeler.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package game;

import utilities.NoteVariables;
import game.TimeBar;
import flixel.graphics.FlxGraphic;
import openfl.utils.Assets;
Expand Down Expand Up @@ -38,7 +39,7 @@ class EventHandeler {
}
case "set gf speed":
if (Std.parseInt(event[2]) != null)
PlayState.instance.gfSpeed = Std.parseInt(event[2]);
game.gfSpeed = Std.parseInt(event[2]);
case "character will idle":
var char = PlayState.getCharFromEvent(event[2]);

Expand All @@ -50,13 +51,13 @@ class EventHandeler {
var hudCamZoomThing:Float = Std.parseFloat(event[3]);

if (Math.isNaN(defaultCamZoomThing))
defaultCamZoomThing = PlayState.instance.defaultCamZoom;
defaultCamZoomThing = game.defaultCamZoom;

if (Math.isNaN(hudCamZoomThing))
hudCamZoomThing = 1;

PlayState.instance.defaultCamZoom = defaultCamZoomThing;
PlayState.instance.defaultHudCamZoom = hudCamZoomThing;
game.defaultCamZoom = defaultCamZoomThing;
game.defaultHudCamZoom = hudCamZoomThing;
case "change character alpha":
var char = PlayState.getCharFromEvent(event[2]);

Expand All @@ -82,15 +83,15 @@ class EventHandeler {
time = 1;

if (Options.getData("flashingLights"))
PlayState.instance.camGame.flash(FlxColor.fromString(event[2].toLowerCase()), time);
game.camGame.flash(FlxColor.fromString(event[2].toLowerCase()), time);
case "camera fade":
var time = Std.parseFloat(event[3]);

if (Math.isNaN(time))
time = 1;

if (Options.getData("flashingLights"))
PlayState.instance.camGame.fade(FlxColor.fromString(event[2].toLowerCase()), time);
game.camGame.fade(FlxColor.fromString(event[2].toLowerCase()), time);
#end
case "add camera zoom":
if (game.cameraZooms && ((FlxG.camera.zoom < 1.35 && game.camZooming) || !game.camZooming)) {
Expand Down Expand Up @@ -300,15 +301,15 @@ class EventHandeler {
game.type_Configs.set("default", CoolUtil.coolTextFile(Paths.txt("arrow types/default")));

// reload ratings
game.uiMap.set("marvelous", FlxGraphic.fromAssetKey(Paths.image("ui skins/" + PlayState.SONG.ui_Skin + "/ratings/marvelous")));
game.uiMap.set("sick", FlxGraphic.fromAssetKey(Paths.image("ui skins/" + PlayState.SONG.ui_Skin + "/ratings/sick")));
game.uiMap.set("good", FlxGraphic.fromAssetKey(Paths.image("ui skins/" + PlayState.SONG.ui_Skin + "/ratings/good")));
game.uiMap.set("bad", FlxGraphic.fromAssetKey(Paths.image("ui skins/" + PlayState.SONG.ui_Skin + "/ratings/bad")));
game.uiMap.set("shit", FlxGraphic.fromAssetKey(Paths.image("ui skins/" + PlayState.SONG.ui_Skin + "/ratings/shit")));
game.uiMap.set("marvelous", Paths.gpuBitmap("ui skins/" + PlayState.SONG.ui_Skin + "/ratings/marvelous"));
game.uiMap.set("sick", Paths.gpuBitmap("ui skins/" + PlayState.SONG.ui_Skin + "/ratings/sick"));
game.uiMap.set("good", Paths.gpuBitmap("ui skins/" + PlayState.SONG.ui_Skin + "/ratings/good"));
game.uiMap.set("bad", Paths.gpuBitmap("ui skins/" + PlayState.SONG.ui_Skin + "/ratings/bad"));
game.uiMap.set("shit", Paths.gpuBitmap("ui skins/" + PlayState.SONG.ui_Skin + "/ratings/shit"));

// preload numbers
for (i in 0...10)
game.uiMap.set(Std.string(i), FlxGraphic.fromAssetKey(Paths.image("ui skins/" + PlayState.SONG.ui_Skin + "/numbers/num" + Std.string(i))));
game.uiMap.set(Std.string(i), Paths.gpuBitmap("ui skins/" + PlayState.SONG.ui_Skin + "/numbers/num" + Std.string(i)));
game.timeBar = new TimeBar(PlayState.SONG, PlayState.storyDifficultyStr);

PlayState.playerStrums.clear();
Expand All @@ -327,6 +328,64 @@ class EventHandeler {
game.generateStaticArrows(0, true, false);
}
}

for (note in game.notes.members) {
var oldAnim:String = note.animation.curAnim.name;
note.frames = Note.getFrames(note);

var lmaoStuff:Float = Std.parseFloat(game.ui_settings[0]) * (Std.parseFloat(game.ui_settings[2])
- (Std.parseFloat(game.mania_size[( note.mustPress ? PlayState.SONG.playerKeyCount : PlayState.SONG.keyCount) - 1])));

if (note.isSustainNote)
note.scale.set(lmaoStuff,
Std.parseFloat(game.ui_settings[0]) * (Std.parseFloat(game.ui_settings[2]) - (Std.parseFloat(game.mania_size[3]))));
else
note.scale.set(lmaoStuff, lmaoStuff);

note.updateHitbox();

note.antialiasing = game.ui_settings[3] == "true";

var localKeyCount:Int = note.mustPress ? note.song.playerKeyCount : note.song.keyCount;

note.animation.addByPrefix("default", NoteVariables.animationDirections[localKeyCount - 1][note.noteData] + "0", 24);
note.animation.addByPrefix("hold", NoteVariables.animationDirections[localKeyCount - 1][note.noteData] + " hold0", 24);
note.animation.addByPrefix("holdend", NoteVariables.animationDirections[localKeyCount - 1][note.noteData] + " hold end0", 24);

note.shader = note.affectedbycolor ? note.colorSwap.shader : null;

note.animation.play(oldAnim);

}

for (note in game.unspawnNotes) {
var oldAnim:String = note.animation.curAnim.name;
note.frames = Note.getFrames(note);

var lmaoStuff:Float = Std.parseFloat(game.ui_settings[0]) * (Std.parseFloat(game.ui_settings[2])
- (Std.parseFloat(game.mania_size[( note.mustPress ? PlayState.SONG.playerKeyCount : PlayState.SONG.keyCount) - 1])));

if (note.isSustainNote)
note.scale.set(lmaoStuff,
Std.parseFloat(game.ui_settings[0]) * (Std.parseFloat(game.ui_settings[2]) - (Std.parseFloat(game.mania_size[3]))));
else
note.scale.set(lmaoStuff, lmaoStuff);

note.updateHitbox();

note.antialiasing = game.ui_settings[3] == "true";


var localKeyCount:Int = note.mustPress ? note.song.playerKeyCount : note.song.keyCount;

note.animation.addByPrefix("default", NoteVariables.animationDirections[localKeyCount - 1][note.noteData] + "0", 24);
note.animation.addByPrefix("hold", NoteVariables.animationDirections[localKeyCount - 1][note.noteData] + " hold0", 24);
note.animation.addByPrefix("holdend", NoteVariables.animationDirections[localKeyCount - 1][note.noteData] + " hold end0", 24);

note.shader = note.affectedbycolor ? note.colorSwap.shader : null;

note.animation.play(oldAnim);
}
// FNFC stuff
case 'focuscamera':
switch (Std.string(event[2])) {
Expand Down
43 changes: 26 additions & 17 deletions source/game/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class Note extends FlxSkewedSprite {

public var inEditor:Bool = false;

public var song:SongData;

#if MODCHARTING_TOOLS
/**
* The mesh used for sustains to make them stretchy
Expand Down Expand Up @@ -95,6 +97,23 @@ class Note extends FlxSkewedSprite {
*/
public static var beats:Array<Int> = [4, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192];

public static function getFrames(note:Note):FlxAtlasFrames{
if (PlayState.instance.types.contains(note.arrow_Type)) {
if (Assets.exists(Paths.image('ui skins/' + note.song.ui_Skin + "/arrows/" + note.arrow_Type, 'shared'))) {
return Paths.getSparrowAtlas('ui skins/' + note.song.ui_Skin + "/arrows/" + note.arrow_Type, 'shared' #if MODCHARTING_TOOLS ,note.song.modchartingTools || FlxG.state is modcharting.ModchartEditorState #end);
} else {
return Paths.getSparrowAtlas('ui skins/${note.song.ui_Skin}/arrows/default', 'shared' #if MODCHARTING_TOOLS ,note.song.modchartingTools || FlxG.state is modcharting.ModchartEditorState #end);
}
} else {
if (Assets.exists(Paths.image("ui skins/default/arrows/" + note.arrow_Type, 'shared'))) {
return Paths.getSparrowAtlas("ui skins/default/arrows/" + note.arrow_Type, 'shared' #if MODCHARTING_TOOLS ,note.song.modchartingTools || FlxG.state is modcharting.ModchartEditorState #end);
} else {
return Paths.getSparrowAtlas('ui skins/${note.song.ui_Skin}/arrows/default', 'shared' #if MODCHARTING_TOOLS ,note.song.modchartingTools || FlxG.state is modcharting.ModchartEditorState #end);
}
}
return Paths.getSparrowAtlas('ui skins/default/arrows/default', 'shared' #if MODCHARTING_TOOLS ,note.song.modchartingTools || FlxG.state is modcharting.ModchartEditorState #end);
}

public function new(strumTime:Float, noteData:Int, ?prevNote:Note, ?sustainNote:Bool = false, ?character:Int = 0, ?arrowType:String = "default",
?song:SongData, ?characters:Array<Int>, ?mustPress:Bool = false, ?inEditor:Bool = false) {
super();
Expand All @@ -118,27 +137,17 @@ class Note extends FlxSkewedSprite {

this.noteData = noteData;

this.song = song;

x += 100;
// MAKE SURE ITS DEFINITELY OFF SCREEN?
y = -2000;

if (PlayState.instance.types.contains(arrow_Type)) {
if (Assets.exists(Paths.image('ui skins/' + song.ui_Skin + "/arrows/" + arrow_Type, 'shared'))) {
frames = Paths.getSparrowAtlas('ui skins/' + song.ui_Skin + "/arrows/" + arrow_Type, 'shared' #if MODCHARTING_TOOLS ,song.modchartingTools || FlxG.state is modcharting.ModchartEditorState #end);
} else {
frames = Paths.getSparrowAtlas('ui skins/${song.ui_Skin}/arrows/default', 'shared' #if MODCHARTING_TOOLS ,song.modchartingTools || FlxG.state is modcharting.ModchartEditorState #end);
}
} else {
if (Assets.exists(Paths.image("ui skins/default/arrows/" + arrow_Type, 'shared'))) {
frames = Paths.getSparrowAtlas("ui skins/default/arrows/" + arrow_Type, 'shared' #if MODCHARTING_TOOLS ,song.modchartingTools || FlxG.state is modcharting.ModchartEditorState #end);
} else {
frames = Paths.getSparrowAtlas('ui skins/${song.ui_Skin}/arrows/default', 'shared' #if MODCHARTING_TOOLS ,song.modchartingTools || FlxG.state is modcharting.ModchartEditorState #end);
}
}
frames = Note.getFrames(this);

animation.addByPrefix("default", NoteVariables.Other_Note_Anim_Stuff[localKeyCount - 1][noteData] + "0", 24);
animation.addByPrefix("hold", NoteVariables.Other_Note_Anim_Stuff[localKeyCount - 1][noteData] + " hold0", 24);
animation.addByPrefix("holdend", NoteVariables.Other_Note_Anim_Stuff[localKeyCount - 1][noteData] + " hold end0", 24);
animation.addByPrefix("default", NoteVariables.animationDirections[localKeyCount - 1][noteData] + "0", 24);
animation.addByPrefix("hold", NoteVariables.animationDirections[localKeyCount - 1][noteData] + " hold0", 24);
animation.addByPrefix("holdend", NoteVariables.animationDirections[localKeyCount - 1][noteData] + " hold end0", 24);

var lmaoStuff:Float = Std.parseFloat(PlayState.instance.ui_settings[0]) * (Std.parseFloat(PlayState.instance.ui_settings[2])
- (Std.parseFloat(PlayState.instance.mania_size[localKeyCount - 1])));
Expand Down Expand Up @@ -235,7 +244,7 @@ class Note extends FlxSkewedSprite {

var realKeyCount:Int = mustPress ? song.playerKeyCount : song.keyCount;

var noteColor = NoteColors.getNoteColor(NoteVariables.Other_Note_Anim_Stuff[realKeyCount - 1][noteData]);
var noteColor = NoteColors.getNoteColor(NoteVariables.animationDirections[realKeyCount - 1][noteData]);

if (colorSwap != null && noteColor != null) {
colorSwap.r = noteColor[0];
Expand Down
4 changes: 2 additions & 2 deletions source/game/NoteSplash.hx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class NoteSplash extends FlxSprite {
this.target = target;
graphic.destroyOnNoUse = false;

animation.addByPrefix("default", "note splash " + NoteVariables.Other_Note_Anim_Stuff[localKeyCount - 1][noteData] + "0", FlxG.random.int(22, 26),
animation.addByPrefix("default", "note splash " + NoteVariables.animationDirections[localKeyCount - 1][noteData] + "0", FlxG.random.int(22, 26),
false);
animation.play("default", true);

Expand All @@ -61,7 +61,7 @@ class NoteSplash extends FlxSprite {

shader = affectedbycolor ? colorSwap.shader : null;

noteColor = NoteColors.getNoteColor(NoteVariables.Other_Note_Anim_Stuff[PlayState.SONG.keyCount - 1][noteData]);
noteColor = NoteColors.getNoteColor(NoteVariables.animationDirections[PlayState.SONG.keyCount - 1][noteData]);
if(colorSwap != null && noteColor != null){
colorSwap.r = noteColor[0];
colorSwap.g = noteColor[1];
Expand Down
2 changes: 1 addition & 1 deletion source/game/SongLoader.hx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class SongLoader {
song.chartOffset = 0.0;

// guarenteed safe value
song.keyCount = Math.floor(Math.min(song.keyCount, NoteVariables.Note_Count_Directions.length));
song.keyCount = Math.floor(Math.min(song.keyCount, NoteVariables.maniaDirections.length));

if (song.events == null)
song.events = [];
Expand Down
8 changes: 4 additions & 4 deletions source/game/StrumNote.hx
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,18 @@ class StrumNote extends FlxSkewedSprite {
frames = Assets.exists(Paths.image("ui skins/" + ui_Skin + "/arrows/strums")) ? Paths.getSparrowAtlas('ui skins/' + ui_Skin
+ "/arrows/strums") : Paths.getSparrowAtlas('ui skins/' + ui_Skin + "/arrows/default");

var animation_Base_Name:String = NoteVariables.Note_Count_Directions[keyCount - 1][Std.int(Math.abs(noteData))].toLowerCase();
var animation_Base_Name:String = NoteVariables.maniaDirections[keyCount - 1][Std.int(Math.abs(noteData))].toLowerCase();

animation.addByPrefix('static', animation_Base_Name + " static");
animation.addByPrefix('pressed', NoteVariables.Other_Note_Anim_Stuff[keyCount - 1][noteData] + ' press', 24, false);
animation.addByPrefix('confirm', NoteVariables.Other_Note_Anim_Stuff[keyCount - 1][noteData] + ' confirm', 24, false);
animation.addByPrefix('pressed', NoteVariables.animationDirections[keyCount - 1][noteData] + ' press', 24, false);
animation.addByPrefix('confirm', NoteVariables.animationDirections[keyCount - 1][noteData] + ' confirm', 24, false);


antialiasing = ui_settings[3] == "true";

setGraphicSize(Std.int((width * Std.parseFloat(ui_settings[0])) * (Std.parseFloat(ui_settings[2]) - (Std.parseFloat(mania_size[keyCount - 1])))));
updateHitbox();
noteColor = NoteColors.getNoteColor(NoteVariables.Other_Note_Anim_Stuff[keyCount - 1][noteData]);
noteColor = NoteColors.getNoteColor(NoteVariables.animationDirections[keyCount - 1][noteData]);
shader = affectedbycolor ? colorSwap.shader : null;

if (affectedbycolor && PlayState.instance != null && colorSwap != null) {
Expand Down
2 changes: 1 addition & 1 deletion source/modding/ModchartUtilities.hx
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ class ModchartUtilities {

setLuaFunction("getSingDirectionID", function(id:Int) {
var thing = ['singLEFT', 'singDOWN', 'singUP', 'singRIGHT'];
var singDir = NoteVariables.Character_Animation_Arrays[PlayState.SONG.playerKeyCount - 1][Std.int(Math.abs(id % PlayState.SONG.playerKeyCount))];
var singDir = NoteVariables.characterAnimations[PlayState.SONG.playerKeyCount - 1][Std.int(Math.abs(id % PlayState.SONG.playerKeyCount))];
return thing.indexOf(singDir);
});

Expand Down
20 changes: 10 additions & 10 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2179,7 +2179,7 @@ class PlayState extends MusicBeatState {
if (!note.mustPress && note.strumTime <= Conductor.songPosition && note.shouldHit) {
camZooming = true;

var singAnim:String = NoteVariables.Character_Animation_Arrays[getCorrectKeyCount(false) - 1][Std.int(Math.abs(note.noteData))]
var singAnim:String = NoteVariables.characterAnimations[getCorrectKeyCount(false) - 1][Std.int(Math.abs(note.noteData))]
+ (characterPlayingAs == 0 ? altAnim : "") + note.singAnimSuffix;
if (note.singAnimPrefix != 'sing') {
singAnim = singAnim.replace('sing', note.singAnimPrefix);
Expand Down Expand Up @@ -3343,37 +3343,37 @@ class PlayState extends MusicBeatState {
if (characterPlayingAs == 0) {
if (boyfriend.otherCharacters != null && !(boyfriend.otherCharacters.length - 1 < note.character)) {
if (note.characters.length <= 1)
boyfriend.otherCharacters[note.character].playAnim(NoteVariables.Character_Animation_Arrays[getCorrectKeyCount(true) - 1][direction]
boyfriend.otherCharacters[note.character].playAnim(NoteVariables.characterAnimations[getCorrectKeyCount(true) - 1][direction]
+ "miss", true);
else {
for (character in note.characters) {
if (boyfriend.otherCharacters.length - 1 >= character)
boyfriend.otherCharacters[character].playAnim(NoteVariables.Character_Animation_Arrays[getCorrectKeyCount(true) - 1][direction]
boyfriend.otherCharacters[character].playAnim(NoteVariables.characterAnimations[getCorrectKeyCount(true) - 1][direction]
+ "miss", true);
}
}
} else
boyfriend.playAnim(NoteVariables.Character_Animation_Arrays[getCorrectKeyCount(true) - 1][direction] + "miss", true);
boyfriend.playAnim(NoteVariables.characterAnimations[getCorrectKeyCount(true) - 1][direction] + "miss", true);
} else {
if (dad.otherCharacters != null && !(dad.otherCharacters.length - 1 < note.character))
if (note.characters.length <= 1)
dad.otherCharacters[note.character].playAnim(NoteVariables.Character_Animation_Arrays[getCorrectKeyCount(true) - 1][direction]
dad.otherCharacters[note.character].playAnim(NoteVariables.characterAnimations[getCorrectKeyCount(true) - 1][direction]
+ "miss", true);
else {
for (character in note.characters) {
if (dad.otherCharacters.length - 1 >= character)
dad.otherCharacters[character].playAnim(NoteVariables.Character_Animation_Arrays[getCorrectKeyCount(true) - 1][direction]
dad.otherCharacters[character].playAnim(NoteVariables.characterAnimations[getCorrectKeyCount(true) - 1][direction]
+ "miss", true);
}
}
else
dad.playAnim(NoteVariables.Character_Animation_Arrays[getCorrectKeyCount(true) - 1][direction] + "miss", true);
dad.playAnim(NoteVariables.characterAnimations[getCorrectKeyCount(true) - 1][direction] + "miss", true);
}
} else {
if (characterPlayingAs == 0)
boyfriend.playAnim(NoteVariables.Character_Animation_Arrays[getCorrectKeyCount(true) - 1][direction] + "miss", true);
boyfriend.playAnim(NoteVariables.characterAnimations[getCorrectKeyCount(true) - 1][direction] + "miss", true);
else
dad.playAnim(NoteVariables.Character_Animation_Arrays[getCorrectKeyCount(true) - 1][direction] + "miss", true);
dad.playAnim(NoteVariables.characterAnimations[getCorrectKeyCount(true) - 1][direction] + "miss", true);
}

calculateAccuracy();
Expand Down Expand Up @@ -3418,7 +3418,7 @@ class PlayState extends MusicBeatState {
note.character
];

var singAnim:String = NoteVariables.Character_Animation_Arrays[getCorrectKeyCount(true) - 1][Std.int(Math.abs(note.noteData % getCorrectKeyCount(true)))]
var singAnim:String = NoteVariables.characterAnimations[getCorrectKeyCount(true) - 1][Std.int(Math.abs(note.noteData % getCorrectKeyCount(true)))]
+ (characterPlayingAs == 1 ? altAnim : "")
+ note.singAnimSuffix;
if (note.singAnimPrefix != 'sing') {
Expand Down
6 changes: 3 additions & 3 deletions source/substates/ControlMenuSubstate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class ControlMenuSubstate extends MusicBeatSubstate
{
if(reset && shift)
{
binds = NoteVariables.Default_Binds;
binds = NoteVariables.defaultBinds;
fullscreenBind = "F11";
killBind = "R";
pauseBind = "ENTER";
Expand Down Expand Up @@ -253,8 +253,8 @@ class ControlMenuSubstate extends MusicBeatSubstate
if(keyCount < 1)
keyCount = 1;

if(keyCount > NoteVariables.Note_Count_Directions.length)
keyCount = NoteVariables.Note_Count_Directions.length;
if(keyCount > NoteVariables.maniaDirections.length)
keyCount = NoteVariables.maniaDirections.length;

create_Arrows();
}
Expand Down
Loading

0 comments on commit 2683c35

Please sign in to comment.