mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-07 16:59:08 +00:00
Add Autoboot UniStore.
This commit is contained in:
@@ -38,6 +38,7 @@ class UniStore : 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;
|
||||||
|
UniStore();
|
||||||
private:
|
private:
|
||||||
void DrawSubMenu(void) const;
|
void DrawSubMenu(void) const;
|
||||||
void DrawStoreList(void) const;
|
void DrawStoreList(void) const;
|
||||||
|
|||||||
@@ -31,8 +31,8 @@
|
|||||||
|
|
||||||
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;
|
||||||
extern std::string ScriptPath, MusicPath, StorePath;
|
extern std::string ScriptPath, MusicPath, StorePath, UniStoreFile;
|
||||||
extern bool Logging, UseBars, GodMode;
|
extern bool Logging, UseBars, GodMode, autobootUnistore;
|
||||||
|
|
||||||
void load();
|
void load();
|
||||||
void save();
|
void save();
|
||||||
|
|||||||
@@ -121,5 +121,8 @@
|
|||||||
"GODMODE": "GodMode: ",
|
"GODMODE": "GodMode: ",
|
||||||
"FUNCTION_NOT_ALLOWED": "This function is not allowed without GodMode!",
|
"FUNCTION_NOT_ALLOWED": "This function is not allowed without GodMode!",
|
||||||
"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?",
|
||||||
|
"AUTOBOOT_STORE": "Would you like to autoboot this Store?\n\nThis will autoboot this store on startup!"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include "mainMenu.hpp"
|
#include "mainMenu.hpp"
|
||||||
#include "screenCommon.hpp"
|
#include "screenCommon.hpp"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
#include "uniStore.hpp"
|
||||||
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
@@ -47,6 +48,7 @@ bool dspFound = false;
|
|||||||
touchPosition touch;
|
touchPosition touch;
|
||||||
sound *bgm = NULL;
|
sound *bgm = NULL;
|
||||||
bool songIsFound = false;
|
bool songIsFound = false;
|
||||||
|
bool UniStoreAutoboot = false;
|
||||||
|
|
||||||
// Include all spritesheet's.
|
// Include all spritesheet's.
|
||||||
C2D_SpriteSheet sprites;
|
C2D_SpriteSheet sprites;
|
||||||
@@ -107,7 +109,18 @@ Result Init::Initialize() {
|
|||||||
Logging::createLogFile();
|
Logging::createLogFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Config::autobootUnistore) {
|
||||||
|
UniStoreAutoboot = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (UniStoreAutoboot) {
|
||||||
|
if (access(Config::UniStoreFile.c_str(), F_OK) == 0) {
|
||||||
|
Gui::setScreen(std::make_unique<UniStore>());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
Gui::setScreen(std::make_unique<MainMenu>());
|
Gui::setScreen(std::make_unique<MainMenu>());
|
||||||
|
}
|
||||||
|
|
||||||
osSetSpeedupEnable(true); // Enable speed-up for New 3DS users
|
osSetSpeedupEnable(true); // Enable speed-up for New 3DS users
|
||||||
|
|
||||||
if( access( "sdmc:/3ds/dspfirm.cdc", F_OK ) != -1 ) {
|
if( access( "sdmc:/3ds/dspfirm.cdc", F_OK ) != -1 ) {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include "formatting.hpp"
|
#include "formatting.hpp"
|
||||||
#include "json.hpp"
|
#include "json.hpp"
|
||||||
#include "keyboard.hpp"
|
#include "keyboard.hpp"
|
||||||
|
#include "mainMenu.hpp"
|
||||||
#include "scriptHelper.hpp"
|
#include "scriptHelper.hpp"
|
||||||
#include "unistore.hpp"
|
#include "unistore.hpp"
|
||||||
|
|
||||||
@@ -49,6 +50,9 @@ extern u32 TextColor;
|
|||||||
extern u32 progressBar;
|
extern u32 progressBar;
|
||||||
extern u32 selected;
|
extern u32 selected;
|
||||||
extern u32 unselected;
|
extern u32 unselected;
|
||||||
|
extern bool UniStoreAutoboot;
|
||||||
|
bool changeBackState = false;
|
||||||
|
|
||||||
C2D_SpriteSheet appStoreSheet;
|
C2D_SpriteSheet appStoreSheet;
|
||||||
|
|
||||||
struct storeInfo2 {
|
struct storeInfo2 {
|
||||||
@@ -61,7 +65,7 @@ struct storeInfo2 {
|
|||||||
std::string sheetURL;
|
std::string sheetURL;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void notImplemented(void);
|
storeInfo2 SI;
|
||||||
|
|
||||||
// Parse informations like URL, Title, Author, Description.
|
// Parse informations like URL, Title, Author, Description.
|
||||||
storeInfo2 parseStoreInfo(std::string fileName) {
|
storeInfo2 parseStoreInfo(std::string fileName) {
|
||||||
@@ -92,6 +96,11 @@ nlohmann::json openStoreFile() {
|
|||||||
return jsonFile;
|
return jsonFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<storeInfo2> storeInfo; // Store selection.
|
||||||
|
std::vector<std::string> appStoreList; // Actual store. ;P
|
||||||
|
std::vector<std::string> descLines;
|
||||||
|
std::string storeDesc = "";
|
||||||
|
|
||||||
// Parse the Objects.
|
// Parse the Objects.
|
||||||
std::vector<std::string> parseStoreObjects(std::string storeName) {
|
std::vector<std::string> parseStoreObjects(std::string storeName) {
|
||||||
FILE* file = fopen(storeName.c_str(), "rt");
|
FILE* file = fopen(storeName.c_str(), "rt");
|
||||||
@@ -111,11 +120,6 @@ std::vector<std::string> parseStoreObjects(std::string storeName) {
|
|||||||
return objs;
|
return objs;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<storeInfo2> storeInfo; // Store selection.
|
|
||||||
std::vector<std::string> appStoreList; // Actual store. ;P
|
|
||||||
std::vector<std::string> descLines;
|
|
||||||
std::string storeDesc = "";
|
|
||||||
|
|
||||||
bool sheetHasLoaded = false;
|
bool sheetHasLoaded = false;
|
||||||
// Sheet / Icon stuff.
|
// Sheet / Icon stuff.
|
||||||
void loadStoreSheet(int pos) {
|
void loadStoreSheet(int pos) {
|
||||||
@@ -124,6 +128,14 @@ void loadStoreSheet(int pos) {
|
|||||||
sheetHasLoaded = true;
|
sheetHasLoaded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void loadStoreAutobootSheet(const std::string &sheet) {
|
||||||
|
if (sheetHasLoaded == false) {
|
||||||
|
appStoreSheet = C2D_SpriteSheetLoad(sheet.c_str());
|
||||||
|
sheetHasLoaded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void freeSheet() {
|
void freeSheet() {
|
||||||
if (sheetHasLoaded == true) {
|
if (sheetHasLoaded == true) {
|
||||||
C2D_SpriteSheetFree(appStoreSheet);
|
C2D_SpriteSheetFree(appStoreSheet);
|
||||||
@@ -184,6 +196,53 @@ void loadStoreColors(nlohmann::json &json) {
|
|||||||
progressBar = colorTemp == 0 ? Config::progressbarColor : colorTemp;
|
progressBar = colorTemp == 0 ? Config::progressbarColor : colorTemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UniStore::UniStore() {
|
||||||
|
// Autobooting UniStore. ;)
|
||||||
|
if (UniStoreAutoboot) {
|
||||||
|
// If store isn't found, go to MainMenu.
|
||||||
|
if (access(Config::UniStoreFile.c_str(), F_OK) != 0) {
|
||||||
|
Gui::setScreen(std::make_unique<MainMenu>());
|
||||||
|
changeBackState = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse store.
|
||||||
|
SI = parseStoreInfo(Config::UniStoreFile);
|
||||||
|
// If WiFi enabled & File exist, update store.
|
||||||
|
if (checkWifiStatus()) {
|
||||||
|
if (Msg::promptMsg(Lang::get("WOULD_YOU_LIKE_UPDATE"))) {
|
||||||
|
if(SI.url != "" && SI.url != "MISSING: storeInfo.url" && SI.file != "" && SI.file != "MISSING: storeInfo.file") {
|
||||||
|
ScriptHelper::downloadFile(SI.url, SI.file, 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 {
|
||||||
|
notConnectedMsg();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ScriptHelper::checkIfValid(Config::UniStoreFile, 1) == true) {
|
||||||
|
currentStoreFile = Config::UniStoreFile;
|
||||||
|
Msg::DisplayMsg(Lang::get("PREPARE_STORE"));
|
||||||
|
if (SI.storeSheet != "" || SI.storeSheet != "MISSING: storeInfo.sheet") {
|
||||||
|
if(access(SI.storeSheet.c_str(), F_OK) != -1 ) {
|
||||||
|
loadStoreAutobootSheet(SI.storeSheet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
appStoreJson = openStoreFile();
|
||||||
|
appStoreList = parseStoreObjects(currentStoreFile);
|
||||||
|
loadStoreColors(appStoreJson);
|
||||||
|
selectedOptionAppStore = 0;
|
||||||
|
displayInformations = handleIfDisplayText();
|
||||||
|
isScriptSelected = true;
|
||||||
|
mode = 2;
|
||||||
|
changeBackState = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void notImplemented(void);
|
||||||
|
|
||||||
void UniStore::DrawSubMenu(void) const {
|
void UniStore::DrawSubMenu(void) const {
|
||||||
GFX::DrawTop();
|
GFX::DrawTop();
|
||||||
if (Config::UseBars == true) {
|
if (Config::UseBars == true) {
|
||||||
@@ -396,9 +455,13 @@ void UniStore::updateStore(int selectedStore) {
|
|||||||
|
|
||||||
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) {
|
||||||
|
Gui::setScreen(std::make_unique<MainMenu>());
|
||||||
|
} else {
|
||||||
Gui::screenBack();
|
Gui::screenBack();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (hDown & KEY_UP) {
|
if (hDown & KEY_UP) {
|
||||||
if(subSelection > 0) subSelection--;
|
if(subSelection > 0) subSelection--;
|
||||||
@@ -650,12 +713,41 @@ void UniStore::StoreSelectionLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hDown & KEY_START) {
|
||||||
|
if (Config::autobootUnistore) {
|
||||||
|
if (Msg::promptMsg(Lang::get("DISABLE_AUTOBOOT_STORE"))) {
|
||||||
|
Config::autobootUnistore = false;
|
||||||
|
Config::UniStoreFile = "";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (dirContents[selection].isDirectory) {
|
||||||
|
} else if (storeInfo.size() != 0) {
|
||||||
|
if (ScriptHelper::checkIfValid(dirContents[selection].name, 1) == true) {
|
||||||
|
if (Msg::promptMsg(Lang::get("AUTOBOOT_STORE"))) {
|
||||||
|
Config::UniStoreFile = Config::StorePath + dirContents[selection].name;
|
||||||
|
Config::autobootUnistore = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UniStore::StoreLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
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) {
|
||||||
|
UniStoreAutoboot = false;
|
||||||
|
mode = 0;
|
||||||
|
appStoreList.clear();
|
||||||
|
isScriptSelected = false;
|
||||||
|
selection2 = 0;
|
||||||
|
if (sheetHasLoaded == true) {
|
||||||
|
freeSheet();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
mode = 1;
|
mode = 1;
|
||||||
appStoreList.clear();
|
appStoreList.clear();
|
||||||
isScriptSelected = false;
|
isScriptSelected = false;
|
||||||
@@ -664,6 +756,7 @@ void UniStore::StoreLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||||||
freeSheet();
|
freeSheet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (hDown & KEY_R) {
|
if (hDown & KEY_R) {
|
||||||
fastMode = true;
|
fastMode = true;
|
||||||
|
|||||||
@@ -48,6 +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;
|
||||||
|
std::string Config::UniStoreFile = "";
|
||||||
nlohmann::json configJson;
|
nlohmann::json configJson;
|
||||||
|
|
||||||
void Config::load() {
|
void Config::load() {
|
||||||
@@ -145,6 +147,18 @@ void Config::load() {
|
|||||||
Config::StorePath = getString("STOREPATH");
|
Config::StorePath = getString("STOREPATH");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!configJson.contains("UNISTORE_AUTOBOOT")) {
|
||||||
|
Config::autobootUnistore = false;
|
||||||
|
} else {
|
||||||
|
Config::autobootUnistore = getBool("UNISTORE_AUTOBOOT");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!configJson.contains("UNISTORE_FILE")) {
|
||||||
|
Config::UniStoreFile = "";
|
||||||
|
} else {
|
||||||
|
Config::UniStoreFile = getString("UNISTORE_FILE");
|
||||||
|
}
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
} else {
|
} else {
|
||||||
Config::Color1 = BarColor;
|
Config::Color1 = BarColor;
|
||||||
@@ -162,6 +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::UniStoreFile = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,6 +197,10 @@ void Config::save() {
|
|||||||
Config::setBool("LOGGING", Config::Logging);
|
Config::setBool("LOGGING", Config::Logging);
|
||||||
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::setString("UNISTORE_FILE", Config::UniStoreFile);
|
||||||
|
|
||||||
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);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
@@ -204,6 +224,10 @@ void Config::initializeNewConfig() {
|
|||||||
Config::setBool("LOGGING", false);
|
Config::setBool("LOGGING", false);
|
||||||
Config::setBool("BARS", true);
|
Config::setBool("BARS", true);
|
||||||
Config::setString("STOREPATH", STORE_PATH);
|
Config::setString("STOREPATH", STORE_PATH);
|
||||||
|
|
||||||
|
Config::setBool("UNISTORE_AUTOBOOT", false);
|
||||||
|
Config::setString("UNISTORE_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