transition scenescave prompt
This commit is contained in:
parent
f726592557
commit
34f22808ee
|
@ -1,10 +1,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "SH_API.h"
|
||||||
#include "Editor/EditorWindow/SHPopUpWindow.h"
|
#include "Editor/EditorWindow/SHPopUpWindow.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
class SHSceneSavePrompt : SHPopUpWindow
|
class SHSceneSavePrompt : public SHPopUpWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SHSceneSavePrompt():SHPopUpWindow("Save Scene As", true, 0, 0){}
|
SHSceneSavePrompt():SHPopUpWindow("Save Scene As", true, 0, 0){}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
//#==============================================================#
|
//#==============================================================#
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
#include "SH_API.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -13,9 +14,11 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SHPopUpWindow(std::string_view const& name, bool modal, ImGuiPopupFlags inPopupFlags, ImGuiWindowFlags inWindowFlags);
|
SHPopUpWindow(std::string_view const& name, bool modal, ImGuiPopupFlags inPopupFlags, ImGuiWindowFlags inWindowFlags);
|
||||||
|
virtual ~SHPopUpWindow() = default;
|
||||||
virtual void Draw(){};
|
virtual void Draw(){};
|
||||||
|
|
||||||
|
bool isOpen;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool Begin();
|
virtual bool Begin();
|
||||||
|
|
||||||
|
@ -23,7 +26,6 @@ namespace SHADE
|
||||||
std::string_view windowName;
|
std::string_view windowName;
|
||||||
ImGuiPopupFlags popupFlags;
|
ImGuiPopupFlags popupFlags;
|
||||||
ImGuiWindowFlags windowFlags;
|
ImGuiWindowFlags windowFlags;
|
||||||
bool isOpen;
|
|
||||||
bool isModal;
|
bool isModal;
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -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 ||
|
||||||
//#==============================================================#
|
//#==============================================================#
|
||||||
|
@ -107,6 +110,9 @@ namespace SHADE
|
||||||
|
|
||||||
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
|
||||||
|
@ -163,7 +169,6 @@ namespace SHADE
|
||||||
popupWindow->Draw();
|
popupWindow->Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderSceneNamePrompt();
|
|
||||||
RenderUnsavedChangesPrompt();
|
RenderUnsavedChangesPrompt();
|
||||||
//PollPicking();
|
//PollPicking();
|
||||||
|
|
||||||
|
@ -182,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)
|
||||||
|
@ -225,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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -568,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
|
||||||
|
@ -649,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()
|
||||||
|
|
|
@ -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...";
|
||||||
|
|
Loading…
Reference in New Issue