Skip to content

Commit d2ab61b

Browse files
committed
Improve death counter in pause menu
1 parent 81f81f2 commit d2ab61b

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed

source/funkin/data/freeplay/player/PlayerData.hx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ class PlayerData
3131
@:default(false)
3232
public var showUnownedChars:Bool = false;
3333

34+
/**
35+
* The name used for the character's type of death as seen on the pause menu.
36+
*/
37+
@:optional
38+
public var deathName:String = 'Deaths';
39+
40+
/**
41+
* The name used for the character's type of death as seen on the pause menu when the death count is at 1.
42+
*/
43+
@:optional
44+
public var deathNameSingular:String = 'Death';
45+
3446
/**
3547
* The default sticker pack to use for songs featuring this playable character.
3648
* Can be overridden by specific songs.

source/funkin/play/PauseSubState.hx

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,16 @@ class PauseSubState extends MusicBeatSubState
458458
metadataDifficulty.scrollFactor.set(0, 0);
459459
metadata.add(metadataDifficulty);
460460

461-
metadataDeaths = new FlxText(20, metadataDifficulty.y + 32, camera.width - Math.max(40, funkin.ui.FullScreenScaleMode.gameNotchSize.x),
462-
'${PlayState.instance?.deathCounter} Blue Balls');
461+
if (PlayState.instance.deathCounter != 1)
462+
{
463+
metadataDeaths = new FlxText(20, metadataDifficulty.y + 32, camera.width - Math.max(40, funkin.ui.FullScreenScaleMode.gameNotchSize.x),
464+
'${PlayState.instance?.deathCounter} Deaths');
465+
}
466+
else
467+
{
468+
metadataDeaths = new FlxText(20, metadataDifficulty.y + 32, camera.width - Math.max(40, funkin.ui.FullScreenScaleMode.gameNotchSize.x),
469+
'${PlayState.instance?.deathCounter} Death');
470+
}
463471
metadataDeaths.setFormat(Paths.font('vcr.ttf'), 32, FlxColor.WHITE, FlxTextAlign.RIGHT);
464472
metadataDeaths.scrollFactor.set(0, 0);
465473
metadata.add(metadataDeaths);
@@ -944,10 +952,30 @@ class PauseSubState extends MusicBeatSubState
944952
}
945953
#end
946954

955+
var playerCharacterId = PlayerRegistry.instance.getCharacterOwnerId(PlayState.instance.currentChart.characters.player);
956+
var playerCharacter = PlayerRegistry.instance.fetchEntry(playerCharacterId ?? Constants.DEFAULT_CHARACTER);
957+
947958
switch (this.currentMode)
948959
{
949960
case Standard | Difficulty:
950-
metadataDeaths.text = '${PlayState.instance?.deathCounter} Blue Balls';
961+
if (PlayState.instance.deathCounter != 1)
962+
{
963+
metadataDeaths.text = '${PlayState.instance?.deathCounter} ${playerCharacter.getDeathName()}';
964+
}
965+
/**
966+
* Singularize the character's type of death if the death count equals 1.
967+
* Print singular death name only if using default plural death name (meaning singular death name is likely also default),
968+
* or not using default singular death name (meaning plural death name is likely also not default).
969+
*/
970+
else if (playerCharacter.getDeathName() == "Deaths" || playerCharacter.getDeathNameSingular() != "Death")
971+
{
972+
metadataDeaths.text = '${PlayState.instance?.deathCounter} ${playerCharacter.getDeathNameSingular()}';
973+
}
974+
// If using default singular death name, but custom plural death name, print the plural death name.
975+
else
976+
{
977+
metadataDeaths.text = '${PlayState.instance?.deathCounter} ${playerCharacter.getDeathName()}';
978+
}
951979
case Charting:
952980
metadataDeaths.text = 'Chart Editor Preview';
953981
case Conversation:

source/funkin/ui/freeplay/charselect/PlayableCharacter.hx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,22 @@ class PlayableCharacter implements IRegistryEntry<PlayerData>
6969
return false;
7070
}
7171

72+
/**
73+
* Retrieve the name of the character's type of death.
74+
*/
75+
public function getDeathName():String
76+
{
77+
return _data?.deathName ?? "Deaths";
78+
}
79+
80+
/**
81+
* Retrieve the name of the character's type of death in singular form.
82+
*/
83+
public function getDeathNameSingular():String
84+
{
85+
return _data?.deathNameSingular ?? "Death";
86+
}
87+
7288
public function getStickerPackID():String
7389
{
7490
return _data?.stickerPack ?? Constants.DEFAULT_STICKER_PACK;

0 commit comments

Comments
 (0)