Universal-Updater Full Rewrite based of UniStore v3.0.0. (#51)

* No Nightlies for the Full-Rewrite.

* Initial push, i guess.

* Forgot to push the Test UniStore + T3X...

* Use C2D flags for wrapping and centering

* gitignore t3x correctly

* Remove Test Store and hardcode to `sdmc:/3ds/Universal-Updater/stores/Universal-DB.unistore` for now.

* Is functional now.

* *More special checks and work.*

* const <typename T> &.

* Universal-DB, not Universal DB.

* Derp.

* Make 3DSX, NDS & Archive path configurable.

* Last fixes + Fade out screen on exit.

* See Desc. for more.

- Add QR Code scan for downloading UniStores.
- Add new Graphics.
- Some fixes + improvements.

* Fix search filtering, re-sort after search

* Fix update check

* Clear search items with X, not just reset results

* The next progress.

* PLEASE tell me, this is the only error..

Co-authored-by: Pk11 <epicpkmn11@outlook.com>
This commit is contained in:
StackZ
2020-10-30 03:31:20 +01:00
committed by GitHub
parent 5d38c98698
commit 913475eabf
142 changed files with 13937 additions and 14588 deletions
-51
View File
@@ -1,51 +0,0 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* 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_UPDATER_MAINMENU_HPP
#define _UNIVERSAL_UPDATER_MAINMENU_HPP
#include "common.hpp"
#include "structs.hpp"
#include <vector>
class MainMenu : public Screen {
public:
void Draw(void) const override;
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
private:
int Selection = 0;
const std::vector<Structs::ButtonPos> mainButtons = {
{0, 60, 149, 52}, // UniStore.
{162, 60, 149, 52}, // Scripts.
{0, 130, 149, 52}, // Settings.
{162, 130, 149, 52}, // FTP.
{0, 215, 25, 25} // Back Arrow.
};
};
#endif
@@ -24,29 +24,41 @@
* reasonable ways as different from the original version.
*/
#ifndef _UNIVERSAL_UPDATER_CREDITS_HPP
#define _UNIVERSAL_UPDATER_CREDITS_HPP
#ifndef _UNIVERSAL_UPDATER_MAIN_SCREEN_HPP
#define _UNIVERSAL_UPDATER_MAIN_SCREEN_HPP
#include "common.hpp"
#include "structs.hpp"
#include "store.hpp"
#include "storeEntry.hpp"
#include "storeUtils.hpp"
#include <vector>
/*
Modes:
class Credits : public Screen {
0: Entry Info.
1: Download List.
2: Search + Favorites.
3: Sorting.
4: Settings / Credits(?).
*/
class MainScreen : public Screen {
public:
MainScreen();
void Draw(void) const override;
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
private:
void DrawBottom(void) const;
int creditsPage = 0;
int screenPos = 0;
int Selection = 0;
int keyRepeatDelay = 0;
std::unique_ptr<Store> store = nullptr;
std::unique_ptr<Meta> meta = nullptr;
std::vector<std::unique_ptr<StoreEntry>> entries;
std::vector<std::string> dwnldList;
bool initialized = false, fetchDown = false, showMarks = false, showSettings = false, ascending = false, updateFilter = false;
int storeMode = 0, marks = 0, markIndex = 0, sPage = 0, lMode = 0, sSelection = 0, lastMode = 0, smallDelay = 0;
SortType sorttype = SortType::LAST_UPDATED;
const std::vector<Structs::ButtonPos> arrowPos = {
{0, 215, 25, 25}, // Back Arrow.
{295, 215, 25, 25} // Next Page.
};
/* Title, Author, Category, Console. */
std::vector<bool> searchIncludes = { false, false, false, false };
std::string searchResult = "";
};
#endif
-87
View File
@@ -1,87 +0,0 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* 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_UPDATER_SCRIPT_BROWSE_HPP
#define _UNIVERSAL_UPDATER_SCRIPT_BROWSE_HPP
#include "common.hpp"
#include "fileBrowse.hpp"
#include "structs.hpp"
#include <vector>
class ScriptBrowse : public Screen {
public:
void Draw(void) const override;
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
ScriptBrowse();
private:
// Selection.
mutable int screenPos = 0;
mutable int screenPosList = 0;
mutable int Selection = 0;
int dropSelection = 0;
int mode = 0;
bool dropDownMenu = false;
bool loaded = false;
// Draws.
void DrawBrowse(void) const;
void DrawGlossary(void) const;
void DropDownLogic(u32 hDown, u32 hHeld, touchPosition touch);
nlohmann::json infoJson;
int maxScripts;
// Browse stuff.
int keyRepeatDelay = 0;
std::vector<DirEntry> dirContents;
void refresh();
void downloadAll();
// Button | Icon struct.
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, 25, 25}, // Download All.
{5, 70, 25, 25}, // Refresh.
{5, 110, 25, 25} // ViewMode.
};
const std::vector<Structs::ButtonPos> dropPos2 = {
{0, 28, 140, 30}, // Download All.
{0, 68, 140, 30}, // Refresh.
{0, 108, 140, 30} // ViewMode.
};
};
#endif
-113
View File
@@ -1,113 +0,0 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* 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_UPDATER_SCRIPT_CREATOR_HPP
#define _UNIVERSAL_UPDATER_SCRIPT_CREATOR_HPP
#include "common.hpp"
#include "json.hpp"
#include "structs.hpp"
#include <vector>
class ScriptCreator : public Screen {
public:
void Draw(void) const override;
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
private:
std::string entryName = "";
// Screen draws.
void DrawSubMenu(void) const;
void DrawScriptScreen(void) const;
void SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch);
void scriptLogic(u32 hDown, u32 hHeld, touchPosition touch);
// Selection + Mode.
int Selection = 0;
int mode = 0;
int page = 0;
// Functions.
void openJson(std::string fileName);
void createNewJson(std::string fileName);
void save();
void setInfoStuff(void);
// Creating Functions. -> Page 1.
void createDownloadRelease();
void createDownloadFile();
void createDeleteFile();
void createExtractFile();
void createInstallCia();
void createMkDir();
// Creating Functions. -> Page 2.
void createRmDir();
void createMkFile();
void createTimeMsg();
void createSaveConfig();
void createBootTitle();
void createPromptMessage();
// Creating Functions. -> Page 3.
void createCopy();
void createMove();
//
void setBool(const std::string &object, const std::string &key, bool v);
void setBool2(const std::string &object, const std::string &key, const std::string &key2, bool v);
void setInt(const std::string &object, const std::string &key, int v);
void setInt2(const std::string &object, const std::string &key, const std::string &key2, int v);
void setString(const std::string &object, const std::string &key, const std::string &v);
void setString2(const std::string &object, const std::string &key, const std::string &key2, const std::string &v);
void createEntry(const std::string &Entryname);
std::string jsonFileName;
nlohmann::json editScript;
// Main Pos.
const std::vector<Structs::ButtonPos> mainButtons = {
{90, 40, 140, 35}, // New Script.
{90, 100, 140, 35} // Existing Script.
};
// Creator Button Pos.
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}
};
};
#endif
-115
View File
@@ -1,115 +0,0 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* 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_UPDATER_SCRIPT_LIST_HPP
#define _UNIVERSAL_UPDATER_SCRIPT_LIST_HPP
#include "common.hpp"
#include "fileBrowse.hpp"
#include "scriptHelper.hpp"
#include "structs.hpp"
#include <vector>
class ScriptList : public Screen {
public:
void Draw(void) const override;
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
ScriptList(); // In case of "Autoboot", have a Constructor which handles stuff.
private:
// Screen Mode.
int mode = 0;
int lastMode = 1;
// Helper functions.
void deleteScript(int selectedScript);
void refreshList();
nlohmann::json openScriptFile();
bool checkForValidate(void);
void loadDesc(void);
Result runFunctions(nlohmann::json &json);
// Draw Functions.
void DrawSubMenu(void) const;
void DrawList(void) const;
void DrawSingleObject(void) const;
void DrawGlossary(void) const;
// Logic Functions.
void SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch);
void ListSelection(u32 hDown, u32 hHeld, touchPosition touch);
void SelectFunction(u32 hDown, u32 hHeld, touchPosition touch);
// This is for the Script Creator, so no one can access it for now, until it is stable or so.
bool isTesting = true;
// Other includes which get destructed automatically.
std::string choice;
std::string currentFile;
std::string selectedTitle;
std::string Desc = "";
nlohmann::json jsonFile;
std::vector<ScriptInfo> fileInfo;
std::vector<std::string> fileInfo2;
std::vector<std::string> lines;
mutable int screenPos = 0;
mutable int screenPosList = 0;
mutable int Selection = 0;
int dropSelection = 0;
bool dropDownMenu = false;
// Browse stuff.
int keyRepeatDelay = 0;
std::vector<DirEntry> dirContents;
// Button | Icon 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.
};
const std::vector<Structs::ButtonPos> subPos = {
{0, 60, 149, 52}, // Script list.
{162, 60, 149, 52}, // Get Scripts.
{0, 130, 149, 52}, // Script Creator.
{162, 130, 149, 52} // Script path change.
};
// DropDownMenu.
const std::vector<Structs::ButtonPos> dropPos = {
{5, 30, 25, 25}, // Delete.
{5, 70, 25, 25} // ViewMode.
};
const std::vector<Structs::ButtonPos> dropPos2 = {
{0, 28, 140, 30}, // Delete.
{0, 68, 140, 30} // ViewMode.
};
};
#endif
-83
View File
@@ -1,83 +0,0 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* 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_UPDATER_SETTINGS_HPP
#define _UNIVERSAL_UPDATER_SETTINGS_HPP
#include "common.hpp"
#include "fileBrowse.hpp"
#include "structs.hpp"
#include <vector>
class Settings : public Screen {
public:
void Draw(void) const override;
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
Settings();
private:
int colorMode = 0;
int mode = 0;
int Selection = 0;
bool dropDownMenu = false;
mutable int screenPos = 0;
int colorSelection = 0;
int keyRepeatDelay = 0;
int settingPage = 0;
// Draws.
void DrawSubMenu(void) const;
void DrawLanguageSelection(void) const;
void DrawColorChanging(void) const;
// Logic's.
void SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch);
void LanguageSelection(u32 hDown, u32 hHeld, touchPosition touch);
void colorChanging(u32 hDown, u32 hHeld, touchPosition touch);
const std::vector<Structs::ButtonPos> mainButtons = {
{80, 30, 149, 52}, // Language.
{80, 90, 149, 52}, // Colors.
{80, 150, 149, 52} // Credits.
};
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.
};
const std::vector<Structs::ButtonPos> arrowPos = {
{0, 0, 25, 25}, // Previous Arrow.
{295, 0, 25, 25}, // Next Arrow.
{0, 215, 25, 25}, // Back Arrow.
{0, 0, 25, 25}, // Back Arrow top left.
{295, 215, 25, 25}, // Next Page / Misc Arrow.
{5, 0, 25, 25} // Dropdown Menu.
};
};
#endif
-42
View File
@@ -1,42 +0,0 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* 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_UPDATER_STARTUP_HPP
#define _UNIVERSAL_UPDATER_STARTUP_HPP
#include "common.hpp"
class Startup : public Screen {
public:
void Draw(void) const override;
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
Startup(int mode = 0, std::string file = "NOT_USED");
private:
int mode = 0, delay = 150;
std::string file = "NOT_USED";
};
#endif
-134
View File
@@ -1,134 +0,0 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* 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_UPDATER_UNISTORE_HPP
#define _UNIVERSAL_UPDATER_UNISTORE_HPP
#include "common.hpp"
#include "fileBrowse.hpp"
#include "scriptHelper.hpp"
#include "structs.hpp"
#include <vector>
class UniStore : public Screen {
public:
void Draw(void) const override;
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
UniStore(bool doAutoboot, std::string file);
private:
bool doAutoboot = false;
std::string autobootFile = "";
void refreshList();
nlohmann::json openStoreFile();
void loadStoreDesc(void);
StoreInfo parseStoreInfo(std::string fileName);
void autobootLogic();
void DrawSubMenu(void) const;
void DrawStoreList(void) const;
void DrawSearch(void) const;
void DrawFullURLScreen(void) const;
void DrawGitHubScreen(void) const;
void SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch);
void StoreSelectionLogic(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);
void descript();
void updateStore(int selectedStore);
void deleteStore(int selectedStore);
bool handleIfDisplayText();
int mode = 0;
bool displayInformations = true;
// Stuff for the GitHub Store Search function and Full URL.
std::string OwnerAndRepo = "";
std::string fileName = "";
std::string FullURL = "";
// Selections.
mutable int Selection = 0;
int screenPos = 0;
mutable int screenPosList = 0;
bool dropDownMenu = false;
int dropSelection = 0;
// Browse stuff.
int keyRepeatDelay = 0;
std::vector<DirEntry> dirContents;
// Other stuff.
std::vector<StoreInfo> storeInfo; // Store Selection.
std::vector<std::string> descLines;
std::string storeDesc = "";
nlohmann::json JSON;
std::string currentStoreFile;
// 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.
};
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} // Universal-DB.
};
const std::vector<Structs::ButtonPos> GitHubPos = {
{30, 50, 260, 30}, // Owner & Repo.
{30, 130, 260, 30}, // Filename.
{135, 180, 50, 30} // OK.
};
const std::vector<Structs::ButtonPos> subPos = {
{80, 30, 149, 52}, // StoreList.
{80, 90, 149, 52}, // storeSearch.
{80, 150, 149, 52} // storePathChange.
};
// DropDownMenu.
const std::vector<Structs::ButtonPos> dropPos = {
{5, 30, 25, 25}, // Delete.
{5, 70, 25, 25}, // Update.
{5, 110, 25, 25} // ViewMode.
};
const std::vector<Structs::ButtonPos> dropPos2 = {
{0, 28, 140, 30}, // Delete.
{0, 68, 140, 30}, // Update.
{0, 108, 140, 30} // ViewMode.
};
};
#endif
-75
View File
@@ -1,75 +0,0 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* 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_UPDATER_UNIVERSAL_STORE_V1_HPP
#define _UNIVERSAL_UPDATER_UNIVERSAL_STORE_V1_HPP
#include "common.hpp"
#include "json.hpp"
#include "structs.hpp"
#include <citro2d.h>
#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
-135
View File
@@ -1,135 +0,0 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* 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_UPDATER_UNIVERSAL_STORE_V2_HPP
#define _UNIVERSAL_UPDATER_UNIVERSAL_STORE_V2_HPP
#include "common.hpp"
#include "json.hpp"
#include "store.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, const std::string fileName);
~UniStoreV2();
private:
std::unique_ptr<Store> sortedStore;
bool darkMode = true, sheetLoaded = false, canDisplay = false, hasLoaded = false, isDropDown = false;
int selectMenu = 0, selectedObject = 0, selectedBox = 0, lastViewMode = 0, dropSelection = 0, searchSelection = 0, iconAmount = 0, categorySelection = 0, selectedBoxList = 0, selection = -1, storePage = 0, downloadPage = 0, storePageList = 0, mode = 0, subSelection = 0, categoryPage = 0;
nlohmann::json storeJson;
C2D_SpriteSheet sheet;
std::vector<std::string> objects;
void DrawSortingMenu(void) const;
void DrawSearchMenu(void) const;
void DrawSelectMenu(int option) const;
// 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, int storeIndex) const;
void DropLogic(u32 hDown, u32 hHeld, touchPosition touch);
void DropDownMenu(void) const;
const std::vector<Structs::ButtonPos> StoreBoxesGrid = {
{25, 35, 50, 50},
{100, 35, 50, 50},
{175, 35, 50, 50},
{250, 35, 50, 50},
{325, 35, 50, 50},
{25, 95, 50, 50},
{100, 95, 50, 50},
{175, 95, 50, 50},
{250, 95, 50, 50},
{325, 95, 50, 50},
{25, 155, 50, 50},
{100, 155, 50, 50},
{175, 155, 50, 50},
{250, 155, 50, 50},
{325, 155, 50, 50}
};
const std::vector<Structs::ButtonPos> StoreBoxesList = {
{20, 35, 360, 50},
{20, 95, 360, 50},
{20, 155, 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.
{5, 110, 140, 25},// Search.
{5, 150, 140, 25} // Reset.
};
const std::vector<Structs::ButtonPos> sortingPos = {
{40, 40, 100, 40}, // Descending.
{180, 40, 100, 40}, // Ascending.
// Now the actual options.
{115, 90, 100, 30}, // Title.
{115, 130, 100, 30}, // Author.
{115, 170, 100, 30} // Last Updated.
};
const std::vector<Structs::ButtonPos> searchPos = {
{0, 60, 149, 52}, // Title.
{162, 60, 149, 52}, // Author.
{0, 130, 149, 52}, // Category.
{162, 130, 149, 52} // Console.
};
u32 barColorLight, barColorDark, bgColorLight, bgColorDark, textColorLight, textColorDark, boxColorLight, boxColorDark, outlineColorLight, outlineColorDark;
};
#endif