|
10 | 10 |
|
11 | 11 | using namespace Supernova; |
12 | 12 |
|
13 | | -System* System::external = nullptr; |
| 13 | +System* System::systemInstance = nullptr; |
14 | 14 |
|
15 | 15 | #define USERSETTINGS_ROOT "userSettings" |
16 | 16 | #define USERSETTINGS_XML_FILE "data://UserSettings.xml" |
17 | 17 |
|
18 | | -#ifdef SUPERNOVA_ANDROID |
19 | | -#include "SupernovaAndroid.h" |
20 | | -#endif |
21 | | -#ifdef SUPERNOVA_IOS |
22 | | -#include "SupernovaIOS.h" |
23 | | -#endif |
24 | | -#ifdef SUPERNOVA_WEB |
25 | | -#include "SupernovaWeb.h" |
26 | | -#endif |
27 | | -#ifdef SUPERNOVA_SOKOL |
28 | | -#include "SupernovaSokol.h" |
29 | | -#endif |
30 | | -#ifdef SUPERNOVA_GLFW |
31 | | -#include "SupernovaGLFW.h" |
32 | | -#endif |
33 | | -#ifdef SUPERNOVA_APPLE |
34 | | -#include "SupernovaApple.h" |
35 | | -#endif |
36 | | - |
37 | 18 | System& System::instance(){ |
38 | | -#ifdef SUPERNOVA_ANDROID |
39 | | - static System* instance = new SupernovaAndroid(); |
40 | | -#elif defined(SUPERNOVA_IOS) |
41 | | - static System* instance = new SupernovaIOS(); |
42 | | -#elif defined(SUPERNOVA_WEB) |
43 | | - static System* instance = new SupernovaWeb(); |
44 | | -#elif defined(SUPERNOVA_SOKOL) |
45 | | - static System* instance = new SupernovaSokol(); |
46 | | -#elif defined(SUPERNOVA_GLFW) |
47 | | - static System* instance = new SupernovaGLFW(); |
48 | | -#elif defined(SUPERNOVA_APPLE) |
49 | | - static System* instance = new SupernovaApple(); |
50 | | -#else |
51 | | - static System* instance = external; |
52 | | -#endif |
| 19 | + if (!systemInstance) { |
| 20 | + Log::error("System instance not set. Engine must call System::setSystemInstance() during initialization."); |
| 21 | + abort(); |
| 22 | + } |
53 | 23 |
|
54 | | - return *instance; |
| 24 | + return *systemInstance; |
55 | 25 | } |
56 | 26 |
|
57 | | -void System::setExternalSystem(System* system){ |
58 | | - external = system; |
| 27 | +void System::setSystemInstance(System* system){ |
| 28 | + systemInstance = system; |
59 | 29 | } |
60 | 30 |
|
61 | 31 | sg_environment System::getSokolEnvironment(){ |
|
0 commit comments