impr: Add localization to color picker tool
This commit is contained in:
parent
aaaa02dbd0
commit
d2d36c2211
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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": "使用できるパターン",
|
||||
|
@ -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": "패턴 적용",
|
||||
|
@ -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",
|
||||
|
@ -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": "接受模式",
|
||||
|
@ -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": "接受模式",
|
||||
|
@ -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<std::map<std::string, std::string>>();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user