|
29 | 29 | #include "wiTimer.h" |
30 | 30 | #include "wiVector.h" |
31 | 31 | #include "wiVersion.h" |
| 32 | +#include "wiPlatform.h" |
32 | 33 |
|
33 | 34 | #include <memory> |
34 | 35 |
|
@@ -72,6 +73,61 @@ namespace wi::lua |
72 | 73 | return 0; |
73 | 74 | } |
74 | 75 |
|
| 76 | + int IsPlatformWindows(lua_State* L) |
| 77 | + { |
| 78 | +#ifdef PLATFORM_WINDOWS_DESKTOP |
| 79 | + wi::lua::SSetBool(L, true); |
| 80 | +#else |
| 81 | + wi::lua::SSetBool(L, false); |
| 82 | +#endif // PLATFORM_WINDOWS_DESKTOP |
| 83 | + return 1; |
| 84 | + } |
| 85 | + int IsPlatformLinux(lua_State* L) |
| 86 | + { |
| 87 | +#ifdef PLATFORM_LINUX |
| 88 | + wi::lua::SSetBool(L, true); |
| 89 | +#else |
| 90 | + wi::lua::SSetBool(L, false); |
| 91 | +#endif // PLATFORM_LINUX |
| 92 | + return 1; |
| 93 | + } |
| 94 | + int IsPlatformMACOS(lua_State* L) |
| 95 | + { |
| 96 | +#ifdef PLATFORM_MACOS |
| 97 | + wi::lua::SSetBool(L, true); |
| 98 | +#else |
| 99 | + wi::lua::SSetBool(L, false); |
| 100 | +#endif // PLATFORM_MACOS |
| 101 | + return 1; |
| 102 | + } |
| 103 | + int IsPlatformIOS(lua_State* L) |
| 104 | + { |
| 105 | +#ifdef PLATFORM_IOS |
| 106 | + wi::lua::SSetBool(L, true); |
| 107 | +#else |
| 108 | + wi::lua::SSetBool(L, false); |
| 109 | +#endif // PLATFORM_IOS |
| 110 | + return 1; |
| 111 | + } |
| 112 | + int IsPlatformPS5(lua_State* L) |
| 113 | + { |
| 114 | +#ifdef PLATFORM_PS5 |
| 115 | + wi::lua::SSetBool(L, true); |
| 116 | +#else |
| 117 | + wi::lua::SSetBool(L, false); |
| 118 | +#endif // PLATFORM_PS5 |
| 119 | + return 1; |
| 120 | + } |
| 121 | + int IsPlatformXBOX(lua_State* L) |
| 122 | + { |
| 123 | +#ifdef PLATFORM_XBOX |
| 124 | + wi::lua::SSetBool(L, true); |
| 125 | +#else |
| 126 | + wi::lua::SSetBool(L, false); |
| 127 | +#endif // PLATFORM_XBOX |
| 128 | + return 1; |
| 129 | + } |
| 130 | + |
75 | 131 | void PostErrorMsg(lua_State* L) |
76 | 132 | { |
77 | 133 | const char* str = lua_tostring(L, -1); |
@@ -289,6 +345,13 @@ namespace wi::lua |
289 | 345 | RegisterFunc("GetCreditsString", GetCreditsString); |
290 | 346 | RegisterFunc("GetSupportersString", GetSupportersString); |
291 | 347 |
|
| 348 | + RegisterFunc("IsPlatformWindows", IsPlatformWindows); |
| 349 | + RegisterFunc("IsPlatformLinux", IsPlatformLinux); |
| 350 | + RegisterFunc("IsPlatformMACOS", IsPlatformMACOS); |
| 351 | + RegisterFunc("IsPlatformIOS", IsPlatformIOS); |
| 352 | + RegisterFunc("IsPlatformPS5", IsPlatformPS5); |
| 353 | + RegisterFunc("IsPlatformXBOX", IsPlatformXBOX); |
| 354 | + |
292 | 355 | Vector_BindLua::Bind(); |
293 | 356 | Matrix_BindLua::Bind(); |
294 | 357 | Application_BindLua::Bind(); |
|
0 commit comments