random start screen image

This commit is contained in:
milek7
2019-10-30 20:28:53 +01:00
parent b48daaf890
commit 6a17b134dc
7 changed files with 24 additions and 5 deletions

View File

@@ -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;

View File

@@ -26,7 +26,6 @@ void launcher_mode::enter()
simulation::is_ready = false;
m_userinterface->set_background( "logo" );
Application.set_title(Global.AppName);
}

View File

@@ -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)

View File

@@ -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();
}

View File

@@ -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
};

View File

@@ -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
{

View File

@@ -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 };