X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=eee87022ee3146e7e37a903467f5a88f41fec398;hb=1101077a226b09854650662759bf12caf7c84f8d;hp=2ddbbcd5769c56c30cadc67d8092fc3fefb3f9f2;hpb=fe158e864d3fa4b0221e9c88d8dfff0157051396;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index 2ddbbcd5..eee87022 100644 --- a/src/init.c +++ b/src/init.c @@ -23,6 +23,8 @@ #include "files.h" #include "network.h" #include "netserv.h" +#include "cartoons.h" +#include "config.h" static char *image_filename[NUM_PICTURES] = { @@ -38,13 +40,13 @@ static char *image_filename[NUM_PICTURES] = "RocksFont3.pcx" }; -static void InitPlayerInfo(void); static void InitSetup(void); +static void InitPlayerInfo(void); static void InitLevelInfo(void); +static void InitArtworkInfo(void); static void InitNetworkServer(void); static void InitSound(void); static void InitGfx(void); -static void InitCustomGraphics(void); static void InitGfxBackground(void); static void InitGadgets(void); static void InitElementProperties(void); @@ -62,13 +64,14 @@ void OpenAll(void) } InitProgramInfo(UNIX_USERDATA_DIRECTORY, - PROGRAM_TITLE_STRING, WINDOW_TITLE_STRING, + PROGRAM_TITLE_STRING, getWindowTitleString(), ICON_TITLE_STRING, X11_ICON_FILENAME, X11_ICONMASK_FILENAME, MSDOS_POINTER_FILENAME, COOKIE_PREFIX, FILENAME_PREFIX, GAME_VERSION_ACTUAL); InitSetup(); InitPlayerInfo(); + InitArtworkInfo(); /* needed before loading gfx, sound & music */ InitCounter(); InitSound(); @@ -87,9 +90,9 @@ void OpenAll(void) InitLevelInfo(); InitGadgets(); /* needs to know number of level series */ - InitCustomGraphics(); - InitGfxBackground(); + InitToons(); + DrawMainMenu(); InitNetworkServer(); @@ -120,6 +123,11 @@ void InitLevelInfo() LoadLevelSetup_SeriesInfo(); /* last played level info */ } +void InitArtworkInfo() +{ + LoadArtworkInfo(); +} + void InitNetworkServer() { #if defined(PLATFORM_UNIX) @@ -149,19 +157,12 @@ void InitSound() OpenAudio(); - for(i=0; iclip_mask, - clip_gc_valuemask, &clip_gc_values); - clip_gc_values.graphics_exposures = False; clip_gc_valuemask = GCGraphicsExposures; tile_clip_gc = @@ -260,11 +254,19 @@ void InitTileClipmasks() clip_gc_values.clip_mask = pix[i]->clip_mask; clip_gc_valuemask = GCGraphicsExposures | GCClipMask; pix[i]->stored_clip_gc = XCreateGC(display, window->drawable, - clip_gc_valuemask,&clip_gc_values); + clip_gc_valuemask, &clip_gc_values); } } #if defined(TARGET_X11_NATIVE) + + /* create graphic context structures needed for clipping */ + clip_gc_values.graphics_exposures = False; + clip_gc_valuemask = GCGraphicsExposures; + copy_clipmask_gc = + XCreateGC(display, pix[PIX_BACK]->clip_mask, + clip_gc_valuemask, &clip_gc_values); + /* create only those clipping Pixmaps we really need */ for(i=0; tile_needs_clipping[i].start>=0; i++) { @@ -288,10 +290,42 @@ void InitTileClipmasks() src_x, src_y, TILEX, TILEY, 0, 0); } } + + XFreeGC(display, copy_clipmask_gc); + #endif /* TARGET_X11_NATIVE */ #endif /* TARGET_X11 */ } +void FreeTileClipmasks() +{ +#if defined(TARGET_X11) + int i; + + for(i=0; istored_clip_gc) + { + XFreeGC(display, pix[i]->stored_clip_gc); + pix[i]->stored_clip_gc = None; + } + } +#endif /* TARGET_X11 */ +} + void InitGfx() { int i; @@ -339,66 +373,61 @@ void InitGfx() InitTileClipmasks(); } -void LoadCustomGraphics() +void InitGfxBackground() { -#if 0 - int i; + int x, y; - for(i=0; i/graphics */ - filename = getPath2(getUserDataDir(), GRAPHICS_DIRECTORY); - if (access(dir, F_OK) == 0) + if (artwork.graphics_set_current != artwork.gfx_current->name) { - } + int i; + ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE); + for(i=0; iuser_defined ? - getUserLevelDir("") : - options.level_directory), - leveldir_current->fullpath, - basename); - - + SetDoorState(DOOR_OPEN_1 | DOOR_CLOSE_2); - filename = getPath3((leveldir_current->user_defined ? - getUserLevelDir("") : - options.level_directory), - leveldir_current->fullpath, - basename); -#endif -} + artwork.graphics_set_current = artwork.gfx_current->name; + } -void InitGfxBackground() -{ - int x, y; + if (artwork.sounds_set_current != artwork.snd_current->name) + { + InitReloadSounds(artwork.snd_current->name); - drawto = backbuffer; - fieldbuffer = pix[PIX_DB_FIELD]; - SetDrawtoField(DRAW_BACKBUFFER); + artwork.sounds_set_current = artwork.snd_current->name; + } - BlitBitmap(pix[PIX_BACK], backbuffer, 0,0, WIN_XSIZE,WIN_YSIZE, 0,0); - ClearRectangle(backbuffer, REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE); - ClearRectangle(pix[PIX_DB_DOOR], 0,0, 3*DXSIZE,DYSIZE+VYSIZE); + if (artwork.music_set_current != artwork.mus_current->name) + { + InitReloadMusic(artwork.mus_current->name); - for(x=0; xname; + } } void InitGadgets() @@ -1564,9 +1593,11 @@ void CloseAllAndExit(int exit_value) int i; StopSounds(); - FreeSounds(NUM_SOUNDS); CloseAudio(); + FreeAllSounds(); + FreeAllMusic(); + FreeTileClipmasks(); for(i=0; i