refactor: Rename and update localization system
This commit is contained in:
parent
c89a870fe9
commit
909f4b7fe8
@ -15,7 +15,7 @@ set(LIBIMHEX_SOURCES
|
||||
source/api/theme_manager.cpp
|
||||
source/api/layout_manager.cpp
|
||||
source/api/achievement_manager.cpp
|
||||
source/api/localization.cpp
|
||||
source/api/localization_manager.cpp
|
||||
|
||||
source/data_processor/attribute.cpp
|
||||
source/data_processor/link.cpp
|
||||
|
@ -24,7 +24,6 @@ struct ImColor;
|
||||
namespace hex {
|
||||
|
||||
class View;
|
||||
class LanguageDefinition;
|
||||
class Shortcut;
|
||||
|
||||
namespace dp {
|
||||
@ -34,6 +33,10 @@ namespace hex {
|
||||
class Provider;
|
||||
}
|
||||
|
||||
namespace LocalizationManager {
|
||||
class LanguageDefinition;
|
||||
}
|
||||
|
||||
/*
|
||||
The Content Registry is the heart of all features in ImHex that are in some way extendable by Plugins.
|
||||
It allows you to add/register new content that will be picked up and used by the ImHex core or by other
|
||||
@ -590,7 +593,7 @@ namespace hex {
|
||||
|
||||
}
|
||||
|
||||
/* Language Registry. Allows together with the LangEntry class and the _lang user defined literal to add new languages */
|
||||
/* Language Registry. Allows together with the Lang class and the _lang user defined literal to add new languages */
|
||||
namespace Language {
|
||||
|
||||
/**
|
||||
@ -602,7 +605,7 @@ namespace hex {
|
||||
namespace impl {
|
||||
|
||||
std::map<std::string, std::string> &getLanguages();
|
||||
std::map<std::string, std::vector<LanguageDefinition>> &getLanguageDefinitions();
|
||||
std::map<std::string, std::vector<LocalizationManager::LanguageDefinition>> &getLanguageDefinitions();
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,67 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace hex {
|
||||
|
||||
class LanguageDefinition {
|
||||
public:
|
||||
explicit LanguageDefinition(std::map<std::string, std::string> &&entries);
|
||||
|
||||
[[nodiscard]] const std::map<std::string, std::string> &getEntries() const;
|
||||
|
||||
private:
|
||||
std::map<std::string, std::string> m_entries;
|
||||
};
|
||||
|
||||
class LangEntry {
|
||||
public:
|
||||
explicit LangEntry(const char *unlocalizedString);
|
||||
explicit LangEntry(std::string unlocalizedString);
|
||||
explicit LangEntry(std::string_view unlocalizedString);
|
||||
|
||||
operator std::string() const;
|
||||
operator std::string_view() const;
|
||||
operator const char *() const;
|
||||
|
||||
[[nodiscard]] const std::string &get() const;
|
||||
|
||||
static void loadLanguage(const std::string &language);
|
||||
static const std::map<std::string, std::string> &getSupportedLanguages();
|
||||
|
||||
static void setFallbackLanguage(const std::string &language);
|
||||
static const std::string &getFallbackLanguage();
|
||||
|
||||
static void resetLanguageStrings();
|
||||
|
||||
static const std::string &getSelectedLanguage();
|
||||
|
||||
private:
|
||||
std::string m_unlocalizedString;
|
||||
};
|
||||
|
||||
std::string operator+(const std::string &&left, const LangEntry &&right);
|
||||
std::string operator+(const LangEntry &&left, const std::string &&right);
|
||||
std::string operator+(const std::string_view &&left, const LangEntry &&right);
|
||||
std::string operator+(const LangEntry &&left, const std::string_view &&right);
|
||||
std::string operator+(const char *left, const LangEntry &&right);
|
||||
std::string operator+(const LangEntry &&left, const char *right);
|
||||
std::string operator+(const LangEntry &&left, const LangEntry &&right);
|
||||
|
||||
inline LangEntry operator""_lang(const char *string, size_t) {
|
||||
return LangEntry(string);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
struct fmt::formatter<hex::LangEntry> : fmt::formatter<std::string_view> {
|
||||
template<typename FormatContext>
|
||||
auto format(const hex::LangEntry &entry, FormatContext &ctx) {
|
||||
return fmt::formatter<std::string_view>::format(entry.get(), ctx);
|
||||
}
|
||||
};
|
71
lib/libimhex/include/hex/api/localization_manager.hpp
Normal file
71
lib/libimhex/include/hex/api/localization_manager.hpp
Normal file
@ -0,0 +1,71 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace hex {
|
||||
|
||||
namespace LocalizationManager {
|
||||
|
||||
class LanguageDefinition {
|
||||
public:
|
||||
explicit LanguageDefinition(std::map<std::string, std::string> &&entries);
|
||||
|
||||
[[nodiscard]] const std::map<std::string, std::string> &getEntries() const;
|
||||
|
||||
private:
|
||||
std::map<std::string, std::string> m_entries;
|
||||
};
|
||||
|
||||
namespace impl {
|
||||
void setFallbackLanguage(const std::string &language);
|
||||
void resetLanguageStrings();
|
||||
}
|
||||
|
||||
void loadLanguage(const std::string &language);
|
||||
|
||||
[[nodiscard]] const std::map<std::string, std::string> &getSupportedLanguages();
|
||||
[[nodiscard]] const std::string &getFallbackLanguage();
|
||||
[[nodiscard]] const std::string &getSelectedLanguage();
|
||||
}
|
||||
|
||||
class Lang {
|
||||
public:
|
||||
explicit Lang(const char *unlocalizedString);
|
||||
explicit Lang(std::string unlocalizedString);
|
||||
explicit Lang(std::string_view unlocalizedString);
|
||||
|
||||
[[nodiscard]] operator std::string() const;
|
||||
[[nodiscard]] operator std::string_view() const;
|
||||
[[nodiscard]] operator const char *() const;
|
||||
|
||||
[[nodiscard]] const std::string &get() const;
|
||||
|
||||
private:
|
||||
std::string m_unlocalizedString;
|
||||
};
|
||||
|
||||
[[nodiscard]] std::string operator+(const std::string &&left, const Lang &&right);
|
||||
[[nodiscard]] std::string operator+(const Lang &&left, const std::string &&right);
|
||||
[[nodiscard]] std::string operator+(const std::string_view &&left, const Lang &&right);
|
||||
[[nodiscard]] std::string operator+(const Lang &&left, const std::string_view &&right);
|
||||
[[nodiscard]] std::string operator+(const char *left, const Lang &&right);
|
||||
[[nodiscard]] std::string operator+(const Lang &&left, const char *right);
|
||||
[[nodiscard]] std::string operator+(const Lang &&left, const Lang &&right);
|
||||
|
||||
[[nodiscard]] inline Lang operator""_lang(const char *string, size_t) {
|
||||
return Lang(string);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
struct fmt::formatter<hex::Lang> : fmt::formatter<std::string_view> {
|
||||
template<typename FormatContext>
|
||||
auto format(const hex::Lang &entry, FormatContext &ctx) {
|
||||
return fmt::formatter<std::string_view>::format(entry.get(), ctx);
|
||||
}
|
||||
};
|
@ -16,7 +16,7 @@
|
||||
#include <hex/providers/provider_data.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
@ -56,7 +56,7 @@ namespace hex {
|
||||
* drawn in the drawAlwaysVisibleContent() function.
|
||||
* @return True if the view should be processed, false otherwise
|
||||
*/
|
||||
[[nodiscard]] virtual bool shouldProcess() const { return true; }
|
||||
[[nodiscard]] virtual bool shouldProcess() const;
|
||||
|
||||
/**
|
||||
* @brief Whether or not the view should have an entry in the view menu
|
||||
@ -170,8 +170,9 @@ namespace hex {
|
||||
|
||||
if (ImGui::BeginPopupModal(View::toWindowName(this->getUnlocalizedName()).c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse | this->getWindowFlags())) {
|
||||
this->drawContent();
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -267,13 +267,13 @@ namespace hex {
|
||||
preview = this->m_items[this->m_value].c_str();
|
||||
|
||||
bool changed = false;
|
||||
if (ImGui::BeginCombo(name.c_str(), LangEntry(preview))) {
|
||||
if (ImGui::BeginCombo(name.c_str(), Lang(preview))) {
|
||||
|
||||
int index = 0;
|
||||
for (const auto &item : this->m_items) {
|
||||
const bool selected = index == this->m_value;
|
||||
|
||||
if (ImGui::Selectable(LangEntry(item), selected)) {
|
||||
if (ImGui::Selectable(Lang(item), selected)) {
|
||||
this->m_value = index;
|
||||
changed = true;
|
||||
}
|
||||
@ -665,7 +665,7 @@ namespace hex {
|
||||
const auto &fallback = data["fallback"];
|
||||
|
||||
if (fallback.is_boolean() && fallback.get<bool>())
|
||||
LangEntry::setFallbackLanguage(code.get<std::string>());
|
||||
LocalizationManager::impl::setFallbackLanguage(code.get<std::string>());
|
||||
}
|
||||
|
||||
impl::getLanguages().insert({ code.get<std::string>(), hex::format("{} ({})", language.get<std::string>(), country.get<std::string>()) });
|
||||
@ -691,8 +691,8 @@ namespace hex {
|
||||
return languages;
|
||||
}
|
||||
|
||||
std::map<std::string, std::vector<LanguageDefinition>> &getLanguageDefinitions() {
|
||||
static std::map<std::string, std::vector<LanguageDefinition>> definitions;
|
||||
std::map<std::string, std::vector<LocalizationManager::LanguageDefinition>> &getLanguageDefinitions() {
|
||||
static std::map<std::string, std::vector<LocalizationManager::LanguageDefinition>> definitions;
|
||||
|
||||
return definitions;
|
||||
}
|
||||
|
@ -1,123 +0,0 @@
|
||||
#include <hex/api/localization.hpp>
|
||||
|
||||
#include <hex/api/content_registry.hpp>
|
||||
|
||||
namespace hex {
|
||||
|
||||
namespace {
|
||||
|
||||
std::string s_fallbackLanguage;
|
||||
std::string s_selectedLanguage;
|
||||
std::map<std::string, std::string> s_currStrings;
|
||||
|
||||
}
|
||||
|
||||
|
||||
LanguageDefinition::LanguageDefinition(std::map<std::string, std::string> &&entries) {
|
||||
for (const auto &[key, value] : entries) {
|
||||
if (value.empty())
|
||||
continue;
|
||||
|
||||
this->m_entries.insert({ key, value });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const std::map<std::string, std::string> &LanguageDefinition::getEntries() const {
|
||||
return this->m_entries;
|
||||
}
|
||||
|
||||
LangEntry::LangEntry(const char *unlocalizedString) : m_unlocalizedString(unlocalizedString) { }
|
||||
LangEntry::LangEntry(std::string unlocalizedString) : m_unlocalizedString(std::move(unlocalizedString)) { }
|
||||
LangEntry::LangEntry(std::string_view unlocalizedString) : m_unlocalizedString(unlocalizedString) { }
|
||||
|
||||
LangEntry::operator std::string() const {
|
||||
return get();
|
||||
}
|
||||
|
||||
LangEntry::operator std::string_view() const {
|
||||
return get();
|
||||
}
|
||||
|
||||
LangEntry::operator const char *() const {
|
||||
return get().c_str();
|
||||
}
|
||||
|
||||
std::string operator+(const std::string &&left, const LangEntry &&right) {
|
||||
return left + static_cast<std::string>(right);
|
||||
}
|
||||
|
||||
std::string operator+(const LangEntry &&left, const std::string &&right) {
|
||||
return static_cast<std::string>(left) + right;
|
||||
}
|
||||
|
||||
std::string operator+(const LangEntry &&left, const LangEntry &&right) {
|
||||
return static_cast<std::string>(left) + static_cast<std::string>(right);
|
||||
}
|
||||
|
||||
std::string operator+(const std::string_view &&left, const LangEntry &&right) {
|
||||
return std::string(left) + static_cast<std::string>(right);
|
||||
}
|
||||
|
||||
std::string operator+(const LangEntry &&left, const std::string_view &&right) {
|
||||
return static_cast<std::string>(left) + std::string(right);
|
||||
}
|
||||
|
||||
std::string operator+(const char *left, const LangEntry &&right) {
|
||||
return left + static_cast<std::string>(right);
|
||||
}
|
||||
|
||||
std::string operator+(const LangEntry &&left, const char *right) {
|
||||
return static_cast<std::string>(left) + right;
|
||||
}
|
||||
|
||||
const std::string &LangEntry::get() const {
|
||||
auto &lang = s_currStrings;
|
||||
if (lang.contains(this->m_unlocalizedString))
|
||||
return lang[this->m_unlocalizedString];
|
||||
else
|
||||
return this->m_unlocalizedString;
|
||||
}
|
||||
|
||||
void LangEntry::loadLanguage(const std::string &language) {
|
||||
s_currStrings.clear();
|
||||
|
||||
auto &definitions = ContentRegistry::Language::impl::getLanguageDefinitions();
|
||||
|
||||
if (!definitions.contains(language))
|
||||
return;
|
||||
|
||||
for (auto &definition : definitions[language])
|
||||
s_currStrings.insert(definition.getEntries().begin(), definition.getEntries().end());
|
||||
|
||||
const auto fallbackLanguage = LangEntry::getFallbackLanguage();
|
||||
if (language != fallbackLanguage) {
|
||||
for (auto &definition : definitions[fallbackLanguage])
|
||||
s_currStrings.insert(definition.getEntries().begin(), definition.getEntries().end());
|
||||
}
|
||||
|
||||
s_selectedLanguage = language;
|
||||
}
|
||||
|
||||
const std::map<std::string, std::string> &LangEntry::getSupportedLanguages() {
|
||||
return ContentRegistry::Language::impl::getLanguages();
|
||||
}
|
||||
|
||||
void LangEntry::setFallbackLanguage(const std::string &language) {
|
||||
s_fallbackLanguage = language;
|
||||
}
|
||||
|
||||
const std::string &LangEntry::getFallbackLanguage() {
|
||||
return s_fallbackLanguage;
|
||||
}
|
||||
|
||||
void LangEntry::resetLanguageStrings() {
|
||||
s_currStrings.clear();
|
||||
s_selectedLanguage.clear();
|
||||
}
|
||||
|
||||
const std::string &LangEntry::getSelectedLanguage() {
|
||||
return s_selectedLanguage;
|
||||
}
|
||||
|
||||
}
|
129
lib/libimhex/source/api/localization_manager.cpp
Normal file
129
lib/libimhex/source/api/localization_manager.cpp
Normal file
@ -0,0 +1,129 @@
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
namespace hex {
|
||||
|
||||
namespace LocalizationManager {
|
||||
|
||||
namespace {
|
||||
|
||||
std::string s_fallbackLanguage;
|
||||
std::string s_selectedLanguage;
|
||||
std::map<std::string, std::string> s_currStrings;
|
||||
|
||||
}
|
||||
|
||||
namespace impl {
|
||||
|
||||
void resetLanguageStrings() {
|
||||
s_currStrings.clear();
|
||||
s_selectedLanguage.clear();
|
||||
}
|
||||
|
||||
void setFallbackLanguage(const std::string &language) {
|
||||
s_fallbackLanguage = language;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LanguageDefinition::LanguageDefinition(std::map<std::string, std::string> &&entries) {
|
||||
for (const auto &[key, value] : entries) {
|
||||
if (value.empty())
|
||||
continue;
|
||||
|
||||
this->m_entries.insert({ key, value });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const std::map<std::string, std::string> &LanguageDefinition::getEntries() const {
|
||||
return this->m_entries;
|
||||
}
|
||||
|
||||
void loadLanguage(const std::string &language) {
|
||||
s_currStrings.clear();
|
||||
|
||||
auto &definitions = ContentRegistry::Language::impl::getLanguageDefinitions();
|
||||
|
||||
if (!definitions.contains(language))
|
||||
return;
|
||||
|
||||
for (auto &definition : definitions[language])
|
||||
s_currStrings.insert(definition.getEntries().begin(), definition.getEntries().end());
|
||||
|
||||
const auto& fallbackLanguage = getFallbackLanguage();
|
||||
if (language != fallbackLanguage) {
|
||||
for (auto &definition : definitions[fallbackLanguage])
|
||||
s_currStrings.insert(definition.getEntries().begin(), definition.getEntries().end());
|
||||
}
|
||||
|
||||
s_selectedLanguage = language;
|
||||
}
|
||||
|
||||
const std::map<std::string, std::string> &getSupportedLanguages() {
|
||||
return ContentRegistry::Language::impl::getLanguages();
|
||||
}
|
||||
|
||||
const std::string &getFallbackLanguage() {
|
||||
return s_fallbackLanguage;
|
||||
}
|
||||
|
||||
const std::string &getSelectedLanguage() {
|
||||
return s_selectedLanguage;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Lang::Lang(const char *unlocalizedString) : m_unlocalizedString(unlocalizedString) { }
|
||||
Lang::Lang(std::string unlocalizedString) : m_unlocalizedString(std::move(unlocalizedString)) { }
|
||||
Lang::Lang(std::string_view unlocalizedString) : m_unlocalizedString(unlocalizedString) { }
|
||||
|
||||
Lang::operator std::string() const {
|
||||
return get();
|
||||
}
|
||||
|
||||
Lang::operator std::string_view() const {
|
||||
return get();
|
||||
}
|
||||
|
||||
Lang::operator const char *() const {
|
||||
return get().c_str();
|
||||
}
|
||||
|
||||
std::string operator+(const std::string &&left, const Lang &&right) {
|
||||
return left + static_cast<std::string>(right);
|
||||
}
|
||||
|
||||
std::string operator+(const Lang &&left, const std::string &&right) {
|
||||
return static_cast<std::string>(left) + right;
|
||||
}
|
||||
|
||||
std::string operator+(const Lang &&left, const Lang &&right) {
|
||||
return static_cast<std::string>(left) + static_cast<std::string>(right);
|
||||
}
|
||||
|
||||
std::string operator+(const std::string_view &&left, const Lang &&right) {
|
||||
return std::string(left) + static_cast<std::string>(right);
|
||||
}
|
||||
|
||||
std::string operator+(const Lang &&left, const std::string_view &&right) {
|
||||
return static_cast<std::string>(left) + std::string(right);
|
||||
}
|
||||
|
||||
std::string operator+(const char *left, const Lang &&right) {
|
||||
return left + static_cast<std::string>(right);
|
||||
}
|
||||
|
||||
std::string operator+(const Lang &&left, const char *right) {
|
||||
return static_cast<std::string>(left) + right;
|
||||
}
|
||||
|
||||
const std::string &Lang::get() const {
|
||||
auto &lang = LocalizationManager::s_currStrings;
|
||||
if (lang.contains(this->m_unlocalizedString))
|
||||
return lang[this->m_unlocalizedString];
|
||||
else
|
||||
return this->m_unlocalizedString;
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
#include <hex/api/task_manager.hpp>
|
||||
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/helpers/logger.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
@ -249,7 +249,7 @@ namespace hex {
|
||||
}
|
||||
|
||||
try {
|
||||
setThreadName(LangEntry(task->m_unlocalizedName));
|
||||
setThreadName(Lang(task->m_unlocalizedName));
|
||||
task->m_function(*task);
|
||||
setThreadName("Idle Task");
|
||||
log::debug("Finished task {}", task->m_unlocalizedName);
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/providers/provider.hpp>
|
||||
|
||||
namespace hex::dp {
|
||||
@ -22,7 +22,7 @@ namespace hex::dp {
|
||||
auto attribute = this->getConnectedInputAttribute(index);
|
||||
|
||||
if (attribute == nullptr)
|
||||
throwNodeError(hex::format("Nothing connected to input '{0}'", LangEntry(this->m_attributes[index].getUnlocalizedName())));
|
||||
throwNodeError(hex::format("Nothing connected to input '{0}'", Lang(this->m_attributes[index].getUnlocalizedName())));
|
||||
|
||||
if (attribute->getType() != Attribute::Type::Buffer)
|
||||
throwNodeError("Tried to read buffer from non-buffer attribute");
|
||||
|
@ -13,6 +13,10 @@ namespace hex {
|
||||
return ImHexApi::Provider::isValid() && ImHexApi::Provider::get()->isAvailable();
|
||||
}
|
||||
|
||||
bool View::shouldProcess() const {
|
||||
return this->shouldDraw() && this->getWindowOpenState();
|
||||
}
|
||||
|
||||
bool View::hasViewMenuItemEntry() const {
|
||||
return true;
|
||||
}
|
||||
@ -61,7 +65,7 @@ namespace hex {
|
||||
}
|
||||
|
||||
std::string View::toWindowName(const std::string &unlocalizedName) {
|
||||
return LangEntry(unlocalizedName) + "###" + unlocalizedName;
|
||||
return Lang(unlocalizedName) + "###" + unlocalizedName;
|
||||
}
|
||||
|
||||
}
|
@ -384,7 +384,7 @@ namespace hex::init {
|
||||
|
||||
ContentRegistry::Language::impl::getLanguages().clear();
|
||||
ContentRegistry::Language::impl::getLanguageDefinitions().clear();
|
||||
LangEntry::resetLanguageStrings();
|
||||
LocalizationManager::impl::resetLanguageStrings();
|
||||
|
||||
ContentRegistry::Interface::impl::getWelcomeScreenEntries().clear();
|
||||
ContentRegistry::Interface::impl::getFooterItems().clear();
|
||||
|
@ -238,10 +238,10 @@ namespace hex {
|
||||
if (name == ContentRegistry::Interface::impl::SubMenuValue) {
|
||||
callback();
|
||||
} else if (menuItems.size() == 1) {
|
||||
if (ImGui::MenuItem(LangEntry(name), shortcut.toString().c_str(), false, enabledCallback()))
|
||||
if (ImGui::MenuItem(Lang(name), shortcut.toString().c_str(), false, enabledCallback()))
|
||||
callback();
|
||||
} else {
|
||||
if (ImGui::BeginMenu(LangEntry(name), *(menuItems.begin() + 1) == ContentRegistry::Interface::impl::SubMenuValue ? enabledCallback() : true)) {
|
||||
if (ImGui::BeginMenu(Lang(name), *(menuItems.begin() + 1) == ContentRegistry::Interface::impl::SubMenuValue ? enabledCallback() : true)) {
|
||||
createNestedMenu({ menuItems.begin() + 1, menuItems.end() }, shortcut, callback, enabledCallback);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
@ -267,7 +267,7 @@ namespace hex {
|
||||
if (ImGuiExt::TitleBarButton(icon.c_str(), buttonSize)) {
|
||||
callback();
|
||||
}
|
||||
ImGuiExt::InfoTooltip(LangEntry(tooltip));
|
||||
ImGuiExt::InfoTooltip(Lang(tooltip));
|
||||
}
|
||||
}
|
||||
|
||||
@ -339,7 +339,7 @@ namespace hex {
|
||||
if (ImGuiExt::TitleBarButton(icon.c_str(), buttonSize)) {
|
||||
callback();
|
||||
}
|
||||
ImGuiExt::InfoTooltip(LangEntry(tooltip));
|
||||
ImGuiExt::InfoTooltip(Lang(tooltip));
|
||||
}
|
||||
}
|
||||
|
||||
@ -553,7 +553,7 @@ namespace hex {
|
||||
const static auto drawMenu = [] {
|
||||
for (const auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMainMenuItems()) {
|
||||
ImGui::GetStyle().TouchExtraPadding = scaled(ImVec2(0, 2));
|
||||
if (ImGui::BeginMenu(LangEntry(menuItem.unlocalizedName))) {
|
||||
if (ImGui::BeginMenu(Lang(menuItem.unlocalizedName))) {
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
ImGui::GetStyle().TouchExtraPadding = ImVec2(0, 0);
|
||||
@ -704,7 +704,7 @@ namespace hex {
|
||||
static double popupDelay = -2.0;
|
||||
|
||||
static std::unique_ptr<impl::PopupBase> currPopup;
|
||||
static LangEntry name("");
|
||||
static Lang name("");
|
||||
|
||||
if (auto &popups = impl::PopupBase::getOpenPopups(); !popups.empty()) {
|
||||
if (!ImGui::IsPopupOpen(ImGuiID(0), ImGuiPopupFlags_AnyPopupId)) {
|
||||
@ -715,7 +715,7 @@ namespace hex {
|
||||
if (popupDelay < 0) {
|
||||
popupDelay = -2.0;
|
||||
currPopup = std::move(popups.back());
|
||||
name = LangEntry(currPopup->getUnlocalizedName());
|
||||
name = Lang(currPopup->getUnlocalizedName());
|
||||
|
||||
ImGui::OpenPopup(name);
|
||||
popups.pop_back();
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <implot.h>
|
||||
|
||||
#include <hex/api/imhex_api.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <hex/providers/provider.hpp>
|
||||
#include <hex/providers/buffered_reader.hpp>
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include <hex/ui/imgui_imhex_extensions.h>
|
||||
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/helpers/http_requests.hpp>
|
||||
|
||||
#include <functional>
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <hex/ui/popup.hpp>
|
||||
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <wolv/utils/string.hpp>
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <hex/ui/popup.hpp>
|
||||
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/api/imhex_api.hpp>
|
||||
|
||||
#include <functional>
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <hex/ui/popup.hpp>
|
||||
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <hex/ui/popup.hpp>
|
||||
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <hex/ui/popup.hpp>
|
||||
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <wolv/hash/uuid.hpp>
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <hex/ui/popup.hpp>
|
||||
|
||||
#include <hex/api/imhex_api.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <hex/ui/popup.hpp>
|
||||
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <hex/providers/provider.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/api/event_manager.hpp>
|
||||
|
||||
#include <wolv/net/socket_server.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <hex/api/content_registry.hpp>
|
||||
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
@ -64,7 +64,7 @@ namespace hex::plugin::builtin {
|
||||
continue;
|
||||
|
||||
std::vector<std::string> names;
|
||||
std::transform(entry.unlocalizedNames.begin(), entry.unlocalizedNames.end(), std::back_inserter(names), [](auto &name) { return LangEntry(name); });
|
||||
std::transform(entry.unlocalizedNames.begin(), entry.unlocalizedNames.end(), std::back_inserter(names), [](auto &name) { return Lang(name); });
|
||||
|
||||
if (auto combined = wolv::util::combineStrings(names, " -> "); hex::containsIgnoreCase(combined, input) && !combined.contains(ContentRegistry::Interface::impl::SeparatorValue) && !combined.contains(ContentRegistry::Interface::impl::SubMenuValue)) {
|
||||
result.emplace_back(ContentRegistry::CommandPaletteCommands::impl::QueryResult {
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/ui/imgui_imhex_extensions.h>
|
||||
#include <hex/data_processor/node.hpp>
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/crypto.hpp>
|
||||
#include <hex/data_processor/node.hpp>
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/data_processor/node.hpp>
|
||||
|
||||
#include <ranges>
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/data_processor/node.hpp>
|
||||
#include <hex/ui/imgui_imhex_extensions.h>
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <hex/api/event_manager.hpp>
|
||||
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/api/project_file_manager.hpp>
|
||||
#include <hex/api/achievement_manager.hpp>
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/helpers/crypto.hpp>
|
||||
|
||||
#include <hex/ui/imgui_imhex_extensions.h>
|
||||
|
@ -221,7 +221,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void drawExportLanguageMenu() {
|
||||
for (const auto &formatter : ContentRegistry::DataFormatter::impl::getEntries()) {
|
||||
if (ImGui::MenuItem(LangEntry(formatter.unlocalizedName), nullptr, false, ImHexApi::Provider::get()->getActualSize() > 0)) {
|
||||
if (ImGui::MenuItem(Lang(formatter.unlocalizedName), nullptr, false, ImHexApi::Provider::get()->getActualSize() > 0)) {
|
||||
fs::openFileBrowser(fs::DialogMode::Save, {}, [&formatter](const auto &path) {
|
||||
TaskManager::createTask("Exporting data", TaskManager::NoProgress, [&formatter, path](auto&){
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
@ -351,7 +351,7 @@ namespace hex::plugin::builtin {
|
||||
/* Open Other */
|
||||
ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.file", "hex.builtin.menu.file.open_other"}, 1150, [] {
|
||||
for (const auto &unlocalizedProviderName : ContentRegistry::Provider::impl::getEntries()) {
|
||||
if (ImGui::MenuItem(LangEntry(unlocalizedProviderName)))
|
||||
if (ImGui::MenuItem(Lang(unlocalizedProviderName)))
|
||||
ImHexApi::Provider::createProvider(unlocalizedProviderName);
|
||||
}
|
||||
}, noRunningTasks);
|
||||
@ -477,7 +477,7 @@ namespace hex::plugin::builtin {
|
||||
if (view->hasViewMenuItemEntry()) {
|
||||
auto &state = view->getWindowOpenState();
|
||||
|
||||
if (ImGui::MenuItem(LangEntry(view->getUnlocalizedName()), "", &state))
|
||||
if (ImGui::MenuItem(Lang(view->getUnlocalizedName()), "", &state))
|
||||
view->setWindowJustOpened(state);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/api/task_manager.hpp>
|
||||
|
||||
#include <hex/helpers/http_requests.hpp>
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <wolv/utils/string.hpp>
|
||||
|
||||
#include <hex/api/project_file_manager.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/api/achievement_manager.hpp>
|
||||
|
||||
#include <hex/providers/provider.hpp>
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "content/providers/disk_provider.hpp"
|
||||
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/api/project_file_manager.hpp>
|
||||
#include <hex/api/achievement_manager.hpp>
|
||||
#include <hex/api/task_manager.hpp>
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
#include <hex/helpers/crypto.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <cstring>
|
||||
|
||||
#include <hex/api/imhex_api.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <cstring>
|
||||
|
||||
#include <hex/api/imhex_api.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/api/event_manager.hpp>
|
||||
|
||||
#include <wolv/io/file.hpp>
|
||||
@ -116,14 +116,14 @@ namespace hex::plugin::builtin {
|
||||
|
||||
[[nodiscard]] std::string MemoryFileProvider::getName() const {
|
||||
if (this->m_name.empty())
|
||||
return LangEntry("hex.builtin.provider.mem_file.unsaved");
|
||||
return Lang("hex.builtin.provider.mem_file.unsaved");
|
||||
else
|
||||
return this->m_name;
|
||||
}
|
||||
|
||||
std::vector<MemoryFileProvider::MenuEntry> MemoryFileProvider::getMenuEntries() {
|
||||
return {
|
||||
MenuEntry { LangEntry("hex.builtin.provider.mem_file.rename"), [this] { this->renameFile(); } }
|
||||
MenuEntry { Lang("hex.builtin.provider.mem_file.rename"), [this] { this->renameFile(); } }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "content/providers/motorola_srec_provider.hpp"
|
||||
|
||||
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
|
||||
|
@ -198,7 +198,7 @@ namespace hex::plugin::builtin::recent {
|
||||
break;
|
||||
}
|
||||
if (!isProject)
|
||||
ImGui::SetItemTooltip("%s", LangEntry(recentEntry.type).get().c_str());
|
||||
ImGui::SetItemTooltip("%s", Lang(recentEntry.type).get().c_str());
|
||||
|
||||
// Detect right click on recent provider
|
||||
std::string popupID = hex::format("RecentEntryMenu.{}", recentEntry.getHash());
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <hex/api/imhex_api.hpp>
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/api/theme_manager.hpp>
|
||||
#include <hex/api/shortcut_manager.hpp>
|
||||
#include <hex/api/event_manager.hpp>
|
||||
@ -358,7 +358,7 @@ namespace hex::plugin::builtin {
|
||||
std::vector<std::string> languageNames;
|
||||
std::vector<nlohmann::json> languageCodes;
|
||||
|
||||
for (auto &[languageCode, languageName] : LangEntry::getSupportedLanguages()) {
|
||||
for (auto &[languageCode, languageName] : LocalizationManager::getSupportedLanguages()) {
|
||||
languageNames.emplace_back(languageName);
|
||||
languageCodes.emplace_back(languageCode);
|
||||
}
|
||||
@ -431,7 +431,7 @@ namespace hex::plugin::builtin {
|
||||
EventManager::subscribe<EventImHexStartupFinished>([]{
|
||||
for (const auto &[name, experiment] : ContentRegistry::Experiments::impl::getExperiments()) {
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.experiments", "", experiment.unlocalizedName, false)
|
||||
.setTooltip(LangEntry(experiment.unlocalizedDescription))
|
||||
.setTooltip(Lang(experiment.unlocalizedDescription))
|
||||
.setChangedCallback([name](Widgets::Widget &widget) {
|
||||
auto checkBox = static_cast<Widgets::Checkbox *>(&widget);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <content/tools_entries.hpp>
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <hex/ui/view.hpp>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <hex/ui/view.hpp>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <llvm/Demangle/Demangle.h>
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <hex/helpers/http_requests.hpp>
|
||||
#include <hex/ui/view.hpp>
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <hex/helpers/http_requests.hpp>
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
#include <hex/helpers/fs.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <random>
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <hex/helpers/fs.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <random>
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
#include <hex/helpers/literals.hpp>
|
||||
#include <hex/helpers/fs.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <random>
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/ui/imgui_imhex_extensions.h>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/api/imhex_api.hpp>
|
||||
#include <hex/providers/provider.hpp>
|
||||
#include <hex/ui/imgui_imhex_extensions.h>
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <content/tools_entries.hpp>
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <hex/helpers/http_requests.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <hex/ui/view.hpp>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/ui/imgui_imhex_extensions.h>
|
||||
#include <wolv/net/socket_client.hpp>
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <hex/api/content_registry.hpp>
|
||||
|
||||
#include <hex/helpers/http_requests.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <hex/ui/view.hpp>
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <hex/api/content_registry.hpp>
|
||||
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <content/tools_entries.hpp>
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/imhex_api.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <hex/ui/view.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
@ -45,7 +45,7 @@ namespace hex::plugin::builtin {
|
||||
// Task exception popup
|
||||
for (const auto &task : TaskManager::getRunningTasks()) {
|
||||
if (task->hadException()) {
|
||||
PopupError::open(hex::format("hex.builtin.popup.error.task_exception"_lang, LangEntry(task->getUnlocalizedName()), task->getExceptionMessage()));
|
||||
PopupError::open(hex::format("hex.builtin.popup.error.task_exception"_lang, Lang(task->getUnlocalizedName()), task->getExceptionMessage()));
|
||||
task->clearException();
|
||||
break;
|
||||
}
|
||||
@ -98,7 +98,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::InvisibleButton("FrontTask", ImVec2(widgetEnd.x - widgetStart.x, ImGui::GetCurrentWindow()->MenuBarHeight()));
|
||||
ImGui::SetCursorPos(widgetEnd);
|
||||
|
||||
ImGuiExt::InfoTooltip(LangEntry(frontTask->getUnlocalizedName()).get().c_str());
|
||||
ImGuiExt::InfoTooltip(Lang(frontTask->getUnlocalizedName()).get().c_str());
|
||||
|
||||
if (ImGui::BeginPopupContextItem("FrontTask", ImGuiPopupFlags_MouseButtonLeft)) {
|
||||
for (const auto &task : tasks) {
|
||||
@ -106,7 +106,7 @@ namespace hex::plugin::builtin {
|
||||
continue;
|
||||
|
||||
ImGui::PushID(&task);
|
||||
ImGuiExt::TextFormatted("{}", LangEntry(task->getUnlocalizedName()));
|
||||
ImGuiExt::TextFormatted("{}", Lang(task->getUnlocalizedName()));
|
||||
ImGui::SameLine();
|
||||
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
|
||||
ImGui::SameLine();
|
||||
|
@ -487,7 +487,7 @@ namespace hex::plugin::builtin {
|
||||
if (ImGui::BeginTabBar("about_tab_bar")) {
|
||||
// Draw all tabs
|
||||
for (const auto &[unlocalizedName, function] : Tabs) {
|
||||
if (ImGui::BeginTabItem(LangEntry(unlocalizedName))) {
|
||||
if (ImGui::BeginTabItem(Lang(unlocalizedName))) {
|
||||
ImGui::NewLine();
|
||||
|
||||
if (ImGui::BeginChild(1)) {
|
||||
|
@ -111,7 +111,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::BeginDisabled(!achievement.isUnlocked());
|
||||
|
||||
// Draw achievement name
|
||||
ImGui::TextUnformatted(LangEntry(achievement.getUnlocalizedName()));
|
||||
ImGui::TextUnformatted(Lang(achievement.getUnlocalizedName()));
|
||||
|
||||
// Draw progress bar if achievement has progress
|
||||
if (auto requiredProgress = achievement.getRequiredProgress(); requiredProgress > 1) {
|
||||
@ -125,7 +125,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::Separator();
|
||||
separator = true;
|
||||
|
||||
ImGuiExt::TextFormattedColored(ImGuiExt::GetCustomColorVec4(ImGuiCustomCol_AchievementUnlocked), "[ {} ]", LangEntry("hex.builtin.view.achievements.click"));
|
||||
ImGuiExt::TextFormattedColored(ImGuiExt::GetCustomColorVec4(ImGuiCustomCol_AchievementUnlocked), "[ {} ]", Lang("hex.builtin.view.achievements.click"));
|
||||
}
|
||||
|
||||
// Draw achievement description if available
|
||||
@ -135,7 +135,7 @@ namespace hex::plugin::builtin {
|
||||
else
|
||||
ImGui::NewLine();
|
||||
|
||||
ImGuiExt::TextFormattedWrapped("{}", LangEntry(desc));
|
||||
ImGuiExt::TextFormattedWrapped("{}", Lang(desc));
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
@ -338,7 +338,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
// Draw the achievement category
|
||||
if (ImGui::BeginTabItem(LangEntry(categoryName), nullptr, flags)) {
|
||||
if (ImGui::BeginTabItem(Lang(categoryName), nullptr, flags)) {
|
||||
auto drawList = ImGui::GetWindowDrawList();
|
||||
|
||||
const auto cursorPos = ImGui::GetCursorPos();
|
||||
@ -427,7 +427,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::SameLine();
|
||||
|
||||
// Draw name of achievement
|
||||
ImGuiExt::TextFormattedWrapped("{}", LangEntry(this->m_currAchievement->getUnlocalizedName()));
|
||||
ImGuiExt::TextFormattedWrapped("{}", Lang(this->m_currAchievement->getUnlocalizedName()));
|
||||
|
||||
// Handle clicking on the popup
|
||||
if (ImGui::IsWindowHovered() && ImGui::IsMouseReleased(ImGuiMouseButton_Left)) {
|
||||
|
@ -154,7 +154,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
if (auto [match, value] = MatchCommand(input, command); match != MatchType::NoMatch) {
|
||||
if (match != MatchType::PerfectMatch)
|
||||
results.push_back({ command + " (" + LangEntry(unlocalizedDescription) + ")", "", AutoComplete });
|
||||
results.push_back({ command + " (" + Lang(unlocalizedDescription) + ")", "", AutoComplete });
|
||||
else {
|
||||
auto matchedCommand = input.substr(command.length());
|
||||
results.push_back({ displayCallback(matchedCommand), matchedCommand, executeCallback });
|
||||
@ -166,7 +166,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
if (auto [match, value] = MatchCommand(input, command + " "); match != MatchType::NoMatch) {
|
||||
if (match != MatchType::PerfectMatch)
|
||||
results.push_back({ command + " (" + LangEntry(unlocalizedDescription) + ")", "", AutoComplete });
|
||||
results.push_back({ command + " (" + Lang(unlocalizedDescription) + ")", "", AutoComplete });
|
||||
else {
|
||||
auto matchedCommand = input.substr(command.length() + 1);
|
||||
results.push_back({ displayCallback(matchedCommand), matchedCommand, executeCallback });
|
||||
|
@ -243,7 +243,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::BeginDisabled(grayedOut);
|
||||
|
||||
// Render inspector row name
|
||||
ImGui::TextUnformatted(LangEntry(unlocalizedName));
|
||||
ImGui::TextUnformatted(Lang(unlocalizedName));
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
if (!editing) {
|
||||
|
@ -82,7 +82,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_name = LangEntry(this->getUnlocalizedName());
|
||||
std::string m_name = Lang(this->getUnlocalizedName());
|
||||
int m_type = 0;
|
||||
|
||||
std::variant<i128, long double, std::vector<u8>> m_value;
|
||||
@ -152,7 +152,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_name = LangEntry(this->getUnlocalizedName());
|
||||
std::string m_name = Lang(this->getUnlocalizedName());
|
||||
int m_type = 0;
|
||||
|
||||
std::variant<i128, long double, std::vector<u8>> m_value;
|
||||
@ -300,7 +300,7 @@ namespace hex::plugin::builtin {
|
||||
void load(const nlohmann::json &j) override {
|
||||
this->m_dataProcessor->loadNodes(this->m_workspace, j.at("nodes"));
|
||||
|
||||
this->m_name = LangEntry(this->getUnlocalizedTitle()).get();
|
||||
this->m_name = Lang(this->getUnlocalizedTitle()).get();
|
||||
this->m_requiresAttributeUpdate = true;
|
||||
}
|
||||
|
||||
@ -579,7 +579,7 @@ namespace hex::plugin::builtin {
|
||||
nlohmann::json nodeJson = nlohmann::json::parse(file.readString());
|
||||
|
||||
// Add the loaded node to the list of custom nodes
|
||||
this->m_customNodes.push_back(CustomNode { LangEntry(nodeJson.at("name")), nodeJson });
|
||||
this->m_customNodes.push_back(CustomNode { Lang(nodeJson.at("name")), nodeJson });
|
||||
} catch (nlohmann::json::exception &e) {
|
||||
log::warn("Failed to load custom node '{}': {}", entry.path().string(), e.what());
|
||||
}
|
||||
@ -646,13 +646,13 @@ namespace hex::plugin::builtin {
|
||||
ImGui::Separator();
|
||||
} else if (unlocalizedCategory.empty()) {
|
||||
// Draw the node if it has no category
|
||||
if (ImGui::MenuItem(LangEntry(unlocalizedName))) {
|
||||
if (ImGui::MenuItem(Lang(unlocalizedName))) {
|
||||
node = function();
|
||||
}
|
||||
} else {
|
||||
// Draw the node inside its sub menu if it has a category
|
||||
if (ImGui::BeginMenu(LangEntry(unlocalizedCategory))) {
|
||||
if (ImGui::MenuItem(LangEntry(unlocalizedName))) {
|
||||
if (ImGui::BeginMenu(Lang(unlocalizedCategory))) {
|
||||
if (ImGui::MenuItem(Lang(unlocalizedName))) {
|
||||
node = function();
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
@ -758,7 +758,7 @@ namespace hex::plugin::builtin {
|
||||
// Draw the node's title bar
|
||||
ImNodes::BeginNodeTitleBar();
|
||||
{
|
||||
ImGui::TextUnformatted(LangEntry(node.getUnlocalizedTitle()));
|
||||
ImGui::TextUnformatted(Lang(node.getUnlocalizedTitle()));
|
||||
}
|
||||
ImNodes::EndNodeTitleBar();
|
||||
|
||||
@ -799,7 +799,7 @@ namespace hex::plugin::builtin {
|
||||
defaultValue.resize(sizeof(i128));
|
||||
|
||||
auto value = i64(*reinterpret_cast<i128*>(defaultValue.data()));
|
||||
if (ImGui::InputScalar(LangEntry(attribute.getUnlocalizedName()), ImGuiDataType_S64, &value)) {
|
||||
if (ImGui::InputScalar(Lang(attribute.getUnlocalizedName()), ImGuiDataType_S64, &value)) {
|
||||
std::fill(defaultValue.begin(), defaultValue.end(), 0x00);
|
||||
|
||||
i128 writeValue = value;
|
||||
@ -809,7 +809,7 @@ namespace hex::plugin::builtin {
|
||||
defaultValue.resize(sizeof(long double));
|
||||
|
||||
auto value = double(*reinterpret_cast<long double*>(defaultValue.data()));
|
||||
if (ImGui::InputScalar(LangEntry(attribute.getUnlocalizedName()), ImGuiDataType_Double, &value)) {
|
||||
if (ImGui::InputScalar(Lang(attribute.getUnlocalizedName()), ImGuiDataType_Double, &value)) {
|
||||
std::fill(defaultValue.begin(), defaultValue.end(), 0x00);
|
||||
|
||||
long double writeValue = value;
|
||||
@ -819,13 +819,13 @@ namespace hex::plugin::builtin {
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
} else {
|
||||
ImGui::TextUnformatted(LangEntry(attribute.getUnlocalizedName()));
|
||||
ImGui::TextUnformatted(Lang(attribute.getUnlocalizedName()));
|
||||
}
|
||||
|
||||
ImNodes::EndInputAttribute();
|
||||
} else if (attribute.getIOType() == dp::Attribute::IOType::Out) {
|
||||
ImNodes::BeginOutputAttribute(attribute.getId(), ImNodesPinShape(pinShape + 1));
|
||||
ImGui::TextUnformatted(LangEntry(attribute.getUnlocalizedName()));
|
||||
ImGui::TextUnformatted(Lang(attribute.getUnlocalizedName()));
|
||||
ImNodes::EndOutputAttribute();
|
||||
}
|
||||
}
|
||||
|
@ -135,10 +135,10 @@ namespace hex::plugin::builtin {
|
||||
this->m_selectedHash = hashes.front().get();
|
||||
}
|
||||
|
||||
if (ImGui::BeginCombo("hex.builtin.view.hashes.function"_lang, this->m_selectedHash != nullptr ? LangEntry(this->m_selectedHash->getUnlocalizedName()) : "")) {
|
||||
if (ImGui::BeginCombo("hex.builtin.view.hashes.function"_lang, this->m_selectedHash != nullptr ? Lang(this->m_selectedHash->getUnlocalizedName()) : "")) {
|
||||
|
||||
for (const auto &hash : hashes) {
|
||||
if (ImGui::Selectable(LangEntry(hash->getUnlocalizedName()), this->m_selectedHash == hash.get())) {
|
||||
if (ImGui::Selectable(Lang(hash->getUnlocalizedName()), this->m_selectedHash == hash.get())) {
|
||||
this->m_selectedHash = hash.get();
|
||||
this->m_newHashName.clear();
|
||||
}
|
||||
@ -148,7 +148,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
if (this->m_newHashName.empty() && this->m_selectedHash != nullptr)
|
||||
this->m_newHashName = hex::format("{} {}", LangEntry(this->m_selectedHash->getUnlocalizedName()), static_cast<const char *>("hex.builtin.view.hashes.hash"_lang));
|
||||
this->m_newHashName = hex::format("{} {}", Lang(this->m_selectedHash->getUnlocalizedName()), static_cast<const char *>("hex.builtin.view.hashes.hash"_lang));
|
||||
|
||||
if (ImGui::BeginChild("##settings", ImVec2(ImGui::GetContentRegionAvail().x, 200_scaled), true)) {
|
||||
if (this->m_selectedHash != nullptr) {
|
||||
@ -206,7 +206,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::PopStyleColor(3);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGuiExt::TextFormatted("{}", LangEntry(function.getType()->getUnlocalizedName()));
|
||||
ImGuiExt::TextFormatted("{}", Lang(function.getType()->getUnlocalizedName()));
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
std::string result;
|
||||
|
@ -1168,7 +1168,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
bool enabled = ImHexApi::HexEditor::isSelectionValid();
|
||||
for (const auto &[unlocalizedName, callback] : ContentRegistry::DataFormatter::impl::getEntries()) {
|
||||
if (ImGui::MenuItem(LangEntry(unlocalizedName), nullptr, false, enabled)) {
|
||||
if (ImGui::MenuItem(Lang(unlocalizedName), nullptr, false, enabled)) {
|
||||
ImGui::SetClipboardText(
|
||||
callback(
|
||||
provider,
|
||||
|
@ -46,12 +46,12 @@ namespace hex::plugin::builtin {
|
||||
continue;
|
||||
|
||||
// For each category, create a new tab
|
||||
if (ImGui::BeginTabItem(LangEntry(category.unlocalizedName))) {
|
||||
if (ImGui::BeginTabItem(Lang(category.unlocalizedName))) {
|
||||
if (ImGui::BeginChild("scrolling")) {
|
||||
|
||||
// Draw the category description
|
||||
if (!category.unlocalizedDescription.empty()) {
|
||||
ImGuiExt::TextFormattedWrapped("{}", LangEntry(category.unlocalizedDescription));
|
||||
ImGuiExt::TextFormattedWrapped("{}", Lang(category.unlocalizedDescription));
|
||||
ImGui::NewLine();
|
||||
}
|
||||
|
||||
@ -62,17 +62,17 @@ namespace hex::plugin::builtin {
|
||||
if (subCategory.entries.empty())
|
||||
continue;
|
||||
|
||||
ImGuiExt::BeginSubWindow(LangEntry(subCategory.unlocalizedName));
|
||||
ImGuiExt::BeginSubWindow(Lang(subCategory.unlocalizedName));
|
||||
{
|
||||
for (auto &setting : subCategory.entries) {
|
||||
ImGui::BeginDisabled(!setting.widget->isEnabled());
|
||||
ImGui::PushItemWidth(-200_scaled);
|
||||
bool settingChanged = setting.widget->draw(LangEntry(setting.unlocalizedName));
|
||||
bool settingChanged = setting.widget->draw(Lang(setting.unlocalizedName));
|
||||
ImGui::PopItemWidth();
|
||||
ImGui::EndDisabled();
|
||||
|
||||
if (auto tooltip = setting.widget->getTooltip(); tooltip.has_value() && ImGui::IsItemHovered())
|
||||
ImGuiExt::InfoTooltip(LangEntry(tooltip.value()));
|
||||
ImGuiExt::InfoTooltip(Lang(tooltip.value()));
|
||||
|
||||
auto &widget = setting.widget;
|
||||
|
||||
|
@ -82,7 +82,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
void ViewStore::drawTab(hex::plugin::builtin::StoreCategory &category) {
|
||||
if (ImGui::BeginTabItem(LangEntry(category.unlocalizedName))) {
|
||||
if (ImGui::BeginTabItem(Lang(category.unlocalizedName))) {
|
||||
if (ImGui::BeginTable("##pattern_language", 4, ImGuiTableFlags_ScrollY | ImGuiTableFlags_Borders | ImGuiTableFlags_SizingStretchSame | ImGuiTableFlags_RowBg)) {
|
||||
ImGui::TableSetupScrollFreeze(0, 1);
|
||||
ImGui::TableSetupColumn("hex.builtin.view.store.row.name"_lang, ImGuiTableColumnFlags_WidthFixed);
|
||||
|
@ -20,7 +20,7 @@ namespace hex::plugin::builtin {
|
||||
if (detached) continue;
|
||||
|
||||
// Draw the tool
|
||||
if (ImGui::CollapsingHeader(LangEntry(name))) {
|
||||
if (ImGui::CollapsingHeader(Lang(name))) {
|
||||
function();
|
||||
ImGui::NewLine();
|
||||
} else {
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <hex/helpers/http_requests.hpp>
|
||||
#include <hex/api/event_manager.hpp>
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
#include <hex/api/plugin_manager.hpp>
|
||||
#include <hex/api/theme_manager.hpp>
|
||||
#include <hex/api/layout_manager.hpp>
|
||||
@ -196,7 +196,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ImGuiExt::BeginSubWindow("hex.builtin.welcome.start.open_other"_lang, ImVec2(0, ImGui::GetTextLineHeightWithSpacing() * 6), ImGuiChildFlags_AutoResizeX);
|
||||
for (const auto &unlocalizedProviderName : ContentRegistry::Provider::impl::getEntries()) {
|
||||
if (ImGuiExt::Hyperlink(LangEntry(unlocalizedProviderName))) {
|
||||
if (ImGuiExt::Hyperlink(Lang(unlocalizedProviderName))) {
|
||||
ImHexApi::Provider::createProvider(unlocalizedProviderName);
|
||||
otherProvidersVisible = false;
|
||||
}
|
||||
@ -454,8 +454,8 @@ namespace hex::plugin::builtin {
|
||||
{
|
||||
auto language = ContentRegistry::Settings::read("hex.builtin.setting.interface", "hex.builtin.setting.interface.language", "en-US").get<std::string>();
|
||||
|
||||
if (language != LangEntry::getSelectedLanguage())
|
||||
LangEntry::loadLanguage(language);
|
||||
if (language != LocalizationManager::getSelectedLanguage())
|
||||
LocalizationManager::loadLanguage(language);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <ui/hex_editor.hpp>
|
||||
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <hex/helpers/encoding_file.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
@ -816,10 +816,10 @@ namespace hex::plugin::builtin::ui {
|
||||
|
||||
ImGui::SameLine(0, 2_scaled);
|
||||
ImGui::PushItemWidth((ImGui::GetContentRegionAvail().x / 3) * 2);
|
||||
if (ImGui::BeginCombo("##visualizer", LangEntry(this->m_currDataVisualizer->getUnlocalizedName()))) {
|
||||
if (ImGui::BeginCombo("##visualizer", Lang(this->m_currDataVisualizer->getUnlocalizedName()))) {
|
||||
|
||||
for (const auto &visualizer : visualizers) {
|
||||
if (ImGui::Selectable(LangEntry(visualizer->getUnlocalizedName()))) {
|
||||
if (ImGui::Selectable(Lang(visualizer->getUnlocalizedName()))) {
|
||||
this->m_currDataVisualizer = visualizer;
|
||||
this->m_encodingLineStartAddresses.clear();
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include <hex/api/imhex_api.hpp>
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/achievement_manager.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <content/helpers/math_evaluator.hpp>
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <hex/plugin.hpp>
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/task_manager.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <hex/helpers/logger.hpp>
|
||||
#include <hex/ui/imgui_imhex_extensions.h>
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <hex/api/imhex_api.hpp>
|
||||
#include <hex/api/event_manager.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <hex/ui/popup.hpp>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <hex/providers/provider.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/localization_manager.hpp>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user