From c60c1e73539c95cb314eefb2ea7473f13520062d Mon Sep 17 00:00:00 2001 From: Franck Charlet Date: Mon, 16 Mar 2009 17:19:40 +0000 Subject: [PATCH] - Modified Initialisation_du_programme() so 0 is returned on SDL initialization fail. - Added support for .png files in Mac OS X port. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@677 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- Grafx2.xcodeproj/project.pbxproj | 18 ++++++++++++ Grafx2.xcodeproj/xx.pbxuser | 4 +-- Grafx2.xcodeproj/xx.perspective | 47 +++++++++++++++++++------------- loadsave.c | 4 --- main.c | 20 +++++++++++--- 5 files changed, 64 insertions(+), 29 deletions(-) diff --git a/Grafx2.xcodeproj/project.pbxproj b/Grafx2.xcodeproj/project.pbxproj index 6af167b5..8b96b815 100644 --- a/Grafx2.xcodeproj/project.pbxproj +++ b/Grafx2.xcodeproj/project.pbxproj @@ -57,6 +57,7 @@ F5B19C3D0EA4DC91003F4BA4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = F5B19C3B0EA4DC91003F4BA4 /* InfoPlist.strings */; }; F5B1EE850EAD0F4E00B087B5 /* gfx2def.ini in Resources */ = {isa = PBXBuildFile; fileRef = F5B1EE840EAD0F4E00B087B5 /* gfx2def.ini */; }; F5B1EE850EAD0F4E00B087B6 /* gfx2gui.gif in Resources */ = {isa = PBXBuildFile; fileRef = F5B1EE840EAD0F4E00B087B6 /* gfx2gui.gif */; }; + F5CDCE320F6EA6D600B31F63 /* pxdouble.c in Sources */ = {isa = PBXBuildFile; fileRef = F5CDCE310F6EA6D600B31F63 /* pxdouble.c */; }; F5DCE2BC0EA5116A0065B0EF /* SDL_ttf in Copy Frameworks into .app bundle */ = {isa = PBXBuildFile; fileRef = F5DCE2BE0EA5118F0065B0EF /* SDL_ttf */; }; F5DCE2BC0EA5116B0065B0EF /* SDL_image in Copy Frameworks into .app bundle */ = {isa = PBXBuildFile; fileRef = F5DCE2BB0EA5116B0065B0EF /* SDL_image */; }; F5DCE2BE0EA5118E0065B0EF /* SDL in Copy Frameworks into .app bundle */ = {isa = PBXBuildFile; fileRef = F5DCE2BD0EA5118E0065B0EF /* SDL */; }; @@ -172,6 +173,7 @@ F5B19C3C0EA4DC91003F4BA4 /* English */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; F5B1EE840EAD0F4E00B087B5 /* gfx2def.ini */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = gfx2def.ini; sourceTree = ""; }; F5B1EE840EAD0F4E00B087B6 /* gfx2gui.gif */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = gfx2gui.gif; sourceTree = ""; }; + F5CDCE310F6EA6D600B31F63 /* pxdouble.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = pxdouble.c; sourceTree = ""; }; F5DCE2BB0EA5116B0065B0EF /* SDL_image */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = SDL_image; path = /Library/Frameworks/SDL_image.framework/Versions/A/SDL_image; sourceTree = ""; }; F5DCE2BD0EA5118E0065B0EF /* SDL */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = SDL; path = /Library/Frameworks/SDL.framework/Versions/A/SDL; sourceTree = ""; }; F5DCE2BE0EA5118F0065B0EF /* SDL_ttf */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = SDL_ttf; path = /Library/Frameworks/SDL_ttf.framework/Versions/A/SDL_ttf; sourceTree = ""; }; @@ -233,6 +235,7 @@ 29B97314FDCFA39411CA2CEA /* Grafx2 */ = { isa = PBXGroup; children = ( + F5CDCE310F6EA6D600B31F63 /* pxdouble.c */, F5AC28B90F4873C700455509 /* hotkeys.c */, F5AC28BA0F4873C700455509 /* input.c */, F5AC28BB0F4873C700455509 /* realpath.c */, @@ -412,6 +415,7 @@ F5AC28BC0F4873C700455509 /* hotkeys.c in Sources */, F5AC28BD0F4873C700455509 /* input.c in Sources */, F5AC28BE0F4873C700455509 /* realpath.c in Sources */, + F5CDCE320F6EA6D600B31F63 /* pxdouble.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -523,11 +527,18 @@ "$(HOME)/Library/Frameworks/SDL.framework/Headers", /Library/Frameworks/SDL.framework/Headers, /Library/SDL_ttf.framework/Headers, + /usr/local/include, "$(HEADER_SEARCH_PATHS)", ); + LIBRARY_SEARCH_PATHS = /usr/local/lib; + OTHER_LDFLAGS = ( + "-lpng", + "-lz", + ); PREBINDING = NO; PRELINK_LIBS = SDL_Image; SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = static; ZERO_LINK = YES; }; name = Debug; @@ -549,11 +560,18 @@ HEADER_SEARCH_PATHS = ( "$(HOME)/Library/Frameworks/SDL.framework/Headers", /Library/Frameworks/SDL.framework/Headers, + /usr/local/include, "$(HEADER_SEARCH_PATHS)", ); + LIBRARY_SEARCH_PATHS = /usr/local/lib; + OTHER_LDFLAGS = ( + "-lpng", + "-lz", + ); PREBINDING = NO; PRELINK_LIBS = SDL_Image; SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = static; }; name = Release; }; diff --git a/Grafx2.xcodeproj/xx.pbxuser b/Grafx2.xcodeproj/xx.pbxuser index f0ecd21a..ac8a7053 100644 --- a/Grafx2.xcodeproj/xx.pbxuser +++ b/Grafx2.xcodeproj/xx.pbxuser @@ -165,8 +165,8 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 256409268; - PBXWorkspaceStateSaveDate = 256409268; + PBXPerProjectTemplateStateSaveDate = 258909867; + PBXWorkspaceStateSaveDate = 258909867; }; sourceControlManager = F5B19B690EA4BD79003F4BA4 /* Source Control */; userBuildSettings = { diff --git a/Grafx2.xcodeproj/xx.perspective b/Grafx2.xcodeproj/xx.perspective index a529bbe6..8aca1e3d 100644 --- a/Grafx2.xcodeproj/xx.perspective +++ b/Grafx2.xcodeproj/xx.perspective @@ -454,7 +454,7 @@ PBXSmartGroupTreeModuleColumnWidthsKey - 252 + 418 PBXSmartGroupTreeModuleColumnsKey_v4 @@ -464,7 +464,12 @@ PBXSmartGroupTreeModuleOutlineStateKey_v7 PBXSmartGroupTreeModuleOutlineStateExpansionKey - + + 29B97314FDCFA39411CA2CEA + 080E96DDFE201D6D7F000001 + 29B97315FDCFA39411CA2CEA + 29B97317FDCFA39411CA2CEA + PBXSmartGroupTreeModuleOutlineStateSelectionKey @@ -472,7 +477,7 @@ PBXSmartGroupTreeModuleOutlineStateVisibleRectKey - {{0, 0}, {252, 575}} + {{0, 0}, {418, 598}} PBXTopSmartGroupGIDs @@ -482,19 +487,19 @@ GeometryConfiguration Frame - {{0, 0}, {269, 593}} + {{0, 0}, {435, 616}} GroupTreeTableConfiguration MainColumn - 252 + 418 RubberWindowFrame - 40 86 970 634 0 0 1024 746 + 146 -297 1487 657 0 0 1024 746 Module PBXSmartGroupTreeModule Proportion - 269pt + 435pt Dock @@ -526,9 +531,9 @@ GeometryConfiguration Frame - {{0, 0}, {696, 0}} + {{0, 0}, {1047, 0}} RubberWindowFrame - 40 86 970 634 0 0 1024 746 + 146 -297 1487 657 0 0 1024 746 Module PBXNavigatorGroup @@ -537,12 +542,16 @@ Proportion - 588pt + 611pt Tabs + BecomeActive + ContentConfiguration + PBXBuildLogShowsTranscriptDefaultKey + {{0, 107}, {1047, 477}} PBXProjectModuleGUID XCMainBuildResultsModuleGUID PBXProjectModuleLabel @@ -555,9 +564,9 @@ GeometryConfiguration Frame - {{10, 27}, {696, 561}} + {{10, 27}, {1047, 584}} RubberWindowFrame - 40 86 970 634 0 0 1024 746 + 146 -297 1487 657 0 0 1024 746 Module PBXBuildResultsModule @@ -610,7 +619,7 @@ GeometryConfiguration Frame - {{0, 0}, {0, 0}} + {{10, 27}, {902, 597}} Module PBXRunSessionModule @@ -619,7 +628,7 @@ Proportion - 696pt + 1047pt Name @@ -637,14 +646,14 @@ TableOfContents - F5D646030F487ECB007E515F + F5CDCE430F6EB68600B31F63 1CA23EE50692099D00951B8B - F5D646040F487ECB007E515F + F5CDCE440F6EB68600B31F63 F5A33EC20EC89C3000F8052D - F5D646050F487ECB007E515F + F5CDCE450F6EB68600B31F63 XCMainBuildResultsModuleGUID 1CA23EE80692099D00951B8B - F5D646060F487ECB007E515F + F5CDCE460F6EB68600B31F63 ToolbarConfiguration xcode.toolbar.config.buildAndRun @@ -818,7 +827,7 @@ /Users/xx/Grafx2/Grafx2.xcodeproj WindowString - 40 86 970 634 0 0 1024 746 + 146 -297 1487 657 0 0 1024 746 WindowTools diff --git a/loadsave.c b/loadsave.c index f63962e8..39121142 100644 --- a/loadsave.c +++ b/loadsave.c @@ -22,10 +22,6 @@ */ #define _XOPEN_SOURCE -#if defined(__macosx__) -#define __no_pnglib__ -#endif - #include #include #include diff --git a/main.c b/main.c index dfa9044a..5e641d21 100644 --- a/main.c +++ b/main.c @@ -282,7 +282,8 @@ void Analyse_de_la_ligne_de_commande(int argc,char * argv[]) } // ------------------------ Initialiser le programme ------------------------- -void Initialisation_du_programme(int argc,char * argv[]) +// Returns 0 on fail +int Initialisation_du_programme(int argc,char * argv[]) { int Temp; int Mode_dans_lequel_on_demarre; @@ -369,9 +370,16 @@ void Initialisation_du_programme(int argc,char * argv[]) Brouillon_Loupe_Decalage_X=0; Brouillon_Loupe_Decalage_Y=0; - // SDL + SDL_putenv("SDL_VIDEO_WINDOW_POS=center"); + SDL_putenv("SDL_VIDEO_CENTERED=1"); - SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO|SDL_INIT_JOYSTICK); + // SDL + if(SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0) + { + // The program can't continue without that anyway + printf("Couldn't initialize SDL.\n"); + return(0); + } joystick = SDL_JoystickOpen(0); SDL_EnableKeyRepeat(250, 32); SDL_EnableUNICODE(SDL_ENABLE); @@ -597,6 +605,7 @@ void Initialisation_du_programme(int argc,char * argv[]) Brosse_Hauteur=1; Capturer_brosse(0,0,0,0,0); *Brosse=CM_Blanc; + return(1); } // ------------------------- Fermeture du programme -------------------------- @@ -645,7 +654,10 @@ int main(int argc,char * argv[]) char Nom_du_fichier_Phoenix[TAILLE_CHEMIN_FICHIER]; char Nom_du_fichier_Phoenix2[TAILLE_CHEMIN_FICHIER]; - Initialisation_du_programme(argc,argv); + if(!Initialisation_du_programme(argc,argv)) + { + return 0; + } // Test de recuperation de fichiers sauvés strcpy(Nom_du_fichier_Phoenix,Repertoire_de_configuration);