Implement localization all throughout ImHex

English only for now, additional languages will come in the future
This commit is contained in:
WerWolv
2021-02-11 23:09:45 +01:00
parent 9227fba474
commit 36a4930b35
26 changed files with 897 additions and 403 deletions

View File

@@ -7,7 +7,7 @@
namespace hex {
ViewBookmarks::ViewBookmarks() : View("Bookmarks") {
ViewBookmarks::ViewBookmarks() : View("hex.view.bookmarks.name"_lang) {
View::subscribeEvent(Events::AddBookmark, [](auto userData) {
auto bookmark = std::any_cast<ImHexApi::Bookmarks::Entry>(userData);
bookmark.comment.resize(0xF'FFFF);
@@ -15,7 +15,7 @@ namespace hex {
if (bookmark.name.empty()) {
bookmark.name.resize(64);
std::memset(bookmark.name.data(), 0x00, 64);
std::strcpy(bookmark.name.data(), hex::format("Bookmark [0x%lX - 0x%lX]",
std::strcpy(bookmark.name.data(), hex::format("hex.view.bookmarks.default_title"_lang,
bookmark.region.address,
bookmark.region.address + bookmark.region.size - 1).c_str());
}
@@ -44,7 +44,7 @@ namespace hex {
}
void ViewBookmarks::drawContent() {
if (ImGui::Begin("Bookmarks", &this->getWindowOpenState())) {
if (ImGui::Begin("hex.view.bookmarks.name"_lang, &this->getWindowOpenState())) {
if (ImGui::BeginChild("##scrolling")) {
auto &bookmarks = ImHexApi::Bookmarks::getEntries();
@@ -52,7 +52,7 @@ namespace hex {
if (bookmarks.empty()) {
ImGui::NewLine();
ImGui::Indent(30);
ImGui::TextWrapped("No bookmarks created yet. Add one with Edit -> Add Bookmark");
ImGui::TextWrapped("%s", static_cast<const char*>("hex.view.bookmarks.no_bookmarks"_lang));
}
u32 id = 1;
@@ -69,9 +69,9 @@ namespace hex {
ImGui::PushStyleColor(ImGuiCol_HeaderActive, color);
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, u32(hoverColor));
if (ImGui::CollapsingHeader((std::string(name.data()) + "###" + std::to_string((u64)comment.data())).c_str())) {
ImGui::TextUnformatted("Information");
ImGui::TextUnformatted("hex.view.bookmarks.title.info"_lang);
ImGui::Separator();
ImGui::Text("0x%08lx : 0x%08lx (%lu bytes)", region.address, region.address + region.size - 1, region.size);
ImGui::Text("hex.view.bookmarks.address"_lang, region.address, region.address + region.size - 1, region.size);
{
u8 bytes[10] = { 0 };
@@ -89,22 +89,22 @@ namespace hex {
ImGui::TextColored(ImColor(0xFF9BC64D), bytesString.c_str());
}
if (ImGui::Button("Jump to"))
if (ImGui::Button("hex.view.bookmarks.button.jump"_lang))
View::postEvent(Events::SelectionChangeRequest, region);
ImGui::SameLine(0, 15);
if (ImGui::Button("Remove"))
if (ImGui::Button("hex.view.bookmarks.button.remove"_lang))
bookmarkToRemove = iter;
ImGui::NewLine();
ImGui::TextUnformatted("Name");
ImGui::TextUnformatted("hex.view.bookmarks.header.name"_lang);
ImGui::Separator();
ImGui::InputText("##nameInput", std::string(name.data()).data(), 64);
ImGui::SameLine();
ImGui::ColorEdit4("Color", (float*)&headerColor.Value, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_NoAlpha);
ImGui::ColorEdit4("hex.view.bookmarks.header.color"_lang, (float*)&headerColor.Value, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_NoAlpha);
color = headerColor;
ImGui::NewLine();
ImGui::TextUnformatted("Comment");
ImGui::TextUnformatted("hex.view.bookmarks.header.comment"_lang);
ImGui::Separator();
ImGui::InputTextMultiline("##colorInput", std::string(comment.data()).data(), 0xF'FFFF);
ImGui::NewLine();

View File

@@ -4,7 +4,7 @@
namespace hex {
ViewCommandPalette::ViewCommandPalette() : View("Command Palette") {
ViewCommandPalette::ViewCommandPalette() : View("hex.view.command_palette.name"_lang) {
this->m_commandBuffer.resize(1024, 0x00);
}
@@ -17,7 +17,7 @@ namespace hex {
if (!this->m_commandPaletteOpen) return;
ImGui::SetNextWindowPos(ImVec2(SharedData::windowPos.x + SharedData::windowSize.x * 0.5F, SharedData::windowPos.y), ImGuiCond_Always, ImVec2(0.5F,0.0F));
if (ImGui::BeginPopup("Command Palette")) {
if (ImGui::BeginPopup("hex.view.command_palette.name"_lang)) {
if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Escape)))
ImGui::CloseCurrentPopup();
@@ -70,7 +70,7 @@ namespace hex {
bool ViewCommandPalette::handleShortcut(int key, int mods) {
if (key == GLFW_KEY_P && mods == (GLFW_MOD_SHIFT | GLFW_MOD_CONTROL)) {
View::doLater([this] {
ImGui::OpenPopup("Command Palette");
ImGui::OpenPopup("hex.view.command_palette.name"_lang);
this->m_commandPaletteOpen = true;
this->m_justOpened = true;
});

View File

@@ -10,7 +10,7 @@ namespace hex {
using NumberDisplayStyle = ContentRegistry::DataInspector::NumberDisplayStyle;
ViewDataInspector::ViewDataInspector() : View("Data Inspector") {
ViewDataInspector::ViewDataInspector() : View("hex.view.data_inspector.name"_lang) {
View::subscribeEvent(Events::RegionSelected, [this](auto userData) {
auto region = std::any_cast<Region>(userData);
@@ -54,7 +54,7 @@ namespace hex {
}
if (ImGui::Begin("Data Inspector", &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (ImGui::Begin("hex.view.data_inspector.name"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
auto provider = SharedData::currentProvider;
if (provider != nullptr && provider->isReadable()) {
@@ -62,8 +62,8 @@ namespace hex {
ImGuiTableFlags_ScrollY | ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_RowBg,
ImVec2(0, ImGui::GetTextLineHeightWithSpacing() * (this->m_cachedData.size() + 1)))) {
ImGui::TableSetupScrollFreeze(0, 1);
ImGui::TableSetupColumn("Name");
ImGui::TableSetupColumn("Value");
ImGui::TableSetupColumn("hex.view.data_inspector.table.name"_lang);
ImGui::TableSetupColumn("hex.view.data_inspector.table.value"_lang);
ImGui::TableHeadersRow();
@@ -80,27 +80,27 @@ namespace hex {
ImGui::NewLine();
if (ImGui::RadioButton("Little Endian", this->m_endian == std::endian::little)) {
if (ImGui::RadioButton("hex.common.little_endian"_lang, this->m_endian == std::endian::little)) {
this->m_endian = std::endian::little;
this->m_shouldInvalidate = true;
}
ImGui::SameLine();
if (ImGui::RadioButton("Big Endian", this->m_endian == std::endian::big)) {
if (ImGui::RadioButton("hex.common.big_endian"_lang, this->m_endian == std::endian::big)) {
this->m_endian = std::endian::big;
this->m_shouldInvalidate = true;
}
if (ImGui::RadioButton("Decimal", this->m_numberDisplayStyle == NumberDisplayStyle::Decimal)) {
if (ImGui::RadioButton("hex.common.decimal"_lang, this->m_numberDisplayStyle == NumberDisplayStyle::Decimal)) {
this->m_numberDisplayStyle = NumberDisplayStyle::Decimal;
this->m_shouldInvalidate = true;
}
ImGui::SameLine();
if (ImGui::RadioButton("Hexadecimal", this->m_numberDisplayStyle == NumberDisplayStyle::Hexadecimal)) {
if (ImGui::RadioButton("hex.common.hexadecimal"_lang, this->m_numberDisplayStyle == NumberDisplayStyle::Hexadecimal)) {
this->m_numberDisplayStyle = NumberDisplayStyle::Hexadecimal;
this->m_shouldInvalidate = true;
}
ImGui::SameLine();
if (ImGui::RadioButton("Octal", this->m_numberDisplayStyle == NumberDisplayStyle::Octal)) {
if (ImGui::RadioButton("hex.common.octal"_lang, this->m_numberDisplayStyle == NumberDisplayStyle::Octal)) {
this->m_numberDisplayStyle = NumberDisplayStyle::Octal;
this->m_shouldInvalidate = true;
}

View File

@@ -6,7 +6,7 @@
namespace hex {
ViewDataProcessor::ViewDataProcessor() : View("Data Processor") {
ViewDataProcessor::ViewDataProcessor() : View("hex.view.data_processor.name"_lang) {
imnodes::Initialize();
imnodes::PushAttributeFlag(imnodes::AttributeFlags_EnableLinkDetachWithDragClick);
imnodes::PushAttributeFlag(imnodes::AttributeFlags_EnableLinkCreationOnSnap);
@@ -126,7 +126,7 @@ namespace hex {
}
void ViewDataProcessor::drawContent() {
if (ImGui::Begin("Data Processor", &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (ImGui::Begin("hex.view.data_processor.name"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (ImGui::IsMouseReleased(ImGuiMouseButton_Right) && ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows)) {
imnodes::ClearNodeSelection();
@@ -146,7 +146,7 @@ namespace hex {
dp::Node *node = nullptr;
if (imnodes::NumSelectedNodes() > 0 || imnodes::NumSelectedLinks() > 0) {
if (ImGui::MenuItem("Remove selected")) {
if (ImGui::MenuItem("hex.view.data_processor.name"_lang)) {
std::vector<int> ids;
ids.resize(imnodes::NumSelectedNodes());
imnodes::GetSelectedNodes(ids.data());
@@ -203,14 +203,14 @@ namespace hex {
}
if (ImGui::BeginPopup("Node Menu")) {
if (ImGui::MenuItem("Remove Node"))
if (ImGui::MenuItem("hex.view.data_processor.menu.remove_node"_lang))
this->eraseNodes({ this->m_rightClickedId });
ImGui::EndPopup();
}
if (ImGui::BeginPopup("Link Menu")) {
if (ImGui::MenuItem("Remove Link"))
if (ImGui::MenuItem("hex.view.data_processor.menu.remove_link"_lang))
this->eraseLink(this->m_rightClickedId);
ImGui::EndPopup();
@@ -220,7 +220,7 @@ namespace hex {
int nodeId;
if (imnodes::IsNodeHovered(&nodeId) && this->m_currNodeError.has_value() && this->m_currNodeError->first->getID() == nodeId) {
ImGui::BeginTooltip();
ImGui::TextUnformatted("Error");
ImGui::TextUnformatted("hex.common.error"_lang);
ImGui::Separator();
ImGui::TextUnformatted(this->m_currNodeError->second.c_str());
ImGui::EndTooltip();

View File

@@ -9,7 +9,7 @@ using namespace std::literals::string_literals;
namespace hex {
ViewDisassembler::ViewDisassembler() : View("Disassembler") {
ViewDisassembler::ViewDisassembler() : View("hex.view.disassembler.name"_lang) {
View::subscribeEvent(Events::DataChanged, [this](auto){
this->m_shouldInvalidate = true;
});
@@ -93,30 +93,30 @@ namespace hex {
}
if (ImGui::Begin("Disassembler", &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (ImGui::Begin("hex.view.disassembler.name"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
auto provider = SharedData::currentProvider;
if (provider != nullptr && provider->isReadable()) {
ImGui::TextUnformatted("Position");
ImGui::TextUnformatted("hex.view.disassembler.position"_lang);
ImGui::Separator();
ImGui::InputScalar("Base address", ImGuiDataType_U64, &this->m_baseAddress, nullptr, nullptr, "%08llX", ImGuiInputTextFlags_CharsHexadecimal);
ImGui::InputScalarN("Code region", ImGuiDataType_U64, this->m_codeRegion, 2, nullptr, nullptr, "%08llX", ImGuiInputTextFlags_CharsHexadecimal);
ImGui::Checkbox("Match selection", &this->m_shouldMatchSelection);
ImGui::InputScalar("hex.view.disassembler.base"_lang, ImGuiDataType_U64, &this->m_baseAddress, nullptr, nullptr, "%08llX", ImGuiInputTextFlags_CharsHexadecimal);
ImGui::InputScalarN("hex.view.disassembler.region"_lang, ImGuiDataType_U64, this->m_codeRegion, 2, nullptr, nullptr, "%08llX", ImGuiInputTextFlags_CharsHexadecimal);
ImGui::Checkbox("hex.common.match_selection"_lang, &this->m_shouldMatchSelection);
ImGui::NewLine();
ImGui::TextUnformatted("Settings");
ImGui::TextUnformatted("hex.view.disassembler.settings.header"_lang);
ImGui::Separator();
ImGui::Combo("Architecture", reinterpret_cast<int*>(&this->m_architecture), Disassembler::ArchitectureNames, Disassembler::getArchitectureSupportedCount());
ImGui::Combo("hex.view.disassembler.arch"_lang, reinterpret_cast<int*>(&this->m_architecture), Disassembler::ArchitectureNames, Disassembler::getArchitectureSupportedCount());
if (ImGui::BeginChild("modes", ImVec2(0, 100), true)) {
if (ImGui::RadioButton("Little Endian", this->m_littleEndianMode))
if (ImGui::RadioButton("hex.common.little_endian"_lang, this->m_littleEndianMode))
this->m_littleEndianMode = true;
ImGui::SameLine();
if (ImGui::RadioButton("Big Endian", !this->m_littleEndianMode))
if (ImGui::RadioButton("hex.common.big_endian"_lang, !this->m_littleEndianMode))
this->m_littleEndianMode = false;
ImGui::NewLine();
@@ -132,19 +132,19 @@ namespace hex {
if (this->m_modeBasicARM == cs_mode(0))
this->m_modeBasicARM = CS_MODE_ARM;
if (ImGui::RadioButton("ARM mode", this->m_modeBasicARM == CS_MODE_ARM))
if (ImGui::RadioButton("hex.view.disassembler.arm.arm"_lang, this->m_modeBasicARM == CS_MODE_ARM))
this->m_modeBasicARM = CS_MODE_ARM;
ImGui::SameLine();
if (ImGui::RadioButton("Thumb mode", this->m_modeBasicARM == CS_MODE_THUMB))
if (ImGui::RadioButton("hex.view.disassembler.arm.thumb"_lang, this->m_modeBasicARM == CS_MODE_THUMB))
this->m_modeBasicARM = CS_MODE_THUMB;
if (ImGui::RadioButton("Default mode", (this->m_modeExtraARM & (CS_MODE_MCLASS | CS_MODE_V8)) == 0))
if (ImGui::RadioButton("hex.view.disassembler.arm.default"_lang, (this->m_modeExtraARM & (CS_MODE_MCLASS | CS_MODE_V8)) == 0))
this->m_modeExtraARM = cs_mode(0);
ImGui::SameLine();
if (ImGui::RadioButton("Cortex-M mode", (this->m_modeExtraARM & (CS_MODE_MCLASS | CS_MODE_V8)) == CS_MODE_MCLASS))
if (ImGui::RadioButton("hex.view.disassembler.arm.cortex_m"_lang, (this->m_modeExtraARM & (CS_MODE_MCLASS | CS_MODE_V8)) == CS_MODE_MCLASS))
this->m_modeExtraARM = CS_MODE_MCLASS;
ImGui::SameLine();
if (ImGui::RadioButton("ARMv8 mode", (this->m_modeExtraARM & (CS_MODE_MCLASS | CS_MODE_V8)) == CS_MODE_V8))
if (ImGui::RadioButton("hex.view.disassembler.arm.armv8"_lang, (this->m_modeExtraARM & (CS_MODE_MCLASS | CS_MODE_V8)) == CS_MODE_V8))
this->m_modeExtraARM = CS_MODE_V8;
break;
case Architecture::MIPS:
@@ -157,16 +157,16 @@ namespace hex {
if (this->m_modeBasicMIPS == cs_mode(0))
this->m_modeBasicMIPS = CS_MODE_MIPS32;
if (ImGui::RadioButton("MIPS32 mode", this->m_modeBasicMIPS == CS_MODE_MIPS32))
if (ImGui::RadioButton("hex.view.disassembler.mips.mips32"_lang, this->m_modeBasicMIPS == CS_MODE_MIPS32))
this->m_modeBasicMIPS = CS_MODE_MIPS32;
ImGui::SameLine();
if (ImGui::RadioButton("MIPS64 mode", this->m_modeBasicMIPS == CS_MODE_MIPS64))
if (ImGui::RadioButton("hex.view.disassembler.mips.mips64"_lang, this->m_modeBasicMIPS == CS_MODE_MIPS64))
this->m_modeBasicMIPS = CS_MODE_MIPS64;
ImGui::SameLine();
if (ImGui::RadioButton("MIPS32R6 mode", this->m_modeBasicMIPS == CS_MODE_MIPS32R6))
if (ImGui::RadioButton("hex.view.disassembler.mips.mips32R6"_lang, this->m_modeBasicMIPS == CS_MODE_MIPS32R6))
this->m_modeBasicMIPS = CS_MODE_MIPS32R6;
ImGui::Checkbox("Micro Mode", &this->m_micoMode);
ImGui::Checkbox("hex.view.disassembler.mips.micro"_lang, &this->m_micoMode);
break;
case Architecture::X86:
this->m_modeBasicARM = cs_mode(0);
@@ -179,13 +179,13 @@ namespace hex {
if (this->m_modeBasicX86 == cs_mode(0))
this->m_modeBasicX86 = CS_MODE_16;
if (ImGui::RadioButton("16-bit mode", this->m_modeBasicX86 == CS_MODE_16))
if (ImGui::RadioButton("hex.view.disassembler.x86.16bit"_lang, this->m_modeBasicX86 == CS_MODE_16))
this->m_modeBasicX86 = CS_MODE_16;
ImGui::SameLine();
if (ImGui::RadioButton("32-bit mode", this->m_modeBasicX86 == CS_MODE_32))
if (ImGui::RadioButton("hex.view.disassembler.x86.32bit"_lang, this->m_modeBasicX86 == CS_MODE_32))
this->m_modeBasicX86 = CS_MODE_32;
ImGui::SameLine();
if (ImGui::RadioButton("64-bit mode", this->m_modeBasicX86 == CS_MODE_64))
if (ImGui::RadioButton("hex.view.disassembler.x86.64bit"_lang, this->m_modeBasicX86 == CS_MODE_64))
this->m_modeBasicX86 = CS_MODE_64;
break;
case Architecture::PPC:
@@ -199,10 +199,10 @@ namespace hex {
if (m_modeBasicPPC == cs_mode(0))
this->m_modeBasicPPC = CS_MODE_32;
if (ImGui::RadioButton("32-bit mode", this->m_modeBasicPPC == CS_MODE_32))
if (ImGui::RadioButton("hex.view.disassembler.ppc.32bit"_lang, this->m_modeBasicPPC == CS_MODE_32))
this->m_modeBasicPPC = CS_MODE_32;
ImGui::SameLine();
if (ImGui::RadioButton("64-bit mode", this->m_modeBasicPPC == CS_MODE_64))
if (ImGui::RadioButton("hex.view.disassembler.ppc.64bit"_lang, this->m_modeBasicPPC == CS_MODE_64))
this->m_modeBasicPPC = CS_MODE_64;
break;
case Architecture::SPARC:
@@ -213,7 +213,7 @@ namespace hex {
this->m_modeBasicPPC = cs_mode(0);
this->m_micoMode = false;
ImGui::Checkbox("Sparc V9 mode", &this->m_sparcV9Mode);
ImGui::Checkbox("hex.view.disassembler.sparc.v9"_lang, &this->m_sparcV9Mode);
break;
case Architecture::ARM64:
case Architecture::SYSZ:
@@ -236,19 +236,19 @@ namespace hex {
ImGui::EndChild();
ImGui::SetCursorPosX((ImGui::GetContentRegionAvail().x - 300) / 2);
if (ImGui::Button("Disassemble", ImVec2(300, 20)))
if (ImGui::Button("hex.view.disassembler.disassemble"_lang, ImVec2(300, 20)))
this->m_shouldInvalidate = true;
ImGui::NewLine();
ImGui::TextUnformatted("Disassembly");
ImGui::TextUnformatted("hex.view.disassembler.disassembly.title"_lang);
ImGui::Separator();
if (ImGui::BeginTable("##disassembly", 4, ImGuiTableFlags_ScrollY | ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_RowBg | ImGuiTableFlags_Reorderable)) {
ImGui::TableSetupScrollFreeze(0, 1);
ImGui::TableSetupColumn("Address");
ImGui::TableSetupColumn("Offset");
ImGui::TableSetupColumn("Bytes");
ImGui::TableSetupColumn("Disassembly");
ImGui::TableSetupColumn("hex.view.disassembler.disassembly.address"_lang);
ImGui::TableSetupColumn("hex.view.disassembler.disassembly.offset"_lang);
ImGui::TableSetupColumn("hex.view.disassembler.disassembly.bytes"_lang);
ImGui::TableSetupColumn("hex.view.disassembler.disassembly.title"_lang);
ImGuiListClipper clipper;
clipper.Begin(this->m_disassembly.size());

View File

@@ -9,7 +9,7 @@
namespace hex {
ViewHashes::ViewHashes() : View("Hashes") {
ViewHashes::ViewHashes() : View("hex.view.hashes.name"_lang) {
View::subscribeEvent(Events::DataChanged, [this](auto) {
this->m_shouldInvalidate = true;
});
@@ -38,26 +38,26 @@ namespace hex {
}
void ViewHashes::drawContent() {
if (ImGui::Begin("Hashing", &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (ImGui::Begin("hex.view.hashes.name"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
ImGui::BeginChild("##scrolling", ImVec2(0, 0), false, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoNav);
auto provider = SharedData::currentProvider;
if (provider != nullptr && provider->isAvailable()) {
ImGui::TextUnformatted("Region");
ImGui::TextUnformatted("hex.common.region"_lang);
ImGui::Separator();
ImGui::InputScalarN("##nolabel", ImGuiDataType_U64, this->m_hashRegion, 2, nullptr, nullptr, "%08X", ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::Checkbox("Match selection", &this->m_shouldMatchSelection);
ImGui::Checkbox("hex.common.match_selection"_lang, &this->m_shouldMatchSelection);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::NewLine();
ImGui::TextUnformatted("Settings");
ImGui::TextUnformatted("hex.view.hashes.settings"_lang);
ImGui::Separator();
if (ImGui::Combo("Hash Function", &this->m_currHashFunction, HashFunctionNames,sizeof(HashFunctionNames) / sizeof(const char *)))
if (ImGui::Combo("hex.view.hashes.function"_lang, &this->m_currHashFunction, HashFunctionNames,sizeof(HashFunctionNames) / sizeof(const char *)))
this->m_shouldInvalidate = true;
size_t dataSize = provider->getSize();
@@ -72,10 +72,10 @@ namespace hex {
{
static int polynomial = 0, init = 0;
ImGui::InputInt("Initial Value", &init, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
ImGui::InputInt("hex.view.hashes.iv"_lang, &init, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::InputInt("Polynomial", &polynomial, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
ImGui::InputInt("hex.view.hashes.poly"_lang, &polynomial, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::NewLine();
@@ -88,7 +88,7 @@ namespace hex {
char buffer[sizeof(result) * 2 + 1];
snprintf(buffer, sizeof(buffer), "%04X", result);
ImGui::TextUnformatted("Result");
ImGui::TextUnformatted("hex.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
@@ -97,10 +97,10 @@ namespace hex {
{
static int polynomial = 0, init = 0;
ImGui::InputInt("Initial Value", &init, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
ImGui::InputInt("hex.view.hashes.iv"_lang, &init, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::InputInt("Polynomial", &polynomial, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
ImGui::InputInt("hex.view.hashes.poly"_lang, &polynomial, 0, 0, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::IsItemEdited()) this->m_shouldInvalidate = true;
ImGui::NewLine();
@@ -113,7 +113,7 @@ namespace hex {
char buffer[sizeof(result) * 2 + 1];
snprintf(buffer, sizeof(buffer), "%08X", result);
ImGui::TextUnformatted("Result");
ImGui::TextUnformatted("hex.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
@@ -129,7 +129,7 @@ namespace hex {
formatBigHexInt(result, buffer, sizeof(buffer));
ImGui::NewLine();
ImGui::TextUnformatted("Result");
ImGui::TextUnformatted("hex.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
@@ -145,7 +145,7 @@ namespace hex {
formatBigHexInt(result, buffer, sizeof(buffer));
ImGui::NewLine();
ImGui::TextUnformatted("Result");
ImGui::TextUnformatted("hex.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
@@ -161,7 +161,7 @@ namespace hex {
formatBigHexInt(result, buffer, sizeof(buffer));
ImGui::NewLine();
ImGui::TextUnformatted("Result");
ImGui::TextUnformatted("hex.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
@@ -177,7 +177,7 @@ namespace hex {
formatBigHexInt(result, buffer, sizeof(buffer));
ImGui::NewLine();
ImGui::TextUnformatted("Result");
ImGui::TextUnformatted("hex.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
@@ -193,7 +193,7 @@ namespace hex {
formatBigHexInt(result, buffer, sizeof(buffer));
ImGui::NewLine();
ImGui::TextUnformatted("Result");
ImGui::TextUnformatted("hex.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}
@@ -209,7 +209,7 @@ namespace hex {
formatBigHexInt(result, buffer, sizeof(buffer));
ImGui::NewLine();
ImGui::TextUnformatted("Result");
ImGui::TextUnformatted("hex.view.hashes.result"_lang);
ImGui::Separator();
ImGui::InputText("##nolabel", buffer, ImGuiInputTextFlags_ReadOnly);
}

View File

@@ -29,26 +29,27 @@ namespace hex {
void ViewHelp::drawAboutPopup() {
if (ImGui::BeginPopupModal("About", &this->m_aboutWindowOpen, ImGuiWindowFlags_AlwaysAutoResize)) {
if (ImGui::BeginPopupModal("hex.view.help.about.title"_lang, &this->m_aboutWindowOpen, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::Text("ImHex Hex Editor v%s by WerWolv -", IMHEX_VERSION);
#if defined(GIT_BRANCH) && defined(GIT_COMMIT_HASH)
ImGui::SameLine();
if (ImGui::Hyperlink(hex::format("%s@%s", GIT_BRANCH, GIT_COMMIT_HASH).c_str()))
hex::openWebpage("https://github.com/WerWolv/ImHex/commit/" GIT_COMMIT_HASH);
#endif
ImGui::TextUnformatted("hex.view.help.about.translator"_lang);
ImGui::TextUnformatted("Source code available on GitHub:"); ImGui::SameLine();
ImGui::TextUnformatted("hex.view.help.about.source"_lang); ImGui::SameLine();
if (ImGui::Hyperlink("WerWolv/ImHex"))
hex::openWebpage("https://github.com/WerWolv/ImHex");
ImGui::NewLine();
ImGui::Text("Donations");
ImGui::Text("hex.view.help.about.donations"_lang);
ImGui::Separator();
constexpr const char* Links[] = { "https://werwolv.net/donate", "https://www.patreon.com/werwolv", "https://github.com/sponsors/WerWolv" };
ImGui::TextWrapped("If you like my work, please consider donating to keep the project going. Thanks a lot <3");
ImGui::TextWrapped("hex.view.help.about.thanks"_lang);
ImGui::NewLine();
@@ -58,7 +59,7 @@ namespace hex {
}
ImGui::NewLine();
ImGui::Text("Libraries used");
ImGui::Text("hex.view.help.about.libs"_lang);
ImGui::Separator();
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.2F, 0.2F, 0.2F, 0.3F));
ImGui::BulletText("ImGui by ocornut");

View File

@@ -17,7 +17,7 @@
namespace hex {
ViewHexEditor::ViewHexEditor(std::vector<lang::PatternData*> &patternData)
: View("Hex Editor"), m_patternData(patternData) {
: View("hex.view.hexeditor.title"_lang), m_patternData(patternData) {
this->m_memoryEditor.ReadFn = [](const ImU8 *data, size_t off) -> ImU8 {
auto provider = SharedData::currentProvider;
@@ -130,7 +130,7 @@ namespace hex {
if (ProjectFile::hasUnsavedChanges()) {
glfwSetWindowShouldClose(window, GLFW_FALSE);
View::doLater([] { ImGui::OpenPopup("Save Changes"); });
View::doLater([] { ImGui::OpenPopup("hex.view.hexeditor.save_changes"_lang); });
}
});
@@ -143,12 +143,12 @@ namespace hex {
View::subscribeEvent(Events::OpenWindow, [this](auto name) {
if (std::any_cast<const char*>(name) == std::string("Open File")) {
View::openFileBrowser("Open File", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, "*.*", [this](auto path) {
View::openFileBrowser("hex.view.hexeditor.open_file"_lang, imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, "*.*", [this](auto path) {
this->openFile(path);
this->getWindowOpenState() = true;
});
} else if (std::any_cast<const char*>(name) == std::string("Open Project")) {
View::openFileBrowser("Open Project", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, ".hexproj", [this](auto path) {
View::openFileBrowser("hex.view.hexeditor.open_project"_lang, imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, ".hexproj", [this](auto path) {
ProjectFile::load(path);
View::postEvent(Events::ProjectFileLoad);
this->getWindowOpenState() = true;
@@ -166,15 +166,15 @@ namespace hex {
size_t dataSize = (provider == nullptr || !provider->isReadable()) ? 0x00 : provider->getSize();
this->m_memoryEditor.DrawWindow("Hex Editor", &this->getWindowOpenState(), this, dataSize, dataSize == 0 ? 0x00 : provider->getBaseAddress());
this->m_memoryEditor.DrawWindow("hex.view.hexeditor.title"_lang, &this->getWindowOpenState(), this, dataSize, dataSize == 0 ? 0x00 : provider->getBaseAddress());
if (dataSize != 0x00) {
if (ImGui::Begin("Hex Editor")) {
if (ImGui::Begin("hex.view.hexeditor.title"_lang)) {
if (ImGui::IsMouseReleased(ImGuiMouseButton_Right) && ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows))
ImGui::OpenPopup("Edit");
ImGui::OpenPopup("hex.menu.edit"_lang);
if (ImGui::BeginPopup("Edit")) {
if (ImGui::BeginPopup("hex.menu.edit"_lang)) {
this->drawEditPopup();
ImGui::EndPopup();
}
@@ -182,7 +182,7 @@ namespace hex {
ImGui::SameLine();
ImGui::Spacing();
ImGui::SameLine();
ImGui::Text("Page %d / %d", provider->getCurrentPage() + 1, provider->getPageCount());
ImGui::Text("hex.view.hexeditor.page"_lang, provider->getCurrentPage() + 1, provider->getPageCount());
ImGui::SameLine();
if (ImGui::ArrowButton("prevPage", ImGuiDir_Left)) {
@@ -215,7 +215,7 @@ namespace hex {
}
static void saveAs() {
View::openFileBrowser("Save As", imgui_addons::ImGuiFileBrowser::DialogMode::SAVE, "*.*", [](auto path) {
View::openFileBrowser("hex.view.hexeditor.save_as"_lang, imgui_addons::ImGuiFileBrowser::DialogMode::SAVE, "*.*", [](auto path) {
FILE *file = fopen(path.c_str(), "wb");
if (file != nullptr) {
@@ -241,10 +241,9 @@ namespace hex {
void ViewHexEditor::drawAlwaysVisible() {
auto provider = SharedData::currentProvider;
if (ImGui::BeginPopupModal("Save Changes", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
constexpr auto Message = "You have unsaved changes made to your Project.\nAre you sure you want to exit?";
if (ImGui::BeginPopupModal("hex.view.hexeditor.save_changes.title"_lang, nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::NewLine();
ImGui::TextUnformatted(Message);
ImGui::TextUnformatted("hex.view.hexeditor.save_changes.desc"_lang);
ImGui::NewLine();
confirmButtons("Yes", "No", [] { View::postEvent(Events::CloseImHex); }, [] { ImGui::CloseCurrentPopup(); });
@@ -255,23 +254,22 @@ namespace hex {
ImGui::EndPopup();
}
if (ImGui::BeginPopupModal("Load File with Loader Script", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
constexpr auto Message = "Load a file using a Python loader script.";
if (ImGui::BeginPopupModal("hex.view.hexeditor.script.title"_lang, nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::SetCursorPosX(10);
ImGui::TextWrapped(Message);
ImGui::TextWrapped("hex.view.hexeditor.script.desc"_lang);
ImGui::NewLine();
ImGui::InputText("##nolabel", this->m_loaderScriptScriptPath.data(), this->m_loaderScriptScriptPath.length(), ImGuiInputTextFlags_ReadOnly);
ImGui::SameLine();
if (ImGui::Button("Script")) {
View::openFileBrowser("Loader Script: Open Script", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, ".py", [this](auto path) {
if (ImGui::Button("hex.view.hexeditor.script.script"_lang)) {
View::openFileBrowser("hex.view.hexeditor.script.script.title"_lang, imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, ".py", [this](auto path) {
this->m_loaderScriptScriptPath = path;
});
}
ImGui::InputText("##nolabel", this->m_loaderScriptFilePath.data(), this->m_loaderScriptFilePath.length(), ImGuiInputTextFlags_ReadOnly);
ImGui::SameLine();
if (ImGui::Button("File")) {
View::openFileBrowser("Loader Script: Open File", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, "*.*", [this](auto path) {
if (ImGui::Button("hex.view.hexeditor.script.file"_lang)) {
View::openFileBrowser("hex.view.hexeditor.script.file.title"_lang, imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, "*.*", [this](auto path) {
this->m_loaderScriptFilePath = path;
});
}
@@ -280,7 +278,7 @@ namespace hex {
ImGui::NewLine();
confirmButtons("Load", "Cancel",
confirmButtons("hex.common.load"_lang, "hex.common.cancel"_lang,
[this, &provider] {
if (!this->m_loaderScriptScriptPath.empty() && !this->m_loaderScriptFilePath.empty()) {
this->openFile(this->m_loaderScriptFilePath);
@@ -299,11 +297,11 @@ namespace hex {
}
if (ImGui::BeginPopupModal("Set base address", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::InputText("Address", this->m_baseAddressBuffer, 16, ImGuiInputTextFlags_CharsHexadecimal);
if (ImGui::BeginPopupModal("hex.view.hexeditor.menu.edit.set_base"_lang, nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::InputText("hex.common.address"_lang, this->m_baseAddressBuffer, 16, ImGuiInputTextFlags_CharsHexadecimal);
ImGui::NewLine();
confirmButtons("Set", "Cancel",
confirmButtons("hex.common.set"_lang, "hex.common.cancel"_lang,
[this, &provider]{
provider->setBaseAddress(strtoull(this->m_baseAddressBuffer, nullptr, 16));
ImGui::CloseCurrentPopup();
@@ -321,38 +319,38 @@ namespace hex {
void ViewHexEditor::drawMenu() {
auto provider = SharedData::currentProvider;
if (ImGui::BeginMenu("File")) {
if (ImGui::MenuItem("Open File...", "CTRL + O")) {
if (ImGui::BeginMenu("hex.menu.file"_lang)) {
if (ImGui::MenuItem("hex.view.hexeditor.menu.file.open_file"_lang, "CTRL + O")) {
View::openFileBrowser("Open File", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, "*.*", [this](auto path) {
View::openFileBrowser("hex.view.hexeditor.open_file"_lang, imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, "*.*", [this](auto path) {
this->openFile(path);
this->getWindowOpenState() = true;
});
}
if (ImGui::MenuItem("Save", "CTRL + S", false, provider != nullptr && provider->isWritable())) {
if (ImGui::MenuItem("hex.view.hexeditor.menu.file.save"_lang, "CTRL + S", false, provider != nullptr && provider->isWritable())) {
save();
}
if (ImGui::MenuItem("Save As...", "CTRL + SHIFT + S", false, provider != nullptr && provider->isWritable())) {
if (ImGui::MenuItem("hex.view.hexeditor.menu.file.save_as"_lang, "CTRL + SHIFT + S", false, provider != nullptr && provider->isWritable())) {
saveAs();
}
ImGui::Separator();
if (ImGui::MenuItem("Open Project", "")) {
View::openFileBrowser("Open Project", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, ".hexproj", [this](auto path) {
if (ImGui::MenuItem("hex.view.hexeditor.menu.file.open_project"_lang, "")) {
View::openFileBrowser("hex.view.hexeditor.menu.file.open_project"_lang, imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, ".hexproj", [this](auto path) {
ProjectFile::load(path);
View::postEvent(Events::ProjectFileLoad);
this->getWindowOpenState() = true;
});
}
if (ImGui::MenuItem("Save Project", "", false, provider != nullptr && provider->isWritable())) {
if (ImGui::MenuItem("hex.view.hexeditor.menu.file.save_project"_lang, "", false, provider != nullptr && provider->isWritable())) {
View::postEvent(Events::ProjectFileStore);
if (ProjectFile::getProjectFilePath() == "") {
View::openFileBrowser("Save Project", imgui_addons::ImGuiFileBrowser::DialogMode::SAVE, ".hexproj", [](auto path) {
View::openFileBrowser("hex.view.hexeditor.save_project"_lang, imgui_addons::ImGuiFileBrowser::DialogMode::SAVE, ".hexproj", [](auto path) {
ProjectFile::store(path);
});
}
@@ -362,10 +360,10 @@ namespace hex {
ImGui::Separator();
if (ImGui::BeginMenu("Import...")) {
if (ImGui::MenuItem("Base64 File")) {
if (ImGui::BeginMenu("hex.view.hexeditor.menu.file.import"_lang)) {
if (ImGui::MenuItem("hex.view.hexeditor.menu.file.import.base64"_lang)) {
View::openFileBrowser("Open Base64 File", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, "*.*", [this](auto path) {
View::openFileBrowser("hex.view.hexeditor.menu.file.import.base64"_lang, imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, "*.*", [this](auto path) {
std::vector<u8> base64;
this->loadFromFile(path, base64);
@@ -373,19 +371,19 @@ namespace hex {
this->m_dataToSave = crypt::decode64(base64);
if (this->m_dataToSave.empty())
View::showErrorPopup("File is not in a valid Base64 format!");
View::showErrorPopup("hex.view.hexeditor.base64.import_error"_lang);
else
ImGui::OpenPopup("Save Data");
ImGui::OpenPopup("hex.view.hexeditor.save_data"_lang);
this->getWindowOpenState() = true;
} else View::showErrorPopup("Failed to open file!");
} else View::showErrorPopup("hex.view.hexeditor.file_open_error"_lang);
});
}
ImGui::Separator();
if (ImGui::MenuItem("IPS Patch")) {
if (ImGui::MenuItem("hex.view.hexeditor.menu.file.import.ips"_lang)) {
View::openFileBrowser("Apply IPS Patch", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, "*.*", [this](auto path) {
View::openFileBrowser("hex.view.hexeditor.open_file"_lang, imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, "*.*", [this](auto path) {
auto patchData = hex::readFile(path);
auto patch = hex::loadIPSPatch(patchData);
@@ -398,8 +396,8 @@ namespace hex {
}
if (ImGui::MenuItem("IPS32 Patch")) {
View::openFileBrowser("Apply IPS32 Patch", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, "*.*", [this](auto path) {
if (ImGui::MenuItem("hex.view.hexeditor.menu.file.import.ips32"_lang)) {
View::openFileBrowser("hex.view.hexeditor.open_file"_lang, imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, "*.*", [this](auto path) {
auto patchData = hex::readFile(path);
auto patch = hex::loadIPS32Patch(patchData);
@@ -410,17 +408,17 @@ namespace hex {
});
}
if (ImGui::MenuItem("File with Loader Script")) {
if (ImGui::MenuItem("hex.view.hexeditor.menu.file.import.script"_lang)) {
this->m_loaderScriptFilePath.clear();
this->m_loaderScriptScriptPath.clear();
View::doLater([]{ ImGui::OpenPopup("Load File with Loader Script"); });
View::doLater([]{ ImGui::OpenPopup("hex.view.hexeditor.script.title"_lang); });
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Export...", provider != nullptr && provider->isWritable())) {
if (ImGui::MenuItem("IPS Patch")) {
if (ImGui::BeginMenu("hex.view.hexeditor.menu.file.export"_lang, provider != nullptr && provider->isWritable())) {
if (ImGui::MenuItem("hex.view.hexeditor.menu.file.export.ips"_lang)) {
Patches patches = provider->getPatches();
if (!patches.contains(0x00454F45) && patches.contains(0x00454F46)) {
u8 value = 0;
@@ -429,11 +427,11 @@ namespace hex {
}
this->m_dataToSave = generateIPSPatch(patches);
View::openFileBrowser("Export File", imgui_addons::ImGuiFileBrowser::DialogMode::SAVE, "*.*", [this](auto path) {
View::openFileBrowser("hex.view.hexeditor.menu.file.export.title"_lang, imgui_addons::ImGuiFileBrowser::DialogMode::SAVE, "*.*", [this](auto path) {
this->saveToFile(path, this->m_dataToSave);
});
}
if (ImGui::MenuItem("IPS32 Patch")) {
if (ImGui::MenuItem("hex.view.hexeditor.menu.file.export.ips32"_lang)) {
Patches patches = provider->getPatches();
if (!patches.contains(0x00454F45) && patches.contains(0x45454F46)) {
u8 value = 0;
@@ -442,7 +440,7 @@ namespace hex {
}
this->m_dataToSave = generateIPS32Patch(patches);
View::openFileBrowser("Export File", imgui_addons::ImGuiFileBrowser::DialogMode::SAVE, "*.*", [this](auto path) {
View::openFileBrowser("hex.view.hexeditor.menu.file.export.title"_lang, imgui_addons::ImGuiFileBrowser::DialogMode::SAVE, "*.*", [this](auto path) {
this->saveToFile(path, this->m_dataToSave);
});
}
@@ -454,20 +452,20 @@ namespace hex {
ImGui::Separator();
if (ImGui::MenuItem("Search", "CTRL + F")) {
if (ImGui::MenuItem("hex.view.hexeditor.menu.file.search"_lang, "CTRL + F")) {
this->getWindowOpenState() = true;
View::doLater([]{ ImGui::OpenPopup("Search"); });
View::doLater([]{ ImGui::OpenPopup("hex.view.hexeditor.menu.file.search"_lang); });
}
if (ImGui::MenuItem("Goto", "CTRL + G")) {
if (ImGui::MenuItem("hex.view.hexeditor.menu.file.goto"_lang, "CTRL + G")) {
this->getWindowOpenState() = true;
View::doLater([]{ ImGui::OpenPopup("Goto"); });
View::doLater([]{ ImGui::OpenPopup("hex.view.hexeditor.menu.file.goto"_lang); });
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Edit")) {
if (ImGui::BeginMenu("hex.menu.edit"_lang)) {
this->drawEditPopup();
ImGui::EndMenu();
}
@@ -481,13 +479,13 @@ namespace hex {
saveAs();
return true;
} else if (mods == GLFW_MOD_CONTROL && key == GLFW_KEY_F) {
View::doLater([]{ ImGui::OpenPopup("Search"); });
View::doLater([]{ ImGui::OpenPopup("hex.view.hexeditor.menu.file.search"_lang); });
return true;
} else if (mods == GLFW_MOD_CONTROL && key == GLFW_KEY_G) {
View::doLater([]{ ImGui::OpenPopup("Goto"); });
View::doLater([]{ ImGui::OpenPopup("hex.view.hexeditor.menu.file.goto"_lang); });
return true;
} else if (mods == GLFW_MOD_CONTROL && key == GLFW_KEY_O) {
View::doLater([]{ ImGui::OpenPopup("Open File"); });
View::doLater([]{ ImGui::OpenPopup("hex.view.hexeditor.open_file"_lang); });
return true;
} else if (mods == (GLFW_MOD_CONTROL | GLFW_MOD_ALT) && key == GLFW_KEY_C) {
this->copyBytes();
@@ -510,13 +508,13 @@ namespace hex {
provider = new prv::FileProvider(path);
if (!provider->isWritable()) {
this->m_memoryEditor.ReadOnly = true;
View::showErrorPopup("Couldn't get write access. File opened in read-only mode.");
View::showErrorPopup("hex.view.hexeditor.error.read_only"_lang);
} else {
this->m_memoryEditor.ReadOnly = false;
}
if (!provider->isAvailable()) {
View::showErrorPopup("Failed to open file!");
View::showErrorPopup("hex.view.hexeditor.error.open"_lang);
return;
}
@@ -918,11 +916,11 @@ R"(
}
};
if (ImGui::BeginPopupContextVoid("Search")) {
ImGui::TextUnformatted("Search");
if (ImGui::BeginPopupContextVoid("hex.view.hexeditor.menu.file.search"_lang)) {
ImGui::TextUnformatted("hex.view.hexeditor.menu.file.search"_lang);
if (ImGui::BeginTabBar("searchTabs")) {
char *currBuffer;
if (ImGui::BeginTabItem("String")) {
if (ImGui::BeginTabItem("hex.view.hexeditor.search.string"_lang)) {
this->m_searchFunction = findString;
this->m_lastSearchBuffer = &this->m_lastStringSearch;
currBuffer = this->m_searchStringBuffer;
@@ -932,7 +930,7 @@ R"(
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Hex")) {
if (ImGui::BeginTabItem("hex.view.hexeditor.search.hex"_lang)) {
this->m_searchFunction = findHex;
this->m_lastSearchBuffer = &this->m_lastHexSearch;
currBuffer = this->m_searchHexBuffer;
@@ -943,16 +941,16 @@ R"(
ImGui::EndTabItem();
}
if (ImGui::Button("Find"))
if (ImGui::Button("hex.view.hexeditor.search.find"_lang))
Find(currBuffer);
if (this->m_lastSearchBuffer->size() > 0) {
if ((ImGui::Button("Find Next")))
if ((ImGui::Button("hex.view.hexeditor.search.find_next"_lang)))
FindNext();
ImGui::SameLine();
if ((ImGui::Button("Find Prev")))
if ((ImGui::Button("hex.view.hexeditor.search.find_prev"_lang)))
FindPrevious();
}
@@ -967,11 +965,11 @@ R"(
void ViewHexEditor::drawGotoPopup() {
auto provider = SharedData::currentProvider;
if (ImGui::BeginPopup("Goto")) {
ImGui::TextUnformatted("Goto");
if (ImGui::BeginPopup("hex.view.hexeditor.menu.file.goto"_lang)) {
ImGui::TextUnformatted("hex.view.hexeditor.menu.file.goto"_lang);
if (ImGui::BeginTabBar("gotoTabs")) {
s64 newOffset = 0;
if (ImGui::BeginTabItem("Begin")) {
if (ImGui::BeginTabItem("hex.view.hexeditor.goto.offset.begin"_lang)) {
ImGui::InputScalar("##nolabel", ImGuiDataType_U64, &this->m_gotoAddress, nullptr, nullptr, "%llx", ImGuiInputTextFlags_CharsHexadecimal);
if (this->m_gotoAddress >= provider->getActualSize())
@@ -981,7 +979,7 @@ R"(
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Current")) {
if (ImGui::BeginTabItem("hex.view.hexeditor.goto.offset.current"_lang)) {
ImGui::InputScalar("##nolabel", ImGuiDataType_S64, &this->m_gotoAddress, nullptr, nullptr, "%llx", ImGuiInputTextFlags_CharsHexadecimal);
if (this->m_memoryEditor.DataPreviewAddr == -1 || this->m_memoryEditor.DataPreviewAddrEnd == -1) {
@@ -1002,7 +1000,7 @@ R"(
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("End")) {
if (ImGui::BeginTabItem("hex.view.hexeditor.goto.offset.end"_lang)) {
ImGui::InputScalar("##nolabel", ImGuiDataType_U64, &this->m_gotoAddress, nullptr, nullptr, "%llx", ImGuiInputTextFlags_CharsHexadecimal);
if (this->m_gotoAddress >= provider->getActualSize())
@@ -1013,7 +1011,7 @@ R"(
ImGui::EndTabItem();
}
if (ImGui::Button("Goto")) {
if (ImGui::Button("hex.view.hexeditor.menu.file.goto"_lang)) {
provider->setCurrentPage(std::floor(newOffset / double(prv::Provider::PageSize)));
this->m_memoryEditor.GotoAddr = newOffset;
this->m_memoryEditor.DataPreviewAddr = newOffset;
@@ -1028,40 +1026,40 @@ R"(
}
void ViewHexEditor::drawEditPopup() {
if (ImGui::BeginMenu("Copy as...", this->m_memoryEditor.DataPreviewAddr != -1 && this->m_memoryEditor.DataPreviewAddrEnd != -1)) {
if (ImGui::MenuItem("Bytes", "CTRL + ALT + C"))
if (ImGui::BeginMenu("hex.view.hexeditor.menu.edit.copy"_lang, this->m_memoryEditor.DataPreviewAddr != -1 && this->m_memoryEditor.DataPreviewAddrEnd != -1)) {
if (ImGui::MenuItem("hex.view.hexeditor.copy.bytes"_lang, "CTRL + ALT + C"))
this->copyBytes();
if (ImGui::MenuItem("Hex String", "CTRL + SHIFT + C"))
if (ImGui::MenuItem("hex.view.hexeditor.copy.hex"_lang, "CTRL + SHIFT + C"))
this->copyString();
ImGui::Separator();
if (ImGui::MenuItem("C Array"))
if (ImGui::MenuItem("hex.view.hexeditor.copy.c"_lang))
this->copyLanguageArray(Language::C);
if (ImGui::MenuItem("C++ Array"))
if (ImGui::MenuItem("hex.view.hexeditor.copy.cpp"_lang))
this->copyLanguageArray(Language::Cpp);
if (ImGui::MenuItem("C# Array"))
if (ImGui::MenuItem("hex.view.hexeditor.copy.csharp"_lang))
this->copyLanguageArray(Language::CSharp);
if (ImGui::MenuItem("Rust Array"))
if (ImGui::MenuItem("hex.view.hexeditor.copy.rust"_lang))
this->copyLanguageArray(Language::Rust);
if (ImGui::MenuItem("Python Array"))
if (ImGui::MenuItem("hex.view.hexeditor.copy.python"_lang))
this->copyLanguageArray(Language::Python);
if (ImGui::MenuItem("Java Array"))
if (ImGui::MenuItem("hex.view.hexeditor.copy.java"_lang))
this->copyLanguageArray(Language::Java);
if (ImGui::MenuItem("JavaScript Array"))
if (ImGui::MenuItem("hex.view.hexeditor.copy.js"_lang))
this->copyLanguageArray(Language::JavaScript);
ImGui::Separator();
if (ImGui::MenuItem("Editor View"))
if (ImGui::MenuItem("hex.view.hexeditor.copy.ascii"_lang))
this->copyHexView();
if (ImGui::MenuItem("HTML"))
if (ImGui::MenuItem("hex.view.hexeditor.copy.html"_lang))
this->copyHexViewHTML();
ImGui::EndMenu();
}
if (ImGui::MenuItem("Create bookmark", nullptr, false, this->m_memoryEditor.DataPreviewAddr != -1 && this->m_memoryEditor.DataPreviewAddrEnd != -1)) {
if (ImGui::MenuItem("hex.view.hexeditor.menu.edit.bookmark"_lang, nullptr, false, this->m_memoryEditor.DataPreviewAddr != -1 && this->m_memoryEditor.DataPreviewAddrEnd != -1)) {
size_t start = std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
size_t end = std::max(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
@@ -1069,9 +1067,9 @@ R"(
}
auto provider = SharedData::currentProvider;
if (ImGui::MenuItem("Set base address", nullptr, false, provider != nullptr && provider->isReadable())) {
if (ImGui::MenuItem("hex.view.hexeditor.menu.edit.set_base"_lang, nullptr, false, provider != nullptr && provider->isReadable())) {
std::memset(this->m_baseAddressBuffer, 0x00, sizeof(this->m_baseAddressBuffer));
View::doLater([]{ ImGui::OpenPopup("Set base address"); });
View::doLater([]{ ImGui::OpenPopup("hex.view.hexeditor.menu.edit.set_base"_lang); });
}
}

View File

@@ -13,7 +13,7 @@
namespace hex {
ViewInformation::ViewInformation() : View("Information") {
ViewInformation::ViewInformation() : View("hex.view.information.title"_lang) {
View::subscribeEvent(Events::DataChanged, [this](auto) {
this->m_dataValid = false;
this->m_highestBlockEntropy = 0;
@@ -45,7 +45,7 @@ namespace hex {
}
void ViewInformation::drawContent() {
if (ImGui::Begin("Data Information", &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (ImGui::Begin("hex.view.information.title"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
ImGui::BeginChild("##scrolling", ImVec2(0, 0), false, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoNav);
auto provider = SharedData::currentProvider;
@@ -125,7 +125,7 @@ namespace hex {
ImGui::NewLine();
if (ImGui::Button("Analyze current page"))
if (ImGui::Button("hex.view.information.analyze"_lang))
this->m_shouldInvalidate = true;
ImGui::NewLine();
@@ -138,20 +138,20 @@ namespace hex {
ImGui::LabelText(name.c_str(), "%s", value.c_str());
}
ImGui::LabelText("Analyzed region", "0x%llx - 0x%llx", this->m_analyzedRegion.first, this->m_analyzedRegion.second);
ImGui::LabelText("hex.view.information.region"_lang, "0x%llx - 0x%llx", this->m_analyzedRegion.first, this->m_analyzedRegion.second);
ImGui::NewLine();
ImGui::Separator();
ImGui::NewLine();
if (!this->m_fileDescription.empty()) {
ImGui::TextUnformatted("Description:");
ImGui::TextUnformatted("hex.view.information.description"_lang);
ImGui::TextWrapped("%s", this->m_fileDescription.c_str());
ImGui::NewLine();
}
if (!this->m_mimeType.empty()) {
ImGui::TextUnformatted("MIME Type:");
ImGui::TextUnformatted("hex.view.information.mime"_lang);
ImGui::TextWrapped("%s", this->m_mimeType.c_str());
ImGui::NewLine();
}
@@ -159,25 +159,25 @@ namespace hex {
ImGui::Separator();
ImGui::NewLine();
ImGui::Text("Byte Distribution");
ImGui::Text("hex.view.information.distribution"_lang);
ImGui::PlotHistogram("##nolabel", this->m_valueCounts.data(), 256, 0, nullptr, FLT_MAX, FLT_MAX,ImVec2(0, 100));
ImGui::NewLine();
ImGui::Separator();
ImGui::NewLine();
ImGui::Text("Entropy");
ImGui::Text("hex.view.information.entropy"_lang);
ImGui::PlotLines("##nolabel", this->m_blockEntropy.data(), this->m_blockEntropy.size(), 0, nullptr, FLT_MAX, FLT_MAX, ImVec2(0, 100));
ImGui::NewLine();
ImGui::LabelText("Block size", "2048 blocks of %lu bytes", this->m_blockSize);
ImGui::LabelText("Average entropy", "%.8f", this->m_averageEntropy);
ImGui::LabelText("Highest entropy block", "%.8f", this->m_highestBlockEntropy);
ImGui::LabelText("hex.view.information.block_size"_lang, "hex.view.information.block_size.desc"_lang, this->m_blockSize);
ImGui::LabelText("hex.view.information.file_entropy"_lang, "%.8f", this->m_averageEntropy);
ImGui::LabelText("hex.view.information.highest_entropy"_lang, "%.8f", this->m_highestBlockEntropy);
if (this->m_averageEntropy > 0.83 && this->m_highestBlockEntropy > 0.9) {
ImGui::NewLine();
ImGui::TextColored(ImVec4(0.92F, 0.25F, 0.2F, 1.0F),"This data is most likely encrypted or compressed!");
ImGui::TextColored(ImVec4(0.92F, 0.25F, 0.2F, 1.0F),"hex.view.information.encrypted"_lang);
}
}

View File

@@ -11,7 +11,7 @@ using namespace std::literals::string_literals;
namespace hex {
ViewPatches::ViewPatches() : View("Patches") {
ViewPatches::ViewPatches() : View("hex.view.patches.title"_lang) {
View::subscribeEvent(Events::ProjectFileStore, [](auto) {
auto provider = SharedData::currentProvider;
if (provider != nullptr)
@@ -31,7 +31,7 @@ namespace hex {
}
void ViewPatches::drawContent() {
if (ImGui::Begin("Patches", &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (ImGui::Begin("hex.view.patches.title"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
auto provider = SharedData::currentProvider;
if (provider != nullptr && provider->isReadable()) {
@@ -39,9 +39,9 @@ namespace hex {
if (ImGui::BeginTable("##patchesTable", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Sortable |
ImGuiTableFlags_Reorderable | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY)) {
ImGui::TableSetupScrollFreeze(0, 1);
ImGui::TableSetupColumn("Offset");
ImGui::TableSetupColumn("Previous Value");
ImGui::TableSetupColumn("Patched Value");
ImGui::TableSetupColumn("hex.view.patches.offset"_lang);
ImGui::TableSetupColumn("hex.view.patches.orig"_lang);
ImGui::TableSetupColumn("hex.view.patches.patch"_lang);
ImGui::TableHeadersRow();
@@ -73,7 +73,7 @@ namespace hex {
}
if (ImGui::BeginPopup("PatchContextMenu")) {
if (ImGui::MenuItem("Remove")) {
if (ImGui::MenuItem("hex.view.patches.remove"_lang)) {
patches.erase(this->m_selectedPatch);
ProjectFile::markDirty();
}

View File

@@ -74,7 +74,7 @@ namespace hex {
}
ViewPattern::ViewPattern(std::vector<lang::PatternData*> &patternData) : View("Pattern"), m_patternData(patternData) {
ViewPattern::ViewPattern(std::vector<lang::PatternData*> &patternData) : View("hex.view.pattern.title"_lang), m_patternData(patternData) {
this->m_patternLanguageRuntime = new lang::PatternLanguage();
this->m_textEditor.SetLanguageDefinition(PatternLanguage());
@@ -165,7 +165,7 @@ namespace hex {
if (!this->m_possiblePatternFiles.empty()) {
this->m_selectedPatternFile = 0;
View::doLater([] { ImGui::OpenPopup("Accept Pattern"); });
View::doLater([] { ImGui::OpenPopup("hex.view.pattern.accept_pattern"_lang); });
}
});
@@ -200,9 +200,9 @@ namespace hex {
}
void ViewPattern::drawMenu() {
if (ImGui::BeginMenu("File")) {
if (ImGui::MenuItem("Load pattern...")) {
View::openFileBrowser("Open Hex Pattern", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, ".hexpat", [this](auto path) {
if (ImGui::BeginMenu("hex.menu.file"_lang)) {
if (ImGui::MenuItem("hex.view.pattern.menu.file.load_pattern"_lang)) {
View::openFileBrowser("hex.view.pattern.open_pattern"_lang, imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, ".hexpat", [this](auto path) {
this->loadPatternFile(path);
});
}
@@ -211,13 +211,13 @@ namespace hex {
}
void ViewPattern::drawContent() {
if (ImGui::Begin("Pattern", &this->getWindowOpenState(), ImGuiWindowFlags_None | ImGuiWindowFlags_NoCollapse)) {
if (ImGui::Begin("hex.view.pattern.title"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_None | ImGuiWindowFlags_NoCollapse)) {
auto provider = SharedData::currentProvider;
if (provider != nullptr && provider->isAvailable()) {
auto textEditorSize = ImGui::GetContentRegionAvail();
textEditorSize.y *= 4.0/5.0;
this->m_textEditor.Render("Pattern", textEditorSize, true);
this->m_textEditor.Render("hex.view.pattern.title"_lang, textEditorSize, true);
auto consoleSize = ImGui::GetContentRegionAvail();
ImGui::PushStyleColor(ImGuiCol_ChildBg, this->m_textEditor.GetPalette()[u32(TextEditor::PaletteIndex::Background)]);
@@ -260,8 +260,8 @@ namespace hex {
}
void ViewPattern::drawAlwaysVisible() {
if (ImGui::BeginPopupModal("Accept Pattern", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::TextWrapped("One or more patterns compatible with this data type has been found");
if (ImGui::BeginPopupModal("hex.view.pattern.accept_pattern"_lang, nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::TextWrapped("hex.view.pattern.accept_pattern.desc"_lang);
char *entries[this->m_possiblePatternFiles.size()];
@@ -269,12 +269,12 @@ namespace hex {
entries[i] = this->m_possiblePatternFiles[i].data();
}
ImGui::ListBox("Patterns", &this->m_selectedPatternFile, entries, IM_ARRAYSIZE(entries), 4);
ImGui::ListBox("hex.view.pattern.accept_pattern.patterns"_lang, &this->m_selectedPatternFile, entries, IM_ARRAYSIZE(entries), 4);
ImGui::NewLine();
ImGui::Text("Do you want to load it?");
ImGui::Text("hex.view.pattern.accept_pattern.question"_lang);
confirmButtons("Yes", "No", [this]{
confirmButtons("hex.common.yes"_lang, "hex.common.no"_lang, [this]{
this->loadPatternFile("patterns/" + this->m_possiblePatternFiles[this->m_selectedPatternFile]);
ImGui::CloseCurrentPopup();
}, []{

View File

@@ -6,7 +6,7 @@
namespace hex {
ViewPatternData::ViewPatternData(std::vector<lang::PatternData*> &patternData)
: View("Pattern Data"), m_patternData(patternData) {
: View("hex.view.pattern_data.title"_lang), m_patternData(patternData) {
this->subscribeEvent(Events::PatternChanged, [this](auto data) {
this->m_sortedPatternData.clear();
@@ -20,12 +20,12 @@ namespace hex {
static bool beginPatternDataTable(prv::Provider* &provider, const std::vector<lang::PatternData*> &patterns, std::vector<lang::PatternData*> &sortedPatterns) {
if (ImGui::BeginTable("##patterndatatable", 6, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Sortable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY)) {
ImGui::TableSetupScrollFreeze(0, 1);
ImGui::TableSetupColumn("Name", 0, -1, ImGui::GetID("name"));
ImGui::TableSetupColumn("Color", 0, -1, ImGui::GetID("color"));
ImGui::TableSetupColumn("Offset", 0, -1, ImGui::GetID("offset"));
ImGui::TableSetupColumn("Size", 0, -1, ImGui::GetID("size"));
ImGui::TableSetupColumn("Type", 0, -1, ImGui::GetID("type"));
ImGui::TableSetupColumn("Value", 0, -1, ImGui::GetID("value"));
ImGui::TableSetupColumn("hex.view.pattern_data.name"_lang, 0, -1, ImGui::GetID("name"));
ImGui::TableSetupColumn("hex.view.pattern_data.color"_lang, 0, -1, ImGui::GetID("color"));
ImGui::TableSetupColumn("hex.view.pattern_data.offset"_lang, 0, -1, ImGui::GetID("offset"));
ImGui::TableSetupColumn("hex.view.pattern_data.size"_lang, 0, -1, ImGui::GetID("size"));
ImGui::TableSetupColumn("hex.view.pattern_data.type"_lang, 0, -1, ImGui::GetID("type"));
ImGui::TableSetupColumn("hex.view.pattern_data.value"_lang, 0, -1, ImGui::GetID("value"));
auto sortSpecs = ImGui::TableGetSortSpecs();
@@ -49,7 +49,7 @@ namespace hex {
}
void ViewPatternData::drawContent() {
if (ImGui::Begin("Pattern Data", &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (ImGui::Begin("hex.view.pattern_data.title"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
auto provider = SharedData::currentProvider;
if (provider != nullptr && provider->isReadable()) {

View File

@@ -4,10 +4,10 @@
namespace hex {
ViewSettings::ViewSettings() : View("Settings") {
ViewSettings::ViewSettings() : View("hex.view.settings.title"_lang) {
View::subscribeEvent(Events::OpenWindow, [this](auto name) {
if (std::any_cast<const char*>(name) == std::string("Preferences")) {
View::doLater([]{ ImGui::OpenPopup("Preferences"); });
if (std::any_cast<const char*>(name) == std::string("hex.view.settings.title"_lang)) {
View::doLater([]{ ImGui::OpenPopup("hex.view.settings.title"_lang); });
this->getWindowOpenState() = true;
}
});
@@ -21,16 +21,13 @@ namespace hex {
ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX));
if (ImGui::BeginPopupModal("Preferences", &this->getWindowOpenState(), ImGuiWindowFlags_AlwaysAutoResize)) {
if (ImGui::BeginPopupModal("hex.view.settings.title"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_AlwaysAutoResize)) {
for (auto &[category, entries] : ContentRegistry::Settings::getEntries()) {
ImGui::TextUnformatted(category.c_str());
ImGui::Separator();
for (auto &[name, callback] : entries) {
ImGui::TextUnformatted(name.c_str());
ImGui::SameLine();
if (callback(ContentRegistry::Settings::getSettingsData()[category][name]))
View::postEvent(Events::SettingsChanged);
ImGui::NewLine();
}
ImGui::NewLine();
}
@@ -41,9 +38,9 @@ namespace hex {
}
void ViewSettings::drawMenu() {
if (ImGui::BeginMenu("Help")) {
if (ImGui::MenuItem("Preferences")) {
View::doLater([]{ ImGui::OpenPopup("Preferences"); });
if (ImGui::BeginMenu("hex.menu.help"_lang)) {
if (ImGui::MenuItem("hex.view.settings.title"_lang)) {
View::doLater([]{ ImGui::OpenPopup("hex.view.settings.title"_lang); });
this->getWindowOpenState() = true;
}
ImGui::EndMenu();

View File

@@ -11,7 +11,7 @@ using namespace std::literals::string_literals;
namespace hex {
ViewStrings::ViewStrings() : View("Strings") {
ViewStrings::ViewStrings() : View("hex.view.strings.title"_lang) {
View::subscribeEvent(Events::DataChanged, [this](auto){
this->m_foundStrings.clear();
});
@@ -32,14 +32,14 @@ namespace hex {
this->m_selectedString = foundString.string;
}
if (ImGui::BeginPopup("StringContextMenu")) {
if (ImGui::MenuItem("Copy string")) {
if (ImGui::MenuItem("hex.view.strings.copy"_lang)) {
ImGui::SetClipboardText(this->m_selectedString.c_str());
}
ImGui::Separator();
if (ImGui::MenuItem("Demangle")) {
if (ImGui::MenuItem("hex.view.strings.demangle"_lang)) {
this->m_demangledName = llvm::demangle(this->m_selectedString);
if (!this->m_demangledName.empty())
View::doLater([]{ ImGui::OpenPopup("Demangled Name"); });
View::doLater([]{ ImGui::OpenPopup("hex.view.strings.demangle.title"_lang); });
}
ImGui::EndPopup();
}
@@ -86,11 +86,11 @@ namespace hex {
if (ImGui::Begin("Strings", &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (provider != nullptr && provider->isReadable()) {
if (ImGui::InputInt("Minimum length", &this->m_minimumLength, 1, 0))
if (ImGui::InputInt("hex.view.strings.min_length"_lang, &this->m_minimumLength, 1, 0))
this->m_shouldInvalidate = true;
ImGui::InputText("Filter", this->m_filter, 0xFFFF);
if (ImGui::Button("Extract"))
ImGui::InputText("hex.view.strings.filter"_lang, this->m_filter, 0xFFFF);
if (ImGui::Button("hex.view.strings.extract"_lang))
this->m_shouldInvalidate = true;
ImGui::Separator();
@@ -100,26 +100,26 @@ namespace hex {
ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Sortable |
ImGuiTableFlags_Reorderable | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY)) {
ImGui::TableSetupScrollFreeze(0, 1);
ImGui::TableSetupColumn("Offset", 0, -1, ImGui::GetID("offset"));
ImGui::TableSetupColumn("Size", 0, -1, ImGui::GetID("size"));
ImGui::TableSetupColumn("String", 0, -1, ImGui::GetID("string"));
ImGui::TableSetupColumn("hex.view.strings.offset"_lang, 0, -1, ImGui::GetID("offset"));
ImGui::TableSetupColumn("hex.view.strings.size"_lang, 0, -1, ImGui::GetID("size"));
ImGui::TableSetupColumn("hex.view.strings.string"_lang, 0, -1, ImGui::GetID("string"));
auto sortSpecs = ImGui::TableGetSortSpecs();
if (sortSpecs->SpecsDirty) {
std::sort(this->m_foundStrings.begin(), this->m_foundStrings.end(),
[&sortSpecs](FoundString &left, FoundString &right) -> bool {
if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("offset")) {
if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("hex.view.strings.offset"_lang)) {
if (sortSpecs->Specs->SortDirection == ImGuiSortDirection_Ascending)
return left.offset > right.offset;
else
return left.offset < right.offset;
} else if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("size")) {
} else if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("hex.view.strings.size"_lang)) {
if (sortSpecs->Specs->SortDirection == ImGuiSortDirection_Ascending)
return left.size > right.size;
else
return left.size < right.size;
} else if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("string")) {
} else if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("hex.view.strings.string"_lang)) {
if (sortSpecs->Specs->SortDirection == ImGuiSortDirection_Ascending)
return left.string > right.string;
else
@@ -170,14 +170,14 @@ namespace hex {
}
ImGui::End();
if (ImGui::BeginPopup("Demangled Name")) {
if (ImGui::BeginPopup("hex.view.strings.demangle.title"_lang)) {
if (ImGui::BeginChild("##scrolling", ImVec2(500, 150))) {
ImGui::Text("Demangled Name");
ImGui::Text("hex.view.strings.demangle.title"_lang);
ImGui::Separator();
ImGui::TextWrapped("%s", this->m_demangledName.c_str());
ImGui::EndChild();
ImGui::NewLine();
if (ImGui::Button("Copy"))
if (ImGui::Button("hex.view.strings.demangle.copy"_lang))
ImGui::SetClipboardText(this->m_demangledName.c_str());
}
ImGui::EndPopup();

View File

@@ -4,12 +4,12 @@
namespace hex {
ViewTools::ViewTools() : View("Tools") { }
ViewTools::ViewTools() : View("hex.view.tools.title"_lang) { }
ViewTools::~ViewTools() { }
void ViewTools::drawContent() {
if (ImGui::Begin("Tools", &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
if (ImGui::Begin("hex.view.tools.title"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
for (const auto& [name, function] : ContentRegistry::Tools::getEntries()) {
if (ImGui::CollapsingHeader(name.c_str())) {
function();

View File

@@ -5,6 +5,7 @@
#include <iostream>
#include <numeric>
#include <typeinfo>
#include <imgui.h>
#include <imgui_internal.h>
@@ -20,8 +21,6 @@
namespace hex {
constexpr auto MenuBarItems = { "File", "Edit", "View", "Help" };
void *ImHexSettingsHandler_ReadOpenFn(ImGuiContext *ctx, ImGuiSettingsHandler *, const char *) {
return ctx; // Unused, but the return value has to be non-null
}
@@ -39,7 +38,7 @@ namespace hex {
buf->appendf("[%s][General]\n", handler->TypeName);
for (auto &view : ContentRegistry::Views::getEntries()) {
buf->appendf("%s=%d\n", view->getName().data(), view->getWindowOpenState());
buf->appendf("%s=%d\n", typeid(*view).name(), view->getWindowOpenState());
}
buf->append("\n");
@@ -51,7 +50,6 @@ namespace hex {
this->initGLFW();
this->initImGui();
this->initPlugins();
ImGui::GetStyle().Colors[ImGuiCol_DockingEmptyBg] = ImGui::GetStyle().Colors[ImGuiCol_WindowBg];
EventManager::subscribe(Events::SettingsChanged, this, [](auto) -> std::any {
@@ -126,6 +124,8 @@ namespace hex {
for (const auto &path : ContentRegistry::Settings::read("ImHex", "RecentFiles"))
this->m_recentFiles.push_back(path);
this->initPlugins();
}
Window::~Window() {
@@ -200,7 +200,6 @@ namespace hex {
}
void Window::frameBegin() {
printf("%s\n", static_cast<const char*>("hello.world"_lang));
glfwPollEvents();
ImGui_ImplOpenGL3_NewFrame();
@@ -227,13 +226,15 @@ namespace hex {
if (ImGui::BeginMenuBar()) {
auto MenuBarItems = { "hex.menu.file"_lang, "hex.menu.edit"_lang, "hex.menu.view"_lang, "hex.menu.help"_lang };
for (auto menu : MenuBarItems)
if (ImGui::BeginMenu(menu)) ImGui::EndMenu();
if (ImGui::BeginMenu("View")) {
if (ImGui::BeginMenu("hex.menu.view"_lang)) {
for (auto &view : ContentRegistry::Views::getEntries()) {
if (view->hasViewMenuItemEntry())
ImGui::MenuItem((std::string(view->getName()) + " View").c_str(), "", &view->getWindowOpenState());
ImGui::MenuItem((std::string(view->getName()) + " " + "hex.menu.view"_lang).c_str(), "", &view->getWindowOpenState());
}
ImGui::EndMenu();
}
@@ -242,11 +243,11 @@ namespace hex {
view->drawMenu();
}
if (ImGui::BeginMenu("View")) {
if (ImGui::BeginMenu("hex.menu.view"_lang)) {
ImGui::Separator();
ImGui::MenuItem("Display FPS", "", &this->m_fpsVisible);
ImGui::MenuItem("hex.menu.view.fps"_lang, "", &this->m_fpsVisible);
#ifdef DEBUG
ImGui::MenuItem("Demo View", "", &this->m_demoWindowOpen);
ImGui::MenuItem("hex.menu.view.demo"_lang, "", &this->m_demoWindowOpen);
#endif
ImGui::EndMenu();
}
@@ -314,7 +315,7 @@ namespace hex {
}
void Window::drawWelcomeScreen() {
ImGui::UnderlinedText("Welcome to ImHex!", ImGui::GetStyleColorVec4(ImGuiCol_HeaderActive));
ImGui::UnderlinedText("hex.welcome.header.main"_lang, ImGui::GetStyleColorVec4(ImGuiCol_HeaderActive));
ImGui::NewLine();
@@ -324,16 +325,16 @@ namespace hex {
if (ImGui::BeginTable("Welcome Left", 1, ImGuiTableFlags_NoBordersInBody, ImVec2(availableSpace.x / 2, availableSpace.y))) {
ImGui::TableNextRow(ImGuiTableRowFlags_None, 100);
ImGui::TableNextColumn();
ImGui::Text("Start");
ImGui::Text("hex.welcome.header.start"_lang);
{
if (ImGui::BulletHyperlink("Open File"))
if (ImGui::BulletHyperlink("hex.welcome.start.open_file"_lang))
EventManager::post(Events::OpenWindow, "Open File");
if (ImGui::BulletHyperlink("Open Project"))
if (ImGui::BulletHyperlink("hex.welcome.start.open_project"_lang))
EventManager::post(Events::OpenWindow, "Open Project");
}
ImGui::TableNextRow(ImGuiTableRowFlags_None, 100);
ImGui::TableNextColumn();
ImGui::Text("Recent");
ImGui::Text("hex.welcome.start.recent"_lang);
{
if (!this->m_recentFiles.empty()) {
for (auto &path : this->m_recentFiles) {
@@ -346,10 +347,10 @@ namespace hex {
}
ImGui::TableNextRow(ImGuiTableRowFlags_None, 100);
ImGui::TableNextColumn();
ImGui::Text("Help");
ImGui::Text("hex.welcome.header.help"_lang);
{
if (ImGui::BulletHyperlink("GitHub Repository")) hex::openWebpage("https://github.com/WerWolv/ImHex");
if (ImGui::BulletHyperlink("Get help")) hex::openWebpage("https://github.com/WerWolv/ImHex/discussions/categories/get-help");
if (ImGui::BulletHyperlink("hex.welcome.help.repo"_lang)) hex::openWebpage("hex.welcome.help.repo.link"_lang);
if (ImGui::BulletHyperlink("hex.welcome.help.gethelp"_lang)) hex::openWebpage("hex.welcome.help.gethelp.link"_lang);
}
ImGui::EndTable();
@@ -358,21 +359,21 @@ namespace hex {
if (ImGui::BeginTable("Welcome Right", 1, ImGuiTableFlags_NoBordersInBody, ImVec2(availableSpace.x / 2, availableSpace.y))) {
ImGui::TableNextRow(ImGuiTableRowFlags_None, 100);
ImGui::TableNextColumn();
ImGui::Text("Customize");
ImGui::Text("hex.welcome.header.customize"_lang);
{
if (ImGui::DescriptionButton("Settings", "Change preferences of ImHex", ImVec2(ImGui::GetContentRegionAvail().x * 0.8f, 0)))
if (ImGui::DescriptionButton("hex.welcome.customize.settings.title"_lang, "hex.welcome.customize.settings.desc"_lang, ImVec2(ImGui::GetContentRegionAvail().x * 0.8f, 0)))
EventManager::post(Events::OpenWindow, "Preferences");
}
ImGui::TableNextRow(ImGuiTableRowFlags_None, 100);
ImGui::TableNextColumn();
ImGui::Text("Learn");
ImGui::Text("hex.welcome.header.learn"_lang);
{
if (ImGui::DescriptionButton("Latest Release", "Get the latest version of ImHex or read the current changelog", ImVec2(ImGui::GetContentRegionAvail().x * 0.8, 0)))
hex::openWebpage("https://github.com/WerWolv/ImHex/releases/latest");
if (ImGui::DescriptionButton("Pattern Language Documentation", "Learn how to write ImHex patterns with our extensive documentation", ImVec2(ImGui::GetContentRegionAvail().x * 0.8, 0)))
hex::openWebpage("https://github.com/WerWolv/ImHex/wiki/Pattern-Language-Guide");
if (ImGui::DescriptionButton("Plugins API", "Extend ImHex with additional features using plugins", ImVec2(ImGui::GetContentRegionAvail().x * 0.8, 0)))
hex::openWebpage("https://github.com/WerWolv/ImHex/wiki/Plugins-Development-Guide");
if (ImGui::DescriptionButton("hex.welcome.learn.latest.title"_lang, "hex.welcome.learn.latest.desc"_lang, ImVec2(ImGui::GetContentRegionAvail().x * 0.8, 0)))
hex::openWebpage("hex.welcome.learn.latest.link"_lang);
if (ImGui::DescriptionButton("hex.welcome.learn.pattern.title"_lang, "hex.welcome.learn.pattern.desc"_lang, ImVec2(ImGui::GetContentRegionAvail().x * 0.8, 0)))
hex::openWebpage("hex.welcome.learn.pattern.link"_lang);
if (ImGui::DescriptionButton("hex.welcome.learn.plugins.title"_lang, "hex.welcome.learn.plugins.desc"_lang, ImVec2(ImGui::GetContentRegionAvail().x * 0.8, 0)))
hex::openWebpage("hex.welcome.learn.plugins.link"_lang);
}
ImGui::EndTable();