17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 23:49:19 +02:00
Files
maszyna/application/applicationmode.cppm
maj00r b8f040e6fd propagate template headers transitively, import Console where used
AnimModel.cpp reaches cParser through the simulation core, not a direct
import, so the previous pass missed it; the propagation now follows the
whole import closure. Train.cpp, drivermode.cpp and Globals.cpp call
Console:: inside _WIN32 guards without importing eu07.console - invisible
on Linux, where those blocks are skipped.
2026-09-10 01:41:24 +02:00

79 lines
2.3 KiB
C++

/*
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/.
*/
// component implementing specific mode of application behaviour
// base interface
module;
#include <array>
#include <chrono>
#include <cstddef>
#include <deque>
#include <limits>
#include <mutex>
#include <ostream>
#include <sstream>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>
#include <string>
#include <memory>
export module eu07.application.applicationmode;
import eu07.application.uilayer;
export {
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;
};
} // export