mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-04 08:39:06 +00:00
Add Autoboot into a script.
This commit is contained in:
@@ -34,6 +34,7 @@ namespace Msg
|
|||||||
void DisplayMsg(std::string text);
|
void DisplayMsg(std::string text);
|
||||||
void DisplayWarnMsg(std::string Text);
|
void DisplayWarnMsg(std::string Text);
|
||||||
bool promptMsg(std::string promptMsg);
|
bool promptMsg(std::string promptMsg);
|
||||||
|
void DisplayStartMSG();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -38,9 +38,11 @@ class ScriptList : public Screen
|
|||||||
public:
|
public:
|
||||||
void Draw(void) const override;
|
void Draw(void) const override;
|
||||||
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
|
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
|
||||||
|
ScriptList();
|
||||||
private:
|
private:
|
||||||
void deleteScript(int selectedScript);
|
void deleteScript(int selectedScript);
|
||||||
|
void refreshList();
|
||||||
|
|
||||||
void DrawSubMenu(void) const;
|
void DrawSubMenu(void) const;
|
||||||
void DrawList(void) const;
|
void DrawList(void) const;
|
||||||
void DrawSingleObject(void) const;
|
void DrawSingleObject(void) const;
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ public:
|
|||||||
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
|
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
|
||||||
UniStore();
|
UniStore();
|
||||||
private:
|
private:
|
||||||
|
void refreshList();
|
||||||
|
|
||||||
void DrawSubMenu(void) const;
|
void DrawSubMenu(void) const;
|
||||||
void DrawStoreList(void) const;
|
void DrawStoreList(void) const;
|
||||||
void DrawStore(void) const;
|
void DrawStore(void) const;
|
||||||
|
|||||||
@@ -30,9 +30,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace Config {
|
namespace Config {
|
||||||
extern int LangPath, lang, Color1, Color2, Color3, TxtColor, SelectedColor, UnselectedColor, viewMode, progressbarColor;
|
extern int LangPath, lang, Color1, Color2, Color3, TxtColor, SelectedColor, UnselectedColor, viewMode, progressbarColor, autoboot;
|
||||||
extern std::string ScriptPath, MusicPath, StorePath, UniStoreFile;
|
extern std::string ScriptPath, MusicPath, StorePath, AutobootFile;
|
||||||
extern bool Logging, UseBars, GodMode, autobootUnistore;
|
extern bool Logging, UseBars, GodMode;
|
||||||
|
|
||||||
void load();
|
void load();
|
||||||
void save();
|
void save();
|
||||||
|
|||||||
@@ -123,10 +123,13 @@
|
|||||||
"ENABLE_GODMODE": "Enable GodMode",
|
"ENABLE_GODMODE": "Enable GodMode",
|
||||||
"ENABLE_GODMODE_PROMPT": "Would you like to enable GodMode?\n\nBe careful when you use GodMode!!",
|
"ENABLE_GODMODE_PROMPT": "Would you like to enable GodMode?\n\nBe careful when you use GodMode!!",
|
||||||
|
|
||||||
"DISABLE_AUTOBOOT_STORE": "Would you like to disable autoboot?",
|
"DISABLE_AUTOBOOT": "Would you like to disable autoboot?",
|
||||||
"AUTOBOOT_STORE": "Would you like to autoboot this Store?\n\nThis will autoboot this store on startup!",
|
"AUTOBOOT_STORE": "Would you like to autoboot this Store?\n\nThis will autoboot this store on startup!",
|
||||||
|
|
||||||
"SCRIPT_NOT_FOUND": "This script does not exist.",
|
"SCRIPT_NOT_FOUND": "This script does not exist.",
|
||||||
"DELETE_SCRIPT": "Would you like to delete this script?",
|
"DELETE_SCRIPT": "Would you like to delete this script?",
|
||||||
"REFRESHING_LIST": "Refreshing List..."
|
"REFRESHING_LIST": "Refreshing List...",
|
||||||
|
|
||||||
|
"AUTOBOOT_SCRIPT": "Would you like to autoboot this Script?\n\nThis will autoboot this Script on startup!",
|
||||||
|
"STARTING_UNIVERSAL_UPDATER": "Starting Universal-Updater..."
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-8
@@ -32,6 +32,7 @@
|
|||||||
#include "logging.hpp"
|
#include "logging.hpp"
|
||||||
#include "mainMenu.hpp"
|
#include "mainMenu.hpp"
|
||||||
#include "screenCommon.hpp"
|
#include "screenCommon.hpp"
|
||||||
|
#include "scriptList.hpp"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
#include "unistore.hpp"
|
#include "unistore.hpp"
|
||||||
|
|
||||||
@@ -49,6 +50,7 @@ touchPosition touch;
|
|||||||
sound *bgm = NULL;
|
sound *bgm = NULL;
|
||||||
bool songIsFound = false;
|
bool songIsFound = false;
|
||||||
bool UniStoreAutoboot = false;
|
bool UniStoreAutoboot = false;
|
||||||
|
int AutobootWhat = 0; // 0 -> MainMenu ; 1 -> Store; 2 -> Script.
|
||||||
|
|
||||||
// Include all spritesheet's.
|
// Include all spritesheet's.
|
||||||
C2D_SpriteSheet sprites;
|
C2D_SpriteSheet sprites;
|
||||||
@@ -87,9 +89,8 @@ Result Init::Initialize() {
|
|||||||
gfxInitDefault();
|
gfxInitDefault();
|
||||||
romfsInit();
|
romfsInit();
|
||||||
amInit();
|
amInit();
|
||||||
Gui::init();
|
|
||||||
Gui::loadSheet("romfs:/gfx/sprites.t3x", sprites);
|
|
||||||
sdmcInit();
|
sdmcInit();
|
||||||
|
Gui::init();
|
||||||
cfguInit();
|
cfguInit();
|
||||||
acInit();
|
acInit();
|
||||||
// Create Folder if missing.
|
// Create Folder if missing.
|
||||||
@@ -104,20 +105,34 @@ Result Init::Initialize() {
|
|||||||
}
|
}
|
||||||
Config::load();
|
Config::load();
|
||||||
Lang::load(Config::lang);
|
Lang::load(Config::lang);
|
||||||
|
// In case it takes a bit longer to autoboot a script or so.
|
||||||
|
Msg::DisplayStartMSG();
|
||||||
if (Config::Logging == true) {
|
if (Config::Logging == true) {
|
||||||
Logging::createLogFile();
|
Logging::createLogFile();
|
||||||
}
|
}
|
||||||
|
Gui::loadSheet("romfs:/gfx/sprites.t3x", sprites);
|
||||||
|
|
||||||
if (Config::autobootUnistore) {
|
AutobootWhat = Config::autoboot;
|
||||||
UniStoreAutoboot = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (UniStoreAutoboot) {
|
if (Config::autoboot == 1) {
|
||||||
if (access(Config::UniStoreFile.c_str(), F_OK) == 0) {
|
if (access(Config::AutobootFile.c_str(), F_OK) == 0) {
|
||||||
Gui::setScreen(std::make_unique<UniStore>());
|
Gui::setScreen(std::make_unique<UniStore>());
|
||||||
|
} else {
|
||||||
|
AutobootWhat = 0;
|
||||||
|
Config::autoboot = 0;
|
||||||
|
Gui::setScreen(std::make_unique<MainMenu>());
|
||||||
|
}
|
||||||
|
} else if (Config::autoboot == 2) {
|
||||||
|
if (access(Config::AutobootFile.c_str(), F_OK) == 0) {
|
||||||
|
Gui::setScreen(std::make_unique<ScriptList>());
|
||||||
|
} else {
|
||||||
|
AutobootWhat = 0;
|
||||||
|
Config::autoboot = 0;
|
||||||
|
Gui::setScreen(std::make_unique<MainMenu>());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
AutobootWhat = 0;
|
||||||
|
Config::autoboot = 0;
|
||||||
Gui::setScreen(std::make_unique<MainMenu>());
|
Gui::setScreen(std::make_unique<MainMenu>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,22 @@ extern u32 bgTopColor;
|
|||||||
extern u32 bgBottomColor;
|
extern u32 bgBottomColor;
|
||||||
extern u32 TextColor;
|
extern u32 TextColor;
|
||||||
|
|
||||||
|
void Msg::DisplayStartMSG() {
|
||||||
|
Gui::clearTextBufs();
|
||||||
|
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||||
|
C2D_TargetClear(Top, BLACK);
|
||||||
|
C2D_TargetClear(Bottom, BLACK);
|
||||||
|
Gui::ScreenDraw(Top);
|
||||||
|
Gui::Draw_Rect(0, 0, 400, 25, Config::Color1);
|
||||||
|
Gui::Draw_Rect(0, 25, 400, 190, Config::Color2);
|
||||||
|
Gui::Draw_Rect(0, 215, 400, 25, Config::Color1);
|
||||||
|
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("STARTING_UNIVERSAL_UPDATER"));
|
||||||
|
Gui::ScreenDraw(Bottom);
|
||||||
|
Gui::Draw_Rect(0, 0, 320, 25, Config::Color1);
|
||||||
|
Gui::Draw_Rect(0, 25, 320, 190, Config::Color2);
|
||||||
|
Gui::Draw_Rect(0, 215, 320, 25, Config::Color1);
|
||||||
|
C3D_FrameEnd(0);
|
||||||
|
}
|
||||||
void Msg::DisplayMsg(std::string text) {
|
void Msg::DisplayMsg(std::string text) {
|
||||||
Gui::clearTextBufs();
|
Gui::clearTextBufs();
|
||||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "download.hpp"
|
#include "download.hpp"
|
||||||
|
#include "mainMenu.hpp"
|
||||||
#include "scriptBrowse.hpp"
|
#include "scriptBrowse.hpp"
|
||||||
#include "scriptCreator.hpp"
|
#include "scriptCreator.hpp"
|
||||||
#include "scriptHelper.hpp"
|
#include "scriptHelper.hpp"
|
||||||
@@ -312,6 +313,49 @@ void ScriptList::DrawSubMenu(void) const {
|
|||||||
Gui::DrawStringCentered(80, subPos[3].y+12, 0.6f, Config::TxtColor, Lang::get("CHANGE_SCRIPTPATH"), 130);
|
Gui::DrawStringCentered(80, subPos[3].y+12, 0.6f, Config::TxtColor, Lang::get("CHANGE_SCRIPTPATH"), 130);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void loadDesc(void) {
|
||||||
|
lines.clear();
|
||||||
|
while(Desc.find('\n') != Desc.npos) {
|
||||||
|
lines.push_back(Desc.substr(0, Desc.find('\n')));
|
||||||
|
Desc = Desc.substr(Desc.find('\n')+1);
|
||||||
|
}
|
||||||
|
lines.push_back(Desc.substr(0, Desc.find('\n')));
|
||||||
|
}
|
||||||
|
|
||||||
|
extern int AutobootWhat;
|
||||||
|
bool changeBackHandle = false;
|
||||||
|
|
||||||
|
ScriptList::ScriptList() {
|
||||||
|
if (AutobootWhat == 2) {
|
||||||
|
// If Script isn't found, go to MainMenu.
|
||||||
|
if (access(Config::AutobootFile.c_str(), F_OK) != 0) {
|
||||||
|
AutobootWhat = 0;
|
||||||
|
changeBackHandle = true;
|
||||||
|
Gui::setScreen(std::make_unique<MainMenu>());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ScriptHelper::checkIfValid(Config::AutobootFile) == true) {
|
||||||
|
Info fI = parseInfo(Config::AutobootFile);
|
||||||
|
currentFile = Config::AutobootFile;
|
||||||
|
selectedTitle = fI.title;
|
||||||
|
jsonFile = openScriptFile();
|
||||||
|
Desc = Description(jsonFile);
|
||||||
|
checkForValidate();
|
||||||
|
fileInfo2 = parseObjects(currentFile);
|
||||||
|
loadColors(jsonFile);
|
||||||
|
loadDesc();
|
||||||
|
isScriptSelected = true;
|
||||||
|
selection = 0;
|
||||||
|
mode = 2;
|
||||||
|
changeBackHandle = true;
|
||||||
|
AutobootWhat = 0;
|
||||||
|
} else {
|
||||||
|
AutobootWhat = 0;
|
||||||
|
changeBackHandle = true;
|
||||||
|
Gui::setScreen(std::make_unique<MainMenu>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptList::DrawList(void) const {
|
void ScriptList::DrawList(void) const {
|
||||||
std::string line1;
|
std::string line1;
|
||||||
@@ -368,15 +412,6 @@ void ScriptList::Draw(void) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadDesc(void) {
|
|
||||||
lines.clear();
|
|
||||||
while(Desc.find('\n') != Desc.npos) {
|
|
||||||
lines.push_back(Desc.substr(0, Desc.find('\n')));
|
|
||||||
Desc = Desc.substr(Desc.find('\n')+1);
|
|
||||||
}
|
|
||||||
lines.push_back(Desc.substr(0, Desc.find('\n')));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptList::DrawSingleObject(void) const {
|
void ScriptList::DrawSingleObject(void) const {
|
||||||
std::string info;
|
std::string info;
|
||||||
std::string entryAmount = std::to_string(selection2+1) + " / " + std::to_string(fileInfo2.size());
|
std::string entryAmount = std::to_string(selection2+1) + " / " + std::to_string(fileInfo2.size());
|
||||||
@@ -419,11 +454,33 @@ void ScriptList::DrawSingleObject(void) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptList::refreshList() {
|
||||||
|
if (returnIfExist(Config::ScriptPath, {"json"}) == true) {
|
||||||
|
Msg::DisplayMsg(Lang::get("REFRESHING_LIST"));
|
||||||
|
dirContents.clear();
|
||||||
|
fileInfo.clear();
|
||||||
|
chdir(Config::ScriptPath.c_str());
|
||||||
|
getDirectoryContents(dirContents, {"json"});
|
||||||
|
for(uint i=0;i<dirContents.size();i++) {
|
||||||
|
fileInfo.push_back(parseInfo(dirContents[i].name));
|
||||||
|
}
|
||||||
|
selection = 0;
|
||||||
|
mode = 1;
|
||||||
|
} else {
|
||||||
|
Msg::DisplayWarnMsg(Lang::get("GET_SCRIPTS_FIRST"));
|
||||||
|
selection = 0;
|
||||||
|
mode = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptList::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
void ScriptList::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||||
if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) {
|
if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) {
|
||||||
Gui::screenBack();
|
if (changeBackHandle) {
|
||||||
return;
|
Gui::setScreen(std::make_unique<MainMenu>());
|
||||||
|
} else {
|
||||||
|
Gui::screenBack();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Navigation.
|
// Navigation.
|
||||||
@@ -539,6 +596,25 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||||||
mode = 0;
|
mode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hDown & KEY_START) {
|
||||||
|
if (Config::autoboot == 2) {
|
||||||
|
if (Msg::promptMsg(Lang::get("DISABLE_AUTOBOOT"))) {
|
||||||
|
Config::autoboot = 0;
|
||||||
|
Config::AutobootFile = "";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (dirContents[selection].isDirectory) {
|
||||||
|
} else if (fileInfo.size() != 0) {
|
||||||
|
if (ScriptHelper::checkIfValid(dirContents[selection].name) == true) {
|
||||||
|
if (Msg::promptMsg(Lang::get("AUTOBOOT_SCRIPT"))) {
|
||||||
|
Config::AutobootFile = Config::ScriptPath + dirContents[selection].name;
|
||||||
|
Config::autoboot = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((hHeld & KEY_DOWN && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[1]))) {
|
if ((hHeld & KEY_DOWN && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[1]))) {
|
||||||
if (selection < (int)fileInfo.size()-1) {
|
if (selection < (int)fileInfo.size()-1) {
|
||||||
selection++;
|
selection++;
|
||||||
@@ -665,7 +741,7 @@ void ScriptList::SelectFunction(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||||||
selection2 = 0;
|
selection2 = 0;
|
||||||
fileInfo2.clear();
|
fileInfo2.clear();
|
||||||
isScriptSelected = false;
|
isScriptSelected = false;
|
||||||
mode = 1;
|
refreshList();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((hHeld & KEY_DOWN && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[1]))) {
|
if ((hHeld & KEY_DOWN && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[1]))) {
|
||||||
|
|||||||
+56
-38
@@ -50,7 +50,7 @@ extern u32 TextColor;
|
|||||||
extern u32 progressBar;
|
extern u32 progressBar;
|
||||||
extern u32 selected;
|
extern u32 selected;
|
||||||
extern u32 unselected;
|
extern u32 unselected;
|
||||||
extern bool UniStoreAutoboot;
|
extern int AutobootWhat;
|
||||||
bool changeBackState = false;
|
bool changeBackState = false;
|
||||||
|
|
||||||
C2D_SpriteSheet appStoreSheet;
|
C2D_SpriteSheet appStoreSheet;
|
||||||
@@ -198,29 +198,35 @@ void loadStoreColors(nlohmann::json &json) {
|
|||||||
|
|
||||||
UniStore::UniStore() {
|
UniStore::UniStore() {
|
||||||
// Autobooting UniStore. ;)
|
// Autobooting UniStore. ;)
|
||||||
if (UniStoreAutoboot) {
|
if (AutobootWhat == 1) {
|
||||||
// If store isn't found, go to MainMenu.
|
// If store isn't found, go to MainMenu.
|
||||||
if (access(Config::UniStoreFile.c_str(), F_OK) != 0) {
|
if (access(Config::AutobootFile.c_str(), F_OK) != 0) {
|
||||||
Gui::setScreen(std::make_unique<MainMenu>());
|
AutobootWhat = 0;
|
||||||
changeBackState = true;
|
changeBackState = true;
|
||||||
|
Gui::setScreen(std::make_unique<MainMenu>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse store.
|
|
||||||
SI = parseStoreInfo(Config::UniStoreFile);
|
|
||||||
// If WiFi enabled & File exist, update store.
|
// If WiFi enabled & File exist, update store.
|
||||||
if (checkWifiStatus()) {
|
if (ScriptHelper::checkIfValid(Config::AutobootFile, 1) == true) {
|
||||||
if (Msg::promptMsg(Lang::get("WOULD_YOU_LIKE_UPDATE"))) {
|
SI = parseStoreInfo(Config::AutobootFile);
|
||||||
if(SI.url != "" && SI.url != "MISSING: storeInfo.url" && SI.file != "" && SI.file != "MISSING: storeInfo.file") {
|
if (checkWifiStatus()) {
|
||||||
ScriptHelper::downloadFile(SI.url, SI.file, Lang::get("UPDATING"));
|
if (Msg::promptMsg(Lang::get("WOULD_YOU_LIKE_UPDATE"))) {
|
||||||
}
|
if(SI.url != "" && SI.url != "MISSING: storeInfo.url" && SI.file != "" && SI.file != "MISSING: storeInfo.file") {
|
||||||
if(SI.sheetURL != "" && SI.sheetURL != "MISSING: storeInfo.sheetURL" && SI.storeSheet != "" && SI.storeSheet != "MISSING: storeInfo.sheet") {
|
ScriptHelper::downloadFile(SI.url, SI.file, Lang::get("UPDATING"));
|
||||||
ScriptHelper::downloadFile(SI.sheetURL, SI.storeSheet, Lang::get("UPDATING"));
|
}
|
||||||
|
if(SI.sheetURL != "" && SI.sheetURL != "MISSING: storeInfo.sheetURL" && SI.storeSheet != "" && SI.storeSheet != "MISSING: storeInfo.sheet") {
|
||||||
|
ScriptHelper::downloadFile(SI.sheetURL, SI.storeSheet, Lang::get("UPDATING"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
AutobootWhat = 0;
|
||||||
|
changeBackState = true;
|
||||||
|
Gui::setScreen(std::make_unique<MainMenu>());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ScriptHelper::checkIfValid(Config::UniStoreFile, 1) == true) {
|
if (ScriptHelper::checkIfValid(Config::AutobootFile, 1) == true) {
|
||||||
currentStoreFile = Config::UniStoreFile;
|
currentStoreFile = Config::AutobootFile;
|
||||||
Msg::DisplayMsg(Lang::get("PREPARE_STORE"));
|
Msg::DisplayMsg(Lang::get("PREPARE_STORE"));
|
||||||
if (SI.storeSheet != "" || SI.storeSheet != "MISSING: storeInfo.sheet") {
|
if (SI.storeSheet != "" || SI.storeSheet != "MISSING: storeInfo.sheet") {
|
||||||
if(access(SI.storeSheet.c_str(), F_OK) != -1 ) {
|
if(access(SI.storeSheet.c_str(), F_OK) != -1 ) {
|
||||||
@@ -234,7 +240,12 @@ UniStore::UniStore() {
|
|||||||
displayInformations = handleIfDisplayText();
|
displayInformations = handleIfDisplayText();
|
||||||
isScriptSelected = true;
|
isScriptSelected = true;
|
||||||
mode = 2;
|
mode = 2;
|
||||||
|
AutobootWhat = 0;
|
||||||
changeBackState = true;
|
changeBackState = true;
|
||||||
|
} else {
|
||||||
|
AutobootWhat = 0;
|
||||||
|
changeBackState = true;
|
||||||
|
Gui::setScreen(std::make_unique<MainMenu>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -452,6 +463,24 @@ void UniStore::updateStore(int selectedStore) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UniStore::refreshList() {
|
||||||
|
if (returnIfExist(Config::StorePath, {"unistore"}) == true) {
|
||||||
|
Msg::DisplayMsg(Lang::get("REFRESHING_LIST"));
|
||||||
|
dirContents.clear();
|
||||||
|
storeInfo.clear();
|
||||||
|
chdir(Config::StorePath.c_str());
|
||||||
|
getDirectoryContents(dirContents, {"unistore"});
|
||||||
|
for(uint i=0;i<dirContents.size();i++) {
|
||||||
|
storeInfo.push_back(parseStoreInfo(dirContents[i].name));
|
||||||
|
descript();
|
||||||
|
loadStoreDesc();
|
||||||
|
}
|
||||||
|
mode = 1;
|
||||||
|
} else {
|
||||||
|
Msg::DisplayWarnMsg(Lang::get("GET_STORES_FIRST"));
|
||||||
|
mode = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
void UniStore::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
void UniStore::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||||
if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) {
|
if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) {
|
||||||
if (changeBackState) {
|
if (changeBackState) {
|
||||||
@@ -717,18 +746,18 @@ void UniStore::StoreSelectionLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hDown & KEY_START) {
|
if (hDown & KEY_START) {
|
||||||
if (Config::autobootUnistore) {
|
if (Config::autoboot == 1) {
|
||||||
if (Msg::promptMsg(Lang::get("DISABLE_AUTOBOOT_STORE"))) {
|
if (Msg::promptMsg(Lang::get("DISABLE_AUTOBOOT"))) {
|
||||||
Config::autobootUnistore = false;
|
Config::autoboot = 0;
|
||||||
Config::UniStoreFile = "";
|
Config::AutobootFile = "";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (dirContents[selection].isDirectory) {
|
if (dirContents[selection].isDirectory) {
|
||||||
} else if (storeInfo.size() != 0) {
|
} else if (storeInfo.size() != 0) {
|
||||||
if (ScriptHelper::checkIfValid(dirContents[selection].name, 1) == true) {
|
if (ScriptHelper::checkIfValid(dirContents[selection].name, 1) == true) {
|
||||||
if (Msg::promptMsg(Lang::get("AUTOBOOT_STORE"))) {
|
if (Msg::promptMsg(Lang::get("AUTOBOOT_STORE"))) {
|
||||||
Config::UniStoreFile = Config::StorePath + dirContents[selection].name;
|
Config::AutobootFile = Config::StorePath + dirContents[selection].name;
|
||||||
Config::autobootUnistore = true;
|
Config::autoboot = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -740,23 +769,12 @@ void UniStore::StoreLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||||||
if (keyRepeatDelay) keyRepeatDelay--;
|
if (keyRepeatDelay) keyRepeatDelay--;
|
||||||
|
|
||||||
if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) {
|
if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) {
|
||||||
if (UniStoreAutoboot) {
|
refreshList();
|
||||||
UniStoreAutoboot = false;
|
appStoreList.clear();
|
||||||
mode = 0;
|
isScriptSelected = false;
|
||||||
appStoreList.clear();
|
selection2 = 0;
|
||||||
isScriptSelected = false;
|
if (sheetHasLoaded == true) {
|
||||||
selection2 = 0;
|
freeSheet();
|
||||||
if (sheetHasLoaded == true) {
|
|
||||||
freeSheet();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mode = 1;
|
|
||||||
appStoreList.clear();
|
|
||||||
isScriptSelected = false;
|
|
||||||
selection2 = 0;
|
|
||||||
if (sheetHasLoaded == true) {
|
|
||||||
freeSheet();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+14
-14
@@ -48,8 +48,8 @@ bool Config::UseBars;
|
|||||||
std::string Config::StorePath;
|
std::string Config::StorePath;
|
||||||
int Config::LangPath;
|
int Config::LangPath;
|
||||||
bool Config::GodMode = false;
|
bool Config::GodMode = false;
|
||||||
bool Config::autobootUnistore = false;
|
int Config::autoboot = 0;
|
||||||
std::string Config::UniStoreFile = "";
|
std::string Config::AutobootFile = "";
|
||||||
nlohmann::json configJson;
|
nlohmann::json configJson;
|
||||||
|
|
||||||
void Config::load() {
|
void Config::load() {
|
||||||
@@ -147,16 +147,16 @@ void Config::load() {
|
|||||||
Config::StorePath = getString("STOREPATH");
|
Config::StorePath = getString("STOREPATH");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!configJson.contains("UNISTORE_AUTOBOOT")) {
|
if(!configJson.contains("AUTOBOOT")) {
|
||||||
Config::autobootUnistore = false;
|
Config::autoboot = 0;
|
||||||
} else {
|
} else {
|
||||||
Config::autobootUnistore = getBool("UNISTORE_AUTOBOOT");
|
Config::autoboot = getInt("AUTOBOOT");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!configJson.contains("UNISTORE_FILE")) {
|
if(!configJson.contains("AUTOBOOT_FILE")) {
|
||||||
Config::UniStoreFile = "";
|
Config::AutobootFile = "";
|
||||||
} else {
|
} else {
|
||||||
Config::UniStoreFile = getString("UNISTORE_FILE");
|
Config::AutobootFile = getString("AUTOBOOT_FILE");
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
@@ -176,8 +176,8 @@ void Config::load() {
|
|||||||
Config::Logging = false;
|
Config::Logging = false;
|
||||||
Config::UseBars = true;
|
Config::UseBars = true;
|
||||||
Config::StorePath = STORE_PATH;
|
Config::StorePath = STORE_PATH;
|
||||||
Config::autobootUnistore = false;
|
Config::autoboot = 0;
|
||||||
Config::UniStoreFile = "";
|
Config::AutobootFile = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,8 +198,8 @@ void Config::save() {
|
|||||||
Config::setBool("BARS", Config::UseBars);
|
Config::setBool("BARS", Config::UseBars);
|
||||||
Config::setString("STOREPATH", Config::StorePath);
|
Config::setString("STOREPATH", Config::StorePath);
|
||||||
|
|
||||||
Config::setBool("UNISTORE_AUTOBOOT", Config::autobootUnistore);
|
Config::setInt("AUTOBOOT", Config::autoboot);
|
||||||
Config::setString("UNISTORE_FILE", Config::UniStoreFile);
|
Config::setString("AUTOBOOT_FILE", Config::AutobootFile);
|
||||||
|
|
||||||
FILE* file = fopen("sdmc:/3ds/Universal-Updater/Settings.json", "w");
|
FILE* file = fopen("sdmc:/3ds/Universal-Updater/Settings.json", "w");
|
||||||
if(file) fwrite(configJson.dump(1, '\t').c_str(), 1, configJson.dump(1, '\t').size(), file);
|
if(file) fwrite(configJson.dump(1, '\t').c_str(), 1, configJson.dump(1, '\t').size(), file);
|
||||||
@@ -225,8 +225,8 @@ void Config::initializeNewConfig() {
|
|||||||
Config::setBool("BARS", true);
|
Config::setBool("BARS", true);
|
||||||
Config::setString("STOREPATH", STORE_PATH);
|
Config::setString("STOREPATH", STORE_PATH);
|
||||||
|
|
||||||
Config::setBool("UNISTORE_AUTOBOOT", false);
|
Config::setInt("AUTOBOOT", 0);
|
||||||
Config::setString("UNISTORE_FILE", "");
|
Config::setString("AUTOBOOT_FILE", "");
|
||||||
|
|
||||||
if(file) fwrite(configJson.dump(1, '\t').c_str(), 1, configJson.dump(1, '\t').size(), file);
|
if(file) fwrite(configJson.dump(1, '\t').c_str(), 1, configJson.dump(1, '\t').size(), file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|||||||
Reference in New Issue
Block a user