diff --git a/src/editor/system/SystemEditor.cpp b/src/editor/system/SystemEditor.cpp index b346bfdbc1a..04943ef6669 100644 --- a/src/editor/system/SystemEditor.cpp +++ b/src/editor/system/SystemEditor.cpp @@ -380,12 +380,28 @@ void SystemEditor::RegisterMenuActions() m_menuBinder->AddAction("New", { "New System", ImGuiKey_N | ImGuiKey_ModCtrl, - sigc::mem_fun(this, &SystemEditor::ActivateNewSystemDialog) + [&]() { + if (HasUnsavedChanges()) { + m_unsavedFileModal = m_app->PushModal(); + m_pendingFileReq = FileRequest_New; + return; + } + + ActivateNewSystemDialog(); + } }); m_menuBinder->AddAction("Open", { "Open File", ImGuiKey_O | ImGuiKey_ModCtrl, - sigc::mem_fun(this, &SystemEditor::ActivateOpenDialog) + [&]() { + if (HasUnsavedChanges()) { + m_unsavedFileModal = m_app->PushModal(); + m_pendingFileReq = FileRequest_Open; + return; + } + + ActivateOpenDialog(); + } }); m_menuBinder->AddAction("Save", { @@ -457,7 +473,8 @@ void SystemEditor::RegisterMenuActions() m_menuBinder->EndGroup(); m_menuBinder->AddAction("Sort", { - "Sort Bodies", {}, + "Sort Bodies", ImGuiKey_None, + [&]() { return m_system.Valid(); }, [&]() { m_pendingOp.type = BodyRequest::TYPE_Resort; } }); @@ -496,12 +513,6 @@ void SystemEditor::OnSaveComplete(bool success) void SystemEditor::ActivateOpenDialog() { - if (HasUnsavedChanges()) { - m_unsavedFileModal = m_app->PushModal(); - m_pendingFileReq = FileRequest_Open; - return; - } - // FIXME: need to handle loading files outside of game data dir m_openFile.reset(new pfd::open_file( "Open Custom System File", @@ -531,12 +542,6 @@ void SystemEditor::ActivateSaveDialog() void SystemEditor::ActivateNewSystemDialog() { - if (HasUnsavedChanges()) { - m_unsavedFileModal = m_app->PushModal(); - m_pendingFileReq = FileRequest_New; - return; - } - m_newSystemModal = m_app->PushModal(this, &m_newSystemPath); } @@ -615,12 +620,10 @@ void SystemEditor::Update(float deltaTime) void SystemEditor::HandlePendingFileRequest() { if (m_pendingFileReq == FileRequest_New) { - ClearSystem(); ActivateNewSystemDialog(); } if (m_pendingFileReq == FileRequest_Open) { - ClearSystem(); ActivateOpenDialog(); } diff --git a/src/editor/system/SystemEditorModals.cpp b/src/editor/system/SystemEditorModals.cpp index dad3b18dc09..1e76a119a60 100644 --- a/src/editor/system/SystemEditorModals.cpp +++ b/src/editor/system/SystemEditorModals.cpp @@ -79,8 +79,10 @@ NewSystemModal::NewSystemModal(EditorApp *app, SystemEditor *editor, SystemPath void NewSystemModal::Draw() { - ImVec2 windSize = ImVec2(ImGui::GetMainViewport()->Size.x * 0.5, -1); - ImGui::SetNextWindowSizeConstraints(windSize, windSize); + ImVec2 vpSize = ImGui::GetMainViewport()->Size; + ImVec2 windSize = ImVec2(vpSize.x * 0.5, vpSize.y * 0.333); + ImVec2 windSizeMax = ImVec2(vpSize.x * 0.5, vpSize.y * 0.5); + ImGui::SetNextWindowSizeConstraints(windSize, windSizeMax); Modal::Draw(); } @@ -89,9 +91,9 @@ void NewSystemModal::DrawInternal() { if (Draw::LayoutHorizontal("Sector", 3, ImGui::GetFontSize())) { bool changed = false; - changed |= ImGui::InputInt("X", &m_path->sectorX, 0, 0); - changed |= ImGui::InputInt("Y", &m_path->sectorY, 0, 0); - changed |= ImGui::InputInt("Z", &m_path->sectorZ, 0, 0); + changed |= ImGui::InputInt("X", &m_path->sectorX, 1, 0); + changed |= ImGui::InputInt("Y", &m_path->sectorY, 1, 0); + changed |= ImGui::InputInt("Z", &m_path->sectorZ, 1, 0); if (changed) m_path->systemIndex = 0; @@ -127,6 +129,17 @@ void NewSystemModal::DrawInternal() ImGui::CloseCurrentPopup(); } + ImGui::SetItemTooltip("Create a new empty system in this sector."); + + ImGui::SameLine(); + + if (ImGui::Button("Edit Selected")) { + m_editor->LoadSystem(m_path->SystemOnly()); + ImGui::CloseCurrentPopup(); + } + + ImGui::SetItemTooltip("Load the selected system as a template."); + ImGui::EndGroup(); ImGui::SameLine(); @@ -140,13 +153,6 @@ void NewSystemModal::DrawInternal() ImGui::AlignTextToFramePadding(); ImGui::TextUnformatted(system.GetName().c_str()); - ImGui::SameLine(); - ImGui::SameLine(0.f, ImGui::GetContentRegionAvail().x - ImGui::GetFrameHeight()); - if (ImGui::Button(EICON_FORWARD1)) { - m_editor->LoadSystem(m_path->SystemOnly()); - ImGui::CloseCurrentPopup(); - } - ImGui::PopFont(); ImGui::Spacing();