Merge remote-tracking branch 'origin/main' into SHPhysics

This commit is contained in:
Diren D Bharwani 2023-01-22 17:39:06 +08:00
commit 826a1bc617
23 changed files with 411 additions and 159 deletions

View File

@ -0,0 +1,15 @@
#pragma once
#include "Camera/SHCameraComponent.h"
#include "Camera/SHCameraArmComponent.h"
#include "Math/Transform/SHTransformComponent.h"
#include "Graphics/MiddleEnd/Interface/SHRenderable.h"
#include "Physics/Interface/SHRigidBodyComponent.h"
#include "UI/SHCanvasComponent.h"
#include "UI/SHButtonComponent.h"
#include "UI/SHUIComponent.h"
#include "UI/SHToggleButtonComponent.h"
#include "UI/SHSliderComponent.h"
#include "Graphics/MiddleEnd/Lights/SHLightComponent.h"
#include "Graphics/MiddleEnd/Interface/SHRenderable.h"
#include "Physics/Interface/SHColliderComponent.h"
#include "Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h"

View File

@ -239,10 +239,7 @@ namespace SHADE
case AssetType::TEXTURE: break; case AssetType::TEXTURE: break;
case AssetType::MESH: break; case AssetType::MESH: break;
case AssetType::SCENE: case AssetType::SCENE:
if(auto editor = SHSystemManager::GetSystem<SHEditor>())
{
editor->LoadScene(asset->id); editor->LoadScene(asset->id);
}
break; break;
case AssetType::PREFAB: break; case AssetType::PREFAB: break;
case AssetType::MATERIAL: case AssetType::MATERIAL:

View File

