Application: improve how invalid IDs are handled.

This commit is contained in:
Guillaume Jacquemin 2024-12-07 15:13:14 +01:00
parent 9469518a4e
commit 9629047fbc
Signed by: williamjcm
SSH key fingerprint: SHA256:AYLOg+iTV0ElElnlu4vqM4edFazVdRiuQB0Y5LoKc4A

View file

@ -467,8 +467,8 @@ Application::drawWeaponEditor(GameObjects::Weapon& weapon) {
if(map->find(part.id) != map->cend()) { if(map->find(part.id) != map->cend()) {
ImGui::TextUnformatted(map->at(part.id).cbegin(), map->at(part.id).cend()); ImGui::TextUnformatted(map->at(part.id).cbegin(), map->at(part.id).cend());
} }
else if(part.id == -1) { else if(part.id < 0) {
ImGui::TextUnformatted("<none>"); ImGui::TextUnformatted("<invalid part ID>");
} }
else{ else{
ImGui::Text("ID: %i", part.id); ImGui::Text("ID: %i", part.id);
@ -498,7 +498,7 @@ Application::drawWeaponEditor(GameObjects::Weapon& weapon) {
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::SmallButton("Hide part " ICON_FA_QUESTION_CIRCLE)) { if(ImGui::SmallButton("Hide part " ICON_FA_QUESTION_CIRCLE)) {
part.id = 96 + (part.id / 100) * 100; part.id = 96 + part.id >= 0 ? (part.id / 100) * 100 : 0;
} }
drawTooltip(_selectedWeaponPart == 0 ? drawTooltip(_selectedWeaponPart == 0 ?
"This will hide the selected part, but not its accessories. " "This will hide the selected part, but not its accessories. "