mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 22:59:19 +02:00
Launcher improvements
Launcher windows are more Starter-like now: - The scenery picker, vehicle list and keymapper buttons are now tied to the top portion of the screen. - The current window is spanning the entire rest of the screen. - Scenarios are now grouped into categories in the exact same way as Starter does. - Some drawbacks include: - Currently you cannot edit the current trainset, as the vehicle picker window overwrites the scenario list window. - The GUI doesn't update when the screen resolution is changed.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#include "stdafx.h"
|
||||
#include "launcher/launcheruilayer.h"
|
||||
#include "application.h"
|
||||
#include "translation.h"
|
||||
|
||||
#include "Logs.h"
|
||||
launcher_ui::launcher_ui()
|
||||
: m_scenery_scanner(m_vehicles_bank), m_scenerylist_panel(m_scenery_scanner)
|
||||
{
|
||||
@@ -13,11 +13,16 @@ launcher_ui::launcher_ui()
|
||||
add_external_panel(&m_keymapper_panel);
|
||||
add_external_panel(&m_vehiclepicker_panel);
|
||||
|
||||
open_panel(&m_vehiclepicker_panel);
|
||||
m_suppress_menu = true;
|
||||
|
||||
load_random_background();
|
||||
}
|
||||
|
||||
bool launcher_ui::on_key(const int Key, const int Action)
|
||||
{
|
||||
if (m_scenerylist_panel.on_key(Key, Action))
|
||||
return true;
|
||||
if (m_keymapper_panel.key(Key))
|
||||
return true;
|
||||
|
||||
@@ -26,20 +31,41 @@ bool launcher_ui::on_key(const int Key, const int Action)
|
||||
|
||||
void launcher_ui::render_()
|
||||
{
|
||||
ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse;
|
||||
ImVec2 display_size = ImGui::GetIO().DisplaySize;
|
||||
ImGui::SetNextWindowPos(ImVec2(display_size.x * 0.66f, display_size.y / 2.0f));
|
||||
ImGui::SetNextWindowSize(ImVec2(200 * Global.ui_scale, -1));
|
||||
ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove;
|
||||
const float topbar_height = 50 * Global.ui_scale;
|
||||
const ImVec2 topbar_button_size = ImVec2(150 * Global.ui_scale, topbar_height - 16);
|
||||
ImGui::SetNextWindowPos(ImVec2(0, 0));
|
||||
ImGui::SetNextWindowSize(ImVec2(Global.window_size.x, topbar_height));
|
||||
|
||||
if (ImGui::Begin(STR_C("Main menu"), nullptr, flags)) {
|
||||
if (ImGui::Button(STR_C("Scenario list"), ImVec2(-1, 0)))
|
||||
m_scenerylist_panel.is_open = !m_scenerylist_panel.is_open;
|
||||
if (ImGui::Button(STR_C("Vehicle list"), ImVec2(-1, 0)))
|
||||
m_vehiclepicker_panel.is_open = !m_vehiclepicker_panel.is_open;
|
||||
if (ImGui::Button(STR_C("Keymapper"), ImVec2(-1, 0)))
|
||||
m_keymapper_panel.is_open = !m_keymapper_panel.is_open;
|
||||
if (ImGui::Button(STR_C("Quit"), ImVec2(-1, 0)))
|
||||
if (ImGui::Button(STR_C("Scenario list"), topbar_button_size))
|
||||
open_panel(&m_scenerylist_panel);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button(STR_C("Vehicle list"), topbar_button_size))
|
||||
open_panel(&m_vehiclepicker_panel);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button(STR_C("Keymapper"), topbar_button_size))
|
||||
open_panel(&m_keymapper_panel);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button(STR_C("Quit"), topbar_button_size))
|
||||
Application.queue_quit(false);
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void launcher_ui::close_panels()
|
||||
{
|
||||
m_scenerylist_panel.is_open = false;
|
||||
m_vehiclepicker_panel.is_open = false;
|
||||
m_keymapper_panel.is_open = false;
|
||||
}
|
||||
|
||||
void launcher_ui::open_panel(ui_panel* panel)
|
||||
{
|
||||
close_panels();
|
||||
const float topbar_height = 50 * Global.ui_scale;
|
||||
panel->pos = glm::vec2(0, topbar_height);
|
||||
panel->size = glm::vec2(Global.window_size.x, Global.window_size.y - topbar_height);
|
||||
panel->no_title_bar = true;
|
||||
panel->is_open = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user