This commit is contained in:
J-D-K 2018-06-15 20:40:22 -04:00
parent 147f29c14e
commit cdc621fe4f
9 changed files with 64 additions and 81 deletions

View File

@ -38,7 +38,7 @@ INCLUDES := inc
EXEFS_SRC := exefs_src
APP_TITLE := JKSV
APP_AUTHOR := JK_
APP_VERSION := 06/14/2018
APP_VERSION := 06/15/2018
ROMFS := romfs
#---------------------------------------------------------------------------------

View File

@ -56,13 +56,14 @@ namespace data
//Returns username
std::string getUsername();
std::string getUsernameSafe();
//Vector for storing save data info for user
std::vector<titledata> titles;
private:
u128 userID;
std::string username;
std::string username, userSafe;
};
//User vector

View File

@ -1,15 +1,13 @@
#include <stdio.h>
#include <switch.h>
#include <vector>
#include <string>
#include <cstring>
#include <fstream>
#include <algorithm>
#include <cstdio>
#include <switch.h>
#include "data.h"
#include "sys.h"
#include "gfx.h"
#include "file.h"
static const char verboten[] = { '.', ',', '/', '\\', '<', '>', ':', '"', '|', '?', '*'};
@ -251,6 +249,7 @@ namespace data
username.assign(base.username);
if(username.empty())
username = "Unknown";
userSafe = safeString(username);
accountProfileClose(&prof);
@ -274,10 +273,14 @@ namespace data
if(R_SUCCEEDED(res))
{
username.assign(base.username);
userSafe = safeString(username);
accountProfileClose(&prof);
}
else
{
username = "Unknown";
userSafe = "Unknown";
}
return true;
}
@ -291,4 +294,9 @@ namespace data
{
return username;
}
std::string user::getUsernameSafe()
{
return userSafe;
}
}

View File

