19 #define Q_DECLARE_METATYPE(x) |
18 #define Q_DECLARE_METATYPE(x) |
20 #endif |
19 #endif |
21 |
20 |
22 namespace Engine { |
21 namespace Engine { |
23 extern "C" { |
22 extern "C" { |
24 #else |
|
25 #define ENUM_CLASS enum class |
|
26 #endif |
|
27 |
23 |
28 typedef struct _EngineInstance EngineInstance; |
24 using EngineInstance = hwengine::EngineInstance; |
|
25 using PreviewInfo = hwengine::PreviewInfo; |
29 |
26 |
30 typedef struct { |
27 using hedgewars_engine_protocol_version_t = |
31 uint32_t width; |
28 decltype(hwengine::hedgewars_engine_protocol_version); |
32 uint32_t height; |
|
33 uint8_t hedgehogs_number; |
|
34 unsigned char* land; |
|
35 } PreviewInfo; |
|
36 |
29 |
37 typedef uint32_t hedgewars_engine_protocol_version_t(); |
30 using start_engine_t = decltype(hwengine::start_engine); |
38 typedef EngineInstance* start_engine_t(const char* data_path); |
31 using generate_preview_t = decltype(hwengine::generate_preview); |
39 typedef void generate_preview_t(EngineInstance* engine_state, |
32 using dispose_preview_t = decltype(hwengine::dispose_preview); |
40 PreviewInfo* preview); |
33 using cleanup_t = decltype(hwengine::cleanup); |
41 typedef void dispose_preview_t(EngineInstance* engine_state); |
34 using send_ipc_t = decltype(hwengine::send_ipc); |
42 typedef void cleanup_t(EngineInstance* engine_state); |
35 using read_ipc_t = decltype(hwengine::read_ipc); |
|
36 using setup_current_gl_context_t = decltype(hwengine::setup_current_gl_context); |
|
37 using render_frame_t = decltype(hwengine::render_frame); |
|
38 using advance_simulation_t = decltype(hwengine::advance_simulation); |
|
39 using move_camera_t = decltype(hwengine::move_camera); |
43 |
40 |
44 typedef void send_ipc_t(EngineInstance* engine_state, uint8_t* buf, |
41 using simple_event_t = decltype(hwengine::simple_event); |
45 size_t size); |
42 using long_event_t = decltype(hwengine::long_event); |
46 typedef size_t read_ipc_t(EngineInstance* engine_state, uint8_t* buf, |
43 using positioned_event_t = decltype(hwengine::positioned_event); |
47 size_t size); |
|
48 |
44 |
49 typedef void setup_current_gl_context_t(EngineInstance* engine_state, |
45 using SimpleEventType = hwengine::SimpleEventType; |
50 uint16_t width, uint16_t height, |
46 using LongEventType = hwengine::LongEventType; |
51 void (*(const char*))()); |
47 using LongEventState = hwengine::LongEventState; |
52 typedef void render_frame_t(EngineInstance* engine_state); |
48 using PositionedEventType = hwengine::PositionedEventType; |
53 |
49 |
54 typedef bool advance_simulation_t(EngineInstance* engine_state, uint32_t ticks); |
|
55 |
|
56 typedef void move_camera_t(EngineInstance* engine_state, int32_t delta_x, |
|
57 int32_t delta_y); |
|
58 |
|
59 ENUM_CLASS SimpleEventType{ |
|
60 SwitchHedgehog, Timer, LongJump, HighJump, Accept, Deny, |
|
61 }; |
|
62 |
|
63 ENUM_CLASS LongEventType{ |
|
64 ArrowUp, ArrowDown, ArrowLeft, ArrowRight, Precision, Attack, |
|
65 }; |
|
66 |
|
67 ENUM_CLASS LongEventState{ |
|
68 Set, |
|
69 Unset, |
|
70 }; |
|
71 |
|
72 ENUM_CLASS PositionedEventType{ |
|
73 CursorMove, |
|
74 CursorClick, |
|
75 }; |
|
76 |
|
77 typedef void simple_event_t(EngineInstance* engine_state, |
|
78 SimpleEventType event_type); |
|
79 typedef void long_event_t(EngineInstance* engine_state, |
|
80 LongEventType event_type, LongEventState state); |
|
81 typedef void positioned_event_t(EngineInstance* engine_state, |
|
82 PositionedEventType event_type, int32_t x, |
|
83 int32_t y); |
|
84 } // extern "C" |
50 } // extern "C" |
85 |
51 |
86 #ifdef __cplusplus |
|
87 Q_NAMESPACE |
52 Q_NAMESPACE |
88 |
53 |
89 Q_ENUM_NS(SimpleEventType) |
54 Q_ENUM_NS(SimpleEventType) |
90 Q_ENUM_NS(LongEventType) |
55 Q_ENUM_NS(LongEventType) |
91 Q_ENUM_NS(LongEventState) |
56 Q_ENUM_NS(LongEventState) |