qmlfrontend/engine_interface.h
author sheepluva
Sat, 07 Dec 2019 23:58:37 +0100
branchhedgeroid
changeset 15518 f0bf14ead75c
parent 15222 b32c52c76977
permissions -rw-r--r--
hedgeroid: adjust build.xml: fix app name; set java version; print hint if sdk build.xml is missing
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14159
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
14276
1aac8a62be6f Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents: 14159
diff changeset
     4
#include <stddef.h>
14159
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
14859
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
     8
#define ENUM_CLASS enum
15222
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
     9
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    10
#ifndef Q_NAMESPACE
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    11
#define Q_NAMESPACE
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    12
#endif
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    13
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    14
#ifndef Q_ENUM_NS
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    15
#define Q_ENUM_NS(x)
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    16
#endif
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    17
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    18
#ifndef Q_DECLARE_METATYPE
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    19
#define Q_DECLARE_METATYPE(x)
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    20
#endif
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    21
14159
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" {
14859
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    24
#else
15222
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    25
#define ENUM_CLASS enum class
14159
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
14375
ef2fc0210362 Rename protocol_version to hedgewars_engine_protocol_version to ensure use of correct library
unC0Rr
parents: 14303
diff changeset
    37
typedef uint32_t hedgewars_engine_protocol_version_t();
14159
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);
14378
4409344db447 Rework EngineInstance::generatePreview, add preview cleanup function in enginelib
unC0Rr
parents: 14377
diff changeset
    41
typedef void dispose_preview_t(EngineInstance* engine_state);
14159
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
14276
1aac8a62be6f Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents: 14159
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: 14159
diff changeset
    45
                        size_t size);
1aac8a62be6f Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents: 14159
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: 14159
diff changeset
    47
                          size_t size);
1aac8a62be6f Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents: 14159
diff changeset
    48
14299
21be7838a127 Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents: 14276
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: 14276
diff changeset
    50
                                        uint16_t width, uint16_t height,
14303
00b56ec8b7df Pass opengl context to engine
unC0Rr
parents: 14299
diff changeset
    51
                                        void (*(const char*))());
14299
21be7838a127 Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents: 14276
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: 14276
diff changeset
    53
21be7838a127 Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents: 14276
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: 14276
diff changeset
    55
14718
cc6ab1e3f7d5 Allow to move camera around
unc0rr
parents: 14378
diff changeset
    56
typedef void move_camera_t(EngineInstance* engine_state, int32_t delta_x,
cc6ab1e3f7d5 Allow to move camera around
unc0rr
parents: 14378
diff changeset
    57
                           int32_t delta_y);
cc6ab1e3f7d5 Allow to move camera around
unc0rr
parents: 14378
diff changeset
    58
14859
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    59
ENUM_CLASS SimpleEventType{
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    60
    SwitchHedgehog, Timer, LongJump, HighJump, Accept, Deny,
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    61
};
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    62
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    63
ENUM_CLASS LongEventType{
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    64
    ArrowUp, ArrowDown, ArrowLeft, ArrowRight, Precision, Attack,
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    65
};
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    66
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    67
ENUM_CLASS LongEventState{
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    68
    Set,
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    69
    Unset,
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    70
};
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    71
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    72
ENUM_CLASS PositionedEventType{
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    73
    CursorMove,
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    74
    CursorClick,
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    75
};
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    76
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    77
typedef void simple_event_t(EngineInstance* engine_state,
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    78
                            SimpleEventType event_type);
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    79
typedef void long_event_t(EngineInstance* engine_state,
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    80
                          LongEventType event_type, LongEventState state);
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    81
typedef void positioned_event_t(EngineInstance* engine_state,
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    82
                                PositionedEventType event_type, int32_t x,
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14718
diff changeset
    83
                                int32_t y);
15222
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    84
}  // extern "C"
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    85
14159
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    86
#ifdef __cplusplus
15222
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    87
Q_NAMESPACE
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    88
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    89
Q_ENUM_NS(SimpleEventType)
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    90
Q_ENUM_NS(LongEventType)
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    91
Q_ENUM_NS(LongEventState)
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    92
Q_ENUM_NS(PositionedEventType)
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    93
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    94
};  // namespace
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    95
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    96
Q_DECLARE_METATYPE(Engine::SimpleEventType)
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    97
Q_DECLARE_METATYPE(Engine::LongEventType)
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    98
Q_DECLARE_METATYPE(Engine::LongEventState)
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14859
diff changeset
    99
Q_DECLARE_METATYPE(Engine::PositionedEventType)
14159
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