--- a/hedgewars/PascalExports.pas Sat Jul 17 16:35:14 2010 +0200
+++ b/hedgewars/PascalExports.pas Sun Jul 18 03:26:15 2010 +0200
@@ -23,7 +23,7 @@
var xx, yy: LongInt;
// retrieve protocol information
-procedure HW_versionInfo(netProto: PShortInt; versionStr: Ppchar); cdecl; export;
+procedure HW_versionInfo(netProto: PShortInt; versionStr: PPChar); cdecl; export;
begin
// http://bugs.freepascal.org/view.php?id=16156
if netProto <> nil then netProto^:= cNetProtoVersion;
@@ -212,6 +212,19 @@
exit( (CurrentHedgehog^.Gear^.State and gstHHChooseTarget) <> 0 )
end;
+function HW_isWeaponTimerable: boolean; cdecl; export;
+var CurSlot, CurAmmo: LongWord;
+begin
+ CurSlot:= CurrentHedgehog^.CurSlot;
+ CurAmmo:= CurrentHedgehog^.CurAmmo;
+ exit( (CurrentHedgehog^.Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Timerable) <> 0)
+end;
+
+procedure HW_setGrenadeTime(time: LongInt); cdecl; export;
+begin
+ ParseCommand('/timer ' + inttostr(time), true);
+end;
+
//amSwitch
{$ENDIF}
--- a/hedgewars/uMisc.pas Sat Jul 17 16:35:14 2010 +0200
+++ b/hedgewars/uMisc.pas Sun Jul 18 03:26:15 2010 +0200
@@ -738,8 +738,8 @@
GameState := Low(TGameState);
GameType := gmtLocal;
- zoom := 2.0;
- ZoomValue := 2.0;
+ zoom := cDefaultZoomLevel;
+ ZoomValue := cDefaultZoomLevel;
WeaponTooltipTex:= nil;
cLaserSighting := false;
cVampiric := false;
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.h Sat Jul 17 16:35:14 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.h Sun Jul 18 03:26:15 2010 +0200
@@ -22,6 +22,7 @@
// ths touch section
CGFloat initialDistanceForPinching;
+ BOOL isSegmentVisible;
// the sdl window underneath
SDL_Window *sdlwindow;
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m Sat Jul 17 16:35:14 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m Sun Jul 18 03:26:15 2010 +0200
@@ -21,6 +21,7 @@
#define doNotDim() [dimTimer setFireDate:HIDING_TIME_NEVER]
#define CONFIRMATION_TAG 5959
+#define GRENADE_TAG 9595
#define ANIMATION_DURATION 0.25
#define removeConfirmationInput() [[self.view viewWithTag:CONFIRMATION_TAG] removeFromSuperview];
@@ -86,7 +87,7 @@
// set initial orientation
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
- UIView *sdlView = [[[UIApplication sharedApplication] keyWindow] viewWithTag:12345];
+ UIView *sdlView = [[[UIApplication sharedApplication] keyWindow] viewWithTag:SDL_VIEW_TAG];
switch (orientation) {
case UIDeviceOrientationLandscapeLeft:
sdlView.transform = CGAffineTransformMakeRotation(degreesToRadian(0));
@@ -311,11 +312,6 @@
}
}
--(void) textFieldDoneEditing:(id) sender{
- [sender resignFirstResponder];
-}
-
-
#pragma mark -
#pragma mark Custom touch event handling
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
@@ -382,8 +378,44 @@
[UIView commitAnimations];
// keep the overlay active, or the button will fade
+ [self activateOverlay];
doNotDim();
- }
+ } else
+ if (HW_isWeaponTimerable()) {
+ if (isSegmentVisible) {
+ UISegmentedControl *grenadeTime = (UISegmentedControl *)[self.view viewWithTag:GRENADE_TAG];
+
+ [UIView beginAnimations:@"removing segmented control" context:NULL];
+ [UIView setAnimationDuration:ANIMATION_DURATION];
+ [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
+ grenadeTime.frame = CGRectMake(screen.size.height / 2 - 125, screen.size.width, 250, 50);
+ [UIView commitAnimations];
+
+ [grenadeTime performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:ANIMATION_DURATION];
+ } else {
+ NSArray *items = [[NSArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5",nil];
+ UISegmentedControl *grenadeTime = [[UISegmentedControl alloc] initWithItems:items];
+ [items release];
+
+ [grenadeTime addTarget:self action:@selector(setGrenadeTime:) forControlEvents:UIControlEventValueChanged];
+ grenadeTime.frame = CGRectMake(screen.size.height / 2 - 125, screen.size.width, 250, 50);
+ grenadeTime.selectedSegmentIndex = 2;
+ grenadeTime.tag = GRENADE_TAG;
+ [self.view addSubview:grenadeTime];
+ [grenadeTime release];
+
+ [UIView beginAnimations:@"inserting segmented control" context:NULL];
+ [UIView setAnimationDuration:ANIMATION_DURATION];
+ [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
+ grenadeTime.frame = CGRectMake(screen.size.height / 2 - 125, screen.size.width - 100, 250, 50);
+ [UIView commitAnimations];
+
+ [self activateOverlay];
+ doNotDim();
+ }
+ isSegmentVisible = !isSegmentVisible;
+ }
+
break;
case 2:
HW_allKeysUp();
@@ -402,6 +434,11 @@
doDim();
}
+-(void) setGrenadeTime:(id) sender {
+ UISegmentedControl *theSegment = (UISegmentedControl *)sender;
+ HW_setGrenadeTime(theSegment.selectedSegmentIndex + 1);
+}
+
-(void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
[self touchesEnded:touches withEvent:event];
}
@@ -449,7 +486,8 @@
}
}
-
+#pragma mark -
+#pragma mark Functions called by pascal
// called from AddProgress and FinishProgress (respectively)
void startSpinning() {
isGameRunning = NO;
@@ -459,12 +497,12 @@
indicator.center = CGPointMake(screen.size.width/2 - 118, screen.size.height/2);
indicator.hidesWhenStopped = YES;
[indicator startAnimating];
- [[[[UIApplication sharedApplication] keyWindow] viewWithTag:12345] addSubview:indicator];
+ [[[[UIApplication sharedApplication] keyWindow] viewWithTag:SDL_VIEW_TAG] addSubview:indicator];
[indicator release];
}
void stopSpinning() {
- UIActivityIndicatorView *indicator = (UIActivityIndicatorView *)[[[[UIApplication sharedApplication] keyWindow] viewWithTag:12345] viewWithTag:987654];
+ UIActivityIndicatorView *indicator = (UIActivityIndicatorView *)[[[[UIApplication sharedApplication] keyWindow] viewWithTag:SDL_VIEW_TAG] viewWithTag:987654];
[indicator stopAnimating];
isGameRunning = YES;
}
@@ -472,11 +510,16 @@
void clearView() {
UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
UIButton *theButton = (UIButton *)[theWindow viewWithTag:CONFIRMATION_TAG];
+ UISegmentedControl *theSegment = (UISegmentedControl *)[theWindow viewWithTag:GRENADE_TAG];
+
[UIView beginAnimations:@"remove button" context:NULL];
[UIView setAnimationDuration:ANIMATION_DURATION];
theButton.alpha = 0;
+ theSegment.alpha = 0;
[UIView commitAnimations];
+
[theWindow performSelector:@selector(removeFromSuperview) withObject:theButton afterDelay:0.3];
+ [theWindow performSelector:@selector(removeFromSuperview) withObject:theSegment afterDelay:0.3];
}
@end
--- a/project_files/HedgewarsMobile/Classes/PascalImports.h Sat Jul 17 16:35:14 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/PascalImports.h Sun Jul 18 03:26:15 2010 +0200
@@ -22,7 +22,7 @@
void GenLandPreview(void);
- void HW_versionInfo(short int*, char**);
+ void HW_versionInfo(short int *netProto, char **versionStr);
void HW_click(void);
@@ -63,6 +63,9 @@
BOOL HW_isAmmoOpen(void);
BOOL HW_isWeaponRequiringClick(void);
+ BOOL HW_isWeaponTimerable(void);
+
+ void HW_setGrenadeTime(int time);
#ifdef __cplusplus
}
--- a/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m Sat Jul 17 16:35:14 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m Sun Jul 18 03:26:15 2010 +0200
@@ -76,11 +76,6 @@
// main routine for calling the actual game engine
-(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] initWithDictionary:gameDictionary];
@@ -98,16 +93,11 @@
free(gameArgs);
// bring the uiwindow below in front
- //UIWindow *aWin = [[[UIApplication sharedApplication] windows] objectAtIndex:0];
- //[aWin makeKeyAndVisible];
+ UIWindow *aWin = [[[UIApplication sharedApplication] windows] objectAtIndex:0];
+ [aWin makeKeyAndVisible];
// notice that in the simulator this reports 2 windows
DLog(@"%@",[[UIApplication sharedApplication] windows]);
-
- [UIView beginAnimations:@"inserting main controller" context:NULL];
- [UIView setAnimationDuration:1];
- mainViewController.view.alpha = 1;
- [UIView commitAnimations];
}
-(void) displayOverlayLater {