First stage of rehabilitating full screen mode selection

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@115 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Dylan Smith 2005-09-06 21:05:03 +00:00
parent 50981407d8
commit 5d9fff6f2f
6 changed files with 93 additions and 44 deletions

View File

@ -127,7 +127,6 @@ Your fair use and other rights are in no way affected by the above.
- (int) indexOfCurrentDisplayMode
{
// TODO: see if fullscreen is actually practical with GNUstep
#ifndef GNUSTEP
NSDictionary *mode;
@ -139,8 +138,11 @@ Your fair use and other rights are in no way affected by the above.
else
return [displayModes indexOfObject:mode];
#else
return NSNotFound;
// TODO: The screen mode array needs to be 'grown up' into proper
// ObjC code, but that's a battle for another day right now.
return [gameView indexOfCurrentSize];
#endif
return NSNotFound;
}
- (NSDictionary *) findDisplayModeForWidth:(unsigned int) d_width Height:(unsigned int) d_height Refresh:(unsigned int) d_refresh
@ -272,7 +274,30 @@ static int _compareModes(id arg1, id arg2, void *context)
modeRefresh = [[mode objectForKey: (NSString *)kCGDisplayRefreshRate] intValue];
//NSLog(@"()=> %d x %d at %dHz", modeWidth, modeHeight, modeRefresh);
}
#endif // ifndef GNUSTEP
#else // ifndef GNUSTEP
// TODO: The low-level act of getting resolutions/count of resolutions
// probably shouldn't belong in the game view but in a support class
// possibly emulating the Macintosh to reduce code differences.
displayModes = [[NSMutableArray alloc] init];
NSSize *sizes=[gameView getSimpleSizeArray];
int sizeCount=[gameView getSimpleSizeArrayCount];
int i;
for(i=0; i < sizeCount; i++)
{
NSMutableDictionary *mode=[[NSMutableDictionary alloc] init];
[mode setValue: [NSNumber numberWithInt: (int)sizes->width]
forKey: kCGDisplayWidth];
[mode setValue: [NSNumber numberWithInt: (int)sizes->height]
forKey: kCGDisplayHeight];
[mode setValue: [NSNumber numberWithInt: 0]
forKey: kCGDisplayRefreshRate];
[displayModes addObject: mode];
NSLog(@"Added mode %@", mode);
sizes++;
}
#endif // ifndef GNUSTEP #else
}
/* end GDC */
@ -356,12 +381,11 @@ static int _compareModes(id arg1, id arg2, void *context)
{
// set full screen mode to first available mode
fullscreenDisplayMode = [displayModes objectAtIndex:0];
#ifndef GNUSTEP
width = [[fullscreenDisplayMode objectForKey: (NSString *)kCGDisplayWidth] intValue];
height = [[fullscreenDisplayMode objectForKey: (NSString *)kCGDisplayHeight] intValue];
refresh = [[fullscreenDisplayMode objectForKey: (NSString *)kCGDisplayRefreshRate] intValue];
#endif
}
NSLog(@"fullScreenDisplayMode=%@", fullscreenDisplayMode);
// moved to before the Universe is created
[self logProgress:@"loading selected expansion packs..."];

View File

