Remove touch controls, add support for system saves tied to accounts, add option to enable system save writing, bugs!

This commit is contained in:
J-D-K
2020-05-15 01:00:47 -04:00
parent 9f71b479f7
commit d872f2f904
21 changed files with 224 additions and 581 deletions

View File

@@ -57,7 +57,7 @@ namespace data
void init(const FsSaveDataInfo& inf, NsApplicationControlData *dat);
//Attempts to mount data with uID + id. Returns false if fails. For filtering.
bool isMountable(const AccountUid& uID);
bool isMountable(const AccountUid& uid);
//Returns title + title without forbidden chars
std::string getTitle() { return title;}
@@ -70,7 +70,7 @@ namespace data
std::string getPath() { return path; }
//returns save_data_id string. only used for helping identify nand files
std::string getSaveDataID(){ return saveDataID; }
std::string getSaveIDStr(){ return saveIDStr; }
uint64_t getID() { return id; }
uint64_t getSaveID() { return saveID; }
@@ -85,7 +85,7 @@ namespace data
private:
uint8_t saveDataType;
std::string title, titleSafe, author, path, saveDataID;
std::string title, titleSafe, author, path, saveIDStr;
uint64_t id, saveID;
uint16_t saveIndex;
bool favorite = false;
@@ -102,7 +102,7 @@ namespace data
bool initNoChk(const AccountUid& _id, const std::string& _backupName);
//Sets ID
void setUID(const AccountUid& _id) { userID = _id; }
void setUID(const AccountUid& _id);
//Assigns icon
void assignIcon(tex *_icn) { userIcon = _icn; }
@@ -129,6 +129,7 @@ namespace data
//User icon
tex* userIcon;
};
//Adds title to blacklist
void blacklistAdd(data::user& u, data::titledata& t);
//Adds title to favorite list
@@ -144,7 +145,7 @@ namespace data
extern user curUser;
extern int selUser, selData;
extern SetLanguage sysLang;
extern bool incDev, autoBack, ovrClk, holdDel, holdRest, holdOver, forceMount;
extern bool incDev, autoBack, ovrClk, holdDel, holdRest, holdOver, forceMount, accSysSave, sysSaveWrite;
}
#endif // DATA_H

View File

@@ -16,6 +16,7 @@ namespace fs
//Mounts usr's save data for open. Returns false it fails
bool mountSave(data::user& usr, data::titledata& open);
inline bool unmountSave(){ return fsdevUnmountDevice("sv") == 0; }
void copyFile(const std::string& from, const std::string& to);
void copyFileCommit(const std::string& from, const std::string& to, const std::string& dev);

View File

@@ -27,7 +27,7 @@ namespace ui
~menu();
//Handles controller input
void handleInput(const uint64_t& down, const uint64_t& held, const touchPosition& p);
void handleInput(const uint64_t& down, const uint64_t& held);
//Returns selected option
int getSelected() { return selected; }
@@ -57,9 +57,6 @@ namespace ui
//How much we shift the color of the rectangle
uint8_t clrSh = 0;
bool clrAdd = true;
ui::touchTrack track;
std::vector<ui::button> optButtons;
};
}

View File

@@ -43,49 +43,6 @@ namespace ui
tex *bg;
};
class button
{
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; }
unsigned getTx() { return tx; }
unsigned getTy() { return ty; }
protected:
bool pressed = false, first = false;
int retEvent = BUTTON_NOTHING;
unsigned x, y, w, h;
unsigned tx, ty;
std::string text;
touchPosition prev, cur;
};
class touchTrack
{
public:
void update(const touchPosition& p);
int getEvent() { return retTrack; }
int getOriginX() { return originX; }
int getOriginY() { return originY; }
private:
touchPosition pos[5];
int retTrack = TRACK_NOTHING;
int curPos = 0, avX = 0, avY = 0;
int originX = 0, originY = 0;
};
//General use
void showMessage(const char *head, const char *fmt, ...);
bool confirm(bool hold, const char *fmt, ...);

View File

@@ -8,17 +8,15 @@ namespace ui
void textUserPrep();
void textTitlePrep(data::user& u);
void textUserMenuUpdate(const uint64_t& down, const uint64_t& held, const touchPosition& p);
void textTitleMenuUpdate(const uint64_t& down, const uint64_t& held, const touchPosition& p);
//I don't think this matched very well
void textFolderMenuUpdate(const uint64_t& down, const uint64_t& held, const touchPosition& p);
void updateExMenu(const uint64_t& down, const uint64_t& held, const touchPosition& p);
void textUserMenuUpdate(const uint64_t& down, const uint64_t& held);
void textTitleMenuUpdate(const uint64_t& down, const uint64_t& held);
void textFolderMenuUpdate(const uint64_t& down, const uint64_t& held);
void updateExMenu(const uint64_t& down, const uint64_t& held);
void exMenuPrep();
//Options
void optMenuInit();
void updateOptMenu(const uint64_t& down, const uint64_t& held, const touchPosition& p);
void updateOptMenu(const uint64_t& down, const uint64_t& held);
}
#endif

View File

@@ -60,20 +60,13 @@ namespace ui
//Shared font
extern font *shared;
extern std::vector<ui::button> selButtons;
//Sets colors and loads font for icon creation
void initTheme();
//Loads graphics and stuff
void init(void *a);
void init();
void exit();
//Prepares ui
//Sets up buttons for icon touchin
void setupSelButtons();
void setupNavButtons();
//Clears and draws general stuff used by multiple screens
void drawUI();
@@ -81,7 +74,7 @@ namespace ui
void drawBoundBox(int x, int y, int w, int h, int clrSh);
//switch case so we don't have problems with multiple main loops like 3DS
void runApp(const uint64_t& down, const uint64_t& held, const touchPosition& p);
void runApp(const uint64_t& down, const uint64_t& held);
}
#endif

View File

@@ -5,10 +5,10 @@
namespace ui
{
void updateUserMenu(const uint64_t& down, const uint64_t& held, const touchPosition& p);
void updateTitleMenu(const uint64_t& down, const uint64_t& held, const touchPosition& p);
void updateFolderMenu(const uint64_t& down, const uint64_t& held, const touchPosition& p);
void updateAdvMode(const uint64_t& down, const uint64_t& held, const touchPosition& p);
void updateUserMenu(const uint64_t& down, const uint64_t& held);
void updateTitleMenu(const uint64_t& down, const uint64_t& held);
void updateFolderMenu(const uint64_t& down, const uint64_t& held);
void updateAdvMode(const uint64_t& down, const uint64_t& held);
//needed here since it uses static menu
void folderMenuPrepare(data::user& usr, data::titledata& dat);

View File

@@ -54,5 +54,7 @@ namespace util
ret.uid[1] = id;
return ret;
}
void setCPU(uint32_t hz);
}
#endif // UTIL_H

