widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #10842
[Merge] lp:~widelands-dev/widelands/buildhelp_overlay into lp:widelands
SirVer has proposed merging lp:~widelands-dev/widelands/buildhelp_overlay into lp:widelands.
Commit message:
Simplify FieldOverlayManager.
- Remove ability to put Overlays on Triangles (which was unused).
- Simplify some functions.
- Replace numeric overlay levels by an enum class.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/buildhelp_overlay/+merge/328956
Another pure refactoring working towards toggable overlays in the editor.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/buildhelp_overlay into lp:widelands.
=== modified file 'src/editor/editorinteractive.cc'
--- src/editor/editorinteractive.cc 2017-05-14 14:40:24 +0000
+++ src/editor/editorinteractive.cc 2017-08-13 18:49:30 +0000
@@ -80,7 +80,7 @@
const std::string str =
world.get_resource(note.fc.field->get_resources())->editor_image(amount);
const Image* pic = g_gr->images().get(str);
- field_overlay_manager->register_overlay(note.fc, pic, 0);
+ field_overlay_manager->register_overlay(note.fc, pic, OverlayLevel::kResource);
}
}
@@ -180,8 +180,10 @@
if (uint8_t const amount = fc.field->get_resources_amount()) {
const std::string& immname =
egbase().world().get_resource(fc.field->get_resources())->editor_image(amount);
- if (immname.size())
- mutable_field_overlay_manager()->register_overlay(fc, g_gr->images().get(immname), 4);
+ if (immname.size()) {
+ mutable_field_overlay_manager()->register_overlay(
+ fc, g_gr->images().get(immname), OverlayLevel::kResource);
+ }
}
}
}
=== modified file 'src/editor/tools/make_infrastructure_tool.cc'
--- src/editor/tools/make_infrastructure_tool.cc 2017-01-25 18:55:59 +0000
+++ src/editor/tools/make_infrastructure_tool.cc 2017-08-13 18:49:30 +0000
@@ -29,7 +29,7 @@
/**
* Callback function to calculate correct overlays
*/
-int32_t editor_make_infrastructure_tool_callback(const Widelands::TCoords<Widelands::FCoords>& c,
+int32_t editor_make_infrastructure_tool_callback(const Widelands::FCoords& c,
Widelands::EditorGameBase& egbase,
int32_t const player) {
return egbase.player(player).get_buildcaps(c);
=== modified file 'src/editor/tools/make_infrastructure_tool.h'
--- src/editor/tools/make_infrastructure_tool.h 2017-01-25 18:55:59 +0000
+++ src/editor/tools/make_infrastructure_tool.h 2017-08-13 18:49:30 +0000
@@ -57,7 +57,7 @@
UI::UniqueWindow::Registry registry_;
};
-int32_t editor_make_infrastructure_tool_callback(const Widelands::TCoords<Widelands::FCoords>& c,
+int32_t editor_make_infrastructure_tool_callback(const Widelands::FCoords& c,
Widelands::EditorGameBase& egbase,
int32_t const player);
=== modified file 'src/editor/tools/set_port_space_tool.cc'
--- src/editor/tools/set_port_space_tool.cc 2017-01-25 18:55:59 +0000
+++ src/editor/tools/set_port_space_tool.cc 2017-08-13 18:49:30 +0000
@@ -29,12 +29,10 @@
using namespace Widelands;
/// static callback function for overlay calculation
-int32_t editor_Tool_set_port_space_callback(const Widelands::TCoords<Widelands::FCoords>& c,
- const Map& map) {
+int32_t editor_tool_set_port_space_callback(const Widelands::FCoords& c, const Map& map) {
NodeCaps const caps = c.field->nodecaps();
- FCoords f = map.get_fcoords(*c.field);
if ((caps & BUILDCAPS_SIZEMASK) == BUILDCAPS_BIG) {
- if (!map.find_portdock(f).empty())
+ if (!map.find_portdock(c).empty())
return caps;
}
return 0;
@@ -63,7 +61,7 @@
*map, Widelands::Area<Widelands::FCoords>(map->get_fcoords(center.node), args->sel_radius));
do {
// check if field is valid
- if (editor_Tool_set_port_space_callback(mr.location(), *map)) {
+ if (editor_tool_set_port_space_callback(mr.location(), *map)) {
map->set_port_space(mr.location(), true);
Area<FCoords> a(mr.location(), 0);
map->recalc_for_field_area(world, a);
@@ -98,7 +96,7 @@
*map, Widelands::Area<Widelands::FCoords>(map->get_fcoords(center.node), args->sel_radius));
do {
// check if field is valid
- if (editor_Tool_set_port_space_callback(mr.location(), *map)) {
+ if (editor_tool_set_port_space_callback(mr.location(), *map)) {
map->set_port_space(mr.location(), false);
Area<FCoords> a(mr.location(), 0);
map->recalc_for_field_area(world, a);
=== modified file 'src/editor/tools/set_port_space_tool.h'
--- src/editor/tools/set_port_space_tool.h 2017-06-24 08:47:46 +0000
+++ src/editor/tools/set_port_space_tool.h 2017-08-13 18:49:30 +0000
@@ -70,7 +70,6 @@
}
};
-int32_t editor_Tool_set_port_space_callback(const Widelands::TCoords<Widelands::FCoords>& c,
- const Widelands::Map& map);
+int32_t editor_tool_set_port_space_callback(const Widelands::FCoords& c, const Widelands::Map& map);
#endif // end of include guard: WL_EDITOR_TOOLS_SET_PORT_SPACE_TOOL_H
=== modified file 'src/editor/tools/set_starting_pos_tool.cc'
--- src/editor/tools/set_starting_pos_tool.cc 2017-05-03 07:24:06 +0000
+++ src/editor/tools/set_starting_pos_tool.cc 2017-08-13 18:49:30 +0000
@@ -31,8 +31,7 @@
/*
* static callback function for overlay calculation
*/
-int32_t editor_tool_set_starting_pos_callback(const Widelands::TCoords<Widelands::FCoords>& c,
- Widelands::Map& map) {
+int32_t editor_tool_set_starting_pos_callback(const Widelands::FCoords& c, Widelands::Map& map) {
// Area around already placed players
Widelands::PlayerNumber const nr_players = map.get_nrplayers();
for (Widelands::PlayerNumber p = 1, last = current_player_ - 1;; ++p) {
@@ -102,8 +101,9 @@
const Image* player_image = playercolor_image(plnum - 1, "images/players/player_position.png");
assert(player_image);
- overlay_manager->register_overlay(
- c, player_image, 8, Vector2i(player_image->width() / 2, STARTING_POS_HOTSPOT_Y), overlay_id);
+ overlay_manager->register_overlay(c, player_image, OverlayLevel::kPlayerStartingPosition,
+ Vector2i(player_image->width() / 2, STARTING_POS_HOTSPOT_Y),
+ overlay_id);
// set new player pos
map->set_starting_pos(plnum, c);
=== modified file 'src/editor/tools/set_starting_pos_tool.h'
--- src/editor/tools/set_starting_pos_tool.h 2017-05-03 07:24:06 +0000
+++ src/editor/tools/set_starting_pos_tool.h 2017-08-13 18:49:30 +0000
@@ -59,7 +59,6 @@
std::vector<FieldOverlayManager::OverlayId> overlay_ids_;
};
-int32_t editor_tool_set_starting_pos_callback(const Widelands::TCoords<Widelands::FCoords>& c,
- Widelands::Map& map);
+int32_t editor_tool_set_starting_pos_callback(const Widelands::FCoords& c, Widelands::Map& map);
#endif // end of include guard: WL_EDITOR_TOOLS_SET_STARTING_POS_TOOL_H
=== modified file 'src/editor/ui_menus/tool_change_resources_options_menu.cc'
--- src/editor/ui_menus/tool_change_resources_options_menu.cc 2017-05-13 11:25:24 +0000
+++ src/editor/ui_menus/tool_change_resources_options_menu.cc 2017-08-13 18:49:30 +0000
@@ -156,10 +156,9 @@
Widelands::EditorGameBase& egbase = eia().egbase();
Widelands::Map& map = egbase.map();
eia().mutable_field_overlay_manager()->register_overlay_callback_function(
- [resource_index, &map,
- &egbase](const Widelands::TCoords<Widelands::FCoords>& coords) -> uint32_t {
- if (map.is_resource_valid(egbase.world(), coords, resource_index)) {
- return coords.field->nodecaps();
+ [resource_index, &map, &egbase](const Widelands::FCoords& fc) -> uint32_t {
+ if (map.is_resource_valid(egbase.world(), fc, resource_index)) {
+ return fc.field->nodecaps();
}
return 0;
});
=== modified file 'src/editor/ui_menus/tool_menu.cc'
--- src/editor/ui_menus/tool_menu.cc 2017-01-25 18:55:59 +0000
+++ src/editor/ui_menus/tool_menu.cc 2017-08-13 18:49:30 +0000
@@ -144,7 +144,7 @@
// Set correct overlay
Widelands::Map& map = parent.egbase().map();
parent.mutable_field_overlay_manager()->register_overlay_callback_function(
- boost::bind(&editor_Tool_set_port_space_callback, _1, boost::ref(map)));
+ boost::bind(&editor_tool_set_port_space_callback, _1, boost::ref(map)));
map.recalc_whole_map(parent.egbase().world());
}
=== modified file 'src/graphic/game_renderer.cc'
--- src/graphic/game_renderer.cc 2017-08-12 20:13:24 +0000
+++ src/graphic/game_renderer.cc 2017-08-13 18:49:30 +0000
@@ -260,43 +260,6 @@
BlendMode::UseAlpha);
}
}
-
- {
- // Render overlays on the right triangle
- overlay_info.clear();
- overlay_manager.get_overlays(TCoords<>(field.fcoords, TCoords<>::R), &overlay_info);
-
- Vector2f tripos(
- (field.rendertarget_pixel.x + rn.rendertarget_pixel.x + brn.rendertarget_pixel.x) / 3.f,
- (field.rendertarget_pixel.y + rn.rendertarget_pixel.y + brn.rendertarget_pixel.y) /
- 3.f);
- for (const auto& overlay : overlay_info) {
- dst->blitrect_scale(Rectf(tripos - overlay.hotspot.cast<float>() * zoom,
- overlay.pic->width() * zoom, overlay.pic->height() * zoom),
- overlay.pic,
- Recti(0, 0, overlay.pic->width(), overlay.pic->height()), 1.f,
- BlendMode::UseAlpha);
- }
- }
-
- {
- // Render overlays on the D triangle
- overlay_info.clear();
- overlay_manager.get_overlays(TCoords<>(field.fcoords, TCoords<>::D), &overlay_info);
-
- Vector2f tripos(
- (field.rendertarget_pixel.x + bln.rendertarget_pixel.x + brn.rendertarget_pixel.x) /
- 3.f,
- (field.rendertarget_pixel.y + bln.rendertarget_pixel.y + brn.rendertarget_pixel.y) /
- 3.f);
- for (const auto& overlay : overlay_info) {
- dst->blitrect_scale(Rectf(tripos - overlay.hotspot.cast<float>() * zoom,
- overlay.pic->width() * zoom, overlay.pic->height() * zoom),
- overlay.pic,
- Recti(0, 0, overlay.pic->width(), overlay.pic->height()), 1.f,
- BlendMode::UseAlpha);
- }
- }
}
}
=== modified file 'src/wui/field_overlay_manager.cc'
--- src/wui/field_overlay_manager.cc 2017-08-12 16:57:43 +0000
+++ src/wui/field_overlay_manager.cc 2017-08-13 18:49:30 +0000
@@ -26,6 +26,12 @@
#include "graphic/graphic.h"
#include "logic/field.h"
+namespace {
+
+constexpr int kLevelForBuildHelp = 5;
+
+} // namespace
+
FieldOverlayManager::FieldOverlayManager() : current_overlay_id_(0) {
OverlayInfo* buildhelp_info = buildhelp_infos_;
const char* filenames[] = {"images/wui/overlays/set_flag.png", "images/wui/overlays/small.png",
@@ -58,12 +64,11 @@
buildhelp_ = value;
}
-void FieldOverlayManager::get_overlays(Widelands::FCoords const c,
+void FieldOverlayManager::get_overlays(const Widelands::FCoords& c,
std::vector<OverlayInfo>* result) const {
- const RegisteredOverlaysMap& overlay_map = overlays_[Widelands::TCoords<>::None];
- RegisteredOverlaysMap::const_iterator it = overlay_map.lower_bound(c);
-
- while (it != overlay_map.end() && it->first == c && it->second.level <= kLevelForBuildHelp) {
+ auto it = overlays_.lower_bound(c);
+ while (it != overlays_.end() && it->first == c &&
+ static_cast<int>(it->second.level) <= kLevelForBuildHelp) {
result->emplace_back(it->second.pic, it->second.hotspot);
++it;
}
@@ -75,19 +80,7 @@
}
}
- while (it != overlay_map.end() && it->first == c) {
- result->emplace_back(it->second.pic, it->second.hotspot);
- ++it;
- }
-}
-
-void FieldOverlayManager::get_overlays(Widelands::TCoords<> const c,
- std::vector<OverlayInfo>* result) const {
- assert(c.t == Widelands::TCoords<>::D || c.t == Widelands::TCoords<>::R);
-
- const RegisteredOverlaysMap& overlay_map = overlays_[c.t];
- RegisteredOverlaysMap::const_iterator it = overlay_map.lower_bound(c);
- while (it != overlay_map.end() && it->first == c) {
+ while (it != overlays_.end() && it->first == c) {
result->emplace_back(it->second.pic, it->second.hotspot);
++it;
}
@@ -97,41 +90,44 @@
Widelands::NodeCaps const caps =
callback_ ? static_cast<Widelands::NodeCaps>(callback_(fc)) : fc.field->nodecaps();
- const int value = (caps & Widelands::BUILDCAPS_MINE) ?
- Widelands::Field::Buildhelp_Mine :
- (caps & Widelands::BUILDCAPS_SIZEMASK) == Widelands::BUILDCAPS_BIG ?
- ((caps & Widelands::BUILDCAPS_PORT) ? Widelands::Field::Buildhelp_Port :
- Widelands::Field::Buildhelp_Big) :
- (caps & Widelands::BUILDCAPS_SIZEMASK) == Widelands::BUILDCAPS_MEDIUM ?
- Widelands::Field::Buildhelp_Medium :
- (caps & Widelands::BUILDCAPS_SIZEMASK) == Widelands::BUILDCAPS_SMALL ?
- Widelands::Field::Buildhelp_Small :
- (caps & Widelands::BUILDCAPS_FLAG) ? Widelands::Field::Buildhelp_Flag :
- Widelands::Field::Buildhelp_None;
- return value;
+ if (caps & Widelands::BUILDCAPS_MINE) {
+ return Widelands::Field::Buildhelp_Mine;
+ }
+ if ((caps & Widelands::BUILDCAPS_SIZEMASK) == Widelands::BUILDCAPS_BIG) {
+ if (caps & Widelands::BUILDCAPS_PORT) {
+ return Widelands::Field::Buildhelp_Port;
+ }
+ return Widelands::Field::Buildhelp_Big;
+ }
+ if ((caps & Widelands::BUILDCAPS_SIZEMASK) == Widelands::BUILDCAPS_MEDIUM) {
+ return Widelands::Field::Buildhelp_Medium;
+ }
+ if ((caps & Widelands::BUILDCAPS_SIZEMASK) == Widelands::BUILDCAPS_SMALL) {
+ return Widelands::Field::Buildhelp_Small;
+ }
+ if (caps & Widelands::BUILDCAPS_FLAG) {
+ return Widelands::Field::Buildhelp_Flag;
+ }
+ return Widelands::Field::Buildhelp_None;
}
-void FieldOverlayManager::register_overlay(const Widelands::TCoords<>& c,
+void FieldOverlayManager::register_overlay(const Widelands::Coords& c,
const Image* pic,
- int32_t const level,
+ const OverlayLevel& level,
Vector2i hotspot,
OverlayId const overlay_id) {
- assert(c.t <= 2);
- assert(level != 5); // level == 5 is undefined behavior
-
if (hotspot == Vector2i::invalid()) {
hotspot = Vector2i(pic->width() / 2, pic->height() / 2);
}
- RegisteredOverlaysMap& overlay_map = overlays_[c.t];
- for (RegisteredOverlaysMap::iterator it = overlay_map.find(c);
- it != overlay_map.end() && it->first == c; ++it)
+ for (auto it = overlays_.find(c);
+ it != overlays_.end() && it->first == c; ++it)
if (it->second.pic == pic && it->second.hotspot == hotspot && it->second.level == level) {
it->second.overlay_ids.insert(overlay_id);
return;
}
- overlay_map.insert(std::pair<Widelands::Coords const, RegisteredOverlays>(
+ overlays_.insert(std::pair<Widelands::Coords const, RegisteredOverlays>(
c, RegisteredOverlays(overlay_id, pic, hotspot, level)));
// Now manually sort, so that they are ordered
@@ -139,18 +135,17 @@
// * second by levels (done manually here)
// there is at least one registered
- RegisteredOverlaysMap::iterator it = overlay_map.lower_bound(c), jt;
-
+ auto it = overlays_.lower_bound(c);
do {
- jt = it;
+ auto jt = it;
++jt;
- if (jt == overlay_map.end())
+ if (jt == overlays_.end())
break;
if (jt->first == it->first) {
// There are several overlays registered for this location.
if (jt->second.level < it->second.level) {
std::swap(it->second, jt->second);
- it = overlay_map.lower_bound(c);
+ it = overlays_.lower_bound(c);
} else
++it;
} else
@@ -163,40 +158,34 @@
*
* @param pic The overlay to remove. If null, all overlays are removed.
*/
-void FieldOverlayManager::remove_overlay(Widelands::TCoords<> const c, const Image* pic) {
- assert(c.t <= 2);
-
- RegisteredOverlaysMap& overlay_map = overlays_[c.t];
-
- if (overlay_map.count(c)) {
- RegisteredOverlaysMap::iterator it = overlay_map.lower_bound(c);
- do {
- if (!pic || it->second.pic == pic) {
- overlay_map.erase(it);
- it = overlay_map.lower_bound(c);
- } else {
- ++it;
- }
- } while (it != overlay_map.end() && it->first == c);
+void FieldOverlayManager::remove_overlay(const Widelands::Coords& c, const Image* pic) {
+ if (overlays_.count(c) == 0) {
+ return;
}
+ auto it = overlays_.lower_bound(c);
+ do {
+ if (!pic || it->second.pic == pic) {
+ overlays_.erase(it);
+ it = overlays_.lower_bound(c);
+ } else {
+ ++it;
+ }
+ } while (it != overlays_.end() && it->first == c);
}
void FieldOverlayManager::remove_overlay(const OverlayId overlay_id) {
- const RegisteredOverlaysMap* const overlays_end = overlays_ + 3;
- for (RegisteredOverlaysMap* j = overlays_; j != overlays_end; ++j)
- for (RegisteredOverlaysMap::iterator it = j->begin(); it != j->end();) {
- it->second.overlay_ids.erase(overlay_id);
- if (it->second.overlay_ids.empty())
- j->erase(it++); // This is necessary!
- else
- ++it;
+ for (auto it = overlays_.begin(); it != overlays_.end();) {
+ it->second.overlay_ids.erase(overlay_id);
+ if (it->second.overlay_ids.empty()) {
+ overlays_.erase(it++); // This is necessary!
+ } else {
+ ++it;
}
+ }
}
void FieldOverlayManager::remove_all_overlays() {
- overlays_[0].clear();
- overlays_[1].clear();
- overlays_[2].clear();
+ overlays_.clear();
}
void FieldOverlayManager::register_overlay_callback_function(CallbackFn function) {
=== modified file 'src/wui/field_overlay_manager.h'
--- src/wui/field_overlay_manager.h 2017-08-12 06:51:08 +0000
+++ src/wui/field_overlay_manager.h 2017-08-13 18:49:30 +0000
@@ -47,7 +47,18 @@
* with the overlay_id can be called and all overlays created in the
* job are removed.
*/
-constexpr int kLevelForBuildHelp = 5;
+
+// Levels for the overlay registers. This defines in which order they will be
+// drawn. Buildhelp is special and has the value 5, i.e. every smaller will be
+// drawn below the buildhelp, everything higher above.
+enum class OverlayLevel {
+ kWorkAreaPreview = 0,
+ kResource = 4,
+ kSelection = 7,
+ kRoadBuildSlope = 8,
+ kPlayerStartingPosition= 9,
+};
+
struct FieldOverlayManager {
/// A unique id identifying a registered overlay.
using OverlayId = uint32_t;
@@ -66,7 +77,7 @@
/// A function returning Field::nodecaps() for the build overlay. This can be
/// registered to hide or change some of the nodecaps during rendering.
using CallbackFn =
- std::function<int32_t(const Widelands::TCoords<Widelands::FCoords>& coordinates)>;
+ std::function<int32_t(const Widelands::FCoords& coordinates)>;
FieldOverlayManager();
@@ -85,14 +96,14 @@
/// Register an overlay at a location (node or triangle). hotspot is the point
/// of the picture that will be exactly over the location. If hotspot is
/// Vector2i::invalid(), the center of the picture will be used as hotspot.
- void register_overlay(const Widelands::TCoords<>& coords,
+ void register_overlay(const Widelands::Coords& coords,
const Image* pic,
- int32_t level,
+ const OverlayLevel& overlay_level,
Vector2i hotspot = Vector2i::invalid(),
OverlayId overlay_id = 0);
/// removes all overlays when pic is nullptr.
- void remove_overlay(Widelands::TCoords<>, const Image* pic);
+ void remove_overlay(const Widelands::Coords& coords, const Image* pic);
/// remove all overlays with this overlay_id
void remove_overlay(OverlayId overlay_id);
@@ -102,34 +113,28 @@
void remove_all_overlays();
/// Returns the currently registered overlays and the buildhelp for a node.
- void get_overlays(Widelands::FCoords c, std::vector<OverlayInfo>* result) const;
-
- /// Returns the currently registered overlays for a triangle.
- void get_overlays(Widelands::TCoords<>, std::vector<OverlayInfo>* result) const;
+ void get_overlays(const Widelands::FCoords& c, std::vector<OverlayInfo>* result) const;
private:
struct RegisteredOverlays {
RegisteredOverlays(const OverlayId init_overlay_id,
const Image* init_pic,
const Vector2i init_hotspot,
- const int init_level)
+ const OverlayLevel& init_level)
: pic(init_pic), hotspot(init_hotspot), level(init_level) {
overlay_ids.insert(init_overlay_id);
}
std::set<OverlayId> overlay_ids;
const Image* pic;
Vector2i hotspot = Vector2i::zero();
- int level;
+ OverlayLevel level;
};
- using RegisteredOverlaysMap = std::multimap<const Widelands::Coords, RegisteredOverlays>;
-
// Returns the index into buildhelp_infos_ for the correct fieldcaps for
// 'fc' according to the current 'callback_'.
int get_buildhelp_overlay(const Widelands::FCoords& fc) const;
- // indexed by TCoords<>::TriangleIndex
- RegisteredOverlaysMap overlays_[3];
+ std::multimap<const Widelands::Coords, RegisteredOverlays> overlays_;
OverlayInfo buildhelp_infos_[Widelands::Field::Buildhelp_None];
bool buildhelp_;
=== modified file 'src/wui/interactive_base.cc'
--- src/wui/interactive_base.cc 2017-08-12 20:13:24 +0000
+++ src/wui/interactive_base.cc 2017-08-13 18:49:30 +0000
@@ -168,13 +168,13 @@
Widelands::MapTriangleRegion<> mr(map, Area<TCoords<>>(center.triangle, sel_.radius));
do
field_overlay_manager_->register_overlay(
- mr.location(), sel_.pic, 7, Vector2i::invalid(), jobid);
+ mr.location(), sel_.pic, OverlayLevel::kSelection, Vector2i::invalid(), jobid);
while (mr.advance(map));
} else {
Widelands::MapRegion<> mr(map, Area<>(center.node, sel_.radius));
do
field_overlay_manager_->register_overlay(
- mr.location(), sel_.pic, 7, Vector2i::invalid(), jobid);
+ mr.location(), sel_.pic, OverlayLevel::kSelection, Vector2i::invalid(), jobid);
while (mr.advance(map));
if (upcast(InteractiveGameBase const, igbase, this))
if (upcast(Widelands::ProductionSite, productionsite, map[center.node].get_immovable())) {
@@ -281,8 +281,9 @@
hollow_area.radius = it->first;
Widelands::MapHollowRegion<> mr(map, hollow_area);
do
- field_overlay_manager_->register_overlay(
- mr.location(), workarea_pics_[wa_index], 0, Vector2i::invalid(), overlay_id);
+ field_overlay_manager_->register_overlay(mr.location(), workarea_pics_[wa_index],
+ OverlayLevel::kWorkAreaPreview,
+ Vector2i::invalid(), overlay_id);
while (mr.advance(map));
wa_index++;
hollow_area.hole_radius = hollow_area.radius;
@@ -742,7 +743,7 @@
name = "images/wui/overlays/roadb_red.png";
field_overlay_manager_->register_overlay(
- neighb, g_gr->images().get(name), 7, Vector2i::invalid(), road_buildhelp_overlay_jobid_);
+ neighb, g_gr->images().get(name), OverlayLevel::kRoadBuildSlope, Vector2i::invalid(), road_buildhelp_overlay_jobid_);
}
}
=== modified file 'src/wui/interactive_gamebase.h'
--- src/wui/interactive_gamebase.h 2017-08-12 20:13:24 +0000
+++ src/wui/interactive_gamebase.h 2017-08-13 18:49:30 +0000
@@ -91,7 +91,7 @@
protected:
void draw_overlay(RenderTarget&) override;
- virtual int32_t calculate_buildcaps(const Widelands::TCoords<Widelands::FCoords>& c) = 0;
+ virtual int32_t calculate_buildcaps(const Widelands::FCoords& c) = 0;
GameMainMenuWindows main_windows_;
ChatProvider* chat_provider_;
=== modified file 'src/wui/interactive_player.cc'
--- src/wui/interactive_player.cc 2017-06-15 22:00:08 +0000
+++ src/wui/interactive_player.cc 2017-08-13 18:49:30 +0000
@@ -184,7 +184,7 @@
return player_number_;
}
-int32_t InteractivePlayer::calculate_buildcaps(const Widelands::TCoords<Widelands::FCoords>& c) {
+int32_t InteractivePlayer::calculate_buildcaps(const Widelands::FCoords& c) {
assert(get_player());
return get_player()->get_buildcaps(c);
}
=== modified file 'src/wui/interactive_player.h'
--- src/wui/interactive_player.h 2017-01-25 18:55:59 +0000
+++ src/wui/interactive_player.h 2017-08-13 18:49:30 +0000
@@ -76,7 +76,7 @@
}
void popup_message(Widelands::MessageId, const Widelands::Message&);
- int32_t calculate_buildcaps(const Widelands::TCoords<Widelands::FCoords>& c) override;
+ int32_t calculate_buildcaps(const Widelands::FCoords& c) override;
private:
void cmdSwitchPlayer(const std::vector<std::string>& args);
=== modified file 'src/wui/interactive_spectator.cc'
--- src/wui/interactive_spectator.cc 2017-02-10 15:41:31 +0000
+++ src/wui/interactive_spectator.cc 2017-08-13 18:49:30 +0000
@@ -107,16 +107,14 @@
return nullptr;
}
-int32_t InteractiveSpectator::calculate_buildcaps(const Widelands::TCoords<Widelands::FCoords>& c) {
+int32_t InteractiveSpectator::calculate_buildcaps(const Widelands::FCoords& c) {
const Widelands::PlayerNumber nr_players = game().map().get_nrplayers();
-
iterate_players_existing(p, nr_players, game(), player) {
const Widelands::NodeCaps nc = player->get_buildcaps(c);
if (nc > Widelands::NodeCaps::CAPS_NONE) {
return nc;
}
}
-
return Widelands::NodeCaps::CAPS_NONE;
}
=== modified file 'src/wui/interactive_spectator.h'
--- src/wui/interactive_spectator.h 2017-01-25 18:55:59 +0000
+++ src/wui/interactive_spectator.h 2017-08-13 18:49:30 +0000
@@ -46,7 +46,7 @@
private:
void exit_btn();
- int32_t calculate_buildcaps(const Widelands::TCoords<Widelands::FCoords>& c) override;
+ int32_t calculate_buildcaps(const Widelands::FCoords& c) override;
bool can_see(Widelands::PlayerNumber) const override;
bool can_act(Widelands::PlayerNumber) const override;
Widelands::PlayerNumber player_number() const override;
Follow ups