diff --git a/src/dialogs.cpp b/src/dialogs.cpp index 432c1450b39..3c142fdd51b 100644 --- a/src/dialogs.cpp +++ b/src/dialogs.cpp @@ -1021,92 +1021,6 @@ void show_unit_description(game_display &disp, const unit_type& t) help::show_unit_help(disp, t.id(), t.hide_help()); } - -namespace { - static const int campaign_preview_border = font::relative_size(10); -} - -campaign_preview_pane::campaign_preview_pane(CVideo &video,std::vector >* desc) : gui::preview_pane(video),descriptions_(desc),index_(0) -{ -// size of the campaign info window with the campaign description and image in pixel -#ifdef USE_TINY_GUI - set_measurements(160, 200); -#else - set_measurements(430, 440); -#endif -} - -bool campaign_preview_pane::show_above() const { return false; } -bool campaign_preview_pane::left_side() const { return false; } - -void campaign_preview_pane::set_selection(int index) -{ - index = std::min(descriptions_->size()-1,index); - if(index != index_ && index >= 0) { - index_ = index; - set_dirty(); - } -} - -void campaign_preview_pane::draw_contents() -{ - if (size_t(index_) >= descriptions_->size()) { - return; - } - - const SDL_Rect area = { - location().x+campaign_preview_border, - location().y, - location().w-campaign_preview_border*2, - location().h }; - - /* background frame */ - gui::dialog_frame f(video(), "", gui::dialog_frame::preview_style, false); - f.layout(area); - f.draw_background(); - f.draw_border(); - - /* description text */ - std::string desc_text; - try { - desc_text = font::word_wrap_text((*descriptions_)[index_].first, - font::SIZE_SMALL, area.w - 2 * campaign_preview_border); - } catch (utils::invalid_utf8_exception&) { - ERR_NG << "Invalid utf-8 found, campaign description is ignored.\n"; - } - const std::vector lines = utils::split(desc_text, '\n',utils::STRIP_SPACES); - SDL_Rect txt_area = { area.x+campaign_preview_border,area.y+campaign_preview_border,0,0 }; - - for(std::vector::const_iterator line = lines.begin(); line != lines.end(); ++line) { - txt_area = font::draw_text(&video(),location(),font::SIZE_SMALL,font::NORMAL_COLOUR,*line,txt_area.x,txt_area.y); - txt_area.y += txt_area.h; - } - - /* description image */ - surface img(NULL); - const std::string desc_img_name = (*descriptions_)[index_].second; - if(!desc_img_name.empty()) { - img.assign(image::get_image(desc_img_name)); - } - if (!img.null()) { - SDL_Rect src_rect,dst_rect; - int max_height = area.h-(txt_area.h+txt_area.y-area.y); - - src_rect.x = src_rect.y = 0; - src_rect.w = std::min(area.w,img->w); - src_rect.h = std::min(max_height,img->h); - dst_rect.x = area.x+(area.w-src_rect.w)/2; - dst_rect.y = txt_area.y+((max_height-src_rect.h)*8)/13; - if(dst_rect.y - txt_area.h - txt_area.y >= 120) { - //for really tall dialogs, just put it under the text - dst_rect.y = txt_area.y + font::get_max_height(font::SIZE_SMALL)*5; - } - - SDL_BlitSurface(img,&src_rect,video().getSurface(),&dst_rect); - - } -} - static network::connection network_data_dialog(display& disp, const std::string& msg, config& cfg, network::connection connection_num, network::statistics (*get_stats)(network::connection handle)) { #ifdef USE_TINY_GUI diff --git a/src/dialogs.hpp b/src/dialogs.hpp index 81f173ed51c..3e92e8ed3de 100644 --- a/src/dialogs.hpp +++ b/src/dialogs.hpp @@ -145,23 +145,6 @@ private: void show_unit_description(game_display &disp, const unit_type& t); void show_unit_description(game_display &disp, const unit& u); - -class campaign_preview_pane : public gui::preview_pane -{ -public: - campaign_preview_pane(CVideo &video,std::vector >* descriptions); - - bool show_above() const; - bool left_side() const; - void set_selection(int index); - -private: - void draw_contents(); - - const std::vector >* descriptions_; - int index_; -}; - network::connection network_send_dialog(display& disp, const std::string& msg, config& cfg, network::connection connection_num=0); network::connection network_receive_dialog(display& disp, const std::string& msg, config& cfg, network::connection connection_num=0); network::connection network_connect_dialog(display& disp, const std::string& msg, const std::string& hostname, int port);