Skip to content

Commit

Permalink
Merge pull request #1315 from JamzTheMan/feature-token-vbl-simplifica…
Browse files Browse the repository at this point in the history
…tion

Feature token vbl simplification
  • Loading branch information
JamzTheMan authored Feb 23, 2020
2 parents a4fe35f + aecfcb2 commit 100bae2
Show file tree
Hide file tree
Showing 18 changed files with 2,098 additions and 225 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ workbench.xmi

# Keystore
build-resources/rptools-keystore
/log.html
/report.html
/output.xml
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ dependencies {

implementation 'net.rptools.decktool:decktool:1.0.b1'

implementation 'net.rptools.maptool.resource:maptool.resource:1.0.b18'
implementation 'net.rptools.maptool-resources:maptool-resources:1.4.0.1'
implementation 'com.github.RPTools:parser:1.5.5'

implementation 'jide-common:jide-common:3.2.3'
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/net/rptools/lib/io/PackedFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -603,13 +603,12 @@ public InputStream getFileAsInputStream(String path) throws IOException {
ZipEntry entry = new ZipEntry(path);
ZipFile zipFile = getZipFile();

try (InputStream in = zipFile.getInputStream(entry)) {
if (in == null) throw new FileNotFoundException(path);
String type = FileUtil.getContentType(in);
if (log.isDebugEnabled() && type != null)
log.debug("FileUtil.getContentType() returned " + type);
return in;
}
InputStream in = zipFile.getInputStream(entry);
if (in == null) throw new FileNotFoundException(path);
String type = FileUtil.getContentType(in);
if (log.isDebugEnabled() && type != null)
log.debug("FileUtil.getContentType() returned " + type);
return in;
}

public void close() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/rptools/maptool/client/AppActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
import net.rptools.maptool.client.ui.StartServerDialog;
import net.rptools.maptool.client.ui.StartServerDialogPreferences;
import net.rptools.maptool.client.ui.StaticMessageDialog;
import net.rptools.maptool.client.ui.SysInfoDialog;
import net.rptools.maptool.client.ui.assetpanel.AssetPanel;
import net.rptools.maptool.client.ui.assetpanel.Directory;
import net.rptools.maptool.client.ui.campaignproperties.CampaignPropertiesDialog;
Expand Down Expand Up @@ -116,7 +117,6 @@
import net.rptools.maptool.util.PersistenceUtil;
import net.rptools.maptool.util.PersistenceUtil.PersistedCampaign;
import net.rptools.maptool.util.PersistenceUtil.PersistedMap;
import net.rptools.maptool.util.SysInfo;
import net.rptools.maptool.util.UPnPUtil;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -2968,7 +2968,7 @@ public void run() {

@Override
protected void executeAction(java.awt.event.ActionEvent e) {
SysInfo.createAndShowGUI((String) getValue(Action.NAME));
SysInfoDialog.createAndShowGUI((String) getValue(Action.NAME));
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
import net.rptools.maptool.model.Token;
import net.rptools.maptool.model.Zone;
import net.rptools.maptool.server.ServerPolicy;
import net.rptools.maptool.util.SysInfo;
import net.rptools.maptool.util.MapToolSysInfoProvider;
import net.rptools.maptool.util.SysInfoProvider;
import net.rptools.parser.Parser;
import net.rptools.parser.ParserException;
import net.rptools.parser.function.AbstractFunction;
Expand All @@ -50,8 +51,16 @@ public class getInfoFunction extends AbstractFunction {
/** The singleton instance. */
private static final getInfoFunction instance = new getInfoFunction();

private SysInfoProvider sysInfoProvider;

private getInfoFunction() {
super(1, 1, "getInfo");
sysInfoProvider = new MapToolSysInfoProvider();
}

// the following is here mostly for testing purpose, until we find a better way to inject
protected void setSysInfoProvider(SysInfoProvider sysInfoProvider) {
this.sysInfoProvider = sysInfoProvider;
}

/**
Expand Down Expand Up @@ -212,9 +221,8 @@ private String getIsoTimeDate() {
*/
private JsonObject getServerInfo() {
ServerPolicy sp = MapTool.getServerPolicy();
JsonObject sinfo = sp.toJSON();

return (sinfo);
return sp.toJSON();
}

/**
Expand Down Expand Up @@ -342,7 +350,6 @@ private JsonObject getCampaignInfo() throws ParserException {
* @throws ParserException if an error occurs.
*/
private JsonObject getDebugInfo() throws ParserException {
SysInfo info = new SysInfo();
return info.getSysInfoJSON();
return sysInfoProvider.getSysInfoJSON();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import net.rptools.maptool.client.functions.getInfoFunction;
import net.rptools.maptool.language.I18N;
import net.rptools.maptool.model.Player;
import net.rptools.maptool.util.SysInfo;
import net.rptools.maptool.util.MapToolSysInfoProvider;
import net.rptools.parser.ParserException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -191,7 +191,7 @@ private static void reportToSentryIO(Throwable thrown) {
boolean hostingServer = MapTool.isHostingServer();
Sentry.getContext().addTag("hosting", String.valueOf(MapTool.isHostingServer()));

Sentry.getContext().addExtra("System Info", new SysInfo().getSysInfoJSON());
Sentry.getContext().addExtra("System Info", new MapToolSysInfoProvider().getSysInfoJSON());

addGetInfoToSentry("campaign");

Expand Down
102 changes: 102 additions & 0 deletions src/main/java/net/rptools/maptool/client/ui/SysInfoDialog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* This software Copyright by the RPTools.net development team, and
* licensed under the Affero GPL Version 3 or, at your option, any later
* version.
*
* MapTool Source Code is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public
* License * along with this source Code. If not, please visit
* <http://www.gnu.org/licenses/> and specifically the Affero license
* text at <http://www.gnu.org/licenses/agpl.html>.
*/
package net.rptools.maptool.client.ui;

import java.awt.*;
import java.util.List;
import java.util.concurrent.ExecutionException;
import javax.swing.*;
import net.rptools.lib.image.ImageUtil;
import net.rptools.maptool.client.MapTool;
import net.rptools.maptool.util.MapToolSysInfoProvider;
import net.rptools.maptool.util.SysInfoProvider;

/**
* Retrieves certain characteristics of the execution environment for the purposes of problem
* determination and diagnostics. This class is invoked via the Help menu, Gather Debug Info... menu
* option.
*
* @author frank
*/
public class SysInfoDialog {
private static JDialog frame;
private JTextArea infoTextArea;
private SysInfoProvider sysInfoProvider = new MapToolSysInfoProvider();

private Container createContentPane() {
JPanel contentPane = new JPanel(new BorderLayout());
contentPane.setOpaque(true);

infoTextArea = new JTextArea(5, 30);
infoTextArea.setEditable(false);
infoTextArea.setLineWrap(true);
infoTextArea.setWrapStyleWord(true);
infoTextArea.setFont(new Font("Monospaced", Font.PLAIN, 13));
infoTextArea.setText("Gathering information, please wait...");
EventQueue.invokeLater(new InfoTextSwingWorker());

JScrollPane scrollPane = new JScrollPane(infoTextArea);
scrollPane.setHorizontalScrollBarPolicy(31);
scrollPane.setVerticalScrollBarPolicy(22);
scrollPane.setViewportView(infoTextArea);

contentPane.add(scrollPane, "Center");
return contentPane;
}

private class InfoTextSwingWorker extends SwingWorker<List<String>, Void> {

@Override
protected List<String> doInBackground() {
return sysInfoProvider.getInfo();
}

@Override
protected void done() {
try {
infoTextArea.setText("");
for (String row : get()) {
infoTextArea.append(row);
}
} catch (InterruptedException ignore) {
} catch (ExecutionException e) {
MapTool.showError("Gathering Debug Information", e);
}
}
}

public static void createAndShowGUI(String title) {
if (frame != null) {
frame
.dispose(); // This is so that the memory characteristics are queried each time this frame
// is displayed.
frame = null;
}
frame = new JDialog(MapTool.getFrame(), title);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

SysInfoDialog sysInfoDialog = new SysInfoDialog();
frame.setContentPane(sysInfoDialog.createContentPane());
try {
Image img = ImageUtil.getImage("net/rptools/maptool/client/image/maptool_icon.png");
frame.setIconImage(img);
} catch (Exception ex) {
MapTool.showError("While retrieving MapTool logo image?!", ex);
}
frame.setSize(550, 640);
frame.setLocationByPlatform(true);
frame.setVisible(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ public void initVblPreviewPanel() {
updateAutoGeneratedVBL(true);
});

getJtsDistanceToleranceSpinner().setModel(new SpinnerNumberModel(10, 1, 100, 1));
getJtsDistanceToleranceSpinner().setModel(new SpinnerNumberModel(2, 0, 100, 1));
getJtsDistanceToleranceSpinner()
.addChangeListener(
e -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ public TokenVblPanel() {

@Override
public void mousePressed(MouseEvent e) {
if (e.getClickCount() == 2) {
scale = 1;
translateX = 0;
translateY = 0;
repaint();
}

startX = e.getX();
startY = e.getY();
}
Expand Down
Loading

0 comments on commit 100bae2

Please sign in to comment.