2021-02-10 17:17:09 +00:00
|
|
|
#include <hex.hpp>
|
|
|
|
|
2020-11-10 14:26:38 +00:00
|
|
|
#include "window.hpp"
|
|
|
|
|
2021-04-20 19:46:48 +00:00
|
|
|
#include "init/splash_window.hpp"
|
|
|
|
#include "init/tasks.hpp"
|
|
|
|
|
2020-12-01 17:19:49 +00:00
|
|
|
int main(int argc, char **argv) {
|
2021-01-13 16:28:27 +00:00
|
|
|
using namespace hex;
|
|
|
|
|
2021-04-20 19:46:48 +00:00
|
|
|
// Initialization
|
|
|
|
{
|
2021-08-22 18:24:42 +00:00
|
|
|
Window::initNative();
|
|
|
|
|
2021-04-20 19:46:48 +00:00
|
|
|
init::WindowSplash splashWindow(argc, argv);
|
|
|
|
|
|
|
|
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<EventFileDropped>(argv[1]);
|
|
|
|
else {
|
|
|
|
hex::log::fatal("Usage: imhex [file_name]");
|
2021-08-20 22:51:50 +00:00
|
|
|
return EXIT_FAILURE;
|
2021-04-20 19:46:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
hex::log::info("Welcome to ImHex!");
|
2020-11-10 14:26:38 +00:00
|
|
|
|
2021-04-20 19:46:48 +00:00
|
|
|
window.loop();
|
|
|
|
}
|
2021-01-12 15:50:15 +00:00
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
2020-11-10 14:26:38 +00:00
|
|
|
}
|