Skip to content

Commit 808f4f4

Browse files
committed
Add a setting for decimal precision for percentages
Signed-off-by: Kevadroz <[email protected]>
1 parent 1180094 commit 808f4f4

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Unreleased
2+
- Added a setting for decimal precision for percentages
3+
14
# 1.2.3
25
- Added support for Mod Previews
36
- Fix crash with Platformer Saves \[[Issue #3](https://github.com/Kevadroz/PracticeCheckpointPermanence/issues/3)\]

mod.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@
3636
}
3737
},
3838
"settings": {
39+
"percentage-display-decimals": {
40+
"name": "Displayed decimals for percentages",
41+
"type": "int",
42+
"default": 2,
43+
"min": 0,
44+
"max": 8,
45+
"control": {
46+
"slider": true,
47+
"slider-step": 1,
48+
"arrows": true,
49+
"arrow-step": 1
50+
}
51+
},
3952
"inactive-checkpoint-opacity": {
4053
"name": "Inactive Checkpoint Opacity",
4154
"type": "float",

src/Hooks/PlayLayerData.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void ModPlayLayer::deserializeCheckpoints() {
6666
stream.end();
6767

6868
m_fields->m_loadError = std::get<LoadError>(verificationResult);
69-
69+
7070
return;
7171
}
7272

src/UI/CheckpointManager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,8 @@ CCNode* createCheckpointCell(
431431
progressString = fmt::format("{}h", time / 3600) + progressString;
432432
}
433433
} else {
434-
progressString = fmt::format("{:.2f}%", (float)checkpoint->m_percent);
434+
int decimals = Mod::get()->getSettingValue<int>("percentage-display-decimals");
435+
progressString = fmt::format("{:.{}f}%", (float)checkpoint->m_percent, decimals);
435436
}
436437

437438
CCSprite* checkpointSprite = CCSprite::createWithSpriteFrame(

src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ using namespace keybinds;
1717
fmt::format("{}/saves/editor/", dataDir)
1818
);
1919

20-
#ifndef GEODE_IS_IOS
20+
#ifndef GEODE_IS_IOS
2121
BindManager::get()->registerBindable(
2222
{// ID, should be prefixed with mod ID
2323
"create_checkpoint"_spr,
@@ -67,5 +67,5 @@ using namespace keybinds;
6767
{Keybind::create(KEY_E, Modifier::Alt | Modifier::Shift)},
6868
"PCP"}
6969
);
70-
#endif
70+
#endif
7171
}

0 commit comments

Comments
 (0)