From e0fdb911f6e0ba6e53c6092ffb3d89160a09f68f Mon Sep 17 00:00:00 2001 From: ps Date: Fri, 19 Jan 2018 21:45:00 +0100 Subject: [PATCH] updated gitignore, modified main menu --- .gitignore | 6 ++++++ code/ui/globalShuffledTiers.h | 3 +++ code/ui/ui_main.cpp | 8 +++++++- code/ui/ui_shared.cpp | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8dc83666e6..5804e75284 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,12 @@ local.properties # PDT-specific .buildpath +################# +## Clion +################# +cmake-build-release/ +cmake-build-debug/ + ################# ## Visual Studio ################# diff --git a/code/ui/globalShuffledTiers.h b/code/ui/globalShuffledTiers.h index 504e8231fe..3c93a86009 100644 --- a/code/ui/globalShuffledTiers.h +++ b/code/ui/globalShuffledTiers.h @@ -59,6 +59,9 @@ extern std::string SHUFFLED_TIER_1; extern std::string SHUFFLED_TIER_2; extern std::string SHUFFLED_TIER_3; +// the modified main menu +extern std::string MAIN_MENU; + // template for the generated menu files // will be set on startup static std::string TMPLT; diff --git a/code/ui/ui_main.cpp b/code/ui/ui_main.cpp index 31729efaeb..1253140dfc 100644 --- a/code/ui/ui_main.cpp +++ b/code/ui/ui_main.cpp @@ -43,6 +43,7 @@ USER INTERFACE MAIN std::string SHUFFLED_TIER_1; std::string SHUFFLED_TIER_2; std::string SHUFFLED_TIER_3; +std::string MAIN_MENU; #include "../server/exe_headers.h" @@ -2898,6 +2899,11 @@ void UI_ParseMenu(const char *menuFile) // if we injected our own randomized menu or not bool injected = false; + // to display message on main menu + if(strcmp(menuFile, "ui/main.menu") == 0) { + injected = true; + } + // Mission select menu gets loaded --> ITS A TRAP!!! // disable free() because YOLO if(strcmp(menuFile, "ui/ingameMissionSelect1.menu") == 0 && SHUFFLED_TIER_1.length() > 0) { @@ -4282,7 +4288,7 @@ void UI_MainMenu(void) std::ifstream templateFileHandle(TEMPLATE_FILE_NAME.c_str()); // crash if the file isn't present - assert(templateFileHandle.good() && "Template file isn't present :("); + assert(templateFileHandle.good() && "The template file isn't present :("); // read the tempalte from file diff --git a/code/ui/ui_shared.cpp b/code/ui/ui_shared.cpp index 1cfac63adc..cc5d4274cf 100644 --- a/code/ui/ui_shared.cpp +++ b/code/ui/ui_shared.cpp @@ -5867,6 +5867,38 @@ int PC_StartParseSession(const char *fileName,char **buffer) // Try to open file and read it in. len = ui.FS_ReadFile( fileName,(void **) buffer ); + // display randomizer message on main menu + if(strcmp(fileName, "ui/main.menu") == 0) { + MAIN_MENU = std::string(*buffer); + + size_t start_pos = 0; + std::string pattern = "@MENUS_EXIT"; + + std::vector texts = { + "FWAHAHAHAHA", + "\"NOW WITH EVEN MOAR RANDOM\"", + "\"THIS_WILL_BE_HARD\"", + "\"OpenJK Rand0mizer by JoeBananas\"", + "\"GET ME OUTTA HERE\"", + "\"EXTREMELY HARD RANDOM PATTERN DETECTED\"", + "\"IT'S A TRAP\"", + "\"BLAME IT ON THE GRAN\"", + "\"THIS IS BANANAS\"", + "\"SUCH RANDOM\"", + }; + + srand(unsigned(time(NULL))); + std::string repl = texts[rand() % (texts.size()-1)]; + + while((start_pos = MAIN_MENU.find(pattern, start_pos)) != std::string::npos) { + MAIN_MENU.replace(start_pos, pattern.length(), repl); + start_pos += repl.length(); + } + + + *buffer = &MAIN_MENU[0]; + } + // Randomizer Hack: use our menu lel if(strcmp(fileName, "ui/ingameMissionSelect1.menu") == 0 && SHUFFLED_TIER_1.length() > 0) { // inject the randomized menu into the buffer --> Win