1
0
mirror of synced 2025-02-17 18:59:21 +01:00

sys: Remove remaining references to hex.builtin from libimhex

This commit is contained in:
WerWolv 2022-07-02 17:53:13 +02:00
parent 0ed885fe0f
commit de269e7a48
20 changed files with 240 additions and 178 deletions

View File

@ -129,6 +129,12 @@ namespace hex {
EVENT_DEF(RequestOpenPopup, std::string);
EVENT_DEF(RequestCreateProvider, std::string, hex::prv::Provider **);
EVENT_DEF(RequestShowInfoPopup, std::string);
EVENT_DEF(RequestShowErrorPopup, std::string);
EVENT_DEF(RequestShowFatalErrorPopup, std::string);
EVENT_DEF(RequestShowYesNoQuestionPopup, std::string, std::function<void()>, std::function<void()>);
EVENT_DEF(RequestShowFileChooserPopup, std::vector<std::fs::path>, std::vector<nfdfilteritem_t>, std::function<void(std::fs::path)>);
EVENT_DEF(QuerySelection, std::optional<Region> &);
}

View File

@ -162,6 +162,8 @@ namespace hex {
void setCustomFontPath(const std::fs::path &path);
void setFontSize(float size);
void setGPUVendor(const std::string &vendor);
}
struct ProgramArguments {
@ -199,6 +201,11 @@ namespace hex {
void enableSystemThemeDetection(bool enabled);
bool usesSystemThemeDetection();
const std::vector<std::fs::path> &getAdditionalFolderPaths();
void setAdditionalFolderPaths(const std::vector<std::fs::path> &paths);
const std::string &getGPUVendor();
}
}

View File

@ -34,11 +34,9 @@ namespace hex {
[[nodiscard]] virtual bool isAvailable() const;
[[nodiscard]] virtual bool shouldProcess() const { return this->isAvailable() && this->getWindowOpenState(); }
static void drawCommonInterfaces();
static void showMessagePopup(const std::string &message);
static void showErrorPopup(const std::string &errorMessage);
static void showFatalPopup(const std::string &errorMessage);
static void showInfoPopup(const std::string &message);
static void showErrorPopup(const std::string &message);
static void showFatalPopup(const std::string &message);
static void showYesNoQuestionPopup(const std::string &message, const std::function<void()> &yesCallback, const std::function<void()> &noCallback);
static void showFileChooserPopup(const std::vector<std::fs::path> &paths, const std::vector<nfdfilteritem_t> &validExtensions, const std::function<void(std::fs::path)> &callback);
@ -71,15 +69,6 @@ namespace hex {
bool m_windowOpen = false;
std::map<Shortcut, std::function<void()>> m_shortcuts;
static std::string s_popupMessage;
static std::function<void()> s_yesCallback, s_noCallback;
static u32 s_selectableFileIndex;
static std::vector<std::fs::path> s_selectableFiles;
static std::function<void(std::fs::path)> s_selectableFileOpenCallback;
static std::vector<nfdfilteritem_t> s_selectableFilesValidExtensions;
static ImFontAtlas *s_fontAtlas;
static ImFontConfig s_fontConfig;

View File

@ -328,6 +328,11 @@ namespace hex {
s_fontSize = size;
}
static std::string s_gpuVendor;
void setGPUVendor(const std::string &vendor) {
s_gpuVendor = vendor;
}
}
@ -406,6 +411,21 @@ namespace hex {
bool usesSystemThemeDetection() {
return s_systemThemeDetection;
}
static std::vector<std::fs::path> s_additionalFolderPaths;
const std::vector<std::fs::path> &getAdditionalFolderPaths() {
return s_additionalFolderPaths;
}
void setAdditionalFolderPaths(const std::vector<std::fs::path> &paths) {
s_additionalFolderPaths = paths;
}
const std::string &getGPUVendor() {
return impl::s_gpuVendor;
}
}
}

View File

