Made theme setting to define max characters for game list. Use "maxcharacters = ##" in theme.txt. Default is 36. This does not affect for the title appears anywhere but the game list.

This commit is contained in:
giantpune 2009-05-13 05:41:49 +00:00
parent 5fabf08980
commit fe926e0eb4
3 changed files with 22 additions and 10 deletions

View File

@ -237,6 +237,7 @@ void CFG_Default(int widescreen) // -1 = non forced Mode
THEME.cover_x = 26; THEME.cover_x = 26;
THEME.cover_y = 55; THEME.cover_y = 55;
THEME.showID = 1; THEME.showID = 1;
THEME.maxcharacters = 36;
THEME.id_x = 68; THEME.id_x = 68;
THEME.id_y = 305; THEME.id_y = 305;
THEME.region_x = 68; THEME.region_x = 68;
@ -631,6 +632,13 @@ void theme_set(char *name, char *val)
THEME.pagesize = x; THEME.pagesize = x;
} }
} }
else if (strcmp(cfg_name, "maxcharacters") == 0) {
short x;
if (sscanf(val, "%hd", &x) == 1) {
THEME.maxcharacters = x;
}
}
cfg_bool("show_id", &THEME.showID); cfg_bool("show_id", &THEME.showID);
cfg_bool("show_tooltip", &THEME.showToolTip); cfg_bool("show_tooltip", &THEME.showToolTip);

View File

@ -79,6 +79,7 @@ struct THEME
short cover_x; short cover_x;
short cover_y; short cover_y;
short showID; short showID;
short maxcharacters;
short id_x; short id_x;
short id_y; short id_y;
short region_x; short region_x;

View File

@ -13,8 +13,12 @@
#include "gui_gamebrowser.h" #include "gui_gamebrowser.h"
#include "../cfg.h" #include "../cfg.h"
#include <string.h>
#include <sstream>
#define GAMESELECTSIZE 30 #define GAMESELECTSIZE 30
extern const int vol; extern const int vol;
int txtscroll = 0;
/** /**
* Constructor for the GuiGameBrowser class. * Constructor for the GuiGameBrowser class.
*/ */
@ -114,18 +118,18 @@ GuiGameBrowser::GuiGameBrowser(int w, int h, struct discHdr * l, int gameCnt, co
gameTxt = new GuiText * [pagesize]; gameTxt = new GuiText * [pagesize];
gameBg = new GuiImage * [pagesize]; gameBg = new GuiImage * [pagesize];
char buffer[CFG.maxcharacters + 4]; char buffer[THEME.maxcharacters + 4];
for(int i=0; i < pagesize; i++) for(int i=0; i < pagesize; i++)
{ {
if (strlen(get_title(&gameList[i])) < (u32)(CFG.maxcharacters + 3)) if (strlen(get_title(&gameList[i])) < (u32)(THEME.maxcharacters + 3))
{ {
sprintf(buffer, "%s", get_title(&gameList[i])); sprintf(buffer, "%s", get_title(&gameList[i]));
} }
else else
{ {
sprintf(buffer, get_title(&gameList[i]), CFG.maxcharacters); sprintf(buffer, get_title(&gameList[i]), THEME.maxcharacters);
buffer[CFG.maxcharacters] = '\0'; buffer[THEME.maxcharacters] = '\0';
strncat(buffer, "...", 3); strncat(buffer, "...", 3);
} }
@ -314,8 +318,7 @@ void GuiGameBrowser::Update(GuiTrigger * t)
// scrolldelay affects how fast the list scrolls // scrolldelay affects how fast the list scrolls
// when the arrows are clicked // when the arrows are clicked
float scrolldelay = 3.5; float scrolldelay = 3.5;
if (scrollbaron == 1) { if (scrollbaron == 1) {
// update the location of the scroll box based on the position in the option list // update the location of the scroll box based on the position in the option list
arrowUpBtn->Update(t); arrowUpBtn->Update(t);
@ -324,7 +327,7 @@ void GuiGameBrowser::Update(GuiTrigger * t)
} }
next = listOffset; next = listOffset;
char buffer[CFG.maxcharacters + 4]; char buffer[THEME.maxcharacters + 4];
for(int i=0; i<pagesize; i++) for(int i=0; i<pagesize; i++)
{ {
@ -336,14 +339,14 @@ void GuiGameBrowser::Update(GuiTrigger * t)
game[i]->SetState(STATE_DEFAULT); game[i]->SetState(STATE_DEFAULT);
} }
if (strlen(get_title(&gameList[next])) < (u32)(CFG.maxcharacters + 3)) if (strlen(get_title(&gameList[next])) < (u32)(THEME.maxcharacters + 3))
{ {
sprintf(buffer, "%s", get_title(&gameList[next])); sprintf(buffer, "%s", get_title(&gameList[next]));
} }
else else
{ {
sprintf(buffer, get_title(&gameList[next]), CFG.maxcharacters); sprintf(buffer, get_title(&gameList[next]), THEME.maxcharacters);
buffer[CFG.maxcharacters] = '\0'; buffer[THEME.maxcharacters] = '\0';
strncat(buffer, "...", 3); strncat(buffer, "...", 3);
} }