The Battle for Wesnoth  1.15.11+dev
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
game_launcher Class Reference

#include <game_launcher.hpp>

Public Types

enum  mp_mode { mp_mode::CONNECT, mp_mode::HOST, mp_mode::LOCAL }
 
enum  reload_mode { reload_mode::RELOAD_DATA, reload_mode::NO_RELOAD_DATA }
 
enum  unit_test_result : int {
  unit_test_result::TEST_PASS = 0, unit_test_result::TEST_FAIL = 1, unit_test_result::TEST_FAIL_LOADING_REPLAY = 3, unit_test_result::TEST_FAIL_PLAYING_REPLAY = 4,
  unit_test_result::TEST_FAIL_BROKE_STRICT = 5, unit_test_result::TEST_FAIL_WML_EXCEPTION = 6, unit_test_result::TEST_FAIL_BY_DEFEAT = 7, unit_test_result::TEST_PASS_BY_VICTORY = 8
}
 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_optionsopts () const
 

Private Member Functions

 game_launcher (const game_launcher &)=delete
 
game_launcheroperator= (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 res)
 
unit_test_result single_unit_test ()
 Internal to the implementation of unit_test(). More...
 

Private Attributes

const commandline_optionscmdline_opts_
 
const std::unique_ptr< CVideovideo_
 
font::manager font_manager_
 
const preferences::manager prefs_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_
 
std::optional< savegame::load_game_metadataload_data_
 

Detailed Description

Definition at line 54 of file game_launcher.hpp.

Member Enumeration Documentation

◆ mp_mode

Enumerator
CONNECT 
HOST 
LOCAL 

Definition at line 60 of file game_launcher.hpp.

◆ reload_mode

Enumerator
RELOAD_DATA 
NO_RELOAD_DATA 

Definition at line 61 of file game_launcher.hpp.

◆ unit_test_result

Status code after running a unit test, should match the run_wml_tests script and the documentation for the –unit_test command-line option.

Enumerator
TEST_PASS 
TEST_FAIL 
TEST_FAIL_LOADING_REPLAY 
TEST_FAIL_PLAYING_REPLAY 
TEST_FAIL_BROKE_STRICT 
TEST_FAIL_WML_EXCEPTION 
TEST_FAIL_BY_DEFEAT 
TEST_PASS_BY_VICTORY 

Definition at line 67 of file game_launcher.hpp.

Constructor & Destructor Documentation

◆ game_launcher() [1/2]

game_launcher::game_launcher ( const commandline_options cmdline_opts)

Definition at line 100 of file game_launcher.cpp.

References preferences::_set_maximized(), preferences::_set_resolution(), 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, preferences::disable_preferences_save(), commandline_options::editor, font_manager_, commandline_options::fps, commandline_options::fullscreen, filesystem::get_cache_dir(), filesystem::get_cwd(), filesystem::get_user_config_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_, preferences::music_on(), preferences::network_host(), gui2::new_widgets, commandline_options::new_widgets, game_config::no_delay, commandline_options::nodelay, commandline_options::nogui, commandline_options::nomusic, commandline_options::nosound, commandline_options::password, game_config::path, play_replay_, commandline_options::resolution, filesystem::sanitize_path(), 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, preferences::set_core_id(), game_config::set_debug(), preferences::set_draw_delay(), preferences::set_level(), preferences::set_login(), set_min_translation_percent(), preferences::set_music(), preferences::set_password(), preferences::set_show_fps(), preferences::set_sound(), preferences::set_turn_bell(), preferences::set_UI_sound(), gui2::dialogs::show_debug_clock_button, utf8::size(), jump_to_campaign_info::skip_story, preferences::sound_on(), state_, commandline_options::test, test_scenarios_, commandline_options::translation_percent, preferences::turn_bell(), preferences::UI_sound_on(), commandline_options::unit_test, commandline_options::username, video_, commandline_options::windowed, commandline_options::with_replay, and font::manager::~manager().

◆ ~game_launcher()

game_launcher::~game_launcher ( )

Definition at line 1039 of file game_launcher.cpp.

References sound::close_sound().

◆ game_launcher() [2/2]

game_launcher::game_launcher ( const game_launcher )
privatedelete

Member Function Documentation

◆ change_language()

bool game_launcher::change_language ( )

◆ clear_loaded_game()

void game_launcher::clear_loaded_game ( )
private

Definition at line 1034 of file game_launcher.cpp.

References load_data_.

Referenced by goto_editor(), and load_game().

◆ goto_campaign()

bool game_launcher::goto_campaign ( )

◆ goto_editor()

bool game_launcher::goto_editor ( )

◆ goto_multiplayer()

bool game_launcher::goto_multiplayer ( )

Definition at line 761 of file game_launcher.cpp.

References CONNECT, jump_to_multiplayer_, and play_multiplayer().

◆ has_load_data()

bool game_launcher::has_load_data ( ) const

Definition at line 651 of file game_launcher.cpp.

References load_data_.

◆ init_language()

bool game_launcher::init_language ( )

◆ init_lua_script()

bool game_launcher::init_lua_script ( )

◆ init_video()

bool game_launcher::init_video ( )

◆ jump_to_campaign_id()

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 740 of file game_launcher.cpp.

