1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-10 04:31:44 +00:00
nxdumptool/source/gamecard_tab.cpp

112 lines
4.4 KiB
C++
Raw Normal View History

/*
* 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);
}
}