2020-09-20 01:21:28 +01:00
|
|
|
#include "main_frame.hpp"
|
2021-09-11 14:48:13 +01:00
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
#include <json.hpp>
|
|
|
|
|
2021-02-10 16:28:47 +00:00
|
|
|
#include "about_tab.hpp"
|
|
|
|
#include "ams_tab.hpp"
|
2021-09-15 16:23:37 +01:00
|
|
|
#include "download.hpp"
|
2021-09-11 14:48:13 +01:00
|
|
|
#include "fs.hpp"
|
|
|
|
#include "list_download_tab.hpp"
|
2021-02-10 16:28:47 +00:00
|
|
|
#include "tools_tab.hpp"
|
|
|
|
#include "utils.hpp"
|
2021-03-10 20:43:00 +00:00
|
|
|
|
2020-10-05 23:53:12 +01:00
|
|
|
namespace i18n = brls::i18n;
|
|
|
|
using namespace i18n::literals;
|
2021-02-06 17:24:47 +00:00
|
|
|
using json = nlohmann::json;
|
2020-10-05 23:53:12 +01:00
|
|
|
|
2021-06-03 21:51:00 +01:00
|
|
|
namespace {
|
|
|
|
constexpr const char AppTitle[] = APP_TITLE;
|
|
|
|
constexpr const char AppVersion[] = APP_VERSION;
|
2021-09-11 14:48:13 +01:00
|
|
|
} // namespace
|
2021-06-03 21:51:00 +01:00
|
|
|
|
2020-09-20 01:21:28 +01:00
|
|
|
MainFrame::MainFrame() : TabFrame()
|
|
|
|
{
|
2021-02-01 16:01:49 +00:00
|
|
|
this->setIcon("romfs:/gui_icon.png");
|
2021-06-03 21:51:00 +01:00
|
|
|
this->setTitle(AppTitle);
|
2021-02-01 16:01:49 +00:00
|
|
|
|
2021-06-03 21:51:00 +01:00
|
|
|
s64 freeStorage;
|
2021-03-16 02:04:21 +00:00
|
|
|
std::string tag = util::getLatestTag(TAGS_INFO);
|
2021-09-11 14:48:13 +01:00
|
|
|
this->setFooterText(fmt::format("menus/main/footer_text"_i18n,
|
|
|
|
(!tag.empty() && tag != AppVersion) ? AppVersion + "menus/main/new_update"_i18n : AppVersion,
|
|
|
|
R_SUCCEEDED(fs::getFreeStorageSD(freeStorage)) ? (float)freeStorage / 0x40000000 : -1));
|
2021-06-03 21:51:00 +01:00
|
|
|
|
2021-03-16 14:56:46 +00:00
|
|
|
json hideStatus = fs::parseJsonFile(HIDE_TABS_JSON);
|
2021-09-15 16:23:37 +01:00
|
|
|
nlohmann::ordered_json nxlinks;
|
|
|
|
download::getRequest(NXLINKS_URL, nxlinks);
|
2021-02-06 17:24:47 +00:00
|
|
|
|
2021-05-21 17:14:26 +01:00
|
|
|
bool erista = util::isErista();
|
2021-02-17 18:00:12 +00:00
|
|
|
|
2021-09-11 14:48:13 +01:00
|
|
|
if (!util::getBoolValue(hideStatus, "about"))
|
2021-03-01 18:19:17 +00:00
|
|
|
this->addTab("menus/main/about"_i18n, new AboutTab());
|
2021-02-06 17:24:47 +00:00
|
|
|
|
2021-09-11 14:48:13 +01:00
|
|
|
if (!util::getBoolValue(hideStatus, "atmosphere"))
|
2021-09-15 16:23:37 +01:00
|
|
|
this->addTab("menus/main/update_ams"_i18n, new AmsTab(nxlinks, erista, util::getBoolValue(hideStatus, "atmosphereentries")));
|
2021-07-21 14:38:43 +01:00
|
|
|
|
2021-09-11 14:48:13 +01:00
|
|
|
if (!util::getBoolValue(hideStatus, "cfw"))
|
2021-09-27 20:56:41 +01:00
|
|
|
this->addTab("menus/main/update_bootloaders"_i18n, new ListDownloadTab(contentType::bootloaders, nxlinks));
|
2020-09-20 01:21:28 +01:00
|
|
|
|
2021-09-11 14:48:13 +01:00
|
|
|
if (!util::getBoolValue(hideStatus, "sigpatches"))
|
2021-09-27 20:56:41 +01:00
|
|
|
this->addTab("menus/main/update_sigpatches"_i18n, new ListDownloadTab(contentType::sigpatches, nxlinks));
|
2020-09-20 01:21:28 +01:00
|
|
|
|
2021-09-11 14:48:13 +01:00
|
|
|
if (!util::getBoolValue(hideStatus, "firmwares"))
|
2021-09-27 20:56:41 +01:00
|
|
|
this->addTab("menus/main/download_firmware"_i18n, new ListDownloadTab(contentType::fw, nxlinks));
|
2020-09-20 01:21:28 +01:00
|
|
|
|
2021-09-11 14:48:13 +01:00
|
|
|
if (!util::getBoolValue(hideStatus, "cheats"))
|
2021-09-27 20:56:41 +01:00
|
|
|
this->addTab("menus/main/download_cheats"_i18n, new ListDownloadTab(contentType::cheats));
|
2020-10-05 23:53:12 +01:00
|
|
|
|
2021-09-11 14:48:13 +01:00
|
|
|
if (!util::getBoolValue(hideStatus, "tools"))
|
2021-09-15 16:50:34 +01:00
|
|
|
this->addTab("menus/main/tools"_i18n, new ToolsTab(tag, util::getValueFromKey(nxlinks, "payloads"), erista, hideStatus));
|
2020-10-05 23:53:12 +01:00
|
|
|
|
2021-09-11 14:48:13 +01:00
|
|
|
this->registerAction("", brls::Key::B, [this] { return true; });
|
2020-09-20 01:21:28 +01:00
|
|
|
}
|