#include <game_launcher.hpp>
Public Types | |
enum class | mp_mode { CONNECT , HOST , LOCAL } |
enum class | reload_mode { RELOAD_DATA , NO_RELOAD_DATA } |
enum class | unit_test_result : int { TEST_PASS = 0 , TEST_FAIL = 1 , TEST_FAIL_LOADING_REPLAY = 3 , TEST_FAIL_PLAYING_REPLAY = 4 , TEST_FAIL_WML_EXCEPTION = 6 , TEST_FAIL_BY_DEFEAT = 7 , TEST_PASS_BY_VICTORY = 8 , BROKE_STRICT_TEST_PASS = 9 , BROKE_STRICT_TEST_FAIL = 10 , BROKE_STRICT_TEST_FAIL_BY_DEFEAT = 11 , BROKE_STRICT_TEST_PASS_BY_VICTORY = 12 } |
Status code after running a unit test, should match the run_wml_tests script and the documentation for the –unit_test command-line option. More... | |
Public Member Functions | |
game_launcher (const commandline_options &cmdline_opts) | |
~game_launcher () | |
bool | init_video () |
bool | init_language () |
bool | init_lua_script () |
bool | play_test () |
bool | play_screenshot_mode () |
bool | play_render_image_mode () |
unit_test_result | unit_test () |
Runs unit tests specified on the command line. More... | |
bool | has_load_data () const |
bool | load_game () |
void | set_test (const std::string &id) |
std::string | jump_to_campaign_id () const |
Return the ID of the campaign to jump to (skipping the main menu). More... | |
bool | new_campaign () |
bool | goto_campaign () |
bool | goto_multiplayer () |
bool | goto_editor () |
void | select_mp_server (const std::string &server) |
bool | play_multiplayer (mp_mode mode) |
bool | play_multiplayer_commandline () |
bool | change_language () |
void | launch_game (reload_mode reload=reload_mode::RELOAD_DATA) |
void | play_replay () |
editor::EXIT_STATUS | start_editor () |
const commandline_options & | opts () const |
Private Member Functions | |
game_launcher (const game_launcher &)=delete | |
game_launcher & | operator= (const game_launcher &)=delete |
void | clear_loaded_game () |
void | start_wesnothd () |
editor::EXIT_STATUS | start_editor (const std::string &filename) |
unit_test_result | pass_victory_or_defeat (level_result::type res) |
unit_test_result | single_unit_test () |
Internal to the implementation of unit_test(). More... | |
Private Attributes | |
const commandline_options & | cmdline_opts_ |
bool | start_in_fullscreen_ = false |
font::manager | font_manager_ |
const image::manager | image_manager_ |
const events::event_context | main_event_context_ |
const hotkey::manager | hotkey_manager_ |
sound::music_thinker | music_thinker_ |
sound::music_muter | music_muter_ |
std::vector< std::string > | test_scenarios_ |
std::string | screenshot_map_ |
std::string | screenshot_filename_ |
saved_game | state_ |
bool | play_replay_ |
std::string | multiplayer_server_ |
bool | jump_to_multiplayer_ |
jump_to_campaign_info | jump_to_campaign_ |
bool | jump_to_editor_ |
utils::optional< savegame::load_game_metadata > | load_data_ |
Definition at line 52 of file game_launcher.hpp.
|
strong |
Enumerator | |
---|---|
CONNECT | |
HOST | |
LOCAL |
Definition at line 58 of file game_launcher.hpp.
|
strong |
Enumerator | |
---|---|
RELOAD_DATA | |
NO_RELOAD_DATA |
Definition at line 59 of file game_launcher.hpp.
|
strong |
Status code after running a unit test, should match the run_wml_tests script and the documentation for the –unit_test command-line option.
Definition at line 65 of file game_launcher.hpp.
game_launcher::game_launcher | ( | const commandline_options & | cmdline_opts | ) |
Definition at line 90 of file game_launcher.cpp.
References commandline_options::campaign, commandline_options::campaign_difficulty, jump_to_campaign_info::campaign_id, commandline_options::campaign_scenario, commandline_options::campaign_skip_story, commandline_options::clock, cmdline_opts_, commandline_options::core_id, commandline_options::debug, savegame::save_index_class::default_saves_dir(), jump_to_campaign_info::difficulty, prefs::disable_preferences_save(), commandline_options::editor, commandline_options::fps, commandline_options::fullscreen, prefs::get(), filesystem::get_cache_dir(), filesystem::get_user_data_dir(), commandline_options::headless_unit_test, sound::init_sound(), jump_to_campaign_info::jump, jump_to_campaign_, jump_to_editor_, jump_to_multiplayer_, commandline_options::load, load_data_, commandline_options::max_fps, game_config::mp_debug, multiplayer_server_, gui2::dialogs::music_on(), prefs::network_host(), commandline_options::new_widgets, gui2::new_widgets, commandline_options::nobanner, commandline_options::nogui, commandline_options::nomusic, commandline_options::nosound, commandline_options::password, game_config::path, PLAIN_LOG, draw::point(), commandline_options::resolution, jump_to_campaign_info::scenario_id, commandline_options::screenshot, screenshot_filename_, screenshot_map_, commandline_options::screenshot_map_file, commandline_options::screenshot_output_file, commandline_options::server, game_config::server_list, game_config::set_debug(), prefs::set_login(), set_min_translation_percent(), prefs::set_music(), prefs::set_password(), prefs::set_resolution(), prefs::set_show_fps(), prefs::set_sound(), prefs::set_turn_bell(), prefs::set_ui_sound(), gui2::dialogs::show_debug_clock_button, utf8::size(), jump_to_campaign_info::skip_story, gui2::dialogs::sound(), start_in_fullscreen_, commandline_options::test, test_scenarios_, commandline_options::translation_percent, game_config::sounds::turn_bell, gui2::dialogs::ui_sound_on(), commandline_options::unit_test, commandline_options::username, commandline_options::windowed, and commandline_options::with_replay.
game_launcher::~game_launcher | ( | ) |
Definition at line 1042 of file game_launcher.cpp.
References sound::close_sound(), video::deinit(), e, ERR_GENERAL, and utils::get_unknown_exception_type().
|
privatedelete |
bool game_launcher::change_language | ( | ) |
Definition at line 950 of file game_launcher.cpp.
References cmdline_opts_, image::flush_cache(), sound::flush_cache(), game_config::get_default_title_string(), commandline_options::headless_unit_test, font::load_font_config(), commandline_options::nogui, t_string::reset_translations(), and video::set_window_title().
Referenced by gui2::dialogs::title_screen::init_callbacks().
|
private |
Definition at line 1037 of file game_launcher.cpp.
References load_data_.
Referenced by goto_editor(), and load_game().
bool game_launcher::goto_campaign | ( | ) |
Definition at line 744 of file game_launcher.cpp.
References jump_to_campaign_info::jump, jump_to_campaign_, launch_game(), new_campaign(), NO_RELOAD_DATA, saved_game::set_skip_story(), jump_to_campaign_info::skip_story, and state_.
bool game_launcher::goto_editor | ( | ) |
Definition at line 769 of file game_launcher.cpp.
References clear_loaded_game(), editor::EXIT_QUIT_TO_DESKTOP, jump_to_editor_, load_data_, filesystem::normalize_path(), and start_editor().
bool game_launcher::goto_multiplayer | ( | ) |
Definition at line 759 of file game_launcher.cpp.
References CONNECT, jump_to_multiplayer_, and play_multiplayer().
bool game_launcher::has_load_data | ( | ) | const |
Definition at line 650 of file game_launcher.cpp.
References load_data_.
bool game_launcher::init_language | ( | ) |
Definition at line 248 of file game_launcher.cpp.
References cmdline_opts_, get_languages(), get_locale(), commandline_options::language, load_language_list(), language_def::localename, PLAIN_LOG, and translation::set_language().
bool game_launcher::init_lua_script | ( | ) |
Definition at line 318 of file game_launcher.cpp.
References plugins_manager::add_plugin(), cmdline_opts_, e, filename, plugins_manager::get(), plugins_manager::get_detailed_status(), plugins_manager::get_kernel_base(), plugins_manager::get_name(), i, filesystem::istream_file(), jump_to_campaign_info::jump, jump_to_campaign_, jump_to_editor_, jump_to_multiplayer_, lua_kernel_base::load_package(), commandline_options::nobanner, PLAIN_LOG, plugins_context::play_slice(), commandline_options::plugin_file, lua_kernel_base::run(), commandline_options::script_file, commandline_options::script_unsafe_mode, gui2::show_error_message(), plugins_manager::size(), plugins_manager::start_plugin(), and STREAMING_LOG.
bool game_launcher::init_video | ( | ) |
Definition at line 275 of file game_launcher.cpp.
References cmdline_opts_, game_config::get_default_title_string(), image::get_surface(), commandline_options::headless_unit_test, video::hide_window, video::init(), commandline_options::multiplayer, video::no_window, commandline_options::nogui, PLAIN_LOG, commandline_options::plugin_file, commandline_options::render_image, commandline_options::screenshot, video::set_window_icon(), video::set_window_title(), and image::UNSCALED.
std::string game_launcher::jump_to_campaign_id | ( | ) | const |
Return the ID of the campaign to jump to (skipping the main menu).
Definition at line 739 of file game_launcher.cpp.
References jump_to_campaign_info::campaign_id, and jump_to_campaign_.
void game_launcher::launch_game | ( | reload_mode | reload = reload_mode::RELOAD_DATA | ) |
Definition at line 968 of file game_launcher.cpp.
References _(), saved_game::classification(), gui2::dialogs::loading_screen::display(), e, game_config_manager::get(), saved_game::get_scenario_id(), load_data, load_data_, game_config_manager::load_game_config_for_game(), campaign_controller::play_game(), play_replay(), play_replay_, gui2::dialogs::loading_screen::progress(), RELOAD_DATA, gui2::show_error_message(), ai::manager::singleton_, and state_.
Referenced by goto_campaign().
bool game_launcher::load_game | ( | ) |
Definition at line 655 of file game_launcher.cpp.
References _(), saved_game::cancel_orders(), saved_game::classification(), statistics_record::campaign_stats_t::clear_current_scenario(), clear_loaded_game(), DBG_GENERAL, savegame::save_index_class::default_saves_dir(), e, game_config_manager::get(), saved_game::get_scenario_id(), string_enums::enum_base< Definition >::get_string(), saved_game::is_mid_game_save(), game_classification::is_multiplayer(), saved_game::is_start_of_scenario(), gui2::tip_of_the_day::load(), load_data_, game_config_manager::load_game_config_for_game(), LOG_CONFIG, play_replay_, gui2::show_error_message(), state_, saved_game::statistics(), game_classification::type, and saved_game::unify_controllers().
Referenced by gui2::dialogs::title_screen::init_callbacks(), and single_unit_test().
bool game_launcher::new_campaign | ( | ) |
Definition at line 730 of file game_launcher.cpp.
References saved_game::classification(), saved_game::clear(), jump_to_campaign_, play_replay_, sp::select_campaign(), state_, and game_classification::type.
Referenced by goto_campaign(), and gui2::dialogs::title_screen::init_callbacks().
|
privatedelete |
|
inline |
Definition at line 112 of file game_launcher.hpp.
References cmdline_opts_.
|
private |
Definition at line 582 of file game_launcher.cpp.
References lg::broke_strict(), BROKE_STRICT_TEST_FAIL_BY_DEFEAT, BROKE_STRICT_TEST_PASS, BROKE_STRICT_TEST_PASS_BY_VICTORY, TEST_FAIL_BY_DEFEAT, TEST_PASS, and TEST_PASS_BY_VICTORY.
Referenced by single_unit_test().
bool game_launcher::play_multiplayer | ( | mp_mode | mode | ) |
Definition at line 824 of file game_launcher.cpp.
References _(), events::discard_input(), e, ERR_CONFIG, ERR_NET, game_config_manager::get(), prefs::get(), translation::gettext(), HOST, load_data_, game_config_manager::load_game_config_for_create(), LOCAL, multiplayer_server_, prefs::network_host(), cursor::NORMAL, PLAIN_LOG, cursor::set(), prefs::set_network_host(), gui2::show_error_message(), gui2::show_transient_message(), prefs::show_wesnothd_server_search(), mp::start_client(), mp::start_local_game(), start_wesnothd(), and wesnothd_connection_error::user_message.
Referenced by do_gameloop(), and goto_multiplayer().
bool game_launcher::play_multiplayer_commandline | ( | ) |
Definition at line 927 of file game_launcher.cpp.
References cmdline_opts_, DBG_MP, events::discard_input(), e, game_config_manager::get(), load_data_, game_config_manager::load_game_config_for_create(), commandline_options::multiplayer, cursor::NORMAL, cursor::set(), and mp::start_local_game_commandline().
bool game_launcher::play_render_image_mode | ( | ) |
Definition at line 619 of file game_launcher.cpp.
References saved_game::classification(), cmdline_opts_, DBG_GENERAL, e, game_config_manager::get(), saved_game::get_scenario_id(), string_enums::enum_base< Definition >::get_string(), game_config_manager::load_game_config_for_game(), PLAIN_LOG, commandline_options::render_image, commandline_options::render_image_dst, image::save_image(), state_, image::success, and game_classification::type.
void game_launcher::play_replay | ( | ) |
Definition at line 1003 of file game_launcher.cpp.
References e, load_data_, campaign_controller::play_replay(), and state_.
Referenced by launch_game().
bool game_launcher::play_screenshot_mode | ( | ) |
Definition at line 605 of file game_launcher.cpp.
References cmdline_opts_, game_config_manager::get(), init_textdomains(), game_config_manager::load_game_config_for_editor(), commandline_options::screenshot, screenshot_filename_, screenshot_map_, and editor::start().
bool game_launcher::play_test | ( | ) |
Definition at line 421 of file game_launcher.cpp.
References saved_game::classification(), cmdline_opts_, e, game_config_manager::get(), saved_game::get_scenario_id(), load_data_, game_config_manager::load_game_config_for_game(), PLAIN_LOG, campaign_controller::play_game(), set_test(), state_, commandline_options::test, and test_scenarios_.
|
inline |
Definition at line 102 of file game_launcher.hpp.
References multiplayer_server_.
Referenced by gui2::dialogs::title_screen::button_callback_multiplayer().
void game_launcher::set_test | ( | const std::string & | id | ) |
Definition at line 411 of file game_launcher.cpp.
References game_classification::campaign_define, saved_game::classification(), saved_game::clear(), game_classification::era_id, saved_game::set_carryover_sides_start(), state_, and game_classification::type.
Referenced by gui2::dialogs::title_screen::hotkey_callback_select_tests(), play_test(), and unit_test().
|
private |
Internal to the implementation of unit_test().
If a single instance of Wesnoth is running multiple unit tests, this gets called once per test.
Definition at line 529 of file game_launcher.cpp.
References lg::broke_strict(), BROKE_STRICT_TEST_FAIL, saved_game::classification(), savegame::clean_saves(), cmdline_opts_, savegame::save_index_class::default_saves_dir(), e, savegame::savegame::filename(), game_config_manager::get(), saved_game::get_scenario_id(), game_classification::label, load_data_, load_game(), game_config_manager::load_game_config_for_game(), compression::none, commandline_options::noreplaycheck, pass_victory_or_defeat(), PLAIN_LOG, campaign_controller::play_game(), campaign_controller::play_replay(), savegame::savegame::save_game_automatic(), state_, TEST_FAIL, TEST_FAIL_LOADING_REPLAY, TEST_FAIL_PLAYING_REPLAY, and TEST_FAIL_WML_EXCEPTION.
Referenced by unit_test().
|
inline |
Definition at line 110 of file game_launcher.hpp.
References start_editor().
Referenced by goto_editor(), and start_editor().
|
private |
Definition at line 1017 of file game_launcher.cpp.
References editor::EXIT_ERROR, editor::EXIT_NORMAL, editor::EXIT_RELOAD_DATA, filename, game_config_manager::get(), init_textdomains(), game_config_manager::load_game_config_for_editor(), game_config_manager::reload_changed_game_config(), and editor::start().
|
private |
Definition at line 785 of file game_launcher.cpp.
References c, e, filesystem::file_exists(), prefs::get(), prefs::get_mp_server_program_name(), filesystem::get_user_data_dir(), filesystem::get_wesnothd_name(), filesystem::get_wml_location(), LOG_GENERAL, filesystem::read_file(), prefs::set_mp_server_program_name(), filesystem::write_file(), and WRN_GENERAL.
Referenced by play_multiplayer().
game_launcher::unit_test_result game_launcher::unit_test | ( | ) |
Runs unit tests specified on the command line.
If multiple unit tests were specified, then this will stop at the first test which returns a non-zero status.
Definition at line 471 of file game_launcher.cpp.
References BROKE_STRICT_TEST_FAIL, BROKE_STRICT_TEST_FAIL_BY_DEFEAT, BROKE_STRICT_TEST_PASS, BROKE_STRICT_TEST_PASS_BY_VICTORY, cmdline_opts_, PLAIN_LOG, set_test(), single_unit_test(), TEST_FAIL, TEST_FAIL_BY_DEFEAT, TEST_FAIL_LOADING_REPLAY, TEST_FAIL_PLAYING_REPLAY, TEST_FAIL_WML_EXCEPTION, TEST_PASS, TEST_PASS_BY_VICTORY, test_scenarios_, and commandline_options::unit_test.
|
private |
Definition at line 130 of file game_launcher.hpp.
Referenced by change_language(), game_launcher(), init_language(), init_lua_script(), init_video(), opts(), play_multiplayer_commandline(), play_render_image_mode(), play_screenshot_mode(), play_test(), single_unit_test(), and unit_test().
|
private |
Definition at line 133 of file game_launcher.hpp.
|
private |
Definition at line 136 of file game_launcher.hpp.
|
private |
Definition at line 134 of file game_launcher.hpp.
|
private |
Definition at line 149 of file game_launcher.hpp.
Referenced by game_launcher(), goto_campaign(), init_lua_script(), jump_to_campaign_id(), and new_campaign().
|
private |
Definition at line 151 of file game_launcher.hpp.
Referenced by game_launcher(), goto_editor(), and init_lua_script().
|
private |
Definition at line 148 of file game_launcher.hpp.
Referenced by game_launcher(), goto_multiplayer(), and init_lua_script().
|
private |
Definition at line 152 of file game_launcher.hpp.
Referenced by clear_loaded_game(), game_launcher(), goto_editor(), has_load_data(), launch_game(), load_game(), play_multiplayer(), play_multiplayer_commandline(), play_replay(), play_test(), and single_unit_test().
|
private |
Definition at line 135 of file game_launcher.hpp.
|
private |
Definition at line 147 of file game_launcher.hpp.
Referenced by game_launcher(), play_multiplayer(), and select_mp_server().
|
private |
Definition at line 138 of file game_launcher.hpp.
|
private |
Definition at line 137 of file game_launcher.hpp.
|
private |
Definition at line 145 of file game_launcher.hpp.
Referenced by launch_game(), load_game(), and new_campaign().
|
private |
Definition at line 142 of file game_launcher.hpp.
Referenced by game_launcher(), and play_screenshot_mode().
|
private |
Definition at line 142 of file game_launcher.hpp.
Referenced by game_launcher(), and play_screenshot_mode().
|
private |
Definition at line 131 of file game_launcher.hpp.
Referenced by game_launcher().
|
private |
Definition at line 144 of file game_launcher.hpp.
Referenced by goto_campaign(), launch_game(), load_game(), new_campaign(), play_render_image_mode(), play_replay(), play_test(), set_test(), and single_unit_test().
|
private |
Definition at line 140 of file game_launcher.hpp.
Referenced by game_launcher(), play_test(), and unit_test().