mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 05:05:19 -05:00
Fixed localization issues when using the content registry
This commit is contained in:
@@ -20,7 +20,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
using Style = hex::ContentRegistry::DataInspector::NumberDisplayStyle;
|
||||
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.binary"_lang, sizeof(u8), [](auto buffer, auto endian, auto style) {
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.binary", sizeof(u8), [](auto buffer, auto endian, auto style) {
|
||||
std::string binary;
|
||||
for (u8 i = 0; i < 8; i++)
|
||||
binary += ((buffer[0] << i) & 0x80) == 0 ? '0' : '1';
|
||||
@@ -28,76 +28,76 @@ namespace hex::plugin::builtin {
|
||||
return [binary] { ImGui::TextUnformatted(binary.c_str()); };
|
||||
});
|
||||
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.u8"_lang, sizeof(u8), [](auto buffer, auto endian, auto style) {
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.u8", sizeof(u8), [](auto buffer, auto endian, auto style) {
|
||||
auto format = (style == Style::Decimal) ? "%u" : ((style == Style::Hexadecimal) ? "0x%X" : "0o%o");
|
||||
auto value = hex::format(format, *reinterpret_cast<u8*>(buffer.data()));
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); };
|
||||
});
|
||||
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.s8"_lang, sizeof(s8), [](auto buffer, auto endian, auto style) {
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.s8", sizeof(s8), [](auto buffer, auto endian, auto style) {
|
||||
auto format = (style == Style::Decimal) ? "%d" : ((style == Style::Hexadecimal) ? "0x%X" : "0o%o");
|
||||
auto value = hex::format(format, *reinterpret_cast<s8*>(buffer.data()));
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); };
|
||||
});
|
||||
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.u16"_lang, sizeof(u16), [](auto buffer, auto endian, auto style) {
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.u16", sizeof(u16), [](auto buffer, auto endian, auto style) {
|
||||
auto format = (style == Style::Decimal) ? "%u" : ((style == Style::Hexadecimal) ? "0x%X" : "0o%o");
|
||||
auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast<u16*>(buffer.data()), endian));
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); };
|
||||
});
|
||||
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.s16"_lang, sizeof(s16), [](auto buffer, auto endian, auto style) {
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.s16", sizeof(s16), [](auto buffer, auto endian, auto style) {
|
||||
auto format = (style == Style::Decimal) ? "%d" : ((style == Style::Hexadecimal) ? "0x%X" : "0o%o");
|
||||
auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast<s16*>(buffer.data()), endian));
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); };
|
||||
});
|
||||
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.u32"_lang, sizeof(u32), [](auto buffer, auto endian, auto style) {
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.u32", sizeof(u32), [](auto buffer, auto endian, auto style) {
|
||||
auto format = (style == Style::Decimal) ? "%u" : ((style == Style::Hexadecimal) ? "0x%X" : "0o%o");
|
||||
auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast<u32*>(buffer.data()), endian));
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); };
|
||||
});
|
||||
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.s32"_lang, sizeof(s32), [](auto buffer, auto endian, auto style) {
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.s32", sizeof(s32), [](auto buffer, auto endian, auto style) {
|
||||
auto format = (style == Style::Decimal) ? "%d" : ((style == Style::Hexadecimal) ? "0x%X" : "0o%o");
|
||||
auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast<s32*>(buffer.data()), endian));
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); };
|
||||
});
|
||||
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.u64"_lang, sizeof(u64), [](auto buffer, auto endian, auto style) {
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.u64", sizeof(u64), [](auto buffer, auto endian, auto style) {
|
||||
auto format = (style == Style::Decimal) ? "%llu" : ((style == Style::Hexadecimal) ? "0x%llX" : "0o%llo");
|
||||
auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast<u64*>(buffer.data()), endian));
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); };
|
||||
});
|
||||
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.s64"_lang, sizeof(s64), [](auto buffer, auto endian, auto style) {
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.s64", sizeof(s64), [](auto buffer, auto endian, auto style) {
|
||||
auto format = (style == Style::Decimal) ? "%lld" : ((style == Style::Hexadecimal) ? "0x%llX" : "0o%llo");
|
||||
auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast<s64*>(buffer.data()), endian));
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); };
|
||||
});
|
||||
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.float"_lang, sizeof(float), [](auto buffer, auto endian, auto style) {
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.float", sizeof(float), [](auto buffer, auto endian, auto style) {
|
||||
auto value = hex::format("%e", hex::changeEndianess(*reinterpret_cast<float*>(buffer.data()), endian));
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); };
|
||||
});
|
||||
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.double"_lang, sizeof(double), [](auto buffer, auto endian, auto style) {
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.double", sizeof(double), [](auto buffer, auto endian, auto style) {
|
||||
auto value = hex::format("%e", hex::changeEndianess(*reinterpret_cast<double*>(buffer.data()), endian));
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); };
|
||||
});
|
||||
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.ascii"_lang, sizeof(char8_t), [](auto buffer, auto endian, auto style) {
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.ascii", sizeof(char8_t), [](auto buffer, auto endian, auto style) {
|
||||
auto value = hex::format("'%s'", makePrintable(*reinterpret_cast<char8_t*>(buffer.data())).c_str());
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); };
|
||||
});
|
||||
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.wide"_lang, sizeof(char16_t), [](auto buffer, auto endian, auto style) {
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.wide", sizeof(char16_t), [](auto buffer, auto endian, auto style) {
|
||||
auto c = *reinterpret_cast<char16_t*>(buffer.data());
|
||||
auto value = hex::format("'%lc'", c == 0 ? '\x01' : hex::changeEndianess(c, endian));
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); };
|
||||
});
|
||||
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.utf8"_lang, sizeof(char8_t) * 4, [](auto buffer, auto endian, auto style) {
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.utf8", sizeof(char8_t) * 4, [](auto buffer, auto endian, auto style) {
|
||||
char utf8Buffer[5] = { 0 };
|
||||
char codepointString[5] = { 0 };
|
||||
u32 codepoint = 0;
|
||||
@@ -116,7 +116,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
#if defined(OS_WINDOWS) && defined(ARCH_64_BIT)
|
||||
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.time32"_lang, sizeof(__time32_t), [](auto buffer, auto endian, auto style) {
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.time32", sizeof(__time32_t), [](auto buffer, auto endian, auto style) {
|
||||
auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast<__time32_t*>(buffer.data()), endian);
|
||||
std::tm * ptm = _localtime32(&endianAdjustedTime);
|
||||
char timeBuffer[32];
|
||||
@@ -129,7 +129,7 @@ namespace hex::plugin::builtin {
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); };
|
||||
});
|
||||
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.time64"_lang, sizeof(__time64_t), [](auto buffer, auto endian, auto style) {
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.time64", sizeof(__time64_t), [](auto buffer, auto endian, auto style) {
|
||||
auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast<__time64_t*>(buffer.data()), endian);
|
||||
std::tm * ptm = _localtime64(&endianAdjustedTime);
|
||||
char timeBuffer[64];
|
||||
@@ -144,7 +144,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
#else
|
||||
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.time"_lang, sizeof(time_t), [](auto buffer, auto endian, auto style) {
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.time", sizeof(time_t), [](auto buffer, auto endian, auto style) {
|
||||
auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast<time_t*>(buffer.data()), endian);
|
||||
std::tm * ptm = localtime(&endianAdjustedTime);
|
||||
char timeBuffer[64];
|
||||
@@ -159,7 +159,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
#endif
|
||||
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.guid"_lang, sizeof(GUID), [](auto buffer, auto endian, auto style) {
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.guid", sizeof(GUID), [](auto buffer, auto endian, auto style) {
|
||||
GUID guid;
|
||||
std::memcpy(&guid, buffer.data(), sizeof(GUID));
|
||||
auto value = hex::format("%s{%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}",
|
||||
@@ -173,7 +173,7 @@ namespace hex::plugin::builtin {
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); };
|
||||
});
|
||||
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.rgba8"_lang, sizeof(u32), [](auto buffer, auto endian, auto style) {
|
||||
hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.rgba8", sizeof(u32), [](auto buffer, auto endian, auto style) {
|
||||
ImColor value(hex::changeEndianess(*reinterpret_cast<u32*>(buffer.data()), endian));
|
||||
|
||||
return [value] {
|
||||
|
||||
Reference in New Issue
Block a user