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
Show file tree
Hide file tree
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
Next Next commit
improve countdown in terms of modding
  • Loading branch information
crowplexus committed Aug 29, 2024
commit da46ed7bba2253ae6777b154d67a83681023e258
3 changes: 2 additions & 1 deletion assets/base_game/shared/stages/limo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"directory": "week4",
"defaultZoom": 0.9,
"stageUI": "",
"introSounds": ["intro3", "intro2", "intro1", "introGo"],

"boyfriend": [1030, -120],
"girlfriend": [400, 130],
Expand All @@ -27,4 +28,4 @@
"boyfriend": "bf-car",
"gf": "gf-car"
}
}
}
3 changes: 2 additions & 1 deletion assets/base_game/shared/stages/mall.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"directory": "week5",
"defaultZoom": 0.8,
"stageUI": "",
"introSounds": ["intro3", "intro2", "intro1", "introGo"],

"boyfriend": [970, 100],
"girlfriend": [400, 130],
Expand All @@ -28,4 +29,4 @@
"boyfriend": "bf-christmas",
"gf": "gf-christmas"
}
}
}
3 changes: 2 additions & 1 deletion assets/base_game/shared/stages/mallEvil.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"directory": "week5",
"defaultZoom": 1.05,
"stageUI": "",
"introSounds": ["intro3", "intro2", "intro1", "introGo"],

"boyfriend": [1090, 100],
"girlfriend": [400, 130],
Expand All @@ -24,4 +25,4 @@
"boyfriend": "bf-christmas",
"gf": "gf-christmas"
}
}
}
3 changes: 2 additions & 1 deletion assets/base_game/shared/stages/philly.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"directory": "week3",
"defaultZoom": 1.05,
"stageUI": "",
"introSounds": ["intro3", "intro2", "intro1", "introGo"],

"boyfriend": [770, 100],
"girlfriend": [400, 130],
Expand All @@ -27,4 +28,4 @@
"boyfriend": "bf",
"gf": "gf"
}
}
}
3 changes: 2 additions & 1 deletion assets/base_game/shared/stages/phillyBlazin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"directory": "weekend1",
"defaultZoom": 0.75,
"stageUI": "",
"introSounds": ["intro3", "intro2", "intro1", "introGo"],

"boyfriend": [900, 800],
"girlfriend": [470, 595],
Expand Down Expand Up @@ -30,4 +31,4 @@
"boyfriend": "pico-playable",
"gf": "nene"
}
}
}
3 changes: 2 additions & 1 deletion assets/base_game/shared/stages/phillyStreets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"directory": "weekend1",
"defaultZoom": 0.77,
"stageUI": "",
"introSounds": ["intro3", "intro2", "intro1", "introGo"],

"boyfriend": [1930, 450],
"girlfriend": [1175, 200],
Expand Down Expand Up @@ -38,4 +39,4 @@
"boyfriend": "pico-playable",
"gf": "nene"
}
}
}
3 changes: 2 additions & 1 deletion assets/base_game/shared/stages/school.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"directory": "week6",
"defaultZoom": 1.05,
"stageUI": "pixel",
"introSounds": ["intro3-pixel", "intro2-pixel", "intro1-pixel", "introGo-pixel"],

"boyfriend": [970, 320],
"girlfriend": [580, 430],
Expand All @@ -28,4 +29,4 @@
"boyfriend": "bf-pixel",
"gf": "gf-pixel"
}
}
}
3 changes: 2 additions & 1 deletion assets/base_game/shared/stages/schoolEvil.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"directory": "week6",
"defaultZoom": 1.05,
"stageUI": "pixel",
"introSounds": ["intro3-pixel", "intro2-pixel", "intro1-pixel", "introGo-pixel"],

"boyfriend": [970, 320],
"girlfriend": [580, 430],
Expand All @@ -24,4 +25,4 @@
"boyfriend": "bf-pixel",
"gf": "gf-pixel"
}
}
}
3 changes: 2 additions & 1 deletion assets/base_game/shared/stages/spooky.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"directory": "week2",
"defaultZoom": 1.05,
"stageUI": "",
"introSounds": ["intro3", "intro2", "intro1", "introGo"],

"boyfriend": [770, 100],
"girlfriend": [400, 130],
Expand All @@ -23,4 +24,4 @@
"boyfriend": "bf",
"gf": "gf"
}
}
}
3 changes: 2 additions & 1 deletion assets/base_game/shared/stages/stage.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"directory": "week1",
"defaultZoom": 0.9,
"stageUI": "",
"introSounds": ["intro3", "intro2", "intro1", "introGo"],

