redo spinning wheel, redo fix for detail selection, redo ammo quantity and name in ammomenu
authorkoda
Thu, 08 Jul 2010 02:23:10 +0200
changeset 3629 86212d2b116a
parent 3628 2b4d878ba565
child 3630 2c7a9d5aa18c
redo spinning wheel, redo fix for detail selection, redo ammo quantity and name in ammomenu
CMakeLists.txt
hedgewars/uStore.pas
hedgewars/uWorld.pas
project_files/HedgewarsMobile/Classes/GameConfigViewController.m
project_files/HedgewarsMobile/Classes/OverlayViewController.h
project_files/HedgewarsMobile/Classes/OverlayViewController.m
project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m
project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj
project_files/HedgewarsMobile/Resources/OverlayViewController.xib
--- a/CMakeLists.txt	Wed Jul 07 03:16:12 2010 +0200
+++ b/CMakeLists.txt	Thu Jul 08 02:23:10 2010 +0200
@@ -159,7 +159,7 @@
 	set(pascal_compiler_flags_cmn "-O2" "-Xs" "-Si" ${pascal_compiler_flags_cmn})
 	set(haskell_compiler_flags_cmn "-O2" "-w")
 else(Optz)
-	set(pascal_compiler_flags_cmn "-O-" "-ghl" "-dDEBUGFILE" ${pascal_compiler_flags_cmn})
+	set(pascal_compiler_flags_cmn "-O-" "-g" "-gh" "-gl" "-dDEBUGFILE" ${pascal_compiler_flags_cmn})
 	set(haskell_compiler_flags_cmn "-Wall" "-debug" "-dcore-lint")
 endif(Optz)
 
--- a/hedgewars/uStore.pas	Wed Jul 07 03:16:12 2010 +0200
+++ b/hedgewars/uStore.pas	Thu Jul 08 02:23:10 2010 +0200
@@ -1265,6 +1265,10 @@
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
+{$IFDEF IPHONEOS}
+procedure startSpinning; cdecl; external;
+procedure stopSpinning; cdecl; external;
+{$ENDIF}
 procedure AddProgress;
 var r: TSDL_Rect;
     texsurf: PSDL_Surface;
@@ -1279,6 +1283,9 @@
         squaresize:= texsurf^.w shr 1;
         numsquares:= texsurf^.h div squaresize;
         SDL_FreeSurface(texsurf);
+{$IFDEF IPHONEOS}
+        startSpinning();
+{$ENDIF}
     end;
 
     TryDo(ProgrTex <> nil, 'Error - Progress Texure is nil!', true);
@@ -1301,15 +1308,12 @@
 
 end;
 
-{$IFDEF IPHONEOS}
-procedure spinningWheelDone; cdecl; external;
-{$ENDIF}
 procedure FinishProgress;
 begin
     WriteLnToConsole('Freeing progress surface... ');
     FreeTexture(ProgrTex);
 {$IFDEF IPHONEOS}
-    spinningWheelDone();
+    stopSpinning();
 {$ENDIF}
 end;
 
--- a/hedgewars/uWorld.pas	Wed Jul 07 03:16:12 2010 +0200
+++ b/hedgewars/uWorld.pas	Thu Jul 08 02:23:10 2010 +0200
@@ -355,12 +355,17 @@
             RenderWeaponTooltip(amSel)
             end;
             
-        {$IFNDEF IPHONEOS}
+{$IFDEF IPHONEOS}
+        DrawTexture(cScreenWidth div 2 - (AMWidth - 10) + AMxShift, AMyOffset - 25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
+
+        if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
+            DrawTexture(cScreenWidth div 2 + AMxOffset - 45, AMyOffset - 25, CountTexz[Ammo^[Slot, Pos].Count]);
+{$ELSE}
         DrawTexture(cScreenWidth div 2 - (AMWidth - 10) + AMxShift, cScreenHeight - AMyOffset - 25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
 
         if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
             DrawTexture(cScreenWidth div 2 + AMxOffset - 45, cScreenHeight - AMyOffset - 25, CountTexz[Ammo^[Slot, Pos].Count]);
-        {$ENDIF}
+{$ENDIF}
 
         if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then
             begin
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m	Wed Jul 07 03:16:12 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m	Thu Jul 08 02:23:10 2010 +0200
@@ -155,12 +155,16 @@
                                                                       nil];
 
     // finally launch game and remove this controller
+    DLog(@"sending config %@", gameDictionary);
+
     [[SDLUIKitDelegate sharedAppDelegate] startSDLgame:gameDictionary];
     [gameDictionary release];
     //[[self parentViewController] dismissModalViewControllerAnimated:YES];
 }
 
 -(void) viewDidLoad {
+    self.view.backgroundColor = [UIColor blackColor];
+    
     CGRect screen = [[UIScreen mainScreen] bounds];
     self.view.frame = CGRectMake(0, 0, screen.size.height, screen.size.width);
 
@@ -185,8 +189,9 @@
     } 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
