--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/HedgewarsMobile/Classes/ObjcExports.h Sun Oct 31 01:49:20 2010 +0200
@@ -0,0 +1,32 @@
+/*
+ * Hedgewars-iOS, a Hedgewars port for iOS devices
+ * Copyright (c) 2009-2010 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 30/10/2010.
+ */
+
+
+#define ANIMATION_DURATION 0.25
+#define CONFIRMATION_TAG 5959
+#define GRENADE_TAG 9595
+#define REPLAYBLACKVIEW_TAG 9955
+#define ACTIVITYINDICATOR_TAG 987654
+
+void objcExportsInit();
+BOOL isGameRunning();
+void setGameRunning(BOOL value);
+NSInteger cachedGrenadeTime();
+void setGrenadeTime(NSInteger value);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/HedgewarsMobile/Classes/ObjcExports.m Sun Oct 31 01:49:20 2010 +0200
@@ -0,0 +1,146 @@
+/*
+ * Hedgewars-iOS, a Hedgewars port for iOS devices
+ * Copyright (c) 2009-2010 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 30/10/2010.
+ */
+
+
+#import "ObjcExports.h"
+
+#pragma mark -
+#pragma mark internal variables
+// actual game started (controls should be enabled)
+BOOL gameRunning;
+// black screen present
+BOOL savedGame;
+// cache the grenade time
+NSInteger grenadeTime;
+
+#pragma mark -
+#pragma mark functions called like oop
+void objcExportsInit() {
+ gameRunning = NO;
+ savedGame = NO;
+ grenadeTime = 2;
+}
+
+BOOL inline isGameRunning() {
+ return gameRunning;
+}
+
+void inline setGameRunning(BOOL value) {
+ gameRunning = value;
+}
+
+NSInteger cachedGrenadeTime() {
+ return grenadeTime;
+}
+
+void inline setGrenadeTime(NSInteger value) {
+ grenadeTime = value;
+}
+
+#pragma mark -
+#pragma mark functions called by pascal code
+// called by uStore from AddProgress
+void startSpinning() {
+ gameRunning = NO;
+ UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
+ UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
+ indicator.tag = ACTIVITYINDICATOR_TAG;
+ int offset;
+ if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft)
+ offset = -120;
+ else
+ offset = 120;
+ if (IS_DUALHEAD())
+ indicator.center = CGPointMake(theWindow.frame.size.width/2, theWindow.frame.size.height/2 + offset);
+ else
+ indicator.center = CGPointMake(theWindow.frame.size.width/2 + offset, theWindow.frame.size.height/2);
+ indicator.hidesWhenStopped = YES;
+ [indicator startAnimating];
+ [theWindow addSubview:indicator];
+ [indicator release];
+}
+
+// called by uStore from FinishProgress and by OverlayViewController by replayBegan
+void stopSpinning() {
+ UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
+ UIActivityIndicatorView *indicator = (UIActivityIndicatorView *)[theWindow viewWithTag:ACTIVITYINDICATOR_TAG];
+ [indicator stopAnimating];
+ HW_zoomSet(1.7);
+ if (savedGame == NO)
+ gameRunning = YES;
+}
+
+// called by CCHandlers from chNextTurn
+void clearView() {
+ UIWindow *theWindow = (IS_DUALHEAD()) ? [SDLUIKitDelegate sharedAppDelegate].uiwindow : [[UIApplication sharedApplication] keyWindow];
+ UIButton *theButton = (UIButton *)[theWindow viewWithTag:CONFIRMATION_TAG];
+ UISegmentedControl *theSegment = (UISegmentedControl *)[theWindow viewWithTag:GRENADE_TAG];
+
+ [UIView beginAnimations:@"remove button" context:NULL];
+ [UIView setAnimationDuration:ANIMATION_DURATION];
+ theButton.alpha = 0;
+ theSegment.alpha = 0;
+ [UIView commitAnimations];
+
+ if (theButton)
+ [theWindow performSelector:@selector(removeFromSuperview) withObject:theButton afterDelay:ANIMATION_DURATION];
+ if (theSegment)
+ [theWindow performSelector:@selector(removeFromSuperview) withObject:theSegment afterDelay:ANIMATION_DURATION];
+
+ grenadeTime = 2;
+}
+
+// called by hwengine
+void replayBegan() {
+ UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
+ UIView *blackView = [[UIView alloc] initWithFrame:theWindow.frame];
+ blackView.backgroundColor = [UIColor blackColor];
+ blackView.alpha = 0.6;
+ blackView.tag = REPLAYBLACKVIEW_TAG;
+ blackView.exclusiveTouch = NO;
+ blackView.multipleTouchEnabled = NO;
+ blackView.userInteractionEnabled = NO;
+
+ UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
+ indicator.center = theWindow.center;
+ [indicator startAnimating];
+ [blackView addSubview:indicator];
+ [indicator release];
+ [theWindow addSubview:blackView];
+ [blackView release];
+
+ savedGame = YES;
+ stopSpinning();
+}
+
+// called by uGame
+void replayFinished() {
+ UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
+ UIView *blackView = (UIView *)[theWindow viewWithTag:REPLAYBLACKVIEW_TAG];
+
+ [UIView beginAnimations:@"removing black" context:NULL];
+ [UIView setAnimationDuration:1];
+ blackView.alpha = 0;
+ [UIView commitAnimations];
+ [theWindow performSelector:@selector(removeFromSuperview) withObject:blackView afterDelay:1];
+
+ gameRunning = YES;
+ savedGame = NO;
+}
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.h Sun Oct 31 00:06:46 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.h Sun Oct 31 01:49:20 2010 +0200
@@ -79,11 +79,3 @@
-(void) cleanup;
@end
-
-// actual game started (controls should be enabled)
-BOOL isGameRunning;
-void setGameRunning(BOOL value);
-// black screen present
-BOOL isReplay;
-// cache the grenade time
-NSInteger cachedGrenadeTime;
\ No newline at end of file
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m Sun Oct 31 00:06:46 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m Sun Oct 31 01:49:20 2010 +0200
@@ -20,7 +20,6 @@
#import "OverlayViewController.h"
-#import "SDL_uikitappdelegate.h"
#import "InGameMenuViewController.h"
#import "HelpPageViewController.h"
#import "AmmoMenuViewController.h"
@@ -29,17 +28,13 @@
#import "CGPointUtils.h"
#import "SDL_config_iphoneos.h"
#import "SDL_mouse.h"
+#import "ObjcExports.h"
#define HIDING_TIME_DEFAULT [NSDate dateWithTimeIntervalSinceNow:2.7]
#define HIDING_TIME_NEVER [NSDate dateWithTimeIntervalSinceNow:10000]
#define doDim() [dimTimer setFireDate: (IS_DUALHEAD()) ? HIDING_TIME_NEVER : HIDING_TIME_DEFAULT]
#define doNotDim() [dimTimer setFireDate:HIDING_TIME_NEVER]
-#define CONFIRMATION_TAG 5959
-#define GRENADE_TAG 9595
-#define REPLAYBLACKVIEW_TAG 9955
-#define ACTIVITYINDICATOR_TAG 987654
-#define ANIMATION_DURATION 0.25
#define removeConfirmationInput() [[self.view viewWithTag:CONFIRMATION_TAG] removeFromSuperview];
@implementation OverlayViewController
@@ -112,10 +107,7 @@
#pragma mark View Management
-(id) initWithCoder:(NSCoder *)aDecoder {
if ((self = [super initWithCoder:aDecoder])) {
- isGameRunning = NO;
- isReplay = NO;
- cachedGrenadeTime = 2;
-
+ objcExportsInit();
isAttacking = NO;
wasVisible = NO;
isPopoverVisible = NO; // it is called "popover" even on the iphone
@@ -288,7 +280,7 @@
#pragma mark overlay user interaction
// nice transition for dimming, should be called only by the timer himself
-(void) dimOverlay {
- if (isGameRunning) {
+ if (isGameRunning()) {
[UIView beginAnimations:@"overlay dim" context:NULL];
[UIView setAnimationDuration:0.6];
self.view.alpha = 0.2;
@@ -304,7 +296,7 @@
// dim the overlay when there's no more input for a certain amount of time
-(IBAction) buttonReleased:(id) sender {
- if (isGameRunning == NO)
+ if (isGameRunning() == NO)
return;
UIButton *theButton = (UIButton *)sender;
@@ -337,7 +329,7 @@
-(IBAction) buttonPressed:(id) sender {
[self activateOverlay];
- if (isGameRunning == NO)
+ if (isGameRunning() == NO)
return;
if (isPopoverVisible)
@@ -422,9 +414,9 @@
-(void) setGrenadeTime:(id) sender {
UISegmentedControl *theSegment = (UISegmentedControl *)sender;
- if (cachedGrenadeTime != theSegment.selectedSegmentIndex) {
+ if (cachedGrenadeTime() != theSegment.selectedSegmentIndex) {
HW_setGrenadeTime(theSegment.selectedSegmentIndex + 1);
- cachedGrenadeTime = theSegment.selectedSegmentIndex;
+ setGrenadeTime(theSegment.selectedSegmentIndex);
}
}
@@ -490,7 +482,7 @@
NSSet *allTouches = [event allTouches];
UITouch *first, *second;
- if (isGameRunning == NO)
+ if (isGameRunning() == NO)
return;
// hide in-game menu
@@ -529,7 +521,7 @@
NSSet *allTouches = [event allTouches];
CGPoint currentPosition = [[[allTouches allObjects] objectAtIndex:0] locationInView:self.view];
- if (isGameRunning == NO)
+ if (isGameRunning() == NO)
return;
switch ([allTouches count]) {
@@ -582,7 +574,7 @@
[grenadeTime addTarget:self action:@selector(setGrenadeTime:) forControlEvents:UIControlEventValueChanged];
grenadeTime.frame = CGRectMake(screen.size.height / 2 - 125, screen.size.width, 250, 50);
- grenadeTime.selectedSegmentIndex = cachedGrenadeTime;
+ grenadeTime.selectedSegmentIndex = cachedGrenadeTime();
grenadeTime.tag = GRENADE_TAG;
[self.view addSubview:grenadeTime];
[grenadeTime release];
@@ -621,7 +613,7 @@
int x, y, dx, dy;
UITouch *touch, *first, *second;
- if (isGameRunning == NO)
+ if (isGameRunning() == NO)
return;
switch ([allTouches count]) {
@@ -674,97 +666,4 @@
}
}
-#pragma mark -
-#pragma mark Functions called by pascal code
-void inline setGameRunning(BOOL value) {
- isGameRunning = value;
-}
-
-// called by uStore from AddProgress
-void startSpinning() {
- setGameRunning(NO);
- UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
- UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
- indicator.tag = ACTIVITYINDICATOR_TAG;
- int offset;
- if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft)
- offset = -120;
- else
- offset = 120;
- if (IS_DUALHEAD())
- indicator.center = CGPointMake(theWindow.frame.size.width/2, theWindow.frame.size.height/2 + offset);
- else
- indicator.center = CGPointMake(theWindow.frame.size.width/2 + offset, theWindow.frame.size.height/2);
- indicator.hidesWhenStopped = YES;
- [indicator startAnimating];
- [theWindow addSubview:indicator];
- [indicator release];
-}
-
-// called by uStore from FinishProgress and by OverlayViewController by replayBegan
-void stopSpinning() {
- UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
- UIActivityIndicatorView *indicator = (UIActivityIndicatorView *)[theWindow viewWithTag:ACTIVITYINDICATOR_TAG];
- [indicator stopAnimating];
- HW_zoomSet(1.7);
- if (isReplay == NO)
- setGameRunning(YES);
-}
-
-// called by CCHandlers from chNextTurn
-void clearView() {
- UIWindow *theWindow = (IS_DUALHEAD()) ? [SDLUIKitDelegate sharedAppDelegate].uiwindow : [[UIApplication sharedApplication] keyWindow];
- UIButton *theButton = (UIButton *)[theWindow viewWithTag:CONFIRMATION_TAG];
- UISegmentedControl *theSegment = (UISegmentedControl *)[theWindow viewWithTag:GRENADE_TAG];
-
- [UIView beginAnimations:@"remove button" context:NULL];
- [UIView setAnimationDuration:ANIMATION_DURATION];
- theButton.alpha = 0;
- theSegment.alpha = 0;
- [UIView commitAnimations];
-
- if (theButton)
- [theWindow performSelector:@selector(removeFromSuperview) withObject:theButton afterDelay:ANIMATION_DURATION];
- if (theSegment)
- [theWindow performSelector:@selector(removeFromSuperview) withObject:theSegment afterDelay:ANIMATION_DURATION];
-
- cachedGrenadeTime = 2;
-}
-
-// called by hwengine
-void replayBegan() {
- UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
- UIView *blackView = [[UIView alloc] initWithFrame:theWindow.frame];
- blackView.backgroundColor = [UIColor blackColor];
- blackView.alpha = 0.6;
- blackView.tag = REPLAYBLACKVIEW_TAG;
- blackView.exclusiveTouch = NO;
- blackView.multipleTouchEnabled = NO;
- blackView.userInteractionEnabled = NO;
- UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
- indicator.center = theWindow.center;
- [indicator startAnimating];
- [blackView addSubview:indicator];
- [indicator release];
- [theWindow addSubview:blackView];
- [blackView release];
- isReplay = YES;
- stopSpinning();
-}
-
-// called by uGame
-void replayFinished() {
- UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
- UIView *blackView = (UIView *)[theWindow viewWithTag:REPLAYBLACKVIEW_TAG];
-
- [UIView beginAnimations:@"removing black" context:NULL];
- [UIView setAnimationDuration:1];
- blackView.alpha = 0;
- [UIView commitAnimations];
- [theWindow performSelector:@selector(removeFromSuperview) withObject:blackView afterDelay:1];
-
- setGameRunning(YES);
- isReplay = NO;
-}
-
@end
--- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Sun Oct 31 00:06:46 2010 +0200
+++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Sun Oct 31 01:49:20 2010 +0200
@@ -151,6 +151,7 @@
61A6710612747E4000B06CE7 /* backgroundCenter.png in Resources */ = {isa = PBXBuildFile; fileRef = 61F903E511DF58550068B24D /* backgroundCenter.png */; };
61B3D71C11EA6F2700EC7420 /* uKeys.pas in Sources */ = {isa = PBXBuildFile; fileRef = 617987FE114AA34C00BA94A9 /* uKeys.pas */; };
61C079E411F35A300072BF46 /* EditableCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = 61C079E311F35A300072BF46 /* EditableCellView.m */; };
+ 61D205A1127CDD1100ABD83E /* ObjcExports.m in Sources */ = {isa = PBXBuildFile; fileRef = 61D205A0127CDD1100ABD83E /* ObjcExports.m */; };
61DE8F221257EB1100B80214 /* AmmoMenuViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 61DE8F211257EB1100B80214 /* AmmoMenuViewController.m */; };
61E1F4F811D004240016A5AA /* adler32.pas in Sources */ = {isa = PBXBuildFile; fileRef = 61E1F4F711D004240016A5AA /* adler32.pas */; };
61EBA62A11DFF2BC0048B68A /* title.png in Resources */ = {isa = PBXBuildFile; fileRef = 61EBA62811DFF2BC0048B68A /* title.png */; };
@@ -888,6 +889,8 @@
61A117FE1168322700359010 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
61C079E211F35A300072BF46 /* EditableCellView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditableCellView.h; sourceTree = "<group>"; };
61C079E311F35A300072BF46 /* EditableCellView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EditableCellView.m; sourceTree = "<group>"; };
+ 61D2059F127CDD1100ABD83E /* ObjcExports.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjcExports.h; path = Classes/ObjcExports.h; sourceTree = "<group>"; };
+ 61D205A0127CDD1100ABD83E /* ObjcExports.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ObjcExports.m; path = Classes/ObjcExports.m; sourceTree = "<group>"; };
61DE8F201257EB1100B80214 /* AmmoMenuViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AmmoMenuViewController.h; sourceTree = "<group>"; };
61DE8F211257EB1100B80214 /* AmmoMenuViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AmmoMenuViewController.m; sourceTree = "<group>"; };
61E1F4F711D004240016A5AA /* adler32.pas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = adler32.pas; path = ../../hedgewars/adler32.pas; sourceTree = SOURCE_ROOT; };
@@ -1015,6 +1018,8 @@
6165922611CA9BD500D6E256 /* CommodityFunctions.m */,
6165922C11CA9BD500D6E256 /* UIImageExtra.h */,
6165922D11CA9BD500D6E256 /* UIImageExtra.m */,
+ 61D2059F127CDD1100ABD83E /* ObjcExports.h */,
+ 61D205A0127CDD1100ABD83E /* ObjcExports.m */,
);
name = "Other Sources";
sourceTree = "<group>";
@@ -2280,6 +2285,7 @@
619C5BA2124FA59000D041AE /* MapPreviewButtonView.m in Sources */,
61DE8F221257EB1100B80214 /* AmmoMenuViewController.m in Sources */,
61399013125D19C0003C2DC0 /* uMobile.pas in Sources */,
+ 61D205A1127CDD1100ABD83E /* ObjcExports.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
--- a/project_files/HedgewarsMobile/Hedgewars_Prefix.pch Sun Oct 31 00:06:46 2010 +0200
+++ b/project_files/HedgewarsMobile/Hedgewars_Prefix.pch Sun Oct 31 01:49:20 2010 +0200
@@ -23,6 +23,7 @@
#import "PascalImports.h"
#import "UIImageExtra.h"
#import "CommodityFunctions.h"
+#import "SDL_uikitappdelegate.h"
#import "SDL.h"
#import "SDL_video.h"
#import "SDL_net.h"