References jump_to_campaign_info::campaign_id, and jump_to_campaign_.

◆ launch_game()

void game_launcher::launch_game ( reload_mode  reload = reload_mode::RELOAD_DATA)

◆ load_game()

bool game_launcher::load_game ( )

◆ new_campaign()

bool game_launcher::new_campaign ( )

◆ operator=()

game_launcher& game_launcher::operator= ( const game_launcher )
privatedelete

◆ opts()

const commandline_options& game_launcher::opts ( ) const
inline

Definition at line 110 of file game_launcher.hpp.

◆ pass_victory_or_defeat()

game_launcher::unit_test_result game_launcher::pass_victory_or_defeat ( LEVEL_RESULT  res)
private

Definition at line 595 of file game_launcher.cpp.

References TEST_FAIL_BY_DEFEAT, TEST_PASS, and TEST_PASS_BY_VICTORY.

Referenced by single_unit_test().

◆ play_multiplayer()

bool game_launcher::play_multiplayer ( mp_mode  mode)

◆ play_multiplayer_commandline()

bool game_launcher::play_multiplayer_commandline ( )

◆ play_render_image_mode()

bool game_launcher::play_render_image_mode ( )

◆ play_replay()

void game_launcher::play_replay ( )

◆ play_screenshot_mode()

bool game_launcher::play_screenshot_mode ( )

◆ play_test()

bool game_launcher::play_test ( )

◆ select_mp_server()

void game_launcher::select_mp_server ( const std::string &  server)
inline

◆ set_test()

void game_launcher::set_test ( const std::string &  id)

◆ single_unit_test()

game_launcher::unit_test_result game_launcher::single_unit_test ( )
private

◆ start_editor() [1/2]

editor::EXIT_STATUS game_launcher::start_editor ( )
inline

Definition at line 108 of file game_launcher.hpp.

References start_editor().

Referenced by goto_editor(), and start_editor().

◆ start_editor() [2/2]

editor::EXIT_STATUS game_launcher::start_editor ( const std::string &  filename)
private

◆ start_wesnothd()

void game_launcher::start_wesnothd ( )
private

◆ unit_test()

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 493 of file game_launcher.cpp.

References cmdline_opts_, set_test(), single_unit_test(), TEST_FAIL, TEST_FAIL_BROKE_STRICT, 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.

Member Data Documentation

◆ cmdline_opts_

const commandline_options& game_launcher::cmdline_opts_
private

◆ font_manager_

font::manager game_launcher::font_manager_
private

Definition at line 132 of file game_launcher.hpp.

Referenced by game_launcher().

◆ hotkey_manager_

const hotkey::manager game_launcher::hotkey_manager_
private

Definition at line 136 of file game_launcher.hpp.

◆ image_manager_

const image::manager game_launcher::image_manager_
private

Definition at line 134 of file game_launcher.hpp.

◆ jump_to_campaign_

jump_to_campaign_info game_launcher::jump_to_campaign_
private

◆ jump_to_editor_

bool game_launcher::jump_to_editor_
private

Definition at line 151 of file game_launcher.hpp.

Referenced by game_launcher(), goto_editor(), and init_lua_script().

◆ jump_to_multiplayer_

bool game_launcher::jump_to_multiplayer_
private

Definition at line 148 of file game_launcher.hpp.

Referenced by game_launcher(), goto_multiplayer(), and init_lua_script().

◆ load_data_

std::optional<savegame::load_game_metadata> game_launcher::load_data_
private

◆ main_event_context_

const events::event_context game_launcher::main_event_context_
private

Definition at line 135 of file game_launcher.hpp.

◆ multiplayer_server_

std::string game_launcher::multiplayer_server_
private

Definition at line 147 of file game_launcher.hpp.

Referenced by game_launcher(), and play_multiplayer().

◆ music_muter_

sound::music_muter game_launcher::music_muter_
private

Definition at line 138 of file game_launcher.hpp.

◆ music_thinker_

sound::music_thinker game_launcher::music_thinker_
private

Definition at line 137 of file game_launcher.hpp.

◆ play_replay_

bool game_launcher::play_replay_
private

Definition at line 145 of file game_launcher.hpp.

Referenced by game_launcher(), launch_game(), load_game(), and new_campaign().

◆ prefs_manager_

const preferences::manager game_launcher::prefs_manager_
private

Definition at line 133 of file game_launcher.hpp.

◆ screenshot_filename_

std::string game_launcher::screenshot_filename_
private

Definition at line 142 of file game_launcher.hpp.

Referenced by game_launcher(), and play_screenshot_mode().

◆ screenshot_map_

std::string game_launcher::screenshot_map_
private

Definition at line 142 of file game_launcher.hpp.

Referenced by game_launcher(), and play_screenshot_mode().

◆ state_

saved_game game_launcher::state_
private

◆ test_scenarios_

std::vector<std::string> game_launcher::test_scenarios_
private

Definition at line 140 of file game_launcher.hpp.

Referenced by game_launcher(), play_test(), and unit_test().

◆ video_

const std::unique_ptr<CVideo> game_launcher::video_
private

Definition at line 130 of file game_launcher.hpp.

Referenced by change_language(), game_launcher(), and init_video().


The documentation for this class was generated from the following files: