SaveTool: some more cleanup.

This commit is contained in:
Guillaume Jacquemin 2022-11-21 20:47:09 +01:00
parent df5fa7a39e
commit 1421257c4f
7 changed files with 27 additions and 25 deletions

View file

@ -203,7 +203,7 @@ void SaveTool::drawGeneralInfo() {
ImGui::Text("Last mission: 0x%x", _currentProfile->lastMissionId()); ImGui::Text("Last mission: 0x%x", _currentProfile->lastMissionId());
} }
drawTooltip("This is the last mission selected in the mission selection screen, not the last mission played.", drawTooltip("This is the last mission selected in the mission selection screen, not the last mission played.",
windowSize().x() * 0.35f); float(windowSize().x()) * 0.35f);
const Float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing(); const Float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
ImGui::Dummy({ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y - footer_height_to_reserve}); ImGui::Dummy({ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y - footer_height_to_reserve});
@ -643,7 +643,7 @@ auto SaveTool::drawDeleteMassPopup(int mass_index) -> ImGuiID {
return 0; return 0;
} }
ImGui::PushTextWrapPos(windowSize().x() * 0.40f); ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f);
if(_massManager->hangar(mass_index).state() == Mass::State::Invalid) { if(_massManager->hangar(mass_index).state() == Mass::State::Invalid) {
ImGui::Text("Are you sure you want to delete the invalid M.A.S.S. data in hangar %.2i ? This operation is irreversible.", ImGui::Text("Are you sure you want to delete the invalid M.A.S.S. data in hangar %.2i ? This operation is irreversible.",
mass_index + 1); mass_index + 1);
@ -687,7 +687,7 @@ auto SaveTool::drawDeleteStagedMassPopup(Containers::StringView filename) -> ImG
return ImGui::GetID("Confirmation##DeleteStagedMassConfirmation"); return ImGui::GetID("Confirmation##DeleteStagedMassConfirmation");
} }
ImGui::PushTextWrapPos(windowSize().x() * 0.40f); ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f);
ImGui::Text("Are you sure you want to delete the staged M.A.S.S. named %s ? This operation is irreversible.", ImGui::Text("Are you sure you want to delete the staged M.A.S.S. named %s ? This operation is irreversible.",
_massManager->stagedMasses().at(filename).data()); _massManager->stagedMasses().at(filename).data());
ImGui::PopTextWrapPos(); ImGui::PopTextWrapPos();

View file

