mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-04-24 15:27:10 -05:00
Add hold. Fix more stuff I missed.
This commit is contained in:
parent
6bcd0f2e83
commit
0514cd2c59
2
Makefile
2
Makefile
|
|
@ -38,7 +38,7 @@ INCLUDES := inc
|
|||
EXEFS_SRC := exefs_src
|
||||
APP_TITLE := JKSV
|
||||
APP_AUTHOR := JK
|
||||
APP_VERSION := 03.24.2020
|
||||
APP_VERSION := 03.27.2020
|
||||
ROMFS := romfs
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef MISCUI_H
|
||||
#define MISCUI_H
|
||||
|
||||
#include "gfx.h"
|
||||
|
||||
enum buttonEvents
|
||||
{
|
||||
BUTTON_NOTHING,
|
||||
|
|
@ -44,12 +46,14 @@ namespace ui
|
|||
{
|
||||
public:
|
||||
button(const std::string& _txt, unsigned _x, unsigned _y, unsigned _w, unsigned _h);
|
||||
void setText(const std::string& _txt);
|
||||
void update(const touchPosition& p);
|
||||
bool isOver();
|
||||
bool wasOver();
|
||||
int getEvent() { return retEvent; }
|
||||
|
||||
void draw();
|
||||
void draw(const clr& _txt);
|
||||
|
||||
unsigned getX() { return x; }
|
||||
unsigned getY() { return y; }
|
||||
|
|
@ -83,7 +87,7 @@ namespace ui
|
|||
|
||||
//General use
|
||||
void showMessage(const std::string& mess, const std::string& head);
|
||||
bool confirm(const std::string& q);
|
||||
bool confirm(const std::string& q, bool hold);
|
||||
bool confirmTransfer(const std::string& f, const std::string& t);
|
||||
bool confirmDelete(const std::string& p);
|
||||
void drawTextbox(int x, int y, int w, int h);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#include "util.h"
|
||||
#include "file.h"
|
||||
|
||||
#define VER_STRING "v. 03.24.2020"
|
||||
#define VER_STRING "v. 03.27.2020"
|
||||
|
||||
//Nav buttons
|
||||
std::vector<ui::button> usrNav, ttlNav, fldNav;
|
||||
|
|
|
|||
|
|
@ -115,11 +115,33 @@ namespace ui
|
|||
{
|
||||
std::string confStr = "Are you 100% sure you want to add \"" + data::curUser.titles[titleMenu.getSelected()].getTitle() + \
|
||||
"\" to your blacklist?";
|
||||
if(ui::confirm(confStr))
|
||||
if(ui::confirm(confStr, false))
|
||||
data::blacklistAdd(data::curUser, data::curUser.titles[titleMenu.getSelected()]);
|
||||
}
|
||||
else if(down & KEY_B || ttlNav[3].getEvent() == BUTTON_RELEASED)
|
||||
mstate = CLS_USR;
|
||||
else if(down & KEY_L)
|
||||
{
|
||||
data::selUser--;
|
||||
if(data::selUser < 0)
|
||||
data::selUser = data::users.size() -1;
|
||||
|
||||
data::curUser = data::users[data::selUser];
|
||||
clsTitlePrep(data::curUser);
|
||||
|
||||
ui::showPopup(data::curUser.getUsername(), POP_FRAME_DEFAULT);
|
||||
}
|
||||
else if(down & KEY_R)
|
||||
{
|
||||
data::selUser++;
|
||||
if(data::selUser > (int)data::users.size() - 1)
|
||||
data::selUser = 0;
|
||||
|
||||
data::curUser = data::users[data::selUser];
|
||||
clsTitlePrep(data::curUser);
|
||||
|
||||
ui::showPopup(data::curUser.getUsername(), POP_FRAME_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
void classicFolderMenuUpdate(const uint64_t& down, const uint64_t& held, const touchPosition& p)
|
||||
|
|
@ -173,7 +195,7 @@ namespace ui
|
|||
fs::dirList list(scanPath);
|
||||
|
||||
std::string folderName = list.getItem(folderMenu.getSelected() - 1);
|
||||
if(confirm("Are you sure you want to overwrite \"" + folderName + "\"?"))
|
||||
if(confirm("Are you sure you want to overwrite \"" + folderName + "\"?", true))
|
||||
{
|
||||
std::string toPath = util::getTitleDir(data::curUser, data::curData) + folderName + "/";
|
||||
//Delete and recreate
|
||||
|
|
@ -188,28 +210,23 @@ namespace ui
|
|||
}
|
||||
else if(down & KEY_Y || fldNav[1].getEvent() == BUTTON_RELEASED)
|
||||
{
|
||||
if(data::curData.getType() != FsSaveDataType_SystemBcat)
|
||||
if(folderMenu.getSelected() > 0)
|
||||
{
|
||||
if(folderMenu.getSelected() > 0)
|
||||
std::string scanPath = util::getTitleDir(data::curUser, data::curData);
|
||||
fs::dirList list(scanPath);
|
||||
|
||||
std::string folderName = list.getItem(folderMenu.getSelected() - 1);
|
||||
if(confirm("Are you sure you want to restore \"" + folderName + "\"?", true))
|
||||
{
|
||||
std::string scanPath = util::getTitleDir(data::curUser, data::curData);
|
||||
fs::dirList list(scanPath);
|
||||
std::string fromPath = util::getTitleDir(data::curUser, data::curData) + folderName + "/";
|
||||
std::string root = "sv:/";
|
||||
|
||||
std::string folderName = list.getItem(folderMenu.getSelected() - 1);
|
||||
if(confirm("Are you sure you want to restore \"" + folderName + "\"?"))
|
||||
{
|
||||
std::string fromPath = util::getTitleDir(data::curUser, data::curData) + folderName + "/";
|
||||
std::string root = "sv:/";
|
||||
fs::delDir(root);
|
||||
fsdevCommitDevice("sv");
|
||||
|
||||
fs::delDir(root);
|
||||
fsdevCommitDevice("sv");
|
||||
|
||||
fs::copyDirToDirCommit(fromPath, root, "sv");
|
||||
}
|
||||
fs::copyDirToDirCommit(fromPath, root, "sv");
|
||||
}
|
||||
}
|
||||
else
|
||||
ui::showMessage("Writing data to system save data is not allowed currently. It CAN brick your system.", "Sorry, bro:");
|
||||
}
|
||||
else if(down & KEY_X || fldNav[2].getEvent() == BUTTON_RELEASED)
|
||||
{
|
||||
|
|
@ -219,7 +236,7 @@ namespace ui
|
|||
fs::dirList list(scanPath);
|
||||
|
||||
std::string folderName = list.getItem(folderMenu.getSelected() - 1);
|
||||
if(confirm("Are you sure you want to delete \"" + folderName + "\"?"))
|
||||
if(confirm("Are you sure you want to delete \"" + folderName + "\"?", true))
|
||||
{
|
||||
std::string delPath = scanPath + folderName + "/";
|
||||
fs::delDir(delPath);
|
||||
|
|
@ -431,7 +448,7 @@ namespace ui
|
|||
}
|
||||
fsdevUnmountDevice("sv");
|
||||
|
||||
if(ui::confirm("System needs to be restarted for nag to go away. Reboot now?"))
|
||||
if(ui::confirm("System needs to be restarted for nag to go away. Reboot now?", false))
|
||||
{
|
||||
bpcInitialize();
|
||||
bpcRebootSystem();
|
||||
|
|
@ -459,7 +476,7 @@ namespace ui
|
|||
fsdevUnmountDevice("sv");
|
||||
std::string idStr = util::getStringInput("8000000000000000", "Enter Sys Save ID", 18, 0, NULL);
|
||||
uint64_t mountID = std::strtoull(idStr.c_str(), NULL, 16);
|
||||
if(R_SUCCEEDED(fsOpen_SystemSaveData(&sv, FsSaveDataSpaceId_System, mountID, (AccountUid){0})))
|
||||
if(R_SUCCEEDED(fsOpen_SystemSaveData(&sv, FsSaveDataSpaceId_System, mountID, (AccountUid) {0})))
|
||||
{
|
||||
fsdevMountDevice("sv", sv);
|
||||
advModePrep("sv:/", true);
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ namespace ui
|
|||
fs::dirList list(scanPath);
|
||||
|
||||
std::string folderName = list.getItem(folderMenu.getSelected() - 1);
|
||||
if(confirm("Are you sure you want to overwrite \"" + folderName + "\"?"))
|
||||
if(confirm("Are you sure you want to overwrite \"" + folderName + "\"?", true))
|
||||
{
|
||||
std::string toPath = util::getTitleDir(data::curUser, data::curData) + folderName + "/";
|
||||
//Delete and recreate
|
||||
|
|
@ -105,7 +105,7 @@ namespace ui
|
|||
fs::dirList list(scanPath);
|
||||
|
||||
std::string folderName = list.getItem(folderMenu.getSelected() - 1);
|
||||
if(confirm("Are you sure you want to restore \"" + folderName + "\"?"))
|
||||
if(confirm("Are you sure you want to restore \"" + folderName + "\"?", false))
|
||||
{
|
||||
std::string fromPath = util::getTitleDir(data::curUser, data::curData) + folderName + "/";
|
||||
std::string root = "sv:/";
|
||||
|
|
@ -125,7 +125,7 @@ namespace ui
|
|||
fs::dirList list(scanPath);
|
||||
|
||||
std::string folderName = list.getItem(folderMenu.getSelected() - 1);
|
||||
if(confirm("Are you sure you want to delete \"" + folderName + "\"?"))
|
||||
if(confirm("Are you sure you want to delete \"" + folderName + "\"?", true))
|
||||
{
|
||||
std::string delPath = scanPath + folderName + "/";
|
||||
fs::delDir(delPath);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,13 @@ enum popStates
|
|||
popFall
|
||||
};
|
||||
|
||||
//8
|
||||
static const std::string loadGlyphArray[] =
|
||||
{
|
||||
"\ue020", "\ue021", "\ue022", "\ue023", "\ue024",
|
||||
"\ue025", "\ue026", "\ue027"
|
||||
};
|
||||
|
||||
namespace ui
|
||||
{
|
||||
progBar::progBar(const uint64_t& _max)
|
||||
|
|
@ -65,6 +72,17 @@ namespace ui
|
|||
ty = y + (h / 2) - (th / 2);
|
||||
}
|
||||
|
||||
void button::setText(const std::string& _txt)
|
||||
{
|
||||
text = _txt;
|
||||
|
||||
unsigned tw = textGetWidth(text.c_str(), ui::shared, 24);
|
||||
unsigned th = 24;
|
||||
|
||||
tx = x + (w / 2) - (tw / 2);
|
||||
ty = y + (h / 2) - (th / 2);
|
||||
}
|
||||
|
||||
void button::update(const touchPosition& p)
|
||||
{
|
||||
prev = cur;
|
||||
|
|
@ -115,6 +133,20 @@ namespace ui
|
|||
}
|
||||
}
|
||||
|
||||
void button::draw(const clr& _txt)
|
||||
{
|
||||
if(pressed)
|
||||
{
|
||||
ui::drawTextboxInvert(x, y, w, h);
|
||||
drawText(text.c_str(), frameBuffer, ui::shared, tx, ty, 24, _txt);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui::drawTextbox(x, y, w, h);
|
||||
drawText(text.c_str(), frameBuffer, ui::shared, tx, ty, 24, _txt);
|
||||
}
|
||||
}
|
||||
|
||||
void touchTrack::update(const touchPosition& p)
|
||||
{
|
||||
if(hidTouchCount() > 0)
|
||||
|
|
@ -189,9 +221,12 @@ namespace ui
|
|||
}
|
||||
}
|
||||
|
||||
bool confirm(const std::string& mess)
|
||||
bool confirm(const std::string& mess, bool hold)
|
||||
{
|
||||
bool ret = false;
|
||||
bool ret = false, heldDown = false;
|
||||
unsigned loadFrame = 0, holdCount = 0;
|
||||
uint8_t holdClrDiff = 0;
|
||||
clr holdClr;
|
||||
|
||||
button yes("Yes \ue0e0", 256, 496, 384, 96);
|
||||
button no("No \ue0e1", 640, 496, 384, 96);
|
||||
|
|
@ -199,18 +234,48 @@ namespace ui
|
|||
size_t headWidth = textGetWidth("Confirm", ui::shared, 24);
|
||||
unsigned headX = (1280 / 2) - (headWidth / 2);
|
||||
|
||||
|
||||
while(true)
|
||||
{
|
||||
hidScanInput();
|
||||
|
||||
uint64_t down = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
uint64_t held = hidKeysHeld(CONTROLLER_P1_AUTO);
|
||||
uint64_t up = hidKeysUp(CONTROLLER_P1_AUTO);
|
||||
|
||||
touchPosition p;
|
||||
hidTouchRead(&p, 0);
|
||||
|
||||
yes.update(p);
|
||||
no.update(p);
|
||||
|
||||
if(down & KEY_A || yes.getEvent() == BUTTON_RELEASED)
|
||||
if(hold && (held & KEY_A || yes.getEvent() == BUTTON_PRESSED))
|
||||
{
|
||||
heldDown = true;
|
||||
holdCount++, holdClrDiff++;
|
||||
if(holdCount % 4 == 0)
|
||||
{
|
||||
loadFrame++;
|
||||
if(loadFrame > 7)
|
||||
loadFrame = 0;
|
||||
}
|
||||
|
||||
if(holdCount >= 180)
|
||||
{
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
|
||||
yes.setText(loadGlyphArray[loadFrame]);
|
||||
}
|
||||
else if((hold && heldDown) && (up & KEY_A || yes.getEvent() == BUTTON_RELEASED))
|
||||
{
|
||||
//Reset everything
|
||||
heldDown= false;
|
||||
holdCount = 0, loadFrame = 0, holdClrDiff = 0;
|
||||
yes.setText("Yes \ue0e0");
|
||||
}
|
||||
else if(down & KEY_A || yes.getEvent() == BUTTON_RELEASED)
|
||||
{
|
||||
ret = true;
|
||||
break;
|
||||
|
|
@ -226,7 +291,18 @@ namespace ui
|
|||
drawText("Confirm", frameBuffer, ui::shared, headX, 144, 24, txtClr);
|
||||
drawRect(frameBuffer, 256, 184, 768, 2, clrCreateU32(0xFF6D6D6D));
|
||||
drawTextWrap(mess.c_str(), frameBuffer, ui::shared, 272, 200, 24, txtClr, 752);
|
||||
yes.draw();
|
||||
if(hold && heldDown)
|
||||
{
|
||||
if(ui::thmID == ColorSetId_Light)
|
||||
holdClr = clrCreateRGBA(0xFF, 0xFF - holdClrDiff, 0xFF - holdClrDiff, 0xFF);
|
||||
else
|
||||
holdClr = clrCreateRGBA(0x25 + holdClrDiff, 0x00, 0x00, 0xFF);
|
||||
|
||||
yes.draw(holdClr);
|
||||
}
|
||||
else
|
||||
yes.draw();
|
||||
|
||||
no.draw();
|
||||
gfxEndFrame();
|
||||
}
|
||||
|
|
@ -238,14 +314,14 @@ namespace ui
|
|||
{
|
||||
std::string confMess = "Are you sure you want to copy #" + f + "# to #" + t +"#?";
|
||||
|
||||
return confirm(confMess);
|
||||
return confirm(confMess, false);
|
||||
}
|
||||
|
||||
bool confirmDelete(const std::string& p)
|
||||
{
|
||||
std::string confMess = "Are you 100% sure you want to delete #" + p + "#? *This is permanent*!";
|
||||
|
||||
return confirm(confMess);
|
||||
return confirm(confMess, true);
|
||||
}
|
||||
|
||||
void drawTextbox(int x, int y, int w, int h)
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ namespace ui
|
|||
{
|
||||
std::string confStr = "Are you 100% sure you want to add \"" + data::curUser.titles[data::selData].getTitle() + \
|
||||
"\" to your blacklist?";
|
||||
if(ui::confirm(confStr))
|
||||
if(ui::confirm(confStr, false))
|
||||
data::blacklistAdd(data::curUser, data::curUser.titles[data::selData]);
|
||||
}
|
||||
else if(down & KEY_B || ttlNav[3].getEvent() == BUTTON_RELEASED)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user