mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-03 00:39:02 +00:00
See desc for more.
- Add WAV playback back with 10 MiB as max limit. - Some more Screenshot Menu checks.
This commit is contained in:
@@ -28,7 +28,9 @@
|
||||
#include "structs.hpp"
|
||||
|
||||
extern bool touching(touchPosition touch, Structs::ButtonPos button);
|
||||
static const Structs::ButtonPos btn = { 53, 215, 20, 20 };
|
||||
static const Structs::ButtonPos btn = { 53, 215, 24, 24 };
|
||||
static const Structs::ButtonPos sshot = { 83, 215, 24, 24 };
|
||||
extern bool checkWifiStatus();
|
||||
|
||||
/*
|
||||
Draw the Entry Info part.
|
||||
@@ -61,7 +63,8 @@ void StoreUtils::DrawEntryInfo(const std::unique_ptr<Store> &store, const std::u
|
||||
Gui::DrawString(61, 190, 0.45, TEXT_COLOR, Lang::get("LICENSE") + ": " + entry->GetLicense(), 240, 0, font);
|
||||
|
||||
GFX::DrawBox(btn.x, btn.y, btn.w, btn.h, false);
|
||||
Gui::DrawString(btn.x + 3, btn.y, 0.6f, TEXT_COLOR, "★", 0, 0, font);
|
||||
GFX::DrawSprite(sprites_screenshot_idx, sshot.x, sshot.y);
|
||||
Gui::DrawString(btn.x + 5, btn.y + 2, 0.6f, TEXT_COLOR, "★", 0, 0, font);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,12 +77,16 @@ void StoreUtils::DrawEntryInfo(const std::unique_ptr<Store> &store, const std::u
|
||||
|
||||
bool &showMark: Reference to showMark.. to show the mark menu.
|
||||
bool &fetch: Reference to fetch, so we know, if we need to fetch, when accessing download list.
|
||||
bool &sFetch: Reference to the screenshot fetch.
|
||||
int &mode: Reference to the Store mode.
|
||||
*/
|
||||
void StoreUtils::EntryHandle(bool &showMark, bool &fetch, bool &sFetch, int &mode) {
|
||||
if ((hDown & KEY_START) || (hDown & KEY_TOUCH && touching(touch, btn))) showMark = true;
|
||||
|
||||
if (hDown & KEY_SELECT) {
|
||||
sFetch = true;
|
||||
mode = 5;
|
||||
if ((hDown & KEY_SELECT) || (hDown & KEY_TOUCH && touching(touch, sshot))) {
|
||||
if (checkWifiStatus()) {
|
||||
sFetch = true;
|
||||
mode = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ static const std::vector<Structs::ButtonPos> markBox = {
|
||||
{ 196, 94, 52, 52 },
|
||||
{ 258, 94, 52, 52 },
|
||||
|
||||
{ 53, 215, 20, 20 }
|
||||
{ 53, 215, 24, 24 }
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -68,7 +68,7 @@ void StoreUtils::DisplayMarkBox(int marks) {
|
||||
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 + 3, markBox[5].y, 0.6f, TEXT_COLOR, "★", 0, 0, font);
|
||||
Gui::DrawString(markBox[5].x + 5, markBox[5].y + 2, 0.6f, TEXT_COLOR, "★", 0, 0, font);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "structs.hpp"
|
||||
|
||||
extern bool touching(touchPosition touch, Structs::ButtonPos button);
|
||||
extern bool checkWifiStatus();
|
||||
|
||||
/*
|
||||
Draw the Screenshot menu.
|
||||
@@ -38,56 +39,73 @@ extern bool touching(touchPosition touch, Structs::ButtonPos button);
|
||||
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) {
|
||||
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 (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;
|
||||
}
|
||||
|
||||
if (!canDisplay) {
|
||||
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;
|
||||
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::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);
|
||||
Gui::DrawStringCentered(0, 2, 0.6f, WHITE, Lang::get("NO_SCREENSHOTS_AVAILABLE"), 310);
|
||||
}
|
||||
|
||||
} else {
|
||||
GFX::DrawBottom();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,18 +117,22 @@ void StoreUtils::DrawScreenshotMenu(const C2D_Image &img, const int sIndex, cons
|
||||
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) {
|
||||
void StoreUtils::ScreenshotMenu(C2D_Image &img, int &sIndex, bool &sFetch, int &storeMode, const int screenshotSize, int &zoom, bool &canDisplay) {
|
||||
if (hDown & KEY_B) {
|
||||
zoom = false;
|
||||
canDisplay = false;
|
||||
zoom = 0;
|
||||
sIndex = 0;
|
||||
storeMode = 0; // Go back to EntryInfo.
|
||||
}
|
||||
|
||||
if (hDown & KEY_RIGHT) {
|
||||
if (sIndex < screenshotSize - 1) {
|
||||
sIndex++;
|
||||
sFetch = true;
|
||||
if ((hDown & KEY_RIGHT) || (hDown & KEY_R)) {
|
||||
if (checkWifiStatus()) {
|
||||
if (sIndex < screenshotSize - 1) {
|
||||
sIndex++;
|
||||
sFetch = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,10 +140,12 @@ void StoreUtils::ScreenshotMenu(C2D_Image &img, int &sIndex, bool &sFetch, int &
|
||||
|
||||
if (hDown & KEY_UP && zoom < 2) zoom++;
|
||||
|
||||
if (hDown & KEY_LEFT) {
|
||||
if (sIndex > 0) {
|
||||
sIndex--;
|
||||
sFetch = true;
|
||||
if ((hDown & KEY_LEFT) || (hDown & KEY_L)) {
|
||||
if (checkWifiStatus()) {
|
||||
if (sIndex > 0) {
|
||||
sIndex--;
|
||||
sFetch = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user