Cleaned up the mess of CVideo references passed around the game initialization process
Essentially, we had CVideo arguments being passed down this chain: - game_launcher - free-standing MP initialization functions - campaign_controller - playsingle_controller/playmp_controller - play_controller - game_display - display And likewise down through - game_launcher - editor_controller - editor_display - display With only a minimal number of actual calls along the way. :| There were maybe... two remaining? This removes the CVideo arguments and class members from both chains (except of course, game_launcher. That's where the "real" CVideo object lives). The display class now initializes its CVideo reference from the singleton, which is also used in the very few other places it's needed. I also replaced a check for a null video ptr in show_tooltip() with a faked() check (see src/tooltips.cpp). That seems to make more sense, since CVideo is never null now.
This commit is contained in:
parent
b46a64b8ad
commit
9dd497db4a
23 changed files with 72 additions and 90 deletions
|
@ -153,13 +153,13 @@ void display::remove_single_overlay(const map_location& loc, const std::string&
|
|||
}
|
||||
}
|
||||
|
||||
display::display(const display_context * dc, CVideo& video, std::weak_ptr<wb::manager> wb, reports & reports_object, const config& theme_cfg, const config& level, bool auto_join) :
|
||||
display::display(const display_context * dc, std::weak_ptr<wb::manager> wb, reports & reports_object, const config& theme_cfg, const config& level, bool auto_join) :
|
||||
video2::draw_layering(auto_join),
|
||||
dc_(dc),
|
||||
halo_man_(new halo::manager(*this)),
|
||||
wb_(wb),
|
||||
exclusive_unit_draw_requests_(),
|
||||
screen_(video),
|
||||
screen_(CVideo::get_singleton()),
|
||||
currentTeam_(0),
|
||||
dont_show_all_(false),
|
||||
xpos_(0),
|
||||
|
@ -236,9 +236,9 @@ display::display(const display_context * dc, CVideo& video, std::weak_ptr<wb::ma
|
|||
|
||||
read(level.child_or_empty("display"));
|
||||
|
||||
if(video.non_interactive()
|
||||
&& (video.getSurface() != nullptr
|
||||
&& video.faked())) {
|
||||
if(screen_.non_interactive()
|
||||
&& (screen_.getSurface() != nullptr
|
||||
&& screen_.faked())) {
|
||||
screen_.lock_updates(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ class gamemap;
|
|||
class display : public filter_context, public video2::draw_layering
|
||||
{
|
||||
public:
|
||||
display(const display_context * dc, CVideo& video, std::weak_ptr<wb::manager> wb,
|
||||
display(const display_context * dc, std::weak_ptr<wb::manager> wb,
|
||||
reports & reports_object,
|
||||
const config& theme_cfg, const config& level, bool auto_join=true);
|
||||
virtual ~display();
|
||||
|
|
|
@ -59,17 +59,17 @@ static std::vector<std::string> saved_windows_;
|
|||
|
||||
namespace editor {
|
||||
|
||||
editor_controller::editor_controller(const config &game_config, CVideo& video)
|
||||
editor_controller::editor_controller(const config &game_config)
|
||||
: controller_base(game_config)
|
||||
, mouse_handler_base()
|
||||
, quit_confirmation(std::bind(&editor_controller::quit_confirm, this))
|
||||
, active_menu_(editor::MAP)
|
||||
, reports_(new reports())
|
||||
, gui_(new editor_display(*this, video, *reports_, controller_base::get_theme(game_config, "editor")))
|
||||
, gui_(new editor_display(*this, *reports_, controller_base::get_theme(game_config, "editor")))
|
||||
, tods_()
|
||||
, context_manager_(new context_manager(*gui_.get(), game_config_))
|
||||
, toolkit_(nullptr)
|
||||
, tooltip_manager_(video)
|
||||
, tooltip_manager_()
|
||||
, floating_label_manager_(nullptr)
|
||||
, help_manager_(nullptr)
|
||||
, do_quit_(false)
|
||||
|
|
|
@ -79,7 +79,7 @@ class editor_controller : public controller_base,
|
|||
* to the map can be retrieved between the main loop's end and the controller's
|
||||
* destruction.
|
||||
*/
|
||||
editor_controller(const config &game_config, CVideo& video);
|
||||
explicit editor_controller(const config &game_config);
|
||||
|
||||
~editor_controller();
|
||||
|
||||
|
|
|
@ -54,12 +54,12 @@ const display_context * get_dummy_display_context() {
|
|||
|
||||
// End dummy display context
|
||||
|
||||
editor_display::editor_display(editor_controller& controller, CVideo& video, reports& reports_object, const config& theme_cfg)
|
||||
: display(get_dummy_display_context(), video, std::shared_ptr<wb::manager>(), reports_object, theme_cfg, config())
|
||||
editor_display::editor_display(editor_controller& controller, reports& reports_object, const config& theme_cfg)
|
||||
: display(get_dummy_display_context(), std::shared_ptr<wb::manager>(), reports_object, theme_cfg, config())
|
||||
, brush_locations_()
|
||||
, controller_(controller)
|
||||
{
|
||||
video.clear_screen();
|
||||
video().clear_screen();
|
||||
}
|
||||
|
||||
void editor_display::add_brush_loc(const map_location& hex)
|
||||
|
|
|
@ -24,7 +24,7 @@ const display_context * get_dummy_display_context();
|
|||
class editor_display : public display
|
||||
{
|
||||
public:
|
||||
editor_display(editor_controller& controller, CVideo& video, reports& reports_object, const config& theme_cfg);
|
||||
editor_display(editor_controller& controller, reports& reports_object, const config& theme_cfg);
|
||||
|
||||
bool in_editor() const override { return true; }
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ lg::log_domain log_editor("editor");
|
|||
|
||||
namespace editor {
|
||||
|
||||
EXIT_STATUS start(const config& game_conf, CVideo& video, const std::string& filename /* = "" */,
|
||||
EXIT_STATUS start(const config& game_conf, const std::string& filename /* = "" */,
|
||||
bool take_screenshot /* = false */, const std::string& screenshot_filename /* = "map_screenshot.bmp" */)
|
||||
{
|
||||
EXIT_STATUS e = EXIT_ERROR;
|
||||
|
@ -33,7 +33,7 @@ EXIT_STATUS start(const config& game_conf, CVideo& video, const std::string& fil
|
|||
hotkey::scope_changer h_;
|
||||
hotkey::deactivate_all_scopes();
|
||||
hotkey::set_scope_active(hotkey::SCOPE_EDITOR);
|
||||
editor_controller editor(game_conf, video);
|
||||
editor_controller editor(game_conf);
|
||||
if (!filename.empty() && filesystem::file_exists (filename)) {
|
||||
if (filesystem::is_directory(filename)) {
|
||||
editor.context_manager_->set_default_dir(filename);
|
||||
|
|
|
@ -34,6 +34,6 @@ enum EXIT_STATUS {
|
|||
* go back to the titlescreen or quit to desktop altogether)
|
||||
*/
|
||||
|
||||
EXIT_STATUS start(const config& game_config, CVideo& video, const std::string& filename = "", bool take_screenshot = false, const std::string& screenshot_filename = "map_screenshot.bmp");
|
||||
EXIT_STATUS start(const config& game_config, const std::string& filename = "", bool take_screenshot = false, const std::string& screenshot_filename = "map_screenshot.bmp");
|
||||
|
||||
} //end namespace editor
|
||||
|
|
|
@ -62,13 +62,13 @@ std::map<map_location,fixed_t> game_display::debugHighlights_;
|
|||
*/
|
||||
std::vector<surface> footsteps_images(const map_location& loc, const pathfind::marked_route & route_, const display_context * dc_);
|
||||
|
||||
game_display::game_display(game_board& board, CVideo& video, std::weak_ptr<wb::manager> wb,
|
||||
game_display::game_display(game_board& board, std::weak_ptr<wb::manager> wb,
|
||||
reports & reports_object,
|
||||
const tod_manager& tod,
|
||||
const config& theme_cfg,
|
||||
const config& level,
|
||||
bool) :
|
||||
display(&board, video, wb, reports_object, theme_cfg, level, false),
|
||||
display(&board, wb, reports_object, theme_cfg, level, false),
|
||||
overlay_map_(),
|
||||
attack_indicator_src_(),
|
||||
attack_indicator_dst_(),
|
||||
|
@ -83,17 +83,17 @@ game_display::game_display(game_board& board, CVideo& video, std::weak_ptr<wb::m
|
|||
needs_rebuild_(false)
|
||||
{
|
||||
replace_overlay_map(&overlay_map_);
|
||||
video.clear_screen();
|
||||
video().clear_screen();
|
||||
}
|
||||
|
||||
game_display* game_display::create_dummy_display(CVideo& video)
|
||||
game_display* game_display::create_dummy_display()
|
||||
{
|
||||
static config dummy_cfg;
|
||||
static config dummy_cfg2;
|
||||
static game_board dummy_board(std::make_shared<terrain_type_data>(dummy_cfg), dummy_cfg2);
|
||||
static tod_manager dummy_tod(dummy_cfg);
|
||||
static reports rep_;
|
||||
return new game_display(dummy_board, video, std::shared_ptr<wb::manager>(), rep_, dummy_tod,
|
||||
return new game_display(dummy_board, std::shared_ptr<wb::manager>(), rep_, dummy_tod,
|
||||
dummy_cfg, dummy_cfg, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class game_board;
|
|||
class game_display : public display
|
||||
{
|
||||
public:
|
||||
game_display(game_board& board, CVideo& video,
|
||||
game_display(game_board& board,
|
||||
std::weak_ptr<wb::manager> wb,
|
||||
reports & reports_object,
|
||||
const tod_manager& tod_manager,
|
||||
|
@ -44,7 +44,7 @@ public:
|
|||
const config& level,
|
||||
bool dummy=false);
|
||||
|
||||
static game_display* create_dummy_display(CVideo& video);
|
||||
static game_display* create_dummy_display();
|
||||
|
||||
~game_display();
|
||||
static game_display* get_singleton()
|
||||
|
|
|
@ -50,7 +50,7 @@ static lg::log_domain log_mp("mp/main");
|
|||
namespace
|
||||
{
|
||||
/** Opens a new server connection and prompts the client for login credentials, if necessary. */
|
||||
std::pair<wesnothd_connection_ptr, config> open_connection(CVideo& video, std::string host)
|
||||
std::pair<wesnothd_connection_ptr, config> open_connection(std::string host)
|
||||
{
|
||||
DBG_MP << "opening connection" << std::endl;
|
||||
|
||||
|
@ -323,7 +323,7 @@ std::pair<wesnothd_connection_ptr, config> open_connection(CVideo& video, std::s
|
|||
gui2::dialogs::mp_login dlg(host, error_message, !((*error)["password_request"].empty()));
|
||||
|
||||
// Need to show the dialog from the main thread or it won't appear.
|
||||
events::call_in_main_thread([&dlg, &video]() { dlg.show(); });
|
||||
events::call_in_main_thread([&dlg]() { dlg.show(); });
|
||||
|
||||
switch(dlg.get_retval()) {
|
||||
//Log in with password
|
||||
|
@ -360,16 +360,13 @@ std::pair<wesnothd_connection_ptr, config> open_connection(CVideo& video, std::s
|
|||
/** Helper struct to manage the MP workflow arguments. */
|
||||
struct mp_workflow_helper
|
||||
{
|
||||
mp_workflow_helper(CVideo& video, const config& gc, saved_game& state, wesnothd_connection* connection, mp::lobby_info* li)
|
||||
: video(video)
|
||||
, game_config(gc)
|
||||
mp_workflow_helper(const config& gc, saved_game& state, wesnothd_connection* connection, mp::lobby_info* li)
|
||||
: game_config(gc)
|
||||
, state(state)
|
||||
, connection(connection)
|
||||
, lobby_info(li)
|
||||
{}
|
||||
|
||||
CVideo& video;
|
||||
|
||||
const config& game_config;
|
||||
|
||||
saved_game& state;
|
||||
|
@ -423,7 +420,7 @@ void enter_wait_mode(mp_workflow_helper_ptr helper, int game_id, bool observe)
|
|||
}
|
||||
|
||||
if(dlg_ok) {
|
||||
campaign_controller controller(helper->video, helper->state, helper->game_config, game_config_manager::get()->terrain_types());
|
||||
campaign_controller controller(helper->state, helper->game_config, game_config_manager::get()->terrain_types());
|
||||
controller.set_mp_info(campaign_info.get());
|
||||
controller.play_game();
|
||||
}
|
||||
|
@ -454,7 +451,7 @@ void enter_staging_mode(mp_workflow_helper_ptr helper)
|
|||
} // end connect_engine_ptr, dlg scope
|
||||
|
||||
if(dlg_ok) {
|
||||
campaign_controller controller(helper->video, helper->state, helper->game_config, game_config_manager::get()->terrain_types());
|
||||
campaign_controller controller(helper->state, helper->game_config, game_config_manager::get()->terrain_types());
|
||||
controller.set_mp_info(campaign_info.get());
|
||||
controller.play_game();
|
||||
}
|
||||
|
@ -569,7 +566,7 @@ bool enter_lobby_mode(mp_workflow_helper_ptr helper, const std::vector<std::stri
|
|||
/** Pubic entry points for the MP workflow */
|
||||
namespace mp
|
||||
{
|
||||
void start_client(CVideo& video, const config& game_config, saved_game& state, const std::string& host)
|
||||
void start_client(const config& game_config, saved_game& state, const std::string& host)
|
||||
{
|
||||
const config* game_config_ptr = &game_config;
|
||||
|
||||
|
@ -586,7 +583,7 @@ void start_client(CVideo& video, const config& game_config, saved_game& state, c
|
|||
config lobby_config;
|
||||
|
||||
gui2::dialogs::loading_screen::display([&]() {
|
||||
std::tie(connection, lobby_config) = open_connection(video, host);
|
||||
std::tie(connection, lobby_config) = open_connection(host);
|
||||
});
|
||||
|
||||
if(!connection) {
|
||||
|
@ -597,7 +594,7 @@ void start_client(CVideo& video, const config& game_config, saved_game& state, c
|
|||
bool re_enter = false;
|
||||
|
||||
do {
|
||||
workflow_helper.reset(new mp_workflow_helper(video, *game_config_ptr, state, connection.get(), nullptr));
|
||||
workflow_helper.reset(new mp_workflow_helper(*game_config_ptr, state, connection.get(), nullptr));
|
||||
|
||||
// A return of false means a config reload was requested, so do that and then loop.
|
||||
re_enter = !enter_lobby_mode(workflow_helper, installed_addons, lobby_config);
|
||||
|
@ -641,7 +638,7 @@ bool goto_mp_wait(saved_game& state, const config& game_config, wesnothd_connect
|
|||
return dlg.show();
|
||||
}
|
||||
|
||||
void start_local_game(CVideo& video, const config& game_config, saved_game& state)
|
||||
void start_local_game(const config& game_config, saved_game& state)
|
||||
{
|
||||
DBG_MP << "starting local game" << std::endl;
|
||||
|
||||
|
@ -649,12 +646,12 @@ void start_local_game(CVideo& video, const config& game_config, saved_game& stat
|
|||
|
||||
// TODO: should lobby_info take a nullptr in this case, or should we pass the installed_addons data here too?
|
||||
lobby_info li(game_config, {});
|
||||
mp_workflow_helper_ptr workflow_helper = std::make_shared<mp_workflow_helper>(video, game_config, state, nullptr, &li);
|
||||
mp_workflow_helper_ptr workflow_helper = std::make_shared<mp_workflow_helper>(game_config, state, nullptr, &li);
|
||||
|
||||
enter_create_mode(workflow_helper);
|
||||
}
|
||||
|
||||
void start_local_game_commandline(CVideo& video, const config& game_config, saved_game& state, const commandline_options& cmdline_opts)
|
||||
void start_local_game_commandline(const config& game_config, saved_game& state, const commandline_options& cmdline_opts)
|
||||
{
|
||||
DBG_MP << "starting local MP game from commandline" << std::endl;
|
||||
|
||||
|
@ -750,7 +747,7 @@ void start_local_game_commandline(CVideo& video, const config& game_config, save
|
|||
unsigned int repeat = (cmdline_opts.multiplayer_repeat) ? *cmdline_opts.multiplayer_repeat : 1;
|
||||
for(unsigned int i = 0; i < repeat; i++){
|
||||
saved_game state_copy(state);
|
||||
campaign_controller controller(video, state_copy, game_config, game_config_manager::get()->terrain_types());
|
||||
campaign_controller controller(state_copy, game_config, game_config_manager::get()->terrain_types());
|
||||
controller.play_game();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,10 +33,9 @@ const size_t max_login_size = 20;
|
|||
|
||||
/** Starts a multiplayer game in single-user mode.
|
||||
*
|
||||
* @param video The global display
|
||||
* @param game_config The global, top-level WML configuration for the game
|
||||
*/
|
||||
void start_local_game(CVideo& video, const config& game_config,
|
||||
void start_local_game(const config& game_config,
|
||||
saved_game& state);
|
||||
|
||||
/** Starts a multiplayer game in single-user mode.
|
||||
|
@ -44,16 +43,15 @@ void start_local_game(CVideo& video, const config& game_config,
|
|||
* Same parameters as start_local_game plus:
|
||||
* cmdline_opts The commandline options
|
||||
*/
|
||||
void start_local_game_commandline(CVideo& video, const config& game_config,
|
||||
void start_local_game_commandline(const config& game_config,
|
||||
saved_game& state, const commandline_options& cmdline_opts);
|
||||
|
||||
/** Starts a multiplayer game in client mode.
|
||||
*
|
||||
* @param video The global display
|
||||
* @param game_config The global, top-level WML configuration for the game
|
||||
* @param host The host to connect to.
|
||||
*/
|
||||
void start_client(CVideo& video, const config& game_config,
|
||||
void start_client(const config& game_config,
|
||||
saved_game& state, const std::string& host);
|
||||
|
||||
/**
|
||||
|
|
|
@ -186,7 +186,7 @@ void campaign_controller::show_carryover_message(playsingle_controller& playcont
|
|||
|
||||
LEVEL_RESULT campaign_controller::playsingle_scenario(end_level_data &end_level)
|
||||
{
|
||||
playsingle_controller playcontroller(is_replay_ ? state_.get_replay_starting_pos() : state_.get_starting_pos(), state_, game_config_, tdata_, video_, false);
|
||||
playsingle_controller playcontroller(is_replay_ ? state_.get_replay_starting_pos() : state_.get_starting_pos(), state_, game_config_, tdata_, false);
|
||||
LOG_NG << "created objects... " << (SDL_GetTicks() - playcontroller.get_ticks()) << "\n";
|
||||
if(is_replay_) {
|
||||
playcontroller.enable_replay(is_unit_test_);
|
||||
|
@ -208,7 +208,7 @@ LEVEL_RESULT campaign_controller::playsingle_scenario(end_level_data &end_level)
|
|||
end_level = playcontroller.get_end_level_data_const();
|
||||
|
||||
show_carryover_message(playcontroller, end_level, res);
|
||||
if(!video_.faked())
|
||||
if(!CVideo::get_singleton().faked())
|
||||
{
|
||||
playcontroller.maybe_linger();
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ LEVEL_RESULT campaign_controller::playmp_scenario(end_level_data &end_level)
|
|||
{
|
||||
|
||||
playmp_controller playcontroller(state_.get_starting_pos(), state_,
|
||||
game_config_, tdata_, video_, mp_info_);
|
||||
game_config_, tdata_, mp_info_);
|
||||
LEVEL_RESULT res = playcontroller.play_scenario(state_.get_starting_pos());
|
||||
|
||||
//Check if the player started as mp client and changed to host
|
||||
|
|
|
@ -57,7 +57,6 @@ struct mp_campaign_info
|
|||
|
||||
class campaign_controller
|
||||
{
|
||||
CVideo& video_;
|
||||
saved_game& state_;
|
||||
const config& game_config_;
|
||||
const ter_data_cache & tdata_;
|
||||
|
@ -65,9 +64,8 @@ class campaign_controller
|
|||
bool is_replay_;
|
||||
mp_campaign_info* mp_info_;
|
||||
public:
|
||||
campaign_controller(CVideo& video, saved_game& state, const config& game_config, const ter_data_cache & tdata, bool is_unit_test = false)
|
||||
: video_(video)
|
||||
, state_(state)
|
||||
campaign_controller(saved_game& state, const config& game_config, const ter_data_cache & tdata, bool is_unit_test = false)
|
||||
: state_(state)
|
||||
, game_config_(game_config)
|
||||
, tdata_(tdata)
|
||||
, is_unit_test_(is_unit_test)
|
||||
|
|
|
@ -487,7 +487,7 @@ bool game_launcher::play_test()
|
|||
load_game_config_for_game(state_.classification());
|
||||
|
||||
try {
|
||||
campaign_controller ccontroller(video(), state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types());
|
||||
campaign_controller ccontroller(state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types());
|
||||
ccontroller.play_game();
|
||||
} catch (savegame::load_game_exception &e) {
|
||||
load_data_.reset(new savegame::load_game_metadata(std::move(e.data_)));
|
||||
|
@ -521,7 +521,7 @@ int game_launcher::unit_test()
|
|||
load_game_config_for_game(state_.classification());
|
||||
|
||||
try {
|
||||
campaign_controller ccontroller(video(), state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types(), true);
|
||||
campaign_controller ccontroller(state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types(), true);
|
||||
LEVEL_RESULT res = ccontroller.play_game();
|
||||
if (!(res == LEVEL_RESULT::VICTORY) || lg::broke_strict()) {
|
||||
return 1;
|
||||
|
@ -547,7 +547,7 @@ int game_launcher::unit_test()
|
|||
}
|
||||
|
||||
try {
|
||||
campaign_controller ccontroller(video(), state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types(), true);
|
||||
campaign_controller ccontroller(state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types(), true);
|
||||
LEVEL_RESULT res = ccontroller.play_replay();
|
||||
if (!(res == LEVEL_RESULT::VICTORY)) {
|
||||
std::cerr << "Observed failure on replay" << std::endl;
|
||||
|
@ -571,7 +571,7 @@ bool game_launcher::play_screenshot_mode()
|
|||
|
||||
::init_textdomains(game_config_manager::get()->game_config());
|
||||
|
||||
editor::start(game_config_manager::get()->game_config(), video(),
|
||||
editor::start(game_config_manager::get()->game_config(),
|
||||
screenshot_map_, true, screenshot_filename_);
|
||||
return false;
|
||||
}
|
||||
|
@ -849,10 +849,10 @@ bool game_launcher::play_multiplayer(mp_selection res)
|
|||
cursor::set(cursor::NORMAL);
|
||||
|
||||
if(res == MP_LOCAL) {
|
||||
mp::start_local_game(video(),
|
||||
mp::start_local_game(
|
||||
game_config_manager::get()->game_config(), state_);
|
||||
} else {
|
||||
mp::start_client(video(), game_config_manager::get()->game_config(),
|
||||
mp::start_client(game_config_manager::get()->game_config(),
|
||||
state_, multiplayer_server_);
|
||||
multiplayer_server_.clear();
|
||||
}
|
||||
|
@ -912,7 +912,7 @@ bool game_launcher::play_multiplayer_commandline()
|
|||
events::discard_input(); // prevent the "keylogger" effect
|
||||
cursor::set(cursor::NORMAL);
|
||||
|
||||
mp::start_local_game_commandline(video(),
|
||||
mp::start_local_game_commandline(
|
||||
game_config_manager::get()->game_config(), state_, cmdline_opts_);
|
||||
|
||||
return false;
|
||||
|
@ -959,7 +959,7 @@ void game_launcher::launch_game(RELOAD_GAME_DATA reload)
|
|||
});
|
||||
|
||||
try {
|
||||
campaign_controller ccontroller(video(), state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types());
|
||||
campaign_controller ccontroller(state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types());
|
||||
LEVEL_RESULT result = ccontroller.play_game();
|
||||
// don't show The End for multiplayer scenario
|
||||
// change this if MP campaigns are implemented
|
||||
|
@ -986,7 +986,7 @@ void game_launcher::play_replay()
|
|||
{
|
||||
assert(!load_data_);
|
||||
try {
|
||||
campaign_controller ccontroller(video(), state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types());
|
||||
campaign_controller ccontroller(state_, game_config_manager::get()->game_config(), game_config_manager::get()->terrain_types());
|
||||
ccontroller.play_replay();
|
||||
} catch (savegame::load_game_exception &e) {
|
||||
load_data_.reset(new savegame::load_game_metadata(std::move(e.data_)));
|
||||
|
@ -1004,7 +1004,7 @@ editor::EXIT_STATUS game_launcher::start_editor(const std::string& filename)
|
|||
::init_textdomains(game_config_manager::get()->game_config());
|
||||
|
||||
editor::EXIT_STATUS res = editor::start(
|
||||
game_config_manager::get()->game_config(), video(), filename);
|
||||
game_config_manager::get()->game_config(), filename);
|
||||
|
||||
if(res != editor::EXIT_RELOAD_DATA)
|
||||
return res;
|
||||
|
|
|
@ -132,8 +132,7 @@ static void clear_resources()
|
|||
}
|
||||
|
||||
play_controller::play_controller(const config& level, saved_game& state_of_game,
|
||||
const config& game_config, const ter_data_cache& tdata,
|
||||
CVideo& video, bool skip_replay)
|
||||
const config& game_config, const ter_data_cache& tdata, bool skip_replay)
|
||||
: controller_base(game_config)
|
||||
, observer()
|
||||
, quit_confirmation()
|
||||
|
@ -182,7 +181,7 @@ play_controller::play_controller(const config& level, saved_game& state_of_game,
|
|||
hotkey::deactivate_all_scopes();
|
||||
hotkey::set_scope_active(hotkey::SCOPE_GAME);
|
||||
try {
|
||||
init(video, level);
|
||||
init(level);
|
||||
} catch (...) {
|
||||
clear_resources();
|
||||
throw;
|
||||
|
@ -203,10 +202,9 @@ struct throw_end_level
|
|||
}
|
||||
};
|
||||
|
||||
void play_controller::init(CVideo& video, const config& level)
|
||||
void play_controller::init(const config& level)
|
||||
{
|
||||
|
||||
gui2::dialogs::loading_screen::display([this, &video, &level]() {
|
||||
gui2::dialogs::loading_screen::display([this, &level]() {
|
||||
gui2::dialogs::loading_screen::progress(loading_stage::load_level);
|
||||
|
||||
LOG_NG << "initializing game_state..." << (SDL_GetTicks() - ticks()) << std::endl;
|
||||
|
@ -239,7 +237,7 @@ void play_controller::init(CVideo& video, const config& level)
|
|||
|
||||
LOG_NG << "building terrain rules... " << (SDL_GetTicks() - ticks()) << std::endl;
|
||||
gui2::dialogs::loading_screen::progress(loading_stage::build_terrain);
|
||||
gui_.reset(new game_display(gamestate().board_, video, whiteboard_manager_, *gamestate().reports_, gamestate().tod_manager_, theme_cfg, level));
|
||||
gui_.reset(new game_display(gamestate().board_, whiteboard_manager_, *gamestate().reports_, gamestate().tod_manager_, theme_cfg, level));
|
||||
map_start_ = map_location(level.child_or_empty("display").child_or_empty("location"));
|
||||
if (!gui_->video().faked()) {
|
||||
if (saved_game_.mp_settings().mp_countdown)
|
||||
|
@ -334,7 +332,7 @@ void play_controller::init_managers()
|
|||
{
|
||||
LOG_NG << "initializing managers... " << (SDL_GetTicks() - ticks()) << std::endl;
|
||||
preferences::set_preference_display_settings();
|
||||
tooltips_manager_.reset(new tooltips::manager(gui_->video()));
|
||||
tooltips_manager_.reset(new tooltips::manager());
|
||||
soundsources_manager_.reset(new soundsource::manager(*gui_));
|
||||
|
||||
resources::soundsources = soundsources_manager_.get();
|
||||
|
|
|
@ -77,8 +77,7 @@ class play_controller : public controller_base, public events::observer, public
|
|||
public:
|
||||
play_controller(const config& level, saved_game& state_of_game,
|
||||
const config& game_config,
|
||||
const ter_data_cache& tdata,
|
||||
CVideo& video, bool skip_replay);
|
||||
const ter_data_cache& tdata, bool skip_replay);
|
||||
virtual ~play_controller();
|
||||
|
||||
//event handler, overridden from observer
|
||||
|
@ -351,7 +350,7 @@ protected:
|
|||
|
||||
private:
|
||||
|
||||
void init(CVideo& video, const config& level);
|
||||
void init(const config& level);
|
||||
|
||||
bool victory_when_enemies_defeated_;
|
||||
bool remove_from_carryover_on_defeat_;
|
||||
|
|
|
@ -41,10 +41,9 @@ static lg::log_domain log_engine("engine");
|
|||
|
||||
playmp_controller::playmp_controller(const config& level,
|
||||
saved_game& state_of_game, const config& game_config,
|
||||
const ter_data_cache & tdata, CVideo& video,
|
||||
const ter_data_cache & tdata,
|
||||
mp_campaign_info* mp_info)
|
||||
: playsingle_controller(level, state_of_game, game_config, tdata, video,
|
||||
mp_info && mp_info->skip_replay)
|
||||
: playsingle_controller(level, state_of_game, game_config, tdata, mp_info && mp_info->skip_replay)
|
||||
, network_processing_stopped_(false)
|
||||
, blindfold_(*gui_, mp_info && mp_info->skip_replay_blindfolded)
|
||||
, mp_info_(mp_info)
|
||||
|
|
|
@ -25,8 +25,7 @@ class playmp_controller : public playsingle_controller, public syncmp_handler
|
|||
public:
|
||||
playmp_controller(const config& level, saved_game& state_of_game,
|
||||
const config& game_config,
|
||||
const ter_data_cache & tdata, CVideo& video,
|
||||
mp_campaign_info* mp_info);
|
||||
const ter_data_cache & tdata, mp_campaign_info* mp_info);
|
||||
virtual ~playmp_controller();
|
||||
|
||||
void maybe_linger() override;
|
||||
|
|
|
@ -67,9 +67,8 @@ static lg::log_domain log_enginerefac("enginerefac");
|
|||
|
||||
playsingle_controller::playsingle_controller(const config& level,
|
||||
saved_game& state_of_game,
|
||||
const config& game_config, const ter_data_cache & tdata,
|
||||
CVideo& video, bool skip_replay)
|
||||
: play_controller(level, state_of_game, game_config, tdata, video, skip_replay)
|
||||
const config& game_config, const ter_data_cache & tdata, bool skip_replay)
|
||||
: play_controller(level, state_of_game, game_config, tdata, skip_replay)
|
||||
, cursor_setter_(cursor::NORMAL)
|
||||
, textbox_info_()
|
||||
, replay_sender_(*resources::recorder)
|
||||
|
|
|
@ -37,7 +37,7 @@ class playsingle_controller : public play_controller
|
|||
{
|
||||
public:
|
||||
playsingle_controller(const config& level, saved_game& state_of_game,
|
||||
const config& game_config, const ter_data_cache & tdata, CVideo& video, bool skip_replay);
|
||||
const config& game_config, const ter_data_cache & tdata, bool skip_replay);
|
||||
virtual ~playsingle_controller();
|
||||
|
||||
LEVEL_RESULT play_scenario(const config& level);
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
|
||||
namespace {
|
||||
|
||||
CVideo* video_ = nullptr;
|
||||
|
||||
static const int font_size = font::SIZE_NORMAL;
|
||||
static const int text_width = 400;
|
||||
|
||||
|
@ -64,7 +62,7 @@ static void clear_tooltip()
|
|||
|
||||
static void show_tooltip(const tooltip& tip)
|
||||
{
|
||||
if(video_ == nullptr) {
|
||||
if(CVideo::get_singleton().faked()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -108,10 +106,9 @@ static void show_tooltip(const tooltip& tip)
|
|||
|
||||
namespace tooltips {
|
||||
|
||||
manager::manager(CVideo& video)
|
||||
manager::manager()
|
||||
{
|
||||
clear_tooltips();
|
||||
video_ = &video;
|
||||
}
|
||||
|
||||
manager::~manager()
|
||||
|
@ -119,7 +116,6 @@ manager::~manager()
|
|||
try {
|
||||
clear_tooltips();
|
||||
} catch (...) {}
|
||||
video_ = nullptr;
|
||||
}
|
||||
|
||||
void clear_tooltips()
|
||||
|
|
|
@ -17,14 +17,13 @@
|
|||
#include <string>
|
||||
#include "sdl/surface.hpp"
|
||||
|
||||
class CVideo;
|
||||
struct SDL_Rect;
|
||||
|
||||
namespace tooltips {
|
||||
|
||||
struct manager
|
||||
{
|
||||
manager(CVideo& video);
|
||||
manager();
|
||||
~manager();
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue