Application: improve the M.A.S.S. manager.

This commit is contained in:
Guillaume Jacquemin 2024-04-16 15:41:02 +02:00
parent b9fe38782d
commit f2a021cd78
Signed by: williamjcm
SSH key fingerprint: SHA256:AYLOg+iTV0ElElnlu4vqM4edFazVdRiuQB0Y5LoKc4A
2 changed files with 15 additions and 21 deletions

View file

@ -127,8 +127,8 @@ class Application: public Platform::Sdl2Application, public efsw::FileWatchListe
void drawMaterialRow(Containers::StringView name, std::int32_t tier, GameData::MaterialID id);
void drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier);
void drawMassManager();
auto drawDeleteMassPopup(int mass_index) -> ImGuiID;
auto drawDeleteStagedMassPopup(Containers::StringView filename) -> ImGuiID;
void drawDeleteMassPopup(int mass_index);
void drawDeleteStagedMassPopup(Containers::StringView filename);
void drawMassViewer();
void drawFrameInfo();

View file

@ -16,6 +16,7 @@
#include <algorithm>
#include <Corrade/Containers/ScopeGuard.h>
#include <Corrade/Utility/Format.h>
#include <Corrade/Utility/Path.h>
@ -399,7 +400,6 @@ Application::drawMassManager() {
}
static int mass_to_delete = 0;
static ImGuiID mass_deletion_popup_ID = drawDeleteMassPopup(mass_to_delete);
if(ImGui::BeginTable("##HangarsTable", 4,
ImGuiTableFlags_BordersOuter|ImGuiTableFlags_RowBg|ImGuiTableFlags_ScrollY,
@ -509,9 +509,10 @@ Application::drawMassManager() {
ImGui::SameLine(0.0f, 2.0f);
if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_TRASH_ALT)) {
mass_to_delete = i;
ImGui::OpenPopup(mass_deletion_popup_ID);
ImGui::OpenPopup("Confirmation##DeleteMassConfirmation");
}
drawTooltip("Delete");
drawDeleteMassPopup(mass_to_delete);
ImGui::PopID();
}
}
@ -521,8 +522,6 @@ Application::drawMassManager() {
drawDeleteMassPopup(mass_to_delete);
// TODO: fix this shit, like with the profile manager.
static ImGuiID staged_mass_deletion_popup_ID = drawDeleteStagedMassPopup("");
static Containers::StringView staged_mass_to_delete;
if(ImGui::BeginTable("##StagingArea", 2,
@ -562,9 +561,10 @@ Application::drawMassManager() {
ImGui::PushID(pair.first.data());
if(ImGui::SmallButton(ICON_FA_TRASH_ALT)) {
staged_mass_to_delete = pair.first;
ImGui::OpenPopup(staged_mass_deletion_popup_ID);
ImGui::OpenPopup("Confirmation##DeleteStagedMassConfirmation");
}
drawTooltip("Delete");
drawDeleteStagedMassPopup(staged_mass_to_delete);
ImGui::PopID();
}
@ -592,24 +592,24 @@ Application::drawMassManager() {
drawDeleteStagedMassPopup(staged_mass_to_delete);
}
ImGuiID
void
Application::drawDeleteMassPopup(int mass_index) {
if(!ImGui::BeginPopupModal("Confirmation##DeleteMassConfirmation", nullptr,
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
{
return ImGui::GetID("Confirmation##DeleteMassConfirmation");
return;
}
Containers::ScopeGuard guard{ImGui::EndPopup};
if(_massManager->hangar(mass_index).state() == GameObjects::Mass::State::Empty) {
ImGui::CloseCurrentPopup();
ImGui::EndPopup();
return 0;
return;
}
if(_gameState != GameState::NotRunning) {
ImGui::CloseCurrentPopup();
ImGui::EndPopup();
return 0;
return;
}
ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f);
@ -643,18 +643,14 @@ Application::drawDeleteMassPopup(int mass_index) {
ImGui::EndTable();
}
ImGui::EndPopup();
return 0;
}
ImGuiID
void
Application::drawDeleteStagedMassPopup(Containers::StringView filename) {
if(!ImGui::BeginPopupModal("Confirmation##DeleteStagedMassConfirmation", nullptr,
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
{
return ImGui::GetID("Confirmation##DeleteStagedMassConfirmation");
return;
}
ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f);
@ -684,8 +680,6 @@ Application::drawDeleteStagedMassPopup(Containers::StringView filename) {
}
ImGui::EndPopup();
return 0;
}
}