2017-09-29 07:45:56 +00:00
|
|
|
/* This file is part of Checkpoint
|
|
|
|
> Copyright (C) 2017 Bernardo Giordano
|
|
|
|
>
|
|
|
|
> This program 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.
|
|
|
|
>
|
|
|
|
> This program 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 <http://www.gnu.org/licenses/>.
|
|
|
|
> See LICENSE for information.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
static Gui* menu;
|
|
|
|
|
2017-09-29 20:58:55 +00:00
|
|
|
void createInfo(std::string title, std::string message)
|
|
|
|
{
|
|
|
|
menu->createInfo(title, message);
|
|
|
|
}
|
|
|
|
|
2017-09-29 07:45:56 +00:00
|
|
|
void createError(Result res, std::string message)
|
|
|
|
{
|
|
|
|
menu->createError(res, message);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
servicesInit();
|
|
|
|
|
2017-10-04 11:19:10 +00:00
|
|
|
int selectionTimer = 0;
|
2017-10-14 18:26:47 +00:00
|
|
|
int refreshTimer = 0;
|
2017-09-29 07:45:56 +00:00
|
|
|
menu = new Gui();
|
|
|
|
|
|
|
|
createThread((ThreadFunc)threadLoadTitles);
|
|
|
|
|
|
|
|
while (aptMainLoop() && !(hidKeysDown() & KEY_START)) {
|
|
|
|
hidScanInput();
|
|
|
|
|
|
|
|
if (hidKeysDown() & KEY_A)
|
|
|
|
{
|
2017-10-02 12:19:31 +00:00
|
|
|
menu->setBottomScroll(true);
|
2017-09-29 07:45:56 +00:00
|
|
|
menu->updateButtonsColor();
|
2017-10-02 12:19:31 +00:00
|
|
|
setEntryType(CELLS);
|
2017-09-29 07:45:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hidKeysDown() & KEY_B)
|
|
|
|
{
|
|
|
|
menu->setBottomScroll(false);
|
|
|
|
menu->updateButtonsColor();
|
|
|
|
setEntryType(TITLES);
|
2017-10-03 12:16:10 +00:00
|
|
|
clearSelectedEntries();
|
2017-09-29 07:45:56 +00:00
|
|
|
}
|
|
|
|
|
2017-09-29 20:58:55 +00:00
|
|
|
if (hidKeysDown() & KEY_X)
|
|
|
|
{
|
2017-12-23 14:29:53 +00:00
|
|
|
if (menu->getBottomScroll())
|
|
|
|
{
|
|
|
|
bool isSaveMode = getMode() == MODE_SAVE;
|
|
|
|
size_t index = getScrollableIndex();
|
|
|
|
// avoid actions if X is pressed on "New..."
|
|
|
|
if (index > 0)
|
|
|
|
{
|
|
|
|
Title title;
|
|
|
|
getTitle(title, menu->getNormalizedIndex());
|
|
|
|
std::vector<std::u16string> list = isSaveMode ? title.getDirectories() : title.getExtdatas();
|
|
|
|
std::u16string basepath = isSaveMode ? title.getBackupPath() : title.getExtdataPath();
|
|
|
|
deleteBackupFolder(basepath + u8tou16("/") + list.at(index));
|
|
|
|
refreshDirectories(title.getId());
|
|
|
|
setScrollableIndex(index - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
menu->resetIndex();
|
|
|
|
setMode(getMode() == MODE_SAVE ? MODE_EXTDATA : MODE_SAVE);
|
|
|
|
clearSelectedEntries();
|
|
|
|
}
|
2017-09-29 20:58:55 +00:00
|
|
|
}
|
|
|
|
|
2017-10-03 12:16:10 +00:00
|
|
|
if (hidKeysDown() & KEY_Y)
|
|
|
|
{
|
|
|
|
addSelectedEntry(menu->getNormalizedIndex());
|
|
|
|
}
|
|
|
|
|
2017-10-04 11:19:10 +00:00
|
|
|
if (hidKeysHeld() & KEY_Y)
|
|
|
|
{
|
|
|
|
selectionTimer++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
selectionTimer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selectionTimer > 90)
|
|
|
|
{
|
|
|
|
clearSelectedEntries();
|
|
|
|
for (size_t i = 0, sz = getTitlesCount(); i < sz; i++)
|
|
|
|
{
|
|
|
|
addSelectedEntry(i);
|
|
|
|
}
|
|
|
|
selectionTimer = 0;
|
|
|
|
}
|
2017-10-14 18:26:47 +00:00
|
|
|
|
|
|
|
if (hidKeysHeld() & KEY_B)
|
|
|
|
{
|
|
|
|
refreshTimer++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
refreshTimer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (refreshTimer > 90)
|
|
|
|
{
|
|
|
|
createThread((ThreadFunc)threadLoadTitles);
|
|
|
|
refreshTimer = 0;
|
|
|
|
}
|
2017-10-04 11:19:10 +00:00
|
|
|
|
2017-09-29 07:45:56 +00:00
|
|
|
if (menu->isBackupReleased())
|
|
|
|
{
|
2017-10-03 12:16:10 +00:00
|
|
|
if (multipleSelectionEnabled())
|
|
|
|
{
|
|
|
|
resetDirectoryListIndex();
|
|
|
|
std::vector<size_t> list = getSelectedEntries();
|
|
|
|
for (size_t i = 0, sz = list.size(); i < sz; i++)
|
|
|
|
{
|
|
|
|
backup(list.at(i));
|
|
|
|
}
|
|
|
|
clearSelectedEntries();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
backup(menu->getNormalizedIndex());
|
|
|
|
}
|
2017-09-29 07:45:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (menu->isRestoreReleased())
|
|
|
|
{
|
2017-10-04 11:19:10 +00:00
|
|
|
if (multipleSelectionEnabled())
|
|
|
|
{
|
|
|
|
clearSelectedEntries();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
restore(menu->getNormalizedIndex());
|
|
|
|
}
|
2017-09-29 07:45:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
menu->updateSelector();
|
|
|
|
menu->draw();
|
|
|
|
}
|
|
|
|
|
|
|
|
delete menu;
|
|
|
|
|
|
|
|
destroyThreads();
|
|
|
|
servicesExit();
|
|
|
|
}
|