Merge branch 'reduce-warnings'

This commit is contained in:
Oskar Wiksten
2013-11-03 15:07:13 +01:00
23 changed files with 44 additions and 102 deletions

View File

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FF0000FF"/>
<stroke android:width="4dp" android:color="#FFFFFFFF"
android:dashWidth="1dp" android:dashGap="2dp" />
<padding android:left="7dp" android:top="7dp"
android:right="7dp" android:bottom="7dp" />
<corners android:radius="4dp" />
</shape>

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background" android:drawable="@drawable/ui_bar_background">
</item>
<item android:id="@android:id/secondaryProgress">
<clip android:drawable="@drawable/ui_bar_background" />
</item>
<item android:id="@android:id/progress">
<clip android:drawable="@drawable/ui_purple_foreground" />
</item>
</layer-list>

View File

@@ -35,7 +35,7 @@
android:id="@+id/about_version"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="version"
android:text="@android:string/unknownName"
/>
</LinearLayout>
</LinearLayout>

View File

@@ -25,7 +25,7 @@
android:layout_height="wrap_content"
style="@style/titleWithIcon"
android:drawableLeft="@drawable/char_hero"
android:text="Name"
android:text="@android:string/unknownName"
/>
<TableLayout
@@ -35,12 +35,12 @@
<TableRow>
<TextView style="@style/traitsinfo_label" android:text="@string/heroinfo_level" />
<TextView android:id="@+id/heroinfo_level" android:text="1" />
<TextView android:id="@+id/heroinfo_level" android:text="@android:string/unknownName" />
</TableRow>
<TableRow>
<TextView style="@style/traitsinfo_label" android:text="@string/heroinfo_totalexperience" />
<TextView android:id="@+id/heroinfo_totalexperience" android:text="1" />
<TextView android:id="@+id/heroinfo_totalexperience" android:text="@android:string/unknownName" />
</TableRow>
</TableLayout>

View File

@@ -5,5 +5,5 @@
android:layout_height="wrap_content"
style="@style/textWithIcon"
android:drawableLeft="@drawable/equip_weapon"
android:text="Name"
android:text="@android:string/unknownName"
/>

View File

@@ -36,7 +36,7 @@
android:id="@+id/loadsave_slot_n"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="1."
android:text="@android:string/unknownName"
/>
<Button
android:id="@+id/loadsave_save_to_new_slot"

View File

@@ -29,7 +29,7 @@
android:id="@+id/startscreen_currenthero"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hero name"
android:text="@android:string/unknownName"
/>
<EditText
android:id="@+id/startscreen_enterheroname"
@@ -57,7 +57,7 @@
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:text="v0.0.1"
android:text="@android:string/unknownName"
/>
</RelativeLayout>

View File

@@ -3,7 +3,7 @@
<resources>
<!-- Do not translate this. -->
<string name="about_copyright">Copyright (C) 2010-2013 Oskar Wiksten&lt;br /&gt;&lt;br /&gt;</string>
<string name="about_copyright">Copyright © 20102013 Oskar Wiksten&lt;br /&gt;&lt;br /&gt;</string>
<string name="about_authors">
Programming by Oskar Wiksten&lt;br /&gt;
&lt;a href="http://andorstrail.com/"&gt;Web site provided by Scott Devaney&lt;/a&gt;&lt;br /&gt;

View File

