From d86018717ebe8abb45d36ab22dd0e73fd54d4430 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Wed, 7 Feb 2024 21:40:26 -0500 Subject: [PATCH] Split Splash Loading Into Own Function --- mods/include/mods/title-screen/title-screen.h | 5 ++++ mods/src/title-screen/title-screen.cpp | 28 +++++++++++-------- 2 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 mods/include/mods/title-screen/title-screen.h diff --git a/mods/include/mods/title-screen/title-screen.h b/mods/include/mods/title-screen/title-screen.h new file mode 100644 index 00000000..bef55ccd --- /dev/null +++ b/mods/include/mods/title-screen/title-screen.h @@ -0,0 +1,5 @@ +#pragma once + +#include + +void title_screen_load_splashes(std::vector &splashes); diff --git a/mods/src/title-screen/title-screen.cpp b/mods/src/title-screen/title-screen.cpp index ebaea2aa..fc1d0d07 100644 --- a/mods/src/title-screen/title-screen.cpp +++ b/mods/src/title-screen/title-screen.cpp @@ -9,6 +9,7 @@ #include #include #include +#include // Improved Title Screen Background static void StartMenuScreen_render_Screen_renderBackground_injection(Screen *screen) { @@ -49,6 +50,20 @@ static void StartMenuScreen_buttonClicked_injection(StartMenuScreen *screen, But } // Add Splashes +void title_screen_load_splashes(std::vector &splashes) { + std::ifstream stream("data/splashes.txt"); + if (stream.good()) { + std::string line; + while (std::getline(stream, line)) { + if (line.length() > 0) { + splashes.push_back(line); + } + } + stream.close(); + } else { + WARN("Unable To Load Splashes"); + } +} static Screen *last_screen = nullptr; static std::string current_splash; static void StartMenuScreen_render_Screen_render_injection(Screen *screen, int x, int y, float param_1) { @@ -62,18 +77,7 @@ static void StartMenuScreen_render_Screen_render_injection(Screen *screen, int x // Mark As Loaded splashes_loaded = true; // Load - std::ifstream stream("data/splashes.txt"); - if (stream.good()) { - std::string line; - while (std::getline(stream, line)) { - if (line.length() > 0) { - splashes.push_back(line); - } - } - stream.close(); - } else { - WARN("Unable To Load Splashes"); - } + title_screen_load_splashes(splashes); } // Display Splash