mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-10-22 15:43:05 -05:00
Clean some stuff up
This commit is contained in:
@@ -64,6 +64,11 @@ namespace data
|
||||
std::string getTitleSafe() { return titleSafe; }
|
||||
std::string getAuthor() { return author; }
|
||||
|
||||
//Creates title folder
|
||||
void createDir();
|
||||
//Returns folder path
|
||||
std::string getPath() { return path; }
|
||||
|
||||
uint64_t getID() { return id; }
|
||||
FsSaveDataType getType() { return (FsSaveDataType)saveDataType; }
|
||||
void setType(FsSaveDataType type) { saveDataType = type; }
|
||||
@@ -75,7 +80,7 @@ namespace data
|
||||
|
||||
private:
|
||||
uint8_t saveDataType;
|
||||
std::string title, titleSafe, author;
|
||||
std::string title, titleSafe, author, path;
|
||||
uint64_t id;
|
||||
bool favorite = false;
|
||||
};
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace ui
|
||||
{
|
||||
public:
|
||||
//Constructor. _max is the maximum value
|
||||
progBar(const uint64_t& _max);
|
||||
progBar(const uint64_t& _max) { max = _max; }
|
||||
|
||||
//Updates progress
|
||||
void update(const uint64_t& _prog);
|
||||
@@ -40,6 +40,7 @@ namespace ui
|
||||
private:
|
||||
uint64_t max, prog;
|
||||
float width;
|
||||
tex *bg;
|
||||
};
|
||||
|
||||
class button
|
||||
|
||||
@@ -19,12 +19,6 @@ namespace util
|
||||
//Returns string with date S+ time
|
||||
std::string getDateTime(int fmt);
|
||||
|
||||
//Creates Dir 'JKSV/[title]
|
||||
void makeTitleDir(data::user& u, data::titledata& t);
|
||||
|
||||
//Returns 'JKSV/[title]/'
|
||||
std::string getTitleDir(data::user& u, data::titledata& t);
|
||||
|
||||
//Copys dir list to a menu with 'D: ' + 'F: '
|
||||
void copyDirListToMenu(fs::dirList& d, ui::menu& m);
|
||||
|
||||
|
||||
@@ -349,6 +349,9 @@ namespace data
|
||||
icons.push_back(newIcn);
|
||||
icon = icons[findIcnIndex(id)];
|
||||
}
|
||||
|
||||
path = fs::getWorkDir() + titleSafe + "/";
|
||||
|
||||
delete dat;
|
||||
}
|
||||
|
||||
@@ -364,6 +367,11 @@ namespace data
|
||||
return false;
|
||||
}
|
||||
|
||||
void titledata::createDir()
|
||||
{
|
||||
mkdir(std::string(fs::getWorkDir() + titleSafe).c_str(), 777);
|
||||
}
|
||||
|
||||
bool user::init(const AccountUid& _id)
|
||||
{
|
||||
userID = _id;
|
||||
|
||||
@@ -363,10 +363,10 @@ namespace fs
|
||||
{
|
||||
if(fs::mountSave(u, u.titles[i]))
|
||||
{
|
||||
util::makeTitleDir(u, u.titles[i]);
|
||||
u.titles[i].createDir();
|
||||
|
||||
//sdmc:/JKSV/[title]/[user] - [date]/
|
||||
std::string outPath = util::getTitleDir(u, u.titles[i]) + u.getUsernameSafe() + " - " + util::getDateTime(util::DATE_FMT_YMD);
|
||||
std::string outPath = u.titles[i].getPath() + u.getUsernameSafe() + " - " + util::getDateTime(util::DATE_FMT_YMD);
|
||||
mkdir(outPath.c_str(), 777);
|
||||
outPath += "/";
|
||||
|
||||
|
||||
@@ -295,7 +295,7 @@ namespace ui
|
||||
|
||||
default:
|
||||
case ColorSetId_Dark:
|
||||
drawRect(frameBuffer, x + 4, y + 4, w - 8, h - 8, clrCreateU32(0xFF272221));
|
||||
drawRect(frameBuffer, x + 4, y + 4, w - 8, h - 8, clrCreateU32(0xFF212221));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,10 +17,9 @@ namespace ui
|
||||
folderMenu.setParams(466, 98, 730);
|
||||
folderMenu.reset();
|
||||
|
||||
util::makeTitleDir(usr, dat);
|
||||
std::string scanPath = util::getTitleDir(usr, dat);
|
||||
dat.createDir();
|
||||
|
||||
fs::dirList list(scanPath);
|
||||
fs::dirList list(dat.getPath());
|
||||
folderMenu.addOpt("New");
|
||||
for(unsigned i = 0; i < list.getCount(); i++)
|
||||
folderMenu.addOpt(list.getItem(i));
|
||||
@@ -70,7 +69,7 @@ namespace ui
|
||||
}
|
||||
if(!folder.empty())
|
||||
{
|
||||
std::string path = util::getTitleDir(data::curUser, data::curData) + "/" + folder;
|
||||
std::string path = data::curData.getPath() + "/" + folder;
|
||||
mkdir(path.c_str(), 777);
|
||||
path += "/";
|
||||
|
||||
@@ -82,13 +81,12 @@ namespace ui
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string scanPath = util::getTitleDir(data::curUser, data::curData);
|
||||
fs::dirList list(scanPath);
|
||||
fs::dirList list(data::curData.getPath());
|
||||
|
||||
std::string folderName = list.getItem(folderMenu.getSelected() - 1);
|
||||
if(confirm("Are you sure you want to overwrite \"" + folderName + "\"?", true))
|
||||
{
|
||||
std::string toPath = util::getTitleDir(data::curUser, data::curData) + folderName + "/";
|
||||
std::string toPath = data::curData.getPath() + folderName + "/";
|
||||
//Delete and recreate
|
||||
fs::delDir(toPath);
|
||||
mkdir(toPath.c_str(), 777);
|
||||
@@ -102,16 +100,15 @@ namespace ui
|
||||
else if(down & KEY_Y || fldNav[1].getEvent() == BUTTON_RELEASED)
|
||||
{
|
||||
if(data::curData.getType() != FsSaveDataType_System && folderMenu.getSelected() > 0)
|
||||
{
|
||||
std::string scanPath = util::getTitleDir(data::curUser, data::curData);
|
||||
fs::dirList list(scanPath);
|
||||
{;
|
||||
fs::dirList list(data::curData.getPath());
|
||||
|
||||
std::string folderName = list.getItem(folderMenu.getSelected() - 1);
|
||||
if(confirm("Are you sure you want to restore \"" + folderName + "\"?", true))
|
||||
{
|
||||
if(data::autoBack)
|
||||
{
|
||||
std::string autoFolder = util::getTitleDir(data::curUser, data::curData) + "/AUTO - " + data::curUser.getUsernameSafe() + " - " + util::getDateTime(util::DATE_FMT_YMD);
|
||||
std::string autoFolder = data::curData.getPath() + "/AUTO - " + data::curUser.getUsernameSafe() + " - " + util::getDateTime(util::DATE_FMT_YMD);
|
||||
mkdir(autoFolder.c_str(), 777);
|
||||
autoFolder += "/";
|
||||
|
||||
@@ -119,7 +116,7 @@ namespace ui
|
||||
fs::copyDirToDir(root, autoFolder);
|
||||
}
|
||||
|
||||
std::string fromPath = util::getTitleDir(data::curUser, data::curData) + folderName + "/";
|
||||
std::string fromPath = data::curData.getPath() + folderName + "/";
|
||||
std::string root = "sv:/";
|
||||
|
||||
fs::delDir(root);
|
||||
@@ -137,13 +134,12 @@ namespace ui
|
||||
{
|
||||
if(folderMenu.getSelected() > 0)
|
||||
{
|
||||
std::string scanPath = util::getTitleDir(data::curUser, data::curData);
|
||||
fs::dirList list(scanPath);
|
||||
fs::dirList list(data::curData.getPath());
|
||||
|
||||
std::string folderName = list.getItem(folderMenu.getSelected() - 1);
|
||||
if(confirm("Are you sure you want to delete \"" + folderName + "\"?", true))
|
||||
{
|
||||
std::string delPath = scanPath + folderName + "/";
|
||||
std::string delPath = data::curData.getPath() + folderName + "/";
|
||||
fs::delDir(delPath);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,11 +26,6 @@ static const std::string loadGlyphArray[] =
|
||||
|
||||
namespace ui
|
||||
{
|
||||
progBar::progBar(const uint64_t& _max)
|
||||
{
|
||||
max = _max;
|
||||
}
|
||||
|
||||
void progBar::update(const uint64_t& _prog)
|
||||
{
|
||||
prog = _prog;
|
||||
|
||||
@@ -91,9 +91,7 @@ namespace ui
|
||||
data::curData = data::curUser.titles[data::selData];
|
||||
if(fs::mountSave(data::curUser, data::curData))
|
||||
{
|
||||
util::makeTitleDir(data::curUser, data::curData);
|
||||
folderMenuPrepare(data::curUser, data::curData);
|
||||
|
||||
mstate = FLD_SEL;
|
||||
}
|
||||
}
|
||||
@@ -175,9 +173,7 @@ namespace ui
|
||||
data::curData = data::curUser.titles[data::selData];
|
||||
if(fs::mountSave(data::curUser, data::curData))
|
||||
{
|
||||
util::makeTitleDir(data::curUser, data::curData);
|
||||
folderMenuPrepare(data::curUser, data::curData);
|
||||
|
||||
//Wanna change this sometime
|
||||
ui::folderMenuInfo = util::getInfoString(data::curUser, data::curData);
|
||||
|
||||
@@ -185,9 +181,7 @@ namespace ui
|
||||
}
|
||||
}
|
||||
else if(down & KEY_Y || ttlNav[1].getEvent() == BUTTON_RELEASED)
|
||||
{
|
||||
fs::dumpAllUserSaves(data::curUser);
|
||||
}
|
||||
else if(down & KEY_X || ttlNav[2].getEvent() == BUTTON_RELEASED)
|
||||
{
|
||||
std::string confStr = "Are you 100% sure you want to add \"" + data::curUser.titles[data::selData].getTitle() + \
|
||||
|
||||
@@ -63,10 +63,9 @@ namespace ui
|
||||
folderMenu.setParams(466, 98, 730);
|
||||
folderMenu.reset();
|
||||
|
||||
util::makeTitleDir(usr, dat);
|
||||
std::string scanPath = util::getTitleDir(usr, dat);
|
||||
dat.createDir();
|
||||
|
||||
fs::dirList list(scanPath);
|
||||
fs::dirList list(dat.getPath());
|
||||
folderMenu.addOpt("New");
|
||||
for(unsigned i = 0; i < list.getCount(); i++)
|
||||
folderMenu.addOpt(list.getItem(i));
|
||||
@@ -111,9 +110,7 @@ namespace ui
|
||||
ui::mstate = EX_MNU;
|
||||
}
|
||||
else if(down & KEY_ZR)
|
||||
{
|
||||
ui::mstate = OPT_MNU;
|
||||
}
|
||||
}
|
||||
|
||||
void textTitleMenuUpdate(const uint64_t& down, const uint64_t& held, const touchPosition& p)
|
||||
@@ -130,9 +127,7 @@ namespace ui
|
||||
|
||||
if(fs::mountSave(data::curUser, data::curData))
|
||||
{
|
||||
util::makeTitleDir(data::curUser, data::curData);
|
||||
textFolderPrep(data::curUser, data::curData);
|
||||
|
||||
mstate = TXT_FLD;
|
||||
}
|
||||
}
|
||||
@@ -221,7 +216,7 @@ namespace ui
|
||||
}
|
||||
if(!folder.empty())
|
||||
{
|
||||
std::string path = util::getTitleDir(data::curUser, data::curData) + "/" + folder;
|
||||
std::string path = data::curData.getPath() + folder;
|
||||
mkdir(path.c_str(), 777);
|
||||
path += "/";
|
||||
|
||||
@@ -233,13 +228,12 @@ namespace ui
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string scanPath = util::getTitleDir(data::curUser, data::curData);
|
||||
fs::dirList list(scanPath);
|
||||
fs::dirList list(data::curData.getPath());
|
||||
|
||||
std::string folderName = list.getItem(folderMenu.getSelected() - 1);
|
||||
if(confirm("Are you sure you want to overwrite \"" + folderName + "\"?", true))
|
||||
{
|
||||
std::string toPath = util::getTitleDir(data::curUser, data::curData) + folderName + "/";
|
||||
std::string toPath = data::curData.getPath() + folderName + "/";
|
||||
//Delete and recreate
|
||||
fs::delDir(toPath);
|
||||
mkdir(toPath.c_str(), 777);
|
||||
@@ -254,15 +248,14 @@ namespace ui
|
||||
{
|
||||
if(data::curData.getType() != FsSaveDataType_System && folderMenu.getSelected() > 0)
|
||||
{
|
||||
std::string scanPath = util::getTitleDir(data::curUser, data::curData);
|
||||
fs::dirList list(scanPath);
|
||||
fs::dirList list(data::curData.getPath());
|
||||
|
||||
std::string folderName = list.getItem(folderMenu.getSelected() - 1);
|
||||
if(confirm("Are you sure you want to restore \"" + folderName + "\"?", true))
|
||||
{
|
||||
if(data::autoBack)
|
||||
{
|
||||
std::string autoFolder = util::getTitleDir(data::curUser, data::curData) + "/AUTO - " + data::curUser.getUsernameSafe() + " - " + util::getDateTime(util::DATE_FMT_YMD);
|
||||
std::string autoFolder = data::curData.getPath() + "/AUTO - " + data::curUser.getUsernameSafe() + " - " + util::getDateTime(util::DATE_FMT_YMD);
|
||||
mkdir(autoFolder.c_str(), 777);
|
||||
autoFolder += "/";
|
||||
|
||||
@@ -270,7 +263,7 @@ namespace ui
|
||||
fs::copyDirToDir(root, autoFolder);
|
||||
}
|
||||
|
||||
std::string fromPath = util::getTitleDir(data::curUser, data::curData) + folderName + "/";
|
||||
std::string fromPath = data::curData.getPath() + folderName + "/";
|
||||
std::string root = "sv:/";
|
||||
|
||||
fs::delDir(root);
|
||||
@@ -287,13 +280,12 @@ namespace ui
|
||||
{
|
||||
if(folderMenu.getSelected() > 0)
|
||||
{
|
||||
std::string scanPath = util::getTitleDir(data::curUser, data::curData);
|
||||
fs::dirList list(scanPath);
|
||||
fs::dirList list(data::curData.getPath());
|
||||
|
||||
std::string folderName = list.getItem(folderMenu.getSelected() - 1);
|
||||
if(confirm("Are you sure you want to delete \"" + folderName + "\"?", true))
|
||||
{
|
||||
std::string delPath = scanPath + folderName + "/";
|
||||
std::string delPath = data::curData.getPath() + folderName + "/";
|
||||
fs::delDir(delPath);
|
||||
}
|
||||
|
||||
|
||||
11
src/util.cpp
11
src/util.cpp
@@ -94,17 +94,6 @@ namespace util
|
||||
return std::string(ret);
|
||||
}
|
||||
|
||||
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(fs::getWorkDir() + t.getTitleSafe() + "/");
|
||||
}
|
||||
|
||||
void copyDirListToMenu(fs::dirList& d, ui::menu& m)
|
||||
{
|
||||
m.reset();
|
||||
|
||||
Reference in New Issue
Block a user