Added two default teams to the apk, so people who first download it don't have to make two teams before playing their first game hedgeroid
authorXeli
Fri, 21 Oct 2011 00:28:06 +0200
branchhedgeroid
changeset 6051 88fb92444d19
parent 6049 7bc38086d771
child 6053 39d763049c0f
Added two default teams to the apk, so people who first download it don't have to make two teams before playing their first game
project_files/Android-build/SDL-android-project/res/raw/team_one.xml
project_files/Android-build/SDL-android-project/res/raw/team_two.xml
project_files/Android-build/SDL-android-project/res/values/frontend_data_pointers.xml
project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/StartGameActivity.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/res/raw/team_one.xml	Fri Oct 21 00:28:06 2011 +0200
@@ -0,0 +1,49 @@
+<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
+<team>
+  <name>Team 1</name>
+  <flag>cm_cog</flag>
+  <fort>Cake</fort>
+  <grave>coffin</grave>
+  <voice>Classic</voice>
+  <hash>0</hash>
+  <hog>
+    <name>Leonidas</name>
+    <hat>spartan</hat>
+    <level>0</level>
+  </hog>
+  <hog>
+    <name>Pipo</name>
+    <hat>clown-copper</hat>
+    <level>0</level>
+  </hog>
+  <hog>
+    <name>Sonic</name>
+    <hat>Sonic</hat>
+    <level>0</level>
+  </hog>
+  <hog>
+    <name>Xin</name>
+    <hat>StrawHat</hat>
+    <level>0</level>
+  </hog>
+  <hog>
+    <name>Arnold</name>
+    <hat>cyborg</hat>
+    <level>0</level>
+  </hog>
+  <hog>
+    <name>Jack</name>
+    <hat>Pumpkin_Hat</hat>
+    <level>0</level>
+  </hog>
+  <hog>
+    <name>Tom</name>
+    <hat>Samurai</hat>
+    <level>0</level>
+  </hog>
+  <hog>
+    <name>Goldie</name>
+    <hat>diglett</hat>
+    <level>0</level>
+  </hog>
+</team>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/res/raw/team_two.xml	Fri Oct 21 00:28:06 2011 +0200
@@ -0,0 +1,49 @@
+<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
+<team>
+  <name>Team 2</name>
+  <flag>cm_42</flag>
+  <fort>Plane</fort>
+  <grave>pyramid</grave>
+  <voice>Singer</voice>
+  <hash>0</hash>
+  <hog>
+    <name>Paris</name>
+    <hat>pinksunhat</hat>
+    <level>3</level>
+  </hog>
+  <hog>
+    <name>Knut</name>
+    <hat>sth_Knux</hat>
+    <level>3</level>
+  </hog>
+  <hog>
+    <name>Ash</name>
+    <hat>RedCap</hat>
+    <level>3</level>
+  </hog>
+  <hog>
+    <name>Woad</name>
+    <hat>Toad</hat>
+    <level>3</level>
+  </hog>
+  <hog>
+    <name>Bob</name>
+    <hat>rasta</hat>
+    <level>3</level>
+  </hog>
+  <hog>
+    <name>Corky</name>
+    <hat>porkey</hat>
+    <level>3</level>
+  </hog>
+  <hog>
+    <name>Bea</name>
+    <hat>crown</hat>
+    <level>3</level>
+  </hog>
+  <hog>
+    <name>Silvia</name>
+    <hat>Rambo</hat>
+    <level>3</level>
+  </hog>
+</team>
\ No newline at end of file
--- a/project_files/Android-build/SDL-android-project/res/values/frontend_data_pointers.xml	Thu Oct 20 23:07:53 2011 +0200
+++ b/project_files/Android-build/SDL-android-project/res/values/frontend_data_pointers.xml	Fri Oct 21 00:28:06 2011 +0200
@@ -25,4 +25,10 @@
     <item>@raw/weapon_promode</item>
     <item>@raw/weapon_shoppa</item>
 </array>
+
+<array name="teams">
+	<item>@raw/team_one</item>
+	<item>@raw/team_two</item>
+
+</array>
 </resources>
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/StartGameActivity.java	Thu Oct 20 23:07:53 2011 +0200
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/StartGameActivity.java	Fri Oct 21 00:28:06 2011 +0200
@@ -28,9 +28,11 @@
 
 import android.app.Activity;
 import android.content.Intent;
+import android.content.SharedPreferences;
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.os.Parcelable;
+import android.preference.PreferenceManager;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.AdapterView;
@@ -53,11 +55,17 @@
 	public void onCreate(Bundle savedInstanceState){
 		super.onCreate(savedInstanceState);
 
-		//SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
+		SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
+		boolean firstTime = sharedPref.getBoolean("firstTime", true);
 		//Copy all the xml files to the device TODO only do first time launch of the app...
-		Utils.resRawToFilesDir(this,R.array.schemes, Scheme.DIRECTORY_SCHEME);
-		Utils.resRawToFilesDir(this, R.array.weapons, Weapon.DIRECTORY_WEAPON);
-		Scheme.parseBasicFlags(this);
+		if(firstTime){
+			sharedPref.edit().putBoolean("firstTime", false).commit();
+			
+			Utils.resRawToFilesDir(this,R.array.schemes, Scheme.DIRECTORY_SCHEME);
+			Utils.resRawToFilesDir(this, R.array.weapons, Weapon.DIRECTORY_WEAPON);
+			Utils.resRawToFilesDir(this, R.array.teams, Team.DIRECTORY_TEAMS);
+			Scheme.parseBasicFlags(this);
+		}
 
 		config = new GameConfig();
 
@@ -76,7 +84,7 @@
 		themeIcon = (ImageView) findViewById(R.id.imgTheme);
 		mapPreview = (ImageView) findViewById(R.id.mapPreview);
 		teamCount = (ImageView) findViewById(R.id.imgTeamsCount);
-		
+
 		start.setOnClickListener(startClicker);
 		back.setOnClickListener(backClicker);
 		team.setOnClickListener(teamClicker);
@@ -113,7 +121,7 @@
 		i.putParcelableArrayListExtra("teams", config.teams);
 		startActivityForResult(i, ACTIVITY_TEAM_SELECTOR);
 	}
-	
+
 	public void onActivityResult(int requestCode, int resultCode, Intent data){
 		switch(requestCode){
 		case ACTIVITY_TEAM_SELECTOR:
@@ -123,7 +131,7 @@
 				for(Parcelable t : parcelables){
 					config.teams.add((Team)t);
 				}
-                teamCount.getDrawable().setLevel(config.teams.size());
+				teamCount.getDrawable().setLevel(config.teams.size());
 			}
 			break;
 		}