mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-04-25 16:15:11 -05:00
Add loading screen, fix some things.
This commit is contained in:
parent
69f3891d24
commit
7ba9cbb97a
5
Makefile
5
Makefile
|
|
@ -38,8 +38,9 @@ INCLUDES := inc
|
|||
EXEFS_SRC := exefs_src
|
||||
APP_TITLE := JKSV
|
||||
APP_AUTHOR := JK
|
||||
APP_VERSION := 05.15.2020
|
||||
APP_VERSION := 05.19.2020
|
||||
ROMFS := romfs
|
||||
ICON := romfs/icon.jpg
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
|
|
@ -51,7 +52,7 @@ override CFLAGS += -g -Wall -O2 -ffunction-sections \
|
|||
|
||||
override CFLAGS += $(INCLUDE) -D__SWITCH__ `freetype-config --cflags`
|
||||
|
||||
CXXFLAGS:= $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
CXXFLAGS:= $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ namespace fs
|
|||
//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);
|
||||
|
||||
//deletes file
|
||||
void delfile(const std::string& path);
|
||||
//Recursively deletes 'path'
|
||||
void delDir(const std::string& path);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ typedef struct
|
|||
s64 offset, fsize;
|
||||
} FSFILE;
|
||||
|
||||
int fsremove(const char *_p);
|
||||
Result fsDelDirRec(const char *_p);
|
||||
|
||||
/*Opens file. Device is fetched from path. Libnx romfs doesn't work with this.
|
||||
Mode needs to be:
|
||||
FsOpenMode_Read
|
||||
|
|
|
|||
9
inc/ui.h
9
inc/ui.h
|
|
@ -41,9 +41,9 @@ namespace ui
|
|||
extern std::string folderMenuInfo;
|
||||
|
||||
//Strings since translation support soonish
|
||||
extern std::string userHelp, titleHelp, folderHelp, optHelp;
|
||||
extern std::string confBlackList, confOverwrite, confRestore, confDel, confCopy;
|
||||
extern std::string confEraseNand, confEraseFolder;
|
||||
extern std::string userHelp, titleHelp, folderHelp, optHelp, \
|
||||
confBlackList, confOverwrite, confRestore, confDel, confCopy, \
|
||||
confEraseNand, confEraseFolder, yt, nt;
|
||||
|
||||
/*Colors
|
||||
clearClr = color to clear buffer
|
||||
|
|
@ -70,6 +70,9 @@ namespace ui
|
|||
void init();
|
||||
void exit();
|
||||
|
||||
//Just draws a screen and flips JIC boot takes long.
|
||||
void showLoadScreen();
|
||||
|
||||
//Clears and draws general stuff used by multiple screens
|
||||
void drawUI();
|
||||
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
|
@ -18,6 +18,10 @@ NULL
|
|||
#Options Menu
|
||||
[A] Toggle [B] Back
|
||||
|
||||
#Button prompts.
|
||||
Yes [A]
|
||||
No [B]
|
||||
|
||||
#Strings for messages/confirmation. '*' and '#' are used in strings to change color. %s is replaced with titles and names.
|
||||
#Confirm blacklist.
|
||||
Are you sure you want to add #%s# to your blacklist?
|
||||
|
|
|
|||
11
src/file.cpp
11
src/file.cpp
|
|
@ -219,7 +219,7 @@ namespace fs
|
|||
switch(open.getType())
|
||||
{
|
||||
case FsSaveDataType_System:
|
||||
svOpen = fsOpen_SystemSaveData(&sv, FsSaveDataSpaceId_System, open.getID(), usr.getUID128() == 1 ? (AccountUid){ 0 } : usr.getUID());
|
||||
svOpen = fsOpen_SystemSaveData(&sv, FsSaveDataSpaceId_System, open.getID(), usr.getUID128() == 1 ? (AccountUid) { 0 } : usr.getUID());
|
||||
break;
|
||||
|
||||
case FsSaveDataType_Account:
|
||||
|
|
@ -441,6 +441,14 @@ namespace fs
|
|||
}
|
||||
}
|
||||
|
||||
void delfile(const std::string& path)
|
||||
{
|
||||
if(data::directFsCmd)
|
||||
fsremove(path.c_str());
|
||||
else
|
||||
remove(path.c_str());
|
||||
}
|
||||
|
||||
void delDir(const std::string& path)
|
||||
{
|
||||
dirList list(path);
|
||||
|
|
@ -460,7 +468,6 @@ namespace fs
|
|||
std::remove(delPath.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
rmdir(path.c_str());
|
||||
}
|
||||
|
||||
|
|
|
|||
27
src/fsfile.c
27
src/fsfile.c
|
|
@ -31,6 +31,27 @@ static char *getFilePath(char *pathOut, size_t _max, const char *path)
|
|||
return pathOut;
|
||||
}
|
||||
|
||||
int fsremove(const char *_p)
|
||||
{
|
||||
char devStr[16];
|
||||
char path[FS_MAX_PATH];
|
||||
if(!getDeviceFromPath(devStr, 16, _p) || !getFilePath(path, FS_MAX_PATH, _p))
|
||||
return -1;
|
||||
|
||||
Result res = fsFsDeleteFile(fsdevGetDeviceFileSystem(devStr), path);
|
||||
return res;
|
||||
}
|
||||
|
||||
Result fsDelDirRec(const char *_p)
|
||||
{
|
||||
char devStr[16];
|
||||
char path[FS_MAX_PATH];
|
||||
if(!getDeviceFromPath(devStr, 16, _p) || ! getFilePath(path, FS_MAX_PATH, _p))
|
||||
return 1;
|
||||
|
||||
return fsFsDeleteDirectoryRecursively(fsdevGetDeviceFileSystem(devStr), path);
|
||||
}
|
||||
|
||||
FSFILE *fsfopen(const char *_p, uint32_t mode)
|
||||
{
|
||||
char devStr[16];
|
||||
|
|
@ -121,6 +142,12 @@ size_t fsftell(FSFILE *_f)
|
|||
size_t fsfwrite(const void *buf, size_t sz, size_t count, FSFILE *_f)
|
||||
{
|
||||
size_t fullSize = sz * count;
|
||||
if(_f->offset + fullSize > _f->fsize)
|
||||
{
|
||||
s64 newSize = (_f->fsize + fullSize) - (_f->fsize - _f->offset);
|
||||
fsFileSetSize(&_f->_f, newSize);
|
||||
_f->fsize = newSize;
|
||||
}
|
||||
_f->error = fsFileWrite(&_f->_f, _f->offset, buf, fullSize, FsWriteOption_Flush);
|
||||
_f->offset += fullSize;
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ int main(int argc, const char *argv[])
|
|||
fs::init();
|
||||
graphicsInit(1280, 720);
|
||||
ui::initTheme();
|
||||
ui::showLoadScreen();
|
||||
data::init();
|
||||
ui::init();
|
||||
//Reset cpu
|
||||
|
|
|
|||
29
src/ui.cpp
29
src/ui.cpp
|
|
@ -17,9 +17,9 @@
|
|||
static tex *top, *bot, *usrGuide, *ttlGuide, *fldrGuide, *optGuide;
|
||||
|
||||
//Ui text strings
|
||||
std::string author, ui::userHelp, ui::titleHelp, ui::folderHelp, ui::optHelp;
|
||||
std::string ui::confBlackList, ui::confOverwrite, ui::confRestore, ui::confDel, ui::confCopy;
|
||||
std::string ui::confEraseNand, ui::confEraseFolder;
|
||||
std::string author, ui::userHelp, ui::titleHelp, ui::folderHelp, ui::optHelp, \
|
||||
ui::confBlackList, ui::confOverwrite, ui::confRestore, ui::confDel, ui::confCopy, \
|
||||
ui::confEraseNand, ui::confEraseFolder, ui::yt, ui::nt;
|
||||
|
||||
//X position of help texts. Calculated to make editing quicker/easier
|
||||
static unsigned userHelpX, titleHelpX, folderHelpX, optHelpX;
|
||||
|
|
@ -49,6 +49,8 @@ static void loadTrans()
|
|||
ui::titleHelp = lang.getNextLine();
|
||||
ui::folderHelp = lang.getNextLine();
|
||||
ui::optHelp = lang.getNextLine();
|
||||
ui::yt = lang.getNextLine();
|
||||
ui::nt = lang.getNextLine();
|
||||
ui::confBlackList = lang.getNextLine();
|
||||
ui::confOverwrite = lang.getNextLine();
|
||||
ui::confRestore = lang.getNextLine();
|
||||
|
|
@ -190,10 +192,12 @@ namespace ui
|
|||
drawTextbox(diaBox, 0, 0, 640, 420);
|
||||
drawRect(diaBox, 0, 56, 640, 2, ui::thmID == ColorSetId_Light ? clrCreateU32(0xFF6D6D6D) : clrCreateU32(0xFFCCCCCC));
|
||||
|
||||
util::replaceButtonsInString(userHelp);
|
||||
util::replaceButtonsInString(titleHelp);
|
||||
util::replaceButtonsInString(folderHelp);
|
||||
util::replaceButtonsInString(optHelp);
|
||||
util::replaceButtonsInString(ui::userHelp);
|
||||
util::replaceButtonsInString(ui::titleHelp);
|
||||
util::replaceButtonsInString(ui::folderHelp);
|
||||
util::replaceButtonsInString(ui::optHelp);
|
||||
util::replaceButtonsInString(ui::yt);
|
||||
util::replaceButtonsInString(ui::nt);
|
||||
|
||||
//Create graphics to hold guides
|
||||
usrGuide = texCreate(textGetWidth(userHelp.c_str(), ui::shared, 18), 28);
|
||||
|
|
@ -250,6 +254,17 @@ namespace ui
|
|||
fontDestroy(shared);
|
||||
}
|
||||
|
||||
void showLoadScreen()
|
||||
{
|
||||
tex *icn = texLoadJPEGFile("romfs:/icon.jpg");
|
||||
gfxBeginFrame();
|
||||
texClearColor(frameBuffer, clrCreateU32(0xFF2D2D2D));
|
||||
texDrawNoAlpha(icn, frameBuffer, 512, 232);
|
||||
drawText("Loading...", frameBuffer, ui::shared, 1100, 673, 16, clrCreateU32(0xFFFFFFFF));
|
||||
gfxEndFrame();
|
||||
texDestroy(icn);
|
||||
}
|
||||
|
||||
void drawUI()
|
||||
{
|
||||
texClearColor(frameBuffer, clearClr);
|
||||
|
|
|
|||
|
|
@ -287,9 +287,7 @@ void performCopyMenuOps()
|
|||
fullPath += "/";
|
||||
|
||||
fs::getDirProps(fullPath, dirCnt, fileCnt, fileSize);
|
||||
char mess[256];
|
||||
sprintf(mess, "#%s#:\n%u Folders\n%u Files\nTotal Size: %.2fMB", fullPath.c_str(), dirCnt, fileCnt, (float)((float)fileSize / 1024 / 1024));
|
||||
ui::showMessage("Folder Properties", mess);
|
||||
ui::showMessage("Folder Properties", "#%s#:\n%u Folders\n%u Files\nTotal Size: %.2fMB", fullPath.c_str(), dirCnt, fileCnt, (float)((float)fileSize / 1024.0f / 1024.0f));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -314,9 +312,7 @@ void performCopyMenuOps()
|
|||
fullPath += "/";
|
||||
|
||||
fs::getDirProps(fullPath, dirCnt, fileCnt, fileSize);
|
||||
char mess[256];
|
||||
sprintf(mess, "#%s#:\n%u Folders\n%u Files\nTotal Size: %.2fMB", fullPath.c_str(), dirCnt, fileCnt, (float)((float)fileSize / 1024 / 1024));
|
||||
ui::showMessage(mess, "Folder Props");
|
||||
ui::showMessage("Folder Properties", "#%s#:\n%u Folders\n%u Files\nTotal Size: %.2fMB", fullPath.c_str(), dirCnt, fileCnt, (float)((float)fileSize / 1024.0f / 1024.0f));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
static bool popDraw = false;
|
||||
static std::string popText;
|
||||
static const char *yt = "Yes \ue0e0", *nt = "No \ue0e1", *okt = "OK \ue0e0";
|
||||
static const char *okt = "OK \ue0e0";
|
||||
static unsigned popY, popX, popWidth, popState, frameCount, frameHold;
|
||||
|
||||
enum popStates
|
||||
|
|
@ -56,7 +56,7 @@ namespace ui
|
|||
//fake focus
|
||||
drawRectAlpha(frameBuffer, 0, 0, 1280, 720, clrCreateU32(0xAA0D0D0D));
|
||||
|
||||
char tmp[512];
|
||||
char tmp[1024];
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vsprintf(tmp, fmt, args);
|
||||
|
|
@ -87,7 +87,7 @@ namespace ui
|
|||
//fake focus
|
||||
drawRectAlpha(frameBuffer, 0, 0, 1280, 720, clrCreateU32(0xAA0D0D0D));
|
||||
|
||||
char tmp[512];
|
||||
char tmp[1024];
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vsprintf(tmp, fmt, args);
|
||||
|
|
@ -98,8 +98,8 @@ namespace ui
|
|||
clr holdClr = ui::txtDiag;
|
||||
|
||||
unsigned headX = (640 / 2) - (textGetWidth("Confirm", ui::shared, 20) / 2);
|
||||
unsigned yesX = 160 - (textGetWidth(yt, ui::shared, 20) / 2);
|
||||
unsigned noX = 160 - (textGetWidth(nt, ui::shared, 20) / 2);
|
||||
unsigned yesX = 160 - (textGetWidth(ui::yt.c_str(), ui::shared, 20) / 2);
|
||||
unsigned noX = 160 - (textGetWidth(ui::nt.c_str(), ui::shared, 20) / 2);
|
||||
|
||||
std::string yesText = yt;
|
||||
|
||||
|
|
@ -142,8 +142,8 @@ namespace ui
|
|||
//Reset everything
|
||||
heldDown= false;
|
||||
holdCount = 0, loadFrame = 0, holdClrDiff = 0;
|
||||
yesX = 160 - (textGetWidth(yt, ui::shared, 20) / 2);
|
||||
yesText = yt;
|
||||
yesX = 160 - (textGetWidth(ui::yt.c_str(), ui::shared, 20) / 2);
|
||||
yesText = ui::yt;
|
||||
holdClr = ui::txtDiag;
|
||||
}
|
||||
else if(down & KEY_A)
|
||||
|
|
@ -169,11 +169,10 @@ namespace ui
|
|||
texDraw(diaBox, frameBuffer, 320, 150);
|
||||
drawText("Confirm", frameBuffer, ui::shared, 320 + headX, 168, 20, ui::txtDiag);
|
||||
drawText(yesText.c_str(), frameBuffer, ui::shared, 320 + yesX, 530, 20, holdClr);
|
||||
drawText(nt, frameBuffer, ui::shared, 860 - noX, 530, 20, ui::txtDiag);
|
||||
drawText(ui::nt.c_str(), frameBuffer, ui::shared, 860 - noX, 530, 20, ui::txtDiag);
|
||||
drawTextWrap(tmp, frameBuffer, ui::shared, 352, 230, 16, ui::txtDiag, 576);
|
||||
gfxEndFrame();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user