qmlfrontend/engine_instance.h
branchui-scaling
changeset 15288 c4fd2813b127
parent 15222 b32c52c76977
equal deleted inserted replaced
13395:0135e64c6c66 15288:c4fd2813b127
       
     1 #ifndef ENGINEINSTANCE_H
       
     2 #define ENGINEINSTANCE_H
       
     3 
       
     4 #include <QImage>
       
     5 #include <QObject>
       
     6 #include <QOpenGLContext>
       
     7 
       
     8 #include "engine_interface.h"
       
     9 #include "game_config.h"
       
    10 
       
    11 class EngineInstance : public QObject {
       
    12   Q_OBJECT
       
    13 
       
    14  public:
       
    15   explicit EngineInstance(const QString& libraryPath,
       
    16                           QObject* parent = nullptr);
       
    17   ~EngineInstance();
       
    18 
       
    19   Q_PROPERTY(bool isValid READ isValid NOTIFY isValidChanged)
       
    20 
       
    21   void sendConfig(const GameConfig& config);
       
    22   void renderFrame();
       
    23   void setOpenGLContext(QOpenGLContext* context);
       
    24   QImage generatePreview();
       
    25 
       
    26   bool isValid() const;
       
    27 
       
    28  signals:
       
    29   void isValidChanged(bool isValid);
       
    30 
       
    31  public slots:
       
    32   void advance(quint32 ticks);
       
    33   void moveCamera(const QPoint& delta);
       
    34   void simpleEvent(Engine::SimpleEventType event_type);
       
    35   void longEvent(Engine::LongEventType event_type,
       
    36                  Engine::LongEventState state);
       
    37   void positionedEvent(Engine::PositionedEventType event_type, qint32 x,
       
    38                        qint32 y);
       
    39 
       
    40  private:
       
    41   Engine::EngineInstance* m_instance;
       
    42 
       
    43   Engine::hedgewars_engine_protocol_version_t*
       
    44       hedgewars_engine_protocol_version;
       
    45   Engine::start_engine_t* start_engine;
       
    46   Engine::generate_preview_t* generate_preview;
       
    47   Engine::dispose_preview_t* dispose_preview;
       
    48   Engine::cleanup_t* cleanup;
       
    49   Engine::send_ipc_t* send_ipc;
       
    50   Engine::read_ipc_t* read_ipc;
       
    51   Engine::setup_current_gl_context_t* setup_current_gl_context;
       
    52   Engine::render_frame_t* render_frame;
       
    53   Engine::advance_simulation_t* advance_simulation;
       
    54   Engine::move_camera_t* move_camera;
       
    55   Engine::simple_event_t* simple_event;
       
    56   Engine::long_event_t* long_event;
       
    57   Engine::positioned_event_t* positioned_event;
       
    58   bool m_isValid;
       
    59 };
       
    60 
       
    61 #endif  // ENGINEINSTANCE_H