"boyfriend": [770, 100],
"girlfriend": [400, 130],
Expand All @@ -25,4 +26,4 @@
"boyfriend": "bf",
"gf": "gf"
}
}
}
3 changes: 2 additions & 1 deletion assets/base_game/shared/stages/tank.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"directory": "week7",
"defaultZoom": 0.9,
"stageUI": "",
"introSounds": ["intro3-pixel", "intro2-pixel", "intro1-pixel", "introGo-pixel"],

"boyfriend": [810, 100],
"girlfriend": [200, 65],
Expand Down Expand Up @@ -31,4 +32,4 @@
"boyfriend": "bf",
"gf": "gf-tankmen"
}
}
}
4 changes: 2 additions & 2 deletions setup/unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ haxelib install lime 8.1.2
haxelib install openfl 9.3.3
haxelib install flixel 5.6.1
haxelib install flixel-addons 3.2.2
haxelib install flixel-tools 1.5.1
haxelib install flixel-tools 1.5.1
haxelib install hscript-iris 1.0.2
haxelib install tjson 1.4.0
haxelib git flxanimate https://github.com/Dot-Stuff/flxanimate 768740a56b26aa0c072720e0d1236b94afe68e3e
haxelib git linc_luajit https://github.com/superpowers04/linc_luajit 633fcc051399afed6781dd60cbf30ed8c3fe2c5a
haxelib git hxdiscord_rpc https://github.com/MAJigsaw77/hxdiscord_rpc 3538a1c2bb07b04208cd014220207f8173acdb21
haxelib git hxvlc https://github.com/MAJigsaw77/hxvlc 70e7f5f3e76d526ac6fb8f0e6665efe7dfda589d
haxelib git funkin.vis https://github.com/FunkinCrew/funkVis d5361037efa3a02c4ab20b5bd14ca11e7d00f519
haxelib git funkin.vis https://github.com/FunkinCrew/funkVis 22b1ce089dd924f15cdc4632397ef3504d464e90
haxelib git grig.audio https://gitlab.com/haxe-grig/grig.audio.git cbf91e2180fd2e374924fe74844086aab7891666
echo Finished!
2 changes: 1 addition & 1 deletion setup/windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ haxelib git flxanimate https://github.com/Dot-Stuff/flxanimate 768740a56b26aa0c0
haxelib git linc_luajit https://github.com/superpowers04/linc_luajit 633fcc051399afed6781dd60cbf30ed8c3fe2c5a
haxelib git hxdiscord_rpc https://github.com/MAJigsaw77/hxdiscord_rpc 3538a1c2bb07b04208cd014220207f8173acdb21
haxelib git hxvlc https://github.com/MAJigsaw77/hxvlc 70e7f5f3e76d526ac6fb8f0e6665efe7dfda589d
haxelib git funkin.vis https://github.com/FunkinCrew/funkVis d5361037efa3a02c4ab20b5bd14ca11e7d00f519
haxelib git funkin.vis https://github.com/FunkinCrew/funkVis 22b1ce089dd924f15cdc4632397ef3504d464e90
haxelib git grig.audio https://gitlab.com/haxe-grig/grig.audio.git cbf91e2180fd2e374924fe74844086aab7891666
echo Finished!
pause
14 changes: 14 additions & 0 deletions source/backend/CoolUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ class CoolUtil
inline public static function capitalize(text:String)
return text.charAt(0).toUpperCase() + text.substr(1).toLowerCase();

/**
* Plays a sound safely by checking if it exists or not.
*
* made to play some sounds in-game with no concerns as to whether it will crash or not.
*
* this is safer than calling Paths.sound due to an extra check
* @param sound The sound stream (i.e: String, openfl.media.Sound, etc)
* @param volume Sound's volume
**/
public static function playSoundSafe(sound:flixel.system.FlxAssets.FlxSoundAsset, ?beepOnError: Bool = true, volume: Float = 1.0)
{
if(sound != null) FlxG.sound.play(sound, volume);
}

inline public static function coolTextFile(path:String):Array<String>
{
var daList:String = null;
Expand Down
12 changes: 6 additions & 6 deletions source/backend/Paths.hx
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ class Paths
return 'assets/videos/$key.$VIDEO_EXT';
}

