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
parent e52bd33905
commit 60e29ddb90
92 changed files with 2564 additions and 1187 deletions
+277
View File
@@ -0,0 +1,277 @@
/*
* 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.
*/
#include "animation.hpp"
#include "common.hpp"
#include "keyboard.hpp"
#include "queueSystem.hpp"
#include "scriptUtils.hpp"
#include "storeUtils.hpp"
#include "structs.hpp"
#include <fstream>
#define DOWNLOAD_ENTRIES 7
extern std::string _3dsxPath;
extern bool is3DSX;
extern bool touching(touchPosition touch, Structs::ButtonPos button);
static const std::vector<Structs::ButtonPos> downloadBoxes = {
{ 46, 32, 241, 22 },
{ 46, 62, 241, 22 },
{ 46, 92, 241, 22 },
{ 46, 122, 241, 22 },
{ 46, 152, 241, 22 },
{ 46, 182, 241, 22 },
{ 46, 212, 241, 22 },
{ 42, 216, 24, 24 }
};
static const std::vector<Structs::ButtonPos> installedPos = {
{ 288, 32, 24, 24 },
{ 288, 62, 24, 24 },
{ 288, 92, 24, 24 },
{ 288, 122, 24, 24 },
{ 288, 152, 24, 24 },
{ 288, 182, 24, 24 },
{ 288, 212, 24, 24 },
};
/*
With this, we can create a shortcut. ;P
const std::string &entryName: The name of the Entry. AKA: The Title Name.
int index: The Download index.
const std::string &unistoreName: The name of the UniStore filename.
const std::string &author: The author of the app.
*/
static bool CreateShortcut(const std::string &entryName, int index, const std::string &unistoreName, const std::string &author) {
std::string sName = Input::setkbdString(30, Lang::get("ENTER_SHORTCUT_FILENAME"), {});
if (sName == "") return false; // Just cancel.
std::ofstream out(config->shortcut() + "/" + sName + ".xml", std::ios::binary);
out << "<shortcut>" << std::endl;
/* Executable. */
const std::string executable = _3dsxPath.substr(5, _3dsxPath.size()); // It must be '/3ds/...'.
out << " <executable>" << executable << "</executable>" << std::endl;
/* Arguments. */
out << " <arg>\"" << unistoreName << "\" \"" << entryName << "\" \"" << std::to_string(index) << "\"" << "</arg>" << std::endl;
/* Title. */
const std::string title = Input::setkbdString(30, Lang::get("ENTER_TITLE_SHORTCUT"), {});
if (title != "") out << " <name>" << title << "</name>" << std::endl;
else out << " <name>" << entryName << "</name>" << std::endl;
/* Description. */
const std::string desc = Input::setkbdString(50, Lang::get("ENTER_DESC_SHORTCUT"), {});
if (desc != "") out << " <description>" << desc << "</description>" << std::endl;
else out << " <description>" << entryName << "</description>" << std::endl;
/* Author and end. */
out << " <author>" << author << "</author>" << std::endl;
out << "</shortcut>" << std::endl;
out.close();
return true;
}
/*
Draw the Download entries part.
const std::vector<std::string> &entries: Const Reference to the download list as a vector of strings.
bool fetch: if fetching or not.
const std::unique_ptr<StoreEntry> &entry: Const Reference to the StoreEntry.
const std::vector<std::string> &sizes: Const Reference to the download sizes as a vector of strings.
*/
void StoreUtils::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) {
/* For the Top Screen. */
if (StoreUtils::store && StoreUtils::store->GetValid() && !fetch && entry) {
if (entries.size() > 0) {
Gui::Draw_Rect(0, 174, 400, 66, GFX::Themes[GFX::SelectedTheme].DownListPrev);
const C2D_Image tempImg = entry->GetIcon();
const uint8_t offsetW = (48 - tempImg.subtex->width) / 2; // Center W.
const uint8_t offsetH = (48 - tempImg.subtex->height) / 2; // Center H.
C2D_DrawImageAt(tempImg, 9 + offsetW, 174 + 9 + offsetH, 0.5);
Gui::DrawString(70, 174 + 15, 0.45f, GFX::Themes[GFX::SelectedTheme].TextColor, entries[StoreUtils::store->GetDownloadIndex()], 310, 0, font);
if (!sizes.empty()) {
if (sizes[StoreUtils::store->GetDownloadIndex()] != "") {
Gui::DrawString(70, 174 + 30, 0.45f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("SIZE") + ": " + sizes[StoreUtils::store->GetDownloadIndex()], 310, 0, font);
}
}
}
}
GFX::DrawTime();
GFX::DrawBattery();
Animation::QueueEntryDone();
GFX::DrawBottom();
Gui::Draw_Rect(40, 0, 280, 25, GFX::Themes[GFX::SelectedTheme].EntryBar);
Gui::Draw_Rect(40, 25, 280, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline);
Gui::DrawStringCentered(17, 2, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("AVAILABLE_DOWNLOADS"), 273, 0, font);
if (StoreUtils::store && StoreUtils::store->GetValid() && !fetch && entry) {
if (entries.size() > 0) {
for (int i = 0; i < DOWNLOAD_ENTRIES && i < (int)entries.size(); i++) {
if (StoreUtils::store->GetDownloadIndex() == i + StoreUtils::store->GetDownloadSIndex()) Gui::Draw_Rect(downloadBoxes[i].x, downloadBoxes[i].y, downloadBoxes[i].w, downloadBoxes[i].h, GFX::Themes[GFX::SelectedTheme].MarkSelected);
Gui::DrawStringCentered(46 - 160 + (241 / 2), downloadBoxes[i].y + 4, 0.45f, GFX::Themes[GFX::SelectedTheme].TextColor, entries[(i + StoreUtils::store->GetDownloadSIndex())], 235, 0, font);
if (installs[(i + StoreUtils::store->GetDownloadSIndex())]) GFX::DrawSprite(sprites_installed_idx, installedPos[i].x, installedPos[i].y);
}
if (is3DSX) GFX::DrawSprite(sprites_shortcut_idx, downloadBoxes[6].x, downloadBoxes[6].y);
} else { // If no downloads available..
Gui::DrawStringCentered(46 - 160 + (241 / 2), downloadBoxes[0].y + 4, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("NO_DOWNLOADS_AVAILABLE"), 235, 0, font);
}
}
}
/*
This is the Download List handle.
Here you can..
- Scroll through the download list, if any available.
- Execute an Entry of the download list.
- Return back to EntryInfo through `B`.
const std::unique_ptr<StoreEntry> &entry: Const Reference to the current StoreEntry, since we do not modify anything in it.
const std::vector<std::string> &entries: Const Reference to the download list, since we do not modify anything in it.
int &currentMenu: Reference to the StoreMode / Menu, so we can switch back to EntryInfo with `B`.
const int &lastMode: Const Reference to the last mode.
int &smallDelay: Reference to the small delay. This helps to not directly press A.
std::vector<bool> &installs: Reference to the installed states.
*/
void StoreUtils::DownloadHandle(const std::unique_ptr<StoreEntry> &entry, const std::vector<std::string> &entries, int &currentMenu, const int &lastMode, int &smallDelay, std::vector<bool> &installs) {
if (StoreUtils::store && entry) { // Ensure, store & entry is not a nullptr.
if (smallDelay > 0) {
smallDelay--;
}
if ((hDown & KEY_Y) || (hDown & KEY_START) || (hDown & KEY_TOUCH && touching(touch, downloadBoxes[6]))) {
if (is3DSX) { // Only allow if 3DSX.
if (StoreUtils::entries.size() <= 0) return; // Smaller than 0 -> No No.
if (Msg::promptMsg(Lang::get("CREATE_SHORTCUT"))) {
if (CreateShortcut(entry->GetTitle(), StoreUtils::store->GetDownloadIndex(), StoreUtils::store->GetFileName(), entry->GetAuthor())) {
Msg::waitMsg(Lang::get("SHORTCUT_CREATED"));
}
}
}
}
if (hRepeat & KEY_DOWN) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
if (StoreUtils::store->GetDownloadIndex() < (int)entries.size() - 1) StoreUtils::store->SetDownloadIndex(StoreUtils::store->GetDownloadIndex() + 1);
else StoreUtils::store->SetDownloadIndex(0);
}
if (hRepeat & KEY_UP) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
if (StoreUtils::store->GetDownloadIndex() > 0) StoreUtils::store->SetDownloadIndex(StoreUtils::store->GetDownloadIndex() - 1);
else StoreUtils::store->SetDownloadIndex(entries.size() - 1);
}
if (hRepeat & KEY_RIGHT) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
if (StoreUtils::store->GetDownloadIndex() + DOWNLOAD_ENTRIES < (int)entries.size()-1) StoreUtils::store->SetDownloadIndex(StoreUtils::store->GetDownloadIndex() + DOWNLOAD_ENTRIES);
else StoreUtils::store->SetDownloadIndex(entries.size()-1);
}
if (hRepeat & KEY_LEFT) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
if (StoreUtils::store->GetDownloadIndex() - DOWNLOAD_ENTRIES > 0) StoreUtils::store->SetDownloadIndex(StoreUtils::store->GetDownloadIndex() - DOWNLOAD_ENTRIES);
else StoreUtils::store->SetDownloadIndex(0);
}
if (smallDelay == 0 && hDown & KEY_TOUCH) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
bool didTouch = false;
for (int i = 0; i < DOWNLOAD_ENTRIES; i++) {
if (touching(touch, downloadBoxes[i])) {
if (i + StoreUtils::store->GetDownloadSIndex() < (int)entries.size()) {
if (Msg::promptMsg(Lang::get("EXECUTE_ENTRY") + "\n\n" + entries[i + StoreUtils::store->GetDownloadSIndex()])) {
StoreUtils::AddToQueue(entry->GetEntryIndex(), entries[i + StoreUtils::store->GetDownloadSIndex()], entry->GetTitle(), entry->GetLastUpdated());
}
didTouch = true;
break;
}
}
}
if (!didTouch) {
for (int i = 0; i < DOWNLOAD_ENTRIES; i++) {
if (touching(touch, installedPos[i])) {
if (i + StoreUtils::store->GetDownloadSIndex() < (int)entries.size()) {
if (installs[i + StoreUtils::store->GetDownloadSIndex()]) {
StoreUtils::meta->RemoveInstalled(StoreUtils::store->GetUniStoreTitle(), entry->GetTitle(), entries[i + StoreUtils::store->GetDownloadSIndex()]);
installs[i + StoreUtils::store->GetDownloadSIndex()] = false;
}
}
didTouch = true;
break;
}
}
}
}
if (smallDelay == 0 && hDown & KEY_A) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
if (Msg::promptMsg(Lang::get("EXECUTE_ENTRY") + "\n\n" + entries[StoreUtils::store->GetDownloadIndex()])) {
StoreUtils::AddToQueue(entry->GetEntryIndex(), entries[StoreUtils::store->GetDownloadIndex()], entry->GetTitle(), entry->GetLastUpdated());
}
}
if (hDown & KEY_X) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
if (installs[StoreUtils::store->GetDownloadIndex()]) {
StoreUtils::meta->RemoveInstalled(StoreUtils::store->GetUniStoreTitle(), entry->GetTitle(), entries[StoreUtils::store->GetDownloadIndex()]);
installs[StoreUtils::store->GetDownloadIndex()] = false;
}
}
if (hDown & KEY_B) currentMenu = lastMode; // Go back to EntryInfo.
/* Scroll Handle. */
if (StoreUtils::store->GetDownloadIndex() < StoreUtils::store->GetDownloadSIndex()) StoreUtils::store->SetDownloadSIndex(StoreUtils::store->GetDownloadIndex());
else if (StoreUtils::store->GetDownloadIndex() > StoreUtils::store->GetDownloadSIndex() + DOWNLOAD_ENTRIES - 1) StoreUtils::store->SetDownloadSIndex(StoreUtils::store->GetDownloadIndex() - DOWNLOAD_ENTRIES + 1);
}
}
+102
View File
@@ -0,0 +1,102 @@
/*
* 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.
*/
#include "common.hpp"
#include "storeUtils.hpp"
#include "structs.hpp"
extern bool touching(touchPosition touch, Structs::ButtonPos button);
static const Structs::ButtonPos btn = { 45, 215, 24, 24 };
static const Structs::ButtonPos sshot = { 75, 215, 24, 24 };
static const Structs::ButtonPos notes = { 105, 215, 24, 24 };
extern bool checkWifiStatus();
extern bool QueueRuns;
/*
Draw the Entry Info part.
const std::unique_ptr<StoreEntry> &entry: Const Reference to the current StoreEntry.
*/
void StoreUtils::DrawEntryInfo(const std::unique_ptr<StoreEntry> &entry) {
if (StoreUtils::store && entry) { // Ensure, store & entry is not a nullptr.
Gui::Draw_Rect(40, 0, 280, 36, GFX::Themes[GFX::SelectedTheme].EntryBar);
Gui::Draw_Rect(40, 36, 280, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline);
Gui::DrawStringCentered(17, 0, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, entry->GetTitle(), 273, 0, font);
Gui::DrawStringCentered(17, 20, 0.4, GFX::Themes[GFX::SelectedTheme].TextColor, entry->GetAuthor(), 273, 0, font);
Gui::DrawStringCentered(17, 50, 0.4, GFX::Themes[GFX::SelectedTheme].TextColor, entry->GetDescription(), 248, 0, font, C2D_WordWrap);
Gui::DrawString(53, 130, 0.45, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("VERSION") + ": " + entry->GetVersion(), 248, 0, font);
Gui::DrawString(53, 145, 0.45, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("CATEGORY") + ": " + entry->GetCategory(), 248, 0, font);
Gui::DrawString(53, 160, 0.45, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("CONSOLE") + ": " + entry->GetConsole(), 248, 0, font);
Gui::DrawString(53, 175, 0.45, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("LAST_UPDATED") + ": " + entry->GetLastUpdated(), 248, 0, font);
Gui::DrawString(53, 190, 0.45, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("LICENSE") + ": " + entry->GetLicense(), 248, 0, font);
GFX::DrawBox(btn.x, btn.y, btn.w, btn.h, false);
if (!entry->GetScreenshots().empty()) GFX::DrawSprite(sprites_screenshot_idx, sshot.x, sshot.y);
if (entry->GetReleaseNotes() != "") GFX::DrawSprite(sprites_notes_idx, notes.x, notes.y);
Gui::DrawString(btn.x + 5, btn.y + 2, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, "", 0, 0, font);
}
}
/*
The EntryInfo handle.
Here you can..
- Go to the download list, by pressing `A`.
- Show the MarkMenu with START.
bool &showMark: Reference to showMark.. to show the mark menu.
bool &fetch: Reference to fetch, so we know, if we need to fetch, when accessing download list.
bool &sFetch: Reference to the screenshot fetch.
int &mode: Reference to the store mode.
const std::unique_ptr<StoreEntry> &entry: The store Entry.
*/
void StoreUtils::EntryHandle(bool &showMark, bool &fetch, bool &sFetch, int &mode, const std::unique_ptr<StoreEntry> &entry) {
if (entry) {
if ((hDown & KEY_START) || (hDown & KEY_TOUCH && touching(touch, btn))) showMark = true;
if ((hDown & KEY_Y) || (hDown & KEY_TOUCH && touching(touch, sshot))) {
if (!entry->GetScreenshots().empty()) {
if (checkWifiStatus()) {
if (QueueRuns) {
if (!Msg::promptMsg(Lang::get("FEATURE_SIDE_EFFECTS"))) return;
sFetch = true;
mode = 6;
} else {
sFetch = true;
mode = 6;
}
}
}
}
if ((hDown & KEY_X) || (hDown & KEY_TOUCH && touching(touch, notes))) {
if (entry->GetReleaseNotes() != "") mode = 7;
}
}
}
+172
View File
@@ -0,0 +1,172 @@
/*
* 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.
*/
#include "common.hpp"
#include "storeUtils.hpp"
#include "structs.hpp"
static const std::vector<Structs::ButtonPos> GridBoxes = {
{ 25, 45, 50, 50 },
{ 100, 45, 50, 50 },
{ 175, 45, 50, 50 },
{ 250, 45, 50, 50 },
{ 325, 45, 50, 50 },
{ 25, 105, 50, 50 },
{ 100, 105, 50, 50 },
{ 175, 105, 50, 50 },
{ 250, 105, 50, 50 },
{ 325, 105, 50, 50 },
{ 25, 165, 50, 50 },
{ 100, 165, 50, 50 },
{ 175, 165, 50, 50 },
{ 250, 165, 50, 50 },
{ 325, 165, 50, 50 }
};
/* Draw the Top Grid. */
void StoreUtils::DrawGrid() {
if (StoreUtils::store) { // Ensure, store is not a nullptr.
if (config->usebg() && StoreUtils::store->customBG()) {
C2D_DrawImageAt(StoreUtils::store->GetStoreImg(), 0, 26, 0.5f, nullptr);
} else {
Gui::Draw_Rect(0, 26, 400, 214, GFX::Themes[GFX::SelectedTheme].BGColor);
}
for (int i = 0, i2 = 0 + (StoreUtils::store->GetScreenIndx() * 5); i2 < 15 + (StoreUtils::store->GetScreenIndx() * 5) && i2 < (int)StoreUtils::entries.size(); i2++, i++) {
/* Boxes. */
if (i == StoreUtils::store->GetBox()) GFX::DrawBox(GridBoxes[i].x, GridBoxes[i].y, 50, 50, true);
/* Ensure, entries is larger than the index. */
if ((int)StoreUtils::entries.size() > i2) {
if (StoreUtils::entries[i2]) { // Ensure, the Entry is not nullptr.
const C2D_Image tempImg = StoreUtils::entries[i2]->GetIcon();
const uint8_t offsetW = (48 - tempImg.subtex->width) / 2; // Center W.
const uint8_t offsetH = (48 - tempImg.subtex->height) / 2; // Center H.
C2D_DrawImageAt(tempImg, GridBoxes[i].x + 1 + offsetW, GridBoxes[i].y + 1 + offsetH, 0.5);
/* Update Available mark. */
if (StoreUtils::entries[i2]->GetUpdateAvl()) GFX::DrawSprite(sprites_update_app_idx, GridBoxes[i].x + 32, GridBoxes[i].y + 32);
}
}
}
}
}
/*
Top Grid Logic Handle.
Here you can..
- Scroll through the Grid with the D-Pad.
const int &currentMode: Reference to the current Mode.
int &lastMode: Reference to the last mode.
bool &fetch: Reference to fetch.
int &smallDelay: Reference to the small delay.
*/
void StoreUtils::GridLogic(int &currentMode, int &lastMode, bool &fetch, int &smallDelay) {
if (StoreUtils::store) { // Ensure, store is not a nullptr.
if (hRepeat & KEY_DOWN) {
if (StoreUtils::store->GetBox() > 9) {
if (StoreUtils::store->GetEntry() + 5 < (int)StoreUtils::entries.size() - 1) {
StoreUtils::store->SetEntry(StoreUtils::store->GetEntry() + 5);
if (StoreUtils::entries.size() > 15) StoreUtils::store->SetScreenIndx((StoreUtils::store->GetEntry() / 5) - 2);
} else {
if (StoreUtils::store->GetEntry() < (int)StoreUtils::entries.size() - 1) {
StoreUtils::store->SetEntry(StoreUtils::entries.size() - 1);
StoreUtils::store->SetBox(10 + (StoreUtils::store->GetEntry() % 5));
if (StoreUtils::entries.size() > 15) StoreUtils::store->SetScreenIndx((StoreUtils::store->GetEntry() / 5) - 2);
}
}
} else {
if (StoreUtils::store->GetEntry() + 5 < (int)StoreUtils::entries.size()) {
StoreUtils::store->SetBox(StoreUtils::store->GetBox() + 5);
StoreUtils::store->SetEntry(StoreUtils::store->GetEntry() + 5);
}
}
}
if (hRepeat & KEY_RIGHT) {
if (StoreUtils::store->GetEntry() < (int)StoreUtils::entries.size() - 1) {
if (StoreUtils::store->GetBox() < 14) {
StoreUtils::store->SetBox(StoreUtils::store->GetBox() + 1);
StoreUtils::store->SetEntry(StoreUtils::store->GetEntry() + 1);
} else {
StoreUtils::store->SetBox(10);
StoreUtils::store->SetEntry(StoreUtils::store->GetEntry() + 1);
StoreUtils::store->SetScreenIndx((StoreUtils::store->GetEntry() / 5) - 2);
}
}
}
if (hRepeat & KEY_LEFT) {
if (StoreUtils::store->GetEntry() > 0) {
if (StoreUtils::store->GetBox() > 0) {
StoreUtils::store->SetBox(StoreUtils::store->GetBox() - 1);
StoreUtils::store->SetEntry(StoreUtils::store->GetEntry() - 1);
} else {
StoreUtils::store->SetBox(4);
StoreUtils::store->SetEntry(StoreUtils::store->GetEntry() - 1);
StoreUtils::store->SetScreenIndx((StoreUtils::store->GetEntry() / 5));
}
}
}
if (hRepeat & KEY_UP) {
if (StoreUtils::store->GetBox() < 5) {
if (StoreUtils::store->GetEntry() > 4) {
StoreUtils::store->SetEntry(StoreUtils::store->GetEntry() - 5);
StoreUtils::store->SetScreenIndx((StoreUtils::store->GetEntry() / 5));
}
} else {
StoreUtils::store->SetBox(StoreUtils::store->GetBox() - 5);
StoreUtils::store->SetEntry(StoreUtils::store->GetEntry() - 5);
}
}
if (hDown & KEY_A) {
fetch = true;
smallDelay = 5;
lastMode = currentMode;
currentMode = 1;
}
}
}
+119
View File
@@ -0,0 +1,119 @@
/*
* 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.
*/
#include "common.hpp"
#include "storeUtils.hpp"
#include "structs.hpp"
static const std::vector<Structs::ButtonPos> StoreBoxesList = {
{ 20, 45, 360, 50 },
{ 20, 105, 360, 50 },
{ 20, 165, 360, 50 }
};
/* Draw the top List. */
void StoreUtils::DrawList() {
if (StoreUtils::store) { // Ensure, store is not a nullptr.
if (config->usebg() && StoreUtils::store->customBG()) {
C2D_DrawImageAt(StoreUtils::store->GetStoreImg(), 0, 26, 0.5f, nullptr);
} else {
Gui::Draw_Rect(0, 26, 400, 214, GFX::Themes[GFX::SelectedTheme].BGColor);
}
if (StoreUtils::entries.size() > 0) {
for (int i = 0; i < 3 && i < (int)StoreUtils::entries.size(); i++) {
if (i + StoreUtils::store->GetScreenIndx() == StoreUtils::store->GetEntry()) {
GFX::DrawBox(StoreBoxesList[i].x, StoreBoxesList[i].y, StoreBoxesList[i].w, StoreBoxesList[i].h, false);
}
/* Ensure, entries is larger than the index. */
if ((int)StoreUtils::entries.size() > i + StoreUtils::store->GetScreenIndx()) {
if (StoreUtils::entries[i + StoreUtils::store->GetScreenIndx()]) { // Ensure, the Entry is not nullptr.
const C2D_Image tempImg = StoreUtils::entries[i + StoreUtils::store->GetScreenIndx()]->GetIcon();
const uint8_t offsetW = (48 - tempImg.subtex->width) / 2; // Center W.
const uint8_t offsetH = (48 - tempImg.subtex->height) / 2; // Center H.
C2D_DrawImageAt(tempImg, StoreBoxesList[i].x + 1 + offsetW, StoreBoxesList[i].y + 1 + offsetH, 0.5);
}
if (StoreUtils::entries[i + StoreUtils::store->GetScreenIndx()]->GetUpdateAvl()) GFX::DrawSprite(sprites_update_app_idx, StoreBoxesList[i].x + 32, StoreBoxesList[i].y + 32);
Gui::DrawStringCentered(29, StoreBoxesList[i].y + 5, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, StoreUtils::entries[i + StoreUtils::store->GetScreenIndx()]->GetTitle(), 300, 0, font);
Gui::DrawStringCentered(29, StoreBoxesList[i].y + 24, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, StoreUtils::entries[i + StoreUtils::store->GetScreenIndx()]->GetAuthor(), 300, 0, font);
}
}
}
}
}
/*
Top List Logic Handle.
Here you can..
- Scroll through the Grid with the D-Pad Up / Down and skip 3 entries with Left / Right.
int &currentMode: Const Reference to the current Mode.
int &lastMode: Reference to the last mode.
bool &fetch: Reference to fetch.
int &smallDelay: Reference to the small delay.
*/
void StoreUtils::ListLogic(int &currentMode, int &lastMode, bool &fetch, int &smallDelay) {
if (StoreUtils::store) { // Ensure, store is not a nullptr.
if (hRepeat & KEY_DOWN) {
if (StoreUtils::store->GetEntry() < (int)StoreUtils::entries.size() - 1) StoreUtils::store->SetEntry(StoreUtils::store->GetEntry() + 1);
else StoreUtils::store->SetEntry(0);
}
if (hRepeat & KEY_RIGHT) {
if (StoreUtils::store->GetEntry() < (int)StoreUtils::entries.size() - 3) StoreUtils::store->SetEntry(StoreUtils::store->GetEntry() + 3);
else StoreUtils::store->SetEntry(StoreUtils::entries.size() - 1);
}
if (hRepeat & KEY_LEFT) {
if (StoreUtils::store->GetEntry() - 2 > 0) StoreUtils::store->SetEntry(StoreUtils::store->GetEntry() - 3);
else StoreUtils::store->SetEntry(0);
}
if (hRepeat & KEY_UP) {
if (StoreUtils::store->GetEntry() > 0) StoreUtils::store->SetEntry(StoreUtils::store->GetEntry() - 1);
else StoreUtils::store->SetEntry(StoreUtils::entries.size() - 1);
}
if (hDown & KEY_A) {
fetch = true;
smallDelay = 5;
lastMode = currentMode;
currentMode = 1;
}
/* Scroll Logic. */
if (StoreUtils::store->GetEntry() < StoreUtils::store->GetScreenIndx()) StoreUtils::store->SetScreenIndx(StoreUtils::store->GetEntry());
else if (StoreUtils::store->GetEntry() > StoreUtils::store->GetScreenIndx() + 3 - 1) StoreUtils::store->SetScreenIndx(StoreUtils::store->GetEntry() - 3 + 1);
}
}
+128
View File
@@ -0,0 +1,128 @@
/*
* 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.
*/
#include "common.hpp"
#include "storeUtils.hpp"
#include "structs.hpp"
extern bool touching(touchPosition touch, Structs::ButtonPos button);
static const std::vector<Structs::ButtonPos> markBox = {
{ 10, 94, 52, 52 },
{ 72, 94, 52, 52 },
{ 134, 94, 52, 52 },
{ 196, 94, 52, 52 },
{ 258, 94, 52, 52 },
{ 45, 215, 24, 24 }
};
/*
Draw the Marking part.
int marks: The active mark flags.
*/
void StoreUtils::DisplayMarkBox(int marks) {
Gui::Draw_Rect(0, 0, 320, 240, DIM_COLOR); // Darken.
Gui::Draw_Rect(markBox[0].x, markBox[0].y, markBox[0].w, markBox[0].h, (marks & favoriteMarks::STAR ?
GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected));
Gui::Draw_Rect(markBox[1].x, markBox[1].y, markBox[1].w, markBox[1].h, (marks & favoriteMarks::HEART ?
GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected));
Gui::Draw_Rect(markBox[2].x, markBox[2].y, markBox[2].w, markBox[2].h, (marks & favoriteMarks::DIAMOND ?
GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected));
Gui::Draw_Rect(markBox[3].x, markBox[3].y, markBox[3].w, markBox[3].h, (marks & favoriteMarks::CLUBS ?
GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected));
Gui::Draw_Rect(markBox[4].x, markBox[4].y, markBox[4].w, markBox[4].h, (marks & favoriteMarks::SPADE ?
GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected));
Gui::DrawString(markBox[0].x + 15, markBox[0].y + 11, 0.9, GFX::Themes[GFX::SelectedTheme].TextColor, "", 0, 0, font);
Gui::DrawString(markBox[1].x + 15, markBox[1].y + 11, 0.9, GFX::Themes[GFX::SelectedTheme].TextColor, "", 0, 0, font);
Gui::DrawString(markBox[2].x + 15, markBox[2].y + 11, 0.9, GFX::Themes[GFX::SelectedTheme].TextColor, "", 0, 0, font);
Gui::DrawString(markBox[3].x + 15, markBox[3].y + 11, 0.9, GFX::Themes[GFX::SelectedTheme].TextColor, "", 0, 0, font);
Gui::DrawString(markBox[4].x + 15, markBox[4].y + 11, 0.9, GFX::Themes[GFX::SelectedTheme].TextColor, "", 0, 0, font);
GFX::DrawBox(markBox[5].x, markBox[5].y, markBox[5].w, markBox[5].h, false);
Gui::DrawString(markBox[5].x + 5, markBox[5].y + 2, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, "", 0, 0, font);
}
/*
Mark Menu handle.
Here you can..
- Mark the selected app.
- Return to EntryInfo with `B`.
std::unique_ptr<StoreEntry> &entry: Reference to the current StoreEntry.
bool &showMark: Reference to showMark, so we know, if we should stay here or not.
*/
void StoreUtils::MarkHandle(std::unique_ptr<StoreEntry> &entry, bool &showMark) {
hidScanInput();
touchPosition t;
hidTouchRead(&t);
if (StoreUtils::meta && entry && StoreUtils::store) {
if (hidKeysDown() & KEY_TOUCH) {
/* Star. */
if (touching(t, markBox[0])) {
StoreUtils::meta->SetMarks(StoreUtils::store->GetUniStoreTitle(), entry->GetTitle(),
StoreUtils::meta->GetMarks(StoreUtils::store->GetUniStoreTitle(), entry->GetTitle()) ^ favoriteMarks::STAR);
entry->SetMark(StoreUtils::meta->GetMarks(StoreUtils::store->GetUniStoreTitle(), entry->GetTitle()));
/* Heart. */
} else if (touching(t, markBox[1])) {
StoreUtils::meta->SetMarks(StoreUtils::store->GetUniStoreTitle(), entry->GetTitle(),
StoreUtils::meta->GetMarks(StoreUtils::store->GetUniStoreTitle(), entry->GetTitle()) ^ favoriteMarks::HEART);
entry->SetMark(StoreUtils::meta->GetMarks(StoreUtils::store->GetUniStoreTitle(), entry->GetTitle()));
/* Diamond. */
} else if (touching(t, markBox[2])) {
StoreUtils::meta->SetMarks(StoreUtils::store->GetUniStoreTitle(), entry->GetTitle(),
StoreUtils::meta->GetMarks(StoreUtils::store->GetUniStoreTitle(), entry->GetTitle()) ^ favoriteMarks::DIAMOND);
entry->SetMark(StoreUtils::meta->GetMarks(StoreUtils::store->GetUniStoreTitle(), entry->GetTitle()));
/* Clubs. */
} else if (touching(t, markBox[3])) {
StoreUtils::meta->SetMarks(StoreUtils::store->GetUniStoreTitle(), entry->GetTitle(),
StoreUtils::meta->GetMarks(StoreUtils::store->GetUniStoreTitle(), entry->GetTitle()) ^ favoriteMarks::CLUBS);
entry->SetMark(StoreUtils::meta->GetMarks(StoreUtils::store->GetUniStoreTitle(), entry->GetTitle()));
/* Spade. */
} else if (touching(t, markBox[4])) {
StoreUtils::meta->SetMarks(StoreUtils::store->GetUniStoreTitle(), entry->GetTitle(),
StoreUtils::meta->GetMarks(StoreUtils::store->GetUniStoreTitle(), entry->GetTitle()) ^ favoriteMarks::SPADE);
entry->SetMark(StoreUtils::meta->GetMarks(StoreUtils::store->GetUniStoreTitle(), entry->GetTitle()));
}
}
}
if ((hidKeysDown() & KEY_B || hidKeysDown() & KEY_START) || (hidKeysDown() & KEY_TOUCH && touching(t, markBox[5]))) showMark = false; // Return back to screen.
}
+311
View File
@@ -0,0 +1,311 @@
/*
* 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.
*/
#include "common.hpp"
#include "queueSystem.hpp"
#include "scriptUtils.hpp"
#include "storeUtils.hpp"
#include "structs.hpp"
#include <curl/curl.h>
#include <math.h> // for std::min.
extern u32 extractSize, writeOffset;
extern u32 installSize, installOffset;
extern u32 copyOffset, copySize;
extern int filesExtracted, extractFilesCount;
extern curl_off_t downloadTotal;
extern curl_off_t downloadNow;
extern curl_off_t downloadSpeed;
extern CURL *CurlHandle;
bool ShowQueueProgress = true; // Queue Mode View.
int queueMenuIdx = 0; // Queue Menu Index.
#define QUEUE_ENTRIES 2 // 2 entries per screen or so.
extern bool touching(touchPosition touch, Structs::ButtonPos button);
static const std::vector<Structs::ButtonPos> QueueBoxes = {
{ 47, 36, 266, 90 },
{ 47, 139, 266, 90 },
{ 292, 37, 20, 20 }, // Cancel current Queue.
{ 292, 140, 20, 20 } // Remove next Queue.
};
extern std::deque<std::unique_ptr<Queue>> queueEntries;
void DrawStatus(QueueStatus s) {
if (!ShowQueueProgress) {
if (!queueEntries.empty()) {
Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, queueEntries[0]->name, 230, 0, font);
char prog[256];
snprintf(prog, sizeof(prog), Lang::get("QUEUE_PROGRESS").c_str(), queueEntries[0]->current, queueEntries[0]->total);
Gui::DrawString(QueueBoxes[0].x + 241, QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, prog, 80, 0, font, C2D_AlignRight);
Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 30, 182, 30, GFX::Themes[GFX::SelectedTheme].ProgressbarOut);
Gui::Draw_Rect(QueueBoxes[0].x + 60 + 1, QueueBoxes[0].y + 30 + 1, (int)(((float)queueEntries[0]->current / (float)queueEntries[0]->total) * 180.0f), 28, GFX::Themes[GFX::SelectedTheme].ProgressbarIn);
switch(s) {
case QueueStatus::Done:
case QueueStatus::Failed:
case QueueStatus::None:
break;
case QueueStatus::Copying:
Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("OP_COPYING"), 120, 0, font);
break;
case QueueStatus::Deleting:
Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("OP_DELETING"), 120, 0, font);
break;
case QueueStatus::Downloading:
Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("OP_DOWNLOADING"), 120, 0, font);
break;
case QueueStatus::Extracting:
Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("OP_EXTRACTING"), 120, 0, font);
break;
case QueueStatus::Installing:
Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("OP_INSTALLING"), 120, 0, font);
break;
case QueueStatus::Moving:
Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("OP_MOVING"), 120, 0, font);
break;
case QueueStatus::Request:
Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("OP_WAITING"), 120, 0, font);
break;
}
}
return;
}
char str[256], str2[256];
/* Progress. */
if (!queueEntries.empty()) {
char prog[256];
snprintf(prog, sizeof(prog), Lang::get("QUEUE_PROGRESS").c_str(), queueEntries[0]->current, queueEntries[0]->total);
Gui::DrawString((QueueBoxes[0].x + 241), QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, prog, 80, 0, font, C2D_AlignRight);
}
/* String Handle. */
switch(s) {
case QueueStatus::Done:
case QueueStatus::Failed:
case QueueStatus::None:
case QueueStatus::Moving:
break;
case QueueStatus::Copying:
snprintf(str, sizeof(str), Lang::get("COPYING").c_str(),
StringUtils::formatBytes(copyOffset).c_str(),
StringUtils::formatBytes(copySize).c_str(),
((float)copyOffset/(float)copySize) * 100.0f);
break;
case QueueStatus::Deleting:
snprintf(str, sizeof(str), Lang::get("DELETING").c_str());
break;
case QueueStatus::Downloading:
if (CurlHandle) curl_easy_getinfo(CurlHandle, CURLINFO_SPEED_DOWNLOAD_T, &downloadSpeed);
else downloadSpeed = 0;
if (downloadTotal < 1.0f) downloadTotal = 1.0f;
if (downloadTotal < downloadNow) downloadTotal = downloadNow;
snprintf(str, sizeof(str), Lang::get("DOWNLOADING").c_str(),
StringUtils::formatBytes(downloadNow).c_str(),
StringUtils::formatBytes(downloadTotal).c_str(),
((float)downloadNow/(float)downloadTotal) * 100.0f);
snprintf(str2, sizeof(str2), Lang::get("DOWNLOAD_SPEED").c_str(),
((downloadSpeed / 1024)));
break;
case QueueStatus::Extracting:
snprintf(str, sizeof(str), Lang::get("EXTRACTING").c_str(),
StringUtils::formatBytes(writeOffset).c_str(),
StringUtils::formatBytes(extractSize).c_str(),
((float)writeOffset/(float)extractSize) * 100.0f);
snprintf(str2, sizeof(str2), Lang::get("FILES").c_str(),
filesExtracted, extractFilesCount);
break;
case QueueStatus::Installing:
snprintf(str, sizeof(str), Lang::get("INSTALLING").c_str(),
StringUtils::formatBytes(installOffset).c_str(),
StringUtils::formatBytes(installSize).c_str(),
((float)installOffset/(float)installSize) * 100.0f);
break;
case QueueStatus::Request:
snprintf(str, sizeof(str), Lang::get("OP_WAITING").c_str());
snprintf(str2, sizeof(str2), Lang::get("ACTION_REQUIRED").c_str());
break;
}
/* Draw Handle. */
switch(s) {
case QueueStatus::Done:
case QueueStatus::Failed:
case QueueStatus::None:
break;
case QueueStatus::Copying:
Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, str, 230, 0, font);
Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 30, 182, 30, GFX::Themes[GFX::SelectedTheme].ProgressbarOut);
Gui::Draw_Rect(QueueBoxes[0].x + 60 + 1, QueueBoxes[0].y + 30 + 1, (int)(((float)copyOffset / (float)copySize) * 180.0f), 28, GFX::Themes[GFX::SelectedTheme].ProgressbarIn);
break;
case QueueStatus::Deleting:
Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, str, 230, 0, font);
break;
case QueueStatus::Downloading:
Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, str, 230, 0, font);
Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 30, 182, 30, GFX::Themes[GFX::SelectedTheme].ProgressbarOut);
Gui::Draw_Rect(QueueBoxes[0].x + 60 + 1, QueueBoxes[0].y + 30 + 1, (int)(((float)downloadNow / (float)downloadTotal) * 180.0f), 28, GFX::Themes[GFX::SelectedTheme].ProgressbarIn);
Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, str2, 120, 0, font);
break;
case QueueStatus::Extracting:
Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, str, 230, 0, font);
Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 30, 182, 30, GFX::Themes[GFX::SelectedTheme].ProgressbarOut);
Gui::Draw_Rect(QueueBoxes[0].x + 60 + 1, QueueBoxes[0].y + 30 + 1, (int)(((float)writeOffset / (float)extractSize) * 180.0f), 28, GFX::Themes[GFX::SelectedTheme].ProgressbarIn);
Gui::DrawString(QueueBoxes[0].x + 60, QueueBoxes[0].y + 68, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, str2, 120, 0, font);
break;
case QueueStatus::Installing:
Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, str, 230, 0, font);
Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 30, 182, 30, GFX::Themes[GFX::SelectedTheme].ProgressbarOut);
Gui::Draw_Rect(QueueBoxes[0].x + 60 + 1, QueueBoxes[0].y + 30 + 1, (int)(((float)installOffset / (float)installSize) * 180.0f), 28, GFX::Themes[GFX::SelectedTheme].ProgressbarIn);
break;
case QueueStatus::Moving:
Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("OP_MOVING"), 230, 0, font);
break;
case QueueStatus::Request:
Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, str, 230, 0, font);
Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 30, 182, 30, GFX::Themes[GFX::SelectedTheme].ProgressbarOut);
Gui::DrawStringCentered(QueueBoxes[0].x + 151 - 160, QueueBoxes[0].y + 32, 0.8f, GFX::Themes[GFX::SelectedTheme].TextColor, str2, 180, 0, font);
break;
}
}
void StoreUtils::DrawQueueMenu(const int queueIndex) {
Gui::Draw_Rect(40, 0, 280, 25, GFX::Themes[GFX::SelectedTheme].EntryBar);
Gui::Draw_Rect(40, 25, 280, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline);
Gui::DrawStringCentered(17, 2, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("QUEUE"), 273, 0, font);
if (!queueEntries.empty()) {
Gui::Draw_Rect(QueueBoxes[0].x, QueueBoxes[0].y, QueueBoxes[0].w, QueueBoxes[0].h, GFX::Themes[GFX::SelectedTheme].MarkSelected);
const C2D_Image tempImg = queueEntries[0]->icn;
const uint8_t offsetW = (48 - tempImg.subtex->width) / 2; // Center W.
const uint8_t offsetH = (48 - tempImg.subtex->height) / 2; // Center H.
C2D_DrawImageAt(tempImg, QueueBoxes[0].x + 5 + offsetW, QueueBoxes[0].y + 21 + offsetH, 0.5f);
DrawStatus(queueEntries[0]->status);
GFX::DrawSprite(sprites_cancel_idx, QueueBoxes[2].x, QueueBoxes[2].y); // Don't show until properly implemented.
/* The next Queue Entries being displayed below. */
if ((1 + queueMenuIdx) < (int)queueEntries.size()) {
Gui::Draw_Rect(QueueBoxes[1].x, QueueBoxes[1].y, QueueBoxes[1].w, QueueBoxes[1].h, GFX::Themes[GFX::SelectedTheme].MarkUnselected);
const C2D_Image tempImg2 = queueEntries[1 + queueMenuIdx]->icn;
const uint8_t offsetW2 = (48 - tempImg2.subtex->width) / 2; // Center W.
const uint8_t offsetH2 = (48 - tempImg2.subtex->height) / 2; // Center H.
C2D_DrawImageAt(tempImg2, QueueBoxes[1].x + 5 + offsetW2, QueueBoxes[1].y + 21 + offsetH2, 0.5f);
Gui::DrawString(QueueBoxes[1].x + 10, QueueBoxes[1].y + 5, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, queueEntries[1 + queueMenuIdx]->name, 230, 0, font);
Gui::DrawString(QueueBoxes[1].x + 60, QueueBoxes[1].y + 30, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("QUEUE_POSITION") + ": " + std::to_string(queueMenuIdx + 1), 0, 0, font);
/* Cancel. */
GFX::DrawSprite(sprites_cancel_idx, QueueBoxes[3].x, QueueBoxes[3].y);
}
}
}
void StoreUtils::QueueMenuHandle(int &queueIndex, int &storeMode) {
if (!queueEntries.empty()) {
if ((1 + queueMenuIdx) > (int)queueEntries.size() - 1) queueMenuIdx = std::max<int>((int)(queueEntries.size() - 1) - 1, 0); // Ensure this really doesn't go below 0.
}
if (hDown & KEY_TOUCH) {
/* Current Queue Cancel. */
if (QueueSystem::RequestNeeded == NO_REQUEST && touching(touch, QueueBoxes[2])) { // Needs to be above the 0 one, otherwise the callback won't be accepted.
QueueSystem::CancelCallback = true;
} else if (touching(touch, QueueBoxes[0])) {
if (QueueSystem::RequestNeeded != NO_REQUEST) { // -1 means no request.
switch(QueueSystem::RequestNeeded) {
case RMDIR_REQUEST: // Remove Directory message.
QueueSystem::RequestAnswer = Msg::promptMsg(QueueSystem::RequestMsg);
QueueSystem::Wait = false;
QueueSystem::Resume();
break;
case PROMPT_REQUEST: // Skip prompt message.
QueueSystem::RequestAnswer = ScriptUtils::prompt(QueueSystem::RequestMsg);
QueueSystem::Wait = false;
QueueSystem::Resume();
break;
}
} else {
ShowQueueProgress = !ShowQueueProgress; // In case no request expected, switch from progress to total progress mode etc.
}
/* Remove from Queue. */
} else if (touching(touch, QueueBoxes[3])) { // Remove Queue entries.
if (queueEntries.size() > 1) queueEntries.erase(queueEntries.begin() + 1 + queueMenuIdx);
}
}
if (hDown & KEY_DOWN) {
if (!queueEntries.empty()) {
if ((1 + queueMenuIdx) < (int)queueEntries.size() - 1) queueMenuIdx++;
}
}
if (hDown & KEY_UP) {
if (queueMenuIdx > 0) queueMenuIdx--;
}
if (hDown & KEY_B) storeMode = 0; // Go to EntryInfo.
}
+122
View File
@@ -0,0 +1,122 @@
/*
* 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.
*/
#include "animation.hpp"
#include "common.hpp"
#include "download.hpp"
#include "storeUtils.hpp"
void StoreUtils::DrawReleaseNotes(const int &scrollIndex, const std::unique_ptr<StoreEntry> &entry) {
if (entry && StoreUtils::store) {
Gui::ScreenDraw(Top);
Gui::Draw_Rect(0, 26, 400, 214, GFX::Themes[GFX::SelectedTheme].BGColor);
Gui::DrawString(5, 25 - scrollIndex, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, entry->GetReleaseNotes(), 390, 0, font, C2D_WordWrap);
Gui::Draw_Rect(0, 0, 400, 25, GFX::Themes[GFX::SelectedTheme].BarColor);
Gui::Draw_Rect(0, 25, 400, 1, GFX::Themes[GFX::SelectedTheme].BarOutline);
Gui::DrawStringCentered(0, 1, 0.7f, GFX::Themes[GFX::SelectedTheme].TextColor, entry->GetTitle(), 390, 0, font);
} else {
Gui::ScreenDraw(Top);
Gui::Draw_Rect(0, 0, 400, 25, GFX::Themes[GFX::SelectedTheme].BarColor);
Gui::Draw_Rect(0, 25, 400, 1, GFX::Themes[GFX::SelectedTheme].BarOutline);
Gui::Draw_Rect(0, 26, 400, 214, GFX::Themes[GFX::SelectedTheme].BGColor);
}
Animation::QueueEntryDone();
}
/*
As the name says: Release notes logic.
int &scrollIndex: The scroll index for the Release Notes text.
int &storeMode: The store mode to properly return back.
*/
void StoreUtils::ReleaseNotesLogic(int &scrollIndex, int &storeMode) {
if (hRepeat & KEY_DOWN) scrollIndex += Gui::GetStringHeight(0.5f, "", font);
if (hRepeat & KEY_UP) {
if (scrollIndex > 0) scrollIndex -= Gui::GetStringHeight(0.5f, "", font);
}
if (hDown & KEY_B) {
scrollIndex = 0;
storeMode = 0;
}
}
/*
I place it temporarely here for now.
Display Release changelog for Universal-Updater.
*/
void DisplayChangelog() {
if (config->changelog()) {
config->changelog(false);
bool confirmed = false;
const std::string notes = GetChangelog();
if (notes == "") return;
int scrollIndex = 0;
while(!confirmed) {
Gui::clearTextBufs();
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
C2D_TargetClear(Top, C2D_Color32(0, 0, 0, 0));
C2D_TargetClear(Bottom, C2D_Color32(0, 0, 0, 0));
Gui::ScreenDraw(Top);
Gui::Draw_Rect(0, 26, 400, 214, GFX::Themes[GFX::SelectedTheme].BGColor);
Gui::DrawString(5, 25 - scrollIndex, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, notes, 390, 0, font, C2D_WordWrap);
Gui::Draw_Rect(0, 0, 400, 25, GFX::Themes[GFX::SelectedTheme].BarColor);
Gui::Draw_Rect(0, 25, 400, 1, GFX::Themes[GFX::SelectedTheme].BarOutline);
Gui::DrawStringCentered(0, 1, 0.7f, GFX::Themes[GFX::SelectedTheme].TextColor, "Universal-Updater", 390, 0, font);
Gui::Draw_Rect(0, 215, 400, 25, GFX::Themes[GFX::SelectedTheme].BarColor);
Gui::Draw_Rect(0, 214, 400, 1, GFX::Themes[GFX::SelectedTheme].BarOutline);
Gui::DrawStringCentered(0, 217, 0.7f, GFX::Themes[GFX::SelectedTheme].TextColor, C_V, 390, 0, font);
GFX::DrawBottom();
Gui::Draw_Rect(0, 0, 320, 25, GFX::Themes[GFX::SelectedTheme].BarColor);
Gui::Draw_Rect(0, 25, 320, 1, GFX::Themes[GFX::SelectedTheme].BarOutline);
C3D_FrameEnd(0);
hidScanInput();
touchPosition t;
touchRead(&t);
u32 repeat = hidKeysDownRepeat();
u32 down = hidKeysDown();
/* Scroll Logic. */
if (repeat & KEY_DOWN) scrollIndex += Gui::GetStringHeight(0.5f, "", font);
if (repeat & KEY_UP) {
if (scrollIndex > 0) scrollIndex -= Gui::GetStringHeight(0.5f, "", font);
}
if ((down & KEY_A) || (down & KEY_B) || (down & KEY_START) || (down & KEY_TOUCH)) confirmed = true;
}
}
}
+157
View File
@@ -0,0 +1,157 @@
/*
* 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.
*/
#include "animation.hpp"
#include "common.hpp"
#include "storeUtils.hpp"
#include "structs.hpp"
extern bool touching(touchPosition touch, Structs::ButtonPos button);
extern bool checkWifiStatus();
/*
Draw the Screenshot menu.
const C2D_Image &img: The C2D_Image of the screenshot.
const int sIndex: The Screenshot index.
const bool sFetch: If fetching screenshots or not.
const int screenshotSize: The screenshot amount.
const std::string &name: The name of the screenshot.
const int zoom: The zoom level, zoom out, 1x scale, or zoom in.
const bool canDisplay: If can display, or not.
*/
void StoreUtils::DrawScreenshotMenu(const C2D_Image &img, const int sIndex, const bool sFetch, const int screenshotSize, const std::string &name, const int zoom, const bool canDisplay) {
Gui::ScreenDraw(Top);
Gui::Draw_Rect(0, 0, 400, 240, GFX::Themes[GFX::SelectedTheme].BGColor);
if (!canDisplay) {
Animation::QueueEntryDone();
GFX::DrawBottom();
if (screenshotSize > 0) { // if texture is nullptr AND screenshot size is larger than 0.
Gui::DrawStringCentered(0, 2, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("SCREENSHOT_COULD_NOT_LOAD"), 310);
} else {
Gui::DrawStringCentered(0, 2, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("NO_SCREENSHOTS_AVAILABLE"), 310);
}
return;
}
if (!sFetch) { // Only, if not fetch. This avoids a small flicker of the old screenshot on entries without screenshots.
if (screenshotSize > 0) {
float scale = 1.0f;
if (zoom == 0) {
scale = std::min(1.0f, std::min(400.0f / img.subtex->width, 240.0f / img.subtex->height));
if (img.tex) C2D_DrawImageAt(img, (400 - img.subtex->width * scale) / 2, (240 - img.subtex->height * scale) / 2, 0.5f, nullptr, scale, scale);
} else {
// Create new C2D_Image with smaller subtex
C2D_Image top = img;
if (img.subtex->height > 240)
top.subtex = new Tex3DS_SubTexture({img.subtex->width, (u16)(img.subtex->height / 2), img.subtex->left, img.subtex->top, img.subtex->right, 1.0f - (img.subtex->height / 2 / 512.0f)});
// If zoom == 2, then zoom in to fit the screen
if (zoom == 2)
scale = std::min(400.0f / top.subtex->width, 240.0f / top.subtex->height);
if (top.tex) C2D_DrawImageAt(top, (400 - top.subtex->width * scale) / 2, (240 - top.subtex->height * scale) / 2, 0.5f, nullptr, scale, scale);
// Only delete if new
if (top.subtex->height > 240)
delete top.subtex;
}
Animation::QueueEntryDone();
GFX::DrawBottom();
/* Bottom. */
if (zoom > 0 && img.subtex->height * scale > 240) {
C2D_Image bottom = img;
bottom.subtex = new Tex3DS_SubTexture({img.subtex->width, (u16)(img.subtex->height / 2), img.subtex->left, img.subtex->bottom + (img.subtex->height / 2 / 512.0f), img.subtex->right, img.subtex->bottom});
if (bottom.tex) C2D_DrawImageAt(bottom, (320 - bottom.subtex->width * scale) / 2, (240 - bottom.subtex->height * scale) / 2, 0.5f, nullptr, scale, scale);
delete bottom.subtex;
} else {
Gui::Draw_Rect(0, 215, 320, 25, GFX::Themes[GFX::SelectedTheme].BarColor);
Gui::Draw_Rect(0, 214, 320, 1, GFX::Themes[GFX::SelectedTheme].BarOutline);
Gui::DrawStringCentered(0, 220, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("SCREENSHOT_INSTRUCTIONS"), 310, 0, font);
char screenshots[0x100];
snprintf(screenshots, sizeof(screenshots), Lang::get("SCREENSHOT").c_str(), sIndex + 1, screenshotSize);
Gui::DrawStringCentered(0, 2, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, screenshots, 310, 0, font);
Gui::DrawStringCentered(0, 40, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, name, 310, 0, font);
}
} else {
Animation::QueueEntryDone();
GFX::DrawBottom();
Gui::DrawStringCentered(0, 2, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("NO_SCREENSHOTS_AVAILABLE"), 310);
}
}
}
/*
Screenshot Menu handle.
C2D_Image &img: The C2D_Image of the screenshot.
int &sIndex: The Screenshot index.
bool &sFetch: If fetching screenshots or not.
const int screenshotSize: The screenshot amount.
int &zoom: The zoom level, zoom out, 1x scale, or zoom in.
bool &canDisplay: If can display or not.
*/
void StoreUtils::ScreenshotMenu(C2D_Image &img, int &sIndex, bool &sFetch, int &storeMode, const int screenshotSize, int &zoom, bool &canDisplay) {
if (hDown & KEY_B) {
canDisplay = false;
zoom = 0;
sIndex = 0;
storeMode = 0; // Go back to EntryInfo.
}
if ((hDown & KEY_RIGHT) || (hDown & KEY_R)) {
if (checkWifiStatus()) {
if (sIndex < screenshotSize - 1) {
sIndex++;
sFetch = true;
}
}
}
if (hDown & KEY_DOWN && zoom > 0) zoom--;
if (hDown & KEY_UP && zoom < 2) zoom++;
if ((hDown & KEY_LEFT) || (hDown & KEY_L)) {
if (checkWifiStatus()) {
if (sIndex > 0) {
sIndex--;
sFetch = true;
}
}
}
}
+235
View File
@@ -0,0 +1,235 @@
/*
* 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.
*/
#include "common.hpp"
#include "keyboard.hpp"
#include "storeUtils.hpp"
#include "structs.hpp"
extern bool touching(touchPosition touch, Structs::ButtonPos button);
static const std::vector<Structs::ButtonPos> SearchMenu = {
{ 51, 41, 262, 30 }, // Search bar.
/* Includes. */
{ 85, 101, 50, 10 },
{ 85, 117, 50, 10 },
{ 167, 101, 50, 10 },
{ 167, 117, 50, 10 },
/* Filters. */
{ 82, 159, 30, 30 },
{ 117, 159, 30, 30 },
{ 152, 159, 30, 30 },
{ 187, 159, 30, 30 },
{ 222, 159, 30, 30 },
{ 257, 159, 30, 30 },
/* Send to Queue. */
{ 91, 200, 185, 25 },
/* AND / OR. */
{ 222, 139, 30, 13 },
{ 257, 139, 30, 13 }
};
/*
Draw the Search + Filter Menu.
const std::vector<bool> &searchIncludes: Const Reference to the searchIncludes.
const std::string &searchResult: Const Reference to the searchResult.
int marks: The filter mark flags.
bool updateFilter: The update filter.
isAND: isAND for the AND / OR mode.
*/
void StoreUtils::DrawSearchMenu(const std::vector<bool> &searchIncludes, const std::string &searchResult, int marks, bool updateFilter, bool isAND) {
Gui::Draw_Rect(40, 0, 280, 25, GFX::Themes[GFX::SelectedTheme].EntryBar);
Gui::Draw_Rect(40, 25, 280, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline);
Gui::DrawStringCentered(21, 2, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("SEARCH_FILTERS"), 269, 0, font);
Gui::Draw_Rect(50, 40, 264, SearchMenu[0].h + 2, GFX::Themes[GFX::SelectedTheme].SearchbarOutline);
Gui::Draw_Rect(SearchMenu[0].x, SearchMenu[0].y, SearchMenu[0].w, SearchMenu[0].h, GFX::Themes[GFX::SelectedTheme].SearchBar);
Gui::DrawStringCentered(24, 46, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, searchResult, 265, 0, font);
/* Checkboxes. */
for (int i = 0; i < 4; i++) {
GFX::DrawCheckbox(SearchMenu[i + 1].x, SearchMenu[i + 1].y, searchIncludes[i]);
}
Gui::DrawString(84, 81, 0.5, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("INCLUDE_IN_RESULTS"), 265, 0, font);
Gui::DrawString(SearchMenu[1].x + 18, SearchMenu[1].y + 1, 0.4, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("TITLE"), 90, 0, font);
Gui::DrawString(SearchMenu[2].x + 18, SearchMenu[2].y + 1, 0.4, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("AUTHOR"), 90, 0, font);
Gui::DrawString(SearchMenu[3].x + 18, SearchMenu[3].y + 1, 0.4, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("CATEGORY"), 90, 0, font);
Gui::DrawString(SearchMenu[4].x + 18, SearchMenu[4].y + 1, 0.4, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("CONSOLE"), 90, 0, font);
/* Filters. */
Gui::DrawString(84, SearchMenu[5].y - 20, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("FILTER_TO"), 265, 0, font);
Gui::Draw_Rect(SearchMenu[5].x, SearchMenu[5].y, SearchMenu[5].w, SearchMenu[5].h, (marks & favoriteMarks::STAR ?
GFX::Themes[GFX::SelectedTheme].SideBarUnselected : GFX::Themes[GFX::SelectedTheme].BoxInside));
Gui::Draw_Rect(SearchMenu[6].x, SearchMenu[6].y, SearchMenu[6].w, SearchMenu[6].h, (marks & favoriteMarks::HEART ?
GFX::Themes[GFX::SelectedTheme].SideBarUnselected : GFX::Themes[GFX::SelectedTheme].BoxInside));
Gui::Draw_Rect(SearchMenu[7].x, SearchMenu[7].y, SearchMenu[7].w, SearchMenu[7].h, (marks & favoriteMarks::DIAMOND ?
GFX::Themes[GFX::SelectedTheme].SideBarUnselected : GFX::Themes[GFX::SelectedTheme].BoxInside));
Gui::Draw_Rect(SearchMenu[8].x, SearchMenu[8].y, SearchMenu[8].w, SearchMenu[8].h, (marks & favoriteMarks::CLUBS ?
GFX::Themes[GFX::SelectedTheme].SideBarUnselected : GFX::Themes[GFX::SelectedTheme].BoxInside));
Gui::Draw_Rect(SearchMenu[9].x, SearchMenu[9].y, SearchMenu[9].w, SearchMenu[9].h, (marks & favoriteMarks::SPADE ?
GFX::Themes[GFX::SelectedTheme].SideBarUnselected : GFX::Themes[GFX::SelectedTheme].BoxInside));
Gui::Draw_Rect(SearchMenu[10].x, SearchMenu[10].y, SearchMenu[10].w, SearchMenu[10].h, (updateFilter ?
GFX::Themes[GFX::SelectedTheme].SideBarUnselected : GFX::Themes[GFX::SelectedTheme].BoxInside));
Gui::DrawString(SearchMenu[5].x + 9, SearchMenu[5].y + 7, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, "", 0, 0, font);
Gui::DrawString(SearchMenu[6].x + 9, SearchMenu[6].y + 7, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, "", 0, 0, font);
Gui::DrawString(SearchMenu[7].x + 9, SearchMenu[7].y + 7, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, "", 0, 0, font);
Gui::DrawString(SearchMenu[8].x + 9, SearchMenu[8].y + 7, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, "", 0, 0, font);
Gui::DrawString(SearchMenu[9].x + 9, SearchMenu[9].y + 7, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, "", 0, 0, font);
GFX::DrawSprite(sprites_update_filter_idx, SearchMenu[10].x + 8, SearchMenu[10].y + 8);
Gui::Draw_Rect(SearchMenu[11].x, SearchMenu[11].y, SearchMenu[11].w, SearchMenu[11].h, GFX::Themes[GFX::SelectedTheme].MarkUnselected);
Gui::DrawStringCentered(23, SearchMenu[11].y + 6, 0.45f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("SELECTION_QUEUE"), 280, 0, font);
/* AND / OR. */
Gui::Draw_Rect(SearchMenu[12].x, SearchMenu[12].y, SearchMenu[12].w, SearchMenu[12].h, (isAND ? GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected));
Gui::DrawString(SearchMenu[12].x + 4, SearchMenu[12].y, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, "AND", 0, 0, font);
Gui::Draw_Rect(SearchMenu[13].x, SearchMenu[13].y, SearchMenu[13].w, SearchMenu[13].h, (!isAND ? GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected));
Gui::DrawString(SearchMenu[13].x + 8, SearchMenu[13].y, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, "OR", 0, 0, font);
}
/*
Search + Filter Handle.
Here you can..
- Filter your apps for the marks.
- Search the UniStore.
- Include stuff into the search.
std::vector<bool> &searchIncludes: Reference to the searchIncludes.
std::string &searchResult: Reference to the searchResult.
int &marks: Reference to the mark flags.
bool &updateFilter: Reference to the update filter.
bool &isAND: Reference to isAND boolean for AND / OR mode.
*/
void StoreUtils::SearchHandle(std::vector<bool> &searchIncludes, std::string &searchResult, int &marks, bool &updateFilter, bool ascending, SortType sorttype, bool &isAND) {
/* Checkboxes. */
if (hDown & KEY_TOUCH) {
bool didTouch = false;
/* Includes. */
for (int i = 0; i < 4; i++) {
if (touching(touch, SearchMenu[i + 1])) {
searchIncludes[i] = !searchIncludes[i];
didTouch = true;
break;
}
}
/* Search bar. */
if (!didTouch) {
if (touching(touch, SearchMenu[0])) {
if (StoreUtils::store) {
searchResult = Input::setkbdString(20, Lang::get("ENTER_SEARCH"), {});
didTouch = true;
} else {
searchResult = Input::setkbdString(20, Lang::get("ENTER_SEARCH"), {});
didTouch = true;
}
}
}
/* Filters. */
if (!didTouch) {
if (touching(touch, SearchMenu[5])) {
marks = marks ^ favoriteMarks::STAR;
didTouch = true;
} else if (touching(touch, SearchMenu[6])) {
marks = marks ^ favoriteMarks::HEART;
didTouch = true;
} else if (touching(touch, SearchMenu[7])) {
marks = marks ^ favoriteMarks::DIAMOND;
didTouch = true;
} else if (touching(touch, SearchMenu[8])) {
marks = marks ^ favoriteMarks::CLUBS;
didTouch = true;
} else if (touching(touch, SearchMenu[9])) {
marks = marks ^ favoriteMarks::SPADE;
didTouch = true;
} else if (touching(touch, SearchMenu[10])) {
updateFilter = !updateFilter;
didTouch = true;
} else if (touching(touch, SearchMenu[11])) {
StoreUtils::AddAllToQueue();
} else if (touching(touch, SearchMenu[12])) {
isAND = true;
didTouch = true;
} else if (touching(touch, SearchMenu[13])) {
isAND = false;
didTouch = true;
}
}
if (didTouch) {
if (StoreUtils::store && StoreUtils::store->GetValid()) { // Only search, when valid.
StoreUtils::ResetAll();
StoreUtils::search(searchResult, searchIncludes[0], searchIncludes[1], searchIncludes[2], searchIncludes[3], marks, updateFilter, isAND);
StoreUtils::store->SetScreenIndx(0);
StoreUtils::store->SetEntry(0);
StoreUtils::store->SetBox(0);
StoreUtils::SortEntries(ascending, sorttype);
}
}
}
/* Reset all. */
if (hDown & KEY_X) {
marks = 0;
updateFilter = false;
for(uint i = 0; i < searchIncludes.size(); i++) searchIncludes[i] = false;
searchResult = "";
if (StoreUtils::store && StoreUtils::store->GetValid()) {
StoreUtils::ResetAll();
StoreUtils::SortEntries(ascending, sorttype);
}
}
}
+667
View File
@@ -0,0 +1,667 @@
/*
* 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.
*/
#include "common.hpp"
#include "init.hpp"
#include "overlay.hpp"
#include "scriptUtils.hpp"
#include "storeUtils.hpp"
#include <unistd.h>
extern bool exiting, QueueRuns;
extern bool touching(touchPosition touch, Structs::ButtonPos button);
static const std::vector<Structs::ButtonPos> mainButtons = {
{ 45, 32, 271, 22 },
{ 45, 62, 271, 22 },
{ 45, 92, 271, 22 },
{ 45, 122, 271, 22 },
{ 45, 152, 271, 22 },
{ 45, 182, 271, 22 },
{ 45, 212, 271, 22 }
};
static const std::vector<Structs::ButtonPos> langButtons = {
{ 45, 32, 271, 22 },
{ 45, 62, 271, 22 },
{ 45, 92, 271, 22 },
{ 45, 122, 271, 22 },
{ 45, 152, 271, 22 },
{ 45, 182, 271, 22 },
{ 45, 220, 16, 16 } // Add Font.
};
static const std::vector<Structs::ButtonPos> toggleAbles = {
{ 288, 44, 24, 24 },
{ 288, 120, 24, 24 }
};
static const Structs::ButtonPos back = { 45, 0, 24, 24 }; // Back arrow for directory.
static const Structs::ButtonPos Themes = { 40, 220, 280, 24 }; // Themes.
static const std::vector<std::string> mainStrings = { "LANGUAGE", "SELECT_UNISTORE", "AUTO_UPDATE_SETTINGS_BTN", "GUI_SETTINGS_BTN", "DIRECTORY_SETTINGS_BTN", "CREDITS", "EXIT_APP" };
static const std::vector<std::string> dirStrings = { "CHANGE_3DSX_PATH", "CHANGE_NDS_PATH", "CHANGE_ARCHIVE_PATH", "CHANGE_SHORTCUT_PATH", "CHANGE_FIRM_PATH" };
/* Note: Украïнська is spelled using a latin i with dieresis to work in the system font */
//static const std::vector<std::string> languages = { "Bruh", "Dansk", "Deutsch", "English", "Español", "Français", "Italiano", "Lietuvių", "Magyar", "Polski", "Português", "Português (Brasil)", "Русский", "Украïнська", "日本語" };
//static const std::string langsTemp[] = { "br", "da", "de", "en", "es", "fr", "it", "lt", "hu", "pl", "pt", "pt-BR", "ru", "uk", "jp"};
static const std::vector<std::string> languages = { "Bruh", "Deutsch", "English", "Español", "Français", "Italiano", "Magyar", "Polski", "Português (Brasil)", "Русский", "Украïнська", "日本語" };
static const std::string langsTemp[] = { "br", "de", "en", "es", "fr", "it", "hu", "pl", "pt-BR", "ru", "uk", "jp"};
static const std::vector<std::string> ThemeNames = { "THEME_DEFAULT" };
/*
Main Settings.
int selection: The Settings Selection.
*/
static void DrawSettingsMain(int selection) {
Gui::Draw_Rect(40, 0, 280, 25, GFX::Themes[GFX::SelectedTheme].EntryBar);
Gui::Draw_Rect(40, 25, 280, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline);
Gui::DrawStringCentered(20, 2, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("SETTINGS"), 280, 0, font);
for (int i = 0; i < 7; i++) {
if (i == selection) Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, GFX::Themes[GFX::SelectedTheme].MarkSelected);
Gui::DrawStringCentered(20, mainButtons[i].y + 4, 0.45f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get(mainStrings[i]), 255, 0, font);
}
}
/*
Draw the Language Selection.
int selection: The Language Selection.
int sPos: The Screen Position.
*/
static void DrawLanguageSettings(int selection, int sPos) {
Gui::Draw_Rect(40, 0, 280, 25, GFX::Themes[GFX::SelectedTheme].EntryBar);
Gui::Draw_Rect(40, 25, 280, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline);
GFX::DrawSprite(sprites_arrow_idx, back.x, back.y);
GFX::DrawSprite(sprites_add_font_idx, langButtons[6].x, langButtons[6].y);
Gui::DrawStringCentered(20, 2, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("SELECT_LANG"), 248, 0, font);
for(int i = 0; i < 6 && i < (int)languages.size(); i++) {
if (sPos + i == selection) Gui::Draw_Rect(langButtons[i].x, langButtons[i].y, langButtons[i].w, langButtons[i].h, GFX::Themes[GFX::SelectedTheme].MarkSelected);
Gui::DrawStringCentered(20, langButtons[i].y + 4, 0.45f, GFX::Themes[GFX::SelectedTheme].TextColor, languages[sPos + i], 280, 0, font);
}
}
/*
Directory Change Draw.
int selection: The Settings Selection.
*/
static void DrawSettingsDir(int selection) {
Gui::Draw_Rect(40, 0, 280, 25, GFX::Themes[GFX::SelectedTheme].EntryBar);
Gui::Draw_Rect(40, 25, 280, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline);
GFX::DrawSprite(sprites_arrow_idx, back.x, back.y);
Gui::DrawStringCentered(20, 2, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("DIRECTORY_SETTINGS"), 248, 0, font);
for (int i = 0; i < 5; i++) {
if (i == selection) Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, GFX::Themes[GFX::SelectedTheme].MarkSelected);
Gui::DrawStringCentered(20, mainButtons[i].y + 4, 0.45f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get(dirStrings[i]), 255, 0, font);
}
}
/*
Draw Auto-Update Settings page.
*/
static void DrawAutoUpdate(int selection) {
Gui::Draw_Rect(40, 0, 280, 25, GFX::Themes[GFX::SelectedTheme].EntryBar);
Gui::Draw_Rect(40, 25, 280, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline);
GFX::DrawSprite(sprites_arrow_idx, back.x, back.y);
Gui::DrawStringCentered(20, 2, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("AUTO_UPDATE_SETTINGS"), 240, 0, font);
/* Toggle Boxes. */
Gui::Draw_Rect(40, 44, 280, 24, (selection == 0 ? GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected));
Gui::DrawString(47, 48, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("AUTO_UPDATE_UNISTORE"), 210, 0, font);
GFX::DrawToggle(toggleAbles[0].x, toggleAbles[0].y, config->autoupdate());
Gui::DrawString(47, 75, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("AUTO_UPDATE_UNISTORE_DESC"), 265, 0, font, C2D_WordWrap);
Gui::Draw_Rect(40, 120, 280, 24, (selection == 1 ? GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected));
Gui::DrawString(47, 124, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("AUTO_UPDATE_UU"), 210, 0, font);
GFX::DrawToggle(toggleAbles[1].x, toggleAbles[1].y, config->updatecheck());
Gui::DrawString(47, 151, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("AUTO_UPDATE_UU_DESC"), 265, 0, font, C2D_WordWrap);
}
/*
Draw the GUI Settings.
int selection: The Settings Selection.
*/
static void DrawGUISettings(int selection) {
Gui::Draw_Rect(40, 0, 280, 25, GFX::Themes[GFX::SelectedTheme].EntryBar);
Gui::Draw_Rect(40, 25, 280, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline);
GFX::DrawSprite(sprites_arrow_idx, back.x, back.y);
Gui::DrawStringCentered(20, 2, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("GUI_SETTINGS"), 248, 0, font);
Gui::Draw_Rect(40, 44, 280, 24, (selection == 0 ? GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected));
Gui::DrawString(47, 48, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("UNISTORE_BG"), 210, 0, font);
GFX::DrawToggle(toggleAbles[0].x, toggleAbles[0].y, config->usebg());
Gui::DrawString(47, 75, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("UNISTORE_BG_DESC"), 265, 0, font, C2D_WordWrap);
Gui::Draw_Rect(40, 120, 280, 24, (selection == 1 ? GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected));
Gui::DrawString(47, 124, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("CUSTOM_FONT"), 210, 0, font);
GFX::DrawToggle(toggleAbles[1].x, toggleAbles[1].y, config->customfont());
Gui::DrawString(47, 151, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("CUSTOM_FONT_DESC"), 265, 0, font, C2D_WordWrap);
Gui::Draw_Rect(40, 196, 280, 24, (selection == 2 ? GFX::Themes[GFX::SelectedTheme].MarkSelected : GFX::Themes[GFX::SelectedTheme].MarkUnselected));
Gui::DrawString(47, 200, 0.5f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("ACTIVE_THEME") + ": " + Lang::get(ThemeNames[GFX::SelectedTheme]), 210, 0, font);
}
/*
Settings Main Handle.
Here you can..
- Change the Language.
- Access the UniStore Manage Handle.
- Enable UniStore auto update on boot.
- Show the Credits.
- Exit Universal-Updater.
int &page: Reference to the page.
bool &dspSettings: Reference to the display Settings.
int &storeMode: Reference to the store Mode.
int &selection: Reference to the Selection.
*/
static void SettingsHandleMain(int &page, bool &dspSettings, int &storeMode, int &selection) {
if (hDown & KEY_B) {
selection = 0;
storeMode = 0;
}
if (hRepeat & KEY_DOWN) {
if (selection < 6) selection++;
else selection = 0;
}
if (hRepeat & KEY_UP) {
if (selection > 0) selection--;
else selection = mainStrings.size() - 1;
}
if (hRepeat & KEY_RIGHT) {
if (selection + 8 < (int)mainStrings.size()) selection += 8;
else selection = mainStrings.size() - 1;
}
if (hRepeat & KEY_LEFT) {
if (selection - 8 > 0) selection -= 8;
else selection = 0;
}
if (hDown & KEY_TOUCH) {
if (touching(touch, mainButtons[0])) {
selection = 0;
page = 4;
} else if (touching(touch, mainButtons[1])) {
if (QueueRuns) {
if (Msg::promptMsg(Lang::get("FEATURE_SIDE_EFFECTS"))) Overlays::SelectStore();
} else {
Overlays::SelectStore();
}
} else if (touching(touch, mainButtons[2])) {
selection = 0;
page = 2;
} else if (touching(touch, mainButtons[3])) {
selection = 0;
page = 3;
} else if (touching(touch, mainButtons[4])) {
selection = 0;
page = 1;
} else if (touching(touch, mainButtons[5])) {
Overlays::ShowCredits();
} else if (touching(touch, mainButtons[6])) {
if (QueueRuns) exiting = Msg::promptMsg(Lang::get("FEATURE_SIDE_EFFECTS"));
else exiting = true;
}
}
if (hDown & KEY_A) {
switch(selection) {
case 0:
selection = 0;
page = 4;
break;
case 1:
if (QueueRuns) {
if (Msg::promptMsg(Lang::get("FEATURE_SIDE_EFFECTS"))) Overlays::SelectStore();
} else {
Overlays::SelectStore();
}
break;
case 2:
selection = 0;
page = 2;
break;
case 3:
selection = 0;
page = 3;
break;
case 4:
selection = 0;
page = 1;
break;
case 5:
Overlays::ShowCredits();
break;
case 6:
if (QueueRuns) exiting = Msg::promptMsg(Lang::get("FEATURE_SIDE_EFFECTS"));
else exiting = true;
break;
}
}
}
/*
Directory Handle.
Here you can..
- Change the Directory of...
- 3DSX, NDS & Archives.
int &page: Reference to the page.
int &selection: Reference to the Selection.
*/
static void SettingsHandleDir(int &page, int &selection) {
if (hDown & KEY_B) {
page = 0;
selection = 4;
}
if (hRepeat & KEY_DOWN) {
if (selection < 4) selection++;
else selection = 0;
}
if (hRepeat & KEY_UP) {
if (selection > 0) selection--;
else selection = dirStrings.size() - 1;
}
if (hRepeat & KEY_RIGHT) {
if (selection + 8 < (int)dirStrings.size() - 1) selection += 8;
else selection = dirStrings.size() - 1;
}
if (hRepeat & KEY_LEFT) {
if (selection - 8 > 0) selection -= 8;
else selection = 0;
}
if (hDown & KEY_TOUCH) {
if (touching(touch, back)) {
page = 0;
selection = 4;
} else if (touching(touch, mainButtons[0])) {
const std::string path = Overlays::SelectDir(config->_3dsxPath(), Lang::get("SELECT_DIR"));
if (path != "") config->_3dsxPath(path);
} else if (touching(touch, mainButtons[1])) {
const std::string path = Overlays::SelectDir(config->ndsPath(), Lang::get("SELECT_DIR"));
if (path != "") config->ndsPath(path);
} else if (touching(touch, mainButtons[2])) {
const std::string path = Overlays::SelectDir(config->archPath(), Lang::get("SELECT_DIR"));
if (path != "") config->archPath(path);
} else if (touching(touch, mainButtons[3])) {
const std::string path = Overlays::SelectDir(config->shortcut(), Lang::get("SELECT_DIR"));
if (path != "") config->shortcut(path);
} else if (touching(touch, mainButtons[4])) {
const std::string path = Overlays::SelectDir(config->firmPath(), Lang::get("SELECT_DIR"));
if (path != "") config->firmPath(path);
}
}
if (hDown & KEY_A) {
std::string path = "";
switch(selection) {
case 0:
path = Overlays::SelectDir(config->_3dsxPath(), Lang::get("SELECT_DIR"));
if (path != "") config->_3dsxPath(path);
break;
case 1:
path = Overlays::SelectDir(config->ndsPath(), Lang::get("SELECT_DIR"));
if (path != "") config->ndsPath(path);
break;
case 2:
path = Overlays::SelectDir(config->archPath(), Lang::get("SELECT_DIR"));
if (path != "") config->archPath(path);
break;
case 3:
path = Overlays::SelectDir(config->shortcut(), Lang::get("SELECT_DIR"));
if (path != "") config->shortcut(path);
break;
case 4:
path = Overlays::SelectDir(config->firmPath(), Lang::get("SELECT_DIR"));
if (path != "") config->firmPath(path);
break;
}
}
}
/*
Logic of the Auto-Update Settings.
Here you can..
- Enable / Disable Automatically updating the UniStore on boot.
- Enable / Disable Automatically check for Universal-Updater updates on boot.
int &page: Reference to the page.
int &selection: Reference to the Selection.
*/
static void AutoUpdateLogic(int &page, int &selection) {
if (hDown & KEY_B) {
page = 0;
selection = 2;
}
if (hRepeat & KEY_DOWN) {
if (selection < 1) selection++;
}
if (hRepeat & KEY_UP) {
if (selection > 0) selection--;
}
if (hDown & KEY_TOUCH) {
if (touching(touch, back)) {
page = 0;
selection = 2;
} else if (touching(touch, toggleAbles[0])) {
config->autoupdate(!config->autoupdate());
} else if (touching(touch, toggleAbles[1])) {
config->updatecheck(!config->updatecheck());
}
}
if (hDown & KEY_A) {
switch(selection) {
case 0:
config->autoupdate(!config->autoupdate());
break;
case 1:
config->updatecheck(!config->updatecheck());
break;
}
}
}
/*
Logic of the GUI Settings.
Here you can..
- Enable / Disable using the SpriteSheet Background Image, if exist.
int &page: Reference to the page.
int &selection: Reference to the Selection.
*/
static void GUISettingsLogic(int &page, int &selection) {
if (hDown & KEY_B) {
page = 0;
selection = 3;
}
if (hRepeat & KEY_DOWN) {
if (selection < 2) selection++;
}
if (hRepeat & KEY_UP) {
if (selection > 0) selection--;
}
if (hDown & KEY_TOUCH) {
if (touching(touch, back)) {
page = 0;
selection = 3;
} else if (touching(touch, toggleAbles[0])) {
config->usebg(!config->usebg());
} else if (touching(touch, toggleAbles[1])) {
config->customfont(!config->customfont());
(config->customfont() ? Init::LoadFont() : Init::UnloadFont());
} else if (touching(touch, Themes)) {
if (GFX::SelectedTheme < (_THEME_AMOUNT - 1)) GFX::SelectedTheme++;
else GFX::SelectedTheme = 0;
config->theme(GFX::SelectedTheme);
}
}
if (hDown & KEY_A) {
switch(selection) {
case 0:
config->usebg(!config->usebg());
break;
case 1:
config->customfont(!config->customfont());
(config->customfont() ? Init::LoadFont() : Init::UnloadFont());
break;
case 2:
if (GFX::SelectedTheme < (_THEME_AMOUNT - 1)) GFX::SelectedTheme++;
else GFX::SelectedTheme = 0;
config->theme(GFX::SelectedTheme);
break;
}
}
}
/*
Logic of the Language Settings.
Here you can..
- Select the language, which should be used with the app.
int &page: Reference to the page.
int &selection: Reference to the Selection.
int &sPos: Reference to the ScreenPos variable.
*/
static void LanguageLogic(int &page, int &selection, int &sPos) {
if (hRepeat & KEY_DOWN) {
if (selection < (int)languages.size() - 1) selection++;
else selection = 0;
}
if (hRepeat & KEY_UP) {
if (selection > 0) selection--;
else selection = languages.size() - 1;
}
if (hRepeat & KEY_RIGHT) {
if (selection + 6 < (int)languages.size() - 1) selection += 6;
else selection = languages.size() - 1;
}
if (hRepeat & KEY_LEFT) {
if (selection - 6 > 0) selection -= 6;
else selection = 0;
}
if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, back))) {
selection = 0;
sPos = 0;
page = 0;
}
if (hDown & KEY_A) {
const std::string l = langsTemp[selection];
/* Check if is "uk". */
if (l == "uk") {
if (access("sdmc:/3ds/Universal-Updater/font.bcfnt", F_OK) != 0) {
ScriptUtils::downloadFile("https://github.com/Universal-Team/extras/raw/master/files/universal-updater.bcfnt", "sdmc:/3ds/Universal-Updater/font.bcfnt", Lang::get("DOWNLOADING_COMPATIBLE_FONT"));
}
config->customfont(true);
Init::LoadFont();
}
config->language(l);
Lang::load(config->language());
selection = 0;
sPos = 0;
page = 0;
}
if (hDown & KEY_TOUCH) {
for (int i = 0; i < 6; i++) {
if (touching(touch, mainButtons[i])) {
if (i + sPos < (int)languages.size()) {
const std::string l = langsTemp[i + sPos];
/* Check if is "uk". */
if (l == "uk") {
if (access("sdmc:/3ds/Universal-Updater/font.bcfnt", F_OK) != 0) {
ScriptUtils::downloadFile("https://github.com/Universal-Team/extras/raw/master/files/universal-updater.bcfnt", "sdmc:/3ds/Universal-Updater/font.bcfnt", Lang::get("DOWNLOADING_COMPATIBLE_FONT"));
}
config->customfont(true);
Init::LoadFont();
}
config->language(l);
Lang::load(config->language());
selection = 0;
sPos = 0;
page = 0;
}
}
}
}
if (hDown & KEY_TOUCH) {
if (touching(touch, langButtons[6])) {
/* Download Font. */
ScriptUtils::downloadFile("https://github.com/Universal-Team/extras/raw/master/files/universal-updater.bcfnt", "sdmc:/3ds/Universal-Updater/font.bcfnt", Lang::get("DOWNLOADING_COMPATIBLE_FONT"), true);
config->customfont(true);
Init::LoadFont();
}
}
if (selection < sPos) sPos = selection;
else if (selection > sPos + 6 - 1) sPos = selection - 6 + 1;
}
/*
Draw the Settings.
int page: The page.
int selection: The selection.
*/
void StoreUtils::DrawSettings(int page, int selection, int sPos) {
switch(page) {
case 0:
DrawSettingsMain(selection);
break;
case 1:
DrawSettingsDir(selection);
break;
case 2:
DrawAutoUpdate(selection);
break;
case 3:
DrawGUISettings(selection);
break;
case 4:
DrawLanguageSettings(selection, sPos);
break;
}
}
/*
Settings Handle.
int &page: Reference to the page.
bool &dspSettings: Reference to the display Settings.
int &storeMode: Reference to the store Mode.
int &selection: Reference to the Selection.
int &sPos: Reference to screen position.
*/
void StoreUtils::SettingsHandle(int &page, bool &dspSettings, int &storeMode, int &selection, int &sPos) {
switch(page) {
case 0:
SettingsHandleMain(page, dspSettings, storeMode, selection);
break;
case 1:
SettingsHandleDir(page, selection);
break;
case 2:
AutoUpdateLogic(page, selection);
break;
case 3:
GUISettingsLogic(page, selection);
break;
case 4:
LanguageLogic(page, selection, sPos);
break;
}
}
+106
View File
@@ -0,0 +1,106 @@
/*
* 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.
*/
#include "animation.hpp"
#include "common.hpp"
#include "storeUtils.hpp"
#include "structs.hpp"
extern bool touching(touchPosition touch, Structs::ButtonPos button);
static const std::vector<Structs::ButtonPos> sidePos = {
{ 0, 0, 40, 40 },
{ 0, 40, 40, 40 },
{ 0, 80, 40, 40 },
{ 0, 120, 40, 40 },
{ 0, 160, 40, 40 },
{ 0, 200, 40, 40 }
};
/*
Draw the Side Menu part.
int currentMenu: The current store Mode / Menu.
*/
void StoreUtils::DrawSideMenu(int currentMenu) {
for (int i = 0; i < 6; i++) {
if (i == currentMenu) {
Gui::Draw_Rect(sidePos[i].x, sidePos[i].y, sidePos[i].w, sidePos[i].h, GFX::Themes[GFX::SelectedTheme].SideBarSelected);
} else {
Gui::Draw_Rect(sidePos[i].x, sidePos[i].y, sidePos[i].w, sidePos[i].h, GFX::Themes[GFX::SelectedTheme].SideBarUnselected);
}
}
GFX::DrawSprite(sprites_info_idx, sidePos[0].x, sidePos[0].y);
GFX::DrawSprite(sprites_download_idx, sidePos[1].x, sidePos[1].y);
Animation::DrawQueue(sidePos[2].x, sidePos[2].y);
GFX::DrawSprite(sprites_search_idx, sidePos[3].x, sidePos[3].y);
GFX::DrawSprite(sprites_sort_idx, sidePos[4].x, sidePos[4].y);
GFX::DrawSprite(sprites_settings_idx, sidePos[5].x, sidePos[5].y);
Gui::Draw_Rect(40, 0, 1, 240, GFX::Themes[GFX::SelectedTheme].BarOutline);
}
/*
Side Menu Handle.
Here you can..
- Switch between the Menus through the sidebar.
int &currentMenu: Reference to the store Mode / Menu.
bool &fetch: Reference of the download fetch variable.. so we know, if we need to fetch the download entries.
int &lastMenu: Reference to the last menu.
*/
void StoreUtils::SideMenuHandle(int &currentMenu, bool &fetch, int &lastMenu) {
Animation::QueueAnimHandle();
if (hDown & KEY_TOUCH) {
for (int i = 0; i < 6; i++) {
if (touching(touch, sidePos[i])) {
lastMenu = currentMenu;
if (i == 1) fetch = true; // Fetch download list, if 1.
currentMenu = i;
break;
}
}
}
if (hRepeat & KEY_R) {
if (currentMenu < 5) {
lastMenu = currentMenu;
if (currentMenu + 1 == 1) fetch = true; // Fetch download list, if 1.
currentMenu++;
}
}
if (hRepeat & KEY_L) {
if (currentMenu > 0) {
lastMenu = currentMenu;
if (currentMenu - 1 == 1) fetch = true; // Fetch download list, if 1.
currentMenu--;
}
}
}
+161
View File
@@ -0,0 +1,161 @@
/*
* 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.
*/
#include "common.hpp"
#include "keyboard.hpp"
#include "storeUtils.hpp"
#include "structs.hpp"
extern bool touching(touchPosition touch, Structs::ButtonPos button);
static const std::vector<Structs::ButtonPos> buttons = {
{ 71, 60, 104, 16 },
{ 71, 80, 104, 16 },
{ 71, 100, 104, 16 },
{ 201, 60, 104, 16 },
{ 201, 80, 104, 16 },
{ 71, 170, 104, 16 },
{ 71, 190, 104, 16 }
};
static void DrawCheck(int pos, bool v) {
GFX::DrawSprite((v ? sprites_sort_checked_idx : sprites_sort_unchecked_idx), buttons[pos].x + 1, buttons[pos].y);
}
/*
Return SortType as an uint8_t.
SortType st: The SortType variable.
*/
static const uint8_t GetType(SortType st) {
switch(st) {
case SortType::TITLE:
return 0;
case SortType::AUTHOR:
return 1;
case SortType::LAST_UPDATED:
return 2;
}
return 1;
}
/*
Draw the Sort Menu.
bool asc: The Ascending variable.
SortType st: The SortType variable.
*/
void StoreUtils::DrawSorting(bool asc, SortType st) {
Gui::Draw_Rect(40, 0, 280, 25, GFX::Themes[GFX::SelectedTheme].EntryBar);
Gui::Draw_Rect(40, 25, 280, 1, GFX::Themes[GFX::SelectedTheme].EntryOutline);
Gui::DrawStringCentered(17, 2, 0.6, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("SORTING"), 273, 0, font);
/* Sort By. */
Gui::DrawString(buttons[0].x + 1, buttons[0].y - 20, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("SORT_BY"), 90, 0, font);
for (int i = 0; i < 3; i++) {
DrawCheck(i, i == GetType(st));
}
Gui::DrawString(buttons[0].x + 21, buttons[0].y + 2, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("TITLE"), 80, 0, font);
Gui::DrawString(buttons[1].x + 21, buttons[1].y + 2, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("AUTHOR"), 80, 0, font);
Gui::DrawString(buttons[2].x + 21, buttons[2].y + 2, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("LAST_UPDATED"), 80, 0, font);
/* Direction. */
Gui::DrawString(buttons[3].x + 1, buttons[3].y - 20, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("DIRECTION"), 80, 0, font);
DrawCheck(3, asc);
DrawCheck(4, !asc);
Gui::DrawString(buttons[3].x + 21, buttons[3].y + 2, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("ASCENDING"), 80, 0, font);
Gui::DrawString(buttons[4].x + 21, buttons[4].y + 2, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("DESCENDING"), 80, 0, font);
/* Top Style. */
Gui::DrawString(buttons[5].x + 1, buttons[5].y - 20, 0.6f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("TOP_STYLE"), 90, 0, font);
DrawCheck(5, config->list());
DrawCheck(6, !config->list());
Gui::DrawString(buttons[5].x + 21, buttons[5].y + 2, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("LIST"), 90, 0, font);
Gui::DrawString(buttons[6].x + 21, buttons[6].y + 2, 0.4f, GFX::Themes[GFX::SelectedTheme].TextColor, Lang::get("GRID"), 90, 0, font);
}
/*
Sort Handle.
Here you can..
- Sort your entries to..
- Title (Ascending / Descending).
- Author (Ascending / Descending).
- Last Updated Date (Ascending / Descending).
- Change the Top Style.
bool &asc: Reference to the Ascending variable.
SortType &st: Reference to the SortType.
*/
void StoreUtils::SortHandle(bool &asc, SortType &st) {
if (StoreUtils::store && StoreUtils::store->GetValid() && StoreUtils::entries.size() > 0) { // Ensure, this is valid and more than 0 StoreUtils::entries exist.
if (hDown & KEY_TOUCH) {
/* SortType Part. */
if (touching(touch, buttons[0])) {
st = SortType::TITLE;
StoreUtils::SortEntries(asc, st);
} else if (touching(touch, buttons[1])) {
st = SortType::AUTHOR;
StoreUtils::SortEntries(asc, st);
} else if (touching(touch, buttons[2])) {
st = SortType::LAST_UPDATED;
StoreUtils::SortEntries(asc, st);
/* Ascending | Descending Part. */
} else if (touching(touch, buttons[3])) {
asc = true;
StoreUtils::SortEntries(asc, st);
} else if (touching(touch, buttons[4])) {
asc = false;
StoreUtils::SortEntries(asc, st);
} else if (touching(touch, buttons[5])) {
if (config->list()) return;
config->list(true);
StoreUtils::store->SetEntry(0);
StoreUtils::store->SetScreenIndx(0);
StoreUtils::store->SetBox(0);
} else if (touching(touch, buttons[6])) {
if (!config->list()) return;
config->list(false);
StoreUtils::store->SetEntry(0);
StoreUtils::store->SetScreenIndx(0);
StoreUtils::store->SetBox(0);
}
}
}
}