mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
feat: Added function to show toast messages, moved native error message function to libimhex
This commit is contained in:
@@ -20,8 +20,6 @@ struct ImGuiSettingsHandler;
|
||||
|
||||
namespace hex {
|
||||
|
||||
void nativeErrorMessage(const std::string &message);
|
||||
|
||||
class Window {
|
||||
public:
|
||||
Window();
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
#include <hex/api/task_manager.hpp>
|
||||
#include <hex/api/workspace_manager.hpp>
|
||||
|
||||
|
||||
#include <hex/helpers/logger.hpp>
|
||||
#include <hex/helpers/fs.hpp>
|
||||
#include <hex/helpers/default_paths.hpp>
|
||||
|
||||
#include <wolv/utils/string.hpp>
|
||||
@@ -15,11 +13,10 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <hex/trace/stacktrace.hpp>
|
||||
|
||||
#include <csignal>
|
||||
#include <exception>
|
||||
#include <typeinfo>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
|
||||
#if defined(IMGUI_TEST_ENGINE)
|
||||
#include <imgui_te_engine.h>
|
||||
@@ -39,7 +36,7 @@ namespace hex::crash {
|
||||
void resetCrashHandlers();
|
||||
|
||||
static void sendNativeMessage(const std::string& message) {
|
||||
hex::nativeErrorMessage(fmt::format("ImHex crashed during initial setup!\nError: {}", message));
|
||||
hex::showErrorMessageBox(fmt::format("ImHex crashed during initial setup!\nError: {}", message));
|
||||
}
|
||||
|
||||
// Function that decides what should happen on a crash
|
||||
|
||||
@@ -478,7 +478,7 @@ namespace hex::init {
|
||||
// Create the splash screen window
|
||||
m_window = glfwCreateWindow(WindowSize.x, WindowSize.y, "Starting ImHex...", nullptr, nullptr);
|
||||
if (m_window == nullptr) {
|
||||
hex::nativeErrorMessage(fmt::format(
|
||||
hex::showErrorMessageBox(fmt::format(
|
||||
"Failed to create GLFW window: [{}] {}.\n"
|
||||
"You may not have a renderer available.\n"
|
||||
"The most common cause of this is using a virtual machine\n"
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <hex/api/task_manager.hpp>
|
||||
#include <hex/api/plugin_manager.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
|
||||
namespace hex::init {
|
||||
|
||||
@@ -61,8 +62,7 @@ int main(int argc, char **argv) {
|
||||
log::info("Linux distribution: {}. Version: {}", distro->name, distro->version == "" ? "None" : distro->version);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// Run ImHex
|
||||
return init::runImHex();
|
||||
}
|
||||
|
||||
@@ -44,15 +44,6 @@ namespace hex {
|
||||
return false;
|
||||
}
|
||||
|
||||
void nativeErrorMessage(const std::string &message) {
|
||||
log::fatal("{}", message);
|
||||
if (isFileInPath("zenity")) {
|
||||
executeCmd({"zenity", "--error", "--text", message});
|
||||
} else if (isFileInPath("notify-send")) {
|
||||
executeCmd({"notify-send", "-i", "script-error", "Error", message});
|
||||
} // Hopefully one of these commands is installed
|
||||
}
|
||||
|
||||
#if defined(IMHEX_HAS_FONTCONFIG)
|
||||
static bool enumerateFontConfig() {
|
||||
if (!FcInit())
|
||||
|
||||
@@ -22,11 +22,6 @@
|
||||
|
||||
namespace hex {
|
||||
|
||||
void nativeErrorMessage(const std::string &message) {
|
||||
log::fatal("{}", message);
|
||||
errorMessageMacos(message.c_str());
|
||||
}
|
||||
|
||||
void Window::configureGLFW() {
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
|
||||
|
||||
@@ -77,13 +77,6 @@ extern "C" void enterTouchMode() {
|
||||
|
||||
namespace hex {
|
||||
|
||||
void nativeErrorMessage(const std::string &message) {
|
||||
log::fatal("{}", message);
|
||||
EM_ASM({
|
||||
alert(UTF8ToString($0));
|
||||
}, message.c_str());
|
||||
}
|
||||
|
||||
void Window::configureGLFW() {
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||
|
||||
@@ -56,11 +56,6 @@ namespace hex {
|
||||
static Microsoft::WRL::ComPtr<ITaskbarList4> s_taskbarList;
|
||||
static bool s_useLayeredWindow = true;
|
||||
|
||||
void nativeErrorMessage(const std::string &message) {
|
||||
log::fatal("{}", message);
|
||||
MessageBoxA(nullptr, message.c_str(), "Error", MB_ICONERROR | MB_OK);
|
||||
}
|
||||
|
||||
// Custom Window procedure for receiving OS events
|
||||
static LRESULT commonWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
switch (uMsg) {
|
||||
|
||||
Reference in New Issue
Block a user