Profile,SaveTool: change how materials are handled.

This commit is contained in:
Guillaume Jacquemin 2022-12-05 12:11:02 +01:00
parent d21e2cbabb
commit 267226a386
4 changed files with 100 additions and 484 deletions

View file

@ -133,33 +133,33 @@ Profile::refreshValues() {
_lastMissionId = prop ? prop->value : 0; _lastMissionId = prop ? prop->value : 0;
LOG_INFO("Getting the materials."); LOG_INFO("Getting the materials.");
_verseSteel = getResource(PROFILE_MATERIAL, VerseSteel); _materials[VerseSteel] = getResource(PROFILE_MATERIAL, VerseSteel);
_undinium = getResource(PROFILE_MATERIAL, Undinium); _materials[Undinium] = getResource(PROFILE_MATERIAL, Undinium);
_necriumAlloy = getResource(PROFILE_MATERIAL, NecriumAlloy); _materials[NecriumAlloy] = getResource(PROFILE_MATERIAL, NecriumAlloy);
_lunarite = getResource(PROFILE_MATERIAL, Lunarite); _materials[Lunarite] = getResource(PROFILE_MATERIAL, Lunarite);
_asterite = getResource(PROFILE_MATERIAL, Asterite); _materials[Asterite] = getResource(PROFILE_MATERIAL, Asterite);
_halliteFragma = getResource(PROFILE_MATERIAL, HalliteFragma); _materials[HalliteFragma] = getResource(PROFILE_MATERIAL, HalliteFragma);
_ednil = getResource(PROFILE_MATERIAL, Ednil); _materials[Ednil] = getResource(PROFILE_MATERIAL, Ednil);
_nuflalt = getResource(PROFILE_MATERIAL, Nuflalt); _materials[Nuflalt] = getResource(PROFILE_MATERIAL, Nuflalt);
_aurelene = getResource(PROFILE_MATERIAL, Aurelene); _materials[Aurelene] = getResource(PROFILE_MATERIAL, Aurelene);
_soldus = getResource(PROFILE_MATERIAL, Soldus); _materials[Soldus] = getResource(PROFILE_MATERIAL, Soldus);
_synthesisedN = getResource(PROFILE_MATERIAL, SynthesisedN); _materials[SynthesisedN] = getResource(PROFILE_MATERIAL, SynthesisedN);
_nanoc = getResource(PROFILE_MATERIAL, Nanoc); _materials[Nanoc] = getResource(PROFILE_MATERIAL, Nanoc);
_alcarbonite = getResource(PROFILE_MATERIAL, Alcarbonite); _materials[Alcarbonite] = getResource(PROFILE_MATERIAL, Alcarbonite);
_keriphene = getResource(PROFILE_MATERIAL, Keriphene); _materials[Keriphene] = getResource(PROFILE_MATERIAL, Keriphene);
_nitinolCM = getResource(PROFILE_MATERIAL, NitinolCM); _materials[NitinolCM] = getResource(PROFILE_MATERIAL, NitinolCM);
_quarkium = getResource(PROFILE_MATERIAL, Quarkium); _materials[Quarkium] = getResource(PROFILE_MATERIAL, Quarkium);
_alterene = getResource(PROFILE_MATERIAL, Alterene); _materials[Alterene] = getResource(PROFILE_MATERIAL, Alterene);
_cosmium = getResource(PROFILE_MATERIAL, Cosmium); _materials[Cosmium] = getResource(PROFILE_MATERIAL, Cosmium);
_mixedComposition = getResource(PROFILE_QUARK_DATA, MixedComposition); _materials[MixedComposition] = getResource(PROFILE_QUARK_DATA, MixedComposition);
_voidResidue = getResource(PROFILE_QUARK_DATA, VoidResidue); _materials[VoidResidue] = getResource(PROFILE_QUARK_DATA, VoidResidue);
_muscularConstruction = getResource(PROFILE_QUARK_DATA, MuscularConstruction); _materials[MuscularConstruction] = getResource(PROFILE_QUARK_DATA, MuscularConstruction);
_mineralExoskeletology = getResource(PROFILE_QUARK_DATA, MineralExoskeletology); _materials[MineralExoskeletology] = getResource(PROFILE_QUARK_DATA, MineralExoskeletology);
_carbonisedSkin = getResource(PROFILE_QUARK_DATA, CarbonisedSkin); _materials[CarbonisedSkin] = getResource(PROFILE_QUARK_DATA, CarbonisedSkin);
_isolatedVoidParticle = getResource(PROFILE_QUARK_DATA, IsolatedVoidParticle); _materials[IsolatedVoidParticle] = getResource(PROFILE_QUARK_DATA, IsolatedVoidParticle);
_valid = true; _valid = true;
} }
@ -252,264 +252,13 @@ Profile::lastMissionId() const {
} }
std::int32_t std::int32_t
Profile::verseSteel() const { Profile::material(MaterialID id) const {
return _verseSteel; return _materials.at(id);
} }
bool bool
Profile::setVerseSteel(std::int32_t amount) { Profile::setMaterial(MaterialID id, std::int32_t amount) {
return setResource(PROFILE_MATERIAL, VerseSteel, amount); Containers::StringView container = id > MixedComposition ? PROFILE_QUARK_DATA : PROFILE_MATERIAL;
}
std::int32_t
Profile::undinium() const {
return _undinium;
}
bool
Profile::setUndinium(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Undinium, amount);
}
std::int32_t
Profile::necriumAlloy() const {
return _necriumAlloy;
}
bool
Profile::setNecriumAlloy(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, NecriumAlloy, amount);
}
std::int32_t
Profile::lunarite() const {
return _lunarite;
}
bool
Profile::setLunarite(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Lunarite, amount);
}
std::int32_t
Profile::asterite() const {
return _asterite;
}
bool
Profile::setAsterite(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Asterite, amount);
}
std::int32_t
Profile::halliteFragma() const {
return _halliteFragma;
}
bool
Profile::setHalliteFragma(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, HalliteFragma, amount);
}
std::int32_t
Profile::ednil() const {
return _ednil;
}
bool
Profile::setEdnil(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Ednil, amount);
}
std::int32_t
Profile::nuflalt() const {
return _nuflalt;
}
bool
Profile::setNuflalt(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Nuflalt, amount);
}
std::int32_t
Profile::aurelene() const {
return _aurelene;
}
bool
Profile::setAurelene(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Aurelene, amount);
}
std::int32_t
Profile::soldus() const {
return _soldus;
}
bool
Profile::setSoldus(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Soldus, amount);
}
std::int32_t
Profile::synthesisedN() const {
return _synthesisedN;
}
bool
Profile::setSynthesisedN(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, SynthesisedN, amount);
}
std::int32_t
Profile::nanoc() const {
return _nanoc;
}
bool
Profile::setNanoc(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Nanoc, amount);
}
std::int32_t
Profile::alcarbonite() const {
return _alcarbonite;
}
bool
Profile::setAlcarbonite(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Alcarbonite, amount);
}
std::int32_t
Profile::keriphene() const {
return _keriphene;
}
bool
Profile::setKeriphene(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Keriphene, amount);
}
std::int32_t
Profile::nitinolCM() const {
return _nitinolCM;
}
bool
Profile::setNitinolCM(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, NitinolCM, amount);
}
std::int32_t
Profile::quarkium() const {
return _quarkium;
}
bool
Profile::setQuarkium(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Quarkium, amount);
}
std::int32_t
Profile::alterene() const {
return _alterene;
}
bool
Profile::setAlterene(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Alterene, amount);
}
std::int32_t
Profile::cosmium() const {
return _cosmium;
}
bool
Profile::setCosmium(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Cosmium, amount);
}
std::int32_t
Profile::mixedComposition() const {
return _mixedComposition;
}
bool
Profile::setMixedComposition(std::int32_t amount) {
return setResource(PROFILE_QUARK_DATA, MixedComposition, amount);
}
std::int32_t
Profile::voidResidue() const {
return _voidResidue;
}
bool
Profile::setVoidResidue(std::int32_t amount) {
return setResource(PROFILE_QUARK_DATA, VoidResidue, amount);
}
std::int32_t
Profile::muscularConstruction() const {
return _muscularConstruction;
}
bool
Profile::setMuscularConstruction(std::int32_t amount) {
return setResource(PROFILE_QUARK_DATA, MuscularConstruction, amount);
}
std::int32_t
Profile::mineralExoskeletology() const {
return _mineralExoskeletology;
}
bool
Profile::setMineralExoskeletology(std::int32_t amount) {
return setResource(PROFILE_QUARK_DATA, MineralExoskeletology, amount);
}
std::int32_t
Profile::carbonisedSkin() const {
return _carbonisedSkin;
}
bool
Profile::setCarbonisedSkin(std::int32_t amount) {
return setResource(PROFILE_QUARK_DATA, CarbonisedSkin, amount);
}
std::int32_t
Profile::isolatedVoidParticle() const {
return _isolatedVoidParticle;
}
bool
Profile::setIsolatedVoidParticle(std::int32_t amount) {
return setResource(PROFILE_QUARK_DATA, IsolatedVoidParticle, amount);
}
std::int32_t
Profile::getResource(Containers::StringView container, MaterialID id) {
auto mats_prop = _profile.at<ArrayProperty>(container);
if(!mats_prop) {
return 0;
}
auto predicate = [&id](UnrealPropertyBase::ptr& prop){
auto res_prop = static_cast<ResourceItemValue*>(prop.get());
return res_prop->id == id;
};
auto it = std::find_if(mats_prop->items.begin(), mats_prop->items.end(), predicate);
return it != mats_prop->items.end() ? static_cast<ResourceItemValue*>(it->get())->quantity : 0;
}
bool
Profile::setResource(Containers::StringView container, MaterialID id, std::int32_t amount) {
auto mats_prop = _profile.at<ArrayProperty>(container); auto mats_prop = _profile.at<ArrayProperty>(container);
if(!mats_prop) { if(!mats_prop) {
@ -549,3 +298,20 @@ Profile::setResource(Containers::StringView container, MaterialID id, std::int32
return true; return true;
} }
std::int32_t
Profile::getResource(Containers::StringView container, MaterialID id) {
auto mats_prop = _profile.at<ArrayProperty>(container);
if(!mats_prop) {
return 0;
}
auto predicate = [&id](UnrealPropertyBase::ptr& prop){
auto res_prop = static_cast<ResourceItemValue*>(prop.get());
return res_prop->id == id;
};
auto it = std::find_if(mats_prop->items.begin(), mats_prop->items.end(), predicate);
return it != mats_prop->items.end() ? static_cast<ResourceItemValue*>(it->get())->quantity : 0;
}

View file

@ -16,6 +16,8 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <map>
#include <Corrade/Containers/String.h> #include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
@ -60,81 +62,11 @@ class Profile {
std::int32_t lastMissionId() const; std::int32_t lastMissionId() const;
std::int32_t verseSteel() const; std::int32_t material(MaterialID id) const;
bool setVerseSteel(std::int32_t amount); bool setMaterial(MaterialID id, std::int32_t amount);
std::int32_t undinium() const;
bool setUndinium(std::int32_t amount);
std::int32_t necriumAlloy() const;
bool setNecriumAlloy(std::int32_t amount);
std::int32_t lunarite() const;
bool setLunarite(std::int32_t amount);
std::int32_t asterite() const;
bool setAsterite(std::int32_t amount);
std::int32_t halliteFragma() const;
bool setHalliteFragma(std::int32_t amount);
std::int32_t ednil() const;
bool setEdnil(std::int32_t amount);
std::int32_t nuflalt() const;
bool setNuflalt(std::int32_t amount);
std::int32_t aurelene() const;
bool setAurelene(std::int32_t amount);
std::int32_t soldus() const;
bool setSoldus(std::int32_t amount);
std::int32_t synthesisedN() const;
bool setSynthesisedN(std::int32_t amount);
std::int32_t nanoc() const;
bool setNanoc(std::int32_t amount);
std::int32_t alcarbonite() const;
bool setAlcarbonite(std::int32_t amount);
std::int32_t keriphene() const;
bool setKeriphene(std::int32_t amount);
std::int32_t nitinolCM() const;
bool setNitinolCM(std::int32_t amount);
std::int32_t quarkium() const;
bool setQuarkium(std::int32_t amount);
std::int32_t alterene() const;
bool setAlterene(std::int32_t amount);
std::int32_t cosmium() const;
bool setCosmium(std::int32_t amount);
std::int32_t mixedComposition() const;
bool setMixedComposition(std::int32_t amount);
std::int32_t voidResidue() const;
bool setVoidResidue(std::int32_t amount);
std::int32_t muscularConstruction() const;
bool setMuscularConstruction(std::int32_t amount);
std::int32_t mineralExoskeletology() const;
bool setMineralExoskeletology(std::int32_t amount);
std::int32_t carbonisedSkin() const;
bool setCarbonisedSkin(std::int32_t amount);
std::int32_t isolatedVoidParticle() const;
bool setIsolatedVoidParticle(std::int32_t amount);
private: private:
std::int32_t getResource(Containers::StringView container, MaterialID id); std::int32_t getResource(Containers::StringView container, MaterialID id);
bool setResource(Containers::StringView container, MaterialID id, std::int32_t amount);
Containers::String _filename; Containers::String _filename;
@ -148,33 +80,7 @@ class Profile {
std::int32_t _storyProgress = 0; std::int32_t _storyProgress = 0;
std::int32_t _lastMissionId = 0; std::int32_t _lastMissionId = 0;
std::int32_t _verseSteel = 0; std::map<MaterialID, std::int32_t> _materials;
std::int32_t _undinium = 0;
std::int32_t _necriumAlloy = 0;
std::int32_t _lunarite = 0;
std::int32_t _asterite = 0;
std::int32_t _halliteFragma = 0;
std::int32_t _ednil = 0;
std::int32_t _nuflalt = 0;
std::int32_t _aurelene = 0;
std::int32_t _soldus = 0;
std::int32_t _synthesisedN = 0;
std::int32_t _nanoc = 0;
std::int32_t _alcarbonite = 0;
std::int32_t _keriphene = 0;
std::int32_t _nitinolCM = 0;
std::int32_t _quarkium = 0;
std::int32_t _alterene = 0;
std::int32_t _cosmium = 0;
std::int32_t _mixedComposition = 0;
std::int32_t _voidResidue = 0;
std::int32_t _muscularConstruction = 0;
std::int32_t _mineralExoskeletology = 0;
std::int32_t _carbonisedSkin = 0;
std::int32_t _isolatedVoidParticle = 0;
Containers::String _account; Containers::String _account;

View file

@ -125,8 +125,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
bool drawRenamePopup(Containers::ArrayView<char> name_view); bool drawRenamePopup(Containers::ArrayView<char> name_view);
void drawGeneralInfo(); void drawGeneralInfo();
void drawResearchInventory(); void drawResearchInventory();
template<typename Getter, typename Setter> void drawMaterialRow(Containers::StringView name, std::int32_t tier, MaterialID id);
void drawMaterialRow(Containers::StringView name, std::int32_t tier, Getter getter, Setter setter);
void drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier); void drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier);
void drawMassManager(); void drawMassManager();
ImGuiID drawDeleteMassPopup(int mass_index); ImGuiID drawDeleteMassPopup(int mass_index);

View file

@ -106,7 +106,7 @@ SaveTool::drawIntEditPopup(int* value_to_edit, int max) {
drawHelpMarker("You can either drag the widget left or right to change the value,\n" drawHelpMarker("You can either drag the widget left or right to change the value,\n"
"or click on it while holding Ctrl to edit the value directly."); "or click on it while holding Ctrl to edit the value directly.");
ImGui::SameLine(); ImGui::SameLine();
drawUnsafeWidget([](auto... args){ return ImGui::SliderInt("", args...); }, drawUnsafeWidget([](auto... args){ return ImGui::SliderInt("##IntSlider", args...); },
value_to_edit, 0, max, "%d", ImGuiSliderFlags_AlwaysClamp); value_to_edit, 0, max, "%d", ImGuiSliderFlags_AlwaysClamp);
ImGui::SameLine(); ImGui::SameLine();
if(drawUnsafeWidget([]{ return ImGui::Button("Apply"); })) { if(drawUnsafeWidget([]{ return ImGui::Button("Apply"); })) {
@ -137,13 +137,15 @@ SaveTool::drawRenamePopup(Containers::ArrayView<char> name_view) {
(name_view[0] != ' ' && name_view[len - 1] != ' ') ? ICON_FA_CHECK : ICON_FA_TIMES); (name_view[0] != ' ' && name_view[len - 1] != ' ') ? ICON_FA_CHECK : ICON_FA_TIMES);
static auto callback = [](ImGuiInputTextCallbackData* data)->int { static auto callback = [](ImGuiInputTextCallbackData* data)->int {
if(data->EventChar < 256 && std::strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789- ", char(data->EventChar))) { if(data->EventChar < 256 &&
std::strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789- ", char(data->EventChar)))
{
return 0; return 0;
} }
return 1; return 1;
}; };
drawUnsafeWidget([](auto... args){ return ImGui::InputText("", args...); }, drawUnsafeWidget([](auto... args){ return ImGui::InputText("##NameField", args...); },
name_view.data(), name_view.size(), name_view.data(), name_view.size(),
ImGuiInputTextFlags_CallbackCharFilter, ImGuiInputTextFlags_CallbackCharFilter,
callback, nullptr); callback, nullptr);
@ -298,139 +300,82 @@ SaveTool::drawResearchInventory() {
ImGui::TableNextRow(ImGuiTableRowFlags_Headers); ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::Text("Engine materials"); ImGui::TextUnformatted("Engine materials");
drawMaterialRow("Verse steel", 1, drawMaterialRow("Verse steel", 1, VerseSteel);
[this]{ return _currentProfile->verseSteel(); }, drawMaterialRow("Undinium", 2, Undinium);
[this](std::int32_t amount){ return _currentProfile->setVerseSteel(amount); }); drawMaterialRow("Necrium alloy", 3, NecriumAlloy);
drawMaterialRow("Undinium", 2, drawMaterialRow("Lunarite", 4, Lunarite);
[this]{ return _currentProfile->undinium(); }, drawMaterialRow("Asterite", 5, Asterite);
[this](std::int32_t amount){ return _currentProfile->setUndinium(amount); }); drawMaterialRow("Hallite fragma", 6, HalliteFragma);
drawMaterialRow("Necrium alloy", 3,
[this]{ return _currentProfile->necriumAlloy(); },
[this](std::int32_t amount){ return _currentProfile->setNecriumAlloy(amount); });
drawMaterialRow("Lunarite", 4,
[this]{ return _currentProfile->lunarite(); },
[this](std::int32_t amount){ return _currentProfile->setLunarite(amount); });
drawMaterialRow("Asterite", 5,
[this]{ return _currentProfile->asterite(); },
[this](std::int32_t amount){ return _currentProfile->setAsterite(amount); });
drawMaterialRow("Hallite fragma", 6,
[this]{ return _currentProfile->halliteFragma(); },
[this](std::int32_t amount){ return _currentProfile->setHalliteFragma(amount); });
drawUnavailableMaterialRow("Unnoctinium", 7); drawUnavailableMaterialRow("Unnoctinium", 7);
ImGui::TableNextRow(ImGuiTableRowFlags_Headers); ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::Text("OS materials"); ImGui::TextUnformatted("OS materials");
drawMaterialRow("Ednil", 1, drawMaterialRow("Ednil", 1, Ednil);
[this]{ return _currentProfile->ednil(); }, drawMaterialRow("Nuflalt", 2, Nuflalt);
[this](std::int32_t amount){ return _currentProfile->setEdnil(amount); }); drawMaterialRow("Aurelene", 3, Aurelene);
drawMaterialRow("Nuflalt", 2, drawMaterialRow("Soldus", 4, Soldus);
[this]{ return _currentProfile->nuflalt(); }, drawMaterialRow("Synthesized N", 5, SynthesisedN);
[this](std::int32_t amount){ return _currentProfile->setNuflalt(amount); }); drawMaterialRow("Nanoc", 6, Nanoc);
drawMaterialRow("Aurelene", 3,
[this]{ return _currentProfile->aurelene(); },
[this](std::int32_t amount){ return _currentProfile->setAurelene(amount); });
drawMaterialRow("Soldus", 4,
[this]{ return _currentProfile->soldus(); },
[this](std::int32_t amount){ return _currentProfile->setSoldus(amount); });
drawMaterialRow("Synthesized N", 5,
[this]{ return _currentProfile->synthesisedN(); },
[this](std::int32_t amount){ return _currentProfile->setSynthesisedN(amount); });
drawMaterialRow("Nanoc", 6,
[this]{ return _currentProfile->nanoc(); },
[this](std::int32_t amount){ return _currentProfile->setNanoc(amount); });
drawUnavailableMaterialRow("Abyssillite", 7); drawUnavailableMaterialRow("Abyssillite", 7);
ImGui::TableNextRow(ImGuiTableRowFlags_Headers); ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::Text("Architect materials"); ImGui::TextUnformatted("Architect materials");
drawMaterialRow("Alcarbonite", 1, drawMaterialRow("Alcarbonite", 1, Alcarbonite);
[this]{ return _currentProfile->alcarbonite(); }, drawMaterialRow("Keriphene", 2, Keriphene);
[this](std::int32_t amount){ return _currentProfile->setAlcarbonite(amount); }); drawMaterialRow("Nitinol-CM", 3, NitinolCM);
drawMaterialRow("Keripehene", 2, drawMaterialRow("Quarkium", 4, Quarkium);
[this]{ return _currentProfile->keriphene(); }, drawMaterialRow("Alterene", 5, Alterene);
[this](std::int32_t amount){ return _currentProfile->setKeriphene(amount); }); drawMaterialRow("Cosmium", 6, Cosmium);
drawMaterialRow("Nitinol-CM", 3,
[this]{ return _currentProfile->nitinolCM(); },
[this](std::int32_t amount){ return _currentProfile->setNitinolCM(amount); });
drawMaterialRow("Quarkium", 4,
[this]{ return _currentProfile->quarkium(); },
[this](std::int32_t amount){ return _currentProfile->setQuarkium(amount); });
drawMaterialRow("Alterene", 5,
[this]{ return _currentProfile->alterene(); },
[this](std::int32_t amount){ return _currentProfile->setAlterene(amount); });
drawMaterialRow("Cosmium", 6,
[this]{ return _currentProfile->cosmium(); },
[this](std::int32_t amount){ return _currentProfile->setCosmium(amount); });
drawUnavailableMaterialRow("Purified quarkium", 7); drawUnavailableMaterialRow("Purified quarkium", 7);
ImGui::TableNextRow(ImGuiTableRowFlags_Headers); ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::Text("Quark data"); ImGui::TextUnformatted("Quark data");
drawMaterialRow("Mixed composition", 1, drawMaterialRow("Mixed composition", 1, MixedComposition);
[this]{ return _currentProfile->mixedComposition(); }, drawMaterialRow("Void residue", 2, VoidResidue);
[this](std::int32_t amount){ return _currentProfile->setMixedComposition(amount); }); drawMaterialRow("Muscular construction", 3, MuscularConstruction);
drawMaterialRow("Void residue", 2, drawMaterialRow("Mineral exoskeletology", 4, MineralExoskeletology);
[this]{ return _currentProfile->voidResidue(); }, drawMaterialRow("Carbonized skin", 5, CarbonisedSkin);
[this](std::int32_t amount){ return _currentProfile->setVoidResidue(amount); }); drawMaterialRow("Isolated void particle", 6, IsolatedVoidParticle);
drawMaterialRow("Muscular construction", 3,
[this]{ return _currentProfile->muscularConstruction(); },
[this](std::int32_t amount){ return _currentProfile->setMuscularConstruction(amount); });
drawMaterialRow("Mineral exoskeletology", 4,
[this]{ return _currentProfile->mineralExoskeletology(); },
[this](std::int32_t amount){ return _currentProfile->setMineralExoskeletology(amount); });
drawMaterialRow("Carbonized skin", 5,
[this]{ return _currentProfile->carbonisedSkin(); },
[this](std::int32_t amount){ return _currentProfile->setCarbonisedSkin(amount); });
drawMaterialRow("Isolated void particle", 6,
[this]{ return _currentProfile->isolatedVoidParticle(); },
[this](std::int32_t amount){ return _currentProfile->setIsolatedVoidParticle(amount); });
drawUnavailableMaterialRow("Weaponised physiology", 7); drawUnavailableMaterialRow("Weaponised physiology", 7);
ImGui::EndTable(); ImGui::EndTable();
} }
} }
template<typename Getter, typename Setter>
void void
SaveTool::drawMaterialRow(Containers::StringView name, std::int32_t tier, Getter getter, Setter setter) { SaveTool::drawMaterialRow(Containers::StringView name, std::int32_t tier, MaterialID id) {
static_assert(std::is_same<decltype(getter()), std::int32_t>::value, "getter doesn't return an std::int32_t, 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 std::int32_t as an argument.");
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
ImGui::Text("T%i", tier); ImGui::Text("T%i", tier);
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::TextUnformatted(name.data()); ImGui::TextUnformatted(name.data());
ImGui::TableSetColumnIndex(2); ImGui::TableSetColumnIndex(2);
if(getter() != -1) { ImGui::Text("%i", _currentProfile->material(id));
ImGui::Text("%i", getter());
if(conf().cheatMode()) { if(conf().cheatMode()) {
ImGui::TableSetColumnIndex(3); ImGui::TableSetColumnIndex(3);
ImGui::PushID(name.data()); ImGui::PushID(name.data());
static std::int32_t var = 0; static std::int32_t var = 0;
if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_EDIT)) { if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_EDIT)) {
(var) = getter(); var = _currentProfile->material(id);
ImGui::OpenPopup("int_edit"); ImGui::OpenPopup("int_edit");
} }
drawTooltip("Edit"); drawTooltip("Edit");
if(drawIntEditPopup(&(var), 9999)) { if(drawIntEditPopup(&var, 9999)) {
if(!setter(var)) { if(!_currentProfile->setMaterial(id, var)) {
_queue.addToast(Toast::Type::Error, _currentProfile->lastError()); _queue.addToast(Toast::Type::Error, _currentProfile->lastError());
} }
} }
ImGui::PopID(); ImGui::PopID();
} }
} }
else {
ImGui::TextDisabled("Not found in the save file");
}
}
void void
SaveTool::drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier) { SaveTool::drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier) {