# HG changeset patch
# User koda
# Date 1262841803 0
# Node ID 334016e8d8951ebe931bb7adb301f2bceae5afcb
# Parent 83ad68ceef727af8442554971ff4b8526ffeb694
injection of custom code in SDL for iPhone in order to implement our frontend
initial support for (real) multitouch events
diff -r 83ad68ceef72 -r 334016e8d895 cocoaTouch/MainWindow.xib
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cocoaTouch/MainWindow.xib Thu Jan 07 05:23:23 2010 +0000
@@ -0,0 +1,686 @@
+
+
+
+ 784
+ 10C540
+ 740
+ 1038.25
+ 458.00
+
+
+
+
+
+ YES
+
+ IBFilesOwner
+
+
+ IBFirstResponder
+
+
+
+
+ 1316
+
+ {320, 480}
+
+ 1
+ MSAxIDEAA
+
+ NO
+ NO
+
+ 2
+
+
+
+
+
+ 2
+
+ YES
+
+ Item 5
+
+ 4
+ Custom
+
+ NSImage
+ toolicon.png
+
+
+
+
+
+ CustomPickerViewController
+
+
+ YES
+
+ Item 1
+
+ Date
+
+ NSImage
+ clockicon.png
+
+
+
+
+ DatePickerViewController
+
+
+ Item 2
+
+ 1
+ Single
+
+ NSImage
+ singleicon.png
+
+
+
+
+ SingleComponentPickerViewController
+
+
+ Item 3
+
+ 2
+ Double
+
+ NSImage
+ doubleicon.png
+
+
+
+
+
+ DoubleComponentPickerViewController
+
+
+ Item 4
+
+ 3
+ Dependent
+
+ NSImage
+ dependenticon.png
+
+
+
+
+
+ DependentComponentPickerViewController
+
+
+
+
+
+ 266
+ {{129, 330}, {163, 49}}
+
+ 3
+ MCAwAA
+
+ NO
+
+
+
+
+
+ YES
+
+
+ delegate
+
+
+
+ 4
+
+
+
+ controller
+
+
+
+ 23
+
+
+
+ window
+
+
+
+ 24
+
+
+
+
+ YES
+
+ 0
+
+
+
+
+
+ 2
+
+
+ YES
+
+
+
+
+ -1
+
+
+ File's Owner
+
+
+ 3
+
+
+
+
+ -2
+
+
+
+
+ 10
+
+
+ YES
+
+
+
+
+
+
+
+
+
+
+ 11
+
+
+
+
+ 12
+
+
+ YES
+
+
+
+
+
+ 13
+
+
+ YES
+
+
+
+
+
+ 14
+
+
+
+
+ 15
+
+
+
+
+ 16
+
+
+ YES
+
+
+
+
+
+ 17
+
+
+
+
+ 18
+
+
+ YES
+
+
+
+
+
+ 19
+
+
+
+
+ 20
+
+
+ YES
+
+
+
+
+
+ 21
+
+
+
+
+
+
+ YES
+
+ YES
+ -1.CustomClassName
+ -2.CustomClassName
+ 10.IBEditorWindowLastContentRect
+ 10.IBPluginDependency
+ 11.IBPluginDependency
+ 12.CustomClassName
+ 12.IBPluginDependency
+ 13.CustomClassName
+ 13.IBPluginDependency
+ 14.IBPluginDependency
+ 15.IBPluginDependency
+ 16.CustomClassName
+ 18.CustomClassName
+ 2.IBAttributePlaceholdersKey
+ 2.IBEditorWindowLastContentRect
+ 2.IBPluginDependency
+ 20.CustomClassName
+ 3.CustomClassName
+ 3.IBPluginDependency
+
+
+ YES
+ UIApplication
+ UIResponder
+ {{0, 654}, {320, 480}}
+ com.apple.InterfaceBuilder.IBCocoaTouchPlugin
+ com.apple.InterfaceBuilder.IBCocoaTouchPlugin
+ DatePickerViewController
+ com.apple.InterfaceBuilder.IBCocoaTouchPlugin
+ SingleComponentPickerViewController
+ com.apple.InterfaceBuilder.IBCocoaTouchPlugin
+ com.apple.InterfaceBuilder.IBCocoaTouchPlugin
+ com.apple.InterfaceBuilder.IBCocoaTouchPlugin
+ DoubleComponentPickerViewController
+ DependentComponentPickerViewController
+
+ YES
+
+
+ YES
+
+
+ {{820, 472}, {320, 480}}
+ com.apple.InterfaceBuilder.IBCocoaTouchPlugin
+ CustomPickerViewController
+ SDLUIKitDelegate
+ com.apple.InterfaceBuilder.IBCocoaTouchPlugin
+
+
+
+ YES
+
+
+ YES
+
+
+
+
+ YES
+
+
+ YES
+
+
+
+ 24
+
+
+
+ YES
+
+ DatePickerViewController
+ UIViewController
+
+ buttonPressed
+ id
+
+
+ date_picker
+ UIDatePicker
+
+
+ IBProjectSource
+ ../begchap7/Classes/DatePickerViewController.h
+
+
+
+ SDLUIKitDelegate
+ NSObject
+
+ startSDLgame
+ id
+
+
+ YES
+
+ YES
+ controller
+ window
+
+
+ YES
+ UITabBarController
+ UIWindow
+
+
+
+ IBProjectSource
+ Classes/SDL_uikitappdelegate.h
+
+
+
+
+ YES
+
+ NSObject
+
+ IBFrameworkSource
+ Foundation.framework/Headers/NSError.h
+
+
+
+ NSObject
+
+ IBFrameworkSource
+ Foundation.framework/Headers/NSFileManager.h
+
+
+
+ NSObject
+
+ IBFrameworkSource
+ Foundation.framework/Headers/NSKeyValueCoding.h
+
+
+
+ NSObject
+
+ IBFrameworkSource
+ Foundation.framework/Headers/NSKeyValueObserving.h
+
+
+
+ NSObject
+
+ IBFrameworkSource
+ Foundation.framework/Headers/NSKeyedArchiver.h
+
+
+
+ NSObject
+
+ IBFrameworkSource
+ Foundation.framework/Headers/NSNetServices.h
+
+
+
+ NSObject
+
+ IBFrameworkSource
+ Foundation.framework/Headers/NSObject.h
+
+
+
+ NSObject
+
+ IBFrameworkSource
+ Foundation.framework/Headers/NSPort.h
+
+
+
+ NSObject
+
+ IBFrameworkSource
+ Foundation.framework/Headers/NSRunLoop.h
+
+
+
+ NSObject
+
+ IBFrameworkSource
+ Foundation.framework/Headers/NSStream.h
+
+
+
+ NSObject
+
+ IBFrameworkSource
+ Foundation.framework/Headers/NSThread.h
+
+
+
+ NSObject
+
+ IBFrameworkSource
+ Foundation.framework/Headers/NSURL.h
+
+
+
+ NSObject
+
+ IBFrameworkSource
+ Foundation.framework/Headers/NSURLConnection.h
+
+
+
+ NSObject
+
+ IBFrameworkSource
+ Foundation.framework/Headers/NSXMLParser.h
+
+
+
+ NSObject
+
+ IBFrameworkSource
+ QuartzCore.framework/Headers/CAAnimation.h
+
+
+
+ NSObject
+
+ IBFrameworkSource
+ QuartzCore.framework/Headers/CALayer.h
+
+
+
+ NSObject
+
+ IBFrameworkSource
+ UIKit.framework/Headers/UIAccessibility.h
+
+
+
+ NSObject
+
+ IBFrameworkSource
+ UIKit.framework/Headers/UINibLoading.h
+
+
+
+ NSObject
+
+ IBFrameworkSource
+ UIKit.framework/Headers/UIResponder.h
+
+
+
+ UIApplication
+ UIResponder
+
+ IBFrameworkSource
+ UIKit.framework/Headers/UIApplication.h
+
+
+
+ UIBarItem
+ NSObject
+
+ IBFrameworkSource
+ UIKit.framework/Headers/UIBarItem.h
+
+
+
+ UIControl
+ UIView
+
+ IBFrameworkSource
+ UIKit.framework/Headers/UIControl.h
+
+
+
+ UIDatePicker
+ UIControl
+
+ IBFrameworkSource
+ UIKit.framework/Headers/UIDatePicker.h
+
+
+
+ UIResponder
+ NSObject
+
+
+
+ UISearchBar
+ UIView
+
+ IBFrameworkSource
+ UIKit.framework/Headers/UISearchBar.h
+
+
+
+ UISearchDisplayController
+ NSObject
+
+ IBFrameworkSource
+ UIKit.framework/Headers/UISearchDisplayController.h
+
+
+
+ UITabBar
+ UIView
+
+ IBFrameworkSource
+ UIKit.framework/Headers/UITabBar.h
+
+
+
+ UITabBarController
+ UIViewController
+
+ IBFrameworkSource
+ UIKit.framework/Headers/UITabBarController.h
+
+
+
+ UITabBarItem
+ UIBarItem
+
+ IBFrameworkSource
+ UIKit.framework/Headers/UITabBarItem.h
+
+
+
+ UIView
+
+ IBFrameworkSource
+ UIKit.framework/Headers/UITextField.h
+
+
+
+ UIView
+ UIResponder
+
+ IBFrameworkSource
+ UIKit.framework/Headers/UIView.h
+
+
+
+ UIViewController
+
+ IBFrameworkSource
+ UIKit.framework/Headers/UINavigationController.h
+
+
+
+ UIViewController
+
+
+
+ UIViewController
+ UIResponder
+
+ IBFrameworkSource
+ UIKit.framework/Headers/UIViewController.h
+
+
+
+ UIWindow
+ UIView
+
+ IBFrameworkSource
+ UIKit.framework/Headers/UIWindow.h
+
+
+
+
+ 0
+
+ com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS
+
+
+
+ com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3
+
+
+ YES
+ ../hwengine.xcodeproj
+ 3
+ 3.1
+
+
diff -r 83ad68ceef72 -r 334016e8d895 cocoaTouch/SDL_uikitappdelegate.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cocoaTouch/SDL_uikitappdelegate.h Thu Jan 07 05:23:23 2010 +0000
@@ -0,0 +1,40 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2009 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga, mods for Hedgewars by Vittorio Giovara
+ slouken@libsdl.org, vittorio.giovara@gmail.com
+*/
+
+#import
+#import "SDL_video.h"
+
+@interface SDLUIKitDelegate:NSObject {
+ UIWindow *window;
+ SDL_WindowID windowID;
+ UITabBarController *controller;
+}
+
+// the outlets are set in MainWindow.xib
+@property (readwrite, retain) IBOutlet UIWindow *window;
+@property (readwrite, assign) SDL_WindowID windowID;
+@property (nonatomic, retain) IBOutlet UITabBarController *controller;
+
++(SDLUIKitDelegate *)sharedAppDelegate;
+-(void) startSDLgame;
+
+@end
diff -r 83ad68ceef72 -r 334016e8d895 cocoaTouch/SDL_uikitappdelegate.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cocoaTouch/SDL_uikitappdelegate.m Thu Jan 07 05:23:23 2010 +0000
@@ -0,0 +1,136 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2009 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga, mods for Hedgewars by Vittorio Giovara
+ slouken@libsdl.org, vittorio.giovara@gmail.com
+*/
+
+#import "SDL_uikitappdelegate.h"
+#import "SDL_uikitopenglview.h"
+#import "SDL_events_c.h"
+#import "jumphack.h"
+#import "SDL_video.h"
+
+#ifdef main
+#undef main
+#endif
+
+extern int SDL_main(int argc, char *argv[]);
+static int forward_argc;
+static char **forward_argv;
+
+int main(int argc, char **argv) {
+ int i;
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ /* store arguments */
+ forward_argc = argc;
+ forward_argv = (char **)malloc(argc * sizeof(char *));
+ for (i=0; i
+#include "SDL_stdinc.h"
+#include "SDL_mouse.h"
+#include "SDL_mouse_c.h"
+#include "SDL_events.h"
+
+#import "CGPointUtils.h"
+
+#if SDL_IPHONE_MULTIPLE_MICE
+#define MAX_SIMULTANEOUS_TOUCHES 5
+#else
+#define MAX_SIMULTANEOUS_TOUCHES 1
+#endif
+
+#define kMinimumPinchDelta 100
+/* *INDENT-OFF* */
+#if SDL_IPHONE_KEYBOARD
+@interface SDL_uikitview : UIView {
+#else
+@interface SDL_uikitview : UIView {
+#endif
+ SDL_Mouse mice[MAX_SIMULTANEOUS_TOUCHES];
+ CGFloat initialDistance;
+#if SDL_IPHONE_KEYBOARD
+ UITextField *textField;
+ BOOL keyboardVisible;
+#endif
+}
+- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
+- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
+- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
+
+@property CGFloat initialDistance;
+
+#if SDL_IPHONE_KEYBOARD
+- (void)showKeyboard;
+- (void)hideKeyboard;
+- (void)initializeKeyboard;
+@property (readonly) BOOL keyboardVisible;
+#endif
+
+@end
+/* *INDENT-ON* */
diff -r 83ad68ceef72 -r 334016e8d895 cocoaTouch/SDL_uikitview.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cocoaTouch/SDL_uikitview.m Thu Jan 07 05:23:23 2010 +0000
@@ -0,0 +1,438 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2009 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga, mods for Hedgewars by Vittorio Giovara
+ slouken@libsdl.org, vittorio.giovara@gmail.com
+ */
+
+#include "PascalImports.h"
+#import "SDL_uikitview.h"
+
+#if SDL_IPHONE_KEYBOARD
+#import "SDL_keyboard_c.h"
+#import "keyinfotable.h"
+#import "SDL_uikitwindow.h"
+#import "SDL_uikitappdelegate.h"
+#endif
+
+@implementation SDL_uikitview
+
+@synthesize initialDistance;
+
+- (void)dealloc {
+#if SDL_IPHONE_KEYBOARD
+ SDL_DelKeyboard(0);
+ [textField release];
+#endif
+ [super dealloc];
+}
+
+- (id)initWithFrame:(CGRect)frame {
+
+ self = [super initWithFrame: frame];
+
+#if SDL_IPHONE_KEYBOARD
+ [self initializeKeyboard];
+#endif
+
+ int i;
+ for (i=0; i kMinimumPinchDelta) {
+ NSLog(@"Outward pinch detected");
+ HW_zoomOut();
+ }
+ else if (initialDistance - currentDistance > kMinimumPinchDelta) {
+ NSLog(@"Inward pinch detected");
+ HW_zoomIn();
+ }
+ }
+
+ /*while(touch = (UITouch *)[enumerator nextObject]) {
+ // try to find the mouse associated with this touch
+ int i, found = NO;
+ for (i=0; idriverdata;
+ view = data->view;
+
+ if (nil == view) {
+ SDL_SetError("Window has no view");
+ return -1;
+ }
+ else {
+ [view showKeyboard];
+ return 0;
+ }
+}
+
+int SDL_iPhoneKeyboardHide(SDL_WindowID windowID) {
+
+ SDL_Window *window = SDL_GetWindowFromID(windowID);
+ SDL_WindowData *data;
+ SDL_uikitview *view;
+
+ if (NULL == window) {
+ SDL_SetError("Window does not exist");
+ return -1;
+ }
+
+ data = (SDL_WindowData *)window->driverdata;
+ view = data->view;
+
+ if (NULL == view) {
+ SDL_SetError("Window has no view");
+ return -1;
+ }
+ else {
+ [view hideKeyboard];
+ return 0;
+ }
+}
+
+SDL_bool SDL_iPhoneKeyboardIsShown(SDL_WindowID windowID) {
+
+ SDL_Window *window = SDL_GetWindowFromID(windowID);
+ SDL_WindowData *data;
+ SDL_uikitview *view;
+
+ if (NULL == window) {
+ SDL_SetError("Window does not exist");
+ return -1;
+ }
+
+ data = (SDL_WindowData *)window->driverdata;
+ view = data->view;
+
+ if (NULL == view) {
+ SDL_SetError("Window has no view");
+ return 0;
+ }
+ else {
+ return view.keyboardVisible;
+ }
+}
+
+int SDL_iPhoneKeyboardToggle(SDL_WindowID windowID) {
+
+ SDL_Window *window = SDL_GetWindowFromID(windowID);
+ SDL_WindowData *data;
+ SDL_uikitview *view;
+
+ if (NULL == window) {
+ SDL_SetError("Window does not exist");
+ return -1;
+ }
+
+ data = (SDL_WindowData *)window->driverdata;
+ view = data->view;
+
+ if (NULL == view) {
+ SDL_SetError("Window has no view");
+ return -1;
+ }
+ else {
+ if (SDL_iPhoneKeyboardIsShown(windowID)) {
+ SDL_iPhoneKeyboardHide(windowID);
+ }
+ else {
+ SDL_iPhoneKeyboardShow(windowID);
+ }
+ return 0;
+ }
+}
+
+#else
+
+/* stubs, used if compiled without keyboard support */
+
+int SDL_iPhoneKeyboardShow(SDL_WindowID windowID) {
+ SDL_SetError("Not compiled with keyboard support");
+ return -1;
+}
+
+int SDL_iPhoneKeyboardHide(SDL_WindowID windowID) {
+ SDL_SetError("Not compiled with keyboard support");
+ return -1;
+}
+
+SDL_bool SDL_iPhoneKeyboardIsShown(SDL_WindowID windowID) {
+ return 0;
+}
+
+int SDL_iPhoneKeyboardToggle(SDL_WindowID windowID) {
+ SDL_SetError("Not compiled with keyboard support");
+ return -1;
+}
+
+
+#endif /* SDL_IPHONE_KEYBOARD */
diff -r 83ad68ceef72 -r 334016e8d895 cocoaTouch/otherSrc/CGPointUtils.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cocoaTouch/otherSrc/CGPointUtils.c Thu Jan 07 05:23:23 2010 +0000
@@ -0,0 +1,40 @@
+/*
+ * CGPointUtils.c
+ * PinchMe
+ *
+ * Created by Jeff LaMarche on 8/2/08.
+ * Copyright 2008 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#include "CGPointUtils.h"
+#include
+
+#define degreesToRadian(x) (M_PI * x / 180.0)
+#define radiansToDegrees(x) (180.0 * x / M_PI)
+
+CGFloat distanceBetweenPoints (CGPoint first, CGPoint second) {
+ CGFloat deltaX = second.x - first.x;
+ CGFloat deltaY = second.y - first.y;
+ return sqrt(deltaX*deltaX + deltaY*deltaY );
+};
+
+CGFloat angleBetweenPoints(CGPoint first, CGPoint second) {
+ CGFloat height = second.y - first.y;
+ CGFloat width = first.x - second.x;
+ CGFloat rads = atan(height/width);
+ return radiansToDegrees(rads);
+ //degs = degrees(atan((top - bottom)/(right - left)))
+}
+
+CGFloat angleBetweenLines(CGPoint line1Start, CGPoint line1End, CGPoint line2Start, CGPoint line2End) {
+
+ CGFloat a = line1End.x - line1Start.x;
+ CGFloat b = line1End.y - line1Start.y;
+ CGFloat c = line2End.x - line2Start.x;
+ CGFloat d = line2End.y - line2Start.y;
+
+ CGFloat rads = acos(((a*c) + (b*d)) / ((sqrt(a*a + b*b)) * (sqrt(c*c + d*d))));
+
+ return radiansToDegrees(rads);
+}
diff -r 83ad68ceef72 -r 334016e8d895 cocoaTouch/otherSrc/CGPointUtils.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cocoaTouch/otherSrc/CGPointUtils.h Thu Jan 07 05:23:23 2010 +0000
@@ -0,0 +1,14 @@
+/*
+ * CGPointUtils.h
+ * PinchMe
+ *
+ * Created by Jeff LaMarche on 8/2/08.
+ * Copyright 2008 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#import
+
+CGFloat distanceBetweenPoints (CGPoint first, CGPoint second);
+CGFloat angleBetweenPoints(CGPoint first, CGPoint second);
+CGFloat angleBetweenLines(CGPoint line1Start, CGPoint line1End, CGPoint line2Start, CGPoint lin2End);
diff -r 83ad68ceef72 -r 334016e8d895 cocoaTouch/otherSrc/PascalImports.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cocoaTouch/otherSrc/PascalImports.h Thu Jan 07 05:23:23 2010 +0000
@@ -0,0 +1,30 @@
+/*
+ * PascalImports.h
+// fpciphonedel
+//
+// Created by Vittorio on 07/01/10.
+// Copyright __MyCompanyName__ 2010. All rights reserved.
+ *
+ */
+
+#ifndef PASCALIMPORTS
+#define PASCALIMPORTS
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* add C declarations below for all exported Pascal functions/procedure
+ * that you want to use
+ */
+
+void HW_click(void);
+void HW_zoomIn(void);
+void HW_zoomOut(void);
+void HW_ammoMenu(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
diff -r 83ad68ceef72 -r 334016e8d895 cocoaTouch/resources/Default.png
Binary file cocoaTouch/resources/Default.png has changed
diff -r 83ad68ceef72 -r 334016e8d895 cocoaTouch/resources/Icon.png
Binary file cocoaTouch/resources/Icon.png has changed
diff -r 83ad68ceef72 -r 334016e8d895 hedgewars/hwengine.pas
--- a/hedgewars/hwengine.pas Tue Jan 05 21:26:38 2010 +0000
+++ b/hedgewars/hwengine.pas Thu Jan 07 05:23:23 2010 +0000
@@ -19,7 +19,8 @@
{$INCLUDE "options.inc"}
program hwengine;
-uses SDLh in 'SDLh.pas',
+uses
+ SDLh in 'SDLh.pas',
{$IFDEF GLES11}
gles11,
{$ELSE}
@@ -116,7 +117,7 @@
SDL_GL_SwapBuffers();
{$IFNDEF IPHONEOS}
-// not going to make captures on the iPhone
+// not going to make captures on the iPhone (nor resizing)
if flagMakeCapture then
begin
flagMakeCapture:= false;
@@ -125,6 +126,17 @@
MakeScreenshot(s);
// SDL_SaveBMP_RW(SDLPrimSurface, SDL_RWFromFile(Str2PChar(s), 'wb'), 1)
end;
+end;
+
+////////////////////////////////
+procedure Resize(w, h: LongInt);
+begin
+cScreenWidth:= w;
+cScreenHeight:= h;
+if cFullScreen then
+ ParseCommand('/fullscr 1', true)
+else
+ ParseCommand('/fullscr 0', true);
{$ENDIF}
end;
@@ -142,17 +154,6 @@
halt
end;
-////////////////////////////////
-procedure Resize(w, h: LongInt);
-begin
-cScreenWidth:= w;
-cScreenHeight:= h;
-if cFullScreen then
- ParseCommand('/fullscr 1', true)
-else
- ParseCommand('/fullscr 0', true);
-end;
-
///////////////////
procedure MainLoop;
var PrevTime,
@@ -160,8 +161,7 @@
event: TSDL_Event;
{$IFDEF TOUCHINPUT}
type TDirection = (nodir, left, right);
-var x, y, dx, dy, mouseState: LongInt;
-// tiltValue: LongInt;
+var tiltValue: LongInt;
direction: TDirection = nodir;
movedbybuttons: boolean = false;
{$ENDIF}
@@ -181,168 +181,44 @@
{$ENDIF}
case event.type_ of
{$IFDEF SDL13}
- SDL_WINDOWEVENT:
+ SDL_WINDOWEVENT:
{$ELSE}
SDL_KEYDOWN: if GameState = gsChat then KeyPressChat(event.key.keysym.unicode);
- SDL_ACTIVEEVENT:
+ SDL_ACTIVEEVENT:
{$ENDIF}
- if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then
+ if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then
cHasFocus:= event.active.gain = 1;
//SDL_VIDEORESIZE: Resize(max(event.resize.w, 600), max(event.resize.h, 450));
-{$IFDEF TOUCHINPUT}
- SDL_MOUSEMOTION: begin
-{$IFDEF DEBUGFILE}
- AddFileLog('********************************************* motion');
-{$ENDIF}
- SDL_SelectMouse(event.motion.which);
- mouseState:= SDL_GetMouseState(@x, @y);
- SDL_GetRelativeMouseState(event.motion.which, @dx, @dy);
-
- direction:= nodir;
-
- if boolean(mouseState) then
- begin
-{$IFDEF DEBUGFILE}
- AddFileLog('x: ' + inttostr(x) + ' y: ' + inttostr(y) + ' dx: ' + inttostr(dx) + ' dy: ' + inttostr(dy));
-{$ENDIF}
-
- {* zoom slider *}
- if (x <= 50) and (y <= 430) and (y > 50) then
- begin
- if (dy > 0) then uKeys.wheelDown:= true
- else if (dy < 0) then uKeys.wheelUp:= true;
- end;
-
- {* aim slider *}
- if (x > 270) and (y > 50) and (y <= 430) then
- begin
- if (dy > 0) then uKeys.downKey:= true
- else if (dy < 0) then uKeys.upKey:= true;
- end;
-
- {* switch *}
- if (x > 50) and (x <= 270) and (y > 400) then
- begin
- if (dy <> 0) then uKeys.tabKey:= true
- end;
- end;
- end;
- {*MoveCamera is in uWord.pas -- conflicts with other commands*}
- SDL_MOUSEBUTTONDOWN: begin
-{$IFDEF DEBUGFILE}
- AddFileLog('********************************************* touch down');
-{$ENDIF}
- SDL_SelectMouse(event.motion.which);
- mouseState:= SDL_GetMouseState(@x, @y);
- SDL_GetRelativeMouseState(event.motion.which, @dx, @dy);
- {* attack *}
- if (x > 50) and (x <= 270) and (y <= 50) then
- begin
- WriteLnToConsole('Space DOWN -- x: ' + inttostr(x) + ' y: ' + inttostr(y));
- uKeys.spaceKey:= true;
- uKeys.isAttacking:= true;
- end;
-
- if (x <= 50) and (y <= 50) then
- begin
- WriteLnToConsole('Left Arrow Key DOWN -- x: ' + inttostr(x) + ' y: ' + inttostr(y));
- direction:= left;
- movedbybuttons:= true;
- end;
-
- if (x > 270) and (y <= 50) then
- begin
- WriteLnToConsole('Right Arrow Key DOWN -- x: ' + inttostr(x) + ' y: ' + inttostr(y));
- direction:= right;
- movedbybuttons:= true;
- end;
-
- {* high jump *}
- if (x > 160) and (x <= 270) and (y > 400) then
- begin
-{$IFDEF DEBUGFILE}
- AddFileLog('Backspace -- x: ' + inttostr(x) + ' y: ' + inttostr(y));
-{$ENDIF}
- uKeys.backspaceKey:= true;
- end;
- end;
- SDL_MOUSEBUTTONUP: begin
-{$IFDEF DEBUGFILE}
- AddFileLog('********************************************* touch up');
-{$ENDIF}
-
- SDL_SelectMouse(event.motion.which);
- mouseState:= SDL_GetMouseState(@x, @y);
- SDL_GetRelativeMouseState(event.motion.which, @dx, @dy);
- uKeys.leftClick:= true;
-
- {* open ammo menu *}
- if (y > 430) and (x > 270) then
- begin
-{$IFDEF DEBUGFILE}
- AddFileLog('Right Click -- x: ' + inttostr(x) + ' y: ' + inttostr(y) );
-{$ENDIF}
- uKeys.rightClick:= true;
- end;
-
- {* long jump *}
- if (x > 50) and (x <= 160) and (y > 400) then
- begin
-{$IFDEF DEBUGFILE}
- AddFileLog('Enter -- x: ' + inttostr(x) + ' y: ' + inttostr(y));
-{$ENDIF}
- uKeys.enterKey:= true;
- end;
-
- {* reset zoom *}
- if (x <= 50) and (y > 430) then
- begin
-{$IFDEF DEBUGFILE}
- AddFileLog('Middle Click -- x: ' + inttostr(x) + ' y: ' + inttostr(y));
-{$ENDIF}
- uKeys.middleClick:= true;
- end;
-
- {* end movement and attack *}
-{$IFDEF DEBUGFILE}
- AddFileLog('Arrow Keys UP | Space UP -- x: ' + inttostr(x) + ' y: ' + inttostr(y) );
-{$ENDIF}
- direction:= nodir;
- movedbybuttons:= false;
- uKeys.isAttacking:= false;
- end;
-{$ENDIF}
{$IFDEF IPHONEOS}
(* SDL_JOYAXISMOTION: begin
{* axis 0 = left and right;
axis 1 = up and down;
axis 2 = back and forth; *}
- WriteLnToConsole('********************************************* accelerometer');
+ WriteLnToConsole('********************************************* accelerometer');
tiltValue:= SDL_JoystickGetAxis(uKeys.theJoystick, 0);
- if (CurrentTeam <> nil) then
- begin
+ if (CurrentTeam <> nil) then
+ begin
{$IFDEF DEBUGFILE}
AddFileLog('Joystick: 0; Axis: 0; Value: ' + inttostr(tiltValue));
{$ENDIF}
-
- if tiltValue > 1500 then
- begin
- uKeys.rightKey:= true;
- uKeys.isWalking:= true;
- end
- else
- if tiltValue <= -1500 then
- begin
- uKeys.leftKey:= true;
+ if tiltValue > 1500 then
+ begin
+ uKeys.rightKey:= true;
uKeys.isWalking:= true;
- end
- else
- if (tiltValue > -1500) and (tiltValue <= 1500) and (movedbybuttons = false) then uKeys.isWalking:= false;
+ end
+ else
+ if tiltValue <= -1500 then
+ begin
+ uKeys.leftKey:= true;
+ uKeys.isWalking:= true;
+ end
+ else
+ if (tiltValue > -1500) and (tiltValue <= 1500) and (movedbybuttons = false) then uKeys.isWalking:= false;
end;
- end;*)
+ end;*)
{$ELSE}
SDL_MOUSEBUTTONDOWN: if event.button.button = SDL_BUTTON_WHEELDOWN then uKeys.wheelDown:= true;
SDL_MOUSEBUTTONUP: if event.button.button = SDL_BUTTON_WHEELUP then uKeys.wheelUp:= true;
diff -r 83ad68ceef72 -r 334016e8d895 hedgewars/uKeys.pas
--- a/hedgewars/uKeys.pas Tue Jan 05 21:26:38 2010 +0000
+++ b/hedgewars/uKeys.pas Thu Jan 07 05:23:23 2010 +0000
@@ -17,6 +17,7 @@
*)
{$INCLUDE "options.inc"}
+{$IFDEF IPHONEOS} {$MODE OBJFPC} {$ENDIF}
unit uKeys;
interface
@@ -40,13 +41,20 @@
procedure ControllerHatEvent(joy, hat, value: Byte);
procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean);
+{$IFDEF IPHONEOS}
+procedure HW_click; cdecl; export;
+procedure HW_zoomIn; cdecl; export;
+procedure HW_zoomOut; cdecl; export;
+procedure HW_ammoMenu; cdecl; export;
+{$ENDIF}
+
var hideAmmoMenu: boolean;
wheelUp: boolean = false;
wheelDown: boolean = false;
{$IFDEF TOUCHINPUT}
- leftClick: boolean = false;
- middleClick: boolean = false;
- rightClick: boolean = false;
+ leftClick: boolean = false;
+ middleClick: boolean = false;
+ rightClick: boolean = false;
upKey: boolean = false;
downKey: boolean = false;
@@ -83,13 +91,45 @@
KeyNames: array [0..cKeyMaxIndex] of string[15];
DefaultBinds, CurrentBinds: TBinds;
-function KeyNameToCode(name: string): word;
-var Result: Word;
+{$IFDEF IPHONEOS}
+// these are called by the touch functions present in SDL_uikitview.m
+procedure HW_click; cdecl; export;
+begin
+ WriteLnToConsole('HW - general click');
+ leftClick:= true;
+ exit
+end;
+
+procedure HW_zoomIn; cdecl; export;
+begin
+ WriteLnToConsole('HW - zooming in');
+ wheelUp:= true;
+ exit
+end;
+
+procedure HW_zoomOut; cdecl; export;
begin
-Result:= cKeyMaxIndex;
-while (Result > 0) and (KeyNames[Result] <> name) do dec(Result);
-KeyNameToCode:= Result
+ WriteLnToConsole('HW - zooming out');
+ wheelDown:= true;
+ exit
+end;
+
+procedure HW_ammoMenu; cdecl; export;
+begin
+ WriteLnToConsole('HW - opening ammomenu');
+ rightClick:= true;
+ exit
end;
+{$ENDIF}
+
+function KeyNameToCode(name: string): word;
+var code: Word;
+begin
+ code:= cKeyMaxIndex;
+ while (code > 0) and (KeyNames[code] <> name) do dec(code);
+ KeyNameToCode:= code;
+end;
+
procedure ProcessKbd;
var i, j, k: LongInt;
@@ -128,7 +168,7 @@
{$ENDIF}
tkbdn[2]:= ((k shr 1) and 1);
-// mouse wheels (see event loop in project file)
+// mouse wheels
tkbdn[4]:= ord(wheelDown);
tkbdn[5]:= ord(wheelUp);
wheelUp:= false;