16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-17 23:39:18 +02:00

Make launcher respond to window resize

This commit is contained in:
jakubg1
2025-09-09 17:08:23 +02:00
parent c217081823
commit 9fa22d81e5
12 changed files with 105 additions and 133 deletions

View File

@@ -38,3 +38,8 @@ void launcher_mode::on_key(const int Key, const int Scancode, const int Action,
{
m_userinterface->on_key(Key, Action);
}
void launcher_mode::on_window_resize(const int w, const int h)
{
m_userinterface->on_window_resize(w, h);
}

View File

@@ -30,16 +30,11 @@ public:
void
exit() override;
// input handlers
void
on_key( int const Key, int const Scancode, int const Action, int const Mods );
void
on_cursor_pos( double const Horizontal, double const Vertical ) override { ; }
void
on_mouse_button( int const Button, int const Action, int const Mods ) override { ; }
void
on_scroll( double const Xoffset, double const Yoffset ) override { ; }
void
on_event_poll() override { ; }
bool
is_command_processor() const override { return false; }
void on_key( int Key, int Scancode, int Action, int Mods ) override;
void on_cursor_pos( double const Horizontal, double const Vertical ) override { ; }
void on_mouse_button( int const Button, int const Action, int const Mods ) override { ; }
void on_scroll( double const Xoffset, double const Yoffset ) override { ; }
void on_window_resize( int w, int h ) override;
void on_event_poll() override { ; }
bool is_command_processor() const override { return false; }
};

View File

@@ -3,8 +3,7 @@
#include "application.h"
#include "translation.h"
launcher_ui::launcher_ui()
: m_scenery_scanner(m_vehicles_bank), m_scenerylist_panel(m_scenery_scanner)
launcher_ui::launcher_ui() : m_scenery_scanner(m_vehicles_bank), m_scenerylist_panel(m_scenery_scanner)
{
m_vehicles_bank.scan_textures();
m_scenery_scanner.scan();
@@ -29,6 +28,11 @@ bool launcher_ui::on_key(const int Key, const int Action)
return ui_layer::on_key(Key, Action);
}
void launcher_ui::on_window_resize(int w, int h)
{
open_panel(m_current_panel);
}
void launcher_ui::render_()
{
ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove;
@@ -68,4 +72,6 @@ void launcher_ui::open_panel(ui_panel* panel)
panel->size = glm::vec2(Global.window_size.x, Global.window_size.y - topbar_height);
panel->no_title_bar = true;
panel->is_open = true;
m_current_panel = panel;
}

View File

@@ -20,6 +20,7 @@ class launcher_ui : public ui_layer {
public:
launcher_ui();
bool on_key(const int Key, const int Action) override;
void on_window_resize(int w, int h) override;
private:
void render_() override;
@@ -32,4 +33,6 @@ private:
ui::scenerylist_panel m_scenerylist_panel;
ui::keymapper_panel m_keymapper_panel;
ui::vehiclepicker_panel m_vehiclepicker_panel;
ui_panel *m_current_panel;
};