-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move most editor windows to Mahakam
- Loading branch information
Showing
26 changed files
with
260 additions
and
37 deletions.
There are no files selected for viewing
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
2 changes: 1 addition & 1 deletion
2
Erebor/src/Panels/AssetManagerPanel.cpp → ...akam/Editor/Windows/AssetManagerPanel.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include "ebpch.h" | ||
#include "Mahakam/mhpch.h" | ||
#include "AssetManagerPanel.h" | ||
|
||
namespace Mahakam::Editor | ||
|
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
Erebor/src/Panels/ContentBrowserPanel.cpp → ...am/Editor/Windows/ContentBrowserPanel.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include "ebpch.h" | ||
#include "Mahakam/mhpch.h" | ||
#include "ContentBrowserPanel.h" | ||
|
||
#include "ImportWizardPanel.h" | ||
|
File renamed without changes.
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,201 @@ | ||
#include "Mahakam/mhpch.h" | ||
#include "DockSpace.h" | ||
|
||
#include <imgui/imgui.h> | ||
|
||
namespace Mahakam::Editor | ||
{ | ||
void DockSpace::Begin() | ||
{ | ||
// Render dockspace | ||
ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_None; | ||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking; | ||
|
||
ImGuiViewport* viewport = ImGui::GetMainViewport(); | ||
ImGui::SetNextWindowPos(viewport->WorkPos); | ||
ImGui::SetNextWindowSize(viewport->WorkSize); | ||
ImGui::SetNextWindowViewport(viewport->ID); | ||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); | ||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); | ||
window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove; | ||
window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus; | ||
|
||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); | ||
|
||
ImGui::Begin("DockSpace", nullptr, window_flags); | ||
|
||
ImGui::PopStyleVar(3); | ||
|
||
ImGuiIO& io = ImGui::GetIO(); | ||
ImGuiStyle& style = ImGui::GetStyle(); | ||
float minWidth = style.WindowMinSize.x; | ||
style.WindowMinSize.x = 370.0f; | ||
if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable) | ||
{ | ||
ImGuiID dockspace_id = ImGui::GetID("DockSpace"); | ||
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags); | ||
} | ||
style.WindowMinSize.x = minWidth; | ||
|
||
// File bar | ||
if (ImGui::BeginMenuBar()) | ||
{ | ||
if (ImGui::BeginMenu("Project")) | ||
{ | ||
if (ImGui::MenuItem("\uec5b" " Open Project")) | ||
{ | ||
std::filesystem::path projectPath = FileUtility::OpenDirectory(); | ||
|
||
if (projectPath != "") | ||
{ | ||
Application::GetInstance()->GetWindow().SetTitle("Erebor " + projectPath.string()); | ||
|
||
FileUtility::SetProjectDirectory(projectPath); | ||
} | ||
} | ||
|
||
if (ImGui::MenuItem("\uef1d" " Exit")) | ||
Application::GetInstance()->Close(); | ||
|
||
ImGui::EndMenu(); | ||
} | ||
|
||
if (ImGui::BeginMenu("Scene")) | ||
{ | ||
// Disabling fullscreen would allow the window to be moved to the front of other windows, | ||
// which we can't undo at the moment without finer window depth/z control. | ||
//ImGui::MenuItem("Fullscreen", NULL, &opt_fullscreen_persistant);1 | ||
if (ImGui::MenuItem("\uef10" " New Scene", "Ctrl+N")) | ||
NewScene(); | ||
|
||
if (ImGui::MenuItem("\uec5b" " Open Scene...", "Ctrl+O")) | ||
OpenScene(); | ||
|
||
if (ImGui::MenuItem("\uee00" " Save Scene...", "Ctrl+S")) | ||
SaveScene(); | ||
|
||
if (ImGui::MenuItem("\uee00" " Save Scene As...", "Ctrl+Shift+S")) | ||
SaveSceneAs(); | ||
|
||
ImGui::EndMenu(); | ||
} | ||
|
||
if (ImGui::BeginMenu("View")) | ||
{ | ||
auto& windowProps = EditorWindowRegistry::GetWindowProps(); | ||
for (auto& props : windowProps) | ||
{ | ||
if (props.second.Viewable) | ||
{ | ||
bool enabled = false; | ||
if (props.second.Unique && props.second.Instance) | ||
enabled = true; | ||
|
||
if (ImGui::MenuItem(props.second.Name.c_str(), nullptr, enabled)) | ||
{ | ||
if (!enabled) | ||
EditorWindowRegistry::OpenWindow(props.second.Name); | ||
else if (props.second.Unique) | ||
EditorWindowRegistry::CloseWindow(props.second.Instance); | ||
} | ||
} | ||
} | ||
|
||
ImGui::EndMenu(); | ||
} | ||
|
||
if (ImGui::BeginMenu("Build")) | ||
{ | ||
if (ImGui::MenuItem("Build Assets")) | ||
{ | ||
// TODO: Build binary assets | ||
|
||
|
||
} | ||
|
||
if (ImGui::MenuItem("Build Executable")) | ||
{ | ||
// TODO: Build executable in MH_STANDALONE | ||
} | ||
|
||
ImGui::EndMenu(); | ||
} | ||
|
||
ImGui::EndMenuBar(); | ||
} | ||
} | ||
|
||
void DockSpace::End() | ||
{ | ||
ImGui::End(); | ||
} | ||
|
||
bool DockSpace::OnKeyPressed(KeyPressedEvent& event) | ||
{ | ||
if (event.GetRepeatCount() > 0) return false; | ||
|
||
// Shortcuts | ||
bool controlPressed = Input::IsKeyPressed(Key::LEFT_CONTROL) || Input::IsKeyPressed(Key::RIGHT_CONTROL); | ||
bool shiftPressed = Input::IsKeyPressed(Key::LEFT_SHIFT) || Input::IsKeyPressed(Key::RIGHT_SHIFT); | ||
|
||
switch (event.GetKeyCode()) | ||
{ | ||
case Key::N: | ||
if (controlPressed) | ||
NewScene(); | ||
break; | ||
case Key::O: | ||
if (controlPressed) | ||
OpenScene(); | ||
break; | ||
case Key::S: | ||
if (controlPressed && shiftPressed) | ||
SaveSceneAs(); | ||
else if (controlPressed) | ||
SaveScene(); | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
void DockSpace::NewScene() | ||
{ | ||
Selection::SetSelectedEntity({}); | ||
Ref<Scene> scene = Scene::Create(); | ||
SceneManager::SetActiveScene(scene); | ||
} | ||
|
||
void DockSpace::OpenScene() | ||
{ | ||
std::filesystem::path filepath = FileUtility::OpenFile("Mahakam Scene (*.mhk)\0*.mhk\0", FileUtility::GetWorkingDirectory() / FileUtility::ASSET_PATH); | ||
|
||
if (!filepath.empty()) | ||
{ | ||
Selection::SetSelectedEntity({}); | ||
Ref<Scene> scene = Scene::Create(); | ||
SceneManager::SetActiveScene(scene); | ||
|
||
SceneSerializer serializer(scene); | ||
serializer.DeserializeFromPath(filepath); | ||
} | ||
} | ||
|
||
void DockSpace::SaveScene() | ||
{ | ||
|
||
} | ||
|
||
void DockSpace::SaveSceneAs() | ||
{ | ||
std::filesystem::path filepath = FileUtility::SaveFile("Mahakam Scene (*.mhk)\0*.mhk\0", FileUtility::GetWorkingDirectory() / FileUtility::ASSET_PATH); | ||
|
||
if (!filepath.empty()) | ||
{ | ||
SceneSerializer serializer(SceneManager::GetActiveScene()); | ||
serializer.SerializeToPath(filepath); | ||
} | ||
} | ||
} |
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,21 @@ | ||
#pragma once | ||
|
||
#include <Mahakam/Mahakam.h> | ||
|
||
namespace Mahakam::Editor | ||
{ | ||
class DockSpace | ||
{ | ||
public: | ||
void Begin(); | ||
void End(); | ||
|
||
bool OnKeyPressed(KeyPressedEvent& event); | ||
|
||
private: | ||
void NewScene(); | ||
void OpenScene(); | ||
void SaveScene(); | ||
void SaveSceneAs(); | ||
}; | ||
} |
2 changes: 1 addition & 1 deletion
2
Erebor/src/Panels/EnvironmentPanel.cpp → ...hakam/Editor/Windows/EnvironmentPanel.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include "ebpch.h" | ||
#include "Mahakam/mhpch.h" | ||
#include "EnvironmentPanel.h" | ||
|
||
namespace Mahakam::Editor | ||
|
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
Erebor/src/Panels/ImportWizardPanel.cpp → ...akam/Editor/Windows/ImportWizardPanel.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include "ebpch.h" | ||
#include "Mahakam/mhpch.h" | ||
#include "ImportWizardPanel.h" | ||
|
||
namespace Mahakam::Editor | ||
|
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
Erebor/src/Panels/ProfilerPanel.cpp → .../Mahakam/Editor/Windows/ProfilerPanel.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include "ebpch.h" | ||
#include "Mahakam/mhpch.h" | ||
#include "ProfilerPanel.h" | ||
|
||
namespace Mahakam::Editor | ||
|
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
Erebor/src/Panels/RenderPassPanel.cpp → ...ahakam/Editor/Windows/RenderPassPanel.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include "ebpch.h" | ||
#include "Mahakam/mhpch.h" | ||
#include "RenderPassPanel.h" | ||
|
||
namespace Mahakam::Editor | ||
|
File renamed without changes.
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
File renamed without changes.
Oops, something went wrong.