Application: use iterators for TextUnformatted calls.

Corrade's string views aren't guaranteed to be null-terminated,
though most of them come from strings, which _are_
null-terminated. Still, safety first.
This commit is contained in:
Guillaume Jacquemin 2024-02-08 11:08:14 +01:00
parent 7ce726f933
commit 22f5fc947c
Signed by: williamjcm
SSH Key Fingerprint: SHA256:AYLOg+iTV0ElElnlu4vqM4edFazVdRiuQB0Y5LoKc4A
6 changed files with 11 additions and 10 deletions

View File

@ -421,7 +421,7 @@ Application::drawTooltip(Containers::StringView text, float wrap_pos) {
if(wrap_pos > 0.0f) {
ImGui::PushTextWrapPos(wrap_pos);
}
ImGui::TextUnformatted(text.data());
ImGui::TextUnformatted(text.cbegin(), text.cend());
if(wrap_pos > 0.0f) {
ImGui::PopTextWrapPos();
}

View File

@ -360,7 +360,7 @@ Application::drawMaterialRow(Containers::StringView name, std::int32_t tier, Gam
ImGui::TableSetColumnIndex(0);
ImGui::Text("T%i", tier);
ImGui::TableSetColumnIndex(1);
ImGui::TextUnformatted(name.data());
ImGui::TextUnformatted(name.cbegin(), name.cend());
ImGui::TableSetColumnIndex(2);
ImGui::Text("%i", _currentProfile->material(id));
if(conf().cheatMode()) {
@ -387,7 +387,7 @@ Application::drawUnavailableMaterialRow(Containers::StringView name, std::int32_
ImGui::TableSetColumnIndex(0);
ImGui::Text("T%i", tier);
ImGui::TableSetColumnIndex(1);
ImGui::TextUnformatted(name.begin(), name.end());
ImGui::TextUnformatted(name.cbegin(), name.cend());
ImGui::TableSetColumnIndex(2);
ImGui::TextDisabled("Unavailable as of game version " SAVETOOL_SUPPORTED_GAME_VERSION);
}
@ -480,7 +480,8 @@ Application::drawMassManager() {
ImGui::TextDisabled("<invalid>");
break;
case GameObjects::Mass::State::Valid:
ImGui::TextUnformatted(_massManager->hangar(i).name().data());
ImGui::TextUnformatted(_massManager->hangar(i).name().cbegin(),
_massManager->hangar(i).name().cend());
break;
}

View File

@ -319,7 +319,7 @@ Application::drawCustomStyle(GameObjects::CustomStyle& style) {
}
if(ImGui::BeginMenuBar()) {
ImGui::TextUnformatted(style.name.data());
ImGui::TextUnformatted(style.name.cbegin(), style.name.cend());
static Containers::StaticArray<33, char> name_buf{ValueInit};
if(ImGui::SmallButton(ICON_FA_EDIT " Rename")) {

View File

@ -257,7 +257,7 @@ Application::drawWeaponCategory(Containers::StringView name, Containers::ArrayVi
{
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableNextColumn();
ImGui::TextUnformatted(name.data());
ImGui::TextUnformatted(name.cbegin(), name.cend());
ImGui::PushID(payload_type.data());
@ -458,7 +458,7 @@ Application::drawWeaponEditor(GameObjects::Weapon& weapon) {
}
if(map->find(part.id) != map->cend()) {
ImGui::TextUnformatted(map->at(part.id).data());
ImGui::TextUnformatted(map->at(part.id).cbegin(), map->at(part.id).cend());
}
else if(part.id == -1) {
ImGui::TextUnformatted("<none>");

View File

@ -266,11 +266,11 @@ Application::drawBackupListPopup() {
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::TextUnformatted(backup.company.data());
ImGui::TextUnformatted(backup.company.cbegin(), backup.company.cend());
if(ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
for(const auto& file : backup.includedFiles) {
ImGui::TextUnformatted(file.data());
ImGui::TextUnformatted(file.cbegin());
}
ImGui::EndTooltip();
}

View File

@ -92,7 +92,7 @@ Application::drawAbout() {
if(ImGui::BeginChild("##GPL", {0.0f, float(windowSize().y()) * 0.3f}, ImGuiChildFlags_Border)) {
static auto licence = _rs.getRaw("COPYING");
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextUnformatted(licence.begin(), licence.end());
ImGui::TextUnformatted(licence.cbegin(), licence.cend());
ImGui::PopFont();
}
ImGui::EndChild();