diff --git a/src/resource/xml/save.cpp b/src/resource/xml/save.cpp index 7e21b6a..387ac22 100644 --- a/src/resource/xml/save.cpp +++ b/src/resource/xml/save.cpp @@ -52,15 +52,15 @@ namespace game::resource::xml element->QueryIntAttribute("TotalFoodItemsEaten", &totalFoodItemsEaten); } - auto element = root->FirstChildElement("SkillCheck"); - if (!element) element = root->FirstChildElement("Play"); - if (element) + auto skillCheckElement = root->FirstChildElement("SkillCheck"); + if (!skillCheckElement) skillCheckElement = root->FirstChildElement("Play"); + if (skillCheckElement) { - element->QueryIntAttribute("TotalPlays", &skillCheck.totalPlays); - element->QueryIntAttribute("HighScore", &skillCheck.highScore); - element->QueryIntAttribute("BestCombo", &skillCheck.bestCombo); + skillCheckElement->QueryIntAttribute("TotalPlays", &skillCheck.totalPlays); + skillCheckElement->QueryIntAttribute("HighScore", &skillCheck.highScore); + skillCheckElement->QueryIntAttribute("BestCombo", &skillCheck.bestCombo); - if (auto child = element->FirstChildElement("Grades")) + if (auto child = skillCheckElement->FirstChildElement("Grades")) { for (auto gradeChild = child->FirstChildElement("Grade"); gradeChild; gradeChild = gradeChild->NextSiblingElement("Grade")) @@ -72,14 +72,14 @@ namespace game::resource::xml } } - if (auto element = root->FirstChildElement("Orbit")) + if (auto orbitElement = root->FirstChildElement("Orbit")) { - element->QueryIntAttribute("HighScore", &orbit.highScore); + orbitElement->QueryIntAttribute("HighScore", &orbit.highScore); } - if (auto element = root->FirstChildElement("Inventory")) + if (auto inventoryElement = root->FirstChildElement("Inventory")) { - for (auto child = element->FirstChildElement("Item"); child; child = child->NextSiblingElement("Item")) + for (auto child = inventoryElement->FirstChildElement("Item"); child; child = child->NextSiblingElement("Item")) { int id{}; int quantity{}; @@ -90,9 +90,9 @@ namespace game::resource::xml } } - if (auto element = root->FirstChildElement("Items")) + if (auto itemsElement = root->FirstChildElement("Items")) { - for (auto child = element->FirstChildElement("Item"); child; child = child->NextSiblingElement("Item")) + for (auto child = itemsElement->FirstChildElement("Item"); child; child = child->NextSiblingElement("Item")) { Item item{}; child->QueryIntAttribute("ID", &item.id); diff --git a/src/state/play/cheats.cpp b/src/state/play/cheats.cpp index 3699013..a2b82a9 100644 --- a/src/state/play/cheats.cpp +++ b/src/state/play/cheats.cpp @@ -19,17 +19,27 @@ namespace game::state::play if (ImGui::BeginChild("##Cheats")) { auto stage = character.stage + 1; + auto caloriesMin = 0.0; + auto maxCapacity = character.max_capacity(); + auto capacityMin = character.data.capacityMin; + auto capacityMax = character.data.capacityMax; + auto weightMin = character.data.weight; + auto weightMax = character.data.weightMax; + auto digestionRateMin = character.data.digestionRateMin; + auto digestionRateMax = character.data.digestionRateMax; + auto eatSpeedMin = character.data.eatSpeedMin; + auto eatSpeedMax = character.data.eatSpeedMax; auto weight_update = [&]() { character.queue_idle_animation(); }; - WIDGET_FX(ImGui::SliderFloat(strings.get(Strings::CheatsCalories).c_str(), &character.calories, 0, - character.max_capacity(), "%0.0f kcal")); - WIDGET_FX(ImGui::SliderFloat(strings.get(Strings::CheatsCapacity).c_str(), &character.capacity, - character.data.capacityMin, character.data.capacityMax, "%0.0f kcal")); + WIDGET_FX(ImGui::SliderScalar(strings.get(Strings::CheatsCalories).c_str(), ImGuiDataType_Double, + &character.calories, &caloriesMin, &maxCapacity, "%0.0f kcal")); + WIDGET_FX(ImGui::SliderScalar(strings.get(Strings::CheatsCapacity).c_str(), ImGuiDataType_Double, + &character.capacity, &capacityMin, &capacityMax, "%0.0f kcal")); - if (WIDGET_FX(ImGui::SliderFloat(strings.get(Strings::CheatsWeight).c_str(), &character.weight, - character.data.weight, character.data.weightMax, - strings.get(Strings::CheatsWeightFormat).c_str()))) + if (WIDGET_FX(ImGui::SliderScalar(strings.get(Strings::CheatsWeight).c_str(), ImGuiDataType_Double, + &character.weight, &weightMin, &weightMax, + strings.get(Strings::CheatsWeightFormat).c_str()))) weight_update(); if (WIDGET_FX(ImGui::SliderInt(strings.get(Strings::CheatsStage).c_str(), &stage, 1, @@ -41,12 +51,12 @@ namespace game::state::play weight_update(); } - WIDGET_FX(ImGui::SliderFloat(strings.get(Strings::CheatsDigestionRate).c_str(), &character.digestionRate, - character.data.digestionRateMin, character.data.digestionRateMax, - strings.get(Strings::CheatsDigestionRateFormat).c_str())); - WIDGET_FX(ImGui::SliderFloat(strings.get(Strings::CheatsEatSpeed).c_str(), &character.eatSpeed, - character.data.eatSpeedMin, character.data.eatSpeedMax, - strings.get(Strings::CheatsEatSpeedFormat).c_str())); + WIDGET_FX(ImGui::SliderScalar(strings.get(Strings::CheatsDigestionRate).c_str(), ImGuiDataType_Double, + &character.digestionRate, &digestionRateMin, &digestionRateMax, + strings.get(Strings::CheatsDigestionRateFormat).c_str())); + WIDGET_FX(ImGui::SliderScalar(strings.get(Strings::CheatsEatSpeed).c_str(), ImGuiDataType_Double, + &character.eatSpeed, &eatSpeedMin, &eatSpeedMax, + strings.get(Strings::CheatsEatSpeedFormat).c_str())); if (WIDGET_FX(ImGui::Button(strings.get(Strings::CheatsDigestButton).c_str()))) character.digestionProgress = entity::Character::DIGESTION_MAX;