tackling the iphoneos todo (another trial for the beginning sporadic bug, remove curl animation, don't need to go to detail page)
authorkoda
Sat, 03 Jul 2010 04:42:29 +0200
changeset 3616 85d69ddb41b6
parent 3615 b78d7959540a
child 3617 1df21e06b8ba
tackling the iphoneos todo (another trial for the beginning sporadic bug, remove curl animation, don't need to go to detail page)
hedgewars/uVisualGears.pas
project_files/HedgewarsMobile/Classes/CommodityFunctions.h
project_files/HedgewarsMobile/Classes/GameConfigViewController.m
project_files/HedgewarsMobile/Classes/GameSetup.h
project_files/HedgewarsMobile/Classes/GameSetup.m
project_files/HedgewarsMobile/Classes/MainMenuViewController.m
project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.h
project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m
--- a/hedgewars/uVisualGears.pas	Sat Jul 03 04:09:27 2010 +0200
+++ b/hedgewars/uVisualGears.pas	Sat Jul 03 04:42:29 2010 +0200
@@ -375,7 +375,7 @@
         begin
         Tint(Gear^.Tint);
         case Gear^.Kind of
-            vgtFlake: if ((cReducedQuality and rqkillFlakes) <> 0) then
+            vgtFlake: if ((cReducedQuality and rqkillFlakes) = 0) then
                         if vobVelocity = 0 then
                             DrawSprite(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
                         else
--- a/project_files/HedgewarsMobile/Classes/CommodityFunctions.h	Sat Jul 03 04:09:27 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/CommodityFunctions.h	Sat Jul 03 04:42:29 2010 +0200
@@ -13,8 +13,6 @@
 
 #define SETTINGS_FILE()         [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) \
                                  objectAtIndex:0] stringByAppendingString:@"/settings.plist"]
-#define GAMECONFIG_FILE()       [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) \
-                                 objectAtIndex:0] stringByAppendingString:@"/gameconfig.plist"]
 #define DEBUG_FILE()            [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) \
                                  objectAtIndex:0] stringByAppendingString:@"/debug.txt"]
 
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m	Sat Jul 03 04:09:27 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m	Sat Jul 03 04:42:29 2010 +0200
@@ -17,8 +17,7 @@
 
 
 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
-    // dirty trick to avoid rotating below the curl
-    return interfaceOrientation == self.parentViewController.interfaceOrientation;
+    return rotationManager(interfaceOrientation);
 }
 
 -(IBAction) buttonPressed:(id) sender {
@@ -88,7 +87,7 @@
     // play only if there is more than one team
     if ([teamConfigViewController.listOfSelectedTeams count] < 2) {
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Too few teams playing",@"")
-                                                        message:NSLocalizedString(@"You need to select at least two teams to play a game",@"")
+                                                        message:NSLocalizedString(@"Select at least two teams to play a game",@"")
                                                        delegate:nil
                                               cancelButtonTitle:NSLocalizedString(@"Ok, got it",@"")
                                               otherButtonTitles:nil];
@@ -104,7 +103,7 @@
 
     if (hogs > mapConfigViewController.maxHogs) {
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Too many hogs",@"")
-                                                        message:NSLocalizedString(@"The map you selected is too small for that many hogs",@"")
+                                                        message:NSLocalizedString(@"The map is too small for that many hogs",@"")
                                                        delegate:nil
                                               cancelButtonTitle:NSLocalizedString(@"Ok, got it",@"")
                                               otherButtonTitles:nil];
@@ -115,7 +114,7 @@
     
     if ([schemeWeaponConfigViewController.selectedScheme length] == 0 || [schemeWeaponConfigViewController.selectedWeapon length] == 0 ) {
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Missing detail",@"")
-                                                        message:NSLocalizedString(@"Make sure you selected one Scheme and one Weapon for this game",@"")
+                                                        message:NSLocalizedString(@"Select one Scheme and one Weapon for this game",@"")
                                                        delegate:nil
                                               cancelButtonTitle:NSLocalizedString(@"Ok, got it",@"")
                                               otherButtonTitles:nil];
@@ -125,7 +124,7 @@
     }
     
     // create the configuration file that is going to be sent to engine
-    NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:mapConfigViewController.seedCommand,@"seed_command",
+    NSDictionary *gameDictionary = [[NSDictionary alloc] initWithObjectsAndKeys:mapConfigViewController.seedCommand,@"seed_command",
                                                                       mapConfigViewController.templateFilterCommand,@"templatefilter_command",
                                                                       mapConfigViewController.mapGenCommand,@"mapgen_command",
                                                                       mapConfigViewController.mazeSizeCommand,@"mazesize_command",
@@ -134,12 +133,11 @@
                                                                       schemeWeaponConfigViewController.selectedScheme,@"scheme",
                                                                       schemeWeaponConfigViewController.selectedWeapon,@"weapon",
                                                                       nil];
-    [dict writeToFile:GAMECONFIG_FILE() atomically:YES];
-    [dict release];
 
     // finally launch game and remove this controller
     [[self parentViewController] dismissModalViewControllerAnimated:YES];
-    [[SDLUIKitDelegate sharedAppDelegate] startSDLgame];
+    [[SDLUIKitDelegate sharedAppDelegate] startSDLgame:gameDictionary];
+    [gameDictionary release];
 }
 
 -(void) viewDidLoad {
@@ -165,8 +163,12 @@
                 break;
             }
         }
-    } else
+    } else {
+        // this is the visible controller
         mapConfigViewController = [[MapConfigViewController alloc] initWithNibName:@"MapConfigViewController-iPhone" bundle:nil];
+        // this must be loaded to auto set default scheme and ammo
+        schemeWeaponConfigViewController = [[SchemeWeaponConfigViewController alloc] initWithStyle:UITableViewStyleGrouped];
+    }
     activeController = mapConfigViewController;
     
     [self.view addSubview:mapConfigViewController.view];
--- a/project_files/HedgewarsMobile/Classes/GameSetup.h	Sat Jul 03 04:09:27 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameSetup.h	Sat Jul 03 04:42:29 2010 +0200
@@ -20,6 +20,7 @@
 @property (nonatomic, retain) NSDictionary *systemSettings;
 @property (nonatomic, retain) NSDictionary *gameConfig;
 
+-(id) initWithDictionary:(NSDictionary *)gameDictionary;
 -(void) engineProtocol;
 -(void) startThread:(NSString *)selector;
 -(int)  sendToEngine:(NSString *)string;
--- a/project_files/HedgewarsMobile/Classes/GameSetup.m	Sat Jul 03 04:09:27 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameSetup.m	Sat Jul 03 04:42:29 2010 +0200
@@ -21,7 +21,7 @@
 
 @synthesize systemSettings, gameConfig;
 
--(id) init {
+-(id) initWithDictionary:(NSDictionary *)gameDictionary {
     if (self = [super init]) {
         ipcPort = randomPort();
         
@@ -30,9 +30,7 @@
         self.systemSettings = dictSett;
         [dictSett release];
         
-        NSDictionary *dictGame = [[NSDictionary alloc] initWithContentsOfFile:GAMECONFIG_FILE()];
-        self.gameConfig = dictGame;
-        [dictGame release];
+        self.gameConfig = gameDictionary;
     } 
     return self;
 }
@@ -336,7 +334,7 @@
                 break;
             default:
                 // empty packet or just statistics -- in either cases gameTicks is sent
-                //gameTicks = SDLNet_Read16 (&buffer[msgSize - 2]);
+                gameTicks = SDLNet_Read16 (&buffer[msgSize - 2]);
                 //DLog(@"engineProtocol - %d: received [%s]", gameTicks, buffer);
                 break;
         }
@@ -347,9 +345,7 @@
     // Close the client socket
     SDLNet_TCP_Close(csd);    
     SDLNet_Quit();
-    
-    [[NSFileManager defaultManager] removeItemAtPath:GAMECONFIG_FILE() error:NULL];
-    
+        
     [pool release];
     //Invoking this method should be avoided as it does not give your thread a chance to clean up any resources it allocated during its execution.
     //[NSThread exit];
--- a/project_files/HedgewarsMobile/Classes/MainMenuViewController.m	Sat Jul 03 04:09:27 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/MainMenuViewController.m	Sat Jul 03 04:42:29 2010 +0200
@@ -107,9 +107,6 @@
         case 0:
             gameConfigViewController = [[GameConfigViewController alloc] initWithNibName:@"GameConfigViewController" bundle:nil];        
 
-            // bug in UIModalTransitionStylePartialCurl, displays the controller awkwardly if it is not allocated every time            
-            if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
-                gameConfigViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;
             [self presentModalViewController:gameConfigViewController animated:YES];
             break;
         case 2:
--- a/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.h	Sat Jul 03 04:09:27 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.h	Sat Jul 03 04:42:29 2010 +0200
@@ -32,7 +32,7 @@
 }
 
 +(SDLUIKitDelegate *)sharedAppDelegate;
--(void) startSDLgame;
+-(void) startSDLgame:(NSDictionary *)gameDictionary;
 -(void) displayOverlayLater;
 
 @end
--- a/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m	Sat Jul 03 04:09:27 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m	Sat Jul 03 04:42:29 2010 +0200
@@ -75,14 +75,15 @@
 }
 
 // main routine for calling the actual game engine
--(IBAction) startSDLgame {
+-(IBAction) startSDLgame: (NSDictionary *)gameDictionary {
     [UIView beginAnimations:@"removing main controller" context:NULL];
     [UIView setAnimationDuration:1];
     mainViewController.view.alpha = 0;
     [UIView commitAnimations];
 
     // pull out useful configuration info from various files
-    GameSetup *setup = [[GameSetup alloc] init];
+    GameSetup *setup = [[GameSetup alloc] initWithDictionary:gameDictionary];
+    
     [setup startThread:@"engineProtocol"];
     const char **gameArgs = [setup getSettings];
     [setup release];
@@ -96,6 +97,7 @@
     isInGame = NO;
     free(gameArgs);
     
+    // bring the uiwindow below in front
     UIWindow *aWin = [[[UIApplication sharedApplication] windows] objectAtIndex:0];
     [aWin makeKeyAndVisible];
     aWin =  [[[UIApplication sharedApplication] windows] lastObject];