qmlfrontend/engine_instance.h
author unC0Rr
Tue, 10 Sep 2024 13:56:51 +0200
branchtransitional_engine
changeset 16032 31cc1e450273
parent 16016 4933920eba89
permissions -rw-r--r--
Add maze land generator ported from pascal engine
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
     1
#ifndef ENGINEINSTANCE_H
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
     2
#define ENGINEINSTANCE_H
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
     3
14373
4409344db447 Rework EngineInstance::generatePreview, add preview cleanup function in enginelib
unC0Rr
parents: 14372
diff changeset
     4
#include <QImage>
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
     5
#include <QObject>
14290
92e5682810d4 Prepare to have possibility to pass opengl context to engine
unc0rr
parents: 14271
diff changeset
     6
#include <QOpenGLContext>
15893
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
     7
#include <memory>
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
     8
14372
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
     9
#include "engine_interface.h"
14271
1aac8a62be6f Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents: 14154
diff changeset
    10
#include "game_config.h"
1aac8a62be6f Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents: 14154
diff changeset
    11
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    12
class EngineInstance : public QObject {
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    13
  Q_OBJECT
14854
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14842
diff changeset
    14
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    15
 public:
15891
d52f5d8e75e6 Allow passing data_path from QML
unc0rr
parents: 15217
diff changeset
    16
  explicit EngineInstance(const QString& libraryPath,const QString& dataPath,
14372
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    17
                          QObject* parent = nullptr);
16016
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    18
  ~EngineInstance() override;
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    19
14372
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    20
  Q_PROPERTY(bool isValid READ isValid NOTIFY isValidChanged)
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    21
14290
92e5682810d4 Prepare to have possibility to pass opengl context to engine
unc0rr
parents: 14271
diff changeset
    22
  void sendConfig(const GameConfig& config);
92e5682810d4 Prepare to have possibility to pass opengl context to engine
unc0rr
parents: 14271
diff changeset
    23
  void renderFrame();
92e5682810d4 Prepare to have possibility to pass opengl context to engine
unc0rr
parents: 14271
diff changeset
    24
  void setOpenGLContext(QOpenGLContext* context);
14373
4409344db447 Rework EngineInstance::generatePreview, add preview cleanup function in enginelib
unC0Rr
parents: 14372
diff changeset
    25
  QImage generatePreview();
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    26
14372
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    27
  bool isValid() const;
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    28
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    29
 signals:
14372
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    30
  void isValidChanged(bool isValid);
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    31
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    32
 public slots:
14842
ef9630519491 Fix some minor problems with new frontend code
unc0rr
parents: 14713
diff changeset
    33
  void advance(quint32 ticks);
ef9630519491 Fix some minor problems with new frontend code
unc0rr
parents: 14713
diff changeset
    34
  void moveCamera(const QPoint& delta);
15217
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    35
  void simpleEvent(Engine::SimpleEventType event_type);
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    36
  void longEvent(Engine::LongEventType event_type,
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    37
                 Engine::LongEventState state);
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    38
  void positionedEvent(Engine::PositionedEventType event_type, qint32 x,
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    39
                       qint32 y);
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    40
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    41
 private:
15891
d52f5d8e75e6 Allow passing data_path from QML
unc0rr
parents: 15217
diff changeset
    42
  std::unique_ptr<Engine::EngineInstance, Engine::cleanup_t*> m_instance;
14372
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    43
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    44
  Engine::hedgewars_engine_protocol_version_t*
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    45
      hedgewars_engine_protocol_version;
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    46
  Engine::start_engine_t* start_engine;
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    47
  Engine::generate_preview_t* generate_preview;
14373
4409344db447 Rework EngineInstance::generatePreview, add preview cleanup function in enginelib
unC0Rr
parents: 14372
diff changeset
    48
  Engine::dispose_preview_t* dispose_preview;
14372
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    49
  Engine::cleanup_t* cleanup;
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    50
  Engine::send_ipc_t* send_ipc;
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    51
  Engine::read_ipc_t* read_ipc;
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    52
  Engine::setup_current_gl_context_t* setup_current_gl_context;
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    53
  Engine::render_frame_t* render_frame;
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    54
  Engine::advance_simulation_t* advance_simulation;
14713
cc6ab1e3f7d5 Allow to move camera around
unc0rr
parents: 14373
diff changeset
    55
  Engine::move_camera_t* move_camera;
14854
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14842
diff changeset
    56
  Engine::simple_event_t* simple_event;
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14842
diff changeset
    57
  Engine::long_event_t* long_event;
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14842
diff changeset
    58
  Engine::positioned_event_t* positioned_event;
14372
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    59
  bool m_isValid;
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    60
};
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    61
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    62
#endif  // ENGINEINSTANCE_H