Created pure virtual game_controller_abstract class,

...which is game_controller's parent
This commit is contained in:
Lukasz Dobrogowski 2011-05-27 22:44:45 +00:00
parent 7068d65385
commit 670f4e940a
3 changed files with 72 additions and 8 deletions

View file

@ -619,7 +619,7 @@ static int do_gameloop(int argc, char** argv)
//static initialization (before any srand() call)
recorder.set_seed(rand());
boost::shared_ptr<game_controller> game = boost::shared_ptr<game_controller>(new game_controller(argc,argv));
boost::shared_ptr<game_controller_abstract> game = boost::shared_ptr<game_controller_abstract>(new game_controller(argc,argv));
const int start_ticks = SDL_GetTicks();
init_locale();
@ -756,7 +756,7 @@ static int do_gameloop(int argc, char** argv)
res = static_cast<gui2::ttitle_screen::tresult>(dlg.get_retval());
}
game_controller::RELOAD_GAME_DATA should_reload = game_controller::RELOAD_DATA;
game_controller_abstract::RELOAD_GAME_DATA should_reload = game_controller_abstract::RELOAD_DATA;
if(res == gui2::ttitle_screen::QUIT_GAME) {
LOG_GENERAL << "quitting game->..\n";
@ -767,7 +767,7 @@ static int do_gameloop(int argc, char** argv)
res = gui2::ttitle_screen::NOTHING;
continue;
}
should_reload = game_controller::NO_RELOAD_DATA;
should_reload = game_controller_abstract::NO_RELOAD_DATA;
} else if(res == gui2::ttitle_screen::TUTORIAL) {
game->set_tutorial();
} else if(res == gui2::ttitle_screen::NEW_CAMPAIGN) {

View file

@ -15,8 +15,9 @@
#ifndef GAME_CONTROLLER_H_INCLUDED
#define GAME_CONTROLLER_H_INCLUDED
#include "game_controller_abstract.hpp"
#include "config_cache.hpp"
#include "editor/editor_main.hpp"
#include "filesystem.hpp"
#include "gamestatus.hpp"
#include "game_config.hpp"
@ -41,7 +42,7 @@ public:
std::string campaign_id_,scenario_id_;
};
class game_controller
class game_controller : public game_controller_abstract
{
public:
game_controller(int argc, char** argv);
@ -49,8 +50,8 @@ public:
game_display& disp();
bool init_config() { return init_config(false); }
bool init_video();
bool init_config(const bool force=false);
bool init_language();
bool play_test();
bool play_multiplayer_mode();
@ -74,11 +75,10 @@ public:
void show_preferences();
enum RELOAD_GAME_DATA { RELOAD_DATA, NO_RELOAD_DATA };
void launch_game(RELOAD_GAME_DATA reload=RELOAD_DATA);
void play_replay();
editor::EXIT_STATUS start_editor(const std::string& filename = "");
editor::EXIT_STATUS start_editor() { return start_editor(""); }
void start_wesnothd();
const config& game_config() const { return game_config_; }
@ -87,10 +87,13 @@ private:
game_controller(const game_controller&);
void operator=(const game_controller&);
bool init_config(const bool force);
void load_game_cfg(const bool force=false);
void set_unit_data();
void mark_completed_campaigns(std::vector<config>& campaigns);
editor::EXIT_STATUS start_editor(const std::string& filename);
const int argc_;
int arg_;

View file

@ -0,0 +1,61 @@
/* $Id$ */
/*
Copyright (C) 2011 by Lukasz Dobrogowski <lukasz.dobrogowski@gmail.com>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#ifndef GAME_CONTROLLER_ABSTRACT_H_INCLUDED
#define GAME_CONTROLLER_ABSTRACT_H_INCLUDED
#include "editor/editor_main.hpp"
#include <string>
class config;
class game_display;
class game_controller_abstract
{
public:
virtual game_display& disp() = 0;
virtual bool init_video() = 0;
virtual bool init_config() = 0;
virtual bool init_language() = 0;
virtual bool play_test() = 0;
virtual bool play_multiplayer_mode() = 0;
virtual bool play_screenshot_mode() = 0;
virtual void reload_changed_game_config() = 0;
virtual bool is_loading() const = 0;
virtual void clear_loaded_game() = 0;
virtual bool load_game() = 0;
virtual void set_tutorial() = 0;
virtual std::string jump_to_campaign_id() const = 0;
virtual bool new_campaign() = 0;
virtual bool goto_campaign() = 0;
virtual bool goto_multiplayer() = 0;
virtual bool goto_editor() = 0;
virtual bool play_multiplayer() = 0;
virtual bool change_language() = 0;
virtual void show_preferences() = 0;
enum RELOAD_GAME_DATA { RELOAD_DATA, NO_RELOAD_DATA };
virtual void launch_game(RELOAD_GAME_DATA) = 0;
virtual void play_replay() = 0;
virtual editor::EXIT_STATUS start_editor() = 0;
virtual const config& game_config() const = 0;
};
#endif