-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare for before commiting changes needed for SDL2
- Loading branch information
Showing
8 changed files
with
3,730 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
// | ||
// $Id: Comparison.h,v 1.3 2004/12/12 20:17:24 will_mason Exp $ | ||
// | ||
// vi: set ft=objc: | ||
|
||
/* | ||
* ObjectiveLib - a library of containers and algorithms for Objective-C | ||
* | ||
* Copyright (c) 2004 | ||
* Will Mason | ||
* | ||
* Portions: | ||
* | ||
* Copyright (c) 1994 | ||
* Hewlett-Packard Company | ||
* | ||
* Copyright (c) 1996,1997 | ||
* Silicon Graphics Computer Systems, Inc. | ||
* | ||
* Copyright (c) 1997 | ||
* Moscow Center for SPARC Technology | ||
* | ||
* Copyright (c) 1999 | ||
* Boris Fomitchev | ||
* | ||
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
* | ||
* You may contact the author at [email protected]. | ||
*/ | ||
|
||
#if defined(GNUSTEP) | ||
|
||
#if !defined(__COMPARISON_OL_GUARD) | ||
#define __COMPARISON_OL_GUARD | ||
|
||
#include <Foundation/NSObject.h> | ||
|
||
/** | ||
* @category NSObject(OLComparisonMethods) Comparison.h Objectivelib/Comparison.h | ||
* | ||
* Comparison methods used in @ref Functors "function objects". These comparison | ||
* methods are only required to be included when GNUstep is the platform, as | ||
* Cocoa already defines them. Under Cocoa they are declared in the | ||
* intuitively-named file @c NSScriptWhoseTests.h. All of these methods send | ||
* the message @c compare: to the receiving object. | ||
* | ||
* @pre The receiving object must implement the method @c compare:. | ||
*/ | ||
@interface NSObject (OLComparisonMethods) | ||
|
||
/** | ||
* Return whether another object is equal to this one. This message returns YES if | ||
* and only if the message @c compare: returns @c NSOrderedSame. | ||
* | ||
* @param object the object to which to compare this one | ||
* @return YES if @a object is equal to this one, NO otherwise | ||
*/ | ||
- (BOOL) isEqualTo: (id)object; | ||
|
||
/** | ||
* Return whether this object is greater than another one. This message returns | ||
* YES if and only if @c compare: returns @c NSOrderedDescending. | ||
* | ||
* @param object the object to which to compare this one | ||
* @return YES if this object is greater than @a object, NO otherwise | ||
*/ | ||
- (BOOL) isGreaterThan: (id)object; | ||
|
||
/** | ||
* Return whether this object is greater than or equal to another one. This message returns | ||
* YES if and only if @c compare: does not return @c NSOrderedAscending. | ||
* | ||
* @param object the object to which to compare this one | ||
* @return YES if this object is greater than or equal to @a object, NO otherwise | ||
*/ | ||
- (BOOL) isGreaterThanOrEqualTo: (id)object; | ||
|
||
/** | ||
* Return whether this object is less than another one. This message returns | ||
* YES if and only if @c compare: returns @c NSOrderedAscending. | ||
* | ||
* @param object the object to which to compare this one | ||
* @return YES if this object is less than @a object, NO otherwise | ||
*/ | ||
- (BOOL) isLessThan: (id)object; | ||
|
||
/** | ||
* Return whether this object is less than or equal to another one. This message returns | ||
* YES if and only if @c compare: does not return @c NSOrderedDescending. | ||
* | ||
* @param object the object to which to compare this one | ||
* @return YES if this object is less than or equal to @a object, NO otherwise | ||
*/ | ||
- (BOOL) isLessThanOrEqualTo: (id)object; | ||
|
||
/** | ||
* Return whether another object is not equal to this one. This message returns YES if | ||
* and only if the message @c compare: does not return @c NSOrderedSame. | ||
* | ||
* @param object the object to which to compare this one | ||
* @return YES if @a object is not equal to this one, NO otherwise | ||
*/ | ||
- (BOOL) isNotEqualTo: (id)object; | ||
|
||
@end | ||
|
||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// | ||
// $Id: Comparison.m,v 1.3 2004/11/29 23:35:50 will_mason Exp $ | ||
// | ||
// vi: set ft=objc: | ||
|
||
/* | ||
* ObjectiveLib - a library of containers and algorithms for Objective-C | ||
* | ||
* Copyright (c) 2004 | ||
* Will Mason | ||
* | ||
* Portions: | ||
* | ||
* Copyright (c) 1994 | ||
* Hewlett-Packard Company | ||
* | ||
* Copyright (c) 1996,1997 | ||
* Silicon Graphics Computer Systems, Inc. | ||
* | ||
* Copyright (c) 1997 | ||
* Moscow Center for SPARC Technology | ||
* | ||
* Copyright (c) 1999 | ||
* Boris Fomitchev | ||
* | ||
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
* | ||
* You may contact the author at [email protected]. | ||
*/ | ||
|
||
#if defined(GNUSTEP) | ||
|
||
#include "Comparison.h" | ||
#include <Foundation/NSString.h> | ||
|
||
@implementation NSObject (OLComparison) | ||
|
||
- (BOOL) isEqualTo: (id)object | ||
{ | ||
return (object != nil && [self compare: object] == NSOrderedSame) ? | ||
YES : NO; | ||
} | ||
|
||
- (BOOL) isGreaterThan: (id)object | ||
{ | ||
return (object != nil && [self compare: object] == NSOrderedDescending) ? | ||
YES : NO; | ||
} | ||
|
||
- (BOOL) isGreaterThanOrEqualTo: (id)object | ||
{ | ||
return (object != nil && [self compare: object] != NSOrderedAscending) ? | ||
YES : NO; | ||
} | ||
|
||
- (BOOL) isLessThan: (id)object | ||
{ | ||
return (object != nil && [self compare: object] == NSOrderedAscending) ? | ||
YES : NO; | ||
} | ||
|
||
- (BOOL) isLessThanOrEqualTo: (id)object | ||
{ | ||
return (object != nil && [self compare: object] != NSOrderedDescending) ? | ||
YES : NO; | ||
} | ||
|
||
- (BOOL) isNotEqualTo: (id)object | ||
{ | ||
return (object != nil && [self compare: object] != NSOrderedSame) ? | ||
YES : NO; | ||
} | ||
|
||
@end | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
/* | ||
GameController+SDLFullScreen.m | ||
Full-screen rendering support for SDL targets. | ||
Oolite | ||
Copyright (C) 2004-2013 Giles C Williams and contributors | ||
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; either version 2 | ||
of the License, or (at your option) any later version. | ||
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., 51 Franklin Street, Fifth Floor, Boston, | ||
MA 02110-1301, USA. | ||
*/ | ||
|
||
|
||
#import "GameController.h" | ||
|
||
#if OOLITE_SDL | ||
|
||
#import "MyOpenGLView.h" | ||
#import "Universe.h" | ||
#import "OOFullScreenController.h" | ||
|
||
|
||
@implementation GameController (FullScreen) | ||
|
||
- (void) setUpDisplayModes | ||
{ | ||
NSArray *modes = [gameView getScreenSizeArray]; | ||
NSDictionary *mode = nil; | ||
unsigned int modeIndex, modeCount; | ||
unsigned int modeWidth, modeHeight; | ||
|
||
displayModes = [[NSMutableArray alloc] init]; | ||
modeCount = [modes count]; | ||
for (modeIndex = 0; modeIndex < modeCount; modeIndex++) | ||
{ | ||
mode = [modes objectAtIndex: modeIndex]; | ||
modeWidth = [[mode objectForKey: kOODisplayWidth] intValue]; | ||
modeHeight = [[mode objectForKey: kOODisplayHeight] intValue]; | ||
|
||
if (modeWidth < DISPLAY_MIN_WIDTH || | ||
modeWidth > DISPLAY_MAX_WIDTH || | ||
modeHeight < DISPLAY_MIN_HEIGHT || | ||
modeHeight > DISPLAY_MAX_HEIGHT) | ||
continue; | ||
[displayModes addObject: mode]; | ||
} | ||
|
||
NSSize fsmSize = [gameView currentScreenSize]; | ||
width = fsmSize.width; | ||
height = fsmSize.height; | ||
} | ||
|
||
|
||
- (void) setFullScreenMode:(BOOL)fsm | ||
{ | ||
fullscreen = fsm; | ||
} | ||
|
||
|
||
- (void) exitFullScreenMode | ||
{ | ||
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"fullscreen"]; | ||
stayInFullScreenMode = NO; | ||
} | ||
|
||
|
||
- (BOOL) inFullScreenMode | ||
{ | ||
return [gameView inFullScreenMode]; | ||
} | ||
|
||
|
||
- (BOOL) setDisplayWidth:(unsigned int) d_width Height:(unsigned int) d_height Refresh:(unsigned int) d_refresh | ||
{ | ||
NSDictionary *d_mode = [self findDisplayModeForWidth: d_width Height: d_height Refresh: d_refresh]; | ||
if (d_mode) | ||
{ | ||
width = d_width; | ||
height = d_height; | ||
refresh = d_refresh; | ||
fullscreenDisplayMode = d_mode; | ||
|
||
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; | ||
|
||
[userDefaults setInteger:width forKey:@"display_width"]; | ||
[userDefaults setInteger:height forKey:@"display_height"]; | ||
[userDefaults setInteger:refresh forKey:@"display_refresh"]; | ||
|
||
// Manual synchronization is required for SDL And doesn't hurt much for OS X. | ||
[userDefaults synchronize]; | ||
|
||
return YES; | ||
} | ||
return NO; | ||
} | ||
|
||
|
||
- (NSDictionary *) findDisplayModeForWidth:(unsigned int) d_width Height:(unsigned int) d_height Refresh:(unsigned int) d_refresh | ||
{ | ||
int i, modeCount; | ||
NSDictionary *mode; | ||
unsigned int modeWidth, modeHeight, modeRefresh; | ||
|
||
modeCount = [displayModes count]; | ||
|
||
for (i = 0; i < modeCount; i++) | ||
{ | ||
mode = [displayModes objectAtIndex: i]; | ||
modeWidth = [[mode objectForKey:kOODisplayWidth] intValue]; | ||
modeHeight = [[mode objectForKey:kOODisplayHeight] intValue]; | ||
modeRefresh = [[mode objectForKey:kOODisplayRefreshRate] intValue]; | ||
if ((modeWidth == d_width)&&(modeHeight == d_height)&&(modeRefresh == d_refresh)) | ||
{ | ||
return mode; | ||
} | ||
} | ||
return nil; | ||
} | ||
|
||
|
||
- (NSArray *) displayModes | ||
{ | ||
return [NSArray arrayWithArray:displayModes]; | ||
} | ||
|
||
|
||
- (NSUInteger) indexOfCurrentDisplayMode | ||
{ | ||
NSDictionary *mode; | ||
|
||
mode = [self findDisplayModeForWidth: width Height: height Refresh: refresh]; | ||
if (mode == nil) | ||
return NSNotFound; | ||
else | ||
return [displayModes indexOfObject:mode]; | ||
|
||
return NSNotFound; | ||
} | ||
|
||
|
||
- (void) pauseFullScreenModeToPerform:(SEL) selector onTarget:(id) target | ||
{ | ||
pauseSelector = selector; | ||
pauseTarget = target; | ||
stayInFullScreenMode = NO; | ||
} | ||
|
||
@end | ||
|
||
#endif |
Oops, something went wrong.