tap to dismiss 'get ready', add a toggle to enable/disable it
authorkoda
Sat, 28 Aug 2010 01:37:21 +0200
changeset 3779 3351a017d4ad
parent 3778 2e61bb50cc57
child 3780 7c704e69242e
tap to dismiss 'get ready', add a toggle to enable/disable it
hedgewars/PascalExports.pas
hedgewars/hwengine.pas
hedgewars/uMisc.pas
project_files/HedgewarsMobile/Classes/GameSetup.m
project_files/HedgewarsMobile/Classes/GeneralSettingsViewController.m
project_files/HedgewarsMobile/Classes/OverlayViewController.m
project_files/HedgewarsMobile/Classes/PascalImports.h
project_files/HedgewarsMobile/Resources/Settings/settings.plist
--- a/hedgewars/PascalExports.pas	Sat Aug 28 00:30:29 2010 +0200
+++ b/hedgewars/PascalExports.pas	Sat Aug 28 01:37:21 2010 +0200
@@ -199,6 +199,11 @@
     exit( isPaused );
 end;
 
+function HW_isWaiting: boolean; cdecl; export;
+begin
+    exit( ReadyTimeLeft > 0 );
+end;
+
 function HW_isWeaponRequiringClick: boolean; cdecl; export;
 begin
     if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.BotLevel = 0) then
--- a/hedgewars/hwengine.pas	Sat Aug 28 00:30:29 2010 +0200
+++ b/hedgewars/hwengine.pas	Sat Aug 28 01:37:21 2010 +0200
@@ -36,7 +36,7 @@
     alsoShutdownFrontend: boolean = false;
 
 {$IFDEF HWLIBRARY}
-type arrayofpchar = array[0..9] of PChar;
+type arrayofpchar = array[0..10] of PChar;
 
 procedure initEverything(complete:boolean);
 procedure freeEverything(complete:boolean);
@@ -218,19 +218,18 @@
 {$ELSE}
     cShowFPS:= false;    // update me at release time
 {$ENDIF}
-    cInitVolume:= 100;
-
-    UserNick:= gameArgs[0];
-    val(gameArgs[1], ipcPort);
-    isSoundEnabled:= gameArgs[2] = '1';
-    isMusicEnabled:= gameArgs[3] = '1';
+    val(gameArgs[0], ipcPort);
+    val(gameArgs[1], cScreenHeight);
+    val(gameArgs[2], cScreenWidth);
+    val(gameArgs[3], cReducedQuality);
     cLocaleFName:= gameArgs[4];
-    cAltDamage:= gameArgs[5] = '1';
-    val(gameArgs[6], cScreenHeight);
-    val(gameArgs[7], cScreenWidth);
-    recordFileName:= gameArgs[8];
-
-    val(gameArgs[9], cReducedQuality);
+    UserNick:= gameArgs[5];
+    isSoundEnabled:= gameArgs[6] = '1';
+    isMusicEnabled:= gameArgs[7] = '1';
+    cAltDamage:= gameArgs[8] = '1';
+    if CompareStr(gameArgs[9],'0') = 0 then
+        cReadyDelay:= 0;
+    recordFileName:= gameArgs[10];
 {$ENDIF}
 
     initEverything(true);
--- a/hedgewars/uMisc.pas	Sat Aug 28 00:30:29 2010 +0200
+++ b/hedgewars/uMisc.pas	Sat Aug 28 01:37:21 2010 +0200
@@ -25,6 +25,26 @@
 uses    SDLh, uConsts, uFloat, GLunit, Math;
 
 var
+/////// init flags ///////
+    cScreenWidth    : LongInt     = 1024;
+    cScreenHeight   : LongInt     = 768;
+    cBits           : LongInt     = 32;
+    //ipcPort is in uIO
+    cFullScreen     : boolean     = false;
+    isSoundEnabled  : boolean     = true;
+    isMusicEnabled  : boolean     = false;
+    cLocaleFName    : shortstring = 'en.txt';
+    cInitVolume     : LongInt     = 100;
+    cTimerInterval  : LongInt     = 8;
+    PathPrefix      : shortstring = './';
+    cShowFPS        : boolean     = false;
+    cAltDamage      : boolean     = true;
+    cReducedQuality : LongInt     = rqNone;
+    //userNick is in uChat
+    recordFileName  : shortstring = '';
+    cReadyDelay     : Longword    = 5000;
+//////////////////////////
+    
     isCursorVisible : boolean;
     isTerminated    : boolean;
     isInLag         : boolean;
@@ -42,7 +62,7 @@
     GameFlags       : Longword;
     TrainingFlags   : Longword;
     TurnTimeLeft    : Longword;
