mirror of
https://github.com/OMGeeky/andors-trail.git
synced 2026-01-23 20:05:29 +01:00
Uncompressed release version
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.gpl.rpg.AndorsTrail"
|
||||
android:versionCode="63"
|
||||
android:versionName="0.7.16"
|
||||
android:versionCode="64"
|
||||
android:versionName="0.7.17"
|
||||
android:installLocation="auto"
|
||||
>
|
||||
<uses-sdk
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
|
||||
<application
|
||||
android:name=".AndorsTrailApplication"
|
||||
android:name="com.gpl.rpg.AndorsTrail.AndorsTrailApplication"
|
||||
android:label="@string/app_name"
|
||||
android:icon="@drawable/icon"
|
||||
android:description="@string/app_description"
|
||||
@@ -36,7 +36,7 @@
|
||||
android:preserveLegacyExternalStorage="true"
|
||||
>
|
||||
<activity
|
||||
android:name=".activity.StartScreenActivity"
|
||||
android:name="com.gpl.rpg.AndorsTrail.activity.StartScreenActivity"
|
||||
android:clearTaskOnLaunch="true"
|
||||
>
|
||||
<intent-filter>
|
||||
@@ -45,25 +45,25 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.MainActivity"
|
||||
android:name="com.gpl.rpg.AndorsTrail.activity.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AndorsTrailTheme_Blue.NoBackground"
|
||||
/>
|
||||
<activity android:name=".activity.HeroinfoActivity" />
|
||||
<activity android:name=".activity.MonsterInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.ItemInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.LevelUpActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.MonsterEncounterActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.ConversationActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.ShopActivity" />
|
||||
<activity android:name=".activity.AboutActivity" />
|
||||
<activity android:name=".activity.LoadingActivity" />
|
||||
<activity android:name=".activity.Preferences" />
|
||||
<activity android:name=".activity.LoadSaveActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.ActorConditionInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.BulkSelectionInterface" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.SkillInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name=".activity.DisplayWorldMapActivity" />
|
||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.HeroinfoActivity" />
|
||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.MonsterInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.ItemInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.LevelUpActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.MonsterEncounterActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.ConversationActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.ShopActivity" />
|
||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.AboutActivity" />
|
||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.LoadingActivity" />
|
||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.Preferences" />
|
||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.LoadSaveActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.ActorConditionInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.BulkSelectionInterface" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.SkillInfoActivity" android:theme="@style/AndorsTrailDialogTheme_Blue" />
|
||||
<activity android:name="com.gpl.rpg.AndorsTrail.activity.DisplayWorldMapActivity" />
|
||||
|
||||
<provider
|
||||
android:name="android.support.v4.content.FileProvider"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<include layout="@layout/title_bg_sky_layout"/>
|
||||
|
||||
<com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView
|
||||
<com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView
|
||||
android:id="@+id/ts_clouds_animator_back"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@@ -19,7 +19,7 @@
|
||||
android:scaleType="fitEnd"
|
||||
android:src="@drawable/ts_background"/>
|
||||
|
||||
<com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView
|
||||
<com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView
|
||||
android:id="@+id/ts_clouds_animator_mid"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@@ -32,7 +32,7 @@
|
||||
android:scaleType="fitEnd"
|
||||
android:src="@drawable/ts_midground"/>
|
||||
|
||||
<com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView
|
||||
<com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView
|
||||
android:id="@+id/ts_clouds_animator_front"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<include layout="@layout/title_bg_sky_layout"/>
|
||||
|
||||
<com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView
|
||||
<com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView
|
||||
android:id="@+id/ts_clouds_animator_back"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@@ -21,7 +21,7 @@
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/ts_background"/>
|
||||
|
||||
<com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView
|
||||
<com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView
|
||||
android:id="@+id/ts_clouds_animator_mid"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@@ -36,7 +36,7 @@
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/ts_midground"/>
|
||||
|
||||
<com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView
|
||||
<com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView
|
||||
android:id="@+id/ts_clouds_animator_front"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
@@ -2702,7 +2702,7 @@
|
||||
},
|
||||
{
|
||||
"id":"chk_wild_berry_50",
|
||||
"message":"I should better wear my gloves again."
|
||||
"message":"I should wear my gloves again."
|
||||
},
|
||||
{
|
||||
"id":"chk_wild_berry1",
|
||||
|
||||
@@ -2555,7 +2555,7 @@
|
||||
},
|
||||
{
|
||||
"id":"ehrenfest_23",
|
||||
"message":"Lorn lay next to me, just a few meters away. His armor was entirely covered in blood, flowing slowly to the ground out of his body.",
|
||||
"message":"Lorn lay next to me, just a few steps away. His armor was entirely covered in blood, flowing slowly to the ground out of his body.",
|
||||
"replies":[
|
||||
{
|
||||
"text":"What about the campfire?",
|
||||
@@ -2856,7 +2856,7 @@
|
||||
"message":"I'm afraid not.",
|
||||
"replies":[
|
||||
{
|
||||
"text":"Ok, we'll talk later.",
|
||||
"text":"OK, we'll talk later.",
|
||||
"nextPhraseID":"X"
|
||||
}
|
||||
]
|
||||
@@ -4327,7 +4327,7 @@
|
||||
"nextPhraseID":"X"
|
||||
},
|
||||
{
|
||||
"text":"Ok, I will help you. Let's solve this once for all.",
|
||||
"text":"OK, I will help you. Let's solve this once for all.",
|
||||
"nextPhraseID":"ehrenfest_39b",
|
||||
"requires":[
|
||||
{
|
||||
@@ -5427,7 +5427,7 @@
|
||||
},
|
||||
{
|
||||
"id":"ortholion_subdued_2",
|
||||
"message":"The scout stares at you with an inconmensurable anger. Before you can react, she swings her dagger, opening a wound in your arm.",
|
||||
"message":"The scout stares at you with an immeasurable anger. Before you can react, she swings her dagger, opening a wound in your arm.",
|
||||
"switchToNPC":"none",
|
||||
"replies":[
|
||||
{
|
||||
@@ -6610,7 +6610,7 @@
|
||||
},
|
||||
{
|
||||
"id":"elm3_corpse_3a",
|
||||
"message":"Everything seems too old and stinky to be worth a penny, but after half a minute of searching you see a strange pendant behind the miner's shirt.",
|
||||
"message":"Everything seems too old and stinky to be worth anything much, but after half a minute of searching you see a strange pendant behind the miner's shirt.",
|
||||
"replies":[
|
||||
{
|
||||
"text":"I need to take a bath.",
|
||||
@@ -9130,7 +9130,7 @@
|
||||
},
|
||||
{
|
||||
"id":"ortholion_16a",
|
||||
"message":"A reward? This does not work that way...What would Feygard would think of my assassination? Who would be blamed for that?\n\nThe reward is I'm alive and no army will chase you.",
|
||||
"message":"A reward? This does not work that way...What would Feygard think of my assassination? Who would be blamed for that?\n\nThe reward is I'm alive and no army will chase you.",
|
||||
"replies":[
|
||||
{
|
||||
"text":"*laughing* Do you think a few drunkards could beat me?",
|
||||
|
||||
@@ -1636,7 +1636,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"itemID":"health_major2",
|
||||
"itemID":"health_major2",
|
||||
"chance":"1/8",
|
||||
"quantity":{
|
||||
"min":1,
|
||||
@@ -1734,13 +1734,13 @@
|
||||
"itemID":"gold",
|
||||
"chance":"100",
|
||||
"quantity":{
|
||||
"min":12,
|
||||
"max":62
|
||||
"min":3,
|
||||
"max":9
|
||||
}
|
||||
},
|
||||
{
|
||||
"itemID":"kamelio_drop1",
|
||||
"chance":"1/4",
|
||||
"chance":"100",
|
||||
"quantity":{
|
||||
"min":1,
|
||||
"max":1
|
||||
@@ -1748,7 +1748,7 @@
|
||||
},
|
||||
{
|
||||
"itemID":"kamelio_drop2",
|
||||
"chance":"1/4",
|
||||
"chance":"100",
|
||||
"quantity":{
|
||||
"min":1,
|
||||
"max":1
|
||||
@@ -1756,7 +1756,7 @@
|
||||
},
|
||||
{
|
||||
"itemID":"kamelio_drop3",
|
||||
"chance":"1/4",
|
||||
"chance":"100",
|
||||
"quantity":{
|
||||
"min":1,
|
||||
"max":1
|
||||
|
||||
@@ -283,7 +283,7 @@
|
||||
"category":"hnd_lthr",
|
||||
"equipEffect":{
|
||||
"increaseAttackChance":-3,
|
||||
"increaseBlockChance":7,
|
||||
"increaseBlockChance":8,
|
||||
"increaseDamageResistance":1
|
||||
}
|
||||
},
|
||||
|
||||
@@ -349,7 +349,7 @@
|
||||
},
|
||||
{
|
||||
"progress":45,
|
||||
"logText":"Ehrenfest revealed his true intentions, but fled before getting surrounded. According with his own words, he will be waiting for General Ortholion in the Elm mine.",
|
||||
"logText":"Ehrenfest revealed his true intentions, but fled before getting surrounded. He told me he will be waiting for General Ortholion in the Elm mine.",
|
||||
"rewardExperience":1000
|
||||
},
|
||||
{
|
||||
|
||||
@@ -140,19 +140,19 @@
|
||||
<string-array name="preferences_language">
|
||||
<item>@string/preferences_language_default</item>
|
||||
<item>English</item>
|
||||
<item>čeština (62->77%)</item>
|
||||
<item>Deutsch (91%)</item>
|
||||
<item>čeština (77->84%)</item>
|
||||
<item>Deutsch (91->100%)</item>
|
||||
<item>Español (90%)</item>
|
||||
<item>Française (86->89%)</item>
|
||||
<item>Française (89%)</item>
|
||||
<item>Italiano (90%)</item>
|
||||
<item>Magyar (32%)</item>
|
||||
<item>Polski (97%)</item>
|
||||
<item>Português (83%)</item>
|
||||
<item>Português Brasil (93->95%)</item>
|
||||
<item>Русский язык (90->91%)</item>
|
||||
<item>Türkçe (39->41%)</item>
|
||||
<item>日本人 (91->100%)</item>
|
||||
<item>中文 (68->100%)</item>
|
||||
<item>Português Brasil (95->98%)</item>
|
||||
<item>Русский язык (91->100%)</item>
|
||||
<item>Türkçe (41%)</item>
|
||||
<item>日本人 (100%)</item>
|
||||
<item>中文 (100%)</item>
|
||||
</string-array>
|
||||
|
||||
<!-- see AndorsTrailApplication.localeForLanguageTag for allowed formats -->
|
||||
|
||||
@@ -157,7 +157,8 @@
|
||||
<item>@raw/questlist_shortcut_lodar</item>
|
||||
<item>@raw/questlist_pathway_fallhaven</item>
|
||||
<item>@raw/questlist_halvor_surprise</item>
|
||||
-
|
||||
-
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,331 +1,332 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="10" height="30" tilewidth="32" tileheight="32" infinite="0" nextlayerid="15" nextobjectid="31">
|
||||
<tileset firstgid="1" name="map_bed_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<!DOCTYPE map SYSTEM "http://mapeditor.org/dtd/1.0/map.dtd">
|
||||
<map version="1.0" orientation="orthogonal" width="10" height="30" tilewidth="32" tileheight="32">
|
||||
<tileset firstgid="1" name="map_bed_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_bed_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="129" name="map_border_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="129" name="map_border_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_border_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="257" name="map_bridge_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="257" name="map_bridge_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_bridge_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="385" name="map_bridge_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="385" name="map_bridge_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_bridge_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="513" name="map_broken_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="513" name="map_broken_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_broken_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="641" name="map_cavewall_1" tilewidth="32" tileheight="32" tilecount="108" columns="18">
|
||||
<tileset firstgid="641" name="map_cavewall_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cavewall_1.png" width="576" height="192"/>
|
||||
</tileset>
|
||||
<tileset firstgid="749" name="map_cavewall_2" tilewidth="32" tileheight="32" tilecount="108" columns="18">
|
||||
<tileset firstgid="749" name="map_cavewall_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cavewall_2.png" width="576" height="192"/>
|
||||
</tileset>
|
||||
<tileset firstgid="857" name="map_cavewall_3" tilewidth="32" tileheight="32" tilecount="108" columns="18">
|
||||
<tileset firstgid="857" name="map_cavewall_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cavewall_3.png" width="576" height="192"/>
|
||||
</tileset>
|
||||
<tileset firstgid="965" name="map_cavewall_4" tilewidth="32" tileheight="32" tilecount="108" columns="18">
|
||||
<tileset firstgid="965" name="map_cavewall_4" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cavewall_4.png" width="576" height="192"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1073" name="map_chair_table_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1073" name="map_chair_table_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_chair_table_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1201" name="map_chair_table_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1201" name="map_chair_table_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_chair_table_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1329" name="map_crate_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1329" name="map_crate_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_crate_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1457" name="map_cupboard_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1457" name="map_cupboard_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cupboard_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1585" name="map_curtain_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1585" name="map_curtain_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_curtain_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1713" name="map_entrance_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1713" name="map_entrance_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_entrance_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1841" name="map_entrance_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1841" name="map_entrance_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_entrance_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1969" name="map_fence_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1969" name="map_fence_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_fence_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2097" name="map_fence_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2097" name="map_fence_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_fence_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2225" name="map_fence_3" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2225" name="map_fence_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_fence_3.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2353" name="map_fence_4" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2353" name="map_fence_4" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_fence_4.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2481" name="map_ground_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2481" name="map_ground_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2609" name="map_ground_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2609" name="map_ground_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2737" name="map_ground_3" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2737" name="map_ground_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_3.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2865" name="map_ground_4" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2865" name="map_ground_4" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_4.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2993" name="map_ground_5" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2993" name="map_ground_5" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_5.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3121" name="map_ground_6" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3121" name="map_ground_6" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_6.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3249" name="map_ground_7" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3249" name="map_ground_7" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_7.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3377" name="map_ground_8" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3377" name="map_ground_8" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_8.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3505" name="map_house_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3505" name="map_house_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_house_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3633" name="map_house_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3633" name="map_house_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_house_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3761" name="map_indoor_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3761" name="map_indoor_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_indoor_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3889" name="map_indoor_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3889" name="map_indoor_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_indoor_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4017" name="map_kitchen_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4017" name="map_kitchen_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_kitchen_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4145" name="map_outdoor_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4145" name="map_outdoor_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_outdoor_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4273" name="map_pillar_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4273" name="map_pillar_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_pillar_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4401" name="map_pillar_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4401" name="map_pillar_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_pillar_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4529" name="map_plant_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4529" name="map_plant_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_plant_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4657" name="map_plant_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4657" name="map_plant_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_plant_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4785" name="map_rock_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4785" name="map_rock_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_rock_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4913" name="map_rock_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4913" name="map_rock_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_rock_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5041" name="map_roof_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5041" name="map_roof_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_roof_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5169" name="map_roof_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5169" name="map_roof_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_roof_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5297" name="map_roof_3" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5297" name="map_roof_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_roof_3.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5425" name="map_shop_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5425" name="map_shop_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_shop_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5553" name="map_sign_ladder_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5553" name="map_sign_ladder_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_sign_ladder_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5681" name="map_table_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5681" name="map_table_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_table_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5809" name="map_trail_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5809" name="map_trail_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_trail_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5937" name="map_transition_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5937" name="map_transition_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_transition_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6065" name="map_transition_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6065" name="map_transition_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_transition_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6193" name="map_transition_3" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6193" name="map_transition_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_transition_3.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6321" name="map_transition_4" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6321" name="map_transition_4" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_transition_4.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6449" name="map_transition_6" tilewidth="32" tileheight="32" tilecount="144" columns="18">
|
||||
<tileset firstgid="6449" name="map_transition_6" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_transition_6.png" width="576" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6593" name="map_tree_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6593" name="map_tree_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_tree_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6721" name="map_tree_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6721" name="map_tree_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_tree_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6849" name="map_wall_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6849" name="map_wall_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_wall_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6977" name="map_wall_2" tilewidth="32" tileheight="32" tilecount="120" columns="15">
|
||||
<tileset firstgid="6977" name="map_wall_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_wall_2.png" width="480" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7097" name="map_wall_3" tilewidth="32" tileheight="32" tilecount="120" columns="15">
|
||||
<tileset firstgid="7097" name="map_wall_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_wall_3.png" width="480" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7217" name="map_wall_4" tilewidth="32" tileheight="32" tilecount="120" columns="15">
|
||||
<tileset firstgid="7217" name="map_wall_4" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_wall_4.png" width="480" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7337" name="map_window_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="7337" name="map_window_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_window_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7465" name="map_window_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="7465" name="map_window_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_window_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<layer id="14" name="Base" width="10" height="30">
|
||||
<layer name="Base" width="10" height="30">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJxjYBgFAwU2cg60C0bBKCANrGMaWPsBsIsBaw==
|
||||
eJxjYKAf2MxJR8uGANg4Gh6jYIiBdUwDaz8A0p8CJw==
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="1" name="Ground" width="10" height="30">
|
||||
<layer name="Ground" width="10" height="30">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJzNkssNgzAQRBESBxpIsdRCC3YUUQBuAbsFisgxtsKK0WjXGCmHHJ74PZvZXce+62ImZZ4Zb7AfpON5NhDP2kcIAH9bxvM+Aq7i7QB7Ht69xpOVcgTD25Qcsha9AueQtewV3o/v1UENmod5vZKP2Yw6EJ6b5mh9/CcP51fzcH61vqBnzZe92nzxPLiG+Urt1n8R3+C5i77cPVfFm4bfnD/O2Op9APDl20M=
|
||||
eJzNkssNwjAQRC0kDmkgVEJz1EILNkIUQFqI04IvdMARW8kqo9GuY6QccnjKR8/2eHfjybmYmTKPTDBIC9PyfTcQT9vj0zt3vczvA8Deq1u9CPiKlwD2Avx7ditvyjEY3qjkkLXoFTiHrGWv8O3np5yZDA/zBiUfMxr3QLhvmqPV8Uge9q/mYf9qdUHP6i97tf7iPPiG/srdrXOR0OD5jbr8O1fFu533mT/O2Or9AHVB2mY=
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="2" name="Objects" width="10" height="30">
|
||||
<layer name="Objects" width="10" height="30">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJx9k7FOw0AMhq0sGZCgdymJMsACvAKPwMbMzMBT8Ao8CqwsfYA0YWMoQjCBVJUiQVVERZEQ2Lqzzuck/JKV9Pydz//FBWjrxgAcFgBHRTt3It6nOcBMxCgPucskvK9w/QHjrHDPSnCsJwuwtC53jfHquSwFGGJspzG/8twa4wLP2sP8PsZB2q5dI1Mjc2vdvi/fT5eIm6D/GmNexr0mecyR1sh8l8GjVuM5YqjmwoQeTgduD3lnVZh/N3GNNxP3MUzCuVr6bomR7FjVTjL3XNp4fSE46s9msd8u3Ys9H2U3u7EVanJ/uifWr2cmeahV9bAsYhrT9qD1KPrqO580U7lpz9zMlU89D89iDrS6ZnIHve96/+SDfY/FLFAv0q+eG9L5wNXXPlg/Yv1zM8zpf6LvfNfB8Dc6Fv999iu/Bc8a3wn9bkx8hy9qfq48+wcca3Tu
|
||||
eJx9k79OwzAQxk9ZMiBB7ZREGWABHgEegY2ZmefgFXgUWFn6APnDxlCEYAKpKh2gKqICJAR3ck4+Xxw+6VTX/vl8n30B6OvGABwVAMdFf+1UjGc5wFzEJPdrl4kfr3H+AeOwcFEJjvVkAVbWrV1j1LkbZynAGGM7Dfm14C7wrD1c38c4SPu5G2QaZG6t2/fZ1RMTcVP032AsyrDWJA850hcy36X3qNV2HDGUc2l8DWcjt4e8sypcfzNhjlcT1jFO/Lla+m6JkWytcieZ+13ZcH4pOKrPZqHfmO7Fnvcyzm5s+Zxcn66J9dsx09znqgZYFjGt6XvQehR1DZ1Pmqu12UDfLJRP3Q/Pog+0Yj25g953O//kg33XoheoFulX9w3pfOTyax+sHzH/sen79D/RO99FGH6jE/Hts1/5FtxrfCf0vzXhHb6o/rnq2D9B53PF
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="3" name="Objects_1" width="10" height="30">
|
||||
<layer name="Objects_1" width="10" height="30">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJxjYBgFxAImMcJqHokyMAgRoe4HUI0SEeqwgT+CxKn7RaS6UTAKiAXHBjhNAQC7GgVt
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="4" name="Above" width="10" height="30">
|
||||
<layer name="Above" width="10" height="30">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJxjYECAw2IMBEE4EF9CUpcizsDgAsShQBwmjqr2CZK6o0IMDM+AfFOgGjc0dRh2ANWaQdWVszMwVABxJTumulQhiP1pQNwOlO8A4k4s6pDBL0n88jDwkkh1r5DUPWYiTg82ANMLsvcVAbtTmSBqCKm9JIRdfDYWdxJjLylqqWkWKeadIVIdKeATjnBEBtjcR2p6uCmI3zwYwBZ/hACx4YcNYIsjapgXy4Qqhg6Q0/gjaBwAABL5Mp4=
|
||||
eJxjYECAw2IMBEE4EF9CUpcizsDgAsShQBwmjqr2CZK6o0IMDC+A/JdA7IamDsMOIYS6cnYGhgogrmTHVJcqBKHTgOragfIdQNyJRR0y+CWJXx4GXhKp7hWSusdMxOnBBmB6Qfa+ImB3KhNEDSG1l4Swi8/G4k5i7CVFLTXNIsW8M0SqIwV8whGOyACb+0hNDzcF8ZsHA9jijxAgNvywAWxxRA3zYplQxdABchp/BI0DAAj2M4o=
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="6" name="Top" width="10" height="30" visible="0">
|
||||
<layer name="Top" width="10" height="30">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJxjYKAMbBViYNgmBGGHCuFXe4yAPDlgNhMDwxwgfiVJfbNHAfWBEv9Au2AUDGUAAIJTBT4=
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="7" name="Walkable" width="10" height="30" visible="0">
|
||||
<layer name="Walkable" width="10" height="30" visible="0">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJy1kcsJACAMQ53C/Vfohp4KIs2nQguejMkzjb1WDJ6cjn6S52W6R/EwNkeHRmmVv+Pn7qLKVYxONxUzy0Vvmc7xc3vr8P3uAemZZ96hN0zHct1/dHQo1+kZdXcAPBOTsw==
|
||||
eJzbKMbAsJGGGAaorZZabkIGuNRiY5OjDhcgpJaQ+cSYR2z4YrOXkBuJCRtsbsZnLy69+NQRYx6x4UaK+8iNB1zq8ZkJk8OlB586fPYS6w9S1OGyl5hwxhV2AAQAkuw=
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="8" name="Walkable_2" width="10" height="30" visible="0">
|
||||
<layer name="Walkable_2" width="10" height="30" visible="0">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJy1kcsJACAMQ53C/Vfohp4KIs2nQguejMkzjb1WDJ6cjn6S52W6R/EwNkeHRmmVv+Pn7qLKVYxONxUzy0Vvmc7xc3vr8P3uAemZZ96hN0zHct1/dHQo1+kZdXcAPBOTsw==
|
||||
eJzbKMbAsJGGGAaorZZabkIGuNRiY5OjDhcgpJaQ+cSYR2z4YrOXkBuJCRtsbsZnLy69+NQRYx6x4UaK+8iNB1zq8ZkJk8OlB586fPYS6w9S1OGyl5hwxhV2AAQAkuw=
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="9" name="Walkable_1" width="10" height="30" visible="0">
|
||||
<layer name="Walkable_1" width="10" height="30" visible="0">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJzbKMbAsJFEjAyoqQ7GJsY8UtRRw0xkt1FDHbF+xqWHHIysF5f96OLEuJPY8Ka2Onzxh0sfsepIiRdqYkrdjSxOTPiRkq6IVYfPHej6sfHx2QEAYCeieA==
|
||||
eJzbKMbAsJFEjAyorQ6fWnLVUcNMmFpkmhJ1yPYRMg+bHnIwsl5c9qOLE+NOYsOb2urwxR8ufcSqIyVeqIkpdTeyODHhR0q6IlYdPneg68fGx2cHACgUobE=
|
||||
</data>
|
||||
</layer>
|
||||
<objectgroup id="10" name="Mapevents" visible="0">
|
||||
<object id="1" name="south" type="mapchange" x="64" y="928" width="64" height="32">
|
||||
<objectgroup name="Mapevents" visible="0">
|
||||
<object name="south" type="mapchange" x="64" y="928" width="64" height="32">
|
||||
<properties>
|
||||
<property name="map" value="blackwater_mountain14"/>
|
||||
<property name="place" value="north2"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="2" name="bwm17_vine_selector" type="script" x="224" y="800" width="96" height="32">
|
||||
<object name="bwm17_vine_selector" type="script" x="224" y="800" width="96" height="32">
|
||||
<properties>
|
||||
<property name="when" value="enter"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="3" name="bwm17_heights_1" type="script" x="32" y="896" width="128" height="32">
|
||||
<object name="bwm17_heights_1" type="script" x="32" y="896" width="128" height="32">
|
||||
<properties>
|
||||
<property name="when" value="enter"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="4" name="bwm17_heights2_1" type="script" x="256" y="480" width="32" height="96">
|
||||
<object name="bwm17_heights2_1" type="script" x="256" y="480" width="32" height="96">
|
||||
<properties>
|
||||
<property name="when" value="enter"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="5" name="bwm17_heights2_1" type="script" x="128" y="192" width="96" height="32">
|
||||
<object name="bwm17_heights2_1" type="script" x="128" y="192" width="96" height="32">
|
||||
<properties>
|
||||
<property name="when" value="enter"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="6" name="bwm17_heights_1" type="script" x="160" y="256" width="32" height="32">
|
||||
<object name="bwm17_heights_1" type="script" x="160" y="256" width="32" height="32">
|
||||
<properties>
|
||||
<property name="when" value="enter"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="8" name="hole" type="mapchange" x="288" y="320" width="32" height="32">
|
||||
<object name="hole" type="mapchange" x="288" y="320" width="32" height="32">
|
||||
<properties>
|
||||
<property name="map" value="blackwater_mountain71"/>
|
||||
<property name="place" value="up"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="10" name="east" type="mapchange" x="288" y="512" width="32" height="32">
|
||||
<object name="east" type="mapchange" x="288" y="512" width="32" height="32">
|
||||
<properties>
|
||||
<property name="map" value="blackwater_mountain15"/>
|
||||
<property name="place" value="west"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="11" name="bwm70_sign" type="script" x="128" y="288" width="32" height="32">
|
||||
<object name="bwm70_sign" type="script" x="128" y="288" width="32" height="32">
|
||||
<properties>
|
||||
<property name="when" value="enter"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="12" name="bwm17_heights2_1" type="script" x="256" y="736" width="32" height="96">
|
||||
<object name="bwm17_heights2_1" type="script" x="256" y="736" width="32" height="96">
|
||||
<properties>
|
||||
<property name="when" value="enter"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="13" name="east2" type="mapchange" x="288" y="704" width="32" height="96">
|
||||
<object name="east2" type="mapchange" x="288" y="704" width="32" height="96">
|
||||
<properties>
|
||||
<property name="map" value="blackwater_mountain15"/>
|
||||
<property name="place" value="west2"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="14" name="bwm70_corpse" type="script" x="224" y="512" width="32" height="32">
|
||||
<object name="bwm70_corpse" type="script" x="224" y="512" width="32" height="32">
|
||||
<properties>
|
||||
<property name="when" value="enter"/>
|
||||
</properties>
|
||||
</object>
|
||||
</objectgroup>
|
||||
<objectgroup id="11" name="Spawn" visible="0">
|
||||
<object id="15" name="forestboar2" type="spawn" x="64" y="576" width="96" height="256">
|
||||
<objectgroup name="Spawn" visible="0">
|
||||
<object name="forestboar2" type="spawn" x="64" y="576" width="96" height="256">
|
||||
<properties>
|
||||
<property name="quantity" value="2"/>
|
||||
<property name="spawngroup" value="forestboar4"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="16" name="gornaud_2" type="spawn" x="128" y="64" width="128" height="128">
|
||||
<object name="gornaud_2" type="spawn" x="128" y="64" width="128" height="128">
|
||||
<properties>
|
||||
<property name="spawngroup" value="gornaud_2"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="17" name="gornaud_1" type="spawn" x="192" y="416" width="96" height="128">
|
||||
<object name="gornaud_1" type="spawn" x="192" y="416" width="96" height="128">
|
||||
<properties>
|
||||
<property name="spawngroup" value="gornaud_2"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="18" name="forestboar1" type="spawn" x="32" y="288" width="96" height="160">
|
||||
<object name="forestboar1" type="spawn" x="32" y="288" width="96" height="160">
|
||||
<properties>
|
||||
<property name="spawngroup" value="forestboar4"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="19" name="primwolf2" type="spawn" x="64" y="224" width="32" height="64">
|
||||
<object name="primwolf2" type="spawn" x="64" y="224" width="32" height="64">
|
||||
<properties>
|
||||
<property name="spawngroup" value="primwolf2"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="27" name="bwm17_worker" type="spawn" x="128" y="288" width="32" height="32">
|
||||
<object name="bwm17_worker" type="spawn" x="128" y="288" width="32" height="32">
|
||||
<properties>
|
||||
<property name="spawngroup" value="bwm17_worker"/>
|
||||
</properties>
|
||||
</object>
|
||||
</objectgroup>
|
||||
<objectgroup id="12" name="Keys" visible="0">
|
||||
<object id="57" name="bwm17_hole" type="key" x="288" y="320" width="32" height="32">
|
||||
<objectgroup name="Keys" visible="0">
|
||||
<object name="bwm17_hole" type="key" x="288" y="320" width="32" height="32">
|
||||
<properties>
|
||||
<property name="phrase" value="bwm17_vine2_1"/>
|
||||
<property name="requireId" value="bwm17_vine"/>
|
||||
@@ -333,7 +334,7 @@
|
||||
<property name="requireValue" value="2"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="26" name="bwm17_questenabled" type="key" x="160" y="256" width="32" height="64">
|
||||
<object name="bwm17_questenabled" type="key" x="160" y="256" width="32" height="64">
|
||||
<properties>
|
||||
<property name="phrase" value="bwm17_questenabled"/>
|
||||
<property name="requireId" value="bwm17_vine"/>
|
||||
@@ -342,8 +343,8 @@
|
||||
</properties>
|
||||
</object>
|
||||
</objectgroup>
|
||||
<objectgroup id="13" name="Replace" visible="0">
|
||||
<object id="30" name="bwm17_questenabled2" type="replace" x="256" y="832" width="32" height="32">
|
||||
<objectgroup name="Replace" visible="0">
|
||||
<object name="bwm17_questenabled2" type="replace" x="256" y="832" width="32" height="32">
|
||||
<properties>
|
||||
<property name="Objects" value="Objects_1"/>
|
||||
<property name="requireId" value="bwm17_vine"/>
|
||||
@@ -351,17 +352,17 @@
|
||||
<property name="requireValue" value="3"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="20" name="bwm17_vine:2" type="replace" x="288" y="320" width="32" height="64">
|
||||
<object name="bwm17_vine:2" type="replace" x="288" y="320" width="32" height="64">
|
||||
<properties>
|
||||
<property name="Objects" value="Objects_1"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="21" name="bwm17_vine:1" type="replace" x="256" y="832" width="32" height="32">
|
||||
<object name="bwm17_vine:1" type="replace" x="256" y="832" width="32" height="32">
|
||||
<properties>
|
||||
<property name="Objects" value="Above"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="22" name="bwm17_heights:1" type="replace" x="32" y="0" width="256" height="960">
|
||||
<object name="bwm17_heights:1" type="replace" x="32" y="0" width="256" height="960">
|
||||
<properties>
|
||||
<property name="Walkable" value="Walkable_2"/>
|
||||
<property name="requireId" value="bwm17_heights"/>
|
||||
@@ -369,7 +370,7 @@
|
||||
<property name="requireValue" value="1"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="23" name="bwm17_heights:2" type="replace" x="32" y="0" width="256" height="960">
|
||||
<object name="bwm17_heights:2" type="replace" x="32" y="0" width="256" height="960">
|
||||
<properties>
|
||||
<property name="Walkable" value="Walkable_1"/>
|
||||
<property name="requireId" value="bwm17_heights"/>
|
||||
@@ -378,7 +379,7 @@
|
||||
<property name="requireValue" value="1"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="24" name="bwm17_heights:2" type="replace" x="288" y="384" width="32" height="256">
|
||||
<object name="bwm17_heights:2" type="replace" x="288" y="384" width="32" height="256">
|
||||
<properties>
|
||||
<property name="Walkable" value="Walkable_1"/>
|
||||
<property name="requireId" value="bwm17_heights"/>
|
||||
@@ -387,7 +388,7 @@
|
||||
<property name="requireValue" value="1"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="25" name="bwm17_heights:1" type="replace" x="288" y="384" width="32" height="256">
|
||||
<object name="bwm17_heights:1" type="replace" x="288" y="384" width="32" height="256">
|
||||
<properties>
|
||||
<property name="Walkable" value="Walkable_2"/>
|
||||
<property name="requireId" value="bwm17_heights"/>
|
||||
@@ -395,7 +396,7 @@
|
||||
<property name="requireValue" value="1"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="29" name="bwm17_questenabled1" type="replace" x="128" y="224" width="64" height="96">
|
||||
<object name="bwm17_questenabled1" type="replace" x="128" y="224" width="64" height="96">
|
||||
<properties>
|
||||
<property name="Objects" value="Objects_1"/>
|
||||
<property name="requireId" value="bwm17_vine"/>
|
||||
|
||||
@@ -1,296 +1,296 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="25" height="20" tilewidth="32" tileheight="32" infinite="0" nextlayerid="12" nextobjectid="18">
|
||||
<tileset firstgid="1" name="map_bed_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<!DOCTYPE map SYSTEM "http://mapeditor.org/dtd/1.0/map.dtd">
|
||||
<map version="1.0" orientation="orthogonal" width="25" height="20" tilewidth="32" tileheight="32">
|
||||
<tileset firstgid="1" name="map_bed_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_bed_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="129" name="map_border_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="129" name="map_border_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_border_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="257" name="map_bridge_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="257" name="map_bridge_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_bridge_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="385" name="map_bridge_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="385" name="map_bridge_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_bridge_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="513" name="map_broken_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="513" name="map_broken_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_broken_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="641" name="map_cavewall_1" tilewidth="32" tileheight="32" tilecount="108" columns="18">
|
||||
<tileset firstgid="641" name="map_cavewall_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cavewall_1.png" width="576" height="192"/>
|
||||
</tileset>
|
||||
<tileset firstgid="749" name="map_cavewall_2" tilewidth="32" tileheight="32" tilecount="108" columns="18">
|
||||
<tileset firstgid="749" name="map_cavewall_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cavewall_2.png" width="576" height="192"/>
|
||||
</tileset>
|
||||
<tileset firstgid="857" name="map_cavewall_3" tilewidth="32" tileheight="32" tilecount="108" columns="18">
|
||||
<tileset firstgid="857" name="map_cavewall_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cavewall_3.png" width="576" height="192"/>
|
||||
</tileset>
|
||||
<tileset firstgid="965" name="map_cavewall_4" tilewidth="32" tileheight="32" tilecount="108" columns="18">
|
||||
<tileset firstgid="965" name="map_cavewall_4" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cavewall_4.png" width="576" height="192"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1073" name="map_chair_table_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1073" name="map_chair_table_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_chair_table_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1201" name="map_chair_table_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1201" name="map_chair_table_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_chair_table_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1329" name="map_crate_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1329" name="map_crate_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_crate_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1457" name="map_cupboard_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1457" name="map_cupboard_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cupboard_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1585" name="map_curtain_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1585" name="map_curtain_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_curtain_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1713" name="map_entrance_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1713" name="map_entrance_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_entrance_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1841" name="map_entrance_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1841" name="map_entrance_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_entrance_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1969" name="map_fence_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1969" name="map_fence_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_fence_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2097" name="map_fence_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2097" name="map_fence_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_fence_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2225" name="map_fence_3" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2225" name="map_fence_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_fence_3.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2353" name="map_fence_4" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2353" name="map_fence_4" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_fence_4.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2481" name="map_ground_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2481" name="map_ground_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2609" name="map_ground_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2609" name="map_ground_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2737" name="map_ground_3" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2737" name="map_ground_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_3.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2865" name="map_ground_4" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2865" name="map_ground_4" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_4.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2993" name="map_ground_5" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2993" name="map_ground_5" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_5.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3121" name="map_ground_6" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3121" name="map_ground_6" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_6.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3249" name="map_ground_7" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3249" name="map_ground_7" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_7.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3377" name="map_ground_8" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3377" name="map_ground_8" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_8.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3505" name="map_house_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3505" name="map_house_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_house_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3633" name="map_house_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3633" name="map_house_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_house_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3761" name="map_indoor_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3761" name="map_indoor_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_indoor_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3889" name="map_indoor_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3889" name="map_indoor_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_indoor_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4017" name="map_kitchen_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4017" name="map_kitchen_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_kitchen_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4145" name="map_outdoor_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4145" name="map_outdoor_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_outdoor_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4273" name="map_pillar_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4273" name="map_pillar_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_pillar_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4401" name="map_pillar_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4401" name="map_pillar_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_pillar_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4529" name="map_plant_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4529" name="map_plant_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_plant_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4657" name="map_plant_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4657" name="map_plant_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_plant_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4785" name="map_rock_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4785" name="map_rock_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_rock_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4913" name="map_rock_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4913" name="map_rock_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_rock_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5041" name="map_roof_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5041" name="map_roof_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_roof_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5169" name="map_roof_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5169" name="map_roof_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_roof_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5297" name="map_roof_3" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5297" name="map_roof_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_roof_3.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5425" name="map_shop_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5425" name="map_shop_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_shop_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5553" name="map_sign_ladder_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5553" name="map_sign_ladder_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_sign_ladder_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5681" name="map_table_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5681" name="map_table_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_table_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5809" name="map_trail_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5809" name="map_trail_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_trail_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5937" name="map_transition_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5937" name="map_transition_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_transition_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6065" name="map_transition_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6065" name="map_transition_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_transition_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6193" name="map_transition_3" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6193" name="map_transition_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_transition_3.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6321" name="map_transition_4" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6321" name="map_transition_4" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_transition_4.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6449" name="map_transition_6" tilewidth="32" tileheight="32" tilecount="144" columns="18">
|
||||
<tileset firstgid="6449" name="map_transition_6" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_transition_6.png" width="576" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6593" name="map_tree_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6593" name="map_tree_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_tree_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6721" name="map_tree_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6721" name="map_tree_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_tree_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6849" name="map_wall_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6849" name="map_wall_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_wall_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6977" name="map_wall_2" tilewidth="32" tileheight="32" tilecount="120" columns="15">
|
||||
<tileset firstgid="6977" name="map_wall_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_wall_2.png" width="480" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7097" name="map_wall_3" tilewidth="32" tileheight="32" tilecount="120" columns="15">
|
||||
<tileset firstgid="7097" name="map_wall_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_wall_3.png" width="480" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7217" name="map_wall_4" tilewidth="32" tileheight="32" tilecount="120" columns="15">
|
||||
<tileset firstgid="7217" name="map_wall_4" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_wall_4.png" width="480" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7337" name="map_window_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="7337" name="map_window_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_window_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7465" name="map_window_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="7465" name="map_window_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_window_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7593" name="map_cavewall_5" tilewidth="32" tileheight="32" tilecount="36" columns="6">
|
||||
<tileset firstgid="7593" name="map_cavewall_5" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cavewall_5.png" width="192" height="192"/>
|
||||
</tileset>
|
||||
<layer id="11" name="Base" width="25" height="20">
|
||||
<layer name="Base" width="25" height="20">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJxjYECAHbKoeD8TA8MBKKYWQLfjItDsS1BMKzu2cDIwPGGCYGrasQ+K4eEF5VML7ASadQoJb5eFiB2hoR17of44RUM7DgPxUSqaDwMgs09wIvAOGtgBAsjmD7QdlLiBnv5AtofadiHbQat4RzYfF9jMCcFDGWBz/5Yh7icQINUPQ9XPAO6PSGM=
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="1" name="Ground" width="25" height="20">
|
||||
<layer name="Ground" width="25" height="20">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJyllb1OwzAQgE23dGB0prwGCxIT4g3gAUA8ARJvADs/YsrISjqkAyAgQYBUCkvLgspIhPiZQerGnexTzOUSp8LSJ0d27j6fkzhJR6kE6AGPoVILwApwAVCj+aQlJzXjTQ7yxC2pc3MHttdO6cjgOp+hFolrYGgdy8Ca9ZzbfgTzYxaTC0i5c5v/ya55G3I+B0rtsr0iR+bEjAX4/iZ2HPP3g3aOkROzPqfUlsOG7clHz76w+SXHfaTUQ1TOF8wh1eH6yEHxxA7kPrY1TPRfB+I6Ckuqy2uc3+sqtd8tHVeQ49TJcwbXh9bxBbEDXV0H1X4AeVLoB4HpaZ47biHnZWRcSBaZ/ToKTR1TwUG8absOj2MIOW8i40LuIrNX+Dw+If6jwdEP5DoI/jzQheC9mBfbjzae9wZXG0fcqcZMdfnOvmjDf+qgc4TGl9h3hPHoSIOSRbhnNTQ0OfhZxdc1K9zBz17u8LHJ1o9MdLND+hZ9SHvkO997zBML70OdA9+Ruv+S5Pier94vuXgdbf8hvv+YW5vr8NXwC+C0Vkw=
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="2" name="Objects" width="25" height="20">
|
||||
<layer name="Objects" width="25" height="20">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJxjYECAM+IMDGZA7CbOQDMw3OxwAeLHQrSzBx28BtrFJEaZGbJMEHoNE241QlA78nCoCRVmYAgTxm8PzPyNggixacDwOiMLYSsB7XgMVFMHVccJpSdzMTBIsjMwSAGxNBAnMeK35xE0/DdDzV0GtCNMHCGnCTRXC2q2JJIdmkCzQ4HqtIF0CNCOYAL2CKL5F5a+QP6zBJprBcSrkcIWZEcIVA3IPSeg/kUH8mhiD5HSE3IaFsIR3mbiCLUgOxqh+qWw2HVeElMMWz4BhZs41L7jYph2YHMrCJwExsF9qB2nZVHtCMORH0HuxWeHOA5/g/SEoJnpArXnFVDuBRp+jccOXADZXej2hKLhO4IQ7IpmB8z9s3HkJWQ7LhFRlqgA1ZiQ4Y8UoNpUAvg20P2mULNNoGJpQPwTaocuDvcdBsp/A+IfRODbaPFwSwxhPjEAFEbIYTkXyP4EFGvkZ2D4LAoJb/T09EmUePMTBRgYmgWwy81FshdfmqUWQLeDEAAA3c9nPQ==
|
||||
eJxjYECAM+IMDGZA7CbOQDMw3OxwAeLHQrSzBx28BtrFJEaZGbJMEHoNE241QlA78nCoCRVmYAgTxm8PzPyNggixacDwOiMLYSsB7XgMVFMHVccJpSdzMTBIsjMwSAGxNBAnMeK35xE0/DdDzV0GtCNMHCGnCTRXC2q2JJIdmkCzQ4HqtIF0CNCOYAL2CKL5F5a+QP6zBJprBcSrkcIWZIcZVA3IPSeg/kUH8mhiD5HSE3IaFsIR3jA73KB2NEL1S2Gx67wkphi2fAIKN3GofcfFMO3A5lYQOAmMg/tQO07LotoRhiM/gtyLzw5xHP4G6QlBM9MFas8roNwLNPwajx24ALK70O0JRcN3BCHYFc0OmPtn48hLyHZcIqIsUQGqMSHDHylAtakE8G2g+02hZptAxdKA+CfUDl0c7jsMlP8GxD+IwLfR4uGWGMJ8YgAojJDDci6Q/Qko1sjPwPBZFBLe6Onpkyjx5icKMDA0C2CXm4tkL740Sy2AbgchAABYr2cf
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="3" name="Above" width="25" height="20">
|
||||
<layer name="Above" width="25" height="20">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJxjYECAw2IMeAEheWIANcwYLHacFWRgSBFmYAgTp775l4HmXwLiMqjZbUh24PLfZSzi+5kYGA5AMTq4BFVPih3YxC8CzX4CxbgANjsu4bEjiJGBIRiIIxlxm4kMGIUh9FKg+cuA+KQsfvXIdm8UYmDYJEScPSCALZwv4dBfCBU/CKQPkWAHoTTMLky8WbgArvAnBVDDHaSCuXjSGakAn/uxxTO1wXApD4mNE1zhPZtI/eTGSTwJaYbc8CLWD6QAUtM6APB1Kig=
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="10" name="Top" width="25" height="20">
|
||||
<layer name="Top" width="25" height="20">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJxjYBgFo2DwgcNiw8OOS3SwYxSMglEwCkAAAJHuAps=
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="4" name="Walkable" width="25" height="20">
|
||||
<layer name="Walkable" width="25" height="20" visible="0">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJzdk10KwCAMgz3F7n8FbzgGeyjSxKTqiwVh/vVL2tmf1vo/vsi+d45bGTFOMOL8JENZd/yyM+o64ilaqv4yBtO2wpj9QyMf+WY6q31lc+TdYSDts/xsn7FcHyh/Vht2X9HJ3pGioVILtQaKRjcq/tm5LK/Sx5W+R0alf45nhfECz/MDsg==
|
||||
</data>
|
||||
</layer>
|
||||
<objectgroup id="5" name="Mapevents" visible="0">
|
||||
<object id="2" name="down1" type="mapchange" x="544" y="544" width="32" height="32">
|
||||
<objectgroup name="Mapevents" visible="0">
|
||||
<object name="down1" type="mapchange" x="544" y="544" width="32" height="32">
|
||||
<properties>
|
||||
<property name="map" value="blackwater_mountain74_h"/>
|
||||
<property name="place" value="up1"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="3" name="down2" type="mapchange" x="352" y="544" width="32" height="32">
|
||||
<object name="down2" type="mapchange" x="352" y="544" width="32" height="32">
|
||||
<properties>
|
||||
<property name="map" value="blackwater_mountain74_h"/>
|
||||
<property name="place" value="up2"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="4" name="west1" type="mapchange" x="0" y="224" width="32" height="64">
|
||||
<object name="west1" type="mapchange" x="0" y="224" width="32" height="64">
|
||||
<properties>
|
||||
<property name="map" value="blackwater_mountain75"/>
|
||||
<property name="place" value="east2"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="6" name="bwm74_waterfall" type="script" x="448" y="608" width="96" height="32">
|
||||
<object name="bwm74_waterfall" type="script" x="448" y="608" width="96" height="32">
|
||||
<properties>
|
||||
<property name="when" value="enter"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="7" name="bwm74_drop1" type="container" x="128" y="576" width="32" height="32"/>
|
||||
<object id="8" name="north2" type="mapchange" x="96" y="0" width="32" height="32">
|
||||
<object name="bwm74_drop1" type="container" x="128" y="576" width="32" height="32"/>
|
||||
<object name="north2" type="mapchange" x="96" y="0" width="32" height="32">
|
||||
<properties>
|
||||
<property name="map" value="blackwater_mountain73"/>
|
||||
<property name="place" value="south2"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="9" name="north1" type="mapchange" x="192" y="0" width="32" height="32">
|
||||
<object name="north1" type="mapchange" x="192" y="0" width="32" height="32">
|
||||
<properties>
|
||||
<property name="map" value="blackwater_mountain73"/>
|
||||
<property name="place" value="south1"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="10" name="bwm73_drop" type="container" x="128" y="288" width="32" height="32"/>
|
||||
<object id="11" name="bwm73_drop" type="container" x="704" y="320" width="32" height="32"/>
|
||||
<object name="bwm73_drop" type="container" x="128" y="288" width="32" height="32"/>
|
||||
<object name="bwm73_drop" type="container" x="704" y="320" width="32" height="32"/>
|
||||
</objectgroup>
|
||||
<objectgroup id="6" name="Spawn" visible="0">
|
||||
<object id="12" name="bwm74_monster1" type="spawn" x="256" y="192" width="256" height="256">
|
||||
<objectgroup name="Spawn" visible="0">
|
||||
<object name="bwm74_monster1" type="spawn" x="256" y="192" width="256" height="256">
|
||||
<properties>
|
||||
<property name="quantity" value="3"/>
|
||||
<property name="spawngroup" value="venomfang_2"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="13" name="bwm74_monster2" type="spawn" x="256" y="288" width="256" height="96">
|
||||
<object name="bwm74_monster2" type="spawn" x="256" y="288" width="256" height="96">
|
||||
<properties>
|
||||
<property name="quantity" value="3"/>
|
||||
<property name="spawngroup" value="tough_venomfang"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="14" name="bwm74_monster3" type="spawn" x="640" y="384" width="96" height="128">
|
||||
<object name="bwm74_monster3" type="spawn" x="640" y="384" width="96" height="128">
|
||||
<properties>
|
||||
<property name="quantity" value="2"/>
|
||||
<property name="spawngroup" value="kazaul_1"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="15" name="bwm74_monster4" type="spawn" x="480" y="160" width="256" height="64">
|
||||
<object name="bwm74_monster4" type="spawn" x="480" y="160" width="256" height="64">
|
||||
<properties>
|
||||
<property name="quantity" value="2"/>
|
||||
<property name="spawngroup" value="bwm_olm"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="16" name="bwm74_monster5" type="spawn" x="64" y="384" width="256" height="192">
|
||||
<object name="bwm74_monster5" type="spawn" x="64" y="384" width="256" height="192">
|
||||
<properties>
|
||||
<property name="quantity" value="4"/>
|
||||
<property name="spawngroup" value="bwm_olm"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="17" name="bwm74_monster6" type="spawn" x="64" y="192" width="96" height="96">
|
||||
<object name="bwm74_monster6" type="spawn" x="64" y="192" width="96" height="96">
|
||||
<properties>
|
||||
<property name="quantity" value="1"/>
|
||||
<property name="spawngroup" value="bwm_olm"/>
|
||||
</properties>
|
||||
</object>
|
||||
</objectgroup>
|
||||
<objectgroup id="7" name="Keys" visible="0"/>
|
||||
<objectgroup id="8" name="Replace" visible="0"/>
|
||||
<objectgroup name="Keys" visible="0"/>
|
||||
<objectgroup name="Replace" visible="0"/>
|
||||
</map>
|
||||
|
||||
@@ -197,12 +197,12 @@
|
||||
</layer>
|
||||
<layer name="Ground" width="18" height="20">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJyNVMGNwkAMjMIPKW9ekfLlOjgkGoAKgAq4u1aumfvcBikEKcmHcqgAW3iUidkEHiOt7d0Zr2eTTZYkG8NWEPIeZ4LGlaAW7GTfIXvEml/Me4611cBRClqCnmkEHfE2lteYOVhfda8EPfNv+dbW4NJ4bxy101fd22yIk+Wv1EewGPfonD6f/8sfKCmPPqp8OAuvDRyl1y/Bd/a8j+/reaDt/cLMYlrgQV3jYtbn2nx8Zr+LIU9J9Yp0/bz8zHw/3GsT0X0HIXJmzCvA15Zpknykz7XY/MBxIk+09iMefgrHKp32IZin7Bfz8Lfo58G++++sc97CJ/92/D3gP/yqSfMVD7xn/8+O4x0eeM/3iL2FMMGDmVzsHnij/i3wfEta81z9npiHYzxTYA79fyrgR0G8d78CLVg=
|
||||
eJyNVEFOw0AMjNJbpZx7WqnX8gOQ+EB5AfACWr7CZ7iwQUpSKc2lz+EF2KpHmTgm9DDS2t6dWXs22VdFsTc8CXIa0RI0bgSd4Fn2vVbXWPOb9cjxaDVw1IIzQc/0goF4e8trzBysr7oXgp75svzZ1uDS+MU4Oqevuj+rKb4tf6F7ZIvRx+D0+fxnuqKmPO7RpOksvDbwJnc9CI7VfB/363mg7f3CzCIt8KCu8XY19yqa2cdmylNTvUmxV9HM/H34rn2gewtycCbyKqdxbr62K4virpzXovnx7OGJ1t7Fw3vheCiXfcjmKfvFPPwt+nmwtv/OBuctfPJvx2vgTcCvjjT/44H3LZ1rHcctPPCe+4jeQl7gQS8n6wNv1L8F7rumNc/V74k8/ItnCcyh/08F/NgS7y8DZS1z
|
||||
</data>
|
||||
</layer>
|
||||
<layer name="Objects" width="18" height="20">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJyNU81KA0EMHhZkUQplZnUXxbH4d/MZ9QmkT7D1AaSWtZ70WBS0vagn0Yse9OBJj8WDEydhMj9b/GBoJ5t8yZdkhPBxrYS4Ue7+o0SEdynEs3T3uyr2mZjvbxhb5EKsmrOWx36L0Ej/vmvi98zZR55bLcTUnOOuvR9hHR+s5hn+72XO9ln5h1Ajz9DYztB+kNAP/JD3r0ZtddbG/6Sy9iHyrLCcVAfFeTqZDXKPWE2gcSOLYyhugHnPkeMrqBfqIh/iC0F967O8oHGZ5YW6DitrB67XRF+ob6NgH9aRh7S3+fHe9IKYVD6OJqGLtPJZAS7M74uyv2OdjgeNk7I931y7mY8TuQGdItaoCpfvGzWFM+eagHuz8HOEtfK7/Mcbm7ZwUW2A7Tze1ZrtEccp+j0smBFxQU9g3/oJHpoXf78Ql5Vx3dAT6lsH637sOj18zylOlbGmJuBMYabt+73Hd78T7EWj43cGINuAfZOYA3brSdrYS2O/wjjozdKW7Q/M/BeybG9i
|
||||
eJyNU81KA0EMDguyKIUys9pFcSz+3XxGfQLpE2x9glq2vSmeioK2F/UketGDHjzpUXpw4iRMdmZa/GBoJ5t8yZdkAJq41gA32t/nGiK8K4Bn5e93Zewzsd/fKLbIAdbt2chjv2WoVfO+b+MP7DkknlsDMLXntO3uJ1THh6h5Rv+7mbd9ls3DqIhnYG3nZD9K6Ed+zPtXo3E6K+t/Vjr7gHjWRE6ug+MaOoUNcw9FTahxK4tjGH3KOyKOr6BerIt9mC8E960n8qLGVZEX6zounR25XhN94b4Ng33YJB7WvshP9qYbaE7lk6gTulirnBUCe/Wi3e/YpONR46SzON+P8TMfJ3IjWkWsURc+3zdpCmcuNSH3dtHMEdYq7+ofb2wacI3ocG2I3Tze1UrskcQV+T0smRFzYU9w33oJHp6XfL8Yl3XiurEn3LcW1f3Y9r2Qe85xuhNrqgPOFGbGvd97evd7wV7UJn5nCLb1xTdFOXC3npSLvbD2S4rD3qzsuP7gzH8BfatvWA==
|
||||
</data>
|
||||
</layer>
|
||||
<layer name="Above" width="18" height="20">
|
||||
@@ -212,12 +212,12 @@
|
||||
</layer>
|
||||
<layer name="Top" width="18" height="20">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJxjYCAdHBajjvpLVDLnMgFz0PVhsxdkBj73EJLHZRep8qSYM1ecNu7BJkZq2BAbXpTYS4o5tAYg/+JLh4TSKAyA3I7P/fjCA1kfPnNIyS+H8cQjPndeRrKfUFrAZw6yPwilBWzmPBZDyJGTloixg5YAAIa2LzU=
|
||||
eJxjYCAdHBajjvpLVDLnMgFz0PVhsxdkBj73EJLHZRep8qSYM1ec+u7B5UdSw4bUuMXmFmqaQw+ALx0SSqPI6vC5H194IOs7jMccUvLLYTzpHp87kf1BKO/gMwfZH4TSAjZzHosh5MhJS8TYQUsAAMVrLYI=
|
||||
</data>
|
||||
</layer>
|
||||
<layer name="Walkable" width="18" height="20">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJylkssNwCAMQ5mC/Vfohj30klr+IZA4REQvtsla//Ps786avc/rDutnMxIr6VCcpNfpU+w0o/XNdKBXxW78sVmM0+h2mhXPZZk47X4pRsO99c1qlensTXpPtap+nOd0ubwUBz0hK+Wj+pw/5N/sXtpdpQt9uixU3f7vC56Koz8=
|
||||
eJzbKMbAsHGIYGQwmMzBJk6s/fjMwGcOse4nxh5SwwybWaSYgy8OsPGJAYTChlBYUhJXpJhDbPogR46a5iDL41JLTHhQyxxi1BLrJ0L2EROulJpBLAYA0IfZqQ==
|
||||
</data>
|
||||
</layer>
|
||||
<objectgroup name="Mapevents">
|
||||
@@ -245,19 +245,24 @@
|
||||
</object>
|
||||
<object name="elm5f_potion" type="container" x="32" y="544" width="32" height="32"/>
|
||||
</objectgroup>
|
||||
<objectgroup name="Spawn">
|
||||
<objectgroup name="Spawn" visible="0">
|
||||
<object name="elm5f_monster1" type="spawn" x="416" y="320" width="32" height="160">
|
||||
<properties>
|
||||
<property name="quantity" value="2"/>
|
||||
<property name="spawngroup" value="elm_mine5"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object name="elm5f_monster2" type="spawn" x="224" y="128" width="64" height="32">
|
||||
<object name="elm5f_monster2" type="spawn" x="224" y="96" width="96" height="32">
|
||||
<properties>
|
||||
<property name="quantity" value="2"/>
|
||||
<property name="spawngroup" value="elm_mine5"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object name="elm5f_monster3" type="spawn" x="224" y="96" width="96" height="32">
|
||||
<properties>
|
||||
<property name="spawngroup" value="elm_mine6"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object name="elm5f_monster4" type="spawn" x="32" y="416" width="64" height="128">
|
||||
<properties>
|
||||
<property name="quantity" value="3"/>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="10" height="15" tilewidth="32" tileheight="32" infinite="0" nextlayerid="10" nextobjectid="4">
|
||||
<map version="1.2" tiledversion="1.3.0" orientation="orthogonal" renderorder="right-down" compressionlevel="0" width="10" height="15" tilewidth="32" tileheight="32" infinite="0" nextlayerid="10" nextobjectid="4">
|
||||
<tileset firstgid="1" name="map_bed_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<image source="../drawable/map_bed_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
@@ -188,27 +188,27 @@
|
||||
</tileset>
|
||||
<layer id="1" name="Ground" width="10" height="15">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJzFzrEOQDAQxvGbSVebB+MxGdoOGOjSd2DjOVxD43OpsBn+SdP7pb22IGoTmfJeykTXP7gG7i03cZ1wOA+zgfPcyOnyMjgPM8dViqhWh9PiHyf2j7ug8+c5y480eHQztzw43H/lNnDSGPHfm7Mf3kKX2usvtwO5cXBE
|
||||
eAG9jjEOgkAQRaeG0NJ5MDwmFGqhFkrDHbSTc/Bf9CeTDYaO4mV257+d2aGNGFY4HyIyaw49nFtys9en/kXnp7j+eva8g5zsLibxECfhHTknG0XXRBwFHjDLe8g9m+q/ZI89ZFX9xRk9n5n3Eu8/nnfgfcScPGdl9T7XMvedmVsOrj3/2e/Luqe3ALlxcEQ=
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="2" name="Objects" width="10" height="15">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJxjYCAfbJQlT44cNTuA9D4o+ySQPo3ExgVg6vDZA5LfJc7AsFucsFvOANXsoYK61+IQ/IZI84YiAACtyhQK
|
||||
eAFjYCAfbJTFrRefHEwXKWp2AO3aB7XvJJA+jcSGmYdOw9Thswdkzi5xBobdQEwInAGq2UMFda+BZoDwGyLNI+SuwSgPAK3KFAo=
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="3" name="Above" width="10" height="15">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJxjYBj+YKPsQLsAFRwWQ7CJcdtgcz8xAAAtXANE
|
||||
eAFjYBj+YKPs4PLjYTGEe4hxGzFqECYODhYALVwDRA==
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="4" name="Top" width="10" height="15" locked="1">
|
||||
<layer id="4" name="Top" width="10" height="15">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJxjYKAfOCxGHXWXofKXcKg7TECe2u4hVd1mWeLUgcDlAXIjpeoAQ7UM7Q==
|
||||
eAFjYKAfOCxGnF2E1F2GmnMJh3kw/bjkYa6AqYPxcdHUVrdZFpdNmOIwv2LKoIpQ242UmgcAQ7UM7Q==
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="5" name="Walkable" width="10" height="15" visible="0">
|
||||
<layer id="5" name="Walkable" width="10" height="15">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJxjYMAONoqhYmLUIKvDJoeujpAaaplBSB0hNxPyM64wosROavuR3uoAgCRbuw==
|
||||
eAFjYMAONooxMCBjbKqQ5WFsmDoYHxcNUodLjlhxYs0gpA4kDwK47IXIIkhK1YH0wwAus2DiIHUwNj56sKkDAJoTWvQ=
|
||||
</data>
|
||||
</layer>
|
||||
<objectgroup id="6" name="Mapevents">
|
||||
|
||||
@@ -1,351 +1,352 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="15" height="20" tilewidth="32" tileheight="32" infinite="0" nextlayerid="12" nextobjectid="29">
|
||||
<tileset firstgid="1" name="map_bed_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<!DOCTYPE map SYSTEM "http://mapeditor.org/dtd/1.0/map.dtd">
|
||||
<map version="1.0" orientation="orthogonal" width="15" height="20" tilewidth="32" tileheight="32">
|
||||
<tileset firstgid="1" name="map_bed_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_bed_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="129" name="map_border_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="129" name="map_border_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_border_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="257" name="map_bridge_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="257" name="map_bridge_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_bridge_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="385" name="map_bridge_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="385" name="map_bridge_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_bridge_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="513" name="map_broken_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="513" name="map_broken_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_broken_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="641" name="map_cavewall_1" tilewidth="32" tileheight="32" tilecount="108" columns="18">
|
||||
<tileset firstgid="641" name="map_cavewall_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cavewall_1.png" width="576" height="192"/>
|
||||
</tileset>
|
||||
<tileset firstgid="749" name="map_cavewall_2" tilewidth="32" tileheight="32" tilecount="108" columns="18">
|
||||
<tileset firstgid="749" name="map_cavewall_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cavewall_2.png" width="576" height="192"/>
|
||||
</tileset>
|
||||
<tileset firstgid="857" name="map_cavewall_3" tilewidth="32" tileheight="32" tilecount="108" columns="18">
|
||||
<tileset firstgid="857" name="map_cavewall_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cavewall_3.png" width="576" height="192"/>
|
||||
</tileset>
|
||||
<tileset firstgid="965" name="map_cavewall_4" tilewidth="32" tileheight="32" tilecount="108" columns="18">
|
||||
<tileset firstgid="965" name="map_cavewall_4" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cavewall_4.png" width="576" height="192"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1073" name="map_chair_table_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1073" name="map_chair_table_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_chair_table_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1201" name="map_chair_table_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1201" name="map_chair_table_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_chair_table_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1329" name="map_crate_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1329" name="map_crate_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_crate_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1457" name="map_cupboard_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1457" name="map_cupboard_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cupboard_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1585" name="map_curtain_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1585" name="map_curtain_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_curtain_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1713" name="map_entrance_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1713" name="map_entrance_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_entrance_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1841" name="map_entrance_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1841" name="map_entrance_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_entrance_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1969" name="map_fence_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1969" name="map_fence_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_fence_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2097" name="map_fence_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2097" name="map_fence_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_fence_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2225" name="map_fence_3" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2225" name="map_fence_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_fence_3.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2353" name="map_fence_4" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2353" name="map_fence_4" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_fence_4.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2481" name="map_ground_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2481" name="map_ground_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2609" name="map_ground_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2609" name="map_ground_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2737" name="map_ground_3" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2737" name="map_ground_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_3.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2865" name="map_ground_4" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2865" name="map_ground_4" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_4.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2993" name="map_ground_5" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2993" name="map_ground_5" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_5.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3121" name="map_ground_6" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3121" name="map_ground_6" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_6.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3249" name="map_ground_7" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3249" name="map_ground_7" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_7.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3377" name="map_ground_8" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3377" name="map_ground_8" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_8.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3505" name="map_house_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3505" name="map_house_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_house_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3633" name="map_house_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3633" name="map_house_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_house_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3761" name="map_indoor_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3761" name="map_indoor_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_indoor_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3889" name="map_indoor_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3889" name="map_indoor_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_indoor_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4017" name="map_kitchen_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4017" name="map_kitchen_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_kitchen_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4145" name="map_outdoor_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4145" name="map_outdoor_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_outdoor_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4273" name="map_pillar_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4273" name="map_pillar_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_pillar_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4401" name="map_pillar_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4401" name="map_pillar_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_pillar_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4529" name="map_plant_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4529" name="map_plant_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_plant_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4657" name="map_plant_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4657" name="map_plant_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_plant_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4785" name="map_rock_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4785" name="map_rock_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_rock_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4913" name="map_rock_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4913" name="map_rock_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_rock_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5041" name="map_roof_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5041" name="map_roof_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_roof_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5169" name="map_roof_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5169" name="map_roof_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_roof_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5297" name="map_roof_3" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5297" name="map_roof_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_roof_3.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5425" name="map_shop_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5425" name="map_shop_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_shop_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5553" name="map_sign_ladder_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5553" name="map_sign_ladder_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_sign_ladder_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5681" name="map_table_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5681" name="map_table_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_table_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5809" name="map_trail_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5809" name="map_trail_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_trail_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5937" name="map_transition_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5937" name="map_transition_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_transition_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6065" name="map_transition_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6065" name="map_transition_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_transition_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6193" name="map_transition_3" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6193" name="map_transition_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_transition_3.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6321" name="map_transition_4" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6321" name="map_transition_4" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_transition_4.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6449" name="map_transition_6" tilewidth="32" tileheight="32" tilecount="144" columns="18">
|
||||
<tileset firstgid="6449" name="map_transition_6" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_transition_6.png" width="576" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6593" name="map_tree_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6593" name="map_tree_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_tree_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6721" name="map_tree_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6721" name="map_tree_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_tree_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6849" name="map_wall_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6849" name="map_wall_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_wall_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6977" name="map_wall_2" tilewidth="32" tileheight="32" tilecount="120" columns="15">
|
||||
<tileset firstgid="6977" name="map_wall_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_wall_2.png" width="480" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7097" name="map_wall_3" tilewidth="32" tileheight="32" tilecount="120" columns="15">
|
||||
<tileset firstgid="7097" name="map_wall_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_wall_3.png" width="480" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7217" name="map_wall_4" tilewidth="32" tileheight="32" tilecount="120" columns="15">
|
||||
<tileset firstgid="7217" name="map_wall_4" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_wall_4.png" width="480" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7337" name="map_window_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="7337" name="map_window_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_window_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7465" name="map_window_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="7465" name="map_window_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_window_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7593" name="map_cavewall_5" tilewidth="32" tileheight="32" tilecount="36" columns="6">
|
||||
<tileset firstgid="7593" name="map_cavewall_5" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cavewall_5.png" width="192" height="192"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7629" name="map_sign_ladder_omi2" tilewidth="32" tileheight="32" tilecount="32" columns="8">
|
||||
<tileset firstgid="7629" name="map_sign_ladder_omi2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_sign_ladder_omi2.png" width="256" height="128"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7661" name="map_rock_3" tilewidth="32" tileheight="32" tilecount="30" columns="6">
|
||||
<tileset firstgid="7661" name="map_rock_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_rock_3.png" width="192" height="160"/>
|
||||
</tileset>
|
||||
<layer id="1" name="Ground" width="15" height="20">
|
||||
<layer name="Ground" width="15" height="20">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJydkzEOwjAMRSuxwRkscX8xZUmKRDqEMrCX8+CIWHxcO60YntRYfk0cO4mGIe9gYq7MgwlMYsYWv28wt3zxxK3x5waSn5WbFOfDBx0f2xmi4Xq1oh8MV/7pEcG33F69kb51XBroHk8+sleBs+xxsS8JztJzA609rNtzi8pDd2Fe6h9ejdKbYLgTuPUu0V2agzHs0dzZN5Id69Xrud5s9Fy8q3/3resbrefc6qvkZVjLbOk3ovuJMxjbutDvm7Y8PYM40/X7DYqjz7w=
|
||||
eJydkzEOwjAMRSuxwRkicX8xZUmK1HZIy8BezoMjbPFx7bRieFJr+SVx7OTQdeMBJuJOPIhIZKLn+LzDwvniiVvjzx0kf1RuVlxPH3S85zMkw/VqRT8arqzpkcC33Fa9KXzruDHoni8+sleBsxxxsS8ZztJyY9h6WLfnFpWH7kq81BpejdKbaLgTuPUu0V3ZwRj2aGnsm4Ida9Xrud5stFy8q3/3rf9D2M651VfJk/c/wGzpN6L7iTO48H8Jv2/a8vQM4kzX7zeSg8/R
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="2" name="Objects" width="15" height="20">
|
||||
<layer name="Objects" width="15" height="20">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJxbL87AsEOWgSSwEah+syxC33MhVHluJsL60cFcoDvmAbEUUO98cYT4aajaZcIMDMuFMcUDBRgY6oHqfwH5rHIMDP1AdiVQXRWS2jtAuYtCEDuQgS5QbC1QrA6Ia4F4PRB3AvV1CTNggLXimGIgALL7M9QtfkyofpmPQw+y3n6omjgmhBgb1B8gNwuiuWUXUPyNOMQ966F6zwDV7RbHDCN0cEYc4jaYu84C3X0OLS6wxQ1ML8zO1XjSC8jN6Ga+wREOr4FqU4Hu3SyE6Z7DYhAaOSxPymKqu4iW9pABLF30I9kP8x8oHF8jicPSxmWovSC/rkMK40tCCH3o/qmH8k8TyEegMEQPc1i6gvkXn96rQH3XsNiBTe8tJDeeArJvA/FpLPEA03seaO4FIP4OxD+A+Asev8DyOyE3o5cL2MBmLPacRBJDTq8gAAB/tl+N
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="3" name="Above" width="15" height="20">
|
||||
<layer name="Above" width="15" height="20">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJxjYCANHBZjYHgohCp2WYw4vdOEGRimC6Pqu4Smd544hM4EqssSRpXbKAuhHfgh7sAFfJhwuy+AgN4YoN4AJuxyCTj09osjqYHplUOIMQL9UUDAXhj4Bw3b1bKo4sToxQYIhRU6OIlkL6GwwgbOQvXjCitiACisNssSVocMQGljE4l6sAFOHHGPDBJxqJEkQu9Agk9C+OU3Ehl+slB/EoojViLCg5h4Rk6TAIk9IJM=
|
||||
eJxjYCANHBZjYHgohCp2WYw4vdOEGRimC6Pqu4Smd544hM4EqssSRpXbKAuhHfgh7sAFfJhwuy+AgN4YoN4AJuxyCTj09osjqYHplUOIMQL9UUDAXhj4Bw3b1bKo4sToxQYIhRU6OIlkL6GwwgbOQvXjCitiACisNssSVocMQGljExF6Pgnhl+fEEffIIBGHGkki9A4kIOT3jUSGuSzUn4TiiJWI8CBkxjZZ1DQJAF1cImo=
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="4" name="Top" width="15" height="20">
|
||||
<layer name="Top" width="15" height="20">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJxjYCAeHBYjQTEauESk3v+y5NtBT0BJWODTO02YgWE6EH8Uoq+9o3qHj96PwDz0icR8BNL7BUlPvzD57qAlAAAmAhQJ
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="5" name="Walkable" width="15" height="20" visible="0">
|
||||
<layer name="Walkable" width="15" height="20" visible="0">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJzbKMbAsJFIDALEqsWmFwbI0YvLPHR5dDY2O/EBYvSS61dKww+X2ynRS8gcbHpx+RMfjU0vsWFGrL2E3E4o7eBLI7jMIVUvPn8So5eU+CVWL7XkCfmNmPxCSC0AbBeLJg==
|
||||
eJzbKMbAsJFIDALEqsWmFwbI0YvLPHR5dDY2O/EBYvSS61dKww+X2ynRS8gcbHpx+RMfjU0vsWFGrL2E3E4o7eBLI7jMIVUvPn8SoxdX2BGrl9R8SYo8IbXE5BdCegHjOIsm
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="6" name="Walkable_2" width="15" height="20" visible="0">
|
||||
<layer name="Walkable_2" width="15" height="20" visible="0">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJxjYBgFpIKNYhA8EHrJBaN6R/UOBwAAtUcK4w==
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="7" name="Walkable_1" width="15" height="20" visible="0">
|
||||
<layer name="Walkable_1" width="15" height="20" visible="0">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJxjYBgF5ICNYqN6R/UOH71DBQAAWewJVQ==
|
||||
</data>
|
||||
</layer>
|
||||
<objectgroup id="8" name="Mapevents" visible="0">
|
||||
<object id="1" name="elm4f_up" type="script" x="32" y="544" width="64" height="32">
|
||||
<objectgroup name="Mapevents">
|
||||
<object name="elm4f_up" type="script" x="32" y="544" width="64" height="32">
|
||||
<properties>
|
||||
<property name="when" value="enter"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="2" name="elm4f_down" type="script" x="96" y="544" width="32" height="32">
|
||||
<object name="elm4f_down" type="script" x="96" y="544" width="32" height="32">
|
||||
<properties>
|
||||
<property name="when" value="enter"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="3" name="up" type="mapchange" x="448" y="288" width="32" height="64">
|
||||
<object name="up" type="mapchange" x="448" y="288" width="32" height="64">
|
||||
<properties>
|
||||
<property name="map" value="elm_3f"/>
|
||||
<property name="place" value="down"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="4" name="elm2f_trap" type="script" x="128" y="96" width="128" height="64">
|
||||
<object name="elm2f_trap" type="script" x="128" y="96" width="128" height="64">
|
||||
<properties>
|
||||
<property name="when" value="round"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="5" name="elm2f_trap" type="script" x="160" y="224" width="64" height="32">
|
||||
<object name="elm2f_trap" type="script" x="160" y="224" width="64" height="32">
|
||||
<properties>
|
||||
<property name="when" value="round"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="6" name="elm2f_trap" type="script" x="128" y="256" width="64" height="64">
|
||||
<object name="elm2f_trap" type="script" x="128" y="256" width="64" height="64">
|
||||
<properties>
|
||||
<property name="when" value="round"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="7" name="elm2f_trap" type="script" x="128" y="352" width="64" height="96">
|
||||
<object name="elm2f_trap" type="script" x="128" y="352" width="64" height="96">
|
||||
<properties>
|
||||
<property name="when" value="round"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="8" name="elm2f_trap" type="script" x="320" y="160" width="96" height="32">
|
||||
<object name="elm2f_trap" type="script" x="320" y="160" width="96" height="32">
|
||||
<properties>
|
||||
<property name="when" value="round"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="9" name="south" type="mapchange" x="128" y="608" width="128" height="32">
|
||||
<object name="south" type="mapchange" x="128" y="608" width="128" height="32">
|
||||
<properties>
|
||||
<property name="map" value="elm_4f_2"/>
|
||||
<property name="place" value="north1"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="10" name="north" type="mapchange" x="352" y="0" width="32" height="32">
|
||||
<object name="north" type="mapchange" x="352" y="0" width="32" height="32">
|
||||
<properties>
|
||||
<property name="map" value="elm_4f_4"/>
|
||||
<property name="place" value="south2"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="11" name="down" type="mapchange" x="384" y="96" width="32" height="32">
|
||||
<object name="down" type="mapchange" x="384" y="96" width="32" height="32">
|
||||
<properties>
|
||||
<property name="map" value="elm5f_1"/>
|
||||
<property name="place" value="up"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="27" name="silver_bar" type="container" x="224" y="96" width="32" height="32"/>
|
||||
<object id="28" name="lead_bar" type="container" x="224" y="576" width="32" height="32"/>
|
||||
<object name="silver_bar" type="container" x="224" y="96" width="32" height="32"/>
|
||||
<object name="lead_bar" type="container" x="224" y="576" width="32" height="32"/>
|
||||
</objectgroup>
|
||||
<objectgroup id="9" name="Spawn" visible="0">
|
||||
<object id="12" name="elm4f_monster1" type="spawn" x="384" y="384" width="32" height="32">
|
||||
<objectgroup name="Spawn" visible="0">
|
||||
<object name="elm4f_monster1" type="spawn" x="384" y="384" width="32" height="32">
|
||||
<properties>
|
||||
<property name="spawngroup" value="elm_mine3"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="13" name="elm4f_monster2" type="spawn" x="352" y="448" width="32" height="32">
|
||||
<object name="elm4f_monster2" type="spawn" x="352" y="448" width="32" height="32">
|
||||
<properties>
|
||||
<property name="spawngroup" value="elm_mine3"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="14" name="elm4f_monster3" type="spawn" x="320" y="384" width="32" height="32">
|
||||
<object name="elm4f_monster3" type="spawn" x="320" y="384" width="32" height="32">
|
||||
<properties>
|
||||
<property name="spawngroup" value="elm_mine2"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="15" name="elm4f_monster4" type="spawn" x="288" y="384" width="32" height="32">
|
||||
<object name="elm4f_monster4" type="spawn" x="288" y="384" width="32" height="32">
|
||||
<properties>
|
||||
<property name="spawngroup" value="elm_mine1"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="16" name="elm4f_monster5" type="spawn" x="256" y="288" width="64" height="32">
|
||||
<object name="elm4f_monster5" type="spawn" x="256" y="288" width="64" height="32">
|
||||
<properties>
|
||||
<property name="quantity" value="2"/>
|
||||
<property name="spawngroup" value="elm_mine1"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="17" name="elm4f_monster6" type="spawn" x="128" y="448" width="96" height="96">
|
||||
<object name="elm4f_monster6" type="spawn" x="128" y="448" width="96" height="96">
|
||||
<properties>
|
||||
<property name="quantity" value="2"/>
|
||||
<property name="spawngroup" value="elm_mine3"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="18" name="elm4f_monster7" type="spawn" x="256" y="512" width="128" height="96">
|
||||
<object name="elm4f_monster7" type="spawn" x="256" y="512" width="128" height="96">
|
||||
<properties>
|
||||
<property name="quantity" value="3"/>
|
||||
<property name="spawngroup" value="elm_mine1"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="19" name="elm4f_monster8" type="spawn" x="32" y="96" width="32" height="192">
|
||||
<object name="elm4f_monster8" type="spawn" x="32" y="96" width="32" height="192">
|
||||
<properties>
|
||||
<property name="spawngroup" value="shadowfang1"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="20" name="elm4f_monster9" type="spawn" x="320" y="64" width="64" height="96">
|
||||
<object name="elm4f_monster9" type="spawn" x="320" y="64" width="64" height="96">
|
||||
<properties>
|
||||
<property name="quantity" value="2"/>
|
||||
<property name="spawngroup" value="elm_mine5"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="21" name="elm4f_monster10" type="spawn" x="416" y="32" width="32" height="32">
|
||||
<object name="elm4f_monster10" type="spawn" x="416" y="32" width="32" height="32">
|
||||
<properties>
|
||||
<property name="spawngroup" value="elm_mine2"/>
|
||||
</properties>
|
||||
</object>
|
||||
</objectgroup>
|
||||
<objectgroup id="10" name="Keys"/>
|
||||
<objectgroup id="11" name="Replace" visible="0">
|
||||
<object id="22" name="height_up" type="replace" x="64" y="160" width="64" height="384">
|
||||
<objectgroup name="Keys"/>
|
||||
<objectgroup name="Replace" visible="0">
|
||||
<object name="height_up" type="replace" x="64" y="160" width="64" height="384">
|
||||
<properties>
|
||||
<property name="Walkable" value="Walkable_1"/>
|
||||
<property name="requireId" value="bwm72_beginning"/>
|
||||
@@ -353,7 +354,7 @@
|
||||
<property name="requireValue" value="36"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="23" name="height_down" type="replace" x="64" y="160" width="64" height="384">
|
||||
<object name="height_down" type="replace" x="64" y="160" width="64" height="384">
|
||||
<properties>
|
||||
<property name="Walkable" value="Walkable_2"/>
|
||||
<property name="requireId" value="bwm72_beginning"/>
|
||||
|
||||
@@ -1,305 +1,306 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="31" height="10" tilewidth="32" tileheight="32" infinite="0" nextlayerid="11" nextobjectid="15">
|
||||
<tileset firstgid="1" name="map_bed_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<!DOCTYPE map SYSTEM "http://mapeditor.org/dtd/1.0/map.dtd">
|
||||
<map version="1.0" orientation="orthogonal" width="31" height="10" tilewidth="32" tileheight="32">
|
||||
<tileset firstgid="1" name="map_bed_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_bed_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="129" name="map_border_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="129" name="map_border_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_border_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="257" name="map_bridge_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="257" name="map_bridge_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_bridge_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="385" name="map_bridge_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="385" name="map_bridge_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_bridge_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="513" name="map_cavewall_1" tilewidth="32" tileheight="32" tilecount="108" columns="18">
|
||||
<tileset firstgid="513" name="map_cavewall_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cavewall_1.png" width="576" height="192"/>
|
||||
</tileset>
|
||||
<tileset firstgid="621" name="map_cavewall_3" tilewidth="32" tileheight="32" tilecount="108" columns="18">
|
||||
<tileset firstgid="621" name="map_cavewall_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cavewall_3.png" width="576" height="192"/>
|
||||
</tileset>
|
||||
<tileset firstgid="729" name="map_cavewall_4" tilewidth="32" tileheight="32" tilecount="108" columns="18">
|
||||
<tileset firstgid="729" name="map_cavewall_4" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cavewall_4.png" width="576" height="192"/>
|
||||
</tileset>
|
||||
<tileset firstgid="837" name="map_chair_table_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="837" name="map_chair_table_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_chair_table_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="965" name="map_chair_table_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="965" name="map_chair_table_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_chair_table_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1093" name="map_crate_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1093" name="map_crate_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_crate_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1221" name="map_cupboard_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1221" name="map_cupboard_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cupboard_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1349" name="map_curtain_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1349" name="map_curtain_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_curtain_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1477" name="map_entrance_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1477" name="map_entrance_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_entrance_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1605" name="map_entrance_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1605" name="map_entrance_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_entrance_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1733" name="map_fence_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1733" name="map_fence_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_fence_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1861" name="map_fence_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1861" name="map_fence_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_fence_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="1989" name="map_fence_3" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="1989" name="map_fence_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_fence_3.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2117" name="map_fence_4" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2117" name="map_fence_4" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_fence_4.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2245" name="map_ground_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2245" name="map_ground_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2373" name="map_ground_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2373" name="map_ground_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2501" name="map_ground_4" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2501" name="map_ground_4" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_4.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2629" name="map_ground_5" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2629" name="map_ground_5" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_5.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2757" name="map_ground_6" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2757" name="map_ground_6" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_6.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="2885" name="map_ground_7" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="2885" name="map_ground_7" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_7.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3013" name="map_ground_8" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3013" name="map_ground_8" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_8.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3141" name="map_house_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3141" name="map_house_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_house_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3269" name="map_house_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3269" name="map_house_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_house_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3397" name="map_indoor_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3397" name="map_indoor_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_indoor_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3525" name="map_kitchen_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3525" name="map_kitchen_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_kitchen_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3653" name="map_pillar_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3653" name="map_pillar_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_pillar_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3781" name="map_pillar_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3781" name="map_pillar_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_pillar_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="3909" name="map_plant_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="3909" name="map_plant_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_plant_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4037" name="map_roof_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4037" name="map_roof_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_roof_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4165" name="map_roof_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4165" name="map_roof_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_roof_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4293" name="map_roof_3" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4293" name="map_roof_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_roof_3.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4421" name="map_shop_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4421" name="map_shop_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_shop_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4549" name="map_sign_ladder_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4549" name="map_sign_ladder_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_sign_ladder_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4677" name="map_table_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4677" name="map_table_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_table_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4805" name="map_transition_3" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4805" name="map_transition_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_transition_3.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="4933" name="map_transition_4" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="4933" name="map_transition_4" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_transition_4.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5061" name="map_transition_6" tilewidth="32" tileheight="32" tilecount="144" columns="18">
|
||||
<tileset firstgid="5061" name="map_transition_6" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_transition_6.png" width="576" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5205" name="map_tree_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5205" name="map_tree_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_tree_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5333" name="map_tree_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5333" name="map_tree_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_tree_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5461" name="map_wall_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5461" name="map_wall_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_wall_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5589" name="map_wall_2" tilewidth="32" tileheight="32" tilecount="120" columns="15">
|
||||
<tileset firstgid="5589" name="map_wall_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_wall_2.png" width="480" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5709" name="map_wall_3" tilewidth="32" tileheight="32" tilecount="120" columns="15">
|
||||
<tileset firstgid="5709" name="map_wall_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_wall_3.png" width="480" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5829" name="map_wall_4" tilewidth="32" tileheight="32" tilecount="120" columns="15">
|
||||
<tileset firstgid="5829" name="map_wall_4" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_wall_4.png" width="480" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="5949" name="map_window_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="5949" name="map_window_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_window_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6077" name="map_window_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6077" name="map_window_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_window_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6205" name="map_cavewall_2" tilewidth="32" tileheight="32" tilecount="108" columns="18">
|
||||
<tileset firstgid="6205" name="map_cavewall_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cavewall_2.png" width="576" height="192"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6313" name="map_ground_3" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6313" name="map_ground_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_ground_3.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6441" name="map_rock_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6441" name="map_rock_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_rock_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6569" name="map_rock_3" tilewidth="32" tileheight="32" tilecount="30" columns="6">
|
||||
<tileset firstgid="6569" name="map_rock_3" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_rock_3.png" width="192" height="160"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6599" name="map_broken_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6599" name="map_broken_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_broken_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6727" name="map_rock_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6727" name="map_rock_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_rock_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6855" name="map_outdoor_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6855" name="map_outdoor_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_outdoor_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="6983" name="map_transition_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="6983" name="map_transition_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_transition_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7111" name="map_transition_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="7111" name="map_transition_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_transition_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7239" name="map_sign_ladder_omi2" tilewidth="32" tileheight="32" tilecount="32" columns="8">
|
||||
<tileset firstgid="7239" name="map_sign_ladder_omi2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_sign_ladder_omi2.png" width="256" height="128"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7271" name="map_plant_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="7271" name="map_plant_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_plant_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7399" name="map_trail_1" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="7399" name="map_trail_1" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_trail_1.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7527" name="map_cavewall_5" tilewidth="32" tileheight="32" tilecount="36" columns="6">
|
||||
<tileset firstgid="7527" name="map_cavewall_5" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_cavewall_5.png" width="192" height="192"/>
|
||||
</tileset>
|
||||
<tileset firstgid="7563" name="map_indoor_2" tilewidth="32" tileheight="32" tilecount="128" columns="16">
|
||||
<tileset firstgid="7563" name="map_indoor_2" tilewidth="32" tileheight="32">
|
||||
<image source="../drawable/map_indoor_2.png" width="512" height="256"/>
|
||||
</tileset>
|
||||
<layer id="10" name="Base" width="31" height="10">
|
||||
<layer name="Base" width="31" height="10">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJxjYBgF2ACT5EC7ALsbmmTp745RMAqGGgAAtxMA1g==
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="1" name="Ground" width="31" height="10">
|
||||
<layer name="Ground" width="31" height="10">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJyNlMEOgjAMhhsTTUx8AAbhwNmXMT6GJy6AyfQgXHwbH00vetXNrfGn28DDn5Vu69eWQlsStUZnv05JG70VEeXxfRlju3bi56YMbXtn+IN98Xxr11nIxRhVHmfzPWt3Ea72fmvvCqKFckL+CSS5zJRCdgcMWd/R28zdF+P93uim3DrMMJGtId8YuwU28nH/CppjVvmvz5z3INi2H4fSKZUTbcI5SrGkGsi7EQzOqfd1cywtzqXq++YPin0nOCc25tPU+8rGvUQ2v3/ue4yJvbubcw8V+rG23vuX5txKhXlibGazpvo79Q/AOeH8Ur2yHPbVCc39F1Kz8wE7y5tX
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="2" name="Objects" width="31" height="10">
|
||||
<layer name="Objects" width="31" height="10">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJylVDtOw0AQnUNAsZu4QpyA0NIklEDMBQhcIDYVDRJxY1HCLehQCqAADkIZJM7Be8qMPF5sFMSTntZez8ybXyIi8hjkT9gbiozAffAkikxjt910IJKDz4j/Am7Dfkf9DMvEd56JlFm/NmN8INYuzjP4ztR/pTUc6XkB3VPwDe/vqk2k+reJlvXiCzYLzb9WmzHuJuDhsO1jMVgvfSrwRp9JarMu75vqrtwMZvC5BO/Utna2W65fjOE1C/XjWSrHSa4GP8M6yYX654Pm3b5P4s86TYv2qV8f2I8nrbfaYP62R1dxPVev6XGfxGLe17Hd665+WPwFcqpC+95mmbv6mOPI7ZHlaz3tgmn4Xr+GZk+Jg7C24Q7bDhSuTuqydw+6/4Yya/c0RddclrHRZk7HodnZPJnlvGf/rd92b7V9bvB/wvjFL7/z/+IbaTJRNA==
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="3" name="Above" width="31" height="10">
|
||||
<layer name="Above" width="31" height="10">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJxjYGBgWCTFQBaYRIS+DZKYYu2yCPZjNPl2Mt1CrP27kficVLDrPBb/YQPOMgwMB5HUShKwu4MIt91HMm8DDjY5IBGoPwmPGZ2yuOWIBZlQM2rR/Fkoiel+Mwr8c5pEveh2u0lCMLK8sQz57kEGhPKdO9AuDwrjEgR+ork3XxaS79DFyQWFsqTnW2rm8+1Av+xACycA8IgcMA==
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="4" name="Top" width="31" height="10">
|
||||
<layer name="Top" width="31" height="10">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJxjYECAnzIMFANyzeCQpcxeTlnSzeDEoR6XOLXsBQFc4QQTf0ZEOJIbZoTspiVAt6NfBlV8gyQDQ5Ekpj4zLGKU2o1LHDn+zYH2WtDRbnT+YyrYXYgjnaCL0yP+aQGw5VcAbEwWqA==
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="5" name="Walkable" width="31" height="10">
|
||||
<layer name="Walkable" width="31" height="10" visible="0">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJy9klkKACAIRD2I97+a1+inQKJxRqgEIXJ5buFmMZVJONZl78Ts8dkf5cmcKkeHr7J3G/pXZ4D6q3pA3E7/qD5Wv+Kb+cqs1R0w1ul9g81i2V38YFfzVu62s3/GeaGVIL8BPjKwCw==
|
||||
eJy9klkKACAIRDtI97+a1+inQKJZhEoQIpfnWNFbi+nKomNf8UrNXp/zUZ/MYT0qfJe9x9C9uwOkj2lA3Ip+NJ+a38nNfGfX7hso1ul8g61q1b/4wWb7dv4t27mj4bUzQ3kD+D6xDg==
|
||||
</data>
|
||||
</layer>
|
||||
<objectgroup id="6" name="Mapevents" visible="0">
|
||||
<object id="1" name="north1" type="mapchange" x="640" y="0" width="128" height="32">
|
||||
<objectgroup name="Mapevents" visible="0">
|
||||
<object name="north1" type="mapchange" x="640" y="0" width="128" height="32">
|
||||
<properties>
|
||||
<property name="map" value="elm_4f_1"/>
|
||||
<property name="place" value="south"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="2" name="north2" type="mapchange" x="96" y="0" width="256" height="32">
|
||||
<object name="north2" type="mapchange" x="96" y="0" width="256" height="32">
|
||||
<properties>
|
||||
<property name="map" value="elm_4f_3"/>
|
||||
<property name="place" value="south"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="3" name="elm2f_trap" type="script" x="64" y="128" width="96" height="96">
|
||||
<object name="elm2f_trap" type="script" x="64" y="128" width="96" height="96">
|
||||
<properties>
|
||||
<property name="when" value="round"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="4" name="elm2f_trap" type="script" x="416" y="0" width="96" height="96">
|
||||
<object name="elm2f_trap" type="script" x="416" y="0" width="96" height="96">
|
||||
<properties>
|
||||
<property name="when" value="round"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="5" name="elm2f_trap" type="script" x="800" y="192" width="64" height="64">
|
||||
<object name="elm2f_trap" type="script" x="800" y="192" width="64" height="64">
|
||||
<properties>
|
||||
<property name="when" value="round"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="6" name="elm2f_trap" type="script" x="608" y="192" width="96" height="96">
|
||||
<object name="elm2f_trap" type="script" x="608" y="192" width="96" height="96">
|
||||
<properties>
|
||||
<property name="when" value="round"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="7" name="elm_golem" type="container" x="512" y="64" width="32" height="32"/>
|
||||
<object name="elm_golem" type="container" x="512" y="64" width="32" height="32"/>
|
||||
</objectgroup>
|
||||
<objectgroup id="7" name="Spawn" visible="0">
|
||||
<object id="8" name="elm4f2_monster1" type="spawn" x="384" y="160" width="192" height="128">
|
||||
<objectgroup name="Spawn" visible="0">
|
||||
<object name="elm4f2_monster1" type="spawn" x="384" y="160" width="192" height="128">
|
||||
<properties>
|
||||
<property name="quantity" value="3"/>
|
||||
<property name="spawngroup" value="elm_mine3"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="9" name="elm4f2_monster2" type="spawn" x="576" y="96" width="128" height="96">
|
||||
<object name="elm4f2_monster2" type="spawn" x="576" y="96" width="128" height="96">
|
||||
<properties>
|
||||
<property name="quantity" value="4"/>
|
||||
<property name="spawngroup" value="elm_mine2"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="10" name="elm4f2_monster3" type="spawn" x="704" y="32" width="160" height="192">
|
||||
<object name="elm4f2_monster3" type="spawn" x="704" y="32" width="160" height="192">
|
||||
<properties>
|
||||
<property name="ignoreAreas" value="true"/>
|
||||
<property name="quantity" value="4"/>
|
||||
<property name="spawngroup" value="elm_mine1"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="11" name="elm4f2_monster4" type="spawn" x="32" y="128" width="160" height="160">
|
||||
<object name="elm4f2_monster4" type="spawn" x="32" y="128" width="160" height="160">
|
||||
<properties>
|
||||
<property name="ignoreAreas" value="true"/>
|
||||
<property name="quantity" value="3"/>
|
||||
<property name="spawngroup" value="elm_mine3"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="12" name="elm4f2_monster5" type="spawn" x="224" y="32" width="128" height="64">
|
||||
<object name="elm4f2_monster5" type="spawn" x="224" y="32" width="128" height="64">
|
||||
<properties>
|
||||
<property name="quantity" value="2"/>
|
||||
<property name="spawngroup" value="elm_mine4"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="13" name="elm4f2_monster6" type="spawn" x="96" y="32" width="64" height="64">
|
||||
<object name="elm4f2_monster6" type="spawn" x="96" y="32" width="64" height="64">
|
||||
<properties>
|
||||
<property name="quantity" value="2"/>
|
||||
<property name="spawngroup" value="elm_mine4"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="14" name="elm4f2_monster7" type="spawn" x="224" y="96" width="96" height="192">
|
||||
<object name="elm4f2_monster7" type="spawn" x="224" y="96" width="96" height="192">
|
||||
<properties>
|
||||
<property name="quantity" value="3"/>
|
||||
<property name="spawngroup" value="elm_mine1"/>
|
||||
</properties>
|
||||
</object>
|
||||
</objectgroup>
|
||||
<objectgroup id="8" name="Keys"/>
|
||||
<objectgroup id="9" name="Replace"/>
|
||||
<objectgroup name="Keys"/>
|
||||
<objectgroup name="Replace"/>
|
||||
</map>
|
||||
|
||||
@@ -1,169 +1,169 @@
|
||||
package com.gpl.rpg.AndorsTrail;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.Constants;
|
||||
import com.gpl.rpg.AndorsTrail.util.AndroidStorage;
|
||||
import com.gpl.rpg.AndorsTrail.util.Pair;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Environment;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
public final class AndorsTrailApplication extends Application {
|
||||
|
||||
public static final boolean DEVELOPMENT_DEBUGRESOURCES = false;
|
||||
public static final boolean DEVELOPMENT_FORCE_STARTNEWGAME = false;
|
||||
public static final boolean DEVELOPMENT_FORCE_CONTINUEGAME = false;
|
||||
public static final boolean DEVELOPMENT_DEBUGBUTTONS = false;
|
||||
public static final boolean DEVELOPMENT_FASTSPEED = false;
|
||||
public static final boolean DEVELOPMENT_VALIDATEDATA = false;
|
||||
public static final boolean DEVELOPMENT_DEBUGMESSAGES = false;
|
||||
public static final String CURRENT_VERSION_DISPLAY = "0.7.16";
|
||||
public static final boolean IS_RELEASE_VERSION = !CURRENT_VERSION_DISPLAY.matches(".*[a-d].*");
|
||||
public static final boolean DEVELOPMENT_INCOMPATIBLE_SAVEGAMES = DEVELOPMENT_DEBUGRESOURCES || DEVELOPMENT_DEBUGBUTTONS || DEVELOPMENT_FASTSPEED || !IS_RELEASE_VERSION;
|
||||
public static final int DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION = 999;
|
||||
public static final int CURRENT_VERSION = DEVELOPMENT_INCOMPATIBLE_SAVEGAMES ? DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION : 63;
|
||||
|
||||
private final AndorsTrailPreferences preferences = new AndorsTrailPreferences();
|
||||
private WorldContext world = new WorldContext();
|
||||
private ControllerContext controllers = new ControllerContext(this, world);
|
||||
private WorldSetup setup = new WorldSetup(world, controllers, this);
|
||||
public WorldContext getWorld() { return world; }
|
||||
public WorldSetup getWorldSetup() { return setup; }
|
||||
public AndorsTrailPreferences getPreferences() { return preferences; }
|
||||
public ControllerContext getControllerContext() { return controllers; }
|
||||
|
||||
public static AndorsTrailApplication getApplicationFromActivity(Activity activity) {
|
||||
return ((AndorsTrailApplication) activity.getApplication());
|
||||
}
|
||||
public static AndorsTrailApplication getApplicationFromActivityContext(Context context) {
|
||||
return getApplicationFromActivity(getActivityFromActivityContext(context));
|
||||
}
|
||||
private static Activity getActivityFromActivityContext(Context context) {
|
||||
return (Activity) context;
|
||||
}
|
||||
|
||||
public boolean isInitialized() { return world.model != null; }
|
||||
|
||||
public void setWindowParameters(Activity activity) {
|
||||
activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
if (preferences.fullscreen) {
|
||||
activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
} else {
|
||||
activity.getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
}
|
||||
|
||||
//Get default locale at startup, as somehow it seems that changing the app's
|
||||
//configured locale impacts the value returned by Locale.getDefault() nowadays.
|
||||
private final Locale defaultLocale = Locale.getDefault();
|
||||
|
||||
private Pair<String, Locale> lastLocale = null;
|
||||
|
||||
public boolean setLocale(Activity context) {
|
||||
Resources res = context.getResources();
|
||||
Configuration conf = res.getConfiguration();
|
||||
|
||||
Locale targetLocale;
|
||||
|
||||
if (lastLocale != null && lastLocale.first == preferences.language) {
|
||||
targetLocale = lastLocale.second;
|
||||
} else {
|
||||
targetLocale = localeForLanguageTag(preferences.language);
|
||||
lastLocale = new Pair<String, Locale>(preferences.language, targetLocale);
|
||||
}
|
||||
|
||||
if (targetLocale.equals(conf.locale)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
conf.locale = targetLocale;
|
||||
res.updateConfiguration(conf, res.getDisplayMetrics());
|
||||
this.getResources().updateConfiguration(conf, res.getDisplayMetrics());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Supports language or language_COUNTRY in short form e.g. "en" or "en_US"
|
||||
private Locale localeForLanguageTag(String languageTag) {
|
||||
Locale locale = null;
|
||||
if (languageTag != null && !languageTag.equalsIgnoreCase("default")) {
|
||||
final int pos = languageTag.indexOf('-');
|
||||
if (pos == -1) {
|
||||
locale = new Locale(languageTag);
|
||||
}
|
||||
else locale = new Locale(languageTag.substring(0, pos), languageTag.substring(pos+1));
|
||||
}
|
||||
if (locale == null) {
|
||||
locale = defaultLocale;
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logging to text file system as found on https://stackoverflow.com/questions/19565685/saving-logcat-to-a-text-file-in-android-device
|
||||
*/
|
||||
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
if ( DEVELOPMENT_DEBUGMESSAGES && isExternalStorageWritable() ) {
|
||||
File appDirectory = AndroidStorage.getStorageDirectory(getApplicationContext(), Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
File logDirectory = new File( appDirectory, "log" );
|
||||
File logFile = new File( logDirectory, "logcat" + System.currentTimeMillis() + ".txt" );
|
||||
|
||||
// create app folder
|
||||
if ( !appDirectory.exists() ) {
|
||||
appDirectory.mkdir();
|
||||
}
|
||||
|
||||
// create log folder
|
||||
if ( !logDirectory.exists() ) {
|
||||
logDirectory.mkdir();
|
||||
}
|
||||
|
||||
// clear the previous logcat and then write the new one to the file
|
||||
try {
|
||||
Process process = Runtime.getRuntime().exec("logcat -c");
|
||||
process = Runtime.getRuntime().exec("logcat -f " + logFile+" *:W");
|
||||
} catch ( IOException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Checks if external storage is available for read and write */
|
||||
public boolean isExternalStorageWritable() {
|
||||
String state = Environment.getExternalStorageState();
|
||||
if ( Environment.MEDIA_MOUNTED.equals( state ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Checks if external storage is available to at least read */
|
||||
public boolean isExternalStorageReadable() {
|
||||
String state = Environment.getExternalStorageState();
|
||||
if ( Environment.MEDIA_MOUNTED.equals( state ) ||
|
||||
Environment.MEDIA_MOUNTED_READ_ONLY.equals( state ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void discardWorld() {
|
||||
world = new WorldContext();
|
||||
controllers = new ControllerContext(this, world);
|
||||
setup = new WorldSetup(world, controllers, getApplicationContext());
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.Constants;
|
||||
import com.gpl.rpg.AndorsTrail.util.AndroidStorage;
|
||||
import com.gpl.rpg.AndorsTrail.util.Pair;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Environment;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
public final class AndorsTrailApplication extends Application {
|
||||
|
||||
public static final boolean DEVELOPMENT_DEBUGRESOURCES = false;
|
||||
public static final boolean DEVELOPMENT_FORCE_STARTNEWGAME = false;
|
||||
public static final boolean DEVELOPMENT_FORCE_CONTINUEGAME = false;
|
||||
public static final boolean DEVELOPMENT_DEBUGBUTTONS = false;
|
||||
public static final boolean DEVELOPMENT_FASTSPEED = false;
|
||||
public static final boolean DEVELOPMENT_VALIDATEDATA = false;
|
||||
public static final boolean DEVELOPMENT_DEBUGMESSAGES = false;
|
||||
public static final String CURRENT_VERSION_DISPLAY = "0.7.17";
|
||||
public static final boolean IS_RELEASE_VERSION = !CURRENT_VERSION_DISPLAY.matches(".*[a-d].*");
|
||||
public static final boolean DEVELOPMENT_INCOMPATIBLE_SAVEGAMES = DEVELOPMENT_DEBUGRESOURCES || DEVELOPMENT_DEBUGBUTTONS || DEVELOPMENT_FASTSPEED || !IS_RELEASE_VERSION;
|
||||
public static final int DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION = 999;
|
||||
public static final int CURRENT_VERSION = DEVELOPMENT_INCOMPATIBLE_SAVEGAMES ? DEVELOPMENT_INCOMPATIBLE_SAVEGAME_VERSION : 64;
|
||||
|
||||
private final AndorsTrailPreferences preferences = new AndorsTrailPreferences();
|
||||
private WorldContext world = new WorldContext();
|
||||
private ControllerContext controllers = new ControllerContext(this, world);
|
||||
private WorldSetup setup = new WorldSetup(world, controllers, this);
|
||||
public WorldContext getWorld() { return world; }
|
||||
public WorldSetup getWorldSetup() { return setup; }
|
||||
public AndorsTrailPreferences getPreferences() { return preferences; }
|
||||
public ControllerContext getControllerContext() { return controllers; }
|
||||
|
||||
public static AndorsTrailApplication getApplicationFromActivity(Activity activity) {
|
||||
return ((AndorsTrailApplication) activity.getApplication());
|
||||
}
|
||||
public static AndorsTrailApplication getApplicationFromActivityContext(Context context) {
|
||||
return getApplicationFromActivity(getActivityFromActivityContext(context));
|
||||
}
|
||||
private static Activity getActivityFromActivityContext(Context context) {
|
||||
return (Activity) context;
|
||||
}
|
||||
|
||||
public boolean isInitialized() { return world.model != null; }
|
||||
|
||||
public void setWindowParameters(Activity activity) {
|
||||
activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
if (preferences.fullscreen) {
|
||||
activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
} else {
|
||||
activity.getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
}
|
||||
|
||||
//Get default locale at startup, as somehow it seems that changing the app's
|
||||
//configured locale impacts the value returned by Locale.getDefault() nowadays.
|
||||
private final Locale defaultLocale = Locale.getDefault();
|
||||
|
||||
private Pair<String, Locale> lastLocale = null;
|
||||
|
||||
public boolean setLocale(Activity context) {
|
||||
Resources res = context.getResources();
|
||||
Configuration conf = res.getConfiguration();
|
||||
|
||||
Locale targetLocale;
|
||||
|
||||
if (lastLocale != null && lastLocale.first == preferences.language) {
|
||||
targetLocale = lastLocale.second;
|
||||
} else {
|
||||
targetLocale = localeForLanguageTag(preferences.language);
|
||||
lastLocale = new Pair<String, Locale>(preferences.language, targetLocale);
|
||||
}
|
||||
|
||||
if (targetLocale.equals(conf.locale)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
conf.locale = targetLocale;
|
||||
res.updateConfiguration(conf, res.getDisplayMetrics());
|
||||
this.getResources().updateConfiguration(conf, res.getDisplayMetrics());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Supports language or language_COUNTRY in short form e.g. "en" or "en_US"
|
||||
private Locale localeForLanguageTag(String languageTag) {
|
||||
Locale locale = null;
|
||||
if (languageTag != null && !languageTag.equalsIgnoreCase("default")) {
|
||||
final int pos = languageTag.indexOf('-');
|
||||
if (pos == -1) {
|
||||
locale = new Locale(languageTag);
|
||||
}
|
||||
else locale = new Locale(languageTag.substring(0, pos), languageTag.substring(pos+1));
|
||||
}
|
||||
if (locale == null) {
|
||||
locale = defaultLocale;
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logging to text file system as found on https://stackoverflow.com/questions/19565685/saving-logcat-to-a-text-file-in-android-device
|
||||
*/
|
||||
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
if ( DEVELOPMENT_DEBUGMESSAGES && isExternalStorageWritable() ) {
|
||||
File appDirectory = AndroidStorage.getStorageDirectory(getApplicationContext(), Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
File logDirectory = new File( appDirectory, "log" );
|
||||
File logFile = new File( logDirectory, "logcat" + System.currentTimeMillis() + ".txt" );
|
||||
|
||||
// create app folder
|
||||
if ( !appDirectory.exists() ) {
|
||||
appDirectory.mkdir();
|
||||
}
|
||||
|
||||
// create log folder
|
||||
if ( !logDirectory.exists() ) {
|
||||
logDirectory.mkdir();
|
||||
}
|
||||
|
||||
// clear the previous logcat and then write the new one to the file
|
||||
try {
|
||||
Process process = Runtime.getRuntime().exec("logcat -c");
|
||||
process = Runtime.getRuntime().exec("logcat -f " + logFile+" *:W");
|
||||
} catch ( IOException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Checks if external storage is available for read and write */
|
||||
public boolean isExternalStorageWritable() {
|
||||
String state = Environment.getExternalStorageState();
|
||||
if ( Environment.MEDIA_MOUNTED.equals( state ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Checks if external storage is available to at least read */
|
||||
public boolean isExternalStorageReadable() {
|
||||
String state = Environment.getExternalStorageState();
|
||||
if ( Environment.MEDIA_MOUNTED.equals( state ) ||
|
||||
Environment.MEDIA_MOUNTED_READ_ONLY.equals( state ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void discardWorld() {
|
||||
world = new WorldContext();
|
||||
controllers = new ControllerContext(this, world);
|
||||
setup = new WorldSetup(world, controllers, getApplicationContext());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,114 +1,112 @@
|
||||
package com.gpl.rpg.AndorsTrail;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
public final class AndorsTrailPreferences {
|
||||
public static final int DISPLAYLOOT_DIALOG_ALWAYS = 0;
|
||||
public static final int DISPLAYLOOT_DIALOG_FOR_ITEMS = 3;
|
||||
public static final int DISPLAYLOOT_DIALOG_FOR_ITEMS_ELSE_TOAST = 4;
|
||||
public static final int DISPLAYLOOT_TOAST = 1;
|
||||
public static final int DISPLAYLOOT_TOAST_FOR_ITEMS = 5;
|
||||
public static final int DISPLAYLOOT_NONE = 2;
|
||||
public static final int MOVEMENTMETHOD_STRAIGHT = 0;
|
||||
public static final int MOVEMENTMETHOD_DIRECTIONAL = 1;
|
||||
public static final int MOVEMENTAGGRESSIVENESS_NORMAL = 0;
|
||||
public static final int MOVEMENTAGGRESSIVENESS_AGGRESSIVE = 1;
|
||||
public static final int MOVEMENTAGGRESSIVENESS_DEFENSIVE = 2;
|
||||
public static final int DPAD_POSITION_DISABLED = 0;
|
||||
public static final int DPAD_POSITION_LOWER_RIGHT = 1;
|
||||
public static final int DPAD_POSITION_LOWER_LEFT = 2;
|
||||
public static final int DPAD_POSITION_LOWER_CENTER = 3;
|
||||
public static final int DPAD_POSITION_CENTER_LEFT = 4;
|
||||
public static final int DPAD_POSITION_CENTER_RIGHT = 5;
|
||||
public static final int DPAD_POSITION_UPPER_LEFT = 6;
|
||||
public static final int DPAD_POSITION_UPPER_RIGHT = 7;
|
||||
public static final int DPAD_POSITION_UPPER_CENTER = 8;
|
||||
public static final int DPAD_TRANSPARENCY_30_PERCENT = 0;
|
||||
public static final int DPAD_TRANSPARENCY_40_PERCENT = 1;
|
||||
public static final int DPAD_TRANSPARENCY_50_PERCENT = 2;
|
||||
public static final int DPAD_TRANSPARENCY_60_PERCENT = 3;
|
||||
public static final int DPAD_TRANSPARENCY_70_PERCENT = 4;
|
||||
public static final int CONFIRM_OVERWRITE_SAVEGAME_ALWAYS = 0;
|
||||
public static final int CONFIRM_OVERWRITE_SAVEGAME_WHEN_PLAYERNAME_DIFFERS = 1;
|
||||
public static final int CONFIRM_OVERWRITE_SAVEGAME_NEVER = 2;
|
||||
public static final int QUICKSLOTS_POSITION_HORIZONTAL_CENTER_BOTTOM = 0;
|
||||
public static final int QUICKSLOTS_POSITION_VERTICAL_CENTER_LEFT = 1;
|
||||
public static final int QUICKSLOTS_POSITION_VERTICAL_CENTER_RIGHT = 2;
|
||||
public static final int QUICKSLOTS_POSITION_VERTICAL_BOTTOM_LEFT = 3;
|
||||
public static final int QUICKSLOTS_POSITION_HORIZONTAL_BOTTOM_LEFT = 4;
|
||||
public static final int QUICKSLOTS_POSITION_HORIZONTAL_BOTTOM_RIGHT = 5;
|
||||
public static final int QUICKSLOTS_POSITION_VERTICAL_BOTTOM_RIGHT = 6;
|
||||
public static final int ATTACKSPEED_DEFAULT_MILLISECONDS = 1000;
|
||||
|
||||
public boolean confirmRest = true;
|
||||
public boolean confirmAttack = true;
|
||||
public int displayLoot = DISPLAYLOOT_DIALOG_ALWAYS;
|
||||
public boolean fullscreen = true;
|
||||
public int attackspeed_milliseconds = 1000;
|
||||
public int movementMethod = MOVEMENTMETHOD_STRAIGHT;
|
||||
public int movementAggressiveness = MOVEMENTAGGRESSIVENESS_NORMAL;
|
||||
public float scalingFactor = 1.0f;
|
||||
public int dpadPosition;
|
||||
public int dpadTransparency;
|
||||
public boolean dpadMinimizeable = true;
|
||||
public boolean optimizedDrawing = false;
|
||||
public boolean highQualityFilters = true;
|
||||
public boolean enableUiAnimations = true;
|
||||
public int displayOverwriteSavegame = CONFIRM_OVERWRITE_SAVEGAME_ALWAYS;
|
||||
public int quickslotsPosition = QUICKSLOTS_POSITION_HORIZONTAL_CENTER_BOTTOM;
|
||||
public boolean showQuickslotsWhenToolboxIsVisible = false;
|
||||
public String language = "default";
|
||||
|
||||
public int selectedTheme = 0;
|
||||
|
||||
public void read(final Context androidContext) {
|
||||
AndorsTrailPreferences dest = this;
|
||||
try {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(androidContext);
|
||||
dest.confirmRest = prefs.getBoolean("confirm_rest", true);
|
||||
dest.confirmAttack = prefs.getBoolean("confirm_attack", true);
|
||||
dest.displayLoot = Integer.parseInt(prefs.getString("display_lootdialog", Integer.toString(DISPLAYLOOT_DIALOG_ALWAYS)));
|
||||
dest.fullscreen = prefs.getBoolean("fullscreen", true);
|
||||
dest.attackspeed_milliseconds = Integer.parseInt(prefs.getString("attackspeed", "1000"));
|
||||
dest.movementMethod = Integer.parseInt(prefs.getString("movementmethod", Integer.toString(MOVEMENTMETHOD_STRAIGHT)));
|
||||
dest.scalingFactor = Float.parseFloat(prefs.getString("scaling_factor", "1.0f"));
|
||||
dest.dpadPosition = Integer.parseInt(prefs.getString("dpadposition", Integer.toString(DPAD_POSITION_DISABLED)));
|
||||
dest.dpadTransparency = Integer.parseInt(prefs.getString("dpadtransparency", Integer.toString(DPAD_TRANSPARENCY_50_PERCENT)));
|
||||
dest.dpadMinimizeable = prefs.getBoolean("dpadMinimizeable", true);
|
||||
dest.optimizedDrawing = prefs.getBoolean("optimized_drawing", false);
|
||||
dest.highQualityFilters = prefs.getBoolean("high_quality_filters", true);
|
||||
dest.enableUiAnimations = prefs.getBoolean("enableUiAnimations", true);
|
||||
dest.displayOverwriteSavegame = Integer.parseInt(prefs.getString("display_overwrite_savegame", Integer.toString(CONFIRM_OVERWRITE_SAVEGAME_ALWAYS)));
|
||||
dest.quickslotsPosition = Integer.parseInt(prefs.getString("quickslots_placement", Integer.toString(QUICKSLOTS_POSITION_HORIZONTAL_CENTER_BOTTOM)));
|
||||
dest.showQuickslotsWhenToolboxIsVisible = prefs.getBoolean("showQuickslotsWhenToolboxIsVisible", false);
|
||||
dest.language = prefs.getString("language", "default");
|
||||
dest.selectedTheme = Integer.parseInt(prefs.getString("selectedTheme", Integer.toString(0)));
|
||||
// This might be implemented as a skill in the future.
|
||||
//dest.movementAggressiveness = Integer.parseInt(prefs.getString("movementaggressiveness", Integer.toString(MOVEMENTAGGRESSIVENESS_NORMAL)));
|
||||
} catch (Exception e) {
|
||||
dest.confirmRest = true;
|
||||
dest.confirmAttack = true;
|
||||
dest.displayLoot = DISPLAYLOOT_DIALOG_ALWAYS;
|
||||
dest.fullscreen = true;
|
||||
dest.attackspeed_milliseconds = 1000;
|
||||
dest.movementMethod = MOVEMENTMETHOD_STRAIGHT;
|
||||
dest.movementAggressiveness = MOVEMENTAGGRESSIVENESS_NORMAL;
|
||||
dest.scalingFactor = 1.0f;
|
||||
dest.dpadPosition = DPAD_POSITION_DISABLED;
|
||||
dest.dpadTransparency = DPAD_TRANSPARENCY_50_PERCENT;
|
||||
dest.dpadMinimizeable = true;
|
||||
dest.optimizedDrawing = false;
|
||||
dest.highQualityFilters = true;
|
||||
dest.enableUiAnimations = true;
|
||||
dest.displayOverwriteSavegame = CONFIRM_OVERWRITE_SAVEGAME_ALWAYS;
|
||||
dest.quickslotsPosition = QUICKSLOTS_POSITION_HORIZONTAL_CENTER_BOTTOM;
|
||||
dest.showQuickslotsWhenToolboxIsVisible = false;
|
||||
dest.language = "default";
|
||||
dest.selectedTheme = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
public final class AndorsTrailPreferences {
|
||||
public static final int DISPLAYLOOT_DIALOG_ALWAYS = 0;
|
||||
public static final int DISPLAYLOOT_DIALOG_FOR_ITEMS = 3;
|
||||
public static final int DISPLAYLOOT_DIALOG_FOR_ITEMS_ELSE_TOAST = 4;
|
||||
public static final int DISPLAYLOOT_TOAST = 1;
|
||||
public static final int DISPLAYLOOT_TOAST_FOR_ITEMS = 5;
|
||||
public static final int DISPLAYLOOT_NONE = 2;
|
||||
public static final int MOVEMENTMETHOD_STRAIGHT = 0;
|
||||
public static final int MOVEMENTMETHOD_DIRECTIONAL = 1;
|
||||
public static final int MOVEMENTAGGRESSIVENESS_NORMAL = 0;
|
||||
public static final int MOVEMENTAGGRESSIVENESS_AGGRESSIVE = 1;
|
||||
public static final int MOVEMENTAGGRESSIVENESS_DEFENSIVE = 2;
|
||||
public static final int DPAD_POSITION_DISABLED = 0;
|
||||
public static final int DPAD_POSITION_LOWER_RIGHT = 1;
|
||||
public static final int DPAD_POSITION_LOWER_LEFT = 2;
|
||||
public static final int DPAD_POSITION_LOWER_CENTER = 3;
|
||||
public static final int DPAD_POSITION_CENTER_LEFT = 4;
|
||||
public static final int DPAD_POSITION_CENTER_RIGHT = 5;
|
||||
public static final int DPAD_POSITION_UPPER_LEFT = 6;
|
||||
public static final int DPAD_POSITION_UPPER_RIGHT = 7;
|
||||
public static final int DPAD_POSITION_UPPER_CENTER = 8;
|
||||
public static final int DPAD_TRANSPARENCY_30_PERCENT = 0;
|
||||
public static final int DPAD_TRANSPARENCY_40_PERCENT = 1;
|
||||
public static final int DPAD_TRANSPARENCY_50_PERCENT = 2;
|
||||
public static final int DPAD_TRANSPARENCY_60_PERCENT = 3;
|
||||
public static final int DPAD_TRANSPARENCY_70_PERCENT = 4;
|
||||
public static final int CONFIRM_OVERWRITE_SAVEGAME_ALWAYS = 0;
|
||||
public static final int CONFIRM_OVERWRITE_SAVEGAME_WHEN_PLAYERNAME_DIFFERS = 1;
|
||||
public static final int CONFIRM_OVERWRITE_SAVEGAME_NEVER = 2;
|
||||
public static final int QUICKSLOTS_POSITION_HORIZONTAL_CENTER_BOTTOM = 0;
|
||||
public static final int QUICKSLOTS_POSITION_VERTICAL_CENTER_LEFT = 1;
|
||||
public static final int QUICKSLOTS_POSITION_VERTICAL_CENTER_RIGHT = 2;
|
||||
public static final int QUICKSLOTS_POSITION_VERTICAL_BOTTOM_LEFT = 3;
|
||||
public static final int QUICKSLOTS_POSITION_HORIZONTAL_BOTTOM_LEFT = 4;
|
||||
public static final int QUICKSLOTS_POSITION_HORIZONTAL_BOTTOM_RIGHT = 5;
|
||||
public static final int QUICKSLOTS_POSITION_VERTICAL_BOTTOM_RIGHT = 6;
|
||||
public static final int ATTACKSPEED_DEFAULT_MILLISECONDS = 1000;
|
||||
|
||||
public boolean confirmRest = true;
|
||||
public boolean confirmAttack = true;
|
||||
public int displayLoot = DISPLAYLOOT_DIALOG_ALWAYS;
|
||||
public boolean fullscreen = true;
|
||||
public int attackspeed_milliseconds = 1000;
|
||||
public int movementMethod = MOVEMENTMETHOD_STRAIGHT;
|
||||
public int movementAggressiveness = MOVEMENTAGGRESSIVENESS_NORMAL;
|
||||
public float scalingFactor = 1.0f;
|
||||
public int dpadPosition;
|
||||
public int dpadTransparency;
|
||||
public boolean dpadMinimizeable = true;
|
||||
public boolean optimizedDrawing = false;
|
||||
public boolean highQualityFilters = true;
|
||||
public boolean enableUiAnimations = true;
|
||||
public int displayOverwriteSavegame = CONFIRM_OVERWRITE_SAVEGAME_ALWAYS;
|
||||
public int quickslotsPosition = QUICKSLOTS_POSITION_HORIZONTAL_CENTER_BOTTOM;
|
||||
public boolean showQuickslotsWhenToolboxIsVisible = false;
|
||||
public String language = "default";
|
||||
|
||||
public int selectedTheme = 0;
|
||||
|
||||
public void read(final Context androidContext) {
|
||||
AndorsTrailPreferences dest = this;
|
||||
try {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(androidContext);
|
||||
dest.confirmRest = prefs.getBoolean("confirm_rest", true);
|
||||
dest.confirmAttack = prefs.getBoolean("confirm_attack", true);
|
||||
dest.displayLoot = Integer.parseInt(prefs.getString("display_lootdialog", Integer.toString(DISPLAYLOOT_DIALOG_ALWAYS)));
|
||||
dest.fullscreen = prefs.getBoolean("fullscreen", true);
|
||||
dest.attackspeed_milliseconds = Integer.parseInt(prefs.getString("attackspeed", "1000"));
|
||||
dest.movementMethod = Integer.parseInt(prefs.getString("movementmethod", Integer.toString(MOVEMENTMETHOD_STRAIGHT)));
|
||||
dest.scalingFactor = Float.parseFloat(prefs.getString("scaling_factor", "1.0f"));
|
||||
dest.dpadPosition = Integer.parseInt(prefs.getString("dpadposition", Integer.toString(DPAD_POSITION_DISABLED)));
|
||||
dest.dpadTransparency = Integer.parseInt(prefs.getString("dpadtransparency", Integer.toString(DPAD_TRANSPARENCY_50_PERCENT)));
|
||||
dest.dpadMinimizeable = prefs.getBoolean("dpadMinimizeable", true);
|
||||
dest.optimizedDrawing = prefs.getBoolean("optimized_drawing", false);
|
||||
dest.highQualityFilters = prefs.getBoolean("high_quality_filters", true);
|
||||
dest.enableUiAnimations = prefs.getBoolean("enableUiAnimations", true);
|
||||
dest.displayOverwriteSavegame = Integer.parseInt(prefs.getString("display_overwrite_savegame", Integer.toString(CONFIRM_OVERWRITE_SAVEGAME_ALWAYS)));
|
||||
dest.quickslotsPosition = Integer.parseInt(prefs.getString("quickslots_placement", Integer.toString(QUICKSLOTS_POSITION_HORIZONTAL_CENTER_BOTTOM)));
|
||||
dest.showQuickslotsWhenToolboxIsVisible = prefs.getBoolean("showQuickslotsWhenToolboxIsVisible", false);
|
||||
dest.language = prefs.getString("language", "default");
|
||||
dest.selectedTheme = Integer.parseInt(prefs.getString("selectedTheme", Integer.toString(0)));
|
||||
// This might be implemented as a skill in the future.
|
||||
//dest.movementAggressiveness = Integer.parseInt(prefs.getString("movementaggressiveness", Integer.toString(MOVEMENTAGGRESSIVENESS_NORMAL)));
|
||||
} catch (Exception e) {
|
||||
dest.confirmRest = true;
|
||||
dest.confirmAttack = true;
|
||||
dest.displayLoot = DISPLAYLOOT_DIALOG_ALWAYS;
|
||||
dest.fullscreen = true;
|
||||
dest.attackspeed_milliseconds = 1000;
|
||||
dest.movementMethod = MOVEMENTMETHOD_STRAIGHT;
|
||||
dest.movementAggressiveness = MOVEMENTAGGRESSIVENESS_NORMAL;
|
||||
dest.scalingFactor = 1.0f;
|
||||
dest.dpadPosition = DPAD_POSITION_DISABLED;
|
||||
dest.dpadTransparency = DPAD_TRANSPARENCY_50_PERCENT;
|
||||
dest.dpadMinimizeable = true;
|
||||
dest.optimizedDrawing = false;
|
||||
dest.highQualityFilters = true;
|
||||
dest.enableUiAnimations = true;
|
||||
dest.displayOverwriteSavegame = CONFIRM_OVERWRITE_SAVEGAME_ALWAYS;
|
||||
dest.quickslotsPosition = QUICKSLOTS_POSITION_HORIZONTAL_CENTER_BOTTOM;
|
||||
dest.showQuickslotsWhenToolboxIsVisible = false;
|
||||
dest.language = "default";
|
||||
dest.selectedTheme = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,478 +1,475 @@
|
||||
package com.gpl.rpg.AndorsTrail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import android.*;
|
||||
import android.Manifest;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
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.Toast;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.activity.ActorConditionInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.BulkSelectionInterface;
|
||||
import com.gpl.rpg.AndorsTrail.activity.ConversationActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.ItemInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.LevelUpActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.LoadSaveActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.MainActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.MonsterEncounterActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.MonsterInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.SkillInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_MainMenu;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.ActorConditionType;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.SkillCollection;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Inventory;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Loot;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.MapObject;
|
||||
import com.gpl.rpg.AndorsTrail.savegames.Savegames;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||
import com.gpl.rpg.AndorsTrail.view.ItemContainerAdapter;
|
||||
|
||||
public final class Dialogs {
|
||||
|
||||
private static void showDialogAndPause(Dialog d, final ControllerContext context) {
|
||||
showDialogAndPause(d, context, null);
|
||||
}
|
||||
private static void showDialogAndPause(Dialog d, final ControllerContext context, final OnDismissListener onDismiss) {
|
||||
context.gameRoundController.pause();
|
||||
CustomDialogFactory.setDismissListener(d, new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
if (onDismiss != null) onDismiss.onDismiss(arg0);
|
||||
context.gameRoundController.resume();
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
public static void showKeyArea(final MainActivity currentActivity, final ControllerContext context, String phraseID) {
|
||||
showConversation(currentActivity, context, phraseID, null);
|
||||
}
|
||||
|
||||
public static void showMapSign(final MainActivity currentActivity, final ControllerContext context, String phraseID) {
|
||||
showConversation(currentActivity, context, phraseID, null);
|
||||
}
|
||||
|
||||
public static void showMapScriptMessage(final MainActivity currentActivity, final ControllerContext context, String phraseID) {
|
||||
showConversation(currentActivity, context, phraseID, null, false);
|
||||
}
|
||||
|
||||
public static void showConversation(final MainActivity currentActivity, final ControllerContext context, final String phraseID, final Monster npc) {
|
||||
showConversation(currentActivity, context, phraseID, npc, true);
|
||||
}
|
||||
|
||||
private static void showConversation(final MainActivity currentActivity, final ControllerContext context, final String phraseID, final Monster npc, boolean applyScriptEffectsForFirstPhrase) {
|
||||
context.gameRoundController.pause();
|
||||
Intent intent = new Intent(currentActivity, ConversationActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/conversation/" + phraseID));
|
||||
intent.putExtra("applyScriptEffectsForFirstPhrase", applyScriptEffectsForFirstPhrase);
|
||||
addMonsterIdentifiers(intent, npc);
|
||||
currentActivity.startActivityForResult(intent, MainActivity.INTENTREQUEST_CONVERSATION);
|
||||
}
|
||||
|
||||
public static void addMonsterIdentifiers(Intent intent, Monster monster) {
|
||||
if (monster == null) return;
|
||||
intent.putExtra("x", monster.position.x);
|
||||
intent.putExtra("y", monster.position.y);
|
||||
}
|
||||
public static void addMonsterIdentifiers(Bundle bundle, Monster monster) {
|
||||
if (monster == null) return;
|
||||
bundle.putInt("x", monster.position.x);
|
||||
bundle.putInt("y", monster.position.y);
|
||||
}
|
||||
|
||||
public static Monster getMonsterFromIntent(Intent intent, final WorldContext world) {
|
||||
return getMonsterFromBundle(intent.getExtras(), world);
|
||||
}
|
||||
public static Monster getMonsterFromBundle(Bundle params, final WorldContext world) {
|
||||
if (params == null) return null;
|
||||
if (!params.containsKey("x")) return null;
|
||||
int x = params.getInt("x");
|
||||
int y = params.getInt("y");
|
||||
return world.model.currentMaps.map.getMonsterAt(x, y);
|
||||
}
|
||||
|
||||
public static void showMonsterEncounter(final MainActivity currentActivity, final ControllerContext context, final Monster monster) {
|
||||
context.gameRoundController.pause();
|
||||
Intent intent = new Intent(currentActivity, MonsterEncounterActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/monsterencounter"));
|
||||
addMonsterIdentifiers(intent, monster);
|
||||
currentActivity.startActivityForResult(intent, MainActivity.INTENTREQUEST_MONSTERENCOUNTER);
|
||||
}
|
||||
|
||||
public static void showMonsterInfo(final Context context, final Monster monster) {
|
||||
Intent intent = new Intent(context, MonsterInfoActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/monsterinfo"));
|
||||
addMonsterIdentifiers(intent, monster);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static String getGroundLootFoundMessage(final Context ctx, final Loot loot) {
|
||||
StringBuilder sb = new StringBuilder(60);
|
||||
if (!loot.items.isEmpty()) {
|
||||
sb.append(ctx.getString(R.string.dialog_groundloot_message));
|
||||
}
|
||||
appendGoldPickedUpMessage(ctx, loot, sb);
|
||||
return sb.toString();
|
||||
}
|
||||
public static String getGroundLootPickedUpMessage(final Context ctx, final Loot loot) {
|
||||
StringBuilder sb = new StringBuilder(60);
|
||||
appendLootPickedUpMessage(ctx, loot, sb);
|
||||
return sb.toString();
|
||||
}
|
||||
public static String getMonsterLootFoundMessage(final Context ctx, final Loot combinedLoot, final int exp) {
|
||||
StringBuilder sb = new StringBuilder(60);
|
||||
appendMonsterEncounterSurvivedMessage(ctx, sb, exp);
|
||||
appendGoldPickedUpMessage(ctx, combinedLoot, sb);
|
||||
return sb.toString();
|
||||
}
|
||||
public static String getMonsterLootPickedUpMessage(final Context ctx, final Loot combinedLoot, final int exp) {
|
||||
StringBuilder sb = new StringBuilder(60);
|
||||
appendMonsterEncounterSurvivedMessage(ctx, sb, exp);
|
||||
appendLootPickedUpMessage(ctx, combinedLoot, sb);
|
||||
return sb.toString();
|
||||
}
|
||||
private static void appendMonsterEncounterSurvivedMessage(final Context ctx, final StringBuilder sb, final int exp) {
|
||||
sb.append(ctx.getString(R.string.dialog_monsterloot_message));
|
||||
if (exp > 0) {
|
||||
sb.append(' ');
|
||||
sb.append(ctx.getString(R.string.dialog_monsterloot_gainedexp, exp));
|
||||
}
|
||||
}
|
||||
private static void appendGoldPickedUpMessage(final Context ctx, final Loot loot, final StringBuilder sb) {
|
||||
if (loot.gold > 0) {
|
||||
sb.append(' ');
|
||||
sb.append(ctx.getString(R.string.dialog_loot_foundgold, loot.gold));
|
||||
}
|
||||
}
|
||||
private static void appendLootPickedUpMessage(final Context ctx, final Loot loot, final StringBuilder sb) {
|
||||
appendGoldPickedUpMessage(ctx, loot, sb);
|
||||
int numItems = loot.items.countItems();
|
||||
if (numItems == 1) {
|
||||
sb.append(' ');
|
||||
sb.append(ctx.getString(R.string.dialog_loot_pickedupitem));
|
||||
} else if (numItems > 1){
|
||||
sb.append(' ');
|
||||
sb.append(ctx.getString(R.string.dialog_loot_pickedupitems, numItems));
|
||||
}
|
||||
}
|
||||
|
||||
public static void showMonsterLoot(final MainActivity mainActivity, final ControllerContext controllers, final WorldContext world, final Collection<Loot> lootBags, final Loot combinedLoot, final String msg) {
|
||||
// CombatController will do killedMonsterBags.clear() after this method has been called,
|
||||
// so we need to keep the list of objects. Therefore, we create a shallow copy of the list of bags.
|
||||
ArrayList<Loot> bags = new ArrayList<Loot>(lootBags);
|
||||
showLoot(mainActivity, controllers, world, combinedLoot, bags, R.string.dialog_monsterloot_title, msg);
|
||||
}
|
||||
|
||||
public static void showGroundLoot(final MainActivity mainActivity, final ControllerContext controllers, final WorldContext world, final Loot loot, final String msg) {
|
||||
showLoot(mainActivity, controllers, world, loot, Collections.singletonList(loot), R.string.dialog_groundloot_title, msg);
|
||||
}
|
||||
|
||||
private static void showLoot(final MainActivity mainActivity, final ControllerContext controllers, final WorldContext world, final Loot combinedLoot, final Iterable<Loot> lootBags, final int title, final String msg) {
|
||||
final ListView itemList = new ListView(mainActivity);
|
||||
itemList.setBackgroundResource(android.R.color.transparent);
|
||||
itemList.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, ListView.LayoutParams.WRAP_CONTENT));
|
||||
// itemList.setPadding(20, 0, 20, 20);
|
||||
itemList.setAdapter(new ItemContainerAdapter(mainActivity, world.tileManager, combinedLoot.items, world.model.player));
|
||||
|
||||
final Dialog d = CustomDialogFactory.createDialog(mainActivity,
|
||||
mainActivity.getResources().getString(title),
|
||||
mainActivity.getResources().getDrawable(R.drawable.ui_icon_equipment),
|
||||
msg,
|
||||
combinedLoot.items.isEmpty() ? null : itemList,
|
||||
true,
|
||||
false);
|
||||
|
||||
itemList.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||
|
||||
final String itemTypeID = ((ItemContainerAdapter) parent.getAdapter()).getItem(position).itemType.id;
|
||||
boolean removeFromCombinedLoot = true;
|
||||
for (Loot l : lootBags) {
|
||||
if (l == combinedLoot) removeFromCombinedLoot = false;
|
||||
if (l.items.removeItem(itemTypeID)) {
|
||||
controllers.itemController.removeLootBagIfEmpty(l);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (removeFromCombinedLoot) {
|
||||
combinedLoot.items.removeItem(itemTypeID);
|
||||
}
|
||||
if (((ItemContainerAdapter) parent.getAdapter()).isEmpty()) {
|
||||
ViewGroup vg = (ViewGroup) d.findViewById(R.id.dialog_content_container);
|
||||
vg.setVisibility(View.GONE);
|
||||
}
|
||||
ItemType type = world.itemTypes.getItemType(itemTypeID);
|
||||
world.model.player.inventory.addItem(type);
|
||||
((ItemContainerAdapter) itemList.getAdapter()).notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
|
||||
if (!itemList.getAdapter().isEmpty()) {
|
||||
CustomDialogFactory.addButton(d, R.string.dialog_loot_pickall, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
controllers.itemController.pickupAll(lootBags);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, R.string.dialog_close);
|
||||
|
||||
showDialogAndPause(d, controllers, new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
controllers.itemController.removeLootBagIfEmpty(lootBags);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void showHeroDied(final MainActivity mainActivity, final ControllerContext controllers) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(mainActivity,
|
||||
mainActivity.getResources().getString(R.string.dialog_game_over_title),
|
||||
mainActivity.getResources().getDrawable(R.drawable.ui_icon_combat),
|
||||
mainActivity.getResources().getString(R.string.dialog_game_over_text),
|
||||
null,
|
||||
true,
|
||||
false);
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
|
||||
showDialogAndPause(d, controllers, new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
mainActivity.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static Intent getIntentForItemInfo(final Context ctx, String itemTypeID, ItemInfoActivity.ItemInfoAction actionType, String buttonText, boolean buttonEnabled, Inventory.WearSlot inventorySlot) {
|
||||
Intent intent = new Intent(ctx, ItemInfoActivity.class);
|
||||
intent.putExtra("buttonText", buttonText);
|
||||
intent.putExtra("buttonEnabled", buttonEnabled);
|
||||
intent.putExtra("moreActions", (actionType == ItemInfoActivity.ItemInfoAction.equip || actionType == ItemInfoActivity.ItemInfoAction.use || actionType == ItemInfoActivity.ItemInfoAction.none));
|
||||
intent.putExtra("itemTypeID", itemTypeID);
|
||||
intent.putExtra("actionType", actionType.name());
|
||||
if (inventorySlot != null) intent.putExtra("inventorySlot", inventorySlot.name());
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/iteminfo/" + itemTypeID));
|
||||
return intent;
|
||||
}
|
||||
public static Intent getIntentForLevelUp(final Context ctx) {
|
||||
Intent intent = new Intent(ctx, LevelUpActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/levelup"));
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static void showConfirmRest(final Activity currentActivity, final ControllerContext controllerContext, final MapObject area) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(currentActivity,
|
||||
currentActivity.getResources().getString(R.string.dialog_rest_title),
|
||||
null,
|
||||
currentActivity.getResources().getString(R.string.dialog_rest_confirm_message),
|
||||
null,
|
||||
true);
|
||||
|
||||
CustomDialogFactory.addButton(d, android.R.string.yes, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
controllerContext.mapController.rest(area);
|
||||
}
|
||||
});
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.no);
|
||||
|
||||
showDialogAndPause(d, controllerContext);
|
||||
}
|
||||
public static void showRested(final Activity currentActivity, final ControllerContext controllerContext) {
|
||||
// Dialog d = new AlertDialog.Builder(new ContextThemeWrapper(currentActivity, R.style.AndorsTrailStyle))
|
||||
// .setTitle(R.string.dialog_rest_title)
|
||||
// .setMessage(R.string.dialog_rest_message)
|
||||
// .setNeutralButton(android.R.string.ok, null)
|
||||
// .create();
|
||||
final Dialog d = CustomDialogFactory.createDialog(currentActivity,
|
||||
currentActivity.getResources().getString(R.string.dialog_rest_title),
|
||||
null,
|
||||
currentActivity.getResources().getString(R.string.dialog_rest_message),
|
||||
null,
|
||||
true);
|
||||
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
|
||||
showDialogAndPause(d, controllerContext);
|
||||
}
|
||||
|
||||
public static void showNewVersion(final Activity currentActivity, final OnDismissListener onDismiss) {
|
||||
// new AlertDialog.Builder(new ContextThemeWrapper(currentActivity, R.style.AndorsTrailStyle))
|
||||
// .setTitle(R.string.dialog_newversion_title)
|
||||
// .setMessage(R.string.dialog_newversion_message)
|
||||
// .setNeutralButton(android.R.string.ok, null)
|
||||
// .show();
|
||||
|
||||
String text = currentActivity.getResources().getString(R.string.dialog_newversion_message);
|
||||
|
||||
if (!hasPermissions(currentActivity) && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||
text += currentActivity.getResources().getString(R.string.dialog_newversion_permission_information);
|
||||
}
|
||||
|
||||
final Dialog d = CustomDialogFactory.createDialog(currentActivity,
|
||||
currentActivity.getResources().getString(R.string.dialog_newversion_title),
|
||||
null,
|
||||
text,
|
||||
null,
|
||||
true);
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
CustomDialogFactory.setDismissListener(d, new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
if (onDismiss != null) onDismiss.onDismiss(arg0);
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
@TargetApi(23)
|
||||
private static boolean hasPermissions(final Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (activity.getApplicationContext().checkSelfPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
|
||||
|| activity.getApplicationContext().checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean showSave(final Activity mainActivity, final ControllerContext controllerContext, final WorldContext world) {
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
Toast.makeText(mainActivity, R.string.menu_save_saving_not_allowed_in_combat, Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!world.model.statistics.hasUnlimitedSaves()) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(mainActivity,
|
||||
mainActivity.getResources().getString(R.string.menu_save_switch_character_title),
|
||||
null,
|
||||
mainActivity.getResources().getString(R.string.menu_save_switch_character),
|
||||
null,
|
||||
true);
|
||||
CustomDialogFactory.addButton(d, android.R.string.ok, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
controllerContext.gameRoundController.pause();
|
||||
Intent intent = new Intent(mainActivity, LoadSaveActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/save"));
|
||||
mainActivity.startActivityForResult(intent, MainActivity.INTENTREQUEST_SAVEGAME);
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.cancel);
|
||||
CustomDialogFactory.show(d);
|
||||
return false;
|
||||
} else {
|
||||
controllerContext.gameRoundController.pause();
|
||||
Intent intent = new Intent(mainActivity, LoadSaveActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/save"));
|
||||
mainActivity.startActivityForResult(intent, MainActivity.INTENTREQUEST_SAVEGAME);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void showLoad(final Activity currentActivity) {
|
||||
Intent intent = new Intent(currentActivity, LoadSaveActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/load"));
|
||||
currentActivity.startActivityForResult(intent, StartScreenActivity_MainMenu.INTENTREQUEST_LOADGAME);
|
||||
}
|
||||
|
||||
public static void showLoad(final Fragment currentFragment) {
|
||||
Intent intent = new Intent(currentFragment.getActivity(), LoadSaveActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/load"));
|
||||
currentFragment.startActivityForResult(intent, StartScreenActivity_MainMenu.INTENTREQUEST_LOADGAME);
|
||||
}
|
||||
|
||||
public static void showActorConditionInfo(final Context context, ActorConditionType conditionType) {
|
||||
Intent intent = new Intent(context, ActorConditionInfoActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/actorconditioninfo/" + conditionType.conditionTypeID));
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static Intent getIntentForBulkBuyingInterface(final Context ctx, String itemTypeID, int totalAvailableAmount) {
|
||||
return getIntentForBulkSelectionInterface(ctx, itemTypeID, totalAvailableAmount, BulkSelectionInterface.BulkInterfaceType.buy);
|
||||
}
|
||||
|
||||
public static Intent getIntentForBulkSellingInterface(final Context ctx, String itemTypeID, int totalAvailableAmount) {
|
||||
return getIntentForBulkSelectionInterface(ctx, itemTypeID, totalAvailableAmount, BulkSelectionInterface.BulkInterfaceType.sell);
|
||||
}
|
||||
|
||||
public static Intent getIntentForBulkDroppingInterface(final Context ctx, String itemTypeID, int totalAvailableAmount) {
|
||||
return getIntentForBulkSelectionInterface(ctx, itemTypeID, totalAvailableAmount, BulkSelectionInterface.BulkInterfaceType.drop);
|
||||
}
|
||||
|
||||
private static Intent getIntentForBulkSelectionInterface(final Context ctx, String itemTypeID, int totalAvailableAmount, BulkSelectionInterface.BulkInterfaceType interfaceType) {
|
||||
Intent intent = new Intent(ctx, BulkSelectionInterface.class);
|
||||
intent.putExtra("itemTypeID", itemTypeID);
|
||||
intent.putExtra("totalAvailableAmount", totalAvailableAmount);
|
||||
intent.putExtra("interfaceType", interfaceType.name());
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/bulkselection/" + itemTypeID));
|
||||
return intent;
|
||||
}
|
||||
public static Intent getIntentForSkillInfo(final Context ctx, SkillCollection.SkillID skillID) {
|
||||
Intent intent = new Intent(ctx, SkillInfoActivity.class);
|
||||
intent.putExtra("skillID", skillID.name());
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/showskillinfo/" + skillID));
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static void showCombatLog(final Context context, final ControllerContext controllerContext, final WorldContext world) {
|
||||
String[] combatLogMessages = world.model.combatLog.getAllMessages();
|
||||
|
||||
View view = null;
|
||||
ListView itemList = null;
|
||||
itemList = new ListView(context);
|
||||
itemList.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, ListView.LayoutParams.WRAP_CONTENT));
|
||||
itemList.setStackFromBottom(true);
|
||||
itemList.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
|
||||
itemList.setChoiceMode(ListView.CHOICE_MODE_NONE);
|
||||
itemList.setBackgroundColor(ThemeHelper.getThemeColor(context, R.attr.ui_theme_stdframe_bg_color));
|
||||
if (combatLogMessages.length <= 0) {
|
||||
combatLogMessages = new String[] {context.getResources().getString(R.string.combat_log_noentries)};
|
||||
}
|
||||
itemList.setAdapter(new ArrayAdapter<String>(context, R.layout.combatlog_row, android.R.id.text1, combatLogMessages));
|
||||
view = itemList;
|
||||
|
||||
final Dialog d = CustomDialogFactory.createDialog(context,
|
||||
context.getResources().getString(R.string.combat_log_title),
|
||||
context.getResources().getDrawable(R.drawable.ui_icon_combat),
|
||||
null,
|
||||
view,
|
||||
true);
|
||||
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, R.string.dialog_close);
|
||||
|
||||
showDialogAndPause(d, controllerContext);
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
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.Toast;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.activity.ActorConditionInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.BulkSelectionInterface;
|
||||
import com.gpl.rpg.AndorsTrail.activity.ConversationActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.ItemInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.LevelUpActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.LoadSaveActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.MainActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.MonsterEncounterActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.MonsterInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.SkillInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_MainMenu;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.ActorConditionType;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.SkillCollection;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Inventory;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Loot;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.MapObject;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||
import com.gpl.rpg.AndorsTrail.view.ItemContainerAdapter;
|
||||
|
||||
public final class Dialogs {
|
||||
|
||||
private static void showDialogAndPause(Dialog d, final ControllerContext context) {
|
||||
showDialogAndPause(d, context, null);
|
||||
}
|
||||
private static void showDialogAndPause(Dialog d, final ControllerContext context, final OnDismissListener onDismiss) {
|
||||
context.gameRoundController.pause();
|
||||
CustomDialogFactory.setDismissListener(d, new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
if (onDismiss != null) onDismiss.onDismiss(arg0);
|
||||
context.gameRoundController.resume();
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
public static void showKeyArea(final MainActivity currentActivity, final ControllerContext context, String phraseID) {
|
||||
showConversation(currentActivity, context, phraseID, null);
|
||||
}
|
||||
|
||||
public static void showMapSign(final MainActivity currentActivity, final ControllerContext context, String phraseID) {
|
||||
showConversation(currentActivity, context, phraseID, null);
|
||||
}
|
||||
|
||||
public static void showMapScriptMessage(final MainActivity currentActivity, final ControllerContext context, String phraseID) {
|
||||
showConversation(currentActivity, context, phraseID, null, false);
|
||||
}
|
||||
|
||||
public static void showConversation(final MainActivity currentActivity, final ControllerContext context, final String phraseID, final Monster npc) {
|
||||
showConversation(currentActivity, context, phraseID, npc, true);
|
||||
}
|
||||
|
||||
private static void showConversation(final MainActivity currentActivity, final ControllerContext context, final String phraseID, final Monster npc, boolean applyScriptEffectsForFirstPhrase) {
|
||||
context.gameRoundController.pause();
|
||||
Intent intent = new Intent(currentActivity, ConversationActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/conversation/" + phraseID));
|
||||
intent.putExtra("applyScriptEffectsForFirstPhrase", applyScriptEffectsForFirstPhrase);
|
||||
addMonsterIdentifiers(intent, npc);
|
||||
currentActivity.startActivityForResult(intent, MainActivity.INTENTREQUEST_CONVERSATION);
|
||||
}
|
||||
|
||||
public static void addMonsterIdentifiers(Intent intent, Monster monster) {
|
||||
if (monster == null) return;
|
||||
intent.putExtra("x", monster.position.x);
|
||||
intent.putExtra("y", monster.position.y);
|
||||
}
|
||||
public static void addMonsterIdentifiers(Bundle bundle, Monster monster) {
|
||||
if (monster == null) return;
|
||||
bundle.putInt("x", monster.position.x);
|
||||
bundle.putInt("y", monster.position.y);
|
||||
}
|
||||
|
||||
public static Monster getMonsterFromIntent(Intent intent, final WorldContext world) {
|
||||
return getMonsterFromBundle(intent.getExtras(), world);
|
||||
}
|
||||
public static Monster getMonsterFromBundle(Bundle params, final WorldContext world) {
|
||||
if (params == null) return null;
|
||||
if (!params.containsKey("x")) return null;
|
||||
int x = params.getInt("x");
|
||||
int y = params.getInt("y");
|
||||
return world.model.currentMaps.map.getMonsterAt(x, y);
|
||||
}
|
||||
|
||||
public static void showMonsterEncounter(final MainActivity currentActivity, final ControllerContext context, final Monster monster) {
|
||||
context.gameRoundController.pause();
|
||||
Intent intent = new Intent(currentActivity, MonsterEncounterActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/monsterencounter"));
|
||||
addMonsterIdentifiers(intent, monster);
|
||||
currentActivity.startActivityForResult(intent, MainActivity.INTENTREQUEST_MONSTERENCOUNTER);
|
||||
}
|
||||
|
||||
public static void showMonsterInfo(final Context context, final Monster monster) {
|
||||
Intent intent = new Intent(context, MonsterInfoActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/monsterinfo"));
|
||||
addMonsterIdentifiers(intent, monster);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static String getGroundLootFoundMessage(final Context ctx, final Loot loot) {
|
||||
StringBuilder sb = new StringBuilder(60);
|
||||
if (!loot.items.isEmpty()) {
|
||||
sb.append(ctx.getString(R.string.dialog_groundloot_message));
|
||||
}
|
||||
appendGoldPickedUpMessage(ctx, loot, sb);
|
||||
return sb.toString();
|
||||
}
|
||||
public static String getGroundLootPickedUpMessage(final Context ctx, final Loot loot) {
|
||||
StringBuilder sb = new StringBuilder(60);
|
||||
appendLootPickedUpMessage(ctx, loot, sb);
|
||||
return sb.toString();
|
||||
}
|
||||
public static String getMonsterLootFoundMessage(final Context ctx, final Loot combinedLoot, final int exp) {
|
||||
StringBuilder sb = new StringBuilder(60);
|
||||
appendMonsterEncounterSurvivedMessage(ctx, sb, exp);
|
||||
appendGoldPickedUpMessage(ctx, combinedLoot, sb);
|
||||
return sb.toString();
|
||||
}
|
||||
public static String getMonsterLootPickedUpMessage(final Context ctx, final Loot combinedLoot, final int exp) {
|
||||
StringBuilder sb = new StringBuilder(60);
|
||||
appendMonsterEncounterSurvivedMessage(ctx, sb, exp);
|
||||
appendLootPickedUpMessage(ctx, combinedLoot, sb);
|
||||
return sb.toString();
|
||||
}
|
||||
private static void appendMonsterEncounterSurvivedMessage(final Context ctx, final StringBuilder sb, final int exp) {
|
||||
sb.append(ctx.getString(R.string.dialog_monsterloot_message));
|
||||
if (exp > 0) {
|
||||
sb.append(' ');
|
||||
sb.append(ctx.getString(R.string.dialog_monsterloot_gainedexp, exp));
|
||||
}
|
||||
}
|
||||
private static void appendGoldPickedUpMessage(final Context ctx, final Loot loot, final StringBuilder sb) {
|
||||
if (loot.gold > 0) {
|
||||
sb.append(' ');
|
||||
sb.append(ctx.getString(R.string.dialog_loot_foundgold, loot.gold));
|
||||
}
|
||||
}
|
||||
private static void appendLootPickedUpMessage(final Context ctx, final Loot loot, final StringBuilder sb) {
|
||||
appendGoldPickedUpMessage(ctx, loot, sb);
|
||||
int numItems = loot.items.countItems();
|
||||
if (numItems == 1) {
|
||||
sb.append(' ');
|
||||
sb.append(ctx.getString(R.string.dialog_loot_pickedupitem));
|
||||
} else if (numItems > 1){
|
||||
sb.append(' ');
|
||||
sb.append(ctx.getString(R.string.dialog_loot_pickedupitems, numItems));
|
||||
}
|
||||
}
|
||||
|
||||
public static void showMonsterLoot(final MainActivity mainActivity, final ControllerContext controllers, final WorldContext world, final Collection<Loot> lootBags, final Loot combinedLoot, final String msg) {
|
||||
// CombatController will do killedMonsterBags.clear() after this method has been called,
|
||||
// so we need to keep the list of objects. Therefore, we create a shallow copy of the list of bags.
|
||||
ArrayList<Loot> bags = new ArrayList<Loot>(lootBags);
|
||||
showLoot(mainActivity, controllers, world, combinedLoot, bags, R.string.dialog_monsterloot_title, msg);
|
||||
}
|
||||
|
||||
public static void showGroundLoot(final MainActivity mainActivity, final ControllerContext controllers, final WorldContext world, final Loot loot, final String msg) {
|
||||
showLoot(mainActivity, controllers, world, loot, Collections.singletonList(loot), R.string.dialog_groundloot_title, msg);
|
||||
}
|
||||
|
||||
private static void showLoot(final MainActivity mainActivity, final ControllerContext controllers, final WorldContext world, final Loot combinedLoot, final Iterable<Loot> lootBags, final int title, final String msg) {
|
||||
final ListView itemList = new ListView(mainActivity);
|
||||
itemList.setBackgroundResource(android.R.color.transparent);
|
||||
itemList.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, ListView.LayoutParams.WRAP_CONTENT));
|
||||
// itemList.setPadding(20, 0, 20, 20);
|
||||
itemList.setAdapter(new ItemContainerAdapter(mainActivity, world.tileManager, combinedLoot.items, world.model.player));
|
||||
|
||||
final Dialog d = CustomDialogFactory.createDialog(mainActivity,
|
||||
mainActivity.getResources().getString(title),
|
||||
mainActivity.getResources().getDrawable(R.drawable.ui_icon_equipment),
|
||||
msg,
|
||||
combinedLoot.items.isEmpty() ? null : itemList,
|
||||
true,
|
||||
false);
|
||||
|
||||
itemList.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||
|
||||
final String itemTypeID = ((ItemContainerAdapter) parent.getAdapter()).getItem(position).itemType.id;
|
||||
boolean removeFromCombinedLoot = true;
|
||||
for (Loot l : lootBags) {
|
||||
if (l == combinedLoot) removeFromCombinedLoot = false;
|
||||
if (l.items.removeItem(itemTypeID)) {
|
||||
controllers.itemController.removeLootBagIfEmpty(l);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (removeFromCombinedLoot) {
|
||||
combinedLoot.items.removeItem(itemTypeID);
|
||||
}
|
||||
if (((ItemContainerAdapter) parent.getAdapter()).isEmpty()) {
|
||||
ViewGroup vg = (ViewGroup) d.findViewById(R.id.dialog_content_container);
|
||||
vg.setVisibility(View.GONE);
|
||||
}
|
||||
ItemType type = world.itemTypes.getItemType(itemTypeID);
|
||||
world.model.player.inventory.addItem(type);
|
||||
((ItemContainerAdapter) itemList.getAdapter()).notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
|
||||
if (!itemList.getAdapter().isEmpty()) {
|
||||
CustomDialogFactory.addButton(d, R.string.dialog_loot_pickall, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
controllers.itemController.pickupAll(lootBags);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, R.string.dialog_close);
|
||||
|
||||
showDialogAndPause(d, controllers, new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
controllers.itemController.removeLootBagIfEmpty(lootBags);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void showHeroDied(final MainActivity mainActivity, final ControllerContext controllers) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(mainActivity,
|
||||
mainActivity.getResources().getString(R.string.dialog_game_over_title),
|
||||
mainActivity.getResources().getDrawable(R.drawable.ui_icon_combat),
|
||||
mainActivity.getResources().getString(R.string.dialog_game_over_text),
|
||||
null,
|
||||
true,
|
||||
false);
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
|
||||
showDialogAndPause(d, controllers, new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
mainActivity.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static Intent getIntentForItemInfo(final Context ctx, String itemTypeID, ItemInfoActivity.ItemInfoAction actionType, String buttonText, boolean buttonEnabled, Inventory.WearSlot inventorySlot) {
|
||||
Intent intent = new Intent(ctx, ItemInfoActivity.class);
|
||||
intent.putExtra("buttonText", buttonText);
|
||||
intent.putExtra("buttonEnabled", buttonEnabled);
|
||||
intent.putExtra("moreActions", (actionType == ItemInfoActivity.ItemInfoAction.equip || actionType == ItemInfoActivity.ItemInfoAction.use || actionType == ItemInfoActivity.ItemInfoAction.none));
|
||||
intent.putExtra("itemTypeID", itemTypeID);
|
||||
intent.putExtra("actionType", actionType.name());
|
||||
if (inventorySlot != null) intent.putExtra("inventorySlot", inventorySlot.name());
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/iteminfo/" + itemTypeID));
|
||||
return intent;
|
||||
}
|
||||
public static Intent getIntentForLevelUp(final Context ctx) {
|
||||
Intent intent = new Intent(ctx, LevelUpActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/levelup"));
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static void showConfirmRest(final Activity currentActivity, final ControllerContext controllerContext, final MapObject area) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(currentActivity,
|
||||
currentActivity.getResources().getString(R.string.dialog_rest_title),
|
||||
null,
|
||||
currentActivity.getResources().getString(R.string.dialog_rest_confirm_message),
|
||||
null,
|
||||
true);
|
||||
|
||||
CustomDialogFactory.addButton(d, android.R.string.yes, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
controllerContext.mapController.rest(area);
|
||||
}
|
||||
});
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.no);
|
||||
|
||||
showDialogAndPause(d, controllerContext);
|
||||
}
|
||||
public static void showRested(final Activity currentActivity, final ControllerContext controllerContext) {
|
||||
// Dialog d = new AlertDialog.Builder(new ContextThemeWrapper(currentActivity, R.style.AndorsTrailStyle))
|
||||
// .setTitle(R.string.dialog_rest_title)
|
||||
// .setMessage(R.string.dialog_rest_message)
|
||||
// .setNeutralButton(android.R.string.ok, null)
|
||||
// .create();
|
||||
final Dialog d = CustomDialogFactory.createDialog(currentActivity,
|
||||
currentActivity.getResources().getString(R.string.dialog_rest_title),
|
||||
null,
|
||||
currentActivity.getResources().getString(R.string.dialog_rest_message),
|
||||
null,
|
||||
true);
|
||||
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
|
||||
showDialogAndPause(d, controllerContext);
|
||||
}
|
||||
|
||||
public static void showNewVersion(final Activity currentActivity, final OnDismissListener onDismiss) {
|
||||
// new AlertDialog.Builder(new ContextThemeWrapper(currentActivity, R.style.AndorsTrailStyle))
|
||||
// .setTitle(R.string.dialog_newversion_title)
|
||||
// .setMessage(R.string.dialog_newversion_message)
|
||||
// .setNeutralButton(android.R.string.ok, null)
|
||||
// .show();
|
||||
|
||||
String text = currentActivity.getResources().getString(R.string.dialog_newversion_message);
|
||||
|
||||
if (!hasPermissions(currentActivity) && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||
text += currentActivity.getResources().getString(R.string.dialog_newversion_permission_information);
|
||||
}
|
||||
|
||||
final Dialog d = CustomDialogFactory.createDialog(currentActivity,
|
||||
currentActivity.getResources().getString(R.string.dialog_newversion_title),
|
||||
null,
|
||||
text,
|
||||
null,
|
||||
true);
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
CustomDialogFactory.setDismissListener(d, new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
if (onDismiss != null) onDismiss.onDismiss(arg0);
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
|
||||
@TargetApi(23)
|
||||
private static boolean hasPermissions(final Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (activity.getApplicationContext().checkSelfPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
|
||||
|| activity.getApplicationContext().checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean showSave(final Activity mainActivity, final ControllerContext controllerContext, final WorldContext world) {
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
Toast.makeText(mainActivity, R.string.menu_save_saving_not_allowed_in_combat, Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!world.model.statistics.hasUnlimitedSaves()) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(mainActivity,
|
||||
mainActivity.getResources().getString(R.string.menu_save_switch_character_title),
|
||||
null,
|
||||
mainActivity.getResources().getString(R.string.menu_save_switch_character),
|
||||
null,
|
||||
true);
|
||||
CustomDialogFactory.addButton(d, android.R.string.ok, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
controllerContext.gameRoundController.pause();
|
||||
Intent intent = new Intent(mainActivity, LoadSaveActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/save"));
|
||||
mainActivity.startActivityForResult(intent, MainActivity.INTENTREQUEST_SAVEGAME);
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.cancel);
|
||||
CustomDialogFactory.show(d);
|
||||
return false;
|
||||
} else {
|
||||
controllerContext.gameRoundController.pause();
|
||||
Intent intent = new Intent(mainActivity, LoadSaveActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/save"));
|
||||
mainActivity.startActivityForResult(intent, MainActivity.INTENTREQUEST_SAVEGAME);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void showLoad(final Activity currentActivity) {
|
||||
Intent intent = new Intent(currentActivity, LoadSaveActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/load"));
|
||||
currentActivity.startActivityForResult(intent, StartScreenActivity_MainMenu.INTENTREQUEST_LOADGAME);
|
||||
}
|
||||
|
||||
public static void showLoad(final Fragment currentFragment) {
|
||||
Intent intent = new Intent(currentFragment.getActivity(), LoadSaveActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/load"));
|
||||
currentFragment.startActivityForResult(intent, StartScreenActivity_MainMenu.INTENTREQUEST_LOADGAME);
|
||||
}
|
||||
|
||||
public static void showActorConditionInfo(final Context context, ActorConditionType conditionType) {
|
||||
Intent intent = new Intent(context, ActorConditionInfoActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/actorconditioninfo/" + conditionType.conditionTypeID));
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static Intent getIntentForBulkBuyingInterface(final Context ctx, String itemTypeID, int totalAvailableAmount) {
|
||||
return getIntentForBulkSelectionInterface(ctx, itemTypeID, totalAvailableAmount, BulkSelectionInterface.BulkInterfaceType.buy);
|
||||
}
|
||||
|
||||
public static Intent getIntentForBulkSellingInterface(final Context ctx, String itemTypeID, int totalAvailableAmount) {
|
||||
return getIntentForBulkSelectionInterface(ctx, itemTypeID, totalAvailableAmount, BulkSelectionInterface.BulkInterfaceType.sell);
|
||||
}
|
||||
|
||||
public static Intent getIntentForBulkDroppingInterface(final Context ctx, String itemTypeID, int totalAvailableAmount) {
|
||||
return getIntentForBulkSelectionInterface(ctx, itemTypeID, totalAvailableAmount, BulkSelectionInterface.BulkInterfaceType.drop);
|
||||
}
|
||||
|
||||
private static Intent getIntentForBulkSelectionInterface(final Context ctx, String itemTypeID, int totalAvailableAmount, BulkSelectionInterface.BulkInterfaceType interfaceType) {
|
||||
Intent intent = new Intent(ctx, BulkSelectionInterface.class);
|
||||
intent.putExtra("itemTypeID", itemTypeID);
|
||||
intent.putExtra("totalAvailableAmount", totalAvailableAmount);
|
||||
intent.putExtra("interfaceType", interfaceType.name());
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/bulkselection/" + itemTypeID));
|
||||
return intent;
|
||||
}
|
||||
public static Intent getIntentForSkillInfo(final Context ctx, SkillCollection.SkillID skillID) {
|
||||
Intent intent = new Intent(ctx, SkillInfoActivity.class);
|
||||
intent.putExtra("skillID", skillID.name());
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/showskillinfo/" + skillID));
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static void showCombatLog(final Context context, final ControllerContext controllerContext, final WorldContext world) {
|
||||
String[] combatLogMessages = world.model.combatLog.getAllMessages();
|
||||
|
||||
View view = null;
|
||||
ListView itemList = null;
|
||||
itemList = new ListView(context);
|
||||
itemList.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, ListView.LayoutParams.WRAP_CONTENT));
|
||||
itemList.setStackFromBottom(true);
|
||||
itemList.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
|
||||
itemList.setChoiceMode(ListView.CHOICE_MODE_NONE);
|
||||
itemList.setBackgroundColor(ThemeHelper.getThemeColor(context, R.attr.ui_theme_stdframe_bg_color));
|
||||
if (combatLogMessages.length <= 0) {
|
||||
combatLogMessages = new String[] {context.getResources().getString(R.string.combat_log_noentries)};
|
||||
}
|
||||
itemList.setAdapter(new ArrayAdapter<String>(context, R.layout.combatlog_row, android.R.id.text1, combatLogMessages));
|
||||
view = itemList;
|
||||
|
||||
final Dialog d = CustomDialogFactory.createDialog(context,
|
||||
context.getResources().getString(R.string.combat_log_title),
|
||||
context.getResources().getDrawable(R.drawable.ui_icon_combat),
|
||||
null,
|
||||
view,
|
||||
true);
|
||||
|
||||
|
||||
CustomDialogFactory.addDismissButton(d, R.string.dialog_close);
|
||||
|
||||
showDialogAndPause(d, controllerContext);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
|
||||
public abstract class AndorsTrailBaseFragmentActivity extends FragmentActivity {
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
|
||||
@@ -1,172 +1,168 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.WorldMapController;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment.WorldMapSegmentMap;
|
||||
import com.gpl.rpg.AndorsTrail.util.AndroidStorage;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.FileProvider;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
public final class DisplayWorldMapActivity extends AndorsTrailBaseActivity {
|
||||
private WorldContext world;
|
||||
|
||||
private WebView displayworldmap_webview;
|
||||
private String worldMapSegmentName;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(ThemeHelper.getBaseTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
if (!app.isInitialized()) { finish(); return; }
|
||||
this.world = app.getWorld();
|
||||
|
||||
app.setWindowParameters(this);
|
||||
|
||||
setContentView(R.layout.displayworldmap);
|
||||
|
||||
displayworldmap_webview = (WebView) findViewById(R.id.displayworldmap_webview);
|
||||
displayworldmap_webview.setBackgroundColor(ThemeHelper.getThemeColor(this, R.attr.ui_theme_displayworldmap_bg_color));
|
||||
displayworldmap_webview.getSettings().setBuiltInZoomControls(true);
|
||||
displayworldmap_webview.getSettings().setUseWideViewPort(true);
|
||||
displayworldmap_webview.setVerticalScrollBarEnabled(true);
|
||||
displayworldmap_webview.setHorizontalScrollBarEnabled(true);
|
||||
displayworldmap_webview.getSettings().setAllowFileAccess(true);
|
||||
enableJavascript();
|
||||
|
||||
Button b = (Button) findViewById(R.id.displayworldmap_close);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
DisplayWorldMapActivity.this.finish();
|
||||
}
|
||||
});
|
||||
|
||||
b = (Button) findViewById(R.id.displayworldmap_recenter);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
recenter();
|
||||
}
|
||||
});
|
||||
|
||||
worldMapSegmentName = getIntent().getStringExtra("worldMapSegmentName");
|
||||
}
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
public void enableJavascript() {
|
||||
displayworldmap_webview.getSettings().setJavaScriptEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
update();
|
||||
}
|
||||
|
||||
WorldMapSegmentMap map;
|
||||
Coord offsetWorldmapTo;
|
||||
@SuppressLint("NewApi")
|
||||
private void update() {
|
||||
File worldmap = WorldMapController.getCombinedWorldMapFile(this, worldMapSegmentName);
|
||||
|
||||
if (!worldmap.exists()) {
|
||||
Toast.makeText(this, getResources().getString(R.string.menu_button_worldmap_failed), Toast.LENGTH_LONG).show();
|
||||
this.finish();
|
||||
}
|
||||
|
||||
WorldMapSegment segment = world.maps.worldMapSegments.get(worldMapSegmentName);
|
||||
map = segment.maps.get(world.model.currentMaps.map.name);
|
||||
if (map == null) {
|
||||
this.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
offsetWorldmapTo = new Coord(999999, 999999);
|
||||
for (WorldMapSegmentMap map : segment.maps.values()) {
|
||||
PredefinedMap predefinedMap = world.maps.findPredefinedMap(map.mapName);
|
||||
if (predefinedMap == null) continue;
|
||||
if (!predefinedMap.visited) continue;
|
||||
if (!WorldMapController.fileForMapExists(this, predefinedMap)) continue;
|
||||
|
||||
offsetWorldmapTo.x = Math.min(offsetWorldmapTo.x, map.worldPosition.x);
|
||||
offsetWorldmapTo.y = Math.min(offsetWorldmapTo.y, map.worldPosition.y);
|
||||
}
|
||||
|
||||
String url = AndroidStorage.getUrlForFile(this, worldmap) + '?'
|
||||
+ (world.model.player.position.x + map.worldPosition.x) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE
|
||||
+ ','
|
||||
+ (world.model.player.position.y + map.worldPosition.y-1) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE;
|
||||
L.log("Showing " + url);
|
||||
displayworldmap_webview.loadUrl(url);
|
||||
displayworldmap_webview.setBackgroundColor(ThemeHelper.getThemeColor(this, R.attr.ui_theme_displayworldmap_bg_color));
|
||||
displayworldmap_webview.setWebViewClient(new WebViewClient() {
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url)
|
||||
{
|
||||
recenter();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void recenter() {
|
||||
displayworldmap_webview.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (map != null) {
|
||||
//Local map to global worldmap
|
||||
int x = world.model.player.position.x + map.worldPosition.x - offsetWorldmapTo.x;
|
||||
//Tile coord to pixel coord
|
||||
x *= WorldMapController.WORLDMAP_DISPLAY_TILESIZE;
|
||||
x += WorldMapController.WORLDMAP_DISPLAY_TILESIZE/2;
|
||||
//Zoom level
|
||||
x = (int)(x * displayworldmap_webview.getScale());
|
||||
//Center
|
||||
x -= displayworldmap_webview.getWidth() / 2;
|
||||
|
||||
//Local map to global worldmap
|
||||
int y = world.model.player.position.y + map.worldPosition.y - offsetWorldmapTo.y;
|
||||
//Tile coord to pixel coord
|
||||
y *= WorldMapController.WORLDMAP_DISPLAY_TILESIZE;
|
||||
y += WorldMapController.WORLDMAP_DISPLAY_TILESIZE/2;
|
||||
//Zoom level
|
||||
y = (int)(y * displayworldmap_webview.getScale());
|
||||
//Center
|
||||
y -= displayworldmap_webview.getHeight() / 2;
|
||||
|
||||
displayworldmap_webview.scrollTo(x, y);
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
ViewGroup view = (ViewGroup) getWindow().getDecorView();
|
||||
view.removeAllViews();
|
||||
super.finish();
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.WorldMapController;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment.WorldMapSegmentMap;
|
||||
import com.gpl.rpg.AndorsTrail.util.AndroidStorage;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
public final class DisplayWorldMapActivity extends AndorsTrailBaseActivity {
|
||||
private WorldContext world;
|
||||
|
||||
private WebView displayworldmap_webview;
|
||||
private String worldMapSegmentName;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(ThemeHelper.getBaseTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
if (!app.isInitialized()) { finish(); return; }
|
||||
this.world = app.getWorld();
|
||||
|
||||
app.setWindowParameters(this);
|
||||
|
||||
setContentView(R.layout.displayworldmap);
|
||||
|
||||
displayworldmap_webview = (WebView) findViewById(R.id.displayworldmap_webview);
|
||||
displayworldmap_webview.setBackgroundColor(ThemeHelper.getThemeColor(this, R.attr.ui_theme_displayworldmap_bg_color));
|
||||
displayworldmap_webview.getSettings().setBuiltInZoomControls(true);
|
||||
displayworldmap_webview.getSettings().setUseWideViewPort(true);
|
||||
displayworldmap_webview.setVerticalScrollBarEnabled(true);
|
||||
displayworldmap_webview.setHorizontalScrollBarEnabled(true);
|
||||
displayworldmap_webview.getSettings().setAllowFileAccess(true);
|
||||
enableJavascript();
|
||||
|
||||
Button b = (Button) findViewById(R.id.displayworldmap_close);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
DisplayWorldMapActivity.this.finish();
|
||||
}
|
||||
});
|
||||
|
||||
b = (Button) findViewById(R.id.displayworldmap_recenter);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
recenter();
|
||||
}
|
||||
});
|
||||
|
||||
worldMapSegmentName = getIntent().getStringExtra("worldMapSegmentName");
|
||||
}
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
public void enableJavascript() {
|
||||
displayworldmap_webview.getSettings().setJavaScriptEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
update();
|
||||
}
|
||||
|
||||
WorldMapSegmentMap map;
|
||||
Coord offsetWorldmapTo;
|
||||
@SuppressLint("NewApi")
|
||||
private void update() {
|
||||
File worldmap = WorldMapController.getCombinedWorldMapFile(this, worldMapSegmentName);
|
||||
|
||||
if (!worldmap.exists()) {
|
||||
Toast.makeText(this, getResources().getString(R.string.menu_button_worldmap_failed), Toast.LENGTH_LONG).show();
|
||||
this.finish();
|
||||
}
|
||||
|
||||
WorldMapSegment segment = world.maps.worldMapSegments.get(worldMapSegmentName);
|
||||
map = segment.maps.get(world.model.currentMaps.map.name);
|
||||
if (map == null) {
|
||||
this.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
offsetWorldmapTo = new Coord(999999, 999999);
|
||||
for (WorldMapSegmentMap map : segment.maps.values()) {
|
||||
PredefinedMap predefinedMap = world.maps.findPredefinedMap(map.mapName);
|
||||
if (predefinedMap == null) continue;
|
||||
if (!predefinedMap.visited) continue;
|
||||
if (!WorldMapController.fileForMapExists(this, predefinedMap)) continue;
|
||||
|
||||
offsetWorldmapTo.x = Math.min(offsetWorldmapTo.x, map.worldPosition.x);
|
||||
offsetWorldmapTo.y = Math.min(offsetWorldmapTo.y, map.worldPosition.y);
|
||||
}
|
||||
|
||||
String url = AndroidStorage.getUrlForFile(this, worldmap) + '?'
|
||||
+ (world.model.player.position.x + map.worldPosition.x) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE
|
||||
+ ','
|
||||
+ (world.model.player.position.y + map.worldPosition.y-1) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE;
|
||||
L.log("Showing " + url);
|
||||
displayworldmap_webview.loadUrl(url);
|
||||
displayworldmap_webview.setBackgroundColor(ThemeHelper.getThemeColor(this, R.attr.ui_theme_displayworldmap_bg_color));
|
||||
displayworldmap_webview.setWebViewClient(new WebViewClient() {
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url)
|
||||
{
|
||||
recenter();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void recenter() {
|
||||
displayworldmap_webview.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (map != null) {
|
||||
//Local map to global worldmap
|
||||
int x = world.model.player.position.x + map.worldPosition.x - offsetWorldmapTo.x;
|
||||
//Tile coord to pixel coord
|
||||
x *= WorldMapController.WORLDMAP_DISPLAY_TILESIZE;
|
||||
x += WorldMapController.WORLDMAP_DISPLAY_TILESIZE/2;
|
||||
//Zoom level
|
||||
x = (int)(x * displayworldmap_webview.getScale());
|
||||
//Center
|
||||
x -= displayworldmap_webview.getWidth() / 2;
|
||||
|
||||
//Local map to global worldmap
|
||||
int y = world.model.player.position.y + map.worldPosition.y - offsetWorldmapTo.y;
|
||||
//Tile coord to pixel coord
|
||||
y *= WorldMapController.WORLDMAP_DISPLAY_TILESIZE;
|
||||
y += WorldMapController.WORLDMAP_DISPLAY_TILESIZE/2;
|
||||
//Zoom level
|
||||
y = (int)(y * displayworldmap_webview.getScale());
|
||||
//Center
|
||||
y -= displayworldmap_webview.getHeight() / 2;
|
||||
|
||||
displayworldmap_webview.scrollTo(x, y);
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
ViewGroup view = (ViewGroup) getWindow().getDecorView();
|
||||
view.removeAllViews();
|
||||
super.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentTabHost;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
@@ -1,139 +1,139 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
import com.gpl.rpg.AndorsTrail.view.ItemEffectsView;
|
||||
|
||||
public final class ItemInfoActivity extends AndorsTrailBaseActivity {
|
||||
|
||||
public static enum ItemInfoAction {
|
||||
none, use, equip, unequip, buy, sell
|
||||
}
|
||||
|
||||
public static final int RESULT_MORE_ACTIONS = Activity.RESULT_FIRST_USER;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(ThemeHelper.getDialogTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
if (!app.isInitialized()) { finish(); return; }
|
||||
final WorldContext world = app.getWorld();
|
||||
|
||||
app.setWindowParameters(this);
|
||||
|
||||
final Intent intent = getIntent();
|
||||
Bundle params = intent.getExtras();
|
||||
String itemTypeID = params.getString("itemTypeID");
|
||||
final ItemType itemType = world.itemTypes.getItemType(itemTypeID);
|
||||
|
||||
final String buttonText = params.getString("buttonText");
|
||||
boolean buttonEnabled = params.getBoolean("buttonEnabled");
|
||||
boolean moreButtonEnabled = params.getBoolean("moreActions");
|
||||
|
||||
setContentView(R.layout.iteminfo);
|
||||
|
||||
TextView tv = (TextView) findViewById(R.id.iteminfo_title);
|
||||
tv.setText(itemType.getName(world.model.player));
|
||||
world.tileManager.setImageViewTileForSingleItemType(getResources(), tv, itemType);
|
||||
|
||||
tv = (TextView) findViewById(R.id.iteminfo_description);
|
||||
String description = itemType.getDescription();
|
||||
if (description != null) {
|
||||
tv.setText(description);
|
||||
tv.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
tv = (TextView) findViewById(R.id.iteminfo_category);
|
||||
tv.setText(itemType.category.displayName);
|
||||
|
||||
((ItemEffectsView) findViewById(R.id.iteminfo_effects)).update(
|
||||
itemType.effects_equip,
|
||||
itemType.effects_use == null ? null : Collections.singletonList(itemType.effects_use),
|
||||
itemType.effects_hit == null ? null : Collections.singletonList(itemType.effects_hit),
|
||||
itemType.effects_kill == null ? null : Collections.singletonList(itemType.effects_kill),
|
||||
itemType.effects_hitReceived == null ? null : Collections.singletonList(itemType.effects_hitReceived),
|
||||
null,
|
||||
itemType.isWeapon()
|
||||
);
|
||||
|
||||
Button b = (Button) findViewById(R.id.iteminfo_close);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
setResult(RESULT_CANCELED);
|
||||
ItemInfoActivity.this.finish();
|
||||
}
|
||||
});
|
||||
|
||||
b = (Button) findViewById(R.id.iteminfo_more);
|
||||
if (!moreButtonEnabled) {
|
||||
b.setVisibility(View.GONE);
|
||||
} else {
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
Intent result = new Intent();
|
||||
result.putExtras(intent);
|
||||
setResult(RESULT_MORE_ACTIONS, intent);
|
||||
ItemInfoActivity.this.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
b = (Button) findViewById(R.id.iteminfo_action);
|
||||
if (buttonText != null && buttonText.length() > 0) {
|
||||
b.setVisibility(View.VISIBLE);
|
||||
b.setEnabled(buttonEnabled);
|
||||
b.setText(buttonText);
|
||||
} else {
|
||||
b.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
Intent result = new Intent();
|
||||
result.putExtras(intent);
|
||||
setResult(RESULT_OK, result);
|
||||
ItemInfoActivity.this.finish();
|
||||
}
|
||||
});
|
||||
|
||||
tv = (TextView) findViewById(R.id.iteminfo_displaytype);
|
||||
if (itemType.isOrdinaryItem()) {
|
||||
tv.setVisibility(View.GONE);
|
||||
} else {
|
||||
tv.setVisibility(View.VISIBLE);
|
||||
final String diplayType = getDisplayTypeString(getResources(), itemType);
|
||||
tv.setText(diplayType);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDisplayTypeString(Resources res, ItemType itemType) {
|
||||
switch (itemType.displayType) {
|
||||
case rare: return res.getString(R.string.iteminfo_displaytypes_rare);
|
||||
case extraordinary: return res.getString(R.string.iteminfo_displaytypes_extraordinary);
|
||||
case legendary: return res.getString(R.string.iteminfo_displaytypes_legendary);
|
||||
case ordinary: return res.getString(R.string.iteminfo_displaytypes_ordinary);
|
||||
case quest: return res.getString(R.string.iteminfo_displaytypes_quest);
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
import com.gpl.rpg.AndorsTrail.view.ItemEffectsView;
|
||||
|
||||
public final class ItemInfoActivity extends AndorsTrailBaseActivity {
|
||||
|
||||
public static enum ItemInfoAction {
|
||||
none, use, equip, unequip, buy, sell
|
||||
}
|
||||
|
||||
public static final int RESULT_MORE_ACTIONS = Activity.RESULT_FIRST_USER;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(ThemeHelper.getDialogTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
if (!app.isInitialized()) { finish(); return; }
|
||||
final WorldContext world = app.getWorld();
|
||||
|
||||
app.setWindowParameters(this);
|
||||
|
||||
final Intent intent = getIntent();
|
||||
Bundle params = intent.getExtras();
|
||||
String itemTypeID = params.getString("itemTypeID");
|
||||
final ItemType itemType = world.itemTypes.getItemType(itemTypeID);
|
||||
|
||||
final String buttonText = params.getString("buttonText");
|
||||
boolean buttonEnabled = params.getBoolean("buttonEnabled");
|
||||
boolean moreButtonEnabled = params.getBoolean("moreActions");
|
||||
|
||||
setContentView(R.layout.iteminfo);
|
||||
|
||||
TextView tv = (TextView) findViewById(R.id.iteminfo_title);
|
||||
tv.setText(itemType.getName(world.model.player));
|
||||
world.tileManager.setImageViewTileForSingleItemType(getResources(), tv, itemType);
|
||||
|
||||
tv = (TextView) findViewById(R.id.iteminfo_description);
|
||||
String description = itemType.getDescription();
|
||||
if (description != null) {
|
||||
tv.setText(description);
|
||||
tv.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
tv = (TextView) findViewById(R.id.iteminfo_category);
|
||||
tv.setText(itemType.category.displayName);
|
||||
|
||||
((ItemEffectsView) findViewById(R.id.iteminfo_effects)).update(
|
||||
itemType.effects_equip,
|
||||
itemType.effects_use == null ? null : Collections.singletonList(itemType.effects_use),
|
||||
itemType.effects_hit == null ? null : Collections.singletonList(itemType.effects_hit),
|
||||
itemType.effects_kill == null ? null : Collections.singletonList(itemType.effects_kill),
|
||||
itemType.effects_hitReceived == null ? null : Collections.singletonList(itemType.effects_hitReceived),
|
||||
null,
|
||||
itemType.isWeapon()
|
||||
);
|
||||
|
||||
Button b = (Button) findViewById(R.id.iteminfo_close);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
setResult(RESULT_CANCELED);
|
||||
ItemInfoActivity.this.finish();
|
||||
}
|
||||
});
|
||||
|
||||
b = (Button) findViewById(R.id.iteminfo_more);
|
||||
if (!moreButtonEnabled) {
|
||||
b.setVisibility(View.GONE);
|
||||
} else {
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
Intent result = new Intent();
|
||||
result.putExtras(intent);
|
||||
setResult(RESULT_MORE_ACTIONS, intent);
|
||||
ItemInfoActivity.this.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
b = (Button) findViewById(R.id.iteminfo_action);
|
||||
if (buttonText != null && buttonText.length() > 0) {
|
||||
b.setVisibility(View.VISIBLE);
|
||||
b.setEnabled(buttonEnabled);
|
||||
b.setText(buttonText);
|
||||
} else {
|
||||
b.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
Intent result = new Intent();
|
||||
result.putExtras(intent);
|
||||
setResult(RESULT_OK, result);
|
||||
ItemInfoActivity.this.finish();
|
||||
}
|
||||
});
|
||||
|
||||
tv = (TextView) findViewById(R.id.iteminfo_displaytype);
|
||||
if (itemType.isOrdinaryItem()) {
|
||||
tv.setVisibility(View.GONE);
|
||||
} else {
|
||||
tv.setVisibility(View.VISIBLE);
|
||||
final String diplayType = getDisplayTypeString(getResources(), itemType);
|
||||
tv.setText(diplayType);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDisplayTypeString(Resources res, ItemType itemType) {
|
||||
switch (itemType.displayType) {
|
||||
case rare: return res.getString(R.string.iteminfo_displaytypes_rare);
|
||||
case extraordinary: return res.getString(R.string.iteminfo_displaytypes_extraordinary);
|
||||
case legendary: return res.getString(R.string.iteminfo_displaytypes_legendary);
|
||||
case ordinary: return res.getString(R.string.iteminfo_displaytypes_ordinary);
|
||||
case quest: return res.getString(R.string.iteminfo_displaytypes_quest);
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
@@ -1,180 +1,179 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.WorldSetup;
|
||||
import com.gpl.rpg.AndorsTrail.WorldSetup.OnResourcesLoadedListener;
|
||||
import com.gpl.rpg.AndorsTrail.WorldSetup.OnSceneLoadedListener;
|
||||
import com.gpl.rpg.AndorsTrail.savegames.Savegames;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
import com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||
|
||||
public final class LoadingActivity extends AndorsTrailBaseActivity implements OnResourcesLoadedListener, OnSceneLoadedListener {
|
||||
|
||||
private WorldSetup setup;
|
||||
private Dialog progressDialog;
|
||||
private CloudsAnimatorView clouds_back, clouds_mid, clouds_front;
|
||||
boolean loaded = false;
|
||||
|
||||
private Object semaphore = new Object();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(ThemeHelper.getBaseTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
app.setWindowParameters(this);
|
||||
setContentView(R.layout.startscreen);
|
||||
|
||||
TextView tv = (TextView) findViewById(R.id.startscreen_version);
|
||||
tv.setVisibility(View.GONE);
|
||||
|
||||
clouds_back = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_back);
|
||||
if (clouds_back != null) clouds_back.setCloudsCountAndLayer(40, CloudsAnimatorView.Layer.below);
|
||||
clouds_mid = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_mid);
|
||||
if (clouds_mid != null) clouds_mid.setCloudsCountAndLayer(15, CloudsAnimatorView.Layer.center);
|
||||
clouds_front = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_front);
|
||||
if (clouds_front != null) clouds_front.setCloudsCountAndLayer(8, CloudsAnimatorView.Layer.above);
|
||||
|
||||
this.setup = app.getWorldSetup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
if (hasFocus) {
|
||||
((AnimationDrawable)((ImageView)findViewById(R.id.title_logo)).getDrawable()).start();
|
||||
ImageView iv = (ImageView) findViewById(R.id.ts_foreground);
|
||||
int ivWidth = iv.getWidth();
|
||||
int drawableWidth = iv.getDrawable().getIntrinsicWidth();
|
||||
float ratio = ((float)ivWidth) / ((float)drawableWidth);
|
||||
|
||||
if (clouds_back != null) {
|
||||
clouds_back.setScalingRatio(ratio);
|
||||
}
|
||||
if (clouds_mid != null) {
|
||||
clouds_mid.setScalingRatio(ratio);
|
||||
}
|
||||
if (clouds_front != null) {
|
||||
clouds_front.setScalingRatio(ratio);
|
||||
}
|
||||
|
||||
if (progressDialog == null) {
|
||||
progressDialog = CustomDialogFactory.createDialog(this, getResources().getString(R.string.dialog_loading_message),
|
||||
getResources().getDrawable(R.drawable.loading_anim), null, null, false, false);
|
||||
synchronized (semaphore) {
|
||||
if (!loaded) {
|
||||
progressDialog.setOwnerActivity(this);
|
||||
CustomDialogFactory.show(progressDialog);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
setup.setOnResourcesLoadedListener(this);
|
||||
|
||||
|
||||
final ImageView iv = (ImageView) findViewById(R.id.ts_foreground);
|
||||
iv.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
float[] point = new float[]{0f,0.25f * iv.getDrawable().getIntrinsicHeight()};
|
||||
iv.getImageMatrix().mapPoints(point);
|
||||
int imgY = (int) (iv.getTop() + point[1]);
|
||||
|
||||
if (clouds_back != null) {
|
||||
clouds_back.setYMax(imgY);
|
||||
}
|
||||
if (clouds_mid != null) {
|
||||
clouds_mid.setYMax(imgY);
|
||||
}
|
||||
if (clouds_front != null) {
|
||||
clouds_front.setYMax(imgY);
|
||||
}
|
||||
iv.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (clouds_back != null)clouds_back.resumeAnimation();
|
||||
if (clouds_mid != null)clouds_mid.resumeAnimation();
|
||||
if (clouds_front != null)clouds_front.resumeAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
setup.setOnResourcesLoadedListener(null);
|
||||
setup.removeOnSceneLoadedListener(this);
|
||||
if (clouds_back != null)clouds_back.pauseAnimation();
|
||||
if (clouds_mid != null)clouds_mid.pauseAnimation();
|
||||
if (clouds_front != null)clouds_front.pauseAnimation();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResourcesLoaded() {
|
||||
loaded = false;
|
||||
setup.startCharacterSetup(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onSceneLoaded() {
|
||||
synchronized (semaphore) {
|
||||
if (progressDialog != null) progressDialog.dismiss();
|
||||
loaded =true;
|
||||
}
|
||||
startActivity(new Intent(this, MainActivity.class));
|
||||
this.finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSceneLoadFailed(Savegames.LoadSavegameResult loadResult) {
|
||||
synchronized (semaphore) {
|
||||
if (progressDialog != null) progressDialog.dismiss();
|
||||
loaded =true;
|
||||
}
|
||||
if (loadResult == Savegames.LoadSavegameResult.savegameIsFromAFutureVersion) {
|
||||
showLoadingFailedDialog(R.string.dialog_loading_failed_incorrectversion);
|
||||
} else if (loadResult == Savegames.LoadSavegameResult.cheatingDetected) {
|
||||
showLoadingFailedDialog(R.string.dialog_loading_failed_cheat);
|
||||
} else {
|
||||
showLoadingFailedDialog(R.string.dialog_loading_failed_message);
|
||||
}
|
||||
}
|
||||
|
||||
private void showLoadingFailedDialog(int messageResourceID) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(this, getResources().getString(R.string.dialog_loading_failed_title), null, getResources().getString(messageResourceID), null, true);
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
CustomDialogFactory.setDismissListener(d, new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
LoadingActivity.this.finish();
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.show(d);
|
||||
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.WorldSetup;
|
||||
import com.gpl.rpg.AndorsTrail.WorldSetup.OnResourcesLoadedListener;
|
||||
import com.gpl.rpg.AndorsTrail.WorldSetup.OnSceneLoadedListener;
|
||||
import com.gpl.rpg.AndorsTrail.savegames.Savegames;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
import com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||
|
||||
public final class LoadingActivity extends AndorsTrailBaseActivity implements OnResourcesLoadedListener, OnSceneLoadedListener {
|
||||
|
||||
private WorldSetup setup;
|
||||
private Dialog progressDialog;
|
||||
private CloudsAnimatorView clouds_back, clouds_mid, clouds_front;
|
||||
boolean loaded = false;
|
||||
|
||||
private Object semaphore = new Object();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(ThemeHelper.getBaseTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
app.setWindowParameters(this);
|
||||
setContentView(R.layout.startscreen);
|
||||
|
||||
TextView tv = (TextView) findViewById(R.id.startscreen_version);
|
||||
tv.setVisibility(View.GONE);
|
||||
|
||||
clouds_back = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_back);
|
||||
if (clouds_back != null) clouds_back.setCloudsCountAndLayer(40, CloudsAnimatorView.Layer.below);
|
||||
clouds_mid = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_mid);
|
||||
if (clouds_mid != null) clouds_mid.setCloudsCountAndLayer(15, CloudsAnimatorView.Layer.center);
|
||||
clouds_front = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_front);
|
||||
if (clouds_front != null) clouds_front.setCloudsCountAndLayer(8, CloudsAnimatorView.Layer.above);
|
||||
|
||||
this.setup = app.getWorldSetup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
if (hasFocus) {
|
||||
((AnimationDrawable)((ImageView)findViewById(R.id.title_logo)).getDrawable()).start();
|
||||
ImageView iv = (ImageView) findViewById(R.id.ts_foreground);
|
||||
int ivWidth = iv.getWidth();
|
||||
int drawableWidth = iv.getDrawable().getIntrinsicWidth();
|
||||
float ratio = ((float)ivWidth) / ((float)drawableWidth);
|
||||
|
||||
if (clouds_back != null) {
|
||||
clouds_back.setScalingRatio(ratio);
|
||||
}
|
||||
if (clouds_mid != null) {
|
||||
clouds_mid.setScalingRatio(ratio);
|
||||
}
|
||||
if (clouds_front != null) {
|
||||
clouds_front.setScalingRatio(ratio);
|
||||
}
|
||||
|
||||
if (progressDialog == null) {
|
||||
progressDialog = CustomDialogFactory.createDialog(this, getResources().getString(R.string.dialog_loading_message),
|
||||
getResources().getDrawable(R.drawable.loading_anim), null, null, false, false);
|
||||
synchronized (semaphore) {
|
||||
if (!loaded) {
|
||||
progressDialog.setOwnerActivity(this);
|
||||
CustomDialogFactory.show(progressDialog);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
setup.setOnResourcesLoadedListener(this);
|
||||
|
||||
|
||||
final ImageView iv = (ImageView) findViewById(R.id.ts_foreground);
|
||||
iv.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
float[] point = new float[]{0f,0.25f * iv.getDrawable().getIntrinsicHeight()};
|
||||
iv.getImageMatrix().mapPoints(point);
|
||||
int imgY = (int) (iv.getTop() + point[1]);
|
||||
|
||||
if (clouds_back != null) {
|
||||
clouds_back.setYMax(imgY);
|
||||
}
|
||||
if (clouds_mid != null) {
|
||||
clouds_mid.setYMax(imgY);
|
||||
}
|
||||
if (clouds_front != null) {
|
||||
clouds_front.setYMax(imgY);
|
||||
}
|
||||
iv.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (clouds_back != null)clouds_back.resumeAnimation();
|
||||
if (clouds_mid != null)clouds_mid.resumeAnimation();
|
||||
if (clouds_front != null)clouds_front.resumeAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
setup.setOnResourcesLoadedListener(null);
|
||||
setup.removeOnSceneLoadedListener(this);
|
||||
if (clouds_back != null)clouds_back.pauseAnimation();
|
||||
if (clouds_mid != null)clouds_mid.pauseAnimation();
|
||||
if (clouds_front != null)clouds_front.pauseAnimation();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResourcesLoaded() {
|
||||
loaded = false;
|
||||
setup.startCharacterSetup(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onSceneLoaded() {
|
||||
synchronized (semaphore) {
|
||||
if (progressDialog != null) progressDialog.dismiss();
|
||||
loaded =true;
|
||||
}
|
||||
startActivity(new Intent(this, MainActivity.class));
|
||||
this.finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSceneLoadFailed(Savegames.LoadSavegameResult loadResult) {
|
||||
synchronized (semaphore) {
|
||||
if (progressDialog != null) progressDialog.dismiss();
|
||||
loaded =true;
|
||||
}
|
||||
if (loadResult == Savegames.LoadSavegameResult.savegameIsFromAFutureVersion) {
|
||||
showLoadingFailedDialog(R.string.dialog_loading_failed_incorrectversion);
|
||||
} else if (loadResult == Savegames.LoadSavegameResult.cheatingDetected) {
|
||||
showLoadingFailedDialog(R.string.dialog_loading_failed_cheat);
|
||||
} else {
|
||||
showLoadingFailedDialog(R.string.dialog_loading_failed_message);
|
||||
}
|
||||
}
|
||||
|
||||
private void showLoadingFailedDialog(int messageResourceID) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(this, getResources().getString(R.string.dialog_loading_failed_title), null, getResources().getString(messageResourceID), null, true);
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
CustomDialogFactory.setDismissListener(d, new OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
LoadingActivity.this.finish();
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.show(d);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import com.gpl.rpg.AndorsTrail.controller.listeners.WorldEventListener;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.ActorCondition;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.ActorConditionEffect;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Loot;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.MapObject;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
|
||||
public final class Preferences extends PreferenceActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(ThemeHelper.getBaseTheme());
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
super.onCreate(savedInstanceState);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
if (app.getPreferences().fullscreen) {
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
} else {
|
||||
getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
|
||||
app.setLocale(this);
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
app.setLocale(this);
|
||||
}
|
||||
}
|
||||
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
|
||||
public final class Preferences extends PreferenceActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(ThemeHelper.getBaseTheme());
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
super.onCreate(savedInstanceState);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
if (app.getPreferences().fullscreen) {
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
} else {
|
||||
getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
|
||||
app.setLocale(this);
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
app.setLocale(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,8 @@ package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentTabHost;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
|
||||
@@ -1,292 +1,287 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailPreferences;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_MainMenu;
|
||||
import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_MainMenu.OnNewGameRequestedListener;
|
||||
import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_NewGame;
|
||||
import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_NewGame.GameCreationOverListener;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
import com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentManager.OnBackStackChangedListener;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public final class StartScreenActivity extends AndorsTrailBaseFragmentActivity implements OnNewGameRequestedListener, GameCreationOverListener, OnBackStackChangedListener {
|
||||
|
||||
private TextView tv;
|
||||
private TextView development_version;
|
||||
private CloudsAnimatorView clouds_back, clouds_mid, clouds_front;
|
||||
private Fragment currentFragment;
|
||||
|
||||
//Means false by default, as a toggle is initiated in onCreate.
|
||||
boolean ui_visible = true;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
initPreferences();
|
||||
setTheme(ThemeHelper.getBaseTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
final Resources res = getResources();
|
||||
TileManager tileManager = app.getWorld().tileManager;
|
||||
tileManager.setDensity(res);
|
||||
app.setWindowParameters(this);
|
||||
|
||||
setContentView(R.layout.startscreen);
|
||||
|
||||
if (findViewById(R.id.startscreen_fragment_container) != null) {
|
||||
StartScreenActivity_MainMenu mainMenu = new StartScreenActivity_MainMenu();
|
||||
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.startscreen_fragment_container, mainMenu)
|
||||
.commit();
|
||||
currentFragment = mainMenu;
|
||||
|
||||
getSupportFragmentManager().addOnBackStackChangedListener(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
tv = (TextView) findViewById(R.id.startscreen_version);
|
||||
tv.setText('v' + AndorsTrailApplication.CURRENT_VERSION_DISPLAY);
|
||||
|
||||
development_version = (TextView) findViewById(R.id.startscreen_dev_version);
|
||||
if (AndorsTrailApplication.DEVELOPMENT_INCOMPATIBLE_SAVEGAMES) {
|
||||
development_version.setText(R.string.startscreen_incompatible_savegames);
|
||||
development_version.setVisibility(View.VISIBLE);
|
||||
} else if (!AndorsTrailApplication.IS_RELEASE_VERSION) {
|
||||
development_version.setText(R.string.startscreen_non_release_version);
|
||||
development_version.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
clouds_back = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_back);
|
||||
if (clouds_back != null) clouds_back.setCloudsCountAndLayer(40, CloudsAnimatorView.Layer.below);
|
||||
clouds_mid = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_mid);
|
||||
if (clouds_mid != null) clouds_mid.setCloudsCountAndLayer(15, CloudsAnimatorView.Layer.center);
|
||||
clouds_front = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_front);
|
||||
if (clouds_front != null) clouds_front.setCloudsCountAndLayer(8, CloudsAnimatorView.Layer.above);
|
||||
|
||||
View background = findViewById(R.id.title_bg);
|
||||
if (background != null) {
|
||||
background.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
toggleUiVisibility();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (development_version.getVisibility() == View.VISIBLE) {
|
||||
development_version.setText(development_version.getText()
|
||||
// +
|
||||
// "\nMax Heap: " + Runtime.getRuntime().maxMemory() / (1024 * 1024) + "MB"+
|
||||
// "\nUsed Heap: " + Runtime.getRuntime().totalMemory() / (1024 * 1024) + "MB"+
|
||||
// "\nTile size: " + (int) (32 * res.getDisplayMetrics().density)
|
||||
);
|
||||
}
|
||||
|
||||
toggleUiVisibility();
|
||||
|
||||
app.getWorldSetup().startResourceLoader(res);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
if (grantResults.length > 0 && grantResults[0] != PackageManager.PERMISSION_GRANTED) {
|
||||
|
||||
final Dialog d = CustomDialogFactory.createDialog(this,
|
||||
getResources().getString(R.string.dialog_permission_information_title),
|
||||
getResources().getDrawable(android.R.drawable.ic_dialog_info),
|
||||
getResources().getString(R.string.dialog_permission_information),
|
||||
null,
|
||||
true);
|
||||
final Activity activity = this;
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
CustomDialogFactory.setDismissListener(d, new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
StartScreenActivity_MainMenu.checkAndRequestPermissions(activity);
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleUiVisibility() {
|
||||
ui_visible = !ui_visible;
|
||||
int visibility = ui_visible ? View.VISIBLE : View.GONE;
|
||||
if (tv != null) tv.setVisibility(visibility);
|
||||
if (!AndorsTrailApplication.IS_RELEASE_VERSION) {
|
||||
if (development_version != null) development_version.setVisibility(visibility);
|
||||
}
|
||||
if (currentFragment != null) {
|
||||
if (ui_visible) {
|
||||
|
||||
if (!AndorsTrailApplication.IS_RELEASE_VERSION) {
|
||||
development_version.setText(
|
||||
development_version.getText()
|
||||
// +
|
||||
// "\nMax Heap: " + Runtime.getRuntime().maxMemory() / (1024 * 1024) + "MB"+
|
||||
// "\nUsed Heap: " + Runtime.getRuntime().totalMemory() / (1024 * 1024) + "MB"+
|
||||
// "\nTile size: " + (int) (32 * getResources().getDisplayMetrics().density)
|
||||
);
|
||||
}
|
||||
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.show(currentFragment)
|
||||
.commit();
|
||||
} else {
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.hide(currentFragment)
|
||||
.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initPreferences() {
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
AndorsTrailPreferences preferences = app.getPreferences();
|
||||
preferences.read(this);
|
||||
ThemeHelper.changeTheme(preferences.selectedTheme);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
if (hasFocus) {
|
||||
((AnimationDrawable)((ImageView)findViewById(R.id.title_logo)).getDrawable()).start();
|
||||
ImageView iv = (ImageView) findViewById(R.id.ts_foreground);
|
||||
int ivWidth = iv.getWidth();
|
||||
int drawableWidth = iv.getDrawable().getIntrinsicWidth();
|
||||
float ratio = ((float)ivWidth) / ((float)drawableWidth);
|
||||
|
||||
if (clouds_back != null) {
|
||||
clouds_back.setScalingRatio(ratio);
|
||||
}
|
||||
if (clouds_mid != null) {
|
||||
clouds_mid.setScalingRatio(ratio);
|
||||
}
|
||||
if (clouds_front != null) {
|
||||
clouds_front.setScalingRatio(ratio);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
final ImageView iv = (ImageView) findViewById(R.id.ts_foreground);
|
||||
iv.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
float[] point = new float[]{0f,0.25f * iv.getDrawable().getIntrinsicHeight()};
|
||||
iv.getImageMatrix().mapPoints(point);
|
||||
int imgY = (int) (iv.getTop() + point[1]);
|
||||
int screenHeight = getResources().getDisplayMetrics().heightPixels;
|
||||
|
||||
if (clouds_back != null) {
|
||||
clouds_back.setYMax(imgY);
|
||||
}
|
||||
if (clouds_mid != null) {
|
||||
clouds_mid.setYMax(imgY);
|
||||
}
|
||||
if (clouds_front != null) {
|
||||
clouds_front.setYMax(imgY);
|
||||
}
|
||||
iv.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (clouds_back != null)clouds_back.resumeAnimation();
|
||||
if (clouds_mid != null)clouds_mid.resumeAnimation();
|
||||
if (clouds_front != null)clouds_front.resumeAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
if (clouds_back != null)clouds_back.pauseAnimation();
|
||||
if (clouds_mid != null)clouds_mid.pauseAnimation();
|
||||
if (clouds_front != null)clouds_front.pauseAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
|
||||
backPressed();
|
||||
return true;
|
||||
} else {
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
private void backPressed() {
|
||||
if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
|
||||
getSupportFragmentManager().popBackStack();
|
||||
currentFragment = getSupportFragmentManager().findFragmentById(R.id.startscreen_fragment_container);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void onNewGameRequested() {
|
||||
if (findViewById(R.id.startscreen_fragment_container) != null) {
|
||||
StartScreenActivity_NewGame newGameFragment = new StartScreenActivity_NewGame();
|
||||
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.startscreen_fragment_container, newGameFragment)
|
||||
.addToBackStack(null)
|
||||
.commit();
|
||||
|
||||
currentFragment = newGameFragment;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGameCreationCancelled() {
|
||||
backPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackStackChanged() {
|
||||
currentFragment = getSupportFragmentManager().findFragmentById(R.id.startscreen_fragment_container);
|
||||
}
|
||||
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailPreferences;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_MainMenu;
|
||||
import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_MainMenu.OnNewGameRequestedListener;
|
||||
import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_NewGame;
|
||||
import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_NewGame.GameCreationOverListener;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
import com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager.OnBackStackChangedListener;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
public final class StartScreenActivity extends AndorsTrailBaseFragmentActivity implements OnNewGameRequestedListener, GameCreationOverListener, OnBackStackChangedListener {
|
||||
|
||||
private TextView tv;
|
||||
private TextView development_version;
|
||||
private CloudsAnimatorView clouds_back, clouds_mid, clouds_front;
|
||||
private Fragment currentFragment;
|
||||
|
||||
//Means false by default, as a toggle is initiated in onCreate.
|
||||
boolean ui_visible = true;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
initPreferences();
|
||||
setTheme(ThemeHelper.getBaseTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
final Resources res = getResources();
|
||||
TileManager tileManager = app.getWorld().tileManager;
|
||||
tileManager.setDensity(res);
|
||||
app.setWindowParameters(this);
|
||||
|
||||
setContentView(R.layout.startscreen);
|
||||
|
||||
if (findViewById(R.id.startscreen_fragment_container) != null) {
|
||||
StartScreenActivity_MainMenu mainMenu = new StartScreenActivity_MainMenu();
|
||||
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.startscreen_fragment_container, mainMenu)
|
||||
.commit();
|
||||
currentFragment = mainMenu;
|
||||
|
||||
getSupportFragmentManager().addOnBackStackChangedListener(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
tv = (TextView) findViewById(R.id.startscreen_version);
|
||||
tv.setText('v' + AndorsTrailApplication.CURRENT_VERSION_DISPLAY);
|
||||
|
||||
development_version = (TextView) findViewById(R.id.startscreen_dev_version);
|
||||
if (AndorsTrailApplication.DEVELOPMENT_INCOMPATIBLE_SAVEGAMES) {
|
||||
development_version.setText(R.string.startscreen_incompatible_savegames);
|
||||
development_version.setVisibility(View.VISIBLE);
|
||||
} else if (!AndorsTrailApplication.IS_RELEASE_VERSION) {
|
||||
development_version.setText(R.string.startscreen_non_release_version);
|
||||
development_version.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
clouds_back = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_back);
|
||||
if (clouds_back != null) clouds_back.setCloudsCountAndLayer(40, CloudsAnimatorView.Layer.below);
|
||||
clouds_mid = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_mid);
|
||||
if (clouds_mid != null) clouds_mid.setCloudsCountAndLayer(15, CloudsAnimatorView.Layer.center);
|
||||
clouds_front = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator_front);
|
||||
if (clouds_front != null) clouds_front.setCloudsCountAndLayer(8, CloudsAnimatorView.Layer.above);
|
||||
|
||||
View background = findViewById(R.id.title_bg);
|
||||
if (background != null) {
|
||||
background.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
toggleUiVisibility();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (development_version.getVisibility() == View.VISIBLE) {
|
||||
development_version.setText(development_version.getText()
|
||||
// +
|
||||
// "\nMax Heap: " + Runtime.getRuntime().maxMemory() / (1024 * 1024) + "MB"+
|
||||
// "\nUsed Heap: " + Runtime.getRuntime().totalMemory() / (1024 * 1024) + "MB"+
|
||||
// "\nTile size: " + (int) (32 * res.getDisplayMetrics().density)
|
||||
);
|
||||
}
|
||||
|
||||
toggleUiVisibility();
|
||||
|
||||
app.getWorldSetup().startResourceLoader(res);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
if (grantResults.length > 0 && grantResults[0] != PackageManager.PERMISSION_GRANTED) {
|
||||
|
||||
final Dialog d = CustomDialogFactory.createDialog(this,
|
||||
getResources().getString(R.string.dialog_permission_information_title),
|
||||
getResources().getDrawable(android.R.drawable.ic_dialog_info),
|
||||
getResources().getString(R.string.dialog_permission_information),
|
||||
null,
|
||||
true);
|
||||
final Activity activity = this;
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
CustomDialogFactory.setDismissListener(d, new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
StartScreenActivity_MainMenu.checkAndRequestPermissions(activity);
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.show(d);
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleUiVisibility() {
|
||||
ui_visible = !ui_visible;
|
||||
int visibility = ui_visible ? View.VISIBLE : View.GONE;
|
||||
if (tv != null) tv.setVisibility(visibility);
|
||||
if (!AndorsTrailApplication.IS_RELEASE_VERSION) {
|
||||
if (development_version != null) development_version.setVisibility(visibility);
|
||||
}
|
||||
if (currentFragment != null) {
|
||||
if (ui_visible) {
|
||||
|
||||
if (!AndorsTrailApplication.IS_RELEASE_VERSION) {
|
||||
development_version.setText(
|
||||
development_version.getText()
|
||||
// +
|
||||
// "\nMax Heap: " + Runtime.getRuntime().maxMemory() / (1024 * 1024) + "MB"+
|
||||
// "\nUsed Heap: " + Runtime.getRuntime().totalMemory() / (1024 * 1024) + "MB"+
|
||||
// "\nTile size: " + (int) (32 * getResources().getDisplayMetrics().density)
|
||||
);
|
||||
}
|
||||
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.show(currentFragment)
|
||||
.commit();
|
||||
} else {
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.hide(currentFragment)
|
||||
.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initPreferences() {
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
AndorsTrailPreferences preferences = app.getPreferences();
|
||||
preferences.read(this);
|
||||
ThemeHelper.changeTheme(preferences.selectedTheme);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
if (hasFocus) {
|
||||
((AnimationDrawable)((ImageView)findViewById(R.id.title_logo)).getDrawable()).start();
|
||||
ImageView iv = (ImageView) findViewById(R.id.ts_foreground);
|
||||
int ivWidth = iv.getWidth();
|
||||
int drawableWidth = iv.getDrawable().getIntrinsicWidth();
|
||||
float ratio = ((float)ivWidth) / ((float)drawableWidth);
|
||||
|
||||
if (clouds_back != null) {
|
||||
clouds_back.setScalingRatio(ratio);
|
||||
}
|
||||
if (clouds_mid != null) {
|
||||
clouds_mid.setScalingRatio(ratio);
|
||||
}
|
||||
if (clouds_front != null) {
|
||||
clouds_front.setScalingRatio(ratio);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
final ImageView iv = (ImageView) findViewById(R.id.ts_foreground);
|
||||
iv.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
float[] point = new float[]{0f,0.25f * iv.getDrawable().getIntrinsicHeight()};
|
||||
iv.getImageMatrix().mapPoints(point);
|
||||
int imgY = (int) (iv.getTop() + point[1]);
|
||||
int screenHeight = getResources().getDisplayMetrics().heightPixels;
|
||||
|
||||
if (clouds_back != null) {
|
||||
clouds_back.setYMax(imgY);
|
||||
}
|
||||
if (clouds_mid != null) {
|
||||
clouds_mid.setYMax(imgY);
|
||||
}
|
||||
if (clouds_front != null) {
|
||||
clouds_front.setYMax(imgY);
|
||||
}
|
||||
iv.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (clouds_back != null)clouds_back.resumeAnimation();
|
||||
if (clouds_mid != null)clouds_mid.resumeAnimation();
|
||||
if (clouds_front != null)clouds_front.resumeAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
if (clouds_back != null)clouds_back.pauseAnimation();
|
||||
if (clouds_mid != null)clouds_mid.pauseAnimation();
|
||||
if (clouds_front != null)clouds_front.pauseAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
|
||||
backPressed();
|
||||
return true;
|
||||
} else {
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
private void backPressed() {
|
||||
if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
|
||||
getSupportFragmentManager().popBackStack();
|
||||
currentFragment = getSupportFragmentManager().findFragmentById(R.id.startscreen_fragment_container);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void onNewGameRequested() {
|
||||
if (findViewById(R.id.startscreen_fragment_container) != null) {
|
||||
StartScreenActivity_NewGame newGameFragment = new StartScreenActivity_NewGame();
|
||||
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.startscreen_fragment_container, newGameFragment)
|
||||
.addToBackStack(null)
|
||||
.commit();
|
||||
|
||||
currentFragment = newGameFragment;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGameCreationCancelled() {
|
||||
backPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackStackChanged() {
|
||||
currentFragment = getSupportFragmentManager().findFragmentById(R.id.startscreen_fragment_container);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,490 +1,490 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity.fragment;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.AdapterView.OnItemLongClickListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.Dialogs;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.activity.ItemInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.ItemController;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.HeroCollection;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Inventory;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemContainer;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomMenuInflater;
|
||||
import com.gpl.rpg.AndorsTrail.view.ItemContainerAdapter;
|
||||
import com.gpl.rpg.AndorsTrail.view.SpinnerEmulator;
|
||||
|
||||
public final class HeroinfoActivity_Inventory extends Fragment implements CustomMenuInflater.MenuItemSelectedListener {
|
||||
|
||||
private static final int INTENTREQUEST_ITEMINFO = 3;
|
||||
private static final int INTENTREQUEST_BULKSELECT_DROP = 11;
|
||||
|
||||
private WorldContext world;
|
||||
private ControllerContext controllers;
|
||||
private TileCollection wornTiles;
|
||||
|
||||
private Player player;
|
||||
private ListView inventoryList;
|
||||
private ItemContainerAdapter inventoryListAdapter;
|
||||
private ItemContainerAdapter inventoryWeaponsListAdapter;
|
||||
private ItemContainerAdapter inventoryArmorListAdapter;
|
||||
private ItemContainerAdapter inventoryJewelryListAdapter;
|
||||
private ItemContainerAdapter inventoryPotionListAdapter;
|
||||
private ItemContainerAdapter inventoryFoodListAdapter;
|
||||
private ItemContainerAdapter inventoryQuestListAdapter;
|
||||
private ItemContainerAdapter inventoryOtherListAdapter;
|
||||
|
||||
private TextView heroinfo_stats_gold;
|
||||
private TextView heroinfo_stats_attack;
|
||||
private TextView heroinfo_stats_defense;
|
||||
|
||||
private ItemType lastSelectedItem; // Workaround android bug #7139
|
||||
|
||||
private final ImageView[] wornItemImage = new ImageView[Inventory.WearSlot.values().length];
|
||||
private final int[] defaultWornItemImageResourceIDs = new int[Inventory.WearSlot.values().length];
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this.getActivity());
|
||||
if (!app.isInitialized()) return;
|
||||
this.world = app.getWorld();
|
||||
this.controllers = app.getControllerContext();
|
||||
this.player = world.model.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
final View v = inflater.inflate(R.layout.heroinfo_inventory, container, false);
|
||||
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this.getActivity());
|
||||
if (!app.isInitialized()) return v;
|
||||
|
||||
inventoryList = (ListView) v.findViewById(R.id.inventorylist_root);
|
||||
ImageView heroicon = (ImageView) v.findViewById(R.id.heroinfo_inventory_heroicon);
|
||||
heroinfo_stats_gold = (TextView) v.findViewById(R.id.heroinfo_stats_gold);
|
||||
heroinfo_stats_attack = (TextView) v.findViewById(R.id.heroinfo_stats_attack);
|
||||
heroinfo_stats_defense = (TextView) v.findViewById(R.id.heroinfo_stats_defense);
|
||||
|
||||
registerForContextMenu(inventoryList);
|
||||
inventoryList.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||
// Move this code to separate function? -- Done
|
||||
ItemType itemType = getSelectedItemType(position);
|
||||
showInventoryItemInfo(itemType.id);
|
||||
}
|
||||
});
|
||||
inventoryList.setOnItemLongClickListener(new OnItemLongClickListener() {
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
showContextMenuForItem(getSelectedItemType(position));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
new SpinnerEmulator(v, R.id.inventorylist_category_filters_button, R.array.inventorylist_category_filters, R.string.heroinfo_inventory_categories) {
|
||||
@Override
|
||||
public void setValue(int value) {
|
||||
world.model.uiSelections.selectedInventoryCategory = value;
|
||||
}
|
||||
@Override
|
||||
public void selectionChanged(int value) {
|
||||
reloadShownCategory(value);
|
||||
}
|
||||
@Override
|
||||
public int getValue() {
|
||||
return world.model.uiSelections.selectedInventoryCategory;
|
||||
}
|
||||
};
|
||||
new SpinnerEmulator(v, R.id.inventorylist_sort_filters_button, R.array.inventorylist_sort_filters, R.string.heroinfo_inventory_sort) {
|
||||
@Override
|
||||
public void setValue(int value) {
|
||||
world.model.uiSelections.selectedInventorySort = value;
|
||||
}
|
||||
@Override
|
||||
public void selectionChanged(int value) {
|
||||
reloadShownSort(player.inventory);
|
||||
}
|
||||
@Override
|
||||
public int getValue() {
|
||||
return world.model.uiSelections.selectedInventorySort;
|
||||
}
|
||||
};
|
||||
|
||||
ItemContainer inv = player.inventory;
|
||||
wornTiles = world.tileManager.loadTilesFor(player.inventory, getResources());
|
||||
inventoryListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, inv, player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryListAdapter);
|
||||
|
||||
|
||||
heroicon.setImageResource(HeroCollection.getHeroLargeSprite(player.iconID));
|
||||
|
||||
setWearSlot(v, Inventory.WearSlot.weapon, R.id.heroinfo_worn_weapon, R.drawable.equip_weapon);
|
||||
setWearSlot(v, Inventory.WearSlot.shield, R.id.heroinfo_worn_shield, R.drawable.equip_shield);
|
||||
setWearSlot(v, Inventory.WearSlot.head, R.id.heroinfo_worn_head, R.drawable.equip_head);
|
||||
setWearSlot(v, Inventory.WearSlot.body, R.id.heroinfo_worn_body, R.drawable.equip_body);
|
||||
setWearSlot(v, Inventory.WearSlot.feet, R.id.heroinfo_worn_feet, R.drawable.equip_feet);
|
||||
setWearSlot(v, Inventory.WearSlot.neck, R.id.heroinfo_worn_neck, R.drawable.equip_neck);
|
||||
setWearSlot(v, Inventory.WearSlot.hand, R.id.heroinfo_worn_hand, R.drawable.equip_hand);
|
||||
setWearSlot(v, Inventory.WearSlot.leftring, R.id.heroinfo_worn_ringleft, R.drawable.equip_ring);
|
||||
setWearSlot(v, Inventory.WearSlot.rightring, R.id.heroinfo_worn_ringright, R.drawable.equip_ring);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
update();
|
||||
}
|
||||
|
||||
private void setWearSlot(final View v, final Inventory.WearSlot inventorySlot, int viewId, int resourceId) {
|
||||
final ImageView imageView = (ImageView) v.findViewById(viewId);
|
||||
wornItemImage[inventorySlot.ordinal()] = imageView;
|
||||
defaultWornItemImageResourceIDs[inventorySlot.ordinal()] = resourceId;
|
||||
imageView.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (player.inventory.isEmptySlot(inventorySlot)) return;
|
||||
imageView.setClickable(false); // Will be enabled again on update()
|
||||
showEquippedItemInfo(player.inventory.getItemTypeInWearSlot(inventorySlot), inventorySlot);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
switch (requestCode) {
|
||||
case INTENTREQUEST_ITEMINFO:
|
||||
if (resultCode == ItemInfoActivity.RESULT_MORE_ACTIONS) {
|
||||
showContextMenuForItem( world.itemTypes.getItemType(data.getExtras().getString("itemTypeID")));
|
||||
break;
|
||||
}
|
||||
if (resultCode != Activity.RESULT_OK) break;
|
||||
|
||||
ItemType itemType = world.itemTypes.getItemType(data.getExtras().getString("itemTypeID"));
|
||||
ItemInfoActivity.ItemInfoAction actionType = ItemInfoActivity.ItemInfoAction.valueOf(data.getExtras().getString("actionType"));
|
||||
if (actionType == ItemInfoActivity.ItemInfoAction.unequip) {
|
||||
Inventory.WearSlot slot = Inventory.WearSlot.valueOf(data.getExtras().getString("inventorySlot"));
|
||||
controllers.itemController.unequipSlot(itemType, slot);
|
||||
} else if (actionType == ItemInfoActivity.ItemInfoAction.equip) {
|
||||
Inventory.WearSlot slot = suggestInventorySlot(itemType);
|
||||
controllers.itemController.equipItem(itemType, slot);
|
||||
} else if (actionType == ItemInfoActivity.ItemInfoAction.use) {
|
||||
controllers.itemController.useItem(itemType);
|
||||
}
|
||||
break;
|
||||
case INTENTREQUEST_BULKSELECT_DROP:
|
||||
if (resultCode != Activity.RESULT_OK) break;
|
||||
|
||||
int quantity = data.getExtras().getInt("selectedAmount");
|
||||
String itemTypeID = data.getExtras().getString("itemTypeID");
|
||||
dropItem(itemTypeID, quantity);
|
||||
break;
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
private Inventory.WearSlot suggestInventorySlot(ItemType itemType) {
|
||||
Inventory.WearSlot slot = itemType.category.inventorySlot;
|
||||
if (player.inventory.isEmptySlot(slot)) return slot;
|
||||
|
||||
if (slot == Inventory.WearSlot.leftring) return Inventory.WearSlot.rightring;
|
||||
if (itemType.isOffhandCapableWeapon()) {
|
||||
ItemType mainWeapon = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.weapon);
|
||||
if (mainWeapon != null && mainWeapon.isTwohandWeapon()) return slot;
|
||||
else if (player.inventory.isEmptySlot(Inventory.WearSlot.shield)) return Inventory.WearSlot.shield;
|
||||
}
|
||||
return slot;
|
||||
}
|
||||
|
||||
private void dropItem(String itemTypeID, int quantity) {
|
||||
ItemType itemType = world.itemTypes.getItemType(itemTypeID);
|
||||
controllers.itemController.dropItem(itemType, quantity);
|
||||
}
|
||||
|
||||
private void update() {
|
||||
updateTraits();
|
||||
updateWorn();
|
||||
updateItemList();
|
||||
}
|
||||
|
||||
private void updateTraits() {
|
||||
heroinfo_stats_gold.setText(getResources().getString(R.string.heroinfo_gold, player.inventory.gold));
|
||||
|
||||
StringBuilder sb = new StringBuilder(10);
|
||||
ItemController.describeAttackEffect(
|
||||
player.getAttackChance(),
|
||||
player.getDamagePotential().current,
|
||||
player.getDamagePotential().max,
|
||||
player.getCriticalSkill(),
|
||||
player.getCriticalMultiplier(),
|
||||
sb);
|
||||
heroinfo_stats_attack.setText(sb.toString());
|
||||
|
||||
sb = new StringBuilder(10);
|
||||
ItemController.describeBlockEffect(player.getBlockChance(), player.getDamageResistance(), sb);
|
||||
heroinfo_stats_defense.setText(sb.toString());
|
||||
}
|
||||
|
||||
private void updateWorn() {
|
||||
for(Inventory.WearSlot slot : Inventory.WearSlot.values()) {
|
||||
updateWornImage(wornItemImage[slot.ordinal()], defaultWornItemImageResourceIDs[slot.ordinal()], player.inventory.getItemTypeInWearSlot(slot));
|
||||
}
|
||||
}
|
||||
|
||||
private void updateWornImage(ImageView imageView, int resourceIDEmptyImage, ItemType type) {
|
||||
if (type != null) {
|
||||
world.tileManager.setImageViewTile(getResources(), imageView, type, wornTiles);
|
||||
} else {
|
||||
imageView.setImageResource(resourceIDEmptyImage);
|
||||
}
|
||||
imageView.setClickable(true);
|
||||
}
|
||||
|
||||
private void updateItemList() {
|
||||
int currentScreen = world.model.uiSelections.selectedInventoryCategory;
|
||||
if (currentScreen == 0)
|
||||
inventoryListAdapter.notifyDataSetChanged();
|
||||
else
|
||||
reloadShownCategory(world.model.uiSelections.selectedInventoryCategory);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {}
|
||||
// ItemType type = getSelectedItemType((AdapterContextMenuInfo) menuInfo);
|
||||
|
||||
|
||||
public void showContextMenuForItem(ItemType type) {
|
||||
MenuInflater inflater = getActivity().getMenuInflater();
|
||||
Menu menu = CustomMenuInflater.newMenuInstance(getActivity());
|
||||
inflater.inflate(R.menu.inventoryitem, menu);
|
||||
if (type.isUsable()){
|
||||
menu.findItem(R.id.inv_menu_use).setVisible(true);
|
||||
menu.findItem(R.id.inv_menu_assign).setVisible(true);
|
||||
}
|
||||
if (type.isEquippable()) {
|
||||
menu.findItem(R.id.inv_menu_equip).setVisible(true);
|
||||
if (type.isOffhandCapableWeapon()) menu.findItem(R.id.inv_menu_equip_offhand).setVisible(true);
|
||||
else if (type.category.inventorySlot == Inventory.WearSlot.leftring) menu.findItem(R.id.inv_menu_equip_offhand).setVisible(true);
|
||||
}
|
||||
lastSelectedItem = null;
|
||||
CustomMenuInflater.showMenuInDialog(getActivity(), menu, world.tileManager.getDrawableForItem(getResources(), type.iconID, world.tileManager.loadTilesFor(Arrays.asList(new Integer[] { type.iconID}), getResources())), type.getName(player), type, this);
|
||||
}
|
||||
|
||||
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) { //Jewelry items
|
||||
return inventoryJewelryListAdapter.getItem(position).itemType;
|
||||
} else if (v == 4) { //Potion items
|
||||
return inventoryPotionListAdapter.getItem(position).itemType;
|
||||
} else if (v == 5) { //Food items
|
||||
return inventoryFoodListAdapter.getItem(position).itemType;
|
||||
} else if (v == 6) { //Quest items
|
||||
return inventoryQuestListAdapter.getItem(position).itemType;
|
||||
} else if (v == 7) { //Other items
|
||||
return inventoryOtherListAdapter.getItem(position).itemType;
|
||||
}
|
||||
|
||||
// Better than crashing...
|
||||
return inventoryListAdapter.getItem(position).itemType;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private ItemType getSelectedItemType(AdapterContextMenuInfo info) {
|
||||
return getSelectedItemType(info.position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMenuItemSelected(MenuItem item, Object data) {
|
||||
ItemType itemType = (ItemType) data;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.inv_menu_info:
|
||||
showInventoryItemInfo(itemType);
|
||||
//context.mapController.itemInfo(this, getSelectedItemType(info));
|
||||
break;
|
||||
case R.id.inv_menu_drop:
|
||||
String itemTypeID = itemType.id;
|
||||
int quantity = player.inventory.getItemQuantity(itemTypeID);
|
||||
if (quantity > 1) {
|
||||
Intent intent = Dialogs.getIntentForBulkDroppingInterface(getActivity(), itemTypeID, quantity);
|
||||
startActivityForResult(intent, INTENTREQUEST_BULKSELECT_DROP);
|
||||
} else {
|
||||
dropItem(itemTypeID, quantity);
|
||||
}
|
||||
break;
|
||||
case R.id.inv_menu_equip:
|
||||
controllers.itemController.equipItem(itemType, itemType.category.inventorySlot);
|
||||
break;
|
||||
case R.id.inv_menu_equip_offhand:
|
||||
if (itemType.category.inventorySlot == Inventory.WearSlot.weapon) {
|
||||
controllers.itemController.equipItem(itemType, Inventory.WearSlot.shield);
|
||||
} else if (itemType.category.inventorySlot == Inventory.WearSlot.leftring) {
|
||||
controllers.itemController.equipItem(itemType, Inventory.WearSlot.rightring);
|
||||
}
|
||||
break;
|
||||
/*case R.id.inv_menu_unequip:
|
||||
context.mapController.unequipItem(this, getSelectedItemType(info));
|
||||
break;*/
|
||||
case R.id.inv_menu_use:
|
||||
controllers.itemController.useItem(itemType);
|
||||
break;
|
||||
case R.id.inv_menu_assign:
|
||||
//lastSelectedItem = itemType;
|
||||
break;
|
||||
case R.id.inv_assign_slot1:
|
||||
controllers.itemController.setQuickItem(itemType, 0);
|
||||
break;
|
||||
case R.id.inv_assign_slot2:
|
||||
controllers.itemController.setQuickItem(itemType, 1);
|
||||
break;
|
||||
case R.id.inv_assign_slot3:
|
||||
controllers.itemController.setQuickItem(itemType, 2);
|
||||
break;
|
||||
case R.id.inv_menu_movetop:
|
||||
player.inventory.sortToTop(itemType.id);
|
||||
break;
|
||||
case R.id.inv_menu_movebottom:
|
||||
player.inventory.sortToBottom(itemType.id);
|
||||
break;
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
private void showEquippedItemInfo(ItemType itemType, Inventory.WearSlot inventorySlot) {
|
||||
String text;
|
||||
boolean enabled = true;
|
||||
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
int ap = world.model.player.getReequipCost();
|
||||
text = getResources().getString(R.string.iteminfo_action_unequip_ap, ap);
|
||||
if (ap > 0) {
|
||||
enabled = world.model.player.hasAPs(ap);
|
||||
}
|
||||
} else {
|
||||
text = getResources().getString(R.string.iteminfo_action_unequip);
|
||||
}
|
||||
Intent intent = Dialogs.getIntentForItemInfo(getActivity(), itemType.id, ItemInfoActivity.ItemInfoAction.unequip, text, enabled, inventorySlot);
|
||||
startActivityForResult(intent, INTENTREQUEST_ITEMINFO);
|
||||
}
|
||||
private void showInventoryItemInfo(String itemTypeID) {
|
||||
showInventoryItemInfo(world.itemTypes.getItemType(itemTypeID));
|
||||
}
|
||||
private void showInventoryItemInfo(ItemType itemType) {
|
||||
String text = "";
|
||||
int ap = 0;
|
||||
boolean enabled = true;
|
||||
ItemInfoActivity.ItemInfoAction action = ItemInfoActivity.ItemInfoAction.none;
|
||||
final boolean isInCombat = world.model.uiSelections.isInCombat;
|
||||
if (itemType.isEquippable()) {
|
||||
if (isInCombat) {
|
||||
ap = world.model.player.getReequipCost();
|
||||
text = getResources().getString(R.string.iteminfo_action_equip_ap, ap);
|
||||
} else {
|
||||
text = getResources().getString(R.string.iteminfo_action_equip);
|
||||
}
|
||||
action = ItemInfoActivity.ItemInfoAction.equip;
|
||||
} else if (itemType.isUsable()) {
|
||||
if (isInCombat) {
|
||||
ap = world.model.player.getUseItemCost();
|
||||
text = getResources().getString(R.string.iteminfo_action_use_ap, ap);
|
||||
} else {
|
||||
text = getResources().getString(R.string.iteminfo_action_use);
|
||||
}
|
||||
action = ItemInfoActivity.ItemInfoAction.use;
|
||||
}
|
||||
if (isInCombat && ap > 0) {
|
||||
enabled = world.model.player.hasAPs(ap);
|
||||
}
|
||||
|
||||
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) { //Jewelry items
|
||||
inventoryJewelryListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildJewelryItems(), player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryJewelryListAdapter);
|
||||
inventoryJewelryListAdapter.notifyDataSetChanged();
|
||||
} else if (v == 4) { //Potion items
|
||||
inventoryPotionListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildPotionItems(), player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryPotionListAdapter);
|
||||
inventoryPotionListAdapter.notifyDataSetChanged();
|
||||
} else if (v == 5) { //Food items
|
||||
inventoryFoodListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildFoodItems(), player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryFoodListAdapter);
|
||||
inventoryFoodListAdapter.notifyDataSetChanged();
|
||||
} else if (v == 6) { //Quest items
|
||||
inventoryQuestListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildQuestItems(), player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryQuestListAdapter);
|
||||
inventoryQuestListAdapter.notifyDataSetChanged();
|
||||
} else if (v == 7) { //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();
|
||||
}
|
||||
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.activity.fragment;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.AdapterView.OnItemLongClickListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.Dialogs;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.activity.ItemInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.ItemController;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.HeroCollection;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Inventory;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemContainer;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomMenuInflater;
|
||||
import com.gpl.rpg.AndorsTrail.view.ItemContainerAdapter;
|
||||
import com.gpl.rpg.AndorsTrail.view.SpinnerEmulator;
|
||||
|
||||
public final class HeroinfoActivity_Inventory extends Fragment implements CustomMenuInflater.MenuItemSelectedListener {
|
||||
|
||||
private static final int INTENTREQUEST_ITEMINFO = 3;
|
||||
private static final int INTENTREQUEST_BULKSELECT_DROP = 11;
|
||||
|
||||
private WorldContext world;
|
||||
private ControllerContext controllers;
|
||||
private TileCollection wornTiles;
|
||||
|
||||
private Player player;
|
||||
private ListView inventoryList;
|
||||
private ItemContainerAdapter inventoryListAdapter;
|
||||
private ItemContainerAdapter inventoryWeaponsListAdapter;
|
||||
private ItemContainerAdapter inventoryArmorListAdapter;
|
||||
private ItemContainerAdapter inventoryJewelryListAdapter;
|
||||
private ItemContainerAdapter inventoryPotionListAdapter;
|
||||
private ItemContainerAdapter inventoryFoodListAdapter;
|
||||
private ItemContainerAdapter inventoryQuestListAdapter;
|
||||
private ItemContainerAdapter inventoryOtherListAdapter;
|
||||
|
||||
private TextView heroinfo_stats_gold;
|
||||
private TextView heroinfo_stats_attack;
|
||||
private TextView heroinfo_stats_defense;
|
||||
|
||||
private ItemType lastSelectedItem; // Workaround android bug #7139
|
||||
|
||||
private final ImageView[] wornItemImage = new ImageView[Inventory.WearSlot.values().length];
|
||||
private final int[] defaultWornItemImageResourceIDs = new int[Inventory.WearSlot.values().length];
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this.getActivity());
|
||||
if (!app.isInitialized()) return;
|
||||
this.world = app.getWorld();
|
||||
this.controllers = app.getControllerContext();
|
||||
this.player = world.model.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
final View v = inflater.inflate(R.layout.heroinfo_inventory, container, false);
|
||||
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this.getActivity());
|
||||
if (!app.isInitialized()) return v;
|
||||
|
||||
inventoryList = (ListView) v.findViewById(R.id.inventorylist_root);
|
||||
ImageView heroicon = (ImageView) v.findViewById(R.id.heroinfo_inventory_heroicon);
|
||||
heroinfo_stats_gold = (TextView) v.findViewById(R.id.heroinfo_stats_gold);
|
||||
heroinfo_stats_attack = (TextView) v.findViewById(R.id.heroinfo_stats_attack);
|
||||
heroinfo_stats_defense = (TextView) v.findViewById(R.id.heroinfo_stats_defense);
|
||||
|
||||
registerForContextMenu(inventoryList);
|
||||
inventoryList.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||
// Move this code to separate function? -- Done
|
||||
ItemType itemType = getSelectedItemType(position);
|
||||
showInventoryItemInfo(itemType.id);
|
||||
}
|
||||
});
|
||||
inventoryList.setOnItemLongClickListener(new OnItemLongClickListener() {
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
showContextMenuForItem(getSelectedItemType(position));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
new SpinnerEmulator(v, R.id.inventorylist_category_filters_button, R.array.inventorylist_category_filters, R.string.heroinfo_inventory_categories) {
|
||||
@Override
|
||||
public void setValue(int value) {
|
||||
world.model.uiSelections.selectedInventoryCategory = value;
|
||||
}
|
||||
@Override
|
||||
public void selectionChanged(int value) {
|
||||
reloadShownCategory(value);
|
||||
}
|
||||
@Override
|
||||
public int getValue() {
|
||||
return world.model.uiSelections.selectedInventoryCategory;
|
||||
}
|
||||
};
|
||||
new SpinnerEmulator(v, R.id.inventorylist_sort_filters_button, R.array.inventorylist_sort_filters, R.string.heroinfo_inventory_sort) {
|
||||
@Override
|
||||
public void setValue(int value) {
|
||||
world.model.uiSelections.selectedInventorySort = value;
|
||||
}
|
||||
@Override
|
||||
public void selectionChanged(int value) {
|
||||
reloadShownSort(player.inventory);
|
||||
}
|
||||
@Override
|
||||
public int getValue() {
|
||||
return world.model.uiSelections.selectedInventorySort;
|
||||
}
|
||||
};
|
||||
|
||||
ItemContainer inv = player.inventory;
|
||||
wornTiles = world.tileManager.loadTilesFor(player.inventory, getResources());
|
||||
inventoryListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, inv, player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryListAdapter);
|
||||
|
||||
|
||||
heroicon.setImageResource(HeroCollection.getHeroLargeSprite(player.iconID));
|
||||
|
||||
setWearSlot(v, Inventory.WearSlot.weapon, R.id.heroinfo_worn_weapon, R.drawable.equip_weapon);
|
||||
setWearSlot(v, Inventory.WearSlot.shield, R.id.heroinfo_worn_shield, R.drawable.equip_shield);
|
||||
setWearSlot(v, Inventory.WearSlot.head, R.id.heroinfo_worn_head, R.drawable.equip_head);
|
||||
setWearSlot(v, Inventory.WearSlot.body, R.id.heroinfo_worn_body, R.drawable.equip_body);
|
||||
setWearSlot(v, Inventory.WearSlot.feet, R.id.heroinfo_worn_feet, R.drawable.equip_feet);
|
||||
setWearSlot(v, Inventory.WearSlot.neck, R.id.heroinfo_worn_neck, R.drawable.equip_neck);
|
||||
setWearSlot(v, Inventory.WearSlot.hand, R.id.heroinfo_worn_hand, R.drawable.equip_hand);
|
||||
setWearSlot(v, Inventory.WearSlot.leftring, R.id.heroinfo_worn_ringleft, R.drawable.equip_ring);
|
||||
setWearSlot(v, Inventory.WearSlot.rightring, R.id.heroinfo_worn_ringright, R.drawable.equip_ring);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
update();
|
||||
}
|
||||
|
||||
private void setWearSlot(final View v, final Inventory.WearSlot inventorySlot, int viewId, int resourceId) {
|
||||
final ImageView imageView = (ImageView) v.findViewById(viewId);
|
||||
wornItemImage[inventorySlot.ordinal()] = imageView;
|
||||
defaultWornItemImageResourceIDs[inventorySlot.ordinal()] = resourceId;
|
||||
imageView.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (player.inventory.isEmptySlot(inventorySlot)) return;
|
||||
imageView.setClickable(false); // Will be enabled again on update()
|
||||
showEquippedItemInfo(player.inventory.getItemTypeInWearSlot(inventorySlot), inventorySlot);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
switch (requestCode) {
|
||||
case INTENTREQUEST_ITEMINFO:
|
||||
if (resultCode == ItemInfoActivity.RESULT_MORE_ACTIONS) {
|
||||
showContextMenuForItem( world.itemTypes.getItemType(data.getExtras().getString("itemTypeID")));
|
||||
break;
|
||||
}
|
||||
if (resultCode != Activity.RESULT_OK) break;
|
||||
|
||||
ItemType itemType = world.itemTypes.getItemType(data.getExtras().getString("itemTypeID"));
|
||||
ItemInfoActivity.ItemInfoAction actionType = ItemInfoActivity.ItemInfoAction.valueOf(data.getExtras().getString("actionType"));
|
||||
if (actionType == ItemInfoActivity.ItemInfoAction.unequip) {
|
||||
Inventory.WearSlot slot = Inventory.WearSlot.valueOf(data.getExtras().getString("inventorySlot"));
|
||||
controllers.itemController.unequipSlot(itemType, slot);
|
||||
} else if (actionType == ItemInfoActivity.ItemInfoAction.equip) {
|
||||
Inventory.WearSlot slot = suggestInventorySlot(itemType);
|
||||
controllers.itemController.equipItem(itemType, slot);
|
||||
} else if (actionType == ItemInfoActivity.ItemInfoAction.use) {
|
||||
controllers.itemController.useItem(itemType);
|
||||
}
|
||||
break;
|
||||
case INTENTREQUEST_BULKSELECT_DROP:
|
||||
if (resultCode != Activity.RESULT_OK) break;
|
||||
|
||||
int quantity = data.getExtras().getInt("selectedAmount");
|
||||
String itemTypeID = data.getExtras().getString("itemTypeID");
|
||||
dropItem(itemTypeID, quantity);
|
||||
break;
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
private Inventory.WearSlot suggestInventorySlot(ItemType itemType) {
|
||||
Inventory.WearSlot slot = itemType.category.inventorySlot;
|
||||
if (player.inventory.isEmptySlot(slot)) return slot;
|
||||
|
||||
if (slot == Inventory.WearSlot.leftring) return Inventory.WearSlot.rightring;
|
||||
if (itemType.isOffhandCapableWeapon()) {
|
||||
ItemType mainWeapon = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.weapon);
|
||||
if (mainWeapon != null && mainWeapon.isTwohandWeapon()) return slot;
|
||||
else if (player.inventory.isEmptySlot(Inventory.WearSlot.shield)) return Inventory.WearSlot.shield;
|
||||
}
|
||||
return slot;
|
||||
}
|
||||
|
||||
private void dropItem(String itemTypeID, int quantity) {
|
||||
ItemType itemType = world.itemTypes.getItemType(itemTypeID);
|
||||
controllers.itemController.dropItem(itemType, quantity);
|
||||
}
|
||||
|
||||
private void update() {
|
||||
updateTraits();
|
||||
updateWorn();
|
||||
updateItemList();
|
||||
}
|
||||
|
||||
private void updateTraits() {
|
||||
heroinfo_stats_gold.setText(getResources().getString(R.string.heroinfo_gold, player.inventory.gold));
|
||||
|
||||
StringBuilder sb = new StringBuilder(10);
|
||||
ItemController.describeAttackEffect(
|
||||
player.getAttackChance(),
|
||||
player.getDamagePotential().current,
|
||||
player.getDamagePotential().max,
|
||||
player.getCriticalSkill(),
|
||||
player.getCriticalMultiplier(),
|
||||
sb);
|
||||
heroinfo_stats_attack.setText(sb.toString());
|
||||
|
||||
sb = new StringBuilder(10);
|
||||
ItemController.describeBlockEffect(player.getBlockChance(), player.getDamageResistance(), sb);
|
||||
heroinfo_stats_defense.setText(sb.toString());
|
||||
}
|
||||
|
||||
private void updateWorn() {
|
||||
for(Inventory.WearSlot slot : Inventory.WearSlot.values()) {
|
||||
updateWornImage(wornItemImage[slot.ordinal()], defaultWornItemImageResourceIDs[slot.ordinal()], player.inventory.getItemTypeInWearSlot(slot));
|
||||
}
|
||||
}
|
||||
|
||||
private void updateWornImage(ImageView imageView, int resourceIDEmptyImage, ItemType type) {
|
||||
if (type != null) {
|
||||
world.tileManager.setImageViewTile(getResources(), imageView, type, wornTiles);
|
||||
} else {
|
||||
imageView.setImageResource(resourceIDEmptyImage);
|
||||
}
|
||||
imageView.setClickable(true);
|
||||
}
|
||||
|
||||
private void updateItemList() {
|
||||
int currentScreen = world.model.uiSelections.selectedInventoryCategory;
|
||||
if (currentScreen == 0)
|
||||
inventoryListAdapter.notifyDataSetChanged();
|
||||
else
|
||||
reloadShownCategory(world.model.uiSelections.selectedInventoryCategory);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {}
|
||||
// ItemType type = getSelectedItemType((AdapterContextMenuInfo) menuInfo);
|
||||
|
||||
|
||||
public void showContextMenuForItem(ItemType type) {
|
||||
MenuInflater inflater = getActivity().getMenuInflater();
|
||||
Menu menu = CustomMenuInflater.newMenuInstance(getActivity());
|
||||
inflater.inflate(R.menu.inventoryitem, menu);
|
||||
if (type.isUsable()){
|
||||
menu.findItem(R.id.inv_menu_use).setVisible(true);
|
||||
menu.findItem(R.id.inv_menu_assign).setVisible(true);
|
||||
}
|
||||
if (type.isEquippable()) {
|
||||
menu.findItem(R.id.inv_menu_equip).setVisible(true);
|
||||
if (type.isOffhandCapableWeapon()) menu.findItem(R.id.inv_menu_equip_offhand).setVisible(true);
|
||||
else if (type.category.inventorySlot == Inventory.WearSlot.leftring) menu.findItem(R.id.inv_menu_equip_offhand).setVisible(true);
|
||||
}
|
||||
lastSelectedItem = null;
|
||||
CustomMenuInflater.showMenuInDialog(getActivity(), menu, world.tileManager.getDrawableForItem(getResources(), type.iconID, world.tileManager.loadTilesFor(Arrays.asList(new Integer[] { type.iconID}), getResources())), type.getName(player), type, this);
|
||||
}
|
||||
|
||||
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) { //Jewelry items
|
||||
return inventoryJewelryListAdapter.getItem(position).itemType;
|
||||
} else if (v == 4) { //Potion items
|
||||
return inventoryPotionListAdapter.getItem(position).itemType;
|
||||
} else if (v == 5) { //Food items
|
||||
return inventoryFoodListAdapter.getItem(position).itemType;
|
||||
} else if (v == 6) { //Quest items
|
||||
return inventoryQuestListAdapter.getItem(position).itemType;
|
||||
} else if (v == 7) { //Other items
|
||||
return inventoryOtherListAdapter.getItem(position).itemType;
|
||||
}
|
||||
|
||||
// Better than crashing...
|
||||
return inventoryListAdapter.getItem(position).itemType;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private ItemType getSelectedItemType(AdapterContextMenuInfo info) {
|
||||
return getSelectedItemType(info.position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMenuItemSelected(MenuItem item, Object data) {
|
||||
ItemType itemType = (ItemType) data;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.inv_menu_info:
|
||||
showInventoryItemInfo(itemType);
|
||||
//context.mapController.itemInfo(this, getSelectedItemType(info));
|
||||
break;
|
||||
case R.id.inv_menu_drop:
|
||||
String itemTypeID = itemType.id;
|
||||
int quantity = player.inventory.getItemQuantity(itemTypeID);
|
||||
if (quantity > 1) {
|
||||
Intent intent = Dialogs.getIntentForBulkDroppingInterface(getActivity(), itemTypeID, quantity);
|
||||
startActivityForResult(intent, INTENTREQUEST_BULKSELECT_DROP);
|
||||
} else {
|
||||
dropItem(itemTypeID, quantity);
|
||||
}
|
||||
break;
|
||||
case R.id.inv_menu_equip:
|
||||
controllers.itemController.equipItem(itemType, itemType.category.inventorySlot);
|
||||
break;
|
||||
case R.id.inv_menu_equip_offhand:
|
||||
if (itemType.category.inventorySlot == Inventory.WearSlot.weapon) {
|
||||
controllers.itemController.equipItem(itemType, Inventory.WearSlot.shield);
|
||||
} else if (itemType.category.inventorySlot == Inventory.WearSlot.leftring) {
|
||||
controllers.itemController.equipItem(itemType, Inventory.WearSlot.rightring);
|
||||
}
|
||||
break;
|
||||
/*case R.id.inv_menu_unequip:
|
||||
context.mapController.unequipItem(this, getSelectedItemType(info));
|
||||
break;*/
|
||||
case R.id.inv_menu_use:
|
||||
controllers.itemController.useItem(itemType);
|
||||
break;
|
||||
case R.id.inv_menu_assign:
|
||||
//lastSelectedItem = itemType;
|
||||
break;
|
||||
case R.id.inv_assign_slot1:
|
||||
controllers.itemController.setQuickItem(itemType, 0);
|
||||
break;
|
||||
case R.id.inv_assign_slot2:
|
||||
controllers.itemController.setQuickItem(itemType, 1);
|
||||
break;
|
||||
case R.id.inv_assign_slot3:
|
||||
controllers.itemController.setQuickItem(itemType, 2);
|
||||
break;
|
||||
case R.id.inv_menu_movetop:
|
||||
player.inventory.sortToTop(itemType.id);
|
||||
break;
|
||||
case R.id.inv_menu_movebottom:
|
||||
player.inventory.sortToBottom(itemType.id);
|
||||
break;
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
private void showEquippedItemInfo(ItemType itemType, Inventory.WearSlot inventorySlot) {
|
||||
String text;
|
||||
boolean enabled = true;
|
||||
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
int ap = world.model.player.getReequipCost();
|
||||
text = getResources().getString(R.string.iteminfo_action_unequip_ap, ap);
|
||||
if (ap > 0) {
|
||||
enabled = world.model.player.hasAPs(ap);
|
||||
}
|
||||
} else {
|
||||
text = getResources().getString(R.string.iteminfo_action_unequip);
|
||||
}
|
||||
Intent intent = Dialogs.getIntentForItemInfo(getActivity(), itemType.id, ItemInfoActivity.ItemInfoAction.unequip, text, enabled, inventorySlot);
|
||||
startActivityForResult(intent, INTENTREQUEST_ITEMINFO);
|
||||
}
|
||||
private void showInventoryItemInfo(String itemTypeID) {
|
||||
showInventoryItemInfo(world.itemTypes.getItemType(itemTypeID));
|
||||
}
|
||||
private void showInventoryItemInfo(ItemType itemType) {
|
||||
String text = "";
|
||||
int ap = 0;
|
||||
boolean enabled = true;
|
||||
ItemInfoActivity.ItemInfoAction action = ItemInfoActivity.ItemInfoAction.none;
|
||||
final boolean isInCombat = world.model.uiSelections.isInCombat;
|
||||
if (itemType.isEquippable()) {
|
||||
if (isInCombat) {
|
||||
ap = world.model.player.getReequipCost();
|
||||
text = getResources().getString(R.string.iteminfo_action_equip_ap, ap);
|
||||
} else {
|
||||
text = getResources().getString(R.string.iteminfo_action_equip);
|
||||
}
|
||||
action = ItemInfoActivity.ItemInfoAction.equip;
|
||||
} else if (itemType.isUsable()) {
|
||||
if (isInCombat) {
|
||||
ap = world.model.player.getUseItemCost();
|
||||
text = getResources().getString(R.string.iteminfo_action_use_ap, ap);
|
||||
} else {
|
||||
text = getResources().getString(R.string.iteminfo_action_use);
|
||||
}
|
||||
action = ItemInfoActivity.ItemInfoAction.use;
|
||||
}
|
||||
if (isInCombat && ap > 0) {
|
||||
enabled = world.model.player.hasAPs(ap);
|
||||
}
|
||||
|
||||
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) { //Jewelry items
|
||||
inventoryJewelryListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildJewelryItems(), player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryJewelryListAdapter);
|
||||
inventoryJewelryListAdapter.notifyDataSetChanged();
|
||||
} else if (v == 4) { //Potion items
|
||||
inventoryPotionListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildPotionItems(), player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryPotionListAdapter);
|
||||
inventoryPotionListAdapter.notifyDataSetChanged();
|
||||
} else if (v == 5) { //Food items
|
||||
inventoryFoodListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildFoodItems(), player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryFoodListAdapter);
|
||||
inventoryFoodListAdapter.notifyDataSetChanged();
|
||||
} else if (v == 6) { //Quest items
|
||||
inventoryQuestListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildQuestItems(), player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryQuestListAdapter);
|
||||
inventoryQuestListAdapter.notifyDataSetChanged();
|
||||
} else if (v == 7) { //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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.gpl.rpg.AndorsTrail.activity.fragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -22,7 +21,6 @@ import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.model.quest.Quest;
|
||||
import com.gpl.rpg.AndorsTrail.model.quest.QuestLogEntry;
|
||||
import com.gpl.rpg.AndorsTrail.model.quest.QuestProgress;
|
||||
import com.gpl.rpg.AndorsTrail.view.SpinnerEmulator;
|
||||
|
||||
public final class HeroinfoActivity_Quests extends Fragment {
|
||||
|
||||
@@ -6,10 +6,6 @@ import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.SpannableString;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.RelativeSizeSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
||||
@@ -1,131 +1,128 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity.fragment;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
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.Button;
|
||||
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;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
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.ShopItemContainerAdapter;
|
||||
import com.gpl.rpg.AndorsTrail.view.SpinnerEmulator;
|
||||
import com.gpl.rpg.AndorsTrail.view.ShopItemContainerAdapter.OnContainerItemClickedListener;
|
||||
|
||||
public abstract class ShopActivityFragment extends Fragment implements OnContainerItemClickedListener {
|
||||
|
||||
protected static final int INTENTREQUEST_ITEMINFO = 3;
|
||||
protected static final int INTENTREQUEST_BULKSELECT = 9;
|
||||
|
||||
protected WorldContext world;
|
||||
protected Player player;
|
||||
|
||||
protected ItemContainer shopInventory;
|
||||
private TextView shop_gc;
|
||||
private ShopItemContainerAdapter listAdapter;
|
||||
private Button shoplist_sort;
|
||||
|
||||
protected abstract boolean isSellingInterface();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(getActivity());
|
||||
if (!app.isInitialized()) return;
|
||||
this.world = app.getWorld();
|
||||
this.player = world.model.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.shoplist, container, false);
|
||||
|
||||
final Monster npc = Dialogs.getMonsterFromIntent(getActivity().getIntent(), world);
|
||||
|
||||
final Resources res = getResources();
|
||||
|
||||
shop_gc = (TextView) v.findViewById(R.id.shop_gc);
|
||||
|
||||
ListView shoplist = (ListView) v.findViewById(R.id.shop_list);
|
||||
|
||||
shopInventory = npc.getShopItems(player);
|
||||
|
||||
HashSet<Integer> iconIDs = world.tileManager.getTileIDsFor(shopInventory);
|
||||
iconIDs.addAll(world.tileManager.getTileIDsFor(player.inventory));
|
||||
TileCollection tiles = world.tileManager.loadTilesFor(iconIDs, res);
|
||||
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 = (Button) v.findViewById(R.id.shoplist_sort_filters);
|
||||
new SpinnerEmulator(v, R.id.shoplist_sort_filters, R.array.shoplist_sort_filters, R.string.shop_item_sort) {
|
||||
@Override
|
||||
public void setValue(int value) {
|
||||
world.model.uiSelections.selectedShopSort = value;
|
||||
}
|
||||
@Override
|
||||
public void selectionChanged(int value) {
|
||||
reloadShownSort(isSelling ? player.inventory : shopInventory);
|
||||
}
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 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();
|
||||
update();
|
||||
}
|
||||
|
||||
private Toast lastToast = null;
|
||||
protected void displayStoreAction(final String msg) {
|
||||
if (lastToast != null) {
|
||||
lastToast.setText(msg);
|
||||
} else {
|
||||
lastToast = Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT);
|
||||
}
|
||||
lastToast.show();
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
lastToast = null;
|
||||
}
|
||||
|
||||
protected void update() {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
String gc = getResources().getString(R.string.shop_yourgold, player.getGold());
|
||||
shop_gc.setText(gc);
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.activity.fragment;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
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;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
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.ShopItemContainerAdapter;
|
||||
import com.gpl.rpg.AndorsTrail.view.SpinnerEmulator;
|
||||
import com.gpl.rpg.AndorsTrail.view.ShopItemContainerAdapter.OnContainerItemClickedListener;
|
||||
|
||||
public abstract class ShopActivityFragment extends Fragment implements OnContainerItemClickedListener {
|
||||
|
||||
protected static final int INTENTREQUEST_ITEMINFO = 3;
|
||||
protected static final int INTENTREQUEST_BULKSELECT = 9;
|
||||
|
||||
protected WorldContext world;
|
||||
protected Player player;
|
||||
|
||||
protected ItemContainer shopInventory;
|
||||
private TextView shop_gc;
|
||||
private ShopItemContainerAdapter listAdapter;
|
||||
private Button shoplist_sort;
|
||||
|
||||
protected abstract boolean isSellingInterface();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(getActivity());
|
||||
if (!app.isInitialized()) return;
|
||||
this.world = app.getWorld();
|
||||
this.player = world.model.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.shoplist, container, false);
|
||||
|
||||
final Monster npc = Dialogs.getMonsterFromIntent(getActivity().getIntent(), world);
|
||||
|
||||
final Resources res = getResources();
|
||||
|
||||
shop_gc = (TextView) v.findViewById(R.id.shop_gc);
|
||||
|
||||
ListView shoplist = (ListView) v.findViewById(R.id.shop_list);
|
||||
|
||||
shopInventory = npc.getShopItems(player);
|
||||
|
||||
HashSet<Integer> iconIDs = world.tileManager.getTileIDsFor(shopInventory);
|
||||
iconIDs.addAll(world.tileManager.getTileIDsFor(player.inventory));
|
||||
TileCollection tiles = world.tileManager.loadTilesFor(iconIDs, res);
|
||||
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 = (Button) v.findViewById(R.id.shoplist_sort_filters);
|
||||
new SpinnerEmulator(v, R.id.shoplist_sort_filters, R.array.shoplist_sort_filters, R.string.shop_item_sort) {
|
||||
@Override
|
||||
public void setValue(int value) {
|
||||
world.model.uiSelections.selectedShopSort = value;
|
||||
}
|
||||
@Override
|
||||
public void selectionChanged(int value) {
|
||||
reloadShownSort(isSelling ? player.inventory : shopInventory);
|
||||
}
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 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();
|
||||
update();
|
||||
}
|
||||
|
||||
private Toast lastToast = null;
|
||||
protected void displayStoreAction(final String msg) {
|
||||
if (lastToast != null) {
|
||||
lastToast.setText(msg);
|
||||
} else {
|
||||
lastToast = Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT);
|
||||
}
|
||||
lastToast.show();
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
lastToast = null;
|
||||
}
|
||||
|
||||
protected void update() {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
String gc = getResources().getString(R.string.shop_yourgold, player.getGold());
|
||||
shop_gc.setText(gc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,400 +1,400 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity.fragment;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
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;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.WorldSetup;
|
||||
import com.gpl.rpg.AndorsTrail.activity.AboutActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.LoadingActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.Preferences;
|
||||
import com.gpl.rpg.AndorsTrail.controller.Constants;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
|
||||
import com.gpl.rpg.AndorsTrail.savegames.Savegames;
|
||||
import com.gpl.rpg.AndorsTrail.savegames.Savegames.FileHeader;
|
||||
import com.gpl.rpg.AndorsTrail.util.AndroidStorage;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||
|
||||
public class StartScreenActivity_MainMenu extends Fragment {
|
||||
|
||||
private static final int INTENTREQUEST_PREFERENCES = 7;
|
||||
public static final int INTENTREQUEST_LOADGAME = 9;
|
||||
|
||||
private boolean hasExistingGame = false;
|
||||
private Button startscreen_continue;
|
||||
private Button startscreen_newgame;
|
||||
private Button startscreen_load;
|
||||
private ViewGroup save_preview_holder;
|
||||
private ImageView save_preview_hero_icon;
|
||||
private TextView save_preview_hero_desc;
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
updatePreferences(false);
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
|
||||
if (container != null) {
|
||||
container.removeAllViews();
|
||||
}
|
||||
|
||||
View root = inflater.inflate(R.layout.startscreen_mainmenu, container, false);
|
||||
|
||||
save_preview_holder = (ViewGroup) root.findViewById(R.id.save_preview_holder);
|
||||
save_preview_hero_icon = (ImageView) root.findViewById(R.id.save_preview_hero_icon);
|
||||
save_preview_hero_desc = (TextView) root.findViewById(R.id.save_preview_hero_desc);
|
||||
|
||||
|
||||
startscreen_continue = (Button) root.findViewById(R.id.startscreen_continue);
|
||||
startscreen_continue.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
continueGame(false, Savegames.SLOT_QUICKSAVE, null);
|
||||
}
|
||||
});
|
||||
|
||||
startscreen_newgame = (Button) root.findViewById(R.id.startscreen_newgame);
|
||||
startscreen_newgame.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
if (hasExistingGame) {
|
||||
comfirmNewGame();
|
||||
} else {
|
||||
createNewGame();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Button b = (Button) root.findViewById(R.id.startscreen_about);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
startActivity(new Intent(getActivity(), AboutActivity.class));
|
||||
}
|
||||
});
|
||||
|
||||
b = (Button) root.findViewById(R.id.startscreen_preferences);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
Intent intent = new Intent(getActivity(), Preferences.class);
|
||||
StartScreenActivity_MainMenu.this.startActivityForResult(intent, INTENTREQUEST_PREFERENCES);
|
||||
}
|
||||
});
|
||||
|
||||
startscreen_load = (Button) root.findViewById(R.id.startscreen_load);
|
||||
startscreen_load.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(getActivity());
|
||||
if (hasExistingGame && app != null && app.getWorld() != null && app.getWorld().model != null
|
||||
&& app.getWorld().model.statistics != null && !app.getWorld().model.statistics.hasUnlimitedSaves()) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(getActivity(),
|
||||
getString(R.string.startscreen_load_game),
|
||||
getResources().getDrawable(android.R.drawable.ic_delete),
|
||||
getString(R.string.startscreen_load_game_confirm),
|
||||
null,
|
||||
true);
|
||||
CustomDialogFactory.addButton(d, android.R.string.ok, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Dialogs.showLoad(StartScreenActivity_MainMenu.this);
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.cancel);
|
||||
CustomDialogFactory.show(d);
|
||||
|
||||
} else {
|
||||
Dialogs.showLoad(StartScreenActivity_MainMenu.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (AndorsTrailApplication.DEVELOPMENT_FORCE_STARTNEWGAME) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGRESOURCES) {
|
||||
continueGame(true, 0, "Debug player");
|
||||
} else {
|
||||
continueGame(true, 0, "Player");
|
||||
}
|
||||
} else if (AndorsTrailApplication.DEVELOPMENT_FORCE_CONTINUEGAME) {
|
||||
continueGame(false, Savegames.SLOT_QUICKSAVE, null);
|
||||
}
|
||||
|
||||
// if it is a new version we first fire a welcome screen in onResume
|
||||
// and afterwards check the permissions
|
||||
if (!isNewVersion()) {
|
||||
checkAndRequestPermissions(getActivity());
|
||||
migrateDataOnDemand(getActivity());
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
String playerName;
|
||||
String displayInfo = null;
|
||||
int iconID = TileManager.CHAR_HERO;
|
||||
boolean isDead = false;
|
||||
|
||||
FileHeader header = Savegames.quickload(getActivity(), Savegames.SLOT_QUICKSAVE);
|
||||
if (header != null && header.playerName != null) {
|
||||
playerName = header.playerName;
|
||||
displayInfo = header.displayInfo;
|
||||
iconID = header.iconID;
|
||||
isDead = header.isDead;
|
||||
} else {
|
||||
// Before fileversion 14 (v0.6.7), quicksave was stored in Shared preferences
|
||||
SharedPreferences p = getActivity().getSharedPreferences("quicksave", Activity.MODE_PRIVATE);
|
||||
playerName = p.getString("playername", null);
|
||||
if (playerName != null) {
|
||||
displayInfo = "level " + p.getInt("level", -1);
|
||||
}
|
||||
}
|
||||
hasExistingGame = (playerName != null);
|
||||
setButtonState(playerName, displayInfo, iconID, isDead);
|
||||
|
||||
if (isNewVersion()) {
|
||||
Dialogs.showNewVersion(getActivity(), new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
setCurrentVersionForVersionCheck();
|
||||
checkAndRequestPermissions(getActivity());
|
||||
migrateDataOnDemand(getActivity());
|
||||
boolean hasSavegames = !Savegames.getUsedSavegameSlots(getActivity()).isEmpty();
|
||||
startscreen_load.setEnabled(hasSavegames);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
boolean hasSavegames = !Savegames.getUsedSavegameSlots(getActivity()).isEmpty();
|
||||
startscreen_load.setEnabled(hasSavegames);
|
||||
}
|
||||
|
||||
@TargetApi(29)
|
||||
public void migrateDataOnDemand(final Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
if (activity.getApplicationContext().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||
if (AndroidStorage.shouldMigrateToInternalStorage(activity.getApplicationContext())) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(activity,
|
||||
getString(R.string.startscreen_migration_title),
|
||||
activity.getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
||||
getString(R.string.startscreen_migration_text),
|
||||
null,
|
||||
true);
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
d.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
boolean hasSavegames = !Savegames.getUsedSavegameSlots(getActivity()).isEmpty();
|
||||
startscreen_load.setEnabled(hasSavegames);
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.show(d);
|
||||
if (!AndroidStorage.migrateToInternalStorage(activity.getApplicationContext())) {
|
||||
final Dialog errorDlg = CustomDialogFactory.createDialog(activity,
|
||||
getString(R.string.startscreen_migration_title),
|
||||
activity.getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
||||
getString(R.string.startscreen_migration_failure),
|
||||
null,
|
||||
true);
|
||||
CustomDialogFactory.addDismissButton(errorDlg, android.R.string.ok);
|
||||
d.cancel();
|
||||
CustomDialogFactory.show(errorDlg);
|
||||
}
|
||||
} else {
|
||||
L.log("INFO: No external files or destination folder ist not empty. No data migration.");
|
||||
}
|
||||
} else {
|
||||
L.log("INFO: No read permission on external folder. No data migration.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final int READ_EXTERNAL_STORAGE_REQUEST=1;
|
||||
private static final int WRITE_EXTERNAL_STORAGE_REQUEST=2;
|
||||
|
||||
@TargetApi(23)
|
||||
public static void checkAndRequestPermissions(final Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
|
||||
if (activity.getApplicationContext().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
activity.requestPermissions(new String[] {Manifest.permission.READ_EXTERNAL_STORAGE}, READ_EXTERNAL_STORAGE_REQUEST);
|
||||
}
|
||||
if (activity.getApplicationContext().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
activity.requestPermissions(new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, WRITE_EXTERNAL_STORAGE_REQUEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
listener = (OnNewGameRequestedListener) activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
listener = null;
|
||||
}
|
||||
|
||||
private void setButtonState(final String playerName, final String displayInfo, int iconID, boolean isDead) {
|
||||
startscreen_continue.setEnabled(hasExistingGame && !isDead);
|
||||
startscreen_newgame.setEnabled(true);
|
||||
if (hasExistingGame) {
|
||||
TileManager tm = AndorsTrailApplication.getApplicationFromActivity(getActivity()).getWorld().tileManager;
|
||||
tm.setImageViewTileForPlayer(getResources(), save_preview_hero_icon, iconID);
|
||||
save_preview_hero_desc.setText((isDead ? getString(R.string.rip_startscreen) : "") + playerName + ", " + displayInfo);
|
||||
save_preview_holder.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
save_preview_holder.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void continueGame(boolean createNewCharacter, int loadFromSlot, String name) {
|
||||
final WorldSetup setup = AndorsTrailApplication.getApplicationFromActivity(getActivity()).getWorldSetup();
|
||||
setup.createNewCharacter = createNewCharacter;
|
||||
setup.loadFromSlot = loadFromSlot;
|
||||
setup.newHeroName = name;
|
||||
startActivity(new Intent(getActivity(), LoadingActivity.class));
|
||||
}
|
||||
|
||||
private void comfirmNewGame() {
|
||||
// new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.AndorsTrailStyle_Dialog))
|
||||
// .setTitle(R.string.startscreen_newgame)
|
||||
// .setMessage(R.string.startscreen_newgame_confirm)
|
||||
// .setIcon(android.R.drawable.ic_delete)
|
||||
// .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(DialogInterface dialog, int which) {
|
||||
// //continueGame(true);
|
||||
//// hasExistingGame = false;
|
||||
//// setButtonState(null, null, 0);
|
||||
// createNewGame();
|
||||
// }
|
||||
// })
|
||||
// .setNegativeButton(android.R.string.cancel, null)
|
||||
// .create().show();
|
||||
//
|
||||
//
|
||||
final Dialog d = CustomDialogFactory.createDialog(getActivity(),
|
||||
getString(R.string.startscreen_newgame),
|
||||
getResources().getDrawable(android.R.drawable.ic_delete),
|
||||
getResources().getString(R.string.startscreen_newgame_confirm),
|
||||
null,
|
||||
true);
|
||||
CustomDialogFactory.addButton(d, android.R.string.ok, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
createNewGame();
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.cancel);
|
||||
|
||||
CustomDialogFactory.show(d);
|
||||
|
||||
}
|
||||
|
||||
private static final String versionCheck = "lastversion";
|
||||
private boolean isNewVersion() {
|
||||
SharedPreferences s = getActivity().getSharedPreferences(Constants.PREFERENCE_MODEL_LASTRUNVERSION, Activity.MODE_PRIVATE);
|
||||
int lastversion = s.getInt(versionCheck, 0);
|
||||
if (lastversion >= AndorsTrailApplication.CURRENT_VERSION) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setCurrentVersionForVersionCheck() {
|
||||
SharedPreferences s = getActivity().getSharedPreferences(Constants.PREFERENCE_MODEL_LASTRUNVERSION, Activity.MODE_PRIVATE);
|
||||
Editor e = s.edit();
|
||||
e.putInt(versionCheck, AndorsTrailApplication.CURRENT_VERSION);
|
||||
e.commit();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
switch (requestCode) {
|
||||
case INTENTREQUEST_LOADGAME:
|
||||
if (resultCode != Activity.RESULT_OK) break;
|
||||
final int slot = data.getIntExtra("slot", 1);
|
||||
continueGame(false, slot, null);
|
||||
break;
|
||||
case INTENTREQUEST_PREFERENCES:
|
||||
updatePreferences(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePreferences(boolean alreadyStartedLoadingResources) {
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(getActivity());
|
||||
AndorsTrailPreferences preferences = app.getPreferences();
|
||||
preferences.read(getActivity());
|
||||
if (app.setLocale(getActivity())) {
|
||||
if (alreadyStartedLoadingResources) {
|
||||
// Changing the locale after having loaded the game requires resources to
|
||||
// be re-loaded. Therefore, we just exit here.
|
||||
Toast.makeText(getActivity(), R.string.change_locale_requires_restart, Toast.LENGTH_LONG).show();
|
||||
doFinish();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (ThemeHelper.changeTheme(preferences.selectedTheme)) {
|
||||
// Changing the theme requires a restart to re-create all activities.
|
||||
Toast.makeText(getActivity(), R.string.change_theme_requires_restart, Toast.LENGTH_LONG).show();
|
||||
doFinish();
|
||||
return;
|
||||
}
|
||||
app.getWorld().tileManager.updatePreferences(preferences);
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void doFinish() {
|
||||
//For Lollipop and above
|
||||
((AndorsTrailApplication)getActivity().getApplication()).discardWorld();
|
||||
getActivity().finish();
|
||||
}
|
||||
|
||||
|
||||
public interface OnNewGameRequestedListener {
|
||||
public void onNewGameRequested();
|
||||
}
|
||||
|
||||
private OnNewGameRequestedListener listener = null;
|
||||
|
||||
private void createNewGame() {
|
||||
if (listener != null) {
|
||||
listener.onNewGameRequested();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.activity.fragment;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
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;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.WorldSetup;
|
||||
import com.gpl.rpg.AndorsTrail.activity.AboutActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.LoadingActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.Preferences;
|
||||
import com.gpl.rpg.AndorsTrail.controller.Constants;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
|
||||
import com.gpl.rpg.AndorsTrail.savegames.Savegames;
|
||||
import com.gpl.rpg.AndorsTrail.savegames.Savegames.FileHeader;
|
||||
import com.gpl.rpg.AndorsTrail.util.AndroidStorage;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;
|
||||
|
||||
public class StartScreenActivity_MainMenu extends Fragment {
|
||||
|
||||
private static final int INTENTREQUEST_PREFERENCES = 7;
|
||||
public static final int INTENTREQUEST_LOADGAME = 9;
|
||||
|
||||
private boolean hasExistingGame = false;
|
||||
private Button startscreen_continue;
|
||||
private Button startscreen_newgame;
|
||||
private Button startscreen_load;
|
||||
private ViewGroup save_preview_holder;
|
||||
private ImageView save_preview_hero_icon;
|
||||
private TextView save_preview_hero_desc;
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
updatePreferences(false);
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
|
||||
if (container != null) {
|
||||
container.removeAllViews();
|
||||
}
|
||||
|
||||
View root = inflater.inflate(R.layout.startscreen_mainmenu, container, false);
|
||||
|
||||
save_preview_holder = (ViewGroup) root.findViewById(R.id.save_preview_holder);
|
||||
save_preview_hero_icon = (ImageView) root.findViewById(R.id.save_preview_hero_icon);
|
||||
save_preview_hero_desc = (TextView) root.findViewById(R.id.save_preview_hero_desc);
|
||||
|
||||
|
||||
startscreen_continue = (Button) root.findViewById(R.id.startscreen_continue);
|
||||
startscreen_continue.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
continueGame(false, Savegames.SLOT_QUICKSAVE, null);
|
||||
}
|
||||
});
|
||||
|
||||
startscreen_newgame = (Button) root.findViewById(R.id.startscreen_newgame);
|
||||
startscreen_newgame.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
if (hasExistingGame) {
|
||||
comfirmNewGame();
|
||||
} else {
|
||||
createNewGame();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Button b = (Button) root.findViewById(R.id.startscreen_about);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
startActivity(new Intent(getActivity(), AboutActivity.class));
|
||||
}
|
||||
});
|
||||
|
||||
b = (Button) root.findViewById(R.id.startscreen_preferences);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
Intent intent = new Intent(getActivity(), Preferences.class);
|
||||
StartScreenActivity_MainMenu.this.startActivityForResult(intent, INTENTREQUEST_PREFERENCES);
|
||||
}
|
||||
});
|
||||
|
||||
startscreen_load = (Button) root.findViewById(R.id.startscreen_load);
|
||||
startscreen_load.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(getActivity());
|
||||
if (hasExistingGame && app != null && app.getWorld() != null && app.getWorld().model != null
|
||||
&& app.getWorld().model.statistics != null && !app.getWorld().model.statistics.hasUnlimitedSaves()) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(getActivity(),
|
||||
getString(R.string.startscreen_load_game),
|
||||
getResources().getDrawable(android.R.drawable.ic_delete),
|
||||
getString(R.string.startscreen_load_game_confirm),
|
||||
null,
|
||||
true);
|
||||
CustomDialogFactory.addButton(d, android.R.string.ok, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Dialogs.showLoad(StartScreenActivity_MainMenu.this);
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.cancel);
|
||||
CustomDialogFactory.show(d);
|
||||
|
||||
} else {
|
||||
Dialogs.showLoad(StartScreenActivity_MainMenu.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (AndorsTrailApplication.DEVELOPMENT_FORCE_STARTNEWGAME) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGRESOURCES) {
|
||||
continueGame(true, 0, "Debug player");
|
||||
} else {
|
||||
continueGame(true, 0, "Player");
|
||||
}
|
||||
} else if (AndorsTrailApplication.DEVELOPMENT_FORCE_CONTINUEGAME) {
|
||||
continueGame(false, Savegames.SLOT_QUICKSAVE, null);
|
||||
}
|
||||
|
||||
// if it is a new version we first fire a welcome screen in onResume
|
||||
// and afterwards check the permissions
|
||||
if (!isNewVersion()) {
|
||||
checkAndRequestPermissions(getActivity());
|
||||
migrateDataOnDemand(getActivity());
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
String playerName;
|
||||
String displayInfo = null;
|
||||
int iconID = TileManager.CHAR_HERO;
|
||||
boolean isDead = false;
|
||||
|
||||
FileHeader header = Savegames.quickload(getActivity(), Savegames.SLOT_QUICKSAVE);
|
||||
if (header != null && header.playerName != null) {
|
||||
playerName = header.playerName;
|
||||
displayInfo = header.displayInfo;
|
||||
iconID = header.iconID;
|
||||
isDead = header.isDead;
|
||||
} else {
|
||||
// Before fileversion 14 (v0.6.7), quicksave was stored in Shared preferences
|
||||
SharedPreferences p = getActivity().getSharedPreferences("quicksave", Activity.MODE_PRIVATE);
|
||||
playerName = p.getString("playername", null);
|
||||
if (playerName != null) {
|
||||
displayInfo = "level " + p.getInt("level", -1);
|
||||
}
|
||||
}
|
||||
hasExistingGame = (playerName != null);
|
||||
setButtonState(playerName, displayInfo, iconID, isDead);
|
||||
|
||||
if (isNewVersion()) {
|
||||
Dialogs.showNewVersion(getActivity(), new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
setCurrentVersionForVersionCheck();
|
||||
checkAndRequestPermissions(getActivity());
|
||||
migrateDataOnDemand(getActivity());
|
||||
boolean hasSavegames = !Savegames.getUsedSavegameSlots(getActivity()).isEmpty();
|
||||
startscreen_load.setEnabled(hasSavegames);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
boolean hasSavegames = !Savegames.getUsedSavegameSlots(getActivity()).isEmpty();
|
||||
startscreen_load.setEnabled(hasSavegames);
|
||||
}
|
||||
|
||||
@TargetApi(29)
|
||||
public void migrateDataOnDemand(final Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
if (activity.getApplicationContext().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||
if (AndroidStorage.shouldMigrateToInternalStorage(activity.getApplicationContext())) {
|
||||
final Dialog d = CustomDialogFactory.createDialog(activity,
|
||||
getString(R.string.startscreen_migration_title),
|
||||
activity.getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
||||
getString(R.string.startscreen_migration_text),
|
||||
null,
|
||||
true);
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.ok);
|
||||
d.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface arg0) {
|
||||
boolean hasSavegames = !Savegames.getUsedSavegameSlots(getActivity()).isEmpty();
|
||||
startscreen_load.setEnabled(hasSavegames);
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.show(d);
|
||||
if (!AndroidStorage.migrateToInternalStorage(activity.getApplicationContext())) {
|
||||
final Dialog errorDlg = CustomDialogFactory.createDialog(activity,
|
||||
getString(R.string.startscreen_migration_title),
|
||||
activity.getResources().getDrawable(android.R.drawable.ic_dialog_alert),
|
||||
getString(R.string.startscreen_migration_failure),
|
||||
null,
|
||||
true);
|
||||
CustomDialogFactory.addDismissButton(errorDlg, android.R.string.ok);
|
||||
d.cancel();
|
||||
CustomDialogFactory.show(errorDlg);
|
||||
}
|
||||
} else {
|
||||
L.log("INFO: No external files or destination folder ist not empty. No data migration.");
|
||||
}
|
||||
} else {
|
||||
L.log("INFO: No read permission on external folder. No data migration.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final int READ_EXTERNAL_STORAGE_REQUEST=1;
|
||||
private static final int WRITE_EXTERNAL_STORAGE_REQUEST=2;
|
||||
|
||||
@TargetApi(23)
|
||||
public static void checkAndRequestPermissions(final Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
|
||||
if (activity.getApplicationContext().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
activity.requestPermissions(new String[] {Manifest.permission.READ_EXTERNAL_STORAGE}, READ_EXTERNAL_STORAGE_REQUEST);
|
||||
}
|
||||
if (activity.getApplicationContext().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
activity.requestPermissions(new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, WRITE_EXTERNAL_STORAGE_REQUEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
listener = (OnNewGameRequestedListener) activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
listener = null;
|
||||
}
|
||||
|
||||
private void setButtonState(final String playerName, final String displayInfo, int iconID, boolean isDead) {
|
||||
startscreen_continue.setEnabled(hasExistingGame && !isDead);
|
||||
startscreen_newgame.setEnabled(true);
|
||||
if (hasExistingGame) {
|
||||
TileManager tm = AndorsTrailApplication.getApplicationFromActivity(getActivity()).getWorld().tileManager;
|
||||
tm.setImageViewTileForPlayer(getResources(), save_preview_hero_icon, iconID);
|
||||
save_preview_hero_desc.setText((isDead ? getString(R.string.rip_startscreen) : "") + playerName + ", " + displayInfo);
|
||||
save_preview_holder.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
save_preview_holder.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void continueGame(boolean createNewCharacter, int loadFromSlot, String name) {
|
||||
final WorldSetup setup = AndorsTrailApplication.getApplicationFromActivity(getActivity()).getWorldSetup();
|
||||
setup.createNewCharacter = createNewCharacter;
|
||||
setup.loadFromSlot = loadFromSlot;
|
||||
setup.newHeroName = name;
|
||||
startActivity(new Intent(getActivity(), LoadingActivity.class));
|
||||
}
|
||||
|
||||
private void comfirmNewGame() {
|
||||
// new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.AndorsTrailStyle_Dialog))
|
||||
// .setTitle(R.string.startscreen_newgame)
|
||||
// .setMessage(R.string.startscreen_newgame_confirm)
|
||||
// .setIcon(android.R.drawable.ic_delete)
|
||||
// .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(DialogInterface dialog, int which) {
|
||||
// //continueGame(true);
|
||||
//// hasExistingGame = false;
|
||||
//// setButtonState(null, null, 0);
|
||||
// createNewGame();
|
||||
// }
|
||||
// })
|
||||
// .setNegativeButton(android.R.string.cancel, null)
|
||||
// .create().show();
|
||||
//
|
||||
//
|
||||
final Dialog d = CustomDialogFactory.createDialog(getActivity(),
|
||||
getString(R.string.startscreen_newgame),
|
||||
getResources().getDrawable(android.R.drawable.ic_delete),
|
||||
getResources().getString(R.string.startscreen_newgame_confirm),
|
||||
null,
|
||||
true);
|
||||
CustomDialogFactory.addButton(d, android.R.string.ok, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
createNewGame();
|
||||
}
|
||||
});
|
||||
CustomDialogFactory.addDismissButton(d, android.R.string.cancel);
|
||||
|
||||
CustomDialogFactory.show(d);
|
||||
|
||||
}
|
||||
|
||||
private static final String versionCheck = "lastversion";
|
||||
private boolean isNewVersion() {
|
||||
SharedPreferences s = getActivity().getSharedPreferences(Constants.PREFERENCE_MODEL_LASTRUNVERSION, Activity.MODE_PRIVATE);
|
||||
int lastversion = s.getInt(versionCheck, 0);
|
||||
if (lastversion >= AndorsTrailApplication.CURRENT_VERSION) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setCurrentVersionForVersionCheck() {
|
||||
SharedPreferences s = getActivity().getSharedPreferences(Constants.PREFERENCE_MODEL_LASTRUNVERSION, Activity.MODE_PRIVATE);
|
||||
Editor e = s.edit();
|
||||
e.putInt(versionCheck, AndorsTrailApplication.CURRENT_VERSION);
|
||||
e.commit();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
switch (requestCode) {
|
||||
case INTENTREQUEST_LOADGAME:
|
||||
if (resultCode != Activity.RESULT_OK) break;
|
||||
final int slot = data.getIntExtra("slot", 1);
|
||||
continueGame(false, slot, null);
|
||||
break;
|
||||
case INTENTREQUEST_PREFERENCES:
|
||||
updatePreferences(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePreferences(boolean alreadyStartedLoadingResources) {
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(getActivity());
|
||||
AndorsTrailPreferences preferences = app.getPreferences();
|
||||
preferences.read(getActivity());
|
||||
if (app.setLocale(getActivity())) {
|
||||
if (alreadyStartedLoadingResources) {
|
||||
// Changing the locale after having loaded the game requires resources to
|
||||
// be re-loaded. Therefore, we just exit here.
|
||||
Toast.makeText(getActivity(), R.string.change_locale_requires_restart, Toast.LENGTH_LONG).show();
|
||||
doFinish();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (ThemeHelper.changeTheme(preferences.selectedTheme)) {
|
||||
// Changing the theme requires a restart to re-create all activities.
|
||||
Toast.makeText(getActivity(), R.string.change_theme_requires_restart, Toast.LENGTH_LONG).show();
|
||||
doFinish();
|
||||
return;
|
||||
}
|
||||
app.getWorld().tileManager.updatePreferences(preferences);
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void doFinish() {
|
||||
//For Lollipop and above
|
||||
((AndorsTrailApplication)getActivity().getApplication()).discardWorld();
|
||||
getActivity().finish();
|
||||
}
|
||||
|
||||
|
||||
public interface OnNewGameRequestedListener {
|
||||
public void onNewGameRequested();
|
||||
}
|
||||
|
||||
private OnNewGameRequestedListener listener = null;
|
||||
|
||||
private void createNewGame() {
|
||||
if (listener != null) {
|
||||
listener.onNewGameRequested();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,446 +1,446 @@
|
||||
package com.gpl.rpg.AndorsTrail.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailPreferences;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.listeners.QuickSlotListeners;
|
||||
import com.gpl.rpg.AndorsTrail.model.ModelContainer;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.SkillCollection;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.traits.AbilityModifierTraits;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Inventory;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemContainer;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemContainer.ItemEntry;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemTraits_OnHitReceived;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemTraits_OnUse;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Loot;
|
||||
|
||||
import static java.lang.Math.min;
|
||||
|
||||
public final class ItemController {
|
||||
|
||||
private final ControllerContext controllers;
|
||||
private final WorldContext world;
|
||||
public final QuickSlotListeners quickSlotListeners = new QuickSlotListeners();
|
||||
|
||||
public ItemController(ControllerContext controllers, WorldContext world) {
|
||||
this.controllers = controllers;
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public void dropItem(ItemType type, int quantity) {
|
||||
if (world.model.player.inventory.getItemQuantity(type.id) < quantity) return;
|
||||
world.model.player.inventory.removeItem(type.id, quantity);
|
||||
world.model.currentMaps.map.itemDropped(type, quantity, world.model.player.position);
|
||||
}
|
||||
|
||||
public void equipItem(ItemType type, Inventory.WearSlot slot) {
|
||||
if (!type.isEquippable()) return;
|
||||
final Player player = world.model.player;
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
boolean changed = controllers.actorStatsController.useAPs(player, player.getReequipCost());
|
||||
if (!changed) return;
|
||||
}
|
||||
|
||||
if (!player.inventory.removeItem(type.id, 1)) return;
|
||||
|
||||
unequipSlot(player, slot);
|
||||
if (type.isTwohandWeapon()) unequipSlot(player, Inventory.WearSlot.shield);
|
||||
else if (slot == Inventory.WearSlot.shield) {
|
||||
ItemType currentWeapon = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.weapon);
|
||||
if (currentWeapon != null && currentWeapon.isTwohandWeapon()) unequipSlot(player, Inventory.WearSlot.weapon);
|
||||
}
|
||||
|
||||
player.inventory.setItemTypeInWearSlot(slot, type);
|
||||
controllers.actorStatsController.addConditionsFromEquippedItem(player, type);
|
||||
controllers.actorStatsController.recalculatePlayerStats(player);
|
||||
if (world.model.uiSelections.isInCombat && !controllers.combatController.playerHasApLeft()) {
|
||||
controllers.combatController.endPlayerTurn();
|
||||
}
|
||||
}
|
||||
|
||||
public void unequipSlot(ItemType type, Inventory.WearSlot slot) {
|
||||
if (!type.isEquippable()) return;
|
||||
final Player player = world.model.player;
|
||||
if (player.inventory.isEmptySlot(slot)) return;
|
||||
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
boolean changed = controllers.actorStatsController.useAPs(player, player.getReequipCost());
|
||||
if (!changed) return;
|
||||
}
|
||||
|
||||
unequipSlot(player, slot);
|
||||
controllers.actorStatsController.recalculatePlayerStats(player);
|
||||
if (world.model.uiSelections.isInCombat && !controllers.combatController.playerHasApLeft()) {
|
||||
controllers.combatController.endPlayerTurn();
|
||||
}
|
||||
}
|
||||
|
||||
private void unequipSlot(Player player, Inventory.WearSlot slot) {
|
||||
ItemType removedItemType = player.inventory.getItemTypeInWearSlot(slot);
|
||||
if (removedItemType == null) return;
|
||||
player.inventory.addItem(removedItemType);
|
||||
player.inventory.setItemTypeInWearSlot(slot, null);
|
||||
controllers.actorStatsController.removeConditionsFromUnequippedItem(player, removedItemType);
|
||||
}
|
||||
|
||||
public void useItem(ItemType type) {
|
||||
if (!type.isUsable()) return;
|
||||
final Player player = world.model.player;
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
boolean changed = controllers.actorStatsController.useAPs(player, player.getUseItemCost());
|
||||
if (!changed) return;
|
||||
}
|
||||
|
||||
if (!player.inventory.removeItem(type.id, 1)) return;
|
||||
|
||||
world.model.combatLog.append(controllers.getResources().getString(R.string.inventory_item_used, type.getName(player)));
|
||||
controllers.actorStatsController.applyUseEffect(player, null, type.effects_use);
|
||||
world.model.statistics.addItemUsage(type);
|
||||
if (world.model.uiSelections.isInCombat && !controllers.combatController.playerHasApLeft()) {
|
||||
controllers.combatController.endPlayerTurn();
|
||||
}
|
||||
}
|
||||
|
||||
public void playerSteppedOnLootBag(Loot loot) {
|
||||
if (pickupLootBagWithoutConfirmation(loot)) {
|
||||
controllers.mapController.worldEventListeners.onPlayerPickedUpGroundLoot(loot);
|
||||
pickupAll(loot);
|
||||
removeLootBagIfEmpty(loot);
|
||||
} else {
|
||||
controllers.mapController.worldEventListeners.onPlayerSteppedOnGroundLoot(loot);
|
||||
consumeNonItemLoot(loot);
|
||||
}
|
||||
}
|
||||
|
||||
public void lootMonsterBags(Collection<Loot> killedMonsterBags, int totalExpThisFight) {
|
||||
if (pickupLootBagsWithoutConfirmation(killedMonsterBags)) {
|
||||
controllers.mapController.worldEventListeners.onPlayerPickedUpMonsterLoot(killedMonsterBags, totalExpThisFight);
|
||||
pickupAll(killedMonsterBags);
|
||||
removeLootBagIfEmpty(killedMonsterBags);
|
||||
controllers.gameRoundController.resume();
|
||||
} else {
|
||||
controllers.mapController.worldEventListeners.onPlayerFoundMonsterLoot(killedMonsterBags, totalExpThisFight);
|
||||
consumeNonItemLoot(killedMonsterBags);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean pickupLootBagWithoutConfirmation(Loot bag) {
|
||||
if (bag.isContainer()) return false;
|
||||
switch (controllers.preferences.displayLoot) {
|
||||
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_ALWAYS:
|
||||
return false;
|
||||
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_FOR_ITEMS:
|
||||
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_FOR_ITEMS_ELSE_TOAST:
|
||||
if (bag.hasItems()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean pickupLootBagsWithoutConfirmation(Collection<Loot> bags) {
|
||||
if (controllers.preferences.displayLoot == AndorsTrailPreferences.DISPLAYLOOT_DIALOG_ALWAYS) return false;
|
||||
for (Loot bag : bags) {
|
||||
if (!pickupLootBagWithoutConfirmation(bag)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void applyInventoryEffects(Player player) {
|
||||
ItemType weapon = getMainWeapon(player);
|
||||
if (weapon != null) {
|
||||
player.attackCost = 0;
|
||||
player.criticalMultiplier = weapon.effects_equip.stats.setCriticalMultiplier;
|
||||
}
|
||||
|
||||
applyInventoryEffects(player, Inventory.WearSlot.weapon);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.shield);
|
||||
SkillController.applySkillEffectsFromFightingStyles(player);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.head);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.body);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.hand);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.feet);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.neck);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.leftring);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.rightring);
|
||||
SkillController.applySkillEffectsFromItemProficiencies(player);
|
||||
}
|
||||
public static ItemType getMainWeapon(Player player) {
|
||||
ItemType itemType = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.weapon);
|
||||
if (itemType != null) return itemType;
|
||||
itemType = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.shield);
|
||||
if (itemType != null && itemType.isWeapon()) return itemType;
|
||||
return null;
|
||||
}
|
||||
|
||||
private void applyInventoryEffects(Player player, Inventory.WearSlot slot) {
|
||||
ItemType type = player.inventory.getItemTypeInWearSlot(slot);
|
||||
if (type == null) return;
|
||||
if (slot == Inventory.WearSlot.shield) {
|
||||
ItemType mainHandItem = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.weapon);
|
||||
// The stats for off-hand weapons will be added later in SkillController.applySkillEffectsFromFightingStyles
|
||||
if (SkillController.isDualWielding(mainHandItem, type)) return;
|
||||
}
|
||||
if (type.effects_equip != null && type.effects_equip.stats != null) {
|
||||
controllers.actorStatsController.applyAbilityEffects(player, type.effects_equip.stats, 1);
|
||||
if (type.isWeapon()) {
|
||||
controllers.actorStatsController.addPlayerWeaponDamage(player, type.effects_equip.stats.increaseMinDamage, type.effects_equip.stats.increaseMaxDamage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void recalculateHitEffectsFromWornItems(Player player) {
|
||||
ArrayList<ItemTraits_OnUse> effects_onHit = null;
|
||||
ArrayList<ItemTraits_OnHitReceived> effects_onHitReceived = null;
|
||||
for (Inventory.WearSlot slot : Inventory.WearSlot.values()) {
|
||||
ItemType type = player.inventory.getItemTypeInWearSlot(slot);
|
||||
if (type == null) continue;
|
||||
ItemTraits_OnUse eh = type.effects_hit;
|
||||
ItemTraits_OnHitReceived ehr = type.effects_hitReceived;
|
||||
if (eh == null && ehr == null) continue;
|
||||
|
||||
if (effects_onHit == null) effects_onHit = new ArrayList<ItemTraits_OnUse>();
|
||||
if (eh != null) effects_onHit.add(eh);
|
||||
|
||||
if (effects_onHitReceived == null) effects_onHitReceived = new ArrayList<ItemTraits_OnHitReceived>();
|
||||
if (ehr != null) effects_onHitReceived.add(ehr);
|
||||
}
|
||||
|
||||
if (effects_onHit != null) {
|
||||
ItemTraits_OnUse[] effects_ = new ItemTraits_OnUse[effects_onHit.size()];
|
||||
effects_ = effects_onHit.toArray(effects_);
|
||||
player.onHitEffects = effects_;
|
||||
} else {
|
||||
player.onHitEffects = null;
|
||||
}
|
||||
|
||||
if (effects_onHitReceived != null) {
|
||||
ItemTraits_OnHitReceived[] effects_ = new ItemTraits_OnHitReceived[effects_onHitReceived.size()];
|
||||
effects_ = effects_onHitReceived.toArray(effects_);
|
||||
player.onHitReceivedEffects = effects_;
|
||||
} else {
|
||||
player.onHitReceivedEffects = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void consumeNonItemLoot(Loot loot) {
|
||||
// Experience will be given as soon as the monster is killed.
|
||||
world.model.player.inventory.gold += loot.gold;
|
||||
loot.gold = 0;
|
||||
removeLootBagIfEmpty(loot);
|
||||
}
|
||||
public void consumeNonItemLoot(Iterable<Loot> lootBags) {
|
||||
for(Loot l : lootBags) {
|
||||
consumeNonItemLoot(l);
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
for(Loot l : lootBags) {
|
||||
pickupAll(l);
|
||||
}
|
||||
}
|
||||
public boolean removeLootBagIfEmpty(final Loot loot) {
|
||||
if (loot.hasItemsOrGold()) return false;
|
||||
|
||||
world.model.currentMaps.map.removeGroundLoot(loot);
|
||||
controllers.mapController.mapLayoutListeners.onLootBagRemoved(world.model.currentMaps.map, loot.position);
|
||||
return true; // The bag was removed.
|
||||
}
|
||||
|
||||
public boolean removeLootBagIfEmpty(final Iterable<Loot> lootBags) {
|
||||
boolean isEmpty = true;
|
||||
for (Loot l : lootBags) {
|
||||
if (!removeLootBagIfEmpty(l)) isEmpty = false;
|
||||
}
|
||||
return isEmpty;
|
||||
}
|
||||
|
||||
private static int getMarketPriceFactor(Player player) {
|
||||
return Constants.MARKET_PRICEFACTOR_PERCENT
|
||||
- player.getSkillLevel(SkillCollection.SkillID.barter) * SkillCollection.PER_SKILLPOINT_INCREASE_BARTER_PRICEFACTOR_PERCENTAGE;
|
||||
}
|
||||
public static int getBuyingPrice(Player player, ItemType itemType) {
|
||||
return itemType.baseMarketCost + itemType.baseMarketCost * getMarketPriceFactor(player) / 100;
|
||||
}
|
||||
public static int getSellingPrice(Player player, ItemType itemType) {
|
||||
return itemType.baseMarketCost - itemType.baseMarketCost * getMarketPriceFactor(player) / 100;
|
||||
}
|
||||
|
||||
public static boolean canAfford(Player player, ItemType itemType) {
|
||||
return player.inventory.gold >= getBuyingPrice(player, itemType);
|
||||
}
|
||||
public static boolean canAfford(Player player, int price) {
|
||||
return player.inventory.gold >= price;
|
||||
}
|
||||
public static boolean maySellItem(Player player, ItemType itemType) {
|
||||
if (!itemType.isSellable()) return false;
|
||||
return true;
|
||||
}
|
||||
public static boolean sell(Player player, ItemType itemType, ItemContainer merchant, int quantity) {
|
||||
int price = getSellingPrice(player, itemType) * quantity;
|
||||
if (!maySellItem(player, itemType)) return false;
|
||||
if (!player.inventory.removeItem(itemType.id, quantity)) return false;
|
||||
player.inventory.gold += price;
|
||||
merchant.addItem(itemType, quantity);
|
||||
return true;
|
||||
}
|
||||
public static boolean buy(ModelContainer model, Player player, ItemType itemType, ItemContainer merchant, int quantity) {
|
||||
int price = getBuyingPrice(player, itemType) * quantity;
|
||||
if (!canAfford(player, price)) return false;
|
||||
if (!merchant.removeItem(itemType.id, quantity)) return false;
|
||||
player.inventory.gold -= price;
|
||||
player.inventory.addItem(itemType, quantity);
|
||||
model.statistics.addGoldSpent(price);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static String describeItemForListView(ItemEntry item, Player player) {
|
||||
StringBuilder sb = new StringBuilder(item.itemType.getName(player));
|
||||
if (item.quantity > 1) {
|
||||
sb.append(" (");
|
||||
sb.append(item.quantity);
|
||||
sb.append(')');
|
||||
}
|
||||
if (item.itemType.effects_equip != null) {
|
||||
AbilityModifierTraits t = item.itemType.effects_equip.stats;
|
||||
if (t != null) {
|
||||
if (t.increaseAttackChance != 0
|
||||
|| t.increaseMinDamage != 0
|
||||
|| t.increaseMaxDamage != 0
|
||||
|| t.increaseCriticalSkill != 0
|
||||
|| t.setCriticalMultiplier != 0) {
|
||||
sb.append(" [");
|
||||
describeAttackEffect(t.increaseAttackChance, t.increaseMinDamage, t.increaseMaxDamage, t.increaseCriticalSkill, t.setCriticalMultiplier, sb);
|
||||
sb.append(']');
|
||||
}
|
||||
if (t.increaseBlockChance != 0
|
||||
|| t.increaseDamageResistance != 0) {
|
||||
sb.append(" [");
|
||||
describeBlockEffect(t.increaseBlockChance, t.increaseDamageResistance, sb);
|
||||
sb.append(']');
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static void describeAttackEffect(int attackChance, int minDamage, int maxDamage, int criticalSkill, float criticalMultiplier, StringBuilder sb) {
|
||||
boolean addSpace = false;
|
||||
if (attackChance != 0) {
|
||||
sb.append(attackChance);
|
||||
addSpace = true;
|
||||
}
|
||||
if (minDamage != 0 || maxDamage != 0) {
|
||||
if (addSpace) sb.append(' ');
|
||||
sb.append(minDamage);
|
||||
if (minDamage != maxDamage) {
|
||||
sb.append('-');
|
||||
sb.append(maxDamage);
|
||||
}
|
||||
addSpace = true;
|
||||
}
|
||||
if (criticalSkill != 0) {
|
||||
if (addSpace) sb.append(' ');
|
||||
if (criticalSkill >= 0) {
|
||||
sb.append('+');
|
||||
}
|
||||
sb.append(criticalSkill);
|
||||
}
|
||||
if (criticalMultiplier != 0 && criticalMultiplier != 1) {
|
||||
sb.append('x');
|
||||
sb.append(criticalMultiplier);
|
||||
}
|
||||
}
|
||||
|
||||
public static void describeBlockEffect(int blockChance, int damageResistance, StringBuilder sb) {
|
||||
if (blockChance != 0) {
|
||||
sb.append(blockChance);
|
||||
}
|
||||
if (damageResistance != 0) {
|
||||
sb.append('/');
|
||||
sb.append(damageResistance);
|
||||
}
|
||||
}
|
||||
|
||||
public void quickitemUse(int quickSlotId) {
|
||||
useItem(world.model.player.inventory.quickitem[quickSlotId]);
|
||||
quickSlotListeners.onQuickSlotUsed(quickSlotId);
|
||||
}
|
||||
|
||||
public void setQuickItem(ItemType itemType, int quickSlotId) {
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int removeEquippedItem(String itemTypeID, int count) {
|
||||
int removed = 0;
|
||||
final Player player = world.model.player;
|
||||
for (Inventory.WearSlot slot : Inventory.WearSlot.values()) {
|
||||
ItemType type = player.inventory.getItemTypeInWearSlot(slot);
|
||||
if (type != null && type.id.equals(itemTypeID)) {
|
||||
player.inventory.setItemTypeInWearSlot(slot, null);
|
||||
controllers.actorStatsController.removeConditionsFromUnequippedItem(player, type);
|
||||
controllers.actorStatsController.recalculatePlayerStats(player);
|
||||
removed++;
|
||||
if (removed >= count) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
public static void applyDamageModifier(Player player) {
|
||||
ItemType itemType = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.weapon);
|
||||
int modifier1 = -1;
|
||||
int modifier2 = -1;
|
||||
if (itemType != null) modifier1 = itemType.effects_equip.stats.setNonWeaponDamageModifier;
|
||||
itemType = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.shield);
|
||||
if (itemType != null && itemType.isWeapon()) modifier2 = itemType.effects_equip.stats.setNonWeaponDamageModifier;
|
||||
|
||||
int modifier = 100;
|
||||
if (modifier1 >= 0 && modifier2 >= 0) {
|
||||
int skillLevelFightStyle = player.getSkillLevel(SkillCollection.SkillID.fightstyleDualWield);
|
||||
if (skillLevelFightStyle == 2) {
|
||||
modifier = Math.max(modifier1, modifier2);
|
||||
} else if (skillLevelFightStyle == 1) {
|
||||
modifier = (modifier1 + modifier2) / 2;
|
||||
} else {
|
||||
modifier = Math.min(modifier1, modifier2);
|
||||
}
|
||||
}
|
||||
else if (modifier1 <= 0 && modifier2 >= 0) modifier = modifier2;
|
||||
else if (modifier2 <= 0 && modifier1 >= 0) modifier = modifier1;
|
||||
|
||||
if (modifier != 100) {
|
||||
final int minBaseDamage = player.damagePotential.current - player.weaponDamage.current;
|
||||
final int maxBaseDamage = player.damagePotential.max - player.weaponDamage.max;
|
||||
player.damagePotential.add(Math.round(minBaseDamage * ((modifier - 100)/100f)), true);
|
||||
player.damagePotential.addToMax(Math.round(maxBaseDamage * ((modifier - 100)/100f)));
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailPreferences;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.listeners.QuickSlotListeners;
|
||||
import com.gpl.rpg.AndorsTrail.model.ModelContainer;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.SkillCollection;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.traits.AbilityModifierTraits;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Inventory;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemContainer;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemContainer.ItemEntry;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemTraits_OnHitReceived;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemTraits_OnUse;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Loot;
|
||||
|
||||
import static java.lang.Math.min;
|
||||
|
||||
public final class ItemController {
|
||||
|
||||
private final ControllerContext controllers;
|
||||
private final WorldContext world;
|
||||
public final QuickSlotListeners quickSlotListeners = new QuickSlotListeners();
|
||||
|
||||
public ItemController(ControllerContext controllers, WorldContext world) {
|
||||
this.controllers = controllers;
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public void dropItem(ItemType type, int quantity) {
|
||||
if (world.model.player.inventory.getItemQuantity(type.id) < quantity) return;
|
||||
world.model.player.inventory.removeItem(type.id, quantity);
|
||||
world.model.currentMaps.map.itemDropped(type, quantity, world.model.player.position);
|
||||
}
|
||||
|
||||
public void equipItem(ItemType type, Inventory.WearSlot slot) {
|
||||
if (!type.isEquippable()) return;
|
||||
final Player player = world.model.player;
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
boolean changed = controllers.actorStatsController.useAPs(player, player.getReequipCost());
|
||||
if (!changed) return;
|
||||
}
|
||||
|
||||
if (!player.inventory.removeItem(type.id, 1)) return;
|
||||
|
||||
unequipSlot(player, slot);
|
||||
if (type.isTwohandWeapon()) unequipSlot(player, Inventory.WearSlot.shield);
|
||||
else if (slot == Inventory.WearSlot.shield) {
|
||||
ItemType currentWeapon = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.weapon);
|
||||
if (currentWeapon != null && currentWeapon.isTwohandWeapon()) unequipSlot(player, Inventory.WearSlot.weapon);
|
||||
}
|
||||
|
||||
player.inventory.setItemTypeInWearSlot(slot, type);
|
||||
controllers.actorStatsController.addConditionsFromEquippedItem(player, type);
|
||||
controllers.actorStatsController.recalculatePlayerStats(player);
|
||||
if (world.model.uiSelections.isInCombat && !controllers.combatController.playerHasApLeft()) {
|
||||
controllers.combatController.endPlayerTurn();
|
||||
}
|
||||
}
|
||||
|
||||
public void unequipSlot(ItemType type, Inventory.WearSlot slot) {
|
||||
if (!type.isEquippable()) return;
|
||||
final Player player = world.model.player;
|
||||
if (player.inventory.isEmptySlot(slot)) return;
|
||||
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
boolean changed = controllers.actorStatsController.useAPs(player, player.getReequipCost());
|
||||
if (!changed) return;
|
||||
}
|
||||
|
||||
unequipSlot(player, slot);
|
||||
controllers.actorStatsController.recalculatePlayerStats(player);
|
||||
if (world.model.uiSelections.isInCombat && !controllers.combatController.playerHasApLeft()) {
|
||||
controllers.combatController.endPlayerTurn();
|
||||
}
|
||||
}
|
||||
|
||||
private void unequipSlot(Player player, Inventory.WearSlot slot) {
|
||||
ItemType removedItemType = player.inventory.getItemTypeInWearSlot(slot);
|
||||
if (removedItemType == null) return;
|
||||
player.inventory.addItem(removedItemType);
|
||||
player.inventory.setItemTypeInWearSlot(slot, null);
|
||||
controllers.actorStatsController.removeConditionsFromUnequippedItem(player, removedItemType);
|
||||
}
|
||||
|
||||
public void useItem(ItemType type) {
|
||||
if (!type.isUsable()) return;
|
||||
final Player player = world.model.player;
|
||||
if (world.model.uiSelections.isInCombat) {
|
||||
boolean changed = controllers.actorStatsController.useAPs(player, player.getUseItemCost());
|
||||
if (!changed) return;
|
||||
}
|
||||
|
||||
if (!player.inventory.removeItem(type.id, 1)) return;
|
||||
|
||||
world.model.combatLog.append(controllers.getResources().getString(R.string.inventory_item_used, type.getName(player)));
|
||||
controllers.actorStatsController.applyUseEffect(player, null, type.effects_use);
|
||||
world.model.statistics.addItemUsage(type);
|
||||
if (world.model.uiSelections.isInCombat && !controllers.combatController.playerHasApLeft()) {
|
||||
controllers.combatController.endPlayerTurn();
|
||||
}
|
||||
}
|
||||
|
||||
public void playerSteppedOnLootBag(Loot loot) {
|
||||
if (pickupLootBagWithoutConfirmation(loot)) {
|
||||
controllers.mapController.worldEventListeners.onPlayerPickedUpGroundLoot(loot);
|
||||
pickupAll(loot);
|
||||
removeLootBagIfEmpty(loot);
|
||||
} else {
|
||||
controllers.mapController.worldEventListeners.onPlayerSteppedOnGroundLoot(loot);
|
||||
consumeNonItemLoot(loot);
|
||||
}
|
||||
}
|
||||
|
||||
public void lootMonsterBags(Collection<Loot> killedMonsterBags, int totalExpThisFight) {
|
||||
if (pickupLootBagsWithoutConfirmation(killedMonsterBags)) {
|
||||
controllers.mapController.worldEventListeners.onPlayerPickedUpMonsterLoot(killedMonsterBags, totalExpThisFight);
|
||||
pickupAll(killedMonsterBags);
|
||||
removeLootBagIfEmpty(killedMonsterBags);
|
||||
controllers.gameRoundController.resume();
|
||||
} else {
|
||||
controllers.mapController.worldEventListeners.onPlayerFoundMonsterLoot(killedMonsterBags, totalExpThisFight);
|
||||
consumeNonItemLoot(killedMonsterBags);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean pickupLootBagWithoutConfirmation(Loot bag) {
|
||||
if (bag.isContainer()) return false;
|
||||
switch (controllers.preferences.displayLoot) {
|
||||
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_ALWAYS:
|
||||
return false;
|
||||
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_FOR_ITEMS:
|
||||
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_FOR_ITEMS_ELSE_TOAST:
|
||||
if (bag.hasItems()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean pickupLootBagsWithoutConfirmation(Collection<Loot> bags) {
|
||||
if (controllers.preferences.displayLoot == AndorsTrailPreferences.DISPLAYLOOT_DIALOG_ALWAYS) return false;
|
||||
for (Loot bag : bags) {
|
||||
if (!pickupLootBagWithoutConfirmation(bag)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void applyInventoryEffects(Player player) {
|
||||
ItemType weapon = getMainWeapon(player);
|
||||
if (weapon != null) {
|
||||
player.attackCost = 0;
|
||||
player.criticalMultiplier = weapon.effects_equip.stats.setCriticalMultiplier;
|
||||
}
|
||||
|
||||
applyInventoryEffects(player, Inventory.WearSlot.weapon);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.shield);
|
||||
SkillController.applySkillEffectsFromFightingStyles(player);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.head);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.body);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.hand);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.feet);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.neck);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.leftring);
|
||||
applyInventoryEffects(player, Inventory.WearSlot.rightring);
|
||||
SkillController.applySkillEffectsFromItemProficiencies(player);
|
||||
}
|
||||
public static ItemType getMainWeapon(Player player) {
|
||||
ItemType itemType = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.weapon);
|
||||
if (itemType != null) return itemType;
|
||||
itemType = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.shield);
|
||||
if (itemType != null && itemType.isWeapon()) return itemType;
|
||||
return null;
|
||||
}
|
||||
|
||||
private void applyInventoryEffects(Player player, Inventory.WearSlot slot) {
|
||||
ItemType type = player.inventory.getItemTypeInWearSlot(slot);
|
||||
if (type == null) return;
|
||||
if (slot == Inventory.WearSlot.shield) {
|
||||
ItemType mainHandItem = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.weapon);
|
||||
// The stats for off-hand weapons will be added later in SkillController.applySkillEffectsFromFightingStyles
|
||||
if (SkillController.isDualWielding(mainHandItem, type)) return;
|
||||
}
|
||||
if (type.effects_equip != null && type.effects_equip.stats != null) {
|
||||
controllers.actorStatsController.applyAbilityEffects(player, type.effects_equip.stats, 1);
|
||||
if (type.isWeapon()) {
|
||||
controllers.actorStatsController.addPlayerWeaponDamage(player, type.effects_equip.stats.increaseMinDamage, type.effects_equip.stats.increaseMaxDamage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void recalculateHitEffectsFromWornItems(Player player) {
|
||||
ArrayList<ItemTraits_OnUse> effects_onHit = null;
|
||||
ArrayList<ItemTraits_OnHitReceived> effects_onHitReceived = null;
|
||||
for (Inventory.WearSlot slot : Inventory.WearSlot.values()) {
|
||||
ItemType type = player.inventory.getItemTypeInWearSlot(slot);
|
||||
if (type == null) continue;
|
||||
ItemTraits_OnUse eh = type.effects_hit;
|
||||
ItemTraits_OnHitReceived ehr = type.effects_hitReceived;
|
||||
if (eh == null && ehr == null) continue;
|
||||
|
||||
if (effects_onHit == null) effects_onHit = new ArrayList<ItemTraits_OnUse>();
|
||||
if (eh != null) effects_onHit.add(eh);
|
||||
|
||||
if (effects_onHitReceived == null) effects_onHitReceived = new ArrayList<ItemTraits_OnHitReceived>();
|
||||
if (ehr != null) effects_onHitReceived.add(ehr);
|
||||
}
|
||||
|
||||
if (effects_onHit != null) {
|
||||
ItemTraits_OnUse[] effects_ = new ItemTraits_OnUse[effects_onHit.size()];
|
||||
effects_ = effects_onHit.toArray(effects_);
|
||||
player.onHitEffects = effects_;
|
||||
} else {
|
||||
player.onHitEffects = null;
|
||||
}
|
||||
|
||||
if (effects_onHitReceived != null) {
|
||||
ItemTraits_OnHitReceived[] effects_ = new ItemTraits_OnHitReceived[effects_onHitReceived.size()];
|
||||
effects_ = effects_onHitReceived.toArray(effects_);
|
||||
player.onHitReceivedEffects = effects_;
|
||||
} else {
|
||||
player.onHitReceivedEffects = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void consumeNonItemLoot(Loot loot) {
|
||||
// Experience will be given as soon as the monster is killed.
|
||||
world.model.player.inventory.gold += loot.gold;
|
||||
loot.gold = 0;
|
||||
removeLootBagIfEmpty(loot);
|
||||
}
|
||||
public void consumeNonItemLoot(Iterable<Loot> lootBags) {
|
||||
for(Loot l : lootBags) {
|
||||
consumeNonItemLoot(l);
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
for(Loot l : lootBags) {
|
||||
pickupAll(l);
|
||||
}
|
||||
}
|
||||
public boolean removeLootBagIfEmpty(final Loot loot) {
|
||||
if (loot.hasItemsOrGold()) return false;
|
||||
|
||||
world.model.currentMaps.map.removeGroundLoot(loot);
|
||||
controllers.mapController.mapLayoutListeners.onLootBagRemoved(world.model.currentMaps.map, loot.position);
|
||||
return true; // The bag was removed.
|
||||
}
|
||||
|
||||
public boolean removeLootBagIfEmpty(final Iterable<Loot> lootBags) {
|
||||
boolean isEmpty = true;
|
||||
for (Loot l : lootBags) {
|
||||
if (!removeLootBagIfEmpty(l)) isEmpty = false;
|
||||
}
|
||||
return isEmpty;
|
||||
}
|
||||
|
||||
private static int getMarketPriceFactor(Player player) {
|
||||
return Constants.MARKET_PRICEFACTOR_PERCENT
|
||||
- player.getSkillLevel(SkillCollection.SkillID.barter) * SkillCollection.PER_SKILLPOINT_INCREASE_BARTER_PRICEFACTOR_PERCENTAGE;
|
||||
}
|
||||
public static int getBuyingPrice(Player player, ItemType itemType) {
|
||||
return itemType.baseMarketCost + itemType.baseMarketCost * getMarketPriceFactor(player) / 100;
|
||||
}
|
||||
public static int getSellingPrice(Player player, ItemType itemType) {
|
||||
return itemType.baseMarketCost - itemType.baseMarketCost * getMarketPriceFactor(player) / 100;
|
||||
}
|
||||
|
||||
public static boolean canAfford(Player player, ItemType itemType) {
|
||||
return player.inventory.gold >= getBuyingPrice(player, itemType);
|
||||
}
|
||||
public static boolean canAfford(Player player, int price) {
|
||||
return player.inventory.gold >= price;
|
||||
}
|
||||
public static boolean maySellItem(Player player, ItemType itemType) {
|
||||
if (!itemType.isSellable()) return false;
|
||||
return true;
|
||||
}
|
||||
public static boolean sell(Player player, ItemType itemType, ItemContainer merchant, int quantity) {
|
||||
int price = getSellingPrice(player, itemType) * quantity;
|
||||
if (!maySellItem(player, itemType)) return false;
|
||||
if (!player.inventory.removeItem(itemType.id, quantity)) return false;
|
||||
player.inventory.gold += price;
|
||||
merchant.addItem(itemType, quantity);
|
||||
return true;
|
||||
}
|
||||
public static boolean buy(ModelContainer model, Player player, ItemType itemType, ItemContainer merchant, int quantity) {
|
||||
int price = getBuyingPrice(player, itemType) * quantity;
|
||||
if (!canAfford(player, price)) return false;
|
||||
if (!merchant.removeItem(itemType.id, quantity)) return false;
|
||||
player.inventory.gold -= price;
|
||||
player.inventory.addItem(itemType, quantity);
|
||||
model.statistics.addGoldSpent(price);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static String describeItemForListView(ItemEntry item, Player player) {
|
||||
StringBuilder sb = new StringBuilder(item.itemType.getName(player));
|
||||
if (item.quantity > 1) {
|
||||
sb.append(" (");
|
||||
sb.append(item.quantity);
|
||||
sb.append(')');
|
||||
}
|
||||
if (item.itemType.effects_equip != null) {
|
||||
AbilityModifierTraits t = item.itemType.effects_equip.stats;
|
||||
if (t != null) {
|
||||
if (t.increaseAttackChance != 0
|
||||
|| t.increaseMinDamage != 0
|
||||
|| t.increaseMaxDamage != 0
|
||||
|| t.increaseCriticalSkill != 0
|
||||
|| t.setCriticalMultiplier != 0) {
|
||||
sb.append(" [");
|
||||
describeAttackEffect(t.increaseAttackChance, t.increaseMinDamage, t.increaseMaxDamage, t.increaseCriticalSkill, t.setCriticalMultiplier, sb);
|
||||
sb.append(']');
|
||||
}
|
||||
if (t.increaseBlockChance != 0
|
||||
|| t.increaseDamageResistance != 0) {
|
||||
sb.append(" [");
|
||||
describeBlockEffect(t.increaseBlockChance, t.increaseDamageResistance, sb);
|
||||
sb.append(']');
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static void describeAttackEffect(int attackChance, int minDamage, int maxDamage, int criticalSkill, float criticalMultiplier, StringBuilder sb) {
|
||||
boolean addSpace = false;
|
||||
if (attackChance != 0) {
|
||||
sb.append(attackChance);
|
||||
addSpace = true;
|
||||
}
|
||||
if (minDamage != 0 || maxDamage != 0) {
|
||||
if (addSpace) sb.append(' ');
|
||||
sb.append(minDamage);
|
||||
if (minDamage != maxDamage) {
|
||||
sb.append('-');
|
||||
sb.append(maxDamage);
|
||||
}
|
||||
addSpace = true;
|
||||
}
|
||||
if (criticalSkill != 0) {
|
||||
if (addSpace) sb.append(' ');
|
||||
if (criticalSkill >= 0) {
|
||||
sb.append('+');
|
||||
}
|
||||
sb.append(criticalSkill);
|
||||
}
|
||||
if (criticalMultiplier != 0 && criticalMultiplier != 1) {
|
||||
sb.append('x');
|
||||
sb.append(criticalMultiplier);
|
||||
}
|
||||
}
|
||||
|
||||
public static void describeBlockEffect(int blockChance, int damageResistance, StringBuilder sb) {
|
||||
if (blockChance != 0) {
|
||||
sb.append(blockChance);
|
||||
}
|
||||
if (damageResistance != 0) {
|
||||
sb.append('/');
|
||||
sb.append(damageResistance);
|
||||
}
|
||||
}
|
||||
|
||||
public void quickitemUse(int quickSlotId) {
|
||||
useItem(world.model.player.inventory.quickitem[quickSlotId]);
|
||||
quickSlotListeners.onQuickSlotUsed(quickSlotId);
|
||||
}
|
||||
|
||||
public void setQuickItem(ItemType itemType, int quickSlotId) {
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int removeEquippedItem(String itemTypeID, int count) {
|
||||
int removed = 0;
|
||||
final Player player = world.model.player;
|
||||
for (Inventory.WearSlot slot : Inventory.WearSlot.values()) {
|
||||
ItemType type = player.inventory.getItemTypeInWearSlot(slot);
|
||||
if (type != null && type.id.equals(itemTypeID)) {
|
||||
player.inventory.setItemTypeInWearSlot(slot, null);
|
||||
controllers.actorStatsController.removeConditionsFromUnequippedItem(player, type);
|
||||
controllers.actorStatsController.recalculatePlayerStats(player);
|
||||
removed++;
|
||||
if (removed >= count) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
public static void applyDamageModifier(Player player) {
|
||||
ItemType itemType = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.weapon);
|
||||
int modifier1 = -1;
|
||||
int modifier2 = -1;
|
||||
if (itemType != null) modifier1 = itemType.effects_equip.stats.setNonWeaponDamageModifier;
|
||||
itemType = player.inventory.getItemTypeInWearSlot(Inventory.WearSlot.shield);
|
||||
if (itemType != null && itemType.isWeapon()) modifier2 = itemType.effects_equip.stats.setNonWeaponDamageModifier;
|
||||
|
||||
int modifier = 100;
|
||||
if (modifier1 >= 0 && modifier2 >= 0) {
|
||||
int skillLevelFightStyle = player.getSkillLevel(SkillCollection.SkillID.fightstyleDualWield);
|
||||
if (skillLevelFightStyle == 2) {
|
||||
modifier = Math.max(modifier1, modifier2);
|
||||
} else if (skillLevelFightStyle == 1) {
|
||||
modifier = (modifier1 + modifier2) / 2;
|
||||
} else {
|
||||
modifier = Math.min(modifier1, modifier2);
|
||||
}
|
||||
}
|
||||
else if (modifier1 <= 0 && modifier2 >= 0) modifier = modifier2;
|
||||
else if (modifier2 <= 0 && modifier1 >= 0) modifier = modifier1;
|
||||
|
||||
if (modifier != 100) {
|
||||
final int minBaseDamage = player.damagePotential.current - player.weaponDamage.current;
|
||||
final int maxBaseDamage = player.damagePotential.max - player.weaponDamage.max;
|
||||
player.damagePotential.add(Math.round(minBaseDamage * ((modifier - 100)/100f)), true);
|
||||
player.damagePotential.addToMax(Math.round(maxBaseDamage * ((modifier - 100)/100f)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,317 +1,317 @@
|
||||
package com.gpl.rpg.AndorsTrail.controller;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.os.AsyncTask;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.activity.DisplayWorldMapActivity;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.LayeredTileMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.MapLayer;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment.NamedWorldMapArea;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment.WorldMapSegmentMap;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
|
||||
import com.gpl.rpg.AndorsTrail.util.AndroidStorage;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
import com.gpl.rpg.AndorsTrail.util.CoordRect;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.Size;
|
||||
|
||||
public final class WorldMapController {
|
||||
|
||||
private static final int WORLDMAP_SCREENSHOT_TILESIZE = 8;
|
||||
public static final int WORLDMAP_DISPLAY_TILESIZE = WORLDMAP_SCREENSHOT_TILESIZE;
|
||||
|
||||
public static void updateWorldMap(Context context, final WorldContext world, final Resources res) {
|
||||
updateWorldMap(context, world, world.model.currentMaps.map, world.model.currentMaps.tileMap, world.model.currentMaps.tiles, res);
|
||||
}
|
||||
|
||||
private static void updateWorldMap(
|
||||
Context context, final WorldContext world,
|
||||
final PredefinedMap map,
|
||||
final LayeredTileMap mapTiles,
|
||||
final TileCollection cachedTiles,
|
||||
final Resources res) {
|
||||
final String worldMapSegmentName = world.maps.getWorldMapSegmentNameForMap(map.name);
|
||||
if (worldMapSegmentName == null) return;
|
||||
|
||||
if (!shouldUpdateWorldMap(context, map, worldMapSegmentName, world.maps.worldMapRequiresUpdate)) return;
|
||||
|
||||
(new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... arg0) {
|
||||
final MapRenderer renderer = new MapRenderer(world, map, mapTiles, cachedTiles);
|
||||
try {
|
||||
updateCachedBitmap(context, map, renderer);
|
||||
updateWorldMapSegment(context, res, world, worldMapSegmentName);
|
||||
world.maps.worldMapRequiresUpdate = false;
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) {
|
||||
L.log("WorldMapController: Updated worldmap segment " + worldMapSegmentName + " for map " + map.name);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
L.log("Error creating worldmap file for map " + map.name + " : " + e.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}).execute();
|
||||
}
|
||||
|
||||
private static boolean shouldUpdateWorldMap(Context context, PredefinedMap map, String worldMapSegmentName, boolean forceUpdate) {
|
||||
if (forceUpdate) return true;
|
||||
if (!map.visited) return true;
|
||||
File file = getFileForMap(context, map, false);
|
||||
if (!file.exists()) return true;
|
||||
|
||||
file = getCombinedWorldMapFile(context, worldMapSegmentName);
|
||||
if (!file.exists()) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void updateCachedBitmap(Context context, PredefinedMap map, MapRenderer renderer) throws IOException {
|
||||
ensureWorldmapDirectoryExists(context);
|
||||
|
||||
File file = getFileForMap(context, map, false);
|
||||
if (file.exists()) return;
|
||||
|
||||
Bitmap image = renderer.drawMap();
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
image.compress(Bitmap.CompressFormat.PNG, 70, fos);
|
||||
fos.flush();
|
||||
fos.close();
|
||||
image.recycle();
|
||||
L.log("WorldMapController: Wrote " + file.getAbsolutePath());
|
||||
}
|
||||
|
||||
private static final class MapRenderer {
|
||||
private final PredefinedMap map;
|
||||
private final LayeredTileMap mapTiles;
|
||||
private final TileCollection cachedTiles;
|
||||
private final int tileSize;
|
||||
private final float scale;
|
||||
private final Paint mPaint = new Paint();
|
||||
|
||||
public MapRenderer(final WorldContext world, final PredefinedMap map, final LayeredTileMap mapTiles, final TileCollection cachedTiles) {
|
||||
this.map = map;
|
||||
this.mapTiles = mapTiles;
|
||||
this.cachedTiles = cachedTiles;
|
||||
this.tileSize = world.tileManager.tileSize;
|
||||
this.scale = (float) WORLDMAP_SCREENSHOT_TILESIZE / world.tileManager.tileSize;
|
||||
mapTiles.setColorFilter(mPaint, null, true);
|
||||
}
|
||||
|
||||
public Bitmap drawMap() {
|
||||
Bitmap image = Bitmap.createBitmap(map.size.width * WORLDMAP_SCREENSHOT_TILESIZE, map.size.height * WORLDMAP_SCREENSHOT_TILESIZE, Config.RGB_565);
|
||||
image.setDensity(Bitmap.DENSITY_NONE);
|
||||
Canvas canvas = new Canvas(image);
|
||||
canvas.scale(scale, scale);
|
||||
|
||||
synchronized (cachedTiles) {
|
||||
tryDrawMapLayer(canvas, mapTiles.currentLayout.layerBase);
|
||||
tryDrawMapLayer(canvas, mapTiles.currentLayout.layerGround);
|
||||
tryDrawMapLayer(canvas, mapTiles.currentLayout.layerObjects);
|
||||
tryDrawMapLayer(canvas, mapTiles.currentLayout.layerAbove);
|
||||
tryDrawMapLayer(canvas, mapTiles.currentLayout.layerTop);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
private void tryDrawMapLayer(Canvas canvas, final MapLayer layer) {
|
||||
if (layer != null) drawMapLayer(canvas, layer);
|
||||
}
|
||||
|
||||
private void drawMapLayer(Canvas canvas, final MapLayer layer) {
|
||||
int py = 0;
|
||||
for (int y = 0; y < map.size.height; ++y, py += tileSize) {
|
||||
int px = 0;
|
||||
for (int x = 0; x < map.size.width; ++x, px += tileSize) {
|
||||
final int tile = layer.tiles[x][y];
|
||||
if (tile == 0) continue;
|
||||
cachedTiles.drawTile(canvas, tile, px, py, mPaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void ensureWorldmapDirectoryExists(Context context) throws IOException {
|
||||
File dir = AndroidStorage.getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
if (!dir.exists()) dir.mkdir();
|
||||
dir = new File(dir, Constants.FILENAME_WORLDMAP_DIRECTORY);
|
||||
if (!dir.exists()) dir.mkdir();
|
||||
|
||||
File noMediaFile = new File(dir, ".nomedia");
|
||||
if (!noMediaFile.exists()) noMediaFile.createNewFile();
|
||||
}
|
||||
public static boolean fileForMapExists(Context context, PredefinedMap map) {
|
||||
if (map.lastSeenLayoutHash.length() > 0) {
|
||||
return getPngFile(context, map.name + '.' + map.lastSeenLayoutHash).exists();
|
||||
}
|
||||
return getPngFile(context, map.name).exists();
|
||||
}
|
||||
private static File getFileForMap(Context context, PredefinedMap map, boolean verifyFileExists) {
|
||||
if (map.lastSeenLayoutHash.length() > 0) {
|
||||
File fileWithHash = getPngFile(context, map.name + '.' + map.lastSeenLayoutHash);
|
||||
if (!verifyFileExists) return fileWithHash;
|
||||
else if (fileWithHash.exists()) return fileWithHash;
|
||||
}
|
||||
return getPngFile(context, map.name);
|
||||
}
|
||||
private static File getPngFile(Context context, String fileName) {
|
||||
return new File(getWorldmapDirectory(context), fileName + ".png");
|
||||
}
|
||||
private static File getWorldmapDirectory(Context context) {
|
||||
File dir = AndroidStorage.getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
return new File(dir, Constants.FILENAME_WORLDMAP_DIRECTORY);
|
||||
}
|
||||
public static File getCombinedWorldMapFile(Context context, String segmentName) {
|
||||
return new File(getWorldmapDirectory(context), Constants.FILENAME_WORLDMAP_HTMLFILE_PREFIX + segmentName + Constants.FILENAME_WORLDMAP_HTMLFILE_SUFFIX);
|
||||
}
|
||||
|
||||
private static String getWorldMapSegmentAsHtml(Context context, Resources res, WorldContext world, String segmentName) {
|
||||
WorldMapSegment segment = world.maps.worldMapSegments.get(segmentName);
|
||||
|
||||
Map<String, File> displayedMapFilenamesPerMapName = new HashMap<String, File>(segment.maps.size());
|
||||
Coord offsetWorldmapTo = new Coord(999999, 999999);
|
||||
for (WorldMapSegmentMap map : segment.maps.values()) {
|
||||
PredefinedMap predefinedMap = world.maps.findPredefinedMap(map.mapName);
|
||||
if (predefinedMap == null) continue;
|
||||
if (!predefinedMap.visited) continue;
|
||||
File f = WorldMapController.getFileForMap(context, predefinedMap, true);
|
||||
if (!f.exists()) continue;
|
||||
displayedMapFilenamesPerMapName.put(map.mapName, f);
|
||||
|
||||
offsetWorldmapTo.x = Math.min(offsetWorldmapTo.x, map.worldPosition.x);
|
||||
offsetWorldmapTo.y = Math.min(offsetWorldmapTo.y, map.worldPosition.y);
|
||||
}
|
||||
|
||||
Coord bottomRight = new Coord(0, 0);
|
||||
|
||||
StringBuilder mapsAsHtml = new StringBuilder(1000);
|
||||
for (WorldMapSegmentMap segmentMap : segment.maps.values()) {
|
||||
File f = displayedMapFilenamesPerMapName.get(segmentMap.mapName);
|
||||
if (f == null) continue;
|
||||
|
||||
Size size = getMapSize(segmentMap, world);
|
||||
mapsAsHtml
|
||||
.append("<img src=\"")
|
||||
.append(f.getName())
|
||||
.append("\" id=\"")
|
||||
.append(segmentMap.mapName)
|
||||
.append("\" style=\"width:")
|
||||
.append(size.width * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; height:")
|
||||
.append(size.height * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; left:")
|
||||
.append((segmentMap.worldPosition.x - offsetWorldmapTo.x) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; top:")
|
||||
.append((segmentMap.worldPosition.y - offsetWorldmapTo.y) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px;\" />");
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) mapsAsHtml.append('\n');
|
||||
|
||||
bottomRight.x = Math.max(bottomRight.x, segmentMap.worldPosition.x + size.width);
|
||||
bottomRight.y = Math.max(bottomRight.y, segmentMap.worldPosition.y + size.height);
|
||||
}
|
||||
Size worldmapSegmentSize = new Size(
|
||||
(bottomRight.x - offsetWorldmapTo.x) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE
|
||||
,(bottomRight.y - offsetWorldmapTo.y) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE
|
||||
);
|
||||
|
||||
StringBuilder namedAreasAsHtml = new StringBuilder(500);
|
||||
for (NamedWorldMapArea area : segment.namedAreas.values()) {
|
||||
CoordRect r = determineNamedAreaBoundary(area, segment, world, displayedMapFilenamesPerMapName.keySet());
|
||||
if (r == null) continue;
|
||||
namedAreasAsHtml
|
||||
.append("<div class=\"namedarea ")
|
||||
.append(area.type)
|
||||
.append("\" style=\"width:")
|
||||
.append(r.size.width * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; line-height:")
|
||||
.append(r.size.height * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; left:")
|
||||
.append((r.topLeft.x - offsetWorldmapTo.x) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; top:")
|
||||
.append((r.topLeft.y - offsetWorldmapTo.y) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px;\"><span>")
|
||||
.append(area.name)
|
||||
.append("</span></div>");
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) namedAreasAsHtml.append('\n');
|
||||
}
|
||||
|
||||
return res.getString(R.string.worldmap_template)
|
||||
.replace("{{maps}}", mapsAsHtml.toString())
|
||||
.replace("{{areas}}", namedAreasAsHtml.toString())
|
||||
.replace("{{sizex}}", Integer.toString(worldmapSegmentSize.width))
|
||||
.replace("{{sizey}}", Integer.toString(worldmapSegmentSize.height))
|
||||
.replace("{{offsetx}}", Integer.toString(offsetWorldmapTo.x * WorldMapController.WORLDMAP_DISPLAY_TILESIZE))
|
||||
.replace("{{offsety}}", Integer.toString(offsetWorldmapTo.y * WorldMapController.WORLDMAP_DISPLAY_TILESIZE));
|
||||
}
|
||||
|
||||
private static Size getMapSize(WorldMapSegmentMap map, WorldContext world) {
|
||||
return world.maps.findPredefinedMap(map.mapName).size;
|
||||
}
|
||||
|
||||
private static CoordRect determineNamedAreaBoundary(NamedWorldMapArea area, WorldMapSegment segment, WorldContext world, Set<String> displayedMapNames) {
|
||||
Coord topLeft = null;
|
||||
Coord bottomRight = null;
|
||||
|
||||
for (String mapName : area.mapNames) {
|
||||
if (!displayedMapNames.contains(mapName)) continue;
|
||||
WorldMapSegmentMap map = segment.maps.get(mapName);
|
||||
Size size = getMapSize(map, world);
|
||||
if (topLeft == null) {
|
||||
topLeft = new Coord(map.worldPosition);
|
||||
} else {
|
||||
topLeft.x = Math.min(topLeft.x, map.worldPosition.x);
|
||||
topLeft.y = Math.min(topLeft.y, map.worldPosition.y);
|
||||
}
|
||||
if (bottomRight == null) {
|
||||
bottomRight = new Coord(map.worldPosition.x + size.width, map.worldPosition.y + size.height);
|
||||
} else {
|
||||
bottomRight.x = Math.max(bottomRight.x, map.worldPosition.x + size.width);
|
||||
bottomRight.y = Math.max(bottomRight.y, map.worldPosition.y + size.height);
|
||||
}
|
||||
}
|
||||
if (topLeft == null) return null;
|
||||
return new CoordRect(topLeft, new Size(bottomRight.x - topLeft.x, bottomRight.y - topLeft.y));
|
||||
}
|
||||
|
||||
public static void updateWorldMapSegment(Context context, Resources res, WorldContext world, String segmentName) throws IOException {
|
||||
String mapAsHtml = getWorldMapSegmentAsHtml(context, res, world, segmentName);
|
||||
File outputFile = getCombinedWorldMapFile(context, segmentName);
|
||||
PrintWriter pw = new PrintWriter(outputFile);
|
||||
pw.write(mapAsHtml);
|
||||
pw.close();
|
||||
}
|
||||
|
||||
public static boolean displayWorldMap(Context context, WorldContext world) {
|
||||
String worldMapSegmentName = world.maps.getWorldMapSegmentNameForMap(world.model.currentMaps.map.name);
|
||||
if (worldMapSegmentName == null) {
|
||||
Toast.makeText(context, context.getResources().getString(R.string.display_worldmap_not_available), Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
Intent intent = new Intent(context, DisplayWorldMapActivity.class);
|
||||
intent.putExtra("worldMapSegmentName", worldMapSegmentName);
|
||||
context.startActivity(intent);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.controller;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.os.AsyncTask;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.activity.DisplayWorldMapActivity;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.LayeredTileMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.MapLayer;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment.NamedWorldMapArea;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment.WorldMapSegmentMap;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
|
||||
import com.gpl.rpg.AndorsTrail.util.AndroidStorage;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
import com.gpl.rpg.AndorsTrail.util.CoordRect;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.Size;
|
||||
|
||||
public final class WorldMapController {
|
||||
|
||||
private static final int WORLDMAP_SCREENSHOT_TILESIZE = 8;
|
||||
public static final int WORLDMAP_DISPLAY_TILESIZE = WORLDMAP_SCREENSHOT_TILESIZE;
|
||||
|
||||
public static void updateWorldMap(Context context, final WorldContext world, final Resources res) {
|
||||
updateWorldMap(context, world, world.model.currentMaps.map, world.model.currentMaps.tileMap, world.model.currentMaps.tiles, res);
|
||||
}
|
||||
|
||||
private static void updateWorldMap(
|
||||
Context context, final WorldContext world,
|
||||
final PredefinedMap map,
|
||||
final LayeredTileMap mapTiles,
|
||||
final TileCollection cachedTiles,
|
||||
final Resources res) {
|
||||
final String worldMapSegmentName = world.maps.getWorldMapSegmentNameForMap(map.name);
|
||||
if (worldMapSegmentName == null) return;
|
||||
|
||||
if (!shouldUpdateWorldMap(context, map, worldMapSegmentName, world.maps.worldMapRequiresUpdate)) return;
|
||||
|
||||
(new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... arg0) {
|
||||
final MapRenderer renderer = new MapRenderer(world, map, mapTiles, cachedTiles);
|
||||
try {
|
||||
updateCachedBitmap(context, map, renderer);
|
||||
updateWorldMapSegment(context, res, world, worldMapSegmentName);
|
||||
world.maps.worldMapRequiresUpdate = false;
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) {
|
||||
L.log("WorldMapController: Updated worldmap segment " + worldMapSegmentName + " for map " + map.name);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
L.log("Error creating worldmap file for map " + map.name + " : " + e.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}).execute();
|
||||
}
|
||||
|
||||
private static boolean shouldUpdateWorldMap(Context context, PredefinedMap map, String worldMapSegmentName, boolean forceUpdate) {
|
||||
if (forceUpdate) return true;
|
||||
if (!map.visited) return true;
|
||||
File file = getFileForMap(context, map, false);
|
||||
if (!file.exists()) return true;
|
||||
|
||||
file = getCombinedWorldMapFile(context, worldMapSegmentName);
|
||||
if (!file.exists()) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void updateCachedBitmap(Context context, PredefinedMap map, MapRenderer renderer) throws IOException {
|
||||
ensureWorldmapDirectoryExists(context);
|
||||
|
||||
File file = getFileForMap(context, map, false);
|
||||
if (file.exists()) return;
|
||||
|
||||
Bitmap image = renderer.drawMap();
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
image.compress(Bitmap.CompressFormat.PNG, 70, fos);
|
||||
fos.flush();
|
||||
fos.close();
|
||||
image.recycle();
|
||||
L.log("WorldMapController: Wrote " + file.getAbsolutePath());
|
||||
}
|
||||
|
||||
private static final class MapRenderer {
|
||||
private final PredefinedMap map;
|
||||
private final LayeredTileMap mapTiles;
|
||||
private final TileCollection cachedTiles;
|
||||
private final int tileSize;
|
||||
private final float scale;
|
||||
private final Paint mPaint = new Paint();
|
||||
|
||||
public MapRenderer(final WorldContext world, final PredefinedMap map, final LayeredTileMap mapTiles, final TileCollection cachedTiles) {
|
||||
this.map = map;
|
||||
this.mapTiles = mapTiles;
|
||||
this.cachedTiles = cachedTiles;
|
||||
this.tileSize = world.tileManager.tileSize;
|
||||
this.scale = (float) WORLDMAP_SCREENSHOT_TILESIZE / world.tileManager.tileSize;
|
||||
mapTiles.setColorFilter(mPaint, null, true);
|
||||
}
|
||||
|
||||
public Bitmap drawMap() {
|
||||
Bitmap image = Bitmap.createBitmap(map.size.width * WORLDMAP_SCREENSHOT_TILESIZE, map.size.height * WORLDMAP_SCREENSHOT_TILESIZE, Config.RGB_565);
|
||||
image.setDensity(Bitmap.DENSITY_NONE);
|
||||
Canvas canvas = new Canvas(image);
|
||||
canvas.scale(scale, scale);
|
||||
|
||||
synchronized (cachedTiles) {
|
||||
tryDrawMapLayer(canvas, mapTiles.currentLayout.layerBase);
|
||||
tryDrawMapLayer(canvas, mapTiles.currentLayout.layerGround);
|
||||
tryDrawMapLayer(canvas, mapTiles.currentLayout.layerObjects);
|
||||
tryDrawMapLayer(canvas, mapTiles.currentLayout.layerAbove);
|
||||
tryDrawMapLayer(canvas, mapTiles.currentLayout.layerTop);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
private void tryDrawMapLayer(Canvas canvas, final MapLayer layer) {
|
||||
if (layer != null) drawMapLayer(canvas, layer);
|
||||
}
|
||||
|
||||
private void drawMapLayer(Canvas canvas, final MapLayer layer) {
|
||||
int py = 0;
|
||||
for (int y = 0; y < map.size.height; ++y, py += tileSize) {
|
||||
int px = 0;
|
||||
for (int x = 0; x < map.size.width; ++x, px += tileSize) {
|
||||
final int tile = layer.tiles[x][y];
|
||||
if (tile == 0) continue;
|
||||
cachedTiles.drawTile(canvas, tile, px, py, mPaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void ensureWorldmapDirectoryExists(Context context) throws IOException {
|
||||
File dir = AndroidStorage.getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
if (!dir.exists()) dir.mkdir();
|
||||
dir = new File(dir, Constants.FILENAME_WORLDMAP_DIRECTORY);
|
||||
if (!dir.exists()) dir.mkdir();
|
||||
|
||||
File noMediaFile = new File(dir, ".nomedia");
|
||||
if (!noMediaFile.exists()) noMediaFile.createNewFile();
|
||||
}
|
||||
public static boolean fileForMapExists(Context context, PredefinedMap map) {
|
||||
if (map.lastSeenLayoutHash.length() > 0) {
|
||||
return getPngFile(context, map.name + '.' + map.lastSeenLayoutHash).exists();
|
||||
}
|
||||
return getPngFile(context, map.name).exists();
|
||||
}
|
||||
private static File getFileForMap(Context context, PredefinedMap map, boolean verifyFileExists) {
|
||||
if (map.lastSeenLayoutHash.length() > 0) {
|
||||
File fileWithHash = getPngFile(context, map.name + '.' + map.lastSeenLayoutHash);
|
||||
if (!verifyFileExists) return fileWithHash;
|
||||
else if (fileWithHash.exists()) return fileWithHash;
|
||||
}
|
||||
return getPngFile(context, map.name);
|
||||
}
|
||||
private static File getPngFile(Context context, String fileName) {
|
||||
return new File(getWorldmapDirectory(context), fileName + ".png");
|
||||
}
|
||||
private static File getWorldmapDirectory(Context context) {
|
||||
File dir = AndroidStorage.getStorageDirectory(context, Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
return new File(dir, Constants.FILENAME_WORLDMAP_DIRECTORY);
|
||||
}
|
||||
public static File getCombinedWorldMapFile(Context context, String segmentName) {
|
||||
return new File(getWorldmapDirectory(context), Constants.FILENAME_WORLDMAP_HTMLFILE_PREFIX + segmentName + Constants.FILENAME_WORLDMAP_HTMLFILE_SUFFIX);
|
||||
}
|
||||
|
||||
private static String getWorldMapSegmentAsHtml(Context context, Resources res, WorldContext world, String segmentName) {
|
||||
WorldMapSegment segment = world.maps.worldMapSegments.get(segmentName);
|
||||
|
||||
Map<String, File> displayedMapFilenamesPerMapName = new HashMap<String, File>(segment.maps.size());
|
||||
Coord offsetWorldmapTo = new Coord(999999, 999999);
|
||||
for (WorldMapSegmentMap map : segment.maps.values()) {
|
||||
PredefinedMap predefinedMap = world.maps.findPredefinedMap(map.mapName);
|
||||
if (predefinedMap == null) continue;
|
||||
if (!predefinedMap.visited) continue;
|
||||
File f = WorldMapController.getFileForMap(context, predefinedMap, true);
|
||||
if (!f.exists()) continue;
|
||||
displayedMapFilenamesPerMapName.put(map.mapName, f);
|
||||
|
||||
offsetWorldmapTo.x = Math.min(offsetWorldmapTo.x, map.worldPosition.x);
|
||||
offsetWorldmapTo.y = Math.min(offsetWorldmapTo.y, map.worldPosition.y);
|
||||
}
|
||||
|
||||
Coord bottomRight = new Coord(0, 0);
|
||||
|
||||
StringBuilder mapsAsHtml = new StringBuilder(1000);
|
||||
for (WorldMapSegmentMap segmentMap : segment.maps.values()) {
|
||||
File f = displayedMapFilenamesPerMapName.get(segmentMap.mapName);
|
||||
if (f == null) continue;
|
||||
|
||||
Size size = getMapSize(segmentMap, world);
|
||||
mapsAsHtml
|
||||
.append("<img src=\"")
|
||||
.append(f.getName())
|
||||
.append("\" id=\"")
|
||||
.append(segmentMap.mapName)
|
||||
.append("\" style=\"width:")
|
||||
.append(size.width * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; height:")
|
||||
.append(size.height * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; left:")
|
||||
.append((segmentMap.worldPosition.x - offsetWorldmapTo.x) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; top:")
|
||||
.append((segmentMap.worldPosition.y - offsetWorldmapTo.y) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px;\" />");
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) mapsAsHtml.append('\n');
|
||||
|
||||
bottomRight.x = Math.max(bottomRight.x, segmentMap.worldPosition.x + size.width);
|
||||
bottomRight.y = Math.max(bottomRight.y, segmentMap.worldPosition.y + size.height);
|
||||
}
|
||||
Size worldmapSegmentSize = new Size(
|
||||
(bottomRight.x - offsetWorldmapTo.x) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE
|
||||
,(bottomRight.y - offsetWorldmapTo.y) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE
|
||||
);
|
||||
|
||||
StringBuilder namedAreasAsHtml = new StringBuilder(500);
|
||||
for (NamedWorldMapArea area : segment.namedAreas.values()) {
|
||||
CoordRect r = determineNamedAreaBoundary(area, segment, world, displayedMapFilenamesPerMapName.keySet());
|
||||
if (r == null) continue;
|
||||
namedAreasAsHtml
|
||||
.append("<div class=\"namedarea ")
|
||||
.append(area.type)
|
||||
.append("\" style=\"width:")
|
||||
.append(r.size.width * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; line-height:")
|
||||
.append(r.size.height * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; left:")
|
||||
.append((r.topLeft.x - offsetWorldmapTo.x) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px; top:")
|
||||
.append((r.topLeft.y - offsetWorldmapTo.y) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px;\"><span>")
|
||||
.append(area.name)
|
||||
.append("</span></div>");
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) namedAreasAsHtml.append('\n');
|
||||
}
|
||||
|
||||
return res.getString(R.string.worldmap_template)
|
||||
.replace("{{maps}}", mapsAsHtml.toString())
|
||||
.replace("{{areas}}", namedAreasAsHtml.toString())
|
||||
.replace("{{sizex}}", Integer.toString(worldmapSegmentSize.width))
|
||||
.replace("{{sizey}}", Integer.toString(worldmapSegmentSize.height))
|
||||
.replace("{{offsetx}}", Integer.toString(offsetWorldmapTo.x * WorldMapController.WORLDMAP_DISPLAY_TILESIZE))
|
||||
.replace("{{offsety}}", Integer.toString(offsetWorldmapTo.y * WorldMapController.WORLDMAP_DISPLAY_TILESIZE));
|
||||
}
|
||||
|
||||
private static Size getMapSize(WorldMapSegmentMap map, WorldContext world) {
|
||||
return world.maps.findPredefinedMap(map.mapName).size;
|
||||
}
|
||||
|
||||
private static CoordRect determineNamedAreaBoundary(NamedWorldMapArea area, WorldMapSegment segment, WorldContext world, Set<String> displayedMapNames) {
|
||||
Coord topLeft = null;
|
||||
Coord bottomRight = null;
|
||||
|
||||
for (String mapName : area.mapNames) {
|
||||
if (!displayedMapNames.contains(mapName)) continue;
|
||||
WorldMapSegmentMap map = segment.maps.get(mapName);
|
||||
Size size = getMapSize(map, world);
|
||||
if (topLeft == null) {
|
||||
topLeft = new Coord(map.worldPosition);
|
||||
} else {
|
||||
topLeft.x = Math.min(topLeft.x, map.worldPosition.x);
|
||||
topLeft.y = Math.min(topLeft.y, map.worldPosition.y);
|
||||
}
|
||||
if (bottomRight == null) {
|
||||
bottomRight = new Coord(map.worldPosition.x + size.width, map.worldPosition.y + size.height);
|
||||
} else {
|
||||
bottomRight.x = Math.max(bottomRight.x, map.worldPosition.x + size.width);
|
||||
bottomRight.y = Math.max(bottomRight.y, map.worldPosition.y + size.height);
|
||||
}
|
||||
}
|
||||
if (topLeft == null) return null;
|
||||
return new CoordRect(topLeft, new Size(bottomRight.x - topLeft.x, bottomRight.y - topLeft.y));
|
||||
}
|
||||
|
||||
public static void updateWorldMapSegment(Context context, Resources res, WorldContext world, String segmentName) throws IOException {
|
||||
String mapAsHtml = getWorldMapSegmentAsHtml(context, res, world, segmentName);
|
||||
File outputFile = getCombinedWorldMapFile(context, segmentName);
|
||||
PrintWriter pw = new PrintWriter(outputFile);
|
||||
pw.write(mapAsHtml);
|
||||
pw.close();
|
||||
}
|
||||
|
||||
public static boolean displayWorldMap(Context context, WorldContext world) {
|
||||
String worldMapSegmentName = world.maps.getWorldMapSegmentNameForMap(world.model.currentMaps.map.name);
|
||||
if (worldMapSegmentName == null) {
|
||||
Toast.makeText(context, context.getResources().getString(R.string.display_worldmap_not_available), Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
Intent intent = new Intent(context, DisplayWorldMapActivity.class);
|
||||
intent.putExtra("worldMapSegmentName", worldMapSegmentName);
|
||||
context.startActivity(intent);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,6 @@ import java.io.IOException;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.LayeredTileMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
|
||||
|
||||
public final class ModelContainer {
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.controller.Constants;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.SkillInfo.SkillLevelRequirement;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
|
||||
@@ -1,58 +1,58 @@
|
||||
package com.gpl.rpg.AndorsTrail.model.actor;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.resource.DynamicTileLoader;
|
||||
|
||||
public class HeroCollection {
|
||||
|
||||
//Id in save is the index in the list +1
|
||||
private static final List<HeroDesc> listOfHeroes = new LinkedList<HeroCollection.HeroDesc>();
|
||||
public static boolean isInitialized = false;
|
||||
|
||||
public static class HeroDesc {
|
||||
int tileIdInSpritesheet, tileIdInManager, smallSpriteResId, largeSpriteResId;
|
||||
public HeroDesc(int tileIdInSpritesheet, int smallSpriteResId, int largeSpriteResId) {
|
||||
this.smallSpriteResId = smallSpriteResId;
|
||||
this.largeSpriteResId = largeSpriteResId;
|
||||
this.tileIdInSpritesheet = tileIdInSpritesheet;
|
||||
//tileIdInManager will be filled by prepareHeroesTileId, called by ResourceLoader
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
listOfHeroes.add(new HeroDesc(0, R.drawable.char_hero, R.drawable.char_hero_large));
|
||||
listOfHeroes.add(new HeroDesc(0, R.drawable.char_hero_maksiu_girl_01, R.drawable.char_hero_maksiu_girl_01_large));
|
||||
listOfHeroes.add(new HeroDesc(0, R.drawable.char_hero_maksiu_boy_01, R.drawable.char_hero_maksiu_boy_01_large));
|
||||
}
|
||||
|
||||
public static int getHeroTileIdForTileManage(int heroId) {
|
||||
//Id in save is the index in the list +1
|
||||
heroId--;
|
||||
if (heroId >= listOfHeroes.size()) return -1;
|
||||
return listOfHeroes.get(heroId).tileIdInManager;
|
||||
}
|
||||
|
||||
public static int getHeroSmallSpriteId(int heroId) {
|
||||
//Id in save is the index in the list +1
|
||||
heroId--;
|
||||
if (heroId >= listOfHeroes.size()) return -1;
|
||||
return listOfHeroes.get(heroId).smallSpriteResId;
|
||||
}
|
||||
|
||||
public static int getHeroLargeSprite(int heroId) {
|
||||
//Id in save is the index in the list +1
|
||||
heroId--;
|
||||
if (heroId >= listOfHeroes.size()) return -1;
|
||||
return listOfHeroes.get(heroId).largeSpriteResId;
|
||||
}
|
||||
|
||||
public static void prepareHeroesTileId(DynamicTileLoader loader) {
|
||||
for (HeroDesc hero : listOfHeroes) {
|
||||
hero.tileIdInManager = loader.prepareTileID(hero.smallSpriteResId, hero.tileIdInSpritesheet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.model.actor;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.resource.DynamicTileLoader;
|
||||
|
||||
public class HeroCollection {
|
||||
|
||||
//Id in save is the index in the list +1
|
||||
private static final List<HeroDesc> listOfHeroes = new LinkedList<HeroCollection.HeroDesc>();
|
||||
public static boolean isInitialized = false;
|
||||
|
||||
public static class HeroDesc {
|
||||
int tileIdInSpritesheet, tileIdInManager, smallSpriteResId, largeSpriteResId;
|
||||
public HeroDesc(int tileIdInSpritesheet, int smallSpriteResId, int largeSpriteResId) {
|
||||
this.smallSpriteResId = smallSpriteResId;
|
||||
this.largeSpriteResId = largeSpriteResId;
|
||||
this.tileIdInSpritesheet = tileIdInSpritesheet;
|
||||
//tileIdInManager will be filled by prepareHeroesTileId, called by ResourceLoader
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
listOfHeroes.add(new HeroDesc(0, R.drawable.char_hero, R.drawable.char_hero_large));
|
||||
listOfHeroes.add(new HeroDesc(0, R.drawable.char_hero_maksiu_girl_01, R.drawable.char_hero_maksiu_girl_01_large));
|
||||
listOfHeroes.add(new HeroDesc(0, R.drawable.char_hero_maksiu_boy_01, R.drawable.char_hero_maksiu_boy_01_large));
|
||||
}
|
||||
|
||||
public static int getHeroTileIdForTileManage(int heroId) {
|
||||
//Id in save is the index in the list +1
|
||||
heroId--;
|
||||
if (heroId >= listOfHeroes.size()) return -1;
|
||||
return listOfHeroes.get(heroId).tileIdInManager;
|
||||
}
|
||||
|
||||
public static int getHeroSmallSpriteId(int heroId) {
|
||||
//Id in save is the index in the list +1
|
||||
heroId--;
|
||||
if (heroId >= listOfHeroes.size()) return -1;
|
||||
return listOfHeroes.get(heroId).smallSpriteResId;
|
||||
}
|
||||
|
||||
public static int getHeroLargeSprite(int heroId) {
|
||||
//Id in save is the index in the list +1
|
||||
heroId--;
|
||||
if (heroId >= listOfHeroes.size()) return -1;
|
||||
return listOfHeroes.get(heroId).largeSpriteResId;
|
||||
}
|
||||
|
||||
public static void prepareHeroesTileId(DynamicTileLoader loader) {
|
||||
for (HeroDesc hero : listOfHeroes) {
|
||||
hero.tileIdInManager = loader.prepareTileID(hero.smallSpriteResId, hero.tileIdInSpritesheet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,115 +1,115 @@
|
||||
package com.gpl.rpg.AndorsTrail.model.item;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.controller.Constants;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
|
||||
|
||||
public final class ItemType {
|
||||
|
||||
public static enum DisplayType {
|
||||
ordinary
|
||||
,quest
|
||||
,rare
|
||||
,extraordinary
|
||||
,legendary;
|
||||
|
||||
public static DisplayType fromString(String s, DisplayType default_) {
|
||||
if (s == null) return default_;
|
||||
return valueOf(s);
|
||||
}
|
||||
}
|
||||
|
||||
public final String id;
|
||||
public final int iconID;
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final boolean hasPersonalizedName;
|
||||
public final ItemCategory category;
|
||||
public final boolean hasManualPrice;
|
||||
public final int baseMarketCost;
|
||||
public final int fixedBaseMarketCost;
|
||||
public final DisplayType displayType;
|
||||
|
||||
public final ItemTraits_OnEquip effects_equip;
|
||||
public final ItemTraits_OnUse effects_use;
|
||||
public final ItemTraits_OnUse effects_hit;
|
||||
public final ItemTraits_OnUse effects_kill;
|
||||
public final ItemTraits_OnHitReceived effects_hitReceived;
|
||||
|
||||
public ItemType(
|
||||
String id
|
||||
, int iconID
|
||||
, String name
|
||||
, String description
|
||||
, ItemCategory category
|
||||
, DisplayType displayType
|
||||
, boolean hasManualPrice
|
||||
, int fixedBaseMarketCost
|
||||
, ItemTraits_OnEquip effects_equip
|
||||
, ItemTraits_OnUse effects_use
|
||||
, ItemTraits_OnUse effects_hit
|
||||
, ItemTraits_OnUse effects_kill
|
||||
, ItemTraits_OnHitReceived effects_hitReceived
|
||||
) {
|
||||
this.id = id;
|
||||
this.iconID = iconID;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.category = category;
|
||||
this.displayType = displayType;
|
||||
this.hasManualPrice = hasManualPrice;
|
||||
this.baseMarketCost = hasManualPrice ? fixedBaseMarketCost : calculateCost(category, effects_equip, effects_use, effects_hit, effects_kill);
|
||||
this.fixedBaseMarketCost = fixedBaseMarketCost;
|
||||
this.effects_equip = effects_equip;
|
||||
this.effects_use = effects_use;
|
||||
this.effects_hit = effects_hit;
|
||||
this.effects_kill = effects_kill;
|
||||
this.effects_hitReceived = effects_hitReceived;
|
||||
this.hasPersonalizedName = name.contains(Constants.PLACEHOLDER_PLAYERNAME);
|
||||
}
|
||||
|
||||
public boolean isEquippable() { return category.isEquippable(); }
|
||||
public boolean isUsable() { return category.isUsable(); }
|
||||
public boolean isQuestItem() { return displayType == DisplayType.quest; }
|
||||
public boolean isOrdinaryItem() { return displayType == DisplayType.ordinary; }
|
||||
public boolean isWeapon() { return category.isWeapon(); }
|
||||
public boolean isArmor() { return category.isArmor(); }
|
||||
public boolean isShield() { return category.isShield(); }
|
||||
public boolean isTwohandWeapon() { return category.isTwohandWeapon(); }
|
||||
public boolean isOffhandCapableWeapon() { return category.isOffhandCapableWeapon(); }
|
||||
public boolean isSellable() {
|
||||
if (isQuestItem()) return false;
|
||||
if (baseMarketCost == 0) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getDescription() { return description; }
|
||||
public String getName(Player p) {
|
||||
if (!hasPersonalizedName) return name;
|
||||
else return name.replace(Constants.PLACEHOLDER_PLAYERNAME, p.getName());
|
||||
}
|
||||
|
||||
public int getOverlayTileID() {
|
||||
switch (displayType) {
|
||||
case quest:
|
||||
return TileManager.iconID_selection_yellow;
|
||||
case legendary:
|
||||
return TileManager.iconID_selection_green;
|
||||
case extraordinary:
|
||||
return TileManager.iconID_selection_blue;
|
||||
case rare:
|
||||
return TileManager.iconID_selection_purple;
|
||||
case ordinary:
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private static int calculateCost(ItemCategory category, ItemTraits_OnEquip effects_equip, ItemTraits_OnUse effects_use, ItemTraits_OnUse effects_hit, ItemTraits_OnUse effects_kill) {
|
||||
final int costEquipStats = effects_equip == null ? 0 : effects_equip.calculateEquipCost(category.isWeapon());
|
||||
final int costUse = effects_use == null ? 0 : effects_use.calculateUseCost();
|
||||
final int costHit = effects_hit == null ? 0 : effects_hit.calculateHitCost();
|
||||
final int costKill = effects_kill == null ? 0 : effects_kill.calculateKillCost();
|
||||
return Math.max(1, costEquipStats + costUse + costHit + costKill);
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.model.item;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.controller.Constants;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
|
||||
|
||||
public final class ItemType {
|
||||
|
||||
public static enum DisplayType {
|
||||
ordinary
|
||||
,quest
|
||||
,rare
|
||||
,extraordinary
|
||||
,legendary;
|
||||
|
||||
public static DisplayType fromString(String s, DisplayType default_) {
|
||||
if (s == null) return default_;
|
||||
return valueOf(s);
|
||||
}
|
||||
}
|
||||
|
||||
public final String id;
|
||||
public final int iconID;
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final boolean hasPersonalizedName;
|
||||
public final ItemCategory category;
|
||||
public final boolean hasManualPrice;
|
||||
public final int baseMarketCost;
|
||||
public final int fixedBaseMarketCost;
|
||||
public final DisplayType displayType;
|
||||
|
||||
public final ItemTraits_OnEquip effects_equip;
|
||||
public final ItemTraits_OnUse effects_use;
|
||||
public final ItemTraits_OnUse effects_hit;
|
||||
public final ItemTraits_OnUse effects_kill;
|
||||
public final ItemTraits_OnHitReceived effects_hitReceived;
|
||||
|
||||
public ItemType(
|
||||
String id
|
||||
, int iconID
|
||||
, String name
|
||||
, String description
|
||||
, ItemCategory category
|
||||
, DisplayType displayType
|
||||
, boolean hasManualPrice
|
||||
, int fixedBaseMarketCost
|
||||
, ItemTraits_OnEquip effects_equip
|
||||
, ItemTraits_OnUse effects_use
|
||||
, ItemTraits_OnUse effects_hit
|
||||
, ItemTraits_OnUse effects_kill
|
||||
, ItemTraits_OnHitReceived effects_hitReceived
|
||||
) {
|
||||
this.id = id;
|
||||
this.iconID = iconID;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.category = category;
|
||||
this.displayType = displayType;
|
||||
this.hasManualPrice = hasManualPrice;
|
||||
this.baseMarketCost = hasManualPrice ? fixedBaseMarketCost : calculateCost(category, effects_equip, effects_use, effects_hit, effects_kill);
|
||||
this.fixedBaseMarketCost = fixedBaseMarketCost;
|
||||
this.effects_equip = effects_equip;
|
||||
this.effects_use = effects_use;
|
||||
this.effects_hit = effects_hit;
|
||||
this.effects_kill = effects_kill;
|
||||
this.effects_hitReceived = effects_hitReceived;
|
||||
this.hasPersonalizedName = name.contains(Constants.PLACEHOLDER_PLAYERNAME);
|
||||
}
|
||||
|
||||
public boolean isEquippable() { return category.isEquippable(); }
|
||||
public boolean isUsable() { return category.isUsable(); }
|
||||
public boolean isQuestItem() { return displayType == DisplayType.quest; }
|
||||
public boolean isOrdinaryItem() { return displayType == DisplayType.ordinary; }
|
||||
public boolean isWeapon() { return category.isWeapon(); }
|
||||
public boolean isArmor() { return category.isArmor(); }
|
||||
public boolean isShield() { return category.isShield(); }
|
||||
public boolean isTwohandWeapon() { return category.isTwohandWeapon(); }
|
||||
public boolean isOffhandCapableWeapon() { return category.isOffhandCapableWeapon(); }
|
||||
public boolean isSellable() {
|
||||
if (isQuestItem()) return false;
|
||||
if (baseMarketCost == 0) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getDescription() { return description; }
|
||||
public String getName(Player p) {
|
||||
if (!hasPersonalizedName) return name;
|
||||
else return name.replace(Constants.PLACEHOLDER_PLAYERNAME, p.getName());
|
||||
}
|
||||
|
||||
public int getOverlayTileID() {
|
||||
switch (displayType) {
|
||||
case quest:
|
||||
return TileManager.iconID_selection_yellow;
|
||||
case legendary:
|
||||
return TileManager.iconID_selection_green;
|
||||
case extraordinary:
|
||||
return TileManager.iconID_selection_blue;
|
||||
case rare:
|
||||
return TileManager.iconID_selection_purple;
|
||||
case ordinary:
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private static int calculateCost(ItemCategory category, ItemTraits_OnEquip effects_equip, ItemTraits_OnUse effects_use, ItemTraits_OnUse effects_hit, ItemTraits_OnUse effects_kill) {
|
||||
final int costEquipStats = effects_equip == null ? 0 : effects_equip.calculateEquipCost(category.isWeapon());
|
||||
final int costUse = effects_use == null ? 0 : effects_use.calculateUseCost();
|
||||
final int costHit = effects_hit == null ? 0 : effects_hit.calculateHitCost();
|
||||
final int costKill = effects_kill == null ? 0 : effects_kill.calculateKillCost();
|
||||
return Math.max(1, costEquipStats + costUse + costHit + costKill);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,237 +1,237 @@
|
||||
package com.gpl.rpg.AndorsTrail.model.map;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
import com.gpl.rpg.AndorsTrail.util.CoordRect;
|
||||
import com.gpl.rpg.AndorsTrail.util.Size;
|
||||
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.ColorMatrixColorFilter;
|
||||
import android.graphics.Paint;
|
||||
|
||||
public final class LayeredTileMap {
|
||||
private static final ColorFilter colorFilterBlack20 = createGrayScaleColorFilter(0.8f);
|
||||
private static final ColorFilter colorFilterBlack40 = createGrayScaleColorFilter(0.6f);
|
||||
private static final ColorFilter colorFilterBlack60 = createGrayScaleColorFilter(0.4f);
|
||||
private static final ColorFilter colorFilterBlack80 = createGrayScaleColorFilter(0.2f);
|
||||
private static final ColorFilter colorFilterInvert = createInvertColorFilter();
|
||||
private static final ColorFilter colorFilterBW = createBWColorFilter();
|
||||
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 ColorFilterId originalColorFilter;
|
||||
public ColorFilterId colorFilter;
|
||||
public final Collection<Integer> usedTileIDs;
|
||||
public LayeredTileMap(
|
||||
Size size
|
||||
, MapSection layout
|
||||
, ReplaceableMapSection[] replacements
|
||||
, ColorFilterId colorFilter
|
||||
, Collection<Integer> usedTileIDs
|
||||
) {
|
||||
this.size = size;
|
||||
this.currentLayout = layout;
|
||||
this.replacements = replacements;
|
||||
this.originalColorFilter = colorFilter;
|
||||
colorFilter = originalColorFilter;
|
||||
this.usedTileIDs = usedTileIDs;
|
||||
this.currentLayoutHash = currentLayout.calculateHash(colorFilter.name());
|
||||
}
|
||||
|
||||
public final boolean isWalkable(final Coord p) {
|
||||
if (isOutside(p.x, p.y)) return false;
|
||||
return currentLayout.isWalkable[p.x][p.y];
|
||||
}
|
||||
public final boolean isWalkable(final int x, final int y) {
|
||||
if (isOutside(x, y)) return false;
|
||||
return currentLayout.isWalkable[x][y];
|
||||
}
|
||||
public final boolean isWalkable(final CoordRect p) {
|
||||
for (int y = 0; y < p.size.height; ++y) {
|
||||
for (int x = 0; x < p.size.width; ++x) {
|
||||
if (!isWalkable(p.topLeft.x + x, p.topLeft.y + y)) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public final boolean isOutside(final Coord p) { return isOutside(p.x, p.y); }
|
||||
public final boolean isOutside(final int x, final int y) {
|
||||
if (x < 0) return true;
|
||||
if (y < 0) return true;
|
||||
if (x >= size.width) return true;
|
||||
if (y >= size.height) return true;
|
||||
return false;
|
||||
}
|
||||
public final boolean isOutside(final CoordRect area) {
|
||||
if (isOutside(area.topLeft)) return true;
|
||||
if (area.topLeft.x + area.size.width > size.width) return true;
|
||||
if (area.topLeft.y + area.size.height > size.height) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean setColorFilter(Paint mPaint, Paint alternateColorFilterPaint, boolean highQuality) {
|
||||
if (!highQuality) {
|
||||
highQuality = !setColor(alternateColorFilterPaint);
|
||||
}
|
||||
mPaint.setColorFilter(highQuality ? getColorFilter() : null);
|
||||
return !highQuality;
|
||||
}
|
||||
|
||||
public ColorFilter getColorFilter() {
|
||||
if (colorFilter == null) 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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public boolean setColor(Paint p) {
|
||||
if (colorFilter == null) {
|
||||
p.setARGB(0, 0, 0, 0);
|
||||
return true;
|
||||
}
|
||||
switch (colorFilter) {
|
||||
case black20:
|
||||
p.setARGB(51, 0, 0, 0); return true;
|
||||
case black40:
|
||||
p.setARGB(102, 0, 0, 0); return true;
|
||||
case black60:
|
||||
p.setARGB(153, 0, 0, 0); return true;
|
||||
case black80:
|
||||
p.setARGB(204, 0, 0, 0); return true;
|
||||
case redtint:
|
||||
p.setARGB(50, 200, 0, 0); return true;
|
||||
case greentint:
|
||||
p.setARGB(50, 0, 200, 0); return true;
|
||||
case bluetint:
|
||||
p.setARGB(50, 0, 0, 200); return true;
|
||||
case bw:
|
||||
case invert:
|
||||
return false;
|
||||
default:
|
||||
p.setARGB(0, 0, 0, 0); return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static ColorMatrixColorFilter createGrayScaleColorFilter(float blackOpacity) {
|
||||
final float f = blackOpacity;
|
||||
return new ColorMatrixColorFilter(new float[] {
|
||||
f, 0.00f, 0.00f, 0.0f, 0.0f,
|
||||
0.00f, f, 0.00f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
}
|
||||
|
||||
private static ColorMatrixColorFilter createInvertColorFilter() {
|
||||
return new ColorMatrixColorFilter(new float[] {
|
||||
-1.00f, 0.00f, 0.00f, 0.0f, 255.0f,
|
||||
0.00f, -1.00f, 0.00f, 0.0f, 255.0f,
|
||||
0.00f, 0.00f, -1.00f, 0.0f, 255.0f,
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
}
|
||||
|
||||
private static ColorMatrixColorFilter createBWColorFilter() {
|
||||
return new ColorMatrixColorFilter(new float[] {
|
||||
0.33f, 0.59f, 0.11f, 0.0f, 0.0f,
|
||||
0.33f, 0.59f, 0.11f, 0.0f, 0.0f,
|
||||
0.33f, 0.59f, 0.11f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
}
|
||||
|
||||
private static ColorMatrixColorFilter createRedTintColorFilter() {
|
||||
return new ColorMatrixColorFilter(new float[] {
|
||||
1.20f, 0.20f, 0.20f, 0.0f, 25.0f,
|
||||
0.00f, 0.80f, 0.00f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, 0.80f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
}
|
||||
|
||||
private static ColorMatrixColorFilter createGreenTintColorFilter() {
|
||||
return new ColorMatrixColorFilter(new float[] {
|
||||
0.85f, 0.00f, 0.00f, 0.0f, 0.0f,
|
||||
0.15f, 1.15f, 0.15f, 0.0f, 15.0f,
|
||||
0.00f, 0.00f, 0.85f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
}
|
||||
|
||||
private static ColorMatrixColorFilter createBlueTintColorFilter() {
|
||||
return new ColorMatrixColorFilter(new float[] {
|
||||
0.70f, 0.00f, 0.00f, 0.0f, 0.0f,
|
||||
0.00f, 0.70f, 0.00f, 0.0f, 0.0f,
|
||||
0.30f, 0.30f, 1.30f, 0.0f, 40.0f,
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
}
|
||||
|
||||
public String getCurrentLayoutHash() {
|
||||
return currentLayoutHash;
|
||||
}
|
||||
|
||||
public void applyReplacement(ReplaceableMapSection replacement) {
|
||||
replacement.apply(currentLayout);
|
||||
currentLayoutHash = currentLayout.calculateHash(colorFilter == ColorFilterId.none ? null : colorFilter.name());
|
||||
}
|
||||
|
||||
public void changeColorFilter(ColorFilterId id) {
|
||||
if (colorFilter == id) return;
|
||||
colorFilter = id;
|
||||
currentLayoutHash = currentLayout.calculateHash(colorFilter == ColorFilterId.none ? null : colorFilter.name());
|
||||
}
|
||||
|
||||
|
||||
public void changeColorFilter(String idString) {
|
||||
ColorFilterId id;
|
||||
if (idString == null) id = originalColorFilter;
|
||||
else id = ColorFilterId.valueOf(idString);
|
||||
if (id != null) {
|
||||
changeColorFilter(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.model.map;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
import com.gpl.rpg.AndorsTrail.util.CoordRect;
|
||||
import com.gpl.rpg.AndorsTrail.util.Size;
|
||||
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.ColorMatrixColorFilter;
|
||||
import android.graphics.Paint;
|
||||
|
||||
public final class LayeredTileMap {
|
||||
private static final ColorFilter colorFilterBlack20 = createGrayScaleColorFilter(0.8f);
|
||||
private static final ColorFilter colorFilterBlack40 = createGrayScaleColorFilter(0.6f);
|
||||
private static final ColorFilter colorFilterBlack60 = createGrayScaleColorFilter(0.4f);
|
||||
private static final ColorFilter colorFilterBlack80 = createGrayScaleColorFilter(0.2f);
|
||||
private static final ColorFilter colorFilterInvert = createInvertColorFilter();
|
||||
private static final ColorFilter colorFilterBW = createBWColorFilter();
|
||||
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 ColorFilterId originalColorFilter;
|
||||
public ColorFilterId colorFilter;
|
||||
public final Collection<Integer> usedTileIDs;
|
||||
public LayeredTileMap(
|
||||
Size size
|
||||
, MapSection layout
|
||||
, ReplaceableMapSection[] replacements
|
||||
, ColorFilterId colorFilter
|
||||
, Collection<Integer> usedTileIDs
|
||||
) {
|
||||
this.size = size;
|
||||
this.currentLayout = layout;
|
||||
this.replacements = replacements;
|
||||
this.originalColorFilter = colorFilter;
|
||||
colorFilter = originalColorFilter;
|
||||
this.usedTileIDs = usedTileIDs;
|
||||
this.currentLayoutHash = currentLayout.calculateHash(colorFilter.name());
|
||||
}
|
||||
|
||||
public final boolean isWalkable(final Coord p) {
|
||||
if (isOutside(p.x, p.y)) return false;
|
||||
return currentLayout.isWalkable[p.x][p.y];
|
||||
}
|
||||
public final boolean isWalkable(final int x, final int y) {
|
||||
if (isOutside(x, y)) return false;
|
||||
return currentLayout.isWalkable[x][y];
|
||||
}
|
||||
public final boolean isWalkable(final CoordRect p) {
|
||||
for (int y = 0; y < p.size.height; ++y) {
|
||||
for (int x = 0; x < p.size.width; ++x) {
|
||||
if (!isWalkable(p.topLeft.x + x, p.topLeft.y + y)) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public final boolean isOutside(final Coord p) { return isOutside(p.x, p.y); }
|
||||
public final boolean isOutside(final int x, final int y) {
|
||||
if (x < 0) return true;
|
||||
if (y < 0) return true;
|
||||
if (x >= size.width) return true;
|
||||
if (y >= size.height) return true;
|
||||
return false;
|
||||
}
|
||||
public final boolean isOutside(final CoordRect area) {
|
||||
if (isOutside(area.topLeft)) return true;
|
||||
if (area.topLeft.x + area.size.width > size.width) return true;
|
||||
if (area.topLeft.y + area.size.height > size.height) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean setColorFilter(Paint mPaint, Paint alternateColorFilterPaint, boolean highQuality) {
|
||||
if (!highQuality) {
|
||||
highQuality = !setColor(alternateColorFilterPaint);
|
||||
}
|
||||
mPaint.setColorFilter(highQuality ? getColorFilter() : null);
|
||||
return !highQuality;
|
||||
}
|
||||
|
||||
public ColorFilter getColorFilter() {
|
||||
if (colorFilter == null) 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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public boolean setColor(Paint p) {
|
||||
if (colorFilter == null) {
|
||||
p.setARGB(0, 0, 0, 0);
|
||||
return true;
|
||||
}
|
||||
switch (colorFilter) {
|
||||
case black20:
|
||||
p.setARGB(51, 0, 0, 0); return true;
|
||||
case black40:
|
||||
p.setARGB(102, 0, 0, 0); return true;
|
||||
case black60:
|
||||
p.setARGB(153, 0, 0, 0); return true;
|
||||
case black80:
|
||||
p.setARGB(204, 0, 0, 0); return true;
|
||||
case redtint:
|
||||
p.setARGB(50, 200, 0, 0); return true;
|
||||
case greentint:
|
||||
p.setARGB(50, 0, 200, 0); return true;
|
||||
case bluetint:
|
||||
p.setARGB(50, 0, 0, 200); return true;
|
||||
case bw:
|
||||
case invert:
|
||||
return false;
|
||||
default:
|
||||
p.setARGB(0, 0, 0, 0); return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static ColorMatrixColorFilter createGrayScaleColorFilter(float blackOpacity) {
|
||||
final float f = blackOpacity;
|
||||
return new ColorMatrixColorFilter(new float[] {
|
||||
f, 0.00f, 0.00f, 0.0f, 0.0f,
|
||||
0.00f, f, 0.00f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
}
|
||||
|
||||
private static ColorMatrixColorFilter createInvertColorFilter() {
|
||||
return new ColorMatrixColorFilter(new float[] {
|
||||
-1.00f, 0.00f, 0.00f, 0.0f, 255.0f,
|
||||
0.00f, -1.00f, 0.00f, 0.0f, 255.0f,
|
||||
0.00f, 0.00f, -1.00f, 0.0f, 255.0f,
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
}
|
||||
|
||||
private static ColorMatrixColorFilter createBWColorFilter() {
|
||||
return new ColorMatrixColorFilter(new float[] {
|
||||
0.33f, 0.59f, 0.11f, 0.0f, 0.0f,
|
||||
0.33f, 0.59f, 0.11f, 0.0f, 0.0f,
|
||||
0.33f, 0.59f, 0.11f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
}
|
||||
|
||||
private static ColorMatrixColorFilter createRedTintColorFilter() {
|
||||
return new ColorMatrixColorFilter(new float[] {
|
||||
1.20f, 0.20f, 0.20f, 0.0f, 25.0f,
|
||||
0.00f, 0.80f, 0.00f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, 0.80f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
}
|
||||
|
||||
private static ColorMatrixColorFilter createGreenTintColorFilter() {
|
||||
return new ColorMatrixColorFilter(new float[] {
|
||||
0.85f, 0.00f, 0.00f, 0.0f, 0.0f,
|
||||
0.15f, 1.15f, 0.15f, 0.0f, 15.0f,
|
||||
0.00f, 0.00f, 0.85f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
}
|
||||
|
||||
private static ColorMatrixColorFilter createBlueTintColorFilter() {
|
||||
return new ColorMatrixColorFilter(new float[] {
|
||||
0.70f, 0.00f, 0.00f, 0.0f, 0.0f,
|
||||
0.00f, 0.70f, 0.00f, 0.0f, 0.0f,
|
||||
0.30f, 0.30f, 1.30f, 0.0f, 40.0f,
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
}
|
||||
|
||||
public String getCurrentLayoutHash() {
|
||||
return currentLayoutHash;
|
||||
}
|
||||
|
||||
public void applyReplacement(ReplaceableMapSection replacement) {
|
||||
replacement.apply(currentLayout);
|
||||
currentLayoutHash = currentLayout.calculateHash(colorFilter == ColorFilterId.none ? null : colorFilter.name());
|
||||
}
|
||||
|
||||
public void changeColorFilter(ColorFilterId id) {
|
||||
if (colorFilter == id) return;
|
||||
colorFilter = id;
|
||||
currentLayoutHash = currentLayout.calculateHash(colorFilter == ColorFilterId.none ? null : colorFilter.name());
|
||||
}
|
||||
|
||||
|
||||
public void changeColorFilter(String idString) {
|
||||
ColorFilterId id;
|
||||
if (idString == null) id = originalColorFilter;
|
||||
else id = ColorFilterId.valueOf(idString);
|
||||
if (id != null) {
|
||||
changeColorFilter(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,63 +1,63 @@
|
||||
package com.gpl.rpg.AndorsTrail.model.map;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.util.ByteUtils;
|
||||
import com.gpl.rpg.AndorsTrail.util.CoordRect;
|
||||
|
||||
public final class MapSection {
|
||||
public final MapLayer layerBase;
|
||||
public final MapLayer layerGround;
|
||||
public final MapLayer layerObjects;
|
||||
public final MapLayer layerAbove;
|
||||
public final MapLayer layerTop;
|
||||
public final boolean[][] isWalkable;
|
||||
private final byte[] layoutHash;
|
||||
|
||||
public MapSection(
|
||||
MapLayer layerBase
|
||||
, MapLayer layerGround
|
||||
, MapLayer layerObjects
|
||||
, MapLayer layerAbove
|
||||
, MapLayer layerTop
|
||||
, boolean[][] isWalkable
|
||||
, byte[] layoutHash
|
||||
) {
|
||||
this.layerBase = layerBase;
|
||||
this.layerGround = layerGround;
|
||||
this.layerObjects = layerObjects;
|
||||
this.layerAbove = layerAbove;
|
||||
this.layerTop = layerTop;
|
||||
this.isWalkable = isWalkable;
|
||||
this.layoutHash = layoutHash;
|
||||
}
|
||||
|
||||
public void replaceLayerContentsWith(final MapSection replaceLayersWith, final CoordRect replacementArea) {
|
||||
replaceTileLayerSection(layerBase, replaceLayersWith.layerBase, replacementArea);
|
||||
replaceTileLayerSection(layerGround, replaceLayersWith.layerGround, replacementArea);
|
||||
replaceTileLayerSection(layerObjects, replaceLayersWith.layerObjects, replacementArea);
|
||||
replaceTileLayerSection(layerAbove, replaceLayersWith.layerAbove, replacementArea);
|
||||
replaceTileLayerSection(layerTop, replaceLayersWith.layerTop, replacementArea);
|
||||
if (replaceLayersWith.isWalkable != null) {
|
||||
final int dy = replacementArea.topLeft.y;
|
||||
final int height = replacementArea.size.height;
|
||||
for (int sx = 0, dx = replacementArea.topLeft.x; sx < replacementArea.size.width; ++sx, ++dx) {
|
||||
System.arraycopy(replaceLayersWith.isWalkable[sx], 0, isWalkable[dx], dy, height);
|
||||
}
|
||||
}
|
||||
ByteUtils.xorArray(layoutHash, replaceLayersWith.layoutHash);
|
||||
}
|
||||
|
||||
private static void replaceTileLayerSection(MapLayer dest, MapLayer src, CoordRect area) {
|
||||
if (src == null) return;
|
||||
final int dy = area.topLeft.y;
|
||||
final int height = area.size.height;
|
||||
for (int sx = 0, dx = area.topLeft.x; sx < area.size.width; ++sx, ++dx) {
|
||||
System.arraycopy(src.tiles[sx], 0, dest.tiles[dx], dy, height);
|
||||
}
|
||||
}
|
||||
|
||||
public String calculateHash(String filter) {
|
||||
byte[] hash = layoutHash.clone();
|
||||
if (filter != null) ByteUtils.xorArray(hash, filter.getBytes());
|
||||
return ByteUtils.toHexString(hash, 4);
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.model.map;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.util.ByteUtils;
|
||||
import com.gpl.rpg.AndorsTrail.util.CoordRect;
|
||||
|
||||
public final class MapSection {
|
||||
public final MapLayer layerBase;
|
||||
public final MapLayer layerGround;
|
||||
public final MapLayer layerObjects;
|
||||
public final MapLayer layerAbove;
|
||||
public final MapLayer layerTop;
|
||||
public final boolean[][] isWalkable;
|
||||
private final byte[] layoutHash;
|
||||
|
||||
public MapSection(
|
||||
MapLayer layerBase
|
||||
, MapLayer layerGround
|
||||
, MapLayer layerObjects
|
||||
, MapLayer layerAbove
|
||||
, MapLayer layerTop
|
||||
, boolean[][] isWalkable
|
||||
, byte[] layoutHash
|
||||
) {
|
||||
this.layerBase = layerBase;
|
||||
this.layerGround = layerGround;
|
||||
this.layerObjects = layerObjects;
|
||||
this.layerAbove = layerAbove;
|
||||
this.layerTop = layerTop;
|
||||
this.isWalkable = isWalkable;
|
||||
this.layoutHash = layoutHash;
|
||||
}
|
||||
|
||||
public void replaceLayerContentsWith(final MapSection replaceLayersWith, final CoordRect replacementArea) {
|
||||
replaceTileLayerSection(layerBase, replaceLayersWith.layerBase, replacementArea);
|
||||
replaceTileLayerSection(layerGround, replaceLayersWith.layerGround, replacementArea);
|
||||
replaceTileLayerSection(layerObjects, replaceLayersWith.layerObjects, replacementArea);
|
||||
replaceTileLayerSection(layerAbove, replaceLayersWith.layerAbove, replacementArea);
|
||||
replaceTileLayerSection(layerTop, replaceLayersWith.layerTop, replacementArea);
|
||||
if (replaceLayersWith.isWalkable != null) {
|
||||
final int dy = replacementArea.topLeft.y;
|
||||
final int height = replacementArea.size.height;
|
||||
for (int sx = 0, dx = replacementArea.topLeft.x; sx < replacementArea.size.width; ++sx, ++dx) {
|
||||
System.arraycopy(replaceLayersWith.isWalkable[sx], 0, isWalkable[dx], dy, height);
|
||||
}
|
||||
}
|
||||
ByteUtils.xorArray(layoutHash, replaceLayersWith.layoutHash);
|
||||
}
|
||||
|
||||
private static void replaceTileLayerSection(MapLayer dest, MapLayer src, CoordRect area) {
|
||||
if (src == null) return;
|
||||
final int dy = area.topLeft.y;
|
||||
final int height = area.size.height;
|
||||
for (int sx = 0, dx = area.topLeft.x; sx < area.size.width; ++sx, ++dx) {
|
||||
System.arraycopy(src.tiles[sx], 0, dest.tiles[dx], dy, height);
|
||||
}
|
||||
}
|
||||
|
||||
public String calculateHash(String filter) {
|
||||
byte[] hash = layoutHash.clone();
|
||||
if (filter != null) ByteUtils.xorArray(hash, filter.getBytes());
|
||||
return ByteUtils.toHexString(hash, 4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,401 +1,401 @@
|
||||
package com.gpl.rpg.AndorsTrail.model.map;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.Constants;
|
||||
import com.gpl.rpg.AndorsTrail.controller.VisualEffectController.BloodSplatter;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Loot;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.MapObject.MapObjectType;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
import com.gpl.rpg.AndorsTrail.util.CoordRect;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.Size;
|
||||
|
||||
public final class PredefinedMap {
|
||||
private static final long VISIT_RESET = 0;
|
||||
|
||||
public final int xmlResourceId;
|
||||
public final String name;
|
||||
public final Size size;
|
||||
public final MapObject[] eventObjects;
|
||||
public final MonsterSpawnArea[] spawnAreas;
|
||||
public final List<String> initiallyActiveMapObjectGroups;
|
||||
public final List<String> activeMapObjectGroups;
|
||||
public final ArrayList<Loot> groundBags = new ArrayList<Loot>();
|
||||
public final String initialColorFilter;
|
||||
public boolean visited = false;
|
||||
public long lastVisitTime = VISIT_RESET;
|
||||
public String lastSeenLayoutHash = "";
|
||||
public final boolean isOutdoors;
|
||||
public String currentColorFilter = null;
|
||||
|
||||
public final ArrayList<BloodSplatter> splatters = new ArrayList<BloodSplatter>();
|
||||
|
||||
public PredefinedMap(
|
||||
int xmlResourceId
|
||||
, String name
|
||||
, Size size
|
||||
, MapObject[] eventObjects
|
||||
, MonsterSpawnArea[] spawnAreas
|
||||
, List<String> initiallyActiveMapObjectGroups
|
||||
, boolean isOutdoors
|
||||
, String colorFilter
|
||||
) {
|
||||
this.xmlResourceId = xmlResourceId;
|
||||
this.name = name;
|
||||
this.size = size;
|
||||
this.eventObjects = eventObjects;
|
||||
this.spawnAreas = spawnAreas;
|
||||
this.initiallyActiveMapObjectGroups = initiallyActiveMapObjectGroups;
|
||||
this.activeMapObjectGroups = new LinkedList<String>();
|
||||
this.activeMapObjectGroups.addAll(this.initiallyActiveMapObjectGroups);
|
||||
activateMapObjects();
|
||||
assert(size.width > 0);
|
||||
assert(size.height > 0);
|
||||
this.isOutdoors = isOutdoors;
|
||||
this.initialColorFilter = colorFilter;
|
||||
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
for (int i = 0; i < spawnAreas.length; i++) {
|
||||
for (int j = i + 1; j < spawnAreas.length; j++) {
|
||||
if (spawnAreas[i].areaID.equals(spawnAreas[j].areaID)) {
|
||||
L.log("WARNING: duplicate areaID " + spawnAreas[i].areaID + " in map " + this.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean isOutside(final Coord p) { return isOutside(p.x, p.y); }
|
||||
public final boolean isOutside(final int x, final int y) {
|
||||
if (x < 0) return true;
|
||||
if (y < 0) return true;
|
||||
if (x >= size.width) return true;
|
||||
if (y >= size.height) return true;
|
||||
return false;
|
||||
}
|
||||
public final boolean isOutside(final CoordRect area) {
|
||||
if (isOutside(area.topLeft)) return true;
|
||||
if (area.topLeft.x + area.size.width > size.width) return true;
|
||||
if (area.topLeft.y + area.size.height > size.height) return true;
|
||||
return false;
|
||||
}
|
||||
public boolean intersects(CoordRect area) {
|
||||
return new CoordRect(new Coord(0,0), size).intersects(area);
|
||||
}
|
||||
|
||||
public MapObject findEventObject(MapObject.MapObjectType objectType, String name) {
|
||||
for (MapObject o : eventObjects) {
|
||||
if (o.type != objectType) continue;
|
||||
if (!name.equals(o.id)) continue;
|
||||
return o;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public List<MapObject> getActiveEventObjectsAt(final Coord p) {
|
||||
List<MapObject> result = null;
|
||||
for (MapObject o : eventObjects) {
|
||||
if (!o.isActive) continue;
|
||||
if (!o.position.contains(p)) continue;
|
||||
//if (!activeMapObjectGroups.contains(o.group)) continue;
|
||||
if (result == null) result = new ArrayList<MapObject>();
|
||||
result.add(o);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public boolean hasContainerAt(final Coord p) {
|
||||
for (MapObject o : eventObjects) {
|
||||
if (!o.isActive) continue;
|
||||
if (o.type != MapObject.MapObjectType.container) continue;
|
||||
if (!o.position.contains(p)) continue;
|
||||
return true;
|
||||
}
|
||||
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 && (exceptMe == null || exceptMe != m)) return m;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public Monster getMonsterAt(final Coord p) { return getMonsterAt(p.x, p.y); }
|
||||
public Monster getMonsterAt(final int x, final int y) {
|
||||
for (MonsterSpawnArea a : spawnAreas) {
|
||||
Monster m = a.getMonsterAt(x, y);
|
||||
if (m != null) return m;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Monster findSpawnedMonster(final String monsterTypeID) {
|
||||
for (MonsterSpawnArea a : spawnAreas) {
|
||||
Monster m = a.findSpawnedMonster(monsterTypeID);
|
||||
if (m != null) return m;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Loot getBagAt(final Coord p) {
|
||||
for (Loot l : groundBags) {
|
||||
if (l.position.equals(p)) return l;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public Loot getBagOrCreateAt(final Coord position) {
|
||||
Loot b = getBagAt(position);
|
||||
if (b != null) return b;
|
||||
boolean isContainer = hasContainerAt(position);
|
||||
b = new Loot(!isContainer);
|
||||
b.position.set(position);
|
||||
if (isOutside(position)) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("WARNING: trying to place bag outside map. Map is " + size.toString() + ", bag tried to place at " + position.toString());
|
||||
}
|
||||
return b;
|
||||
}
|
||||
groundBags.add(b);
|
||||
return b;
|
||||
}
|
||||
public void itemDropped(ItemType itemType, int quantity, Coord position) {
|
||||
Loot l = getBagOrCreateAt(position);
|
||||
l.items.addItem(itemType, quantity);
|
||||
}
|
||||
public void removeGroundLoot(Loot loot) {
|
||||
groundBags.remove(loot);
|
||||
}
|
||||
public void resetForNewGame() {
|
||||
for (MonsterSpawnArea a : spawnAreas) {
|
||||
a.resetForNewGame();
|
||||
}
|
||||
activeMapObjectGroups.clear();
|
||||
activeMapObjectGroups.addAll(initiallyActiveMapObjectGroups);
|
||||
activateMapObjects();
|
||||
resetTemporaryData();
|
||||
groundBags.clear();
|
||||
visited = false;
|
||||
currentColorFilter = initialColorFilter;
|
||||
lastSeenLayoutHash = "";
|
||||
}
|
||||
|
||||
public boolean isRecentlyVisited() {
|
||||
if (lastVisitTime == VISIT_RESET) return false;
|
||||
return (System.currentTimeMillis() - lastVisitTime) < Constants.MAP_UNVISITED_RESPAWN_DURATION_MS;
|
||||
}
|
||||
public void updateLastVisitTime() {
|
||||
lastVisitTime = System.currentTimeMillis();
|
||||
}
|
||||
public void resetTemporaryData() {
|
||||
for(MonsterSpawnArea a : spawnAreas) {
|
||||
if (a.isUnique) a.resetShops();
|
||||
else a.removeAllMonsters();
|
||||
}
|
||||
splatters.clear();
|
||||
lastVisitTime = VISIT_RESET;
|
||||
}
|
||||
public boolean hasResetTemporaryData() {
|
||||
return lastVisitTime == VISIT_RESET;
|
||||
}
|
||||
|
||||
public void createAllContainerLoot() {
|
||||
for (MapObject o : eventObjects) {
|
||||
if (!o.isActive) continue;
|
||||
if (o.type != MapObject.MapObjectType.container) continue;
|
||||
createContainerLoot(o);
|
||||
}
|
||||
}
|
||||
|
||||
public void createContainerLoot(MapObject container) {
|
||||
Loot bag = getBagOrCreateAt(container.position.topLeft);
|
||||
container.dropList.createRandomLoot(bag, null);
|
||||
}
|
||||
|
||||
|
||||
private void activateMapObjects() {
|
||||
for (MapObject o : eventObjects) {
|
||||
o.isActive = activeMapObjectGroups.contains(o.group);
|
||||
}
|
||||
}
|
||||
|
||||
public void activateMapObjectGroup(String group) {
|
||||
if (!activeMapObjectGroups.contains(group)) {
|
||||
activeMapObjectGroups.add(group);
|
||||
for (MapObject o : eventObjects) {
|
||||
if (o.group.equals(group)) {
|
||||
o.isActive = true;
|
||||
if (o.type == MapObjectType.container) createContainerLoot(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void deactivateMapObjectGroup(String group) {
|
||||
if (activeMapObjectGroups.contains(group)) {
|
||||
activeMapObjectGroups.remove(group);
|
||||
for (MapObject o : eventObjects) {
|
||||
if (o.group.equals(group)) {
|
||||
o.isActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
public void readFromParcel(DataInputStream src, WorldContext world, ControllerContext controllers, int fileversion) throws IOException {
|
||||
boolean shouldLoadMapData = true;
|
||||
if (fileversion >= 37) shouldLoadMapData = src.readBoolean();
|
||||
|
||||
int loadedSpawnAreas = 0;
|
||||
if (shouldLoadMapData) {
|
||||
loadedSpawnAreas = src.readInt();
|
||||
for(int i = 0; i < loadedSpawnAreas; ++i) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
if (i >= this.spawnAreas.length) {
|
||||
L.log("WARNING: Trying to load monsters from savegame in map " + this.name + " for spawn #" + i + ". This will totally fail.");
|
||||
}
|
||||
}
|
||||
if(fileversion >= 43) {
|
||||
//Spawn areas now have unique IDs. Need to check as maps can change.
|
||||
String id = src.readUTF();
|
||||
int j = i;
|
||||
boolean found = false;
|
||||
do {
|
||||
if (this.spawnAreas[j].areaID.equals(id)) {
|
||||
this.spawnAreas[j].readFromParcel(src, world, fileversion);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
j = (j+1)%spawnAreas.length;
|
||||
} while (j != i);
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
if (!found) {
|
||||
L.log("WARNING: Trying to load monsters from savegame in map " + this.name + " for spawn #" + id + " but this area cannot be found. This will totally fail.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.spawnAreas[i].readFromParcel(src, world, fileversion);
|
||||
}
|
||||
}
|
||||
|
||||
activeMapObjectGroups.clear();
|
||||
if(fileversion >= 43) {
|
||||
int activeListLength = src.readInt();
|
||||
for (int i = 0; i < activeListLength; i++) {
|
||||
String activeGroupID = src.readUTF();
|
||||
activeMapObjectGroups.add(activeGroupID);
|
||||
}
|
||||
} else {
|
||||
activeMapObjectGroups.addAll(initiallyActiveMapObjectGroups);
|
||||
}
|
||||
activateMapObjects();
|
||||
|
||||
groundBags.clear();
|
||||
if (fileversion <= 5) return;
|
||||
|
||||
final int size2 = src.readInt();
|
||||
for(int i = 0; i < size2; ++i) {
|
||||
groundBags.add(new Loot(src, world, fileversion));
|
||||
}
|
||||
|
||||
if (fileversion <= 11) return;
|
||||
|
||||
if (fileversion < 37) visited = src.readBoolean();
|
||||
|
||||
if (fileversion <= 15) {
|
||||
if (visited) {
|
||||
lastVisitTime = System.currentTimeMillis();
|
||||
createAllContainerLoot();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (fileversion >= 43) {
|
||||
if (src.readBoolean()) {
|
||||
currentColorFilter = src.readUTF();
|
||||
} else {
|
||||
currentColorFilter = null;
|
||||
}
|
||||
}
|
||||
|
||||
lastVisitTime = src.readLong();
|
||||
|
||||
if (visited) {
|
||||
if (fileversion > 30 && fileversion < 36) {
|
||||
/*int lastVisitVersion = */src.readInt();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
activeMapObjectGroups.clear();
|
||||
activeMapObjectGroups.addAll(initiallyActiveMapObjectGroups);
|
||||
activateMapObjects();
|
||||
}
|
||||
if (fileversion >= 37) {
|
||||
if (fileversion < 41) visited = true;
|
||||
else visited = src.readBoolean();
|
||||
}
|
||||
|
||||
if (fileversion < 36) lastSeenLayoutHash = "";
|
||||
else lastSeenLayoutHash = src.readUTF();
|
||||
|
||||
for(int i = loadedSpawnAreas; i < spawnAreas.length; ++i) {
|
||||
MonsterSpawnArea area = this.spawnAreas[i];
|
||||
if (area.isUnique && visited) controllers.monsterSpawnController.spawnAllInArea(this, null, area, true);
|
||||
else area.resetForNewGame();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean shouldSaveMapData(WorldContext world) {
|
||||
if (!hasResetTemporaryData()) return true;
|
||||
if (this == world.model.currentMaps.map) return true;
|
||||
if (!groundBags.isEmpty()) return true;
|
||||
for (MonsterSpawnArea a : spawnAreas) {
|
||||
if (this.visited && a.isUnique) return true;
|
||||
if (a.isSpawning != a.isSpawningForNewGame) return true;
|
||||
}
|
||||
if (!activeMapObjectGroups.containsAll(initiallyActiveMapObjectGroups)
|
||||
|| !initiallyActiveMapObjectGroups.containsAll(activeMapObjectGroups)) return true;
|
||||
if (currentColorFilter != null) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void writeToParcel(DataOutputStream dest, WorldContext world) throws IOException {
|
||||
if (shouldSaveMapData(world)) {
|
||||
dest.writeBoolean(true);
|
||||
dest.writeInt(spawnAreas.length);
|
||||
for(MonsterSpawnArea a : spawnAreas) {
|
||||
dest.writeUTF(a.areaID);
|
||||
a.writeToParcel(dest);
|
||||
}
|
||||
dest.writeInt(activeMapObjectGroups.size());
|
||||
for(String s : activeMapObjectGroups) {
|
||||
dest.writeUTF(s);
|
||||
}
|
||||
dest.writeInt(groundBags.size());
|
||||
for(Loot l : groundBags) {
|
||||
l.writeToParcel(dest);
|
||||
}
|
||||
dest.writeBoolean(currentColorFilter != null);
|
||||
if (currentColorFilter != null) dest.writeUTF(currentColorFilter);
|
||||
dest.writeLong(lastVisitTime);
|
||||
} else {
|
||||
dest.writeBoolean(false);
|
||||
}
|
||||
dest.writeBoolean(visited);
|
||||
dest.writeUTF(lastSeenLayoutHash);
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.model.map;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.Constants;
|
||||
import com.gpl.rpg.AndorsTrail.controller.VisualEffectController.BloodSplatter;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Loot;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.MapObject.MapObjectType;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
import com.gpl.rpg.AndorsTrail.util.CoordRect;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.Size;
|
||||
|
||||
public final class PredefinedMap {
|
||||
private static final long VISIT_RESET = 0;
|
||||
|
||||
public final int xmlResourceId;
|
||||
public final String name;
|
||||
public final Size size;
|
||||
public final MapObject[] eventObjects;
|
||||
public final MonsterSpawnArea[] spawnAreas;
|
||||
public final List<String> initiallyActiveMapObjectGroups;
|
||||
public final List<String> activeMapObjectGroups;
|
||||
public final ArrayList<Loot> groundBags = new ArrayList<Loot>();
|
||||
public final String initialColorFilter;
|
||||
public boolean visited = false;
|
||||
public long lastVisitTime = VISIT_RESET;
|
||||
public String lastSeenLayoutHash = "";
|
||||
public final boolean isOutdoors;
|
||||
public String currentColorFilter = null;
|
||||
|
||||
public final ArrayList<BloodSplatter> splatters = new ArrayList<BloodSplatter>();
|
||||
|
||||
public PredefinedMap(
|
||||
int xmlResourceId
|
||||
, String name
|
||||
, Size size
|
||||
, MapObject[] eventObjects
|
||||
, MonsterSpawnArea[] spawnAreas
|
||||
, List<String> initiallyActiveMapObjectGroups
|
||||
, boolean isOutdoors
|
||||
, String colorFilter
|
||||
) {
|
||||
this.xmlResourceId = xmlResourceId;
|
||||
this.name = name;
|
||||
this.size = size;
|
||||
this.eventObjects = eventObjects;
|
||||
this.spawnAreas = spawnAreas;
|
||||
this.initiallyActiveMapObjectGroups = initiallyActiveMapObjectGroups;
|
||||
this.activeMapObjectGroups = new LinkedList<String>();
|
||||
this.activeMapObjectGroups.addAll(this.initiallyActiveMapObjectGroups);
|
||||
activateMapObjects();
|
||||
assert(size.width > 0);
|
||||
assert(size.height > 0);
|
||||
this.isOutdoors = isOutdoors;
|
||||
this.initialColorFilter = colorFilter;
|
||||
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
for (int i = 0; i < spawnAreas.length; i++) {
|
||||
for (int j = i + 1; j < spawnAreas.length; j++) {
|
||||
if (spawnAreas[i].areaID.equals(spawnAreas[j].areaID)) {
|
||||
L.log("WARNING: duplicate areaID " + spawnAreas[i].areaID + " in map " + this.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean isOutside(final Coord p) { return isOutside(p.x, p.y); }
|
||||
public final boolean isOutside(final int x, final int y) {
|
||||
if (x < 0) return true;
|
||||
if (y < 0) return true;
|
||||
if (x >= size.width) return true;
|
||||
if (y >= size.height) return true;
|
||||
return false;
|
||||
}
|
||||
public final boolean isOutside(final CoordRect area) {
|
||||
if (isOutside(area.topLeft)) return true;
|
||||
if (area.topLeft.x + area.size.width > size.width) return true;
|
||||
if (area.topLeft.y + area.size.height > size.height) return true;
|
||||
return false;
|
||||
}
|
||||
public boolean intersects(CoordRect area) {
|
||||
return new CoordRect(new Coord(0,0), size).intersects(area);
|
||||
}
|
||||
|
||||
public MapObject findEventObject(MapObject.MapObjectType objectType, String name) {
|
||||
for (MapObject o : eventObjects) {
|
||||
if (o.type != objectType) continue;
|
||||
if (!name.equals(o.id)) continue;
|
||||
return o;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public List<MapObject> getActiveEventObjectsAt(final Coord p) {
|
||||
List<MapObject> result = null;
|
||||
for (MapObject o : eventObjects) {
|
||||
if (!o.isActive) continue;
|
||||
if (!o.position.contains(p)) continue;
|
||||
//if (!activeMapObjectGroups.contains(o.group)) continue;
|
||||
if (result == null) result = new ArrayList<MapObject>();
|
||||
result.add(o);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public boolean hasContainerAt(final Coord p) {
|
||||
for (MapObject o : eventObjects) {
|
||||
if (!o.isActive) continue;
|
||||
if (o.type != MapObject.MapObjectType.container) continue;
|
||||
if (!o.position.contains(p)) continue;
|
||||
return true;
|
||||
}
|
||||
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 && (exceptMe == null || exceptMe != m)) return m;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public Monster getMonsterAt(final Coord p) { return getMonsterAt(p.x, p.y); }
|
||||
public Monster getMonsterAt(final int x, final int y) {
|
||||
for (MonsterSpawnArea a : spawnAreas) {
|
||||
Monster m = a.getMonsterAt(x, y);
|
||||
if (m != null) return m;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Monster findSpawnedMonster(final String monsterTypeID) {
|
||||
for (MonsterSpawnArea a : spawnAreas) {
|
||||
Monster m = a.findSpawnedMonster(monsterTypeID);
|
||||
if (m != null) return m;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Loot getBagAt(final Coord p) {
|
||||
for (Loot l : groundBags) {
|
||||
if (l.position.equals(p)) return l;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public Loot getBagOrCreateAt(final Coord position) {
|
||||
Loot b = getBagAt(position);
|
||||
if (b != null) return b;
|
||||
boolean isContainer = hasContainerAt(position);
|
||||
b = new Loot(!isContainer);
|
||||
b.position.set(position);
|
||||
if (isOutside(position)) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("WARNING: trying to place bag outside map. Map is " + size.toString() + ", bag tried to place at " + position.toString());
|
||||
}
|
||||
return b;
|
||||
}
|
||||
groundBags.add(b);
|
||||
return b;
|
||||
}
|
||||
public void itemDropped(ItemType itemType, int quantity, Coord position) {
|
||||
Loot l = getBagOrCreateAt(position);
|
||||
l.items.addItem(itemType, quantity);
|
||||
}
|
||||
public void removeGroundLoot(Loot loot) {
|
||||
groundBags.remove(loot);
|
||||
}
|
||||
public void resetForNewGame() {
|
||||
for (MonsterSpawnArea a : spawnAreas) {
|
||||
a.resetForNewGame();
|
||||
}
|
||||
activeMapObjectGroups.clear();
|
||||
activeMapObjectGroups.addAll(initiallyActiveMapObjectGroups);
|
||||
activateMapObjects();
|
||||
resetTemporaryData();
|
||||
groundBags.clear();
|
||||
visited = false;
|
||||
currentColorFilter = initialColorFilter;
|
||||
lastSeenLayoutHash = "";
|
||||
}
|
||||
|
||||
public boolean isRecentlyVisited() {
|
||||
if (lastVisitTime == VISIT_RESET) return false;
|
||||
return (System.currentTimeMillis() - lastVisitTime) < Constants.MAP_UNVISITED_RESPAWN_DURATION_MS;
|
||||
}
|
||||
public void updateLastVisitTime() {
|
||||
lastVisitTime = System.currentTimeMillis();
|
||||
}
|
||||
public void resetTemporaryData() {
|
||||
for(MonsterSpawnArea a : spawnAreas) {
|
||||
if (a.isUnique) a.resetShops();
|
||||
else a.removeAllMonsters();
|
||||
}
|
||||
splatters.clear();
|
||||
lastVisitTime = VISIT_RESET;
|
||||
}
|
||||
public boolean hasResetTemporaryData() {
|
||||
return lastVisitTime == VISIT_RESET;
|
||||
}
|
||||
|
||||
public void createAllContainerLoot() {
|
||||
for (MapObject o : eventObjects) {
|
||||
if (!o.isActive) continue;
|
||||
if (o.type != MapObject.MapObjectType.container) continue;
|
||||
createContainerLoot(o);
|
||||
}
|
||||
}
|
||||
|
||||
public void createContainerLoot(MapObject container) {
|
||||
Loot bag = getBagOrCreateAt(container.position.topLeft);
|
||||
container.dropList.createRandomLoot(bag, null);
|
||||
}
|
||||
|
||||
|
||||
private void activateMapObjects() {
|
||||
for (MapObject o : eventObjects) {
|
||||
o.isActive = activeMapObjectGroups.contains(o.group);
|
||||
}
|
||||
}
|
||||
|
||||
public void activateMapObjectGroup(String group) {
|
||||
if (!activeMapObjectGroups.contains(group)) {
|
||||
activeMapObjectGroups.add(group);
|
||||
for (MapObject o : eventObjects) {
|
||||
if (o.group.equals(group)) {
|
||||
o.isActive = true;
|
||||
if (o.type == MapObjectType.container) createContainerLoot(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void deactivateMapObjectGroup(String group) {
|
||||
if (activeMapObjectGroups.contains(group)) {
|
||||
activeMapObjectGroups.remove(group);
|
||||
for (MapObject o : eventObjects) {
|
||||
if (o.group.equals(group)) {
|
||||
o.isActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
public void readFromParcel(DataInputStream src, WorldContext world, ControllerContext controllers, int fileversion) throws IOException {
|
||||
boolean shouldLoadMapData = true;
|
||||
if (fileversion >= 37) shouldLoadMapData = src.readBoolean();
|
||||
|
||||
int loadedSpawnAreas = 0;
|
||||
if (shouldLoadMapData) {
|
||||
loadedSpawnAreas = src.readInt();
|
||||
for(int i = 0; i < loadedSpawnAreas; ++i) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
if (i >= this.spawnAreas.length) {
|
||||
L.log("WARNING: Trying to load monsters from savegame in map " + this.name + " for spawn #" + i + ". This will totally fail.");
|
||||
}
|
||||
}
|
||||
if(fileversion >= 43) {
|
||||
//Spawn areas now have unique IDs. Need to check as maps can change.
|
||||
String id = src.readUTF();
|
||||
int j = i;
|
||||
boolean found = false;
|
||||
do {
|
||||
if (this.spawnAreas[j].areaID.equals(id)) {
|
||||
this.spawnAreas[j].readFromParcel(src, world, fileversion);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
j = (j+1)%spawnAreas.length;
|
||||
} while (j != i);
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
if (!found) {
|
||||
L.log("WARNING: Trying to load monsters from savegame in map " + this.name + " for spawn #" + id + " but this area cannot be found. This will totally fail.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.spawnAreas[i].readFromParcel(src, world, fileversion);
|
||||
}
|
||||
}
|
||||
|
||||
activeMapObjectGroups.clear();
|
||||
if(fileversion >= 43) {
|
||||
int activeListLength = src.readInt();
|
||||
for (int i = 0; i < activeListLength; i++) {
|
||||
String activeGroupID = src.readUTF();
|
||||
activeMapObjectGroups.add(activeGroupID);
|
||||
}
|
||||
} else {
|
||||
activeMapObjectGroups.addAll(initiallyActiveMapObjectGroups);
|
||||
}
|
||||
activateMapObjects();
|
||||
|
||||
groundBags.clear();
|
||||
if (fileversion <= 5) return;
|
||||
|
||||
final int size2 = src.readInt();
|
||||
for(int i = 0; i < size2; ++i) {
|
||||
groundBags.add(new Loot(src, world, fileversion));
|
||||
}
|
||||
|
||||
if (fileversion <= 11) return;
|
||||
|
||||
if (fileversion < 37) visited = src.readBoolean();
|
||||
|
||||
if (fileversion <= 15) {
|
||||
if (visited) {
|
||||
lastVisitTime = System.currentTimeMillis();
|
||||
createAllContainerLoot();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (fileversion >= 43) {
|
||||
if (src.readBoolean()) {
|
||||
currentColorFilter = src.readUTF();
|
||||
} else {
|
||||
currentColorFilter = null;
|
||||
}
|
||||
}
|
||||
|
||||
lastVisitTime = src.readLong();
|
||||
|
||||
if (visited) {
|
||||
if (fileversion > 30 && fileversion < 36) {
|
||||
/*int lastVisitVersion = */src.readInt();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
activeMapObjectGroups.clear();
|
||||
activeMapObjectGroups.addAll(initiallyActiveMapObjectGroups);
|
||||
activateMapObjects();
|
||||
}
|
||||
if (fileversion >= 37) {
|
||||
if (fileversion < 41) visited = true;
|
||||
else visited = src.readBoolean();
|
||||
}
|
||||
|
||||
if (fileversion < 36) lastSeenLayoutHash = "";
|
||||
else lastSeenLayoutHash = src.readUTF();
|
||||
|
||||
for(int i = loadedSpawnAreas; i < spawnAreas.length; ++i) {
|
||||
MonsterSpawnArea area = this.spawnAreas[i];
|
||||
if (area.isUnique && visited) controllers.monsterSpawnController.spawnAllInArea(this, null, area, true);
|
||||
else area.resetForNewGame();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean shouldSaveMapData(WorldContext world) {
|
||||
if (!hasResetTemporaryData()) return true;
|
||||
if (this == world.model.currentMaps.map) return true;
|
||||
if (!groundBags.isEmpty()) return true;
|
||||
for (MonsterSpawnArea a : spawnAreas) {
|
||||
if (this.visited && a.isUnique) return true;
|
||||
if (a.isSpawning != a.isSpawningForNewGame) return true;
|
||||
}
|
||||
if (!activeMapObjectGroups.containsAll(initiallyActiveMapObjectGroups)
|
||||
|| !initiallyActiveMapObjectGroups.containsAll(activeMapObjectGroups)) return true;
|
||||
if (currentColorFilter != null) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void writeToParcel(DataOutputStream dest, WorldContext world) throws IOException {
|
||||
if (shouldSaveMapData(world)) {
|
||||
dest.writeBoolean(true);
|
||||
dest.writeInt(spawnAreas.length);
|
||||
for(MonsterSpawnArea a : spawnAreas) {
|
||||
dest.writeUTF(a.areaID);
|
||||
a.writeToParcel(dest);
|
||||
}
|
||||
dest.writeInt(activeMapObjectGroups.size());
|
||||
for(String s : activeMapObjectGroups) {
|
||||
dest.writeUTF(s);
|
||||
}
|
||||
dest.writeInt(groundBags.size());
|
||||
for(Loot l : groundBags) {
|
||||
l.writeToParcel(dest);
|
||||
}
|
||||
dest.writeBoolean(currentColorFilter != null);
|
||||
if (currentColorFilter != null) dest.writeUTF(currentColorFilter);
|
||||
dest.writeLong(lastVisitTime);
|
||||
} else {
|
||||
dest.writeBoolean(false);
|
||||
}
|
||||
dest.writeBoolean(visited);
|
||||
dest.writeUTF(lastSeenLayoutHash);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,494 +1,494 @@
|
||||
package com.gpl.rpg.AndorsTrail.model.map;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import android.content.res.Resources;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.MonsterType;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.MonsterTypeCollection;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.DropList;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.DropListCollection;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.TMXMapFileParser.TMXLayer;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.TMXMapFileParser.TMXLayerMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.TMXMapFileParser.TMXMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.TMXMapFileParser.TMXObject;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.TMXMapFileParser.TMXObjectGroup;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.TMXMapFileParser.TMXObjectMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.TMXMapFileParser.TMXProperty;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.TMXMapFileParser.TMXTileSet;
|
||||
import com.gpl.rpg.AndorsTrail.model.quest.QuestProgress;
|
||||
import com.gpl.rpg.AndorsTrail.model.script.Requirement;
|
||||
import com.gpl.rpg.AndorsTrail.resource.parsers.ResourceParserUtils;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCache;
|
||||
import com.gpl.rpg.AndorsTrail.util.ConstRange;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
import com.gpl.rpg.AndorsTrail.util.CoordRect;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.Range;
|
||||
import com.gpl.rpg.AndorsTrail.util.Size;
|
||||
|
||||
public final class TMXMapTranslator {
|
||||
private final ArrayList<TMXObjectMap> maps = new ArrayList<TMXObjectMap>();
|
||||
|
||||
public void read(Resources r, int xmlResourceId, String name) {
|
||||
maps.add(TMXMapFileParser.readObjectMap(r, xmlResourceId, name));
|
||||
}
|
||||
|
||||
public static LayeredTileMap readLayeredTileMap(Resources res, TileCache tileCache, PredefinedMap map) {
|
||||
TMXLayerMap resultMap = TMXMapFileParser.readLayerMap(res, map.xmlResourceId, map.name);
|
||||
return transformMap(resultMap, tileCache);
|
||||
}
|
||||
|
||||
public ArrayList<PredefinedMap> transformMaps(MonsterTypeCollection monsterTypes, DropListCollection dropLists) {
|
||||
return transformMaps(maps, monsterTypes, dropLists);
|
||||
}
|
||||
public ArrayList<PredefinedMap> transformMaps(Collection<TMXObjectMap> maps, MonsterTypeCollection monsterTypes, DropListCollection dropLists) {
|
||||
ArrayList<PredefinedMap> result = new ArrayList<PredefinedMap>();
|
||||
|
||||
for (TMXObjectMap m : maps) {
|
||||
assert(m.name != null);
|
||||
assert(m.name.length() > 0);
|
||||
assert(m.width > 0);
|
||||
assert(m.height > 0);
|
||||
|
||||
boolean isOutdoors = false;
|
||||
String colorFilter = null;
|
||||
for (TMXProperty p : m.properties) {
|
||||
if(p.name.equalsIgnoreCase("outdoors")) isOutdoors = (Integer.parseInt(p.value) != 0);
|
||||
else if(p.name.equalsIgnoreCase("colorfilter")) colorFilter = p.value;
|
||||
else if(AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) L.log("OPTIMIZE: Map " + m.name + " has unrecognized property \"" + p.name + "\".");
|
||||
}
|
||||
|
||||
final Size mapSize = new Size(m.width, m.height);
|
||||
List<MapObject> mapObjects = new LinkedList<MapObject>();
|
||||
List<MonsterSpawnArea> spawnAreas = new LinkedList<MonsterSpawnArea>();
|
||||
List<String> activeGroups = new LinkedList<String>();
|
||||
|
||||
for (TMXObjectGroup group : m.objectGroups) {
|
||||
boolean active = true;
|
||||
for (TMXProperty p : group.properties) {
|
||||
if (p.name.equalsIgnoreCase("active")) {
|
||||
active = Boolean.parseBoolean(p.value);
|
||||
} else if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("OPTIMIZE: Map " + m.name + ", group " + group.name + " has unrecognized property \"" + p.name + "\".");
|
||||
}
|
||||
}
|
||||
if (active) {
|
||||
activeGroups.add(group.name);
|
||||
}
|
||||
for (TMXObject object : group.objects) {
|
||||
final CoordRect position = getTMXObjectPosition(object, m);
|
||||
final Coord topLeft = position.topLeft;
|
||||
|
||||
if (object.type == null) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA)
|
||||
L.log("WARNING: Map " + m.name + ", object \"" + object.name + "\"@" + topLeft.toString() + " has null type.");
|
||||
} else if (object.type.equalsIgnoreCase("sign")) {
|
||||
String phraseID = object.name;
|
||||
for (TMXProperty p : object.properties) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) L.log("OPTIMIZE: Map " + m.name + ", sign " + object.name + "@" + topLeft.toString() + " has unrecognized property \"" + p.name + "\".");
|
||||
}
|
||||
mapObjects.add(MapObject.createMapSignEvent(position, phraseID, group.name));
|
||||
} else if (object.type.equalsIgnoreCase("mapchange")) {
|
||||
String map = null;
|
||||
String place = null;
|
||||
for (TMXProperty p : object.properties) {
|
||||
if (p.name.equalsIgnoreCase("map")) {
|
||||
map = p.value;
|
||||
} else if (p.name.equalsIgnoreCase("place")) {
|
||||
place = p.value;
|
||||
} else if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("OPTIMIZE: Map " + m.name + ", mapchange " + object.name + "@" + topLeft.toString() + " has unrecognized property \"" + p.name + "\".");
|
||||
}
|
||||
}
|
||||
mapObjects.add(MapObject.createMapChangeArea(position, object.name, map, place, group.name));
|
||||
} else if (object.type.equalsIgnoreCase("spawn")) {
|
||||
boolean isActiveForNewGame = true;
|
||||
boolean ignoreAreas = false;
|
||||
int maxQuantity = 1;
|
||||
int spawnChance = 10;
|
||||
String spawnGroup = object.name;
|
||||
for (TMXProperty p : object.properties) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
if (p.value.equals("")) {
|
||||
L.log("OPTIMIZE: Map " + m.name + ", spawn " + object.name + "@" + topLeft.toString() + " has property \"" + p.name + "\" without value.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (p.name.equalsIgnoreCase("quantity")) {
|
||||
maxQuantity = Integer.parseInt(p.value);
|
||||
} else if (p.name.equalsIgnoreCase("spawnchance")) {
|
||||
spawnChance = Integer.parseInt(p.value);
|
||||
} else if (p.name.equalsIgnoreCase("active")) {
|
||||
isActiveForNewGame = Boolean.parseBoolean(p.value);
|
||||
} else if (p.name.equalsIgnoreCase("ignoreAreas")) {
|
||||
ignoreAreas = Boolean.parseBoolean(p.value);
|
||||
} else if (p.name.equalsIgnoreCase("spawngroup")) {
|
||||
spawnGroup = p.value;
|
||||
} else if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("OPTIMIZE: Map " + m.name + ", spawn " + object.name + "@" + topLeft.toString() + " has unrecognized property \"" + p.name + "\".");
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<MonsterType> types = monsterTypes.getMonsterTypesFromSpawnGroup(spawnGroup);
|
||||
if (types.isEmpty()) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("OPTIMIZE: Map " + m.name + " contains spawn \"" + object.name + "\"@" + topLeft.toString() + " that does not correspond to any monsters. The spawn will be removed.");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
String[] monsterTypeIDs = new String[types.size()];
|
||||
boolean isUnique = types.get(0).isUnique;
|
||||
for (int i = 0; i < monsterTypeIDs.length; ++i) {
|
||||
monsterTypeIDs[i] = types.get(i).id;
|
||||
}
|
||||
MonsterSpawnArea area = new MonsterSpawnArea(
|
||||
position
|
||||
,new Range(maxQuantity, 0)
|
||||
,new Range(1000, spawnChance)
|
||||
,object.name
|
||||
,monsterTypeIDs
|
||||
,isUnique
|
||||
,ignoreAreas
|
||||
,group.name
|
||||
,isActiveForNewGame
|
||||
);
|
||||
spawnAreas.add(area);
|
||||
} else if (object.type.equalsIgnoreCase("key")) {
|
||||
String phraseID = "";
|
||||
for (TMXProperty p : object.properties) {
|
||||
if (p.name.equalsIgnoreCase("phrase")) {
|
||||
phraseID = p.value;
|
||||
} else if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
if (!requirementPropertiesNames.contains(p.name.toLowerCase())) {
|
||||
L.log("OPTIMIZE: Map " + m.name + ", key " + object.name + "@" + topLeft.toString() + " has unrecognized property \"" + p.name + "\".");
|
||||
}
|
||||
}
|
||||
}
|
||||
Requirement req = parseRequirement(object);
|
||||
mapObjects.add(MapObject.createKeyArea(position, phraseID, req, group.name));
|
||||
} else if (object.type.equals("rest")) {
|
||||
mapObjects.add(MapObject.createRestArea(position, object.name, group.name));
|
||||
} else if (object.type.equals("container")) {
|
||||
DropList dropList = dropLists.getDropList(object.name);
|
||||
if (dropList == null) continue;
|
||||
mapObjects.add(MapObject.createContainerArea(position, dropList, group.name));
|
||||
} else if (object.type.equals("replace")) {
|
||||
// Do nothing. Will be handled when reading map layers instead.
|
||||
} else if (object.type.equalsIgnoreCase("script")) {
|
||||
String phraseID = object.name;
|
||||
MapObject.MapObjectEvaluationType evaluateWhen = MapObject.MapObjectEvaluationType.whenEntering;
|
||||
for (TMXProperty p : object.properties) {
|
||||
if (p.name.equalsIgnoreCase("when")) {
|
||||
if (p.value.equalsIgnoreCase("enter")) {
|
||||
evaluateWhen = MapObject.MapObjectEvaluationType.whenEntering;
|
||||
} else if (p.value.equalsIgnoreCase("step")) {
|
||||
evaluateWhen = MapObject.MapObjectEvaluationType.onEveryStep;
|
||||
} else if (p.value.equalsIgnoreCase("round")) {
|
||||
evaluateWhen = MapObject.MapObjectEvaluationType.afterEveryRound;
|
||||
} else if (p.value.equalsIgnoreCase("always")) {
|
||||
evaluateWhen = MapObject.MapObjectEvaluationType.continuously;
|
||||
} else if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("OPTIMIZE: Map " + m.name + ", script " + object.name + "@" + topLeft.toString() + " has unrecognized value for \"when\" property: \"" + p.value + "\".");
|
||||
}
|
||||
} else if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("OPTIMIZE: Map " + m.name + ", script " + object.name + "@" + topLeft.toString() + " has unrecognized property \"" + p.name + "\".");
|
||||
}
|
||||
}
|
||||
mapObjects.add(MapObject.createScriptArea(position, phraseID, evaluateWhen, group.name));
|
||||
} else if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("OPTIMIZE: Map " + m.name + ", has unrecognized object type \"" + object.type + "\" for name \"" + object.name + "\".");
|
||||
}
|
||||
}
|
||||
}
|
||||
MapObject[] _eventObjects = new MapObject[mapObjects.size()];
|
||||
_eventObjects = mapObjects.toArray(_eventObjects);
|
||||
MonsterSpawnArea[] _spawnAreas = new MonsterSpawnArea[spawnAreas.size()];
|
||||
_spawnAreas = spawnAreas.toArray(_spawnAreas);
|
||||
|
||||
result.add(new PredefinedMap(m.xmlResourceId, m.name, mapSize, _eventObjects, _spawnAreas, activeGroups, isOutdoors, colorFilter));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static final List<String> requirementPropertiesNames = Arrays.asList(new String[]{"requireType".toLowerCase(), "requireId".toLowerCase(), "requireValue".toLowerCase(), "requireNegation".toLowerCase()});
|
||||
|
||||
private static Requirement parseRequirement(TMXObject object) {
|
||||
Requirement.RequirementType requireType = Requirement.RequirementType.questProgress;
|
||||
String requireId = null;
|
||||
int requireValue = 0;
|
||||
boolean requireNegation = false;
|
||||
ConstRange requireChance = null;
|
||||
for (TMXProperty p : object.properties) {
|
||||
if (p.name.equalsIgnoreCase("requireType")) {
|
||||
try {
|
||||
requireType = Requirement.RequirementType.valueOf(p.value);
|
||||
} catch (IllegalArgumentException e) {
|
||||
requireType = null;
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("OPTIMIZE: Unrecognized requirement type: "+p.value);
|
||||
}
|
||||
}
|
||||
} else if (p.name.equalsIgnoreCase("requireId")) {
|
||||
requireId = p.value;
|
||||
} else if (p.name.equalsIgnoreCase("requireValue")) {
|
||||
requireValue = Integer.parseInt(p.value);
|
||||
} else if (p.name.equalsIgnoreCase("requireNegation")) {
|
||||
requireNegation = Boolean.parseBoolean(p.value);
|
||||
}
|
||||
}
|
||||
if (requireType == null) return null;
|
||||
if (requireType == Requirement.RequirementType.random)
|
||||
{
|
||||
requireChance = ResourceParserUtils.parseChance(requireId);
|
||||
requireId = null;
|
||||
}
|
||||
|
||||
return new Requirement(requireType, requireId, requireValue, requireNegation, requireChance);
|
||||
}
|
||||
|
||||
private static CoordRect getTMXObjectPosition(TMXObject object, TMXMap m) {
|
||||
final Coord topLeft = new Coord(
|
||||
Math.round(((float)object.x) / m.tilewidth)
|
||||
,Math.round(((float)object.y) / m.tileheight)
|
||||
);
|
||||
final int width = Math.round(((float)object.width) / m.tilewidth);
|
||||
final int height = Math.round(((float)object.height) / m.tileheight);
|
||||
return new CoordRect(topLeft, new Size(width, height));
|
||||
}
|
||||
|
||||
private static final String LAYERNAME_BASE = "base";
|
||||
private static final String LAYERNAME_GROUND = "ground";
|
||||
private static final String LAYERNAME_OBJECTS = "objects";
|
||||
private static final String LAYERNAME_ABOVE = "above";
|
||||
private static final String LAYERNAME_TOP = "top";
|
||||
private static final String LAYERNAME_WALKABLE = "walkable";
|
||||
private static final String PROPNAME_FILTER = "colorfilter";
|
||||
private static final SetOfLayerNames defaultLayerNames = new SetOfLayerNames(LAYERNAME_BASE, LAYERNAME_GROUND, LAYERNAME_OBJECTS, LAYERNAME_ABOVE, LAYERNAME_TOP, LAYERNAME_WALKABLE);
|
||||
|
||||
private static LayeredTileMap transformMap(TMXLayerMap map, TileCache tileCache) {
|
||||
final Size mapSize = new Size(map.width, map.height);
|
||||
LayeredTileMap.ColorFilterId colorFilter = LayeredTileMap.ColorFilterId.none;
|
||||
for (TMXProperty prop : map.properties) {
|
||||
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>();
|
||||
for (TMXLayer layer : map.layers) {
|
||||
String layerName = layer.name;
|
||||
assert(layerName != null);
|
||||
assert(layerName.length() > 0);
|
||||
layerName = layerName.toLowerCase();
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
if (layersPerLayerName.containsKey(layerName)) {
|
||||
L.log("WARNING: Map \"" + map.name + "\" contains multiple layers with name \"" + layerName + "\".");
|
||||
}
|
||||
}
|
||||
layersPerLayerName.put(layerName, layer);
|
||||
}
|
||||
|
||||
MapSection defaultLayout = transformMapSection(map,
|
||||
tileCache,
|
||||
new CoordRect(new Coord(0,0), mapSize),
|
||||
layersPerLayerName,
|
||||
usedTileIDs,
|
||||
defaultLayerNames);
|
||||
|
||||
ArrayList<ReplaceableMapSection> replaceableSections = new ArrayList<ReplaceableMapSection>();
|
||||
for (TMXObjectGroup objectGroup : map.objectGroups) {
|
||||
for(TMXObject obj : objectGroup.objects) {
|
||||
if ("replace".equals(obj.type)) {
|
||||
final CoordRect position = getTMXObjectPosition(obj, map);
|
||||
SetOfLayerNames layerNames = new SetOfLayerNames();
|
||||
for (TMXProperty prop : obj.properties) {
|
||||
if (prop.name.equalsIgnoreCase(LAYERNAME_BASE)) layerNames.baseLayerName = prop.value;
|
||||
else if (prop.name.equalsIgnoreCase(LAYERNAME_GROUND)) layerNames.groundLayerName = prop.value;
|
||||
else if (prop.name.equalsIgnoreCase(LAYERNAME_OBJECTS)) layerNames.objectsLayerName = prop.value;
|
||||
else if (prop.name.equalsIgnoreCase(LAYERNAME_ABOVE)) layerNames.aboveLayersName = prop.value;
|
||||
else if (prop.name.equalsIgnoreCase(LAYERNAME_TOP)) layerNames.topLayersName = prop.value;
|
||||
else if (prop.name.equalsIgnoreCase(LAYERNAME_WALKABLE)) layerNames.walkableLayersName = prop.value;
|
||||
else if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
if (!requirementPropertiesNames.contains(prop.name.toLowerCase()))
|
||||
L.log("OPTIMIZE: Map " + map.name + " contains replace area with unknown property \"" + prop.name + "\".");
|
||||
}
|
||||
}
|
||||
MapSection replacementSection = transformMapSection(map, tileCache, position, layersPerLayerName, usedTileIDs, layerNames);
|
||||
Requirement req = parseRequirement(obj);
|
||||
if (req == null || !req.isValid()) {
|
||||
QuestProgress qp = QuestProgress.parseQuestProgress(obj.name);
|
||||
if (qp != null) req = new Requirement(qp);
|
||||
}
|
||||
if (req == null || !req.isValid()) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("WARNING: Map " + map.name + " contains replace area "+obj.name+" with unparsable requirement");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
replaceableSections.add(new ReplaceableMapSection(position, replacementSection, req, objectGroup.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ReplaceableMapSection[] replaceableSections_ = null;
|
||||
if (!replaceableSections.isEmpty()) {
|
||||
replaceableSections_ = replaceableSections.toArray(new ReplaceableMapSection[replaceableSections.size()]);
|
||||
}
|
||||
return new LayeredTileMap(mapSize, defaultLayout, replaceableSections_, colorFilter, usedTileIDs);
|
||||
}
|
||||
|
||||
private static MapSection transformMapSection(
|
||||
TMXLayerMap srcMap,
|
||||
TileCache tileCache,
|
||||
CoordRect area,
|
||||
HashMap<String, TMXLayer> layersPerLayerName,
|
||||
HashSet<Integer> usedTileIDs,
|
||||
SetOfLayerNames layerNames
|
||||
) {
|
||||
|
||||
final MapLayer layerBase = transformMapLayer(layersPerLayerName, layerNames.baseLayerName, srcMap, tileCache, area, usedTileIDs);
|
||||
final MapLayer layerGround = transformMapLayer(layersPerLayerName, layerNames.groundLayerName, srcMap, tileCache, area, usedTileIDs);
|
||||
final MapLayer layerObjects = transformMapLayer(layersPerLayerName, layerNames.objectsLayerName, srcMap, tileCache, area, usedTileIDs);
|
||||
final MapLayer layerAbove = transformMapLayer(layersPerLayerName, layerNames.aboveLayersName, srcMap, tileCache, area, usedTileIDs);
|
||||
final MapLayer layerTop = transformMapLayer(layersPerLayerName, layerNames.topLayersName, srcMap, tileCache, area, usedTileIDs);
|
||||
boolean[][] isWalkable = transformWalkableMapLayer(findLayer(layersPerLayerName, layerNames.walkableLayersName, srcMap.name), area);
|
||||
byte[] layoutHash = calculateLayoutHash(srcMap, layersPerLayerName, layerNames);
|
||||
return new MapSection(layerBase, layerGround, layerObjects, layerAbove, layerTop, isWalkable, layoutHash);
|
||||
}
|
||||
|
||||
private static TMXLayer findLayer(HashMap<String, TMXLayer> layersPerLayerName, String layerName, String mapName) {
|
||||
if (layerName == null) return null;
|
||||
if (layerName.length() == 0) return null;
|
||||
TMXLayer result = layersPerLayerName.get(layerName.toLowerCase());
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
if (result == null && !"top".equals(layerName) && !"base".equals(layerName)) {
|
||||
L.log("WARNING: Cannot find maplayer \"" + layerName + "\" requested by map \"" + mapName + "\".");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static MapLayer transformMapLayer(
|
||||
HashMap<String, TMXLayer> layersPerLayerName,
|
||||
String layerName,
|
||||
TMXLayerMap srcMap,
|
||||
TileCache tileCache,
|
||||
CoordRect area,
|
||||
HashSet<Integer> usedTileIDs
|
||||
) {
|
||||
TMXLayer srcLayer = findLayer(layersPerLayerName, layerName, srcMap.name);
|
||||
if (srcLayer == null) return null;
|
||||
final MapLayer result = new MapLayer(area.size);
|
||||
Tile tile = new Tile();
|
||||
for (int dy = 0, sy = area.topLeft.y; dy < area.size.height; ++dy, ++sy) {
|
||||
for (int dx = 0, sx = area.topLeft.x; dx < area.size.width; ++dx, ++sx) {
|
||||
int gid = srcLayer.gids[sx][sy];
|
||||
if (gid <= 0) continue;
|
||||
|
||||
if (!getTile(srcMap, gid, tile)) continue;
|
||||
|
||||
int tileID = tileCache.getTileID(tile.tilesetName, tile.localId);
|
||||
result.tiles[dx][dy] = tileID;
|
||||
usedTileIDs.add(tileID);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static boolean[][] transformWalkableMapLayer(TMXLayer srcLayer, CoordRect area) {
|
||||
if (srcLayer == null) return null;
|
||||
final boolean[][] isWalkable = new boolean[area.size.width][area.size.height];
|
||||
for (int x = 0; x < area.size.width; ++x) {
|
||||
Arrays.fill(isWalkable[x], true);
|
||||
}
|
||||
for (int dy = 0, sy = area.topLeft.y; dy < area.size.height; ++dy, ++sy) {
|
||||
for (int dx = 0, sx = area.topLeft.x; dx < area.size.width; ++dx, ++sx) {
|
||||
int gid = srcLayer.gids[sx][sy];
|
||||
if (gid > 0) {
|
||||
isWalkable[dx][dy] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isWalkable;
|
||||
}
|
||||
|
||||
private static byte[] calculateLayoutHash(TMXLayerMap map, HashMap<String, TMXLayer> layersPerLayerName, SetOfLayerNames layerNames) {
|
||||
try {
|
||||
MessageDigest digest = MessageDigest.getInstance("MD5");
|
||||
digestLayer(layersPerLayerName, layerNames.baseLayerName, map, digest);
|
||||
digestLayer(layersPerLayerName, layerNames.groundLayerName, map, digest);
|
||||
digestLayer(layersPerLayerName, layerNames.objectsLayerName, map, digest);
|
||||
digestLayer(layersPerLayerName, layerNames.aboveLayersName, map, digest);
|
||||
digestLayer(layersPerLayerName, layerNames.topLayersName, map, digest);
|
||||
return digest.digest();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
L.log("ERROR: Failed to create layout hash for map " + map.name + " : " + e.toString());
|
||||
}
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
private static void digestLayer(HashMap<String, TMXLayer> layersPerLayerName, String layerName, TMXLayerMap map, MessageDigest digest) {
|
||||
TMXLayer srcLayer = findLayer(layersPerLayerName, layerName, map.name);
|
||||
if (srcLayer == null) return;
|
||||
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];
|
||||
if (ts.firstgid <= gid) {
|
||||
dest.tilesetName = ts.name;
|
||||
dest.localId = (gid - ts.firstgid);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
L.log("WARNING: Cannot find tile for gid " + gid);
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final class Tile {
|
||||
public String tilesetName;
|
||||
public int localId;
|
||||
}
|
||||
|
||||
private static final class SetOfLayerNames {
|
||||
public String baseLayerName;
|
||||
public String groundLayerName;
|
||||
public String objectsLayerName;
|
||||
public String aboveLayersName;
|
||||
public String topLayersName;
|
||||
public String walkableLayersName;
|
||||
public SetOfLayerNames() {
|
||||
this.baseLayerName = null;
|
||||
this.groundLayerName = null;
|
||||
this.objectsLayerName = null;
|
||||
this.aboveLayersName = null;
|
||||
this.topLayersName = null;
|
||||
this.walkableLayersName = null;
|
||||
}
|
||||
public SetOfLayerNames(String baseLayerName, String groundLayerName, String objectsLayerName, String aboveLayersName, String topLayersName, String walkableLayersName) {
|
||||
this.baseLayerName = baseLayerName;
|
||||
this.groundLayerName = groundLayerName;
|
||||
this.objectsLayerName = objectsLayerName;
|
||||
this.aboveLayersName = aboveLayersName;
|
||||
this.topLayersName = topLayersName;
|
||||
this.walkableLayersName = walkableLayersName;
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.model.map;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import android.content.res.Resources;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.MonsterType;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.MonsterTypeCollection;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.DropList;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.DropListCollection;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.TMXMapFileParser.TMXLayer;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.TMXMapFileParser.TMXLayerMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.TMXMapFileParser.TMXMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.TMXMapFileParser.TMXObject;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.TMXMapFileParser.TMXObjectGroup;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.TMXMapFileParser.TMXObjectMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.TMXMapFileParser.TMXProperty;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.TMXMapFileParser.TMXTileSet;
|
||||
import com.gpl.rpg.AndorsTrail.model.quest.QuestProgress;
|
||||
import com.gpl.rpg.AndorsTrail.model.script.Requirement;
|
||||
import com.gpl.rpg.AndorsTrail.resource.parsers.ResourceParserUtils;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCache;
|
||||
import com.gpl.rpg.AndorsTrail.util.ConstRange;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
import com.gpl.rpg.AndorsTrail.util.CoordRect;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.Range;
|
||||
import com.gpl.rpg.AndorsTrail.util.Size;
|
||||
|
||||
public final class TMXMapTranslator {
|
||||
private final ArrayList<TMXObjectMap> maps = new ArrayList<TMXObjectMap>();
|
||||
|
||||
public void read(Resources r, int xmlResourceId, String name) {
|
||||
maps.add(TMXMapFileParser.readObjectMap(r, xmlResourceId, name));
|
||||
}
|
||||
|
||||
public static LayeredTileMap readLayeredTileMap(Resources res, TileCache tileCache, PredefinedMap map) {
|
||||
TMXLayerMap resultMap = TMXMapFileParser.readLayerMap(res, map.xmlResourceId, map.name);
|
||||
return transformMap(resultMap, tileCache);
|
||||
}
|
||||
|
||||
public ArrayList<PredefinedMap> transformMaps(MonsterTypeCollection monsterTypes, DropListCollection dropLists) {
|
||||
return transformMaps(maps, monsterTypes, dropLists);
|
||||
}
|
||||
public ArrayList<PredefinedMap> transformMaps(Collection<TMXObjectMap> maps, MonsterTypeCollection monsterTypes, DropListCollection dropLists) {
|
||||
ArrayList<PredefinedMap> result = new ArrayList<PredefinedMap>();
|
||||
|
||||
for (TMXObjectMap m : maps) {
|
||||
assert(m.name != null);
|
||||
assert(m.name.length() > 0);
|
||||
assert(m.width > 0);
|
||||
assert(m.height > 0);
|
||||
|
||||
boolean isOutdoors = false;
|
||||
String colorFilter = null;
|
||||
for (TMXProperty p : m.properties) {
|
||||
if(p.name.equalsIgnoreCase("outdoors")) isOutdoors = (Integer.parseInt(p.value) != 0);
|
||||
else if(p.name.equalsIgnoreCase("colorfilter")) colorFilter = p.value;
|
||||
else if(AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) L.log("OPTIMIZE: Map " + m.name + " has unrecognized property \"" + p.name + "\".");
|
||||
}
|
||||
|
||||
final Size mapSize = new Size(m.width, m.height);
|
||||
List<MapObject> mapObjects = new LinkedList<MapObject>();
|
||||
List<MonsterSpawnArea> spawnAreas = new LinkedList<MonsterSpawnArea>();
|
||||
List<String> activeGroups = new LinkedList<String>();
|
||||
|
||||
for (TMXObjectGroup group : m.objectGroups) {
|
||||
boolean active = true;
|
||||
for (TMXProperty p : group.properties) {
|
||||
if (p.name.equalsIgnoreCase("active")) {
|
||||
active = Boolean.parseBoolean(p.value);
|
||||
} else if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("OPTIMIZE: Map " + m.name + ", group " + group.name + " has unrecognized property \"" + p.name + "\".");
|
||||
}
|
||||
}
|
||||
if (active) {
|
||||
activeGroups.add(group.name);
|
||||
}
|
||||
for (TMXObject object : group.objects) {
|
||||
final CoordRect position = getTMXObjectPosition(object, m);
|
||||
final Coord topLeft = position.topLeft;
|
||||
|
||||
if (object.type == null) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA)
|
||||
L.log("WARNING: Map " + m.name + ", object \"" + object.name + "\"@" + topLeft.toString() + " has null type.");
|
||||
} else if (object.type.equalsIgnoreCase("sign")) {
|
||||
String phraseID = object.name;
|
||||
for (TMXProperty p : object.properties) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) L.log("OPTIMIZE: Map " + m.name + ", sign " + object.name + "@" + topLeft.toString() + " has unrecognized property \"" + p.name + "\".");
|
||||
}
|
||||
mapObjects.add(MapObject.createMapSignEvent(position, phraseID, group.name));
|
||||
} else if (object.type.equalsIgnoreCase("mapchange")) {
|
||||
String map = null;
|
||||
String place = null;
|
||||
for (TMXProperty p : object.properties) {
|
||||
if (p.name.equalsIgnoreCase("map")) {
|
||||
map = p.value;
|
||||
} else if (p.name.equalsIgnoreCase("place")) {
|
||||
place = p.value;
|
||||
} else if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("OPTIMIZE: Map " + m.name + ", mapchange " + object.name + "@" + topLeft.toString() + " has unrecognized property \"" + p.name + "\".");
|
||||
}
|
||||
}
|
||||
mapObjects.add(MapObject.createMapChangeArea(position, object.name, map, place, group.name));
|
||||
} else if (object.type.equalsIgnoreCase("spawn")) {
|
||||
boolean isActiveForNewGame = true;
|
||||
boolean ignoreAreas = false;
|
||||
int maxQuantity = 1;
|
||||
int spawnChance = 10;
|
||||
String spawnGroup = object.name;
|
||||
for (TMXProperty p : object.properties) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
if (p.value.equals("")) {
|
||||
L.log("OPTIMIZE: Map " + m.name + ", spawn " + object.name + "@" + topLeft.toString() + " has property \"" + p.name + "\" without value.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (p.name.equalsIgnoreCase("quantity")) {
|
||||
maxQuantity = Integer.parseInt(p.value);
|
||||
} else if (p.name.equalsIgnoreCase("spawnchance")) {
|
||||
spawnChance = Integer.parseInt(p.value);
|
||||
} else if (p.name.equalsIgnoreCase("active")) {
|
||||
isActiveForNewGame = Boolean.parseBoolean(p.value);
|
||||
} else if (p.name.equalsIgnoreCase("ignoreAreas")) {
|
||||
ignoreAreas = Boolean.parseBoolean(p.value);
|
||||
} else if (p.name.equalsIgnoreCase("spawngroup")) {
|
||||
spawnGroup = p.value;
|
||||
} else if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("OPTIMIZE: Map " + m.name + ", spawn " + object.name + "@" + topLeft.toString() + " has unrecognized property \"" + p.name + "\".");
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<MonsterType> types = monsterTypes.getMonsterTypesFromSpawnGroup(spawnGroup);
|
||||
if (types.isEmpty()) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("OPTIMIZE: Map " + m.name + " contains spawn \"" + object.name + "\"@" + topLeft.toString() + " that does not correspond to any monsters. The spawn will be removed.");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
String[] monsterTypeIDs = new String[types.size()];
|
||||
boolean isUnique = types.get(0).isUnique;
|
||||
for (int i = 0; i < monsterTypeIDs.length; ++i) {
|
||||
monsterTypeIDs[i] = types.get(i).id;
|
||||
}
|
||||
MonsterSpawnArea area = new MonsterSpawnArea(
|
||||
position
|
||||
,new Range(maxQuantity, 0)
|
||||
,new Range(1000, spawnChance)
|
||||
,object.name
|
||||
,monsterTypeIDs
|
||||
,isUnique
|
||||
,ignoreAreas
|
||||
,group.name
|
||||
,isActiveForNewGame
|
||||
);
|
||||
spawnAreas.add(area);
|
||||
} else if (object.type.equalsIgnoreCase("key")) {
|
||||
String phraseID = "";
|
||||
for (TMXProperty p : object.properties) {
|
||||
if (p.name.equalsIgnoreCase("phrase")) {
|
||||
phraseID = p.value;
|
||||
} else if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
if (!requirementPropertiesNames.contains(p.name.toLowerCase())) {
|
||||
L.log("OPTIMIZE: Map " + m.name + ", key " + object.name + "@" + topLeft.toString() + " has unrecognized property \"" + p.name + "\".");
|
||||
}
|
||||
}
|
||||
}
|
||||
Requirement req = parseRequirement(object);
|
||||
mapObjects.add(MapObject.createKeyArea(position, phraseID, req, group.name));
|
||||
} else if (object.type.equals("rest")) {
|
||||
mapObjects.add(MapObject.createRestArea(position, object.name, group.name));
|
||||
} else if (object.type.equals("container")) {
|
||||
DropList dropList = dropLists.getDropList(object.name);
|
||||
if (dropList == null) continue;
|
||||
mapObjects.add(MapObject.createContainerArea(position, dropList, group.name));
|
||||
} else if (object.type.equals("replace")) {
|
||||
// Do nothing. Will be handled when reading map layers instead.
|
||||
} else if (object.type.equalsIgnoreCase("script")) {
|
||||
String phraseID = object.name;
|
||||
MapObject.MapObjectEvaluationType evaluateWhen = MapObject.MapObjectEvaluationType.whenEntering;
|
||||
for (TMXProperty p : object.properties) {
|
||||
if (p.name.equalsIgnoreCase("when")) {
|
||||
if (p.value.equalsIgnoreCase("enter")) {
|
||||
evaluateWhen = MapObject.MapObjectEvaluationType.whenEntering;
|
||||
} else if (p.value.equalsIgnoreCase("step")) {
|
||||
evaluateWhen = MapObject.MapObjectEvaluationType.onEveryStep;
|
||||
} else if (p.value.equalsIgnoreCase("round")) {
|
||||
evaluateWhen = MapObject.MapObjectEvaluationType.afterEveryRound;
|
||||
} else if (p.value.equalsIgnoreCase("always")) {
|
||||
evaluateWhen = MapObject.MapObjectEvaluationType.continuously;
|
||||
} else if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("OPTIMIZE: Map " + m.name + ", script " + object.name + "@" + topLeft.toString() + " has unrecognized value for \"when\" property: \"" + p.value + "\".");
|
||||
}
|
||||
} else if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("OPTIMIZE: Map " + m.name + ", script " + object.name + "@" + topLeft.toString() + " has unrecognized property \"" + p.name + "\".");
|
||||
}
|
||||
}
|
||||
mapObjects.add(MapObject.createScriptArea(position, phraseID, evaluateWhen, group.name));
|
||||
} else if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("OPTIMIZE: Map " + m.name + ", has unrecognized object type \"" + object.type + "\" for name \"" + object.name + "\".");
|
||||
}
|
||||
}
|
||||
}
|
||||
MapObject[] _eventObjects = new MapObject[mapObjects.size()];
|
||||
_eventObjects = mapObjects.toArray(_eventObjects);
|
||||
MonsterSpawnArea[] _spawnAreas = new MonsterSpawnArea[spawnAreas.size()];
|
||||
_spawnAreas = spawnAreas.toArray(_spawnAreas);
|
||||
|
||||
result.add(new PredefinedMap(m.xmlResourceId, m.name, mapSize, _eventObjects, _spawnAreas, activeGroups, isOutdoors, colorFilter));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static final List<String> requirementPropertiesNames = Arrays.asList(new String[]{"requireType".toLowerCase(), "requireId".toLowerCase(), "requireValue".toLowerCase(), "requireNegation".toLowerCase()});
|
||||
|
||||
private static Requirement parseRequirement(TMXObject object) {
|
||||
Requirement.RequirementType requireType = Requirement.RequirementType.questProgress;
|
||||
String requireId = null;
|
||||
int requireValue = 0;
|
||||
boolean requireNegation = false;
|
||||
ConstRange requireChance = null;
|
||||
for (TMXProperty p : object.properties) {
|
||||
if (p.name.equalsIgnoreCase("requireType")) {
|
||||
try {
|
||||
requireType = Requirement.RequirementType.valueOf(p.value);
|
||||
} catch (IllegalArgumentException e) {
|
||||
requireType = null;
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("OPTIMIZE: Unrecognized requirement type: "+p.value);
|
||||
}
|
||||
}
|
||||
} else if (p.name.equalsIgnoreCase("requireId")) {
|
||||
requireId = p.value;
|
||||
} else if (p.name.equalsIgnoreCase("requireValue")) {
|
||||
requireValue = Integer.parseInt(p.value);
|
||||
} else if (p.name.equalsIgnoreCase("requireNegation")) {
|
||||
requireNegation = Boolean.parseBoolean(p.value);
|
||||
}
|
||||
}
|
||||
if (requireType == null) return null;
|
||||
if (requireType == Requirement.RequirementType.random)
|
||||
{
|
||||
requireChance = ResourceParserUtils.parseChance(requireId);
|
||||
requireId = null;
|
||||
}
|
||||
|
||||
return new Requirement(requireType, requireId, requireValue, requireNegation, requireChance);
|
||||
}
|
||||
|
||||
private static CoordRect getTMXObjectPosition(TMXObject object, TMXMap m) {
|
||||
final Coord topLeft = new Coord(
|
||||
Math.round(((float)object.x) / m.tilewidth)
|
||||
,Math.round(((float)object.y) / m.tileheight)
|
||||
);
|
||||
final int width = Math.round(((float)object.width) / m.tilewidth);
|
||||
final int height = Math.round(((float)object.height) / m.tileheight);
|
||||
return new CoordRect(topLeft, new Size(width, height));
|
||||
}
|
||||
|
||||
private static final String LAYERNAME_BASE = "base";
|
||||
private static final String LAYERNAME_GROUND = "ground";
|
||||
private static final String LAYERNAME_OBJECTS = "objects";
|
||||
private static final String LAYERNAME_ABOVE = "above";
|
||||
private static final String LAYERNAME_TOP = "top";
|
||||
private static final String LAYERNAME_WALKABLE = "walkable";
|
||||
private static final String PROPNAME_FILTER = "colorfilter";
|
||||
private static final SetOfLayerNames defaultLayerNames = new SetOfLayerNames(LAYERNAME_BASE, LAYERNAME_GROUND, LAYERNAME_OBJECTS, LAYERNAME_ABOVE, LAYERNAME_TOP, LAYERNAME_WALKABLE);
|
||||
|
||||
private static LayeredTileMap transformMap(TMXLayerMap map, TileCache tileCache) {
|
||||
final Size mapSize = new Size(map.width, map.height);
|
||||
LayeredTileMap.ColorFilterId colorFilter = LayeredTileMap.ColorFilterId.none;
|
||||
for (TMXProperty prop : map.properties) {
|
||||
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>();
|
||||
for (TMXLayer layer : map.layers) {
|
||||
String layerName = layer.name;
|
||||
assert(layerName != null);
|
||||
assert(layerName.length() > 0);
|
||||
layerName = layerName.toLowerCase();
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
if (layersPerLayerName.containsKey(layerName)) {
|
||||
L.log("WARNING: Map \"" + map.name + "\" contains multiple layers with name \"" + layerName + "\".");
|
||||
}
|
||||
}
|
||||
layersPerLayerName.put(layerName, layer);
|
||||
}
|
||||
|
||||
MapSection defaultLayout = transformMapSection(map,
|
||||
tileCache,
|
||||
new CoordRect(new Coord(0,0), mapSize),
|
||||
layersPerLayerName,
|
||||
usedTileIDs,
|
||||
defaultLayerNames);
|
||||
|
||||
ArrayList<ReplaceableMapSection> replaceableSections = new ArrayList<ReplaceableMapSection>();
|
||||
for (TMXObjectGroup objectGroup : map.objectGroups) {
|
||||
for(TMXObject obj : objectGroup.objects) {
|
||||
if ("replace".equals(obj.type)) {
|
||||
final CoordRect position = getTMXObjectPosition(obj, map);
|
||||
SetOfLayerNames layerNames = new SetOfLayerNames();
|
||||
for (TMXProperty prop : obj.properties) {
|
||||
if (prop.name.equalsIgnoreCase(LAYERNAME_BASE)) layerNames.baseLayerName = prop.value;
|
||||
else if (prop.name.equalsIgnoreCase(LAYERNAME_GROUND)) layerNames.groundLayerName = prop.value;
|
||||
else if (prop.name.equalsIgnoreCase(LAYERNAME_OBJECTS)) layerNames.objectsLayerName = prop.value;
|
||||
else if (prop.name.equalsIgnoreCase(LAYERNAME_ABOVE)) layerNames.aboveLayersName = prop.value;
|
||||
else if (prop.name.equalsIgnoreCase(LAYERNAME_TOP)) layerNames.topLayersName = prop.value;
|
||||
else if (prop.name.equalsIgnoreCase(LAYERNAME_WALKABLE)) layerNames.walkableLayersName = prop.value;
|
||||
else if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
if (!requirementPropertiesNames.contains(prop.name.toLowerCase()))
|
||||
L.log("OPTIMIZE: Map " + map.name + " contains replace area with unknown property \"" + prop.name + "\".");
|
||||
}
|
||||
}
|
||||
MapSection replacementSection = transformMapSection(map, tileCache, position, layersPerLayerName, usedTileIDs, layerNames);
|
||||
Requirement req = parseRequirement(obj);
|
||||
if (req == null || !req.isValid()) {
|
||||
QuestProgress qp = QuestProgress.parseQuestProgress(obj.name);
|
||||
if (qp != null) req = new Requirement(qp);
|
||||
}
|
||||
if (req == null || !req.isValid()) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("WARNING: Map " + map.name + " contains replace area "+obj.name+" with unparsable requirement");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
replaceableSections.add(new ReplaceableMapSection(position, replacementSection, req, objectGroup.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ReplaceableMapSection[] replaceableSections_ = null;
|
||||
if (!replaceableSections.isEmpty()) {
|
||||
replaceableSections_ = replaceableSections.toArray(new ReplaceableMapSection[replaceableSections.size()]);
|
||||
}
|
||||
return new LayeredTileMap(mapSize, defaultLayout, replaceableSections_, colorFilter, usedTileIDs);
|
||||
}
|
||||
|
||||
private static MapSection transformMapSection(
|
||||
TMXLayerMap srcMap,
|
||||
TileCache tileCache,
|
||||
CoordRect area,
|
||||
HashMap<String, TMXLayer> layersPerLayerName,
|
||||
HashSet<Integer> usedTileIDs,
|
||||
SetOfLayerNames layerNames
|
||||
) {
|
||||
|
||||
final MapLayer layerBase = transformMapLayer(layersPerLayerName, layerNames.baseLayerName, srcMap, tileCache, area, usedTileIDs);
|
||||
final MapLayer layerGround = transformMapLayer(layersPerLayerName, layerNames.groundLayerName, srcMap, tileCache, area, usedTileIDs);
|
||||
final MapLayer layerObjects = transformMapLayer(layersPerLayerName, layerNames.objectsLayerName, srcMap, tileCache, area, usedTileIDs);
|
||||
final MapLayer layerAbove = transformMapLayer(layersPerLayerName, layerNames.aboveLayersName, srcMap, tileCache, area, usedTileIDs);
|
||||
final MapLayer layerTop = transformMapLayer(layersPerLayerName, layerNames.topLayersName, srcMap, tileCache, area, usedTileIDs);
|
||||
boolean[][] isWalkable = transformWalkableMapLayer(findLayer(layersPerLayerName, layerNames.walkableLayersName, srcMap.name), area);
|
||||
byte[] layoutHash = calculateLayoutHash(srcMap, layersPerLayerName, layerNames);
|
||||
return new MapSection(layerBase, layerGround, layerObjects, layerAbove, layerTop, isWalkable, layoutHash);
|
||||
}
|
||||
|
||||
private static TMXLayer findLayer(HashMap<String, TMXLayer> layersPerLayerName, String layerName, String mapName) {
|
||||
if (layerName == null) return null;
|
||||
if (layerName.length() == 0) return null;
|
||||
TMXLayer result = layersPerLayerName.get(layerName.toLowerCase());
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
if (result == null && !"top".equals(layerName) && !"base".equals(layerName)) {
|
||||
L.log("WARNING: Cannot find maplayer \"" + layerName + "\" requested by map \"" + mapName + "\".");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static MapLayer transformMapLayer(
|
||||
HashMap<String, TMXLayer> layersPerLayerName,
|
||||
String layerName,
|
||||
TMXLayerMap srcMap,
|
||||
TileCache tileCache,
|
||||
CoordRect area,
|
||||
HashSet<Integer> usedTileIDs
|
||||
) {
|
||||
TMXLayer srcLayer = findLayer(layersPerLayerName, layerName, srcMap.name);
|
||||
if (srcLayer == null) return null;
|
||||
final MapLayer result = new MapLayer(area.size);
|
||||
Tile tile = new Tile();
|
||||
for (int dy = 0, sy = area.topLeft.y; dy < area.size.height; ++dy, ++sy) {
|
||||
for (int dx = 0, sx = area.topLeft.x; dx < area.size.width; ++dx, ++sx) {
|
||||
int gid = srcLayer.gids[sx][sy];
|
||||
if (gid <= 0) continue;
|
||||
|
||||
if (!getTile(srcMap, gid, tile)) continue;
|
||||
|
||||
int tileID = tileCache.getTileID(tile.tilesetName, tile.localId);
|
||||
result.tiles[dx][dy] = tileID;
|
||||
usedTileIDs.add(tileID);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static boolean[][] transformWalkableMapLayer(TMXLayer srcLayer, CoordRect area) {
|
||||
if (srcLayer == null) return null;
|
||||
final boolean[][] isWalkable = new boolean[area.size.width][area.size.height];
|
||||
for (int x = 0; x < area.size.width; ++x) {
|
||||
Arrays.fill(isWalkable[x], true);
|
||||
}
|
||||
for (int dy = 0, sy = area.topLeft.y; dy < area.size.height; ++dy, ++sy) {
|
||||
for (int dx = 0, sx = area.topLeft.x; dx < area.size.width; ++dx, ++sx) {
|
||||
int gid = srcLayer.gids[sx][sy];
|
||||
if (gid > 0) {
|
||||
isWalkable[dx][dy] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isWalkable;
|
||||
}
|
||||
|
||||
private static byte[] calculateLayoutHash(TMXLayerMap map, HashMap<String, TMXLayer> layersPerLayerName, SetOfLayerNames layerNames) {
|
||||
try {
|
||||
MessageDigest digest = MessageDigest.getInstance("MD5");
|
||||
digestLayer(layersPerLayerName, layerNames.baseLayerName, map, digest);
|
||||
digestLayer(layersPerLayerName, layerNames.groundLayerName, map, digest);
|
||||
digestLayer(layersPerLayerName, layerNames.objectsLayerName, map, digest);
|
||||
digestLayer(layersPerLayerName, layerNames.aboveLayersName, map, digest);
|
||||
digestLayer(layersPerLayerName, layerNames.topLayersName, map, digest);
|
||||
return digest.digest();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
L.log("ERROR: Failed to create layout hash for map " + map.name + " : " + e.toString());
|
||||
}
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
private static void digestLayer(HashMap<String, TMXLayer> layersPerLayerName, String layerName, TMXLayerMap map, MessageDigest digest) {
|
||||
TMXLayer srcLayer = findLayer(layersPerLayerName, layerName, map.name);
|
||||
if (srcLayer == null) return;
|
||||
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];
|
||||
if (ts.firstgid <= gid) {
|
||||
dest.tilesetName = ts.name;
|
||||
dest.localId = (gid - ts.firstgid);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
L.log("WARNING: Cannot find tile for gid " + gid);
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final class Tile {
|
||||
public String tilesetName;
|
||||
public int localId;
|
||||
}
|
||||
|
||||
private static final class SetOfLayerNames {
|
||||
public String baseLayerName;
|
||||
public String groundLayerName;
|
||||
public String objectsLayerName;
|
||||
public String aboveLayersName;
|
||||
public String topLayersName;
|
||||
public String walkableLayersName;
|
||||
public SetOfLayerNames() {
|
||||
this.baseLayerName = null;
|
||||
this.groundLayerName = null;
|
||||
this.objectsLayerName = null;
|
||||
this.aboveLayersName = null;
|
||||
this.topLayersName = null;
|
||||
this.walkableLayersName = null;
|
||||
}
|
||||
public SetOfLayerNames(String baseLayerName, String groundLayerName, String objectsLayerName, String aboveLayersName, String topLayersName, String walkableLayersName) {
|
||||
this.baseLayerName = baseLayerName;
|
||||
this.groundLayerName = groundLayerName;
|
||||
this.objectsLayerName = objectsLayerName;
|
||||
this.aboveLayersName = aboveLayersName;
|
||||
this.topLayersName = topLayersName;
|
||||
this.walkableLayersName = walkableLayersName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,116 +1,116 @@
|
||||
package com.gpl.rpg.AndorsTrail.resource;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import android.util.SparseArray;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.ResourceFileTileset;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCache;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.Size;
|
||||
|
||||
public final class DynamicTileLoader {
|
||||
private final TileCache tileCache;
|
||||
|
||||
private final SparseArray<ResourceFileTilesetLoadList> preparedTilesetsByResourceId = new SparseArray<ResourceFileTilesetLoadList>();
|
||||
private final HashMap<String, ResourceFileTilesetLoadList> preparedTilesetsByResourceName = new HashMap<String, ResourceFileTilesetLoadList>();
|
||||
private int currentTileStoreIndex;
|
||||
|
||||
private static final class ResourceFileTilesetLoadList {
|
||||
public final ResourceFileTileset tileset;
|
||||
public final SparseIntArray tileIDsToLoadPerLocalID = new SparseIntArray();
|
||||
public ResourceFileTilesetLoadList(ResourceFileTileset tileset) {
|
||||
this.tileset = tileset;
|
||||
}
|
||||
}
|
||||
|
||||
public DynamicTileLoader(TileCache tileCache) {
|
||||
this.tileCache = tileCache;
|
||||
initialize();
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
preparedTilesetsByResourceId.clear();
|
||||
preparedTilesetsByResourceName.clear();
|
||||
currentTileStoreIndex = tileCache.getMaxTileID();
|
||||
}
|
||||
|
||||
public void prepareTileset(int resourceId, String tilesetName, Size gridDimensions, Size spriteDimensionsInTiles, int tileSize) {
|
||||
ResourceFileTileset b = new ResourceFileTileset(resourceId, tilesetName, gridDimensions, spriteDimensionsInTiles, tileSize);
|
||||
ResourceFileTilesetLoadList loadList = new ResourceFileTilesetLoadList(b);
|
||||
preparedTilesetsByResourceId.put(resourceId, loadList);
|
||||
preparedTilesetsByResourceName.put(tilesetName, loadList);
|
||||
}
|
||||
private ResourceFileTilesetLoadList getTilesetBitmap(int tilesetImageResourceID) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
if (preparedTilesetsByResourceId.get(tilesetImageResourceID) == null) {
|
||||
L.log("WARNING: Cannot load tileset " + tilesetImageResourceID);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return preparedTilesetsByResourceId.get(tilesetImageResourceID);
|
||||
}
|
||||
private ResourceFileTilesetLoadList getTilesetBitmap(String tilesetName) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
if (!preparedTilesetsByResourceName.containsKey(tilesetName)) {
|
||||
L.log("WARNING: Cannot load tileset " + tilesetName);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return preparedTilesetsByResourceName.get(tilesetName);
|
||||
}
|
||||
|
||||
public int prepareTileID(int tilesetImageResourceID, int localID) {
|
||||
ResourceFileTilesetLoadList b = getTilesetBitmap(tilesetImageResourceID);
|
||||
return prepareTileID(b, localID);
|
||||
}
|
||||
|
||||
public int prepareTileID(String tilesetName, int localID) {
|
||||
ResourceFileTilesetLoadList b = getTilesetBitmap(tilesetName);
|
||||
return prepareTileID(b, localID);
|
||||
}
|
||||
public Size getTilesetSize(String tilesetName) {
|
||||
ResourceFileTilesetLoadList b = getTilesetBitmap(tilesetName);
|
||||
return b.tileset.destinationTileSize;
|
||||
}
|
||||
public Size getTilesetTileSize(String tilesetName) {
|
||||
ResourceFileTilesetLoadList b = getTilesetBitmap(tilesetName);
|
||||
return b.tileset.spriteDimensionsInTiles;
|
||||
}
|
||||
|
||||
private int prepareTileID(ResourceFileTilesetLoadList tileset, int localID) {
|
||||
int tileID = tileset.tileIDsToLoadPerLocalID.get(localID);
|
||||
if (tileID == 0) {
|
||||
++currentTileStoreIndex;
|
||||
tileID = currentTileStoreIndex;
|
||||
tileset.tileIDsToLoadPerLocalID.put(localID, tileID);
|
||||
}
|
||||
return tileID;
|
||||
}
|
||||
|
||||
public void prepareAllMapTiles() {
|
||||
for (Map.Entry<String, ResourceFileTilesetLoadList> tileset : preparedTilesetsByResourceName.entrySet()) {
|
||||
if (!tileset.getKey().startsWith("map_")) continue;
|
||||
ResourceFileTilesetLoadList b = tileset.getValue();
|
||||
int numTiles = b.tileset.numTiles.width * b.tileset.numTiles.height;
|
||||
for(int i = 0; i < numTiles; ++i) {
|
||||
prepareTileID(b, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void flush() {
|
||||
tileCache.allocateMaxTileID(currentTileStoreIndex);
|
||||
for (int i = 0; i < preparedTilesetsByResourceId.size(); ++i) {
|
||||
ResourceFileTilesetLoadList e = preparedTilesetsByResourceId.valueAt(i);
|
||||
ResourceFileTileset tileset = e.tileset;
|
||||
SparseIntArray tileIDsToLoad = e.tileIDsToLoadPerLocalID;
|
||||
for (int j = 0; j < tileIDsToLoad.size(); ++j) {
|
||||
tileCache.setTile(tileIDsToLoad.valueAt(j), tileset, tileIDsToLoad.keyAt(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.resource;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import android.util.SparseArray;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.ResourceFileTileset;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCache;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.Size;
|
||||
|
||||
public final class DynamicTileLoader {
|
||||
private final TileCache tileCache;
|
||||
|
||||
private final SparseArray<ResourceFileTilesetLoadList> preparedTilesetsByResourceId = new SparseArray<ResourceFileTilesetLoadList>();
|
||||
private final HashMap<String, ResourceFileTilesetLoadList> preparedTilesetsByResourceName = new HashMap<String, ResourceFileTilesetLoadList>();
|
||||
private int currentTileStoreIndex;
|
||||
|
||||
private static final class ResourceFileTilesetLoadList {
|
||||
public final ResourceFileTileset tileset;
|
||||
public final SparseIntArray tileIDsToLoadPerLocalID = new SparseIntArray();
|
||||
public ResourceFileTilesetLoadList(ResourceFileTileset tileset) {
|
||||
this.tileset = tileset;
|
||||
}
|
||||
}
|
||||
|
||||
public DynamicTileLoader(TileCache tileCache) {
|
||||
this.tileCache = tileCache;
|
||||
initialize();
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
preparedTilesetsByResourceId.clear();
|
||||
preparedTilesetsByResourceName.clear();
|
||||
currentTileStoreIndex = tileCache.getMaxTileID();
|
||||
}
|
||||
|
||||
public void prepareTileset(int resourceId, String tilesetName, Size gridDimensions, Size spriteDimensionsInTiles, int tileSize) {
|
||||
ResourceFileTileset b = new ResourceFileTileset(resourceId, tilesetName, gridDimensions, spriteDimensionsInTiles, tileSize);
|
||||
ResourceFileTilesetLoadList loadList = new ResourceFileTilesetLoadList(b);
|
||||
preparedTilesetsByResourceId.put(resourceId, loadList);
|
||||
preparedTilesetsByResourceName.put(tilesetName, loadList);
|
||||
}
|
||||
private ResourceFileTilesetLoadList getTilesetBitmap(int tilesetImageResourceID) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
if (preparedTilesetsByResourceId.get(tilesetImageResourceID) == null) {
|
||||
L.log("WARNING: Cannot load tileset " + tilesetImageResourceID);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return preparedTilesetsByResourceId.get(tilesetImageResourceID);
|
||||
}
|
||||
private ResourceFileTilesetLoadList getTilesetBitmap(String tilesetName) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
if (!preparedTilesetsByResourceName.containsKey(tilesetName)) {
|
||||
L.log("WARNING: Cannot load tileset " + tilesetName);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return preparedTilesetsByResourceName.get(tilesetName);
|
||||
}
|
||||
|
||||
public int prepareTileID(int tilesetImageResourceID, int localID) {
|
||||
ResourceFileTilesetLoadList b = getTilesetBitmap(tilesetImageResourceID);
|
||||
return prepareTileID(b, localID);
|
||||
}
|
||||
|
||||
public int prepareTileID(String tilesetName, int localID) {
|
||||
ResourceFileTilesetLoadList b = getTilesetBitmap(tilesetName);
|
||||
return prepareTileID(b, localID);
|
||||
}
|
||||
public Size getTilesetSize(String tilesetName) {
|
||||
ResourceFileTilesetLoadList b = getTilesetBitmap(tilesetName);
|
||||
return b.tileset.destinationTileSize;
|
||||
}
|
||||
public Size getTilesetTileSize(String tilesetName) {
|
||||
ResourceFileTilesetLoadList b = getTilesetBitmap(tilesetName);
|
||||
return b.tileset.spriteDimensionsInTiles;
|
||||
}
|
||||
|
||||
private int prepareTileID(ResourceFileTilesetLoadList tileset, int localID) {
|
||||
int tileID = tileset.tileIDsToLoadPerLocalID.get(localID);
|
||||
if (tileID == 0) {
|
||||
++currentTileStoreIndex;
|
||||
tileID = currentTileStoreIndex;
|
||||
tileset.tileIDsToLoadPerLocalID.put(localID, tileID);
|
||||
}
|
||||
return tileID;
|
||||
}
|
||||
|
||||
public void prepareAllMapTiles() {
|
||||
for (Map.Entry<String, ResourceFileTilesetLoadList> tileset : preparedTilesetsByResourceName.entrySet()) {
|
||||
if (!tileset.getKey().startsWith("map_")) continue;
|
||||
ResourceFileTilesetLoadList b = tileset.getValue();
|
||||
int numTiles = b.tileset.numTiles.width * b.tileset.numTiles.height;
|
||||
for(int i = 0; i < numTiles; ++i) {
|
||||
prepareTileID(b, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void flush() {
|
||||
tileCache.allocateMaxTileID(currentTileStoreIndex);
|
||||
for (int i = 0; i < preparedTilesetsByResourceId.size(); ++i) {
|
||||
ResourceFileTilesetLoadList e = preparedTilesetsByResourceId.valueAt(i);
|
||||
ResourceFileTileset tileset = e.tileset;
|
||||
SparseIntArray tileIDsToLoad = e.tileIDsToLoadPerLocalID;
|
||||
for (int j = 0; j < tileIDsToLoad.size(); ++j) {
|
||||
tileCache.setTile(tileIDsToLoad.valueAt(j), tileset, tileIDsToLoad.keyAt(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,182 +1,182 @@
|
||||
package com.gpl.rpg.AndorsTrail.resource;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import android.content.res.AssetManager;
|
||||
import android.content.res.Resources;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
|
||||
public final class TranslationLoader {
|
||||
private final BinaryMoFileParser parser;
|
||||
|
||||
public TranslationLoader(AssetManager mgr, Resources res) {
|
||||
this.parser = createParser(mgr, res);
|
||||
}
|
||||
public TranslationLoader(AssetManager mgr, String filename) {
|
||||
this.parser = createParser(mgr, filename);
|
||||
}
|
||||
|
||||
private static final String translationDir = "translation" + File.separator;
|
||||
private static BinaryMoFileParser createParser(AssetManager mgr, Resources res) {
|
||||
String translationFilename = res.getString(R.string.localize_resources_from_mo_filename);
|
||||
if (translationFilename == null || translationFilename.length() <= 0) return null;
|
||||
|
||||
return createParser(mgr, translationDir + translationFilename);
|
||||
}
|
||||
|
||||
private static BinaryMoFileParser createParser(AssetManager mgr, String translationFilename) {
|
||||
try {
|
||||
InputStream is = mgr.open(translationFilename, AssetManager.ACCESS_RANDOM);
|
||||
return new BinaryMoFileParser(is);
|
||||
} catch (IOException e) {
|
||||
L.log("ERROR: Reading from translation asset \"" + translationFilename + "\" failed: " + e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String tr(String s) {
|
||||
if (s == null) return null;
|
||||
if (parser == null) return s;
|
||||
if (s.length() <= 1) return s;
|
||||
try {
|
||||
String t = parser.translate(s);
|
||||
//L.log(translations.size() + " : " + s + " -> " + t);
|
||||
if (t.startsWith("[REVIEW]")) {
|
||||
t = t.substring(8);
|
||||
} else if (t.startsWith("[OUTDATED]")) {
|
||||
t = s;
|
||||
}
|
||||
return t;
|
||||
//return parser.translate(s);
|
||||
} catch (IOException e) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (parser == null) return;
|
||||
try {
|
||||
parser.close();
|
||||
} catch (IOException ignored) { }
|
||||
}
|
||||
|
||||
public String translateItemCategoryName(String s) { return tr(s); }
|
||||
public String translateActorConditionName(String s) { return tr(s); }
|
||||
public String translateItemTypeName(String s) { return tr(s); }
|
||||
public String translateItemTypeDescription(String s) {return tr(s); }
|
||||
public String translateMonsterTypeName(String s) { return tr(s); }
|
||||
public String translateQuestName(String s) { return tr(s); }
|
||||
public String translateQuestLogEntry(String s) { return tr(s); }
|
||||
public String translateConversationPhrase(String s) { return tr(s); }
|
||||
public String translateConversationReply(String s) { return tr(s); }
|
||||
public String translateWorldmapLocation(String s) { return tr(s); }
|
||||
|
||||
private static final class BinaryMoFileParser {
|
||||
private final InputStream is;
|
||||
private final BufferedInputStream reader;
|
||||
private final int numStrings;
|
||||
private final int offsetOriginalStrings;
|
||||
private final int offsetTranslatedStrings;
|
||||
|
||||
public BinaryMoFileParser(InputStream is) throws IOException {
|
||||
this.is = is;
|
||||
this.reader = new BufferedInputStream(is, is.available());
|
||||
this.reader.mark(9999999);
|
||||
int magic = readIntLE();
|
||||
if (magic != 0x950412de) throw new IOException("Invalid magic in MO file");
|
||||
this.reader.skip(4);
|
||||
numStrings = readIntLE();
|
||||
offsetOriginalStrings = readIntLE();
|
||||
offsetTranslatedStrings = readIntLE();
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
reader.close();
|
||||
is.close();
|
||||
}
|
||||
|
||||
private static final String charset = "utf-8";
|
||||
|
||||
public String translate(String s) throws IOException {
|
||||
if (numStrings <= 0) return s;
|
||||
|
||||
byte[] bytes = s.getBytes(charset);
|
||||
byte[] translation = find(bytes);
|
||||
if (translation == null || translation.length <= 0) return s;
|
||||
return new String(translation, charset);
|
||||
}
|
||||
|
||||
private byte[] find(byte[] bytes) throws IOException {
|
||||
return find(bytes, 0, numStrings);
|
||||
}
|
||||
|
||||
private byte[] find(byte[] bytes, int minIndex, int maxIndex) throws IOException {
|
||||
int middleIndex;
|
||||
while(minIndex != maxIndex) {
|
||||
if (minIndex+1 == maxIndex) middleIndex = minIndex;
|
||||
else if (minIndex+2 == maxIndex) middleIndex = minIndex;
|
||||
else middleIndex = (minIndex + maxIndex) / 2;
|
||||
|
||||
int c = compare(bytes, middleIndex);
|
||||
if (c == 0) return getTranslatedStringAt(middleIndex);
|
||||
|
||||
if (minIndex+1 == maxIndex) {
|
||||
return null;
|
||||
} else if (c > 0) {
|
||||
maxIndex = middleIndex;
|
||||
} else {
|
||||
minIndex = middleIndex+1;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private final byte[] buf = new byte[8];
|
||||
public final int readIntLE() throws IOException
|
||||
{
|
||||
reader.read(buf, 0, 4);
|
||||
return
|
||||
(buf[3]&0xff) << 24 |
|
||||
(buf[2]&0xff) << 16 |
|
||||
(buf[1]&0xff) << 8 |
|
||||
(buf[0]&0xff);
|
||||
}
|
||||
|
||||
private void seek(int pos) throws IOException {
|
||||
reader.reset();
|
||||
reader.skip(pos);
|
||||
}
|
||||
|
||||
private byte[] getTranslatedStringAt(int idx) throws IOException {
|
||||
seek(offsetTranslatedStrings + idx*8);
|
||||
int length = readIntLE();
|
||||
int offset = readIntLE();
|
||||
seek(offset);
|
||||
byte[] result = new byte[length];
|
||||
reader.read(result, 0, length);
|
||||
return result;
|
||||
}
|
||||
|
||||
private int compare(byte[] bytes, int idx) throws IOException {
|
||||
seek(offsetOriginalStrings + idx*8);
|
||||
int length = readIntLE();
|
||||
int offset = readIntLE();
|
||||
seek(offset);
|
||||
int maxLength = bytes.length;
|
||||
for(int i = 0; i < length; ++i) {
|
||||
if (i == maxLength) return 1;
|
||||
int b = reader.read();
|
||||
if (b == bytes[i]) continue;
|
||||
return (b < bytes[i]) ? -1 : 1;
|
||||
}
|
||||
if (length < maxLength) return -1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.resource;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import android.content.res.AssetManager;
|
||||
import android.content.res.Resources;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
|
||||
public final class TranslationLoader {
|
||||
private final BinaryMoFileParser parser;
|
||||
|
||||
public TranslationLoader(AssetManager mgr, Resources res) {
|
||||
this.parser = createParser(mgr, res);
|
||||
}
|
||||
public TranslationLoader(AssetManager mgr, String filename) {
|
||||
this.parser = createParser(mgr, filename);
|
||||
}
|
||||
|
||||
private static final String translationDir = "translation" + File.separator;
|
||||
private static BinaryMoFileParser createParser(AssetManager mgr, Resources res) {
|
||||
String translationFilename = res.getString(R.string.localize_resources_from_mo_filename);
|
||||
if (translationFilename == null || translationFilename.length() <= 0) return null;
|
||||
|
||||
return createParser(mgr, translationDir + translationFilename);
|
||||
}
|
||||
|
||||
private static BinaryMoFileParser createParser(AssetManager mgr, String translationFilename) {
|
||||
try {
|
||||
InputStream is = mgr.open(translationFilename, AssetManager.ACCESS_RANDOM);
|
||||
return new BinaryMoFileParser(is);
|
||||
} catch (IOException e) {
|
||||
L.log("ERROR: Reading from translation asset \"" + translationFilename + "\" failed: " + e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String tr(String s) {
|
||||
if (s == null) return null;
|
||||
if (parser == null) return s;
|
||||
if (s.length() <= 1) return s;
|
||||
try {
|
||||
String t = parser.translate(s);
|
||||
//L.log(translations.size() + " : " + s + " -> " + t);
|
||||
if (t.startsWith("[REVIEW]")) {
|
||||
t = t.substring(8);
|
||||
} else if (t.startsWith("[OUTDATED]")) {
|
||||
t = s;
|
||||
}
|
||||
return t;
|
||||
//return parser.translate(s);
|
||||
} catch (IOException e) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (parser == null) return;
|
||||
try {
|
||||
parser.close();
|
||||
} catch (IOException ignored) { }
|
||||
}
|
||||
|
||||
public String translateItemCategoryName(String s) { return tr(s); }
|
||||
public String translateActorConditionName(String s) { return tr(s); }
|
||||
public String translateItemTypeName(String s) { return tr(s); }
|
||||
public String translateItemTypeDescription(String s) {return tr(s); }
|
||||
public String translateMonsterTypeName(String s) { return tr(s); }
|
||||
public String translateQuestName(String s) { return tr(s); }
|
||||
public String translateQuestLogEntry(String s) { return tr(s); }
|
||||
public String translateConversationPhrase(String s) { return tr(s); }
|
||||
public String translateConversationReply(String s) { return tr(s); }
|
||||
public String translateWorldmapLocation(String s) { return tr(s); }
|
||||
|
||||
private static final class BinaryMoFileParser {
|
||||
private final InputStream is;
|
||||
private final BufferedInputStream reader;
|
||||
private final int numStrings;
|
||||
private final int offsetOriginalStrings;
|
||||
private final int offsetTranslatedStrings;
|
||||
|
||||
public BinaryMoFileParser(InputStream is) throws IOException {
|
||||
this.is = is;
|
||||
this.reader = new BufferedInputStream(is, is.available());
|
||||
this.reader.mark(9999999);
|
||||
int magic = readIntLE();
|
||||
if (magic != 0x950412de) throw new IOException("Invalid magic in MO file");
|
||||
this.reader.skip(4);
|
||||
numStrings = readIntLE();
|
||||
offsetOriginalStrings = readIntLE();
|
||||
offsetTranslatedStrings = readIntLE();
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
reader.close();
|
||||
is.close();
|
||||
}
|
||||
|
||||
private static final String charset = "utf-8";
|
||||
|
||||
public String translate(String s) throws IOException {
|
||||
if (numStrings <= 0) return s;
|
||||
|
||||
byte[] bytes = s.getBytes(charset);
|
||||
byte[] translation = find(bytes);
|
||||
if (translation == null || translation.length <= 0) return s;
|
||||
return new String(translation, charset);
|
||||
}
|
||||
|
||||
private byte[] find(byte[] bytes) throws IOException {
|
||||
return find(bytes, 0, numStrings);
|
||||
}
|
||||
|
||||
private byte[] find(byte[] bytes, int minIndex, int maxIndex) throws IOException {
|
||||
int middleIndex;
|
||||
while(minIndex != maxIndex) {
|
||||
if (minIndex+1 == maxIndex) middleIndex = minIndex;
|
||||
else if (minIndex+2 == maxIndex) middleIndex = minIndex;
|
||||
else middleIndex = (minIndex + maxIndex) / 2;
|
||||
|
||||
int c = compare(bytes, middleIndex);
|
||||
if (c == 0) return getTranslatedStringAt(middleIndex);
|
||||
|
||||
if (minIndex+1 == maxIndex) {
|
||||
return null;
|
||||
} else if (c > 0) {
|
||||
maxIndex = middleIndex;
|
||||
} else {
|
||||
minIndex = middleIndex+1;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private final byte[] buf = new byte[8];
|
||||
public final int readIntLE() throws IOException
|
||||
{
|
||||
reader.read(buf, 0, 4);
|
||||
return
|
||||
(buf[3]&0xff) << 24 |
|
||||
(buf[2]&0xff) << 16 |
|
||||
(buf[1]&0xff) << 8 |
|
||||
(buf[0]&0xff);
|
||||
}
|
||||
|
||||
private void seek(int pos) throws IOException {
|
||||
reader.reset();
|
||||
reader.skip(pos);
|
||||
}
|
||||
|
||||
private byte[] getTranslatedStringAt(int idx) throws IOException {
|
||||
seek(offsetTranslatedStrings + idx*8);
|
||||
int length = readIntLE();
|
||||
int offset = readIntLE();
|
||||
seek(offset);
|
||||
byte[] result = new byte[length];
|
||||
reader.read(result, 0, length);
|
||||
return result;
|
||||
}
|
||||
|
||||
private int compare(byte[] bytes, int idx) throws IOException {
|
||||
seek(offsetOriginalStrings + idx*8);
|
||||
int length = readIntLE();
|
||||
int offset = readIntLE();
|
||||
seek(offset);
|
||||
int maxLength = bytes.length;
|
||||
for(int i = 0; i < length; ++i) {
|
||||
if (i == maxLength) return 1;
|
||||
int b = reader.read();
|
||||
if (b == bytes[i]) continue;
|
||||
return (b < bytes[i]) ? -1 : 1;
|
||||
}
|
||||
if (length < maxLength) return -1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
package com.gpl.rpg.AndorsTrail.resource.tiles;
|
||||
|
||||
import android.graphics.Matrix;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.util.Size;
|
||||
|
||||
public final class ResourceFileTileset {
|
||||
public final int resourceID;
|
||||
public final String tilesetName;
|
||||
public final Size spriteDimensionsInTiles;
|
||||
public final Size destinationTileSize;
|
||||
public final Size numTiles;
|
||||
public Size sourceTileSize;
|
||||
public Matrix scale;
|
||||
|
||||
public ResourceFileTileset(int resourceID, String tilesetName, Size gridDimensions, Size spriteDimensionsInTiles, int tileSize) {
|
||||
this.resourceID = resourceID;
|
||||
this.tilesetName = tilesetName;
|
||||
this.spriteDimensionsInTiles = spriteDimensionsInTiles;
|
||||
this.destinationTileSize = new Size(tileSize * spriteDimensionsInTiles.width, tileSize * spriteDimensionsInTiles.height);
|
||||
this.numTiles = gridDimensions;
|
||||
}
|
||||
|
||||
@Override public int hashCode() { return resourceID; }
|
||||
|
||||
public void calculateFromSourceImageSize(final int sourceWidth, final int sourceHeight) {
|
||||
sourceTileSize = new Size(
|
||||
sourceWidth / numTiles.width
|
||||
,sourceHeight / numTiles.height
|
||||
);
|
||||
|
||||
if (destinationTileSize.width == sourceTileSize.width && destinationTileSize.height == sourceTileSize.height) {
|
||||
scale = null;
|
||||
} else {
|
||||
scale = new Matrix();
|
||||
scale.postScale(
|
||||
((float) destinationTileSize.width) / sourceTileSize.width
|
||||
,((float) destinationTileSize.height) / sourceTileSize.height
|
||||
);
|
||||
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
//L.log("OPTIMIZE: Tileset " + tilesetName + " will be resized from " + sourceTileSize.toString() + " to " + destinationTileSize.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.resource.tiles;
|
||||
|
||||
import android.graphics.Matrix;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.util.Size;
|
||||
|
||||
public final class ResourceFileTileset {
|
||||
public final int resourceID;
|
||||
public final String tilesetName;
|
||||
public final Size spriteDimensionsInTiles;
|
||||
public final Size destinationTileSize;
|
||||
public final Size numTiles;
|
||||
public Size sourceTileSize;
|
||||
public Matrix scale;
|
||||
|
||||
public ResourceFileTileset(int resourceID, String tilesetName, Size gridDimensions, Size spriteDimensionsInTiles, int tileSize) {
|
||||
this.resourceID = resourceID;
|
||||
this.tilesetName = tilesetName;
|
||||
this.spriteDimensionsInTiles = spriteDimensionsInTiles;
|
||||
this.destinationTileSize = new Size(tileSize * spriteDimensionsInTiles.width, tileSize * spriteDimensionsInTiles.height);
|
||||
this.numTiles = gridDimensions;
|
||||
}
|
||||
|
||||
@Override public int hashCode() { return resourceID; }
|
||||
|
||||
public void calculateFromSourceImageSize(final int sourceWidth, final int sourceHeight) {
|
||||
sourceTileSize = new Size(
|
||||
sourceWidth / numTiles.width
|
||||
,sourceHeight / numTiles.height
|
||||
);
|
||||
|
||||
if (destinationTileSize.width == sourceTileSize.width && destinationTileSize.height == sourceTileSize.height) {
|
||||
scale = null;
|
||||
} else {
|
||||
scale = new Matrix();
|
||||
scale.postScale(
|
||||
((float) destinationTileSize.width) / sourceTileSize.width
|
||||
,((float) destinationTileSize.height) / sourceTileSize.height
|
||||
);
|
||||
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
//L.log("OPTIMIZE: Tileset " + tilesetName + " will be resized from " + sourceTileSize.toString() + " to " + destinationTileSize.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,125 +1,123 @@
|
||||
package com.gpl.rpg.AndorsTrail.resource.tiles;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.SparseArray;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.LruCache;
|
||||
|
||||
public final class TileCache {
|
||||
|
||||
private final ReferenceQueue<Bitmap> gcQueue = new ReferenceQueue<Bitmap>();
|
||||
private ResourceFileTile[] resourceTiles = new ResourceFileTile[1];
|
||||
private final HashMap<String, SparseIntArray> tileIDsPerTilesetAndLocalID = new HashMap<String, SparseIntArray>();
|
||||
private final LruCache<Integer, Bitmap> cache = new LruCache<Integer, Bitmap>(1000);
|
||||
|
||||
public int getMaxTileID() { return resourceTiles.length-1; }
|
||||
public void allocateMaxTileID(int maxTileID) {
|
||||
if (maxTileID <= 0) return;
|
||||
|
||||
ResourceFileTile[] oldArray = resourceTiles;
|
||||
resourceTiles = new ResourceFileTile[maxTileID+1];
|
||||
System.arraycopy(oldArray, 0, resourceTiles, 0, oldArray.length);
|
||||
}
|
||||
public void setTile(int tileID, ResourceFileTileset tileset, int localID) {
|
||||
if (resourceTiles[tileID] == null) resourceTiles[tileID] = new ResourceFileTile(tileset, localID);
|
||||
SparseIntArray tileIDsPerLocalID = tileIDsPerTilesetAndLocalID.get(tileset.tilesetName);
|
||||
if (tileIDsPerLocalID == null) {
|
||||
tileIDsPerLocalID = new SparseIntArray();
|
||||
tileIDsPerTilesetAndLocalID.put(tileset.tilesetName, tileIDsPerLocalID);
|
||||
}
|
||||
tileIDsPerLocalID.put(localID, tileID);
|
||||
}
|
||||
public int getTileID(String tileSetName, int localID) {
|
||||
return tileIDsPerTilesetAndLocalID.get(tileSetName).get(localID);
|
||||
}
|
||||
|
||||
private static final class ResourceFileTile {
|
||||
public final ResourceFileTileset tileset;
|
||||
public final int localID;
|
||||
//public WeakReference<Bitmap> bitmap;
|
||||
public ResourceFileTile(ResourceFileTileset tileset, int localID) {
|
||||
this.tileset = tileset;
|
||||
this.localID = localID;
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanQueue() {
|
||||
System.gc();
|
||||
Reference<? extends Bitmap> ref;
|
||||
while ((ref = gcQueue.poll()) != null) {
|
||||
Bitmap b = ref.get();
|
||||
if (b != null) b.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
public TileCollection loadTilesFor(Collection<Integer> iconIDs, Resources r) { return loadTilesFor(iconIDs, r, null); }
|
||||
public TileCollection loadTilesFor(Collection<Integer> iconIDs, Resources r, TileCollection result) {
|
||||
int maxTileID = 0;
|
||||
HashMap<ResourceFileTileset, SparseArray<ResourceFileTile>> tilesToLoadPerSourceFile = new HashMap<ResourceFileTileset, SparseArray<ResourceFileTile>>();
|
||||
for(int tileID : iconIDs) {
|
||||
ResourceFileTile tile = resourceTiles[tileID];
|
||||
SparseArray<ResourceFileTile> tiles = tilesToLoadPerSourceFile.get(tile.tileset);
|
||||
if (tiles == null) {
|
||||
tiles = new SparseArray<TileCache.ResourceFileTile>();
|
||||
tilesToLoadPerSourceFile.put(tile.tileset, tiles);
|
||||
}
|
||||
tiles.put(tileID, tile);
|
||||
maxTileID = Math.max(maxTileID, tileID);
|
||||
}
|
||||
|
||||
boolean hasLoadedTiles = false;
|
||||
if (result == null) result = new TileCollection(maxTileID);
|
||||
for(Entry<ResourceFileTileset, SparseArray<ResourceFileTile>> e : tilesToLoadPerSourceFile.entrySet()) {
|
||||
TileCutter cutter = null;
|
||||
|
||||
SparseArray<ResourceFileTile> tilesToLoad = e.getValue();
|
||||
for (int i = 0; i < tilesToLoad.size(); ++i) {
|
||||
int tileID = tilesToLoad.keyAt(i);
|
||||
ResourceFileTile tile = tilesToLoad.valueAt(i);
|
||||
|
||||
Bitmap bitmap = cache.get(tileID);
|
||||
|
||||
if (bitmap == null) {
|
||||
if (cutter == null) {
|
||||
if (!hasLoadedTiles) cleanQueue();
|
||||
cutter = new TileCutter(e.getKey(), r);
|
||||
hasLoadedTiles = true;
|
||||
}
|
||||
|
||||
bitmap = cutter.createTile(tile.localID);
|
||||
cache.put(tileID, bitmap);
|
||||
new WeakReference<Bitmap>(bitmap, gcQueue);
|
||||
}
|
||||
result.setBitmap(tileID, bitmap);
|
||||
}
|
||||
|
||||
if (cutter != null) cutter.recycle();
|
||||
}
|
||||
if (hasLoadedTiles) cleanQueue();
|
||||
return result;
|
||||
}
|
||||
|
||||
public Bitmap loadSingleTile(int tileID, Resources r) {
|
||||
cleanQueue();
|
||||
ResourceFileTile tile = resourceTiles[tileID];
|
||||
Bitmap bitmap = cache.get(tileID);
|
||||
if (bitmap != null) return bitmap;
|
||||
|
||||
TileCutter cutter = new TileCutter(tile.tileset, r);
|
||||
Bitmap result = cutter.createTile(tile.localID);
|
||||
cutter.recycle();
|
||||
cache.put(tileID, result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.resource.tiles;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.SparseArray;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.util.LruCache;
|
||||
|
||||
public final class TileCache {
|
||||
|
||||
private final ReferenceQueue<Bitmap> gcQueue = new ReferenceQueue<Bitmap>();
|
||||
private ResourceFileTile[] resourceTiles = new ResourceFileTile[1];
|
||||
private final HashMap<String, SparseIntArray> tileIDsPerTilesetAndLocalID = new HashMap<String, SparseIntArray>();
|
||||
private final LruCache<Integer, Bitmap> cache = new LruCache<Integer, Bitmap>(1000);
|
||||
|
||||
public int getMaxTileID() { return resourceTiles.length-1; }
|
||||
public void allocateMaxTileID(int maxTileID) {
|
||||
if (maxTileID <= 0) return;
|
||||
|
||||
ResourceFileTile[] oldArray = resourceTiles;
|
||||
resourceTiles = new ResourceFileTile[maxTileID+1];
|
||||
System.arraycopy(oldArray, 0, resourceTiles, 0, oldArray.length);
|
||||
}
|
||||
public void setTile(int tileID, ResourceFileTileset tileset, int localID) {
|
||||
if (resourceTiles[tileID] == null) resourceTiles[tileID] = new ResourceFileTile(tileset, localID);
|
||||
SparseIntArray tileIDsPerLocalID = tileIDsPerTilesetAndLocalID.get(tileset.tilesetName);
|
||||
if (tileIDsPerLocalID == null) {
|
||||
tileIDsPerLocalID = new SparseIntArray();
|
||||
tileIDsPerTilesetAndLocalID.put(tileset.tilesetName, tileIDsPerLocalID);
|
||||
}
|
||||
tileIDsPerLocalID.put(localID, tileID);
|
||||
}
|
||||
public int getTileID(String tileSetName, int localID) {
|
||||
return tileIDsPerTilesetAndLocalID.get(tileSetName).get(localID);
|
||||
}
|
||||
|
||||
private static final class ResourceFileTile {
|
||||
public final ResourceFileTileset tileset;
|
||||
public final int localID;
|
||||
//public WeakReference<Bitmap> bitmap;
|
||||
public ResourceFileTile(ResourceFileTileset tileset, int localID) {
|
||||
this.tileset = tileset;
|
||||
this.localID = localID;
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanQueue() {
|
||||
System.gc();
|
||||
Reference<? extends Bitmap> ref;
|
||||
while ((ref = gcQueue.poll()) != null) {
|
||||
Bitmap b = ref.get();
|
||||
if (b != null) b.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
public TileCollection loadTilesFor(Collection<Integer> iconIDs, Resources r) { return loadTilesFor(iconIDs, r, null); }
|
||||
public TileCollection loadTilesFor(Collection<Integer> iconIDs, Resources r, TileCollection result) {
|
||||
int maxTileID = 0;
|
||||
HashMap<ResourceFileTileset, SparseArray<ResourceFileTile>> tilesToLoadPerSourceFile = new HashMap<ResourceFileTileset, SparseArray<ResourceFileTile>>();
|
||||
for(int tileID : iconIDs) {
|
||||
ResourceFileTile tile = resourceTiles[tileID];
|
||||
SparseArray<ResourceFileTile> tiles = tilesToLoadPerSourceFile.get(tile.tileset);
|
||||
if (tiles == null) {
|
||||
tiles = new SparseArray<TileCache.ResourceFileTile>();
|
||||
tilesToLoadPerSourceFile.put(tile.tileset, tiles);
|
||||
}
|
||||
tiles.put(tileID, tile);
|
||||
maxTileID = Math.max(maxTileID, tileID);
|
||||
}
|
||||
|
||||
boolean hasLoadedTiles = false;
|
||||
if (result == null) result = new TileCollection(maxTileID);
|
||||
for(Entry<ResourceFileTileset, SparseArray<ResourceFileTile>> e : tilesToLoadPerSourceFile.entrySet()) {
|
||||
TileCutter cutter = null;
|
||||
|
||||
SparseArray<ResourceFileTile> tilesToLoad = e.getValue();
|
||||
for (int i = 0; i < tilesToLoad.size(); ++i) {
|
||||
int tileID = tilesToLoad.keyAt(i);
|
||||
ResourceFileTile tile = tilesToLoad.valueAt(i);
|
||||
|
||||
Bitmap bitmap = cache.get(tileID);
|
||||
|
||||
if (bitmap == null) {
|
||||
if (cutter == null) {
|
||||
if (!hasLoadedTiles) cleanQueue();
|
||||
cutter = new TileCutter(e.getKey(), r);
|
||||
hasLoadedTiles = true;
|
||||
}
|
||||
|
||||
bitmap = cutter.createTile(tile.localID);
|
||||
cache.put(tileID, bitmap);
|
||||
new WeakReference<Bitmap>(bitmap, gcQueue);
|
||||
}
|
||||
result.setBitmap(tileID, bitmap);
|
||||
}
|
||||
|
||||
if (cutter != null) cutter.recycle();
|
||||
}
|
||||
if (hasLoadedTiles) cleanQueue();
|
||||
return result;
|
||||
}
|
||||
|
||||
public Bitmap loadSingleTile(int tileID, Resources r) {
|
||||
cleanQueue();
|
||||
ResourceFileTile tile = resourceTiles[tileID];
|
||||
Bitmap bitmap = cache.get(tileID);
|
||||
if (bitmap != null) return bitmap;
|
||||
|
||||
TileCutter cutter = new TileCutter(tile.tileset, r);
|
||||
Bitmap result = cutter.createTile(tile.localID);
|
||||
cutter.recycle();
|
||||
cache.put(tileID, result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,60 +1,60 @@
|
||||
package com.gpl.rpg.AndorsTrail.savegames;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.WorldMapController;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.MonsterSpawnArea;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
|
||||
import android.content.res.Resources;
|
||||
|
||||
public class LegacySavegamesContentAdaptations {
|
||||
|
||||
public static void adaptToNewContentForVersion45(WorldContext world, ControllerContext controllers, Resources res) {
|
||||
PredefinedMap fields5Map = world.maps.findPredefinedMap("fields5");
|
||||
if (fields5Map != null) {
|
||||
for (MonsterSpawnArea area : fields5Map.spawnAreas) {
|
||||
if (area.monsters != null) {
|
||||
for (Monster m : area.monsters) {
|
||||
if (m.getMonsterTypeID().equals("feygard_bridgeguard")) {
|
||||
area.resetForNewGame();
|
||||
for (MonsterSpawnArea newarea : fields5Map.spawnAreas) {
|
||||
if (newarea.areaID.equals("guynmart_robber1")) {
|
||||
controllers.monsterSpawnController.spawnAllInArea(fields5Map,
|
||||
(world.model.currentMaps.map == fields5Map ? world.model.currentMaps.tileMap : null),
|
||||
newarea, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Force update of existing worldmaps to ensure regenerating the html when needed, using the new UTF-8-enabled template.
|
||||
List<String> segmentsCovered = new LinkedList<String>();
|
||||
for (WorldMapSegment segment : world.maps.worldMapSegments.values()) {
|
||||
if (segment == null || segment.name == null) continue;
|
||||
if (segmentsCovered.contains(segment.name)) continue;
|
||||
segmentsCovered.add(segment.name);
|
||||
try {
|
||||
WorldMapController.updateWorldMapSegment(controllers.getContext(), res, world, segment.name);
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) {
|
||||
L.log("Forcing generation of worldmap file for segment " + segment.name);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
L.log("Error creating worldmap file for segment " + segment.name + " : " + e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.savegames;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.WorldMapController;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.MonsterSpawnArea;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
|
||||
import android.content.res.Resources;
|
||||
|
||||
public class LegacySavegamesContentAdaptations {
|
||||
|
||||
public static void adaptToNewContentForVersion45(WorldContext world, ControllerContext controllers, Resources res) {
|
||||
PredefinedMap fields5Map = world.maps.findPredefinedMap("fields5");
|
||||
if (fields5Map != null) {
|
||||
for (MonsterSpawnArea area : fields5Map.spawnAreas) {
|
||||
if (area.monsters != null) {
|
||||
for (Monster m : area.monsters) {
|
||||
if (m.getMonsterTypeID().equals("feygard_bridgeguard")) {
|
||||
area.resetForNewGame();
|
||||
for (MonsterSpawnArea newarea : fields5Map.spawnAreas) {
|
||||
if (newarea.areaID.equals("guynmart_robber1")) {
|
||||
controllers.monsterSpawnController.spawnAllInArea(fields5Map,
|
||||
(world.model.currentMaps.map == fields5Map ? world.model.currentMaps.tileMap : null),
|
||||
newarea, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Force update of existing worldmaps to ensure regenerating the html when needed, using the new UTF-8-enabled template.
|
||||
List<String> segmentsCovered = new LinkedList<String>();
|
||||
for (WorldMapSegment segment : world.maps.worldMapSegments.values()) {
|
||||
if (segment == null || segment.name == null) continue;
|
||||
if (segmentsCovered.contains(segment.name)) continue;
|
||||
segmentsCovered.add(segment.name);
|
||||
try {
|
||||
WorldMapController.updateWorldMapSegment(controllers.getContext(), res, world, segment.name);
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) {
|
||||
L.log("Forcing generation of worldmap file for segment " + segment.name);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
L.log("Error creating worldmap file for segment " + segment.name + " : " + e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.gpl.rpg.AndorsTrail.util;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
|
||||
public final class L {
|
||||
private static final String TAG = "AndorsTrail";
|
||||
|
||||
public static void log(String s) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) {
|
||||
Log.w(TAG, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.util;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
|
||||
public final class L {
|
||||
private static final String TAG = "AndorsTrail";
|
||||
|
||||
public static void log(String s) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) {
|
||||
Log.w(TAG, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,87 +1,87 @@
|
||||
package com.gpl.rpg.AndorsTrail.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
public class ThemeHelper {
|
||||
|
||||
private static final class ThemeSet {
|
||||
int baseThemeRes, noBackgroundThemeRes, dialogThemeRes;
|
||||
public ThemeSet(int baseThemeRes, int noBackgroundThemeRes, int dialogThemeRes) {
|
||||
this.baseThemeRes = baseThemeRes;
|
||||
this.noBackgroundThemeRes = noBackgroundThemeRes;
|
||||
this.dialogThemeRes = dialogThemeRes;
|
||||
}
|
||||
}
|
||||
|
||||
public static enum Theme {
|
||||
blue,
|
||||
green,
|
||||
charcoal
|
||||
}
|
||||
|
||||
private static final Map<Theme, ThemeSet> THEME_SETS = new HashMap<ThemeHelper.Theme, ThemeHelper.ThemeSet>();
|
||||
private static Theme SELECTED_THEME = Theme.blue;
|
||||
private static boolean first = true;
|
||||
|
||||
static {
|
||||
THEME_SETS.put(Theme.blue, new ThemeSet(R.style.AndorsTrailTheme_Blue, R.style.AndorsTrailTheme_Blue_NoBackground, R.style.AndorsTrailDialogTheme_Blue));
|
||||
THEME_SETS.put(Theme.green, new ThemeSet(R.style.AndorsTrailTheme_Green, R.style.AndorsTrailTheme_Green_NoBackground, R.style.AndorsTrailDialogTheme_Green));
|
||||
THEME_SETS.put(Theme.charcoal, new ThemeSet(R.style.AndorsTrailTheme_Charcoal, R.style.AndorsTrailTheme_Charcoal_NoBackground, R.style.AndorsTrailDialogTheme_Charcoal));
|
||||
}
|
||||
|
||||
public static int getThemeColor(Context context, int attrResId) {
|
||||
TypedArray ta = context.getTheme().obtainStyledAttributes(new int[] {attrResId});
|
||||
int c = ta.getColor(0, Color.BLACK);
|
||||
ta.recycle();
|
||||
return c;
|
||||
}
|
||||
|
||||
public static int getThemeResource(Context context, int attrResId) {
|
||||
TypedArray ta = context.getTheme().obtainStyledAttributes(new int[] {attrResId});
|
||||
int resId = ta.getResourceId(0, 0);
|
||||
ta.recycle();
|
||||
return resId;
|
||||
}
|
||||
|
||||
public static Drawable getThemeDrawable(Context context, int attrResId) {
|
||||
TypedArray ta = context.getTheme().obtainStyledAttributes(new int[] {attrResId});
|
||||
Drawable d = ta.getDrawable(0);
|
||||
ta.recycle();
|
||||
return d;
|
||||
}
|
||||
|
||||
public static int getBaseTheme() {
|
||||
return THEME_SETS.get(SELECTED_THEME).baseThemeRes;
|
||||
}
|
||||
|
||||
public static int getNoBackgroundTheme() {
|
||||
return THEME_SETS.get(SELECTED_THEME).noBackgroundThemeRes;
|
||||
}
|
||||
|
||||
public static int getDialogTheme() {
|
||||
return THEME_SETS.get(SELECTED_THEME).dialogThemeRes;
|
||||
}
|
||||
|
||||
//Returns true if theme has changed after startup.
|
||||
public static boolean changeTheme(int id) {
|
||||
Theme t = Theme.values()[id];
|
||||
if (t == SELECTED_THEME) {
|
||||
first = false;
|
||||
return false;
|
||||
}
|
||||
SELECTED_THEME = t;
|
||||
if (first) {
|
||||
first = false;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
public class ThemeHelper {
|
||||
|
||||
private static final class ThemeSet {
|
||||
int baseThemeRes, noBackgroundThemeRes, dialogThemeRes;
|
||||
public ThemeSet(int baseThemeRes, int noBackgroundThemeRes, int dialogThemeRes) {
|
||||
this.baseThemeRes = baseThemeRes;
|
||||
this.noBackgroundThemeRes = noBackgroundThemeRes;
|
||||
this.dialogThemeRes = dialogThemeRes;
|
||||
}
|
||||
}
|
||||
|
||||
public static enum Theme {
|
||||
blue,
|
||||
green,
|
||||
charcoal
|
||||
}
|
||||
|
||||
private static final Map<Theme, ThemeSet> THEME_SETS = new HashMap<ThemeHelper.Theme, ThemeHelper.ThemeSet>();
|
||||
private static Theme SELECTED_THEME = Theme.blue;
|
||||
private static boolean first = true;
|
||||
|
||||
static {
|
||||
THEME_SETS.put(Theme.blue, new ThemeSet(R.style.AndorsTrailTheme_Blue, R.style.AndorsTrailTheme_Blue_NoBackground, R.style.AndorsTrailDialogTheme_Blue));
|
||||
THEME_SETS.put(Theme.green, new ThemeSet(R.style.AndorsTrailTheme_Green, R.style.AndorsTrailTheme_Green_NoBackground, R.style.AndorsTrailDialogTheme_Green));
|
||||
THEME_SETS.put(Theme.charcoal, new ThemeSet(R.style.AndorsTrailTheme_Charcoal, R.style.AndorsTrailTheme_Charcoal_NoBackground, R.style.AndorsTrailDialogTheme_Charcoal));
|
||||
}
|
||||
|
||||
public static int getThemeColor(Context context, int attrResId) {
|
||||
TypedArray ta = context.getTheme().obtainStyledAttributes(new int[] {attrResId});
|
||||
int c = ta.getColor(0, Color.BLACK);
|
||||
ta.recycle();
|
||||
return c;
|
||||
}
|
||||
|
||||
public static int getThemeResource(Context context, int attrResId) {
|
||||
TypedArray ta = context.getTheme().obtainStyledAttributes(new int[] {attrResId});
|
||||
int resId = ta.getResourceId(0, 0);
|
||||
ta.recycle();
|
||||
return resId;
|
||||
}
|
||||
|
||||
public static Drawable getThemeDrawable(Context context, int attrResId) {
|
||||
TypedArray ta = context.getTheme().obtainStyledAttributes(new int[] {attrResId});
|
||||
Drawable d = ta.getDrawable(0);
|
||||
ta.recycle();
|
||||
return d;
|
||||
}
|
||||
|
||||
public static int getBaseTheme() {
|
||||
return THEME_SETS.get(SELECTED_THEME).baseThemeRes;
|
||||
}
|
||||
|
||||
public static int getNoBackgroundTheme() {
|
||||
return THEME_SETS.get(SELECTED_THEME).noBackgroundThemeRes;
|
||||
}
|
||||
|
||||
public static int getDialogTheme() {
|
||||
return THEME_SETS.get(SELECTED_THEME).dialogThemeRes;
|
||||
}
|
||||
|
||||
//Returns true if theme has changed after startup.
|
||||
public static boolean changeTheme(int id) {
|
||||
Theme t = Theme.values()[id];
|
||||
if (t == SELECTED_THEME) {
|
||||
first = false;
|
||||
return false;
|
||||
}
|
||||
SELECTED_THEME = t;
|
||||
if (first) {
|
||||
first = false;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,411 +1,411 @@
|
||||
package com.gpl.rpg.AndorsTrail.view;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.Animation.AnimationListener;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailPreferences;
|
||||
import com.gpl.rpg.AndorsTrail.Dialogs;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.CombatController;
|
||||
import com.gpl.rpg.AndorsTrail.controller.listeners.ActorConditionListener;
|
||||
import com.gpl.rpg.AndorsTrail.controller.listeners.ActorStatsListener;
|
||||
import com.gpl.rpg.AndorsTrail.controller.listeners.CombatSelectionListener;
|
||||
import com.gpl.rpg.AndorsTrail.controller.listeners.CombatTurnListener;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.ActorCondition;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Actor;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
|
||||
public final class CombatView extends RelativeLayout implements CombatSelectionListener, CombatTurnListener, ActorStatsListener, ActorConditionListener {
|
||||
private final RangeBar playerAPBar;
|
||||
private final Button attackMoveButton;
|
||||
private final ImageButton monsterInfo;
|
||||
private final RangeBar monsterHealth;
|
||||
private final ImageButton monsterConditionsButton;
|
||||
private final RelativeLayout activeConditionsBar;
|
||||
private DisplayActiveActorConditionIcons activeConditions;
|
||||
private final ViewGroup monsterBar;
|
||||
private final ViewGroup actionBar;
|
||||
private final TextView monsterActionText;
|
||||
|
||||
private final WorldContext world;
|
||||
private final ControllerContext controllers;
|
||||
private final Resources res;
|
||||
private final AndorsTrailPreferences preferences;
|
||||
private final Player player;
|
||||
private final Animation displayAnimation;
|
||||
private final Animation hideAnimation;
|
||||
private final Animation displayConditionsButtonAnimation;
|
||||
private final Animation hideConditionsButtonAnimation;
|
||||
private final Animation displayConditionsBarAnimation;
|
||||
private final Animation hideConditionsBarAnimation;
|
||||
|
||||
private Monster currentMonster;
|
||||
private boolean conditionsBarToggled = false;
|
||||
|
||||
public CombatView(final Context context, AttributeSet attr) {
|
||||
super(context, attr);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivityContext(context);
|
||||
this.world = app.getWorld();
|
||||
this.player = world.model.player;
|
||||
this.controllers = app.getControllerContext();
|
||||
this.preferences = app.getPreferences();
|
||||
this.res = getResources();
|
||||
|
||||
setFocusable(false);
|
||||
inflate(context, R.layout.combatview, this);
|
||||
//Prevents mis-taps from registering as main area taps by going through the combat view.
|
||||
findViewById(R.id.combatview_fixedarea).setClickable(true);
|
||||
|
||||
final CombatController c = controllers.combatController;
|
||||
attackMoveButton = (Button) findViewById(R.id.combatview_moveattack);
|
||||
//Enable marquee if text is too long.
|
||||
attackMoveButton.setSelected(true);
|
||||
attackMoveButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
c.executeMoveAttack(0, 0);
|
||||
}
|
||||
});
|
||||
|
||||
Button endTurnButton = (Button) findViewById(R.id.combatview_endturn);
|
||||
//Enable marquee if text is too long.
|
||||
endTurnButton.setSelected(true);
|
||||
endTurnButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
c.endPlayerTurn();
|
||||
}
|
||||
});
|
||||
Button fleeButton = (Button) findViewById(R.id.combatview_flee);
|
||||
//Enable marquee if text is too long.
|
||||
fleeButton.setSelected(true);
|
||||
fleeButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
c.startFlee();
|
||||
}
|
||||
});
|
||||
|
||||
playerAPBar = (RangeBar) findViewById(R.id.combatview_status);
|
||||
playerAPBar.init(R.drawable.ui_progress_ap, R.string.status_ap);
|
||||
|
||||
monsterInfo = (ImageButton) findViewById(R.id.combatview_monsterinfo);
|
||||
monsterInfo.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
Dialogs.showMonsterInfo(context, currentMonster);
|
||||
}
|
||||
});
|
||||
|
||||
monsterHealth = (RangeBar) findViewById(R.id.combatview_monsterhealth);
|
||||
monsterHealth.init(R.drawable.ui_progress_health, R.string.combat_monsterhealth);
|
||||
monsterBar = (ViewGroup) findViewById(R.id.combatview_monsterbar);
|
||||
actionBar = (ViewGroup) findViewById(R.id.combatview_actionbar);
|
||||
monsterActionText = (TextView) findViewById(R.id.combatview_monsterismoving);
|
||||
|
||||
monsterConditionsButton = (ImageButton) findViewById(R.id.combatview_monsterconditions_button);
|
||||
monsterConditionsButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
toggleConditionsBarVisibility();
|
||||
}
|
||||
});
|
||||
|
||||
activeConditionsBar = (RelativeLayout) findViewById(R.id.combatview_activeconditions);
|
||||
activeConditions = new DisplayActiveActorConditionIcons(controllers, world, context, activeConditionsBar);
|
||||
|
||||
|
||||
// monsterBar.setBackgroundColor(res.getColor(color.transparent));
|
||||
// actionBar.setBackgroundColor(res.getColor(color.transparent));
|
||||
|
||||
displayAnimation = AnimationUtils.loadAnimation(context, R.anim.showcombatbar);
|
||||
hideAnimation = AnimationUtils.loadAnimation(context, R.anim.hidecombatbar);
|
||||
hideAnimation.setAnimationListener(new AnimationListener() {
|
||||
@Override public void onAnimationStart(Animation animation) {}
|
||||
@Override public void onAnimationRepeat(Animation animation) {}
|
||||
@Override public void onAnimationEnd(Animation arg0) {
|
||||
CombatView.this.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
displayConditionsButtonAnimation = AnimationUtils.loadAnimation(context, R.anim.showmonsterconditionbutton);
|
||||
hideConditionsButtonAnimation = AnimationUtils.loadAnimation(context, R.anim.hidemonsterconditionbutton);
|
||||
hideConditionsButtonAnimation.setAnimationListener(new AnimationListener() {
|
||||
@Override public void onAnimationStart(Animation animation) {}
|
||||
@Override public void onAnimationRepeat(Animation animation) {}
|
||||
@Override public void onAnimationEnd(Animation arg0) {
|
||||
monsterConditionsButton.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
displayConditionsBarAnimation = AnimationUtils.loadAnimation(context, R.anim.showmonsterconditionbar);
|
||||
hideConditionsBarAnimation = AnimationUtils.loadAnimation(context, R.anim.hidemonsterconditionbar);
|
||||
hideConditionsBarAnimation.setAnimationListener(new AnimationListener() {
|
||||
@Override public void onAnimationStart(Animation animation) {}
|
||||
@Override public void onAnimationRepeat(Animation animation) {}
|
||||
@Override public void onAnimationEnd(Animation arg0) {
|
||||
activeConditionsBar.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void toggleConditionsBarVisibility() {
|
||||
conditionsBarToggled = !conditionsBarToggled;
|
||||
if (conditionsBarToggled) showConditionsBar();
|
||||
else hideConditionsBar();
|
||||
}
|
||||
|
||||
private void updateTurnInfo(Monster currentActiveMonster) {
|
||||
if (currentActiveMonster != null) {
|
||||
actionBar.setVisibility(View.INVISIBLE);
|
||||
monsterActionText.setVisibility(View.VISIBLE);
|
||||
monsterActionText.setText(res.getString(R.string.combat_monsteraction, currentActiveMonster.getName()));
|
||||
} else {
|
||||
actionBar.setVisibility(View.VISIBLE);
|
||||
monsterActionText.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMonsterHealth(Monster m) {
|
||||
monsterHealth.update(m.getMaxHP(), m.getCurrentHP());
|
||||
}
|
||||
private void updatePlayerAP() {
|
||||
playerAPBar.update(player.getMaxAP(), player.getCurrentAP());
|
||||
updateAttackMoveButtonText();
|
||||
}
|
||||
private void updateSelectedMonster(Monster selectedMonster) {
|
||||
if (currentMonster != null && currentMonster == selectedMonster) return;
|
||||
|
||||
attackMoveButton.setEnabled(true);
|
||||
monsterBar.setVisibility(View.INVISIBLE);
|
||||
currentMonster = null;
|
||||
if (selectedMonster != null) {
|
||||
monsterBar.setVisibility(View.VISIBLE);
|
||||
world.tileManager.setImageViewTile(res, monsterInfo, selectedMonster, world.model.currentMaps.tiles);
|
||||
updateMonsterHealth(selectedMonster);
|
||||
currentMonster = selectedMonster;
|
||||
}
|
||||
updateAttackMoveButtonText(selectedMonster != null);
|
||||
updateConditions();
|
||||
}
|
||||
|
||||
private void updateConditions() {
|
||||
activeConditions.setTarget(currentMonster);
|
||||
if (currentMonster == null) {
|
||||
hideConditionsButton();
|
||||
return;
|
||||
}
|
||||
if (currentMonster.conditions.size()+currentMonster.immunities.size() > 0) {
|
||||
if (currentMonster.conditions.size() > 0) world.tileManager.setImageViewTile(getContext(), monsterConditionsButton, currentMonster.conditions.get(0).conditionType, false, Integer.toString(currentMonster.conditions.size()+currentMonster.immunities.size()), null);
|
||||
else world.tileManager.setImageViewTile(getContext(), monsterConditionsButton, currentMonster.immunities.get(0).conditionType, true, Integer.toString(currentMonster.conditions.size()+currentMonster.immunities.size()), null);
|
||||
showConditionsButton();
|
||||
if (conditionsBarToggled) showConditionsBar();
|
||||
} else {
|
||||
hideConditionsButton();
|
||||
hideConditionsBar();
|
||||
}
|
||||
}
|
||||
|
||||
private void showConditionsButton() {
|
||||
if (monsterConditionsButton.getVisibility() != View.VISIBLE) {
|
||||
monsterConditionsButton.setVisibility(View.VISIBLE);
|
||||
if (preferences.enableUiAnimations) {
|
||||
monsterConditionsButton.startAnimation(displayConditionsButtonAnimation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void hideConditionsButton() {
|
||||
if (monsterConditionsButton.getVisibility() == View.VISIBLE) {
|
||||
if (preferences.enableUiAnimations) {
|
||||
monsterConditionsButton.startAnimation(hideConditionsButtonAnimation);
|
||||
} else {
|
||||
monsterConditionsButton.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void showConditionsBar() {
|
||||
if (activeConditionsBar.getVisibility() != View.VISIBLE) {
|
||||
activeConditionsBar.setVisibility(View.VISIBLE);
|
||||
if (preferences.enableUiAnimations) {
|
||||
activeConditionsBar.startAnimation(displayConditionsBarAnimation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void hideConditionsBar() {
|
||||
if (activeConditionsBar.getVisibility() == View.VISIBLE) {
|
||||
if (preferences.enableUiAnimations) {
|
||||
activeConditionsBar.startAnimation(hideConditionsBarAnimation);
|
||||
} else {
|
||||
activeConditionsBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAttackMoveButtonText() {
|
||||
updateAttackMoveButtonText(world.model.uiSelections.selectedMonster != null);
|
||||
}
|
||||
private void updateAttackMoveButtonText(boolean hasSelectedMonster) {
|
||||
if (hasSelectedMonster) {
|
||||
attackMoveButton.setText(res.getString(R.string.combat_attack, player.getAttackCost()));
|
||||
} else {
|
||||
attackMoveButton.setText(res.getString(R.string.combat_move, player.getMoveCost()));
|
||||
}
|
||||
}
|
||||
|
||||
public void updateStatus() {
|
||||
updatePlayerAP();
|
||||
updateSelectedMonster(world.model.uiSelections.selectedMonster);
|
||||
}
|
||||
|
||||
private void show() {
|
||||
updateStatus();
|
||||
setVisibility(View.VISIBLE);
|
||||
bringToFront();
|
||||
if (preferences.enableUiAnimations) {
|
||||
startAnimation(displayAnimation);
|
||||
}
|
||||
}
|
||||
|
||||
private void hide() {
|
||||
if (preferences.enableUiAnimations) {
|
||||
startAnimation(hideAnimation);
|
||||
} else {
|
||||
setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void subscribe() {
|
||||
controllers.combatController.combatSelectionListeners.add(this);
|
||||
controllers.combatController.combatTurnListeners.add(this);
|
||||
controllers.actorStatsController.actorStatsListeners.add(this);
|
||||
controllers.actorStatsController.actorConditionListeners.add(this);
|
||||
activeConditions.subscribe();
|
||||
}
|
||||
public void unsubscribe() {
|
||||
controllers.actorStatsController.actorStatsListeners.remove(this);
|
||||
controllers.combatController.combatTurnListeners.remove(this);
|
||||
controllers.combatController.combatSelectionListeners.remove(this);
|
||||
controllers.actorStatsController.actorConditionListeners.remove(this);
|
||||
activeConditions.unsubscribe();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMonsterSelected(Monster m, Coord selectedPosition, Coord previousSelection) {
|
||||
updateSelectedMonster(m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMovementDestinationSelected(Coord selectedPosition, Coord previousSelection) {
|
||||
updateSelectedMonster(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCombatSelectionCleared(Coord previousSelection) {
|
||||
updateSelectedMonster(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCombatStarted() {
|
||||
show();
|
||||
updateTurnInfo(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCombatEnded() {
|
||||
hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewPlayerTurn() {
|
||||
updateTurnInfo(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMonsterIsAttacking(Monster m) {
|
||||
updateTurnInfo(m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorHealthChanged(Actor actor) {
|
||||
if (actor == currentMonster) updateMonsterHealth(currentMonster);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorAPChanged(Actor actor) {
|
||||
if (actor == player) updatePlayerAP();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorAttackCostChanged(Actor actor, int newAttackCost) {
|
||||
if (actor == player) updateAttackMoveButtonText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorMoveCostChanged(Actor actor, int newMoveCost) {
|
||||
if (actor == player) updateAttackMoveButtonText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerReequipCostChanged(Player actor, int newAttackCost) {}
|
||||
|
||||
@Override
|
||||
public void onPlayerUseCostChanged(Player actor, int newMoveCost) {}
|
||||
|
||||
@Override
|
||||
public void onActorConditionAdded(Actor actor, ActorCondition condition) {
|
||||
if (actor == currentMonster) updateConditions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorConditionRemoved(Actor actor, ActorCondition condition) {
|
||||
if (actor == currentMonster) updateConditions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorConditionDurationChanged(Actor actor, ActorCondition condition) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorConditionMagnitudeChanged(Actor actor, ActorCondition condition) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorConditionRoundEffectApplied(Actor actor, ActorCondition condition) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorConditionImmunityAdded(Actor actor, ActorCondition condition) {
|
||||
if (actor == currentMonster) updateConditions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorConditionImmunityRemoved(Actor actor, ActorCondition condition) {
|
||||
if (actor == currentMonster) updateConditions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorConditionImmunityDurationChanged(Actor actor, ActorCondition condition) {
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.view;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.Animation.AnimationListener;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailPreferences;
|
||||
import com.gpl.rpg.AndorsTrail.Dialogs;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.CombatController;
|
||||
import com.gpl.rpg.AndorsTrail.controller.listeners.ActorConditionListener;
|
||||
import com.gpl.rpg.AndorsTrail.controller.listeners.ActorStatsListener;
|
||||
import com.gpl.rpg.AndorsTrail.controller.listeners.CombatSelectionListener;
|
||||
import com.gpl.rpg.AndorsTrail.controller.listeners.CombatTurnListener;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.ActorCondition;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Actor;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
|
||||
public final class CombatView extends RelativeLayout implements CombatSelectionListener, CombatTurnListener, ActorStatsListener, ActorConditionListener {
|
||||
private final RangeBar playerAPBar;
|
||||
private final Button attackMoveButton;
|
||||
private final ImageButton monsterInfo;
|
||||
private final RangeBar monsterHealth;
|
||||
private final ImageButton monsterConditionsButton;
|
||||
private final RelativeLayout activeConditionsBar;
|
||||
private DisplayActiveActorConditionIcons activeConditions;
|
||||
private final ViewGroup monsterBar;
|
||||
private final ViewGroup actionBar;
|
||||
private final TextView monsterActionText;
|
||||
|
||||
private final WorldContext world;
|
||||
private final ControllerContext controllers;
|
||||
private final Resources res;
|
||||
private final AndorsTrailPreferences preferences;
|
||||
private final Player player;
|
||||
private final Animation displayAnimation;
|
||||
private final Animation hideAnimation;
|
||||
private final Animation displayConditionsButtonAnimation;
|
||||
private final Animation hideConditionsButtonAnimation;
|
||||
private final Animation displayConditionsBarAnimation;
|
||||
private final Animation hideConditionsBarAnimation;
|
||||
|
||||
private Monster currentMonster;
|
||||
private boolean conditionsBarToggled = false;
|
||||
|
||||
public CombatView(final Context context, AttributeSet attr) {
|
||||
super(context, attr);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivityContext(context);
|
||||
this.world = app.getWorld();
|
||||
this.player = world.model.player;
|
||||
this.controllers = app.getControllerContext();
|
||||
this.preferences = app.getPreferences();
|
||||
this.res = getResources();
|
||||
|
||||
setFocusable(false);
|
||||
inflate(context, R.layout.combatview, this);
|
||||
//Prevents mis-taps from registering as main area taps by going through the combat view.
|
||||
findViewById(R.id.combatview_fixedarea).setClickable(true);
|
||||
|
||||
final CombatController c = controllers.combatController;
|
||||
attackMoveButton = (Button) findViewById(R.id.combatview_moveattack);
|
||||
//Enable marquee if text is too long.
|
||||
attackMoveButton.setSelected(true);
|
||||
attackMoveButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
c.executeMoveAttack(0, 0);
|
||||
}
|
||||
});
|
||||
|
||||
Button endTurnButton = (Button) findViewById(R.id.combatview_endturn);
|
||||
//Enable marquee if text is too long.
|
||||
endTurnButton.setSelected(true);
|
||||
endTurnButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
c.endPlayerTurn();
|
||||
}
|
||||
});
|
||||
Button fleeButton = (Button) findViewById(R.id.combatview_flee);
|
||||
//Enable marquee if text is too long.
|
||||
fleeButton.setSelected(true);
|
||||
fleeButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
c.startFlee();
|
||||
}
|
||||
});
|
||||
|
||||
playerAPBar = (RangeBar) findViewById(R.id.combatview_status);
|
||||
playerAPBar.init(R.drawable.ui_progress_ap, R.string.status_ap);
|
||||
|
||||
monsterInfo = (ImageButton) findViewById(R.id.combatview_monsterinfo);
|
||||
monsterInfo.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
Dialogs.showMonsterInfo(context, currentMonster);
|
||||
}
|
||||
});
|
||||
|
||||
monsterHealth = (RangeBar) findViewById(R.id.combatview_monsterhealth);
|
||||
monsterHealth.init(R.drawable.ui_progress_health, R.string.combat_monsterhealth);
|
||||
monsterBar = (ViewGroup) findViewById(R.id.combatview_monsterbar);
|
||||
actionBar = (ViewGroup) findViewById(R.id.combatview_actionbar);
|
||||
monsterActionText = (TextView) findViewById(R.id.combatview_monsterismoving);
|
||||
|
||||
monsterConditionsButton = (ImageButton) findViewById(R.id.combatview_monsterconditions_button);
|
||||
monsterConditionsButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
toggleConditionsBarVisibility();
|
||||
}
|
||||
});
|
||||
|
||||
activeConditionsBar = (RelativeLayout) findViewById(R.id.combatview_activeconditions);
|
||||
activeConditions = new DisplayActiveActorConditionIcons(controllers, world, context, activeConditionsBar);
|
||||
|
||||
|
||||
// monsterBar.setBackgroundColor(res.getColor(color.transparent));
|
||||
// actionBar.setBackgroundColor(res.getColor(color.transparent));
|
||||
|
||||
displayAnimation = AnimationUtils.loadAnimation(context, R.anim.showcombatbar);
|
||||
hideAnimation = AnimationUtils.loadAnimation(context, R.anim.hidecombatbar);
|
||||
hideAnimation.setAnimationListener(new AnimationListener() {
|
||||
@Override public void onAnimationStart(Animation animation) {}
|
||||
@Override public void onAnimationRepeat(Animation animation) {}
|
||||
@Override public void onAnimationEnd(Animation arg0) {
|
||||
CombatView.this.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
displayConditionsButtonAnimation = AnimationUtils.loadAnimation(context, R.anim.showmonsterconditionbutton);
|
||||
hideConditionsButtonAnimation = AnimationUtils.loadAnimation(context, R.anim.hidemonsterconditionbutton);
|
||||
hideConditionsButtonAnimation.setAnimationListener(new AnimationListener() {
|
||||
@Override public void onAnimationStart(Animation animation) {}
|
||||
@Override public void onAnimationRepeat(Animation animation) {}
|
||||
@Override public void onAnimationEnd(Animation arg0) {
|
||||
monsterConditionsButton.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
displayConditionsBarAnimation = AnimationUtils.loadAnimation(context, R.anim.showmonsterconditionbar);
|
||||
hideConditionsBarAnimation = AnimationUtils.loadAnimation(context, R.anim.hidemonsterconditionbar);
|
||||
hideConditionsBarAnimation.setAnimationListener(new AnimationListener() {
|
||||
@Override public void onAnimationStart(Animation animation) {}
|
||||
@Override public void onAnimationRepeat(Animation animation) {}
|
||||
@Override public void onAnimationEnd(Animation arg0) {
|
||||
activeConditionsBar.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void toggleConditionsBarVisibility() {
|
||||
conditionsBarToggled = !conditionsBarToggled;
|
||||
if (conditionsBarToggled) showConditionsBar();
|
||||
else hideConditionsBar();
|
||||
}
|
||||
|
||||
private void updateTurnInfo(Monster currentActiveMonster) {
|
||||
if (currentActiveMonster != null) {
|
||||
actionBar.setVisibility(View.INVISIBLE);
|
||||
monsterActionText.setVisibility(View.VISIBLE);
|
||||
monsterActionText.setText(res.getString(R.string.combat_monsteraction, currentActiveMonster.getName()));
|
||||
} else {
|
||||
actionBar.setVisibility(View.VISIBLE);
|
||||
monsterActionText.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMonsterHealth(Monster m) {
|
||||
monsterHealth.update(m.getMaxHP(), m.getCurrentHP());
|
||||
}
|
||||
private void updatePlayerAP() {
|
||||
playerAPBar.update(player.getMaxAP(), player.getCurrentAP());
|
||||
updateAttackMoveButtonText();
|
||||
}
|
||||
private void updateSelectedMonster(Monster selectedMonster) {
|
||||
if (currentMonster != null && currentMonster == selectedMonster) return;
|
||||
|
||||
attackMoveButton.setEnabled(true);
|
||||
monsterBar.setVisibility(View.INVISIBLE);
|
||||
currentMonster = null;
|
||||
if (selectedMonster != null) {
|
||||
monsterBar.setVisibility(View.VISIBLE);
|
||||
world.tileManager.setImageViewTile(res, monsterInfo, selectedMonster, world.model.currentMaps.tiles);
|
||||
updateMonsterHealth(selectedMonster);
|
||||
currentMonster = selectedMonster;
|
||||
}
|
||||
updateAttackMoveButtonText(selectedMonster != null);
|
||||
updateConditions();
|
||||
}
|
||||
|
||||
private void updateConditions() {
|
||||
activeConditions.setTarget(currentMonster);
|
||||
if (currentMonster == null) {
|
||||
hideConditionsButton();
|
||||
return;
|
||||
}
|
||||
if (currentMonster.conditions.size()+currentMonster.immunities.size() > 0) {
|
||||
if (currentMonster.conditions.size() > 0) world.tileManager.setImageViewTile(getContext(), monsterConditionsButton, currentMonster.conditions.get(0).conditionType, false, Integer.toString(currentMonster.conditions.size()+currentMonster.immunities.size()), null);
|
||||
else world.tileManager.setImageViewTile(getContext(), monsterConditionsButton, currentMonster.immunities.get(0).conditionType, true, Integer.toString(currentMonster.conditions.size()+currentMonster.immunities.size()), null);
|
||||
showConditionsButton();
|
||||
if (conditionsBarToggled) showConditionsBar();
|
||||
} else {
|
||||
hideConditionsButton();
|
||||
hideConditionsBar();
|
||||
}
|
||||
}
|
||||
|
||||
private void showConditionsButton() {
|
||||
if (monsterConditionsButton.getVisibility() != View.VISIBLE) {
|
||||
monsterConditionsButton.setVisibility(View.VISIBLE);
|
||||
if (preferences.enableUiAnimations) {
|
||||
monsterConditionsButton.startAnimation(displayConditionsButtonAnimation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void hideConditionsButton() {
|
||||
if (monsterConditionsButton.getVisibility() == View.VISIBLE) {
|
||||
if (preferences.enableUiAnimations) {
|
||||
monsterConditionsButton.startAnimation(hideConditionsButtonAnimation);
|
||||
} else {
|
||||
monsterConditionsButton.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void showConditionsBar() {
|
||||
if (activeConditionsBar.getVisibility() != View.VISIBLE) {
|
||||
activeConditionsBar.setVisibility(View.VISIBLE);
|
||||
if (preferences.enableUiAnimations) {
|
||||
activeConditionsBar.startAnimation(displayConditionsBarAnimation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void hideConditionsBar() {
|
||||
if (activeConditionsBar.getVisibility() == View.VISIBLE) {
|
||||
if (preferences.enableUiAnimations) {
|
||||
activeConditionsBar.startAnimation(hideConditionsBarAnimation);
|
||||
} else {
|
||||
activeConditionsBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAttackMoveButtonText() {
|
||||
updateAttackMoveButtonText(world.model.uiSelections.selectedMonster != null);
|
||||
}
|
||||
private void updateAttackMoveButtonText(boolean hasSelectedMonster) {
|
||||
if (hasSelectedMonster) {
|
||||
attackMoveButton.setText(res.getString(R.string.combat_attack, player.getAttackCost()));
|
||||
} else {
|
||||
attackMoveButton.setText(res.getString(R.string.combat_move, player.getMoveCost()));
|
||||
}
|
||||
}
|
||||
|
||||
public void updateStatus() {
|
||||
updatePlayerAP();
|
||||
updateSelectedMonster(world.model.uiSelections.selectedMonster);
|
||||
}
|
||||
|
||||
private void show() {
|
||||
updateStatus();
|
||||
setVisibility(View.VISIBLE);
|
||||
bringToFront();
|
||||
if (preferences.enableUiAnimations) {
|
||||
startAnimation(displayAnimation);
|
||||
}
|
||||
}
|
||||
|
||||
private void hide() {
|
||||
if (preferences.enableUiAnimations) {
|
||||
startAnimation(hideAnimation);
|
||||
} else {
|
||||
setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void subscribe() {
|
||||
controllers.combatController.combatSelectionListeners.add(this);
|
||||
controllers.combatController.combatTurnListeners.add(this);
|
||||
controllers.actorStatsController.actorStatsListeners.add(this);
|
||||
controllers.actorStatsController.actorConditionListeners.add(this);
|
||||
activeConditions.subscribe();
|
||||
}
|
||||
public void unsubscribe() {
|
||||
controllers.actorStatsController.actorStatsListeners.remove(this);
|
||||
controllers.combatController.combatTurnListeners.remove(this);
|
||||
controllers.combatController.combatSelectionListeners.remove(this);
|
||||
controllers.actorStatsController.actorConditionListeners.remove(this);
|
||||
activeConditions.unsubscribe();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMonsterSelected(Monster m, Coord selectedPosition, Coord previousSelection) {
|
||||
updateSelectedMonster(m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMovementDestinationSelected(Coord selectedPosition, Coord previousSelection) {
|
||||
updateSelectedMonster(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCombatSelectionCleared(Coord previousSelection) {
|
||||
updateSelectedMonster(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCombatStarted() {
|
||||
show();
|
||||
updateTurnInfo(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCombatEnded() {
|
||||
hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewPlayerTurn() {
|
||||
updateTurnInfo(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMonsterIsAttacking(Monster m) {
|
||||
updateTurnInfo(m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorHealthChanged(Actor actor) {
|
||||
if (actor == currentMonster) updateMonsterHealth(currentMonster);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorAPChanged(Actor actor) {
|
||||
if (actor == player) updatePlayerAP();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorAttackCostChanged(Actor actor, int newAttackCost) {
|
||||
if (actor == player) updateAttackMoveButtonText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorMoveCostChanged(Actor actor, int newMoveCost) {
|
||||
if (actor == player) updateAttackMoveButtonText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerReequipCostChanged(Player actor, int newAttackCost) {}
|
||||
|
||||
@Override
|
||||
public void onPlayerUseCostChanged(Player actor, int newMoveCost) {}
|
||||
|
||||
@Override
|
||||
public void onActorConditionAdded(Actor actor, ActorCondition condition) {
|
||||
if (actor == currentMonster) updateConditions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorConditionRemoved(Actor actor, ActorCondition condition) {
|
||||
if (actor == currentMonster) updateConditions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorConditionDurationChanged(Actor actor, ActorCondition condition) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorConditionMagnitudeChanged(Actor actor, ActorCondition condition) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorConditionRoundEffectApplied(Actor actor, ActorCondition condition) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorConditionImmunityAdded(Actor actor, ActorCondition condition) {
|
||||
if (actor == currentMonster) updateConditions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorConditionImmunityRemoved(Actor actor, ActorCondition condition) {
|
||||
if (actor == currentMonster) updateConditions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorConditionImmunityDurationChanged(Actor actor, ActorCondition condition) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,177 +1,177 @@
|
||||
package com.gpl.rpg.AndorsTrail.view;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
|
||||
public class CustomDialogFactory {
|
||||
|
||||
public static class CustomDialog extends Dialog {
|
||||
public CustomDialog(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static CustomDialog createDialog(final Context context, String title, Drawable icon, String desc, View content, boolean hasButtons) {
|
||||
return createDialog(context, title, icon, desc, content, hasButtons, true);
|
||||
}
|
||||
|
||||
public static CustomDialog createDialog(final Context context, String title, Drawable icon, String desc, View content, boolean hasButtons, final boolean canDismiss) {
|
||||
final CustomDialog dialog = new CustomDialog(new ContextThemeWrapper(context, ThemeHelper.getDialogTheme())) {
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
Rect r = new Rect();
|
||||
this.getWindow().getDecorView().findViewById(R.id.dialog_hitrect).getHitRect(r);
|
||||
|
||||
if (r.contains((int)event.getX(), (int)event.getY())) {
|
||||
return super.onTouchEvent(event);
|
||||
} else {
|
||||
if (canDismiss) {
|
||||
this.dismiss();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
TextView title = (TextView) this.getWindow().getDecorView().findViewById(R.id.dialog_title);
|
||||
if (title != null && title.getCompoundDrawables() != null && title.getCompoundDrawables()[0] != null) {
|
||||
if (title.getCompoundDrawables()[0] instanceof AnimationDrawable) {
|
||||
((AnimationDrawable)title.getCompoundDrawables()[0]).start();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(R.layout.custom_dialog_title_icon);
|
||||
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
|
||||
if (((AndorsTrailApplication)context.getApplicationContext()).getPreferences().fullscreen) {
|
||||
dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
} else {
|
||||
dialog.getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
|
||||
setTitle(dialog, title, icon);
|
||||
|
||||
setDesc(dialog, desc);
|
||||
|
||||
setContent(dialog, content);
|
||||
|
||||
ViewGroup buttonsHolder = (ViewGroup) dialog.findViewById(R.id.dialog_button_container);
|
||||
if (hasButtons) {
|
||||
buttonsHolder.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
buttonsHolder.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static CustomDialog setTitle(final CustomDialog dialog, String title, Drawable icon) {
|
||||
TextView titleView = (TextView) dialog.findViewById(R.id.dialog_title);
|
||||
if (title != null || icon != null) {
|
||||
titleView.setText(title);
|
||||
titleView.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
|
||||
titleView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
titleView.setVisibility(View.GONE);
|
||||
}
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static CustomDialog setDesc(final CustomDialog dialog, String desc) {
|
||||
TextView descView = (TextView) dialog.findViewById(R.id.dialog_description);
|
||||
ViewGroup descHolder = (ViewGroup) dialog.findViewById(R.id.dialog_description_container);
|
||||
if (desc != null) {
|
||||
descView.setText(desc);
|
||||
descHolder.setVisibility(View.VISIBLE);
|
||||
descView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
descHolder.setVisibility(View.GONE);
|
||||
}
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static CustomDialog setContent(final CustomDialog dialog, View content) {
|
||||
ViewGroup contentHolder = (ViewGroup) dialog.findViewById(R.id.dialog_content_container);
|
||||
if (content != null) {
|
||||
contentHolder.addView(content);
|
||||
contentHolder.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
contentHolder.setVisibility(View.GONE);
|
||||
}
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static Dialog addButton(final Dialog dialog, int textId, final OnClickListener listener) {
|
||||
|
||||
Button template = (Button) dialog.findViewById(R.id.dialog_template_button);
|
||||
LayoutParams params = template.getLayoutParams();
|
||||
ViewGroup buttonsHolder = (ViewGroup) dialog.findViewById(R.id.dialog_button_container);
|
||||
|
||||
Button b = new Button(dialog.getContext());
|
||||
b.setLayoutParams(params);
|
||||
//Old android versions need this "reminder"
|
||||
b.setBackgroundDrawable(ThemeHelper.getThemeDrawable(dialog.getContext(), R.attr.ui_theme_textbutton_drawable));
|
||||
b.setTextColor(ThemeHelper.getThemeColor(dialog.getContext(), R.attr.ui_theme_dialogue_light_color));
|
||||
|
||||
b.setText(textId);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
listener.onClick(v);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
buttonsHolder.addView(b, params);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static Dialog addDismissButton(final Dialog dialog, int textId) {
|
||||
return CustomDialogFactory.addButton(dialog, textId, new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Dialog setDismissListener(Dialog dialog, OnDismissListener listener) {
|
||||
dialog.setOnDismissListener(listener);
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static void show(Dialog dialog) {
|
||||
|
||||
dialog.findViewById(R.id.dialog_template_button).setVisibility(View.GONE);
|
||||
dialog.show();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.view;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
|
||||
public class CustomDialogFactory {
|
||||
|
||||
public static class CustomDialog extends Dialog {
|
||||
public CustomDialog(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static CustomDialog createDialog(final Context context, String title, Drawable icon, String desc, View content, boolean hasButtons) {
|
||||
return createDialog(context, title, icon, desc, content, hasButtons, true);
|
||||
}
|
||||
|
||||
public static CustomDialog createDialog(final Context context, String title, Drawable icon, String desc, View content, boolean hasButtons, final boolean canDismiss) {
|
||||
final CustomDialog dialog = new CustomDialog(new ContextThemeWrapper(context, ThemeHelper.getDialogTheme())) {
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
Rect r = new Rect();
|
||||
this.getWindow().getDecorView().findViewById(R.id.dialog_hitrect).getHitRect(r);
|
||||
|
||||
if (r.contains((int)event.getX(), (int)event.getY())) {
|
||||
return super.onTouchEvent(event);
|
||||
} else {
|
||||
if (canDismiss) {
|
||||
this.dismiss();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
TextView title = (TextView) this.getWindow().getDecorView().findViewById(R.id.dialog_title);
|
||||
if (title != null && title.getCompoundDrawables() != null && title.getCompoundDrawables()[0] != null) {
|
||||
if (title.getCompoundDrawables()[0] instanceof AnimationDrawable) {
|
||||
((AnimationDrawable)title.getCompoundDrawables()[0]).start();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(R.layout.custom_dialog_title_icon);
|
||||
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
|
||||
if (((AndorsTrailApplication)context.getApplicationContext()).getPreferences().fullscreen) {
|
||||
dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
} else {
|
||||
dialog.getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
|
||||
setTitle(dialog, title, icon);
|
||||
|
||||
setDesc(dialog, desc);
|
||||
|
||||
setContent(dialog, content);
|
||||
|
||||
ViewGroup buttonsHolder = (ViewGroup) dialog.findViewById(R.id.dialog_button_container);
|
||||
if (hasButtons) {
|
||||
buttonsHolder.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
buttonsHolder.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static CustomDialog setTitle(final CustomDialog dialog, String title, Drawable icon) {
|
||||
TextView titleView = (TextView) dialog.findViewById(R.id.dialog_title);
|
||||
if (title != null || icon != null) {
|
||||
titleView.setText(title);
|
||||
titleView.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
|
||||
titleView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
titleView.setVisibility(View.GONE);
|
||||
}
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static CustomDialog setDesc(final CustomDialog dialog, String desc) {
|
||||
TextView descView = (TextView) dialog.findViewById(R.id.dialog_description);
|
||||
ViewGroup descHolder = (ViewGroup) dialog.findViewById(R.id.dialog_description_container);
|
||||
if (desc != null) {
|
||||
descView.setText(desc);
|
||||
descHolder.setVisibility(View.VISIBLE);
|
||||
descView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
descHolder.setVisibility(View.GONE);
|
||||
}
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static CustomDialog setContent(final CustomDialog dialog, View content) {
|
||||
ViewGroup contentHolder = (ViewGroup) dialog.findViewById(R.id.dialog_content_container);
|
||||
if (content != null) {
|
||||
contentHolder.addView(content);
|
||||
contentHolder.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
contentHolder.setVisibility(View.GONE);
|
||||
}
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static Dialog addButton(final Dialog dialog, int textId, final OnClickListener listener) {
|
||||
|
||||
Button template = (Button) dialog.findViewById(R.id.dialog_template_button);
|
||||
LayoutParams params = template.getLayoutParams();
|
||||
ViewGroup buttonsHolder = (ViewGroup) dialog.findViewById(R.id.dialog_button_container);
|
||||
|
||||
Button b = new Button(dialog.getContext());
|
||||
b.setLayoutParams(params);
|
||||
//Old android versions need this "reminder"
|
||||
b.setBackgroundDrawable(ThemeHelper.getThemeDrawable(dialog.getContext(), R.attr.ui_theme_textbutton_drawable));
|
||||
b.setTextColor(ThemeHelper.getThemeColor(dialog.getContext(), R.attr.ui_theme_dialogue_light_color));
|
||||
|
||||
b.setText(textId);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
listener.onClick(v);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
buttonsHolder.addView(b, params);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static Dialog addDismissButton(final Dialog dialog, int textId) {
|
||||
return CustomDialogFactory.addButton(dialog, textId, new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Dialog setDismissListener(Dialog dialog, OnDismissListener listener) {
|
||||
dialog.setOnDismissListener(listener);
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static void show(Dialog dialog) {
|
||||
|
||||
dialog.findViewById(R.id.dialog_template_button).setVisibility(View.GONE);
|
||||
dialog.show();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,101 +1,101 @@
|
||||
package com.gpl.rpg.AndorsTrail.view;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.preference.ListPreference;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory.CustomDialog;
|
||||
|
||||
public class CustomListPreference extends ListPreference {
|
||||
|
||||
//Extensive constructor support
|
||||
public CustomListPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
public CustomListPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
// Min API 21
|
||||
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
// public CustomListPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
// super(context, attrs, defStyleAttr);
|
||||
// }
|
||||
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
// public CustomListPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
// super(context, attrs, defStyleAttr, defStyleRes);
|
||||
// }
|
||||
|
||||
CustomDialog d = null;
|
||||
int clickedEntryIndex = 0;
|
||||
|
||||
@Override
|
||||
public Dialog getDialog() {
|
||||
if (d == null) createDialog();
|
||||
return d;
|
||||
}
|
||||
|
||||
private void createDialog() {
|
||||
final ListView choicesList = new ListView(getContext());
|
||||
choicesList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
|
||||
choicesList.setBackgroundResource(android.R.color.transparent);
|
||||
ArrayAdapter<CharSequence> choicesAdapter = new ArrayAdapter<CharSequence>(getContext(), R.layout.custom_checkedlistitem_layout, getEntries());
|
||||
choicesList.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, ListView.LayoutParams.WRAP_CONTENT));
|
||||
choicesList.setAdapter(choicesAdapter);
|
||||
choicesList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (getValue() != getEntryValues()[position]) {
|
||||
CustomListPreference.this.notifyChanged();
|
||||
clickedEntryIndex = position;
|
||||
CustomListPreference.this.onClick(d, DialogInterface.BUTTON_POSITIVE);
|
||||
} else {
|
||||
CustomListPreference.this.onClick(d, DialogInterface.BUTTON_NEGATIVE);
|
||||
}
|
||||
d.dismiss();
|
||||
}
|
||||
});
|
||||
choicesList.setItemChecked(getValueIndex(), true);
|
||||
|
||||
d = CustomDialogFactory.createDialog(getContext(), getTitle().toString(), null, null, choicesList, false);
|
||||
}
|
||||
|
||||
public int getValueIndex() {
|
||||
int selectedPosition;
|
||||
for (selectedPosition = getEntryValues().length - 1; selectedPosition >= 0; selectedPosition--) {
|
||||
if (getValue().equals(getEntryValues()[selectedPosition].toString())) break;
|
||||
}
|
||||
return selectedPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDialogClosed(boolean positiveResult) {
|
||||
CharSequence[] entryValues = getEntryValues();
|
||||
if (positiveResult && clickedEntryIndex >= 0 && entryValues != null) {
|
||||
String value = entryValues[clickedEntryIndex].toString();
|
||||
if (callChangeListener(value)) {
|
||||
setValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showDialog(Bundle state) {
|
||||
getDialog().setOnDismissListener(this);
|
||||
getDialog().show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
d = null;
|
||||
super.onDismiss(dialog);
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.view;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.preference.ListPreference;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory.CustomDialog;
|
||||
|
||||
public class CustomListPreference extends ListPreference {
|
||||
|
||||
//Extensive constructor support
|
||||
public CustomListPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
public CustomListPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
// Min API 21
|
||||
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
// public CustomListPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
// super(context, attrs, defStyleAttr);
|
||||
// }
|
||||
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
// public CustomListPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
// super(context, attrs, defStyleAttr, defStyleRes);
|
||||
// }
|
||||
|
||||
CustomDialog d = null;
|
||||
int clickedEntryIndex = 0;
|
||||
|
||||
@Override
|
||||
public Dialog getDialog() {
|
||||
if (d == null) createDialog();
|
||||
return d;
|
||||
}
|
||||
|
||||
private void createDialog() {
|
||||
final ListView choicesList = new ListView(getContext());
|
||||
choicesList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
|
||||
choicesList.setBackgroundResource(android.R.color.transparent);
|
||||
ArrayAdapter<CharSequence> choicesAdapter = new ArrayAdapter<CharSequence>(getContext(), R.layout.custom_checkedlistitem_layout, getEntries());
|
||||
choicesList.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, ListView.LayoutParams.WRAP_CONTENT));
|
||||
choicesList.setAdapter(choicesAdapter);
|
||||
choicesList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (getValue() != getEntryValues()[position]) {
|
||||
CustomListPreference.this.notifyChanged();
|
||||
clickedEntryIndex = position;
|
||||
CustomListPreference.this.onClick(d, DialogInterface.BUTTON_POSITIVE);
|
||||
} else {
|
||||
CustomListPreference.this.onClick(d, DialogInterface.BUTTON_NEGATIVE);
|
||||
}
|
||||
d.dismiss();
|
||||
}
|
||||
});
|
||||
choicesList.setItemChecked(getValueIndex(), true);
|
||||
|
||||
d = CustomDialogFactory.createDialog(getContext(), getTitle().toString(), null, null, choicesList, false);
|
||||
}
|
||||
|
||||
public int getValueIndex() {
|
||||
int selectedPosition;
|
||||
for (selectedPosition = getEntryValues().length - 1; selectedPosition >= 0; selectedPosition--) {
|
||||
if (getValue().equals(getEntryValues()[selectedPosition].toString())) break;
|
||||
}
|
||||
return selectedPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDialogClosed(boolean positiveResult) {
|
||||
CharSequence[] entryValues = getEntryValues();
|
||||
if (positiveResult && clickedEntryIndex >= 0 && entryValues != null) {
|
||||
String value = entryValues[clickedEntryIndex].toString();
|
||||
if (callChangeListener(value)) {
|
||||
setValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showDialog(Bundle state) {
|
||||
getDialog().setOnDismissListener(this);
|
||||
getDialog().show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
d = null;
|
||||
super.onDismiss(dialog);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,62 +1,60 @@
|
||||
package com.gpl.rpg.AndorsTrail.view;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.Checkable;
|
||||
import android.widget.TextView;
|
||||
|
||||
//Thanks to https://stackoverflow.com/questions/6205339/listview-item-selected-state-not-working
|
||||
|
||||
public class SelectableTextView extends TextView implements Checkable {
|
||||
private static final int[] CHECKED_STATE_SET = {
|
||||
android.R.attr.state_checked
|
||||
};
|
||||
|
||||
private boolean mChecked;
|
||||
|
||||
public SelectableTextView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public SelectableTextView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public SelectableTextView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
// public SelectableTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
// super(context, attrs, defStyleAttr, defStyleRes);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void setChecked(boolean checked) {
|
||||
if (mChecked != checked) {
|
||||
mChecked = checked;
|
||||
refreshDrawableState();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return mChecked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggle() {
|
||||
setSelected(!mChecked);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int[] onCreateDrawableState(int extraSpace) {
|
||||
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
|
||||
if (isChecked()) {
|
||||
mergeDrawableStates(drawableState, CHECKED_STATE_SET);
|
||||
}
|
||||
return drawableState;
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.Checkable;
|
||||
import android.widget.TextView;
|
||||
|
||||
//Thanks to https://stackoverflow.com/questions/6205339/listview-item-selected-state-not-working
|
||||
|
||||
public class SelectableTextView extends TextView implements Checkable {
|
||||
private static final int[] CHECKED_STATE_SET = {
|
||||
android.R.attr.state_checked
|
||||
};
|
||||
|
||||
private boolean mChecked;
|
||||
|
||||
public SelectableTextView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public SelectableTextView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public SelectableTextView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
// public SelectableTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
// super(context, attrs, defStyleAttr, defStyleRes);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void setChecked(boolean checked) {
|
||||
if (mChecked != checked) {
|
||||
mChecked = checked;
|
||||
refreshDrawableState();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return mChecked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggle() {
|
||||
setSelected(!mChecked);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int[] onCreateDrawableState(int extraSpace) {
|
||||
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
|
||||
if (isChecked()) {
|
||||
mergeDrawableStates(drawableState, CHECKED_STATE_SET);
|
||||
}
|
||||
return drawableState;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,75 +1,75 @@
|
||||
package com.gpl.rpg.AndorsTrail.view;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
|
||||
/**
|
||||
* Simply instantiate this class, implement abstract methods in an anonymous type, and tada, your Button is a Spinner!
|
||||
*/
|
||||
public abstract class SpinnerEmulator {
|
||||
|
||||
private Button spinnerButton;
|
||||
private Dialog spinnerDialog = null;
|
||||
private ListView choicesList;
|
||||
private Context context;
|
||||
|
||||
public SpinnerEmulator(Button b, int arrayResId, int promptResId) {
|
||||
spinnerButton = b;
|
||||
context=b.getContext();
|
||||
initializeSpinnerEmulation(arrayResId, promptResId);
|
||||
}
|
||||
|
||||
|
||||
public SpinnerEmulator(View v, int buttonId, int arrayResId, int promptResId) {
|
||||
spinnerButton = (Button) v.findViewById(buttonId);
|
||||
context=v.getContext();
|
||||
initializeSpinnerEmulation(arrayResId, promptResId);
|
||||
}
|
||||
|
||||
public void initializeSpinnerEmulation(final int arrayResId, final int promptResId) {
|
||||
choicesList = new ListView(context);//(Spinner) v.findViewById(R.id.inventorylist_category_filters);
|
||||
choicesList.setBackgroundResource(android.R.color.transparent);
|
||||
ArrayAdapter<CharSequence> skillCategoryFilterAdapter = ArrayAdapter.createFromResource(context, arrayResId, android.R.layout.simple_list_item_1);
|
||||
choicesList.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, ListView.LayoutParams.WRAP_CONTENT));
|
||||
choicesList.setAdapter(skillCategoryFilterAdapter);
|
||||
choicesList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (getValue() == position) {
|
||||
spinnerDialog.dismiss();
|
||||
return;
|
||||
}
|
||||
setValue(position);
|
||||
spinnerButton.setText(context.getResources().getStringArray(arrayResId)[position]);
|
||||
spinnerDialog.dismiss();
|
||||
selectionChanged(position);
|
||||
}
|
||||
});
|
||||
choicesList.setSelection(getValue());
|
||||
|
||||
spinnerButton.setText(context.getResources().getStringArray(arrayResId)[getValue()]);
|
||||
spinnerButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (spinnerDialog == null) {
|
||||
spinnerDialog = CustomDialogFactory.createDialog(context, context.getString(promptResId), null, null, choicesList, false);
|
||||
}
|
||||
CustomDialogFactory.show(spinnerDialog);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public abstract int getValue();
|
||||
public abstract void setValue(int value);
|
||||
public abstract void selectionChanged(int value);
|
||||
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.view;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
|
||||
/**
|
||||
* Simply instantiate this class, implement abstract methods in an anonymous type, and tada, your Button is a Spinner!
|
||||
*/
|
||||
public abstract class SpinnerEmulator {
|
||||
|
||||
private Button spinnerButton;
|
||||
private Dialog spinnerDialog = null;
|
||||
private ListView choicesList;
|
||||
private Context context;
|
||||
|
||||
public SpinnerEmulator(Button b, int arrayResId, int promptResId) {
|
||||
spinnerButton = b;
|
||||
context=b.getContext();
|
||||
initializeSpinnerEmulation(arrayResId, promptResId);
|
||||
}
|
||||
|
||||
|
||||
public SpinnerEmulator(View v, int buttonId, int arrayResId, int promptResId) {
|
||||
spinnerButton = (Button) v.findViewById(buttonId);
|
||||
context=v.getContext();
|
||||
initializeSpinnerEmulation(arrayResId, promptResId);
|
||||
}
|
||||
|
||||
public void initializeSpinnerEmulation(final int arrayResId, final int promptResId) {
|
||||
choicesList = new ListView(context);//(Spinner) v.findViewById(R.id.inventorylist_category_filters);
|
||||
choicesList.setBackgroundResource(android.R.color.transparent);
|
||||
ArrayAdapter<CharSequence> skillCategoryFilterAdapter = ArrayAdapter.createFromResource(context, arrayResId, android.R.layout.simple_list_item_1);
|
||||
choicesList.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, ListView.LayoutParams.WRAP_CONTENT));
|
||||
choicesList.setAdapter(skillCategoryFilterAdapter);
|
||||
choicesList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (getValue() == position) {
|
||||
spinnerDialog.dismiss();
|
||||
return;
|
||||
}
|
||||
setValue(position);
|
||||
spinnerButton.setText(context.getResources().getStringArray(arrayResId)[position]);
|
||||
spinnerDialog.dismiss();
|
||||
selectionChanged(position);
|
||||
}
|
||||
});
|
||||
choicesList.setSelection(getValue());
|
||||
|
||||
spinnerButton.setText(context.getResources().getStringArray(arrayResId)[getValue()]);
|
||||
spinnerButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (spinnerDialog == null) {
|
||||
spinnerDialog = CustomDialogFactory.createDialog(context, context.getString(promptResId), null, null, choicesList, false);
|
||||
}
|
||||
CustomDialogFactory.show(spinnerDialog);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public abstract int getValue();
|
||||
public abstract void setValue(int value);
|
||||
public abstract void selectionChanged(int value);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,133 +1,133 @@
|
||||
package com.gpl.rpg.AndorsTrail.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.activity.HeroinfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.listeners.ActorStatsListener;
|
||||
import com.gpl.rpg.AndorsTrail.controller.listeners.PlayerStatsListener;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Actor;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
|
||||
|
||||
public final class StatusView extends RelativeLayout implements PlayerStatsListener, ActorStatsListener {
|
||||
|
||||
private final ControllerContext controllers;
|
||||
private final WorldContext world;
|
||||
private final Player player;
|
||||
private final Resources res;
|
||||
|
||||
private final RangeBar healthBar;
|
||||
private final RangeBar expBar;
|
||||
private final ImageButton heroImage;
|
||||
private boolean showingLevelup;
|
||||
// private final Drawable levelupDrawable;
|
||||
|
||||
public StatusView(final Context context, AttributeSet attr) {
|
||||
super(context, attr);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivityContext(context);
|
||||
this.controllers = app.getControllerContext();
|
||||
this.world = app.getWorld();
|
||||
this.player = world.model.player;
|
||||
|
||||
setFocusable(false);
|
||||
inflate(context, R.layout.statusview, this);
|
||||
this.setBackgroundResource(R.drawable.ui_gradientshape);
|
||||
|
||||
heroImage = (ImageButton) findViewById(R.id.status_image);
|
||||
showingLevelup = true;
|
||||
|
||||
heroImage.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
context.startActivity(new Intent(context, HeroinfoActivity.class));
|
||||
}
|
||||
});
|
||||
healthBar = (RangeBar) findViewById(R.id.statusview_health);
|
||||
healthBar.init(R.drawable.ui_progress_health, R.string.status_hp);
|
||||
|
||||
expBar = (RangeBar) findViewById(R.id.statusview_exp);
|
||||
expBar.init(R.drawable.ui_progress_exp, R.string.status_exp);
|
||||
|
||||
res = getResources();
|
||||
// levelupDrawable = new LayerDrawable(new Drawable[] {
|
||||
// new BitmapDrawable(res, world.tileManager.preloadedTiles.getBitmap(player.iconID))
|
||||
// ,new BitmapDrawable(res, world.tileManager.preloadedTiles.getBitmap(TileManager.iconID_moveselect))
|
||||
// });
|
||||
|
||||
updateStatus();
|
||||
updateIcon(player.canLevelup());
|
||||
}
|
||||
|
||||
public void registerToolboxViews(ToolboxView toolbox, QuickitemView quickitemView) {
|
||||
toolbox.registerToolboxViews((ImageButton) findViewById(R.id.toolbox_toggle), quickitemView);
|
||||
}
|
||||
|
||||
public void updateStatus() {
|
||||
updateHealth();
|
||||
updateExperience();
|
||||
}
|
||||
|
||||
public void subscribe() {
|
||||
controllers.actorStatsController.actorStatsListeners.add(this);
|
||||
controllers.actorStatsController.playerStatsListeners.add(this);
|
||||
}
|
||||
public void unsubscribe() {
|
||||
controllers.actorStatsController.playerStatsListeners.remove(this);
|
||||
controllers.actorStatsController.actorStatsListeners.remove(this);
|
||||
}
|
||||
|
||||
private void updateHealth() {
|
||||
healthBar.update(player.getMaxHP(), player.getCurrentHP());
|
||||
}
|
||||
private void updateExperience() {
|
||||
expBar.update(player.getMaxLevelExperience(), player.getCurrentLevelExperience());
|
||||
boolean canLevelUp = player.canLevelup();
|
||||
if (showingLevelup != canLevelUp) {
|
||||
updateIcon(canLevelUp);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateIcon(boolean canLevelUp) {
|
||||
showingLevelup = canLevelUp;
|
||||
if (canLevelUp) {
|
||||
world.tileManager.setImageViewTileWithOverlay(res, heroImage, TileManager.iconID_moveselect, world.tileManager.preloadedTiles.getBitmap(player.iconID), true);
|
||||
} else {
|
||||
world.tileManager.setImageViewTile(res, heroImage, player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorHealthChanged(Actor actor) {
|
||||
if (actor == player) updateHealth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorAPChanged(Actor actor) { }
|
||||
|
||||
@Override
|
||||
public void onActorAttackCostChanged(Actor actor, int newAttackCost) { }
|
||||
|
||||
@Override
|
||||
public void onActorMoveCostChanged(Actor actor, int newMoveCost) { }
|
||||
|
||||
@Override
|
||||
public void onPlayerReequipCostChanged(Player actor, int newAttackCost) {}
|
||||
|
||||
@Override
|
||||
public void onPlayerUseCostChanged(Player actor, int newMoveCost) {}
|
||||
|
||||
@Override
|
||||
public void onPlayerExperienceChanged(Player p) {
|
||||
updateExperience();
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.AndorsTrail.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.activity.HeroinfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.listeners.ActorStatsListener;
|
||||
import com.gpl.rpg.AndorsTrail.controller.listeners.PlayerStatsListener;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Actor;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
|
||||
|
||||
public final class StatusView extends RelativeLayout implements PlayerStatsListener, ActorStatsListener {
|
||||
|
||||
private final ControllerContext controllers;
|
||||
private final WorldContext world;
|
||||
private final Player player;
|
||||
private final Resources res;
|
||||
|
||||
private final RangeBar healthBar;
|
||||
private final RangeBar expBar;
|
||||
private final ImageButton heroImage;
|
||||
private boolean showingLevelup;
|
||||
// private final Drawable levelupDrawable;
|
||||
|
||||
public StatusView(final Context context, AttributeSet attr) {
|
||||
super(context, attr);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivityContext(context);
|
||||
this.controllers = app.getControllerContext();
|
||||
this.world = app.getWorld();
|
||||
this.player = world.model.player;
|
||||
|
||||
setFocusable(false);
|
||||
inflate(context, R.layout.statusview, this);
|
||||
this.setBackgroundResource(R.drawable.ui_gradientshape);
|
||||
|
||||
heroImage = (ImageButton) findViewById(R.id.status_image);
|
||||
showingLevelup = true;
|
||||
|
||||
heroImage.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
context.startActivity(new Intent(context, HeroinfoActivity.class));
|
||||
}
|
||||
});
|
||||
healthBar = (RangeBar) findViewById(R.id.statusview_health);
|
||||
healthBar.init(R.drawable.ui_progress_health, R.string.status_hp);
|
||||
|
||||
expBar = (RangeBar) findViewById(R.id.statusview_exp);
|
||||
expBar.init(R.drawable.ui_progress_exp, R.string.status_exp);
|
||||
|
||||
res = getResources();
|
||||
// levelupDrawable = new LayerDrawable(new Drawable[] {
|
||||
// new BitmapDrawable(res, world.tileManager.preloadedTiles.getBitmap(player.iconID))
|
||||
// ,new BitmapDrawable(res, world.tileManager.preloadedTiles.getBitmap(TileManager.iconID_moveselect))
|
||||
// });
|
||||
|
||||
updateStatus();
|
||||
updateIcon(player.canLevelup());
|
||||
}
|
||||
|
||||
public void registerToolboxViews(ToolboxView toolbox, QuickitemView quickitemView) {
|
||||
toolbox.registerToolboxViews((ImageButton) findViewById(R.id.toolbox_toggle), quickitemView);
|
||||
}
|
||||
|
||||
public void updateStatus() {
|
||||
updateHealth();
|
||||
updateExperience();
|
||||
}
|
||||
|
||||
public void subscribe() {
|
||||
controllers.actorStatsController.actorStatsListeners.add(this);
|
||||
controllers.actorStatsController.playerStatsListeners.add(this);
|
||||
}
|
||||
public void unsubscribe() {
|
||||
controllers.actorStatsController.playerStatsListeners.remove(this);
|
||||
controllers.actorStatsController.actorStatsListeners.remove(this);
|
||||
}
|
||||
|
||||
private void updateHealth() {
|
||||
healthBar.update(player.getMaxHP(), player.getCurrentHP());
|
||||
}
|
||||
private void updateExperience() {
|
||||
expBar.update(player.getMaxLevelExperience(), player.getCurrentLevelExperience());
|
||||
boolean canLevelUp = player.canLevelup();
|
||||
if (showingLevelup != canLevelUp) {
|
||||
updateIcon(canLevelUp);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateIcon(boolean canLevelUp) {
|
||||
showingLevelup = canLevelUp;
|
||||
if (canLevelUp) {
|
||||
world.tileManager.setImageViewTileWithOverlay(res, heroImage, TileManager.iconID_moveselect, world.tileManager.preloadedTiles.getBitmap(player.iconID), true);
|
||||
} else {
|
||||
world.tileManager.setImageViewTile(res, heroImage, player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorHealthChanged(Actor actor) {
|
||||
if (actor == player) updateHealth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActorAPChanged(Actor actor) { }
|
||||
|
||||
@Override
|
||||
public void onActorAttackCostChanged(Actor actor, int newAttackCost) { }
|
||||
|
||||
@Override
|
||||
public void onActorMoveCostChanged(Actor actor, int newMoveCost) { }
|
||||
|
||||
@Override
|
||||
public void onPlayerReequipCostChanged(Player actor, int newAttackCost) {}
|
||||
|
||||
@Override
|
||||
public void onPlayerUseCostChanged(Player actor, int newMoveCost) {}
|
||||
|
||||
@Override
|
||||
public void onPlayerExperienceChanged(Player p) {
|
||||
updateExperience();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user