|
| 1 | +#include "window_module.hpp" |
| 2 | + |
| 3 | +extern "C" |
| 4 | +{ |
| 5 | +#include "grngame/core/app.h" |
| 6 | +#include "grngame/core/window.h" |
| 7 | +} |
| 8 | + |
| 9 | +static void window_fullscreen() |
| 10 | +{ |
| 11 | + WindowFullscreen(&g_app.info); |
| 12 | +} |
| 13 | + |
| 14 | +static void window_maximized() |
| 15 | +{ |
| 16 | + WindowMaximized(&g_app.info); |
| 17 | +} |
| 18 | + |
| 19 | +static void window_set_size(int width, int height) |
| 20 | +{ |
| 21 | + WindowSetSize(&g_app.info, (uint16)width, (uint16)height); |
| 22 | +} |
| 23 | + |
| 24 | +static int window_get_width() |
| 25 | +{ |
| 26 | + return (int)WindowGetWidth(); |
| 27 | +} |
| 28 | + |
| 29 | +static int window_get_height() |
| 30 | +{ |
| 31 | + return (int)WindowGetHeight(); |
| 32 | +} |
| 33 | + |
| 34 | +static int window_get_universe_width() |
| 35 | +{ |
| 36 | + return (int)WindowGetUniverseWidth(); |
| 37 | +} |
| 38 | + |
| 39 | +static int window_get_universe_height() |
| 40 | +{ |
| 41 | + return (int)WindowGetUniverseHeight(); |
| 42 | +} |
| 43 | + |
| 44 | +static float window_get_offset_x() |
| 45 | +{ |
| 46 | + return WindowGetOffsetX(); |
| 47 | +} |
| 48 | + |
| 49 | +static float window_get_offset_y() |
| 50 | +{ |
| 51 | + return WindowGetOffsetY(); |
| 52 | +} |
| 53 | + |
| 54 | +// todo make c function |
| 55 | +static bool window_is_force_universe_scale() |
| 56 | +{ |
| 57 | + return g_app.info.force_universe_scale; |
| 58 | +} |
| 59 | + |
| 60 | +WindowModule::WindowModule() : Module("grngame_window") |
| 61 | +{ |
| 62 | + auto module_library = das::ModuleLibrary(this); |
| 63 | + module_library.addBuiltInModule(); |
| 64 | + module_library.addModule(this); |
| 65 | + |
| 66 | + das::addExtern<DAS_BIND_FUN(window_fullscreen)>(*this, module_library, "window_fullscreen", |
| 67 | + das::SideEffects::modifyExternal, "window_fullscreen"); |
| 68 | + das::addExtern<DAS_BIND_FUN(window_maximized)>(*this, module_library, "window_maximized", |
| 69 | + das::SideEffects::modifyExternal, "window_maximized"); |
| 70 | + das::addExtern<DAS_BIND_FUN(window_set_size)>(*this, module_library, "window_set_size", |
| 71 | + das::SideEffects::modifyExternal, "window_set_size"); |
| 72 | + |
| 73 | + das::addExtern<DAS_BIND_FUN(window_get_width)>(*this, module_library, "window_get_width", |
| 74 | + das::SideEffects::modifyExternal, "window_get_width"); |
| 75 | + das::addExtern<DAS_BIND_FUN(window_get_height)>(*this, module_library, "window_get_height", |
| 76 | + das::SideEffects::modifyExternal, "window_get_height"); |
| 77 | + das::addExtern<DAS_BIND_FUN(window_get_universe_width)>(*this, module_library, "window_get_universe_width", |
| 78 | + das::SideEffects::modifyExternal, |
| 79 | + "window_get_universe_width"); |
| 80 | + das::addExtern<DAS_BIND_FUN(window_get_universe_height)>(*this, module_library, "window_get_universe_height", |
| 81 | + das::SideEffects::modifyExternal, |
| 82 | + "window_get_universe_height"); |
| 83 | + das::addExtern<DAS_BIND_FUN(window_get_offset_x)>(*this, module_library, "window_get_offset_x", |
| 84 | + das::SideEffects::modifyExternal, "window_get_offset_x"); |
| 85 | + das::addExtern<DAS_BIND_FUN(window_get_offset_y)>(*this, module_library, "window_get_offset_y", |
| 86 | + das::SideEffects::modifyExternal, "window_get_offset_y"); |
| 87 | + das::addExtern<DAS_BIND_FUN(window_is_force_universe_scale)>( |
| 88 | + *this, module_library, "window_is_force_universe_scale", das::SideEffects::modifyExternal, |
| 89 | + "window_is_force_universe_scale"); |
| 90 | +} |
| 91 | + |
| 92 | +REGISTER_MODULE(WindowModule); |
0 commit comments