Skip to content

Commit

Permalink
Merge pull request #4263 from kwvanderlinde/bugfix/4258-delete-drawin…
Browse files Browse the repository at this point in the history
…g-tool-does-not-respect-selected-layer

Fix delete drawing tool to respect the selected layer
  • Loading branch information
cwisniew authored Aug 26, 2023
2 parents c20e5da + 233a092 commit 39a3f65
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ protected void selectedLayerChanged(Zone.Layer layer) {
protected void attachTo(ZoneRenderer renderer) {
super.attachTo(renderer);
this.renderer = renderer;
layerSelectionDialog.updateViewList();
selectedLayer = renderer.getActiveLayer();
layerSelectionDialog.setSelectedLayer(selectedLayer);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ protected void attachTo(ZoneRenderer renderer) {
}
htmlRenderer.attach(renderer);

if (renderer.getActiveLayer() != Zone.Layer.TOKEN) {
if (getSelectedLayer() != Zone.Layer.TOKEN) {
MapTool.getFrame().getToolbox().setSelectedTool(StampTool.class);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ protected void completeDrawable(GUID zoneId, Pen pen, Drawable drawable) {
return;
}
if (MapTool.getPlayer().isGM()) {
drawable.setLayer(renderer.getActiveLayer());
drawable.setLayer(getSelectedLayer());
} else {
drawable.setLayer(Layer.TOKEN);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import net.rptools.maptool.client.ui.zone.ZoneRenderer;
import net.rptools.maptool.events.MapToolEventBus;
import net.rptools.maptool.model.GUID;
import net.rptools.maptool.model.Zone.Layer;
import net.rptools.maptool.model.ZonePoint;
import net.rptools.maptool.model.drawing.DrawnElement;

Expand All @@ -46,8 +45,6 @@ public class DeleteDrawingTool extends DefaultTool implements ZoneOverlay, Mouse
private static final DrawPanelPopupMenu.DeleteDrawingAction deleteAction =
new DrawPanelPopupMenu.DeleteDrawingAction(selectedDrawings);

private static Layer selectedLayer = Layer.TOKEN;

public DeleteDrawingTool() {
new MapToolEventBus().getMainEventBus().register(this);
}
Expand Down Expand Up @@ -91,7 +88,7 @@ public void mouseClicked(MouseEvent e) {

if (!multiSelect) selectedDrawings.clear();

var drawableList = zone.getDrawnElements(selectedLayer);
var drawableList = zone.getDrawnElements(getSelectedLayer());
for (var element : drawableList) {
var drawable = element.getDrawable();
var id = drawable.getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListSelectionModel;
import net.rptools.maptool.client.MapTool;
import net.rptools.maptool.client.swing.AbeillePanel;
import net.rptools.maptool.model.Zone;

Expand Down Expand Up @@ -51,11 +50,6 @@ public void fireViewSelectionChange() {
}
}

public void updateViewList() {
getLayerList()
.setSelectedValue(MapTool.getFrame().getCurrentZoneRenderer().getActiveLayer(), true);
}

private JList<Zone.Layer> getLayerList() {

if (list == null) {
Expand Down Expand Up @@ -83,7 +77,7 @@ private JList<Zone.Layer> getLayerList() {
}

public void setSelectedLayer(Zone.Layer layer) {
list.setSelectedValue(layer, true);
getLayerList().setSelectedValue(layer, true);
}

public interface LayerSelectionListener {
Expand Down

0 comments on commit 39a3f65

Please sign in to comment.