From: "Enrico Weigelt, metux IT consult" <[email protected]>
---
.../gui/panel/colopedia/UnitDetailPanel.java | 57 +++++++++++-----------
.../sf/freecol/common/model/IndianNationType.java | 9 ++++
2 files changed, 38 insertions(+), 28 deletions(-)
diff --git a/src/net/sf/freecol/client/gui/panel/colopedia/UnitDetailPanel.java
b/src/net/sf/freecol/client/gui/panel/colopedia/UnitDetailPanel.java
index 7ded9ea3b1b..566a9d1b34a 100644
--- a/src/net/sf/freecol/client/gui/panel/colopedia/UnitDetailPanel.java
+++ b/src/net/sf/freecol/client/gui/panel/colopedia/UnitDetailPanel.java
@@ -135,38 +135,39 @@ public class UnitDetailPanel extends
ColopediaGameObjectTypePanel<UnitType> {
panel.add(Utility.localizedLabel("colopedia.unit.skill"));
panel.add(new JLabel(Integer.toString(type.getSkill())), "right");
- List<BuildingType> schools = transform(spec.getBuildingTypeList(),
- bt -> bt.hasAbility(Ability.TEACH) && bt.canAdd(type));
- if (!schools.isEmpty()) {
- panel.add(Utility.localizedLabel("colopedia.unit.school"),
"newline");
- int count = 0;
- for (BuildingType school : schools) {
- JButton label = getButton(school);
- if (count > 0 && count % 3 == 0) {
- panel.add(label, "skip");
- } else {
- panel.add(label);
- }
- count++;
+ int count = 0;
+
+ for (BuildingType school : spec.getBuildingTypeList()) {
+ if (!school.hasAbility(Ability.TEACH) || !school.canAdd(type))
+ continue;
+
+ if (count == 0)
+ panel.add(Utility.localizedLabel("colopedia.unit.school"),
"newline");
+
+ JButton label = getButton(school);
+ if (count > 0 && count % 3 == 0) {
+ panel.add(label, "skip");
+ } else {
+ panel.add(label);
}
+ count++;
}
- List<IndianNationType> nations
- = transform(spec.getIndianNationTypes(),
- nt -> any(nt.getSkills(),
- matchKey(type,
RandomChoice::getObject)));
- if (!nations.isEmpty()) {
- panel.add(Utility.localizedLabel("colopedia.unit.natives"),
"newline");
- int count = 0;
- for (IndianNationType nation : nations) {
- JButton label = getButton(nation);
- if (count > 0 && count % 3 == 0) {
- panel.add(label, "skip");
- } else {
- panel.add(label);
- }
- count++;
+ count = 0;
+ for (IndianNationType nt : spec.getIndianNationTypes()) {
+ if (!nt.hasSkill(type))
+ continue;
+
+ if (count == 0)
+
panel.add(Utility.localizedLabel("colopedia.unit.natives"), "newline");
+
+ JButton label = getButton(nt);
+ if (count > 0 && count % 3 == 0) {
+ panel.add(label, "skip");
+ } else {
+ panel.add(label);
}
+ count++;
}
}
diff --git a/src/net/sf/freecol/common/model/IndianNationType.java
b/src/net/sf/freecol/common/model/IndianNationType.java
index 1f3e78959e2..139d3addb4b 100644
--- a/src/net/sf/freecol/common/model/IndianNationType.java
+++ b/src/net/sf/freecol/common/model/IndianNationType.java
@@ -128,6 +128,15 @@ public class IndianNationType extends NationType {
: skills;
}
+ public boolean hasSkill(UnitType t) {
+ if (skills != null)
+ for (RandomChoice<UnitType> walk : skills)
+ if (walk.getObject() == t)
+ return true;
+
+ return true;
+ }
+
/**
* Add a skill.
*
--
2.11.0.rc0.7.gbe5a750
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Freecol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freecol-developers