André Schnabel avatar André Schnabel committed d7eb6aa Draft

Tweaks for iOS release

Comments (0)

Files changed (7)

XNAPlayground/XNAPlayground/Map/GameMap.cs

 using System.IO;
 using Microsoft.Xna.Framework;
+using System.IO.IsolatedStorage;
 
 namespace XNAPlayground.Map {
 	internal class GameMap {
 		public static void LoadMapInfos() {
 			MapInfo[] infos = MapInfos;
 
+			var store = IsolatedStorageFile.GetUserStoreForApplication();
+
 			for(int i = 0; i < infos.Length; i++) {
 				infos[i] = new MapInfo(false, 0);
 			}
-#if WINDOWS
+
 			int counter = 0;
-			if(File.Exists(SaveFilename)) {
-				string fstr = File.ReadAllText(SaveFilename);
+			if(store.FileExists(SaveFilename)) {
+				var strm = new IsolatedStorageFileStream(SaveFilename, FileMode.Open, store);
+				var reader = new StreamReader(strm);
+
+				string fstr = reader.ReadToEnd(); //File.ReadAllText(SaveFilename);
 				string[] lines = fstr.Split('\n');
 				foreach(string line in lines) {
 					if(counter >= infos.Length) break;
 					infos[counter].TicksNeeded = long.Parse(parts[1]);
 					counter++;
 				}
+
+				reader.Dispose();
+				strm.Dispose();
 			}
-#endif
+
+			store.Dispose();
 		}
 
 		public static void SaveMapInfos() {
-#if WINDOWS
+
+			var store = IsolatedStorageFile.GetUserStoreForApplication();
+
+			var strm = new IsolatedStorageFileStream(SaveFilename, FileMode.Create, store);
+			var writer = new StreamWriter(strm);
+
 			var mapInfoStr = "";
 			foreach(MapInfo info in MapInfos) {
 				mapInfoStr += (info.Finished) ? "yes" : "no";
 				mapInfoStr += "\n";
 			}
 
-			File.WriteAllText(SaveFilename, mapInfoStr);
-#endif
+			//File.WriteAllText(SaveFilename, mapInfoStr);
+			writer.Write(mapInfoStr);
+
+			writer.Dispose();
+			strm.Dispose();
+
+			store.Dispose();
 		}
 	}
 }

XNAPlayground/XNAPlayground/Screens/MainScreen.cs

 			}
 		}
 
+		private const int BackButtonW = 200;
+		private const int BackButtonH = 30;
+
 		private void ProcessInput(float delta) {
 #if WINDOWS_PHONE || IOS
 			bool leftBorder = false, rightBorder = false;
 				var x = (int)(touchLocation.Position.X * 800.0f / Globals.ActualScrW);
 				var y = (int)(touchLocation.Position.Y * 480.0f / Globals.ActualScrH);
 
-				if(y < 50) {
+				if(x > 400.0f - BackButtonW / 2.0f && x < 400.0f + BackButtonW / 2.0f && y < BackButtonH) {
 					Game.SetScreen(new WorldScreen(Game));
 				}
 
 			var sinVal = (float)Math.Sin(MathHelper.ToRadians(coinCtr += 200f * Utils.GetDeltaTime()));
 			float rotZ = sinVal < 0.0f ? 180.0f : 0.0f;
 			float xOffset = (sinVal < 0.0f ? -coinW : 0.0f) + coinW / 2.0f;
+			xOffset = 0.0f;
 			foreach(Vector2 coinPos in coinPositions) {
 				sb.Draw(coinRegion, coinPos.X + xOffset, coinPos.Y, coinW/2.0f, coinH/2.0f, coinW, coinH, (float) Math.Abs(sinVal), 1.0f, rotZ);
 			}
 
 			sb.Draw("Score: " + score, Globals.ScrW - 130, Globals.ScrH - 10, Color.Black);
 			sb.Draw("Score: " + score, Globals.ScrW - 131, Globals.ScrH - 11, Color.Yellow);
+
+			sb.Draw (Utils.GetRegion("button"), 400.0f - BackButtonW / 2.0f, 480.0f - BackButtonH, BackButtonW, BackButtonH);
 		}
 
 		public static string GenTimeStr(long msecs) {

XNAPlayground/XNAPlayground/Screens/WorldScreen.cs

 				if(touchCollection.Count > 0 && touchCollection[0].State != TouchLocationState.Released) {
 					x = (int)(touchCollection[0].Position.X * 800.0f / Globals.ActualScrW);
 					y = (int)(touchCollection[0].Position.Y * 480.0f / Globals.ActualScrH);
+					y = Globals.ScrH - y;
 				} else return;
 #else
 				if(Mouse.GetState().LeftButton == ButtonState.Released) {

XNAPlayground/XNAPlayground/Utilities/Utils.cs

 using System;
 using Microsoft.Xna.Framework;
+using System.IO.IsolatedStorage;
 
 namespace XNAPlayground.Utilities {
 	internal static class Utils {
+
 		public static Random Rand = new Random();
 
 		public static Rectangle GetRegion(string name) {

XNAPlaygroundTouch/Info.plist

 	</array>
 	<key>UISupportedInterfaceOrientations</key>
 	<array>
+		<string>UIInterfaceOrientationLandscapeLeft</string>
 		<string>UIInterfaceOrientationLandscapeRight</string>
 	</array>
 	<key>UISupportedInterfaceOrientations~ipad</key>
 	<array>
+		<string>UIInterfaceOrientationLandscapeLeft</string>
 		<string>UIInterfaceOrientationLandscapeRight</string>
 	</array>
 </dict>

XNAPlaygroundTouch/XNAPlaygroundTouch.csproj

     <MtouchDebug>true</MtouchDebug>
     <MtouchProfiling>true</MtouchProfiling>
     <MtouchI18n />
+    <IpaPackageName />
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
     <DebugType>none</DebugType>

XNAPlaygroundTouch/XNAPlaygroundTouch.sln

 	EndGlobalSection
 	GlobalSection(MonoDevelopProperties) = preSolution
 		StartupItem = XNAPlaygroundTouch.csproj
+		Policies = $0
+		$0.DotNetNamingPolicy = $1
+		$1.DirectoryNamespaceAssociation = None
+		$1.ResourceNamePolicy = FileFormatDefault
+		$0.TextStylePolicy = $2
+		$2.inheritsSet = null
+		$2.scope = text/x-csharp
+		$0.CSharpFormattingPolicy = $3
+		$3.inheritsSet = Mono
+		$3.inheritsScope = text/x-csharp
+		$3.scope = text/x-csharp
+		$0.TextStylePolicy = $4
+		$4.FileWidth = 120
+		$4.TabsToSpaces = False
+		$4.EolMarker = Windows
+		$4.inheritsSet = VisualStudio
+		$4.inheritsScope = text/plain
+		$4.scope = text/plain
+		$0.TextStylePolicy = $5
+		$5.inheritsSet = null
+		$5.scope = text/html
+		$0.StandardHeader = $6
+		$6.Text = 
+		$6.IncludeInNewFiles = True
 	EndGlobalSection
 EndGlobal
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.