# HG changeset patch
# User koda
# Date 1328577015 -3600
# Node ID 436289cfebf5bfea6c273d3d418bff7b1b032fb2
# Parent eed176af3cc6827d6cb483354486a50c248ce630# Parent 9ff40cf44827f2593707f83ecf720eef5da87f99
merge
diff -r 9ff40cf44827 -r 436289cfebf5 hedgewars/hwengine.pas
--- a/hedgewars/hwengine.pas Mon Feb 06 20:04:32 2012 -0500
+++ b/hedgewars/hwengine.pas Tue Feb 07 02:10:15 2012 +0100
@@ -518,6 +518,7 @@
{$IFDEF HWLIBRARY}
WriteLnToConsole('Preview connecting on port ' + inttostr(port));
ipcPort:= port;
+ InitStepsFlags:= cifRandomize;
{$ENDIF}
InitIPC;
IPCWaitPongEvent;
diff -r 9ff40cf44827 -r 436289cfebf5 project_files/HedgewarsMobile/Classes/GameConfigViewController-iPad.xib
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController-iPad.xib Mon Feb 06 20:04:32 2012 -0500
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController-iPad.xib Tue Feb 07 02:10:15 2012 +0100
@@ -12,6 +12,7 @@
@@ -394,7 +357,6 @@
-
@@ -467,12 +429,6 @@
Filter Slider
-
- 64
-
-
- Filter Label
-
@@ -506,16 +462,15 @@
55.CustomClassName
55.IBEditorWindowLastContentRect
55.IBPluginDependency
+ 60.CustomClassName
60.IBPluginDependency
60.IBViewBoundsToFrameTransform
- 64.IBPluginDependency
- 64.IBViewBoundsToFrameTransform
YES
GameConfigViewController
UIResponder
- {{289, 287}, {1024, 768}}
+ {{252, 239}, {1024, 768}}
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
@@ -554,14 +509,11 @@
MapConfigViewController
{{126, 377}, {1024, 768}}
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
+ ValueTrackingSliderView
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
AUNRAABEMoAAA
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
-
- P4AAAL+AAADCtgAAxDoAAA
-
@@ -580,7 +532,7 @@
- 67
+ 68
@@ -627,12 +579,14 @@
mapConfigViewController
schemeWeaponConfigViewController
teamConfigViewController
+ titleImage
YES
MapConfigViewController
SchemeWeaponConfigViewController
TeamConfigViewController
+ UIImageView
@@ -642,6 +596,7 @@
mapConfigViewController
schemeWeaponConfigViewController
teamConfigViewController
+ titleImage
YES
@@ -657,6 +612,10 @@
teamConfigViewController
TeamConfigViewController
+
+ titleImage
+ UIImageView
+
@@ -720,7 +679,6 @@
maxLabel
previewButton
segmentedControl
- sizeLabel
slider
tableView
@@ -729,8 +687,7 @@
UILabel
MapPreviewButtonView
UISegmentedControl
- UILabel
- UISlider
+ ValueTrackingSliderView
UITableView
@@ -741,7 +698,6 @@
maxLabel
previewButton
segmentedControl
- sizeLabel
slider
tableView
@@ -760,12 +716,8 @@
UISegmentedControl
- sizeLabel
- UILabel
-
-
slider
- UISlider
+ ValueTrackingSliderView
tableView
@@ -815,14 +767,22 @@
UILabel
-
+
IBProjectSource
- ExtraCategories.h
+ Classes/ExtraCategories.h
UITableView
-
+
+
+
+ ValueTrackingSliderView
+ UISlider
+
+ IBProjectSource
+ ValueTrackingSliderView.h
+
diff -r 9ff40cf44827 -r 436289cfebf5 project_files/HedgewarsMobile/Classes/GameConfigViewController.h
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.h Mon Feb 06 20:04:32 2012 -0500
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.h Tue Feb 07 02:10:15 2012 +0100
@@ -28,6 +28,8 @@
@interface GameConfigViewController : UIViewController {
UIView *imgContainer;
+ UIImageView *titleImage;
+ UILabel *sliderBackground;
SchemeWeaponConfigViewController *schemeWeaponConfigViewController;
TeamConfigViewController *teamConfigViewController;
@@ -36,6 +38,8 @@
}
@property (retain) UIView *imgContainer;
+@property (nonatomic,retain) UILabel * sliderBackground;
+@property (nonatomic,retain) IBOutlet UIImageView *titleImage;
@property (nonatomic,retain) IBOutlet SchemeWeaponConfigViewController *schemeWeaponConfigViewController;
@property (nonatomic,retain) IBOutlet TeamConfigViewController *teamConfigViewController;
@property (nonatomic,retain) IBOutlet MapConfigViewController *mapConfigViewController;
diff -r 9ff40cf44827 -r 436289cfebf5 project_files/HedgewarsMobile/Classes/GameConfigViewController.m
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Mon Feb 06 20:04:32 2012 -0500
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Tue Feb 07 02:10:15 2012 +0100
@@ -26,9 +26,9 @@
#import "HelpPageViewController.h"
#import "GameInterfaceBridge.h"
-
@implementation GameConfigViewController
-@synthesize imgContainer, helpPage, mapConfigViewController, teamConfigViewController, schemeWeaponConfigViewController;
+@synthesize imgContainer, helpPage, titleImage, sliderBackground,
+ mapConfigViewController, teamConfigViewController, schemeWeaponConfigViewController;
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
@@ -243,7 +243,9 @@
[self.imgContainer removeFromSuperview];
self.imgContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 40)];
- for (int i = 0; i < 1 + random()%20; i++) {
+ NSInteger numberOfHogs = 1 + random() % 20;
+ DLog(@"Drawing %d nice hedgehogs", numberOfHogs);
+ for (int i = 0; i < numberOfHogs; i++) {
NSString *hat = [hatArray objectAtIndex:random()%numberOfHats];
NSString *hatFile = [[NSString alloc] initWithFormat:@"%@/%@", HATS_DIRECTORY(), hat];
@@ -274,6 +276,11 @@
[hog release];
}
+ // don't place the nice hogs if there is no space for them
+ if ((self.interfaceOrientation == UIInterfaceOrientationPortrait ||
+ self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown))
+ self.imgContainer.alpha = 0;
+
[self.view addSubview:self.imgContainer];
[hogSprite release];
[pool drain];
@@ -282,16 +289,17 @@
-(void) viewDidLoad {
self.view.backgroundColor = [UIColor blackColor];
- CGRect screen = [[UIScreen mainScreen] bounds];
- self.view.frame = CGRectMake(0, 0, screen.size.height, screen.size.width);
+ CGRect screenRect = [[UIScreen mainScreen] safeBounds];
+ self.view.frame = screenRect;
if (IS_IPAD()) {
// the label for the filter slider
- UILabel *filterLabel = [[UILabel alloc] initWithFrame:CGRectMake(116, 714, 310, 40)
- andTitle:nil
- withBorderWidth:2.0f];
- [self.view insertSubview:filterLabel belowSubview:self.mapConfigViewController.slider];
- [filterLabel release];
+ UILabel *backLabel = [[UILabel alloc] initWithFrame:CGRectMake(116, 714, 310, 40)
+ andTitle:nil
+ withBorderWidth:2.0f];
+ self.sliderBackground = backLabel;
+ [backLabel release];
+ [self.view addSubview:self.sliderBackground];
// the label for max hogs
UILabel *maxLabel = [[UILabel alloc] initWithFrame:CGRectMake(598, 714, 310, 40)
@@ -303,17 +311,44 @@
[self.view addSubview:maxLabel];
self.mapConfigViewController.maxLabel = maxLabel;
[maxLabel release];
-
- // as this is loaded from a NIB we need to set its size and position
- self.mapConfigViewController.view.frame = CGRectMake(704, 0, 320, 680);
} else {
- self.mapConfigViewController.view.frame = CGRectMake(0, 0, screen.size.height, screen.size.width-44);
+ self.mapConfigViewController.view.frame = CGRectMake(0, 0, screenRect.size.height, screenRect.size.width-44);
}
[self.view addSubview:self.mapConfigViewController.view];
+ [self.view bringSubviewToFront:self.mapConfigViewController.slider];
[super viewDidLoad];
}
+-(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval) duration {
+ if (IS_IPAD() == NO)
+ return;
+
+ if ((toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
+ toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)) {
+ self.imgContainer.alpha = 1;
+ self.titleImage.frame = CGRectMake(357, 17, 309, 165);
+ self.schemeWeaponConfigViewController.view.frame = CGRectMake(0, 60, 320, 620);
+ self.mapConfigViewController.view.frame = CGRectMake(704, 0, 320, 680);
+ self.teamConfigViewController.view.frame = CGRectMake(337, 187, 350, 505);
+ self.mapConfigViewController.maxLabel.frame = CGRectMake(121, 714, 300, 40);
+ self.sliderBackground.frame = CGRectMake(603, 714, 300, 40);
+ self.mapConfigViewController.slider.frame = CGRectMake(653, 724, 200, 23);
+ } else {
+ self.imgContainer.alpha = 0;
+ self.titleImage.frame = CGRectMake(37, 28, 309, 165);
+ self.schemeWeaponConfigViewController.view.frame = CGRectMake(0, 214, 378, 366);
+ self.mapConfigViewController.view.frame = CGRectMake(390, 0, 378, 580);
+ self.teamConfigViewController.view.frame = CGRectMake(170, 590, 428, 366);
+ self.mapConfigViewController.maxLabel.frame = CGRectMake(104, 975, 200, 40);
+ self.sliderBackground.frame = CGRectMake(465, 975, 200, 40);
+ self.mapConfigViewController.slider.frame = CGRectMake(475, 983, 180, 23);
+ }
+
+ [self.schemeWeaponConfigViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation
+ duration:duration];
+}
+
-(void) viewWillAppear:(BOOL)animated {
if (IS_IPAD())
[NSThread detachNewThreadSelector:@selector(loadNiceHogs) toTarget:self withObject:nil];
@@ -350,6 +385,11 @@
-(void) didReceiveMemoryWarning {
self.imgContainer = nil;
+ if (self.titleImage.superview == nil)
+ self.titleImage = nil;
+ if (self.sliderBackground.superview == nil)
+ self.sliderBackground = nil;
+
if (self.mapConfigViewController.view.superview == nil)
self.mapConfigViewController = nil;
if (self.teamConfigViewController.view.superview == nil)
@@ -364,6 +404,8 @@
-(void) viewDidUnload {
self.imgContainer = nil;
+ self.titleImage = nil;
+ self.sliderBackground = nil;
self.schemeWeaponConfigViewController = nil;
self.teamConfigViewController = nil;
self.mapConfigViewController = nil;
@@ -374,6 +416,8 @@
-(void) dealloc {
releaseAndNil(imgContainer);
+ releaseAndNil(titleImage);
+ releaseAndNil(sliderBackground);
releaseAndNil(schemeWeaponConfigViewController);
releaseAndNil(teamConfigViewController);
releaseAndNil(mapConfigViewController);
diff -r 9ff40cf44827 -r 436289cfebf5 project_files/HedgewarsMobile/Classes/MapConfigViewController-iPad.xib
--- a/project_files/HedgewarsMobile/Classes/MapConfigViewController-iPad.xib Mon Feb 06 20:04:32 2012 -0500
+++ b/project_files/HedgewarsMobile/Classes/MapConfigViewController-iPad.xib Tue Feb 07 02:10:15 2012 +0100
@@ -44,7 +44,7 @@
YES
- 289
+ 261
{{20, 166}, {280, 30}}
NO
@@ -113,6 +113,33 @@
YES
44
+
+
+ 301
+ {{32, 32}, {256, 128}}
+
+ NO
+ IBIPadFramework
+ 0
+ 0
+
+ Helvetica-Bold
+ 15
+ 16
+
+
+ 3
+ MQA
+
+
+ 1
+ MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA
+
+
+ 3
+ MC41AA
+
+
{320, 768}
@@ -177,6 +204,31 @@
69
+
+
+ previewButton
+
+
+
+ 128
+
+
+
+ mapButtonPressed:
+
+
+ 7
+
+ 129
+
+
+
+ delegate
+
+
+
+ 130
+
@@ -205,6 +257,7 @@
YES
+
@@ -218,6 +271,11 @@
+
+ 127
+
+
+
@@ -228,6 +286,9 @@
-2.CustomClassName
1.IBEditorWindowLastContentRect
1.IBPluginDependency
+ 127.CustomClassName
+ 127.IBPluginDependency
+ 127.IBViewBoundsToFrameTransform
66.IBPluginDependency
66.IBViewBoundsToFrameTransform
7.IBPluginDependency
@@ -239,6 +300,11 @@
UIResponder
{{289, 181}, {320, 768}}
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
+ MapPreviewButtonView
+ com.apple.InterfaceBuilder.IBCocoaTouchPlugin
+
+ AUIAAABB0AAAA
+
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
P4AAAL+AAABEMAAAxCmAAA
@@ -265,7 +331,7 @@
- 126
+ 130
@@ -405,14 +471,14 @@
UILabel
-
+
IBProjectSource
- Classes/HWUtils.h
+ Classes/ExtraCategories.h
UITableView
-
+
diff -r 9ff40cf44827 -r 436289cfebf5 project_files/HedgewarsMobile/Classes/MapConfigViewController.h
--- a/project_files/HedgewarsMobile/Classes/MapConfigViewController.h Mon Feb 06 20:04:32 2012 -0500
+++ b/project_files/HedgewarsMobile/Classes/MapConfigViewController.h Tue Feb 07 02:10:15 2012 +0100
@@ -21,7 +21,7 @@
#import
#import "MapPreviewButtonView.h"
-
+#import "ValueTrackingSliderView.h"
@interface MapConfigViewController : UIViewController {
NSInteger oldValue; // for the slider
@@ -42,9 +42,8 @@
MapPreviewButtonView *previewButton;
UITableView *tableView;
UILabel *maxLabel;
- UILabel *sizeLabel;
UISegmentedControl *segmentedControl;
- UISlider *slider;
+ ValueTrackingSliderView *slider;
// internal objects
NSIndexPath *lastIndexPath;
@@ -67,9 +66,8 @@
@property (nonatomic,retain) IBOutlet MapPreviewButtonView *previewButton;
@property (nonatomic,retain) IBOutlet UITableView *tableView;
@property (nonatomic,retain) IBOutlet UILabel *maxLabel;
-@property (nonatomic,retain) IBOutlet UILabel *sizeLabel;
@property (nonatomic,retain) IBOutlet UISegmentedControl *segmentedControl;
-@property (nonatomic,retain) IBOutlet UISlider *slider;
+@property (nonatomic,retain) IBOutlet ValueTrackingSliderView *slider;
@property (nonatomic,retain) NSIndexPath *lastIndexPath;
@property (nonatomic,retain) NSArray *dataSourceArray;
diff -r 9ff40cf44827 -r 436289cfebf5 project_files/HedgewarsMobile/Classes/MapConfigViewController.m
--- a/project_files/HedgewarsMobile/Classes/MapConfigViewController.m Mon Feb 06 20:04:32 2012 -0500
+++ b/project_files/HedgewarsMobile/Classes/MapConfigViewController.m Tue Feb 07 02:10:15 2012 +0100
@@ -24,13 +24,12 @@
#import "SchemeWeaponConfigViewController.h"
#import "GameConfigViewController.h"
-
#define scIndex self.segmentedControl.selectedSegmentIndex
#define isRandomness() (segmentedControl.selectedSegmentIndex == 0 || segmentedControl.selectedSegmentIndex == 2)
@implementation MapConfigViewController
@synthesize previewButton, maxHogs, seedCommand, templateFilterCommand, mapGenCommand, mazeSizeCommand, themeCommand, staticMapCommand,
- missionCommand, tableView, maxLabel, sizeLabel, segmentedControl, slider, lastIndexPath, dataSourceArray, busy,
+ missionCommand, tableView, maxLabel, segmentedControl, slider, lastIndexPath, dataSourceArray, busy,
oldPage, oldValue;
@@ -282,7 +281,7 @@
break;
}
- self.sizeLabel.text = labelText;
+ self.slider.textValue = labelText;
self.templateFilterCommand = templateCommand;
self.mazeSizeCommand = mazeCommand;
}
@@ -320,7 +319,6 @@
staticmap = @"map Bamboo";
mission = @"";
self.slider.enabled = NO;
- self.sizeLabel.text = NSLocalizedString(@"No filter",@"");
[SchemeWeaponConfigViewController fillInstanceSections];
break;
@@ -339,7 +337,6 @@
staticmap = @"map Bamboo";
mission = @"";
self.slider.enabled = NO;
- self.sizeLabel.text = NSLocalizedString(@"No filter",@"");
[SchemeWeaponConfigViewController emptyInstanceSections];
break;
@@ -407,32 +404,13 @@
return dataSourceArray;
}
--(MapPreviewButtonView *)previewButton {
- if (previewButton == nil) {
- MapPreviewButtonView *preview = [[MapPreviewButtonView alloc] initWithFrame:CGRectMake(32, 26, 256, 128)];
- preview.delegate = self;
- [preview addTarget:self action:@selector(mapButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:preview];
- self.previewButton = preview;
- [preview release];
- }
- return previewButton;
-}
-
-(void) viewDidLoad {
[super viewDidLoad];
-
srandom(time(NULL));
-
- /*
- CGSize screenSize = [[UIScreen mainScreen] bounds].size;
- self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44);
- */
// initialize some "default" values
self.slider.value = 0.05f;
self.slider.enabled = NO;
- self.sizeLabel.text = NSLocalizedString(@"No filter",@"");
self.oldValue = 5;
self.busy = NO;
self.oldPage = self.segmentedControl.selectedSegmentIndex;
@@ -451,6 +429,7 @@
self.tableView.contentInset = UIEdgeInsetsMake(10, 0, 10, 0);
UILabel *backLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 14, 300, 190) andTitle:nil withBorderWidth:2.3f];
+ backLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
[self.view insertSubview:backLabel belowSubview:self.segmentedControl];
[backLabel release];
}
@@ -480,7 +459,6 @@
self.previewButton = nil;
self.tableView = nil;
self.maxLabel = nil;
- self.sizeLabel = nil;
self.segmentedControl = nil;
self.slider = nil;
@@ -499,7 +477,6 @@
if (self.view.superview == nil) {
self.tableView = nil;
self.maxLabel = nil;
- self.sizeLabel = nil;
self.slider = nil;
}
@@ -518,7 +495,6 @@
releaseAndNil(previewButton);
releaseAndNil(tableView);
releaseAndNil(maxLabel);
- releaseAndNil(sizeLabel);
releaseAndNil(segmentedControl);
releaseAndNil(slider);
diff -r 9ff40cf44827 -r 436289cfebf5 project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m
--- a/project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m Mon Feb 06 20:04:32 2012 -0500
+++ b/project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m Tue Feb 07 02:10:15 2012 +0100
@@ -91,7 +91,6 @@
controller.tintColor = [UIColor lightGrayColor];
controller.selectedSegmentIndex = 0;
self.topControl = controller;
- [controller addTarget:self.tableView action:@selector(reloadData) forControlEvents:UIControlEventValueChanged];
[controller release];
}
return topControl;
@@ -124,6 +123,7 @@
aTableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
aTableView.separatorColor = [UIColor whiteColor];
aTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
+ aTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.tableView = aTableView;
[aTableView release];
[self.view addSubview:self.tableView];
@@ -132,6 +132,11 @@
controllerInstance = self;
}
+// this is a workaround to keep the uisegmented control visible
+-(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
+ [self.tableView reloadData];
+}
+
#pragma mark -
#pragma mark Table view data source
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
@@ -209,11 +214,13 @@
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
- UIView *theView = [[[UIView alloc] init] autorelease];
+ UIView *theView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 30)];
+ theView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
self.topControl.frame = CGRectMake(0, 0, self.view.frame.size.width * 80/100, 30);
self.topControl.center = CGPointMake(self.view.frame.size.width/2, 24);
+ [self.topControl addTarget:self.tableView action:@selector(reloadData) forControlEvents:UIControlEventValueChanged];
[theView addSubview:self.topControl];
- return theView;
+ return [theView autorelease];
}
#pragma mark -
@@ -320,6 +327,9 @@
theLabel.center = CGPointMake(controllerInstance.view.frame.size.width/2, controllerInstance.view.frame.size.height/2);
theLabel.numberOfLines = 2;
theLabel.tag = LABEL_TAG;
+ theLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth |
+ UIViewAutoresizingFlexibleTopMargin |
+ UIViewAutoresizingFlexibleBottomMargin;
[controllerInstance.view addSubview:theLabel];
[theLabel release];
diff -r 9ff40cf44827 -r 436289cfebf5 project_files/HedgewarsMobile/Classes/TeamConfigViewController.m
--- a/project_files/HedgewarsMobile/Classes/TeamConfigViewController.m Mon Feb 06 20:04:32 2012 -0500
+++ b/project_files/HedgewarsMobile/Classes/TeamConfigViewController.m Tue Feb 07 02:10:15 2012 +0100
@@ -56,6 +56,7 @@
aTableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
aTableView.separatorColor = [UIColor whiteColor];
aTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
+ aTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.tableView = aTableView;
[aTableView release];
@@ -178,16 +179,18 @@
return 45.0;
}
--(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
- CGRect frame = CGRectMake(0, 0, self.view.frame.size.width * 80/100, 30);
+-(UIView *)tableView:(UITableView *)aTableView viewForHeaderInSection:(NSInteger)section {
+ CGRect frame = CGRectMake(0, 0, self.view.frame.size.width * 70/100, 30);
NSString *text = (section == 0) ? NSLocalizedString(@"Playing Teams",@"") : NSLocalizedString(@"Available Teams",@"");
UILabel *theLabel = [[UILabel alloc] initWithFrame:frame andTitle:text];
theLabel.center = CGPointMake(self.view.frame.size.width/2, 20);
+ theLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
- UIView *theView = [[[UIView alloc] init] autorelease];
+ UIView *theView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, aTableView.frame.size.width, 30)];
+ theView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[theView addSubview:theLabel];
[theLabel release];
- return theView;
+ return [theView autorelease];
}
-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
@@ -198,6 +201,7 @@
NSInteger height = IS_IPAD() ? 40 : 20;
UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, aTableView.frame.size.width, height)];
footer.backgroundColor = [UIColor clearColor];
+ footer.autoresizingMask = UIViewAutoresizingFlexibleWidth;
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, aTableView.frame.size.width*80/100, height)];
label.center = CGPointMake(aTableView.frame.size.width/2, height/2);
@@ -205,12 +209,14 @@
label.font = [UIFont italicSystemFontOfSize:12];
label.textColor = [UIColor whiteColor];
label.numberOfLines = 2;
+ label.backgroundColor = [UIColor clearColor];
+ label.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
+
if (section == 0)
label.text = NSLocalizedString(@"Tap to add hogs or change color, touch and hold to remove a team.",@"");
else
label.text = NSLocalizedString(@"The robot badge indicates an AI-controlled team.",@"");
- label.backgroundColor = [UIColor clearColor];
[footer addSubview:label];
[label release];
return [footer autorelease];
diff -r 9ff40cf44827 -r 436289cfebf5 project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj
--- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Mon Feb 06 20:04:32 2012 -0500
+++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Tue Feb 07 02:10:15 2012 +0100
@@ -31,6 +31,7 @@
610782961440EE5C00645B29 /* basicFlags.plist in Resources */ = {isa = PBXBuildFile; fileRef = 610782931440EE5C00645B29 /* basicFlags.plist */; };
610782971440EE5C00645B29 /* credits.plist in Resources */ = {isa = PBXBuildFile; fileRef = 610782941440EE5C00645B29 /* credits.plist */; };
610782981440EE5C00645B29 /* gameMods.plist in Resources */ = {isa = PBXBuildFile; fileRef = 610782951440EE5C00645B29 /* gameMods.plist */; };
+ 610C8E3714E018D200CF5C4C /* ValueTrackingSliderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 610C8E3614E018D200CF5C4C /* ValueTrackingSliderView.m */; };
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 */; };
61156521147F48B6006729A9 /* About.strings in Resources */ = {isa = PBXBuildFile; fileRef = 61156520147F48B6006729A9 /* About.strings */; };
@@ -378,6 +379,8 @@
610782931440EE5C00645B29 /* basicFlags.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = basicFlags.plist; path = Resources/basicFlags.plist; sourceTree = ""; };
610782941440EE5C00645B29 /* credits.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = credits.plist; path = Resources/credits.plist; sourceTree = ""; };
610782951440EE5C00645B29 /* gameMods.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = gameMods.plist; path = Resources/gameMods.plist; sourceTree = ""; };
+ 610C8E3514E018D200CF5C4C /* ValueTrackingSliderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValueTrackingSliderView.h; sourceTree = ""; };
+ 610C8E3614E018D200CF5C4C /* ValueTrackingSliderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ValueTrackingSliderView.m; sourceTree = ""; };
6115651A147F48AE006729A9 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = Locale/English.lproj/About.strings; sourceTree = ""; };
6115651B147F48AE006729A9 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = Locale/English.lproj/Localizable.strings; sourceTree = ""; };
6115651C147F48AE006729A9 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = Locale/English.lproj/Scheme.strings; sourceTree = ""; };
@@ -1095,6 +1098,8 @@
61DE91561258B76800B80214 /* Custom UIs */ = {
isa = PBXGroup;
children = (
+ 610C8E3514E018D200CF5C4C /* ValueTrackingSliderView.h */,
+ 610C8E3614E018D200CF5C4C /* ValueTrackingSliderView.m */,
619C5BA0124FA59000D041AE /* MapPreviewButtonView.h */,
619C5BA1124FA59000D041AE /* MapPreviewButtonView.m */,
61F544C512AF1748007FD913 /* HoldTableViewCell.h */,
@@ -1728,6 +1733,7 @@
61D08D7414AEA7FE0007C078 /* uGearsHedgehog.pas in Sources */,
61D08D7514AEA7FE0007C078 /* uGearsList.pas in Sources */,
61D08D7614AEA7FE0007C078 /* uGearsUtils.pas in Sources */,
+ 610C8E3714E018D200CF5C4C /* ValueTrackingSliderView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff -r 9ff40cf44827 -r 436289cfebf5 project_files/HedgewarsMobile/ValueTrackingSliderView.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/HedgewarsMobile/ValueTrackingSliderView.h Tue Feb 07 02:10:15 2012 +0100
@@ -0,0 +1,36 @@
+/*
+ * Hedgewars-iOS, a Hedgewars port for iOS devices
+ * Copyright (c) 2009-2011 Vittorio Giovara
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * File created on 06/02/2012.
+ */
+
+// class heavily based on: http://blog.neuwert-media.com/2011/04/customized-uislider-with-visual-value-tracking/
+
+
+#import
+
+@class SliderValuePopupView;
+
+@interface ValueTrackingSliderView : UISlider {
+ SliderValuePopupView *valuePopupView;
+ NSString *textValue;
+}
+
+@property (nonatomic, readonly) CGRect thumbRect;
+@property (nonatomic, retain) NSString *textValue;
+
+@end
diff -r 9ff40cf44827 -r 436289cfebf5 project_files/HedgewarsMobile/ValueTrackingSliderView.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/HedgewarsMobile/ValueTrackingSliderView.m Tue Feb 07 02:10:15 2012 +0100
@@ -0,0 +1,193 @@
+/*
+ * Hedgewars-iOS, a Hedgewars port for iOS devices
+ * Copyright (c) 2009-2011 Vittorio Giovara
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * File created on 06/02/2012.
+ */
+
+// class heavily based on: http://blog.neuwert-media.com/2011/04/customized-uislider-with-visual-value-tracking/
+
+
+#import "ValueTrackingSliderView.h"
+
+#pragma mark -
+#pragma mark Private UIView subclass rendering the popup showing slider value
+@interface SliderValuePopupView : UIView
+@property (nonatomic) float value;
+@property (nonatomic, retain) UIFont *font;
+@property (nonatomic, retain) NSString *text;
+@end
+
+@implementation SliderValuePopupView
+
+@synthesize value = _value;
+@synthesize font = _font;
+@synthesize text = _text;
+
+-(id) initWithFrame:(CGRect) frame {
+ self = [super initWithFrame:frame];
+ if (self) {
+ self.font = [UIFont boldSystemFontOfSize:18];
+ }
+ return self;
+}
+
+-(void) dealloc {
+ self.text = nil;
+ self.font = nil;
+ [super dealloc];
+}
+
+-(void) drawRect:(CGRect) rect {
+ // Create the path for the rounded rectangle
+ CGRect roundedRect = CGRectMake(self.bounds.origin.x, self.bounds.origin.y, self.bounds.size.width, floorf(self.bounds.size.height * 0.8));
+ UIBezierPath *roundedRectPath = [UIBezierPath bezierPathWithRoundedRect:roundedRect cornerRadius:6.0];
+ roundedRectPath.lineWidth = 2.0f;
+
+ // Create the arrow path
+ UIBezierPath *arrowPath = [UIBezierPath bezierPath];
+ CGFloat midX = CGRectGetMidX(self.bounds);
+ CGPoint p0 = CGPointMake(midX, CGRectGetMaxY(self.bounds));
+ [arrowPath moveToPoint:p0];
+ [arrowPath addLineToPoint:CGPointMake((midX - 10.0), CGRectGetMaxY(roundedRect))];
+ [arrowPath addLineToPoint:CGPointMake((midX + 10.0), CGRectGetMaxY(roundedRect))];
+ [arrowPath closePath];
+
+ // Attach the arrow path to the rounded rect
+ [roundedRectPath appendPath:arrowPath];
+
+ // Color various sections
+ [[UIColor blackColor] setFill];
+ [roundedRectPath fill];
+ [[UIColor whiteColor] setStroke];
+ [roundedRectPath stroke];
+ [[UIColor whiteColor] setFill];
+ [arrowPath fill];
+
+ // Draw the text
+ if (self.text) {
+ [[UIColor lightYellowColor] set];
+ CGSize s = [_text sizeWithFont:self.font];
+ CGFloat yOffset = (roundedRect.size.height - s.height) / 2;
+ CGRect textRect = CGRectMake(roundedRect.origin.x, yOffset, roundedRect.size.width, s.height);
+
+ [_text drawInRect:textRect
+ withFont:self.font
+ lineBreakMode:UILineBreakModeWordWrap
+ alignment:UITextAlignmentCenter];
+ }
+}
+
+@end
+
+#pragma mark -
+#pragma mark MNEValueTrackingSlider implementations
+@implementation ValueTrackingSliderView
+
+@synthesize thumbRect, textValue;
+
+#pragma Private methods
+
+-(void) _constructSlider {
+ valuePopupView = [[SliderValuePopupView alloc] initWithFrame:CGRectZero];
+ valuePopupView.backgroundColor = [UIColor clearColor];
+ valuePopupView.alpha = 0.0;
+ [self addSubview:valuePopupView];
+}
+
+-(void) _fadePopupViewInAndOut:(BOOL)aFadeIn {
+ [UIView beginAnimations:nil context:NULL];
+ [UIView setAnimationDuration:0.25];
+ if (aFadeIn) {
+ valuePopupView.alpha = 1.0;
+ } else {
+ valuePopupView.alpha = 0.0;
+ }
+ [UIView commitAnimations];
+}
+
+-(void) _positionAndUpdatePopupView {
+ CGRect _thumbRect = self.thumbRect;
+ CGRect popupRect = CGRectOffset(_thumbRect, 0, -floorf(_thumbRect.size.height * 1.5));
+ valuePopupView.frame = CGRectInset(popupRect, -100, -15);
+ valuePopupView.text = self.textValue;
+ [valuePopupView setNeedsDisplay];
+}
+
+#pragma mark Memory management
+
+-(id) initWithFrame:(CGRect) frame {
+ self = [super initWithFrame:frame];
+ if (self) {
+ [self _constructSlider];
+ }
+ return self;
+}
+
+-(id) initWithCoder:(NSCoder *)aDecoder {
+ self = [super initWithCoder:aDecoder];
+ if (self) {
+ [self _constructSlider];
+ }
+ return self;
+}
+
+-(void) dealloc {
+ [valuePopupView release];
+ [textValue release];
+ [super dealloc];
+}
+
+#pragma mark -
+#pragma mark UIControl touch event tracking
+-(BOOL) beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event {
+ // Fade in and update the popup view
+ CGPoint touchPoint = [touch locationInView:self];
+ // Check if the knob is touched. Only in this case show the popup-view
+ if(CGRectContainsPoint(CGRectInset(self.thumbRect, -12.0, -12.0), touchPoint)) {
+ [self _positionAndUpdatePopupView];
+ [self _fadePopupViewInAndOut:YES];
+ }
+ return [super beginTrackingWithTouch:touch withEvent:event];
+}
+
+-(BOOL) continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event {
+ // Update the popup view as slider knob is being moved
+ [self _positionAndUpdatePopupView];
+ return [super continueTrackingWithTouch:touch withEvent:event];
+}
+
+-(void) cancelTrackingWithEvent:(UIEvent *)event {
+ [super cancelTrackingWithEvent:event];
+}
+
+-(void) endTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event {
+ // Fade out the popoup view
+ [self _fadePopupViewInAndOut:NO];
+ [super endTrackingWithTouch:touch withEvent:event];
+}
+
+#pragma mark -
+#pragma mark Custom property accessors
+-(CGRect) thumbRect {
+ CGRect trackRect = [self trackRectForBounds:self.bounds];
+ CGRect thumbR = [self thumbRectForBounds:self.bounds
+ trackRect:trackRect
+ value:self.value];
+ return thumbR;
+}
+
+@end