Allow WML to disable the credits at the end of a single-player campaign

This is done by implementing an end_credits attribute for use in
[endlevel], [scenario] and [campaign]. The (boolean) value is stored in
saved games and defaults to true.

Example:

  [endlevel]
      next_scenario=null
      end_credits=no
      linger_mode=no
  [/endlevel]

This will be documented later in the wiki.
This commit is contained in:
Ignacio R. Morelle 2012-02-06 22:17:22 +00:00
parent d773fc7990
commit 683df4374e
5 changed files with 16 additions and 1 deletions

View file

@ -30,6 +30,9 @@ Version 1.11.0-svn:
* Removed support for the deprecated "colour=", "debug_border_colour=",
and [colour_adjust]
* Fixed bug #18996: Increase random number generation range.
* Made it possible to disable the credits screen at the end of a campaign
by specifying end_credits=no in the final [endlevel] action, or in
[scenario] or [campaign] (defaults to yes)
* Unit changes and balancing:
* New extra_define ENABLE_WOLF_ADVANCEMENT to optionally enable Wolves
advancement to Great Wolves and Direwolves

View file

@ -1271,7 +1271,9 @@ void game_controller::launch_game(RELOAD_GAME_DATA reload)
if(result == VICTORY && (state_.classification().campaign_type.empty() || state_.classification().campaign_type != "multiplayer")) {
preferences::add_completed_campaign(state_.classification().campaign);
the_end(disp(), state_.classification().end_text, state_.classification().end_text_duration);
about::show_about(disp(),state_.classification().campaign);
if(state_.classification().end_credits) {
about::show_about(disp(),state_.classification().campaign);
}
}
clear_loaded_game();

View file

@ -2424,6 +2424,10 @@ WML_HANDLER_FUNCTION(endlevel, /*event_info*/, cfg)
end_of_campaign_text_delay.to_int(state_of_game->classification().end_text_duration);
}
if(cfg.has_attribute("end_credits")) {
state_of_game->classification().end_credits = cfg["end_credits"].to_bool(true);
}
std::string result = cfg["result"];
VALIDATE_WITH_DEV_MESSAGE(

View file

@ -75,6 +75,7 @@ game_classification::game_classification():
scenario(),
next_scenario(),
completion(),
end_credits(true),
end_text(),
end_text_duration(),
difficulty("NORMAL")
@ -96,6 +97,7 @@ game_classification::game_classification(const config& cfg):
scenario(cfg["scenario"]),
next_scenario(cfg["next_scenario"]),
completion(cfg["completion"]),
end_credits(cfg["end_credits"].to_bool(true)),
end_text(cfg["end_text"]),
end_text_duration(cfg["end_text_duration"]),
difficulty(cfg["difficulty"].empty() ? "NORMAL" : cfg["difficulty"].str())
@ -117,6 +119,7 @@ game_classification::game_classification(const game_classification& gc):
scenario(gc.scenario),
next_scenario(gc.next_scenario),
completion(gc.completion),
end_credits(gc.end_credits),
end_text(gc.end_text),
end_text_duration(gc.end_text_duration),
difficulty(gc.difficulty)
@ -141,6 +144,7 @@ config game_classification::to_config() const
cfg["scenario"] = scenario;
cfg["next_scenario"] = next_scenario;
cfg["completion"] = completion;
cfg["end_credits"] = end_credits;
cfg["end_text"] = end_text;
cfg["end_text_duration"] = str_cast<unsigned int>(end_text_duration);
cfg["difficulty"] = difficulty;
@ -354,6 +358,7 @@ void game_state::write_snapshot(config& cfg) const
cfg["random_seed"] = rng_.get_random_seed();
cfg["random_calls"] = rng_.get_random_calls();
cfg["end_credits"] = classification_.end_credits;
cfg["end_text"] = classification_.end_text;
cfg["end_text_duration"] = str_cast<unsigned int>(classification_.end_text_duration);

View file

@ -62,6 +62,7 @@ public:
std::string scenario; /**< the scenario being played */
std::string next_scenario; /**< the scenario coming next (for campaigns) */
std::string completion; /**< running. victory, or defeat */
bool end_credits; /**< whether to show the standard credits at the end */
std::string end_text; /**< end-of-campaign text */
unsigned int end_text_duration; /**< for how long the end-of-campaign text is shown */
std::string difficulty; /**< The difficulty level the game is being played on. */