Implement Universal-Store [UniStore] 3DS side. (#13)

* WIP App store. ;P

* Make the FileBrowse look like Scripts Screen.

* Add *all* Script Functions for the App Store.

* WIP; Store Selection & Store Screen.

To-Do: Big cleanup and remove of duplicate stuff.

* Some UniStore work.

* :bigBruh:.

* Add Spritesheet with Icon support.

* Add a Store Prepare message, just in case it takes longer.

* ~~Not really Camera stuff, just UniStore work.~~ (#12)

* We don't want Nightly builds here.

* Add UniStore Icon.

* New banner by https://github.com/TotallyNotGuy

* Add Buttons for a prompt & update icon.

* Update README.md to be more descriptive and stuff

* Update README.md

* Add updating the spritesheet too.

* Only update stores, if needed things exist!

* Make Storepath changeable.

* Change App Description.

* Display `Title` as well.

* You can now download .unistore files by entering a URL!

Co-authored-by: FlameKat53 <flame9804@yahoo.com>

* This should fix all warnings.

Also add posX and posY for the Icons in UniStore.

* Last changes for UniStore.

Co-authored-by: FlameKat53 <flame9804@yahoo.com>
This commit is contained in:
StackZ
2019-12-29 07:52:45 +01:00
committed by GitHub
parent b6d6e6357a
commit d28194d28c
29 changed files with 1064 additions and 546 deletions
+10
View File
@@ -47,6 +47,7 @@ std::string Config::ScriptPath;
std::string Config::MusicPath;
bool Config::Logging;
bool Config::UseBars;
std::string Config::StorePath;
nlohmann::json configJson;
void Config::load() {
@@ -138,6 +139,12 @@ void Config::load() {
Config::UseBars = getBool("BARS");
}
if(!configJson.contains("STOREPATH")) {
Config::StorePath = STORE_PATH;
} else {
Config::StorePath = getString("STOREPATH");
}
fclose(file);
} else {
Config::Color1 = BarColor;
@@ -154,6 +161,7 @@ void Config::load() {
Config::MusicPath = MUSIC_PATH;
Config::Logging = false;
Config::UseBars = true;
Config::StorePath = STORE_PATH;
}
}
@@ -172,6 +180,7 @@ void Config::save() {
Config::setString("MUSICPATH", Config::MusicPath);
Config::setBool("LOGGING", Config::Logging);
Config::setBool("BARS", Config::UseBars);
Config::setString("STOREPATH", Config::StorePath);
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);
fclose(file);
@@ -194,6 +203,7 @@ void Config::initializeNewConfig() {
Config::setString("MUSICPATH", MUSIC_PATH);
Config::setBool("LOGGING", false);
Config::setBool("BARS", true);
Config::setString("STOREPATH", STORE_PATH);
if(file) fwrite(configJson.dump(1, '\t').c_str(), 1, configJson.dump(1, '\t').size(), file);
fclose(file);
+52 -17
View File
@@ -2,6 +2,7 @@
#include "screens/screenCommon.hpp"
#include "utils/common.hpp"
#include "utils/config.hpp"
#include "utils/fileBrowse.h"
#include "utils/structs.hpp"
@@ -36,6 +37,7 @@ std::vector<Structs::ButtonPos> buttonPositions = {
{80, 220, 50, 15, -1}, // Select.
{145, 220, 50, 15, -1}, // Refresh.
{210, 220, 50, 15, -1}, // Back.
{0, 0, 25, 25, -1}, // ViewMode Change.
};
/**
@@ -198,7 +200,10 @@ std::string selectFilePath(std::string selectText, const std::vector<std::string
static int keyRepeatDelay = 4;
static bool dirChanged = true;
static bool fastMode = false;
uint screenPos = 0;
uint screenPosList = 0;
std::vector<DirEntry> dirContents;
std::string dirs;
while (1) {
Gui::clearTextBufs();
@@ -215,21 +220,28 @@ std::string selectFilePath(std::string selectText, const std::vector<std::string
Gui::DrawString((400-(Gui::GetStringWidth(0.60f, path)))/2, 0, 0.60f, Config::TxtColor, path);
Gui::DrawStringCentered(0, 218, 0.60f, Config::TxtColor, selectText, 400);
}
std::string dirs;
for (uint i=(selectedFile<5) ? 0 : selectedFile-5;i<dirContents.size()&&i<((selectedFile<5) ? 6 : selectedFile+1);i++) {
if (i == selectedFile) {
dirs += "> " + dirContents[i].name + "\n\n";
} else {
dirs += dirContents[i].name + "\n\n";
Gui::DrawBottom();
if (Config::viewMode == 0) {
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)dirContents.size();i++) {
dirs = dirContents[screenPos + i].name;
if(screenPos + i == selectedFile) {
Gui::Draw_Rect(0, 40+(i*57), 320, 45, C2D_Color32(120, 192, 216, 255));
} else {
Gui::Draw_Rect(0, 40+(i*57), 320, 45, C2D_Color32(77, 118, 132, 255));
}
Gui::DrawStringCentered(0, 50+(i*57), 0.7f, WHITE, dirs, 320);
}
} else if (Config::viewMode == 1) {
for(int i=0;i<ENTRIES_PER_LIST && i<(int)dirContents.size();i++) {
dirs = dirContents[screenPosList + i].name;
if(screenPosList + i == selectedFile) {
Gui::Draw_Rect(0, (i+1)*27, 320, 25, Config::SelectedColor);
} else {
Gui::Draw_Rect(0, (i+1)*27, 320, 25, Config::UnselectedColor);
}
Gui::DrawStringCentered(0, ((i+1)*27)+1, 0.7f, Config::TxtColor, dirs, 320);
}
}
for (uint i=0;i<((dirContents.size()<6) ? 6-dirContents.size() : 0);i++) {
dirs += "\n\n";
}
Gui::DrawString(26, 32, 0.53f, Config::TxtColor, dirs.c_str());
Gui::DrawBottom();
if (Config::UseBars == true) {
Gui::DrawStringCentered(0, 0, 0.5f, Config::TxtColor, Lang::get("FILEBROWSE_MSG"), 320);
@@ -238,6 +250,7 @@ std::string selectFilePath(std::string selectText, const std::vector<std::string
}
Gui::DrawArrow(295, -1);
Gui::DrawArrow(315, 240, 180.0);
Gui::spriteBlend(sprites_view_idx, buttonPositions[6].x, buttonPositions[6].y);
Gui::Draw_Rect(buttonPositions[2].x, buttonPositions[2].y, buttonPositions[2].w, buttonPositions[2].h, C2D_Color32(0, 0, 0, 190));
Gui::Draw_Rect(buttonPositions[3].x, buttonPositions[3].y, buttonPositions[3].w, buttonPositions[3].h, C2D_Color32(0, 0, 0, 190));
@@ -267,11 +280,11 @@ std::string selectFilePath(std::string selectText, const std::vector<std::string
dirChanged = false;
}
if (hidKeysDown() & KEY_SELECT || hidKeysDown() & KEY_TOUCH && touching(touch, buttonPositions[4])) {
if ((hidKeysDown() & KEY_SELECT) || (hidKeysDown() & KEY_TOUCH && touching(touch, buttonPositions[4]))) {
dirChanged = true;
}
if (hidKeysDown() & KEY_A || hidKeysDown() & KEY_TOUCH && touching(touch, buttonPositions[2])) {
if ((hidKeysDown() & KEY_A) || (hidKeysDown() & KEY_TOUCH && touching(touch, buttonPositions[2]))) {
if (dirContents.size() != 0) {
if (dirContents[selectedFile].isDirectory) {
chdir(dirContents[selectedFile].name.c_str());
@@ -310,7 +323,7 @@ std::string selectFilePath(std::string selectText, const std::vector<std::string
}
}
if (hidKeysDown() & KEY_B || hidKeysDown() & KEY_TOUCH && touching(touch, buttonPositions[5])) {
if ((hidKeysDown() & KEY_B) || (hidKeysDown() & KEY_TOUCH && touching(touch, buttonPositions[5]))) {
char path[PATH_MAX];
getcwd(path, PATH_MAX);
if(strcmp(path, "sdmc:/") == 0 || strcmp(path, "/") == 0) {
@@ -322,7 +335,7 @@ std::string selectFilePath(std::string selectText, const std::vector<std::string
}
}
if (hidKeysDown() & KEY_X || hidKeysDown() & KEY_TOUCH && touching(touch, buttonPositions[3])) {
if ((hidKeysDown() & KEY_X) || (hidKeysDown() & KEY_TOUCH && touching(touch, buttonPositions[3]))) {
char path[PATH_MAX];
getcwd(path, PATH_MAX);
selectedPath = path;
@@ -339,5 +352,27 @@ std::string selectFilePath(std::string selectText, const std::vector<std::string
if (hidKeysDown() & KEY_L) {
fastMode = false;
}
// Switch ViewMode.
if ((hidKeysDown() & KEY_Y) || (hidKeysDown() & KEY_TOUCH && touching(touch, buttonPositions[6]))) {
if (Config::viewMode == 0) {
Config::viewMode = 1;
} else {
Config::viewMode = 0;
}
}
if (Config::viewMode == 0) {
if(selectedFile < screenPos) {
screenPos = selectedFile;
} else if (selectedFile > screenPos + ENTRIES_PER_SCREEN - 1) {
screenPos = selectedFile - ENTRIES_PER_SCREEN + 1;
}
} else if (Config::viewMode == 1) {
if(selectedFile < screenPosList) {
screenPosList = selectedFile;
} else if (selectedFile > screenPosList + ENTRIES_PER_LIST - 1) {
screenPosList = selectedFile - ENTRIES_PER_LIST + 1;
}
}
}
}
+6 -2
View File
@@ -133,7 +133,7 @@ void ScriptHelper::displayTimeMsg(std::string message, int seconds) {
}
}
bool ScriptHelper::checkIfValid(std::string scriptFile) {
bool ScriptHelper::checkIfValid(std::string scriptFile, int mode) {
FILE* file = fopen(scriptFile.c_str(), "rt");
if(!file) {
printf("File not found\n");
@@ -142,7 +142,11 @@ bool ScriptHelper::checkIfValid(std::string scriptFile) {
nlohmann::json json = nlohmann::json::parse(file, nullptr, false);
fclose(file);
if (!json.contains("info")) return false;
if (mode == 0) {
if (!json.contains("info")) return false;
} else if (mode == 1) {
if (!json.contains("storeInfo")) return false;
}
return true;
}