refactor: Make sure unlocalized strings are always actually unlocalized
This commit is contained in:
parent
8fe490ed03
commit
dd4be3b772
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <hex/ui/imgui_imhex_extensions.h>
|
#include <hex/ui/imgui_imhex_extensions.h>
|
||||||
|
#include <hex/api/localization_manager.hpp>
|
||||||
|
|
||||||
namespace hex {
|
namespace hex {
|
||||||
|
|
||||||
@ -20,13 +21,13 @@ namespace hex {
|
|||||||
|
|
||||||
class Achievement {
|
class Achievement {
|
||||||
public:
|
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
|
* @brief Returns the unlocalized name of the achievement
|
||||||
* @return 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;
|
return this->m_unlocalizedName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ namespace hex {
|
|||||||
* @brief Returns the unlocalized category of the achievement
|
* @brief Returns the unlocalized category of the achievement
|
||||||
* @return 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;
|
return this->m_unlocalizedCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +136,7 @@ namespace hex {
|
|||||||
* @brief Returns the unlocalized description of the achievement
|
* @brief Returns the unlocalized description of the achievement
|
||||||
* @return 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;
|
return this->m_unlocalizedDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,8 +274,8 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_unlocalizedCategory, m_unlocalizedName;
|
UnlocalizedString m_unlocalizedCategory, m_unlocalizedName;
|
||||||
std::string m_unlocalizedDescription;
|
UnlocalizedString m_unlocalizedDescription;
|
||||||
|
|
||||||
bool m_blacked = false;
|
bool m_blacked = false;
|
||||||
bool m_invisible = false;
|
bool m_invisible = false;
|
||||||
@ -364,7 +365,7 @@ namespace hex {
|
|||||||
* @param unlocalizedCategory Unlocalized category of the achievement
|
* @param unlocalizedCategory Unlocalized category of the achievement
|
||||||
* @param unlocalizedName Unlocalized name 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
|
* @brief Returns all registered achievements
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <hex.hpp>
|
#include <hex.hpp>
|
||||||
|
#include <hex/api/localization_manager.hpp>
|
||||||
#include <hex/helpers/concepts.hpp>
|
#include <hex/helpers/concepts.hpp>
|
||||||
|
|
||||||
#include <pl/pattern_language.hpp>
|
#include <pl/pattern_language.hpp>
|
||||||
@ -254,18 +255,18 @@ namespace hex {
|
|||||||
namespace impl {
|
namespace impl {
|
||||||
|
|
||||||
struct Entry {
|
struct Entry {
|
||||||
std::string unlocalizedName;
|
UnlocalizedString unlocalizedName;
|
||||||
std::unique_ptr<Widgets::Widget> widget;
|
std::unique_ptr<Widgets::Widget> widget;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SubCategory {
|
struct SubCategory {
|
||||||
std::string unlocalizedName;
|
UnlocalizedString unlocalizedName;
|
||||||
std::vector<Entry> entries;
|
std::vector<Entry> entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Category {
|
struct Category {
|
||||||
std::string unlocalizedName;
|
UnlocalizedString unlocalizedName;
|
||||||
std::string unlocalizedDescription;
|
UnlocalizedString unlocalizedDescription;
|
||||||
std::vector<SubCategory> subCategories;
|
std::vector<SubCategory> subCategories;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -274,14 +275,14 @@ namespace hex {
|
|||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
std::vector<Category> &getSettings();
|
std::vector<Category> &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();
|
nlohmann::json &getSettingsData();
|
||||||
|
|
||||||
Widgets::Widget* add(const std::string &unlocalizedCategory, const std::string &unlocalizedSubCategory, const std::string &unlocalizedName, std::unique_ptr<Widgets::Widget> &&widget);
|
Widgets::Widget* add(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedSubCategory, const UnlocalizedString &unlocalizedName, std::unique_ptr<Widgets::Widget> &&widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<std::derived_from<Widgets::Widget> T>
|
template<std::derived_from<Widgets::Widget> 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(
|
return impl::add(
|
||||||
unlocalizedCategory,
|
unlocalizedCategory,
|
||||||
unlocalizedSubCategory,
|
unlocalizedSubCategory,
|
||||||
@ -290,10 +291,10 @@ namespace hex {
|
|||||||
)->getInterface();
|
)->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);
|
[[nodiscard]] nlohmann::json read(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const nlohmann::json &defaultValue);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Command Palette Command Registry. Allows adding of new commands to the command palette */
|
/* Command Palette Command Registry. Allows adding of new commands to the command palette */
|
||||||
@ -318,7 +319,7 @@ namespace hex {
|
|||||||
struct Entry {
|
struct Entry {
|
||||||
Type type;
|
Type type;
|
||||||
std::string command;
|
std::string command;
|
||||||
std::string unlocalizedDescription;
|
UnlocalizedString unlocalizedDescription;
|
||||||
DisplayCallback displayCallback;
|
DisplayCallback displayCallback;
|
||||||
ExecuteCallback executeCallback;
|
ExecuteCallback executeCallback;
|
||||||
};
|
};
|
||||||
@ -346,7 +347,7 @@ namespace hex {
|
|||||||
void add(
|
void add(
|
||||||
Type type,
|
Type type,
|
||||||
const std::string &command,
|
const std::string &command,
|
||||||
const std::string &unlocalizedDescription,
|
const UnlocalizedString &unlocalizedDescription,
|
||||||
const impl::DisplayCallback &displayCallback,
|
const impl::DisplayCallback &displayCallback,
|
||||||
const impl::ExecuteCallback &executeCallback = [](auto) {});
|
const impl::ExecuteCallback &executeCallback = [](auto) {});
|
||||||
|
|
||||||
@ -484,7 +485,7 @@ namespace hex {
|
|||||||
* @param unlocalizedName The unlocalized name of the view
|
* @param unlocalizedName The unlocalized name of the view
|
||||||
* @return The view if it exists, nullptr otherwise
|
* @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 */
|
/* 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 unlocalizedName The unlocalized name of the tool
|
||||||
* @param function The function that will be called to draw 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 */
|
/* Data Inspector Registry. Allows adding of new types to the data inspector */
|
||||||
@ -529,7 +530,7 @@ namespace hex {
|
|||||||
using GeneratorFunction = std::function<DisplayFunction(const std::vector<u8> &, std::endian, NumberDisplayStyle)>;
|
using GeneratorFunction = std::function<DisplayFunction(const std::vector<u8> &, std::endian, NumberDisplayStyle)>;
|
||||||
|
|
||||||
struct Entry {
|
struct Entry {
|
||||||
std::string unlocalizedName;
|
UnlocalizedString unlocalizedName;
|
||||||
size_t requiredSize;
|
size_t requiredSize;
|
||||||
size_t maxSize;
|
size_t maxSize;
|
||||||
GeneratorFunction generatorFunction;
|
GeneratorFunction generatorFunction;
|
||||||
@ -547,7 +548,7 @@ namespace hex {
|
|||||||
* @param displayGeneratorFunction The function that will be called to generate the display function
|
* @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
|
* @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<impl::EditingFunction> editingFunction = std::nullopt);
|
void add(const UnlocalizedString &unlocalizedName, size_t requiredSize, impl::GeneratorFunction displayGeneratorFunction, std::optional<impl::EditingFunction> editingFunction = std::nullopt);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Adds a new entry to the data inspector
|
* @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 displayGeneratorFunction The function that will be called to generate the display function
|
||||||
* @param editingFunction The function that will be called to edit the data
|
* @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<impl::EditingFunction> editingFunction = std::nullopt);
|
void add(const UnlocalizedString &unlocalizedName, size_t requiredSize, size_t maxSize, impl::GeneratorFunction displayGeneratorFunction, std::optional<impl::EditingFunction> editingFunction = std::nullopt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Data Processor Node Registry. Allows adding new processor nodes to be used in the data processor */
|
/* 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<std::unique_ptr<dp::Node>()>;
|
using CreatorFunction = std::function<std::unique_ptr<dp::Node>()>;
|
||||||
|
|
||||||
struct Entry {
|
struct Entry {
|
||||||
std::string category;
|
UnlocalizedString unlocalizedCategory;
|
||||||
std::string name;
|
UnlocalizedString unlocalizedName;
|
||||||
CreatorFunction creatorFunction;
|
CreatorFunction creatorFunction;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -588,10 +589,10 @@ namespace hex {
|
|||||||
* @param args Arguments passed to the constructor of the node
|
* @param args Arguments passed to the constructor of the node
|
||||||
*/
|
*/
|
||||||
template<std::derived_from<dp::Node> T, typename... Args>
|
template<std::derived_from<dp::Node> 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 {
|
add(impl::Entry {
|
||||||
unlocalizedCategory.c_str(),
|
unlocalizedCategory,
|
||||||
unlocalizedName.c_str(),
|
unlocalizedName,
|
||||||
[=, ...args = std::forward<Args>(args)] mutable {
|
[=, ...args = std::forward<Args>(args)] mutable {
|
||||||
auto node = std::make_unique<T>(std::forward<Args>(args)...);
|
auto node = std::make_unique<T>(std::forward<Args>(args)...);
|
||||||
node->setUnlocalizedName(unlocalizedName);
|
node->setUnlocalizedName(unlocalizedName);
|
||||||
@ -636,11 +637,11 @@ namespace hex {
|
|||||||
using ClickCallback = std::function<void()>;
|
using ClickCallback = std::function<void()>;
|
||||||
|
|
||||||
struct MainMenuItem {
|
struct MainMenuItem {
|
||||||
std::string unlocalizedName;
|
UnlocalizedString unlocalizedName;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MenuItem {
|
struct MenuItem {
|
||||||
std::vector<std::string> unlocalizedNames;
|
std::vector<UnlocalizedString> unlocalizedNames;
|
||||||
std::unique_ptr<Shortcut> shortcut;
|
std::unique_ptr<Shortcut> shortcut;
|
||||||
View *view;
|
View *view;
|
||||||
MenuCallback callback;
|
MenuCallback callback;
|
||||||
@ -655,7 +656,7 @@ namespace hex {
|
|||||||
|
|
||||||
struct TitleBarButton {
|
struct TitleBarButton {
|
||||||
std::string icon;
|
std::string icon;
|
||||||
std::string unlocalizedTooltip;
|
UnlocalizedString unlocalizedTooltip;
|
||||||
ClickCallback callback;
|
ClickCallback callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -678,7 +679,7 @@ namespace hex {
|
|||||||
* @param unlocalizedName The unlocalized name of the entry
|
* @param unlocalizedName The unlocalized name of the entry
|
||||||
* @param priority The priority of the entry. Lower values are displayed first
|
* @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
|
* @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 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
|
* @param view The view to use for the entry. If nullptr, the shortcut will work globally
|
||||||
*/
|
*/
|
||||||
void addMenuItem(const std::vector<std::string> &unlocalizedMainMenuNames, u32 priority, const Shortcut &shortcut, const impl::MenuCallback &function, const impl::EnabledCallback& enabledCallback = []{ return true; }, View *view = nullptr);
|
void addMenuItem(const std::vector<UnlocalizedString> &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
|
* @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 function The function to call when the entry is clicked
|
||||||
* @param enabledCallback The function to call to determine if the entry is enabled
|
* @param enabledCallback The function to call to determine if the entry is enabled
|
||||||
*/
|
*/
|
||||||
void addMenuItemSubMenu(std::vector<std::string> unlocalizedMainMenuNames, u32 priority, const impl::MenuCallback &function, const impl::EnabledCallback& enabledCallback = []{ return true; });
|
void addMenuItemSubMenu(std::vector<UnlocalizedString> unlocalizedMainMenuNames, u32 priority, const impl::MenuCallback &function, const impl::EnabledCallback& enabledCallback = []{ return true; });
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Adds a new main menu separator
|
* @brief Adds a new main menu separator
|
||||||
* @param unlocalizedMainMenuNames The unlocalized names of the main menu entries
|
* @param unlocalizedMainMenuNames The unlocalized names of the main menu entries
|
||||||
* @param priority The priority of the entry. Lower values are displayed first
|
* @param priority The priority of the entry. Lower values are displayed first
|
||||||
*/
|
*/
|
||||||
void addMenuItemSeparator(std::vector<std::string> unlocalizedMainMenuNames, u32 priority);
|
void addMenuItemSeparator(std::vector<UnlocalizedString> unlocalizedMainMenuNames, u32 priority);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -740,7 +741,7 @@ namespace hex {
|
|||||||
* @param unlocalizedTooltip The unlocalized tooltip to use for the button
|
* @param unlocalizedTooltip The unlocalized tooltip to use for the button
|
||||||
* @param function The function to call when the button is clicked
|
* @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 {
|
namespace impl {
|
||||||
|
|
||||||
void addProviderName(const std::string &unlocalizedName);
|
void addProviderName(const UnlocalizedString &unlocalizedName);
|
||||||
|
|
||||||
using ProviderCreationFunction = prv::Provider*(*)();
|
using ProviderCreationFunction = prv::Provider*(*)();
|
||||||
void add(const std::string &typeName, ProviderCreationFunction creationFunction);
|
void add(const std::string &typeName, ProviderCreationFunction creationFunction);
|
||||||
@ -784,7 +785,7 @@ namespace hex {
|
|||||||
|
|
||||||
using Callback = std::function<std::string(prv::Provider *provider, u64 address, size_t size)>;
|
using Callback = std::function<std::string(prv::Provider *provider, u64 address, size_t size)>;
|
||||||
struct Entry {
|
struct Entry {
|
||||||
std::string unlocalizedName;
|
UnlocalizedString unlocalizedName;
|
||||||
Callback callback;
|
Callback callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -798,7 +799,7 @@ namespace hex {
|
|||||||
* @param unlocalizedName The unlocalized name of the formatter
|
* @param unlocalizedName The unlocalized name of the formatter
|
||||||
* @param callback The function to call to format the data
|
* @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 {
|
class DataVisualizer {
|
||||||
public:
|
public:
|
||||||
DataVisualizer(std::string unlocalizedName, u16 bytesPerCell, u16 maxCharsPerCell)
|
DataVisualizer(UnlocalizedString unlocalizedName, u16 bytesPerCell, u16 maxCharsPerCell)
|
||||||
: m_unlocalizedName(std::move(unlocalizedName)),
|
: m_unlocalizedName(std::move(unlocalizedName)),
|
||||||
m_bytesPerCell(bytesPerCell),
|
m_bytesPerCell(bytesPerCell),
|
||||||
m_maxCharsPerCell(maxCharsPerCell) { }
|
m_maxCharsPerCell(maxCharsPerCell) { }
|
||||||
@ -844,7 +845,7 @@ namespace hex {
|
|||||||
[[nodiscard]] u16 getBytesPerCell() const { return this->m_bytesPerCell; }
|
[[nodiscard]] u16 getBytesPerCell() const { return this->m_bytesPerCell; }
|
||||||
[[nodiscard]] u16 getMaxCharsPerCell() const { return this->m_maxCharsPerCell; }
|
[[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:
|
protected:
|
||||||
const static int TextInputFlags;
|
const static int TextInputFlags;
|
||||||
@ -853,7 +854,7 @@ namespace hex {
|
|||||||
bool drawDefaultTextEditingTextBox(u64 address, std::string &data, ImGuiInputTextFlags flags) const;
|
bool drawDefaultTextEditingTextBox(u64 address, std::string &data, ImGuiInputTextFlags flags) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_unlocalizedName;
|
UnlocalizedString m_unlocalizedName;
|
||||||
u16 m_bytesPerCell;
|
u16 m_bytesPerCell;
|
||||||
u16 m_maxCharsPerCell;
|
u16 m_maxCharsPerCell;
|
||||||
};
|
};
|
||||||
@ -881,7 +882,7 @@ namespace hex {
|
|||||||
* @param unlocalizedName Unlocalized name of the data visualizer
|
* @param unlocalizedName Unlocalized name of the data visualizer
|
||||||
* @return The data visualizer, or nullptr if it doesn't exist
|
* @return The data visualizer, or nullptr if it doesn't exist
|
||||||
*/
|
*/
|
||||||
std::shared_ptr<DataVisualizer> getVisualizerByName(const std::string &unlocalizedName);
|
std::shared_ptr<DataVisualizer> getVisualizerByName(const UnlocalizedString &unlocalizedName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -890,7 +891,7 @@ namespace hex {
|
|||||||
|
|
||||||
class Hash {
|
class Hash {
|
||||||
public:
|
public:
|
||||||
explicit Hash(std::string unlocalizedName) : m_unlocalizedName(std::move(unlocalizedName)) {}
|
explicit Hash(UnlocalizedString unlocalizedName) : m_unlocalizedName(std::move(unlocalizedName)) {}
|
||||||
virtual ~Hash() = default;
|
virtual ~Hash() = default;
|
||||||
|
|
||||||
class Function {
|
class Function {
|
||||||
@ -932,7 +933,7 @@ namespace hex {
|
|||||||
[[nodiscard]] virtual nlohmann::json store() const = 0;
|
[[nodiscard]] virtual nlohmann::json store() const = 0;
|
||||||
virtual void load(const nlohmann::json &json) = 0;
|
virtual void load(const nlohmann::json &json) = 0;
|
||||||
|
|
||||||
[[nodiscard]] const std::string &getUnlocalizedName() const {
|
[[nodiscard]] const UnlocalizedString &getUnlocalizedName() const {
|
||||||
return this->m_unlocalizedName;
|
return this->m_unlocalizedName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -942,7 +943,7 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_unlocalizedName;
|
UnlocalizedString m_unlocalizedName;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace impl {
|
namespace impl {
|
||||||
@ -980,7 +981,7 @@ namespace hex {
|
|||||||
void stopServices();
|
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 */
|
/* Network Communication Interface Registry. Allows adding new communication interface endpoints */
|
||||||
@ -1002,14 +1003,14 @@ namespace hex {
|
|||||||
namespace impl {
|
namespace impl {
|
||||||
|
|
||||||
struct Experiment {
|
struct Experiment {
|
||||||
std::string unlocalizedName, unlocalizedDescription;
|
UnlocalizedString unlocalizedName, unlocalizedDescription;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<std::string, Experiment> &getExperiments();
|
std::map<std::string, Experiment> &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);
|
void enableExperiement(const std::string &experimentName, bool enabled);
|
||||||
|
|
||||||
[[nodiscard]] bool isExperimentEnabled(const std::string &experimentName);
|
[[nodiscard]] bool isExperimentEnabled(const std::string &experimentName);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <hex.hpp>
|
#include <hex.hpp>
|
||||||
|
#include <hex/api/localization_manager.hpp>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <span>
|
#include <span>
|
||||||
@ -338,7 +339,7 @@ namespace hex {
|
|||||||
* @param skipLoadInterface Whether to skip the provider's loading interface (see property documentation)
|
* @param skipLoadInterface Whether to skip the provider's loading interface (see property documentation)
|
||||||
* @param select Whether to select the provider after adding it
|
* @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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,10 +32,13 @@ namespace hex {
|
|||||||
[[nodiscard]] const std::string &getSelectedLanguage();
|
[[nodiscard]] const std::string &getSelectedLanguage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct UnlocalizedString;
|
||||||
|
|
||||||
class Lang {
|
class Lang {
|
||||||
public:
|
public:
|
||||||
explicit Lang(const char *unlocalizedString);
|
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);
|
explicit Lang(std::string_view unlocalizedString);
|
||||||
|
|
||||||
[[nodiscard]] operator std::string() const;
|
[[nodiscard]] operator std::string() const;
|
||||||
@ -60,6 +63,43 @@ namespace hex {
|
|||||||
return Lang(string);
|
return Lang(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct UnlocalizedString {
|
||||||
|
public:
|
||||||
|
UnlocalizedString() = default;
|
||||||
|
UnlocalizedString(auto && arg) : m_unlocalizedString(std::forward<decltype(arg)>(arg)) {
|
||||||
|
static_assert(!std::same_as<std::remove_cvref_t<decltype(arg)>, 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<>
|
template<>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <hex.hpp>
|
#include <hex.hpp>
|
||||||
#include <GLFW/glfw3.h>
|
#include <hex/api/localization_manager.hpp>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -9,6 +9,8 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
struct ImGuiWindow;
|
struct ImGuiWindow;
|
||||||
|
|
||||||
namespace hex {
|
namespace hex {
|
||||||
@ -391,7 +393,7 @@ namespace hex {
|
|||||||
using Callback = std::function<void()>;
|
using Callback = std::function<void()>;
|
||||||
struct ShortcutEntry {
|
struct ShortcutEntry {
|
||||||
Shortcut shortcut;
|
Shortcut shortcut;
|
||||||
std::string unlocalizedName;
|
UnlocalizedString unlocalizedName;
|
||||||
Callback callback;
|
Callback callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -401,7 +403,7 @@ namespace hex {
|
|||||||
* @param unlocalizedName The unlocalized name of the shortcut
|
* @param unlocalizedName The unlocalized name of the shortcut
|
||||||
* @param callback The callback to call when the shortcut is triggered.
|
* @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.
|
* @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 unlocalizedName The unlocalized name of the shortcut
|
||||||
* @param callback The callback to call when the shortcut is triggered.
|
* @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);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <hex.hpp>
|
#include <hex.hpp>
|
||||||
|
#include <hex/api/localization_manager.hpp>
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
@ -23,7 +24,7 @@ namespace hex {
|
|||||||
class Task {
|
class Task {
|
||||||
public:
|
public:
|
||||||
Task() = default;
|
Task() = default;
|
||||||
Task(std::string unlocalizedName, u64 maxValue, bool background, std::function<void(Task &)> function);
|
Task(UnlocalizedString unlocalizedName, u64 maxValue, bool background, std::function<void(Task &)> function);
|
||||||
|
|
||||||
Task(const Task&) = delete;
|
Task(const Task&) = delete;
|
||||||
Task(Task &&other) noexcept;
|
Task(Task &&other) noexcept;
|
||||||
@ -64,7 +65,7 @@ namespace hex {
|
|||||||
void clearException();
|
void clearException();
|
||||||
[[nodiscard]] std::string getExceptionMessage() const;
|
[[nodiscard]] std::string getExceptionMessage() const;
|
||||||
|
|
||||||
[[nodiscard]] const std::string &getUnlocalizedName();
|
[[nodiscard]] const UnlocalizedString &getUnlocalizedName();
|
||||||
[[nodiscard]] u64 getValue() const;
|
[[nodiscard]] u64 getValue() const;
|
||||||
[[nodiscard]] u64 getMaxValue() const;
|
[[nodiscard]] u64 getMaxValue() const;
|
||||||
|
|
||||||
@ -76,7 +77,7 @@ namespace hex {
|
|||||||
private:
|
private:
|
||||||
mutable std::mutex m_mutex;
|
mutable std::mutex m_mutex;
|
||||||
|
|
||||||
std::string m_unlocalizedName;
|
UnlocalizedString m_unlocalizedName;
|
||||||
std::atomic<u64> m_currValue = 0, m_maxValue = 0;
|
std::atomic<u64> m_currValue = 0, m_maxValue = 0;
|
||||||
std::function<void()> m_interruptCallback;
|
std::function<void()> m_interruptCallback;
|
||||||
std::function<void(Task &)> m_function;
|
std::function<void(Task &)> m_function;
|
||||||
|
@ -24,7 +24,7 @@ namespace hex {
|
|||||||
|
|
||||||
struct Tutorial {
|
struct Tutorial {
|
||||||
Tutorial() = delete;
|
Tutorial() = delete;
|
||||||
Tutorial(const std::string &unlocalizedName, const std::string &unlocalizedDescription) :
|
Tutorial(const UnlocalizedString &unlocalizedName, const UnlocalizedString &unlocalizedDescription) :
|
||||||
m_unlocalizedName(unlocalizedName),
|
m_unlocalizedName(unlocalizedName),
|
||||||
m_unlocalizedDescription(unlocalizedDescription) { }
|
m_unlocalizedDescription(unlocalizedDescription) { }
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ namespace hex {
|
|||||||
* @param ids ID of the element to highlight
|
* @param ids ID of the element to highlight
|
||||||
* @return Current step
|
* @return Current step
|
||||||
*/
|
*/
|
||||||
Step& addHighlight(const std::string &unlocalizedText, std::initializer_list<std::variant<Lang, std::string, int>> &&ids);
|
Step& addHighlight(const UnlocalizedString &unlocalizedText, std::initializer_list<std::variant<Lang, std::string, int>> &&ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Adds a highlighting to a specific element
|
* @brief Adds a highlighting to a specific element
|
||||||
@ -53,7 +53,7 @@ namespace hex {
|
|||||||
* @param position Position of the message box
|
* @param position Position of the message box
|
||||||
* @return Current step
|
* @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
|
* @brief Allows this step to be skipped by clicking on the advance button
|
||||||
@ -78,14 +78,14 @@ namespace hex {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
struct Highlight {
|
struct Highlight {
|
||||||
std::string unlocalizedText;
|
UnlocalizedString unlocalizedText;
|
||||||
std::vector<std::variant<Lang, std::string, int>> highlightIds;
|
std::vector<std::variant<Lang, std::string, int>> highlightIds;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Message {
|
struct Message {
|
||||||
Position position;
|
Position position;
|
||||||
std::string unlocalizedTitle;
|
UnlocalizedString unlocalizedTitle;
|
||||||
std::string unlocalizedMessage;
|
UnlocalizedString unlocalizedMessage;
|
||||||
bool allowSkip;
|
bool allowSkip;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -105,16 +105,16 @@ namespace hex {
|
|||||||
|
|
||||||
Step& addStep();
|
Step& addStep();
|
||||||
|
|
||||||
const std::string& getUnlocalizedName() const { return this->m_unlocalizedName; }
|
const UnlocalizedString& getUnlocalizedName() const { return this->m_unlocalizedName; }
|
||||||
const std::string& getUnlocalizedDescription() const { return this->m_unlocalizedDescription; }
|
const UnlocalizedString& getUnlocalizedDescription() const { return this->m_unlocalizedDescription; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class TutorialManager;
|
friend class TutorialManager;
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
std::string m_unlocalizedName;
|
UnlocalizedString m_unlocalizedName;
|
||||||
std::string m_unlocalizedDescription;
|
UnlocalizedString m_unlocalizedDescription;
|
||||||
std::list<Step> m_steps;
|
std::list<Step> m_steps;
|
||||||
decltype(m_steps)::iterator m_currentStep, m_latestStep;
|
decltype(m_steps)::iterator m_currentStep, m_latestStep;
|
||||||
};
|
};
|
||||||
@ -137,13 +137,13 @@ namespace hex {
|
|||||||
* @param unlocalizedDescription
|
* @param unlocalizedDescription
|
||||||
* @return Reference to created tutorial
|
* @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
|
* @brief Starts the tutorial with the given name
|
||||||
* @param unlocalizedName Name of tutorial to start
|
* @param unlocalizedName Name of tutorial to start
|
||||||
*/
|
*/
|
||||||
static void startTutorial(const std::string &unlocalizedName);
|
static void startTutorial(const UnlocalizedString &unlocalizedName);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <hex.hpp>
|
#include <hex.hpp>
|
||||||
|
#include <hex/api/localization_manager.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
@ -23,7 +25,7 @@ namespace hex::dp {
|
|||||||
Out
|
Out
|
||||||
};
|
};
|
||||||
|
|
||||||
Attribute(IOType ioType, Type type, std::string unlocalizedName);
|
Attribute(IOType ioType, Type type, UnlocalizedString unlocalizedName);
|
||||||
~Attribute();
|
~Attribute();
|
||||||
|
|
||||||
[[nodiscard]] int getId() const { return this->m_id; }
|
[[nodiscard]] int getId() const { return this->m_id; }
|
||||||
@ -31,7 +33,7 @@ namespace hex::dp {
|
|||||||
|
|
||||||
[[nodiscard]] IOType getIOType() const { return this->m_ioType; }
|
[[nodiscard]] IOType getIOType() const { return this->m_ioType; }
|
||||||
[[nodiscard]] Type getType() const { return this->m_type; }
|
[[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 addConnectedAttribute(int linkId, Attribute *to) { this->m_connectedAttributes.insert({ linkId, to }); }
|
||||||
void removeConnectedAttribute(int linkId) { this->m_connectedAttributes.erase(linkId); }
|
void removeConnectedAttribute(int linkId) { this->m_connectedAttributes.erase(linkId); }
|
||||||
@ -56,7 +58,7 @@ namespace hex::dp {
|
|||||||
int m_id;
|
int m_id;
|
||||||
IOType m_ioType;
|
IOType m_ioType;
|
||||||
Type m_type;
|
Type m_type;
|
||||||
std::string m_unlocalizedName;
|
UnlocalizedString m_unlocalizedName;
|
||||||
std::map<int, Attribute *> m_connectedAttributes;
|
std::map<int, Attribute *> m_connectedAttributes;
|
||||||
Node *m_parentNode = nullptr;
|
Node *m_parentNode = nullptr;
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <hex.hpp>
|
#include <hex.hpp>
|
||||||
|
#include <hex/api/localization_manager.hpp>
|
||||||
|
|
||||||
#include <hex/helpers/intrinsics.hpp>
|
#include <hex/helpers/intrinsics.hpp>
|
||||||
#include <hex/data_processor/attribute.hpp>
|
#include <hex/data_processor/attribute.hpp>
|
||||||
@ -21,17 +22,17 @@ namespace hex::dp {
|
|||||||
|
|
||||||
class Node {
|
class Node {
|
||||||
public:
|
public:
|
||||||
Node(std::string unlocalizedTitle, std::vector<Attribute> attributes);
|
Node(UnlocalizedString unlocalizedTitle, std::vector<Attribute> attributes);
|
||||||
|
|
||||||
virtual ~Node() = default;
|
virtual ~Node() = default;
|
||||||
|
|
||||||
[[nodiscard]] int getId() const { return this->m_id; }
|
[[nodiscard]] int getId() const { return this->m_id; }
|
||||||
void setId(int id) { this->m_id = id; }
|
void setId(int id) { this->m_id = id; }
|
||||||
|
|
||||||
[[nodiscard]] const std::string &getUnlocalizedName() const { return this->m_unlocalizedName; }
|
[[nodiscard]] const UnlocalizedString &getUnlocalizedName() const { return this->m_unlocalizedName; }
|
||||||
void setUnlocalizedName(const std::string &unlocalizedName) { this->m_unlocalizedName = 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); }
|
void setUnlocalizedTitle(std::string title) { this->m_unlocalizedTitle = std::move(title); }
|
||||||
|
|
||||||
[[nodiscard]] std::vector<Attribute> &getAttributes() { return this->m_attributes; }
|
[[nodiscard]] std::vector<Attribute> &getAttributes() { return this->m_attributes; }
|
||||||
@ -81,7 +82,7 @@ namespace hex::dp {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int m_id;
|
int m_id;
|
||||||
std::string m_unlocalizedTitle, m_unlocalizedName;
|
UnlocalizedString m_unlocalizedTitle, m_unlocalizedName;
|
||||||
std::vector<Attribute> m_attributes;
|
std::vector<Attribute> m_attributes;
|
||||||
std::set<u32> m_processedInputs;
|
std::set<u32> m_processedInputs;
|
||||||
prv::Overlay *m_overlay = nullptr;
|
prv::Overlay *m_overlay = nullptr;
|
||||||
|
@ -10,7 +10,7 @@ namespace hex::prv::undo {
|
|||||||
|
|
||||||
class OperationGroup : public Operation {
|
class OperationGroup : public Operation {
|
||||||
public:
|
public:
|
||||||
explicit OperationGroup(std::string unlocalizedName) : m_unlocalizedName(std::move(unlocalizedName)) {}
|
explicit OperationGroup(UnlocalizedString unlocalizedName) : m_unlocalizedName(std::move(unlocalizedName)) {}
|
||||||
|
|
||||||
OperationGroup(const OperationGroup &other) {
|
OperationGroup(const OperationGroup &other) {
|
||||||
for (const auto &operation : other.m_operations)
|
for (const auto &operation : other.m_operations)
|
||||||
@ -59,7 +59,7 @@ namespace hex::prv::undo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_unlocalizedName;
|
UnlocalizedString m_unlocalizedName;
|
||||||
std::vector<std::unique_ptr<Operation>> m_operations;
|
std::vector<std::unique_ptr<Operation>> m_operations;
|
||||||
|
|
||||||
u64 m_startAddress = std::numeric_limits<u64>::max();
|
u64 m_startAddress = std::numeric_limits<u64>::max();
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <hex.hpp>
|
#include <hex.hpp>
|
||||||
|
#include <hex/api/localization_manager.hpp>
|
||||||
|
|
||||||
#include <hex/providers/undo_redo/operations/operation.hpp>
|
#include <hex/providers/undo_redo/operations/operation.hpp>
|
||||||
|
|
||||||
#include <atomic>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
@ -24,7 +25,7 @@ namespace hex::prv::undo {
|
|||||||
void undo(u32 count = 1);
|
void undo(u32 count = 1);
|
||||||
void redo(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);
|
void apply(const Stack &otherStack);
|
||||||
|
|
||||||
[[nodiscard]] bool canUndo() const;
|
[[nodiscard]] bool canUndo() const;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <hex.hpp>
|
#include <hex.hpp>
|
||||||
|
#include <hex/api/localization_manager.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -17,7 +18,7 @@ namespace hex {
|
|||||||
|
|
||||||
class PopupBase {
|
class PopupBase {
|
||||||
public:
|
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) { }
|
: m_unlocalizedName(std::move(unlocalizedName)), m_closeButton(closeButton), m_modal(modal) { }
|
||||||
|
|
||||||
virtual ~PopupBase() = default;
|
virtual ~PopupBase() = default;
|
||||||
@ -35,7 +36,7 @@ namespace hex {
|
|||||||
|
|
||||||
[[nodiscard]] static std::vector<std::unique_ptr<PopupBase>> &getOpenPopups();
|
[[nodiscard]] static std::vector<std::unique_ptr<PopupBase>> &getOpenPopups();
|
||||||
|
|
||||||
[[nodiscard]] const std::string &getUnlocalizedName() const {
|
[[nodiscard]] const UnlocalizedString &getUnlocalizedName() const {
|
||||||
return this->m_unlocalizedName;
|
return this->m_unlocalizedName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ namespace hex {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string m_unlocalizedName;
|
UnlocalizedString m_unlocalizedName;
|
||||||
bool m_closeButton, m_modal;
|
bool m_closeButton, m_modal;
|
||||||
std::atomic<bool> m_close = false;
|
std::atomic<bool> m_close = false;
|
||||||
};
|
};
|
||||||
@ -68,7 +69,7 @@ namespace hex {
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
class Popup : public impl::PopupBase {
|
class Popup : public impl::PopupBase {
|
||||||
protected:
|
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:
|
public:
|
||||||
template<typename ...Args>
|
template<typename ...Args>
|
||||||
|
@ -11,11 +11,12 @@
|
|||||||
#include <hex/api/imhex_api.hpp>
|
#include <hex/api/imhex_api.hpp>
|
||||||
#include <hex/api/shortcut_manager.hpp>
|
#include <hex/api/shortcut_manager.hpp>
|
||||||
#include <hex/api/event_manager.hpp>
|
#include <hex/api/event_manager.hpp>
|
||||||
|
#include <hex/api/localization_manager.hpp>
|
||||||
|
|
||||||
#include <hex/providers/provider.hpp>
|
#include <hex/providers/provider.hpp>
|
||||||
#include <hex/providers/provider_data.hpp>
|
#include <hex/providers/provider_data.hpp>
|
||||||
#include <hex/helpers/utils.hpp>
|
#include <hex/helpers/utils.hpp>
|
||||||
|
|
||||||
#include <hex/api/localization_manager.hpp>
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -23,7 +24,7 @@
|
|||||||
namespace hex {
|
namespace hex {
|
||||||
|
|
||||||
class View {
|
class View {
|
||||||
explicit View(std::string unlocalizedName);
|
explicit View(UnlocalizedString unlocalizedName);
|
||||||
public:
|
public:
|
||||||
virtual ~View() = default;
|
virtual ~View() = default;
|
||||||
|
|
||||||
@ -86,7 +87,7 @@ namespace hex {
|
|||||||
[[nodiscard]] bool &getWindowOpenState();
|
[[nodiscard]] bool &getWindowOpenState();
|
||||||
[[nodiscard]] const bool &getWindowOpenState() const;
|
[[nodiscard]] const bool &getWindowOpenState() const;
|
||||||
|
|
||||||
[[nodiscard]] const std::string &getUnlocalizedName() const;
|
[[nodiscard]] const UnlocalizedString &getUnlocalizedName() const;
|
||||||
[[nodiscard]] std::string getName() const;
|
[[nodiscard]] std::string getName() const;
|
||||||
|
|
||||||
[[nodiscard]] bool didWindowJustOpen();
|
[[nodiscard]] bool didWindowJustOpen();
|
||||||
@ -96,7 +97,7 @@ namespace hex {
|
|||||||
|
|
||||||
static void discardNavigationRequests();
|
static void discardNavigationRequests();
|
||||||
|
|
||||||
[[nodiscard]] static std::string toWindowName(const std::string &unlocalizedName);
|
[[nodiscard]] static std::string toWindowName(const UnlocalizedString &unlocalizedName);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class Window;
|
class Window;
|
||||||
@ -105,7 +106,7 @@ namespace hex {
|
|||||||
class Modal;
|
class Modal;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_unlocalizedViewName;
|
UnlocalizedString m_unlocalizedViewName;
|
||||||
bool m_windowOpen = false, m_prevWindowOpen = false;
|
bool m_windowOpen = false, m_prevWindowOpen = false;
|
||||||
std::map<Shortcut, ShortcutManager::ShortcutEntry> m_shortcuts;
|
std::map<Shortcut, ShortcutManager::ShortcutEntry> m_shortcuts;
|
||||||
bool m_windowJustOpened = false;
|
bool m_windowJustOpened = false;
|
||||||
@ -119,7 +120,7 @@ namespace hex {
|
|||||||
*/
|
*/
|
||||||
class View::Window : public View {
|
class View::Window : public View {
|
||||||
public:
|
public:
|
||||||
explicit Window(std::string unlocalizedName) : View(std::move(unlocalizedName)) {}
|
explicit Window(UnlocalizedString unlocalizedName) : View(std::move(unlocalizedName)) {}
|
||||||
|
|
||||||
void draw() final {
|
void draw() final {
|
||||||
if (this->shouldDraw()) {
|
if (this->shouldDraw()) {
|
||||||
@ -138,7 +139,7 @@ namespace hex {
|
|||||||
*/
|
*/
|
||||||
class View::Special : public View {
|
class View::Special : public View {
|
||||||
public:
|
public:
|
||||||
explicit Special(std::string unlocalizedName) : View(std::move(unlocalizedName)) {}
|
explicit Special(UnlocalizedString unlocalizedName) : View(std::move(unlocalizedName)) {}
|
||||||
|
|
||||||
void draw() final {
|
void draw() final {
|
||||||
if (this->shouldDraw()) {
|
if (this->shouldDraw()) {
|
||||||
@ -153,7 +154,7 @@ namespace hex {
|
|||||||
*/
|
*/
|
||||||
class View::Floating : public View::Window {
|
class View::Floating : public View::Window {
|
||||||
public:
|
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; }
|
[[nodiscard]] ImGuiWindowFlags getWindowFlags() const override { return ImGuiWindowFlags_NoDocking; }
|
||||||
};
|
};
|
||||||
@ -163,7 +164,7 @@ namespace hex {
|
|||||||
*/
|
*/
|
||||||
class View::Modal : public View {
|
class View::Modal : public View {
|
||||||
public:
|
public:
|
||||||
explicit Modal(std::string unlocalizedName) : View(std::move(unlocalizedName)) {}
|
explicit Modal(UnlocalizedString unlocalizedName) : View(std::move(unlocalizedName)) {}
|
||||||
|
|
||||||
void draw() final {
|
void draw() final {
|
||||||
if (this->shouldDraw()) {
|
if (this->shouldDraw()) {
|
||||||
|
@ -87,7 +87,7 @@ namespace hex {
|
|||||||
return startNodes;
|
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 &categories = getAchievements();
|
||||||
|
|
||||||
auto categoryIter = categories.find(unlocalizedCategory);
|
auto categoryIter = categories.find(unlocalizedCategory);
|
||||||
|
@ -28,7 +28,7 @@ namespace hex {
|
|||||||
|
|
||||||
namespace impl {
|
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();
|
auto &settings = getSettingsData();
|
||||||
|
|
||||||
if (!settings.contains(unlocalizedCategory))
|
if (!settings.contains(unlocalizedCategory))
|
||||||
@ -113,7 +113,7 @@ namespace hex {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static T* insertOrGetEntry(std::vector<T> &vector, const std::string &unlocalizedName) {
|
static T* insertOrGetEntry(std::vector<T> &vector, const UnlocalizedString &unlocalizedName) {
|
||||||
T *foundEntry = nullptr;
|
T *foundEntry = nullptr;
|
||||||
for (auto &entry : vector) {
|
for (auto &entry : vector) {
|
||||||
if (entry.unlocalizedName == unlocalizedName) {
|
if (entry.unlocalizedName == unlocalizedName) {
|
||||||
@ -138,7 +138,7 @@ namespace hex {
|
|||||||
return categories;
|
return categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widgets::Widget* add(const std::string &unlocalizedCategory, const std::string &unlocalizedSubCategory, const std::string &unlocalizedName, std::unique_ptr<Widgets::Widget> &&widget) {
|
Widgets::Widget* add(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedSubCategory, const UnlocalizedString &unlocalizedName, std::unique_ptr<Widgets::Widget> &&widget) {
|
||||||
const auto category = insertOrGetEntry(getSettings(), unlocalizedCategory);
|
const auto category = insertOrGetEntry(getSettings(), unlocalizedCategory);
|
||||||
const auto subCategory = insertOrGetEntry(category->subCategories, unlocalizedSubCategory);
|
const auto subCategory = insertOrGetEntry(category->subCategories, unlocalizedSubCategory);
|
||||||
const auto entry = insertOrGetEntry(subCategory->entries, unlocalizedName);
|
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);
|
const auto category = insertOrGetEntry(impl::getSettings(), unlocalizedCategory);
|
||||||
|
|
||||||
category->unlocalizedDescription = unlocalizedDescription;
|
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);
|
auto setting = impl::getSetting(unlocalizedCategory, unlocalizedName, defaultValue);
|
||||||
|
|
||||||
if (setting.is_number() && defaultValue.is_boolean())
|
if (setting.is_number() && defaultValue.is_boolean())
|
||||||
@ -169,7 +169,7 @@ namespace hex {
|
|||||||
return setting;
|
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;
|
impl::getSetting(unlocalizedCategory, unlocalizedName, value) = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,7 +391,7 @@ namespace hex {
|
|||||||
|
|
||||||
namespace ContentRegistry::CommandPaletteCommands {
|
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);
|
log::debug("Registered new command palette command: {}", command);
|
||||||
|
|
||||||
impl::getEntries().push_back(impl::Entry { type, command, unlocalizedDescription, displayCallback, executeCallback });
|
impl::getEntries().push_back(impl::Entry { type, command, unlocalizedDescription, displayCallback, executeCallback });
|
||||||
@ -561,12 +561,12 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void impl::add(std::unique_ptr<View> &&view) {
|
void impl::add(std::unique_ptr<View> &&view) {
|
||||||
log::debug("Registered new view: {}", view->getUnlocalizedName());
|
log::debug("Registered new view: {}", view->getUnlocalizedName().get());
|
||||||
|
|
||||||
getEntries().insert({ view->getUnlocalizedName(), std::move(view) });
|
getEntries().insert({ view->getUnlocalizedName(), std::move(view) });
|
||||||
}
|
}
|
||||||
|
|
||||||
View* getViewByName(const std::string &unlocalizedName) {
|
View* getViewByName(const UnlocalizedString &unlocalizedName) {
|
||||||
auto &views = impl::getEntries();
|
auto &views = impl::getEntries();
|
||||||
|
|
||||||
if (views.contains(unlocalizedName))
|
if (views.contains(unlocalizedName))
|
||||||
@ -579,8 +579,8 @@ namespace hex {
|
|||||||
|
|
||||||
namespace ContentRegistry::Tools {
|
namespace ContentRegistry::Tools {
|
||||||
|
|
||||||
void add(const std::string &unlocalizedName, const impl::Callback &function) {
|
void add(const UnlocalizedString &unlocalizedName, const impl::Callback &function) {
|
||||||
log::debug("Registered new tool: {}", unlocalizedName);
|
log::debug("Registered new tool: {}", unlocalizedName.get());
|
||||||
|
|
||||||
impl::getEntries().emplace_back(impl::Entry { unlocalizedName, function, false });
|
impl::getEntries().emplace_back(impl::Entry { unlocalizedName, function, false });
|
||||||
}
|
}
|
||||||
@ -599,14 +599,14 @@ namespace hex {
|
|||||||
|
|
||||||
namespace ContentRegistry::DataInspector {
|
namespace ContentRegistry::DataInspector {
|
||||||
|
|
||||||
void add(const std::string &unlocalizedName, size_t requiredSize, impl::GeneratorFunction displayGeneratorFunction, std::optional<impl::EditingFunction> editingFunction) {
|
void add(const UnlocalizedString &unlocalizedName, size_t requiredSize, impl::GeneratorFunction displayGeneratorFunction, std::optional<impl::EditingFunction> editingFunction) {
|
||||||
log::debug("Registered new data inspector format: {}", unlocalizedName);
|
log::debug("Registered new data inspector format: {}", unlocalizedName.get());
|
||||||
|
|
||||||
impl::getEntries().push_back({ unlocalizedName, requiredSize, requiredSize, std::move(displayGeneratorFunction), std::move(editingFunction) });
|
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<impl::EditingFunction> editingFunction) {
|
void add(const UnlocalizedString &unlocalizedName, size_t requiredSize, size_t maxSize, impl::GeneratorFunction displayGeneratorFunction, std::optional<impl::EditingFunction> editingFunction) {
|
||||||
log::debug("Registered new data inspector format: {}", unlocalizedName);
|
log::debug("Registered new data inspector format: {}", unlocalizedName.get());
|
||||||
|
|
||||||
impl::getEntries().push_back({ unlocalizedName, requiredSize, maxSize, std::move(displayGeneratorFunction), std::move(editingFunction) });
|
impl::getEntries().push_back({ unlocalizedName, requiredSize, maxSize, std::move(displayGeneratorFunction), std::move(editingFunction) });
|
||||||
}
|
}
|
||||||
@ -627,7 +627,7 @@ namespace hex {
|
|||||||
namespace ContentRegistry::DataProcessorNode {
|
namespace ContentRegistry::DataProcessorNode {
|
||||||
|
|
||||||
void impl::add(const Entry &entry) {
|
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);
|
getEntries().push_back(entry);
|
||||||
}
|
}
|
||||||
@ -712,14 +712,14 @@ namespace hex {
|
|||||||
|
|
||||||
namespace ContentRegistry::Interface {
|
namespace ContentRegistry::Interface {
|
||||||
|
|
||||||
void registerMainMenuItem(const std::string &unlocalizedName, u32 priority) {
|
void registerMainMenuItem(const UnlocalizedString &unlocalizedName, u32 priority) {
|
||||||
log::debug("Registered new main menu item: {}", unlocalizedName);
|
log::debug("Registered new main menu item: {}", unlocalizedName.get());
|
||||||
|
|
||||||
impl::getMainMenuItems().insert({ priority, { unlocalizedName } });
|
impl::getMainMenuItems().insert({ priority, { unlocalizedName } });
|
||||||
}
|
}
|
||||||
|
|
||||||
void addMenuItem(const std::vector<std::string> &unlocalizedMainMenuNames, u32 priority, const Shortcut &shortcut, const impl::MenuCallback &function, const impl::EnabledCallback& enabledCallback, View *view) {
|
void addMenuItem(const std::vector<UnlocalizedString> &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);
|
log::debug("Added new menu item to menu {} with priority {}", unlocalizedMainMenuNames[0].get(), priority);
|
||||||
|
|
||||||
impl::getMenuItems().insert({
|
impl::getMenuItems().insert({
|
||||||
priority, impl::MenuItem { unlocalizedMainMenuNames, std::make_unique<Shortcut>(shortcut), view, function, enabledCallback }
|
priority, impl::MenuItem { unlocalizedMainMenuNames, std::make_unique<Shortcut>(shortcut), view, function, enabledCallback }
|
||||||
@ -733,8 +733,8 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addMenuItemSubMenu(std::vector<std::string> unlocalizedMainMenuNames, u32 priority, const impl::MenuCallback &function, const impl::EnabledCallback& enabledCallback) {
|
void addMenuItemSubMenu(std::vector<UnlocalizedString> 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);
|
log::debug("Added new menu item sub menu to menu {} with priority {}", unlocalizedMainMenuNames[0].get(), priority);
|
||||||
|
|
||||||
unlocalizedMainMenuNames.emplace_back(impl::SubMenuValue);
|
unlocalizedMainMenuNames.emplace_back(impl::SubMenuValue);
|
||||||
impl::getMenuItems().insert({
|
impl::getMenuItems().insert({
|
||||||
@ -742,7 +742,7 @@ namespace hex {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void addMenuItemSeparator(std::vector<std::string> unlocalizedMainMenuNames, u32 priority) {
|
void addMenuItemSeparator(std::vector<UnlocalizedString> unlocalizedMainMenuNames, u32 priority) {
|
||||||
unlocalizedMainMenuNames.emplace_back(impl::SeparatorValue);
|
unlocalizedMainMenuNames.emplace_back(impl::SeparatorValue);
|
||||||
impl::getMenuItems().insert({
|
impl::getMenuItems().insert({
|
||||||
priority, impl::MenuItem { unlocalizedMainMenuNames, std::make_unique<Shortcut>(), nullptr, []{}, []{ return true; } }
|
priority, impl::MenuItem { unlocalizedMainMenuNames, std::make_unique<Shortcut>(), nullptr, []{}, []{ return true; } }
|
||||||
@ -765,7 +765,7 @@ namespace hex {
|
|||||||
impl::getSidebarItems().push_back({ icon, function, enabledCallback });
|
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 });
|
impl::getTitleBarButtons().push_back({ icon, unlocalizedTooltip, function });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -835,8 +835,8 @@ namespace hex {
|
|||||||
return providerNames;
|
return providerNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addProviderName(const std::string &unlocalizedName) {
|
void addProviderName(const UnlocalizedString &unlocalizedName) {
|
||||||
log::debug("Registered new provider: {}", unlocalizedName);
|
log::debug("Registered new provider: {}", unlocalizedName.get());
|
||||||
|
|
||||||
getEntries().push_back(unlocalizedName);
|
getEntries().push_back(unlocalizedName);
|
||||||
}
|
}
|
||||||
@ -848,8 +848,8 @@ namespace hex {
|
|||||||
|
|
||||||
namespace ContentRegistry::DataFormatter {
|
namespace ContentRegistry::DataFormatter {
|
||||||
|
|
||||||
void add(const std::string &unlocalizedName, const impl::Callback &callback) {
|
void add(const UnlocalizedString &unlocalizedName, const impl::Callback &callback) {
|
||||||
log::debug("Registered new data formatter: {}", unlocalizedName);
|
log::debug("Registered new data formatter: {}", unlocalizedName.get());
|
||||||
|
|
||||||
impl::getEntries().push_back({ unlocalizedName, callback });
|
impl::getEntries().push_back({ unlocalizedName, callback });
|
||||||
}
|
}
|
||||||
@ -966,7 +966,7 @@ namespace hex {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<DataVisualizer> getVisualizerByName(const std::string &unlocalizedName) {
|
std::shared_ptr<DataVisualizer> getVisualizerByName(const UnlocalizedString &unlocalizedName) {
|
||||||
for (const auto &visualizer : impl::getVisualizers()) {
|
for (const auto &visualizer : impl::getVisualizers()) {
|
||||||
if (visualizer->getUnlocalizedName() == unlocalizedName)
|
if (visualizer->getUnlocalizedName() == unlocalizedName)
|
||||||
return visualizer;
|
return visualizer;
|
||||||
@ -1019,8 +1019,8 @@ namespace hex {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerService(const std::string &unlocalizedName, const impl::Callback &callback) {
|
void registerService(const UnlocalizedString &unlocalizedName, const impl::Callback &callback) {
|
||||||
log::debug("Registered new background service: {}", unlocalizedName);
|
log::debug("Registered new background service: {}", unlocalizedName.get());
|
||||||
|
|
||||||
impl::getServices().push_back(impl::Service {
|
impl::getServices().push_back(impl::Service {
|
||||||
unlocalizedName,
|
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();
|
auto &experiments = impl::getExperiments();
|
||||||
|
|
||||||
if (experiments.contains(experimentName)) {
|
if (experiments.contains(experimentName)) {
|
||||||
|
@ -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;
|
prv::Provider* result = nullptr;
|
||||||
RequestCreateProvider::post(unlocalizedName, skipLoadInterface, select, &result);
|
RequestCreateProvider::post(unlocalizedName, skipLoadInterface, select, &result);
|
||||||
|
|
||||||
|
@ -75,7 +75,8 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Lang::Lang(const char *unlocalizedString) : m_unlocalizedString(unlocalizedString) { }
|
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::Lang(std::string_view unlocalizedString) : m_unlocalizedString(unlocalizedString) { }
|
||||||
|
|
||||||
Lang::operator std::string() const {
|
Lang::operator std::string() const {
|
||||||
|
@ -15,11 +15,11 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ShortcutManager::addGlobalShortcut(const Shortcut &shortcut, const std::string &unlocalizedName, const std::function<void()> &callback) {
|
void ShortcutManager::addGlobalShortcut(const Shortcut &shortcut, const UnlocalizedString &unlocalizedName, const std::function<void()> &callback) {
|
||||||
s_globalShortcuts.insert({ shortcut, { shortcut, unlocalizedName, callback } });
|
s_globalShortcuts.insert({ shortcut, { shortcut, unlocalizedName, callback } });
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShortcutManager::addShortcut(View *view, const Shortcut &shortcut, const std::string &unlocalizedName, const std::function<void()> &callback) {
|
void ShortcutManager::addShortcut(View *view, const Shortcut &shortcut, const UnlocalizedString &unlocalizedName, const std::function<void()> &callback) {
|
||||||
view->m_shortcuts.insert({ shortcut + CurrentView, { shortcut, unlocalizedName, callback } });
|
view->m_shortcuts.insert({ shortcut + CurrentView, { shortcut, unlocalizedName, callback } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ namespace hex {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Task::Task(std::string unlocalizedName, u64 maxValue, bool background, std::function<void(Task &)> function)
|
Task::Task(UnlocalizedString unlocalizedName, u64 maxValue, bool background, std::function<void(Task &)> function)
|
||||||
: m_unlocalizedName(std::move(unlocalizedName)), m_maxValue(maxValue), m_function(std::move(function)), m_background(background) { }
|
: m_unlocalizedName(std::move(unlocalizedName)), m_maxValue(maxValue), m_function(std::move(function)), m_background(background) { }
|
||||||
|
|
||||||
Task::Task(hex::Task &&other) noexcept {
|
Task::Task(hex::Task &&other) noexcept {
|
||||||
@ -138,7 +138,7 @@ namespace hex {
|
|||||||
return this->m_exceptionMessage;
|
return this->m_exceptionMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string &Task::getUnlocalizedName() {
|
const UnlocalizedString &Task::getUnlocalizedName() {
|
||||||
return this->m_unlocalizedName;
|
return this->m_unlocalizedName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,17 +281,17 @@ namespace hex {
|
|||||||
// Execute the task
|
// Execute the task
|
||||||
task->m_function(*task);
|
task->m_function(*task);
|
||||||
|
|
||||||
log::debug("Task '{}' finished", task->m_unlocalizedName);
|
log::debug("Task '{}' finished", task->m_unlocalizedName.get());
|
||||||
} catch (const Task::TaskInterruptor &) {
|
} catch (const Task::TaskInterruptor &) {
|
||||||
// Handle the task being interrupted by user request
|
// Handle the task being interrupted by user request
|
||||||
task->interruption();
|
task->interruption();
|
||||||
} catch (const std::exception &e) {
|
} 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
|
// Handle the task throwing an uncaught exception
|
||||||
task->exception(e.what());
|
task->exception(e.what());
|
||||||
} catch (...) {
|
} 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
|
// Handle the task throwing an uncaught exception of unknown type
|
||||||
task->exception("Unknown Exception");
|
task->exception("Unknown Exception");
|
||||||
|
@ -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;
|
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);
|
s_currentTutorial = s_tutorials.find(unlocalizedName);
|
||||||
if (s_currentTutorial == s_tutorials.end())
|
if (s_currentTutorial == s_tutorials.end())
|
||||||
return;
|
return;
|
||||||
@ -251,7 +251,7 @@ namespace hex {
|
|||||||
}, id);
|
}, 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<std::variant<Lang, std::string, int>>&& ids) {
|
TutorialManager::Tutorial::Step& TutorialManager::Tutorial::Step::addHighlight(const UnlocalizedString &unlocalizedText, std::initializer_list<std::variant<Lang, std::string, int>>&& ids) {
|
||||||
this->m_highlights.emplace_back(
|
this->m_highlights.emplace_back(
|
||||||
unlocalizedText,
|
unlocalizedText,
|
||||||
ids
|
ids
|
||||||
@ -298,12 +298,12 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TutorialManager::Tutorial::Step& TutorialManager::Tutorial::Step::addHighlight(std::initializer_list<std::variant<Lang, std::string, int>>&& ids) {
|
TutorialManager::Tutorial::Step& TutorialManager::Tutorial::Step::addHighlight(std::initializer_list<std::variant<Lang, std::string, int>>&& ids) {
|
||||||
return this->addHighlight("", std::move(ids));
|
return this->addHighlight("", std::forward<decltype(ids)>(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 {
|
this->m_message = Message {
|
||||||
position,
|
position,
|
||||||
unlocalizedTitle,
|
unlocalizedTitle,
|
||||||
|
@ -6,7 +6,7 @@ namespace hex::dp {
|
|||||||
int Attribute::s_idCounter = 1;
|
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() {
|
Attribute::~Attribute() {
|
||||||
|
@ -9,7 +9,7 @@ namespace hex::dp {
|
|||||||
|
|
||||||
int Node::s_idCounter = 1;
|
int Node::s_idCounter = 1;
|
||||||
|
|
||||||
Node::Node(std::string unlocalizedTitle, std::vector<Attribute> attributes) : m_id(s_idCounter++), m_unlocalizedTitle(std::move(unlocalizedTitle)), m_attributes(std::move(attributes)) {
|
Node::Node(UnlocalizedString unlocalizedTitle, std::vector<Attribute> attributes) : m_id(s_idCounter++), m_unlocalizedTitle(std::move(unlocalizedTitle)), m_attributes(std::move(attributes)) {
|
||||||
for (auto &attr : this->m_attributes)
|
for (auto &attr : this->m_attributes)
|
||||||
attr.setParentNode(this);
|
attr.setParentNode(this);
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,13 @@
|
|||||||
|
|
||||||
#include <wolv/utils/guards.hpp>
|
#include <wolv/utils/guards.hpp>
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
namespace hex::prv::undo {
|
namespace hex::prv::undo {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
std::atomic_bool s_locked;
|
std::atomic<bool> s_locked;
|
||||||
std::mutex s_mutex;
|
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)
|
if (count <= 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
namespace hex {
|
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 {
|
bool View::shouldDraw() const {
|
||||||
return ImHexApi::Provider::isValid() && ImHexApi::Provider::get()->isAvailable();
|
return ImHexApi::Provider::isValid() && ImHexApi::Provider::get()->isAvailable();
|
||||||
@ -43,7 +43,7 @@ namespace hex {
|
|||||||
return this->m_windowOpen;
|
return this->m_windowOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string &View::getUnlocalizedName() const {
|
const UnlocalizedString &View::getUnlocalizedName() const {
|
||||||
return this->m_unlocalizedViewName;
|
return this->m_unlocalizedViewName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,8 +71,8 @@ namespace hex {
|
|||||||
ImGui::GetIO().ConfigFlags &= ~ImGuiConfigFlags_NavEnableKeyboard;
|
ImGui::GetIO().ConfigFlags &= ~ImGuiConfigFlags_NavEnableKeyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string View::toWindowName(const std::string &unlocalizedName) {
|
std::string View::toWindowName(const UnlocalizedString &unlocalizedName) {
|
||||||
return Lang(unlocalizedName) + "###" + unlocalizedName;
|
return Lang(unlocalizedName) + "###" + unlocalizedName.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -231,21 +231,21 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void createNestedMenu(std::span<const std::string> menuItems, const Shortcut &shortcut, const std::function<void()> &callback, const std::function<bool()> &enabledCallback) {
|
static void createNestedMenu(std::span<const UnlocalizedString> menuItems, const Shortcut &shortcut, const std::function<void()> &callback, const std::function<bool()> &enabledCallback) {
|
||||||
const auto &name = menuItems.front();
|
const auto &name = menuItems.front();
|
||||||
|
|
||||||
if (name == ContentRegistry::Interface::impl::SeparatorValue) {
|
if (name.get() == ContentRegistry::Interface::impl::SeparatorValue) {
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name == ContentRegistry::Interface::impl::SubMenuValue) {
|
if (name.get() == ContentRegistry::Interface::impl::SubMenuValue) {
|
||||||
callback();
|
callback();
|
||||||
} else if (menuItems.size() == 1) {
|
} else if (menuItems.size() == 1) {
|
||||||
if (ImGui::MenuItem(Lang(name), shortcut.toString().c_str(), false, enabledCallback()))
|
if (ImGui::MenuItem(Lang(name), shortcut.toString().c_str(), false, enabledCallback()))
|
||||||
callback();
|
callback();
|
||||||
} else {
|
} 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)) {
|
if (ImGui::BeginMenu(Lang(name), isSubmenu ? enabledCallback() : true)) {
|
||||||
createNestedMenu({ menuItems.begin() + 1, menuItems.end() }, shortcut, callback, enabledCallback);
|
createNestedMenu({ menuItems.begin() + 1, menuItems.end() }, shortcut, callback, enabledCallback);
|
||||||
@ -760,7 +760,7 @@ namespace hex {
|
|||||||
for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItems()) {
|
for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItems()) {
|
||||||
const auto &[unlocalizedNames, shortcut, view, callback, enabledCallback] = menuItem;
|
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);
|
createNestedMenu({ unlocalizedNames.begin() + 1, unlocalizedNames.end() }, *shortcut, callback, enabledCallback);
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
@ -1178,7 +1178,7 @@ namespace hex {
|
|||||||
Window* window = static_cast<Window*>(handler->UserData);
|
Window* window = static_cast<Window*>(handler->UserData);
|
||||||
|
|
||||||
for (auto &[name, view] : ContentRegistry::Views::impl::getEntries()) {
|
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());
|
sscanf(line, format.c_str(), &view->getWindowOpenState());
|
||||||
}
|
}
|
||||||
for (auto &[name, function, detached] : ContentRegistry::Tools::impl::getEntries()) {
|
for (auto &[name, function, detached] : ContentRegistry::Tools::impl::getEntries()) {
|
||||||
|
@ -15,7 +15,7 @@ namespace hex::plugin::builtin {
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
class PopupNotification : public Popup<T> {
|
class PopupNotification : public Popup<T> {
|
||||||
public:
|
public:
|
||||||
PopupNotification(std::string unlocalizedName, std::string message, std::function<void()> function)
|
PopupNotification(UnlocalizedString unlocalizedName, std::string message, std::function<void()> function)
|
||||||
: hex::Popup<T>(std::move(unlocalizedName), false),
|
: hex::Popup<T>(std::move(unlocalizedName), false),
|
||||||
m_message(std::move(message)), m_function(std::move(function)) { }
|
m_message(std::move(message)), m_function(std::move(function)) { }
|
||||||
|
|
||||||
|
@ -14,12 +14,12 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
class PopupTextInput : public Popup<PopupTextInput> {
|
class PopupTextInput : public Popup<PopupTextInput> {
|
||||||
public:
|
public:
|
||||||
PopupTextInput(std::string unlocalizedName, std::string message, std::function<void(std::string)> function)
|
PopupTextInput(UnlocalizedString unlocalizedName, UnlocalizedString message, std::function<void(std::string)> function)
|
||||||
: hex::Popup<PopupTextInput>(std::move(unlocalizedName), false),
|
: hex::Popup<PopupTextInput>(std::move(unlocalizedName), false),
|
||||||
m_message(std::move(message)), m_function(std::move(function)) { }
|
m_message(std::move(message)), m_function(std::move(function)) { }
|
||||||
|
|
||||||
void drawContent() override {
|
void drawContent() override {
|
||||||
ImGuiExt::TextFormattedWrapped("{}", this->m_message.c_str());
|
ImGuiExt::TextFormattedWrapped("{}", Lang(this->m_message));
|
||||||
ImGui::NewLine();
|
ImGui::NewLine();
|
||||||
|
|
||||||
ImGui::PushItemWidth(-1);
|
ImGui::PushItemWidth(-1);
|
||||||
@ -65,7 +65,7 @@ namespace hex::plugin::builtin {
|
|||||||
private:
|
private:
|
||||||
std::string m_input;
|
std::string m_input;
|
||||||
|
|
||||||
std::string m_message;
|
UnlocalizedString m_message;
|
||||||
std::function<void(std::string)> m_function;
|
std::function<void(std::string)> m_function;
|
||||||
bool m_justOpened = true;
|
bool m_justOpened = true;
|
||||||
};
|
};
|
||||||
|
@ -20,7 +20,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
struct InspectorCacheEntry {
|
struct InspectorCacheEntry {
|
||||||
std::string unlocalizedName;
|
UnlocalizedString unlocalizedName;
|
||||||
ContentRegistry::DataInspector::impl::DisplayFunction displayFunction;
|
ContentRegistry::DataInspector::impl::DisplayFunction displayFunction;
|
||||||
std::optional<ContentRegistry::DataInspector::impl::EditingFunction> editingFunction;
|
std::optional<ContentRegistry::DataInspector::impl::EditingFunction> editingFunction;
|
||||||
bool editing;
|
bool editing;
|
||||||
|
@ -38,7 +38,7 @@ namespace hex::plugin::builtin {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct StoreCategory {
|
struct StoreCategory {
|
||||||
std::string unlocalizedName;
|
UnlocalizedString unlocalizedName;
|
||||||
std::string requestName;
|
std::string requestName;
|
||||||
fs::ImHexPath path;
|
fs::ImHexPath path;
|
||||||
std::vector<StoreEntry> entries;
|
std::vector<StoreEntry> entries;
|
||||||
@ -76,7 +76,7 @@ namespace hex::plugin::builtin {
|
|||||||
void refresh();
|
void refresh();
|
||||||
void parseResponse();
|
void parseResponse();
|
||||||
|
|
||||||
void addCategory(const std::string &unlocalizedName, const std::string &requestName, fs::ImHexPath path, std::function<void()> downloadCallback = []{});
|
void addCategory(const UnlocalizedString &unlocalizedName, const std::string &requestName, fs::ImHexPath path, std::function<void()> downloadCallback = []{});
|
||||||
|
|
||||||
bool download(fs::ImHexPath pathType, const std::string &fileName, const std::string &url, bool update);
|
bool download(fs::ImHexPath pathType, const std::string &fileName, const std::string &url, bool update);
|
||||||
bool remove(fs::ImHexPath pathType, const std::string &fileName);
|
bool remove(fs::ImHexPath pathType, const std::string &fileName);
|
||||||
|
@ -16,32 +16,32 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
class AchievementStartingOut : public Achievement {
|
class AchievementStartingOut : public Achievement {
|
||||||
public:
|
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 {
|
class AchievementHexEditor : public Achievement {
|
||||||
public:
|
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 {
|
class AchievementPatterns : public Achievement {
|
||||||
public:
|
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 {
|
class AchievementDataProcessor : public Achievement {
|
||||||
public:
|
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 {
|
class AchievementFind : public Achievement {
|
||||||
public:
|
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 {
|
class AchievementMisc : public Achievement {
|
||||||
public:
|
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() {
|
void registerGettingStartedAchievements() {
|
||||||
|
@ -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<int>() * 30;
|
autoBackupTime = ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.auto_backup_time", 0).get<int>() * 30;
|
||||||
});
|
});
|
||||||
|
|
||||||
ContentRegistry::BackgroundServices::registerService("hex.builtin.background_service.network_interface"_lang, handleNetworkInterfaceService);
|
ContentRegistry::BackgroundServices::registerService("hex.builtin.background_service.network_interface", handleNetworkInterfaceService);
|
||||||
ContentRegistry::BackgroundServices::registerService("hex.builtin.background_service.auto_backup"_lang, handleAutoBackup);
|
ContentRegistry::BackgroundServices::registerService("hex.builtin.background_service.auto_backup", handleAutoBackup);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -542,14 +542,14 @@ namespace hex::plugin::builtin {
|
|||||||
ContentRegistry::Interface::registerMainMenuItem("hex.builtin.menu.workspace", 4000);
|
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, [] {
|
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);
|
LayoutManager::save(name);
|
||||||
});
|
});
|
||||||
}, ImHexApi::Provider::isValid);
|
}, ImHexApi::Provider::isValid);
|
||||||
|
|
||||||
ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.workspace", "hex.builtin.menu.workspace.layout" }, 1150, [] {
|
ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.workspace", "hex.builtin.menu.workspace.layout" }, 1150, [] {
|
||||||
bool locked = LayoutManager::isLayoutLocked();
|
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);
|
LayoutManager::lockLayout(locked);
|
||||||
ContentRegistry::Settings::write("hex.builtin.setting.interface", "hex.builtin.setting.interface.layout_locked", 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::addMenuItemSeparator({ "hex.builtin.menu.workspace" }, 3000);
|
||||||
|
|
||||||
ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.workspace", "hex.builtin.menu.workspace.create" }, 3100, Shortcut::None, [] {
|
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);
|
WorkspaceManager::createWorkspace(name);
|
||||||
});
|
});
|
||||||
}, ImHexApi::Provider::isValid);
|
}, ImHexApi::Provider::isValid);
|
||||||
|
@ -146,7 +146,7 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MemoryFileProvider::renameFile() {
|
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;
|
this->m_name = name;
|
||||||
RequestUpdateWindowTitle::post();
|
RequestUpdateWindowTitle::post();
|
||||||
});
|
});
|
||||||
|
@ -37,7 +37,7 @@ namespace hex::plugin::builtin::recent {
|
|||||||
std::fs::path path;
|
std::fs::path path;
|
||||||
};
|
};
|
||||||
public:
|
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 &backupPath : fs::getDefaultPaths(fs::ImHexPath::Backups)) {
|
||||||
for (const auto &entry : std::fs::directory_iterator(backupPath)) {
|
for (const auto &entry : std::fs::directory_iterator(backupPath)) {
|
||||||
if (entry.is_regular_file() && entry.path().extension() == ".hexproj") {
|
if (entry.is_regular_file() && entry.path().extension() == ".hexproj") {
|
||||||
|
@ -92,7 +92,7 @@ namespace hex::plugin::builtin {
|
|||||||
})
|
})
|
||||||
.onAppear([&step] {
|
.onAppear([&step] {
|
||||||
EventViewOpened::subscribe([&step](View *view){
|
EventViewOpened::subscribe([&step](View *view){
|
||||||
if (view->getUnlocalizedName() == "hex.builtin.view.tutorials.name")
|
if (view->getUnlocalizedName() == UnlocalizedString("hex.builtin.view.tutorials.name"))
|
||||||
step.complete();
|
step.complete();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
@ -579,7 +579,7 @@ namespace hex::plugin::builtin {
|
|||||||
nlohmann::json nodeJson = nlohmann::json::parse(file.readString());
|
nlohmann::json nodeJson = nlohmann::json::parse(file.readString());
|
||||||
|
|
||||||
// Add the loaded node to the list of custom nodes
|
// 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<std::string>()), nodeJson });
|
||||||
} catch (nlohmann::json::exception &e) {
|
} catch (nlohmann::json::exception &e) {
|
||||||
log::warn("Failed to load custom node '{}': {}", entry.path().string(), e.what());
|
log::warn("Failed to load custom node '{}': {}", entry.path().string(), e.what());
|
||||||
}
|
}
|
||||||
@ -1077,7 +1077,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
std::unique_ptr<dp::Node> newNode;
|
std::unique_ptr<dp::Node> newNode;
|
||||||
for (auto &entry : nodeEntries) {
|
for (auto &entry : nodeEntries) {
|
||||||
if (data.contains("name") && entry.name == data["type"].get<std::string>())
|
if (data.contains("name") && entry.unlocalizedName == data["type"].get<std::string>())
|
||||||
newNode = entry.creatorFunction();
|
newNode = entry.creatorFunction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ namespace hex::plugin::builtin {
|
|||||||
m_hash(hash) { }
|
m_hash(hash) { }
|
||||||
|
|
||||||
void drawContent() override {
|
void drawContent() override {
|
||||||
ImGuiExt::Header(this->getUnlocalizedName().c_str(), true);
|
ImGuiExt::Header(this->getUnlocalizedName(), true);
|
||||||
|
|
||||||
ImGui::PushItemWidth(-1);
|
ImGui::PushItemWidth(-1);
|
||||||
if (ImGui::InputTextMultiline("##input", this->m_input)) {
|
if (ImGui::InputTextMultiline("##input", this->m_input)) {
|
||||||
|
@ -1044,7 +1044,7 @@ namespace hex::plugin::builtin {
|
|||||||
ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 1300);
|
ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 1300);
|
||||||
|
|
||||||
/* Save */
|
/* 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,
|
CTRLCMD + Keys::S,
|
||||||
save,
|
save,
|
||||||
[] {
|
[] {
|
||||||
@ -1055,7 +1055,7 @@ namespace hex::plugin::builtin {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/* Save As */
|
/* 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,
|
CTRLCMD + SHIFT + Keys::S,
|
||||||
saveAs,
|
saveAs,
|
||||||
[] {
|
[] {
|
||||||
|
@ -21,7 +21,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
// Add the settings menu item to the Extras menu
|
// Add the settings menu item to the Extras menu
|
||||||
ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.extras" }, 3000);
|
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;
|
this->getWindowOpenState() = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ namespace hex::plugin::builtin {
|
|||||||
ContentRegistry::Settings::write(category.unlocalizedName, setting.unlocalizedName, newValue);
|
ContentRegistry::Settings::write(category.unlocalizedName, setting.unlocalizedName, newValue);
|
||||||
|
|
||||||
// Print a debug message
|
// 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
|
// Signal that the setting was changed
|
||||||
EventSettingsChanged::post();
|
EventSettingsChanged::post();
|
||||||
|
@ -37,20 +37,20 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
this->m_httpRequest.setTimeout(30'0000);
|
this->m_httpRequest.setTimeout(30'0000);
|
||||||
|
|
||||||
addCategory("hex.builtin.view.store.tab.patterns"_lang, "patterns", fs::ImHexPath::Patterns);
|
addCategory("hex.builtin.view.store.tab.patterns", "patterns", fs::ImHexPath::Patterns);
|
||||||
addCategory("hex.builtin.view.store.tab.includes"_lang, "includes", fs::ImHexPath::PatternsInclude);
|
addCategory("hex.builtin.view.store.tab.includes", "includes", fs::ImHexPath::PatternsInclude);
|
||||||
addCategory("hex.builtin.view.store.tab.magic"_lang, "magic", fs::ImHexPath::Magic, []{
|
addCategory("hex.builtin.view.store.tab.magic", "magic", fs::ImHexPath::Magic, []{
|
||||||
magic::compile();
|
magic::compile();
|
||||||
});
|
});
|
||||||
addCategory("hex.builtin.view.store.tab.nodes"_lang, "nodes", fs::ImHexPath::Nodes);
|
addCategory("hex.builtin.view.store.tab.nodes", "nodes", fs::ImHexPath::Nodes);
|
||||||
addCategory("hex.builtin.view.store.tab.encodings"_lang, "encodings", fs::ImHexPath::Encodings);
|
addCategory("hex.builtin.view.store.tab.encodings", "encodings", fs::ImHexPath::Encodings);
|
||||||
addCategory("hex.builtin.view.store.tab.constants"_lang, "constants", fs::ImHexPath::Constants);
|
addCategory("hex.builtin.view.store.tab.constants", "constants", fs::ImHexPath::Constants);
|
||||||
addCategory("hex.builtin.view.store.tab.themes"_lang, "themes", fs::ImHexPath::Themes, [this]{
|
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);
|
auto themeFile = wolv::io::File(this->m_downloadPath, wolv::io::File::Mode::Read);
|
||||||
|
|
||||||
ThemeManager::addTheme(themeFile.readString());
|
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;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewStore::addCategory(const std::string &unlocalizedName, const std::string &requestName, fs::ImHexPath path, std::function<void()> downloadCallback) {
|
void ViewStore::addCategory(const UnlocalizedString &unlocalizedName, const std::string &requestName, fs::ImHexPath path, std::function<void()> downloadCallback) {
|
||||||
this->m_categories.push_back({ unlocalizedName, requestName, path, { }, std::move(downloadCallback) });
|
this->m_categories.push_back({ unlocalizedName, requestName, path, { }, std::move(downloadCallback) });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user