cleanup of deps against display: fonts do not need a display at all

This commit is contained in:
Yann Dirson 2005-03-15 20:01:31 +00:00
parent 6853762579
commit a5a9f8205d
23 changed files with 105 additions and 105 deletions

View file

@ -382,7 +382,7 @@ void show_about(display& disp)
int cur_line = 0;
do {
SDL_Rect tr = font::draw_text(&disp,disp.screen_area(),font::SIZE_XLARGE,font::BLACK_COLOUR,
SDL_Rect tr = font::draw_text(&disp.video(),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

@ -390,7 +390,7 @@ void save_preview_pane::draw_contents()
}
}
font::draw_text(&disp(), area, font::SIZE_SMALL, font::NORMAL_COLOUR, str.str(), area.x, ypos, true);
font::draw_text(&disp().video(), area, font::SIZE_SMALL, font::NORMAL_COLOUR, str.str(), area.x, ypos, true);
}
} //end anon namespace
@ -637,7 +637,7 @@ void unit_preview_pane::draw_contents()
desc << font::NORMAL_TEXT << u.description();
const std::string description = desc.str();
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);
description_rect = font::draw_text(&disp().video(),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,7 +716,7 @@ void unit_preview_pane::draw_contents()
xpos = cur_area.x + cur_area.w - line_area.w;
}
cur_area = font::draw_text(&disp(),location(),font::SIZE_SMALL,font::NORMAL_COLOUR,*line,xpos,cur_area.y);
cur_area = font::draw_text(&disp().video(),location(),font::SIZE_SMALL,font::NORMAL_COLOUR,*line,xpos,cur_area.y);
cur_area.y += cur_area.h;
}
}
@ -779,7 +779,7 @@ void campaign_preview_pane::draw_contents()
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(),font::SIZE_SMALL,font::NORMAL_COLOUR,*line,txt_area.x,txt_area.y);
txt_area = font::draw_text(&disp().video(),location(),font::SIZE_SMALL,font::NORMAL_COLOUR,*line,txt_area.x,txt_area.y);
txt_area.y += txt_area.h;
}

View file

