Window now maximized by default
Application now loads working scene if run with editor Added editor config to save: - Window size - Window Maximized - Working Scene - Editor Style
This commit is contained in:
parent
35c8321e98
commit
51c9058ab8
|
@ -67,6 +67,9 @@ namespace Sandbox
|
||||||
SHFileUtilities::SetWorkDirToExecDir();
|
SHFileUtilities::SetWorkDirToExecDir();
|
||||||
WindowData wndData{};
|
WindowData wndData{};
|
||||||
auto& appConfig = SHConfigurationManager::LoadApplicationConfig(&wndData);
|
auto& appConfig = SHConfigurationManager::LoadApplicationConfig(&wndData);
|
||||||
|
#if SHEDITOR
|
||||||
|
auto& editorConfig = SHConfigurationManager::LoadEditorConfig(&wndData);
|
||||||
|
#endif
|
||||||
window.Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow, wndData);
|
window.Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow, wndData);
|
||||||
|
|
||||||
// Create Systems
|
// Create Systems
|
||||||
|
@ -158,8 +161,11 @@ namespace Sandbox
|
||||||
|
|
||||||
SHSystemManager::Init();
|
SHSystemManager::Init();
|
||||||
|
|
||||||
|
#if SHEDITOR
|
||||||
|
SHSceneManager::InitSceneManager<SBMainScene>(editorConfig.workingSceneID);
|
||||||
|
#else
|
||||||
SHSceneManager::InitSceneManager<SBMainScene>(appConfig.startingSceneID);
|
SHSceneManager::InitSceneManager<SBMainScene>(appConfig.startingSceneID);
|
||||||
|
#endif
|
||||||
SHFrameRateController::UpdateFRC();
|
SHFrameRateController::UpdateFRC();
|
||||||
|
|
||||||
// Link up SHDebugDraw
|
// Link up SHDebugDraw
|
||||||
|
|
|
@ -183,7 +183,7 @@ namespace SHADE
|
||||||
//ImGui::InputScalar("Starting Scene", ImGuiDataType_U32, &appConfig.startingSceneID);
|
//ImGui::InputScalar("Starting Scene", ImGuiDataType_U32, &appConfig.startingSceneID);
|
||||||
auto sceneAsset = SHAssetManager::GetData<SHSceneAsset>(appConfig.startingSceneID);
|
auto sceneAsset = SHAssetManager::GetData<SHSceneAsset>(appConfig.startingSceneID);
|
||||||
|
|
||||||
if(ImGui::BeginCombo("Starting Scne", sceneAsset ? sceneAsset->name.data() : ""))
|
if(ImGui::BeginCombo("Starting Scene", sceneAsset ? sceneAsset->name.data() : ""))
|
||||||
{
|
{
|
||||||
auto scenes = SHAssetManager::GetAllRecordOfType(AssetType::SCENE);
|
auto scenes = SHAssetManager::GetAllRecordOfType(AssetType::SCENE);
|
||||||
for(auto const& scene : scenes)
|
for(auto const& scene : scenes)
|
||||||
|
|
|
@ -94,6 +94,8 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
editorConfig = &SHConfigurationManager::LoadEditorConfig();
|
||||||
|
|
||||||
//Add editor windows
|
//Add editor windows
|
||||||
SHEditorWindowManager::CreateEditorWindow<SHEditorMenuBar>();
|
SHEditorWindowManager::CreateEditorWindow<SHEditorMenuBar>();
|
||||||
SHEditorWindowManager::CreateEditorWindow<SHHierarchyPanel>();
|
SHEditorWindowManager::CreateEditorWindow<SHHierarchyPanel>();
|
||||||
|
@ -122,7 +124,7 @@ namespace SHADE
|
||||||
|
|
||||||
InitBackend();
|
InitBackend();
|
||||||
|
|
||||||
SetStyle(Style::SHADE);
|
SetStyle(static_cast<Style>(editorConfig->style));
|
||||||
|
|
||||||
|
|
||||||
for (const auto& window : SHEditorWindowManager::editorWindows | std::views::values)
|
for (const auto& window : SHEditorWindowManager::editorWindows | std::views::values)
|
||||||
|
@ -376,10 +378,14 @@ namespace SHADE
|
||||||
ImGui_ImplVulkan_Shutdown();
|
ImGui_ImplVulkan_Shutdown();
|
||||||
ImGui_ImplSDL2_Shutdown();
|
ImGui_ImplSDL2_Shutdown();
|
||||||
ImGui::DestroyContext();
|
ImGui::DestroyContext();
|
||||||
|
|
||||||
|
editorConfig->startMaximized = shWindow->GetWindowData().isMaximised;
|
||||||
|
SHConfigurationManager::SaveEditorConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHEditor::SetStyle(Style style)
|
void SHEditor::SetStyle(Style style)
|
||||||
{
|
{
|
||||||
|
editorConfig->style = static_cast<uint32_t>(style);
|
||||||
switch (style)
|
switch (style)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
|
@ -586,6 +592,7 @@ namespace SHADE
|
||||||
|
|
||||||
SHSceneManager::SetCurrentSceneName(newSceneName);
|
SHSceneManager::SetCurrentSceneName(newSceneName);
|
||||||
SHSceneManager::SetCurrentSceneAssetID(SHAssetManager::CreateNewAsset(AssetType::SCENE, newSceneName));
|
SHSceneManager::SetCurrentSceneAssetID(SHAssetManager::CreateNewAsset(AssetType::SCENE, newSceneName));
|
||||||
|
editorConfig->workingSceneID = SHSceneManager::GetCurrentSceneAssetID();
|
||||||
}
|
}
|
||||||
//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
|
||||||
|
|
||||||
|
@ -594,7 +601,7 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
if(shWindow->IsUnsavedChanges())
|
if(shWindow->IsUnsavedChanges())
|
||||||
shWindow->ToggleUnsavedChanges();
|
shWindow->ToggleUnsavedChanges();
|
||||||
|
editorConfig->workingSceneID = SHSceneManager::GetCurrentSceneAssetID();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -675,6 +682,18 @@ namespace SHADE
|
||||||
ImGuizmo::BeginFrame();
|
ImGuizmo::BeginFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SHEditor::SetSHWindow(SHWindow* inWindow)
|
||||||
|
{
|
||||||
|
shWindow = inWindow;
|
||||||
|
shWindow->RegisterWindowSizeCallback([&](uint32_t width, uint32_t height)
|
||||||
|
{
|
||||||
|
if(width > 0 && height > 0)
|
||||||
|
{
|
||||||
|
auto [width, height] = shWindow->GetWindowSize();
|
||||||
|
editorConfig->windowSize = { static_cast<float>(width), static_cast<float>(height) };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void SHEditor::EditorRoutine::Execute(double dt) noexcept
|
void SHEditor::EditorRoutine::Execute(double dt) noexcept
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "Events/SHEventDefines.h"
|
#include "Events/SHEventDefines.h"
|
||||||
#include "Events/SHEvent.h"
|
#include "Events/SHEvent.h"
|
||||||
#include "Graphics/Windowing/SHWindow.h"
|
#include "Graphics/Windowing/SHWindow.h"
|
||||||
|
#include "Serialization/Configurations/SHConfigurationManager.h"
|
||||||
|
|
||||||
//#==============================================================#
|
//#==============================================================#
|
||||||
//|| Library Includes ||
|
//|| Library Includes ||
|
||||||
|
@ -108,7 +109,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 SetSHWindow(SHWindow* inWindow);
|
||||||
|
|
||||||
void PollPicking();
|
void PollPicking();
|
||||||
|
|
||||||
|
@ -127,6 +128,8 @@ namespace SHADE
|
||||||
|
|
||||||
State editorState = State::STOP;
|
State editorState = State::STOP;
|
||||||
|
|
||||||
|
SHEditorConfig* editorConfig;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief Start new frame for editor
|
* @brief Start new frame for editor
|
||||||
|
|
|
@ -160,7 +160,7 @@ namespace SHADE
|
||||||
|
|
||||||
template <typename T, std::size_t N>
|
template <typename T, std::size_t N>
|
||||||
static bool DragN(const std::string& label, std::vector<std::string>const& componentLabels,
|
static bool DragN(const std::string& label, std::vector<std::string>const& componentLabels,
|
||||||
std::vector<T*> values, float speed = 0.1f, const char* displayFormat = "", T valueMin = T(), T valueMax = T(),
|
std::vector<T*> values, float speed = 0.1f, const char* displayFormat = "%.3f", T valueMin = T(), T valueMax = T(),
|
||||||
ImGuiSliderFlags flags = 0, bool* isHovered = nullptr)
|
ImGuiSliderFlags flags = 0, bool* isHovered = nullptr)
|
||||||
{
|
{
|
||||||
const ImGuiWindow* const window = ImGui::GetCurrentWindow();
|
const ImGuiWindow* const window = ImGui::GetCurrentWindow();
|
||||||
|
|
|
@ -115,6 +115,11 @@ namespace SHADE
|
||||||
SetFocus(wndHWND);
|
SetFocus(wndHWND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!wndData.isFullscreen && wndData.isMaximised)
|
||||||
|
{
|
||||||
|
Maximize();
|
||||||
|
}
|
||||||
|
|
||||||
if (!wndData.icoPath.empty())
|
if (!wndData.icoPath.empty())
|
||||||
{
|
{
|
||||||
//HICON hIcon = ::LoadIcon(nullptr, MAKEINTRESOURCE(wndData.icoPath.c_str()));
|
//HICON hIcon = ::LoadIcon(nullptr, MAKEINTRESOURCE(wndData.icoPath.c_str()));
|
||||||
|
@ -208,10 +213,12 @@ namespace SHADE
|
||||||
if (!IsZoomed(wndHWND))
|
if (!IsZoomed(wndHWND))
|
||||||
{
|
{
|
||||||
ShowWindow(wndHWND, SW_MAXIMIZE);
|
ShowWindow(wndHWND, SW_MAXIMIZE);
|
||||||
|
wndData.isMaximised = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ShowWindow(wndHWND, SW_RESTORE);
|
ShowWindow(wndHWND, SW_RESTORE);
|
||||||
|
wndData.isMaximised = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,7 +435,9 @@ namespace SHADE
|
||||||
wndData.isMinimised = true;
|
wndData.isMinimised = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
wndData.isMinimised = false;
|
wndData.isMinimised = false;
|
||||||
|
}
|
||||||
|
|
||||||
for (auto const& entry : windowResizeCallbacks)
|
for (auto const& entry : windowResizeCallbacks)
|
||||||
{
|
{
|
||||||
|
|
|
@ -64,6 +64,8 @@ namespace SHADE
|
||||||
|
|
||||||
bool isMinimised = false;
|
bool isMinimised = false;
|
||||||
|
|
||||||
|
bool isMaximised = true;
|
||||||
|
|
||||||
std::wstring title = L"SHADE ENGINE";
|
std::wstring title = L"SHADE ENGINE";
|
||||||
|
|
||||||
std::wstring name = L"SHADEEngineApp";
|
std::wstring name = L"SHADEEngineApp";
|
||||||
|
|
|
@ -52,15 +52,27 @@ namespace SHADE
|
||||||
SHFileIO::WriteStringToFile(editorConfigPath, out.c_str());
|
SHFileIO::WriteStringToFile(editorConfigPath, out.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
SHEditorConfig& SHConfigurationManager::LoadEditorConfig()
|
SHEditorConfig& SHConfigurationManager::LoadEditorConfig(WindowData* windowData)
|
||||||
{
|
{
|
||||||
|
if (!std::filesystem::exists(editorConfigPath))
|
||||||
|
{
|
||||||
|
SaveApplicationConfig();
|
||||||
|
return editorConfig;
|
||||||
|
}
|
||||||
|
|
||||||
auto const node = YAML::Load(SHFileIO::GetStringFromFile(editorConfigPath));
|
auto const node = YAML::Load(SHFileIO::GetStringFromFile(editorConfigPath));
|
||||||
auto properties = rttr::type::get<SHApplicationConfig>().get_properties();
|
auto properties = rttr::type::get<SHEditorConfig>().get_properties();
|
||||||
for(auto const& property : properties)
|
for(auto const& property : properties)
|
||||||
{
|
{
|
||||||
if(node[property.get_name().data()].IsDefined())
|
if(node[property.get_name().data()].IsDefined())
|
||||||
SHSerializationHelper::InitializeProperty(&editorConfig, property, node[property.get_name().data()]);
|
SHSerializationHelper::InitializeProperty(&editorConfig, property, node[property.get_name().data()]);
|
||||||
}
|
}
|
||||||
|
if(windowData)
|
||||||
|
{
|
||||||
|
windowData->isMaximised = editorConfig.startMaximized;
|
||||||
|
windowData->width = static_cast<uint32_t>(editorConfig.windowSize.x);
|
||||||
|
windowData->height = static_cast<uint32_t>(editorConfig.windowSize.y);
|
||||||
|
}
|
||||||
return editorConfig;
|
return editorConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,4 +98,10 @@ RTTR_REGISTRATION
|
||||||
.property("Starting Scene ID", &SHApplicationConfig::startingSceneID)
|
.property("Starting Scene ID", &SHApplicationConfig::startingSceneID)
|
||||||
.property("Window Size", &SHApplicationConfig::windowSize)
|
.property("Window Size", &SHApplicationConfig::windowSize)
|
||||||
.property("Window Title", &SHApplicationConfig::windowTitle);
|
.property("Window Title", &SHApplicationConfig::windowTitle);
|
||||||
|
|
||||||
|
registration::class_<SHEditorConfig>("Editor Config")
|
||||||
|
.property("Start Maximized", &SHEditorConfig::startMaximized)
|
||||||
|
.property("Working Scene ID", &SHEditorConfig::workingSceneID)
|
||||||
|
.property("Window Size", &SHEditorConfig::windowSize)
|
||||||
|
.property("Style", &SHEditorConfig::style);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
|
||||||
struct SHApplicationConfig
|
struct SHApplicationConfig
|
||||||
{
|
{
|
||||||
bool startInFullScreen{ false };
|
bool startInFullScreen{ false };
|
||||||
|
@ -19,7 +18,11 @@ namespace SHADE
|
||||||
|
|
||||||
struct SHEditorConfig
|
struct SHEditorConfig
|
||||||
{
|
{
|
||||||
|
bool startMaximized{true};
|
||||||
|
AssetID workingSceneID{};
|
||||||
|
SHVec2 windowSize {1920, 1080};
|
||||||
|
uint32_t style = 0;
|
||||||
|
RTTR_ENABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
class SH_API SHConfigurationManager
|
class SH_API SHConfigurationManager
|
||||||
|
@ -33,7 +36,7 @@ namespace SHADE
|
||||||
static SHApplicationConfig applicationConfig;
|
static SHApplicationConfig applicationConfig;
|
||||||
#ifdef SHEDITOR
|
#ifdef SHEDITOR
|
||||||
static void SaveEditorConfig();
|
static void SaveEditorConfig();
|
||||||
static SHEditorConfig& LoadEditorConfig();
|
static SHEditorConfig& LoadEditorConfig(WindowData* windowData = nullptr);
|
||||||
static SHEditorConfig editorConfig;
|
static SHEditorConfig editorConfig;
|
||||||
private:
|
private:
|
||||||
static void FetchEditorCameraData();
|
static void FetchEditorCameraData();
|
||||||
|
|
Loading…
Reference in New Issue