SaveTool: optimise code readability.
...mostly for Clang/CLion. :D
This commit is contained in:
parent
de2ba9ce7f
commit
572585e648
2 changed files with 114 additions and 68 deletions
|
@ -105,6 +105,9 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
||||||
auto drawRenamePopup(Containers::ArrayView<char> name_view) -> bool;
|
auto drawRenamePopup(Containers::ArrayView<char> name_view) -> bool;
|
||||||
void drawGeneralInfo();
|
void drawGeneralInfo();
|
||||||
void drawResearchInventory();
|
void drawResearchInventory();
|
||||||
|
template<typename Getter, typename Setter>
|
||||||
|
void drawMaterialRow(const char* name, Int tier, Getter getter, Setter setter);
|
||||||
|
void drawUnavailableMaterialRow(const char* name, Int tier);
|
||||||
void drawMassManager();
|
void drawMassManager();
|
||||||
auto drawDeleteMassPopup(int mass_index) -> ImGuiID;
|
auto drawDeleteMassPopup(int mass_index) -> ImGuiID;
|
||||||
auto drawDeleteStagedMassPopup(const std::string& filename) -> ImGuiID;
|
auto drawDeleteStagedMassPopup(const std::string& filename) -> ImGuiID;
|
||||||
|
|
|
@ -287,44 +287,6 @@ void SaveTool::drawResearchInventory() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define unavRow(name, tier) \
|
|
||||||
ImGui::TableNextRow(); \
|
|
||||||
ImGui::TableSetColumnIndex(0); \
|
|
||||||
ImGui::TextUnformatted("T" #tier); \
|
|
||||||
ImGui::TableSetColumnIndex(1); \
|
|
||||||
ImGui::TextUnformatted(name); \
|
|
||||||
ImGui::TableSetColumnIndex(2); \
|
|
||||||
ImGui::TextDisabled("Unavailable as of game version " SUPPORTED_GAME_VERSION);
|
|
||||||
|
|
||||||
#define matRow(name, tier, var, getter, setter) \
|
|
||||||
ImGui::TableNextRow(); \
|
|
||||||
ImGui::TableSetColumnIndex(0); \
|
|
||||||
ImGui::TextUnformatted("T" #tier); \
|
|
||||||
ImGui::TableSetColumnIndex(1); \
|
|
||||||
ImGui::TextUnformatted(name); \
|
|
||||||
ImGui::TableSetColumnIndex(2); \
|
|
||||||
if(_currentProfile->getter() != -1) { \
|
|
||||||
ImGui::Text("%i", _currentProfile->getter()); \
|
|
||||||
if(_cheatMode) { \
|
|
||||||
ImGui::TableSetColumnIndex(3); \
|
|
||||||
ImGui::PushID(#setter); \
|
|
||||||
static Int var = _currentProfile->getter(); \
|
|
||||||
if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_EDIT)) { \
|
|
||||||
(var) = _currentProfile->getter(); \
|
|
||||||
ImGui::OpenPopup("int_edit"); \
|
|
||||||
} \
|
|
||||||
if(drawIntEditPopup(&(var), 9999)) { \
|
|
||||||
if(!_currentProfile->set##setter((var))) { \
|
|
||||||
_queue.addToast(Toast::Type::Error, _currentProfile->lastError()); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
ImGui::PopID(); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
else { \
|
|
||||||
ImGui::TextDisabled("Not found in the save file"); \
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ImGui::BeginTable("##ResearchInventoryTable", 4,
|
if(ImGui::BeginTable("##ResearchInventoryTable", 4,
|
||||||
ImGuiTableFlags_BordersOuter|ImGuiTableFlags_ScrollY|ImGuiTableFlags_BordersInnerH))
|
ImGuiTableFlags_BordersOuter|ImGuiTableFlags_ScrollY|ImGuiTableFlags_BordersInnerH))
|
||||||
{
|
{
|
||||||
|
@ -337,55 +299,136 @@ void SaveTool::drawResearchInventory() {
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
ImGui::Text("Engine materials");
|
ImGui::Text("Engine materials");
|
||||||
|
|
||||||
matRow("Verse steel", 1, verse_steel, verseSteel, VerseSteel)
|
drawMaterialRow("Verse steel", 1,
|
||||||
matRow("Undinium", 2, undinium, undinium, Undinium)
|
[this]{ return _currentProfile->verseSteel(); },
|
||||||
matRow("Necrium alloy", 3, necrium_alloy, necriumAlloy, NecriumAlloy)
|
[this](Int amount){ return _currentProfile->setVerseSteel(amount); });
|
||||||
matRow("Lunarite", 4, lunarite, lunarite, Lunarite)
|
drawMaterialRow("Undinium", 2,
|
||||||
matRow("Asterite", 5, asterite, asterite, Asterite)
|
[this]{ return _currentProfile->undinium(); },
|
||||||
unavRow("Hallite fragma", 6)
|
[this](Int amount){ return _currentProfile->setUndinium(amount); });
|
||||||
unavRow("Unnoctinium", 7)
|
drawMaterialRow("Necrium alloy", 3,
|
||||||
|
[this]{ return _currentProfile->necriumAlloy(); },
|
||||||
|
[this](Int amount){ return _currentProfile->setNecriumAlloy(amount); });
|
||||||
|
drawMaterialRow("Lunarite", 4,
|
||||||
|
[this]{ return _currentProfile->lunarite(); },
|
||||||
|
[this](Int amount){ return _currentProfile->setLunarite(amount); });
|
||||||
|
drawMaterialRow("Asterite", 5,
|
||||||
|
[this]{ return _currentProfile->asterite(); },
|
||||||
|
[this](Int amount){ return _currentProfile->setAsterite(amount); });
|
||||||
|
drawUnavailableMaterialRow("Hallite fragma", 6);
|
||||||
|
drawUnavailableMaterialRow("Unnoctinium", 7);
|
||||||
|
|
||||||
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
|
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
ImGui::Text("OS materials");
|
ImGui::Text("OS materials");
|
||||||
|
|
||||||
matRow("Ednil", 1, ednil, ednil, Ednil)
|
drawMaterialRow("Ednil", 1,
|
||||||
matRow("Nuflalt", 2, nuflalt, nuflalt, Nuflalt)
|
[this]{ return _currentProfile->ednil(); },
|
||||||
matRow("Aurelene", 3, aurelene, aurelene, Aurelene)
|
[this](Int amount){ return _currentProfile->setEdnil(amount); });
|
||||||
matRow("Soldus", 4, soldus, soldus, Soldus)
|
drawMaterialRow("Nuflalt", 2,
|
||||||
matRow("Synthesized N", 5, synthesised_n, synthesisedN, SynthesisedN)
|
[this]{ return _currentProfile->nuflalt(); },
|
||||||
unavRow("Nanoc", 6)
|
[this](Int amount){ return _currentProfile->setNuflalt(amount); });
|
||||||
unavRow("Abyssillite", 7)
|
drawMaterialRow("Aurelene", 3,
|
||||||
|
[this]{ return _currentProfile->aurelene(); },
|
||||||
|
[this](Int amount){ return _currentProfile->setAurelene(amount); });
|
||||||
|
drawMaterialRow("Soldus", 4,
|
||||||
|
[this]{ return _currentProfile->soldus(); },
|
||||||
|
[this](Int amount){ return _currentProfile->setSoldus(amount); });
|
||||||
|
drawMaterialRow("Synthesized N", 5,
|
||||||
|
[this]{ return _currentProfile->synthesisedN(); },
|
||||||
|
[this](Int amount){ return _currentProfile->setSynthesisedN(amount); });
|
||||||
|
drawUnavailableMaterialRow("Nanoc", 6);
|
||||||
|
drawUnavailableMaterialRow("Abyssillite", 7);
|
||||||
|
|
||||||
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
|
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
ImGui::Text("Architect materials");
|
ImGui::Text("Architect materials");
|
||||||
|
|
||||||
matRow("Alcarbonite", 1, alcarbonite, alcarbonite, Alcarbonite)
|
drawMaterialRow("Alcarbonite", 1,
|
||||||
matRow("Keriphene", 2, keriphene, keriphene, Keriphene)
|
[this]{ return _currentProfile->alcarbonite(); },
|
||||||
matRow("Nitinol-CM", 3, nitinol_cm, nitinolCM, NitinolCM)
|
[this](Int amount){ return _currentProfile->setAlcarbonite(amount); });
|
||||||
matRow("Quarkium", 4, quarkium, quarkium, Quarkium)
|
drawMaterialRow("Keripehene", 2,
|
||||||
matRow("Alterene", 5, alterene, alterene, Alterene)
|
[this]{ return _currentProfile->keriphene(); },
|
||||||
unavRow("Cosmium", 6)
|
[this](Int amount){ return _currentProfile->setKeriphene(amount); });
|
||||||
unavRow("Purified quarkium", 7)
|
drawMaterialRow("Nitinol-CM", 3,
|
||||||
|
[this]{ return _currentProfile->nitinolCM(); },
|
||||||
|
[this](Int amount){ return _currentProfile->setNitinolCM(amount); });
|
||||||
|
drawMaterialRow("Quarkium", 4,
|
||||||
|
[this]{ return _currentProfile->quarkium(); },
|
||||||
|
[this](Int amount){ return _currentProfile->setQuarkium(amount); });
|
||||||
|
drawMaterialRow("Alterene", 5,
|
||||||
|
[this]{ return _currentProfile->alterene(); },
|
||||||
|
[this](Int amount){ return _currentProfile->setAlterene(amount); });
|
||||||
|
drawUnavailableMaterialRow("Cosmium", 6);
|
||||||
|
drawUnavailableMaterialRow("Purified quarkium", 7);
|
||||||
|
|
||||||
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
|
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
ImGui::Text("Quark data");
|
ImGui::Text("Quark data");
|
||||||
|
|
||||||
matRow("Mixed composition", 1, mixed_composition, mixedComposition, MixedComposition)
|
drawMaterialRow("Mixed composition", 1,
|
||||||
matRow("Void residue", 2, void_residue, voidResidue, VoidResidue)
|
[this]{ return _currentProfile->mixedComposition(); },
|
||||||
matRow("Muscular construction", 3, muscular_construction, muscularConstruction, MuscularConstruction)
|
[this](Int amount){ return _currentProfile->setMixedComposition(amount); });
|
||||||
matRow("Mineral exoskeletology", 4, mineral_exoskeletology, mineralExoskeletology, MineralExoskeletology)
|
drawMaterialRow("Void residue", 2,
|
||||||
matRow("Carbonized skin", 5, carbonised_skin, carbonisedSkin, CarbonisedSkin)
|
[this]{ return _currentProfile->voidResidue(); },
|
||||||
unavRow("Isolated void particle", 6)
|
[this](Int amount){ return _currentProfile->setVoidResidue(amount); });
|
||||||
unavRow("Weaponised physiology", 7)
|
drawMaterialRow("Muscular construction", 3,
|
||||||
|
[this]{ return _currentProfile->muscularConstruction(); },
|
||||||
|
[this](Int amount){ return _currentProfile->setMuscularConstruction(amount); });
|
||||||
|
drawMaterialRow("Mineral exoskeletology", 4,
|
||||||
|
[this]{ return _currentProfile->mineralExoskeletology(); },
|
||||||
|
[this](Int amount){ return _currentProfile->setMineralExoskeletology(amount); });
|
||||||
|
drawMaterialRow("Carbonized skin", 5,
|
||||||
|
[this]{ return _currentProfile->carbonisedSkin(); },
|
||||||
|
[this](Int amount){ return _currentProfile->setCarbonisedSkin(amount); });
|
||||||
|
drawUnavailableMaterialRow("Isolated void particle", 6);
|
||||||
|
drawUnavailableMaterialRow("Weaponised physiology", 7);
|
||||||
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#undef unavRow
|
template<typename Getter, typename Setter>
|
||||||
#undef matRow
|
void SaveTool::drawMaterialRow(const char* name, Int tier, Getter getter, Setter setter) {
|
||||||
|
static_assert(std::is_same<decltype(getter()), Int>::value, "getter doesn't return an Int, and/or doesn't take zero arguments.");
|
||||||
|
static_assert(std::is_same<decltype(setter(0)), bool>::value, "setter doesn't return a bool, and/or doesn't take a single Int as an argument.");
|
||||||
|
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableSetColumnIndex(0);
|
||||||
|
ImGui::Text("T%i", tier);
|
||||||
|
ImGui::TableSetColumnIndex(1);
|
||||||
|
ImGui::TextUnformatted(name);
|
||||||
|
ImGui::TableSetColumnIndex(2);
|
||||||
|
if(getter() != -1) {
|
||||||
|
ImGui::Text("%i", getter());
|
||||||
|
if(_cheatMode) {
|
||||||
|
ImGui::TableSetColumnIndex(3);
|
||||||
|
ImGui::PushID(name);
|
||||||
|
static Int var = 0;
|
||||||
|
if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_EDIT)) {
|
||||||
|
(var) = getter();
|
||||||
|
ImGui::OpenPopup("int_edit");
|
||||||
|
}
|
||||||
|
if(drawIntEditPopup(&(var), 9999)) {
|
||||||
|
if(!setter(var)) {
|
||||||
|
_queue.addToast(Toast::Type::Error, _currentProfile->lastError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::PopID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ImGui::TextDisabled("Not found in the save file");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SaveTool::drawUnavailableMaterialRow(const char* name, Int tier) {
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableSetColumnIndex(0);
|
||||||
|
ImGui::Text("T%i", tier);
|
||||||
|
ImGui::TableSetColumnIndex(1);
|
||||||
|
ImGui::TextUnformatted(name);
|
||||||
|
ImGui::TableSetColumnIndex(2);
|
||||||
|
ImGui::TextDisabled("Unavailable as of game version " SUPPORTED_GAME_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveTool::drawMassManager() {
|
void SaveTool::drawMassManager() {
|
||||||
|
|
Loading…
Reference in a new issue