mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-03 16:49:06 +00:00
My last work for today.
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "screens/screenCommon.hpp"
|
||||
|
||||
#include "utils/config.hpp"
|
||||
#include "utils/extract.hpp"
|
||||
#include "utils/fileBrowse.h"
|
||||
#include "utils/inifile.h"
|
||||
@@ -671,4 +672,75 @@ void download::extractFileList(std::string file, std::string input, std::string
|
||||
Threads::create((ThreadFunc)displayProgressBar);
|
||||
extractArchive(file, input, output);
|
||||
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.
|
||||
*/
|
||||
|
||||
#include "download/download.hpp"
|
||||
#include "screens/mainMenu.hpp"
|
||||
#include "screens/settings.hpp"
|
||||
#include "screens/scriptlist.hpp"
|
||||
@@ -91,4 +92,8 @@ void MainMenu::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
Gui::setScreen(std::make_unique<Settings>());
|
||||
}
|
||||
}
|
||||
|
||||
if (hDown & KEY_X) {
|
||||
downloadScripts();
|
||||
}
|
||||
}
|
||||
@@ -265,7 +265,7 @@ void loadColors(nlohmann::json &json) {
|
||||
|
||||
ScriptList::ScriptList() {
|
||||
dirContents.clear();
|
||||
chdir(SCRIPTS_PATH);
|
||||
chdir(Config::ScriptPath.c_str());
|
||||
getDirectoryContents(dirContents);
|
||||
for(uint i=0;i<dirContents.size();i++) {
|
||||
fileInfo.push_back(parseInfo(dirContents[i].name));
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "gui.hpp"
|
||||
|
||||
#include "utils/common.hpp"
|
||||
#include "utils/inifile.h"
|
||||
#include "utils/config.hpp"
|
||||
|
||||
@@ -44,6 +45,7 @@ int Config::Color3;
|
||||
int Config::TxtColor;
|
||||
int Config::SelectedColor;
|
||||
int Config::UnselectedColor;
|
||||
std::string Config::ScriptPath;
|
||||
|
||||
void Config::loadConfig() {
|
||||
// [UI]
|
||||
@@ -54,6 +56,7 @@ void Config::loadConfig() {
|
||||
Config::TxtColor = settingsini.GetInt("UI", "TEXTCOLOR", WHITE);
|
||||
Config::SelectedColor = settingsini.GetInt("UI", "SELECTEDCOLOR", SelectedColordefault);
|
||||
Config::UnselectedColor = settingsini.GetInt("UI", "UNSELECTEDCOLOR", UnselectedColordefault);
|
||||
Config::ScriptPath = settingsini.GetString("UI", "SCRIPTPATH", SCRIPTS_PATH);
|
||||
}
|
||||
|
||||
void Config::saveConfig() {
|
||||
@@ -65,5 +68,6 @@ void Config::saveConfig() {
|
||||
settingsini.SetInt("UI", "TEXTCOLOR", Config::TxtColor);
|
||||
settingsini.SetInt("UI", "SELECTEDCOLOR", Config::SelectedColor);
|
||||
settingsini.SetInt("UI", "UNSELECTEDCOLOR", Config::UnselectedColor);
|
||||
settingsini.SetString("UI", "SCRIPTPATH", Config::ScriptPath);
|
||||
settingsini.SaveIniFile("sdmc:/3ds/Universal-Updater/Settings.ini");
|
||||
}
|
||||
Reference in New Issue
Block a user