diff --git a/src/main/java/net/rptools/maptool/client/ui/campaignproperties/CampaignPropertiesDialogView.form b/src/main/java/net/rptools/maptool/client/ui/campaignproperties/CampaignPropertiesDialogView.form index 511ec13c1a..1ff21921e7 100644 --- a/src/main/java/net/rptools/maptool/client/ui/campaignproperties/CampaignPropertiesDialogView.form +++ b/src/main/java/net/rptools/maptool/client/ui/campaignproperties/CampaignPropertiesDialogView.form @@ -3,7 +3,7 @@ - + @@ -953,7 +953,9 @@ - + + + diff --git a/src/main/java/net/rptools/maptool/client/ui/campaignproperties/CampaignPropertiesDialogView.java b/src/main/java/net/rptools/maptool/client/ui/campaignproperties/CampaignPropertiesDialogView.java index f5dd60e779..1d910d7108 100644 --- a/src/main/java/net/rptools/maptool/client/ui/campaignproperties/CampaignPropertiesDialogView.java +++ b/src/main/java/net/rptools/maptool/client/ui/campaignproperties/CampaignPropertiesDialogView.java @@ -18,6 +18,7 @@ import javax.swing.*; public class CampaignPropertiesDialogView { + private JPanel mainPanel; public JComponent getRootComponent() { diff --git a/src/main/java/net/rptools/maptool/client/ui/campaignproperties/TokenBarController.java b/src/main/java/net/rptools/maptool/client/ui/campaignproperties/TokenBarController.java index 321237c99a..9e1350cbe2 100644 --- a/src/main/java/net/rptools/maptool/client/ui/campaignproperties/TokenBarController.java +++ b/src/main/java/net/rptools/maptool/client/ui/campaignproperties/TokenBarController.java @@ -25,6 +25,7 @@ import java.awt.image.BufferedImage; import java.io.File; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; @@ -219,20 +220,48 @@ public class TokenBarController new String[0], // Two Tone }; - private static final List types = - List.of( - "CampaignPropertiesDialog.combo.bars.type.twoImages", - "CampaignPropertiesDialog.combo.bars.type.singleImage", - "CampaignPropertiesDialog.combo.bars.type.multipleImages", - "CampaignPropertiesDialog.combo.bars.type.solid", - "CampaignPropertiesDialog.combo.bars.type.twoTone"); - - private static final List sides = - List.of( - "CampaignPropertiesDialog.combo.bars.side.top", - "CampaignPropertiesDialog.combo.bars.type.bottom", - "CampaignPropertiesDialog.combo.bars.type.left", - "CampaignPropertiesDialog.combo.bars.type.right"); + enum BarType { + TWO_IMAGE("CampaignPropertiesDialog.combo.bars.type.twoImages"), + ONE_IMAGE("CampaignPropertiesDialog.combo.bars.type.singleImage"), + MULTIPLE_IMAGE("CampaignPropertiesDialog.combo.bars.type.multipleImages"), + SOLID("CampaignPropertiesDialog.combo.bars.type.solid"), + TWO_TONE("CampaignPropertiesDialog.combo.bars.type.twoTone"); + + private final String i18nKey; + + BarType(String i18nKey) { + this.i18nKey = i18nKey; + } + + @Override + public String toString() { + return I18N.getText(i18nKey); + } + } + + enum BarSide { + TOP("CampaignPropertiesDialog.combo.bars.side.top", Side.TOP), + BOTTOM("CampaignPropertiesDialog.combo.bars.type.bottom", Side.BOTTOM), + LEFT("CampaignPropertiesDialog.combo.bars.type.left", Side.LEFT), + RIGHT("CampaignPropertiesDialog.combo.bars.type.right", Side.RIGHT); + + private final String i18nKey; + private final Side side; + + BarSide(String i18nKey, Side side) { + this.i18nKey = i18nKey; + this.side = side; + } + + public Side getSide() { + return side; + } + + @Override + public String toString() { + return I18N.getText(i18nKey); + } + } /** * Set up the button listeners, spinner models, list cell renderer and selection listeners @@ -253,17 +282,13 @@ public TokenBarController(AbeillePanel panel) { panel.getButton(IMAGE_MOVE_DOWN).addActionListener(this); var typeComboBox = panel.getComboBox(TYPE); - typeComboBox.setModel(new DefaultComboBoxModel()); - for (var type : types) { - typeComboBox.addItem(I18N.getText(type)); - } + typeComboBox.setModel(new DefaultComboBoxModel()); + Arrays.stream(BarType.values()).forEach(typeComboBox::addItem); typeComboBox.addActionListener(this); var sideComboBox = panel.getComboBox(SIDE); - sideComboBox.setModel(new DefaultComboBoxModel()); - for (var side : sides) { - sideComboBox.addItem(I18N.getText(side)); - } + sideComboBox.setModel(new DefaultComboBoxModel()); + Arrays.stream(BarSide.values()).forEach(sideComboBox::addItem); panel.getSpinner(THICKNESS).setModel(new SpinnerNumberModel(5, 2, 10, 1)); panel.getSpinner(INCREMENTS).setModel(new SpinnerNumberModel(0, 0, 100, 1)); @@ -271,6 +296,7 @@ public TokenBarController(AbeillePanel panel) { panel.getSpinner(OPACITY).setModel(new SpinnerNumberModel(100, 1, 100, 5)); panel.getList(BARS).setCellRenderer(renderer); panel.getList(BARS).addListSelectionListener(this); + panel.getList(IMAGES).setModel(new DefaultListModel()); panel.getList(IMAGES).setCellRenderer(new ImageListRenderer()); panel.getList(IMAGES).addListSelectionListener(this); panel.getTextComponent(NAME).getDocument().addDocumentListener(this); @@ -730,20 +756,23 @@ public BarTokenOverlay createTokenOverlay(BarTokenOverlay updatedOverlay) { Color bgColor = ((ColorWell) formPanel.getComponent(BG_COLOR)).getColor(); String name = formPanel.getTextComponent(NAME).getText(); boolean mouseover = formPanel.getCheckBox(MOUSEOVER).isSelected(); - String overlay = ((String) formPanel.getComboBox(TYPE).getSelectedItem()); + var overlay = ((BarType) formPanel.getComboBox(TYPE).getSelectedItem()); int opacity = TokenStatesController.getSpinner(OPACITY, "opacity", formPanel); boolean showGM = formPanel.getCheckBox(SHOW_GM).isSelected(); boolean showOwner = formPanel.getCheckBox(SHOW_OWNER).isSelected(); boolean showOthers = formPanel.getCheckBox(SHOW_OTHERS).isSelected(); int thickness = TokenStatesController.getSpinner(THICKNESS, "thickness", formPanel); int increments = TokenStatesController.getSpinner(INCREMENTS, "increments", formPanel); - Side side = - Side.valueOf(((String) formPanel.getComboBox(SIDE).getSelectedItem()).toUpperCase()); + var side = (BarSide) formPanel.getComboBox(SIDE).getSelectedItem(); + + if (overlay == null || side == null) { + return null; + } BarTokenOverlay to = null; - if (overlay.equals("SOLID_BAR")) { + if (overlay.equals(BarType.SOLID)) { to = new DrawnBarTokenOverlay(name, color, thickness); - } else if (overlay.equals("TWO_TONE_BAR")) { + } else if (overlay.equals(BarType.TWO_TONE)) { to = new TwoToneBarTokenOverlay(name, color, bgColor, thickness); } else { @@ -754,11 +783,11 @@ public BarTokenOverlay createTokenOverlay(BarTokenOverlay updatedOverlay) { model.copyInto(assetIds); // Create the bars - if (overlay.equals("TWO_IMAGES_BAR")) { + if (overlay.equals(BarType.TWO_IMAGE)) { to = new TwoImageBarTokenOverlay(name, assetIds[1], assetIds[0]); - } else if (overlay.equals("SINGLE_IMAGE_BAR")) { + } else if (overlay.equals(BarType.ONE_IMAGE)) { to = new SingleImageBarTokenOverlay(name, assetIds[0]); - } else if (overlay.equals("MULTIPLE_IMAGES_BAR")) { + } else if (overlay.equals(BarType.MULTIPLE_IMAGE)) { to = new MultipleImageBarTokenOverlay(name, assetIds); } // endif } // endif @@ -771,7 +800,7 @@ public BarTokenOverlay createTokenOverlay(BarTokenOverlay updatedOverlay) { to.setShowOthers(showOthers); to.setShowOwner(showOwner); to.setIncrements(increments); - to.setSide(side); + to.setSide(side.getSide()); } // endif return to; } diff --git a/src/main/java/net/rptools/maptool/client/ui/theme/RessourceManager.java b/src/main/java/net/rptools/maptool/client/ui/theme/RessourceManager.java index a98db2f7b3..357ca1a3e9 100644 --- a/src/main/java/net/rptools/maptool/client/ui/theme/RessourceManager.java +++ b/src/main/java/net/rptools/maptool/client/ui/theme/RessourceManager.java @@ -237,7 +237,7 @@ public class RessourceManager { put(Images.DECORATION_RPTOK, IMAGE_DIR + "rptokIcon.png"); put(Images.EMPTY, IMAGE_DIR + "empty.png"); put(Images.GRID_BORDER_HEX, IMAGE_DIR + "hexBorder.png"); - put(Images.GRID_BORDER_ISOMETRIC, IMAGE_DIR + "hexBorder.png"); + put(Images.GRID_BORDER_ISOMETRIC, IMAGE_DIR + "isoBorder.png"); put(Images.GRID_BORDER_SQUARE, IMAGE_DIR + "whiteBorder.png"); put(Images.GRID_BORDER_SQUARE_RED, IMAGE_DIR + "grid-square-red.png"); put(Images.HEROLABS_PORTRAIT, IMAGE_DIR + "powered_by_hero_lab_small.png"); diff --git a/src/main/java/net/rptools/maptool/model/Zone.java b/src/main/java/net/rptools/maptool/model/Zone.java index 7736e44760..c0c0db65e2 100644 --- a/src/main/java/net/rptools/maptool/model/Zone.java +++ b/src/main/java/net/rptools/maptool/model/Zone.java @@ -601,18 +601,29 @@ public Zone(Zone zone, boolean keepIds) { } } // Set the initiative list using the newly create tokens. + // We also have to work around old campaign issues where there may be empty positions in the + // initiative list + int newCurrent = -1; + int oldCurrent = zone.initiativeList.getCurrent(); if (saveInitiative.length > 0) { + int newInd = 0; for (int i = 0; i < saveInitiative.length; i++) { Token token = (Token) saveInitiative[i][0]; - initiativeList.insertToken(i, token); - TokenInitiative ti = initiativeList.getTokenInitiative(i); - TokenInitiative oldti = (TokenInitiative) saveInitiative[i][1]; - ti.setHolding(oldti.isHolding()); - ti.setState(oldti.getState()); + if (token != null) { + initiativeList.insertToken(newInd, token); + TokenInitiative ti = initiativeList.getTokenInitiative(newInd); + TokenInitiative oldti = (TokenInitiative) saveInitiative[i][1]; + ti.setHolding(oldti.isHolding()); + ti.setState(oldti.getState()); + if (oldCurrent == i) { + newCurrent = newInd; + } + newInd++; + } } } initiativeList.setZone(this); - initiativeList.setCurrent(zone.initiativeList.getCurrent()); + initiativeList.setCurrent(newCurrent); initiativeList.setRound(zone.initiativeList.getRound()); initiativeList.setHideNPC(zone.initiativeList.isHideNPC()); @@ -2336,6 +2347,10 @@ public static Zone fromDto(ZoneDto dto) { public ZoneDto toDto() { var dto = ZoneDto.newBuilder(); + dto.setName(name); + if (playerAlias != null) { + dto.setPlayerAlias(StringValue.of(playerAlias)); + } dto.setCreationTime(creationTime); dto.setId(id.toString()); dto.setGrid(grid.toDto()); @@ -2385,10 +2400,6 @@ public ZoneDto toDto() { dto.setBoardPosition(Mapper.map(boardPosition)); dto.setDrawBoard(drawBoard); dto.setBoardChanged(boardChanged); - dto.setName(name); - if (playerAlias != null) { - dto.setPlayerAlias(StringValue.of(playerAlias)); - } dto.setIsVisible(isVisible); dto.setVisionType(ZoneDto.VisionTypeDto.valueOf(visionType.name())); dto.setLightingStyle(ZoneDto.LightingStyleDto.valueOf(lightingStyle.name())); diff --git a/src/main/java/net/rptools/maptool/model/drawing/Drawable.java b/src/main/java/net/rptools/maptool/model/drawing/Drawable.java index 4053a8fb04..2b10791b15 100644 --- a/src/main/java/net/rptools/maptool/model/drawing/Drawable.java +++ b/src/main/java/net/rptools/maptool/model/drawing/Drawable.java @@ -211,7 +211,9 @@ static Drawable fromDto(DrawableDto drawableDto) { drawable.setRadius(dto.getRadius()); var vertex = dto.getVertex(); drawable.setVertex(new ZonePoint(vertex.getX(), vertex.getY())); - drawable.setQuadrant(AbstractTemplate.Quadrant.valueOf(dto.getQuadrant())); + if (!dto.getQuadrant().isEmpty()) { + drawable.setQuadrant(AbstractTemplate.Quadrant.valueOf(dto.getQuadrant())); + } drawable.setMouseSlopeGreater(dto.getMouseSlopeGreater()); var pathVertex = dto.getPathVertex(); drawable.setPathVertex(new ZonePoint(pathVertex.getX(), pathVertex.getY())); diff --git a/src/main/java/net/rptools/maptool/model/drawing/LineTemplate.java b/src/main/java/net/rptools/maptool/model/drawing/LineTemplate.java index 1c146e7bbb..4ebfab6c4d 100644 --- a/src/main/java/net/rptools/maptool/model/drawing/LineTemplate.java +++ b/src/main/java/net/rptools/maptool/model/drawing/LineTemplate.java @@ -486,10 +486,14 @@ public DrawableDto toDto() { .setZoneId(getZoneId().toString()) .setRadius(getRadius()) .setVertex(getVertex().toDto()) - .setQuadrant(getQuadrant().name()) .setMouseSlopeGreater(isMouseSlopeGreater()) - .setPathVertex(getPathVertex().toDto()) .setDoubleWide(isDoubleWide()); + if (getPathVertex() != null) { + dto.setPathVertex(getPathVertex().toDto()); + } + if (getQuadrant() != null) { + dto.setQuadrant(getQuadrant().name()); + } if (getName() != null) dto.setName(StringValue.of(getName()));