Fix #2273: map labels aren't drawn in the editor
It was caused by two independent bugs. Fixing either would have made the
map labels to show up: I fixed both.
First, map_labels::visible_global_label() is intended to check whether any
label from the player's team is shown in a certain position, in order to
check if a global label in the same position can be shown. In the editor,
the "team name" is the empty string - the same as the "team name" for
global labels. As a result, all global labels were considered to be in the
player's team, and therefore every global label was suppressed in favor of
itself.
That wouldn't have been a problem on its own, however. Commit 2fb13f89da
added a check that makes all labels visible in the editor, before checking
if they overlap team labels. The problem was that the check wasn't working.
It's true that there are no teams in the map editor, but the same isn't
true in the scenario editor - and labels can only be placed in the scenario
editor.
I fixed the first problem by checking if there is a viewing team to begin
with, and the second problem by calling display::in_editor() instead of
checking the number of teams.
This commit is contained in:
parent
ddd8d81d81
commit
a1fe596cff
2 changed files with 11 additions and 6 deletions
|
@ -265,6 +265,11 @@ void map_labels::enable(bool is_enabled)
|
|||
*/
|
||||
bool map_labels::visible_global_label(const map_location& loc) const
|
||||
{
|
||||
if(team_ == nullptr) {
|
||||
// We're in the editor. All global labels can be shown.
|
||||
return true;
|
||||
}
|
||||
|
||||
const team_label_map::const_iterator glabels = labels_.find(team_name());
|
||||
return glabels == labels_.end() || glabels->second.find(loc) == glabels->second.end();
|
||||
}
|
||||
|
@ -529,7 +534,7 @@ void terrain_label::draw()
|
|||
|
||||
clear();
|
||||
|
||||
if(!viewable(disp->get_disp_context())) {
|
||||
if(!viewable(*disp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -609,19 +614,19 @@ bool terrain_label::hidden() const
|
|||
* creating a label. Conditions that can change during unit movement (disregarding
|
||||
* potential WML events) should not be listed here; they belong in hidden().
|
||||
*/
|
||||
bool terrain_label::viewable(const display_context& dc) const
|
||||
bool terrain_label::viewable(const display& disp) const
|
||||
{
|
||||
if(!parent_->enabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// In the editor, all labels are viewable.
|
||||
if(dc.teams().empty()) {
|
||||
if(disp.in_editor()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Observers are not privvy to team labels.
|
||||
const bool can_see_team_labels = !dc.is_observer();
|
||||
const bool can_see_team_labels = !disp.get_disp_context().is_observer();
|
||||
|
||||
// Global labels are shown unless covered by a team label.
|
||||
if(team_name_.empty()) {
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <string>
|
||||
|
||||
class config;
|
||||
class display_context;
|
||||
class display;
|
||||
class team;
|
||||
class terrain_label;
|
||||
|
||||
|
@ -207,7 +207,7 @@ private:
|
|||
void clear();
|
||||
void draw();
|
||||
bool hidden() const;
|
||||
bool viewable(const display_context& dc) const;
|
||||
bool viewable(const display& disp) const;
|
||||
|
||||
int handle_;
|
||||
int tooltip_handle_;
|
||||
|
|
Loading…
Add table
Reference in a new issue