Skip to content

Commit

Permalink
v1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
RayDeeUx committed Sep 6, 2024
1 parent 74d5695 commit 32bc21a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 19 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# EndscreenTweaks Changelog
## v1.4.1
- Added "Custom Quotes Only" option, by popular demand. (If no custom quotes are found, the mod will fall back to anything enabled from the default set of quotes.)
- Skip to v1.4.1 for consistency with DeathScreenTweaks.
## v1.3.0
- Add config directory shortcut button.
- Add "Fluked From %" options for Classic levels. (suggested by [yolodomo](https://discord.com/users/708984489283682327))
Expand Down
8 changes: 7 additions & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"android": "2.206",
"win": "2.206"
},
"version": "v1.3.0",
"version": "v1.4.1",
"id": "raydeeux.endscreentweaks",
"name": "EndscreenTweaks",
"developers": ["RayDeeUx", "sofabeddd", "Relative"],
Expand Down Expand Up @@ -35,6 +35,12 @@
"type": "bool",
"default": false
},
"customTextsOnly": {
"name": "Only Use Custom Messages",
"description": "<cp>REQUIRES GAME RESTART TO APPLY.</c>\n\nOnly uses your own custom \"New Best\" texts from \"custom.txt\" file.\n\nIf no custom quotes are found, the mod will fall back to the default set of quotes.\n\n<cr>Enabling this setting will override the \"Include Technoblade\" setting if you have written your own custom quotes.</c>",
"type": "bool",
"default": false
},
"technoblade": {
"name": "Include Technoblade (o7)",
"description": "<cp>[REQUIRES RESTART TO APPLY]</c>\n\nIncludes quotes from Minecraft YouTuber Technoblade.",
Expand Down
39 changes: 21 additions & 18 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using namespace geode::prelude;

std::vector<std::string> quotes;
std::vector<std::string> customQuotes;
std::vector<std::string> wETMigration;

std::string fallbackString = "We've got too many players to congratulate on level completions. Beat this level again for an actual message.";
Expand Down Expand Up @@ -106,14 +107,15 @@ migration failed, womp womp)";
str = fmt::format("- {} -", str);
}
quotes.push_back(str);
customQuotes.push_back(str);
} // technically i can write two one-time use boolean variables to allow people to toggle these things on and off as they please without the quotes adding themselves multiple times into the vector, but i'd rather add the "restart required" barrier just to be extra safe
}
}

const char* grabRandomQuote() {
const char* grabRandomQuote(std::vector<std::string> vector = quotes) {
std::mt19937 randomSeed(std::random_device{}());
std::shuffle(quotes.begin(), quotes.end(), randomSeed);
return quotes.front().c_str();
std::shuffle(vector.begin(), vector.end(), randomSeed);
return vector.front().c_str();
}

class $modify(CCScheduler) {
Expand Down Expand Up @@ -338,8 +340,9 @@ class $modify(MyEndLevelLayer, EndLevelLayer) {
}
void applyRandomQuoteAndFont(PlayLayer* playLayer, GJGameLevel* theLevel) {
if (auto endTextLabel = typeinfo_cast<CCLabelBMFont*>(getChildByIDRecursive("end-text"))) {
auto randomString = grabRandomQuote();
if (strcmp("Make sure to screenshot this win!", randomString) == 0) {
std::string randomString = grabRandomQuote();
if (!customQuotes.empty() && getModBool("customTextsOnly")) randomString = grabRandomQuote(customQuotes);
if ("Make sure to screenshot this win!" == randomString) {
#ifdef GEODE_IS_MACOS
randomString = "Press Command + Shift + 3 to screenshot this win!";
#endif
Expand All @@ -349,28 +352,28 @@ class $modify(MyEndLevelLayer, EndLevelLayer) {
#ifdef GEODE_IS_WINDOWS
randomString = "Press \"Win + Shift + S\'\' or \"PrtSc\'\' to screenshot this win!";
#endif
} else if (strcmp(R"(''First try, part two!")", randomString) == 0) {
std::string temp = fmt::format("\'\'First try, part {}!\"", playLayer->m_attempts);
} else if (R"(''First try, part two!")" == randomString) {
std::string temp = fmt::format(R"(''First try, part {}!")", playLayer->m_attempts);
if (playLayer->m_attempts == 1) { temp = R"(''First try!")"; }
randomString = temp.c_str();
} else if (strcmp(R"(''As you can see, my FPS is around 18 or so, which means we can definitely take this further.")", randomString) == 0) {
randomString = fmt::format("\'\'As you can see, my FPS is around {} or so, which means we can definitely take this further.\"", fps).c_str();
} else if (strcmp(R"(''If you wish to defeat me, train for another 100 years.")", randomString) == 0) {
randomString = fmt::format("\'\'If you wish to defeat me, train for another {} years.\"", std::max(100, (playLayer->m_jumps * 100))).c_str();
} else if (strcmp("Good luck on that statgrinding session!", randomString) == 0 && theLevel->m_stars.value() != 0) {
randomString = temp;
} else if (R"(''As you can see, my FPS is around 18 or so, which means we can definitely take this further.")" == randomString) {
randomString = fmt::format(R"(''As you can see, my FPS is around {} or so, which means we can definitely take this further.")", fps);
} else if (R"(''If you wish to defeat me, train for another 100 years.")" == randomString) {
randomString = fmt::format(R"(''If you wish to defeat me, train for another {} years.")", std::max(100, (playLayer->m_jumps * 100)));
} else if ("Good luck on that statgrinding session!" == randomString && theLevel->m_stars.value() != 0) {
if (theLevel->isPlatformer()) { randomString = "Good luck on that moongrinding session!"; }
else { randomString = "Good luck on that stargrinding session!"; }
}

float scale = 0.36f * 228.f / strlen(randomString);
if (strcmp("BELIEVE", randomString) == 0) { scale = 1.5f; }
else if (strcmp("endTextLabel->setString(randomString.c_str(), true);", randomString) == 0) { scale = 0.4f;}
float scale = 0.36f * 228.f / strlen(randomString.c_str());
if ("BELIEVE" == randomString) { scale = 1.5f; }
else if ("endTextLabel->setString(randomString.c_str(), true);" == randomString) { scale = 0.4f; }
else if (scale > Mod::get()->getSettingValue<double>("maxScale")) { scale = Mod::get()->getSettingValue<double>("maxScale"); }

endTextLabel->setScale(scale);
endTextLabel->setWidth(336.f); // width of end screen minus 20px

endTextLabel->setString(randomString, true); // set string
endTextLabel->setString(randomString.c_str(), true); // set string

int64_t fontID = Mod::get()->getSettingValue<int64_t>("customFont");
if (fontID == -2) {
Expand All @@ -384,7 +387,7 @@ class $modify(MyEndLevelLayer, EndLevelLayer) {
endTextLabel->setAlignment(CCTextAlignment::kCCTextAlignmentCenter); // center text

if (isCompactEndscreen) endTextLabel->setPositionX(compactEndscreenFallbackPosition);
if (strcmp("", randomString) == 0) { endTextLabel->setString(fallbackString.c_str(), true); } // fallback string
if (randomString.empty()) { endTextLabel->setString(fallbackString.c_str(), true); } // fallback string
}
}
CCNode* getMainLayer() {
Expand Down

0 comments on commit 32bc21a

Please sign in to comment.