mirror of
https://github.com/OMGeeky/andors-trail.git
synced 2026-01-18 17:44:22 +01:00
Merge branch 'worldmap'
Conflicts: AndorsTrail/res/values/strings.xml AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/CombatController.java AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/StatusView.java
This commit is contained in:
@@ -62,6 +62,7 @@
|
||||
<activity android:name=".activity.HeroinfoActivity_Stats" />
|
||||
<activity android:name=".activity.HeroinfoActivity_Skills" />
|
||||
<activity android:name=".activity.HeroinfoActivity_Inventory" />
|
||||
<activity android:name=".activity.DisplayWorldMapActivity" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
||||
8
AndorsTrail/res/anim/hidetoolbox.xml
Normal file
8
AndorsTrail/res/anim/hidetoolbox.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<translate
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:interpolator="@android:anim/accelerate_interpolator"
|
||||
android:duration="300"
|
||||
android:fromYDelta="0%"
|
||||
android:toYDelta="100%"
|
||||
/>
|
||||
8
AndorsTrail/res/anim/showtoolbox.xml
Normal file
8
AndorsTrail/res/anim/showtoolbox.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<translate
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:duration="300"
|
||||
android:fromYDelta="100%"
|
||||
android:toYDelta="0%"
|
||||
/>
|
||||
BIN
AndorsTrail/res/drawable/ui_icon_map.png
Normal file
BIN
AndorsTrail/res/drawable/ui_icon_map.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 365 B |
44
AndorsTrail/res/layout/displayworldmap.xml
Normal file
44
AndorsTrail/res/layout/displayworldmap.xml
Normal file
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:background="@drawable/ui_gradientshape"
|
||||
android:padding="@dimen/boxshape_margin"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/menu_button_worldmap"
|
||||
style="@style/textWithIcon"
|
||||
android:textSize="@dimen/titletext"
|
||||
android:drawableLeft="@android:drawable/ic_dialog_map"
|
||||
|
||||
/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/displayworldmap_close"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="?android:attr/buttonStyleSmall"
|
||||
android:text="@string/dialog_close"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<WebView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/displayworldmap_webview"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -27,6 +27,15 @@
|
||||
android:layout_alignParentTop="true"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<com.gpl.rpg.AndorsTrail.view.ToolboxView
|
||||
android:id="@+id/main_toolboxview"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@id/main_statusview"
|
||||
android:layout_alignParentRight="true"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<com.gpl.rpg.AndorsTrail.view.MainView
|
||||
android:id="@+id/main_mainview"
|
||||
@@ -51,7 +60,7 @@
|
||||
android:shadowDx="1"
|
||||
android:shadowDy="1"
|
||||
android:shadowRadius="1"
|
||||
android:shadowColor="#000"
|
||||
android:shadowColor="#000"
|
||||
/>
|
||||
|
||||
<RelativeLayout
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/quickitem_toggle"
|
||||
android:id="@+id/toolbox_toggle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
@@ -27,7 +27,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toRightOf="@id/status_image"
|
||||
android:layout_toLeftOf="@id/quickitem_toggle"
|
||||
android:layout_toLeftOf="@id/toolbox_toggle"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<com.gpl.rpg.AndorsTrail.view.RangeBar
|
||||
|
||||
20
AndorsTrail/res/layout/toolboxview.xml
Normal file
20
AndorsTrail/res/layout/toolboxview.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/ui_gradientshape"
|
||||
>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/toolbox_map"
|
||||
style="@style/toolboxButton"
|
||||
android:src="@drawable/ui_icon_map"
|
||||
/>
|
||||
<ImageButton
|
||||
android:id="@+id/toolbox_quickitems"
|
||||
style="@style/toolboxButton"
|
||||
android:src="@drawable/ui_icon_equipment"
|
||||
/>
|
||||
</LinearLayout>
|
||||
@@ -507,5 +507,9 @@
|
||||
<string name="preferences_ui_category">Interface</string>
|
||||
<string name="preferences_ui_enable_animations_title">Enable animations</string>
|
||||
<string name="preferences_ui_enable_animations">Show animations for various interface elements, such as the combat bar.</string>
|
||||
<string name="menu_button_worldmap">Map</string>
|
||||
<string name="menu_button_worldmap_failed">Map cannot be displayed.</string>
|
||||
<string name="display_worldmap_not_available">The map cannot be displayed from this location.</string>
|
||||
<string name="display_worldmap_title">Map</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="translucent_black">#80000000</color>
|
||||
<color name="displayworldmap_background">#423921</color>
|
||||
</resources>
|
||||
|
||||
@@ -29,4 +29,9 @@
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">@dimen/smalltext_buttonheight</item>
|
||||
</style>
|
||||
|
||||
<style name="toolboxButton">
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
</style>
|
||||
</resources>
|
||||
45
AndorsTrail/res/values/worldmap_template.xml
Normal file
45
AndorsTrail/res/values/worldmap_template.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<resources><string name="worldmap_template">"<![CDATA[<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
|
||||
<html xmlns=\"http://www.w3.org/1999/xhtml\">
|
||||
<head>
|
||||
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />
|
||||
<title></title>
|
||||
<style type=\"text/css\">
|
||||
#playerPosition { position: absolute; z-index: 3; font-size: 19pt; color: red; text-shadow: rgba(0, 0, 0, 1) 2px 2px 2px; }
|
||||
img { z-index: 1; position: absolute; }
|
||||
.namedarea { position: absolute; z-index: 2; font-size: 16pt; text-shadow: black 0.1em 0.1em 0.2em; text-align: center; }
|
||||
.namedarea span { display: inline-block; vertical-align: middle; line-height: 1em; }
|
||||
.settlement { color: white; }
|
||||
.other { color: #cccccc; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id=\"maps\">
|
||||
|
||||
{{maps}}
|
||||
{{areas}}
|
||||
|
||||
<div id=\"playerPosition\">x</div>
|
||||
</div>
|
||||
|
||||
<script type=\"text/javascript\">
|
||||
var player = document.getElementById(\"playerPosition\");
|
||||
var params = window.location.search.substring(1);
|
||||
if (params) {
|
||||
var pos = params.split(\",\");
|
||||
var x = parseInt(pos[0])-{{offsetx}};
|
||||
var y = parseInt(pos[1])-{{offsety}};
|
||||
player.style.top = y + \"px\";
|
||||
player.style.left = x + \"px\";
|
||||
window.scrollTo(x-100, y-100);
|
||||
} else {
|
||||
player.style.display = \"none\";
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
]]></string></resources>
|
||||
259
AndorsTrail/res/xml/worldmap.xml
Normal file
259
AndorsTrail/res/xml/worldmap.xml
Normal file
@@ -0,0 +1,259 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<worldmap>
|
||||
<segment id="waytobrimhavencave" x="319" y="270">
|
||||
<map id="waytobrimhavencave0" x="350" y="270" />
|
||||
<map id="waytobrimhavencave1" x="381" y="278" />
|
||||
<map id="waytobrimhavencave2" x="412" y="278" />
|
||||
<map id="waytobrimhavencave3" x="443" y="278" />
|
||||
<map id="waytobrimhavencave4" x="319" y="278" />
|
||||
<map id="waytobrimhavencave1a" x="350" y="299" />
|
||||
</segment>
|
||||
<segment id="bwcave1" x="69" y="233">
|
||||
<map id="blackwater_mountain39" x="118" y="233" />
|
||||
<map id="blackwater_mountain19" x="86" y="240" />
|
||||
<map id="blackwater_mountain17" x="69" y="264" />
|
||||
<map id="blackwater_mountain18" x="70" y="241" />
|
||||
<map id="blackwater_mountain20" x="97" y="239" />
|
||||
</segment>
|
||||
<segment id="flagstone" x="124" y="491">
|
||||
<map id="flagstone2" x="124" y="491" />
|
||||
<map id="flagstone3" x="130" y="522" />
|
||||
<map id="flagstone4" x="151" y="518" />
|
||||
</segment>
|
||||
<segment id="world1" x="11" y="0">
|
||||
<map id="lodar21" x="374" y="373" />
|
||||
<map id="lodar20" x="374" y="342" />
|
||||
<map id="waytominingtown1a" x="375" y="415" />
|
||||
<map id="waytobrimhaven2" x="334" y="245" />
|
||||
<map id="waytobrimhaven3" x="365" y="247" />
|
||||
<map id="waytobrimhaven0" x="269" y="259" />
|
||||
<map id="waytobrimhaven1" x="303" y="255" />
|
||||
<map id="roadtocarntower1" x="117" y="308" />
|
||||
<map id="roadtocarntower0" x="148" y="308" />
|
||||
<map id="woodsettlement0" x="202" y="375" />
|
||||
<map id="roadtocarntower2" x="86" y="308" />
|
||||
<map id="lodar8" x="312" y="330" />
|
||||
<map id="lodar9" x="343" y="285" />
|
||||
<map id="lodar6" x="262" y="330" />
|
||||
<map id="lodar7" x="281" y="330" />
|
||||
<map id="lodar4" x="312" y="304" />
|
||||
<map id="lodar5" x="281" y="314" />
|
||||
<map id="fields9" x="117" y="292" />
|
||||
<map id="lodar2" x="281" y="283" />
|
||||
<map id="lodar3" x="312" y="283" />
|
||||
<map id="lodar10" x="374" y="285" />
|
||||
<map id="waterway9" x="551" y="228" />
|
||||
<map id="fields6" x="179" y="232" />
|
||||
<map id="waterway8" x="520" y="228" />
|
||||
<map id="fields5" x="148" y="230" />
|
||||
<map id="lodar12" x="374" y="311" />
|
||||
<map id="fields8" x="148" y="292" />
|
||||
<map id="lodar11" x="343" y="311" />
|
||||
<map id="fields7" x="210" y="236" />
|
||||
<map id="lodar14" x="293" y="361" />
|
||||
<map id="fields2" x="148" y="261" />
|
||||
<map id="lodar13" x="262" y="361" />
|
||||
<map id="fields1" x="179" y="261" />
|
||||
<map id="lodar16" x="313" y="361" />
|
||||
<map id="fields4" x="210" y="261" />
|
||||
<map id="lodar15" x="293" y="392" />
|
||||
<map id="fields3" x="127" y="271" />
|
||||
<map id="lodar18" x="343" y="342" />
|
||||
<map id="lodar17" x="313" y="392" />
|
||||
<map id="fields0" x="179" y="292" />
|
||||
<map id="lodar19" x="343" y="373" />
|
||||
<map id="wild14_clearing" x="318" y="433" />
|
||||
<map id="fallhaven_nw" x="210" y="390" area="fallhaven" />
|
||||
<map id="waterway12" x="458" y="228" />
|
||||
<map id="waterway11" x="582" y="228" />
|
||||
<map id="mountainlake10a" x="725" y="31" />
|
||||
<map id="waterway14" x="404" y="166" />
|
||||
<map id="waterway13" x="489" y="228" />
|
||||
<map id="blackwater_mountain4" x="14" y="411" />
|
||||
<map id="waterway15" x="412" y="197" />
|
||||
<map id="waterway11_east" x="613" y="229" />
|
||||
<map id="fallhaven_ne" x="241" y="390" area="fallhaven" />
|
||||
<map id="waterway10" x="551" y="259" />
|
||||
<map id="wild3" x="173" y="394" />
|
||||
<map id="wild2" x="152" y="394" />
|
||||
<map id="wild5" x="159" y="415" />
|
||||
<map id="wild4" x="201" y="359" />
|
||||
<map id="wild7" x="147" y="467" />
|
||||
<map id="wild6" x="155" y="436" />
|
||||
<map id="wild9" x="186" y="450" />
|
||||
<map id="wild8" x="126" y="476" />
|
||||
<map id="blackwater_mountain0" x="53" y="477" />
|
||||
<map id="blackwater_mountain1" x="11" y="449" />
|
||||
<map id="roadbeforecrossroads" x="210" y="326" />
|
||||
<map id="blackwater_mountain2" x="11" y="438" />
|
||||
<map id="blackwater_mountain3" x="14" y="427" />
|
||||
<map id="wild1" x="179" y="361" />
|
||||
<map id="wild0" x="179" y="339" />
|
||||
<map id="wild17" x="32" y="463" />
|
||||
<map id="wild15" x="335" y="456" />
|
||||
<map id="roadbeforecrossroads8" x="335" y="428" />
|
||||
<map id="mountainlake13a" x="649" y="50" />
|
||||
<map id="wild16" x="74" y="477" />
|
||||
<map id="roadbeforecrossroads9" x="356" y="428" />
|
||||
<map id="wild13" x="293" y="444" />
|
||||
<map id="roadbeforecrossroads6" x="293" y="413" />
|
||||
<map id="flagstone0" x="95" y="477" area="flagstone" />
|
||||
<map id="wild14" x="314" y="449" />
|
||||
<map id="roadbeforecrossroads7" x="314" y="428" />
|
||||
<map id="wild11" x="238" y="442" />
|
||||
<map id="roadbeforecrossroads4" x="272" y="390" />
|
||||
<map id="wild12" x="272" y="434" />
|
||||
<map id="roadbeforecrossroads5" x="272" y="411" />
|
||||
<map id="roadbeforecrossroads2" x="232" y="356" />
|
||||
<map id="wild10" x="217" y="442" />
|
||||
<map id="roadbeforecrossroads3" x="262" y="374" />
|
||||
<map id="waterway6" x="396" y="228" />
|
||||
<map id="waterway7" x="427" y="228" />
|
||||
<map id="waterway4" x="373" y="166" />
|
||||
<map id="waterway5" x="381" y="197" />
|
||||
<map id="waterway2" x="342" y="158" />
|
||||
<map id="waterway3" x="311" y="158" />
|
||||
<map id="waterway0" x="280" y="200" />
|
||||
<map id="waterway1" x="311" y="179" />
|
||||
<map id="road4_gargoylecave" x="425" y="446" />
|
||||
<map id="lodar1" x="232" y="318" />
|
||||
<map id="lodar0" x="250" y="299" />
|
||||
<map id="waytomountaincave1" x="622" y="285" />
|
||||
<map id="waytomountaincave0" x="628" y="255" />
|
||||
<map id="waytomountaincave2" x="623" y="305" />
|
||||
<map id="wild11_clearing" x="241" y="463" />
|
||||
<map id="fallhaven_sw" x="210" y="421" area="fallhaven" />
|
||||
<map id="waterwayextention" x="343" y="189" />
|
||||
<map id="mountainlake3" x="757" y="128" />
|
||||
<map id="waytominingtown0" x="314" y="412" />
|
||||
<map id="mountainlake2" x="736" y="141" />
|
||||
<map id="waytominingtown1" x="344" y="397" />
|
||||
<map id="mountainlake1" x="705" y="128" />
|
||||
<map id="waytominingtown2" x="375" y="394" />
|
||||
<map id="mountainlake0" x="703" y="159" />
|
||||
<map id="waytominingtown3" x="395" y="386" />
|
||||
<map id="mountainlake7" x="801" y="53" />
|
||||
<map id="mountainlake6" x="796" y="74" />
|
||||
<map id="mountainlake5" x="788" y="104" />
|
||||
<map id="mountainlake4" x="762" y="111" />
|
||||
<map id="mountainlake9" x="764" y="0" />
|
||||
<map id="vilegard_sw" x="349" y="513" />
|
||||
<map id="mountainlake8" x="780" y="31" />
|
||||
<map id="gapfiller1" x="259" y="442" />
|
||||
<map id="lostmine0" x="426" y="369" />
|
||||
<map id="gapfiller3" x="179" y="383" />
|
||||
<map id="fallhaven_se" x="241" y="421" area="fallhaven" />
|
||||
<map id="gapfiller4" x="194" y="390" />
|
||||
<map id="fields10" x="96" y="292" />
|
||||
<map id="waytolake0" x="650" y="266" />
|
||||
<map id="fields11" x="238" y="226" />
|
||||
<map id="fields12" x="259" y="222" />
|
||||
<map id="vilegard_n" x="360" y="479" area="vilegard" />
|
||||
<map id="waytolostmine0" x="395" y="355" />
|
||||
<map id="roadbeforecrossroads1" x="232" y="330" />
|
||||
<map id="waytolake3" x="673" y="208" />
|
||||
<map id="vilegard_s" x="360" y="500" area="vilegard" />
|
||||
<map id="waytolake1" x="671" y="255" />
|
||||
<map id="waytolake2" x="671" y="229" />
|
||||
<map id="waytolostmine2" x="426" y="309" />
|
||||
<map id="waytolostmine1" x="395" y="327" />
|
||||
<map id="waytolostmine3" x="426" y="338" />
|
||||
<map id="mountainlake13" x="641" y="20" />
|
||||
<map id="mountainlake12" x="672" y="8" />
|
||||
<map id="mountainlake11" x="702" y="4" />
|
||||
<map id="mountainlake10" x="733" y="0" />
|
||||
<map id="loneford2" x="238" y="259" area="loneford" />
|
||||
<map id="loneford1" x="210" y="286" />
|
||||
<map id="crossglen" x="148" y="363" area="crossglen" />
|
||||
<map id="remgard1" x="674" y="83" area="remgard" />
|
||||
<map id="remgard0" x="643" y="76" area="remgard" />
|
||||
<map id="remgard3" x="653" y="107" area="remgard" />
|
||||
<map id="remgard2" x="674" y="114" area="remgard" />
|
||||
<map id="remgard4" x="622" y="107" area="remgard" />
|
||||
<map id="road1" x="356" y="453" area="fflask" />
|
||||
<map id="crossroads" x="179" y="308" area="crossroads" />
|
||||
<map id="road3" x="403" y="467" />
|
||||
<map id="road2" x="382" y="463" />
|
||||
<map id="road5" x="455" y="470" />
|
||||
<map id="road4" x="429" y="462" />
|
||||
<namedarea id="crossglen" name="Crossglen" type="settlement"/>
|
||||
<namedarea id="loneford" name="Loneford" type="settlement"/>
|
||||
<namedarea id="flagstone" name="Flagstone Prison" type="other"/>
|
||||
<namedarea id="fallhaven" name="Fallhaven" type="settlement"/>
|
||||
<namedarea id="fflask" name="Foaming Flask Tavern" type="other"/>
|
||||
<namedarea id="crossroads" name="Crossroads Guardhouse" type="other"/>
|
||||
<namedarea id="remgard" name="Remgard" type="settlement"/>
|
||||
<namedarea id="vilegard" name="Vilegard" type="settlement"/>
|
||||
</segment>
|
||||
<segment id="blackwater" x="10" y="214">
|
||||
<map id="blackwater_mountain15" x="81" y="302" />
|
||||
<map id="blackwater_mountain16" x="83" y="271" />
|
||||
<map id="blackwater_mountain40" x="77" y="354" />
|
||||
<map id="blackwater_mountain32" x="128" y="214" />
|
||||
<map id="blackwater_mountain14" x="60" y="333" />
|
||||
<map id="blackwater_mountain11" x="39" y="302" area="prim" />
|
||||
<map id="blackwater_mountain30" x="130" y="245" />
|
||||
<map id="blackwater_mountain12" x="10" y="323" />
|
||||
<map id="blackwater_mountain10" x="39" y="333" />
|
||||
<namedarea id="prim" name="Prim" type="settlement"/>
|
||||
</segment>
|
||||
<segment id="pwcave" x="288" y="42">
|
||||
<map id="pwcave4" x="319" y="99" />
|
||||
<map id="pwcave2a" x="292" y="42" />
|
||||
<map id="pwcave2" x="288" y="68" />
|
||||
<map id="pwcave3" x="319" y="68" />
|
||||
<map id="pwcave0" x="308" y="130" />
|
||||
<map id="pwcave1" x="288" y="99" />
|
||||
</segment>
|
||||
<segment id="snakecave" x="115" y="353">
|
||||
<map id="snakecave2" x="123" y="384" />
|
||||
<map id="snakecave1" x="144" y="384" />
|
||||
<map id="snakecave3" x="115" y="353" />
|
||||
</segment>
|
||||
<segment id="bwentry" x="14" y="350">
|
||||
<map id="blackwater_mountain7" x="34" y="374" />
|
||||
<map id="blackwater_mountain6" x="23" y="388" />
|
||||
<map id="blackwater_mountain5" x="14" y="399" />
|
||||
<map id="blackwater_mountain9" x="42" y="350" />
|
||||
</segment>
|
||||
<segment id="gargoylecave" x="395" y="411">
|
||||
<map id="gargoylecave3" x="395" y="411" />
|
||||
<map id="gargoylecave4" x="411" y="423" />
|
||||
<map id="gargoylecave1" x="420" y="432" />
|
||||
<map id="gargoylecave2" x="399" y="432" />
|
||||
</segment>
|
||||
<segment id="lodarcave" x="309" y="283">
|
||||
<map id="lodarcave4a" x="361" y="366" />
|
||||
<map id="lodarcave7" x="373" y="420" />
|
||||
<map id="lodarcave5" x="348" y="387" />
|
||||
<map id="lodarcave6" x="352" y="408" />
|
||||
<map id="lodarcave3" x="323" y="335" />
|
||||
<map id="lodarcave4" x="335" y="366" />
|
||||
<map id="lodarcave1" x="309" y="283" />
|
||||
<map id="lodarcave2" x="319" y="314" />
|
||||
</segment>
|
||||
<segment id="mountaincave" x="600" y="245">
|
||||
<map id="mountaincave3" x="600" y="245" />
|
||||
<map id="mountaincave2" x="603" y="266" />
|
||||
<map id="mountaincave1" x="615" y="297" />
|
||||
<map id="mountaincave0" x="636" y="297" />
|
||||
</segment>
|
||||
<segment id="bwcave2" x="105" y="208">
|
||||
<map id="blackwater_mountain37" x="136" y="219" />
|
||||
<map id="blackwater_mountain38" x="105" y="225" />
|
||||
<map id="blackwater_mountain36" x="134" y="208" />
|
||||
</segment>
|
||||
<segment id="lodar5cave" x="284" y="322">
|
||||
<map id="lodar5cave1" x="305" y="352" />
|
||||
<map id="lodar5cave0" x="297" y="322" />
|
||||
<map id="lodar5cave2" x="284" y="376" />
|
||||
</segment>
|
||||
<segment id="bwsettlement" x="113" y="166">
|
||||
<map id="blackwater_mountain51" x="138" y="243" />
|
||||
<map id="blackwater_mountain52" x="138" y="212" />
|
||||
<map id="blackwater_mountain43" x="150" y="166" />
|
||||
<map id="blackwater_mountain44" x="129" y="191" />
|
||||
<map id="blackwater_mountain45" x="113" y="205" />
|
||||
<map id="blackwater_mountain46" x="116" y="197" />
|
||||
</segment>
|
||||
</worldmap>
|
||||
@@ -16,7 +16,7 @@ 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_DEBUGBUTTONS = true;
|
||||
public static final boolean DEVELOPMENT_VALIDATEDATA = false;
|
||||
public static final boolean DEVELOPMENT_DEBUGMESSAGES = false;
|
||||
public static final boolean DEVELOPMENT_INCOMPATIBLE_SAVEGAMES = DEVELOPMENT_DEBUGRESOURCES;
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
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.WorldMapSegment;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment.WorldMapSegmentMap;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
|
||||
public class DisplayWorldMapActivity extends Activity {
|
||||
private WorldContext world;
|
||||
|
||||
private WebView displayworldmap_webview;
|
||||
private String worldMapSegmentName;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
if (!app.isInitialized()) { finish(); return; }
|
||||
this.world = app.world;
|
||||
|
||||
AndorsTrailApplication.setWindowParameters(this, app.preferences);
|
||||
|
||||
setContentView(R.layout.displayworldmap);
|
||||
|
||||
displayworldmap_webview = (WebView) findViewById(R.id.displayworldmap_webview);
|
||||
displayworldmap_webview.setBackgroundColor(getResources().getColor(R.color.displayworldmap_background));
|
||||
displayworldmap_webview.getSettings().setBuiltInZoomControls(true);
|
||||
enableJavascript();
|
||||
|
||||
Button b = (Button) findViewById(R.id.displayworldmap_close);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
DisplayWorldMapActivity.this.finish();
|
||||
}
|
||||
});
|
||||
|
||||
worldMapSegmentName = getIntent().getStringExtra("worldMapSegmentName");
|
||||
}
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
public void enableJavascript() {
|
||||
displayworldmap_webview.getSettings().setJavaScriptEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
update();
|
||||
}
|
||||
|
||||
private void update() {
|
||||
File worldmap = WorldMapController.getCombinedWorldMapFile(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);
|
||||
WorldMapSegmentMap map = segment.maps.get(world.model.currentMap.name);
|
||||
if (map == null) this.finish();
|
||||
|
||||
String url = "file://" + worldmap.getAbsolutePath() + "?"
|
||||
+ (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);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
import com.gpl.rpg.AndorsTrail.view.CombatView;
|
||||
import com.gpl.rpg.AndorsTrail.view.DisplayActiveActorConditionIcons;
|
||||
import com.gpl.rpg.AndorsTrail.view.MainView;
|
||||
import com.gpl.rpg.AndorsTrail.view.ToolboxView;
|
||||
import com.gpl.rpg.AndorsTrail.view.VirtualDpadView;
|
||||
import com.gpl.rpg.AndorsTrail.view.QuickButton.QuickButtonContextMenuInfo;
|
||||
import com.gpl.rpg.AndorsTrail.view.QuickitemView;
|
||||
@@ -40,7 +41,6 @@ import android.widget.Toast;
|
||||
|
||||
public final class MainActivity extends Activity {
|
||||
|
||||
public static final int INTENTREQUEST_HEROINFO = 1;
|
||||
public static final int INTENTREQUEST_MONSTERENCOUNTER = 2;
|
||||
public static final int INTENTREQUEST_ITEMINFO = 3;
|
||||
public static final int INTENTREQUEST_CONVERSATION = 4;
|
||||
@@ -61,6 +61,7 @@ public final class MainActivity extends Activity {
|
||||
public CombatView combatview;
|
||||
public QuickitemView quickitemview;
|
||||
private DisplayActiveActorConditionIcons activeConditions;
|
||||
private ToolboxView toolboxview;
|
||||
private VirtualDpadView dpad;
|
||||
|
||||
private static final int NUM_MESSAGES = 3;
|
||||
@@ -87,6 +88,8 @@ public final class MainActivity extends Activity {
|
||||
quickitemview = (QuickitemView) findViewById(R.id.main_quickitemview);
|
||||
activeConditions = new DisplayActiveActorConditionIcons(app.preferences, world.tileManager, this, (RelativeLayout) findViewById(R.id.statusview_activeconditions));
|
||||
dpad = (VirtualDpadView) findViewById(R.id.main_virtual_dpad);
|
||||
toolboxview = (ToolboxView) findViewById(R.id.main_toolboxview);
|
||||
statusview.registerToolboxViews(toolboxview, quickitemview);
|
||||
|
||||
statusText = (TextView) findViewById(R.id.statusview_statustext);
|
||||
statusText.setOnClickListener(new OnClickListener() {
|
||||
@@ -97,22 +100,25 @@ public final class MainActivity extends Activity {
|
||||
});
|
||||
clearMessages();
|
||||
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGBUTTONS) new DebugInterface(view).addDebugButtons();
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGBUTTONS) new DebugInterface(view).addDebugButtons();
|
||||
|
||||
quickitemview.setVisibility(View.GONE);
|
||||
quickitemview.registerForContextMenu(this);
|
||||
quickitemview.refreshQuickitems();
|
||||
|
||||
dpad.updateVisibility(app.preferences);
|
||||
|
||||
// Define which views are in front of each other.
|
||||
dpad.bringToFront();
|
||||
quickitemview.bringToFront();
|
||||
toolboxview.bringToFront();
|
||||
combatview.bringToFront();
|
||||
statusview.bringToFront();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
switch (requestCode) {
|
||||
case INTENTREQUEST_HEROINFO:
|
||||
updateStatus();
|
||||
break;
|
||||
case INTENTREQUEST_MONSTERENCOUNTER:
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
view.combatController.enterCombat(CombatController.BEGIN_TURN_PLAYER);
|
||||
@@ -264,6 +270,7 @@ public final class MainActivity extends Activity {
|
||||
statusview.updateStatus();
|
||||
quickitemview.refreshQuickitems();
|
||||
combatview.updateStatus();
|
||||
toolboxview.updateIcons();
|
||||
}
|
||||
|
||||
public void redrawAll(int why) {
|
||||
@@ -306,5 +313,4 @@ public final class MainActivity extends Activity {
|
||||
}
|
||||
t.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,6 +35,9 @@ public final class Constants {
|
||||
public static final String PREFERENCE_MODEL_LASTRUNVERSION = "lastversion";
|
||||
public static final String FILENAME_SAVEGAME_QUICKSAVE = "savegame";
|
||||
public static final String FILENAME_SAVEGAME_DIRECTORY = "andors-trail";
|
||||
public static final String FILENAME_WORLDMAP_DIRECTORY = "worldmap";
|
||||
public static final String FILENAME_WORLDMAP_HTMLFILE_PREFIX = "worldmap_";
|
||||
public static final String FILENAME_WORLDMAP_HTMLFILE_SUFFIX = ".html";
|
||||
public static final String FILENAME_SAVEGAME_FILENAME_PREFIX = "savegame";
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.gpl.rpg.AndorsTrail.controller;
|
||||
import com.gpl.rpg.AndorsTrail.context.ViewContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.ModelContainer;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.TimedMessageTask;
|
||||
import com.gpl.rpg.AndorsTrail.view.MainView;
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@ package com.gpl.rpg.AndorsTrail.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.Dialogs;
|
||||
import com.gpl.rpg.AndorsTrail.context.ViewContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
@@ -236,17 +234,6 @@ public final class ItemController {
|
||||
model.player.inventory.quickitem[quickSlotId] = itemType;
|
||||
view.mainActivity.updateStatus();
|
||||
}
|
||||
|
||||
public void toggleQuickItemView() {
|
||||
if (view.mainActivity.quickitemview.getVisibility()==View.VISIBLE){
|
||||
view.mainActivity.quickitemview.setVisibility(View.GONE);
|
||||
view.mainActivity.statusview.updateQuickItemImage(false);
|
||||
} else {
|
||||
view.mainActivity.quickitemview.setVisibility(View.VISIBLE);
|
||||
view.mainActivity.quickitemview.bringToFront();
|
||||
view.mainActivity.statusview.updateQuickItemImage(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static void correctActorConditionsFromItemsPre0611b1(Player player, String conditionTypeID, WorldContext world, String itemTypeIDWithCondition) {
|
||||
if (!player.hasCondition(conditionTypeID)) return;
|
||||
|
||||
@@ -272,6 +272,8 @@ public final class MovementController implements TimedMessageTask.Callback {
|
||||
world.model.currentTileMap = mapTiles;
|
||||
world.tileManager.currentMapTiles = cachedTiles;
|
||||
world.tileManager.cacheAdjacentMaps(res, world, nextMap);
|
||||
|
||||
WorldMapController.updateWorldMap(world, nextMap, mapTiles, cachedTiles, res);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,280 @@
|
||||
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.HashSet;
|
||||
|
||||
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.os.Environment;
|
||||
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.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 {
|
||||
|
||||
public static int WORLDMAP_SCREENSHOT_TILESIZE = 8;
|
||||
public static int WORLDMAP_DISPLAY_TILESIZE = WORLDMAP_SCREENSHOT_TILESIZE;
|
||||
|
||||
public static void updateWorldMap(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(map, worldMapSegmentName)) return;
|
||||
|
||||
(new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... arg0) {
|
||||
final MapRenderer renderer = new MapRenderer(world, map, mapTiles, cachedTiles);
|
||||
try {
|
||||
updateCachedBitmap(map, renderer);
|
||||
updateWorldMapSegment(res, world, worldMapSegmentName);
|
||||
} catch (IOException e) {
|
||||
L.log("Error creating worldmap file for map " + map.name + " : " + e.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}).execute();
|
||||
}
|
||||
|
||||
private static boolean shouldUpdateWorldMap(PredefinedMap map, String worldMapSegmentName) {
|
||||
if (!map.visited) return true;
|
||||
File file = getFileForMap(map);
|
||||
if (!file.exists()) return true;
|
||||
|
||||
if (map.lastVisitVersion < AndorsTrailApplication.CURRENT_VERSION) return true;
|
||||
|
||||
file = getCombinedWorldMapFile(worldMapSegmentName);
|
||||
if (!file.exists()) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void updateCachedBitmap(PredefinedMap map, MapRenderer renderer) throws IOException {
|
||||
ensureWorldmapDirectoryExists();
|
||||
|
||||
File file = getFileForMap(map);
|
||||
if (file.exists()) {
|
||||
if (map.lastVisitVersion == AndorsTrailApplication.CURRENT_VERSION) return;
|
||||
}
|
||||
|
||||
Bitmap image = renderer.drawMap();
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
image.compress(Bitmap.CompressFormat.PNG, 70, fos);
|
||||
fos.flush();
|
||||
fos.close();
|
||||
image.recycle();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
drawMapLayer(canvas, mapTiles.layers[LayeredTileMap.LAYER_GROUND]);
|
||||
tryDrawMapLayer(canvas, LayeredTileMap.LAYER_OBJECTS);
|
||||
tryDrawMapLayer(canvas, LayeredTileMap.LAYER_ABOVE);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
private void tryDrawMapLayer(Canvas canvas, final int layerIndex) {
|
||||
if (mapTiles.layers.length > layerIndex) drawMapLayer(canvas, mapTiles.layers[layerIndex]);
|
||||
}
|
||||
|
||||
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) {
|
||||
canvas.drawBitmap(cachedTiles.bitmaps[tile], px, py, mPaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void ensureWorldmapDirectoryExists() throws IOException {
|
||||
File root = Environment.getExternalStorageDirectory();
|
||||
File dir = new File(root, 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 File getFileForMap(PredefinedMap map) { return getFileForMap(map.name); }
|
||||
public static File getFileForMap(String mapName) {
|
||||
return new File(getWorldmapDirectory(), mapName + ".png");
|
||||
}
|
||||
public static File getWorldmapDirectory() {
|
||||
File dir = Environment.getExternalStorageDirectory();
|
||||
dir = new File(dir, Constants.FILENAME_SAVEGAME_DIRECTORY);
|
||||
return new File(dir, Constants.FILENAME_WORLDMAP_DIRECTORY);
|
||||
}
|
||||
public static File getCombinedWorldMapFile(String segmentName) {
|
||||
return new File(getWorldmapDirectory(), Constants.FILENAME_WORLDMAP_HTMLFILE_PREFIX + segmentName + Constants.FILENAME_WORLDMAP_HTMLFILE_SUFFIX);
|
||||
}
|
||||
|
||||
private static boolean shouldDisplayMapOnWorldmap(String mapName) {
|
||||
File f = WorldMapController.getFileForMap(mapName);
|
||||
return f.exists();
|
||||
}
|
||||
private static String getWorldMapSegmentAsHtml(Resources res, WorldContext world, String segmentName) throws IOException {
|
||||
WorldMapSegment segment = world.maps.worldMapSegments.get(segmentName);
|
||||
|
||||
HashSet<String> displayedMapNames = new HashSet<String>();
|
||||
Coord offsetWorldmapTo = new Coord(999999, 999999);
|
||||
for (WorldMapSegmentMap map : segment.maps.values()) {
|
||||
if (!shouldDisplayMapOnWorldmap(map.mapName)) continue;
|
||||
|
||||
displayedMapNames.add(map.mapName);
|
||||
offsetWorldmapTo.x = Math.min(offsetWorldmapTo.x, map.worldPosition.x);
|
||||
offsetWorldmapTo.y = Math.min(offsetWorldmapTo.y, map.worldPosition.y);
|
||||
}
|
||||
|
||||
StringBuffer mapsAsHtml = new StringBuffer();
|
||||
for (WorldMapSegmentMap segmentMap : segment.maps.values()) {
|
||||
File f = WorldMapController.getFileForMap(segmentMap.mapName);
|
||||
if (!f.exists()) 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");
|
||||
}
|
||||
|
||||
StringBuffer namedAreasAsHtml = new StringBuffer();
|
||||
for (NamedWorldMapArea area : segment.namedAreas.values()) {
|
||||
CoordRect r = determineNamedAreaBoundary(area, segment, world, displayedMapNames);
|
||||
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("{{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, HashSet<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));
|
||||
}
|
||||
|
||||
private static void updateWorldMapSegment(Resources res, WorldContext world, String segmentName) throws IOException {
|
||||
String mapAsHtml = getWorldMapSegmentAsHtml(res, world, segmentName);
|
||||
File outputFile = getCombinedWorldMapFile(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.currentMap.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;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
@@ -11,6 +12,7 @@ import com.gpl.rpg.AndorsTrail.util.L;
|
||||
|
||||
public final class MapCollection {
|
||||
public final ArrayList<PredefinedMap> predefinedMaps = new ArrayList<PredefinedMap>();
|
||||
public final HashMap<String, WorldMapSegment> worldMapSegments = new HashMap<String, WorldMapSegment>();
|
||||
|
||||
public MapCollection() {}
|
||||
|
||||
@@ -29,6 +31,13 @@ public final class MapCollection {
|
||||
m.reset();
|
||||
}
|
||||
}
|
||||
|
||||
public String getWorldMapSegmentNameForMap(String mapName) {
|
||||
for (WorldMapSegment segment : worldMapSegments.values()) {
|
||||
if (segment.containsMap(mapName)) return segment.name;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
@@ -29,11 +29,13 @@ public final class PredefinedMap {
|
||||
public final ArrayList<Loot> groundBags = new ArrayList<Loot>();
|
||||
public boolean visited = false;
|
||||
public long lastVisitTime = VISIT_RESET;
|
||||
public int lastVisitVersion = 0;
|
||||
public final boolean isOutdoors;
|
||||
|
||||
public final boolean[][] isWalkable;
|
||||
public final ArrayList<BloodSplatter> splatters = new ArrayList<BloodSplatter>();
|
||||
|
||||
public PredefinedMap(int xmlResourceId, String name, Size size, boolean[][] isWalkable, MapObject[] eventObjects, MonsterSpawnArea[] spawnAreas, boolean hasFOW) {
|
||||
|
||||
public PredefinedMap(int xmlResourceId, String name, Size size, boolean[][] isWalkable, MapObject[] eventObjects, MonsterSpawnArea[] spawnAreas, boolean hasFOW, boolean isOutdoors) {
|
||||
this.xmlResourceId = xmlResourceId;
|
||||
this.name = name;
|
||||
this.size = size;
|
||||
@@ -44,6 +46,7 @@ public final class PredefinedMap {
|
||||
assert(isWalkable.length == size.width);
|
||||
assert(isWalkable[0].length == size.height);
|
||||
this.isWalkable = isWalkable;
|
||||
this.isOutdoors = isOutdoors;
|
||||
}
|
||||
|
||||
public final boolean isWalkable(final Coord p) {
|
||||
@@ -216,6 +219,7 @@ public final class PredefinedMap {
|
||||
}
|
||||
groundBags.clear();
|
||||
visited = false;
|
||||
lastVisitVersion = 0;
|
||||
}
|
||||
|
||||
public boolean isRecentlyVisited() {
|
||||
@@ -224,6 +228,7 @@ public final class PredefinedMap {
|
||||
}
|
||||
public void updateLastVisitTime() {
|
||||
lastVisitTime = System.currentTimeMillis();
|
||||
lastVisitVersion = AndorsTrailApplication.CURRENT_VERSION;
|
||||
}
|
||||
public void resetTemporaryData() {
|
||||
for(MonsterSpawnArea a : spawnAreas) {
|
||||
@@ -277,6 +282,11 @@ public final class PredefinedMap {
|
||||
}
|
||||
lastVisitTime = src.readLong();
|
||||
|
||||
if (visited) {
|
||||
if (fileversion <= 30) lastVisitVersion = 30;
|
||||
else lastVisitVersion = src.readInt();
|
||||
}
|
||||
|
||||
for(int i = loadedSpawnAreas; i < spawnAreas.length; ++i) {
|
||||
MonsterSpawnArea area = this.spawnAreas[i];
|
||||
if (area.isUnique && visited) spawnAllInArea(world, area, true);
|
||||
@@ -295,5 +305,6 @@ public final class PredefinedMap {
|
||||
}
|
||||
dest.writeBoolean(visited);
|
||||
dest.writeLong(lastVisitTime);
|
||||
if (visited) dest.writeInt(lastVisitVersion);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.util.Base64;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.XmlResourceParserUtils;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.XmlResourceParser;
|
||||
@@ -41,7 +42,7 @@ public final class TMXMapFileParser {
|
||||
map.height = xrp.getAttributeIntValue(null, "height", -1);
|
||||
map.tilewidth = xrp.getAttributeIntValue(null, "tilewidth", -1);
|
||||
map.tileheight = xrp.getAttributeIntValue(null, "tileheight", -1);
|
||||
readCurrentTagUntilEnd(xrp, new TagHandler() {
|
||||
XmlResourceParserUtils.readCurrentTagUntilEnd(xrp, new XmlResourceParserUtils.TagHandler() {
|
||||
public void handleTag(XmlResourceParser xrp, String tagName) throws XmlPullParserException, IOException {
|
||||
if (tagName.equals("tileset")) {
|
||||
tileSets.add(readTMXTileSet(xrp));
|
||||
@@ -49,6 +50,8 @@ public final class TMXMapFileParser {
|
||||
map.objectGroups.add(readTMXObjectGroup(xrp));
|
||||
} else if (tagName.equals("layer")) {
|
||||
layers.add(readTMXMapLayer(xrp));
|
||||
} else if (tagName.equals("property")) {
|
||||
map.properties.add(readTMXProperty(xrp));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -79,7 +82,7 @@ public final class TMXMapFileParser {
|
||||
if (s.equals("map")) {
|
||||
map.width = xrp.getAttributeIntValue(null, "width", -1);
|
||||
map.height = xrp.getAttributeIntValue(null, "height", -1);
|
||||
readCurrentTagUntilEnd(xrp, new TagHandler() {
|
||||
XmlResourceParserUtils.readCurrentTagUntilEnd(xrp, new XmlResourceParserUtils.TagHandler() {
|
||||
public void handleTag(XmlResourceParser xrp, String tagName) throws XmlPullParserException, IOException {
|
||||
if (tagName.equals("tileset")) {
|
||||
tileSets.add(readTMXTileSet(xrp));
|
||||
@@ -109,7 +112,7 @@ public final class TMXMapFileParser {
|
||||
ts.name = xrp.getAttributeValue(null, "name");
|
||||
ts.tilewidth = xrp.getAttributeIntValue(null, "tilewidth", -1);
|
||||
ts.tileheight = xrp.getAttributeIntValue(null, "tileheight", -1);
|
||||
readCurrentTagUntilEnd(xrp, new TagHandler() {
|
||||
XmlResourceParserUtils.readCurrentTagUntilEnd(xrp, new XmlResourceParserUtils.TagHandler() {
|
||||
public void handleTag(XmlResourceParser xrp, String tagName) {
|
||||
if (tagName.equals("image")) {
|
||||
ts.imageSource = xrp.getAttributeValue(null, "source");
|
||||
@@ -128,7 +131,7 @@ public final class TMXMapFileParser {
|
||||
group.name = xrp.getAttributeValue(null, "name");
|
||||
group.width = xrp.getAttributeIntValue(null, "width", 1);
|
||||
group.height = xrp.getAttributeIntValue(null, "height", 1);
|
||||
readCurrentTagUntilEnd(xrp, new TagHandler() {
|
||||
XmlResourceParserUtils.readCurrentTagUntilEnd(xrp, new XmlResourceParserUtils.TagHandler() {
|
||||
public void handleTag(XmlResourceParser xrp, String tagName) throws XmlPullParserException, IOException {
|
||||
if (tagName.equals("object")) {
|
||||
group.objects.add(readTMXObject(xrp));
|
||||
@@ -146,13 +149,10 @@ public final class TMXMapFileParser {
|
||||
object.y = xrp.getAttributeIntValue(null, "y", -1);
|
||||
object.width = xrp.getAttributeIntValue(null, "width", -1);
|
||||
object.height = xrp.getAttributeIntValue(null, "height", -1);
|
||||
readCurrentTagUntilEnd(xrp, new TagHandler() {
|
||||
public void handleTag(XmlResourceParser xrp, String tagName) {
|
||||
XmlResourceParserUtils.readCurrentTagUntilEnd(xrp, new XmlResourceParserUtils.TagHandler() {
|
||||
public void handleTag(XmlResourceParser xrp, String tagName) throws XmlPullParserException, IOException {
|
||||
if (tagName.equals("property")) {
|
||||
final TMXProperty property = new TMXProperty();
|
||||
object.properties.add(property);
|
||||
property.name = xrp.getAttributeValue(null, "name");
|
||||
property.value = xrp.getAttributeValue(null, "value");
|
||||
object.properties.add(readTMXProperty(xrp));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -165,7 +165,7 @@ public final class TMXMapFileParser {
|
||||
layer.width = xrp.getAttributeIntValue(null, "width", 1);
|
||||
layer.height = xrp.getAttributeIntValue(null, "height", 1);
|
||||
layer.gids = new int[layer.width][layer.height];
|
||||
readCurrentTagUntilEnd(xrp, new TagHandler() {
|
||||
XmlResourceParserUtils.readCurrentTagUntilEnd(xrp, new XmlResourceParserUtils.TagHandler() {
|
||||
public void handleTag(XmlResourceParser xrp, String tagName) throws XmlPullParserException, IOException {
|
||||
if (tagName.equals("data")) {
|
||||
readTMXMapLayerData(xrp, layer);
|
||||
@@ -209,6 +209,13 @@ public final class TMXMapFileParser {
|
||||
}
|
||||
}
|
||||
|
||||
private static TMXProperty readTMXProperty(XmlResourceParser xrp) throws XmlPullParserException, IOException {
|
||||
final TMXProperty property = new TMXProperty();
|
||||
property.name = xrp.getAttributeValue(null, "name");
|
||||
property.value = xrp.getAttributeValue(null, "value");
|
||||
return property;
|
||||
}
|
||||
|
||||
private static void copyStreamToBuffer(InflaterInputStream zi, byte[] buffer, int len) throws IOException {
|
||||
int offset = 0;
|
||||
int bytesToRead = len;
|
||||
@@ -220,23 +227,6 @@ public final class TMXMapFileParser {
|
||||
}
|
||||
}
|
||||
|
||||
private interface TagHandler {
|
||||
void handleTag(XmlResourceParser xrp, String tagName) throws XmlPullParserException, IOException;
|
||||
}
|
||||
private static void readCurrentTagUntilEnd(XmlResourceParser xrp, TagHandler handler) throws XmlPullParserException, IOException {
|
||||
String outerTagName = xrp.getName();
|
||||
String tagName;
|
||||
int eventType;
|
||||
while ((eventType = xrp.next()) != XmlResourceParser.END_DOCUMENT) {
|
||||
if (eventType == XmlResourceParser.START_TAG) {
|
||||
tagName = xrp.getName();
|
||||
handler.handleTag(xrp, tagName);
|
||||
} else if (eventType == XmlResourceParser.END_TAG) {
|
||||
tagName = xrp.getName();
|
||||
if (tagName.equals(outerTagName)) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
private static String getHexString(byte v) {
|
||||
String result = Integer.toHexString(v & 0xff);
|
||||
@@ -270,6 +260,7 @@ public final class TMXMapFileParser {
|
||||
public int height;
|
||||
public TMXTileSet[] tileSets;
|
||||
public TMXLayer[] layers;
|
||||
public final ArrayList<TMXProperty> properties = new ArrayList<TMXProperty>();
|
||||
}
|
||||
public static final class TMXTileSet {
|
||||
public int firstgid;
|
||||
@@ -289,7 +280,7 @@ public final class TMXMapFileParser {
|
||||
public String name;
|
||||
public int width;
|
||||
public int height;
|
||||
public ArrayList<TMXObject> objects = new ArrayList<TMXObject>();
|
||||
public final ArrayList<TMXObject> objects = new ArrayList<TMXObject>();
|
||||
}
|
||||
public static final class TMXObject {
|
||||
public String name;
|
||||
@@ -298,7 +289,7 @@ public final class TMXMapFileParser {
|
||||
public int y;
|
||||
public int width;
|
||||
public int height;
|
||||
public ArrayList<TMXProperty> properties = new ArrayList<TMXProperty>();
|
||||
public final ArrayList<TMXProperty> properties = new ArrayList<TMXProperty>();
|
||||
}
|
||||
public static final class TMXProperty {
|
||||
public String name;
|
||||
|
||||
@@ -52,6 +52,12 @@ public final class TMXMapTranslator {
|
||||
assert(m.width > 0);
|
||||
assert(m.height > 0);
|
||||
|
||||
boolean isOutdoors = false;
|
||||
for (TMXProperty p : m.properties) {
|
||||
if(p.name.equalsIgnoreCase("outside")) isOutdoors = (Integer.parseInt(p.value) != 0);
|
||||
else if(AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) L.log("OPTIMIZE: Map " + m.name + " has unrecognized property \"" + p.name + "\".");
|
||||
}
|
||||
|
||||
boolean[][] isWalkable = new boolean[m.width][m.height];
|
||||
for (int y = 0; y < m.height; ++y) {
|
||||
for (int x = 0; x < m.width; ++x) {
|
||||
@@ -186,7 +192,7 @@ public final class TMXMapTranslator {
|
||||
MonsterSpawnArea[] _spawnAreas = new MonsterSpawnArea[spawnAreas.size()];
|
||||
_spawnAreas = spawnAreas.toArray(_spawnAreas);
|
||||
|
||||
result.add(new PredefinedMap(m.xmlResourceId, m.name, mapSize, isWalkable, _eventObjects, _spawnAreas, false));
|
||||
result.add(new PredefinedMap(m.xmlResourceId, m.name, mapSize, isWalkable, _eventObjects, _spawnAreas, false, isOutdoors));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.gpl.rpg.AndorsTrail.model.map;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
|
||||
public final class WorldMapSegment {
|
||||
public final String name;
|
||||
public final HashMap<String, WorldMapSegmentMap> maps = new HashMap<String, WorldMapSegmentMap>();
|
||||
public final HashMap<String, NamedWorldMapArea> namedAreas = new HashMap<String, NamedWorldMapArea>();
|
||||
|
||||
public WorldMapSegment(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean containsMap(String mapName) { return maps.containsKey(mapName); }
|
||||
|
||||
public static final class WorldMapSegmentMap {
|
||||
public final String mapName;
|
||||
public final Coord worldPosition;
|
||||
public WorldMapSegmentMap(String mapName, Coord worldPosition) {
|
||||
this.mapName = mapName;
|
||||
this.worldPosition = worldPosition;
|
||||
}
|
||||
}
|
||||
|
||||
// Towns, cities, villages, taverns, named dungeons
|
||||
public static final class NamedWorldMapArea {
|
||||
public final String id;
|
||||
public final String name;
|
||||
public final String type; // "settlement" or "other"
|
||||
public final HashSet<String> mapNames = new HashSet<String>();
|
||||
public NamedWorldMapArea(String id, String name, String type) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import com.gpl.rpg.AndorsTrail.resource.parsers.DropListParser;
|
||||
import com.gpl.rpg.AndorsTrail.resource.parsers.ItemTypeParser;
|
||||
import com.gpl.rpg.AndorsTrail.resource.parsers.MonsterTypeParser;
|
||||
import com.gpl.rpg.AndorsTrail.resource.parsers.QuestParser;
|
||||
import com.gpl.rpg.AndorsTrail.resource.parsers.WorldMapParser;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.Size;
|
||||
|
||||
@@ -163,6 +164,14 @@ public final class ResourceLoader {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) timingCheckpoint("DynamicTileLoader");
|
||||
// ========================================================================
|
||||
|
||||
|
||||
// ========================================================================
|
||||
// Load worldmap coordinates
|
||||
WorldMapParser.read(r, R.xml.worldmap, world.maps);
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) timingCheckpoint("WorldMapParser");
|
||||
// ========================================================================
|
||||
|
||||
|
||||
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) {
|
||||
long duration = System.currentTimeMillis() - start;
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.gpl.rpg.AndorsTrail.resource.parsers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.XmlResourceParser;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.model.map.MapCollection;
|
||||
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.util.Coord;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.Pair;
|
||||
import com.gpl.rpg.AndorsTrail.util.XmlResourceParserUtils;
|
||||
|
||||
public final class WorldMapParser {
|
||||
public static void read(Resources r, int xmlResourceId, final MapCollection maps) {
|
||||
read(r.getXml(xmlResourceId), maps);
|
||||
}
|
||||
|
||||
private static void read(XmlResourceParser xrp, final MapCollection maps) {
|
||||
try {
|
||||
int eventType;
|
||||
while ((eventType = xrp.next()) != XmlResourceParser.END_DOCUMENT) {
|
||||
if (eventType == XmlResourceParser.START_TAG) {
|
||||
String s = xrp.getName();
|
||||
if (s.equals("segment")) {
|
||||
WorldMapSegment segment = parseSegment(xrp, maps);
|
||||
maps.worldMapSegments.put(segment.name, segment);
|
||||
}
|
||||
}
|
||||
}
|
||||
xrp.close();
|
||||
} catch (Exception e) {
|
||||
L.log("Error reading worldmap: " + e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static WorldMapSegment parseSegment(XmlResourceParser xrp, final MapCollection maps) throws XmlPullParserException, IOException {
|
||||
String segmentName = xrp.getAttributeValue(null, "id");
|
||||
final WorldMapSegment segment = new WorldMapSegment(segmentName);
|
||||
|
||||
final ArrayList<Pair<String, String>> mapsInNamedAreas = new ArrayList<Pair<String,String>>();
|
||||
XmlResourceParserUtils.readCurrentTagUntilEnd(xrp, new XmlResourceParserUtils.TagHandler() {
|
||||
@Override
|
||||
public void handleTag(XmlResourceParser xrp, String tagName) throws XmlPullParserException, IOException {
|
||||
if (tagName.equals("map")) {
|
||||
String mapName = xrp.getAttributeValue(null, "id");
|
||||
if (maps.findPredefinedMap(mapName) == null) return;
|
||||
Coord mapPosition = new Coord(
|
||||
xrp.getAttributeIntValue(null, "x", -1),
|
||||
xrp.getAttributeIntValue(null, "y", -1)
|
||||
);
|
||||
WorldMapSegmentMap map = new WorldMapSegmentMap(mapName, mapPosition);
|
||||
segment.maps.put(mapName, map);
|
||||
|
||||
String namedArea = xrp.getAttributeValue(null, "area");
|
||||
if (namedArea != null) mapsInNamedAreas.add(new Pair<String, String>(mapName, namedArea));
|
||||
} else if (tagName.equals("namedarea")) {
|
||||
String id = xrp.getAttributeValue(null, "id");
|
||||
String name = xrp.getAttributeValue(null, "name");
|
||||
String type = xrp.getAttributeValue(null, "type");
|
||||
segment.namedAreas.put(id, new NamedWorldMapArea(id, name, type));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (Pair<String, String> m : mapsInNamedAreas) {
|
||||
segment.namedAreas.get(m.second).mapNames.add(m.first);
|
||||
}
|
||||
|
||||
return segment;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.gpl.rpg.AndorsTrail.util;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import android.content.res.XmlResourceParser;
|
||||
|
||||
public final class XmlResourceParserUtils {
|
||||
|
||||
public static interface TagHandler {
|
||||
void handleTag(XmlResourceParser xrp, String tagName) throws XmlPullParserException, IOException;
|
||||
}
|
||||
|
||||
public static void readCurrentTagUntilEnd(XmlResourceParser xrp, TagHandler handler) throws XmlPullParserException, IOException {
|
||||
String outerTagName = xrp.getName();
|
||||
String tagName;
|
||||
int eventType;
|
||||
while ((eventType = xrp.next()) != XmlResourceParser.END_DOCUMENT) {
|
||||
if (eventType == XmlResourceParser.START_TAG) {
|
||||
tagName = xrp.getName();
|
||||
handler.handleTag(xrp, tagName);
|
||||
} else if (eventType == XmlResourceParser.END_TAG) {
|
||||
tagName = xrp.getName();
|
||||
if (tagName.equals(outerTagName)) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,7 @@ package com.gpl.rpg.AndorsTrail.view;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.activity.MainActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.HeroinfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.context.ViewContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
|
||||
@@ -23,21 +21,20 @@ public final class StatusView extends RelativeLayout {
|
||||
|
||||
private final WorldContext world;
|
||||
private final Player player;
|
||||
private final ViewContext view;
|
||||
|
||||
private final RangeBar healthBar;
|
||||
private final RangeBar expBar;
|
||||
private final ImageButton heroImage;
|
||||
private final ImageButton quickToggle;
|
||||
private final ImageButton toggleToolbox;
|
||||
private boolean showingLevelup;
|
||||
private final Drawable levelupDrawable;
|
||||
private ToolboxView toolbox;
|
||||
|
||||
public StatusView(final Context context, AttributeSet attr) {
|
||||
super(context, attr);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivityContext(context);
|
||||
this.world = app.world;
|
||||
this.player = app.world.model.player;
|
||||
this.view = app.currentView.get();
|
||||
|
||||
setFocusable(false);
|
||||
inflate(context, R.layout.statusview, this);
|
||||
@@ -49,8 +46,7 @@ public final class StatusView extends RelativeLayout {
|
||||
heroImage.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
Intent intent = new Intent(context, HeroinfoActivity.class);
|
||||
AndorsTrailApplication.getActivityFromActivityContext(context).startActivityForResult(intent, MainActivity.INTENTREQUEST_HEROINFO);
|
||||
context.startActivity(new Intent(context, HeroinfoActivity.class));
|
||||
}
|
||||
});
|
||||
healthBar = (RangeBar) findViewById(R.id.statusview_health);
|
||||
@@ -64,18 +60,24 @@ public final class StatusView extends RelativeLayout {
|
||||
,new BitmapDrawable(world.tileManager.preloadedTiles.getBitmap(TileManager.iconID_moveselect))
|
||||
});
|
||||
|
||||
quickToggle = (ImageButton) findViewById(R.id.quickitem_toggle);
|
||||
world.tileManager.setImageViewTileForUIIcon(quickToggle, TileManager.iconID_boxclosed);
|
||||
quickToggle.setOnClickListener(new OnClickListener() {
|
||||
toggleToolbox = (ImageButton) findViewById(R.id.toolbox_toggle);
|
||||
world.tileManager.setImageViewTileForUIIcon(toggleToolbox, TileManager.iconID_boxclosed);
|
||||
toggleToolbox.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
view.itemController.toggleQuickItemView();
|
||||
toolbox.toggleVisibility();
|
||||
}
|
||||
});
|
||||
|
||||
updateStatus();
|
||||
updateIcon(player.canLevelup());
|
||||
}
|
||||
|
||||
public void registerToolboxViews(ToolboxView toolbox, QuickitemView quickitemView) {
|
||||
this.toolbox = toolbox;
|
||||
toolbox.registerToolboxViews(toggleToolbox, quickitemView);
|
||||
toolbox.updateIcons();
|
||||
}
|
||||
|
||||
public void updateStatus() {
|
||||
healthBar.update(player.health);
|
||||
@@ -94,12 +96,4 @@ public final class StatusView extends RelativeLayout {
|
||||
world.tileManager.setImageViewTile(heroImage, player);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateQuickItemImage(boolean visible){
|
||||
if(visible){
|
||||
world.tileManager.setImageViewTileForUIIcon(quickToggle, TileManager.iconID_boxopened);
|
||||
} else {
|
||||
world.tileManager.setImageViewTileForUIIcon(quickToggle, TileManager.iconID_boxclosed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.gpl.rpg.AndorsTrail.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.animation.Animation.AnimationListener;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
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.resource.tiles.TileManager;
|
||||
|
||||
public class ToolboxView extends LinearLayout implements OnClickListener {
|
||||
private final WorldContext world;
|
||||
private final Animation showAnimation;
|
||||
private final Animation hideAnimation;
|
||||
private final ImageButton toolbox_quickitems;
|
||||
private final ImageButton toolbox_map;
|
||||
private ImageButton toggleVisibility;
|
||||
private QuickitemView quickitemView;
|
||||
|
||||
public ToolboxView(final Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivityContext(context);
|
||||
this.world = app.world;
|
||||
|
||||
inflate(context, R.layout.toolboxview, this);
|
||||
|
||||
this.showAnimation = AnimationUtils.loadAnimation(context, R.anim.showtoolbox);
|
||||
this.hideAnimation = AnimationUtils.loadAnimation(context, R.anim.hidetoolbox);
|
||||
this.hideAnimation.setAnimationListener(new AnimationListener() {
|
||||
@Override public void onAnimationStart(Animation animation) { }
|
||||
@Override public void onAnimationRepeat(Animation animation) { }
|
||||
@Override public void onAnimationEnd(Animation animation) {
|
||||
ToolboxView.this.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
toolbox_quickitems = (ImageButton)findViewById(R.id.toolbox_quickitems);
|
||||
toolbox_quickitems.setOnClickListener(this);
|
||||
toolbox_map = (ImageButton)findViewById(R.id.toolbox_map);
|
||||
toolbox_map.setOnClickListener(this);
|
||||
}
|
||||
|
||||
public void registerToolboxViews(ImageButton toggleVisibility, QuickitemView quickitemView) {
|
||||
this.toggleVisibility = toggleVisibility;
|
||||
this.quickitemView = quickitemView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View btn) {
|
||||
Context context = getContext();
|
||||
if (btn == toolbox_quickitems) {
|
||||
toggleQuickItemView();
|
||||
} else if (btn == toolbox_map) {
|
||||
if (!WorldMapController.displayWorldMap(context, world)) return;
|
||||
setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleQuickItemView() {
|
||||
if (quickitemView.getVisibility() == View.VISIBLE){
|
||||
quickitemView.setVisibility(View.GONE);
|
||||
} else {
|
||||
quickitemView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleVisibility() {
|
||||
if (getVisibility() == View.VISIBLE) {
|
||||
startAnimation(hideAnimation);
|
||||
setToolboxIcon(false);
|
||||
} else {
|
||||
setVisibility(View.VISIBLE);
|
||||
startAnimation(showAnimation);
|
||||
setToolboxIcon(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateIcons() {
|
||||
setToolboxIcon(getVisibility() == View.VISIBLE);
|
||||
}
|
||||
|
||||
private void setToolboxIcon(boolean opened) {
|
||||
if (opened) {
|
||||
world.tileManager.setImageViewTileForUIIcon(toggleVisibility, TileManager.iconID_boxopened);
|
||||
} else {
|
||||
world.tileManager.setImageViewTileForUIIcon(toggleVisibility, TileManager.iconID_boxclosed);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user