Add queue system with background downloading and much more (#73)

* Do not build here until it is merged.

* WIP: Queue System.

Right now crashes randomly for whatever reason..

* Animate queue spinner more slowly

* Use LightLocks to prevent crashing in the queue

(I hope it's fixed at least)

* Build nightlies in queue-system

* Use version.h for version and specify 7 digits

* Remove unneeded $(CURDIR)

I put that these for testing, but it's not needed

* Multiple Changes, see desc for more.

1.) Theme Implementation.
2.) Show Battery + Time.
3.) Some more work on Queue-System (might still be broke).
4.) Update Copyright to 2021.
5.) Add `%FIRM%` to regex.
6.) Mass Add to Queue.
7.) Search with AND / OR filter.

* Gaaah, not again...

* Remove DoNothing, some LightLock changes, etc

aka
Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.

* See desc for more.

- Current Queue Entry can now be canceled.

- Fix installed list.

- Display Download Speed.

- BYE BYE Queue LightLock!

* Various adjustments to the queue menu

- Make cancel button slightly smaller
- Right align "Steps: ..." text
- Remove "Current Operation:" text
- Change KB/MB/GB to KiB/MiB/GiB
- Lots of little positioning tweaks
- Fix bug where you could get stuck in the prompt
- Make spinny thing have a ! when action is needed
- Make extracting file increment at the start instead of the end
- Delete dumb VS Code file and gitignore it

* Change to hollow full charge plugged in icon

* Fix the settings positions a bit

* Fix custom font download not having prompt

Also tweak the text positions, I forgot to change them

