--- a/hedgewars/hwengine.pas Mon Feb 06 23:21:04 2012 +0100
+++ b/hedgewars/hwengine.pas Tue Feb 07 01:18:29 2012 +0100
@@ -518,6 +518,7 @@
{$IFDEF HWLIBRARY}
WriteLnToConsole('Preview connecting on port ' + inttostr(port));
ipcPort:= port;
+ InitStepsFlags:= cifRandomize;
{$ENDIF}
InitIPC;
IPCWaitPongEvent;
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController-iPad.xib Mon Feb 06 23:21:04 2012 +0100
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController-iPad.xib Tue Feb 07 01:18:29 2012 +0100
@@ -12,6 +12,7 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <integer value="2"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -43,10 +44,9 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBUIImageView" id="109536142">
<reference key="NSNextResponder" ref="766721923"/>
- <int key="NSvFlags">292</int>
+ <int key="NSvFlags">274</int>
<string key="NSFrameSize">{1024, 768}</string>
<reference key="NSSuperview" ref="766721923"/>
- <reference key="NSWindow"/>
<bool key="IBUIAutoresizesSubviews">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<bool key="IBUIUserInteractionEnabled">NO</bool>
@@ -58,10 +58,9 @@
</object>
<object class="IBUIImageView" id="533754865">
<reference key="NSNextResponder" ref="766721923"/>
- <int key="NSvFlags">292</int>
+ <int key="NSvFlags">301</int>
<string key="NSFrame">{{357, 17}, {309, 165}}</string>
<reference key="NSSuperview" ref="766721923"/>
- <reference key="NSWindow"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
@@ -72,10 +71,9 @@
</object>
<object class="IBUIButton" id="410546531">
<reference key="NSNextResponder" ref="766721923"/>
- <int key="NSvFlags">292</int>
+ <int key="NSvFlags">301</int>
<string key="NSFrame">{{441, 702}, {142, 64}}</string>
<reference key="NSSuperview" ref="766721923"/>
- <reference key="NSWindow"/>
<bool key="IBUIOpaque">NO</bool>
<int key="IBUITag">1</int>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
@@ -105,10 +103,9 @@
</object>
<object class="IBUIButton" id="495854712">
<reference key="NSNextResponder" ref="766721923"/>
- <int key="NSvFlags">292</int>
+ <int key="NSvFlags">268</int>
<string key="NSFrame">{{20, 693}, {64, 64}}</string>
<reference key="NSSuperview" ref="766721923"/>
- <reference key="NSWindow"/>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
@@ -127,10 +124,9 @@
</object>
<object class="IBUIButton" id="688316814">
<reference key="NSNextResponder" ref="766721923"/>
- <int key="NSvFlags">292</int>
+ <int key="NSvFlags">265</int>
<string key="NSFrame">{{940, 693}, {64, 64}}</string>
<reference key="NSSuperview" ref="766721923"/>
- <reference key="NSWindow"/>
<bool key="IBUIOpaque">NO</bool>
<int key="IBUITag">2</int>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
@@ -150,10 +146,9 @@
</object>
<object class="IBUIView" id="123574818">
<reference key="NSNextResponder" ref="766721923"/>
- <int key="NSvFlags">278</int>
+ <int key="NSvFlags">301</int>
<string key="NSFrame">{{0, 60}, {320, 620}}</string>
<reference key="NSSuperview" ref="766721923"/>
- <reference key="NSWindow"/>
<object class="NSColor" key="IBUIBackgroundColor" id="720784738">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MCAwAA</bytes>
@@ -164,10 +159,9 @@
</object>
<object class="IBUIView" id="983956256">
<reference key="NSNextResponder" ref="766721923"/>
- <int key="NSvFlags">277</int>
+ <int key="NSvFlags">301</int>
<string key="NSFrame">{{337, 187}, {350, 505}}</string>
<reference key="NSSuperview" ref="766721923"/>
- <reference key="NSWindow"/>
<reference key="IBUIBackgroundColor" ref="720784738"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
@@ -178,7 +172,6 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{269, 724}, {150, 23}}</string>
<reference key="NSSuperview" ref="766721923"/>
- <reference key="NSWindow"/>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
@@ -186,39 +179,9 @@
<float key="IBUIValue">0.05000000074505806</float>
<float key="IBUIMaxValue">0.05000000074505806</float>
</object>
- <object class="IBUILabel" id="66923483">
- <reference key="NSNextResponder" ref="766721923"/>
- <int key="NSvFlags">292</int>
- <string key="NSFrame">{{121, 720}, {148, 30}}</string>
- <reference key="NSSuperview" ref="766721923"/>
- <reference key="NSWindow"/>
- <bool key="IBUIOpaque">NO</bool>
- <bool key="IBUIClipsSubviews">YES</bool>
- <int key="IBUIContentMode">7</int>
- <bool key="IBUIUserInteractionEnabled">NO</bool>
- <string key="targetRuntimeIdentifier">IBIPadFramework</string>
- <string key="IBUIText">Label</string>
- <object class="NSFont" key="IBUIFont">
- <string key="NSName">Helvetica-Oblique</string>
- <double key="NSSize">18</double>
- <int key="NSfFlags">16</int>
- </object>
- <object class="NSColor" key="IBUITextColor">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MQA</bytes>
- <object class="NSColorSpace" key="NSCustomColorSpace">
- <int key="NSID">2</int>
- </object>
- </object>
- <nil key="IBUIHighlightedColor"/>
- <int key="IBUIBaselineAdjustment">1</int>
- <float key="IBUIMinimumFontSize">10</float>
- <int key="IBUITextAlignment">1</int>
- </object>
</object>
<string key="NSFrameSize">{1024, 768}</string>
<reference key="NSSuperview"/>
- <reference key="NSWindow"/>
<reference key="IBUIBackgroundColor" ref="473179629"/>
<bool key="IBUIClipsSubviews">YES</bool>
<object class="IBUISimulatedOrientationMetrics" key="IBUISimulatedOrientationMetrics">
@@ -335,14 +298,6 @@
<int key="connectionID">61</int>
</object>
<object class="IBConnectionRecord">
- <object class="IBCocoaTouchOutletConnection" key="connection">
- <string key="label">sizeLabel</string>
- <reference key="source" ref="670598485"/>
- <reference key="destination" ref="66923483"/>
- </object>
- <int key="connectionID">65</int>
- </object>
- <object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">sliderChanged:</string>
<reference key="source" ref="1000322445"/>
@@ -360,6 +315,14 @@
</object>
<int key="connectionID">67</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">titleImage</string>
+ <reference key="source" ref="841351856"/>
+ <reference key="destination" ref="533754865"/>
+ </object>
+ <int key="connectionID">68</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -394,7 +357,6 @@
<reference ref="123574818"/>
<reference ref="983956256"/>
<reference ref="1000322445"/>
- <reference ref="66923483"/>
</object>
<reference key="parent" ref="0"/>
</object>
@@ -467,12 +429,6 @@
<reference key="parent" ref="766721923"/>
<string key="objectName">Filter Slider</string>
</object>
- <object class="IBObjectRecord">
- <int key="objectID">64</int>
- <reference key="object" ref="66923483"/>
- <reference key="parent" ref="766721923"/>
- <string key="objectName">Filter Label</string>
- </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -506,16 +462,15 @@
<string>55.CustomClassName</string>
<string>55.IBEditorWindowLastContentRect</string>
<string>55.IBPluginDependency</string>
+ <string>60.CustomClassName</string>
<string>60.IBPluginDependency</string>
<string>60.IBViewBoundsToFrameTransform</string>
- <string>64.IBPluginDependency</string>
- <string>64.IBViewBoundsToFrameTransform</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>GameConfigViewController</string>
<string>UIResponder</string>
- <string>{{289, 287}, {1024, 768}}</string>
+ <string>{{252, 239}, {1024, 768}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<object class="NSAffineTransform">
@@ -554,14 +509,11 @@
<string>MapConfigViewController</string>
<string>{{126, 377}, {1024, 768}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string>ValueTrackingSliderView</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">AUNRAABEMoAAA</bytes>
</object>
- <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- <object class="NSAffineTransform">
- <bytes key="NSTransformStruct">P4AAAL+AAADCtgAAxDoAAA</bytes>
- </object>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
@@ -580,7 +532,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">67</int>
+ <int key="maxID">68</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -627,12 +579,14 @@
<string>mapConfigViewController</string>
<string>schemeWeaponConfigViewController</string>
<string>teamConfigViewController</string>
+ <string>titleImage</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>MapConfigViewController</string>
<string>SchemeWeaponConfigViewController</string>
<string>TeamConfigViewController</string>
+ <string>UIImageView</string>
</object>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
@@ -642,6 +596,7 @@
<string>mapConfigViewController</string>
<string>schemeWeaponConfigViewController</string>
<string>teamConfigViewController</string>
+ <string>titleImage</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -657,6 +612,10 @@
<string key="name">teamConfigViewController</string>
<string key="candidateClassName">TeamConfigViewController</string>
</object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">titleImage</string>
+ <string key="candidateClassName">UIImageView</string>
+ </object>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
@@ -720,7 +679,6 @@
<string>maxLabel</string>
<string>previewButton</string>
<string>segmentedControl</string>
- <string>sizeLabel</string>
<string>slider</string>
<string>tableView</string>
</object>
@@ -729,8 +687,7 @@
<string>UILabel</string>
<string>MapPreviewButtonView</string>
<string>UISegmentedControl</string>
- <string>UILabel</string>
- <string>UISlider</string>
+ <string>ValueTrackingSliderView</string>
<string>UITableView</string>
</object>
</object>
@@ -741,7 +698,6 @@
<string>maxLabel</string>
<string>previewButton</string>
<string>segmentedControl</string>
- <string>sizeLabel</string>
<string>slider</string>
<string>tableView</string>
</object>
@@ -760,12 +716,8 @@
<string key="candidateClassName">UISegmentedControl</string>
</object>
<object class="IBToOneOutletInfo">
- <string key="name">sizeLabel</string>
- <string key="candidateClassName">UILabel</string>
- </object>
- <object class="IBToOneOutletInfo">
<string key="name">slider</string>
- <string key="candidateClassName">UISlider</string>
+ <string key="candidateClassName">ValueTrackingSliderView</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">tableView</string>
@@ -815,14 +767,22 @@
</object>
<object class="IBPartialClassDescription">
<string key="className">UILabel</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier" id="379894190">
+ <object class="IBClassDescriptionSource" key="sourceIdentifier" id="106046383">
<string key="majorKey">IBProjectSource</string>
- <string key="minorKey">ExtraCategories.h</string>
+ <string key="minorKey">Classes/ExtraCategories.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UITableView</string>
- <reference key="sourceIdentifier" ref="379894190"/>
+ <reference key="sourceIdentifier" ref="106046383"/>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">ValueTrackingSliderView</string>
+ <string key="superclassName">UISlider</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">ValueTrackingSliderView.h</string>
+ </object>
</object>
</object>
<object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.h Mon Feb 06 23:21:04 2012 +0100
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.h Tue Feb 07 01:18:29 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;
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Mon Feb 06 23:21:04 2012 +0100
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Tue Feb 07 01:18:29 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);
--- a/project_files/HedgewarsMobile/Classes/MapConfigViewController-iPad.xib Mon Feb 06 23:21:04 2012 +0100
+++ b/project_files/HedgewarsMobile/Classes/MapConfigViewController-iPad.xib Tue Feb 07 01:18:29 2012 +0100
@@ -44,7 +44,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBUISegmentedControl" id="88728219">
<reference key="NSNextResponder" ref="191373211"/>
- <int key="NSvFlags">289</int>
+ <int key="NSvFlags">261</int>
<string key="NSFrame">{{20, 166}, {280, 30}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
@@ -113,6 +113,33 @@
<bool key="IBUIShowsSelectionImmediatelyOnTouchBegin">YES</bool>
<float key="IBUIRowHeight">44</float>
</object>
+ <object class="IBUIButton" id="426759828">
+ <reference key="NSNextResponder" ref="191373211"/>
+ <int key="NSvFlags">301</int>
+ <string key="NSFrame">{{32, 32}, {256, 128}}</string>
+ <reference key="NSSuperview" ref="191373211"/>
+ <bool key="IBUIOpaque">NO</bool>
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ <int key="IBUIContentHorizontalAlignment">0</int>
+ <int key="IBUIContentVerticalAlignment">0</int>
+ <object class="NSFont" key="IBUIFont">
+ <string key="NSName">Helvetica-Bold</string>
+ <double key="NSSize">15</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ <object class="NSColor" key="IBUIHighlightedTitleColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MQA</bytes>
+ </object>
+ <object class="NSColor" key="IBUINormalTitleColor">
+ <int key="NSColorSpace">1</int>
+ <bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
+ </object>
+ <object class="NSColor" key="IBUINormalTitleShadowColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC41AA</bytes>
+ </object>
+ </object>
</object>
<string key="NSFrameSize">{320, 768}</string>
<reference key="NSSuperview"/>
@@ -177,6 +204,31 @@
</object>
<int key="connectionID">69</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">previewButton</string>
+ <reference key="source" ref="372490531"/>
+ <reference key="destination" ref="426759828"/>
+ </object>
+ <int key="connectionID">128</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchEventConnection" key="connection">
+ <string key="label">mapButtonPressed:</string>
+ <reference key="source" ref="426759828"/>
+ <reference key="destination" ref="372490531"/>
+ <int key="IBEventType">7</int>
+ </object>
+ <int key="connectionID">129</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="426759828"/>
+ <reference key="destination" ref="372490531"/>
+ </object>
+ <int key="connectionID">130</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -205,6 +257,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="394383001"/>
<reference ref="88728219"/>
+ <reference ref="426759828"/>
</object>
<reference key="parent" ref="0"/>
</object>
@@ -218,6 +271,11 @@
<reference key="object" ref="88728219"/>
<reference key="parent" ref="191373211"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">127</int>
+ <reference key="object" ref="426759828"/>
+ <reference key="parent" ref="191373211"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -228,6 +286,9 @@
<string>-2.CustomClassName</string>
<string>1.IBEditorWindowLastContentRect</string>
<string>1.IBPluginDependency</string>
+ <string>127.CustomClassName</string>
+ <string>127.IBPluginDependency</string>
+ <string>127.IBViewBoundsToFrameTransform</string>
<string>66.IBPluginDependency</string>
<string>66.IBViewBoundsToFrameTransform</string>
<string>7.IBPluginDependency</string>
@@ -239,6 +300,11 @@
<string>UIResponder</string>
<string>{{289, 181}, {320, 768}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string>MapPreviewButtonView</string>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <object class="NSAffineTransform">
+ <bytes key="NSTransformStruct">AUIAAABB0AAAA</bytes>
+ </object>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">P4AAAL+AAABEMAAAxCmAAA</bytes>
@@ -265,7 +331,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">126</int>
+ <int key="maxID">130</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -405,14 +471,14 @@
</object>
<object class="IBPartialClassDescription">
<string key="className">UILabel</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier" id="1034187891">
+ <object class="IBClassDescriptionSource" key="sourceIdentifier" id="823133985">
<string key="majorKey">IBProjectSource</string>
- <string key="minorKey">Classes/HWUtils.h</string>
+ <string key="minorKey">Classes/ExtraCategories.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UITableView</string>
- <reference key="sourceIdentifier" ref="1034187891"/>
+ <reference key="sourceIdentifier" ref="823133985"/>
</object>
</object>
<object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
--- a/project_files/HedgewarsMobile/Classes/MapConfigViewController.h Mon Feb 06 23:21:04 2012 +0100
+++ b/project_files/HedgewarsMobile/Classes/MapConfigViewController.h Tue Feb 07 01:18:29 2012 +0100
@@ -21,7 +21,7 @@
#import <UIKit/UIKit.h>
#import "MapPreviewButtonView.h"
-
+#import "ValueTrackingSliderView.h"
@interface MapConfigViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, MapPreviewViewDelegate> {
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;
--- a/project_files/HedgewarsMobile/Classes/MapConfigViewController.m Mon Feb 06 23:21:04 2012 +0100
+++ b/project_files/HedgewarsMobile/Classes/MapConfigViewController.m Tue Feb 07 01:18:29 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);
--- a/project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m Mon Feb 06 23:21:04 2012 +0100
+++ b/project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m Tue Feb 07 01:18:29 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];
--- a/project_files/HedgewarsMobile/Classes/TeamConfigViewController.m Mon Feb 06 23:21:04 2012 +0100
+++ b/project_files/HedgewarsMobile/Classes/TeamConfigViewController.m Tue Feb 07 01:18:29 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];
--- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Mon Feb 06 23:21:04 2012 +0100
+++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Tue Feb 07 01:18:29 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 = "<group>"; };
610782941440EE5C00645B29 /* credits.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = credits.plist; path = Resources/credits.plist; sourceTree = "<group>"; };
610782951440EE5C00645B29 /* gameMods.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = gameMods.plist; path = Resources/gameMods.plist; sourceTree = "<group>"; };
+ 610C8E3514E018D200CF5C4C /* ValueTrackingSliderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValueTrackingSliderView.h; sourceTree = "<group>"; };
+ 610C8E3614E018D200CF5C4C /* ValueTrackingSliderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ValueTrackingSliderView.m; sourceTree = "<group>"; };
6115651A147F48AE006729A9 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = Locale/English.lproj/About.strings; sourceTree = "<group>"; };
6115651B147F48AE006729A9 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = Locale/English.lproj/Localizable.strings; sourceTree = "<group>"; };
6115651C147F48AE006729A9 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = Locale/English.lproj/Scheme.strings; sourceTree = "<group>"; };
@@ -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;
};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/HedgewarsMobile/ValueTrackingSliderView.h Tue Feb 07 01:18:29 2012 +0100
@@ -0,0 +1,36 @@
+/*
+ * Hedgewars-iOS, a Hedgewars port for iOS devices
+ * Copyright (c) 2009-2011 Vittorio Giovara <vittorio.giovara@gmail.com>
+ *
+ * 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 <Foundation/Foundation.h>
+
+@class SliderValuePopupView;
+
+@interface ValueTrackingSliderView : UISlider {
+ SliderValuePopupView *valuePopupView;
+ NSString *textValue;
+}
+
+@property (nonatomic, readonly) CGRect thumbRect;
+@property (nonatomic, retain) NSString *textValue;
+
+@end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/HedgewarsMobile/ValueTrackingSliderView.m Tue Feb 07 01:18:29 2012 +0100
@@ -0,0 +1,193 @@
+/*
+ * Hedgewars-iOS, a Hedgewars port for iOS devices
+ * Copyright (c) 2009-2011 Vittorio Giovara <vittorio.giovara@gmail.com>
+ *
+ * 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