Add animation scaling option, revise menu event handling

This commit is contained in:
J-D-K 2021-07-16 21:58:15 -04:00
parent cf832a0f91
commit f12f81b67f
14 changed files with 155 additions and 600 deletions

10
inc/fm.h Normal file
View File

@ -0,0 +1,10 @@
#pragma once
namespace ui
{
void fmInit();
void fmExit();
void fmPrep(const FsSaveDataType& _type, const std::string& _dev, bool _commit);
void fmUpdate(SDL_Texture *target);
void fmDraw();
}

View File

@ -11,14 +11,6 @@
#define MENU_FONT_SIZE_DEFAULT 18
#define MENU_MAX_SCROLL_DEFAULT 15
typedef enum
{
FUNC_A,
FUNC_B,
FUNC_X,
FUNC_Y,
} menuFuncTypes;
typedef enum
{
MENU_X,
@ -31,12 +23,18 @@ typedef enum
//For smaller classes that aren't easy to get lost in and general functions
namespace ui
{
typedef struct
{
funcPtr func = NULL;
void *args = NULL;
HidNpadButton button = (HidNpadButton)0;
} menuOptEvent;
typedef struct
{
SDL_Texture *icn = NULL;
std::string txt;
funcPtr func[4] = {NULL};
void *argPtr[4] = {NULL};
std::vector<menuOptEvent> events;
} menuOpt;
class menu
@ -56,10 +54,11 @@ namespace ui
//Adds option.
int addOpt(SDL_Texture *_icn, const std::string& add);
//Adds an function to be executed on pressing button specified
void optAddButtonEvent(unsigned _ind, HidNpadButton _button, funcPtr _func, void *args);
//Changes opt text
void editOpt(int ind, SDL_Texture *_icn, const std::string& ch);
void setOptFunc(unsigned _ind, unsigned _funcbtn, funcPtr _func, void *args);
void updateOptArgs(unsigned _ind, unsigned _funcbtn, void *args) { opt[_ind].argPtr[_funcbtn] = args; }
size_t getOptCount() { return opt.size(); }
int getOptPos(const std::string& txt);

View File

@ -13,6 +13,7 @@
#include "usr.h"
#include "ttl.h"
#include "sett.h"
#include "fm.h"
enum menuState
{
@ -25,12 +26,12 @@ enum menuState
namespace ui
{
//Text menus
extern bool textMode;
//Current menu/ui state
extern int mstate, prevState;
//Slide/animation scaling
extern float animScale;
//pad data cause i don't know where else to put it
extern PadState pad;
extern HidTouchScreenState touchState;

View File

@ -16,7 +16,7 @@ namespace ui
//Strings for extras menu
extern std::string exMenuStr[11];
//Strings for options menu
extern std::string optMenuStr[13];
extern std::string optMenuStr[14];
//Strings for the holding thing
extern std::string holdingText[3];
//Strings for sort type

View File

@ -497,6 +497,9 @@ void data::loadCfg()
uint64_t cfgIn = 0;
fread(&cfgIn, sizeof(uint64_t), 1, cfg);
fread(&data::sortType, 1, 1, cfg);
fread(&ui::animScale, sizeof(float), 1, cfg);
if(ui::animScale == 0)
ui::animScale = 3.5f;
fclose(cfg);
data::config["incDev"] = cfgIn >> 63 & 1;
@ -535,6 +538,7 @@ void data::saveCfg()
cfgOut |= (uint64_t)data::config["langOverride"] << 50;
fwrite(&cfgOut, sizeof(uint64_t), 1, cfg);
fwrite(&data::sortType, 1, 1, cfg);
fwrite(&ui::animScale, sizeof(float), 1, cfg);
fclose(cfg);
}
@ -553,6 +557,7 @@ void data::restoreDefaultConfig()
data::config["directFsCmd"] = false;
data::config["zip"] = false;
data::sortType = 0;
ui::animScale = 3.5f;
}
void data::loadFav()

View File

@ -590,7 +590,6 @@ void fs::copyZipToDir(unzFile *unz, const std::string& to, const std::string& de
uint8_t *buff = new uint8_t[BUFF_SIZE];
int readIn = 0;
unz_file_info info;
int fCount = 0;
if(unzGoToFirstFile(*unz) == UNZ_OK)
{
do

View File

@ -14,6 +14,8 @@
//Current menu state
int ui::mstate = USR_SEL, ui::prevState = USR_SEL;
float ui::animScale = 3.5f;
//pad data?
PadState ui::pad;
HidTouchScreenState ui::touchState;

View File

@ -1,525 +0,0 @@
#include <string>
#include <vector>
#include <sys/stat.h>
#include "file.h"
#include "ui.h"
#include "miscui.h"
#include "util.h"
//Text menus
static ui::menu saveMenu, sdMenu, copyMenu;
//Paths + wrapped string paths
static std::string savePath, sdPath, dev;
//Adv Ctrl mode
static int advMenuCtrl, advPrev;
//Dir listings
fs::dirList saveList, sdList;
static bool commit = false;
static FsSaveDataType type = FsSaveDataType_System;
static inline bool sysSaveCheck()
{
return data::config["sysSaveWrite"] || type != FsSaveDataType_System;
}
//Performs copy menu operations. To big to stuff into case IMO.
void performCopyMenuOps()
{
switch(copyMenu.getSelected())
{
//Copy
case 0:
{
switch(advPrev)
{
//save
case 0:
if(saveMenu.getSelected() == 0)
{
//Copy current open dir
if(ui::confirmTransfer(savePath, sdPath))
fs::copyDirToDir(savePath, sdPath);
}
else if(saveMenu.getSelected() > 1)
{
//Forget '..'
int saveSel = saveMenu.getSelected() - 2;
if(saveList.isDir(saveSel))
{
//Dir we're copying from
std::string fromPath = savePath + saveList.getItem(saveSel) + "/";
//Where we're copying to
std::string toPath = sdPath + saveList.getItem(saveSel);
if(ui::confirmTransfer(fromPath, toPath))
{
//make dir on sd
mkdir(toPath.c_str(), 777);
toPath += "/";
fs::copyDirToDir(fromPath, toPath);
}
}
else
{
//just copy file
std::string fromPath = savePath + saveList.getItem(saveSel);
std::string toPath = sdPath + saveList.getItem(saveSel);
if(ui::confirmTransfer(fromPath, toPath))
fs::copyFile(fromPath, toPath);
}
}
break;
case 1:
if(sysSaveCheck() && sdMenu.getSelected() == 0)
{
if(ui::confirmTransfer(sdPath, savePath))
commit ? fs::copyDirToDirCommit(sdPath, savePath, dev) : fs::copyDirToDir(sdPath, savePath);
}
else if(sysSaveCheck() && sdMenu.getSelected() > 1)
{
//Same as above, but reverse
int sdSel = sdMenu.getSelected() - 2;
if(sdList.isDir(sdSel))
{
std::string fromPath = sdPath + sdList.getItem(sdSel) + "/";
std::string toPath = savePath + sdList.getItem(sdSel);
if(ui::confirmTransfer(fromPath, toPath))
{
mkdir(toPath.c_str(), 777);
toPath += "/";
commit ? fs::copyDirToDirCommit(fromPath, toPath, dev) : fs::copyDirToDir(fromPath, toPath);
}
}
else
{
std::string fromPath = sdPath + sdList.getItem(sdSel);
std::string toPath = savePath + sdList.getItem(sdSel);
if(ui::confirmTransfer(fromPath, toPath))
commit ? fs::copyFileCommit(fromPath, toPath, dev) : fs::copyFile(fromPath, toPath);
}
}
break;
}
}
break;
//delete
case 1:
{
switch(advPrev)
{
//save menu
case 0:
if(sysSaveCheck())
{
if(saveMenu.getSelected() == 0)
{
if(ui::confirmDelete(savePath))
{
fs::delDir(savePath);
fsdevCommitDevice(dev.c_str());
}
}
else if(saveMenu.getSelected() > 1)
{
int saveSel = saveMenu.getSelected() - 2;
if(saveList.isDir(saveSel))
{
std::string delPath = savePath + saveList.getItem(saveSel) + "/";
if(ui::confirmDelete(delPath))
fs::delDir(delPath);
}
else
{
std::string delPath = savePath + saveList.getItem(saveSel);
if(ui::confirmDelete(delPath))
std::remove(delPath.c_str());
}
if(commit)
fsdevCommitDevice(dev.c_str());
}
}
break;
//sd
case 1:
if(sdMenu.getSelected() == 0)
{
if(ui::confirmDelete(sdPath) && sdPath != "sdmc:/")
fs::delDir(sdPath);
}
else if(sdMenu.getSelected() > 1)
{
int sdSel = sdMenu.getSelected() - 2;
if(sdList.isDir(sdSel))
{
std::string delPath = sdPath + sdList.getItem(sdSel) + "/";
if(ui::confirmDelete(delPath))
fs::delDir(delPath);
}
else
{
std::string delPath = sdPath + sdList.getItem(sdSel);
if(ui::confirmDelete(delPath))
std::remove(delPath.c_str());
}
}
break;
}
}
break;
//Rename
case 2:
switch(advPrev)
{
//save
case 0:
{
if(sysSaveCheck() && saveMenu.getSelected() > 1)
{
int selSave = saveMenu.getSelected() - 2;
std::string newName = util::getStringInput(saveList.getItem(selSave), "Rename", 256, 0, NULL);
if(!newName.empty())
{
std::string b4Path = savePath + saveList.getItem(selSave);
std::string newPath = savePath + newName;
std::rename(b4Path.c_str(), newPath.c_str());
if(commit)
{
fsdevCommitDevice(dev.c_str());
}
}
}
}
break;
//sd
case 1:
{
if(sdMenu.getSelected() > 1)
{
int sdSel = sdMenu.getSelected() - 2;
std::string newName = util::getStringInput(sdList.getItem(sdSel), "Rename", 256, 0, NULL);
if(!newName.empty())
{
std::string b4Path = sdPath + sdList.getItem(sdSel);
std::string newPath = sdPath + newName;
std::rename(b4Path.c_str(), newPath.c_str());
}
}
}
break;
}
break;
//Mkdir
case 3:
{
switch(advPrev)
{
//save
case 0:
{
if(sysSaveCheck())
{
std::string newFolder = util::getStringInput("", "New Folder", 256, 0, NULL);
if(!newFolder.empty())
{
std::string folderPath = savePath + newFolder;
mkdir(folderPath.c_str(), 777);
if(commit)
{
fsdevCommitDevice(dev.c_str());
}
}
}
}
break;
//sd
case 1:
{
std::string newFolder = util::getStringInput("", "New Folder", 256, 0, NULL);
if(!newFolder.empty())
{
std::string folderPath = sdPath + newFolder;
mkdir(folderPath.c_str(), 777);
}
}
break;
}
}
break;
//Props
case 4:
{
switch(advPrev)
{
//sv
case 0:
{
if(saveMenu.getSelected() > 1)
{
int sel = saveMenu.getSelected() - 2;
std::string fullPath = savePath + saveList.getItem(sel);
if(fs::isDir(fullPath))
{
uint32_t dirCnt = 0, fileCnt = 0;
uint64_t fileSize = 0;
fullPath += "/";
fs::getDirProps(fullPath, dirCnt, fileCnt, fileSize);
ui::showMessage("Folder Properties", "#%s#:\n%u Folders\n%u Files\nTotal Size: %.2fMB", fullPath.c_str(), dirCnt, fileCnt, (float)((float)fileSize / 1024.0f / 1024.0f));
}
else
{
std::string fprops = fs::getFileProps(fullPath);
if(!fprops.empty())
ui::showMessage("File Properties:", fprops.c_str());
}
}
}
break;
case 1:
{
if(sdMenu.getSelected() > 1)
{
int sel = sdMenu.getSelected() - 2;
std::string fullPath = sdPath + sdList.getItem(sel);
if(fs::isDir(fullPath))
{
uint32_t dirCnt = 0, fileCnt = 0;
uint64_t fileSize = 0;
fullPath += "/";
fs::getDirProps(fullPath, dirCnt, fileCnt, fileSize);
ui::showMessage("Folder Properties", "#%s#:\n%u Folders\n%u Files\nTotal Size: %.2fMB", fullPath.c_str(), dirCnt, fileCnt, (float)((float)fileSize / 1024.0f / 1024.0f));
}
else
{
std::string fprops = fs::getFileProps(fullPath);
if(!fprops.empty())
ui::showMessage("File Properties:", fprops.c_str());
}
}
}
break;
}
}
break;
//back
case 5:
advMenuCtrl = advPrev;
break;
}
//update lists + menus
sdList.rescan();
saveList.rescan();
util::copyDirListToMenu(sdList, sdMenu);
util::copyDirListToMenu(saveList, saveMenu);
}
void advCopyMenuPrep()
{
for(unsigned i = 0; i < 6; i++)
copyMenu.addOpt(NULL, ui::advMenuStr[i]);
}
void advModePrep(const std::string& svDev, const FsSaveDataType& _type, bool commitOnWrite)
{
commit = commitOnWrite;
type = _type;
saveMenu.setParams(30, 98, 602, MENU_FONT_SIZE_DEFAULT, MENU_MAX_SCROLL_DEFAULT);
sdMenu.setParams(648, 98, 602, MENU_FONT_SIZE_DEFAULT, MENU_MAX_SCROLL_DEFAULT);
copyMenu.setParams(472, 278, 304, MENU_FONT_SIZE_DEFAULT, MENU_MAX_SCROLL_DEFAULT);
savePath = svDev, dev = svDev;
sdPath = "sdmc:/";
saveList.reassign(savePath);
sdList.reassign(sdPath);
util::copyDirListToMenu(saveList, saveMenu);
util::copyDirListToMenu(sdList, sdMenu);
advMenuCtrl = 0;
}
void drawAdvMode()
{
saveMenu.draw(NULL, &ui::txtCont, true);
sdMenu.draw(NULL, &ui::txtCont, true);
gfx::drawTextfWrap(NULL, 14, 30, 654, 600, &ui::txtCont, savePath.c_str());
gfx::drawTextfWrap(NULL, 14, 640, 654, 600, &ui::txtCont, sdPath.c_str());
//draw copy menu if it's supposed to be up
if(advMenuCtrl == 2)
{
switch(advPrev)
{
case 0:
copyMenu.setParams(176, 278, 304, MENU_FONT_SIZE_DEFAULT, MENU_MAX_SCROLL_DEFAULT);
copyMenu.editOpt(0, NULL, ui::advMenuStr[0] + "sdmc");
ui::drawTextbox(NULL, 168, 236, 320, 268);
gfx::drawTextf(NULL, 18, 176, 250, &ui::txtDiag, dev.c_str());
break;
case 1:
copyMenu.setParams(816, 278, 304, MENU_FONT_SIZE_DEFAULT, MENU_MAX_SCROLL_DEFAULT);
copyMenu.editOpt(0, NULL, ui::advMenuStr[0] + dev);
ui::drawTextbox(NULL, 808, 236, 320, 268);
gfx::drawTextf(NULL, 18, 816, 250, &ui::txtDiag, "SDMC");
break;
}
copyMenu.draw(NULL, &ui::txtDiag, true);
}
}
void updateAdvMode(const uint64_t& down, const uint64_t& held)
{
//0 = save; 1 = sd; 2 = cpy
switch(advMenuCtrl)
{
case 0:
saveMenu.update();
break;
case 1:
sdMenu.update();
break;
case 2:
copyMenu.update();
break;
}
//OH BOY HERE WE GO
if(down & HidNpadButton_A)
{
switch(advMenuCtrl)
{
//save
case 0:
{
int saveSel = saveMenu.getSelected();
if(saveSel == 1 && savePath != dev)
{
util::removeLastFolderFromString(savePath);
saveList.reassign(savePath);
util::copyDirListToMenu(saveList, saveMenu);
}
else if(saveSel > 1 && saveList.isDir(saveSel - 2))
{
savePath += saveList.getItem(saveSel - 2) + "/";
saveList.reassign(savePath);
util::copyDirListToMenu(saveList, saveMenu);
}
}
break;
//sd
case 1:
{
int sdSel = sdMenu.getSelected();
if(sdSel == 1 && sdPath != "sdmc:/")
{
util::removeLastFolderFromString(sdPath);
sdList.reassign(sdPath);
util::copyDirListToMenu(sdList, sdMenu);
}
else if(sdSel > 1 && sdList.isDir(sdSel - 2))
{
sdPath += sdList.getItem(sdSel - 2) + "/";
sdList.reassign(sdPath);
util::copyDirListToMenu(sdList, sdMenu);
}
}
break;
//advanced mode
case 2:
performCopyMenuOps();
break;
}
}
else if(down & HidNpadButton_B)
{
//save
if(advMenuCtrl == 0 && savePath != dev)
{
util::removeLastFolderFromString(savePath);
saveList.reassign(savePath);
util::copyDirListToMenu(saveList, saveMenu);
}
//sd
else if(advMenuCtrl == 1 && sdPath != "sdmc:/")
{
util::removeLastFolderFromString(sdPath);
sdList.reassign(sdPath);
util::copyDirListToMenu(sdList, sdMenu);
}
else if(advMenuCtrl == 2)
advMenuCtrl = advPrev;
}
else if(down & HidNpadButton_X)
{
if(advMenuCtrl == 2)
{
advMenuCtrl = advPrev;
}
else
{
advPrev = advMenuCtrl;
advMenuCtrl = 2;
}
}
else if(down & HidNpadButton_ZL || down & HidNpadButton_ZR)
{
if(advMenuCtrl == 0 || advMenuCtrl == 1)
advMenuCtrl = advMenuCtrl == 0 ? 1 : 0;
}
else if(down & HidNpadButton_Minus)
{
switch(ui::prevState)
{
case EX_MNU:
ui::mstate = EX_MNU;
break;
case TTL_SEL:
ui::mstate = TTL_SEL;
break;
}
}
}

59
src/ui/fm.cpp Normal file
View File

@ -0,0 +1,59 @@
#include <string>
#include "ui.h"
#include "file.h"
#include "util.h"
#include "fm.h"
static ui::slideOutPanel *copyPanel;
static ui::menu *devMenu, *sdMenu, *copyMenu;
static fs::dirList *devList, *sdList;
static std::string devPath, sdPath, dev;
static FsSaveDataType type;
static bool commit = false;
static void copyPanelDraw(void *a)
{
}
void ui::fmInit()
{
devMenu = new ui::menu;
devMenu->setParams(10, 32, 520, 18, 8);
devMenu->setActive(true);
sdMenu = new ui::menu;
sdMenu->setParams(560, 32, 520, 18, 18);
sdMenu->setActive(false);
copyPanel = new ui::slideOutPanel(410, 720, 0, copyPanelDraw);
devList = new fs::dirList;
sdList = new fs::dirList;
}
void ui::fmExit()
{
delete devMenu;
delete sdMenu;
delete devList;
delete sdList;
delete copyPanel;
}
void ui::fmPrep(const FsSaveDataType& _type, const std::string& _dev, bool _commit)
{
type = _type;
dev = _dev;
commit = _commit;
devPath = _dev;
sdPath = "sdmc:/";
devList->reassign(dev);
sdList->reassign("sdmc:/");
util::copyDirListToMenu(*devList, *devMenu);
util::copyDirListToMenu(*sdList, *sdMenu);
}

View File

@ -100,10 +100,10 @@ void ui::menu::editOpt(int ind, SDL_Texture *_icn, const std::string& ch)
opt[ind].txt = ch;
}
void ui::menu::setOptFunc(unsigned _ind, unsigned _funcbtn, funcPtr _func, void *args)
void ui::menu::optAddButtonEvent(unsigned _ind, HidNpadButton _button, funcPtr _func, void *args)
{
opt[_ind].func[_funcbtn] = _func;
opt[_ind].argPtr[_funcbtn] = args;
ui::menuOptEvent newEvent = {_func, args, _button};
opt[_ind].events.push_back(newEvent);
}
int ui::menu::getOptPos(const std::string& txt)
@ -182,28 +182,13 @@ void ui::menu::update()
start = selected - scrL;
}
//func exec
switch(down)
if(down)
{
case HidNpadButton_A:
if(opt[selected].func[FUNC_A])
(*opt[selected].func[FUNC_A])(opt[selected].argPtr[FUNC_A]);
break;
case HidNpadButton_B:
if(opt[selected].func[FUNC_B])
(*opt[selected].func[FUNC_B])(opt[selected].argPtr[FUNC_B]);
break;
case HidNpadButton_X:
if(opt[selected].func[FUNC_X])
(*opt[selected].func[FUNC_X])(opt[selected].argPtr[FUNC_X]);
break;
case HidNpadButton_Y:
if(opt[selected].func[FUNC_Y])
(*opt[selected].func[FUNC_Y])(opt[selected].argPtr[FUNC_Y]);
break;
for(ui::menuOptEvent& e : opt[selected].events)
{
if((down & e.button) && e.func)
(*e.func)(e.args);
}
}
if(selected != oldSel && onChange)
@ -325,13 +310,13 @@ void ui::slideOutPanel::draw(const SDL_Color *backCol)
if(open && x > 1280 - w)
{
float add = ((1280 - (float)w) - (float)x) / 2;
x += round(add);
float add = ((1280 - (float)w) - (float)x) / ui::animScale;
x += ceil(add);
}
else if(!open && x < 1280)
{
float add = (1280 - (float)x) / 2;
x += round(add);
float add = (1280 - (float)x) / ui::animScale;
x += ceil(add);
}
//don't waste time drawing if you can't even see it.
@ -345,9 +330,9 @@ void ui::slideOutPanel::draw(const SDL_Color *backCol)
//Todo make less hardcoded
void ui::titleTile::draw(SDL_Texture *target, int x, int y, bool sel)
{
unsigned xScale = w * 1.28, yScale = h * 1.28;
if(sel)
{
unsigned xScale = w * 1.28, yScale = h * 1.28;
if(wS < xScale)
wS += 18;
if(hS < yScale)
@ -453,18 +438,21 @@ void ui::titleview::update()
void ui::titleview::draw(SDL_Texture *target)
{
if(tiles.size() <= 0)
return;
int tH = 0, tY = 0;
SDL_QueryTexture(target, NULL, NULL, NULL, &tH);
tY = tH - 214;
if(selRectY > tY)
{
float add = ((float)tY - (float)selRectY) / 2;
y += round(add);
float add = ((float)tY - (float)selRectY) / ui::animScale;
y += ceil(add);
}
else if(selRectY < 38)
{
float add = (38.0f - (float)selRectY) / 2;
y += round(add);
float add = (38.0f - (float)selRectY) / ui::animScale;
y += ceil(add);
}
if(clrAdd)
@ -489,7 +477,7 @@ void ui::titleview::draw(SDL_Texture *target)
if(i >= totalTitles)
break;
if(i == selected && showSel)
if(i == selected)
{
//save x and y for later so it's draw over top
selX = tX;
@ -507,6 +495,8 @@ void ui::titleview::draw(SDL_Texture *target)
ui::drawBoundBox(target, selRectX, selRectY, 176, 176, clrShft);
tiles[selected]->draw(target, selX, selY, true);
}
else
tiles[selected]->draw(target, selX, selY, false);
}
ui::popMessageMngr::~popMessageMngr()
@ -538,7 +528,7 @@ void ui::popMessageMngr::draw()
{
y -= 48;
if(p.y != y)
p.y += (y - p.y) / 2;
p.y += (y - p.y) / ui::animScale;
gfx::drawRect(NULL, &ui::tboxClr, 64, p.y, p.rectWidth, 40);
gfx::drawTextf(NULL, 24, 80, p.y + 8, &ui::txtDiag, p.message.c_str());
@ -585,7 +575,7 @@ bool ui::confirm(bool hold, const char *fmt, ...)
uint8_t holdClrDiff = 0;
SDL_Color holdClr = ui::txtDiag;
unsigned headX = (640 / 2) - (gfx::getTextWidth("Confirm", 20) / 2);
unsigned headX = (640 / 2) - (gfx::getTextWidth(ui::confirmHead.c_str(), 20) / 2);
unsigned yesX = 160 - (gfx::getTextWidth(ui::yt.c_str(), 20) / 2);
unsigned noX = 160 - (gfx::getTextWidth(ui::nt.c_str(), 20) / 2);

View File

@ -96,6 +96,12 @@ static void toggleOpt(void *a)
data::loadUsersTitles(false);
ui::refreshAllViews();
break;
case 13:
ui::animScale += 0.5f;
if(ui::animScale > 8)
ui::animScale = 1;
break;
}
}
@ -114,6 +120,10 @@ static void updateMenuText()
ui::settMenu->editOpt(10, NULL, ui::optMenuStr[10] + getBoolText(data::config["zip"]));
ui::settMenu->editOpt(11, NULL, ui::optMenuStr[11] + getBoolText(data::config["langOverride"]));
ui::settMenu->editOpt(12, NULL, ui::optMenuStr[12] + ui::sortString[data::sortType]);
char tmp[16];
sprintf(tmp, "%.1f", ui::animScale);
ui::settMenu->editOpt(13, NULL, ui::optMenuStr[13] + std::string(tmp));
}
void ui::settInit()
@ -125,10 +135,10 @@ void ui::settInit()
optHelpX = 1220 - gfx::getTextWidth(ui::optHelp.c_str(), 18);
for(unsigned i = 0; i < 13; i++)
for(unsigned i = 0; i < 14; i++)
{
ui::settMenu->addOpt(NULL, ui::optMenuStr[i]);
ui::settMenu->setOptFunc(i, FUNC_A, toggleOpt, NULL);
ui::settMenu->optAddButtonEvent(i, HidNpadButton_A, toggleOpt, NULL);
}
}

View File

@ -32,15 +32,15 @@ void ui::populateFldMenu()
*backargs = {fldMenu, fldList};
fldMenu->addOpt(NULL, "New");
fldMenu->setOptFunc(0, FUNC_A, fs::createNewBackup, backargs);
fldMenu->optAddButtonEvent(0, HidNpadButton_A, fs::createNewBackup, backargs);
for(unsigned i = 0; i < fldList->getCount(); i++)
{
fldMenu->addOpt(NULL, fldList->getItem(i));
fldMenu->setOptFunc(i + 1, FUNC_A, fs::overwriteBackup, backargs);
fldMenu->setOptFunc(i + 1, FUNC_X, fs::deleteBackup, backargs);
fldMenu->setOptFunc(i + 1, FUNC_Y, fs::restoreBackup, backargs);
fldMenu->optAddButtonEvent(i + 1, HidNpadButton_A, fs::overwriteBackup, backargs);
fldMenu->optAddButtonEvent(i + 1, HidNpadButton_X, fs::deleteBackup, backargs);
fldMenu->optAddButtonEvent(i + 1, HidNpadButton_Y, fs::restoreBackup, backargs);
}
fldMenu->setActive(true);
@ -209,15 +209,19 @@ static void ttlOptsExtendSaveData(void *a)
Result res = 0;
if(R_SUCCEEDED(res = fs::extendSaveDataFileSystem(space, sid, expSize, journ)))
{
ui::showPopMessage(POP_FRAME_DEFAULT, "Save data expanded for %s!", extend->title.c_str());
fs::logWrite("Extend Succeeded!\n");
}
else
{
int64_t totalSize = 0;
fs::mountSave(data::curData.saveInfo);
fsFsGetTotalSpace(fsdevGetDeviceFileSystem("sv"), "/", &totalSize);
fs::unmountSave();
fs::logWrite("Extend Failed: %uMB to %uMB -> %X\n", totalSize / 1024 / 1024, expSize / 1024 / 1024, res);
ui::showPopMessage(POP_FRAME_DEFAULT, "Failed to expand save data.");
fs::unmountSave();
}
}
}
@ -261,15 +265,15 @@ void ui::ttlInit()
ttlOpts->setActive(false);
ttlOpts->addOpt(NULL, ui::titleOptString[0]);
ttlOpts->setOptFunc(0, FUNC_A, ttlOptsShowInfoPanel, NULL);
ttlOpts->optAddButtonEvent(0, HidNpadButton_A, ttlOptsShowInfoPanel, NULL);
ttlOpts->addOpt(NULL, ui::titleOptString[1]);
ttlOpts->setOptFunc(1, FUNC_A, ttlOptsBlacklistTitle, NULL);
ttlOpts->optAddButtonEvent(1, HidNpadButton_A, ttlOptsBlacklistTitle, NULL);
ttlOpts->addOpt(NULL, ui::titleOptString[2]);
ttlOpts->setOptFunc(2, FUNC_A, ttlOptsResetSaveData, NULL);
ttlOpts->optAddButtonEvent(2, HidNpadButton_A, ttlOptsResetSaveData, NULL);
ttlOpts->addOpt(NULL, ui::titleOptString[3]);
ttlOpts->setOptFunc(3, FUNC_A, ttlOptsDeleteSaveData, NULL);
ttlOpts->optAddButtonEvent(3, HidNpadButton_A, ttlOptsDeleteSaveData, NULL);
ttlOpts->addOpt(NULL, ui::titleOptString[4]);
ttlOpts->setOptFunc(4, FUNC_A, ttlOptsExtendSaveData, NULL);
ttlOpts->optAddButtonEvent(4, HidNpadButton_A, ttlOptsExtendSaveData, NULL);
}

