The Battle for Wesnoth  1.15.1+dev
game_launcher.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2018 by David White <dave@whitevine.net>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 
17 #include "editor/editor_main.hpp" // for EXIT_STATUS
18 #include "events.hpp" // for event_context
19 #include "font/font_config.hpp" // for manager
20 #include "preferences/game.hpp" // for manager
21 #include "hotkey/hotkey_manager.hpp" // for manager
22 #include "picture.hpp" // for manager
23 #include "saved_game.hpp" // for saved_game
24 #include "sound.hpp" // for music_thinker
25 
26 #include <string> // for string
27 #include <vector> // for vector
28 
30 class config;
31 class CVideo;
32 namespace savegame { struct load_game_metadata; }
34 {
35 public:
36  jump_to_campaign_info(bool jump, bool skip_story, int difficulty, const std::string& campaign_id,const std::string& scenario_id)
37  : jump_(jump)
38  , skip_story_(skip_story)
39  , difficulty_(difficulty)
40  , campaign_id_(campaign_id)
41  , scenario_id_(scenario_id)
42  {
43  }
44  bool jump_;
47  std::string campaign_id_,scenario_id_;
48 };
49 
51 {
52 public:
53  game_launcher(const commandline_options& cmdline_opts, const char* appname);
54  ~game_launcher();
55 
56  CVideo& video() { return *video_; }
57 
58  enum mp_selection {MP_CONNECT, MP_HOST, MP_LOCAL};
59 
60  bool init_video();
61  bool init_language();
62  bool init_joystick();
63  bool init_lua_script();
64 
65  bool play_test();
66  bool play_screenshot_mode();
67  bool play_render_image_mode();
68  int unit_test();
69 
70  bool is_loading() const;
71  void clear_loaded_game();
72  bool load_game();
73  void set_tutorial();
74  void set_test(const std::string& id);
75 
76  /// Return the ID of the campaign to jump to (skipping the main menu).
77  std::string jump_to_campaign_id() const;
78  bool new_campaign();
79  bool goto_campaign();
80  bool goto_multiplayer();
81  bool goto_editor();
82 
83  bool jump_to_editor() const { return jump_to_editor_; }
84 
85  void select_mp_server(std::string server) { multiplayer_server_ = server; }
86  bool play_multiplayer(mp_selection res);
87  bool play_multiplayer_commandline();
88  bool change_language();
89 
90  void show_preferences();
91 
92  enum RELOAD_GAME_DATA { RELOAD_DATA, NO_RELOAD_DATA };
93  void launch_game(RELOAD_GAME_DATA reload=RELOAD_DATA);
94  void play_replay();
95 
97 
98  void start_wesnothd();
99 
100  const commandline_options & opts() const { return cmdline_opts_; }
101 private:
103  void operator=(const game_launcher&);
104 
105  void mark_completed_campaigns(std::vector<config>& campaigns);
106 
107  editor::EXIT_STATUS start_editor(const std::string& filename);
108 
110  //Never null.
111  const std::unique_ptr<CVideo> video_;
112 
120 
121  std::string test_scenario_;
122 
123  std::string screenshot_map_, screenshot_filename_;
124 
127 
128  std::string multiplayer_server_;
131 
133  std::unique_ptr<savegame::load_game_metadata> load_data_;
134 };
sound::music_muter music_muter_
CVideo & video()
void select_mp_server(std::string server)
const hotkey::manager hotkey_manager_
const std::unique_ptr< CVideo > video_
this class is initialized once at game start put all initialization and wipe code in the methods here...
jump_to_campaign_info(bool jump, bool skip_story, int difficulty, const std::string &campaign_id, const std::string &scenario_id)
Definition: video.hpp:31
jump_to_campaign_info jump_to_campaign_
const commandline_options & opts() const
font::manager font_manager_
std::string multiplayer_server_
editor::EXIT_STATUS start_editor()
bool jump_to_editor() const
std::string screenshot_map_
std::unique_ptr< savegame::load_game_metadata > load_data_
const preferences::manager prefs_manager_
the image manager is responsible for setting up images, and destroying all images when the program ex...
Definition: picture.hpp:157
const commandline_options & cmdline_opts_
std::string jump(const unsigned amount)
Definition: help_impl.hpp:356
sound::music_thinker music_thinker_
saved_game state_
const events::event_context main_event_context_
std::string test_scenario_
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:92
const image::manager image_manager_