display uses display_context internally, not 3 private pointers
Also refactor editor and game_display to use this. To achieve this it turns out we also have to add a "dummy display context" unique to the editor code, which it can use to initalize editor display, because after refactor NULL doesn't cut it anymore. This appears in src/editor/editor_display.?pp, might want to branch into its own file later.
This commit is contained in:
parent
90e5d9206b
commit
43ade4615a
7 changed files with 98 additions and 90 deletions
|
@ -78,8 +78,8 @@ int display::last_zoom_ = SmallZoom;
|
|||
|
||||
void display::parse_team_overlays()
|
||||
{
|
||||
const team& curr_team = (*teams_)[playing_team()];
|
||||
const team& prev_team = (*teams_)[playing_team()-1 < teams_->size() ? playing_team()-1 : teams_->size()-1];
|
||||
const team& curr_team = dc_->teams()[playing_team()];
|
||||
const team& prev_team = dc_->teams()[playing_team()-1 < dc_->teams().size() ? playing_team()-1 : dc_->teams().size()-1];
|
||||
BOOST_FOREACH(const game_display::overlay_map::value_type i, *overlays_) {
|
||||
const overlay& ov = i.second;
|
||||
if (!ov.team_name.empty() &&
|
||||
|
@ -136,13 +136,11 @@ void display::remove_single_overlay(const map_location& loc, const std::string&
|
|||
|
||||
|
||||
|
||||
display::display(unit_map* units, CVideo& video, const gamemap* map, const std::vector<team>* t,const config& theme_cfg, const config& level) :
|
||||
units_(units),
|
||||
display::display(const display_context * dc, CVideo& video, const config& theme_cfg, const config& level) :
|
||||
dc_(dc),
|
||||
exclusive_unit_draw_requests_(),
|
||||
screen_(video),
|
||||
map_(map),
|
||||
currentTeam_(0),
|
||||
teams_(t),
|
||||
viewpoint_(NULL),
|
||||
energy_bar_rects_(),
|
||||
xpos_(0),
|
||||
|
@ -150,7 +148,7 @@ display::display(unit_map* units, CVideo& video, const gamemap* map, const std::
|
|||
view_locked_(false),
|
||||
theme_(theme_cfg, screen_area()),
|
||||
zoom_(DefaultZoom),
|
||||
builder_(new terrain_builder(level, map, theme_.border().tile_image)),
|
||||
builder_(new terrain_builder(level, &dc_->map(), theme_.border().tile_image)),
|
||||
minimap_(NULL),
|
||||
minimap_location_(sdl::empty_rect),
|
||||
redrawMinimap_(false),
|
||||
|
@ -252,13 +250,13 @@ display::~display()
|
|||
void display::init_flags() {
|
||||
|
||||
flags_.clear();
|
||||
if (!teams_) return;
|
||||
flags_.resize(teams_->size());
|
||||
if (!dc_) return;
|
||||
flags_.resize(dc_->teams().size());
|
||||
|
||||
std::vector<std::string> side_colors;
|
||||
side_colors.reserve(teams_->size());
|
||||
side_colors.reserve(dc_->teams().size());
|
||||
|
||||
for(size_t i = 0; i != teams_->size(); ++i) {
|
||||
for(size_t i = 0; i != dc_->teams().size(); ++i) {
|
||||
std::string side_color = team::get_side_color_index(i+1);
|
||||
side_colors.push_back(side_color);
|
||||
init_flags_for_side_internal(i, side_color);
|
||||
|
@ -268,7 +266,7 @@ void display::init_flags() {
|
|||
|
||||
void display::reinit_flags_for_side(size_t side)
|
||||
{
|
||||
if (!teams_ || side >= teams_->size()) {
|
||||
if (!dc_ || side >= dc_->teams().size()) {
|
||||
ERR_DP << "Cannot rebuild flags for inexistent or unconfigured side " << side << '\n';
|
||||
return;
|
||||
}
|
||||
|
@ -278,11 +276,11 @@ void display::reinit_flags_for_side(size_t side)
|
|||
|
||||
void display::init_flags_for_side_internal(size_t n, const std::string& side_color)
|
||||
{
|
||||
assert(teams_ != NULL);
|
||||
assert(n < teams_->size());
|
||||
assert(dc_ != NULL);
|
||||
assert(n < dc_->teams().size());
|
||||
assert(n < flags_.size());
|
||||
|
||||
std::string flag = (*teams_)[n].flag();
|
||||
std::string flag = dc_->teams()[n].flag();
|
||||
std::string old_rgb = game_config::flag_rgb;
|
||||
std::string new_rgb = side_color;
|
||||
|
||||
|
@ -336,9 +334,9 @@ surface display::get_flag(const map_location& loc)
|
|||
return surface(NULL);
|
||||
}
|
||||
|
||||
for(size_t i = 0; i != teams_->size(); ++i) {
|
||||
if((*teams_)[i].owns_village(loc) &&
|
||||
(!fogged(loc) || !(*teams_)[currentTeam_].is_enemy(i+1)))
|
||||
for(size_t i = 0; i != dc_->teams().size(); ++i) {
|
||||
if(dc_->teams()[i].owns_village(loc) &&
|
||||
(!fogged(loc) || !dc_->teams()[currentTeam_].is_enemy(i+1)))
|
||||
{
|
||||
flags_[i].update_last_draw_time();
|
||||
const image::locator &image_flag = animate_map_ ?
|
||||
|
@ -352,12 +350,12 @@ surface display::get_flag(const map_location& loc)
|
|||
|
||||
void display::set_team(size_t teamindex, bool show_everything)
|
||||
{
|
||||
assert(teamindex < teams_->size());
|
||||
assert(teamindex < dc_->teams().size());
|
||||
currentTeam_ = teamindex;
|
||||
if (!show_everything)
|
||||
{
|
||||
labels().set_team(&(*teams_)[teamindex]);
|
||||
viewpoint_ = &(*teams_)[teamindex];
|
||||
labels().set_team(&dc_->teams()[teamindex]);
|
||||
viewpoint_ = &dc_->teams()[teamindex];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -371,7 +369,7 @@ void display::set_team(size_t teamindex, bool show_everything)
|
|||
|
||||
void display::set_playing_team(size_t teamindex)
|
||||
{
|
||||
assert(teamindex < teams_->size());
|
||||
assert(teamindex < dc_->teams().size());
|
||||
activeTeam_ = teamindex;
|
||||
invalidate_game_status();
|
||||
}
|
||||
|
@ -563,20 +561,10 @@ void display::reload_map()
|
|||
builder_->reload_map();
|
||||
}
|
||||
|
||||
void display::change_map(const gamemap* m)
|
||||
void display::change_display_context(const display_context * dc)
|
||||
{
|
||||
map_ = m;
|
||||
builder_->change_map(m);
|
||||
}
|
||||
|
||||
void display::change_units(const unit_map* umap)
|
||||
{
|
||||
units_ = umap;
|
||||
}
|
||||
|
||||
void display::change_teams(const std::vector<team>* teams)
|
||||
{
|
||||
teams_ = teams;
|
||||
dc_ = dc;
|
||||
builder_->change_map(&dc_->map()); //TODO: Should display_context own and initalize the builder object?
|
||||
}
|
||||
|
||||
void display::blindfold(bool value)
|
||||
|
@ -1911,9 +1899,9 @@ void display::draw_minimap_units()
|
|||
double xscaling = 1.0 * minimap_location_.w / get_map().w();
|
||||
double yscaling = 1.0 * minimap_location_.h / get_map().h();
|
||||
|
||||
for(unit_map::const_iterator u = units_->begin(); u != units_->end(); ++u) {
|
||||
for(unit_map::const_iterator u = dc_->units().begin(); u != dc_->units().end(); ++u) {
|
||||
if (fogged(u->get_location()) ||
|
||||
((*teams_)[currentTeam_].is_enemy(u->side()) &&
|
||||
(dc_->teams()[currentTeam_].is_enemy(u->side()) &&
|
||||
u->invisible(u->get_location())) ||
|
||||
u->get_hidden()) {
|
||||
continue;
|
||||
|
@ -1924,7 +1912,7 @@ void display::draw_minimap_units()
|
|||
|
||||
if (preferences::minimap_movement_coding()) {
|
||||
|
||||
if ((*teams_)[currentTeam_].is_enemy(side)) {
|
||||
if (dc_->teams()[currentTeam_].is_enemy(side)) {
|
||||
col = int_to_color(game_config::color_info(preferences::enemy_color()).rep());
|
||||
} else {
|
||||
|
||||
|
@ -2554,9 +2542,9 @@ void display::draw_invalidated() {
|
|||
invalidated_hexes_ += invalidated_.size();
|
||||
|
||||
BOOST_FOREACH(const map_location& loc, invalidated_) {
|
||||
unit_map::const_iterator u_it = units_->find(loc);
|
||||
unit_map::const_iterator u_it = dc_->units().find(loc);
|
||||
exclusive_unit_draw_requests_t::iterator request = exclusive_unit_draw_requests_.find(loc);
|
||||
if (u_it != units_->end()
|
||||
if (u_it != dc_->units().end()
|
||||
&& (request == exclusive_unit_draw_requests_.end() || request->second == u_it->id()))
|
||||
u_it->redraw_unit();
|
||||
}
|
||||
|
@ -2596,7 +2584,7 @@ void display::draw_hex(const map_location& loc) {
|
|||
std::pair<Itor,Itor> overlays = overlays_->equal_range(loc);
|
||||
for( ; overlays.first != overlays.second; ++overlays.first) {
|
||||
if ((overlays.first->second.team_name == "" ||
|
||||
overlays.first->second.team_name.find((*teams_)[playing_team()].team_name()) != std::string::npos)
|
||||
overlays.first->second.team_name.find(dc_->teams()[playing_team()].team_name()) != std::string::npos)
|
||||
&& !(fogged(loc) && !overlays.first->second.visible_in_fog))
|
||||
{
|
||||
drawing_buffer_add(LAYER_TERRAIN_BG, loc, xpos, ypos,
|
||||
|
@ -3027,7 +3015,7 @@ void display::invalidate_animations_location(const map_location& loc) {
|
|||
if (get_map().is_village(loc)) {
|
||||
const int owner = village_owner(loc);
|
||||
if (owner >= 0 && flags_[owner].need_update()
|
||||
&& (!fogged(loc) || !(*teams_)[currentTeam_].is_enemy(owner+1))) {
|
||||
&& (!fogged(loc) || !dc_->teams()[currentTeam_].is_enemy(owner+1))) {
|
||||
invalidate(loc);
|
||||
}
|
||||
}
|
||||
|
@ -3036,7 +3024,7 @@ void display::invalidate_animations_location(const map_location& loc) {
|
|||
|
||||
std::vector<const unit*> display::get_unit_list_for_invalidation() {
|
||||
std::vector<const unit*> unit_list;
|
||||
BOOST_FOREACH(const unit &u, *units_) {
|
||||
BOOST_FOREACH(const unit &u, dc_->units()) {
|
||||
unit_list.push_back(&u);
|
||||
}
|
||||
return unit_list;
|
||||
|
|
|
@ -39,6 +39,7 @@ struct time_of_day;
|
|||
class map_labels;
|
||||
class arrow;
|
||||
|
||||
#include "display_context.hpp"
|
||||
#include "font.hpp"
|
||||
#include "key.hpp"
|
||||
#include "team.hpp"
|
||||
|
@ -62,19 +63,21 @@ class gamemap;
|
|||
class display
|
||||
{
|
||||
public:
|
||||
display(unit_map* units, CVideo& video, const gamemap* map, const std::vector<team>* t,
|
||||
display(const display_context * dc, CVideo& video,
|
||||
const config& theme_cfg, const config& level);
|
||||
virtual ~display();
|
||||
static display* get_singleton() { return singleton_ ;}
|
||||
|
||||
bool show_everything() const { return !viewpoint_ && !is_blindfolded(); }
|
||||
|
||||
const std::vector<team>& get_teams() const {return *teams_;}
|
||||
const gamemap& get_map() const { return dc_->map(); }
|
||||
|
||||
const std::vector<team>& get_teams() const {return dc_->teams();}
|
||||
|
||||
/** The playing team is the team whose turn it is. */
|
||||
size_t playing_team() const { return activeTeam_; }
|
||||
|
||||
bool team_valid() const { return currentTeam_ < teams_->size(); }
|
||||
bool team_valid() const { return currentTeam_ < dc_->teams().size(); }
|
||||
|
||||
/** The viewing team is the team currently viewing the game. */
|
||||
size_t viewing_team() const { return currentTeam_; }
|
||||
|
@ -96,7 +99,7 @@ public:
|
|||
* Cancels all the exclusive draw requests.
|
||||
*/
|
||||
void clear_exclusive_draws() { exclusive_unit_draw_requests_.clear(); }
|
||||
const unit_map& get_units() const {return *units_;}
|
||||
const unit_map& get_units() const {return dc_->units();}
|
||||
|
||||
/**
|
||||
* Allows a unit to request to be the only one drawn in its hex. Useful for situations where
|
||||
|
@ -152,9 +155,7 @@ public:
|
|||
*/
|
||||
void reload_map();
|
||||
|
||||
void change_map(const gamemap* m);
|
||||
void change_teams(const std::vector<team>* teams);
|
||||
void change_units(const unit_map* units);
|
||||
void change_display_context(const display_context * dc);
|
||||
|
||||
static Uint32 rgb(Uint8 red, Uint8 green, Uint8 blue)
|
||||
{ return 0xFF000000 | (red << 16) | (green << 8) | blue; }
|
||||
|
@ -418,8 +419,6 @@ public:
|
|||
*/
|
||||
void invalidate_animations_location(const map_location& loc);
|
||||
|
||||
const gamemap& get_map() const { return *map_; }
|
||||
|
||||
/**
|
||||
* mouseover_hex_overlay_ require a prerendered surface
|
||||
* and is drawn underneath the mouse's location
|
||||
|
@ -627,7 +626,7 @@ private:
|
|||
|
||||
protected:
|
||||
//TODO sort
|
||||
const unit_map* units_;
|
||||
const display_context * dc_;
|
||||
|
||||
typedef std::map<map_location, std::string> exclusive_unit_draw_requests_t;
|
||||
/// map of hexes where only one unit should be drawn, the one identified by the associated id string
|
||||
|
@ -720,9 +719,7 @@ protected:
|
|||
const std::string& get_variant(const std::vector<std::string>& variants, const map_location &loc) const;
|
||||
|
||||
CVideo& screen_;
|
||||
const gamemap* map_;
|
||||
size_t currentTeam_;
|
||||
const std::vector<team>* teams_;
|
||||
const team *viewpoint_;
|
||||
std::map<surface,SDL_Rect> energy_bar_rects_;
|
||||
int xpos_, ypos_;
|
||||
|
|
|
@ -56,12 +56,11 @@ static std::vector<std::string> saved_windows_;
|
|||
|
||||
namespace editor {
|
||||
|
||||
|
||||
editor_controller::editor_controller(const config &game_config, CVideo& video)
|
||||
: controller_base(SDL_GetTicks(), game_config, video)
|
||||
, mouse_handler_base()
|
||||
, active_menu_(editor::MAP)
|
||||
, gui_(new editor_display(NULL, video, NULL, NULL, get_theme(game_config, "editor"), config()))
|
||||
, gui_(new editor_display(editor::get_dummy_display_context(), video, get_theme(game_config, "editor"), config()))
|
||||
, tods_()
|
||||
, context_manager_(new context_manager(*gui_.get(), game_config_))
|
||||
, toolkit_(NULL)
|
||||
|
@ -90,9 +89,7 @@ editor_controller::editor_controller(const config &game_config, CVideo& video)
|
|||
|
||||
void editor_controller::init_gui()
|
||||
{
|
||||
gui_->change_map(&context_manager_->get_map());
|
||||
gui_->change_units(&context_manager_->get_map_context().get_units());
|
||||
gui_->change_teams(&context_manager_->get_map_context().get_teams());
|
||||
gui_->change_display_context(&context_manager_->get_map_context());
|
||||
gui_->set_grid(preferences::grid());
|
||||
prefs_disp_manager_.reset(new preferences::display_manager(&gui()));
|
||||
gui_->add_redraw_observer(boost::bind(&editor_controller::display_redraw_callback, this, _1));
|
||||
|
|
|
@ -19,9 +19,35 @@
|
|||
|
||||
namespace editor {
|
||||
|
||||
editor_display::editor_display(unit_map* units, CVideo& video, const editor_map* map,
|
||||
const std::vector<team>* t, const config& theme_cfg, const config& level)
|
||||
: display(units, video, map, t, theme_cfg, level)
|
||||
// Define dummy display context;
|
||||
|
||||
class dummy_editor_display_context : public display_context
|
||||
{
|
||||
config dummy_cfg1;
|
||||
|
||||
editor_map em;
|
||||
unit_map u;
|
||||
std::vector<team> t;
|
||||
|
||||
public:
|
||||
dummy_editor_display_context() : dummy_cfg1(), em(dummy_cfg1), u(), t() {}
|
||||
virtual ~dummy_editor_display_context(){}
|
||||
|
||||
virtual const gamemap & map() const { return em; }
|
||||
virtual const unit_map & units() const { return u; }
|
||||
virtual const std::vector<team> & teams() const { return t; }
|
||||
};
|
||||
|
||||
const display_context * get_dummy_display_context() {
|
||||
static const dummy_editor_display_context dedc = dummy_editor_display_context();
|
||||
return &dedc;
|
||||
}
|
||||
|
||||
// End dummy display context
|
||||
|
||||
editor_display::editor_display(const display_context * dc, CVideo& video,
|
||||
const config& theme_cfg, const config& level)
|
||||
: display(dc, video, theme_cfg, level)
|
||||
, brush_locations_()
|
||||
, palette_report_()
|
||||
{
|
||||
|
@ -110,7 +136,7 @@ void editor_display::draw_sidebar()
|
|||
refresh_report("position", &element);
|
||||
}
|
||||
|
||||
if (teams_->empty()) {
|
||||
if (dc_->teams().empty()) {
|
||||
text = int(get_map().villages().size());
|
||||
refresh_report("villages", &element);
|
||||
} else {
|
||||
|
|
|
@ -20,11 +20,13 @@
|
|||
|
||||
namespace editor {
|
||||
|
||||
const display_context * get_dummy_display_context();
|
||||
|
||||
class editor_display : public display
|
||||
{
|
||||
public:
|
||||
editor_display(unit_map* units, CVideo& video, const editor_map* map,
|
||||
const std::vector<team>* t, const config& theme_cfg, const config& level);
|
||||
editor_display(const display_context * dc, CVideo& video,
|
||||
const config& theme_cfg, const config& level);
|
||||
|
||||
bool in_editor() const { return true; }
|
||||
|
||||
|
|
|
@ -73,19 +73,17 @@ public:
|
|||
if (!refreshed_) refresh();
|
||||
}
|
||||
void refresh() {
|
||||
context_manager_.gui().change_map(&context_manager_.get_map());
|
||||
resources::game_map = &context_manager_.get_map();
|
||||
context_manager_.gui().change_display_context(&context_manager_.get_map_context());
|
||||
|
||||
context_manager_.gui().change_units(&context_manager_.get_map_context().get_units());
|
||||
resources::game_map = &context_manager_.get_map();
|
||||
resources::units = &context_manager_.get_map_context().get_units();
|
||||
resources::teams = &context_manager_.get_map_context().get_teams();
|
||||
|
||||
// TODO register the tod_manager with the gui?
|
||||
resources::tod_manager = context_manager_.get_map_context().get_time_manager();
|
||||
context_manager_.gui().change_teams(&context_manager_.get_map_context().get_teams());
|
||||
|
||||
context_manager_.gui().replace_overlay_map(&context_manager_.get_map_context().get_overlays());
|
||||
|
||||
resources::teams = &context_manager_.get_map_context().get_teams();
|
||||
|
||||
resources::classification = &context_manager_.get_map_context().get_game_state().classification();
|
||||
resources::mp_settings = &context_manager_.get_map_context().get_game_state().mp_settings();
|
||||
|
|
|
@ -64,7 +64,7 @@ std::map<map_location,fixed_t> game_display::debugHighlights_;
|
|||
game_display::game_display(game_board& board, CVideo& video,
|
||||
const tod_manager& tod,
|
||||
const config& theme_cfg, const config& level) :
|
||||
display(&board.units_, video, & board.map(), & board.teams(), theme_cfg, level),
|
||||
display(&board, video, theme_cfg, level),
|
||||
overlay_map_(),
|
||||
fake_units_(),
|
||||
attack_indicator_src_(),
|
||||
|
@ -165,15 +165,15 @@ void game_display::highlight_hex(map_location hex)
|
|||
{
|
||||
wb::future_map future; /**< Lasts for whole method. */
|
||||
|
||||
const unit *u = resources::gameboard->get_visible_unit(hex, (*teams_)[viewing_team()], !viewpoint_);
|
||||
const unit *u = resources::gameboard->get_visible_unit(hex, dc_->teams()[viewing_team()], !viewpoint_);
|
||||
if (u) {
|
||||
displayedUnitHex_ = hex;
|
||||
invalidate_unit();
|
||||
} else {
|
||||
u = resources::gameboard->get_visible_unit(mouseoverHex_, (*teams_)[viewing_team()], !viewpoint_);
|
||||
u = resources::gameboard->get_visible_unit(mouseoverHex_, dc_->teams()[viewing_team()], !viewpoint_);
|
||||
if (u) {
|
||||
// mouse moved from unit hex to non-unit hex
|
||||
if (units_->count(selectedHex_)) {
|
||||
if (dc_->units().count(selectedHex_)) {
|
||||
displayedUnitHex_ = selectedHex_;
|
||||
invalidate_unit();
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ void game_display::display_unit_hex(map_location hex)
|
|||
|
||||
wb::future_map future; /**< Lasts for whole method. */
|
||||
|
||||
const unit *u = resources::gameboard->get_visible_unit(hex, (*teams_)[viewing_team()], !viewpoint_);
|
||||
const unit *u = resources::gameboard->get_visible_unit(hex, dc_->teams()[viewing_team()], !viewpoint_);
|
||||
if (u) {
|
||||
displayedUnitHex_ = hex;
|
||||
invalidate_unit();
|
||||
|
@ -209,7 +209,7 @@ void game_display::invalidate_unit_after_move(const map_location& src, const map
|
|||
|
||||
void game_display::scroll_to_leader(int side, SCROLL_TYPE scroll_type,bool force)
|
||||
{
|
||||
unit_map::const_iterator leader = units_->find_leader(side);
|
||||
unit_map::const_iterator leader = dc_->units().find_leader(side);
|
||||
|
||||
if(leader.valid()) {
|
||||
// YogiHH: I can't see why we need another key_handler here,
|
||||
|
@ -279,7 +279,7 @@ void game_display::draw_hex(const map_location& loc)
|
|||
|
||||
if(on_map && loc == mouseoverHex_) {
|
||||
tdrawing_layer hex_top_layer = LAYER_MOUSEOVER_BOTTOM;
|
||||
const unit *u = resources::gameboard->get_visible_unit(loc, (*teams_)[viewing_team()] );
|
||||
const unit *u = resources::gameboard->get_visible_unit(loc, dc_->teams()[viewing_team()] );
|
||||
if( u != NULL ) {
|
||||
hex_top_layer = LAYER_MOUSEOVER_TOP;
|
||||
}
|
||||
|
@ -288,12 +288,12 @@ void game_display::draw_hex(const map_location& loc)
|
|||
image::get_image("misc/hover-hex-top.png~RC(magenta>gold)", image::SCALED_TO_HEX));
|
||||
drawing_buffer_add(LAYER_MOUSEOVER_BOTTOM, loc, xpos, ypos,
|
||||
image::get_image("misc/hover-hex-bottom.png~RC(magenta>gold)", image::SCALED_TO_HEX));
|
||||
} else if((*teams_)[currentTeam_].is_enemy(u->side())) {
|
||||
} else if(dc_->teams()[currentTeam_].is_enemy(u->side())) {
|
||||
drawing_buffer_add( hex_top_layer, loc, xpos, ypos,
|
||||
image::get_image("misc/hover-hex-enemy-top.png~RC(magenta>red)", image::SCALED_TO_HEX));
|
||||
drawing_buffer_add(LAYER_MOUSEOVER_BOTTOM, loc, xpos, ypos,
|
||||
image::get_image("misc/hover-hex-enemy-bottom.png~RC(magenta>red)", image::SCALED_TO_HEX));
|
||||
} else if((*teams_)[currentTeam_].side() == u->side()) {
|
||||
} else if(dc_->teams()[currentTeam_].side() == u->side()) {
|
||||
drawing_buffer_add( hex_top_layer, loc, xpos, ypos,
|
||||
image::get_image("misc/hover-hex-top.png~RC(magenta>green)", image::SCALED_TO_HEX));
|
||||
drawing_buffer_add(LAYER_MOUSEOVER_BOTTOM, loc, xpos, ypos,
|
||||
|
@ -416,8 +416,8 @@ void game_display::draw_movement_info(const map_location& loc)
|
|||
&& !route_.steps.empty() && route_.steps.front() != loc) {
|
||||
const unit_map::const_iterator un =
|
||||
resources::whiteboard->get_temp_move_unit().valid() ?
|
||||
resources::whiteboard->get_temp_move_unit() : units_->find(route_.steps.front());
|
||||
if(un != units_->end()) {
|
||||
resources::whiteboard->get_temp_move_unit() : dc_->units().find(route_.steps.front());
|
||||
if(un != dc_->units().end()) {
|
||||
// Display the def% of this terrain
|
||||
int def = 100 - un->defense_modifier(get_map().get_terrain(loc));
|
||||
std::stringstream def_text;
|
||||
|
@ -463,7 +463,7 @@ void game_display::draw_movement_info(const map_location& loc)
|
|||
{
|
||||
const unit_map::const_iterator selectedUnit = resources::gameboard->find_visible_unit(selectedHex_,resources::teams->at(currentTeam_));
|
||||
const unit_map::const_iterator mouseoveredUnit = resources::gameboard->find_visible_unit(mouseoverHex_,resources::teams->at(currentTeam_));
|
||||
if(selectedUnit != units_->end() && mouseoveredUnit == units_->end()) {
|
||||
if(selectedUnit != dc_->units().end() && mouseoveredUnit == dc_->units().end()) {
|
||||
// Display the def% of this terrain
|
||||
int def = 100 - selectedUnit->defense_modifier(get_map().get_terrain(loc));
|
||||
std::stringstream def_text;
|
||||
|
@ -503,8 +503,8 @@ std::vector<surface> game_display::footsteps_images(const map_location& loc)
|
|||
|
||||
// Check which footsteps images of game_config we will use
|
||||
int move_cost = 1;
|
||||
const unit_map::const_iterator u = units_->find(route_.steps.front());
|
||||
if(u != units_->end()) {
|
||||
const unit_map::const_iterator u = dc_->units().find(route_.steps.front());
|
||||
if(u != dc_->units().end()) {
|
||||
move_cost = u->movement_cost(get_map().get_terrain(loc));
|
||||
}
|
||||
int image_number = std::min<int>(move_cost, game_config::foot_speed_prefix.size());
|
||||
|
@ -757,7 +757,7 @@ std::string game_display::current_team_name() const
|
|||
{
|
||||
if (team_valid())
|
||||
{
|
||||
return (*teams_)[currentTeam_].team_name();
|
||||
return dc_->teams()[currentTeam_].team_name();
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
|
@ -989,12 +989,12 @@ void game_display::send_notification(const std::string& /*owner*/, const std::st
|
|||
|
||||
void game_display::set_team(size_t teamindex, bool show_everything)
|
||||
{
|
||||
assert(teamindex < teams_->size());
|
||||
assert(teamindex < dc_->teams().size());
|
||||
currentTeam_ = teamindex;
|
||||
if (!show_everything)
|
||||
{
|
||||
labels().set_team(&(*teams_)[teamindex]);
|
||||
viewpoint_ = &(*teams_)[teamindex];
|
||||
labels().set_team(&dc_->teams()[teamindex]);
|
||||
viewpoint_ = &dc_->teams()[teamindex];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1008,7 +1008,7 @@ void game_display::set_team(size_t teamindex, bool show_everything)
|
|||
|
||||
void game_display::set_playing_team(size_t teamindex)
|
||||
{
|
||||
assert(teamindex < teams_->size());
|
||||
assert(teamindex < dc_->teams().size());
|
||||
activeTeam_ = teamindex;
|
||||
invalidate_game_status();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue