|
1 | 1 | #include <Geode/modify/EndLevelLayer.hpp> |
2 | | -#include <vector> |
3 | | -#include <algorithm> |
4 | | -#include <random> |
5 | 2 | #include "Manager.hpp" |
6 | 3 |
|
7 | 4 | #define managerMacro Manager::getSharedInstance() |
@@ -169,10 +166,10 @@ class $modify(MyEndLevelLayer, EndLevelLayer) { |
169 | 166 | } |
170 | 167 | void applyPlatAttemptsAndJumpsOrFlukedFromPercent(GJGameLevel* theLevel) { |
171 | 168 | 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; |
176 | 173 | if (getModBool("platAttemptsAndJumps") && isPlat) { |
177 | 174 | const auto timeLabel = getChildByIDRecursive("time-label"); |
178 | 175 | if (!timeLabel) return; |
@@ -202,6 +199,36 @@ class $modify(MyEndLevelLayer, EndLevelLayer) { |
202 | 199 | m_mainLayer->addChild(flukedFromLabel); |
203 | 200 | } |
204 | 201 | } |
| 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 | + } |
205 | 232 | void applyCustomLevelCompleteText(const std::string_view matchPlayLayer) { |
206 | 233 | if (!getModBool("customLevelCompleteText") || !getModBool("enabled") || !m_playLayer) return; |
207 | 234 | const auto lvlCompleteText = typeinfo_cast<CCSprite*>(getChildByIDRecursive("level-complete-text")); |
@@ -348,6 +375,7 @@ class $modify(MyEndLevelLayer, EndLevelLayer) { |
348 | 375 | MyEndLevelLayer::applyHideChainsBackground(); |
349 | 376 | MyEndLevelLayer::applySpaceUK(); |
350 | 377 | MyEndLevelLayer::applyPlatAttemptsAndJumpsOrFlukedFromPercent(m_playLayer->m_level); |
| 378 | + MyEndLevelLayer::applyTotalAttemptAndJumpCount(m_playLayer->m_level); |
351 | 379 | MyEndLevelLayer::addLoadedModsList(); |
352 | 380 | } |
353 | 381 | void customSetup() { |
|
0 commit comments