Skip to content

Commit

Permalink
Merge pull request #61 from w3irDv/enh/backupset
Browse files Browse the repository at this point in the history
enhancement: restore from batch backup |  fixes: savedata timestamp not shown, several bugs in from/to users operations
  • Loading branch information
w3irDv authored Aug 24, 2024
2 parents 9aa4171 + 28bd63a commit 0f6c2bc
Show file tree
Hide file tree
Showing 35 changed files with 1,059 additions and 608 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Docker Layer Caching
Expand All @@ -22,13 +22,13 @@ jobs:
docker build . --file Dockerfile --tag builder
docker run --rm -v ${PWD}:/project builder make release -j$(nproc)
- name: Upload Aroma version
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: SaveMiiModWUTPort-Aroma
path: SaveMiiModWUTPort-Aroma.zip
if-no-files-found: warn
- name: Upload HBL version
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: SaveMiiModWUTPort-HBL
path: SaveMiiModWUTPort-HBL.zip
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ghcr.io/wiiu-env/devkitppc:20231112
FROM ghcr.io/wiiu-env/devkitppc:20240704

COPY --from=ghcr.io/wiiu-env/libmocha:20231127 /artifacts $DEVKITPRO
COPY --from=ghcr.io/wiiu-env/libmocha:20240603 /artifacts $DEVKITPRO

RUN git clone --recursive https://github.com/yawut/libromfs-wiiu --single-branch && \
cd libromfs-wiiu && \
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ TOPDIR ?= $(CURDIR)
#-------------------------------------------------------------------------------
APP_NAME := SaveMii WUT Port
APP_SHORTNAME := SaveMii
APP_AUTHOR := DaThinkingChair
APP_AUTHOR := DaThinkingChair,w3irDv

include $(DEVKITPRO)/wut/share/wut_rules

Expand Down
39 changes: 39 additions & 0 deletions include/BackupSetList.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once

#include <string>
#include <vector>
#include <memory>

class BackupSetList {
public:
friend class BackupSetListState;

BackupSetList() {};
BackupSetList(const char *backupSetListRoot);
static std::unique_ptr<BackupSetList> currentBackupSetList;

void sort(bool sortAscending = false);
std::string at(int i);
void add(std::string backupSet);

static const std::string ROOT_BS;
static std::string getBackupSetSubPath() { return backupSetSubPath; }
static std::string getBackupSetEntry() { return backupSetEntry; }
static void setBackupSetEntry(int i);
static void setBackupSetSubPath();
static void initBackupSetList();
static void setBackupSetSubPathToRoot() { backupSetSubPath = "/"; }
static void saveBackupSetSubPath() { savedBackupSetSubPath = backupSetSubPath; }
static void restoreBackupSetSubPath() { backupSetSubPath = savedBackupSetSubPath; }

private:
static bool sortAscending;
std::vector<std::string> backupSets;
int entries;
std::string backupSetListRoot;
static std::string backupSetSubPath;
static std::string backupSetEntry;
static std::string savedBackupSetSubPath;

};

30 changes: 30 additions & 0 deletions include/Metadata.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#include <jansson.h>
#include <utils/StringUtils.h>
#include <savemng.h>

class Metadata {
public:
Metadata(uint32_t high, uint32_t low, uint8_t s) : highID(high),
lowID(low),
slot(s),
path (getDynamicBackupPath(highID, lowID, slot).append("/savemiiMeta.json")) {
}

Metadata(uint32_t high, uint32_t low, uint8_t s, std::string datetime) : highID(high),
lowID(low),
slot(s),
path (getBatchBackupPath(highID, lowID, slot, datetime).append("/savemiiMeta.json")) {
}

std::string get();
bool set(const std::string &date,bool isUSB);
static std::string serialId;

private:
uint32_t highID;
uint32_t lowID;
uint8_t slot;
std::string path;
};
21 changes: 0 additions & 21 deletions include/date.h

This file was deleted.

29 changes: 29 additions & 0 deletions include/menu/BackupSetListState.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#include <ApplicationState.h>
#include <memory>
#include <utils/InputUtils.h>




