more fontsize names, more source files converted, -DUSE_TINY_GUI can be used to test with smaller fonts

This commit is contained in:
Yann Dirson 2004-09-25 19:46:33 +00:00
parent 48219f6e49
commit 1702b387ed
7 changed files with 72 additions and 58 deletions

View File

@ -312,7 +312,7 @@ void show_about(display& disp)
int cur_line = 0;
do {
SDL_Rect tr = font::draw_text(&disp,disp.screen_area(),24,font::BLACK_COLOUR,
SDL_Rect tr = font::draw_text(&disp,disp.screen_area(),font::SIZE_XLARGE,font::BLACK_COLOUR,
text[line], map_rect.x + map_rect.w / 8,y);
if(is_new_line) {
is_new_line = false;

View File

@ -384,7 +384,7 @@ void save_preview_pane::draw()
str << "\n" << _("Difficulty") << ": " << string_table[summary["difficulty"]];
}
font::draw_text(&disp(),area,12,font::NORMAL_COLOUR,str.str(),area.x,ypos,NULL,true);
font::draw_text(&disp(),area,font::SIZE_SMALL,font::NORMAL_COLOUR,str.str(),area.x,ypos,NULL,true);
}
} //end anon namespace
@ -637,8 +637,8 @@ void unit_preview_pane::draw()
std::stringstream desc;
desc << font::NORMAL_TEXT << u.description();
const std::string description = desc.str();
description_rect = font::text_area(description,14);
description_rect = font::draw_text(&disp(),area,14,font::NORMAL_COLOUR,desc.str(),right_align ? image_rect.x : image_rect.x + image_rect.w - description_rect.w,image_rect.y+image_rect.h+details_button_.location().h);
description_rect = font::text_area(description,font::SIZE_NORMAL);
description_rect = font::draw_text(&disp(),area,font::SIZE_NORMAL,font::NORMAL_COLOUR,desc.str(),right_align ? image_rect.x : image_rect.x + image_rect.w - description_rect.w,image_rect.y+image_rect.h+details_button_.location().h);
}
std::stringstream details;
@ -716,11 +716,11 @@ void unit_preview_pane::draw()
for(std::vector<std::string>::const_iterator line = lines.begin(); line != lines.end(); ++line) {
int xpos = cur_area.x;
if(right_align && !weapons_) {
const SDL_Rect& line_area = font::text_area(*line,12);
const SDL_Rect& line_area = font::text_area(*line,font::SIZE_SMALL);
xpos = cur_area.x + cur_area.w - line_area.w;
}
cur_area = font::draw_text(&disp(),location(),12,font::NORMAL_COLOUR,*line,xpos,cur_area.y);
cur_area = font::draw_text(&disp(),location(),font::SIZE_SMALL,font::NORMAL_COLOUR,*line,xpos,cur_area.y);
cur_area.y += cur_area.h;
}
}
@ -787,12 +787,12 @@ void campaign_preview_pane::draw()
gui::draw_dialog_frame(area.x,area.y,area.w,area.h,disp(),style);
/* description text */
const std::string& desc_text = font::word_wrap_text((*descriptions_)[index_].first,12,area.w-2*campaign_preview_border);
const std::string& desc_text = font::word_wrap_text((*descriptions_)[index_].first,font::SIZE_SMALL,area.w-2*campaign_preview_border);
const std::vector<std::string> lines = config::split(desc_text,'\n');
SDL_Rect txt_area = { area.x+campaign_preview_border,area.y,0,0 };
for(std::vector<std::string>::const_iterator line = lines.begin(); line != lines.end(); ++line) {
txt_area = font::draw_text(&disp(),location(),12,font::NORMAL_COLOUR,*line,txt_area.x,txt_area.y);
txt_area = font::draw_text(&disp(),location(),font::SIZE_SMALL,font::NORMAL_COLOUR,*line,txt_area.x,txt_area.y);
txt_area.y += txt_area.h;
}

View File

