From 4179dabc517f32c163c5d2c9aec2e15c57225d42 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Fri, 16 Apr 2010 12:03:17 +0200 Subject: [PATCH] rnd-20100416-1-src --- src/conf_gfx.c | 42 ++++++++++++---------- src/conf_var.c | 96 +++++++++++++++++++++++++++++++------------------- src/conftime.h | 2 +- src/files.c | 40 +++++++++++++++++++++ src/main.h | 23 +++++------- src/tools.c | 75 ++++++++++++--------------------------- 6 files changed, 155 insertions(+), 123 deletions(-) diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 156d4855..b5156490 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -6408,24 +6408,30 @@ struct ConfigInfo image_config[] = { "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" }, + { "viewport.playfield.width", "17" }, + { "viewport.playfield.height", "17" }, + { "viewport.playfield.MAIN.width", ARG_DEFAULT }, + { "viewport.playfield.MAIN.height", ARG_DEFAULT }, + { "viewport.playfield.PLAYING.width", ARG_DEFAULT }, + { "viewport.playfield.PLAYING.height", ARG_DEFAULT }, + { "viewport.playfield.EDITOR.width", ARG_DEFAULT }, + { "viewport.playfield.EDITOR.height", ARG_DEFAULT }, + { "viewport.door_1.x", "566" }, + { "viewport.door_1.y", "60" }, + { "viewport.door_1.MAIN.x", ARG_DEFAULT }, + { "viewport.door_1.MAIN.y", ARG_DEFAULT }, + { "viewport.door_1.PLAYING.x", ARG_DEFAULT }, + { "viewport.door_1.PLAYING.y", ARG_DEFAULT }, + { "viewport.door_1.EDITOR.x", ARG_DEFAULT }, + { "viewport.door_1.EDITOR.y", ARG_DEFAULT }, + { "viewport.door_2.x", "566" }, + { "viewport.door_2.y", "400" }, + { "viewport.door_2.MAIN.x", ARG_DEFAULT }, + { "viewport.door_2.MAIN.y", ARG_DEFAULT }, + { "viewport.door_2.PLAYING.x", ARG_DEFAULT }, + { "viewport.door_2.PLAYING.y", ARG_DEFAULT }, + { "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 0f2cd01c..4593e424 100644 --- a/src/conf_var.c +++ b/src/conf_var.c @@ -5101,76 +5101,100 @@ struct TokenIntPtrInfo image_config_vars[] = &viewport.window.height }, { - "viewport.playfield.menu.width", - &viewport.playfield.menu.width + "viewport.playfield.width", + &viewport.playfield[GFX_SPECIAL_ARG_DEFAULT].width }, { - "viewport.playfield.menu.height", - &viewport.playfield.menu.height + "viewport.playfield.height", + &viewport.playfield[GFX_SPECIAL_ARG_DEFAULT].height }, { - "viewport.playfield.game.width", - &viewport.playfield.game.width + "viewport.playfield.MAIN.width", + &viewport.playfield[GFX_SPECIAL_ARG_MAIN].width }, { - "viewport.playfield.game.height", - &viewport.playfield.game.height + "viewport.playfield.MAIN.height", + &viewport.playfield[GFX_SPECIAL_ARG_MAIN].height }, { - "viewport.playfield.editor.width", - &viewport.playfield.editor.width + "viewport.playfield.PLAYING.width", + &viewport.playfield[GFX_SPECIAL_ARG_PLAYING].width }, { - "viewport.playfield.editor.height", - &viewport.playfield.editor.height + "viewport.playfield.PLAYING.height", + &viewport.playfield[GFX_SPECIAL_ARG_PLAYING].height }, { - "viewport.door_1.menu.x", - &viewport.door_1.menu.x + "viewport.playfield.EDITOR.width", + &viewport.playfield[GFX_SPECIAL_ARG_EDITOR].width }, { - "viewport.door_1.menu.y", - &viewport.door_1.menu.y + "viewport.playfield.EDITOR.height", + &viewport.playfield[GFX_SPECIAL_ARG_EDITOR].height }, { - "viewport.door_1.game.x", - &viewport.door_1.game.x + "viewport.door_1.x", + &viewport.door_1[GFX_SPECIAL_ARG_DEFAULT].x }, { - "viewport.door_1.game.y", - &viewport.door_1.game.y + "viewport.door_1.y", + &viewport.door_1[GFX_SPECIAL_ARG_DEFAULT].y }, { - "viewport.door_1.editor.x", - &viewport.door_1.editor.x + "viewport.door_1.MAIN.x", + &viewport.door_1[GFX_SPECIAL_ARG_MAIN].x }, { - "viewport.door_1.editor.y", - &viewport.door_1.editor.y + "viewport.door_1.MAIN.y", + &viewport.door_1[GFX_SPECIAL_ARG_MAIN].y }, { - "viewport.door_2.menu.x", - &viewport.door_2.menu.x + "viewport.door_1.PLAYING.x", + &viewport.door_1[GFX_SPECIAL_ARG_PLAYING].x }, { - "viewport.door_2.menu.y", - &viewport.door_2.menu.y + "viewport.door_1.PLAYING.y", + &viewport.door_1[GFX_SPECIAL_ARG_PLAYING].y }, { - "viewport.door_2.game.x", - &viewport.door_2.game.x + "viewport.door_1.EDITOR.x", + &viewport.door_1[GFX_SPECIAL_ARG_EDITOR].x }, { - "viewport.door_2.game.y", - &viewport.door_2.game.y + "viewport.door_1.EDITOR.y", + &viewport.door_1[GFX_SPECIAL_ARG_EDITOR].y }, { - "viewport.door_2.editor.x", - &viewport.door_2.editor.x + "viewport.door_2.x", + &viewport.door_2[GFX_SPECIAL_ARG_DEFAULT].x }, { - "viewport.door_2.editor.y", - &viewport.door_2.editor.y + "viewport.door_2.y", + &viewport.door_2[GFX_SPECIAL_ARG_DEFAULT].y + }, + { + "viewport.door_2.MAIN.x", + &viewport.door_2[GFX_SPECIAL_ARG_MAIN].x + }, + { + "viewport.door_2.MAIN.y", + &viewport.door_2[GFX_SPECIAL_ARG_MAIN].y + }, + { + "viewport.door_2.PLAYING.x", + &viewport.door_2[GFX_SPECIAL_ARG_PLAYING].x + }, + { + "viewport.door_2.PLAYING.y", + &viewport.door_2[GFX_SPECIAL_ARG_PLAYING].y + }, + { + "viewport.door_2.EDITOR.x", + &viewport.door_2[GFX_SPECIAL_ARG_EDITOR].x + }, + { + "viewport.door_2.EDITOR.y", + &viewport.door_2[GFX_SPECIAL_ARG_EDITOR].y }, { NULL, diff --git a/src/conftime.h b/src/conftime.h index 15df429d..d918a3cb 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2010-04-07 23:40" +#define COMPILE_DATE_STRING "2010-04-16 11:49" diff --git a/src/files.c b/src/files.c index 91e597b1..9f92ad68 100644 --- a/src/files.c +++ b/src/files.c @@ -9807,6 +9807,15 @@ static void InitMenuDesignSettings_SpecialPreProcessing() menu.enter_screen[i] = menu.enter_screen[GFX_SPECIAL_ARG_DEFAULT]; menu.leave_screen[i] = menu.leave_screen[GFX_SPECIAL_ARG_DEFAULT]; } + + /* special case: initialize "ARG_DEFAULT" values in static default config */ + /* (eg, init "viewport.door_1.MAIN.xyz" from "viewport.door_1.xyz") */ + for (i = 0; i < NUM_SPECIAL_GFX_ARGS; i++) + { + viewport.playfield[i] = viewport.playfield[GFX_SPECIAL_ARG_DEFAULT]; + viewport.door_1[i] = viewport.door_1[GFX_SPECIAL_ARG_DEFAULT]; + viewport.door_2[i] = viewport.door_2[GFX_SPECIAL_ARG_DEFAULT]; + } } static void InitMenuDesignSettings_SpecialPostProcessing() @@ -9944,6 +9953,37 @@ static void LoadMenuDesignSettingsFromFilename(char *filename) value_6); } + /* special case: initialize with default values that may be overwritten */ + /* (eg, init "viewport.door_1.MAIN.xyz" from "viewport.door_1.xyz") */ + for (i = 0; i < NUM_SPECIAL_GFX_ARGS; i++) + { + char *token_1 = "viewport.playfield.width"; + char *token_2 = "viewport.playfield.height"; + char *token_3 = "viewport.door_1.x"; + char *token_4 = "viewport.door_1.y"; + char *token_5 = "viewport.door_2.x"; + char *token_6 = "viewport.door_2.y"; + char *value_1 = getHashEntry(setup_file_hash, token_1); + char *value_2 = getHashEntry(setup_file_hash, token_2); + char *value_3 = getHashEntry(setup_file_hash, token_3); + char *value_4 = getHashEntry(setup_file_hash, token_4); + char *value_5 = getHashEntry(setup_file_hash, token_5); + char *value_6 = getHashEntry(setup_file_hash, token_6); + + if (value_1 != NULL) + viewport.playfield[i].width = get_token_parameter_value(token_1,value_1); + if (value_2 != NULL) + viewport.playfield[i].height = get_token_parameter_value(token_2,value_2); + if (value_3 != NULL) + viewport.door_1[i].x = get_token_parameter_value(token_3, value_3); + if (value_4 != NULL) + viewport.door_1[i].y = get_token_parameter_value(token_4, value_4); + if (value_5 != NULL) + viewport.door_2[i].x = get_token_parameter_value(token_5, value_5); + if (value_6 != NULL) + viewport.door_2[i].y = get_token_parameter_value(token_6, value_6); + } + /* special case: initialize with default values that may be overwritten */ /* (e.g., init "titlemessage_1.fade_mode" from "[titlemessage].fade_mode") */ for (i = 0; titlemessage_arrays[i].array != NULL; i++) diff --git a/src/main.h b/src/main.h index 09306600..4268c901 100644 --- a/src/main.h +++ b/src/main.h @@ -2257,6 +2257,14 @@ struct PreviewInfo int anim_mode; }; +struct ViewportInfo +{ + struct Rect window; + struct Rect playfield[NUM_SPECIAL_GFX_ARGS]; + struct Rect door_1[NUM_SPECIAL_GFX_ARGS]; + struct Rect door_2[NUM_SPECIAL_GFX_ARGS]; +}; + struct HiScore { char Name[MAX_PLAYER_NAME_LEN + 1]; @@ -2454,21 +2462,6 @@ struct GlobalInfo #endif }; -struct SubViewportInfo -{ - struct Rect menu; - struct Rect game; - struct Rect editor; -}; - -struct ViewportInfo -{ - struct Rect window; - struct SubViewportInfo playfield; - struct SubViewportInfo door_1; - struct SubViewportInfo door_2; -}; - struct ElementChangeInfo { boolean can_change; /* use or ignore this change info */ diff --git a/src/tools.c b/src/tools.c index 30df9f7c..2ec7c9ee 100644 --- a/src/tools.c +++ b/src/tools.c @@ -8088,6 +8088,14 @@ void ToggleFullscreenIfNeeded() void ChangeViewportPropertiesIfNeeded() { + int *door_1_x = &DX; + int *door_1_y = &DY; + int *door_2_x = (game_status == GAME_MODE_EDITOR ? &EX : &VX); + int *door_2_y = (game_status == GAME_MODE_EDITOR ? &EY : &VY); + int gfx_game_mode = (game_status == GAME_MODE_PLAYING || + game_status == GAME_MODE_EDITOR ? game_status : + GAME_MODE_MAIN); + if (viewport.window.width != WIN_XSIZE || viewport.window.height != WIN_YSIZE) { @@ -8105,64 +8113,25 @@ void ChangeViewportPropertiesIfNeeded() #endif } - if (game_status == GAME_MODE_PLAYING) + if (viewport.playfield[gfx_game_mode].width != SCR_FIELDX || + viewport.playfield[gfx_game_mode].height != SCR_FIELDY || + viewport.door_1[gfx_game_mode].x != *door_1_x || + viewport.door_1[gfx_game_mode].y != *door_1_y || + viewport.door_2[gfx_game_mode].x != *door_2_x || + viewport.door_2[gfx_game_mode].y != *door_2_y) { - 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; + SCR_FIELDX = viewport.playfield[gfx_game_mode].width; + SCR_FIELDY = viewport.playfield[gfx_game_mode].height; - 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; + *door_1_x = viewport.door_1[gfx_game_mode].x; + *door_1_y = viewport.door_1[gfx_game_mode].y; + *door_2_x = viewport.door_2[gfx_game_mode].x; + *door_2_y = viewport.door_2[gfx_game_mode].y; - 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(); - 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) + if (gfx_game_mode == GAME_MODE_MAIN) { - 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(); } -- 2.34.1