Skip to content

Commit

Permalink
Merge pull request #4115 from cwisniew/merge-1.13.1
Browse files Browse the repository at this point in the history
Merge 1.13.1 into develop
  • Loading branch information
cwisniew authored Jun 9, 2023
2 parents c0c943a + a200ca4 commit b3924f9
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<grid id="6db9f" binding="mainPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="5" left="5" bottom="5" right="5"/>
<constraints>
<xy x="10" y="10" width="774" height="720"/>
<xy x="10" y="10" width="815" height="720"/>
</constraints>
<properties>
<name value="mainForm"/>
Expand Down Expand Up @@ -953,7 +953,9 @@
<constraints>
<grid row="4" column="1" row-span="1" col-span="8" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<properties>
<name value="tokenBarImagesScroll"/>
</properties>
<border type="none"/>
<children>
<component id="82992" class="javax.swing.JList">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import javax.swing.*;

public class CampaignPropertiesDialogView {

private JPanel mainPanel;

public JComponent getRootComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -219,20 +220,48 @@ public class TokenBarController
new String[0], // Two Tone
};

private static final List<String> 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<String> 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
Expand All @@ -253,24 +282,21 @@ 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<BarType>());
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<BarSide>());
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));
panel.getSpinner(INCREMENTS).addChangeListener(this);
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<MD5Key>());
panel.getList(IMAGES).setCellRenderer(new ImageListRenderer());
panel.getList(IMAGES).addListSelectionListener(this);
panel.getTextComponent(NAME).getDocument().addDocumentListener(this);
Expand Down Expand Up @@ -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 {

Expand All @@ -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
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
31 changes: 21 additions & 10 deletions src/main/java/net/rptools/maptool/model/Zone.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));

Expand Down

0 comments on commit b3924f9

Please sign in to comment.