16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 12:29:18 +02:00

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

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