From 5cdf02eb2a6d9627f7461ab9d386698cb7596096 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 7 Apr 2010 23:47:50 +0200 Subject: [PATCH] rnd-20100407-1-src * added initial, experimental support for different viewport properties (with "viewports" being menu/playfield area and doors; currently the size of the menu/playfield area and door positions can be redefined) --- ChangeLog | 7 ++- src/conf_gfx.c | 22 +++++++++- src/conf_var.c | 80 ++++++++++++++++++++++++++++++++-- src/conftime.h | 2 +- src/editor.c | 116 ++++++++++++++++++++++++++++++++++++++++++++++++- src/game.c | 5 +++ src/init.h | 1 + src/main.c | 17 +++++++- src/main.h | 28 +++++++++++- src/screens.c | 38 +++++++++++++++- src/tools.c | 95 +++++++++++++++++++++++++++++++++++----- src/tools.h | 2 +- 12 files changed, 386 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7558d728..285539ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ +2010-04-07 + * added initial, experimental support for different viewport properties + (with "viewports" being menu/playfield area and doors; currently the + size of the menu/playfield area and door positions can be redefined) + 2010-04-02 - * added initial, experimental support for different screen sizes + * added initial, experimental support for different window sizes 2010-03-27 * added support for native Sokoban solution files in pure 'udlrUDLR' diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 87127ad1..156d4855 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -6406,8 +6406,26 @@ struct ConfigInfo image_config[] = { "[player].sleeping_delay_fixed", "2000" }, { "[player].sleeping_delay_random", "2000" }, - { "global.screen.width", "672" }, - { "global.screen.height", "560" }, + { "viewport.window.width", "672" }, + { "viewport.window.height", "560" }, + { "viewport.playfield.menu.width", "17" }, + { "viewport.playfield.menu.height", "17" }, + { "viewport.playfield.game.width", "17" }, + { "viewport.playfield.game.height", "17" }, + { "viewport.playfield.editor.width", "17" }, + { "viewport.playfield.editor.height", "17" }, + { "viewport.door_1.menu.x", "566" }, + { "viewport.door_1.menu.y", "60" }, + { "viewport.door_1.game.x", "566" }, + { "viewport.door_1.game.y", "60" }, + { "viewport.door_1.editor.x", "566" }, + { "viewport.door_1.editor.y", "60" }, + { "viewport.door_2.menu.x", "566" }, + { "viewport.door_2.menu.y", "400" }, + { "viewport.door_2.game.x", "566" }, + { "viewport.door_2.game.y", "400" }, + { "viewport.door_2.editor.x", "566" }, + { "viewport.door_2.editor.y", "356" }, { NULL, NULL } }; diff --git a/src/conf_var.c b/src/conf_var.c index 83a5e0d9..0f2cd01c 100644 --- a/src/conf_var.c +++ b/src/conf_var.c @@ -5093,12 +5093,84 @@ struct TokenIntPtrInfo image_config_vars[] = &game.player_sleeping_delay_random }, { - "global.screen.width", - &global.screen.width + "viewport.window.width", + &viewport.window.width }, { - "global.screen.height", - &global.screen.height + "viewport.window.height", + &viewport.window.height + }, + { + "viewport.playfield.menu.width", + &viewport.playfield.menu.width + }, + { + "viewport.playfield.menu.height", + &viewport.playfield.menu.height + }, + { + "viewport.playfield.game.width", + &viewport.playfield.game.width + }, + { + "viewport.playfield.game.height", + &viewport.playfield.game.height + }, + { + "viewport.playfield.editor.width", + &viewport.playfield.editor.width + }, + { + "viewport.playfield.editor.height", + &viewport.playfield.editor.height + }, + { + "viewport.door_1.menu.x", + &viewport.door_1.menu.x + }, + { + "viewport.door_1.menu.y", + &viewport.door_1.menu.y + }, + { + "viewport.door_1.game.x", + &viewport.door_1.game.x + }, + { + "viewport.door_1.game.y", + &viewport.door_1.game.y + }, + { + "viewport.door_1.editor.x", + &viewport.door_1.editor.x + }, + { + "viewport.door_1.editor.y", + &viewport.door_1.editor.y + }, + { + "viewport.door_2.menu.x", + &viewport.door_2.menu.x + }, + { + "viewport.door_2.menu.y", + &viewport.door_2.menu.y + }, + { + "viewport.door_2.game.x", + &viewport.door_2.game.x + }, + { + "viewport.door_2.game.y", + &viewport.door_2.game.y + }, + { + "viewport.door_2.editor.x", + &viewport.door_2.editor.x + }, + { + "viewport.door_2.editor.y", + &viewport.door_2.editor.y }, { NULL, diff --git a/src/conftime.h b/src/conftime.h index 636b81e7..15df429d 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2010-04-02 22:02" +#define COMPILE_DATE_STRING "2010-04-07 23:40" diff --git a/src/editor.c b/src/editor.c index 6c20b638..83df2e15 100644 --- a/src/editor.c +++ b/src/editor.c @@ -1047,7 +1047,11 @@ static struct /* ---------- current level number --------------------------------------- */ { +#if 1 + -1, -1, /* these values are not constant, but can change at runtime */ +#else DX + 5 - SX, DY + 3 - SY, +#endif 1, 100, GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP, GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE, @@ -2474,25 +2478,41 @@ static struct { { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 0 * ED_SCROLLBUTTON_YSIZE, +#if 1 + -1, -1, /* these values are not constant, but can change at runtime */ +#else ED_SCROLL_UP_XPOS, ED_SCROLL_UP_YPOS, +#endif GADGET_ID_SCROLL_UP, "scroll level editing area up" }, { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 1 * ED_SCROLLBUTTON_YSIZE, +#if 1 + -1, -1, /* these values are not constant, but can change at runtime */ +#else ED_SCROLL_DOWN_XPOS, ED_SCROLL_DOWN_YPOS, +#endif GADGET_ID_SCROLL_DOWN, "scroll level editing area down" }, { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 2 * ED_SCROLLBUTTON_YSIZE, +#if 1 + -1, -1, /* these values are not constant, but can change at runtime */ +#else ED_SCROLL_LEFT_XPOS, ED_SCROLL_LEFT_YPOS, +#endif GADGET_ID_SCROLL_LEFT, "scroll level editing area left" }, { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 3 * ED_SCROLLBUTTON_YSIZE, +#if 1 + -1, -1, /* these values are not constant, but can change at runtime */ +#else ED_SCROLL_RIGHT_XPOS, ED_SCROLL_RIGHT_YPOS, +#endif GADGET_ID_SCROLL_RIGHT, "scroll level editing area right" }, @@ -2524,29 +2544,49 @@ static struct { { ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS, +#if 1 + -1, -1, /* these values are not constant, but can change at runtime */ + -1, -1, /* these values are not constant, but can change at runtime */ + -1, -1, /* these values are not constant, but can change at runtime */ + -1, -1, /* these values are not constant, but can change at runtime */ +#else SX + ED_SCROLL_HORIZONTAL_XPOS, SY + ED_SCROLL_HORIZONTAL_YPOS, ED_SCROLL_HORIZONTAL_XSIZE, ED_SCROLL_HORIZONTAL_YSIZE, SX, SY, SXSIZE, SYSIZE, +#endif GD_TYPE_SCROLLBAR_HORIZONTAL, GADGET_ID_SCROLL_HORIZONTAL, "scroll level editing area horizontally" }, { ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS, +#if 1 + -1, -1, /* these values are not constant, but can change at runtime */ + -1, -1, /* these values are not constant, but can change at runtime */ + -1, -1, /* these values are not constant, but can change at runtime */ + -1, -1, /* these values are not constant, but can change at runtime */ +#else SX + ED_SCROLL_VERTICAL_XPOS, SY + ED_SCROLL_VERTICAL_YPOS, ED_SCROLL_VERTICAL_XSIZE, ED_SCROLL_VERTICAL_YSIZE, SX, SY, SXSIZE, SYSIZE, +#endif GD_TYPE_SCROLLBAR_VERTICAL, GADGET_ID_SCROLL_VERTICAL, "scroll level editing area vertically" }, { ED_SCROLLBAR2_XPOS, ED_SCROLLBAR2_YPOS, +#if 1 + -1, -1, /* these values are not constant, but can change at runtime */ + ED_SCROLL2_VERTICAL_XSIZE, ED_SCROLL2_VERTICAL_YSIZE, + -1, -1, /* these values are not constant, but can change at runtime */ +#else DX + ED_SCROLL2_VERTICAL_XPOS, DY + ED_SCROLL2_VERTICAL_YPOS, ED_SCROLL2_VERTICAL_XSIZE, ED_SCROLL2_VERTICAL_YSIZE, DX, DY, +#endif DXSIZE, DYSIZE, GD_TYPE_SCROLLBAR_VERTICAL, GADGET_ID_SCROLL_LIST_VERTICAL, @@ -2992,7 +3032,12 @@ static struct { 0, 0, GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE, - NULL, MAX_ED_FIELDX, MAX_ED_FIELDY, + NULL, +#if 1 + -1, -1, /* these values are not constant, but can change at runtime */ +#else + MAX_ED_FIELDX, MAX_ED_FIELDY, +#endif NULL, NULL, NULL, NULL }, @@ -3254,7 +3299,11 @@ static struct */ /* actual size of level editor drawing area */ +#if 1 +static int ed_fieldx, ed_fieldy; +#else static int ed_fieldx = MAX_ED_FIELDX - 1, ed_fieldy = MAX_ED_FIELDY - 1; +#endif /* actual position of level editor drawing area in level playfield */ static int level_xpos = -1, level_ypos = -1; @@ -5311,6 +5360,16 @@ static void CreateControlButtons() level_editor_gadget[id] = gi; } + /* these values are not constant, but can change at runtime */ + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS; + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS; + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS; + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS; + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS; + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS; + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS; + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS; + /* create buttons for scrolling of drawing area and element list */ for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++) { @@ -5426,6 +5485,10 @@ static void CreateCounterButtons() int max_infotext_len = getMaxInfoTextLength(); int i; + /* these values are not constant, but can change at runtime */ + counterbutton_info[ED_COUNTER_ID_SELECT_LEVEL].x = DX + 5 - SX; + counterbutton_info[ED_COUNTER_ID_SELECT_LEVEL].y = DY + 3 - SY; + for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++) { int j; @@ -5580,6 +5643,10 @@ static void CreateDrawingAreas() { int i; + /* these values are not constant, but can change at runtime */ + drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX; + drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY; + for (i = 0; i < ED_NUM_DRAWING_AREAS; i++) { struct GadgetInfo *gi; @@ -5947,6 +6014,40 @@ static void CreateScrollbarGadgets() { int i; + /* these values are not constant, but can change at runtime */ + scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x = + SX + ED_SCROLL_HORIZONTAL_XPOS; + scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y = + SY + ED_SCROLL_HORIZONTAL_YPOS; + scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width = + ED_SCROLL_HORIZONTAL_XSIZE; + scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height = + ED_SCROLL_HORIZONTAL_YSIZE; + scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX; + scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY; + scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE; + scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE; + + scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].x = + SX + ED_SCROLL_VERTICAL_XPOS; + scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].y = + SY + ED_SCROLL_VERTICAL_YPOS; + scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].width = + ED_SCROLL_VERTICAL_XSIZE; + scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].height = + ED_SCROLL_VERTICAL_YSIZE; + scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX; + scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY; + scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE; + scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE; + + scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].x = + DX + ED_SCROLL2_VERTICAL_XPOS; + scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].y = + DY + ED_SCROLL2_VERTICAL_YPOS; + scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = DX; + scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = DY; + for (i = 0; i < ED_NUM_SCROLLBARS; i++) { int id = scrollbar_info[i].gadget_id; @@ -6149,6 +6250,10 @@ void CreateLevelEditorGadgets() /* setting 'game_status' is needed to get the right fonts for the editor */ game_status = GAME_MODE_EDITOR; + /* these values are not constant, but can change at runtime */ + ed_fieldx = MAX_ED_FIELDX - 1; + ed_fieldy = MAX_ED_FIELDY - 1; + ReinitializeElementList(); CreateControlButtons(); @@ -7342,6 +7447,11 @@ void DrawLevelEd() redraw_mask |= REDRAW_ALL; +#if 1 + FreeLevelEditorGadgets(); + CreateLevelEditorGadgets(); +#endif + ReinitializeElementList(); /* update dynamic level element list */ ReinitializeElementListButtons(); /* custom element may look different */ @@ -10005,7 +10115,11 @@ static void SelectArea(int from_x, int from_y, int to_x, int to_y, static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y, int button, int mode) { +#if 1 + static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +#else static short brush_buffer[MAX_ED_FIELDX][MAX_ED_FIELDY]; +#endif static int brush_width, brush_height; static int last_cursor_x = -1, last_cursor_y = -1; static boolean delete_old_brush; diff --git a/src/game.c b/src/game.c index 556c22b2..e671dbe4 100644 --- a/src/game.c +++ b/src/game.c @@ -3720,6 +3720,11 @@ void InitGame() game_status = GAME_MODE_PLAYING; +#if 1 + /* needed if different viewport properties defined for playing */ + ChangeViewportPropertiesIfNeeded(); +#endif + InitGameEngine(); InitGameControlValues(); diff --git a/src/init.h b/src/init.h index 02985dd6..42bc9f74 100644 --- a/src/init.h +++ b/src/init.h @@ -44,6 +44,7 @@ void RedrawBackground(); void KeyboardAutoRepeatOffUnlessAutoplay(); void InitGfxBuffers(); +void InitGadgets(); void OpenAll(void); void CloseAllAndExit(int); diff --git a/src/main.c b/src/main.c index 02e49257..aab51a38 100644 --- a/src/main.c +++ b/src/main.c @@ -39,7 +39,11 @@ SDL_Thread *server_thread; int key_joystick_mapping = 0; +#if 1 +boolean redraw[MAX_LEV_FIELDX + 2][MAX_LEV_FIELDY + 2]; +#else boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; +#endif int redraw_x1 = 0, redraw_y1 = 0; short Feld[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; @@ -84,8 +88,11 @@ int ActiveFont[NUM_FONTS]; int lev_fieldx, lev_fieldy; int scroll_x, scroll_y; -int WIN_XSIZE = 672; -int WIN_YSIZE = 560; +int WIN_XSIZE = 672, WIN_YSIZE = 560; +int SCR_FIELDX = 17, SCR_FIELDY = 17; +int DX = 566, DY = 60; +int VX = 566, VY = 400; +int EX = 566, EY = 356; int FX = SX, FY = SY; int ScrollStepSize; @@ -94,8 +101,13 @@ int ScreenGfxPos = 0; int BorderElement = EL_STEELWALL; int GameFrameDelay = GAME_FRAME_DELAY; int FfwdFrameDelay = FFWD_FRAME_DELAY; +#if 1 +int BX1, BY1; +int BX2, BY2; +#else int BX1 = 0, BY1 = 0; int BX2 = SCR_FIELDX - 1, BY2 = SCR_FIELDY - 1; +#endif int SBX_Left, SBX_Right; int SBY_Upper, SBY_Lower; int ZX, ZY; @@ -115,6 +127,7 @@ struct SetupInfo setup; struct GameInfo game; struct GlobalInfo global; struct BorderInfo border; +struct ViewportInfo viewport; struct TitleFadingInfo fading; struct TitleFadingInfo title_initial_default; struct TitleFadingInfo title_default; diff --git a/src/main.h b/src/main.h index 8632855a..09306600 100644 --- a/src/main.h +++ b/src/main.h @@ -50,8 +50,10 @@ #define DEFAULT_FULLSCREEN_MODE "800x600" +#if 0 #define SCR_FIELDX 17 #define SCR_FIELDY 17 +#endif #define MAX_BUF_XSIZE (SCR_FIELDX + 2) #define MAX_BUF_YSIZE (SCR_FIELDY + 2) #define MIN_LEV_FIELDX 3 @@ -949,12 +951,14 @@ #define SY 8 #define REAL_SX (SX - 2) #define REAL_SY (SY - 2) +#if 0 #define DX 566 #define DY 60 #define VX DX #define VY 400 #define EX DX #define EY (VY - 44) +#endif #define TILESIZE 32 #define TILEX TILESIZE #define TILEY TILESIZE @@ -2448,8 +2452,21 @@ struct GlobalInfo int fading_status; int fading_type; #endif +}; + +struct SubViewportInfo +{ + struct Rect menu; + struct Rect game; + struct Rect editor; +}; - struct Rect screen; +struct ViewportInfo +{ + struct Rect window; + struct SubViewportInfo playfield; + struct SubViewportInfo door_1; + struct SubViewportInfo door_2; }; struct ElementChangeInfo @@ -2802,7 +2819,11 @@ extern SDL_Thread *server_thread; extern int key_joystick_mapping; +#if 1 +extern boolean redraw[MAX_LEV_FIELDX + 2][MAX_LEV_FIELDY + 2]; +#else extern boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; +#endif extern int redraw_x1, redraw_y1; extern short Feld[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; @@ -2848,6 +2869,10 @@ extern int lev_fieldx, lev_fieldy; extern int scroll_x, scroll_y; extern int WIN_XSIZE, WIN_YSIZE; +extern int SCR_FIELDX, SCR_FIELDY; +extern int DX, DY; +extern int VX, VY; +extern int EX, EY; extern int FX, FY; extern int ScrollStepSize; @@ -2875,6 +2900,7 @@ extern struct HiScore highscore[]; extern struct TapeInfo tape; extern struct GlobalInfo global; extern struct BorderInfo border; +extern struct ViewportInfo viewport; extern struct TitleFadingInfo fading; extern struct TitleFadingInfo fading_none; extern struct TitleFadingInfo title_initial_default; diff --git a/src/screens.c b/src/screens.c index 9fbd5b1b..94f0824e 100644 --- a/src/screens.c +++ b/src/screens.c @@ -1025,7 +1025,11 @@ static boolean insideTextPosRect(struct TextPosInfo *rect, int x, int y) static void drawCursorExt(int xpos, int ypos, boolean active, int graphic) { +#if 1 + static int cursor_array[MAX_LEV_FIELDY]; +#else static int cursor_array[SCR_FIELDY]; +#endif int x = mSX + TILEX * xpos; int y = mSY + TILEY * (MENU_SCREEN_START_YPOS + ypos); @@ -1286,8 +1290,8 @@ void DrawMainMenuExt(int fade_mask, boolean do_fading) #endif #if 1 - /* needed if newly loaded custom artwork requires a different screen mode */ - ChangeScreenModeIfNeeded(); + /* needed if different viewport properties defined for menues */ + ChangeViewportPropertiesIfNeeded(); #endif #if defined(TARGET_SDL) @@ -1777,6 +1781,11 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) FadeSetEnterScreen(); +#if 1 + /* needed if different viewport properties defined for editor */ + ChangeViewportPropertiesIfNeeded(); +#endif + DrawLevelEd(); } else if (pos == MAIN_CONTROL_INFO) @@ -5673,13 +5682,21 @@ static struct { { IMG_MENU_BUTTON_UP, IMG_MENU_BUTTON_UP_ACTIVE, +#if 1 + -1, -1, /* these values are not constant, but can change at runtime */ +#else SC_SCROLL_UP_XPOS, SC_SCROLL_UP_YPOS, +#endif SCREEN_CTRL_ID_SCROLL_UP, "scroll up" }, { IMG_MENU_BUTTON_DOWN, IMG_MENU_BUTTON_DOWN_ACTIVE, +#if 1 + -1, -1, /* these values are not constant, but can change at runtime */ +#else SC_SCROLL_DOWN_XPOS, SC_SCROLL_DOWN_YPOS, +#endif SCREEN_CTRL_ID_SCROLL_DOWN, "scroll down" } @@ -5705,8 +5722,13 @@ static struct #else IMG_MENU_SCROLLBAR, IMG_MENU_SCROLLBAR_ACTIVE, #endif +#if 1 + -1, -1, /* these values are not constant, but can change at runtime */ + -1, -1, /* these values are not constant, but can change at runtime */ +#else SC_SCROLL_VERTICAL_XPOS, SC_SCROLL_VERTICAL_YPOS, SC_SCROLL_VERTICAL_XSIZE, SC_SCROLL_VERTICAL_YSIZE, +#endif GD_TYPE_SCROLLBAR_VERTICAL, SCREEN_CTRL_ID_SCROLL_VERTICAL, "scroll level series vertically" @@ -5772,6 +5794,12 @@ static void CreateScreenScrollbuttons() unsigned long event_mask; int i; + /* these values are not constant, but can change at runtime */ + scrollbutton_info[0].x = SC_SCROLL_UP_XPOS; + scrollbutton_info[0].y = SC_SCROLL_UP_YPOS; + scrollbutton_info[1].x = SC_SCROLL_DOWN_XPOS; + scrollbutton_info[1].y = SC_SCROLL_DOWN_YPOS; + for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++) { Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed; @@ -5827,6 +5855,12 @@ static void CreateScreenScrollbars() { int i; + /* these values are not constant, but can change at runtime */ + scrollbar_info[0].x = SC_SCROLL_VERTICAL_XPOS; + scrollbar_info[0].y = SC_SCROLL_VERTICAL_YPOS; + scrollbar_info[0].width = SC_SCROLL_VERTICAL_XSIZE; + scrollbar_info[0].height = SC_SCROLL_VERTICAL_YSIZE; + for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++) { Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed; diff --git a/src/tools.c b/src/tools.c index ef618691..30df9f7c 100644 --- a/src/tools.c +++ b/src/tools.c @@ -349,6 +349,10 @@ void BackToFront() if (redraw_mask & REDRAW_FIELD) { +#if 0 + printf("::: REDRAW_FIELD\n"); +#endif + if (game_status != GAME_MODE_PLAYING || redraw_mask & REDRAW_FROM_BACKBUFFER) { @@ -431,6 +435,10 @@ void BackToFront() if (redraw_mask & REDRAW_TILES) { +#if 0 + printf("::: REDRAW_TILES\n"); +#endif + for (x = 0; x < SCR_FIELDX; x++) for (y = 0 ; y < SCR_FIELDY; y++) if (redraw[redraw_x1 + x][redraw_y1 + y]) @@ -8078,22 +8086,85 @@ void ToggleFullscreenIfNeeded() } } -void ChangeScreenModeIfNeeded() +void ChangeViewportPropertiesIfNeeded() { - if (global.screen.width == WIN_XSIZE && - global.screen.height == WIN_YSIZE) - return; - - WIN_XSIZE = global.screen.width; - WIN_YSIZE = global.screen.height; + if (viewport.window.width != WIN_XSIZE || + viewport.window.height != WIN_YSIZE) + { + WIN_XSIZE = viewport.window.width; + WIN_YSIZE = viewport.window.height; - InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen); - InitGfxBuffers(); + InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen); + InitGfxBuffers(); #if 1 - SetDrawDeactivationMask(REDRAW_NONE); - SetDrawBackgroundMask(REDRAW_FIELD); + SetDrawDeactivationMask(REDRAW_NONE); + SetDrawBackgroundMask(REDRAW_FIELD); - // RedrawBackground(); + // RedrawBackground(); #endif + } + + if (game_status == GAME_MODE_PLAYING) + { + if (viewport.playfield.game.width != SCR_FIELDX || + viewport.playfield.game.height != SCR_FIELDY || + viewport.door_1.game.x != DX || + viewport.door_1.game.y != DY || + viewport.door_2.game.x != VX || + viewport.door_2.game.y != VY) + { + SCR_FIELDX = viewport.playfield.game.width; + SCR_FIELDY = viewport.playfield.game.height; + + DX = viewport.door_1.game.x; + DY = viewport.door_1.game.y; + VX = viewport.door_2.game.x; + VY = viewport.door_2.game.y; + + InitGfxBuffers(); + } + } + else if (game_status == GAME_MODE_EDITOR) + { + if (viewport.playfield.editor.width != SCR_FIELDX || + viewport.playfield.editor.height != SCR_FIELDY || + viewport.door_1.editor.x != DX || + viewport.door_1.editor.y != DY || + viewport.door_2.editor.x != EX || + viewport.door_2.editor.y != EY) + { + SCR_FIELDX = viewport.playfield.editor.width; + SCR_FIELDY = viewport.playfield.editor.height; + + DX = viewport.door_1.editor.x; + DY = viewport.door_1.editor.y; + EX = viewport.door_2.editor.x; + EY = viewport.door_2.editor.y; + + InitGfxBuffers(); + } + } + else /* any menu screen */ + { + if (viewport.playfield.menu.width != SCR_FIELDX || + viewport.playfield.menu.height != SCR_FIELDY || + viewport.door_1.menu.x != DX || + viewport.door_1.menu.y != DY || + viewport.door_2.menu.x != VX || + viewport.door_2.menu.y != VY) + { + SCR_FIELDX = viewport.playfield.menu.width; + SCR_FIELDY = viewport.playfield.menu.height; + + DX = viewport.door_1.menu.x; + DY = viewport.door_1.menu.y; + VX = viewport.door_2.menu.x; + VY = viewport.door_2.menu.y; + + InitGfxBuffers(); + InitGadgets(); + InitToons(); + } + } } diff --git a/src/tools.h b/src/tools.h index 2ae83cfe..0fd7aa7e 100644 --- a/src/tools.h +++ b/src/tools.h @@ -215,6 +215,6 @@ void PlaySoundActivating(); void PlaySoundSelecting(); void ToggleFullscreenIfNeeded(); -void ChangeScreenModeIfNeeded(); +void ChangeViewportPropertiesIfNeeded(); #endif /* TOOLS_H */ -- 2.34.1