From 3594399b406539f8a9520b0a7c02d8bbe91c3fdb Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Sat, 1 Apr 2006 18:57:39 +0000 Subject: [PATCH] Begone, AppKit git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@402 127b21dd-08f5-0310-b4b7-95ae10353056 --- GNUmakefile | 10 +++++----- GNUmakefile.postamble | 17 +++++++++++++++-- src/Core/Entity.m | 2 +- src/Core/LoadSave.m | 2 +- src/Core/OpenGLSprite.h | 4 ++++ src/Core/OpenGLSprite.m | 6 ++++-- src/Core/PlayerEntity Additions.m | 10 +++++----- src/Core/PlayerEntity.m | 15 +++++++++++---- src/Core/PlayerEntity_StickMapper.m | 2 +- src/Core/ResourceManager.h | 2 ++ src/Core/ResourceManager.m | 4 +++- src/Core/Universe.m | 10 +++++----- src/SDL/main.m | 3 --- 13 files changed, 57 insertions(+), 30 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 2749b5a5..e87310d5 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -6,23 +6,23 @@ vpath %.c src/SDL:src/Core:src/BSDCompat GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_USER_ROOT) ifeq ($(GNUSTEP_HOST_OS),mingw32) ADDITIONAL_INCLUDE_DIRS = - ADDITIONAL_GUI_LIBS = -lglu32 -lopengl32 -lmingw32 -lSDLmain -lSDL -lSDL_mixer -lSDL_image + ADDITIONAL_OBJC_LIBS = -lglu32 -lopengl32 -lmingw32 -lSDLmain -lSDL -lSDL_mixer -lSDL_image -lgnustep-base ADDITIONAL_CFLAGS = -DLINUX -DWIN32 -DNEED_STRLCPY `sdl-config --cflags` # note the vpath stuff above isn't working for me, so adding src/SDL and src/Core explicitly ADDITIONAL_OBJCFLAGS = -DLOADSAVEGUI -DLINUX -DWIN32 -DHAVE_SOUND -Isrc/SDL -Isrc/Core -Wno-import `sdl-config --cflags` oolite_LIB_DIRS += -L$(GNUSTEP_LOCAL_ROOT)/lib else ADDITIONAL_INCLUDE_DIRS = -Isrc/SDL -Isrc/Core -Isrc/BSDCompat - ADDITIONAL_GUI_LIBS = -lGLU -lGL -lSDL -lpthread -lSDL_mixer -lSDL_image + ADDITIONAL_OBJC_LIBS = -lGLU -lGL -lSDL -lpthread -lSDL_mixer -lSDL_image -lgnustep-base ADDITIONAL_CFLAGS = -DLINUX -DNEED_STRLCPY `sdl-config --cflags` ADDITIONAL_OBJCFLAGS = -DLOADSAVEGUI -DLINUX -DHAVE_SOUND -Wno-import `sdl-config --cflags` oolite_LIB_DIRS += -L/usr/X11R6/lib/ endif -APP_NAME = oolite +OBJC_PROGRAM_NAME = oolite oolite_C_FILES = vector.c legacy_random.c strlcpy.c -oolite_OBJC_FILES = Comparison.m AI.m DustEntity.m Entity.m GameController.m GuiDisplayGen.m HeadUpDisplay.m main.m MyOpenGLView.m OpenGLSprite.m ParticleEntity.m PlanetEntity.m PlayerEntity_Additions.m PlayerEntity_contracts.m PlayerEntity_Controls.m PlayerEntity_Sound.m PlayerEntity.m ResourceManager.m RingEntity.m ShipEntity_AI.m ShipEntity.m SkyEntity.m StationEntity.m TextureStore.m Universe.m OOSound.m OOMusic.m SDLImage.m LoadSave.m OOFileManager.m JoystickHandler.m PlayerEntity_StickMapper.m OOBasicSoundReferencePoint.m OOBasicSoundSource.m OOCharacter.m OOTrumble.m WormholeEntity.m ScannerExtension.m OOXMLExtensions.m MutableDictionaryExtension.m Geometry.m Octree.m CollisionRegion.m +oolite_OBJC_FILES = Comparison.m AI.m DustEntity.m Entity.m GameController.m GuiDisplayGen.m HeadUpDisplay.m main.m MyOpenGLView.m OpenGLSprite.m ParticleEntity.m PlanetEntity.m PlayerEntity_Additions.m PlayerEntity_contracts.m PlayerEntity_Controls.m PlayerEntity_Sound.m PlayerEntity.m ResourceManager.m RingEntity.m ShipEntity_AI.m ShipEntity.m SkyEntity.m StationEntity.m TextureStore.m Universe.m OOSound.m OOMusic.m SDLImage.m LoadSave.m OOFileManager.m JoystickHandler.m PlayerEntity_StickMapper.m OOBasicSoundReferencePoint.m OOBasicSoundSource.m OOCharacter.m OOTrumble.m WormholeEntity.m ScannerExtension.m OOXMLExtensions.m MutableDictionaryExtension.m Geometry.m Octree.m CollisionRegion.m OOColor.m -include $(GNUSTEP_MAKEFILES)/application.make +include $(GNUSTEP_MAKEFILES)/objc.make include GNUmakefile.postamble diff --git a/GNUmakefile.postamble b/GNUmakefile.postamble index a4e4a2f9..f8e7f5f5 100644 --- a/GNUmakefile.postamble +++ b/GNUmakefile.postamble @@ -5,15 +5,28 @@ # ifeq ($(debug),yes) EXTENSION=debug + SHAREDOBJ=shared_debug_obj else EXTENSION=app + SHAREDOBJ=shared_obj endif + +ifeq ($(GNUSTEP_HOST_OS),mingw32) + BINARY=$(SHAREDOBJ)/$(OBJC_PROGRAM_NAME).exe +else + BINARY=$(SHAREDOBJ)/$(OBJC_PROGRAM_NAME) +endif + CONTENTS = Contents -CONTENTDIR=$(APP_NAME).$(EXTENSION)/$(CONTENTS) -GNUSTEP_OW=$(APP_NAME).$(EXTENSION)/Resources/Info-gnustep.plist +PROGDIR=$(OBJC_PROGRAM_NAME).$(EXTENSION) +CONTENTDIR=$(OBJC_PROGRAM_NAME).$(EXTENSION)/$(CONTENTS) +GNUSTEP_OW=$(OBJC_PROGRAM_NAME).$(EXTENSION)/Resources/Info-gnustep.plist after-all:: rm -rf $(CONTENTDIR) + $(MKDIRS) $(PROGDIR) + $(MKDIRS) $(PROGDIR)/Resources $(MKDIRS) $(CONTENTDIR) $(CP) -r Resources $(CONTENTDIR)/Resources $(CP) src/Cocoa/Info-Oolite.plist $(GNUSTEP_OW) + $(CP) $(BINARY) $(PROGDIR) diff --git a/src/Core/Entity.m b/src/Core/Entity.m index ae559e66..d5e41ef9 100644 --- a/src/Core/Entity.m +++ b/src/Core/Entity.m @@ -695,7 +695,7 @@ static Universe *data_store_universe; else { NSLog(@"ERROR no basefile for entity %@"); - NSBeep(); + // NSBeep(); // appkit dependency } } glShadeModel(GL_SMOOTH); diff --git a/src/Core/LoadSave.m b/src/Core/LoadSave.m index a6202f4d..7970e5a9 100644 --- a/src/Core/LoadSave.m +++ b/src/Core/LoadSave.m @@ -503,7 +503,7 @@ if(![[self commanderDataDictionary] writeOOXMLToFile:savePath atomically:YES]) { - NSBeep(); + //NSBeep(); // appkit dependency NSLog(@"***** ERROR: Save to %@ failed!", savePath); NSException *myException = [NSException exceptionWithName:@"OoliteException" diff --git a/src/Core/OpenGLSprite.h b/src/Core/OpenGLSprite.h index 4b2e7d33..bb1a2463 100644 --- a/src/Core/OpenGLSprite.h +++ b/src/Core/OpenGLSprite.h @@ -62,7 +62,9 @@ extern int debug; - (id) init; +#ifndef GNUSTEP - (id) initWithImage:(NSImage *)textureImage cropRectangle:(NSRect)cropRect size:(NSSize) spriteSize; +#endif - (id) initWithText:(NSString *)str; - (id) initWithText:(NSString *)str ofColor:(NSColor *) textColor; - (void) dealloc; @@ -73,10 +75,12 @@ extern int debug; - (void)blitCentredToX:(float)x Y:(float)y Z:(float)z Alpha:(float)a; - (void) setText:(NSString *)str; +#ifndef GNUSTEP - (void)makeTextureFromImage:(NSImage *)texImage cropRectangle:(NSRect)cropRect size:(NSSize)spriteSize; - (void)replaceTextureFromImage:(NSImage *)texImage cropRectangle:(NSRect)cropRect; - (void)substituteTextureFromImage:(NSImage *)texImage; +#endif #ifdef GNUSTEP - (id) initWithSurface:(SDLImage *)textureImage cropRectangle:(NSRect)cropRect size:(NSSize) spriteSize; diff --git a/src/Core/OpenGLSprite.m b/src/Core/OpenGLSprite.m index 432a81df..3a8057e6 100644 --- a/src/Core/OpenGLSprite.m +++ b/src/Core/OpenGLSprite.m @@ -59,7 +59,7 @@ Your fair use and other rights are in no way affected by the above. - (id) initWithText:(NSString *)str { - return [self initWithText:str ofColor:[NSColor yellowColor]]; + return [self initWithText:str ofColor:[OOColor yellowColor]]; } - (id) initWithText:(NSString *)str ofColor:(NSColor *) textColor @@ -183,7 +183,7 @@ Your fair use and other rights are in no way affected by the above. #endif } - +#ifndef GNUSTEP - (void)makeTextureFromImage:(NSImage *)texImage cropRectangle:(NSRect)cropRect size:(NSSize)spriteSize { NSBitmapImageRep* bitmapImageRep; @@ -346,6 +346,8 @@ Your fair use and other rights are in no way affected by the above. [bitmapImageRep release]; } +#endif + #ifdef GNUSTEP /* SDL interprets each pixel as a 32-bit number, so our masks must depend on the endianness (byte order) of the machine */ diff --git a/src/Core/PlayerEntity Additions.m b/src/Core/PlayerEntity Additions.m index 634e0212..c58e9db6 100644 --- a/src/Core/PlayerEntity Additions.m +++ b/src/Core/PlayerEntity Additions.m @@ -97,13 +97,13 @@ static NSString * mission_key; if (conditions == nil) { NSLog(@"SCRIPT ERROR no 'conditions' in %@ - returning YES.", [couplet description]); - NSBeep(); + // NSBeep(); // AppKit dependency return success; } if (![conditions isKindOfClass:[NSArray class]]) { NSLog(@"SCRIPT ERROR \"conditions = %@\" is not an array - returning YES.", [conditions description]); - NSBeep(); + // NSBeep(); // AppKit dependency return success; } for (i = 0; (i < [conditions count])&&(success); i++) @@ -113,7 +113,7 @@ static NSString * mission_key; if (![actions isKindOfClass:[NSArray class]]) { NSLog(@"SCRIPT ERROR \"actions = %@\" is not an array.", [actions description]); - NSBeep(); + // NSBeep(); AppKit dependency } else { @@ -132,7 +132,7 @@ static NSString * mission_key; if (![else_actions isKindOfClass:[NSArray class]]) { NSLog(@"SCRIPT ERROR \"else_actions = %@\" is not an array.", [else_actions description]); - NSBeep(); + // NSBeep(); AppKit } else { @@ -1807,7 +1807,7 @@ static int shipsFound; if (![conditions isKindOfClass:[NSArray class]]) { NSLog(@"SCENE ERROR \"conditions = %@\" is not an array - returning NO.", [conditions description]); - NSBeep(); + // NSBeep(); AppKit return NO; } } diff --git a/src/Core/PlayerEntity.m b/src/Core/PlayerEntity.m index 42485b36..6322bbe8 100644 --- a/src/Core/PlayerEntity.m +++ b/src/Core/PlayerEntity.m @@ -3998,7 +3998,7 @@ double scoopSoundPlayTime = 0.0; filename = [[(MyOpenGLView *)[universe gameView] gameController] playerFileToLoad]; if (!filename) { - NSBeep(); + // NSBeep(); // AppKit NSLog(@"ERROR no filename returned by [[(MyOpenGLView *)[universe gameView] gameController] playerFileToLoad]"); NSException* myException = [NSException exceptionWithName:@"GameNotSavedException" @@ -4009,7 +4009,7 @@ double scoopSoundPlayTime = 0.0; } if (![[self commanderDataDictionary] writeOOXMLToFile:filename atomically:YES]) { - NSBeep(); + // NSBeep(); //AppKit NSLog(@"***** ERROR: Save to %@ failed!", filename); NSException* myException = [NSException exceptionWithName:@"OoliteException" @@ -4036,6 +4036,8 @@ double scoopSoundPlayTime = 0.0; - (void) savePlayer { +// Load/Save is done by an Oolite native function for gnustep. +#ifndef GNUSTEP NSSavePanel *sp; int runResult; @@ -4063,7 +4065,7 @@ double scoopSoundPlayTime = 0.0; if (![[self commanderDataDictionary] writeOOXMLToFile:[sp filename] atomically:YES]) { - NSBeep(); + // NSBeep(); // AppKit NSLog(@"***** ERROR: Save to %@ failed!", [sp filename]); NSException* myException = [NSException exceptionWithName:@"OoliteException" @@ -4087,10 +4089,12 @@ double scoopSoundPlayTime = 0.0; [[[Entity dataStore] preloadedDataFiles] writeToFile: cache_path atomically: YES]; } [self setGuiToStatusScreen]; +#endif } - (void) loadPlayer { +#ifndef GNUSTEP int result; NSArray *fileTypes = [NSArray arrayWithObject:@"oolite-save"]; NSOpenPanel *oPanel = [NSOpenPanel openPanel]; @@ -4099,6 +4103,7 @@ double scoopSoundPlayTime = 0.0; result = [oPanel runModalForDirectory:nil file:nil types:fileTypes]; if (result == NSOKButton) [self loadPlayerFromFile:[oPanel filename]]; +#endif } - (void) loadPlayerFromFile:(NSString *)fileToOpen @@ -4156,7 +4161,7 @@ double scoopSoundPlayTime = 0.0; else { NSLog(@"***** FILE LOADING ERROR!! *****"); - NSBeep(); + // NSBeep(); AppKit [[universe gameController] setPlayerFileToLoad:nil]; [universe game_over]; [universe clearPreviousMessage]; @@ -4580,6 +4585,7 @@ double scoopSoundPlayTime = 0.0; - (void) starChartDump { +#ifndef GNUSTEP NSString *filepath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent]; NSString *pathToPic = [filepath stringByAppendingPathComponent:[NSString stringWithFormat:@"StarChart-Galaxy-%03d.tiff",galaxy_number]]; BOOL dumpPic = (![[NSFileManager defaultManager] fileExistsAtPath:pathToPic]); @@ -4760,6 +4766,7 @@ double scoopSoundPlayTime = 0.0; [NSBezierPath setDefaultLineWidth:1.0]; } /* ends */ +#endif } diff --git a/src/Core/PlayerEntity_StickMapper.m b/src/Core/PlayerEntity_StickMapper.m index 4e3414f4..d6c8b62e 100644 --- a/src/Core/PlayerEntity_StickMapper.m +++ b/src/Core/PlayerEntity_StickMapper.m @@ -165,7 +165,7 @@ - (void) displayFunctionList: (GuiDisplayGen *)gui { int i; - [gui setColor: [NSColor greenColor] forRow: HEADINGROW]; + [gui setColor: [OOColor greenColor] forRow: HEADINGROW]; [gui setArray: [NSArray arrayWithObjects: @"Function", @"Assigned to", @"Type", nil] forRow: HEADINGROW]; diff --git a/src/Core/ResourceManager.h b/src/Core/ResourceManager.h index 5545e3a6..0f1d2ca0 100644 --- a/src/Core/ResourceManager.h +++ b/src/Core/ResourceManager.h @@ -81,7 +81,9 @@ BOOL always_include_addons; + (OOSound *) ooSoundNamed:(NSString *)filename inFolder:(NSString *)foldername; + (OOMusic *) ooMusicNamed:(NSString *)filename inFolder:(NSString *)foldername; +#ifndef GNUSTEP + (NSImage *) imageNamed:(NSString *)filename inFolder:(NSString *)foldername; +#endif + (NSString *) stringFromFilesNamed:(NSString *)filename inFolder:(NSString *)foldername; #ifdef GNUSTEP + (SDLImage *) surfaceNamed:(NSString *)filename inFolder:(NSString *)foldername; diff --git a/src/Core/ResourceManager.m b/src/Core/ResourceManager.m index 3bc724b9..46fe773b 100644 --- a/src/Core/ResourceManager.m +++ b/src/Core/ResourceManager.m @@ -227,7 +227,7 @@ NSMutableDictionary* surface_cache; else { NSString* version = (NSString *)[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]; - NSBeep(); + // NSBeep(); // AppKit if (!failed_parsing) { NSString* old_errors = errors; @@ -569,6 +569,7 @@ NSMutableDictionary* surface_cache; return result; } +#ifndef GNUSTEP + (NSImage *) imageNamed:(NSString *)filename inFolder:(NSString *)foldername { NSImage *result = nil; @@ -608,6 +609,7 @@ NSMutableDictionary* surface_cache; //NSLog(@"---> ResourceManager found %d file(s) with name '%@' (in folder '%@')", r, filename, foldername); return result; } +#endif + (NSString *) stringFromFilesNamed:(NSString *)filename inFolder:(NSString *)foldername { diff --git a/src/Core/Universe.m b/src/Core/Universe.m index 72830ee7..1d408059 100644 --- a/src/Core/Universe.m +++ b/src/Core/Universe.m @@ -4253,7 +4253,7 @@ GLfloat starboard_matrix[] = { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, if (!e1) { NSLog(@"ERROR ***** No entity set in Universe getSafeVectorFromEntity:toDistance:fromPoint:"); - NSBeep(); + // NSBeep(); // AppKit return make_vector( 0.0f, 0.0f, 0.0f); } Vector f1; @@ -7016,7 +7016,7 @@ NSComparisonResult comparePrice( id dict1, id dict2, void * context) if (!ship) { NSLog(@"ERROR ***** No ship set in Universe getSunSkimStartPositionForShip:"); - NSBeep(); + // NSBeep(); // AppKit return make_vector( 0.0f, 0.0f, 0.0f); } PlanetEntity* the_sun = [self sun]; @@ -7024,7 +7024,7 @@ NSComparisonResult comparePrice( id dict1, id dict2, void * context) if (!the_sun) { NSLog(@"ERROR ***** No sun set in Universe getSunSkimStartPositionForShip:"); - NSBeep(); + // NSBeep(); // AppKit return make_vector( 0.0f, 0.0f, 0.0f); } Vector v0 = the_sun->position; @@ -7047,14 +7047,14 @@ NSComparisonResult comparePrice( id dict1, id dict2, void * context) if (!ship) { NSLog(@"ERROR ***** No ship set in Universe getSunSkimEndPositionForShip:"); - NSBeep(); + // NSBeep(); // AppKit return make_vector( 0.0f, 0.0f, 0.0f); } // get vector from sun position to ship if (!the_sun) { NSLog(@"ERROR ***** No sun set in Universe getSunSkimEndPositionForShip:"); - NSBeep(); + // NSBeep(); // AppKit return make_vector( 0.0f, 0.0f, 0.0f); } Vector v0 = the_sun->position; diff --git a/src/SDL/main.m b/src/SDL/main.m index 961581de..6d3b675b 100644 --- a/src/SDL/main.m +++ b/src/SDL/main.m @@ -22,9 +22,6 @@ int main(int argc, char *argv[]) #ifdef GNUSTEP && !OOLITE_SDL_MAC int i; - // This is still necessary for NSFont calls. - [NSApplication sharedApplication]; - // Need this because we're not using the default run loop's autorelease // pool. NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];