1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-12-22 16:42:11 +00:00

UI: add AboutTab class.

This commit is contained in:
Pablo Curiel 2021-06-14 16:54:33 -04:00
parent 296115f886
commit 7a964c8282
10 changed files with 183 additions and 14 deletions

61
include/about_tab.hpp Normal file
View file

@ -0,0 +1,61 @@
/*
* about_tab.hpp
*
* Copyright (c) 2020-2021, DarkMatterCore <pabloacurielz@gmail.com>.
*
* 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/>.
*/
#pragma once
#ifndef __ABOUT_TAB_HPP__
#define __ABOUT_TAB_HPP__
#include <borealis.hpp>
namespace nxdt::views
{
/* Extended class to display a focusable (but unhighlightable) image. */
class AboutTabLogo: public brls::Image
{
protected:
void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override;
brls::View* getDefaultFocus(void);
//void onFocusGained(void);
public:
AboutTabLogo(void);
};
/* Extended class to display a focusable (but unhighlightable) label. */
class AboutTabLabel: public brls::Label
{
protected:
brls::View* getDefaultFocus(void);
//void onFocusGained(void);
public:
AboutTabLabel(brls::LabelStyle labelStyle, std::string text, bool center = false, bool multiline = true);
};
class AboutTab: public brls::List
{
public:
AboutTab(void);
};
}
#endif /* __ABOUT_TAB_HPP__ */

View file

@ -72,4 +72,7 @@
#define GITHUB_REPOSITORY_URL "https://github.com/DarkMatterCore/nxdumptool"
#define GITHUB_NEW_ISSUE_URL GITHUB_REPOSITORY_URL "/issues/new/choose"
#define BOREALIS_URL "https://github.com/natinusala/borealis"
#define LIBUSBHSFS_URL "https://github.com/DarkMatterCore/libusbhsfs"
#endif /* __DEFINES_H__ */

View file

@ -29,6 +29,7 @@
namespace nxdt::views
{
/* Extended class to display a focusable (but unhighlightable) table. */
class GameCardTable: public brls::Table
{
protected:
@ -37,9 +38,9 @@ namespace nxdt::views
public:
GameCardTable(void);
~GameCardTable(void);
};
/* Extended class to switch between ErrorFrame and List views whenever the gamecard status event is triggered. */
class GameCardTab: public brls::LayerView
{
private:

View file

@ -0,0 +1,5 @@
{
"description": "Nintendo Switch Dump Tool",
"copyright": "Licensed under GPLv3+\n\u00A9 2020 - 2021 {0}",
"links": "\uE016 Source code is available at: {0}.\n\uE016 {1} is powered by Borealis, a hardware-accelerated UI library: {2}.\n\uE016 USB Mass Storage device support is powered by libusbhsfs: {3}."
}

View file

@ -17,8 +17,7 @@
"lafw_version": "Required LAFW version",
"lafw_version_value": "%lu or greater (%s)",
"sdk_version": "SDK version",
"compatibility_type": "Compatibility type",
"unknown": "Unknown"
"compatibility_type": "Compatibility type"
},
"dump_options": "Dump options",

View file

@ -0,0 +1,3 @@
{
"unknown": "Unknown"
}

100
source/about_tab.cpp Normal file
View file

@ -0,0 +1,100 @@
/*
* about_tab.cpp
*
* Copyright (c) 2020-2021, DarkMatterCore <pabloacurielz@gmail.com>.
*
* 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/>.
*/
#include <nxdt_includes.h>
#include <about_tab.hpp>
#define LOGO_SIZE 256
namespace i18n = brls::i18n; /* For getStr(). */
using namespace i18n::literals; /* For _i18n. */
namespace nxdt::views
{
AboutTabLogo::AboutTabLogo(void) : brls::Image(BOREALIS_ASSET("icon/" APP_TITLE ".jpg"))
{
this->setScaleType(brls::ImageScaleType::NO_RESIZE);
}
void AboutTabLogo::layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash)
{
this->setBoundaries(this->x + this->width / 2 - LOGO_SIZE / 2, this->y, LOGO_SIZE, LOGO_SIZE);
brls::Image::layout(vg, style, stash);
}
brls::View* AboutTabLogo::getDefaultFocus(void)
{
return this;
}
/*
void AboutTabLogo::onFocusGained(void)
{
this->focused = true;
this->focusEvent.fire(this);
if (this->hasParent()) this->getParent()->onChildFocusGained(this);
}
*/
AboutTabLabel::AboutTabLabel(brls::LabelStyle labelStyle, std::string text, bool center, bool multiline) : brls::Label(labelStyle, text, multiline)
{
if (center) this->setHorizontalAlign(NVG_ALIGN_CENTER);
}
brls::View* AboutTabLabel::getDefaultFocus(void)
{
return this;
}
/*
void AboutTabLabel::onFocusGained(void)
{
this->focused = true;
this->focusEvent.fire(this);
if (this->hasParent()) this->getParent()->onChildFocusGained(this);
}
*/
AboutTab::AboutTab(void) : brls::List()
{
this->setSpacing(this->getSpacing() / 2);
this->setMarginBottom(20);
/* Logo. */
this->addView(new AboutTabLogo());
/* Description. */
brls::Label* description = new brls::Label(brls::LabelStyle::REGULAR, "about_tab/description"_i18n, true);
description->setHorizontalAlign(NVG_ALIGN_CENTER);
this->addView(description);
/* Copyright. */
brls::Label* copyright = new brls::Label(brls::LabelStyle::DESCRIPTION, i18n::getStr("about_tab/copyright"_i18n, APP_AUTHOR), true);
copyright->setHorizontalAlign(NVG_ALIGN_CENTER);
this->addView(copyright);
/* Links and resources. */
this->addView(new brls::Header("Links and resources"));
AboutTabLabel* links = new AboutTabLabel(brls::LabelStyle::SMALL, i18n::getStr("about_tab/links"_i18n, GITHUB_REPOSITORY_URL, APP_TITLE, BOREALIS_URL, LIBUSBHSFS_URL));
this->addView(links);
}
}

