diff --git a/Makefile b/Makefile index 86c823f..a9c8e68 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ INCLUDES := inc EXEFS_SRC := exefs_src APP_TITLE := JKSV APP_AUTHOR := JK -APP_VERSION := 04.26.2020 +APP_VERSION := 04.30.2020 ROMFS := romfs #--------------------------------------------------------------------------------- diff --git a/README.MD b/README.MD index 9a45aad..1ad445f 100644 --- a/README.MD +++ b/README.MD @@ -1,9 +1,7 @@ # JKSV Data Dump/Restore tool for Switch. -
-
## Info JKSV on Switch started as a small project/port to test some things and get familiar with libnx. A list of what it currently can do: @@ -22,6 +20,8 @@ JKSV on Switch started as a small project/port to test some things and get famil * Hold R while opening a game or applet with Atmosphere so the homebrew menu loads. Open JKSV and press minus and select **Mount Process RomFS**. The romfs of the app should appear in the browser along with your SD on the right. ## Quick Guide +**A custom path can be defined by creating "sdmc:/switch/jksv_dir.txt" and typing the path you want to use. For example, `sdmc:/switch/JKSV/` will force JKSV to create its folder in the switch homebrew folder.** + 1. User Select * A opens the selected user's save files. * Y Dumps __all__ save data from __all users__, device save data, and BCAT save data. System save data is not included in this. diff --git a/inc/ui.h b/inc/ui.h index 48b5836..d70836d 100644 --- a/inc/ui.h +++ b/inc/ui.h @@ -62,10 +62,10 @@ namespace ui extern std::vector selButtons; - //Sets colors and stuff + //Sets colors and loads font for icon creation void initTheme(); - //Loads in the A, B, X, Y button graphics + //Loads graphics and stuff void init(); void exit(); diff --git a/src/ex.c b/src/ex.c index dd223d5..4aa2148 100644 --- a/src/ex.c +++ b/src/ex.c @@ -4,7 +4,8 @@ Result fsOpenDataFileSystemByCurrentProcess(FsFileSystem *out) { - /*Result ret = 0; + /* + Result ret = 0; IpcCommand c; ipcInitialize(&c); diff --git a/src/file.cpp b/src/file.cpp index b4af958..57a459a 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -128,13 +128,40 @@ static inline size_t fsize(const std::string& _f) return ret; } +static void mkdirRec(const std::string& _p) +{ + //skip first slash + size_t pos = _p.find('/', 0) + 1; + while((pos = _p.find('/', pos)) != _p.npos) + { + std::string create; + create.assign(_p.begin(), _p.begin() + pos); + mkdir(create.c_str(), 777); + ++pos; + } +} + namespace fs { void init() { - mkdir("sdmc:/JKSV", 777); - logOpen(); - wd = "sdmc:/JKSV/"; + if(fs::fileExists("sdmc:/switch/jksv_dir.txt")) + { + char tmp[256]; + FILE *getDir = fopen("sdmc:/switch/jksv_dir.txt", "r"); + fgets(tmp, 256, getDir); + fclose(getDir); + wd = tmp; + util::stripNL(wd); + mkdirRec(wd); + } + else + { + mkdir("sdmc:/JKSV", 777); + wd = "sdmc:/JKSV/"; + } + //to fix later + //logOpen(); } void exit() @@ -500,10 +527,11 @@ namespace fs void logOpen() { - remove("sdmc:/JKSV/log.txt"); + std::string logPath = wd + "log.txt"; + remove(logPath.c_str()); FsFileSystem *sd = fsdevGetDeviceFileSystem("sdmc"); - fsFsCreateFile(sd, "/JKSV/log.txt", 0, FsWriteOption_Flush); - fsFsOpenFile(sd, "/JKSV/log.txt", FsOpenMode_Write, &logFile); + fsFsCreateFile(sd, logPath.c_str(), 0, FsWriteOption_Flush); + fsFsOpenFile(sd, logPath.c_str(), FsOpenMode_Write, &logFile); } void logWrite(const char *fmt, ...) diff --git a/src/gfx.c b/src/gfx.c index 87b0cb2..f9e04b2 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -66,7 +66,7 @@ bool graphicsInit(int windowWidth, int windowHeight) framebufferCreate(&fb, window, windowWidth, windowHeight, PIXEL_FORMAT_RGBA_8888, 2); framebufferMakeLinear(&fb); - plInitialize(); + plInitialize(PlServiceType_System); //Make a fake tex that points to framebuffer frameBuffer = malloc(sizeof(tex)); diff --git a/src/ui.cpp b/src/ui.cpp index 317668a..78f6bf0 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -10,7 +10,7 @@ #include "util.h" #include "file.h" -#define VER_STRING "v. 04.26.2020" +#define VER_STRING "v. 04.30.2020" //Nav buttons std::vector usrNav, ttlNav, fldNav; @@ -94,25 +94,9 @@ namespace ui setsysGetColorSetId(&thmID); - mnuTopLeft = texLoadPNGFile("romfs:/img/fb/menuTopLeft.png"); - mnuTopRight = texLoadPNGFile("romfs:/img/fb/menuTopRight.png"); - mnuBotLeft = texLoadPNGFile("romfs:/img/fb/menuBotLeft.png"); - mnuBotRight = texLoadPNGFile("romfs:/img/fb/menuBotRight.png"); - switch(thmID) { case ColorSetId_Light: - //Dark corners - cornerTopLeft = texLoadPNGFile("romfs:/img/tboxDrk/tboxCornerTopLeft.png"); - cornerTopRight = texLoadPNGFile("romfs:/img/tboxDrk/tboxCornerTopRight.png"); - cornerBottomLeft = texLoadPNGFile("romfs:/img/tboxDrk/tboxCornerBotLeft.png"); - cornerBottomRight = texLoadPNGFile("romfs:/img/tboxDrk/tboxCornerBotRight.png"); - progCovLeft = texLoadPNGFile("romfs:/img/tboxDrk/progBarCoverLeftDrk.png"); - progCovRight = texLoadPNGFile("romfs:/img/tboxDrk/progBarCoverRightDrk.png"); - - icn = texLoadPNGFile("romfs:/img/icn/icnDrk.png"); - sideBar = texLoadPNGFile("romfs:/img/fb/lLight.png"); - clearClr = clrCreateU32(0xFFEBEBEB); mnuTxt = clrCreateU32(0xFF000000); txtClr = clrCreateU32(0xFFFFFFFF); @@ -127,17 +111,6 @@ namespace ui case ColorSetId_Dark: //jic thmID = ColorSetId_Dark; - //Light corners - cornerTopLeft = texLoadPNGFile("romfs:/img/tboxLght/tboxCornerTopLeft.png"); - cornerTopRight = texLoadPNGFile("romfs:/img/tboxLght/tboxCornerTopRight.png"); - cornerBottomLeft = texLoadPNGFile("romfs:/img/tboxLght/tboxCornerBotLeft.png"); - cornerBottomRight = texLoadPNGFile("romfs:/img/tboxLght/tboxCornerBotRight.png"); - progCovLeft = texLoadPNGFile("romfs:/img/tboxLght/progBarCoverLeftLight.png"); - progCovRight = texLoadPNGFile("romfs:/img/tboxLght/progBarCoverRightLight.png"); - - icn = texLoadPNGFile("romfs:/img/icn/icnLght.png"); - sideBar = texLoadPNGFile("romfs:/img/fb/lDark.png"); - clearClr = clrCreateU32(0xFF2D2D2D); mnuTxt = clrCreateU32(0xFFFFFFFF); txtClr = clrCreateU32(0xFF000000); @@ -152,6 +125,39 @@ namespace ui void init() { + mnuTopLeft = texLoadPNGFile("romfs:/img/fb/menuTopLeft.png"); + mnuTopRight = texLoadPNGFile("romfs:/img/fb/menuTopRight.png"); + mnuBotLeft = texLoadPNGFile("romfs:/img/fb/menuBotLeft.png"); + mnuBotRight = texLoadPNGFile("romfs:/img/fb/menuBotRight.png"); + switch(ui::thmID) + { + case ColorSetId_Light: + //Dark corners + cornerTopLeft = texLoadPNGFile("romfs:/img/tboxDrk/tboxCornerTopLeft.png"); + cornerTopRight = texLoadPNGFile("romfs:/img/tboxDrk/tboxCornerTopRight.png"); + cornerBottomLeft = texLoadPNGFile("romfs:/img/tboxDrk/tboxCornerBotLeft.png"); + cornerBottomRight = texLoadPNGFile("romfs:/img/tboxDrk/tboxCornerBotRight.png"); + progCovLeft = texLoadPNGFile("romfs:/img/tboxDrk/progBarCoverLeftDrk.png"); + progCovRight = texLoadPNGFile("romfs:/img/tboxDrk/progBarCoverRightDrk.png"); + + icn = texLoadPNGFile("romfs:/img/icn/icnDrk.png"); + sideBar = texLoadPNGFile("romfs:/img/fb/lLight.png"); + break; + + default: + //Light corners + cornerTopLeft = texLoadPNGFile("romfs:/img/tboxLght/tboxCornerTopLeft.png"); + cornerTopRight = texLoadPNGFile("romfs:/img/tboxLght/tboxCornerTopRight.png"); + cornerBottomLeft = texLoadPNGFile("romfs:/img/tboxLght/tboxCornerBotLeft.png"); + cornerBottomRight = texLoadPNGFile("romfs:/img/tboxLght/tboxCornerBotRight.png"); + progCovLeft = texLoadPNGFile("romfs:/img/tboxLght/progBarCoverLeftLight.png"); + progCovRight = texLoadPNGFile("romfs:/img/tboxLght/progBarCoverRightLight.png"); + + icn = texLoadPNGFile("romfs:/img/icn/icnLght.png"); + sideBar = texLoadPNGFile("romfs:/img/fb/lDark.png"); + break; + } + top = texCreate(1280, 88); bot = texCreate(1280, 72); @@ -193,7 +199,6 @@ namespace ui folderHelpX = 1220 - textGetWidth(folderHelp.c_str(), ui::shared, 18); optHelpX = 1220 - textGetWidth(optHelp.c_str(), ui::shared, 18); - advCopyMenuPrep(); ui::exMenuPrep(); ui::optMenuInit(); diff --git a/src/ui/advmode.cpp b/src/ui/advmode.cpp index 095bfdd..46e15c3 100644 --- a/src/ui/advmode.cpp +++ b/src/ui/advmode.cpp @@ -281,7 +281,7 @@ void performCopyMenuOps() fs::getDirProps(fullPath, dirCnt, fileCnt, fileSize); char mess[256]; sprintf(mess, "#%s#:\n%u Folders\n%u Files\nTotal Size: %.2fMB", fullPath.c_str(), dirCnt, fileCnt, (float)((float)fileSize / 1024 / 1024)); - ui::showMessage(mess, "Folder Props"); + ui::showMessage("Folder Properties", mess); } else { diff --git a/src/util.cpp b/src/util.cpp index 9dcddf1..bf4717c 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -250,6 +250,9 @@ namespace util size_t pos = 0; while((pos = _s.find('\n')) != _s.npos) _s.erase(pos, 1); + + while((pos = _s.find('\r')) != _s.npos) + _s.erase(pos, 1); } void replaceButtonsInString(std::string& rep)