Skip to content

Commit

Permalink
Merge branch 'Snirozu:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
mcagabe19 authored Oct 6, 2024
2 parents 3327e98 + 22aaae1 commit 92ae45b
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 38 deletions.
1 change: 1 addition & 0 deletions source/backend/ClientPrefs.hx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import states.TitleState;
public var noteSkin:String = 'Default';
public var splashSkin:String = 'Psych';
public var splashAlpha:Float = 0.6;
public var holdSplashAlpha:Float = 0.6;
public var lowQuality:Bool = false;
public var shaders:Bool = true;
public var cacheOnGPU:Bool = #if !switch false #else true #end; //From Stilic
Expand Down
2 changes: 2 additions & 0 deletions source/objects/Character.hx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class Character extends FlxSprite {
public var healthColorArray:Array<Int> = [255, 0, 0];

public var isSkin:Bool = false;
public var loadFailed:Bool = false;

public static var DEFAULT_CHARACTER:String = 'bf'; // In case a character is missing, it will use BF on its place

Expand Down Expand Up @@ -104,6 +105,7 @@ class Character extends FlxSprite {
if (!Assets.exists(path))
#end
{
loadFailed = true;
path = Paths.getPreloadPath('characters/' + DEFAULT_CHARACTER +
'.json'); // If a character couldn't be found, change him to BF just to prevent a crash
}
Expand Down
1 change: 1 addition & 0 deletions source/objects/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class Note extends FlxSprite
b: -1,
a: ClientPrefs.data.splashAlpha
};
public var noteHoldSplash:SustainSplash;

public var offsetX:Float = 0;
public var offsetY:Float = 0;
Expand Down
45 changes: 26 additions & 19 deletions source/objects/SustainSplash.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class SustainSplash extends FlxSprite {
public static var frameRate:Int;
public var strumNote:StrumNote;

var timer:FlxTimer;

public static var defaultNoteHoldSplash(default, never):String = 'noteSplashes/holdSplashes/holdSplash';

public function new():Void {
Expand All @@ -20,19 +22,16 @@ class SustainSplash extends FlxSprite {

animation.addByPrefix('hold', 'hold', 24, true);
animation.addByPrefix('end', 'end', 24, false);
animation.play('hold', true, false, 0);
animation.curAnim.frameRate = frameRate;
animation.curAnim.looped = true;
}

override function update(elapsed) {
super.update(elapsed);

if (strumNote != null) {
alpha = ClientPrefs.data.splashAlpha - (1 - strumNote.alpha);
alpha = ClientPrefs.data.holdSplashAlpha - (1 - strumNote.alpha);

if (animation.curAnim.name == "hold" && strumNote.animation.curAnim.name == "static") {
visible = false;
kill();
}
}
}
Expand All @@ -45,6 +44,10 @@ class SustainSplash extends FlxSprite {

var tailEnd:Note = !daNote.isSustainNote ? daNote.tail[daNote.tail.length - 1] : daNote.parent.tail[daNote.parent.tail.length - 1];

animation.play('hold', true, false, 0);
animation.curAnim.frameRate = frameRate;
animation.curAnim.looped = true;

clipRect = new flixel.math.FlxRect(0, !PlayState.isPixelStage ? 0 : -210, frameWidth, frameHeight);

if (daNote.shader != null) {
Expand All @@ -56,24 +59,28 @@ class SustainSplash extends FlxSprite {
}

strumNote = strum;
alpha = ClientPrefs.data.splashAlpha - (1 - strumNote.alpha);
alpha = ClientPrefs.data.holdSplashAlpha - (1 - strumNote.alpha);
setPosition(strum.x, strum.y);
offset.set(PlayState.isPixelStage ? 112.5 : 106.25, 100);

new FlxTimer().start(timeThingy, (idk:FlxTimer) -> {
if (PlayState.isPlayerNote(tailEnd) && !(daNote.isSustainNote ? daNote.parent.noteSplashData.disabled : daNote.noteSplashData.disabled) && ClientPrefs.data.splashAlpha != 0) {
alpha = ClientPrefs.data.splashAlpha - (1 - strumNote.alpha);
animation.play('end', true, false, 0);
animation.curAnim.looped = false;
animation.curAnim.frameRate = 24;
clipRect = null;
animation.finishCallback = (idkEither:Dynamic) -> {
visible = false;
if (timer != null)
timer.cancel();

if (PlayState.isPlayerNote(tailEnd) && ClientPrefs.data.holdSplashAlpha != 0)
timer = new FlxTimer().start(timeThingy, (idk:FlxTimer) -> {
if (!(daNote.isSustainNote ? daNote.parent.noteSplashData.disabled : daNote.noteSplashData.disabled)) {
alpha = ClientPrefs.data.holdSplashAlpha - (1 - strumNote.alpha);
animation.play('end', true, false, 0);
animation.curAnim.looped = false;
animation.curAnim.frameRate = 24;
clipRect = null;
animation.finishCallback = (idkEither:Dynamic) -> {
kill();
}
return;
}
return;
}
visible = false;
});
kill();
});

}

Expand Down
13 changes: 12 additions & 1 deletion source/options/VisualsUISubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class VisualsUISubState extends BaseOptionsMenu
}

var option:Option = new Option('Note Splash Opacity',
'How much transparent should the Note Splashes be.',
'How much transparent should the Note Splashes be.\n0% disables it.',
'splashAlpha',
'percent');
option.scrollSpeed = 1.6;
Expand All @@ -72,6 +72,17 @@ class VisualsUISubState extends BaseOptionsMenu
option.decimals = 1;
addOption(option);

var option:Option = new Option('Note Hold Splash Opacity',
'How much transparent should the Note Hold Splash be.\n0% disables it.',
'holdSplashAlpha',
'percent');
option.scrollSpeed = 1.6;
option.minValue = 0.0;
option.maxValue = 1;
option.changeValue = 0.1;
option.decimals = 1;
addOption(option);

var option:Option = new Option('Hide HUD',
'If checked, hides most HUD elements.',
'hideHud',
Expand Down
35 changes: 17 additions & 18 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ class PlayState extends MusicBeatState
dad = new Character(0, 0, ClientPrefs.data.modSkin[1] + skinsSuffix, !playsAsBF(), true);
}

if (dad == null) {
if (dad == null || dad.loadFailed) {
Mods.currentModDirectory = oldModDir;
dad = new Character(0, 0, SONG.player2, !playsAsBF());
}
Expand Down Expand Up @@ -787,7 +787,7 @@ class PlayState extends MusicBeatState
boyfriend = new Character(0, 0, ClientPrefs.data.modSkin[1] + skinsSuffix + "-player", playsAsBF(), true);
}

if (boyfriend == null) {
if (boyfriend == null || boyfriend.loadFailed) {
Mods.currentModDirectory = oldModDir;
boyfriend = new Character(0, 0, SONG.player1, playsAsBF());
}
Expand Down Expand Up @@ -3965,8 +3965,8 @@ class PlayState extends MusicBeatState
});

final end:Note = daNote.isSustainNote ? daNote.parent.tail[daNote.parent.tail.length - 1] : daNote.tail[daNote.tail.length - 1];
if (end != null && end.extraData['holdSplash'] != null) {
end.extraData['holdSplash'].visible = false;
if (end != null && end.noteHoldSplash != null) {
end.noteHoldSplash.kill();
}

noteMissCommon(daNote.noteData, daNote);
Expand Down Expand Up @@ -4214,29 +4214,28 @@ class PlayState extends MusicBeatState
}

public function spawnHoldSplashOnNote(note:Note) {
if (!note.isSustainNote && note.tail.length != 0 && note.tail[note.tail.length - 1].extraData['holdSplash'] == null) {
spawnHoldSplash(note);
} else if (note.isSustainNote) {
final end:Note = StringTools.endsWith(note.animation.curAnim.name, 'end') ? note : note.parent.tail[note.parent.tail.length - 1];
if (end != null) {
var leSplash:SustainSplash = end.extraData['holdSplash'];
if (leSplash == null && !end.parent.wasGoodHit) {
spawnHoldSplash(end);
} else if (leSplash != null) {
leSplash.visible = true;
}
}
if (ClientPrefs.data.holdSplashAlpha <= 0)
return;

if (note != null) {
var strum:StrumNote = (note.mustPress ? playerStrums : opponentStrums).members[note.noteData];

if(strum != null && note.tail.length != 0)
spawnHoldSplash(note);
}
}

public function spawnHoldSplash(note:Note) {
var end:Note = note.isSustainNote ? note.parent.tail[note.parent.tail.length - 1] : note.tail[note.tail.length - 1];
var splash:SustainSplash = grpHoldSplashes.recycle(SustainSplash);
splash.setupSusSplash(getPlayerStrums().members[note.noteData], note, playbackRate);
grpHoldSplashes.add(end.extraData['holdSplash'] = splash);
splash.setupSusSplash((note.mustPress ? playerStrums : opponentStrums).members[note.noteData], note, playbackRate);
grpHoldSplashes.add(end.noteHoldSplash = splash);
}

public function spawnNoteSplashOnNote(note:Note) {
if (ClientPrefs.data.splashAlpha <= 0)
return;

if(note != null) {
var strum:StrumNote = getPlayerStrums().members[note.noteData];
if(strum != null)
Expand Down

0 comments on commit 92ae45b

Please sign in to comment.