qmlfrontend/engine_interface.h
author unC0Rr
Wed, 28 Aug 2024 13:41:51 +0200
changeset 16020 9be943326d9c
parent 16016 4933920eba89
permissions -rw-r--r--
Store all snowflakes in a separate array, achieving performance increase of about 10% for the whole engine on winter maps
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 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
15893
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
     7
#include "../rust/lib-hedgewars-engine/target/lib-hedgewars-engine.hpp"
15217
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
     8
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
     9
#ifndef Q_NAMESPACE
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    10
#define Q_NAMESPACE
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    11
#endif
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    12
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    13
#ifndef Q_ENUM_NS
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    14
#define Q_ENUM_NS(x)
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    15
#endif
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    16
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    17
#ifndef Q_DECLARE_METATYPE
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    18
#define Q_DECLARE_METATYPE(x)
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    19
#endif
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    20
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    21
namespace Engine {
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    22
extern "C" {
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    23
15893
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
    24
using EngineInstance = hwengine::EngineInstance;
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
    25
using PreviewInfo = hwengine::PreviewInfo;
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    26
15893
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
    27
using hedgewars_engine_protocol_version_t =
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
    28
    decltype(hwengine::hedgewars_engine_protocol_version);
14294
21be7838a127 Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents: 14271
diff changeset
    29
15893
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
    30
using start_engine_t = decltype(hwengine::start_engine);
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
    31
using generate_preview_t = decltype(hwengine::generate_preview);
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
    32
using dispose_preview_t = decltype(hwengine::dispose_preview);
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
    33
using cleanup_t = decltype(hwengine::cleanup);
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
    34
using send_ipc_t = decltype(hwengine::send_ipc);
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
    35
using read_ipc_t = decltype(hwengine::read_ipc);
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
    36
using setup_current_gl_context_t = decltype(hwengine::setup_current_gl_context);
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
    37
using render_frame_t = decltype(hwengine::render_frame);
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
    38
using advance_simulation_t = decltype(hwengine::advance_simulation);
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
    39
using move_camera_t = decltype(hwengine::move_camera);
14854
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14713
diff changeset
    40
15893
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
    41
using simple_event_t = decltype(hwengine::simple_event);
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
    42
using long_event_t = decltype(hwengine::long_event);
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
    43
using positioned_event_t = decltype(hwengine::positioned_event);
14854
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14713
diff changeset
    44
16016
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    45
}  // extern "C"
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    46
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    47
Q_NAMESPACE
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    48
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    49
/*
15893
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
    50
using SimpleEventType = hwengine::SimpleEventType;
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
    51
using LongEventType = hwengine::LongEventType;
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
    52
using LongEventState = hwengine::LongEventState;
5b3beb90e1a6 Implement generation of c header from rust interface, adapt qmlfrontend
unC0Rr
parents: 15891
diff changeset
    53
using PositionedEventType = hwengine::PositionedEventType;
16016
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    54
*/
14854
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14713
diff changeset
    55
16016
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    56
// NOTE: have to copy these to be able to register then in Qt meta object system
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    57
enum class LongEventState {
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    58
  Set,
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    59
  Unset,
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    60
};
15217
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    61
16016
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    62
enum class LongEventType {
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    63
  ArrowUp,
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    64
  ArrowDown,
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    65
  ArrowLeft,
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    66
  ArrowRight,
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    67
  Precision,
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    68
  Attack,
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    69
};
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    70
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    71
enum class PositionedEventType {
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    72
  CursorMove,
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    73
  CursorClick,
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    74
};
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    75
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    76
enum class SimpleEventType {
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    77
  SwitchHedgehog,
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    78
  Timer,
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    79
  LongJump,
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    80
  HighJump,
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    81
  Accept,
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    82
  Deny,
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    83
};
15217
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    84
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    85
Q_ENUM_NS(SimpleEventType)
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    86
Q_ENUM_NS(LongEventType)
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    87
Q_ENUM_NS(LongEventState)
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    88
Q_ENUM_NS(PositionedEventType)
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    89
16016
4933920eba89 Implement key bindings
unC0Rr
parents: 15893
diff changeset
    90
};  // namespace Engine
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    91
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    92
#endif  // ENGINE_H