diff --git a/application.cpp b/application.cpp index 8b077fb4..896aedc1 100644 --- a/application.cpp +++ b/application.cpp @@ -802,6 +802,8 @@ eu07_application::init_data() { int eu07_application::init_modes() { + Global.local_random_engine.seed(std::random_device{}()); + if ((!Global.network_servers.empty() || Global.network_client) && Global.SceneryFile.empty()) { ErrorLog("launcher mode is currently not supported in network mode"); return -1; diff --git a/launcher/launchermode.cpp b/launcher/launchermode.cpp index 2e0a54d7..1d9f5a79 100644 --- a/launcher/launchermode.cpp +++ b/launcher/launchermode.cpp @@ -26,7 +26,6 @@ void launcher_mode::enter() simulation::is_ready = false; - m_userinterface->set_background( "logo" ); Application.set_title(Global.AppName); } diff --git a/launcher/launcheruilayer.cpp b/launcher/launcheruilayer.cpp index 18069cca..ab7a6ddd 100644 --- a/launcher/launcheruilayer.cpp +++ b/launcher/launcheruilayer.cpp @@ -12,6 +12,8 @@ launcher_ui::launcher_ui() add_external_panel(&m_scenerylist_panel); add_external_panel(&m_keymapper_panel); add_external_panel(&m_vehiclepicker_panel); + + load_random_background(); } bool launcher_ui::on_key(const int Key, const int Action) diff --git a/scenarioloadermode.cpp b/scenarioloadermode.cpp index 19fe5069..92e02493 100644 --- a/scenarioloadermode.cpp +++ b/scenarioloadermode.cpp @@ -80,10 +80,9 @@ scenarioloader_mode::enter() { simulation::is_ready = false; - m_userinterface->set_background( "logo" ); Application.set_title( Global.AppName + " (" + Global.SceneryFile + ")" ); m_userinterface->set_progress(); - m_userinterface->set_progress(STR("Loading scenery")); + m_userinterface->set_progress(STR("Loading scenery")); GfxRenderer.Render(); } diff --git a/scenarioloaderuilayer.h b/scenarioloaderuilayer.h index c167a444..3890e8ec 100644 --- a/scenarioloaderuilayer.h +++ b/scenarioloaderuilayer.h @@ -12,6 +12,9 @@ http://mozilla.org/MPL/2.0/. #include "uilayer.h" class scenarioloader_ui : public ui_layer { - +public: + scenarioloader_ui() : ui_layer() { + load_random_background(); + } // TODO: implement mode-specific elements }; diff --git a/uilayer.cpp b/uilayer.cpp index 8aabb1e3..09aa152f 100644 --- a/uilayer.cpp +++ b/uilayer.cpp @@ -128,6 +128,19 @@ ui_layer::ui_layer() m_logpanel.size = { 700, 400 }; } +void::ui_layer::load_random_background() +{ + std::vector images; + for (auto &f : std::filesystem::directory_iterator("textures/logo")) + if (f.is_regular_file()) + images.emplace_back(std::filesystem::relative(f.path(), "textures/").string()); + + if (!images.empty()) { + std::string &selected = images[std::lround(LocalRandom(images.size() - 1))]; + set_background(selected); + } +} + static ImVec4 imvec_lerp(const ImVec4& a, const ImVec4& b, float t) { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); @@ -373,7 +386,7 @@ void ui_layer::set_background(std::string const &Filename) { if (false == Filename.empty()) { - m_background = GfxRenderer.Fetch_Texture(Filename); + m_background = GfxRenderer.Fetch_Texture(Filename); } else { diff --git a/uilayer.h b/uilayer.h index 68775ec2..731ba9bd 100644 --- a/uilayer.h +++ b/uilayer.h @@ -156,6 +156,7 @@ protected: static ImGuiIO *m_imguiio; static bool m_cursorvisible; + void load_random_background(); virtual void render_menu_contents(); ui_log_panel m_logpanel { "Log", true };