diff --git a/AndorsTrail/res/drawable/char_hero_maksiu_boy_01.png b/AndorsTrail/res/drawable/char_hero_maksiu_boy_01.png
new file mode 100755
index 000000000..d61765b06
Binary files /dev/null and b/AndorsTrail/res/drawable/char_hero_maksiu_boy_01.png differ
diff --git a/AndorsTrail/res/drawable/char_hero_maksiu_girl_01.png b/AndorsTrail/res/drawable/char_hero_maksiu_girl_01.png
new file mode 100755
index 000000000..97a87c88e
Binary files /dev/null and b/AndorsTrail/res/drawable/char_hero_maksiu_girl_01.png differ
diff --git a/AndorsTrail/res/layout-land/startscreen.xml b/AndorsTrail/res/layout-land/startscreen.xml
index fdc1e416e..821e40cac 100644
--- a/AndorsTrail/res/layout-land/startscreen.xml
+++ b/AndorsTrail/res/layout-land/startscreen.xml
@@ -8,6 +8,14 @@
android:layout_height="match_parent"
layout="@layout/title_bg_layout" />
+
+
-
-
+ android:layout_weight="0.6"
+ android:gravity="bottom|center_horizontal" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/AndorsTrail/res/layout/heroinfo_equipped.xml b/AndorsTrail/res/layout/heroinfo_equipped.xml
index b2f916be2..10fc685a3 100644
--- a/AndorsTrail/res/layout/heroinfo_equipped.xml
+++ b/AndorsTrail/res/layout/heroinfo_equipped.xml
@@ -6,13 +6,13 @@
>
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AndorsTrail/res/layout/startscreen.xml b/AndorsTrail/res/layout/startscreen.xml
index 1c09410d0..e705820ef 100644
--- a/AndorsTrail/res/layout/startscreen.xml
+++ b/AndorsTrail/res/layout/startscreen.xml
@@ -5,6 +5,14 @@
+
+
-
-
-
-
-
-
-
-
+ android:textColor="#880000"
+ android:visibility="gone" />
-
+ android:layout_height="wrap_content" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
\ No newline at end of file
diff --git a/AndorsTrail/res/layout/startscreen_mainmenu.xml b/AndorsTrail/res/layout/startscreen_mainmenu.xml
new file mode 100644
index 000000000..fd12c5808
--- /dev/null
+++ b/AndorsTrail/res/layout/startscreen_mainmenu.xml
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AndorsTrail/res/layout/startscreen_newgame.xml b/AndorsTrail/res/layout/startscreen_newgame.xml
new file mode 100644
index 000000000..8b7598a0c
--- /dev/null
+++ b/AndorsTrail/res/layout/startscreen_newgame.xml
@@ -0,0 +1,108 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AndorsTrail/res/values/strings.xml b/AndorsTrail/res/values/strings.xml
index 4ed923678..7c0e2f504 100644
--- a/AndorsTrail/res/values/strings.xml
+++ b/AndorsTrail/res/values/strings.xml
@@ -133,8 +133,11 @@
Continue current game
New game
+ Start game
+ Cancel
You will lose your current game and your current character, are you sure you want to start a new game?
About/help
+ Choose your hero
Enter hero name
Load
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/Dialogs.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/Dialogs.java
index 5e781febb..ba2c1f4e6 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/Dialogs.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/Dialogs.java
@@ -10,13 +10,16 @@ import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.Bundle;
+import android.support.v4.app.Fragment;
import android.view.View;
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.*;
+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;
@@ -288,7 +291,13 @@ public final class Dialogs {
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.INTENTREQUEST_LOADGAME);
+ 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) {
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/WorldSetup.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/WorldSetup.java
index 35848144c..e93999bf6 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/WorldSetup.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/WorldSetup.java
@@ -26,6 +26,7 @@ public final class WorldSetup {
public int loadFromSlot = Savegames.SLOT_QUICKSAVE;
public boolean isSceneReady = false;
public String newHeroName;
+ public int newHeroIcon;
private Savegames.LoadSavegameResult loadResult;
public WorldSetup(WorldContext world, ControllerContext controllers, Context androidContext) {
@@ -53,10 +54,14 @@ public final class WorldSetup {
isInitializingResources = true;
}
+ //Load resources essential to the app synchroneously
+ ResourceLoader.loadResourcesSync(world, r);
+
+ //And the rest asynchroneously
(new AsyncTask() {
@Override
protected Void doInBackground(Void... arg0) {
- ResourceLoader.loadResources(world, r);
+ ResourceLoader.loadResourcesAsync(world, r);
return null;
}
@@ -144,7 +149,7 @@ public final class WorldSetup {
private void createNewWorld() {
Context ctx = androidContext.get();
world.model = new ModelContainer();
- world.model.player.initializeNewPlayer(world.dropLists, newHeroName);
+ world.model.player.initializeNewPlayer(world.dropLists, newHeroName, newHeroIcon);
controllers.actorStatsController.recalculatePlayerStats(world.model.player);
controllers.movementController.respawnPlayer(ctx.getResources());
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/StartScreenActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/StartScreenActivity.java
index 00db4b024..d3b3e62b1 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/StartScreenActivity.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/StartScreenActivity.java
@@ -1,41 +1,25 @@
package com.gpl.rpg.AndorsTrail.activity;
import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.DialogInterface;
+import android.app.Fragment;
import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.Editor;
import android.content.res.Resources;
import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+import android.view.KeyEvent;
import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.Button;
-import android.widget.EditText;
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.controller.Constants;
+import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_MainMenu;
+import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_NewGame;
+import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_MainMenu.OnNewGameRequestedListener;
+import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_NewGame.GameCreationOverListener;
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
-import com.gpl.rpg.AndorsTrail.savegames.Savegames;
-import com.gpl.rpg.AndorsTrail.savegames.Savegames.FileHeader;
-public final class StartScreenActivity extends Activity {
+public final class StartScreenActivity extends FragmentActivity implements OnNewGameRequestedListener, GameCreationOverListener {
- 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 TextView startscreen_currenthero;
- private EditText startscreen_enterheroname;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -45,63 +29,23 @@ public final class StartScreenActivity extends Activity {
final Resources res = getResources();
TileManager tileManager = app.getWorld().tileManager;
tileManager.setDensity(res);
- updatePreferences(false);
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();
+
+ }
+
+
+
TextView tv = (TextView) findViewById(R.id.startscreen_version);
tv.setText('v' + AndorsTrailApplication.CURRENT_VERSION_DISPLAY);
-
- startscreen_currenthero = (TextView) findViewById(R.id.startscreen_currenthero);
- startscreen_enterheroname = (EditText) findViewById(R.id.startscreen_enterheroname);
- //startscreen_enterheroname.setImeOptions(EditorInfo.IME_ACTION_DONE);
-
- startscreen_continue = (Button) 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) findViewById(R.id.startscreen_newgame);
- startscreen_newgame.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View arg0) {
- if (hasExistingGame) {
- comfirmNewGame();
- } else {
- createNewGame();
- }
- }
- });
-
- Button b = (Button) findViewById(R.id.startscreen_about);
- b.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View arg0) {
- startActivity(new Intent(StartScreenActivity.this, AboutActivity.class));
- }
- });
-
- b = (Button) findViewById(R.id.startscreen_preferences);
- b.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View arg0) {
- Intent intent = new Intent(StartScreenActivity.this, Preferences.class);
- startActivityForResult(intent, INTENTREQUEST_PREFERENCES);
- }
- });
-
- startscreen_load = (Button) findViewById(R.id.startscreen_load);
- startscreen_load.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View arg0) {
- Dialogs.showLoad(StartScreenActivity.this);
- }
- });
-
TextView development_version = (TextView) findViewById(R.id.startscreen_dev_version);
if (AndorsTrailApplication.DEVELOPMENT_INCOMPATIBLE_SAVEGAMES) {
@@ -119,134 +63,55 @@ public final class StartScreenActivity extends Activity {
app.getWorldSetup().startResourceLoader(res);
- 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);
- }
- }
-
- private void updatePreferences(boolean alreadyStartedLoadingResources) {
- AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
- AndorsTrailPreferences preferences = app.getPreferences();
- preferences.read(this);
- if (app.setLocale(this)) {
- if (alreadyStartedLoadingResources) {
- // Changing the locale after having loaded the game requires resources to
- // be re-loaded. Therefore, we just exit here.
- Toast.makeText(this, R.string.change_locale_requires_restart, Toast.LENGTH_LONG).show();
- this.finish();
- return;
- }
- }
- app.getWorld().tileManager.updatePreferences(preferences);
}
+
@Override
protected void onResume() {
super.onResume();
- String playerName;
- String displayInfo = null;
-
- FileHeader header = Savegames.quickload(this, Savegames.SLOT_QUICKSAVE);
- if (header != null && header.playerName != null) {
- playerName = header.playerName;
- displayInfo = header.displayInfo;
- } else {
- // Before fileversion 14 (v0.6.7), quicksave was stored in Shared preferences
- SharedPreferences p = getSharedPreferences("quicksave", MODE_PRIVATE);
- playerName = p.getString("playername", null);
- if (playerName != null) {
- displayInfo = "level " + p.getInt("level", -1);
- }
- }
- hasExistingGame = (playerName != null);
- setButtonState(playerName, displayInfo);
-
- if (isNewVersion()) {
- Dialogs.showNewVersion(this);
- }
-
- boolean hasSavegames = !Savegames.getUsedSavegameSlots().isEmpty();
- startscreen_load.setEnabled(hasSavegames);
+
}
@Override
protected 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 boolean isNewVersion() {
- final String v = "lastversion";
- SharedPreferences s = getSharedPreferences(Constants.PREFERENCE_MODEL_LASTRUNVERSION, MODE_PRIVATE);
- int lastversion = s.getInt(v, 0);
- if (lastversion >= AndorsTrailApplication.CURRENT_VERSION) return false;
- Editor e = s.edit();
- e.putInt(v, AndorsTrailApplication.CURRENT_VERSION);
- e.commit();
- return true;
- }
-
-
- private void setButtonState(final String playerName, final String displayInfo) {
- startscreen_continue.setEnabled(hasExistingGame);
- startscreen_newgame.setEnabled(true);
- if (hasExistingGame) {
- startscreen_currenthero.setText(playerName + ", " + displayInfo);
- startscreen_enterheroname.setText(playerName);
- startscreen_enterheroname.setVisibility(View.GONE);
- } else {
- startscreen_currenthero.setText(R.string.startscreen_enterheroname);
- startscreen_enterheroname.setVisibility(View.VISIBLE);
- }
- }
-
- private void continueGame(boolean createNewCharacter, int loadFromSlot, String name) {
- final WorldSetup setup = AndorsTrailApplication.getApplicationFromActivity(this).getWorldSetup();
- setup.createNewCharacter = createNewCharacter;
- setup.loadFromSlot = loadFromSlot;
- setup.newHeroName = name;
- startActivity(new Intent(this, LoadingActivity.class));
- }
-
- private void createNewGame() {
- String name = startscreen_enterheroname.getText().toString().trim();
- if (name == null || name.length() <= 0) {
- Toast.makeText(this, R.string.startscreen_enterheroname, Toast.LENGTH_SHORT).show();
- return;
- }
- continueGame(true, 0, name);
- }
-
- private void comfirmNewGame() {
- new AlertDialog.Builder(this)
- .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);
+
+ @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);
}
- })
- .setNegativeButton(android.R.string.cancel, null)
- .create().show();
+ }
+ return super.onKeyDown(keyCode, event);
}
+
+ private void backPressed() {
+ if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
+ getSupportFragmentManager().popBackStack();
+ }
+ }
+
+ 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();
+
+ }
+ }
+
+ @Override
+ public void onGameCreationCancelled() {
+ backPressed();
+ }
+
}
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Inventory.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Inventory.java
index 498e6279f..fadd85445 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Inventory.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Inventory.java
@@ -30,6 +30,7 @@ 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.resource.tiles.TileManager;
import com.gpl.rpg.AndorsTrail.view.ItemContainerAdapter;
public final class HeroinfoActivity_Inventory extends Fragment {
@@ -94,6 +95,10 @@ public final class HeroinfoActivity_Inventory extends Fragment {
inventoryListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, inv, player, wornTiles);
inventoryList.setAdapter(inventoryListAdapter);
+ ImageView heroicon = (ImageView) v.findViewById(R.id.heroinfo_inventory_heroicon);
+ world.tileManager.setImageViewTileForPlayer(getResources(), heroicon, player.iconID);
+
+
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);
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/StartScreenActivity_MainMenu.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/StartScreenActivity_MainMenu.java
new file mode 100644
index 000000000..616c91f1c
--- /dev/null
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/StartScreenActivity_MainMenu.java
@@ -0,0 +1,265 @@
+package com.gpl.rpg.AndorsTrail.activity.fragment;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
+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.EditText;
+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;
+
+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) {
+ super.onCreateView(inflater, container, savedInstanceState);
+
+ updatePreferences(false);
+
+ 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) {
+ 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);
+ }
+
+ return root;
+ }
+
+ @Override
+ public void onResume() {
+ // TODO Auto-generated method stub
+ super.onResume();
+
+ String playerName;
+ String displayInfo = null;
+ int iconID = TileManager.CHAR_HERO;
+
+ FileHeader header = Savegames.quickload(getActivity(), Savegames.SLOT_QUICKSAVE);
+ if (header != null && header.playerName != null) {
+ playerName = header.playerName;
+ displayInfo = header.displayInfo;
+ iconID = header.iconID;
+ } 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);
+
+ if (isNewVersion()) {
+ Dialogs.showNewVersion(getActivity());
+ }
+
+ boolean hasSavegames = !Savegames.getUsedSavegameSlots().isEmpty();
+ startscreen_load.setEnabled(hasSavegames);
+ }
+
+ @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) {
+ startscreen_continue.setEnabled(hasExistingGame);
+ 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(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(getActivity())
+ .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();
+ }
+
+ private boolean isNewVersion() {
+ final String v = "lastversion";
+ SharedPreferences s = getActivity().getSharedPreferences(Constants.PREFERENCE_MODEL_LASTRUNVERSION, Activity.MODE_PRIVATE);
+ int lastversion = s.getInt(v, 0);
+ if (lastversion >= AndorsTrailApplication.CURRENT_VERSION) return false;
+ Editor e = s.edit();
+ e.putInt(v, AndorsTrailApplication.CURRENT_VERSION);
+ e.commit();
+ return true;
+ }
+
+
+ @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();
+ getActivity().finish();
+ return;
+ }
+ }
+ app.getWorld().tileManager.updatePreferences(preferences);
+ }
+
+
+ public interface OnNewGameRequestedListener {
+ public void onNewGameRequested();
+ }
+
+ private OnNewGameRequestedListener listener = null;
+
+ private void createNewGame() {
+ if (listener != null) {
+ listener.onNewGameRequested();
+ }
+ }
+
+
+}
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/StartScreenActivity_NewGame.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/StartScreenActivity_NewGame.java
new file mode 100644
index 000000000..cf3fb129c
--- /dev/null
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/StartScreenActivity_NewGame.java
@@ -0,0 +1,144 @@
+package com.gpl.rpg.AndorsTrail.activity.fragment;
+
+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.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.RadioGroup;
+import android.widget.ToggleButton;
+import android.widget.RadioGroup.OnCheckedChangeListener;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
+import com.gpl.rpg.AndorsTrail.R;
+import com.gpl.rpg.AndorsTrail.WorldSetup;
+import com.gpl.rpg.AndorsTrail.activity.LoadingActivity;
+import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_MainMenu.OnNewGameRequestedListener;
+import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
+
+public class StartScreenActivity_NewGame extends Fragment {
+
+ private TextView startscreen_enterheroname;
+
+ private int selectedIconID = TileManager.CHAR_HERO;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ super.onCreateView(inflater, container, savedInstanceState);
+
+ if (container != null) {
+ container.removeAllViews();
+ }
+
+ View root = inflater.inflate(R.layout.startscreen_newgame, container, false);
+
+
+ startscreen_enterheroname = (TextView) root.findViewById(R.id.startscreen_enterheroname);
+
+ final RadioGroup group = (RadioGroup) root.findViewById(R.id.newgame_spritegroup);
+ group.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+
+ @Override
+ public void onCheckedChanged(RadioGroup group, int checkedId) {
+ for (int i = 0; i < group.getChildCount(); i++) {
+ ToggleButton tb = ((ToggleButton)group.getChildAt(i));
+ tb.setChecked(tb.getId() == checkedId);
+ }
+ switch (checkedId) {
+ case R.id.newgame_sprite0:
+ selectedIconID = TileManager.CHAR_HERO_0;
+ break;
+ case R.id.newgame_sprite1:
+ selectedIconID = TileManager.CHAR_HERO_1;
+ break;
+ case R.id.newgame_sprite2:
+ selectedIconID = TileManager.CHAR_HERO_2;
+ break;
+ }
+ }
+ });
+
+ OnClickListener l = new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ group.check(v.getId());
+ }
+ };
+
+ for (int i = 0; i < group.getChildCount(); i++) {
+ ToggleButton tb = ((ToggleButton)group.getChildAt(i));
+ tb.setOnClickListener(l);
+ }
+
+ Button b = (Button) root.findViewById(R.id.startscreen_newgame_start);
+ b.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ createNewGame();
+ }
+ });
+
+ b = (Button) root.findViewById(R.id.startscreen_newgame_cancel);
+ b.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ gameCreationOver();
+ }
+ });
+
+ return root;
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+ listener = (GameCreationOverListener) activity;
+ }
+
+ @Override
+ public void onDetach() {
+ super.onDetach();
+ listener = null;
+ }
+
+
+ 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;
+ setup.newHeroIcon = selectedIconID;
+ gameCreationOver();
+ startActivity(new Intent(getActivity(), LoadingActivity.class));
+ }
+
+ private void createNewGame() {
+ String name = startscreen_enterheroname.getText().toString().trim();
+ if (name == null || name.length() <= 0) {
+ Toast.makeText(getActivity(), R.string.startscreen_enterheroname, Toast.LENGTH_SHORT).show();
+ return;
+ }
+ continueGame(true, 0, name);
+ }
+
+ public interface GameCreationOverListener {
+ public void onGameCreationCancelled();
+ }
+
+ private GameCreationOverListener listener = null;
+
+ private void gameCreationOver() {
+ if (listener != null) {
+ listener.onGameCreationCancelled();
+ }
+ }
+
+
+}
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Player.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Player.java
index 6632c941c..42abbd3b8 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Player.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Player.java
@@ -90,8 +90,8 @@ public final class Player extends Actor {
this.inventory = new Inventory();
}
- public void initializeNewPlayer(DropListCollection dropLists, String playerName) {
- baseTraits.iconID = TileManager.CHAR_HERO;
+ public void initializeNewPlayer(DropListCollection dropLists, String playerName, int playerIcon) {
+ baseTraits.iconID = playerIcon;
baseTraits.maxAP = 10;
baseTraits.maxHP = 25;
baseTraits.moveCost = 6;
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/ResourceLoader.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/ResourceLoader.java
index ad85a91c0..b63c8d6c9 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/ResourceLoader.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/ResourceLoader.java
@@ -28,6 +28,7 @@ public final class ResourceLoader {
private static final int monstersResourceId = AndorsTrailApplication.DEVELOPMENT_DEBUGRESOURCES ? R.array.loadresource_monsters_debug : R.array.loadresource_monsters;
private static final int mapsResourceId = AndorsTrailApplication.DEVELOPMENT_DEBUGRESOURCES ? R.array.loadresource_maps_debug : R.array.loadresource_maps;
+ private static DynamicTileLoader loader;
private static long taskStart;
private static void timingCheckpoint(String loaderName) {
long now = System.currentTimeMillis();
@@ -35,22 +36,23 @@ public final class ResourceLoader {
L.log(loaderName + " ran for " + duration + " ms.");
taskStart = now;
}
-
- public static void loadResources(WorldContext world, Resources r) {
+
+ public static void loadResourcesSync(WorldContext world, Resources r) {
long start = System.currentTimeMillis();
taskStart = start;
final int mTileSize = world.tileManager.tileSize;
- final TranslationLoader translationLoader = new TranslationLoader(r.getAssets(), r);
- DynamicTileLoader loader = new DynamicTileLoader(world.tileManager.tileCache);
+ loader = new DynamicTileLoader(world.tileManager.tileCache);
prepareTilesets(loader, mTileSize);
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) timingCheckpoint("prepareTilesets");
// ========================================================================
// Load various ui icons
- /*TileManager.iconID_CHAR_HERO = */loader.prepareTileID(R.drawable.char_hero, 0);
+ /*TileManager.iconID_CHAR_HERO_0 = */loader.prepareTileID(R.drawable.char_hero, 0);
+ /*TileManager.iconID_CHAR_HERO_1 = */loader.prepareTileID(R.drawable.char_hero_maksiu_girl_01, 0);
+ /*TileManager.iconID_CHAR_HERO_2 = */loader.prepareTileID(R.drawable.char_hero_maksiu_boy_01, 0);
/*TileManager.iconID_selection_red = */loader.prepareTileID(R.drawable.ui_selections, 0);
/*TileManager.iconID_selection_yellow = */loader.prepareTileID(R.drawable.ui_selections, 1);
/*TileManager.iconID_groundbag = */loader.prepareTileID(R.drawable.ui_icon_equipment, 0);
@@ -64,8 +66,47 @@ public final class ResourceLoader {
loader.prepareTileID(R.drawable.ui_splatters1, i+8);
}
loader.prepareTileID(R.drawable.ui_icon_immunity, 0);
+ // ========================================================================
+ // Load preloaded tiles
+ loader.flush();
+ world.tileManager.loadPreloadedTiles(r);
+ }
+ public static void loadResourcesAsync(WorldContext world, Resources r) {
+ long start = System.currentTimeMillis();
+ taskStart = start;
+// final int mTileSize = world.tileManager.tileSize;
+//
+//
+// DynamicTileLoader loader = new DynamicTileLoader(world.tileManager.tileCache);
+// prepareTilesets(loader, mTileSize);
+// if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) timingCheckpoint("prepareTilesets");
+//
+// // ========================================================================
+// // Load various ui icons
+// /*TileManager.iconID_CHAR_HERO = */loader.prepareTileID(R.drawable.char_hero, 0);
+// /*TileManager.iconID_selection_red = */loader.prepareTileID(R.drawable.ui_selections, 0);
+// /*TileManager.iconID_selection_yellow = */loader.prepareTileID(R.drawable.ui_selections, 1);
+// /*TileManager.iconID_groundbag = */loader.prepareTileID(R.drawable.ui_icon_equipment, 0);
+// /*TileManager.iconID_boxopened = */loader.prepareTileID(R.drawable.ui_quickslots, 1);
+// /*TileManager.iconID_boxclosed = */loader.prepareTileID(R.drawable.ui_quickslots, 0);
+// /*TileManager.iconID_selection_blue = */loader.prepareTileID(R.drawable.ui_selections, 2);
+// /*TileManager.iconID_selection_purple = */loader.prepareTileID(R.drawable.ui_selections, 3);
+// /*TileManager.iconID_selection_green = */loader.prepareTileID(R.drawable.ui_selections, 4);
+// for(int i = 0; i < 5; ++i) {
+// loader.prepareTileID(R.drawable.ui_splatters1, i);
+// loader.prepareTileID(R.drawable.ui_splatters1, i+8);
+// }
+// loader.prepareTileID(R.drawable.ui_icon_immunity, 0);
+// // ========================================================================
+// // Load preloaded tiles
+// loader.flush();
+// world.tileManager.loadPreloadedTiles(r);
+
+
+ final TranslationLoader translationLoader = new TranslationLoader(r.getAssets(), r);
+
// ========================================================================
// Load effects
world.visualEffectTypes.initialize(loader);
@@ -96,12 +137,6 @@ public final class ResourceLoader {
conditionsToLoad.recycle();
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) timingCheckpoint("ActorConditionsTypeParser");
- // ========================================================================
- // Load preloaded tiles
- loader.flush();
- world.tileManager.loadPreloadedTiles(r);
-
-
// ========================================================================
// Load items
final ItemTypeParser itemTypeParser = new ItemTypeParser(loader, world.actorConditionsTypes, world.itemCategories, translationLoader);
@@ -230,6 +265,8 @@ public final class ResourceLoader {
final Size mapTileSize = new Size(16, 8);
loader.prepareTileset(R.drawable.char_hero, "char_hero", sz1x1, sz1x1, mTileSize);
+ loader.prepareTileset(R.drawable.char_hero_maksiu_girl_01, "char_hero_maksiu_girl_01", sz1x1, sz1x1, mTileSize);
+ loader.prepareTileset(R.drawable.char_hero_maksiu_boy_01, "char_hero_maksiu_boy_01", sz1x1, sz1x1, mTileSize);
loader.prepareTileset(R.drawable.ui_selections, "ui_selections", new Size(5, 1), sz1x1, mTileSize);
loader.prepareTileset(R.drawable.ui_quickslots, "ui_quickslots", sz2x1, sz1x1, mTileSize);
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/tiles/TileManager.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/tiles/TileManager.java
index 4e047a8ae..f4843a4e8 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/tiles/TileManager.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/tiles/TileManager.java
@@ -34,32 +34,40 @@ import com.gpl.rpg.AndorsTrail.model.map.TMXMapTranslator;
import com.gpl.rpg.AndorsTrail.util.L;
public final class TileManager {
- public static final int CHAR_HERO = 1;
- public static final int iconID_selection_red = 2;
- public static final int iconID_selection_yellow = 3;
+
+ public static final int BEGIN_ID = 1;
+
+ public static final int CHAR_HERO_0 = BEGIN_ID;
+ public static final int CHAR_HERO_1 = CHAR_HERO_0+1;
+ public static final int CHAR_HERO_2 = CHAR_HERO_1+1;
+ //Default hero
+ public static final int CHAR_HERO = CHAR_HERO_2;
+
+ public static final int iconID_selection_red = CHAR_HERO_2+1;
+ public static final int iconID_selection_yellow = iconID_selection_red+1;
public static final int iconID_attackselect = iconID_selection_red;
public static final int iconID_moveselect = iconID_selection_yellow;
- public static final int iconID_groundbag = 4;
- public static final int iconID_boxopened = 5;
- public static final int iconID_boxclosed = 6;
+ public static final int iconID_groundbag = iconID_moveselect+1;
+ public static final int iconID_boxopened = iconID_groundbag+1;
+ public static final int iconID_boxclosed = iconID_boxopened+1;
public static final int iconID_shop = iconID_groundbag;
public static final int iconID_unassigned_quickslot = iconID_groundbag;
- public static final int iconID_selection_blue = 7;
- public static final int iconID_selection_purple = 8;
- public static final int iconID_selection_green = 9;
+ public static final int iconID_selection_blue = iconID_boxclosed+1;
+ public static final int iconID_selection_purple = iconID_selection_blue+1;
+ public static final int iconID_selection_green = iconID_selection_purple+1;
- public static final int iconID_splatter_red_1a = 10;
- public static final int iconID_splatter_red_1b = 11;
- public static final int iconID_splatter_red_2a = 12;
- public static final int iconID_splatter_red_2b = 13;
- public static final int iconID_splatter_brown_1a = 14;
- public static final int iconID_splatter_brown_1b = 15;
- public static final int iconID_splatter_brown_2a = 16;
- public static final int iconID_splatter_brown_2b = 17;
- public static final int iconID_splatter_white_1a = 18;
- public static final int iconID_splatter_white_1b = 19;
+ public static final int iconID_splatter_red_1a = iconID_selection_green+1;
+ public static final int iconID_splatter_red_1b = iconID_splatter_red_1a+1;
+ public static final int iconID_splatter_red_2a = iconID_splatter_red_1b+1;
+ public static final int iconID_splatter_red_2b = iconID_splatter_red_2a+1;
+ public static final int iconID_splatter_brown_1a = iconID_splatter_red_2b+1;
+ public static final int iconID_splatter_brown_1b = iconID_splatter_brown_1a+1;
+ public static final int iconID_splatter_brown_2a = iconID_splatter_brown_1b+1;
+ public static final int iconID_splatter_brown_2b = iconID_splatter_brown_2a+1;
+ public static final int iconID_splatter_white_1a = iconID_splatter_brown_2b+1;
+ public static final int iconID_splatter_white_1b = iconID_splatter_white_1a+1;
- public static final int iconID_immunity_overlay = 20;
+ public static final int iconID_immunity_overlay = iconID_splatter_white_1b+1;
public int tileSize;
public float density;
@@ -70,7 +78,7 @@ public final class TileManager {
public final TileCache tileCache = new TileCache();
- public final TileCollection preloadedTiles = new TileCollection(114);
+ public final TileCollection preloadedTiles = new TileCollection(116);
public TileCollection currentMapTiles;
public TileCollection adjacentMapTiles;
private final HashSet preloadedTileIDs = new HashSet();
@@ -316,7 +324,7 @@ public final class TileManager {
throw new IndexOutOfBoundsException("ERROR: TileManager.preloadedTiles needs to be initialized with at least " + maxTileID + " slots. Application will crash now.");
}
}
- for(int i = TileManager.CHAR_HERO; i <= maxTileID; ++i) {
+ for(int i = TileManager.BEGIN_ID; i <= maxTileID; ++i) {
preloadedTileIDs.add(i);
}
tileCache.loadTilesFor(preloadedTileIDs, r, preloadedTiles);
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/savegames/Savegames.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/savegames/Savegames.java
index 25c53f83a..421e7da03 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/savegames/Savegames.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/savegames/Savegames.java
@@ -3,11 +3,13 @@ package com.gpl.rpg.AndorsTrail.savegames;
import android.content.Context;
import android.content.res.Resources;
import android.os.Environment;
+
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.model.ModelContainer;
+import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
import com.gpl.rpg.AndorsTrail.util.L;
import java.io.*;
@@ -94,7 +96,7 @@ public final class Savegames {
public static void saveWorld(WorldContext world, OutputStream outStream, String displayInfo) throws IOException {
DataOutputStream dest = new DataOutputStream(outStream);
- FileHeader.writeToParcel(dest, world.model.player.getName(), displayInfo);
+ FileHeader.writeToParcel(dest, world.model.player.getName(), displayInfo, world.model.player.iconID);
world.maps.writeToParcel(dest, world);
world.model.writeToParcel(dest);
dest.close();
@@ -164,7 +166,8 @@ public final class Savegames {
public final int fileversion;
public final String playerName;
public final String displayInfo;
-
+ public final int iconID;
+
public String describe() {
return playerName + ", " + displayInfo;
}
@@ -183,12 +186,18 @@ public final class Savegames {
this.playerName = null;
this.displayInfo = null;
}
+ if (fileversion >= 43) {
+ this.iconID = src.readInt();
+ } else {
+ this.iconID = TileManager.CHAR_HERO;
+ }
}
- public static void writeToParcel(DataOutputStream dest, String playerName, String displayInfo) throws IOException {
+ public static void writeToParcel(DataOutputStream dest, String playerName, String displayInfo, int iconID) throws IOException {
dest.writeInt(AndorsTrailApplication.CURRENT_VERSION);
dest.writeUTF(playerName);
dest.writeUTF(displayInfo);
+ dest.writeInt(iconID);
}
}
}