From d2d36c221168a283de078e6e90417f24b9db33bf Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 18 Dec 2023 08:58:15 +0100 Subject: [PATCH] impr: Add localization to color picker tool --- plugins/builtin/romfs/lang/de_DE.json | 2 +- plugins/builtin/romfs/lang/en_US.json | 8 +++- plugins/builtin/romfs/lang/es_ES.json | 2 +- plugins/builtin/romfs/lang/it_IT.json | 2 +- plugins/builtin/romfs/lang/ja_JP.json | 2 +- plugins/builtin/romfs/lang/ko_KR.json | 2 +- plugins/builtin/romfs/lang/pt_BR.json | 2 +- plugins/builtin/romfs/lang/zh_CN.json | 2 +- plugins/builtin/romfs/lang/zh_TW.json | 2 +- .../source/content/tools/color_picker.cpp | 46 ++++++++++--------- 10 files changed, 39 insertions(+), 31 deletions(-) diff --git a/plugins/builtin/romfs/lang/de_DE.json b/plugins/builtin/romfs/lang/de_DE.json index e4a79b863..4ddf753aa 100644 --- a/plugins/builtin/romfs/lang/de_DE.json +++ b/plugins/builtin/romfs/lang/de_DE.json @@ -910,7 +910,7 @@ "hex.builtin.view.patches.name": "Patches", "hex.builtin.view.patches.offset": "Offset", "hex.builtin.view.patches.orig": "Originalwert", - "hex.builtin.view.patches.patch": "Patchwert", + "hex.builtin.view.patches.patch": "Beschreibung", "hex.builtin.view.patches.remove": "Patch entfernen", "hex.builtin.view.pattern_data.name": "Pattern Daten", "hex.builtin.view.pattern_editor.accept_pattern": "Pattern akzeptieren", diff --git a/plugins/builtin/romfs/lang/en_US.json b/plugins/builtin/romfs/lang/en_US.json index cf65cd29f..e3b79b6cf 100644 --- a/plugins/builtin/romfs/lang/en_US.json +++ b/plugins/builtin/romfs/lang/en_US.json @@ -633,6 +633,12 @@ "hex.builtin.tools.byte_swapper": "Byte Swapper", "hex.builtin.tools.calc": "Calculator", "hex.builtin.tools.color": "Color picker", + "hex.builtin.tools.color.components": "Components", + "hex.builtin.tools.color.formats": "Formats", + "hex.builtin.tools.color.formats.hex": "HEX", + "hex.builtin.tools.color.formats.vec4": "Vector4f", + "hex.builtin.tools.color.formats.percent": "Percentage", + "hex.builtin.tools.color.formats.color_name": "Color Name", "hex.builtin.tools.demangler": "LLVM Demangler", "hex.builtin.tools.demangler.demangled": "Demangled name", "hex.builtin.tools.demangler.mangled": "Mangled name", @@ -1036,7 +1042,7 @@ "hex.builtin.view.patches.name": "Patches", "hex.builtin.view.patches.offset": "Offset", "hex.builtin.view.patches.orig": "Original value", - "hex.builtin.view.patches.patch": "Patched value", + "hex.builtin.view.patches.patch": "Description", "hex.builtin.view.patches.remove": "Remove patch", "hex.builtin.view.pattern_data.name": "Pattern Data", "hex.builtin.view.pattern_editor.accept_pattern": "Accept pattern", diff --git a/plugins/builtin/romfs/lang/es_ES.json b/plugins/builtin/romfs/lang/es_ES.json index c3167feed..ebfb24364 100644 --- a/plugins/builtin/romfs/lang/es_ES.json +++ b/plugins/builtin/romfs/lang/es_ES.json @@ -909,7 +909,7 @@ "hex.builtin.view.patches.name": "Parches", "hex.builtin.view.patches.offset": "Offset", "hex.builtin.view.patches.orig": "Valor original", - "hex.builtin.view.patches.patch": "Valor parcheado", + "hex.builtin.view.patches.patch": "", "hex.builtin.view.patches.remove": "Eliminar parche", "hex.builtin.view.pattern_data.name": "Datos de Pattern", "hex.builtin.view.pattern_editor.accept_pattern": "Aceptar pattern", diff --git a/plugins/builtin/romfs/lang/it_IT.json b/plugins/builtin/romfs/lang/it_IT.json index d58004300..87b32826e 100644 --- a/plugins/builtin/romfs/lang/it_IT.json +++ b/plugins/builtin/romfs/lang/it_IT.json @@ -909,7 +909,7 @@ "hex.builtin.view.patches.name": "Patches", "hex.builtin.view.patches.offset": "Offset", "hex.builtin.view.patches.orig": "Valore Originale", - "hex.builtin.view.patches.patch": "Valore patchato", + "hex.builtin.view.patches.patch": "", "hex.builtin.view.patches.remove": "Rimuovi patch", "hex.builtin.view.pattern_data.name": "Dati dei Pattern", "hex.builtin.view.pattern_editor.accept_pattern": "Accetta pattern", diff --git a/plugins/builtin/romfs/lang/ja_JP.json b/plugins/builtin/romfs/lang/ja_JP.json index 47aafd296..c8776bdaa 100644 --- a/plugins/builtin/romfs/lang/ja_JP.json +++ b/plugins/builtin/romfs/lang/ja_JP.json @@ -909,7 +909,7 @@ "hex.builtin.view.patches.name": "パッチ", "hex.builtin.view.patches.offset": "オフセット", "hex.builtin.view.patches.orig": "元の値", - "hex.builtin.view.patches.patch": "パッチした値", + "hex.builtin.view.patches.patch": "", "hex.builtin.view.patches.remove": "パッチを削除", "hex.builtin.view.pattern_data.name": "パターンデータ", "hex.builtin.view.pattern_editor.accept_pattern": "使用できるパターン", diff --git a/plugins/builtin/romfs/lang/ko_KR.json b/plugins/builtin/romfs/lang/ko_KR.json index 8afa2a0e4..5063c8af0 100644 --- a/plugins/builtin/romfs/lang/ko_KR.json +++ b/plugins/builtin/romfs/lang/ko_KR.json @@ -923,7 +923,7 @@ "hex.builtin.view.patches.name": "패치", "hex.builtin.view.patches.offset": "오프셋", "hex.builtin.view.patches.orig": "원본 값", - "hex.builtin.view.patches.patch": "패치된 값", + "hex.builtin.view.patches.patch": "", "hex.builtin.view.patches.remove": "패치 제거", "hex.builtin.view.pattern_data.name": "패턴 데이터", "hex.builtin.view.pattern_editor.accept_pattern": "패턴 적용", diff --git a/plugins/builtin/romfs/lang/pt_BR.json b/plugins/builtin/romfs/lang/pt_BR.json index a93efd479..9f34eecc9 100644 --- a/plugins/builtin/romfs/lang/pt_BR.json +++ b/plugins/builtin/romfs/lang/pt_BR.json @@ -909,7 +909,7 @@ "hex.builtin.view.patches.name": "Patches", "hex.builtin.view.patches.offset": "Desvio", "hex.builtin.view.patches.orig": "Valor Original", - "hex.builtin.view.patches.patch": "Valor Atualizado", + "hex.builtin.view.patches.patch": "", "hex.builtin.view.patches.remove": "Remover Atualização", "hex.builtin.view.pattern_data.name": "Padrão de Dados", "hex.builtin.view.pattern_editor.accept_pattern": "Aceitar padrão", diff --git a/plugins/builtin/romfs/lang/zh_CN.json b/plugins/builtin/romfs/lang/zh_CN.json index 813e6acf0..426db4cf9 100644 --- a/plugins/builtin/romfs/lang/zh_CN.json +++ b/plugins/builtin/romfs/lang/zh_CN.json @@ -923,7 +923,7 @@ "hex.builtin.view.patches.name": "补丁", "hex.builtin.view.patches.offset": "偏移", "hex.builtin.view.patches.orig": "原始值", - "hex.builtin.view.patches.patch": "修改值", + "hex.builtin.view.patches.patch": "", "hex.builtin.view.patches.remove": "移除补丁", "hex.builtin.view.pattern_data.name": "模式数据", "hex.builtin.view.pattern_editor.accept_pattern": "接受模式", diff --git a/plugins/builtin/romfs/lang/zh_TW.json b/plugins/builtin/romfs/lang/zh_TW.json index 9d0598200..415d175bb 100644 --- a/plugins/builtin/romfs/lang/zh_TW.json +++ b/plugins/builtin/romfs/lang/zh_TW.json @@ -923,7 +923,7 @@ "hex.builtin.view.patches.name": "修補程式", "hex.builtin.view.patches.offset": "位移", "hex.builtin.view.patches.orig": "原始數值", - "hex.builtin.view.patches.patch": "修補後的值", + "hex.builtin.view.patches.patch": "", "hex.builtin.view.patches.remove": "移除修補程式", "hex.builtin.view.pattern_data.name": "模式資料", "hex.builtin.view.pattern_editor.accept_pattern": "接受模式", diff --git a/plugins/builtin/source/content/tools/color_picker.cpp b/plugins/builtin/source/content/tools/color_picker.cpp index 986f5dc64..7e23cd08f 100644 --- a/plugins/builtin/source/content/tools/color_picker.cpp +++ b/plugins/builtin/source/content/tools/color_picker.cpp @@ -18,24 +18,24 @@ namespace hex::plugin::builtin { static std::string rgba8; struct BitValue { - int bits; - float color; - float saturationMultiplier; - char name; - u8 index; + int bits; + float color; + float saturationMultiplier; + const char *name; + u8 index; }; static std::array bitValues = { - BitValue{ 8, 0.00F, 1.0F, 'R', 0 }, - BitValue{ 8, 0.33F, 1.0F, 'G', 1 }, - BitValue{ 8, 0.66F, 1.0F, 'B', 2 }, - BitValue{ 8, 0.00F, 0.0F, 'A', 3 } + BitValue{ 8, 0.00F, 1.0F, "R", 0 }, + BitValue{ 8, 0.33F, 1.0F, "G", 1 }, + BitValue{ 8, 0.66F, 1.0F, "B", 2 }, + BitValue{ 8, 0.00F, 0.0F, "A", 3 } }; if (ImGui::BeginTable("##color_picker_table", 3, ImGuiTableFlags_BordersInnerV)) { - ImGui::TableSetupColumn(" Color Picker", ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoResize, 300_scaled); - ImGui::TableSetupColumn(" Components", ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoResize, 105_scaled); - ImGui::TableSetupColumn(" Formats", ImGuiTableColumnFlags_WidthStretch | ImGuiTableColumnFlags_NoResize); + ImGui::TableSetupColumn(hex::format(" {}", "hex.builtin.tools.color"_lang).c_str(), ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoResize, 300_scaled); + ImGui::TableSetupColumn(hex::format(" {}", "hex.builtin.tools.color.components"_lang).c_str(), ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoResize, 105_scaled); + ImGui::TableSetupColumn(hex::format(" {}", "hex.builtin.tools.color.formats"_lang).c_str(), ImGuiTableColumnFlags_WidthStretch | ImGuiTableColumnFlags_NoResize); ImGui::TableHeadersRow(); @@ -43,19 +43,21 @@ namespace hex::plugin::builtin { ImGui::TableNextColumn(); // Draw main color picker widget - ImVec2 startCursor, endCursor; { ImGui::PushItemWidth(-1); - startCursor = ImGui::GetCursorPos(); ImGui::ColorPicker4("hex.builtin.tools.color"_lang, pickedColor.data(), ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_AlphaBar | ImGuiColorEditFlags_NoSidePreview | ImGuiColorEditFlags_NoSmallPreview | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_DisplayHex); - endCursor = ImGui::GetCursorPos(); ImGui::ColorButton("##color_button", ImColor(pickedColor[0], pickedColor[1], pickedColor[2], pickedColor[3]), ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_NoDragDrop | ImGuiColorEditFlags_AlphaPreviewHalf, ImVec2(300_scaled, 0)); ImGui::PopItemWidth(); } ImGui::TableNextColumn(); - const auto colorFormatName = hex::format("{}{}{}{}", bitValues[0].name, bitValues[1].name, bitValues[2].name, bitValues[3].name); + const auto colorFormatName = hex::format("{}{}{}{}", + bitValues[0].bits > 0 ? bitValues[0].name : "", + bitValues[1].bits > 0 ? bitValues[1].name : "", + bitValues[2].bits > 0 ? bitValues[2].name : "", + bitValues[3].bits > 0 ? bitValues[3].name : "" + ); // Draw color bit count sliders { @@ -71,7 +73,7 @@ namespace hex::plugin::builtin { // Draw slider ImGui::PushID(&bitValue->bits); auto format = hex::format("%d\n{}", bitValue->name); - ImGui::VSliderInt("##slider", ImVec2(18_scaled, (endCursor - startCursor).y - 3_scaled), &bitValue->bits, 0, 16, format.c_str(), ImGuiSliderFlags_AlwaysClamp); + ImGui::VSliderInt("##slider", ImVec2(18_scaled, 350_scaled), &bitValue->bits, 0, 16, format.c_str(), ImGuiSliderFlags_AlwaysClamp); ImGui::PopID(); ImGui::PopStyleColor(4); @@ -135,7 +137,7 @@ namespace hex::plugin::builtin { } // Draw a table with the color values - if (ImGui::BeginTable("##value_table", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoHostExtendX , ImVec2(0, 0))) { + if (ImGui::BeginTable("##value_table", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoHostExtendX , ImVec2(230_scaled, 0))) { ImGui::TableSetupColumn("name", ImGuiTableColumnFlags_WidthFixed); ImGui::TableSetupColumn("value", ImGuiTableColumnFlags_WidthStretch); @@ -158,7 +160,7 @@ namespace hex::plugin::builtin { // Draw the different representations - drawValue("HEX", [&] { + drawValue("hex.builtin.tools.color.formats.hex"_lang, [&] { u64 hexValue = 0; for (u32 index = 0; auto &bitValue : bitValues) { hexValue <<= bitValue.bits; @@ -173,15 +175,15 @@ namespace hex::plugin::builtin { return hex::format("{}({}, {}, {}, {})", colorFormatName, intColor[0], intColor[1], intColor[2], intColor[3]); }); - drawValue("Vector4f", [&] { + drawValue("hex.builtin.tools.color.formats.vec4"_lang, [&] { return hex::format("{{ {:.2}F, {:.2}F, {:.2}F, {:.2}F }}", floatColor[0], floatColor[1], floatColor[2], floatColor[3]); }); - drawValue("Percentage", [&] { + drawValue("hex.builtin.tools.color.formats.percent"_lang, [&] { return hex::format("{{ {}%, {}%, {}%, {}% }}", u32(floatColor[0] * 100), u32(floatColor[1] * 100), u32(floatColor[2] * 100), u32(floatColor[3] * 100)); }); - drawValue("Color Name", [&] -> std::string { + drawValue("hex.builtin.tools.color.formats.color_name"_lang, [&] -> std::string { const static auto ColorTable = [] { auto colorMap = nlohmann::json::parse(romfs::get("assets/common/color_names.json").string()).get>();