Repository navigation
Expand file tree
/
Copy pathTweenPackage.cpp
More file actions
128 lines (103 loc) · 3.88 KB
/
Copy pathTweenPackage.cpp
File metadata and controls
128 lines (103 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Package entry point of the deki-tween DLL: exports the standard Deki plugin
// interface so the editor can load it and register its components
// (TweenComponent).
//
// When the DLL is linked instead of loaded at run time, the main executable
// must call DekiTweenEnsureRegistered() to run the static initializers.
#include <deki/interop/Plugin.h>
#include "TweenComponent.h"
#include "TweenManager.h"
#include "TweenInit.h"
#include <deki/reflection/ComponentRegistry.h>
#include <deki/reflection/ComponentFactory.h>
extern void DekiTweenRegisterComponents();
extern int DekiTweenGetAutoComponentCount();
extern const Deki::ComponentMeta* DekiTweenGetAutoComponentMeta(int index);
namespace DekiTween
{
#ifdef DEKI_EDITOR
// =============================================================================
// Linked DLL initialization
// =============================================================================
// When deki-tween is linked, not loaded at run time, the editor calls
// DekiTweenEnsureRegistered so the DLL is really loaded and its static
// initializers (REGISTER_COMPONENT) have run.
// Set once registered, so a second call does not register twice.
static bool s_TweenRegistered = false;
// The exports below are C symbols at global scope; the package's own
// registration helpers and statics live in its namespace.
using namespace DekiTween;
extern "C"
{
/// Registers the package's components once and returns how many there
/// are. Call from the editor at startup: the call alone makes the linker
/// include the DLL and run its static initializers.
DEKI_TWEEN_API int DekiTweenEnsureRegistered(void)
{
if (s_TweenRegistered)
{
return ::DekiTweenGetAutoComponentCount();
}
s_TweenRegistered = true;
// Generated: registers every Tween component with ComponentRegistry and ComponentFactory.
::DekiTweenRegisterComponents();
return ::DekiTweenGetAutoComponentCount();
}
} // extern "C"
// =============================================================================
// Plugin metadata, for loading as a DLL
// =============================================================================
extern "C"
{
DEKI_PLUGIN_API const char* DekiPluginGetName(void)
{
return "Deki Tween Package";
}
DEKI_PLUGIN_API const char* DekiPluginGetVersion(void)
{
#ifdef DEKI_PACKAGE_VERSION
return DEKI_PACKAGE_VERSION;
#else
return "0.0.0-dev";
#endif
}
DEKI_PLUGIN_API int DekiPluginInit(void)
{
// Ticks TweenManager from the engine's update loop, so programmatic tweens
// run without a TweenComponent in the scene.
DekiTweenInitSystem();
return 0;
}
DEKI_PLUGIN_API void DekiPluginShutdown(void)
{
DekiTweenShutdownSystem();
s_TweenRegistered = false;
}
DEKI_PLUGIN_API int DekiPluginGetComponentCount(void)
{
return ::DekiTweenGetAutoComponentCount();
}
DEKI_PLUGIN_API const Deki::ComponentMeta* DekiPluginGetComponentMeta(int index)
{
return ::DekiTweenGetAutoComponentMeta(index);
}
DEKI_PLUGIN_API void DekiPluginRegisterComponents(void)
{
DekiTweenEnsureRegistered();
}
DEKI_PLUGIN_API void DekiPluginOnPlayModeStop(void)
{
DekiTween::TweenManager::Instance().KillAll();
}
// deki-tween renders no editor UI of its own, so it links no ImGui and shares no
// ImGui context. Its component inspectors are drawn by the editor via reflection.
// =============================================================================
// Package-specific API, named so linked DLLs do not clash
// =============================================================================
DEKI_TWEEN_API const char* DekiTweenGetName(void)
{
return "Tween";
}
} // extern "C"
#endif // DEKI_EDITOR
} // namespace DekiTween