-    ReadyTimeLeft    : Longword;
+    ReadyTimeLeft   : Longword;
     cSuddenDTurns   : LongInt;
     cDamagePercent  : LongInt;
     cMineDudPercent : LongWord;
@@ -81,24 +101,6 @@
     LAND_HEIGHT_MASK : LongWord;
     cMaxCaptions     : LongInt;
 
-    // init flags
-    cScreenWidth    : LongInt = 1024;
-    cScreenHeight   : LongInt = 768;
-    cBits           : LongInt = 32;
-    //ipcPort is in uIO
-    cFullScreen     : boolean = false;
-    isSoundEnabled  : boolean = true;
-    isMusicEnabled  : boolean = false;
-    cLocaleFName    : shortstring = 'en.txt';
-    cInitVolume     : LongInt = 50;
-    cTimerInterval  : LongInt = 8;
-    PathPrefix: shortstring = './';
-    cShowFPS        : boolean = false;
-    cAltDamage      : boolean = true;
-    cReducedQuality : LongInt = rqNone;
-    //userNick is in uChat
-    recordFileName  : shortstring = '';
-
     cLeftScreenBorder     : LongInt;
     cRightScreenBorder    : LongInt;
     cScreenSpace          : LongInt;
@@ -111,7 +113,6 @@
     cVolumeDelta    : LongInt;
     cHasFocus       : boolean;
     cInactDelay     : Longword;
-    cReadyDelay     : Longword;
 
     bBetweenTurns   : boolean;
     cHealthDecrease : LongWord;
@@ -785,8 +786,7 @@
     cVolumeDelta    := 0;
     cHasFocus       := true;
     cInactDelay     := 1250;
-    cReadyDelay     := 5000;
-    ReadyTimeLeft    := 0;
+    ReadyTimeLeft   := 0;
 
     ScreenFade      := sfNone;
 
@@ -860,7 +860,7 @@
     isSoundEnabled  := true;
     isMusicEnabled  := false;
     cLocaleFName    := 'en.txt';
-    cInitVolume     := 50;
+    cInitVolume     := 100;
     cTimerInterval  := 8;
     PathPrefix := './';
     cShowFPS        := false;
@@ -868,6 +868,7 @@
     cReducedQuality := rqNone;
     //userNick is in uChat
     recordFileName  := '';
+    cReadyDelay     := 5000;
 end;
 
 end.
--- a/project_files/HedgewarsMobile/Classes/GameSetup.m	Sat Aug 28 00:30:29 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameSetup.m	Sat Aug 28 01:37:21 2010 +0200
@@ -388,8 +388,6 @@
     if (![modelId hasPrefix:@"iPad"])                                       // = disable tooltips unless iPad
         tmpQuality = tmpQuality | 0x00000400;
 
-    gameArgs[9] = [[[NSNumber numberWithInteger:tmpQuality] stringValue] UTF8String];
-
     // prevents using an empty nickname
     NSString *username;
     NSString *originalUsername = [self.systemSettings objectForKey:@"username"];
@@ -398,15 +396,17 @@
     else
         username = [[NSString alloc] initWithString:originalUsername];
 
-    gameArgs[0] = [username UTF8String];                                                        //UserNick
-    gameArgs[1] = [ipcString UTF8String];                                                       //ipcPort
-    gameArgs[2] = [[[self.systemSettings objectForKey:@"sound"] stringValue] UTF8String];       //isSoundEnabled
-    gameArgs[3] = [[[self.systemSettings objectForKey:@"music"] stringValue] UTF8String];       //isMusicEnabled
-    gameArgs[4] = [localeString UTF8String];                                                    //cLocaleFName
-    gameArgs[5] = [[[self.systemSettings objectForKey:@"alternate"] stringValue] UTF8String];   //cAltDamage
-    gameArgs[6] = [wSize UTF8String];                                                           //cScreenHeight
-    gameArgs[7] = [hSize UTF8String];                                                           //cScreenWidth
-    gameArgs[8] = NULL;                                                                         //recordFileName
+    gameArgs[ 0] = [ipcString UTF8String];                                                       //ipcPort
+    gameArgs[ 1] = [wSize UTF8String];                                                           //cScreenHeight
+    gameArgs[ 2] = [hSize UTF8String];                                                           //cScreenWidth
+    gameArgs[ 3] = [[[NSNumber numberWithInteger:tmpQuality] stringValue] UTF8String];           //quality
+    gameArgs[ 4] = [localeString UTF8String];                                                    //cLocaleFName
+    gameArgs[ 5] = [username UTF8String];                                                        //UserNick
+    gameArgs[ 6] = [[[self.systemSettings objectForKey:@"sound"] stringValue] UTF8String];       //isSoundEnabled
+    gameArgs[ 7] = [[[self.systemSettings objectForKey:@"music"] stringValue] UTF8String];       //isMusicEnabled
+    gameArgs[ 8] = [[[self.systemSettings objectForKey:@"alternate"] stringValue] UTF8String];   //cAltDamage
+    gameArgs[ 9] = [[[self.systemSettings objectForKey:@"ready"] stringValue] UTF8String];       //cReady
+    gameArgs[10] = NULL;                                                                         //recordFileName
 
     [wSize release];
     [hSize release];
