1
0
mirror of synced 2024-11-30 18:34:29 +01:00
ImHex/source/main.cpp

60 lines
1.3 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 <hex/helpers/shared_data.hpp>
2021-08-29 22:15:18 +02:00
#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) {
hex::SharedData::mainArgc = argc;
hex::SharedData::mainArgv = argv;
hex::SharedData::mainEnvp = envp;
using namespace hex;
// Initialization
{
Window::initNative();
init::WindowSplash splashWindow;
for (const auto &[name, task] : init::getInitTasks())
splashWindow.addStartupTask(name, task);
if (!splashWindow.loop())
init::getInitArguments().push_back({ "tasks-failed", { } });
}
// Clean up
ON_SCOPE_EXIT {
for (const auto &[name, task] : init::getExitTasks())
task();
};
// Main window
{
Window window;
if (argc == 1)
; // No arguments provided
else if (argc == 2)
EventManager::post<RequestOpenFile>(argv[1]);
else {
hex::log::fatal("Usage: imhex [file_name]");
2021-08-21 00:51:50 +02:00
return EXIT_FAILURE;
}
hex::log::info("Welcome to ImHex!");
window.loop();
}
2021-01-12 16:50:15 +01:00
return EXIT_SUCCESS;
}