move game_classification to its own file

This commit is contained in:
gfgtdf 2014-06-16 23:52:46 +02:00
parent 64580a7a81
commit 63c07fea3e
30 changed files with 178 additions and 143 deletions

View File

@ -740,6 +740,7 @@ set(wesnoth-main_SRC
formula_string_utils.cpp
formula_tokenizer.cpp
game_board.cpp
game_classification.cpp
game_config_manager.cpp
game_controller.cpp
game_display.cpp

View File

@ -273,6 +273,7 @@ wesnoth_sources = Split("""
formula_string_utils.cpp
formula_tokenizer.cpp
game_board.cpp
game_classification.cpp
game_config_manager.cpp
game_controller.cpp
game_display.cpp

View File

@ -23,7 +23,6 @@
#include "../manager.hpp"
#include "../../log.hpp"
#include "../lua/lua_object.hpp"
#include "../../gamestatus.hpp"
#include "../../resources.hpp"
#include "../../scripting/lua.hpp"
#include "../../terrain_filter.hpp"

View File

@ -27,7 +27,7 @@
#include "../../dialogs.hpp"
#include "../../game_board.hpp"
#include "../../game_events/pump.hpp"
#include "../../gamestatus.hpp"
#include "../../game_classification.hpp"
#include "../../log.hpp"
#include "../../mouse_handler_base.hpp"
#include "../../resources.hpp"

View File

@ -33,7 +33,6 @@
#include "../../attack_prediction.hpp"
#include "../../filesystem.hpp"
#include "../../game_display.hpp"
#include "../../gamestatus.hpp"
#include "../../log.hpp"
#include "../../map.hpp"
#include "../../pathfind/pathfind.hpp"

View File

@ -24,6 +24,7 @@
#include "../composite/rca.hpp"
#include "../composite/stage.hpp"
#include "../../game_board.hpp"
#include "../../game_classification.hpp"
#include "../../gamestatus.hpp"
#include "../../log.hpp"
#include "../../map.hpp"

View File

@ -24,7 +24,6 @@
#include "../composite/rca.hpp"
#include "../composite/stage.hpp"
#include "../../game_board.hpp"
#include "../../gamestatus.hpp"
#include "../../log.hpp"
#include "../../map.hpp"
#include "../../resources.hpp"

View File

@ -16,8 +16,9 @@
#define EDITOR_MAP_CONTEXT_HPP_INCLUDED
#include "editor_map.hpp"
#include "gamestatus.hpp"
#include "game_classification.hpp"
#include "map_label.hpp"
#include "mp_game_settings.hpp"
#include "sound_music_track.hpp"
#include "tod_manager.hpp"
#include "unit_map.hpp"

101
src/game_classification.cpp Normal file
View File

@ -0,0 +1,101 @@
/*
Copyright (C) 2003 - 2014 by David White <dave@whitevine.net>
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 "global.hpp"
#include "game_classification.hpp"
#include "util.hpp"
#include "serialization/string_utils.hpp"
#include "log.hpp"
static lg::log_domain log_engine("engine");
#define ERR_NG LOG_STREAM(err, log_engine)
#define WRN_NG LOG_STREAM(warn, log_engine)
#define LOG_NG LOG_STREAM(info, log_engine)
#define DBG_NG LOG_STREAM(debug, log_engine)
/// The default difficulty setting for campaigns.
const std::string DEFAULT_DIFFICULTY("NORMAL");
game_classification::game_classification():
savegame_config(),
label(),
version(),
campaign_type(),
campaign_define(),
campaign_xtra_defines(),
campaign(),
abbrev(),
completion(),
end_credits(true),
end_text(),
end_text_duration(),
difficulty(DEFAULT_DIFFICULTY),
random_mode("")
{}
game_classification::game_classification(const config& cfg):
savegame_config(),
label(cfg["label"]),
version(cfg["version"]),
campaign_type(lexical_cast_default<game_classification::CAMPAIGN_TYPE> (cfg["campaign_type"].str(), game_classification::SCENARIO)),
campaign_define(cfg["campaign_define"]),
campaign_xtra_defines(utils::split(cfg["campaign_extra_defines"])),
campaign(cfg["campaign"]),
abbrev(cfg["abbrev"]),
completion(cfg["completion"]),
end_credits(cfg["end_credits"].to_bool(true)),
end_text(cfg["end_text"]),
end_text_duration(cfg["end_text_duration"]),
difficulty(cfg["difficulty"].empty() ? DEFAULT_DIFFICULTY : cfg["difficulty"].str()),
random_mode(cfg["random_mode"])
{}
game_classification::game_classification(const game_classification& gc):
savegame_config(),
label(gc.label),
version(gc.version),
campaign_type(gc.campaign_type),
campaign_define(gc.campaign_define),
campaign_xtra_defines(gc.campaign_xtra_defines),
campaign(gc.campaign),
abbrev(gc.abbrev),
completion(gc.completion),
end_credits(gc.end_credits),
end_text(gc.end_text),
end_text_duration(gc.end_text_duration),
difficulty(gc.difficulty),
random_mode(gc.random_mode)
{
}
config game_classification::to_config() const
{
config cfg;
cfg["label"] = label;
cfg["version"] = game_config::version;
cfg["campaign_type"] = lexical_cast<std::string> (campaign_type);
cfg["campaign_define"] = campaign_define;
cfg["campaign_extra_defines"] = utils::join(campaign_xtra_defines);
cfg["campaign"] = campaign;
cfg["abbrev"] = abbrev;
cfg["completion"] = completion;
cfg["end_credits"] = end_credits;
cfg["end_text"] = end_text;
cfg["end_text_duration"] = str_cast<unsigned int>(end_text_duration);
cfg["difficulty"] = difficulty;
cfg["random_mode"] = random_mode;
return cfg;
}

View File

@ -0,0 +1,61 @@
/*
Copyright (C) 2003 - 2014 by David White <dave@whitevine.net>
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_CLASSIFICATION_HPP_INCLUDED
#define GAME_CLASSIFICATION_HPP_INCLUDED
#include "config.hpp"
#include "make_enum.hpp"
#include "savegame_config.hpp"
/// The default difficulty setting for campaigns.
extern const std::string DEFAULT_DIFFICULTY;
//meta information of the game
class game_classification : public savegame::savegame_config
{
public:
game_classification();
explicit game_classification(const config& cfg);
game_classification(const game_classification& gc);
config to_config() const;
std::string label; /**< Name of the game (e.g. name of save file). */
std::string version; /**< Version game was created with. */
MAKE_ENUM (CAMPAIGN_TYPE, /**< Type of the game - campaign, multiplayer etc. */
(SCENARIO, "scenario")
(MULTIPLAYER, "multiplayer")
(TEST, "test")
(TUTORIAL, "tutorial")
)
CAMPAIGN_TYPE campaign_type;
std::string campaign_define; /**< If there is a define the campaign uses to customize data */
std::vector<std::string> campaign_xtra_defines; /**< more customization of data */
std::string campaign; /**< the campaign being played */
std::string abbrev; /**< the campaign abbreviation */
// std::string scenario; /**< the scenario being played */
// std::string next_scenario; /**< the scenario coming next (for campaigns) */
std::string completion; /**< running. victory, or defeat */
bool end_credits; /**< whether to show the standard credits at the end */
std::string end_text; /**< end-of-campaign text */
unsigned int end_text_duration; /**< for how long the end-of-campaign text is shown */
std::string difficulty; /**< The difficulty level the game is being played on. */
std::string random_mode;
};
MAKE_ENUM_STREAM_OPS2(game_classification, CAMPAIGN_TYPE)
#endif

View File

@ -19,6 +19,7 @@
#include "cursor.hpp"
#include "game_config.hpp"
#include "gettext.hpp"
#include "game_classification.hpp"
#include "gui/dialogs/wml_error.hpp"
#include "hotkey/hotkey_item.hpp"
#include "hotkey/hotkey_command.hpp"

View File

@ -16,11 +16,11 @@
#include "commandline_options.hpp"
#include "config_cache.hpp"
#include "gamestatus.hpp"
#include "game_display.hpp"
#include "filesystem.hpp"
class config;
class game_classification;
class game_config_manager
{

View File

@ -32,6 +32,7 @@
#include "../dialogs.hpp"
#include "../fake_unit.hpp"
#include "../fake_unit_manager.hpp"
#include "../game_classification.hpp"
#include "../game_display.hpp"
#include "../game_preferences.hpp"
#include "../gettext.hpp"

View File

@ -19,7 +19,6 @@
#include "game_board.hpp"
#include "game_display.hpp"
#include "game_preferences.hpp"
#include "gamestatus.hpp"
#include "gettext.hpp"
#include "log.hpp"
#include "map.hpp"

View File

@ -523,76 +523,3 @@ game_data* game_data::operator=(const game_data* info)
}
return this ;
}
game_classification::game_classification():
savegame_config(),
label(),
version(),
campaign_type(),
campaign_define(),
campaign_xtra_defines(),
campaign(),
abbrev(),
completion(),
end_credits(true),
end_text(),
end_text_duration(),
difficulty(DEFAULT_DIFFICULTY),
random_mode("")
{}
game_classification::game_classification(const config& cfg):
savegame_config(),
label(cfg["label"]),
version(cfg["version"]),
campaign_type(lexical_cast_default<game_classification::CAMPAIGN_TYPE> (cfg["campaign_type"].str(), game_classification::SCENARIO)),
campaign_define(cfg["campaign_define"]),
campaign_xtra_defines(utils::split(cfg["campaign_extra_defines"])),
campaign(cfg["campaign"]),
abbrev(cfg["abbrev"]),
completion(cfg["completion"]),
end_credits(cfg["end_credits"].to_bool(true)),
end_text(cfg["end_text"]),
end_text_duration(cfg["end_text_duration"]),
difficulty(cfg["difficulty"].empty() ? DEFAULT_DIFFICULTY : cfg["difficulty"].str()),
random_mode(cfg["random_mode"])
{}
game_classification::game_classification(const game_classification& gc):
savegame_config(),
label(gc.label),
version(gc.version),
campaign_type(gc.campaign_type),
campaign_define(gc.campaign_define),
campaign_xtra_defines(gc.campaign_xtra_defines),
campaign(gc.campaign),
abbrev(gc.abbrev),
completion(gc.completion),
end_credits(gc.end_credits),
end_text(gc.end_text),
end_text_duration(gc.end_text_duration),
difficulty(gc.difficulty),
random_mode(gc.random_mode)
{
}
config game_classification::to_config() const
{
config cfg;
cfg["label"] = label;
cfg["version"] = game_config::version;
cfg["campaign_type"] = lexical_cast<std::string> (campaign_type);
cfg["campaign_define"] = campaign_define;
cfg["campaign_extra_defines"] = utils::join(campaign_xtra_defines);
cfg["campaign"] = campaign;
cfg["abbrev"] = abbrev;
cfg["completion"] = completion;
cfg["end_credits"] = end_credits;
cfg["end_text"] = end_text;
cfg["end_text_duration"] = str_cast<unsigned int>(end_text_duration);
cfg["difficulty"] = difficulty;
cfg["random_mode"] = random_mode;
return cfg;
}

View File

@ -20,9 +20,7 @@
#include "config.hpp"
#include "game_end_exceptions.hpp"
#include "game_events/wmi_container.hpp"
#include "make_enum.hpp"
#include "map_location.hpp"
#include "mp_game_settings.hpp"
#include "simple_rng.hpp"
#include <boost/shared_ptr.hpp>
@ -35,22 +33,13 @@ class t_string;
class team;
class unit_map;
// Defined later in this header:
class game_data;
namespace t_translation {
struct t_match;
}
extern int sdfasf;
class team_builder;
typedef boost::shared_ptr<team_builder> team_builder_ptr;
/// The default difficulty setting for campaigns.
extern const std::string DEFAULT_DIFFICULTY;
class game_data : public variable_set {
public:
game_data();
@ -125,40 +114,4 @@ private:
std::string next_scenario_; /**< the scenario coming next (for campaigns) */
};
//meta information of the game
class game_classification : public savegame::savegame_config
{
public:
game_classification();
explicit game_classification(const config& cfg);
game_classification(const game_classification& gc);
config to_config() const;
std::string label; /**< Name of the game (e.g. name of save file). */
std::string version; /**< Version game was created with. */
MAKE_ENUM (CAMPAIGN_TYPE, /**< Type of the game - campaign, multiplayer etc. */
(SCENARIO, "scenario")
(MULTIPLAYER, "multiplayer")
(TEST, "test")
(TUTORIAL, "tutorial")
)
CAMPAIGN_TYPE campaign_type;
std::string campaign_define; /**< If there is a define the campaign uses to customize data */
std::vector<std::string> campaign_xtra_defines; /**< more customization of data */
std::string campaign; /**< the campaign being played */
std::string abbrev; /**< the campaign abbreviation */
// std::string scenario; /**< the scenario being played */
// std::string next_scenario; /**< the scenario coming next (for campaigns) */
std::string completion; /**< running. victory, or defeat */
bool end_credits; /**< whether to show the standard credits at the end */
std::string end_text; /**< end-of-campaign text */
unsigned int end_text_duration; /**< for how long the end-of-campaign text is shown */
std::string difficulty; /**< The difficulty level the game is being played on. */
std::string random_mode;
};
MAKE_ENUM_STREAM_OPS2(game_classification, CAMPAIGN_TYPE)
#endif

View File

@ -32,7 +32,6 @@
#include "../../clipboard.hpp"
#include "../../game_preferences.hpp"
#include "../../gamestatus.hpp"
#include "../../log.hpp"
#include "../../resources.hpp"
#include "../../team.hpp"

View File

@ -20,7 +20,7 @@
#include "gettext.hpp"
#include "game_config.hpp"
#include "game_preferences.hpp"
#include "gamestatus.hpp"
#include "game_classification.hpp"
#include "gui/auxiliary/log.hpp"
#include "gui/dialogs/field.hpp"
#include "gui/dialogs/game_delete.hpp"

View File

@ -18,7 +18,6 @@
#define MULTIPLAYER_CONNECT_H_INCLUDED
#include "commandline_options.hpp"
#include "gamestatus.hpp"
#include "multiplayer_connect_engine.hpp"
#include "multiplayer_ui.hpp"
#include "widgets/combo_drag.hpp"

View File

@ -15,7 +15,6 @@
#include "global.hpp"
#include "construct_dialog.hpp"
#include "gamestatus.hpp"
#include "game_display.hpp"
#include "game_preferences.hpp"
#include "gettext.hpp"

View File

@ -16,7 +16,6 @@
#define MULTIPLAYER_WAIT_HPP_INCLUDED
#include "flg_manager.hpp"
#include "gamestatus.hpp"
#include "multiplayer_ui.hpp"
#include "show_dialog.hpp"
#include "widgets/combo.hpp"

View File

@ -17,7 +17,6 @@
#define REPLAY_CONTROLLER_H_INCLUDED
#include "game_end_exceptions.hpp"
#include "gamestatus.hpp"
#include "saved_game.hpp"
#include "play_controller.hpp"

View File

@ -28,7 +28,6 @@
#include "serialization/binary_or_text.hpp"
#include "serialization/parser.hpp"
#include "gamestatus.hpp"
#include "filesystem.hpp"
#include "config.hpp"
#include <boost/foreach.hpp>

View File

@ -16,10 +16,6 @@
#ifndef SAVE_INDEX_H_INCLUDED
#define SAVE_INDEX_H_INCLUDED
//#include "filesystem.hpp"
//#include "gamestatus.hpp"
//#include "tod_manager.hpp"
//#include "show_dialog.hpp"
#include "config.hpp"
#include "serialization/compression.hpp"

View File

@ -35,7 +35,6 @@
*/
#include "saved_game.hpp"
#include "gamestatus.hpp"
#include "carryover.hpp"
#include "cursor.hpp"
#include "log.hpp"

View File

@ -3,7 +3,8 @@
#define SAVED_GAME_HPP_INCLUDED
#include "config.hpp"
#include "gamestatus.hpp" //game_classification
#include "game_classification.hpp"
#include "mp_game_settings.hpp"
class config_writer;

View File

@ -17,7 +17,6 @@
#define SAVEGAME_H_INCLUDED
#include "filesystem.hpp"
#include "gamestatus.hpp"
#include "saved_game.hpp"
#include "show_dialog.hpp"
#include "serialization/compression.hpp"

View File

@ -41,6 +41,7 @@
#include "ai/testing/stage_rca.hpp"
#include "attack_prediction.hpp"
#include "filesystem.hpp"
#include "game_classification.hpp"
#include "game_display.hpp"
#include "game_events/conditional_wml.hpp"
#include "game_events/pump.hpp"
@ -51,6 +52,7 @@
#include "lua_jailbreak_exception.hpp"
#include "map.hpp"
#include "map_label.hpp"
#include "mp_game_settings.hpp"
#include "pathfind/pathfind.hpp"
#include "pathfind/teleport.hpp"
#include "play_controller.hpp"

View File

@ -6,6 +6,7 @@
#include "global.hpp"
#include "config.hpp"
#include "config_assign.hpp"
#include "game_classification.hpp"
#include "replay.hpp"
#include "random_new.hpp"
#include "random_new_synced.hpp"

View File

@ -17,7 +17,6 @@
* Manage unit-abilities, like heal, cure, and weapon_specials.
*/
#include "gamestatus.hpp"
#include "log.hpp"
#include "resources.hpp"
#include "terrain_filter.hpp"