mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 01:59:19 +02:00
Reorganize source files into logical subdirectories
Co-authored-by: Hirek193 <23196899+Hirek193@users.noreply.github.com>
This commit is contained in:
59
application/applicationmode.h
Normal file
59
application/applicationmode.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "uilayer.h"
|
||||
|
||||
// component implementing specific mode of application behaviour
|
||||
// base interface
|
||||
class application_mode {
|
||||
|
||||
public:
|
||||
// destructor
|
||||
virtual ~application_mode() = default;
|
||||
// methods;
|
||||
// initializes internal data structures of the mode. returns: true on success, false otherwise
|
||||
virtual bool init() = 0;
|
||||
// mode-specific update of simulation data. returns: false on error, true otherwise
|
||||
virtual bool update() = 0;
|
||||
// draws mode-specific user interface
|
||||
inline
|
||||
void render_ui() {
|
||||
if( m_userinterface != nullptr ) {
|
||||
m_userinterface->render(); } }
|
||||
inline
|
||||
void begin_ui_frame() {
|
||||
if( m_userinterface != nullptr ) {
|
||||
m_userinterface->begin_ui_frame(); } }
|
||||
inline
|
||||
void set_progress( float const Progress = 0.f, float const Subtaskprogress = 0.f ) {
|
||||
if( m_userinterface != nullptr ) {
|
||||
m_userinterface->set_progress( Progress, Subtaskprogress ); } }
|
||||
inline
|
||||
void set_tooltip( std::string const &Tooltip ) {
|
||||
if( m_userinterface != nullptr ) {
|
||||
m_userinterface->set_tooltip( Tooltip ); } }
|
||||
// maintenance method, called when the mode is activated
|
||||
virtual void enter() = 0;
|
||||
// maintenance method, called when the mode is deactivated
|
||||
virtual void exit() = 0;
|
||||
// input handlers
|
||||
virtual void on_key( int Key, int Scancode, int Action, int Mods ) = 0;
|
||||
virtual void on_cursor_pos( double X, double Y ) = 0;
|
||||
virtual void on_mouse_button( int Button, int Action, int Mods ) = 0;
|
||||
virtual void on_scroll( double Xoffset, double Yoffset ) = 0;
|
||||
virtual void on_window_resize( int w, int h ) = 0;
|
||||
virtual void on_event_poll() = 0;
|
||||
virtual bool is_command_processor() const = 0;
|
||||
|
||||
protected:
|
||||
// members
|
||||
std::shared_ptr<ui_layer> m_userinterface;
|
||||
};
|
||||
Reference in New Issue
Block a user