@ -90,7 +90,7 @@ void SaveTool::drawMassViewer() {
_selectedWeaponPart = 0; _selectedWeaponPart = 0;
_selectedWeaponDecal = 0; _selectedWeaponDecal = 0;
_selectedWeaponAccessory = 0; _selectedWeaponAccessory = 0;
}; }
ImGui::EndTable(); ImGui::EndTable();
} }
@ -166,7 +166,7 @@ void SaveTool::drawGlobalStyles() {
ImGui::TextWrapped("In-game values are multiplied by 100. For example, 0.500 here is equal to 50 in-game."); ImGui::TextWrapped("In-game values are multiplied by 100. For example, 0.500 here is equal to 50 in-game.");
for(UnsignedInt i = 0; i < _currentMass->globalStyles().size(); i++) { for(UnsignedInt i = 0; i < _currentMass->globalStyles().size(); i++) {
ImGui::PushID(i); ImGui::PushID(int(i));
DCSResult result; DCSResult result;
result = drawCustomStyle(_currentMass->globalStyles()[i]); result = drawCustomStyle(_currentMass->globalStyles()[i]);
switch(result) { switch(result) {

View file

@ -43,7 +43,7 @@ void SaveTool::drawArmour() {
}; };
for(UnsignedInt i = 0; i < _currentMass->armourParts().size(); i++) { for(UnsignedInt i = 0; i < _currentMass->armourParts().size(); i++) {
ImGui::PushID(i); ImGui::PushID(int(i));
auto& part = _currentMass->armourParts()[i]; auto& part = _currentMass->armourParts()[i];
@ -126,7 +126,7 @@ void SaveTool::drawArmour() {
drawAlignedText("Showing/editing decal"); drawAlignedText("Showing/editing decal");
for(UnsignedInt j = 0; j < part.decals.size(); j++) { for(UnsignedInt j = 0; j < part.decals.size(); j++) {
ImGui::SameLine(); ImGui::SameLine();
ImGui::RadioButton(std::to_string(j + 1).c_str(), &_selectedArmourDecals[i], j); ImGui::RadioButton(std::to_string(j + 1).c_str(), &_selectedArmourDecals[i], int(j));
} }
drawDecalEditor(part.decals[_selectedArmourDecals[i]]); drawDecalEditor(part.decals[_selectedArmourDecals[i]]);
@ -141,7 +141,7 @@ void SaveTool::drawArmour() {
drawAlignedText("Showing/editing accessory"); drawAlignedText("Showing/editing accessory");
for(UnsignedInt j = 0; j < part.accessories.size(); j++) { for(UnsignedInt j = 0; j < part.accessories.size(); j++) {
ImGui::SameLine(); ImGui::SameLine();
ImGui::RadioButton(std::string{char(65 + j)}.c_str(), &_selectedArmourAccessories[i], j); ImGui::RadioButton(std::string{char(65 + j)}.c_str(), &_selectedArmourAccessories[i], int(j));
} }
drawAccessoryEditor(part.accessories[_selectedArmourAccessories[i]], _currentMass->armourCustomStyles()); drawAccessoryEditor(part.accessories[_selectedArmourAccessories[i]], _currentMass->armourCustomStyles());
@ -301,7 +301,7 @@ void SaveTool::drawCustomArmourStyles() {
ImGui::TextWrapped("In-game values are multiplied by 100. For example, 0.500 here is equal to 50 in-game."); ImGui::TextWrapped("In-game values are multiplied by 100. For example, 0.500 here is equal to 50 in-game.");
for(UnsignedInt i = 0; i < _currentMass->armourCustomStyles().size(); i++) { for(UnsignedInt i = 0; i < _currentMass->armourCustomStyles().size(); i++) {
ImGui::PushID(i); ImGui::PushID(int(i));
DCSResult result; DCSResult result;
result = drawCustomStyle(_currentMass->armourCustomStyles()[i]); result = drawCustomStyle(_currentMass->armourCustomStyles()[i]);
switch(result) { switch(result) {

View file

@ -291,7 +291,7 @@ void SaveTool::drawCustomFrameStyles() {
ImGui::TextWrapped("In-game values are multiplied by 100. For example, 0.500 here is equal to 50 in-game."); ImGui::TextWrapped("In-game values are multiplied by 100. For example, 0.500 here is equal to 50 in-game.");
for(UnsignedInt i = 0; i < _currentMass->frameCustomStyles().size(); i++) { for(UnsignedInt i = 0; i < _currentMass->frameCustomStyles().size(); i++) {
ImGui::PushID(i); ImGui::PushID(int(i));
DCSResult result; DCSResult result;
result = drawCustomStyle(_currentMass->frameCustomStyles()[i]); result = drawCustomStyle(_currentMass->frameCustomStyles()[i]);
switch(result) { switch(result) {

View file

@ -269,7 +269,7 @@ void SaveTool::drawWeaponCategory(Containers::StringView name, Containers::Array
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::PushID(i); ImGui::PushID(int(i));
if(ImGui::Selectable(weapon.name.data(), _currentWeapon == &weapon)) { if(ImGui::Selectable(weapon.name.data(), _currentWeapon == &weapon)) {
_currentWeapon = &weapon; _currentWeapon = &weapon;
@ -309,7 +309,7 @@ void SaveTool::drawWeaponCategory(Containers::StringView name, Containers::Array
ImGui::PopID(); ImGui::PopID();
if(weapon.attached == true) { if(weapon.attached) {
ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, 0x1F008CFFu); ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, 0x1F008CFFu);
} }
} }
@ -454,7 +454,9 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) {
return nullptr; return nullptr;
}(); }();
CORRADE_INTERNAL_ASSERT(map); if(!map) {
return;
}
if(map->find(part.id) != map->cend()) { if(map->find(part.id) != map->cend()) {
ImGui::TextUnformatted(map->at(part.id).data()); ImGui::TextUnformatted(map->at(part.id).data());
@ -531,7 +533,7 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) {
drawAlignedText("Showing/editing decal"); drawAlignedText("Showing/editing decal");
for(UnsignedLong i = 0; i < part.decals.size(); i++) { for(UnsignedLong i = 0; i < part.decals.size(); i++) {
ImGui::SameLine(); ImGui::SameLine();
ImGui::RadioButton(std::to_string(i + 1).c_str(), &_selectedWeaponDecal, i); ImGui::RadioButton(std::to_string(i + 1).c_str(), &_selectedWeaponDecal, int(i));
} }
drawDecalEditor(part.decals[_selectedWeaponDecal]); drawDecalEditor(part.decals[_selectedWeaponDecal]);
@ -546,7 +548,7 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) {
drawAlignedText("Showing/editing accessory"); drawAlignedText("Showing/editing accessory");
for(UnsignedLong i = 0; i < part.accessories.size(); i++) { for(UnsignedLong i = 0; i < part.accessories.size(); i++) {
ImGui::SameLine(); ImGui::SameLine();
ImGui::RadioButton(std::string{char(65 + i)}.c_str(), &_selectedWeaponAccessory, i); ImGui::RadioButton(std::string{char(65 + i)}.c_str(), &_selectedWeaponAccessory, int(i));
} }
drawAccessoryEditor(part.accessories[_selectedWeaponAccessory], weapon.customStyles); drawAccessoryEditor(part.accessories[_selectedWeaponAccessory], weapon.customStyles);

View file

@ -85,7 +85,7 @@ void SaveTool::drawProfileManager() {
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
ImGui::PushID(i); ImGui::PushID(int(i));
if(ImGui::Selectable(profile.companyName().data(), false, if(ImGui::Selectable(profile.companyName().data(), false,
ImGuiSelectableFlags_SpanAllColumns|ImGuiSelectableFlags_AllowItemOverlap)) ImGuiSelectableFlags_SpanAllColumns|ImGuiSelectableFlags_AllowItemOverlap))
{ {
@ -138,7 +138,7 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID {
if(ImGui::BeginPopupModal("Restore backup", nullptr, if(ImGui::BeginPopupModal("Restore backup", nullptr,
ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_AlwaysAutoResize)) ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_AlwaysAutoResize))
{ {
ImGui::PushTextWrapPos(windowSize().x() * 0.40f); ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f);
ImGui::Text("Are you sure you want to restore the %s backup from %.4i-%.2i-%.2i %.2i:%.2i:%.2i ? Any existing data will be overwritten.", ImGui::Text("Are you sure you want to restore the %s backup from %.4i-%.2i-%.2i %.2i:%.2i:%.2i ? Any existing data will be overwritten.",
_profileManager->backups()[backup_index].company.data(), _profileManager->backups()[backup_index].company.data(),
_profileManager->backups()[backup_index].timestamp.year, _profileManager->backups()[backup_index].timestamp.year,
@ -181,7 +181,7 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID {
if(ImGui::BeginPopupModal("Delete backup", nullptr, if(ImGui::BeginPopupModal("Delete backup", nullptr,
ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_AlwaysAutoResize)) ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_AlwaysAutoResize))
{ {
ImGui::PushTextWrapPos(windowSize().x() * 0.40f); ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f);
ImGui::Text("Are you sure you want to delete the %s backup from %.4i-%.2i-%.2i %.2i:%.2i:%.2i ? This operation is irreversible.", ImGui::Text("Are you sure you want to delete the %s backup from %.4i-%.2i-%.2i %.2i:%.2i:%.2i ? This operation is irreversible.",
_profileManager->backups()[backup_index].company.data(), _profileManager->backups()[backup_index].company.data(),
_profileManager->backups()[backup_index].timestamp.year, _profileManager->backups()[backup_index].timestamp.year,
@ -284,7 +284,7 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID {
ImGui::TextUnformatted(backup.type == ProfileType::Demo ? "Demo" : "Full"); ImGui::TextUnformatted(backup.type == ProfileType::Demo ? "Demo" : "Full");
ImGui::TableSetColumnIndex(3); ImGui::TableSetColumnIndex(3);
ImGui::PushID(i); ImGui::PushID(int(i));
if(ImGui::SmallButton(ICON_FA_UNDO)) { if(ImGui::SmallButton(ICON_FA_UNDO)) {
backup_index = i; backup_index = i;
ImGui::OpenPopup(restore_backup_popup_id); ImGui::OpenPopup(restore_backup_popup_id);
@ -380,7 +380,7 @@ auto SaveTool::drawDeleteProfilePopup(std::size_t profile_index) -> ImGuiID {
delete_builds = false; delete_builds = false;
} }
ImGui::PushTextWrapPos(windowSize().x() * 0.40f); ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f);
ImGui::Text("Are you sure you want to delete the %s profile named %s ? This operation is irreversible.", ImGui::Text("Are you sure you want to delete the %s profile named %s ? This operation is irreversible.",
_profileManager->profiles()[profile_index].isDemo() ? "demo" : "full game", _profileManager->profiles()[profile_index].isDemo() ? "demo" : "full game",
_profileManager->profiles()[profile_index].companyName().data()); _profileManager->profiles()[profile_index].companyName().data());

View file

@ -75,7 +75,7 @@ void SaveTool::updateCheckEvent(SDL_Event& event) {
} }
bool operator>(const Version& other) const { bool operator>(const Version& other) const {
if((fullVersion > other.fullVersion) || if((fullVersion > other.fullVersion) ||
(fullVersion == other.fullVersion && prerelease == false && other.prerelease == true)) (fullVersion == other.fullVersion && !prerelease && other.prerelease))
{ {
return true; return true;
} }
@ -83,7 +83,7 @@ void SaveTool::updateCheckEvent(SDL_Event& event) {
return false; return false;
} }
} }
operator Containers::String() const { explicit operator Containers::String() const {
return Utility::format("{}.{}.{}{}", major, minor, patch, prerelease ? "-pre" : ""); return Utility::format("{}.{}.{}{}", major, minor, patch, prerelease ? "-pre" : "");
} }
}; };
@ -99,14 +99,14 @@ void SaveTool::updateCheckEvent(SDL_Event& event) {
_queue.addToast(Toast::Type::Warning, "Your version is out of date.\nCheck the settings for more information."_s, _queue.addToast(Toast::Type::Warning, "Your version is out of date.\nCheck the settings for more information."_s,
std::chrono::milliseconds{5000}); std::chrono::milliseconds{5000});
_updateAvailable = true; _updateAvailable = true;
_latestVersion = latest_ver; _latestVersion = Containers::String{latest_ver};
_releaseLink = Utility::format("https://williamjcm.ovh/git/williamjcm/MassBuilderSaveTool/releases/tag/v{}", components.front()); _releaseLink = Utility::format("https://williamjcm.ovh/git/williamjcm/MassBuilderSaveTool/releases/tag/v{}", components.front());
_downloadLink = components.back(); _downloadLink = components.back();
} }
else if(latest_ver == current_ver || (current_ver > latest_ver && current_ver.prerelease == true)) { else if(latest_ver == current_ver || (current_ver > latest_ver && current_ver.prerelease)) {
_queue.addToast(Toast::Type::Success, "The application is already up to date."_s); _queue.addToast(Toast::Type::Success, "The application is already up to date."_s);
} }
else if(current_ver > latest_ver && current_ver.prerelease == false) { else if(current_ver > latest_ver && !current_ver.prerelease) {
_queue.addToast(Toast::Type::Warning, "Your version is more recent than the latest one in the repo. How???"_s); _queue.addToast(Toast::Type::Warning, "Your version is more recent than the latest one in the repo. How???"_s);
} }
} }