+        // this must be loaded & added to auto set default scheme and ammo
         schemeWeaponConfigViewController = [[SchemeWeaponConfigViewController alloc] initWithStyle:UITableViewStyleGrouped];
+        [self.view addSubview:schemeWeaponConfigViewController.view];
     }
     activeController = mapConfigViewController;
     
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.h	Wed Jul 07 03:16:12 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.h	Thu Jul 08 02:23:10 2010 +0200
@@ -19,19 +19,13 @@
     PopoverMenuViewController *popupMenu;
     BOOL isPopoverVisible;
     
-    UITextField *writeChatTextField;
-    
     CGFloat initialDistanceForPinching;
-    UIActivityIndicatorView *spinningWheel;
 }
 
 @property (nonatomic,retain) id popoverController;
 @property (nonatomic,retain) PopoverMenuViewController *popupMenu;
-@property (nonatomic,retain) UITextField *writeChatTextField;
-@property (nonatomic,retain) IBOutlet UIActivityIndicatorView *spinningWheel;
 
-UIActivityIndicatorView *singleton;
-BOOL canDim;
+BOOL isGameRunning;
 
 -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
 -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Wed Jul 07 03:16:12 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Thu Jul 08 02:23:10 2010 +0200
@@ -20,7 +20,7 @@
 
 
 @implementation OverlayViewController
-@synthesize popoverController, popupMenu, writeChatTextField, spinningWheel;
+@synthesize popoverController, popupMenu;
 
 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
     return rotationManager(interfaceOrientation);
