Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disables Token Selection buttons when the server has no Individual Views #3885

Merged
merged 3 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 11 additions & 65 deletions src/main/java/net/rptools/maptool/client/AppActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,11 @@
package net.rptools.maptool.client;

import com.jidesoft.docking.DockableFrame;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.Transparency;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.UnknownHostException;
Expand All @@ -37,42 +29,22 @@
import java.security.spec.InvalidKeySpecException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.zip.GZIPOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.crypto.NoSuchPaddingException;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ImageIcon;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JTextPane;
import javax.swing.KeyStroke;
import javax.swing.SwingWorker;
import javax.swing.*;
import javax.swing.text.BadLocationException;
import net.rptools.lib.FileUtil;
import net.rptools.lib.MD5Key;
import net.rptools.maptool.client.tool.boardtool.BoardTool;
import net.rptools.maptool.client.tool.gridtool.GridTool;
import net.rptools.maptool.client.ui.AppMenuBar;
import net.rptools.maptool.client.ui.ConnectionStatusPanel;
import net.rptools.maptool.client.ui.MapToolFrame;
import net.rptools.maptool.client.ui.*;
import net.rptools.maptool.client.ui.MapToolFrame.MTFrame;
import net.rptools.maptool.client.ui.PreviewPanelFileChooser;
import net.rptools.maptool.client.ui.StaticMessageDialog;
import net.rptools.maptool.client.ui.SysInfoDialog;
import net.rptools.maptool.client.ui.addon.AddOnLibrariesDialog;
import net.rptools.maptool.client.ui.addresource.AddResourceDialog;
import net.rptools.maptool.client.ui.assetpanel.AssetPanel;
Expand All @@ -85,12 +57,8 @@
import net.rptools.maptool.client.ui.connecttoserverdialog.ConnectToServerDialogPreferences;
import net.rptools.maptool.client.ui.exportdialog.ExportDialog;
import net.rptools.maptool.client.ui.htmlframe.HTMLOverlayManager;
import net.rptools.maptool.client.ui.io.FTPClient;
import net.rptools.maptool.client.ui.io.FTPTransferObject;
import net.rptools.maptool.client.ui.io.*;
import net.rptools.maptool.client.ui.io.FTPTransferObject.Direction;
import net.rptools.maptool.client.ui.io.LoadSaveImpl;
import net.rptools.maptool.client.ui.io.ProgressBarList;
import net.rptools.maptool.client.ui.io.UpdateRepoDialog;
import net.rptools.maptool.client.ui.mappropertiesdialog.MapPropertiesDialog;
import net.rptools.maptool.client.ui.players.PlayerDatabaseDialog;
import net.rptools.maptool.client.ui.preferencesdialog.PreferencesDialog;
Expand All @@ -103,43 +71,19 @@
import net.rptools.maptool.client.ui.zone.ZoneRenderer;
import net.rptools.maptool.client.utilities.DungeonDraftImporter;
import net.rptools.maptool.language.I18N;
import net.rptools.maptool.model.Asset;
import net.rptools.maptool.model.AssetManager;
import net.rptools.maptool.model.Campaign;
import net.rptools.maptool.model.CampaignFactory;
import net.rptools.maptool.model.CampaignProperties;
import net.rptools.maptool.model.CellPoint;
import net.rptools.maptool.model.ExposedAreaMetaData;
import net.rptools.maptool.model.GUID;
import net.rptools.maptool.model.Grid;
import net.rptools.maptool.model.LookupTable;
import net.rptools.maptool.model.TextMessage;
import net.rptools.maptool.model.Token;
import net.rptools.maptool.model.Zone;
import net.rptools.maptool.model.*;
import net.rptools.maptool.model.Zone.Layer;
import net.rptools.maptool.model.Zone.VisionType;
import net.rptools.maptool.model.ZoneFactory;
import net.rptools.maptool.model.ZonePoint;
import net.rptools.maptool.model.campaign.CampaignManager;
import net.rptools.maptool.model.drawing.DrawableTexturePaint;
import net.rptools.maptool.model.player.LocalPlayer;
import net.rptools.maptool.model.player.PasswordDatabaseException;
import net.rptools.maptool.model.player.PasswordFilePlayerDatabase;
import net.rptools.maptool.model.player.PersistedPlayerDatabase;
import net.rptools.maptool.model.player.Player;
import net.rptools.maptool.model.player.*;
import net.rptools.maptool.model.player.Player.Role;
import net.rptools.maptool.model.player.PlayerDatabase;
import net.rptools.maptool.model.player.PlayerDatabaseFactory;
import net.rptools.maptool.model.player.PlayerDatabaseFactory.PlayerDatabaseType;
import net.rptools.maptool.server.ServerConfig;
import net.rptools.maptool.server.ServerPolicy;
import net.rptools.maptool.util.ImageManager;
import net.rptools.maptool.util.MessageUtil;
import net.rptools.maptool.util.PasswordGenerator;
import net.rptools.maptool.util.PersistenceUtil;
import net.rptools.maptool.util.*;
import net.rptools.maptool.util.PersistenceUtil.PersistedCampaign;
import net.rptools.maptool.util.PersistenceUtil.PersistedMap;
import net.rptools.maptool.util.UPnPUtil;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -2532,6 +2476,8 @@ public static void disconnectFromServer() {
MapTool.stopServer();
MapTool.disconnect();
MapTool.getFrame().getToolbarPanel().getMapselect().setVisible(true);
MapTool.getFrame().getToolbarPanel().setTokenSelectionGroupEnabled(true);

try {
MapTool.startPersonalServer(campaign);
} catch (IOException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void handleDisconnect(AbstractConnection connection) {
MapTool.getFrame().getToolbarPanel().getMapselect().setVisible(true);
MapTool.getFrame().getAssetPanel().enableAssets();
new CampaignManager().clearCampaignData();

MapTool.getFrame().getToolbarPanel().setTokenSelectionGroupEnabled(true);
try {
MapTool.startPersonalServer(CampaignFactory.createBasicCampaign());
} catch (IOException
Expand Down
8 changes: 1 addition & 7 deletions src/main/java/net/rptools/maptool/client/ui/AppMenuBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,8 @@
import java.util.stream.Stream;
import javax.swing.*;
import net.rptools.lib.FileUtil;
import net.rptools.maptool.client.AppActions;
import net.rptools.maptool.client.*;
import net.rptools.maptool.client.AppActions.OpenUrlAction;
import net.rptools.maptool.client.AppConstants;
import net.rptools.maptool.client.AppSetup;
import net.rptools.maptool.client.AppState;
import net.rptools.maptool.client.AppUtil;
import net.rptools.maptool.client.MRUCampaignManager;
import net.rptools.maptool.client.MapTool;
import net.rptools.maptool.client.ui.MapToolFrame.MTFrame;
import net.rptools.maptool.client.ui.htmlframe.HTMLOverlayManager;
import net.rptools.maptool.client.ui.theme.Icons;
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/net/rptools/maptool/client/ui/ToolbarPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package net.rptools.maptool.client.ui;

import java.awt.*;
import java.util.Enumeration;
import java.util.Hashtable;
import javax.swing.*;
import javax.swing.plaf.basic.BasicToolBarUI;
Expand Down Expand Up @@ -487,6 +488,14 @@ public void setVisible(boolean visible) {
}
}

public void setTokenSelectionGroupEnabled(boolean enabled) {
Enumeration<AbstractButton> enumeration = tokenSelectionbuttonGroup.getElements();
while (enumeration.hasMoreElements()) {
AbstractButton button = enumeration.nextElement();
button.setEnabled(enabled);
}
}

private class OptionPanel extends JToolBar {

private Class<? extends Tool> firstTool;
Expand Down
20 changes: 6 additions & 14 deletions src/main/java/net/rptools/maptool/server/ClientHandshake.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.*;
import net.rptools.clientserver.simple.MessageHandler;
import net.rptools.clientserver.simple.client.ClientConnection;
import net.rptools.lib.MD5Key;
Expand All @@ -51,18 +49,8 @@
import net.rptools.maptool.model.player.Player.Role;
import net.rptools.maptool.model.player.PlayerDatabaseFactory;
import net.rptools.maptool.model.player.PlayerDatabaseFactory.PlayerDatabaseType;
import net.rptools.maptool.server.proto.AuthTypeEnum;
import net.rptools.maptool.server.proto.ClientAuthMsg;
import net.rptools.maptool.server.proto.ClientInitMsg;
import net.rptools.maptool.server.proto.ConnectionSuccessfulMsg;
import net.rptools.maptool.server.proto.HandshakeMsg;
import net.rptools.maptool.server.proto.*;
import net.rptools.maptool.server.proto.HandshakeMsg.MessageTypeCase;
import net.rptools.maptool.server.proto.HandshakeResponseCodeMsg;
import net.rptools.maptool.server.proto.PublicKeyAddedMsg;
import net.rptools.maptool.server.proto.PublicKeyUploadMsg;
import net.rptools.maptool.server.proto.RequestPublicKeyMsg;
import net.rptools.maptool.server.proto.RoleDto;
import net.rptools.maptool.server.proto.UseAuthTypeMsg;
import net.rptools.maptool.util.cipher.CipherUtil;
import net.rptools.maptool.util.cipher.CipherUtil.Key;
import net.rptools.maptool.util.cipher.PublicPrivateKeyStore;
Expand Down Expand Up @@ -337,6 +325,10 @@ private void handle(ConnectionSuccessfulMsg connectionSuccessfulMsg) throws IOEx
throw new IOException(e.getCause());
}
}
if (!policy.isUseIndividualViews()) {
MapTool.getFrame().getToolbarPanel().setTokenSelectionGroupEnabled(false);
log.info("No individual views, disabling FoW buttons");
}
var libraryManager = new LibraryManager();
for (var library : connectionSuccessfulMsg.getAddOnLibraryListDto().getLibrariesList()) {
var md5key = new MD5Key(library.getMd5Hash());
Expand Down