From 8f9f27a8c44fbb8cd50c439c5454c8c709c19f76 Mon Sep 17 00:00:00 2001 From: kauron Date: Sun, 19 Jul 2015 19:12:38 +0200 Subject: [PATCH] Powers: now all fields are optional, except the names Made display scrollable --- .../java/com/kauron/dungeonmanager/Power.java | 4 +- .../com/kauron/dungeonmanager/ShowPlayer.java | 27 +- app/src/main/res/layout/attack_display.xml | 289 +++++++++--------- 3 files changed, 168 insertions(+), 152 deletions(-) diff --git a/app/src/main/java/com/kauron/dungeonmanager/Power.java b/app/src/main/java/com/kauron/dungeonmanager/Power.java index 3e2ec61..7ab578b 100644 --- a/app/src/main/java/com/kauron/dungeonmanager/Power.java +++ b/app/src/main/java/com/kauron/dungeonmanager/Power.java @@ -59,13 +59,15 @@ class Power implements Serializable{ String getKeywords() {return keywords;} - String getTypeString() {return ACTIONS[action];} + String getActionString() {return ACTIONS[action];} String getFrequencyString() {return FREQ[freq];} String getRangeString() {return RANGES[range];} int getAtk() {return atk;} int getDef() {return def;} int getFreq() {return freq;} + int getAction() {return action;} + int getRange() {return range;} String getDistance() {return distance;} String getName(){return name;} diff --git a/app/src/main/java/com/kauron/dungeonmanager/ShowPlayer.java b/app/src/main/java/com/kauron/dungeonmanager/ShowPlayer.java index d69c9f8..e2e6e8f 100644 --- a/app/src/main/java/com/kauron/dungeonmanager/ShowPlayer.java +++ b/app/src/main/java/com/kauron/dungeonmanager/ShowPlayer.java @@ -577,13 +577,30 @@ public class ShowPlayer extends ActionBarActivity { nameText.setBackgroundColor(color); ((TextView) nameText).setText(power.getName()); - ((TextView) dialog.findViewById(R.id.typeText)).setText(power.getTypeString()); - ((TextView) dialog.findViewById(R.id.rangeText)).setText(power.getRangeString() + " "); - ((TextView) dialog.findViewById(R.id.freqText)).setText(power.getFrequencyString()); + + if (power.getAction() != 0) + ((TextView) dialog.findViewById(R.id.actionText)).setText(power.getActionString()); + else dialog.findViewById(R.id.actionText).setVisibility(View.GONE); + + if (power.getRange() != 0) + ((TextView) dialog.findViewById(R.id.rangeText)).setText(power.getRangeString() + " "); + else dialog.findViewById(R.id.rangeText).setVisibility(View.GONE); + + if (power.getFreq() != 0) + ((TextView) dialog.findViewById(R.id.freqText)).setText(power.getFrequencyString()); + else dialog.findViewById(R.id.freqText).setVisibility(View.GONE); + ((TextView) dialog.findViewById(R.id.keywordsText)).setText(power.getKeywords()); ((TextView) dialog.findViewById(R.id.distanceText)).setText(String.valueOf(power.getDistance())); - ((TextView) dialog.findViewById(R.id.objectiveText)).setText(power.getObjective()); - ((TextView) dialog.findViewById(R.id.impactText)).setText(power.getImpact()); + + if (!power.getObjective().isEmpty()) + ((TextView) dialog.findViewById(R.id.objectiveText)).setText(power.getObjective()); + else dialog.findViewById(R.id.objectiveLayout).setVisibility(View.GONE); + + if (!power.getImpact().isEmpty()) + ((TextView) dialog.findViewById(R.id.impactText)).setText(power.getImpact()); + else dialog.findViewById(R.id.impactLayout).setVisibility(View.GONE); + ((TextView) dialog.findViewById(R.id.otherText)).setText(power.getOther()); String[] attack = getResources().getStringArray(R.array.attack); diff --git a/app/src/main/res/layout/attack_display.xml b/app/src/main/res/layout/attack_display.xml index 4b7bac1..f2e3803 100644 --- a/app/src/main/res/layout/attack_display.xml +++ b/app/src/main/res/layout/attack_display.xml @@ -19,162 +19,159 @@ android:textColor="@color/white" android:id="@+id/nameText" /> - + - + - + - + - - + + - + - + - + + + - + - + - - + + -