@ -1539,20 +1539,20 @@ void display::draw_footstep(const gamemap::location& loc, int xloc, int yloc)
const SDL_Rect& rect = map_area();
std::string str(1,'x');
str[0] = '1' + route_.move_left;
const SDL_Rect& text_area = font::text_area(str,18);
const SDL_Rect& text_area = font::text_area(str,font::SIZE_LARGE);
const int x = xloc + zoom_/2 - text_area.w/2;
const int y = yloc + zoom_/2 - text_area.h/2;
//draw the text with a black outline
font::draw_text(this,rect,18,font::DARK_COLOUR,str,x-1,y-1);
font::draw_text(this,rect,18,font::DARK_COLOUR,str,x-1,y);
font::draw_text(this,rect,18,font::DARK_COLOUR,str,x-1,y+1);
font::draw_text(this,rect,18,font::DARK_COLOUR,str,x,y-1);
font::draw_text(this,rect,18,font::DARK_COLOUR,str,x+1,y-1);
font::draw_text(this,rect,18,font::DARK_COLOUR,str,x+1,y);
font::draw_text(this,rect,18,font::DARK_COLOUR,str,x+1,y+1);
font::draw_text(this,rect,18,font::DARK_COLOUR,str,x,y+1);
font::draw_text(this,rect,18,font::YELLOW_COLOUR,str,x,y);
font::draw_text(this,rect,font::SIZE_LARGE,font::DARK_COLOUR,str,x-1,y-1);
font::draw_text(this,rect,font::SIZE_LARGE,font::DARK_COLOUR,str,x-1,y);
font::draw_text(this,rect,font::SIZE_LARGE,font::DARK_COLOUR,str,x-1,y+1);
font::draw_text(this,rect,font::SIZE_LARGE,font::DARK_COLOUR,str,x,y-1);
font::draw_text(this,rect,font::SIZE_LARGE,font::DARK_COLOUR,str,x+1,y-1);
font::draw_text(this,rect,font::SIZE_LARGE,font::DARK_COLOUR,str,x+1,y);
font::draw_text(this,rect,font::SIZE_LARGE,font::DARK_COLOUR,str,x+1,y+1);
font::draw_text(this,rect,font::SIZE_LARGE,font::DARK_COLOUR,str,x,y+1);
font::draw_text(this,rect,font::SIZE_LARGE,font::YELLOW_COLOUR,str,x,y);
}
}
@ -1824,7 +1824,7 @@ void display::float_label(const gamemap::location& loc, const std::string& text,
}
const SDL_Color colour = {red,green,blue,255};
font::add_floating_label(text,24,colour,get_location_x(loc)+zoom_/2,get_location_y(loc),
font::add_floating_label(text,font::SIZE_XLARGE,colour,get_location_x(loc)+zoom_/2,get_location_y(loc),
0,-2,60,screen_area(),font::CENTER_ALIGN,NULL,0,font::ANCHOR_LABEL_MAP);
}
@ -2139,7 +2139,7 @@ int display::set_help_string(const std::string& str)
font::remove_floating_label(help_string_);
const SDL_Color colour = {0x0,0x00,0x00,0x77};
help_string_ = font::add_floating_label(str,18,font::NORMAL_COLOUR,x()/2,y(),0.0,0.0,-1,screen_area(),font::CENTER_ALIGN,&colour,5);
help_string_ = font::add_floating_label(str,font::SIZE_LARGE,font::NORMAL_COLOUR,x()/2,y(),0.0,0.0,-1,screen_area(),font::CENTER_ALIGN,&colour,5);
const SDL_Rect& rect = font::get_floating_label_rect(help_string_);
font::move_floating_label(help_string_,0.0,-double(rect.h));
return help_string_;
@ -2221,11 +2221,11 @@ void display::add_chat_message(const std::string& speaker, int side, const std::
}
const SDL_Rect rect = map_area();
const int speaker_handle = font::add_floating_label(str.str(),12,speaker_colour,
const int speaker_handle = font::add_floating_label(str.str(),font::SIZE_SMALL,speaker_colour,
rect.x+chat_message_x,rect.y+ypos,
0,0,-1,rect,font::LEFT_ALIGN,&chat_message_bg,chat_message_border);
const int message_handle = font::add_floating_label(message_str.str(),12,chat_message_colour,
const int message_handle = font::add_floating_label(message_str.str(),font::SIZE_SMALL,chat_message_colour,
rect.x + chat_message_x + font::get_floating_label_rect(speaker_handle).w,rect.y+ypos,
0,0,-1,rect,font::LEFT_ALIGN,&chat_message_bg,chat_message_border);
@ -2266,7 +2266,7 @@ void display::set_diagnostic(const std::string& msg)
}
if(msg != "") {
diagnostic_label_ = font::add_floating_label(msg,16,font::YELLOW_COLOUR,300.0,50.0,0.0,0.0,-1,map_area());
diagnostic_label_ = font::add_floating_label(msg,font::SIZE_PLUS,font::YELLOW_COLOUR,300.0,50.0,0.0,0.0,-1,map_area());
}
}

