char str[80];
int i = -32;
- if(0 > rect.x - (int)strlen(info.c_str()) * white_small_text.w)
- i = rect.w + strlen(info.c_str()) * white_small_text.w;
+ if(0 > rect.x - (int)strlen(info.c_str()) * white_small_text->w)
+ i = rect.w + strlen(info.c_str()) * white_small_text->w;
if(!info.empty())
- text_draw(&white_small_text, info.c_str(), i + rect.x - strlen(info.c_str()) * white_small_text.w, rect.y, 1);
+ white_small_text->draw(info.c_str(), i + rect.x - strlen(info.c_str()) * white_small_text->w, rect.y, 1);
sprintf(str,"(%s)", SDL_GetKeyName(shortcut));
- text_draw(&white_small_text, str, i + rect.x - strlen(str) * white_small_text.w, rect.y + white_small_text.h+2, 1);
+ white_small_text->draw(str, i + rect.x - strlen(str) * white_small_text->w, rect.y + white_small_text->h+2, 1);
}
if(state == BUTTON_PRESSED)
fillrect(rect.x,rect.y,rect.w,rect.h,75,75,75,200);
clearscreen(0, 0, 0);
sprintf(str, "LEVEL %d", levelnb);
- text_drawf(&blue_text, str, 0, 200, A_HMIDDLE, A_TOP, 1);
+ blue_text->drawf(str, 0, 200, A_HMIDDLE, A_TOP, 1);
sprintf(str, "%s", world->get_level()->name.c_str());
- text_drawf(&gold_text, str, 0, 224, A_HMIDDLE, A_TOP, 1);
+ gold_text->drawf(str, 0, 224, A_HMIDDLE, A_TOP, 1);
sprintf(str, "by %s", world->get_level()->author.c_str());
- text_drawf(&gold_text, str, 0, 256, A_HMIDDLE, A_TOP, 1);
+ gold_text->drawf(str, 0, 256, A_HMIDDLE, A_TOP, 1);
sprintf(str, "TUX x %d", tux.lives);
- text_drawf(&white_text, str, 0, 288, A_HMIDDLE, A_TOP, 1);
+ white_text->drawf(str, 0, 288, A_HMIDDLE, A_TOP, 1);
flipscreen();
fillrect(i % 2 ? (pause_menu_frame * i)%screen->w : -((pause_menu_frame * i)%screen->w) ,(i*20+pause_menu_frame)%screen->h,screen->w,10,20,20,20, rand() % 20 + 1);
}
fillrect(0,0,screen->w,screen->h,rand() % 50, rand() % 50, rand() % 50, 128);
- text_drawf(&blue_text, "PAUSE - Press 'P' To Play", 0, 230, A_HMIDDLE, A_TOP, 1);
+ blue_text->drawf("PAUSE - Press 'P' To Play", 0, 230, A_HMIDDLE, A_TOP, 1);
}
if(show_menu)
char str[60];
sprintf(str, "%d", player_status.score);
- text_draw(&white_text, "SCORE", 0, 0, 1);
- text_draw(&gold_text, str, 96, 0, 1);
+ white_text->draw("SCORE", 0, 0, 1);
+ gold_text->draw(str, 96, 0, 1);
if(st_gl_mode != ST_GL_TEST)
{
sprintf(str, "%d", hs_score);
- text_draw(&white_text, "HIGH", 0, 20, 1);
- text_draw(&gold_text, str, 96, 20, 1);
+ white_text->draw("HIGH", 0, 20, 1);
+ gold_text->draw(str, 96, 20, 1);
}
else
{
- text_draw(&white_text,"Press ESC To Return",0,20,1);
+ white_text->draw("Press ESC To Return",0,20,1);
}
if (time_left.get_left() > TIME_WARNING || (global_frame_counter % 10) < 5)
{
sprintf(str, "%d", time_left.get_left() / 1000 );
- text_draw(&white_text, "TIME", 224, 0, 1);
- text_draw(&gold_text, str, 304, 0, 1);
+ white_text->draw("TIME", 224, 0, 1);
+ gold_text->draw(str, 304, 0, 1);
}
sprintf(str, "%d", player_status.distros);
- text_draw(&white_text, "DISTROS", screen->h, 0, 1);
- text_draw(&gold_text, str, 608, 0, 1);
+ white_text->draw("DISTROS", screen->h, 0, 1);
+ gold_text->draw(str, 608, 0, 1);
- text_draw(&white_text, "LIVES", screen->h, 20, 1);
+ white_text->draw("LIVES", screen->h, 20, 1);
if(show_fps)
{
sprintf(str, "%2.1f", fps_fps);
- text_draw(&white_text, "FPS", screen->h, 40, 1);
- text_draw(&gold_text, str, screen->h + 60, 40, 1);
+ white_text->draw("FPS", screen->h, 40, 1);
+ gold_text->draw(str, screen->h + 60, 40, 1);
}
for(int i= 0; i < tux.lives; ++i)
clearscreen(0, 0, 0);
- text_drawf(&blue_text, "GAMEOVER", 0, 200, A_HMIDDLE, A_TOP, 1);
+ blue_text->drawf("GAMEOVER", 0, 200, A_HMIDDLE, A_TOP, 1);
sprintf(str, "SCORE: %d", player_status.score);
- text_drawf(&gold_text, str, 0, 224, A_HMIDDLE, A_TOP, 1);
+ gold_text->drawf(str, 0, 224, A_HMIDDLE, A_TOP, 1);
sprintf(str, "DISTROS: %d", player_status.distros);
- text_drawf(&gold_text, str, 0, 256, A_HMIDDLE, A_TOP, 1);
+ gold_text->drawf(str, 0, 256, A_HMIDDLE, A_TOP, 1);
flipscreen();
clearscreen(0, 0, 0);
- text_drawf(&blue_text, "Result:", 0, 200, A_HMIDDLE, A_TOP, 1);
+ blue_text->drawf("Result:", 0, 200, A_HMIDDLE, A_TOP, 1);
sprintf(str, "SCORE: %d", player_status.score);
- text_drawf(&gold_text, str, 0, 224, A_HMIDDLE, A_TOP, 1);
+ gold_text->drawf(str, 0, 224, A_HMIDDLE, A_TOP, 1);
sprintf(str, "DISTROS: %d", player_status.distros);
- text_drawf(&gold_text, str, 0, 256, A_HMIDDLE, A_TOP, 1);
+ gold_text->drawf(str, 0, 256, A_HMIDDLE, A_TOP, 1);
flipscreen();
{
char str[10];
sprintf(str, "%d", value);
- text_draw(&gold_text, str, (int)base.x + 16 - strlen(str) * 8, (int)base.y, 1);
+ gold_text->draw(str, (int)base.x + 16 - strlen(str) * 8, (int)base.y, 1);
}
/* EOF */
/* Local Variables: */
/* mode:c++ */
-/* End */
+/* End: */
std::string datadir;
SDL_Surface * screen;
-text_type black_text, gold_text, blue_text, red_text, yellow_nums, white_text, white_small_text, white_big_text;
+Text* black_text;
+Text* gold_text;
+Text* blue_text;
+Text* red_text;
+Text* yellow_nums;
+Text* white_text;
+Text* white_small_text;
+Text* white_big_text;
MouseCursor * mouse_cursor;
extern std::string datadir;
extern SDL_Surface * screen;
-extern text_type black_text;
-extern text_type gold_text;
-extern text_type white_text;
-extern text_type white_small_text;
-extern text_type white_big_text;
-extern text_type blue_text;
-extern text_type red_text;
-extern text_type yellow_nums;
+extern Text* black_text;
+extern Text* gold_text;
+extern Text* white_text;
+extern Text* white_small_text;
+extern Text* white_big_text;
+extern Text* blue_text;
+extern Text* red_text;
+extern Text* yellow_nums;
extern MouseCursor * mouse_cursor;
{
bkgd->draw_bg();
- text_drawf(&blue_text, "Congratulations", 0, 130, A_HMIDDLE, A_TOP, 2, NO_UPDATE);
- text_draw(&blue_text, "Your score:", 150, 180, 1, NO_UPDATE);
+ blue_text->drawf("Congratulations", 0, 130, A_HMIDDLE, A_TOP, 2, NO_UPDATE);
+ blue_text->draw("Your score:", 150, 180, 1, NO_UPDATE);
sprintf(str, "%d", hs_score);
- text_draw(&yellow_nums, str, 350, 170, 1, NO_UPDATE);
+ yellow_nums->draw(str, 350, 170, 1, NO_UPDATE);
menu_process_current();
flipscreen();
le_tilemap_panel->draw();
sprintf(str, "%d/%d", le_level,le_level_subset.levels);
- text_drawf(&white_text, str, -10, 16, A_RIGHT, A_TOP, 0);
+ white_text->drawf(str, -10, 16, A_RIGHT, A_TOP, 0);
- text_draw(&white_small_text, "F1 for Help", 10, 430, 1);
+ white_small_text->draw("F1 for Help", 10, 430, 1);
}
else
{
if(show_menu == false)
- text_draw(&white_small_text, "No Level Subset loaded - Press ESC and choose one in the menu", 10, 430, 1);
+ white_small_text->draw("No Level Subset loaded - Press ESC and choose one in the menu", 10, 430, 1);
else
- text_draw(&white_small_text, "No Level Subset loaded", 10, 430, 1);
+ white_small_text->draw("No Level Subset loaded", 10, 430, 1);
}
}
char str[1024];
int d = 0;
sprintf(str,"Level %d doesn't exist.",le_level+1);
- text_drawf(&white_text,str,0,-18,A_HMIDDLE,A_VMIDDLE,2);
- text_drawf(&white_text,"Do you want to create it?",0,0,A_HMIDDLE,A_VMIDDLE,2);
- text_drawf(&red_text,"(Y)es/(N)o",0,20,A_HMIDDLE,A_VMIDDLE,2);
+ white_text->drawf(str,0,-18,A_HMIDDLE,A_VMIDDLE,2);
+ white_text->drawf("Do you want to create it?",0,0,A_HMIDDLE,A_VMIDDLE,2);
+ red_text->drawf("(Y)es/(N)o",0,20,A_HMIDDLE,A_VMIDDLE,2);
flipscreen();
while(d == 0)
{
};
- text_drawf(&blue_text, "- Help -", 0, 30, A_HMIDDLE, A_TOP, 2);
+ blue_text->drawf("- Help -", 0, 30, A_HMIDDLE, A_TOP, 2);
for(i = 0; i < sizeof(text)/sizeof(char *); i++)
- text_draw(&white_text, text[i], 5, 80+(i*18), 1);
+ white_text->draw(text[i], 5, 80+(i*18), 1);
- text_drawf(&gold_text, "Press Any Key to Continue", 0, 440, A_HMIDDLE, A_TOP, 1);
+ gold_text->drawf("Press Any Key to Continue", 0, 440, A_HMIDDLE, A_TOP, 1);
flipscreen();
int text_width = strlen(pitem.text) * font_width;
int input_width = strlen(pitem.input) * font_width;
int list_width = strlen(string_list_active(pitem.list)) * font_width;
- text_type* text_font = &white_text;
+ Text* text_font = white_text;
if (arrange_left)
x_pos += 24 - menu_width/2 + (text_width + input_width + list_width)/2;
if(index == active_item)
{
shadow_size = 3;
- text_font = &blue_text;
+ text_font = blue_text;
}
switch (pitem.kind)
{
case MN_DEACTIVE:
{
- text_draw_align(&black_text, pitem.text,
- x_pos, y_pos,
- A_HMIDDLE, A_VMIDDLE, 2);
+ black_text->draw_align(pitem.text,
+ x_pos, y_pos,
+ A_HMIDDLE, A_VMIDDLE, 2);
break;
}
}
case MN_LABEL:
{
- text_draw_align(&white_big_text, pitem.text,
- x_pos, y_pos,
- A_HMIDDLE, A_VMIDDLE, 2);
+ white_big_text->draw_align(pitem.text,
+ x_pos, y_pos,
+ A_HMIDDLE, A_VMIDDLE, 2);
break;
}
case MN_TEXTFIELD:
input_width + font_width, 18,
0,0,0,128);
- text_draw_align(&gold_text, pitem.input,
- x_pos + text_pos, y_pos,
- A_HMIDDLE, A_VMIDDLE, 2);
+ gold_text->draw_align(pitem.input,
+ x_pos + text_pos, y_pos,
+ A_HMIDDLE, A_VMIDDLE, 2);
- text_draw_align(text_font, pitem.text,
- x_pos - (input_width + font_width)/2, y_pos,
- A_HMIDDLE, A_VMIDDLE, shadow_size);
+ text_font->draw_align(pitem.text,
+ x_pos - (input_width + font_width)/2, y_pos,
+ A_HMIDDLE, A_VMIDDLE, shadow_size);
break;
}
case MN_STRINGSELECT:
list_pos_2, 18,
0,0,0,128);
- text_draw_align(&gold_text, string_list_active(pitem.list),
+ gold_text->draw_align(string_list_active(pitem.list),
x_pos + text_pos, y_pos,
A_HMIDDLE, A_VMIDDLE,2);
- text_draw_align(text_font, pitem.text,
+ text_font->draw_align(pitem.text,
x_pos - list_pos_2/2, y_pos,
A_HMIDDLE, A_VMIDDLE, shadow_size);
break;
}
case MN_BACK:
{
- text_draw_align(text_font, pitem.text, x_pos, y_pos, A_HMIDDLE, A_VMIDDLE, shadow_size);
+ text_font->draw_align(pitem.text, x_pos, y_pos, A_HMIDDLE, A_VMIDDLE, shadow_size);
back->draw( x_pos + text_width/2 + font_width, y_pos - 8);
break;
}
case MN_TOGGLE:
{
- text_draw_align(text_font, pitem.text, x_pos, y_pos, A_HMIDDLE, A_VMIDDLE, shadow_size);
+ text_font->draw_align(pitem.text, x_pos, y_pos, A_HMIDDLE, A_VMIDDLE, shadow_size);
if(pitem.toggled)
checkbox_checked->draw(
break;
}
case MN_ACTION:
- text_draw_align(text_font, pitem.text, x_pos, y_pos, A_HMIDDLE, A_VMIDDLE, shadow_size);
+ text_font->draw_align(pitem.text, x_pos, y_pos, A_HMIDDLE, A_VMIDDLE, shadow_size);
break;
case MN_GOTO:
- text_draw_align(text_font, pitem.text, x_pos, y_pos, A_HMIDDLE, A_VMIDDLE, shadow_size);
+ text_font->draw_align(pitem.text, x_pos, y_pos, A_HMIDDLE, A_VMIDDLE, shadow_size);
break;
}
}
/* Local Variables: */
/* mode: c++ */
-/* End */
+/* End: */
}
if(dying)
- text_drawf(&gold_text,"Penguins can fly !:",0,0,A_HMIDDLE,A_VMIDDLE,1);
+ gold_text->drawf("Penguins can fly !:",0,0,A_HMIDDLE,A_VMIDDLE,1);
if (debug_mode)
fillrect(base.x - scroll_x, base.y, 32, 32, 75,75,75, 150);
/* Load global images: */
- text_load(&black_text, datadir + "/images/status/letters-black.png", TEXT_TEXT, 16,18);
- text_load(&gold_text,datadir + "/images/status/letters-gold.png", TEXT_TEXT, 16,18);
- text_load(&blue_text,datadir + "/images/status/letters-blue.png", TEXT_TEXT, 16,18);
- text_load(&red_text,datadir + "/images/status/letters-red.png", TEXT_TEXT, 16,18);
- text_load(&white_text,datadir + "/images/status/letters-white.png", TEXT_TEXT, 16,18);
- text_load(&white_small_text,datadir + "/images/status/letters-white-small.png", TEXT_TEXT, 8,9);
- text_load(&white_big_text,datadir + "/images/status/letters-white-big.png", TEXT_TEXT, 20,23);
- text_load(&yellow_nums,datadir + "/images/status/numbers.png", TEXT_NUM, 32,32);
+ black_text = new Text(datadir + "/images/status/letters-black.png", TEXT_TEXT, 16,18);
+ gold_text = new Text(datadir + "/images/status/letters-gold.png", TEXT_TEXT, 16,18);
+ blue_text = new Text(datadir + "/images/status/letters-blue.png", TEXT_TEXT, 16,18);
+ red_text = new Text(datadir + "/images/status/letters-red.png", TEXT_TEXT, 16,18);
+ white_text = new Text(datadir + "/images/status/letters-white.png", TEXT_TEXT, 16,18);
+ white_small_text = new Text(datadir + "/images/status/letters-white-small.png", TEXT_TEXT, 8,9);
+ white_big_text = new Text(datadir + "/images/status/letters-white-big.png", TEXT_TEXT, 20,23);
+ yellow_nums = new Text(datadir + "/images/status/numbers.png", TEXT_NUM, 32,32);
/* Load GUI/menu images: */
checkbox = new Surface(datadir + "/images/status/checkbox.png", USE_ALPHA);
/* Free global images: */
- text_free(&black_text);
- text_free(&gold_text);
- text_free(&white_text);
- text_free(&blue_text);
- text_free(&red_text);
- text_free(&white_small_text);
- text_free(&white_big_text);
+ delete black_text;
+ delete gold_text;
+ delete white_text;
+ delete blue_text;
+ delete red_text;
+ delete white_small_text;
+ delete white_big_text;
/* Free GUI/menu images: */
delete checkbox;
/* Local Variables: */
/* mode:c++ */
-/* End */
+/* End: */
#include "screen.h"
#include "text.h"
-void text_load(text_type* ptext, const std::string& file, int kind, int w, int h)
+Text::Text(const std::string& file, int kind_, int w_, int h_)
{
+ kind = kind_;
+ w = w_;
+ h = h_;
+
int mx, my;
SDL_Surface *conv;
int pixels;
mx = 0;
my = 0;
}
- ptext->kind = kind;
- ptext->w = w;
- ptext->h = h;
- ptext->chars = new Surface(file, USE_ALPHA);
+ chars = new Surface(file, USE_ALPHA);
/* Load shadow font. */
- conv = SDL_DisplayFormatAlpha(ptext->chars->impl->sdl_surface);
+ conv = SDL_DisplayFormatAlpha(chars->impl->sdl_surface);
pixels = conv->w * conv->h;
SDL_LockSurface(conv);
for(i = 0; i < pixels; ++i)
}
SDL_UnlockSurface(conv);
SDL_SetAlpha(conv, SDL_SRCALPHA, 128);
- ptext->shadow_chars = new Surface(conv, USE_ALPHA);
+ shadow_chars = new Surface(conv, USE_ALPHA);
SDL_FreeSurface(conv);
}
-void text_draw(text_type* ptext,const char* text, int x, int y, int shadowsize, int update)
+void
+Text::draw(const char* text, int x, int y, int shadowsize, int update)
{
if(text != NULL)
{
if(shadowsize != 0)
- text_draw_chars(ptext, ptext->shadow_chars, text,x+shadowsize,y+shadowsize, update);
+ draw_chars(shadow_chars, text,x+shadowsize,y+shadowsize, update);
- text_draw_chars(ptext, ptext->chars, text,x,y, update);
+ draw_chars(chars, text,x,y, update);
}
}
-void text_draw_chars(text_type* ptext, Surface* pchars,const char* text, int x, int y, int update)
+void
+Text::draw_chars(Surface* pchars,const char* text, int x, int y, int update)
{
int i,j,len;
- int w, h;
len = strlen(text);
- w = ptext->w;
- h = ptext->h;
+ int w = this->w;
+ int h = this->h;
- if(ptext->kind == TEXT_TEXT)
+ if(kind == TEXT_TEXT)
{
for( i = 0, j = 0; i < len; ++i,++j)
{
if( text[i] >= 'A' && text[i] <= 'Z')
- pchars->draw_part((int)(text[i] - 'A')*w, 0, x+(j*w), y, ptext->w, ptext->h, 255, update);
+ pchars->draw_part((int)(text[i] - 'A')*w, 0, x+(j*w), y, w, h, 255, update);
else if( text[i] >= 'a' && text[i] <= 'z')
- pchars->draw_part((int)(text[i] - 'a')*w, h, x+(j*w), y, ptext->w, ptext->h, 255, update);
+ pchars->draw_part((int)(text[i] - 'a')*w, h, x+(j*w), y, w, h, 255, update);
else if ( text[i] >= '!' && text[i] <= '9')
- pchars->draw_part((int)(text[i] - '!')*w, h*2, x+(j*w), y, ptext->w, ptext->h, 255, update);
+ pchars->draw_part((int)(text[i] - '!')*w, h*2, x+(j*w), y, w, h, 255, update);
else if ( text[i] == '?')
- pchars->draw_part(25*w, h*2, x+(j*w), y, ptext->w, ptext->h, 255, update);
+ pchars->draw_part(25*w, h*2, x+(j*w), y, w, h, 255, update);
else if ( text[i] == '\n')
{
- y += ptext->h + 2;
+ y += h + 2;
j = 0;
}
}
}
- else if(ptext->kind == TEXT_NUM)
+ else if(kind == TEXT_NUM)
{
for( i = 0, j = 0; i < len; ++i, ++j)
{
pchars->draw_part((int)(text[i] - '0')*w, 0, x+(j*w), y, w, h, 255, update);
else if ( text[i] == '\n')
{
- y += ptext->h + 2;
+ y += h + 2;
j = 0;
}
}
}
}
-void text_draw_align(text_type* ptext, const char* text, int x, int y,
- TextHAlign halign, TextVAlign valign, int shadowsize, int update)
+void
+Text::draw_align(const char* text, int x, int y,
+ TextHAlign halign, TextVAlign valign, int shadowsize, int update)
{
if(text != NULL)
{
switch (halign)
{
case A_RIGHT:
- x += -(strlen(text)*ptext->w);
+ x += -(strlen(text)*w);
break;
case A_HMIDDLE:
- x += -((strlen(text)*ptext->w)/2);
+ x += -((strlen(text)*w)/2);
break;
case A_LEFT:
// default
switch (valign)
{
case A_BOTTOM:
- y -= ptext->h;
+ y -= h;
break;
case A_VMIDDLE:
- y -= ptext->h/2;
+ y -= h/2;
case A_TOP:
// default
break;
}
- text_draw(ptext, text, x, y, shadowsize, update);
+ draw(text, x, y, shadowsize, update);
}
}
-void text_drawf(text_type* ptext,const char* text, int x, int y, TextHAlign halign, TextVAlign valign, int shadowsize, int update)
+void
+Text::drawf(const char* text, int x, int y,
+ TextHAlign halign, TextVAlign valign, int shadowsize, int update)
{
if(text != NULL)
{
if(halign == A_RIGHT) /* FIXME: this doesn't work correctly for strings with newlines.*/
- x += screen->w - (strlen(text)*ptext->w);
+ x += screen->w - (strlen(text)*w);
else if(halign == A_HMIDDLE)
- x += screen->w/2 - ((strlen(text)*ptext->w)/2);
+ x += screen->w/2 - ((strlen(text)*w)/2);
if(valign == A_BOTTOM)
- y += screen->h - ptext->h;
+ y += screen->h - h;
else if(valign == A_VMIDDLE)
- y += screen->h/2 - ptext->h/2;
+ y += screen->h/2 - h/2;
- text_draw(ptext,text,x,y,shadowsize, update);
+ draw(text,x,y,shadowsize, update);
}
}
-void text_free(text_type* ptext)
+Text::~Text()
{
- if(ptext->kind == TEXT_TEXT)
- delete ptext->chars;
- else if(ptext->kind == TEXT_NUM)
- delete ptext->chars;
+ if(kind == TEXT_TEXT)
+ delete chars;
+ else if(kind == TEXT_NUM)
+ delete chars;
}
/* --- ERASE TEXT: --- */
-void erasetext(text_type* ptext,const char * text, int x, int y, Surface * ptexture, int update, int shadowsize)
+void
+Text::erasetext(const char * text, int x, int y, Surface * ptexture, int update, int shadowsize)
{
SDL_Rect dest;
-
dest.x = x;
dest.y = y;
- dest.w = strlen(text) * ptext->w + shadowsize;
- dest.h = ptext->h;
+ dest.w = strlen(text) * w + shadowsize;
+ dest.h = h;
if (dest.w > screen->w)
dest.w = screen->w;
/* --- ERASE CENTERED TEXT: --- */
-void erasecenteredtext(text_type* ptext,const char * text, int y, Surface * ptexture, int update, int shadowsize)
+void
+Text::erasecenteredtext(const char * text, int y, Surface * ptexture, int update, int shadowsize)
{
- erasetext(ptext, text, screen->w / 2 - (strlen(text) * 8), y, ptexture, update, shadowsize);
+ erasetext(text, screen->w / 2 - (strlen(text) * 8), y, ptexture, update, shadowsize);
}
#include "texture.h"
-/* Text type */
-struct text_type
-{
- Surface* chars;
- Surface* shadow_chars;
- int kind;
- int w;
- int h;
-};
/* Kinds of texts. */
enum {
A_BOTTOM,
};
-void text_load(text_type* ptext, const std::string& file, int kind, int w, int h);
-void text_draw(text_type* ptext, const char* text, int x, int y, int shadowsize, int update = NO_UPDATE);
-void text_draw_chars(text_type* ptext, Surface* pchars, const char* text, int x, int y, int update = NO_UPDATE);
-void text_drawf(text_type* ptext, const char* text, int x, int y, TextHAlign halign, TextVAlign valign, int shadowsize, int update = NO_UPDATE);
-void text_draw_align(text_type* ptext, const char* text, int x, int y, TextHAlign halign, TextVAlign valign, int shadowsize, int update = NO_UPDATE);
-void text_free(text_type* ptext);
-void erasetext(text_type* ptext, const char * text, int x, int y, Surface* surf, int update, int shadowsize);
-void erasecenteredtext(text_type* ptext, const char * text, int y, Surface* surf, int update, int shadowsize);
+/* Text type */
+class Text
+{
+ public:
+ Surface* chars;
+ Surface* shadow_chars;
+ int kind;
+ int w;
+ int h;
+ public:
+ Text(const std::string& file, int kind, int w, int h);
+ ~Text();
+
+ void draw(const char* text, int x, int y, int shadowsize, int update = NO_UPDATE);
+ void draw_chars(Surface* pchars, const char* text, int x, int y, int update = NO_UPDATE);
+ void drawf(const char* text, int x, int y, TextHAlign halign, TextVAlign valign, int shadowsize, int update = NO_UPDATE);
+ void draw_align(const char* text, int x, int y, TextHAlign halign, TextVAlign valign, int shadowsize, int update = NO_UPDATE);
+ void erasetext(const char * text, int x, int y, Surface* surf, int update, int shadowsize);
+ void erasecenteredtext(const char * text, int y, Surface* surf, int update, int shadowsize);
+};
#endif /*SUPERTUX_TEXT_H*/
/* Local Variables: */
/* mode: c++ */
-/* End */
+/* End: */
/* Local Variables: */
/* mode:c++ */
-/* End */
+/* End: */
if (current_menu == main_menu)
logo->draw( 160, 30);
- text_draw(&white_small_text,
+ white_small_text->draw(
" SuperTux " VERSION "\n"
"Copyright (c) 2003 SuperTux Devel Team\n"
"This game comes with ABSOLUTELY NO WARRANTY. This is free software, and you\n"
draw_background();
- text_drawf(&white_big_text, "- Credits -", 0, screen->h-scroll, A_HMIDDLE, A_TOP, 2);
+ white_big_text->drawf("- Credits -", 0, screen->h-scroll, A_HMIDDLE, A_TOP, 2);
for(i = 0, n = 0, d = 0; i < length; i++,n++,d++)
{
else
{
if(names.item[i][0] == ' ')
- text_drawf(&white_small_text, names.item[i], 0, 60+screen->h+(n*18)+(d*18)-scroll-10, A_HMIDDLE, A_TOP, 1);
+ white_small_text->drawf(names.item[i], 0, 60+screen->h+(n*18)+(d*18)-scroll-10, A_HMIDDLE, A_TOP, 1);
else if(names.item[i][0] == ' ')
- text_drawf(&white_text, names.item[i], 0, 60+screen->h+(n*18)+(d*18)-scroll, A_HMIDDLE, A_TOP, 1);
+ white_text->drawf(names.item[i], 0, 60+screen->h+(n*18)+(d*18)-scroll, A_HMIDDLE, A_TOP, 1);
else if(names.item[i+1][0] == '-' || names.item[i][0] == '-')
- text_drawf(&white_big_text, names.item[i], 0, 60+screen->h+(n*18)+(d*18)-scroll, A_HMIDDLE, A_TOP, 3);
+ white_big_text->drawf(names.item[i], 0, 60+screen->h+(n*18)+(d*18)-scroll, A_HMIDDLE, A_TOP, 3);
else
- text_drawf(&blue_text, names.item[i], 0, 60+screen->h+(n*18)+(d*18)-scroll, A_HMIDDLE, A_TOP, 1);
+ blue_text->drawf(names.item[i], 0, 60+screen->h+(n*18)+(d*18)-scroll, A_HMIDDLE, A_TOP, 1);
}
}
/* Local Variables: */
/* mode:c++ */
-/* End */
+/* End: */
/* Local Variables: */
/* mode:c++ */
-/* End */
+/* End: */