Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Countdown Modifications #15439

Open
wants to merge 7 commits into
base: experimental
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update PlayState.hx
  • Loading branch information
crowplexus committed Sep 16, 2024
commit 14fc0e3c1d5d6a2a2fed86a60c80062eb0d68288
18 changes: 11 additions & 7 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ class PlayState extends MusicBeatState

introSoundNames = stageData.introSounds;
if(introSoundNames == null || introSoundNames.length < 4)
introSoundNames = getCountdownSoundNames(stageUI); // safety measure
introSoundNames = getDefaultCountdownSounds(stageUI); // in case stageData doesn't have any sounds
for(sndName in introSoundNames) {
if(sndName == null) continue;
// trim trailing spaces in the sound, just in case, JUST in case.
Expand Down Expand Up @@ -909,11 +909,14 @@ class PlayState extends MusicBeatState
var startTimer:FlxTimer;
var finishTimer:FlxTimer = null;

// I would make a countdown class to handle this better but honestly this works fine
// it's a BIT cluttered due to everything being in playstate, but it works @crowplexus
// For being able to mess with the sprites on Lua
public var countdownPrepare:FlxSprite; // new additional sprite, for "three" sound during countdown
public var countdownReady:FlxSprite;
public var countdownSet:FlxSprite;
public var countdownGo:FlxSprite;
public var countdownReady:FlxSprite; // two
public var countdownSet:FlxSprite; // one
public var countdownGo:FlxSprite; // go

public static var startOnTime:Float = 0;

function cacheCountdown()
Expand All @@ -932,11 +935,12 @@ class PlayState extends MusicBeatState
};
}

function getCountdownSoundNames(?givenUI: Null<String>):Array<String> {
function getDefaultCountdownSounds(?givenUI: Null<String>):Array<String> {
// function to prevent null strings for countdown sounds, if you need to hardcode anything
// this is your place to do it
if(givenUI == null) givenUI = stageUI;
var sounds: Array<String> = ["intro3", "intro2", "intro1", "introGo"];
return switch(givenUI) { // add custom ones here if you need to hardcode or something
default: sounds;
default: ["intro3", "intro2", "intro1", "introGo"];
}
}

Expand Down