mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-12-23 10:21:55 +01:00
* For Themes - added alternate coordinates for widescreen-mode.
- Differ the coordinates between 16:9 and 4:3, can add a setting with a "w" as prefix (e.g. sdcard_coord = 163,395 for 4:3 and wsdcard_coord = 170,395 for 16:9). Isn't setted "w???._coord", the "normal"-coordinate is used for both modes. * added a new constructor for GuiImageData currebtly the constructor is unused, i will use later
This commit is contained in:
parent
812c37bf4a
commit
fc8f4c2c7a
@ -559,6 +559,7 @@ class GuiImageData
|
||||
//!\param i Image data
|
||||
GuiImageData(const u8 * i);
|
||||
GuiImageData(const char * imgPath, const u8 * buffer);
|
||||
GuiImageData(const char *path, const char *file, const u8 * buffer, bool force_widescreen=false, const u8 * wbuffer=NULL);
|
||||
//!Destructor
|
||||
~GuiImageData();
|
||||
//!Gets a pointer to the image data
|
||||
|
@ -153,6 +153,116 @@ GuiImageData::GuiImageData(const char * imgPath, const u8 * buffer)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for the GuiImageData class.
|
||||
*/
|
||||
GuiImageData::GuiImageData(const char *path, const char *file, const u8 *buffer, bool force_widescreen/*=false*/, const u8 *wbuffer/*=NULL*/)
|
||||
{
|
||||
data = NULL;
|
||||
width = 0;
|
||||
height = 0;
|
||||
char path_4_3[100];
|
||||
char path_16_9[100];
|
||||
char *imgPath;
|
||||
|
||||
snprintf(path_4_3, sizeof(path_4_3), "%s%s", path, file);
|
||||
if(force_widescreen)
|
||||
{
|
||||
snprintf(path_16_9, sizeof(path_16_9), "%sw%s", path, file);
|
||||
imgPath = path_16_9;
|
||||
if(wbuffer)
|
||||
buffer = wbuffer;
|
||||
}
|
||||
else
|
||||
imgPath = path_4_3;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
if(imgPath)
|
||||
{
|
||||
PNGUPROP imgProp;
|
||||
IMGCTX ctx = PNGU_SelectImageFromDevice(imgPath);
|
||||
//if (((4%imgProp.imgWidth)!=0)||((4%imgProp.imgHeight)!=0))idiotFlag=1;
|
||||
|
||||
if(ctx)
|
||||
{
|
||||
int res = PNGU_GetImageProperties(ctx, &imgProp);
|
||||
|
||||
if(res == PNGU_OK)
|
||||
{
|
||||
int len = imgProp.imgWidth * imgProp.imgHeight * 4;
|
||||
if(len%32) len += (32-len%32);
|
||||
data = (u8 *)memalign (32, len);
|
||||
|
||||
if(data)
|
||||
{
|
||||
res = PNGU_DecodeTo4x4RGBA8 (ctx, imgProp.imgWidth, imgProp.imgHeight, data, 255);
|
||||
|
||||
if(res == PNGU_OK)
|
||||
{
|
||||
width = imgProp.imgWidth;
|
||||
height = imgProp.imgHeight;
|
||||
DCFlushRange(data, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
free(data);
|
||||
data = NULL;
|
||||
idiotFlag=1;
|
||||
snprintf(idiotChar, sizeof(idiotChar), "%s", imgPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
PNGU_ReleaseImageContext (ctx);
|
||||
}
|
||||
}
|
||||
if(data || imgPath == path_4_3)
|
||||
break;
|
||||
imgPath = path_4_3;
|
||||
}
|
||||
|
||||
if (!data) //use buffer data instead
|
||||
{
|
||||
width = 0;
|
||||
height = 0;
|
||||
if(buffer)
|
||||
{
|
||||
PNGUPROP imgProp;
|
||||
IMGCTX ctx = PNGU_SelectImageFromBuffer(buffer);
|
||||
|
||||
if(!ctx)
|
||||
return;
|
||||
|
||||
int res = PNGU_GetImageProperties(ctx, &imgProp);
|
||||
|
||||
if(res == PNGU_OK)
|
||||
{
|
||||
int len = imgProp.imgWidth * imgProp.imgHeight * 4;
|
||||
if(len%32) len += (32-len%32);
|
||||
data = (u8 *)memalign (32, len);
|
||||
|
||||
if(data)
|
||||
{
|
||||
res = PNGU_DecodeTo4x4RGBA8 (ctx, imgProp.imgWidth, imgProp.imgHeight, data, 255);
|
||||
|
||||
if(res == PNGU_OK)
|
||||
{
|
||||
width = imgProp.imgWidth;
|
||||
height = imgProp.imgHeight;
|
||||
DCFlushRange(data, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
free(data);
|
||||
data = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
PNGU_ReleaseImageContext (ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor for the GuiImageData class.
|
||||
*/
|
||||
|
@ -527,23 +527,51 @@ void path_set(char *name, char *val) {
|
||||
|
||||
}
|
||||
|
||||
#define CFG_COORDS2(name) \
|
||||
if (strcmp(cfg_name, #name "_coords") == 0) { \
|
||||
short x,y; \
|
||||
if (sscanf(val, "%hd,%hd", &x, &y) == 2) { \
|
||||
THEME.name##_x = x; \
|
||||
THEME.name##_y = y; \
|
||||
} \
|
||||
static u32 wCOORDS_FLAGS[2] = {0, 0}; // space for 64 coords - this is enough, also for the future
|
||||
#define GET_wCOORD_FLAG(i) (wCOORDS_FLAGS[i/32] & (1UL << (i%32)))
|
||||
#define SET_wCOORD_FLAG(i) (wCOORDS_FLAGS[i/32] |= (1UL << (i%32)))
|
||||
#define CLEAR_wCOORD_FLAGS (wCOORDS_FLAGS[0] = wCOORDS_FLAGS[1] = 0)
|
||||
|
||||
|
||||
#define CFG_COORDS2(name) \
|
||||
if ((wcoords_idx++, 1) && !GET_wCOORD_FLAG(wcoords_idx) && \
|
||||
strcmp(cfg_name, #name "_coords") == 0) { \
|
||||
short x,y; \
|
||||
if (sscanf(val, "%hd,%hd", &x, &y) == 2) { \
|
||||
THEME.name##_x = x; \
|
||||
THEME.name##_y = y; \
|
||||
} \
|
||||
} \
|
||||
else if (CFG.widescreen && \
|
||||
strcmp(cfg_name, "w" #name "_coords") == 0) { \
|
||||
short x,y; \
|
||||
if (sscanf(val, "%hd,%hd", &x, &y) == 2) { \
|
||||
THEME.name##_x = x; \
|
||||
THEME.name##_y = y; \
|
||||
SET_wCOORD_FLAG(wcoords_idx); \
|
||||
} \
|
||||
}
|
||||
#define CFG_COORDS4(name) \
|
||||
if (strcmp(cfg_name, #name "_coords") == 0) { \
|
||||
short x,y,w,h; \
|
||||
if (sscanf(val, "%hd,%hd,%hd,%hd", &x, &y, &w, &h) == 4) { \
|
||||
THEME.name##_x = x; \
|
||||
THEME.name##_y = y; \
|
||||
THEME.name##_w = w; \
|
||||
THEME.name##_h = h; \
|
||||
} \
|
||||
if ((wcoords_idx++, 1) && !GET_wCOORD_FLAG(wcoords_idx) && \
|
||||
strcmp(cfg_name, #name "_coords") == 0) { \
|
||||
short x,y,w,h; \
|
||||
if (sscanf(val, "%hd,%hd,%hd,%hd", &x, &y, &w, &h) == 4) { \
|
||||
THEME.name##_x = x; \
|
||||
THEME.name##_y = y; \
|
||||
THEME.name##_w = w; \
|
||||
THEME.name##_h = h; \
|
||||
} \
|
||||
} \
|
||||
else if (CFG.widescreen && \
|
||||
strcmp(cfg_name, "w" #name "_coords") == 0) { \
|
||||
short x,y,w,h; \
|
||||
if (sscanf(val, "%hd,%hd,%hd,%hd", &x, &y, &w, &h) == 4) { \
|
||||
THEME.name##_x = x; \
|
||||
THEME.name##_y = y; \
|
||||
THEME.name##_w = w; \
|
||||
THEME.name##_h = h; \
|
||||
SET_wCOORD_FLAG(wcoords_idx); \
|
||||
} \
|
||||
}
|
||||
#define CFG_COLOR(name) \
|
||||
if (strcmp(cfg_name, #name "_color") == 0) { \
|
||||
@ -577,13 +605,13 @@ void path_set(char *name, char *val) {
|
||||
#define OLD_LIST_ICON 8
|
||||
#define OLD_GRID_ICON 16
|
||||
#define OLD_CAROUSEL_ICON 32
|
||||
#define OLD_DVD_ICON 64
|
||||
short WorkAroundIconSet=0;
|
||||
short WorkAroundBarOffset=100;
|
||||
static short WorkAroundIconSet=0;
|
||||
static short WorkAroundBarOffset=100;
|
||||
|
||||
void theme_set(char *name, char *val) {
|
||||
cfg_name = name;
|
||||
cfg_val = val;
|
||||
int wcoords_idx = -1;
|
||||
|
||||
CFG_COORDS4(gamelist)
|
||||
else CFG_COORDS4(gamegrid)
|
||||
@ -756,17 +784,13 @@ void theme_set(char *name, char *val) {
|
||||
THEME.gamegrid_carousel_x = THEME.gamecarousel_carousel_x = x-WorkAroundBarOffset;
|
||||
THEME.gamelist_carousel_y = THEME.gamegrid_carousel_y = THEME.gamecarousel_carousel_y = y;
|
||||
WorkAroundIconSet |= OLD_CAROUSEL_ICON;
|
||||
}
|
||||
}
|
||||
|
||||
else if (strcmp(cfg_name, "dvd_coords") == 0) {
|
||||
short x,y;
|
||||
if (sscanf(val, "%hd,%hd", &x, &y) == 2) {
|
||||
if(!CFG.widescreen) x+=24;
|
||||
// old themes have no dvd_coords
|
||||
// place the dvdIcon to the right side of the carouselIcon
|
||||
if(!CFG.widescreen) x+= CFG.widescreen ? 32 : 40;
|
||||
THEME.gamelist_dvd_x = x;
|
||||
THEME.gamegrid_dvd_x = THEME.gamecarousel_dvd_x = x-WorkAroundBarOffset;
|
||||
THEME.gamelist_dvd_y = THEME.gamegrid_dvd_y = THEME.gamecarousel_dvd_y = y;
|
||||
WorkAroundIconSet |= OLD_DVD_ICON;
|
||||
}
|
||||
}
|
||||
|
||||
@ -804,9 +828,6 @@ void theme_set(char *name, char *val) {
|
||||
{
|
||||
THEME.gamegrid_carousel_x += WorkAroundBarOffset - o;
|
||||
THEME.gamecarousel_carousel_x += WorkAroundBarOffset - o;
|
||||
}
|
||||
if(WorkAroundIconSet & OLD_DVD_ICON)
|
||||
{
|
||||
THEME.gamegrid_dvd_x += WorkAroundBarOffset - o;
|
||||
THEME.gamecarousel_dvd_x += WorkAroundBarOffset - o;
|
||||
}
|
||||
@ -1652,7 +1673,8 @@ void CFG_Load(void) {
|
||||
cfg_parsefile(pathname, &path_set); //then set config and layout options
|
||||
|
||||
WorkAroundIconSet=0; WorkAroundBarOffset=100; // set Workaroundstuff to defaults
|
||||
snprintf(pathname, sizeof(pathname), "%sGXtheme.cfg", CFG.theme_path);
|
||||
CLEAR_wCOORD_FLAGS;
|
||||
snprintf(pathname, sizeof(pathname), "%sGXtheme.cfg", CFG.theme_path);
|
||||
cfg_parsefile(pathname, &theme_set); //finally set theme information
|
||||
|
||||
// set GUI language, use Wii's language setting if language is set to default
|
||||
|
Loading…
Reference in New Issue
Block a user