@@ -107,8 +107,6 @@
 #pragma mark View Management
 -(void) viewDidLoad {
     isPopoverVisible = NO;
-    singleton = self.spinningWheel;
-    canDim = NO;
     self.view.alpha = 0;
     self.view.center = CGPointMake(self.view.frame.size.height/2.0, self.view.frame.size.width/2.0);
     
@@ -152,12 +150,9 @@
 
 /* these are causing problems at reloading so let's remove 'em
 -(void) viewDidUnload {
-    [popoverController dismissPopoverAnimated:NO];
     [dimTimer invalidate];
-    self.writeChatTextField = nil;
     self.popoverController = nil;
     self.popupMenu = nil;
-    self.spinningWheel = nil;
     [super viewDidUnload];
     MSG_DIDUNLOAD();
 }
@@ -173,11 +168,9 @@
 */
 
 -(void) dealloc {
-    [writeChatTextField release];
     [popupMenu release];
     [popoverController release];
     // dimTimer is autoreleased
-    [spinningWheel release];
     [super dealloc];
 }
 
@@ -185,7 +178,7 @@
 #pragma mark Overlay actions and members
 // nice transition for dimming, should be called only by the timer himself
 -(void) dimOverlay {
-    if (canDim) {
+    if (isGameRunning) {
         [UIView beginAnimations:@"overlay dim" context:NULL];
         [UIView setAnimationDuration:0.6];
         self.view.alpha = 0.2;
@@ -201,6 +194,9 @@
 
 // dim the overlay when there's no more input for a certain amount of time
 -(IBAction) buttonReleased:(id) sender {
+    if (!isGameRunning)
+        return;
+    
     UIButton *theButton = (UIButton *)sender;
     
     switch (theButton.tag) {
@@ -229,6 +225,10 @@
     if (isPopoverVisible) {
         [self dismissPopover];
     }
+    
+    if (!isGameRunning)
+        return;
+    
     UIButton *theButton = (UIButton *)sender;
     
     switch (theButton.tag) {
@@ -333,12 +333,6 @@
     [sender resignFirstResponder];
 }
 
-// this function is called by pascal FinishProgress and removes the spinning wheel when loading is done
-void spinningWheelDone (void) {
-    [singleton stopAnimating];
-    singleton = nil;
-    canDim = YES;
-}
 
 #pragma mark -
 #pragma mark Custom touch event handling
@@ -351,12 +345,14 @@
     if (isPopoverVisible) {
         [self dismissPopover];
     }
+    /*
     if (writeChatTextField) {
         [self.writeChatTextField resignFirstResponder];
         [dimTimer setFireDate:HIDING_TIME_DEFAULT];
     }
-    
-    if (currentPosition.y < screen.size.width - 120) {
+    */
+
+    if (currentPosition.y < screen.size.width - 130 || (currentPosition.x > 130 && currentPosition.x < screen.size.height - 130)) {
         switch ([touches count]) {
             case 1:
                 DLog(@"X:%d Y:%d", HWX(currentPosition.x), HWY(currentPosition.y));
@@ -428,5 +424,23 @@
     }
 }
 
+// called from AddProgress and FinishProgress (respectively)
+void startSpinning() {
+    isGameRunning = NO;
+    CGRect screen = [[UIScreen mainScreen] bounds];
+    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
+    indicator.tag = 987654;
+    indicator.center = CGPointMake(screen.size.width/2 - 118, screen.size.height/2);
+    indicator.hidesWhenStopped = YES;
+    [indicator startAnimating];
+    [[[[UIApplication sharedApplication] keyWindow] viewWithTag:12345] addSubview:indicator];
+    [indicator release];
+}
+
+void stopSpinning() {
+    UIActivityIndicatorView *indicator = (UIActivityIndicatorView *)[[[[UIApplication sharedApplication] keyWindow] viewWithTag:12345] viewWithTag:987654];
+    [indicator stopAnimating];
+    isGameRunning = YES;
+}
 
 @end
--- a/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m	Wed Jul 07 03:16:12 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m	Thu Jul 08 02:23:10 2010 +0200
@@ -100,7 +100,9 @@
     // bring the uiwindow below in front
     //UIWindow *aWin = [[[UIApplication sharedApplication] windows] objectAtIndex:0];
     //[aWin makeKeyAndVisible];
-    //DLog(@"%@",[[UIApplication sharedApplication] windows]);
+    
+    // notice that in the simulator this reports 2 windows
+    DLog(@"%@",[[UIApplication sharedApplication] windows]);
     
     [UIView beginAnimations:@"inserting main controller" context:NULL];
     [UIView setAnimationDuration:1];
--- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Wed Jul 07 03:16:12 2010 +0200
+++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Thu Jul 08 02:23:10 2010 +0200
@@ -1373,7 +1373,7 @@
 				FPC_COMPILER_BINARY_DIR = /usr/local/lib/fpc/2.5.1;
 				FPC_MAIN_FILE = "$(PROJECT_DIR)/../../hedgewars/hwLibrary.pas";
 				FPC_RTL_UNITS_BASE = /usr/local/lib/fpc;
-				FPC_SPECIFIC_OPTIONS = "-dDEBUGFILE -O- -gl -gw2 -gs -gt -ghttt -Xs-";
+				FPC_SPECIFIC_OPTIONS = "-dDEBUGFILE -O- -g -gl -gw2 -gt -ghttt -Xs-";
 				FPC_UNITS_PATH = "-Fu\"$(PROJECT_DIR)\"";
 				GCC_C_LANGUAGE_STANDARD = c99;
 				GCC_DEBUGGING_SYMBOLS = full;
@@ -1577,7 +1577,7 @@
 				FPC_COMPILER_BINARY_DIR = /usr/local/lib/fpc/2.5.1;
 				FPC_MAIN_FILE = "$(PROJECT_DIR)/../../hedgewars/hwLibrary.pas";
 				FPC_RTL_UNITS_BASE = /usr/local/lib/fpc;
-				FPC_SPECIFIC_OPTIONS = "-dDEBUGFILE -O- -gl -gw2 -gt -ghttt -Xs-";
+				FPC_SPECIFIC_OPTIONS = "-dDEBUGFILE -O- -g -gl -gw2 -gt -ghttt -Xs-";
 				FPC_UNITS_PATH = "-Fu\"$(PROJECT_DIR)\"";
 				GCC_C_LANGUAGE_STANDARD = c99;
 				GCC_DEBUGGING_SYMBOLS = full;
--- a/project_files/HedgewarsMobile/Resources/OverlayViewController.xib	Wed Jul 07 03:16:12 2010 +0200
+++ b/project_files/HedgewarsMobile/Resources/OverlayViewController.xib	Thu Jul 08 02:23:10 2010 +0200
@@ -242,16 +242,6 @@
 							<string key="NSResourceName">menuCorner.png</string>
 						</object>
 					</object>
-					<object class="IBUIActivityIndicatorView" id="324194355">
-						<reference key="NSNextResponder" ref="191373211"/>
-						<int key="NSvFlags">269</int>
-						<string key="NSFrame">{{225, 248}, {37, 37}}</string>
-						<reference key="NSSuperview" ref="191373211"/>
-						<bool key="IBUIOpaque">NO</bool>
-						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
-						<bool key="IBUIAnimating">YES</bool>
-						<int key="IBUIStyle">0</int>
-					</object>
 					<object class="IBUIButton" id="50885250">
 						<reference key="NSNextResponder" ref="191373211"/>
 						<int key="NSvFlags">289</int>
@@ -565,14 +555,6 @@
 					<int key="connectionID">60</int>
 				</object>
 				<object class="IBConnectionRecord">
-					<object class="IBCocoaTouchOutletConnection" key="connection">
-						<string key="label">spinningWheel</string>
-						<reference key="source" ref="372490531"/>
-						<reference key="destination" ref="324194355"/>
-					</object>
-					<int key="connectionID">64</int>
-				</object>
-				<object class="IBConnectionRecord">
 					<object class="IBCocoaTouchEventConnection" key="connection">
 						<string key="label">buttonPressed:</string>
 						<reference key="source" ref="50885250"/>
@@ -606,7 +588,6 @@
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
 							<reference ref="309477778"/>
-							<reference ref="324194355"/>
 							<reference ref="590902961"/>
 							<reference ref="81315603"/>
 							<reference ref="584263820"/>
@@ -677,11 +658,6 @@
 						<reference key="parent" ref="191373211"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">63</int>
-						<reference key="object" ref="324194355"/>
-						<reference key="parent" ref="191373211"/>
-					</object>
-					<object class="IBObjectRecord">
 						<int key="objectID">67</int>
 						<reference key="object" ref="50885250"/>
 						<reference key="parent" ref="191373211"/>
@@ -704,7 +680,6 @@
 					<string>48.IBPluginDependency</string>
 					<string>53.IBPluginDependency</string>
 					<string>58.IBPluginDependency</string>
-					<string>63.IBPluginDependency</string>
 					<string>67.IBPluginDependency</string>
 				</object>
 				<object class="NSMutableArray" key="dict.values">
@@ -722,7 +697,6 @@
 					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
-					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 				</object>
 			</object>
 			<object class="NSMutableDictionary" key="unlocalizedProperties">
@@ -781,17 +755,6 @@
 							</object>
 						</object>
 					</object>
-					<object class="NSMutableDictionary" key="outlets">
-						<string key="NS.key.0">spinningWheel</string>
-						<string key="NS.object.0">UIActivityIndicatorView</string>
-					</object>
-					<object class="NSMutableDictionary" key="toOneOutletInfosByName">
-						<string key="NS.key.0">spinningWheel</string>
-						<object class="IBToOneOutletInfo" key="NS.object.0">
-							<string key="name">spinningWheel</string>
-							<string key="candidateClassName">UIActivityIndicatorView</string>
-						</object>
-					</object>
 					<object class="IBClassDescriptionSource" key="sourceIdentifier">
 						<string key="majorKey">IBProjectSource</string>
 						<string key="minorKey">Classes/OverlayViewController.h</string>
@@ -934,14 +897,6 @@
 					</object>
 				</object>
 				<object class="IBPartialClassDescription">
-					<string key="className">UIActivityIndicatorView</string>
-					<string key="superclassName">UIView</string>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBFrameworkSource</string>
-						<string key="minorKey">UIKit.framework/Headers/UIActivityIndicatorView.h</string>
-					</object>
-				</object>
-				<object class="IBPartialClassDescription">
 					<string key="className">UIButton</string>
 					<string key="superclassName">UIControl</string>
 					<object class="IBClassDescriptionSource" key="sourceIdentifier">