author | alfadur |
Mon, 14 Mar 2022 22:08:31 +0300 | |
changeset 15837 | 42109eb6ef51 |
parent 15217 | b32c52c76977 |
child 15891 | d52f5d8e75e6 |
permissions | -rw-r--r-- |
14154
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
1 |
#ifndef ENGINE_H |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
2 |
#define ENGINE_H |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
3 |
|
14271
1aac8a62be6f
Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents:
14154
diff
changeset
|
4 |
#include <stddef.h> |
14154
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
5 |
#include <stdint.h> |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
6 |
|
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
7 |
#ifdef __cplusplus |
14854
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
8 |
#define ENUM_CLASS enum |
15217 | 9 |
|
10 |
#ifndef Q_NAMESPACE |
|
11 |
#define Q_NAMESPACE |
|
12 |
#endif |
|
13 |
||
14 |
#ifndef Q_ENUM_NS |
|
15 |
#define Q_ENUM_NS(x) |
|
16 |
#endif |
|
17 |
||
18 |
#ifndef Q_DECLARE_METATYPE |
|
19 |
#define Q_DECLARE_METATYPE(x) |
|
20 |
#endif |
|
21 |
||
14154
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
22 |
namespace Engine { |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
23 |
extern "C" { |
14854
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
24 |
#else |
15217 | 25 |
#define ENUM_CLASS enum class |
14154
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
26 |
#endif |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
27 |
|
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
28 |
typedef struct _EngineInstance EngineInstance; |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
29 |
|
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
30 |
typedef struct { |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
31 |
uint32_t width; |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
32 |
uint32_t height; |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
33 |
uint8_t hedgehogs_number; |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
34 |
unsigned char* land; |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
35 |
} PreviewInfo; |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
36 |
|
14370
ef2fc0210362
Rename protocol_version to hedgewars_engine_protocol_version to ensure use of correct library
unC0Rr
parents:
14298
diff
changeset
|
37 |
typedef uint32_t hedgewars_engine_protocol_version_t(); |
14154
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
38 |
typedef EngineInstance* start_engine_t(); |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
39 |
typedef void generate_preview_t(EngineInstance* engine_state, |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
40 |
PreviewInfo* preview); |
14373
4409344db447
Rework EngineInstance::generatePreview, add preview cleanup function in enginelib
unC0Rr
parents:
14372
diff
changeset
|
41 |
typedef void dispose_preview_t(EngineInstance* engine_state); |
14154
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
42 |
typedef void cleanup_t(EngineInstance* engine_state); |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
43 |
|
14271
1aac8a62be6f
Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents:
14154
diff
changeset
|
44 |
typedef void send_ipc_t(EngineInstance* engine_state, uint8_t* buf, |
1aac8a62be6f
Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents:
14154
diff
changeset
|
45 |
size_t size); |
1aac8a62be6f
Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents:
14154
diff
changeset
|
46 |
typedef size_t read_ipc_t(EngineInstance* engine_state, uint8_t* buf, |
1aac8a62be6f
Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents:
14154
diff
changeset
|
47 |
size_t size); |
1aac8a62be6f
Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents:
14154
diff
changeset
|
48 |
|
14294
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14271
diff
changeset
|
49 |
typedef void setup_current_gl_context_t(EngineInstance* engine_state, |
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14271
diff
changeset
|
50 |
uint16_t width, uint16_t height, |
14298 | 51 |
void (*(const char*))()); |
14294
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14271
diff
changeset
|
52 |
typedef void render_frame_t(EngineInstance* engine_state); |
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14271
diff
changeset
|
53 |
|
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14271
diff
changeset
|
54 |
typedef bool advance_simulation_t(EngineInstance* engine_state, uint32_t ticks); |
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14271
diff
changeset
|
55 |
|
14713 | 56 |
typedef void move_camera_t(EngineInstance* engine_state, int32_t delta_x, |
57 |
int32_t delta_y); |
|
58 |
||
14854
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
59 |
ENUM_CLASS SimpleEventType{ |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
60 |
SwitchHedgehog, Timer, LongJump, HighJump, Accept, Deny, |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
61 |
}; |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
62 |
|
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
63 |
ENUM_CLASS LongEventType{ |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
64 |
ArrowUp, ArrowDown, ArrowLeft, ArrowRight, Precision, Attack, |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
65 |
}; |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
66 |
|
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
67 |
ENUM_CLASS LongEventState{ |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
68 |
Set, |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
69 |
Unset, |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
70 |
}; |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
71 |
|
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
72 |
ENUM_CLASS PositionedEventType{ |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
73 |
CursorMove, |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
74 |
CursorClick, |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
75 |
}; |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
76 |
|
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
77 |
typedef void simple_event_t(EngineInstance* engine_state, |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
78 |
SimpleEventType event_type); |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
79 |
typedef void long_event_t(EngineInstance* engine_state, |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
80 |
LongEventType event_type, LongEventState state); |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
81 |
typedef void positioned_event_t(EngineInstance* engine_state, |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
82 |
PositionedEventType event_type, int32_t x, |
aed75d439027
Implement external events approach to input user actions into engine.
unc0rr
parents:
14713
diff
changeset
|
83 |
int32_t y); |
15217 | 84 |
} // extern "C" |
85 |
||
14154
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
86 |
#ifdef __cplusplus |
15217 | 87 |
Q_NAMESPACE |
88 |
||
89 |
Q_ENUM_NS(SimpleEventType) |
|
90 |
Q_ENUM_NS(LongEventType) |
|
91 |
Q_ENUM_NS(LongEventState) |
|
92 |
Q_ENUM_NS(PositionedEventType) |
|
93 |
||
94 |
}; // namespace |
|
95 |
||
96 |
Q_DECLARE_METATYPE(Engine::SimpleEventType) |
|
97 |
Q_DECLARE_METATYPE(Engine::LongEventType) |
|
98 |
Q_DECLARE_METATYPE(Engine::LongEventState) |
|
99 |
Q_DECLARE_METATYPE(Engine::PositionedEventType) |
|
14154
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
100 |
#endif |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
101 |
|
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
102 |
#endif // ENGINE_H |