inline static public function sound(key:String, ?modsAllowed:Bool = true):Sound
return returnSound('sounds/$key', modsAllowed);
inline static public function sound(key:String, ?modsAllowed:Bool = true, ?playBeep: Bool = true):Sound
return returnSound('sounds/$key', null, modsAllowed, playBeep);

inline static public function music(key:String, ?modsAllowed:Bool = true):Sound
return returnSound('music/$key', modsAllowed);
inline static public function music(key:String, ?modsAllowed:Bool = true, ?playBeep: Bool = true):Sound
return returnSound('music/$key', null, modsAllowed, playBeep);

inline static public function inst(song:String, ?modsAllowed:Bool = true):Sound
return returnSound('${formatToSongPath(song)}/Inst', 'songs', modsAllowed);
Expand Down Expand Up @@ -198,7 +198,7 @@ class Paths

if (bitmap == null)
{
trace('oh no its returning null NOOOO ($file)');
trace('Tried loading bitmap, caught null at "$file"');
return null;
}
}
Expand Down Expand Up @@ -246,7 +246,7 @@ class Paths
return 'assets/fonts/$key';
}

public static function fileExists(key:String, type:AssetType, ?ignoreMods:Bool = false, ?parentFolder:String = null)
public static function fileExists(key:String, ?type:AssetType = TEXT, ?ignoreMods:Bool = false, ?parentFolder:String = null)
{
#if MODS_ALLOWED
if(!ignoreMods)
Expand Down
3 changes: 3 additions & 0 deletions source/backend/StageData.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ typedef StageFile = {
var defaultZoom:Float;
@:optional var isPixelStage:Null<Bool>;
var stageUI:String;
@default(["intro3", "intro2", "intro1", "introGo"])
var introSounds: Array<String>;

var boyfriend:Array<Dynamic>;
var girlfriend:Array<Dynamic>;
Expand Down Expand Up @@ -42,6 +44,7 @@ class StageData {
directory: "",
defaultZoom: 0.9,
stageUI: "normal",
introSounds: ["intro3", "intro2", "intro1", "introGo"],

boyfriend: [770, 100],
girlfriend: [400, 130],
Expand Down
2 changes: 1 addition & 1 deletion source/states/MainMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ class MainMenuState extends MusicBeatState
}
}
});

for (memb in menuItems)
{
if(memb == item)
Expand Down
74 changes: 43 additions & 31 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ class PlayState extends MusicBeatState
case 'phillyStreets': new PhillyStreets(); //Weekend 1 - Darnell, Lit Up, 2Hot
case 'phillyBlazin': new PhillyBlazin(); //Weekend 1 - Blazin
}
if(isPixelStage) introSoundsSuffix = '-pixel';

#if (LUA_ALLOWED || HSCRIPT_ALLOWED)
luaDebugGroup = new FlxTypedGroup<psychlua.DebugLuaText>();
Expand Down Expand Up @@ -899,27 +898,38 @@ class PlayState extends MusicBeatState
var finishTimer:FlxTimer = null;

// 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 static var startOnTime:Float = 0;

function cacheCountdown()
{
var introAssets:Map<String, Array<String>> = new Map<String, Array<String>>();
var introImagesArray:Array<String> = switch(stageUI) {
case "pixel": ['${stageUI}UI/ready-pixel', '${stageUI}UI/set-pixel', '${stageUI}UI/date-pixel'];
case "normal": ["ready", "set" ,"go"];
default: ['${stageUI}UI/ready', '${stageUI}UI/set', '${stageUI}UI/go'];
}
introAssets.set(stageUI, introImagesArray);
var introAlts:Array<String> = introAssets.get(stageUI);
for (asset in introAlts) Paths.image(asset);
var introSprites:Array<String> = getCountdownSpriteNames(stageUI);
var introSounds:Array<String> = getCountdownSoundNames(stageUI);
if(introSounds.length < 3) introSounds.resize(3);
for (asset in introSprites) Paths.image(asset);
for (sound in introSounds) Paths.sound(sound + introSoundsSuffix, true, false); // this should cover backwards compat
}

function getCountdownSpriteNames(?givenUI: Null<String>):Array<String> {
if(givenUI == null) givenUI = stageUI;
return switch(givenUI) {
case "pixel": ['${givenUI}UI/ready-pixel', '${givenUI}UI/ready-pixel', '${givenUI}UI/set-pixel', '${givenUI}UI/date-pixel'];
case "normal": ["prepare", "ready", "set" ,"go"];
default: ['${givenUI}UI/prepare', '${givenUI}UI/ready', '${givenUI}UI/set', '${givenUI}UI/go'];
};
}

