mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
random start screen image
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -26,7 +26,6 @@ void launcher_mode::enter()
|
||||
|
||||
simulation::is_ready = false;
|
||||
|
||||
m_userinterface->set_background( "logo" );
|
||||
Application.set_title(Global.AppName);
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
15
uilayer.cpp
15
uilayer.cpp
@@ -128,6 +128,19 @@ ui_layer::ui_layer()
|
||||
m_logpanel.size = { 700, 400 };
|
||||
}
|
||||
|
||||
void::ui_layer::load_random_background()
|
||||
{
|
||||
std::vector<std::string> 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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user