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:
@@ -101,7 +101,7 @@ namespace hex {
|
||||
|
||||
std::vector<CommandResult> results;
|
||||
|
||||
for (const auto &[type, command, description, displayCallback, executeCallback] : ContentRegistry::CommandPaletteCommands::getEntries()) {
|
||||
for (const auto &[type, command, unlocalizedDescription, displayCallback, executeCallback] : ContentRegistry::CommandPaletteCommands::getEntries()) {
|
||||
|
||||
auto AutoComplete = [this, &currCommand = command](auto) {
|
||||
focusInputTextBox();
|
||||
@@ -112,7 +112,7 @@ namespace hex {
|
||||
if (type == ContentRegistry::CommandPaletteCommands::Type::SymbolCommand) {
|
||||
if (auto [match, value] = MatchCommand(input, command); match != MatchType::NoMatch) {
|
||||
if (match != MatchType::PerfectMatch)
|
||||
results.push_back({ command + " (" + description + ")", "", AutoComplete });
|
||||
results.push_back({ command + " (" + LangEntry(unlocalizedDescription) + ")", "", AutoComplete });
|
||||
else {
|
||||
auto matchedCommand = input.substr(command.length()).data();
|
||||
results.push_back({ displayCallback(matchedCommand), matchedCommand, executeCallback });
|
||||
@@ -121,7 +121,7 @@ namespace hex {
|
||||
} else if (type == ContentRegistry::CommandPaletteCommands::Type::KeywordCommand) {
|
||||
if (auto [match, value] = MatchCommand(input, command + " "); match != MatchType::NoMatch) {
|
||||
if (match != MatchType::PerfectMatch)
|
||||
results.push_back({ command + " (" + description + ")", "", AutoComplete });
|
||||
results.push_back({ command + " (" + LangEntry(unlocalizedDescription) + ")", "", AutoComplete });
|
||||
else {
|
||||
auto matchedCommand = input.substr(command.length() + 1).data();
|
||||
results.push_back({ displayCallback(matchedCommand), matchedCommand, executeCallback });
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace hex {
|
||||
|
||||
std::vector<u8> buffer(entry.requiredSize);
|
||||
provider->read(this->m_startAddress, buffer.data(), buffer.size());
|
||||
this->m_cachedData.emplace_back(entry.name, entry.generatorFunction(buffer, this->m_endian, this->m_numberDisplayStyle));
|
||||
this->m_cachedData.emplace_back(entry.unlocalizedName, entry.generatorFunction(buffer, this->m_endian, this->m_numberDisplayStyle));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,10 +67,10 @@ namespace hex {
|
||||
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
for (const auto &[name, function] : this->m_cachedData) {
|
||||
for (const auto &[unlocalizedName, function] : this->m_cachedData) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextUnformatted(name.c_str());
|
||||
ImGui::TextUnformatted(LangEntry(unlocalizedName));
|
||||
ImGui::TableNextColumn();
|
||||
function();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace hex {
|
||||
}
|
||||
|
||||
View::subscribeEvent(Events::SettingsChanged, [](auto) {
|
||||
int theme = ContentRegistry::Settings::getSettingsData()["Interface"]["Color theme"];
|
||||
int theme = ContentRegistry::Settings::getSettingsData()["hex.builtin.setting.interface"]["hex.builtin.setting.interface.color"];
|
||||
|
||||
switch (theme) {
|
||||
default:
|
||||
@@ -238,7 +238,7 @@ namespace hex {
|
||||
imnodes::BeginNode(node->getID());
|
||||
|
||||
imnodes::BeginNodeTitleBar();
|
||||
ImGui::TextUnformatted(node->getTitle().data());
|
||||
ImGui::TextUnformatted(LangEntry(node->getUnlocalizedName()));
|
||||
imnodes::EndNodeTitleBar();
|
||||
|
||||
node->drawNode();
|
||||
@@ -254,11 +254,11 @@ namespace hex {
|
||||
|
||||
if (attribute.getIOType() == dp::Attribute::IOType::In) {
|
||||
imnodes::BeginInputAttribute(attribute.getID(), pinShape);
|
||||
ImGui::TextUnformatted(attribute.getName().data());
|
||||
ImGui::TextUnformatted(LangEntry(attribute.getUnlocalizedName()));
|
||||
imnodes::EndInputAttribute();
|
||||
} else if (attribute.getIOType() == dp::Attribute::IOType::Out) {
|
||||
imnodes::BeginOutputAttribute(attribute.getID(), imnodes::PinShape(pinShape + 1));
|
||||
ImGui::TextUnformatted(attribute.getName().data());
|
||||
ImGui::TextUnformatted(LangEntry(attribute.getUnlocalizedName()));
|
||||
imnodes::EndOutputAttribute();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ namespace hex {
|
||||
{
|
||||
|
||||
View::subscribeEvent(Events::SettingsChanged, [this](auto) {
|
||||
int theme = ContentRegistry::Settings::getSettingsData()["Interface"]["Color theme"];
|
||||
int theme = ContentRegistry::Settings::getSettingsData()["hex.builtin.setting.interface"]["hex.builtin.setting.interface.color"];
|
||||
|
||||
switch (theme) {
|
||||
default:
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace hex {
|
||||
|
||||
ViewSettings::ViewSettings() : View("hex.view.settings.title"_lang) {
|
||||
View::subscribeEvent(Events::OpenWindow, [this](auto name) {
|
||||
if (std::any_cast<const char*>(name) == std::string("hex.view.settings.title"_lang)) {
|
||||
if (std::any_cast<const char*>(name) == std::string("hex.view.settings.title")) {
|
||||
View::doLater([]{ ImGui::OpenPopup("hex.view.settings.title"_lang); });
|
||||
this->getWindowOpenState() = true;
|
||||
}
|
||||
@@ -23,10 +23,10 @@ namespace hex {
|
||||
|
||||
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::TextUnformatted(LangEntry(category));
|
||||
ImGui::Separator();
|
||||
for (auto &[name, callback] : entries) {
|
||||
if (callback(ContentRegistry::Settings::getSettingsData()[category][name]))
|
||||
if (callback(LangEntry(name), ContentRegistry::Settings::getSettingsData()[category][name]))
|
||||
View::postEvent(Events::SettingsChanged);
|
||||
}
|
||||
ImGui::NewLine();
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace hex {
|
||||
void ViewTools::drawContent() {
|
||||
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())) {
|
||||
if (ImGui::CollapsingHeader(LangEntry(name))) {
|
||||
function();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace hex {
|
||||
EventManager::subscribe(Events::SettingsChanged, this, [](auto) -> std::any {
|
||||
|
||||
{
|
||||
int theme = ContentRegistry::Settings::getSettingsData()["Interface"]["Color theme"];
|
||||
int theme = ContentRegistry::Settings::getSettingsData()["hex.builtin.setting.interface"]["hex.builtin.setting.interface.color"];
|
||||
switch (theme) {
|
||||
default:
|
||||
case 0: /* Dark theme */
|
||||
@@ -72,7 +72,7 @@ namespace hex {
|
||||
}
|
||||
|
||||
{
|
||||
std::string language = ContentRegistry::Settings::getSettingsData()["Interface"]["Language"];
|
||||
std::string language = ContentRegistry::Settings::getSettingsData()["hex.builtin.setting.interface"]["hex.builtin.setting.interface.language"];
|
||||
LangEntry::loadLanguage(language);
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace hex {
|
||||
std::vector<std::string> recentFilesVector;
|
||||
std::copy(this->m_recentFiles.begin(), this->m_recentFiles.end(), std::back_inserter(recentFilesVector));
|
||||
|
||||
ContentRegistry::Settings::write("ImHex", "RecentFiles", recentFilesVector);
|
||||
ContentRegistry::Settings::write("hex.builtin.setting.imhex", "hex.builtin.setting.imhex.recent_files", recentFilesVector);
|
||||
}
|
||||
|
||||
return { };
|
||||
@@ -119,13 +119,13 @@ namespace hex {
|
||||
return { };
|
||||
});
|
||||
|
||||
this->initPlugins();
|
||||
|
||||
ContentRegistry::Settings::load();
|
||||
View::postEvent(Events::SettingsChanged);
|
||||
|
||||
for (const auto &path : ContentRegistry::Settings::read("ImHex", "RecentFiles"))
|
||||
for (const auto &path : ContentRegistry::Settings::read("hex.builtin.setting.imhex", "hex.builtin.setting.imhex.recent_files"))
|
||||
this->m_recentFiles.push_back(path);
|
||||
|
||||
this->initPlugins();
|
||||
}
|
||||
|
||||
Window::~Window() {
|
||||
@@ -362,7 +362,7 @@ namespace hex {
|
||||
ImGui::Text("hex.welcome.header.customize"_lang);
|
||||
{
|
||||
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");
|
||||
EventManager::post(Events::OpenWindow, "hex.view.settings.title");
|
||||
}
|
||||
ImGui::TableNextRow(ImGuiTableRowFlags_None, 100);
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
Reference in New Issue
Block a user