View file

@ -105,7 +105,7 @@ bool utilsInitializeResources(const int program_argc, const char **program_argv)
/* Create logfile. */
logWriteStringToLogFile("________________________________________________________________\r\n");
LOG_MSG(APP_TITLE " v%u.%u.%u starting. Built on " __DATE__ " - " __TIME__ ".", VERSION_MAJOR, VERSION_MINOR, VERSION_MICRO);
LOG_MSG(APP_TITLE " v%u.%u.%u starting (" GIT_COMMIT "). Built on " __DATE__ " - " __TIME__ ".", VERSION_MAJOR, VERSION_MINOR, VERSION_MICRO);
if (g_appLaunchPath) LOG_MSG("Launch path: \"%s\".", g_appLaunchPath);
/* Log Horizon OS version. */

View file

@ -43,8 +43,6 @@ namespace nxdt::views
GameCardTable::GameCardTable(void) : brls::Table() { }
GameCardTable::~GameCardTable(void) { }
brls::View* GameCardTable::getDefaultFocus(void)
{
return this;
@ -53,9 +51,7 @@ namespace nxdt::views
void GameCardTable::onFocusGained(void)
{
this->focused = true;
this->focusEvent.fire(this);
if (this->hasParent()) this->getParent()->onChildFocusGained(this);
}
@ -151,15 +147,15 @@ namespace nxdt::views
card_info.upp_version.major_relstep, card_info.upp_version.minor_relstep, card_info.upp_version.value);
this->update_version->setValue(std::string(strbuf));
snprintf(strbuf, sizeof(strbuf), "gamecard_tab/list/properties_table/lafw_version_value"_i18n.c_str(), card_info.fw_version, \
card_info.fw_version >= GameCardFwVersion_Count ? "gamecard_tab/list/properties_table/unknown"_i18n.c_str() : GameCardFwVersionStrings[card_info.fw_version]);
snprintf(strbuf, sizeof(strbuf), "%lu (%s)", card_info.fw_version, \
card_info.fw_version >= GameCardFwVersion_Count ? "generic/unknown"_i18n.c_str() : GameCardFwVersionStrings[card_info.fw_version]);
this->lafw_version->setValue(std::string(strbuf));
snprintf(strbuf, sizeof(strbuf), "%u.%u.%u-%u (v%u)", card_info.fw_mode.major, card_info.fw_mode.minor, card_info.fw_mode.micro, card_info.fw_mode.relstep, card_info.fw_mode.value);
this->sdk_version->setValue(std::string(strbuf));
snprintf(strbuf, sizeof(strbuf), "%s (%u)", card_info.compatibility_type >= GameCardCompatibilityType_Count ? \
"gamecard_tab/list/properties_table/unknown"_i18n.c_str() : GameCardCompatibilityTypeStrings[card_info.compatibility_type], \
snprintf(strbuf, sizeof(strbuf), "%s (%u)", \
card_info.compatibility_type >= GameCardCompatibilityType_Count ? "generic/unknown"_i18n.c_str() : GameCardCompatibilityTypeStrings[card_info.compatibility_type], \
card_info.compatibility_type);
this->compatibility_type->setValue(std::string(strbuf));

View file

@ -25,7 +25,7 @@
//#include <user_titles_tab.hpp>
//#include <system_titles_tab.hpp>
//#include <options_tab.hpp>
//#include <about_tab.hpp>
#include <about_tab.hpp>
using namespace brls::i18n::literals; /* For _i18n. */
@ -51,7 +51,8 @@ namespace nxdt::views
this->addTab("root_view/tabs/system_titles"_i18n, new brls::Rectangle(nvgRGB(0, 0, 255)));
this->addSeparator();
this->addTab("root_view/tabs/options"_i18n, new brls::Rectangle(nvgRGB(255, 255, 0)));
this->addTab("root_view/tabs/about"_i18n, new brls::Rectangle(nvgRGB(255, 0, 255)));
this->addSeparator();
this->addTab("root_view/tabs/about"_i18n, new AboutTab());
}
RootView::~RootView(void)