--- a/project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m Mon Apr 25 06:38:59 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m Mon Apr 25 07:53:06 2011 +0200
@@ -396,7 +396,6 @@
case 'q':
// game ended, can remove the savefile and the trailing overlay (when dualhead)
[self gameHasEndedWithStats:statsArray];
- [statsArray release];
break;
case 'Q':
// game exited but not completed, nothing to do (just don't save the message)
@@ -408,6 +407,8 @@
}
DLog(@"Engine exited, ending thread");
[self.stream close];
+ [self.stream release];
+ [statsArray release];
// Close the client socket
SDLNet_TCP_Close(csd);
--- a/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m Mon Apr 25 06:38:59 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m Mon Apr 25 07:53:06 2011 +0200
@@ -177,6 +177,10 @@
// warn our host that it's going to be visible again
[self.parentController viewWillAppear:YES];
+
+ // release the network manager and the savepath as they are not needed anymore
+ [self.engineProtocol release];
+ [self.savePath release];
}
// set up variables for a local game
@@ -185,8 +189,7 @@
NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
[outputFormatter setDateFormat:@"yyyy-MM-dd '@' HH.mm"];
- NSString *newDateString = [outputFormatter stringFromDate:[NSDate date]];
- self.savePath = [SAVES_DIRECTORY() stringByAppendingFormat:@"%@.hws", newDateString];
+ self.savePath = [[NSString alloc] initWithFormat:@"%@%@.hws",SAVES_DIRECTORY(),[outputFormatter stringFromDate:[NSDate date]]];
[outputFormatter release];
// in the rare case in which a savefile with the same name exists the older one must be removed (or it gets corrupted)
--- a/project_files/HedgewarsMobile/Classes/ObjcExports.m Mon Apr 25 06:38:59 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/ObjcExports.m Mon Apr 25 07:53:06 2011 +0200
@@ -33,8 +33,7 @@
NSInteger grenadeTime;
// the reference to the newMenu instance
OverlayViewController *overlay_instance;
-// the audiosession must be initialized before using properties
-BOOL gAudioSessionInited = NO;
+
#pragma mark -
#pragma mark functions called like oop
@@ -86,21 +85,18 @@
void clearView() {
// don't use any engine calls here as this function is called every time the ammomenu is opened
- UIWindow *theWindow = (IS_DUALHEAD()) ? [HedgewarsAppDelegate sharedAppDelegate].uiwindow : [[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;
+ overlay_instance.confirmButton.alpha = 0;
+ overlay_instance.grenadeTimeSegment.alpha = 0;
[UIView commitAnimations];
- if (theButton)
- [theWindow performSelector:@selector(removeFromSuperview) withObject:theButton afterDelay:ANIMATION_DURATION];
- if (theSegment)
- [theWindow performSelector:@selector(removeFromSuperview) withObject:theSegment afterDelay:ANIMATION_DURATION];
-
+ if (overlay_instance.confirmButton)
+ [overlay_instance.confirmButton performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:ANIMATION_DURATION];
+ if (overlay_instance.grenadeTimeSegment) {
+ [overlay_instance.grenadeTimeSegment performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:ANIMATION_DURATION];
+ overlay_instance.grenadeTimeSegment.tag = 0;
+ }
grenadeTime = 2;
}
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.h Mon Apr 25 06:38:59 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.h Mon Apr 25 07:53:06 2011 +0200
@@ -44,7 +44,6 @@
// ths touch section
CGFloat initialDistanceForPinching;
CGPoint startingPoint;
- BOOL isSegmentVisible;
BOOL isAttacking;
// stuff initialized externally
@@ -54,9 +53,11 @@
// dual head support
NSInteger initialScreenCount;
- // spinning icons low
+ // various other widgets
UIActivityIndicatorView *lowerIndicator;
UIActivityIndicatorView *savesIndicator;
+ UIButton *confirmButton;
+ UISegmentedControl *grenadeTimeSegment;
}
@property (nonatomic,retain) id popoverController;
@@ -65,10 +66,14 @@
@property (nonatomic,retain) AmmoMenuViewController *amvc;
@property (nonatomic,retain) UIActivityIndicatorView *lowerIndicator;
@property (nonatomic,retain) UIActivityIndicatorView *savesIndicator;
+@property (nonatomic,retain) UIButton *confirmButton;
+@property (nonatomic,retain) UISegmentedControl *grenadeTimeSegment;
+
@property (assign) BOOL useClassicMenu;
@property (assign) NSInteger initialOrientation;
@property (assign) NSInteger initialScreenCount;
+
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m Mon Apr 25 06:38:59 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m Mon Apr 25 07:53:06 2011 +0200
@@ -35,12 +35,10 @@
#define doDim() [dimTimer setFireDate: (IS_DUALHEAD()) ? HIDING_TIME_NEVER : HIDING_TIME_DEFAULT]
#define doNotDim() [dimTimer setFireDate:HIDING_TIME_NEVER]
-#define removeInputWidget() [[self.view viewWithTag:CONFIRMATION_TAG] removeFromSuperview]; \
- [[self.view viewWithTag:GRENADE_TAG] removeFromSuperview];
-
@implementation OverlayViewController
-@synthesize popoverController, popupMenu, helpPage, amvc, useClassicMenu, initialScreenCount, initialOrientation, lowerIndicator, savesIndicator;
+@synthesize popoverController, popupMenu, helpPage, amvc, useClassicMenu, initialScreenCount, initialOrientation,
+ lowerIndicator, savesIndicator, confirmButton, grenadeTimeSegment;
#pragma mark -
#pragma mark rotation
@@ -192,6 +190,10 @@
self.lowerIndicator = nil;
if (self.savesIndicator.superview == nil)
self.savesIndicator = nil;
+ if (self.confirmButton.superview == nil)
+ self.confirmButton = nil;
+ if (self.grenadeTimeSegment.superview == nil)
+ self.grenadeTimeSegment = nil;
if (IS_IPAD())
if (((UIPopoverController *)self.popoverController).contentViewController.view.superview == nil)
self.popoverController = nil;
@@ -207,6 +209,8 @@
[amvc release];
[lowerIndicator release];
[savesIndicator release];
+ [confirmButton release];
+ [grenadeTimeSegment release];
// dimTimer is autoreleased
[super dealloc];
}
@@ -342,13 +346,12 @@
doDim();
[self.amvc disappear];
}
- removeInputWidget();
+ clearView();
[self showPopover];
break;
case 11:
playSound(@"clickSound");
clearView();
- removeInputWidget();
if (IS_DUALHEAD() || self.useClassicMenu == NO) {
if (self.amvc == nil)
@@ -378,7 +381,7 @@
-(void) sendHWClick {
HW_click();
- removeInputWidget();
+ clearView();
doDim();
}
@@ -491,9 +494,6 @@
// reset default dimming
doDim();
- // remove other widgets
- removeInputWidget();
-
HW_setPianoSound([allTouches count]);
switch ([allTouches count]) {
@@ -535,18 +535,20 @@
HW_setCursor(HWX(currentPosition.x), HWY(currentPosition.y));
// draw the button at the last touched point (which is the current position)
- UIButton *tapAgain = [UIButton buttonWithType:UIButtonTypeRoundedRect];
- tapAgain.frame = CGRectMake(currentPosition.x - 75, currentPosition.y + 25, 150, 40);
- tapAgain.tag = CONFIRMATION_TAG;
- tapAgain.alpha = 0;
- [tapAgain addTarget:self action:@selector(sendHWClick) forControlEvents:UIControlEventTouchUpInside];
- [tapAgain setTitle:NSLocalizedString(@"Tap to set!",@"from the overlay") forState:UIControlStateNormal];
- [self.view addSubview:tapAgain];
+ if (self.confirmButton == nil) {
+ UIButton *tapAgain = [UIButton buttonWithType:UIButtonTypeRoundedRect];
+ [tapAgain addTarget:self action:@selector(sendHWClick) forControlEvents:UIControlEventTouchUpInside];
+ [tapAgain setTitle:NSLocalizedString(@"Set!",@"on the overlay") forState:UIControlStateNormal];
+ self.confirmButton = tapAgain;
+ }
+ self.confirmButton.alpha = 0;
+ self.confirmButton.frame = CGRectMake(currentPosition.x - 75, currentPosition.y + 25, 150, 40);
+ [self.view addSubview:self.confirmButton];
// animation ftw!
[UIView beginAnimations:@"inserting button" context:NULL];
[UIView setAnimationDuration:ANIMATION_DURATION];
- [self.view viewWithTag:CONFIRMATION_TAG].alpha = 1;
+ self.confirmButton.alpha = 1;
[UIView commitAnimations];
// keep the overlay active, or the button will fade
@@ -554,38 +556,38 @@
doNotDim();
} else
if (HW_isWeaponTimerable()) {
- if (isSegmentVisible) {
- UISegmentedControl *grenadeTime = (UISegmentedControl *)[self.view viewWithTag:GRENADE_TAG];
-
+ if (self.grenadeTimeSegment.tag != 0) {
[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);
+ self.grenadeTimeSegment.alpha = 0;
[UIView commitAnimations];
- [grenadeTime performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:ANIMATION_DURATION];
+ [self.grenadeTimeSegment performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:ANIMATION_DURATION];
+ self.grenadeTimeSegment.tag = 0;
} 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 = cachedGrenadeTime();
- grenadeTime.tag = GRENADE_TAG;
- [self.view addSubview:grenadeTime];
- [grenadeTime release];
+ if (self.grenadeTimeSegment == nil) {
+ NSArray *items = [[NSArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5",nil];
+ UISegmentedControl *grenadeSegment = [[UISegmentedControl alloc] initWithItems:items];
+ [items release];
+ [grenadeSegment addTarget:self action:@selector(setGrenadeTime:) forControlEvents:UIControlEventValueChanged];
+ self.grenadeTimeSegment = grenadeSegment;
+ [grenadeSegment release];
+ }
+ self.grenadeTimeSegment.frame = CGRectMake(screen.size.height / 2 - 125, screen.size.width, 250, 50);
+ self.grenadeTimeSegment.selectedSegmentIndex = cachedGrenadeTime();
+ self.grenadeTimeSegment.alpha = 1;
+ [self.view addSubview:self.grenadeTimeSegment];
[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);
+ self.grenadeTimeSegment.frame = CGRectMake(screen.size.height / 2 - 125, screen.size.width - 100, 250, 50);
[UIView commitAnimations];
+ self.grenadeTimeSegment.tag++;
[self activateOverlay];
doNotDim();
}
- isSegmentVisible = !isSegmentVisible;
} else
if (HW_isWeaponSwitch())
HW_tab();