Revision: 758
Author: ace.stef
Date: Tue Sep 4 12:18:45 2012
Log: Show depleted construction materials symbol. Changed unit so it
fires an change event when the construction materials are reset to max.
http://code.google.com/p/customwars/source/detail?r=758
Modified:
/trunk/v2/resources/res/plugin/dor/images/unitDecorations.png
/trunk/v2/src/com/customwars/client/model/gameobject/Unit.java
/trunk/v2/src/com/customwars/client/model/gameobject/UnitStats.java
/trunk/v2/src/com/customwars/client/ui/sprite/UnitSprite.java
=======================================
--- /trunk/v2/resources/res/plugin/dor/images/unitDecorations.png Wed Feb
10 06:40:40 2010
+++ /trunk/v2/resources/res/plugin/dor/images/unitDecorations.png Tue Sep
4 12:18:45 2012
Binary file, no diff available.
=======================================
--- /trunk/v2/src/com/customwars/client/model/gameobject/Unit.java Fri Mar
25 08:50:39 2011
+++ /trunk/v2/src/com/customwars/client/model/gameobject/Unit.java Tue Sep
4 12:18:45 2012
@@ -537,8 +537,12 @@
//
---------------------------------------------------------------------------
public void deCreaseConstructionMaterials() {
+ setConstructionMaterials(constructionMaterials-1);
+ }
+
+ private void setConstructionMaterials(int newVal) {
int oldVal = this.constructionMaterials;
- this.constructionMaterials =
Args.getBetweenZeroMax(constructionMaterials - 1,
stats.maxConstructionMaterial);
+ this.constructionMaterials = Args.getBetweenZeroMax(newVal,
stats.maxConstructionMaterial);
firePropertyChange("constructionMaterials", oldVal,
constructionMaterials);
}
@@ -609,7 +613,7 @@
}
public void setMaxConstructionMaterials() {
- this.constructionMaterials = stats.maxConstructionMaterial;
+ setConstructionMaterials(stats.maxConstructionMaterial);
}
public void setLocation(Location newLocation) {
=======================================
--- /trunk/v2/src/com/customwars/client/model/gameobject/UnitStats.java Sun
Mar 20 06:49:26 2011
+++ /trunk/v2/src/com/customwars/client/model/gameobject/UnitStats.java Tue
Sep 4 12:18:45 2012
@@ -261,6 +261,10 @@
public List<String> getTransports() {
return transportStats.getTransports();
}
+
+ public boolean canBuildCity() {
+ return !buildCities.isEmpty();
+ }
public boolean canBuildCity(String id) {
return buildCities.containsKey(id);
=======================================
--- /trunk/v2/src/com/customwars/client/ui/sprite/UnitSprite.java Sat Aug
7 03:53:48 2010
+++ /trunk/v2/src/com/customwars/client/ui/sprite/UnitSprite.java Tue Sep
4 12:18:45 2012
@@ -35,6 +35,7 @@
private static final int RANK_II = 7;
private static final int RANK_V = 8;
private static final int CO = 9;
+ private static final int CONSTRUCTION_MATERIALS_DEPLETED = 10;
private final ImageRotator statusRotator;
private Font hpFont;
@@ -59,6 +60,7 @@
statusRotator.setShowFrame(LOW_AMMO, unit.hasLowAmmo());
statusRotator.setShowFrame(LOW_SUPPLIES, unit.hasLowSupplies());
statusRotator.setShowFrame(LOAD, unit.getLocatableCount() > 0);
+ constructionMaterialsChanged(unit.getCurrentConstructionMaterials());
experienceChange(unit.getExperience());
// Hide the unit when it is on a fogged location
@@ -228,6 +230,8 @@
unitStateChange((UnitState) evt.getNewValue());
} else if (propertyName.equals("experience")) {
experienceChange((Integer) evt.getNewValue());
+ } else if (propertyName.equals("constructionMaterials")) {
+ constructionMaterialsChanged((Integer) evt.getNewValue());
}
} else if (evt.getSource() == unit.getPrimaryWeapon()) {
if (propertyName.equals("ammo")) {
@@ -255,6 +259,12 @@
}
}
}
+
+ private void constructionMaterialsChanged(int newValue) {
+ boolean canUseMaterials = unit.getStats().canBuildCity() ||
unit.getStats().canProduceUnits();
+ boolean materialsDepleted = canUseMaterials && newValue == 0;
+ statusRotator.setShowFrame(CONSTRUCTION_MATERIALS_DEPLETED,
materialsDepleted);
+ }
private void showRank(int rank) {
statusRotator.showFrame(rank);