mirror of
https://github.com/DarkMatterCore/nxdumptool.git
synced 2024-11-22 18:26:39 +00:00
UI: added ErrorFrame and GameCardTab classes.
This commit is contained in:
parent
4ffbb1f903
commit
ac647310ad
9 changed files with 355 additions and 16 deletions
|
@ -191,12 +191,13 @@ NXDT_ASSERT(GameCardHeader, 0x200);
|
|||
|
||||
typedef enum {
|
||||
GameCardStatus_NotInserted = 0, ///< No gamecard is inserted.
|
||||
GameCardStatus_NoGameCardPatchEnabled = 1, ///< A gamecard has been inserted, but the running CFW enabled the "nogc" patch at boot.
|
||||
GameCardStatus_Processing = 1, ///< A gamecard has been inserted and it's being processed.
|
||||
GameCardStatus_NoGameCardPatchEnabled = 2, ///< A gamecard has been inserted, but the running CFW enabled the "nogc" patch at boot.
|
||||
///< This triggers an error whenever fsDeviceOperatorGetGameCardHandle is called. Nothing at all can be done with the inserted gamecard.
|
||||
GameCardStatus_LotusAsicFirmwareUpdateRequired = 2, ///< A gamecard has been inserted, but a LAFW update is needed before being able to read the secure storage area.
|
||||
GameCardStatus_LotusAsicFirmwareUpdateRequired = 3, ///< A gamecard has been inserted, but a LAFW update is needed before being able to read the secure storage area.
|
||||
///< Operations on the normal storage area are still possible, though.
|
||||
GameCardStatus_InsertedAndInfoNotLoaded = 3, ///< A gamecard has been inserted, but an unexpected error unrelated to both "nogc" patch and LAFW version occurred.
|
||||
GameCardStatus_InsertedAndInfoLoaded = 4 ///< A gamecard has been inserted and all required information could be successfully retrieved from it.
|
||||
GameCardStatus_InsertedAndInfoNotLoaded = 4, ///< A gamecard has been inserted, but an unexpected error unrelated to both "nogc" patch and LAFW version occurred.
|
||||
GameCardStatus_InsertedAndInfoLoaded = 5 ///< A gamecard has been inserted and all required information could be successfully retrieved from it.
|
||||
} GameCardStatus;
|
||||
|
||||
typedef enum {
|
||||
|
|
51
include/error_frame.hpp
Normal file
51
include/error_frame.hpp
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* error_frame.hpp
|
||||
*
|
||||
* Copyright (c) 2020-2021, DarkMatterCore <pabloacurielz@gmail.com>.
|
||||
*
|
||||
* Based on crash_frame.hpp from Borealis.
|
||||
*
|
||||
* 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 __ERROR_FRAME_HPP__
|
||||
#define __ERROR_FRAME_HPP__
|
||||
|
||||
#include <borealis.hpp>
|
||||
|
||||
namespace nxdt::views
|
||||
{
|
||||
class ErrorFrame: public brls::View
|
||||
{
|
||||
private:
|
||||
brls::Label *label = nullptr;
|
||||
bool print_dbg = false;
|
||||
|
||||
protected:
|
||||
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override;
|
||||
void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override;
|
||||
|
||||
public:
|
||||
ErrorFrame(std::string msg);
|
||||
~ErrorFrame(void);
|
||||
|
||||
void SetMessage(std::string msg);
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* __ERROR_FRAME_HPP__ */
|
54
include/gamecard_tab.hpp
Normal file
54
include/gamecard_tab.hpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* gamecard_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 __GAMECARD_TAB_HPP__
|
||||
#define __GAMECARD_TAB_HPP__
|
||||
|
||||
#include "tasks.hpp"
|
||||
#include "error_frame.hpp"
|
||||
|
||||
namespace nxdt::views
|
||||
{
|
||||
class GameCardTab: public brls::LayerView
|
||||
{
|
||||
private:
|
||||
nxdt::tasks::GameCardTask *gc_status_task = nullptr;
|
||||
nxdt::tasks::GameCardStatusEvent::Subscription gc_status_task_sub;
|
||||
GameCardStatus gc_status = GameCardStatus_NotInserted;
|
||||
|
||||
ErrorFrame *error_frame = nullptr;
|
||||
brls::List *list = nullptr;
|
||||
|
||||
std::vector<brls::View*> views;
|
||||
int view_index = -1;
|
||||
|
||||
void addLayerWrapper(brls::View* view);
|
||||
void changeLayerWrapper(brls::View* view);
|
||||
|
||||
public:
|
||||
GameCardTab(nxdt::tasks::GameCardTask *gc_status_task);
|
||||
~GameCardTab(void);
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* __GAMECARD_TAB_HPP__ */
|
|
@ -19,7 +19,12 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <tasks.hpp>
|
||||
#pragma once
|
||||
|
||||
#ifndef __ROOT_VIEW_HPP__
|
||||
#define __ROOT_VIEW_HPP__
|
||||
|
||||
#include "tasks.hpp"
|
||||
|
||||
namespace nxdt::views
|
||||
{
|
||||
|
@ -33,5 +38,8 @@ namespace nxdt::views
|
|||
|
||||
public:
|
||||
RootView(void);
|
||||
~RootView(void);
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* __ROOT_VIEW_HPP__ */
|
||||
|
|
|
@ -53,12 +53,13 @@ namespace nxdt::tasks
|
|||
GameCardStatus cur_gc_status = GameCardStatus_NotInserted;
|
||||
GameCardStatus prev_gc_status = GameCardStatus_NotInserted;
|
||||
|
||||
protected:
|
||||
void run(retro_time_t current_time) override;
|
||||
|
||||
public:
|
||||
GameCardTask(void);
|
||||
~GameCardTask(void);
|
||||
|
||||
void run(retro_time_t current_time) override;
|
||||
|
||||
ALWAYS_INLINE GameCardStatusEvent::Subscription RegisterListener(GameCardStatusEvent::Callback cb)
|
||||
{
|
||||
return this->gc_status_event.subscribe(cb);
|
||||
|
@ -81,12 +82,13 @@ namespace nxdt::tasks
|
|||
|
||||
void PopulateApplicationMetadataVector(bool is_system);
|
||||
|
||||
protected:
|
||||
void run(retro_time_t current_time) override;
|
||||
|
||||
public:
|
||||
TitleTask(void);
|
||||
~TitleTask(void);
|
||||
|
||||
void run(retro_time_t current_time) override;
|
||||
|
||||
TitleApplicationMetadataVector* GetApplicationMetadata(bool is_system);
|
||||
|
||||
ALWAYS_INLINE VoidEvent::Subscription RegisterListener(VoidEvent::Callback cb)
|
||||
|
@ -109,12 +111,14 @@ namespace nxdt::tasks
|
|||
UmsDeviceVector ums_devices;
|
||||
|
||||
void PopulateUmsDeviceVector(void);
|
||||
|
||||
protected:
|
||||
void run(retro_time_t current_time) override;
|
||||
|
||||
public:
|
||||
UmsTask(void);
|
||||
~UmsTask(void);
|
||||
|
||||
void run(retro_time_t current_time) override;
|
||||
|
||||
UmsDeviceVector* GetUmsDevices(void);
|
||||
|
||||
ALWAYS_INLINE VoidEvent::Subscription RegisterListener(VoidEvent::Callback cb)
|
||||
|
@ -136,12 +140,14 @@ namespace nxdt::tasks
|
|||
|
||||
bool cur_usb_host_status = false;
|
||||
bool prev_usb_host_status = false;
|
||||
|
||||
protected:
|
||||
void run(retro_time_t current_time) override;
|
||||
|
||||
public:
|
||||
UsbHostTask(void);
|
||||
~UsbHostTask(void);
|
||||
|
||||
void run(retro_time_t current_time) override;
|
||||
|
||||
ALWAYS_INLINE BooleanEvent::Subscription RegisterListener(BooleanEvent::Callback cb)
|
||||
{
|
||||
return this->usb_host_event.subscribe(cb);
|
||||
|
|
|
@ -305,7 +305,7 @@ UEvent *gamecardGetStatusChangeUserEvent(void)
|
|||
|
||||
u8 gamecardGetStatus(void)
|
||||
{
|
||||
u8 status = GameCardStatus_NotInserted;
|
||||
u8 status = GameCardStatus_Processing;
|
||||
|
||||
SCOPED_TRY_LOCK(&g_gameCardMutex)
|
||||
{
|
||||
|
|
97
source/error_frame.cpp
Normal file
97
source/error_frame.cpp
Normal file
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* error_frame.cpp
|
||||
*
|
||||
* Copyright (c) 2020-2021, DarkMatterCore <pabloacurielz@gmail.com>.
|
||||
*
|
||||
* Based on crash_frame.cpp from Borealis.
|
||||
*
|
||||
* 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 <error_frame.hpp>
|
||||
|
||||
namespace nxdt::views
|
||||
{
|
||||
ErrorFrame::ErrorFrame(std::string msg): brls::View()
|
||||
{
|
||||
this->label = new brls::Label(brls::LabelStyle::REGULAR, msg, true);
|
||||
this->label->setHorizontalAlign(NVG_ALIGN_CENTER);
|
||||
this->label->setParent(this);
|
||||
}
|
||||
|
||||
ErrorFrame::~ErrorFrame(void)
|
||||
{
|
||||
delete this->label;
|
||||
}
|
||||
|
||||
void ErrorFrame::draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx)
|
||||
{
|
||||
nvgSave(vg);
|
||||
|
||||
/* Background. */
|
||||
nvgFillColor(vg, brls::Application::getTheme()->backgroundColorRGB);
|
||||
nvgBeginPath(vg);
|
||||
nvgRect(vg, x, y, width, height);
|
||||
nvgFill(vg);
|
||||
|
||||
/* Scale. */
|
||||
float scale = (this->alpha + 2.0f) / 3.0f;
|
||||
nvgTranslate(vg, (1.0f - scale) * width * 0.5f, (1.0f - scale) * height * 0.5f);
|
||||
nvgScale(vg, scale, scale);
|
||||
|
||||
/* Label. */
|
||||
this->label->frame(ctx);
|
||||
|
||||
/* [!] box. */
|
||||
unsigned boxSize = style->CrashFrame.boxSize;
|
||||
nvgStrokeColor(vg, RGB(255, 255, 255));
|
||||
nvgStrokeWidth(vg, style->CrashFrame.boxStrokeWidth);
|
||||
nvgBeginPath(vg);
|
||||
nvgRect(vg, x + (width - boxSize) / 2, y + style->CrashFrame.boxSpacing, boxSize, boxSize);
|
||||
nvgStroke(vg);
|
||||
|
||||
nvgFillColor(vg, RGB(255, 255, 255));
|
||||
|
||||
nvgFontSize(vg, (float)style->CrashFrame.boxSize / 1.25f);
|
||||
nvgTextAlign(vg, NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE);
|
||||
nvgBeginPath(vg);
|
||||
nvgText(vg, x + width / 2, y + style->CrashFrame.boxSpacing + boxSize / 2, "!", nullptr);
|
||||
nvgFill(vg);
|
||||
|
||||
/* End scale. */
|
||||
nvgResetTransform(vg);
|
||||
nvgRestore(vg);
|
||||
}
|
||||
|
||||
void ErrorFrame::layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash)
|
||||
{
|
||||
this->label->setWidth(roundf((float)this->width * 0.90f));
|
||||
this->label->invalidate(true);
|
||||
|
||||
this->label->setBoundaries(
|
||||
this->x + this->width / 2 - this->label->getWidth() / 2,
|
||||
this->y + (this->height - style->AppletFrame.footerHeight) / 2,
|
||||
this->label->getWidth(),
|
||||
this->label->getHeight());
|
||||
}
|
||||
|
||||
void ErrorFrame::SetMessage(std::string msg)
|
||||
{
|
||||
this->label->setText(msg);
|
||||
this->invalidate(true);
|
||||
}
|
||||
}
|
111
source/gamecard_tab.cpp
Normal file
111
source/gamecard_tab.cpp
Normal file
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* gamecard_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 <gamecard_tab.hpp>
|
||||
|
||||
using namespace brls::i18n::literals; /* For _i18n. */
|
||||
|
||||
namespace nxdt::views
|
||||
{
|
||||
GameCardTab::GameCardTab(nxdt::tasks::GameCardTask *gc_status_task) : brls::LayerView(), gc_status_task(gc_status_task)
|
||||
{
|
||||
/* Add error frame. */
|
||||
this->error_frame = new ErrorFrame("No gamecard inserted.");
|
||||
this->addLayer(this->error_frame);
|
||||
|
||||
/* Add list. */
|
||||
this->list = new brls::List();
|
||||
this->list->addView(new brls::ListItem("Placeholder"));
|
||||
this->addLayer(this->list);
|
||||
|
||||
/* Setup gamecard status task. */
|
||||
this->gc_status_task_sub = this->gc_status_task->RegisterListener([this](GameCardStatus gc_status) {
|
||||
switch(gc_status)
|
||||
{
|
||||
case GameCardStatus_NotInserted:
|
||||
this->error_frame->SetMessage("No gamecard inserted.");
|
||||
break;
|
||||
case GameCardStatus_Processing:
|
||||
this->error_frame->SetMessage("Processing gamecard, please wait...");
|
||||
break;
|
||||
case GameCardStatus_NoGameCardPatchEnabled:
|
||||
this->error_frame->SetMessage("A gamecard has been inserted, but the \"nogc\" patch is enabled.\n" \
|
||||
"Nothing at all can be done with the inserted gamecard.\n" \
|
||||
"Disabling this patch *will* update the Lotus ASIC firmware if it's outdated.\n" \
|
||||
"Consider disabling this patch if you wish to use gamecard dumping features.");
|
||||
break;
|
||||
case GameCardStatus_LotusAsicFirmwareUpdateRequired:
|
||||
this->error_frame->SetMessage("A gamecard has been inserted, but a Lotus ASIC firmware update is required.\n" \
|
||||
"Update your console using the inserted gamecard and try again.");
|
||||
break;
|
||||
case GameCardStatus_InsertedAndInfoNotLoaded:
|
||||
this->error_frame->SetMessage("A gamecard has been inserted, but an unexpected I/O error occurred.\n" \
|
||||
"Please check the logfile and report this issue to " APP_AUTHOR ".");
|
||||
break;
|
||||
case GameCardStatus_InsertedAndInfoLoaded:
|
||||
this->changeLayer(1);
|
||||
this->list->invalidate(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (gc_status < GameCardStatus_InsertedAndInfoLoaded) this->changeLayer(0);
|
||||
|
||||
this->gc_status = gc_status;
|
||||
});
|
||||
}
|
||||
|
||||
GameCardTab::~GameCardTab(void)
|
||||
{
|
||||
/* Unregister gamecard task listener. */
|
||||
this->gc_status_task->UnregisterListener(this->gc_status_task_sub);
|
||||
}
|
||||
|
||||
void GameCardTab::addLayerWrapper(brls::View* view)
|
||||
{
|
||||
this->views.push_back(view);
|
||||
this->addLayer(view);
|
||||
if (this->view_index == -1) this->view_index = 0;
|
||||
}
|
||||
|
||||
void GameCardTab::changeLayerWrapper(brls::View* view)
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
for(size_t i = 0; i < this->views.size(); i++)
|
||||
{
|
||||
if (this->views[i] == view)
|
||||
{
|
||||
index = (int)i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index == -1 || index == this->view_index) return;
|
||||
|
||||
//reinterpret_cast<brls::TabFrame*>(this->getParent())->onCancel();
|
||||
this->changeLayer(index);
|
||||
this->view_index = index;
|
||||
view->invalidate(true);
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include <nxdt_includes.h>
|
||||
#include <root_view.hpp>
|
||||
//#include <gamecard_tab.hpp>
|
||||
#include <gamecard_tab.hpp>
|
||||
//#include <user_titles_tab.hpp>
|
||||
//#include <system_titles_tab.hpp>
|
||||
//#include <options_tab.hpp>
|
||||
|
@ -45,10 +45,21 @@ namespace nxdt::views
|
|||
this->setFooterText("v" APP_VERSION);
|
||||
|
||||
/* Add tabs. */
|
||||
this->addTab("root_view/tabs/gamecard"_i18n, new brls::Rectangle(nvgRGB(255, 0, 0)));
|
||||
this->addTab("root_view/tabs/gamecard"_i18n, new GameCardTab(this->gc_status_task));
|
||||
this->addSeparator();
|
||||
this->addTab("root_view/tabs/user_titles"_i18n, new brls::Rectangle(nvgRGB(0, 255, 0)));
|
||||
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)));
|
||||
}
|
||||
|
||||
RootView::~RootView(void)
|
||||
{
|
||||
/* Stop background tasks. */
|
||||
this->gc_status_task->stop();
|
||||
this->title_task->stop();
|
||||
this->ums_task->stop();
|
||||
this->usb_host_task->stop();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue