adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
authorkoda
Sat, 01 May 2010 21:54:08 +0000
changeset 3395 095273ad0e08
parent 3394 47b51e22e670
child 3396 e5b3e5f2818e
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
cocoaTouch/GameSetup.m
cocoaTouch/OverlayViewController.m
cocoaTouch/otherSrc/PascalImports.h
hedgewars/CCHandlers.inc
hedgewars/PascalExports.pas
hedgewars/uWorld.pas
project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj
--- a/cocoaTouch/GameSetup.m	Sat May 01 21:53:31 2010 +0000
+++ b/cocoaTouch/GameSetup.m	Sat May 01 21:54:08 2010 +0000
@@ -195,7 +195,7 @@
 				[self sendToEngine:[self.gameConfig objectForKey:@"seed_command"]];
 				
 				// various flags
-				[self sendToEngine:@"e$gmflags 8448"]; 
+				[self sendToEngine:@"e$gmflags 256"]; 
 				[self sendToEngine:@"e$damagepct 100"];
 				[self sendToEngine:@"e$turntime 45000"];
 				[self sendToEngine:@"e$minestime 3000"];
@@ -221,10 +221,10 @@
                 }
                 
                 NSDictionary *ammoData = [[NSDictionary alloc] initWithObjectsAndKeys:
-                                          @"9391929422199121032235111001201000000211190",@"ammostore_initialqt",
-                                          @"0405040541600655546554464776576666666155501",@"ammostore_probability",
-                                          @"0000000000000205500000040007004000000000200",@"ammostore_delay",
-                                          @"1311110312111111123114111111111111111211101",@"ammostore_crate", nil];
+                                          @"939192942219912103223511100120100000021119091",@"ammostore_initialqt",
+                                          @"040504054160065554655446477657666666615550100",@"ammostore_probability",
+                                          @"000000000000020550000004000700400000000020000",@"ammostore_delay",
+                                          @"131111031211111112311411111111111111121110111",@"ammostore_crate", nil];
                 [self sendAmmoData:ammoData forTeams:[teamsConfig count]];
                 [ammoData release];
                 
--- a/cocoaTouch/OverlayViewController.m	Sat May 01 21:53:31 2010 +0000
+++ b/cocoaTouch/OverlayViewController.m	Sat May 01 21:54:08 2010 +0000
@@ -32,28 +32,42 @@
 -(void) didRotate:(NSNotification *)notification {	
     UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
     CGRect rect = [[UIScreen mainScreen] bounds];
+    CGRect usefulRect = CGRectMake(0, 0, rect.size.width, rect.size.height);
+    UIView *sdlView = [[SDLUIKitDelegate sharedAppDelegate].uiwindow viewWithTag:SDL_VIEW_TAG];
     
-	if (orientation == UIDeviceOrientationLandscapeLeft) {
-        [UIView beginAnimations:@"flip1" context:NULL];
-        [UIView setAnimationDuration:0.8f];
-        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
-        [[SDLUIKitDelegate sharedAppDelegate].uiwindow viewWithTag:SDL_VIEW_TAG].transform = CGAffineTransformMakeRotation(degreesToRadian(0));
-        self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
-        self.view.frame = CGRectMake(0, 0, rect.size.width, rect.size.height);
-        [UIView commitAnimations];
-	} else
-        if (orientation == UIDeviceOrientationLandscapeRight) {
-            [UIView beginAnimations:@"flip2" context:NULL];
-            [UIView setAnimationDuration:0.8f];
-            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
-            [[SDLUIKitDelegate sharedAppDelegate].uiwindow viewWithTag:SDL_VIEW_TAG].transform = CGAffineTransformMakeRotation(degreesToRadian(180));
+    [UIView beginAnimations:@"rotation" context:NULL];
+    [UIView setAnimationDuration:0.8f];
+    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
+	switch (orientation) {
+        case UIDeviceOrientationLandscapeLeft:
+            sdlView.transform = CGAffineTransformMakeRotation(degreesToRadian(0));
+            self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
+            HW_setLandscape(YES);
+            break;
+        case UIDeviceOrientationLandscapeRight:
+            sdlView.transform = CGAffineTransformMakeRotation(degreesToRadian(180));
             self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
-            self.view.frame = CGRectMake(0, 0, rect.size.width, rect.size.height);
-            [UIView commitAnimations];
-        }
+            HW_setLandscape(YES);
+            break;
+        case UIDeviceOrientationPortrait:
+            sdlView.transform = CGAffineTransformMakeRotation(degreesToRadian(270));
+            self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(0));
+            HW_setLandscape(NO);
+            break;
+        case UIDeviceOrientationPortraitUpsideDown:
+            sdlView.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
+            self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(180));
+            HW_setLandscape(NO);
+            break;
+        default:
+            NSLog(@"warning - Unknown rotation status");
+            break;
+    }
+    self.view.frame = usefulRect;
+    sdlView.frame = usefulRect;
+    [UIView commitAnimations];
 }
 
-
 -(void) viewDidLoad {
 
     isPopoverVisible = NO;
--- a/cocoaTouch/otherSrc/PascalImports.h	Sat May 01 21:53:31 2010 +0000
+++ b/cocoaTouch/otherSrc/PascalImports.h	Sat May 01 21:54:08 2010 +0000
@@ -51,7 +51,7 @@
     
     void HW_terminate(BOOL);
 	
-    void HW_setRotationQt(float);
+    void HW_setLandscape(BOOL);
 #ifdef __cplusplus
 }
 #endif
--- a/hedgewars/CCHandlers.inc	Sat May 01 21:53:31 2010 +0000
+++ b/hedgewars/CCHandlers.inc	Sat May 01 21:54:08 2010 +0000
@@ -697,8 +697,7 @@
         SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN    
         {$IFDEF IPHONEOS} or SDL_WINDOW_BORDERLESS{$ENDIF});     
     SDL_CreateRenderer(window, -1, 0);
-    PixelFormat:= nil;   
-        
+    
     SDL_SetRenderDrawColor(0, 0, 0, 255);    
     SDL_RenderFill(nil);     
     SDL_RenderPresent();
--- a/hedgewars/PascalExports.pas	Sat May 01 21:53:31 2010 +0000
+++ b/hedgewars/PascalExports.pas	Sat May 01 21:54:08 2010 +0000
@@ -13,7 +13,7 @@
 unit PascalExports;
 
 interface
-uses uKeys, uConsole, hwengine;
+uses uKeys, uConsole, uStore, GLunit, uMisc, uWorld, hwengine;
 
 {$INCLUDE "config.inc"}
 
@@ -138,6 +138,26 @@
     isTerminated:= true;
     if closeFrontend then alsoShutdownFrontend:= true;
 end;
+
+procedure HW_setLandscape(landscape: boolean); cdecl; export;
+begin
+    if landscape then
+    begin
+        rotationQt:= -90;
+        uStore.wScreen:= cScreenWidth;
+        uStore.hScreen:= cScreenHeight;
+        //uWorld.w:= cScreenWidth;
+        //uWorld.h:= cScreenHeight;
+    end
+    else
+    begin
+        rotationQt:= 270;
+        uStore.wScreen:= cScreenHeight;
+        uStore.hScreen:= cScreenWidth;
+        //uWorld.w:= cScreenHeight;
+        //uWorld.h:= cScreenWidth;
+    end;
+end;
 {$ENDIF}
 
 end.
--- a/hedgewars/uWorld.pas	Sat May 01 21:53:31 2010 +0000
+++ b/hedgewars/uWorld.pas	Sat May 01 21:54:08 2010 +0000
@@ -172,6 +172,11 @@
 
 procedure ShowAmmoMenu;
 const MENUSPEED = 15;
+{$IFDEF IPHONEOS}
+const MENUWIDTH = 210;
+{$ELSE}
+const MENUWIDTH = 240;
+{$ENDIF}
 var x, y, i, t, l, g: LongInt;
     Slot, Pos: LongInt;
     Ammo: PHHAmmo;
@@ -180,7 +185,7 @@
 if bShowAmmoMenu then
    begin
    FollowGear:= nil;
-   if AMxShift = 210 then prevPoint.X:= 0;
+   if AMxShift = MENUWIDTH then prevPoint.X:= 0;
    if cReducedQuality then
        AMxShift:= 0
    else
@@ -195,9 +200,9 @@
       SDL_WarpMouse(CursorPoint.X  + cScreenWidth div 2, cScreenHeight - CursorPoint.Y)
       end;
    if cReducedQuality then
-       AMxShift:= 210
+       AMxShift:= MENUWIDTH
    else
-       if AMxShift < 210 then inc(AMxShift, MENUSPEED);
+       if AMxShift < MENUWIDTH then inc(AMxShift, MENUSPEED);
    end;
 Ammo:= nil;
 if (CurrentTeam <> nil) and (CurrentHedgehog <> nil) and (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then
@@ -212,24 +217,43 @@
     exit
     end;
 SlotsNum:= 0;
-x:= (cScreenWidth shr 1) - 210 + AMxShift;
+x:= (cScreenWidth shr 1) - MENUWIDTH + AMxShift;
 y:= cScreenHeight - 40;
+
+{$IFDEF IPHONEOS}
+dec(y);
+DrawSprite(sprAMBordersIPhone, x, y, 0);
+dec(y);
+DrawSprite(sprAMBordersIPhone, x, y, 1);
+dec(y, 33);
+DrawSprite(sprAMSlotNameIPhone, x, y, 0);
+{$ELSE}
 dec(y);
 DrawSprite(sprAMBorders, x, y, 0);
 dec(y);
 DrawSprite(sprAMBorders, x, y, 1);
 dec(y, 33);
 DrawSprite(sprAMSlotName, x, y, 0);
+{$ENDIF}
+
 for i:= cMaxSlotIndex downto 0 do
     if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
         begin
         if (cScreenHeight - CursorPoint.Y >= y - 33) and (cScreenHeight - CursorPoint.Y < y) then Slot:= i;
         dec(y, 33);
         inc(SlotsNum);
+        {$IFDEF IPHONEOS}
+        DrawSprite(sprAMSlotIPhone, x, y, 0);
+        {$ELSE}
         DrawSprite(sprAMSlot, x, y, 0);
         DrawSprite(sprAMSlotKeys, x + 2, y + 1, i);
+        {$ENDIF}
         t:= 0;
-                    g:= 0;
+        {$IFDEF IPHONEOS}
+        g:= -1;
+        {$ELSE}
+        g:= 0;
+        {$ENDIF}
         while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do
             begin
             if (Ammo^[i, t].AmmoType <> amNothing) then
@@ -255,7 +279,11 @@
             end
         end;
 dec(y, 1);
+{$IFDEF IPHONEOS}
+DrawSprite(sprAMBordersIPhone, x, y, 0);
+{$ELSE}
 DrawSprite(sprAMBorders, x, y, 0);
+{$ENDIF}
 
 if (Pos >= 0) then
     begin
@@ -266,7 +294,7 @@
             RenderWeaponTooltip(amSel)
             end;
         
-        DrawTexture(cScreenWidth div 2 - 200 + AMxShift, cScreenHeight - 68, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
+        DrawTexture(cScreenWidth div 2 - (MENUWIDTH - 10) + AMxShift, cScreenHeight - 68, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
 
         if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
             DrawTexture(cScreenWidth div 2 + AMxShift - 35, cScreenHeight - 68, CountTexz[Ammo^[Slot, Pos].Count]);
@@ -915,7 +943,7 @@
 
 if AMxShift < 210 then
     begin
-    if CursorPoint.X < cScreenWidth div 2 + AMxShift - 175 then CursorPoint.X:= cScreenWidth div 2 + AMxShift - 175;
+    if CursorPoint.X < cScreenWidth div 2 + AMxShift - 206 then CursorPoint.X:= cScreenWidth div 2 + AMxShift - 206;
     if CursorPoint.X > cScreenWidth div 2 + AMxShift - 10 then CursorPoint.X:= cScreenWidth div 2 + AMxShift - 10;
     if CursorPoint.Y > 75 + SlotsNum * 33 then CursorPoint.Y:= 75 + SlotsNum * 33;
     if CursorPoint.Y < 76 then CursorPoint.Y:= 76;
--- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Sat May 01 21:53:31 2010 +0000
+++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Sat May 01 21:54:08 2010 +0000
@@ -329,6 +329,7 @@
 		617995311150403800BA94A9 /* joyPush.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = joyPush.png; path = ../../cocoaTouch/resources/joyPush.png; sourceTree = SOURCE_ROOT; };
 		6184DEA111795DBD00AF6EFA /* UIImageExtra.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UIImageExtra.h; path = ../../cocoaTouch/otherSrc/UIImageExtra.h; sourceTree = SOURCE_ROOT; };
 		6184DEA211795DBD00AF6EFA /* UIImageExtra.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = UIImageExtra.m; path = ../../cocoaTouch/otherSrc/UIImageExtra.m; sourceTree = SOURCE_ROOT; };
+		618736B8118CA28600123B23 /* GearDrawing.inc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = GearDrawing.inc; path = ../../hedgewars/GearDrawing.inc; sourceTree = SOURCE_ROOT; };
 		618BE5911175126900F22556 /* LevelViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LevelViewController.h; path = ../../cocoaTouch/LevelViewController.h; sourceTree = SOURCE_ROOT; };
 		618BE5921175126900F22556 /* LevelViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LevelViewController.m; path = ../../cocoaTouch/LevelViewController.m; sourceTree = SOURCE_ROOT; };
 		618BE60111751F4F00F22556 /* GravesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GravesViewController.h; path = ../../cocoaTouch/GravesViewController.h; sourceTree = SOURCE_ROOT; };
@@ -590,6 +591,7 @@
 		61798892114AA56300BA94A9 /* inc */ = {
 			isa = PBXGroup;
 			children = (
+				618736B8118CA28600123B23 /* GearDrawing.inc */,
 				61798852114AA44900BA94A9 /* config.inc */,
 				617987E1114AA34C00BA94A9 /* CCHandlers.inc */,
 				617987E4114AA34C00BA94A9 /* GSHandlers.inc */,