diff --git a/AndorsTrail/res/layout-land/heroinfo_inventory.xml b/AndorsTrail/res/layout-land/heroinfo_inventory.xml
index c48730d39..19a00479b 100644
--- a/AndorsTrail/res/layout-land/heroinfo_inventory.xml
+++ b/AndorsTrail/res/layout-land/heroinfo_inventory.xml
@@ -41,6 +41,35 @@
android:orientation="vertical"
android:gravity="left"
>
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/AndorsTrail/res/layout/heroinfo_inventory.xml b/AndorsTrail/res/layout/heroinfo_inventory.xml
index 3ca4ba0f6..557b4b119 100644
--- a/AndorsTrail/res/layout/heroinfo_inventory.xml
+++ b/AndorsTrail/res/layout/heroinfo_inventory.xml
@@ -4,39 +4,85 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- android:gravity="left"
>
-
-
-
+
-
+
+
+
+
+
+
+
-
+ android:orientation="vertical"
+ android:gravity="left"
+ >
+
+
-
+
+
-
\ No newline at end of file
+
+
+
+
+
+
+
diff --git a/AndorsTrail/res/layout/heroinfo_skill_list.xml b/AndorsTrail/res/layout/heroinfo_skill_list.xml
index a764e30bd..b851d7d18 100644
--- a/AndorsTrail/res/layout/heroinfo_skill_list.xml
+++ b/AndorsTrail/res/layout/heroinfo_skill_list.xml
@@ -1,23 +1,65 @@
-
+
+
+ android:layout_marginBottom="5dp"
+ android:layout_marginTop="10dp"
+ android:gravity="right"
+ android:orientation="horizontal">
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
-
+
\ No newline at end of file
diff --git a/AndorsTrail/res/layout/quickbuttons_usable_inventory.xml b/AndorsTrail/res/layout/quickbuttons_usable_inventory.xml
new file mode 100644
index 000000000..af06d9345
--- /dev/null
+++ b/AndorsTrail/res/layout/quickbuttons_usable_inventory.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AndorsTrail/res/layout/shoplist.xml b/AndorsTrail/res/layout/shoplist.xml
index 2b871b54f..5f6e93784 100644
--- a/AndorsTrail/res/layout/shoplist.xml
+++ b/AndorsTrail/res/layout/shoplist.xml
@@ -1,21 +1,38 @@
-
+ android:orientation="vertical">
-
+ android:layout_marginBottom="5dp"
+ android:layout_marginTop="10dp"
+ android:gravity="right"
+ android:orientation="horizontal"
+ android:layout_alignParentRight="true">
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/AndorsTrail/res/raw/actorconditions_v0611.json b/AndorsTrail/res/raw/actorconditions_v0611.json
index 333e28f4e..3ebf019c1 100644
--- a/AndorsTrail/res/raw/actorconditions_v0611.json
+++ b/AndorsTrail/res/raw/actorconditions_v0611.json
@@ -41,6 +41,7 @@
"iconID":"actorconditions_1:70",
"name":"Focused damage",
"category":"mental",
+ "isPositive":1,
"abilityEffect":{
"increaseAttackDamage":{
"min":3,
@@ -54,6 +55,7 @@
"iconID":"actorconditions_1:98",
"name":"Focused accuracy",
"category":"mental",
+ "isPositive":1,
"abilityEffect":{
"increaseAttackChance":40,
"increaseAttackCost":1
@@ -64,7 +66,7 @@
"iconID":"actorconditions_1:60",
"name":"Irdegh poison",
"category":"blood",
- "stacking":1,
+ "isStacking":1,
"roundEffect":{
"visualEffectID":"greenSplash",
"increaseCurrentHP":{
@@ -73,4 +75,4 @@
}
}
}
-]
\ No newline at end of file
+]
diff --git a/AndorsTrail/res/raw/actorconditions_v0611_2.json b/AndorsTrail/res/raw/actorconditions_v0611_2.json
index 60acf2e4b..39b85dee1 100644
--- a/AndorsTrail/res/raw/actorconditions_v0611_2.json
+++ b/AndorsTrail/res/raw/actorconditions_v0611_2.json
@@ -15,6 +15,7 @@
"iconID":"actorconditions_1:70",
"name":"Blessing of Shadow strength",
"category":"spiritual",
+ "isPositive":1,
"abilityEffect":{
"increaseAttackDamage":{
"min":1,
@@ -27,6 +28,7 @@
"iconID":"actorconditions_1:35",
"name":"Blessing of Shadow regeneration",
"category":"spiritual",
+ "isPositive":1,
"roundEffect":{
"visualEffectID":"blueSwirl",
"increaseCurrentHP":{
@@ -40,6 +42,7 @@
"iconID":"actorconditions_1:98",
"name":"Blessing of Shadow accuracy",
"category":"spiritual",
+ "isPositive":1,
"abilityEffect":{
"increaseAttackChance":30
}
@@ -49,6 +52,7 @@
"iconID":"actorconditions_1:91",
"name":"Shadow guardian blessing",
"category":"spiritual",
+ "isPositive":1,
"abilityEffect":{
"increaseMaxHP":30,
"increaseDamageResistance":1
@@ -59,7 +63,7 @@
"iconID":"actorconditions_1:89",
"name":"Internal bleeding",
"category":"physical",
- "stacking":1,
+ "isStacking":1,
"abilityEffect":{
"increaseAttackChance":-50,
"increaseAttackDamage":{
@@ -74,7 +78,7 @@
"iconID":"actorconditions_1:89",
"name":"Fracture",
"category":"physical",
- "stacking":1,
+ "isStacking":1,
"abilityEffect":{
"increaseBlockChance":-50,
"increaseDamageResistance":-2
@@ -85,9 +89,9 @@
"iconID":"actorconditions_1:80",
"name":"Concussion",
"category":"physical",
- "stacking":1,
+ "isStacking":1,
"abilityEffect":{
"increaseAttackChance":-30
}
}
-]
\ No newline at end of file
+]
diff --git a/AndorsTrail/res/raw/actorconditions_v0612_2.json b/AndorsTrail/res/raw/actorconditions_v0612_2.json
index 3c7865368..e082784e9 100644
--- a/AndorsTrail/res/raw/actorconditions_v0612_2.json
+++ b/AndorsTrail/res/raw/actorconditions_v0612_2.json
@@ -4,6 +4,7 @@
"iconID":"actorconditions_1:35",
"name":"Sustenance",
"category":"physical",
+ "isPositive":1,
"roundEffect":{
"increaseCurrentHP":{
"min":1,
@@ -23,4 +24,4 @@
}
}
}
-]
\ No newline at end of file
+]
diff --git a/AndorsTrail/res/raw/actorconditions_v069.json b/AndorsTrail/res/raw/actorconditions_v069.json
index d30250724..87275e1f7 100644
--- a/AndorsTrail/res/raw/actorconditions_v069.json
+++ b/AndorsTrail/res/raw/actorconditions_v069.json
@@ -4,6 +4,7 @@
"iconID":"actorconditions_1:41",
"name":"Bless",
"category":"spiritual",
+ "isPositive":1,
"abilityEffect":{
"increaseAttackChance":5
}
@@ -26,6 +27,7 @@
"iconID":"actorconditions_1:70",
"name":"Strength",
"category":"physical",
+ "isPositive":1,
"abilityEffect":{
"increaseAttackDamage":{
"min":1,
@@ -38,6 +40,7 @@
"iconID":"actorconditions_1:35",
"name":"Shadow Regeneration",
"category":"spiritual",
+ "isPositive":1,
"roundEffect":{
"visualEffectID":"blueSwirl",
"increaseCurrentHP":{
@@ -46,4 +49,4 @@
}
}
}
-]
\ No newline at end of file
+]
diff --git a/AndorsTrail/res/raw/actorconditions_v069_bwm.json b/AndorsTrail/res/raw/actorconditions_v069_bwm.json
index 3f8c94cf4..45a3f5004 100644
--- a/AndorsTrail/res/raw/actorconditions_v069_bwm.json
+++ b/AndorsTrail/res/raw/actorconditions_v069_bwm.json
@@ -4,6 +4,7 @@
"iconID":"actorconditions_1:87",
"name":"Minor speed",
"category":"physical",
+ "isPositive":1,
"abilityEffect":{
"increaseMaxAP":2
}
@@ -39,7 +40,7 @@
"iconID":"actorconditions_2:0",
"name":"Bleeding wound",
"category":"blood",
- "stacking":1,
+ "isStacking":1,
"roundEffect":{
"visualEffectID":"redSplash",
"increaseCurrentHP":{
@@ -53,6 +54,7 @@
"iconID":"actorconditions_1:90",
"name":"Minor berserker rage",
"category":"mental",
+ "isPositive":1,
"abilityEffect":{
"increaseAttackChance":60,
"increaseMaxHP":35,
@@ -76,6 +78,7 @@
"iconID":"actorconditions_2:1",
"name":"Intoxicated",
"category":"mental",
+ "isPositive":1,
"abilityEffect":{
"increaseAttackChance":-30,
"increaseAttackDamage":{
@@ -95,4 +98,4 @@
"increaseBlockChance":-40
}
}
-]
\ No newline at end of file
+]
diff --git a/AndorsTrail/res/raw/actorconditions_v070.json b/AndorsTrail/res/raw/actorconditions_v070.json
index 18a7d6e60..064afb81d 100644
--- a/AndorsTrail/res/raw/actorconditions_v070.json
+++ b/AndorsTrail/res/raw/actorconditions_v070.json
@@ -194,4 +194,4 @@
}
}
}
-]
\ No newline at end of file
+]
diff --git a/AndorsTrail/res/raw/conversationlist_debug.json b/AndorsTrail/res/raw/conversationlist_debug.json
index c8a3cef14..cb1c03c00 100644
--- a/AndorsTrail/res/raw/conversationlist_debug.json
+++ b/AndorsTrail/res/raw/conversationlist_debug.json
@@ -192,7 +192,19 @@
"replies":[
{
"nextPhraseID":"npc3_1",
- "text":"Beer !"
+ "text":"Beer!"
+ },
+ {
+ "nextPhraseID":"npc3_2",
+ "text":"Lights out!"
+ },
+ {
+ "nextPhraseID":"npc3_3",
+ "text":"Lights on!"
+ },
+ {
+ "nextPhraseID":"npc3_4",
+ "text":"Red ligths!"
}
]
},
@@ -220,5 +232,38 @@
{
"message":"No beer for you !",
"id":"signnobeer"
- }
+ },
+ {
+ "id":"npc3_2",
+ "message":"Ok.",
+ "rewards":[
+ {
+ "rewardType":"changeMapFilter",
+ "rewardID":"black80",
+ "mapName":"debugmap"
+ }
+ ]
+ },
+ {
+ "id":"npc3_3",
+ "message":"Ok.",
+ "rewards":[
+ {
+ "rewardType":"changeMapFilter",
+ "rewardID":"none",
+ "mapName":"debugmap"
+ }
+ ]
+ },
+ {
+ "id":"npc3_4",
+ "message":"Ok.",
+ "rewards":[
+ {
+ "rewardType":"changeMapFilter",
+ "rewardID":"redtint",
+ "mapName":"debugmap"
+ }
+ ]
+ }
]
diff --git a/AndorsTrail/res/values/arrays.xml b/AndorsTrail/res/values/arrays.xml
index da1fd0406..6a7c65b3f 100644
--- a/AndorsTrail/res/values/arrays.xml
+++ b/AndorsTrail/res/values/arrays.xml
@@ -8,6 +8,56 @@
- @string/questlog_includecompleted_onlycompleted
+
+
+ - @string/inventory_category_all
+ - @string/inventory_category_weapons
+ - @string/inventory_category_armor
+ - @string/inventory_category_usable
+ - @string/inventory_category_quest
+ - @string/inventory_category_other
+
+
+
+
+ - @string/inventory_sort_custom
+ - @string/inventory_sort_name
+ - @string/inventory_sort_price
+ - @string/inventory_sort_quantity
+ - @string/inventory_sort_rarity
+ - @string/inventory_sort_type
+
+
+
+
+ - @string/skill_category_all
+ - @string/skill_category_offense
+ - @string/skill_category_defense
+ - @string/skill_category_criticals
+ - @string/skill_category_immunity
+ - @string/skill_category_utility
+ - @string/skill_category_speciality
+ - @string/skill_category_proficiency
+
+
+
+
+ - @string/skill_sort_unsorted
+ - @string/skill_sort_name
+ - @string/skill_sort_points
+ - @string/skill_sort_unlocked
+
+
+
+
+ - @string/shoplist_sort_custom
+ - @string/shoplist_sort_name
+ - @string/shoplist_sort_price
+ - @string/shoplist_sort_quantity
+ - @string/shoplist_sort_rarity
+ - @string/shoplist_sort_type
+
+
- @string/preferences_display_loot_dialog
- @string/preferences_display_loot_dialog_on_items
diff --git a/AndorsTrail/res/values/authors.xml b/AndorsTrail/res/values/authors.xml
index 3078720ad..b736163ba 100644
--- a/AndorsTrail/res/values/authors.xml
+++ b/AndorsTrail/res/values/authors.xml
@@ -18,6 +18,7 @@
Additional programming by <a href="https://github.com/Zukero">Kevin Pochat</a><br />
Additional programming by Lucas Delvallet<br />
Additional programming by Florian Doublet<br />
+ Additional programming by M.H. Alkotob<br />
Additional graphics by Karvis<br />
Russian translation by Dreamer..., e.solodookhin, shell.andor, konstmih, istasman, Aleksey Kabanov, Alexander Zubok, Paul Sulemenkov and dromoz<br />
Italian translation by k6blue, liogiu, Joker and Andrea Luciano Damico<br />
diff --git a/AndorsTrail/res/values/strings.xml b/AndorsTrail/res/values/strings.xml
index b19ccd1ce..850684e9b 100644
--- a/AndorsTrail/res/values/strings.xml
+++ b/AndorsTrail/res/values/strings.xml
@@ -33,11 +33,15 @@
Overview
Items
Skills
+ Category
+ Sort
Level up
Level
Total experience
Worn equipment
Inventory
+ Category
+ Sort By
Gold: %1$d
Action points (AP):
Quests
@@ -142,6 +146,7 @@
Your gold: %1$d
%1$s bought.
%1$s sold.
+ Sort
Level up
Welcome to level %1$d!
@@ -322,6 +327,7 @@
Double size
Assign quick slot
+ Select item to assign
Slot 1
Slot 2
Slot 3
@@ -630,4 +636,39 @@ Every skill level increases the attack chance of weapons with %1$d %% of their o
Use translation of interface and content, where available. (requires restart)
Changing locale requires restart. Andor\'s Trail has been closed.
+ All
+ Favorites
+ Weapon
+ Armor
+ Consumable
+ Quest Item
+ Other
+
+ Unsorted
+ Name
+ Price
+ Quantity
+ Rarity
+ Type
+
+ Unsorted
+ Name
+ Price
+ Quantity
+ Rarity
+ Type
+
+ All
+ Offense
+ Defense
+ Criticals
+ Immunity
+ Utility
+ Speciality
+ Proficiency
+
+ Unsorted
+ Name
+ Points
+ Unlocked
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java
index 2985390fb..cf6306240 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java
@@ -1,14 +1,22 @@
package com.gpl.rpg.AndorsTrail.activity;
import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.*;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.View.OnClickListener;
+import android.view.View.OnLongClickListener;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.Button;
+import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
+
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
import com.gpl.rpg.AndorsTrail.AndorsTrailPreferences;
import com.gpl.rpg.AndorsTrail.Dialogs;
@@ -27,6 +35,7 @@ import com.gpl.rpg.AndorsTrail.model.item.ItemContainer.ItemEntry;
import com.gpl.rpg.AndorsTrail.model.item.Loot;
import com.gpl.rpg.AndorsTrail.model.map.MapObject;
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
+import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
import com.gpl.rpg.AndorsTrail.savegames.Savegames;
import com.gpl.rpg.AndorsTrail.util.Coord;
import com.gpl.rpg.AndorsTrail.view.*;
@@ -59,7 +68,8 @@ public final class MainActivity
private TextView statusText;
private WeakReference lastToast = null;
- private ContextMenuInfo lastSelectedMenu = null;
+ //private ContextMenuInfo lastSelectedMenu = null;
+ private OnLongClickListener quickButtonLongClickListener = null;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -95,6 +105,7 @@ public final class MainActivity
new DebugInterface(controllers, world, this).addDebugButtons();
quickitemview.setVisibility(View.GONE);
+ createLongClickListener();
quickitemview.registerForContextMenu(this);
dpad.updateVisibility(preferences);
@@ -194,48 +205,97 @@ public final class MainActivity
combatview.subscribe();
activeConditions.subscribe();
}
+
- @Override
- public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
- super.onCreateContextMenu(menu, v, menuInfo);
- if(quickitemview.isQuickButtonId(v.getId())){
- createQuickButtonMenu(menu);
- }
- lastSelectedMenu = null;
+ public void registerForLongClick(QuickButton item) {
+ item.setOnLongClickListener(quickButtonLongClickListener);
}
- private void createQuickButtonMenu(ContextMenu menu){
- menu.add(Menu.NONE, R.id.quick_menu_unassign, Menu.NONE, R.string.inventory_unassign);
- SubMenu assignMenu = menu.addSubMenu(Menu.NONE, R.id.quick_menu_assign, Menu.NONE, R.string.inventory_assign);
- for(int i=0; i parent, View view, int position, long id) {
+ controllers.itemController.setQuickItem(inventoryListAdapter.getItem(position).itemType, buttonId);
+ dialog.dismiss();
+ }
+ });
+
+// Button b = (Button) view.findViewById(R.id.quickbuttons_unassign);
+// b.setOnClickListener(new OnClickListener() {
+// @Override
+// public void onClick(View v) {
+// controllers.itemController.setQuickItem(null, buttonId);
+// dialog.dismiss();
+// }
+// });
+
+ dialog.setView(view);
+ dialog.setCancelable(true);
+ dialog.show();
+ }
+ return true;
+ }
+ };
}
+
+// @Override
+// public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
+//
+// super.onCreateContextMenu(menu, v, menuInfo);
+// if(quickitemview.isQuickButtonId(v.getId())){
+// createQuickButtonMenu(menu);
+// }
+// lastSelectedMenu = null;
+// }
+//
+// private void createQuickButtonMenu(ContextMenu menu){
+// menu.add(Menu.NONE, R.id.quick_menu_unassign, Menu.NONE, R.string.inventory_unassign);
+// SubMenu assignMenu = menu.addSubMenu(Menu.NONE, R.id.quick_menu_assign, Menu.NONE, R.string.inventory_assign);
+// for(int i=0; i parent, View v, int position, long id) {
- ItemType itemType = inventoryListAdapter.getItem(position).itemType;
+ // Move this code to separate function? -- Done
+ ItemType itemType = getSelectedItemType(position);
showInventoryItemInfo(itemType.id);
}
});
+
ItemContainer inv = player.inventory;
wornTiles = world.tileManager.loadTilesFor(player.inventory, getResources());
inventoryListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, inv, player, wornTiles);
@@ -93,6 +111,52 @@ public final class HeroinfoActivity_Inventory extends Fragment {
return v;
}
+ private void initialiseInventorySpinners(View v) {
+ inventorylist_categories = (Spinner) v.findViewById(R.id.inventorylist_category_filters);
+ ArrayAdapter categoryFilterAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.inventorylist_category_filters, android.R.layout.simple_spinner_item);
+ categoryFilterAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ inventorylist_categories.setAdapter(categoryFilterAdapter);
+ inventorylist_categories.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView> arg0, View arg1, int arg2, long arg3) {
+ world.model.uiSelections.selectedInventoryCategory = inventorylist_categories.getSelectedItemPosition();
+ reloadShownCategory(world.model.uiSelections.selectedInventoryCategory);
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> arg0) {
+ world.model.uiSelections.selectedInventoryCategory = 0;
+ }
+ });
+ inventorylist_categories.setSelection(world.model.uiSelections.selectedInventoryCategory);
+
+
+ inventorylist_sort = (Spinner) v.findViewById(R.id.inventorylist_sort_filters);
+ ArrayAdapter sortFilterAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.inventorylist_sort_filters, android.R.layout.simple_spinner_item);
+ sortFilterAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ inventorylist_sort.setAdapter(sortFilterAdapter);
+ inventorylist_sort.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView> parent, View view, int position, long id) {
+ world.model.uiSelections.selectedInventorySort = inventorylist_sort.getSelectedItemPosition();
+ reloadShownSort(player.inventory);
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> parent) {
+ // Reset to "Custom" position
+ world.model.uiSelections.selectedInventorySort = 0;
+ }
+ });
+ inventorylist_sort.setSelection(world.model.uiSelections.selectedInventorySort);
+ }
+
+ private void setHeroStatsVisiblity(int visibility) {
+ heroinfo_stats_gold.setVisibility(visibility);
+ heroinfo_stats_attack.setVisibility(visibility);
+ heroinfo_stats_defense.setVisibility(visibility);
+ }
+
@Override
public void onStart() {
super.onStart();
@@ -201,7 +265,11 @@ public final class HeroinfoActivity_Inventory extends Fragment {
}
private void updateItemList() {
- inventoryListAdapter.notifyDataSetChanged();
+ int currentScreen = world.model.uiSelections.selectedInventoryCategory;
+ if (currentScreen == 0)
+ inventoryListAdapter.notifyDataSetChanged();
+ else
+ reloadShownCategory(world.model.uiSelections.selectedInventoryCategory);
}
@Override
@@ -226,6 +294,29 @@ public final class HeroinfoActivity_Inventory extends Fragment {
lastSelectedItem = null;
}
+ private ItemType getSelectedItemType(int position) {
+ int v = world.model.uiSelections.selectedInventoryCategory;
+
+ if (v == 0) { //All items
+ return inventoryListAdapter.getItem(position).itemType;
+ }else if (v == 1) { //Weapon items
+ return inventoryWeaponsListAdapter.getItem(position).itemType;
+ } else if (v == 2) { //Armor items
+ return inventoryArmorListAdapter.getItem(position).itemType;
+ } else if (v == 3) { //Usable items
+ return inventoryUsableListAdapter.getItem(position).itemType;
+ } else if (v == 4) { //Quest items
+ return inventoryQuestListAdapter.getItem(position).itemType;
+ } else if (v == 5) { //Other items
+ return inventoryOtherListAdapter.getItem(position).itemType;
+ }
+
+ // Better than crashing...
+ return inventoryListAdapter.getItem(position).itemType;
+
+ }
+
+
private ItemType getSelectedItemType(AdapterContextMenuInfo info) {
return inventoryListAdapter.getItem(info.position).itemType;
}
@@ -340,4 +431,48 @@ public final class HeroinfoActivity_Inventory extends Fragment {
Intent intent = Dialogs.getIntentForItemInfo(getActivity(), itemType.id, action, text, enabled, null);
startActivityForResult(intent, INTENTREQUEST_ITEMINFO);
}
-}
\ No newline at end of file
+
+ private void reloadShownCategory(int v) { // Apologies about the code duplication,
+ // just didn't seem to make sense as an array, although I did create a nice array for skill category adapters.
+
+ // Decide which category to show
+ if (v == 0) { //All items
+ inventoryList.setAdapter(inventoryListAdapter);
+ inventoryListAdapter.notifyDataSetChanged();
+ } else if (v == 1) { //Weapon items
+ inventoryWeaponsListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildWeaponItems(), player, wornTiles);
+ inventoryList.setAdapter(inventoryWeaponsListAdapter);
+ inventoryWeaponsListAdapter.notifyDataSetChanged();
+ } else if (v == 2) { //Armor items
+ inventoryArmorListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildArmorItems(), player, wornTiles);
+ inventoryList.setAdapter(inventoryArmorListAdapter);
+ inventoryArmorListAdapter.notifyDataSetChanged();
+ } else if (v == 3) { //Usable items
+ inventoryUsableListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildUsableItems(), player, wornTiles);
+ inventoryList.setAdapter(inventoryUsableListAdapter);
+ inventoryUsableListAdapter.notifyDataSetChanged();
+ } else if (v == 4) { //Quest items
+ inventoryQuestListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildQuestItems(), player, wornTiles);
+ inventoryList.setAdapter(inventoryQuestListAdapter);
+ inventoryQuestListAdapter.notifyDataSetChanged();
+ } else if (v == 5) { //Other items
+ inventoryOtherListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildOtherItems(), player, wornTiles);
+ inventoryList.setAdapter(inventoryOtherListAdapter);
+ inventoryOtherListAdapter.notifyDataSetChanged();
+ }
+ //updateItemList();
+ }
+
+ private void reloadShownSort(Inventory inv) {
+ int selected = world.model.uiSelections.selectedInventorySort;
+
+ inventoryListAdapter.reloadShownSort(selected, world.model.uiSelections.oldSortSelection, player.inventory, player);
+
+ // Currently not functional, perhaps because selection only updates when changed.
+ if (world.model.uiSelections.oldSortSelection == selected)
+ world.model.uiSelections.oldSortSelection = 0;
+ else world.model.uiSelections.oldSortSelection = selected;
+ updateItemList();
+ }
+
+}
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Skills.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Skills.java
index 6bd30e740..3be757014 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Skills.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Skills.java
@@ -9,7 +9,9 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ArrayAdapter;
import android.widget.ListView;
+import android.widget.Spinner;
import android.widget.TextView;
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
import com.gpl.rpg.AndorsTrail.Dialogs;
@@ -20,6 +22,7 @@ import com.gpl.rpg.AndorsTrail.model.ability.SkillCollection;
import com.gpl.rpg.AndorsTrail.model.actor.Player;
import com.gpl.rpg.AndorsTrail.view.SkillListAdapter;
+import java.util.ArrayList;
public final class HeroinfoActivity_Skills extends Fragment {
private static final int INTENTREQUEST_SKILLINFO = 12;
@@ -28,7 +31,10 @@ public final class HeroinfoActivity_Skills extends Fragment {
private ControllerContext controllers;
private Player player;
- private SkillListAdapter skillListAdapter;
+ ListView skillList;
+ private ArrayList skillListCategoryViewsAdapters = new ArrayList();
+ private Spinner skillList_categories;
+ private Spinner skillList_sort;
private TextView listskills_number_of_increases;
@Override
@@ -46,13 +52,62 @@ public final class HeroinfoActivity_Skills extends Fragment {
View v = inflater.inflate(R.layout.heroinfo_skill_list, container, false);
final Activity ctx = getActivity();
- skillListAdapter = new SkillListAdapter(ctx, world.skills.getAllSkills(), player);
- ListView skillList = (ListView) v.findViewById(R.id.heroinfo_listskills_list);
- skillList.setAdapter(skillListAdapter);
+
+ //Initiating drop-down list for category filters
+ skillList_categories = (Spinner) v.findViewById(R.id.skillList_category_filters);
+ ArrayAdapter skillCategoryFilterAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.skill_category_filters, android.R.layout.simple_spinner_item);
+ skillCategoryFilterAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ skillList_categories.setAdapter(skillCategoryFilterAdapter);
+ skillList_categories.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView> arg0, View arg1, int arg2, long arg3) {
+ world.model.uiSelections.selectedSkillCategory = skillList_categories.getSelectedItemPosition();
+ reloadShownCategory();
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> arg0) {
+ world.model.uiSelections.selectedSkillCategory = 0;
+ }
+ });
+ skillList_categories.setSelection(world.model.uiSelections.selectedSkillCategory);
+
+ for(int i = 0; i< SkillCollection.SkillCategory.values().length; i++){
+ // Creates a list of adapters for each category.
+ // The adapter at position 0 has all items.
+ // length + 1 in order to create an extra position for "all"
+ skillListCategoryViewsAdapters.add(
+ new SkillListAdapter(ctx, world.skills.getAllSkills(), player, i));
+ }
+
+
+ //Initiating drop-down list for sort filters
+ skillList_sort = (Spinner) v.findViewById(R.id.skillList_sort_filters);
+ ArrayAdapter skillSortFilterAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.skill_sort_filters, android.R.layout.simple_spinner_item);
+ skillSortFilterAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ skillList_sort.setAdapter(skillSortFilterAdapter);
+ skillList_sort.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView> arg0, View arg1, int arg2, long arg3) {
+ world.model.uiSelections.selectedSkillSort = skillList_sort.getSelectedItemPosition();
+ reloadShownSort(); //Yet to be implemented
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> arg0) {
+ world.model.uiSelections.selectedSkillSort = 0;
+ }
+ });
+ skillList_sort.setSelection(world.model.uiSelections.selectedSkillSort);
+
+
+ skillList = (ListView) v.findViewById(R.id.heroinfo_listskills_list);
+ skillList.setAdapter(getCurrentCategoryAdapter());
skillList.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView> parent, View v, int position, long id) {
- Intent intent = Dialogs.getIntentForSkillInfo(ctx, skillListAdapter.getItem(position).id);
+ Intent intent = Dialogs.getIntentForSkillInfo(ctx,
+ getCurrentCategoryAdapter().getItem(position).id);
startActivityForResult(intent, INTENTREQUEST_SKILLINFO);
}
});
@@ -60,6 +115,25 @@ public final class HeroinfoActivity_Skills extends Fragment {
return v;
}
+ private void reloadShownSort() {
+ int v = world.model.uiSelections.selectedSkillSort;
+ if(v ==0);
+ if(v==1) getCurrentCategoryAdapter().sortByName();
+ if(v==2) getCurrentCategoryAdapter().sortByPoints();
+ if(v==3) getCurrentCategoryAdapter().sortByUnlocked();
+
+ updateSkillList();
+ }
+
+ private void reloadShownCategory() {
+ skillList.setAdapter(getCurrentCategoryAdapter());
+ updateSkillList();
+ }
+ private SkillListAdapter getCurrentCategoryAdapter(){
+ return skillListCategoryViewsAdapters.get(
+ world.model.uiSelections.selectedSkillCategory);
+ }
+
@Override
public void onStart() {
super.onStart();
@@ -96,6 +170,6 @@ public final class HeroinfoActivity_Skills extends Fragment {
} else {
listskills_number_of_increases.setVisibility(View.GONE);
}
- skillListAdapter.notifyDataSetInvalidated();
+ getCurrentCategoryAdapter().notifyDataSetInvalidated();
}
-}
\ No newline at end of file
+}
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/ShopActivityFragment.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/ShopActivityFragment.java
index 2cc0ba64e..1aa5476f3 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/ShopActivityFragment.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/ShopActivityFragment.java
@@ -6,7 +6,10 @@ import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
import android.widget.ListView;
+import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
@@ -17,6 +20,7 @@ import com.gpl.rpg.AndorsTrail.model.actor.Monster;
import com.gpl.rpg.AndorsTrail.model.actor.Player;
import com.gpl.rpg.AndorsTrail.model.item.ItemContainer;
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
+import com.gpl.rpg.AndorsTrail.view.ItemContainerAdapter;
import com.gpl.rpg.AndorsTrail.view.ShopItemContainerAdapter;
import com.gpl.rpg.AndorsTrail.view.ShopItemContainerAdapter.OnContainerItemClickedListener;
@@ -33,6 +37,7 @@ public abstract class ShopActivityFragment extends Fragment implements OnContain
protected ItemContainer shopInventory;
private TextView shop_gc;
private ShopItemContainerAdapter listAdapter;
+ private Spinner shoplist_sort;
protected abstract boolean isSellingInterface();
@@ -66,9 +71,34 @@ public abstract class ShopActivityFragment extends Fragment implements OnContain
final boolean isSelling = isSellingInterface();
listAdapter = new ShopItemContainerAdapter(getActivity(), tiles, world.tileManager, player, isSelling ? player.inventory : shopInventory, this, isSelling);
shoplist.setAdapter(listAdapter);
+
+ //Initiating drop-down list for category filters
+ shoplist_sort = (Spinner) v.findViewById(R.id.shoplist_sort_filters);
+ ArrayAdapter sortFilterAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.shoplist_sort_filters, android.R.layout.simple_spinner_item);
+ sortFilterAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ shoplist_sort.setAdapter(sortFilterAdapter);
+ shoplist_sort.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView> arg0, View arg1, int arg2, long arg3) {
+ world.model.uiSelections.selectedShopSort = shoplist_sort.getSelectedItemPosition();
+ reloadShownSort(isSelling ? player.inventory : shopInventory);
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> arg0) {
+ world.model.uiSelections.selectedShopSort = 0;
+ }
+ });
+ shoplist_sort.setSelection(world.model.uiSelections.selectedShopSort);
+
return v;
}
+ private void reloadShownSort(ItemContainer itemContainer) {
+ listAdapter.reloadShownSort(world.model.uiSelections.selectedShopSort, itemContainer, player);
+ listAdapter.notifyDataSetChanged();
+ }
+
@Override
public void onStart() {
super.onStart();
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ConversationController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ConversationController.java
index f5a59d042..828a15f1d 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ConversationController.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ConversationController.java
@@ -22,7 +22,6 @@ import com.gpl.rpg.AndorsTrail.model.conversation.Reply;
import com.gpl.rpg.AndorsTrail.model.item.ItemTypeCollection;
import com.gpl.rpg.AndorsTrail.model.item.Loot;
import com.gpl.rpg.AndorsTrail.model.map.LayeredTileMap;
-import com.gpl.rpg.AndorsTrail.model.map.MapObject;
import com.gpl.rpg.AndorsTrail.model.map.MonsterSpawnArea;
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
import com.gpl.rpg.AndorsTrail.model.quest.QuestLogEntry;
@@ -59,12 +58,12 @@ public final class ConversationController {
}
}
- private ScriptEffectResult applyScriptEffectsForPhrase(final Player player, final Phrase phrase) {
+ private ScriptEffectResult applyScriptEffectsForPhrase(Resources res, final Player player, final Phrase phrase) {
if (phrase.scriptEffects == null || phrase.scriptEffects.length == 0) return null;
final ScriptEffectResult result = new ScriptEffectResult();
for (ScriptEffect effect : phrase.scriptEffects) {
- applyScriptEffect(player, effect, result);
+ applyScriptEffect(res, player, effect, result);
}
if (result.isEmpty()) return null;
@@ -75,7 +74,7 @@ public final class ConversationController {
return result;
}
- private void applyScriptEffect(Player player, ScriptEffect effect, ScriptEffectResult result) {
+ private void applyScriptEffect(Resources res, Player player, ScriptEffect effect, ScriptEffectResult result) {
switch (effect.type) {
case actorCondition:
addActorConditionReward(player, effect.effectID, effect.value, result);
@@ -116,9 +115,20 @@ public final class ConversationController {
case removeQuestProgress:
addRemoveQuestProgressReward(player, effect.effectID, effect.value);
break;
+ case changeMapFilter:
+ changeMapFilter(res, effect.mapName, effect.effectID);
+ break;
}
}
+ private void changeMapFilter(Resources res, String mapName, String effectID) {
+ PredefinedMap map = findMapForScriptEffect(mapName);
+ map.currentColorFilter = effectID;
+ if (world.model.currentMap == map) {
+ controllers.mapController.applyCurrentMapReplacements(res, true);
+ }
+ }
+
private void deactivateMapObjectGroup(String mapName, String mapObjectGroupID) {
PredefinedMap map = findMapForScriptEffect(mapName);
controllers.mapController.deactivateMapObjectGroup(map, mapObjectGroupID);
@@ -360,7 +370,7 @@ public final class ConversationController {
setCurrentPhrase(res, phraseID);
if (applyScriptEffects) {
- ScriptEffectResult scriptEffectResult = controllers.conversationController.applyScriptEffectsForPhrase(player, currentPhrase);
+ ScriptEffectResult scriptEffectResult = controllers.conversationController.applyScriptEffectsForPhrase(res, player, currentPhrase);
if (scriptEffectResult != null) {
listener.onScriptEffectsApplied(scriptEffectResult);
}
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ItemController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ItemController.java
index 4943b0066..c109536f8 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ItemController.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ItemController.java
@@ -210,6 +210,7 @@ public final class ItemController {
public void pickupAll(Loot loot) {
world.model.player.inventory.add(loot.items);
consumeNonItemLoot(loot);
+ checkQuickslotItemLooted(loot.items);
loot.clear();
}
public void pickupAll(Iterable lootBags) {
@@ -352,4 +353,18 @@ public final class ItemController {
world.model.player.inventory.quickitem[quickSlotId] = itemType;
quickSlotListeners.onQuickSlotChanged(quickSlotId);
}
+
+ private void checkQuickslotItemLooted(ItemContainer items) {
+ for (ItemEntry item : items.items) {
+ if (item.itemType.isUsable()) {
+ for (int i = 0; i < world.model.player.inventory.quickitem.length; i++) {
+ if (item.itemType == world.model.player.inventory.quickitem[i]) {
+ quickSlotListeners.onQuickSlotChanged(i);
+
+ }
+ }
+ }
+ }
+ }
+
}
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MapController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MapController.java
index 5e62a4938..22a8196ad 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MapController.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MapController.java
@@ -188,6 +188,13 @@ public final class MapController {
hasUpdated = true;
}
}
+ if (map.currentColorFilter != null) {
+ LayeredTileMap.ColorFilterId filter = LayeredTileMap.ColorFilterId.valueOf(map.currentColorFilter);
+ if (filter != tileMap.colorFilter) {
+ tileMap.changeColorFilter(filter);
+ hasUpdated = true;
+ }
+ }
map.lastSeenLayoutHash = tileMap.getCurrentLayoutHash();
return hasUpdated;
}
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterMovementController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterMovementController.java
index 61d3aa8e5..f31fd7c62 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterMovementController.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterMovementController.java
@@ -52,17 +52,17 @@ public final class MonsterMovementController implements EvaluateWalkable {
}
}
- public static boolean monsterCanMoveTo(final PredefinedMap map, final LayeredTileMap tilemap, final CoordRect p) {
+ public static boolean monsterCanMoveTo(final Monster movingMonster, final PredefinedMap map, final LayeredTileMap tilemap, final CoordRect p) {
if (tilemap != null) {
if (!tilemap.isWalkable(p)) return false;
}
- if (map.getMonsterAt(p) != null) return false;
+ if (map.getMonsterAt(p, movingMonster) != null) return false;
- for (MapObject m : map.eventObjects) {
- if (m == null) continue;
- if (!m.isActive) continue;
- if (!m.position.intersects(p)) continue;
- switch (m.type) {
+ for (MapObject mObj : map.eventObjects) {
+ if (mObj == null) continue;
+ if (!mObj.isActive) continue;
+ if (!mObj.position.intersects(p)) continue;
+ switch (mObj.type) {
case newmap:
case keyarea:
case rest:
@@ -90,7 +90,7 @@ public final class MonsterMovementController implements EvaluateWalkable {
} else {
determineMonsterNextPosition(m, area, world.model.player.position);
- if (!monsterCanMoveTo(map, tileMap, m.nextPosition)) {
+ if (!monsterCanMoveTo(m, map, tileMap, m.nextPosition)) {
cancelCurrentMonsterMovement(m);
return;
}
@@ -155,7 +155,7 @@ public final class MonsterMovementController implements EvaluateWalkable {
@Override
public boolean isWalkable(CoordRect r) {
- return monsterCanMoveTo(world.model.currentMap, world.model.currentTileMap, r);
+ return monsterCanMoveTo(null, world.model.currentMap, world.model.currentTileMap, r);
}
public void moveMonsterToNextPosition(final Monster m, final PredefinedMap map) {
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterSpawningController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterSpawningController.java
index fcd2c1ce7..830c0437e 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterSpawningController.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterSpawningController.java
@@ -64,7 +64,7 @@ public final class MonsterSpawningController {
p.topLeft.set(
area.topLeft.x + Constants.rnd.nextInt(area.size.width)
,area.topLeft.y + Constants.rnd.nextInt(area.size.height));
- if (!MonsterMovementController.monsterCanMoveTo(map, tileMap, p)) continue;
+ if (!MonsterMovementController.monsterCanMoveTo(null, map, tileMap, p)) continue;
if (playerPosition != null && p.contains(playerPosition)) continue;
return p.topLeft;
}
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MovementController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MovementController.java
index 989b0335b..1183f89c8 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MovementController.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MovementController.java
@@ -301,6 +301,7 @@ public final class MovementController implements TimedMessageTask.Callback {
private void cacheCurrentMapData(final Resources res, final PredefinedMap nextMap) {
LayeredTileMap mapTiles = TMXMapTranslator.readLayeredTileMap(res, world.tileManager.tileCache, nextMap);
+ mapTiles.changeColorFilter(nextMap.currentColorFilter);
TileCollection cachedTiles = world.tileManager.loadTilesFor(nextMap, mapTiles, world, res);
world.model.currentTileMap = mapTiles;
world.tileManager.currentMapTiles = cachedTiles;
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/InterfaceData.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/InterfaceData.java
index 532544b39..3d368fc47 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/InterfaceData.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/InterfaceData.java
@@ -1,6 +1,7 @@
package com.gpl.rpg.AndorsTrail.model;
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
+import com.gpl.rpg.AndorsTrail.model.item.Inventory;
import com.gpl.rpg.AndorsTrail.util.Coord;
import java.io.DataInputStream;
@@ -16,6 +17,13 @@ public final class InterfaceData {
public String selectedTabHeroInfo = "";
public int selectedQuestFilter = 0; // Should not be parceled
+ public int selectedInventoryCategory = 0; //All
+ public int selectedInventorySort = 0; //Unsorted
+ public int oldSortSelection = 0; // Later will be used for reversing ascending/descending order
+ public int selectedSkillCategory = 0; //All
+ public int selectedSkillSort = 0; //Unsorted
+ public int selectedShopSort = 0; //Unsorted
+
public InterfaceData() { }
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java
index 7a3f75e1e..7fc01dc89 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java
@@ -54,6 +54,20 @@ public final class SkillCollection {
,specializationWeaponShield
}
+ // should be in the same number &U order as in arrays.xml
+ public static enum SkillCategory {
+ all, // filler value -- don't use
+ offense,
+ defense,
+ criticals,
+ immunity, //fortitude?
+ utility, // efficiency?
+ specialty,
+ proficiency
+ }
+
+
+
public static final int PER_SKILLPOINT_INCREASE_WEAPON_CHANCE = 12;
public static final int PER_SKILLPOINT_INCREASE_WEAPON_DAMAGE_MAX = 2;
public static final int PER_SKILLPOINT_INCREASE_WEAPON_DAMAGE_MIN = 0;
@@ -124,95 +138,95 @@ public final class SkillCollection {
skills.put(skill.id.ordinal(), skill);
}
public void initialize() {
- initializeSkill(new SkillInfo(SkillID.weaponChance, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, null));
- initializeSkill(new SkillInfo(SkillID.weaponDmg, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, null));
- initializeSkill(new SkillInfo(SkillID.barter, MAX_LEVEL_BARTER, SkillInfo.LevelUpType.alwaysShown, null));
- initializeSkill(new SkillInfo(SkillID.dodge, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, null));
- initializeSkill(new SkillInfo(SkillID.barkSkin, MAX_LEVEL_BARKSKIN, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] {
+ initializeSkill(new SkillInfo(SkillID.weaponChance, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.offense, null));
+ initializeSkill(new SkillInfo(SkillID.weaponDmg, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.offense, null));
+ initializeSkill(new SkillInfo(SkillID.barter, MAX_LEVEL_BARTER, SkillInfo.LevelUpType.alwaysShown, SkillCategory.utility, null));
+ initializeSkill(new SkillInfo(SkillID.dodge, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.defense, null));
+ initializeSkill(new SkillInfo(SkillID.barkSkin, MAX_LEVEL_BARKSKIN, SkillInfo.LevelUpType.alwaysShown, SkillCategory.defense, new SkillLevelRequirement[] {
SkillLevelRequirement.requireExperienceLevels(10, 0)
,SkillLevelRequirement.requirePlayerStats(Player.StatID.blockChance, 15, 0)
}));
- initializeSkill(new SkillInfo(SkillID.moreCriticals, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, null));
- initializeSkill(new SkillInfo(SkillID.betterCriticals, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] {
+ initializeSkill(new SkillInfo(SkillID.moreCriticals, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.criticals, null));
+ initializeSkill(new SkillInfo(SkillID.betterCriticals, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.criticals, new SkillLevelRequirement[] {
SkillLevelRequirement.requireOtherSkill(SkillID.moreCriticals, 1)
}));
- initializeSkill(new SkillInfo(SkillID.speed, MAX_LEVEL_SPEED, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] {
+ initializeSkill(new SkillInfo(SkillID.speed, MAX_LEVEL_SPEED, SkillInfo.LevelUpType.alwaysShown, SkillCategory.offense, new SkillLevelRequirement[] {
SkillLevelRequirement.requireExperienceLevels(15, 0)
}));
- initializeSkill(new SkillInfo(SkillID.coinfinder, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, null));
- initializeSkill(new SkillInfo(SkillID.moreExp, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, null));
- initializeSkill(new SkillInfo(SkillID.cleave, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] {
+ initializeSkill(new SkillInfo(SkillID.coinfinder, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.utility, null));
+ initializeSkill(new SkillInfo(SkillID.moreExp, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.utility, null));
+ initializeSkill(new SkillInfo(SkillID.cleave, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.offense, new SkillLevelRequirement[] {
SkillLevelRequirement.requireOtherSkill(SkillID.weaponChance, 1)
,SkillLevelRequirement.requireOtherSkill(SkillID.weaponDmg, 1)
}));
- initializeSkill(new SkillInfo(SkillID.eater, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] {
+ initializeSkill(new SkillInfo(SkillID.eater, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, new SkillLevelRequirement[] {
SkillLevelRequirement.requirePlayerStats(Player.StatID.maxHP, 20, 20)
}));
- initializeSkill(new SkillInfo(SkillID.fortitude, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] {
+ initializeSkill(new SkillInfo(SkillID.fortitude, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, new SkillLevelRequirement[] {
SkillLevelRequirement.requireExperienceLevels(15, -10)
}));
- initializeSkill(new SkillInfo(SkillID.evasion, MAX_LEVEL_EVASION, SkillInfo.LevelUpType.alwaysShown, null));
- initializeSkill(new SkillInfo(SkillID.regeneration, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] {
+ initializeSkill(new SkillInfo(SkillID.evasion, MAX_LEVEL_EVASION, SkillInfo.LevelUpType.alwaysShown, SkillCategory.defense, null));
+ initializeSkill(new SkillInfo(SkillID.regeneration, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, new SkillLevelRequirement[] {
SkillLevelRequirement.requirePlayerStats(Player.StatID.maxHP, 30, 0)
,SkillLevelRequirement.requireOtherSkill(SkillID.fortitude, 1)
}));
- initializeSkill(new SkillInfo(SkillID.lowerExploss, MAX_LEVEL_LOWER_EXPLOSS, SkillInfo.LevelUpType.alwaysShown, null));
- initializeSkill(new SkillInfo(SkillID.magicfinder, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, null));
- initializeSkill(new SkillInfo(SkillID.resistanceMental, MAX_LEVEL_RESISTANCE, SkillInfo.LevelUpType.alwaysShown, null));
- initializeSkill(new SkillInfo(SkillID.resistancePhysical, MAX_LEVEL_RESISTANCE, SkillInfo.LevelUpType.alwaysShown, null));
- initializeSkill(new SkillInfo(SkillID.resistanceBlood, MAX_LEVEL_RESISTANCE, SkillInfo.LevelUpType.alwaysShown, null));
- initializeSkill(new SkillInfo(SkillID.shadowBless, 1, SkillInfo.LevelUpType.onlyByQuests, null));
- initializeSkill(new SkillInfo(SkillID.crit1, 1, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] {
+ initializeSkill(new SkillInfo(SkillID.lowerExploss, MAX_LEVEL_LOWER_EXPLOSS, SkillInfo.LevelUpType.alwaysShown, SkillCategory.utility, null));
+ initializeSkill(new SkillInfo(SkillID.magicfinder, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.utility, null));
+ initializeSkill(new SkillInfo(SkillID.resistanceMental, MAX_LEVEL_RESISTANCE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, null));
+ initializeSkill(new SkillInfo(SkillID.resistancePhysical, MAX_LEVEL_RESISTANCE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, null));
+ initializeSkill(new SkillInfo(SkillID.resistanceBlood, MAX_LEVEL_RESISTANCE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, null));
+ initializeSkill(new SkillInfo(SkillID.shadowBless, 1, SkillInfo.LevelUpType.onlyByQuests, SkillCategory.immunity, null));
+ initializeSkill(new SkillInfo(SkillID.crit1, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.criticals, new SkillLevelRequirement[] {
SkillLevelRequirement.requireOtherSkill(SkillID.moreCriticals, 3)
,SkillLevelRequirement.requireOtherSkill(SkillID.betterCriticals, 3)
}));
- initializeSkill(new SkillInfo(SkillID.crit2, 1, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] {
+ initializeSkill(new SkillInfo(SkillID.crit2, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.criticals, new SkillLevelRequirement[] {
SkillLevelRequirement.requireOtherSkill(SkillID.moreCriticals, 6)
,SkillLevelRequirement.requireOtherSkill(SkillID.betterCriticals, 6)
,SkillLevelRequirement.requireOtherSkill(SkillID.crit1, 1)
}));
- initializeSkill(new SkillInfo(SkillID.rejuvenation, 1, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] {
+ initializeSkill(new SkillInfo(SkillID.rejuvenation, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, new SkillLevelRequirement[] {
SkillLevelRequirement.requireOtherSkill(SkillID.resistanceBlood, 3)
,SkillLevelRequirement.requireOtherSkill(SkillID.resistanceMental, 3)
,SkillLevelRequirement.requireOtherSkill(SkillID.resistancePhysical, 3)
}));
- initializeSkill(new SkillInfo(SkillID.taunt, 1, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] {
+ initializeSkill(new SkillInfo(SkillID.taunt, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.defense, new SkillLevelRequirement[] {
SkillLevelRequirement.requireOtherSkill(SkillID.evasion, 2)
,SkillLevelRequirement.requireOtherSkill(SkillID.dodge, 4)
}));
- initializeSkill(new SkillInfo(SkillID.concussion, 1, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] {
+ initializeSkill(new SkillInfo(SkillID.concussion, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.offense, new SkillLevelRequirement[] {
SkillLevelRequirement.requireOtherSkill(SkillID.speed, 2)
,SkillLevelRequirement.requireOtherSkill(SkillID.weaponChance, 3)
,SkillLevelRequirement.requireOtherSkill(SkillID.weaponDmg, 5)
}));
- initializeSkill(new SkillInfo(SkillID.weaponProficiencyDagger, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, null));
- initializeSkill(new SkillInfo(SkillID.weaponProficiency1hsword, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, null));
- initializeSkill(new SkillInfo(SkillID.weaponProficiency2hsword, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, null));
- initializeSkill(new SkillInfo(SkillID.weaponProficiencyAxe, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, null));
- initializeSkill(new SkillInfo(SkillID.weaponProficiencyBlunt, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, null));
- initializeSkill(new SkillInfo(SkillID.weaponProficiencyUnarmed, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, null));
- initializeSkill(new SkillInfo(SkillID.armorProficiencyShield, 2, SkillInfo.LevelUpType.firstLevelRequiresQuest, null));
- initializeSkill(new SkillInfo(SkillID.armorProficiencyUnarmored, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, null));
- initializeSkill(new SkillInfo(SkillID.armorProficiencyLight, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, null));
- initializeSkill(new SkillInfo(SkillID.armorProficiencyHeavy, 4, SkillInfo.LevelUpType.firstLevelRequiresQuest, null));
- initializeSkill(new SkillInfo(SkillID.fightstyleDualWield, 2, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] {
+ initializeSkill(new SkillInfo(SkillID.weaponProficiencyDagger, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null));
+ initializeSkill(new SkillInfo(SkillID.weaponProficiency1hsword, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null));
+ initializeSkill(new SkillInfo(SkillID.weaponProficiency2hsword, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null));
+ initializeSkill(new SkillInfo(SkillID.weaponProficiencyAxe, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null));
+ initializeSkill(new SkillInfo(SkillID.weaponProficiencyBlunt, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null));
+ initializeSkill(new SkillInfo(SkillID.weaponProficiencyUnarmed, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null));
+ initializeSkill(new SkillInfo(SkillID.armorProficiencyShield, 2, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null));
+ initializeSkill(new SkillInfo(SkillID.armorProficiencyUnarmored, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null));
+ initializeSkill(new SkillInfo(SkillID.armorProficiencyLight, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null));
+ initializeSkill(new SkillInfo(SkillID.armorProficiencyHeavy, 4, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null));
+ initializeSkill(new SkillInfo(SkillID.fightstyleDualWield, 2, SkillInfo.LevelUpType.alwaysShown, SkillCategory.specialty, new SkillLevelRequirement[] {
SkillLevelRequirement.requireExperienceLevels(15, 0)
}));
- initializeSkill(new SkillInfo(SkillID.fightstyle2hand, 2, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] {
+ initializeSkill(new SkillInfo(SkillID.fightstyle2hand, 2, SkillInfo.LevelUpType.alwaysShown, SkillCategory.specialty, new SkillLevelRequirement[] {
SkillLevelRequirement.requireExperienceLevels(15, 0)
}));
- initializeSkill(new SkillInfo(SkillID.fightstyleWeaponShield, 2, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] {
+ initializeSkill(new SkillInfo(SkillID.fightstyleWeaponShield, 2, SkillInfo.LevelUpType.alwaysShown, SkillCategory.specialty, new SkillLevelRequirement[] {
SkillLevelRequirement.requireExperienceLevels(15, 0)
}));
- initializeSkill(new SkillInfo(SkillID.specializationDualWield, 1, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] {
+ initializeSkill(new SkillInfo(SkillID.specializationDualWield, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.specialty, new SkillLevelRequirement[] {
SkillLevelRequirement.requireExperienceLevels(45, 0)
,SkillLevelRequirement.requireOtherSkill(SkillID.fightstyleDualWield, 2)
}));
- initializeSkill(new SkillInfo(SkillID.specialization2hand, 1, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] {
+ initializeSkill(new SkillInfo(SkillID.specialization2hand, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.specialty, new SkillLevelRequirement[] {
SkillLevelRequirement.requireExperienceLevels(45, 0)
,SkillLevelRequirement.requireOtherSkill(SkillID.fightstyle2hand, 2)
}));
- initializeSkill(new SkillInfo(SkillID.specializationWeaponShield, 1, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] {
+ initializeSkill(new SkillInfo(SkillID.specializationWeaponShield, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.specialty, new SkillLevelRequirement[] {
SkillLevelRequirement.requireExperienceLevels(45, 0)
,SkillLevelRequirement.requireOtherSkill(SkillID.fightstyleWeaponShield, 2)
}));
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillInfo.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillInfo.java
index 2df7e0cfd..430e1b859 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillInfo.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillInfo.java
@@ -14,16 +14,19 @@ public final class SkillInfo {
public final int maxLevel;
public final LevelUpType levelupVisibility;
public final SkillLevelRequirement[] levelupRequirements;
+ public final SkillCollection.SkillCategory categoryType;
public SkillInfo(
SkillCollection.SkillID id
, int maxLevel
, LevelUpType levelupVisibility
+ , SkillCollection.SkillCategory categoryType
, SkillLevelRequirement[] levelupRequirements
) {
this.id = id;
this.maxLevel = maxLevel;
this.levelupVisibility = levelupVisibility;
this.levelupRequirements = levelupRequirements;
+ this.categoryType = categoryType;
}
public boolean hasMaxLevel() {
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java
index a901d750d..a5c29cd5d 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java
@@ -1,11 +1,18 @@
package com.gpl.rpg.AndorsTrail.model.item;
import com.gpl.rpg.AndorsTrail.context.WorldContext;
+import com.gpl.rpg.AndorsTrail.model.actor.Player;
import com.gpl.rpg.AndorsTrail.savegames.LegacySavegameFormatReaderForItemContainer;
+import com.gpl.rpg.AndorsTrail.savegames.Savegames;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
public final class Inventory extends ItemContainer {
@@ -87,6 +94,58 @@ public final class Inventory extends ItemContainer {
}
+ // Move to item container?
+ public Inventory buildQuestItems() {
+ Inventory questItems = new Inventory();
+ for (ItemEntry i : this.items) {
+ if (i == null) break;
+ if (i.itemType.isQuestItem())
+ questItems.items.add(i);
+ }
+ return questItems;
+ }
+ // Move to item container?
+ public Inventory buildUsableItems() {
+ Inventory usableItems = new Inventory();
+ for (ItemEntry i : this.items) {
+ if (i == null) break;
+ if (i.itemType.isUsable())
+ usableItems.items.add(i);
+ }
+ return usableItems;
+ }
+ // Move to item container?
+ public Inventory buildWeaponItems() {
+ Inventory weaponItems = new Inventory();
+ for (ItemEntry i : this.items) {
+ if (i == null) break;
+ if (i.itemType.isWeapon())
+ weaponItems.items.add(i);
+ }
+ return weaponItems;
+ }
+ // Move to item container?
+ public Inventory buildArmorItems() {
+ Inventory armorItems = new Inventory();
+ for (ItemEntry i : this.items) {
+ if (i == null) break;
+ if (i.itemType.isEquippable() && !i.itemType.isWeapon())
+ armorItems.items.add(i);
+ }
+ return armorItems;
+ }
+ // Move to item container?
+ public Inventory buildOtherItems() {
+ Inventory otherItems = new Inventory();
+ for (ItemEntry i : this.items) {
+ if (i == null) break;
+ if (i.itemType.isEquippable() || i.itemType.isUsable() || i.itemType.isQuestItem())
+ continue;
+ otherItems.items.add(i);
+ }
+ return otherItems;
+ }
+
// ====== PARCELABLE ===================================================================
public Inventory(DataInputStream src, WorldContext world, int fileversion) throws IOException {
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemContainer.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemContainer.java
index 0ade2120c..9c203076f 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemContainer.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemContainer.java
@@ -1,11 +1,14 @@
package com.gpl.rpg.AndorsTrail.model.item;
import com.gpl.rpg.AndorsTrail.context.WorldContext;
+import com.gpl.rpg.AndorsTrail.model.actor.Player;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
public class ItemContainer {
public final ArrayList items = new ArrayList();
@@ -115,6 +118,127 @@ public class ItemContainer {
if (i < 0) return;
items.add(items.remove(i));
}
+
+ public ItemContainer usableItems() {
+ ItemContainer usableContainer = new ItemContainer();
+ for (ItemEntry item : items) {
+ if (item.itemType.isUsable()) {
+ usableContainer.addItem(item.itemType, item.quantity);
+ }
+ }
+ return usableContainer;
+ }
+
+
+ public void sortByName(Player p) {
+ final Player q = p;
+ Comparator comparatorName = new Comparator() {
+ @Override
+ public int compare(ItemEntry item1, ItemEntry item2) {
+ return item1.itemType.getName(q).compareTo(item2.itemType.getName(q));
+ }
+ };
+ Collections.sort(this.items, comparatorName);
+
+ }
+
+
+ public void sortByPrice(Player p) {
+ final Player q = p;
+ Comparator comparatorPrice = new Comparator() {
+ @Override
+ public int compare(ItemEntry item1, ItemEntry item2) {
+ // More expensive items go to top
+ if (item1.itemType.baseMarketCost < item2.itemType.baseMarketCost) {
+ return 1;
+ } else if (item1.itemType.baseMarketCost > item2.itemType.baseMarketCost) {
+ return -1;
+ } else { // compares the names if rarity is the same
+ return item1.itemType.getName(q).compareTo(item2.itemType.getName(q));
+ }
+ }
+ };
+ Collections.sort(this.items, comparatorPrice);
+
+ }
+
+ public void sortByQuantity(Player p) {
+ final Player q = p;
+ Comparator comparatorQuantity = new Comparator() {
+ @Override
+ public int compare(ItemEntry item1, ItemEntry item2) {
+ // Bigger quantity is put first
+ if (item1.quantity > item2.quantity) {
+ return -1;
+ } else if (item1.quantity < item2.quantity) {
+ return 1;
+ } else { // compares the names if quantity is the same
+ return item1.itemType.getName(q).compareTo(item2.itemType.getName(q));
+ }
+ }
+ };
+ Collections.sort(this.items, comparatorQuantity);
+
+ }
+
+
+ public void sortByRarity(Player p) {
+ final Player q = p;
+ Comparator comparatorRarity = new Comparator() {
+ @Override
+ public int compare(ItemEntry item1, ItemEntry item2) {
+ // More rare items go to top
+ if (item1.itemType.displayType.compareTo(item2.itemType.displayType) != 0 ) {
+ return (-1) * item1.itemType.displayType.compareTo(item2.itemType.displayType);
+ // ^ More rare goes on top
+ } else { // compares the names if rarity is the same
+ return item1.itemType.getName(q).compareTo(item2.itemType.getName(q));
+ }
+ }
+ };
+ Collections.sort(this.items, comparatorRarity);
+
+ }
+
+
+ public void sortByType(Player p) {
+ final Player q = p;
+ Comparator comparatorType = new Comparator() {
+ @Override
+ public int compare(ItemEntry item1, ItemEntry item2) {
+ if (determineType(item1) > determineType(item2)) {
+ return 1;
+ } else if (determineType(item1) < determineType(item2)) {
+ return -666;
+ } else { // compares the names if type is the same
+ return item1.itemType.getName(q).compareTo(item2.itemType.getName(q));
+ }
+ }
+ };
+ Collections.sort(this.items, comparatorType);
+
+ }
+
+ public int determineType(ItemEntry item) {
+ if (item.itemType.isWeapon()) {
+ if(item.itemType.isTwohandWeapon())
+ return 1;
+ if(false)//item.itemType.isRangedWeapon())
+ return 2;
+ return 3;
+ } // Weapons
+ else if (item.itemType.isShield()) { return 4; } // Shields
+ else if (item.itemType.isArmor()) { return 5; } // Armor, gloves, hats, boots
+ else if (item.itemType.isEquippable()) { return 6; } // Jewelry
+ else if (item.itemType.isUsable()) { return 7; } // Items with use, for example food
+ else if (item.itemType.isQuestItem()) { return 8; } // Quest items
+ else { return 9; } // others
+ }
+
+ public void sortByReverse() {
+ Collections.reverse(this.items);
+ }
+
// ====== PARCELABLE ===================================================================
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/LayeredTileMap.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/LayeredTileMap.java
index 3e85fbc98..3ae745566 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/LayeredTileMap.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/LayeredTileMap.java
@@ -19,26 +19,42 @@ public final class LayeredTileMap {
private static final ColorFilter colorFilterRedTint = createRedTintColorFilter();
private static final ColorFilter colorFilterGreenTint = createGreenTintColorFilter();
private static final ColorFilter colorFilterBlueTint = createBlueTintColorFilter();
+
+
+ public enum ColorFilterId {
+ none,
+ black20,
+ black40,
+ black60,
+ black80,
+ invert,
+ bw,
+ redtint,
+ greentint,
+ bluetint
+ }
private final Size size;
public final MapSection currentLayout;
private String currentLayoutHash;
public final ReplaceableMapSection[] replacements;
- public final String colorFilter;
+ public final ColorFilterId originalColorFilter;
+ public ColorFilterId colorFilter;
public final Collection usedTileIDs;
public LayeredTileMap(
Size size
, MapSection layout
, ReplaceableMapSection[] replacements
- , String colorFilter
+ , ColorFilterId colorFilter
, Collection usedTileIDs
) {
this.size = size;
this.currentLayout = layout;
this.replacements = replacements;
- this.colorFilter = colorFilter;
+ this.originalColorFilter = colorFilter;
+ colorFilter = originalColorFilter;
this.usedTileIDs = usedTileIDs;
- this.currentLayoutHash = currentLayout.calculateHash();
+ this.currentLayoutHash = currentLayout.calculateHash(colorFilter.name());
}
public final boolean isWalkable(final Coord p) {
@@ -78,17 +94,30 @@ public final class LayeredTileMap {
public ColorFilter getColorFilter() {
if (colorFilter == null) return null;
- else if (colorFilter.length() <= 0) return null;
- else if (colorFilter.equals("black20")) return colorFilterBlack20;
- else if (colorFilter.equals("black40")) return colorFilterBlack40;
- else if (colorFilter.equals("black60")) return colorFilterBlack60;
- else if (colorFilter.equals("black80")) return colorFilterBlack80;
- else if (colorFilter.equals("invert")) return colorFilterInvert;
- else if (colorFilter.equals("bw")) return colorFilterBW;
- else if (colorFilter.equals("redtint")) return colorFilterRedTint;
- else if (colorFilter.equals("greentint")) return colorFilterGreenTint;
- else if (colorFilter.equals("bluetint")) return colorFilterBlueTint;
- return null;
+ switch (colorFilter) {
+ case black20:
+ return colorFilterBlack20;
+ case black40:
+ return colorFilterBlack40;
+ case black60:
+ return colorFilterBlack60;
+ case black80:
+ return colorFilterBlack80;
+ case invert:
+ return colorFilterInvert;
+ case bw:
+ return colorFilterBW;
+ case redtint:
+ return colorFilterRedTint;
+ case greentint:
+ return colorFilterGreenTint;
+ case bluetint:
+ return colorFilterBlueTint;
+ default:
+ return null;
+
+ }
+
}
private static ColorMatrixColorFilter createGrayScaleColorFilter(float blackOpacity) {
@@ -152,6 +181,22 @@ public final class LayeredTileMap {
public void applyReplacement(ReplaceableMapSection replacement) {
replacement.apply(currentLayout);
- currentLayoutHash = currentLayout.calculateHash();
+ currentLayoutHash = currentLayout.calculateHash(colorFilter.name());
+ }
+
+ public void changeColorFilter(ColorFilterId id) {
+ if (colorFilter == id) return;
+ colorFilter = id;
+ currentLayoutHash = currentLayout.calculateHash(colorFilter.name());
+ }
+
+
+ public void changeColorFilter(String idString) {
+ ColorFilterId id;
+ if (idString == null) id = originalColorFilter;
+ else id = ColorFilterId.valueOf(idString);
+ if (id != null) {
+ changeColorFilter(id);
+ }
}
}
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/MapSection.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/MapSection.java
index 461f7c3b1..fa95a1d6e 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/MapSection.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/MapSection.java
@@ -47,7 +47,9 @@ public final class MapSection {
}
}
- public String calculateHash() {
- return ByteUtils.toHexString(layoutHash, 4);
+ public String calculateHash(String filter) {
+ byte[] hash = layoutHash.clone();
+ ByteUtils.xorArray(hash, filter.getBytes());
+ return ByteUtils.toHexString(hash, 4);
}
}
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/PredefinedMap.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/PredefinedMap.java
index 083c68f78..0634c6495 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/PredefinedMap.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/PredefinedMap.java
@@ -1,5 +1,7 @@
package com.gpl.rpg.AndorsTrail.model.map;
+import android.app.ActivityManager.RecentTaskInfo;
+
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
import com.gpl.rpg.AndorsTrail.context.WorldContext;
@@ -36,6 +38,7 @@ public final class PredefinedMap {
public long lastVisitTime = VISIT_RESET;
public String lastSeenLayoutHash = "";
public final boolean isOutdoors;
+ public String currentColorFilter = null;
public final ArrayList splatters = new ArrayList();
@@ -108,11 +111,13 @@ public final class PredefinedMap {
}
return false;
}
-
public Monster getMonsterAt(final CoordRect p) {
+ return getMonsterAt(p, null);
+ }
+ public Monster getMonsterAt(final CoordRect p, Monster exceptMe) {
for (MonsterSpawnArea a : spawnAreas) {
Monster m = a.getMonsterAt(p);
- if (m != null) return m;
+ if (m != null && (exceptMe == null || exceptMe != m)) return m;
}
return null;
}
@@ -171,6 +176,7 @@ public final class PredefinedMap {
resetTemporaryData();
groundBags.clear();
visited = false;
+ currentColorFilter = null;
lastSeenLayoutHash = "";
}
@@ -315,6 +321,15 @@ public final class PredefinedMap {
}
return;
}
+
+ if (fileversion >= 43) {
+ if (src.readBoolean()) {
+ currentColorFilter = src.readUTF();
+ } else {
+ currentColorFilter = null;
+ }
+ }
+
lastVisitTime = src.readLong();
if (visited) {
@@ -352,6 +367,7 @@ public final class PredefinedMap {
}
if (!activeMapObjectGroups.containsAll(initiallyActiveMapObjectGroups)
|| !initiallyActiveMapObjectGroups.containsAll(activeMapObjectGroups)) return true;
+ if (currentColorFilter != null) return true;
return false;
}
@@ -371,6 +387,8 @@ public final class PredefinedMap {
for(Loot l : groundBags) {
l.writeToParcel(dest);
}
+ dest.writeBoolean(currentColorFilter != null);
+ if (currentColorFilter != null) dest.writeUTF(currentColorFilter);
dest.writeLong(lastVisitTime);
} else {
dest.writeBoolean(false);
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/TMXMapTranslator.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/TMXMapTranslator.java
index 79849c5b4..1ed1cd8ec 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/TMXMapTranslator.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/TMXMapTranslator.java
@@ -220,13 +220,19 @@ public final class TMXMapTranslator {
private static final String LAYERNAME_OBJECTS = "objects";
private static final String LAYERNAME_ABOVE = "above";
private static final String LAYERNAME_WALKABLE = "walkable";
+ private static final String PROPNAME_FILTER = "colorfilter";
private static final SetOfLayerNames defaultLayerNames = new SetOfLayerNames(LAYERNAME_GROUND, LAYERNAME_OBJECTS, LAYERNAME_ABOVE, LAYERNAME_WALKABLE);
private static LayeredTileMap transformMap(TMXLayerMap map, TileCache tileCache) {
final Size mapSize = new Size(map.width, map.height);
- String colorFilter = null;
+ LayeredTileMap.ColorFilterId colorFilter = LayeredTileMap.ColorFilterId.none;
for (TMXProperty prop : map.properties) {
- if (prop.name.equalsIgnoreCase("colorfilter")) colorFilter = prop.value;
+ if (prop.name.equalsIgnoreCase(PROPNAME_FILTER)) {
+ String filterId = prop.value;
+ if (filterId != null) {
+ colorFilter = LayeredTileMap.ColorFilterId.valueOf(filterId);
+ }
+ }
}
HashSet usedTileIDs = new HashSet();
HashMap layersPerLayerName = new HashMap();
@@ -376,7 +382,7 @@ public final class TMXMapTranslator {
if (srcLayer.layoutHash == null) return;
digest.update(srcLayer.layoutHash);
}
-
+
private static boolean getTile(final TMXLayerMap map, final int gid, final Tile dest) {
for(int i = map.tileSets.length - 1; i >= 0; --i) {
TMXTileSet ts = map.tileSets[i];
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/script/ScriptEffect.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/script/ScriptEffect.java
index cd106a4cd..583cf51c9 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/script/ScriptEffect.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/script/ScriptEffect.java
@@ -15,6 +15,7 @@ public final class ScriptEffect {
, activateMapObjectGroup
, deactivateMapObjectGroup
, removeQuestProgress
+ , changeMapFilter
}
public final ScriptEffectType type;
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/parsers/ResourceParserUtils.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/parsers/ResourceParserUtils.java
index 58638f725..98526b113 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/parsers/ResourceParserUtils.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/parsers/ResourceParserUtils.java
@@ -22,7 +22,6 @@ public final class ResourceParserUtils {
public static Size parseTilesetTileSize(DynamicTileLoader tileLoader, String s, final Size defaultSize) {
if (s == null || s.length() <= 0) return defaultSize;
String[] parts = s.split(":");
- L.log(s+"-"+tileLoader.getTilesetTileSize(parts[0]).toString());
return tileLoader.getTilesetTileSize(parts[0]);
}
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/util/CoordRect.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/util/CoordRect.java
index 7472936f2..d83843dfc 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/util/CoordRect.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/util/CoordRect.java
@@ -92,4 +92,24 @@ public final class CoordRect {
return new CoordRect(new Coord(x, y), new Size(w, h));
}
+
+ public static CoordRect getBoundingRect(Coord c1, Coord c2, Size s) {
+ int x, y, w, h;
+ if (c2.x < c1.x) {
+ x = c2.x;
+ w = 1 + c1.x - c2.x;
+ } else {
+ x = c1.x;
+ w = 1 + c2.x - c1.x;
+ }
+ if (c2.y < c1.y) {
+ y = c2.y;
+ h = 1 + c1.y - c2.y;
+ } else {
+ y = c1.y;
+ h = 1 + c2.y - c1.y;
+ }
+
+ return new CoordRect(new Coord(x, y), new Size(w + s.width - 1, h + s.height - 1));
+ }
}
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/ItemContainerAdapter.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/ItemContainerAdapter.java
index 392e036b7..e6dd5d639 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/ItemContainerAdapter.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/ItemContainerAdapter.java
@@ -13,7 +13,7 @@ import com.gpl.rpg.AndorsTrail.model.item.ItemContainer.ItemEntry;
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
-public final class ItemContainerAdapter extends ArrayAdapter {
+public class ItemContainerAdapter extends ArrayAdapter {
private final TileManager tileManager;
private final TileCollection tileCollection;
private final Player player;
@@ -47,4 +47,49 @@ public final class ItemContainerAdapter extends ArrayAdapter {
public long getItemId(int position) {
return getItem(position).itemType.id.hashCode();
}
+
+ /*public void reloadShownCategory(int category){ // Overwrites player.inventory instead of cloning it
+ this.clear();
+ ArrayList<
+ for(ItemEntry i: (ItemEntry) this.player.inventory.items.clone()){
+ if(category == 0)
+ this.add(i);
+ else if(i.itemType.isWeapon())
+ if(category ==1)
+ this.add(i);
+ else if(i.itemType.isEquippable() && ! i.itemType.isWeapon())
+ if(category==2)
+ this.add(i);
+ else if(i.itemType.isUsable())
+ if(category ==3)
+ this.add(i);
+ else if(i.itemType.isQuestItem())
+ if(category ==4)
+ this.add(i);
+ else if(category == 5) //other items
+ this.add(i);
+ }
+ }*/
+
+ public static void reloadShownSort(int selected, int oldSortSelection, ItemContainer container, Player p) {
+ //Not sure which is worse, hardcoding the names or the position.
+
+ if(selected == oldSortSelection);
+ //inv.sortByReverse();
+ else if (selected ==1)
+ container.sortByName(p);
+ else if (selected == 2)
+ container.sortByPrice(p);
+ else if (selected == 3)
+ container.sortByQuantity(p);
+ else if (selected == 4)
+ container.sortByRarity(p);
+ else if (selected == 5)
+ container.sortByType(p);
+ else if (selected == 0); //Unsorted
+ }
+
+ public static void reloadShownSort(int selected, ItemContainer container, Player p){
+ reloadShownSort(selected, -1, container, p);
+ }
}
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/MainView.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/MainView.java
index 28b9a2a03..c632ae72d 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/MainView.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/MainView.java
@@ -829,6 +829,7 @@ public final class MainView extends SurfaceView
public void onMapTilesChanged(PredefinedMap map, LayeredTileMap tileMap) {
if (map != currentMap) return;
updateBitmaps();
+ currentTileMap.setColorFilter(this.mPaint);
redrawAll(RedrawAllDebugReason.MapChanged);
}
@@ -844,12 +845,12 @@ public final class MainView extends SurfaceView
@Override
public void onNewSpriteMoveFrame(SpriteMoveAnimation animation) {
- redrawMoveArea_(CoordRect.getBoundingRect(animation.origin, animation.destination), animation);
+ redrawMoveArea_(CoordRect.getBoundingRect(animation.origin, animation.destination, animation.actor.tileSize), animation);
}
@Override
public void onSpriteMoveCompleted(SpriteMoveAnimation animation) {
- redrawArea(CoordRect.getBoundingRect(animation.origin, animation.destination), RedrawAreaDebugReason.EffectCompleted);
+ redrawArea(CoordRect.getBoundingRect(animation.origin, animation.destination, animation.actor.tileSize), RedrawAreaDebugReason.EffectCompleted);
}
@Override
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/QuickitemView.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/QuickitemView.java
index b8bb92fc9..2fe1118a8 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/QuickitemView.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/QuickitemView.java
@@ -123,7 +123,7 @@ public final class QuickitemView extends LinearLayout implements OnClickListener
public void registerForContextMenu(MainActivity mainActivity) {
for(QuickButton item: buttons)
- mainActivity.registerForContextMenu(item);
+ mainActivity.registerForLongClick(item);
}
public void setPosition(AndorsTrailPreferences preferences) {
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/QuickslotsItemContainerAdapter.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/QuickslotsItemContainerAdapter.java
new file mode 100644
index 000000000..1c43dbfed
--- /dev/null
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/QuickslotsItemContainerAdapter.java
@@ -0,0 +1,62 @@
+package com.gpl.rpg.AndorsTrail.view;
+
+import com.gpl.rpg.AndorsTrail.R;
+import com.gpl.rpg.AndorsTrail.model.actor.Player;
+import com.gpl.rpg.AndorsTrail.model.item.ItemContainer;
+import com.gpl.rpg.AndorsTrail.model.item.ItemContainer.ItemEntry;
+import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
+import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
+
+import android.content.Context;
+import android.graphics.ColorMatrix;
+import android.graphics.ColorMatrixColorFilter;
+import android.graphics.drawable.Drawable;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+public class QuickslotsItemContainerAdapter extends ItemContainerAdapter {
+
+ public static final ItemEntry EMPTY_ENTRY = new ItemEntry(null, 0);
+ public static Drawable EMPTY_DRAWABLE = null;
+
+ public QuickslotsItemContainerAdapter(Context context, TileManager tileManager, ItemContainer items, Player player, TileCollection tileCollection) {
+ super(context, tileManager, items, player, tileCollection);
+ insert(EMPTY_ENTRY, 0);
+ if (EMPTY_DRAWABLE == null) {
+
+ ColorMatrix matrix = new ColorMatrix();
+ matrix.setSaturation(0);
+ ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
+ EMPTY_DRAWABLE = context.getResources().getDrawable(R.drawable.ui_icon_equipment).mutate();
+ EMPTY_DRAWABLE.setColorFilter(filter);
+ }
+ }
+
+ public QuickslotsItemContainerAdapter(Context context, TileManager tileManager, ItemContainer items, Player player) {
+ this(context, tileManager, items, player, tileManager.loadTilesFor(items, context.getResources()));
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ if (getItem(position) == EMPTY_ENTRY) {
+ View result = convertView;
+ if (result == null) {
+ result = View.inflate(getContext(), R.layout.inventoryitemview, null);
+ }
+ TextView tv = (TextView) result;
+
+ tv.setCompoundDrawablesWithIntrinsicBounds(EMPTY_DRAWABLE, null, null, null);
+ tv.setText(R.string.inventory_unassign);
+ return result;
+ }
+ return super.getView(position, convertView, parent);
+ }
+
+ @Override
+ public long getItemId(int position) {
+ if (getItem(position) == EMPTY_ENTRY) return EMPTY_ENTRY.hashCode();
+ return super.getItemId(position);
+ }
+
+}
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/ShopItemContainerAdapter.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/ShopItemContainerAdapter.java
index a99212911..0d2c7f36a 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/ShopItemContainerAdapter.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/ShopItemContainerAdapter.java
@@ -82,4 +82,8 @@ public final class ShopItemContainerAdapter extends ArrayAdapter {
void onItemActionClicked(int position, ItemType itemType);
void onItemInfoClicked(int position, ItemType itemType);
}
+
+ public void reloadShownSort(int selection, ItemContainer container, Player p){
+ ItemContainerAdapter.reloadShownSort(selection, container, player);
+ }
}
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/SkillListAdapter.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/SkillListAdapter.java
index 7c30bf2a8..930420511 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/SkillListAdapter.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/SkillListAdapter.java
@@ -26,6 +26,12 @@ public final class SkillListAdapter extends ArrayAdapter {
this.player = player;
}
+ public SkillListAdapter(Context context, Collection skills, Player player, int category) {
+ super(context, 0, filterNondisplayedSkills(skills, player, category-1));
+ this.r = context.getResources();
+ this.player = player;
+ }
+
private static List filterNondisplayedSkills(Collection skills, Player player) {
final ArrayList result = new ArrayList();
for (SkillInfo skill : skills) {
@@ -39,7 +45,24 @@ public final class SkillListAdapter extends ArrayAdapter {
});
return result;
}
-
+ private static List filterNondisplayedSkills(Collection skills, Player player, int category) {
+ final ArrayList result = new ArrayList();
+ for (SkillInfo skill : skills) {
+ if (shouldDisplaySkill(skill, player)){
+ if(category <0)
+ result.add(skill);
+ else if(skill.categoryType.equals(SkillCollection.SkillCategory.values()[category+1]))
+ result.add(skill);
+ }
+ }
+ Collections.sort(result, new Comparator() {
+ @Override
+ public int compare(SkillInfo a, SkillInfo b) {
+ return a.id.ordinal() - b.id.ordinal();
+ }
+ });
+ return result;
+ }
private static boolean shouldDisplaySkill(SkillInfo skill, Player player) {
if (player.hasSkill(skill.id)) return true;
if (skill.levelupVisibility == SkillInfo.LevelUpType.alwaysShown) return true;
@@ -134,4 +157,59 @@ public final class SkillListAdapter extends ArrayAdapter {
return -1;
}
}
+
+ public void sortByName(){
+ Comparator comparatorName = new Comparator() {
+ @Override
+ public int compare(SkillInfo item1, SkillInfo item2) {
+ return r.getString( SkillInfoActivity.getSkillTitleResourceID(item1.id)).compareTo(
+ r.getString( SkillInfoActivity.getSkillTitleResourceID(item2.id)));
+ }
+ };
+ this.sort(comparatorName);
+ }
+
+ public void sortByPoints(){
+ Comparator comparatorPoints = new Comparator() {
+ @Override
+ public int compare(SkillInfo item1, SkillInfo item2) {
+ if(player.getSkillLevel(item1.id) > player.getSkillLevel(item2.id))
+ return -1;
+ else if(player.getSkillLevel(item1.id) < player.getSkillLevel(item2.id))
+ return 1;
+ else
+ return r.getString( SkillInfoActivity.getSkillTitleResourceID(item1.id)).compareTo(
+ r.getString( SkillInfoActivity.getSkillTitleResourceID(item2.id)));
+ }
+ };
+ this.sort(comparatorPoints);
+ }
+
+ public void sortByUnlocked(){
+ Comparator comparatorUnlocked = new Comparator() {
+ @Override
+ public int compare(SkillInfo item1, SkillInfo item2) {
+ // First compare by whether requirements are met
+ if(item1.canLevelUpSkillTo(player, player.getSkillLevel(item1.id) + 1)
+ && !(item2.canLevelUpSkillTo(player, player.getSkillLevel(item2.id) +1)))
+ return -1;
+ else if(!(item1.canLevelUpSkillTo(player, player.getSkillLevel(item1.id) +1))
+ && item2.canLevelUpSkillTo(player, player.getSkillLevel(item2.id) +1))
+ return 1;
+ else { // Then compare by number of requirements (complexity)
+ if(item1.levelupRequirements == null)
+ return -1;
+ if(item2.levelupRequirements == null)
+ return 1;
+ if(item1.levelupRequirements.length< item2.levelupRequirements.length)
+ return -1;
+ else if(item1.levelupRequirements.length > item2.levelupRequirements.length)
+ return 1;
+ return r.getString(SkillInfoActivity.getSkillTitleResourceID(item1.id)).compareTo(
+ r.getString(SkillInfoActivity.getSkillTitleResourceID(item2.id)));
+ }
+ }
+ };
+ this.sort(comparatorUnlocked);
+ }
}