|
|
|
|
@ -12,7 +12,6 @@
|
|
|
|
|
#include <core/core.h>
|
|
|
|
|
#include <core/version.h>
|
|
|
|
|
#include <utils/logger.h>
|
|
|
|
|
#include <gui/file_browser.h>
|
|
|
|
|
#include <internal_data/dataManager.h>
|
|
|
|
|
#include <gui/dearimgui/imgui.h>
|
|
|
|
|
|
|
|
|
|
@ -88,8 +87,12 @@ namespace editor
|
|
|
|
|
void Editor::OnRender(lunarium::IGraphics* g)
|
|
|
|
|
{
|
|
|
|
|
DoMainMenu();
|
|
|
|
|
DoStatusBar();
|
|
|
|
|
mPanelManager.OnRender(g);
|
|
|
|
|
//DoStatusBar();
|
|
|
|
|
RenderWindow();
|
|
|
|
|
|
|
|
|
|
//mPanelManager.OnRender(g);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mpMapEditor)
|
|
|
|
|
{
|
|
|
|
|
@ -101,12 +104,9 @@ namespace editor
|
|
|
|
|
mAboutPanel.DoFrame();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mpFileBrowser)
|
|
|
|
|
if (mFileBrowser.IsOpen())
|
|
|
|
|
{
|
|
|
|
|
if (!mpFileBrowser->DoFrame())
|
|
|
|
|
{
|
|
|
|
|
mpPath = mpFileBrowser->GetSelectedItem();
|
|
|
|
|
}
|
|
|
|
|
mFileBrowser.DoFrame();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -142,6 +142,30 @@ namespace editor
|
|
|
|
|
// HELPER METHODS
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void Editor::RenderWindow()
|
|
|
|
|
{
|
|
|
|
|
ImGuiViewport* Viewport = ImGui::GetWindowViewport();
|
|
|
|
|
ImGui::SetNextWindowPos( Viewport->WorkPos );
|
|
|
|
|
ImGui::SetNextWindowSize( Viewport->WorkSize );
|
|
|
|
|
ImGui::SetNextWindowViewport( Viewport->ID );
|
|
|
|
|
ImGuiWindowFlags WindowFlags = 0;
|
|
|
|
|
WindowFlags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDocking;
|
|
|
|
|
WindowFlags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;
|
|
|
|
|
|
|
|
|
|
ImGui::PushStyleVar( ImGuiStyleVar_WindowRounding, 0.0f );
|
|
|
|
|
ImGui::PushStyleVar( ImGuiStyleVar_WindowBorderSize, 0.0f );
|
|
|
|
|
ImGui::PushStyleVar( ImGuiStyleVar_WindowPadding, ImVec2( 0.0f, 0.0f ) );
|
|
|
|
|
|
|
|
|
|
ImGui::Begin("Lunarium Editor", nullptr, WindowFlags);
|
|
|
|
|
ImGui::PopStyleVar(3);
|
|
|
|
|
|
|
|
|
|
mPanelManager.MakeDockSpaces();
|
|
|
|
|
|
|
|
|
|
ImGui::End();
|
|
|
|
|
|
|
|
|
|
mPanelManager.RenderPanels();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Editor::DestroyTools()
|
|
|
|
|
{
|
|
|
|
|
@ -156,26 +180,21 @@ namespace editor
|
|
|
|
|
// FILE
|
|
|
|
|
if (mDoNewProject)
|
|
|
|
|
{
|
|
|
|
|
if (!mpFileBrowser)
|
|
|
|
|
if (!mFileBrowser.IsOpen())
|
|
|
|
|
{
|
|
|
|
|
mpFileBrowser = new FileBrowser;
|
|
|
|
|
// mpFileBrowser->WarnOnExistingFileSelection(true);
|
|
|
|
|
mpFileBrowser->SetSelectionMode(FileBrowser::SelectionMode::FILES_ONLY);
|
|
|
|
|
mpFileBrowser->SetPrompt("Pick a location and name for the project");
|
|
|
|
|
if (!mpFileBrowser->OpenInDirectory(""))
|
|
|
|
|
mFileBrowser.SetSelectionMode(FileBrowser::SelectionMode::FILES_ONLY);
|
|
|
|
|
mFileBrowser.SetPrompt("Pick a location and name for the project");
|
|
|
|
|
if (!mFileBrowser.OpenInDirectory(""))
|
|
|
|
|
{
|
|
|
|
|
delete mpFileBrowser;
|
|
|
|
|
mpFileBrowser = nullptr;
|
|
|
|
|
mDoNewProject = false;
|
|
|
|
|
Logger::Log(mLogCat, LogLevel::ERROR, "Could not open the File Browser");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!mpFileBrowser->IsOpen())
|
|
|
|
|
{
|
|
|
|
|
if (mpFileBrowser->GetResult() == FileBrowser::Result::OK)
|
|
|
|
|
if (mFileBrowser.GetResult() == FileBrowser::Result::OK)
|
|
|
|
|
{
|
|
|
|
|
mpPath = mFileBrowser.GetSelectedItem();
|
|
|
|
|
Logger::Log(mLogCat, LogLevel::INFO, "Generating new project at %s", mpPath->string().c_str());
|
|
|
|
|
|
|
|
|
|
// Generate new project at mpPath
|
|
|
|
|
@ -185,60 +204,48 @@ namespace editor
|
|
|
|
|
Logger::Log(mLogCat, LogLevel::ERROR, "Could not create a new project: %s", result.Description);
|
|
|
|
|
}
|
|
|
|
|
((AssetBrowser*)mPanelManager.GetPanel(PanelType::PT_ASSET_BROWSER))->SetAssetDirectory(*mpPath / std::filesystem::path("contents/assets"));
|
|
|
|
|
mDoNewProject = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
else if (mFileBrowser.GetResult() == FileBrowser::Result::CANCEL)
|
|
|
|
|
{
|
|
|
|
|
Logger::Log(mLogCat, LogLevel::INFO, "New Project operation cancelled");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mpPath = nullptr;
|
|
|
|
|
delete mpFileBrowser;
|
|
|
|
|
mpFileBrowser = nullptr;
|
|
|
|
|
mDoNewProject = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mDoOpenProject)
|
|
|
|
|
{
|
|
|
|
|
if (!mpFileBrowser)
|
|
|
|
|
if (!mFileBrowser.IsOpen())
|
|
|
|
|
{
|
|
|
|
|
mpFileBrowser = new FileBrowser;
|
|
|
|
|
// mpFileBrowser->WarnOnExistingFileSelection(true);
|
|
|
|
|
mpFileBrowser->SetSelectionMode(FileBrowser::SelectionMode::FILES_ONLY);
|
|
|
|
|
mpFileBrowser->SetPrompt("Locate the project to open");
|
|
|
|
|
if (!mpFileBrowser->OpenInDirectory(""))
|
|
|
|
|
mFileBrowser.SetSelectionMode(FileBrowser::SelectionMode::FILES_ONLY);
|
|
|
|
|
mFileBrowser.SetPrompt("Pick a location and name for the project");
|
|
|
|
|
if (!mFileBrowser.OpenInDirectory(""))
|
|
|
|
|
{
|
|
|
|
|
delete mpFileBrowser;
|
|
|
|
|
mpFileBrowser = nullptr;
|
|
|
|
|
mDoOpenProject = false;
|
|
|
|
|
mDoNewProject = false;
|
|
|
|
|
Logger::Log(mLogCat, LogLevel::ERROR, "Could not open the File Browser");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!mpFileBrowser->IsOpen())
|
|
|
|
|
{
|
|
|
|
|
if (mpFileBrowser->GetResult() == FileBrowser::Result::OK)
|
|
|
|
|
if (mFileBrowser.GetResult() == FileBrowser::Result::OK)
|
|
|
|
|
{
|
|
|
|
|
mpPath = mFileBrowser.GetSelectedItem();
|
|
|
|
|
Logger::Log(mLogCat, LogLevel::INFO, "Generating new project at %s", mpPath->string().c_str());
|
|
|
|
|
|
|
|
|
|
// Generate new project at mpPath
|
|
|
|
|
// Open project at mpPath
|
|
|
|
|
OpRes result = mProject.LoadProject(*mpPath);
|
|
|
|
|
if (Failed(result))
|
|
|
|
|
{
|
|
|
|
|
Logger::Log(mLogCat, LogLevel::ERROR, "Could not open project: %s -- reason: %s", mpPath->string().c_str(), result.Description);
|
|
|
|
|
}
|
|
|
|
|
((AssetBrowser*)mPanelManager.GetPanel(PanelType::PT_ASSET_BROWSER))->SetAssetDirectory(mpPath->parent_path() / std::filesystem::path("contents/assets"));
|
|
|
|
|
((AssetBrowser*)mPanelManager.GetPanel(PanelType::PT_ASSET_BROWSER))->SetAssetDirectory(*mpPath / std::filesystem::path("contents/assets"));
|
|
|
|
|
mDoOpenProject = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
else if (mFileBrowser.GetResult() == FileBrowser::Result::CANCEL)
|
|
|
|
|
{
|
|
|
|
|
Logger::Log(mLogCat, LogLevel::INFO, "New Project operation cancelled");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mpPath = nullptr;
|
|
|
|
|
delete mpFileBrowser;
|
|
|
|
|
mpFileBrowser = nullptr;
|
|
|
|
|
Logger::Log(mLogCat, LogLevel::INFO, "Open Project operation cancelled");
|
|
|
|
|
mDoOpenProject = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|