本文整理汇总了C++中saved_game::get_scenario_id方法的典型用法代码示例。如果您正苦于以下问题:C++ saved_game::get_scenario_id方法的具体用法?C++ saved_game::get_scenario_id怎么用?C++ saved_game::get_scenario_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类saved_game
的用法示例。
在下文中一共展示了saved_game::get_scenario_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add_multiplayer_classification
// To remove radundant informaion in the clientside internal programmflow
// I want to remove these values from mp_settings so i need to readd them here
static void add_multiplayer_classification(config& multiplayer, saved_game& state)
{
multiplayer["mp_scenario"] = state.get_scenario_id();
multiplayer["mp_scenario_name"] = state.get_starting_pos()["name"];
multiplayer["difficulty_define"] = state.classification().difficulty;
multiplayer["mp_campaign"] = state.classification().campaign;
}
示例2: enter_create_mode
bool enter_create_mode(game_display& disp, const config& game_config,
saved_game& state, jump_to_campaign_info jump_to_campaign, bool local_players_only) {
bool configure_canceled = false;
do {
ng::create_engine create_eng(disp, state);
create_eng.set_current_level_type(ng::level::TYPE::SP_CAMPAIGN);
std::vector<ng::create_engine::level_ptr> campaigns(
create_eng.get_levels_by_type_unfiltered(ng::level::TYPE::SP_CAMPAIGN));
if (campaigns.empty()) {
gui2::show_error_message(disp.video(),
_("No campaigns are available.\n"));
return false;
}
bool use_deterministic_mode = false;
// No campaign selected from command line
if (jump_to_campaign.campaign_id_.empty() == true)
{
gui2::tcampaign_selection dlg(create_eng);
try {
dlg.show(disp.video());
} catch(twml_exception& e) {
e.show(disp);
return false;
}
if(dlg.get_retval() != gui2::twindow::OK) {
return false;
}
use_deterministic_mode = dlg.get_deterministic();
}
else
{
// don't reset the campaign_id_ so we can know
// if we should quit the game or return to the main menu
// checking for valid campaign name
bool not_found = true;
for(size_t i = 0; i < campaigns.size(); ++i)
{
if (campaigns[i]->data()["id"] == jump_to_campaign.campaign_id_)
{
create_eng.set_current_level(i);
not_found = false;
break;
}
}
// didn't find any campaign with that id
if (not_found)
{
//TODO: use ERR_NG or similar
std::cerr<<"No such campaign id to jump to: ["<<jump_to_campaign.campaign_id_<<"]\n";
return false;
}
}
std::string random_mode = use_deterministic_mode ? "deterministic" : "";
state.classification().random_mode = random_mode;
std::string selected_difficulty = create_eng.select_campaign_difficulty(jump_to_campaign.difficulty_);
if (selected_difficulty == "FAIL") return false;
if (selected_difficulty == "CANCEL") {
if (jump_to_campaign.campaign_id_.empty() == false)
{
jump_to_campaign.campaign_id_ = "";
}
// canceled difficulty dialog, relaunch the campaign selection dialog
return enter_create_mode(disp, game_config, state, jump_to_campaign, local_players_only);
}
create_eng.prepare_for_era_and_mods();
create_eng.prepare_for_campaign(selected_difficulty);
if(!jump_to_campaign.scenario_id_.empty()) {
state.set_carryover_sides_start(
config_of("next_scenario", jump_to_campaign.scenario_id_)
);
}
create_eng.prepare_for_new_level();
create_eng.get_parameters();
if(!state.valid())
{
//TODO: use ERR_NG or similar
std::cerr << "Cannot load scenario with id=" << state.get_scenario_id() << "\n";
return false;
}
configure_canceled = !enter_configure_mode(disp, game_config_manager::get()->game_config(), state, local_players_only);
//.........这里部分代码省略.........
示例3: enter_create_mode
bool enter_create_mode(CVideo& video, const config& game_config, saved_game& state, jump_to_campaign_info jump_to_campaign, bool local_players_only)
{
bool configure_canceled = false;
do {
ng::create_engine create_eng(video, state);
create_eng.set_current_level_type(ng::level::TYPE::SP_CAMPAIGN);
const std::vector<ng::create_engine::level_ptr> campaigns =
create_eng.get_levels_by_type_unfiltered(ng::level::TYPE::SP_CAMPAIGN);
if(campaigns.empty()) {
gui2::show_error_message(video, _("No campaigns are available."));
return false;
}
std::string random_mode = "";
// No campaign selected from command line
if(jump_to_campaign.campaign_id_.empty()) {
gui2::tcampaign_selection dlg(create_eng);
try {
dlg.show(video);
} catch(twml_exception& e) {
e.show(video);
return false;
}
if(dlg.get_retval() != gui2::twindow::OK) {
return false;
}
if(dlg.get_deterministic()) {
random_mode = "deterministic";
}
} else {
// Don't reset the campaign_id_ so we can know
// if we should quit the game or return to the main menu
// Checking for valid campaign name
const auto campaign = std::find_if(campaigns.begin(), campaigns.end(), [&jump_to_campaign](ng::create_engine::level_ptr level) {
return level->data()["id"] == jump_to_campaign.campaign_id_;
});
// Didn't find a campaign with that id
if(campaign == campaigns.end()) {
ERR_NG << "No such campaign id to jump to: [" << jump_to_campaign.campaign_id_ << "]" << std::endl;
return false;
}
create_eng.set_current_level(campaign - campaigns.begin());
}
state.classification().random_mode = random_mode;
const std::string selected_difficulty = create_eng.select_campaign_difficulty(jump_to_campaign.difficulty_);
if(selected_difficulty == "FAIL") return false;
if(selected_difficulty == "CANCEL") {
if(!jump_to_campaign.campaign_id_.empty()) {
jump_to_campaign.campaign_id_ = "";
}
// Canceled difficulty dialog, relaunch the campaign selection dialog
return enter_create_mode(video, game_config, state, jump_to_campaign, local_players_only);
}
create_eng.prepare_for_era_and_mods();
create_eng.prepare_for_campaign(selected_difficulty);
if(!jump_to_campaign.scenario_id_.empty()) {
state.set_carryover_sides_start(
config_of("next_scenario", jump_to_campaign.scenario_id_)
);
}
if(!state.valid()) {
ERR_NG << "Cannot load scenario with id=" << state.get_scenario_id() << std::endl;
return false;
}
configure_canceled = !enter_configure_mode(video, game_config_manager::get()->game_config(), state, create_eng, local_players_only);
} while (configure_canceled);
return true;
}