Skip to content

Commit

Permalink
Merge pull request #4949 from kwvanderlinde/bugfix/4933-repeated-menu…
Browse files Browse the repository at this point in the history
…-item-for-clearing-lights

Add clear lights menu items only once
  • Loading branch information
cwisniew authored Sep 27, 2024
2 parents 354f07a + 7da81bd commit fbb27b1
Showing 1 changed file with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,24 +120,33 @@ public void actionPerformed(ActionEvent e) {
protected JMenu createLightSourceMenu() {
JMenu menu = new JMenu(I18N.getText("panel.MapExplorer.View.LIGHT_SOURCES"));

if (tokenUnderMouse.hasLightSources()) {
boolean hasAnyLights = false;
boolean hasLights = false;
boolean hasAuras = false;
boolean hasGmAuras = false;
boolean hasOwnerOnlyAuras = false;

for (GUID tokenGUID : selectedTokenSet) {
Token token = renderer.getZone().getToken(tokenGUID);
hasAnyLights |= token.hasLightSources();
hasLights |= token.hasLightSourceType(LightSource.Type.NORMAL);
hasAuras |= token.hasLightSourceType(LightSource.Type.AURA);
hasGmAuras |= token.hasGMAuras();
hasOwnerOnlyAuras |= token.hasOwnerOnlyAuras();
}
if (hasAnyLights) {
menu.add(new ClearLightAction());

ZoneRenderer renderer = MapTool.getFrame().getCurrentZoneRenderer();
for (GUID tokenGUID : selectedTokenSet) {
Token token = renderer.getZone().getToken(tokenGUID);
if (token.hasLightSourceType(LightSource.Type.NORMAL)) {
menu.add(new ClearLightsOnlyAction());
}
if (token.hasLightSourceType(LightSource.Type.AURA)) {
menu.add(new ClearAurasOnlyAction());
}
if (token.hasGMAuras()) {
menu.add(new ClearGMAurasOnlyAction());
}
if (token.hasOwnerOnlyAuras()) {
menu.add(new ClearOwnerAurasOnlyAction());
}
if (hasLights) {
menu.add(new ClearLightsOnlyAction());
}
if (hasAuras) {
menu.add(new ClearAurasOnlyAction());
}
if (hasGmAuras) {
menu.add(new ClearGMAurasOnlyAction());
}
if (hasOwnerOnlyAuras) {
menu.add(new ClearOwnerAurasOnlyAction());
}
menu.addSeparator();
}
Expand Down

0 comments on commit fbb27b1

Please sign in to comment.