author | alfadur |
Fri, 31 May 2019 21:34:32 +0300 | |
changeset 15110 | 24994035a0e0 |
parent 14875 | aed75d439027 |
child 15238 | b32c52c76977 |
permissions | -rw-r--r-- |
14175
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 |
|
14394
4409344db447
Rework EngineInstance::generatePreview, add preview cleanup function in enginelib
unC0Rr
parents:
14393
diff
changeset
|
4 |
#include <QImage> |
14175
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
5 |
#include <QObject> |
14311
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14292
diff
changeset
|
6 |
#include <QOpenGLContext> |
14175
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
7 |
|
14393
b6824a53d4b1
Allow to instantiate HWEngine with different library binaries
unC0Rr
parents:
14311
diff
changeset
|
8 |
#include "engine_interface.h" |
14292
1aac8a62be6f
Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents:
14175
diff
changeset
|
9 |
#include "game_config.h" |
1aac8a62be6f
Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents:
14175
diff
changeset
|
10 |
|
14175
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
11 |
class EngineInstance : public QObject { |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
12 |
Q_OBJECT |
14875
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14863
diff
changeset
|
13 |
|
14175
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
14 |
public: |
14875
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14863
diff
changeset
|
15 |
using SimpleEventType = Engine::SimpleEventType; |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14863
diff
changeset
|
16 |
Q_ENUMS(SimpleEventType) |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14863
diff
changeset
|
17 |
using LongEventType = Engine::LongEventType; |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14863
diff
changeset
|
18 |
Q_ENUMS(LongEventType) |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14863
diff
changeset
|
19 |
using LongEventState = Engine::LongEventState; |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14863
diff
changeset
|
20 |
Q_ENUMS(LongEventState) |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14863
diff
changeset
|
21 |
using PositionedEventType = Engine::PositionedEventType; |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14863
diff
changeset
|
22 |
Q_ENUMS(PositionedEventType) |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14863
diff
changeset
|
23 |
|
14393
b6824a53d4b1
Allow to instantiate HWEngine with different library binaries
unC0Rr
parents:
14311
diff
changeset
|
24 |
explicit EngineInstance(const QString& libraryPath, |
b6824a53d4b1
Allow to instantiate HWEngine with different library binaries
unC0Rr
parents:
14311
diff
changeset
|
25 |
QObject* parent = nullptr); |
14175
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
26 |
~EngineInstance(); |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
27 |
|
14393
b6824a53d4b1
Allow to instantiate HWEngine with different library binaries
unC0Rr
parents:
14311
diff
changeset
|
28 |
Q_PROPERTY(bool isValid READ isValid NOTIFY isValidChanged) |
b6824a53d4b1
Allow to instantiate HWEngine with different library binaries
unC0Rr
parents:
14311
diff
changeset
|
29 |
|
14311
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14292
diff
changeset
|
30 |
void sendConfig(const GameConfig& config); |
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14292
diff
changeset
|
31 |
void renderFrame(); |
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14292
diff
changeset
|
32 |
void setOpenGLContext(QOpenGLContext* context); |
14394
4409344db447
Rework EngineInstance::generatePreview, add preview cleanup function in enginelib
unC0Rr
parents:
14393
diff
changeset
|
33 |
QImage generatePreview(); |
14175
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
34 |
|
14393
b6824a53d4b1
Allow to instantiate HWEngine with different library binaries
unC0Rr
parents:
14311
diff
changeset
|
35 |
bool isValid() const; |
b6824a53d4b1
Allow to instantiate HWEngine with different library binaries
unC0Rr
parents:
14311
diff
changeset
|
36 |
|
14175
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
37 |
signals: |
14393
b6824a53d4b1
Allow to instantiate HWEngine with different library binaries
unC0Rr
parents:
14311
diff
changeset
|
38 |
void isValidChanged(bool isValid); |
14175
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
39 |
|
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
40 |
public slots: |
14863 | 41 |
void advance(quint32 ticks); |
42 |
void moveCamera(const QPoint& delta); |
|
14875
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14863
diff
changeset
|
43 |
void simpleEvent(SimpleEventType event_type); |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14863
diff
changeset
|
44 |
void longEvent(LongEventType event_type, LongEventState state); |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14863
diff
changeset
|
45 |
void positionedEvent(PositionedEventType event_type, qint32 x, qint32 y); |
14175
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
46 |
|
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
47 |
private: |
14311
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14292
diff
changeset
|
48 |
Engine::EngineInstance* m_instance; |
14393
b6824a53d4b1
Allow to instantiate HWEngine with different library binaries
unC0Rr
parents:
14311
diff
changeset
|
49 |
|
b6824a53d4b1
Allow to instantiate HWEngine with different library binaries
unC0Rr
parents:
14311
diff
changeset
|
50 |
Engine::hedgewars_engine_protocol_version_t* |
b6824a53d4b1
Allow to instantiate HWEngine with different library binaries
unC0Rr
parents:
14311
diff
changeset
|
51 |
hedgewars_engine_protocol_version; |
b6824a53d4b1
Allow to instantiate HWEngine with different library binaries
unC0Rr
parents:
14311
diff
changeset
|
52 |
Engine::start_engine_t* start_engine; |
b6824a53d4b1
Allow to instantiate HWEngine with different library binaries
unC0Rr
parents:
14311
diff
changeset
|
53 |
Engine::generate_preview_t* generate_preview; |
14394
4409344db447
Rework EngineInstance::generatePreview, add preview cleanup function in enginelib
unC0Rr
parents:
14393
diff
changeset
|
54 |
Engine::dispose_preview_t* dispose_preview; |
14393
b6824a53d4b1
Allow to instantiate HWEngine with different library binaries
unC0Rr
parents:
14311
diff
changeset
|
55 |
Engine::cleanup_t* cleanup; |
b6824a53d4b1
Allow to instantiate HWEngine with different library binaries
unC0Rr
parents:
14311
diff
changeset
|
56 |
Engine::send_ipc_t* send_ipc; |
b6824a53d4b1
Allow to instantiate HWEngine with different library binaries
unC0Rr
parents:
14311
diff
changeset
|
57 |
Engine::read_ipc_t* read_ipc; |
b6824a53d4b1
Allow to instantiate HWEngine with different library binaries
unC0Rr
parents:
14311
diff
changeset
|
58 |
Engine::setup_current_gl_context_t* setup_current_gl_context; |
b6824a53d4b1
Allow to instantiate HWEngine with different library binaries
unC0Rr
parents:
14311
diff
changeset
|
59 |
Engine::render_frame_t* render_frame; |
b6824a53d4b1
Allow to instantiate HWEngine with different library binaries
unC0Rr
parents:
14311
diff
changeset
|
60 |
Engine::advance_simulation_t* advance_simulation; |
14734 | 61 |
Engine::move_camera_t* move_camera; |
14875
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14863
diff
changeset
|
62 |
Engine::simple_event_t* simple_event; |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14863
diff
changeset
|
63 |
Engine::long_event_t* long_event; |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14863
diff
changeset
|
64 |
Engine::positioned_event_t* positioned_event; |
14393
b6824a53d4b1
Allow to instantiate HWEngine with different library binaries
unC0Rr
parents:
14311
diff
changeset
|
65 |
bool m_isValid; |
14175
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
66 |
}; |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
67 |
|
14875
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14863
diff
changeset
|
68 |
Q_DECLARE_METATYPE(EngineInstance::SimpleEventType) |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14863
diff
changeset
|
69 |
Q_DECLARE_METATYPE(EngineInstance::LongEventType) |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14863
diff
changeset
|
70 |
Q_DECLARE_METATYPE(EngineInstance::LongEventState) |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14863
diff
changeset
|
71 |
Q_DECLARE_METATYPE(EngineInstance::PositionedEventType) |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14863
diff
changeset
|
72 |
|
14175
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
73 |
#endif // ENGINEINSTANCE_H |