Allow multiple background images in about,

...customizable by campaign, and put in a white drop-shadow on the text.
This commit is contained in:
John W. C. McNabb 2006-03-23 01:47:59 +00:00
parent 52f88bf53c
commit d6b4a2b667
6 changed files with 609 additions and 543 deletions

2
.gitignore vendored
View file

@ -40,3 +40,5 @@ wesnoth.ncb
wesnoth.opt
wesnoth.plg
zlib1.dll
userdata
stderr.txt

File diff suppressed because it is too large Load diff

View file

@ -16,6 +16,10 @@
description= _ "Fight to regain the throne of Wesnoth, of which you are the legitimate heir."
image=portraits/konrad.png
[about]
images = maps/wesnoth.png,story/httt_story1.jpg,story/httt_story2.jpg,story/httt_story3.jpg,story/httt_story4.jpg,story/httt_story5.jpg,story/httt_story6.jpg,story/httt_story7.jpg,story/httt_story8.jpg
[/about]
#textdomain wesnoth
[about]
title = _ "Campaign Designer"

View file

@ -23,7 +23,9 @@ namespace about
{
config about_list = config();
std::map<std::string , std::string> images;
std::string images_default;
std::vector<std::string> get_text(std::string campaign) {
static const char *credits[] = {
"_" N_("+Core Developers"),
@ -31,12 +33,12 @@ std::vector<std::string> get_text(std::string campaign) {
" David White (Sirp)",
"- ",
"_" N_("- Artwork and graphics designer"),
" Francisco Muñoz (fmunoz)",
" Francisco Muñoz (fmunoz)",
"_" N_("+Developers"),
"- Alfredo Beaumont (ziberpunk)",
"- András Salamon (ott)",
"- Benoît Timbert (Noyga)",
"- András Salamon (ott)",
"- Benoît Timbert (Noyga)",
"- Bram Ridder (Morloth)",
"- Bruno Wolff III",
"- Cedric Duval",
@ -44,12 +46,12 @@ std::vector<std::string> get_text(std::string campaign) {
"- Dominic Bolin (Xan)",
"- Guillaume Melquiond (silene)",
"- Isaac Clerencia",
"- Jan Zvánovec (jaz)",
"- Jérémy Rosen (Boucman)",
"- Jan Zvánovec (jaz)",
"- Jérémy Rosen (Boucman)",
"- John B. Messerly",
"- John W. C. McNabb (Darth Fool)",
"- Jon Daniel (forcemstr)",
"- Jörg Hinrichs (Yogi Bear/YogiHH)",
"- Jörg Hinrichs (Yogi Bear/YogiHH)",
"- Justin Zaun (jzaun)",
"- J.R. Blain (Cowboy)",
"- Kristoffer Erlandsson (erl)",
@ -59,6 +61,7 @@ std::vector<std::string> get_text(std::string campaign) {
"- Rusty Russell (rusty)",
"- Yann Dirson",
"- Zas",
"_" N_("+General Purpose Administrators"),
"- Crossbow/Miyo",
"- Isaac Clerencia",
@ -128,37 +131,57 @@ std::vector<std::string> get_text(std::string campaign) {
}
void set_about(const config& cfg){
config::child_list about = cfg.get_children("about");
for(config::child_list::const_iterator A = about.begin(); A != about.end(); A++) {
about_list.add_child("about",(**A));
}
config::child_list campaigns = cfg.get_children("campaign");
for(config::child_list::const_iterator C = campaigns.begin(); C != campaigns.end(); C++) {
config::child_list about = (**C).get_children("about");
if(about.size()){
config temp;
std::string text;
std::string title;
title=(**C)["name"];
temp["title"]=title;
temp["id"]=(**C)["id"];
for(config::child_list::const_iterator A = about.begin(); A != about.end(); A++) {
config AA = (**A);
std::string subtitle=AA["title"];
if(subtitle.size()){
if (subtitle[0] == '_')
subtitle = gettext(subtitle.substr(1,subtitle.size()-1).c_str()); }
text += subtitle + "\n";
std::vector<std::string> lines=utils::split(AA["text"],'\n');
for(std::vector<std::string>::iterator line=lines.begin();
line != lines.end(); line++){
text+=" "+(*line)+"\n";
config::child_list about = cfg.get_children("about");
for(config::child_list::const_iterator A = about.begin(); A != about.end(); A++) {
config AA = (**A);
about_list.add_child("about",AA);
if(!AA["images"].empty()){
std::cout<<"set here:"<<""<<":\n";
if(images_default.empty()){
images_default=AA["images"];
}else{
images_default+=","+AA["images"];
}
}
}
config::child_list campaigns = cfg.get_children("campaign");
for(config::child_list::const_iterator C = campaigns.begin(); C != campaigns.end(); C++) {
config::child_list about = (**C).get_children("about");
if(about.size()){
config temp;
std::string text;
std::string title;
std::string campaign=(**C)["id"];
title=(**C)["name"];
temp["title"]=title;
temp["id"]=(**C)["id"];
for(config::child_list::const_iterator A = about.begin(); A != about.end(); A++) {
config AA = (**A);
std::string subtitle=AA["title"];
if(subtitle.size()){
if (subtitle[0] == '_')
subtitle = gettext(subtitle.substr(1,subtitle.size()-1).c_str());
}
text += subtitle + "\n";
std::vector<std::string> lines=utils::split(AA["text"],'\n');
for(std::vector<std::string>::iterator line=lines.begin();
line != lines.end(); line++){
text+=" "+(*line)+"\n";
}
std::cout<<"set here:"<<title<<":\n";
if(!AA["images"].empty()){
std::cout<<"set here:"<<title<<":\n";
if(images[campaign].empty()){
images[campaign]=AA["images"];
}else{
images[campaign]+=","+AA["images"];
}
}
}
temp["text"]=text;
about_list.add_child("about",temp);
}
}
}
temp["text"]=text;
about_list.add_child("about",temp);
}
}
}
void show_about(display &disp, std::string campaign)
@ -173,14 +196,27 @@ void show_about(display &disp, std::string campaign)
draw_solid_tinted_rectangle(0,0,video.getx()-1,video.gety()-1,
0,0,0,1.0,video.getSurface());
update_whole_screen();
std::cout<<"got here:"<<campaign<<":\n";
std::vector<std::string> image_list;
if(campaign.size()){
image_list=utils::split(images[campaign]);
}else{
std::cout<<"got here--"<<images_default<<"--\n";
image_list=utils::split(images_default,',',utils::STRIP_SPACES);
std::cout<<"got here--"<<image_list[0]<<"--\n";
}
surface map_image(scale_surface(image::get_image(image_list[0],image::UNSCALED), disp.x(), disp.y()));
if(! map_image){
image_list[0]=game_config::game_title;
map_image=surface(scale_surface(image::get_image(image_list[0],image::UNSCALED), disp.x(), disp.y()));
}
const surface map_image(scale_surface(image::get_image(game_config::game_title,image::UNSCALED), disp.x(), disp.y()));
SDL_Rect map_rect;
map_rect.x = video.getx()/2 - map_image->w/2;
map_rect.y = video.gety()/2 - map_image->h/2;
map_rect.w = map_image->w;
map_rect.h = map_image->h;
gui::button close(video,_("Close"));
close.set_location((video.getx()/2)-(close.width()/2), video.gety() - 30);
close.set_volatile(true);
@ -224,10 +260,22 @@ void show_about(display &disp, std::string campaign)
CKey key;
bool last_escape;
int image_count=0;
do {
last_escape = key[SDLK_ESCAPE] != 0;
// check to see if background image has changed
std::cout<<"got here: "<<text.size()<<" : "<<startline<<":"<<image_count<<"<?"<<startline*(image_list.size())/text.size()<<"\n";
std::cout<<"\t"<< (text.size()) << ":" << ((image_count)) << ":"<< ((startline*(image_list.size())/text.size()))<<"\n";
std::cout<<std::flush;
if(text.size() && (image_count < ((startline*(int)image_list.size())/(int)text.size()))){
std::cout<<"\tgot count\n";
image_count++;
surface temp=surface(scale_surface(image::get_image(image_list[image_count],image::UNSCALED), disp.x(), disp.y()));
map_image=temp?temp:map_image;
}
// draw map to screen, thus erasing all text
SDL_BlitSurface(map_image,&middle_src,video.getSurface(),&middle_dest);
// draw one screen full of text
@ -237,8 +285,11 @@ void show_about(display &disp, std::string campaign)
int cur_line = 0;
do {
SDL_Rect tr2 = font::draw_text(&video,screen_area(),font::SIZE_XLARGE,font::NORMAL_COLOUR,
text[line], map_rect.x + map_rect.w / 8 + 1,y + 1);
SDL_Rect tr = font::draw_text(&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;
first_line_height = tr.h + line_spacing;
@ -258,8 +309,10 @@ void show_about(display &disp, std::string campaign)
offset -= first_line_height;
is_new_line = true;
startline++;
if(size_t(startline) == text.size())
if(size_t(startline) == text.size()){
startline = 0;
image_count = -1;
}
}
// mask off the upper and lower half of the map,

View file

@ -371,9 +371,9 @@ bool game_controller::init_config()
game_config::load_config(game_config_.child("game_config"));
hotkey::load_hotkeys(game_config_);
about::set_about(game_config_);
paths_manager_.set_paths(game_config_);
::init_textdomains(game_config_);
about::set_about(game_config_);
return true;
}

View file

@ -330,6 +330,7 @@ game_state read_game(const game_data& data, const config* cfg)
res.label = (*cfg)["label"];
res.version = (*cfg)["version"];
res.scenario = (*cfg)["scenario"];
res.campaign = (*cfg)["campaign"];
const config::child_list& players = cfg->get_children("player");
@ -442,6 +443,8 @@ void write_game(const game_state& game, config& cfg/*, WRITE_GAME_MODE mode*/)
cfg["scenario"] = game.scenario;
cfg["campaign"] = game.campaign;
cfg["campaign_type"] = game.campaign_type;
cfg["difficulty"] = game.difficulty;