--- a/project_files/HedgewarsMobile/Classes/GeneralSettingsViewController.m	Sat Aug 28 00:30:29 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/GeneralSettingsViewController.m	Sat Aug 28 01:37:21 2010 +0200
@@ -63,6 +63,9 @@
         case 30:    //alternateSwitch
             [self.settingsDictionary setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"alternate"];
             break;
+        case 60:    //getReady
+            [self.settingsDictionary setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"ready"];
+            break;
         default:
             DLog(@"Wrong tag");
             break;
@@ -90,8 +93,8 @@
         case 1:     // audio
             return 2;
             break;
-        case 2:     // alternate damage
-            return 1;
+        case 2:     // other stuff
+            return 2;
             break;
         default:
             break;
@@ -121,49 +124,52 @@
 -(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
     static NSString *cellIdentifier0 = @"Cell0";
     static NSString *cellIdentifier1 = @"Cell1";
+    static NSString *cellIdentifier2 = @"Cell2";
     NSInteger row = [indexPath row];
     NSInteger section = [indexPath section];
 
     UITableViewCell *cell = nil;
     EditableCellView *editableCell = nil;
-    if (section == 0) {
-        editableCell = (EditableCellView *)[aTableView dequeueReusableCellWithIdentifier:cellIdentifier0];
-        if (nil == editableCell) {
-            editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier0] autorelease];
-            editableCell.minimumCharacters = 0;
-            editableCell.delegate = self;
-            editableCell.textField.font = [UIFont systemFontOfSize:[UIFont systemFontSize]];
-            editableCell.textField.textColor = [UIColor lightGrayColor];
-        }
-
-        if (row == 0) {
-            editableCell.titleLabel.text = NSLocalizedString(@"Nickname","from the settings table");
-            editableCell.textField.placeholder = NSLocalizedString(@"Insert your username (if you have one)",@"");
-            editableCell.textField.text = [self.settingsDictionary objectForKey:@"username"];
-            editableCell.textField.secureTextEntry = NO;
-            editableCell.tag = 40;
-        } else {
-            editableCell.titleLabel.text = NSLocalizedString(@"Password","from the settings table");
-            editableCell.textField.placeholder = NSLocalizedString(@"Insert your password",@"");
-            editableCell.textField.text = [self.settingsDictionary objectForKey:@"password"];
-            editableCell.textField.secureTextEntry = YES;
-            editableCell.tag = 50;
-        }
-
-        editableCell.accessoryView = nil;
-        cell = editableCell;
-    } else {
-        cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier1];
-        if (nil == cell) {
-            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier1] autorelease];
-            UISwitch *theSwitch = [[UISwitch alloc] init];
-            [theSwitch addTarget:self action:@selector(switchValueChanged:) forControlEvents:UIControlEventValueChanged];
-            cell.accessoryView = theSwitch;
-            [theSwitch release];
-        }
-
-        UISwitch *switchContent = (UISwitch *)cell.accessoryView;
-        if (section == 1) {
+    UISwitch *switchContent = nil;
+    switch(section) {
+        case 0:
+            editableCell = (EditableCellView *)[aTableView dequeueReusableCellWithIdentifier:cellIdentifier0];
+            if (nil == editableCell) {
+                editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier0] autorelease];
+                editableCell.minimumCharacters = 0;
+                editableCell.delegate = self;
+                editableCell.textField.font = [UIFont systemFontOfSize:[UIFont systemFontSize]];
+                editableCell.textField.textColor = [UIColor lightGrayColor];
+            }
+            
+            if (row == 0) {
+                editableCell.titleLabel.text = NSLocalizedString(@"Nickname","from the settings table");
+                editableCell.textField.placeholder = NSLocalizedString(@"Insert your username (if you have one)",@"");
+                editableCell.textField.text = [self.settingsDictionary objectForKey:@"username"];
+                editableCell.textField.secureTextEntry = NO;
+                editableCell.tag = 40;
+            } else {
+                editableCell.titleLabel.text = NSLocalizedString(@"Password","from the settings table");
+                editableCell.textField.placeholder = NSLocalizedString(@"Insert your password",@"");
+                editableCell.textField.text = [self.settingsDictionary objectForKey:@"password"];
+                editableCell.textField.secureTextEntry = YES;
+                editableCell.tag = 50;
+            }
+            
+            editableCell.accessoryView = nil;
+            cell = editableCell;
+            break;
+        case 1:
+            cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier1];
+            if (nil == cell) {
+                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier1] autorelease];
+                UISwitch *theSwitch = [[UISwitch alloc] init];
+                [theSwitch addTarget:self action:@selector(switchValueChanged:) forControlEvents:UIControlEventValueChanged];
+                cell.accessoryView = theSwitch;
+                [theSwitch release];
+            }
+            
+            switchContent = (UISwitch *)cell.accessoryView;
             if (row == 0) {
                 cell.textLabel.text = NSLocalizedString(@"Sound", @"");
                 switchContent.on = [[self.settingsDictionary objectForKey:@"sound"] boolValue];
@@ -173,13 +179,34 @@
                 switchContent.on = [[self.settingsDictionary objectForKey:@"music"] boolValue];
                 switchContent.tag = 20;
             }
