author | koda |
Sun, 20 Jun 2010 18:35:59 +0200 | |
changeset 3523 | 6592fbb969da |
parent 3514 | 59dbd31e9953 |
child 3525 | 1d7b056ff866 |
permissions | -rw-r--r-- |
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
1 |
// |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
2 |
// overlayViewController.m |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
3 |
// HedgewarsMobile |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
4 |
// |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
5 |
// Created by Vittorio on 16/03/10. |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
6 |
// Copyright 2010 __MyCompanyName__. All rights reserved. |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
7 |
// |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
8 |
|
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
9 |
#import "OverlayViewController.h" |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
10 |
#import "SDL_uikitappdelegate.h" |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
11 |
#import "PascalImports.h" |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
12 |
#import "CGPointUtils.h" |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
13 |
#import "SDL_mouse.h" |
3463 | 14 |
#import "SDL_config_iphoneos.h" |
3305 | 15 |
#import "PopoverMenuViewController.h" |
3335 | 16 |
#import "CommodityFunctions.h" |
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
17 |
|
3463 | 18 |
#define HIDING_TIME_DEFAULT [NSDate dateWithTimeIntervalSinceNow:2.7] |
19 |
#define HIDING_TIME_NEVER [NSDate dateWithTimeIntervalSinceNow:10000] |
|
20 |
||
21 |
||
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
22 |
@implementation OverlayViewController |
3463 | 23 |
@synthesize popoverController, popupMenu, writeChatTextField; |
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
24 |
|
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
25 |
|
3335 | 26 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
27 |
return rotationManager(interfaceOrientation); |
|
28 |
} |
|
29 |
||
30 |
||
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
31 |
-(void) didReceiveMemoryWarning { |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
32 |
// Releases the view if it doesn't have a superview. |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
33 |
[super didReceiveMemoryWarning]; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
34 |
// Release any cached data, images, etc that aren't in use. |
3490 | 35 |
if (popupMenu.view.superview == nil) |
36 |
popupMenu = nil; |
|
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
37 |
} |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
38 |
|
3385 | 39 |
-(void) didRotate:(NSNotification *)notification { |
40 |
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; |
|
41 |
CGRect rect = [[UIScreen mainScreen] bounds]; |
|
3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
42 |
CGRect usefulRect = CGRectMake(0, 0, rect.size.width, rect.size.height); |
3463 | 43 |
UIView *sdlView = [[[UIApplication sharedApplication] keyWindow] viewWithTag:12345]; |
3385 | 44 |
|
3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
45 |
[UIView beginAnimations:@"rotation" context:NULL]; |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
46 |
[UIView setAnimationDuration:0.8f]; |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
47 |
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
48 |
switch (orientation) { |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
49 |
case UIDeviceOrientationLandscapeLeft: |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
50 |
sdlView.transform = CGAffineTransformMakeRotation(degreesToRadian(0)); |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
51 |
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(90)); |
3463 | 52 |
[self chatDisappear]; |
3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
53 |
HW_setLandscape(YES); |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
54 |
break; |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
55 |
case UIDeviceOrientationLandscapeRight: |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
56 |
sdlView.transform = CGAffineTransformMakeRotation(degreesToRadian(180)); |
3385 | 57 |
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(-90)); |
3463 | 58 |
[self chatDisappear]; |
3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
59 |
HW_setLandscape(YES); |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
60 |
break; |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
61 |
case UIDeviceOrientationPortrait: |
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3490
diff
changeset
|
62 |
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3490
diff
changeset
|
63 |
sdlView.transform = CGAffineTransformMakeRotation(degreesToRadian(270)); |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3490
diff
changeset
|
64 |
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(0)); |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3490
diff
changeset
|
65 |
[self chatAppear]; |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3490
diff
changeset
|
66 |
HW_setLandscape(NO); |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3490
diff
changeset
|
67 |
} |
3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
68 |
break; |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
69 |
case UIDeviceOrientationPortraitUpsideDown: |
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3490
diff
changeset
|
70 |
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3490
diff
changeset
|
71 |
sdlView.transform = CGAffineTransformMakeRotation(degreesToRadian(90)); |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3490
diff
changeset
|
72 |
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(180)); |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3490
diff
changeset
|
73 |
[self chatAppear]; |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3490
diff
changeset
|
74 |
HW_setLandscape(NO); |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3490
diff
changeset
|
75 |
} |
3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
76 |
break; |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
77 |
default: |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
78 |
break; |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
79 |
} |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
80 |
self.view.frame = usefulRect; |
3463 | 81 |
//sdlView.frame = usefulRect; |
3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3385
diff
changeset
|
82 |
[UIView commitAnimations]; |
3340 | 83 |
} |
3385 | 84 |
|
3463 | 85 |
-(void) chatAppear { |
86 |
if (writeChatTextField == nil) { |
|
87 |
writeChatTextField = [[UITextField alloc] initWithFrame:CGRectMake(0, 100, 768, [UIFont systemFontSize]+8)]; |
|
88 |
writeChatTextField.textColor = [UIColor whiteColor]; |
|
89 |
writeChatTextField.backgroundColor = [UIColor blueColor]; |
|
90 |
writeChatTextField.autocapitalizationType = UITextAutocapitalizationTypeNone; |
|
91 |
writeChatTextField.autocorrectionType = UITextAutocorrectionTypeNo; |
|
92 |
writeChatTextField.enablesReturnKeyAutomatically = NO; |
|
93 |
writeChatTextField.keyboardAppearance = UIKeyboardAppearanceDefault; |
|
94 |
writeChatTextField.keyboardType = UIKeyboardTypeDefault; |
|
95 |
writeChatTextField.returnKeyType = UIReturnKeyDefault; |
|
96 |
writeChatTextField.secureTextEntry = NO; |
|
97 |
[self.view addSubview:writeChatTextField]; |
|
98 |
} |
|
99 |
writeChatTextField.alpha = 1; |
|
3479 | 100 |
[self activateOverlay]; |
101 |
[dimTimer setFireDate:HIDING_TIME_NEVER]; |
|
3463 | 102 |
} |
103 |
||
104 |
-(void) chatDisappear { |
|
105 |
writeChatTextField.alpha = 0; |
|
106 |
[writeChatTextField resignFirstResponder]; |
|
107 |
[dimTimer setFireDate:HIDING_TIME_DEFAULT]; |
|
108 |
} |
|
109 |
||
3523 | 110 |
#pragma mark - |
111 |
#pragma mark View Management |
|
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
112 |
-(void) viewDidLoad { |
3308 | 113 |
isPopoverVisible = NO; |
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
114 |
self.view.alpha = 0; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
115 |
self.view.center = CGPointMake(self.view.frame.size.height/2.0, self.view.frame.size.width/2.0); |
3385 | 116 |
|
3317
198ec44b6d92
minor tweaks, icon for ipad, merged overlayviewcontroller, pop viewcontroller when selected a hat
koda
parents:
3308
diff
changeset
|
117 |
|
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
118 |
dimTimer = [[NSTimer alloc] initWithFireDate:[NSDate dateWithTimeIntervalSinceNow:6] |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
119 |
interval:1000 |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
120 |
target:self |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
121 |
selector:@selector(dimOverlay) |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
122 |
userInfo:nil |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
123 |
repeats:YES]; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
124 |
|
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
125 |
// add timer too runloop, otherwise it doesn't work |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
126 |
[[NSRunLoop currentRunLoop] addTimer:dimTimer forMode:NSDefaultRunLoopMode]; |
3357 | 127 |
|
128 |
// listen for dismissal of the popover (see below) |
|
129 |
[[NSNotificationCenter defaultCenter] addObserver:self |
|
130 |
selector:@selector(dismissPopover) |
|
131 |
name:@"dismissPopover" |
|
132 |
object:nil]; |
|
3385 | 133 |
|
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3490
diff
changeset
|
134 |
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3490
diff
changeset
|
135 |
[[NSNotificationCenter defaultCenter] addObserver:self |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3490
diff
changeset
|
136 |
selector:@selector(didRotate:) |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3490
diff
changeset
|
137 |
name:@"UIDeviceOrientationDidChangeNotification" |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3490
diff
changeset
|
138 |
object:nil]; |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3490
diff
changeset
|
139 |
|
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3490
diff
changeset
|
140 |
//self.view.transform = CGAffineTransformRotate(self.view.transform, (M_PI/2.0)); |
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
141 |
[UIView beginAnimations:@"showing overlay" context:NULL]; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
142 |
[UIView setAnimationDuration:1]; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
143 |
self.view.alpha = 1; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
144 |
[UIView commitAnimations]; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
145 |
} |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
146 |
|
3463 | 147 |
-(void) viewDidUnload { |
148 |
self.writeChatTextField = nil; |
|
149 |
self.popoverController = nil; |
|
150 |
self.popupMenu = nil; |
|
151 |
[super viewDidUnload]; |
|
3490 | 152 |
MSG_DIDUNLOAD(); |
3463 | 153 |
} |
154 |
||
155 |
-(void) dealloc { |
|
156 |
[dimTimer invalidate]; |
|
157 |
[writeChatTextField release]; |
|
158 |
[popupMenu release]; |
|
159 |
[popoverController release]; |
|
160 |
// dimTimer is autoreleased |
|
161 |
[super dealloc]; |
|
162 |
} |
|
163 |
||
3523 | 164 |
#pragma mark - |
165 |
#pragma mark Overlay actions and members |
|
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
166 |
// dim the overlay when there's no more input for a certain amount of time |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
167 |
-(IBAction) buttonReleased:(id) sender { |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
168 |
HW_allKeysUp(); |
3463 | 169 |
[dimTimer setFireDate:HIDING_TIME_DEFAULT]; |
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
170 |
} |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
171 |
|
3463 | 172 |
// nice transition for dimming, should be called only by the timer himself |
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
173 |
-(void) dimOverlay { |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
174 |
[UIView beginAnimations:@"overlay dim" context:NULL]; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
175 |
[UIView setAnimationDuration:0.6]; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
176 |
self.view.alpha = 0.2; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
177 |
[UIView commitAnimations]; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
178 |
} |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
179 |
|
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
180 |
// set the overlay visible and put off the timer for enough time |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
181 |
-(void) activateOverlay { |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
182 |
self.view.alpha = 1; |
3463 | 183 |
[dimTimer setFireDate:HIDING_TIME_NEVER]; |
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
184 |
} |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
185 |
|
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
186 |
// issue certain action based on the tag of the button |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
187 |
-(IBAction) buttonPressed:(id) sender { |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
188 |
[self activateOverlay]; |
3308 | 189 |
if (isPopoverVisible) { |
190 |
[self dismissPopover]; |
|
191 |
} |
|
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
192 |
UIButton *theButton = (UIButton *)sender; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
193 |
|
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
194 |
switch (theButton.tag) { |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
195 |
case 0: |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
196 |
HW_walkLeft(); |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
197 |
break; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
198 |
case 1: |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
199 |
HW_walkRight(); |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
200 |
break; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
201 |
case 2: |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
202 |
HW_aimUp(); |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
203 |
break; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
204 |
case 3: |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
205 |
HW_aimDown(); |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
206 |
break; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
207 |
case 4: |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
208 |
HW_shoot(); |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
209 |
break; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
210 |
case 5: |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
211 |
HW_jump(); |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
212 |
break; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
213 |
case 6: |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
214 |
HW_backjump(); |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
215 |
break; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
216 |
case 7: |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
217 |
HW_tab(); |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
218 |
break; |
3308 | 219 |
case 10: |
220 |
[self showPopover]; |
|
221 |
break; |
|
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
222 |
default: |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
223 |
NSLog(@"Nope"); |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
224 |
break; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
225 |
} |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
226 |
} |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
227 |
|
3305 | 228 |
// present a further check before closing game |
229 |
-(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex { |
|
230 |
if ([actionSheet cancelButtonIndex] != buttonIndex) |
|
231 |
HW_terminate(NO); |
|
232 |
else |
|
233 |
HW_pause(); |
|
234 |
} |
|
235 |
||
236 |
// show up a popover containing a popupMenuViewController; we hook it with setPopoverContentSize |
|
3308 | 237 |
// on iphone instead just use the tableViewController directly (and implement manually all animations) |
3305 | 238 |
-(IBAction) showPopover{ |
3308 | 239 |
isPopoverVisible = YES; |
3463 | 240 |
CGRect anchorForPopover; |
3308 | 241 |
Class popoverControllerClass = NSClassFromString(@"UIPopoverController"); |
242 |
if (popoverControllerClass) { |
|
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3490
diff
changeset
|
243 |
#if __IPHONE_3_2 |
3490 | 244 |
if (popupMenu == nil) |
245 |
popupMenu = [[PopoverMenuViewController alloc] initWithStyle:UITableViewStylePlain]; |
|
3308 | 246 |
popoverController = [[popoverControllerClass alloc] initWithContentViewController:popupMenu]; |
247 |
[popoverController setPopoverContentSize:CGSizeMake(220, 170) animated:YES]; |
|
248 |
[popoverController setPassthroughViews:[NSArray arrayWithObject:self.view]]; |
|
3463 | 249 |
|
250 |
if (UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation])) |
|
251 |
anchorForPopover = CGRectMake(960, 0, 220, 32); |
|
252 |
else |
|
253 |
anchorForPopover = CGRectMake(736, 0, 220, 32); |
|
3305 | 254 |
|
3463 | 255 |
[popoverController presentPopoverFromRect:anchorForPopover |
3308 | 256 |
inView:self.view |
3463 | 257 |
permittedArrowDirections:UIPopoverArrowDirectionUp |
3308 | 258 |
animated:YES]; |
3305 | 259 |
#endif |
260 |
} else { |
|
3490 | 261 |
if (popupMenu == nil) |
262 |
popupMenu = [[PopoverMenuViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
3308 | 263 |
popupMenu.view.backgroundColor = [UIColor clearColor]; |
264 |
popupMenu.view.frame = CGRectMake(480, 0, 200, 170); |
|
265 |
[self.view addSubview:popupMenu.view]; |
|
266 |
||
267 |
[UIView beginAnimations:@"showing popover" context:NULL]; |
|
268 |
[UIView setAnimationDuration:0.35]; |
|
269 |
popupMenu.view.frame = CGRectMake(280, 0, 200, 170); |
|
270 |
[UIView commitAnimations]; |
|
271 |
} |
|
272 |
popupMenu.tableView.scrollEnabled = NO; |
|
273 |
} |
|
274 |
||
3463 | 275 |
// on ipad just dismiss it, on iphone transtion to the right |
3308 | 276 |
-(void) dismissPopover { |
277 |
if (YES == isPopoverVisible) { |
|
278 |
isPopoverVisible = NO; |
|
279 |
||
280 |
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { |
|
3490 | 281 |
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2 |
3308 | 282 |
[popoverController dismissPopoverAnimated:YES]; |
283 |
#endif |
|
284 |
} else { |
|
285 |
[UIView beginAnimations:@"hiding popover" context:NULL]; |
|
286 |
[UIView setAnimationDuration:0.35]; |
|
287 |
popupMenu.view.frame = CGRectMake(480, 0, 200, 170); |
|
288 |
[UIView commitAnimations]; |
|
289 |
||
290 |
[popupMenu.view performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:0.35]; |
|
291 |
[popupMenu performSelector:@selector(release) withObject:nil afterDelay:0.35]; |
|
292 |
} |
|
293 |
[self buttonReleased:nil]; |
|
3305 | 294 |
} |
295 |
} |
|
296 |
||
3463 | 297 |
-(void) textFieldDoneEditing:(id) sender{ |
298 |
[sender resignFirstResponder]; |
|
299 |
} |
|
3305 | 300 |
|
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
301 |
#pragma mark - |
3305 | 302 |
#pragma mark Custom touch event handling |
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
303 |
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
304 |
NSArray *twoTouches; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
305 |
UITouch *touch = [touches anyObject]; |
3305 | 306 |
|
3308 | 307 |
if (isPopoverVisible) { |
308 |
[self dismissPopover]; |
|
309 |
} |
|
3463 | 310 |
if (writeChatTextField) { |
311 |
[self.writeChatTextField resignFirstResponder]; |
|
312 |
[dimTimer setFireDate:HIDING_TIME_DEFAULT]; |
|
313 |
} |
|
3347 | 314 |
|
315 |
gestureStartPoint = [touch locationInView:self.view]; |
|
3308 | 316 |
|
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
317 |
switch ([touches count]) { |
3523 | 318 |
/*case 1: |
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
319 |
initialDistanceForPinching = 0; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
320 |
switch ([touch tapCount]) { |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
321 |
case 1: |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
322 |
NSLog(@"X:%d Y:%d", (int)gestureStartPoint.x, (int)gestureStartPoint.y ); |
3347 | 323 |
//SDL_WarpMouseInWindow([SDLUIKitDelegate sharedAppDelegate].window, |
324 |
// (int)gestureStartPoint.y, width - (int)gestureStartPoint.x); |
|
325 |
//HW_click(); |
|
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
326 |
break; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
327 |
case 2: |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
328 |
HW_ammoMenu(); |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
329 |
break; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
330 |
default: |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
331 |
break; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
332 |
} |
3523 | 333 |
break;*/ |
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
334 |
case 2: |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
335 |
if (2 == [touch tapCount]) { |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
336 |
HW_zoomReset(); |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
337 |
} |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
338 |
|
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
339 |
// pinching |
3523 | 340 |
gestureStartPoint = CGPointMake(0, 0); |
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
341 |
twoTouches = [touches allObjects]; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
342 |
UITouch *first = [twoTouches objectAtIndex:0]; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
343 |
UITouch *second = [twoTouches objectAtIndex:1]; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
344 |
initialDistanceForPinching = distanceBetweenPoints([first locationInView:self.view], [second locationInView:self.view]); |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
345 |
break; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
346 |
default: |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
347 |
break; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
348 |
} |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
349 |
|
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
350 |
} |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
351 |
|
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
352 |
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { |
3523 | 353 |
gestureStartPoint = CGPointMake(0, 0); |
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
354 |
initialDistanceForPinching = 0; |
3523 | 355 |
//HW_allKeysUp(); |
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
356 |
} |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
357 |
|
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
358 |
-(void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { |
3347 | 359 |
// this can happen if the user puts more than 5 touches on the screen at once, or perhaps in other circumstances |
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
360 |
[self touchesEnded:touches withEvent:event]; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
361 |
} |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
362 |
|
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
363 |
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { |
3364 | 364 |
CGFloat minimumGestureLength; |
3347 | 365 |
int logCoeff; |
366 |
||
367 |
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { |
|
3364 | 368 |
minimumGestureLength = 5.0f; |
3347 | 369 |
logCoeff = 19; |
370 |
} else { |
|
3364 | 371 |
minimumGestureLength = 3.0f; |
3347 | 372 |
logCoeff = 3; |
373 |
} |
|
374 |
||
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
375 |
NSArray *twoTouches; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
376 |
CGPoint currentPosition; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
377 |
UITouch *touch = [touches anyObject]; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
378 |
|
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
379 |
switch ([touches count]) { |
3523 | 380 |
/*case 1: |
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
381 |
currentPosition = [touch locationInView:self.view]; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
382 |
// panning |
3347 | 383 |
CGFloat deltaX = fabsf(gestureStartPoint.x - currentPosition.x); |
384 |
CGFloat deltaY = fabsf(gestureStartPoint.y - currentPosition.y); |
|
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
385 |
|
3523 | 386 |
// the two ifs are not mutually exclusive |
3347 | 387 |
if (deltaX >= minimumGestureLength) { |
3523 | 388 |
Dlog(@"deltaX: %f deltaY: %f", deltaX, deltaY); |
3364 | 389 |
if (currentPosition.x > gestureStartPoint.x) { |
3356 | 390 |
HW_cursorLeft(logCoeff*log(deltaX)); |
3347 | 391 |
} else { |
3356 | 392 |
HW_cursorRight(logCoeff*log(deltaX)); |
3347 | 393 |
} |
394 |
||
395 |
} |
|
396 |
if (deltaY >= minimumGestureLength) { |
|
3523 | 397 |
DLog(@"deltaX: %f deltaY: %f", deltaX, deltaY); |
3364 | 398 |
if (currentPosition.y < gestureStartPoint.y) { |
3356 | 399 |
HW_cursorDown(logCoeff*log(deltaY)); |
3347 | 400 |
} else { |
3356 | 401 |
HW_cursorUp(logCoeff*log(deltaY)); |
3347 | 402 |
} |
403 |
} |
|
404 |
||
3523 | 405 |
break;*/ |
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
406 |
case 2: |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
407 |
twoTouches = [touches allObjects]; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
408 |
UITouch *first = [twoTouches objectAtIndex:0]; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
409 |
UITouch *second = [twoTouches objectAtIndex:1]; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
410 |
CGFloat currentDistanceOfPinching = distanceBetweenPoints([first locationInView:self.view], [second locationInView:self.view]); |
3523 | 411 |
const int pinchDelta = 40; |
412 |
||
413 |
if (0 != initialDistanceForPinching) { |
|
414 |
if (currentDistanceOfPinching - initialDistanceForPinching > pinchDelta) { |
|
415 |
HW_zoomIn(); |
|
416 |
initialDistanceForPinching = currentDistanceOfPinching; |
|
417 |
} |
|
418 |
else if (initialDistanceForPinching - currentDistanceOfPinching > pinchDelta) { |
|
419 |
HW_zoomOut(); |
|
420 |
initialDistanceForPinching = currentDistanceOfPinching; |
|
421 |
} |
|
422 |
} else |
|
423 |
initialDistanceForPinching = currentDistanceOfPinching; |
|
424 |
||
3117
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
425 |
break; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
426 |
default: |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
427 |
break; |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
428 |
} |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
429 |
} |
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
430 |
|
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
431 |
|
f3e363a9b7db
complete previous commit (which broken my local copy as well)
koda
parents:
diff
changeset
|
432 |
@end |