On Wed, 7 Nov 2012 08:45:34 PM Stéphane Perez wrote:
>[patch]

I looked at fixing Tension.getKey().  It turns out cause some complication.
Does the attached patch fix the bug for you, without breaking other
native displays, like the Indian Report?

Cheers,
Mike Pope

Attachment: signature.asc
Description: This is a digitally signed message part.

diff --git a/data/strings/FreeColMessages.properties b/data/strings/FreeColMessages.properties
index abec5aa..3d107e1 100644
--- a/data/strings/FreeColMessages.properties
+++ b/data/strings/FreeColMessages.properties
@@ -220,6 +220,7 @@ tension.content=Content
 tension.displeased=Displeased
 tension.angry=Angry
 tension.hateful=Hateful
+tension.unknown=Unknown
 tension=Tension
 
 noSuchFile=The specified file does not exist or is not a regular file.
@@ -1197,14 +1198,13 @@ indianSettlement.skillNone=None
 indianSettlement.mostHated=The most hated nation at this settlement:
 indianSettlement.mostHatedNone=None
 indianSettlement.mostHatedUnknown=Unknown
-indianSettlement.tensionUnknown=Unknown
 indianSettlement.wantedGoodsUnknown=Unknown
 indianSettlement.wantedGoodsNone=None
-indianSettlement.alarm.happy=The members of the %nation% nation are happily dancing around their camp fire and singing the songs of their ancestors.
-indianSettlement.alarm.content=The members of the %nation% nation are busy at work. Their children merrily play hide and seek.
-indianSettlement.alarm.displeased=The members of the %nation% nation are busy at work. Their children are nowhere to be seen, and their elders are frowning.
-indianSettlement.alarm.angry=The braves of the %nation% nation are busy at target practice. The women and children hide in their tents.
-indianSettlement.alarm.hateful=The braves of the %nation% nation are shaking their weapons. They have adorned their belts with the scalps of their enemies, and their torture stakes show signs of heavy use.
+indianSettlement.tension.happy=The members of the %nation% nation are happily dancing around their camp fire and singing the songs of their ancestors.
+indianSettlement.tension.content=The members of the %nation% nation are busy at work. Their children merrily play hide and seek.
+indianSettlement.tension.displeased=The members of the %nation% nation are busy at work. Their children are nowhere to be seen, and their elders are frowning.
+indianSettlement.tension.angry=The braves of the %nation% nation are busy at target practice. The women and children hide in their tents.
+indianSettlement.tension.hateful=The braves of the %nation% nation are shaking their weapons. They have adorned their belts with the scalps of their enemies, and their torture stakes show signs of heavy use.
 indianSettlement.mission.happy=Mission founded, %nation% approach your new religion with joy.
 indianSettlement.mission.content=Mission founded, %nation% approach your new religion with curiosity.
 indianSettlement.mission.displeased=Mission founded, %nation% are offended.
