void game_display::select_hex(map_location hex) { if(hex.valid() && fogged(hex)) { return; } display::select_hex(hex); display_unit_hex(hex); }
void game_display::float_label(const map_location& loc, const std::string& text, const SDL_Color& color) { if(preferences::show_floating_labels() == false || fogged(loc)) { return; } font::floating_label flabel(text); flabel.set_font_size(font::SIZE_XLARGE); flabel.set_color(color); flabel.set_position(get_location_x(loc)+zoom_/2, get_location_y(loc)); flabel.set_move(0, -2 * turbo_speed()); flabel.set_lifetime(60/turbo_speed()); flabel.set_scroll_mode(font::ANCHOR_LABEL_MAP); font::add_floating_label(flabel); }
void game_display::draw_hex(const map_location& loc) { const bool on_map = get_map().on_board(loc); const bool is_shrouded = shrouded(loc); const bool is_fogged = fogged(loc); int xpos = get_location_x(loc); int ypos = get_location_y(loc); tblit blit(xpos, ypos); image::TYPE image_type = get_image_type(loc); display::draw_hex(loc); if(!is_shrouded) { typedef overlay_map::const_iterator Itor; 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) && !(is_fogged && !overlays.first->second.visible_in_fog)) { drawing_buffer_add(LAYER_TERRAIN_BG, loc, tblit(xpos, ypos, image::get_image(overlays.first->second.image,image_type))); } } // village-control flags. //drawing_buffer_add(LAYER_TERRAIN_BG, loc, tblit(xpos, ypos, get_flag(loc))); textureAtlasInfo tinfo = get_flag(loc); if (tinfo.mapId != 0) { drawing_buffer_add(LAYER_UNIT_FG, loc, tblit(xpos, ypos, tinfo)); } } // Draw the time-of-day mask on top of the terrain in the hex. // tod may differ from tod if hex is illuminated. std::string tod_hex_mask = timeofday_at(status_,units_,loc,get_map()).image_mask; if(tod_hex_mask1 != NULL || tod_hex_mask2 != NULL) { drawing_buffer_add(LAYER_TERRAIN_FG, loc, tblit(xpos, ypos, tod_hex_mask1)); drawing_buffer_add(LAYER_TERRAIN_FG, loc, tblit(xpos, ypos, tod_hex_mask2)); } else if(tod_hex_mask != "") { drawing_buffer_add(LAYER_TERRAIN_FG, loc, tblit(xpos, ypos, image::get_image(tod_hex_mask,image::UNMASKED))); } // Draw reach_map information. // We remove the reachability mask of the unit // that we want to attack. if (!is_shrouded && !reach_map_.empty() && reach_map_.find(loc) == reach_map_.end() && loc != attack_indicator_dst_) { textureAtlasInfo tinfo; if (getTextureAtlasInfo(game_config::unreachable_image, tinfo)) drawing_buffer_add(LAYER_REACHMAP, loc, tblit(xpos, ypos, //image::get_image(game_config::unreachable_image,image::UNMASKED))); tinfo)); } // Footsteps indicating a movement path drawing_buffer_add(LAYER_TERRAIN_TMP_BG, loc, tblit(xpos, ypos, footsteps_images(loc))); // Draw cross images for debug highlights if(game_config::debug && debugHighlights_.count(loc)) { drawing_buffer_add(LAYER_TERRAIN_TMP_BG, loc, tblit(xpos, ypos, image::get_image(game_config::cross_image, image::UNMASKED))); } // Draw the attack direction indicator if(on_map && loc == attack_indicator_src_) { textureAtlasInfo tinfo; getTextureAtlasInfo("misc/attack-indicator-src-" + attack_indicator_direction() + ".png", tinfo); drawing_buffer_add(LAYER_ATTACK_INDICATOR, loc, tblit(xpos, ypos, //image::get_image("misc/attack-indicator-src-" + attack_indicator_direction() + ".png", image::UNMASKED))); tinfo)); } else if (on_map && loc == attack_indicator_dst_) { textureAtlasInfo tinfo; getTextureAtlasInfo("misc/attack-indicator-dst-" + attack_indicator_direction() + ".png", tinfo); drawing_buffer_add(LAYER_ATTACK_INDICATOR, loc, tblit(xpos, ypos, //image::get_image("misc/attack-indicator-dst-" + attack_indicator_direction() + ".png", image::UNMASKED))); tinfo)); } // Linger overlay unconditionally otherwise it might give glitches // so it's drawn over the shroud and fog. if(game_mode_ != RUNNING) { blit.surf.push_back(image::get_image(game_config::linger_image, image::SCALED_TO_HEX)); drawing_buffer_add(LAYER_LINGER_OVERLAY, loc, blit); blit.surf.clear(); } // Show def% and turn to reach infos if(!is_shrouded && on_map) { draw_movement_info(loc); } //simulate_delay += 1; }
void game_display::draw_hex(const map_location& loc) { const bool on_map = get_map().on_board(loc); const bool is_shrouded = shrouded(loc); const bool is_fogged = fogged(loc); const int xpos = get_location_x(loc); const int ypos = get_location_y(loc); image::TYPE image_type = get_image_type(loc); display::draw_hex(loc); if(on_map && loc == mouseoverHex_) { tdrawing_layer hex_top_layer = LAYER_MOUSEOVER_BOTTOM; if( get_visible_unit(loc, (*teams_)[viewing_team()] ) != NULL ) { hex_top_layer = LAYER_MOUSEOVER_TOP; } drawing_buffer_add( hex_top_layer, loc, xpos, ypos, image::get_image("misc/hover-hex-top.png", image::SCALED_TO_HEX)); drawing_buffer_add(LAYER_MOUSEOVER_BOTTOM, loc, xpos, ypos, image::get_image("misc/hover-hex-bottom.png", image::SCALED_TO_HEX)); } if(!is_shrouded) { typedef overlay_map::const_iterator Itor; 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) && !(is_fogged && !overlays.first->second.visible_in_fog)) { drawing_buffer_add(LAYER_TERRAIN_BG, loc, xpos, ypos, image::get_image(overlays.first->second.image,image_type)); } } // village-control flags. drawing_buffer_add(LAYER_TERRAIN_BG, loc, xpos, ypos, get_flag(loc)); } // Draw reach_map information. // We remove the reachability mask of the unit // that we want to attack. if (!is_shrouded && !reach_map_.empty() && reach_map_.find(loc) == reach_map_.end() && loc != attack_indicator_dst_) { static const image::locator unreachable(game_config::images::unreachable); drawing_buffer_add(LAYER_REACHMAP, loc, xpos, ypos, image::get_image(unreachable,image::SCALED_TO_HEX)); } resources::whiteboard->draw_hex(loc); if (!(resources::whiteboard->is_active() && resources::whiteboard->has_temp_move())) { // Footsteps indicating a movement path const std::vector<surface>& footstepImages = footsteps_images(loc); if (footstepImages.size() != 0) { drawing_buffer_add(LAYER_FOOTSTEPS, loc, xpos, ypos, footstepImages); } } // Draw the attack direction indicator if(on_map && loc == attack_indicator_src_) { drawing_buffer_add(LAYER_ATTACK_INDICATOR, loc, xpos, ypos, image::get_image("misc/attack-indicator-src-" + attack_indicator_direction() + ".png", image::SCALED_TO_HEX)); } else if (on_map && loc == attack_indicator_dst_) { drawing_buffer_add(LAYER_ATTACK_INDICATOR, loc, xpos, ypos, image::get_image("misc/attack-indicator-dst-" + attack_indicator_direction() + ".png", image::SCALED_TO_HEX)); } // Linger overlay unconditionally otherwise it might give glitches // so it's drawn over the shroud and fog. if(game_mode_ != RUNNING) { static const image::locator linger(game_config::images::linger); drawing_buffer_add(LAYER_LINGER_OVERLAY, loc, xpos, ypos, image::get_image(linger, image::TOD_COLORED)); } if(on_map && loc == selectedHex_ && !game_config::images::selected.empty()) { static const image::locator selected(game_config::images::selected); drawing_buffer_add(LAYER_SELECTED_HEX, loc, xpos, ypos, image::get_image(selected, image::SCALED_TO_HEX)); } // Show def% and turn to reach info if(!is_shrouded && on_map) { draw_movement_info(loc); } if(game_config::debug) { int debugH = debugHighlights_[loc]; if (debugH) { std::string txt = lexical_cast<std::string>(debugH); draw_text_in_hex(loc, LAYER_MOVE_INFO, txt, 18, font::BAD_COLOR); } } //simulate_delay += 1; }