Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move game_classification to its own file
- Loading branch information
Showing
30 changed files
with
178 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.