From e6b9b95fcaf6874a8a7bfa90e0cb161d0b4c54c5 Mon Sep 17 00:00:00 2001 From: codernator Date: Sun, 22 Mar 2015 15:50:26 -0400 Subject: [PATCH 1/5] Issue 40 - compare equipable item to corresponding equipped item (if any). --- AndorsTrail/res/layout/iteminfo.xml | 60 ++++++++++++ AndorsTrail/res/values/strings.xml | 1 + .../activity/ItemInfoActivity.java | 92 ++++++++++++------- 3 files changed, 122 insertions(+), 31 deletions(-) diff --git a/AndorsTrail/res/layout/iteminfo.xml b/AndorsTrail/res/layout/iteminfo.xml index cbd52bb21..2cdc37e39 100644 --- a/AndorsTrail/res/layout/iteminfo.xml +++ b/AndorsTrail/res/layout/iteminfo.xml @@ -64,6 +64,66 @@ android:layout_width="match_parent" android:layout_height="wrap_content" /> + + + + + + + + + + + + + + + + + + + diff --git a/AndorsTrail/res/values/strings.xml b/AndorsTrail/res/values/strings.xml index 5b95c043b..45dad8a57 100644 --- a/AndorsTrail/res/values/strings.xml +++ b/AndorsTrail/res/values/strings.xml @@ -109,6 +109,7 @@ + (Equipped) Category: Use Equip diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ItemInfoActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ItemInfoActivity.java index fc2e41e84..b13ac74e8 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ItemInfoActivity.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ItemInfoActivity.java @@ -35,35 +35,32 @@ public void onCreate(Bundle savedInstanceState) { Bundle params = intent.getExtras(); String itemTypeID = params.getString("itemTypeID"); final ItemType itemType = world.itemTypes.getItemType(itemTypeID); + final ItemType equippedType = itemType.isEquippable() + ? world.model.player.inventory.getItemTypeInWearSlot(itemType.category.inventorySlot) + : null; final String buttonText = params.getString("buttonText"); boolean buttonEnabled = params.getBoolean("buttonEnabled"); + final Resources resources = getResources(); setContentView(R.layout.iteminfo); - TextView tv = (TextView) findViewById(R.id.iteminfo_title); - tv.setText(itemType.getName(world.model.player)); - world.tileManager.setImageViewTileForSingleItemType(getResources(), tv, itemType); - - tv = (TextView) findViewById(R.id.iteminfo_description); - String description = itemType.getDescription(); - if (description != null) { - tv.setText(description); - tv.setVisibility(View.VISIBLE); - } else { - tv.setVisibility(View.GONE); - } - - tv = (TextView) findViewById(R.id.iteminfo_category); - tv.setText(itemType.category.displayName); - - ((ItemEffectsView) findViewById(R.id.iteminfo_effects)).update( - itemType.effects_equip, - itemType.effects_use == null ? null : Collections.singletonList(itemType.effects_use), - itemType.effects_hit == null ? null : Collections.singletonList(itemType.effects_hit), - itemType.effects_kill == null ? null : Collections.singletonList(itemType.effects_kill), - itemType.isWeapon() - ); + fillTitle(world, resources, (TextView) findViewById(R.id.iteminfo_title), itemType, (itemType == equippedType)); + fillDescription((TextView) findViewById(R.id.iteminfo_description), itemType); + fillCategory((TextView) findViewById(R.id.iteminfo_category), itemType); + fillItemEffects((ItemEffectsView) findViewById(R.id.iteminfo_effects), itemType); + fillDisplayType(resources, (TextView) findViewById(R.id.iteminfo_displaytype), itemType); + + if (equippedType != null && equippedType != itemType){ + findViewById(R.id.compareinfo).setVisibility(View.VISIBLE); + fillTitle(world, resources, (TextView) findViewById(R.id.compareinfo_title), equippedType, true); + fillDescription((TextView) findViewById(R.id.compareinfo_description), equippedType); + fillCategory((TextView) findViewById(R.id.compareinfo_category), equippedType); + fillItemEffects((ItemEffectsView) findViewById(R.id.compareinfo_effects), equippedType); + fillDisplayType(resources, (TextView) findViewById(R.id.compareinfo_displaytype), equippedType); + } else { + findViewById(R.id.compareinfo).setVisibility(View.GONE); + } Button b = (Button) findViewById(R.id.iteminfo_close); b.setOnClickListener(new OnClickListener() { @@ -93,16 +90,49 @@ public void onClick(View arg0) { } }); - tv = (TextView) findViewById(R.id.iteminfo_displaytype); - if (itemType.isOrdinaryItem()) { - tv.setVisibility(View.GONE); - } else { - tv.setVisibility(View.VISIBLE); - final String diplayType = getDisplayTypeString(getResources(), itemType); - tv.setText(diplayType); - } } + private static void fillTitle(WorldContext world, Resources resources, TextView tv, ItemType itemType, boolean equipped) { + tv.setText(itemType.getName(world.model.player) + (equipped ? " " + resources.getString(R.string.iteminfo_title_equipped) : "")); + world.tileManager.setImageViewTileForSingleItemType(resources, tv, itemType); + + } + + private static void fillCategory(TextView tv, ItemType itemType) { + tv.setText(itemType.category.displayName); + } + + private static void fillDisplayType(Resources resources, TextView tv, ItemType itemType) { + if (itemType.isOrdinaryItem()) { + tv.setVisibility(View.GONE); + } else { + tv.setVisibility(View.VISIBLE); + final String diplayType = getDisplayTypeString(resources, itemType); + tv.setText(diplayType); + } + } + + private static void fillItemEffects(ItemEffectsView iev, ItemType itemType) { + iev.update( + itemType.effects_equip, + itemType.effects_use == null ? null : Collections.singletonList(itemType.effects_use), + itemType.effects_hit == null ? null : Collections.singletonList(itemType.effects_hit), + itemType.effects_kill == null ? null : Collections.singletonList(itemType.effects_kill), + itemType.isWeapon() + ); + } + + private static void fillDescription(TextView tv, ItemType itemType) { + String description = itemType.getDescription(); + if (description != null) { + tv.setText(description); + tv.setVisibility(View.VISIBLE); + } else { + tv.setVisibility(View.GONE); + } + } + + public static String getDisplayTypeString(Resources res, ItemType itemType) { switch (itemType.displayType) { case rare: return res.getString(R.string.iteminfo_displaytypes_rare); From d612f4bfa1ca32cbad1876deace199cfe88dc994 Mon Sep 17 00:00:00 2001 From: codernator Date: Sun, 22 Mar 2015 15:55:49 -0400 Subject: [PATCH 2/5] Spaces to tabs. :/ --- .../activity/ItemInfoActivity.java | 118 +++++++++--------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ItemInfoActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ItemInfoActivity.java index b13ac74e8..e30fcadd0 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ItemInfoActivity.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ItemInfoActivity.java @@ -35,32 +35,32 @@ public void onCreate(Bundle savedInstanceState) { Bundle params = intent.getExtras(); String itemTypeID = params.getString("itemTypeID"); final ItemType itemType = world.itemTypes.getItemType(itemTypeID); - final ItemType equippedType = itemType.isEquippable() - ? world.model.player.inventory.getItemTypeInWearSlot(itemType.category.inventorySlot) - : null; + final ItemType equippedType = itemType.isEquippable() + ? world.model.player.inventory.getItemTypeInWearSlot(itemType.category.inventorySlot) + : null; final String buttonText = params.getString("buttonText"); boolean buttonEnabled = params.getBoolean("buttonEnabled"); - final Resources resources = getResources(); + final Resources resources = getResources(); setContentView(R.layout.iteminfo); - fillTitle(world, resources, (TextView) findViewById(R.id.iteminfo_title), itemType, (itemType == equippedType)); - fillDescription((TextView) findViewById(R.id.iteminfo_description), itemType); - fillCategory((TextView) findViewById(R.id.iteminfo_category), itemType); - fillItemEffects((ItemEffectsView) findViewById(R.id.iteminfo_effects), itemType); - fillDisplayType(resources, (TextView) findViewById(R.id.iteminfo_displaytype), itemType); - - if (equippedType != null && equippedType != itemType){ - findViewById(R.id.compareinfo).setVisibility(View.VISIBLE); - fillTitle(world, resources, (TextView) findViewById(R.id.compareinfo_title), equippedType, true); - fillDescription((TextView) findViewById(R.id.compareinfo_description), equippedType); - fillCategory((TextView) findViewById(R.id.compareinfo_category), equippedType); - fillItemEffects((ItemEffectsView) findViewById(R.id.compareinfo_effects), equippedType); - fillDisplayType(resources, (TextView) findViewById(R.id.compareinfo_displaytype), equippedType); - } else { - findViewById(R.id.compareinfo).setVisibility(View.GONE); - } + fillTitle(world, resources, (TextView) findViewById(R.id.iteminfo_title), itemType, (itemType == equippedType)); + fillDescription((TextView) findViewById(R.id.iteminfo_description), itemType); + fillCategory((TextView) findViewById(R.id.iteminfo_category), itemType); + fillItemEffects((ItemEffectsView) findViewById(R.id.iteminfo_effects), itemType); + fillDisplayType(resources, (TextView) findViewById(R.id.iteminfo_displaytype), itemType); + + if (equippedType != null && equippedType != itemType){ + findViewById(R.id.compareinfo).setVisibility(View.VISIBLE); + fillTitle(world, resources, (TextView) findViewById(R.id.compareinfo_title), equippedType, true); + fillDescription((TextView) findViewById(R.id.compareinfo_description), equippedType); + fillCategory((TextView) findViewById(R.id.compareinfo_category), equippedType); + fillItemEffects((ItemEffectsView) findViewById(R.id.compareinfo_effects), equippedType); + fillDisplayType(resources, (TextView) findViewById(R.id.compareinfo_displaytype), equippedType); + } else { + findViewById(R.id.compareinfo).setVisibility(View.GONE); + } Button b = (Button) findViewById(R.id.iteminfo_close); b.setOnClickListener(new OnClickListener() { @@ -92,45 +92,45 @@ public void onClick(View arg0) { } - private static void fillTitle(WorldContext world, Resources resources, TextView tv, ItemType itemType, boolean equipped) { - tv.setText(itemType.getName(world.model.player) + (equipped ? " " + resources.getString(R.string.iteminfo_title_equipped) : "")); - world.tileManager.setImageViewTileForSingleItemType(resources, tv, itemType); - - } - - private static void fillCategory(TextView tv, ItemType itemType) { - tv.setText(itemType.category.displayName); - } - - private static void fillDisplayType(Resources resources, TextView tv, ItemType itemType) { - if (itemType.isOrdinaryItem()) { - tv.setVisibility(View.GONE); - } else { - tv.setVisibility(View.VISIBLE); - final String diplayType = getDisplayTypeString(resources, itemType); - tv.setText(diplayType); - } - } - - private static void fillItemEffects(ItemEffectsView iev, ItemType itemType) { - iev.update( - itemType.effects_equip, - itemType.effects_use == null ? null : Collections.singletonList(itemType.effects_use), - itemType.effects_hit == null ? null : Collections.singletonList(itemType.effects_hit), - itemType.effects_kill == null ? null : Collections.singletonList(itemType.effects_kill), - itemType.isWeapon() - ); - } - - private static void fillDescription(TextView tv, ItemType itemType) { - String description = itemType.getDescription(); - if (description != null) { - tv.setText(description); - tv.setVisibility(View.VISIBLE); - } else { - tv.setVisibility(View.GONE); - } - } + private static void fillTitle(WorldContext world, Resources resources, TextView tv, ItemType itemType, boolean equipped) { + tv.setText(itemType.getName(world.model.player) + (equipped ? " " + resources.getString(R.string.iteminfo_title_equipped) : "")); + world.tileManager.setImageViewTileForSingleItemType(resources, tv, itemType); + + } + + private static void fillCategory(TextView tv, ItemType itemType) { + tv.setText(itemType.category.displayName); + } + + private static void fillDisplayType(Resources resources, TextView tv, ItemType itemType) { + if (itemType.isOrdinaryItem()) { + tv.setVisibility(View.GONE); + } else { + tv.setVisibility(View.VISIBLE); + final String diplayType = getDisplayTypeString(resources, itemType); + tv.setText(diplayType); + } + } + + private static void fillItemEffects(ItemEffectsView iev, ItemType itemType) { + iev.update( + itemType.effects_equip, + itemType.effects_use == null ? null : Collections.singletonList(itemType.effects_use), + itemType.effects_hit == null ? null : Collections.singletonList(itemType.effects_hit), + itemType.effects_kill == null ? null : Collections.singletonList(itemType.effects_kill), + itemType.isWeapon() + ); + } + + private static void fillDescription(TextView tv, ItemType itemType) { + String description = itemType.getDescription(); + if (description != null) { + tv.setText(description); + tv.setVisibility(View.VISIBLE); + } else { + tv.setVisibility(View.GONE); + } + } public static String getDisplayTypeString(Resources res, ItemType itemType) { From 388af45f0d9caed64ce179291afab0e5f5b8395d Mon Sep 17 00:00:00 2001 From: codernator Date: Tue, 24 Mar 2015 23:30:13 -0400 Subject: [PATCH 3/5] Issue 40 - Show info for both equipped rings when appropriate. Show info for both weapons or weapon and shield when appropriate. --- AndorsTrail/res/layout/iteminfo.xml | 56 ++++++++++++++++++- .../activity/ItemInfoActivity.java | 36 ++++++++++-- 2 files changed, 86 insertions(+), 6 deletions(-) diff --git a/AndorsTrail/res/layout/iteminfo.xml b/AndorsTrail/res/layout/iteminfo.xml index 2cdc37e39..678a76ef1 100644 --- a/AndorsTrail/res/layout/iteminfo.xml +++ b/AndorsTrail/res/layout/iteminfo.xml @@ -65,8 +65,6 @@ android:layout_height="wrap_content" /> - - + + + + + + + + + + + + + diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ItemInfoActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ItemInfoActivity.java index e30fcadd0..c46db0b73 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ItemInfoActivity.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ItemInfoActivity.java @@ -11,6 +11,7 @@ import com.gpl.rpg.AndorsTrail.AndorsTrailApplication; import com.gpl.rpg.AndorsTrail.R; import com.gpl.rpg.AndorsTrail.context.WorldContext; +import com.gpl.rpg.AndorsTrail.model.item.Inventory; import com.gpl.rpg.AndorsTrail.model.item.ItemType; import com.gpl.rpg.AndorsTrail.view.ItemEffectsView; @@ -35,9 +36,25 @@ public void onCreate(Bundle savedInstanceState) { Bundle params = intent.getExtras(); String itemTypeID = params.getString("itemTypeID"); final ItemType itemType = world.itemTypes.getItemType(itemTypeID); - final ItemType equippedType = itemType.isEquippable() - ? world.model.player.inventory.getItemTypeInWearSlot(itemType.category.inventorySlot) - : null; + final ItemType equippedType; + final ItemType secondaryEquippedType; + + if (itemType.isEquippable()) { + equippedType = world.model.player.inventory.getItemTypeInWearSlot(itemType.category.inventorySlot); + if (itemType.category.inventorySlot == Inventory.WearSlot.leftring) + { + secondaryEquippedType = world.model.player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.rightring); + } else if (itemType.category.inventorySlot == Inventory.WearSlot.weapon) { + secondaryEquippedType = world.model.player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.shield); + } else { + secondaryEquippedType = null; + } + } else { + equippedType = null; + secondaryEquippedType = null; + } + + final String buttonText = params.getString("buttonText"); boolean buttonEnabled = params.getBoolean("buttonEnabled"); @@ -45,7 +62,7 @@ public void onCreate(Bundle savedInstanceState) { setContentView(R.layout.iteminfo); - fillTitle(world, resources, (TextView) findViewById(R.id.iteminfo_title), itemType, (itemType == equippedType)); + fillTitle(world, resources, (TextView) findViewById(R.id.iteminfo_title), itemType, (itemType == equippedType || itemType == secondaryEquippedType)); fillDescription((TextView) findViewById(R.id.iteminfo_description), itemType); fillCategory((TextView) findViewById(R.id.iteminfo_category), itemType); fillItemEffects((ItemEffectsView) findViewById(R.id.iteminfo_effects), itemType); @@ -62,6 +79,17 @@ public void onCreate(Bundle savedInstanceState) { findViewById(R.id.compareinfo).setVisibility(View.GONE); } + if (secondaryEquippedType != null && itemType != secondaryEquippedType && equippedType != secondaryEquippedType) { + findViewById(R.id.compare2info).setVisibility(View.VISIBLE); + fillTitle(world, resources, (TextView) findViewById(R.id.compare2info_title), secondaryEquippedType, true); + fillDescription((TextView) findViewById(R.id.compare2info_description), secondaryEquippedType); + fillCategory((TextView) findViewById(R.id.compare2info_category), secondaryEquippedType); + fillItemEffects((ItemEffectsView) findViewById(R.id.compare2info_effects), secondaryEquippedType); + fillDisplayType(resources, (TextView) findViewById(R.id.compare2info_displaytype), secondaryEquippedType); + } else { + findViewById(R.id.compare2info).setVisibility(View.GONE); + } + Button b = (Button) findViewById(R.id.iteminfo_close); b.setOnClickListener(new OnClickListener() { @Override From 9f387eb2348f2511c504aa9bbfddb6b6db7383fe Mon Sep 17 00:00:00 2001 From: codernator Date: Tue, 24 Mar 2015 23:32:25 -0400 Subject: [PATCH 4/5] Spaces to tabs. :/ --- .../activity/ItemInfoActivity.java | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ItemInfoActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ItemInfoActivity.java index c46db0b73..f5e690282 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ItemInfoActivity.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ItemInfoActivity.java @@ -36,23 +36,23 @@ public void onCreate(Bundle savedInstanceState) { Bundle params = intent.getExtras(); String itemTypeID = params.getString("itemTypeID"); final ItemType itemType = world.itemTypes.getItemType(itemTypeID); - final ItemType equippedType; - final ItemType secondaryEquippedType; - - if (itemType.isEquippable()) { - equippedType = world.model.player.inventory.getItemTypeInWearSlot(itemType.category.inventorySlot); - if (itemType.category.inventorySlot == Inventory.WearSlot.leftring) - { - secondaryEquippedType = world.model.player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.rightring); - } else if (itemType.category.inventorySlot == Inventory.WearSlot.weapon) { - secondaryEquippedType = world.model.player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.shield); - } else { - secondaryEquippedType = null; - } - } else { - equippedType = null; - secondaryEquippedType = null; - } + final ItemType equippedType; + final ItemType secondaryEquippedType; + + if (itemType.isEquippable()) { + equippedType = world.model.player.inventory.getItemTypeInWearSlot(itemType.category.inventorySlot); + if (itemType.category.inventorySlot == Inventory.WearSlot.leftring) + { + secondaryEquippedType = world.model.player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.rightring); + } else if (itemType.category.inventorySlot == Inventory.WearSlot.weapon) { + secondaryEquippedType = world.model.player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.shield); + } else { + secondaryEquippedType = null; + } + } else { + equippedType = null; + secondaryEquippedType = null; + } @@ -79,16 +79,16 @@ public void onCreate(Bundle savedInstanceState) { findViewById(R.id.compareinfo).setVisibility(View.GONE); } - if (secondaryEquippedType != null && itemType != secondaryEquippedType && equippedType != secondaryEquippedType) { - findViewById(R.id.compare2info).setVisibility(View.VISIBLE); - fillTitle(world, resources, (TextView) findViewById(R.id.compare2info_title), secondaryEquippedType, true); - fillDescription((TextView) findViewById(R.id.compare2info_description), secondaryEquippedType); - fillCategory((TextView) findViewById(R.id.compare2info_category), secondaryEquippedType); - fillItemEffects((ItemEffectsView) findViewById(R.id.compare2info_effects), secondaryEquippedType); - fillDisplayType(resources, (TextView) findViewById(R.id.compare2info_displaytype), secondaryEquippedType); - } else { - findViewById(R.id.compare2info).setVisibility(View.GONE); - } + if (secondaryEquippedType != null && itemType != secondaryEquippedType && equippedType != secondaryEquippedType) { + findViewById(R.id.compare2info).setVisibility(View.VISIBLE); + fillTitle(world, resources, (TextView) findViewById(R.id.compare2info_title), secondaryEquippedType, true); + fillDescription((TextView) findViewById(R.id.compare2info_description), secondaryEquippedType); + fillCategory((TextView) findViewById(R.id.compare2info_category), secondaryEquippedType); + fillItemEffects((ItemEffectsView) findViewById(R.id.compare2info_effects), secondaryEquippedType); + fillDisplayType(resources, (TextView) findViewById(R.id.compare2info_displaytype), secondaryEquippedType); + } else { + findViewById(R.id.compare2info).setVisibility(View.GONE); + } Button b = (Button) findViewById(R.id.iteminfo_close); b.setOnClickListener(new OnClickListener() { From 5d6903bd1eed224db78191057d325af210e293a8 Mon Sep 17 00:00:00 2001 From: codernator Date: Tue, 24 Mar 2015 23:33:14 -0400 Subject: [PATCH 5/5] Spaces to tabs. :/ --- AndorsTrail/res/layout/iteminfo.xml | 222 ++++++++++++++-------------- 1 file changed, 111 insertions(+), 111 deletions(-) diff --git a/AndorsTrail/res/layout/iteminfo.xml b/AndorsTrail/res/layout/iteminfo.xml index 678a76ef1..f7b5836c7 100644 --- a/AndorsTrail/res/layout/iteminfo.xml +++ b/AndorsTrail/res/layout/iteminfo.xml @@ -65,117 +65,117 @@ android:layout_height="wrap_content" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + +