Select your hero !

Support for three different hero sprites.
Externalized New Game Creation in a separate fragment.
Enhanced title screen UI.
Continuable game preview.
This commit is contained in:
Zukero
2017-10-31 18:26:11 +01:00
parent 6cfe381b84
commit a8b24abb39
19 changed files with 830 additions and 401 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -8,6 +8,14 @@
android:layout_height="match_parent"
layout="@layout/title_bg_layout" />
<TextView
android:id="@+id/startscreen_version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="@android:string/unknownName" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -21,11 +29,10 @@
android:id="@+id/startcreen_centerarea"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:layout_weight="0.4"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/startscreen_dev_version"
android:layout_width="match_parent"
@@ -37,85 +44,15 @@
android:visibility="gone" />
</LinearLayout>
<LinearLayout
<FrameLayout
android:id="@+id/startscreen_fragment_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:gravity="bottom|center_horizontal"
android:orientation="vertical" >
android:layout_weight="0.6"
android:gravity="bottom|center_horizontal" />
<TextView
android:id="@+id/startscreen_version"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_gravity="top|right"
android:gravity="top|right"
android:text="@android:string/unknownName" />
<TextView
android:id="@+id/startscreen_currenthero"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#BB1212FF"
android:gravity="center_horizontal"
android:text="@android:string/unknownName" />
<EditText
android:id="@+id/startscreen_enterheroname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:visibility="gone" />
<Button
android:id="@+id/startscreen_continue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/startscreen_continue" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal" >
<Button
android:id="@+id/startscreen_newgame"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/startscreen_newgame" />
<Button
android:id="@+id/startscreen_load"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/startscreen_load" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal" >
<Button
android:id="@+id/startscreen_preferences"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/menu_settings" />
<Button
android:id="@+id/startscreen_about"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/startscreen_about" />
</LinearLayout>
</LinearLayout>
<!-- <include layout="@layout/startscreen_mainmenu" />
</FrameLayout> -->
</LinearLayout>
</RelativeLayout>

View File

@@ -6,13 +6,13 @@
>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="80dp"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:id="@+id/heroinfo_worn_center"
>
<ImageView
android:id="@+id/heroinfo_inventory_heroicon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_margin="@dimen/boxshape_margin"
android:background="@drawable/ui_boxshape"
android:drawablePadding="@dimen/boxshape_margin"
android:gravity="top|start"
android:padding="@dimen/boxshape_margin" >
<RelativeLayout
android:id="@+id/save_preview_hero_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="top|start" >
<ImageView
android:id="@+id/save_preview_hero_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/save_preview_hero_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/save_preview_hero_icon"
android:gravity="top|start"
android:text="@android:string/unknownName" />
</RelativeLayout>
<Button
android:id="@+id/startscreen_continue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/save_preview_hero_info"
android:layout_marginTop="10dp"
android:text="@string/startscreen_continue" />
</RelativeLayout>

View File

@@ -5,6 +5,14 @@
<include layout="@layout/title_bg_layout" />
<TextView
android:id="@+id/startscreen_version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="@android:string/unknownName" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -18,104 +26,26 @@
android:layout_height="wrap_content"
android:layout_weight="1" >
<LinearLayout
android:id="@+id/startcreen_centerarea"
<TextView
android:id="@+id/startscreen_dev_version"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="15dp"
android:background="#FFFFFFFF"
android:gravity="center_horizontal"
android:orientation="vertical" >
<!--
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/andors_trail_logo"
/>
-->
<TextView
android:id="@+id/startscreen_dev_version"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="#FFFFFFFF"
android:gravity="center_horizontal"
android:textColor="#880000"
android:visibility="gone" />
</LinearLayout>
<TextView
android:id="@+id/startscreen_version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="@android:string/unknownName" />
android:textColor="#880000"
android:visibility="gone" />
</RelativeLayout>
<TextView
android:id="@+id/startscreen_currenthero"
<FrameLayout
android:id="@+id/startscreen_fragment_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#BB1212FF"
android:gravity="center_horizontal"
android:text="@android:string/unknownName" />
android:layout_height="wrap_content" />
<EditText
android:id="@+id/startscreen_enterheroname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:visibility="gone" />
<Button
android:id="@+id/startscreen_continue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/startscreen_continue" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal" >
<Button
android:id="@+id/startscreen_newgame"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/startscreen_newgame" />
<Button
android:id="@+id/startscreen_load"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/startscreen_load" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal" >
<Button
android:id="@+id/startscreen_preferences"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/menu_settings" />
<Button
android:id="@+id/startscreen_about"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/startscreen_about" />
</LinearLayout>
<!-- <include layout="@layout/startscreen_mainmenu" />
</FrameLayout> -->
</LinearLayout>
</RelativeLayout>

