Abstract class for exposing game data that doesn't depend on the GUI, however which for historical reasons is generally accessed via the GUI method display::get_singleton(). More...
#include <display_context.hpp>
Classes | |
struct | can_move_result |
Public Member Functions | |
virtual const std::vector< team > & | teams () const =0 |
virtual const gamemap & | map () const =0 |
virtual const unit_map & | units () const =0 |
virtual const std::vector< std::string > & | hidden_label_categories () const =0 |
virtual std::vector< std::string > & | hidden_label_categories ()=0 |
const team & | get_team (int side) const |
This getter takes a 1-based side number, not a 0-based team number. More... | |
bool | has_team (int side) const |
bool | would_be_discovered (const map_location &loc, int side_num, bool see_all=true) |
Given a location and a side number, indicates whether an invisible unit of that side at that location would be revealed (perhaps ambushed), based on what team side_num can see. More... | |
const unit * | get_visible_unit (const map_location &loc, const team ¤t_team, bool see_all=false) const |
unit_const_ptr | get_visible_unit_shared_ptr (const map_location &loc, const team ¤t_team, bool see_all=false) const |
can_move_result | unit_can_move (const unit &u) const |
Work out what u can do - this does not check which player's turn is currently active, the result is calculated assuming that the unit's owner is currently active. More... | |
orb_status | unit_orb_status (const unit &u) const |
Returns an enumurated summary of whether this unit can move and/or attack. More... | |
int | village_owner (const map_location &loc) const |
Given the location of a village, will return the 1-based number of the team that currently owns it, and 0 if it is unowned. More... | |
int | side_units (int side_num) const |
Returns the number of units of the side side_num. More... | |
int | side_units_cost (int side_num) const |
Returns the total cost of units of side side_num. More... | |
int | side_upkeep (int side_num) const |
bool | is_observer () const |
Check if we are an observer in this game. More... | |
virtual | ~display_context () |
Abstract class for exposing game data that doesn't depend on the GUI, however which for historical reasons is generally accessed via the GUI method display::get_singleton().
Definition at line 34 of file display_context.hpp.
|
inlinevirtual |
Definition at line 119 of file display_context.hpp.
const team & display_context::get_team | ( | int | side | ) | const |
This getter takes a 1-based side number, not a 0-based team number.
Definition at line 24 of file display_context.cpp.
References teams().
Referenced by unit::ability_active_impl(), gui2::dialogs::add_unit_entry(), attack_info(), gui2::dialogs::gamestate_inspector::controller::build_stuff_list(), side_filter::match(), terrain_filter::match_internal(), side_filter::match_internal(), gui2::dialogs::team_mode_controller::show_array(), gui2::dialogs::team_mode_controller::show_list(), gui2::dialogs::team_mode_controller::show_recall_unit(), gui2::dialogs::team_mode_controller::show_var(), gui2::dialogs::team_mode_controller::show_vars(), attack_type::special_active_impl(), unit_can_move(), unit_side(), and would_be_discovered().
const unit * display_context::get_visible_unit | ( | const map_location & | loc, |
const team & | current_team, | ||
bool | see_all = false |
||
) | const |
Definition at line 56 of file display_context.cpp.
References unit_map::find(), map(), units(), and unit_map::iterator_base< iter_types >::valid().
Referenced by game_display::display_unit_hex(), game_display::draw_hex(), get_selected_unit(), get_visible_unit(), and game_display::highlight_hex().
unit_const_ptr display_context::get_visible_unit_shared_ptr | ( | const map_location & | loc, |
const team & | current_team, | ||
bool | see_all = false |
||
) | const |
Definition at line 66 of file display_context.cpp.
References unit_map::find(), unit_map::iterator_base< iter_types >::get_shared_ptr(), map(), units(), and unit_map::iterator_base< iter_types >::valid().
Referenced by get_selected_unit_ptr().
bool display_context::has_team | ( | int | side | ) | const |
Definition at line 29 of file display_context.cpp.
References utf8::size(), and teams().
|
pure virtual |
Implemented in pathfind::ignore_units_display_context, game_board, and editor::map_context.
Referenced by terrain_label::hidden(), and gui2::dialogs::label_settings::post_show().
|
pure virtual |
Implemented in pathfind::ignore_units_display_context, game_board, and editor::map_context.
bool display_context::is_observer | ( | ) | const |
Check if we are an observer in this game.
Determine if we are an observer, by checking if every team is not locally controlled.
Definition at line 163 of file display_context.cpp.
Referenced by display_chat_manager::add_chat_message(), play_controller::is_observer(), events::menu_handler::send_chat_message(), and terrain_label::viewable().
|
pure virtual |
Implemented in pathfind::ignore_units_display_context, game_board, and editor::map_context.
Referenced by display::bounds_check_position(), display::draw_hex(), game_display::draw_hex(), display::draw_minimap(), display::draw_minimap_units(), display::draw_overlays_at(), footsteps_images(), wfl::gamemap_callable::get_gamemap(), terrain_filter::get_locs_impl(), editor::editor_display::get_map(), get_visible_unit(), get_visible_unit_shared_ptr(), unit_animation_component::invalidate(), reports::context::map(), terrain_filter::match_impl(), terrain_filter::match_internal(), unit_animation::matches(), display::max_map_area(), display::minimap_location_on(), gui2::dialogs::game_stats::pre_show(), and unit_can_move().
int display_context::side_units | ( | int | side_num | ) | const |
Returns the number of units of the side side_num.
Definition at line 175 of file display_context.cpp.
References unit::side(), and units().
Referenced by ai_testing::log_turn().
int display_context::side_units_cost | ( | int | side_num | ) | const |
Returns the total cost of units of side side_num.
Definition at line 184 of file display_context.cpp.
References unit::cost(), unit::side(), and units().
Referenced by ai_testing::log_turn().
int display_context::side_upkeep | ( | int | side_num | ) | const |
Definition at line 193 of file display_context.cpp.
References unit::side(), units(), and unit::upkeep().
Referenced by play_controller::do_init_side(), and ai::default_recruitment::recruitment::get_estimated_income().
|
pure virtual |
Implemented in pathfind::ignore_units_display_context, game_board, and editor::map_context.
Referenced by gui2::dialogs::gamestate_inspector::controller::build_stuff_list(), get_team(), side_filter::get_teams(), has_team(), is_observer(), display::playing_team(), gui2::dialogs::game_stats::pre_show(), gui2::dialogs::label_settings::pre_show(), reports::context::teams(), display::viewing_team(), and village_owner().
display_context::can_move_result display_context::unit_can_move | ( | const unit & | u | ) | const |
Work out what u can do - this does not check which player's turn is currently active, the result is calculated assuming that the unit's owner is currently active.
Definition at line 76 of file display_context.cpp.
References display_context::can_move_result::attack_here, unit::attacks(), unit::attacks_left(), distance_between(), unit_map::find(), get_adjacent_tiles(), unit::get_location(), get_team(), unit::has_goto(), unit::has_moved(), i, team::is_enemy(), map(), display_context::can_move_result::move, unit::movement_cost(), unit::movement_left(), prev, unit::side(), units(), map_location::x, and map_location::y.
Referenced by events::mouse_handler::unit_in_cycle(), and unit_orb_status().
orb_status display_context::unit_orb_status | ( | const unit & | u | ) | const |
Returns an enumurated summary of whether this unit can move and/or attack.
This does not check which player's turn is currently active, the result is calculated assuming that the unit's owner is currently active. For this reason this never returns orb_status::enemy nor orb_status::allied.
Definition at line 136 of file display_context.cpp.
References unit::attacks_left(), disengaged, unit::max_attacks(), moved, unit::movement_left(), partial, unit::total_movement(), unit_can_move(), unmoved, and unit::user_end_turn().
Referenced by display::draw_minimap_units(), image::prep_minimap_for_rendering(), and unit_drawer::redraw_unit().
|
pure virtual |
Implemented in pathfind::ignore_units_display_context, game_board, and editor::map_context.
Referenced by unit_filter::all_matches_on_map(), editor::mouse_action_unit::click_left(), editor::mouse_action_unit::drag_end_left(), display::draw_invalidated(), game_display::draw_movement_info(), unit_filter_impl::unit_filter_compound::fill(), unit_filter::first_match_on_map(), footsteps_images(), gui2::dialogs::game_stats::get_leader(), terrain_filter::get_locs_impl(), get_visible_unit(), get_visible_unit_shared_ptr(), terrain_filter::match_impl(), terrain_filter::match_internal(), side_filter::match_internal(), unit_animation::matches(), unit_filter_impl::unit_filter_compound::matches(), editor::mouse_action_unit::move(), unit_display::reset_helpers(), game_display::scroll_to_leader(), gui2::dialogs::unit_mode_controller::show_array(), gui2::dialogs::unit_mode_controller::show_list(), gui2::dialogs::unit_mode_controller::show_unit(), gui2::dialogs::team_mode_controller::show_units(), gui2::dialogs::unit_mode_controller::show_var(), side_units(), side_units_cost(), side_upkeep(), unit_can_move(), unit_display::unit_recruited(), reports::context::units(), and would_be_discovered().
int display_context::village_owner | ( | const map_location & | loc | ) | const |
Given the location of a village, will return the 1-based number of the team that currently owns it, and 0 if it is unowned.
Definition at line 150 of file display_context.cpp.
Referenced by events::menu_handler::change_side(), game_board::change_terrain(), game_lua_kernel::intf_get_village_owner(), game_lua_kernel::intf_set_village_owner(), display::invalidate_animations_location(), terrain_filter::match_internal(), actions::place_recruit(), image::prep_minimap_for_rendering(), ai::ai_default_rca::aspect_attacks_base::rate_terrain(), ai::default_ai_context_impl::rate_terrain(), and game_board::replace_map().
bool display_context::would_be_discovered | ( | const map_location & | loc, |
int | side_num, | ||
bool | see_all = true |
||
) |
Given a location and a side number, indicates whether an invisible unit of that side at that location would be revealed (perhaps ambushed), based on what team side_num can see.
If see_all is true then the calculation ignores fog, and enemy ambushers.
Definition at line 34 of file display_context.cpp.
References unit_map::find(), get_adjacent_tiles(), get_team(), unit::incapacitated(), unit::side(), units(), and unit_map::iterator_base< iter_types >::valid().
Referenced by unit::invisible().