fix print formatter

This commit is contained in:
Green Sky 2023-09-04 23:46:12 +02:00
parent 7a3823db78
commit c791f4c6a1
No known key found for this signature in database

View File

@ -4,6 +4,7 @@
#include <imgui.h> #include <imgui.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <imgui/misc/cpp/imgui_stdlib.h> #include <imgui/misc/cpp/imgui_stdlib.h>
#include <cinttypes>
namespace MM::ImGuiWidgets { namespace MM::ImGuiWidgets {
@ -55,16 +56,16 @@ void JsonViewerSimple(const char* name, const JsonObjectType& json) {
} }
break; break;
case JsonObjectType::value_t::number_integer: case JsonObjectType::value_t::number_integer:
ImGui::TextColored(int_color, "%ld", json.template get<int64_t>()); ImGui::TextColored(int_color, "%" PRId64, json.template get<int64_t>());
break; break;
case JsonObjectType::value_t::number_unsigned: case JsonObjectType::value_t::number_unsigned:
ImGui::TextColored(unsigned_color, "%lu", json.template get<uint64_t>()); ImGui::TextColored(unsigned_color, "%" PRIu64, json.template get<uint64_t>());
break; break;
case JsonObjectType::value_t::number_float: case JsonObjectType::value_t::number_float:
ImGui::TextColored(float_color, "%f", json.template get<float>()); ImGui::TextColored(float_color, "%f", json.template get<float>());
break; break;
case JsonObjectType::value_t::object: case JsonObjectType::value_t::object:
ImGui::TextDisabled("{%d}", json.size()); ImGui::TextDisabled("{%zu}", json.size());
ImGui::Indent(); ImGui::Indent();
for (auto& [key, value] : json.items()) { for (auto& [key, value] : json.items()) {
@ -74,7 +75,7 @@ void JsonViewerSimple(const char* name, const JsonObjectType& json) {
break; break;
case JsonObjectType::value_t::array: case JsonObjectType::value_t::array:
ImGui::TextDisabled("[%d]", json.size()); ImGui::TextDisabled("[%zu]", json.size());
ImGui::Indent(); ImGui::Indent();
for (auto& [key, value] : json.items()) { for (auto& [key, value] : json.items()) {
@ -103,9 +104,9 @@ void JsonViewerTree(const char* name, const JsonObjectType& json) {
ImGui::SameLine(); ImGui::SameLine();
if (json.is_object()) { if (json.is_object()) {
ImGui::TextDisabled("{%d}", json.size()); ImGui::TextDisabled("{%zu}", json.size());
} else { // is_array() } else { // is_array()
ImGui::TextDisabled("[%d]", json.size()); ImGui::TextDisabled("[%zu]", json.size());
} }
if (tree_open) { if (tree_open) {
@ -143,10 +144,10 @@ void JsonViewerTree(const char* name, const JsonObjectType& json) {
} }
break; break;
case JsonObjectType::value_t::number_integer: case JsonObjectType::value_t::number_integer:
ImGui::TextColored(int_color, "%ld", json.template get<int64_t>()); ImGui::TextColored(int_color, "%" PRId64, json.template get<int64_t>());
break; break;
case JsonObjectType::value_t::number_unsigned: case JsonObjectType::value_t::number_unsigned:
ImGui::TextColored(unsigned_color, "%lu", json.template get<uint64_t>()); ImGui::TextColored(unsigned_color, "%" PRIu64, json.template get<uint64_t>());
break; break;
case JsonObjectType::value_t::number_float: case JsonObjectType::value_t::number_float:
ImGui::TextColored(float_color, "%f", json.template get<float>()); ImGui::TextColored(float_color, "%f", json.template get<float>());
@ -200,9 +201,9 @@ void JsonEditor(const char* name, JsonObjectType& json) {
ImGui::SameLine(); ImGui::SameLine();
if (json.is_object()) { if (json.is_object()) {
ImGui::TextDisabled("{%d}", json.size()); ImGui::TextDisabled("{%zu}", json.size());
} else { // is_array() } else { // is_array()
ImGui::TextDisabled("[%d]", json.size()); ImGui::TextDisabled("[%zu]", json.size());
} }
if (tree_open) { if (tree_open) {