View File

@@ -0,0 +1,62 @@
<?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:gravity="bottom"
android:orientation="vertical" >
<!-- <TextView
android:id="@+id/startscreen_currenthero"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#BB1212FF"
android:gravity="center_horizontal"
android:text="@android:string/unknownName" /> -->
<include layout="@layout/save_preview"
android:id="@+id/save_preview_holder"
android:visibility="gone"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal" >
<Button
android:id="@+id/startscreen_newgame"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/startscreen_newgame" />
<Button
android:id="@+id/startscreen_load"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/startscreen_load" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal" >
<Button
android:id="@+id/startscreen_preferences"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/menu_settings" />
<Button
android:id="@+id/startscreen_about"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/startscreen_about" />
</LinearLayout>
</LinearLayout>

View File

@@ -0,0 +1,108 @@
<?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:gravity="bottom"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/boxshape_margin"
android:background="@drawable/ui_boxshape"
android:drawablePadding="@dimen/boxshape_margin"
android:gravity="bottom|start"
android:padding="@dimen/boxshape_margin"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:text="@string/startscreen_selectherosprite" />
<RadioGroup
android:id="@+id/newgame_spritegroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ToggleButton
android:id="@+id/newgame_sprite0"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text=""
android:textSize="0dp"
android:drawableTop="@drawable/char_hero"
android:checked="true"/>
<ToggleButton
android:id="@+id/newgame_sprite1"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text=""
android:textSize="0dp"
android:drawableTop="@drawable/char_hero_maksiu_girl_01"/>
<ToggleButton
android:id="@+id/newgame_sprite2"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text=""
android:textSize="0dp"
android:drawableTop="@drawable/char_hero_maksiu_boy_01"/>
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/boxshape_margin"
android:background="@drawable/ui_boxshape"
android:drawablePadding="@dimen/boxshape_margin"
android:gravity="bottom|start"
android:padding="@dimen/boxshape_margin"
android:orientation="vertical" >
<TextView
android:id="@+id/startscreen_currenthero"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:text="@string/startscreen_enterheroname" />
<EditText
android:id="@+id/startscreen_enterheroname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal" >
<Button
android:id="@+id/startscreen_newgame_cancel"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/startscreen_newgame_cancel" />
<Button
android:id="@+id/startscreen_newgame_start"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/startscreen_newgame_start" />
</LinearLayout>
</LinearLayout>

View File

@@ -133,8 +133,11 @@
<string name="startscreen_continue">Continue current game</string>
<string name="startscreen_newgame">New game</string>
<string name="startscreen_newgame_start">Start game</string>
<string name="startscreen_newgame_cancel">Cancel</string>
<string name="startscreen_newgame_confirm">You will lose your current game and your current character, are you sure you want to start a new game?</string>
<string name="startscreen_about">About/help</string>
<string name="startscreen_selectherosprite">Choose your hero</string>
<string name="startscreen_enterheroname">Enter hero name</string>
<string name="startscreen_load">Load</string>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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<Integer> preloadedTileIDs = new HashSet<Integer>();
@@ -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);

View File

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