Update for devkitA64
2
Makefile
|
|
@ -38,7 +38,7 @@ INCLUDES := inc
|
|||
EXEFS_SRC := exefs_src
|
||||
APP_TITLE := JKSV
|
||||
APP_AUTHOR := JK_
|
||||
APP_VERSION := 07/11/2018
|
||||
APP_VERSION := 07/15/2018
|
||||
ROMFS := romfs
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@
|
|||
|
||||
namespace ui
|
||||
{
|
||||
void clsUserPrep();
|
||||
void clsTitlePrep(data::user& u);
|
||||
void clsUserPrep();
|
||||
void clsTitlePrep(data::user& u);
|
||||
|
||||
void classicUserMenuUpdate(const uint64_t& down, const uint64_t& held, const touchPosition& p);
|
||||
void classicTitleMenuUpdate(const uint64_t& down, const uint64_t& held, const touchPosition& p);
|
||||
void classicUserMenuUpdate(const uint64_t& down, const uint64_t& held, const touchPosition& p);
|
||||
void classicTitleMenuUpdate(const uint64_t& down, const uint64_t& held, const touchPosition& p);
|
||||
}
|
||||
|
||||
#endif // CLSUI_H
|
||||
|
|
|
|||
132
inc/data.h
|
|
@ -10,94 +10,94 @@
|
|||
|
||||
namespace data
|
||||
{
|
||||
extern bool sysSave;
|
||||
extern bool sysSave;
|
||||
|
||||
//Loads user + title info
|
||||
void loadDataInfo();
|
||||
void exit();
|
||||
//Loads user + title info
|
||||
void loadDataInfo();
|
||||
void exit();
|
||||
|
||||
//Class to help not load the same icons over and over
|
||||
class icn : gfx::tex
|
||||
{
|
||||
public:
|
||||
//Loads jpeg icon from jpegData
|
||||
void load(const uint64_t& _id, const uint8_t *jpegData, const size_t& jpegSize);
|
||||
//For loading default icon
|
||||
void load(const uint64_t & _id, const std::string& _png);
|
||||
//Class to help not load the same icons over and over
|
||||
class icn : gfx::tex
|
||||
{
|
||||
public:
|
||||
//Loads jpeg icon from jpegData
|
||||
void load(const uint64_t& _id, const uint8_t *jpegData, const size_t& jpegSize);
|
||||
//For loading default icon
|
||||
void load(const uint64_t & _id, const std::string& _png);
|
||||
|
||||
void draw(unsigned x, unsigned y) { gfx::tex::draw(x, y); }
|
||||
void drawHalf(unsigned x, unsigned y) { gfx::tex::drawNoBlendSkipSmooth(x, y); }
|
||||
void draw(unsigned x, unsigned y) { gfx::tex::draw(x, y); }
|
||||
void drawHalf(unsigned x, unsigned y) { gfx::tex::drawNoBlendSkipSmooth(x, y); }
|
||||
|
||||
uint64_t getTitleID() { return titleID; }
|
||||
uint64_t getTitleID() { return titleID; }
|
||||
|
||||
void deleteData() { gfx::tex::deleteData(); }
|
||||
void deleteData() { gfx::tex::deleteData(); }
|
||||
|
||||
private:
|
||||
uint64_t titleID;
|
||||
};
|
||||
private:
|
||||
uint64_t titleID;
|
||||
};
|
||||
|
||||
//Class to store title info
|
||||
class titledata
|
||||
{
|
||||
public:
|
||||
//Attempts to read title's info. Returns false if failed
|
||||
bool init(const FsSaveDataInfo& inf);
|
||||
//Class to store title info
|
||||
class titledata
|
||||
{
|
||||
public:
|
||||
//Attempts to read title's info. Returns false if failed
|
||||
bool init(const FsSaveDataInfo& inf);
|
||||
|
||||
//Attempts to mount data with uID + id. Returns false if fails. For filtering.
|
||||
bool isMountable(const u128& uID);
|
||||
//Attempts to mount data with uID + id. Returns false if fails. For filtering.
|
||||
bool isMountable(const u128& uID);
|
||||
|
||||
//Returns title + title without forbidden chars
|
||||
std::string getTitle() { return title;}
|
||||
std::string getTitleSafe() { return titleSafe; }
|
||||
//Returns title + title without forbidden chars
|
||||
std::string getTitle() { return title;}
|
||||
std::string getTitleSafe() { return titleSafe; }
|
||||
|
||||
//Returns ID
|
||||
uint64_t getID() { return id; }
|
||||
//Returns ID
|
||||
uint64_t getID() { return id; }
|
||||
|
||||
//Game icon
|
||||
icn icon;
|
||||
//Game icon
|
||||
icn icon;
|
||||
|
||||
FsSaveDataType getType() { return type; }
|
||||
FsSaveDataType getType() { return type; }
|
||||
|
||||
private:
|
||||
FsSaveDataType type;
|
||||
std::string title, titleSafe;
|
||||
uint64_t id;
|
||||
u128 uID;
|
||||
};
|
||||
private:
|
||||
FsSaveDataType type;
|
||||
std::string title, titleSafe;
|
||||
uint64_t id;
|
||||
u128 uID;
|
||||
};
|
||||
|
||||
//Class to store user info + titles
|
||||
class user
|
||||
{
|
||||
public:
|
||||
//Attempts to read user data using _id
|
||||
bool init(const u128& _id);
|
||||
//Class to store user info + titles
|
||||
class user
|
||||
{
|
||||
public:
|
||||
//Attempts to read user data using _id
|
||||
bool init(const u128& _id);
|
||||
|
||||
//Allows user to init without reading data. For fun.
|
||||
bool initNoChk(const u128& _id);
|
||||
//Allows user to init without reading data. For fun.
|
||||
bool initNoChk(const u128& _id);
|
||||
|
||||
//Returns user ID
|
||||
u128 getUID() { return userID; }
|
||||
//Returns user ID
|
||||
u128 getUID() { return userID; }
|
||||
|
||||
//Returns username
|
||||
std::string getUsername() { return username; }
|
||||
std::string getUsernameSafe() { return userSafe; }
|
||||
//Returns username
|
||||
std::string getUsername() { return username; }
|
||||
std::string getUsernameSafe() { return userSafe; }
|
||||
|
||||
//Vector for storing save data info for user
|
||||
std::vector<titledata> titles;
|
||||
//Vector for storing save data info for user
|
||||
std::vector<titledata> titles;
|
||||
|
||||
gfx::tex icn;
|
||||
gfx::tex icn;
|
||||
|
||||
private:
|
||||
u128 userID;
|
||||
std::string username, userSafe;
|
||||
};
|
||||
private:
|
||||
u128 userID;
|
||||
std::string username, userSafe;
|
||||
};
|
||||
|
||||
//User vector
|
||||
extern std::vector<user> users;
|
||||
//User vector
|
||||
extern std::vector<user> users;
|
||||
|
||||
//Stores current data we're using so I don't have to type so much.
|
||||
extern titledata curData;
|
||||
extern user curUser;
|
||||
//Stores current data we're using so I don't have to type so much.
|
||||
extern titledata curData;
|
||||
extern user curUser;
|
||||
}
|
||||
|
||||
#endif // DATA_H
|
||||
|
|
|
|||
67
inc/file.h
|
|
@ -10,47 +10,52 @@
|
|||
|
||||
namespace fs
|
||||
{
|
||||
//Mounts usr's save data for open. Returns false it fails
|
||||
bool mountSave(data::user& usr, data::titledata& open);
|
||||
void init();
|
||||
|
||||
void copyFile(const std::string& from, const std::string& to);
|
||||
void copyFileCommit(const std::string& from, const std::string& to, const std::string& dev);
|
||||
//Mounts usr's save data for open. Returns false it fails
|
||||
bool mountSave(data::user& usr, data::titledata& open);
|
||||
|
||||
//Recursively copies 'from' to 'to'
|
||||
void copyDirToDir(const std::string& from, const std::string& to);
|
||||
void copyFile(const std::string& from, const std::string& to);
|
||||
void copyFileCommit(const std::string& from, const std::string& to, const std::string& dev);
|
||||
|
||||
//Same as above, but commits data to 'dev' after every file is closed
|
||||
void copyDirToDirCommit(const std::string& from, const std::string& to, const std::string& dev);
|
||||
//Recursively copies 'from' to 'to'
|
||||
void copyDirToDir(const std::string& from, const std::string& to);
|
||||
|
||||
//Recursively deletes 'path'
|
||||
void delDir(const std::string& path);
|
||||
//Same as above, but commits data to 'dev' after every file is closed
|
||||
void copyDirToDirCommit(const std::string& from, const std::string& to, const std::string& dev);
|
||||
|
||||
//Dumps all titles for 'user'
|
||||
void dumpAllUserSaves(data::user& u);
|
||||
//Recursively deletes 'path'
|
||||
void delDir(const std::string& path);
|
||||
|
||||
//returns file properties as C++ string
|
||||
std::string getFileProps(const std::string& _path);
|
||||
//Dumps all titles for 'user'
|
||||
void dumpAllUserSaves(data::user& u);
|
||||
|
||||
bool fileExists(const std::string& _path);
|
||||
//returns file properties as C++ string
|
||||
std::string getFileProps(const std::string& _path);
|
||||
|
||||
//Just retrieves a listing for _path and stores it in item vector
|
||||
class dirList
|
||||
{
|
||||
public:
|
||||
dirList(const std::string& _path);
|
||||
void reassign(const std::string& _path);
|
||||
void rescan();
|
||||
bool fileExists(const std::string& _path);
|
||||
|
||||
std::string getItem(int index);
|
||||
bool isDir(int index);
|
||||
unsigned getCount();
|
||||
//Retrieves working dir string
|
||||
std::string getWorkDir();
|
||||
|
||||
private:
|
||||
DIR *d;
|
||||
struct dirent *ent;
|
||||
std::string path;
|
||||
std::vector<std::string> item;
|
||||
};
|
||||
//Just retrieves a listing for _path and stores it in item vector
|
||||
class dirList
|
||||
{
|
||||
public:
|
||||
dirList(const std::string& _path);
|
||||
void reassign(const std::string& _path);
|
||||
void rescan();
|
||||
|
||||
std::string getItem(int index);
|
||||
bool isDir(int index);
|
||||
unsigned getCount();
|
||||
|
||||
private:
|
||||
DIR *d;
|
||||
struct dirent *ent;
|
||||
std::string path;
|
||||
std::vector<std::string> item;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // FILE_H
|
||||
|
|
|
|||
137
inc/gfx.h
|
|
@ -5,94 +5,91 @@
|
|||
|
||||
namespace gfx
|
||||
{
|
||||
class color
|
||||
{
|
||||
public:
|
||||
void fromRGBA(const uint8_t& _r, const uint8_t& _g, const uint8_t& _b, const uint8_t& _a);
|
||||
void fromU32(const uint32_t& _px);
|
||||
void invert();
|
||||
class color
|
||||
{
|
||||
public:
|
||||
void fromRGBA(const uint8_t& _r, const uint8_t& _g, const uint8_t& _b, const uint8_t& _a);
|
||||
void fromU32(const uint32_t& _px);
|
||||
void invert();
|
||||
|
||||
void setR(const uint8_t& _r) { rgb[3] = _r; }
|
||||
void setG(const uint8_t& _g) { rgb[2] = _g; }
|
||||
void setB(const uint8_t& _b) { rgb[1] = _b; }
|
||||
void setA(const uint8_t& _a) { rgb[0] = _a; }
|
||||
void setR(const uint8_t& _r) { rgb[3] = _r; }
|
||||
void setG(const uint8_t& _g) { rgb[2] = _g; }
|
||||
void setB(const uint8_t& _b) { rgb[1] = _b; }
|
||||
void setA(const uint8_t& _a) { rgb[0] = _a; }
|
||||
|
||||
uint8_t r() { return rgb[3]; }
|
||||
uint8_t g() { return rgb[2]; }
|
||||
uint8_t b() { return rgb[1]; }
|
||||
uint8_t a() { return rgb[0]; }
|
||||
uint32_t clr() { return rgb[0] << 24 | rgb[1] << 16 | rgb[2] << 8 | rgb[3]; }
|
||||
uint8_t r() { return rgb[3]; }
|
||||
uint8_t g() { return rgb[2]; }
|
||||
uint8_t b() { return rgb[1]; }
|
||||
uint8_t a() { return rgb[0]; }
|
||||
uint32_t clr() { return rgb[0] << 24 | rgb[1] << 16 | rgb[2] << 8 | rgb[3]; }
|
||||
|
||||
private:
|
||||
uint8_t rgb[4];
|
||||
};
|
||||
private:
|
||||
uint8_t rgb[4];
|
||||
};
|
||||
|
||||
class tex
|
||||
{
|
||||
public:
|
||||
/*
|
||||
Now uses libpng and png files
|
||||
Only accepts RGBA8 PNGs
|
||||
Others will have issues.
|
||||
*/
|
||||
void loadPNGFile(const std::string& path);
|
||||
void loadJpegMem(const uint8_t *txData, const size_t& jpegSz);
|
||||
void loadJpegFile(const std::string& path);
|
||||
//Frees memory used by data
|
||||
void deleteData();
|
||||
uint16_t getWidth() { return width; }
|
||||
uint16_t getHeight() { return height; }
|
||||
uint32_t *getDataPointer() { return data; }
|
||||
class tex
|
||||
{
|
||||
public:
|
||||
/*
|
||||
Now uses libpng and png files
|
||||
Only accepts RGBA8 PNGs
|
||||
Others will have issues.
|
||||
*/
|
||||
void loadPNGFile(const std::string& path);
|
||||
void loadJpegMem(const uint8_t *txData, const size_t& jpegSz);
|
||||
void loadJpegFile(const std::string& path);
|
||||
//Frees memory used by data
|
||||
void deleteData();
|
||||
unsigned getWidth() { return width; }
|
||||
unsigned getHeight() { return height; }
|
||||
uint32_t *getDataPointer() { return data; }
|
||||
|
||||
void draw(uint32_t x, uint32_t y);
|
||||
void drawInvert(uint32_t x, uint32_t y);
|
||||
void drawNoBlend(uint32_t x, uint32_t y);
|
||||
void draw(unsigned x, unsigned y);
|
||||
void drawInvert(unsigned x, unsigned y);
|
||||
void drawNoBlend(unsigned x, unsigned y);
|
||||
|
||||
//For lazy-scaling icons
|
||||
//Skips every-other pixel and row, so 1/2 scale
|
||||
void drawNoBlendSkip(unsigned x, unsigned y);
|
||||
void drawNoBlendSkipSmooth(unsigned x, unsigned y);
|
||||
//For lazy-scaling icons
|
||||
//Skips every-other pixel and row, so 1/2 scale
|
||||
void drawNoBlendSkip(unsigned x, unsigned y);
|
||||
void drawNoBlendSkipSmooth(unsigned x, unsigned y);
|
||||
|
||||
//These only repeat pixels.
|
||||
void drawRepeatHori(uint32_t x, uint32_t y, uint32_t w);
|
||||
void drawRepeatHoriNoBlend(uint32_t x, uint32_t y, uint32_t w);
|
||||
//These only repeat pixels.
|
||||
void drawRepeatHori(unsigned x, unsigned y, unsigned w);
|
||||
void drawRepeatHoriNoBlend(unsigned x, unsigned y, unsigned w);
|
||||
|
||||
void drawRepeatVert(uint32_t x, uint32_t y, uint32_t h);
|
||||
void drawRepeatVertNoBlend(uint32_t x, uint32_t y, uint32_t h);
|
||||
void drawRepeatVert(unsigned x, unsigned y, unsigned h);
|
||||
void drawRepeatVertNoBlend(unsigned x, unsigned y, unsigned h);
|
||||
|
||||
protected:
|
||||
uint32_t sz;
|
||||
uint16_t width, height;
|
||||
uint32_t *data = NULL;
|
||||
};
|
||||
protected:
|
||||
size_t sz;
|
||||
unsigned width, height;
|
||||
uint32_t *data = NULL;
|
||||
};
|
||||
|
||||
|
||||
//Inits graphics and shared font. Code for shared font is from switch-portlibs examples
|
||||
bool init();
|
||||
bool exit();
|
||||
//Inits graphics and shared font. Code for shared font is from switch-portlibs examples
|
||||
bool init();
|
||||
bool exit();
|
||||
|
||||
//Changes gfx mode to linear double
|
||||
void switchMode();
|
||||
//Changes gfx mode to linear double
|
||||
void switchMode();
|
||||
|
||||
void handleBuffs();
|
||||
void handleBuffs();
|
||||
|
||||
//Clears framebuffer to clr. RGBA8
|
||||
void clearBufferColor(const uint32_t& clr);
|
||||
//Clears framebuffer to clr. RGBA8
|
||||
void clearBufferColor(const uint32_t& clr);
|
||||
|
||||
//Blends two pixels. Clr is the color to be drawn. FB should be the framebuffer pixel
|
||||
uint32_t blend(color& px, color& fb);
|
||||
//Draws text using shared font.
|
||||
void drawText(const std::string& str, unsigned x, unsigned y, const unsigned& sz, const uint32_t& clr);
|
||||
|
||||
//Draws text using shared font.
|
||||
void drawText(const std::string& str, unsigned x, unsigned y, const uint32_t& sz, const uint32_t& clr);
|
||||
//Returns width of str
|
||||
unsigned getTextWidth(const std::string& str, const unsigned& sz);
|
||||
|
||||
//Returns width of str
|
||||
unsigned getTextWidth(const std::string& str, const uint32_t& sz);
|
||||
//Returns height of text if using sz
|
||||
unsigned getTextHeight(const unsigned& sz);
|
||||
|
||||
//Returns height of text if using sz
|
||||
unsigned getTextHeight(const uint32_t& sz);
|
||||
|
||||
//Draws a rectangle. clr = RGBA8. Be careful not to go outside framebuffer
|
||||
void drawRectangle(uint32_t x, uint32_t y, const uint32_t& width, const uint32_t& height, const uint32_t& clr);
|
||||
//Draws a rectangle. clr = RGBA8. Be careful not to go outside framebuffer
|
||||
void drawRectangle(const unsigned& x, const unsigned& y, const unsigned& width, const unsigned& height, const uint32_t& clr);
|
||||
}
|
||||
|
||||
#endif // GFX_H
|
||||
|
|
|
|||
78
inc/kb.h
|
|
@ -8,54 +8,54 @@
|
|||
|
||||
namespace ui
|
||||
{
|
||||
//The way it should have been. Inheritance drives me insane sometimes, but they're basically the same thing.
|
||||
class key : button
|
||||
{
|
||||
public:
|
||||
key(const std::string& _txt, const char& _l, unsigned _x, unsigned _y, unsigned _w, unsigned _h);
|
||||
//The way it should have been. Inheritance drives me insane sometimes, but they're basically the same thing.
|
||||
class key : button
|
||||
{
|
||||
public:
|
||||
key(const std::string& _txt, const char& _l, unsigned _x, unsigned _y, unsigned _w, unsigned _h);
|
||||
|
||||
//Returns char assigned to key
|
||||
char getLet() { return let; }
|
||||
//Returns char assigned to key
|
||||
char getLet() { return let; }
|
||||
|
||||
//Updates displayed text
|
||||
void updateText(const std::string& txt);
|
||||
//Updates displayed text
|
||||
void updateText(const std::string& txt);
|
||||
|
||||
//toUpper
|
||||
void toCaps();
|
||||
//toUpper
|
||||
void toCaps();
|
||||
|
||||
//toLower
|
||||
void toLower();
|
||||
//toLower
|
||||
void toLower();
|
||||
|
||||
void draw() { button::draw();}
|
||||
void update(const touchPosition& p) { button::update(p);}
|
||||
int getEvent() { return button::getEvent(); }
|
||||
int getX() { return button::getX(); }
|
||||
int getY() { return button::getY(); }
|
||||
int getW() { return w; }
|
||||
int getH() { return h; }
|
||||
void draw() { button::draw();}
|
||||
void update(const touchPosition& p) { button::update(p);}
|
||||
int getEvent() { return button::getEvent(); }
|
||||
int getX() { return button::getX(); }
|
||||
int getY() { return button::getY(); }
|
||||
int getW() { return w; }
|
||||
int getH() { return h; }
|
||||
|
||||
private:
|
||||
char let;
|
||||
};
|
||||
private:
|
||||
char let;
|
||||
};
|
||||
|
||||
class keyboard
|
||||
{
|
||||
public:
|
||||
//Builds keyboard
|
||||
keyboard();
|
||||
~keyboard();
|
||||
class keyboard
|
||||
{
|
||||
public:
|
||||
//Builds keyboard
|
||||
keyboard();
|
||||
~keyboard();
|
||||
|
||||
void draw();
|
||||
//returns string
|
||||
std::string getString(const std::string& def);
|
||||
void draw();
|
||||
//returns string
|
||||
std::string getString(const std::string& def);
|
||||
|
||||
private:
|
||||
std::vector<key> keys;
|
||||
std::string str;
|
||||
int selKey = 0;
|
||||
uint8_t clrSh = 0;
|
||||
bool clrAdd = true;
|
||||
};
|
||||
private:
|
||||
std::vector<key> keys;
|
||||
std::string str;
|
||||
int selKey = 0;
|
||||
uint8_t clrSh = 0;
|
||||
bool clrAdd = true;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // KB_H
|
||||
|
|
|
|||
66
inc/menu.h
|
|
@ -8,50 +8,50 @@
|
|||
|
||||
enum menuTouch
|
||||
{
|
||||
MENU_NOTHING,
|
||||
MENU_DOUBLE_REL
|
||||
MENU_NOTHING,
|
||||
MENU_DOUBLE_REL
|
||||
};
|
||||
|
||||
namespace ui
|
||||
{
|
||||
class menu
|
||||
{
|
||||
public:
|
||||
void setParams(const unsigned& _x, const unsigned& _y, const unsigned& _rW);
|
||||
//Adds option
|
||||
void addOpt(const std::string& add);
|
||||
//Clears menu stuff
|
||||
~menu();
|
||||
class menu
|
||||
{
|
||||
public:
|
||||
void setParams(const unsigned& _x, const unsigned& _y, const unsigned& _rW);
|
||||
//Adds option
|
||||
void addOpt(const std::string& add);
|
||||
//Clears menu stuff
|
||||
~menu();
|
||||
|
||||
//Handles controller input
|
||||
void handleInput(const uint64_t& down, const uint64_t& held, const touchPosition& p);
|
||||
//Handles controller input
|
||||
void handleInput(const uint64_t& down, const uint64_t& held, const touchPosition& p);
|
||||
|
||||
//Returns selected option
|
||||
int getSelected() { return selected; }
|
||||
//Returns selected option
|
||||
int getSelected() { return selected; }
|
||||
|
||||
//Returns touch event from buttons
|
||||
int getTouchEvent() { return retEvent; }
|
||||
//Returns touch event from buttons
|
||||
int getTouchEvent() { return retEvent; }
|
||||
|
||||
//Draws the menu at x and y. rectWidth is the width of the rectangle drawn under the selected
|
||||
void draw(const uint32_t& textClr);
|
||||
//Draws the menu at x and y. rectWidth is the width of the rectangle drawn under the selected
|
||||
void draw(const uint32_t& textClr);
|
||||
|
||||
//Clears and resets menu
|
||||
void reset();
|
||||
//Clears and resets menu
|
||||
void reset();
|
||||
|
||||
private:
|
||||
//drawing x and y + rectangle width
|
||||
unsigned x, y, rW, rY;
|
||||
//Options vector
|
||||
std::vector<std::string> opt;
|
||||
//Selected + frame counting for auto-scroll
|
||||
int selected = 0, fc = 0, start = 0, retEvent = MENU_NOTHING;
|
||||
//How much we shift the color of the rectangle
|
||||
uint8_t clrSh = 0;
|
||||
bool clrAdd = true;
|
||||
private:
|
||||
//drawing x and y + rectangle width
|
||||
unsigned x = 0, y = 0, rW = 0, rY = 0;
|
||||
//Options vector
|
||||
std::vector<std::string> opt;
|
||||
//Selected + frame counting for auto-scroll
|
||||
int selected = 0, fc = 0, start = 0, retEvent = MENU_NOTHING;
|
||||
//How much we shift the color of the rectangle
|
||||
uint8_t clrSh = 0;
|
||||
bool clrAdd = true;
|
||||
|
||||
ui::touchTrack track;
|
||||
std::vector<ui::button> optButtons;
|
||||
};
|
||||
ui::touchTrack track;
|
||||
std::vector<ui::button> optButtons;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
118
inc/miscui.h
|
|
@ -3,85 +3,85 @@
|
|||
|
||||
enum buttonEvents
|
||||
{
|
||||
BUTTON_NOTHING,
|
||||
BUTTON_PRESSED,
|
||||
BUTTON_RELEASED
|
||||
BUTTON_NOTHING,
|
||||
BUTTON_PRESSED,
|
||||
BUTTON_RELEASED
|
||||
};
|
||||
|
||||
enum trackEvents
|
||||
{
|
||||
TRACK_NOTHING,
|
||||
TRACK_SWIPE_UP,
|
||||
TRACK_SWIPE_DOWN,
|
||||
TRACK_SWIPE_LEFT,
|
||||
TRACK_SWIPE_RIGHT
|
||||
TRACK_NOTHING,
|
||||
TRACK_SWIPE_UP,
|
||||
TRACK_SWIPE_DOWN,
|
||||
TRACK_SWIPE_LEFT,
|
||||
TRACK_SWIPE_RIGHT
|
||||
};
|
||||
|
||||
//For smaller classes that aren't easy to get lost in and general functions
|
||||
namespace ui
|
||||
{
|
||||
//Progress bar for showing loading. Mostly so people know it didn't freeze
|
||||
class progBar
|
||||
{
|
||||
public:
|
||||
//Constructor. _max is the maximum value
|
||||
progBar(const uint32_t& _max);
|
||||
//Progress bar for showing loading. Mostly so people know it didn't freeze
|
||||
class progBar
|
||||
{
|
||||
public:
|
||||
//Constructor. _max is the maximum value
|
||||
progBar(const unsigned& _max);
|
||||
|
||||
//Updates progress
|
||||
void update(const uint32_t& _prog);
|
||||
//Updates progress
|
||||
void update(const unsigned& _prog);
|
||||
|
||||
//Draws with text at top
|
||||
void draw(const std::string& text);
|
||||
//Draws with text at top
|
||||
void draw(const std::string& text);
|
||||
|
||||
private:
|
||||
float max, prog, width;
|
||||
};
|
||||
private:
|
||||
float max, prog, width;
|
||||
};
|
||||
|
||||
class button
|
||||
{
|
||||
public:
|
||||
button(const std::string& _txt, unsigned _x, unsigned _y, unsigned _w, unsigned _h);
|
||||
void update(const touchPosition& p);
|
||||
bool isOver();
|
||||
bool wasOver();
|
||||
int getEvent() { return retEvent; }
|
||||
class button
|
||||
{
|
||||
public:
|
||||
button(const std::string& _txt, unsigned _x, unsigned _y, unsigned _w, unsigned _h);
|
||||
void update(const touchPosition& p);
|
||||
bool isOver();
|
||||
bool wasOver();
|
||||
int getEvent() { return retEvent; }
|
||||
|
||||
void draw();
|
||||
void draw();
|
||||
|
||||
unsigned getX() { return x; }
|
||||
unsigned getY() { return y; }
|
||||
unsigned getTx() { return tx; }
|
||||
unsigned getTy() { return ty; }
|
||||
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;
|
||||
};
|
||||
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);
|
||||
class touchTrack
|
||||
{
|
||||
public:
|
||||
void update(const touchPosition& p);
|
||||
|
||||
int getEvent() { return retTrack; }
|
||||
int getEvent() { return retTrack; }
|
||||
|
||||
private:
|
||||
touchPosition pos[5];
|
||||
int retTrack = TRACK_NOTHING;
|
||||
int curPos = 0, avX = 0, avY = 0;
|
||||
};
|
||||
private:
|
||||
touchPosition pos[5];
|
||||
int retTrack = TRACK_NOTHING;
|
||||
int curPos = 0, avX = 0, avY = 0;
|
||||
};
|
||||
|
||||
//General use
|
||||
void showMessage(const std::string& mess);
|
||||
void showError(const std::string& mess, const Result& r);
|
||||
bool confirm(const std::string& q);
|
||||
bool confirmTransfer(const std::string& f, const std::string& t);
|
||||
bool confirmDelete(const std::string& p);
|
||||
void drawTextbox(unsigned x, unsigned y, unsigned w, unsigned h);
|
||||
//General use
|
||||
void showMessage(const std::string& mess);
|
||||
void showError(const std::string& mess, const Result& r);
|
||||
bool confirm(const std::string& q);
|
||||
bool confirmTransfer(const std::string& f, const std::string& t);
|
||||
bool confirmDelete(const std::string& p);
|
||||
void drawTextbox(unsigned x, unsigned y, unsigned w, unsigned h);
|
||||
}
|
||||
|
||||
#endif // MISCUI_H
|
||||
|
|
|
|||
60
inc/ui.h
|
|
@ -16,50 +16,50 @@
|
|||
|
||||
enum menuState
|
||||
{
|
||||
USR_SEL,
|
||||
TTL_SEL,
|
||||
FLD_SEL,
|
||||
ADV_MDE,
|
||||
CLS_USR,
|
||||
CLS_TTL
|
||||
USR_SEL,
|
||||
TTL_SEL,
|
||||
FLD_SEL,
|
||||
ADV_MDE,
|
||||
CLS_USR,
|
||||
CLS_TTL
|
||||
};
|
||||
|
||||
|
||||
namespace ui
|
||||
{
|
||||
//Classic mode/text menus
|
||||
extern bool clsMode;
|
||||
//Classic mode/text menus
|
||||
extern bool clsMode;
|
||||
|
||||
//Current menu/ui state
|
||||
extern int mstate;
|
||||
//Current menu/ui state
|
||||
extern int mstate;
|
||||
|
||||
//Both UI modes need access to this
|
||||
extern std::string folderMenuInfo;
|
||||
//Both UI modes need access to this
|
||||
extern std::string folderMenuInfo;
|
||||
|
||||
//Colors to use now that I added theme detection
|
||||
extern uint32_t clearClr, mnuTxt, txtClr, rectLt, rectSh, tboxClr;
|
||||
//Colors to use now that I added theme detection
|
||||
extern uint32_t clearClr, mnuTxt, txtClr, rectLt, rectSh, tboxClr;
|
||||
|
||||
//Button tex
|
||||
extern gfx::tex buttonA, buttonB, buttonX, buttonY, buttonMin;
|
||||
//Textbox graphics
|
||||
extern gfx::tex cornerTopLeft, cornerTopRight, cornerBottomLeft, cornerBottomRight,\
|
||||
horEdgeTop, horEdgeBot, vertEdgeLeft, vertEdgeRight;
|
||||
//Button tex
|
||||
extern gfx::tex buttonA, buttonB, buttonX, buttonY, buttonMin;
|
||||
//Textbox graphics
|
||||
extern gfx::tex cornerTopLeft, cornerTopRight, cornerBottomLeft, cornerBottomRight,\
|
||||
horEdgeTop, horEdgeBot, vertEdgeLeft, vertEdgeRight;
|
||||
|
||||
extern std::vector<ui::button> selButtons;
|
||||
extern std::vector<ui::button> selButtons;
|
||||
|
||||
//Loads in the A, B, X, Y button graphics
|
||||
void init();
|
||||
void exit();
|
||||
//Loads in the A, B, X, Y button graphics
|
||||
void init();
|
||||
void exit();
|
||||
|
||||
//Prepares ui
|
||||
//Sets up buttons for icon touchin
|
||||
void setupSelButtons();
|
||||
//Prepares ui
|
||||
//Sets up buttons for icon touchin
|
||||
void setupSelButtons();
|
||||
|
||||
//Clears and draws general stuff used by multiple screens
|
||||
void drawUI();
|
||||
//Clears and draws general stuff used by multiple screens
|
||||
void drawUI();
|
||||
|
||||
//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);
|
||||
//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);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -5,15 +5,15 @@
|
|||
|
||||
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, 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);
|
||||
|
||||
//needed here since it uses static menu
|
||||
void folderMenuPrepare(data::user& usr, data::titledata& dat);
|
||||
void advCopyMenuPrep();
|
||||
void advModePrep();
|
||||
//needed here since it uses static menu
|
||||
void folderMenuPrepare(data::user& usr, data::titledata& dat);
|
||||
void advCopyMenuPrep();
|
||||
void advModePrep();
|
||||
}
|
||||
|
||||
#endif // USRSEL_H
|
||||
|
|
|
|||
28
inc/util.h
|
|
@ -7,26 +7,26 @@
|
|||
|
||||
namespace util
|
||||
{
|
||||
//Returns string with date + time
|
||||
std::string getDateTime();
|
||||
//Returns string with date + time
|
||||
std::string getDateTime();
|
||||
|
||||
//Creates Dir 'JKSV/[title]
|
||||
void makeTitleDir(data::user& u, data::titledata& t);
|
||||
//Creates Dir 'JKSV/[title]
|
||||
void makeTitleDir(data::user& u, data::titledata& t);
|
||||
|
||||
//Returns 'JKSV/[title]/'
|
||||
std::string getTitleDir(data::user& u, data::titledata& t);
|
||||
//Returns 'JKSV/[title]/'
|
||||
std::string getTitleDir(data::user& u, data::titledata& t);
|
||||
|
||||
//Just returns string with '\n' inserted.
|
||||
std::string getWrappedString(const std::string& s, const unsigned& sz, const unsigned& maxWidth);
|
||||
//Just returns string with '\n' inserted.
|
||||
std::string getWrappedString(const std::string& s, const unsigned& sz, const unsigned& maxWidth);
|
||||
|
||||
//Copys dir list to a menu with 'D: ' + 'F: '
|
||||
void copyDirListToMenu(fs::dirList& d, ui::menu& m);
|
||||
//Copys dir list to a menu with 'D: ' + 'F: '
|
||||
void copyDirListToMenu(fs::dirList& d, ui::menu& m);
|
||||
|
||||
//Removes last folder from '_path'
|
||||
void removeLastFolderFromString(std::string& _path);
|
||||
//Removes last folder from '_path'
|
||||
void removeLastFolderFromString(std::string& _path);
|
||||
|
||||
std::string safeString(const std::string& s);
|
||||
std::string safeString(const std::string& s);
|
||||
|
||||
std::string getInfoString(data::user& u, data::titledata& d);
|
||||
std::string getInfoString(data::user& u, data::titledata& d);
|
||||
}
|
||||
#endif // UTIL_H
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 240 B |
|
Before Width: | Height: | Size: 235 B |
|
Before Width: | Height: | Size: 236 B |
|
Before Width: | Height: | Size: 237 B |
|
Before Width: | Height: | Size: 237 B |
|
Before Width: | Height: | Size: 230 B |
|
Before Width: | Height: | Size: 252 B |
|
Before Width: | Height: | Size: 245 B |
|
Before Width: | Height: | Size: 181 B |
|
Before Width: | Height: | Size: 181 B |
|
Before Width: | Height: | Size: 180 B |
|
Before Width: | Height: | Size: 182 B |
|
Before Width: | Height: | Size: 175 B |
|
Before Width: | Height: | Size: 175 B |
|
Before Width: | Height: | Size: 176 B |
|
Before Width: | Height: | Size: 177 B |
BIN
romfs/img/tboxDrk/tboxCornerBotLeft.png
Normal file
|
After Width: | Height: | Size: 287 B |
BIN
romfs/img/tboxDrk/tboxCornerBotRight.png
Normal file
|
After Width: | Height: | Size: 267 B |
BIN
romfs/img/tboxDrk/tboxCornerTopLeft.png
Normal file
|
After Width: | Height: | Size: 290 B |
BIN
romfs/img/tboxDrk/tboxCornerTopRight.png
Normal file
|
After Width: | Height: | Size: 287 B |
BIN
romfs/img/tboxLght/tboxCornerBotLeft.png
Normal file
|
After Width: | Height: | Size: 273 B |
BIN
romfs/img/tboxLght/tboxCornerBotRight.png
Normal file
|
After Width: | Height: | Size: 266 B |
BIN
romfs/img/tboxLght/tboxCornerTopLeft.png
Normal file
|
After Width: | Height: | Size: 279 B |
BIN
romfs/img/tboxLght/tboxCornerTopRight.png
Normal file
|
After Width: | Height: | Size: 285 B |
440
src/data.cpp
|
|
@ -13,278 +13,278 @@
|
|||
//Sorts titles sort-of alphabetically
|
||||
static struct
|
||||
{
|
||||
bool operator()(data::titledata& a, data::titledata& b)
|
||||
{
|
||||
for(unsigned i = 0; i < a.getTitle().length(); i++)
|
||||
{
|
||||
int charA = tolower(a.getTitle().c_str()[i]), charB = tolower(b.getTitle().c_str()[i]);
|
||||
if(charA != charB)
|
||||
return charA < charB;
|
||||
}
|
||||
bool operator()(data::titledata& a, data::titledata& b)
|
||||
{
|
||||
for(unsigned i = 0; i < a.getTitle().length(); i++)
|
||||
{
|
||||
int charA = tolower(a.getTitle().c_str()[i]), charB = tolower(b.getTitle().c_str()[i]);
|
||||
if(charA != charB)
|
||||
return charA < charB;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} sortTitles;
|
||||
|
||||
//Returns -1 for new
|
||||
static int getUserIndex(const u128& id)
|
||||
{
|
||||
for(unsigned i = 0; i < data::users.size(); i++)
|
||||
{
|
||||
if(data::users[i].getUID() == id)
|
||||
return i;
|
||||
}
|
||||
for(unsigned i = 0; i < data::users.size(); i++)
|
||||
{
|
||||
if(data::users[i].getUID() == id)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
namespace data
|
||||
{
|
||||
titledata curData;
|
||||
user curUser;
|
||||
std::vector<icn> icons;
|
||||
std::vector<user> users;
|
||||
bool sysSave = false;
|
||||
titledata curData;
|
||||
user curUser;
|
||||
std::vector<icn> icons;
|
||||
std::vector<user> users;
|
||||
bool sysSave = false;
|
||||
|
||||
void loadDataInfo()
|
||||
{
|
||||
icn defIcon;
|
||||
defIcon.load(0, "romfs:/img/icn/icnDefault.png");
|
||||
icons.push_back(defIcon);
|
||||
void loadDataInfo()
|
||||
{
|
||||
icn defIcon;
|
||||
defIcon.load(0, "romfs:/img/icn/icnDefault.png");
|
||||
icons.push_back(defIcon);
|
||||
|
||||
for(unsigned i = 0; i < users.size(); i++)
|
||||
users[i].titles.clear();
|
||||
for(unsigned i = 0; i < users.size(); i++)
|
||||
users[i].titles.clear();
|
||||
|
||||
users.clear();
|
||||
users.clear();
|
||||
|
||||
Result res = 0;
|
||||
FsSaveDataIterator saveIt;
|
||||
size_t total = 0;
|
||||
FsSaveDataInfo info;
|
||||
Result res = 0;
|
||||
FsSaveDataIterator saveIt;
|
||||
size_t total = 0;
|
||||
FsSaveDataInfo info;
|
||||
|
||||
res = fsOpenSaveDataIterator(&saveIt, FsSaveDataSpaceId_All);
|
||||
if(R_FAILED(res))
|
||||
{
|
||||
printf("SaveDataIterator Failed\n");
|
||||
return;
|
||||
}
|
||||
res = fsOpenSaveDataIterator(&saveIt, FsSaveDataSpaceId_All);
|
||||
if(R_FAILED(res))
|
||||
{
|
||||
printf("SaveDataIterator Failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
while(true)
|
||||
{
|
||||
res = fsSaveDataIteratorRead(&saveIt, &info, 1, &total);
|
||||
if(R_FAILED(res) || total == 0)
|
||||
break;
|
||||
while(true)
|
||||
{
|
||||
res = fsSaveDataIteratorRead(&saveIt, &info, 1, &total);
|
||||
if(R_FAILED(res) || total == 0)
|
||||
break;
|
||||
|
||||
if((info.SaveDataType == FsSaveDataType_SaveData) || sysSave)
|
||||
{
|
||||
int u = getUserIndex(info.userID);
|
||||
if(u == -1)
|
||||
{
|
||||
user newUser;
|
||||
if(newUser.init(info.userID) || (sysSave && newUser.initNoChk(info.userID)))
|
||||
{
|
||||
users.push_back(newUser);
|
||||
if((info.SaveDataType == FsSaveDataType_SaveData) || sysSave)
|
||||
{
|
||||
int u = getUserIndex(info.userID);
|
||||
if(u == -1)
|
||||
{
|
||||
user newUser;
|
||||
if(newUser.init(info.userID) || (sysSave && newUser.initNoChk(info.userID)))
|
||||
{
|
||||
users.push_back(newUser);
|
||||
|
||||
u = getUserIndex(info.userID);
|
||||
titledata newData;
|
||||
if(newData.init(info) && newData.isMountable(newUser.getUID()))
|
||||
{
|
||||
users[u].titles.push_back(newData);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
titledata newData;
|
||||
if(newData.init(info) && newData.isMountable(users[u].getUID()))
|
||||
{
|
||||
users[u].titles.push_back(newData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
u = getUserIndex(info.userID);
|
||||
titledata newData;
|
||||
if(newData.init(info) && newData.isMountable(newUser.getUID()))
|
||||
{
|
||||
users[u].titles.push_back(newData);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
titledata newData;
|
||||
if(newData.init(info) && newData.isMountable(users[u].getUID()))
|
||||
{
|
||||
users[u].titles.push_back(newData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fsSaveDataIteratorClose(&saveIt);
|
||||
fsSaveDataIteratorClose(&saveIt);
|
||||
|
||||
for(unsigned i = 0; i < users.size(); i++)
|
||||
std::sort(users[i].titles.begin(), users[i].titles.end(), sortTitles);
|
||||
for(unsigned i = 0; i < users.size(); i++)
|
||||
std::sort(users[i].titles.begin(), users[i].titles.end(), sortTitles);
|
||||
|
||||
curUser = users[0];
|
||||
}
|
||||
curUser = users[0];
|
||||
}
|
||||
|
||||
void exit()
|
||||
{
|
||||
for(unsigned i = 0; i < users.size(); i++)
|
||||
users[i].icn.deleteData();
|
||||
void exit()
|
||||
{
|
||||
for(unsigned i = 0; i < users.size(); i++)
|
||||
users[i].icn.deleteData();
|
||||
|
||||
for(unsigned i = 0; i < icons.size(); i++)
|
||||
icons[i].deleteData();
|
||||
}
|
||||
for(unsigned i = 0; i < icons.size(); i++)
|
||||
icons[i].deleteData();
|
||||
}
|
||||
|
||||
void icn::load(const uint64_t& _id, const uint8_t *jpegData, const size_t& jpegSize)
|
||||
{
|
||||
titleID = _id;
|
||||
gfx::tex::loadJpegMem(jpegData, jpegSize);
|
||||
}
|
||||
void icn::load(const uint64_t& _id, const uint8_t *jpegData, const size_t& jpegSize)
|
||||
{
|
||||
titleID = _id;
|
||||
gfx::tex::loadJpegMem(jpegData, jpegSize);
|
||||
}
|
||||
|
||||
void icn::load(const uint64_t& _id, const std::string& _png)
|
||||
{
|
||||
titleID = _id;
|
||||
gfx::tex::loadPNGFile(_png);
|
||||
}
|
||||
void icn::load(const uint64_t& _id, const std::string& _png)
|
||||
{
|
||||
titleID = _id;
|
||||
gfx::tex::loadPNGFile(_png);
|
||||
}
|
||||
|
||||
int findIcnIndex(const uint64_t& titleID)
|
||||
{
|
||||
for(unsigned i = 0; i < icons.size(); i++)
|
||||
{
|
||||
if(icons[i].getTitleID() == titleID)
|
||||
return i;
|
||||
}
|
||||
int findIcnIndex(const uint64_t& titleID)
|
||||
{
|
||||
for(unsigned i = 0; i < icons.size(); i++)
|
||||
{
|
||||
if(icons[i].getTitleID() == titleID)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool titledata::init(const FsSaveDataInfo& inf)
|
||||
{
|
||||
Result res = 0;
|
||||
NsApplicationControlData *dat = new NsApplicationControlData;
|
||||
std::memset(dat, 0, sizeof(NsApplicationControlData));
|
||||
NacpLanguageEntry *ent = NULL;
|
||||
bool titledata::init(const FsSaveDataInfo& inf)
|
||||
{
|
||||
Result res = 0;
|
||||
NsApplicationControlData *dat = new NsApplicationControlData;
|
||||
std::memset(dat, 0, sizeof(NsApplicationControlData));
|
||||
NacpLanguageEntry *ent = NULL;
|
||||
|
||||
if(inf.SaveDataType == FsSaveDataType_SaveData)
|
||||
id = inf.titleID;
|
||||
else if(inf.SaveDataType == FsSaveDataType_SystemSaveData)
|
||||
id = inf.saveID;
|
||||
if(inf.SaveDataType == FsSaveDataType_SaveData)
|
||||
id = inf.titleID;
|
||||
else if(inf.SaveDataType == FsSaveDataType_SystemSaveData)
|
||||
id = inf.saveID;
|
||||
|
||||
uID = inf.userID;
|
||||
type = (FsSaveDataType)inf.SaveDataType;
|
||||
size_t outSz = 0;
|
||||
uID = inf.userID;
|
||||
type = (FsSaveDataType)inf.SaveDataType;
|
||||
size_t outSz = 0;
|
||||
|
||||
res = nsGetApplicationControlData(1, id, dat, sizeof(NsApplicationControlData), &outSz);
|
||||
if(R_FAILED(res) || outSz < sizeof(dat->nacp))
|
||||
{
|
||||
if(!sysSave)
|
||||
printf("nsGetAppCtrlData Failed: 0x%08X\n", (unsigned)res);
|
||||
delete dat;
|
||||
}
|
||||
res = nsGetApplicationControlData(1, id, dat, sizeof(NsApplicationControlData), &outSz);
|
||||
if(R_FAILED(res) || outSz < sizeof(dat->nacp))
|
||||
{
|
||||
if(!sysSave)
|
||||
printf("nsGetAppCtrlData Failed: 0x%08X\n", (unsigned)res);
|
||||
delete dat;
|
||||
}
|
||||
|
||||
if(R_SUCCEEDED(res))
|
||||
{
|
||||
res = nacpGetLanguageEntry(&dat->nacp, &ent);
|
||||
if(R_FAILED(res) || ent == NULL)
|
||||
{
|
||||
printf("nacpGetLanguageEntry Failed\n");
|
||||
delete dat;
|
||||
}
|
||||
}
|
||||
if(R_SUCCEEDED(res))
|
||||
{
|
||||
res = nacpGetLanguageEntry(&dat->nacp, &ent);
|
||||
if(R_FAILED(res) || ent == NULL)
|
||||
{
|
||||
printf("nacpGetLanguageEntry Failed\n");
|
||||
delete dat;
|
||||
}
|
||||
}
|
||||
|
||||
if(R_SUCCEEDED(res))
|
||||
{
|
||||
title.assign(ent->name);
|
||||
titleSafe = util::safeString(ent->name);
|
||||
if(R_SUCCEEDED(res))
|
||||
{
|
||||
title.assign(ent->name);
|
||||
titleSafe = util::safeString(ent->name);
|
||||
|
||||
int iconIndex = findIcnIndex(id);
|
||||
if(iconIndex == -1)
|
||||
{
|
||||
uint32_t icnSize = outSz - sizeof(dat->nacp);
|
||||
icn newIcon;
|
||||
newIcon.load(id, dat->icon, icnSize);
|
||||
icons.push_back(newIcon);
|
||||
int iconIndex = findIcnIndex(id);
|
||||
if(iconIndex == -1)
|
||||
{
|
||||
uint32_t icnSize = outSz - sizeof(dat->nacp);
|
||||
icn newIcon;
|
||||
newIcon.load(id, dat->icon, icnSize);
|
||||
icons.push_back(newIcon);
|
||||
|
||||
icon = icons[findIcnIndex(id)];
|
||||
}
|
||||
else
|
||||
icon = icons[iconIndex];
|
||||
icon = icons[findIcnIndex(id)];
|
||||
}
|
||||
else
|
||||
icon = icons[iconIndex];
|
||||
|
||||
delete dat;
|
||||
}
|
||||
else
|
||||
{
|
||||
char tmp[32];
|
||||
sprintf(tmp, "%016lX", (u64)id);
|
||||
title.assign(tmp);
|
||||
titleSafe = util::safeString(tmp);
|
||||
icon = icons[0];
|
||||
}
|
||||
delete dat;
|
||||
}
|
||||
else
|
||||
{
|
||||
char tmp[32];
|
||||
sprintf(tmp, "%016lX", (u64)id);
|
||||
title.assign(tmp);
|
||||
titleSafe = util::safeString(tmp);
|
||||
icon = icons[0];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool titledata::isMountable(const u128& uID)
|
||||
{
|
||||
data::user tmpUser;
|
||||
tmpUser.initNoChk(uID);
|
||||
if(fs::mountSave(tmpUser, *this))
|
||||
{
|
||||
fsdevUnmountDevice("sv");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool titledata::isMountable(const u128& uID)
|
||||
{
|
||||
data::user tmpUser;
|
||||
tmpUser.initNoChk(uID);
|
||||
if(fs::mountSave(tmpUser, *this))
|
||||
{
|
||||
fsdevUnmountDevice("sv");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool user::init(const u128& _id)
|
||||
{
|
||||
Result res = 0;
|
||||
userID = _id;
|
||||
bool user::init(const u128& _id)
|
||||
{
|
||||
Result res = 0;
|
||||
userID = _id;
|
||||
|
||||
AccountProfile prof;
|
||||
AccountProfileBase base;
|
||||
AccountProfile prof;
|
||||
AccountProfileBase base;
|
||||
|
||||
res = accountGetProfile(&prof, userID);
|
||||
if(R_FAILED(res))
|
||||
return false;
|
||||
res = accountGetProfile(&prof, userID);
|
||||
if(R_FAILED(res))
|
||||
return false;
|
||||
|
||||
res = accountProfileGet(&prof, NULL, &base);
|
||||
if(R_FAILED(res))
|
||||
return false;
|
||||
res = accountProfileGet(&prof, NULL, &base);
|
||||
if(R_FAILED(res))
|
||||
return false;
|
||||
|
||||
username.assign(base.username);
|
||||
if(username.empty())
|
||||
username = "Unknown";
|
||||
userSafe = util::safeString(username);
|
||||
username.assign(base.username);
|
||||
if(username.empty())
|
||||
username = "Unknown";
|
||||
userSafe = util::safeString(username);
|
||||
|
||||
size_t sz = 0;
|
||||
accountProfileGetImageSize(&prof, &sz);
|
||||
uint8_t *profJpeg = new uint8_t[sz];
|
||||
size_t sz = 0;
|
||||
accountProfileGetImageSize(&prof, &sz);
|
||||
uint8_t *profJpeg = new uint8_t[sz];
|
||||
|
||||
accountProfileLoadImage(&prof, profJpeg, sz, &sz);
|
||||
icn.loadJpegMem(profJpeg, sz);
|
||||
accountProfileLoadImage(&prof, profJpeg, sz, &sz);
|
||||
icn.loadJpegMem(profJpeg, sz);
|
||||
|
||||
delete[] profJpeg;
|
||||
delete[] profJpeg;
|
||||
|
||||
accountProfileClose(&prof);
|
||||
accountProfileClose(&prof);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool user::initNoChk(const u128& _id)
|
||||
{
|
||||
Result res = 0;
|
||||
userID = _id;
|
||||
bool user::initNoChk(const u128& _id)
|
||||
{
|
||||
Result res = 0;
|
||||
userID = _id;
|
||||
|
||||
AccountProfile prof;
|
||||
AccountProfileBase base;
|
||||
AccountProfile prof;
|
||||
AccountProfileBase base;
|
||||
|
||||
res = accountGetProfile(&prof, userID);
|
||||
if(R_SUCCEEDED(res))
|
||||
{
|
||||
res = accountProfileGet(&prof, NULL, &base);
|
||||
}
|
||||
res = accountGetProfile(&prof, userID);
|
||||
if(R_SUCCEEDED(res))
|
||||
{
|
||||
res = accountProfileGet(&prof, NULL, &base);
|
||||
}
|
||||
|
||||
if(R_SUCCEEDED(res))
|
||||
{
|
||||
username.assign(base.username);
|
||||
userSafe = util::safeString(username);
|
||||
accountProfileClose(&prof);
|
||||
}
|
||||
else
|
||||
{
|
||||
username = "Unknown";
|
||||
userSafe = "Unknown";
|
||||
//This shouldn't happen too much
|
||||
icn.loadPNGFile("romfs:/img/icn/icnDefault.png");
|
||||
}
|
||||
if(R_SUCCEEDED(res))
|
||||
{
|
||||
username.assign(base.username);
|
||||
userSafe = util::safeString(username);
|
||||
accountProfileClose(&prof);
|
||||
}
|
||||
else
|
||||
{
|
||||
username = "Unknown";
|
||||
userSafe = "Unknown";
|
||||
//This shouldn't happen too much
|
||||
icn.loadPNGFile("romfs:/img/icn/icnDefault.png");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
479
src/file.cpp
|
|
@ -13,299 +13,314 @@
|
|||
|
||||
#define BUFF_SIZE 512 * 1024
|
||||
|
||||
static std::string wd;
|
||||
|
||||
namespace fs
|
||||
{
|
||||
bool mountSave(data::user& usr, data::titledata& open)
|
||||
{
|
||||
FsFileSystem sv;
|
||||
Result res = 0;
|
||||
void init()
|
||||
{
|
||||
mkdir("sdmc:/JKSV", 777);
|
||||
chdir("sdmc:/JKSV");
|
||||
|
||||
if(open.getType() == FsSaveDataType_SaveData)
|
||||
{
|
||||
res = fsMount_SaveData(&sv, open.getID(), usr.getUID());
|
||||
if(R_FAILED(res))
|
||||
return false;
|
||||
wd = "sdmc:/JKSV/";
|
||||
}
|
||||
|
||||
int r = fsdevMountDevice("sv", sv);
|
||||
if(r == -1)
|
||||
return false;
|
||||
}
|
||||
else if(data::sysSave)
|
||||
{
|
||||
res = fsMount_SystemSaveData(&sv, open.getID());
|
||||
if(R_FAILED(res))
|
||||
return false;
|
||||
bool mountSave(data::user& usr, data::titledata& open)
|
||||
{
|
||||
FsFileSystem sv;
|
||||
Result res = 0;
|
||||
|
||||
int r = fsdevMountDevice("sv", sv);
|
||||
if(r == -1)
|
||||
return false;
|
||||
}
|
||||
if(open.getType() == FsSaveDataType_SaveData)
|
||||
{
|
||||
res = fsMount_SaveData(&sv, open.getID(), usr.getUID());
|
||||
if(R_FAILED(res))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
int r = fsdevMountDevice("sv", sv);
|
||||
if(r == -1)
|
||||
return false;
|
||||
}
|
||||
else if(data::sysSave)
|
||||
{
|
||||
res = fsMount_SystemSaveData(&sv, open.getID());
|
||||
if(R_FAILED(res))
|
||||
return false;
|
||||
|
||||
dirList::dirList(const std::string& _path)
|
||||
{
|
||||
path = _path;
|
||||
d = opendir(path.c_str());
|
||||
int r = fsdevMountDevice("sv", sv);
|
||||
if(r == -1)
|
||||
return false;
|
||||
}
|
||||
|
||||
while((ent = readdir(d)))
|
||||
{
|
||||
item.push_back(ent->d_name);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
closedir(d);
|
||||
}
|
||||
dirList::dirList(const std::string& _path)
|
||||
{
|
||||
path = _path;
|
||||
d = opendir(path.c_str());
|
||||
|
||||
void dirList::reassign(const std::string& _path)
|
||||
{
|
||||
path = _path;
|
||||
while((ent = readdir(d)))
|
||||
{
|
||||
item.push_back(ent->d_name);
|
||||
}
|
||||
|
||||
d = opendir(path.c_str());
|
||||
closedir(d);
|
||||
}
|
||||
|
||||
item.clear();
|
||||
void dirList::reassign(const std::string& _path)
|
||||
{
|
||||
path = _path;
|
||||
|
||||
while((ent = readdir(d)))
|
||||
{
|
||||
item.push_back(ent->d_name);
|
||||
}
|
||||
d = opendir(path.c_str());
|
||||
|
||||
closedir(d);
|
||||
}
|
||||
item.clear();
|
||||
|
||||
void dirList::rescan()
|
||||
{
|
||||
item.clear();
|
||||
d = opendir(path.c_str());
|
||||
while((ent = readdir(d)))
|
||||
{
|
||||
item.push_back(ent->d_name);
|
||||
}
|
||||
|
||||
while((ent = readdir(d)))
|
||||
{
|
||||
item.push_back(ent->d_name);
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
|
||||
closedir(d);
|
||||
}
|
||||
void dirList::rescan()
|
||||
{
|
||||
item.clear();
|
||||
d = opendir(path.c_str());
|
||||
|
||||
std::string dirList::getItem(int index)
|
||||
{
|
||||
return item[index];
|
||||
}
|
||||
while((ent = readdir(d)))
|
||||
{
|
||||
item.push_back(ent->d_name);
|
||||
}
|
||||
|
||||
bool dirList::isDir(int index)
|
||||
{
|
||||
std::string fullPath = path + item[index];
|
||||
struct stat s;
|
||||
if(stat(fullPath.c_str(), &s) == 0)
|
||||
{
|
||||
if(S_ISDIR(s.st_mode))
|
||||
return true;
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
std::string dirList::getItem(int index)
|
||||
{
|
||||
return item[index];
|
||||
}
|
||||
|
||||
unsigned dirList::getCount()
|
||||
{
|
||||
return item.size();
|
||||
}
|
||||
bool dirList::isDir(int index)
|
||||
{
|
||||
std::string fullPath = path + item[index];
|
||||
struct stat s;
|
||||
if(stat(fullPath.c_str(), &s) == 0)
|
||||
{
|
||||
if(S_ISDIR(s.st_mode))
|
||||
return true;
|
||||
}
|
||||
|
||||
void copyFile(const std::string& from, const std::string& to)
|
||||
{
|
||||
std::fstream f(from, std::ios::in | std::ios::binary);
|
||||
std::fstream t(to, std::ios::out | std::ios::binary);
|
||||
return false;
|
||||
}
|
||||
|
||||
f.seekg(0, f.end);
|
||||
size_t fileSize = f.tellg();
|
||||
f.seekg(0, f.beg);
|
||||
unsigned dirList::getCount()
|
||||
{
|
||||
return item.size();
|
||||
}
|
||||
|
||||
uint8_t *buff = new uint8_t[BUFF_SIZE];
|
||||
ui::progBar prog(fileSize);
|
||||
void copyFile(const std::string& from, const std::string& to)
|
||||
{
|
||||
std::fstream f(from, std::ios::in | std::ios::binary);
|
||||
std::fstream t(to, std::ios::out | std::ios::binary);
|
||||
|
||||
std::string copyString = "Copying " + from + "...";
|
||||
copyString = util::getWrappedString(copyString, 24, 1136);
|
||||
for(unsigned i = 0; i < fileSize; )
|
||||
{
|
||||
f.read((char *)buff, BUFF_SIZE);
|
||||
t.write((char *)buff, f.gcount());
|
||||
f.seekg(0, f.end);
|
||||
size_t fileSize = f.tellg();
|
||||
f.seekg(0, f.beg);
|
||||
|
||||
i += f.gcount();
|
||||
prog.update(i);
|
||||
uint8_t *buff = new uint8_t[BUFF_SIZE];
|
||||
ui::progBar prog(fileSize);
|
||||
|
||||
prog.draw(copyString);
|
||||
std::string copyString = "Copying " + from + "...";
|
||||
copyString = util::getWrappedString(copyString, 24, 1136);
|
||||
for(unsigned i = 0; i < fileSize; )
|
||||
{
|
||||
f.read((char *)buff, BUFF_SIZE);
|
||||
t.write((char *)buff, f.gcount());
|
||||
|
||||
gfx::handleBuffs();
|
||||
}
|
||||
i += f.gcount();
|
||||
prog.update(i);
|
||||
|
||||
delete[] buff;
|
||||
prog.draw(copyString);
|
||||
|
||||
f.close();
|
||||
t.close();
|
||||
}
|
||||
gfx::handleBuffs();
|
||||
}
|
||||
|
||||
void copyFileCommit(const std::string& from, const std::string& to, const std::string& dev)
|
||||
{
|
||||
std::fstream f(from, std::ios::in | std::ios::binary);
|
||||
std::fstream t(to, std::ios::out | std::ios::binary);
|
||||
delete[] buff;
|
||||
|
||||
f.seekg(0, f.end);
|
||||
size_t fileSize = f.tellg();
|
||||
f.seekg(0, f.beg);
|
||||
f.close();
|
||||
t.close();
|
||||
}
|
||||
|
||||
uint8_t *buff = new uint8_t[BUFF_SIZE];
|
||||
ui::progBar prog(fileSize);
|
||||
void copyFileCommit(const std::string& from, const std::string& to, const std::string& dev)
|
||||
{
|
||||
std::fstream f(from, std::ios::in | std::ios::binary);
|
||||
std::fstream t(to, std::ios::out | std::ios::binary);
|
||||
|
||||
std::string copyString = "Copying " + from + "...";
|
||||
copyString = util::getWrappedString(copyString, 24, 1136);
|
||||
for(unsigned i = 0; i < fileSize; )
|
||||
{
|
||||
f.read((char *)buff, BUFF_SIZE);
|
||||
t.write((char *)buff, f.gcount());
|
||||
f.seekg(0, f.end);
|
||||
size_t fileSize = f.tellg();
|
||||
f.seekg(0, f.beg);
|
||||
|
||||
i += f.gcount();
|
||||
prog.update(i);
|
||||
uint8_t *buff = new uint8_t[BUFF_SIZE];
|
||||
ui::progBar prog(fileSize);
|
||||
|
||||
prog.draw(copyString);
|
||||
std::string copyString = "Copying " + from + "...";
|
||||
copyString = util::getWrappedString(copyString, 24, 1136);
|
||||
for(unsigned i = 0; i < fileSize; )
|
||||
{
|
||||
f.read((char *)buff, BUFF_SIZE);
|
||||
t.write((char *)buff, f.gcount());
|
||||
|
||||
gfx::handleBuffs();
|
||||
}
|
||||
i += f.gcount();
|
||||
prog.update(i);
|
||||
|
||||
delete[] buff;
|
||||
prog.draw(copyString);
|
||||
|
||||
f.close();
|
||||
t.close();
|
||||
gfx::handleBuffs();
|
||||
}
|
||||
|
||||
Result res = fsdevCommitDevice(dev.c_str());
|
||||
if(R_FAILED(res))
|
||||
ui::showError("Error committing file to device", res);
|
||||
}
|
||||
delete[] buff;
|
||||
|
||||
void copyDirToDir(const std::string& from, const std::string& to)
|
||||
{
|
||||
dirList list(from);
|
||||
f.close();
|
||||
t.close();
|
||||
|
||||
for(unsigned i = 0; i < list.getCount(); i++)
|
||||
{
|
||||
if(list.isDir(i))
|
||||
{
|
||||
std::string newFrom = from + list.getItem(i) + "/";
|
||||
std::string newTo = to + list.getItem(i);
|
||||
mkdir(newTo.c_str(), 0777);
|
||||
newTo += "/";
|
||||
Result res = fsdevCommitDevice(dev.c_str());
|
||||
if(R_FAILED(res))
|
||||
ui::showError("Error committing file to device", res);
|
||||
}
|
||||
|
||||
copyDirToDir(newFrom, newTo);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string fullFrom = from + list.getItem(i);
|
||||
std::string fullTo = to + list.getItem(i);
|
||||
void copyDirToDir(const std::string& from, const std::string& to)
|
||||
{
|
||||
dirList list(from);
|
||||
|
||||
copyFile(fullFrom, fullTo);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(unsigned i = 0; i < list.getCount(); i++)
|
||||
{
|
||||
if(list.isDir(i))
|
||||
{
|
||||
std::string newFrom = from + list.getItem(i) + "/";
|
||||
std::string newTo = to + list.getItem(i);
|
||||
mkdir(newTo.c_str(), 0777);
|
||||
newTo += "/";
|
||||
|
||||
void copyDirToDirCommit(const std::string& from, const std::string& to, const std::string& dev)
|
||||
{
|
||||
dirList list(from);
|
||||
copyDirToDir(newFrom, newTo);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string fullFrom = from + list.getItem(i);
|
||||
std::string fullTo = to + list.getItem(i);
|
||||
|
||||
for(unsigned i = 0; i < list.getCount(); i++)
|
||||
{
|
||||
if(list.isDir(i))
|
||||
{
|
||||
std::string newFrom = from + list.getItem(i) + "/";
|
||||
std::string newTo = to + list.getItem(i);
|
||||
mkdir(newTo.c_str(), 0777);
|
||||
newTo += "/";
|
||||
copyFile(fullFrom, fullTo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
copyDirToDirCommit(newFrom, newTo, dev);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string fullFrom = from + list.getItem(i);
|
||||
std::string fullTo = to + list.getItem(i);
|
||||
void copyDirToDirCommit(const std::string& from, const std::string& to, const std::string& dev)
|
||||
{
|
||||
dirList list(from);
|
||||
|
||||
copyFileCommit(fullFrom, fullTo, dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(unsigned i = 0; i < list.getCount(); i++)
|
||||
{
|
||||
if(list.isDir(i))
|
||||
{
|
||||
std::string newFrom = from + list.getItem(i) + "/";
|
||||
std::string newTo = to + list.getItem(i);
|
||||
mkdir(newTo.c_str(), 0777);
|
||||
newTo += "/";
|
||||
|
||||
void delDir(const std::string& path)
|
||||
{
|
||||
dirList list(path);
|
||||
for(unsigned i = 0; i < list.getCount(); i++)
|
||||
{
|
||||
if(list.isDir(i))
|
||||
{
|
||||
std::string newPath = path + "/" + list.getItem(i) + "/";
|
||||
delDir(newPath);
|
||||
copyDirToDirCommit(newFrom, newTo, dev);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string fullFrom = from + list.getItem(i);
|
||||
std::string fullTo = to + list.getItem(i);
|
||||
|
||||
std::string delPath = path + list.getItem(i);
|
||||
rmdir(delPath.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string delPath = path + list.getItem(i);
|
||||
std::remove(delPath.c_str());
|
||||
}
|
||||
}
|
||||
copyFileCommit(fullFrom, fullTo, dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rmdir(path.c_str());
|
||||
}
|
||||
void delDir(const std::string& path)
|
||||
{
|
||||
dirList list(path);
|
||||
for(unsigned i = 0; i < list.getCount(); i++)
|
||||
{
|
||||
if(list.isDir(i))
|
||||
{
|
||||
std::string newPath = path + "/" + list.getItem(i) + "/";
|
||||
delDir(newPath);
|
||||
|
||||
void dumpAllUserSaves(data::user& u)
|
||||
{
|
||||
for(unsigned i = 0; i < u.titles.size(); i++)
|
||||
{
|
||||
if(fs::mountSave(u, u.titles[i]))
|
||||
{
|
||||
util::makeTitleDir(u, u.titles[i]);
|
||||
std::string delPath = path + list.getItem(i);
|
||||
rmdir(delPath.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string delPath = path + list.getItem(i);
|
||||
std::remove(delPath.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
//sdmc:/JKSV/[title]/[user] - [date]/
|
||||
std::string outPath = util::getTitleDir(u, u.titles[i]) + u.getUsernameSafe() + " - " + util::getDateTime();
|
||||
mkdir(outPath.c_str(), 777);
|
||||
outPath += "/";
|
||||
rmdir(path.c_str());
|
||||
}
|
||||
|
||||
std::string root = "sv:/";
|
||||
void dumpAllUserSaves(data::user& u)
|
||||
{
|
||||
for(unsigned i = 0; i < u.titles.size(); i++)
|
||||
{
|
||||
if(fs::mountSave(u, u.titles[i]))
|
||||
{
|
||||
util::makeTitleDir(u, u.titles[i]);
|
||||
|
||||
fs::copyDirToDir(root, outPath);
|
||||
//sdmc:/JKSV/[title]/[user] - [date]/
|
||||
std::string outPath = util::getTitleDir(u, u.titles[i]) + u.getUsernameSafe() + " - " + util::getDateTime();
|
||||
mkdir(outPath.c_str(), 777);
|
||||
outPath += "/";
|
||||
|
||||
fsdevUnmountDevice("sv");
|
||||
}
|
||||
}
|
||||
}
|
||||
std::string root = "sv:/";
|
||||
|
||||
std::string getFileProps(const std::string& _path)
|
||||
{
|
||||
std::string ret = "";
|
||||
std::fstream get(_path, std::ios::in | std::ios::binary);
|
||||
if(get.is_open())
|
||||
{
|
||||
//Size
|
||||
get.seekg(0, get.end);
|
||||
unsigned fileSize = get.tellg();
|
||||
get.seekg(0, get.beg);
|
||||
fs::copyDirToDir(root, outPath);
|
||||
|
||||
get.close();
|
||||
fsdevUnmountDevice("sv");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Probably add more later
|
||||
std::string getFileProps(const std::string& _path)
|
||||
{
|
||||
std::string ret = "";
|
||||
std::fstream get(_path, std::ios::in | std::ios::binary);
|
||||
if(get.is_open())
|
||||
{
|
||||
//Size
|
||||
get.seekg(0, get.end);
|
||||
unsigned fileSize = get.tellg();
|
||||
get.seekg(0, get.beg);
|
||||
|
||||
char tmp[256];
|
||||
std::sprintf(tmp, "Path: \"%s\"\nSize: %u", _path.c_str(), fileSize);
|
||||
get.close();
|
||||
|
||||
ret = tmp;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
//Probably add more later
|
||||
|
||||
bool fileExists(const std::string& path)
|
||||
{
|
||||
std::fstream chk(path, std::ios::in);
|
||||
if(chk.is_open())
|
||||
{
|
||||
chk.close();
|
||||
return true;
|
||||
}
|
||||
char tmp[256];
|
||||
std::sprintf(tmp, "Path: \"%s\"\nSize: %u", _path.c_str(), fileSize);
|
||||
|
||||
return false;
|
||||
}
|
||||
ret = tmp;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool fileExists(const std::string& path)
|
||||
{
|
||||
std::fstream chk(path, std::ios::in);
|
||||
if(chk.is_open())
|
||||
{
|
||||
chk.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string getWorkDir()
|
||||
{
|
||||
return wd;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
1177
src/gfx.cpp
96
src/main.cpp
|
|
@ -13,66 +13,62 @@
|
|||
|
||||
extern "C"
|
||||
{
|
||||
void userAppInit(void)
|
||||
{
|
||||
romfsInit();
|
||||
hidInitialize();
|
||||
nsInitialize();
|
||||
setsysInitialize();
|
||||
accountInitialize();
|
||||
void userAppInit(void)
|
||||
{
|
||||
romfsInit();
|
||||
hidInitialize();
|
||||
nsInitialize();
|
||||
setsysInitialize();
|
||||
accountInitialize();
|
||||
}
|
||||
|
||||
mkdir(".JKSV", 777);
|
||||
chdir(".JKSV");
|
||||
}
|
||||
|
||||
void userAppExit(void)
|
||||
{
|
||||
romfsExit();
|
||||
hidExit();
|
||||
nsExit();
|
||||
setsysExit();
|
||||
accountExit();
|
||||
}
|
||||
void userAppExit(void)
|
||||
{
|
||||
romfsExit();
|
||||
hidExit();
|
||||
nsExit();
|
||||
setsysExit();
|
||||
accountExit();
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
gfx::init();
|
||||
data::loadDataInfo();
|
||||
ui::init();
|
||||
fs::init();
|
||||
gfx::init();
|
||||
data::loadDataInfo();
|
||||
ui::init();
|
||||
|
||||
appletSetScreenShotPermission(0);
|
||||
bool run = true;
|
||||
while(appletMainLoop() && run)
|
||||
{
|
||||
hidScanInput();
|
||||
|
||||
bool run = true;
|
||||
while(appletMainLoop() && run)
|
||||
{
|
||||
hidScanInput();
|
||||
uint64_t down = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
uint64_t held = hidKeysHeld(CONTROLLER_P1_AUTO);
|
||||
|
||||
uint64_t down = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
uint64_t held = hidKeysHeld(CONTROLLER_P1_AUTO);
|
||||
touchPosition p;
|
||||
hidTouchRead(&p, 0);
|
||||
|
||||
touchPosition p;
|
||||
hidTouchRead(&p, 0);
|
||||
if((held & KEY_L) && (held & KEY_R) && (held & KEY_ZL) && (held & KEY_ZR))
|
||||
{
|
||||
if(ui::confirm("You are about to enable system save dumping and remove checks. Are you sure you want to continue?"))
|
||||
{
|
||||
data::sysSave = true;
|
||||
data::loadDataInfo();
|
||||
|
||||
if((held & KEY_L) && (held & KEY_R) && (held & KEY_ZL) && (held & KEY_ZR))
|
||||
{
|
||||
if(ui::confirm("You are about to enable system save dumping and remove checks. Are you sure you want to continue?"))
|
||||
{
|
||||
data::sysSave = true;
|
||||
data::loadDataInfo();
|
||||
//Just to be sure
|
||||
fsdevUnmountDevice("sv");
|
||||
}
|
||||
}
|
||||
else if(down & KEY_PLUS)
|
||||
break;
|
||||
|
||||
//Just to be sure
|
||||
fsdevUnmountDevice("sv");
|
||||
}
|
||||
}
|
||||
else if(down & KEY_PLUS)
|
||||
break;
|
||||
ui::runApp(down, held, p);
|
||||
|
||||
ui::runApp(down, held, p);
|
||||
|
||||
gfx::handleBuffs();
|
||||
}
|
||||
gfx::exit();
|
||||
ui::exit();
|
||||
data::exit();
|
||||
gfx::handleBuffs();
|
||||
}
|
||||
gfx::exit();
|
||||
ui::exit();
|
||||
data::exit();
|
||||
}
|
||||
|
|
|
|||
442
src/ui.cpp
|
|
@ -11,284 +11,266 @@
|
|||
#include "util.h"
|
||||
#include "file.h"
|
||||
|
||||
#define TITLE_TEXT "JKSV - 07/11/2018"
|
||||
#define TITLE_TEXT "JKSV - 07/15/2018"
|
||||
|
||||
//Secret background that can be drawn from ".JKSV/back.jpg"
|
||||
static gfx::tex background;
|
||||
|
||||
namespace ui
|
||||
{
|
||||
//Classic mode
|
||||
bool clsMode = false;
|
||||
//Classic mode
|
||||
bool clsMode = false;
|
||||
|
||||
//Current menu state
|
||||
int mstate = USR_SEL;
|
||||
//Current menu state
|
||||
int mstate = USR_SEL;
|
||||
|
||||
//Info printed on folder menu
|
||||
std::string folderMenuInfo;
|
||||
//Info printed on folder menu
|
||||
std::string folderMenuInfo;
|
||||
|
||||
//Touch button vector
|
||||
std::vector<ui::button> selButtons;
|
||||
//Touch button vector
|
||||
std::vector<ui::button> selButtons;
|
||||
|
||||
//UI colors 0xAABBGGRR
|
||||
uint32_t clearClr = 0xFFFFFFFF, mnuTxt = 0xFF000000, txtClr = 0xFF000000, \
|
||||
rectLt = 0xFFC0C0C0, rectSh = 0, tboxClr = 0xFFC0C0C0;
|
||||
//UI colors 0xAABBGGRR
|
||||
uint32_t clearClr = 0xFFFFFFFF, mnuTxt = 0xFF000000, txtClr = 0xFF000000, \
|
||||
rectLt = 0xFFC0C0C0, rectSh = 0, tboxClr = 0xFFC0C0C0;
|
||||
|
||||
//textbox pieces
|
||||
//I was going to flip them when I draw them, but then laziness kicked in.
|
||||
gfx::tex cornerTopLeft, cornerTopRight, cornerBottomLeft, cornerBottomRight, \
|
||||
horEdgeTop, horEdgeBot, vertEdgeLeft, vertEdgeRight;
|
||||
//textbox pieces
|
||||
//I was going to flip them when I draw them, but then laziness kicked in.
|
||||
gfx::tex cornerTopLeft, cornerTopRight, cornerBottomLeft, cornerBottomRight;
|
||||
|
||||
gfx::tex buttonA, buttonB, buttonX, buttonY, buttonMin;
|
||||
gfx::tex buttonA, buttonB, buttonX, buttonY, buttonMin;
|
||||
|
||||
void init()
|
||||
{
|
||||
ColorSetId gthm;
|
||||
setsysGetColorSetId(>hm);
|
||||
void init()
|
||||
{
|
||||
ColorSetId gthm;
|
||||
setsysGetColorSetId(>hm);
|
||||
|
||||
switch(gthm)
|
||||
{
|
||||
case ColorSetId_Light:
|
||||
//Dark corners
|
||||
cornerTopLeft.loadPNGFile("romfs:/img/tbox/tboxCornerTopLeft_drk.png");
|
||||
cornerTopRight.loadPNGFile("romfs:/img/tbox/tboxCornerTopRight_drk.png");
|
||||
cornerBottomLeft.loadPNGFile("romfs:/img/tbox/tboxCornerBotLeft_drk.png");
|
||||
cornerBottomRight.loadPNGFile("romfs:/img/tbox/tboxCornerBotRight_drk.png");
|
||||
switch(gthm)
|
||||
{
|
||||
case ColorSetId_Light:
|
||||
//Dark corners
|
||||
cornerTopLeft.loadPNGFile("romfs:/img/tboxDrk/tboxCornerTopLeft.png");
|
||||
cornerTopRight.loadPNGFile("romfs:/img/tboxDrk/tboxCornerTopRight.png");
|
||||
cornerBottomLeft.loadPNGFile("romfs:/img/tboxDrk/tboxCornerBotLeft.png");
|
||||
cornerBottomRight.loadPNGFile("romfs:/img/tboxDrk/tboxCornerBotRight.png");
|
||||
|
||||
//Dark edges
|
||||
horEdgeTop.loadPNGFile("romfs:/img/tbox/tboxHorEdgeTop_drk.png");
|
||||
horEdgeBot.loadPNGFile("romfs:/img/tbox/tboxHorEdgeBot_drk.png");
|
||||
vertEdgeLeft.loadPNGFile("romfs:/img/tbox/tboxVertEdgeLeft_drk.png");
|
||||
vertEdgeRight.loadPNGFile("romfs:/img/tbox/tboxVertEdgeRight_drk.png");
|
||||
//Dark buttons
|
||||
buttonA.loadPNGFile("romfs:/img/button/buttonA_drk.png");
|
||||
buttonB.loadPNGFile("romfs:/img/button/buttonB_drk.png");
|
||||
buttonX.loadPNGFile("romfs:/img/button/buttonX_drk.png");
|
||||
buttonY.loadPNGFile("romfs:/img/button/buttonY_drk.png");
|
||||
buttonMin.loadPNGFile("romfs:/img/button/buttonMin_drk.png");
|
||||
|
||||
//Dark buttons
|
||||
buttonA.loadPNGFile("romfs:/img/button/buttonA_drk.png");
|
||||
buttonB.loadPNGFile("romfs:/img/button/buttonB_drk.png");
|
||||
buttonX.loadPNGFile("romfs:/img/button/buttonX_drk.png");
|
||||
buttonY.loadPNGFile("romfs:/img/button/buttonY_drk.png");
|
||||
buttonMin.loadPNGFile("romfs:/img/button/buttonMin_drk.png");
|
||||
clearClr = 0xFFEBEBEB;
|
||||
mnuTxt = 0xFF000000;
|
||||
txtClr = 0xFFFFFFFF;
|
||||
rectLt = 0xFFDFDFDF;
|
||||
rectSh = 0xFFCACACA;
|
||||
tboxClr = 0xFF505050;
|
||||
break;
|
||||
|
||||
clearClr = 0xFFEBEBEB;
|
||||
mnuTxt = 0xFF000000;
|
||||
txtClr = 0xFFFFFFFF;
|
||||
rectLt = 0xFFDFDFDF;
|
||||
rectSh = 0xFFCACACA;
|
||||
tboxClr = 0xFF505050;
|
||||
break;
|
||||
default:
|
||||
case ColorSetId_Dark:
|
||||
//Light corners
|
||||
cornerTopLeft.loadPNGFile("romfs:/img/tboxLght/tboxCornerTopLeft.png");
|
||||
cornerTopRight.loadPNGFile("romfs:/img/tboxLght/tboxCornerTopRight.png");
|
||||
cornerBottomLeft.loadPNGFile("romfs:/img/tboxLght/tboxCornerBotLeft.png");
|
||||
cornerBottomRight.loadPNGFile("romfs:/img/tboxLght/tboxCornerBotRight.png");
|
||||
|
||||
default:
|
||||
case ColorSetId_Dark:
|
||||
//Light corners
|
||||
cornerTopLeft.loadPNGFile("romfs:/img/tbox/tboxCornerTopLeft_lght.png");
|
||||
cornerTopRight.loadPNGFile("romfs:/img/tbox/tboxCornerTopRight_lght.png");
|
||||
cornerBottomLeft.loadPNGFile("romfs:/img/tbox/tboxCornerBotLeft_lght.png");
|
||||
cornerBottomRight.loadPNGFile("romfs:/img/tbox/tboxCornerBotRight_lght.png");
|
||||
//Light buttons
|
||||
buttonA.loadPNGFile("romfs:/img/button/buttonA_lght.png");
|
||||
buttonB.loadPNGFile("romfs:/img/button/buttonB_lght.png");
|
||||
buttonX.loadPNGFile("romfs:/img/button/buttonX_lght.png");
|
||||
buttonY.loadPNGFile("romfs:/img/button/buttonY_lght.png");
|
||||
buttonMin.loadPNGFile("romfs:/img/button/buttonMin_lght.png");
|
||||
|
||||
//light edges
|
||||
horEdgeTop.loadPNGFile("romfs:/img/tbox/tboxHorEdgeTop_lght.png");
|
||||
horEdgeBot.loadPNGFile("romfs:/img/tbox/tboxHorEdgeBot_lght.png");
|
||||
vertEdgeLeft.loadPNGFile("romfs:/img/tbox/tboxVertEdgeLeft_lght.png");
|
||||
vertEdgeRight.loadPNGFile("romfs:/img/tbox/tboxVertEdgeRight_lght.png");
|
||||
clearClr = 0xFF2D2D2D;
|
||||
mnuTxt = 0xFFFFFFFF;
|
||||
txtClr = 0xFF000000;
|
||||
rectLt = 0xFF505050;
|
||||
rectSh = 0xFF202020;
|
||||
tboxClr = 0xFFEBEBEB;
|
||||
break;
|
||||
}
|
||||
|
||||
//Light buttons
|
||||
buttonA.loadPNGFile("romfs:/img/button/buttonA_lght.png");
|
||||
buttonB.loadPNGFile("romfs:/img/button/buttonB_lght.png");
|
||||
buttonX.loadPNGFile("romfs:/img/button/buttonX_lght.png");
|
||||
buttonY.loadPNGFile("romfs:/img/button/buttonY_lght.png");
|
||||
buttonMin.loadPNGFile("romfs:/img/button/buttonMin_lght.png");
|
||||
setupSelButtons();
|
||||
|
||||
clearClr = 0xFF2D2D2D;
|
||||
mnuTxt = 0xFFFFFFFF;
|
||||
txtClr = 0xFF000000;
|
||||
rectLt = 0xFF505050;
|
||||
rectSh = 0xFF202020;
|
||||
tboxClr = 0xFFEBEBEB;
|
||||
break;
|
||||
}
|
||||
if(fs::fileExists("back.jpg"))
|
||||
background.loadJpegFile("back.jpg");
|
||||
|
||||
setupSelButtons();
|
||||
if(fs::fileExists("cls.txt"))
|
||||
{
|
||||
clsUserPrep();
|
||||
clsMode = true;
|
||||
mstate = CLS_USR;
|
||||
}
|
||||
|
||||
if(fs::fileExists("back.jpg"))
|
||||
background.loadJpegFile("back.jpg");
|
||||
advCopyMenuPrep();
|
||||
}
|
||||
|
||||
if(fs::fileExists("cls.txt"))
|
||||
{
|
||||
clsUserPrep();
|
||||
clsMode = true;
|
||||
mstate = CLS_USR;
|
||||
}
|
||||
void exit()
|
||||
{
|
||||
cornerTopLeft.deleteData();
|
||||
cornerTopRight.deleteData();
|
||||
cornerBottomLeft.deleteData();
|
||||
cornerBottomRight.deleteData();
|
||||
|
||||
advCopyMenuPrep();
|
||||
}
|
||||
buttonA.deleteData();
|
||||
buttonB.deleteData();
|
||||
buttonX.deleteData();
|
||||
buttonY.deleteData();
|
||||
|
||||
void exit()
|
||||
{
|
||||
cornerTopLeft.deleteData();
|
||||
cornerTopRight.deleteData();
|
||||
cornerBottomLeft.deleteData();
|
||||
cornerBottomRight.deleteData();
|
||||
background.deleteData();
|
||||
}
|
||||
|
||||
horEdgeTop.deleteData();
|
||||
horEdgeBot.deleteData();
|
||||
vertEdgeLeft.deleteData();
|
||||
vertEdgeRight.deleteData();
|
||||
void setupSelButtons()
|
||||
{
|
||||
int x = 70, y = 80;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buttonA.deleteData();
|
||||
buttonB.deleteData();
|
||||
buttonX.deleteData();
|
||||
buttonY.deleteData();
|
||||
void drawUI()
|
||||
{
|
||||
if(background.getDataPointer() == NULL)
|
||||
gfx::clearBufferColor(clearClr);
|
||||
else
|
||||
background.drawNoBlend(0, 0);
|
||||
|
||||
background.deleteData();
|
||||
}
|
||||
gfx::drawText(TITLE_TEXT, 16, 16, 32, mnuTxt);
|
||||
|
||||
void setupSelButtons()
|
||||
{
|
||||
int x = 70, y = 80;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
switch(mstate)
|
||||
{
|
||||
case FLD_SEL:
|
||||
gfx::drawRectangle(16, 64, 1248, 1, rectLt);
|
||||
gfx::drawRectangle(16, 65, 1248, 2, rectSh);
|
||||
|
||||
void drawUI()
|
||||
{
|
||||
if(background.getDataPointer() == NULL)
|
||||
gfx::clearBufferColor(clearClr);
|
||||
else
|
||||
background.drawNoBlend(0, 0);
|
||||
gfx::drawRectangle(288, 65, 1, 592, rectLt);
|
||||
gfx::drawRectangle(289, 65, 2, 592, rectSh);
|
||||
|
||||
gfx::drawText(TITLE_TEXT, 16, 16, 32, mnuTxt);
|
||||
gfx::drawRectangle(16, 656, 1248, 1, rectLt);
|
||||
gfx::drawRectangle(16, 657, 1248, 2, rectSh);
|
||||
break;
|
||||
|
||||
switch(mstate)
|
||||
{
|
||||
case FLD_SEL:
|
||||
gfx::drawRectangle(16, 64, 1248, 1, rectLt);
|
||||
gfx::drawRectangle(16, 65, 1248, 2, rectSh);
|
||||
case USR_SEL:
|
||||
case TTL_SEL:
|
||||
gfx::drawRectangle(16, 64, 1248, 1, rectLt);
|
||||
gfx::drawRectangle(16, 65, 1248, 2, rectSh);
|
||||
|
||||
gfx::drawRectangle(288, 65, 1, 592, rectLt);
|
||||
gfx::drawRectangle(289, 65, 2, 592, rectSh);
|
||||
gfx::drawRectangle(16, 656, 1248, 1, rectLt);
|
||||
gfx::drawRectangle(16, 657, 1248, 2, rectSh);
|
||||
break;
|
||||
|
||||
gfx::drawRectangle(16, 656, 1248, 1, rectLt);
|
||||
gfx::drawRectangle(16, 657, 1248, 2, rectSh);
|
||||
break;
|
||||
case ADV_MDE:
|
||||
gfx::drawRectangle(16, 64, 1248, 1, rectLt);
|
||||
gfx::drawRectangle(16, 65, 1248, 2, rectSh);
|
||||
|
||||
case USR_SEL:
|
||||
case TTL_SEL:
|
||||
gfx::drawRectangle(16, 64, 1248, 1, rectLt);
|
||||
gfx::drawRectangle(16, 65, 1248, 2, rectSh);
|
||||
gfx::drawRectangle(640, 64, 1, 592, rectLt);
|
||||
gfx::drawRectangle(641, 64, 2, 592, rectSh);
|
||||
|
||||
gfx::drawRectangle(16, 656, 1248, 1, rectLt);
|
||||
gfx::drawRectangle(16, 657, 1248, 2, rectSh);
|
||||
break;
|
||||
gfx::drawRectangle(16, 656, 1248, 1, rectLt);
|
||||
gfx::drawRectangle(16, 657, 1248, 2, rectSh);
|
||||
break;
|
||||
|
||||
case ADV_MDE:
|
||||
gfx::drawRectangle(16, 64, 1248, 1, rectLt);
|
||||
gfx::drawRectangle(16, 65, 1248, 2, rectSh);
|
||||
case CLS_TTL:
|
||||
case CLS_USR:
|
||||
gfx::drawRectangle(16, 64, 1248, 1, rectLt);
|
||||
gfx::drawRectangle(16, 65, 1248, 2, rectSh);
|
||||
|
||||
gfx::drawRectangle(640, 64, 1, 592, rectLt);
|
||||
gfx::drawRectangle(641, 64, 2, 592, rectSh);
|
||||
gfx::drawRectangle(448, 64, 1, 592, rectLt);
|
||||
gfx::drawRectangle(449, 64, 2, 592, rectSh);
|
||||
|
||||
gfx::drawRectangle(16, 656, 1248, 1, rectLt);
|
||||
gfx::drawRectangle(16, 657, 1248, 2, rectSh);
|
||||
break;
|
||||
gfx::drawRectangle(16, 656, 1248, 1, rectLt);
|
||||
gfx::drawRectangle(16, 657, 1248, 2, rectSh);
|
||||
break;
|
||||
}
|
||||
|
||||
case CLS_TTL:
|
||||
case CLS_USR:
|
||||
gfx::drawRectangle(16, 64, 1248, 1, rectLt);
|
||||
gfx::drawRectangle(16, 65, 1248, 2, rectSh);
|
||||
switch(mstate)
|
||||
{
|
||||
case USR_SEL:
|
||||
case CLS_USR:
|
||||
{
|
||||
//Input guide
|
||||
unsigned startX = 848;
|
||||
buttonA.draw(startX, 672);
|
||||
gfx::drawText("Select", startX += 38, 680, 14, mnuTxt);
|
||||
buttonY.draw(startX += 72, 672);
|
||||
gfx::drawText("Dump All", startX += 38, 680, 14, mnuTxt);
|
||||
buttonX.draw(startX += 96, 672);
|
||||
gfx::drawText("Classic Mode", startX += 38, 680, 14, mnuTxt);
|
||||
}
|
||||
break;
|
||||
|
||||
gfx::drawRectangle(448, 64, 1, 592, rectLt);
|
||||
gfx::drawRectangle(449, 64, 2, 592, rectSh);
|
||||
case TTL_SEL:
|
||||
case CLS_TTL:
|
||||
{
|
||||
unsigned startX = 914;
|
||||
buttonA.draw(startX, 672);
|
||||
gfx::drawText("Select", startX += 38, 680, 14, mnuTxt);
|
||||
buttonY.draw(startX += 72, 672);
|
||||
gfx::drawText("Dump All", startX += 38, 680, 14, mnuTxt);
|
||||
buttonB.draw(startX += 96, 672);
|
||||
gfx::drawText("Back", startX += 38, 680, 14, mnuTxt);
|
||||
}
|
||||
break;
|
||||
|
||||
gfx::drawRectangle(16, 656, 1248, 1, rectLt);
|
||||
gfx::drawRectangle(16, 657, 1248, 2, rectSh);
|
||||
break;
|
||||
}
|
||||
case FLD_SEL:
|
||||
{
|
||||
//Input guide
|
||||
unsigned startX = 690;
|
||||
buttonMin.draw(startX, 672);
|
||||
gfx::drawText("Adv. Mode", startX += 38, 680, 14, mnuTxt);
|
||||
buttonA.draw(startX += 100, 672);
|
||||
gfx::drawText("Backup", startX += 38, 680, 14, mnuTxt);
|
||||
buttonY.draw(startX += 72, 672);
|
||||
gfx::drawText("Restore", startX += 38, 680, 14, mnuTxt);
|
||||
buttonX.draw(startX += 72, 672);
|
||||
gfx::drawText("Delete", startX += 38, 680, 14, mnuTxt);
|
||||
buttonB.draw(startX += 72, 672);
|
||||
gfx::drawText("Back", startX += 38, 680, 14, mnuTxt);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch(mstate)
|
||||
{
|
||||
case USR_SEL:
|
||||
case CLS_USR:
|
||||
{
|
||||
//Input guide
|
||||
unsigned startX = 848;
|
||||
buttonA.draw(startX, 672);
|
||||
gfx::drawText("Select", startX += 38, 680, 14, mnuTxt);
|
||||
buttonY.draw(startX += 72, 672);
|
||||
gfx::drawText("Dump All", startX += 38, 680, 14, mnuTxt);
|
||||
buttonX.draw(startX += 96, 672);
|
||||
gfx::drawText("Classic Mode", startX += 38, 680, 14, mnuTxt);
|
||||
}
|
||||
break;
|
||||
void runApp(const uint64_t& down, const uint64_t& held, const touchPosition& p)
|
||||
{
|
||||
//Draw first. Shouldn't, but it simplifies the showX functions
|
||||
drawUI();
|
||||
|
||||
case TTL_SEL:
|
||||
case CLS_TTL:
|
||||
{
|
||||
unsigned startX = 914;
|
||||
buttonA.draw(startX, 672);
|
||||
gfx::drawText("Select", startX += 38, 680, 14, mnuTxt);
|
||||
buttonY.draw(startX += 72, 672);
|
||||
gfx::drawText("Dump All", startX += 38, 680, 14, mnuTxt);
|
||||
buttonB.draw(startX += 96, 672);
|
||||
gfx::drawText("Back", startX += 38, 680, 14, mnuTxt);
|
||||
}
|
||||
break;
|
||||
switch(mstate)
|
||||
{
|
||||
case USR_SEL:
|
||||
updateUserMenu(down, held, p);
|
||||
break;
|
||||
|
||||
case FLD_SEL:
|
||||
{
|
||||
//Input guide
|
||||
unsigned startX = 690;
|
||||
buttonMin.draw(startX, 672);
|
||||
gfx::drawText("Adv. Mode", startX += 38, 680, 14, mnuTxt);
|
||||
buttonA.draw(startX += 100, 672);
|
||||
gfx::drawText("Backup", startX += 38, 680, 14, mnuTxt);
|
||||
buttonY.draw(startX += 72, 672);
|
||||
gfx::drawText("Restore", startX += 38, 680, 14, mnuTxt);
|
||||
buttonX.draw(startX += 72, 672);
|
||||
gfx::drawText("Delete", startX += 38, 680, 14, mnuTxt);
|
||||
buttonB.draw(startX += 72, 672);
|
||||
gfx::drawText("Back", startX += 38, 680, 14, mnuTxt);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
case TTL_SEL:
|
||||
updateTitleMenu(down, held, p);
|
||||
break;
|
||||
|
||||
void runApp(const uint64_t& down, const uint64_t& held, const touchPosition& p)
|
||||
{
|
||||
//Draw first. Shouldn't, but it simplifies the showX functions
|
||||
drawUI();
|
||||
case FLD_SEL:
|
||||
updateFolderMenu(down, held, p);
|
||||
break;
|
||||
|
||||
switch(mstate)
|
||||
{
|
||||
case USR_SEL:
|
||||
updateUserMenu(down, held, p);
|
||||
break;
|
||||
case ADV_MDE:
|
||||
updateAdvMode(down, held, p);
|
||||
break;
|
||||
|
||||
case TTL_SEL:
|
||||
updateTitleMenu(down, held, p);
|
||||
break;
|
||||
case CLS_USR:
|
||||
classicUserMenuUpdate(down, held, p);
|
||||
break;
|
||||
|
||||
case FLD_SEL:
|
||||
updateFolderMenu(down, held, p);
|
||||
break;
|
||||
|
||||
case ADV_MDE:
|
||||
updateAdvMode(down, held, p);
|
||||
break;
|
||||
|
||||
case CLS_USR:
|
||||
classicUserMenuUpdate(down, held, p);
|
||||
break;
|
||||
|
||||
case CLS_TTL:
|
||||
classicTitleMenuUpdate(down, held, p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
case CLS_TTL:
|
||||
classicTitleMenuUpdate(down, held, p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "ui.h"
|
||||
#include "miscui.h"
|
||||
|
|
@ -22,467 +23,467 @@ fs::dirList saveList(""), sdList("sdmc:/");
|
|||
//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) + "/";
|
||||
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 += "/";
|
||||
//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;
|
||||
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(data::curData.getType() != FsSaveDataType_SystemSaveData)
|
||||
{
|
||||
if(sdMenu.getSelected() == 0)
|
||||
{
|
||||
if(ui::confirmTransfer(sdPath, savePath))
|
||||
fs::copyDirToDirCommit(sdPath, savePath, "sv");
|
||||
}
|
||||
else if(sdMenu.getSelected() > 1)
|
||||
{
|
||||
//Same as above, but reverse
|
||||
int sdSel = sdMenu.getSelected() - 2;
|
||||
if(sdList.isDir(sdSel))
|
||||
{
|
||||
std::string fromPath = sdPath + sdList.getItem(sdSel) + "/";
|
||||
case 1:
|
||||
if(data::curData.getType() != FsSaveDataType_SystemSaveData)
|
||||
{
|
||||
if(sdMenu.getSelected() == 0)
|
||||
{
|
||||
if(ui::confirmTransfer(sdPath, savePath))
|
||||
fs::copyDirToDirCommit(sdPath, savePath, "sv");
|
||||
}
|
||||
else if(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);
|
||||
std::string toPath = savePath + sdList.getItem(sdSel);
|
||||
|
||||
if(ui::confirmTransfer(fromPath, toPath))
|
||||
{
|
||||
mkdir(toPath.c_str(), 777);
|
||||
toPath += "/";
|
||||
if(ui::confirmTransfer(fromPath, toPath))
|
||||
{
|
||||
mkdir(toPath.c_str(), 777);
|
||||
toPath += "/";
|
||||
|
||||
fs::copyDirToDirCommit(fromPath, toPath, "sv");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string fromPath = sdPath + sdList.getItem(sdSel);
|
||||
std::string toPath = savePath + sdList.getItem(sdSel);
|
||||
if(ui::confirmTransfer(fromPath, toPath))
|
||||
fs::copyFileCommit(fromPath, toPath, "sv");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
fs::copyDirToDirCommit(fromPath, toPath, "sv");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string fromPath = sdPath + sdList.getItem(sdSel);
|
||||
std::string toPath = savePath + sdList.getItem(sdSel);
|
||||
if(ui::confirmTransfer(fromPath, toPath))
|
||||
fs::copyFileCommit(fromPath, toPath, "sv");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
//delete
|
||||
case 1:
|
||||
{
|
||||
switch(advPrev)
|
||||
{
|
||||
//save menu
|
||||
case 0:
|
||||
if(data::curData.getType() != FsSaveDataType_SystemSaveData)
|
||||
{
|
||||
if(saveMenu.getSelected() == 0)
|
||||
{
|
||||
if(ui::confirmDelete(savePath))
|
||||
{
|
||||
fs::delDir(savePath);
|
||||
fsdevCommitDevice("sv");
|
||||
}
|
||||
}
|
||||
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());
|
||||
}
|
||||
fsdevCommitDevice("sv");
|
||||
}
|
||||
}
|
||||
break;
|
||||
//delete
|
||||
case 1:
|
||||
{
|
||||
switch(advPrev)
|
||||
{
|
||||
//save menu
|
||||
case 0:
|
||||
if(data::curData.getType() != FsSaveDataType_SystemSaveData)
|
||||
{
|
||||
if(saveMenu.getSelected() == 0)
|
||||
{
|
||||
if(ui::confirmDelete(savePath))
|
||||
{
|
||||
fs::delDir(savePath);
|
||||
fsdevCommitDevice("sv");
|
||||
}
|
||||
}
|
||||
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());
|
||||
}
|
||||
fsdevCommitDevice("sv");
|
||||
}
|
||||
}
|
||||
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;
|
||||
//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(saveMenu.getSelected() > 1 && data::curData.getType() != FsSaveDataType_SystemSaveData)
|
||||
{
|
||||
int selSave = saveMenu.getSelected() - 2;
|
||||
ui::keyboard getName;
|
||||
std::string newName = getName.getString(saveList.getItem(selSave));
|
||||
if(!newName.empty())
|
||||
{
|
||||
std::string b4Path = savePath + saveList.getItem(selSave);
|
||||
std::string newPath = savePath + newName;
|
||||
//Rename
|
||||
case 2:
|
||||
switch(advPrev)
|
||||
{
|
||||
//save
|
||||
case 0:
|
||||
{
|
||||
if(saveMenu.getSelected() > 1 && data::curData.getType() != FsSaveDataType_SystemSaveData)
|
||||
{
|
||||
int selSave = saveMenu.getSelected() - 2;
|
||||
ui::keyboard getName;
|
||||
std::string newName = getName.getString(saveList.getItem(selSave));
|
||||
if(!newName.empty())
|
||||
{
|
||||
std::string b4Path = savePath + saveList.getItem(selSave);
|
||||
std::string newPath = savePath + newName;
|
||||
|
||||
std::rename(b4Path.c_str(), newPath.c_str());
|
||||
fsdevCommitDevice("sv");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
std::rename(b4Path.c_str(), newPath.c_str());
|
||||
fsdevCommitDevice("sv");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
//sd
|
||||
case 1:
|
||||
{
|
||||
if(sdMenu.getSelected() > 1)
|
||||
{
|
||||
int sdSel = sdMenu.getSelected() - 2;
|
||||
ui::keyboard getName;
|
||||
std::string newName = getName.getString(sdList.getItem(sdSel));
|
||||
if(!newName.empty())
|
||||
{
|
||||
std::string b4Path = sdPath + sdList.getItem(sdSel);
|
||||
std::string newPath = sdPath + newName;
|
||||
//sd
|
||||
case 1:
|
||||
{
|
||||
if(sdMenu.getSelected() > 1)
|
||||
{
|
||||
int sdSel = sdMenu.getSelected() - 2;
|
||||
ui::keyboard getName;
|
||||
std::string newName = getName.getString(sdList.getItem(sdSel));
|
||||
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;
|
||||
std::rename(b4Path.c_str(), newPath.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
//Mkdir
|
||||
case 3:
|
||||
{
|
||||
switch(advPrev)
|
||||
{
|
||||
//save
|
||||
case 0:
|
||||
{
|
||||
if(data::curData.getType() != FsSaveDataType_SystemSaveData)
|
||||
{
|
||||
ui::keyboard getFolder;
|
||||
std::string newFolder = util::safeString(getFolder.getString(""));
|
||||
if(!newFolder.empty())
|
||||
{
|
||||
std::string folderPath = savePath + newFolder;
|
||||
mkdir(folderPath.c_str(), 777);
|
||||
fsdevCommitDevice("sv");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
//Mkdir
|
||||
case 3:
|
||||
{
|
||||
switch(advPrev)
|
||||
{
|
||||
//save
|
||||
case 0:
|
||||
{
|
||||
if(data::curData.getType() != FsSaveDataType_SystemSaveData)
|
||||
{
|
||||
ui::keyboard getFolder;
|
||||
std::string newFolder = util::safeString(getFolder.getString(""));
|
||||
if(!newFolder.empty())
|
||||
{
|
||||
std::string folderPath = savePath + newFolder;
|
||||
mkdir(folderPath.c_str(), 777);
|
||||
fsdevCommitDevice("sv");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
//sd
|
||||
case 1:
|
||||
{
|
||||
ui::keyboard getFolder;
|
||||
std::string newFolder = getFolder.getString("");
|
||||
if(!newFolder.empty())
|
||||
{
|
||||
std::string folderPath = sdPath + newFolder;
|
||||
mkdir(folderPath.c_str(), 777);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
//sd
|
||||
case 1:
|
||||
{
|
||||
ui::keyboard getFolder;
|
||||
std::string newFolder = getFolder.getString("");
|
||||
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);
|
||||
std::string props = fs::getFileProps(fullPath);
|
||||
if(!props.empty())
|
||||
ui::showMessage(props);
|
||||
}
|
||||
}
|
||||
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);
|
||||
std::string props = fs::getFileProps(fullPath);
|
||||
if(!props.empty())
|
||||
ui::showMessage(props);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
if(sdMenu.getSelected() > 1)
|
||||
{
|
||||
int sel = sdMenu.getSelected() - 2;
|
||||
std::string fullPath = sdPath + sdList.getItem(sel);
|
||||
std::string props = fs::getFileProps(fullPath);
|
||||
if(!props.empty())
|
||||
ui::showMessage(props);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
if(sdMenu.getSelected() > 1)
|
||||
{
|
||||
int sel = sdMenu.getSelected() - 2;
|
||||
std::string fullPath = sdPath + sdList.getItem(sel);
|
||||
std::string props = fs::getFileProps(fullPath);
|
||||
if(!props.empty())
|
||||
ui::showMessage(props);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
//back
|
||||
case 5:
|
||||
advMenuCtrl = advPrev;
|
||||
break;
|
||||
//back
|
||||
case 5:
|
||||
advMenuCtrl = advPrev;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//update lists + menus
|
||||
sdList.rescan();
|
||||
saveList.rescan();
|
||||
util::copyDirListToMenu(sdList, sdMenu);
|
||||
util::copyDirListToMenu(saveList, saveMenu);
|
||||
//update lists + menus
|
||||
sdList.rescan();
|
||||
saveList.rescan();
|
||||
util::copyDirListToMenu(sdList, sdMenu);
|
||||
util::copyDirListToMenu(saveList, saveMenu);
|
||||
}
|
||||
|
||||
namespace ui
|
||||
{
|
||||
void advCopyMenuPrep()
|
||||
{
|
||||
copyMenu.addOpt("Copy From");
|
||||
copyMenu.addOpt("Delete");
|
||||
copyMenu.addOpt("Rename");
|
||||
copyMenu.addOpt("Make Dir");
|
||||
copyMenu.addOpt("Properties");
|
||||
copyMenu.addOpt("Back");
|
||||
}
|
||||
void advCopyMenuPrep()
|
||||
{
|
||||
copyMenu.addOpt("Copy From");
|
||||
copyMenu.addOpt("Delete");
|
||||
copyMenu.addOpt("Rename");
|
||||
copyMenu.addOpt("Make Dir");
|
||||
copyMenu.addOpt("Properties");
|
||||
copyMenu.addOpt("Back");
|
||||
}
|
||||
|
||||
void advModePrep()
|
||||
{
|
||||
saveMenu.setParams(16, 88, 616);
|
||||
sdMenu.setParams(648, 88, 616);
|
||||
copyMenu.setParams(472, 278, 304);
|
||||
void advModePrep()
|
||||
{
|
||||
saveMenu.setParams(16, 88, 616);
|
||||
sdMenu.setParams(648, 88, 616);
|
||||
copyMenu.setParams(472, 278, 304);
|
||||
|
||||
savePath = "sv:/";
|
||||
sdPath = "sdmc:/";
|
||||
savePath = "sv:/";
|
||||
sdPath = "sdmc:/";
|
||||
|
||||
saveWrap = "sv:/";
|
||||
sdWrap = "sdmc:/";
|
||||
saveWrap = "sv:/";
|
||||
sdWrap = "sdmc:/";
|
||||
|
||||
saveList.reassign(savePath);
|
||||
sdList.reassign(sdPath);
|
||||
saveList.reassign(savePath);
|
||||
sdList.reassign(sdPath);
|
||||
|
||||
util::copyDirListToMenu(saveList, saveMenu);
|
||||
util::copyDirListToMenu(sdList, sdMenu);
|
||||
util::copyDirListToMenu(saveList, saveMenu);
|
||||
util::copyDirListToMenu(sdList, sdMenu);
|
||||
|
||||
advMenuCtrl = 0;
|
||||
}
|
||||
advMenuCtrl = 0;
|
||||
}
|
||||
|
||||
void updateAdvMode(const uint64_t& down, const uint64_t& held, const touchPosition& p)
|
||||
{
|
||||
//0 = save; 1 = sd; 2 = cpy
|
||||
switch(advMenuCtrl)
|
||||
{
|
||||
case 0:
|
||||
saveMenu.handleInput(down, held, p);
|
||||
break;
|
||||
void updateAdvMode(const uint64_t& down, const uint64_t& held, const touchPosition& p)
|
||||
{
|
||||
//0 = save; 1 = sd; 2 = cpy
|
||||
switch(advMenuCtrl)
|
||||
{
|
||||
case 0:
|
||||
saveMenu.handleInput(down, held, p);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
sdMenu.handleInput(down, held, p);
|
||||
break;
|
||||
case 1:
|
||||
sdMenu.handleInput(down, held, p);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
copyMenu.handleInput(down, held, p);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
copyMenu.handleInput(down, held, p);
|
||||
break;
|
||||
}
|
||||
|
||||
saveMenu.draw(mnuTxt);
|
||||
sdMenu.draw(mnuTxt);
|
||||
saveMenu.draw(mnuTxt);
|
||||
sdMenu.draw(mnuTxt);
|
||||
|
||||
gfx::drawText(saveWrap, 16, 668, 14, mnuTxt);
|
||||
gfx::drawText(sdWrap, 656, 668, 14, mnuTxt);
|
||||
gfx::drawText(saveWrap, 16, 668, 14, mnuTxt);
|
||||
gfx::drawText(sdWrap, 656, 668, 14, mnuTxt);
|
||||
|
||||
//OH BOY HERE WE GO
|
||||
if(down & KEY_A)
|
||||
{
|
||||
switch(advMenuCtrl)
|
||||
{
|
||||
//save
|
||||
case 0:
|
||||
{
|
||||
int saveSel = saveMenu.getSelected();
|
||||
if(saveSel == 1 && savePath != "sv:/")
|
||||
{
|
||||
util::removeLastFolderFromString(savePath);
|
||||
saveWrap = util::getWrappedString(savePath, 14, 600);
|
||||
//OH BOY HERE WE GO
|
||||
if(down & KEY_A)
|
||||
{
|
||||
switch(advMenuCtrl)
|
||||
{
|
||||
//save
|
||||
case 0:
|
||||
{
|
||||
int saveSel = saveMenu.getSelected();
|
||||
if(saveSel == 1 && savePath != "sv:/")
|
||||
{
|
||||
util::removeLastFolderFromString(savePath);
|
||||
saveWrap = util::getWrappedString(savePath, 14, 600);
|
||||
|
||||
saveList.reassign(savePath);
|
||||
util::copyDirListToMenu(saveList, saveMenu);
|
||||
}
|
||||
else if(saveSel > 1 && saveList.isDir(saveSel - 2))
|
||||
{
|
||||
savePath += saveList.getItem(saveSel - 2) + "/";
|
||||
saveWrap = util::getWrappedString(savePath, 14, 600);
|
||||
saveList.reassign(savePath);
|
||||
util::copyDirListToMenu(saveList, saveMenu);
|
||||
}
|
||||
else if(saveSel > 1 && saveList.isDir(saveSel - 2))
|
||||
{
|
||||
savePath += saveList.getItem(saveSel - 2) + "/";
|
||||
saveWrap = util::getWrappedString(savePath, 14, 600);
|
||||
|
||||
saveList.reassign(savePath);
|
||||
util::copyDirListToMenu(saveList, saveMenu);
|
||||
}
|
||||
}
|
||||
break;
|
||||
saveList.reassign(savePath);
|
||||
util::copyDirListToMenu(saveList, saveMenu);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
//sd
|
||||
case 1:
|
||||
{
|
||||
int sdSel = sdMenu.getSelected();
|
||||
if(sdSel == 1 && sdPath != "sdmc:/")
|
||||
{
|
||||
util::removeLastFolderFromString(sdPath);
|
||||
sdWrap = util::getWrappedString(sdPath, 14, 600);
|
||||
//sd
|
||||
case 1:
|
||||
{
|
||||
int sdSel = sdMenu.getSelected();
|
||||
if(sdSel == 1 && sdPath != "sdmc:/")
|
||||
{
|
||||
util::removeLastFolderFromString(sdPath);
|
||||
sdWrap = util::getWrappedString(sdPath, 14, 600);
|
||||
|
||||
sdList.reassign(sdPath);
|
||||
util::copyDirListToMenu(sdList, sdMenu);
|
||||
}
|
||||
else if(sdSel > 1 && sdList.isDir(sdSel - 2))
|
||||
{
|
||||
sdPath += sdList.getItem(sdSel - 2) + "/";
|
||||
sdWrap = util::getWrappedString(sdPath, 14, 600);
|
||||
sdList.reassign(sdPath);
|
||||
util::copyDirListToMenu(sdList, sdMenu);
|
||||
}
|
||||
else if(sdSel > 1 && sdList.isDir(sdSel - 2))
|
||||
{
|
||||
sdPath += sdList.getItem(sdSel - 2) + "/";
|
||||
sdWrap = util::getWrappedString(sdPath, 14, 600);
|
||||
|
||||
sdList.reassign(sdPath);
|
||||
util::copyDirListToMenu(sdList, sdMenu);
|
||||
}
|
||||
}
|
||||
break;
|
||||
sdList.reassign(sdPath);
|
||||
util::copyDirListToMenu(sdList, sdMenu);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
//advanced mode
|
||||
case 2:
|
||||
performCopyMenuOps();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(down & KEY_B)
|
||||
{
|
||||
//save
|
||||
if(advMenuCtrl == 0 && savePath != "sv:/")
|
||||
{
|
||||
util::removeLastFolderFromString(savePath);
|
||||
saveWrap = util::getWrappedString(savePath, 14, 600);
|
||||
//advanced mode
|
||||
case 2:
|
||||
performCopyMenuOps();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(down & KEY_B)
|
||||
{
|
||||
//save
|
||||
if(advMenuCtrl == 0 && savePath != "sv:/")
|
||||
{
|
||||
util::removeLastFolderFromString(savePath);
|
||||
saveWrap = util::getWrappedString(savePath, 14, 600);
|
||||
|
||||
saveList.reassign(savePath);
|
||||
util::copyDirListToMenu(saveList, saveMenu);
|
||||
}
|
||||
//sd
|
||||
else if(advMenuCtrl == 1 && sdPath != "sdmc:/")
|
||||
{
|
||||
util::removeLastFolderFromString(sdPath);
|
||||
sdWrap = util::getWrappedString(sdPath, 14, 600);
|
||||
saveList.reassign(savePath);
|
||||
util::copyDirListToMenu(saveList, saveMenu);
|
||||
}
|
||||
//sd
|
||||
else if(advMenuCtrl == 1 && sdPath != "sdmc:/")
|
||||
{
|
||||
util::removeLastFolderFromString(sdPath);
|
||||
sdWrap = util::getWrappedString(sdPath, 14, 600);
|
||||
|
||||
sdList.reassign(sdPath);
|
||||
util::copyDirListToMenu(sdList, sdMenu);
|
||||
}
|
||||
else if(advMenuCtrl == 2)
|
||||
advMenuCtrl = advPrev;
|
||||
}
|
||||
else if(down & KEY_X)
|
||||
{
|
||||
if(advMenuCtrl == 2)
|
||||
{
|
||||
advMenuCtrl = advPrev;
|
||||
}
|
||||
else
|
||||
{
|
||||
advPrev = advMenuCtrl;
|
||||
advMenuCtrl = 2;
|
||||
}
|
||||
}
|
||||
else if(down & KEY_ZL || down & KEY_ZR)
|
||||
{
|
||||
if(advMenuCtrl == 0 || advMenuCtrl == 1)
|
||||
{
|
||||
if(advMenuCtrl == 0)
|
||||
advMenuCtrl = 1;
|
||||
else
|
||||
advMenuCtrl = 0;
|
||||
}
|
||||
}
|
||||
else if(down & KEY_MINUS)
|
||||
mstate = FLD_SEL;
|
||||
sdList.reassign(sdPath);
|
||||
util::copyDirListToMenu(sdList, sdMenu);
|
||||
}
|
||||
else if(advMenuCtrl == 2)
|
||||
advMenuCtrl = advPrev;
|
||||
}
|
||||
else if(down & KEY_X)
|
||||
{
|
||||
if(advMenuCtrl == 2)
|
||||
{
|
||||
advMenuCtrl = advPrev;
|
||||
}
|
||||
else
|
||||
{
|
||||
advPrev = advMenuCtrl;
|
||||
advMenuCtrl = 2;
|
||||
}
|
||||
}
|
||||
else if(down & KEY_ZL || down & KEY_ZR)
|
||||
{
|
||||
if(advMenuCtrl == 0 || advMenuCtrl == 1)
|
||||
{
|
||||
if(advMenuCtrl == 0)
|
||||
advMenuCtrl = 1;
|
||||
else
|
||||
advMenuCtrl = 0;
|
||||
}
|
||||
}
|
||||
else if(down & KEY_MINUS)
|
||||
mstate = FLD_SEL;
|
||||
|
||||
//draw copy menu if it's supposed to be up
|
||||
if(advMenuCtrl == 2)
|
||||
{
|
||||
ui::drawTextbox(464, 236, 320, 268);
|
||||
//draw copy menu if it's supposed to be up
|
||||
if(advMenuCtrl == 2)
|
||||
{
|
||||
ui::drawTextbox(464, 236, 320, 268);
|
||||
|
||||
switch(advPrev)
|
||||
{
|
||||
case 0:
|
||||
gfx::drawText("SAVE", 472, 250, 18,txtClr);
|
||||
break;
|
||||
switch(advPrev)
|
||||
{
|
||||
case 0:
|
||||
gfx::drawText("SAVE", 472, 250, 18,txtClr);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
gfx::drawText("SDMC", 472, 250, 18, txtClr);
|
||||
break;
|
||||
}
|
||||
copyMenu.draw(txtClr);
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
gfx::drawText("SDMC", 472, 250, 18, txtClr);
|
||||
break;
|
||||
}
|
||||
copyMenu.draw(txtClr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
122
src/ui/clsui.cpp
|
|
@ -9,81 +9,75 @@
|
|||
|
||||
static ui::menu userMenu, titleMenu;
|
||||
|
||||
//So we can change state from here
|
||||
extern int mstate;
|
||||
|
||||
//Set folderMenuInfo
|
||||
extern std::string folderMenuInfo;
|
||||
|
||||
namespace ui
|
||||
{
|
||||
void clsUserPrep()
|
||||
{
|
||||
userMenu.reset();
|
||||
void clsUserPrep()
|
||||
{
|
||||
userMenu.reset();
|
||||
|
||||
userMenu.setParams(16, 88, 424);
|
||||
userMenu.setParams(16, 88, 424);
|
||||
|
||||
for(unsigned i = 0; i < data::users.size(); i++)
|
||||
userMenu.addOpt(data::users[i].getUsername());
|
||||
}
|
||||
for(unsigned i = 0; i < data::users.size(); i++)
|
||||
userMenu.addOpt(data::users[i].getUsername());
|
||||
}
|
||||
|
||||
void clsTitlePrep(data::user& u)
|
||||
{
|
||||
titleMenu.reset();
|
||||
titleMenu.setParams(16, 88, 424);
|
||||
void clsTitlePrep(data::user& u)
|
||||
{
|
||||
titleMenu.reset();
|
||||
titleMenu.setParams(16, 88, 424);
|
||||
|
||||
for(unsigned i = 0; i < u.titles.size(); i++)
|
||||
titleMenu.addOpt(u.titles[i].getTitle());
|
||||
}
|
||||
for(unsigned i = 0; i < u.titles.size(); i++)
|
||||
titleMenu.addOpt(u.titles[i].getTitle());
|
||||
}
|
||||
|
||||
void classicUserMenuUpdate(const uint64_t& down, const uint64_t& held, const touchPosition& p)
|
||||
{
|
||||
userMenu.handleInput(down, held, p);
|
||||
userMenu.draw(mnuTxt);
|
||||
void classicUserMenuUpdate(const uint64_t& down, const uint64_t& held, const touchPosition& p)
|
||||
{
|
||||
userMenu.handleInput(down, held, p);
|
||||
userMenu.draw(mnuTxt);
|
||||
|
||||
if(down & KEY_A)
|
||||
{
|
||||
data::curUser = data::users[userMenu.getSelected()];
|
||||
clsTitlePrep(data::curUser);
|
||||
if(down & KEY_A)
|
||||
{
|
||||
data::curUser = data::users[userMenu.getSelected()];
|
||||
clsTitlePrep(data::curUser);
|
||||
|
||||
mstate = 5;
|
||||
}
|
||||
else if(down & KEY_Y)
|
||||
{
|
||||
for(unsigned i = 0; i < data::users.size(); i++)
|
||||
fs::dumpAllUserSaves(data::users[i]);
|
||||
}
|
||||
else if(down & KEY_X)
|
||||
{
|
||||
std::remove("cls.txt");
|
||||
clsMode = false;
|
||||
mstate = 0;//USR_SEL
|
||||
}
|
||||
}
|
||||
mstate = 5;
|
||||
}
|
||||
else if(down & KEY_Y)
|
||||
{
|
||||
for(unsigned i = 0; i < data::users.size(); i++)
|
||||
fs::dumpAllUserSaves(data::users[i]);
|
||||
}
|
||||
else if(down & KEY_X)
|
||||
{
|
||||
std::remove("cls.txt");
|
||||
clsMode = false;
|
||||
mstate = USR_SEL;
|
||||
}
|
||||
}
|
||||
|
||||
void classicTitleMenuUpdate(const uint64_t& down, const uint64_t& held, const touchPosition& p)
|
||||
{
|
||||
titleMenu.handleInput(down, held, p);
|
||||
titleMenu.draw(mnuTxt);
|
||||
void classicTitleMenuUpdate(const uint64_t& down, const uint64_t& held, const touchPosition& p)
|
||||
{
|
||||
titleMenu.handleInput(down, held, p);
|
||||
titleMenu.draw(mnuTxt);
|
||||
|
||||
if(down & KEY_A)
|
||||
{
|
||||
data::curData = data::curUser.titles[titleMenu.getSelected()];
|
||||
if(down & KEY_A)
|
||||
{
|
||||
data::curData = data::curUser.titles[titleMenu.getSelected()];
|
||||
|
||||
if(fs::mountSave(data::curUser, data::curData))
|
||||
{
|
||||
util::makeTitleDir(data::curUser, data::curData);
|
||||
folderMenuPrepare(data::curUser, data::curData);
|
||||
folderMenuInfo = util::getWrappedString(util::getInfoString(data::curUser, data::curData), 18, 256);
|
||||
if(fs::mountSave(data::curUser, data::curData))
|
||||
{
|
||||
util::makeTitleDir(data::curUser, data::curData);
|
||||
folderMenuPrepare(data::curUser, data::curData);
|
||||
folderMenuInfo = util::getWrappedString(util::getInfoString(data::curUser, data::curData), 18, 256);
|
||||
|
||||
mstate = 2; //FLD_SEL
|
||||
}
|
||||
}
|
||||
else if(down & KEY_Y)
|
||||
{
|
||||
fs::dumpAllUserSaves(data::curUser);
|
||||
}
|
||||
else if(down & KEY_B)
|
||||
mstate = 4;//CLS_USR
|
||||
}
|
||||
mstate = FLD_SEL;
|
||||
}
|
||||
}
|
||||
else if(down & KEY_Y)
|
||||
{
|
||||
fs::dumpAllUserSaves(data::curUser);
|
||||
}
|
||||
else if(down & KEY_B)
|
||||
mstate = CLS_USR;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "ui.h"
|
||||
#include "uiupdate.h"
|
||||
|
|
@ -9,117 +10,117 @@ static ui::menu folderMenu;
|
|||
|
||||
namespace ui
|
||||
{
|
||||
void folderMenuPrepare(data::user& usr, data::titledata& dat)
|
||||
{
|
||||
folderMenu.setParams(308, 88, 956);
|
||||
folderMenu.reset();
|
||||
void folderMenuPrepare(data::user& usr, data::titledata& dat)
|
||||
{
|
||||
folderMenu.setParams(308, 88, 956);
|
||||
folderMenu.reset();
|
||||
|
||||
util::makeTitleDir(usr, dat);
|
||||
std::string scanPath = util::getTitleDir(usr, dat);
|
||||
util::makeTitleDir(usr, dat);
|
||||
std::string scanPath = util::getTitleDir(usr, dat);
|
||||
|
||||
fs::dirList list(scanPath);
|
||||
folderMenu.addOpt("New");
|
||||
for(unsigned i = 0; i < list.getCount(); i++)
|
||||
folderMenu.addOpt(list.getItem(i));
|
||||
}
|
||||
fs::dirList list(scanPath);
|
||||
folderMenu.addOpt("New");
|
||||
for(unsigned i = 0; i < list.getCount(); i++)
|
||||
folderMenu.addOpt(list.getItem(i));
|
||||
}
|
||||
|
||||
void updateFolderMenu(const uint64_t& down, const uint64_t& held, const touchPosition& p)
|
||||
{
|
||||
folderMenu.handleInput(down, held, p);
|
||||
void updateFolderMenu(const uint64_t& down, const uint64_t& held, const touchPosition& p)
|
||||
{
|
||||
folderMenu.handleInput(down, held, p);
|
||||
|
||||
//Draw folder menu
|
||||
folderMenu.draw(mnuTxt);
|
||||
//Draw folder menu
|
||||
folderMenu.draw(mnuTxt);
|
||||
|
||||
data::curData.icon.draw(16, 88);
|
||||
gfx::drawText(folderMenuInfo, 16, 360, 18, mnuTxt);
|
||||
data::curData.icon.draw(16, 88);
|
||||
gfx::drawText(folderMenuInfo, 16, 360, 18, mnuTxt);
|
||||
|
||||
if(down & KEY_A || folderMenu.getTouchEvent() == MENU_DOUBLE_REL)
|
||||
{
|
||||
if(folderMenu.getSelected() == 0)
|
||||
{
|
||||
ui::keyboard key;
|
||||
std::string folder = key.getString("");
|
||||
if(!folder.empty())
|
||||
{
|
||||
std::string path = util::getTitleDir(data::curUser, data::curData) + "/" + folder;
|
||||
mkdir(path.c_str(), 777);
|
||||
path += "/";
|
||||
if(down & KEY_A || folderMenu.getTouchEvent() == MENU_DOUBLE_REL)
|
||||
{
|
||||
if(folderMenu.getSelected() == 0)
|
||||
{
|
||||
ui::keyboard key;
|
||||
std::string folder = key.getString("");
|
||||
if(!folder.empty())
|
||||
{
|
||||
std::string path = util::getTitleDir(data::curUser, data::curData) + "/" + folder;
|
||||
mkdir(path.c_str(), 777);
|
||||
path += "/";
|
||||
|
||||
std::string root = "sv:/";
|
||||
fs::copyDirToDir(root, path);
|
||||
std::string root = "sv:/";
|
||||
fs::copyDirToDir(root, path);
|
||||
|
||||
folderMenuPrepare(data::curUser, data::curData);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string scanPath = util::getTitleDir(data::curUser, data::curData);
|
||||
fs::dirList list(scanPath);
|
||||
folderMenuPrepare(data::curUser, data::curData);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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 overwrite \"" + folderName + "\"?"))
|
||||
{
|
||||
std::string toPath = 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 overwrite \"" + folderName + "\"?"))
|
||||
{
|
||||
std::string toPath = util::getTitleDir(data::curUser, data::curData) + folderName + "/";
|
||||
std::string root = "sv:/";
|
||||
|
||||
fs::copyDirToDir(root, toPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(down & KEY_Y)
|
||||
{
|
||||
if(data::curData.getType() != FsSaveDataType_SystemSaveData)
|
||||
{
|
||||
if(folderMenu.getSelected() > 0)
|
||||
{
|
||||
std::string scanPath = util::getTitleDir(data::curUser, data::curData);
|
||||
fs::dirList list(scanPath);
|
||||
fs::copyDirToDir(root, toPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(down & KEY_Y)
|
||||
{
|
||||
if(data::curData.getType() != FsSaveDataType_SystemSaveData)
|
||||
{
|
||||
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 + "\"?"))
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
ui::showMessage("Writing data to system save data is not allowed currently. It CAN brick your system.");
|
||||
}
|
||||
else if(down & KEY_X)
|
||||
{
|
||||
if(folderMenu.getSelected() > 0)
|
||||
{
|
||||
std::string scanPath = util::getTitleDir(data::curUser, data::curData);
|
||||
fs::dirList list(scanPath);
|
||||
fs::copyDirToDirCommit(fromPath, root, "sv");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
ui::showMessage("Writing data to system save data is not allowed currently. It CAN brick your system.");
|
||||
}
|
||||
else if(down & KEY_X)
|
||||
{
|
||||
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 delete \"" + folderName + "\"?"))
|
||||
{
|
||||
std::string delPath = scanPath + folderName + "/";
|
||||
fs::delDir(delPath);
|
||||
}
|
||||
std::string folderName = list.getItem(folderMenu.getSelected() - 1);
|
||||
if(confirm("Are you sure you want to delete \"" + folderName + "\"?"))
|
||||
{
|
||||
std::string delPath = scanPath + folderName + "/";
|
||||
fs::delDir(delPath);
|
||||
}
|
||||
|
||||
folderMenuPrepare(data::curUser, data::curData);
|
||||
}
|
||||
}
|
||||
else if(down & KEY_MINUS)
|
||||
{
|
||||
advModePrep();
|
||||
mstate = ADV_MDE;
|
||||
}
|
||||
else if(down & KEY_B)
|
||||
{
|
||||
fsdevUnmountDevice("sv");
|
||||
if(clsMode)
|
||||
mstate = CLS_TTL;
|
||||
else
|
||||
mstate = TTL_SEL;
|
||||
}
|
||||
}
|
||||
folderMenuPrepare(data::curUser, data::curData);
|
||||
}
|
||||
}
|
||||
else if(down & KEY_MINUS)
|
||||
{
|
||||
advModePrep();
|
||||
mstate = ADV_MDE;
|
||||
}
|
||||
else if(down & KEY_B)
|
||||
{
|
||||
fsdevUnmountDevice("sv");
|
||||
if(clsMode)
|
||||
mstate = CLS_TTL;
|
||||
else
|
||||
mstate = TTL_SEL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
326
src/ui/kb.cpp
|
|
@ -6,197 +6,197 @@
|
|||
|
||||
static const char qwerty[] =
|
||||
{
|
||||
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
|
||||
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p',
|
||||
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', '_',
|
||||
'z', 'x', 'c', 'v', 'b', 'n', 'm', ':', '.', '/'
|
||||
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
|
||||
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p',
|
||||
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', '_',
|
||||
'z', 'x', 'c', 'v', 'b', 'n', 'm', ':', '.', '/'
|
||||
};
|
||||
|
||||
namespace ui
|
||||
{
|
||||
key::key(const std::string& _txt, const char& _l, unsigned _x, unsigned _y, unsigned _w, unsigned _h) : button(_txt, _x, _y, _w, _h)
|
||||
{
|
||||
let = _l;
|
||||
}
|
||||
key::key(const std::string& _txt, const char& _l, unsigned _x, unsigned _y, unsigned _w, unsigned _h) : button(_txt, _x, _y, _w, _h)
|
||||
{
|
||||
let = _l;
|
||||
}
|
||||
|
||||
void key::updateText(const std::string& txt)
|
||||
{
|
||||
text = txt;
|
||||
}
|
||||
void key::updateText(const std::string& txt)
|
||||
{
|
||||
text = txt;
|
||||
}
|
||||
|
||||
void key::toCaps()
|
||||
{
|
||||
let = toupper(let);
|
||||
void key::toCaps()
|
||||
{
|
||||
let = toupper(let);
|
||||
|
||||
char tmp[2];
|
||||
sprintf(tmp, "%c", let);
|
||||
updateText(tmp);
|
||||
}
|
||||
char tmp[2];
|
||||
sprintf(tmp, "%c", let);
|
||||
updateText(tmp);
|
||||
}
|
||||
|
||||
void key::toLower()
|
||||
{
|
||||
let = tolower(let);
|
||||
void key::toLower()
|
||||
{
|
||||
let = tolower(let);
|
||||
|
||||
char tmp[2];
|
||||
sprintf(tmp, "%c", let);
|
||||
updateText(tmp);
|
||||
}
|
||||
char tmp[2];
|
||||
sprintf(tmp, "%c", let);
|
||||
updateText(tmp);
|
||||
}
|
||||
|
||||
keyboard::keyboard()
|
||||
{
|
||||
keyboard::keyboard()
|
||||
{
|
||||
|
||||
for(int y = 256, i = 0; i < 40; y += 96)
|
||||
{
|
||||
int endRow = i + 10;
|
||||
for(int x = 160; i < endRow; x += 96, i++)
|
||||
{
|
||||
char tmp[2];
|
||||
sprintf(tmp, "%c", qwerty[i]);
|
||||
key newKey(tmp, qwerty[i], x, y, 80, 80);
|
||||
keys.push_back(newKey);
|
||||
}
|
||||
}
|
||||
for(int y = 256, i = 0; i < 40; y += 96)
|
||||
{
|
||||
int endRow = i + 10;
|
||||
for(int x = 160; i < endRow; x += 96, i++)
|
||||
{
|
||||
char tmp[2];
|
||||
sprintf(tmp, "%c", qwerty[i]);
|
||||
key newKey(tmp, qwerty[i], x, y, 80, 80);
|
||||
keys.push_back(newKey);
|
||||
}
|
||||
}
|
||||
|
||||
//spc key
|
||||
key shift("Shift", ' ', 16, 544, 128, 80);
|
||||
//Space bar needs to be trimmed back so we don't try to draw off buffer
|
||||
key space(" ", ' ', 240, 640, 800, 72);
|
||||
key bckSpc("Back", ' ', 1120, 256, 128, 80);
|
||||
key enter("Entr", ' ', 1120, 352, 128, 80);
|
||||
key cancel("Cancl", ' ', 1120, 448, 128, 80);
|
||||
//spc key
|
||||
key shift("Shift", ' ', 16, 544, 128, 80);
|
||||
//Space bar needs to be trimmed back so we don't try to draw off buffer
|
||||
key space(" ", ' ', 240, 640, 800, 72);
|
||||
key bckSpc("Back", ' ', 1120, 256, 128, 80);
|
||||
key enter("Entr", ' ', 1120, 352, 128, 80);
|
||||
key cancel("Cancl", ' ', 1120, 448, 128, 80);
|
||||
|
||||
keys.push_back(space);
|
||||
keys.push_back(shift);
|
||||
keys.push_back(bckSpc);
|
||||
keys.push_back(enter);
|
||||
keys.push_back(cancel);
|
||||
}
|
||||
keys.push_back(space);
|
||||
keys.push_back(shift);
|
||||
keys.push_back(bckSpc);
|
||||
keys.push_back(enter);
|
||||
keys.push_back(cancel);
|
||||
}
|
||||
|
||||
keyboard::~keyboard()
|
||||
{
|
||||
keys.clear();
|
||||
}
|
||||
keyboard::~keyboard()
|
||||
{
|
||||
keys.clear();
|
||||
}
|
||||
|
||||
void keyboard::draw()
|
||||
{
|
||||
if(clrAdd)
|
||||
{
|
||||
clrSh += 4;
|
||||
if(clrSh > 63)
|
||||
clrAdd = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
clrSh--;
|
||||
if(clrSh == 0)
|
||||
clrAdd = true;
|
||||
}
|
||||
void keyboard::draw()
|
||||
{
|
||||
if(clrAdd)
|
||||
{
|
||||
clrSh += 4;
|
||||
if(clrSh > 63)
|
||||
clrAdd = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
clrSh--;
|
||||
if(clrSh == 0)
|
||||
clrAdd = true;
|
||||
}
|
||||
|
||||
gfx::drawRectangle(0, 176, 1280, 64, 0xFFFFFFFF);
|
||||
gfx::drawRectangle(0, 240, 1280, 480, 0xFF2D2D2D);
|
||||
gfx::drawRectangle(0, 176, 1280, 64, 0xFFFFFFFF);
|
||||
gfx::drawRectangle(0, 240, 1280, 480, 0xFF2D2D2D);
|
||||
|
||||
uint32_t rectClr = 0xFF << 24 | ((0xBB + clrSh) & 0xFF) << 16 | ((0x88 + clrSh) & 0xFF) << 8 | 0x00;
|
||||
uint32_t rectClr = 0xFF << 24 | ((0xBB + clrSh) & 0xFF) << 16 | ((0x88 + clrSh) & 0xFF) << 8 | 0x00;
|
||||
|
||||
//Draw sel rectangle around key for controller
|
||||
gfx::drawRectangle(keys[selKey].getX() - 4, keys[selKey].getY() - 4, keys[selKey].getW() + 8, keys[selKey].getH() + 8, rectClr);
|
||||
//Draw sel rectangle around key for controller
|
||||
gfx::drawRectangle(keys[selKey].getX() - 4, keys[selKey].getY() - 4, keys[selKey].getW() + 8, keys[selKey].getH() + 8, rectClr);
|
||||
|
||||
for(unsigned i = 0; i < keys.size(); i++)
|
||||
keys[i].draw();
|
||||
for(unsigned i = 0; i < keys.size(); i++)
|
||||
keys[i].draw();
|
||||
|
||||
gfx::drawText(str, 16, 192, 32, 0xFF000000);
|
||||
}
|
||||
gfx::drawText(str, 16, 192, 32, 0xFF000000);
|
||||
}
|
||||
|
||||
std::string keyboard::getString(const std::string& def)
|
||||
{
|
||||
str = def;
|
||||
while(true)
|
||||
{
|
||||
hidScanInput();
|
||||
std::string keyboard::getString(const std::string& def)
|
||||
{
|
||||
str = def;
|
||||
while(true)
|
||||
{
|
||||
hidScanInput();
|
||||
|
||||
uint64_t down = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
if(down & KEY_R)
|
||||
str += util::getDateTime();
|
||||
uint64_t down = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
if(down & KEY_R)
|
||||
str += util::getDateTime();
|
||||
|
||||
touchPosition p;
|
||||
hidTouchRead(&p, 0);
|
||||
touchPosition p;
|
||||
hidTouchRead(&p, 0);
|
||||
|
||||
//Controller input for keyboard
|
||||
if(down & KEY_RIGHT)
|
||||
selKey++;
|
||||
else if(down & KEY_LEFT && selKey > 0)
|
||||
selKey--;
|
||||
else if(down & KEY_DOWN)
|
||||
{
|
||||
selKey += 10;
|
||||
if(selKey > 40)
|
||||
selKey = 40;
|
||||
}
|
||||
else if(down & KEY_UP)
|
||||
{
|
||||
selKey -= 10;
|
||||
if(selKey < 0)
|
||||
selKey = 0;
|
||||
}
|
||||
else if(down & KEY_A)
|
||||
{
|
||||
if(selKey < 41)
|
||||
{
|
||||
str += keys[selKey].getLet();
|
||||
}
|
||||
}
|
||||
else if(down & KEY_X)
|
||||
{
|
||||
str += ' ';
|
||||
}
|
||||
//Controller input for keyboard
|
||||
if(down & KEY_RIGHT)
|
||||
selKey++;
|
||||
else if(down & KEY_LEFT && selKey > 0)
|
||||
selKey--;
|
||||
else if(down & KEY_DOWN)
|
||||
{
|
||||
selKey += 10;
|
||||
if(selKey > 40)
|
||||
selKey = 40;
|
||||
}
|
||||
else if(down & KEY_UP)
|
||||
{
|
||||
selKey -= 10;
|
||||
if(selKey < 0)
|
||||
selKey = 0;
|
||||
}
|
||||
else if(down & KEY_A)
|
||||
{
|
||||
if(selKey < 41)
|
||||
{
|
||||
str += keys[selKey].getLet();
|
||||
}
|
||||
}
|
||||
else if(down & KEY_X)
|
||||
{
|
||||
str += ' ';
|
||||
}
|
||||
|
||||
//Stndrd key
|
||||
for(unsigned i = 0; i < 41; i++)
|
||||
{
|
||||
keys[i].update(p);
|
||||
if(keys[i].getEvent() == BUTTON_RELEASED)
|
||||
{
|
||||
str += keys[i].getLet();
|
||||
}
|
||||
}
|
||||
//Stndrd key
|
||||
for(unsigned i = 0; i < 41; i++)
|
||||
{
|
||||
keys[i].update(p);
|
||||
if(keys[i].getEvent() == BUTTON_RELEASED)
|
||||
{
|
||||
str += keys[i].getLet();
|
||||
}
|
||||
}
|
||||
|
||||
for(unsigned i = 41; i < 44; i++)
|
||||
keys[i].update(p);
|
||||
for(unsigned i = 41; i < 44; i++)
|
||||
keys[i].update(p);
|
||||
|
||||
//shift
|
||||
if(keys[41].getEvent() == BUTTON_RELEASED || down & KEY_LSTICK)
|
||||
{
|
||||
if(keys[10].getLet() == 'q')
|
||||
{
|
||||
for(unsigned i = 10; i < 41; i++)
|
||||
keys[i].toCaps();
|
||||
}
|
||||
else
|
||||
{
|
||||
for(unsigned i = 10; i < 41; i++)
|
||||
keys[i].toLower();
|
||||
}
|
||||
}
|
||||
//bckspace
|
||||
else if(keys[42].getEvent() == BUTTON_RELEASED || down & KEY_Y)
|
||||
{
|
||||
if(!str.empty())
|
||||
str.erase(str.end() - 1, str.end());
|
||||
}
|
||||
//enter
|
||||
else if(keys[43].getEvent() == BUTTON_RELEASED || down & KEY_PLUS)
|
||||
break;
|
||||
//cancel
|
||||
else if(keys[44].getEvent() == BUTTON_RELEASED || down & KEY_B)
|
||||
{
|
||||
str.erase(str.begin(), str.end());
|
||||
break;
|
||||
}
|
||||
//shift
|
||||
if(keys[41].getEvent() == BUTTON_RELEASED || down & KEY_LSTICK)
|
||||
{
|
||||
if(keys[10].getLet() == 'q')
|
||||
{
|
||||
for(unsigned i = 10; i < 41; i++)
|
||||
keys[i].toCaps();
|
||||
}
|
||||
else
|
||||
{
|
||||
for(unsigned i = 10; i < 41; i++)
|
||||
keys[i].toLower();
|
||||
}
|
||||
}
|
||||
//bckspace
|
||||
else if(keys[42].getEvent() == BUTTON_RELEASED || down & KEY_Y)
|
||||
{
|
||||
if(!str.empty())
|
||||
str.erase(str.end() - 1, str.end());
|
||||
}
|
||||
//enter
|
||||
else if(keys[43].getEvent() == BUTTON_RELEASED || down & KEY_PLUS)
|
||||
break;
|
||||
//cancel
|
||||
else if(keys[44].getEvent() == BUTTON_RELEASED || down & KEY_B)
|
||||
{
|
||||
str.erase(str.begin(), str.end());
|
||||
break;
|
||||
}
|
||||
|
||||
draw();
|
||||
draw();
|
||||
|
||||
gfx::handleBuffs();
|
||||
}
|
||||
gfx::handleBuffs();
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
279
src/ui/menu.cpp
|
|
@ -7,154 +7,169 @@
|
|||
|
||||
namespace ui
|
||||
{
|
||||
void menu::setParams(const unsigned& _x, const unsigned& _y, const unsigned& _rW)
|
||||
{
|
||||
x = _x;
|
||||
y = _y;
|
||||
rW = _rW;
|
||||
rY = _y;
|
||||
void menu::setParams(const unsigned& _x, const unsigned& _y, const unsigned& _rW)
|
||||
{
|
||||
x = _x;
|
||||
y = _y;
|
||||
rW = _rW;
|
||||
rY = _y;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
opt.push_back(add);
|
||||
}
|
||||
void menu::addOpt(const std::string& add)
|
||||
{
|
||||
if(gfx::getTextWidth(add, 16) < rW || rW == 0)
|
||||
opt.push_back(add);
|
||||
else
|
||||
{
|
||||
std::string tmp;
|
||||
for(unsigned i = 0; i < add.length(); i++)
|
||||
{
|
||||
tmp += add[i];
|
||||
if(gfx::getTextWidth(tmp, 16) >= rW)
|
||||
{
|
||||
tmp.replace(i - 1, 2, "[]");
|
||||
opt.push_back(tmp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
menu::~menu()
|
||||
{
|
||||
opt.clear();
|
||||
}
|
||||
menu::~menu()
|
||||
{
|
||||
opt.clear();
|
||||
}
|
||||
|
||||
void menu::handleInput(const uint64_t& down, const uint64_t& held, const touchPosition& p)
|
||||
{
|
||||
if( (held & KEY_UP) || (held & KEY_DOWN))
|
||||
fc++;
|
||||
else
|
||||
fc = 0;
|
||||
if(fc > 10)
|
||||
fc = 0;
|
||||
void menu::handleInput(const uint64_t& down, const uint64_t& held, const touchPosition& p)
|
||||
{
|
||||
if( (held & KEY_UP) || (held & KEY_DOWN))
|
||||
fc++;
|
||||
else
|
||||
fc = 0;
|
||||
if(fc > 10)
|
||||
fc = 0;
|
||||
|
||||
int size = opt.size() - 1;
|
||||
if((down & KEY_UP) || ((held & KEY_UP) && fc == 10))
|
||||
{
|
||||
selected--;
|
||||
if(selected < 0)
|
||||
selected = size;
|
||||
int size = opt.size() - 1;
|
||||
if((down & KEY_UP) || ((held & KEY_UP) && fc == 10))
|
||||
{
|
||||
selected--;
|
||||
if(selected < 0)
|
||||
selected = size;
|
||||
|
||||
if((start > selected) && (start > 0))
|
||||
start--;
|
||||
if(size < 15)
|
||||
start = 0;
|
||||
if((selected - 14) > start)
|
||||
start = selected - 14;
|
||||
}
|
||||
else if((down & KEY_DOWN) || ((held & KEY_DOWN) && fc == 10))
|
||||
{
|
||||
selected++;
|
||||
if(selected > size)
|
||||
selected = 0;
|
||||
if((start > selected) && (start > 0))
|
||||
start--;
|
||||
if(size < 15)
|
||||
start = 0;
|
||||
if((selected - 14) > start)
|
||||
start = selected - 14;
|
||||
}
|
||||
else if((down & KEY_DOWN) || ((held & KEY_DOWN) && fc == 10))
|
||||
{
|
||||
selected++;
|
||||
if(selected > size)
|
||||
selected = 0;
|
||||
|
||||
if((selected > (start + 14)) && ((start + 14) < size))
|
||||
start++;
|
||||
if(selected == 0)
|
||||
start = 0;
|
||||
}
|
||||
else if(down & KEY_RIGHT)
|
||||
{
|
||||
selected += 7;
|
||||
if(selected > size)
|
||||
selected = size;
|
||||
if((selected - 14) > start)
|
||||
start = selected - 14;
|
||||
}
|
||||
else if(down & KEY_LEFT)
|
||||
{
|
||||
selected -= 7;
|
||||
if(selected < 0)
|
||||
selected = 0;
|
||||
if(selected < start)
|
||||
start = selected;
|
||||
}
|
||||
if((selected > (start + 14)) && ((start + 14) < size))
|
||||
start++;
|
||||
if(selected == 0)
|
||||
start = 0;
|
||||
}
|
||||
else if(down & KEY_RIGHT)
|
||||
{
|
||||
selected += 7;
|
||||
if(selected > size)
|
||||
selected = size;
|
||||
if((selected - 14) > start)
|
||||
start = selected - 14;
|
||||
}
|
||||
else if(down & KEY_LEFT)
|
||||
{
|
||||
selected -= 7;
|
||||
if(selected < 0)
|
||||
selected = 0;
|
||||
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;
|
||||
}
|
||||
//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);
|
||||
track.update(p);
|
||||
|
||||
switch(track.getEvent())
|
||||
{
|
||||
case TRACK_SWIPE_UP:
|
||||
if(start + 15 < (int)opt.size())
|
||||
start++, selected++;
|
||||
break;
|
||||
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;
|
||||
}
|
||||
}
|
||||
case TRACK_SWIPE_DOWN:
|
||||
if(start - 1 >= 0)
|
||||
start--, selected--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void menu::draw(const uint32_t& textClr)
|
||||
{
|
||||
if(clrAdd)
|
||||
{
|
||||
clrSh += 4;
|
||||
if(clrSh > 63)
|
||||
clrAdd = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
clrSh--;
|
||||
if(clrSh == 0)
|
||||
clrAdd = true;
|
||||
}
|
||||
void menu::draw(const uint32_t& textClr)
|
||||
{
|
||||
if(clrAdd)
|
||||
{
|
||||
clrSh += 4;
|
||||
if(clrSh > 63)
|
||||
clrAdd = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
clrSh--;
|
||||
if(clrSh == 0)
|
||||
clrAdd = true;
|
||||
}
|
||||
|
||||
int length = 0;
|
||||
if((opt.size() - 1) < 15)
|
||||
length = opt.size();
|
||||
else
|
||||
length = start + 15;
|
||||
int length = 0;
|
||||
if((opt.size() - 1) < 15)
|
||||
length = opt.size();
|
||||
else
|
||||
length = start + 15;
|
||||
|
||||
uint32_t rectClr = 0xFF << 24 | ((0xBB + clrSh) & 0xFF) << 16 | ((0x60 + clrSh)) << 8 | 0x00;
|
||||
uint32_t rectClr = 0xFF << 24 | ((0xBB + clrSh) & 0xFF) << 16 | ((0x60 + clrSh)) << 8 | 0x00;
|
||||
|
||||
for(int i = start; i < length; i++)
|
||||
{
|
||||
if(i == selected)
|
||||
gfx::drawRectangle(x, y + ((i - start) * 36), rW, 32, rectClr);
|
||||
for(int i = start; i < length; i++)
|
||||
{
|
||||
if(i == selected)
|
||||
gfx::drawRectangle(x, y + ((i - start) * 36), rW, 32, rectClr);
|
||||
|
||||
gfx::drawText(opt[i], x, (y + 8) + ((i - start) * 36), 16, textClr);
|
||||
}
|
||||
}
|
||||
gfx::drawText(opt[i], x, (y + 8) + ((i - start) * 36), 16, textClr);
|
||||
}
|
||||
}
|
||||
|
||||
void menu::reset()
|
||||
{
|
||||
opt.clear();
|
||||
void menu::reset()
|
||||
{
|
||||
opt.clear();
|
||||
|
||||
selected = 0;
|
||||
fc = 0;
|
||||
start = 0;
|
||||
}
|
||||
selected = 0;
|
||||
fc = 0;
|
||||
start = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,263 +8,261 @@
|
|||
|
||||
namespace ui
|
||||
{
|
||||
progBar::progBar(const uint32_t& _max)
|
||||
{
|
||||
max = (float)_max;
|
||||
}
|
||||
progBar::progBar(const unsigned& _max)
|
||||
{
|
||||
max = (float)_max;
|
||||
}
|
||||
|
||||
void progBar::update(const uint32_t& _prog)
|
||||
{
|
||||
prog = (float)_prog;
|
||||
void progBar::update(const unsigned& _prog)
|
||||
{
|
||||
prog = (float)_prog;
|
||||
|
||||
float percent = (float)(prog / max) * 100;
|
||||
width = (float)(percent * 1088) / 100;
|
||||
}
|
||||
float percent = (float)(prog / max) * 100;
|
||||
width = (float)(percent * 1088) / 100;
|
||||
}
|
||||
|
||||
void progBar::draw(const std::string& text)
|
||||
{
|
||||
ui::drawTextbox(64, 240, 1152, 240);
|
||||
gfx::drawRectangle(96, 400, 1088, 64, 0xFF000000);
|
||||
gfx::drawRectangle(96, 400, (uint32_t)width, 64, 0xFF00CC00);
|
||||
void progBar::draw(const std::string& text)
|
||||
{
|
||||
ui::drawTextbox(64, 240, 1152, 240);
|
||||
gfx::drawRectangle(96, 400, 1088, 64, 0xFF000000);
|
||||
gfx::drawRectangle(96, 400, (unsigned)width, 64, 0xFF00CC00);
|
||||
|
||||
//char tmp[64];
|
||||
//sprintf(tmp, "%u / %u", (unsigned)prog, (unsigned)max);
|
||||
gfx::drawText(text, 80, 256, 24, txtClr);
|
||||
//gfx::drawText(tmp, 80, 320, 64, 0x000000FF);
|
||||
}
|
||||
//char tmp[64];
|
||||
//sprintf(tmp, "%u / %u", (unsigned)prog, (unsigned)max);
|
||||
gfx::drawText(text, 80, 256, 24, txtClr);
|
||||
//gfx::drawText(tmp, 80, 320, 64, 0x000000FF);
|
||||
}
|
||||
|
||||
button::button(const std::string& _txt, unsigned _x, unsigned _y, unsigned _w, unsigned _h)
|
||||
{
|
||||
x = _x;
|
||||
y = _y;
|
||||
w = _w;
|
||||
h = _h;
|
||||
text = _txt;
|
||||
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 = gfx::getTextWidth(text, 24);
|
||||
unsigned th = gfx::getTextHeight(24);
|
||||
unsigned tw = gfx::getTextWidth(text, 24);
|
||||
unsigned th = gfx::getTextHeight(24);
|
||||
|
||||
tx = x + (w / 2) - (tw / 2);
|
||||
ty = y + (h / 2) - (th / 2);
|
||||
}
|
||||
tx = x + (w / 2) - (tw / 2);
|
||||
ty = y + (h / 2) - (th / 2);
|
||||
}
|
||||
|
||||
void button::update(const touchPosition& p)
|
||||
{
|
||||
prev = cur;
|
||||
cur = p;
|
||||
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;
|
||||
}
|
||||
}
|
||||
//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::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);
|
||||
}
|
||||
bool button::wasOver()
|
||||
{
|
||||
return (prev.px > x && prev.px < x + w && prev.py > y && prev.py < y + h);
|
||||
}
|
||||
|
||||
void button::draw()
|
||||
{
|
||||
if(pressed)
|
||||
gfx::drawRectangle(x, y, w, h, 0xFFD0D0D0);
|
||||
else
|
||||
ui::drawTextbox(x, y, w, h);
|
||||
void button::draw()
|
||||
{
|
||||
if(pressed)
|
||||
gfx::drawRectangle(x, y, w, h, 0xFFD0D0D0);
|
||||
else
|
||||
ui::drawTextbox(x, y, w, h);
|
||||
|
||||
gfx::drawText(text, tx, ty, 24, txtClr);
|
||||
}
|
||||
gfx::drawText(text, tx, ty, 24, txtClr);
|
||||
}
|
||||
|
||||
void touchTrack::update(const touchPosition& p)
|
||||
{
|
||||
if(hidTouchCount() > 0)
|
||||
{
|
||||
pos[curPos++] = p;
|
||||
if(curPos == 5)
|
||||
{
|
||||
curPos = 0;
|
||||
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;
|
||||
}
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
std::memset(pos, 0, sizeof(touchPosition) * 5);
|
||||
}
|
||||
else
|
||||
retTrack = TRACK_NOTHING;
|
||||
}
|
||||
else
|
||||
{
|
||||
retTrack = TRACK_NOTHING;
|
||||
curPos = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void showMessage(const std::string& mess)
|
||||
{
|
||||
button ok("OK", 256, 496, 768, 96);
|
||||
std::string wrapMess = util::getWrappedString(mess, 24, 752);
|
||||
while(true)
|
||||
{
|
||||
hidScanInput();
|
||||
void showMessage(const std::string& mess)
|
||||
{
|
||||
button ok("OK", 256, 496, 768, 96);
|
||||
std::string wrapMess = util::getWrappedString(mess, 24, 752);
|
||||
while(true)
|
||||
{
|
||||
hidScanInput();
|
||||
|
||||
uint64_t down = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
touchPosition p;
|
||||
hidTouchRead(&p, 0);
|
||||
uint64_t down = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
touchPosition p;
|
||||
hidTouchRead(&p, 0);
|
||||
|
||||
ok.update(p);
|
||||
ok.update(p);
|
||||
|
||||
if(down & KEY_A || down & KEY_B || ok.getEvent() == BUTTON_RELEASED)
|
||||
break;
|
||||
if(down & KEY_A || down & KEY_B || ok.getEvent() == BUTTON_RELEASED)
|
||||
break;
|
||||
|
||||
ui::drawTextbox(256, 128, 768, 464);
|
||||
gfx::drawText(wrapMess, 272, 144, 24, txtClr);
|
||||
ok.draw();
|
||||
ui::buttonA.drawInvert(ok.getTx() + 56, ok.getTy() - 4);
|
||||
ui::drawTextbox(256, 128, 768, 464);
|
||||
gfx::drawText(wrapMess, 272, 144, 24, txtClr);
|
||||
ok.draw();
|
||||
ui::buttonA.drawInvert(ok.getTx() + 56, ok.getTy() - 4);
|
||||
|
||||
gfx::handleBuffs();
|
||||
}
|
||||
}
|
||||
gfx::handleBuffs();
|
||||
}
|
||||
}
|
||||
|
||||
void showError(const std::string& mess, const Result& r)
|
||||
{
|
||||
button ok("OK (A)", 256, 496, 768, 96);
|
||||
char tmp[512];
|
||||
std::string wrapMess = util::getWrappedString(mess, 48, 752);
|
||||
sprintf(tmp, "%s\n0x%08X", mess.c_str(), (unsigned)r);
|
||||
void showError(const std::string& mess, const Result& r)
|
||||
{
|
||||
button ok("OK (A)", 256, 496, 768, 96);
|
||||
char tmp[512];
|
||||
std::string wrapMess = util::getWrappedString(mess, 48, 752);
|
||||
sprintf(tmp, "%s\n0x%08X", mess.c_str(), (unsigned)r);
|
||||
|
||||
while(true)
|
||||
{
|
||||
hidScanInput();
|
||||
while(true)
|
||||
{
|
||||
hidScanInput();
|
||||
|
||||
uint64_t down = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
touchPosition p;
|
||||
hidTouchRead(&p, 0);
|
||||
uint64_t down = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
touchPosition p;
|
||||
hidTouchRead(&p, 0);
|
||||
|
||||
ok.update(p);
|
||||
ok.update(p);
|
||||
|
||||
if(down & KEY_A || down & KEY_B || ok.getEvent() == BUTTON_RELEASED)
|
||||
break;
|
||||
if(down & KEY_A || down & KEY_B || ok.getEvent() == BUTTON_RELEASED)
|
||||
break;
|
||||
|
||||
ui::drawTextbox(256, 128, 768, 464);
|
||||
gfx::drawText(tmp, 272, 144, 48, txtClr);
|
||||
ok.draw();
|
||||
ui::drawTextbox(256, 128, 768, 464);
|
||||
gfx::drawText(tmp, 272, 144, 48, txtClr);
|
||||
ok.draw();
|
||||
|
||||
gfx::handleBuffs();
|
||||
}
|
||||
}
|
||||
gfx::handleBuffs();
|
||||
}
|
||||
}
|
||||
|
||||
bool confirm(const std::string& mess)
|
||||
{
|
||||
bool ret = false;
|
||||
bool confirm(const std::string& mess)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
button yes("Yes ", 256, 496, 384, 96);
|
||||
button no("No ", 640, 496, 384, 96);
|
||||
button yes("Yes ", 256, 496, 384, 96);
|
||||
button no("No ", 640, 496, 384, 96);
|
||||
|
||||
std::string wrapMess = util::getWrappedString(mess, 24, 752);
|
||||
std::string wrapMess = util::getWrappedString(mess, 24, 752);
|
||||
|
||||
while(true)
|
||||
{
|
||||
hidScanInput();
|
||||
while(true)
|
||||
{
|
||||
hidScanInput();
|
||||
|
||||
uint64_t down = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
touchPosition p;
|
||||
hidTouchRead(&p, 0);
|
||||
uint64_t down = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
touchPosition p;
|
||||
hidTouchRead(&p, 0);
|
||||
|
||||
yes.update(p);
|
||||
no.update(p);
|
||||
yes.update(p);
|
||||
no.update(p);
|
||||
|
||||
if(down & KEY_A || yes.getEvent() == BUTTON_RELEASED)
|
||||
{
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
else if(down & KEY_B || no.getEvent() == BUTTON_RELEASED)
|
||||
{
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
if(down & KEY_A || yes.getEvent() == BUTTON_RELEASED)
|
||||
{
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
else if(down & KEY_B || no.getEvent() == BUTTON_RELEASED)
|
||||
{
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
|
||||
ui::drawTextbox(256, 128, 768, 464);
|
||||
gfx::drawText(wrapMess, 272, 144, 24, txtClr);
|
||||
yes.draw();
|
||||
ui::buttonA.drawInvert(yes.getTx() + 64, yes.getTy() - 4);
|
||||
no.draw();
|
||||
ui::buttonB.drawInvert(no.getTx() + 56, no.getTy() - 4);
|
||||
ui::drawTextbox(256, 128, 768, 464);
|
||||
gfx::drawText(wrapMess, 272, 144, 24, txtClr);
|
||||
yes.draw();
|
||||
ui::buttonA.drawInvert(yes.getTx() + 64, yes.getTy() - 4);
|
||||
no.draw();
|
||||
ui::buttonB.drawInvert(no.getTx() + 56, no.getTy() - 4);
|
||||
|
||||
gfx::handleBuffs();
|
||||
}
|
||||
gfx::handleBuffs();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool confirmTransfer(const std::string& f, const std::string& t)
|
||||
{
|
||||
std::string confMess = "Are you sure you want to copy \"" + f + "\" to \"" + t +"\"?";
|
||||
bool confirmTransfer(const std::string& f, const std::string& t)
|
||||
{
|
||||
std::string confMess = "Are you sure you want to copy \"" + f + "\" to \"" + t +"\"?";
|
||||
|
||||
return confirm(confMess);
|
||||
}
|
||||
return confirm(confMess);
|
||||
}
|
||||
|
||||
bool confirmDelete(const std::string& p)
|
||||
{
|
||||
std::string confMess = "Are you 100% sure you want to delete \"" + p + "\"? This is permanent!";
|
||||
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);
|
||||
}
|
||||
|
||||
void drawTextbox(unsigned x, unsigned y, unsigned w, unsigned h)
|
||||
{
|
||||
//Top
|
||||
cornerTopLeft.draw(x, y);
|
||||
horEdgeTop.drawRepeatHoriNoBlend(x + 32, y, w - 64);
|
||||
cornerTopRight.draw((x + w) - 32, y);
|
||||
void drawTextbox(unsigned x, unsigned y, unsigned w, unsigned h)
|
||||
{
|
||||
//Top
|
||||
cornerTopLeft.draw(x, y);
|
||||
gfx::drawRectangle(x + 32, y, w - 64, 32, tboxClr);
|
||||
cornerTopRight.draw((x + w) - 32, y);
|
||||
|
||||
//middle
|
||||
vertEdgeLeft.drawRepeatVertNoBlend(x, y + 32, h - 64);
|
||||
gfx::drawRectangle(x + 32, y + 32, w - 64, h - 64, tboxClr);
|
||||
vertEdgeRight.drawRepeatVertNoBlend((x + w) - 32, y + 32, h - 64);
|
||||
//middle
|
||||
gfx::drawRectangle(x, y + 32, w, h - 64, tboxClr);
|
||||
|
||||
//bottom
|
||||
cornerBottomLeft.draw(x, (y + h) - 32);
|
||||
horEdgeBot.drawRepeatHoriNoBlend(x + 32, (y + h) - 32, w - 64);
|
||||
cornerBottomRight.draw((x + w) - 32, (y + h) -32);
|
||||
//bottom
|
||||
cornerBottomLeft.draw(x, (y + h) - 32);
|
||||
gfx::drawRectangle(x + 32, (y + h) - 32, w - 64, 32, tboxClr);
|
||||
cornerBottomRight.draw((x + w) - 32, (y + h) -32);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,201 +8,201 @@
|
|||
|
||||
namespace ui
|
||||
{
|
||||
void updateTitleMenu(const uint64_t& down, const uint64_t& held, const touchPosition& p)
|
||||
{
|
||||
//Static vars so they don't change on every loop
|
||||
//Where to start in titles, selected title
|
||||
static int start = 0, selected = 0;
|
||||
void updateTitleMenu(const uint64_t& down, const uint64_t& held, const touchPosition& p)
|
||||
{
|
||||
//Static vars so they don't change on every loop
|
||||
//Where to start in titles, selected title
|
||||
static int start = 0, selected = 0;
|
||||
|
||||
//Color shift for rect
|
||||
static uint8_t clrShft = 0;
|
||||
//Whether or not we're adding or subtracting from clrShft
|
||||
static bool clrAdd = true;
|
||||
//Color shift for rect
|
||||
static uint8_t clrShft = 0;
|
||||
//Whether or not we're adding or subtracting from clrShft
|
||||
static bool clrAdd = true;
|
||||
|
||||
//Selected rectangle X and Y.
|
||||
static unsigned selRectX = 64, selRectY = 74;
|
||||
//Selected rectangle X and Y.
|
||||
static unsigned selRectX = 64, selRectY = 74;
|
||||
|
||||
static ui::touchTrack track;
|
||||
static ui::touchTrack track;
|
||||
|
||||
if(clrAdd)
|
||||
{
|
||||
clrShft += 4;
|
||||
if(clrShft > 63)
|
||||
clrAdd = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
clrShft--;
|
||||
if(clrShft == 0)
|
||||
clrAdd = true;
|
||||
}
|
||||
if(clrAdd)
|
||||
{
|
||||
clrShft += 4;
|
||||
if(clrShft > 63)
|
||||
clrAdd = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
clrShft--;
|
||||
if(clrShft == 0)
|
||||
clrAdd = true;
|
||||
}
|
||||
|
||||
unsigned x = 70, y = 80;
|
||||
unsigned x = 70, y = 80;
|
||||
|
||||
unsigned endTitle = start + 32;
|
||||
if(start + 32 > (int)data::curUser.titles.size())
|
||||
endTitle = data::curUser.titles.size();
|
||||
unsigned endTitle = start + 32;
|
||||
if(start + 32 > (int)data::curUser.titles.size())
|
||||
endTitle = data::curUser.titles.size();
|
||||
|
||||
//draw Rect so it's always behind icons
|
||||
uint32_t rectClr = 0xFF << 24 | ((0xBB + clrShft) & 0xFF) << 16 | ((0x60 + clrShft)) << 8 | 0x00;
|
||||
gfx::drawRectangle(selRectX, selRectY, 140, 140, rectClr);
|
||||
//draw Rect so it's always behind icons
|
||||
uint32_t rectClr = 0xFF << 24 | ((0xBB + clrShft) & 0xFF) << 16 | ((0x60 + clrShft)) << 8 | 0x00;
|
||||
gfx::drawRectangle(selRectX, selRectY, 140, 140, rectClr);
|
||||
|
||||
for(unsigned i = start; i < endTitle; y += 144)
|
||||
{
|
||||
unsigned endRow = i + 8;
|
||||
for(unsigned tX = x; i < endRow; i++, tX += 144)
|
||||
{
|
||||
if(i == endTitle)
|
||||
break;
|
||||
for(unsigned i = start; i < endTitle; y += 144)
|
||||
{
|
||||
unsigned endRow = i + 8;
|
||||
for(unsigned tX = x; i < endRow; i++, tX += 144)
|
||||
{
|
||||
if(i == endTitle)
|
||||
break;
|
||||
|
||||
if((int)i == selected)
|
||||
{
|
||||
//Most Switch icons seem to be 256x256, we're drawing them 128x128
|
||||
if(selRectX != tX - 6)
|
||||
{
|
||||
if(selRectX < tX - 6)
|
||||
selRectX += 24;
|
||||
else
|
||||
selRectX -= 24;
|
||||
}
|
||||
if((int)i == selected)
|
||||
{
|
||||
//Most Switch icons seem to be 256x256, we're drawing them 128x128
|
||||
if(selRectX != tX - 6)
|
||||
{
|
||||
if(selRectX < tX - 6)
|
||||
selRectX += 24;
|
||||
else
|
||||
selRectX -= 24;
|
||||
}
|
||||
|
||||
if(selRectY != y - 6)
|
||||
{
|
||||
if(selRectY < y - 6)
|
||||
selRectY += 24;
|
||||
else
|
||||
selRectY -= 24;
|
||||
}
|
||||
if(selRectY != y - 6)
|
||||
{
|
||||
if(selRectY < y - 6)
|
||||
selRectY += 24;
|
||||
else
|
||||
selRectY -= 24;
|
||||
}
|
||||
|
||||
std::string title = data::curUser.titles[selected].getTitle();
|
||||
unsigned titleWidth = gfx::getTextWidth(title, 16);
|
||||
int rectWidth = titleWidth + 32, rectX = (tX + 64) - (rectWidth / 2);
|
||||
if(rectX < 16)
|
||||
rectX = 16;
|
||||
std::string title = data::curUser.titles[selected].getTitle();
|
||||
unsigned titleWidth = gfx::getTextWidth(title, 16);
|
||||
int rectWidth = titleWidth + 32, rectX = (tX + 64) - (rectWidth / 2);
|
||||
if(rectX < 16)
|
||||
rectX = 16;
|
||||
|
||||
if(rectX + rectWidth > 1264)
|
||||
rectX = 1264 - rectWidth;
|
||||
if(rectX + rectWidth > 1264)
|
||||
rectX = 1264 - rectWidth;
|
||||
|
||||
drawTextbox(rectX, y - 50, rectWidth, 38);
|
||||
gfx::drawText(title, rectX + 16, y - 38, 16, txtClr);
|
||||
}
|
||||
data::curUser.titles[i].icon.drawHalf(tX, y);
|
||||
}
|
||||
}
|
||||
drawTextbox(rectX, y - 50, rectWidth, 38);
|
||||
gfx::drawText(title, rectX + 16, y - 38, 16, txtClr);
|
||||
}
|
||||
data::curUser.titles[i].icon.drawHalf(tX, y);
|
||||
}
|
||||
}
|
||||
|
||||
//Buttons
|
||||
for(int i = 0; i < 32; i++)
|
||||
{
|
||||
selButtons[i].update(p);
|
||||
if(i == selected - start && selButtons[i].getEvent() == BUTTON_RELEASED)
|
||||
{
|
||||
//Correct rectangle if it can't catch up. Buttons use same x, y as icons
|
||||
selRectX = selButtons[i].getX() - 6;
|
||||
selRectY = selButtons[i].getY() - 6;
|
||||
//Buttons
|
||||
for(int i = 0; i < 32; i++)
|
||||
{
|
||||
selButtons[i].update(p);
|
||||
if(i == selected - start && selButtons[i].getEvent() == BUTTON_RELEASED)
|
||||
{
|
||||
//Correct rectangle if it can't catch up. Buttons use same x, y as icons
|
||||
selRectX = selButtons[i].getX() - 6;
|
||||
selRectY = selButtons[i].getY() - 6;
|
||||
|
||||
data::curData = data::curUser.titles[selected];
|
||||
if(fs::mountSave(data::curUser, data::curData))
|
||||
{
|
||||
util::makeTitleDir(data::curUser, data::curData);
|
||||
folderMenuPrepare(data::curUser, data::curData);
|
||||
folderMenuInfo = util::getWrappedString(util::getInfoString(data::curUser, data::curData), 18, 256);
|
||||
data::curData = data::curUser.titles[selected];
|
||||
if(fs::mountSave(data::curUser, data::curData))
|
||||
{
|
||||
util::makeTitleDir(data::curUser, data::curData);
|
||||
folderMenuPrepare(data::curUser, data::curData);
|
||||
folderMenuInfo = util::getWrappedString(util::getInfoString(data::curUser, data::curData), 18, 256);
|
||||
|
||||
mstate = FLD_SEL;
|
||||
}
|
||||
}
|
||||
else if(selButtons[i].getEvent() == BUTTON_RELEASED)
|
||||
{
|
||||
if(start + i < (int)data::curUser.titles.size())
|
||||
selected = start + i;
|
||||
}
|
||||
}
|
||||
mstate = FLD_SEL;
|
||||
}
|
||||
}
|
||||
else if(selButtons[i].getEvent() == BUTTON_RELEASED)
|
||||
{
|
||||
if(start + i < (int)data::curUser.titles.size())
|
||||
selected = start + i;
|
||||
}
|
||||
}
|
||||
|
||||
//Update touchtracking
|
||||
track.update(p);
|
||||
//Update touchtracking
|
||||
track.update(p);
|
||||
|
||||
switch(track.getEvent())
|
||||
{
|
||||
case TRACK_SWIPE_UP:
|
||||
{
|
||||
if(start + 32 < (int)data::curUser.titles.size())
|
||||
{
|
||||
start += 8;
|
||||
selected += 8;
|
||||
if(selected > (int)data::curUser.titles.size() - 1)
|
||||
selected = data::curUser.titles.size() - 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
switch(track.getEvent())
|
||||
{
|
||||
case TRACK_SWIPE_UP:
|
||||
{
|
||||
if(start + 32 < (int)data::curUser.titles.size())
|
||||
{
|
||||
start += 8;
|
||||
selected += 8;
|
||||
if(selected > (int)data::curUser.titles.size() - 1)
|
||||
selected = data::curUser.titles.size() - 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TRACK_SWIPE_DOWN:
|
||||
{
|
||||
if(start - 8 >= 0)
|
||||
{
|
||||
start -= 8;
|
||||
selected -= 8;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TRACK_SWIPE_DOWN:
|
||||
{
|
||||
if(start - 8 >= 0)
|
||||
{
|
||||
start -= 8;
|
||||
selected -= 8;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(down & KEY_RIGHT)
|
||||
{
|
||||
if(selected < (int)data::curUser.titles.size() - 1)
|
||||
selected++;
|
||||
if(down & KEY_RIGHT)
|
||||
{
|
||||
if(selected < (int)data::curUser.titles.size() - 1)
|
||||
selected++;
|
||||
|
||||
if(selected >= (int)start + 32)
|
||||
start += 8;
|
||||
}
|
||||
else if(down & KEY_LEFT)
|
||||
{
|
||||
if(selected > 0)
|
||||
selected--;
|
||||
if(selected >= (int)start + 32)
|
||||
start += 8;
|
||||
}
|
||||
else if(down & KEY_LEFT)
|
||||
{
|
||||
if(selected > 0)
|
||||
selected--;
|
||||
|
||||
if(selected < (int)start)
|
||||
start -= 8;
|
||||
}
|
||||
else if(down & KEY_UP)
|
||||
{
|
||||
selected -= 8;
|
||||
if(selected < 0)
|
||||
selected = 0;
|
||||
if(selected < (int)start)
|
||||
start -= 8;
|
||||
}
|
||||
else if(down & KEY_UP)
|
||||
{
|
||||
selected -= 8;
|
||||
if(selected < 0)
|
||||
selected = 0;
|
||||
|
||||
if(selected < start)
|
||||
start -= 8;
|
||||
}
|
||||
else if(down & KEY_DOWN)
|
||||
{
|
||||
selected += 8;
|
||||
if(selected > (int)data::curUser.titles.size() - 1)
|
||||
selected = data::curUser.titles.size() - 1;
|
||||
if(selected < start)
|
||||
start -= 8;
|
||||
}
|
||||
else if(down & KEY_DOWN)
|
||||
{
|
||||
selected += 8;
|
||||
if(selected > (int)data::curUser.titles.size() - 1)
|
||||
selected = data::curUser.titles.size() - 1;
|
||||
|
||||
if(selected - start >= 32)
|
||||
start += 8;
|
||||
}
|
||||
else if(down & KEY_A)
|
||||
{
|
||||
data::curData = data::curUser.titles[selected];
|
||||
if(fs::mountSave(data::curUser, data::curData))
|
||||
{
|
||||
util::makeTitleDir(data::curUser, data::curData);
|
||||
folderMenuPrepare(data::curUser, data::curData);
|
||||
folderMenuInfo = util::getWrappedString(util::getInfoString(data::curUser, data::curData), 18, 256);
|
||||
if(selected - start >= 32)
|
||||
start += 8;
|
||||
}
|
||||
else if(down & KEY_A)
|
||||
{
|
||||
data::curData = data::curUser.titles[selected];
|
||||
if(fs::mountSave(data::curUser, data::curData))
|
||||
{
|
||||
util::makeTitleDir(data::curUser, data::curData);
|
||||
folderMenuPrepare(data::curUser, data::curData);
|
||||
folderMenuInfo = util::getWrappedString(util::getInfoString(data::curUser, data::curData), 18, 256);
|
||||
|
||||
mstate = FLD_SEL;
|
||||
}
|
||||
}
|
||||
else if(down & KEY_Y)
|
||||
{
|
||||
fs::dumpAllUserSaves(data::curUser);
|
||||
}
|
||||
else if(down & KEY_B)
|
||||
{
|
||||
start = 0;
|
||||
selected = 0;
|
||||
selRectX = 64;
|
||||
selRectY = 74;
|
||||
mstate = USR_SEL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
mstate = FLD_SEL;
|
||||
}
|
||||
}
|
||||
else if(down & KEY_Y)
|
||||
{
|
||||
fs::dumpAllUserSaves(data::curUser);
|
||||
}
|
||||
else if(down & KEY_B)
|
||||
{
|
||||
start = 0;
|
||||
selected = 0;
|
||||
selRectX = 64;
|
||||
selRectY = 74;
|
||||
mstate = USR_SEL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,158 +8,158 @@
|
|||
|
||||
namespace ui
|
||||
{
|
||||
void updateUserMenu(const uint64_t& down, const uint64_t& held, const touchPosition& p)
|
||||
{
|
||||
//Static so they don't get reset every loop
|
||||
static int start = 0, selected = 0;
|
||||
void updateUserMenu(const uint64_t& down, const uint64_t& held, const touchPosition& p)
|
||||
{
|
||||
//Static so they don't get reset every loop
|
||||
static int start = 0, selected = 0;
|
||||
|
||||
static uint8_t clrShft = 0;
|
||||
static bool clrAdd = true;
|
||||
static uint8_t clrShft = 0;
|
||||
static bool clrAdd = true;
|
||||
|
||||
static unsigned selRectX = 64, selRectY = 74;
|
||||
static unsigned selRectX = 64, selRectY = 74;
|
||||
|
||||
static ui::touchTrack track;
|
||||
static ui::touchTrack track;
|
||||
|
||||
if(clrAdd)
|
||||
{
|
||||
clrShft += 4;
|
||||
if(clrShft > 63)
|
||||
clrAdd = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
clrShft--;
|
||||
if(clrShft == 0)
|
||||
clrAdd = true;
|
||||
}
|
||||
if(clrAdd)
|
||||
{
|
||||
clrShft += 4;
|
||||
if(clrShft > 63)
|
||||
clrAdd = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
clrShft--;
|
||||
if(clrShft == 0)
|
||||
clrAdd = true;
|
||||
}
|
||||
|
||||
unsigned x = 70, y = 80;
|
||||
unsigned endUser = start + 32;
|
||||
if(start + 32 > (int)data::users.size())
|
||||
endUser = data::users.size();
|
||||
unsigned x = 70, y = 80;
|
||||
unsigned endUser = start + 32;
|
||||
if(start + 32 > (int)data::users.size())
|
||||
endUser = data::users.size();
|
||||
|
||||
uint32_t rectClr = 0xFF << 24 | ((0xBB + clrShft) & 0xFF) << 16 | ((0x60 + clrShft)) << 8 | 0x00;
|
||||
gfx::drawRectangle(selRectX, selRectY, 140, 140, rectClr);
|
||||
uint32_t rectClr = 0xFF << 24 | ((0xBB + clrShft) & 0xFF) << 16 | ((0x60 + clrShft)) << 8 | 0x00;
|
||||
gfx::drawRectangle(selRectX, selRectY, 140, 140, rectClr);
|
||||
|
||||
for(unsigned i = start; i < endUser; y += 144)
|
||||
{
|
||||
unsigned endRow = i + 8;
|
||||
for(unsigned tX = x; i < endRow; i++, tX += 144)
|
||||
{
|
||||
if(i == endUser)
|
||||
break;
|
||||
for(unsigned i = start; i < endUser; y += 144)
|
||||
{
|
||||
unsigned endRow = i + 8;
|
||||
for(unsigned tX = x; i < endRow; i++, tX += 144)
|
||||
{
|
||||
if(i == endUser)
|
||||
break;
|
||||
|
||||
if((int)i == selected)
|
||||
{
|
||||
if(selRectX != tX - 6)
|
||||
{
|
||||
if(selRectX < tX - 6)
|
||||
selRectX += 24;
|
||||
else
|
||||
selRectX -= 24;
|
||||
}
|
||||
if((int)i == selected)
|
||||
{
|
||||
if(selRectX != tX - 6)
|
||||
{
|
||||
if(selRectX < tX - 6)
|
||||
selRectX += 24;
|
||||
else
|
||||
selRectX -= 24;
|
||||
}
|
||||
|
||||
if(selRectY != y - 6)
|
||||
{
|
||||
if(selRectY < y - 6)
|
||||
selRectY += 24;
|
||||
else
|
||||
selRectX -= 24;
|
||||
}
|
||||
if(selRectY != y - 6)
|
||||
{
|
||||
if(selRectY < y - 6)
|
||||
selRectY += 24;
|
||||
else
|
||||
selRectX -= 24;
|
||||
}
|
||||
|
||||
std::string username = data::users[selected].getUsername();
|
||||
unsigned userWidth = gfx::getTextWidth(username, 16);
|
||||
int userRectWidth = userWidth + 32, userRectX = (tX + 64) - (userRectWidth / 2);
|
||||
if(userRectX < 16)
|
||||
userRectX = 16;
|
||||
std::string username = data::users[selected].getUsername();
|
||||
unsigned userWidth = gfx::getTextWidth(username, 16);
|
||||
int userRectWidth = userWidth + 32, userRectX = (tX + 64) - (userRectWidth / 2);
|
||||
if(userRectX < 16)
|
||||
userRectX = 16;
|
||||
|
||||
if(userRectX + userRectWidth > 1264)
|
||||
userRectX = 1264 - userRectWidth;
|
||||
if(userRectX + userRectWidth > 1264)
|
||||
userRectX = 1264 - userRectWidth;
|
||||
|
||||
drawTextbox(userRectX, y - 50, userRectWidth, 38);
|
||||
gfx::drawText(username, userRectX + 16, y - 38, 16, txtClr);
|
||||
}
|
||||
data::users[i].icn.drawNoBlendSkipSmooth(tX, y);
|
||||
}
|
||||
}
|
||||
drawTextbox(userRectX, y - 50, userRectWidth, 38);
|
||||
gfx::drawText(username, userRectX + 16, y - 38, 16, txtClr);
|
||||
}
|
||||
data::users[i].icn.drawNoBlendSkipSmooth(tX, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Update invisible buttons
|
||||
for(int i = 0; i < 32; i++)
|
||||
{
|
||||
selButtons[i].update(p);
|
||||
if(selected == i && selButtons[i].getEvent() == BUTTON_RELEASED)
|
||||
{
|
||||
data::curUser = data::users[selected];
|
||||
mstate = TTL_SEL;
|
||||
}
|
||||
else if(selButtons[i].getEvent() == BUTTON_RELEASED)
|
||||
{
|
||||
if(start + i < (int)data::users.size())
|
||||
selected = start + i;
|
||||
}
|
||||
}
|
||||
//Update invisible buttons
|
||||
for(int i = 0; i < 32; i++)
|
||||
{
|
||||
selButtons[i].update(p);
|
||||
if(selected == i && selButtons[i].getEvent() == BUTTON_RELEASED)
|
||||
{
|
||||
data::curUser = data::users[selected];
|
||||
mstate = TTL_SEL;
|
||||
}
|
||||
else if(selButtons[i].getEvent() == BUTTON_RELEASED)
|
||||
{
|
||||
if(start + i < (int)data::users.size())
|
||||
selected = start + i;
|
||||
}
|
||||
}
|
||||
|
||||
//Update touch tracking
|
||||
track.update(p);
|
||||
//Update touch tracking
|
||||
track.update(p);
|
||||
|
||||
if(down & KEY_RIGHT)
|
||||
{
|
||||
if(selected < (int)data::users.size() - 1)
|
||||
selected++;
|
||||
if(down & KEY_RIGHT)
|
||||
{
|
||||
if(selected < (int)data::users.size() - 1)
|
||||
selected++;
|
||||
|
||||
if(selected >= (int)start + 32)
|
||||
start += 8;
|
||||
}
|
||||
else if(down & KEY_LEFT)
|
||||
{
|
||||
if(selected > 0)
|
||||
selected--;
|
||||
if(selected >= (int)start + 32)
|
||||
start += 8;
|
||||
}
|
||||
else if(down & KEY_LEFT)
|
||||
{
|
||||
if(selected > 0)
|
||||
selected--;
|
||||
|
||||
if(selected < start)
|
||||
start -= 8;
|
||||
}
|
||||
else if(down & KEY_UP)
|
||||
{
|
||||
selected -= 8;
|
||||
if(selected < 0)
|
||||
selected = 0;
|
||||
if(selected < start)
|
||||
start -= 8;
|
||||
}
|
||||
else if(down & KEY_UP)
|
||||
{
|
||||
selected -= 8;
|
||||
if(selected < 0)
|
||||
selected = 0;
|
||||
|
||||
if(selected - start >= 32)
|
||||
start -= 8;
|
||||
}
|
||||
else if(down & KEY_DOWN)
|
||||
{
|
||||
selected += 8;
|
||||
if(selected > (int)data::users.size() - 1)
|
||||
selected = data::users.size() - 1;
|
||||
if(selected - start >= 32)
|
||||
start -= 8;
|
||||
}
|
||||
else if(down & KEY_DOWN)
|
||||
{
|
||||
selected += 8;
|
||||
if(selected > (int)data::users.size() - 1)
|
||||
selected = data::users.size() - 1;
|
||||
|
||||
if(selected - start >= 32)
|
||||
start += 8;
|
||||
}
|
||||
else if(down & KEY_A)
|
||||
{
|
||||
data::curUser = data::users[selected];
|
||||
//Reset this
|
||||
start = 0;
|
||||
selected = 0;
|
||||
selRectX = 64, selRectY = 74;
|
||||
mstate = TTL_SEL;
|
||||
}
|
||||
else if(down & KEY_Y)
|
||||
{
|
||||
for(unsigned i = 0; i < data::users.size(); i++)
|
||||
fs::dumpAllUserSaves(data::users[i]);
|
||||
}
|
||||
else if(down & KEY_X)
|
||||
{
|
||||
//Just create file so user doesn't have to constantly enable
|
||||
std::fstream cls("cls.txt", std::ios::out);
|
||||
cls.close();
|
||||
clsUserPrep();
|
||||
mstate = CLS_USR;
|
||||
clsMode = true;
|
||||
}
|
||||
if(selected - start >= 32)
|
||||
start += 8;
|
||||
}
|
||||
else if(down & KEY_A)
|
||||
{
|
||||
data::curUser = data::users[selected];
|
||||
//Reset this
|
||||
start = 0;
|
||||
selected = 0;
|
||||
selRectX = 64, selRectY = 74;
|
||||
mstate = TTL_SEL;
|
||||
}
|
||||
else if(down & KEY_Y)
|
||||
{
|
||||
for(unsigned i = 0; i < data::users.size(); i++)
|
||||
fs::dumpAllUserSaves(data::users[i]);
|
||||
}
|
||||
else if(down & KEY_X)
|
||||
{
|
||||
//Just create file so user doesn't have to constantly enable
|
||||
std::fstream cls("cls.txt", std::ios::out);
|
||||
cls.close();
|
||||
clsUserPrep();
|
||||
mstate = CLS_USR;
|
||||
clsMode = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
234
src/util.cpp
|
|
@ -13,152 +13,152 @@ static const char verboten[] = { '.', ',', '/', '\\', '<', '>', ':', '"', '|', '
|
|||
|
||||
namespace util
|
||||
{
|
||||
std::string getDateTime()
|
||||
{
|
||||
char ret[48];
|
||||
std::string getDateTime()
|
||||
{
|
||||
char ret[48];
|
||||
|
||||
time_t raw;
|
||||
time(&raw);
|
||||
tm *Time = localtime(&raw);
|
||||
time_t raw;
|
||||
time(&raw);
|
||||
tm *Time = localtime(&raw);
|
||||
|
||||
sprintf(ret, "%04d-%02d-%02d@%02d-%02d-%02d", Time->tm_year + 1900, Time->tm_mon + 1, Time->tm_mday, Time->tm_hour, Time->tm_min, Time->tm_sec);
|
||||
sprintf(ret, "%04d-%02d-%02d@%02d-%02d-%02d", Time->tm_year + 1900, Time->tm_mon + 1, Time->tm_mday, Time->tm_hour, Time->tm_min, Time->tm_sec);
|
||||
|
||||
return std::string(ret);
|
||||
}
|
||||
return std::string(ret);
|
||||
}
|
||||
|
||||
void makeTitleDir(data::user& u, data::titledata& t)
|
||||
{
|
||||
std::string path = t.getTitleSafe();
|
||||
mkdir(path.c_str(), 777);
|
||||
}
|
||||
void makeTitleDir(data::user& u, data::titledata& t)
|
||||
{
|
||||
std::string path = fs::getWorkDir() + t.getTitleSafe();
|
||||
mkdir(path.c_str(), 777);
|
||||
}
|
||||
|
||||
std::string getTitleDir(data::user& u, data::titledata& t)
|
||||
{
|
||||
return std::string(t.getTitleSafe() + "/");
|
||||
}
|
||||
std::string getTitleDir(data::user& u, data::titledata& t)
|
||||
{
|
||||
return std::string(fs::getWorkDir() + t.getTitleSafe() + "/");
|
||||
}
|
||||
|
||||
std::string getWrappedString(const std::string& s, const unsigned& sz, const unsigned& maxWidth)
|
||||
{
|
||||
if(gfx::getTextWidth(s, sz) < maxWidth)
|
||||
return s;
|
||||
std::string getWrappedString(const std::string& s, const unsigned& sz, const unsigned& maxWidth)
|
||||
{
|
||||
if(gfx::getTextWidth(s, sz) < maxWidth)
|
||||
return s;
|
||||
|
||||
std::string ret = "", tmp = "";
|
||||
unsigned first = 0, lastSpace = 0;
|
||||
std::string ret = "", tmp = "";
|
||||
unsigned first = 0, lastSpace = 0;
|
||||
|
||||
for(unsigned i = 0; i < s.length(); i++)
|
||||
{
|
||||
tmp += s[i];
|
||||
for(unsigned i = 0; i < s.length(); i++)
|
||||
{
|
||||
tmp += s[i];
|
||||
|
||||
// slash for really long file paths with no spaces.
|
||||
if(s[i] == ' ' || s[i] == '/')
|
||||
lastSpace = i;
|
||||
// slash for really long file paths with no spaces.
|
||||
if(s[i] == ' ' || s[i] == '/')
|
||||
lastSpace = i;
|
||||
|
||||
if(gfx::getTextWidth(tmp, sz) >= maxWidth)
|
||||
{
|
||||
tmp.assign(s, first, lastSpace - first);
|
||||
if(gfx::getTextWidth(tmp, sz) >= maxWidth)
|
||||
{
|
||||
tmp.assign(s, first, lastSpace - first);
|
||||
|
||||
ret += tmp + "\n";
|
||||
ret += tmp + "\n";
|
||||
|
||||
first = lastSpace + 1;
|
||||
i = lastSpace;
|
||||
first = lastSpace + 1;
|
||||
i = lastSpace;
|
||||
|
||||
tmp.clear();
|
||||
}
|
||||
}
|
||||
if(!tmp.empty())
|
||||
ret += tmp;
|
||||
tmp.clear();
|
||||
}
|
||||
}
|
||||
if(!tmp.empty())
|
||||
ret += tmp;
|
||||
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void copyDirListToMenu(fs::dirList& d, ui::menu& m)
|
||||
{
|
||||
m.reset();
|
||||
m.addOpt(".");
|
||||
m.addOpt("..");
|
||||
for(unsigned i = 0; i < d.getCount(); i++)
|
||||
{
|
||||
if(d.isDir(i))
|
||||
m.addOpt("D " + d.getItem(i));
|
||||
else
|
||||
m.addOpt("F " + d.getItem(i));
|
||||
}
|
||||
}
|
||||
void copyDirListToMenu(fs::dirList& d, ui::menu& m)
|
||||
{
|
||||
m.reset();
|
||||
m.addOpt(".");
|
||||
m.addOpt("..");
|
||||
for(unsigned i = 0; i < d.getCount(); i++)
|
||||
{
|
||||
if(d.isDir(i))
|
||||
m.addOpt("D " + d.getItem(i));
|
||||
else
|
||||
m.addOpt("F " + d.getItem(i));
|
||||
}
|
||||
}
|
||||
|
||||
void removeLastFolderFromString(std::string& _path)
|
||||
{
|
||||
unsigned last = _path.find_last_of('/', _path.length() - 2);
|
||||
_path.erase(last + 1, _path.length());
|
||||
}
|
||||
void removeLastFolderFromString(std::string& _path)
|
||||
{
|
||||
unsigned last = _path.find_last_of('/', _path.length() - 2);
|
||||
_path.erase(last + 1, _path.length());
|
||||
}
|
||||
|
||||
bool isVerboten(char t)
|
||||
{
|
||||
for(unsigned i = 0; i < 11; i++)
|
||||
{
|
||||
if(t == verboten[i])
|
||||
return true;
|
||||
}
|
||||
bool isVerboten(char t)
|
||||
{
|
||||
for(unsigned i = 0; i < 11; i++)
|
||||
{
|
||||
if(t == verboten[i])
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string safeString(const std::string& s)
|
||||
{
|
||||
std::string ret = "";
|
||||
for(unsigned i = 0; i < s.length(); i++)
|
||||
{
|
||||
if(isVerboten(s[i]))
|
||||
{
|
||||
ret += ' ';
|
||||
}
|
||||
else
|
||||
ret += s[i];
|
||||
}
|
||||
std::string safeString(const std::string& s)
|
||||
{
|
||||
std::string ret = "";
|
||||
for(unsigned i = 0; i < s.length(); i++)
|
||||
{
|
||||
if(isVerboten(s[i]))
|
||||
{
|
||||
ret += ' ';
|
||||
}
|
||||
else
|
||||
ret += s[i];
|
||||
}
|
||||
|
||||
//Check for spaces at end
|
||||
if(ret[ret.length() - 1] == ' ')
|
||||
ret.erase(ret.end() - 1, ret.end());
|
||||
//Check for spaces at end
|
||||
if(ret[ret.length() - 1] == ' ')
|
||||
ret.erase(ret.end() - 1, ret.end());
|
||||
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string getInfoString(data::user& u, data::titledata& d)
|
||||
{
|
||||
std::string ret = d.getTitle();
|
||||
std::string getInfoString(data::user& u, data::titledata& d)
|
||||
{
|
||||
std::string ret = d.getTitle();
|
||||
|
||||
char id[18];
|
||||
sprintf(id, " %016lX", d.getID());
|
||||
ret += id;
|
||||
char id[18];
|
||||
sprintf(id, " %016lX", d.getID());
|
||||
ret += id;
|
||||
|
||||
switch(d.getType())
|
||||
{
|
||||
case FsSaveDataType_SystemSaveData:
|
||||
ret += " System Save";
|
||||
break;
|
||||
switch(d.getType())
|
||||
{
|
||||
case FsSaveDataType_SystemSaveData:
|
||||
ret += " System Save";
|
||||
break;
|
||||
|
||||
case FsSaveDataType_SaveData:
|
||||
ret += " Save Data";
|
||||
break;
|
||||
case FsSaveDataType_SaveData:
|
||||
ret += " Save Data";
|
||||
break;
|
||||
|
||||
case FsSaveDataType_BcatDeliveryCacheStorage:
|
||||
ret += " Bcat Delivery Cache";
|
||||
break;
|
||||
case FsSaveDataType_BcatDeliveryCacheStorage:
|
||||
ret += " Bcat Delivery Cache";
|
||||
break;
|
||||
|
||||
case FsSaveDataType_DeviceSaveData:
|
||||
ret += " Device Save";
|
||||
break;
|
||||
case FsSaveDataType_DeviceSaveData:
|
||||
ret += " Device Save";
|
||||
break;
|
||||
|
||||
case FsSaveDataType_TemporaryStorage:
|
||||
ret = " Temp Storage";
|
||||
break;
|
||||
case FsSaveDataType_TemporaryStorage:
|
||||
ret = " Temp Storage";
|
||||
break;
|
||||
|
||||
case FsSaveDataType_CacheStorage:
|
||||
ret+= " Cache Storage";
|
||||
break;
|
||||
}
|
||||
case FsSaveDataType_CacheStorage:
|
||||
ret+= " Cache Storage";
|
||||
break;
|
||||
}
|
||||
|
||||
ret += "\n" + u.getUsername();
|
||||
ret += "\n" + u.getUsername();
|
||||
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
|
|||