get window from application for now

This commit is contained in:
Sri Sham Haran 2022-11-01 00:41:37 +08:00
parent 917009a5cb
commit 67ad65a2d5
3 changed files with 17 additions and 6 deletions

View File

@ -76,7 +76,9 @@ namespace Sandbox
SDL_Init(SDL_INIT_VIDEO); SDL_Init(SDL_INIT_VIDEO);
sdlWindow = SDL_CreateWindowFrom(window.GetHWND()); sdlWindow = SDL_CreateWindowFrom(window.GetHWND());
SHSystemManager::CreateSystem<SHEditor>(); SHSystemManager::CreateSystem<SHEditor>();
SHSystemManager::GetSystem<SHEditor>()->SetSDLWindow(sdlWindow); auto editor = SHSystemManager::GetSystem<SHEditor>();
editor->SetSDLWindow(sdlWindow);
editor->SetSHWindow(&window);
#endif #endif
// Create Routines // Create Routines

View File

@ -138,6 +138,9 @@ namespace SHADE
window->Update(); window->Update();
} }
} }
RenderUnsavedChangesPrompt();
RenderSceneNamePrompt();
//PollPicking(); //PollPicking();
@ -431,7 +434,7 @@ namespace SHADE
void SHEditor::NewScene() void SHEditor::NewScene()
{ {
if(windowMap.GetMainWindow()->IsUnsavedChanges()) if(shWindow->IsUnsavedChanges())
{ {
//Unsaved changes prompt //Unsaved changes prompt
sceneToLoad = 0; sceneToLoad = 0;
@ -440,6 +443,7 @@ namespace SHADE
else else
{ {
SHSceneManager::RestartScene(0); SHSceneManager::RestartScene(0);
shWindow->ToggleUnsavedChanges();
} }
} }
@ -462,13 +466,16 @@ namespace SHADE
//Get data, if data is null, asset doesn't exist, prompt for a name and create a new asset with the name //Get data, if data is null, asset doesn't exist, prompt for a name and create a new asset with the name
//serialize the scene //serialize the scene
SHSerialization::SerializeSceneToFile(SHSceneManager::GetCurrentSceneAssetID()); if(SHSerialization::SerializeSceneToFile(SHSceneManager::GetCurrentSceneAssetID()))
windowMap.GetMainWindow()->ToggleUnsavedChanges(); {
if(shWindow->IsUnsavedChanges())
shWindow->ToggleUnsavedChanges();
}
} }
void SHEditor::LoadScene(AssetID const& assetID) noexcept void SHEditor::LoadScene(AssetID const& assetID) noexcept
{ {
if(windowMap.GetMainWindow()->IsUnsavedChanges()) if(shWindow->IsUnsavedChanges())
{ {
//Unsaved changes prompt //Unsaved changes prompt
isUnsavedChangesPromptOpen = true; isUnsavedChangesPromptOpen = true;

View File

@ -17,7 +17,7 @@
#include "EditorWindow/SHEditorWindow.h" #include "EditorWindow/SHEditorWindow.h"
#include "Tools/SHLogger.h" #include "Tools/SHLogger.h"
#include "Gizmos/SHTransformGizmo.h" #include "Gizmos/SHTransformGizmo.h"
#include "Graphics/Windowing/SHWindow.h"
//#==============================================================# //#==============================================================#
//|| Library Includes || //|| Library Includes ||
@ -172,6 +172,7 @@ namespace SHADE
void InitBackend(); void InitBackend();
void SetSDLWindow(SDL_Window* inSDLWindow){sdlWindow = inSDLWindow;}; void SetSDLWindow(SDL_Window* inSDLWindow){sdlWindow = inSDLWindow;};
void SetSHWindow(SHWindow* inWindow){shWindow = inWindow;}
void PollPicking(); void PollPicking();
@ -221,6 +222,7 @@ namespace SHADE
Handle<SHVkCommandBuffer> imguiCommandBuffer; Handle<SHVkCommandBuffer> imguiCommandBuffer;
SDL_Window* sdlWindow {nullptr}; SDL_Window* sdlWindow {nullptr};
SHWindow* shWindow{nullptr};
ImGuiIO* io{nullptr}; ImGuiIO* io{nullptr};