Skip to content

Commit

Permalink
Merge pull request #5266 from Jmr3366/j_develop_oLock
Browse files Browse the repository at this point in the history
Overlay Updates
  • Loading branch information
kwvanderlinde authored Feb 23, 2025
2 parents 09a6949 + ee69396 commit 0701a3d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public Object childEvaluate(
throw new ParserException(
I18N.getText("msg.error.frame.reservedName", parameters.get(0).toString()));
}

if (functionName.equalsIgnoreCase("isDialogVisible")) {
FunctionUtil.checkNumberParam(functionName, parameters, 1, 1);
return HTMLFrameFactory.isVisible(false, parameters.get(0).toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ public static void addToOverlayMenu(HTMLOverlayManager overlayManager) {
JCheckBoxMenuItem menuItem =
new RPCheckBoxMenuItem(new AppActions.ToggleOverlayAction(overlayManager), overlayMenu);
menuItem.setText(overlayManager.getName());
if (overlayManager.getLocked()) {
if (overlayManager.getLocked() && !MapTool.getPlayer().isGM()) {
overlayMenu.add(menuItem).setEnabled(false);
} else {
overlayMenu.add(menuItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ void setZOrder(int zOrder) {
this.zOrder = zOrder;
}

void setLocked(boolean locked) {
this.locked = locked;
}

/**
* @return the name of the overlay.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,16 @@
import java.util.*;
import java.util.concurrent.ConcurrentSkipListSet;
import javafx.application.Platform;
import javafx.collections.ObservableList;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.input.ScrollEvent;
import javafx.scene.layout.Background;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import javafx.scene.web.WebView;
import javax.swing.*;
import net.rptools.maptool.client.AppConstants;
import net.rptools.maptool.client.MapTool;
import net.rptools.maptool.client.events.OverlayVisibilityChanged;
import net.rptools.maptool.client.swing.SwingUtil;
Expand Down Expand Up @@ -212,10 +211,12 @@ public void removeOverlay(String name) {
*/
private void removeOverlay(HTMLOverlayManager overlay) {
if (overlay != null) {
root.getChildren().remove(overlay.getWebView());
overlays.remove(overlay);
AppMenuBar.removeFromOverlayMenu(overlay.getName());
overlay.flush();
if (!overlay.getName().startsWith(AppConstants.INTERNAL_FRAME_PREFIX)) {
root.getChildren().remove(overlay.getWebView());
overlays.remove(overlay);
AppMenuBar.removeFromOverlayMenu(overlay.getName());
overlay.flush();
}
if (overlays.isEmpty()) {
setVisible(false); // hide overlay panel if all are gone
}
Expand All @@ -224,17 +225,19 @@ private void removeOverlay(HTMLOverlayManager overlay) {

/** Removes all overlays. */
public void removeAllOverlays() {
this.setVisible(false);
Platform.runLater(
() -> {
ObservableList<Node> listChildren = root.getChildren();
for (HTMLOverlayManager overlay : overlays) {
listChildren.remove(overlay.getWebView());
AppMenuBar.removeFromOverlayMenu(overlay.getName());
overlay.flush();
if (!overlay.getName().startsWith(AppConstants.INTERNAL_FRAME_PREFIX)) {
root.getChildren().remove(overlay.getWebView());
overlays.remove(overlay);
AppMenuBar.removeFromOverlayMenu(overlay.getName());
overlay.flush();
}
}
if (overlays.isEmpty()) {
setVisible(false);
}
overlays.clear();
setVisible(false);
});
}

Expand All @@ -257,12 +260,16 @@ public void showOverlay(String name, int zOrder, boolean locked, String html, Ob
// Blank removes the overlay
removeOverlay(overlayManager);
return;
} else if (zOrder != overlayManager.getZOrder()) {
// Resorts by removing and adding back the overlay
overlays.remove(overlayManager);
overlayManager.setZOrder(zOrder);
overlays.add(overlayManager);
} else {
if (zOrder != overlayManager.getZOrder()) {
// Resorts by removing and adding back the overlay
overlays.remove(overlayManager);
overlayManager.setZOrder(zOrder);
overlays.add(overlayManager);
}
overlayManager.setLocked(locked);
}

} else {
overlayManager = new HTMLOverlayManager(name, zOrder, locked);
overlayManager.setupWebView(new WebView());
Expand Down

0 comments on commit 0701a3d

Please sign in to comment.