diff --git a/DeerStudio/imgui.ini b/DeerStudio/imgui.ini index 3bfee56..7d8a2c1 100644 --- a/DeerStudio/imgui.ini +++ b/DeerStudio/imgui.ini @@ -10,31 +10,31 @@ Collapsed=0 [Window][Terrain Editor] Pos=925,24 -Size=355,413 +Size=355,434 Collapsed=0 DockId=0x00000006,0 [Window][Viewport] Pos=309,24 -Size=614,413 +Size=614,434 Collapsed=0 DockId=0x00000005,0 [Window][ViewportPannel] Pos=309,24 -Size=614,413 +Size=614,434 Collapsed=0 DockId=0x00000005,1 [Window][ShaderExplorer] -Pos=0,439 -Size=1280,281 +Pos=0,460 +Size=1280,260 Collapsed=0 DockId=0x00000004,0 [Window][TreePannel] Pos=0,24 -Size=307,413 +Size=307,434 Collapsed=0 DockId=0x00000001,0 @@ -46,7 +46,7 @@ DockId=0x00000004,0 [Window][PropertiesPannel] Pos=925,24 -Size=355,413 +Size=355,434 Collapsed=0 DockId=0x00000006,1 @@ -73,17 +73,17 @@ Collapsed=0 DockId=0x00000005,2 [Window][AssetExplorer] -Pos=0,439 -Size=1280,281 +Pos=0,460 +Size=1280,260 Collapsed=0 DockId=0x00000004,1 [Docking][Data] DockSpace ID=0xA1672E74 Window=0x4647B76E Pos=0,24 Size=1280,696 Split=Y Selected=0x34A4C10F - DockNode ID=0x00000003 Parent=0xA1672E74 SizeRef=1280,413 Split=X + DockNode ID=0x00000003 Parent=0xA1672E74 SizeRef=1280,434 Split=X DockNode ID=0x00000001 Parent=0x00000003 SizeRef=307,696 Selected=0xE45B9F93 DockNode ID=0x00000002 Parent=0x00000003 SizeRef=971,696 Split=X Selected=0x34A4C10F DockNode ID=0x00000005 Parent=0x00000002 SizeRef=614,454 CentralNode=1 Selected=0x34A4C10F DockNode ID=0x00000006 Parent=0x00000002 SizeRef=355,454 Selected=0xA35A27E3 - DockNode ID=0x00000004 Parent=0xA1672E74 SizeRef=1280,281 Selected=0x21191D0B + DockNode ID=0x00000004 Parent=0xA1672E74 SizeRef=1280,260 Selected=0x21191D0B diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API/Layout.h b/DeerStudio/src/DeerStudio/EditorEngine/API/Layout.h index 01c7305..1db6454 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/API/Layout.h +++ b/DeerStudio/src/DeerStudio/EditorEngine/API/Layout.h @@ -5,26 +5,31 @@ class asIScriptFunction; class CScriptAny; namespace Deer { - namespace EditorEngine { - // Set up the colums to fit the pixelSize elements - void setupAutomaticColumns(int pixelSize); - // Set up the colums to the number - void setupColumns(int); - // Iterates to the next column - void nextColumn(); - // Ends the columns made with setupColumns - void endColumns(); + namespace EditorEngine { + // Set up the colums to fit the pixelSize elements + void setupAutomaticColumns(int pixelSize); + // Set up the colums to the number + void setupColumns(int); + // Iterates to the next column + void nextColumn(); + // Ends the columns made with setupColumns + void endColumns(); - // Renders a component node - bool componentNode(std::string&, CScriptAny*, asIScriptFunction*); - // Renders a component node with option to menu - bool componentNode_contextMenu(std::string&, CScriptAny*, asIScriptFunction*, asIScriptFunction*); - // Renders a tree leaf - void treeNode(std::string&, bool); - // Renders a tree node with its sub nodes - bool treeNodeRecursive(std::string&, bool, CScriptAny*, asIScriptFunction&); + // Renders a component node + bool componentNode(std::string&, CScriptAny*, asIScriptFunction*); + // Renders a component node with option to menu + bool componentNode_contextMenu(std::string&, CScriptAny*, + asIScriptFunction*, asIScriptFunction*); + // Renders a tree leaf + void treeNode(std::string&, bool); + // Renders a tree node with its sub nodes + bool treeNodeRecursive(std::string&, bool, CScriptAny*, + asIScriptFunction&); - void space(); - void space_params(int, int); - } -} \ No newline at end of file + // Call, x, y, border + void childWindow(CScriptAny*, asIScriptFunction*, int, int, bool); + + void space(); + void space_params(int, int); + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Layout.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Layout.cpp index 87a1849..bbb3957 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Layout.cpp +++ b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Layout.cpp @@ -1,196 +1,193 @@ #include "DeerStudio/EditorEngine/API/Layout.h" -#include "DeerStudio/EditorEngine/ErrorHandle.h" #include "DeerStudio/EditorEngine.h" +#include "DeerStudio/EditorEngine/ErrorHandle.h" #include "angelscript.h" -#include "scriptany.h" #include "imgui.h" +#include "scriptany.h" namespace Deer { - namespace EditorEngine { - void treeNode(std::string& txt, bool active) { - ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_Leaf | + namespace EditorEngine { + void treeNode(std::string& txt, bool active) { + ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_SpanFullWidth; - if (active) - flags |= ImGuiTreeNodeFlags_Selected; + if (active) + flags |= ImGuiTreeNodeFlags_Selected; - ImGui::TreeNodeEx(txt.c_str(), flags); - } + ImGui::TreeNodeEx(txt.c_str(), flags); + } - bool treeNodeRecursive(std::string& txt, bool active, CScriptAny *data, asIScriptFunction& func) { - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); - ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_OpenOnDoubleClick | - ImGuiTreeNodeFlags_OpenOnArrow | - ImGuiTreeNodeFlags_SpanFullWidth | - ImGuiTreeNodeFlags_DefaultOpen; + bool treeNodeRecursive(std::string& txt, bool active, CScriptAny* data, + asIScriptFunction& func) { + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); + ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_OpenOnDoubleClick | + ImGuiTreeNodeFlags_OpenOnArrow | + ImGuiTreeNodeFlags_SpanFullWidth | + ImGuiTreeNodeFlags_DefaultOpen; - if (active) - flags |= ImGuiTreeNodeFlags_Selected; + if (active) + flags |= ImGuiTreeNodeFlags_Selected; - if (ImGui::TreeNodeEx(txt.c_str(), flags)) { - ImGui::PushID(txt.c_str()); - if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) { - AS_CHECK_ADDITIONAL_INFO( - executingScriptContext->Prepare(&func), - func.GetDeclaration() - ); + if (ImGui::TreeNodeEx(txt.c_str(), flags)) { + ImGui::PushID(txt.c_str()); + if (executingScriptContext && + executingScriptContext->PushState() == asSUCCESS) { + AS_CHECK_ADDITIONAL_INFO( + executingScriptContext->Prepare(&func), + func.GetDeclaration()); - AS_CHECK_ADDITIONAL_INFO( - executingScriptContext->SetArgObject(0, data), - func.GetDeclaration() - ); - - AS_CHECK_ADDITIONAL_INFO( - executingScriptContext->Execute(), - func.GetDeclaration() - ); - - executingScriptContext->PopState(); - } else { - ImGui::Text("Something failed"); - } + AS_CHECK_ADDITIONAL_INFO( + executingScriptContext->SetArgObject(0, data), + func.GetDeclaration()); - ImGui::PopID(); - ImGui::TreePop(); + AS_CHECK_ADDITIONAL_INFO(executingScriptContext->Execute(), + func.GetDeclaration()); + executingScriptContext->PopState(); + } else { + ImGui::Text("Something failed"); + } - ImGui::PopStyleVar(); - return true; - } + ImGui::PopID(); + ImGui::TreePop(); - ImGui::PopStyleVar(); - return false; - } + ImGui::PopStyleVar(); + return true; + } - bool componentNode(std::string& txt, CScriptAny* data, asIScriptFunction* func) { - - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 4)); - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); + ImGui::PopStyleVar(); + return false; + } - ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_SpanAvailWidth | - ImGuiTreeNodeFlags_Framed | - ImGuiTreeNodeFlags_AllowItemOverlap | - ImGuiTreeNodeFlags_FramePadding | - ImGuiTreeNodeFlags_DefaultOpen; + bool componentNode(std::string& txt, CScriptAny* data, + asIScriptFunction* func) { - if (ImGui::TreeNodeEx(txt.c_str(), flags)){ - ImGui::Dummy(ImVec2(0, 10)); - ImGui::PushID(txt.c_str()); - if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) { + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 4)); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); - AS_CHECK( executingScriptContext->Prepare(func)); + ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_SpanAvailWidth | + ImGuiTreeNodeFlags_Framed | + ImGuiTreeNodeFlags_AllowItemOverlap | + ImGuiTreeNodeFlags_FramePadding | + ImGuiTreeNodeFlags_DefaultOpen; - AS_CHECK(executingScriptContext->SetArgObject(0, data)); - - AS_CHECK(executingScriptContext->Execute()); - - executingScriptContext->PopState(); - } else { - ImGui::Text("Something failed"); - } + if (ImGui::TreeNodeEx(txt.c_str(), flags)) { + ImGui::Dummy(ImVec2(0, 10)); + ImGui::PushID(txt.c_str()); + if (executingScriptContext && + executingScriptContext->PushState() == asSUCCESS) { - ImGui::Dummy(ImVec2(0, 10)); - ImGui::PopID(); - ImGui::TreePop(); + AS_CHECK(executingScriptContext->Prepare(func)); - ImGui::PopStyleVar(2); - return true; - } + AS_CHECK(executingScriptContext->SetArgObject(0, data)); - ImGui::PopStyleVar(2); - return false; - } - - bool componentNode_contextMenu(std::string& txt, CScriptAny* data, asIScriptFunction* func, asIScriptFunction* menu) { - - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 4)); - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); + AS_CHECK(executingScriptContext->Execute()); - ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_SpanAvailWidth | - ImGuiTreeNodeFlags_Framed | - ImGuiTreeNodeFlags_AllowItemOverlap | - ImGuiTreeNodeFlags_FramePadding | - ImGuiTreeNodeFlags_DefaultOpen; + executingScriptContext->PopState(); + } else { + ImGui::Text("Something failed"); + } - if (ImGui::TreeNodeEx(txt.c_str(), flags)){ - ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10)); - if (ImGui::BeginPopupContextItem(txt.c_str())) { - if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) { + ImGui::Dummy(ImVec2(0, 10)); + ImGui::PopID(); + ImGui::TreePop(); - AS_CHECK( executingScriptContext->Prepare(menu)); + ImGui::PopStyleVar(2); + return true; + } - AS_CHECK(executingScriptContext->SetArgObject(0, data)); - - AS_CHECK(executingScriptContext->Execute()); - - executingScriptContext->PopState(); - } else { - ImGui::Text("Something failed"); - } - ImGui::EndPopup(); - } - ImGui::PopStyleVar(); + ImGui::PopStyleVar(2); + return false; + } - ImGui::Dummy(ImVec2(0, 10)); - ImGui::PushID(txt.c_str()); - if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) { + bool componentNode_contextMenu(std::string& txt, CScriptAny* data, + asIScriptFunction* func, + asIScriptFunction* menu) { - AS_CHECK( executingScriptContext->Prepare(func)); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 4)); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); - AS_CHECK(executingScriptContext->SetArgObject(0, data)); - - AS_CHECK(executingScriptContext->Execute()); - - executingScriptContext->PopState(); - } else { - ImGui::Text("Something failed"); - } + ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_SpanAvailWidth | + ImGuiTreeNodeFlags_Framed | + ImGuiTreeNodeFlags_AllowItemOverlap | + ImGuiTreeNodeFlags_FramePadding | + ImGuiTreeNodeFlags_DefaultOpen; - ImGui::Dummy(ImVec2(0, 10)); - ImGui::PopID(); - ImGui::TreePop(); + if (ImGui::TreeNodeEx(txt.c_str(), flags)) { + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, + ImVec2(10, 10)); + if (ImGui::BeginPopupContextItem(txt.c_str())) { + if (executingScriptContext && + executingScriptContext->PushState() == asSUCCESS) { - ImGui::PopStyleVar(2); - return true; - } + AS_CHECK(executingScriptContext->Prepare(menu)); - ImGui::PopStyleVar(2); - return false; - } - - void setupColumns(int i) { - ImGui::Columns(i, nullptr, false); - } - - void setupAutomaticColumns(int pixelSize) { - float width = ImGui::GetWindowContentRegionWidth(); - - if (width < pixelSize) { - ImGui::Columns(); - return; - } - - int cols = (int)(width / (pixelSize)); - float componentWidth = width / (float)cols; - - ImGui::Columns(cols, 0, false); - } - - void endColumns() { - ImGui::Columns(); - } - - void nextColumn() { - ImGui::NextColumn(); - } - - void space() { - ImGui::Dummy(ImVec2(10, 10)); - } + AS_CHECK(executingScriptContext->SetArgObject(0, data)); - void space_params(int x, int y) { - ImGui::Dummy(ImVec2(x, y)); - } - } -} \ No newline at end of file + AS_CHECK(executingScriptContext->Execute()); + + executingScriptContext->PopState(); + } else { + ImGui::Text("Something failed"); + } + ImGui::EndPopup(); + } + ImGui::PopStyleVar(); + + ImGui::Dummy(ImVec2(0, 10)); + ImGui::PushID(txt.c_str()); + if (executingScriptContext && + executingScriptContext->PushState() == asSUCCESS) { + + AS_CHECK(executingScriptContext->Prepare(func)); + + AS_CHECK(executingScriptContext->SetArgObject(0, data)); + + AS_CHECK(executingScriptContext->Execute()); + + executingScriptContext->PopState(); + } else { + ImGui::Text("Something failed"); + } + + ImGui::Dummy(ImVec2(0, 10)); + ImGui::PopID(); + ImGui::TreePop(); + + ImGui::PopStyleVar(2); + return true; + } + + ImGui::PopStyleVar(2); + return false; + } + + void setupColumns(int i) { ImGui::Columns(i, nullptr, false); } + + void setupAutomaticColumns(int pixelSize) { + float width = ImGui::GetWindowContentRegionWidth(); + + if (width < pixelSize) { + ImGui::Columns(); + return; + } + + int cols = (int)(width / (pixelSize)); + float componentWidth = width / (float)cols; + + ImGui::Columns(cols, 0, false); + } + + void childWindow(CScriptAny* data, asIScriptFunction* func, int width, + int height, bool border) {} + + void endColumns() { ImGui::Columns(); } + + void nextColumn() { ImGui::NextColumn(); } + + void space() { ImGui::Dummy(ImVec2(10, 10)); } + + void space_params(int x, int y) { ImGui::Dummy(ImVec2(x, y)); } + } // namespace EditorEngine +} // namespace Deer \ No newline at end of file diff --git a/roe/Editor/Panels/AssetExplorer/IconRender.as b/roe/Editor/Panels/AssetExplorer/IconRender.as index ea87afd..918f3b4 100644 --- a/roe/Editor/Panels/AssetExplorer/IconRender.as +++ b/roe/Editor/Panels/AssetExplorer/IconRender.as @@ -11,6 +11,19 @@ bool drawFolder(string&in name) { return click; } +bool drawIcon(string&in name, string&in iconName) { + bool click = false; + UI::drawIconCentered(iconName, 64); + + if (UI::isItemClicked(0) and UI::isMouseDoubleClicked(0)) { + click = true; + } + + UI::textCenter(name); + UI::nextColumn(); + return click; +} + bool drawFile(string&in name) { bool click = false; UI::drawIconCentered("file", 64); diff --git a/roe/Editor/Panels/AssetExplorer/RootAssets.as b/roe/Editor/Panels/AssetExplorer/RootAssets.as index 0403e47..0fe25fb 100644 --- a/roe/Editor/Panels/AssetExplorer/RootAssets.as +++ b/roe/Editor/Panels/AssetExplorer/RootAssets.as @@ -2,10 +2,10 @@ AssetType renderRootAssets() { AssetType selectedAssetType = AssetType::None; - if (drawFolder("Scripts")) selectedAssetType = AssetType::None; - if (drawFolder("Meshes")) selectedAssetType = AssetType::Mesh; - if (drawFolder("Textures")) selectedAssetType = AssetType::None; - if (drawFolder("Shaders")) selectedAssetType = AssetType::Shader; + if (drawIcon("Scripts", "script")) selectedAssetType = AssetType::None; + if (drawIcon("Meshes", "mesh")) selectedAssetType = AssetType::Mesh; + if (drawIcon("Textures", "texture")) selectedAssetType = AssetType::None; + if (drawIcon("Shaders", "shader")) selectedAssetType = AssetType::Shader; return selectedAssetType; } diff --git a/roe/Editor/icons/mesh.ase b/roe/Editor/icons/mesh.ase new file mode 100644 index 0000000..dd58515 Binary files /dev/null and b/roe/Editor/icons/mesh.ase differ diff --git a/roe/Editor/icons/mesh.png b/roe/Editor/icons/mesh.png new file mode 100644 index 0000000..d8f6c0e Binary files /dev/null and b/roe/Editor/icons/mesh.png differ diff --git a/roe/Editor/icons/script.png b/roe/Editor/icons/script.png new file mode 100644 index 0000000..6e8e47a Binary files /dev/null and b/roe/Editor/icons/script.png differ diff --git a/roe/Editor/icons/shader.png b/roe/Editor/icons/shader.png index 80393c2..97b68de 100755 Binary files a/roe/Editor/icons/shader.png and b/roe/Editor/icons/shader.png differ diff --git a/roe/Editor/icons/texture.png b/roe/Editor/icons/texture.png new file mode 100644 index 0000000..7ccbe36 Binary files /dev/null and b/roe/Editor/icons/texture.png differ