add a default description to the new ammomenu Hedgewars-iOS-1.1
authorkoda
Thu, 21 Oct 2010 23:11:49 +0200
changeset 3989 adffb668f06e
parent 3988 044cc945b2f8
child 3990 e8a428710a94
add a default description to the new ammomenu
hedgewars/PascalExports.pas
project_files/HedgewarsMobile/Classes/AmmoMenuViewController.h
project_files/HedgewarsMobile/Classes/AmmoMenuViewController.m
project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj
--- 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;
--- 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
--- 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);
--- 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;
 		};