Merge branch 'master' into master

This commit is contained in:
Zukero
2017-03-26 16:02:59 +02:00
committed by GitHub
44 changed files with 1336 additions and 197 deletions

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="left"
>
<TextView
android:id="@+id/quickslot_assign_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/inventory_assign"
android:drawableLeft="@drawable/ui_icon_equipment"
android:paddingTop="3sp"
style="@style/titleWithIcon"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/inventory_selectitem"
/>
<ListView
android:id="@+id/quickbuttons_assignlist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>

View File

@@ -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"

View File

@@ -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>

View File

@@ -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 @@
}
}
}
]
]

View File

@@ -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
}
}
]
]

View File

@@ -4,6 +4,7 @@
"iconID":"actorconditions_1:35",
"name":"Sustenance",
"category":"physical",
"isPositive":1,
"roundEffect":{
"increaseCurrentHP":{
"min":1,
@@ -23,4 +24,4 @@
}
}
}
]
]

View File

@@ -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 @@
}
}
}
]
]

View File

@@ -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
}
}
]
]

View File

@@ -194,4 +194,4 @@
}
}
}
]
]

View File

@@ -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"
}
]
}
]

View File

@@ -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>

View File

@@ -18,6 +18,7 @@
Additional programming by &lt;a href="https://github.com/Zukero"&gt;Kevin Pochat&lt;/a&gt;&lt;br /&gt;
Additional programming by Lucas Delvallet&lt;br /&gt;
Additional programming by Florian Doublet&lt;br /&gt;
Additional programming by M.H. Alkotob&lt;br /&gt;
Additional graphics by Karvis&lt;br /&gt;
Russian translation by Dreamer..., e.solodookhin, shell.andor, konstmih, istasman, Aleksey Kabanov, Alexander Zubok, Paul Sulemenkov and dromoz&lt;br /&gt;
Italian translation by k6blue, liogiu, Joker and Andrea Luciano Damico&lt;br /&gt;

View File

@@ -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>
@@ -322,6 +327,7 @@
<string name="preferences_display_scaling_factor_double">Double size</string>
<string name="inventory_assign">Assign quick slot</string>
<string name="inventory_selectitem">Select item to assign</string>
<string name="inventory_assign_slot1">Slot 1</string>
<string name="inventory_assign_slot2">Slot 2</string>
<string name="inventory_assign_slot3">Slot 3</string>
@@ -630,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>

View File

@@ -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<Toast> 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<world.model.player.inventory.items.size(); ++i){
ItemEntry itemEntry = world.model.player.inventory.items.get(i);
if(itemEntry.itemType.isUsable())
assignMenu.add(R.id.quick_menu_assign_group, i, Menu.NONE, itemEntry.itemType.getName(world.model.player));
}
}
public void createLongClickListener() {
if (quickButtonLongClickListener != null) return;
quickButtonLongClickListener = new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if (v instanceof QuickButton) {
final int buttonId = ((QuickButton)v).getIndex();
final AlertDialog dialog = new AlertDialog.Builder(v.getContext()).create();
View view = getLayoutInflater().inflate(R.layout.quickbuttons_usable_inventory, null);
ListView lv = (ListView) view.findViewById(R.id.quickbuttons_assignlist);
@Override
public boolean onContextItemSelected(MenuItem item) {
QuickButtonContextMenuInfo menuInfo;
if(item.getGroupId() == R.id.quick_menu_assign_group){
menuInfo = (QuickButtonContextMenuInfo) lastSelectedMenu;
controllers.itemController.setQuickItem(world.model.player.inventory.items.get(item.getItemId()).itemType, menuInfo.index);
return true;
}
switch(item.getItemId()){
case R.id.quick_menu_unassign:
menuInfo = (QuickButtonContextMenuInfo) item.getMenuInfo();
controllers.itemController.setQuickItem(null, menuInfo.index);
break;
case R.id.quick_menu_assign:
menuInfo = (QuickButtonContextMenuInfo) item.getMenuInfo();
lastSelectedMenu = menuInfo;
break;
default:
return super.onContextItemSelected(item);
}
return true;
TileCollection wornTiles = world.tileManager.loadTilesFor(world.model.player.inventory, getResources());
final ItemContainerAdapter inventoryListAdapter = new QuickslotsItemContainerAdapter(lv.getContext(), world.tileManager, world.model.player.inventory.usableItems(), world.model.player, wornTiles);
lv.setAdapter(inventoryListAdapter);
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> 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<world.model.player.inventory.items.size(); ++i){
// ItemEntry itemEntry = world.model.player.inventory.items.get(i);
// if(itemEntry.itemType.isUsable())
// assignMenu.add(R.id.quick_menu_assign_group, i, Menu.NONE, itemEntry.itemType.getName(world.model.player));
// }
// }
//
// @Override
// public boolean onContextItemSelected(MenuItem item) {
// QuickButtonContextMenuInfo menuInfo;
// if(item.getGroupId() == R.id.quick_menu_assign_group){
// menuInfo = (QuickButtonContextMenuInfo) lastSelectedMenu;
// controllers.itemController.setQuickItem(world.model.player.inventory.items.get(item.getItemId()).itemType, menuInfo.index);
// return true;
// }
// switch(item.getItemId()){
// case R.id.quick_menu_unassign:
// menuInfo = (QuickButtonContextMenuInfo) item.getMenuInfo();
// controllers.itemController.setQuickItem(null, menuInfo.index);
// break;
// case R.id.quick_menu_assign:
// menuInfo = (QuickButtonContextMenuInfo) item.getMenuInfo();
// lastSelectedMenu = menuInfo;
// break;
// default:
// return super.onContextItemSelected(item);
// }
// return true;
// }
private void updateStatus() {
statusview.updateStatus();
@@ -433,4 +493,5 @@ public final class MainActivity
public void onPlayerDoesNotHaveEnoughAP() {
message(getString(R.string.combat_not_enough_ap));
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}
}

View File

@@ -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();

View File

@@ -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);
}

View File

@@ -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<Loot> 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);
}
}
}
}
}
}

View File

@@ -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;
}

View File

@@ -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) {

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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() { }

View File

@@ -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)
}));

View File

@@ -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() {

View File

@@ -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 {

View File

@@ -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>();
@@ -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<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 ===================================================================

View File

@@ -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<Integer> usedTileIDs;
public LayeredTileMap(
Size size
, MapSection layout
, ReplaceableMapSection[] replacements
, String colorFilter
, ColorFilterId colorFilter
, Collection<Integer> 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);
}
}
}

View File

@@ -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);
}
}

View File

@@ -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<BloodSplatter> splatters = new ArrayList<BloodSplatter>();
@@ -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);

View File

@@ -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<Integer> usedTileIDs = new HashSet<Integer>();
HashMap<String, TMXLayer> layersPerLayerName = new HashMap<String, TMXLayer>();
@@ -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];

View File

@@ -15,6 +15,7 @@ public final class ScriptEffect {
, activateMapObjectGroup
, deactivateMapObjectGroup
, removeQuestProgress
, changeMapFilter
}
public final ScriptEffectType type;

View File

@@ -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]);
}

View File

@@ -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));
}
}

View File

@@ -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<ItemEntry> {
public class ItemContainerAdapter extends ArrayAdapter<ItemEntry> {
private final TileManager tileManager;
private final TileCollection tileCollection;
private final Player player;
@@ -47,4 +47,49 @@ public final 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);
}
}

View File

@@ -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

View File

@@ -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) {

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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,59 @@ 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 == 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);
}
}