Minor stuff

This commit is contained in:
J-D-K
2018-08-23 23:15:53 -04:00
parent 6572e49e91
commit 2ab16b9e04
12 changed files with 66 additions and 52 deletions

View File

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

View File

@@ -10,7 +10,7 @@
namespace data
{
extern bool sysSave;
extern bool sysSave, forceMount;
//Loads user + title info
void loadDataInfo();
@@ -97,7 +97,7 @@ namespace data
std::string username, userSafe;
};
//Adds title to blacklist
void blacklistAdd(titledata& t);
void blacklistAdd(user& u, titledata& t);
//User vector
extern std::vector<user> users;

View File

@@ -63,7 +63,7 @@ namespace data
user curUser;
std::vector<icn> icons;
std::vector<user> users;
bool sysSave = false;
bool sysSave = false, forceMount = true;
void loadDataInfo()
{
@@ -109,7 +109,7 @@ namespace data
u = getUserIndex(info.userID);
titledata newData;
if(newData.init(info) && newData.isMountable(newUser.getUID()))
if(newData.init(info) && (newData.isMountable(newUser.getUID()) || !forceMount))
{
users[u].titles.push_back(newData);
}
@@ -118,7 +118,7 @@ namespace data
else
{
titledata newData;
if(newData.init(info) && newData.isMountable(users[u].getUID()))
if(newData.init(info) && (newData.isMountable(users[u].getUID()) || !forceMount))
{
users[u].titles.push_back(newData);
}
@@ -347,10 +347,11 @@ namespace data
blacklist.push_back(pushID);
}
bl.close();
}
}
void blacklistAdd(titledata& t)
void blacklistAdd(user& u, titledata& t)
{
std::fstream bl(fs::getWorkDir() + "blacklist.txt", std::ios::app);
@@ -371,5 +372,8 @@ namespace data
users[i].titles.erase(users[i].titles.begin() + j);
}
}
int uInd = getUserIndex(u.getUID());
u = users[uInd];
}
}

View File

@@ -60,9 +60,7 @@ namespace fs
d = opendir(path.c_str());
while((ent = readdir(d)))
{
item.push_back(ent->d_name);
}
closedir(d);
}
@@ -76,9 +74,7 @@ namespace fs
item.clear();
while((ent = readdir(d)))
{
item.push_back(ent->d_name);
}
closedir(d);
}
@@ -89,9 +85,7 @@ namespace fs
d = opendir(path.c_str());
while((ent = readdir(d)))
{
item.push_back(ent->d_name);
}
closedir(d);
}
@@ -105,11 +99,8 @@ namespace fs
{
std::string fullPath = path + item[index];
struct stat s;
if(stat(fullPath.c_str(), &s) == 0)
{
if(S_ISDIR(s.st_mode))
return true;
}
if(stat(fullPath.c_str(), &s) == 0 && S_ISDIR(s.st_mode))
return true;
return false;
}

View File

