1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-23 02:36:41 +00:00
nxdumptool/include/views/layered_error_frame.hpp

60 lines
2 KiB
C++
Raw Normal View History

2021-06-20 08:49:33 +01:00
/*
* layered_error_frame.hpp
2021-06-20 08:49:33 +01:00
*
2024-04-12 10:47:36 +01:00
* Copyright (c) 2020-2024, DarkMatterCore <pabloacurielz@gmail.com>.
2021-06-20 08:49:33 +01: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/>.
*/
#pragma once
#ifndef __LAYERED_ERROR_FRAME_HPP__
#define __LAYERED_ERROR_FRAME_HPP__
2021-06-20 08:49:33 +01:00
#include "error_frame.hpp"
namespace nxdt::views
{
/* Extended class to switch between ErrorFrame and List views on demand. */
[ci skip] Add GameCardImageDumpTask and FileWriter classes GameCardImageDumpTask is a derived class of DataTransferTask, and it's designed to dump a gamecard image using the options selected by the user (which must be passed from a GameCardImageDumpOptionsFrame object). It uses std::optional<std::string> as its return type -- the idea behind this is to return error strings that may later be displayed by an ErrorFrame during the dump process (views not yet implemented). FileWriter is a class that encapsulates write operations to different storage mediums (SD card, USB host and UMS devices), based on the provided input path. It is used by GameCardImageDumpTask to painlessly write data to the right output storage without explicitly having to implement multiple code paths for all storage types as part of the actual dump code. Furthermore, FileWriter also supports writing split files to FAT-formatted UMS devices if an output file is >= 4 GiB -- part file handling is completely abstracted away from any callers. Other changes include: * AsyncTask: rename all class methods to use PascalCase naming. * AsyncTask: rename get() -> GetResult(). * DataTransferTask: reflect the changes made to AsyncTask. * DataTransferTask: pause the RepeatingTask right after LoopCallback() returns true instead of pausing it in the cancel/post-execute callbacks. * DataTransferTask: add private FormatTimeString() method. * DataTransferTask: remove superfluous override for DoInBackground() -- classes derived from DataTransferTask must provide it on their own, anyway. * DataTransferTask: add public GetDurationString() method. * defines: update FAT32_FILESIZE_LIMIT macro to use UINT32_MAX. * defines: add CONCATENATION_FILE_PART_SIZE macro (used by the new FileWriter class). * DownloadTask: reflect the changes made to AsyncTask. * DumpOptionsFrame: file extension is no longer stored as a class member, nor required by the class constructor. * DumpOptionsFrame: change the return type for GetOutputFilePath() to bool. The method now saves its output to a variable passed by reference. * GameCardImageDumpOptionsFrame: reflect the changes made to DumpOptionsFrame. * i18n: update localization strings where applicable. * nxdt_utils: fix a potential buffer overflow in utilsGetFileSystemStatsByPath(). * OptionsTab: reflect the changes made to AsyncTask. * usb: add const qualifier to the input buffer required by usbSendFileData(). * usb: add const qualifier to the input buffer required by usbSendNspHeader().
2024-04-25 00:49:04 +01:00
/* Intended to be used with lists that need to be updated dynamically based on runtime events. */
/* Implements some hacky workarounds to prevent borealis from crashing and/or going out of focus. */
class LayeredErrorFrame: public brls::LayerView
2021-06-20 08:49:33 +01:00
{
private:
brls::SidebarItem *sidebar_item = nullptr;
protected:
2021-06-20 08:49:33 +01:00
ErrorFrame *error_frame = nullptr;
brls::List *list = nullptr;
bool IsListItemFocused(void);
int GetFocusStackViewIndex(void);
bool UpdateFocusStackViewAtIndex(int index, brls::View *view);
brls::View *GetListFirstFocusableChild(void);
void SwitchLayerView(bool use_error_frame, bool update_focused_view = false, bool update_focus_stack = true);
2021-06-20 08:49:33 +01:00
public:
LayeredErrorFrame(std::string msg = "");
void SetParentSidebarItem(brls::SidebarItem *sidebar_item);
2021-06-20 08:49:33 +01:00
};
}
#endif /* __LAYERED_ERROR_FRAME_HPP__ */