# HG changeset patch # User koda # Date 1287695509 -7200 # Node ID adffb668f06e265b45d1e4aedc283e6f4e5ba7e8 # Parent 044cc945b2f8c9dd4e1163dfb5214ef9d31383fb add a default description to the new ammomenu diff -r 044cc945b2f8 -r adffb668f06e hedgewars/PascalExports.pas --- a/hedgewars/PascalExports.pas Thu Oct 21 15:40:43 2010 -0400 +++ b/hedgewars/PascalExports.pas Thu Oct 21 23:11:49 2010 +0200 @@ -297,8 +297,12 @@ var a : PHHAmmo; slot, index: LongInt; begin - if (CurrentTeam^.ExtDriven) or (CurrentTeam^.Hedgehogs[0].BotLevel <> 0) then + if (CurrentTeam = nil) or + (CurrentHedgehog = nil) or + (CurrentTeam^.ExtDriven) or + (CurrentTeam^.Hedgehogs[0].BotLevel <> 0) then exit(-1); + a:= CurrentHedgehog^.Ammo; for slot:= 0 to cMaxSlotIndex do for index:= 0 to cMaxSlotAmmoIndex do @@ -314,7 +318,7 @@ skipTurns[ord(a)-1]:= byte(Ammoz[a].SkipTurns); end; -function HW_getTurnsForCurrentTeam:LongInt; cdecl; export; +function HW_getTurnsForCurrentTeam: LongInt; cdecl; export; begin exit(CurrentTeam^.Clan^.TurnNumber); end; diff -r 044cc945b2f8 -r adffb668f06e project_files/HedgewarsMobile/Classes/AmmoMenuViewController.h --- a/project_files/HedgewarsMobile/Classes/AmmoMenuViewController.h Thu Oct 21 15:40:43 2010 -0400 +++ b/project_files/HedgewarsMobile/Classes/AmmoMenuViewController.h Thu Oct 21 23:11:49 2010 +0200 @@ -43,9 +43,13 @@ @property (nonatomic,retain) UILabel *captionLabel; @property (assign) BOOL isVisible; --(void) buttonPressed:(id)sender; --(void) updateAmmoVisuals; +-(void) buttonPressed:(id) sender; +-(void) buttonReleased:(id) sender; +-(void) buttonCancelled:(id) sender; -(void) appearInView:(UIView *)container; -(void) disappear; +-(void) updateAmmoVisuals; +-(void) loadLabels; +-(void) loadAmmoStuff:(id) object; @end diff -r 044cc945b2f8 -r adffb668f06e project_files/HedgewarsMobile/Classes/AmmoMenuViewController.m --- a/project_files/HedgewarsMobile/Classes/AmmoMenuViewController.m Thu Oct 21 15:40:43 2010 -0400 +++ b/project_files/HedgewarsMobile/Classes/AmmoMenuViewController.m Thu Oct 21 23:11:49 2010 +0200 @@ -25,7 +25,8 @@ #import "UIImageExtra.h" #import "PascalImports.h" -#define BTNS_PER_ROW 9 +#define BTNS_PER_ROW 9 +#define DEFAULT_DESCRIPTION NSLocalizedString(@"Hold your finger on a weapon to see what it does",@"") @implementation AmmoMenuViewController @synthesize imagesArray, buttonsArray, nameLabel, extraLabel, captionLabel, isVisible; @@ -87,7 +88,7 @@ #pragma mark - #pragma mark drawing --(void) prepareLabels { +-(void) loadLabels { int x = 12; int y = (HW_getNumberOfWeapons()/BTNS_PER_ROW)*44 + 18; UILabel *name = [[UILabel alloc] initWithFrame:CGRectMake(x, y, 200, 20)]; @@ -111,6 +112,7 @@ UILabel *description = [[UILabel alloc] initWithFrame:CGRectMake(x+2, y+20, 410, 53)]; description.backgroundColor = [UIColor clearColor]; description.textColor = [UIColor whiteColor]; + description.text = DEFAULT_DESCRIPTION; description.font = [UIFont italicSystemFontOfSize:[UIFont systemFontSize]]; description.adjustsFontSizeToFitWidth = YES; description.minimumFontSize = 8; @@ -157,7 +159,7 @@ [button.layer setMasksToBounds:YES]; [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchDown]; [button addTarget:self action:@selector(buttonReleased:) forControlEvents:UIControlEventTouchUpInside]; - [button addTarget:self action:@selector(buttonCancel:) forControlEvents:UIControlEventTouchUpOutside|UIControlEventTouchCancel]; + [button addTarget:self action:@selector(buttonCancelled:) forControlEvents:UIControlEventTouchUpOutside|UIControlEventTouchCancel]; [button setTitleColor:UICOLOR_HW_YELLOW_TEXT forState:UIControlStateNormal]; button.titleLabel.backgroundColor = [UIColor blackColor]; button.titleLabel.font = [UIFont boldSystemFontOfSize:[UIFont smallSystemFontSize]]; @@ -180,6 +182,8 @@ [imgs release]; [ammoStoreImage release]; + [self performSelectorOnMainThread:@selector(loadLabels) withObject:nil waitUntilDone:NO]; + [self performSelectorOnMainThread:@selector(updateAmmoVisuals) withObject:nil waitUntilDone:YES]; UIActivityIndicatorView *spinner = (UIActivityIndicatorView *)object; [spinner stopAnimating]; @@ -247,7 +251,7 @@ -(void) buttonPressed:(id) sender { UIButton *theButton = (UIButton *)sender; if (self.nameLabel == nil || self.extraLabel == nil) - [self prepareLabels]; + [self loadLabels]; self.nameLabel.text = [NSString stringWithUTF8String:HW_getWeaponNameByIndex(theButton.tag)]; // description contains a lot of unnecessary stuff, we clean it by removing .|, !| and ?| @@ -262,19 +266,19 @@ self.captionLabel.text = [NSString stringWithUTF8String:HW_getWeaponCaptionByIndex(theButton.tag)]; } --(void) buttonCancel:(id) sender { +-(void) buttonCancelled:(id) sender { self.nameLabel.text = nil; - self.extraLabel.text = nil; + self.extraLabel.text = DEFAULT_DESCRIPTION; self.captionLabel.text = nil; } -(void) buttonReleased:(id) sender { UIButton *theButton = (UIButton *)sender; if (self.nameLabel == nil || self.extraLabel == nil) - [self prepareLabels]; + [self loadLabels]; self.nameLabel.text = nil; - self.extraLabel.text = nil; + self.extraLabel.text = DEFAULT_DESCRIPTION; self.captionLabel.text = nil; if (theButton.currentTitle == nil) { HW_setWeapon(theButton.tag); diff -r 044cc945b2f8 -r adffb668f06e project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj --- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Thu Oct 21 15:40:43 2010 -0400 +++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Thu Oct 21 23:11:49 2010 +0200 @@ -25,6 +25,8 @@ 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; 28FD15000DC6FC520079059D /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28FD14FF0DC6FC520079059D /* OpenGLES.framework */; }; 28FD15080DC6FC5B0079059D /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28FD15070DC6FC5B0079059D /* QuartzCore.framework */; settings = {ATTRIBUTES = (Required, ); }; }; + 610D5FB21270E2660033333A /* Icon-Small@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 61F7A43411E290650040BA66 /* Icon-Small@2x.png */; }; + 610D5FB31270E26C0033333A /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 61F7A43611E290650040BA66 /* Icon@2x.png */; }; 611D9BFB12497E9800008271 /* SavedGamesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 611D9BF912497E9800008271 /* SavedGamesViewController.m */; }; 611D9BFC12497E9800008271 /* SavedGamesViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 611D9BFA12497E9800008271 /* SavedGamesViewController.xib */; }; 611DA031124E2BC500008271 /* background_med.png in Resources */ = {isa = PBXBuildFile; fileRef = 611DA030124E2BC500008271 /* background_med.png */; }; @@ -2122,6 +2124,8 @@ 611DA031124E2BC500008271 /* background_med.png in Resources */, 611DA1D0124E5C6300008271 /* plus.png in Resources */, 6147DAD31253DCDE0010357E /* savesButton.png in Resources */, + 610D5FB21270E2660033333A /* Icon-Small@2x.png in Resources */, + 610D5FB31270E26C0033333A /* Icon@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; };