#include <game_data.hpp>
Public Types | |
enum | PHASE { INITIAL, PRELOAD, PRESTART, START, PLAY } |
Public Member Functions | |
game_data () | |
game_data (const config &level) | |
game_data (const game_data &data) | |
const config & | get_variables () const |
config::attribute_value & | get_variable (const std::string &varname) |
throws invalid_variablename_exception if varname is no valid variable name. More... | |
virtual config::attribute_value | get_variable_const (const std::string &varname) const |
returns a blank attribute value if varname is no valid variable name. More... | |
config & | get_variable_cfg (const std::string &varname) |
throws invalid_variablename_exception if varname is no valid variable name. More... | |
void | set_variable (const std::string &varname, const t_string &value) |
does nothing if varname is no valid variable name. More... | |
config & | add_variable_cfg (const std::string &varname, const config &value=config()) |
throws invalid_variablename_exception if varname is no valid variable name. More... | |
variable_access_const | get_variable_access_read (const std::string &varname) const |
returns a variable_access that cannot be used to change the game variables More... | |
variable_access_create | get_variable_access_write (const std::string &varname) |
returns a variable_access that can be used to change the game variables More... | |
void | clear_variable (const std::string &varname) |
Clears attributes config children does nothing if varname is no valid variable name. More... | |
void | clear_variable_cfg (const std::string &varname) |
Clears only the config children does nothing if varname is no valid variable name. More... | |
const rand_rng::mt_rng & | rng () const |
rand_rng::mt_rng & | rng () |
PHASE | phase () const |
void | set_phase (PHASE phase) |
bool | allow_end_turn () const |
void | set_allow_end_turn (bool value) |
void | write_snapshot (config &cfg) const |
const std::string & | next_scenario () const |
void | set_next_scenario (const std::string &next_scenario) |
Public Member Functions inherited from variable_set | |
virtual | ~variable_set () |
Public Attributes | |
std::vector < scoped_wml_variable * > | scoped_variables |
map_location | last_selected |
the last location where a select event fired. More... | |
Private Member Functions | |
void | activate_scope_variable (std::string var_name) const |
variable_access_throw | get_variable_access_throw (const std::string &varname) |
Used to delete variables. More... | |
Private Attributes | |
rand_rng::mt_rng | rng_ |
config | variables_ |
PHASE | phase_ |
bool | can_end_turn_ |
std::string | next_scenario_ |
the scenario coming next (for campaigns) More... | |
Definition at line 29 of file game_data.hpp.
enum game_data::PHASE |
Enumerator | |
---|---|
INITIAL | |
PRELOAD | |
PRESTART | |
START | |
PLAY |
Definition at line 70 of file game_data.hpp.
game_data::game_data | ( | ) |
Definition at line 36 of file game_data.cpp.
|
explicit |
Definition at line 47 of file game_data.cpp.
game_data::game_data | ( | const game_data & | data | ) |
Definition at line 59 of file game_data.cpp.
|
private |
Definition at line 152 of file game_data.cpp.
References gui2::event::find(), itor, and scoped_variables.
Referenced by get_variable_access_read(), get_variable_access_throw(), and get_variable_access_write().
config & game_data::add_variable_cfg | ( | const std::string & | varname, |
const config & | value = config() |
||
) |
throws invalid_variablename_exception if varname is no valid variable name.
Definition at line 104 of file game_data.cpp.
References non_const_variable_info< vit >::append_array(), and get_variable_access_write().
Referenced by scoped_wml_variable::store(), and scoped_wml_variable::~scoped_wml_variable().
|
inline |
Definition at line 81 of file game_data.hpp.
References can_end_turn_.
void game_data::clear_variable | ( | const std::string & | varname | ) |
Clears attributes config children does nothing if varname is no valid variable name.
Definition at line 122 of file game_data.cpp.
References non_const_variable_info< vit >::clear(), and get_variable_access_throw().
Referenced by get_global_variable(), team::get_village(), and game_lua_kernel::intf_set_variable().
void game_data::clear_variable_cfg | ( | const std::string & | varname | ) |
Clears only the config children does nothing if varname is no valid variable name.
Definition at line 110 of file game_data.cpp.
References non_const_variable_info< vit >::clear(), and get_variable_access_throw().
Referenced by scoped_wml_variable::store(), and scoped_wml_variable::~scoped_wml_variable().
config::attribute_value & game_data::get_variable | ( | const std::string & | varname | ) |
throws invalid_variablename_exception if varname is no valid variable name.
Definition at line 70 of file game_data.cpp.
References variable_info< vit >::as_scalar(), and get_variable_access_write().
Referenced by play_controller::do_init_side(), game_events::wmi_container::fire_item(), play_controller::fire_preload(), play_controller::fire_prestart(), play_controller::fire_start(), game_events::wmi_container::get_items(), team::get_village(), game_lua_kernel::intf_heal_unit(), game_events::t_pump::operator()(), tod_manager::set_turn(), and set_variable().
|
inline |
returns a variable_access that cannot be used to change the game variables
Definition at line 49 of file game_data.hpp.
References activate_scope_variable(), and variables_.
Referenced by get_variable_const(), game_lua_kernel::intf_get_variable(), vconfig::all_children_iterator::operator++(), and game_events::WML_HANDLER_FUNCTION().
|
inlineprivate |
Used to delete variables.
Definition at line 95 of file game_data.hpp.
References activate_scope_variable(), and variables_.
Referenced by clear_variable(), and clear_variable_cfg().
|
inline |
returns a variable_access that can be used to change the game variables
Definition at line 55 of file game_data.hpp.
References activate_scope_variable(), and variables_.
Referenced by add_variable_cfg(), get_variable(), get_variable_cfg(), game_lua_kernel::intf_set_variable(), and game_events::WML_HANDLER_FUNCTION().
config & game_data::get_variable_cfg | ( | const std::string & | varname | ) |
throws invalid_variablename_exception if varname is no valid variable name.
Definition at line 87 of file game_data.cpp.
References variable_info< vit >::as_container(), and get_variable_access_write().
Referenced by game_events::WML_HANDLER_FUNCTION().
|
virtual |
returns a blank attribute value if varname is no valid variable name.
Implements variable_set.
Definition at line 75 of file game_data.cpp.
References variable_info< vit >::as_scalar(), and get_variable_access_read().
Referenced by events::console_handler::do_show_var(), storyscreen::controller::resolve_wml(), and storyscreen::part::resolve_wml().
|
inline |
Definition at line 37 of file game_data.hpp.
References variables_.
Referenced by gui2::variable_mode_controller::handle_stuff_list_selection(), set_global_variable(), and gui2::variable_mode_controller::show_stuff_list().
|
inline |
Definition at line 89 of file game_data.hpp.
References next_scenario_.
Referenced by playmp_controller::hotkey_handler::can_execute_command(), events::console_handler::do_choose_level(), playmp_controller::maybe_linger(), turn_info::process_network_data(), set_next_scenario(), and campaign_controller::show_carryover_message().
|
inline |
Definition at line 78 of file game_data.hpp.
References phase_.
Referenced by advance_unit_at(), mp_sync::get_user_choice(), user_choice_manager::get_user_choice_internal(), play_controller::is_browsing(), play_controller::maybe_do_init_side(), set_phase(), wait_ingame(), game_events::WML_HANDLER_FUNCTION(), and game_state::write().
|
inline |
|
inline |
Definition at line 68 of file game_data.hpp.
References rng_.
|
inline |
Definition at line 82 of file game_data.hpp.
References can_end_turn_.
Referenced by game_lua_kernel::intf_allow_end_turn().
|
inline |
Definition at line 90 of file game_data.hpp.
References next_scenario(), and next_scenario_.
Referenced by game_lua_kernel::intf_set_next_scenario().
Definition at line 79 of file game_data.hpp.
References phase(), and phase_.
Referenced by play_controller::fire_prestart(), play_controller::fire_start(), play_controller::init(), play_controller::reset_gamestate(), and play_controller::start_game().
void game_data::set_variable | ( | const std::string & | varname, |
const t_string & | value | ||
) |
does nothing if varname is no valid variable name.
Definition at line 92 of file game_data.cpp.
References ERR_NG, and get_variable().
Referenced by get_global_variable(), and SYNCED_COMMAND_HANDLER_FUNCTION().
Definition at line 134 of file game_data.cpp.
References config::add_child(), can_end_turn_, rand_rng::mt_rng::get_random_calls(), rand_rng::mt_rng::get_random_seed_str(), next_scenario_, rng_, and variables_.
Referenced by game_state::write().
|
private |
Definition at line 104 of file game_data.hpp.
Referenced by allow_end_turn(), set_allow_end_turn(), and write_snapshot().
map_location game_data::last_selected |
the last location where a select event fired.
Used by wml menu items with needs_select=yes
Definition at line 85 of file game_data.hpp.
Referenced by game_events::wml_menu_item::can_show(), game_events::wml_menu_item::fire_event(), play_controller::init_side_begin(), and game_events::t_pump::process_event().
|
private |
the scenario coming next (for campaigns)
Definition at line 105 of file game_data.hpp.
Referenced by next_scenario(), set_next_scenario(), and write_snapshot().
|
private |
Definition at line 103 of file game_data.hpp.
Referenced by phase(), and set_phase().
|
private |
Definition at line 101 of file game_data.hpp.
Referenced by rng(), and write_snapshot().
std::vector<scoped_wml_variable*> game_data::scoped_variables |
Definition at line 35 of file game_data.hpp.
Referenced by activate_scope_variable(), scoped_wml_variable::scoped_wml_variable(), and scoped_wml_variable::~scoped_wml_variable().
|
private |
Definition at line 102 of file game_data.hpp.
Referenced by get_variable_access_read(), get_variable_access_throw(), get_variable_access_write(), get_variables(), and write_snapshot().