@@ -4,19 +4,15 @@
<string name="app_name">Andor\'s Trail</string>
<string name="app_description">Quest-driven fantasy RPG</string>
<string name="exit">Exit</string>
<string name="exit_to_menu">Exit to menu</string>
<string name="menu_pause">Pause</string>
<string name="menu_settings">Preferences</string>
<string name="menu_save">Save</string>
<string name="menu_load">Load</string>
<string name="menu_save_gamesaved">Game was saved to slot %1$d</string>
<string name="menu_save_failed">Failed to save game! Is the SD card mounted and writable?</string>
<string name="loadsave_title_save">Save game</string>
<string name="loadsave_title_load">Load saved game</string>
<string name="loadsave_selectslot">Select slot</string>
<string name="loadsave_slot_empty">(empty)</string>
<string name="savegame_currenthero_displayinfo">level %1$d, %2$d exp, %3$d gold</string>
<string name="dialog_loading_message">Loading resources…</string>
@@ -26,27 +22,17 @@
<string name="dialog_close">Close</string>
<string name="dialog_confirmexit_title">Exit</string>
<string name="dialog_confirmexit_message">Are you sure you want to exit?</string>
<string name="dialog_paused_title">Paused</string>
<string name="dialog_paused_message">Game is paused</string>
<string name="dialog_paused_resume">Resume</string>
<string name="dialog_monsterencounter_title">Encounter</string>
<string name="dialog_monsterencounter_message">Do you want to attack?\nDifficulty: %1$s</string>
<string name="dialog_monsterencounter_info">Info</string>
<string name="status_hp">HP:</string>
<string name="status_mp">MP:</string>
<string name="status_ap">AP:</string>
<string name="status_exp">Level:</string>
<string name="heroinfo_char">Overview</string>
<string name="heroinfo_inv">Items</string>
<string name="heroinfo_wear">Equipped</string>
<string name="heroinfo_skill">Skills</string>
<string name="heroinfo_spell">Spells</string>
<string name="heroinfo_levelup">Level up</string>
<string name="heroinfo_level">Level</string>
<string name="heroinfo_totalexperience">Total experience</string>
@@ -59,7 +45,6 @@
<string name="combat_attack">Attack (%1$d AP)</string>
<string name="combat_move">Move (%1$d AP)</string>
<string name="combat_use">Use item</string>
<string name="combat_spell">Spell</string>
<string name="combat_endturn">End turn</string>
<!-- <string name="combat_endcombat">End combat</string>-->
<string name="combat_flee">Flee</string>
@@ -108,10 +93,7 @@
<string name="actorinfo_class">Class:</string>
<string name="actorinfo_difficulty">Difficulty:</string>
<string name="actorinfo_health">Health:</string>
<string name="actorinfo_attacksperturn">Attacks/turn:</string>
<string name="actorinfo_movesperturn">Movement/turn:</string>
<string name="actorinfo_attack">Attack:</string>
<string name="actorinfo_criticalhit">Critical hit:</string>
<string name="actorinfo_defense">Defense:</string>
<string name="actorinfo_movecost">Move cost (AP):</string>
<string name="actorinfo_basetraits">Base combat statistics (without equipment and skills)</string>
@@ -135,18 +117,6 @@
<string name="iteminfo_action_equip_ap">Equip (%1$d AP)</string>
<string name="iteminfo_action_unequip_ap">Unequip (%1$d AP)</string>
<string name="itemcategory_money">Money</string>
<string name="itemcategory_weapon">Weapon</string>
<string name="itemcategory_shield">Shield</string>
<string name="itemcategory_wearable_head">Wearable (head)</string>
<string name="itemcategory_wearable_body">Wearable (body)</string>
<string name="itemcategory_wearable_hand">Wearable (hands)</string>
<string name="itemcategory_wearable_feet">Wearable (feet)</string>
<string name="itemcategory_wearable_neck">Wearable (neck)</string>
<string name="itemcategory_wearable_ring">Wearable (ring)</string>
<string name="itemcategory_potion">Potion</string>
<string name="itemcategory_other">Other</string>
<string name="startscreen_continue">Continue current game</string>
<string name="startscreen_newgame">New game</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>
@@ -228,7 +198,6 @@
Thanks for all the feedback!
</string>
<string name="questlog_title">Quests</string>
<string name="questlog_includecompleted_prompt">Select quests to show</string>
<string name="questlog_includecompleted_hidecompleted">Hide completed quests</string>
<string name="questlog_includecompleted_includecompleted">Include completed quests</string>

View File

@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="translucent_black">#80000000</color>
<color name="displayworldmap_background">#423921</color>
</resources>

View File