View File

@@ -13,7 +13,7 @@ NULL
[A] Select [L][R] Change User [Y] Dump All [-] Favorite [X] BlackList [ZR] Erase [B] Back
#Folder Select
[-] File Mode [L][R] Auto [A] Backup [Y] Restore [X] Delete Folder [ZR] Delete [B] Back
[-] File Mode [L][R] Auto [A] Backup [Y] Restore [X] Delete Folder [ZR] Erase [B] Back
#Options Menu
[A] Toggle [B] Back
@@ -38,4 +38,4 @@ Are you sure you want to copy #%s# to #%s#?
*WARNING*: This *will* erase the save data for #%s# *from your system*. This is the same as deleting it from #Data Management#! Are you sure you want to continue?
#Warning for deleting save data in folder menu
*WARNING*: This *will* delete the current save data for #%s# from your system! Are you sure you want to continue?
*WARNING*: This *will* delete the current save data for #%s# *from your system*! Are you sure you want to continue?

View File

@@ -10,6 +10,9 @@
#include "file.h"
#include "util.h"
static std::vector<uint64_t> blacklist;
static std::vector<uint64_t> favorites;
//Sorts titles sort-of alphabetically
static struct
{
@@ -60,10 +63,6 @@ static int findIcnIndex(const uint64_t& titleID)
return -1;
}
static std::vector<uint64_t> blacklist;
static std::vector<uint64_t> favorites;
static bool blacklisted(const uint64_t& id)
{
for(unsigned i = 0; i < blacklist.size(); i++)
@@ -90,11 +89,19 @@ static tex *createDeviceIcon()
{
tex *ret = texCreate(256, 256);
texClearColor(ret, ui::rectLt);
unsigned x = 128 - (textGetWidth("\ue121", ui::shared, 144) / 2);
drawText("\ue121", ret, ui::shared, x, 56, 144, ui::mnuTxt);
unsigned x = 128 - (textGetWidth("\ue121", ui::shared, 188) / 2);
drawText("\ue121", ret, ui::shared, x, 34, 188, ui::mnuTxt);
return ret;
}
static bool accountSystemSaveCheck(const FsSaveDataInfo& _inf)
{
if(_inf.save_data_type == FsSaveDataType_System && util::accountUIDToU128(_inf.uid) != 1 && !data::accSysSave)
return false;
return true;
}
namespace data
{
//Current data
@@ -114,7 +121,7 @@ namespace data
//Options
bool incDev = false, autoBack = true, ovrClk = false, isOvrClk = false;
bool holdDel = true, holdRest = true, holdOver = true, forceMount = true;
bool holdDel = true, holdRest = true, holdOver = true, forceMount = true, accSysSave = false, sysSaveWrite = false;
void init()
{
@@ -134,18 +141,6 @@ namespace data
loadFav();
loadCfg();
if(data::ovrClk)
{
clkrstInitialize();
ClkrstSession cpu;
clkrstOpenSession(&cpu, PcvModuleId_CpuBus, 3);
clkrstSetClockRate(&cpu, 1224000000);
clkrstCloseSession(&cpu);
clkrstExit();
data::isOvrClk = true;
}
//Get system language and copy to std::string
uint64_t lang;
setGetSystemLanguage(&lang);
@@ -174,7 +169,8 @@ namespace data
switch(info.save_data_type)
{
case FsSaveDataType_System:
info.uid = util::u128ToAccountUID(1);
if(util::accountUIDToU128(info.uid) == 0)
info.uid = util::u128ToAccountUID(1);
break;
case FsSaveDataType_Bcat:
@@ -191,7 +187,7 @@ namespace data
}
//If save data, not black listed or just ignore
if(!blacklisted(info.application_id) && !blacklisted(info.save_data_id))
if(!blacklisted(info.application_id) && !blacklisted(info.save_data_id) && accountSystemSaveCheck(info))
{
int u = getUserIndex(info.uid);
if(u == -1)
@@ -207,7 +203,7 @@ namespace data
if(isFavorite(newData.getID()))
newData.setFav(true);
if(newData.isMountable(newUser.getUID()) || !forceMount)
if(!forceMount || newData.isMountable(data::users[u].getUID()))
users[u].titles.push_back(newData);
}
}
@@ -218,7 +214,7 @@ namespace data
if(isFavorite(newData.getID()))
newData.setFav(true);
if(newData.isMountable(users[u].getUID()) || !forceMount)
if(!forceMount || newData.isMountable(data::users[u].getUID()))
users[u].titles.push_back(newData);
}
}
@@ -247,16 +243,6 @@ namespace data
for(unsigned i = 0; i < icons.size(); i++)
icons[i].deleteData();
if(data::isOvrClk)
{
clkrstInitialize();
ClkrstSession cpu;
clkrstOpenSession(&cpu, PcvModuleId_CpuBus, 3);
clkrstSetClockRate(&cpu, 1020000000);
clkrstCloseSession(&cpu);
clkrstExit();
}
saveFav();
saveCfg();
}
@@ -313,8 +299,8 @@ namespace data
title.assign(ent->name);
titleSafe.assign(util::safeString(title));
author.assign(ent->author);
sprintf(tmp, "%016lx", inf.save_data_id);
saveDataID.assign(tmp);
sprintf(tmp, "%016lX", inf.save_data_id);
saveIDStr.assign(tmp);
if(titleSafe.empty())
{
char tmp[32];
@@ -342,7 +328,7 @@ namespace data
title.assign(tmp);
titleSafe.assign(tmp);
sprintf(tmp, "%016lx", inf.save_data_id);
saveDataID.assign(tmp);
saveIDStr.assign(tmp);
icn newIcn;
newIcn.create(id, "");
newIcn.createFav();
@@ -353,13 +339,13 @@ namespace data
path = fs::getWorkDir() + titleSafe + "/";
}
bool titledata::isMountable(const AccountUid& uID)
bool titledata::isMountable(const AccountUid& uid)
{
data::user tmpUser;
tmpUser.setUID(uID);
tmpUser.setUID(uid);
if(fs::mountSave(tmpUser, *this))
{
fsdevUnmountDevice("sv");
fs::unmountSave();
return true;
}
return false;
@@ -423,6 +409,12 @@ namespace data
return true;
}
void user::setUID(const AccountUid& _id)
{
userID = _id;
uID128 = util::accountUIDToU128(_id);
}
void loadBlacklist()
{
blacklist.clear();
@@ -518,6 +510,8 @@ namespace data
data::holdRest = cfgIn >> 59 & 1;
data::holdOver = cfgIn >> 58 & 1;
data::forceMount = cfgIn >> 57 & 1;
data::accSysSave = cfgIn >> 56 & 1;
data::sysSaveWrite = cfgIn >> 55 & 1;
}
}
@@ -534,6 +528,8 @@ namespace data
cfgOut |= (uint64_t)data::holdRest << 59;
cfgOut |= (uint64_t)data::holdOver << 58;
cfgOut |= (uint64_t)data::forceMount << 57;
cfgOut |= (uint64_t)data::accSysSave << 56;
cfgOut |= (uint64_t)data::sysSaveWrite << 55;
fwrite(&cfgOut, sizeof(uint64_t), 1, cfg);
fclose(cfg);
@@ -578,15 +574,16 @@ namespace data
switch(info.save_data_type)
{
case FsSaveDataType_System:
info.uid = util::u128ToAccountUID(1);
if(util::accountUIDToU128(info.uid) == 0)
info.uid = util::u128ToAccountUID(1);
break;
case FsSaveDataType_Bcat:
info.uid = util::u128ToAccountUID(2);
info.uid = util::u128ToAccountUID(1);
break;
case FsSaveDataType_Device:
info.uid = util::u128ToAccountUID(3);
info.uid = util::u128ToAccountUID(2);
break;
}
@@ -600,7 +597,10 @@ namespace data
newData.setFav(true);
if(newData.isMountable(data::users[u].getUID()) || !forceMount)
{
users[u].titles.push_back(newData);
fs::unmountSave();
}
}
}
delete dat;

