Changed Some More Stuff To DarkStore & Removed All Translations For Now

This commit is contained in:
Dark98
2021-06-18 06:58:54 +01:00
committed by dark98
parent fa3ce2acc8
commit eba72e5cb3
117 changed files with 52444 additions and 54800 deletions
+254 -254
View File
@@ -1,255 +1,255 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#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, 270, 22 },
{ 46, 62, 270, 22 },
{ 46, 92, 270, 22 },
{ 46, 122, 270, 22 },
{ 46, 152, 270, 22 },
{ 46, 182, 270, 22 },
{ 46, 212, 270, 22 },
{ 42, 216, 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 &EshopName: The name of the eShop filename.
const std::string &author: The author of the app.
*/
static bool CreateShortcut(const std::string &entryName, int index, const std::string &EshopName, 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>\"" << EshopName << "\" \"" << 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::unique_ptr<Store> &store: Const Reference to the Store class.
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::unique_ptr<Store> &store, const std::vector<std::string> &entries, bool fetch, const std::unique_ptr<StoreEntry> &entry, const std::vector<std::string> &sizes) {
/* For the Top Screen. */
if (store && store->GetValid() && !fetch && entry) {
if (entries.size() > 0) {
Gui::Draw_Rect(0, 174, 400, 66, BOX_INSIDE_COLOR);
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, TEXT_COLOR, entries[store->GetDownloadIndex()], 310, 0, font);
if (!sizes.empty()) {
if (sizes[store->GetDownloadIndex()] != "") {
Gui::DrawString(70, 174 + 30, 0.45f, TEXT_COLOR, Lang::get("SIZE") + ": " + sizes[store->GetDownloadIndex()], 310, 0, font);
}
}
}
}
GFX::DrawBottom();
Gui::Draw_Rect(40, 0, 280, 25, ENTRY_BAR_COLOR);
Gui::Draw_Rect(40, 25, 280, 1, ENTRY_BAR_OUTL_COLOR);
Gui::DrawStringCentered(17, 2, 0.6, TEXT_COLOR, Lang::get("AVAILABLE_DOWNLOADS"), 273, 0, font);
if (store && store->GetValid() && !fetch && entry) {
if (entries.size() > 0) {
for (int i = 0; i < DOWNLOAD_ENTRIES && i < (int)entries.size(); i++) {
if (store->GetDownloadIndex() == i + store->GetDownloadSIndex()) GFX::DrawBox(downloadBoxes[i].x, downloadBoxes[i].y, downloadBoxes[i].w, downloadBoxes[i].h, false);
Gui::DrawStringCentered(46 - 160 + (270 / 2), downloadBoxes[i].y + 4, 0.45f, TEXT_COLOR, entries[(i + store->GetDownloadSIndex())], 268, 0, font);
}
if (is3DSX) GFX::DrawSprite(sprites_shortcut_idx, downloadBoxes[6].x, downloadBoxes[6].y);
} else { // If no downloads available..
Gui::DrawStringCentered(46 - 160 + (270 / 2), downloadBoxes[0].y + 4, 0.5f, TEXT_COLOR, Lang::get("NO_DOWNLOADS_AVAILABLE"), 263, 0, font);
}
}
}
/*
Adding to Queue.. with checks!
*/
void AddToQueue(int index, const std::string &entry, const std::unique_ptr<Store> &store) {
if (!store) return;
/* Check first for proper JSON. */
if (!store->GetJson().contains("storeContent")) return;
if ((int)store->GetJson()["storeContent"].size() < index) return;
if (!store->GetJson()["storeContent"][index].contains(entry)) return;
nlohmann::json Script = nullptr;
/* Detect if array or new object thing. Else return Syntax error. :P */
if (store->GetJson()["storeContent"][index][entry].type() == nlohmann::json::value_t::array) {
Script = store->GetJson()["storeContent"][index][entry];
} else if (store->GetJson()["storeContent"][index][entry].type() == nlohmann::json::value_t::object) {
if (store->GetJson()["storeContent"][index][entry].contains("script") && store->GetJson()["storeContent"][index][entry]["script"].is_array()) {
Script = store->GetJson()["storeContent"][index][entry]["script"];
} else {
return;
}
}
QueueSystem::AddToQueue(Script, store->GetIconEntry(index), entry); // Here we add this to the Queue at the end.
}
/*
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<Store> &store: Const Reference to the Store class, since we do not modify anything in it.
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`.
std::unique_ptr<Meta> &meta: Reference to the Meta, to apply the updates stuff.
const int &lastMode: Const Reference to the last mode.
int &smallDelay: Reference to the small delay. This helps to not directly press A.
*/
void StoreUtils::DownloadHandle(const std::unique_ptr<Store> &store, const std::unique_ptr<StoreEntry> &entry, const std::vector<std::string> &entries, int &currentMenu, std::unique_ptr<Meta> &meta, const int &lastMode, int &smallDelay) {
if (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 (entries.size() <= 0) return; // Smaller than 0 -> No No.
if (Msg::promptMsg(Lang::get("CREATE_SHORTCUT"))) {
if (CreateShortcut(entry->GetTitle(), store->GetDownloadIndex(), store->GetFileName(), entry->GetAuthor())) {
Msg::waitMsg(Lang::get("SHORTCUT_CREATED"));
}
}
}
}
if (hRepeat & KEY_DOWN) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
if (store->GetDownloadIndex() < (int)entries.size() - 1) store->SetDownloadIndex(store->GetDownloadIndex() + 1);
else store->SetDownloadIndex(0);
}
if (hRepeat & KEY_UP) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
if (store->GetDownloadIndex() > 0) store->SetDownloadIndex(store->GetDownloadIndex() - 1);
else store->SetDownloadIndex(entries.size() - 1);
}
if (hRepeat & KEY_RIGHT) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
if (store->GetDownloadIndex() + DOWNLOAD_ENTRIES < (int)entries.size()-1) store->SetDownloadIndex(store->GetDownloadIndex() + DOWNLOAD_ENTRIES);
else store->SetDownloadIndex(entries.size()-1);
}
if (hRepeat & KEY_LEFT) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
if (store->GetDownloadIndex() - DOWNLOAD_ENTRIES > 0) store->SetDownloadIndex(store->GetDownloadIndex() - DOWNLOAD_ENTRIES);
else store->SetDownloadIndex(0);
}
if (smallDelay == 0 && hDown & KEY_TOUCH) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
for (int i = 0; i < DOWNLOAD_ENTRIES; i++) {
if (touching(touch, downloadBoxes[i])) {
if (i + store->GetDownloadSIndex() < (int)entries.size()) {
if (Msg::promptMsg(Lang::get("EXECUTE_ENTRY") + "\n\n" + entries[i + store->GetDownloadSIndex()])) {
AddToQueue(entry->GetEntryIndex(), entries[i + store->GetDownloadSIndex()], store);
}
}
}
}
}
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[store->GetDownloadIndex()])) {
AddToQueue(entry->GetEntryIndex(), entries[store->GetDownloadIndex()], store);
}
}
if (hDown & KEY_B) currentMenu = lastMode; // Go back to EntryInfo.
/* Scroll Handle. */
if (store->GetDownloadIndex() < store->GetDownloadSIndex()) store->SetDownloadSIndex(store->GetDownloadIndex());
else if (store->GetDownloadIndex() > store->GetDownloadSIndex() + DOWNLOAD_ENTRIES - 1) store->SetDownloadSIndex(store->GetDownloadIndex() - DOWNLOAD_ENTRIES + 1);
}
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#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, 270, 22 },
{ 46, 62, 270, 22 },
{ 46, 92, 270, 22 },
{ 46, 122, 270, 22 },
{ 46, 152, 270, 22 },
{ 46, 182, 270, 22 },
{ 46, 212, 270, 22 },
{ 42, 216, 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 &EshopName: The name of the eShop filename.
const std::string &author: The author of the app.
*/
static bool CreateShortcut(const std::string &entryName, int index, const std::string &EshopName, 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>\"" << EshopName << "\" \"" << 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::unique_ptr<Store> &store: Const Reference to the Store class.
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::unique_ptr<Store> &store, const std::vector<std::string> &entries, bool fetch, const std::unique_ptr<StoreEntry> &entry, const std::vector<std::string> &sizes) {
/* For the Top Screen. */
if (store && store->GetValid() && !fetch && entry) {
if (entries.size() > 0) {
Gui::Draw_Rect(0, 174, 400, 66, BOX_INSIDE_COLOR);
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, TEXT_COLOR, entries[store->GetDownloadIndex()], 310, 0, font);
if (!sizes.empty()) {
if (sizes[store->GetDownloadIndex()] != "") {
Gui::DrawString(70, 174 + 30, 0.45f, TEXT_COLOR, Lang::get("SIZE") + ": " + sizes[store->GetDownloadIndex()], 310, 0, font);
}
}
}
}
GFX::DrawBottom();
Gui::Draw_Rect(40, 0, 280, 25, ENTRY_BAR_COLOR);
Gui::Draw_Rect(40, 25, 280, 1, ENTRY_BAR_OUTL_COLOR);
Gui::DrawStringCentered(17, 2, 0.6, TEXT_COLOR, Lang::get("AVAILABLE_DOWNLOADS"), 273, 0, font);
if (store && store->GetValid() && !fetch && entry) {
if (entries.size() > 0) {
for (int i = 0; i < DOWNLOAD_ENTRIES && i < (int)entries.size(); i++) {
if (store->GetDownloadIndex() == i + store->GetDownloadSIndex()) GFX::DrawBox(downloadBoxes[i].x, downloadBoxes[i].y, downloadBoxes[i].w, downloadBoxes[i].h, false);
Gui::DrawStringCentered(46 - 160 + (270 / 2), downloadBoxes[i].y + 4, 0.45f, TEXT_COLOR, entries[(i + store->GetDownloadSIndex())], 268, 0, font);
}
if (is3DSX) GFX::DrawSprite(sprites_shortcut_idx, downloadBoxes[6].x, downloadBoxes[6].y);
} else { // If no downloads available..
Gui::DrawStringCentered(46 - 160 + (270 / 2), downloadBoxes[0].y + 4, 0.5f, TEXT_COLOR, Lang::get("NO_DOWNLOADS_AVAILABLE"), 263, 0, font);
}
}
}
/*
Adding to Queue.. with checks!
*/
void AddToQueue(int index, const std::string &entry, const std::unique_ptr<Store> &store) {
if (!store) return;
/* Check first for proper JSON. */
if (!store->GetJson().contains("storeContent")) return;
if ((int)store->GetJson()["storeContent"].size() < index) return;
if (!store->GetJson()["storeContent"][index].contains(entry)) return;
nlohmann::json Script = nullptr;
/* Detect if array or new object thing. Else return Syntax error. :P */
if (store->GetJson()["storeContent"][index][entry].type() == nlohmann::json::value_t::array) {
Script = store->GetJson()["storeContent"][index][entry];
} else if (store->GetJson()["storeContent"][index][entry].type() == nlohmann::json::value_t::object) {
if (store->GetJson()["storeContent"][index][entry].contains("script") && store->GetJson()["storeContent"][index][entry]["script"].is_array()) {
Script = store->GetJson()["storeContent"][index][entry]["script"];
} else {
return;
}
}
QueueSystem::AddToQueue(Script, store->GetIconEntry(index), entry); // Here we add this to the Queue at the end.
}
/*
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<Store> &store: Const Reference to the Store class, since we do not modify anything in it.
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`.
std::unique_ptr<Meta> &meta: Reference to the Meta, to apply the updates stuff.
const int &lastMode: Const Reference to the last mode.
int &smallDelay: Reference to the small delay. This helps to not directly press A.
*/
void StoreUtils::DownloadHandle(const std::unique_ptr<Store> &store, const std::unique_ptr<StoreEntry> &entry, const std::vector<std::string> &entries, int &currentMenu, std::unique_ptr<Meta> &meta, const int &lastMode, int &smallDelay) {
if (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 (entries.size() <= 0) return; // Smaller than 0 -> No No.
if (Msg::promptMsg(Lang::get("CREATE_SHORTCUT"))) {
if (CreateShortcut(entry->GetTitle(), store->GetDownloadIndex(), store->GetFileName(), entry->GetAuthor())) {
Msg::waitMsg(Lang::get("SHORTCUT_CREATED"));
}
}
}
}
if (hRepeat & KEY_DOWN) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
if (store->GetDownloadIndex() < (int)entries.size() - 1) store->SetDownloadIndex(store->GetDownloadIndex() + 1);
else store->SetDownloadIndex(0);
}
if (hRepeat & KEY_UP) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
if (store->GetDownloadIndex() > 0) store->SetDownloadIndex(store->GetDownloadIndex() - 1);
else store->SetDownloadIndex(entries.size() - 1);
}
if (hRepeat & KEY_RIGHT) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
if (store->GetDownloadIndex() + DOWNLOAD_ENTRIES < (int)entries.size()-1) store->SetDownloadIndex(store->GetDownloadIndex() + DOWNLOAD_ENTRIES);
else store->SetDownloadIndex(entries.size()-1);
}
if (hRepeat & KEY_LEFT) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
if (store->GetDownloadIndex() - DOWNLOAD_ENTRIES > 0) store->SetDownloadIndex(store->GetDownloadIndex() - DOWNLOAD_ENTRIES);
else store->SetDownloadIndex(0);
}
if (smallDelay == 0 && hDown & KEY_TOUCH) {
if (entries.size() <= 0) return; // Smaller *than* 0 -> Invalid.
for (int i = 0; i < DOWNLOAD_ENTRIES; i++) {
if (touching(touch, downloadBoxes[i])) {
if (i + store->GetDownloadSIndex() < (int)entries.size()) {
if (Msg::promptMsg(Lang::get("EXECUTE_ENTRY") + "\n\n" + entries[i + store->GetDownloadSIndex()])) {
AddToQueue(entry->GetEntryIndex(), entries[i + store->GetDownloadSIndex()], store);
}
}
}
}
}
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[store->GetDownloadIndex()])) {
AddToQueue(entry->GetEntryIndex(), entries[store->GetDownloadIndex()], store);
}
}
if (hDown & KEY_B) currentMenu = lastMode; // Go back to EntryInfo.
/* Scroll Handle. */
if (store->GetDownloadIndex() < store->GetDownloadSIndex()) store->SetDownloadSIndex(store->GetDownloadIndex());
else if (store->GetDownloadIndex() > store->GetDownloadSIndex() + DOWNLOAD_ENTRIES - 1) store->SetDownloadSIndex(store->GetDownloadIndex() - DOWNLOAD_ENTRIES + 1);
}
}
+88 -88
View File
@@ -1,89 +1,89 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#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();
/*
Dessinez la partie Entry Info.
const std::unique_ptr<Store> &store : Const Référence à la classe Store.
const std::unique_ptr<StoreEntry> &entry : Const Référence au StoreEntry actuel.
*/
void StoreUtils::DrawEntryInfo(const std::unique_ptr<Store> &store, const std::unique_ptr<StoreEntry> &entry) {
if (store && entry) { // Assurez-vous que lenregistrement et la saisie ne sont pas un nullptr.
Gui::Draw_Rect(40, 0, 280, 36, ENTRY_BAR_COLOR);
Gui::Draw_Rect(40, 36, 280, 1, ENTRY_BAR_OUTL_COLOR);
Gui::DrawStringCentered(17, 0, 0.6, TEXT_COLOR, entry->GetTitle(), 273, 0, font);
Gui::DrawStringCentered(17, 20, 0.4, TEXT_COLOR, entry->GetAuthor(), 273, 0, font);
Gui::DrawStringCentered(17, 50, 0.4, TEXT_COLOR, entry->GetDescription(), 248, 0, font, C2D_WordWrap);
Gui::DrawString(61, 130, 0.45, TEXT_COLOR, Lang::get("VERSION") + ": " + entry->GetVersion(), 248, 0, font);
Gui::DrawString(61, 145, 0.45, TEXT_COLOR, Lang::get("CATEGORY") + ": " + entry->GetCategory(), 248, 0, font);
Gui::DrawString(61, 160, 0.45, TEXT_COLOR, Lang::get("CONSOLE") + ": " + entry->GetConsole(), 248, 0, font);
Gui::DrawString(61, 175, 0.45, TEXT_COLOR, Lang::get("SIZE") + ": " + entry->GetSize(), 248, 0, font);
Gui::DrawString(61, 195, 0.45, TEXT_COLOR, entry->GetAdditionalcontent(), 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, TEXT_COLOR, "", 0, 0, font);
}
}
/*
La poignée EntryInfo.
Ici vous pouvez..
- Accédez à la liste de téléchargement en appuyant sur « A ».
- Montrez le MarkMenu avec START.
bool &showMark : Référence à showMark.. pour afficher le menu mark.
bool &fetch : Référence à fetch, pour que nous sachions, si nous avons besoin de fetch,
quand nous accédons à la liste de téléchargement.
*/
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()) {
sFetch = true;
mode = 6;
}
}
}
if ((hDown & KEY_X) || (hDown & KEY_TOUCH && touching(touch, notes))) {
if (entry->GetReleaseNotes() != "") mode = 7;
}
}
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#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();
/*
Dessinez la partie Entry Info.
const std::unique_ptr<Store> &store : Const Référence à la classe Store.
const std::unique_ptr<StoreEntry> &entry : Const Référence au StoreEntry actuel.
*/
void StoreUtils::DrawEntryInfo(const std::unique_ptr<Store> &store, const std::unique_ptr<StoreEntry> &entry) {
if (store && entry) { // Assurez-vous que lenregistrement et la saisie ne sont pas un nullptr.
Gui::Draw_Rect(40, 0, 280, 36, ENTRY_BAR_COLOR);
Gui::Draw_Rect(40, 36, 280, 1, ENTRY_BAR_OUTL_COLOR);
Gui::DrawStringCentered(17, 0, 0.6, TEXT_COLOR, entry->GetTitle(), 273, 0, font);
Gui::DrawStringCentered(17, 20, 0.4, TEXT_COLOR, entry->GetAuthor(), 273, 0, font);
Gui::DrawStringCentered(17, 50, 0.4, TEXT_COLOR, entry->GetDescription(), 248, 0, font, C2D_WordWrap);
Gui::DrawString(61, 130, 0.45, TEXT_COLOR, Lang::get("VERSION") + ": " + entry->GetVersion(), 248, 0, font);
Gui::DrawString(61, 145, 0.45, TEXT_COLOR, Lang::get("CATEGORY") + ": " + entry->GetCategory(), 248, 0, font);
Gui::DrawString(61, 160, 0.45, TEXT_COLOR, Lang::get("CONSOLE") + ": " + entry->GetConsole(), 248, 0, font);
Gui::DrawString(61, 175, 0.45, TEXT_COLOR, Lang::get("SIZE") + ": " + entry->GetSize(), 248, 0, font);
Gui::DrawString(61, 195, 0.45, TEXT_COLOR, entry->GetAdditionalcontent(), 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, TEXT_COLOR, "", 0, 0, font);
}
}
/*
La poignée EntryInfo.
Ici vous pouvez..
- Accédez à la liste de téléchargement en appuyant sur « A ».
- Montrez le MarkMenu avec START.
bool &showMark : Référence à showMark.. pour afficher le menu mark.
bool &fetch : Référence à fetch, pour que nous sachions, si nous avons besoin de fetch,
quand nous accédons à la liste de téléchargement.
*/
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()) {
sFetch = true;
mode = 6;
}
}
}
if ((hDown & KEY_X) || (hDown & KEY_TOUCH && touching(touch, notes))) {
if (entry->GetReleaseNotes() != "") mode = 7;
}
}
}
+175 -175
View File
@@ -1,176 +1,176 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#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 }
};
/*
Dessinez la grille supérieure.
const std::unique_ptr<Store> &store : Const Référence à la classe Store.
const std::vector<std::unique_ptr<StoreEntry>> &entries : Const Référence à StoreEntries.
*/
void StoreUtils::DrawGrid(const std::unique_ptr<Store> &store, const std::vector<std::unique_ptr<StoreEntry>> &entries) {
if (store) { // Assurez-vous que le magasin nest pas un nullptr.
if (config->usebg() && store->customBG()) {
C2D_DrawImageAt(store->GetStoreImg(), 0, 26, 0.5f, nullptr);
} else {
Gui::Draw_Rect(0, 26, 400, 214, BG_COLOR);
}
for (int i = 0, i2 = 0 + (store->GetScreenIndx() * 5); i2 < 15 + (store->GetScreenIndx() * 5) && i2 < (int)entries.size(); i2++, i++) {
/* Boxes. */
if (i == store->GetBox()) GFX::DrawBox(GridBoxes[i].x, GridBoxes[i].y, 50, 50, true);
/* Assurez-vous que les entrées sont plus grandes que lindex. */
if ((int)entries.size() > i2) {
if (entries[i2]) { // Assurez-vous que lentrée nest pas nullptr.
const C2D_Image tempImg = entries[i2]->GetIcon();
const uint8_t offsetW = (48 - tempImg.subtex->width) / 2; // Centre W.
const uint8_t offsetH = (48 - tempImg.subtex->height) / 2; // Centre H.
C2D_DrawImageAt(tempImg, GridBoxes[i].x + 1 + offsetW, GridBoxes[i].y + 1 + offsetH, 0.5);
/* Mettre à jour la marque disponible. */
if (entries[i2]->GetUpdateAvl()) GFX::DrawSprite(sprites_update_app_idx, GridBoxes[i].x + 32, GridBoxes[i].y + 32);
}
}
}
}
}
/*
Poignée logique de grille supérieure.
Ici vous pouvez..
- Faire défiler la grille à laide du pavé en D.
std::unique_ptrStore> &store : Référence à la classe Store.
std::vectorstd::unique_ptrStoreEntry>> &entries : Référence à StoreEntries.
const int &currentMode : Référence au mode actuel.
int &lastMode : Référence au dernier mode.
bool &fetch : Référence à fetch.
int &smallDelay : Référence au petit délai.
*/
void StoreUtils::GridLogic(std::unique_ptr<Store> &store, std::vector<std::unique_ptr<StoreEntry>> &entries, int &currentMode, int &lastMode, bool &fetch, int &smallDelay) {
if (store) { // Assurez-vous que le magasin nest pas un nullptr.
if (hRepeat & KEY_DOWN) {
if (store->GetBox() > 9) {
if (store->GetEntry() + 5 < (int)entries.size() - 1) {
store->SetEntry(store->GetEntry() + 5);
if (entries.size() > 15) store->SetScreenIndx((store->GetEntry() / 5) - 2);
} else {
if (store->GetEntry() < (int)entries.size() - 1) {
store->SetEntry(entries.size() - 1);
store->SetBox(10 + (store->GetEntry() % 5));
if (entries.size() > 15) store->SetScreenIndx((store->GetEntry() / 5) - 2);
}
}
} else {
if (store->GetEntry() + 5 < (int)entries.size()) {
store->SetBox(store->GetBox() + 5);
store->SetEntry(store->GetEntry() + 5);
}
}
}
if (hRepeat & KEY_RIGHT) {
if (store->GetEntry() < (int)entries.size() - 1) {
if (store->GetBox() < 14) {
store->SetBox(store->GetBox() + 1);
store->SetEntry(store->GetEntry() + 1);
} else {
store->SetBox(10);
store->SetEntry(store->GetEntry() + 1);
store->SetScreenIndx((store->GetEntry() / 5) - 2);
}
}
}
if (hRepeat & KEY_LEFT) {
if (store->GetEntry() > 0) {
if (store->GetBox() > 0) {
store->SetBox(store->GetBox() - 1);
store->SetEntry(store->GetEntry() - 1);
} else {
store->SetBox(4);
store->SetEntry(store->GetEntry() - 1);
store->SetScreenIndx((store->GetEntry() / 5));
}
}
}
if (hRepeat & KEY_UP) {
if (store->GetBox() < 5) {
if (store->GetEntry() > 4) {
store->SetEntry(store->GetEntry() - 5);
store->SetScreenIndx((store->GetEntry() / 5));
}
} else {
store->SetBox(store->GetBox() - 5);
store->SetEntry(store->GetEntry() - 5);
}
}
if (hDown & KEY_A) {
fetch = true;
smallDelay = 5;
lastMode = currentMode;
currentMode = 1;
}
}
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#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 }
};
/*
Dessinez la grille supérieure.
const std::unique_ptr<Store> &store : Const Référence à la classe Store.
const std::vector<std::unique_ptr<StoreEntry>> &entries : Const Référence à StoreEntries.
*/
void StoreUtils::DrawGrid(const std::unique_ptr<Store> &store, const std::vector<std::unique_ptr<StoreEntry>> &entries) {
if (store) { // Assurez-vous que le magasin nest pas un nullptr.
if (config->usebg() && store->customBG()) {
C2D_DrawImageAt(store->GetStoreImg(), 0, 26, 0.5f, nullptr);
} else {
Gui::Draw_Rect(0, 26, 400, 214, BG_COLOR);
}
for (int i = 0, i2 = 0 + (store->GetScreenIndx() * 5); i2 < 15 + (store->GetScreenIndx() * 5) && i2 < (int)entries.size(); i2++, i++) {
/* Boxes. */
if (i == store->GetBox()) GFX::DrawBox(GridBoxes[i].x, GridBoxes[i].y, 50, 50, true);
/* Assurez-vous que les entrées sont plus grandes que lindex. */
if ((int)entries.size() > i2) {
if (entries[i2]) { // Assurez-vous que lentrée nest pas nullptr.
const C2D_Image tempImg = entries[i2]->GetIcon();
const uint8_t offsetW = (48 - tempImg.subtex->width) / 2; // Centre W.
const uint8_t offsetH = (48 - tempImg.subtex->height) / 2; // Centre H.
C2D_DrawImageAt(tempImg, GridBoxes[i].x + 1 + offsetW, GridBoxes[i].y + 1 + offsetH, 0.5);
/* Mettre à jour la marque disponible. */
if (entries[i2]->GetUpdateAvl()) GFX::DrawSprite(sprites_update_app_idx, GridBoxes[i].x + 32, GridBoxes[i].y + 32);
}
}
}
}
}
/*
Poignée logique de grille supérieure.
Ici vous pouvez..
- Faire défiler la grille à laide du pavé en D.
std::unique_ptrStore> &store : Référence à la classe Store.
std::vectorstd::unique_ptrStoreEntry>> &entries : Référence à StoreEntries.
const int &currentMode : Référence au mode actuel.
int &lastMode : Référence au dernier mode.
bool &fetch : Référence à fetch.
int &smallDelay : Référence au petit délai.
*/
void StoreUtils::GridLogic(std::unique_ptr<Store> &store, std::vector<std::unique_ptr<StoreEntry>> &entries, int &currentMode, int &lastMode, bool &fetch, int &smallDelay) {
if (store) { // Assurez-vous que le magasin nest pas un nullptr.
if (hRepeat & KEY_DOWN) {
if (store->GetBox() > 9) {
if (store->GetEntry() + 5 < (int)entries.size() - 1) {
store->SetEntry(store->GetEntry() + 5);
if (entries.size() > 15) store->SetScreenIndx((store->GetEntry() / 5) - 2);
} else {
if (store->GetEntry() < (int)entries.size() - 1) {
store->SetEntry(entries.size() - 1);
store->SetBox(10 + (store->GetEntry() % 5));
if (entries.size() > 15) store->SetScreenIndx((store->GetEntry() / 5) - 2);
}
}
} else {
if (store->GetEntry() + 5 < (int)entries.size()) {
store->SetBox(store->GetBox() + 5);
store->SetEntry(store->GetEntry() + 5);
}
}
}
if (hRepeat & KEY_RIGHT) {
if (store->GetEntry() < (int)entries.size() - 1) {
if (store->GetBox() < 14) {
store->SetBox(store->GetBox() + 1);
store->SetEntry(store->GetEntry() + 1);
} else {
store->SetBox(10);
store->SetEntry(store->GetEntry() + 1);
store->SetScreenIndx((store->GetEntry() / 5) - 2);
}
}
}
if (hRepeat & KEY_LEFT) {
if (store->GetEntry() > 0) {
if (store->GetBox() > 0) {
store->SetBox(store->GetBox() - 1);
store->SetEntry(store->GetEntry() - 1);
} else {
store->SetBox(4);
store->SetEntry(store->GetEntry() - 1);
store->SetScreenIndx((store->GetEntry() / 5));
}
}
}
if (hRepeat & KEY_UP) {
if (store->GetBox() < 5) {
if (store->GetEntry() > 4) {
store->SetEntry(store->GetEntry() - 5);
store->SetScreenIndx((store->GetEntry() / 5));
}
} else {
store->SetBox(store->GetBox() - 5);
store->SetEntry(store->GetEntry() - 5);
}
}
if (hDown & KEY_A) {
fetch = true;
smallDelay = 5;
lastMode = currentMode;
currentMode = 1;
}
}
}
+121 -121
View File
@@ -1,122 +1,122 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#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 }
};
/*
Dessinez la liste du haut.
const std::unique_ptr<Store> &store : Const Référence à la classe Store.
const std::vector<std::unique_ptr<StoreEntry>> &entries : Const Référence à StoreEntries.
*/
void StoreUtils::DrawList(const std::unique_ptr<Store> &store, const std::vector<std::unique_ptr<StoreEntry>> &entries) {
if (store) { // Assurez-vous que le magasin nest pas un nullptr.
if (config->usebg() && store->customBG()) {
C2D_DrawImageAt(store->GetStoreImg(), 0, 26, 0.5f, nullptr);
} else {
Gui::Draw_Rect(0, 26, 400, 214, BG_COLOR);
}
if (entries.size() > 0) {
for (int i = 0; i < 3 && i < (int)entries.size(); i++) {
if (i + store->GetScreenIndx() == store->GetEntry()) {
GFX::DrawBox(StoreBoxesList[i].x, StoreBoxesList[i].y, StoreBoxesList[i].w, StoreBoxesList[i].h, false);
}
/* Assurez-vous que les entrées sont plus grandes que lindex. */
if ((int)entries.size() > i + store->GetScreenIndx()) {
if (entries[i + store->GetScreenIndx()]) { // Assurez-vous que lentrée nest pas nulle.
const C2D_Image tempImg = entries[i + store->GetScreenIndx()]->GetIcon();
const uint8_t offsetW = (48 - tempImg.subtex->width) / 2; // Centre W.
const uint8_t offsetH = (48 - tempImg.subtex->height) / 2; // Centre H.
C2D_DrawImageAt(tempImg, StoreBoxesList[i].x + 1 + offsetW, StoreBoxesList[i].y + 1 + offsetH, 0.5);
}
if (entries[i + 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, TEXT_COLOR, entries[i + store->GetScreenIndx()]->GetTitle(), 300, 0, font);
Gui::DrawStringCentered(29, StoreBoxesList[i].y + 24, 0.6f, TEXT_COLOR, entries[i + store->GetScreenIndx()]->GetAuthor(), 300, 0, font);
}
}
}
}
}
/*
Poignée logique de liste supérieure.
Ici vous pouvez..
- Faites défiler la grille avec le pavé en D vers le haut/vers le bas et sautez 3 entrées avec la gauche/droite.
std::unique_ptrStore> &store : Référence à la classe Store.
std::vectorstd::unique_ptrStoreEntry>> &entries : Référence à StoreEntries.
int &currentMode : Const Référence au mode actuel.
int &lastMode : Référence au dernier mode.
bool &fetch : Référence à fetch.
int &smallDelay : Référence au petit délai.
*/
void StoreUtils::ListLogic(std::unique_ptr<Store> &store, std::vector<std::unique_ptr<StoreEntry>> &entries, int &currentMode, int &lastMode, bool &fetch, int &smallDelay) {
if (store) { // Assurez-vous que le magasin nest pas un nullptr.
if (hRepeat & KEY_DOWN) {
if (store->GetEntry() < (int)entries.size() - 1) store->SetEntry(store->GetEntry() + 1);
else store->SetEntry(0);
}
if (hRepeat & KEY_RIGHT) {
if (store->GetEntry() < (int)entries.size() - 3) store->SetEntry(store->GetEntry() + 3);
else store->SetEntry(entries.size() - 1);
}
if (hRepeat & KEY_LEFT) {
if (store->GetEntry() - 2 > 0) store->SetEntry(store->GetEntry() - 3);
else store->SetEntry(0);
}
if (hRepeat & KEY_UP) {
if (store->GetEntry() > 0) store->SetEntry(store->GetEntry() - 1);
else store->SetEntry(entries.size() - 1);
}
if (hDown & KEY_A) {
fetch = true;
smallDelay = 5;
lastMode = currentMode;
currentMode = 1;
}
/* Scroll Logic. */
if (store->GetEntry() < store->GetScreenIndx()) store->SetScreenIndx(store->GetEntry());
else if (store->GetEntry() > store->GetScreenIndx() + 3 - 1) store->SetScreenIndx(store->GetEntry() - 3 + 1);
}
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#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 }
};
/*
Dessinez la liste du haut.
const std::unique_ptr<Store> &store : Const Référence à la classe Store.
const std::vector<std::unique_ptr<StoreEntry>> &entries : Const Référence à StoreEntries.
*/
void StoreUtils::DrawList(const std::unique_ptr<Store> &store, const std::vector<std::unique_ptr<StoreEntry>> &entries) {
if (store) { // Assurez-vous que le magasin nest pas un nullptr.
if (config->usebg() && store->customBG()) {
C2D_DrawImageAt(store->GetStoreImg(), 0, 26, 0.5f, nullptr);
} else {
Gui::Draw_Rect(0, 26, 400, 214, BG_COLOR);
}
if (entries.size() > 0) {
for (int i = 0; i < 3 && i < (int)entries.size(); i++) {
if (i + store->GetScreenIndx() == store->GetEntry()) {
GFX::DrawBox(StoreBoxesList[i].x, StoreBoxesList[i].y, StoreBoxesList[i].w, StoreBoxesList[i].h, false);
}
/* Assurez-vous que les entrées sont plus grandes que lindex. */
if ((int)entries.size() > i + store->GetScreenIndx()) {
if (entries[i + store->GetScreenIndx()]) { // Assurez-vous que lentrée nest pas nulle.
const C2D_Image tempImg = entries[i + store->GetScreenIndx()]->GetIcon();
const uint8_t offsetW = (48 - tempImg.subtex->width) / 2; // Centre W.
const uint8_t offsetH = (48 - tempImg.subtex->height) / 2; // Centre H.
C2D_DrawImageAt(tempImg, StoreBoxesList[i].x + 1 + offsetW, StoreBoxesList[i].y + 1 + offsetH, 0.5);
}
if (entries[i + 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, TEXT_COLOR, entries[i + store->GetScreenIndx()]->GetTitle(), 300, 0, font);
Gui::DrawStringCentered(29, StoreBoxesList[i].y + 24, 0.6f, TEXT_COLOR, entries[i + store->GetScreenIndx()]->GetAuthor(), 300, 0, font);
}
}
}
}
}
/*
Poignée logique de liste supérieure.
Ici vous pouvez..
- Faites défiler la grille avec le pavé en D vers le haut/vers le bas et sautez 3 entrées avec la gauche/droite.
std::unique_ptrStore> &store : Référence à la classe Store.
std::vectorstd::unique_ptrStoreEntry>> &entries : Référence à StoreEntries.
int &currentMode : Const Référence au mode actuel.
int &lastMode : Référence au dernier mode.
bool &fetch : Référence à fetch.
int &smallDelay : Référence au petit délai.
*/
void StoreUtils::ListLogic(std::unique_ptr<Store> &store, std::vector<std::unique_ptr<StoreEntry>> &entries, int &currentMode, int &lastMode, bool &fetch, int &smallDelay) {
if (store) { // Assurez-vous que le magasin nest pas un nullptr.
if (hRepeat & KEY_DOWN) {
if (store->GetEntry() < (int)entries.size() - 1) store->SetEntry(store->GetEntry() + 1);
else store->SetEntry(0);
}
if (hRepeat & KEY_RIGHT) {
if (store->GetEntry() < (int)entries.size() - 3) store->SetEntry(store->GetEntry() + 3);
else store->SetEntry(entries.size() - 1);
}
if (hRepeat & KEY_LEFT) {
if (store->GetEntry() - 2 > 0) store->SetEntry(store->GetEntry() - 3);
else store->SetEntry(0);
}
if (hRepeat & KEY_UP) {
if (store->GetEntry() > 0) store->SetEntry(store->GetEntry() - 1);
else store->SetEntry(entries.size() - 1);
}
if (hDown & KEY_A) {
fetch = true;
smallDelay = 5;
lastMode = currentMode;
currentMode = 1;
}
/* Scroll Logic. */
if (store->GetEntry() < store->GetScreenIndx()) store->SetScreenIndx(store->GetEntry());
else if (store->GetEntry() > store->GetScreenIndx() + 3 - 1) store->SetScreenIndx(store->GetEntry() - 3 + 1);
}
}
+125 -125
View File
@@ -1,126 +1,126 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#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 }
};
/*
Dessinez la partie Marquage.
int marks : Les drapeaux de marque actifs.
*/
void StoreUtils::DisplayMarkBox(int marks) {
Gui::Draw_Rect(0, 0, 320, 240, DIM_COLOR); // Assombrir.
Gui::Draw_Rect(markBox[0].x, markBox[0].y, markBox[0].w, markBox[0].h, (marks & favoriteMarks::STAR ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::Draw_Rect(markBox[1].x, markBox[1].y, markBox[1].w, markBox[1].h, (marks & favoriteMarks::HEART ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::Draw_Rect(markBox[2].x, markBox[2].y, markBox[2].w, markBox[2].h, (marks & favoriteMarks::DIAMOND ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::Draw_Rect(markBox[3].x, markBox[3].y, markBox[3].w, markBox[3].h, (marks & favoriteMarks::CLUBS ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::Draw_Rect(markBox[4].x, markBox[4].y, markBox[4].w, markBox[4].h, (marks & favoriteMarks::SPADE ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::DrawString(markBox[0].x + 15, markBox[0].y + 11, 0.9, TEXT_COLOR, "", 0, 0, font);
Gui::DrawString(markBox[1].x + 15, markBox[1].y + 11, 0.9, TEXT_COLOR, "", 0, 0, font);
Gui::DrawString(markBox[2].x + 15, markBox[2].y + 11, 0.9, TEXT_COLOR, "", 0, 0, font);
Gui::DrawString(markBox[3].x + 15, markBox[3].y + 11, 0.9, TEXT_COLOR, "", 0, 0, font);
Gui::DrawString(markBox[4].x + 15, markBox[4].y + 11, 0.9, TEXT_COLOR, "", 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, TEXT_COLOR, "", 0, 0, font);
}
/*
Sélectionner la poignée de menu.
Ici vous pouvez..
- Cochez lapplication sélectionnée.
- Retournez à EntryInfo avec `B`.
std::unique_ptrStoreEntry> &entry : Référence au StoreEntry actuel.
const std::unique_ptrStore> &store : Const Référence au Store, puisque nous ny modifions rien.
bool &showMark : Référence à showMark, pour que nous sachions si nous devrions rester ici ou non.
std::unique_ptrMeta> &meta : Référence à la classe Meta.
*/
void StoreUtils::MarkHandle(std::unique_ptr<StoreEntry> &entry, const std::unique_ptr<Store> &store, bool &showMark, std::unique_ptr<Meta> &meta) {
hidScanInput();
touchPosition t;
hidTouchRead(&t);
if (meta && entry && store) {
if (hidKeysDown() & KEY_TOUCH) {
/* Etoiles. */
if (touching(t, markBox[0])) {
meta->SetMarks(store->GetEshopTitle(), entry->GetTitle(),
meta->GetMarks(store->GetEshopTitle(), entry->GetTitle()) ^ favoriteMarks::STAR);
entry->SetMark(meta->GetMarks(store->GetEshopTitle(), entry->GetTitle()));
/* Coeur. */
} else if (touching(t, markBox[1])) {
meta->SetMarks(store->GetEshopTitle(), entry->GetTitle(),
meta->GetMarks(store->GetEshopTitle(), entry->GetTitle()) ^ favoriteMarks::HEART);
entry->SetMark(meta->GetMarks(store->GetEshopTitle(), entry->GetTitle()));
/* Diamand. */
} else if (touching(t, markBox[2])) {
meta->SetMarks(store->GetEshopTitle(), entry->GetTitle(),
meta->GetMarks(store->GetEshopTitle(), entry->GetTitle()) ^ favoriteMarks::DIAMOND);
entry->SetMark(meta->GetMarks(store->GetEshopTitle(), entry->GetTitle()));
/* Clubs. */
} else if (touching(t, markBox[3])) {
meta->SetMarks(store->GetEshopTitle(), entry->GetTitle(),
meta->GetMarks(store->GetEshopTitle(), entry->GetTitle()) ^ favoriteMarks::CLUBS);
entry->SetMark(meta->GetMarks(store->GetEshopTitle(), entry->GetTitle()));
/* Spade. */
} else if (touching(t, markBox[4])) {
meta->SetMarks(store->GetEshopTitle(), entry->GetTitle(),
meta->GetMarks(store->GetEshopTitle(), entry->GetTitle()) ^ favoriteMarks::SPADE);
entry->SetMark(meta->GetMarks(store->GetEshopTitle(), entry->GetTitle()));
}
}
}
if ((hidKeysDown() & KEY_B || hidKeysDown() & KEY_START) || (hidKeysDown() & KEY_TOUCH && touching(t, markBox[5]))) showMark = false; // Return back to screen.
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#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 }
};
/*
Dessinez la partie Marquage.
int marks : Les drapeaux de marque actifs.
*/
void StoreUtils::DisplayMarkBox(int marks) {
Gui::Draw_Rect(0, 0, 320, 240, DIM_COLOR); // Assombrir.
Gui::Draw_Rect(markBox[0].x, markBox[0].y, markBox[0].w, markBox[0].h, (marks & favoriteMarks::STAR ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::Draw_Rect(markBox[1].x, markBox[1].y, markBox[1].w, markBox[1].h, (marks & favoriteMarks::HEART ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::Draw_Rect(markBox[2].x, markBox[2].y, markBox[2].w, markBox[2].h, (marks & favoriteMarks::DIAMOND ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::Draw_Rect(markBox[3].x, markBox[3].y, markBox[3].w, markBox[3].h, (marks & favoriteMarks::CLUBS ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::Draw_Rect(markBox[4].x, markBox[4].y, markBox[4].w, markBox[4].h, (marks & favoriteMarks::SPADE ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::DrawString(markBox[0].x + 15, markBox[0].y + 11, 0.9, TEXT_COLOR, "", 0, 0, font);
Gui::DrawString(markBox[1].x + 15, markBox[1].y + 11, 0.9, TEXT_COLOR, "", 0, 0, font);
Gui::DrawString(markBox[2].x + 15, markBox[2].y + 11, 0.9, TEXT_COLOR, "", 0, 0, font);
Gui::DrawString(markBox[3].x + 15, markBox[3].y + 11, 0.9, TEXT_COLOR, "", 0, 0, font);
Gui::DrawString(markBox[4].x + 15, markBox[4].y + 11, 0.9, TEXT_COLOR, "", 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, TEXT_COLOR, "", 0, 0, font);
}
/*
Sélectionner la poignée de menu.
Ici vous pouvez..
- Cochez lapplication sélectionnée.
- Retournez à EntryInfo avec `B`.
std::unique_ptrStoreEntry> &entry : Référence au StoreEntry actuel.
const std::unique_ptrStore> &store : Const Référence au Store, puisque nous ny modifions rien.
bool &showMark : Référence à showMark, pour que nous sachions si nous devrions rester ici ou non.
std::unique_ptrMeta> &meta : Référence à la classe Meta.
*/
void StoreUtils::MarkHandle(std::unique_ptr<StoreEntry> &entry, const std::unique_ptr<Store> &store, bool &showMark, std::unique_ptr<Meta> &meta) {
hidScanInput();
touchPosition t;
hidTouchRead(&t);
if (meta && entry && store) {
if (hidKeysDown() & KEY_TOUCH) {
/* Etoiles. */
if (touching(t, markBox[0])) {
meta->SetMarks(store->GetEshopTitle(), entry->GetTitle(),
meta->GetMarks(store->GetEshopTitle(), entry->GetTitle()) ^ favoriteMarks::STAR);
entry->SetMark(meta->GetMarks(store->GetEshopTitle(), entry->GetTitle()));
/* Coeur. */
} else if (touching(t, markBox[1])) {
meta->SetMarks(store->GetEshopTitle(), entry->GetTitle(),
meta->GetMarks(store->GetEshopTitle(), entry->GetTitle()) ^ favoriteMarks::HEART);
entry->SetMark(meta->GetMarks(store->GetEshopTitle(), entry->GetTitle()));
/* Diamand. */
} else if (touching(t, markBox[2])) {
meta->SetMarks(store->GetEshopTitle(), entry->GetTitle(),
meta->GetMarks(store->GetEshopTitle(), entry->GetTitle()) ^ favoriteMarks::DIAMOND);
entry->SetMark(meta->GetMarks(store->GetEshopTitle(), entry->GetTitle()));
/* Clubs. */
} else if (touching(t, markBox[3])) {
meta->SetMarks(store->GetEshopTitle(), entry->GetTitle(),
meta->GetMarks(store->GetEshopTitle(), entry->GetTitle()) ^ favoriteMarks::CLUBS);
entry->SetMark(meta->GetMarks(store->GetEshopTitle(), entry->GetTitle()));
/* Spade. */
} else if (touching(t, markBox[4])) {
meta->SetMarks(store->GetEshopTitle(), entry->GetTitle(),
meta->GetMarks(store->GetEshopTitle(), entry->GetTitle()) ^ favoriteMarks::SPADE);
entry->SetMark(meta->GetMarks(store->GetEshopTitle(), entry->GetTitle()));
}
}
}
if ((hidKeysDown() & KEY_B || hidKeysDown() & KEY_START) || (hidKeysDown() & KEY_TOUCH && touching(t, markBox[5]))) showMark = false; // Return back to screen.
}
+134 -134
View File
@@ -1,135 +1,135 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "common.hpp"
#include "fileBrowse.hpp"
#include "meta.hpp"
#include <unistd.h>
/*
Le Constructeur de la Meta.
Inclut la création de fichier MetaData, si elle nexiste pas.
*/
Meta::Meta() {
if (access(_META_PATH, F_OK) != 0) {
FILE *temp = fopen(_META_PATH, "w");
char tmp[2] = { '{', '}' };
fwrite(tmp, sizeof(tmp), 1, temp);
fclose(temp);
}
FILE *temp = fopen(_META_PATH, "rt");
this->metadataJson = nlohmann::json::parse(temp, nullptr, false);
fclose(temp);
if (config->metadata()) this->ImportMetadata();
}
/*
Importez les anciennes métadonnées du fichier 'updates.json'.
*/
void Meta::ImportMetadata() {
if (access("sdmc:/3ds/DarkStore/updates.json", F_OK) != 0) {
config->metadata(false);
return; // Introuvables.
}
Msg::DisplayMsg(Lang::get("FETCHING_METADATA"));
FILE *old = fopen("sdmc:/3ds/DarkStore/updates.json", "r");
nlohmann::json oldJson = nlohmann::json::parse(old, nullptr, false);
fclose(old);
std::vector<EshopInfo> info = GetEshopInfo(_STORE_PATH); // Va chercher eShop.
for (int i = 0; i < (int)info.size(); i++) {
if (info[i].Title != "" && oldJson.contains(info[i].FileName)) {
for(auto it = oldJson[info[i].FileName].begin(); it != oldJson[info[i].FileName].end(); ++it) {
this->SetUpdated(info[i].Title, it.key().c_str(), it.value().get<std::string>());
}
}
}
config->metadata(false);
}
/*
Obtenir la dernière mise à jour.
const std::string &EshopName : Le nom eShop.
const std::string &entry : Le nom de lentrée.
*/
std::string Meta::GetUpdated(const std::string &EshopName, const std::string &entry) const {
if (!this->metadataJson.contains(EshopName)) return ""; // Le nom de l'eShop nexiste pas.
if (!this->metadataJson[EshopName].contains(entry)) return ""; // L'entrée n'existe pas.
if (!this->metadataJson[EshopName][entry].contains("updated")) return ""; // Les mises à jour n'existe pas.
if (this->metadataJson[EshopName][entry]["updated"].is_string()) return this->metadataJson[EshopName][entry]["updated"];
return "";
}
/*
Prends les marques.
const std::string &EshopName : Le nom eShop.
const std::string &entry : Le nom de lentrée.
*/
int Meta::GetMarks(const std::string &EshopName, const std::string &entry) const {
int temp = 0;
if (!this->metadataJson.contains(EshopName)) return temp; // Le nom de l'eShop nexiste pas.
if (!this->metadataJson[EshopName].contains(entry)) return temp; // L'entrée n'existe pas.
if (!this->metadataJson[EshopName][entry].contains("marks")) return temp; // Les marques n'existe pas.
if (this->metadataJson[EshopName][entry]["marks"].is_number()) return this->metadataJson[EshopName][entry]["marks"];
return temp;
}
/*
Retourner, si la mise à jour est disponible.
const std::string &EshopName : Le nom eShop.
const std::string &entry : Le nom de lentrée.
const std::string &updated : Compare pour la mise à jour.
*/
bool Meta::UpdateAvailable(const std::string &EshopName, const std::string &entry, const std::string &updated) const {
if (this->GetUpdated(EshopName, entry) != "" && updated != "") {
return strcasecmp(updated.c_str(), this->GetUpdated(EshopName, entry).c_str()) > 0;
}
return false;
}
/*
Lappel de sauvegarde.
Ecrire au fichier.. appelé sur destructor.
*/
void Meta::SaveCall() {
FILE *file = fopen(_META_PATH, "wb");
const std::string dump = this->metadataJson.dump(1, '\t');
fwrite(dump.c_str(), 1, dump.size(), file);
fclose(file);
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "common.hpp"
#include "fileBrowse.hpp"
#include "meta.hpp"
#include <unistd.h>
/*
Le Constructeur de la Meta.
Inclut la création de fichier MetaData, si elle nexiste pas.
*/
Meta::Meta() {
if (access(_META_PATH, F_OK) != 0) {
FILE *temp = fopen(_META_PATH, "w");
char tmp[2] = { '{', '}' };
fwrite(tmp, sizeof(tmp), 1, temp);
fclose(temp);
}
FILE *temp = fopen(_META_PATH, "rt");
this->metadataJson = nlohmann::json::parse(temp, nullptr, false);
fclose(temp);
if (config->metadata()) this->ImportMetadata();
}
/*
Importez les anciennes métadonnées du fichier 'updates.json'.
*/
void Meta::ImportMetadata() {
if (access("sdmc:/3ds/DarkStore/updates.json", F_OK) != 0) {
config->metadata(false);
return; // Introuvables.
}
Msg::DisplayMsg(Lang::get("FETCHING_METADATA"));
FILE *old = fopen("sdmc:/3ds/DarkStore/updates.json", "r");
nlohmann::json oldJson = nlohmann::json::parse(old, nullptr, false);
fclose(old);
std::vector<EshopInfo> info = GetEshopInfo(_STORE_PATH); // Va chercher eShop.
for (int i = 0; i < (int)info.size(); i++) {
if (info[i].Title != "" && oldJson.contains(info[i].FileName)) {
for(auto it = oldJson[info[i].FileName].begin(); it != oldJson[info[i].FileName].end(); ++it) {
this->SetUpdated(info[i].Title, it.key().c_str(), it.value().get<std::string>());
}
}
}
config->metadata(false);
}
/*
Obtenir la dernière mise à jour.
const std::string &EshopName : Le nom eShop.
const std::string &entry : Le nom de lentrée.
*/
std::string Meta::GetUpdated(const std::string &EshopName, const std::string &entry) const {
if (!this->metadataJson.contains(EshopName)) return ""; // Le nom de l'eShop nexiste pas.
if (!this->metadataJson[EshopName].contains(entry)) return ""; // L'entrée n'existe pas.
if (!this->metadataJson[EshopName][entry].contains("updated")) return ""; // Les mises à jour n'existe pas.
if (this->metadataJson[EshopName][entry]["updated"].is_string()) return this->metadataJson[EshopName][entry]["updated"];
return "";
}
/*
Prends les marques.
const std::string &EshopName : Le nom eShop.
const std::string &entry : Le nom de lentrée.
*/
int Meta::GetMarks(const std::string &EshopName, const std::string &entry) const {
int temp = 0;
if (!this->metadataJson.contains(EshopName)) return temp; // Le nom de l'eShop nexiste pas.
if (!this->metadataJson[EshopName].contains(entry)) return temp; // L'entrée n'existe pas.
if (!this->metadataJson[EshopName][entry].contains("marks")) return temp; // Les marques n'existe pas.
if (this->metadataJson[EshopName][entry]["marks"].is_number()) return this->metadataJson[EshopName][entry]["marks"];
return temp;
}
/*
Retourner, si la mise à jour est disponible.
const std::string &EshopName : Le nom eShop.
const std::string &entry : Le nom de lentrée.
const std::string &updated : Compare pour la mise à jour.
*/
bool Meta::UpdateAvailable(const std::string &EshopName, const std::string &entry, const std::string &updated) const {
if (this->GetUpdated(EshopName, entry) != "" && updated != "") {
return strcasecmp(updated.c_str(), this->GetUpdated(EshopName, entry).c_str()) > 0;
}
return false;
}
/*
Lappel de sauvegarde.
Ecrire au fichier.. appelé sur destructor.
*/
void Meta::SaveCall() {
FILE *file = fopen(_META_PATH, "wb");
const std::string dump = this->metadataJson.dump(1, '\t');
fwrite(dump.c_str(), 1, dump.size(), file);
fclose(file);
}
+134 -134
View File
@@ -1,135 +1,135 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "queueSystem.hpp"
#include "storeUtils.hpp"
#include "structs.hpp"
#include <curl/curl.h>
extern u32 extractSize, writeOffset;
extern u32 installSize, installOffset;
extern u32 copyOffset, copySize;
extern curl_off_t downloadTotal;
extern curl_off_t downloadNow;
#define QUEUE_ENTRIES 2 // 2 Entries per screen or so.
extern bool touching(touchPosition touch, Structs::ButtonPos button);
/* TODO: Rework positions + sizes.. */
static const std::vector<Structs::ButtonPos> QueueBoxes = {
{ 46, 32, 266, 80 },
{ 46, 132, 266, 80 }
};
extern std::deque<std::unique_ptr<Queue>> queueEntries;
void DrawStatus(QueueStatus s) {
char str[256];
/* String Handle. */
switch(s) {
case QueueStatus::None:
case QueueStatus::Failed:
case QueueStatus::Done:
break;
case QueueStatus::Downloading:
if (downloadTotal < 1.0f) downloadTotal = 1.0f;
if (downloadTotal < downloadNow) downloadTotal = downloadNow;
snprintf(str, sizeof(str), "Downloading... %s / %s (%.2f%%)",
StringUtils::formatBytes(downloadNow).c_str(),
StringUtils::formatBytes(downloadTotal).c_str(),
((float)downloadNow/(float)downloadTotal) * 100.0f);
break;
case QueueStatus::Extracting:
snprintf(str, sizeof(str), "Extracting... %s / %s (%.2f%%)",
StringUtils::formatBytes(writeOffset).c_str(),
StringUtils::formatBytes(extractSize).c_str(),
((float)writeOffset/(float)extractSize) * 100.0f);
break;
case QueueStatus::Installing:
snprintf(str, sizeof(str), "Installing... %s / %s (%.2f%%)",
StringUtils::formatBytes(installOffset).c_str(),
StringUtils::formatBytes(installSize).c_str(),
((float)installOffset/(float)installSize) * 100.0f);
break;
}
/* Draw Handle. */
switch(s) {
case QueueStatus::None:
case QueueStatus::Failed:
case QueueStatus::Done:
break;
case QueueStatus::Downloading:
Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, TEXT_COLOR, str, 250, 0, font);
Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 25, 180, 30, BLACK);
Gui::Draw_Rect(QueueBoxes[0].x + 60 + 1, QueueBoxes[0].y + 25 + 1, (int)(((float)downloadNow / (float)downloadTotal) * 180.0f), 28, WHITE);
break;
case QueueStatus::Extracting:
Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, TEXT_COLOR, str, 250, 0, font);
Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 25, 180, 30, BLACK);
Gui::Draw_Rect(QueueBoxes[0].x + 60 + 1, QueueBoxes[0].y + 25 + 1, (int)(((float)writeOffset / (float)extractSize) * 180.0f), 28, WHITE);
break;
case QueueStatus::Installing:
Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, TEXT_COLOR, str, 250, 0, font);
Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 25, 180, 30, BLACK);
Gui::Draw_Rect(QueueBoxes[0].x + 60 + 1, QueueBoxes[0].y + 25 + 1, (int)(((float)installOffset / (float)installSize) * 180.0f), 28, WHITE);
break;
}
}
void StoreUtils::DrawQueueMenu(const int queueIndex) {
Gui::Draw_Rect(40, 0, 280, 25, ENTRY_BAR_COLOR);
Gui::Draw_Rect(40, 25, 280, 1, ENTRY_BAR_OUTL_COLOR);
Gui::DrawStringCentered(17, 2, 0.6, TEXT_COLOR, "Queue System", 273, 0, font);
LightLock_Lock(&QueueSystem::lock);
if (!queueEntries.empty()) {
GFX::DrawBox(QueueBoxes[0].x, QueueBoxes[0].y, QueueBoxes[0].w, QueueBoxes[0].h, false);
C2D_DrawImageAt(queueEntries[0]->icn, QueueBoxes[0].x + 5, QueueBoxes[0].y + 21, 0.5f);
DrawStatus(queueEntries[0]->status);
}
LightLock_Unlock(&QueueSystem::lock);
}
void StoreUtils::QueueMenuHandle(int &queueIndex) {
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "queueSystem.hpp"
#include "storeUtils.hpp"
#include "structs.hpp"
#include <curl/curl.h>
extern u32 extractSize, writeOffset;
extern u32 installSize, installOffset;
extern u32 copyOffset, copySize;
extern curl_off_t downloadTotal;
extern curl_off_t downloadNow;
#define QUEUE_ENTRIES 2 // 2 Entries per screen or so.
extern bool touching(touchPosition touch, Structs::ButtonPos button);
/* TODO: Rework positions + sizes.. */
static const std::vector<Structs::ButtonPos> QueueBoxes = {
{ 46, 32, 266, 80 },
{ 46, 132, 266, 80 }
};
extern std::deque<std::unique_ptr<Queue>> queueEntries;
void DrawStatus(QueueStatus s) {
char str[256];
/* String Handle. */
switch(s) {
case QueueStatus::None:
case QueueStatus::Failed:
case QueueStatus::Done:
break;
case QueueStatus::Downloading:
if (downloadTotal < 1.0f) downloadTotal = 1.0f;
if (downloadTotal < downloadNow) downloadTotal = downloadNow;
snprintf(str, sizeof(str), "Downloading... %s / %s (%.2f%%)",
StringUtils::formatBytes(downloadNow).c_str(),
StringUtils::formatBytes(downloadTotal).c_str(),
((float)downloadNow/(float)downloadTotal) * 100.0f);
break;
case QueueStatus::Extracting:
snprintf(str, sizeof(str), "Extracting... %s / %s (%.2f%%)",
StringUtils::formatBytes(writeOffset).c_str(),
StringUtils::formatBytes(extractSize).c_str(),
((float)writeOffset/(float)extractSize) * 100.0f);
break;
case QueueStatus::Installing:
snprintf(str, sizeof(str), "Installing... %s / %s (%.2f%%)",
StringUtils::formatBytes(installOffset).c_str(),
StringUtils::formatBytes(installSize).c_str(),
((float)installOffset/(float)installSize) * 100.0f);
break;
}
/* Draw Handle. */
switch(s) {
case QueueStatus::None:
case QueueStatus::Failed:
case QueueStatus::Done:
break;
case QueueStatus::Downloading:
Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, TEXT_COLOR, str, 250, 0, font);
Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 25, 180, 30, BLACK);
Gui::Draw_Rect(QueueBoxes[0].x + 60 + 1, QueueBoxes[0].y + 25 + 1, (int)(((float)downloadNow / (float)downloadTotal) * 180.0f), 28, WHITE);
break;
case QueueStatus::Extracting:
Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, TEXT_COLOR, str, 250, 0, font);
Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 25, 180, 30, BLACK);
Gui::Draw_Rect(QueueBoxes[0].x + 60 + 1, QueueBoxes[0].y + 25 + 1, (int)(((float)writeOffset / (float)extractSize) * 180.0f), 28, WHITE);
break;
case QueueStatus::Installing:
Gui::DrawString(QueueBoxes[0].x + 10, QueueBoxes[0].y + 5, 0.4f, TEXT_COLOR, str, 250, 0, font);
Gui::Draw_Rect(QueueBoxes[0].x + 60, QueueBoxes[0].y + 25, 180, 30, BLACK);
Gui::Draw_Rect(QueueBoxes[0].x + 60 + 1, QueueBoxes[0].y + 25 + 1, (int)(((float)installOffset / (float)installSize) * 180.0f), 28, WHITE);
break;
}
}
void StoreUtils::DrawQueueMenu(const int queueIndex) {
Gui::Draw_Rect(40, 0, 280, 25, ENTRY_BAR_COLOR);
Gui::Draw_Rect(40, 25, 280, 1, ENTRY_BAR_OUTL_COLOR);
Gui::DrawStringCentered(17, 2, 0.6, TEXT_COLOR, "Queue System", 273, 0, font);
LightLock_Lock(&QueueSystem::lock);
if (!queueEntries.empty()) {
GFX::DrawBox(QueueBoxes[0].x, QueueBoxes[0].y, QueueBoxes[0].w, QueueBoxes[0].h, false);
C2D_DrawImageAt(queueEntries[0]->icn, QueueBoxes[0].x + 5, QueueBoxes[0].y + 21, 0.5f);
DrawStatus(queueEntries[0]->status);
}
LightLock_Unlock(&QueueSystem::lock);
}
void StoreUtils::QueueMenuHandle(int &queueIndex) {
}
+117 -117
View File
@@ -1,118 +1,118 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "download.hpp"
#include "storeUtils.hpp"
void StoreUtils::DrawReleaseNotes(const int &scrollIndex, const std::unique_ptr<StoreEntry> &entry, const std::unique_ptr<Store> &store) {
if (entry && store) {
Gui::ScreenDraw(Top);
Gui::Draw_Rect(0, 26, 400, 214, BG_COLOR);
Gui::DrawString(5, 25 - scrollIndex, 0.5f, TEXT_COLOR, entry->GetReleaseNotes(), 390, 0, font, C2D_WordWrap);
Gui::Draw_Rect(0, 0, 400, 25, BAR_COLOR);
Gui::Draw_Rect(0, 25, 400, 1, BAR_OUTL_COLOR);
Gui::DrawStringCentered(0, 1, 0.7f, TEXT_COLOR, entry->GetTitle(), 390, 0, font);
} else {
Gui::ScreenDraw(Top);
Gui::Draw_Rect(0, 0, 400, 25, BAR_COLOR);
Gui::Draw_Rect(0, 25, 400, 1, BAR_OUTL_COLOR);
Gui::Draw_Rect(0, 26, 400, 214, BG_COLOR);
}
}
/*
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 DarkStore.
*/
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, BG_COLOR);
Gui::DrawString(5, 25 - scrollIndex, 0.5f, TEXT_COLOR, notes, 390, 0, font, C2D_WordWrap);
Gui::Draw_Rect(0, 0, 400, 25, BAR_COLOR);
Gui::Draw_Rect(0, 25, 400, 1, BAR_OUTL_COLOR);
Gui::DrawStringCentered(0, 1, 0.7f, TEXT_COLOR, "DarkStore", 390, 0, font);
Gui::Draw_Rect(0, 215, 400, 25, BAR_COLOR);
Gui::Draw_Rect(0, 214, 400, 1, BAR_OUTL_COLOR);
Gui::DrawStringCentered(0, 217, 0.7f, TEXT_COLOR, C_V, 390, 0, font);
GFX::DrawBottom();
Gui::Draw_Rect(0, 0, 320, 25, BAR_COLOR);
Gui::Draw_Rect(0, 25, 320, 1, BAR_OUTL_COLOR);
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;
}
}
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "download.hpp"
#include "storeUtils.hpp"
void StoreUtils::DrawReleaseNotes(const int &scrollIndex, const std::unique_ptr<StoreEntry> &entry, const std::unique_ptr<Store> &store) {
if (entry && store) {
Gui::ScreenDraw(Top);
Gui::Draw_Rect(0, 26, 400, 214, BG_COLOR);
Gui::DrawString(5, 25 - scrollIndex, 0.5f, TEXT_COLOR, entry->GetReleaseNotes(), 390, 0, font, C2D_WordWrap);
Gui::Draw_Rect(0, 0, 400, 25, BAR_COLOR);
Gui::Draw_Rect(0, 25, 400, 1, BAR_OUTL_COLOR);
Gui::DrawStringCentered(0, 1, 0.7f, TEXT_COLOR, entry->GetTitle(), 390, 0, font);
} else {
Gui::ScreenDraw(Top);
Gui::Draw_Rect(0, 0, 400, 25, BAR_COLOR);
Gui::Draw_Rect(0, 25, 400, 1, BAR_OUTL_COLOR);
Gui::Draw_Rect(0, 26, 400, 214, BG_COLOR);
}
}
/*
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 DarkStore.
*/
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, BG_COLOR);
Gui::DrawString(5, 25 - scrollIndex, 0.5f, TEXT_COLOR, notes, 390, 0, font, C2D_WordWrap);
Gui::Draw_Rect(0, 0, 400, 25, BAR_COLOR);
Gui::Draw_Rect(0, 25, 400, 1, BAR_OUTL_COLOR);
Gui::DrawStringCentered(0, 1, 0.7f, TEXT_COLOR, "DarkStore", 390, 0, font);
Gui::Draw_Rect(0, 215, 400, 25, BAR_COLOR);
Gui::Draw_Rect(0, 214, 400, 1, BAR_OUTL_COLOR);
Gui::DrawStringCentered(0, 217, 0.7f, TEXT_COLOR, C_V, 390, 0, font);
GFX::DrawBottom();
Gui::Draw_Rect(0, 0, 320, 25, BAR_COLOR);
Gui::Draw_Rect(0, 25, 320, 1, BAR_OUTL_COLOR);
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;
}
}
}
+150 -150
View File
@@ -1,151 +1,151 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#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, BG_COLOR);
if (!canDisplay) {
GFX::DrawBottom();
if (screenshotSize > 0) { // if texture is nullptr AND screenshot size is larger than 0.
Gui::DrawStringCentered(0, 2, 0.6f, WHITE, Lang::get("SCREENSHOT_COULD_NOT_LOAD"), 310);
} else {
Gui::DrawStringCentered(0, 2, 0.6f, WHITE, 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;
}
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, BAR_COLOR);
Gui::Draw_Rect(0, 214, 320, 1, BAR_OUTL_COLOR);
Gui::DrawStringCentered(0, 220, 0.5f, TEXT_COLOR, 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, WHITE, screenshots, 310, 0, font);
Gui::DrawStringCentered(0, 40, 0.6f, WHITE, name, 310, 0, font);
}
} else {
GFX::DrawBottom();
Gui::DrawStringCentered(0, 2, 0.6f, WHITE, 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;
}
}
}
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#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, BG_COLOR);
if (!canDisplay) {
GFX::DrawBottom();
if (screenshotSize > 0) { // if texture is nullptr AND screenshot size is larger than 0.
Gui::DrawStringCentered(0, 2, 0.6f, WHITE, Lang::get("SCREENSHOT_COULD_NOT_LOAD"), 310);
} else {
Gui::DrawStringCentered(0, 2, 0.6f, WHITE, 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;
}
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, BAR_COLOR);
Gui::Draw_Rect(0, 214, 320, 1, BAR_OUTL_COLOR);
Gui::DrawStringCentered(0, 220, 0.5f, TEXT_COLOR, 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, WHITE, screenshots, 310, 0, font);
Gui::DrawStringCentered(0, 40, 0.6f, WHITE, name, 310, 0, font);
}
} else {
GFX::DrawBottom();
Gui::DrawStringCentered(0, 2, 0.6f, WHITE, 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;
}
}
}
}
+203 -203
View File
@@ -1,204 +1,204 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#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, 45, 262, 30 }, // Search bar.
/* Inclure. */
{ 85, 109, 50, 10 },
{ 85, 125, 50, 10 },
{ 167, 109, 50, 10 },
{ 167, 125, 50, 10 },
/* Filtrer. */
{ 82, 195, 30, 30 },
{ 117, 195, 30, 30 },
{ 152, 195, 30, 30 },
{ 187, 195, 30, 30 },
{ 222, 195, 30, 30 },
{ 257, 195, 30, 30 }
};
/*
Dessinez le menu Recherche + Filtre.
const std::vectorbool> &searchIncludes : Const Référence à la searchIncludes.
const std::string &searchResult : Const Référence à searchResult.
int marks : Les drapeaux de marque de filtre.
bool updateFilter : Le filtre de mise à jour.
*/
void StoreUtils::DrawSearchMenu(const std::vector<bool> &searchIncludes, const std::string &searchResult, int marks, bool updateFilter) {
Gui::Draw_Rect(40, 0, 280, 25, ENTRY_BAR_COLOR);
Gui::Draw_Rect(40, 25, 280, 1, ENTRY_BAR_OUTL_COLOR);
Gui::DrawStringCentered(21, 2, 0.6, TEXT_COLOR, Lang::get("SEARCH_FILTERS"), 269, 0, font);
Gui::Draw_Rect(50, 44, 264, SearchMenu[0].h + 2, SEARCH_BAR_OUTL_COLOR);
Gui::Draw_Rect(SearchMenu[0].x, SearchMenu[0].y, SearchMenu[0].w, SearchMenu[0].h, SEARCH_BAR_COLOR);
Gui::DrawStringCentered(24, 50, 0.6, TEXT_COLOR, 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, 85, 0.5, TEXT_COLOR, Lang::get("INCLUDE_IN_RESULTS"), 265, 0, font);
Gui::DrawString(SearchMenu[1].x + 18, SearchMenu[1].y + 1, 0.4, TEXT_COLOR, Lang::get("TITLE"), 90, 0, font);
Gui::DrawString(SearchMenu[2].x + 18, SearchMenu[2].y + 1, 0.4, TEXT_COLOR, Lang::get("AUTHOR"), 90, 0, font);
Gui::DrawString(SearchMenu[3].x + 18, SearchMenu[3].y + 1, 0.4, TEXT_COLOR, Lang::get("CATEGORY"), 90, 0, font);
Gui::DrawString(SearchMenu[4].x + 18, SearchMenu[4].y + 1, 0.4, TEXT_COLOR, Lang::get("CONSOLE"), 90, 0, font);
/* Filtrer. */
Gui::DrawString(84, 175, 0.5f, TEXT_COLOR, 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 ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::Draw_Rect(SearchMenu[6].x, SearchMenu[6].y, SearchMenu[6].w, SearchMenu[6].h, (marks & favoriteMarks::HEART ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::Draw_Rect(SearchMenu[7].x, SearchMenu[7].y, SearchMenu[7].w, SearchMenu[7].h, (marks & favoriteMarks::DIAMOND ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::Draw_Rect(SearchMenu[8].x, SearchMenu[8].y, SearchMenu[8].w, SearchMenu[8].h, (marks & favoriteMarks::CLUBS ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::Draw_Rect(SearchMenu[9].x, SearchMenu[9].y, SearchMenu[9].w, SearchMenu[9].h, (marks & favoriteMarks::SPADE ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::Draw_Rect(SearchMenu[10].x, SearchMenu[10].y, SearchMenu[10].w, SearchMenu[10].h, (updateFilter ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::DrawString(SearchMenu[5].x + 9, SearchMenu[5].y + 7, 0.5f, TEXT_COLOR, "", 0, 0, font);
Gui::DrawString(SearchMenu[6].x + 9, SearchMenu[6].y + 7, 0.5f, TEXT_COLOR, "", 0, 0, font);
Gui::DrawString(SearchMenu[7].x + 9, SearchMenu[7].y + 7, 0.5f, TEXT_COLOR, "", 0, 0, font);
Gui::DrawString(SearchMenu[8].x + 9, SearchMenu[8].y + 7, 0.5f, TEXT_COLOR, "", 0, 0, font);
Gui::DrawString(SearchMenu[9].x + 9, SearchMenu[9].y + 7, 0.5f, TEXT_COLOR, "", 0, 0, font);
GFX::DrawSprite(sprites_update_filter_idx, SearchMenu[10].x + 8, SearchMenu[10].y + 8);
}
/*
Rechercher + Filter Handle.
Ici vous pouvez..
- Filtrez les marques dans vos applications.
- Rechercher dans eShop.
- Inclure des éléments dans la recherche.
std::unique_ptrStore> &store : Référence à la classe Store.
std::vectorstd::unique_ptrStoreEntry>> &entries : Référence aux entrées du magasin.
std::vectorbool> &searchIncludes : Référence aux InclusionsRecherche.
std::unique_ptrMeta> &meta : Référence à la classe Meta.
std::string &searchResult : Référence à searchResult.
int &marks : Référence aux drapeaux de marque.
bool &updateFilter : référence au filtre de mise à jour.
*/
void StoreUtils::SearchHandle(std::unique_ptr<Store> &store, std::vector<std::unique_ptr<StoreEntry>> &entries, std::vector<bool> &searchIncludes, std::unique_ptr<Meta> &meta, std::string &searchResult, int &marks, bool &updateFilter, bool ascending, SortType sorttype) {
/* Checkboxes. */
if (hDown & KEY_TOUCH) {
bool didTouch = false;
/* Inclures. */
for (int i = 0; i < 4; i++) {
if (touching(touch, SearchMenu[i + 1])) {
searchIncludes[i] = !searchIncludes[i];
didTouch = true;
break;
}
}
/* Barres de Recherche. */
if (!didTouch) {
if (touching(touch, SearchMenu[0])) {
if (store) {
searchResult = Input::setkbdString(20, Lang::get("ENTER_SEARCH"), {});
didTouch = true;
} else {
searchResult = Input::setkbdString(20, Lang::get("ENTER_SEARCH"), {});
didTouch = true;
}
}
}
/* Filtrer. */
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;
}
}
if (didTouch) {
if (store && store->GetValid()) { // Ne cherchez que si cest valide.
StoreUtils::ResetAll(store, meta, entries);
StoreUtils::search(entries, searchResult, searchIncludes[0], searchIncludes[1], searchIncludes[2], searchIncludes[3], marks, updateFilter);
store->SetScreenIndx(0);
store->SetEntry(0);
store->SetBox(0);
StoreUtils::SortEntries(ascending, sorttype, entries);
}
}
}
/* Réinitialiser tout. */
if (hDown & KEY_X) {
marks = 0;
updateFilter = false;
for(uint i = 0; i < searchIncludes.size(); i++) searchIncludes[i] = false;
searchResult = "";
if (store && store->GetValid()) {
StoreUtils::ResetAll(store, meta, entries);
StoreUtils::SortEntries(ascending, sorttype, entries);
}
}
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#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, 45, 262, 30 }, // Search bar.
/* Inclure. */
{ 85, 109, 50, 10 },
{ 85, 125, 50, 10 },
{ 167, 109, 50, 10 },
{ 167, 125, 50, 10 },
/* Filtrer. */
{ 82, 195, 30, 30 },
{ 117, 195, 30, 30 },
{ 152, 195, 30, 30 },
{ 187, 195, 30, 30 },
{ 222, 195, 30, 30 },
{ 257, 195, 30, 30 }
};
/*
Dessinez le menu Recherche + Filtre.
const std::vectorbool> &searchIncludes : Const Référence à la searchIncludes.
const std::string &searchResult : Const Référence à searchResult.
int marks : Les drapeaux de marque de filtre.
bool updateFilter : Le filtre de mise à jour.
*/
void StoreUtils::DrawSearchMenu(const std::vector<bool> &searchIncludes, const std::string &searchResult, int marks, bool updateFilter) {
Gui::Draw_Rect(40, 0, 280, 25, ENTRY_BAR_COLOR);
Gui::Draw_Rect(40, 25, 280, 1, ENTRY_BAR_OUTL_COLOR);
Gui::DrawStringCentered(21, 2, 0.6, TEXT_COLOR, Lang::get("SEARCH_FILTERS"), 269, 0, font);
Gui::Draw_Rect(50, 44, 264, SearchMenu[0].h + 2, SEARCH_BAR_OUTL_COLOR);
Gui::Draw_Rect(SearchMenu[0].x, SearchMenu[0].y, SearchMenu[0].w, SearchMenu[0].h, SEARCH_BAR_COLOR);
Gui::DrawStringCentered(24, 50, 0.6, TEXT_COLOR, 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, 85, 0.5, TEXT_COLOR, Lang::get("INCLUDE_IN_RESULTS"), 265, 0, font);
Gui::DrawString(SearchMenu[1].x + 18, SearchMenu[1].y + 1, 0.4, TEXT_COLOR, Lang::get("TITLE"), 90, 0, font);
Gui::DrawString(SearchMenu[2].x + 18, SearchMenu[2].y + 1, 0.4, TEXT_COLOR, Lang::get("AUTHOR"), 90, 0, font);
Gui::DrawString(SearchMenu[3].x + 18, SearchMenu[3].y + 1, 0.4, TEXT_COLOR, Lang::get("CATEGORY"), 90, 0, font);
Gui::DrawString(SearchMenu[4].x + 18, SearchMenu[4].y + 1, 0.4, TEXT_COLOR, Lang::get("CONSOLE"), 90, 0, font);
/* Filtrer. */
Gui::DrawString(84, 175, 0.5f, TEXT_COLOR, 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 ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::Draw_Rect(SearchMenu[6].x, SearchMenu[6].y, SearchMenu[6].w, SearchMenu[6].h, (marks & favoriteMarks::HEART ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::Draw_Rect(SearchMenu[7].x, SearchMenu[7].y, SearchMenu[7].w, SearchMenu[7].h, (marks & favoriteMarks::DIAMOND ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::Draw_Rect(SearchMenu[8].x, SearchMenu[8].y, SearchMenu[8].w, SearchMenu[8].h, (marks & favoriteMarks::CLUBS ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::Draw_Rect(SearchMenu[9].x, SearchMenu[9].y, SearchMenu[9].w, SearchMenu[9].h, (marks & favoriteMarks::SPADE ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::Draw_Rect(SearchMenu[10].x, SearchMenu[10].y, SearchMenu[10].w, SearchMenu[10].h, (updateFilter ?
SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR));
Gui::DrawString(SearchMenu[5].x + 9, SearchMenu[5].y + 7, 0.5f, TEXT_COLOR, "", 0, 0, font);
Gui::DrawString(SearchMenu[6].x + 9, SearchMenu[6].y + 7, 0.5f, TEXT_COLOR, "", 0, 0, font);
Gui::DrawString(SearchMenu[7].x + 9, SearchMenu[7].y + 7, 0.5f, TEXT_COLOR, "", 0, 0, font);
Gui::DrawString(SearchMenu[8].x + 9, SearchMenu[8].y + 7, 0.5f, TEXT_COLOR, "", 0, 0, font);
Gui::DrawString(SearchMenu[9].x + 9, SearchMenu[9].y + 7, 0.5f, TEXT_COLOR, "", 0, 0, font);
GFX::DrawSprite(sprites_update_filter_idx, SearchMenu[10].x + 8, SearchMenu[10].y + 8);
}
/*
Rechercher + Filter Handle.
Ici vous pouvez..
- Filtrez les marques dans vos applications.
- Rechercher dans eShop.
- Inclure des éléments dans la recherche.
std::unique_ptrStore> &store : Référence à la classe Store.
std::vectorstd::unique_ptrStoreEntry>> &entries : Référence aux entrées du magasin.
std::vectorbool> &searchIncludes : Référence aux InclusionsRecherche.
std::unique_ptrMeta> &meta : Référence à la classe Meta.
std::string &searchResult : Référence à searchResult.
int &marks : Référence aux drapeaux de marque.
bool &updateFilter : référence au filtre de mise à jour.
*/
void StoreUtils::SearchHandle(std::unique_ptr<Store> &store, std::vector<std::unique_ptr<StoreEntry>> &entries, std::vector<bool> &searchIncludes, std::unique_ptr<Meta> &meta, std::string &searchResult, int &marks, bool &updateFilter, bool ascending, SortType sorttype) {
/* Checkboxes. */
if (hDown & KEY_TOUCH) {
bool didTouch = false;
/* Inclures. */
for (int i = 0; i < 4; i++) {
if (touching(touch, SearchMenu[i + 1])) {
searchIncludes[i] = !searchIncludes[i];
didTouch = true;
break;
}
}
/* Barres de Recherche. */
if (!didTouch) {
if (touching(touch, SearchMenu[0])) {
if (store) {
searchResult = Input::setkbdString(20, Lang::get("ENTER_SEARCH"), {});
didTouch = true;
} else {
searchResult = Input::setkbdString(20, Lang::get("ENTER_SEARCH"), {});
didTouch = true;
}
}
}
/* Filtrer. */
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;
}
}
if (didTouch) {
if (store && store->GetValid()) { // Ne cherchez que si cest valide.
StoreUtils::ResetAll(store, meta, entries);
StoreUtils::search(entries, searchResult, searchIncludes[0], searchIncludes[1], searchIncludes[2], searchIncludes[3], marks, updateFilter);
store->SetScreenIndx(0);
store->SetEntry(0);
store->SetBox(0);
StoreUtils::SortEntries(ascending, sorttype, entries);
}
}
}
/* Réinitialiser tout. */
if (hDown & KEY_X) {
marks = 0;
updateFilter = false;
for(uint i = 0; i < searchIncludes.size(); i++) searchIncludes[i] = false;
searchResult = "";
if (store && store->GetValid()) {
StoreUtils::ResetAll(store, meta, entries);
StoreUtils::SortEntries(ascending, sorttype, entries);
}
}
}
+611 -611
View File
File diff suppressed because it is too large Load Diff
+101 -101
View File
@@ -1,102 +1,102 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "animation.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 }
};
/*
Dessinez la partie Menu latéral.
int currentMenu : Le Mode Store / Menu courant.
*/
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, SIDEBAR_SELECTED_COLOR);
} else {
Gui::Draw_Rect(sidePos[i].x, sidePos[i].y, sidePos[i].w, sidePos[i].h, SIDEBAR_UNSELECTED_COLOR);
}
}
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, BAR_OUTL_COLOR);
}
/*
Poignée de menu latéral.
Ici vous pouvez..
- Basculer entre les menus à travers la barre latérale.
int tMenu : Référence au Mode Store / Menu.
bool &fetch : Référence de la variable download fetch.. donc nous savons, si nous avons besoin de récupérer les entrées de téléchargement.
int &lastMenu : Référence au dernier 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; // Récupérez la liste des téléchargements, si 1.
currentMenu = i;
break;
}
}
}
if (hRepeat & KEY_R) {
if (currentMenu < 5) {
lastMenu = currentMenu;
if (currentMenu + 1 == 1) fetch = true; // Récupérez la liste des téléchargements, si 1.
currentMenu++;
}
}
if (hRepeat & KEY_L) {
if (currentMenu > 0) {
lastMenu = currentMenu;
if (currentMenu - 1 == 1) fetch = true; // Récupérez la liste des téléchargements, si 1.
currentMenu--;
}
}
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "animation.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 }
};
/*
Dessinez la partie Menu latéral.
int currentMenu : Le Mode Store / Menu courant.
*/
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, SIDEBAR_SELECTED_COLOR);
} else {
Gui::Draw_Rect(sidePos[i].x, sidePos[i].y, sidePos[i].w, sidePos[i].h, SIDEBAR_UNSELECTED_COLOR);
}
}
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, BAR_OUTL_COLOR);
}
/*
Poignée de menu latéral.
Ici vous pouvez..
- Basculer entre les menus à travers la barre latérale.
int tMenu : Référence au Mode Store / Menu.
bool &fetch : Référence de la variable download fetch.. donc nous savons, si nous avons besoin de récupérer les entrées de téléchargement.
int &lastMenu : Référence au dernier 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; // Récupérez la liste des téléchargements, si 1.
currentMenu = i;
break;
}
}
}
if (hRepeat & KEY_R) {
if (currentMenu < 5) {
lastMenu = currentMenu;
if (currentMenu + 1 == 1) fetch = true; // Récupérez la liste des téléchargements, si 1.
currentMenu++;
}
}
if (hRepeat & KEY_L) {
if (currentMenu > 0) {
lastMenu = currentMenu;
if (currentMenu - 1 == 1) fetch = true; // Récupérez la liste des téléchargements, si 1.
currentMenu--;
}
}
}
+156 -156
View File
@@ -1,157 +1,157 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#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, ENTRY_BAR_COLOR);
Gui::Draw_Rect(40, 25, 280, 1, ENTRY_BAR_OUTL_COLOR);
Gui::DrawStringCentered(17, 2, 0.6, TEXT_COLOR, Lang::get("SORTING"), 273, 0, font);
/* Sort By. */
Gui::DrawString(buttons[0].x + 1, buttons[0].y - 20, 0.6f, TEXT_COLOR, 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, TEXT_COLOR, Lang::get("TITLE"), 80, 0, font);
Gui::DrawString(buttons[1].x + 21, buttons[1].y + 2, 0.4f, TEXT_COLOR, Lang::get("AUTHOR"), 80, 0, font);
Gui::DrawString(buttons[2].x + 21, buttons[2].y + 2, 0.4f, TEXT_COLOR, Lang::get("LAST_UPDATED"), 80, 0, font);
/* Direction. */
Gui::DrawString(buttons[3].x + 1, buttons[3].y - 20, 0.6f, TEXT_COLOR, Lang::get("DIRECTION"), 80, 0, font);
DrawCheck(3, asc);
DrawCheck(4, !asc);
Gui::DrawString(buttons[3].x + 21, buttons[3].y + 2, 0.4f, TEXT_COLOR, Lang::get("ASCENDING"), 80, 0, font);
Gui::DrawString(buttons[4].x + 21, buttons[4].y + 2, 0.4f, TEXT_COLOR, Lang::get("DESCENDING"), 80, 0, font);
/* Top Style. */
Gui::DrawString(buttons[5].x + 1, buttons[5].y - 20, 0.6f, TEXT_COLOR, 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, TEXT_COLOR, Lang::get("LIST"), 90, 0, font);
Gui::DrawString(buttons[6].x + 21, buttons[6].y + 2, 0.4f, TEXT_COLOR, 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.
std::unique_ptr<Store> &store: Reference to the Store class.
std::vector<std::unique_ptr<StoreEntry>> &entries: Reference to the StoreEntries.
bool &asc: Reference to the Ascending variable.
SortType &st: Reference to the SortType.
*/
void StoreUtils::SortHandle(std::unique_ptr<Store> &store, std::vector<std::unique_ptr<StoreEntry>> &entries, bool &asc, SortType &st) {
if (store && store->GetValid() && entries.size() > 0) { // Ensure, this is valid and more than 0 entries exist.
if (hDown & KEY_TOUCH) {
/* SortType Part. */
if (touching(touch, buttons[0])) {
st = SortType::TITLE;
StoreUtils::SortEntries(asc, st, entries);
} else if (touching(touch, buttons[1])) {
st = SortType::AUTHOR;
StoreUtils::SortEntries(asc, st, entries);
} else if (touching(touch, buttons[2])) {
st = SortType::LAST_UPDATED;
StoreUtils::SortEntries(asc, st, entries);
/* Ascending | Descending Part. */
} else if (touching(touch, buttons[3])) {
asc = true;
StoreUtils::SortEntries(asc, st, entries);
} else if (touching(touch, buttons[4])) {
asc = false;
StoreUtils::SortEntries(asc, st, entries);
} else if (touching(touch, buttons[5])) {
if (config->list()) return;
config->list(true);
store->SetEntry(0);
store->SetScreenIndx(0);
store->SetBox(0);
} else if (touching(touch, buttons[6])) {
if (!config->list()) return;
config->list(false);
store->SetEntry(0);
store->SetScreenIndx(0);
store->SetBox(0);
}
}
}
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2020 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#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, ENTRY_BAR_COLOR);
Gui::Draw_Rect(40, 25, 280, 1, ENTRY_BAR_OUTL_COLOR);
Gui::DrawStringCentered(17, 2, 0.6, TEXT_COLOR, Lang::get("SORTING"), 273, 0, font);
/* Sort By. */
Gui::DrawString(buttons[0].x + 1, buttons[0].y - 20, 0.6f, TEXT_COLOR, 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, TEXT_COLOR, Lang::get("TITLE"), 80, 0, font);
Gui::DrawString(buttons[1].x + 21, buttons[1].y + 2, 0.4f, TEXT_COLOR, Lang::get("AUTHOR"), 80, 0, font);
Gui::DrawString(buttons[2].x + 21, buttons[2].y + 2, 0.4f, TEXT_COLOR, Lang::get("LAST_UPDATED"), 80, 0, font);
/* Direction. */
Gui::DrawString(buttons[3].x + 1, buttons[3].y - 20, 0.6f, TEXT_COLOR, Lang::get("DIRECTION"), 80, 0, font);
DrawCheck(3, asc);
DrawCheck(4, !asc);
Gui::DrawString(buttons[3].x + 21, buttons[3].y + 2, 0.4f, TEXT_COLOR, Lang::get("ASCENDING"), 80, 0, font);
Gui::DrawString(buttons[4].x + 21, buttons[4].y + 2, 0.4f, TEXT_COLOR, Lang::get("DESCENDING"), 80, 0, font);
/* Top Style. */
Gui::DrawString(buttons[5].x + 1, buttons[5].y - 20, 0.6f, TEXT_COLOR, 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, TEXT_COLOR, Lang::get("LIST"), 90, 0, font);
Gui::DrawString(buttons[6].x + 21, buttons[6].y + 2, 0.4f, TEXT_COLOR, 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.
std::unique_ptr<Store> &store: Reference to the Store class.
std::vector<std::unique_ptr<StoreEntry>> &entries: Reference to the StoreEntries.
bool &asc: Reference to the Ascending variable.
SortType &st: Reference to the SortType.
*/
void StoreUtils::SortHandle(std::unique_ptr<Store> &store, std::vector<std::unique_ptr<StoreEntry>> &entries, bool &asc, SortType &st) {
if (store && store->GetValid() && entries.size() > 0) { // Ensure, this is valid and more than 0 entries exist.
if (hDown & KEY_TOUCH) {
/* SortType Part. */
if (touching(touch, buttons[0])) {
st = SortType::TITLE;
StoreUtils::SortEntries(asc, st, entries);
} else if (touching(touch, buttons[1])) {
st = SortType::AUTHOR;
StoreUtils::SortEntries(asc, st, entries);
} else if (touching(touch, buttons[2])) {
st = SortType::LAST_UPDATED;
StoreUtils::SortEntries(asc, st, entries);
/* Ascending | Descending Part. */
} else if (touching(touch, buttons[3])) {
asc = true;
StoreUtils::SortEntries(asc, st, entries);
} else if (touching(touch, buttons[4])) {
asc = false;
StoreUtils::SortEntries(asc, st, entries);
} else if (touching(touch, buttons[5])) {
if (config->list()) return;
config->list(true);
store->SetEntry(0);
store->SetScreenIndx(0);
store->SetBox(0);
} else if (touching(touch, buttons[6])) {
if (!config->list()) return;
config->list(false);
store->SetEntry(0);
store->SetScreenIndx(0);
store->SetBox(0);
}
}
}
}