Application: improve the M.A.S.S. manager.
This commit is contained in:
parent
b9fe38782d
commit
f2a021cd78
2 changed files with 15 additions and 21 deletions
|
@ -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 drawMaterialRow(Containers::StringView name, std::int32_t tier, GameData::MaterialID id);
|
||||||
void drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier);
|
void drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier);
|
||||||
void drawMassManager();
|
void drawMassManager();
|
||||||
auto drawDeleteMassPopup(int mass_index) -> ImGuiID;
|
void drawDeleteMassPopup(int mass_index);
|
||||||
auto drawDeleteStagedMassPopup(Containers::StringView filename) -> ImGuiID;
|
void drawDeleteStagedMassPopup(Containers::StringView filename);
|
||||||
|
|
||||||
void drawMassViewer();
|
void drawMassViewer();
|
||||||
void drawFrameInfo();
|
void drawFrameInfo();
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include <Corrade/Containers/ScopeGuard.h>
|
||||||
#include <Corrade/Utility/Format.h>
|
#include <Corrade/Utility/Format.h>
|
||||||
#include <Corrade/Utility/Path.h>
|
#include <Corrade/Utility/Path.h>
|
||||||
|
|
||||||
|
@ -399,7 +400,6 @@ Application::drawMassManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mass_to_delete = 0;
|
static int mass_to_delete = 0;
|
||||||
static ImGuiID mass_deletion_popup_ID = drawDeleteMassPopup(mass_to_delete);
|
|
||||||
|
|
||||||
if(ImGui::BeginTable("##HangarsTable", 4,
|
if(ImGui::BeginTable("##HangarsTable", 4,
|
||||||
ImGuiTableFlags_BordersOuter|ImGuiTableFlags_RowBg|ImGuiTableFlags_ScrollY,
|
ImGuiTableFlags_BordersOuter|ImGuiTableFlags_RowBg|ImGuiTableFlags_ScrollY,
|
||||||
|
@ -509,9 +509,10 @@ Application::drawMassManager() {
|
||||||
ImGui::SameLine(0.0f, 2.0f);
|
ImGui::SameLine(0.0f, 2.0f);
|
||||||
if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_TRASH_ALT)) {
|
if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_TRASH_ALT)) {
|
||||||
mass_to_delete = i;
|
mass_to_delete = i;
|
||||||
ImGui::OpenPopup(mass_deletion_popup_ID);
|
ImGui::OpenPopup("Confirmation##DeleteMassConfirmation");
|
||||||
}
|
}
|
||||||
drawTooltip("Delete");
|
drawTooltip("Delete");
|
||||||
|
drawDeleteMassPopup(mass_to_delete);
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -521,8 +522,6 @@ Application::drawMassManager() {
|
||||||
|
|
||||||
drawDeleteMassPopup(mass_to_delete);
|
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;
|
static Containers::StringView staged_mass_to_delete;
|
||||||
|
|
||||||
if(ImGui::BeginTable("##StagingArea", 2,
|
if(ImGui::BeginTable("##StagingArea", 2,
|
||||||
|
@ -562,9 +561,10 @@ Application::drawMassManager() {
|
||||||
ImGui::PushID(pair.first.data());
|
ImGui::PushID(pair.first.data());
|
||||||
if(ImGui::SmallButton(ICON_FA_TRASH_ALT)) {
|
if(ImGui::SmallButton(ICON_FA_TRASH_ALT)) {
|
||||||
staged_mass_to_delete = pair.first;
|
staged_mass_to_delete = pair.first;
|
||||||
ImGui::OpenPopup(staged_mass_deletion_popup_ID);
|
ImGui::OpenPopup("Confirmation##DeleteStagedMassConfirmation");
|
||||||
}
|
}
|
||||||
drawTooltip("Delete");
|
drawTooltip("Delete");
|
||||||
|
drawDeleteStagedMassPopup(staged_mass_to_delete);
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -592,24 +592,24 @@ Application::drawMassManager() {
|
||||||
drawDeleteStagedMassPopup(staged_mass_to_delete);
|
drawDeleteStagedMassPopup(staged_mass_to_delete);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiID
|
void
|
||||||
Application::drawDeleteMassPopup(int mass_index) {
|
Application::drawDeleteMassPopup(int mass_index) {
|
||||||
if(!ImGui::BeginPopupModal("Confirmation##DeleteMassConfirmation", nullptr,
|
if(!ImGui::BeginPopupModal("Confirmation##DeleteMassConfirmation", nullptr,
|
||||||
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
|
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) {
|
if(_massManager->hangar(mass_index).state() == GameObjects::Mass::State::Empty) {
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
ImGui::EndPopup();
|
return;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_gameState != GameState::NotRunning) {
|
if(_gameState != GameState::NotRunning) {
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
ImGui::EndPopup();
|
return;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f);
|
ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f);
|
||||||
|
@ -643,18 +643,14 @@ Application::drawDeleteMassPopup(int mass_index) {
|
||||||
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndPopup();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiID
|
void
|
||||||
Application::drawDeleteStagedMassPopup(Containers::StringView filename) {
|
Application::drawDeleteStagedMassPopup(Containers::StringView filename) {
|
||||||
if(!ImGui::BeginPopupModal("Confirmation##DeleteStagedMassConfirmation", nullptr,
|
if(!ImGui::BeginPopupModal("Confirmation##DeleteStagedMassConfirmation", nullptr,
|
||||||
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
|
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
|
||||||
{
|
{
|
||||||
return ImGui::GetID("Confirmation##DeleteStagedMassConfirmation");
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f);
|
ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f);
|
||||||
|
@ -684,8 +680,6 @@ Application::drawDeleteStagedMassPopup(Containers::StringView filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue