Added [if] [then] [else] functionality to [bigmap]

I have needed to move some lines up the creation of the events_manager
to do this, I think it doesn't break anything else, closes bug #9719
This commit is contained in:
Isaac Clerencia Perez 2004-07-27 16:53:57 +00:00
parent 35500b6027
commit 7d537053b2
3 changed files with 55 additions and 32 deletions

View file

@ -227,29 +227,8 @@ bool show_intro_part(display& screen, const config& part,
return true;
}
void show_map_scene(display& screen, config& data)
{
std::cerr << "showing map scene...\n";
//stop the screen being resized while we're in this function
const events::resize_lock stop_resizing;
const events::event_context context;
//clear the screen
gui::draw_solid_tinted_rectangle(0,0,screen.x()-1,screen.y()-1,0,0,0,1.0,
screen.video().getSurface());
const config* const cfg_item = data.child("bigmap");
if(cfg_item == NULL) {
std::cerr << "no map scene...\n";
return;
}
const config& cfg = *cfg_item;
const config::child_list& dots = cfg.get_children("dot");
const std::string& image_file = cfg["image"];
void display_map_scene(display& screen, const std::string& scenario,
const config::child_list& dots, const std::string& image_file) {
const surface image(image::get_image(image_file,image::UNSCALED));
const surface dot_image(image::get_image(game_config::dot_image,image::UNSCALED));
@ -274,11 +253,6 @@ void show_map_scene(display& screen, config& data)
SDL_BlitSurface(image,NULL,screen.video().getSurface(),&dstrect);
update_whole_screen();
const std::string& id = data.values["id"];
const std::string& scenario_name = string_table[id];
const std::string& scenario = scenario_name.empty() ? data.values["name"] :
scenario_name;
screen.video().flip();
CKey key;
@ -380,3 +354,51 @@ void show_map_scene(display& screen, config& data)
gui::draw_solid_tinted_rectangle(0,0,screen.x()-1,screen.y()-1,0,0,0,1.0,
screen.video().getSurface());
}
void show_map_scene(display& screen, config& data, game_state& state_of_game)
{
std::cerr << "showing map scene...\n";
//stop the screen being resized while we're in this function
const events::resize_lock stop_resizing;
const events::event_context context;
//clear the screen
gui::draw_solid_tinted_rectangle(0,0,screen.x()-1,screen.y()-1,0,0,0,1.0,
screen.video().getSurface());
const config* const cfg_item = data.child("bigmap");
if(cfg_item == NULL) {
std::cerr << "no map scene...\n";
return;
}
const std::string& id = data.values["id"];
const std::string& scenario_name = string_table[id];
const std::string& scenario = scenario_name.empty() ? data.values["name"] :
scenario_name;
const config& cfg = *cfg_item;
config::all_children_iterator i = cfg.ordered_begin();
std::pair<const std::string*, const config*> item = *i;
if(*item.first == "if") {
const std::string type = game_events::conditional_passed(
state_of_game, NULL, *item.second) ? "then":"else";
const config* const thens = (*item.second).child(type);
if(thens == NULL) {
std::cerr << "no map scene this way...\n";
return;
}
const config& selection = *thens;
const config::child_list& dots = selection.get_children("dot");
const std::string& image_file = selection["image"];
display_map_scene(screen, scenario, dots, image_file);
}else{
const config::child_list& dots = cfg.get_children("dot");
const std::string& image_file = cfg["image"];
display_map_scene(screen, scenario, dots, image_file);
}
}

View file

@ -49,6 +49,6 @@ void show_intro(display& screen, const config& data, game_state& state_of_game);
//where 'map-image' is the image of the map. dots are displayed
//at 'x','y' on the image in sequence. type=cross should be used
//for the last dot, to show where the battle takes place.
void show_map_scene(display& screen, config& data);
void show_map_scene(display& screen, config& data, game_state& state_of_game);
#endif

View file

@ -315,13 +315,16 @@ LEVEL_RESULT play_level(game_data& gameinfo, const config& game_config,
std::cerr << "b... " << (SDL_GetTicks() - ticks) << "\n";
game_events::manager events_manager(*level,gui,map,units,teams,
state_of_game,status,gameinfo);
if(recorder.skipping() == false) {
for(std::vector<config*>::const_iterator story_i = story.begin();
story_i != story.end(); ++story_i) {
show_intro(gui,**story_i, state_of_game);
}
show_map_scene(gui,*level);
show_map_scene(gui,*level,state_of_game);
}
std::cerr << "c... " << (SDL_GetTicks() - ticks) << "\n";
@ -338,8 +341,6 @@ LEVEL_RESULT play_level(game_data& gameinfo, const config& game_config,
std::cerr << "initializing events manager... " << (SDL_GetTicks() - ticks) << "\n";
game_events::manager events_manager(*level,gui,map,units,teams,
state_of_game,status,gameinfo);
help::help_manager help_manager(&game_config, &gameinfo);
//find a list of 'items' (i.e. overlays) on the level, and add them