mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-03-21 17:24:37 -05:00
Tweak dialogs, fix white theme, add CPU boost for ZIP files
This commit is contained in:
parent
d18a048471
commit
5ae0d587c3
2
Makefile
2
Makefile
|
|
@ -38,7 +38,7 @@ INCLUDES := inc inc/ui
|
|||
EXEFS_SRC := exefs_src
|
||||
APP_TITLE := JKSV
|
||||
APP_AUTHOR := JK
|
||||
APP_VERSION := 07.22.2021
|
||||
APP_VERSION := 07.24.2021
|
||||
ROMFS := romfs
|
||||
ICON := icon.jpg
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#define curData users[data::selUser].titleInfo[data::selData]
|
||||
|
||||
#define BLD_MON 7
|
||||
#define BLD_DAY 22
|
||||
#define BLD_DAY 24
|
||||
#define BLD_YEAR 2021
|
||||
|
||||
namespace data
|
||||
|
|
|
|||
2
inc/ui.h
2
inc/ui.h
|
|
@ -64,7 +64,7 @@ namespace ui
|
|||
txtCont = text that contrasts clearClr
|
||||
txtDiag = text color for dialogs
|
||||
*/
|
||||
extern SDL_Color clearClr, transparent, txtCont, txtDiag, rectLt, rectSh, tboxClr, sideRect, divClr, heartColor, slidePanelColor, loadGlyphClr;
|
||||
extern SDL_Color clearClr, transparent, txtCont, txtDiag, rectLt, rectSh, tboxClr, sideRect, divClr, heartColor, slidePanelColor;
|
||||
|
||||
//Textbox graphics
|
||||
extern SDL_Texture *cornerTopLeft, *cornerTopRight, *cornerBottomLeft, *cornerBottomRight;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ namespace ui
|
|||
|
||||
//Stuff needed to keep track
|
||||
bool sel = 1;//1 = YES
|
||||
unsigned lgFrame = 0, frameCount = 0;//To count frames cause I don't have time and am lazy
|
||||
|
||||
} confirmArgs;
|
||||
|
||||
|
|
@ -155,7 +156,6 @@ namespace ui
|
|||
|
||||
//General use
|
||||
ui::confirmArgs *confirmArgsCreate(bool _hold, funcPtr _func, void *_funcArgs, bool _cleanup, const char *fmt, ...);
|
||||
void showMessage(const char *head, const char *fmt, ...);
|
||||
void confirm(void *a);
|
||||
bool confirmTransfer(const std::string& f, const std::string& t);
|
||||
bool confirmDelete(const std::string& p);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ namespace ui
|
|||
|
||||
private:
|
||||
std::vector<threadInfo *> threads;
|
||||
uint8_t lgFrame = 0;
|
||||
uint8_t lgFrame = 0, clrShft = 0;
|
||||
bool clrAdd = true;
|
||||
unsigned frameCount = 0;
|
||||
Mutex threadLock = 0;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ namespace ui
|
|||
bool active = false, showSel = false, clrAdd = true;
|
||||
uint8_t clrShft = 0;
|
||||
funcPtr callback = NULL;
|
||||
int x = 34, y = 69, selected = 0, selRectX = 10, selRectY = 45;
|
||||
int x = 34, y = 62, selected = 0, selRectX = 10, selRectY = 45;
|
||||
int iconW, iconH, horGap, vertGap, rowCount;
|
||||
std::vector<ui::titleTile *> tiles;
|
||||
};
|
||||
|
|
|
|||
14
src/file.cpp
14
src/file.cpp
|
|
@ -641,6 +641,8 @@ void copyDirToZip_t(void *a)
|
|||
delete list;
|
||||
if(args->cleanup)
|
||||
{
|
||||
if(data::config["ovrClk"])
|
||||
util::setCPU(1224000000);
|
||||
ui::newThread(closeZip_t, args->z, NULL);
|
||||
delete args->prog;
|
||||
delete args;
|
||||
|
|
@ -651,6 +653,11 @@ void copyDirToZip_t(void *a)
|
|||
|
||||
void fs::copyDirToZip(const std::string& from, zipFile to)
|
||||
{
|
||||
if(data::config["ovrClk"])
|
||||
{
|
||||
util::setCPU(1785000000);
|
||||
ui::showPopMessage(POP_FRAME_DEFAULT, "CPU Boost Enabled for ZIP.");
|
||||
}
|
||||
copyArgs *send = copyArgsCreate(from, "", "", to, NULL, true);
|
||||
ui::newThread(copyDirToZip_t, send, _fileDrawFunc);
|
||||
}
|
||||
|
|
@ -739,6 +746,8 @@ void copyZipToDir_t(void *a)
|
|||
{
|
||||
unzClose(args->unz);
|
||||
copyArgsDestroy(args);
|
||||
if(data::config["ovrClk"])
|
||||
util::setCPU(1224000000);
|
||||
}
|
||||
delete[] buff;
|
||||
t->finished = true;
|
||||
|
|
@ -746,6 +755,11 @@ void copyZipToDir_t(void *a)
|
|||
|
||||
void fs::copyZipToDir(unzFile unz, const std::string& to, const std::string& dev)
|
||||
{
|
||||
if(data::config["ovrClk"])
|
||||
{
|
||||
util::setCPU(1785000000);
|
||||
ui::showPopMessage(POP_FRAME_DEFAULT, "CPU Boost Enabled for ZIP.");
|
||||
}
|
||||
copyArgs *send = copyArgsCreate("", to, dev, NULL, unz, true);
|
||||
ui::newThread(copyZipToDir_t, send, _fileDrawFunc);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ std::string ui::folderMenuInfo;
|
|||
|
||||
//UI colors
|
||||
SDL_Color ui::clearClr, ui::txtCont, ui::txtDiag, ui::rectLt, ui::rectSh, ui::tboxClr, ui::divClr, ui::slidePanelColor;
|
||||
SDL_Color ui::transparent = {0x00, 0x00, 0x00, 0x00}, ui::loadGlyphClr = {0x00, 0xFF, 0xC5, 0xFF};
|
||||
SDL_Color ui::transparent = {0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
//textbox pieces
|
||||
//I was going to flip them when I draw them, but then laziness kicked in.
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@
|
|||
#include "util.h"
|
||||
#include "type.h"
|
||||
|
||||
static const char *okt = "OK \ue0e0";
|
||||
|
||||
static const SDL_Color divLight = {0x6D, 0x6D, 0x6D, 0xFF};
|
||||
static const SDL_Color divDark = {0xCC, 0xCC, 0xCC, 0xFF};
|
||||
static const SDL_Color shadow = {0x66, 0x66, 0x66, 0xFF};
|
||||
|
|
@ -258,7 +256,7 @@ void ui::progBar::update(const uint64_t& _prog)
|
|||
prog = _prog;
|
||||
|
||||
if(max > 0)
|
||||
width = (float)((float)prog / (float)max) * 576.0f;
|
||||
width = (float)((float)prog / (float)max) * 648.0f;
|
||||
}
|
||||
|
||||
void ui::progBar::draw(const std::string& text)
|
||||
|
|
@ -267,11 +265,12 @@ void ui::progBar::draw(const std::string& text)
|
|||
sprintf(progStr, "%.2fMB / %.2fMB", (float)prog / 1024.0f / 1024.0f, (float)max / 1024.0f / 1024.0f);
|
||||
int progX = 640 - (gfx::getTextWidth(progStr, 18) / 2);
|
||||
|
||||
ui::drawTextbox(NULL, 320, 262, 640, 256);
|
||||
gfx::drawRect(NULL, &fillBack, 352, 464, 576, 32);
|
||||
gfx::drawRect(NULL, &fillBar, 352, 464, (int)width, 32);
|
||||
gfx::drawTextf(NULL, 18, progX, 471, &ui::txtCont, progStr);
|
||||
gfx::drawTextfWrap(NULL, 16, 352, 288, 576, &ui::txtCont, text.c_str());
|
||||
ui::drawTextbox(NULL, 280, 262, 720, 256);
|
||||
gfx::drawLine(NULL, &ui::rectSh, 280, 454, 999, 454);
|
||||
gfx::drawRect(NULL, &fillBack, 312, 471, 648, 32);
|
||||
gfx::drawRect(NULL, &fillBar, 312, 471, (int)width, 32);
|
||||
gfx::drawTextf(NULL, 18, progX, 478, &ui::txtCont, progStr);
|
||||
gfx::drawTextfWrap(NULL, 16, 312, 288, 648, &ui::txtCont, text.c_str());
|
||||
}
|
||||
|
||||
ui::popMessageMngr::~popMessageMngr()
|
||||
|
|
@ -317,33 +316,6 @@ void ui::popMessageMngr::draw()
|
|||
}
|
||||
}
|
||||
|
||||
void ui::showMessage(const char *head, const char *fmt, ...)
|
||||
{
|
||||
char tmp[1024];
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vsprintf(tmp, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
unsigned headX = (640 / 2) - (gfx::getTextWidth(head, 20) / 2);
|
||||
unsigned okX = (640 / 2) - (gfx::getTextWidth(okt, 20) / 2);
|
||||
|
||||
while(true)
|
||||
{
|
||||
ui::updateInput();
|
||||
|
||||
if(ui::padKeysDown())
|
||||
break;
|
||||
|
||||
ui::drawTextbox(NULL, 320, 150, 640, 420);
|
||||
gfx::drawTextf(NULL, 20, 320 + headX, 168, &ui::txtDiag, head);
|
||||
gfx::drawTextfWrap(NULL, 16, 352, 230, 576, &ui::txtDiag, tmp);
|
||||
gfx::drawTextf(NULL, 20, 320 + okX, 522, &ui::txtDiag, okt);
|
||||
gfx::present();
|
||||
}
|
||||
ui::updateInput();
|
||||
}
|
||||
|
||||
ui::confirmArgs *ui::confirmArgsCreate(bool _hold, funcPtr _func, void *_funcArgs, bool _cleanup, const char *fmt, ...)
|
||||
{
|
||||
char tmp[1024];
|
||||
|
|
@ -370,15 +342,29 @@ void confirm_t(void *a)
|
|||
|
||||
while(true)
|
||||
{
|
||||
if(ui::padKeysDown() & HidNpadButton_A)
|
||||
uint64_t down = ui::padKeysDown();
|
||||
uint64_t held = ui::padKeysHeld();
|
||||
|
||||
if((down & HidNpadButton_A) && !c->hold)
|
||||
{
|
||||
ui::newThread(c->func, c->args, NULL);
|
||||
break;
|
||||
}
|
||||
else if(ui::padKeysDown() & HidNpadButton_B)
|
||||
else if((held & HidNpadButton_A) && c->hold)
|
||||
{
|
||||
if(c->frameCount % 4 == 0 && ++c->lgFrame > 7)
|
||||
c->lgFrame = 0;
|
||||
|
||||
if(c->frameCount >= 120)
|
||||
{
|
||||
ui::newThread(c->func, c->args, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(down & HidNpadButton_B)
|
||||
break;
|
||||
|
||||
svcSleepThread(1000000);
|
||||
svcSleepThread(10000000);//Close enough
|
||||
}
|
||||
if(c->cleanup)
|
||||
delete c;
|
||||
|
|
@ -393,10 +379,33 @@ void confirmDrawFunc(void *a)
|
|||
ui::confirmArgs *c = (ui::confirmArgs *)t->argPtr;
|
||||
if(!t->finished)
|
||||
{
|
||||
ui::drawTextbox(NULL, 320, 262, 640, 256);
|
||||
gfx::drawTextfWrap(NULL, 16, 352, 288, 576, &ui::txtCont, c->text.c_str());
|
||||
gfx::drawTextf(NULL, 18, 320 + 128, 476, &ui::txtCont, ui::yt.c_str());
|
||||
gfx::drawTextf(NULL, 18, 960 - 208, 476, &ui::txtCont, ui::nt.c_str());
|
||||
std::string yesTxt = ui::yt;
|
||||
unsigned yesX = 0;
|
||||
|
||||
if((ui::padKeysHeld() & HidNpadButton_A) && c->hold)
|
||||
{
|
||||
c->frameCount++;
|
||||
if(c->frameCount <= 40)
|
||||
yesTxt = ui::holdingText[0];
|
||||
else if(c->frameCount <= 80)
|
||||
yesTxt = ui::holdingText[1];
|
||||
else if(c->frameCount <= 120)
|
||||
yesTxt = ui::holdingText[2];
|
||||
|
||||
yesTxt += ui::loadGlyphArray[c->lgFrame];
|
||||
}
|
||||
else
|
||||
c->frameCount = 0;
|
||||
|
||||
|
||||
//I positioned these by eye. They're probably off.
|
||||
yesX = 458 - (gfx::getTextWidth(yesTxt.c_str(), 18) / 2);
|
||||
ui::drawTextbox(NULL, 280, 262, 720, 256);
|
||||
gfx::drawTextfWrap(NULL, 16, 312, 288, 656, &ui::txtCont, c->text.c_str());
|
||||
gfx::drawLine(NULL, &ui::rectSh, 280, 454, 999, 454);
|
||||
gfx::drawLine(NULL, &ui::rectSh, 640, 454, 640, 518);
|
||||
gfx::drawTextf(NULL, 18, yesX, 478, &ui::txtCont, yesTxt.c_str());
|
||||
gfx::drawTextf(NULL, 18, 782, 478, &ui::txtCont, ui::nt.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
#include "ui.h"
|
||||
#include "gfx.h"
|
||||
|
||||
//Thread status screen always using white
|
||||
static const SDL_Color white = {0xFF, 0xFF, 0xFF, 0xFF};
|
||||
static const SDL_Color darkenBack = {0x00, 0x00, 0x00, 0xBB};
|
||||
|
||||
ui::threadProcMngr::~threadProcMngr()
|
||||
|
|
@ -68,8 +70,16 @@ void ui::threadProcMngr::draw()
|
|||
if(++frameCount % 4 == 0 && ++lgFrame > 7)
|
||||
lgFrame = 0;
|
||||
|
||||
if(clrAdd && (clrShft += 6) >= 0x72)
|
||||
clrAdd = false;
|
||||
else if(!clrAdd && (clrShft -= 3) <= 0x00)
|
||||
clrAdd = true;
|
||||
|
||||
|
||||
SDL_Color glyphCol = {0x00, (uint8_t)(0x88 + clrShft), (uint8_t)(0xC5 + (clrShft / 2)), 0xFF};
|
||||
|
||||
gfx::drawRect(NULL, &darkenBack, 0, 0, 1280, 720);
|
||||
gfx::drawTextf(NULL, 32, 56, 673, &ui::loadGlyphClr, loadGlyphArray[lgFrame].c_str());
|
||||
gfx::drawTextf(NULL, 32, 56, 673, &glyphCol, loadGlyphArray[lgFrame].c_str());
|
||||
if(threads[0]->drawFunc)
|
||||
(*(threads[0]->drawFunc))(threads[0]);
|
||||
else
|
||||
|
|
@ -78,6 +88,6 @@ void ui::threadProcMngr::draw()
|
|||
threads[0]->status->getStatus(gStatus);
|
||||
|
||||
int statX = 640 - (gfx::getTextWidth(gStatus.c_str(), 18) / 2);
|
||||
gfx::drawTextf(NULL, 18, statX, 387, &ui::txtCont, gStatus.c_str());
|
||||
gfx::drawTextf(NULL, 18, statX, 387, &white, gStatus.c_str());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ static ui::menu *ttlOpts, *fldMenu;
|
|||
static ui::slideOutPanel *ttlOptsPanel, *infoPanel, *fldPanel;//There's no reason to have a separate folder section
|
||||
static fs::dirList *fldList;
|
||||
static fs::backupArgs *backargs;
|
||||
static ui::confirmArgs *overwriteArgs, *deleteArgs, *restArgs;
|
||||
static std::string infoPanelString;
|
||||
|
||||
void ui::refreshAllViews()
|
||||
|
|
@ -20,6 +19,47 @@ void ui::refreshAllViews()
|
|||
ttlViews[i]->refresh();
|
||||
}
|
||||
|
||||
static void fldFuncOverwrite(void *a)
|
||||
{
|
||||
fs::backupArgs *b = (fs::backupArgs *)a;
|
||||
fs::dirList *d = (fs::dirList *)b->d;
|
||||
ui::menu *m = (ui::menu *)b->m;
|
||||
|
||||
int sel = m->getSelected() - 1;//Skip 'New'
|
||||
std::string itm = d->getItem(sel);
|
||||
|
||||
ui::confirmArgs *conf = ui::confirmArgsCreate(data::config["holdOver"], fs::overwriteBackup, a, true, ui::confOverwrite.c_str(), itm.c_str());
|
||||
ui::confirm(conf);
|
||||
}
|
||||
|
||||
static void fldFuncDelete(void *a)
|
||||
{
|
||||
fs::backupArgs *b = (fs::backupArgs *)a;
|
||||
fs::dirList *d = (fs::dirList *)b->d;
|
||||
ui::menu *m = (ui::menu *)b->m;
|
||||
|
||||
int sel = m->getSelected() - 1;//Skip 'New'
|
||||
std::string itm = d->getItem(sel);
|
||||
|
||||
ui::confirmArgs *conf = ui::confirmArgsCreate(data::config["holdDel"], fs::deleteBackup, a, true, ui::confDel.c_str(), itm.c_str());
|
||||
ui::confirm(conf);
|
||||
}
|
||||
|
||||
static void fldFuncRestore(void *a)
|
||||
{
|
||||
fs::backupArgs *b = (fs::backupArgs *)a;
|
||||
fs::dirList *d = (fs::dirList *)b->d;
|
||||
ui::menu *m = (ui::menu *)b->m;
|
||||
|
||||
int sel = m->getSelected() - 1;//Skip 'New'
|
||||
std::string itm = d->getItem(sel);
|
||||
|
||||
ui::confirmArgs *conf = ui::confirmArgsCreate(data::config["holdRest"], fs::restoreBackup, a, true, ui::confRestore.c_str(), itm.c_str());
|
||||
ui::confirm(conf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ui::populateFldMenu()
|
||||
{
|
||||
fldMenu->reset();
|
||||
|
|
@ -31,10 +71,6 @@ void ui::populateFldMenu()
|
|||
fs::loadPathFilters(targetDir + "pathFilters.txt");
|
||||
|
||||
*backargs = {fldMenu, fldList};
|
||||
//todo: text stuff
|
||||
*overwriteArgs = {"Overwrite?", data::config["holdOver"], false, fs::overwriteBackup, backargs};
|
||||
*deleteArgs = {"Delete?", data::config["holdDel"], false, fs::deleteBackup, backargs};
|
||||
*restArgs = {"Restore?", data::config["holdRest"], false, fs::restoreBackup, backargs};
|
||||
|
||||
fldMenu->addOpt(NULL, "New");
|
||||
fldMenu->optAddButtonEvent(0, HidNpadButton_A, fs::createNewBackup, backargs);
|
||||
|
|
@ -43,9 +79,9 @@ void ui::populateFldMenu()
|
|||
{
|
||||
fldMenu->addOpt(NULL, fldList->getItem(i));
|
||||
|
||||
fldMenu->optAddButtonEvent(i + 1, HidNpadButton_A, confirm, overwriteArgs);
|
||||
fldMenu->optAddButtonEvent(i + 1, HidNpadButton_X, confirm, deleteArgs);
|
||||
fldMenu->optAddButtonEvent(i + 1, HidNpadButton_Y, confirm, restArgs);
|
||||
fldMenu->optAddButtonEvent(i + 1, HidNpadButton_A, fldFuncOverwrite, backargs);
|
||||
fldMenu->optAddButtonEvent(i + 1, HidNpadButton_X, fldFuncDelete, backargs);
|
||||
fldMenu->optAddButtonEvent(i + 1, HidNpadButton_Y, fldFuncRestore, backargs);
|
||||
}
|
||||
|
||||
fldMenu->setActive(true);
|
||||
|
|
@ -321,9 +357,6 @@ void ui::ttlInit()
|
|||
|
||||
fldList = new fs::dirList;
|
||||
backargs = new fs::backupArgs;
|
||||
overwriteArgs = new ui::confirmArgs;
|
||||
deleteArgs = new ui::confirmArgs;
|
||||
restArgs = new ui::confirmArgs;
|
||||
|
||||
ttlOpts->setActive(false);
|
||||
ttlOpts->addOpt(NULL, ui::titleOptString[0]);
|
||||
|
|
@ -353,9 +386,6 @@ void ui::ttlExit()
|
|||
delete fldMenu;
|
||||
delete fldList;
|
||||
delete backargs;
|
||||
delete overwriteArgs;
|
||||
delete deleteArgs;
|
||||
delete restArgs;
|
||||
}
|
||||
|
||||
void ui::ttlSetActive(int usr)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ std::string ui::userHelp = "[A] Select [X] User Options";
|
|||
std::string ui::titleHelp = "[A] Select [L][R] Jump [Y] Favorite [X] Title Options [B] Back";
|
||||
std::string ui::folderHelp = "[A] Select [Y] Restore [X] Delete [B] Close";
|
||||
std::string ui::optHelp = "[A] Toggle [X] Defaults [B] Back";
|
||||
std::string ui::yt = "Yes [A]", ui::nt = "No [B]";
|
||||
std::string ui::yt = "Yes [A]", ui::nt = "No [B]";
|
||||
std::string ui::on = ">On>", ui::off = "Off";
|
||||
std::string ui::confBlacklist = "Are you sure you want to add #%s# to your blacklist?";
|
||||
std::string ui::confOverwrite = "Are you sure you want to overwrite #%s#?";
|
||||
|
|
@ -208,7 +208,7 @@ void ui::loadTrans()
|
|||
break;
|
||||
|
||||
default:
|
||||
ui::showMessage("*Translation File Error:*", "On Line: %s\n*%s* is not a known or valid string name.", lang.getLine(), lang.getName());
|
||||
fs::logWrite("Translation File Error -> On Line: %s: '%s' is not a known or valid string name.\n", lang.getLine().c_str(), lang.getName().c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user