From ee0393d5f73daadafb429c969a8d9b266b12a1be Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Sat, 2 Nov 2019 03:06:00 +0700 Subject: [PATCH] new binds --- headers/enduro2d/high/_high.hpp | 30 - headers/enduro2d/math/_math.hpp | 1 - sources/enduro2d/high/bindings/bindings.hpp | 28 +- .../high/bindings/core_binds/_core_binds.hpp | 29 + .../high/bindings/core_binds/dbgui_binds.cpp | 22 + .../high/bindings/core_binds/debug_binds.cpp | 34 + .../high/bindings/core_binds/engine_binds.cpp | 24 + .../input_binds.cpp} | 117 +-- .../high/bindings/core_binds/window_binds.cpp | 62 ++ sources/enduro2d/high/bindings/high_binds.cpp | 75 -- .../high/bindings/high_binds/_high_binds.hpp | 55 ++ .../high_binds/components/actor_binds.cpp | 21 + .../high_binds/components/behaviour_binds.cpp | 23 + .../high_binds/components/camera_binds.cpp | 35 + .../components/flipbook_player_binds.cpp | 48 ++ .../high_binds/components/label_binds.cpp | 129 ++++ .../components/model_renderer_binds.cpp | 23 + .../high_binds/components/named_binds.cpp | 23 + .../high_binds/components/renderer_binds.cpp | 19 + .../high_binds/components/scene_binds.cpp | 23 + .../components/spine_player_binds.cpp | 167 +++++ .../components/sprite_renderer_binds.cpp | 43 ++ .../bindings/high_binds/gobject_binds.cpp | 47 ++ .../bindings/high_binds/library_binds.cpp | 18 + .../high/bindings/high_binds/luasol_binds.cpp | 18 + .../high/bindings/high_binds/node_binds.cpp | 75 ++ .../high/bindings/high_binds/world_binds.cpp | 18 + sources/enduro2d/high/bindings/math_binds.cpp | 678 ------------------ .../high/bindings/math_binds/_math_binds.hpp | 53 ++ .../high/bindings/math_binds/aabb_binds.cpp | 80 +++ .../high/bindings/math_binds/mat2_binds.cpp | 64 ++ .../high/bindings/math_binds/mat3_binds.cpp | 71 ++ .../high/bindings/math_binds/mat4_binds.cpp | 77 ++ .../high/bindings/math_binds/quat_binds.cpp | 74 ++ .../high/bindings/math_binds/rect_binds.cpp | 80 +++ .../high/bindings/math_binds/trs2_binds.cpp | 48 ++ .../high/bindings/math_binds/trs3_binds.cpp | 45 ++ .../high/bindings/math_binds/unit_binds.cpp | 58 ++ .../high/bindings/math_binds/vec2_binds.cpp | 94 +++ .../high/bindings/math_binds/vec3_binds.cpp | 99 +++ .../high/bindings/math_binds/vec4_binds.cpp | 98 +++ .../enduro2d/high/bindings/utils_binds.cpp | 146 ---- .../bindings/utils_binds/_utils_binds.hpp | 25 + .../bindings/utils_binds/color32_binds.cpp | 76 ++ .../high/bindings/utils_binds/color_binds.cpp | 76 ++ .../bindings/utils_binds/str_hash_binds.cpp | 28 + sources/enduro2d/high/luasol.cpp | 5 +- .../enduro2d/high/systems/script_system.cpp | 16 +- support/components/actor.md | 6 + support/components/behaviour.md | 6 + support/components/camera.md | 10 + support/components/flipbook_player.md | 19 + support/components/label.md | 28 + support/components/model_renderer.md | 6 + support/components/named.md | 6 + support/components/renderer.md | 2 + support/components/scene.md | 6 + support/components/spine_player.md | 92 +++ support/components/sprite_renderer.md | 17 + support/gobject.md | 42 ++ support/modules/dbgui.md | 18 + support/modules/debug.md | 16 + support/modules/engine.md | 18 + support/modules/input.md | 122 ++++ support/modules/library.md | 1 + support/modules/luasol.md | 1 + support/modules/window.md | 46 ++ support/modules/world.md | 2 + support/node.md | 44 ++ 69 files changed, 2672 insertions(+), 1034 deletions(-) create mode 100644 sources/enduro2d/high/bindings/core_binds/_core_binds.hpp create mode 100644 sources/enduro2d/high/bindings/core_binds/dbgui_binds.cpp create mode 100644 sources/enduro2d/high/bindings/core_binds/debug_binds.cpp create mode 100644 sources/enduro2d/high/bindings/core_binds/engine_binds.cpp rename sources/enduro2d/high/bindings/{core_binds.cpp => core_binds/input_binds.cpp} (65%) create mode 100644 sources/enduro2d/high/bindings/core_binds/window_binds.cpp delete mode 100644 sources/enduro2d/high/bindings/high_binds.cpp create mode 100644 sources/enduro2d/high/bindings/high_binds/_high_binds.hpp create mode 100644 sources/enduro2d/high/bindings/high_binds/components/actor_binds.cpp create mode 100644 sources/enduro2d/high/bindings/high_binds/components/behaviour_binds.cpp create mode 100644 sources/enduro2d/high/bindings/high_binds/components/camera_binds.cpp create mode 100644 sources/enduro2d/high/bindings/high_binds/components/flipbook_player_binds.cpp create mode 100644 sources/enduro2d/high/bindings/high_binds/components/label_binds.cpp create mode 100644 sources/enduro2d/high/bindings/high_binds/components/model_renderer_binds.cpp create mode 100644 sources/enduro2d/high/bindings/high_binds/components/named_binds.cpp create mode 100644 sources/enduro2d/high/bindings/high_binds/components/renderer_binds.cpp create mode 100644 sources/enduro2d/high/bindings/high_binds/components/scene_binds.cpp create mode 100644 sources/enduro2d/high/bindings/high_binds/components/spine_player_binds.cpp create mode 100644 sources/enduro2d/high/bindings/high_binds/components/sprite_renderer_binds.cpp create mode 100644 sources/enduro2d/high/bindings/high_binds/gobject_binds.cpp create mode 100644 sources/enduro2d/high/bindings/high_binds/library_binds.cpp create mode 100644 sources/enduro2d/high/bindings/high_binds/luasol_binds.cpp create mode 100644 sources/enduro2d/high/bindings/high_binds/node_binds.cpp create mode 100644 sources/enduro2d/high/bindings/high_binds/world_binds.cpp delete mode 100644 sources/enduro2d/high/bindings/math_binds.cpp create mode 100644 sources/enduro2d/high/bindings/math_binds/_math_binds.hpp create mode 100644 sources/enduro2d/high/bindings/math_binds/aabb_binds.cpp create mode 100644 sources/enduro2d/high/bindings/math_binds/mat2_binds.cpp create mode 100644 sources/enduro2d/high/bindings/math_binds/mat3_binds.cpp create mode 100644 sources/enduro2d/high/bindings/math_binds/mat4_binds.cpp create mode 100644 sources/enduro2d/high/bindings/math_binds/quat_binds.cpp create mode 100644 sources/enduro2d/high/bindings/math_binds/rect_binds.cpp create mode 100644 sources/enduro2d/high/bindings/math_binds/trs2_binds.cpp create mode 100644 sources/enduro2d/high/bindings/math_binds/trs3_binds.cpp create mode 100644 sources/enduro2d/high/bindings/math_binds/unit_binds.cpp create mode 100644 sources/enduro2d/high/bindings/math_binds/vec2_binds.cpp create mode 100644 sources/enduro2d/high/bindings/math_binds/vec3_binds.cpp create mode 100644 sources/enduro2d/high/bindings/math_binds/vec4_binds.cpp delete mode 100644 sources/enduro2d/high/bindings/utils_binds.cpp create mode 100644 sources/enduro2d/high/bindings/utils_binds/_utils_binds.hpp create mode 100644 sources/enduro2d/high/bindings/utils_binds/color32_binds.cpp create mode 100644 sources/enduro2d/high/bindings/utils_binds/color_binds.cpp create mode 100644 sources/enduro2d/high/bindings/utils_binds/str_hash_binds.cpp create mode 100644 support/components/actor.md create mode 100644 support/components/behaviour.md create mode 100644 support/components/camera.md create mode 100644 support/components/flipbook_player.md create mode 100644 support/components/label.md create mode 100644 support/components/model_renderer.md create mode 100644 support/components/named.md create mode 100644 support/components/renderer.md create mode 100644 support/components/scene.md create mode 100644 support/components/spine_player.md create mode 100644 support/components/sprite_renderer.md create mode 100644 support/gobject.md create mode 100644 support/modules/dbgui.md create mode 100644 support/modules/debug.md create mode 100644 support/modules/engine.md create mode 100644 support/modules/input.md create mode 100644 support/modules/library.md create mode 100644 support/modules/luasol.md create mode 100644 support/modules/window.md create mode 100644 support/modules/world.md create mode 100644 support/node.md diff --git a/headers/enduro2d/high/_high.hpp b/headers/enduro2d/high/_high.hpp index 88eaddcb..b09b8185 100644 --- a/headers/enduro2d/high/_high.hpp +++ b/headers/enduro2d/high/_high.hpp @@ -111,34 +111,4 @@ namespace sol return ptr.get(); } }; - - template < typename T > - struct unique_usertype_traits> { - using type = T; - using actual_type = e2d::gcomponent; - static const bool value = true; - - static bool is_null(const actual_type& ptr) { - return !ptr; - } - - static type* get(actual_type& ptr) { - return ptr.find(); - } - }; - - template < typename T > - struct unique_usertype_traits> { - using type = T; - using actual_type = e2d::const_gcomponent; - static const bool value = true; - - static bool is_null(const actual_type& ptr) { - return !ptr; - } - - static type* get(actual_type& ptr) { - return ptr.find(); - } - }; } diff --git a/headers/enduro2d/math/_math.hpp b/headers/enduro2d/math/_math.hpp index c190aae4..bd7d7d32 100644 --- a/headers/enduro2d/math/_math.hpp +++ b/headers/enduro2d/math/_math.hpp @@ -742,7 +742,6 @@ namespace e2d::math template < typename T > T inverse_lerp(T l, T r, T v) noexcept { - E2D_ASSERT(!approximately(l, r, T(0))); return (v - l) / (r - l); } } diff --git a/sources/enduro2d/high/bindings/bindings.hpp b/sources/enduro2d/high/bindings/bindings.hpp index d7afed3a..9e39be5b 100644 --- a/sources/enduro2d/high/bindings/bindings.hpp +++ b/sources/enduro2d/high/bindings/bindings.hpp @@ -6,12 +6,30 @@ #pragma once -#include +#include namespace e2d::bindings { - void bind_math(sol::state& l); - void bind_utils(sol::state& l); - void bind_core(sol::state& l); - void bind_high(sol::state& l); + template < typename T > + struct component_wrapper { + gcomponent component; + }; +} + +namespace sol +{ + template < typename T > + struct unique_usertype_traits> { + using type = e2d::gcomponent; + using actual_type = e2d::bindings::component_wrapper; + static const bool value = true; + + static bool is_null(const actual_type& ptr) { + return !ptr.component.exists(); + } + + static type* get(actual_type& ptr) { + return &ptr.component; + } + }; } diff --git a/sources/enduro2d/high/bindings/core_binds/_core_binds.hpp b/sources/enduro2d/high/bindings/core_binds/_core_binds.hpp new file mode 100644 index 00000000..0cad61e1 --- /dev/null +++ b/sources/enduro2d/high/bindings/core_binds/_core_binds.hpp @@ -0,0 +1,29 @@ +/******************************************************************************* +* This file is part of the "Enduro2D" +* For conditions of distribution and use, see copyright notice in LICENSE.md +* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) +******************************************************************************/ + +#pragma once + +#include "../bindings.hpp" + +namespace e2d::bindings::core +{ + void bind_dbgui(sol::state& l); + void bind_debug(sol::state& l); + void bind_engine(sol::state& l); + void bind_input(sol::state& l); + void bind_window(sol::state& l); +} + +namespace e2d::bindings +{ + inline void bind_core(sol::state& l) { + core::bind_dbgui(l); + core::bind_debug(l); + core::bind_engine(l); + core::bind_input(l); + core::bind_window(l); + } +} diff --git a/sources/enduro2d/high/bindings/core_binds/dbgui_binds.cpp b/sources/enduro2d/high/bindings/core_binds/dbgui_binds.cpp new file mode 100644 index 00000000..4db7e9cf --- /dev/null +++ b/sources/enduro2d/high/bindings/core_binds/dbgui_binds.cpp @@ -0,0 +1,22 @@ +/******************************************************************************* +* This file is part of the "Enduro2D" +* For conditions of distribution and use, see copyright notice in LICENSE.md +* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) +******************************************************************************/ + +#include "_core_binds.hpp" + +namespace e2d::bindings::core +{ + void bind_dbgui(sol::state& l) { + l["e2d"].get_or_create() + ["core"].get_or_create() + .new_usertype("dbgui", + sol::no_constructor, + + "visible", sol::property( + &dbgui::visible, + &dbgui::toggle_visible) + ); + } +} diff --git a/sources/enduro2d/high/bindings/core_binds/debug_binds.cpp b/sources/enduro2d/high/bindings/core_binds/debug_binds.cpp new file mode 100644 index 00000000..e0e90e91 --- /dev/null +++ b/sources/enduro2d/high/bindings/core_binds/debug_binds.cpp @@ -0,0 +1,34 @@ +/******************************************************************************* +* This file is part of the "Enduro2D" +* For conditions of distribution and use, see copyright notice in LICENSE.md +* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) +******************************************************************************/ + +#include "_core_binds.hpp" + +namespace e2d::bindings::core +{ + void bind_debug(sol::state& l) { + l["e2d"].get_or_create() + ["core"].get_or_create() + .new_usertype("debug", + sol::no_constructor, + + "trace", [](debug& d, const char* s){ + d.trace(s); + }, + + "warning", [](debug& d, const char* s){ + d.warning(s); + }, + + "error", [](debug& d, const char* s){ + d.error(s); + }, + + "fatal", [](debug& d, const char* s){ + d.fatal(s); + } + ); + } +} diff --git a/sources/enduro2d/high/bindings/core_binds/engine_binds.cpp b/sources/enduro2d/high/bindings/core_binds/engine_binds.cpp new file mode 100644 index 00000000..d27d9954 --- /dev/null +++ b/sources/enduro2d/high/bindings/core_binds/engine_binds.cpp @@ -0,0 +1,24 @@ +/******************************************************************************* +* This file is part of the "Enduro2D" +* For conditions of distribution and use, see copyright notice in LICENSE.md +* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) +******************************************************************************/ + +#include "_core_binds.hpp" + +namespace e2d::bindings::core +{ + void bind_engine(sol::state& l) { + l["e2d"].get_or_create() + ["core"].get_or_create() + .new_usertype("engine", + sol::no_constructor, + + "time", sol::property(&engine::time), + "delta_time", sol::property(&engine::delta_time), + "frame_rate", sol::property(&engine::frame_rate), + "frame_count", sol::property(&engine::frame_count), + "realtime_time", sol::property(&engine::realtime_time) + ); + } +} diff --git a/sources/enduro2d/high/bindings/core_binds.cpp b/sources/enduro2d/high/bindings/core_binds/input_binds.cpp similarity index 65% rename from sources/enduro2d/high/bindings/core_binds.cpp rename to sources/enduro2d/high/bindings/core_binds/input_binds.cpp index baeea5fd..c0e1205f 100644 --- a/sources/enduro2d/high/bindings/core_binds.cpp +++ b/sources/enduro2d/high/bindings/core_binds/input_binds.cpp @@ -1,52 +1,28 @@ /******************************************************************************* - * This file is part of the "Enduro2D" - * For conditions of distribution and use, see copyright notice in LICENSE.md - * Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) - ******************************************************************************/ +* This file is part of the "Enduro2D" +* For conditions of distribution and use, see copyright notice in LICENSE.md +* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) +******************************************************************************/ -#include "bindings.hpp" +#include "_core_binds.hpp" -namespace +namespace e2d::bindings::core { - using namespace e2d; - - void bind_debug(sol::state& l) { - l.new_usertype("debug", - "min_level", sol::property(&debug::min_level, &debug::set_min_level), - "log", [](debug& d, debug::level l, const char* s){ d.log(l, s); }, - "trace", [](debug& d, const char* s){ d.trace(s); }, - "warning", [](debug& d, const char* s){ d.warning(s); }, - "error", [](debug& d, const char* s){ d.error(s); }, - "fatal", [](debug& d, const char* s){ d.fatal(s); } - ); - #define DEBUG_LEVEL_PAIR(x) {#x, debug::level::x}, - l["debug"].get_or_create() - .new_enum("level", { - DEBUG_LEVEL_PAIR(trace) - DEBUG_LEVEL_PAIR(warning) - DEBUG_LEVEL_PAIR(error) - DEBUG_LEVEL_PAIR(fatal) - }); - #undef DEBUG_LEVEL_PAIR - } - - void bind_engine(sol::state& l) { - l.new_usertype("engine", - "time", sol::property(&engine::time), - "delta_time", sol::property(&engine::delta_time), - "frame_rate", sol::property(&engine::frame_rate), - "frame_count", sol::property(&engine::frame_count), - "realtime_time", sol::property(&engine::realtime_time) - ); - } - void bind_input(sol::state& l) { - l.new_usertype("input", + l["e2d"].get_or_create() + ["core"].get_or_create() + .new_usertype("input", + sol::no_constructor, + "mouse", sol::property(&input::mouse), "keyboard", sol::property(&input::keyboard) ); - l.new_usertype("mouse", + l["e2d"].get_or_create() + ["core"].get_or_create() + .new_usertype("mouse", + sol::no_constructor, + "cursor_pos", sol::property(&mouse::cursor_pos), "scroll_delta", sol::property(&mouse::scroll_delta), @@ -63,8 +39,14 @@ namespace "just_released_buttons", sol::property(&mouse::just_released_buttons) ); - l.new_usertype("keyboard", - "input_text", sol::property([](const keyboard& k){ return make_utf8(k.input_text()); }), + l["e2d"].get_or_create() + ["core"].get_or_create() + .new_usertype("keyboard", + sol::no_constructor, + + "input_text", sol::property([](const keyboard& k){ + return make_utf8(k.input_text()); + }), "is_any_key_pressed", sol::property(&keyboard::is_any_key_pressed), "is_any_key_just_pressed", sol::property(&keyboard::is_any_key_just_pressed), @@ -80,7 +62,8 @@ namespace ); #define MOUSE_BUTTON_PAIR(x) {#x, mouse_button::x}, - l.new_enum("mouse_button", { + l["e2d"].get_or_create() + .new_enum("mouse_button", { MOUSE_BUTTON_PAIR(left) MOUSE_BUTTON_PAIR(right) MOUSE_BUTTON_PAIR(middle) @@ -90,7 +73,8 @@ namespace #undef MOUSE_BUTTON_PAIR #define KEYBOARD_KEY_PAIR(x) {#x, keyboard_key::x}, - l.new_enum("keyboard_key", { + l["e2d"].get_or_create() + .new_enum("keyboard_key", { KEYBOARD_KEY_PAIR(_0) KEYBOARD_KEY_PAIR(_1) KEYBOARD_KEY_PAIR(_2) @@ -225,49 +209,4 @@ namespace }); #undef KEYBOARD_KEY_PAIR } - - void bind_window(sol::state& l) { - l.new_usertype("window", - "hide", &window::hide, - "show", &window::show, - "restore", &window::restore, - "minimize", &window::minimize, - - "enabled", sol::property(&window::enabled), - "visible", sol::property(&window::visible), - "focused", sol::property(&window::focused), - "minimized", sol::property(&window::minimized), - - "fullscreen", sol::property( - &window::fullscreen, - &window::toggle_fullscreen), - - "cursor_hidden", sol::property( - &window::is_cursor_hidden, - [](window& w, bool yesno){ - if ( yesno ) { - w.hide_cursor(); - } else { - w.show_cursor(); - } - }), - - "real_size", sol::property([](const window& w){ return w.real_size().cast_to(); }), - "virtual_size", sol::property([](const window& w){ return w.virtual_size().cast_to(); }), - "framebuffer_size", sol::property([](const window& w){ return w.framebuffer_size().cast_to(); }), - - "title", sol::property(&window::title, &window::set_title), - "should_close", sol::property(&window::should_close, &window::set_should_close) - ); - } -} - -namespace e2d::bindings -{ - void bind_core(sol::state& l) { - bind_debug(l); - bind_engine(l); - bind_input(l); - bind_window(l); - } } diff --git a/sources/enduro2d/high/bindings/core_binds/window_binds.cpp b/sources/enduro2d/high/bindings/core_binds/window_binds.cpp new file mode 100644 index 00000000..6d6f8360 --- /dev/null +++ b/sources/enduro2d/high/bindings/core_binds/window_binds.cpp @@ -0,0 +1,62 @@ +/******************************************************************************* +* This file is part of the "Enduro2D" +* For conditions of distribution and use, see copyright notice in LICENSE.md +* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) +******************************************************************************/ + +#include "_core_binds.hpp" + +namespace e2d::bindings::core +{ + void bind_window(sol::state& l) { + l["e2d"].get_or_create() + ["core"].get_or_create() + .new_usertype("window", + sol::no_constructor, + + "hide", &window::hide, + "show", &window::show, + "restore", &window::restore, + "minimize", &window::minimize, + + "enabled", sol::property(&window::enabled), + "visible", sol::property(&window::visible), + "focused", sol::property(&window::focused), + "minimized", sol::property(&window::minimized), + + "fullscreen", sol::property( + &window::fullscreen, + &window::toggle_fullscreen), + + "cursor_hidden", sol::property( + &window::is_cursor_hidden, + [](window& w, bool yesno){ + if ( yesno ) { + w.hide_cursor(); + } else { + w.show_cursor(); + } + }), + + "real_size", sol::property([](const window& w){ + return w.real_size().cast_to(); + }), + + "virtual_size", sol::property([](const window& w){ + return w.virtual_size().cast_to(); + }), + + "framebuffer_size", sol::property([](const window& w){ + return w.framebuffer_size().cast_to(); + }), + + "title", sol::property( + &window::title, + &window::set_title), + + "should_close", sol::property( + &window::should_close, + &window::set_should_close) + ); + } +} diff --git a/sources/enduro2d/high/bindings/high_binds.cpp b/sources/enduro2d/high/bindings/high_binds.cpp deleted file mode 100644 index b10dd7ec..00000000 --- a/sources/enduro2d/high/bindings/high_binds.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * This file is part of the "Enduro2D" - * For conditions of distribution and use, see copyright notice in LICENSE.md - * Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) - ******************************************************************************/ - -#include "bindings.hpp" - -#include -#include -#include - -#include -#include - -#include -#include - -namespace -{ - using namespace e2d; - - void bind_library(sol::state& l) { - l.new_usertype("library"); - } - - void bind_luasol(sol::state& l) { - l.new_usertype("luasol"); - } - - void bind_world(sol::state& l) { - l.new_usertype("world"); - } -} - -namespace -{ - using namespace e2d; - - void bind_node(sol::state& l) { - l.new_usertype("node"); - } - - void bind_gobject(sol::state& l) { - l.new_usertype("gobject"); - } -} - -namespace -{ - using namespace e2d; - - void bind_actor(sol::state& l) { - l.new_usertype("actor"); - } - - void bind_behaviour(sol::state& l) { - l.new_usertype("behaviour"); - } -} - -namespace e2d::bindings -{ - void bind_high(sol::state& l) { - bind_library(l); - bind_luasol(l); - bind_world(l); - - bind_node(l); - bind_gobject(l); - - bind_actor(l); - bind_behaviour(l); - } -} diff --git a/sources/enduro2d/high/bindings/high_binds/_high_binds.hpp b/sources/enduro2d/high/bindings/high_binds/_high_binds.hpp new file mode 100644 index 00000000..bef1fbc0 --- /dev/null +++ b/sources/enduro2d/high/bindings/high_binds/_high_binds.hpp @@ -0,0 +1,55 @@ +/******************************************************************************* +* This file is part of the "Enduro2D" +* For conditions of distribution and use, see copyright notice in LICENSE.md +* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) +******************************************************************************/ + +#pragma once + +#include "../bindings.hpp" + +namespace e2d::bindings::high +{ + void bind_library(sol::state& l); + void bind_luasol(sol::state& l); + void bind_world(sol::state& l); + + void bind_node(sol::state& l); + void bind_gobject(sol::state& l); + + void bind_actor(sol::state& l); + void bind_behaviour(sol::state& l); + void bind_camera(sol::state& l); + void bind_flipbook_player(sol::state& l); + void bind_label(sol::state& l); + void bind_model_renderer(sol::state& l); + void bind_named(sol::state& l); + void bind_renderer(sol::state& l); + void bind_scene(sol::state& l); + void bind_spine_player(sol::state& l); + void bind_sprite_renderer(sol::state& l); +} + +namespace e2d::bindings +{ + inline void bind_high(sol::state& l) { + high::bind_library(l); + high::bind_luasol(l); + high::bind_world(l); + + high::bind_node(l); + high::bind_gobject(l); + + high::bind_actor(l); + high::bind_behaviour(l); + high::bind_camera(l); + high::bind_flipbook_player(l); + high::bind_label(l); + high::bind_model_renderer(l); + high::bind_named(l); + high::bind_renderer(l); + high::bind_scene(l); + high::bind_spine_player(l); + high::bind_sprite_renderer(l); + } +} diff --git a/sources/enduro2d/high/bindings/high_binds/components/actor_binds.cpp b/sources/enduro2d/high/bindings/high_binds/components/actor_binds.cpp new file mode 100644 index 00000000..0914fef3 --- /dev/null +++ b/sources/enduro2d/high/bindings/high_binds/components/actor_binds.cpp @@ -0,0 +1,21 @@ +/******************************************************************************* +* This file is part of the "Enduro2D" +* For conditions of distribution and use, see copyright notice in LICENSE.md +* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) +******************************************************************************/ + +#include "../_high_binds.hpp" + +#include +#include + +namespace e2d::bindings::high +{ + void bind_actor(sol::state& l) { + l["e2d"].get_or_create() + ["components"].get_or_create() + .new_usertype>("actor", + "node", sol::property([](const gcomponent& a){ return a->node(); }) + ); + } +} diff --git a/sources/enduro2d/high/bindings/high_binds/components/behaviour_binds.cpp b/sources/enduro2d/high/bindings/high_binds/components/behaviour_binds.cpp new file mode 100644 index 00000000..3e460c6b --- /dev/null +++ b/sources/enduro2d/high/bindings/high_binds/components/behaviour_binds.cpp @@ -0,0 +1,23 @@ +/******************************************************************************* +* This file is part of the "Enduro2D" +* For conditions of distribution and use, see copyright notice in LICENSE.md +* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) +******************************************************************************/ + +#include "../_high_binds.hpp" + +#include +#include + +namespace e2d::bindings::high +{ + void bind_behaviour(sol::state& l) { + l["e2d"].get_or_create() + ["components"].get_or_create() + .new_usertype>("behaviour", + "meta", sol::property( + [](const gcomponent& b){ return b->meta(); }, + [](gcomponent& b, sol::table v){ b->meta(std::move(v)); }) + ); + } +} diff --git a/sources/enduro2d/high/bindings/high_binds/components/camera_binds.cpp b/sources/enduro2d/high/bindings/high_binds/components/camera_binds.cpp new file mode 100644 index 00000000..a8324096 --- /dev/null +++ b/sources/enduro2d/high/bindings/high_binds/components/camera_binds.cpp @@ -0,0 +1,35 @@ +/******************************************************************************* +* This file is part of the "Enduro2D" +* For conditions of distribution and use, see copyright notice in LICENSE.md +* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) +******************************************************************************/ + +#include "../_high_binds.hpp" + +#include +#include + +namespace e2d::bindings::high +{ + void bind_camera(sol::state& l) { + l["e2d"].get_or_create() + ["components"].get_or_create() + .new_usertype>("camera", + "depth", sol::property( + [](const gcomponent& b){ return b->depth(); }, + [](gcomponent& b, i32 v){ b->depth(v); }), + "viewport", sol::property( + [](const gcomponent& b){ return b->viewport().cast_to(); }, + [](gcomponent& b, const b2f& v){ b->viewport(v.cast_to()); }), + "projection", sol::property( + [](const gcomponent& b){ return b->projection(); }, + [](gcomponent& b, const m4f& v){ b->projection(v); }), + "target", sol::property( + [](const gcomponent& b){ return b->target(); }, + [](gcomponent& b, const render_target_ptr& v){ b->target(v); }), + "background", sol::property( + [](const gcomponent& b){ return b->background(); }, + [](gcomponent& b, const color& v){ b->background(v); }) + ); + } +} diff --git a/sources/enduro2d/high/bindings/high_binds/components/flipbook_player_binds.cpp b/sources/enduro2d/high/bindings/high_binds/components/flipbook_player_binds.cpp new file mode 100644 index 00000000..d3697639 --- /dev/null +++ b/sources/enduro2d/high/bindings/high_binds/components/flipbook_player_binds.cpp @@ -0,0 +1,48 @@ +/******************************************************************************* +* This file is part of the "Enduro2D" +* For conditions of distribution and use, see copyright notice in LICENSE.md +* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) +******************************************************************************/ + +#include "../_high_binds.hpp" + +#include +#include + +namespace e2d::bindings::high +{ + void bind_flipbook_player(sol::state& l) { + l["e2d"].get_or_create() + ["components"].get_or_create() + .new_usertype>("flipbook_player", + "time", sol::property( + [](const gcomponent& b){ return b->time(); }, + [](gcomponent& b, f32 v){ b->time(v); }), + "speed", sol::property( + [](const gcomponent& b){ return b->speed(); }, + [](gcomponent& b, f32 v){ b->speed(v); }), + "looped", sol::property( + [](const gcomponent& b){ return b->looped(); }, + [](gcomponent& b, bool v){ b->looped(v); }), + "stopped", sol::property( + [](const gcomponent& b){ return b->stopped(); }, + [](gcomponent& b, bool v){ b->stopped(v); }), + "playing", sol::property( + [](const gcomponent& b){ return b->playing(); }, + [](gcomponent& b, bool v){ b->playing(v); }), + "sequence", sol::property( + [](const gcomponent& b){ return b->sequence(); }, + [](gcomponent& b, str_hash v){ b->sequence(v); }), + "flipbook", sol::property( + [](const gcomponent& b){ return b->flipbook(); }, + [](gcomponent& b, const flipbook_asset::ptr& v){ b->flipbook(v); }), + + "stop", sol::overload( + [](gcomponent& b, f32 v){ b->stop(v); }, + [](gcomponent& b, str_hash v){ b->stop(v); }), + "play", sol::overload( + [](gcomponent& b, f32 v){ b->play(v); }, + [](gcomponent& b, str_hash v){ b->play(v); }) + ); + } +} diff --git a/sources/enduro2d/high/bindings/high_binds/components/label_binds.cpp b/sources/enduro2d/high/bindings/high_binds/components/label_binds.cpp new file mode 100644 index 00000000..cf1c19d2 --- /dev/null +++ b/sources/enduro2d/high/bindings/high_binds/components/label_binds.cpp @@ -0,0 +1,129 @@ +/******************************************************************************* +* This file is part of the "Enduro2D" +* For conditions of distribution and use, see copyright notice in LICENSE.md +* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) +******************************************************************************/ + +#include "../_high_binds.hpp" + +#include +#include + +namespace e2d::bindings::high +{ + void bind_label(sol::state& l) { + l["e2d"].get_or_create() + ["components"].get_or_create() + .new_usertype>("label", + "text", sol::property( + [](const gcomponent