-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d13c445
commit d36de49
Showing
17 changed files
with
347 additions
and
53 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
Volt/Sandbox/src/Sandbox/Modals/ConvertToWorldEngineModal.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include "sbpch.h" | ||
#include "ConvertToWorldEngineModal.h" | ||
|
||
#include <Volt/Asset/AssetManager.h> | ||
#include <Volt/Scene/Scene.h> | ||
|
||
#include <Volt/Utility/FileSystem.h> | ||
|
||
#include <imgui.h> | ||
|
||
ConvertToWorldEngineModal::ConvertToWorldEngineModal(const std::string& stringId) | ||
: Modal(stringId) | ||
{ | ||
} | ||
|
||
ConvertToWorldEngineModal::~ConvertToWorldEngineModal() | ||
{ | ||
} | ||
|
||
void ConvertToWorldEngineModal::DrawModalContent() | ||
{ | ||
ImGui::Text("Are you sure you want to convert to WorldEngine?"); | ||
|
||
ImGui::SameLine(); | ||
|
||
if (ImGui::Button("Convert")) | ||
{ | ||
m_scene->GetSceneSettingsMutable().useWorldEngine = true; | ||
|
||
const auto& metadata = Volt::AssetManager::GetMetadataFromHandle(m_scene->handle); | ||
if (metadata.IsValid()) | ||
{ | ||
const std::filesystem::path directoryPath = Volt::AssetManager::GetFilesystemPath(metadata.filePath); | ||
const std::filesystem::path layersPath = directoryPath / "Layers"; | ||
|
||
if (std::filesystem::exists(directoryPath) && std::filesystem::exists(layersPath)) | ||
{ | ||
FileSystem::MoveToRecycleBin(layersPath); | ||
} | ||
} | ||
|
||
Volt::AssetManager::SaveAsset(m_scene.GetSharedPtr()); | ||
Close(); | ||
} | ||
|
||
ImGui::SameLine(); | ||
|
||
if (ImGui::Button("Cancel")) | ||
{ | ||
m_scene->GetSceneSettingsMutable().useWorldEngine = false; | ||
Close(); | ||
} | ||
} | ||
|
||
void ConvertToWorldEngineModal::OnClose() | ||
{ | ||
m_scene.Reset(); | ||
} |
24 changes: 24 additions & 0 deletions
24
Volt/Sandbox/src/Sandbox/Modals/ConvertToWorldEngineModal.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include "Sandbox/Modals/Modal.h" | ||
|
||
namespace Volt | ||
{ | ||
class Scene; | ||
} | ||
|
||
class ConvertToWorldEngineModal : public Modal | ||
{ | ||
public: | ||
ConvertToWorldEngineModal(const std::string& stringId); | ||
~ConvertToWorldEngineModal(); | ||
|
||
inline void SetCurrentScene(Weak<Volt::Scene> scene) { m_scene = scene; } | ||
|
||
protected: | ||
void DrawModalContent() override; | ||
void OnClose() override; | ||
|
||
protected: | ||
Weak<Volt::Scene> m_scene; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "sbpch.h" | ||
#include "SceneSettingsPanel.h" | ||
|
||
#include "Sandbox/Modals/ConvertToWorldEngineModal.h" | ||
#include "Sandbox/UISystems/ModalSystem.h" | ||
|
||
#include <Volt/Utility/UIUtility.h> | ||
|
||
SceneSettingsPanel::SceneSettingsPanel(Ref<Volt::Scene>& editorScene) | ||
: EditorWindow("Scene Settings"), m_editorScene(editorScene) | ||
{ | ||
auto& modal = ModalSystem::AddModal<ConvertToWorldEngineModal>("Convert To World Engine##sceneSettings"); | ||
m_convertionModal = modal.GetID(); | ||
} | ||
|
||
void SceneSettingsPanel::UpdateMainContent() | ||
{ | ||
auto& sceneSettings = m_editorScene->GetSceneSettingsMutable(); | ||
|
||
if (UI::BeginProperties("sceneSettings")) | ||
{ | ||
if (UI::Property("Use World Engine", sceneSettings.useWorldEngine)) | ||
{ | ||
ModalSystem::GetModal<ConvertToWorldEngineModal>(m_convertionModal).SetCurrentScene(m_editorScene); | ||
ModalSystem::GetModal<ConvertToWorldEngineModal>(m_convertionModal).Open(); | ||
} | ||
|
||
UI::EndProperties(); | ||
} | ||
} |
Oops, something went wrong.