Skip to content

Commit

Permalink
Remove unused color property type from DTD and impossible file proper…
Browse files Browse the repository at this point in the history
…ty type (#7528)

* Remove unused color property type from DTD and impossible file property type

1) No map uses the 'color' property type, eg:
<property name="colorProperty>
  <color/>
</property>

2) In the property type handling code there is an option for
a "file" type. That is not defined in the DTD as a valid
tag to property and hence would be impossible to have.

* Auto-Formatting

Co-authored-by: tripleabuilderbot <tripleabuilderbot@gmail.com>
  • Loading branch information
DanVanAtta and tripleabuilderbot authored Sep 4, 2020
1 parent 00799e8 commit f52c756
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 37 deletions.
11 changes: 0 additions & 11 deletions game-core/src/main/java/games/strategy/engine/data/GameParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import games.strategy.engine.ClientContext;
import games.strategy.engine.data.gameparser.XmlGameElementMapper;
import games.strategy.engine.data.properties.BooleanProperty;
import games.strategy.engine.data.properties.ColorProperty;
import games.strategy.engine.data.properties.GameProperties;
import games.strategy.engine.data.properties.IEditableProperty;
import games.strategy.engine.data.properties.NumberProperty;
Expand All @@ -20,7 +19,6 @@
import games.strategy.triplea.delegate.GenericTechAdvance;
import games.strategy.triplea.delegate.TechAdvance;
import games.strategy.triplea.formatter.MyFormatter;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -29,7 +27,6 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
import java.util.function.Function;
Expand Down Expand Up @@ -679,9 +676,6 @@ private void parseProperties(final Node root) throws GameParseException {
case "boolean":
properties.set(property, Boolean.valueOf(value));
break;
case "file":
properties.set(property, Optional.ofNullable(value).map(File::new).orElse(null));
break;
case "number":
int intValue = 0;
if (value != null) {
Expand Down Expand Up @@ -741,11 +735,6 @@ private void parseEditableProperty(
final int def = Integer.parseInt(defaultValue);
editableProperty = new NumberProperty(name, null, max, min, def);
break;
case "color":
// Parse the value as a hexadecimal number
final int defaultColor = Integer.valueOf(defaultValue, 16);
editableProperty = new ColorProperty(name, null, defaultColor);
break;
case "string":
editableProperty = new StringProperty(name, null, defaultValue);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,12 @@
*/
public class ColorProperty extends AbstractEditableProperty<Color> {
private static final long serialVersionUID = 6826763550643504789L;
private static final int MAX_COLOR = 0xFFFFFF;
private static final int MIN_COLOR = 0x000000;

private Color color;

public ColorProperty(final String name, final String description, final int def) {
super(name, description);
if (def > MAX_COLOR || def < MIN_COLOR) {
throw new IllegalArgumentException("Default value out of range");
}
color = new Color(def);
}

public ColorProperty(final String name, final String description, final Color def) {
super(name, description);
if (def == null) {
color = Color.black;
} else {
color = def;
}
color = def == null ? Color.black : def;
}

@Override
Expand All @@ -47,11 +33,7 @@ public Color getValue() {

@Override
public void setValue(final Color value) {
if (value == null) {
color = Color.black;
} else {
color = value;
}
color = value == null ? Color.black : value;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@


<!ELEMENT propertyList (property*)>
<!ELEMENT property (boolean?, string?, number?, color?, value?) >
<!ELEMENT property (boolean?, string?, number?, value?) >
<!-- can the player edit this on start up? if true then the type must be specified with a nested element -->
<!ATTLIST property
value CDATA ""
Expand All @@ -279,8 +279,4 @@
max CDATA #REQUIRED
min CDATA #REQUIRED
>

<!ELEMENT color EMPTY>
<!ATTLIST color
>


0 comments on commit f52c756

Please sign in to comment.