From 697ac050dfda2e8e31b87d0187bf78e40513a821 Mon Sep 17 00:00:00 2001 From: J-D-K Date: Sat, 23 Jun 2018 16:16:37 -0400 Subject: [PATCH] Small update --- README.MD | 2 ++ inc/file.h | 3 +++ src/file.cpp | 24 ++++++++++++++++++++++++ src/gfx.cpp | 6 +++--- src/ui.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++--------- 5 files changed, 76 insertions(+), 12 deletions(-) diff --git a/README.MD b/README.MD index 4c760fc..844becc 100644 --- a/README.MD +++ b/README.MD @@ -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 diff --git a/inc/file.h b/inc/file.h index 2f0eba4..3a384f7 100644 --- a/inc/file.h +++ b/inc/file.h @@ -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 { diff --git a/src/file.cpp b/src/file.cpp index 2029f87..208ffa9 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -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; + } } diff --git a/src/gfx.cpp b/src/gfx.cpp index f99a8db..0daecbc 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -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; } } } diff --git a/src/ui.cpp b/src/ui.cpp index 4c4b96a..39eef63 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -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); } }