diff --git a/src/net/sf/freecol/client/gui/i18n/Messages.java b/src/net/sf/freecol/client/gui/i18n/Messages.java
index 0678bb3..aa5bc6c 100644
--- a/src/net/sf/freecol/client/gui/i18n/Messages.java
+++ b/src/net/sf/freecol/client/gui/i18n/Messages.java
@@ -656,16 +656,6 @@ public class Messages {
     }
 
     /**
-     * Returns a string describing the given stance.
-     *
-     * @param stance The stance.
-     * @return A matching string.
-     */
-    public static String getStanceAsString(Player.Stance stance) {
-        return message("model.stance." + stance.toString().toLowerCase());
-    }
-
-    /**
      * Gets a string describing the number of turns left for a colony
      * to finish building something.
      *
diff --git a/src/net/sf/freecol/client/gui/panel/NegotiationDialog.java b/src/net/sf/freecol/client/gui/panel/NegotiationDialog.java
index 72e388b..c51054a 100644
--- a/src/net/sf/freecol/client/gui/panel/NegotiationDialog.java
+++ b/src/net/sf/freecol/client/gui/panel/NegotiationDialog.java
@@ -325,7 +325,7 @@ public final class NegotiationDialog extends FreeColDialog<DiplomaticTrade>
         String description = null;
         if (item instanceof StanceTradeItem) {
             StanceTradeItem i = (StanceTradeItem)item;
-            description = Messages.getStanceAsString(i.getStance());
+            description = Messages.message(i.getStance().getKey());
         } else if (item instanceof GoldTradeItem) {
             int gold = ((GoldTradeItem)item).getGold();
             description = Messages
@@ -749,7 +749,7 @@ public final class NegotiationDialog extends FreeColDialog<DiplomaticTrade>
 
             @Override
             public String toString() {
-                return Messages.getStanceAsString(value);
+                return Messages.message(value.getKey());
             }
 
             public Stance getValue() {
diff --git a/src/net/sf/freecol/client/gui/panel/ReportForeignAffairPanel.java b/src/net/sf/freecol/client/gui/panel/ReportForeignAffairPanel.java
index 29ab948..047c356 100644
--- a/src/net/sf/freecol/client/gui/panel/ReportForeignAffairPanel.java
+++ b/src/net/sf/freecol/client/gui/panel/ReportForeignAffairPanel.java
@@ -65,7 +65,7 @@ public final class ReportForeignAffairPanel extends ReportPanel {
             enemyPanel.add(localizedLabel(enemy.getNationName()), "wrap 12");
 
             enemyPanel.add(new JLabel(Messages.message("report.stance")), "newline");
-            enemyPanel.add(new JLabel(Messages.message(Messages.getStanceAsString(ns.getStance()))));
+            enemyPanel.add(new JLabel(Messages.message(ns.getStance().getKey())));
 
             enemyPanel.add(new JLabel(Messages.message("report.numberOfColonies")), "newline");
             enemyPanel.add(new JLabel(ns.getNumberOfSettlements()));
diff --git a/src/net/sf/freecol/client/gui/panel/ReportIndianPanel.java b/src/net/sf/freecol/client/gui/panel/ReportIndianPanel.java
index 421c989..1cb32a0 100644
--- a/src/net/sf/freecol/client/gui/panel/ReportIndianPanel.java
+++ b/src/net/sf/freecol/client/gui/panel/ReportIndianPanel.java
@@ -118,9 +118,8 @@ public final class ReportIndianPanel extends ReportPanel {
         label = localizedLabel("report.indian.tribeTension");
         reportPanel.add(label);
         label.setFont(boldFont);
-        reportPanel.add(new JLabel(Messages.message("tension." + opponent.getTension(player).getKey())
-                + "/"
-                + Messages.message(Messages.getStanceAsString(opponent.getStance(player)))),
+        reportPanel.add(new JLabel(Messages.message(opponent.getTension(player).getKey())
+                + "/" + Messages.message(opponent.getStance(player).getKey())),
             "left, wrap 20");
 
         if (knownNumberOfSettlements > 0) {
diff --git a/src/net/sf/freecol/common/model/IndianSettlement.java b/src/net/sf/freecol/common/model/IndianSettlement.java
index adc283b..c39c2db 100644
--- a/src/net/sf/freecol/common/model/IndianSettlement.java
+++ b/src/net/sf/freecol/common/model/IndianSettlement.java
@@ -582,7 +582,7 @@ public class IndianSettlement extends Settlement {
     public String getShortAlarmLevelMessageId(Player player) {
         return (!player.hasContacted(owner)) ? "tension.wary"
             : (hasContacted(player)) ? getAlarm(player).getKey()
-            : "indianSettlement.tensionUnknown";
+            : "tension.unknown";
     }
 
     /**
@@ -595,7 +595,7 @@ public class IndianSettlement extends Settlement {
     public String getAlarmLevelMessageId(Player player) {
         Tension alarm = (hasContacted(player)) ? getAlarm(player)
             : new Tension(Tension.TENSION_MIN);
-        return "indianSettlement.alarm." + alarm.getKey();
+        return "indianSettlement." + alarm.getKey();
     }
 
     /**
diff --git a/src/net/sf/freecol/common/model/Player.java b/src/net/sf/freecol/common/model/Player.java
index 52dda41..355c9b8 100644
--- a/src/net/sf/freecol/common/model/Player.java
+++ b/src/net/sf/freecol/common/model/Player.java
@@ -208,6 +208,15 @@ public class Player extends FreeColGameObject implements Nameable {
                 throw new IllegalStateException("Bogus newStance");
             }
         }
+
+        /**
+         * Gets a message id for this stance.
+         *
+         * @return A message id string.
+         */
+        public String getKey() {
+            return "model.stance." + toString().toLowerCase(Locale.US);
+        }
     }
 
 
diff --git a/src/net/sf/freecol/common/model/Tension.java b/src/net/sf/freecol/common/model/Tension.java
index c93011f..62fd0ff 100644
--- a/src/net/sf/freecol/common/model/Tension.java
+++ b/src/net/sf/freecol/common/model/Tension.java
@@ -142,12 +142,12 @@ public class Tension {
     }
 
     /**
-     * Gets a string suitable for use in a message id.
+     * Gets a message id for this tension.
      *
      * @return A message id string.
      */
     public String getKey() {
-        return toString().toLowerCase(Locale.US);
+        return "tension." + toString().toLowerCase(Locale.US);
     }
 
     /**
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
Freecol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freecol-developers

Reply via email to