@ -0,0 +1,33 @@
#include "SHpch.h"
#include "SHEditorPopups.h"
#include "Editor/SHEditor.h"
#include "misc/cpp/imgui_stdlib.h"
namespace SHADE
{
void SHSceneSavePrompt::Draw()
{
if(Begin())
{
static std::string newSceneName{};
ImGui::Text("Enter new scene name");
ImGui::InputText("##name", &newSceneName);
ImGui::BeginDisabled(newSceneName.empty());
if (ImGui::Button("Save"))
{
editor->SaveScene(newSceneName);
newSceneName.clear();
isOpen = false;
ImGui::CloseCurrentPopup();
}
ImGui::EndDisabled();
ImGui::SameLine();
if (ImGui::Button("Cancel"))
{
isOpen = false;
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
}
}

View File

@ -0,0 +1,17 @@
#pragma once
#include "SH_API.h"
#include "Editor/EditorWindow/SHPopUpWindow.h"
namespace SHADE
{
class SHSceneSavePrompt : public SHPopUpWindow
{
public:
SHSceneSavePrompt():SHPopUpWindow("Save Scene As", true, 0, 0){}
void Draw() override;
private:
};
}

View File

@ -3,6 +3,11 @@
//#==============================================================# //#==============================================================#
#include "SHpch.h" #include "SHpch.h"
//#==============================================================#
//|| Library Includes ||
//#==============================================================#
#include <imgui.h>
//#==============================================================# //#==============================================================#
//|| SHADE Includes || //|| SHADE Includes ||
//#==============================================================# //#==============================================================#
@ -16,14 +21,11 @@
#include "Tools/SHException.h" #include "Tools/SHException.h"
#include "Editor/IconsMaterialDesign.h" #include "Editor/IconsMaterialDesign.h"
#include "SHHierarchyPanelCommands.h" #include "SHHierarchyPanelCommands.h"
#include "Common/SHAllComponents.h"
//#==============================================================#
//|| Library Includes ||
//#==============================================================#
#include <imgui.h>
#include "Serialization/SHSerialization.h" #include "Serialization/SHSerialization.h"
#include "Tools/Utilities/SHClipboardUtilities.h" #include "Tools/Utilities/SHClipboardUtilities.h"
#include "Tools/Utilities/SHStringUtilities.h"
namespace SHADE namespace SHADE
@ -80,7 +82,6 @@ namespace SHADE
if (ImGui::IsWindowHovered() && !SHDragDrop::hasDragDrop && !ImGui::IsAnyItemHovered() && ImGui::IsMouseReleased(ImGuiMouseButton_Left)) if (ImGui::IsWindowHovered() && !SHDragDrop::hasDragDrop && !ImGui::IsAnyItemHovered() && ImGui::IsMouseReleased(ImGuiMouseButton_Left))
{ {
if (auto editor = SHSystemManager::GetSystem<SHEditor>())
editor->selectedEntities.clear(); editor->selectedEntities.clear();
} }
ImGui::SeparatorEx(ImGuiSeparatorFlags_Horizontal); ImGui::SeparatorEx(ImGuiSeparatorFlags_Horizontal);
@ -99,7 +100,6 @@ namespace SHADE
} }
if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyReleased(ImGuiKey_V)) if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyReleased(ImGuiKey_V))
{ {
const auto editor = SHSystemManager::GetSystem<SHEditor>();
if (editor->selectedEntities.size() == 1) if (editor->selectedEntities.size() == 1)
{ {
PasteEntities(editor->selectedEntities.back()); PasteEntities(editor->selectedEntities.back());
@ -141,16 +141,18 @@ namespace SHADE
//#==============================================================# //#==============================================================#
//|| Private Member Functions || //|| Private Member Functions ||
//#==============================================================# //#==============================================================#
void SHHierarchyPanel::DrawMenuBar() const noexcept void SHHierarchyPanel::DrawMenuBar() noexcept
{ {
if (ImGui::BeginMenuBar()) if (ImGui::BeginMenuBar())
{ {
auto size = ImGui::GetWindowSize(); auto size = ImGui::GetWindowSize();
auto g = ImGui::GetCurrentContext(); auto g = ImGui::GetCurrentContext();
DrawHierarchyPanelFilter();
ImGui::SetCursorPosX(size.x - g->Style.FramePadding.x * 15.0f); ImGui::SetCursorPosX(size.x - g->Style.FramePadding.x * 15.0f);
if (ImGui::SmallButton(ICON_MD_CLEAR_ALL)) if (ImGui::SmallButton(ICON_MD_CLEAR_ALL))
{ {
auto editor = SHSystemManager::GetSystem<SHEditor>();
editor->selectedEntities.clear(); editor->selectedEntities.clear();
} }
if (ImGui::IsItemHovered()) if (ImGui::IsItemHovered())
@ -173,6 +175,56 @@ namespace SHADE
} }
} }
void SHHierarchyPanel::DrawHierarchyPanelFilter() noexcept
{
if(ImGui::InputTextWithHint("##hierarchyPanelFilter", "Filter", &filter))
{
}
ImGui::SameLine();
if(ImGui::Button("x"))
{
filter.clear();
}
}
bool SHHierarchyPanel::EntityFilterCheck(SHSceneNode* entityNode) noexcept
{
if(!entityNode || filter.empty())
return false;
EntityID const eid = entityNode->GetEntityID();
SHEntity* entity = SHEntityManager::GetEntityByID(eid);
bool result = false;
result |= SHStringUtilities::StringFindInsensitive(entity->name, filter) != std::string::npos;
if(SHStringUtilities::StringFindInsensitive(rttr::type::get<SHTransformComponent>().get_name().data(), filter) != std::string::npos)
{
result |= SHComponentManager::HasComponent<SHTransformComponent>(eid);
}
//result |= SHStringUtilities::StringFindInsensitive(rttr::type::get<SHColliderComponent>().get_name().data(), filter) != std::string::npos;
//result |= SHStringUtilities::StringFindInsensitive(rttr::type::get<SHRigidBodyComponent>().get_name().data(), filter) != std::string::npos;
//result |= SHStringUtilities::StringFindInsensitive(rttr::type::get<SHCameraComponent>().get_name().data(), filter) != std::string::npos;
//result |= SHStringUtilities::StringFindInsensitive(rttr::type::get<SHCameraArmComponent>().get_name().data(), filter) != std::string::npos;
//result |= SHStringUtilities::StringFindInsensitive(rttr::type::get<SHRenderable>().get_name().data(), filter) != std::string::npos;
//result |= SHStringUtilities::StringFindInsensitive(rttr::type::get<SHLightComponent>().get_name().data(), filter) != std::string::npos;
//result |= SHStringUtilities::StringFindInsensitive(rttr::type::get<SHTextRenderableComponent>().get_name().data(), filter) != std::string::npos;
//result |= SHStringUtilities::StringFindInsensitive(rttr::type::get<SHUIComponent>().get_name().data(), filter) != std::string::npos;
//result |= SHStringUtilities::StringFindInsensitive(rttr::type::get<SHButtonComponent>().get_name().data(), filter) != std::string::npos;
//result |= SHStringUtilities::StringFindInsensitive(rttr::type::get<SHCanvasComponent>().get_name().data(), filter) != std::string::npos;
//std::vector<SHSceneNode*> const& children = entityNode->GetChildren();
//for (auto const& child : children)
//{
// result |= EntityFilterCheck(child);
//}
return result;
}
ImRect SHHierarchyPanel::RecursivelyDrawEntityNode(SHSceneNode* const currentNode) ImRect SHHierarchyPanel::RecursivelyDrawEntityNode(SHSceneNode* const currentNode)
{ {
if (currentNode == nullptr) if (currentNode == nullptr)
@ -189,21 +241,39 @@ namespace SHADE
scrollTo = MAX_EID; scrollTo = MAX_EID;
} }
auto editor = SHSystemManager::GetSystem<SHEditor>(); auto* entity = SHEntityManager::GetEntityByID(eid);
const bool isSelected = (std::ranges::find(editor->selectedEntities, eid) != editor->selectedEntities.end()); const bool isSelected = (std::ranges::find(editor->selectedEntities, eid) != editor->selectedEntities.end());
const ImGuiTreeNodeFlags nodeFlags = ((isSelected) ? ImGuiTreeNodeFlags_Selected : 0) | ((children.empty()) ? ImGuiTreeNodeFlags_Leaf : ImGuiTreeNodeFlags_OpenOnArrow); bool highlighted = false;
//if(!filter.empty())
//bool highlighted = false;
//if(highlighted)
//{ //{
// ImGui::PushStyleColor(ImGuiCol_Text, highlightedColor); // highlighted = EntityFilterCheck(currentNode);
// if (highlighted)
// {
// ImGui::PushStyleColor(ImGuiCol_Text, highlightedColor);
//
// ImGui::SetNextItemOpen(true);
//
//
// }
// else
// {
//
// }
//} //}
auto* entity = SHEntityManager::GetEntityByID(currentNode->GetEntityID()); const ImGuiTreeNodeFlags nodeFlags = ((isSelected) ? ImGuiTreeNodeFlags_Selected : 0) | ((children.empty()) ? ImGuiTreeNodeFlags_Leaf : ImGuiTreeNodeFlags_OpenOnArrow);
//Draw Node //Draw Node
bool isNodeOpen = ImGui::TreeNodeEx(reinterpret_cast<void*>(entity), nodeFlags, "%u: %s", SHEntityManager::GetEntityIndex(eid), entity->name.c_str()); bool isNodeOpen = ImGui::TreeNodeEx(reinterpret_cast<void*>(eid), nodeFlags, "%u: %s", SHEntityManager::GetEntityIndex(eid), entity->name.c_str());
if (highlighted)
{
ImGui::PopStyleColor();
}
const ImRect nodeRect = ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax()); const ImRect nodeRect = ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
//Check For Begin Drag //Check For Begin Drag
@ -336,6 +406,7 @@ namespace SHADE
drawList->AddLine(vertLineStart, vertLineEnd, treeLineColor, 2); drawList->AddLine(vertLineStart, vertLineEnd, treeLineColor, 2);
ImGui::TreePop(); ImGui::TreePop();
} }
return nodeRect; return nodeRect;
} }
@ -350,7 +421,6 @@ namespace SHADE
std::vector<EntityID> entitiesToParent = CleanUpEIDList(entities); std::vector<EntityID> entitiesToParent = CleanUpEIDList(entities);
//auto const editor = SHSystemManager::GetSystem<SHEditor>();
SHEntityParentCommand::EntityParentData entityParentData; SHEntityParentCommand::EntityParentData entityParentData;
std::vector<EntityID> parentedEIDS; std::vector<EntityID> parentedEIDS;
for (auto const& eid : entitiesToParent) for (auto const& eid : entitiesToParent)
@ -371,7 +441,7 @@ namespace SHADE
void SHHierarchyPanel::SelectRangeOfEntities(EntityID beginEID, EntityID endEID) void SHHierarchyPanel::SelectRangeOfEntities(EntityID beginEID, EntityID endEID)
{ {
bool startSelecting = false; bool endSelecting = false; bool startSelecting = false; bool endSelecting = false;
auto const editor = SHSystemManager::GetSystem<SHEditor>();
editor->selectedEntities.clear(); editor->selectedEntities.clear();
auto const& sceneGraph = SHSceneManager::GetCurrentSceneGraph(); auto const& sceneGraph = SHSceneManager::GetCurrentSceneGraph();
sceneGraph.Traverse([&](SHSceneNode* nodePtr) sceneGraph.Traverse([&](SHSceneNode* nodePtr)
@ -403,7 +473,6 @@ namespace SHADE
void SHHierarchyPanel::SelectAllEntities() void SHHierarchyPanel::SelectAllEntities()
{ {
const auto editor = SHSystemManager::GetSystem<SHEditor>();
editor->selectedEntities.clear(); editor->selectedEntities.clear();
auto const& sceneGraph = SHSceneManager::GetCurrentSceneGraph(); auto const& sceneGraph = SHSceneManager::GetCurrentSceneGraph();
sceneGraph.Traverse([&](SHSceneNode* nodePtr) sceneGraph.Traverse([&](SHSceneNode* nodePtr)
@ -415,7 +484,6 @@ namespace SHADE
void SHHierarchyPanel::CopySelectedEntities() void SHHierarchyPanel::CopySelectedEntities()
{ {
const auto editor = SHSystemManager::GetSystem<SHEditor>();
std::vector<EntityID> entitiesToCopy = CleanUpEIDList(editor->selectedEntities); std::vector<EntityID> entitiesToCopy = CleanUpEIDList(editor->selectedEntities);
SHClipboardUtilities::WriteToClipboard(SHSerialization::SerializeEntitiesToString(entitiesToCopy)); SHClipboardUtilities::WriteToClipboard(SHSerialization::SerializeEntitiesToString(entitiesToCopy));
} }
@ -428,7 +496,6 @@ namespace SHADE
void SHHierarchyPanel::DeleteSelectedEntities() void SHHierarchyPanel::DeleteSelectedEntities()
{ {
const auto editor = SHSystemManager::GetSystem<SHEditor>();
std::vector<EntityID> entitiesToDelete = CleanUpEIDList(editor->selectedEntities); std::vector<EntityID> entitiesToDelete = CleanUpEIDList(editor->selectedEntities);
SHCommandManager::PerformCommand(std::make_shared<SHDeleteEntitiesCommand>(entitiesToDelete)); SHCommandManager::PerformCommand(std::make_shared<SHDeleteEntitiesCommand>(entitiesToDelete));
} }

View File

@ -10,6 +10,8 @@
#include "imgui_internal.h" #include "imgui_internal.h"
#include "ECS_Base/SHECSMacros.h" #include "ECS_Base/SHECSMacros.h"
#include "Editor/EditorWindow/SHEditorWindow.h" #include "Editor/EditorWindow/SHEditorWindow.h"
#include "ECS_Base/Entity/SHEntity.h"
namespace SHADE namespace SHADE
{ {
class SHSceneNode; class SHSceneNode;
@ -24,7 +26,11 @@ namespace SHADE
void Exit() override; void Exit() override;
void SetScrollTo(EntityID eid); void SetScrollTo(EntityID eid);
private: private:
void DrawMenuBar() const noexcept; void DrawMenuBar() noexcept;
void DrawHierarchyPanelFilter() noexcept;
bool EntityFilterCheck(SHSceneNode* entityNode) noexcept;
ImRect RecursivelyDrawEntityNode(SHSceneNode* const); ImRect RecursivelyDrawEntityNode(SHSceneNode* const);
void CreateChildEntity(EntityID parentEID) const noexcept; void CreateChildEntity(EntityID parentEID) const noexcept;
void ParentSelectedEntities(EntityID parentEID, std::vector<EntityID> const& entities) noexcept; void ParentSelectedEntities(EntityID parentEID, std::vector<EntityID> const& entities) noexcept;

View File

@ -78,7 +78,7 @@ namespace SHADE
ImGui::PushID(SHFamilyID<SHComponent>::GetID<T>()); ImGui::PushID(SHFamilyID<SHComponent>::GetID<T>());
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active"); SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::CollapsingHeader(componentType.get_name().data())) if (ImGui::CollapsingHeader(componentType.get_name().data(), ImGuiTreeNodeFlags_DefaultOpen))
{ {
DrawContextMenu(component); DrawContextMenu(component);
auto const& properties = componentType.get_properties(); auto const& properties = componentType.get_properties();
@ -235,7 +235,7 @@ namespace SHADE
const auto componentType = rttr::type::get<SHRigidBodyComponent>(); const auto componentType = rttr::type::get<SHRigidBodyComponent>();
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active"); SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::CollapsingHeader(componentType.get_name().data())) if (ImGui::CollapsingHeader(componentType.get_name().data(), ImGuiTreeNodeFlags_DefaultOpen))
{ {
DrawContextMenu(component); DrawContextMenu(component);
@ -338,7 +338,7 @@ namespace SHADE
const auto componentType = rttr::type::get(*component); const auto componentType = rttr::type::get(*component);
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active"); SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::CollapsingHeader(componentType.get_name().data())) if (ImGui::CollapsingHeader(componentType.get_name().data(), ImGuiTreeNodeFlags_DefaultOpen))
{ {
DrawContextMenu(component); DrawContextMenu(component);
@ -462,7 +462,7 @@ namespace SHADE
const auto componentType = rttr::type::get(*component); const auto componentType = rttr::type::get(*component);
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active"); SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::CollapsingHeader(componentType.get_name().data())) if (ImGui::CollapsingHeader(componentType.get_name().data(), ImGuiTreeNodeFlags_DefaultOpen))
{ {
DrawContextMenu(component); DrawContextMenu(component);
@ -494,7 +494,7 @@ namespace SHADE
const auto componentType = rttr::type::get(*component); const auto componentType = rttr::type::get(*component);
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active"); SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::CollapsingHeader(componentType.get_name().data())) if (ImGui::CollapsingHeader(componentType.get_name().data(), ImGuiTreeNodeFlags_DefaultOpen))
{ {
DrawContextMenu(component); DrawContextMenu(component);
Handle<SHMesh> const& mesh = component->GetMesh(); Handle<SHMesh> const& mesh = component->GetMesh();
@ -552,7 +552,7 @@ namespace SHADE
const auto componentType = rttr::type::get(*component); const auto componentType = rttr::type::get(*component);
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active"); SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::CollapsingHeader(componentType.get_name().data())) if (ImGui::CollapsingHeader(componentType.get_name().data(), ImGuiTreeNodeFlags_DefaultOpen))
{ {
DrawContextMenu(component); DrawContextMenu(component);
Handle<SHFont> const& font = component->GetFont(); Handle<SHFont> const& font = component->GetFont();

View File

@ -94,7 +94,6 @@ namespace SHADE
SHEditorWindow::Update(); SHEditorWindow::Update();
if (Begin()) if (Begin())
{ {
auto editor = SHSystemManager::GetSystem<SHEditor>();
if (editor && !editor->selectedEntities.empty()) if (editor && !editor->selectedEntities.empty())
{ {
EntityID const& eid = editor->selectedEntities[0]; EntityID const& eid = editor->selectedEntities[0];

View File

@ -112,7 +112,7 @@ namespace SHADE
{ {
ImGui::BeginMenuBar(); ImGui::BeginMenuBar();
ImGui::SetCursorPosX(ImGui::GetContentRegionAvail().x * 0.5f - 80.f); ImGui::SetCursorPosX(ImGui::GetContentRegionAvail().x * 0.5f - 80.f);
const auto editor = SHSystemManager::GetSystem<SHEditor>();
ImGui::BeginDisabled(editor->editorState == SHEditor::State::PLAY); ImGui::BeginDisabled(editor->editorState == SHEditor::State::PLAY);
if(ImGui::SmallButton(ICON_MD_PLAY_ARROW)) if(ImGui::SmallButton(ICON_MD_PLAY_ARROW))
{ {
@ -167,16 +167,18 @@ namespace SHADE
{ {
if (ImGui::Selectable("New Scene")) if (ImGui::Selectable("New Scene"))
{ {
SHSystemManager::GetSystem<SHEditor>()->NewScene(); editor->NewScene();
} }
if (ImGui::Selectable("Save")) if (ImGui::Selectable("Save"))
{ {
SHSystemManager::GetSystem<SHEditor>()->SaveScene(); editor->SaveScene();
} }
ImGui::BeginDisabled(true);
if (ImGui::Selectable("Load")) if (ImGui::Selectable("Load"))
{ {
//SHSystemManager::GetSystem<SHEditor>()->LoadScene() //SHSystemManager::GetSystem<SHEditor>()->LoadScene()
} }
ImGui::EndDisabled();
ImGui::EndMenu(); ImGui::EndMenu();
} }
} }
@ -213,7 +215,7 @@ namespace SHADE
auto* scriptEngine = static_cast<SHScriptEngine*>(SHSystemManager::GetSystem<SHScriptEngine>()); auto* scriptEngine = static_cast<SHScriptEngine*>(SHSystemManager::GetSystem<SHScriptEngine>());
scriptEngine->OpenSolution(); scriptEngine->OpenSolution();
} }
ImGui::BeginDisabled(SHSystemManager::GetSystem<SHEditor>()->editorState != SHEditor::State::STOP); ImGui::BeginDisabled(editor->editorState != SHEditor::State::STOP);
if (ImGui::Selectable("Build Scripts - Debug")) if (ImGui::Selectable("Build Scripts - Debug"))
{ {
auto* scriptEngine = static_cast<SHScriptEngine*>(SHSystemManager::GetSystem<SHScriptEngine>()); auto* scriptEngine = static_cast<SHScriptEngine*>(SHSystemManager::GetSystem<SHScriptEngine>());
@ -254,7 +256,6 @@ namespace SHADE
{ {
if (ImGui::Selectable(style.to_string().c_str())) if (ImGui::Selectable(style.to_string().c_str()))
{ {
if (auto editor = SHSystemManager::GetSystem<SHEditor>())
editor->SetStyle(style.convert<SHEditor::Style>()); editor->SetStyle(style.convert<SHEditor::Style>());
} }
} }

View File

@ -7,6 +7,8 @@
//|| SHADE Includes || //|| SHADE Includes ||
//#==============================================================# //#==============================================================#
#include "SHEditorWindow.h" #include "SHEditorWindow.h"
#include "ECS_Base/Managers/SHSystemManager.h"
#include "Editor/SHEditor.h"
//#==============================================================# //#==============================================================#
//|| Library Includes || //|| Library Includes ||
@ -21,6 +23,7 @@ namespace SHADE
SHEditorWindow::SHEditorWindow(std::string_view const& name, ImGuiWindowFlags const& inFlags) SHEditorWindow::SHEditorWindow(std::string_view const& name, ImGuiWindowFlags const& inFlags)
:isOpen(true), isWindowHovered(false), windowName(name), windowFlags(inFlags), io(ImGui::GetIO()) :isOpen(true), isWindowHovered(false), windowName(name), windowFlags(inFlags), io(ImGui::GetIO())
{ {
editor = SHSystemManager::GetSystem<SHEditor>();
} }
void SHEditorWindow::Init() void SHEditorWindow::Init()

View File

@ -12,9 +12,9 @@
//#==============================================================# //#==============================================================#
struct ImGuiIO; struct ImGuiIO;
typedef int ImGuiWindowFlags; typedef int ImGuiWindowFlags;
namespace SHADE namespace SHADE
{ {
class SHEditor;
class SHEditorWindow class SHEditorWindow
{ {
public: public:
@ -38,6 +38,6 @@ namespace SHADE
ImGuiWindowFlags windowFlags = 0; ImGuiWindowFlags windowFlags = 0;
ImGuiIO& io; ImGuiIO& io;
SHEditor* editor;
};//class SHEditorWindow };//class SHEditorWindow
}//namespace SHADE }//namespace SHADE

View File

@ -4,5 +4,7 @@
namespace SHADE namespace SHADE
{ {
SHEditorWindowManager::EditorWindowMap SHEditorWindowManager::editorWindows{}; SHEditorWindowManager::EditorWindowMap SHEditorWindowManager::editorWindows{};
SHEditorWindowManager::PopupWindowMap SHEditorWindowManager::popupWindows{};
SHEditorWindowManager::EditorWindowID SHEditorWindowManager::windowCount{}; SHEditorWindowManager::EditorWindowID SHEditorWindowManager::windowCount{};
SHEditorWindowManager::EditorWindowID SHEditorWindowManager::popupWindowCount{};
} }

View File

@ -3,6 +3,7 @@
#include <memory> #include <memory>
#include <unordered_map> #include <unordered_map>
#include "SHEditorWindow.h" #include "SHEditorWindow.h"
#include "SHPopUpWindow.h"
#include "Tools/Logger/SHLog.h" #include "Tools/Logger/SHLog.h"
namespace SHADE namespace SHADE
@ -16,6 +17,10 @@ namespace SHADE
using EditorWindowID = uint8_t; using EditorWindowID = uint8_t;
using EditorWindowPtr = std::unique_ptr<SHEditorWindow>; using EditorWindowPtr = std::unique_ptr<SHEditorWindow>;
using EditorWindowMap = std::unordered_map<EditorWindowID, EditorWindowPtr>; using EditorWindowMap = std::unordered_map<EditorWindowID, EditorWindowPtr>;
using PopupWindowPtr = std::unique_ptr<SHPopUpWindow>;
using PopupWindowMap = std::unordered_map<EditorWindowID, PopupWindowPtr>;
/** /**
* @brief Get ID for the Editor Window Type * @brief Get ID for the Editor Window Type
* *
@ -67,10 +72,63 @@ namespace SHADE
return reinterpret_cast<T*>(editorWindows[GetEditorWindowID<T>()].get()); return reinterpret_cast<T*>(editorWindows[GetEditorWindowID<T>()].get());
} }
/**
* @brief Get ID for the Popup Window Type
*
* @tparam T Type of Popup Window
* @return EditorWindowID ID of Popup Window Type
*/
template <typename T, std::enable_if_t<std::is_base_of_v<SHPopUpWindow, T>, bool> = true>
static EditorWindowID GetPopupWindowID()
{
static EditorWindowID id;
static bool idCreated = false;
if (!idCreated)
{
id = popupWindowCount++;
idCreated = true;
}
return id;
}
/**
* @brief Create an Popup Window
*
* @tparam T Type of Popup Window to create
*/
template <typename T, std::enable_if_t<std::is_base_of_v<SHPopUpWindow, T>, bool> = true>
static void CreatePopupWindow()
{
static bool isCreated = false;
if (!isCreated)
{
popupWindows[GetPopupWindowID<T>()] = std::make_unique<T>();
isCreated = true;
}
else
{
SHLog::Warning("Attempt to create duplicate of Popup window type");
}
}
/**
* @brief Get pointer to the Editor Window
*
* @tparam T Type of editor window to retrieve
* @return T* Pointer to the editor window
*/
template <typename T, std::enable_if_t<std::is_base_of_v<SHPopUpWindow, T>, bool> = true>
static T* GetPopupWindow()
{
return reinterpret_cast<T*>(popupWindows[GetPopupWindowID<T>()].get());
}
static EditorWindowMap editorWindows; static EditorWindowMap editorWindows;
static PopupWindowMap popupWindows;
private: private:
// Number of windows; used for Editor Window ID Generation // Number of windows; used for Editor Window ID Generation
static EditorWindowID windowCount; static EditorWindowID windowCount;
static EditorWindowID popupWindowCount;
// Map of Editor Windows // Map of Editor Windows
friend class SHEditor; friend class SHEditor;
}; };

View File

@ -0,0 +1,21 @@
#include "SHpch.h"
#include "SHPopUpWindow.h"
#include "ECS_Base/Managers/SHSystemManager.h"
#include "Editor/SHEditor.h"
namespace SHADE
{
SHPopUpWindow::SHPopUpWindow(std::string_view const& name, bool modal, ImGuiPopupFlags inPopupFlags, ImGuiWindowFlags inWindowFlags)
:editor(nullptr), windowName(name), popupFlags(inPopupFlags), windowFlags(inWindowFlags), isOpen(false), isModal(modal)
{
editor = SHSystemManager::GetSystem<SHEditor>();
}
bool SHPopUpWindow::Begin()
{
if (isOpen)
ImGui::OpenPopup(windowName.data(), popupFlags);
return isModal ? ImGui::BeginPopupModal(windowName.data(), &isOpen, windowFlags) : ImGui::BeginPopup(windowName.data(), windowFlags);
}
}

View File

@ -0,0 +1,31 @@
#pragma once
//#==============================================================#
//|| STL Includes ||
//#==============================================================#
#include <string>
#include <imgui.h>
#include "SH_API.h"
namespace SHADE
{
class SHEditor;
class SHPopUpWindow
{
public:
SHPopUpWindow(std::string_view const& name, bool modal, ImGuiPopupFlags inPopupFlags, ImGuiWindowFlags inWindowFlags);
virtual ~SHPopUpWindow() = default;
virtual void Draw(){};
bool isOpen;
protected:
virtual bool Begin();
SHEditor* editor;
std::string_view windowName;
ImGuiPopupFlags popupFlags;
ImGuiWindowFlags windowFlags;
bool isModal;
};
}

View File

@ -35,7 +35,6 @@ namespace SHADE
{ {
SHEditorWindow::Update(); SHEditorWindow::Update();
auto camSystem = SHSystemManager::GetSystem<SHCameraSystem>(); auto camSystem = SHSystemManager::GetSystem<SHCameraSystem>();
SHEditor* editor = SHSystemManager::GetSystem<SHEditor>();
if (!editor->selectedEntities.empty()) if (!editor->selectedEntities.empty())
{ {

View File

@ -32,6 +32,9 @@
#include "EditorWindow/SHEditorWindowManager.h" #include "EditorWindow/SHEditorWindowManager.h"
#include "EditorWindow/SHEditorWindowIncludes.h" #include "EditorWindow/SHEditorWindowIncludes.h"
#include "EditorWindow/SHPopUpWindow.h"
#include "EditorWindow/EditorPopups/SHEditorPopups.h"
//#==============================================================# //#==============================================================#
//|| Library Includes || //|| Library Includes ||
//#==============================================================# //#==============================================================#
@ -98,15 +101,18 @@ namespace SHADE
//Add editor windows //Add editor windows
SHEditorWindowManager::CreateEditorWindow<SHEditorMenuBar>(); SHEditorWindowManager::CreateEditorWindow<SHEditorMenuBar>();
SHEditorWindowManager::CreateEditorWindow<SHHierarchyPanel>();
SHEditorWindowManager::CreateEditorWindow<SHEditorInspector>();
SHEditorWindowManager::CreateEditorWindow<SHEditorProfiler>(); SHEditorWindowManager::CreateEditorWindow<SHEditorProfiler>();
SHEditorWindowManager::CreateEditorWindow<SHAssetBrowser>(); SHEditorWindowManager::CreateEditorWindow<SHAssetBrowser>();
SHEditorWindowManager::CreateEditorWindow<SHMaterialInspector>(); SHEditorWindowManager::CreateEditorWindow<SHMaterialInspector>();
SHEditorWindowManager::CreateEditorWindow<SHColliderTagPanel>(); SHEditorWindowManager::CreateEditorWindow<SHColliderTagPanel>();
SHEditorWindowManager::CreateEditorWindow<SHHierarchyPanel>();
SHEditorWindowManager::CreateEditorWindow<SHEditorInspector>();
SHEditorWindowManager::CreateEditorWindow<SHEditorViewport>(); SHEditorWindowManager::CreateEditorWindow<SHEditorViewport>();
//Add popup windows
SHEditorWindowManager::CreatePopupWindow<SHSceneSavePrompt>();
io = &ImGui::GetIO(); io = &ImGui::GetIO();
io->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
@ -150,7 +156,7 @@ namespace SHADE
{ {
(void)dt; (void)dt;
NewFrame(); NewFrame();
for (const auto& window : SHEditorWindowManager::editorWindows | std::views::values) for (auto const& window : SHEditorWindowManager::editorWindows | std::views::values)
{ {
if(window->isOpen) if(window->isOpen)
{ {
@ -158,7 +164,11 @@ namespace SHADE
} }
} }
RenderSceneNamePrompt(); for(auto const& popupWindow : SHEditorWindowManager::popupWindows | std::views::values)
{
popupWindow->Draw();
}
RenderUnsavedChangesPrompt(); RenderUnsavedChangesPrompt();
//PollPicking(); //PollPicking();
@ -177,37 +187,6 @@ namespace SHADE
} }
} }
void SHEditor::RenderSceneNamePrompt() noexcept
{
if(isSceneNamePromptOpen)
{
ImGui::OpenPopup(sceneNamePromptName.data());
}
if(ImGui::BeginPopupModal(sceneNamePromptName.data(), &isSceneNamePromptOpen))
{
static std::string newSceneName{};
ImGui::Text("Enter new scene name");
ImGui::InputText("##name", &newSceneName);
ImGui::BeginDisabled(newSceneName.empty());
if(ImGui::Button("Save"))
{
SaveScene(newSceneName);
newSceneName.clear();
isSceneNamePromptOpen = false;
ImGui::CloseCurrentPopup();
}
ImGui::EndDisabled();
ImGui::SameLine();
if(ImGui::Button("Cancel"))
{
isSceneNamePromptOpen = false;
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
}
void SHEditor::RenderUnsavedChangesPrompt() noexcept void SHEditor::RenderUnsavedChangesPrompt() noexcept
{ {
if(isUnsavedChangesPromptOpen) if(isUnsavedChangesPromptOpen)
@ -220,12 +199,12 @@ namespace SHADE
ImGui::Text("You have unsaved changes!"); ImGui::Text("You have unsaved changes!");
if(ImGui::Button("Save")) if(ImGui::Button("Save"))
{ {
isSceneNamePromptOpen = true; SHEditorWindowManager::GetPopupWindow<SHSceneSavePrompt>()->isOpen = true;
} }
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Button("Cancel")) if(ImGui::Button("Cancel"))
{ {
isUnsavedChangesPromptOpen = false; SHEditorWindowManager::GetPopupWindow<SHSceneSavePrompt>()->isOpen = true;
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
} }
@ -563,7 +542,7 @@ namespace SHADE
if (newSceneName.empty()) if (newSceneName.empty())
{ {
//Prompt for scene name //Prompt for scene name
isSceneNamePromptOpen = true; SHEditorWindowManager::GetPopupWindow<SHSceneSavePrompt>()->isOpen = true;
return false; return false;
} }
//Else We have a new name //Else We have a new name
@ -644,7 +623,7 @@ namespace SHADE
editorState = SHEditor::State::STOP; editorState = SHEditor::State::STOP;
SHCommandManager::SwapStacks(); SHCommandManager::SwapStacks();
SHEventManager::BroadcastEvent<SHEditorStateChangeEvent>(STATE_CHANGE_EVENT, SH_EDITOR_ON_STOP_EVENT); SHEventManager::BroadcastEvent<SHEditorStateChangeEvent>(STATE_CHANGE_EVENT, SH_EDITOR_ON_STOP_EVENT);
LoadScene(SHSceneManager::GetCurrentSceneAssetID()); LoadScene(editorConfig->workingSceneID);
} }
void SHEditor::ProcessShortcuts() void SHEditor::ProcessShortcuts()

View File

@ -37,8 +37,6 @@ namespace SHADE
class SHVkCommandBuffer; class SHVkCommandBuffer;
class SHVkCommandPool; class SHVkCommandPool;
/** /**
* @brief SHEditor static class contains editor variables and implementation of editor functions. * @brief SHEditor static class contains editor variables and implementation of editor functions.
* *
@ -144,8 +142,6 @@ namespace SHADE
*/ */
void Render(); void Render();
void RenderSceneNamePrompt() noexcept;
void RenderUnsavedChangesPrompt() noexcept; void RenderUnsavedChangesPrompt() noexcept;
void InitLayout() noexcept; void InitLayout() noexcept;
@ -156,8 +152,6 @@ namespace SHADE
SHEventHandle onEditorStateChanged(SHEventPtr eventPtr); SHEventHandle onEditorStateChanged(SHEventPtr eventPtr);
bool isSceneNamePromptOpen = false;
bool isUnsavedChangesPromptOpen = false; bool isUnsavedChangesPromptOpen = false;
static constexpr std::string_view sceneNamePromptName = "Save scene as..."; static constexpr std::string_view sceneNamePromptName = "Save scene as...";

View File

@ -13,6 +13,8 @@
#include "Command/SHCommandManager.h" #include "Command/SHCommandManager.h"
#include "SHImGuiHelpers.hpp" #include "SHImGuiHelpers.hpp"
#include "SH_API.h" #include "SH_API.h"
#include "Assets/SHAssetMacros.h"
#include "ECS_Base/SHECSMacros.h"
//#==============================================================# //#==============================================================#
//|| Library Includes || //|| Library Includes ||
@ -454,7 +456,33 @@ namespace SHADE
ImGui::BeginGroup(); ImGui::BeginGroup();
ImGui::PushID(label.data()); ImGui::PushID(label.data());
TextLabel(label); TextLabel(label);
const bool hasChange = ImGui::InputScalar("##dragScalar", data_type, &value); bool hasChange = ImGui::DragScalar("##dragScalar", data_type, &value);
if constexpr(std::is_same_v<T, uint32_t>) //EID or Resource
{
if (SHDragDrop::BeginTarget())
{
if(AssetID * payload = SHDragDrop::AcceptPayload<T>(SHDragDrop::DRAG_RESOURCE))
{
value = *payload;
SHCommandManager::PerformCommand(std::reinterpret_pointer_cast<SHBaseCommand>(std::make_shared<SHCommand<T>>(get(), value, set)), false);
hasChange = true;
SHDragDrop::EndTarget();
}
else if (std::vector<EntityID>* payload = SHDragDrop::AcceptPayload<std::vector<EntityID>>(SHDragDrop::DRAG_EID))
{
value = payload->back();
SHCommandManager::PerformCommand(std::reinterpret_pointer_cast<SHBaseCommand>(std::make_shared<SHCommand<T>>(get(), value, set)), false);
hasChange = true;
SHDragDrop::EndTarget();
}
if(hasChange)
{
ImGui::PopID();
ImGui::EndGroup();
return true;
}
}
}
static bool startRecording = false; static bool startRecording = false;
if (hasChange) if (hasChange)
{ {

View File

@ -11,16 +11,8 @@
#include <fstream> #include <fstream>
#include "Assets/Asset Types/SHSceneAsset.h" #include "Assets/Asset Types/SHSceneAsset.h"
#include "Camera/SHCameraComponent.h" #include "Common/SHAllComponents.h"
#include "Camera/SHCameraArmComponent.h"
#include "Math/Transform/SHTransformComponent.h"
#include "Graphics/MiddleEnd/Interface/SHRenderable.h"
#include "Physics/Interface/SHRigidBodyComponent.h"
#include "UI/SHCanvasComponent.h"
#include "UI/SHButtonComponent.h"
#include "UI/SHToggleButtonComponent.h"
#include "ECS_Base/Managers/SHSystemManager.h" #include "ECS_Base/Managers/SHSystemManager.h"
#include "Graphics/MiddleEnd/Lights/SHLightComponent.h"
#include "Scripting/SHScriptEngine.h" #include "Scripting/SHScriptEngine.h"
#include "Tools/FileIO/SHFileIO.h" #include "Tools/FileIO/SHFileIO.h"

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
#include "Graphics/MiddleEnd/Interface/SHRenderable.h" #include "Graphics/MiddleEnd/Interface/SHRenderable.h"
#include "Physics/Interface/SHColliderComponent.h"
#include "Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h"
#include "Graphics/MiddleEnd/Materials/SHMaterialSpec.h" #include "Graphics/MiddleEnd/Materials/SHMaterialSpec.h"
#include "Resource/SHResourceManager.h" #include "Resource/SHResourceManager.h"
#include "Math/Vector/SHVec2.h" #include "Math/Vector/SHVec2.h"
@ -8,8 +10,6 @@
#include "Graphics/MiddleEnd/Interface/SHMaterial.h" #include "Graphics/MiddleEnd/Interface/SHMaterial.h"
#include "Graphics/MiddleEnd/Interface/SHMaterialInstance.h" #include "Graphics/MiddleEnd/Interface/SHMaterialInstance.h"
#include "SHSerializationTools.h" #include "SHSerializationTools.h"
#include "Physics/Interface/SHColliderComponent.h"
#include "Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h"
#include "Graphics/MiddleEnd/TextRendering/SHFont.h" #include "Graphics/MiddleEnd/TextRendering/SHFont.h"
#include "Physics/Collision/SHCompositeCollider.h" #include "Physics/Collision/SHCompositeCollider.h"
#include "Physics/Collision/CollisionTags/SHCollisionTagMatrix.h" #include "Physics/Collision/CollisionTags/SHCollisionTagMatrix.h"

View File

@ -13,6 +13,7 @@ of DigiPen Institute of Technology is prohibited.
#include <SHpch.h> #include <SHpch.h>
// Primary Header // Primary Header
#include "SHStringUtilities.h" #include "SHStringUtilities.h"
#include <algorithm>
namespace SHADE namespace SHADE
{ {
@ -50,5 +51,12 @@ namespace SHADE
{ {
return std::system_category().message(errorCode); return std::system_category().message(errorCode);
} }
size_t SHStringUtilities::StringFindInsensitive(std::string str, std::string search, size_t pos)
{
std::transform(str.begin(), str.end(), str.begin(), [](char c) {return static_cast<char>(std::tolower(c)); });
std::transform(search.begin(), search.end(), search.begin(), [](char c) {return static_cast<char>(std::tolower(c)); });
return str.find(search, pos);
}
} }

View File

@ -4,9 +4,9 @@
\par email: kahwei.tng\@digipen.edu \par email: kahwei.tng\@digipen.edu
\date Nov 29, 2021 \date Nov 29, 2021
\brief Contains the declaration of functions for working with files and folders. \brief Contains the declaration of functions for working with files and folders.
Copyright (C) 2021 DigiPen Institute of Technology. Copyright (C) 2021 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the prior written consent Reproduction or disclosure of this file or its contents without the prior written consent
of DigiPen Institute of Technology is prohibited. of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/ *//*************************************************************************************/
#pragma once #pragma once
@ -16,66 +16,68 @@ of DigiPen Institute of Technology is prohibited.
namespace SHADE namespace SHADE
{ {
/// <summary> /// <summary>
/// Contains useful functions for operating on strings. /// Contains useful functions for operating on strings.
/// </summary> /// </summary>
class SHStringUtilities class SHStringUtilities
{ {
public: public:
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Utility Functions */ /* Utility Functions */
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/// <summary>
/// Splits a string separated by a specified delimiter into a vector of strings.
/// </summary>
/// <typeparam name="T">Internal type of each element in the string.</typeparam>
/// <param name="str">Read only reference to the string to split.</param>
/// <param name="delim">Read only reference to the delimiter.</param>
/// <returns>Vector of strings that have been split.</returns>
template<typename T>
static std::vector<std::basic_string<T>> Split(const std::basic_string<T>& str, const T& delim);
/// <summary>
/// Splits a string separated by a specified delimiter into a vector of strings.
/// Overload of Split<T>() to allow for string literals to be accepted.
/// </summary>
/// <param name="str">Read only reference to the string to split.</param>
/// <param name="delim">Read only reference to the delimiter.</param>
/// <returns>Vector of strings that have been split.</returns>
static std::vector<std::string> Split(const std::string& str, const char& delim);
/// <summary>
/// Splits a string separated by a specified delimiter into a vector of strings.
/// Overload of Split<T>() to allow for wide string literals to be accepted.
/// </summary>
/// <param name="str">Read only reference to the string to split.</param>
/// <param name="delim">Read only reference to the delimiter.</param>
/// <returns>Vector of strings that have been split.</returns>
static std::vector<std::wstring> Split(const std::wstring& str, const wchar_t& delim);
/// <summary>
/// Converts a wstring to a string.
/// </summary>
/// <param name="wstr">wstring to convert.</param>
/// <returns>The converted wstring in string form.</returns>
static std::string WstrToStr(const std::wstring& wstr);
/// <summary>
/// Converts a string to a wstring.
/// </summary>
/// <param name="str">string to convert.</param>
/// <returns>The converted string in wstring form.</returns>
static std::wstring StrToWstr(const std::string& str);
/// <summary>
/// Retrieves the error message associated with a Win32 error code.
/// </summary>
/// <param name="errorCode">Win32 error code to decode.</param>
/// <returns>String that represents the Win32 error.</returns>
static std::string GetWin32ErrorMessage(unsigned long errorCode);
private: /// <summary>
/*-------------------------------------------------------------------------------*/ /// Splits a string separated by a specified delimiter into a vector of strings.
/* Constructors/Destructors */ /// </summary>
/*-------------------------------------------------------------------------------*/ /// <typeparam name="T">Internal type of each element in the string.</typeparam>
SHStringUtilities() = delete; /// <param name="str">Read only reference to the string to split.</param>
}; /// <param name="delim">Read only reference to the delimiter.</param>
/// <returns>Vector of strings that have been split.</returns>
template<typename T>
static std::vector<std::basic_string<T>> Split(const std::basic_string<T>& str, const T& delim);
/// <summary>
/// Splits a string separated by a specified delimiter into a vector of strings.
/// Overload of Split<T>() to allow for string literals to be accepted.
/// </summary>
/// <param name="str">Read only reference to the string to split.</param>
/// <param name="delim">Read only reference to the delimiter.</param>
/// <returns>Vector of strings that have been split.</returns>
static std::vector<std::string> Split(const std::string& str, const char& delim);
/// <summary>
/// Splits a string separated by a specified delimiter into a vector of strings.
/// Overload of Split<T>() to allow for wide string literals to be accepted.
/// </summary>
/// <param name="str">Read only reference to the string to split.</param>
/// <param name="delim">Read only reference to the delimiter.</param>
/// <returns>Vector of strings that have been split.</returns>
static std::vector<std::wstring> Split(const std::wstring& str, const wchar_t& delim);
/// <summary>
/// Converts a wstring to a string.
/// </summary>
/// <param name="wstr">wstring to convert.</param>
/// <returns>The converted wstring in string form.</returns>
static std::string WstrToStr(const std::wstring& wstr);
/// <summary>
/// Converts a string to a wstring.
/// </summary>
/// <param name="str">string to convert.</param>
/// <returns>The converted string in wstring form.</returns>
static std::wstring StrToWstr(const std::string& str);
/// <summary>
/// Retrieves the error message associated with a Win32 error code.
/// </summary>
/// <param name="errorCode">Win32 error code to decode.</param>
/// <returns>String that represents the Win32 error.</returns>
static std::string GetWin32ErrorMessage(unsigned long errorCode);
static size_t StringFindInsensitive(std::string str, std::string search, size_t pos = 0);
private:
/*-------------------------------------------------------------------------------*/
/* Constructors/Destructors */
/*-------------------------------------------------------------------------------*/
SHStringUtilities() = delete;
};
} }
#include "SHStringUtilities.hpp" #include "SHStringUtilities.hpp"