mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-07 16:59:08 +00:00
Add deleteTitle and bootTitle.
**ONLY USE "DELETE TITLE" WHEN NEEDED!!!!!!!!!!!!!**
This commit is contained in:
@@ -2,4 +2,8 @@
|
|||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
|
||||||
|
#include <3ds.h>
|
||||||
|
|
||||||
|
Result CIA_LaunchTitle(u64 titleId, FS_MediaType mediaType);
|
||||||
|
Result deletePrevious(u64 titleid, FS_MediaType media);
|
||||||
Result installCia(const char * ciaPath);
|
Result installCia(const char * ciaPath);
|
||||||
@@ -45,6 +45,9 @@ namespace ScriptHelper {
|
|||||||
void displayTimeMsg(std::string message, int seconds);
|
void displayTimeMsg(std::string message, int seconds);
|
||||||
|
|
||||||
bool checkIfValid(std::string scriptFile, int mode = 0);
|
bool checkIfValid(std::string scriptFile, int mode = 0);
|
||||||
|
|
||||||
|
void deleteTitle(const std::string TitleID, bool isNAND, std::string message);
|
||||||
|
void bootTitle(const std::string TitleID, bool isNAND, std::string message);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -111,5 +111,10 @@
|
|||||||
"OWNER_AND_REPO": "Owner & Repo",
|
"OWNER_AND_REPO": "Owner & Repo",
|
||||||
"FILENAME": "Filename",
|
"FILENAME": "Filename",
|
||||||
"OK": "OK",
|
"OK": "OK",
|
||||||
"DELETE_STORE": "Would you like to delete this store?"
|
"DELETE_STORE": "Would you like to delete this store?",
|
||||||
|
|
||||||
|
"DELETE_TITLE": "Would you like to delete this title?",
|
||||||
|
"MEDIATYPE_SD": "MediaType SD",
|
||||||
|
"MEDIATYPE_NAND": "MediaType NAND",
|
||||||
|
"BOOT_TITLE": "Would you like to boot this title?"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ void Init::stopMusic(void) {
|
|||||||
Result Init::Initialize() {
|
Result Init::Initialize() {
|
||||||
gfxInitDefault();
|
gfxInitDefault();
|
||||||
romfsInit();
|
romfsInit();
|
||||||
|
amInit();
|
||||||
Gui::init();
|
Gui::init();
|
||||||
Gui::loadSheet("romfs:/gfx/sprites.t3x", sprites);
|
Gui::loadSheet("romfs:/gfx/sprites.t3x", sprites);
|
||||||
sdmcInit();
|
sdmcInit();
|
||||||
@@ -151,6 +152,8 @@ Result Init::MainLoop() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern void freeSheet();
|
||||||
|
|
||||||
Result Init::Exit() {
|
Result Init::Exit() {
|
||||||
if (songIsFound == true) {
|
if (songIsFound == true) {
|
||||||
stopMusic();
|
stopMusic();
|
||||||
@@ -159,12 +162,16 @@ Result Init::Exit() {
|
|||||||
if (dspFound == true) {
|
if (dspFound == true) {
|
||||||
ndspExit();
|
ndspExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Free UniStore spritesheet, just in case.
|
||||||
|
freeSheet();
|
||||||
Config::save();
|
Config::save();
|
||||||
Gui::exit();
|
Gui::exit();
|
||||||
Gui::unloadSheet(sprites);
|
Gui::unloadSheet(sprites);
|
||||||
gfxExit();
|
gfxExit();
|
||||||
cfguExit();
|
cfguExit();
|
||||||
acExit();
|
acExit();
|
||||||
|
amExit();
|
||||||
romfsExit();
|
romfsExit();
|
||||||
sdmcExit();
|
sdmcExit();
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -211,6 +211,28 @@ void runFunctions(nlohmann::json &json) {
|
|||||||
if(!missing) ScriptHelper::displayTimeMsg(message, seconds);
|
if(!missing) ScriptHelper::displayTimeMsg(message, seconds);
|
||||||
} else if (type == "saveConfig") {
|
} else if (type == "saveConfig") {
|
||||||
Config::save();
|
Config::save();
|
||||||
|
} else if (type == "deleteTitle") {
|
||||||
|
std::string TitleID = "";
|
||||||
|
std::string message = "";
|
||||||
|
bool isNAND = false, missing = false;
|
||||||
|
if(json.at(choice).at(i).contains("TitleID")) TitleID = json.at(choice).at(i).at("TitleID");
|
||||||
|
else missing = true;
|
||||||
|
if (json.at(choice).at(i).contains("NAND") && json.at(choice).at(i).at("NAND").is_boolean()) isNAND = json.at(choice).at(i).at("NAND");
|
||||||
|
else missing = true;
|
||||||
|
if(json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
|
||||||
|
else missing = true;
|
||||||
|
if(!missing) ScriptHelper::deleteTitle(TitleID, isNAND, message);
|
||||||
|
} else if (type == "bootTitle") {
|
||||||
|
std::string TitleID = "";
|
||||||
|
std::string message = "";
|
||||||
|
bool isNAND = false, missing = false;
|
||||||
|
if(json.at(choice).at(i).contains("TitleID")) TitleID = json.at(choice).at(i).at("TitleID");
|
||||||
|
else missing = true;
|
||||||
|
if (json.at(choice).at(i).contains("NAND") && json.at(choice).at(i).at("NAND").is_boolean()) isNAND = json.at(choice).at(i).at("NAND");
|
||||||
|
else missing = true;
|
||||||
|
if(json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
|
||||||
|
else missing = true;
|
||||||
|
if(!missing) ScriptHelper::bootTitle(TitleID, isNAND, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
doneMsg();
|
doneMsg();
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ extern u32 TextColor;
|
|||||||
extern u32 progressBar;
|
extern u32 progressBar;
|
||||||
extern u32 selected;
|
extern u32 selected;
|
||||||
extern u32 unselected;
|
extern u32 unselected;
|
||||||
|
|
||||||
C2D_SpriteSheet appStoreSheet;
|
C2D_SpriteSheet appStoreSheet;
|
||||||
|
|
||||||
struct storeInfo2 {
|
struct storeInfo2 {
|
||||||
@@ -120,13 +119,17 @@ std::string storeDesc = "";
|
|||||||
bool sheetHasLoaded = false;
|
bool sheetHasLoaded = false;
|
||||||
// Sheet / Icon stuff.
|
// Sheet / Icon stuff.
|
||||||
void loadStoreSheet(int pos) {
|
void loadStoreSheet(int pos) {
|
||||||
|
if (sheetHasLoaded == false) {
|
||||||
appStoreSheet = C2D_SpriteSheetLoad(storeInfo[pos].storeSheet.c_str());
|
appStoreSheet = C2D_SpriteSheetLoad(storeInfo[pos].storeSheet.c_str());
|
||||||
sheetHasLoaded = true;
|
sheetHasLoaded = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
void freeSheet() {
|
void freeSheet() {
|
||||||
|
if (sheetHasLoaded == true) {
|
||||||
C2D_SpriteSheetFree(appStoreSheet);
|
C2D_SpriteSheetFree(appStoreSheet);
|
||||||
sheetHasLoaded = false;
|
sheetHasLoaded = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void drawBlend(int key, int x, int y) {
|
void drawBlend(int key, int x, int y) {
|
||||||
C2D_ImageTint tint;
|
C2D_ImageTint tint;
|
||||||
@@ -857,6 +860,28 @@ void UniStore::execute() {
|
|||||||
Config::save();
|
Config::save();
|
||||||
} else if (type == "notImplemented") {
|
} else if (type == "notImplemented") {
|
||||||
notImplemented();
|
notImplemented();
|
||||||
|
} else if (type == "deleteTitle") {
|
||||||
|
std::string TitleID = "";
|
||||||
|
std::string message = "";
|
||||||
|
bool isNAND = false, missing = false;
|
||||||
|
if(appStoreJson.at("storeContent").at(selectedOptionAppStore).at("script").at(i).contains("TitleID")) TitleID = appStoreJson.at("storeContent").at(selectedOptionAppStore).at("script").at(i).at("TitleID");
|
||||||
|
else missing = true;
|
||||||
|
if (appStoreJson.at("storeContent").at(selectedOptionAppStore).at("script").at(i).contains("NAND") && appStoreJson.at("storeContent").at(selectedOptionAppStore).at("script").at(i).at("NAND").is_boolean()) isNAND = appStoreJson.at("storeContent").at(selectedOptionAppStore).at("script").at(i).at("NAND");
|
||||||
|
else missing = true;
|
||||||
|
if(appStoreJson.at("storeContent").at(selectedOptionAppStore).at("script").at(i).contains("message")) message = appStoreJson.at("storeContent").at(selectedOptionAppStore).at("script").at(i).at("message");
|
||||||
|
else missing = true;
|
||||||
|
if(!missing) ScriptHelper::deleteTitle(TitleID, isNAND, message);
|
||||||
|
} else if (type == "bootTitle") {
|
||||||
|
std::string TitleID = "";
|
||||||
|
std::string message = "";
|
||||||
|
bool isNAND = false, missing = false;
|
||||||
|
if(appStoreJson.at("storeContent").at(selectedOptionAppStore).at("script").at(i).contains("TitleID")) TitleID = appStoreJson.at("storeContent").at(selectedOptionAppStore).at("script").at(i).at("TitleID");
|
||||||
|
else missing = true;
|
||||||
|
if (appStoreJson.at("storeContent").at(selectedOptionAppStore).at("script").at(i).contains("NAND") && appStoreJson.at("storeContent").at(selectedOptionAppStore).at("script").at(i).at("NAND").is_boolean()) isNAND = appStoreJson.at("storeContent").at(selectedOptionAppStore).at("script").at(i).at("NAND");
|
||||||
|
else missing = true;
|
||||||
|
if(appStoreJson.at("storeContent").at(selectedOptionAppStore).at("script").at(i).contains("message")) message = appStoreJson.at("storeContent").at(selectedOptionAppStore).at("script").at(i).at("message");
|
||||||
|
else missing = true;
|
||||||
|
if(!missing) ScriptHelper::bootTitle(TitleID, isNAND, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
doneMsg();
|
doneMsg();
|
||||||
|
|||||||
+1
-8
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
bool updatingSelf = false;
|
bool updatingSelf = false;
|
||||||
|
|
||||||
static Result CIA_LaunchTitle(u64 titleId, FS_MediaType mediaType) {
|
Result CIA_LaunchTitle(u64 titleId, FS_MediaType mediaType) {
|
||||||
Result ret = 0;
|
Result ret = 0;
|
||||||
u8 param[0x300];
|
u8 param[0x300];
|
||||||
u8 hmac[0x20];
|
u8 hmac[0x20];
|
||||||
@@ -74,12 +74,6 @@ Result installCia(const char * ciaPath)
|
|||||||
AM_TitleEntry info;
|
AM_TitleEntry info;
|
||||||
Result ret = 0;
|
Result ret = 0;
|
||||||
|
|
||||||
ret = amInit();
|
|
||||||
if (R_FAILED(ret)) {
|
|
||||||
printf("Error in:\namInit();\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
FS_MediaType media = MEDIATYPE_SD;
|
FS_MediaType media = MEDIATYPE_SD;
|
||||||
|
|
||||||
ret = openFile(&fileHandle, ciaPath, false);
|
ret = openFile(&fileHandle, ciaPath, false);
|
||||||
@@ -140,6 +134,5 @@ Result installCia(const char * ciaPath)
|
|||||||
if (R_FAILED(ret = CIA_LaunchTitle(info.titleID, MEDIATYPE_SD)))
|
if (R_FAILED(ret = CIA_LaunchTitle(info.titleID, MEDIATYPE_SD)))
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
amExit();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -149,3 +149,35 @@ bool ScriptHelper::checkIfValid(std::string scriptFile, int mode) {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptHelper::deleteTitle(const std::string TitleID, bool isNAND, std::string message) {
|
||||||
|
std::string MSG = Lang::get("DELETE_TITLE") + "\n\n";
|
||||||
|
if (isNAND) MSG += Lang::get("MEDIATYPE_NAND") + "\n" + TitleID;
|
||||||
|
else MSG += Lang::get("MEDIATYPE_SD") + "\n" + TitleID;
|
||||||
|
u64 ID = std::stoull(TitleID, 0, 16);
|
||||||
|
if (Msg::promptMsg(MSG)) {
|
||||||
|
if (isNAND == true) {
|
||||||
|
Msg::DisplayMsg(message);
|
||||||
|
deletePrevious(ID, MEDIATYPE_NAND);
|
||||||
|
} else {
|
||||||
|
Msg::DisplayMsg(message);
|
||||||
|
deletePrevious(ID, MEDIATYPE_SD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptHelper::bootTitle(const std::string TitleID, bool isNAND, std::string message) {
|
||||||
|
std::string MSG = Lang::get("BOOT_TITLE") + "\n\n";
|
||||||
|
if (isNAND) MSG += Lang::get("MEDIATYPE_NAND") + "\n" + TitleID;
|
||||||
|
else MSG += Lang::get("MEDIATYPE_SD") + "\n" + TitleID;
|
||||||
|
u64 ID = std::stoull(TitleID, 0, 16);
|
||||||
|
if (Msg::promptMsg(MSG)) {
|
||||||
|
if (isNAND == true) {
|
||||||
|
Msg::DisplayMsg(message);
|
||||||
|
CIA_LaunchTitle(ID, MEDIATYPE_NAND);
|
||||||
|
} else {
|
||||||
|
Msg::DisplayMsg(message);
|
||||||
|
CIA_LaunchTitle(ID, MEDIATYPE_SD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user