1
0
mirror of synced 2024-11-15 03:27:40 +01:00
ImHex/main/source/main.cpp

64 lines
1.4 KiB
C++
Raw Normal View History

#include <hex.hpp>
2021-08-29 22:15:18 +02:00
#include <hex/helpers/utils.hpp>
#include <hex/helpers/logger.hpp>
#include "window.hpp"
#include "init/splash_window.hpp"
#include "init/tasks.hpp"
#include <hex/helpers/file.hpp>
int main(int argc, char **argv, char **envp) {
using namespace hex;
ImHexApi::System::impl::setProgramArguments(argc, argv, envp);
bool useBorderlessWindow = false;
#if defined(OS_WINDOWS)
useBorderlessWindow = true;
#endif
// Initialization
{
Window::initNative();
2022-01-13 14:34:27 +01:00
hex::log::info("Welcome to ImHex!");
init::WindowSplash splashWindow;
for (const auto &[name, task] : init::getInitTasks())
splashWindow.addStartupTask(name, task);
if (!splashWindow.loop())
ImHexApi::System::getInitArguments().insert({ "tasks-failed", {} });
useBorderlessWindow = !hex::containsIgnoreCase(splashWindow.getGPUVendor(), "Intel");
}
// Clean up
ON_SCOPE_EXIT {
for (const auto &[name, task] : init::getExitTasks())
task();
};
// Main window
{
Window window(useBorderlessWindow);
if (argc == 1)
; // No arguments provided
else if (argc == 2)
EventManager::post<RequestOpenFile>(argv[1]);
else {
2022-01-13 14:34:27 +01:00
hex::log::fatal("Usage: {} [<file_name>]", argv[0]);
2021-08-21 00:51:50 +02:00
return EXIT_FAILURE;
}
window.loop();
}
2021-01-12 16:50:15 +01:00
return EXIT_SUCCESS;
}