2021-03-30 16:30:10 -03:00
|
|
|
/*
|
2021-06-11 00:41:58 -04:00
|
|
|
* main.cpp
|
|
|
|
*
|
2024-04-12 05:47:36 -04:00
|
|
|
* Copyright (c) 2020-2024, DarkMatterCore <pabloacurielz@gmail.com>.
|
2021-06-11 00:41:58 -04:00
|
|
|
*
|
|
|
|
* This file is part of nxdumptool (https://github.com/DarkMatterCore/nxdumptool).
|
|
|
|
*
|
|
|
|
* nxdumptool is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* nxdumptool is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2021-03-30 16:30:10 -03:00
|
|
|
|
2024-04-30 17:01:42 -04:00
|
|
|
#include <core/nxdt_utils.h>
|
|
|
|
#include <utils/scope_guard.hpp>
|
|
|
|
#include <views/root_view.hpp>
|
2021-06-10 20:33:11 -04:00
|
|
|
|
2022-07-27 18:53:52 -04:00
|
|
|
namespace i18n = brls::i18n; /* For getStr(). */
|
|
|
|
using namespace i18n::literals; /* For _i18n. */
|
2021-07-30 17:07:26 -04:00
|
|
|
|
2021-08-25 16:48:01 -04:00
|
|
|
bool g_borealisInitialized = false;
|
|
|
|
|
2021-06-10 21:13:26 -04:00
|
|
|
int main(int argc, char *argv[])
|
2021-03-30 16:30:10 -03:00
|
|
|
{
|
2023-12-20 16:32:48 -03:00
|
|
|
NX_IGNORE_ARG(argc);
|
|
|
|
NX_IGNORE_ARG(argv);
|
|
|
|
|
2021-06-11 00:41:58 -04:00
|
|
|
/* Set scope guard to clean up resources at exit. */
|
2021-06-07 23:13:45 -04:00
|
|
|
ON_SCOPE_EXIT { utilsCloseResources(); };
|
2022-07-04 21:04:28 -04:00
|
|
|
|
2021-06-09 00:48:17 -04:00
|
|
|
/* Initialize application resources. */
|
2023-12-20 16:32:48 -03:00
|
|
|
if (!utilsInitializeResources()) return EXIT_FAILURE;
|
2022-07-04 21:04:28 -04:00
|
|
|
|
2021-06-09 00:48:17 -04:00
|
|
|
/* Load Borealis translation files. */
|
2021-06-11 00:41:58 -04:00
|
|
|
brls::i18n::loadTranslations();
|
2022-07-04 21:04:28 -04:00
|
|
|
|
2021-08-08 11:50:20 -04:00
|
|
|
/* Set common footer. */
|
|
|
|
brls::Application::setCommonFooter("v" APP_VERSION " (" GIT_REV ")");
|
2022-07-04 21:04:28 -04:00
|
|
|
|
2021-06-09 00:48:17 -04:00
|
|
|
/* Initialize Borealis. */
|
2021-06-09 14:06:10 -04:00
|
|
|
if (!brls::Application::init(APP_TITLE)) return EXIT_FAILURE;
|
2021-08-25 16:48:01 -04:00
|
|
|
g_borealisInitialized = true;
|
2022-07-04 21:04:28 -04:00
|
|
|
|
2022-07-27 18:53:52 -04:00
|
|
|
try {
|
|
|
|
/* Check if we're running under applet mode. */
|
2023-04-08 07:34:53 -04:00
|
|
|
if (utilsIsAppletMode())
|
2022-07-27 18:53:52 -04:00
|
|
|
{
|
|
|
|
/* Push crash frame with the applet mode warning. */
|
|
|
|
brls::Application::pushView(new brls::CrashFrame("generic/applet_mode_warning"_i18n, [](brls::View *view) {
|
|
|
|
/* Swap crash frame with root view whenever the crash frame button is clicked. */
|
|
|
|
//brls::Application::swapView(new nxdt::views::RootView());
|
|
|
|
/* TODO: restore original behavior after fixing the applet mode issues. */
|
|
|
|
brls::Application::quit();
|
|
|
|
}));
|
|
|
|
} else {
|
|
|
|
/* Push root view. */
|
|
|
|
brls::Application::pushView(new nxdt::views::RootView());
|
|
|
|
}
|
2022-07-04 21:04:28 -04:00
|
|
|
|
2022-07-27 18:53:52 -04:00
|
|
|
/* Run the application. */
|
|
|
|
while(brls::Application::mainLoop());
|
|
|
|
} catch (...) {
|
|
|
|
std::exception_ptr p = std::current_exception();
|
|
|
|
LOG_MSG_ERROR("Exception caught! (%s).", p ? p.__cxa_exception_type()->name() : "unknown");
|
2024-05-10 06:18:57 -04:00
|
|
|
brls::Application::crash(i18n::getStr("generic/exception_caught", p ? p.__cxa_exception_type()->name() : "generic/unknown_exception"_i18n));
|
2022-07-27 18:53:52 -04:00
|
|
|
while(brls::Application::mainLoop());
|
|
|
|
}
|
2022-07-04 21:04:28 -04:00
|
|
|
|
2021-06-11 00:41:58 -04:00
|
|
|
/* Exit. */
|
2021-03-30 16:30:10 -03:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|