View File

@ -43,11 +43,25 @@ enum MARKUP { USE_MARKUP, NO_MARKUP };
extern const char LARGE_TEXT, SMALL_TEXT, GOOD_TEXT, BAD_TEXT, NORMAL_TEXT, BLACK_TEXT, BOLD_TEXT, IMAGE, NULL_MARKUP;
// font sizes, probably to make theme parameters
#ifndef USE_TINY_GUI
const int SIZE_NORMAL = 14,
SIZE_TINY = 10,
SIZE_SMALL = 12
SIZE_SMALL = 12,
SIZE_PLUS = 16,
SIZE_LARGE = 18,
SIZE_XLARGE = 24
;
#else
const int SIZE_NORMAL = 10,
SIZE_TINY = 6,
SIZE_SMALL = 8,
SIZE_PLUS = 12,
SIZE_LARGE = 14,
SIZE_XLARGE = 20
;
#endif
//function to draw text on the screen. The text will be clipped to area.
//If the text runs outside of area horizontally, an ellipsis will be displayed
//at the end of it. If use_tooltips is true, then text with an ellipsis will

View File

@ -132,8 +132,8 @@ bool show_intro_part(display& screen, const config& part,
if(show_title) {
const SDL_Rect area = {0,0,screen.x(),screen.y()};
const SDL_Rect scenario_size =
font::draw_text(NULL,area,24,font::NORMAL_COLOUR,scenario,0,0);
update_rect(font::draw_text(&screen,area,24,font::NORMAL_COLOUR,scenario,
font::draw_text(NULL,area,font::SIZE_XLARGE,font::NORMAL_COLOUR,scenario,0,0);
update_rect(font::draw_text(&screen,area,font::SIZE_XLARGE,font::NORMAL_COLOUR,scenario,
dstrect.x,dstrect.y - scenario_size.h - 4));
}
@ -238,7 +238,7 @@ bool show_intro_part(display& screen, const config& part,
word += *k;
}
const SDL_Rect rect = font::draw_text(NULL,screen.screen_area(),
16,font::NORMAL_COLOUR,
font::SIZE_PLUS,font::NORMAL_COLOUR,
word,xpos,ypos,NULL,
false,font::NO_MARKUP);
@ -252,7 +252,7 @@ bool show_intro_part(display& screen, const config& part,
// output the character
const SDL_Rect rect = font::draw_text(&screen,
screen.screen_area(),16,
screen.screen_area(),font::SIZE_PLUS,
font::NORMAL_COLOUR,*j,xpos,ypos,
NULL,false,font::NO_MARKUP);
@ -310,7 +310,7 @@ void the_end(display& screen)
screen.video().flip();
const std::string text = _("The End");
const size_t font_size = 24;
const size_t font_size = font::SIZE_XLARGE;
area = font::text_area(text,font_size);
area.x = screen.screen_area().w/2 - area.w/2;

View File

@ -82,13 +82,13 @@ void default_map_generator::user_config(display& disp)
const std::string& villages_label = _("Villages") + std::string(":");
const std::string& landform_label = _("Landform") + std::string(":");
SDL_Rect players_rect = font::draw_text(NULL,disp.screen_area(),14,font::NORMAL_COLOUR,players_label,0,0);
SDL_Rect width_rect = font::draw_text(NULL,disp.screen_area(),14,font::NORMAL_COLOUR,width_label,0,0);
SDL_Rect height_rect = font::draw_text(NULL,disp.screen_area(),14,font::NORMAL_COLOUR,height_label,0,0);
SDL_Rect iterations_rect = font::draw_text(NULL,disp.screen_area(),14,font::NORMAL_COLOUR,iterations_label,0,0);
SDL_Rect hillsize_rect = font::draw_text(NULL,disp.screen_area(),14,font::NORMAL_COLOUR,hillsize_label,0,0);
SDL_Rect villages_rect = font::draw_text(NULL,disp.screen_area(),14,font::NORMAL_COLOUR,villages_label,0,0);
SDL_Rect landform_rect = font::draw_text(NULL,disp.screen_area(),14,font::NORMAL_COLOUR,landform_label,0,0);
SDL_Rect players_rect = font::draw_text(NULL,disp.screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,players_label,0,0);
SDL_Rect width_rect = font::draw_text(NULL,disp.screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,width_label,0,0);
SDL_Rect height_rect = font::draw_text(NULL,disp.screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,height_label,0,0);
SDL_Rect iterations_rect = font::draw_text(NULL,disp.screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,iterations_label,0,0);
SDL_Rect hillsize_rect = font::draw_text(NULL,disp.screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,hillsize_label,0,0);
SDL_Rect villages_rect = font::draw_text(NULL,disp.screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,villages_label,0,0);
SDL_Rect landform_rect = font::draw_text(NULL,disp.screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,landform_label,0,0);
const int horz_margin = 5;
const int text_right = xpos + horz_margin +
@ -218,37 +218,37 @@ void default_map_generator::user_config(display& disp)
events::raise_process_event();
events::raise_draw_event();
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,players_label,players_rect.x,players_rect.y);
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,width_label,width_rect.x,width_rect.y);
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,height_label,height_rect.x,height_rect.y);
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,iterations_label,iterations_rect.x,iterations_rect.y);
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,hillsize_label,hillsize_rect.x,hillsize_rect.y);
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,villages_label,villages_rect.x,villages_rect.y);
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,landform_label,landform_rect.x,landform_rect.y);
font::draw_text(&disp,disp.screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,players_label,players_rect.x,players_rect.y);
font::draw_text(&disp,disp.screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,width_label,width_rect.x,width_rect.y);
font::draw_text(&disp,disp.screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,height_label,height_rect.x,height_rect.y);
font::draw_text(&disp,disp.screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,iterations_label,iterations_rect.x,iterations_rect.y);
font::draw_text(&disp,disp.screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,hillsize_label,hillsize_rect.x,hillsize_rect.y);
font::draw_text(&disp,disp.screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,villages_label,villages_rect.x,villages_rect.y);
font::draw_text(&disp,disp.screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,landform_label,landform_rect.x,landform_rect.y);
std::stringstream players_str;
players_str << nplayers_;
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,players_str.str(),
font::draw_text(&disp,disp.screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,players_str.str(),
slider_right+horz_margin,players_rect.y);
std::stringstream width_str;
width_str << width_;
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,width_str.str(),
font::draw_text(&disp,disp.screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,width_str.str(),
slider_right+horz_margin,width_rect.y);
std::stringstream height_str;
height_str << height_;
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,height_str.str(),
font::draw_text(&disp,disp.screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,height_str.str(),
slider_right+horz_margin,height_rect.y);
std::stringstream villages_str;
villages_str << nvillages_ << _("/1000 tiles");
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,villages_str.str(),
font::draw_text(&disp,disp.screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,villages_str.str(),
slider_right+horz_margin,villages_rect.y);
std::stringstream landform_str;
landform_str << gettext(island_size_ == 0 ? N_("Inland") : (island_size_ < max_coastal ? N_("Coastal") : N_("Island")));
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,landform_str.str(),
font::draw_text(&disp,disp.screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,landform_str.str(),
slider_right+horz_margin,landform_rect.y);
update_rect(xpos,ypos,width,height);