@ -100,8 +100,7 @@ namespace hex::fs {
std::vector<std::fs::path> getDefaultPaths(ImHexPath path, bool listNonExisting) {
std::vector<std::fs::path> result;
const auto exePath = getExecutablePath();
const std::string settingName { "hex.builtin.setting.folders" };
auto userDirs = ContentRegistry::Settings::read(settingName, settingName, std::vector<std::string> {});
auto userDirs = ImHexApi::System::getAdditionalFolderPaths();
[[maybe_unused]]
auto addUserDirs = [&userDirs](auto &paths) {

View File

@ -2,25 +2,17 @@
#include <hex.hpp>
#include <hex/api/content_registry.hpp>
#include <hex/api/event.hpp>
#include <hex/ui/view.hpp>
#include <cmath>
#include <cstring>
#include <map>
#include <optional>
#include <string>
#include <pl/pattern_language.hpp>
namespace hex::prv {
Provider::Provider() {
this->m_patches.emplace_back();
this->m_patternLanguageRuntime = ContentRegistry::PatternLanguage::createDefaultRuntime(this);
if (this->hasLoadInterface())
EventManager::post<RequestOpenPopup>(View::toWindowName("hex.builtin.view.provider_settings.load_popup"));
}
Provider::~Provider() {

View File

@ -8,15 +8,6 @@
namespace hex {
std::string View::s_popupMessage;
std::function<void()> View::s_yesCallback, View::s_noCallback;
u32 View::s_selectableFileIndex;
std::vector<std::fs::path> View::s_selectableFiles;
std::function<void(std::fs::path)> View::s_selectableFileOpenCallback;
std::vector<nfdfilteritem_t> View::s_selectableFilesValidExtensions;
ImFontAtlas *View::s_fontAtlas;
ImFontConfig View::s_fontConfig;
@ -26,123 +17,21 @@ namespace hex {
return ImHexApi::Provider::isValid() && ImHexApi::Provider::get()->isAvailable();
}
void View::drawCommonInterfaces() {
auto windowSize = ImHexApi::System::getMainWindowSize();
ImGui::SetNextWindowSizeConstraints(scaled(ImVec2(400, 100)), scaled(ImVec2(600, 300)));
if (ImGui::BeginPopupModal("hex.builtin.common.info"_lang, nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::TextFormattedWrapped("{}", s_popupMessage.c_str());
ImGui::NewLine();
ImGui::Separator();
if (ImGui::Button("hex.builtin.common.okay"_lang) || ImGui::IsKeyDown(ImGuiKey_Escape))
ImGui::CloseCurrentPopup();
ImGui::SetWindowPos((windowSize - ImGui::GetWindowSize()) / 2, ImGuiCond_Appearing);
ImGui::EndPopup();
}
ImGui::SetNextWindowSizeConstraints(scaled(ImVec2(400, 100)), scaled(ImVec2(600, 300)));
if (ImGui::BeginPopupModal("hex.builtin.common.error"_lang, nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::TextFormattedWrapped("{}", s_popupMessage.c_str());
ImGui::NewLine();
ImGui::Separator();
if (ImGui::Button("hex.builtin.common.okay"_lang) || ImGui::IsKeyDown(ImGuiKey_Escape))
ImGui::CloseCurrentPopup();
ImGui::SetWindowPos((windowSize - ImGui::GetWindowSize()) / 2, ImGuiCond_Appearing);
ImGui::EndPopup();
}
ImGui::SetNextWindowSizeConstraints(scaled(ImVec2(400, 100)), scaled(ImVec2(600, 300)));
if (ImGui::BeginPopupModal("hex.builtin.common.fatal"_lang, nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::TextFormattedWrapped("{}", s_popupMessage.c_str());
ImGui::NewLine();
ImGui::Separator();
if (ImGui::Button("hex.builtin.common.okay"_lang) || ImGui::IsKeyDown(ImGuiKey_Escape)) {
ImHexApi::Common::closeImHex();
ImGui::CloseCurrentPopup();
}
ImGui::SetWindowPos((windowSize - ImGui::GetWindowSize()) / 2, ImGuiCond_Appearing);
ImGui::EndPopup();
}
ImGui::SetNextWindowSizeConstraints(scaled(ImVec2(400, 100)), scaled(ImVec2(600, 300)));
if (ImGui::BeginPopupModal("hex.builtin.common.question"_lang, nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::TextFormattedWrapped("{}", s_popupMessage.c_str());
ImGui::NewLine();
ImGui::Separator();
View::confirmButtons(
"hex.builtin.common.yes"_lang, "hex.builtin.common.no"_lang, [] {
s_yesCallback();
ImGui::CloseCurrentPopup(); }, [] {
s_noCallback();
ImGui::CloseCurrentPopup(); });
ImGui::SetWindowPos((windowSize - ImGui::GetWindowSize()) / 2, ImGuiCond_Appearing);
ImGui::EndPopup();
}
bool opened = true;
ImGui::SetNextWindowPos(ImGui::GetMainViewport()->GetCenter(), ImGuiCond_Appearing, ImVec2(0.5F, 0.5F));
if (ImGui::BeginPopupModal("hex.builtin.common.choose_file"_lang, &opened, ImGuiWindowFlags_AlwaysAutoResize)) {
if (ImGui::BeginListBox("##files", ImVec2(300_scaled, 0))) {
u32 index = 0;
for (auto &path : View::s_selectableFiles) {
if (ImGui::Selectable(path.filename().string().c_str(), index == View::s_selectableFileIndex))
View::s_selectableFileIndex = index;
index++;
}
ImGui::EndListBox();
}
if (ImGui::Button("hex.builtin.common.open"_lang)) {
View::s_selectableFileOpenCallback(View::s_selectableFiles[View::s_selectableFileIndex]);
ImGui::CloseCurrentPopup();
}
ImGui::SameLine();
if (ImGui::Button("hex.builtin.common.browse"_lang)) {
fs::openFileBrowser(fs::DialogMode::Open, View::s_selectableFilesValidExtensions, [](const auto &path) {
View::s_selectableFileOpenCallback(path);
ImGui::CloseCurrentPopup();
});
}
ImGui::EndPopup();
}
void View::showInfoPopup(const std::string &message) {
EventManager::post<RequestShowInfoPopup>(message);
}
void View::showMessagePopup(const std::string &message) {
s_popupMessage = message;
ImHexApi::Tasks::doLater([] { ImGui::OpenPopup("hex.builtin.common.info"_lang); });
void View::showErrorPopup(const std::string &message) {
EventManager::post<RequestShowErrorPopup>(message);
}
void View::showErrorPopup(const std::string &errorMessage) {
s_popupMessage = errorMessage;
ImHexApi::Tasks::doLater([] { ImGui::OpenPopup("hex.builtin.common.error"_lang); });
}
void View::showFatalPopup(const std::string &errorMessage) {
s_popupMessage = errorMessage;
ImHexApi::Tasks::doLater([] { ImGui::OpenPopup("hex.builtin.common.fatal"_lang); });
void View::showFatalPopup(const std::string &message) {
EventManager::post<RequestShowFatalErrorPopup>(message);
}
void View::showYesNoQuestionPopup(const std::string &message, const std::function<void()> &yesCallback, const std::function<void()> &noCallback) {
s_popupMessage = message;
EventManager::post<RequestShowYesNoQuestionPopup>(message, yesCallback, noCallback);
s_yesCallback = yesCallback;
s_noCallback = noCallback;
ImHexApi::Tasks::doLater([] { ImGui::OpenPopup("hex.builtin.common.question"_lang); });
}
void View::showFileChooserPopup(const std::vector<std::fs::path> &paths, const std::vector<nfdfilteritem_t> &validExtensions, const std::function<void(std::fs::path)> &callback) {
@ -151,12 +40,7 @@ namespace hex {
callback(path);
});
} else {
View::s_selectableFileIndex = 0;
View::s_selectableFiles = paths;
View::s_selectableFilesValidExtensions = validExtensions;
View::s_selectableFileOpenCallback = callback;
ImHexApi::Tasks::doLater([] { ImGui::OpenPopup("hex.builtin.common.choose_file"_lang); });
EventManager::post<RequestShowFileChooserPopup>(paths, validExtensions, callback);
}
}

View File

@ -23,8 +23,6 @@ namespace hex::init {
this->m_tasks.emplace_back(taskName, task);
}
[[nodiscard]] const std::string &getGPUVendor() const { return this->m_gpuVendor; }
private:
GLFWwindow *m_window;
std::mutex m_progressMutex;

View File

@ -30,7 +30,7 @@ namespace hex::init {
this->initGLFW();
this->initImGui();
this->m_gpuVendor = reinterpret_cast<const char *>(glGetString(GL_VENDOR));
ImHexApi::System::impl::setGPUVendor(reinterpret_cast<const char *>(glGetString(GL_VENDOR)));
}
WindowSplash::~WindowSplash() {

View File

@ -25,17 +25,6 @@ int main(int argc, char **argv, char **envp) {
init::WindowSplash splashWindow;
// Intel's OpenGL driver has weird bugs that cause the drawn window to be offset to the bottom right.
// This can be fixed by either using Mesa3D's OpenGL Software renderer or by simply disabling it.
// If you want to try if it works anyways on your GPU, set the hex.builtin.setting.interface.force_borderless_window_mode setting to 1
if (ImHexApi::System::isBorderlessWindowModeEnabled()) {
bool isIntelGPU = hex::containsIgnoreCase(splashWindow.getGPUVendor(), "Intel");
ImHexApi::System::impl::setBorderlessWindowMode(!isIntelGPU);
if (isIntelGPU)
log::warn("Intel GPU detected! Intel's OpenGL driver has bugs that can cause issues when using ImHex. If you experience any rendering bugs, please try the Mesa3D Software Renderer");
}
for (const auto &[name, task] : init::getInitTasks())
splashWindow.addStartupTask(name, task);

View File

@ -2,6 +2,7 @@
#if defined(OS_LINUX)
#include <hex/api/imhex_api.hpp>
#include <hex/api/content_registry.hpp>
#include <hex/api/event.hpp>

View File

@ -2,6 +2,7 @@
#if defined(OS_MACOS)
#include <hex/api/imhex_api.hpp>
#include <hex/api/content_registry.hpp>
#include <hex/api/event.hpp>

View File

@ -421,8 +421,6 @@ namespace hex {
calls.clear();
}
View::drawCommonInterfaces();
for (auto &[name, view] : ContentRegistry::Views::getEntries()) {
ImGui::GetCurrentContext()->NextWindowData.ClearFlags();

View File

@ -1,6 +1,7 @@
#include <hex/api/event.hpp>
#include <hex/api/content_registry.hpp>
#include <hex/providers/provider.hpp>
#include <hex/ui/view.hpp>
#include <hex/helpers/project_file_handler.hpp>
#include <hex/api/localization.hpp>
@ -88,6 +89,11 @@ namespace hex::plugin::builtin {
EventManager::subscribe<EventProviderChanged>([](auto, auto) {
EventManager::post<EventHighlightingChanged>();
});
EventManager::subscribe<EventProviderCreated>([](hex::prv::Provider *provider) {
if (provider->hasLoadInterface())
EventManager::post<RequestOpenPopup>(View::toWindowName("hex.builtin.view.provider_settings.load_popup"));
});
}
}

View File

@ -314,17 +314,34 @@ namespace hex::plugin::builtin {
ContentRegistry::Settings::add(dirsSetting, dirsSetting, std::vector<std::string> {}, [](auto name, nlohmann::json &setting) {
hex::unused(name);
static std::vector<std::string> folders = setting;
static size_t currentItemIndex = 0;
static size_t currentItemIndex = 0;
static std::vector<std::fs::path> folders = [&setting]{
std::vector<std::fs::path> result;
std::vector<std::u8string> paths = setting;
for (const auto &path : paths)
result.emplace_back(path);
return result;
}();
bool result = false;
auto writeSetting = [&setting]{
std::vector<std::u8string> folderStrings;
for (const auto &folder : folders)
folderStrings.push_back(folder.u8string());
setting = folderStrings;
ImHexApi::System::setAdditionalFolderPaths(folders);
};
if (!ImGui::BeginListBox("", ImVec2(-38, -FLT_MIN))) {
return false;
} else {
for (size_t n = 0; n < folders.size(); n++) {
const bool isSelected = (currentItemIndex == n);
if (ImGui::Selectable(folders.at(n).c_str(), isSelected)) { currentItemIndex = n; }
if (ImGui::Selectable(folders.at(n).string().c_str(), isSelected)) { currentItemIndex = n; }
if (isSelected) { ImGui::SetItemDefaultFocus(); }
}
ImGui::EndListBox();
@ -334,11 +351,12 @@ namespace hex::plugin::builtin {
if (ImGui::IconButton(ICON_VS_NEW_FOLDER, ImGui::GetCustomColorVec4(ImGuiCustomCol_DescButton), ImVec2(30, 30))) {
fs::openFileBrowser(fs::DialogMode::Folder, {}, [&](const std::fs::path &path) {
auto pathStr = path.string();
if (std::find(folders.begin(), folders.end(), pathStr) == folders.end()) {
folders.emplace_back(pathStr);
ContentRegistry::Settings::write(dirsSetting, dirsSetting, folders);
if (std::find(folders.begin(), folders.end(), path) == folders.end()) {
folders.emplace_back(path);
writeSetting();
result = true;
}
});
@ -348,7 +366,9 @@ namespace hex::plugin::builtin {
if (ImGui::IconButton(ICON_VS_REMOVE_CLOSE, ImGui::GetCustomColorVec4(ImGuiCustomCol_DescButton), ImVec2(30, 30))) {
if (!folders.empty()) {
folders.erase(std::next(folders.begin(), currentItemIndex));
ContentRegistry::Settings::write(dirsSetting, dirsSetting, folders);
writeSetting();
result = true;
}
}

View File

@ -853,7 +853,7 @@ namespace hex::plugin::builtin {
file.remove();
View::showMessagePopup("hex.builtin.tools.file_tools.shredder.success"_lang);
View::showInfoPopup("hex.builtin.tools.file_tools.shredder.success"_lang);
}).detach();
}
}
@ -976,7 +976,7 @@ namespace hex::plugin::builtin {
index++;
}
View::showMessagePopup("hex.builtin.tools.file_tools.splitter.success"_lang);
View::showInfoPopup("hex.builtin.tools.file_tools.splitter.success"_lang);
}).detach();
}
}
@ -1110,7 +1110,7 @@ namespace hex::plugin::builtin {
selectedIndex = 0;
outputPath.clear();
View::showMessagePopup("hex.builtin.tools.file_tools.combiner.success"_lang);
View::showInfoPopup("hex.builtin.tools.file_tools.combiner.success"_lang);
}).detach();
}
}

View File

@ -4,6 +4,7 @@
#include <hex/ui/view.hpp>
#include <hex/helpers/utils.hpp>
#include <hex/helpers/fmt.hpp>
#include <hex/helpers/logger.hpp>
#include <codicons_font.h>
#include <imgui.h>
@ -12,6 +13,13 @@
namespace hex::plugin::builtin {
static std::string s_popupMessage;
static std::function<void()> s_yesCallback, s_noCallback;
static u32 s_selectableFileIndex;
static std::vector<std::fs::path> s_selectableFiles;
static std::function<void(std::fs::path)> s_selectableFileOpenCallback;
static std::vector<nfdfilteritem_t> s_selectableFilesValidExtensions;
static void drawGlobalPopups() {
// "Are you sure you want to exit?" Popup
@ -28,10 +36,141 @@ namespace hex::plugin::builtin {
ImGui::EndPopup();
}
auto windowSize = ImHexApi::System::getMainWindowSize();
// Info popup
ImGui::SetNextWindowSizeConstraints(scaled(ImVec2(400, 100)), scaled(ImVec2(600, 300)));
if (ImGui::BeginPopupModal("hex.builtin.common.info"_lang, nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::TextFormattedWrapped("{}", s_popupMessage.c_str());
ImGui::NewLine();
ImGui::Separator();
if (ImGui::Button("hex.builtin.common.okay"_lang) || ImGui::IsKeyDown(ImGuiKey_Escape))
ImGui::CloseCurrentPopup();
ImGui::SetWindowPos((windowSize - ImGui::GetWindowSize()) / 2, ImGuiCond_Appearing);
ImGui::EndPopup();
}
// Error popup
ImGui::SetNextWindowSizeConstraints(scaled(ImVec2(400, 100)), scaled(ImVec2(600, 300)));
if (ImGui::BeginPopupModal("hex.builtin.common.error"_lang, nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::TextFormattedWrapped("{}", s_popupMessage.c_str());
ImGui::NewLine();
ImGui::Separator();
if (ImGui::Button("hex.builtin.common.okay"_lang) || ImGui::IsKeyDown(ImGuiKey_Escape))
ImGui::CloseCurrentPopup();
ImGui::SetWindowPos((windowSize - ImGui::GetWindowSize()) / 2, ImGuiCond_Appearing);
ImGui::EndPopup();
}
// Fatal error popup
ImGui::SetNextWindowSizeConstraints(scaled(ImVec2(400, 100)), scaled(ImVec2(600, 300)));
if (ImGui::BeginPopupModal("hex.builtin.common.fatal"_lang, nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::TextFormattedWrapped("{}", s_popupMessage.c_str());
ImGui::NewLine();
ImGui::Separator();
if (ImGui::Button("hex.builtin.common.okay"_lang) || ImGui::IsKeyDown(ImGuiKey_Escape)) {
ImHexApi::Common::closeImHex();
ImGui::CloseCurrentPopup();
}
ImGui::SetWindowPos((windowSize - ImGui::GetWindowSize()) / 2, ImGuiCond_Appearing);
ImGui::EndPopup();
}
// Yes/No question popup
ImGui::SetNextWindowSizeConstraints(scaled(ImVec2(400, 100)), scaled(ImVec2(600, 300)));
if (ImGui::BeginPopupModal("hex.builtin.common.question"_lang, nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::TextFormattedWrapped("{}", s_popupMessage.c_str());
ImGui::NewLine();
ImGui::Separator();
View::confirmButtons(
"hex.builtin.common.yes"_lang, "hex.builtin.common.no"_lang, [] {
s_yesCallback();
ImGui::CloseCurrentPopup(); }, [] {
s_noCallback();
ImGui::CloseCurrentPopup(); });
ImGui::SetWindowPos((windowSize - ImGui::GetWindowSize()) / 2, ImGuiCond_Appearing);
ImGui::EndPopup();
}
// File chooser popup
bool opened = true;
ImGui::SetNextWindowPos(ImGui::GetMainViewport()->GetCenter(), ImGuiCond_Appearing, ImVec2(0.5F, 0.5F));
if (ImGui::BeginPopupModal("hex.builtin.common.choose_file"_lang, &opened, ImGuiWindowFlags_AlwaysAutoResize)) {
if (ImGui::BeginListBox("##files", ImVec2(300_scaled, 0))) {
u32 index = 0;
for (auto &path : s_selectableFiles) {
if (ImGui::Selectable(path.filename().string().c_str(), index == s_selectableFileIndex))
s_selectableFileIndex = index;
index++;
}
ImGui::EndListBox();
}
if (ImGui::Button("hex.builtin.common.open"_lang)) {
s_selectableFileOpenCallback(s_selectableFiles[s_selectableFileIndex]);
ImGui::CloseCurrentPopup();
}
ImGui::SameLine();
if (ImGui::Button("hex.builtin.common.browse"_lang)) {
fs::openFileBrowser(fs::DialogMode::Open, s_selectableFilesValidExtensions, [](const auto &path) {
s_selectableFileOpenCallback(path);
ImGui::CloseCurrentPopup();
});
}
ImGui::EndPopup();
}
}
void addGlobalUIItems() {
EventManager::subscribe<EventFrameEnd>(drawGlobalPopups);
EventManager::subscribe<RequestShowInfoPopup>([](const std::string &message) {
s_popupMessage = message;
ImHexApi::Tasks::doLater([] { ImGui::OpenPopup("hex.builtin.common.info"_lang); });
});
EventManager::subscribe<RequestShowErrorPopup>([](const std::string &message) {
s_popupMessage = message;
ImHexApi::Tasks::doLater([] { ImGui::OpenPopup("hex.builtin.common.error"_lang); });
});
EventManager::subscribe<RequestShowFatalErrorPopup>([](const std::string &message) {
s_popupMessage = message;
ImHexApi::Tasks::doLater([] { ImGui::OpenPopup("hex.builtin.common.fatal"_lang); });
});
EventManager::subscribe<RequestShowYesNoQuestionPopup>([](const std::string &message, const std::function<void()> &yesCallback, const std::function<void()> &noCallback) {
s_popupMessage = message;
s_yesCallback = yesCallback;
s_noCallback = noCallback;
ImHexApi::Tasks::doLater([] { ImGui::OpenPopup("hex.builtin.common.question"_lang); });
});
EventManager::subscribe<RequestShowFileChooserPopup>([](const std::vector<std::fs::path> &paths, const std::vector<nfdfilteritem_t> &validExtensions, const std::function<void(std::fs::path)> &callback) {
s_selectableFileIndex = 0;
s_selectableFiles = paths;
s_selectableFilesValidExtensions = validExtensions;
s_selectableFileOpenCallback = callback;
ImHexApi::Tasks::doLater([] { ImGui::OpenPopup("hex.builtin.common.choose_file"_lang); });
});
}
void addFooterItems() {
@ -178,4 +317,17 @@ namespace hex::plugin::builtin {
}
void handleBorderlessWindowMode() {
// Intel's OpenGL driver has weird bugs that cause the drawn window to be offset to the bottom right.
// This can be fixed by either using Mesa3D's OpenGL Software renderer or by simply disabling it.
// If you want to try if it works anyways on your GPU, set the hex.builtin.setting.interface.force_borderless_window_mode setting to 1
if (ImHexApi::System::isBorderlessWindowModeEnabled()) {
bool isIntelGPU = hex::containsIgnoreCase(ImHexApi::System::getGPUVendor(), "Intel");
ImHexApi::System::impl::setBorderlessWindowMode(!isIntelGPU);
if (isIntelGPU)
log::warn("Intel GPU detected! Intel's OpenGL driver has bugs that can cause issues when using ImHex. If you experience any rendering bugs, please try the Mesa3D Software Renderer");
}
}
}

View File

@ -49,7 +49,7 @@ namespace hex::plugin::builtin {
ContentRegistry::FileHandler::add({ ".mgc" }, [](const auto &path) {
for (const auto &destPath : fs::getDefaultPaths(fs::ImHexPath::Magic)) {
if (fs::copyFile(path, destPath / path.filename(), std::fs::copy_options::overwrite_existing)) {
View::showMessagePopup("hex.builtin.view.information.magic_db_added"_lang);
View::showInfoPopup("hex.builtin.view.information.magic_db_added"_lang);
return true;
}
}

View File

@ -51,7 +51,7 @@ namespace hex::plugin::builtin {
if (ImGui::BeginTabItem(LangEntry(category))) {
const std::string &categoryDesc = descriptions.count(category) ? descriptions.at(category) : category.name;
LangEntry descriptionEntry{categoryDesc};
ImGui::TextUnformatted(descriptionEntry);
ImGui::TextWrapped("%s", static_cast<const char*>(descriptionEntry));
ImGui::InfoTooltip(descriptionEntry);
ImGui::Separator();

View File

@ -20,7 +20,7 @@ namespace hex::plugin::builtin {
ContentRegistry::FileHandler::add({ ".yar" }, [](const auto &path) {
for (const auto &destPath : fs::getDefaultPaths(fs::ImHexPath::Yara)) {
if (fs::copyFile(path, destPath / path.filename(), std::fs::copy_options::overwrite_existing)) {
View::showMessagePopup("hex.builtin.view.yara.rule_added"_lang);
View::showInfoPopup("hex.builtin.view.yara.rule_added"_lang);
return true;
}
}