From b278d242d03ba614779243ec9e9495fc95abea3d Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sun, 5 Oct 2025 15:15:55 +0200 Subject: strops format --- src/ui/imgui_extensions.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/ui/imgui_extensions.cpp') diff --git a/src/ui/imgui_extensions.cpp b/src/ui/imgui_extensions.cpp index 5a00648..4e8270a 100644 --- a/src/ui/imgui_extensions.cpp +++ b/src/ui/imgui_extensions.cpp @@ -1,4 +1,3 @@ -#include #include #include "ui.hpp" @@ -93,7 +92,7 @@ namespace ImGui for (int x = 0; x < config::country_count; x++) { char locale_str[20]; - snprintf(locale_str, 20, "country.%s", config::country_codes[x]); + strops::format(locale_str, 20, "country.%s", config::country_codes[x]); countries[x] = locale::get(locale_str); } @@ -227,7 +226,7 @@ namespace ImGui for (int i = 0; i < autocomplete_count; i++) { autocomplete_strings[i] = (char*)malloc(200); - snprintf(autocomplete_strings[i], 200, "%s (%s %s)", autocomplete_list[i].name, autocomplete_list[i].address.address1, autocomplete_list[i].address.address2); + strops::format(autocomplete_strings[i], 200, "%s (%s %s)", autocomplete_list[i].name, autocomplete_list[i].address.address1, autocomplete_list[i].address.address2); } int autocomplete_index = ImGui::TextInputWithAutocomplete(locale::get("contact.form.fullname"), @@ -355,10 +354,10 @@ namespace ImGui { if (strcmp(selected_tax_rate->country_code, "00") == 0) { char category_code_desc[MAX_LEN_LONG_DESC]; - snprintf(category_code_desc, MAX_LEN_LONG_DESC, "taxcategory.%s", selected_tax_rate->category_code); - snprintf(rate_str_buf, 40, "%s", locale::get(category_code_desc)); + strops::format(category_code_desc, MAX_LEN_LONG_DESC, "taxcategory.%s", selected_tax_rate->category_code); + strops::format(rate_str_buf, 40, "%s", locale::get(category_code_desc)); } - else snprintf(rate_str_buf, 40, "%s/%.1f%%", selected_tax_rate->country_code, selected_tax_rate->rate); + else strops::format(rate_str_buf, 40, "%s/%.1f%%", selected_tax_rate->country_code, selected_tax_rate->rate); } if (has_error) { @@ -374,10 +373,10 @@ namespace ImGui if (strcmp(buffer[n].country_code, "00") == 0) { char category_code_desc[MAX_LEN_LONG_DESC]; - snprintf(category_code_desc, MAX_LEN_LONG_DESC, "taxcategory.%s", buffer[n].category_code); - snprintf(rate_str_buf, 40, "%s", locale::get(category_code_desc)); + strops::format(category_code_desc, MAX_LEN_LONG_DESC, "taxcategory.%s", buffer[n].category_code); + strops::format(rate_str_buf, 40, "%s", locale::get(category_code_desc)); } - else snprintf(rate_str_buf, 40, "%s/%.1f%%", buffer[n].country_code, buffer[n].rate); + else strops::format(rate_str_buf, 40, "%s/%.1f%%", buffer[n].country_code, buffer[n].rate); if (ImGui::Selectable(rate_str_buf, is_selected)) { selected_tax_rate_index = n; @@ -458,7 +457,7 @@ namespace ImGui const char* items[] = { option1, option2 }; char ID[MAX_LEN_LONG_DESC]; - snprintf(ID, MAX_LEN_LONG_DESC, "Mode##%p", buffer); + strops::format(ID, MAX_LEN_LONG_DESC, "Mode##%p", buffer); if (ImGui::BeginCombo(ID, items[*buffer])) { for (int n = 0; n < 2; n++) { bool is_selected = (n == (int)*buffer); -- cgit v1.2.3-70-g09d2