1.5: Fuckin' UE5... #38

Manually merged
williamjcm merged 126 commits from one-point-five into master 2024-07-22 11:06:13 +02:00
4 changed files with 100 additions and 484 deletions
Showing only changes of commit 03472e56dc - Show all commits

View file

@ -133,33 +133,33 @@ Profile::refreshValues() {
_lastMissionId = prop ? prop->value : 0;
LOG_INFO("Getting the materials.");
_verseSteel = getResource(PROFILE_MATERIAL, VerseSteel);
_undinium = getResource(PROFILE_MATERIAL, Undinium);
_necriumAlloy = getResource(PROFILE_MATERIAL, NecriumAlloy);
_lunarite = getResource(PROFILE_MATERIAL, Lunarite);
_asterite = getResource(PROFILE_MATERIAL, Asterite);
_halliteFragma = getResource(PROFILE_MATERIAL, HalliteFragma);
_materials[VerseSteel] = getResource(PROFILE_MATERIAL, VerseSteel);
_materials[Undinium] = getResource(PROFILE_MATERIAL, Undinium);
_materials[NecriumAlloy] = getResource(PROFILE_MATERIAL, NecriumAlloy);
_materials[Lunarite] = getResource(PROFILE_MATERIAL, Lunarite);
_materials[Asterite] = getResource(PROFILE_MATERIAL, Asterite);
_materials[HalliteFragma] = getResource(PROFILE_MATERIAL, HalliteFragma);
_ednil = getResource(PROFILE_MATERIAL, Ednil);
_nuflalt = getResource(PROFILE_MATERIAL, Nuflalt);
_aurelene = getResource(PROFILE_MATERIAL, Aurelene);
_soldus = getResource(PROFILE_MATERIAL, Soldus);
_synthesisedN = getResource(PROFILE_MATERIAL, SynthesisedN);
_nanoc = getResource(PROFILE_MATERIAL, Nanoc);
_materials[Ednil] = getResource(PROFILE_MATERIAL, Ednil);
_materials[Nuflalt] = getResource(PROFILE_MATERIAL, Nuflalt);
_materials[Aurelene] = getResource(PROFILE_MATERIAL, Aurelene);
_materials[Soldus] = getResource(PROFILE_MATERIAL, Soldus);
_materials[SynthesisedN] = getResource(PROFILE_MATERIAL, SynthesisedN);
_materials[Nanoc] = getResource(PROFILE_MATERIAL, Nanoc);
_alcarbonite = getResource(PROFILE_MATERIAL, Alcarbonite);
_keriphene = getResource(PROFILE_MATERIAL, Keriphene);
_nitinolCM = getResource(PROFILE_MATERIAL, NitinolCM);
_quarkium = getResource(PROFILE_MATERIAL, Quarkium);
_alterene = getResource(PROFILE_MATERIAL, Alterene);
_cosmium = getResource(PROFILE_MATERIAL, Cosmium);
_materials[Alcarbonite] = getResource(PROFILE_MATERIAL, Alcarbonite);
_materials[Keriphene] = getResource(PROFILE_MATERIAL, Keriphene);
_materials[NitinolCM] = getResource(PROFILE_MATERIAL, NitinolCM);
_materials[Quarkium] = getResource(PROFILE_MATERIAL, Quarkium);
_materials[Alterene] = getResource(PROFILE_MATERIAL, Alterene);
_materials[Cosmium] = getResource(PROFILE_MATERIAL, Cosmium);
_mixedComposition = getResource(PROFILE_QUARK_DATA, MixedComposition);
_voidResidue = getResource(PROFILE_QUARK_DATA, VoidResidue);
_muscularConstruction = getResource(PROFILE_QUARK_DATA, MuscularConstruction);
_mineralExoskeletology = getResource(PROFILE_QUARK_DATA, MineralExoskeletology);
_carbonisedSkin = getResource(PROFILE_QUARK_DATA, CarbonisedSkin);
_isolatedVoidParticle = getResource(PROFILE_QUARK_DATA, IsolatedVoidParticle);
_materials[MixedComposition] = getResource(PROFILE_QUARK_DATA, MixedComposition);
_materials[VoidResidue] = getResource(PROFILE_QUARK_DATA, VoidResidue);
_materials[MuscularConstruction] = getResource(PROFILE_QUARK_DATA, MuscularConstruction);
_materials[MineralExoskeletology] = getResource(PROFILE_QUARK_DATA, MineralExoskeletology);
_materials[CarbonisedSkin] = getResource(PROFILE_QUARK_DATA, CarbonisedSkin);
_materials[IsolatedVoidParticle] = getResource(PROFILE_QUARK_DATA, IsolatedVoidParticle);
_valid = true;
}
@ -252,264 +252,13 @@ Profile::lastMissionId() const {
}
std::int32_t
Profile::verseSteel() const {
return _verseSteel;
Profile::material(MaterialID id) const {
return _materials.at(id);
}
bool
Profile::setVerseSteel(std::int32_t amount) {
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) {
Profile::setMaterial(MaterialID id, std::int32_t amount) {
Containers::StringView container = id > MixedComposition ? PROFILE_QUARK_DATA : PROFILE_MATERIAL;
auto mats_prop = _profile.at<ArrayProperty>(container);
if(!mats_prop) {
@ -549,3 +298,20 @@ Profile::setResource(Containers::StringView container, MaterialID id, std::int32
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
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <map>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringView.h>
@ -60,81 +62,11 @@ class Profile {
std::int32_t lastMissionId() const;
std::int32_t verseSteel() const;
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);
std::int32_t material(MaterialID id) const;
bool setMaterial(MaterialID id, std::int32_t amount);
private:
std::int32_t getResource(Containers::StringView container, MaterialID id);
bool setResource(Containers::StringView container, MaterialID id, std::int32_t amount);
Containers::String _filename;
@ -148,33 +80,7 @@ class Profile {
std::int32_t _storyProgress = 0;
std::int32_t _lastMissionId = 0;
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;
std::map<MaterialID, std::int32_t> _materials;
Containers::String _account;

View file

@ -125,8 +125,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
bool drawRenamePopup(Containers::ArrayView<char> name_view);
void drawGeneralInfo();
void drawResearchInventory();
template<typename Getter, typename Setter>
void drawMaterialRow(Containers::StringView name, std::int32_t tier, Getter getter, Setter setter);
void drawMaterialRow(Containers::StringView name, std::int32_t tier, MaterialID id);
void drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier);
void drawMassManager();
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"
"or click on it while holding Ctrl to edit the value directly.");
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);
ImGui::SameLine();
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);
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 1;
};
drawUnsafeWidget([](auto... args){ return ImGui::InputText("", args...); },
drawUnsafeWidget([](auto... args){ return ImGui::InputText("##NameField", args...); },
name_view.data(), name_view.size(),
ImGuiInputTextFlags_CallbackCharFilter,
callback, nullptr);
@ -298,139 +300,82 @@ SaveTool::drawResearchInventory() {
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableSetColumnIndex(1);
ImGui::Text("Engine materials");
ImGui::TextUnformatted("Engine materials");
drawMaterialRow("Verse steel", 1,
[this]{ return _currentProfile->verseSteel(); },
[this](std::int32_t amount){ return _currentProfile->setVerseSteel(amount); });
drawMaterialRow("Undinium", 2,
[this]{ return _currentProfile->undinium(); },
[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); });
drawMaterialRow("Verse steel", 1, VerseSteel);
drawMaterialRow("Undinium", 2, Undinium);
drawMaterialRow("Necrium alloy", 3, NecriumAlloy);
drawMaterialRow("Lunarite", 4, Lunarite);
drawMaterialRow("Asterite", 5, Asterite);
drawMaterialRow("Hallite fragma", 6, HalliteFragma);
drawUnavailableMaterialRow("Unnoctinium", 7);
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableSetColumnIndex(1);
ImGui::Text("OS materials");
ImGui::TextUnformatted("OS materials");
drawMaterialRow("Ednil", 1,
[this]{ return _currentProfile->ednil(); },
[this](std::int32_t amount){ return _currentProfile->setEdnil(amount); });
drawMaterialRow("Nuflalt", 2,
[this]{ return _currentProfile->nuflalt(); },
[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); });
drawMaterialRow("Ednil", 1, Ednil);
drawMaterialRow("Nuflalt", 2, Nuflalt);
drawMaterialRow("Aurelene", 3, Aurelene);
drawMaterialRow("Soldus", 4, Soldus);
drawMaterialRow("Synthesized N", 5, SynthesisedN);
drawMaterialRow("Nanoc", 6, Nanoc);
drawUnavailableMaterialRow("Abyssillite", 7);
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableSetColumnIndex(1);
ImGui::Text("Architect materials");
ImGui::TextUnformatted("Architect materials");
drawMaterialRow("Alcarbonite", 1,
[this]{ return _currentProfile->alcarbonite(); },
[this](std::int32_t amount){ return _currentProfile->setAlcarbonite(amount); });
drawMaterialRow("Keripehene", 2,
[this]{ return _currentProfile->keriphene(); },
[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); });
drawMaterialRow("Alcarbonite", 1, Alcarbonite);
drawMaterialRow("Keriphene", 2, Keriphene);
drawMaterialRow("Nitinol-CM", 3, NitinolCM);
drawMaterialRow("Quarkium", 4, Quarkium);
drawMaterialRow("Alterene", 5, Alterene);
drawMaterialRow("Cosmium", 6, Cosmium);
drawUnavailableMaterialRow("Purified quarkium", 7);
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableSetColumnIndex(1);
ImGui::Text("Quark data");
ImGui::TextUnformatted("Quark data");
drawMaterialRow("Mixed composition", 1,
[this]{ return _currentProfile->mixedComposition(); },
[this](std::int32_t amount){ return _currentProfile->setMixedComposition(amount); });
drawMaterialRow("Void residue", 2,
[this]{ return _currentProfile->voidResidue(); },
[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); });
drawMaterialRow("Mixed composition", 1, MixedComposition);
drawMaterialRow("Void residue", 2, VoidResidue);
drawMaterialRow("Muscular construction", 3, MuscularConstruction);
drawMaterialRow("Mineral exoskeletology", 4, MineralExoskeletology);
drawMaterialRow("Carbonized skin", 5, CarbonisedSkin);
drawMaterialRow("Isolated void particle", 6, IsolatedVoidParticle);
drawUnavailableMaterialRow("Weaponised physiology", 7);
ImGui::EndTable();
}
}
template<typename Getter, typename Setter>
void
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.");
SaveTool::drawMaterialRow(Containers::StringView name, std::int32_t tier, MaterialID id) {
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::Text("T%i", tier);
ImGui::TableSetColumnIndex(1);
ImGui::TextUnformatted(name.data());
ImGui::TableSetColumnIndex(2);
if(getter() != -1) {
ImGui::Text("%i", getter());
ImGui::Text("%i", _currentProfile->material(id));
if(conf().cheatMode()) {
ImGui::TableSetColumnIndex(3);
ImGui::PushID(name.data());
static std::int32_t var = 0;
if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_EDIT)) {
(var) = getter();
var = _currentProfile->material(id);
ImGui::OpenPopup("int_edit");
}
drawTooltip("Edit");
if(drawIntEditPopup(&(var), 9999)) {
if(!setter(var)) {
if(drawIntEditPopup(&var, 9999)) {
if(!_currentProfile->setMaterial(id, var)) {
_queue.addToast(Toast::Type::Error, _currentProfile->lastError());
}
}
ImGui::PopID();
}
}
else {
ImGui::TextDisabled("Not found in the save file");
}
}
void
SaveTool::drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier) {