Compare commits

..

No commits in common. "640a7d3cd05f6021ec2ae5a1389eb8cdde2527c2" and "847e07e88dbfde890c4e3a0e025d3811c018895a" have entirely different histories.

4 changed files with 484 additions and 100 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.");
_materials[VerseSteel] = getResource(PROFILE_MATERIAL, VerseSteel); _verseSteel = getResource(PROFILE_MATERIAL, VerseSteel);
_materials[Undinium] = getResource(PROFILE_MATERIAL, Undinium); _undinium = getResource(PROFILE_MATERIAL, Undinium);
_materials[NecriumAlloy] = getResource(PROFILE_MATERIAL, NecriumAlloy); _necriumAlloy = getResource(PROFILE_MATERIAL, NecriumAlloy);
_materials[Lunarite] = getResource(PROFILE_MATERIAL, Lunarite); _lunarite = getResource(PROFILE_MATERIAL, Lunarite);
_materials[Asterite] = getResource(PROFILE_MATERIAL, Asterite); _asterite = getResource(PROFILE_MATERIAL, Asterite);
_materials[HalliteFragma] = getResource(PROFILE_MATERIAL, HalliteFragma); _halliteFragma = getResource(PROFILE_MATERIAL, HalliteFragma);
_materials[Ednil] = getResource(PROFILE_MATERIAL, Ednil); _ednil = getResource(PROFILE_MATERIAL, Ednil);
_materials[Nuflalt] = getResource(PROFILE_MATERIAL, Nuflalt); _nuflalt = getResource(PROFILE_MATERIAL, Nuflalt);
_materials[Aurelene] = getResource(PROFILE_MATERIAL, Aurelene); _aurelene = getResource(PROFILE_MATERIAL, Aurelene);
_materials[Soldus] = getResource(PROFILE_MATERIAL, Soldus); _soldus = getResource(PROFILE_MATERIAL, Soldus);
_materials[SynthesisedN] = getResource(PROFILE_MATERIAL, SynthesisedN); _synthesisedN = getResource(PROFILE_MATERIAL, SynthesisedN);
_materials[Nanoc] = getResource(PROFILE_MATERIAL, Nanoc); _nanoc = getResource(PROFILE_MATERIAL, Nanoc);
_materials[Alcarbonite] = getResource(PROFILE_MATERIAL, Alcarbonite); _alcarbonite = getResource(PROFILE_MATERIAL, Alcarbonite);
_materials[Keriphene] = getResource(PROFILE_MATERIAL, Keriphene); _keriphene = getResource(PROFILE_MATERIAL, Keriphene);
_materials[NitinolCM] = getResource(PROFILE_MATERIAL, NitinolCM); _nitinolCM = getResource(PROFILE_MATERIAL, NitinolCM);
_materials[Quarkium] = getResource(PROFILE_MATERIAL, Quarkium); _quarkium = getResource(PROFILE_MATERIAL, Quarkium);
_materials[Alterene] = getResource(PROFILE_MATERIAL, Alterene); _alterene = getResource(PROFILE_MATERIAL, Alterene);
_materials[Cosmium] = getResource(PROFILE_MATERIAL, Cosmium); _cosmium = getResource(PROFILE_MATERIAL, Cosmium);
_materials[MixedComposition] = getResource(PROFILE_QUARK_DATA, MixedComposition); _mixedComposition = getResource(PROFILE_QUARK_DATA, MixedComposition);
_materials[VoidResidue] = getResource(PROFILE_QUARK_DATA, VoidResidue); _voidResidue = getResource(PROFILE_QUARK_DATA, VoidResidue);
_materials[MuscularConstruction] = getResource(PROFILE_QUARK_DATA, MuscularConstruction); _muscularConstruction = getResource(PROFILE_QUARK_DATA, MuscularConstruction);
_materials[MineralExoskeletology] = getResource(PROFILE_QUARK_DATA, MineralExoskeletology); _mineralExoskeletology = getResource(PROFILE_QUARK_DATA, MineralExoskeletology);
_materials[CarbonisedSkin] = getResource(PROFILE_QUARK_DATA, CarbonisedSkin); _carbonisedSkin = getResource(PROFILE_QUARK_DATA, CarbonisedSkin);
_materials[IsolatedVoidParticle] = getResource(PROFILE_QUARK_DATA, IsolatedVoidParticle); _isolatedVoidParticle = getResource(PROFILE_QUARK_DATA, IsolatedVoidParticle);
_valid = true; _valid = true;
} }
@ -252,13 +252,264 @@ Profile::lastMissionId() const {
} }
std::int32_t std::int32_t
Profile::material(MaterialID id) const { Profile::verseSteel() const {
return _materials.at(id); return _verseSteel;
} }
bool bool
Profile::setMaterial(MaterialID id, std::int32_t amount) { Profile::setVerseSteel(std::int32_t amount) {
Containers::StringView container = id > MixedComposition ? PROFILE_QUARK_DATA : PROFILE_MATERIAL; return setResource(PROFILE_MATERIAL, VerseSteel, amount);
}
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) {
@ -294,20 +545,3 @@ Profile::setMaterial(MaterialID id, std::int32_t amount) {
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,8 +16,6 @@
// 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>
@ -62,11 +60,81 @@ class Profile {
std::int32_t lastMissionId() const; std::int32_t lastMissionId() const;
std::int32_t material(MaterialID id) const; std::int32_t verseSteel() const;
bool setMaterial(MaterialID id, std::int32_t amount); bool setVerseSteel(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;
@ -80,7 +148,33 @@ class Profile {
std::int32_t _storyProgress = 0; std::int32_t _storyProgress = 0;
std::int32_t _lastMissionId = 0; std::int32_t _lastMissionId = 0;
std::map<MaterialID, std::int32_t> _materials; std::int32_t _verseSteel = 0;
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,7 +125,8 @@ 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();
void drawMaterialRow(Containers::StringView name, std::int32_t tier, MaterialID id); template<typename Getter, typename Setter>
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("##IntSlider", args...); }, drawUnsafeWidget([](auto... args){ return ImGui::SliderInt("", 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,15 +137,13 @@ 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 && if(data->EventChar < 256 && std::strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789- ", char(data->EventChar))) {
std::strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789- ", char(data->EventChar)))
{
return 0; return 0;
} }
return 1; return 1;
}; };
drawUnsafeWidget([](auto... args){ return ImGui::InputText("##NameField", args...); }, drawUnsafeWidget([](auto... args){ return ImGui::InputText("", args...); },
name_view.data(), name_view.size(), name_view.data(), name_view.size(),
ImGuiInputTextFlags_CallbackCharFilter, ImGuiInputTextFlags_CallbackCharFilter,
callback, nullptr); callback, nullptr);
@ -300,82 +298,139 @@ SaveTool::drawResearchInventory() {
ImGui::TableNextRow(ImGuiTableRowFlags_Headers); ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::TextUnformatted("Engine materials"); ImGui::Text("Engine materials");
drawMaterialRow("Verse steel", 1, VerseSteel); drawMaterialRow("Verse steel", 1,
drawMaterialRow("Undinium", 2, Undinium); [this]{ return _currentProfile->verseSteel(); },
drawMaterialRow("Necrium alloy", 3, NecriumAlloy); [this](std::int32_t amount){ return _currentProfile->setVerseSteel(amount); });
drawMaterialRow("Lunarite", 4, Lunarite); drawMaterialRow("Undinium", 2,
drawMaterialRow("Asterite", 5, Asterite); [this]{ return _currentProfile->undinium(); },
drawMaterialRow("Hallite fragma", 6, HalliteFragma); [this](std::int32_t amount){ return _currentProfile->setUndinium(amount); });
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::TextUnformatted("OS materials"); ImGui::Text("OS materials");
drawMaterialRow("Ednil", 1, Ednil); drawMaterialRow("Ednil", 1,
drawMaterialRow("Nuflalt", 2, Nuflalt); [this]{ return _currentProfile->ednil(); },
drawMaterialRow("Aurelene", 3, Aurelene); [this](std::int32_t amount){ return _currentProfile->setEdnil(amount); });
drawMaterialRow("Soldus", 4, Soldus); drawMaterialRow("Nuflalt", 2,
drawMaterialRow("Synthesized N", 5, SynthesisedN); [this]{ return _currentProfile->nuflalt(); },
drawMaterialRow("Nanoc", 6, Nanoc); [this](std::int32_t amount){ return _currentProfile->setNuflalt(amount); });
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::TextUnformatted("Architect materials"); ImGui::Text("Architect materials");
drawMaterialRow("Alcarbonite", 1, Alcarbonite); drawMaterialRow("Alcarbonite", 1,
drawMaterialRow("Keriphene", 2, Keriphene); [this]{ return _currentProfile->alcarbonite(); },
drawMaterialRow("Nitinol-CM", 3, NitinolCM); [this](std::int32_t amount){ return _currentProfile->setAlcarbonite(amount); });
drawMaterialRow("Quarkium", 4, Quarkium); drawMaterialRow("Keripehene", 2,
drawMaterialRow("Alterene", 5, Alterene); [this]{ return _currentProfile->keriphene(); },
drawMaterialRow("Cosmium", 6, Cosmium); [this](std::int32_t amount){ return _currentProfile->setKeriphene(amount); });
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::TextUnformatted("Quark data"); ImGui::Text("Quark data");
drawMaterialRow("Mixed composition", 1, MixedComposition); drawMaterialRow("Mixed composition", 1,
drawMaterialRow("Void residue", 2, VoidResidue); [this]{ return _currentProfile->mixedComposition(); },
drawMaterialRow("Muscular construction", 3, MuscularConstruction); [this](std::int32_t amount){ return _currentProfile->setMixedComposition(amount); });
drawMaterialRow("Mineral exoskeletology", 4, MineralExoskeletology); drawMaterialRow("Void residue", 2,
drawMaterialRow("Carbonized skin", 5, CarbonisedSkin); [this]{ return _currentProfile->voidResidue(); },
drawMaterialRow("Isolated void particle", 6, IsolatedVoidParticle); [this](std::int32_t amount){ return _currentProfile->setVoidResidue(amount); });
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, MaterialID id) { SaveTool::drawMaterialRow(Containers::StringView name, std::int32_t tier, Getter getter, Setter setter) {
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);
ImGui::Text("%i", _currentProfile->material(id)); if(getter() != -1) {
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 = _currentProfile->material(id); (var) = getter();
ImGui::OpenPopup("int_edit"); ImGui::OpenPopup("int_edit");
} }
drawTooltip("Edit"); drawTooltip("Edit");
if(drawIntEditPopup(&var, 9999)) { if(drawIntEditPopup(&(var), 9999)) {
if(!_currentProfile->setMaterial(id, var)) { if(!setter(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) {
@ -383,7 +438,7 @@ SaveTool::drawUnavailableMaterialRow(Containers::StringView name, std::int32_t t
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.begin(), name.end()); ImGui::TextUnformatted(name.data());
ImGui::TableSetColumnIndex(2); ImGui::TableSetColumnIndex(2);
ImGui::TextDisabled("Unavailable as of game version " SUPPORTED_GAME_VERSION); ImGui::TextDisabled("Unavailable as of game version " SUPPORTED_GAME_VERSION);
} }