Paths.sound('intro3' + introSoundsSuffix);
Paths.sound('intro2' + introSoundsSuffix);
Paths.sound('intro1' + introSoundsSuffix);
Paths.sound('introGo' + introSoundsSuffix);
function getCountdownSoundNames(?givenUI: Null<String>):Array<String> {
if(givenUI == null) givenUI = stageUI;
var stageData:StageFile = StageData.getStageFile(curStage);
var introSounds:Array<String> = ["intro3", "intro2", "intro1", "introGo"];
if(stageData.introSounds != null) introSounds = stageData.introSounds;
return switch(givenUI) { // add custom ones here if you need to
default: introSounds;
}
}

public function startCountdown()
Expand Down Expand Up @@ -970,34 +980,29 @@ class PlayState extends MusicBeatState
{
characterBopper(tmr.loopsLeft);

var introAssets:Map<String, Array<String>> = new Map<String, Array<String>>();
var introImagesArray:Array<String> = switch(stageUI) {
case "pixel": ['${stageUI}UI/ready-pixel', '${stageUI}UI/set-pixel', '${stageUI}UI/date-pixel'];
case "normal": ["ready", "set" ,"go"];
default: ['${stageUI}UI/ready', '${stageUI}UI/set', '${stageUI}UI/go'];
}
introAssets.set(stageUI, introImagesArray);

var introAlts:Array<String> = introAssets.get(stageUI);
var introSprites:Array<String> = getCountdownSpriteNames(stageUI);
var introSounds: Array<String> = getCountdownSoundNames(stageUI);
if(introSounds.length < 3) introSounds.resize(3); // safety measure
var antialias:Bool = (ClientPrefs.data.antialiasing && !isPixelStage);
var tick:Countdown = THREE;

switch (swagCounter)
{
case 0:
FlxG.sound.play(Paths.sound('intro3' + introSoundsSuffix), 0.6);
countdownPrepare = createCountdownSprite(introSprites[0], antialias);
CoolUtil.playSoundSafe(Paths.sound(introSounds[0] + introSoundsSuffix, true, false), 0.6);
tick = THREE;
case 1:
countdownReady = createCountdownSprite(introAlts[0], antialias);
FlxG.sound.play(Paths.sound('intro2' + introSoundsSuffix), 0.6);
countdownReady = createCountdownSprite(introSprites[1], antialias);
CoolUtil.playSoundSafe(Paths.sound(introSounds[1] + introSoundsSuffix, true, false), 0.6);
tick = TWO;
case 2:
countdownSet = createCountdownSprite(introAlts[1], antialias);
FlxG.sound.play(Paths.sound('intro1' + introSoundsSuffix), 0.6);
countdownSet = createCountdownSprite(introSprites[2], antialias);
CoolUtil.playSoundSafe(Paths.sound(introSounds[2] + introSoundsSuffix, true, false), 0.6);
tick = ONE;
case 3:
countdownGo = createCountdownSprite(introAlts[2], antialias);
FlxG.sound.play(Paths.sound('introGo' + introSoundsSuffix), 0.6);
countdownGo = createCountdownSprite(introSprites[3], antialias);
CoolUtil.playSoundSafe(Paths.sound(introSounds[3] + introSoundsSuffix, true, false), 0.6);
tick = GO;
case 4:
tick = START;
Expand Down Expand Up @@ -1028,7 +1033,14 @@ class PlayState extends MusicBeatState

inline private function createCountdownSprite(image:String, antialias:Bool):FlxSprite
{
var spr:FlxSprite = new FlxSprite().loadGraphic(Paths.image(image));
var countdownGraphic = Paths.image(image);
if (countdownGraphic == null) {
var dum:FlxSprite = new FlxSprite();
new FlxTimer().start(Conductor.crochet / 1000, function(_) dum.destroy());
return dum; // return an empty sprite if the image doesn't exist
}

var spr:FlxSprite = new FlxSprite().loadGraphic(countdownGraphic);
spr.cameras = [camHUD];
spr.scrollFactor.set();
spr.updateHitbox();
Expand Down
2 changes: 1 addition & 1 deletion source/states/stages/objects/ABotSpeaker.hx
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,4 @@ class ABotSpeaker extends FlxSpriteGroup
if(!lookingAtRight) eyes.anim.play('lookright', true);
lookingAtRight = true;
}
}
}