[customwars] r766 committed - Show construction materials in unit panel.

0 views
Skip to first unread message

codesite...@google.com

unread,
Oct 17, 2012, 6:47:17 AM10/17/12
to customwar...@googlegroups.com
Revision: 766
Author: ace.stef
Date: Wed Oct 17 03:46:58 2012
Log: Show construction materials in unit panel.
http://code.google.com/p/customwars/source/detail?r=766

Modified:
/trunk/v2/resources/res/plugin/dor/images/panel_info.png
/trunk/v2/src/com/customwars/client/model/gameobject/UnitStats.java

/trunk/v2/src/com/customwars/client/ui/hud/panel/HorizontalUnitInfoPanel.java

=======================================
--- /trunk/v2/resources/res/plugin/dor/images/panel_info.png Mon Dec 28
04:43:32 2009
+++ /trunk/v2/resources/res/plugin/dor/images/panel_info.png Wed Oct 17
03:46:58 2012
Binary file, no diff available.
=======================================
--- /trunk/v2/src/com/customwars/client/model/gameobject/UnitStats.java Tue
Sep 4 12:18:45 2012
+++ /trunk/v2/src/com/customwars/client/model/gameobject/UnitStats.java Wed
Oct 17 03:46:58 2012
@@ -317,6 +317,10 @@
public int getSuppliesPerTurnWhenHidden() {
return suppliesPerTurnWhenHidden;
}
+
+ public boolean hasConstructionMaterials() {
+ return maxConstructionMaterial > 0;
+ }

public int getMaxConstructionMaterial() {
return maxConstructionMaterial;
=======================================
---
/trunk/v2/src/com/customwars/client/ui/hud/panel/HorizontalUnitInfoPanel.java
Sat Jul 10 10:38:41 2010
+++
/trunk/v2/src/com/customwars/client/ui/hud/panel/HorizontalUnitInfoPanel.java
Wed Oct 17 03:46:58 2012
@@ -81,7 +81,21 @@
setFrontImage(resources.getUnitImg(unit, Unit.DEFAULT_ORIENTATION));
hpTxtBox.setText(unit.getHp() + "");
suppliesTxtBox.setText(unit.getSupplies() + "");
- ammoTxtBox.setText(unit.getAmmo() + "");
+ initAmmoBoxes();
+ }
+
+ /**
+ * If the unit has construction materials show them instead of the ammo.
+ * Using the same ammo boxes.
+ */
+ private void initAmmoBoxes() {
+ if(unit.getStats().hasConstructionMaterials()) {
+ ammoImgBox.setImage(statusImageStrip.getSubImage(6));
+ ammoTxtBox.setText(unit.getCurrentConstructionMaterials() + "");
+ } else {
+ ammoImgBox.setImage(statusImageStrip.getSubImage(3));
+ ammoTxtBox.setText(unit.getAmmo() + "");
+ }
}

protected Dimension getNameSize() {
Reply all
Reply to author
Forward
0 new messages