mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-03 00:39:02 +00:00
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:
@@ -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
|
||||
@@ -24,9 +24,11 @@
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "animation.hpp"
|
||||
#include "download.hpp"
|
||||
#include "fileBrowse.hpp"
|
||||
#include "mainScreen.hpp"
|
||||
#include "queueSystem.hpp"
|
||||
#include "screenshot.hpp"
|
||||
#include "storeUtils.hpp"
|
||||
#include <unistd.h>
|
||||
@@ -40,12 +42,12 @@ extern void DisplayChangelog();
|
||||
/*
|
||||
MainScreen Constructor.
|
||||
|
||||
Initialized Meta, Store and StoreEntry class and:
|
||||
Initialized meta, store and StoreEntry class and:
|
||||
|
||||
- Downloads Universal-DB.. in case nothing exist.
|
||||
*/
|
||||
MainScreen::MainScreen() {
|
||||
this->meta = std::make_unique<Meta>();
|
||||
StoreUtils::meta = std::make_unique<Meta>();
|
||||
|
||||
/* Check if lastStore is accessible. */
|
||||
if (config->lastStore() != "universal-db.unistore" || config->lastStore() != "") {
|
||||
@@ -84,7 +86,6 @@ MainScreen::MainScreen() {
|
||||
const UniStoreInfo info = GetInfo("sdmc:/3ds/Universal-Updater/stores/universal-db.unistore", "universal-db.unistore");
|
||||
|
||||
if (info.Version != 3 && info.Version != _UNISTORE_VERSION) {
|
||||
Msg::waitMsg("Not passing the check!");
|
||||
if (checkWifiStatus()) {
|
||||
std::string tmp = ""; // Just a temp.
|
||||
DownloadUniStore("https://db.universal-team.net/unistore/universal-db.unistore", -1, tmp, true, true);
|
||||
@@ -97,9 +98,9 @@ MainScreen::MainScreen() {
|
||||
}
|
||||
}
|
||||
|
||||
this->store = std::make_unique<Store>(_STORE_PATH + config->lastStore(), config->lastStore());
|
||||
StoreUtils::ResetAll(this->store, this->meta, this->entries);
|
||||
StoreUtils::SortEntries(false, SortType::LAST_UPDATED, this->entries);
|
||||
StoreUtils::store = std::make_unique<Store>(_STORE_PATH + config->lastStore(), config->lastStore());
|
||||
StoreUtils::ResetAll();
|
||||
StoreUtils::SortEntries(false, SortType::LAST_UPDATED);
|
||||
DisplayChangelog();
|
||||
};
|
||||
|
||||
@@ -107,30 +108,33 @@ MainScreen::MainScreen() {
|
||||
MainScreen Main Draw.
|
||||
*/
|
||||
void MainScreen::Draw(void) const {
|
||||
if (this->storeMode == 5) {
|
||||
if (this->storeMode == 6) {
|
||||
/* Screenshot Menu. */
|
||||
StoreUtils::DrawScreenshotMenu(this->Screenshot, this->screenshotIndex, this->screenshotFetch, this->sSize, this->screenshotName, this->zoom, this->canDisplay);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->storeMode == 6) {
|
||||
if (this->storeMode == 7) {
|
||||
/* Release Notes. */
|
||||
StoreUtils::DrawReleaseNotes(this->scrollIndex, this->entries[this->store->GetEntry()], this->store);
|
||||
StoreUtils::DrawReleaseNotes(this->scrollIndex, StoreUtils::entries[StoreUtils::store->GetEntry()]);
|
||||
GFX::DrawBottom();
|
||||
return;
|
||||
}
|
||||
|
||||
Gui::ScreenDraw(Top);
|
||||
Gui::Draw_Rect(0, 0, 400, 25, BAR_COLOR);
|
||||
Gui::Draw_Rect(0, 25, 400, 1, BAR_OUTL_COLOR);
|
||||
Gui::Draw_Rect(0, 0, 400, 25, GFX::Themes[GFX::SelectedTheme].BarColor);
|
||||
Gui::Draw_Rect(0, 25, 400, 1, GFX::Themes[GFX::SelectedTheme].BarOutline);
|
||||
|
||||
if (this->store && this->store->GetValid()) Gui::DrawStringCentered(0, 1, 0.7f, TEXT_COLOR, this->store->GetUniStoreTitle(), 370, 0, font);
|
||||
else Gui::DrawStringCentered(0, 1, 0.7f, TEXT_COLOR, Lang::get("INVALID_UNISTORE"), 370, 0, font);
|
||||
config->list() ? StoreUtils::DrawList(this->store, this->entries) : StoreUtils::DrawGrid(this->store, this->entries);
|
||||
if (StoreUtils::store && StoreUtils::store->GetValid()) Gui::DrawStringCentered(0, 1, 0.7f, GFX::Themes[GFX::SelectedTheme].TextColor, StoreUtils::store->GetUniStoreTitle(), 360, 0, font);
|
||||
else Gui::DrawStringCentered(0, 1, 0.7f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("INVALID_UNISTORE"), 370, 0, font);
|
||||
config->list() ? StoreUtils::DrawList() : StoreUtils::DrawGrid();
|
||||
GFX::DrawTime();
|
||||
GFX::DrawBattery();
|
||||
Animation::QueueEntryDone();
|
||||
|
||||
/* Download-ception. */
|
||||
if (this->storeMode == 1) {
|
||||
StoreUtils::DrawDownList(this->store, this->dwnldList, this->fetchDown, this->entries[this->store->GetEntry()], this->dwnldSizes);
|
||||
StoreUtils::DrawDownList(this->dwnldList, this->fetchDown, StoreUtils::entries[StoreUtils::store->GetEntry()], this->dwnldSizes, this->installs);
|
||||
|
||||
} else {
|
||||
if (fadeAlpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(0, 0, 0, fadeAlpha));
|
||||
@@ -139,20 +143,25 @@ void MainScreen::Draw(void) const {
|
||||
switch(this->storeMode) {
|
||||
case 0:
|
||||
/* Entry Info. */
|
||||
if (this->store && this->store->GetValid() && this->entries.size() > 0) StoreUtils::DrawEntryInfo(this->store, this->entries[this->store->GetEntry()]);
|
||||
if (StoreUtils::store && StoreUtils::store->GetValid() && StoreUtils::entries.size() > 0) StoreUtils::DrawEntryInfo(StoreUtils::entries[StoreUtils::store->GetEntry()]);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
/* Search + Favorites. */
|
||||
StoreUtils::DrawSearchMenu(this->searchIncludes, this->searchResult, this->marks, this->updateFilter);
|
||||
/* Queue Menu. */
|
||||
StoreUtils::DrawQueueMenu(this->queueIndex);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
/* Search + Favorites. */
|
||||
StoreUtils::DrawSearchMenu(this->searchIncludes, this->searchResult, this->marks, this->updateFilter, this->isAND);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
/* Sorting. */
|
||||
StoreUtils::DrawSorting(this->ascending, this->sorttype);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
case 5:
|
||||
/* Settings. */
|
||||
StoreUtils::DrawSettings(this->sPage, this->sSelection, this->sPos);
|
||||
break;
|
||||
@@ -160,7 +169,7 @@ void MainScreen::Draw(void) const {
|
||||
}
|
||||
|
||||
StoreUtils::DrawSideMenu(this->storeMode);
|
||||
if (this->showMarks && this->store && this->store->GetValid()) StoreUtils::DisplayMarkBox(this->entries[this->store->GetEntry()]->GetMarks());
|
||||
if (this->showMarks && StoreUtils::store && StoreUtils::store->GetValid()) StoreUtils::DisplayMarkBox(StoreUtils::entries[StoreUtils::store->GetEntry()]->GetMarks());
|
||||
if (fadeAlpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(0, 0, 0, fadeAlpha));
|
||||
}
|
||||
|
||||
@@ -168,8 +177,11 @@ void MainScreen::Draw(void) const {
|
||||
MainScreen Logic.
|
||||
*/
|
||||
void MainScreen::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
Animation::HandleQueueEntryDone();
|
||||
GFX::HandleBattery();
|
||||
|
||||
/* Screenshots Menu. */
|
||||
if (this->storeMode == 5) {
|
||||
if (this->storeMode == 6) {
|
||||
if (this->screenshotFetch) {
|
||||
/* Delete Texture first. */
|
||||
if (this->Screenshot.tex) {
|
||||
@@ -180,16 +192,16 @@ void MainScreen::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
|
||||
this->screenshotName = "";
|
||||
|
||||
if (this->screenshotIndex < (int)this->entries[this->store->GetEntry()]->GetScreenshotNames().size()) {
|
||||
this->screenshotName = this->entries[this->store->GetEntry()]->GetScreenshotNames()[this->screenshotIndex];
|
||||
if (this->screenshotIndex < (int)StoreUtils::entries[StoreUtils::store->GetEntry()]->GetScreenshotNames().size()) {
|
||||
this->screenshotName = StoreUtils::entries[StoreUtils::store->GetEntry()]->GetScreenshotNames()[this->screenshotIndex];
|
||||
}
|
||||
|
||||
this->sSize = 0;
|
||||
this->sSize = this->entries[this->store->GetEntry()]->GetScreenshots().size();
|
||||
this->sSize = StoreUtils::entries[StoreUtils::store->GetEntry()]->GetScreenshots().size();
|
||||
|
||||
if (this->screenshotIndex < this->sSize) {
|
||||
if (this->sSize > 0) {
|
||||
this->Screenshot = FetchScreenshot(this->entries[this->store->GetEntry()]->GetScreenshots()[this->screenshotIndex]);
|
||||
this->Screenshot = FetchScreenshot(StoreUtils::entries[StoreUtils::store->GetEntry()]->GetScreenshots()[this->screenshotIndex]);
|
||||
if (this->Screenshot.tex) this->canDisplay = true;
|
||||
else this->canDisplay = false;
|
||||
}
|
||||
@@ -203,58 +215,79 @@ void MainScreen::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
|
||||
/* Release Notes. */
|
||||
if (this->storeMode == 6) {
|
||||
if (this->storeMode == 7) {
|
||||
StoreUtils::ReleaseNotesLogic(this->scrollIndex, this->storeMode);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Mark Menu. */
|
||||
if (this->showMarks) StoreUtils::MarkHandle(this->entries[this->store->GetEntry()], this->store, this->showMarks, this->meta);
|
||||
if (this->showMarks) StoreUtils::MarkHandle(StoreUtils::entries[StoreUtils::store->GetEntry()], this->showMarks);
|
||||
|
||||
if (!this->showMarks) {
|
||||
if (this->storeMode == 0 || this->storeMode == 2 || this->storeMode == 3) {
|
||||
config->list() ? StoreUtils::ListLogic(this->store, this->entries, this->storeMode, this->lastMode, this->fetchDown, this->smallDelay) : StoreUtils::GridLogic(this->store, this->entries, this->storeMode, this->lastMode, this->fetchDown, this->smallDelay);
|
||||
if (storeMode == 0 || storeMode == 3 || storeMode == 4) {
|
||||
config->list() ? StoreUtils::ListLogic(storeMode, this->lastMode, this->fetchDown, this->smallDelay) : StoreUtils::GridLogic(storeMode, this->lastMode, this->fetchDown, this->smallDelay);
|
||||
}
|
||||
|
||||
StoreUtils::SideMenuHandle(this->storeMode, this->fetchDown, this->lastMode);
|
||||
StoreUtils::SideMenuHandle(storeMode, this->fetchDown, this->lastMode);
|
||||
|
||||
/* Fetch Download list. */
|
||||
if (this->fetchDown) {
|
||||
this->installs.clear();
|
||||
this->dwnldList.clear();
|
||||
this->dwnldSizes.clear();
|
||||
|
||||
if (this->store && this->store->GetValid()) {
|
||||
this->store->SetDownloadIndex(0); // Reset to 0.
|
||||
this->store->SetDownloadSIndex(0);
|
||||
if (StoreUtils::store && StoreUtils::store->GetValid()) {
|
||||
const std::vector<std::string> installedNames = StoreUtils::meta->GetInstalled(StoreUtils::store->GetUniStoreTitle(), StoreUtils::entries[StoreUtils::store->GetEntry()]->GetTitle());
|
||||
StoreUtils::store->SetDownloadIndex(0); // Reset to 0.
|
||||
StoreUtils::store->SetDownloadSIndex(0);
|
||||
|
||||
if ((int)this->entries.size() > this->store->GetEntry()) {
|
||||
this->dwnldList = this->store->GetDownloadList(this->entries[this->store->GetEntry()]->GetEntryIndex());
|
||||
this->dwnldSizes = this->entries[this->store->GetEntry()]->GetSizes();
|
||||
if ((int)StoreUtils::entries.size() > StoreUtils::store->GetEntry()) {
|
||||
this->dwnldList = StoreUtils::store->GetDownloadList(StoreUtils::entries[StoreUtils::store->GetEntry()]->GetEntryIndex());
|
||||
this->dwnldSizes = StoreUtils::entries[StoreUtils::store->GetEntry()]->GetSizes();
|
||||
|
||||
bool good = false;
|
||||
|
||||
for (int i = 0; i < (int)this->dwnldList.size(); i++) {
|
||||
good = false;
|
||||
|
||||
for (int i2 = 0; i2 < (int)installedNames.size(); i2++) {
|
||||
if (installedNames[i2] == this->dwnldList[i]) {
|
||||
this->installs.push_back( true );
|
||||
good = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!good) this->installs.push_back( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->fetchDown = false;
|
||||
}
|
||||
|
||||
switch(this->storeMode) {
|
||||
switch(storeMode) {
|
||||
case 0:
|
||||
if (this->store && this->store->GetValid() && this->entries.size() > 0) StoreUtils::EntryHandle(this->showMarks, this->fetchDown, this->screenshotFetch, this->storeMode, this->entries[this->store->GetEntry()]);
|
||||
if (StoreUtils::store && StoreUtils::store->GetValid() && StoreUtils::entries.size() > 0) StoreUtils::EntryHandle(this->showMarks, this->fetchDown, this->screenshotFetch, storeMode, StoreUtils::entries[StoreUtils::store->GetEntry()]);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (this->store && this->store->GetValid() && this->entries.size() > 0) StoreUtils::DownloadHandle(this->store, this->entries[this->store->GetEntry()], this->dwnldList, this->storeMode, this->meta, this->lastMode, this->smallDelay);
|
||||
if (StoreUtils::store && StoreUtils::store->GetValid() && StoreUtils::entries.size() > 0) StoreUtils::DownloadHandle(StoreUtils::entries[StoreUtils::store->GetEntry()], this->dwnldList, storeMode, this->lastMode, this->smallDelay, this->installs);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
StoreUtils::SearchHandle(this->store, this->entries, this->searchIncludes, this->meta, this->searchResult, this->marks, this->updateFilter, this->ascending, this->sorttype);
|
||||
StoreUtils::QueueMenuHandle(this->queueIndex, this->storeMode);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
StoreUtils::SortHandle(this->store, this->entries, this->ascending, this->sorttype);
|
||||
StoreUtils::SearchHandle(this->searchIncludes, this->searchResult, this->marks, this->updateFilter, this->ascending, this->sorttype, this->isAND);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
StoreUtils::SettingsHandle(this->sPage, this->showSettings, this->storeMode, this->sSelection, this->store, this->entries, this->meta, this->sPos);
|
||||
StoreUtils::SortHandle(this->ascending, this->sorttype);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
StoreUtils::SettingsHandle(this->sPage, this->showSettings, storeMode, this->sSelection, this->sPos);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user