mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 23:19: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:
115
uilayer.h
115
uilayer.h
@@ -10,8 +10,8 @@ http://mozilla.org/MPL/2.0/.
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include "Texture.h"
|
||||
#include "translation.h"
|
||||
#include "widgets/popup.h"
|
||||
|
||||
// GuiLayer -- basic user interface class. draws requested information on top of openGL screen
|
||||
@@ -20,7 +20,7 @@ class ui_panel {
|
||||
|
||||
public:
|
||||
// constructor
|
||||
ui_panel( std::string const &Identifier, bool const Isopen );
|
||||
ui_panel( std::string Identifier, bool Isopen );
|
||||
virtual ~ui_panel() = default;
|
||||
// methods
|
||||
virtual void update() {};
|
||||
@@ -29,23 +29,21 @@ public:
|
||||
// temporary access
|
||||
// types
|
||||
struct text_line {
|
||||
|
||||
std::string data;
|
||||
glm::vec4 color;
|
||||
|
||||
text_line( std::string const &Data, glm::vec4 const &Color)
|
||||
: data(Data), color(Color)
|
||||
{}
|
||||
text_line( std::string const &Data, glm::vec4 const &Color) : data(Data), color(Color) {}
|
||||
};
|
||||
// members
|
||||
std::string title;
|
||||
bool is_open;
|
||||
|
||||
glm::ivec2 pos { -1, -1 };
|
||||
glm::ivec2 size { -1, -1 };
|
||||
glm::ivec2 size_min { -1, -1 };
|
||||
glm::ivec2 size_max { -1, -1 };
|
||||
std::deque<text_line> text_lines;
|
||||
int window_flags = -1;
|
||||
bool no_title_bar = false;
|
||||
|
||||
const std::string& name() { return m_name; }
|
||||
void register_popup(std::unique_ptr<ui::popup> &&popup);
|
||||
@@ -59,19 +57,16 @@ protected:
|
||||
class ui_expandable_panel : public ui_panel {
|
||||
public:
|
||||
using ui_panel::ui_panel;
|
||||
|
||||
bool is_expanded { false };
|
||||
|
||||
void render_contents() override;
|
||||
};
|
||||
|
||||
class ui_log_panel : public ui_panel {
|
||||
using ui_panel::ui_panel;
|
||||
|
||||
void render_contents() override;
|
||||
};
|
||||
|
||||
class ImFont;
|
||||
struct ImFont;
|
||||
class ui_layer {
|
||||
|
||||
public:
|
||||
@@ -81,68 +76,38 @@ public:
|
||||
virtual ~ui_layer();
|
||||
|
||||
// methods
|
||||
static
|
||||
bool
|
||||
init( GLFWwindow *Window );
|
||||
|
||||
static
|
||||
void
|
||||
imgui_style();
|
||||
static bool init( GLFWwindow *Window );
|
||||
static void imgui_style();
|
||||
|
||||
// assign texturing hardware unit
|
||||
static
|
||||
void
|
||||
set_unit( GLint const Textureunit ) { m_textureunit = GL_TEXTURE0 + Textureunit; }
|
||||
static
|
||||
void
|
||||
shutdown();
|
||||
static void set_unit( GLint const Textureunit ) { m_textureunit = GL_TEXTURE0 + Textureunit; }
|
||||
static void shutdown();
|
||||
// potentially processes provided input key. returns: true if the input was processed, false otherwise
|
||||
virtual
|
||||
bool
|
||||
on_key( int const Key, int const Action );
|
||||
virtual bool on_key( int Key, int Action );
|
||||
// potentially processes provided mouse movement. returns: true if the input was processed, false otherwise
|
||||
virtual
|
||||
bool
|
||||
on_cursor_pos( double const Horizontal, double const Vertical );
|
||||
virtual bool on_cursor_pos( double Horizontal, double Vertical );
|
||||
// potentially processes provided mouse button. returns: true if the input was processed, false otherwise
|
||||
virtual
|
||||
bool
|
||||
on_mouse_button( int const Button, int const Action );
|
||||
virtual bool on_mouse_button( int Button, int Action );
|
||||
// updates state of UI elements
|
||||
virtual
|
||||
void
|
||||
update();
|
||||
virtual void update();
|
||||
// draws requested UI elements
|
||||
void
|
||||
render();
|
||||
static void
|
||||
render_internal();
|
||||
void render();
|
||||
static void render_internal();
|
||||
// begins new UI frame
|
||||
// (this is separate from render() to allow for debug GUI outside of proper UI framework)
|
||||
void
|
||||
begin_ui_frame();
|
||||
static void
|
||||
begin_ui_frame_internal();
|
||||
void begin_ui_frame();
|
||||
static void begin_ui_frame_internal();
|
||||
//
|
||||
static
|
||||
void
|
||||
set_cursor( int const Mode );
|
||||
static void set_cursor( int Mode );
|
||||
// stores operation progress
|
||||
void
|
||||
set_progress( float const Progress = 0.0f, float const Subtaskprogress = 0.0f );
|
||||
void
|
||||
set_progress( std::string const &Text ) { m_progresstext = Text; }
|
||||
void set_progress( float Progress = 0.0f, float Subtaskprogress = 0.0f );
|
||||
void set_progress( std::string const &Text ) { m_progresstext = Text; }
|
||||
// sets the ui background texture, if any
|
||||
void
|
||||
set_background( std::string const &Filename = "" );
|
||||
void
|
||||
set_tooltip( std::string const &Tooltip ) { m_tooltip = Tooltip; }
|
||||
void
|
||||
clear_panels();
|
||||
void
|
||||
add_external_panel( ui_panel *Panel ) { m_panels.emplace_back( Panel ); }
|
||||
void
|
||||
add_owned_panel( ui_panel *Panel );
|
||||
void set_background( std::string const &Filename = "" );
|
||||
void set_tooltip( std::string const &Tooltip ) { m_tooltip = Tooltip; }
|
||||
void clear_panels();
|
||||
void add_external_panel( ui_panel *Panel ) { m_panels.emplace_back( Panel ); }
|
||||
void add_owned_panel( ui_panel *Panel );
|
||||
|
||||
// callback functions for imgui input
|
||||
// returns true if input is consumed
|
||||
@@ -158,35 +123,27 @@ protected:
|
||||
// members
|
||||
static GLFWwindow *m_window;
|
||||
static ImGuiIO *m_imguiio;
|
||||
static bool m_cursorvisible;
|
||||
static bool m_cursorvisible;
|
||||
|
||||
void load_random_background();
|
||||
virtual void render_menu_contents();
|
||||
ui_log_panel m_logpanel { "Log", true };
|
||||
bool m_suppress_menu = false; // if `true`, the menu at the top of the window will not be present
|
||||
|
||||
private:
|
||||
private:
|
||||
// methods
|
||||
// render() subclass details
|
||||
virtual
|
||||
void
|
||||
render_() {};
|
||||
virtual void render_() {};
|
||||
// draws background quad with specified earlier texture
|
||||
void
|
||||
render_background();
|
||||
void render_background();
|
||||
// draws a progress bar in defined earlier state
|
||||
void
|
||||
render_progress();
|
||||
void
|
||||
render_tooltip();
|
||||
void render_progress();
|
||||
void render_tooltip();
|
||||
void render_panels();
|
||||
|
||||
void render_menu();
|
||||
|
||||
void render_quit_widget();
|
||||
|
||||
void render_menu();
|
||||
void render_quit_widget();
|
||||
// draws a quad between coordinates x,y and z,w with uv-coordinates spanning 0-1
|
||||
void
|
||||
quad( glm::vec4 const &Coordinates, glm::vec4 const &Color );
|
||||
void quad( glm::vec4 const &Coordinates, glm::vec4 const &Color );
|
||||
// members
|
||||
static GLint m_textureunit;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user