Skip to content

Commit

Permalink
Revert "Merge branch 'feature-mbl' of https://github.com/RPTools/maptool
Browse files Browse the repository at this point in the history
 into develop"

This reverts commit fd65dea, reversing
changes made to 80af7b2.
  • Loading branch information
Phergus committed Feb 2, 2020
1 parent 3d9a332 commit 7f7c5dc
Show file tree
Hide file tree
Showing 26 changed files with 384 additions and 434 deletions.
53 changes: 20 additions & 33 deletions src/main/java/net/rptools/maptool/client/AppPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@
import net.rptools.maptool.model.GridFactory;
import net.rptools.maptool.model.Token;
import net.rptools.maptool.model.Zone;
import net.rptools.maptool.model.Zone.TopologyMode;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class AppPreferences {

private static final Logger log = LogManager.getLogger(AppPreferences.class);
private static Preferences prefs = Preferences.userRoot().node(AppConstants.APP_NAME + "/prefs");

Expand Down Expand Up @@ -177,15 +175,9 @@ public class AppPreferences {
private static final String KEY_USE_ASTAR_PATHFINDING = "useAstarPathfinding";
private static final boolean DEFAULT_USE_ASTAR_PATHFINDING = true;

private static final String KEY_VBL_BLOCKS_MOVE = "vblBlocksMove";
private static final boolean DEFAULT_VBL_BLOCKS_MOVE = true;

private static final String MACRO_EDITOR_THEME = "macroEditorTheme";
private static final String DEFAULT_MACRO_EDITOR_THEME = "default";

private static final String KEY_TOPOLOGY_DRAWING_MODE = "topologyDrawingMode";
private static final String DEFAULT_TOPOLOGY_DRAWING_MODE = "VBL";

public static void setFillSelectionBox(boolean fill) {
prefs.putBoolean(KEY_FILL_SELECTION_BOX, fill);
}
Expand Down Expand Up @@ -1029,9 +1021,8 @@ public static void setMruCampaigns(List<File> mruCampaigns) {
path = file.getCanonicalPath();
} catch (IOException e) {
// Probably pretty rare, but we want to know about it
if (log.isInfoEnabled()) {
if (log.isInfoEnabled())
log.info("unexpected during file.getCanonicalPath()", e); // $NON-NLS-1$
}
path = file.getPath();
}
// It's important that '%3A' is done last. Note that the pathSeparator may not be a colon on
Expand All @@ -1051,9 +1042,7 @@ public static List<File> getMruCampaigns() {
// It's important that '%3A' is done first
combined = combined.replaceAll("%3A", File.pathSeparator).replaceAll("%25", "%");
String[] all = combined.split(File.pathSeparator);
for (int i = 0; i < all.length; i++) {
mruCampaigns.add(new File(all[i]));
}
for (int i = 0; i < all.length; i++) mruCampaigns.add(new File(all[i]));
}
return mruCampaigns;
}
Expand All @@ -1072,13 +1061,20 @@ public static List<File> getSavedPaintTextures() {
String combined = prefs.get(KEY_SAVED_PAINT_TEXTURES, null);
if (combined != null) {
String[] all = combined.split(File.pathSeparator);
for (int i = 0; i < all.length; i++) {
savedTextures.add(new File(all[i]));
}
for (int i = 0; i < all.length; i++) savedTextures.add(new File(all[i]));
}
return savedTextures;
}

// Jamz: Disabling Initiative Panel server sync prevents panel updates to other clients.
// Effectively, only the GM now has access to the initiative panel. This greatly increases
// performance and
// prevents the updates from getting out of sync as they can today.
// Note: This is a HACK to fix a broken system, but we're not going to invest anymore time into
// the current classes. REWRITE ME!
// private static final String INIT_ENABLE_SERVER_SYNC = "initEnableServerSync";
// private static final boolean DEFAULT_INIT_ENABLE_SERVER_SYNC = true;

private static final String INIT_SHOW_TOKENS = "initShowTokens";
private static final boolean DEFAULT_INIT_SHOW_TOKENS = true;

Expand All @@ -1100,6 +1096,14 @@ public static List<File> getSavedPaintTextures() {
private static final String INIT_LOCK_MOVEMENT = "initLockMovement";
private static final boolean DEFAULT_INIT_LOCK_MOVEMENT = false;

// public static boolean getInitEnableServerSync() {
// return prefs.getBoolean(INIT_ENABLE_SERVER_SYNC, DEFAULT_INIT_ENABLE_SERVER_SYNC);
// }
//
// public static void setInitEnableServerSync(boolean enableSync) {
// prefs.putBoolean(INIT_ENABLE_SERVER_SYNC, enableSync);
// }

public static boolean getInitShowTokens() {
return prefs.getBoolean(INIT_SHOW_TOKENS, DEFAULT_INIT_SHOW_TOKENS);
}
Expand Down Expand Up @@ -1184,28 +1188,11 @@ public static void setUseAstarPathfinding(boolean show) {
prefs.putBoolean(KEY_USE_ASTAR_PATHFINDING, show);
}

public static boolean getVblBlocksMove() {
return prefs.getBoolean(KEY_VBL_BLOCKS_MOVE, DEFAULT_VBL_BLOCKS_MOVE);
}

public static void setVblBlocksMove(boolean use) {
prefs.putBoolean(KEY_VBL_BLOCKS_MOVE, use);
}

public static String getDefaultMacroEditorTheme() {
return prefs.get(MACRO_EDITOR_THEME, DEFAULT_MACRO_EDITOR_THEME);
}

public static void setDefaultMacroEditorTheme(String type) {
prefs.put(MACRO_EDITOR_THEME, type);
}

public static TopologyMode getTopologyDrawingMode() {
return TopologyMode.valueOf(
prefs.get(KEY_TOPOLOGY_DRAWING_MODE, DEFAULT_TOPOLOGY_DRAWING_MODE));
}

public static void setTopologyDrawingMode(TopologyMode mode) {
prefs.put(KEY_TOPOLOGY_DRAWING_MODE, mode.toString());
}
}
4 changes: 0 additions & 4 deletions src/main/java/net/rptools/maptool/client/AppStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ public class AppStyle {
public static Color topologyAddColor = new Color(255, 0, 0, 128);
public static Color topologyRemoveColor = new Color(255, 255, 255, 128);

public static Color topologyTerrainColor = new Color(255, 0, 255, 128);
public static Color topologyTerrainAddColor = new Color(255, 0, 0, 128);
public static Color topologyTerrainRemoveColor = new Color(255, 255, 255, 128);

public static Color tokenTopologyColor = new Color(255, 255, 0, 128);
public static Color tokenTopologyAddColor = new Color(255, 0, 0, 128);
public static Color tokenTopologyRemoveColor = new Color(255, 255, 255, 128);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.awt.Point;
import java.awt.geom.Area;
import java.io.IOException;
import java.lang.reflect.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -47,7 +48,6 @@
import net.rptools.maptool.model.TextMessage;
import net.rptools.maptool.model.Token;
import net.rptools.maptool.model.Zone;
import net.rptools.maptool.model.Zone.TopologyMode;
import net.rptools.maptool.model.Zone.VisionType;
import net.rptools.maptool.model.ZonePoint;
import net.rptools.maptool.model.drawing.Drawable;
Expand Down Expand Up @@ -485,21 +485,19 @@ public void run() {
case addTopology:
zoneGUID = (GUID) parameters[0];
area = (Area) parameters[1];
TopologyMode topologyMode = (TopologyMode) parameters[2];

zone = MapTool.getCampaign().getZone(zoneGUID);
zone.addTopology(area, topologyMode);
zone.addTopology(area);

MapTool.getFrame().getZoneRenderer(zoneGUID).repaint();
return;

case removeTopology:
zoneGUID = (GUID) parameters[0];
area = (Area) parameters[1];
topologyMode = (TopologyMode) parameters[2];

zone = MapTool.getCampaign().getZone(zoneGUID);
zone.removeTopology(area, topologyMode);
zone.removeTopology(area);

MapTool.getFrame().getZoneRenderer(zoneGUID).repaint();
return;
Expand Down
29 changes: 10 additions & 19 deletions src/main/java/net/rptools/maptool/client/MapTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public static void showMessage(
* window (formatted using <code>params</code>)
* @param messageType one of <code>JOptionPane.ERROR_MESSAGE</code>, <code>
* JOptionPane.WARNING_MESSAGE</code>, <code>JOptionPane.INFORMATION_MESSAGE
* </code>
* </code>
* @param params optional parameters to use when formatting the title text from the properties
* file
*/
Expand Down Expand Up @@ -1341,18 +1341,6 @@ private static void postInitialize() {
// Jamz: After preferences are loaded, Asset Tree and ImagePanel are out of sync,
// so after frame is all done loading we sync them back up.
MapTool.getFrame().getAssetPanel().getAssetTree().initialize();

// Set the Topology drawing mode to the last mode used for convenience
MapTool.getFrame()
.getCurrentZoneRenderer()
.getZone()
.setTopologyMode(AppPreferences.getTopologyDrawingMode());

// Set the Topology drawing mode to the last mode used for convenience
MapTool.getFrame()
.getCurrentZoneRenderer()
.getZone()
.setTopologyMode(AppPreferences.getTopologyDrawingMode());
}

/**
Expand Down Expand Up @@ -1446,12 +1434,13 @@ public void run() {
*
* <p>Examples: -version=1.4.0.1 -user=Jamz
*
* @param cmd {@link org.apache.commons.cli.Options}
* @param options {@link org.apache.commons.cli.Options}
* @param searchValue Option string to search for, ie -version
* @param defaultValue A default value to return if option is not found
* @param args String array of passed in args
* @return Option value found as a String, or defaultValue if not found
* @author Jamz
* @since 1.5.12
* @since 1.4.0.1
*/
private static String getCommandLineOption(
CommandLine cmd, String searchValue, String defaultValue) {
Expand All @@ -1463,11 +1452,12 @@ private static String getCommandLineOption(
*
* <p>Examples: -x or -fullscreen
*
* @param cmd {@link org.apache.commons.cli.Options}
* @param options {@link org.apache.commons.cli.Options}
* @param searchValue Option string to search for, ie -version
* @param args String array of passed in args
* @return A boolean value of true if option parameter found
* @author Jamz
* @since 1.5.12
* @since 1.4.0.1
*/
private static boolean getCommandLineOption(CommandLine cmd, String searchValue) {
return cmd.hasOption(searchValue);
Expand All @@ -1479,12 +1469,13 @@ private static boolean getCommandLineOption(CommandLine cmd, String searchValue)
*
* <p>Examples: -monitor=1 -x=0 -y=0 -w=1200 -h=960
*
* @param cmd {@link org.apache.commons.cli.Options}
* @param options {@link org.apache.commons.cli.Options}
* @param searchValue Option string to search for, ie -version
* @param defaultValue A default value to return if option is not found
* @param args String array of passed in args
* @return Int value of the matching option parameter if found
* @author Jamz
* @since 1.5.12
* @since 1.4.0.1
*/
private static int getCommandLineOption(CommandLine cmd, String searchValue, int defaultValue) {
return StringUtil.parseInteger(cmd.getOptionValue(searchValue), defaultValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import net.rptools.maptool.model.TextMessage;
import net.rptools.maptool.model.Token;
import net.rptools.maptool.model.Zone;
import net.rptools.maptool.model.Zone.TopologyMode;
import net.rptools.maptool.model.Zone.VisionType;
import net.rptools.maptool.model.ZonePoint;
import net.rptools.maptool.model.drawing.Drawable;
Expand Down Expand Up @@ -262,12 +261,12 @@ public void toggleTokenMoveWaypoint(GUID zoneGUID, GUID tokenGUID, ZonePoint cp)
makeServerCall(COMMAND.toggleTokenMoveWaypoint, zoneGUID, tokenGUID, cp);
}

public void addTopology(GUID zoneGUID, Area area, TopologyMode topologyMode) {
makeServerCall(COMMAND.addTopology, zoneGUID, area, topologyMode);
public void addTopology(GUID zoneGUID, Area area) {
makeServerCall(COMMAND.addTopology, zoneGUID, area);
}

public void removeTopology(GUID zoneGUID, Area area, TopologyMode topologyMode) {
makeServerCall(COMMAND.removeTopology, zoneGUID, area, topologyMode);
public void removeTopology(GUID zoneGUID, Area area) {
makeServerCall(COMMAND.removeTopology, zoneGUID, area);
}

public void exposePCArea(GUID zoneGUID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.List;
import net.rptools.lib.swing.ColorPicker;
import net.rptools.lib.swing.SwingUtil;
import net.rptools.maptool.client.AppStyle;
import net.rptools.maptool.client.MapTool;
import net.rptools.maptool.client.MapToolUtil;
import net.rptools.maptool.client.ScreenPoint;
Expand All @@ -42,13 +41,10 @@
import net.rptools.maptool.model.Zone.Layer;
import net.rptools.maptool.model.ZonePoint;
import net.rptools.maptool.model.drawing.Drawable;
import net.rptools.maptool.model.drawing.DrawableColorPaint;
import net.rptools.maptool.model.drawing.Pen;
import net.rptools.maptool.model.drawing.ShapeDrawable;

/** Tool for drawing freehand lines. */
public abstract class AbstractDrawingTool extends DefaultTool implements ZoneOverlay {

private static final long serialVersionUID = 9121558405484986225L;

private boolean isEraser;
Expand Down Expand Up @@ -255,78 +251,6 @@ protected Area getTokenTopology() {
@Override
public abstract void paintOverlay(ZoneRenderer renderer, Graphics2D g);

protected void paintTopologyOverlay(Graphics2D g, Drawable drawable) {
paintTopologyOverlay(g, drawable, Pen.MODE_SOLID);
}

protected void paintTopologyOverlay(Graphics2D g, Shape shape) {
ShapeDrawable drawable = null;

if (shape != null) {
drawable = new ShapeDrawable(shape, false);
}

paintTopologyOverlay(g, drawable, Pen.MODE_SOLID);
}

protected void paintTopologyOverlay(Graphics2D g, Shape shape, int penMode) {
ShapeDrawable drawable = null;

if (shape != null) {
drawable = new ShapeDrawable(shape, false);
}

paintTopologyOverlay(g, drawable, penMode);
}

protected void paintTopologyOverlay(Graphics2D g) {
Rectangle rectangle = null;
paintTopologyOverlay(g, rectangle, Pen.MODE_SOLID);
}

protected void paintTopologyOverlay(Graphics2D g, Drawable drawable, int penMode) {
if (MapTool.getPlayer().isGM()) {
Zone zone = renderer.getZone();
Area topology = zone.getTopology();

Graphics2D g2 = (Graphics2D) g.create();
g2.translate(renderer.getViewOffsetX(), renderer.getViewOffsetY());
g2.scale(renderer.getScale(), renderer.getScale());

g2.setColor(AppStyle.tokenTopologyColor);
g2.fill(getTokenTopology());

g2.setColor(AppStyle.topologyTerrainColor);
g2.fill(zone.getTopologyTerrain());

g2.setColor(AppStyle.topologyColor);
g2.fill(topology);

g2.dispose();
}

if (drawable != null) {
Pen pen = new Pen();
pen.setEraser(getPen().isEraser());
pen.setOpacity(AppStyle.topologyRemoveColor.getAlpha() / 255.0f);
pen.setBackgroundMode(penMode);

if (penMode == Pen.MODE_TRANSPARENT) {
pen.setThickness(3.0f);
}

if (pen.isEraser()) {
pen.setEraser(false);
}
if (isEraser()) {
pen.setBackgroundPaint(new DrawableColorPaint(AppStyle.topologyRemoveColor));
} else {
pen.setBackgroundPaint(new DrawableColorPaint(AppStyle.topologyAddColor));
}
paintTransformed(g, renderer, drawable, pen);
}
}

/**
* Render a drawable on a zone. This method consolidates all of the calls to the server in one
* place so that it is easier to keep them in sync.
Expand All @@ -339,15 +263,10 @@ protected void completeDrawable(GUID zoneId, Pen pen, Drawable drawable) {
if (!hasPaint(pen)) {
return;
}
if (drawable.getBounds() == null) {
return;
}
if (drawable.getBounds() == null) return;
drawable.setLayer(selectedLayer);
if (MapTool.getPlayer().isGM()) {
drawable.setLayer(selectedLayer);
} else {
drawable.setLayer(Layer.TOKEN);
}
if (MapTool.getPlayer().isGM()) drawable.setLayer(selectedLayer);
else drawable.setLayer(Layer.TOKEN);

// Send new textures
MapToolUtil.uploadTexture(pen.getPaint());
Expand Down
Loading

0 comments on commit 7f7c5dc

Please sign in to comment.