mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-06 08:39:07 +00:00
My last work for today.
This commit is contained in:
@@ -109,4 +109,6 @@ namespace download {
|
|||||||
void deleteFileList(std::string file, std::string message);
|
void deleteFileList(std::string file, std::string message);
|
||||||
void installFileList(std::string file, std::string message);
|
void installFileList(std::string file, std::string message);
|
||||||
void extractFileList(std::string file, std::string input, std::string output, std::string message);
|
void extractFileList(std::string file, std::string input, std::string output, std::string message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void downloadScripts(void);
|
||||||
@@ -59,4 +59,4 @@ using json = nlohmann::json;
|
|||||||
extern char * arg0;
|
extern char * arg0;
|
||||||
|
|
||||||
#define WORKING_DIR "/"
|
#define WORKING_DIR "/"
|
||||||
#define SCRIPTS_PATH "/3ds/Universal-Updater/scripts/" // The Scripts will be here.
|
#define SCRIPTS_PATH "sdmc:/3ds/Universal-Updater/scripts/" // The Scripts will be here.
|
||||||
@@ -34,6 +34,7 @@ namespace Config {
|
|||||||
// [UI]
|
// [UI]
|
||||||
extern int lang; // The current Language.
|
extern int lang; // The current Language.
|
||||||
extern int Color1, Color2, Color3, TxtColor, SelectedColor, UnselectedColor; // Colors!
|
extern int Color1, Color2, Color3, TxtColor, SelectedColor, UnselectedColor; // Colors!
|
||||||
|
extern std::string ScriptPath;
|
||||||
|
|
||||||
void loadConfig();
|
void loadConfig();
|
||||||
void saveConfig();
|
void saveConfig();
|
||||||
|
|||||||
@@ -30,5 +30,9 @@
|
|||||||
"INCOMPATIBLE_SCRIPT": "You have an incompatible script.",
|
"INCOMPATIBLE_SCRIPT": "You have an incompatible script.",
|
||||||
|
|
||||||
"DELETE_PROMPT": "Are you sure you want to delete this Directory?",
|
"DELETE_PROMPT": "Are you sure you want to delete this Directory?",
|
||||||
"CONFIRM_OR_CANCEL": "Press A to confirm, B to cancel."
|
"CONFIRM_OR_CANCEL": "Press A to confirm, B to cancel.",
|
||||||
|
|
||||||
|
"GETTING_SCRIPT_LIST": "Getting Script List...",
|
||||||
|
"B_BACK": "\uE001: Back",
|
||||||
|
"A_CHOOSE": "\uE000: Choose"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "screens/screenCommon.hpp"
|
#include "screens/screenCommon.hpp"
|
||||||
|
|
||||||
|
#include "utils/config.hpp"
|
||||||
#include "utils/extract.hpp"
|
#include "utils/extract.hpp"
|
||||||
#include "utils/fileBrowse.h"
|
#include "utils/fileBrowse.h"
|
||||||
#include "utils/inifile.h"
|
#include "utils/inifile.h"
|
||||||
@@ -671,4 +672,75 @@ void download::extractFileList(std::string file, std::string input, std::string
|
|||||||
Threads::create((ThreadFunc)displayProgressBar);
|
Threads::create((ThreadFunc)displayProgressBar);
|
||||||
extractArchive(file, input, output);
|
extractArchive(file, input, output);
|
||||||
showProgressBar = false;
|
showProgressBar = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Script Browse.
|
||||||
|
void downloadScripts(void) {
|
||||||
|
int keyRepeatDelay = 0;
|
||||||
|
std::string ScriptsPath = Config::ScriptPath;
|
||||||
|
|
||||||
|
DisplayMsg(Lang::get("GETTING_SCRIPT_LIST"));
|
||||||
|
|
||||||
|
std::vector<ThemeEntry> scriptList;
|
||||||
|
scriptList = getThemeList("Universal-Team/extras", "Scripts");
|
||||||
|
makeDirs(ScriptsPath.c_str());
|
||||||
|
|
||||||
|
for(uint i=0;i<scriptList.size();i++) {
|
||||||
|
if(scriptList[i].name.size() < 4 || scriptList[i].name.substr(scriptList[i].name.size()-4) != "json") {
|
||||||
|
scriptList.erase(scriptList.begin()+i);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int selectedScript = 0;
|
||||||
|
while(1) {
|
||||||
|
gspWaitForVBlank();
|
||||||
|
hidScanInput();
|
||||||
|
const u32 hDown = hidKeysDown();
|
||||||
|
const u32 hHeld = hidKeysHeld();
|
||||||
|
if(keyRepeatDelay) keyRepeatDelay--;
|
||||||
|
if(hDown & KEY_A) {
|
||||||
|
mkdir((scriptList[selectedScript].sdPath).c_str(), 0777);
|
||||||
|
DisplayMsg((Lang::get("DOWNLOADING") +scriptList[selectedScript].name).c_str());
|
||||||
|
downloadToFile(scriptList[selectedScript].downloadUrl, ScriptsPath.c_str() +scriptList[selectedScript].name);
|
||||||
|
} else if(hDown & KEY_B) {
|
||||||
|
selectedScript = 0;
|
||||||
|
return;
|
||||||
|
} else if(hHeld & KEY_UP && !keyRepeatDelay) {
|
||||||
|
if(selectedScript > 0) {
|
||||||
|
selectedScript--;
|
||||||
|
keyRepeatDelay = 3;
|
||||||
|
}
|
||||||
|
} else if(hHeld & KEY_DOWN && !keyRepeatDelay) {
|
||||||
|
if(selectedScript < (int)scriptList.size()-1) {
|
||||||
|
selectedScript++;
|
||||||
|
keyRepeatDelay = 3;
|
||||||
|
}
|
||||||
|
} else if(hHeld & KEY_LEFT && !keyRepeatDelay) {
|
||||||
|
selectedScript -= 10;
|
||||||
|
if(selectedScript < 0) {
|
||||||
|
selectedScript = 0;
|
||||||
|
}
|
||||||
|
keyRepeatDelay = 3;
|
||||||
|
} else if(hHeld & KEY_RIGHT && !keyRepeatDelay) {
|
||||||
|
selectedScript += 10;
|
||||||
|
if(selectedScript > (int)scriptList.size()) {
|
||||||
|
selectedScript = scriptList.size()-1;
|
||||||
|
}
|
||||||
|
keyRepeatDelay = 3;
|
||||||
|
}
|
||||||
|
std::string scriptText;
|
||||||
|
for(int i=(selectedScript<10) ? 0 : selectedScript-10;i<(int)scriptList.size()&&i<((selectedScript<10) ? 11 : selectedScript+1);i++) {
|
||||||
|
if(i == selectedScript) {
|
||||||
|
scriptText += "> " + scriptList[i].name + "\n";
|
||||||
|
} else {
|
||||||
|
scriptText += " " + scriptList[i].name + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(uint i=0;i<((scriptList.size()<10) ? 11-scriptList.size() : 0);i++) {
|
||||||
|
scriptText += "\n";
|
||||||
|
}
|
||||||
|
scriptText += Lang::get("B_BACK") + " " +Lang::get("A_CHOOSE");
|
||||||
|
DisplayMsg(scriptText.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
* reasonable ways as different from the original version.
|
* reasonable ways as different from the original version.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "download/download.hpp"
|
||||||
#include "screens/mainMenu.hpp"
|
#include "screens/mainMenu.hpp"
|
||||||
#include "screens/settings.hpp"
|
#include "screens/settings.hpp"
|
||||||
#include "screens/scriptlist.hpp"
|
#include "screens/scriptlist.hpp"
|
||||||
@@ -91,4 +92,8 @@ void MainMenu::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||||||
Gui::setScreen(std::make_unique<Settings>());
|
Gui::setScreen(std::make_unique<Settings>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hDown & KEY_X) {
|
||||||
|
downloadScripts();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -265,7 +265,7 @@ void loadColors(nlohmann::json &json) {
|
|||||||
|
|
||||||
ScriptList::ScriptList() {
|
ScriptList::ScriptList() {
|
||||||
dirContents.clear();
|
dirContents.clear();
|
||||||
chdir(SCRIPTS_PATH);
|
chdir(Config::ScriptPath.c_str());
|
||||||
getDirectoryContents(dirContents);
|
getDirectoryContents(dirContents);
|
||||||
for(uint i=0;i<dirContents.size();i++) {
|
for(uint i=0;i<dirContents.size();i++) {
|
||||||
fileInfo.push_back(parseInfo(dirContents[i].name));
|
fileInfo.push_back(parseInfo(dirContents[i].name));
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include "gui.hpp"
|
#include "gui.hpp"
|
||||||
|
|
||||||
|
#include "utils/common.hpp"
|
||||||
#include "utils/inifile.h"
|
#include "utils/inifile.h"
|
||||||
#include "utils/config.hpp"
|
#include "utils/config.hpp"
|
||||||
|
|
||||||
@@ -44,6 +45,7 @@ int Config::Color3;
|
|||||||
int Config::TxtColor;
|
int Config::TxtColor;
|
||||||
int Config::SelectedColor;
|
int Config::SelectedColor;
|
||||||
int Config::UnselectedColor;
|
int Config::UnselectedColor;
|
||||||
|
std::string Config::ScriptPath;
|
||||||
|
|
||||||
void Config::loadConfig() {
|
void Config::loadConfig() {
|
||||||
// [UI]
|
// [UI]
|
||||||
@@ -54,6 +56,7 @@ void Config::loadConfig() {
|
|||||||
Config::TxtColor = settingsini.GetInt("UI", "TEXTCOLOR", WHITE);
|
Config::TxtColor = settingsini.GetInt("UI", "TEXTCOLOR", WHITE);
|
||||||
Config::SelectedColor = settingsini.GetInt("UI", "SELECTEDCOLOR", SelectedColordefault);
|
Config::SelectedColor = settingsini.GetInt("UI", "SELECTEDCOLOR", SelectedColordefault);
|
||||||
Config::UnselectedColor = settingsini.GetInt("UI", "UNSELECTEDCOLOR", UnselectedColordefault);
|
Config::UnselectedColor = settingsini.GetInt("UI", "UNSELECTEDCOLOR", UnselectedColordefault);
|
||||||
|
Config::ScriptPath = settingsini.GetString("UI", "SCRIPTPATH", SCRIPTS_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::saveConfig() {
|
void Config::saveConfig() {
|
||||||
@@ -65,5 +68,6 @@ void Config::saveConfig() {
|
|||||||
settingsini.SetInt("UI", "TEXTCOLOR", Config::TxtColor);
|
settingsini.SetInt("UI", "TEXTCOLOR", Config::TxtColor);
|
||||||
settingsini.SetInt("UI", "SELECTEDCOLOR", Config::SelectedColor);
|
settingsini.SetInt("UI", "SELECTEDCOLOR", Config::SelectedColor);
|
||||||
settingsini.SetInt("UI", "UNSELECTEDCOLOR", Config::UnselectedColor);
|
settingsini.SetInt("UI", "UNSELECTEDCOLOR", Config::UnselectedColor);
|
||||||
|
settingsini.SetString("UI", "SCRIPTPATH", Config::ScriptPath);
|
||||||
settingsini.SaveIniFile("sdmc:/3ds/Universal-Updater/Settings.ini");
|
settingsini.SaveIniFile("sdmc:/3ds/Universal-Updater/Settings.ini");
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user