@@ -26,7 +26,7 @@ public final class WorldSetup {
public int loadFromSlot = Savegames.SLOT_QUICKSAVE;
public boolean isSceneReady = false;
public String newHeroName;
private int loadResult;
private Savegames.LoadSavegameResult loadResult;
public WorldSetup(WorldContext world, ControllerContext controllers, Context androidContext) {
this.world = world;
@@ -105,7 +105,7 @@ public final class WorldSetup {
if (world.model != null) world.resetForNewGame();
if (createNewCharacter) {
createNewWorld();
loadResult = Savegames.LOAD_RESULT_SUCCESS;
loadResult = Savegames.LoadSavegameResult.success;
} else {
loadResult = continueWorld();
}
@@ -126,7 +126,7 @@ public final class WorldSetup {
onSceneLoadedListener = null;
if (o == null) return;
if (loadResult == Savegames.LOAD_RESULT_SUCCESS) {
if (loadResult == Savegames.LoadSavegameResult.success) {
o.onSceneLoaded();
} else {
o.onSceneLoadFailed(loadResult);
@@ -136,7 +136,7 @@ public final class WorldSetup {
}).execute();
}
private int continueWorld() {
private Savegames.LoadSavegameResult continueWorld() {
Context ctx = androidContext.get();
return Savegames.loadWorld(world, controllers, ctx, loadFromSlot);
}
@@ -154,7 +154,7 @@ public final class WorldSetup {
public interface OnSceneLoadedListener {
void onSceneLoaded();
void onSceneLoadFailed(int loadResult);
void onSceneLoadFailed(Savegames.LoadSavegameResult loadResult);
}
public interface OnResourcesLoadedListener {
void onResourcesLoaded();

View File

@@ -49,7 +49,7 @@ public final class ConversationActivity
private WorldContext world;
private Player player;
private ArrayList<ConversationStatement> conversationHistory = new ArrayList<ConversationStatement>();
private final ArrayList<ConversationStatement> conversationHistory = new ArrayList<ConversationStatement>();
private ConversationController.ConversationStatemachine conversationState;
private StatementContainerAdapter listAdapter;

View File

@@ -58,7 +58,7 @@ public final class LoadSaveActivity extends Activity implements OnClickListener
slotList.removeView(slotTemplateButton);
slotList.removeView(createNewSlot);
addSavegameSlotButtons(slotList, params, Savegames.getUsedSavegameSlots(this));
addSavegameSlotButtons(slotList, params, Savegames.getUsedSavegameSlots());
if (!isLoading) {
Button b = new Button(this);
@@ -86,7 +86,7 @@ public final class LoadSaveActivity extends Activity implements OnClickListener
public void loadsave(int slot) {
if (slot == SLOT_NUMBER_CREATE_NEW_SLOT) {
List<Integer> usedSlots = Savegames.getUsedSavegameSlots(this);
List<Integer> usedSlots = Savegames.getUsedSavegameSlots();
if (usedSlots.isEmpty()) slot = SLOT_NUMBER_FIRST_SLOT;
else slot = Collections.max(usedSlots) + 1;
}

View File

@@ -55,9 +55,9 @@ public final class LoadingActivity extends Activity implements OnResourcesLoaded
}
@Override
public void onSceneLoadFailed(int loadResult) {
public void onSceneLoadFailed(Savegames.LoadSavegameResult loadResult) {
progressDialog.dismiss();
if (loadResult == Savegames.LOAD_RESULT_FUTURE_VERSION) {
if (loadResult == Savegames.LoadSavegameResult.savegameIsFromAFutureVersion) {
showLoadingFailedDialog(R.string.dialog_loading_failed_incorrectversion);
} else {
showLoadingFailedDialog(R.string.dialog_loading_failed_message);

View File

@@ -22,7 +22,7 @@ import com.gpl.rpg.AndorsTrail.savegames.Savegames.FileHeader;
public final class StartScreenActivity extends Activity {
public static final int INTENTREQUEST_PREFERENCES = 7;
private static final int INTENTREQUEST_PREFERENCES = 7;
public static final int INTENTREQUEST_LOADGAME = 9;
private boolean hasExistingGame = false;
@@ -161,7 +161,7 @@ public final class StartScreenActivity extends Activity {
Dialogs.showNewVersion(this);
}
boolean hasSavegames = !Savegames.getUsedSavegameSlots(this).isEmpty();
boolean hasSavegames = !Savegames.getUsedSavegameSlots().isEmpty();
startscreen_load.setEnabled(hasSavegames);
}

View File

@@ -283,7 +283,7 @@ public final class ConversationController {
private String phraseID;
private Phrase currentPhrase;
private Monster npc;
public ConversationStateListener listener;
public final ConversationStateListener listener;
public ConversationStatemachine(WorldContext world, ControllerContext controllers, ConversationStateListener listener) {
this.world = world;

View File

@@ -11,7 +11,6 @@ public class PathFinder {
private final boolean visited[];
private final ListOfCoords visitQueue;
private final EvaluateWalkable map;
public int iterations = 0;
public PathFinder(int maxWidth, int maxHeight, EvaluateWalkable map) {
this.maxWidth = maxWidth;
@@ -26,7 +25,7 @@ public class PathFinder {
}
public boolean findPathBetween(final CoordRect from, final Coord to, CoordRect nextStep) {
iterations = 0;
int iterations = 0;
if (from.equals(to)) return false;
Coord measureDistanceTo = from.topLeft;

View File

@@ -26,7 +26,7 @@ public final class MapObject {
public final String id; //placeName on this map or phraseID
public final String map;
public final String place;
public final String group;
private final String group;
public final Requirement enteringRequirement;
public final DropList dropList;
public final MapObjectEvaluationType evaluateWhen;

View File

@@ -21,7 +21,7 @@ public final class MonsterSpawnArea {
public final String[] monsterTypeIDs;
public final ArrayList<Monster> monsters = new ArrayList<Monster>();
public final boolean isUnique; // unique == non-respawnable
public final String group;
private final String group;
public boolean isSpawning;
public final boolean isSpawningForNewGame;

View File

@@ -8,7 +8,7 @@ public final class ReplaceableMapSection {
public final CoordRect replacementArea;
public final MapSection replaceLayersWith;
public final QuestProgress requireQuestStage;
public final String group;
private final String group;
public ReplaceableMapSection(
CoordRect replacementArea

View File

@@ -19,6 +19,11 @@ public abstract class JsonArrayParserFor<T> extends JsonParserFor<T> {
final ArrayList<T> arrayList = new ArrayList<T>(array.length());
parseRows(array, arrayList);
if (arrayList.isEmpty()) return null;
return arrayList.toArray((T[]) Array.newInstance(classType, arrayList.size()));
return arrayList.toArray(newArray(arrayList.size()));
}
@SuppressWarnings("unchecked")
private T[] newArray(int size) {
return (T[]) Array.newInstance(classType, size);
}
}

View File

@@ -163,10 +163,6 @@ public final class TileManager {
public void setImageViewTile(ImageView imageView, ActorConditionType conditionType) { imageView.setImageBitmap(preloadedTiles.getBitmap(conditionType.iconID)); }
public void setImageViewTileForUIIcon(ImageView imageView, int iconID) { imageView.setImageBitmap(preloadedTiles.getBitmap(iconID)); }
public void setImageViewTileForSingleItemType(Resources res, ImageView imageView, ItemType itemType) {
final Bitmap icon = tileCache.loadSingleTile(itemType.iconID, res);
setImageViewTile(res, imageView, itemType, icon);
}
public void setImageViewTile(Resources res, ImageView imageView, ItemType itemType, TileCollection itemTileCollection) {
final Bitmap icon = itemTileCollection.getBitmap(itemType.iconID);
setImageViewTile(res, imageView, itemType, icon);

View File

@@ -20,9 +20,11 @@ import java.util.regex.Pattern;
public final class Savegames {
public static final int SLOT_QUICKSAVE = 0;
public static final int LOAD_RESULT_SUCCESS = 0;
public static final int LOAD_RESULT_UNKNOWN_ERROR = 1;
public static final int LOAD_RESULT_FUTURE_VERSION = 2;
public static enum LoadSavegameResult {
success
, unknownError
, savegameIsFromAFutureVersion
}
public static boolean saveWorld(WorldContext world, Context androidContext, int slot, String displayInfo) {
try {
@@ -42,10 +44,10 @@ public final class Savegames {
return false;
}
}
public static int loadWorld(WorldContext world, ControllerContext controllers, Context androidContext, int slot) {
public static LoadSavegameResult loadWorld(WorldContext world, ControllerContext controllers, Context androidContext, int slot) {
try {
FileInputStream fos = getInputFile(androidContext, slot);
int result = loadWorld(androidContext.getResources(), world, controllers, fos);
LoadSavegameResult result = loadWorld(androidContext.getResources(), world, controllers, fos);
fos.close();
return result;
} catch (IOException e) {
@@ -56,7 +58,7 @@ public final class Savegames {
e.printStackTrace(pw);
L.log("Load error: " + sw.toString());
}
return LOAD_RESULT_UNKNOWN_ERROR;
return LoadSavegameResult.unknownError;
}
}
@@ -99,10 +101,10 @@ public final class Savegames {
dest.close();
}
public static int loadWorld(Resources res, WorldContext world, ControllerContext controllers, InputStream inState) throws IOException {
public static LoadSavegameResult loadWorld(Resources res, WorldContext world, ControllerContext controllers, InputStream inState) throws IOException {
DataInputStream src = new DataInputStream(inState);
final FileHeader header = new FileHeader(src);
if (header.fileversion > AndorsTrailApplication.CURRENT_VERSION) return LOAD_RESULT_FUTURE_VERSION;
if (header.fileversion > AndorsTrailApplication.CURRENT_VERSION) return LoadSavegameResult.savegameIsFromAFutureVersion;
world.maps.readFromParcel(src, world, controllers, header.fileversion);
world.model = new ModelContainer(src, world, controllers, header.fileversion);
@@ -110,7 +112,7 @@ public final class Savegames {
onWorldLoaded(res, world, controllers);
return LOAD_RESULT_SUCCESS;
return LoadSavegameResult.success;
}
private static void onWorldLoaded(Resources res, WorldContext world, ControllerContext controllers) {
@@ -138,7 +140,7 @@ public final class Savegames {
}
private static final Pattern savegameFilenamePattern = Pattern.compile(Constants.FILENAME_SAVEGAME_FILENAME_PREFIX + "(\\d+)");
public static List<Integer> getUsedSavegameSlots(Context androidContext) {
public static List<Integer> getUsedSavegameSlots() {
try {
final List<Integer> result = new ArrayList<Integer>();
getSavegameDirectory().listFiles(new FilenameFilter() {
@@ -164,12 +166,6 @@ public final class Savegames {
public final String playerName;
public final String displayInfo;
public FileHeader(String playerName, String displayInfo) {
this.fileversion = AndorsTrailApplication.CURRENT_VERSION;
this.playerName = playerName;
this.displayInfo = displayInfo;
}
public String describe() {
return playerName + ", " + displayInfo;
}