Skip to content

Commit 20942d5

Browse files
committed
new setting and i shouldve tested before pushing to prod but fuckit
1 parent 8fa8d25 commit 20942d5

File tree

3 files changed

+46
-8
lines changed

3 files changed

+46
-8
lines changed

mod.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,17 @@
145145
"type": "bool",
146146
"default": false
147147
},
148+
"showTotalAttemptsAndJumps": {
149+
"name": "Show Total Attempts + Jumps",
150+
"description": "Shows your total attempt/jump count for each level, even Platformer levels (if <cl>\"Plat. Attempts + Jumps\"</c> is enabled).\n\n- Disabled: This feature is disabled. Not much to say there.\n-Fully Replace: Fully replaces the displayed attempt/jump count with the total attempt/jump count instead.\n-Show as Addt'l Info: Shows the total attempt/jump count next to the displayed attempt/jump count.",
151+
"type": "string",
152+
"default": "Disabled",
153+
"one-of": [
154+
"Disabled",
155+
"Fully Replace",
156+
"Show As Addt'l Info"
157+
]
158+
},
148159
"classicFlukedFrom": {
149160
"name": "Classic \"Fluked From\" %",
150161
"description": "<cl>Original idea by yolodomo.</c>\n\nShows your last best percentage on the \"Level Complete\" screen when completing Classic levels.\n\n<cy>To disable, set this setting to \"[Disabled]\". Otherwise, choose a prefix for this label to enable this feature.</c>\n\n<cr>I am not responsible if some of these prefix options will overlap past the borders of the endscreen or the level completion rewards; go experiment on your own.</c>",

src/EndLevelLayer.cpp

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
#include <Geode/modify/EndLevelLayer.hpp>
2-
#include <vector>
3-
#include <algorithm>
4-
#include <random>
52
#include "Manager.hpp"
63

74
#define managerMacro Manager::getSharedInstance()
@@ -169,10 +166,10 @@ class $modify(MyEndLevelLayer, EndLevelLayer) {
169166
}
170167
void applyPlatAttemptsAndJumpsOrFlukedFromPercent(GJGameLevel* theLevel) {
171168
Manager* manager = managerMacro;
172-
manager->isCompactEndscreen = Loader::get()->isModLoaded("suntle.compactendscreen");
173-
const auto playLayer = PlayLayer::get();
174-
if (!m_mainLayer|| !playLayer) return;
175-
const bool isPlat = theLevel->isPlatformer();
169+
// manager->isCompactEndscreen = Loader::get()->isModLoaded("suntle.compactendscreen");
170+
const auto playLayer = m_playLayer;
171+
if (!m_mainLayer || !playLayer) return;
172+
const bool isPlat = theLevel->isPlatformer() && playLayer->m_isPlatformer;
176173
if (getModBool("platAttemptsAndJumps") && isPlat) {
177174
const auto timeLabel = getChildByIDRecursive("time-label");
178175
if (!timeLabel) return;
@@ -202,6 +199,36 @@ class $modify(MyEndLevelLayer, EndLevelLayer) {
202199
m_mainLayer->addChild(flukedFromLabel);
203200
}
204201
}
202+
void applyTotalAttemptAndJumpCount(GJGameLevel* level) {
203+
const std::string_view showTotalAttemptsAndJumps = geode::utils::string::toLower(getModString("showTotalAttemptsAndJumps"));
204+
if (showTotalAttemptsAndJumps != "fully replace" && showTotalAttemptsAndJumps != "show as addt'l info") return;
205+
if (!getModBool("enabled") || showTotalAttemptsAndJumps == "disabled" || !level) return;
206+
207+
const bool isPlat = level->isPlatformer() && m_playLayer->m_isPlatformer;
208+
if (isPlat && !getModBool("platAttemptsAndJumps")) return;
209+
210+
CCLabelBMFont* attemptLabel = nullptr;
211+
CCLabelBMFont* jumpsLabel = nullptr;
212+
if (isPlat) {
213+
attemptLabel = static_cast<CCLabelBMFont*>(m_mainLayer->getChildByID("attempts-label"_spr));
214+
jumpsLabel = static_cast<CCLabelBMFont*>(m_mainLayer->getChildByID("jumps-label"_spr));
215+
} else {
216+
attemptLabel = static_cast<CCLabelBMFont*>(m_mainLayer->getChildByID("attempts-label"));
217+
jumpsLabel = static_cast<CCLabelBMFont*>(m_mainLayer->getChildByID("jumps-label"));
218+
}
219+
220+
if (!attemptLabel || !jumpsLabel) return;
221+
222+
const std::string& totalAttemptsString = fmt::format(std::locale("en_US.UTF-8"), "{:L}", level->m_attempts).c_str();
223+
const std::string& totalJumpsString = fmt::format(std::locale("en_US.UTF-8"), "{:L}", level->m_jumps).c_str();
224+
if (showTotalAttemptsAndJumps == "fully replace") {
225+
attemptLabel->setString(fmt::format(std::locale("en_US.UTF-8"), "Total Attempts: {}", totalAttemptsString).c_str());
226+
jumpsLabel->setString(fmt::format(std::locale("en_US.UTF-8"), "Total Jumps: {}", totalJumpsString).c_str());
227+
} else if (showTotalAttemptsAndJumps == "show as addt'l info") {
228+
attemptLabel->setString(fmt::format("{} ({})", static_cast<std::string>(attemptLabel->getString()), totalAttemptsString).c_str());
229+
jumpsLabel->setString(fmt::format("{} ({})", static_cast<std::string>(jumpsLabel->getString()), totalJumpsString).c_str());
230+
}
231+
}
205232
void applyCustomLevelCompleteText(const std::string_view matchPlayLayer) {
206233
if (!getModBool("customLevelCompleteText") || !getModBool("enabled") || !m_playLayer) return;
207234
const auto lvlCompleteText = typeinfo_cast<CCSprite*>(getChildByIDRecursive("level-complete-text"));
@@ -348,6 +375,7 @@ class $modify(MyEndLevelLayer, EndLevelLayer) {
348375
MyEndLevelLayer::applyHideChainsBackground();
349376
MyEndLevelLayer::applySpaceUK();
350377
MyEndLevelLayer::applyPlatAttemptsAndJumpsOrFlukedFromPercent(m_playLayer->m_level);
378+
MyEndLevelLayer::applyTotalAttemptAndJumpCount(m_playLayer->m_level);
351379
MyEndLevelLayer::addLoadedModsList();
352380
}
353381
void customSetup() {

src/main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include <fstream>
21
#include "Manager.hpp"
32
#include "Settings.hpp"
43
#include "boilerplate.hpp"

0 commit comments

Comments
 (0)