mirror of
https://github.com/OMGeeky/andors-trail.git
synced 2026-01-20 10:31:28 +01:00
Merge pull request #22 from HummusSamurai/feature/SortingAndCategories
Feature/sorting and categories Inventory, skills and shoplists can now be filtered and sorted ! Thank you M.H. Alkotob.
This commit is contained in:
@@ -41,6 +41,35 @@
|
||||
android:orientation="vertical"
|
||||
android:gravity="left"
|
||||
>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
<Spinner
|
||||
android:id="@+id/inventorylist_category_filters"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left"
|
||||
android:orientation="horizontal"
|
||||
android:prompt="@string/heroinfo_inventory_categories"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="5dp" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/inventorylist_sort_filters"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_toRightOf="@+id/inventorylist_category_filters"
|
||||
android:prompt="@string/heroinfo_inventory_sort"
|
||||
android:layout_margin="@dimen/dialog_margin"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginLeft="5dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
@@ -56,4 +85,4 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
@@ -4,39 +4,85 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="left"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/heroinfo_wornequipment"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:gravity="left"
|
||||
>
|
||||
|
||||
<include layout="@layout/heroinfo_equipped" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/heroinfo_wornequipment"
|
||||
/>
|
||||
|
||||
<include layout="@layout/heroinfo_statsicons" />
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
>
|
||||
|
||||
<include layout="@layout/heroinfo_equipped" />
|
||||
|
||||
<include layout="@layout/heroinfo_statsicons" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<TextView
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/heroinfo_inventory"
|
||||
/>
|
||||
android:orientation="vertical"
|
||||
android:gravity="left"
|
||||
>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
<Spinner
|
||||
android:id="@+id/inventorylist_category_filters"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left"
|
||||
android:orientation="horizontal"
|
||||
android:prompt="@string/heroinfo_inventory_categories"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="5dp" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/inventorylist_root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<Spinner
|
||||
android:id="@+id/inventorylist_sort_filters"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_toRightOf="@+id/inventorylist_category_filters"
|
||||
android:prompt="@string/heroinfo_inventory_sort"
|
||||
android:layout_margin="@dimen/dialog_margin"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginLeft="5dp" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/heroinfo_inventory"
|
||||
/>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/inventorylist_root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -1,23 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
<TextView
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/skill_number_of_increases_several"
|
||||
android:id="@+id/heroinfo_listskills_number_of_increases"
|
||||
android:layout_marginBottom="@dimen/section_margin"
|
||||
android:layout_marginTop="@dimen/section_margin"
|
||||
android:layout_gravity="center_horizontal"
|
||||
/>
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="right"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/heroinfo_listskills_number_of_increases"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_gravity="left"
|
||||
android:layout_marginBottom="@dimen/section_margin"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginTop="@dimen/section_margin"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/skill_number_of_increases_several" />
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/skillList_filters_spinners"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:gravity="right"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/skillList_category_filters"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:orientation="horizontal"
|
||||
android:prompt="@string/heroinfo_skill_categories" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/skillList_sort_filters"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_toRightOf="@+id/heroinfo_skill_categories"
|
||||
android:layout_marginRight="10dp"
|
||||
android:orientation="horizontal"
|
||||
android:prompt="@string/heroinfo_skill_sort" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<ListView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/heroinfo_listskills_list"
|
||||
/>
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@@ -1,21 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="left"
|
||||
>
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/shop_gc"
|
||||
android:drawableLeft="@drawable/ui_icon_coins"
|
||||
android:drawablePadding="@dimen/boxshape_margin"
|
||||
android:layout_gravity="right"
|
||||
android:gravity="center_vertical"
|
||||
/>
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="right"
|
||||
android:orientation="horizontal"
|
||||
android:layout_alignParentRight="true">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/shop_gc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawableLeft="@drawable/ui_icon_coins"
|
||||
android:drawablePadding="@dimen/boxshape_margin"
|
||||
android:gravity="center_vertical"
|
||||
/>
|
||||
<Spinner
|
||||
android:id="@+id/shoplist_sort_filters"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:orientation="horizontal"
|
||||
android:layout_alignParentRight="true"
|
||||
android:prompt="@string/shop_item_sort" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<ListView
|
||||
android:id="@+id/shop_list"
|
||||
|
||||
@@ -16,4 +16,4 @@
|
||||
</item>
|
||||
<item android:title="@string/inventory_movetop" android:id="@+id/inv_menu_movetop" />
|
||||
<item android:title="@string/inventory_movebottom" android:id="@+id/inv_menu_movebottom" />
|
||||
</menu>
|
||||
</menu>
|
||||
@@ -8,6 +8,56 @@
|
||||
<item>@string/questlog_includecompleted_onlycompleted</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Order is hardcoded within HeroInfoActivity_inventory-->
|
||||
<string-array name="inventorylist_category_filters">
|
||||
<item>@string/inventory_category_all</item>
|
||||
<item>@string/inventory_category_weapons</item>
|
||||
<item>@string/inventory_category_armor</item>
|
||||
<item>@string/inventory_category_usable</item>
|
||||
<item>@string/inventory_category_quest</item>
|
||||
<item>@string/inventory_category_other</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Order is hardcoded within ItemContainerAdapter method-->
|
||||
<string-array name="inventorylist_sort_filters">
|
||||
<item>@string/inventory_sort_custom</item>
|
||||
<item>@string/inventory_sort_name</item>
|
||||
<item>@string/inventory_sort_price</item>
|
||||
<item>@string/inventory_sort_quantity</item>
|
||||
<item>@string/inventory_sort_rarity</item>
|
||||
<item>@string/inventory_sort_type</item>
|
||||
</string-array>
|
||||
|
||||
<!-- the categories need to be in the same order as SkillList.SkillCategory-->
|
||||
<string-array name="skill_category_filters">
|
||||
<item>@string/skill_category_all</item>
|
||||
<item>@string/skill_category_offense</item>
|
||||
<item>@string/skill_category_defense</item>
|
||||
<item>@string/skill_category_criticals</item>
|
||||
<item>@string/skill_category_immunity</item>
|
||||
<item>@string/skill_category_utility</item>
|
||||
<item>@string/skill_category_speciality</item>
|
||||
<item>@string/skill_category_proficiency</item>
|
||||
</string-array>
|
||||
|
||||
<!-- order is hardcoded in HeroInfoActivity_skills method -->
|
||||
<string-array name="skill_sort_filters">
|
||||
<item>@string/skill_sort_unsorted</item>
|
||||
<item>@string/skill_sort_name</item>
|
||||
<item>@string/skill_sort_points</item>
|
||||
<item>@string/skill_sort_unlocked</item>
|
||||
</string-array>
|
||||
|
||||
<!-- order hardcoded similar to skills adapter -->
|
||||
<string-array name="shoplist_sort_filters">
|
||||
<item>@string/shoplist_sort_custom</item>
|
||||
<item>@string/shoplist_sort_name</item>
|
||||
<item>@string/shoplist_sort_price</item>
|
||||
<item>@string/shoplist_sort_quantity</item>
|
||||
<item>@string/shoplist_sort_rarity</item>
|
||||
<item>@string/shoplist_sort_type</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="preferences_display_loot">
|
||||
<item>@string/preferences_display_loot_dialog</item>
|
||||
<item>@string/preferences_display_loot_dialog_on_items</item>
|
||||
|
||||
@@ -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 />
|
||||
|
||||
@@ -33,11 +33,15 @@
|
||||
<string name="heroinfo_char">Overview</string>
|
||||
<string name="heroinfo_inv">Items</string>
|
||||
<string name="heroinfo_skill">Skills</string>
|
||||
<string name="heroinfo_skill_categories">Category</string>
|
||||
<string name="heroinfo_skill_sort">Sort</string>
|
||||
<string name="heroinfo_levelup">Level up</string>
|
||||
<string name="heroinfo_level">Level</string>
|
||||
<string name="heroinfo_totalexperience">Total experience</string>
|
||||
<string name="heroinfo_wornequipment">Worn equipment</string>
|
||||
<string name="heroinfo_inventory">Inventory</string>
|
||||
<string name="heroinfo_inventory_categories">Category</string>
|
||||
<string name="heroinfo_inventory_sort">Sort By</string>
|
||||
<string name="heroinfo_gold">Gold: %1$d</string>
|
||||
<string name="heroinfo_actionpoints">Action points (AP):</string>
|
||||
<string name="heroinfo_quests">Quests</string>
|
||||
@@ -142,6 +146,7 @@
|
||||
<string name="shop_yourgold">Your gold: %1$d</string>
|
||||
<string name="shop_item_bought">%1$s bought.</string>
|
||||
<string name="shop_item_sold">%1$s sold.</string>
|
||||
<string name="shop_item_sort">Sort</string>
|
||||
|
||||
<string name="levelup_title">Level up</string>
|
||||
<string name="levelup_description">Welcome to level %1$d!</string>
|
||||
@@ -631,4 +636,39 @@ Every skill level increases the attack chance of weapons with %1$d %% of their o
|
||||
<string name="preferences_ui_use_localized_resources">Use translation of interface and content, where available. (requires restart)</string>
|
||||
<string name="change_locale_requires_restart">Changing locale requires restart. Andor\'s Trail has been closed.</string>
|
||||
|
||||
<string name="inventory_category_all">All</string>
|
||||
<string name="inventory_category_favorites">Favorites</string>
|
||||
<string name="inventory_category_weapons">Weapon</string>
|
||||
<string name="inventory_category_armor">Armor</string>
|
||||
<string name="inventory_category_usable">Consumable</string>
|
||||
<string name="inventory_category_quest">Quest Item</string>
|
||||
<string name="inventory_category_other">Other</string>
|
||||
|
||||
<string name="inventory_sort_custom">Unsorted</string>
|
||||
<string name="inventory_sort_name">Name</string>
|
||||
<string name="inventory_sort_price">Price</string>
|
||||
<string name="inventory_sort_quantity">Quantity</string>
|
||||
<string name="inventory_sort_rarity">Rarity</string>
|
||||
<string name="inventory_sort_type">Type</string>
|
||||
|
||||
<string name="shoplist_sort_custom">Unsorted</string>
|
||||
<string name="shoplist_sort_name">Name</string>
|
||||
<string name="shoplist_sort_price">Price</string>
|
||||
<string name="shoplist_sort_quantity">Quantity</string>
|
||||
<string name="shoplist_sort_rarity">Rarity</string>
|
||||
<string name="shoplist_sort_type">Type</string>
|
||||
|
||||
<string name="skill_category_all">All</string>
|
||||
<string name="skill_category_offense"> Offense</string>
|
||||
<string name="skill_category_defense">Defense</string>
|
||||
<string name="skill_category_criticals">Criticals</string>
|
||||
<string name="skill_category_immunity">Immunity</string>
|
||||
<string name="skill_category_utility">Utility</string>
|
||||
<string name="skill_category_speciality">Speciality</string>
|
||||
<string name="skill_category_proficiency">Proficiency</string>
|
||||
|
||||
<string name="skill_sort_unsorted">Unsorted</string>
|
||||
<string name="skill_sort_name">Name</string>
|
||||
<string name="skill_sort_points">Points</string>
|
||||
<string name="skill_sort_unlocked">Unlocked</string>
|
||||
</resources>
|
||||
|
||||
@@ -10,9 +10,14 @@ import android.view.View.OnClickListener;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.Dialogs;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
@@ -37,7 +42,16 @@ public final class HeroinfoActivity_Inventory extends Fragment {
|
||||
private TileCollection wornTiles;
|
||||
|
||||
private Player player;
|
||||
private ListView inventoryList;
|
||||
private Spinner inventorylist_categories;
|
||||
private Spinner inventorylist_sort;
|
||||
private ItemContainerAdapter inventoryListAdapter;
|
||||
private ItemContainerAdapter inventoryWeaponsListAdapter;
|
||||
private ItemContainerAdapter inventoryArmorListAdapter;
|
||||
private ItemContainerAdapter inventoryUsableListAdapter;
|
||||
private ItemContainerAdapter inventoryQuestListAdapter;
|
||||
private ItemContainerAdapter inventoryOtherListAdapter;
|
||||
|
||||
|
||||
private TextView heroinfo_stats_gold;
|
||||
private TextView heroinfo_stats_attack;
|
||||
@@ -60,17 +74,21 @@ public final class HeroinfoActivity_Inventory extends Fragment {
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.heroinfo_inventory, container, false);
|
||||
final View v = inflater.inflate(R.layout.heroinfo_inventory, container, false);
|
||||
|
||||
ListView inventoryList = (ListView) v.findViewById(R.id.inventorylist_root);
|
||||
initialiseInventorySpinners(v);
|
||||
|
||||
inventoryList = (ListView) v.findViewById(R.id.inventorylist_root);
|
||||
registerForContextMenu(inventoryList);
|
||||
inventoryList.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> 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<CharSequence> 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<CharSequence> 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);
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<SkillListAdapter> skillListCategoryViewsAdapters = new ArrayList<SkillListAdapter>();
|
||||
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<CharSequence> 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<CharSequence> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<CharSequence> 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();
|
||||
|
||||
@@ -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() { }
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
}));
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<ItemEntry> items = new ArrayList<ItemEntry>();
|
||||
@@ -127,6 +130,117 @@ public class ItemContainer {
|
||||
}
|
||||
|
||||
|
||||
public void sortByName(Player p) {
|
||||
final Player q = p;
|
||||
Comparator<ItemEntry> comparatorName = new Comparator<ItemEntry>() {
|
||||
@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<ItemEntry> comparatorPrice = new Comparator<ItemEntry>() {
|
||||
@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<ItemEntry> comparatorQuantity = new Comparator<ItemEntry>() {
|
||||
@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<ItemEntry> comparatorRarity = new Comparator<ItemEntry>() {
|
||||
@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<ItemEntry> comparatorType = new Comparator<ItemEntry>() {
|
||||
@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 ===================================================================
|
||||
|
||||
public static ItemContainer newFromParcel(DataInputStream src, WorldContext world, int fileversion) throws IOException {
|
||||
|
||||
@@ -47,4 +47,49 @@ public class ItemContainerAdapter extends ArrayAdapter<ItemEntry> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,4 +82,8 @@ public final class ShopItemContainerAdapter extends ArrayAdapter<ItemEntry> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,12 @@ public final class SkillListAdapter extends ArrayAdapter<SkillInfo> {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public SkillListAdapter(Context context, Collection<SkillInfo> skills, Player player, int category) {
|
||||
super(context, 0, filterNondisplayedSkills(skills, player, category-1));
|
||||
this.r = context.getResources();
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
private static List<SkillInfo> filterNondisplayedSkills(Collection<SkillInfo> skills, Player player) {
|
||||
final ArrayList<SkillInfo> result = new ArrayList<SkillInfo>();
|
||||
for (SkillInfo skill : skills) {
|
||||
@@ -39,7 +45,24 @@ public final class SkillListAdapter extends ArrayAdapter<SkillInfo> {
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
private static List<SkillInfo> filterNondisplayedSkills(Collection<SkillInfo> skills, Player player, int category) {
|
||||
final ArrayList<SkillInfo> result = new ArrayList<SkillInfo>();
|
||||
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<SkillInfo>() {
|
||||
@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,55 @@ public final class SkillListAdapter extends ArrayAdapter<SkillInfo> {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public void sortByName(){
|
||||
Comparator<SkillInfo> comparatorName = new Comparator<SkillInfo>() {
|
||||
@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<SkillInfo> comparatorPoints = new Comparator<SkillInfo>() {
|
||||
@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<SkillInfo> comparatorUnlocked = new Comparator<SkillInfo>() {
|
||||
@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.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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user