2021-02-10 18:17:09 +01:00
|
|
|
#include <hex.hpp>
|
|
|
|
|
2021-08-29 22:15:18 +02:00
|
|
|
#include <hex/helpers/utils.hpp>
|
|
|
|
#include <hex/helpers/logger.hpp>
|
2021-12-30 23:21:32 +01:00
|
|
|
#include <hex/helpers/shared_data.hpp>
|
2021-08-29 22:15:18 +02:00
|
|
|
|
2020-11-10 15:26:38 +01:00
|
|
|
#include "window.hpp"
|
|
|
|
|
2021-04-20 21:46:48 +02:00
|
|
|
#include "init/splash_window.hpp"
|
|
|
|
#include "init/tasks.hpp"
|
|
|
|
|
2021-09-08 15:18:24 +02:00
|
|
|
#include <hex/helpers/file.hpp>
|
|
|
|
|
2021-12-22 13:16:51 +01:00
|
|
|
int main(int argc, char **argv, char **envp) {
|
2021-12-30 23:21:32 +01:00
|
|
|
hex::SharedData::mainArgc = argc;
|
|
|
|
hex::SharedData::mainArgv = argv;
|
|
|
|
hex::SharedData::mainEnvp = envp;
|
|
|
|
|
2021-01-13 17:28:27 +01:00
|
|
|
using namespace hex;
|
|
|
|
|
2021-04-20 21:46:48 +02:00
|
|
|
// Initialization
|
|
|
|
{
|
2021-08-22 20:24:42 +02:00
|
|
|
Window::initNative();
|
|
|
|
|
2021-12-30 23:21:32 +01:00
|
|
|
init::WindowSplash splashWindow;
|
2021-04-20 21:46:48 +02:00
|
|
|
|
|
|
|
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)
|
2021-09-08 15:18:24 +02:00
|
|
|
EventManager::post<RequestOpenFile>(argv[1]);
|
2021-04-20 21:46:48 +02:00
|
|
|
else {
|
|
|
|
hex::log::fatal("Usage: imhex [file_name]");
|
2021-08-21 00:51:50 +02:00
|
|
|
return EXIT_FAILURE;
|
2021-04-20 21:46:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
hex::log::info("Welcome to ImHex!");
|
2020-11-10 15:26:38 +01:00
|
|
|
|
2021-04-20 21:46:48 +02:00
|
|
|
window.loop();
|
|
|
|
}
|
2021-01-12 16:50:15 +01:00
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
2020-11-10 15:26:38 +01:00
|
|
|
}
|