View File

@@ -163,7 +163,7 @@ namespace fs
switch(open.getType())
{
case FsSaveDataType_System:
svOpen = fsOpen_SystemSaveData(&sv, FsSaveDataSpaceId_System, open.getID(), (AccountUid) {0});
svOpen = fsOpen_SystemSaveData(&sv, FsSaveDataSpaceId_System, open.getID(), usr.getUID128() == 1 ? (AccountUid){ 0 } : usr.getUID());
break;
case FsSaveDataType_Account:
@@ -194,7 +194,6 @@ namespace fs
svOpen = 1;
break;
}
return R_SUCCEEDED(svOpen) && fsdevMountDevice("sv", sv) != -1;
}
@@ -428,6 +427,8 @@ namespace fs
fsdevUnmountDevice("sv");
}
}
return true;//?
}
std::string getFileProps(const std::string& _path)

View File

@@ -8,6 +8,7 @@
#include "data.h"
#include "ui.h"
#include "file.h"
#include "util.h"
extern "C"
{
@@ -38,19 +39,15 @@ extern "C"
int main(int argc, const char *argv[])
{
//Max cpu to speed up boot. Doesn't take long.
util::setCPU(1785000000);
fs::init();
graphicsInit(1280, 720);
//Needed for icon gen
ui::initTheme();
/*Not completely stable yet
Thread uiInitThrd;
threadCreate(&uiInitThrd, ui::init, NULL, NULL, 0x80000, 0x2B, -2);
threadStart(&uiInitThrd);*/
data::init();
ui::init(NULL);
/*threadWaitForExit(&uiInitThrd);
threadClose(&uiInitThrd);*/
ui::init();
//Reset cpu
util::setCPU(data::ovrClk ? 1224000000 : 1020000000);
while(appletMainLoop())
{
@@ -59,17 +56,18 @@ int main(int argc, const char *argv[])
uint64_t down = hidKeysDown(CONTROLLER_P1_AUTO);
uint64_t held = hidKeysHeld(CONTROLLER_P1_AUTO);
touchPosition p;
hidTouchRead(&p, 0);
if(down & KEY_PLUS)
break;
gfxBeginFrame();
ui::runApp(down, held, p);
ui::runApp(down, held);
gfxEndFrame();
}
//reset cpu on exit
if(data::ovrClk)
util::setCPU(1020000000);
ui::exit();
data::exit();
graphicsExit();

View File

@@ -12,11 +12,9 @@
#define VER_STRING "v. 05.14.2020"
//Nav buttons
std::vector<ui::button> usrNav, ttlNav, fldNav;
//Don't waste time drawing top and bottom over and over
static tex *top, *bot;
//guide graphics are to save cpu drawing that over and over with alpha
static tex *top, *bot, *usrGuide, *ttlGuide, *fldrGuide, *optGuide;
//Ui text strings
std::string author, ui::userHelp, ui::titleHelp, ui::folderHelp, ui::optHelp;
@@ -74,9 +72,6 @@ namespace ui
//Info printed on folder menu
std::string folderMenuInfo;
//Touch button vector
std::vector<ui::button> selButtons;
//UI colors
clr clearClr, mnuTxt, txtClr, rectLt, rectSh, tboxClr, sideRect, divClr;
@@ -129,7 +124,7 @@ namespace ui
}
}
void init(void *a)
void init()
{
mnuTopLeft = texLoadPNGFile("romfs:/img/fb/menuTopLeft.png");
mnuTopRight = texLoadPNGFile("romfs:/img/fb/menuTopRight.png");
@@ -176,9 +171,6 @@ namespace ui
loadTrans();
setupSelButtons();
setupNavButtons();
//Setup top and bottom gfx
texClearColor(top, clearClr);
texDraw(icn, top, 66, 27);
@@ -199,11 +191,29 @@ namespace ui
util::replaceButtonsInString(folderHelp);
util::replaceButtonsInString(optHelp);
//Create graphics to hold guides
usrGuide = texCreate(textGetWidth(userHelp.c_str(), ui::shared, 18), 28);
ttlGuide = texCreate(textGetWidth(titleHelp.c_str(), ui::shared, 18), 28);
fldrGuide = texCreate(textGetWidth(folderHelp.c_str(), ui::shared, 18), 28);
optGuide = texCreate(textGetWidth(optHelp.c_str(), ui::shared, 18), 28);
//Clear with bg color
texClearColor(usrGuide, ui::clearClr);
texClearColor(ttlGuide, ui::clearClr);
texClearColor(fldrGuide, ui::clearClr);
texClearColor(optGuide, ui::clearClr);
//Draw text to them
drawText(userHelp.c_str(), usrGuide, ui::shared, 0, 3, 18, ui::mnuTxt);
drawText(titleHelp.c_str(), ttlGuide, ui::shared, 0, 3, 18, ui::mnuTxt);
drawText(folderHelp.c_str(), fldrGuide, ui::shared, 0, 3, 18, ui::mnuTxt);
drawText(optHelp.c_str(), optGuide, ui::shared, 0, 3, 18, ui::mnuTxt);
//Calculate x position of help text
userHelpX = 1220 - textGetWidth(userHelp.c_str(), ui::shared, 18);
titleHelpX = 1220 - textGetWidth(titleHelp.c_str(), ui::shared, 18);
folderHelpX = 1220 - textGetWidth(folderHelp.c_str(), ui::shared, 18);
optHelpX = 1220 - textGetWidth(optHelp.c_str(), ui::shared, 18);
userHelpX = 1220 - usrGuide->width;
titleHelpX = 1220 - ttlGuide->width;
folderHelpX = 1220 - fldrGuide->width;
optHelpX = 1220 - optGuide->width;
advCopyMenuPrep();
ui::exMenuPrep();
@@ -224,60 +234,14 @@ namespace ui
texDestroy(mnuBotLeft);
texDestroy(mnuBotRight);
texDestroy(usrGuide);
texDestroy(ttlGuide);
texDestroy(fldrGuide);
texDestroy(optGuide);
fontDestroy(shared);
}
void setupSelButtons()
{
int x = 70, y = 98;
for(int i = 0; i < 32; y += 144)
{
int endRow = i + 8;
for(int tX = x; i < endRow; tX += 144, i++)
{
//Make a new button with no text. We're not drawing them anyway
ui::button newSelButton("", tX, y, 128, 128);
selButtons.push_back(newSelButton);
}
}
}
void setupNavButtons()
{
//User Select
int startX = 754;
ui::button sel("", startX, 656, 110, 64);
ui::button dmp("", startX += 110, 656, 134, 64);
ui::button cls("", startX += 134, 656, 110, 64);
ui::button ex("", startX += 110, 656, 110, 64);
usrNav.push_back(sel);
usrNav.push_back(dmp);
usrNav.push_back(cls);
usrNav.push_back(ex);
//Title
startX = 804;
ui::button ttlSel("", startX, 656, 110, 64);
ui::button ttlDmp("", startX += 110, 656, 134, 64);
ui::button ttlBlk("", startX += 134, 656, 110, 64);
ui::button ttlBck("", startX += 110, 656, 110, 64);
ttlNav.push_back(ttlSel);
ttlNav.push_back(ttlDmp);
ttlNav.push_back(ttlBlk);
ttlNav.push_back(ttlBck);
//Folder. Skip adv since it can't be touch controlled
startX = 800;
ui::button fldBackup("", startX, 656, 110, 64);
ui::button fldRestor("", startX += 110, 656, 110, 64);
ui::button fldDelete("", startX += 110, 656, 110, 64);
ui::button fldBack("", startX += 110, 672, 110, 64);
fldNav.push_back(fldBackup);
fldNav.push_back(fldRestor);
fldNav.push_back(fldDelete);
fldNav.push_back(fldBack);
}
void drawUI()
{
texClearColor(frameBuffer, clearClr);
@@ -287,31 +251,31 @@ namespace ui
switch(mstate)
{
case USR_SEL:
drawText(userHelp.c_str(), frameBuffer, ui::shared, userHelpX, 676, 18, ui::mnuTxt);
texDrawNoAlpha(usrGuide, frameBuffer, userHelpX, 673);
break;
case TTL_SEL:
drawText(titleHelp.c_str(), frameBuffer, ui::shared, titleHelpX, 676, 18, ui::mnuTxt);
texDrawNoAlpha(ttlGuide, frameBuffer, titleHelpX, 673);
break;
case FLD_SEL:
texDrawNoAlpha(sideBar, frameBuffer, 0, 88);
drawText(folderHelp.c_str(), frameBuffer, ui::shared, folderHelpX, 676, 18, ui::mnuTxt);
texDrawNoAlpha(fldrGuide, frameBuffer, folderHelpX, 673);
break;
case TXT_USR:
texDrawNoAlpha(sideBar, frameBuffer, 0, 88);
drawText(userHelp.c_str(), frameBuffer, ui::shared, userHelpX, 676, 18, ui::mnuTxt);
texDrawNoAlpha(usrGuide, frameBuffer, userHelpX, 673);
break;
case TXT_TTL:
texDrawNoAlpha(sideBar, frameBuffer, 0, 88);
drawText(titleHelp.c_str(), frameBuffer, ui::shared, titleHelpX, 676, 18, ui::mnuTxt);
texDrawNoAlpha(ttlGuide, frameBuffer, titleHelpX, 673);
break;
case TXT_FLD:
texDrawNoAlpha(sideBar, frameBuffer, 0, 88);
drawText(folderHelp.c_str(), frameBuffer, ui::shared, folderHelpX, 676, 18, ui::mnuTxt);
texDrawNoAlpha(fldrGuide, frameBuffer, folderHelpX, 673);
break;
case EX_MNU:
@@ -320,7 +284,7 @@ namespace ui
case OPT_MNU:
texDrawNoAlpha(sideBar, frameBuffer, 0, 88);
drawText(optHelp.c_str(), frameBuffer, ui::shared, optHelpX, 676, 18, ui::mnuTxt);
texDrawNoAlpha(optGuide, frameBuffer, optHelpX, 673);
break;
case ADV_MDE:
@@ -370,7 +334,7 @@ namespace ui
texSwapColors(mnuBotRight, rectClr, clrCreateRGBA(0x00, 0x88, 0xC5, 0xFF));
}
void runApp(const uint64_t& down, const uint64_t& held, const touchPosition& p)
void runApp(const uint64_t& down, const uint64_t& held)
{
//Draw first. Shouldn't, but it simplifies the showX functions
drawUI();
@@ -378,42 +342,41 @@ namespace ui
switch(mstate)
{
case USR_SEL:
updateUserMenu(down, held, p);
updateUserMenu(down, held);
break;
case TTL_SEL:
updateTitleMenu(down, held, p);
updateTitleMenu(down, held);
break;
case FLD_SEL:
updateFolderMenu(down, held, p);
updateFolderMenu(down, held);
break;
case ADV_MDE:
updateAdvMode(down, held, p);
updateAdvMode(down, held);
break;
case TXT_USR:
textUserMenuUpdate(down, held, p);
textUserMenuUpdate(down, held);
break;
case TXT_TTL:
textTitleMenuUpdate(down, held, p);
textTitleMenuUpdate(down, held);
break;
case TXT_FLD:
textFolderMenuUpdate(down, held, p);
textFolderMenuUpdate(down, held);
break;
case EX_MNU:
updateExMenu(down, held, p);
updateExMenu(down, held);
break;
case OPT_MNU:
updateOptMenu(down, held, p);
updateOptMenu(down, held);
break;
}
drawPopup(down);
}
}