@ -567,13 +567,13 @@ void draw_panel(display& disp, const theme::panel& panel, std::vector<gui::butto
}
}
void draw_label(display& disp, surface target, const theme::label& label)
void draw_label(CVideo& video, surface target, const theme::label& label)
{
//log_scope("draw label");
const std::string& text = label.text();
const std::string& icon = label.icon();
SDL_Rect& loc = label.location(disp.screen_area());
SDL_Rect& loc = label.location(screen_area());
if(icon.empty() == false) {
surface surf(image::get_image(icon,image::UNSCALED));
@ -587,7 +587,7 @@ void draw_label(display& disp, surface target, const theme::label& label)
tooltips::add_tooltip(loc,text);
}
} else if(text.empty() == false) {
font::draw_text(&disp,loc,label.font_size(),font::NORMAL_COLOUR,text,loc.x,loc.y);
font::draw_text(&video,loc,label.font_size(),font::NORMAL_COLOUR,text,loc.x,loc.y);
}
@ -613,7 +613,7 @@ void display::draw(bool update,bool force)
const std::vector<theme::label>& labels = theme_.labels();
for(std::vector<theme::label>::const_iterator i = labels.begin(); i != labels.end(); ++i) {
draw_label(*this,screen,*i);
draw_label(video(),screen,*i);
}
//invalidate the reports so they are redrawn
@ -865,7 +865,7 @@ void display::draw_report(reports::TYPE report_num)
for(reports::report::iterator i = report.begin(); i != report.end(); ++i) {
if(i->text.empty() == false) {
// Draw a text element
area = font::draw_text(this,rect,item->font_size(),font::NORMAL_COLOUR,i->text,x,y);
area = font::draw_text(&screen_,rect,item->font_size(),font::NORMAL_COLOUR,i->text,x,y);
if(area.h > tallest) tallest = area.h;
if(i->text[i->text.size() - 1] == '\n') {
x = rect.x;
@ -1017,7 +1017,7 @@ void display::draw_unit_details(int x, int y, const gamemap::location& loc,
//with on the right-side panel
const size_t font_size = this->y() >= 700 ? 13 : 10;
description_rect = font::draw_text(this,clipRect,font_size,font::NORMAL_COLOUR,
description_rect = font::draw_text(&screen_,clipRect,font_size,font::NORMAL_COLOUR,
details.str(),x,y);
update_rect(description_rect);
@ -1608,15 +1608,15 @@ void display::draw_footstep(const gamemap::location& loc, int xloc, int yloc)
const int y = yloc + zoom_/2 - text_area.h/2;
//draw the text with a black outline
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);
font::draw_text(&screen_,rect,font::SIZE_LARGE,font::DARK_COLOUR,str,x-1,y-1);
font::draw_text(&screen_,rect,font::SIZE_LARGE,font::DARK_COLOUR,str,x-1,y);
font::draw_text(&screen_,rect,font::SIZE_LARGE,font::DARK_COLOUR,str,x-1,y+1);
font::draw_text(&screen_,rect,font::SIZE_LARGE,font::DARK_COLOUR,str,x,y-1);
font::draw_text(&screen_,rect,font::SIZE_LARGE,font::DARK_COLOUR,str,x+1,y-1);
font::draw_text(&screen_,rect,font::SIZE_LARGE,font::DARK_COLOUR,str,x+1,y);
font::draw_text(&screen_,rect,font::SIZE_LARGE,font::DARK_COLOUR,str,x+1,y+1);
font::draw_text(&screen_,rect,font::SIZE_LARGE,font::DARK_COLOUR,str,x,y+1);
font::draw_text(&screen_,rect,font::SIZE_LARGE,font::YELLOW_COLOUR,str,x,y);
}
}

View file

@ -70,15 +70,15 @@ std::string new_map_dialog(display& disp, gamemap::TERRAIN fill_terrain,
gui::draw_dialog_frame(xpos,ypos,width,height,disp);
SDL_Rect title_rect = font::draw_text(NULL,disp.screen_area(),24,font::NORMAL_COLOUR,
SDL_Rect title_rect = font::draw_text(NULL,screen_area(),24,font::NORMAL_COLOUR,
_("Create New Map"),0,0);
const std::string& width_label = _("Width:");
const std::string& height_label = _("Height:");
SDL_Rect width_rect = font::draw_text(NULL, disp.screen_area(), 14, font::NORMAL_COLOUR,
SDL_Rect width_rect = font::draw_text(NULL, 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,
SDL_Rect height_rect = font::draw_text(NULL, screen_area(), 14, font::NORMAL_COLOUR,
height_label, 0, 0);
const int text_right = xpos + horz_margin +
@ -191,23 +191,23 @@ std::string new_map_dialog(display& disp, gamemap::TERRAIN fill_terrain,
map_width = width_slider.value();
map_height = height_slider.value();
gui::draw_dialog_frame(xpos,ypos,width,height,disp);
title_rect = font::draw_text(&disp,disp.screen_area(),24,font::NORMAL_COLOUR,
title_rect = font::draw_text(&disp.video(),screen_area(),24,font::NORMAL_COLOUR,
_("Create New Map"),
xpos+(width-title_rect.w)/2,ypos+10);
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,
font::draw_text(&disp.video(),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,
font::draw_text(&disp.video(),screen_area(),14,font::NORMAL_COLOUR,
height_label,height_rect.x,height_rect.y);
std::stringstream width_str;
width_str << map_width;
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,width_str.str(),
font::draw_text(&disp.video(),screen_area(),14,font::NORMAL_COLOUR,width_str.str(),
slider_right+horz_margin,width_rect.y);
std::stringstream height_str;
height_str << map_height;
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,height_str.str(),
font::draw_text(&disp.video(),screen_area(),14,font::NORMAL_COLOUR,height_str.str(),
slider_right+horz_margin,height_rect.y);
}
@ -325,10 +325,10 @@ void preferences_dialog(display &disp, config &prefs) {
hotkeys_button.set_dirty();
scroll_slider.set_dirty();
font::draw_text(&disp,clip_rect,14,font::NORMAL_COLOUR,scroll_label,
font::draw_text(&disp.video(),clip_rect,14,font::NORMAL_COLOUR,scroll_label,
scroll_rect.x,scroll_rect.y);
update_rect(disp.screen_area());
update_rect(screen_area());
redraw_all = false;
}
@ -384,15 +384,15 @@ resize_dialog(display &disp, const unsigned curr_w, const unsigned curr_h) {
gui::draw_dialog_frame(xpos,ypos,width,height,disp);
SDL_Rect title_rect = font::draw_text(NULL,disp.screen_area(),24,font::NORMAL_COLOUR,
SDL_Rect title_rect = font::draw_text(NULL,screen_area(),24,font::NORMAL_COLOUR,
_("Resize Map"),0,0);
const std::string& width_label = _("Width:");
const std::string& height_label = _("Height:");
SDL_Rect width_rect = font::draw_text(NULL, disp.screen_area(), 14, font::NORMAL_COLOUR,
SDL_Rect width_rect = font::draw_text(NULL, 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,
SDL_Rect height_rect = font::draw_text(NULL, screen_area(), 14, font::NORMAL_COLOUR,
height_label, 0, 0);
const int text_right = xpos + horz_margin +
@ -444,23 +444,23 @@ resize_dialog(display &disp, const unsigned curr_w, const unsigned curr_h) {
map_width = width_slider.value();
map_height = height_slider.value();
gui::draw_dialog_frame(xpos,ypos,width,height,disp);
title_rect = font::draw_text(&disp,disp.screen_area(),24,font::NORMAL_COLOUR,
title_rect = font::draw_text(&disp.video(),screen_area(),24,font::NORMAL_COLOUR,
_("Resize Map"),
xpos+(width-title_rect.w)/2,ypos+10);
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,
font::draw_text(&disp.video(),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,
font::draw_text(&disp.video(),screen_area(),14,font::NORMAL_COLOUR,
height_label,height_rect.x,height_rect.y);
std::stringstream width_str;
width_str << map_width;
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,width_str.str(),
font::draw_text(&disp.video(),screen_area(),14,font::NORMAL_COLOUR,width_str.str(),
slider_right+horz_margin,width_rect.y);
std::stringstream height_str;
height_str << map_height;
font::draw_text(&disp,disp.screen_area(),14,font::NORMAL_COLOUR,height_str.str(),
font::draw_text(&disp.video(),screen_area(),14,font::NORMAL_COLOUR,height_str.str(),
slider_right+horz_margin,height_rect.y);
}

View file

@ -14,7 +14,6 @@
#include "wesconfig.h"
#include "global.hpp"
#include "display.hpp"
#include "font.hpp"
#include "filesystem.hpp"
#include "game_config.hpp"
@ -718,7 +717,7 @@ SDL_Rect draw_text_line(surface gui_surface, const SDL_Rect& area, int size,
return dest;
}
SDL_Rect draw_text_line(display* gui, const SDL_Rect& area, int size,
SDL_Rect draw_text_line(CVideo* gui, const SDL_Rect& area, int size,
const SDL_Color& colour, const std::string& text,
int x, int y, bool use_tooltips, int style)
{
@ -727,7 +726,7 @@ SDL_Rect draw_text_line(display* gui, const SDL_Rect& area, int size,
if(gui == NULL) {
surface = NULL;
} else {
surface = gui->video().getSurface();
surface = gui->getSurface();
}
return draw_text_line(surface, area, size, colour, text, x, y, use_tooltips, style);
@ -739,7 +738,7 @@ SDL_Rect text_area(const std::string& text, int size, int style)
return draw_text(NULL, area, size, font::NORMAL_COLOUR, text, 0, 0, false, style);
}
SDL_Rect draw_text(display* gui, const SDL_Rect& area, int size,
SDL_Rect draw_text(CVideo* gui, const SDL_Rect& area, int size,
const SDL_Color& colour, const std::string& txt,
int x, int y, bool use_tooltips, int style)
{
@ -926,7 +925,7 @@ std::string make_text_ellipsis(const std::string &text, int font_size, int max_w
return text; // Should not happen
}
SDL_Rect draw_wrapped_text(display* gui, const SDL_Rect& area, int font_size,
SDL_Rect draw_wrapped_text(CVideo* gui, const SDL_Rect& area, int font_size,
const SDL_Color& colour, const std::string& text,
int x, int y, int max_width)
{

View file

@ -16,7 +16,7 @@
#include "SDL.h"
#include "SDL_ttf.h"
class display;
class CVideo;
#include "sdl_utils.hpp"
#include "serialization/string_utils.hpp"
@ -88,7 +88,7 @@ const int
//a bounding rectangle of the text is returned. If gui is NULL, then the
//text will not be drawn, and a bounding rectangle only will be returned.
SDL_Rect draw_text(display* gui, const SDL_Rect& area, int size,
SDL_Rect draw_text(CVideo* gui, const SDL_Rect& area, int size,
const SDL_Color& colour, const std::string& text,
int x, int y, bool use_tooltips = false, int style = 0);
@ -134,7 +134,7 @@ std::string make_text_ellipsis(const std::string& text, int font_size, int max_w
///
/// @return a bounding rectangle of the text.
///
SDL_Rect draw_wrapped_text(display* gui, const SDL_Rect& area, int font_size,
SDL_Rect draw_wrapped_text(CVideo* gui, const SDL_Rect& area, int font_size,
const SDL_Color& colour, const std::string& text,
int x, int y, int max_width);

View file

@ -1429,7 +1429,7 @@ void game_controller::play_game(RELOAD_GAME_DATA reload)
try {
const LEVEL_RESULT result = ::play_game(disp(),state_,game_config_,units_data_,video_);
if(result == VICTORY) {
the_end(disp());
the_end(disp().video());
about::show_about(disp());
}
} catch(gamestatus::load_game_exception& e) {

View file

@ -140,8 +140,8 @@ bool show_intro_part(display& screen, const config& part,
const SDL_Rect area = {0,0,screen.x(),screen.y()};
const SDL_Rect scenario_size =
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));
update_rect(font::draw_text(&screen.video(),area,font::SIZE_XLARGE,font::NORMAL_COLOUR,scenario,
dstrect.x,dstrect.y - scenario_size.h - 4));
}
update_whole_screen();
@ -257,7 +257,7 @@ bool show_intro_part(display& screen, const config& part,
// FIXME: this is broken: it does not take kerning into account.
std::string tmp;
tmp.append(itor.substr().first, itor.substr().second);
const SDL_Rect rect = font::draw_text(&screen,
const SDL_Rect rect = font::draw_text(&screen.video(),
screen.screen_area(),font::SIZE_PLUS,
font::NORMAL_COLOUR,tmp,xpos,ypos,
false);
@ -303,28 +303,28 @@ bool show_intro_part(display& screen, const config& part,
return true;
}
void the_end(display& screen)
void the_end(CVideo& screen)
{
SDL_Rect area = screen.screen_area();
SDL_FillRect(screen.video().getSurface(),&area,0);
SDL_Rect area = screen_area();
SDL_FillRect(screen.getSurface(),&area,0);
update_whole_screen();
screen.video().flip();
screen.flip();
const std::string text = _("The End");
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;
area.y = screen.screen_area().h/2 - area.h/2;
area.x = screen_area().w/2 - area.w/2;
area.y = screen_area().h/2 - area.h/2;
for(size_t n = 0; n < 255; n += 5) {
const SDL_Color col = {n,n,n,n};
font::draw_text(&screen,area,font_size,col,text,area.x,area.y);
update_rect(area);
screen.video().flip();
screen.flip();
SDL_FillRect(screen.video().getSurface(),&area,0);
SDL_FillRect(screen.getSurface(),&area,0);
SDL_Delay(10);
}

View file

@ -14,6 +14,7 @@
#define INTRO_HPP_INCLUDED
class config;
class CVideo;
class display;
#include "SDL.h"
@ -33,6 +34,6 @@ class display;
//user able to go to the next part, or skip it entirely.
void show_intro(display& screen, const config& data, const config& level);
void the_end(display& screen);
void the_end(CVideo& screen);
#endif

View file

@ -89,13 +89,13 @@ void default_map_generator::user_config(display& disp)
const std::string& villages_label = _("Villages:");
const std::string& landform_label = _("Landform:");
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);
SDL_Rect players_rect = font::draw_text(NULL,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,players_label,0,0);
SDL_Rect width_rect = font::draw_text(NULL,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,width_label,0,0);
SDL_Rect height_rect = font::draw_text(NULL,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,height_label,0,0);
SDL_Rect iterations_rect = font::draw_text(NULL,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,iterations_label,0,0);
SDL_Rect hillsize_rect = font::draw_text(NULL,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,hillsize_label,0,0);
SDL_Rect villages_rect = font::draw_text(NULL,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,villages_label,0,0);
SDL_Rect landform_rect = font::draw_text(NULL,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,landform_label,0,0);
const int horz_margin = 5;
const int text_right = xpos + horz_margin +
@ -226,37 +226,37 @@ void default_map_generator::user_config(display& disp)
events::raise_process_event();
events::raise_draw_event();
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);
font::draw_text(&disp.video(),screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,players_label,players_rect.x,players_rect.y);
font::draw_text(&disp.video(),screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,width_label,width_rect.x,width_rect.y);
font::draw_text(&disp.video(),screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,height_label,height_rect.x,height_rect.y);
font::draw_text(&disp.video(),screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,iterations_label,iterations_rect.x,iterations_rect.y);
font::draw_text(&disp.video(),screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,hillsize_label,hillsize_rect.x,hillsize_rect.y);
font::draw_text(&disp.video(),screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOUR,villages_label,villages_rect.x,villages_rect.y);
font::draw_text(&disp.video(),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(),font::SIZE_NORMAL,font::NORMAL_COLOUR,players_str.str(),
font::draw_text(&disp.video(),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(),font::SIZE_NORMAL,font::NORMAL_COLOUR,width_str.str(),
font::draw_text(&disp.video(),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(),font::SIZE_NORMAL,font::NORMAL_COLOUR,height_str.str(),
font::draw_text(&disp.video(),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(),font::SIZE_NORMAL,font::NORMAL_COLOUR,villages_str.str(),
font::draw_text(&disp.video(),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(),font::SIZE_NORMAL,font::NORMAL_COLOUR,landform_str.str(),
font::draw_text(&disp.video(),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

@ -758,7 +758,7 @@ void connect::layout_children(const SDL_Rect& rect)
bottom-left_button->height()-gui::ButtonVPadding);
// Title and labels
gui::draw_dialog_title(left,top,&disp(),_("Game Lobby"));
gui::draw_dialog_title(left,top,&disp().video(),_("Game Lobby"));
type_title_label_.set_location((left+30)+(launch_.width()/2)-(type_title_label_.width()/2),top+35);
faction_title_label_.set_location((left+145)+(launch_.width()/2)-(faction_title_label_.width()/2),top+35);

View file

@ -376,7 +376,7 @@ void create::layout_children(const SDL_Rect& rect)
int ypos = ca.y;
// Dialog title
ypos += gui::draw_dialog_title(xpos, ypos, &disp(), _("Create Game")).h + border_size;
ypos += gui::draw_dialog_title(xpos, ypos, &disp().video(), _("Create Game")).h + border_size;
// Name Entry
name_entry_label_.set_location(xpos, ypos);

View file

@ -108,10 +108,10 @@ void wait::leader_preview_pane::draw_contents()
SDL_BlitSurface(unit_image,NULL,screen,&image_rect);
}
font::draw_text(&disp(),area,font::SIZE_PLUS,font::NORMAL_COLOUR,faction,area.x + 80, area.y + 30);
const SDL_Rect leader_rect = font::draw_text(&disp(),area,font::SIZE_SMALL,font::NORMAL_COLOUR,
font::draw_text(&disp().video(),area,font::SIZE_PLUS,font::NORMAL_COLOUR,faction,area.x + 80, area.y + 30);
const SDL_Rect leader_rect = font::draw_text(&disp().video(),area,font::SIZE_SMALL,font::NORMAL_COLOUR,
_("Leader: "),area.x, area.y + 80);
font::draw_wrapped_text(&disp(),area,font::SIZE_SMALL,font::NORMAL_COLOUR,
font::draw_wrapped_text(&disp().video(),area,font::SIZE_SMALL,font::NORMAL_COLOUR,
_("Recruits: ") + recruit_string.str(),area.x, area.y + 102,
area.w);

View file

@ -1193,7 +1193,7 @@ void show_hotkeys_dialog (display & disp, config *save_config)
centery-text_size.h/2 - 6,
text_size.w+40,
text_size.h+12,disp);
font::draw_text (&disp, clip_rect, font::SIZE_LARGE,font::NORMAL_COLOUR,
font::draw_text (&disp.video(), clip_rect, font::SIZE_LARGE,font::NORMAL_COLOUR,
_("Press desired HotKey"),centerx-text_size.w/2-10,
centery-text_size.h/2-3);
disp.update_display();

View file

@ -204,11 +204,11 @@ void draw_dialog_background(int x, int y, int w, int h, display& disp, const std
}
}
SDL_Rect draw_dialog_title(int x, int y, display* disp, const std::string& text)
SDL_Rect draw_dialog_title(int x, int y, CVideo* disp, const std::string& text)
{
SDL_Rect rect = {0,0,10000,10000};
if(disp != NULL) {
rect = disp->screen_area();
rect = screen_area();
}
return font::draw_text(disp, rect, font::SIZE_LARGE, font::TITLE_COLOUR,
@ -257,7 +257,7 @@ void draw_dialog(int x, int y, int w, int h, display& disp, const std::string& t
draw_dialog_frame(xpos,ypos,width,height,disp,style,restorer);
if (!title.empty()) {
draw_dialog_title(x + border_size, y - title_area.h, &disp, title);
draw_dialog_title(x + border_size, y - title_area.h, &disp.video(), title);
}
if(buttons != NULL) {
@ -696,7 +696,7 @@ int show_dialog(display& disp, surface image,
text_widget_width - text_widget.location().w,
text_widget_y_unpadded);
events::raise_draw_event();
font::draw_text(&disp, clipRect, message_font_size,
font::draw_text(&disp.video(), clipRect, message_font_size,
font::NORMAL_COLOUR, text_widget_label,
xloc + left_padding,text_widget_y_unpadded);
}
@ -713,13 +713,13 @@ int show_dialog(display& disp, surface image,
disp.blit_surface(x,y,image);
font::draw_text(&disp, clipRect, caption_font_size,
font::draw_text(&disp.video(), clipRect, caption_font_size,
font::NORMAL_COLOUR, caption,
xloc+image_width+left_padding+image_h_padding,
yloc+top_padding);
}
font::draw_text(&disp, clipRect, message_font_size,
font::draw_text(&disp.video(), clipRect, message_font_size,
font::NORMAL_COLOUR, message,
xloc+image_width+left_padding+image_h_padding,
yloc+top_padding+caption_size.h);

View file

@ -58,7 +58,7 @@ void draw_solid_tinted_rectangle(int x, int y, int w, int h,
//given the location of a dialog, will draw its title.
//Returns the area the title takes up
SDL_Rect draw_dialog_title(int x, int y, display* disp, const std::string& text);
SDL_Rect draw_dialog_title(int x, int y, CVideo* disp, const std::string& text);
//function to draw a dialog on the screen. x,y,w,h give the dimensions of the client area
//of the dialog. 'title' is the title of the dialog. The title will be displayed at the

View file

@ -155,7 +155,7 @@ TITLE_RESULT show_title(display& screen, config& tips_of_day, int* ntip)
ERR_DP << "Could not find title image\n";
} else {
screen.blit_surface(0,0,title_surface);
update_rect(screen.screen_area());
update_rect(screen_area());
LOG_DP << "displayed title image\n";
}
@ -167,13 +167,13 @@ TITLE_RESULT show_title(display& screen, config& tips_of_day, int* ntip)
const std::string& version_str = _("Version") + std::string(" ") +
game_config::version;
const SDL_Rect version_area = font::draw_text(NULL,screen.screen_area(),
const SDL_Rect version_area = font::draw_text(NULL,screen_area(),
font::SIZE_TINY,
font::NORMAL_COLOUR,version_str,0,0);
const size_t versiony = screen.y() - version_area.h;
if(versiony < size_t(screen.y())) {
font::draw_text(&screen,screen.screen_area(),
font::draw_text(&screen.video(),screen.screen_area(),
font::SIZE_TINY,
font::NORMAL_COLOUR,version_str,0,versiony);
}
@ -255,8 +255,8 @@ TITLE_RESULT show_title(display& screen, config& tips_of_day, int* ntip)
draw_dialog_frame(area.x,area.y,area.w,area.h,screen,&style);
font::draw_text(&screen,area,font::SIZE_NORMAL,font::NORMAL_COLOUR,tip_of_day,area.x+pad,area.y+pad);
font::draw_text(&screen, area, font::SIZE_NORMAL, font::NORMAL_COLOUR,
font::draw_text(&screen.video(),area,font::SIZE_NORMAL,font::NORMAL_COLOUR,tip_of_day,area.x+pad,area.y+pad);
font::draw_text(&screen.video(), area, font::SIZE_NORMAL, font::NORMAL_COLOUR,
tome, area.x + area.w - tome_area.w - pad,
next_tip_button.location().y - tome_area.h - pad, false, TTF_STYLE_ITALIC);
}

View file

@ -156,7 +156,7 @@ void process(int mousex, int mousey)
current_tooltip = tips.end();
}
SDL_Rect draw_text(display* gui, const SDL_Rect& area, int size,
SDL_Rect draw_text(CVideo* gui, const SDL_Rect& area, int size,
const SDL_Color& colour, const std::string& text,
int x, int y)
{

View file

@ -2,7 +2,6 @@
#define TOOLTIPS_HPP_INCLUDED
class CVideo;
class display;
#include "SDL.h"
@ -10,7 +9,7 @@ namespace tooltips {
struct manager
{
manager(CVideo& disp);
manager(CVideo& video);
~manager();
};
@ -22,7 +21,7 @@ void process(int mousex, int mousey);
//a function exactly the same as font::draw_text, but will also register
//a tooltip
SDL_Rect draw_text(display* gui, const SDL_Rect& area, int size,
SDL_Rect draw_text(CVideo* gui, const SDL_Rect& area, int size,
const SDL_Color& colour, const std::string& text,
int x, int y);

View file

@ -157,7 +157,7 @@ void button::draw_contents()
break;
}
SDL_Rect const &clipArea = disp().screen_area();
SDL_Rect const &clipArea = screen_area();
SDL_Rect const &loc = location();
const int texty = loc.y + loc.h / 2 - textRect_.h / 2 + offset;
int textx;
@ -172,7 +172,7 @@ void button::draw_contents()
disp().blit_surface(loc.x, loc.y, image);
const std::string etext = font::make_text_ellipsis(label_, font_size, loc.w);
font::draw_text(&disp(), clipArea, font_size, font::BUTTON_COLOUR, etext, textx, texty);
font::draw_text(&disp().video(), clipArea, font_size, font::BUTTON_COLOUR, etext, textx, texty);
update_rect(loc);
}

View file

@ -16,6 +16,7 @@
#include "label.hpp"
#include "../display.hpp"
#include "../font.hpp"
#include "../video.hpp"
namespace gui {
@ -67,7 +68,7 @@ const SDL_Color& label::get_colour() const
void label::draw_contents()
{
font::draw_text(&disp(), disp().screen_area(), size_, colour_, text_, location().x, location().y);
font::draw_text(&disp().video(), screen_area(), size_, colour_, text_, location().x, location().y);
}
void label::update_label_size()

View file

@ -429,7 +429,7 @@ void menu::draw_item(int item)
font::make_text_ellipsis(str, menu_font_size, loc.w - (xpos - rect.x)) : str;
const SDL_Rect& text_size = font::text_area(str,menu_font_size);
const size_t y = rect.y + (rect.h - text_size.h)/2;
font::draw_text(&disp(),area,menu_font_size,font::NORMAL_COLOUR,to_show,xpos,y);
font::draw_text(&disp().video(),area,menu_font_size,font::NORMAL_COLOUR,to_show,xpos,y);
xpos += text_size.w + 5;
}
}

View file

@ -37,7 +37,7 @@ void progress_bar::draw_contents()
text_area.x = area.x + area.w/2 - text_area.w/2;
text_area.y = area.y + area.h/2 - text_area.h/2;
font::draw_text(&disp(),location(),font::SIZE_NORMAL,font::BLACK_COLOUR,text,text_area.x,text_area.y);
font::draw_text(&disp().video(),location(),font::SIZE_NORMAL,font::BLACK_COLOUR,text,text_area.x,text_area.y);
}
update_rect(location());