@ -156,6 +156,10 @@ extern int debug;
- (BOOL) inFullScreenMode;
#ifdef GNUSTEP
- (void) setFullScreenMode:(BOOL)fsm;
- (int) indexOfCurrentSize;
- (void) setScreenSize: (int)sizeIndex;
- (NSSize *)getSimpleSizeArray;
- (int) getSimpleSizeArrayCount;
#endif
/*

View File

@ -96,6 +96,7 @@ Your fair use and other rights are in no way affected by the above.
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
NSLog(@"CREATING MODE LIST");
screenSizes[0] = [MyOpenGLView getNativeSize];
screenSizes[1] = NSMakeSize(800, 600);
screenSizes[2] = NSMakeSize(1024, 768);
@ -211,6 +212,30 @@ Your fair use and other rights are in no way affected by the above.
{
fullScreen = fsm;
}
- (int) indexOfCurrentSize
{
return currentSize;
}
- (void) setScreenSize: (int)sizeIndex
{
currentSize=sizeIndex;
[self initialiseGLWithSize:screenSizes[currentSize]];
}
- (NSSize *)getSimpleSizeArray
{
return screenSizes;
}
- (int)getSimpleSizeArrayCount
{
// TODO: Yuck. Need a proper screen size enumerator.
// This is temporary until we get the SDL code working the same as Mac
// code.
return 3;
}
#endif
- (void) display

View File

@ -79,14 +79,14 @@ Your fair use and other rights are in no way affected by the above.
#define GUI_ROW_OPTIONS_LOAD 9
#define GUI_ROW_OPTIONS_BEGIN_NEW 10
#define GUI_ROW_OPTIONS_OPTIONS 11
#define GUI_ROW_OPTIONS_DISPLAY 12
#ifdef GNUSTEP
#define GUI_ROW_OPTIONS_OOTUNES 12
//#define GUI_ROW_OPTIONS_OOTUNES 12
#define GUI_ROW_OPTIONS_DETAIL 13
#define GUI_ROW_OPTIONS_STRICT 14
#define GUI_ROW_OPTIONS_QUIT 15
#else
#define GUI_ROW_OPTIONS_DISPLAY 12
#define GUI_ROW_OPTIONS_SPEECH 13
#define GUI_ROW_OPTIONS_OOTUNES 14
#define GUI_ROW_OPTIONS_DETAIL 15

View File

@ -3165,17 +3165,13 @@ static BOOL taking_snapshot;
// ***JESTER_START*** 11/08/04
//Utility function
#ifndef GNUSTEP
static NSString* GenerateDisplayString(int inModeWidth, int inModeHeight, int inModeRefresh);
#endif
// ***JESTER_END*** 11/08/04
static BOOL pling_pressed;
static BOOL cursor_moving;
static BOOL disc_operation_in_progress;
#ifndef GNUSTEP
static BOOL switching_resolution;
#endif
static BOOL wait_for_key_up;
static int searchStringLength;
static double timeLastKeyPress;
@ -3419,7 +3415,9 @@ static BOOL queryPressed;
int load_row = GUI_ROW_OPTIONS_LOAD;
int begin_new_row = GUI_ROW_OPTIONS_BEGIN_NEW;
int options_row = GUI_ROW_OPTIONS_OPTIONS;
#ifndef GNUSTEP
int ootunes_row = GUI_ROW_OPTIONS_OOTUNES;
#endif
int strict_row = GUI_ROW_OPTIONS_STRICT;
int detail_row = GUI_ROW_OPTIONS_DETAIL;
#ifdef GNUSTEP
@ -3428,11 +3426,11 @@ static BOOL queryPressed;
int quit_row = GUI_ROW_OPTIONS_QUIT;
#else
// Macintosh only
int display_row = GUI_ROW_OPTIONS_DISPLAY;
int speech_row = GUI_ROW_OPTIONS_SPEECH;
NSArray *modes = [controller displayModes];
GameController *controller = [universe gameController];
#endif
int display_row = GUI_ROW_OPTIONS_DISPLAY;
GameController *controller = [universe gameController];
NSArray *modes = [controller displayModes];
[self handleGUIUpDownArrowKeys: gui :gameView];
BOOL selectKeyPress = ([gameView isDown:13]||[gameView isDown:gvMouseDoubleClick]);
@ -3499,14 +3497,13 @@ static BOOL queryPressed;
disc_operation_in_progress = NO;
}
#ifndef GNUSTEP
if (([gui selectedRow] == display_row)&&(([gameView isDown:gvArrowKeyRight])||([gameView isDown:gvArrowKeyLeft]))&&(!switching_resolution))
{
int direction = ([gameView isDown:gvArrowKeyRight]) ? 1 : -1;
int displayModeIndex = [controller indexOfCurrentDisplayMode];
if (displayModeIndex == NSNotFound)
{
NSLog(@"***** couldn't find current display mode switching to basic 640x480");
NSLog(@"***** couldn't find current display mode switching to native display resolution");
displayModeIndex = 0;
}
else
@ -3522,6 +3519,12 @@ static BOOL queryPressed;
int modeHeight = [[mode objectForKey: (NSString *)kCGDisplayHeight] intValue];
int modeRefresh = [[mode objectForKey: (NSString *)kCGDisplayRefreshRate] intValue];
[controller setDisplayWidth:modeWidth Height:modeHeight Refresh:modeRefresh];
#ifdef GNUSTEP
// TODO: The gameView for the SDL game currently holds and
// sets the actual screen resolution (controller just stores
// it). This probably ought to change.
[gameView setScreenSize: displayModeIndex];
#endif
// ****JESTER_START*** 11/08/04
//NSString *displayModeString = [NSString stringWithFormat:@" Fullscreen: %d x %d at %d Hz ", modeWidth, modeHeight, modeRefresh];
NSString *displayModeString = GenerateDisplayString(modeWidth, modeHeight, modeRefresh);
@ -3537,7 +3540,8 @@ static BOOL queryPressed;
}
if ((![gameView isDown:gvArrowKeyRight])&&(![gameView isDown:gvArrowKeyLeft])&&(!selectKeyPress))
switching_resolution = NO;
#ifndef GNUSTEP
if (([gui selectedRow] == speech_row)&&(([gameView isDown:gvArrowKeyRight])||([gameView isDown:gvArrowKeyLeft])))
{
GuiDisplayGen* gui = [universe gui];
@ -3550,7 +3554,6 @@ static BOOL queryPressed;
[gui setText:@" Spoken messages: OFF " forRow:speech_row align:GUI_ALIGN_CENTER];
[universe guiUpdated];
}
#endif
if (([gui selectedRow] == ootunes_row)&&(([gameView isDown:gvArrowKeyRight])||([gameView isDown:gvArrowKeyLeft])))
{
@ -3558,19 +3561,13 @@ static BOOL queryPressed;
if ([gameView isDown:gvArrowKeyRight] != ootunes_on)
[gui click];
ootunes_on = [gameView isDown:gvArrowKeyRight];
#ifdef GNUSTEP
if (ootunes_on)
[gui setText:@" xine integration: ON " forRow:ootunes_row align:GUI_ALIGN_CENTER];
else
[gui setText:@" xine integration: OFF " forRow:ootunes_row align:GUI_ALIGN_CENTER];
#else
if (ootunes_on)
[gui setText:@" iTunes integration: ON " forRow:ootunes_row align:GUI_ALIGN_CENTER];
else
[gui setText:@" iTunes integration: OFF " forRow:ootunes_row align:GUI_ALIGN_CENTER];
#endif
[universe guiUpdated];
}
#endif
if (([gui selectedRow] == detail_row)&&(([gameView isDown:gvArrowKeyRight])||([gameView isDown:gvArrowKeyLeft])))
{
@ -6260,7 +6257,6 @@ static BOOL toggling_music;
BOOL canQuickSave = (canLoadOrSave && ([[(MyOpenGLView *)[universe gameView] gameController] playerFileToLoad] != nil));
GameController *controller = [universe gameController];
#ifndef GNUSTEP
int displayModeIndex = [controller indexOfCurrentDisplayMode];
if (displayModeIndex == NSNotFound)
{
@ -6280,8 +6276,7 @@ static BOOL toggling_music;
int modeHeight = [[mode objectForKey: (NSString *)kCGDisplayHeight] intValue];
int modeRefresh = [[mode objectForKey: (NSString *)kCGDisplayRefreshRate] intValue];
NSString *displayModeString = [NSString stringWithFormat:@" Fullscreen: %d x %d at %d Hz ", modeWidth, modeHeight, modeRefresh];
#endif
NSString *displayModeString = GenerateDisplayString(modeWidth, modeHeight, modeRefresh);
// GUI stuff
{
@ -6296,18 +6291,14 @@ static BOOL toggling_music;
// doesn't need speech.
int quit_row = GUI_ROW_OPTIONS_QUIT;
#else
int display_row = GUI_ROW_OPTIONS_DISPLAY;
int speech_row = GUI_ROW_OPTIONS_SPEECH;
#endif
int ootunes_row = GUI_ROW_OPTIONS_OOTUNES;
#endif
int display_row = GUI_ROW_OPTIONS_DISPLAY;
int detail_row = GUI_ROW_OPTIONS_DETAIL;
int strict_row = GUI_ROW_OPTIONS_STRICT;
#ifdef GNUSTEP
int first_sel_row = (canLoadOrSave)? save_row : ootunes_row;
#else
int first_sel_row = (canLoadOrSave)? save_row : display_row;
#endif
if (canQuickSave)
first_sel_row = quicksave_row;
@ -6338,15 +6329,10 @@ static BOOL toggling_music;
//
[gui setText:@"Game Options:" forRow:options_row align:GUI_ALIGN_CENTER];
[gui setColor:[NSColor grayColor] forRow:options_row];
//
[gui setText:displayModeString forRow:display_row align:GUI_ALIGN_CENTER];
[gui setKey:GUI_KEY_OK forRow:display_row];
#ifdef GNUSTEP
// TODO: This menu section is preliminary.
if (ootunes_on)
[gui setText:@" xine integration: ON " forRow:ootunes_row align:GUI_ALIGN_CENTER];
else
[gui setText:@" xine integration: OFF " forRow:ootunes_row align:GUI_ALIGN_CENTER];
// full screen mode is probably not possible in GNUstep.
// [gui setText:displayModeString
// forRow:display_row align:GUI_ALIGN_CENTER];
// quit menu option
[gui setText:@" Exit game " forRow:quit_row align:GUI_ALIGN_CENTER];
@ -7339,10 +7325,14 @@ NSSound* burnersound;
}
// ***JESTER_START*** 11/08/04
#ifndef GNUSTEP
NSString* GenerateDisplayString(int inModeWidth, int inModeHeight, int inModeRefresh)
{
NSString *displayModeString = nil;
#ifdef GNUSTEP
// We don't actually know the refresh rate.
displayModeString=[NSString stringWithFormat:@" Fullscreen: %d x %d ",
inModeWidth, inModeHeight];
#else
if(inModeRefresh != 0)
{
displayModeString = [NSString stringWithFormat:@" Fullscreen: %d x %d at %d Hz ", inModeWidth, inModeHeight, inModeRefresh];
@ -7352,9 +7342,9 @@ NSString* GenerateDisplayString(int inModeWidth, int inModeHeight, int inModeRef
//Let's not bother showing the useless modeRefresh info on Powerbooks that don't have refresh info.
displayModeString = [NSString stringWithFormat:@" Fullscreen: %d x %d ", inModeWidth, inModeHeight];
}
#endif
return displayModeString;
}
#endif
// ***JESTER_END*** 11/08/04
- (void) setScript_target:(ShipEntity *)ship

View File

@ -17,4 +17,10 @@
#include "SDL_syswm.h"
#define MAX_CHANNELS 16
// Macintosh compatibility defines
#define kCGDisplayWidth (@"Width")
#define kCGDisplayHeight (@"Height")
#define kCGDisplayRefreshRate (@"RefreshRate")
#endif /* OOLITE_LINUX */