View File

@ -41,7 +41,7 @@ std::string ui::errorConnecting = "Error Connecting!";
std::string ui::noUpdate = "No updates available!";
std::string ui::advMenuStr[6] = { "Copy to ", "Delete", "Rename", "Make Dir", "Properties", "Close" };
std::string ui::exMenuStr[11] = { "SD to SD Browser", "BIS: PRODINFOF", "BIS: SAFE", "BIS: SYSTEM", "BIS: USER", "Remove Update", "Terminate Process", "Mount System Save", "Rescan Titles", "Mount Process RomFS", "Backup JKSV Folder" };
std::string ui::optMenuStr[13] = { "Include Device Saves: ", "AutoBackup: ", "Overclock: ", "Hold to Delete: ", "Hold to Restore: ", "Hold to Overwrite: ", "Force Mount: ", "Account Sys. Saves: ", "Write to Sys. Saves: ", "Direct FS Cmd: ", "Export to ZIP: ", "Language Override: ", "Sort: "};
std::string ui::optMenuStr[14] = { "Include Device Saves: ", "AutoBackup: ", "Overclock: ", "Hold to Delete: ", "Hold to Restore: ", "Hold to Overwrite: ", "Force Mount: ", "Account Sys. Saves: ", "Write to Sys. Saves: ", "Direct FS Cmd: ", "Export to ZIP: ", "Language Override: ", "Sort: ", "Animation Scale: "};
std::string ui::holdingText[3] = { "(Hold) ", "(Keep Holding) ", "(Almost there!) " };
std::string ui::sortString[3] = { "Alphabetical", "Time Played", "Last Played" };
std::string ui::usrOptString[2] = { "Create Save Data", "Delete All User Saves" };