@ -4,11 +4,10 @@
#include <unistd.h>
#include "file.h"
#include "data.h"
#include "gfx.h"
#include "ui.h"
#include "util.h"
#include "sys.h"
#include "ui.h"
#include "gfx.h"
#define BUFF_SIZE 512 * 1024
@ -108,13 +107,6 @@ namespace fs
copyString = util::getWrappedString(copyString, 64, 1136);
for(unsigned i = 0; i < fileSize; )
{
hidScanInput();
uint64_t held = hidKeysHeld(CONTROLLER_P1_AUTO);
if(held & KEY_B)
break;
f.read((char *)buff, BUFF_SIZE);
t.write((char *)buff, f.gcount());
@ -148,13 +140,6 @@ namespace fs
copyString = util::getWrappedString(copyString, 64, 1136);
for(unsigned i = 0; i < fileSize; )
{
hidScanInput();
uint64_t held = hidKeysHeld(CONTROLLER_P1_AUTO);
if(held & KEY_B)
break;
f.read((char *)buff, BUFF_SIZE);
t.write((char *)buff, f.gcount());

View File

@ -1,11 +1,9 @@
#include <string>
#include <cstring>
#include <fstream>
#include <stdio.h>
#include <cstdio>
#include <switch.h>
#include <malloc.h>
#include <ft2build.h>
#include FT_FREETYPE_H

View File

@ -1,15 +1,11 @@
#include <string>
#include <vector>
#include <fstream>
#include <unistd.h>
#include <sys/stat.h>
#include <switch.h>
#include "gfx.h"
#include "sys.h"
#include "data.h"
#include "file.h"
#include "util.h"
#include "ui.h"
int main(int argc, const char *argv[])
@ -41,7 +37,7 @@ int main(int argc, const char *argv[])
break;
gfx::clearBufferColor(0x3B3B3BFF);
gfx::drawText("JKSV - 6/14/2018", 16, 16, 64, 0xFFFFFFFF);
gfx::drawText("JKSV - 6/15/2018", 16, 16, 64, 0xFFFFFFFF);
gfx::drawRectangle(16, 64, 1248, 1, 0xFFFFFFFF);
gfx::drawRectangle(448, 64, 1, 592, 0xFFFFFFFF);
gfx::drawRectangle(16, 656, 1248, 1, 0xFFFFFFFF);

View File

@ -4,7 +4,6 @@
#include <unistd.h>
#include "sys.h"
#include "ui.h"
static std::fstream deb;

View File

@ -1,8 +1,7 @@
#include <string>
#include <vector>
#include <fstream>
#include <stdio.h>
#include <cstdio>
#include <switch.h>
#include "ui.h"
@ -328,7 +327,6 @@ namespace ui
clrAdd = true;
}
drawMenus();
gfx::drawRectangle(0, 176, 1280, 64, 0xFFFFFFFF);
gfx::drawRectangle(0, 240, 1280, 480, 0x3B3B3BFF);
@ -523,16 +521,45 @@ namespace ui
switch(mstate)
{
case USR_SEL:
userMenu.print(16, 88, 424);
{
//Menu
userMenu.print(16, 88, 424);
//Input guide
unsigned startX = 1152;
buttonA.draw(startX, 672);
gfx::drawText("Select", startX += 38, 668, 32, 0xFFFFFFFF);
}
break;
case TTL_SEL:
titleMenu.print(16, 88, 424);
{
//Menu
titleMenu.print(16, 88, 424);
//Input guide
unsigned startX = 1056;
buttonA.draw(startX, 672);
gfx::drawText("Select", startX += 38, 668, 32, 0xFFFFFFFF);
buttonB.draw(startX += 72, 672);
gfx::drawText("Back", startX += 38, 668, 32, 0xFFFFFFFF);
}
break;
case FLD_SEL:
titleMenu.print(16, 88, 424);
folderMenu.print(458, 88, 806);
{
//Menus
titleMenu.print(16, 88, 424);
folderMenu.print(458, 88, 806);
//Input guide
unsigned startX = 836;
buttonA.draw(startX, 672);
gfx::drawText("Backup", startX += 38, 668, 32, 0xFFFFFFFF);
buttonY.draw(startX += 72, 672);
gfx::drawText("Restore", startX += 38, 668, 32, 0xFFFFFFFF);
buttonX.draw(startX += 72, 672);
gfx::drawText("Delete", startX += 38, 668, 32, 0xFFFFFFFF);
buttonB.draw(startX += 72, 672);
gfx::drawText("Back", startX += 38, 668, 32, 0xFFFFFFFF);
}
break;
}
}
@ -541,6 +568,8 @@ namespace ui
{
userMenu.handleInput(down, held);
drawMenus();
if(down & KEY_A)
{
data::curUser = data::users[userMenu.getSelected()];
@ -555,19 +584,14 @@ namespace ui
devMenuPrepare();
mstate = DEV_MNU;
}
drawMenus();
//I'm too lazy to add width calculation right now.
unsigned startX = 1152;
buttonA.draw(startX, 672);
gfx::drawText("Select", startX += 38, 668, 32, 0xFFFFFFFF);
}
void showTitleMenu(const uint64_t& down, const uint64_t& held)
{
titleMenu.handleInput(down, held);
drawMenus();
if(down & KEY_A)
{
data::curData = data::curUser.titles[titleMenu.getSelected()];
@ -584,10 +608,6 @@ namespace ui
else if(down & KEY_B)
mstate = USR_SEL;
drawMenus();
unsigned startX = 1056;
if(sys::sysSave)
{
std::string drawType = "Type: ";
@ -620,17 +640,14 @@ namespace ui
gfx::drawText(drawType, 16, 668, 32, 0xFFFFFFFF);
}
buttonA.draw(startX, 672);
gfx::drawText("Select", startX += 38, 668, 32, 0xFFFFFFFF);
buttonB.draw(startX += 72, 672);
gfx::drawText("Back", startX += 38, 668, 32, 0xFFFFFFFF);
}
void showFolderMenu(const uint64_t& down, const uint64_t& held)
{
folderMenu.handleInput(down, held);
drawMenus();
if(down & KEY_A)
{
if(folderMenu.getSelected() == 0)
@ -710,22 +727,6 @@ namespace ui
fsdevUnmountDevice("sv");
mstate = TTL_SEL;
}
drawMenus();
unsigned startX = 836;
buttonA.draw(startX, 672);
gfx::drawText("Backup", startX += 38, 668, 32, 0xFFFFFFFF);
buttonY.draw(startX += 72, 672);
gfx::drawText("Restore", startX += 38, 668, 32, 0xFFFFFFFF);
buttonX.draw(startX += 72, 672);
gfx::drawText("Delete", startX += 38, 668, 32, 0xFFFFFFFF);
buttonB.draw(startX += 72, 672);
gfx::drawText("Back", startX += 38, 668, 32, 0xFFFFFFFF);
}
void showDevMenu(const uint64_t& down, const uint64_t& held)
@ -810,8 +811,6 @@ namespace ui
if(down & KEY_A || down & KEY_B || ok.released(p))
break;
drawMenus();
gfx::drawRectangle(256, 128, 768, 464, 0xC0C0C0FF);
gfx::drawText(mess, 272, 144, 48, 0x000000FF);
ok.draw();
@ -871,8 +870,6 @@ namespace ui
break;
}
drawMenus();
gfx::drawRectangle(256, 128, 768, 464, 0xC0C0C0FF);
gfx::drawText(mess, 272, 144, 48, 0x000000FF);
yes.draw();

View File

@ -1,11 +1,10 @@
#include <string>
#include <stdio.h>
#include <time.h>
#include <cstdio>
#include <ctime>
#include <sys/stat.h>
#include "data.h"
#include "gfx.h"
#include "ui.h"
namespace util
{
@ -24,18 +23,18 @@ namespace util
void makeUserDir(data::user& u)
{
mkdir(u.getUsername().c_str(), 0777);
mkdir(u.getUsernameSafe().c_str(), 0777);
}
void makeTitleDir(data::user& u, data::titledata& t)
{
std::string path = u.getUsername() + "/" + t.getTitleSafe();
std::string path = u.getUsernameSafe() + "/" + t.getTitleSafe();
mkdir(path.c_str(), 777);
}
std::string getTitleDir(data::user& u, data::titledata& t)
{
return std::string(u.getUsername() + "/" + t.getTitleSafe() + "/");
return std::string(u.getUsernameSafe() + "/" + t.getTitleSafe() + "/");
}
std::string getWrappedString(const std::string& s, const unsigned& sz, const unsigned& maxWidth)