class BackupSetListState : public ApplicationState {
public:
BackupSetListState();
static void resetCursorPosition();
enum eState {
STATE_BACKUPSET_MENU,
STATE_DO_SUBSTATE,
};

void render() override;
ApplicationState::eSubState update(Input *input) override;

private:
std::unique_ptr<ApplicationState> subState{};
eState state = STATE_BACKUPSET_MENU;

bool sortAscending;

std::string backupSetListRoot;
};
1 change: 1 addition & 0 deletions include/menu/BatchBackupState.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class BatchBackupState : public ApplicationState {
void render() override;
ApplicationState::eSubState update(Input *input) override;


private:
std::unique_ptr<ApplicationState> subState{};
eState state = STATE_BATCH_BACKUP;
Expand Down
14 changes: 7 additions & 7 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 sdusers, int8_t allusers, bool common, int8_t allusers_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),
sdusers(sdusers),
allusers(allusers),
sduser(sduser),
wiiuuser(wiiuuser),
common(common),
allusers_d(allusers_d),
wiiuuser_d(wiiuuser_d),
titles(titles),
titleCount(titleCount) {}

Expand All @@ -34,10 +34,10 @@ class TitleOptionsState : public ApplicationState {

int *versionList;

int8_t sdusers;
int8_t allusers;
int8_t sduser;
int8_t wiiuuser;
bool common;
int8_t allusers_d;
int8_t wiiuuser_d;

Title *titles;
int titleCount;
Expand Down
17 changes: 12 additions & 5 deletions include/savemng.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,25 @@ std::string getUSB();
void consolePrintPos(int x, int y, const char *format, ...) __attribute__((hot));
bool promptConfirm(Style st, const std::string &question);
void promptError(const char *message, ...);
std::string getDynamicBackupPath(uint32_t highID, uint32_t lowID, uint8_t slot);
std::string getBatchBackupPath(uint32_t highID, uint32_t lowID, uint8_t slot, std::string datetime);
void getAccountsWiiU();
void getAccountsSD(Title *title, uint8_t slot);
bool hasAccountSave(Title *title, bool inSD, bool iine, uint32_t user, uint8_t slot, int version);
bool getLoadiineGameSaveDir(char *out, const char *productCode, const char *longName, const uint32_t highID, const uint32_t lowID);
bool getLoadiineSaveVersionList(int *out, const char *gamePath);
bool isSlotEmpty(uint32_t highID, uint32_t lowID, uint8_t slot);
bool isSlotEmpty(uint32_t highID, uint32_t lowID, uint8_t slot, const std::string &batchDatetime);
bool hasCommonSave(Title *title, bool inSD, bool iine, uint8_t slot, int version);
void copySavedata(Title *title, Title *titled, int8_t allusers, int8_t allusers_d, bool common) __attribute__((hot));
void backupAllSave(Title *titles, int count, OSCalendarTime *date) __attribute__((hot));
void backupSavedata(Title *title, uint8_t slot, int8_t allusers, bool common) __attribute__((hot));
void restoreSavedata(Title *title, uint8_t slot, int8_t sdusers, int8_t allusers, bool common) __attribute__((hot));
void wipeSavedata(Title *title, int8_t allusers, 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 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
5 changes: 4 additions & 1 deletion include/utils/Colors.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
#define COLOR_WHITE Color(0xffffffff)
#define COLOR_BLACK Color(0, 0, 0, 255)
#define COLOR_BACKGROUND Color(0x00006F00)
#define COLOR_TEXT COLOR_WHITE
#define COLOR_TEXT COLOR_WHITE
#define COLOR_LIST_HIGH Color(0x40D050FF)
#define COLOR_LIST Color(0x00FF00FF)
#define COLOR_INFO Color(0x88CC88FF)
2 changes: 1 addition & 1 deletion include/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

#define VERSION_MAJOR 1
#define VERSION_MINOR 6
#define VERSION_MICRO 2
#define VERSION_MICRO 3
8 changes: 4 additions & 4 deletions languages/SChinese.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@
"Filesize: %d bytes": "文件大小:%d 字节",
"Deleting folder %s": "正在删除 %s 文件夹",
"From: \n%s": "从:\n%s",
"Failed to delete folder %s\n%s": "删除文件夹失败 %s\n%s",
"Failed to delete folder %s: %s": "删除文件夹失败 %s: %s",
"Deleting file %s": "正在删除文件 %s",
"Failed to delete file %s\n%s": "删除文件失败 %s\n%s",
"Failed to delete file %s: %s": "删除文件失败 %s: %s",
"Loadiine game folder not found.": "Loadiine游戏文件夹没有发现。",
"Failed to open Loadiine game save directory.": "Loadiine游戏文件夹无法打开。",
"Are you sure?": "你确定吗?",
Expand All @@ -90,9 +90,9 @@
"Restore failed.": "还原保存数据失败。",
"Hm, are you REALLY sure?": "嘶,你真的真的要这样做?",
"Backup current savedata first?": "要不要先备份现在的保存数据?",
"Failed to delete common folder.\n%s": "删除common文件夹失败\n%s",
"Failed to delete common folder: %s": "删除common文件夹失败: %s",
"Failed to delete savefile.": "删除保存数据失败。",
"Failed to delete user folder.\n%s": "删除user文件夹失败\n%s",
"Failed to delete user folder: %s": "删除user文件夹失败: %s",
"Failed to import savedata from loadiine.": "导入loadiine保存数据失败。",
"Failed to export savedata to loadiine.": "导出保存数据到loadiine失败。"
}
8 changes: 4 additions & 4 deletions languages/TChinese.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@
"Filesize: %d bytes": "資料大小:%d 個字節",
"Deleting folder %s": "刪除資料夾 %s",
"From: \n%s": "從:\n%s",
"Failed to delete folder %s\n%s": "無法刪除資料夾 %s\n%s",
"Failed to delete folder %s: %s": "無法刪除資料夾 %s: %s",
"Deleting file %s": "刪除資料 %s",
"Failed to delete file %s\n%s": "無法刪除資料 %s\n%s",
"Failed to delete file %s: %s": "無法刪除資料 %s: %s",
"Loadiine game folder not found.": "未找到Loadiine遊戲資料夾。",
"Failed to open Loadiine game save directory.": "打開Loadiine遊戲保存資料夾失敗。",
"Are you sure?": "你確定嗎?",
Expand All @@ -90,9 +90,9 @@
"Restore failed.": "還原失敗。",
"Hm, are you REALLY sure?": "蛤?你真的確定嗎?",
"Backup current savedata first?": "先備份當前的保存數據?",
"Failed to delete common folder.\n%s": "無法刪除Common資料夾\n%s",
"Failed to delete common folder: %s": "無法刪除Common資料夾: %s",
"Failed to delete savefile.": "無法刪除保存資料。",
"Failed to delete user folder.\n%s": "無法刪除使用者資料夾\n%s",
"Failed to delete user folder: %s": "無法刪除使用者資料夾: %s",
"Failed to import savedata from loadiine.": "無法從loadiine導入保存數據。",
"Failed to export savedata to loadiine.": "無法導出保存數據到Loadiine。"
}
21 changes: 15 additions & 6 deletions languages/english.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"yes": "yes",
"no ": "no ",
"No 'common' save found.": "No 'common' save found.",
"\ue000: Restore \ue001: Back": "\ue000: Restore \ue001: Back",
"\ue000: Wipe \ue001: Back": "\ue000: Wipe \ue001: Back",
"\ue000: Import \ue001: Back": "\ue000: Import \ue001: Back",
"\ue000: Export \ue001: Back": "\ue000: Export \ue001: Back",
Expand All @@ -72,9 +71,9 @@
"Filesize: %d bytes": "Filesize: %d bytes",
"Deleting folder %s": "Deleting folder %s",
"From: \n%s": "From: \n%s",
"Failed to delete folder %s\n%s": "Failed to delete folder %s\n%s",
"Failed to delete folder %s: %s": "Failed to delete folder %s: %s",
"Deleting file %s": "Deleting file %s",
"Failed to delete file %s\n%s": "Failed to delete file %s\n%s",
"Failed to delete file %s: %s": "Failed to delete file %s: %s",
"Loadiine game folder not found.": "Loadiine game folder not found.",
"Failed to open Loadiine game save directory.": "Failed to open Loadiine game save directory.",
"Are you sure?": "Are you sure?",
Expand All @@ -90,9 +89,19 @@
"Restore failed.": "Restore failed.",
"Hm, are you REALLY sure?": "Hm, are you REALLY sure?",
"Backup current savedata first?": "Backup current savedata first?",
"Failed to delete common folder.\n%s": "Failed to delete common folder.\n%s",
"Failed to delete common folder: %s": "Failed to delete common folder: %s",
"Failed to delete savefile.": "Failed to delete savefile.",
"Failed to delete user folder.\n%s": "Failed to delete user folder.\n%s",
"Failed to delete user folder: %s": "Failed to delete user folder: %s",
"Failed to import savedata from loadiine.": "Failed to import savedata from loadiine.",
"Failed to export savedata to loadiine.": "Failed to export savedata to loadiine."
"Failed to export savedata to loadiine.": "Failed to export savedata to loadiine.",
"\ue083 Sort: %s \ue084": "\ue083 Sort: %s \ue084",
"\ue000: Select BackupSet \ue001: Back": "\ue000: Select BackupSet \ue001: Back",
"\ue002: Change BackupSet \ue000: Restore \ue001: Back": "\ue002: Change BackupSet \ue000: Restore \ue001: Back",
"WiiU USB Savedata >> slot 0": "WiiU USB Savedata >> slot 0",
"WiiU NAND Savedata >> slot 1": "WiiU NAND Savedata >> slot 1",
"vWii Savedata >> slot 0": "vWii Savedata >> slot 0",
"BackupSet: %s": "BackupSet: %s",
", from ": ", from ",
"Common save not restored.": "Common save not restored.",
"\ue001: Back": "\ue001: Back"
}
20 changes: 14 additions & 6 deletions languages/german.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"yes": "Ja",
"no ": "Nein ",
"No 'common' save found.": "Keine 'gemeinsame' Speicherung gefunden.",
"\ue000: Restore \ue001: Back": "\ue000: Wiederherstellen \ue001: Zurück",
"\ue000: Wipe \ue001: Back": "\ue000: Lösche \ue001: Zurück",
"\ue000: Import \ue001: Back": "\ue000: Importieren \ue001: Zurück",
"\ue000: Export \ue001: Back": "\ue000: Exportieren \ue001: Zurück",
Expand All @@ -72,9 +71,9 @@
"Filesize: %d bytes": "Dateigröße: %d bytes",
"Deleting folder %s": "Lösche Ordner %s",
"From: \n%s": "Von: \n%s",
"Failed to delete folder %s\n%s": "Löschen von Ordner %s\n%s fehlgeschlagen",
"Failed to delete folder %s: %s": "Löschen von Ordner %s: %s fehlgeschlagen",
"Deleting file %s": "Lösche Datei %s",
"Failed to delete file %s\n%s": "Löschen von Datei %s\n%s fehlgeschlagen",
"Failed to delete file %s: %s": "Löschen von Datei %s: %s fehlgeschlagen",
"Loadiine game folder not found.": "Loadiine Spielordner nicht gefunden.",
"Failed to open Loadiine game save directory.": "Fehlgeschlagen Loadiine Spielspeicherverzeichnis zu öffnen.",
"Are you sure?": "Bist du sicher?",
Expand All @@ -90,10 +89,19 @@
"Restore failed.": "Wiederherstellen fehlgeschlagen.",
"Hm, are you REALLY sure?": "Hm, are you REALLY sure?",
"Backup current savedata first?": "Sichere aktuellen Speicherstand zuerst?",
"Failed to delete common folder.\n%s": "Löschen von 'gemeinsamem' Ordner fehlgeschlagen.\n%s",
"Failed to delete common folder: %s": "Löschen von 'gemeinsamem' Ordner fehlgeschlagen: %s",
"Failed to delete savefile.": "Löschen von Speicherstand fehlgeschlagen.",
"Failed to delete user folder.\n%s": "Löschen vom Nutzerordner fehlgeschlagen.\n%s",
"Failed to delete user folder: %s": "Löschen vom Nutzerordner fehlgeschlagen: %s",
"Failed to import savedata from loadiine.": "Importieren von Loadiine Speicherdaten fehlgeschlagen.",
"Failed to export savedata to loadiine.": "Exportieren von Loadiine Speicherdaten fehlgeschlagen.",
"German": "Deutsch"
"\ue083 Sort: %s \ue084": "\ue083 Sortieren: %s \ue084",
"\ue000: Select BackupSet \ue001: Back": "\ue000: Wählen Sie BackupSet \ue001: Zurück",
"\ue002: Change BackupSet \ue000: Restore \ue001: Back": "\ue002: BackupSet ändern \ue000: Wiederherstellen \ue001: Zurück",
"WiiU USB Savedata >> slot 0": "WiiU USB Savedata >> slot 0",
"WiiU NAND Savedata >> slot 1": "WiiU NAND Savedata >> slot 1",
"vWii Savedata >> slot 0": "vWii Savedata >> slot 0",
"BackupSet: %s": "BackupSet: %s",
", from ": ", aus ",
"Common save not restored.": "'Gemeinsame' Sicherung nicht wiederhergestellt",
"\ue001: Back": "\ue001: Zurück"
}
Loading

0 comments on commit 0f6c2bc

Please sign in to comment.