mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 13:05:25 -05:00
impr: Various web build improvements, API cleanup (#1541)
This commit is contained in:
@@ -16,9 +16,10 @@ namespace hex::plugin::builtin {
|
||||
void drawAlwaysVisibleContent() override;
|
||||
|
||||
private:
|
||||
std::vector<ContentRegistry::Tools::impl::Entry>::iterator m_dragStartIterator;
|
||||
std::vector<ContentRegistry::Tools::impl::Entry>::const_iterator m_dragStartIterator;
|
||||
|
||||
std::map<ImGuiWindow*, float> m_windowHeights;
|
||||
std::map<UnlocalizedString, bool> m_detachedTools;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -483,6 +483,7 @@
|
||||
"hex.builtin.setting.imhex.recent_files": "Zuletzt geöffnete Dateien",
|
||||
"hex.builtin.setting.interface": "Aussehen",
|
||||
"hex.builtin.setting.interface.color": "Farbdesign",
|
||||
"hex.builtin.setting.interface.crisp_scaling": "Gestochen scharfe Skallierung aktivieren",
|
||||
"hex.builtin.setting.interface.fps": "FPS Limit",
|
||||
"hex.builtin.setting.interface.fps.native": "Nativ",
|
||||
"hex.builtin.setting.interface.fps.unlocked": "Unbegrenzt",
|
||||
|
||||
@@ -470,6 +470,7 @@
|
||||
"hex.builtin.setting.interface": "Interface",
|
||||
"hex.builtin.setting.interface.always_show_provider_tabs": "Always show Provider Tabs",
|
||||
"hex.builtin.setting.interface.color": "Color theme",
|
||||
"hex.builtin.setting.interface.crisp_scaling": "Enable crisp scaling",
|
||||
"hex.builtin.setting.interface.fps": "FPS Limit",
|
||||
"hex.builtin.setting.interface.fps.unlocked": "Unlocked",
|
||||
"hex.builtin.setting.interface.fps.native": "Native",
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace hex::plugin::builtin {
|
||||
ui::PopupQuestion::open("hex.builtin.popup.exit_application.desc"_lang,
|
||||
[] {
|
||||
imhexClosing = true;
|
||||
for (const auto &provider : auto(ImHexApi::Provider::getProviders()))
|
||||
for (const auto &provider : ImHexApi::Provider::getProviders())
|
||||
ImHexApi::Provider::remove(provider);
|
||||
},
|
||||
[] { }
|
||||
|
||||
@@ -290,7 +290,7 @@ namespace hex::plugin::builtin {
|
||||
queryRange.push_back(0x00);
|
||||
|
||||
// Build the font atlas with the query range
|
||||
auto newFont = atlas.AddFontFromMemoryTTF(font.fontData.data(), int(font.fontData.size()), 0, &cfg, queryRange.Data);
|
||||
auto newFont = atlas.AddFontFromMemoryTTF(const_cast<u8 *>(font.fontData.data()), int(font.fontData.size()), 0, &cfg, queryRange.Data);
|
||||
atlas.Build();
|
||||
|
||||
return newFont->Descent;
|
||||
@@ -300,7 +300,7 @@ namespace hex::plugin::builtin {
|
||||
std::memset(cfg.Name, 0x00, sizeof(cfg.Name));
|
||||
std::strncpy(cfg.Name, font.name.c_str(), sizeof(cfg.Name) - 1);
|
||||
cfg.GlyphOffset = { font.offset.x, font.offset.y - defaultFont->Descent + descent };
|
||||
fonts->AddFontFromMemoryTTF(font.fontData.data(), int(font.fontData.size()), 0, &cfg, ranges.back().Data);
|
||||
fonts->AddFontFromMemoryTTF(const_cast<u8 *>(font.fontData.data()), int(font.fontData.size()), 0, &cfg, ranges.back().Data);
|
||||
}
|
||||
cfg.FontBuilderFlags = startFlags;
|
||||
|
||||
|
||||
@@ -57,8 +57,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
}
|
||||
|
||||
auto providers = auto(ImHexApi::Provider::getProviders());
|
||||
for (const auto &provider : providers) {
|
||||
for (const auto &provider : ImHexApi::Provider::getProviders()) {
|
||||
ImHexApi::Provider::remove(provider);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace hex::plugin::builtin {
|
||||
task->interrupt();
|
||||
|
||||
TaskManager::runWhenTasksFinished([]{
|
||||
for (auto provider : ImHexApi::Provider::getProviders())
|
||||
for (const auto &provider : ImHexApi::Provider::getProviders())
|
||||
ImHexApi::Provider::remove(provider, true);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -443,7 +443,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
// Find all menu items that are in the toolbar and sort them by their toolbar index
|
||||
std::set<ContentRegistry::Interface::impl::MenuItem*, MenuItemSorter> toolbarItems;
|
||||
for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItems()) {
|
||||
for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItemsMutable()) {
|
||||
if (menuItem.toolbarIndex == -1)
|
||||
continue;
|
||||
|
||||
@@ -580,10 +580,10 @@ namespace hex::plugin::builtin {
|
||||
if (toolbarItems.empty())
|
||||
return;
|
||||
|
||||
for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItems())
|
||||
for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItemsMutable())
|
||||
menuItem.toolbarIndex = -1;
|
||||
|
||||
for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItems()) {
|
||||
for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItemsMutable()) {
|
||||
for (const auto &[index, value] : toolbarItems) {
|
||||
const auto &[name, color] = value;
|
||||
if (menuItem.unlocalizedNames.back().get() == name) {
|
||||
@@ -604,184 +604,208 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
void registerSettings() {
|
||||
|
||||
/* General */
|
||||
|
||||
namespace Widgets = ContentRegistry::Settings::Widgets;
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "", "hex.builtin.setting.general.show_tips", false);
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "", "hex.builtin.setting.general.save_recent_providers", true);
|
||||
ContentRegistry::Settings::add<AutoBackupWidget>("hex.builtin.setting.general", "", "hex.builtin.setting.general.auto_backup_time");
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "hex.builtin.setting.general.patterns", "hex.builtin.setting.general.auto_load_patterns", true);
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "hex.builtin.setting.general.patterns", "hex.builtin.setting.general.sync_pattern_source", false);
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "hex.builtin.setting.general.network", "hex.builtin.setting.general.network_interface", false);
|
||||
/* General */
|
||||
{
|
||||
|
||||
#if !defined(OS_WEB)
|
||||
ContentRegistry::Settings::add<ServerContactWidget>("hex.builtin.setting.general", "hex.builtin.setting.general.network", "hex.builtin.setting.general.server_contact");
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "hex.builtin.setting.general.network", "hex.builtin.setting.general.upload_crash_logs", true);
|
||||
#endif
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "", "hex.builtin.setting.general.show_tips", false);
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "", "hex.builtin.setting.general.save_recent_providers", true);
|
||||
ContentRegistry::Settings::add<AutoBackupWidget>("hex.builtin.setting.general", "", "hex.builtin.setting.general.auto_backup_time");
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "hex.builtin.setting.general.patterns", "hex.builtin.setting.general.auto_load_patterns", true);
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "hex.builtin.setting.general.patterns", "hex.builtin.setting.general.sync_pattern_source", false);
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "hex.builtin.setting.general.network", "hex.builtin.setting.general.network_interface", false);
|
||||
|
||||
/* Interface */
|
||||
|
||||
auto themeNames = ThemeManager::getThemeNames();
|
||||
std::vector<nlohmann::json> themeJsons = { };
|
||||
for (const auto &themeName : themeNames)
|
||||
themeJsons.emplace_back(themeName);
|
||||
|
||||
themeNames.emplace(themeNames.begin(), ThemeManager::NativeTheme);
|
||||
themeJsons.emplace(themeJsons.begin(), ThemeManager::NativeTheme);
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::DropDown>("hex.builtin.setting.interface", "hex.builtin.setting.interface.style", "hex.builtin.setting.interface.color",
|
||||
themeNames,
|
||||
themeJsons,
|
||||
"Dark").setChangedCallback([](auto &widget) {
|
||||
auto dropDown = static_cast<Widgets::DropDown *>(&widget);
|
||||
|
||||
if (dropDown->getValue() == ThemeManager::NativeTheme)
|
||||
ImHexApi::System::enableSystemThemeDetection(true);
|
||||
else {
|
||||
ImHexApi::System::enableSystemThemeDetection(false);
|
||||
ThemeManager::changeTheme(dropDown->getValue());
|
||||
}
|
||||
});
|
||||
|
||||
ContentRegistry::Settings::add<ScalingWidget>("hex.builtin.setting.interface", "hex.builtin.setting.interface.style", "hex.builtin.setting.interface.scaling_factor").requiresRestart();
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.interface", "hex.builtin.setting.interface.style", "hex.builtin.setting.interface.pattern_data_row_bg", false);
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.interface", "hex.builtin.setting.interface.style", "hex.builtin.setting.interface.always_show_provider_tabs", false);
|
||||
|
||||
std::vector<std::string> languageNames;
|
||||
std::vector<nlohmann::json> languageCodes;
|
||||
|
||||
for (auto &[languageCode, languageName] : LocalizationManager::getSupportedLanguages()) {
|
||||
languageNames.emplace_back(languageName);
|
||||
languageCodes.emplace_back(languageCode);
|
||||
#if !defined(OS_WEB)
|
||||
ContentRegistry::Settings::add<ServerContactWidget>("hex.builtin.setting.general", "hex.builtin.setting.general.network", "hex.builtin.setting.general.server_contact");
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "hex.builtin.setting.general.network", "hex.builtin.setting.general.upload_crash_logs", true);
|
||||
#endif
|
||||
}
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::DropDown>("hex.builtin.setting.interface", "hex.builtin.setting.interface.language", "hex.builtin.setting.interface.language", languageNames, languageCodes, "en-US");
|
||||
/* Interface */
|
||||
{
|
||||
auto themeNames = ThemeManager::getThemeNames();
|
||||
std::vector<nlohmann::json> themeJsons = { };
|
||||
for (const auto &themeName : themeNames)
|
||||
themeJsons.emplace_back(themeName);
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::TextBox>("hex.builtin.setting.interface", "hex.builtin.setting.interface.language", "hex.builtin.setting.interface.wiki_explain_language", "en");
|
||||
ContentRegistry::Settings::add<FPSWidget>("hex.builtin.setting.interface", "hex.builtin.setting.interface.window", "hex.builtin.setting.interface.fps");
|
||||
themeNames.emplace(themeNames.begin(), ThemeManager::NativeTheme);
|
||||
themeJsons.emplace(themeJsons.begin(), ThemeManager::NativeTheme);
|
||||
|
||||
#if defined (OS_LINUX)
|
||||
constexpr static auto MultiWindowSupportEnabledDefault = 0;
|
||||
#else
|
||||
constexpr static auto MultiWindowSupportEnabledDefault = 1;
|
||||
#endif
|
||||
ContentRegistry::Settings::add<Widgets::DropDown>("hex.builtin.setting.interface", "hex.builtin.setting.interface.style", "hex.builtin.setting.interface.color",
|
||||
themeNames,
|
||||
themeJsons,
|
||||
"Dark").setChangedCallback([](auto &widget) {
|
||||
auto dropDown = static_cast<Widgets::DropDown *>(&widget);
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.interface", "hex.builtin.setting.interface.window", "hex.builtin.setting.interface.multi_windows", MultiWindowSupportEnabledDefault).requiresRestart();
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.interface", "hex.builtin.setting.interface.window", "hex.builtin.setting.interface.restore_window_pos", false);
|
||||
if (dropDown->getValue() == ThemeManager::NativeTheme)
|
||||
ImHexApi::System::enableSystemThemeDetection(true);
|
||||
else {
|
||||
ImHexApi::System::enableSystemThemeDetection(false);
|
||||
ThemeManager::changeTheme(dropDown->getValue());
|
||||
}
|
||||
});
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::ColorPicker>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.highlight_color", ImColor(0x80, 0x80, 0xC0, 0x60));
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.sync_scrolling", false);
|
||||
ContentRegistry::Settings::add<Widgets::SliderInteger>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.byte_padding", 0, 0, 50);
|
||||
ContentRegistry::Settings::add<Widgets::SliderInteger>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.char_padding", 0, 0, 50);
|
||||
ContentRegistry::Settings::add<ScalingWidget>("hex.builtin.setting.interface", "hex.builtin.setting.interface.style", "hex.builtin.setting.interface.scaling_factor").requiresRestart();
|
||||
|
||||
#if defined (OS_WEB)
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.interface", "hex.builtin.setting.interface.style", "hex.builtin.setting.interface.crisp_scaling", false)
|
||||
.setChangedCallback([](Widgets::Widget &widget) {
|
||||
auto checkBox = static_cast<Widgets::Checkbox *>(&widget);
|
||||
|
||||
EM_ASM({
|
||||
var canvas = document.getElementById('canvas');
|
||||
if ($0)
|
||||
canvas.style.imageRendering = 'pixelated';
|
||||
else
|
||||
canvas.style.imageRendering = 'smooth';
|
||||
}, checkBox->isChecked());
|
||||
});
|
||||
#endif
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.interface", "hex.builtin.setting.interface.style", "hex.builtin.setting.interface.pattern_data_row_bg", false);
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.interface", "hex.builtin.setting.interface.style", "hex.builtin.setting.interface.always_show_provider_tabs", false);
|
||||
|
||||
std::vector<std::string> languageNames;
|
||||
std::vector<nlohmann::json> languageCodes;
|
||||
|
||||
for (auto &[languageCode, languageName] : LocalizationManager::getSupportedLanguages()) {
|
||||
languageNames.emplace_back(languageName);
|
||||
languageCodes.emplace_back(languageCode);
|
||||
}
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::DropDown>("hex.builtin.setting.interface", "hex.builtin.setting.interface.language", "hex.builtin.setting.interface.language", languageNames, languageCodes, "en-US");
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::TextBox>("hex.builtin.setting.interface", "hex.builtin.setting.interface.language", "hex.builtin.setting.interface.wiki_explain_language", "en");
|
||||
ContentRegistry::Settings::add<FPSWidget>("hex.builtin.setting.interface", "hex.builtin.setting.interface.window", "hex.builtin.setting.interface.fps");
|
||||
|
||||
#if defined (OS_LINUX)
|
||||
constexpr static auto MultiWindowSupportEnabledDefault = 0;
|
||||
#else
|
||||
constexpr static auto MultiWindowSupportEnabledDefault = 1;
|
||||
#endif
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.interface", "hex.builtin.setting.interface.window", "hex.builtin.setting.interface.multi_windows", MultiWindowSupportEnabledDefault).requiresRestart();
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.interface", "hex.builtin.setting.interface.window", "hex.builtin.setting.interface.restore_window_pos", false);
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::ColorPicker>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.highlight_color", ImColor(0x80, 0x80, 0xC0, 0x60));
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.sync_scrolling", false);
|
||||
ContentRegistry::Settings::add<Widgets::SliderInteger>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.byte_padding", 0, 0, 50);
|
||||
ContentRegistry::Settings::add<Widgets::SliderInteger>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.char_padding", 0, 0, 50);
|
||||
}
|
||||
|
||||
/* Fonts */
|
||||
{
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.font", "hex.builtin.setting.font.glyphs", "hex.builtin.setting.font.load_all_unicode_chars", false)
|
||||
.requiresRestart();
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.font", "hex.builtin.setting.font.glyphs", "hex.builtin.setting.font.load_all_unicode_chars", false)
|
||||
.requiresRestart();
|
||||
|
||||
auto customFontEnabledSetting = ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font", "hex.builtin.setting.font.custom_font_enable", false).requiresRestart();
|
||||
auto customFontEnabledSetting = ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font", "hex.builtin.setting.font.custom_font_enable", false).requiresRestart();
|
||||
|
||||
const auto customFontsEnabled = [customFontEnabledSetting] {
|
||||
auto &customFontsEnabled = static_cast<Widgets::Checkbox &>(customFontEnabledSetting.getWidget());
|
||||
const auto customFontsEnabled = [customFontEnabledSetting] {
|
||||
auto &customFontsEnabled = static_cast<Widgets::Checkbox &>(customFontEnabledSetting.getWidget());
|
||||
|
||||
return customFontsEnabled.isChecked();
|
||||
};
|
||||
return customFontsEnabled.isChecked();
|
||||
};
|
||||
|
||||
auto customFontPathSetting = ContentRegistry::Settings::add<Widgets::FilePicker>("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font", "hex.builtin.setting.font.font_path")
|
||||
.requiresRestart()
|
||||
.setEnabledCallback(customFontsEnabled);
|
||||
auto customFontPathSetting = ContentRegistry::Settings::add<Widgets::FilePicker>("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font", "hex.builtin.setting.font.font_path")
|
||||
.requiresRestart()
|
||||
.setEnabledCallback(customFontsEnabled);
|
||||
|
||||
const auto customFontSettingsEnabled = [customFontEnabledSetting, customFontPathSetting] {
|
||||
auto &customFontsEnabled = static_cast<Widgets::Checkbox &>(customFontEnabledSetting.getWidget());
|
||||
auto &fontPath = static_cast<Widgets::FilePicker &>(customFontPathSetting.getWidget());
|
||||
const auto customFontSettingsEnabled = [customFontEnabledSetting, customFontPathSetting] {
|
||||
auto &customFontsEnabled = static_cast<Widgets::Checkbox &>(customFontEnabledSetting.getWidget());
|
||||
auto &fontPath = static_cast<Widgets::FilePicker &>(customFontPathSetting.getWidget());
|
||||
|
||||
return customFontsEnabled.isChecked() && !fontPath.getPath().empty();
|
||||
};
|
||||
return customFontsEnabled.isChecked() && !fontPath.getPath().empty();
|
||||
};
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::Label>("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font", "hex.builtin.setting.font.custom_font_info")
|
||||
.setEnabledCallback(customFontsEnabled);
|
||||
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::SliderInteger>("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font", "hex.builtin.setting.font.font_size", 13, 0, 100)
|
||||
.requiresRestart()
|
||||
.setEnabledCallback(customFontSettingsEnabled);
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font", "hex.builtin.setting.font.font_bold", false)
|
||||
.requiresRestart()
|
||||
.setEnabledCallback(customFontSettingsEnabled);
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font", "hex.builtin.setting.font.font_italic", false)
|
||||
.requiresRestart()
|
||||
.setEnabledCallback(customFontSettingsEnabled);
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font", "hex.builtin.setting.font.font_antialias", true)
|
||||
.requiresRestart()
|
||||
.setEnabledCallback(customFontSettingsEnabled);
|
||||
ContentRegistry::Settings::add<Widgets::Label>("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font", "hex.builtin.setting.font.custom_font_info")
|
||||
.setEnabledCallback(customFontsEnabled);
|
||||
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::SliderInteger>("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font", "hex.builtin.setting.font.font_size", 13, 0, 100)
|
||||
.requiresRestart()
|
||||
.setEnabledCallback(customFontSettingsEnabled);
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font", "hex.builtin.setting.font.font_bold", false)
|
||||
.requiresRestart()
|
||||
.setEnabledCallback(customFontSettingsEnabled);
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font", "hex.builtin.setting.font.font_italic", false)
|
||||
.requiresRestart()
|
||||
.setEnabledCallback(customFontSettingsEnabled);
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font", "hex.builtin.setting.font.font_antialias", true)
|
||||
.requiresRestart()
|
||||
.setEnabledCallback(customFontSettingsEnabled);
|
||||
}
|
||||
|
||||
/* Folders */
|
||||
|
||||
ContentRegistry::Settings::setCategoryDescription("hex.builtin.setting.folders", "hex.builtin.setting.folders.description");
|
||||
ContentRegistry::Settings::add<UserFolderWidget>("hex.builtin.setting.folders", "", "hex.builtin.setting.folders.description");
|
||||
{
|
||||
ContentRegistry::Settings::setCategoryDescription("hex.builtin.setting.folders", "hex.builtin.setting.folders.description");
|
||||
ContentRegistry::Settings::add<UserFolderWidget>("hex.builtin.setting.folders", "", "hex.builtin.setting.folders.description");
|
||||
}
|
||||
|
||||
/* Proxy */
|
||||
{
|
||||
HttpRequest::setProxyUrl(ContentRegistry::Settings::read<std::string>("hex.builtin.setting.proxy", "hex.builtin.setting.proxy.url", ""));
|
||||
|
||||
HttpRequest::setProxyUrl(ContentRegistry::Settings::read<std::string>("hex.builtin.setting.proxy", "hex.builtin.setting.proxy.url", ""));
|
||||
ContentRegistry::Settings::setCategoryDescription("hex.builtin.setting.proxy", "hex.builtin.setting.proxy.description");
|
||||
|
||||
ContentRegistry::Settings::setCategoryDescription("hex.builtin.setting.proxy", "hex.builtin.setting.proxy.description");
|
||||
auto proxyEnabledSetting = ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.proxy", "", "hex.builtin.setting.proxy.enable", false)
|
||||
.setChangedCallback([](Widgets::Widget &widget) {
|
||||
auto checkBox = static_cast<Widgets::Checkbox *>(&widget);
|
||||
|
||||
auto proxyEnabledSetting = ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.proxy", "", "hex.builtin.setting.proxy.enable", false).setChangedCallback([](Widgets::Widget &widget) {
|
||||
auto checkBox = static_cast<Widgets::Checkbox *>(&widget);
|
||||
HttpRequest::setProxyState(checkBox->isChecked());
|
||||
});
|
||||
|
||||
HttpRequest::setProxyState(checkBox->isChecked());
|
||||
});
|
||||
ContentRegistry::Settings::add<Widgets::TextBox>("hex.builtin.setting.proxy", "", "hex.builtin.setting.proxy.url", "")
|
||||
.setEnabledCallback([proxyEnabledSetting] {
|
||||
auto &checkBox = static_cast<Widgets::Checkbox &>(proxyEnabledSetting.getWidget());
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::TextBox>("hex.builtin.setting.proxy", "", "hex.builtin.setting.proxy.url", "")
|
||||
.setEnabledCallback([proxyEnabledSetting] {
|
||||
auto &checkBox = static_cast<Widgets::Checkbox &>(proxyEnabledSetting.getWidget());
|
||||
|
||||
return checkBox.isChecked();
|
||||
})
|
||||
.setChangedCallback([](Widgets::Widget &widget) {
|
||||
auto textBox = static_cast<Widgets::TextBox *>(&widget);
|
||||
|
||||
HttpRequest::setProxyUrl(textBox->getValue());
|
||||
});
|
||||
return checkBox.isChecked();
|
||||
})
|
||||
.setChangedCallback([](Widgets::Widget &widget) {
|
||||
auto textBox = static_cast<Widgets::TextBox *>(&widget);
|
||||
|
||||
HttpRequest::setProxyUrl(textBox->getValue());
|
||||
});
|
||||
}
|
||||
|
||||
/* Experiments */
|
||||
ContentRegistry::Settings::setCategoryDescription("hex.builtin.setting.experiments", "hex.builtin.setting.experiments.description");
|
||||
EventImHexStartupFinished::subscribe([]{
|
||||
for (const auto &[name, experiment] : ContentRegistry::Experiments::impl::getExperiments()) {
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.experiments", "", experiment.unlocalizedName, false)
|
||||
{
|
||||
ContentRegistry::Settings::setCategoryDescription("hex.builtin.setting.experiments", "hex.builtin.setting.experiments.description");
|
||||
EventImHexStartupFinished::subscribe([]{
|
||||
for (const auto &[name, experiment] : ContentRegistry::Experiments::impl::getExperiments()) {
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.experiments", "", experiment.unlocalizedName, false)
|
||||
.setTooltip(Lang(experiment.unlocalizedDescription))
|
||||
.setChangedCallback([name](Widgets::Widget &widget) {
|
||||
auto checkBox = static_cast<Widgets::Checkbox *>(&widget);
|
||||
|
||||
ContentRegistry::Experiments::enableExperiement(name, checkBox->isChecked());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* Shorcuts */
|
||||
EventImHexStartupFinished::subscribe([]{
|
||||
for (const auto &shortcutEntry : ShortcutManager::getGlobalShortcuts()) {
|
||||
ContentRegistry::Settings::add<KeybindingWidget>("hex.builtin.setting.shortcuts", "hex.builtin.setting.shortcuts.global", shortcutEntry.unlocalizedName, nullptr, shortcutEntry.shortcut);
|
||||
}
|
||||
|
||||
for (auto &[viewName, view] : ContentRegistry::Views::impl::getEntries()) {
|
||||
for (const auto &shortcutEntry : ShortcutManager::getViewShortcuts(view.get())) {
|
||||
ContentRegistry::Settings::add<KeybindingWidget>("hex.builtin.setting.shortcuts", viewName, shortcutEntry.unlocalizedName, view.get(), shortcutEntry.shortcut);
|
||||
{
|
||||
EventImHexStartupFinished::subscribe([]{
|
||||
for (const auto &shortcutEntry : ShortcutManager::getGlobalShortcuts()) {
|
||||
ContentRegistry::Settings::add<KeybindingWidget>("hex.builtin.setting.shortcuts", "hex.builtin.setting.shortcuts.global", shortcutEntry.unlocalizedName, nullptr, shortcutEntry.shortcut);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/* Toolbar icons */
|
||||
ContentRegistry::Settings::setCategoryDescription("hex.builtin.setting.toolbar", "hex.builtin.setting.toolbar.description");
|
||||
for (auto &[viewName, view] : ContentRegistry::Views::impl::getEntries()) {
|
||||
for (const auto &shortcutEntry : ShortcutManager::getViewShortcuts(view.get())) {
|
||||
ContentRegistry::Settings::add<KeybindingWidget>("hex.builtin.setting.shortcuts", viewName, shortcutEntry.unlocalizedName, view.get(), shortcutEntry.shortcut);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ContentRegistry::Settings::add<ToolbarIconsWidget>("hex.builtin.setting.toolbar", "", "hex.builtin.setting.toolbar.icons");
|
||||
/* Toolbar icons */
|
||||
{
|
||||
ContentRegistry::Settings::setCategoryDescription("hex.builtin.setting.toolbar", "hex.builtin.setting.toolbar.description");
|
||||
|
||||
ContentRegistry::Settings::add<ToolbarIconsWidget>("hex.builtin.setting.toolbar", "", "hex.builtin.setting.toolbar.icons");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -326,7 +326,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ImGui::BeginDisabled(!providerValid || tasksRunning);
|
||||
{
|
||||
auto &providers = ImHexApi::Provider::getProviders();
|
||||
auto providers = ImHexApi::Provider::getProviders();
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_TabActive, ImGui::GetColorU32(ImGuiCol_MenuBarBg));
|
||||
ImGui::PushStyleColor(ImGuiCol_TabUnfocusedActive, ImGui::GetColorU32(ImGuiCol_MenuBarBg));
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "content/views/view_highlight_rules.hpp"
|
||||
#include "content/views/view_tutorials.hpp"
|
||||
|
||||
#include <hex/api/layout_manager.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
void registerViews() {
|
||||
@@ -44,6 +46,20 @@ namespace hex::plugin::builtin {
|
||||
ContentRegistry::Views::add<ViewAchievements>();
|
||||
ContentRegistry::Views::add<ViewHighlightRules>();
|
||||
ContentRegistry::Views::add<ViewTutorials>();
|
||||
|
||||
|
||||
LayoutManager::registerLoadCallback([](std::string_view line) {
|
||||
for (auto &[name, view] : ContentRegistry::Views::impl::getEntries()) {
|
||||
std::string format = hex::format("{}=%d", view->getUnlocalizedName().get());
|
||||
sscanf(line.data(), format.c_str(), &view->getWindowOpenState());
|
||||
}
|
||||
});
|
||||
|
||||
LayoutManager::registerStoreCallback([](ImGuiTextBuffer *buffer) {
|
||||
for (auto &[name, view] : ContentRegistry::Views::impl::getEntries()) {
|
||||
buffer->appendf("%s=%d\n", name.c_str(), view->getWindowOpenState());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -160,7 +160,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
void drawOverlay(ImDrawList *drawList, ImVec2 windowMin, ImVec2 windowMax, const std::string &currCategory) {
|
||||
auto &achievements = AchievementManager::getAchievements()[currCategory];
|
||||
auto &achievements = AchievementManager::getAchievements().at(currCategory);
|
||||
|
||||
// Calculate number of achievements that have been unlocked
|
||||
const auto unlockedCount = std::count_if(achievements.begin(), achievements.end(), [](const auto &entry) {
|
||||
@@ -313,7 +313,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
// Draw each individual achievement category
|
||||
for (const auto &categoryName : categories) {
|
||||
const auto &achievements = startNodes[categoryName];
|
||||
const auto &achievements = startNodes.at(categoryName);
|
||||
|
||||
// Check if any achievements in the category are unlocked or unlockable
|
||||
bool visible = false;
|
||||
|
||||
@@ -803,7 +803,7 @@ namespace hex::plugin::builtin {
|
||||
RequestHexEditorSelectionChange::subscribe(this, [this](Region region) {
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
|
||||
if (region == Region::Invalid()) {
|
||||
if (region == Region::Invalid() || provider == nullptr) {
|
||||
m_selectionStart->reset();
|
||||
m_selectionEnd->reset();
|
||||
EventRegionSelected::post(ImHexApi::HexEditor::ProviderRegion({ Region::Invalid(), nullptr }));
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <imgui_internal.h>
|
||||
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/layout_manager.hpp>
|
||||
|
||||
#include <fonts/codicons_font.h>
|
||||
|
||||
@@ -9,6 +10,21 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ViewTools::ViewTools() : View::Window("hex.builtin.view.tools.name", ICON_VS_TOOLS) {
|
||||
m_dragStartIterator = ContentRegistry::Tools::impl::getEntries().end();
|
||||
|
||||
LayoutManager::registerLoadCallback([this](std::string_view line) {
|
||||
auto parts = wolv::util::splitString(std::string(line), "=");
|
||||
if (parts.size() != 2)
|
||||
return;
|
||||
|
||||
m_detachedTools[parts[0]] = parts[1] == "1";
|
||||
});
|
||||
|
||||
LayoutManager::registerStoreCallback([this](ImGuiTextBuffer *buffer) {
|
||||
for (auto &[unlocalizedName, function] : ContentRegistry::Tools::impl::getEntries()) {
|
||||
auto detached = m_detachedTools[unlocalizedName];
|
||||
buffer->appendf("%s=%d\n", unlocalizedName.get().c_str(), detached);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void ViewTools::drawContent() {
|
||||
@@ -16,13 +32,13 @@ namespace hex::plugin::builtin {
|
||||
|
||||
// Draw all tools
|
||||
for (auto iter = tools.begin(); iter != tools.end(); ++iter) {
|
||||
auto &[name, function, detached] = *iter;
|
||||
auto &[unlocalizedName, function] = *iter;
|
||||
|
||||
// If the tool has been detached from the main window, don't draw it here anymore
|
||||
if (detached) continue;
|
||||
if (m_detachedTools[unlocalizedName]) continue;
|
||||
|
||||
// Draw the tool
|
||||
if (ImGui::CollapsingHeader(Lang(name))) {
|
||||
if (ImGui::CollapsingHeader(Lang(unlocalizedName))) {
|
||||
function();
|
||||
ImGui::NewLine();
|
||||
} else {
|
||||
@@ -38,7 +54,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
// Detach the tool if the user dragged it out of the main window
|
||||
if (!ImGui::IsItemHovered() && m_dragStartIterator == iter) {
|
||||
detached = true;
|
||||
m_detachedTools[unlocalizedName] = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -53,19 +69,19 @@ namespace hex::plugin::builtin {
|
||||
auto &tools = ContentRegistry::Tools::impl::getEntries();
|
||||
|
||||
for (auto iter = tools.begin(); iter != tools.end(); ++iter) {
|
||||
auto &[name, function, detached] = *iter;
|
||||
auto &[unlocalizedName, function] = *iter;
|
||||
|
||||
// If the tool is still attached to the main window, don't draw it here
|
||||
if (!detached) continue;
|
||||
if (!m_detachedTools[unlocalizedName]) continue;
|
||||
|
||||
// Load the window height that is dependent on the tool content
|
||||
const auto windowName = View::toWindowName(name);
|
||||
const auto windowName = View::toWindowName(unlocalizedName);
|
||||
const auto height = m_windowHeights[ImGui::FindWindowByName(windowName.c_str())];
|
||||
if (height > 0)
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(400_scaled, height), ImVec2(FLT_MAX, height));
|
||||
|
||||
// Create a new window for the tool
|
||||
if (ImGui::Begin(windowName.c_str(), &detached, ImGuiWindowFlags_NoCollapse)) {
|
||||
if (ImGui::Begin(windowName.c_str(), &m_detachedTools[unlocalizedName], ImGuiWindowFlags_NoCollapse)) {
|
||||
// Draw the tool content
|
||||
function();
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
if (ImGuiExt::DescriptionButton("hex.builtin.welcome.update.title"_lang, hex::format("hex.builtin.welcome.update.desc"_lang, ImHexApi::System::getInitArguments()["update-available"]).c_str(), ImVec2(ImGui::GetContentRegionAvail().x * 0.8F, 0)))
|
||||
if (ImGuiExt::DescriptionButton("hex.builtin.welcome.update.title"_lang, hex::format("hex.builtin.welcome.update.desc"_lang, ImHexApi::System::getInitArgument("update-available")).c_str(), ImVec2(ImGui::GetContentRegionAvail().x * 0.8F, 0)))
|
||||
ImHexApi::System::updateImHex(ImHexApi::System::UpdateType::Stable);
|
||||
}
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ namespace hex::plugin::builtin {
|
||||
#endif
|
||||
}
|
||||
|
||||
auto &titleBarButtons = ContentRegistry::Interface::impl::getTitleBarButtons();
|
||||
auto &titleBarButtons = ContentRegistry::Interface::impl::getTitlebarButtons();
|
||||
|
||||
// Draw custom title bar buttons
|
||||
if (!titleBarButtons.empty()) {
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace hex::plugin::diffing {
|
||||
|
||||
ImGui::PushID(&column);
|
||||
|
||||
auto &providers = ImHexApi::Provider::getProviders();
|
||||
auto providers = ImHexApi::Provider::getProviders();
|
||||
auto &providerIndex = column.provider;
|
||||
|
||||
// Get the name of the currently selected provider
|
||||
|
||||
Reference in New Issue
Block a user