From: Holger Schemel Date: Fri, 2 Apr 2010 20:08:52 +0000 (+0200) Subject: rnd-20100402-1-src X-Git-Tag: 3.3.0.0^2~13 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=59ee473b86e7cbc1d9b09a3c22b0bbd3a410f16f;p=rocksndiamonds.git rnd-20100402-1-src * added initial, experimental support for different screen sizes --- diff --git a/ChangeLog b/ChangeLog index 16909a52..7558d728 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2010-04-02 + * added initial, experimental support for different screen sizes + 2010-03-27 * added support for native Sokoban solution files in pure 'udlrUDLR' format with extension ".sln" instead of ".tape" for solution tapes @@ -25,10 +28,7 @@ static walls, not for in-game dynamically changing walls using CEs.) 2010-03-16 - * continued code cleanup of native Supaplex game engine - -2010-03-15 - * continued code cleanup of native Supaplex game engine + * finished code cleanup of native Supaplex game engine 2010-03-14 * started code cleanup of native Supaplex game engine diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 1282c695..87127ad1 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -6406,5 +6406,8 @@ struct ConfigInfo image_config[] = { "[player].sleeping_delay_fixed", "2000" }, { "[player].sleeping_delay_random", "2000" }, + { "global.screen.width", "672" }, + { "global.screen.height", "560" }, + { NULL, NULL } }; diff --git a/src/conf_var.c b/src/conf_var.c index 3edf500b..83a5e0d9 100644 --- a/src/conf_var.c +++ b/src/conf_var.c @@ -5092,6 +5092,14 @@ struct TokenIntPtrInfo image_config_vars[] = "[player].sleeping_delay_random", &game.player_sleeping_delay_random }, + { + "global.screen.width", + &global.screen.width + }, + { + "global.screen.height", + &global.screen.height + }, { NULL, NULL diff --git a/src/conftime.h b/src/conftime.h index 4b951c0d..636b81e7 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2010-03-31 10:44" +#define COMPILE_DATE_STRING "2010-04-02 22:02" diff --git a/src/editor.c b/src/editor.c index 9d5c42d2..6c20b638 100644 --- a/src/editor.c +++ b/src/editor.c @@ -2526,13 +2526,8 @@ static struct ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS, SX + ED_SCROLL_HORIZONTAL_XPOS, SY + ED_SCROLL_HORIZONTAL_YPOS, ED_SCROLL_HORIZONTAL_XSIZE, ED_SCROLL_HORIZONTAL_YSIZE, -#if 1 SX, SY, SXSIZE, SYSIZE, -#else - 0, 0, - SX + SXSIZE + SX, WIN_YSIZE, -#endif GD_TYPE_SCROLLBAR_HORIZONTAL, GADGET_ID_SCROLL_HORIZONTAL, "scroll level editing area horizontally" @@ -2541,13 +2536,8 @@ static struct ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS, SX + ED_SCROLL_VERTICAL_XPOS, SY + ED_SCROLL_VERTICAL_YPOS, ED_SCROLL_VERTICAL_XSIZE, ED_SCROLL_VERTICAL_YSIZE, -#if 1 SX, SY, SXSIZE, SYSIZE, -#else - 0, 0, - SX + SXSIZE + SX, WIN_YSIZE, -#endif GD_TYPE_SCROLLBAR_VERTICAL, GADGET_ID_SCROLL_VERTICAL, "scroll level editing area vertically" @@ -2556,13 +2546,8 @@ static struct ED_SCROLLBAR2_XPOS, ED_SCROLLBAR2_YPOS, DX + ED_SCROLL2_VERTICAL_XPOS, DY + ED_SCROLL2_VERTICAL_YPOS, ED_SCROLL2_VERTICAL_XSIZE, ED_SCROLL2_VERTICAL_YSIZE, -#if 1 DX, DY, DXSIZE, DYSIZE, -#else - SX + SXSIZE + SX, 0, - WIN_XSIZE - (SX + SXSIZE + SX), WIN_YSIZE, -#endif GD_TYPE_SCROLLBAR_VERTICAL, GADGET_ID_SCROLL_LIST_VERTICAL, "scroll element list vertically" @@ -5158,38 +5143,10 @@ static void DrawDrawingArea(int id) static void ScrollMiniLevel(int from_x, int from_y, int scroll) { -#if 0 - /* (directly solved in BlitBitmap() now) */ - static Bitmap *tmp_backbuffer = NULL; -#endif int x, y; int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0); int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0); -#if 0 - /* (directly solved in BlitBitmap() now) */ - if (tmp_backbuffer == NULL) - tmp_backbuffer = CreateBitmap(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH); - - /* needed when blitting directly to same bitmap -- should not be needed with - recent SDL libraries, but apparently does not work in 1.2.11 directly */ - BlitBitmap(drawto, tmp_backbuffer, - SX + (dx == -1 ? MINI_TILEX : 0), - SY + (dy == -1 ? MINI_TILEY : 0), - (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0), - (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0), - SX + (dx == +1 ? MINI_TILEX : 0), - SY + (dy == +1 ? MINI_TILEY : 0)); - BlitBitmap(tmp_backbuffer, drawto, - SX + (dx == +1 ? MINI_TILEX : 0), - SY + (dy == +1 ? MINI_TILEY : 0), - (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0), - (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0), - SX + (dx == +1 ? MINI_TILEX : 0), - SY + (dy == +1 ? MINI_TILEY : 0)); - -#else - BlitBitmap(drawto, drawto, SX + (dx == -1 ? MINI_TILEX : 0), SY + (dy == -1 ? MINI_TILEY : 0), @@ -5197,7 +5154,6 @@ static void ScrollMiniLevel(int from_x, int from_y, int scroll) (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0), SX + (dx == +1 ? MINI_TILEX : 0), SY + (dy == +1 ? MINI_TILEY : 0)); -#endif if (dx) { diff --git a/src/init.c b/src/init.c index 6d0b9501..89b4bc6a 100644 --- a/src/init.c +++ b/src/init.c @@ -39,7 +39,7 @@ #define CONFIG_TOKEN_GLOBAL_BUSY "global.busy" #define DEBUG_PRINT_INIT_TIMESTAMPS TRUE -#define DEBUG_PRINT_INIT_TIMESTAMPS_DEPTH 10 +#define DEBUG_PRINT_INIT_TIMESTAMPS_DEPTH 1 static struct FontBitmapInfo font_initial[NUM_INITIAL_FONTS]; @@ -186,20 +186,8 @@ void DrawInitAnim() } #endif -#if 0 - anim_initial.anim_mode = ANIM_LOOP; - anim_initial.anim_start_frame = 0; - anim_initial.offset_x = anim_initial.width; - anim_initial.offset_y = 0; -#endif - -#if 1 - x = ALIGNED_TEXT_XPOS(&init.busy); - y = ALIGNED_TEXT_YPOS(&init.busy); -#else - x = WIN_XSIZE / 2 - TILESIZE / 2; - y = WIN_YSIZE / 2 - TILESIZE / 2; -#endif + x = ALIGNED_TEXT_XPOS(&init_last.busy); + y = ALIGNED_TEXT_YPOS(&init_last.busy); graphic_info = &anim_initial; /* graphic == 0 => anim_initial */ @@ -5461,6 +5449,24 @@ static void InitMixer() StartMixer(); } +void InitGfxBuffers() +{ + ReCreateBitmap(&bitmap_db_cross, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH); + ReCreateBitmap(&bitmap_db_field, FXSIZE, FYSIZE, DEFAULT_DEPTH); + ReCreateBitmap(&bitmap_db_panel, DXSIZE, DYSIZE, DEFAULT_DEPTH); + ReCreateBitmap(&bitmap_db_door, 3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH); + ReCreateBitmap(&bitmap_db_toons, FULL_SXSIZE, FULL_SYSIZE, DEFAULT_DEPTH); + + /* initialize screen properties */ + InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE, + REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE, + bitmap_db_field); + InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE); + InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE); + InitGfxWindowInfo(WIN_XSIZE, WIN_YSIZE); + InitGfxScrollbufferInfo(FXSIZE, FYSIZE); +} + void InitGfx() { struct GraphicInfo *graphic_info_last = graphic_info; @@ -5507,6 +5513,9 @@ void InitGfx() if (filename_font_initial == NULL) /* should not happen */ Error(ERR_EXIT, "cannot get filename for '%s'", CONFIG_TOKEN_FONT_INITIAL); +#if 1 + InitGfxBuffers(); +#else /* create additional image buffers for double-buffering and cross-fading */ bitmap_db_cross = CreateBitmap(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH); bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH); @@ -5522,6 +5531,8 @@ void InitGfx() InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE); InitGfxWindowInfo(WIN_XSIZE, WIN_YSIZE); InitGfxScrollbufferInfo(FXSIZE, FYSIZE); +#endif + InitGfxCustomArtworkInfo(); bitmap_font_initial = LoadCustomImage(filename_font_initial); @@ -5635,6 +5646,9 @@ void InitGfx() InitMenuDesignSettings_Static(); InitGfxDrawBusyAnimFunction(DrawInitAnim); + + /* use copy of busy animation to prevent change while reloading artwork */ + init_last = init; #endif } @@ -6114,6 +6128,8 @@ void ReloadCustomArtwork(int force_reload) game_status = last_game_status; /* restore current game status */ + init_last = init; /* switch to new busy animation */ + #if 0 printf("::: ----------------DELAY 1 ...\n"); Delay(3000); diff --git a/src/init.h b/src/init.h index 4226241a..02985dd6 100644 --- a/src/init.h +++ b/src/init.h @@ -43,6 +43,8 @@ void RedrawBackground(); void KeyboardAutoRepeatOffUnlessAutoplay(); +void InitGfxBuffers(); + void OpenAll(void); void CloseAllAndExit(int); diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index f751fe85..4c484243 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -140,6 +140,13 @@ void SDLInitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window, fullscreen_xoffset = (fullscreen_width - video.width) / 2; fullscreen_yoffset = (fullscreen_height - video.height) / 2; +#if 1 + checked_free(video.fullscreen_modes); + + video.fullscreen_modes = NULL; + video.fullscreen_mode_current = NULL; +#endif + /* get available hardware supported fullscreen modes */ modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE); @@ -228,7 +235,11 @@ void SDLInitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window, should never be drawn to directly, it would do no harm nevertheless. */ /* create additional (symbolic) buffer for double-buffering */ +#if 1 + ReCreateBitmap(window, video.width, video.height, video.depth); +#else *window = CreateBitmap(video.width, video.height, video.depth); +#endif } boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen) @@ -241,6 +252,10 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen) if (*backbuffer == NULL) *backbuffer = CreateBitmapStruct(); + /* (real bitmap might be larger in fullscreen mode with video offsets) */ + (*backbuffer)->width = video.width; + (*backbuffer)->height = video.height; + if (fullscreen && !video.fullscreen_enabled && video.fullscreen_available) { setFullscreenParameters(setup.fullscreen_mode); @@ -292,11 +307,11 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen) (*backbuffer)->surface = new_surface; video.fullscreen_enabled = FALSE; + success = TRUE; } } - #if 1 SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); @@ -423,6 +438,17 @@ void SDLFadeRectangle(Bitmap *bitmap_cross, int x, int y, int width, int height, int dst_x = x, dst_y = y; unsigned int time_last, time_current; + /* check if screen size has changed */ + if (surface_source != NULL && (video.width != surface_source->w || + video.height != surface_source->h)) + { + SDL_FreeSurface(surface_source); + SDL_FreeSurface(surface_target); + SDL_FreeSurface(surface_black); + + initialization_needed = TRUE; + } + src_rect.x = src_x; src_rect.y = src_y; src_rect.w = width; diff --git a/src/libgame/system.c b/src/libgame/system.c index d4b7f9a9..8a5942da 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -166,8 +166,10 @@ void InitGfxFieldInfo(int sx, int sy, int sxsize, int sysize, gfx.field_save_buffer = field_save_buffer; +#if 0 gfx.background_bitmap = NULL; gfx.background_bitmap_mask = REDRAW_NONE; +#endif SetDrawDeactivationMask(REDRAW_NONE); /* do not deactivate drawing */ SetDrawBackgroundMask(REDRAW_NONE); /* deactivate masked drawing */ @@ -193,6 +195,12 @@ void InitGfxWindowInfo(int win_xsize, int win_ysize) { gfx.win_xsize = win_xsize; gfx.win_ysize = win_ysize; + +#if 1 + gfx.background_bitmap_mask = REDRAW_NONE; + + ReCreateBitmap(&gfx.background_bitmap, win_xsize, win_ysize, DEFAULT_DEPTH); +#endif } void InitGfxScrollbufferInfo(int scrollbuffer_width, int scrollbuffer_height) @@ -259,9 +267,11 @@ void SetBackgroundBitmap(Bitmap *background_bitmap_tile, int mask) else gfx.background_bitmap_mask &= ~mask; +#if 0 if (gfx.background_bitmap == NULL) gfx.background_bitmap = CreateBitmap(video.width, video.height, DEFAULT_DEPTH); +#endif if (background_bitmap_tile == NULL) /* empty background requested */ return; @@ -367,8 +377,10 @@ void InitVideoBuffer(int width, int height, int depth, boolean fullscreen) video.fullscreen_available = FULLSCREEN_STATUS; video.fullscreen_enabled = FALSE; - video.fullscreen_modes = NULL; +#if 0 video.fullscreen_mode_current = NULL; + video.fullscreen_modes = NULL; +#endif #if defined(TARGET_SDL) SDLInitVideoBuffer(&backbuffer, &window, fullscreen); @@ -379,34 +391,6 @@ void InitVideoBuffer(int width, int height, int depth, boolean fullscreen) drawto = backbuffer; } -Bitmap *CreateBitmapStruct(void) -{ -#if defined(TARGET_SDL) - return checked_calloc(sizeof(struct SDLSurfaceInfo)); -#else - return checked_calloc(sizeof(struct X11DrawableInfo)); -#endif -} - -Bitmap *CreateBitmap(int width, int height, int depth) -{ - Bitmap *new_bitmap = CreateBitmapStruct(); - int real_width = MAX(1, width); /* prevent zero bitmap width */ - int real_height = MAX(1, height); /* prevent zero bitmap height */ - int real_depth = GetRealDepth(depth); - -#if defined(TARGET_SDL) - SDLCreateBitmapContent(new_bitmap, real_width, real_height, real_depth); -#else - X11CreateBitmapContent(new_bitmap, real_width, real_height, real_depth); -#endif - - new_bitmap->width = real_width; - new_bitmap->height = real_height; - - return new_bitmap; -} - inline static void FreeBitmapPointers(Bitmap *bitmap) { if (bitmap == NULL) @@ -443,16 +427,53 @@ void FreeBitmap(Bitmap *bitmap) free(bitmap); } -void CloseWindow(DrawWindow *window) +Bitmap *CreateBitmapStruct(void) { -#if defined(TARGET_X11) - if (window->drawable) +#if defined(TARGET_SDL) + return checked_calloc(sizeof(struct SDLSurfaceInfo)); +#else + return checked_calloc(sizeof(struct X11DrawableInfo)); +#endif +} + +Bitmap *CreateBitmap(int width, int height, int depth) +{ + Bitmap *new_bitmap = CreateBitmapStruct(); + int real_width = MAX(1, width); /* prevent zero bitmap width */ + int real_height = MAX(1, height); /* prevent zero bitmap height */ + int real_depth = GetRealDepth(depth); + +#if defined(TARGET_SDL) + SDLCreateBitmapContent(new_bitmap, real_width, real_height, real_depth); +#else + X11CreateBitmapContent(new_bitmap, real_width, real_height, real_depth); +#endif + + new_bitmap->width = real_width; + new_bitmap->height = real_height; + + return new_bitmap; +} + +void ReCreateBitmap(Bitmap **bitmap, int width, int height, int depth) +{ + Bitmap *new_bitmap = CreateBitmap(width, height, depth); + + if (*bitmap == NULL) { - XUnmapWindow(display, window->drawable); - XDestroyWindow(display, window->drawable); + *bitmap = new_bitmap; } - if (window->gc) - XFreeGC(display, window->gc); + else + { + TransferBitmapPointers(new_bitmap, *bitmap); + free(new_bitmap); + } +} + +void CloseWindow(DrawWindow *window) +{ +#if defined(TARGET_X11) + X11CloseWindow(window); #endif } @@ -498,6 +519,25 @@ void BlitBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap, if (DrawingDeactivated(dst_x, dst_y, width, height)) return; +#if 1 + /* skip if rectangle starts outside bitmap */ + if (src_x >= src_bitmap->width || + src_y >= src_bitmap->height || + dst_x >= dst_bitmap->width || + dst_y >= dst_bitmap->height) + return; + + /* clip if rectangle overlaps bitmap */ + if (src_x + width > src_bitmap->width) + width = src_bitmap->width - src_x; + if (src_y + height > src_bitmap->height) + height = src_bitmap->height - src_y; + if (dst_x + width > dst_bitmap->width) + width = dst_bitmap->width - dst_x; + if (dst_y + height > dst_bitmap->height) + height = dst_bitmap->height - dst_y; +#endif + #if 0 /* !!! 2009-03-30: Fixed by using self-compiled, patched SDL.dll !!! */ /* (This bug still exists in the actual (as of 2009-06-15) version 1.2.13, @@ -574,6 +614,19 @@ void FillRectangle(Bitmap *bitmap, int x, int y, int width, int height, if (DrawingDeactivated(x, y, width, height)) return; +#if 1 + /* skip if rectangle starts outside bitmap */ + if (x >= bitmap->width || + y >= bitmap->height) + return; + + /* clip if rectangle overlaps bitmap */ + if (x + width > bitmap->width) + width = bitmap->width - x; + if (y + height > bitmap->height) + height = bitmap->height - y; +#endif + sysFillRectangle(bitmap, x, y, width, height, color); } diff --git a/src/libgame/system.h b/src/libgame/system.h index 75668281..d35505b5 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -1192,6 +1192,7 @@ void CloseVideoDisplay(void); void InitVideoBuffer(int, int, int, boolean); Bitmap *CreateBitmapStruct(void); Bitmap *CreateBitmap(int, int, int); +void ReCreateBitmap(Bitmap **, int, int, int); void FreeBitmap(Bitmap *); void BlitBitmap(Bitmap *, Bitmap *, int, int, int, int, int, int); void FadeRectangle(Bitmap *bitmap, int, int, int, int, int, int, int, diff --git a/src/libgame/x11.c b/src/libgame/x11.c index fe022c5b..f95c3da9 100644 --- a/src/libgame/x11.c +++ b/src/libgame/x11.c @@ -40,13 +40,21 @@ void X11InitVideoDisplay(void) void X11InitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window) { + if (*window != NULL) + X11CloseWindow(*window); + *window = X11InitWindow(); XMapWindow(display, (*window)->drawable); + FlushDisplay(); /* create additional (off-screen) buffer for double-buffering */ +#if 1 + ReCreateBitmap(backbuffer, video.width, video.height, video.depth); +#else *backbuffer = CreateBitmap(video.width, video.height, video.depth); +#endif } static void X11InitDisplay() @@ -129,6 +137,9 @@ static DrawWindow *X11InitWindow() win_xpos = (screen_width - width) / 2; win_ypos = (screen_height - height) / 2; + new_window->width = width; + new_window->height = height; + new_window->drawable = XCreateSimpleWindow(display, RootWindow(display, screen), win_xpos, win_ypos, @@ -227,6 +238,20 @@ static DrawWindow *X11InitWindow() return new_window; } +void X11CloseWindow(DrawWindow *window) +{ + if (window->drawable) + { + XUnmapWindow(display, window->drawable); + XDestroyWindow(display, window->drawable); + } + + if (window->gc) + XFreeGC(display, window->gc); + + free(window); +} + void X11ZoomBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap) { #if defined(TARGET_ALLEGRO) diff --git a/src/libgame/x11.h b/src/libgame/x11.h index 2ebaf86c..9f2efee8 100644 --- a/src/libgame/x11.h +++ b/src/libgame/x11.h @@ -333,6 +333,8 @@ struct MouseCursorInfo void X11InitVideoDisplay(void); void X11InitVideoBuffer(DrawBuffer **, DrawWindow **); +void X11CloseWindow(DrawWindow *); + void X11ZoomBitmap(Bitmap *, Bitmap *); Bitmap *X11LoadImage(char *); diff --git a/src/main.c b/src/main.c index 5ad230da..02e49257 100644 --- a/src/main.c +++ b/src/main.c @@ -84,6 +84,9 @@ int ActiveFont[NUM_FONTS]; int lev_fieldx, lev_fieldy; int scroll_x, scroll_y; +int WIN_XSIZE = 672; +int WIN_YSIZE = 560; + int FX = SX, FY = SY; int ScrollStepSize; int ScreenMovDir = MV_NONE, ScreenMovPos = 0; @@ -120,7 +123,7 @@ struct TitleMessageInfo titlemessage_initial[MAX_NUM_TITLE_MESSAGES]; struct TitleMessageInfo titlemessage_default; struct TitleMessageInfo titlemessage[MAX_NUM_TITLE_MESSAGES]; struct TitleMessageInfo readme; -struct InitInfo init; +struct InitInfo init, init_last; struct MenuInfo menu; struct DoorInfo door_1, door_2; struct PreviewInfo preview; diff --git a/src/main.h b/src/main.h index 640a4fc9..8632855a 100644 --- a/src/main.h +++ b/src/main.h @@ -43,8 +43,10 @@ #define SND_UNDEFINED (-1) #define MUS_UNDEFINED (-1) +#if 0 #define WIN_XSIZE 672 #define WIN_YSIZE 560 +#endif #define DEFAULT_FULLSCREEN_MODE "800x600" @@ -2446,6 +2448,8 @@ struct GlobalInfo int fading_status; int fading_type; #endif + + struct Rect screen; }; struct ElementChangeInfo @@ -2843,6 +2847,8 @@ extern int ActiveFont[NUM_FONTS]; extern int lev_fieldx, lev_fieldy; extern int scroll_x, scroll_y; +extern int WIN_XSIZE, WIN_YSIZE; + extern int FX, FY; extern int ScrollStepSize; extern int ScreenMovDir, ScreenMovPos, ScreenGfxPos; @@ -2878,7 +2884,7 @@ extern struct TitleMessageInfo titlemessage_initial[]; extern struct TitleMessageInfo titlemessage_default; extern struct TitleMessageInfo titlemessage[]; extern struct TitleMessageInfo readme; -extern struct InitInfo init; +extern struct InitInfo init, init_last; extern struct MenuInfo menu; extern struct DoorInfo door_1, door_2; extern struct PreviewInfo preview; diff --git a/src/screens.c b/src/screens.c index 87f4a3e0..9fbd5b1b 100644 --- a/src/screens.c +++ b/src/screens.c @@ -1266,6 +1266,8 @@ void DrawMainMenuExt(int fade_mask, boolean do_fading) /* store valid level series information */ leveldir_last_valid = leveldir_current; + init_last = init; /* switch to new busy animation */ + /* needed if last screen (level choice) changed graphics, sounds or music */ ReloadCustomArtwork(0); @@ -1283,6 +1285,11 @@ void DrawMainMenuExt(int fade_mask, boolean do_fading) #endif #endif +#if 1 + /* needed if newly loaded custom artwork requires a different screen mode */ + ChangeScreenModeIfNeeded(); +#endif + #if defined(TARGET_SDL) SetDrawtoField(DRAW_BACKBUFFER); #endif diff --git a/src/tools.c b/src/tools.c index 970dfb6d..ef618691 100644 --- a/src/tools.c +++ b/src/tools.c @@ -14,6 +14,7 @@ #include "libgame/libgame.h" #include "tools.h" +#include "init.h" #include "game.h" #include "events.h" #include "cartoons.h" @@ -8045,30 +8046,16 @@ void ToggleFullscreenIfNeeded() if (!video.fullscreen_available) return; -#if 1 if (change_fullscreen || change_fullscreen_mode) -#else - if (setup.fullscreen != video.fullscreen_enabled || - setup.fullscreen_mode != video.fullscreen_mode_current) -#endif { Bitmap *tmp_backbuffer = CreateBitmap(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH); /* save backbuffer content which gets lost when toggling fullscreen mode */ BlitBitmap(backbuffer, tmp_backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0); -#if 1 if (change_fullscreen_mode) -#else - if (setup.fullscreen && video.fullscreen_enabled) -#endif { /* keep fullscreen, but change fullscreen mode (screen resolution) */ -#if 1 - /* (this is now set in sdl.c) */ -#else - video.fullscreen_mode_current = setup.fullscreen_mode; -#endif video.fullscreen_enabled = FALSE; /* force new fullscreen mode */ } @@ -8090,3 +8077,23 @@ void ToggleFullscreenIfNeeded() #endif } } + +void ChangeScreenModeIfNeeded() +{ + if (global.screen.width == WIN_XSIZE && + global.screen.height == WIN_YSIZE) + return; + + WIN_XSIZE = global.screen.width; + WIN_YSIZE = global.screen.height; + + InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen); + InitGfxBuffers(); + +#if 1 + SetDrawDeactivationMask(REDRAW_NONE); + SetDrawBackgroundMask(REDRAW_FIELD); + + // RedrawBackground(); +#endif +} diff --git a/src/tools.h b/src/tools.h index dccbe10b..2ae83cfe 100644 --- a/src/tools.h +++ b/src/tools.h @@ -215,5 +215,6 @@ void PlaySoundActivating(); void PlaySoundSelecting(); void ToggleFullscreenIfNeeded(); +void ChangeScreenModeIfNeeded(); #endif /* TOOLS_H */