View File

@ -173,7 +173,7 @@ void multiplayer_game_setup_dialog::set_area(const SDL_Rect& area)
int ypos = top + gui::draw_dialog_title(left,top,&disp_,_("Create Game")).h + border_size;
//Name Entry
ypos += font::draw_text(&disp_,disp_.screen_area(),12,font::GOOD_COLOUR,
ypos += font::draw_text(&disp_,disp_.screen_area(),font::SIZE_SMALL,font::GOOD_COLOUR,
_("Name of game") + std::string(":"),xpos,ypos).h + border_size;
string_map i18n_symbols;
i18n_symbols["login"] = preferences::login();
@ -188,7 +188,7 @@ void multiplayer_game_setup_dialog::set_area(const SDL_Rect& area)
//the map selection menu goes near the middle of the dialog, to the right of
//the minimap
const int map_label_height = font::draw_text(&disp_,disp_.screen_area(),12,font::GOOD_COLOUR,
const int map_label_height = font::draw_text(&disp_,disp_.screen_area(),font::SIZE_SMALL,font::GOOD_COLOUR,
_("Map to play") + std::string(":"),xpos + minimap_width + border_size,ypos).h;
maps_menu_->set_loc(xpos + minimap_width + border_size,ypos + map_label_height + border_size);
@ -201,7 +201,7 @@ void multiplayer_game_setup_dialog::set_area(const SDL_Rect& area)
rect.y = ypos;
rect.w = maximum<int>(0,right - border_size - rect.x);
//a font sized "12" isn't necessarily 12 pixel high.
rect.h = font::get_max_height(12);
rect.h = font::get_max_height(font::SIZE_SMALL);
turns_restorer_ = surface_restorer(&disp_.video(),rect);
@ -286,7 +286,7 @@ void multiplayer_game_setup_dialog::set_area(const SDL_Rect& area)
playernum_restorer_ = surface_restorer(&disp_.video(),player_num_rect);
SDL_Rect era_rect = {xpos,player_num_rect.y+player_num_rect.h + border_size,50,20};
era_rect = font::draw_text(&disp_,era_rect,12,font::GOOD_COLOUR,_("Era") + std::string(":"),
era_rect = font::draw_text(&disp_,era_rect,font::SIZE_SMALL,font::GOOD_COLOUR,_("Era") + std::string(":"),
era_rect.x,era_rect.y);
era_combo_->set_location(era_rect.x+era_rect.w+border_size,era_rect.y);
@ -351,7 +351,7 @@ lobby::RESULT multiplayer_game_setup_dialog::process()
turns_str = _("Unlimited");
}
font::draw_text(&disp_,disp_.screen_area(),12,font::GOOD_COLOUR,
font::draw_text(&disp_,disp_.screen_area(),font::SIZE_SMALL,font::GOOD_COLOUR,
_("Turns") + std::string(": ") + turns_str,
turns_restorer_.area().x,turns_restorer_.area().y);
@ -359,7 +359,7 @@ lobby::RESULT multiplayer_game_setup_dialog::process()
const int village_gold = village_gold_slider_->value();
village_gold_restorer_.restore();
sprintf(buf,": %d", village_gold);
font::draw_text(&disp_,disp_.screen_area(),12,font::GOOD_COLOUR,
font::draw_text(&disp_,disp_.screen_area(),font::SIZE_SMALL,font::GOOD_COLOUR,
_("Village Gold") + std::string(buf),
village_gold_restorer_.area().x,village_gold_restorer_.area().y);
@ -371,7 +371,7 @@ lobby::RESULT multiplayer_game_setup_dialog::process()
sprintf(buf,": %d%%", xpmod);
const SDL_Rect& xp_rect = xp_restorer_.area();
font::draw_text(&disp_,disp_.screen_area(),12,font::GOOD_COLOUR,
font::draw_text(&disp_,disp_.screen_area(),font::SIZE_SMALL,font::GOOD_COLOUR,
_("Experience Requirements") + std::string(buf),xp_rect.x,xp_rect.y);
bool map_changed = map_selection_ != maps_menu_->selection();
@ -416,7 +416,7 @@ lobby::RESULT multiplayer_game_setup_dialog::process()
playernum_restorer_.restore();
minimap_restorer_.restore();
const SDL_Rect& player_num_rect = playernum_restorer_.area();
font::draw_text(&disp_,disp_.screen_area(),12,font::GOOD_COLOUR,
font::draw_text(&disp_,disp_.screen_area(),font::SIZE_SMALL,font::GOOD_COLOUR,
" Load Map ",player_num_rect.x,player_num_rect.y);
}
}
@ -482,7 +482,7 @@ lobby::RESULT multiplayer_game_setup_dialog::process()
std::stringstream players;
players << _("Players") << ": " << nsides;
font::draw_text(&disp_,disp_.screen_area(),12,font::GOOD_COLOUR,
font::draw_text(&disp_,disp_.screen_area(),font::SIZE_SMALL,font::GOOD_COLOUR,
players.str(),players_rect.x,players_rect.y);
}
}