View File

@ -308,26 +308,27 @@ void ui::usrInit()
for(data::user u : data::users)
{
int usrPos = usrMenu->addOpt(u.getUserIcon(), u.getUsername());
usrMenu->setOptFunc(usrPos, FUNC_A, toTTL, NULL);
usrMenu->optAddButtonEvent(usrPos, HidNpadButton_A, toTTL, NULL);
}
sett = util::createIconGeneric("Settings", 40);
int pos = usrMenu->addOpt(sett, "Settings");
usrMenu->setOptFunc(pos, FUNC_A, toOPT, NULL);
usrMenu->optAddButtonEvent(pos, HidNpadButton_A, toOPT, NULL);
ext = util::createIconGeneric("Extras", 40);
pos = usrMenu->addOpt(ext, "Extras");
usrMenu->setOptFunc(pos, FUNC_A, toEXT, NULL);
usrMenu->optAddButtonEvent(pos, HidNpadButton_A, toEXT, NULL);
usrMenu->setOnChangeFunc(onMainChange);
usrMenu->editParam(MENU_RECT_WIDTH, 126);
usrOptPanel = new ui::slideOutPanel(410, 720, 0, usrOptPanelDraw);
ui::registerPanel(usrOptPanel);
usrOptMenu->addOpt(NULL, ui::usrOptString[0]);
usrOptMenu->setOptFunc(0, FUNC_A, usrOptSaveCreate, usrMenu);
usrOptMenu->optAddButtonEvent(0, HidNpadButton_A, usrOptSaveCreate, usrMenu);
usrOptMenu->addOpt(NULL, ui::usrOptString[1]);
usrOptMenu->setOptFunc(1, FUNC_A, usrOptDeleteAllUserSaves, NULL);
usrOptMenu->optAddButtonEvent(1, HidNpadButton_A, usrOptDeleteAllUserSaves, NULL);
usrOptMenu->setActive(false);
saveCreatePanel = new ui::slideOutPanel(410, 720, 0, saveCreatePanelDraw);
@ -353,28 +354,28 @@ void ui::usrInit()
if(nacp->user_account_save_data_size > 0)
{
int optPos = saveCreateMenu->addOpt(NULL, t.second.title);
saveCreateMenu->setOptFunc(optPos, FUNC_A, createSaveData, &accCreate);
saveCreateMenu->optAddButtonEvent(optPos, HidNpadButton_A, createSaveData, &accCreate);
accSids.push_back(t.first);
}
if(nacp->device_save_data_size > 0)
{
int optPos = deviceSaveMenu->addOpt(NULL, t.second.title);
deviceSaveMenu->setOptFunc(optPos, FUNC_A, createSaveData, &devCreate);
deviceSaveMenu->optAddButtonEvent(optPos, HidNpadButton_A, createSaveData, &devCreate);
devSids.push_back(t.first);
}
if(nacp->bcat_delivery_cache_storage_size > 0)
{
int optPos = bcatSaveMenu->addOpt(NULL, t.second.title);
bcatSaveMenu->setOptFunc(optPos, FUNC_A, createSaveData, &bcatCreate);
bcatSaveMenu->optAddButtonEvent(optPos, HidNpadButton_A, createSaveData, &bcatCreate);
bcatSids.push_back(t.first);
}
if(nacp->cache_storage_size > 0)
{
int optPos = cacheSaveMenu->addOpt(NULL, t.second.title);
cacheSaveMenu->setOptFunc(optPos, FUNC_A, createSaveData, &cacheCreate);
cacheSaveMenu->optAddButtonEvent(optPos, HidNpadButton_A, createSaveData, &cacheCreate);
cacheSids.push_back(t.first);
}
}