Skip to content

Commit

Permalink
Squash Develop Commits in and Prep for Rework
Browse files Browse the repository at this point in the history
  • Loading branch information
ColdAnkles committed Dec 10, 2024
1 parent a107f82 commit beaaa5f
Show file tree
Hide file tree
Showing 136 changed files with 4,736 additions and 1,825 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/copy-label-to-pr.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: Copy Labels to PR
on:
pull_request:
pull_request_target:
types: [opened]

jobs:
copy-labels:
permissions:
contents: read
issues: write
issues: read
pull-requests: write
runs-on: ubuntu-latest
name: Copy labels from linked issues
steps:
- name: copy-labels
uses: michalvankodev/copy-issue-labels@v1.2.1
uses: michalvankodev/copy-issue-labels@v1.3.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
labels-to-include: |
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,8 @@ dependencies {
implementation 'com.github.jknack:handlebars:4.3.1'
implementation 'com.github.jknack:handlebars-helpers:4.3.1'

implementation 'org.jgrapht:jgrapht-core:1.5.2'


// Built In Add-on Libraries
implementation 'com.github.RPTools:maptool-builtin-addons:1.3'
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/shared.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spotless {
licenseHeaderFile rootProject.file('spotless.license.java')
toggleOffOn()
// Now using the Google Java style guide
googleJavaFormat("1.17.0")
googleJavaFormat("1.24.0")
}

format 'misc', {
Expand Down
2 changes: 1 addition & 1 deletion clientserver/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies {
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1' // https://mvnrepository.com/artifact/com.google.code.gson/gson

// webrtc
implementation group: 'org.java-websocket', name: 'Java-WebSocket', version: '1.5.6'
implementation group: 'org.java-websocket', name: 'Java-WebSocket', version: '1.5.7'
// Needs to be API since WebRTCConnection implements PeerConnectionObserver and RTCDataChannelObserver.
implementation 'dev.onvoid.webrtc:webrtc-java:0.8.0'
if (osdetector.os.is('windows'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public Object childEvaluate(
return switch (diceName) {
case "sw" -> new GenesysDiceRolls().roll(DiceType.StarWars, diceExpression, resolver);
case "gs" -> new GenesysDiceRolls().roll(DiceType.Genesys, diceExpression, resolver);
default -> throw new ParserException(
I18N.getText("advanced.roll.unknownDiceType", diceName));
default ->
throw new ParserException(I18N.getText("advanced.roll.unknownDiceType", diceName));
};
} catch (IllegalArgumentException e) {
throw new ParserException(e.getMessage());
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/net/rptools/lib/CodeTimer.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ public static <Ex extends Exception> void using(String name, TimedSection<Ex> ca

stack.addLast(timer);
try {
timer.start("<root>");
callback.call(timer);
} finally {
timer.stop("<root>");

final var lastTimer = stack.removeLast();
assert lastTimer == timer : "Timer stack is corrupted";

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/rptools/lib/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import net.rptools.maptool.client.ui.token.BarTokenOverlay;
import net.rptools.maptool.model.AStarCellPointConverter;
import net.rptools.maptool.model.ShapeType;
import net.rptools.maptool.model.converters.WallTopologyConverter;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -484,6 +485,7 @@ public static XStream getConfiguredXStream() {
XStream.setupDefaultSecurity(xStream);
xStream.allowTypesByWildcard(new String[] {"net.rptools.**", "java.awt.**", "sun.awt.**"});
xStream.registerConverter(new AStarCellPointConverter());
xStream.registerConverter(new WallTopologyConverter(xStream));
xStream.addImmutableType(ShapeType.class, true);
xStream.addImmutableType(BarTokenOverlay.Side.class, true);
return xStream;
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/net/rptools/lib/GeometryUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,12 @@ public static Collection<Polygon> toJtsPolygons(Area area) {

return toPolygonizer(area).getPolygons();
}

public static Point2D coordinateToPoint2D(Coordinate coordinate) {
return new Point2D.Double(coordinate.getX(), coordinate.getY());
}

public static Coordinate point2DToCoordinate(Point2D point2D) {
return new Coordinate(point2D.getX(), point2D.getY());
}
}
44 changes: 42 additions & 2 deletions src/main/java/net/rptools/maptool/client/AppActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -1898,6 +1898,46 @@ protected void executeAction() {
}
};

public static final Action TOGGLE_LANDING_MAP =
new ZoneAdminClientAction() {

{
init("action.toggleLandingMap");
}

@Override
public boolean isSelected() {
ZoneRenderer renderer = MapTool.getFrame().getCurrentZoneRenderer();
if (renderer == null) {
return false;
}

var landingMapId = MapTool.getCampaign().getLandingMapId();
if (landingMapId == null) {
return false;
}

return landingMapId.equals(renderer.getZone().getId());
}

@Override
protected void executeAction() {
ZoneRenderer renderer = MapTool.getFrame().getCurrentZoneRenderer();
if (renderer == null) {
return;
}

var landingMapId = MapTool.getCampaign().getLandingMapId();

var newLandingMapId = renderer.getZone().getId();
if (newLandingMapId.equals(landingMapId)) {
// Already set. Unset it instead.
newLandingMapId = null;
}
MapTool.serverCommand().setLandingMap(newLandingMapId);
}
};

public static final Action TOGGLE_CURRENT_ZONE_VISIBILITY =
new ZoneAdminClientAction() {

Expand Down Expand Up @@ -1977,7 +2017,7 @@ protected void executeAction() {

Campaign campaign = CampaignFactory.createBasicCampaign();
AppState.setCampaignFile(null);
MapTool.setCampaign(campaign);
MapTool.setCampaign(campaign, null);
MapTool.serverCommand().setCampaign(campaign);

ImageManager.flush();
Expand Down Expand Up @@ -2338,7 +2378,7 @@ protected void executeAction() {
// Install a temporary gimped campaign until we get the one from the
// server
final Campaign oldCampaign = MapTool.getCampaign();
MapTool.setCampaign(new Campaign());
MapTool.setCampaign(new Campaign(), null);

// connecting
MapTool.getFrame()
Expand Down
52 changes: 38 additions & 14 deletions src/main/java/net/rptools/maptool/client/AppStatePersisted.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.prefs.Preferences;
import java.util.stream.Collectors;
import net.rptools.maptool.model.Zone;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -65,6 +67,9 @@ public class AppStatePersisted {
/** Represents the key used to save the paint textures to the preferences. */
private static final String KEY_SAVED_PAINT_TEXTURES = "savedTextures";

/** Will be null until read from preferences. */
private static EnumSet<Zone.TopologyType> topologyTypes = null;

public static void clearAssetRoots() {
prefs.put(KEY_ASSET_ROOTS, "");
}
Expand Down Expand Up @@ -167,38 +172,57 @@ public static List<File> getMruCampaigns() {
return mruCampaigns;
}

public static Zone.TopologyTypeSet getTopologyTypes() {
private static EnumSet<Zone.TopologyType> readTopologyTypes() {
try {
String typeNames = prefs.get(KEY_TOPOLOGY_TYPES, "");
if ("".equals(typeNames)) {
// Fallback to the key used prior to the introduction of various VBL types.
String oldDrawingMode = prefs.get(KEY_OLD_TOPOLOGY_DRAWING_MODE, DEFAULT_TOPOLOGY_TYPE);
return switch (oldDrawingMode) {
case "VBL" -> new Zone.TopologyTypeSet(Zone.TopologyType.WALL_VBL);
case "MBL" -> new Zone.TopologyTypeSet(Zone.TopologyType.MBL);
case "COMBINED" -> new Zone.TopologyTypeSet(
Zone.TopologyType.WALL_VBL, Zone.TopologyType.MBL);
default -> new Zone.TopologyTypeSet(Zone.TopologyType.WALL_VBL);
case "VBL" -> EnumSet.of(Zone.TopologyType.WALL_VBL);
case "MBL" -> EnumSet.of(Zone.TopologyType.MBL);
case "COMBINED" -> EnumSet.of(Zone.TopologyType.WALL_VBL, Zone.TopologyType.MBL);
default -> EnumSet.of(Zone.TopologyType.WALL_VBL);
};
} else {
return Zone.TopologyTypeSet.valueOf(typeNames);
var result = EnumSet.noneOf(Zone.TopologyType.class);
for (var topologyType : Zone.TopologyType.values()) {
if (typeNames.contains(topologyType.name())) {
result.add(topologyType);
}
}
return result;
}
} catch (Exception exc) {
return new Zone.TopologyTypeSet(Zone.TopologyType.WALL_VBL);
return EnumSet.of(Zone.TopologyType.WALL_VBL);
}
}

private static void writeTopologyTypes(Set<Zone.TopologyType> types) {
String joined = types.stream().map(Enum::name).collect(Collectors.joining(",", "[", "]"));
prefs.put(KEY_TOPOLOGY_TYPES, joined);
}

public static Set<Zone.TopologyType> getTopologyTypes() {
if (topologyTypes == null) {
topologyTypes = readTopologyTypes();
}
return topologyTypes;
}

/**
* Sets the selected topology modes.
*
* @param types the topology types. A value of null resets to default.
* @param types the topology types.
*/
public static void setTopologyTypes(Zone.TopologyTypeSet types) {
if (types == null) {
prefs.remove(KEY_TOPOLOGY_TYPES);
} else {
prefs.put(KEY_TOPOLOGY_TYPES, types.toString());
public static void setTopologyTypes(Set<Zone.TopologyType> types) {
if (topologyTypes == null) {
topologyTypes = EnumSet.noneOf(Zone.TopologyType.class);
}
topologyTypes.clear();
topologyTypes.addAll(types);

writeTopologyTypes(topologyTypes);
}

public static void setSavedPaintTextures(List<File> savedTextures) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/net/rptools/maptool/client/AppStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public class AppStyle {
public static Color selectionBoxFill = Color.blue;
public static Color resizeBoxOutline = Color.red;
public static Color resizeBoxFill = Color.yellow;
public static Color wallTopologyColor = new Color(255, 182, 0, 255);
public static Color wallTopologyOutlineColor = Color.black;
public static Color selectedWallTopologyColor = new Color(255, 136, 0, 255);
public static Color topologyColor = new Color(0, 0, 255, 128);
public static Color topologyAddColor = new Color(255, 0, 0, 128);
public static Color topologyRemoveColor = new Color(255, 255, 255, 128);
Expand Down
40 changes: 32 additions & 8 deletions src/main/java/net/rptools/maptool/client/ClientMessageHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import net.rptools.maptool.model.library.addon.AddOnLibraryImporter;
import net.rptools.maptool.model.library.addon.TransferableAddOnLibrary;
import net.rptools.maptool.model.player.Player;
import net.rptools.maptool.model.topology.WallTopology;
import net.rptools.maptool.model.zones.TokensAdded;
import net.rptools.maptool.model.zones.TokensRemoved;
import net.rptools.maptool.model.zones.ZoneAdded;
Expand Down Expand Up @@ -101,7 +102,7 @@ public void handleMessage(String id, byte[] message) {
log.debug("{} got: {}", id, msgType);

switch (msgType) {
case UPDATE_TOPOLOGY_MSG -> handle(msg.getUpdateTopologyMsg());
case UPDATE_MASK_TOPOLOGY_MSG -> handle(msg.getUpdateMaskTopologyMsg());
case BOOT_PLAYER_MSG -> handle(msg.getBootPlayerMsg());
case CHANGE_ZONE_DISPLAY_NAME_MSG -> handle(msg.getChangeZoneDisplayNameMsg());
case CLEAR_ALL_DRAWINGS_MSG -> handle(msg.getClearAllDrawingsMsg());
Expand Down Expand Up @@ -134,6 +135,7 @@ public void handleMessage(String id, byte[] message) {
case SET_BOARD_MSG -> handle(msg.getSetBoardMsg());
case SET_CAMPAIGN_MSG -> handle(msg.getSetCampaignMsg());
case SET_CAMPAIGN_NAME_MSG -> handle(msg.getSetCampaignNameMsg());
case SET_CAMPAIGN_LANDING_MAP_MSG -> handle(msg.getSetCampaignLandingMapMsg());
case SET_FOW_MSG -> handle(msg.getSetFowMsg());
case SET_LIVE_TYPING_LABEL_MSG -> handle(msg.getSetLiveTypingLabelMsg());
case SET_TOKEN_LOCATION_MSG -> handle(msg.getSetTokenLocationMsg());
Expand Down Expand Up @@ -168,6 +170,7 @@ public void handleMessage(String id, byte[] message) {
case UPDATE_EXPOSED_AREA_META_MSG -> handle(msg.getUpdateExposedAreaMetaMsg());
case UPDATE_TOKEN_MOVE_MSG -> handle(msg.getUpdateTokenMoveMsg());
case UPDATE_PLAYER_STATUS_MSG -> handle(msg.getUpdatePlayerStatusMsg());
case SET_WALL_TOPOLOGY_MSG -> handle(msg.getSetWallTopologyMsg());
default -> log.warn(msgType + "not handled.");
}
log.debug(id + " handled: " + msgType);
Expand Down Expand Up @@ -638,11 +641,22 @@ private void handle(SetCampaignNameMsg msg) {
});
}

private void handle(SetCampaignLandingMapMsg msg) {
EventQueue.invokeLater(
() -> {
if (msg.hasLandingMapId()) {
client.getCampaign().setLandingMapId(GUID.valueOf(msg.getLandingMapId()));
} else {
client.getCampaign().setLandingMapId(null);
}
});
}

private void handle(SetCampaignMsg msg) {
EventQueue.invokeLater(
() -> {
Campaign campaign = Campaign.fromDto(msg.getCampaign());
MapTool.setCampaign(campaign);
MapTool.setCampaign(campaign, null);

// Hide the "Connecting" overlay
MapTool.getFrame().hideGlassPane();
Expand Down Expand Up @@ -1003,16 +1017,16 @@ private void handle(ChangeZoneDisplayNameMsg changeZoneDisplayNameMsg) {
});
}

private void handle(UpdateTopologyMsg updateTopologyMsg) {
private void handle(UpdateMaskTopologyMsg updateMaskTopologyMsg) {
EventQueue.invokeLater(
() -> {
var zoneGUID = GUID.valueOf(updateTopologyMsg.getZoneGuid());
var area = Mapper.map(updateTopologyMsg.getArea());
var erase = updateTopologyMsg.getErase();
var topologyType = Zone.TopologyType.valueOf(updateTopologyMsg.getType().name());
var zoneGUID = GUID.valueOf(updateMaskTopologyMsg.getZoneGuid());
var area = Mapper.map(updateMaskTopologyMsg.getArea());
var erase = updateMaskTopologyMsg.getErase();
var topologyType = Zone.TopologyType.valueOf(updateMaskTopologyMsg.getType().name());

var zone = client.getCampaign().getZone(zoneGUID);
zone.updateTopology(area, erase, topologyType);
zone.updateMaskTopology(area, erase, topologyType);
});
}

Expand Down Expand Up @@ -1048,4 +1062,14 @@ private void handle(UpdatePlayerStatusMsg updatePlayerStatusMsg) {
final var eventBus = new MapToolEventBus().getMainEventBus();
eventBus.post(new PlayerStatusChanged(player));
}

private void handle(SetWallTopologyMsg setWallTopologyMsg) {
EventQueue.invokeLater(
() -> {
var zoneId = new GUID(setWallTopologyMsg.getZoneGuid());
var zone = client.getCampaign().getZone(zoneId);
var topology = WallTopology.fromDto(setWallTopologyMsg.getTopology());
zone.replaceWalls(topology);
});
}
}
Loading

0 comments on commit beaaa5f

Please sign in to comment.