From 5a9a75c1f2ffee091900ef50942eaff1f9ed8555 Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Sat, 7 Dec 2019 18:09:53 +0700 Subject: [PATCH] dummy editor module --- headers/enduro2d/high/_all.hpp | 1 + headers/enduro2d/high/_high.hpp | 1 + headers/enduro2d/high/editor.hpp | 18 +++++++++++++ .../bin/library/scripts/emmy/high/editor.lua | 6 +++++ .../high/bindings/high_binds/_high_binds.hpp | 2 ++ .../high/bindings/high_binds/editor_binds.cpp | 18 +++++++++++++ sources/enduro2d/high/editor.cpp | 25 +++++++++++++++++++ sources/enduro2d/high/starter.cpp | 13 ++++------ .../enduro2d/high/systems/script_system.cpp | 2 ++ 9 files changed, 78 insertions(+), 8 deletions(-) create mode 100644 headers/enduro2d/high/editor.hpp create mode 100644 samples/bin/library/scripts/emmy/high/editor.lua create mode 100644 sources/enduro2d/high/bindings/high_binds/editor_binds.cpp create mode 100644 sources/enduro2d/high/editor.cpp diff --git a/headers/enduro2d/high/_all.hpp b/headers/enduro2d/high/_all.hpp index 8df00ff4..4036a393 100644 --- a/headers/enduro2d/high/_all.hpp +++ b/headers/enduro2d/high/_all.hpp @@ -53,6 +53,7 @@ #include "asset.hpp" #include "asset.inl" #include "atlas.hpp" +#include "editor.hpp" #include "factory.hpp" #include "factory.inl" #include "flipbook.hpp" diff --git a/headers/enduro2d/high/_high.hpp b/headers/enduro2d/high/_high.hpp index 9dbaadb8..733b5a82 100644 --- a/headers/enduro2d/high/_high.hpp +++ b/headers/enduro2d/high/_high.hpp @@ -86,6 +86,7 @@ namespace e2d class spine; class sprite; + class editor; class luasol; class starter; class world; diff --git a/headers/enduro2d/high/editor.hpp b/headers/enduro2d/high/editor.hpp new file mode 100644 index 00000000..ba4c87f9 --- /dev/null +++ b/headers/enduro2d/high/editor.hpp @@ -0,0 +1,18 @@ +/******************************************************************************* + * 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 "_high.hpp" + +namespace e2d +{ + class editor final : public module { + public: + editor(); + ~editor() noexcept final; + }; +} diff --git a/samples/bin/library/scripts/emmy/high/editor.lua b/samples/bin/library/scripts/emmy/high/editor.lua new file mode 100644 index 00000000..9beba268 --- /dev/null +++ b/samples/bin/library/scripts/emmy/high/editor.lua @@ -0,0 +1,6 @@ +---@class editor +local editor = { +} + +---@type editor +_G.the_editor = _G.the_editor or editor diff --git a/sources/enduro2d/high/bindings/high_binds/_high_binds.hpp b/sources/enduro2d/high/bindings/high_binds/_high_binds.hpp index 572f9c2f..65a9d75a 100644 --- a/sources/enduro2d/high/bindings/high_binds/_high_binds.hpp +++ b/sources/enduro2d/high/bindings/high_binds/_high_binds.hpp @@ -10,6 +10,7 @@ namespace e2d::bindings::high { + void bind_editor(sol::state& l); void bind_library(sol::state& l); void bind_luasol(sol::state& l); void bind_world(sol::state& l); @@ -33,6 +34,7 @@ namespace e2d::bindings::high namespace e2d::bindings { inline void bind_high(sol::state& l) { + high::bind_editor(l); high::bind_library(l); high::bind_luasol(l); high::bind_world(l); diff --git a/sources/enduro2d/high/bindings/high_binds/editor_binds.cpp b/sources/enduro2d/high/bindings/high_binds/editor_binds.cpp new file mode 100644 index 00000000..017bdf07 --- /dev/null +++ b/sources/enduro2d/high/bindings/high_binds/editor_binds.cpp @@ -0,0 +1,18 @@ +/******************************************************************************* + * 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 + +namespace e2d::bindings::high +{ + void bind_editor(sol::state& l) { + l.new_usertype("editor", + sol::no_constructor + ); + } +} diff --git a/sources/enduro2d/high/editor.cpp b/sources/enduro2d/high/editor.cpp new file mode 100644 index 00000000..1b79785b --- /dev/null +++ b/sources/enduro2d/high/editor.cpp @@ -0,0 +1,25 @@ +/******************************************************************************* + * 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 + +#include + +namespace +{ + using namespace e2d; +} + +namespace e2d +{ + editor::editor() { + if ( modules::is_initialized() ) { + the().register_menu_widget("Scene", "Hierarchy"); + } + } + + editor::~editor() noexcept = default; +} diff --git a/sources/enduro2d/high/starter.cpp b/sources/enduro2d/high/starter.cpp index 71a14879..5ca734bc 100644 --- a/sources/enduro2d/high/starter.cpp +++ b/sources/enduro2d/high/starter.cpp @@ -6,10 +6,11 @@ #include -#include -#include +#include #include #include +#include +#include #include #include @@ -32,8 +33,6 @@ #include #include -#include - namespace { using namespace e2d; @@ -201,15 +200,13 @@ namespace e2d params.library_params().root()); safe_module_initialize(); - - if ( modules::is_initialized() ) { - the().register_menu_widget("Scene", "Hierarchy"); - } + safe_module_initialize(); } starter::~starter() noexcept { the().collect_garbage(); + modules::shutdown(); modules::shutdown(); modules::shutdown(); modules::shutdown(); diff --git a/sources/enduro2d/high/systems/script_system.cpp b/sources/enduro2d/high/systems/script_system.cpp index 142f48dd..1184908d 100644 --- a/sources/enduro2d/high/systems/script_system.cpp +++ b/sources/enduro2d/high/systems/script_system.cpp @@ -6,6 +6,7 @@ #include +#include #include #include #include @@ -31,6 +32,7 @@ namespace } void init_high_table(sol::state& s) { + s["the_editor"] = &the(); s["the_library"] = &the(); s["the_luasol"] = &the(); s["the_world"] = &the();