diff --git a/Source/Examples/Editor/CMakeSources.cmake b/Source/Examples/Editor/CMakeSources.cmake index fa24a7db..ce85aee5 100644 --- a/Source/Examples/Editor/CMakeSources.cmake +++ b/Source/Examples/Editor/CMakeSources.cmake @@ -62,6 +62,7 @@ set (TE_EDITOR_INC_WIDGET "Widget/TeWidgetProfiler.h" "Widget/TeWidgetSettings.h" "Widget/TeWidgetShaders.h" + "Widget/TeWidgetScripts.h" ) set (TE_EDITOR_SRC_WIDGET @@ -79,6 +80,7 @@ set (TE_EDITOR_SRC_WIDGET "Widget/TeWidgetProfiler.cpp" "Widget/TeWidgetSettings.cpp" "Widget/TeWidgetShaders.cpp" + "Widget/TeWidgetScripts.cpp" ) set (TE_EDITOR_INC_MATERIALS_PREVIEW diff --git a/Source/Examples/Editor/TeEditor.cpp b/Source/Examples/Editor/TeEditor.cpp index af4f38ee..07ccd1b1 100644 --- a/Source/Examples/Editor/TeEditor.cpp +++ b/Source/Examples/Editor/TeEditor.cpp @@ -13,6 +13,7 @@ #include "Widget/TeWidgetConsole.h" #include "Widget/TeWidgetViewport.h" #include "Widget/TeWidgetResources.h" +#include "Widget/TeWidgetScripts.h" #include "Widget/TeWidgetTextEditor.h" #include "Widget/TeWidgetMaterials.h" #include "Widget/TeWidgetShaders.h" @@ -106,6 +107,9 @@ namespace te const String Editor::MeshesExtensionsStr = ".obj,.dae,.fbx,.stl,.gltf,.glb"; const String Editor::SoundsExtensionsStr = ".ogg,.flac,.wav"; + Event Editor::OnOpen; + Event Editor::OnSave; + const Vector Editor::ComponentsWhichNeedGuizmo = { TID_CRenderable, TID_CRigidBody, @@ -459,7 +463,7 @@ namespace te _widgets.emplace_back(te_unique_ptr_new()); _settings.WSettings = _widgets.back(); _widgets.emplace_back(te_unique_ptr_new()); _settings.WRenderOptions = _widgets.back(); _widgets.emplace_back(te_unique_ptr_new()); _settings.WConsole = _widgets.back(); - _widgets.emplace_back(te_unique_ptr_new()); _settings.WScript = _widgets.back(); + _widgets.emplace_back(te_unique_ptr_new()); _settings.WScript = _widgets.back(); _widgets.emplace_back(te_unique_ptr_new()); _settings.WShaders = _widgets.back(); _widgets.emplace_back(te_unique_ptr_new()); _settings.WMaterials = _widgets.back(); _widgets.emplace_back(te_unique_ptr_new()); _settings.WResources = _widgets.back(); @@ -636,9 +640,9 @@ namespace te ImGui::DockBuilderDockWindow(CONSOLE_TITLE, dockBottomId); ImGui::DockBuilderDockWindow(RESOURCES_TITLE, dockBottomId); ImGui::DockBuilderDockWindow(VIEWPORT_TITLE, dockMainId); - ImGui::DockBuilderDockWindow(SCRIPT_TITLE, dockMainId); ImGui::DockBuilderDockWindow(SHADERS_TITLE, dockRightBottomId); ImGui::DockBuilderDockWindow(MATERIALS_TITLE, dockRightBottomId); + ImGui::DockBuilderDockWindow(SCRIPTS_TITLE, dockLeftBottomId); ImGui::DockBuilderDockWindow(PROPERTIES_TITLE, dockLeftBottomId); ImGui::DockBuilderFinish(dockMainId); } @@ -913,6 +917,8 @@ namespace te _project = static_resource_cast(multiResourceScene->Entries[0].Res); _project->SetPath(path); + OnOpen(); + return true; } @@ -933,6 +939,8 @@ namespace te _settings.State = EditorState::Saved; + OnSave(); + return true; } diff --git a/Source/Examples/Editor/TeEditor.h b/Source/Examples/Editor/TeEditor.h index b15bc7d0..ddab6d15 100644 --- a/Source/Examples/Editor/TeEditor.h +++ b/Source/Examples/Editor/TeEditor.h @@ -240,6 +240,9 @@ namespace te static const String MeshesExtensionsStr; static const String SoundsExtensionsStr; + static Event OnOpen; + static Event OnSave; + protected: static const Vector ComponentsWhichNeedGuizmo; diff --git a/Source/Examples/Editor/Widget/TeWidget.h b/Source/Examples/Editor/Widget/TeWidget.h index 372c7ca5..2806e16f 100644 --- a/Source/Examples/Editor/Widget/TeWidget.h +++ b/Source/Examples/Editor/Widget/TeWidget.h @@ -18,7 +18,8 @@ #define RESOURCES_TITLE ICON_FA_SUITCASE " Resources" #define TOOLBAR_TITLE "ToolBar" #define VIEWPORT_TITLE ICON_FA_IMAGE " Viewport" -#define SCRIPT_TITLE ICON_FA_SCROLL " Script" +#define EDITOR_TITLE ICON_FA_CODE " Editor" +#define SCRIPTS_TITLE ICON_FA_SCROLL " Scripts" #define MATERIALS_TITLE ICON_FA_PALETTE " Materials" #define PROFILER_TITLE ICON_FA_CHART_LINE " Profiler" #define SETTINGS_TITLE ICON_FA_COGS " Settings" @@ -45,11 +46,12 @@ namespace te ToolBar, Viewport, Resources, - Script, + Editor, Material, Profiler, Settings, Shaders, + Scripts, None }; diff --git a/Source/Examples/Editor/Widget/TeWidgetMenuBar.cpp b/Source/Examples/Editor/Widget/TeWidgetMenuBar.cpp index cf7168fd..a9796dc9 100644 --- a/Source/Examples/Editor/Widget/TeWidgetMenuBar.cpp +++ b/Source/Examples/Editor/Widget/TeWidgetMenuBar.cpp @@ -165,9 +165,9 @@ namespace te widget->SetVisible(!widget->GetVisible()); } - if (ImGui::MenuItem(ICON_FA_SCROLL " " ICON_FA_GRIP_LINES_VERTICAL " Script")) + if (ImGui::MenuItem(ICON_FA_SCROLL " " ICON_FA_GRIP_LINES_VERTICAL " Scripts")) { - Widget* widget = static_cast(gEditor().GetWidget(WidgetType::Script)); + Widget* widget = static_cast(gEditor().GetWidget(WidgetType::Scripts)); if (widget) widget->SetVisible(!widget->GetVisible()); } diff --git a/Source/Examples/Editor/Widget/TeWidgetScripts.cpp b/Source/Examples/Editor/Widget/TeWidgetScripts.cpp new file mode 100644 index 00000000..2b04a68a --- /dev/null +++ b/Source/Examples/Editor/Widget/TeWidgetScripts.cpp @@ -0,0 +1,23 @@ +#include "TeWidgetScripts.h" + +namespace te +{ + WidgetScripts::WidgetScripts() + : Widget(WidgetType::Scripts) + { + _title = SCRIPTS_TITLE; + _flags |= ImGuiWindowFlags_HorizontalScrollbar; + } + + WidgetScripts::~WidgetScripts() + { } + + void WidgetScripts::Initialize() + { } + + void WidgetScripts::Update() + { } + + void WidgetScripts::UpdateBackground() + { } +} diff --git a/Source/Examples/Editor/Widget/TeWidgetScripts.h b/Source/Examples/Editor/Widget/TeWidgetScripts.h new file mode 100644 index 00000000..6960c621 --- /dev/null +++ b/Source/Examples/Editor/Widget/TeWidgetScripts.h @@ -0,0 +1,19 @@ +#pragma once + +#include "TeCorePrerequisites.h" +#include "../TeEditor.h" +#include "TeWidget.h" + +namespace te +{ + class WidgetScripts : public Widget + { + public: + WidgetScripts(); + virtual ~WidgetScripts(); + + virtual void Initialize() override; + virtual void Update() override; + virtual void UpdateBackground() override; + }; +} diff --git a/Source/Examples/Editor/Widget/TeWidgetTextEditor.cpp b/Source/Examples/Editor/Widget/TeWidgetTextEditor.cpp index 8803029d..939d0d3e 100644 --- a/Source/Examples/Editor/Widget/TeWidgetTextEditor.cpp +++ b/Source/Examples/Editor/Widget/TeWidgetTextEditor.cpp @@ -8,24 +8,24 @@ namespace te { - WidgetScriptEditor::WidgetScriptEditor() - : Widget(WidgetType::Script) + WidgetTextEditor::WidgetTextEditor() + : Widget(WidgetType::Editor) , _selections(gEditor().GetSelectionData()) , _editor(nullptr) , _needsSave(false) { - _title = SCRIPT_TITLE; + _title = EDITOR_TITLE; } - WidgetScriptEditor::~WidgetScriptEditor() + WidgetTextEditor::~WidgetTextEditor() { } - void WidgetScriptEditor::Initialize() + void WidgetTextEditor::Initialize() { _editor = te_shared_ptr_new(); } - void WidgetScriptEditor::Update() + void WidgetTextEditor::Update() { const auto& scripts = gScriptManager().GetScripts(); for (const auto& script : scripts) @@ -47,10 +47,10 @@ namespace te } } - void WidgetScriptEditor::UpdateBackground() + void WidgetTextEditor::UpdateBackground() { } - void WidgetScriptEditor::PutFocus() + void WidgetTextEditor::PutFocus() { Widget::PutFocus(); @@ -76,7 +76,7 @@ namespace te } } - void WidgetScriptEditor::Save(bool force) + void WidgetTextEditor::Save(bool force) { if (!_currentScriptName.empty() && (_needsSave || force)) { @@ -93,7 +93,7 @@ namespace te } } - void WidgetScriptEditor::Build() + void WidgetTextEditor::Build() { if (!_currentScriptName.empty()) { @@ -109,7 +109,7 @@ namespace te } } - void WidgetScriptEditor::UpdateEditorContent() + void WidgetTextEditor::UpdateEditorContent() { if (_currentScriptName != "") { @@ -129,14 +129,14 @@ namespace te } } - void WidgetScriptEditor::ShowEditor() + void WidgetTextEditor::ShowEditor() { ImGui::BeginChild("ScriptEditor", ImVec2(ImGui::GetContentRegionAvail().x, ImGui::GetWindowHeight() - 90.0f), false); _editor->Render("Title", ImVec2(0.0f, ImGui::GetContentRegionMax().y)); // shrink y to bring the compile button into view ImGui::EndChild(); } - void WidgetScriptEditor::ShowToolbar() + void WidgetTextEditor::ShowToolbar() { auto ShowButton = [this](const char* title, bool enabled, const std::function& action) { diff --git a/Source/Examples/Editor/Widget/TeWidgetTextEditor.h b/Source/Examples/Editor/Widget/TeWidgetTextEditor.h index 485a48e3..231608ab 100644 --- a/Source/Examples/Editor/Widget/TeWidgetTextEditor.h +++ b/Source/Examples/Editor/Widget/TeWidgetTextEditor.h @@ -9,11 +9,11 @@ namespace te class ImGuiTextEditor; - class WidgetScriptEditor : public Widget + class WidgetTextEditor : public Widget { public: - WidgetScriptEditor(); - virtual ~WidgetScriptEditor(); + WidgetTextEditor(); + virtual ~WidgetTextEditor(); virtual void Initialize() override; virtual void Update() override; diff --git a/Source/Examples/Editor/Widget/TeWidgetViewport.h b/Source/Examples/Editor/Widget/TeWidgetViewport.h index c90e1419..70ee00b2 100644 --- a/Source/Examples/Editor/Widget/TeWidgetViewport.h +++ b/Source/Examples/Editor/Widget/TeWidgetViewport.h @@ -45,7 +45,7 @@ namespace te protected: static const float MIN_TIME_BETWEEN_UPDATE; - + protected: HEvent _resizeEvent; Editor::SelectionData& _selections;