2021-05-29 21:52:18 +02:00
|
|
|
#include <hex/plugin.hpp>
|
|
|
|
|
2022-02-01 18:09:40 +01:00
|
|
|
#include <hex/api/content_registry.hpp>
|
|
|
|
|
2022-02-15 22:50:04 +01:00
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
|
2021-05-29 21:52:18 +02:00
|
|
|
#include "views/view_tty_console.hpp"
|
|
|
|
|
2022-02-15 22:50:04 +01:00
|
|
|
using namespace hex;
|
|
|
|
|
2021-06-06 18:19:17 +02:00
|
|
|
namespace hex::plugin::windows {
|
|
|
|
|
|
|
|
void registerLanguageEnUS();
|
2022-02-02 00:36:25 +01:00
|
|
|
void registerLanguageDeDE();
|
2021-09-20 18:41:22 +02:00
|
|
|
void registerLanguageZhCN();
|
2022-06-03 11:34:31 +02:00
|
|
|
void registerLanguagePtBR();
|
2022-07-27 16:47:03 +02:00
|
|
|
void registerLanguageZhTW();
|
2021-06-06 18:19:17 +02:00
|
|
|
|
2021-06-06 19:17:51 +02:00
|
|
|
void addFooterItems();
|
2022-02-02 00:36:09 +01:00
|
|
|
void addTitleBarButtons();
|
2021-10-31 16:28:10 +01:00
|
|
|
void registerSettings();
|
2021-06-06 18:19:17 +02:00
|
|
|
}
|
|
|
|
|
2022-02-15 22:50:04 +01:00
|
|
|
static void detectSystemTheme() {
|
|
|
|
// Setup system theme change detector
|
|
|
|
bool themeFollowSystem = ContentRegistry::Settings::getSetting("hex.builtin.setting.interface", "hex.builtin.setting.interface.color") == 0;
|
|
|
|
EventManager::subscribe<EventOSThemeChanged>([themeFollowSystem] {
|
|
|
|
if (!themeFollowSystem) return;
|
|
|
|
|
|
|
|
HKEY hkey;
|
|
|
|
if (RegOpenKey(HKEY_CURRENT_USER, R"(Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)", &hkey) == ERROR_SUCCESS) {
|
|
|
|
DWORD value = 0;
|
|
|
|
DWORD size = sizeof(DWORD);
|
|
|
|
|
|
|
|
auto error = RegQueryValueEx(hkey, "AppsUseLightTheme", nullptr, nullptr, reinterpret_cast<LPBYTE>(&value), &size);
|
|
|
|
if (error == ERROR_SUCCESS) {
|
|
|
|
EventManager::post<RequestChangeTheme>(value == 0 ? 1 : 2);
|
2022-06-30 15:09:57 +02:00
|
|
|
} else {
|
|
|
|
EventManager::post<RequestChangeTheme>(1);
|
2022-02-15 22:50:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
EventManager::subscribe<EventWindowInitialized>([=] {
|
|
|
|
if (themeFollowSystem)
|
|
|
|
EventManager::post<EventOSThemeChanged>();
|
|
|
|
});
|
|
|
|
}
|
2021-06-06 18:19:17 +02:00
|
|
|
|
2022-02-15 23:07:48 +01:00
|
|
|
static void checkBorderlessWindowOverride() {
|
|
|
|
bool borderlessWindowForced = ContentRegistry::Settings::read("hex.builtin.setting.interface", "hex.builtin.setting.interface.force_borderless_window_mode", 0) != 0;
|
|
|
|
|
|
|
|
if (borderlessWindowForced)
|
|
|
|
ImHexApi::System::impl::setBorderlessWindowMode(true);
|
|
|
|
}
|
|
|
|
|
2021-05-29 21:52:18 +02:00
|
|
|
IMHEX_PLUGIN_SETUP("Windows", "WerWolv", "Windows-only features") {
|
2021-06-06 18:19:17 +02:00
|
|
|
using namespace hex::plugin::windows;
|
|
|
|
|
|
|
|
registerLanguageEnUS();
|
2022-02-02 00:36:25 +01:00
|
|
|
registerLanguageDeDE();
|
2021-09-20 18:41:22 +02:00
|
|
|
registerLanguageZhCN();
|
2022-06-03 11:34:31 +02:00
|
|
|
registerLanguagePtBR();
|
2022-07-27 16:47:03 +02:00
|
|
|
registerLanguageZhTW();
|
|
|
|
|
2022-02-16 21:32:33 +01:00
|
|
|
hex::ContentRegistry::Views::add<ViewTTYConsole>();
|
|
|
|
|
2021-06-06 19:17:51 +02:00
|
|
|
addFooterItems();
|
2022-02-02 00:36:09 +01:00
|
|
|
addTitleBarButtons();
|
2021-10-31 16:28:10 +01:00
|
|
|
registerSettings();
|
2022-02-15 22:50:04 +01:00
|
|
|
|
|
|
|
detectSystemTheme();
|
2022-02-15 23:07:48 +01:00
|
|
|
checkBorderlessWindowOverride();
|
2021-05-29 21:52:18 +02:00
|
|
|
}
|