Added a special font for the clock

This commit is contained in:
ardi@ist-einmalig.de 2009-05-04 21:50:46 +00:00
parent fc549f113f
commit a00104784f
8 changed files with 1158 additions and 1130 deletions

View File

@ -177,9 +177,12 @@ void cfg_int(char *name, short *var, int count)
//static char bg_path[100]; //static char bg_path[100];
void CFG_Default() void CFG_Default(int widescreen) // -1 = non forced Mode
{ {
if(widescreen == -1)
CFG.widescreen = CONF_GetAspectRatio(); CFG.widescreen = CONF_GetAspectRatio();
else
CFG.widescreen = widescreen;
if (CFG.widescreen) { if (CFG.widescreen) {
snprintf(CFG.theme_path, sizeof(CFG.theme_path), "SD:/wtheme/"); snprintf(CFG.theme_path, sizeof(CFG.theme_path), "SD:/wtheme/");
@ -346,6 +349,10 @@ void widescreen_set(char *name, char *val)
cfg_name = name; cfg_name = name;
cfg_val = val; cfg_val = val;
short widescreen;
if (cfg_bool("widescreen", &widescreen) && CFG.widescreen != widescreen)
CFG_Default(widescreen); //reset default when forced an other Screenmode
/*
if (cfg_bool("widescreen", &CFG.widescreen)) //reset default if (cfg_bool("widescreen", &CFG.widescreen)) //reset default
{ {
if (CFG.widescreen) { if (CFG.widescreen) {
@ -358,6 +365,7 @@ void widescreen_set(char *name, char *val)
snprintf(CFG.theme_path, sizeof(CFG.theme_path), "SD:/theme/"); snprintf(CFG.theme_path, sizeof(CFG.theme_path), "SD:/theme/");
} }
} }
*/
} }
@ -1019,7 +1027,7 @@ void CFG_Load(int argc, char **argv)
//set app path //set app path
// chdir_app(argv[0]); // chdir_app(argv[0]);
CFG_Default(); CFG_Default(-1); // set defaults non forced
snprintf(pathname, sizeof(pathname), "SD:/config/config.txt"); snprintf(pathname, sizeof(pathname), "SD:/config/config.txt");

View File

@ -142,7 +142,7 @@ struct Game_CFG
}; };
void CFG_Default(); void CFG_Default(int widescreen); // -1 = non forced mode
void CFG_Load(int argc, char **argv); void CFG_Load(int argc, char **argv);
struct Game_CFG* CFG_get_game_opt(u8 *id); struct Game_CFG* CFG_get_game_opt(u8 *id);
bool CFG_save_game_opt(u8 *id); bool CFG_save_game_opt(u8 *id);

View File

@ -14,6 +14,9 @@
extern const u8 font_ttf[]; extern const u8 font_ttf[];
extern const u32 font_ttf_size; extern const u32 font_ttf_size;
extern const u8 clock_ttf[];
extern const u32 clock_ttf_size;
extern const u8 sdcard_png[]; extern const u8 sdcard_png[];
extern const u32 sdcard_png_size; extern const u32 sdcard_png_size;

BIN
source/fonts/clock.ttf Normal file

Binary file not shown.

View File

@ -622,6 +622,7 @@ class GuiText : public GuiElement
//!\param hor Horizontal alignment (ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTRE) //!\param hor Horizontal alignment (ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTRE)
//!\param vert Vertical alignment (ALIGN_TOP, ALIGN_BOTTOM, ALIGN_MIDDLE) //!\param vert Vertical alignment (ALIGN_TOP, ALIGN_BOTTOM, ALIGN_MIDDLE)
void SetAlignment(int hor, int vert); void SetAlignment(int hor, int vert);
void SetFont(FreeTypeGX *f);
//!Constantly called to draw the text //!Constantly called to draw the text
void Draw(); void Draw();
protected: protected:
@ -630,6 +631,7 @@ class GuiText : public GuiElement
int maxWidth; //!< Maximum width of the generated text object (for text wrapping) int maxWidth; //!< Maximum width of the generated text object (for text wrapping)
u16 style; //!< FreeTypeGX style attributes u16 style; //!< FreeTypeGX style attributes
GXColor color; //!< Font color GXColor color; //!< Font color
FreeTypeGX *font;
}; };
//!Display, manage, and manipulate buttons in the GUI. Buttons can have images, icons, text, and sound set (all of which are optional) //!Display, manage, and manipulate buttons in the GUI. Buttons can have images, icons, text, and sound set (all of which are optional)

View File

