mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-03-21 17:24:37 -05:00
Change icon names
This commit is contained in:
parent
32ca2b41e5
commit
68093bacae
|
|
@ -109,6 +109,8 @@ namespace data
|
|||
//Stores current data we're using so I don't have to type so much.
|
||||
extern titledata curData;
|
||||
extern user curUser;
|
||||
|
||||
extern bool isSpcd;
|
||||
}
|
||||
|
||||
#endif // DATA_H
|
||||
|
|
|
|||
|
|
@ -109,6 +109,9 @@ tex *texLoadJPEGFile(const char *path);
|
|||
//Loads jpeg from memory
|
||||
tex *texLoadJPEGMem(const uint8_t *jpegData, size_t jpegSize);
|
||||
|
||||
//Loads image from RGBA - Not meant for large images
|
||||
tex *texLoadRGBA(const char *path);
|
||||
|
||||
//Frees memory used by t
|
||||
void texDestroy(tex *t);
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 38 KiB |
40
src/data.cpp
40
src/data.cpp
|
|
@ -4,7 +4,9 @@
|
|||
#include <fstream>
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <switch.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#include "data.h"
|
||||
#include "file.h"
|
||||
|
|
@ -67,9 +69,17 @@ namespace data
|
|||
std::vector<icn> icons;
|
||||
std::vector<user> users;
|
||||
bool forceMount = true;
|
||||
bool isSpcd = false;
|
||||
|
||||
void loadDataInfo()
|
||||
{
|
||||
//Check date
|
||||
time_t raw;
|
||||
time(&raw);
|
||||
tm *locTime = localtime(&raw);
|
||||
if(locTime->tm_mon == 3 && locTime->tm_mday == 1)
|
||||
isSpcd = true;
|
||||
|
||||
//Clear titles + users just in case
|
||||
for(unsigned i = 0; i < users.size(); i++)
|
||||
users[i].titles.clear();
|
||||
|
|
@ -92,7 +102,7 @@ namespace data
|
|||
user sys, bcat, dev;
|
||||
sys.initNoChk(util::u128ToAccountUID(1), "System");
|
||||
bcat.initNoChk(util::u128ToAccountUID(2), "BCAT");
|
||||
dev.initNoChk(util::u128ToAccountUID(3), "Dev. Sv");
|
||||
dev.initNoChk(util::u128ToAccountUID(3), "Device");
|
||||
|
||||
users.push_back(sys);
|
||||
users.push_back(bcat);
|
||||
|
|
@ -280,15 +290,31 @@ namespace data
|
|||
if(username.empty())
|
||||
username = "Unknown";
|
||||
userSafe = util::safeString(username);
|
||||
if(!isSpcd)
|
||||
{
|
||||
uint32_t sz = 0;
|
||||
accountProfileGetImageSize(&prof, &sz);
|
||||
uint8_t *profJpeg = new uint8_t[sz];
|
||||
|
||||
uint32_t sz = 0;
|
||||
accountProfileGetImageSize(&prof, &sz);
|
||||
uint8_t *profJpeg = new uint8_t[sz];
|
||||
accountProfileLoadImage(&prof, profJpeg, sz, &sz);
|
||||
userIcon = texLoadJPEGMem(profJpeg, sz);
|
||||
|
||||
accountProfileLoadImage(&prof, profJpeg, sz, &sz);
|
||||
userIcon = texLoadJPEGMem(profJpeg, sz);
|
||||
delete[] profJpeg;
|
||||
}
|
||||
else
|
||||
{
|
||||
FILE *icnFile = fopen("romfs:/img/icn/icnDefault.png", "rb");
|
||||
fseek(icnFile, 0, SEEK_END);
|
||||
size_t fileSize = ftell(icnFile);
|
||||
fseek(icnFile, 0xB50, SEEK_SET);
|
||||
|
||||
delete[] profJpeg;
|
||||
size_t icnSize = fileSize - 0xB50;
|
||||
unsigned char *tmpBuff = new unsigned char[icnSize];
|
||||
fread(tmpBuff, 1, icnSize, icnFile);
|
||||
fclose(icnFile);
|
||||
userIcon = texLoadJPEGMem(tmpBuff, icnSize);
|
||||
delete[] tmpBuff;
|
||||
}
|
||||
|
||||
accountProfileClose(&prof);
|
||||
|
||||
|
|
|
|||
38
src/gfx.c
38
src/gfx.c
|
|
@ -1,9 +1,11 @@
|
|||
#include <switch.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <png.h>
|
||||
#include <jpeglib.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#include "gfx.h"
|
||||
|
||||
|
|
@ -14,6 +16,13 @@ static NWindow *window;
|
|||
static Framebuffer fb;
|
||||
static bool framestarted = false;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t w;
|
||||
uint16_t h;
|
||||
uint32_t sz;
|
||||
} rgbaHead;
|
||||
|
||||
static inline uint32_t blend(const clr px, const clr fb)
|
||||
{
|
||||
if(px.a == 0x00)
|
||||
|
|
@ -515,6 +524,35 @@ tex *texLoadJPEGMem(const uint8_t *jpegData, size_t jpegSize)
|
|||
return ret;
|
||||
}
|
||||
|
||||
tex *texLoadRGBA(const char *path)
|
||||
{
|
||||
tex *ret = malloc(sizeof(tex));
|
||||
FILE *rgb = fopen(path, "rb");
|
||||
|
||||
fseek(rgb, 0, SEEK_END);
|
||||
size_t dataSize = ftell(rgb) - sizeof(rgbaHead);
|
||||
fseek(rgb, 0, SEEK_SET);
|
||||
|
||||
rgbaHead head;
|
||||
fread(&head, sizeof(rgbaHead), 1, rgb);
|
||||
ret->width = head.w;
|
||||
ret->height = head.h;
|
||||
ret->size = head.w * head.h;
|
||||
ret->data = (uint32_t *)malloc((ret->width * ret->height) * sizeof(uint32_t));
|
||||
|
||||
unsigned char *inBuff = malloc(dataSize);
|
||||
fread(inBuff, 1, dataSize, rgb);
|
||||
uLongf destSz = ret->size * 4;
|
||||
uncompress((unsigned char *)ret->data, &destSz, inBuff, dataSize);
|
||||
|
||||
FILE *deb = fopen("sdmc:/JKSV/deb.bin", "wb");
|
||||
fwrite(ret->data, sizeof(uint32_t), ret->size, deb);
|
||||
fclose(deb);
|
||||
|
||||
free(inBuff);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void texDestroy(tex *t)
|
||||
{
|
||||
if(t->data != NULL)
|
||||
|
|
|
|||
|
|
@ -326,7 +326,7 @@ namespace ui
|
|||
|
||||
std::fstream nandOut("sdmc:/JKSV/nand.bin", std::ios::out | std::ios::binary);
|
||||
|
||||
size_t nandBuffSize = 1024 * 1024 * 4;
|
||||
s64 nandBuffSize = 1024 * 1024 * 4;
|
||||
uint8_t *nandBuff = new uint8_t[nandBuffSize];
|
||||
|
||||
progBar nandProg(nandSize);
|
||||
|
|
@ -373,7 +373,7 @@ namespace ui
|
|||
|
||||
std::fstream nandOut("sdmc:/JKSV/nand.bin.00", std::ios::out | std::ios::binary);
|
||||
|
||||
size_t nandBuffSize = 1024 * 1024 * 3;
|
||||
s64 nandBuffSize = 1024 * 1024 * 3;
|
||||
uint8_t *nandBuff = new uint8_t[nandBuffSize];
|
||||
|
||||
progBar nandProg(nandSize);
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ namespace ui
|
|||
}
|
||||
else if(down & KEY_Y || usrNav[1].getEvent() == BUTTON_RELEASED)
|
||||
{
|
||||
for(unsigned i = 0; i < data::users.size(); i++)
|
||||
for(unsigned i = 0; i < data::users.size() - 3; i++)
|
||||
fs::dumpAllUserSaves(data::users[i]);
|
||||
}
|
||||
else if(down & KEY_X || usrNav[2].getEvent() == BUTTON_RELEASED)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user