-        } else {
-            cell.textLabel.text = NSLocalizedString(@"Alternate Damage", @"");
-            switchContent.on = [[self.settingsDictionary objectForKey:@"alternate"] boolValue];
-            switchContent.tag = 30;
-        }
+            break;
+        case 2:
+            cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier2];
+            if (nil == cell) {
+                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier2] autorelease];
+                UISwitch *theSwitch = [[UISwitch alloc] init];
+                [theSwitch addTarget:self action:@selector(switchValueChanged:) forControlEvents:UIControlEventValueChanged];
+                cell.accessoryView = theSwitch;
+                [theSwitch release];
+            }
+            
+            switchContent = (UISwitch *)cell.accessoryView;
+            if (row == 0) {
+                cell.textLabel.text = NSLocalizedString(@"Alternate Damage", @"");
+                cell.detailTextLabel.text = NSLocalizedString(@"Damage will popup when the hedgehog is injured", @"");
+                switchContent.on = [[self.settingsDictionary objectForKey:@"alternate"] boolValue];
+                switchContent.tag = 30;
+            } else {
+                cell.textLabel.text = NSLocalizedString(@"Get Ready Dialogue", @"");
+                cell.detailTextLabel.text = NSLocalizedString(@"Pause for 5 seconds between turns",@"");
+                switchContent.on = [[self.settingsDictionary objectForKey:@"ready"] boolValue];
+                switchContent.tag = 60;
+            }
+            break;
+        default:
+            break;
     }
-
+    
     cell.accessoryType = UITableViewCellAccessoryNone;
     cell.selectionStyle = UITableViewCellSelectionStyleNone;
     cell.imageView.image = nil;
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Sat Aug 28 00:30:29 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Sat Aug 28 01:37:21 2010 +0200
@@ -218,8 +218,10 @@
     if (!isGameRunning)
         return;
 
+    if (HW_isWaiting())
+        HW_shoot();
+    
     UIButton *theButton = (UIButton *)sender;
-
     switch (theButton.tag) {
         case 0:
             if (isAttacking == NO)
@@ -367,6 +369,10 @@
 
     switch ([allTouches count]) {
         case 1:
+            // this dismisses the "get ready"
+            if (HW_isWaiting())
+                HW_shoot();
+
             // if we're in the menu we just click in the point
             if (HW_isAmmoOpen()) {
                 HW_setCursor(HWXZ(currentPosition.x), HWYZ(currentPosition.y));
--- a/project_files/HedgewarsMobile/Classes/PascalImports.h	Sat Aug 28 00:30:29 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/PascalImports.h	Sat Aug 28 01:37:21 2010 +0200
@@ -61,6 +61,7 @@
 
     BOOL HW_isAmmoOpen(void);
     BOOL HW_isPaused(void);
+    BOOL HW_isWaiting(void);
     BOOL HW_isWeaponRequiringClick(void);
     BOOL HW_isWeaponTimerable(void);
     BOOL HW_isWeaponSwitch(void);
--- a/project_files/HedgewarsMobile/Resources/Settings/settings.plist	Sat Aug 28 00:30:29 2010 +0200
+++ b/project_files/HedgewarsMobile/Resources/Settings/settings.plist	Sat Aug 28 01:37:21 2010 +0200
@@ -12,5 +12,7 @@
 	<true/>
 	<key>username</key>
 	<string></string>
+	<key>ready</key>
+	<true/>
 </dict>
 </plist>