Skip to content

Commit 9d639cb

Browse files
committed
Add preference for score separation with separator types
1 parent b1a37a7 commit 9d639cb

File tree

4 files changed

+59
-3
lines changed

4 files changed

+59
-3
lines changed

source/funkin/Preferences.hx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,44 @@ class Preferences
436436
return value;
437437
}
438438

439+
/**
440+
* Determines the thousands separators type for the score:
441+
* - `"Comma"` -> uses commas, e.g. `1,000`
442+
* - `"Period"` -> uses periods, e.g. `1.000`
443+
* - `"Off"` -> no separator, e.g. `1000`
444+
*
445+
* @default `"Comma"`
446+
*/
447+
public static var separatedScore(get, set):String;
448+
449+
static function get_separatedScore():String
450+
{
451+
var value = Save?.instance?.options?.commaSeparatedScore ?? "Comma";
452+
return value;
453+
}
454+
455+
static function set_separatedScore(value:String):String
456+
{
457+
var normalized:String = value.toLowerCase();
458+
459+
var result:String = switch (normalized)
460+
{
461+
case "off":
462+
"Off";
463+
case "comma":
464+
"Comma";
465+
case "period":
466+
"Period";
467+
default:
468+
"Comma";
469+
};
470+
471+
var save:Save = Save.instance;
472+
save.options.commaSeparatedScore = result;
473+
save.flush();
474+
return result;
475+
}
476+
439477
/**
440478
* If enabled, the game will hide the mouse when taking a screenshot.
441479
* @default `true`

source/funkin/play/PlayState.hx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2558,9 +2558,9 @@ class PlayState extends MusicBeatSubState
25582558
}
25592559
else
25602560
{
2561-
// TODO: Add an option for this maybe?
2562-
var commaSeparated:Bool = true;
2563-
scoreText.text = 'Score: ${FlxStringUtil.formatMoney(songScore, false, commaSeparated)}';
2561+
var commaSeparated:Bool = Preferences.separatedScore == "Comma";
2562+
var score:String = Preferences.separatedScore != "Off" ? FlxStringUtil.formatMoney(songScore, false, commaSeparated) : Std.string(songScore);
2563+
scoreText.text = 'Score: ${score}';
25642564
}
25652565
}
25662566

source/funkin/save/Save.hx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class Save implements ConsoleClass
130130
videoSubtitles: true,
131131
vsyncMode: 'Off',
132132
strumlineBackgroundOpacity: 0,
133+
separatedScore: "Comma",
133134
autoFullscreen: false,
134135
globalOffset: 0,
135136
audioVisualOffset: 0,
@@ -1655,6 +1656,16 @@ typedef SaveDataOptions =
16551656
*/
16561657
var strumlineBackgroundOpacity:Int;
16571658

1659+
/**
1660+
* Determines the thousands separators type for the score:
1661+
* - `"Comma"` -> uses commas, e.g. `1,000`
1662+
* - `"Period"` -> uses periods, e.g. `1.000`
1663+
* - `"Off"` -> no separator, e.g. `1000`
1664+
*
1665+
* @default `"Comma"`
1666+
*/
1667+
var separatedScore:String;
1668+
16581669
/**
16591670
* If enabled, the game will automatically launch in fullscreen on startup.
16601671
* @default `true`

source/funkin/ui/options/PreferencesMenu.hx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ class PreferencesMenu extends Page<OptionsState.OptionsMenuPageName>
121121
createPrefItemPercentage('Strumline Background', 'Give the strumline a semi-transparent background', function(value:Int):Void {
122122
Preferences.strumlineBackgroundOpacity = value;
123123
}, Preferences.strumlineBackgroundOpacity);
124+
createPrefItemEnum('Separated Score', 'If enabled, the score will be formatted using thousands separators based on the given mode.', [
125+
"Period" => "Period",
126+
"Comma" => "Comma",
127+
"Off" => "Off"
128+
], (key:String, value:String) -> {
129+
Preferences.separatedScore = value;
130+
}, Preferences.separatedScore);
124131
#if FEATURE_HAPTICS
125132
createPrefItemEnum('Haptics', 'If enabled, game will use haptic feedback effects.', [
126133
"All" => HapticsMode.ALL,

0 commit comments

Comments
 (0)