Co-authored-by: StackZ <47382115+SuperSaiyajinStackZ@users.noreply.github.com>
This commit is contained in:
Pk11 2021-03-13 01:28:23 -06:00 committed by GitHub
commit 60e29ddb90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
92 changed files with 2566 additions and 1189 deletions

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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
@ -27,15 +27,17 @@
#ifndef _UNIVERSAL_UPDATER_COMMON_HPP
#define _UNIVERSAL_UPDATER_COMMON_HPP
#include <3ds.h>
#include "config.hpp"
#include "gfx.hpp"
#include "lang.hpp"
#include "msg.hpp"
#include "screenCommon.hpp"
#include <3ds.h>
#include <vector>
#define _STORE_PATH "sdmc:/3ds/Universal-Updater/stores/"
#define _META_PATH "sdmc:/3ds/Universal-Updater/MetaData.json"
#define _THEME_AMOUNT 1
#define _UNISTORE_VERSION 4
inline std::unique_ptr<Config> config;

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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
@ -32,50 +32,48 @@
#include <citro2d.h>
#include <string>
/*
Define all used Colors, for easier changes.
*/
/* Standard Colors. */
#define WHITE C2D_Color32(255, 255, 255, 255)
#define BLACK C2D_Color32(0, 0, 0, 255)
#define TRANSPARENT C2D_Color32(0, 0, 0, 0)
#define DIM_COLOR C2D_Color32(0, 0, 0, 190)
/* Bar, Text, BG Colors. */
#define TEXT_COLOR WHITE
#define BAR_COLOR C2D_Color32(50, 73, 98, 255)
#define BAR_OUTL_COLOR C2D_Color32(25, 30, 53, 255)
#define BG_COLOR C2D_Color32(38, 44, 77, 255)
/* Entry Colors. */
#define ENTRY_BAR_COLOR BAR_COLOR
#define ENTRY_BAR_OUTL_COLOR BAR_OUTL_COLOR
/* Entry Box Colors. */
#define BOX_INSIDE_COLOR C2D_Color32(28, 33, 58, 255)
#define BOX_SELECTED_COLOR C2D_Color32(108, 130, 155, 255)
#define BOX_UNSELECTED_COLOR BLACK
/* Progressbar Colors. */
#define PROGRESSBAR_OUT_COLOR BOX_INSIDE_COLOR
#define PROGRESSBAR_IN_COLOR SIDEBAR_UNSELECTED_COLOR
/* Search Menu Colors. */
#define SEARCH_BAR_COLOR C2D_Color32(51, 75, 102, 255)
#define SEARCH_BAR_OUTL_COLOR BAR_OUTL_COLOR
/* Sidebar Colors. */
#define SIDEBAR_SELECTED_COLOR C2D_Color32(108, 130, 155, 255)
#define SIDEBAR_UNSELECTED_COLOR C2D_Color32(77, 101, 128, 255)
struct UITheme {
uint32_t BarColor;
uint32_t BGColor;
uint32_t BarOutline;
uint32_t TextColor;
uint32_t EntryBar;
uint32_t EntryOutline;
uint32_t BoxInside;
uint32_t BoxSelected;
uint32_t BoxUnselected;
uint32_t ProgressbarOut;
uint32_t ProgressbarIn;
uint32_t SearchBar;
uint32_t SearchbarOutline;
uint32_t SideBarSelected;
uint32_t SideBarUnselected;
/* NOTE: Also used for the buttons. */
uint32_t MarkSelected;
uint32_t MarkUnselected;
uint32_t DownListPrev;
uint32_t SideBarIconColor;
};
namespace GFX {
extern std::vector<UITheme> Themes;
extern int SelectedTheme;
void DrawTop(void);
void DrawBottom();
void DrawSprite(int img, int x, int y, float ScaleX = 1, float ScaleY = 1);
void DrawBox(float xPos, float yPos, float width = 50, float height = 50, bool selected = false, uint32_t clr = BOX_INSIDE_COLOR);
void DrawBox(float xPos, float yPos, float width = 50, float height = 50, bool selected = false, uint32_t clr = GFX::Themes[GFX::SelectedTheme].BoxInside);
void DrawCheckbox(float xPos, float yPos, bool selected);
void DrawToggle(float xPos, float yPos, bool toggled);
void DrawTime();
void DrawBattery();
void HandleBattery();
};
#endif

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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
@ -28,15 +28,13 @@
#define _UNIVERSAL_UPDATER_OVERLAY_HPP
#include "common.hpp"
#include "store.hpp"
#include "storeEntry.hpp"
#include <3ds.h>
namespace Overlays {
void SelectStore(std::unique_ptr<Store> &store, std::vector<std::unique_ptr<StoreEntry>> &entries, std::unique_ptr<Meta> &meta);
void SelectLanguage(const std::unique_ptr<Store> &store);
void SelectStore();
void SelectLanguage();
void ShowCredits();
std::string SelectDir(const std::string &oldDir, const std::string &msg, const std::unique_ptr<Store> &store);
std::string SelectDir(const std::string &oldDir, const std::string &msg);
};
#endif

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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
@ -37,11 +37,12 @@
0: Entry Info.
1: Download List.
2: Search + Favorites.
3: Sorting.
4: Settings / Credits(?).
5: Screenshot Menu.
6: Release Notes.
2: Queue.
3: Search + Favorites.
4: Sorting.
5: Settings / Credits(?).
6: Screenshot Menu.
7: Release Notes.
*/
class MainScreen : public Screen {
@ -50,21 +51,18 @@ public:
void Draw(void) const override;
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
private:
std::unique_ptr<Store> store = nullptr;
std::unique_ptr<Meta> meta = nullptr;
std::vector<std::unique_ptr<StoreEntry>> entries;
std::vector<std::string> dwnldList, dwnldSizes;
bool initialized = false, fetchDown = false, showMarks = false, showSettings = false,
ascending = false, updateFilter = false, screenshotFetch = false, canDisplay = false;
ascending = false, updateFilter = false, screenshotFetch = false, canDisplay = false, isAND = true;
int storeMode = 0, marks = 0, markIndex = 0, sPage = 0, lMode = 0, sSelection = 0,
lastMode = 0, smallDelay = 0, sPos = 0, screenshotIndex = 0, sSize = 0, zoom = 0, scrollIndex = 0;
lastMode = 0, smallDelay = 0, sPos = 0, screenshotIndex = 0, sSize = 0, zoom = 0, scrollIndex = 0, queueIndex = 0;
SortType sorttype = SortType::LAST_UPDATED;
/* Title, Author, Category, Console. */
std::vector<bool> searchIncludes = { false, false, false, false };
std::vector<bool> searchIncludes = { false, false, false, false }, installs = { };
std::string searchResult = "", screenshotName = "";
C2D_Image Screenshot = { nullptr, nullptr };

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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
@ -29,6 +29,7 @@
#include "json.hpp"
#include <string>
#include <vector>
enum favoriteMarks {
STAR = 1 << 0,
@ -46,15 +47,58 @@ public:
std::string GetUpdated(const std::string &unistoreName, const std::string &entry) const;
int GetMarks(const std::string &unistoreName, const std::string &entry) const;
bool UpdateAvailable(const std::string &unistoreName, const std::string &entry, const std::string &updated) const;
std::vector<std::string> GetInstalled(const std::string &unistoreName, const std::string &entry) const;
void SetUpdated(const std::string &unistoreName, const std::string &entry, const std::string &updated) {
if (this->metadataJson.is_discarded()) return;
this->metadataJson[unistoreName][entry]["updated"] = updated;
};
void SetMarks(const std::string &unistoreName, const std::string &entry, int marks) {
if (this->metadataJson.is_discarded()) return;
this->metadataJson[unistoreName][entry]["marks"] = marks;
};
/* TODO: Handle this better. */
void SetInstalled(const std::string &unistoreName, const std::string &entry, const std::string &name) {
if (this->metadataJson.is_discarded()) return;
const std::vector<std::string> installs = this->GetInstalled(unistoreName, entry);
bool write = true;
if (!installs.empty()) {
write = !installs.empty();
for (int i = 0; i < (int)installs.size(); i++) {
if (installs[i] == name) {
write = false;
break;
}
}
}
if (write) this->metadataJson[unistoreName][entry]["installed"] += name;
}
/* Remove installed state from a download list entry. */
void RemoveInstalled(const std::string &unistoreName, const std::string &entry, const std::string &name) {
if (this->metadataJson.is_discarded()) return;
const std::vector<std::string> installs = this->GetInstalled(unistoreName, entry);
int idx = -1;
if (!installs.empty()) {
for (int i = 0; i < (int)installs.size(); i++) {
if (installs[i] == name) {
idx = i;
break;
}
}
}
if (idx != -1) this->metadataJson[unistoreName][entry]["installed"].erase(idx);
}
void ImportMetadata();
void SaveCall();
private:

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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
@ -44,7 +44,7 @@ public:
std::string GetUniStoreTitle() const;
std::string GetUniStoreAuthor() const;
/* Get Information of the UniStore Entries. */
/* Get Information of the UniStore entries. */
std::string GetTitleEntry(int index) const;
std::string GetAuthorEntry(int index) const;
std::string GetDescriptionEntry(int index) const;

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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
@ -27,7 +27,7 @@
#ifndef _UNIVERSAL_UPDATER_STORE_UTILS_HPP
#define _UNIVERSAL_UPDATER_STORE_UTILS_HPP
#include "common.hpp"
#include "meta.hpp"
#include "store.hpp"
#include "storeEntry.hpp"
#include <vector>
@ -39,33 +39,41 @@ enum class SortType : uint8_t {
};
namespace StoreUtils {
extern std::unique_ptr<Meta> meta;
extern std::unique_ptr<Store> store;
extern std::vector<std::unique_ptr<StoreEntry>> entries;
/* Grid. */
void DrawGrid(const std::unique_ptr<Store> &store, const std::vector<std::unique_ptr<StoreEntry>> &entries);
void GridLogic(std::unique_ptr<Store> &store, std::vector<std::unique_ptr<StoreEntry>> &entries, int &currentMode, int &lastMode, bool &fetch, int &smallDelay);
void DrawGrid();
void GridLogic(int &currentMode, int &lastMode, bool &fetch, int &smallDelay);
/* Top List. */
void DrawList(const std::unique_ptr<Store> &store, const std::vector<std::unique_ptr<StoreEntry>> &entries);
void ListLogic(std::unique_ptr<Store> &store, std::vector<std::unique_ptr<StoreEntry>> &entries, int &currentMode, int &lastMode, bool &fetch, int &smallDelay);
void DrawList();
void ListLogic(int &currentMode, int &lastMode, bool &fetch, int &smallDelay);
/* Entry Info. */
void DrawEntryInfo(const std::unique_ptr<Store> &store, const std::unique_ptr<StoreEntry> &entry);
void DrawEntryInfo(const std::unique_ptr<StoreEntry> &entry);
void EntryHandle(bool &showMark, bool &fetch, bool &sFetch, int &mode, const std::unique_ptr<StoreEntry> &entry);
/* Side Menu. */
void DrawSideMenu(int currentMenu);
void SideMenuHandle(int &currentMenu, bool &fetch, int &lastMenu);
/* Download Entries. */
void DrawDownList(const std::unique_ptr<Store> &store, const std::vector<std::string> &entries, bool fetch, const std::unique_ptr<StoreEntry> &entry, const std::vector<std::string> &sizes);
void DownloadHandle(const std::unique_ptr<Store> &store, const std::unique_ptr<StoreEntry> &entry, const std::vector<std::string> &entries, int &currentMenu, std::unique_ptr<Meta> &meta, const int &lastMode, int &smallDelay);
/* Download entries. */
void DrawDownList(const std::vector<std::string> &entries, bool fetch, const std::unique_ptr<StoreEntry> &entry, const std::vector<std::string> &sizes, const std::vector<bool> &installs);
void DownloadHandle(const std::unique_ptr<StoreEntry> &entry, const std::vector<std::string> &entries, int &currentMenu, const int &lastMode, int &smallDelay, std::vector<bool> &installs);
/* Queue System. */
void DrawQueueMenu(const int queueIndex);
void QueueMenuHandle(int &queueIndex, int &storeMode);
/* Search + Favorite Menu. */
void DrawSearchMenu(const std::vector<bool> &searchIncludes, const std::string &searchResult, int marks, bool updateFilter);
void SearchHandle(std::unique_ptr<Store> &store, std::vector<std::unique_ptr<StoreEntry>> &entries, std::vector<bool> &searchIncludes, std::unique_ptr<Meta> &meta, std::string &searchResult, int &marks, bool &updateFilter, bool ascending, SortType sorttype);
void DrawSearchMenu(const std::vector<bool> &searchIncludes, const std::string &searchResult, int marks, bool updateFilter, bool isAND);
void SearchHandle(std::vector<bool> &searchIncludes, std::string &searchResult, int &marks, bool &updateFilter, bool ascending, SortType sorttype, bool &isAND);
/* Mark Menu. */
void DisplayMarkBox(int marks);
void MarkHandle(std::unique_ptr<StoreEntry> &entry, const std::unique_ptr<Store> &store, bool &showMark, std::unique_ptr<Meta> &meta);
void MarkHandle(std::unique_ptr<StoreEntry> &entry, bool &showMark);
/* Credits. */
void DrawCredits();
@ -76,14 +84,14 @@ namespace StoreUtils {
/* Settings. */
void DrawSettings(int page, int selection, int sPos);
void SettingsHandle(int &page, bool &dspSettings, int &storeMode, int &selection, std::unique_ptr<Store> &store, std::vector<std::unique_ptr<StoreEntry>> &entries, std::unique_ptr<Meta> &meta, int &sPos);
void SettingsHandle(int &page, bool &dspSettings, int &storeMode, int &selection, int &sPos);
/* Sorting. */
void DrawSorting(bool asc, SortType st);
void SortHandle(std::unique_ptr<Store> &store, std::vector<std::unique_ptr<StoreEntry>> &entries, bool &asc, SortType &st);
void SortHandle(bool &asc, SortType &st);
/* Release Notes. */
void DrawReleaseNotes(const int &scrollIndex, const std::unique_ptr<StoreEntry> &entry, const std::unique_ptr<Store> &store);
void DrawReleaseNotes(const int &scrollIndex, const std::unique_ptr<StoreEntry> &entry);
void ReleaseNotesLogic(int &scrollIndex, int &storeMode);
bool compareTitleDescending(const std::unique_ptr<StoreEntry> &a, const std::unique_ptr<StoreEntry> &b);
@ -95,13 +103,18 @@ namespace StoreUtils {
bool compareUpdateDescending(const std::unique_ptr<StoreEntry> &a, const std::unique_ptr<StoreEntry> &b);
bool compareUpdateAscending(const std::unique_ptr<StoreEntry> &a, const std::unique_ptr<StoreEntry> &b);
void SortEntries(bool Ascending, SortType sorttype, std::vector<std::unique_ptr<StoreEntry>> &entries);
void SortEntries(bool Ascending, SortType sorttype);
void search(std::vector<std::unique_ptr<StoreEntry>> &entries, const std::string &query, bool title, bool author, bool category, bool console, int selectedMarks, bool updateAvl);
void search(const std::string &query, bool title, bool author, bool category, bool console, int selectedMarks, bool updateAvl, bool isAND);
void FilterUpdateAvailable(std::vector<std::unique_ptr<StoreEntry>> &entries);
void FilterUpdateAvailable();
void ResetAll(const std::unique_ptr<Store> &store, const std::unique_ptr<Meta> &meta, std::vector<std::unique_ptr<StoreEntry>> &entries);
void ResetAll();
void RefreshUpdateAVL();
void AddToQueue(int index, const std::string &entry, const std::string &entryName, const std::string &lUpdated);
void AddAllToQueue();
};
#endif

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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
@ -38,8 +38,17 @@ enum class ProgressBar {
};
namespace Animation {
extern int DisplayY, DisplayDelay;
extern bool MoveUp, DoDelay;
void DrawProgressBar(u64 currentProgress, u64 totalProgress);
void displayProgressBar();
void DrawQueue(int x, int y);
void QueueAnimHandle();
void QueueEntryDone();
void HandleQueueEntryDone();
};
#endif

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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
@ -64,6 +64,9 @@ public:
std::string archPath() const { return this->v_archivePath; };
void archPath(const std::string &v) { this->v_archivePath = v; if (!this->changesMade) this->changesMade = true; };
std::string firmPath() const { return this->v_firmPath; };
void firmPath(const std::string &v) { this->v_firmPath = v; if (!this->changesMade) this->changesMade = true; };
/* Fetching old metadata. */
bool metadata() const { return this->v_metadata; };
void metadata(bool v) { this->v_metadata = v; if (!this->changesMade) this->changesMade = true; };
@ -87,6 +90,14 @@ public:
/* If displaying changelog. */
bool changelog() const { return this->v_changelog; };
void changelog(bool v) { this->v_changelog = v; if (!this->changesMade) this->changesMade = true; };
/* The active Theme. */
int theme() const { return this->v_theme; };
void theme(int v) { this->v_theme = v; if (!this->changesMade) this->changesMade = true; };
/* If showing prompt if action failed / succeeded. */
bool prompt() const { return this->v_prompt; };
void prompt(bool v) { this->v_prompt = v; if (!this->changesMade) this->changesMade = true; };
private:
/* Mainly helper. */
bool getBool(const std::string &key);
@ -99,12 +110,14 @@ private:
nlohmann::json json;
bool changesMade = false;
int v_theme = 0;
std::string v_language = "en", v_lastStore = "universal-db.unistore",
v_3dsxPath = "sdmc:/3ds", v_ndsPath = "sdmc:", v_archivePath = "sdmc:",
v_shortcutPath = "sdmc:/3ds/Universal-Updater/shortcuts";
v_shortcutPath = "sdmc:/3ds/Universal-Updater/shortcuts", v_firmPath = "sdmc:/luma/payloads";
bool v_list = false, v_autoUpdate = true, v_metadata = true, v_updateCheck = true,
v_showBg = false, v_customFont = false, v_changelog = true;
v_showBg = false, v_customFont = false, v_changelog = true, v_prompt = true;
};
#endif

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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

View file

@ -0,0 +1,82 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2021 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_QUEUE_SYSTEM_HPP
#define _UNIVERSAL_UPDATER_QUEUE_SYSTEM_HPP
#include "json.hpp"
#include <citro2d.h>
#include <deque>
#include <memory>
/* Extend this, if more statuses are neccessary. */
enum class QueueStatus {
None,
Copying,
Deleting,
Downloading,
Extracting,
Installing,
Moving,
Request, // For User needed Requests.
Failed,
Done
};
enum RequestType {
PROMPT_RET = -3,
NO_REQUEST = -1,
RMDIR_REQUEST = 1, // remove dir prompt request.
PROMPT_REQUEST = 2, // skip prompt request.
PROMPT_ERROR = 3 // Error message prompt. Unused right now.
};
class Queue {
public:
Queue(nlohmann::json object, const C2D_Image &img, const std::string &name, const std::string &uName, const std::string &eName, const std::string &lUpdated) :
obj(object), icn(img), name(name), unistoreName(uName), entryName(eName), lastUpdated(lUpdated) { };
QueueStatus status = QueueStatus::None;
nlohmann::json obj;
C2D_Image icn;
int total, current;
std::string name = "", unistoreName = "", entryName = "", lastUpdated = "";
};
/* Of course also a namespace to that part, so we can do that in a Thread. */
namespace QueueSystem {
extern int RequestNeeded, RequestAnswer;
extern std::string RequestMsg, EndMsg;
extern int LastElement;
extern bool Wait, Popup, CancelCallback;
void QueueHandle(); // Handles the Queue.
void AddToQueue(nlohmann::json obj, const C2D_Image &icn, const std::string &name, const std::string &uName, const std::string &eName, const std::string &lUpdated); // Adds to Queue.
void ClearQueue(); // Clears the Queue.
void Resume();
};
#endif

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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
@ -44,15 +44,15 @@ enum ScriptState {
namespace ScriptUtils {
bool matchPattern(const std::string &pattern, const std::string &tested);
Result removeFile(const std::string &file, const std::string &message);
void bootTitle(const std::string &TitleID, bool isNAND, const std::string &message);
Result removeFile(const std::string &file, const std::string &message, bool isARG = false);
void bootTitle(const std::string &TitleID, bool isNAND, const std::string &message, bool isARG = false);
Result prompt(const std::string &message);
Result copyFile(const std::string &source, const std::string &destination, const std::string &message);
Result renameFile(const std::string &oldName, const std::string &newName, const std::string &message);
Result downloadRelease(const std::string &repo, const std::string &file, const std::string &output, bool includePrereleases, const std::string &message);
Result downloadFile(const std::string &file, const std::string &output, const std::string &message);
void installFile(const std::string &file, bool updatingSelf, const std::string &message);
void extractFile(const std::string &file, const std::string &input, const std::string &output, const std::string &message);
Result copyFile(const std::string &source, const std::string &destination, const std::string &message, bool isARG = false);
Result renameFile(const std::string &oldName, const std::string &newName, const std::string &message, bool isARG = false);
Result downloadRelease(const std::string &repo, const std::string &file, const std::string &output, bool includePrereleases, const std::string &message, bool isARG = false);
Result downloadFile(const std::string &file, const std::string &output, const std::string &message, bool isARG = false);
void installFile(const std::string &file, bool updatingSelf, const std::string &message, bool isARG = false);
void extractFile(const std::string &file, const std::string &input, const std::string &output, const std::string &message, bool isARG = false);
Result runFunctions(nlohmann::json storeJson, int selection, const std::string &entry);
};

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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

View file

@ -1,6 +1,6 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
* Copyright (C) 2019-2021 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
@ -37,6 +37,7 @@ namespace StringUtils {
std::string formatBytes(int bytes);
std::string GetMarkString(int marks);
std::vector<std::string> GetMarks(int marks);
std::string format(const std::string &fmt_str, ...);
};
#endif