added game_controller_new, which takes over game_controller...
...responsibilities in case of --new-syntax
This commit is contained in:
parent
470a0067bd
commit
99f15ffae5
9 changed files with 222 additions and 25 deletions
|
@ -359,6 +359,7 @@ set(wesnoth-main_SRC
|
|||
formula_string_utils.cpp
|
||||
formula_tokenizer.cpp
|
||||
game_controller.cpp
|
||||
game_controller_abstract.cpp
|
||||
game_controller_new.cpp
|
||||
game_display.cpp
|
||||
game_errors.cpp
|
||||
|
|
|
@ -221,6 +221,7 @@ wesnoth_sources = Split("""
|
|||
formula_string_utils.cpp
|
||||
formula_tokenizer.cpp
|
||||
game_controller.cpp
|
||||
game_controller_abstract.cpp
|
||||
game_controller_new.cpp
|
||||
game_display.cpp
|
||||
game_errors.cpp
|
||||
|
|
|
@ -318,6 +318,8 @@ static int process_command_args(int argc, char** argv) {
|
|||
std::cout << "Battle for Wesnoth" << " " << game_config::version
|
||||
<< "\n";
|
||||
return 0;
|
||||
} else if (val == "--new-syntax") {
|
||||
game_config::new_syntax = true;
|
||||
} else if (val == "--config-path") {
|
||||
std::cout << get_user_data_dir() << '\n';
|
||||
return 0;
|
||||
|
@ -620,8 +622,11 @@ static int do_gameloop(int argc, char** argv)
|
|||
//ensure recorder has an actually random seed instead of what it got during
|
||||
//static initialization (before any srand() call)
|
||||
recorder.set_seed(rand());
|
||||
|
||||
boost::shared_ptr<game_controller_abstract> game = boost::shared_ptr<game_controller_abstract>(new game_controller(argc,argv));
|
||||
boost::shared_ptr<game_controller_abstract> game;
|
||||
if (game_config::new_syntax)
|
||||
game = boost::shared_ptr<game_controller_abstract>(new game_controller_new());
|
||||
else
|
||||
game = boost::shared_ptr<game_controller_abstract>(new game_controller(argc,argv));
|
||||
const int start_ticks = SDL_GetTicks();
|
||||
|
||||
init_locale();
|
||||
|
|
|
@ -71,7 +71,6 @@ game_controller::game_controller(int argc, char** argv) :
|
|||
arg_(1),
|
||||
argv_(argv),
|
||||
thread_manager(),
|
||||
video_(),
|
||||
font_manager_(),
|
||||
prefs_manager_(),
|
||||
image_manager_(),
|
||||
|
@ -90,7 +89,6 @@ game_controller::game_controller(int argc, char** argv) :
|
|||
force_bpp_(-1),
|
||||
game_config_(),
|
||||
old_defines_map_(),
|
||||
disp_(NULL),
|
||||
state_(),
|
||||
multiplayer_server_(),
|
||||
jump_to_multiplayer_(false),
|
||||
|
@ -318,9 +316,6 @@ game_controller::game_controller(int argc, char** argv) :
|
|||
// This is a hidden option to enable the new widget toolkit.
|
||||
gui2::new_widgets = true;
|
||||
}
|
||||
else if (val == "--new-syntax") {
|
||||
game_config::new_syntax = true;
|
||||
}
|
||||
else if(val == "--clock") {
|
||||
gui2::show_debug_clock_button = true;
|
||||
} else if(val == "-e" || val == "--editor") {
|
||||
|
@ -376,17 +371,6 @@ game_controller::game_controller(int argc, char** argv) :
|
|||
}
|
||||
}
|
||||
|
||||
game_display& game_controller::disp()
|
||||
{
|
||||
if(disp_.get() == NULL) {
|
||||
if(get_video_surface() == NULL) {
|
||||
throw CVideo::error();
|
||||
}
|
||||
disp_.assign(game_display::create_dummy_display(video_));
|
||||
}
|
||||
return *disp_.get();
|
||||
}
|
||||
|
||||
bool game_controller::init_video()
|
||||
{
|
||||
if(no_gui_) {
|
||||
|
|
|
@ -48,8 +48,6 @@ public:
|
|||
game_controller(int argc, char** argv);
|
||||
~game_controller();
|
||||
|
||||
game_display& disp();
|
||||
|
||||
bool init_config() { return init_config(false); }
|
||||
bool init_video();
|
||||
bool init_language();
|
||||
|
@ -103,8 +101,6 @@ private:
|
|||
//to clean up threads after the display disappears.
|
||||
const threading::manager thread_manager;
|
||||
|
||||
CVideo video_;
|
||||
|
||||
const font::manager font_manager_;
|
||||
const preferences::manager prefs_manager_;
|
||||
const image::manager image_manager_;
|
||||
|
@ -123,8 +119,6 @@ private:
|
|||
config game_config_;
|
||||
preproc_map old_defines_map_;
|
||||
|
||||
util::scoped_ptr<game_display> disp_;
|
||||
|
||||
/// Stateful class taking over scenario-switching capabilities from the current game_controller and playsingle_controller. Currently only available when --new-syntax command line option is enabled.
|
||||
game_state state_;
|
||||
|
||||
|
|
36
src/game_controller_abstract.cpp
Normal file
36
src/game_controller_abstract.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
/* $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.
|
||||
*/
|
||||
|
||||
#include "game_controller_abstract.hpp"
|
||||
|
||||
#include "game_display.hpp"
|
||||
|
||||
game_controller_abstract::game_controller_abstract() :
|
||||
disp_(NULL),
|
||||
video_()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
game_display& game_controller_abstract::disp()
|
||||
{
|
||||
if(disp_.get() == NULL) {
|
||||
if(get_video_surface() == NULL) {
|
||||
throw CVideo::error();
|
||||
}
|
||||
disp_.assign(game_display::create_dummy_display(video_));
|
||||
}
|
||||
return *disp_.get();
|
||||
}
|
|
@ -15,6 +15,8 @@
|
|||
#ifndef GAME_CONTROLLER_ABSTRACT_H_INCLUDED
|
||||
#define GAME_CONTROLLER_ABSTRACT_H_INCLUDED
|
||||
#include "editor/editor_main.hpp"
|
||||
#include "scoped_resource.hpp"
|
||||
#include "video.hpp"
|
||||
#include <string>
|
||||
|
||||
class config;
|
||||
|
@ -23,9 +25,10 @@ class game_display;
|
|||
class game_controller_abstract
|
||||
{
|
||||
public:
|
||||
game_controller_abstract();
|
||||
virtual ~game_controller_abstract() {}
|
||||
|
||||
virtual game_display& disp() = 0;
|
||||
game_display& disp();
|
||||
|
||||
virtual bool init_video() = 0;
|
||||
virtual bool init_config() = 0;
|
||||
|
@ -59,5 +62,9 @@ public:
|
|||
virtual editor::EXIT_STATUS start_editor() = 0;
|
||||
|
||||
virtual const config& game_config() const = 0;
|
||||
protected:
|
||||
util::scoped_ptr<game_display> disp_;
|
||||
|
||||
CVideo video_;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -14,3 +14,131 @@
|
|||
*/
|
||||
|
||||
#include "game_controller_new.hpp"
|
||||
#include "game_display.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
game_controller_new::game_controller_new() :
|
||||
main_config_()
|
||||
{
|
||||
}
|
||||
|
||||
game_controller_new::~game_controller_new()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool game_controller_new::init_config()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool game_controller_new::init_video()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool game_controller_new::init_language()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool game_controller_new::play_test()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool game_controller_new::play_multiplayer_mode()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool game_controller_new::play_screenshot_mode()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void game_controller_new::reload_changed_game_config()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool game_controller_new::is_loading() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void game_controller_new::clear_loaded_game()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool game_controller_new::load_game()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void game_controller_new::set_tutorial()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string game_controller_new::jump_to_campaign_id() const
|
||||
{
|
||||
return std::string();
|
||||
}
|
||||
|
||||
bool game_controller_new::new_campaign()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool game_controller_new::goto_campaign()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool game_controller_new::goto_multiplayer()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool game_controller_new::goto_editor()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool game_controller_new::play_multiplayer()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool game_controller_new::change_language()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void game_controller_new::show_preferences()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void game_controller_new::launch_game ( game_controller_abstract::RELOAD_GAME_DATA /*reload*/ )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void game_controller_new::play_replay()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
editor::EXIT_STATUS game_controller_new::start_editor()
|
||||
{
|
||||
return editor::EXIT_NORMAL;
|
||||
}
|
||||
|
||||
const config& game_controller_new::game_config() const
|
||||
{
|
||||
return main_config_;
|
||||
}
|
||||
|
|
|
@ -17,8 +17,49 @@
|
|||
#define GAME_CONTROLLER_NEW_HPP_INCLUDED
|
||||
#include "game_controller_abstract.hpp"
|
||||
|
||||
#include "config.hpp"
|
||||
|
||||
class game_controller_new : public game_controller_abstract
|
||||
{
|
||||
public:
|
||||
game_controller_new();
|
||||
~game_controller_new();
|
||||
|
||||
bool init_config();
|
||||
bool init_video();
|
||||
bool init_language();
|
||||
bool play_test();
|
||||
bool play_multiplayer_mode();
|
||||
bool play_screenshot_mode();
|
||||
|
||||
void reload_changed_game_config();
|
||||
|
||||
bool is_loading() const;
|
||||
void clear_loaded_game();
|
||||
bool load_game();
|
||||
void set_tutorial();
|
||||
|
||||
std::string jump_to_campaign_id() const;
|
||||
bool new_campaign();
|
||||
bool goto_campaign();
|
||||
bool goto_multiplayer();
|
||||
bool goto_editor();
|
||||
|
||||
bool play_multiplayer();
|
||||
bool change_language();
|
||||
|
||||
void show_preferences();
|
||||
|
||||
void launch_game(RELOAD_GAME_DATA reload=RELOAD_DATA);
|
||||
void play_replay();
|
||||
|
||||
editor::EXIT_STATUS start_editor();
|
||||
|
||||
const config& game_config() const;
|
||||
|
||||
private:
|
||||
config main_config_;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue