Skip to content

Commit

Permalink
use getBatchBackupPath function and Id > ID
Browse files Browse the repository at this point in the history
  • Loading branch information
w3irDv committed Aug 24, 2024
1 parent c63e9db commit e6b7f68
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 73 deletions.
10 changes: 5 additions & 5 deletions include/menu/TitleOptionsState.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

class TitleOptionsState : public ApplicationState {
public:
TitleOptionsState(Title title, Task task, int *versionList, int8_t sduser, int8_t wiiuser, bool common, int8_t wiiuser_d, Title *titles, int titleCount) : title(title),
TitleOptionsState(Title title, Task task, int *versionList, int8_t sduser, int8_t wiiuuser, bool common, int8_t wiiuuser_d, Title *titles, int titleCount) : title(title),
task(task),
versionList(versionList),
sduser(sduser),
wiiuser(wiiuser),
wiiuuser(wiiuuser),
common(common),
wiiuser_d(wiiuser_d),
wiiuuser_d(wiiuuser_d),
titles(titles),
titleCount(titleCount) {}

Expand All @@ -35,9 +35,9 @@ class TitleOptionsState : public ApplicationState {
int *versionList;

int8_t sduser;
int8_t wiiuser;
int8_t wiiuuser;
bool common;
int8_t wiiuser_d;
int8_t wiiuuser_d;

Title *titles;
int titleCount;
Expand Down
8 changes: 4 additions & 4 deletions include/savemng.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ bool getLoadiineGameSaveDir(char *out, const char *productCode, const char *long
bool getLoadiineSaveVersionList(int *out, const char *gamePath);
bool isSlotEmpty(uint32_t highID, uint32_t lowID, uint8_t slot);
bool hasCommonSave(Title *title, bool inSD, bool iine, uint8_t slot, int version);
void copySavedata(Title *title, Title *titled, int8_t wiiuser, int8_t wiiuser_d, bool common) __attribute__((hot));
void copySavedata(Title *title, Title *titled, int8_t wiiuuser, int8_t wiiuuser_d, bool common) __attribute__((hot));
std::string getNowDateForFolder() __attribute__((hot));
std::string getNowDate() __attribute__((hot));
void writeMetadata(uint32_t highID,uint32_t lowID,uint8_t slot,bool isUSB) __attribute__((hot));
void writeMetadata(uint32_t highID,uint32_t lowID,uint8_t slot,bool isUSB,const std::string &batchDatetime) __attribute__((hot));
void backupAllSave(Title *titles, int count, const std::string &batchDatetime) __attribute__((hot));
void backupSavedata(Title *title, uint8_t slot, int8_t wiiuser, bool common) __attribute__((hot));
void restoreSavedata(Title *title, uint8_t slot, int8_t sduser, int8_t wiiuser, bool common) __attribute__((hot));
void wipeSavedata(Title *title, int8_t wiiuser, bool common) __attribute__((hot));
void backupSavedata(Title *title, uint8_t slot, int8_t wiiuuser, bool common) __attribute__((hot));
void restoreSavedata(Title *title, uint8_t slot, int8_t sduser, int8_t wiiuuser, bool common) __attribute__((hot));
void wipeSavedata(Title *title, int8_t wiiuuser, bool common) __attribute__((hot));
void importFromLoadiine(Title *title, bool common, int version);
void exportToLoadiine(Title *title, bool common, int version);
int checkEntry(const char *fPath);
Expand Down
72 changes: 36 additions & 36 deletions src/menu/TitleOptionsState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ void TitleOptionsState::render() {

if (task == wipe) {
consolePrintPos(M_OFF, 7, LanguageUtils::gettext("Select Wii U user to delete from:"));
if (this->wiiuser == -1)
if (this->wiiuuser == -1)
consolePrintPos(M_OFF, 8, " < %s >", LanguageUtils::gettext("all users"));
else
consolePrintPos(M_OFF, 8, " < %s (%s) > (%s)", getWiiUacc()[this->wiiuser].miiName,
getWiiUacc()[this->wiiuser].persistentID,
hasAccountSave(&this->title, false, false, getWiiUacc()[this->wiiuser].pID,
consolePrintPos(M_OFF, 8, " < %s (%s) > (%s)", getWiiUacc()[this->wiiuuser].miiName,
getWiiUacc()[this->wiiuuser].persistentID,
hasAccountSave(&this->title, false, false, getWiiUacc()[this->wiiuuser].pID,
slot, 0)
? LanguageUtils::gettext("Has Save")
: LanguageUtils::gettext("Empty"));
Expand All @@ -84,15 +84,15 @@ void TitleOptionsState::render() {
else {
consolePrintPos(M_OFF, (task == restore) ? 10 : 7, LanguageUtils::gettext("Select Wii U user%s:"),
(task == copytoOtherDevice) ? LanguageUtils::gettext(" to copy from") : ((task == restore) ? LanguageUtils::gettext(" to copy to") : ""));
if (this->wiiuser == -1)
if (this->wiiuuser == -1)
consolePrintPos(M_OFF, (task == restore) ? 11 : 8, " < %s >", LanguageUtils::gettext("all users"));
else
consolePrintPos(M_OFF, (task == restore) ? 11 : 8, " < %s (%s) > (%s)",
getWiiUacc()[wiiuser].miiName, getWiiUacc()[wiiuser].persistentID,
getWiiUacc()[wiiuuser].miiName, getWiiUacc()[wiiuuser].persistentID,
hasAccountSave(&this->title,
(!((task == backup) || (task == restore) || (task == copytoOtherDevice))),
(!((task < 3) || (task == copytoOtherDevice))),
getWiiUacc()[this->wiiuser].pID, slot,
getWiiUacc()[this->wiiuuser].pID, slot,
this->versionList != nullptr ? this->versionList[slot] : 0)
? LanguageUtils::gettext("Has Save")
: LanguageUtils::gettext("Empty"));
Expand All @@ -109,19 +109,19 @@ void TitleOptionsState::render() {
if (task == copytoOtherDevice) {
entrycount++;
consolePrintPos(M_OFF, 10, LanguageUtils::gettext("Select Wii U user%s:"), (task == copytoOtherDevice) ? LanguageUtils::gettext(" to copy to") : "");
if (wiiuser_d == -1)
if (wiiuuser_d == -1)
consolePrintPos(M_OFF, 11, " < %s >", LanguageUtils::gettext("all users"));
else
consolePrintPos(M_OFF, 11, " < %s (%s) > (%s)", getWiiUacc()[wiiuser_d].miiName,
getWiiUacc()[wiiuser_d].persistentID,
consolePrintPos(M_OFF, 11, " < %s (%s) > (%s)", getWiiUacc()[wiiuuser_d].miiName,
getWiiUacc()[wiiuuser_d].persistentID,
hasAccountSave(&titles[this->title.dupeID], false, false,
getWiiUacc()[wiiuser_d].pID, 0, 0)
getWiiUacc()[wiiuuser_d].pID, 0, 0)
? LanguageUtils::gettext("Has Save")
: LanguageUtils::gettext("Empty"));
}

if ((task != importLoadiine) && (task != exportLoadiine)) {
if (this->wiiuser > -1) {
if (this->wiiuuser > -1) {
if (hasCommonSave(&this->title,
(!((task == backup) || (task == wipe) || (task == copytoOtherDevice))),
(!((task < 3) || (task == copytoOtherDevice))), slot,
Expand Down Expand Up @@ -206,12 +206,12 @@ ApplicationState::eSubState TitleOptionsState::update(Input *input) {
case 0:
break;
case 1:
this->wiiuser = ((this->wiiuser == -1) ? -1 : (this->wiiuser - 1));
wiiuser_d = this->wiiuser;
this->wiiuuser = ((this->wiiuuser == -1) ? -1 : (this->wiiuuser - 1));
wiiuuser_d = this->wiiuuser;
break;
case 2:
wiiuser_d = (((this->wiiuser == -1) || (wiiuser_d == -1)) ? -1 : (wiiuser_d - 1));
wiiuser_d = ((this->wiiuser > -1) && (wiiuser_d == -1)) ? 0 : wiiuser_d;
wiiuuser_d = (((this->wiiuuser == -1) || (wiiuuser_d == -1)) ? -1 : (wiiuuser_d - 1));
wiiuuser_d = ((this->wiiuuser > -1) && (wiiuuser_d == -1)) ? 0 : wiiuuser_d;
break;
case 3:
common = common ? false : true;
Expand All @@ -226,16 +226,16 @@ ApplicationState::eSubState TitleOptionsState::update(Input *input) {
if ( sduser > getSDaccn() - 1 )
{
sduser = -1;
wiiuser = -1;
wiiuuser = -1;
}
break;
case 1:
sduser = ((sduser == -1) ? -1 : (sduser - 1));
this->wiiuser = ((sduser == -1) ? -1 : this->wiiuser);
this->wiiuuser = ((sduser == -1) ? -1 : this->wiiuuser);
break;
case 2:
wiiuser = (((wiiuser == -1) || (sduser == -1)) ? -1 : (wiiuser - 1));
wiiuser = ((sduser > -1) && (wiiuser == -1)) ? 0 : wiiuser;
wiiuuser = (((wiiuuser == -1) || (sduser == -1)) ? -1 : (wiiuuser - 1));
wiiuuser = ((sduser > -1) && (wiiuuser == -1)) ? 0 : wiiuuser;
break;
case 3:
common = common ? false : true;
Expand All @@ -248,7 +248,7 @@ ApplicationState::eSubState TitleOptionsState::update(Input *input) {
case 0:
break;
case 1:
wiiuser = ((wiiuser == -1) ? -1 : (wiiuser - 1));
wiiuuser = ((wiiuuser == -1) ? -1 : (wiiuuser - 1));
break;
case 2:
common = common ? false : true;
Expand All @@ -273,7 +273,7 @@ ApplicationState::eSubState TitleOptionsState::update(Input *input) {
slot--;
break;
case 1:
wiiuser = ((wiiuser == -1) ? -1 : (wiiuser - 1));
wiiuuser = ((wiiuuser == -1) ? -1 : (wiiuuser - 1));
break;
case 2:
common = common ? false : true;
Expand All @@ -289,12 +289,12 @@ ApplicationState::eSubState TitleOptionsState::update(Input *input) {
case 0:
break;
case 1:
wiiuser = ((wiiuser == (getWiiUaccn() - 1)) ? (getWiiUaccn() - 1) : (wiiuser + 1));
wiiuser_d = wiiuser;
wiiuuser = ((wiiuuser == (getWiiUaccn() - 1)) ? (getWiiUaccn() - 1) : (wiiuuser + 1));
wiiuuser_d = wiiuuser;
break;
case 2:
wiiuser_d = ((wiiuser_d == (getWiiUaccn() - 1)) ? (getWiiUaccn() - 1) : (wiiuser_d + 1));
wiiuser_d = (wiiuser == -1) ? -1 : wiiuser_d;
wiiuuser_d = ((wiiuuser_d == (getWiiUaccn() - 1)) ? (getWiiUaccn() - 1) : (wiiuuser_d + 1));
wiiuuser_d = (wiiuuser == -1) ? -1 : wiiuuser_d;
break;
case 3:
common = common ? false : true;
Expand All @@ -309,16 +309,16 @@ ApplicationState::eSubState TitleOptionsState::update(Input *input) {
if ( sduser > getSDaccn() -1 )
{
sduser = -1;
wiiuser = -1;
wiiuuser = -1;
}
break;
case 1:
sduser = ((sduser == (getSDaccn() - 1)) ? (getSDaccn() - 1) : (sduser + 1));
wiiuser = ((sduser > -1) && (wiiuser == -1)) ? 0 : wiiuser;
wiiuuser = ((sduser > -1) && (wiiuuser == -1)) ? 0 : wiiuuser;
break;
case 2:
wiiuser = ((wiiuser == (getWiiUaccn() - 1)) ? (getWiiUaccn() - 1) : (wiiuser + 1));
wiiuser = (sduser == -1) ? -1 : wiiuser;
wiiuuser = ((wiiuuser == (getWiiUaccn() - 1)) ? (getWiiUaccn() - 1) : (wiiuuser + 1));
wiiuuser = (sduser == -1) ? -1 : wiiuuser;
break;
case 3:
common = common ? false : true;
Expand All @@ -331,7 +331,7 @@ ApplicationState::eSubState TitleOptionsState::update(Input *input) {
case 0:
break;
case 1:
wiiuser = ((wiiuser == (getWiiUaccn() - 1)) ? (getWiiUaccn() - 1) : (wiiuser + 1));
wiiuuser = ((wiiuuser == (getWiiUaccn() - 1)) ? (getWiiUaccn() - 1) : (wiiuuser + 1));
break;
case 2:
common = common ? false : true;
Expand All @@ -356,7 +356,7 @@ ApplicationState::eSubState TitleOptionsState::update(Input *input) {
slot++;
break;
case 1:
wiiuser = ((wiiuser == (getWiiUaccn() - 1)) ? (getWiiUaccn() - 1) : (wiiuser + 1));
wiiuuser = ((wiiuuser == (getWiiUaccn() - 1)) ? (getWiiUaccn() - 1) : (wiiuuser + 1));
break;
case 2:
common = common ? false : true;
Expand All @@ -376,21 +376,21 @@ ApplicationState::eSubState TitleOptionsState::update(Input *input) {
if (input->get(TRIGGER, PAD_BUTTON_A)) {
switch (this->task) {
case backup:
backupSavedata(&this->title, slot, wiiuser, common);
backupSavedata(&this->title, slot, wiiuuser, common);
DrawUtils::setRedraw(true);
break;
case restore:
restoreSavedata(&this->title, slot, sduser, wiiuser, common);
restoreSavedata(&this->title, slot, sduser, wiiuuser, common);
DrawUtils::setRedraw(true);
break;
case wipe:
wipeSavedata(&this->title, wiiuser, common);
wipeSavedata(&this->title, wiiuuser, common);
DrawUtils::setRedraw(true);
break;
case copytoOtherDevice:
for (int i = 0; i < this->titleCount; i++) {
if (titles[i].listID == this->title.dupeID) {
copySavedata(&this->title, &titles[i], wiiuser, wiiuser_d, common);
copySavedata(&this->title, &titles[i], wiiuuser, wiiuuser_d, common);
DrawUtils::setRedraw(true);
break;
}
Expand Down
8 changes: 4 additions & 4 deletions src/menu/TitleTaskState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
static int cursorPos = 0;
static int entrycount;
static uint8_t slot = 0;
static int8_t wiiuser = -1, wiiuser_d = -1, sduser = -1;
static int8_t wiiuuser = -1, wiiuuser_d = -1, sduser = -1;
static bool common = true;

void TitleTaskState::render() {
Expand Down Expand Up @@ -64,8 +64,8 @@ ApplicationState::eSubState TitleTaskState::update(Input *input) {
if (this->task == restore) {
BackupSetList::setBackupSetSubPath();
getAccountsSD(&this->title, slot);
wiiuser = ((sduser == -1) ? -1 : wiiuser);
sduser = ((wiiuser == -1) ? -1 : sduser);
wiiuuser = ((sduser == -1) ? -1 : wiiuuser);
sduser = ((wiiuuser == -1) ? -1 : sduser);
}

if (this->task == wipe) {
Expand Down Expand Up @@ -103,7 +103,7 @@ ApplicationState::eSubState TitleTaskState::update(Input *input) {
if (noError) {
DrawUtils::setRedraw(true);
this->state = STATE_DO_SUBSTATE;
this->subState = std::make_unique<TitleOptionsState>(this->title, this->task, this->versionList, sduser, wiiuser, common, wiiuser_d, this->titles, this->titlesCount);
this->subState = std::make_unique<TitleOptionsState>(this->title, this->task, this->versionList, sduser, wiiuuser, common, wiiuuser_d, this->titles, this->titlesCount);
}
}
if (cursorPos > entrycount)
Expand Down
Loading

0 comments on commit e6b7f68

Please sign in to comment.