Skip to content

Commit

Permalink
send property display name to statsheet
Browse files Browse the repository at this point in the history
  • Loading branch information
cwisniew committed Aug 3, 2023
1 parent 1ffb75a commit a8e6da4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ public Object getValueAt(int rowIndex, int columnIndex) {
return switch (columnIndex) {
case 0 -> property.getName();
case 1 -> property.getShortName();
case 2 -> property.getDisplayName();
case 2 -> {
var displayName = property.getDisplayName();
yield displayName == null || displayName.isBlank() ? null : displayName;
}
case 3 -> property.isShowOnStatSheet();
case 4 -> property.isGMOnly() & property.isShowOnStatSheet();
case 5 -> property.isOwnerOnly() & property.isShowOnStatSheet();
Expand Down Expand Up @@ -110,7 +113,7 @@ public boolean isCellEditable(int rowIndex, int columnIndex) {
var properties = tokenTypeMap.get(tokenType);
var tokenProperty = properties.get(rowIndex);
return switch (columnIndex) {
case 3, 4 -> tokenProperty
case 4, 5 -> tokenProperty
.isShowOnStatSheet(); // GM, Owner only editable if show on stat sheet is set
default -> true;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import net.rptools.lib.MD5Key;
import net.rptools.maptool.client.AppPreferences;
import net.rptools.maptool.client.AppUtil;
Expand All @@ -34,6 +35,9 @@ public class StatSheetContext {
/** Class that represents a token property on a stat sheet. */
static class Property {
/** Name of the property. */
private final String name;

/** Display Name of the property. */
private final String displayName;
/** Value of the property. */
private final Object value;
Expand All @@ -46,13 +50,15 @@ static class Property {
/**
* Creates a new instance of the class.
*
* @param displayName Name of the property.
* @param name Name of the property.
* @param displayName Display Name of the property.
* @param value Value of the property.
* @param gmOnly True if the property is GM only.
* @note GM only properties are only extracted if the player is a GM.
*/
Property(String displayName, String shortName, Object value, boolean gmOnly) {
this.displayName = displayName;
Property(String name, String displayName, String shortName, Object value, boolean gmOnly) {
this.name = name;
this.displayName = Objects.requireNonNullElse(displayName, name);
this.shortName = shortName;
this.value = value;
this.gmOnly = gmOnly;
Expand All @@ -63,6 +69,15 @@ static class Property {
*
* @return The name of the property.
*/
public String getName() {
return name;
}

/**
* Returns the display name of the property.
*
* @return The display name of the property.
*/
public String getDisplayName() {
return displayName;
}
Expand Down Expand Up @@ -193,7 +208,13 @@ public StatSheetContext(Token token, Player player, StatSheetLocation location)
return;
}
}
properties.add(new Property(tp.getName(), tp.getShortName(), value, tp.isGMOnly()));
properties.add(
new Property(
tp.getName(),
tp.getDisplayName(),
tp.getShortName(),
value,
tp.isGMOnly()));
}
});

Expand Down

0 comments on commit a8e6da4

Please sign in to comment.