@ -29,6 +29,7 @@ GuiText::GuiText(const char * t, int s, GXColor c)
alpha = c.a; alpha = c.a;
style = FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE; style = FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE;
maxWidth = 0; maxWidth = 0;
font = 0;
alignmentHor = ALIGN_CENTRE; alignmentHor = ALIGN_CENTRE;
alignmentVert = ALIGN_MIDDLE; alignmentVert = ALIGN_MIDDLE;
@ -142,7 +143,13 @@ void GuiText::SetAlignment(int hor, int vert)
alignmentHor = hor; alignmentHor = hor;
alignmentVert = vert; alignmentVert = vert;
} }
/**
* Set the Font
*/
void GuiText::SetFont(FreeTypeGX *f)
{
font = f;
}
/** /**
* Draw the text on screen * Draw the text on screen
*/ */
@ -161,7 +168,7 @@ void GuiText::Draw()
if(newSize != currentSize) if(newSize != currentSize)
{ {
fontSystem->changeSize(newSize); (font ? font : fontSystem)->changeSize(newSize);
currentSize = newSize; currentSize = newSize;
} }
@ -191,7 +198,7 @@ void GuiText::Draw()
if(text[ch] == ' ' || ch == strlen-1) if(text[ch] == ' ' || ch == strlen-1)
{ {
if(fontSystem->getWidth(tmptext[linenum]) >= maxWidth) if((font ? font : fontSystem)->getWidth(tmptext[linenum]) >= maxWidth)
{ {
if(lastSpace >= 0) if(lastSpace >= 0)
{ {
@ -222,13 +229,13 @@ void GuiText::Draw()
for(i=0; i < linenum; i++) for(i=0; i < linenum; i++)
{ {
fontSystem->drawText(this->GetLeft(), this->GetTop()+voffset+i*lineheight, tmptext[i], c, style); (font ? font : fontSystem)->drawText(this->GetLeft(), this->GetTop()+voffset+i*lineheight, tmptext[i], c, style);
delete tmptext[i]; delete tmptext[i];
} }
} }
else else
{ {
fontSystem->drawText(this->GetLeft(), this->GetTop()+voffset, text, c, style); (font ? font : fontSystem)->drawText(this->GetLeft(), this->GetTop()+voffset, text, c, style);
} }
this->UpdateEffects(); this->UpdateEffects();
} }

View File

@ -41,7 +41,8 @@
#define CONSOLE_WIDTH 340 #define CONSOLE_WIDTH 340
#define CONSOLE_HEIGHT 218 #define CONSOLE_HEIGHT 218
FreeTypeGX *fontSystem; FreeTypeGX *fontSystem=0;
FreeTypeGX *fontClock=0;
int ExitRequested = 0; int ExitRequested = 0;
bool netcheck = false; bool netcheck = false;
@ -146,6 +147,10 @@ main(int argc, char *argv[])
fontSystem->loadFont(font_ttf, font_ttf_size, 0); fontSystem->loadFont(font_ttf, font_ttf_size, 0);
fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE); fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE);
fontClock = new FreeTypeGX();
fontClock->loadFont(clock_ttf, clock_ttf_size, 0);
fontClock->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE);
InitGUIThreads(); InitGUIThreads();
MainMenu(MENU_CHECK); MainMenu(MENU_CHECK);
return 0; return 0;

View File

@ -42,6 +42,8 @@
#define MAX_CHARACTERS 38 #define MAX_CHARACTERS 38
extern FreeTypeGX *fontClock; //CLOCK
static GuiImage * coverImg = NULL; static GuiImage * coverImg = NULL;
static GuiImageData * cover = NULL; static GuiImageData * cover = NULL;
@ -2381,6 +2383,7 @@ static int MenuDiscList()
GuiText clockTime(theTime, 30, (GXColor){138, 138, 138, 255}); GuiText clockTime(theTime, 30, (GXColor){138, 138, 138, 255});
clockTime.SetAlignment(THEME.clockAlign, ALIGN_BOTTOM); clockTime.SetAlignment(THEME.clockAlign, ALIGN_BOTTOM);
clockTime.SetPosition(THEME.clock_x, THEME.clock_y); clockTime.SetPosition(THEME.clock_x, THEME.clock_y);
clockTime.SetFont(fontClock);
HaltGui(); HaltGui();
GuiWindow w(screenwidth, screenheight); GuiWindow w(screenwidth, screenheight);
@ -2609,7 +2612,7 @@ static int MenuDiscList()
snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]); snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]);
snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]);
w.Remove(&DownloadBtn); w.Remove(&DownloadBtn);
w.Remove(coverImg); // w.Remove(coverImg);
if (GameIDTxt) if (GameIDTxt)
{ {