View File

@@ -22,6 +22,11 @@ fs::dirList saveList(""), sdList("sdmc:/");
static bool commit = false;
static inline bool sysSaveCheck()
{
return data::sysSaveWrite || data::curData.getType() != FsSaveDataType_System;
}
//Performs copy menu operations. To big to stuff into case IMO.
void performCopyMenuOps()
{
@@ -72,12 +77,12 @@ void performCopyMenuOps()
break;
case 1:
if(sdMenu.getSelected() == 0)
if(sysSaveCheck() && sdMenu.getSelected() == 0)
{
if(ui::confirmTransfer(sdPath, savePath))
commit ? fs::copyDirToDirCommit(sdPath, savePath, dev) : fs::copyDirToDir(sdPath, savePath);
}
else if(sdMenu.getSelected() > 1)
else if(sysSaveCheck() && sdMenu.getSelected() > 1)
{
//Same as above, but reverse
int sdSel = sdMenu.getSelected() - 2;
@@ -116,7 +121,7 @@ void performCopyMenuOps()
{
//save menu
case 0:
if(data::curData.getType() != FsSaveDataType_System)
if(sysSaveCheck())
{
if(saveMenu.getSelected() == 0)
{
@@ -184,7 +189,7 @@ void performCopyMenuOps()
//save
case 0:
{
if(saveMenu.getSelected() > 1)
if(sysSaveCheck() && saveMenu.getSelected() > 1)
{
int selSave = saveMenu.getSelected() - 2;
std::string newName = util::getStringInput(saveList.getItem(selSave), "Rename", 256, 0, NULL);
@@ -232,14 +237,17 @@ void performCopyMenuOps()
//save
case 0:
{
std::string newFolder = util::getStringInput("", "New Folder", 256, 0, NULL);
if(!newFolder.empty())
if(sysSaveCheck())
{
std::string folderPath = savePath + newFolder;
mkdir(folderPath.c_str(), 777);
if(commit)
std::string newFolder = util::getStringInput("", "New Folder", 256, 0, NULL);
if(!newFolder.empty())
{
fsdevCommitDevice(dev.c_str());
std::string folderPath = savePath + newFolder;
mkdir(folderPath.c_str(), 777);
if(commit)
{
fsdevCommitDevice(dev.c_str());
}
}
}
}
@@ -368,21 +376,21 @@ namespace ui
advMenuCtrl = 0;
}
void updateAdvMode(const uint64_t& down, const uint64_t& held, const touchPosition& p)
void updateAdvMode(const uint64_t& down, const uint64_t& held)
{
//0 = save; 1 = sd; 2 = cpy
switch(advMenuCtrl)
{
case 0:
saveMenu.handleInput(down, held, p);
saveMenu.handleInput(down, held);
break;
case 1:
sdMenu.handleInput(down, held, p);
sdMenu.handleInput(down, held);
break;
case 2:
copyMenu.handleInput(down, held, p);
copyMenu.handleInput(down, held);
break;
}

View File

@@ -8,8 +8,6 @@
ui::menu folderMenu;
extern std::vector<ui::button> fldNav;
namespace ui
{
void folderMenuPrepare(data::user& usr, data::titledata& dat)
@@ -27,13 +25,9 @@ namespace ui
folderMenu.adjust();
}
void updateFolderMenu(const uint64_t& down, const uint64_t& held, const touchPosition& p)
void updateFolderMenu(const uint64_t& down, const uint64_t& held)
{
folderMenu.handleInput(down, held, p);
//Update nav
for(unsigned i = 0; i < fldNav.size(); i++)
fldNav[i].update(p);
folderMenu.handleInput(down, held);
//Draw folder menu
folderMenu.draw(ui::mnuTxt);
@@ -42,7 +36,7 @@ namespace ui
drawTextWrap(folderMenuInfo.c_str(), frameBuffer, ui::shared, 60, 370, 16, ui::mnuTxt, 360);
if(down & KEY_A || fldNav[0].getEvent() == BUTTON_RELEASED || folderMenu.getTouchEvent() == MENU_DOUBLE_REL)
if(down & KEY_A)
{
if(folderMenu.getSelected() == 0)
{
@@ -97,10 +91,10 @@ namespace ui
}
}
}
else if(down & KEY_Y || fldNav[1].getEvent() == BUTTON_RELEASED)
else if(down & KEY_Y)
{
if(data::curData.getType() != FsSaveDataType_System && folderMenu.getSelected() > 0)
{;
if((data::curData.getType() != FsSaveDataType_System || data::sysSaveWrite) && folderMenu.getSelected() > 0)
{
fs::dirList list(data::curData.getPath());
std::string folderName = list.getItem(folderMenu.getSelected() - 1);
@@ -130,7 +124,7 @@ namespace ui
}
}
}
else if(down & KEY_X || fldNav[2].getEvent() == BUTTON_RELEASED)
else if(down & KEY_X)
{
if(folderMenu.getSelected() > 0)
{
@@ -156,7 +150,7 @@ namespace ui
fs::delDir("sv:/");
fsdevCommitDevice("sv");
}
else if(down & KEY_B || fldNav[3].getEvent() == BUTTON_RELEASED)
else if(down & KEY_B)
{
fsdevUnmountDevice("sv");
mstate = TTL_SEL;

View File

@@ -16,15 +16,6 @@ namespace ui
y = _y;
rW = _rW;
rY = _y;
optButtons.clear();
for(unsigned i = 0; i < 15; i++)
{
//Init + push invisible options buttons
ui::button newOptButton("", x, y + i * 36, rW, 36);
optButtons.push_back(newOptButton);
}
}
void menu::addOpt(const std::string& add)
@@ -60,7 +51,7 @@ namespace ui
opt.clear();
}
void menu::handleInput(const uint64_t& down, const uint64_t& held, const touchPosition& p)
void menu::handleInput(const uint64_t& down, const uint64_t& held)
{
if( (held & KEY_UP) || (held & KEY_DOWN))
fc++;
@@ -110,39 +101,6 @@ namespace ui
if(selected < start)
start = selected;
}
//New touch shit
for(int i = 0; i < 15; i++)
{
optButtons[i].update(p);
if(selected == i && optButtons[i - start].getEvent() == BUTTON_RELEASED)
{
retEvent = MENU_DOUBLE_REL;
break;
}
else if(optButtons[i].getEvent() == BUTTON_RELEASED && i + start < (int)opt.size())
{
selected = i + start;
retEvent = MENU_NOTHING;
}
else
retEvent = MENU_NOTHING;
}
track.update(p);
switch(track.getEvent())
{
case TRACK_SWIPE_UP:
if(start + 15 < (int)opt.size())
start++, selected++;
break;
case TRACK_SWIPE_DOWN:
if(start - 1 >= 0)
start--, selected--;
break;
}
}
void menu::draw(const clr& textClr)

View File

@@ -50,139 +50,6 @@ namespace ui
drawTextWrap(text.c_str(), frameBuffer, ui::shared, 352, 230, 16, txtClr, 576);
}
button::button(const std::string& _txt, unsigned _x, unsigned _y, unsigned _w, unsigned _h)
{
x = _x;
y = _y;
w = _w;
h = _h;
text = _txt;
unsigned tw = textGetWidth(text.c_str(), ui::shared, 20);
unsigned th = 20;
tx = x + (w / 2) - (tw / 2);
ty = y + (h / 2) - (th / 2);
}
void button::setText(const std::string& _txt)
{
text = _txt;
unsigned tw = textGetWidth(text.c_str(), ui::shared, 20);
unsigned th = 20;
tx = x + (w / 2) - (tw / 2);
ty = y + (h / 2) - (th / 2);
}
void button::update(const touchPosition& p)
{
prev = cur;
cur = p;
//If button was first thing pressed
if(isOver() && prev.px == 0 && prev.py == 0)
{
first = true;
pressed = true;
retEvent = BUTTON_PRESSED;
}
else if(retEvent == BUTTON_PRESSED && hidTouchCount() == 0 && wasOver())
{
first = false;
pressed = false;
retEvent = BUTTON_RELEASED;
}
else if(retEvent != BUTTON_NOTHING && hidTouchCount() == 0)
{
first = false;
pressed = false;
retEvent = BUTTON_NOTHING;
}
}
bool button::isOver()
{
return (cur.px > x && cur.px < x + w && cur.py > y && cur.py < y + h);
}
bool button::wasOver()
{
return (prev.px > x && prev.px < x + w && prev.py > y && prev.py < y + h);
}
void button::draw()
{
if(pressed)
{
ui::drawTextboxInvert(x, y, w, h);
drawText(text.c_str(), frameBuffer, ui::shared, tx, ty, 20, mnuTxt);
}
else
{
ui::drawTextbox(x, y, w, h);
drawText(text.c_str(), frameBuffer, ui::shared, tx, ty, 20, txtClr);
}
}
void button::draw(const clr& _txt)
{
if(pressed)
{
ui::drawTextboxInvert(x, y, w, h);
drawText(text.c_str(), frameBuffer, ui::shared, tx, ty, 20, _txt);
}
else
{
ui::drawTextbox(x, y, w, h);
drawText(text.c_str(), frameBuffer, ui::shared, tx, ty, 20, _txt);
}
}
void touchTrack::update(const touchPosition& p)
{
if(hidTouchCount() > 0)
{
pos[curPos++] = p;
if(curPos == 5)
{
curPos = 0;
for(unsigned i = 1; i < 5; i++)
{
touchPosition c = pos[i], p = pos[i - 1];
avX += c.px - p.px;
avY += c.py - p.py;
}
avX /= 5;
avY /= 5;
if(avY <= -8)
retTrack = TRACK_SWIPE_UP;
else if(avY >= 8)
retTrack = TRACK_SWIPE_DOWN;
else if(retTrack <= -8)
retTrack = TRACK_SWIPE_LEFT;
else if(retTrack >= 8)
retTrack = TRACK_SWIPE_RIGHT;
else
retTrack = TRACK_NOTHING;
std::memset(pos, 0, sizeof(touchPosition) * 5);
}
else
retTrack = TRACK_NOTHING;
}
else
{
retTrack = TRACK_NOTHING;
curPos = 0;
}
}
void showMessage(const char *head, const char *fmt, ...)
{
char tmp[512];
@@ -190,8 +57,6 @@ namespace ui
va_start(args, fmt);
vsprintf(tmp, fmt, args);
button ok("OK \ue0e0 ", 320, 506, 640, 64);
//center head text width
size_t headWidth = textGetWidth(head, ui::shared, 20);
unsigned headX = (1280 / 2) - (headWidth / 2);
@@ -201,12 +66,8 @@ namespace ui
hidScanInput();
uint64_t down = hidKeysDown(CONTROLLER_P1_AUTO);
touchPosition p;
hidTouchRead(&p, 0);
ok.update(p);
if(down || ok.getEvent() == BUTTON_RELEASED)
if(down)
break;
gfxBeginFrame();
@@ -214,7 +75,6 @@ namespace ui
drawText(head, frameBuffer, ui::shared, headX, 168, 20, txtClr);
drawRect(frameBuffer, 320, 206, 640, 2, ui::thmID == ColorSetId_Light ? clrCreateU32(0xFF6D6D6D) : clrCreateU32(0xFFCCCCCC));
drawTextWrap(tmp, frameBuffer, ui::shared, 352, 230, 16, txtClr, 576);
ok.draw();
gfxEndFrame();
}
}
@@ -231,9 +91,6 @@ namespace ui
uint8_t holdClrDiff = 0;
clr holdClr;
button yes("Yes \ue0e0", 320, 506, 320, 64);
button no("No \ue0e1", 640, 506, 320, 64);
size_t headWidth = textGetWidth("Confirm", ui::shared, 20);
unsigned headX = (1280 / 2) - (headWidth / 2);
@@ -244,17 +101,10 @@ namespace ui
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);
std::string holdText;
if(hold && (held & KEY_A || yes.getEvent() == BUTTON_PRESSED))
if(hold && held & KEY_A)
{
heldDown = true;
holdCount++, holdClrDiff++;
@@ -279,21 +129,19 @@ namespace ui
holdText = "(Almost There!) ";
holdText += loadGlyphArray[loadFrame];
yes.setText(holdText);
}
else if((hold && heldDown) && (up & KEY_A || yes.getEvent() == BUTTON_RELEASED))
else if(hold && heldDown)
{
//Reset everything
heldDown= false;
holdCount = 0, loadFrame = 0, holdClrDiff = 0;
yes.setText("Yes \ue0e0");
}
else if(down & KEY_A || yes.getEvent() == BUTTON_RELEASED)
else if(down & KEY_A)
{
ret = true;
break;
}
else if(down & KEY_B || no.getEvent() == BUTTON_RELEASED)
else if(down & KEY_B)
{
ret = false;
break;
@@ -310,13 +158,7 @@ namespace ui
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();
}

View File

@@ -7,11 +7,9 @@
#include "util.h"
#include "ex.h"
extern std::vector<ui::button> ttlNav;
namespace ui
{
void updateTitleMenu(const uint64_t& down, const uint64_t& held, const touchPosition& p)
void updateTitleMenu(const uint64_t& down, const uint64_t& held)
{
//Static vars so they don't change on every loop
//Where to start in titles, selected title
@@ -25,8 +23,6 @@ namespace ui
//Selected rectangle X and Y.
static unsigned selRectX = 66, selRectY = 94;
static ui::touchTrack track;
if(clrAdd)
{
clrShft += 6;
@@ -82,59 +78,6 @@ namespace ui
}
}
//Buttons
for(int i = 0; i < 32; i++)
{
selButtons[i].update(p);
if(i == data::selData - start && selButtons[i].getEvent() == BUTTON_RELEASED)
{
data::curData = data::curUser.titles[data::selData];
if(fs::mountSave(data::curUser, data::curData))
{
folderMenuInfo = util::getInfoString(data::curUser, data::curData);
folderMenuPrepare(data::curUser, data::curData);
mstate = FLD_SEL;
}
}
else if(selButtons[i].getEvent() == BUTTON_RELEASED)
{
if(start + i < (int)data::curUser.titles.size())
data::selData = start + i;
}
}
//Nav
for(unsigned i = 0; i < ttlNav.size(); i++)
ttlNav[i].update(p);
//Update touchtracking
track.update(p);
switch(track.getEvent())
{
case TRACK_SWIPE_UP:
{
if(start + 32 < (int)data::curUser.titles.size())
{
start += 8;
data::selData += 8;
if(data::selData > (int)data::curUser.titles.size() - 1)
data::selData = data::curUser.titles.size() - 1;
}
}
break;
case TRACK_SWIPE_DOWN:
{
if(start - 8 >= 0)
{
start -= 8;
data::selData -= 8;
}
}
break;
}
if(down & KEY_RIGHT)
{
if(data::selData < (int)data::curUser.titles.size() - 1)
@@ -169,7 +112,7 @@ namespace ui
if(data::selData - start >= 32)
start += 8;
}
else if(down & KEY_A || ttlNav[0].getEvent() == BUTTON_RELEASED)
else if(down & KEY_A)
{
data::curData = data::curUser.titles[data::selData];
if(fs::mountSave(data::curUser, data::curData))
@@ -181,14 +124,14 @@ namespace ui
mstate = FLD_SEL;
}
}
else if(down & KEY_Y || ttlNav[1].getEvent() == BUTTON_RELEASED)
else if(down & KEY_Y)
fs::dumpAllUserSaves(data::curUser);
else if(down & KEY_X || ttlNav[2].getEvent() == BUTTON_RELEASED)
else if(down & KEY_X)
{
if(ui::confirm(false, ui::confBlackList.c_str(), data::curUser.titles[data::selData].getTitle().c_str()))
data::blacklistAdd(data::curUser, data::curUser.titles[data::selData]);
}
else if(down & KEY_B || ttlNav[3].getEvent() == BUTTON_RELEASED)
else if(down & KEY_B)
{
start = 0;
data::selData = 0;

View File

@@ -12,7 +12,6 @@
static ui::menu userMenu, titleMenu, exMenu, optMenu;
extern ui::menu folderMenu;
extern std::vector<ui::button> usrNav, ttlNav, fldNav;
//Help text for options
static const std::string optHelpStrings[] =
@@ -23,7 +22,9 @@ static const std::string optHelpStrings[] =
"Whether or not holding \ue0e0 is required when deleting save folders and files.",
"Whether or not holding \ue0e0 is required when restoring saves to games.",
"Whether or not holding \ue0e0 is required when overwriting save folders.",
"When on, JKSV will only show save data that can be opened. When off, JKSV shows everything."
"When on, JKSV will only show save data that can be opened. When off, JKSV shows everything.",
"Includes system save data tied to accounts.",
"Controls whether or not system saves can be restored/overwritten. *THIS CAN BE EXTREMELY DANGEROUS*."
};
static inline void switchBool(bool& sw)
@@ -77,15 +78,12 @@ namespace ui
folderMenu.adjust();
}
void textUserMenuUpdate(const uint64_t& down, const uint64_t& held, const touchPosition& p)
void textUserMenuUpdate(const uint64_t& down, const uint64_t& held)
{
userMenu.handleInput(down, held, p);
userMenu.handleInput(down, held);
userMenu.draw(mnuTxt);
for(unsigned i = 0; i < usrNav.size(); i++)
usrNav[i].update(p);
if(down & KEY_A || usrNav[0].getEvent() == BUTTON_RELEASED)
if(down & KEY_A)
{
if(data::users[userMenu.getSelected()].titles.size() > 0)
{
@@ -96,18 +94,18 @@ namespace ui
else
ui::showPopup("No saves available for " + data::users[userMenu.getSelected()].getUsername() + ".", POP_FRAME_DEFAULT);
}
else if(down & KEY_Y || usrNav[1].getEvent() == BUTTON_RELEASED)
else if(down & KEY_Y)
{
for(unsigned i = 0; i < data::users.size(); i++)
fs::dumpAllUserSaves(data::users[i]);
}
else if(down & KEY_X || usrNav[2].getEvent() == BUTTON_RELEASED)
else if(down & KEY_X)
{
std::remove(std::string(fs::getWorkDir() + "cls.txt").c_str());
ui::textMode = false;
mstate = USR_SEL;
}
else if(down & KEY_MINUS || usrNav[3].getEvent() == BUTTON_RELEASED)
else if(down & KEY_MINUS)
{
fsdevUnmountDevice("sv");
ui::exMenuPrep();
@@ -117,15 +115,12 @@ namespace ui
ui::mstate = OPT_MNU;
}
void textTitleMenuUpdate(const uint64_t& down, const uint64_t& held, const touchPosition& p)
void textTitleMenuUpdate(const uint64_t& down, const uint64_t& held)
{
titleMenu.handleInput(down, held, p);
titleMenu.handleInput(down, held);
titleMenu.draw(mnuTxt);
for(unsigned i = 0; i < ttlNav.size(); i++)
ttlNav[i].update(p);
if(down & KEY_A || ttlNav[0].getEvent() == BUTTON_RELEASED)
if(down & KEY_A)
{
data::curData = data::curUser.titles[titleMenu.getSelected()];
@@ -135,11 +130,11 @@ namespace ui
mstate = TXT_FLD;
}
}
else if(down & KEY_Y || ttlNav[1].getEvent() == BUTTON_RELEASED)
else if(down & KEY_Y)
{
fs::dumpAllUserSaves(data::curUser);
}
else if(down & KEY_X || ttlNav[2].getEvent() == BUTTON_RELEASED)
else if(down & KEY_X)
{
if(ui::confirm(false, ui::confBlackList.c_str(), data::curUser.titles[titleMenu.getSelected()].getTitle().c_str()))
data::blacklistAdd(data::curUser, data::curUser.titles[titleMenu.getSelected()]);
@@ -190,20 +185,17 @@ namespace ui
ui::textTitlePrep(data::curUser);
}
}
else if(down & KEY_B || ttlNav[3].getEvent() == BUTTON_RELEASED)
else if(down & KEY_B)
mstate = TXT_USR;
}
void textFolderMenuUpdate(const uint64_t& down, const uint64_t& held, const touchPosition& p)
void textFolderMenuUpdate(const uint64_t& down, const uint64_t& held)
{
titleMenu.draw(mnuTxt);
folderMenu.handleInput(down, held, p);
folderMenu.handleInput(down, held);
folderMenu.draw(mnuTxt);
for(unsigned i = 0; i < fldNav.size(); i++)
fldNav[i].update(p);
if(down & KEY_A || fldNav[0].getEvent() == BUTTON_RELEASED || folderMenu.getTouchEvent() == MENU_DOUBLE_REL)
if(down & KEY_A)
{
if(folderMenu.getSelected() == 0)
{
@@ -258,9 +250,9 @@ namespace ui
}
}
}
else if(down & KEY_Y || fldNav[1].getEvent() == BUTTON_RELEASED)
else if(down & KEY_Y)
{
if(data::curData.getType() != FsSaveDataType_System && folderMenu.getSelected() > 0)
if((data::curData.getType() != FsSaveDataType_System || data::sysSaveWrite) && folderMenu.getSelected() > 0)
{
fs::dirList list(data::curData.getPath());
@@ -290,7 +282,7 @@ namespace ui
}
}
}
else if(down & KEY_X || fldNav[2].getEvent() == BUTTON_RELEASED)
else if(down & KEY_X)
{
if(folderMenu.getSelected() > 0)
{
@@ -316,7 +308,7 @@ namespace ui
fs::delDir("sv:/");
fsdevCommitDevice("sv");
}
else if(down & KEY_B || fldNav[3].getEvent() == BUTTON_RELEASED)
else if(down & KEY_B)
{
fsdevUnmountDevice("sv");
mstate = TXT_TTL;
@@ -339,9 +331,9 @@ namespace ui
exMenu.addOpt("Mount Process RomFS");
}
void updateExMenu(const uint64_t& down, const uint64_t& held, const touchPosition& p)
void updateExMenu(const uint64_t& down, const uint64_t& held)
{
exMenu.handleInput(down, held, p);
exMenu.handleInput(down, held);
if(down & KEY_A)
{
@@ -488,11 +480,13 @@ namespace ui
optMenu.addOpt("Hold to Restore");
optMenu.addOpt("Hold to Overwrite");
optMenu.addOpt("Force Mount");
optMenu.addOpt("Account Sys Saves");
optMenu.addOpt("Write to Sys Saves");
}
void updateOptMenu(const uint64_t& down, const uint64_t& held, const touchPosition& p)
void updateOptMenu(const uint64_t& down, const uint64_t& held)
{
optMenu.handleInput(down, held, p);
optMenu.handleInput(down, held);
//Update Menu Options to reflect changes
optMenu.editOpt(0, "Include Dev Sv: " + getBoolText(data::incDev));
@@ -502,6 +496,8 @@ namespace ui
optMenu.editOpt(4, "Hold to Restore: " + getBoolText(data::holdRest));
optMenu.editOpt(5, "Hold to Overwrite: " + getBoolText(data::holdOver));
optMenu.editOpt(6, "Force Mount: " + getBoolText(data::forceMount));
optMenu.editOpt(7, "Account Sys. Saves: " + getBoolText(data::accSysSave));
optMenu.editOpt(8, "Write To Sys. Saves: " + getBoolText(data::sysSaveWrite));
if(down & KEY_A)
{
@@ -534,6 +530,14 @@ namespace ui
case 6:
switchBool(data::forceMount);
break;
case 7:
switchBool(data::accSysSave);
break;
case 8:
switchBool(data::sysSaveWrite);
break;
}
}
else if(down & KEY_B)

View File

@@ -7,11 +7,9 @@
#include "uiupdate.h"
#include "file.h"
extern std::vector<ui::button> usrNav;
namespace ui
{
void updateUserMenu(const uint64_t& down, const uint64_t& held, const touchPosition& p)
void updateUserMenu(const uint64_t& down, const uint64_t& held)
{
//Static so they don't get reset every loop
static int start = 0;
@@ -21,8 +19,6 @@ namespace ui
static unsigned selRectX = 66, selRectY = 94;
static ui::touchTrack track;
if(clrAdd)
{
clrShft += 6;
@@ -72,30 +68,6 @@ namespace ui
}
}
//Update invisible buttons
for(int i = 0; i < 32; i++)
{
selButtons[i].update(p);
if(data::selUser == i && selButtons[i].getEvent() == BUTTON_RELEASED)
{
data::curUser = data::users[data::selUser];
mstate = TTL_SEL;
}
else if(selButtons[i].getEvent() == BUTTON_RELEASED)
{
if(start + i < (int)data::users.size())
data::selUser = start + i;
}
}
//Update nav
for(unsigned i = 0; i < usrNav.size(); i++)
usrNav[i].update(p);
//Update touch tracking
track.update(p);
if(down & KEY_RIGHT)
{
if(data::selUser < (int)data::users.size() - 1)
@@ -130,7 +102,7 @@ namespace ui
if(data::selUser - start >= 32)
start += 8;
}
else if(down & KEY_A || usrNav[0].getEvent() == BUTTON_RELEASED)
else if(down & KEY_A)
{
if(data::users[data::selUser].titles.size() > 0)
{
@@ -140,7 +112,7 @@ namespace ui
else
ui::showPopup("No Saves available for " + data::users[data::selUser].getUsername() + ".", POP_FRAME_DEFAULT);
}
else if(down & KEY_Y || usrNav[1].getEvent() == BUTTON_RELEASED)
else if(down & KEY_Y)
{
bool cont = true;
for(unsigned i = 0; i < data::users.size() - 2; i++)
@@ -149,7 +121,7 @@ namespace ui
cont = fs::dumpAllUserSaves(data::users[i]);
}
}
else if(down & KEY_X || usrNav[2].getEvent() == BUTTON_RELEASED)
else if(down & KEY_X)
{
FILE *cls = fopen(std::string(fs::getWorkDir() + "cls.txt").c_str(), "w");
fclose(cls);
@@ -157,10 +129,9 @@ namespace ui
mstate = TXT_USR;
textMode = true;
}
else if(down & KEY_MINUS || usrNav[3].getEvent() == BUTTON_RELEASED)
else if(down & KEY_MINUS)
{
fsdevUnmountDevice("sv");
fs::unmountSave();
ui::mstate = EX_MNU;
}
else if(down & KEY_ZR)

View File

@@ -157,7 +157,7 @@ namespace util
char id[18];
sprintf(id, " %016lX", d.getID());
ret += "TID: " + std::string(id) + "\n\n";
ret += "SID: " + d.getSaveDataID() + "\n\n";
ret += "SID: " + d.getSaveIDStr() + "\n\n";
switch(d.getType())
{
@@ -284,5 +284,17 @@ namespace util
drawText(txt, ret, ui::shared, x, 112, 32, ui::mnuTxt);
return ret;
}
void setCPU(uint32_t hz)
{
if(R_FAILED(clkrstInitialize()))
return;
ClkrstSession cpu;
clkrstOpenSession(&cpu, PcvModuleId_CpuBus, 3);
clkrstSetClockRate(&cpu, hz);
clkrstCloseSession(&cpu);
clkrstExit();
}
}