UniStore v2! (#36)

* Do not build here.

* WIP: UniStoreV2!

This implementation is ugly and a big cleanup is needed.

* [UniStoreV2]: Add `Lang::get(...)`.

* Add back UniStore autobooting.

* UniStoreV2: Add List Layout.

* Some more UniStore work.

Also constify vector's.

* Some more spritesheet checks.

* oops.. forgot to do `Config::fading`.

* Display UniStore version on the Store list bar.

* version now needs to be `0` or `1` or not included.

versions with 2, 3, 4 and up shows an error now.

* You can now also scroll to the next page with D-Pad Left/D-Pad Right!

* Last fix before merge?
This commit is contained in:
StackZ
2020-06-19 04:54:05 +02:00
committed by GitHub
parent d86f612d09
commit 2641e4922b
23 changed files with 1598 additions and 798 deletions
+2 -2
View File
@@ -43,9 +43,9 @@ private:
int Selection = 0;
int keyRepeatDelay = 0;
std::vector<Structs::ButtonPos> arrowPos = {
const std::vector<Structs::ButtonPos> arrowPos = {
{0, 215, 25, 25}, // Back Arrow.
{295, 215, 25, 25}, // Next Page.
{295, 215, 25, 25} // Next Page.
};
};
+2 -2
View File
@@ -36,7 +36,7 @@ public:
private:
int ftpEnabled = 1;
std::vector<Structs::ButtonPos> arrowPos = {
{0, 215, 25, 25}, // Back Arrow.
const std::vector<Structs::ButtonPos> arrowPos = {
{0, 215, 25, 25} // Back Arrow.
};
};
+1 -1
View File
@@ -39,7 +39,7 @@ public:
private:
int Selection = 0;
std::vector<Structs::ButtonPos> mainButtons = {
const std::vector<Structs::ButtonPos> mainButtons = {
{0, 60, 149, 52}, // UniStore.
{162, 60, 149, 52}, // Scripts.
{0, 130, 149, 52}, // Settings.
+3 -3
View File
@@ -64,7 +64,7 @@ private:
void downloadAll();
// Button | Icon struct.
std::vector<Structs::ButtonPos> arrowPos = {
const std::vector<Structs::ButtonPos> arrowPos = {
{295, 0, 25, 25}, // Arrow Up.
{295, 215, 25, 25}, // Arrow Down.
{0, 215, 25, 25}, // Back Arrow.
@@ -72,12 +72,12 @@ private:
};
// DropDownMenu.
std::vector<Structs::ButtonPos> dropPos = {
const std::vector<Structs::ButtonPos> dropPos = {
{5, 30, 25, 25}, // Download All.
{5, 70, 25, 25}, // Refresh.
{5, 110, 25, 25} // ViewMode.
};
std::vector<Structs::ButtonPos> dropPos2 = {
const std::vector<Structs::ButtonPos> dropPos2 = {
{0, 28, 140, 30}, // Download All.
{0, 68, 140, 30}, // Refresh.
{0, 108, 140, 30} // ViewMode.
+4 -4
View File
@@ -83,19 +83,19 @@ private:
std::string jsonFileName;
// Main Pos.
std::vector<Structs::ButtonPos> mainButtons = {
const std::vector<Structs::ButtonPos> mainButtons = {
{90, 40, 140, 35}, // New Script.
{90, 100, 140, 35}, // Existing Script.
{90, 100, 140, 35} // Existing Script.
};
// Creator Button Pos.
std::vector<Structs::ButtonPos> creatorButtons = {
const std::vector<Structs::ButtonPos> creatorButtons = {
{10, 40, 140, 35},
{170, 40, 140, 35},
{10, 100, 140, 35},
{170, 100, 140, 35},
{10, 160, 140, 35},
{170, 160, 140, 35},
{170, 160, 140, 35}
};
};
+4 -4
View File
@@ -88,13 +88,13 @@ private:
// Button | Icon structs.
std::vector<Structs::ButtonPos> arrowPos = {
const std::vector<Structs::ButtonPos> arrowPos = {
{295, 0, 25, 25}, // Arrow Up.
{295, 215, 25, 25}, // Arrow Down.
{0, 215, 25, 25}, // Back Arrow.
{5, 0, 25, 25} // Dropdown Menu.
};
std::vector<Structs::ButtonPos> subPos = {
const std::vector<Structs::ButtonPos> subPos = {
{0, 60, 149, 52}, // Script list.
{162, 60, 149, 52}, // Get Scripts.
{0, 130, 149, 52}, // Script Creator.
@@ -102,11 +102,11 @@ private:
};
// DropDownMenu.
std::vector<Structs::ButtonPos> dropPos = {
const std::vector<Structs::ButtonPos> dropPos = {
{5, 30, 25, 25}, // Delete.
{5, 70, 25, 25} // ViewMode.
};
std::vector<Structs::ButtonPos> dropPos2 = {
const std::vector<Structs::ButtonPos> dropPos2 = {
{0, 28, 140, 30}, // Delete.
{0, 68, 140, 30} // ViewMode.
};
+3 -3
View File
@@ -58,20 +58,20 @@ private:
void colorChanging(u32 hDown, u32 hHeld, touchPosition touch);
void MiscSettingsLogic(u32 hDown, u32 hHeld, touchPosition touch);
std::vector<Structs::ButtonPos> mainButtons = {
const std::vector<Structs::ButtonPos> mainButtons = {
{80, 30, 149, 52}, // Language.
{80, 90, 149, 52}, // Colors.
{80, 150, 149, 52} // Credits.
};
std::vector<Structs::ButtonPos> mainButtons2 = {
const std::vector<Structs::ButtonPos> mainButtons2 = {
{0, 60, 149, 52}, // Change Music File.
{162, 60, 149, 52}, // Change bar style.
{0, 130, 149, 52}, // Change Key Delay.
{162, 130, 149, 52} // Toggle animation.
};
std::vector<Structs::ButtonPos> arrowPos = {
const std::vector<Structs::ButtonPos> arrowPos = {
{0, 0, 25, 25}, // Previous Arrow.
{295, 0, 25, 25}, // Next Arrow.
{0, 215, 25, 25}, // Back Arrow.
+16 -19
View File
@@ -38,37 +38,34 @@ class UniStore : public Screen {
public:
void Draw(void) const override;
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
UniStore();
UniStore(bool doAutoboot, std::string file);
private:
bool doAutoboot = false;
std::string autobootFile = "";
void refreshList();
nlohmann::json openStoreFile();
void loadStoreDesc(void);
void loadStoreSheet(int pos);
StoreInfo parseStoreInfo(std::string fileName);
void autobootLogic();
void DrawSubMenu(void) const;
void DrawStoreList(void) const;
void DrawStore(void) const;
void DrawSearch(void) const;
void DrawFullURLScreen(void) const;
void DrawGitHubScreen(void) const;
void DrawGlossary(void) const;
void SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch);
void StoreSelectionLogic(u32 hDown, u32 hHeld, touchPosition touch);
void StoreLogic(u32 hDown, u32 hHeld, touchPosition touch);
void SearchLogic(u32 hDown, u32 hHeld, touchPosition touch);
void FullURLLogic(u32 hDown, u32 hHeld, touchPosition touch);
void GitHubLogic(u32 hDown, u32 hHeld, touchPosition touch);
Result execute();
void descript();
void updateStore(int selectedStore);
void deleteStore(int selectedStore);
bool handleIfDisplayText();
int mode = 0;
int lastMode = 1;
mutable bool displayInformations = true;
bool displayInformations = true;
// Stuff for the GitHub Store Search function and Full URL.
std::string OwnerAndRepo = "";
@@ -88,46 +85,46 @@ private:
// Other stuff.
std::vector<StoreInfo> storeInfo; // Store Selection.
std::vector<std::string> appStoreList; // Actual store. ;P
std::vector<std::string> descLines;
std::string storeDesc = "";
nlohmann::json appStoreJson;
nlohmann::json JSON;
std::string currentStoreFile;
// Icon | Button Structs.
std::vector<Structs::ButtonPos> arrowPos = {
const std::vector<Structs::ButtonPos> arrowPos = {
{295, 0, 25, 25}, // Arrow Up.
{295, 215, 25, 25}, // Arrow Down.
{0, 215, 25, 25}, // Back Arrow.
{5, 0, 25, 25}, // Dropdown Menu.
{5, 0, 25, 25} // Dropdown Menu.
};
std::vector<Structs::ButtonPos> URLBtn = {
const std::vector<Structs::ButtonPos> URLBtn = {
{0, 60, 149, 52}, // FULL URL.
{162, 60, 149, 52}, // GitHub.
{0, 130, 149, 52}, // TinyDB.
{162, 130, 149, 52} // QR Code?
{162, 130, 149, 52} // Universal-DB.
};
std::vector<Structs::ButtonPos> GitHubPos = {
const std::vector<Structs::ButtonPos> GitHubPos = {
{30, 50, 260, 30}, // Owner & Repo.
{30, 130, 260, 30}, // Filename.
{135, 180, 50, 30} // OK.
};
std::vector<Structs::ButtonPos> subPos = {
const std::vector<Structs::ButtonPos> subPos = {
{80, 30, 149, 52}, // StoreList.
{80, 90, 149, 52}, // storeSearch.
{80, 150, 149, 52} // storePathChange.
};
// DropDownMenu.
std::vector<Structs::ButtonPos> dropPos = {
const std::vector<Structs::ButtonPos> dropPos = {
{5, 30, 25, 25}, // Delete.
{5, 70, 25, 25}, // Update.
{5, 110, 25, 25} // ViewMode.
};
std::vector<Structs::ButtonPos> dropPos2 = {
const std::vector<Structs::ButtonPos> dropPos2 = {
{0, 28, 140, 30}, // Delete.
{0, 68, 140, 30}, // Update.
{0, 108, 140, 30} // ViewMode.
@@ -24,15 +24,52 @@
* reasonable ways as different from the original version.
*/
#ifndef EXITING_HPP
#define EXITING_HPP
#ifndef UNIVERSAL_STORE_V1_HPP
#define UNIVERSAL_STORE_V1_HPP
#include "common.hpp"
#include "json.hpp"
#include "structs.hpp"
#include <citro2d.h>
class Exiting : public Screen {
#include <vector>
class UniStoreV1 : public Screen {
public:
void Draw(void) const override;
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
UniStoreV1(nlohmann::json &JSON, const std::string sheetPath, bool displayInf);
~UniStoreV1();
private:
// Selections.
mutable int Selection = 0;
bool sheetHasLoaded = false;
int screenPos = 0;
mutable int screenPosList = 0;
bool dropDownMenu = false;
int dropSelection = 0;
int keyRepeatDelay = 0;
nlohmann::json storeJson;
C2D_SpriteSheet sheet;
std::vector<std::string> objects;
mutable bool displayInformations = true;
void drawBlend(int key, int x, int y) const;
void parseObjects();
Result execute();
// Icon | Button Structs.
const std::vector<Structs::ButtonPos> arrowPos = {
{295, 0, 25, 25}, // Arrow Up.
{295, 215, 25, 25}, // Arrow Down.
{0, 215, 25, 25}, // Back Arrow.
{5, 0, 25, 25} // Dropdown Menu.
};
// DropDownMenu.
const std::vector<Structs::ButtonPos> dropPos = {
{5, 30, 140, 30}, // Delete.
{5, 70, 140, 30}, // Update.
{5, 110, 140, 30} // ViewMode.
};
};
#endif
+104
View File
@@ -0,0 +1,104 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef UNIVERSAL_STORE_V2_HPP
#define UNIVERSAL_STORE_V2_HPP
#include "common.hpp"
#include "json.hpp"
#include "structs.hpp"
#include <citro2d.h>
#include <vector>
class UniStoreV2 : public Screen {
public:
void Draw(void) const override;
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
UniStoreV2(nlohmann::json &JSON, const std::string sheetPath);
~UniStoreV2();
private:
bool darkMode = true, sheetLoaded = false, canDisplay = false, hasLoaded = false, isDropDown = false;
int selectedBox = 0, lastViewMode = 0, dropSelection = 0, iconAmount = 0, selectedBoxList = 0, selection = -1, storePage = 0, downloadPage = 0, storePageList = 0, mode = 0, subSelection = 0;
nlohmann::json storeJson;
C2D_SpriteSheet sheet;
std::vector<std::string> objects;
// Base stuff.
void DrawBaseTop(void) const;
void DrawBaseBottom(void) const;
void drawBox(float xPos, float yPos, float width, float height, bool selected) const;
void DrawGrid(void) const;
void DrawDescription(int selection) const;
u32 returnTextColor() const;
void parseObjects(int selection);
Result runFunctions(std::string entry);
void DrawList(void) const;
void displaySelectedEntry(int selection) const;
void DropLogic(u32 hDown, u32 hHeld, touchPosition touch);
void DropDownMenu(void) const;
const std::vector<Structs::ButtonPos> StoreBoxesGrid = {
{20, 30, 100, 50},
{150, 30, 100, 50},
{280, 30, 100, 50},
{20, 95, 100, 50},
{150, 95, 100, 50},
{280, 95, 100, 50},
{20, 160, 100, 50},
{150, 160, 100, 50},
{280, 160, 100, 50}
};
const std::vector<Structs::ButtonPos> StoreBoxesList = {
{20, 30, 360, 50},
{20, 95, 360, 50},
{20, 160, 360, 50}
};
const std::vector<Structs::ButtonPos> downloadBoxes = {
{10, 40, 300, 25},
{10, 75, 300, 25},
{10, 110, 300, 25},
{10, 145, 300, 25},
{10, 180, 300, 25}
};
const std::vector<Structs::ButtonPos> iconPos = {
{5, 0, 25, 25} // Dropdown Menu.
};
const std::vector<Structs::ButtonPos> dropPos = {
{5, 30, 140, 25}, // Theme.
{5, 70, 140, 25} // Style.
};
u32 barColorLight, barColorDark, bgColorLight, bgColorDark, textColorLight, textColorDark, boxColorLight, boxColorDark, outlineColorLight, outlineColorDark;
};
#endif
+1
View File
@@ -45,6 +45,7 @@ struct StoreInfo {
std::string file;
std::string storeSheet;
std::string sheetURL;
int version;
};
enum ScriptState {