diff --git a/lib/libimhex/include/hex/api/achievement_manager.hpp b/lib/libimhex/include/hex/api/achievement_manager.hpp index 7c0c6e5e3..ed6bdb731 100644 --- a/lib/libimhex/include/hex/api/achievement_manager.hpp +++ b/lib/libimhex/include/hex/api/achievement_manager.hpp @@ -13,6 +13,7 @@ #include #include +#include namespace hex { @@ -20,13 +21,13 @@ namespace hex { class Achievement { public: - explicit Achievement(std::string unlocalizedCategory, std::string unlocalizedName) : m_unlocalizedCategory(std::move(unlocalizedCategory)), m_unlocalizedName(std::move(unlocalizedName)) { } + explicit Achievement(UnlocalizedString unlocalizedCategory, UnlocalizedString unlocalizedName) : m_unlocalizedCategory(std::move(unlocalizedCategory)), m_unlocalizedName(std::move(unlocalizedName)) { } /** * @brief Returns the unlocalized name of the achievement * @return Unlocalized name of the achievement */ - [[nodiscard]] const std::string &getUnlocalizedName() const { + [[nodiscard]] const UnlocalizedString &getUnlocalizedName() const { return this->m_unlocalizedName; } @@ -34,7 +35,7 @@ namespace hex { * @brief Returns the unlocalized category of the achievement * @return Unlocalized category of the achievement */ - [[nodiscard]] const std::string &getUnlocalizedCategory() const { + [[nodiscard]] const UnlocalizedString &getUnlocalizedCategory() const { return this->m_unlocalizedCategory; } @@ -135,7 +136,7 @@ namespace hex { * @brief Returns the unlocalized description of the achievement * @return Unlocalized description of the achievement */ - [[nodiscard]] const std::string &getUnlocalizedDescription() const { + [[nodiscard]] const UnlocalizedString &getUnlocalizedDescription() const { return this->m_unlocalizedDescription; } @@ -273,8 +274,8 @@ namespace hex { } private: - std::string m_unlocalizedCategory, m_unlocalizedName; - std::string m_unlocalizedDescription; + UnlocalizedString m_unlocalizedCategory, m_unlocalizedName; + UnlocalizedString m_unlocalizedDescription; bool m_blacked = false; bool m_invisible = false; @@ -364,7 +365,7 @@ namespace hex { * @param unlocalizedCategory Unlocalized category of the achievement * @param unlocalizedName Unlocalized name of the achievement */ - static void unlockAchievement(const std::string &unlocalizedCategory, const std::string &unlocalizedName); + static void unlockAchievement(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName); /** * @brief Returns all registered achievements diff --git a/lib/libimhex/include/hex/api/content_registry.hpp b/lib/libimhex/include/hex/api/content_registry.hpp index f65486795..9f37f2891 100644 --- a/lib/libimhex/include/hex/api/content_registry.hpp +++ b/lib/libimhex/include/hex/api/content_registry.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -254,18 +255,18 @@ namespace hex { namespace impl { struct Entry { - std::string unlocalizedName; + UnlocalizedString unlocalizedName; std::unique_ptr widget; }; struct SubCategory { - std::string unlocalizedName; + UnlocalizedString unlocalizedName; std::vector entries; }; struct Category { - std::string unlocalizedName; - std::string unlocalizedDescription; + UnlocalizedString unlocalizedName; + UnlocalizedString unlocalizedDescription; std::vector subCategories; }; @@ -274,14 +275,14 @@ namespace hex { void clear(); std::vector &getSettings(); - nlohmann::json& getSetting(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const nlohmann::json &defaultValue); + nlohmann::json& getSetting(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const nlohmann::json &defaultValue); nlohmann::json &getSettingsData(); - Widgets::Widget* add(const std::string &unlocalizedCategory, const std::string &unlocalizedSubCategory, const std::string &unlocalizedName, std::unique_ptr &&widget); + Widgets::Widget* add(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedSubCategory, const UnlocalizedString &unlocalizedName, std::unique_ptr &&widget); } template T> - Widgets::Widget::Interface& add(const std::string &unlocalizedCategory, const std::string &unlocalizedSubCategory, const std::string &unlocalizedName, auto && ... args) { + Widgets::Widget::Interface& add(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedSubCategory, const UnlocalizedString &unlocalizedName, auto && ... args) { return impl::add( unlocalizedCategory, unlocalizedSubCategory, @@ -290,10 +291,10 @@ namespace hex { )->getInterface(); } - void setCategoryDescription(const std::string &unlocalizedCategory, const std::string &unlocalizedDescription); + void setCategoryDescription(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedDescription); - [[nodiscard]] nlohmann::json read(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const nlohmann::json &defaultValue); - void write(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const nlohmann::json &value); + [[nodiscard]] nlohmann::json read(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const nlohmann::json &defaultValue); + void write(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const nlohmann::json &value); } /* Command Palette Command Registry. Allows adding of new commands to the command palette */ @@ -318,7 +319,7 @@ namespace hex { struct Entry { Type type; std::string command; - std::string unlocalizedDescription; + UnlocalizedString unlocalizedDescription; DisplayCallback displayCallback; ExecuteCallback executeCallback; }; @@ -346,7 +347,7 @@ namespace hex { void add( Type type, const std::string &command, - const std::string &unlocalizedDescription, + const UnlocalizedString &unlocalizedDescription, const impl::DisplayCallback &displayCallback, const impl::ExecuteCallback &executeCallback = [](auto) {}); @@ -484,7 +485,7 @@ namespace hex { * @param unlocalizedName The unlocalized name of the view * @return The view if it exists, nullptr otherwise */ - View* getViewByName(const std::string &unlocalizedName); + View* getViewByName(const UnlocalizedString &unlocalizedName); } /* Tools Registry. Allows adding new entries to the tools window */ @@ -509,7 +510,7 @@ namespace hex { * @param unlocalizedName The unlocalized name of the tool * @param function The function that will be called to draw the tool */ - void add(const std::string &unlocalizedName, const impl::Callback &function); + void add(const UnlocalizedString &unlocalizedName, const impl::Callback &function); } /* Data Inspector Registry. Allows adding of new types to the data inspector */ @@ -529,7 +530,7 @@ namespace hex { using GeneratorFunction = std::function &, std::endian, NumberDisplayStyle)>; struct Entry { - std::string unlocalizedName; + UnlocalizedString unlocalizedName; size_t requiredSize; size_t maxSize; GeneratorFunction generatorFunction; @@ -547,7 +548,7 @@ namespace hex { * @param displayGeneratorFunction The function that will be called to generate the display function * @param editingFunction The function that will be called to edit the data */ - void add(const std::string &unlocalizedName, size_t requiredSize, impl::GeneratorFunction displayGeneratorFunction, std::optional editingFunction = std::nullopt); + void add(const UnlocalizedString &unlocalizedName, size_t requiredSize, impl::GeneratorFunction displayGeneratorFunction, std::optional editingFunction = std::nullopt); /** * @brief Adds a new entry to the data inspector @@ -557,7 +558,7 @@ namespace hex { * @param displayGeneratorFunction The function that will be called to generate the display function * @param editingFunction The function that will be called to edit the data */ - void add(const std::string &unlocalizedName, size_t requiredSize, size_t maxSize, impl::GeneratorFunction displayGeneratorFunction, std::optional editingFunction = std::nullopt); + void add(const UnlocalizedString &unlocalizedName, size_t requiredSize, size_t maxSize, impl::GeneratorFunction displayGeneratorFunction, std::optional editingFunction = std::nullopt); } /* Data Processor Node Registry. Allows adding new processor nodes to be used in the data processor */ @@ -568,8 +569,8 @@ namespace hex { using CreatorFunction = std::function()>; struct Entry { - std::string category; - std::string name; + UnlocalizedString unlocalizedCategory; + UnlocalizedString unlocalizedName; CreatorFunction creatorFunction; }; @@ -588,10 +589,10 @@ namespace hex { * @param args Arguments passed to the constructor of the node */ template T, typename... Args> - void add(const std::string &unlocalizedCategory, const std::string &unlocalizedName, Args &&...args) { + void add(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, Args &&...args) { add(impl::Entry { - unlocalizedCategory.c_str(), - unlocalizedName.c_str(), + unlocalizedCategory, + unlocalizedName, [=, ...args = std::forward(args)] mutable { auto node = std::make_unique(std::forward(args)...); node->setUnlocalizedName(unlocalizedName); @@ -636,11 +637,11 @@ namespace hex { using ClickCallback = std::function; struct MainMenuItem { - std::string unlocalizedName; + UnlocalizedString unlocalizedName; }; struct MenuItem { - std::vector unlocalizedNames; + std::vector unlocalizedNames; std::unique_ptr shortcut; View *view; MenuCallback callback; @@ -655,7 +656,7 @@ namespace hex { struct TitleBarButton { std::string icon; - std::string unlocalizedTooltip; + UnlocalizedString unlocalizedTooltip; ClickCallback callback; }; @@ -678,7 +679,7 @@ namespace hex { * @param unlocalizedName The unlocalized name of the entry * @param priority The priority of the entry. Lower values are displayed first */ - void registerMainMenuItem(const std::string &unlocalizedName, u32 priority); + void registerMainMenuItem(const UnlocalizedString &unlocalizedName, u32 priority); /** * @brief Adds a new main menu entry @@ -689,7 +690,7 @@ namespace hex { * @param enabledCallback The function to call to determine if the entry is enabled * @param view The view to use for the entry. If nullptr, the shortcut will work globally */ - void addMenuItem(const std::vector &unlocalizedMainMenuNames, u32 priority, const Shortcut &shortcut, const impl::MenuCallback &function, const impl::EnabledCallback& enabledCallback = []{ return true; }, View *view = nullptr); + void addMenuItem(const std::vector &unlocalizedMainMenuNames, u32 priority, const Shortcut &shortcut, const impl::MenuCallback &function, const impl::EnabledCallback& enabledCallback = []{ return true; }, View *view = nullptr); /** * @brief Adds a new main menu sub-menu entry @@ -698,14 +699,14 @@ namespace hex { * @param function The function to call when the entry is clicked * @param enabledCallback The function to call to determine if the entry is enabled */ - void addMenuItemSubMenu(std::vector unlocalizedMainMenuNames, u32 priority, const impl::MenuCallback &function, const impl::EnabledCallback& enabledCallback = []{ return true; }); + void addMenuItemSubMenu(std::vector unlocalizedMainMenuNames, u32 priority, const impl::MenuCallback &function, const impl::EnabledCallback& enabledCallback = []{ return true; }); /** * @brief Adds a new main menu separator * @param unlocalizedMainMenuNames The unlocalized names of the main menu entries * @param priority The priority of the entry. Lower values are displayed first */ - void addMenuItemSeparator(std::vector unlocalizedMainMenuNames, u32 priority); + void addMenuItemSeparator(std::vector unlocalizedMainMenuNames, u32 priority); /** @@ -740,7 +741,7 @@ namespace hex { * @param unlocalizedTooltip The unlocalized tooltip to use for the button * @param function The function to call when the button is clicked */ - void addTitleBarButton(const std::string &icon, const std::string &unlocalizedTooltip, const impl::ClickCallback &function); + void addTitleBarButton(const std::string &icon, const UnlocalizedString &unlocalizedTooltip, const impl::ClickCallback &function); } @@ -749,7 +750,7 @@ namespace hex { namespace impl { - void addProviderName(const std::string &unlocalizedName); + void addProviderName(const UnlocalizedString &unlocalizedName); using ProviderCreationFunction = prv::Provider*(*)(); void add(const std::string &typeName, ProviderCreationFunction creationFunction); @@ -784,7 +785,7 @@ namespace hex { using Callback = std::function; struct Entry { - std::string unlocalizedName; + UnlocalizedString unlocalizedName; Callback callback; }; @@ -798,7 +799,7 @@ namespace hex { * @param unlocalizedName The unlocalized name of the formatter * @param callback The function to call to format the data */ - void add(const std::string &unlocalizedName, const impl::Callback &callback); + void add(const UnlocalizedString &unlocalizedName, const impl::Callback &callback); } @@ -831,7 +832,7 @@ namespace hex { class DataVisualizer { public: - DataVisualizer(std::string unlocalizedName, u16 bytesPerCell, u16 maxCharsPerCell) + DataVisualizer(UnlocalizedString unlocalizedName, u16 bytesPerCell, u16 maxCharsPerCell) : m_unlocalizedName(std::move(unlocalizedName)), m_bytesPerCell(bytesPerCell), m_maxCharsPerCell(maxCharsPerCell) { } @@ -844,7 +845,7 @@ namespace hex { [[nodiscard]] u16 getBytesPerCell() const { return this->m_bytesPerCell; } [[nodiscard]] u16 getMaxCharsPerCell() const { return this->m_maxCharsPerCell; } - [[nodiscard]] const std::string& getUnlocalizedName() const { return this->m_unlocalizedName; } + [[nodiscard]] const UnlocalizedString& getUnlocalizedName() const { return this->m_unlocalizedName; } protected: const static int TextInputFlags; @@ -853,7 +854,7 @@ namespace hex { bool drawDefaultTextEditingTextBox(u64 address, std::string &data, ImGuiInputTextFlags flags) const; private: - std::string m_unlocalizedName; + UnlocalizedString m_unlocalizedName; u16 m_bytesPerCell; u16 m_maxCharsPerCell; }; @@ -881,7 +882,7 @@ namespace hex { * @param unlocalizedName Unlocalized name of the data visualizer * @return The data visualizer, or nullptr if it doesn't exist */ - std::shared_ptr getVisualizerByName(const std::string &unlocalizedName); + std::shared_ptr getVisualizerByName(const UnlocalizedString &unlocalizedName); } @@ -890,7 +891,7 @@ namespace hex { class Hash { public: - explicit Hash(std::string unlocalizedName) : m_unlocalizedName(std::move(unlocalizedName)) {} + explicit Hash(UnlocalizedString unlocalizedName) : m_unlocalizedName(std::move(unlocalizedName)) {} virtual ~Hash() = default; class Function { @@ -932,7 +933,7 @@ namespace hex { [[nodiscard]] virtual nlohmann::json store() const = 0; virtual void load(const nlohmann::json &json) = 0; - [[nodiscard]] const std::string &getUnlocalizedName() const { + [[nodiscard]] const UnlocalizedString &getUnlocalizedName() const { return this->m_unlocalizedName; } @@ -942,7 +943,7 @@ namespace hex { } private: - std::string m_unlocalizedName; + UnlocalizedString m_unlocalizedName; }; namespace impl { @@ -980,7 +981,7 @@ namespace hex { void stopServices(); } - void registerService(const std::string &unlocalizedName, const impl::Callback &callback); + void registerService(const UnlocalizedString &unlocalizedName, const impl::Callback &callback); } /* Network Communication Interface Registry. Allows adding new communication interface endpoints */ @@ -1002,14 +1003,14 @@ namespace hex { namespace impl { struct Experiment { - std::string unlocalizedName, unlocalizedDescription; + UnlocalizedString unlocalizedName, unlocalizedDescription; bool enabled; }; std::map &getExperiments(); } - void addExperiment(const std::string &experimentName, const std::string &unlocalizedName, const std::string &unlocalizedDescription = ""); + void addExperiment(const std::string &experimentName, const UnlocalizedString &unlocalizedName, const UnlocalizedString &unlocalizedDescription = ""); void enableExperiement(const std::string &experimentName, bool enabled); [[nodiscard]] bool isExperimentEnabled(const std::string &experimentName); diff --git a/lib/libimhex/include/hex/api/imhex_api.hpp b/lib/libimhex/include/hex/api/imhex_api.hpp index a21d014df..e22357931 100644 --- a/lib/libimhex/include/hex/api/imhex_api.hpp +++ b/lib/libimhex/include/hex/api/imhex_api.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -338,7 +339,7 @@ namespace hex { * @param skipLoadInterface Whether to skip the provider's loading interface (see property documentation) * @param select Whether to select the provider after adding it */ - prv::Provider* createProvider(const std::string &unlocalizedName, bool skipLoadInterface = false, bool select = true); + prv::Provider* createProvider(const UnlocalizedString &unlocalizedName, bool skipLoadInterface = false, bool select = true); } diff --git a/lib/libimhex/include/hex/api/localization_manager.hpp b/lib/libimhex/include/hex/api/localization_manager.hpp index faea1ef61..1bf84dd30 100644 --- a/lib/libimhex/include/hex/api/localization_manager.hpp +++ b/lib/libimhex/include/hex/api/localization_manager.hpp @@ -32,10 +32,13 @@ namespace hex { [[nodiscard]] const std::string &getSelectedLanguage(); } + struct UnlocalizedString; + class Lang { public: explicit Lang(const char *unlocalizedString); - explicit Lang(std::string unlocalizedString); + explicit Lang(const std::string &unlocalizedString); + explicit Lang(const UnlocalizedString &unlocalizedString); explicit Lang(std::string_view unlocalizedString); [[nodiscard]] operator std::string() const; @@ -60,6 +63,43 @@ namespace hex { return Lang(string); } + + struct UnlocalizedString { + public: + UnlocalizedString() = default; + UnlocalizedString(auto && arg) : m_unlocalizedString(std::forward(arg)) { + static_assert(!std::same_as, Lang>, "Expected a unlocalized name, got a localized one!"); + } + + [[nodiscard]] operator std::string() const { + return m_unlocalizedString; + } + + [[nodiscard]] operator std::string_view() const { + return m_unlocalizedString; + } + + [[nodiscard]] operator const char *() const { + return m_unlocalizedString.c_str(); + } + + [[nodiscard]] const std::string &get() const { + return m_unlocalizedString; + } + + [[nodiscard]] bool empty() const { + return m_unlocalizedString.empty(); + } + + auto operator<=>(const UnlocalizedString &) const = default; + auto operator<=>(const std::string &other) const { + return m_unlocalizedString <=> other; + } + + private: + std::string m_unlocalizedString; + }; + } template<> diff --git a/lib/libimhex/include/hex/api/shortcut_manager.hpp b/lib/libimhex/include/hex/api/shortcut_manager.hpp index 81a4c08d5..a977a2428 100644 --- a/lib/libimhex/include/hex/api/shortcut_manager.hpp +++ b/lib/libimhex/include/hex/api/shortcut_manager.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include @@ -9,6 +9,8 @@ #include #include +#include + struct ImGuiWindow; namespace hex { @@ -391,7 +393,7 @@ namespace hex { using Callback = std::function; struct ShortcutEntry { Shortcut shortcut; - std::string unlocalizedName; + UnlocalizedString unlocalizedName; Callback callback; }; @@ -401,7 +403,7 @@ namespace hex { * @param unlocalizedName The unlocalized name of the shortcut * @param callback The callback to call when the shortcut is triggered. */ - static void addGlobalShortcut(const Shortcut &shortcut, const std::string &unlocalizedName, const Callback &callback); + static void addGlobalShortcut(const Shortcut &shortcut, const UnlocalizedString &unlocalizedName, const Callback &callback); /** * @brief Add a view-specific shortcut. View-specific shortcuts can only be triggered when the specified view is focused. @@ -410,7 +412,7 @@ namespace hex { * @param unlocalizedName The unlocalized name of the shortcut * @param callback The callback to call when the shortcut is triggered. */ - static void addShortcut(View *view, const Shortcut &shortcut, const std::string &unlocalizedName, const Callback &callback); + static void addShortcut(View *view, const Shortcut &shortcut, const UnlocalizedString &unlocalizedName, const Callback &callback); /** diff --git a/lib/libimhex/include/hex/api/task_manager.hpp b/lib/libimhex/include/hex/api/task_manager.hpp index 888b82f74..7364573f8 100644 --- a/lib/libimhex/include/hex/api/task_manager.hpp +++ b/lib/libimhex/include/hex/api/task_manager.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -23,7 +24,7 @@ namespace hex { class Task { public: Task() = default; - Task(std::string unlocalizedName, u64 maxValue, bool background, std::function function); + Task(UnlocalizedString unlocalizedName, u64 maxValue, bool background, std::function function); Task(const Task&) = delete; Task(Task &&other) noexcept; @@ -64,7 +65,7 @@ namespace hex { void clearException(); [[nodiscard]] std::string getExceptionMessage() const; - [[nodiscard]] const std::string &getUnlocalizedName(); + [[nodiscard]] const UnlocalizedString &getUnlocalizedName(); [[nodiscard]] u64 getValue() const; [[nodiscard]] u64 getMaxValue() const; @@ -76,7 +77,7 @@ namespace hex { private: mutable std::mutex m_mutex; - std::string m_unlocalizedName; + UnlocalizedString m_unlocalizedName; std::atomic m_currValue = 0, m_maxValue = 0; std::function m_interruptCallback; std::function m_function; diff --git a/lib/libimhex/include/hex/api/tutorial_manager.hpp b/lib/libimhex/include/hex/api/tutorial_manager.hpp index c517db3c0..77f2205e3 100644 --- a/lib/libimhex/include/hex/api/tutorial_manager.hpp +++ b/lib/libimhex/include/hex/api/tutorial_manager.hpp @@ -24,7 +24,7 @@ namespace hex { struct Tutorial { Tutorial() = delete; - Tutorial(const std::string &unlocalizedName, const std::string &unlocalizedDescription) : + Tutorial(const UnlocalizedString &unlocalizedName, const UnlocalizedString &unlocalizedDescription) : m_unlocalizedName(unlocalizedName), m_unlocalizedDescription(unlocalizedDescription) { } @@ -37,7 +37,7 @@ namespace hex { * @param ids ID of the element to highlight * @return Current step */ - Step& addHighlight(const std::string &unlocalizedText, std::initializer_list> &&ids); + Step& addHighlight(const UnlocalizedString &unlocalizedText, std::initializer_list> &&ids); /** * @brief Adds a highlighting to a specific element @@ -53,7 +53,7 @@ namespace hex { * @param position Position of the message box * @return Current step */ - Step& setMessage(const std::string &unlocalizedTitle, const std::string &unlocalizedMessage, Position position = Position::None); + Step& setMessage(const UnlocalizedString &unlocalizedTitle, const UnlocalizedString &unlocalizedMessage, Position position = Position::None); /** * @brief Allows this step to be skipped by clicking on the advance button @@ -78,14 +78,14 @@ namespace hex { private: struct Highlight { - std::string unlocalizedText; + UnlocalizedString unlocalizedText; std::vector> highlightIds; }; struct Message { Position position; - std::string unlocalizedTitle; - std::string unlocalizedMessage; + UnlocalizedString unlocalizedTitle; + UnlocalizedString unlocalizedMessage; bool allowSkip; }; @@ -105,16 +105,16 @@ namespace hex { Step& addStep(); - const std::string& getUnlocalizedName() const { return this->m_unlocalizedName; } - const std::string& getUnlocalizedDescription() const { return this->m_unlocalizedDescription; } + const UnlocalizedString& getUnlocalizedName() const { return this->m_unlocalizedName; } + const UnlocalizedString& getUnlocalizedDescription() const { return this->m_unlocalizedDescription; } private: friend class TutorialManager; void start(); - std::string m_unlocalizedName; - std::string m_unlocalizedDescription; + UnlocalizedString m_unlocalizedName; + UnlocalizedString m_unlocalizedDescription; std::list m_steps; decltype(m_steps)::iterator m_currentStep, m_latestStep; }; @@ -137,13 +137,13 @@ namespace hex { * @param unlocalizedDescription * @return Reference to created tutorial */ - static Tutorial& createTutorial(const std::string &unlocalizedName, const std::string &unlocalizedDescription); + static Tutorial& createTutorial(const UnlocalizedString &unlocalizedName, const UnlocalizedString &unlocalizedDescription); /** * @brief Starts the tutorial with the given name * @param unlocalizedName Name of tutorial to start */ - static void startTutorial(const std::string &unlocalizedName); + static void startTutorial(const UnlocalizedString &unlocalizedName); /** diff --git a/lib/libimhex/include/hex/data_processor/attribute.hpp b/lib/libimhex/include/hex/data_processor/attribute.hpp index 83979235c..6bb21bf2e 100644 --- a/lib/libimhex/include/hex/data_processor/attribute.hpp +++ b/lib/libimhex/include/hex/data_processor/attribute.hpp @@ -1,5 +1,7 @@ #pragma once + #include +#include #include #include @@ -23,7 +25,7 @@ namespace hex::dp { Out }; - Attribute(IOType ioType, Type type, std::string unlocalizedName); + Attribute(IOType ioType, Type type, UnlocalizedString unlocalizedName); ~Attribute(); [[nodiscard]] int getId() const { return this->m_id; } @@ -31,7 +33,7 @@ namespace hex::dp { [[nodiscard]] IOType getIOType() const { return this->m_ioType; } [[nodiscard]] Type getType() const { return this->m_type; } - [[nodiscard]] const std::string &getUnlocalizedName() const { return this->m_unlocalizedName; } + [[nodiscard]] const UnlocalizedString &getUnlocalizedName() const { return this->m_unlocalizedName; } void addConnectedAttribute(int linkId, Attribute *to) { this->m_connectedAttributes.insert({ linkId, to }); } void removeConnectedAttribute(int linkId) { this->m_connectedAttributes.erase(linkId); } @@ -56,7 +58,7 @@ namespace hex::dp { int m_id; IOType m_ioType; Type m_type; - std::string m_unlocalizedName; + UnlocalizedString m_unlocalizedName; std::map m_connectedAttributes; Node *m_parentNode = nullptr; diff --git a/lib/libimhex/include/hex/data_processor/node.hpp b/lib/libimhex/include/hex/data_processor/node.hpp index 69e477366..61729f160 100644 --- a/lib/libimhex/include/hex/data_processor/node.hpp +++ b/lib/libimhex/include/hex/data_processor/node.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -21,17 +22,17 @@ namespace hex::dp { class Node { public: - Node(std::string unlocalizedTitle, std::vector attributes); + Node(UnlocalizedString unlocalizedTitle, std::vector attributes); virtual ~Node() = default; [[nodiscard]] int getId() const { return this->m_id; } void setId(int id) { this->m_id = id; } - [[nodiscard]] const std::string &getUnlocalizedName() const { return this->m_unlocalizedName; } - void setUnlocalizedName(const std::string &unlocalizedName) { this->m_unlocalizedName = unlocalizedName; } + [[nodiscard]] const UnlocalizedString &getUnlocalizedName() const { return this->m_unlocalizedName; } + void setUnlocalizedName(const UnlocalizedString &unlocalizedName) { this->m_unlocalizedName = unlocalizedName; } - [[nodiscard]] const std::string &getUnlocalizedTitle() const { return this->m_unlocalizedTitle; } + [[nodiscard]] const UnlocalizedString &getUnlocalizedTitle() const { return this->m_unlocalizedTitle; } void setUnlocalizedTitle(std::string title) { this->m_unlocalizedTitle = std::move(title); } [[nodiscard]] std::vector &getAttributes() { return this->m_attributes; } @@ -81,7 +82,7 @@ namespace hex::dp { private: int m_id; - std::string m_unlocalizedTitle, m_unlocalizedName; + UnlocalizedString m_unlocalizedTitle, m_unlocalizedName; std::vector m_attributes; std::set m_processedInputs; prv::Overlay *m_overlay = nullptr; diff --git a/lib/libimhex/include/hex/providers/undo_redo/operations/operation_group.hpp b/lib/libimhex/include/hex/providers/undo_redo/operations/operation_group.hpp index bb4e5da17..ec16c038f 100644 --- a/lib/libimhex/include/hex/providers/undo_redo/operations/operation_group.hpp +++ b/lib/libimhex/include/hex/providers/undo_redo/operations/operation_group.hpp @@ -10,7 +10,7 @@ namespace hex::prv::undo { class OperationGroup : public Operation { public: - explicit OperationGroup(std::string unlocalizedName) : m_unlocalizedName(std::move(unlocalizedName)) {} + explicit OperationGroup(UnlocalizedString unlocalizedName) : m_unlocalizedName(std::move(unlocalizedName)) {} OperationGroup(const OperationGroup &other) { for (const auto &operation : other.m_operations) @@ -59,7 +59,7 @@ namespace hex::prv::undo { } private: - std::string m_unlocalizedName; + UnlocalizedString m_unlocalizedName; std::vector> m_operations; u64 m_startAddress = std::numeric_limits::max(); diff --git a/lib/libimhex/include/hex/providers/undo_redo/stack.hpp b/lib/libimhex/include/hex/providers/undo_redo/stack.hpp index 3ab22cd2c..f5ceb9c8c 100644 --- a/lib/libimhex/include/hex/providers/undo_redo/stack.hpp +++ b/lib/libimhex/include/hex/providers/undo_redo/stack.hpp @@ -1,9 +1,10 @@ #pragma once #include +#include + #include -#include #include #include #include @@ -24,7 +25,7 @@ namespace hex::prv::undo { void undo(u32 count = 1); void redo(u32 count = 1); - void groupOperations(u32 count, const std::string &unlocalizedName); + void groupOperations(u32 count, const UnlocalizedString &unlocalizedName); void apply(const Stack &otherStack); [[nodiscard]] bool canUndo() const; diff --git a/lib/libimhex/include/hex/ui/popup.hpp b/lib/libimhex/include/hex/ui/popup.hpp index 4a792a235..a73b60738 100644 --- a/lib/libimhex/include/hex/ui/popup.hpp +++ b/lib/libimhex/include/hex/ui/popup.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -17,7 +18,7 @@ namespace hex { class PopupBase { public: - explicit PopupBase(std::string unlocalizedName, bool closeButton, bool modal) + explicit PopupBase(UnlocalizedString unlocalizedName, bool closeButton, bool modal) : m_unlocalizedName(std::move(unlocalizedName)), m_closeButton(closeButton), m_modal(modal) { } virtual ~PopupBase() = default; @@ -35,7 +36,7 @@ namespace hex { [[nodiscard]] static std::vector> &getOpenPopups(); - [[nodiscard]] const std::string &getUnlocalizedName() const { + [[nodiscard]] const UnlocalizedString &getUnlocalizedName() const { return this->m_unlocalizedName; } @@ -57,7 +58,7 @@ namespace hex { private: - std::string m_unlocalizedName; + UnlocalizedString m_unlocalizedName; bool m_closeButton, m_modal; std::atomic m_close = false; }; @@ -68,7 +69,7 @@ namespace hex { template class Popup : public impl::PopupBase { protected: - explicit Popup(std::string unlocalizedName, bool closeButton = true, bool modal = true) : PopupBase(std::move(unlocalizedName), closeButton, modal) { } + explicit Popup(UnlocalizedString unlocalizedName, bool closeButton = true, bool modal = true) : PopupBase(std::move(unlocalizedName), closeButton, modal) { } public: template diff --git a/lib/libimhex/include/hex/ui/view.hpp b/lib/libimhex/include/hex/ui/view.hpp index c8bb9afd0..913e1934f 100644 --- a/lib/libimhex/include/hex/ui/view.hpp +++ b/lib/libimhex/include/hex/ui/view.hpp @@ -11,11 +11,12 @@ #include #include #include +#include + #include #include #include -#include #include #include @@ -23,7 +24,7 @@ namespace hex { class View { - explicit View(std::string unlocalizedName); + explicit View(UnlocalizedString unlocalizedName); public: virtual ~View() = default; @@ -86,7 +87,7 @@ namespace hex { [[nodiscard]] bool &getWindowOpenState(); [[nodiscard]] const bool &getWindowOpenState() const; - [[nodiscard]] const std::string &getUnlocalizedName() const; + [[nodiscard]] const UnlocalizedString &getUnlocalizedName() const; [[nodiscard]] std::string getName() const; [[nodiscard]] bool didWindowJustOpen(); @@ -96,7 +97,7 @@ namespace hex { static void discardNavigationRequests(); - [[nodiscard]] static std::string toWindowName(const std::string &unlocalizedName); + [[nodiscard]] static std::string toWindowName(const UnlocalizedString &unlocalizedName); public: class Window; @@ -105,7 +106,7 @@ namespace hex { class Modal; private: - std::string m_unlocalizedViewName; + UnlocalizedString m_unlocalizedViewName; bool m_windowOpen = false, m_prevWindowOpen = false; std::map m_shortcuts; bool m_windowJustOpened = false; @@ -119,7 +120,7 @@ namespace hex { */ class View::Window : public View { public: - explicit Window(std::string unlocalizedName) : View(std::move(unlocalizedName)) {} + explicit Window(UnlocalizedString unlocalizedName) : View(std::move(unlocalizedName)) {} void draw() final { if (this->shouldDraw()) { @@ -138,7 +139,7 @@ namespace hex { */ class View::Special : public View { public: - explicit Special(std::string unlocalizedName) : View(std::move(unlocalizedName)) {} + explicit Special(UnlocalizedString unlocalizedName) : View(std::move(unlocalizedName)) {} void draw() final { if (this->shouldDraw()) { @@ -153,7 +154,7 @@ namespace hex { */ class View::Floating : public View::Window { public: - explicit Floating(std::string unlocalizedName) : Window(std::move(unlocalizedName)) {} + explicit Floating(UnlocalizedString unlocalizedName) : Window(std::move(unlocalizedName)) {} [[nodiscard]] ImGuiWindowFlags getWindowFlags() const override { return ImGuiWindowFlags_NoDocking; } }; @@ -163,7 +164,7 @@ namespace hex { */ class View::Modal : public View { public: - explicit Modal(std::string unlocalizedName) : View(std::move(unlocalizedName)) {} + explicit Modal(UnlocalizedString unlocalizedName) : View(std::move(unlocalizedName)) {} void draw() final { if (this->shouldDraw()) { diff --git a/lib/libimhex/source/api/achievement_manager.cpp b/lib/libimhex/source/api/achievement_manager.cpp index c1681fe94..8d3d050f6 100644 --- a/lib/libimhex/source/api/achievement_manager.cpp +++ b/lib/libimhex/source/api/achievement_manager.cpp @@ -87,7 +87,7 @@ namespace hex { return startNodes; } - void AchievementManager::unlockAchievement(const std::string &unlocalizedCategory, const std::string &unlocalizedName) { + void AchievementManager::unlockAchievement(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName) { auto &categories = getAchievements(); auto categoryIter = categories.find(unlocalizedCategory); diff --git a/lib/libimhex/source/api/content_registry.cpp b/lib/libimhex/source/api/content_registry.cpp index 537590aaf..97c9d6dbd 100644 --- a/lib/libimhex/source/api/content_registry.cpp +++ b/lib/libimhex/source/api/content_registry.cpp @@ -28,7 +28,7 @@ namespace hex { namespace impl { - nlohmann::json& getSetting(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const nlohmann::json &defaultValue) { + nlohmann::json& getSetting(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const nlohmann::json &defaultValue) { auto &settings = getSettingsData(); if (!settings.contains(unlocalizedCategory)) @@ -113,7 +113,7 @@ namespace hex { #endif template - static T* insertOrGetEntry(std::vector &vector, const std::string &unlocalizedName) { + static T* insertOrGetEntry(std::vector &vector, const UnlocalizedString &unlocalizedName) { T *foundEntry = nullptr; for (auto &entry : vector) { if (entry.unlocalizedName == unlocalizedName) { @@ -138,7 +138,7 @@ namespace hex { return categories; } - Widgets::Widget* add(const std::string &unlocalizedCategory, const std::string &unlocalizedSubCategory, const std::string &unlocalizedName, std::unique_ptr &&widget) { + Widgets::Widget* add(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedSubCategory, const UnlocalizedString &unlocalizedName, std::unique_ptr &&widget) { const auto category = insertOrGetEntry(getSettings(), unlocalizedCategory); const auto subCategory = insertOrGetEntry(category->subCategories, unlocalizedSubCategory); const auto entry = insertOrGetEntry(subCategory->entries, unlocalizedName); @@ -152,13 +152,13 @@ namespace hex { } - void setCategoryDescription(const std::string &unlocalizedCategory, const std::string &unlocalizedDescription) { + void setCategoryDescription(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedDescription) { const auto category = insertOrGetEntry(impl::getSettings(), unlocalizedCategory); category->unlocalizedDescription = unlocalizedDescription; } - nlohmann::json read(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const nlohmann::json &defaultValue) { + nlohmann::json read(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const nlohmann::json &defaultValue) { auto setting = impl::getSetting(unlocalizedCategory, unlocalizedName, defaultValue); if (setting.is_number() && defaultValue.is_boolean()) @@ -169,7 +169,7 @@ namespace hex { return setting; } - void write(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const nlohmann::json &value) { + void write(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const nlohmann::json &value) { impl::getSetting(unlocalizedCategory, unlocalizedName, value) = value; } @@ -391,7 +391,7 @@ namespace hex { namespace ContentRegistry::CommandPaletteCommands { - void add(Type type, const std::string &command, const std::string &unlocalizedDescription, const impl::DisplayCallback &displayCallback, const impl::ExecuteCallback &executeCallback) { + void add(Type type, const std::string &command, const UnlocalizedString &unlocalizedDescription, const impl::DisplayCallback &displayCallback, const impl::ExecuteCallback &executeCallback) { log::debug("Registered new command palette command: {}", command); impl::getEntries().push_back(impl::Entry { type, command, unlocalizedDescription, displayCallback, executeCallback }); @@ -561,12 +561,12 @@ namespace hex { } void impl::add(std::unique_ptr &&view) { - log::debug("Registered new view: {}", view->getUnlocalizedName()); + log::debug("Registered new view: {}", view->getUnlocalizedName().get()); getEntries().insert({ view->getUnlocalizedName(), std::move(view) }); } - View* getViewByName(const std::string &unlocalizedName) { + View* getViewByName(const UnlocalizedString &unlocalizedName) { auto &views = impl::getEntries(); if (views.contains(unlocalizedName)) @@ -579,8 +579,8 @@ namespace hex { namespace ContentRegistry::Tools { - void add(const std::string &unlocalizedName, const impl::Callback &function) { - log::debug("Registered new tool: {}", unlocalizedName); + void add(const UnlocalizedString &unlocalizedName, const impl::Callback &function) { + log::debug("Registered new tool: {}", unlocalizedName.get()); impl::getEntries().emplace_back(impl::Entry { unlocalizedName, function, false }); } @@ -599,14 +599,14 @@ namespace hex { namespace ContentRegistry::DataInspector { - void add(const std::string &unlocalizedName, size_t requiredSize, impl::GeneratorFunction displayGeneratorFunction, std::optional editingFunction) { - log::debug("Registered new data inspector format: {}", unlocalizedName); + void add(const UnlocalizedString &unlocalizedName, size_t requiredSize, impl::GeneratorFunction displayGeneratorFunction, std::optional editingFunction) { + log::debug("Registered new data inspector format: {}", unlocalizedName.get()); impl::getEntries().push_back({ unlocalizedName, requiredSize, requiredSize, std::move(displayGeneratorFunction), std::move(editingFunction) }); } - void add(const std::string &unlocalizedName, size_t requiredSize, size_t maxSize, impl::GeneratorFunction displayGeneratorFunction, std::optional editingFunction) { - log::debug("Registered new data inspector format: {}", unlocalizedName); + void add(const UnlocalizedString &unlocalizedName, size_t requiredSize, size_t maxSize, impl::GeneratorFunction displayGeneratorFunction, std::optional editingFunction) { + log::debug("Registered new data inspector format: {}", unlocalizedName.get()); impl::getEntries().push_back({ unlocalizedName, requiredSize, maxSize, std::move(displayGeneratorFunction), std::move(editingFunction) }); } @@ -627,7 +627,7 @@ namespace hex { namespace ContentRegistry::DataProcessorNode { void impl::add(const Entry &entry) { - log::debug("Registered new data processor node type: [{}]: {}", entry.category, entry.name); + log::debug("Registered new data processor node type: [{}]: {}", entry.unlocalizedCategory.get(), entry.unlocalizedName.get()); getEntries().push_back(entry); } @@ -712,14 +712,14 @@ namespace hex { namespace ContentRegistry::Interface { - void registerMainMenuItem(const std::string &unlocalizedName, u32 priority) { - log::debug("Registered new main menu item: {}", unlocalizedName); + void registerMainMenuItem(const UnlocalizedString &unlocalizedName, u32 priority) { + log::debug("Registered new main menu item: {}", unlocalizedName.get()); impl::getMainMenuItems().insert({ priority, { unlocalizedName } }); } - void addMenuItem(const std::vector &unlocalizedMainMenuNames, u32 priority, const Shortcut &shortcut, const impl::MenuCallback &function, const impl::EnabledCallback& enabledCallback, View *view) { - log::debug("Added new menu item to menu {} with priority {}", wolv::util::combineStrings(unlocalizedMainMenuNames, " -> "), priority); + void addMenuItem(const std::vector &unlocalizedMainMenuNames, u32 priority, const Shortcut &shortcut, const impl::MenuCallback &function, const impl::EnabledCallback& enabledCallback, View *view) { + log::debug("Added new menu item to menu {} with priority {}", unlocalizedMainMenuNames[0].get(), priority); impl::getMenuItems().insert({ priority, impl::MenuItem { unlocalizedMainMenuNames, std::make_unique(shortcut), view, function, enabledCallback } @@ -733,8 +733,8 @@ namespace hex { } } - void addMenuItemSubMenu(std::vector unlocalizedMainMenuNames, u32 priority, const impl::MenuCallback &function, const impl::EnabledCallback& enabledCallback) { - log::debug("Added new menu item sub menu to menu {} with priority {}", wolv::util::combineStrings(unlocalizedMainMenuNames, " -> "), priority); + void addMenuItemSubMenu(std::vector unlocalizedMainMenuNames, u32 priority, const impl::MenuCallback &function, const impl::EnabledCallback& enabledCallback) { + log::debug("Added new menu item sub menu to menu {} with priority {}", unlocalizedMainMenuNames[0].get(), priority); unlocalizedMainMenuNames.emplace_back(impl::SubMenuValue); impl::getMenuItems().insert({ @@ -742,7 +742,7 @@ namespace hex { }); } - void addMenuItemSeparator(std::vector unlocalizedMainMenuNames, u32 priority) { + void addMenuItemSeparator(std::vector unlocalizedMainMenuNames, u32 priority) { unlocalizedMainMenuNames.emplace_back(impl::SeparatorValue); impl::getMenuItems().insert({ priority, impl::MenuItem { unlocalizedMainMenuNames, std::make_unique(), nullptr, []{}, []{ return true; } } @@ -765,7 +765,7 @@ namespace hex { impl::getSidebarItems().push_back({ icon, function, enabledCallback }); } - void addTitleBarButton(const std::string &icon, const std::string &unlocalizedTooltip, const impl::ClickCallback &function) { + void addTitleBarButton(const std::string &icon, const UnlocalizedString &unlocalizedTooltip, const impl::ClickCallback &function) { impl::getTitleBarButtons().push_back({ icon, unlocalizedTooltip, function }); } @@ -835,8 +835,8 @@ namespace hex { return providerNames; } - void addProviderName(const std::string &unlocalizedName) { - log::debug("Registered new provider: {}", unlocalizedName); + void addProviderName(const UnlocalizedString &unlocalizedName) { + log::debug("Registered new provider: {}", unlocalizedName.get()); getEntries().push_back(unlocalizedName); } @@ -848,8 +848,8 @@ namespace hex { namespace ContentRegistry::DataFormatter { - void add(const std::string &unlocalizedName, const impl::Callback &callback) { - log::debug("Registered new data formatter: {}", unlocalizedName); + void add(const UnlocalizedString &unlocalizedName, const impl::Callback &callback) { + log::debug("Registered new data formatter: {}", unlocalizedName.get()); impl::getEntries().push_back({ unlocalizedName, callback }); } @@ -966,7 +966,7 @@ namespace hex { } - std::shared_ptr getVisualizerByName(const std::string &unlocalizedName) { + std::shared_ptr getVisualizerByName(const UnlocalizedString &unlocalizedName) { for (const auto &visualizer : impl::getVisualizers()) { if (visualizer->getUnlocalizedName() == unlocalizedName) return visualizer; @@ -1019,8 +1019,8 @@ namespace hex { } - void registerService(const std::string &unlocalizedName, const impl::Callback &callback) { - log::debug("Registered new background service: {}", unlocalizedName); + void registerService(const UnlocalizedString &unlocalizedName, const impl::Callback &callback) { + log::debug("Registered new background service: {}", unlocalizedName.get()); impl::getServices().push_back(impl::Service { unlocalizedName, @@ -1067,7 +1067,7 @@ namespace hex { } - void addExperiment(const std::string &experimentName, const std::string &unlocalizedName, const std::string &unlocalizedDescription) { + void addExperiment(const std::string &experimentName, const UnlocalizedString &unlocalizedName, const UnlocalizedString &unlocalizedDescription) { auto &experiments = impl::getExperiments(); if (experiments.contains(experimentName)) { diff --git a/lib/libimhex/source/api/imhex_api.cpp b/lib/libimhex/source/api/imhex_api.cpp index e90eb4a27..31097e10f 100644 --- a/lib/libimhex/source/api/imhex_api.cpp +++ b/lib/libimhex/source/api/imhex_api.cpp @@ -365,7 +365,7 @@ namespace hex { }); } - prv::Provider* createProvider(const std::string &unlocalizedName, bool skipLoadInterface, bool select) { + prv::Provider* createProvider(const UnlocalizedString &unlocalizedName, bool skipLoadInterface, bool select) { prv::Provider* result = nullptr; RequestCreateProvider::post(unlocalizedName, skipLoadInterface, select, &result); diff --git a/lib/libimhex/source/api/localization_manager.cpp b/lib/libimhex/source/api/localization_manager.cpp index 92ebff197..a77648482 100644 --- a/lib/libimhex/source/api/localization_manager.cpp +++ b/lib/libimhex/source/api/localization_manager.cpp @@ -75,7 +75,8 @@ namespace hex { } Lang::Lang(const char *unlocalizedString) : m_unlocalizedString(unlocalizedString) { } - Lang::Lang(std::string unlocalizedString) : m_unlocalizedString(std::move(unlocalizedString)) { } + Lang::Lang(const std::string &unlocalizedString) : m_unlocalizedString(unlocalizedString) { } + Lang::Lang(const UnlocalizedString &unlocalizedString) : m_unlocalizedString(unlocalizedString.get()) { } Lang::Lang(std::string_view unlocalizedString) : m_unlocalizedString(unlocalizedString) { } Lang::operator std::string() const { diff --git a/lib/libimhex/source/api/shortcut_manager.cpp b/lib/libimhex/source/api/shortcut_manager.cpp index 10829dc7d..fc82f47cf 100644 --- a/lib/libimhex/source/api/shortcut_manager.cpp +++ b/lib/libimhex/source/api/shortcut_manager.cpp @@ -15,11 +15,11 @@ namespace hex { } - void ShortcutManager::addGlobalShortcut(const Shortcut &shortcut, const std::string &unlocalizedName, const std::function &callback) { + void ShortcutManager::addGlobalShortcut(const Shortcut &shortcut, const UnlocalizedString &unlocalizedName, const std::function &callback) { s_globalShortcuts.insert({ shortcut, { shortcut, unlocalizedName, callback } }); } - void ShortcutManager::addShortcut(View *view, const Shortcut &shortcut, const std::string &unlocalizedName, const std::function &callback) { + void ShortcutManager::addShortcut(View *view, const Shortcut &shortcut, const UnlocalizedString &unlocalizedName, const std::function &callback) { view->m_shortcuts.insert({ shortcut + CurrentView, { shortcut, unlocalizedName, callback } }); } diff --git a/lib/libimhex/source/api/task_manager.cpp b/lib/libimhex/source/api/task_manager.cpp index 1327982b2..f32db4e8b 100644 --- a/lib/libimhex/source/api/task_manager.cpp +++ b/lib/libimhex/source/api/task_manager.cpp @@ -55,7 +55,7 @@ namespace hex { #endif } - Task::Task(std::string unlocalizedName, u64 maxValue, bool background, std::function function) + Task::Task(UnlocalizedString unlocalizedName, u64 maxValue, bool background, std::function function) : m_unlocalizedName(std::move(unlocalizedName)), m_maxValue(maxValue), m_function(std::move(function)), m_background(background) { } Task::Task(hex::Task &&other) noexcept { @@ -138,7 +138,7 @@ namespace hex { return this->m_exceptionMessage; } - const std::string &Task::getUnlocalizedName() { + const UnlocalizedString &Task::getUnlocalizedName() { return this->m_unlocalizedName; } @@ -281,17 +281,17 @@ namespace hex { // Execute the task task->m_function(*task); - log::debug("Task '{}' finished", task->m_unlocalizedName); + log::debug("Task '{}' finished", task->m_unlocalizedName.get()); } catch (const Task::TaskInterruptor &) { // Handle the task being interrupted by user request task->interruption(); } catch (const std::exception &e) { - log::error("Exception in task '{}': {}", task->m_unlocalizedName, e.what()); + log::error("Exception in task '{}': {}", task->m_unlocalizedName.get(), e.what()); // Handle the task throwing an uncaught exception task->exception(e.what()); } catch (...) { - log::error("Exception in task '{}'", task->m_unlocalizedName); + log::error("Exception in task '{}'", task->m_unlocalizedName.get()); // Handle the task throwing an uncaught exception of unknown type task->exception("Unknown Exception"); diff --git a/lib/libimhex/source/api/tutorial_manager.cpp b/lib/libimhex/source/api/tutorial_manager.cpp index 1024abda3..d1696b62b 100644 --- a/lib/libimhex/source/api/tutorial_manager.cpp +++ b/lib/libimhex/source/api/tutorial_manager.cpp @@ -66,11 +66,11 @@ namespace hex { } - TutorialManager::Tutorial& TutorialManager::createTutorial(const std::string& unlocalizedName, const std::string& unlocalizedDescription) { + TutorialManager::Tutorial& TutorialManager::createTutorial(const UnlocalizedString &unlocalizedName, const UnlocalizedString &unlocalizedDescription) { return s_tutorials.try_emplace(unlocalizedName, Tutorial(unlocalizedName, unlocalizedDescription)).first->second; } - void TutorialManager::startTutorial(const std::string& unlocalizedName) { + void TutorialManager::startTutorial(const UnlocalizedString &unlocalizedName) { s_currentTutorial = s_tutorials.find(unlocalizedName); if (s_currentTutorial == s_tutorials.end()) return; @@ -251,7 +251,7 @@ namespace hex { }, id); } - s_highlights.emplace(idStack.get(), text.c_str()); + s_highlights.emplace(idStack.get(), text); } } @@ -288,7 +288,7 @@ namespace hex { } - TutorialManager::Tutorial::Step& TutorialManager::Tutorial::Step::addHighlight(const std::string& unlocalizedText, std::initializer_list>&& ids) { + TutorialManager::Tutorial::Step& TutorialManager::Tutorial::Step::addHighlight(const UnlocalizedString &unlocalizedText, std::initializer_list>&& ids) { this->m_highlights.emplace_back( unlocalizedText, ids @@ -298,12 +298,12 @@ namespace hex { } TutorialManager::Tutorial::Step& TutorialManager::Tutorial::Step::addHighlight(std::initializer_list>&& ids) { - return this->addHighlight("", std::move(ids)); + return this->addHighlight("", std::forward(ids)); } - TutorialManager::Tutorial::Step& TutorialManager::Tutorial::Step::setMessage(const std::string& unlocalizedTitle, const std::string& unlocalizedMessage, Position position) { + TutorialManager::Tutorial::Step& TutorialManager::Tutorial::Step::setMessage(const UnlocalizedString &unlocalizedTitle, const UnlocalizedString &unlocalizedMessage, Position position) { this->m_message = Message { position, unlocalizedTitle, diff --git a/lib/libimhex/source/data_processor/attribute.cpp b/lib/libimhex/source/data_processor/attribute.cpp index 2b9ee244a..2c8902ca5 100644 --- a/lib/libimhex/source/data_processor/attribute.cpp +++ b/lib/libimhex/source/data_processor/attribute.cpp @@ -6,7 +6,7 @@ namespace hex::dp { int Attribute::s_idCounter = 1; - Attribute::Attribute(IOType ioType, Type type, std::string unlocalizedName) : m_id(s_idCounter++), m_ioType(ioType), m_type(type), m_unlocalizedName(std::move(unlocalizedName)) { + Attribute::Attribute(IOType ioType, Type type, UnlocalizedString unlocalizedName) : m_id(s_idCounter++), m_ioType(ioType), m_type(type), m_unlocalizedName(std::move(unlocalizedName)) { } Attribute::~Attribute() { diff --git a/lib/libimhex/source/data_processor/node.cpp b/lib/libimhex/source/data_processor/node.cpp index c1a8010bd..ef5405d87 100644 --- a/lib/libimhex/source/data_processor/node.cpp +++ b/lib/libimhex/source/data_processor/node.cpp @@ -9,7 +9,7 @@ namespace hex::dp { int Node::s_idCounter = 1; - Node::Node(std::string unlocalizedTitle, std::vector attributes) : m_id(s_idCounter++), m_unlocalizedTitle(std::move(unlocalizedTitle)), m_attributes(std::move(attributes)) { + Node::Node(UnlocalizedString unlocalizedTitle, std::vector attributes) : m_id(s_idCounter++), m_unlocalizedTitle(std::move(unlocalizedTitle)), m_attributes(std::move(attributes)) { for (auto &attr : this->m_attributes) attr.setParentNode(this); } diff --git a/lib/libimhex/source/providers/undo/stack.cpp b/lib/libimhex/source/providers/undo/stack.cpp index ff57d1803..cc6ebf587 100644 --- a/lib/libimhex/source/providers/undo/stack.cpp +++ b/lib/libimhex/source/providers/undo/stack.cpp @@ -5,12 +5,13 @@ #include +#include namespace hex::prv::undo { namespace { - std::atomic_bool s_locked; + std::atomic s_locked; std::mutex s_mutex; } @@ -66,7 +67,7 @@ namespace hex::prv::undo { } } - void Stack::groupOperations(u32 count, const std::string &unlocalizedName) { + void Stack::groupOperations(u32 count, const UnlocalizedString &unlocalizedName) { if (count <= 1) return; diff --git a/lib/libimhex/source/ui/view.cpp b/lib/libimhex/source/ui/view.cpp index 8abb364f9..a4a3b30e7 100644 --- a/lib/libimhex/source/ui/view.cpp +++ b/lib/libimhex/source/ui/view.cpp @@ -7,7 +7,7 @@ namespace hex { - View::View(std::string unlocalizedName) : m_unlocalizedViewName(std::move(unlocalizedName)) { } + View::View(UnlocalizedString unlocalizedName) : m_unlocalizedViewName(std::move(unlocalizedName)) { } bool View::shouldDraw() const { return ImHexApi::Provider::isValid() && ImHexApi::Provider::get()->isAvailable(); @@ -43,7 +43,7 @@ namespace hex { return this->m_windowOpen; } - const std::string &View::getUnlocalizedName() const { + const UnlocalizedString &View::getUnlocalizedName() const { return this->m_unlocalizedViewName; } @@ -71,8 +71,8 @@ namespace hex { ImGui::GetIO().ConfigFlags &= ~ImGuiConfigFlags_NavEnableKeyboard; } - std::string View::toWindowName(const std::string &unlocalizedName) { - return Lang(unlocalizedName) + "###" + unlocalizedName; + std::string View::toWindowName(const UnlocalizedString &unlocalizedName) { + return Lang(unlocalizedName) + "###" + unlocalizedName.get(); } } \ No newline at end of file diff --git a/main/gui/source/window/window.cpp b/main/gui/source/window/window.cpp index 99c906c1f..9d0d72b0a 100644 --- a/main/gui/source/window/window.cpp +++ b/main/gui/source/window/window.cpp @@ -231,21 +231,21 @@ namespace hex { } } - static void createNestedMenu(std::span menuItems, const Shortcut &shortcut, const std::function &callback, const std::function &enabledCallback) { + static void createNestedMenu(std::span menuItems, const Shortcut &shortcut, const std::function &callback, const std::function &enabledCallback) { const auto &name = menuItems.front(); - if (name == ContentRegistry::Interface::impl::SeparatorValue) { + if (name.get() == ContentRegistry::Interface::impl::SeparatorValue) { ImGui::Separator(); return; } - if (name == ContentRegistry::Interface::impl::SubMenuValue) { + if (name.get() == ContentRegistry::Interface::impl::SubMenuValue) { callback(); } else if (menuItems.size() == 1) { if (ImGui::MenuItem(Lang(name), shortcut.toString().c_str(), false, enabledCallback())) callback(); } else { - bool isSubmenu = *(menuItems.begin() + 1) == ContentRegistry::Interface::impl::SubMenuValue; + bool isSubmenu = (menuItems.begin() + 1)->get() == ContentRegistry::Interface::impl::SubMenuValue; if (ImGui::BeginMenu(Lang(name), isSubmenu ? enabledCallback() : true)) { createNestedMenu({ menuItems.begin() + 1, menuItems.end() }, shortcut, callback, enabledCallback); @@ -760,7 +760,7 @@ namespace hex { for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItems()) { const auto &[unlocalizedNames, shortcut, view, callback, enabledCallback] = menuItem; - if (ImGui::BeginPopup(unlocalizedNames.front().c_str())) { + if (ImGui::BeginPopup(unlocalizedNames.front().get().c_str())) { createNestedMenu({ unlocalizedNames.begin() + 1, unlocalizedNames.end() }, *shortcut, callback, enabledCallback); ImGui::EndPopup(); } @@ -1178,7 +1178,7 @@ namespace hex { Window* window = static_cast(handler->UserData); for (auto &[name, view] : ContentRegistry::Views::impl::getEntries()) { - std::string format = view->getUnlocalizedName() + "=%d"; + std::string format = view->getUnlocalizedName().get() + "=%d"; sscanf(line, format.c_str(), &view->getWindowOpenState()); } for (auto &[name, function, detached] : ContentRegistry::Tools::impl::getEntries()) { diff --git a/plugins/builtin/include/content/popups/popup_notification.hpp b/plugins/builtin/include/content/popups/popup_notification.hpp index aff63146c..89f51a4ab 100644 --- a/plugins/builtin/include/content/popups/popup_notification.hpp +++ b/plugins/builtin/include/content/popups/popup_notification.hpp @@ -15,7 +15,7 @@ namespace hex::plugin::builtin { template class PopupNotification : public Popup { public: - PopupNotification(std::string unlocalizedName, std::string message, std::function function) + PopupNotification(UnlocalizedString unlocalizedName, std::string message, std::function function) : hex::Popup(std::move(unlocalizedName), false), m_message(std::move(message)), m_function(std::move(function)) { } diff --git a/plugins/builtin/include/content/popups/popup_text_input.hpp b/plugins/builtin/include/content/popups/popup_text_input.hpp index 7afb2ffaf..b9b3943ec 100644 --- a/plugins/builtin/include/content/popups/popup_text_input.hpp +++ b/plugins/builtin/include/content/popups/popup_text_input.hpp @@ -14,12 +14,12 @@ namespace hex::plugin::builtin { class PopupTextInput : public Popup { public: - PopupTextInput(std::string unlocalizedName, std::string message, std::function function) + PopupTextInput(UnlocalizedString unlocalizedName, UnlocalizedString message, std::function function) : hex::Popup(std::move(unlocalizedName), false), m_message(std::move(message)), m_function(std::move(function)) { } void drawContent() override { - ImGuiExt::TextFormattedWrapped("{}", this->m_message.c_str()); + ImGuiExt::TextFormattedWrapped("{}", Lang(this->m_message)); ImGui::NewLine(); ImGui::PushItemWidth(-1); @@ -65,7 +65,7 @@ namespace hex::plugin::builtin { private: std::string m_input; - std::string m_message; + UnlocalizedString m_message; std::function m_function; bool m_justOpened = true; }; diff --git a/plugins/builtin/include/content/views/view_data_inspector.hpp b/plugins/builtin/include/content/views/view_data_inspector.hpp index 367f558be..003f71cf9 100644 --- a/plugins/builtin/include/content/views/view_data_inspector.hpp +++ b/plugins/builtin/include/content/views/view_data_inspector.hpp @@ -20,7 +20,7 @@ namespace hex::plugin::builtin { private: struct InspectorCacheEntry { - std::string unlocalizedName; + UnlocalizedString unlocalizedName; ContentRegistry::DataInspector::impl::DisplayFunction displayFunction; std::optional editingFunction; bool editing; diff --git a/plugins/builtin/include/content/views/view_store.hpp b/plugins/builtin/include/content/views/view_store.hpp index 6b979f14c..275e9b47b 100644 --- a/plugins/builtin/include/content/views/view_store.hpp +++ b/plugins/builtin/include/content/views/view_store.hpp @@ -38,7 +38,7 @@ namespace hex::plugin::builtin { }; struct StoreCategory { - std::string unlocalizedName; + UnlocalizedString unlocalizedName; std::string requestName; fs::ImHexPath path; std::vector entries; @@ -76,7 +76,7 @@ namespace hex::plugin::builtin { void refresh(); void parseResponse(); - void addCategory(const std::string &unlocalizedName, const std::string &requestName, fs::ImHexPath path, std::function downloadCallback = []{}); + void addCategory(const UnlocalizedString &unlocalizedName, const std::string &requestName, fs::ImHexPath path, std::function downloadCallback = []{}); bool download(fs::ImHexPath pathType, const std::string &fileName, const std::string &url, bool update); bool remove(fs::ImHexPath pathType, const std::string &fileName); diff --git a/plugins/builtin/source/content/achievements.cpp b/plugins/builtin/source/content/achievements.cpp index 0c69fe7f5..22141cc43 100644 --- a/plugins/builtin/source/content/achievements.cpp +++ b/plugins/builtin/source/content/achievements.cpp @@ -16,32 +16,32 @@ namespace hex::plugin::builtin { class AchievementStartingOut : public Achievement { public: - explicit AchievementStartingOut(std::string unlocalizedName) : Achievement("hex.builtin.achievement.starting_out", std::move(unlocalizedName)) { } + explicit AchievementStartingOut(UnlocalizedString unlocalizedName) : Achievement("hex.builtin.achievement.starting_out", std::move(unlocalizedName)) { } }; class AchievementHexEditor : public Achievement { public: - explicit AchievementHexEditor(std::string unlocalizedName) : Achievement("hex.builtin.achievement.hex_editor", std::move(unlocalizedName)) { } + explicit AchievementHexEditor(UnlocalizedString unlocalizedName) : Achievement("hex.builtin.achievement.hex_editor", std::move(unlocalizedName)) { } }; class AchievementPatterns : public Achievement { public: - explicit AchievementPatterns(std::string unlocalizedName) : Achievement("hex.builtin.achievement.patterns", std::move(unlocalizedName)) { } + explicit AchievementPatterns(UnlocalizedString unlocalizedName) : Achievement("hex.builtin.achievement.patterns", std::move(unlocalizedName)) { } }; class AchievementDataProcessor : public Achievement { public: - explicit AchievementDataProcessor(std::string unlocalizedName) : Achievement("hex.builtin.achievement.data_processor", std::move(unlocalizedName)) { } + explicit AchievementDataProcessor(UnlocalizedString unlocalizedName) : Achievement("hex.builtin.achievement.data_processor", std::move(unlocalizedName)) { } }; class AchievementFind : public Achievement { public: - explicit AchievementFind(std::string unlocalizedName) : Achievement("hex.builtin.achievement.find", std::move(unlocalizedName)) { } + explicit AchievementFind(UnlocalizedString unlocalizedName) : Achievement("hex.builtin.achievement.find", std::move(unlocalizedName)) { } }; class AchievementMisc : public Achievement { public: - explicit AchievementMisc(std::string unlocalizedName) : Achievement("hex.builtin.achievement.misc", std::move(unlocalizedName)) { } + explicit AchievementMisc(UnlocalizedString unlocalizedName) : Achievement("hex.builtin.achievement.misc", std::move(unlocalizedName)) { } }; void registerGettingStartedAchievements() { diff --git a/plugins/builtin/source/content/background_services.cpp b/plugins/builtin/source/content/background_services.cpp index 22588ed8d..471489095 100644 --- a/plugins/builtin/source/content/background_services.cpp +++ b/plugins/builtin/source/content/background_services.cpp @@ -91,8 +91,8 @@ namespace hex::plugin::builtin { autoBackupTime = ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.auto_backup_time", 0).get() * 30; }); - ContentRegistry::BackgroundServices::registerService("hex.builtin.background_service.network_interface"_lang, handleNetworkInterfaceService); - ContentRegistry::BackgroundServices::registerService("hex.builtin.background_service.auto_backup"_lang, handleAutoBackup); + ContentRegistry::BackgroundServices::registerService("hex.builtin.background_service.network_interface", handleNetworkInterfaceService); + ContentRegistry::BackgroundServices::registerService("hex.builtin.background_service.auto_backup", handleAutoBackup); } } \ No newline at end of file diff --git a/plugins/builtin/source/content/main_menu_items.cpp b/plugins/builtin/source/content/main_menu_items.cpp index 4faa9d3d0..b42e21fe1 100644 --- a/plugins/builtin/source/content/main_menu_items.cpp +++ b/plugins/builtin/source/content/main_menu_items.cpp @@ -542,14 +542,14 @@ namespace hex::plugin::builtin { ContentRegistry::Interface::registerMainMenuItem("hex.builtin.menu.workspace", 4000); ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.workspace", "hex.builtin.menu.workspace.layout", "hex.builtin.menu.workspace.layout.save" }, 1100, Shortcut::None, [] { - PopupTextInput::open("hex.builtin.popup.save_layout.title"_lang, "hex.builtin.popup.save_layout.desc"_lang, [](const std::string &name) { + PopupTextInput::open("hex.builtin.popup.save_layout.title", "hex.builtin.popup.save_layout.desc", [](const std::string &name) { LayoutManager::save(name); }); }, ImHexApi::Provider::isValid); ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.workspace", "hex.builtin.menu.workspace.layout" }, 1150, [] { bool locked = LayoutManager::isLayoutLocked(); - if (ImGui::MenuItem("hex.builtin.menu.workspace.layout.lock"_lang, nullptr, &locked, ImHexApi::Provider::isValid())) { + if (ImGui::MenuItem("hex.builtin.menu.workspace.layout.lock", nullptr, &locked, ImHexApi::Provider::isValid())) { LayoutManager::lockLayout(locked); ContentRegistry::Settings::write("hex.builtin.setting.interface", "hex.builtin.setting.interface.layout_locked", locked); } @@ -584,7 +584,7 @@ namespace hex::plugin::builtin { ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.workspace" }, 3000); ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.workspace", "hex.builtin.menu.workspace.create" }, 3100, Shortcut::None, [] { - PopupTextInput::open("hex.builtin.popup.create_workspace.title"_lang, "hex.builtin.popup.create_workspace.desc"_lang, [](const std::string &name) { + PopupTextInput::open("hex.builtin.popup.create_workspace.title", "hex.builtin.popup.create_workspace.desc", [](const std::string &name) { WorkspaceManager::createWorkspace(name); }); }, ImHexApi::Provider::isValid); diff --git a/plugins/builtin/source/content/providers/memory_file_provider.cpp b/plugins/builtin/source/content/providers/memory_file_provider.cpp index b8c6d917d..faa571498 100644 --- a/plugins/builtin/source/content/providers/memory_file_provider.cpp +++ b/plugins/builtin/source/content/providers/memory_file_provider.cpp @@ -146,7 +146,7 @@ namespace hex::plugin::builtin { } void MemoryFileProvider::renameFile() { - PopupTextInput::open("hex.builtin.provider.mem_file.rename"_lang, "hex.builtin.provider.mem_file.rename.desc"_lang, [this](const std::string &name) { + PopupTextInput::open("hex.builtin.provider.mem_file.rename", "hex.builtin.provider.mem_file.rename.desc", [this](const std::string &name) { this->m_name = name; RequestUpdateWindowTitle::post(); }); diff --git a/plugins/builtin/source/content/recent.cpp b/plugins/builtin/source/content/recent.cpp index 74760eefc..35823773b 100644 --- a/plugins/builtin/source/content/recent.cpp +++ b/plugins/builtin/source/content/recent.cpp @@ -37,7 +37,7 @@ namespace hex::plugin::builtin::recent { std::fs::path path; }; public: - PopupAutoBackups() : Popup("hex.builtin.welcome.start.recent.auto_backups"_lang, true, true) { + PopupAutoBackups() : Popup("hex.builtin.welcome.start.recent.auto_backups", true, true) { for (const auto &backupPath : fs::getDefaultPaths(fs::ImHexPath::Backups)) { for (const auto &entry : std::fs::directory_iterator(backupPath)) { if (entry.is_regular_file() && entry.path().extension() == ".hexproj") { diff --git a/plugins/builtin/source/content/tutorials/introduction.cpp b/plugins/builtin/source/content/tutorials/introduction.cpp index 5c5ae0212..fa6951bfc 100644 --- a/plugins/builtin/source/content/tutorials/introduction.cpp +++ b/plugins/builtin/source/content/tutorials/introduction.cpp @@ -92,7 +92,7 @@ namespace hex::plugin::builtin { }) .onAppear([&step] { EventViewOpened::subscribe([&step](View *view){ - if (view->getUnlocalizedName() == "hex.builtin.view.tutorials.name") + if (view->getUnlocalizedName() == UnlocalizedString("hex.builtin.view.tutorials.name")) step.complete(); }); }) diff --git a/plugins/builtin/source/content/views/view_data_processor.cpp b/plugins/builtin/source/content/views/view_data_processor.cpp index e927434b1..91bd4487e 100644 --- a/plugins/builtin/source/content/views/view_data_processor.cpp +++ b/plugins/builtin/source/content/views/view_data_processor.cpp @@ -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 { Lang(nodeJson.at("name")), nodeJson }); + this->m_customNodes.push_back(CustomNode { Lang(nodeJson.at("name").get()), nodeJson }); } catch (nlohmann::json::exception &e) { log::warn("Failed to load custom node '{}': {}", entry.path().string(), e.what()); } @@ -1077,7 +1077,7 @@ namespace hex::plugin::builtin { std::unique_ptr newNode; for (auto &entry : nodeEntries) { - if (data.contains("name") && entry.name == data["type"].get()) + if (data.contains("name") && entry.unlocalizedName == data["type"].get()) newNode = entry.creatorFunction(); } diff --git a/plugins/builtin/source/content/views/view_hashes.cpp b/plugins/builtin/source/content/views/view_hashes.cpp index 4b7f9fd1d..f8713b2c2 100644 --- a/plugins/builtin/source/content/views/view_hashes.cpp +++ b/plugins/builtin/source/content/views/view_hashes.cpp @@ -19,7 +19,7 @@ namespace hex::plugin::builtin { m_hash(hash) { } void drawContent() override { - ImGuiExt::Header(this->getUnlocalizedName().c_str(), true); + ImGuiExt::Header(this->getUnlocalizedName(), true); ImGui::PushItemWidth(-1); if (ImGui::InputTextMultiline("##input", this->m_input)) { diff --git a/plugins/builtin/source/content/views/view_hex_editor.cpp b/plugins/builtin/source/content/views/view_hex_editor.cpp index 03cdfe325..fa6432abb 100644 --- a/plugins/builtin/source/content/views/view_hex_editor.cpp +++ b/plugins/builtin/source/content/views/view_hex_editor.cpp @@ -1044,7 +1044,7 @@ namespace hex::plugin::builtin { ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 1300); /* Save */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.hex_editor.menu.file.save"_lang }, 1350, + ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.hex_editor.menu.file.save" }, 1350, CTRLCMD + Keys::S, save, [] { @@ -1055,7 +1055,7 @@ namespace hex::plugin::builtin { }); /* Save As */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.hex_editor.menu.file.save_as"_lang }, 1375, + ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.hex_editor.menu.file.save_as" }, 1375, CTRLCMD + SHIFT + Keys::S, saveAs, [] { diff --git a/plugins/builtin/source/content/views/view_settings.cpp b/plugins/builtin/source/content/views/view_settings.cpp index 7cb860507..524ba9d13 100644 --- a/plugins/builtin/source/content/views/view_settings.cpp +++ b/plugins/builtin/source/content/views/view_settings.cpp @@ -21,7 +21,7 @@ namespace hex::plugin::builtin { // Add the settings menu item to the Extras menu ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.extras" }, 3000); - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.extras", "hex.builtin.view.settings.name"_lang }, 4000, Shortcut::None, [&, this] { + ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.extras", "hex.builtin.view.settings.name" }, 4000, Shortcut::None, [&, this] { this->getWindowOpenState() = true; }); } @@ -80,7 +80,7 @@ namespace hex::plugin::builtin { ContentRegistry::Settings::write(category.unlocalizedName, setting.unlocalizedName, newValue); // Print a debug message - log::debug("Setting [{} / {}]: Value was changed to {}", category.unlocalizedName, setting.unlocalizedName, nlohmann::to_string(newValue)); + log::debug("Setting [{} / {}]: Value was changed to {}", category.unlocalizedName.get(), setting.unlocalizedName.get(), nlohmann::to_string(newValue)); // Signal that the setting was changed EventSettingsChanged::post(); diff --git a/plugins/builtin/source/content/views/view_store.cpp b/plugins/builtin/source/content/views/view_store.cpp index 6d2505fed..4a5781b37 100644 --- a/plugins/builtin/source/content/views/view_store.cpp +++ b/plugins/builtin/source/content/views/view_store.cpp @@ -37,20 +37,20 @@ namespace hex::plugin::builtin { this->m_httpRequest.setTimeout(30'0000); - addCategory("hex.builtin.view.store.tab.patterns"_lang, "patterns", fs::ImHexPath::Patterns); - addCategory("hex.builtin.view.store.tab.includes"_lang, "includes", fs::ImHexPath::PatternsInclude); - addCategory("hex.builtin.view.store.tab.magic"_lang, "magic", fs::ImHexPath::Magic, []{ + addCategory("hex.builtin.view.store.tab.patterns", "patterns", fs::ImHexPath::Patterns); + addCategory("hex.builtin.view.store.tab.includes", "includes", fs::ImHexPath::PatternsInclude); + addCategory("hex.builtin.view.store.tab.magic", "magic", fs::ImHexPath::Magic, []{ magic::compile(); }); - addCategory("hex.builtin.view.store.tab.nodes"_lang, "nodes", fs::ImHexPath::Nodes); - addCategory("hex.builtin.view.store.tab.encodings"_lang, "encodings", fs::ImHexPath::Encodings); - addCategory("hex.builtin.view.store.tab.constants"_lang, "constants", fs::ImHexPath::Constants); - addCategory("hex.builtin.view.store.tab.themes"_lang, "themes", fs::ImHexPath::Themes, [this]{ + addCategory("hex.builtin.view.store.tab.nodes", "nodes", fs::ImHexPath::Nodes); + addCategory("hex.builtin.view.store.tab.encodings", "encodings", fs::ImHexPath::Encodings); + addCategory("hex.builtin.view.store.tab.constants", "constants", fs::ImHexPath::Constants); + addCategory("hex.builtin.view.store.tab.themes", "themes", fs::ImHexPath::Themes, [this]{ auto themeFile = wolv::io::File(this->m_downloadPath, wolv::io::File::Mode::Read); ThemeManager::addTheme(themeFile.readString()); }); - addCategory("hex.builtin.view.store.tab.yara"_lang, "yara", fs::ImHexPath::Yara); + addCategory("hex.builtin.view.store.tab.yara", "yara", fs::ImHexPath::Yara); } @@ -333,7 +333,7 @@ namespace hex::plugin::builtin { return removed; } - void ViewStore::addCategory(const std::string &unlocalizedName, const std::string &requestName, fs::ImHexPath path, std::function downloadCallback) { + void ViewStore::addCategory(const UnlocalizedString &unlocalizedName, const std::string &requestName, fs::ImHexPath path, std::function downloadCallback) { this->m_categories.push_back({ unlocalizedName, requestName, path, { }, std::move(downloadCallback) }); }