Small update

This commit is contained in:
J-D-K 2018-06-23 16:16:37 -04:00
parent 22441f0e4f
commit 697ac050df
5 changed files with 76 additions and 12 deletions

View File

@ -2,6 +2,8 @@
JKSV for Switch. Mostly to get used to libnx. Reuses a lot of code of JKSM for 3DS.
![JKSV](https://dl.dropboxusercontent.com/s/g8wuu0qkzo8va8k/2018062316054200-DB1426D1DFD034027CECDE9C2DD914B8.jpg)
# Building:
1. Requires [devkitPro](https://devkitpro.org/) devkitA64
2. Requires switch-freetype

View File

@ -28,6 +28,9 @@ namespace fs
//Dumps all titles for 'user'
void dumpAllUserSaves(data::user& u);
//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
{

View File

@ -1,4 +1,5 @@
#include <fstream>
#include <cstdio>
#include <switch.h>
#include <dirent.h>
#include <unistd.h>
@ -271,4 +272,27 @@ namespace fs
}
}
}
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);
get.close();
//Probably add more later
char tmp[256];
std::sprintf(tmp, "Path: \"%s\"\nSize: %u", _path.c_str(), fileSize);
ret = tmp;
}
return ret;
}
}

View File

@ -241,14 +241,14 @@ namespace gfx
void drawRectangle(uint32_t x, uint32_t y, const uint32_t& width, const uint32_t& height, const uint32_t& clr)
{
uint32_t w, h, tX, tY;
uint32_t *frameBuffer = (uint32_t *)gfxGetFramebuffer(&w, &h);
uint32_t tX, tY;
uint32_t *frameBuffer = (uint32_t *)gfxGetFramebuffer(NULL, NULL);
for(tY = y; tY < y + height; tY++)
{
for(tX = x; tX < x + width; tX++)
{
frameBuffer[tY * w + tX] = clr;
frameBuffer[tY * frameBufWidth + tX] = clr;
}
}
}

View File

@ -84,6 +84,7 @@ namespace ui
copyMenu.addOpt("Delete");
copyMenu.addOpt("Rename");
copyMenu.addOpt("Make Dir");
copyMenu.addOpt("Properties");
copyMenu.addOpt("Back");
}
@ -648,8 +649,8 @@ namespace ui
saveMenu.print(16, 88, mnuTxt, 616);
sdMenu.print(648, 88, mnuTxt, 616);
gfx::drawText(savePath, 16, 668, 32, mnuTxt);
gfx::drawText(sdPath, 656, 668, 32, mnuTxt);
gfx::drawText(util::getWrappedString(savePath, 32, 600), 16, 652, 32, mnuTxt);
gfx::drawText(util::getWrappedString(sdPath, 32, 600), 656, 652, 32, mnuTxt);
break;
}
}
@ -733,7 +734,7 @@ namespace ui
break;
}
gfx::drawText(drawType, 16, 668, 32, 0xFFFFFFFF);
gfx::drawText(drawType, 16, 668, 32, mnuTxt);
}
}
@ -1074,9 +1075,43 @@ namespace ui
}
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())
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())
showMessage(props);
}
}
break;
}
}
break;
//back
case 4:
case 5:
advMenuCtrl = advPrev;
break;
@ -1203,21 +1238,21 @@ namespace ui
//draw copy menu if it's supposed to be up
if(advMenuCtrl == 2)
{
gfx::drawRectangle(462, 250, 324, 234, 0xFF2D2D2D);
gfx::drawRectangle(464, 252, 320, 230, 0xFFEBEBEB);
gfx::drawRectangle(462, 234, 324, 272, 0xFF2D2D2D);
gfx::drawRectangle(464, 236, 320, 268, 0xFFEBEBEB);
switch(advPrev)
{
case 0:
gfx::drawText("SAVE", 472, 256, 32, 0xFF000000);
gfx::drawText("SAVE", 472, 242, 32, 0xFF000000);
break;
case 1:
gfx::drawText("SDMC", 472, 256, 32, 0xFF000000);
gfx::drawText("SDMC", 472, 242, 32, 0xFF000000);
break;
}
copyMenu.print(472, 294, 0xFF000000, 304);
copyMenu.print(472, 286, 0xFF000000, 304);
}
}