@@ -110,18 +110,18 @@ static inline void resizeFont(const font *f, int sz)
}
}
static inline FT_GlyphSlot loadGlyph(const uint32_t c, const font *f)
static inline FT_GlyphSlot loadGlyph(const uint32_t c, const font *f, FT_Int32 flags)
{
if(f->external)
{
FT_Load_Glyph(f->face[0], FT_Get_Char_Index(f->face[0], c), FT_LOAD_RENDER);
FT_Load_Glyph(f->face[0], FT_Get_Char_Index(f->face[0], c), flags);
return f->face[0]->glyph;
}
for(int i = 0; i < 6; i++)
{
FT_UInt cInd = 0;
if( (cInd = FT_Get_Char_Index(f->face[i], c)) != 0 && \
FT_Load_Glyph(f->face[i], cInd, FT_LOAD_RENDER) == 0)
FT_Load_Glyph(f->face[i], cInd, flags) == 0)
{
return f->face[i]->glyph;
}
@@ -153,7 +153,7 @@ void drawText(const char *str, tex *target, const font *f, int x, int y, int sz,
continue;
}
FT_GlyphSlot slot = loadGlyph(tmpChr, f);
FT_GlyphSlot slot = loadGlyph(tmpChr, f, FT_LOAD_RENDER);
if(slot != NULL)
{
int drawY = y + (sz - slot->bitmap_top);
@@ -174,29 +174,44 @@ void drawTextWrap(const char *str, tex *target, const font *f, int x, int y, int
{
nextbreak = strcspn(&str[i], " /");
if(nextbreak == strLength)
memset(wordBuf, 0, 128);
memcpy(wordBuf, &str[i], nextbreak + 1);
size_t width = textGetWidth(wordBuf, f, sz);
if(tmpX + width >= x + maxWidth)
{
drawText(&str[i], target, f, tmpX, y, sz, c);
break;
tmpX = x;
y += sz + 8;
}
else
size_t wLength = strlen(wordBuf);
uint32_t tmpChr = 0;
for(unsigned j = 0; j < wLength; )
{
memset(wordBuf, 0, 128);
memcpy(wordBuf, &str[i], nextbreak + 1);
ssize_t unitCnt = decode_utf8(&tmpChr, (const uint8_t *)&wordBuf[j]);
if(unitCnt <= 0)
break;
size_t width = textGetWidth(wordBuf, f, sz);
if(tmpX + width >= x + maxWidth)
j += unitCnt;
if(tmpChr == '\n')
{
tmpX = x;
y += sz + 8;
continue;
}
drawText(wordBuf, target, f, tmpX, y, sz, c);
tmpX += width;
FT_GlyphSlot slot = loadGlyph(tmpChr, f, FT_LOAD_RENDER);
if(slot != NULL)
{
int drawY = y + (sz - slot->bitmap_top);
drawGlyph(&slot->bitmap, target, tmpX + slot->bitmap_left, drawY, c);
i += strlen(wordBuf);
tmpX += slot->advance.x >> 6;
}
}
i += strlen(wordBuf);
}
}
@@ -217,7 +232,7 @@ size_t textGetWidth(const char *str, const font *f, int sz)
break;
i += untCnt;
FT_GlyphSlot slot = loadGlyph(tmpChr, f);
FT_GlyphSlot slot = loadGlyph(tmpChr, f, FT_LOAD_DEFAULT);
if(ret)
return 0;

View File

@@ -61,7 +61,7 @@ int main(int argc, const char *argv[])
//Just to be sure
fsdevUnmountDevice("sv");
data::sysSave = true;
data::sysSave = true, data::forceMount = false;
data::loadDataInfo();
//Kick back to user

View File

@@ -11,7 +11,7 @@
#include "util.h"
#include "file.h"
#define TITLE_TEXT "JKSV - 08/18/2018"
#define TITLE_TEXT "JKSV - 08/23/2018"
//background that can be drawn from "/JKSV/back.jpg"
static tex *background = NULL;

View File

@@ -107,7 +107,7 @@ namespace ui
std::string confStr = "Are you 100% sure you want to add \"" + data::curUser.titles[titleMenu.getSelected()].getTitle() + \
"\" to your blacklist?";
if(ui::confirm(confStr))
data::blacklistAdd(data::curUser.titles[titleMenu.getSelected()]);
data::blacklistAdd(data::curUser, data::curUser.titles[titleMenu.getSelected()]);
}
else if(down & KEY_B || ttlNav[3].getEvent() == BUTTON_RELEASED)
mstate = CLS_USR;

View File

@@ -15,6 +15,8 @@ namespace ui
rW = _rW;
rY = _y;
optButtons.clear();
for(unsigned i = 0; i < 15; i++)
{
//Init + push invisible options buttons

View File

@@ -27,10 +27,12 @@ namespace ui
drawRect(frameBuffer, 96, 400, 1088, 64, clrCreateU32(0xFF000000));
drawRect(frameBuffer, 96, 400, (unsigned)width, 64, clrCreateU32(0xFF00CC00));
//char tmp[64];
//sprintf(tmp, "%u / %u", (unsigned)prog, (unsigned)max);
drawTextWrap(text.c_str(), frameBuffer, ui::shared, 80, 256, 24, txtClr, 752);
//gfx::drawText(tmp, 80, 320, 64, 0x000000FF);
char tmp[128];
sprintf(tmp, "%u KB/%u KB", (unsigned)prog / 1024, (unsigned)max / 1024);
int szX = 640 - (textGetWidth(tmp, shared, 24) / 2);
drawTextWrap(text.c_str(), frameBuffer, ui::shared, 80, 256, 18, txtClr, 752);
drawText(tmp, frameBuffer, shared, szX, 416, 24, clrCreateU32(0xFFFFFFFF));
}
button::button(const std::string& _txt, unsigned _x, unsigned _y, unsigned _w, unsigned _h)

View File

@@ -214,7 +214,7 @@ namespace ui
std::string confStr = "Are you 100% sure you want to add \"" + data::curUser.titles[selected].getTitle() + \
"\" to your blacklist?";
if(ui::confirm(confStr))
data::blacklistAdd(data::curUser.titles[selected]);
data::blacklistAdd(data::curUser, data::curUser.titles[selected]);
}
else if(down & KEY_B || ttlNav[3].getEvent() == BUTTON_RELEASED)
{

View File

@@ -99,40 +99,40 @@ namespace util
std::string getInfoString(data::user& u, data::titledata& d)
{
std::string ret = d.getTitle();
std::string ret = d.getTitle() + "\n";
char id[18];
sprintf(id, " %016lX", d.getID());
ret += id;
ret += std::string(id) + "\n\n";
switch(d.getType())
{
case FsSaveDataType_SystemSaveData:
ret += " System Save";
ret += "System Save\n\n";
break;
case FsSaveDataType_SaveData:
ret += " Save Data";
ret += "Save Data\n\n";
break;
case FsSaveDataType_BcatDeliveryCacheStorage:
ret += " Bcat Delivery Cache";
ret += "Bcat Delivery Cache\n\n";
break;
case FsSaveDataType_DeviceSaveData:
ret += " Device Save";
ret += "Device Save\n\n";
break;
case FsSaveDataType_TemporaryStorage:
ret = " Temp Storage";
ret = "Temp Storage\n\n";
break;
case FsSaveDataType_CacheStorage:
ret+= " Cache Storage";
ret+= "Cache Storage\n\n";
break;
}
ret += "\n" + u.getUsername();
ret += u.getUsername();
return ret;
}