update iphone frontend to the new (silly) sdl api, code cleanups for other sections
--- a/cocoaTouch/MainWindow.xib Sun Jan 24 19:01:51 2010 +0000
+++ b/cocoaTouch/MainWindow.xib Sun Jan 24 19:52:30 2010 +0000
@@ -148,11 +148,11 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
- <string key="label">window</string>
+ <string key="label">uiwindow</string>
<reference key="source" ref="664661524"/>
<reference key="destination" ref="380026005"/>
</object>
- <int key="connectionID">24</int>
+ <int key="connectionID">25</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
@@ -331,7 +331,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">24</int>
+ <int key="maxID">25</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -382,7 +382,7 @@
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>controller</string>
- <string>window</string>
+ <string>uiwindow</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -398,6 +398,19 @@
<object class="IBPartialClassDescription">
<string key="className">SchemeEditViewController</string>
<string key="superclassName">UIViewController</string>
+ <object class="NSMutableDictionary" key="outlets">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>cell0</string>
+ <string>table</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>UITableViewCell</string>
+ <string>UITableView</string>
+ </object>
+ </object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">../../../hedge.build/trunk/cocoaTouch/SchemeEditViewController.h</string>
@@ -406,6 +419,42 @@
<object class="IBPartialClassDescription">
<string key="className">SettingsViewController</string>
<string key="superclassName">UIViewController</string>
+ <object class="NSMutableDictionary" key="actions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>backgroundTap:</string>
+ <string>sliderChanged:</string>
+ <string>textFieldDoneEditing:</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="outlets">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>password</string>
+ <string>table</string>
+ <string>username</string>
+ <string>volumeCell</string>
+ <string>volumeLabel</string>
+ <string>volumeSlider</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>UITextField</string>
+ <string>UITableView</string>
+ <string>UITextField</string>
+ <string>UITableViewCell</string>
+ <string>UILabel</string>
+ <string>UISlider</string>
+ </object>
+ </object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">../../../hedge.build/trunk/cocoaTouch/SettingsViewController.h</string>
@@ -601,6 +650,14 @@
<reference key="sourceIdentifier" ref="186590129"/>
</object>
<object class="IBPartialClassDescription">
+ <string key="className">UIScrollView</string>
+ <string key="superclassName">UIView</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">UIKit.framework/Headers/UIScrollView.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
<string key="className">UISearchBar</string>
<string key="superclassName">UIView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
@@ -617,6 +674,14 @@
</object>
</object>
<object class="IBPartialClassDescription">
+ <string key="className">UISlider</string>
+ <string key="superclassName">UIControl</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">UIKit.framework/Headers/UISlider.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
<string key="className">UITabBar</string>
<string key="superclassName">UIView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
@@ -641,14 +706,35 @@
</object>
</object>
<object class="IBPartialClassDescription">
- <string key="className">UIView</string>
+ <string key="className">UITableView</string>
+ <string key="superclassName">UIScrollView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">UIKit.framework/Headers/UITableView.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">UITableViewCell</string>
+ <string key="superclassName">UIView</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">UIKit.framework/Headers/UITableViewCell.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">UITextField</string>
+ <string key="superclassName">UIControl</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier" id="1045548135">
+ <string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UITextField.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIView</string>
+ <reference key="sourceIdentifier" ref="1045548135"/>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">UIView</string>
<string key="superclassName">UIResponder</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
--- a/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.h Sun Jan 24 19:01:51 2010 +0000
+++ b/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.h Sun Jan 24 19:52:30 2010 +0000
@@ -23,15 +23,15 @@
#import <UIKit/UIKit.h>
#import "SDL_video.h"
-@interface SDLUIKitDelegate:NSObject<UIApplicationDelegate> {
- UIWindow *window;
- SDL_WindowID windowID;
+@interface SDLUIKitDelegate:NSObject <UIApplicationDelegate> {
+ SDL_Window *window;
+ UIWindow *uiwindow;
UITabBarController *controller;
}
// the outlets are set in MainWindow.xib
-@property (readwrite, retain) IBOutlet UIWindow *window;
-@property (readwrite, assign) SDL_WindowID windowID;
+@property (readwrite, assign) SDL_Window *window;
+@property (readwrite, retain) IBOutlet UIWindow *uiwindow;
@property (nonatomic, retain) IBOutlet UITabBarController *controller;
+(SDLUIKitDelegate *)sharedAppDelegate;
--- a/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m Sun Jan 24 19:01:51 2010 +0000
+++ b/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m Sun Jan 24 19:52:30 2010 +0000
@@ -47,20 +47,30 @@
@implementation SDLUIKitDelegate
-@synthesize window, windowID, controller;
+@synthesize uiwindow, window, controller;
/* convenience method */
+(SDLUIKitDelegate *)sharedAppDelegate {
- /* the delegate is set in UIApplicationMain(), which is garaunteed to be called before this method */
+ /* the delegate is set in UIApplicationMain(), which is guaranteed to be called before this method */
return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate];
}
+-(id) init {
+ self = [super init];
+ self.uiwindow = nil;
+ self.window = NULL;
+ self.controller = nil;
+ return self;
+}
+
-(void) dealloc {
[controller release];
- [window release];
+ [uiwindow release];
[super dealloc];
}
+#pragma mark -
+#pragma mark Custom stuff
-(IBAction) startSDLgame {
NSAutoreleasePool *internal_pool = [[NSAutoreleasePool alloc] init];
@@ -84,17 +94,16 @@
free(gameArgs);
NSLog(@"Game is exting...");
- [[window viewWithTag:54867] removeFromSuperview];
[setup release];
- [window addSubview:controller.view];
- [window makeKeyAndVisible];
-
[UIView beginAnimations:@"inserting main controller" context:NULL];
[UIView setAnimationDuration:1];
controller.view.alpha = 1;
[UIView commitAnimations];
+ [uiwindow addSubview:controller.view];
+ [uiwindow makeKeyAndVisible];
+
[internal_pool release];
}
@@ -120,6 +129,23 @@
return isFirstRun;
}
+-(NSString *)dataFilePath: (NSString *)fileName {
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString *documentsDirectory = [paths objectAtIndex:0];
+ return [documentsDirectory stringByAppendingPathComponent:fileName];
+}
+
+-(void) applicationDidReceiveMemoryWarning:(UIApplication *)application {
+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Running low on memory"
+ message:@"Will try to free some memory but app may crash"
+ delegate:nil
+ cancelButtonTitle:@"Ok"
+ otherButtonTitles:nil ];
+ [alert show];
+ [alert release];
+}
+#pragma mark -
+#pragma mark SDLUIKitDelegate methods
// override the direct execution of SDL_main to allow us to implement the frontend (even using a nib)
-(void) applicationDidFinishLaunching:(UIApplication *)application {
[application setStatusBarHidden:YES animated:NO];
@@ -128,8 +154,8 @@
/* Set working directory to resource path */
[[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]];
- [window addSubview:controller.view];
- [window makeKeyAndVisible];
+ [uiwindow addSubview:controller.view];
+ [uiwindow makeKeyAndVisible];
}
-(void) applicationWillTerminate:(UIApplication *)application {
@@ -141,12 +167,12 @@
-(void) applicationWillResignActive:(UIApplication*)application {
// NSLog(@"%@", NSStringFromSelector(_cmd));
- SDL_SendWindowEvent(self.windowID, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
+ SDL_SendWindowEvent(self.window, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
}
-(void) applicationDidBecomeActive:(UIApplication*)application {
// NSLog(@"%@", NSStringFromSelector(_cmd));
- SDL_SendWindowEvent(self.windowID, SDL_WINDOWEVENT_RESTORED, 0, 0);
+ SDL_SendWindowEvent(self.window, SDL_WINDOWEVENT_RESTORED, 0, 0);
}
/*
@@ -156,10 +182,4 @@
}
*/
--(NSString *)dataFilePath: (NSString *)fileName {
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *documentsDirectory = [paths objectAtIndex:0];
- return [documentsDirectory stringByAppendingPathComponent:fileName];
-}
-
@end
--- a/cocoaTouch/SDLOverrides/SDL_uikitopengles.h Sun Jan 24 19:01:51 2010 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- 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
- slouken@libsdl.org
-*/
-
-#include "SDL_config.h"
-
-#ifndef _SDL_uikitopengles
-#define _SDL_uikitopengles
-
-#include "SDL_uikitvideo.h"
-
-extern int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window,
- SDL_GLContext context);
-extern void UIKit_GL_SwapWindow(_THIS, SDL_Window * window);
-extern SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window);
-extern void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context);
-extern void *UIKit_GL_GetProcAddress(_THIS, const char *proc);
-extern int UIKit_GL_LoadLibrary(_THIS, const char *path);
-
-#endif
--- a/cocoaTouch/SDLOverrides/SDL_uikitopengles.m Sun Jan 24 19:01:51 2010 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,139 +0,0 @@
-/*
- 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
- slouken@libsdl.org
- */
-
-#include "SDL_uikitopengles.h"
-#include "SDL_uikitopenglview.h"
-#include "SDL_uikitappdelegate.h"
-#include "SDL_uikitwindow.h"
-#include "jumphack.h"
-#include "SDL_sysvideo.h"
-#include "SDL_loadso.h"
-#include <dlfcn.h>
-
-static int UIKit_GL_Initialize(_THIS);
-
-void *
-UIKit_GL_GetProcAddress(_THIS, const char *proc)
-{
- /* Look through all SO's for the proc symbol. Here's why:
- -Looking for the path to the OpenGL Library seems not to work in the iPhone Simulator.
- -We don't know that the path won't change in the future.
- */
- return SDL_LoadFunction(RTLD_DEFAULT, proc);
-}
-
-/*
- note that SDL_GL_Delete context makes it current without passing the window
-*/
-int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
-{
-
- if (context) {
- SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
- [data->view setCurrentContext];
- }
- else {
- [EAGLContext setCurrentContext: nil];
- }
-
- return 0;
-}
-
-int
-UIKit_GL_LoadLibrary(_THIS, const char *path)
-{
- /*
- shouldn't be passing a path into this function
- why? Because we've already loaded the library
- and because the SDK forbids loading an external SO
- */
- if (path != NULL) {
- SDL_SetError("iPhone GL Load Library just here for compatibility");
- return -1;
- }
- return 0;
-}
-
-
-void UIKit_GL_SwapWindow(_THIS, SDL_Window * window)
-{
-
- SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
-
- if (nil == data->view) {
- return;
- }
- [data->view swapBuffers];
- /* since now we've got something to draw
- make the window visible */
- [data->uiwindow makeKeyAndVisible];
-
- /* we need to let the event cycle run, or the OS won't update the OpenGL view! */
- SDL_PumpEvents();
-
-}
-
-SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
-{
-
- SDL_uikitopenglview *view;
-
- SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
-
- /* construct our view, passing in SDL's OpenGL configuration data */
- view = [[SDL_uikitopenglview alloc] initWithFrame: [[UIScreen mainScreen] applicationFrame] \
- retainBacking: _this->gl_config.retained_backing \
- rBits: _this->gl_config.red_size \
- gBits: _this->gl_config.green_size \
- bBits: _this->gl_config.blue_size \
- aBits: _this->gl_config.alpha_size \
- depthBits: _this->gl_config.depth_size];
-
- // add a tag to be able to remove from superview once finished
- view.tag = 54867;
- data->view = view;
-
- /* add the view to our window */
- [data->uiwindow addSubview: view ];
-
- /* Don't worry, the window retained the view */
- [view release];
-
- if ( UIKit_GL_MakeCurrent(_this, window, view) < 0 ) {
- UIKit_GL_DeleteContext(_this, view);
- return NULL;
- }
-
- return view;
-}
-
-void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context)
-{
- /* the delegate has retained the view, this will release him */
- SDL_uikitopenglview *view = (SDL_uikitopenglview *)context;
- /* this will also delete it */
- [view removeFromSuperview];
-
- return;
-}
-
-
--- a/cocoaTouch/SDLOverrides/SDL_uikitview.h Sun Jan 24 19:01:51 2010 +0000
+++ b/cocoaTouch/SDLOverrides/SDL_uikitview.h Sun Jan 24 19:52:30 2010 +0000
@@ -35,9 +35,9 @@
#endif
// constants for telling which input has been received
-#define kMinimumPinchDelta 100
+#define kMinimumPinchDelta 100
#define kMinimumGestureLength 10
-#define kMaximumVariance 4
+#define kMaximumVariance 4
/* *INDENT-OFF* */
//#if SDL_IPHONE_KEYBOARD
--- a/cocoaTouch/SDLOverrides/SDL_uikitview.m Sun Jan 24 19:01:51 2010 +0000
+++ b/cocoaTouch/SDLOverrides/SDL_uikitview.m Sun Jan 24 19:52:30 2010 +0000
@@ -37,7 +37,7 @@
// they have to be global variables to allow showControls() to use them
UIButton *attackButton, *menuButton;
-- (void)dealloc {
+-(void) dealloc {
#if SDL_IPHONE_KEYBOARD
SDL_DelKeyboard(0);
[textField release];
@@ -52,7 +52,7 @@
// this object is inherited by SDL_openglesview.m which is the one allocated by SDL.
// We select this class with [self superclass] and call the selectors with "+" because
// they are superclass methods
- self = [super initWithFrame: frame];
+ self = [super initWithFrame:frame];
#if SDL_IPHONE_KEYBOARD
[self initializeKeyboard];
@@ -77,7 +77,6 @@
[menuButton addTarget:[self superclass] action:@selector(attackButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:menuButton];
- [[SDLUIKitDelegate sharedAppDelegate].window makeKeyAndVisible];
self.multipleTouchEnabled = YES;
return self;
@@ -87,9 +86,9 @@
#pragma mark Exported functions for FreePascal
const char* IPH_getDocumentsPath() {
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *documentsDirectory = [paths objectAtIndex: 0];
- return [documentsDirectory UTF8String];
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString *documentsDirectory = [paths objectAtIndex: 0];
+ return [documentsDirectory UTF8String];
}
void IPH_showControls (void) {
@@ -167,7 +166,7 @@
// one tap - single click
if (1 == [touch tapCount] ) {
- //SDL_WarpMouseInWindow([SDLUIKitDelegate sharedAppDelegate].windowID, gestureStartPoint.x, gestureStartPoint.y);
+ //SDL_WarpMouseInWindow([SDLUIKitDelegate sharedAppDelegate].window, gestureStartPoint.x, gestureStartPoint.y);
HW_click();
}
@@ -395,9 +394,7 @@
/* iPhone keyboard addition functions */
#if SDL_IPHONE_KEYBOARD
-int SDL_iPhoneKeyboardShow(SDL_WindowID windowID) {
-
- SDL_Window *window = SDL_GetWindowFromID(windowID);
+int SDL_iPhoneKeyboardShow(SDL_Window *window) {
SDL_WindowData *data;
SDL_uikitview *view;
@@ -419,9 +416,7 @@
}
}
-int SDL_iPhoneKeyboardHide(SDL_WindowID windowID) {
-
- SDL_Window *window = SDL_GetWindowFromID(windowID);
+int SDL_iPhoneKeyboardHide(SDL_Window *window) {
SDL_WindowData *data;
SDL_uikitview *view;
@@ -443,9 +438,7 @@
}
}
-SDL_bool SDL_iPhoneKeyboardIsShown(SDL_WindowID windowID) {
-
- SDL_Window *window = SDL_GetWindowFromID(windowID);
+SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window *window) {
SDL_WindowData *data;
SDL_uikitview *view;
@@ -466,9 +459,7 @@
}
}
-int SDL_iPhoneKeyboardToggle(SDL_WindowID windowID) {
-
- SDL_Window *window = SDL_GetWindowFromID(windowID);
+int SDL_iPhoneKeyboardToggle(SDL_Window *window) {
SDL_WindowData *data;
SDL_uikitview *view;
@@ -485,11 +476,11 @@
return -1;
}
else {
- if (SDL_iPhoneKeyboardIsShown(windowID)) {
- SDL_iPhoneKeyboardHide(windowID);
+ if (SDL_iPhoneKeyboardIsShown(window)) {
+ SDL_iPhoneKeyboardHide(window);
}
else {
- SDL_iPhoneKeyboardShow(windowID);
+ SDL_iPhoneKeyboardShow(window);
}
return 0;
}
@@ -499,21 +490,21 @@
/* stubs, used if compiled without keyboard support */
-int SDL_iPhoneKeyboardShow(SDL_WindowID windowID) {
+int SDL_iPhoneKeyboardShow(SDL_Window *window) {
SDL_SetError("Not compiled with keyboard support");
return -1;
}
-int SDL_iPhoneKeyboardHide(SDL_WindowID windowID) {
+int SDL_iPhoneKeyboardHide(SDL_Window *window) {
SDL_SetError("Not compiled with keyboard support");
return -1;
}
-SDL_bool SDL_iPhoneKeyboardIsShown(SDL_WindowID windowID) {
+SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window *window) {
return 0;
}
-int SDL_iPhoneKeyboardToggle(SDL_WindowID windowID) {
+int SDL_iPhoneKeyboardToggle(SDL_Window *window) {
SDL_SetError("Not compiled with keyboard support");
return -1;
}
--- a/cocoaTouch/SDLOverrides/SDL_uikitwindow.h Sun Jan 24 19:01:51 2010 +0000
+++ b/cocoaTouch/SDLOverrides/SDL_uikitwindow.h Sun Jan 24 19:52:30 2010 +0000
@@ -36,7 +36,7 @@
struct SDL_WindowData
{
- SDL_WindowID windowID;
+ SDL_Window *window;
UIWindow *uiwindow;
SDL_uikitopenglview *view;
};
--- a/cocoaTouch/SDLOverrides/SDL_uikitwindow.m Sun Jan 24 19:01:51 2010 +0000
+++ b/cocoaTouch/SDLOverrides/SDL_uikitwindow.m Sun Jan 24 19:52:30 2010 +0000
@@ -39,26 +39,25 @@
#include <Foundation/Foundation.h>
static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bool created) {
-
- SDL_WindowData *data;
-
- /* Allocate the window data */
- data = (SDL_WindowData *)SDL_malloc(sizeof(*data));
- if (!data) {
- SDL_OutOfMemory();
- return -1;
- }
- data->windowID = window->id;
- data->uiwindow = uiwindow;
+ SDL_WindowData *data;
+
+ /* Allocate the window data */
+ data = (SDL_WindowData *)SDL_malloc(sizeof(*data));
+ if (!data) {
+ SDL_OutOfMemory();
+ return -1;
+ }
+ data->window = window;
+ data->uiwindow = uiwindow;
data->view = nil;
-
- /* Fill in the SDL window with the window data */
+
+ /* Fill in the SDL window with the window data */
{
- window->x = 0;
- window->y = 0;
- window->w = (int)uiwindow.frame.size.width;
- window->h = (int)uiwindow.frame.size.height;
- }
+ window->x = 0;
+ window->y = 0;
+ window->w = (int)uiwindow.frame.size.width;
+ window->h = (int)uiwindow.frame.size.height;
+ }
window->driverdata = data;
@@ -67,7 +66,7 @@
window->flags |= SDL_WINDOW_FULLSCREEN; /* window is always fullscreen */
window->flags |= SDL_WINDOW_SHOWN; /* only one window on iPod touch, always shown */
window->flags |= SDL_WINDOW_INPUT_FOCUS; /* always has input focus */
-
+
/* SDL_WINDOW_BORDERLESS controls whether status bar is hidden */
if (window->flags & SDL_WINDOW_BORDERLESS) {
[UIApplication sharedApplication].statusBarHidden = YES;
@@ -76,7 +75,7 @@
[UIApplication sharedApplication].statusBarHidden = NO;
}
- return 0;
+ return 0;
}
@@ -91,17 +90,18 @@
UIWindow *uiwindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];*/
// since we handle the window with a NIB, we don't need the initialization above
- if (SetupWindowData(_this, window, [SDLUIKitDelegate sharedAppDelegate].window, SDL_TRUE) < 0) {
+ if (SetupWindowData(_this, window, [SDLUIKitDelegate sharedAppDelegate].uiwindow, SDL_TRUE) < 0) {
SDL_SetError("SetupWindowData() failed");
- return -1;
- }
+ //[uiwindow release];
+ return -1;
+ }
// This saves the main window in the app delegate so event callbacks can do stuff on the window.
// This assumes a single window application design and needs to be fixed for multiple windows.
- [SDLUIKitDelegate sharedAppDelegate].windowID = window->id;
+ [SDLUIKitDelegate sharedAppDelegate].window = window;
-/* [SDLUIKitDelegate sharedAppDelegate].window = uiwindow;
- [uiwindow release]; /* release the window (the app delegate has retained it) */
+ //[SDLUIKitDelegate sharedAppDelegate].uiwindow = uiwindow;
+ //[uiwindow release]; /* release the window (the app delegate has retained it) */
return 1;
@@ -116,8 +116,8 @@
}
/* this will also destroy the window */
- //[SDLUIKitDelegate sharedAppDelegate].window = nil;
- [SDLUIKitDelegate sharedAppDelegate].windowID = 0;
+ [SDLUIKitDelegate sharedAppDelegate].window = NULL;
+ //[SDLUIKitDelegate sharedAppDelegate].uiwindow = nil;
}
--- a/hedgewars/CCHandlers.inc Sun Jan 24 19:01:51 2010 +0000
+++ b/hedgewars/CCHandlers.inc Sun Jan 24 19:52:30 2010 +0000
@@ -598,9 +598,6 @@
{$IFDEF DEBUGFILE}
buf: array[byte] of char;
{$ENDIF}
-{$IFDEF SDL13}
- windowID: TSDL_WindowID;
-{$ENDIF}
begin
if Length(s) = 0 then cFullScreen:= not cFullScreen
else cFullScreen:= s = '1';
@@ -631,20 +628,9 @@
SDL_FreeSurface(SDLPrimSurface);
end;
-{$IFDEF SDL13}
- windowID:= SDL_CreateWindow(nil, 0, 0, cScreenWidth, cScreenHeight, SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN
- {$IFDEF IPHONEOS} or SDL_WINDOW_BORDERLESS{$ENDIF});
- SDL_CreateRenderer(windowID, 0, 0);
- PixelFormat:=nil;// SDLPrimSurface^.format;
-
- SDL_SetRenderDrawColor(0, 0, 0, 255);
- SDL_RenderFill(nil);
- SDL_RenderPresent();
-{$ELSE}
SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags);
SDLTry(SDLPrimSurface <> nil, true);
PixelFormat:= SDLPrimSurface^.format;
-{$ENDIF}
{$IFDEF DEBUGFILE}
AddFileLog('Setting up OpenGL...');
--- a/hedgewars/PascalExports.pas Sun Jan 24 19:01:51 2010 +0000
+++ b/hedgewars/PascalExports.pas Sun Jan 24 19:52:30 2010 +0000
@@ -19,6 +19,7 @@
{$IFDEF IPHONEOS}
// called by pascal code, they deal with the objc code
+procedure IPH_CreateWindowsFromObjc; cdecl; external;
function IPH_getDocumentsPath: PChar; cdecl; external;
procedure IPH_showControls; cdecl; external;
--- a/hedgewars/SDLh.pas Sun Jan 24 19:01:51 2010 +0000
+++ b/hedgewars/SDLh.pas Sun Jan 24 19:52:30 2010 +0000
@@ -327,24 +327,34 @@
{* SDL_Event type definition *}
{$IFDEF SDL13}
- TSDL_WindowID = LongInt;
- TSDL_TextureID = LongInt;
+ //UPDATE TSDL_Window AND TSDL_Texture before usage!!!
+ PSDL_Window = ^TSDL_Window;
+ TSDL_Window = LongInt; //not true anymore
+
+ PSDL_Texture = ^TSDL_Texture;
+ TSDL_Texture = LongInt; //not true anymore
TSDL_WindowEvent = record
type_: byte;
gain: byte;
state: byte;
- windowID: TSDL_WindowID;
+ windowID: LongInt;
data1, data2: LongInt;
end;
// implement SDL_TextEditingEvent + SDL_TextInputEvent for sdl13
{$ELSE}
+ //these two are present in sdl1.3 but only for backward compatibility
TSDL_ActiveEvent = record
type_: byte;
gain: byte;
state: byte;
end;
+
+ TSDL_ResizeEvent = record
+ type_: Byte;
+ w, h: LongInt;
+ end;
{$ENDIF}
TSDL_MouseMotionEvent = record
@@ -352,6 +362,7 @@
which: byte;
state: byte;
{$IFDEF SDL13}
+ windowID: LongInt;
x, y, xrel, yrel : LongInt;
pressure, pressure_max, pressure_min,
rotation, tilt, cursor: LongInt;
@@ -363,7 +374,7 @@
TSDL_KeyboardEvent = record
type_: Byte;
{$IFDEF SDL13}
- windowID: TSDL_WindowID;
+ windowID: LongInt;
{$ENDIF}
which: Byte;
state: Byte;
@@ -376,6 +387,7 @@
button,
state: byte;
{$IFDEF SDL13}
+ windowID: LongInt;
x, y: LongInt;
{$ELSE}
x, y: word;
@@ -385,7 +397,7 @@
{$IFDEF SDL13}
TSDL_MouseWheelEvent = record
type_: Byte;
- windowID: TSDL_WindowID;
+ windowID: LongInt;
which: Byte;
x, y: LongInt;
end;
@@ -431,13 +443,6 @@
type_: Byte;
end;
-{$IFNDEF SDL13}
- TSDL_ResizeEvent = record
- type_: Byte;
- w, h: LongInt;
- end;
-{$ENDIF}
-
PSDL_Event = ^TSDL_Event;
TSDL_Event = record
case Byte of
@@ -626,27 +631,19 @@
function SDL_SaveBMP_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: LongInt): LongInt; cdecl; external SDLLibName;
{$IFDEF SDL13}
-function SDL_CreateWindow(title: PChar; x,y,w,h, flags: LongInt): TSDL_WindowID; cdecl; external SDLLibName;
-function SDL_CreateRenderer(windowID: TSDL_WindowID; index, flags: LongInt): LongInt; cdecl; external SDLLibName;
-function SDL_SetRenderDrawColor(r,g,b,a: byte): LongInt; cdecl; external SDLLibName;
function SDL_RenderFill(rect: PSDL_Rect): LongInt;
function SDL_RenderFillRect(rect: PSDL_Rect): LongInt; cdecl; external SDLLibName;
function SDL_RenderClear: LongInt; cdecl; external SDLLibName;
procedure SDL_RenderPresent; cdecl; external SDLLibName;
-function SDL_RenderCopy(textureID: TSDL_TextureID; srcrect, dstrect: PSDL_Rect): LongInt; cdecl; external SDLLibName;
procedure SDL_VideoQuit; cdecl; external SDLLibName;
-function SDL_CreateTextureFromSurface(format: LongInt; surface: PSDL_Surface): TSDL_TextureID; cdecl; external SDLLibName;
-procedure SDL_DestroyTexture(textureID: TSDL_TextureID); cdecl; external SDLLibName;
-
-function SDL_GetKeyboardState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName;
function SDL_SelectMouse(index: LongInt): LongInt; cdecl; external SDLLibName;
function SDL_GetRelativeMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
function SDL_GetNumMice: LongInt; cdecl; external SDLLibName;
function SDL_PixelFormatEnumToMasks(format: TSDL_ArrayByteOrder; bpp: PLongInt; Rmask, Gmask, Bmask, Amask: PLongInt): boolean; cdecl; external SDLLibName;
-{$ELSE}
-function SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName;
{$ENDIF}
+
+function SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName {$IFDEF SDL13} name 'SDL_GetKeyboardState'{$ENDIF};
function SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
function SDL_GetKeyName(key: Longword): PChar; cdecl; external SDLLibName;
procedure SDL_WarpMouse(x, y: Word); cdecl; external SDLLibName;
@@ -668,13 +665,6 @@
function SDL_GL_SetAttribute(attr: TSDL_GLattr; value: LongInt): LongInt; cdecl; external SDLLibName;
procedure SDL_GL_SwapBuffers(); cdecl; external SDLLibName;
-{$IFDEF IPHONEOS}
-function SDL_iPhoneKeyboardShow(windowID: LongInt): LongInt; cdecl; external SDLLibName;
-function SDL_iPhoneKeyboardHide(windowID: LongInt): LongInt; cdecl; external SDLLibName;
-function SDL_iPhoneKeyboardIsShown(windowID: LongInt): boolean; cdecl; external SDLLibName;
-function SDL_iPhoneKeyboardToggle(windowID: LongInt): LongInt; cdecl; external SDLLibName;
-{$ENDIF}
-
function SDL_NumJoysticks: LongInt; cdecl; external SDLLibName;
function SDL_JoystickName(idx: LongInt): PChar; cdecl; external SDLLibName;
function SDL_JoystickOpen(idx: LongInt): PSDL_Joystick; cdecl; external SDLLibName;
--- a/hedgewars/hwengine.pas Sun Jan 24 19:01:51 2010 +0000
+++ b/hedgewars/hwengine.pas Sun Jan 24 19:52:30 2010 +0000
@@ -255,7 +255,7 @@
if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p];
WriteToConsole('Init SDL... ');
- SDLTry(SDL_Init(SDL_INIT_VIDEO or SDL_INIT_NOPARACHUTE) >= 0, true);
+ SDLTry(SDL_Init(SDL_INIT_VIDEO) >= 0, true);
WriteLnToConsole(msgOK);
SDL_EnableUNICODE(1);
--- a/hedgewars/uKeys.pas Sun Jan 24 19:01:51 2010 +0000
+++ b/hedgewars/uKeys.pas Sun Jan 24 19:52:30 2010 +0000
@@ -108,11 +108,7 @@
movecursor(5 * CursorMovementX, 5 * CursorMovementY);
k:= SDL_GetMouseState(nil, nil);
-{$IFDEF SDL13}
-pkbd:= SDL_GetKeyboardState(@j);
-{$ELSE}
pkbd:= SDL_GetKeyState(@j);
-{$ENDIF}
{$IFNDEF IPHONEOS}
for i:= 6 to pred(j) do // first 6 will be overwritten
@@ -207,11 +203,8 @@
begin
k:= SDL_GetMouseState(nil, nil);
-{$IFDEF SDL13}
-pkbd:= SDL_GetKeyboardState(@j);
-{$ELSE}
pkbd:= SDL_GetKeyState(@j);
-{$ENDIF}
+
TryDo(j < cKeyMaxIndex, 'SDL keys number is more than expected (' + inttostr(j) + ')', true);
{$IFNDEF IPHONEOS}
@@ -312,11 +305,7 @@
//for i:= 0 to cKeyMaxIndex do writeln(stdout,inttostr(i) + ': ' + KeyNames[i]);
// get the size of keyboard array
-{$IFDEF SDL13}
-SDL_GetKeyboardState(@k);
-{$ELSE}
SDL_GetKeyState(@k);
-{$ENDIF}
// Controller(s)
for j:= 0 to Pred(ControllerNumControllers) do