From 6f20c46794de2b6e936f9f9ea46f893a059ffd47 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 27 Jan 2014 22:17:08 +0100 Subject: [PATCH] rnd-20140127-1-src * fixed problems with window scaling and updating related setup value * added setup option to select anti-aliasing quality of scaled windows --- ChangeLog | 4 + src/conf_gfx.c | 10 ++ src/conf_gfx.h | 23 ++-- src/conf_snd.c | 3 + src/conf_snd.h | 64 +++++----- src/conf_var.c | 4 + src/conftime.h | 2 +- src/files.c | 41 ++++--- src/init.c | 2 +- src/libgame/sdl.c | 29 ++++- src/libgame/sdl.h | 1 + src/libgame/system.h | 9 ++ src/screens.c | 279 ++++++++++++++++++++++++++++++------------- src/tools.c | 75 ++++++++---- 14 files changed, 374 insertions(+), 172 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7d65e26f..7e353343 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-01-27 + * fixed problems with window scaling and updating related setup value + * added setup option to select anti-aliasing quality of scaled windows + 2014-01-17 * improved speed of displaying progress when loading levels and artwork * changed fullscreen and window scaling changes in setup menu to have diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 61fa003a..76333abd 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -5287,6 +5287,14 @@ struct ConfigInfo image_config[] = { "background.envelope_4.anim_mode", "default" }, { "background.envelope_4.draw_masked", "false" }, + { "background.request", "RocksScreen.png" }, + { "background.request.x", "562" }, + { "background.request.y", "56" }, + { "background.request.width", "108" }, + { "background.request.height", "288" }, + { "background.request.anim_mode", "default" }, + { "background.request.draw_masked", "false" }, + { "titlescreen_initial_1", UNDEFINED_FILENAME }, { "titlescreen_initial_2", UNDEFINED_FILENAME }, { "titlescreen_initial_3", UNDEFINED_FILENAME }, @@ -6717,6 +6725,8 @@ struct ConfigInfo image_config[] = { "request.button.player_4.draw_player", "true" }, { "request.button.player_4.tile_size", "16" }, + { "global.use_envelope_request", "false" }, + { "game.forced_scroll_delay_value", "-1" }, { "game.use_native_emc_graphics_engine", "false" }, { "game.use_native_sp_graphics_engine", "true" }, diff --git a/src/conf_gfx.h b/src/conf_gfx.h index f63c06ed..01f9fbd5 100644 --- a/src/conf_gfx.h +++ b/src/conf_gfx.h @@ -1856,17 +1856,18 @@ #define IMG_BACKGROUND_ENVELOPE_2 1835 #define IMG_BACKGROUND_ENVELOPE_3 1836 #define IMG_BACKGROUND_ENVELOPE_4 1837 -#define IMG_TITLESCREEN_INITIAL_1 1838 -#define IMG_TITLESCREEN_INITIAL_2 1839 -#define IMG_TITLESCREEN_INITIAL_3 1840 -#define IMG_TITLESCREEN_INITIAL_4 1841 -#define IMG_TITLESCREEN_INITIAL_5 1842 -#define IMG_TITLESCREEN_1 1843 -#define IMG_TITLESCREEN_2 1844 -#define IMG_TITLESCREEN_3 1845 -#define IMG_TITLESCREEN_4 1846 -#define IMG_TITLESCREEN_5 1847 +#define IMG_BACKGROUND_REQUEST 1838 +#define IMG_TITLESCREEN_INITIAL_1 1839 +#define IMG_TITLESCREEN_INITIAL_2 1840 +#define IMG_TITLESCREEN_INITIAL_3 1841 +#define IMG_TITLESCREEN_INITIAL_4 1842 +#define IMG_TITLESCREEN_INITIAL_5 1843 +#define IMG_TITLESCREEN_1 1844 +#define IMG_TITLESCREEN_2 1845 +#define IMG_TITLESCREEN_3 1846 +#define IMG_TITLESCREEN_4 1847 +#define IMG_TITLESCREEN_5 1848 -#define NUM_IMAGE_FILES 1848 +#define NUM_IMAGE_FILES 1849 #endif /* CONF_GFX_H */ diff --git a/src/conf_snd.c b/src/conf_snd.c index 763f31d9..f929a01e 100644 --- a/src/conf_snd.c +++ b/src/conf_snd.c @@ -252,6 +252,9 @@ struct ConfigInfo sound_config[] = { "door.opening", "oeffnen.wav" }, { "door.closing", "oeffnen.wav" }, + { "request.opening", UNDEFINED_FILENAME }, + { "request.closing", UNDEFINED_FILENAME }, + /* sounds for menu actions */ { "menu.item.activating", "empty.wav" }, { "menu.item.selecting", "base.wav" }, diff --git a/src/conf_snd.h b/src/conf_snd.h index 08fe1a95..ff472d73 100644 --- a/src/conf_snd.h +++ b/src/conf_snd.h @@ -212,37 +212,39 @@ #define SND_GAME_SOKOBAN_SOLVING 191 #define SND_DOOR_OPENING 192 #define SND_DOOR_CLOSING 193 -#define SND_MENU_ITEM_ACTIVATING 194 -#define SND_MENU_ITEM_SELECTING 195 -#define SND_BACKGROUND_TITLE_INITIAL 196 -#define SND_BACKGROUND_TITLE 197 -#define SND_BACKGROUND_MAIN 198 -#define SND_BACKGROUND_LEVELS 199 -#define SND_BACKGROUND_SCORES 200 -#define SND_BACKGROUND_EDITOR 201 -#define SND_BACKGROUND_INFO 202 -#define SND_BACKGROUND_SETUP 203 -#define SND_BACKGROUND_TITLESCREEN_INITIAL_1 204 -#define SND_BACKGROUND_TITLESCREEN_INITIAL_2 205 -#define SND_BACKGROUND_TITLESCREEN_INITIAL_3 206 -#define SND_BACKGROUND_TITLESCREEN_INITIAL_4 207 -#define SND_BACKGROUND_TITLESCREEN_INITIAL_5 208 -#define SND_BACKGROUND_TITLESCREEN_1 209 -#define SND_BACKGROUND_TITLESCREEN_2 210 -#define SND_BACKGROUND_TITLESCREEN_3 211 -#define SND_BACKGROUND_TITLESCREEN_4 212 -#define SND_BACKGROUND_TITLESCREEN_5 213 -#define SND_BACKGROUND_TITLEMESSAGE_INITIAL_1 214 -#define SND_BACKGROUND_TITLEMESSAGE_INITIAL_2 215 -#define SND_BACKGROUND_TITLEMESSAGE_INITIAL_3 216 -#define SND_BACKGROUND_TITLEMESSAGE_INITIAL_4 217 -#define SND_BACKGROUND_TITLEMESSAGE_INITIAL_5 218 -#define SND_BACKGROUND_TITLEMESSAGE_1 219 -#define SND_BACKGROUND_TITLEMESSAGE_2 220 -#define SND_BACKGROUND_TITLEMESSAGE_3 221 -#define SND_BACKGROUND_TITLEMESSAGE_4 222 -#define SND_BACKGROUND_TITLEMESSAGE_5 223 +#define SND_REQUEST_OPENING 194 +#define SND_REQUEST_CLOSING 195 +#define SND_MENU_ITEM_ACTIVATING 196 +#define SND_MENU_ITEM_SELECTING 197 +#define SND_BACKGROUND_TITLE_INITIAL 198 +#define SND_BACKGROUND_TITLE 199 +#define SND_BACKGROUND_MAIN 200 +#define SND_BACKGROUND_LEVELS 201 +#define SND_BACKGROUND_SCORES 202 +#define SND_BACKGROUND_EDITOR 203 +#define SND_BACKGROUND_INFO 204 +#define SND_BACKGROUND_SETUP 205 +#define SND_BACKGROUND_TITLESCREEN_INITIAL_1 206 +#define SND_BACKGROUND_TITLESCREEN_INITIAL_2 207 +#define SND_BACKGROUND_TITLESCREEN_INITIAL_3 208 +#define SND_BACKGROUND_TITLESCREEN_INITIAL_4 209 +#define SND_BACKGROUND_TITLESCREEN_INITIAL_5 210 +#define SND_BACKGROUND_TITLESCREEN_1 211 +#define SND_BACKGROUND_TITLESCREEN_2 212 +#define SND_BACKGROUND_TITLESCREEN_3 213 +#define SND_BACKGROUND_TITLESCREEN_4 214 +#define SND_BACKGROUND_TITLESCREEN_5 215 +#define SND_BACKGROUND_TITLEMESSAGE_INITIAL_1 216 +#define SND_BACKGROUND_TITLEMESSAGE_INITIAL_2 217 +#define SND_BACKGROUND_TITLEMESSAGE_INITIAL_3 218 +#define SND_BACKGROUND_TITLEMESSAGE_INITIAL_4 219 +#define SND_BACKGROUND_TITLEMESSAGE_INITIAL_5 220 +#define SND_BACKGROUND_TITLEMESSAGE_1 221 +#define SND_BACKGROUND_TITLEMESSAGE_2 222 +#define SND_BACKGROUND_TITLEMESSAGE_3 223 +#define SND_BACKGROUND_TITLEMESSAGE_4 224 +#define SND_BACKGROUND_TITLEMESSAGE_5 225 -#define NUM_SOUND_FILES 224 +#define NUM_SOUND_FILES 226 #endif /* CONF_SND_H */ diff --git a/src/conf_var.c b/src/conf_var.c index f10abd81..9676d1d7 100644 --- a/src/conf_var.c +++ b/src/conf_var.c @@ -5436,6 +5436,10 @@ struct TokenIntPtrInfo image_config_vars[] = "request.button.player_4.tile_size", &request.button.player_4.size }, + { + "global.use_envelope_request", + &global.use_envelope_request + }, { "game.forced_scroll_delay_value", &game.forced_scroll_delay_value diff --git a/src/conftime.h b/src/conftime.h index a4a710b7..62dbfd32 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2014-01-22 14:42" +#define COMPILE_DATE_STRING "2014-01-27 22:11" diff --git a/src/files.c b/src/files.c index 80105139..487793f0 100644 --- a/src/files.c +++ b/src/files.c @@ -11347,25 +11347,26 @@ void SaveScore(int nr) #define SETUP_TOKEN_FULLSCREEN 17 #define SETUP_TOKEN_FULLSCREEN_MODE 18 #define SETUP_TOKEN_WINDOW_SCALING_PERCENT 19 -#define SETUP_TOKEN_ASK_ON_ESCAPE 20 -#define SETUP_TOKEN_ASK_ON_ESCAPE_EDITOR 21 -#define SETUP_TOKEN_QUICK_SWITCH 22 -#define SETUP_TOKEN_INPUT_ON_FOCUS 23 -#define SETUP_TOKEN_PREFER_AGA_GRAPHICS 24 -#define SETUP_TOKEN_GAME_FRAME_DELAY 25 -#define SETUP_TOKEN_SP_SHOW_BORDER_ELEMENTS 26 -#define SETUP_TOKEN_SMALL_GAME_GRAPHICS 27 -#define SETUP_TOKEN_GRAPHICS_SET 28 -#define SETUP_TOKEN_SOUNDS_SET 29 -#define SETUP_TOKEN_MUSIC_SET 30 -#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS 31 -#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS 32 -#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC 33 -#define SETUP_TOKEN_VOLUME_SIMPLE 34 -#define SETUP_TOKEN_VOLUME_LOOPS 35 -#define SETUP_TOKEN_VOLUME_MUSIC 36 - -#define NUM_GLOBAL_SETUP_TOKENS 37 +#define SETUP_TOKEN_WINDOW_SCALING_QUALITY 20 +#define SETUP_TOKEN_ASK_ON_ESCAPE 21 +#define SETUP_TOKEN_ASK_ON_ESCAPE_EDITOR 22 +#define SETUP_TOKEN_QUICK_SWITCH 23 +#define SETUP_TOKEN_INPUT_ON_FOCUS 24 +#define SETUP_TOKEN_PREFER_AGA_GRAPHICS 25 +#define SETUP_TOKEN_GAME_FRAME_DELAY 26 +#define SETUP_TOKEN_SP_SHOW_BORDER_ELEMENTS 27 +#define SETUP_TOKEN_SMALL_GAME_GRAPHICS 28 +#define SETUP_TOKEN_GRAPHICS_SET 29 +#define SETUP_TOKEN_SOUNDS_SET 30 +#define SETUP_TOKEN_MUSIC_SET 31 +#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS 32 +#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS 33 +#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC 34 +#define SETUP_TOKEN_VOLUME_SIMPLE 35 +#define SETUP_TOKEN_VOLUME_LOOPS 36 +#define SETUP_TOKEN_VOLUME_MUSIC 37 + +#define NUM_GLOBAL_SETUP_TOKENS 38 /* editor setup */ #define SETUP_TOKEN_EDITOR_EL_BOULDERDASH 0 @@ -11495,6 +11496,7 @@ static struct TokenInfo global_setup_tokens[] = { TYPE_SWITCH, &si.fullscreen, "fullscreen" }, { TYPE_STRING, &si.fullscreen_mode, "fullscreen_mode" }, { TYPE_INTEGER,&si.window_scaling_percent, "window_scaling_percent" }, + { TYPE_STRING, &si.window_scaling_quality, "window_scaling_quality" }, { TYPE_SWITCH, &si.ask_on_escape, "ask_on_escape" }, { TYPE_SWITCH, &si.ask_on_escape_editor, "ask_on_escape_editor" }, { TYPE_SWITCH, &si.quick_switch, "quick_player_switch" }, @@ -11667,6 +11669,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->fullscreen = FALSE; si->fullscreen_mode = getStringCopy(DEFAULT_FULLSCREEN_MODE); si->window_scaling_percent = STD_WINDOW_SCALING_PERCENT; + si->window_scaling_quality = getStringCopy(SCALING_QUALITY_DEFAULT); si->ask_on_escape = TRUE; si->ask_on_escape_editor = TRUE; si->quick_switch = FALSE; diff --git a/src/init.c b/src/init.c index a1b92d25..ab342b8a 100644 --- a/src/init.c +++ b/src/init.c @@ -5027,7 +5027,7 @@ static void InitGlobal() global.fading_type = TYPE_ENTER_MENU; #endif - global.use_envelope_request = FALSE; /* !!! MOVE TO ARTWORK CONFIG !!! */ + global.use_envelope_request = FALSE; } void Execute_Command(char *command) diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 3d45ad0a..120fe30c 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -255,6 +255,7 @@ void SDLInitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window, #endif video.window_scaling_percent = setup.window_scaling_percent; + video.window_scaling_quality = setup.window_scaling_quality; #if defined(TARGET_SDL2) int num_displays = SDL_GetNumVideoDisplays(); @@ -520,7 +521,8 @@ static SDL_Surface *SDLCreateScreen(DrawBuffer **backbuffer, if (sdl_renderer != NULL) { SDL_RenderSetLogicalSize(sdl_renderer, width, height); - SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); + // SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); + SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, setup.window_scaling_quality); sdl_texture = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_ARGB8888, @@ -794,6 +796,7 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen) video.fullscreen_enabled = FALSE; video.window_scaling_percent = setup.window_scaling_percent; + video.window_scaling_quality = setup.window_scaling_quality; success = TRUE; } @@ -846,6 +849,30 @@ void SDLSetWindowScaling(int window_scaling_percent) video.window_height = new_window_height; } +void SDLSetWindowScalingQuality(char *window_scaling_quality) +{ + if (sdl_texture == NULL) + return; + + SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, window_scaling_quality); + + SDL_Texture *new_texture = SDL_CreateTexture(sdl_renderer, + SDL_PIXELFORMAT_ARGB8888, + SDL_TEXTUREACCESS_STREAMING, + video.width, video.height); + + if (new_texture != NULL) + { + SDL_DestroyTexture(sdl_texture); + + sdl_texture = new_texture; + + SDLRedrawWindow(); + } + + video.window_scaling_quality = window_scaling_quality; +} + void SDLSetWindowFullscreen(boolean fullscreen) { if (sdl_window == NULL) diff --git a/src/libgame/sdl.h b/src/libgame/sdl.h index 710d247c..8f64ef18 100644 --- a/src/libgame/sdl.h +++ b/src/libgame/sdl.h @@ -438,6 +438,7 @@ struct MouseCursorInfo #if defined(TARGET_SDL2) SDL_Surface *SDL_DisplayFormat(SDL_Surface *); void SDLSetWindowScaling(int); +void SDLSetWindowScalingQuality(char *); void SDLSetWindowFullscreen(boolean); void SDLRedrawWindow(); #endif diff --git a/src/libgame/system.h b/src/libgame/system.h index 95076061..9ec6e757 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -60,6 +60,13 @@ #define MAX_WINDOW_SCALING_PERCENT 300 #define STEP_WINDOW_SCALING_PERCENT 10 +/* values for window scaling quality */ +#define SCALING_QUALITY_NEAREST "nearest" +#define SCALING_QUALITY_LINEAR "linear" +#define SCALING_QUALITY_BEST "best" + +#define SCALING_QUALITY_DEFAULT SCALING_QUALITY_LINEAR + /* default input keys */ #define DEFAULT_KEY_LEFT KSYM_Left #define DEFAULT_KEY_RIGHT KSYM_Right @@ -743,6 +750,7 @@ struct VideoSystemInfo boolean window_scaling_available; int window_scaling_percent; + char *window_scaling_quality; }; struct AudioSystemInfo @@ -953,6 +961,7 @@ struct SetupInfo boolean fullscreen; char *fullscreen_mode; int window_scaling_percent; + char *window_scaling_quality; boolean ask_on_escape; boolean ask_on_escape_editor; boolean quick_switch; diff --git a/src/screens.c b/src/screens.c index 23950185..6ddc6044 100644 --- a/src/screens.c +++ b/src/screens.c @@ -60,17 +60,18 @@ /* sub-screens on the setup screen (specific) */ #define SETUP_MODE_CHOOSE_GAME_SPEED 15 -#define SETUP_MODE_CHOOSE_SCREEN_MODE 16 -#define SETUP_MODE_CHOOSE_WINDOW_SIZE 17 -#define SETUP_MODE_CHOOSE_SCROLL_DELAY 18 -#define SETUP_MODE_CHOOSE_GRAPHICS 19 -#define SETUP_MODE_CHOOSE_SOUNDS 20 -#define SETUP_MODE_CHOOSE_MUSIC 21 -#define SETUP_MODE_CHOOSE_VOLUME_SIMPLE 22 -#define SETUP_MODE_CHOOSE_VOLUME_LOOPS 23 -#define SETUP_MODE_CHOOSE_VOLUME_MUSIC 24 - -#define MAX_SETUP_MODES 25 +#define SETUP_MODE_CHOOSE_SCROLL_DELAY 16 +#define SETUP_MODE_CHOOSE_SCREEN_MODE 17 +#define SETUP_MODE_CHOOSE_WINDOW_SIZE 18 +#define SETUP_MODE_CHOOSE_SCALING_TYPE 19 +#define SETUP_MODE_CHOOSE_GRAPHICS 20 +#define SETUP_MODE_CHOOSE_SOUNDS 21 +#define SETUP_MODE_CHOOSE_MUSIC 22 +#define SETUP_MODE_CHOOSE_VOLUME_SIMPLE 23 +#define SETUP_MODE_CHOOSE_VOLUME_LOOPS 24 +#define SETUP_MODE_CHOOSE_VOLUME_MUSIC 25 + +#define MAX_SETUP_MODES 26 /* for input setup functions */ #define SETUPINPUT_SCREEN_POS_START 0 @@ -180,6 +181,9 @@ static TreeInfo *screen_mode_current = NULL; static TreeInfo *window_sizes = NULL; static TreeInfo *window_size_current = NULL; +static TreeInfo *scaling_types = NULL; +static TreeInfo *scaling_type_current = NULL; + static TreeInfo *scroll_delays = NULL; static TreeInfo *scroll_delay_current = NULL; @@ -220,6 +224,19 @@ static struct { -1, NULL }, }; +static struct +{ + char *value; + char *text; +} scaling_types_list[] = +{ + { SCALING_QUALITY_NEAREST, "None" }, + { SCALING_QUALITY_LINEAR, "Linear" }, + { SCALING_QUALITY_BEST, "Anisotropic" }, + + { NULL, NULL }, +}; + static struct { int value; @@ -3620,11 +3637,12 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, } else if (game_status == GAME_MODE_SETUP) { - if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED) + if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED || + setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY) execSetupGame(); else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE || setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE || - setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY) + setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE) execSetupGraphics(); else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE || setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS || @@ -3815,11 +3833,12 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, if (game_status == GAME_MODE_SETUP) { - if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED) + if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED || + setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY) execSetupGame(); else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE || setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE || - setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY) + setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE) execSetupGraphics(); else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE || setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS || @@ -4092,6 +4111,7 @@ static int num_setup_info; static char *screen_mode_text; static char *window_size_text; +static char *scaling_type_text; static char *scroll_delay_text; static char *game_speed_text; static char *graphics_set_name; @@ -4108,7 +4128,7 @@ static void execSetupMain() DrawSetupScreen(); } -static void execSetupGame() +static void execSetupGame_setGameSpeeds() { if (game_speeds == NULL) { @@ -4156,6 +4176,62 @@ static void execSetupGame() /* needed for displaying game speed text instead of identifier */ game_speed_text = game_speed_current->name; +} + +static void execSetupGame_setScrollDelays() +{ + if (scroll_delays == NULL) + { + int i; + + for (i = 0; scroll_delays_list[i].value != -1; i++) + { + TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED); + char identifier[32], name[32]; + int value = scroll_delays_list[i].value; + char *text = scroll_delays_list[i].text; + + ti->node_top = &scroll_delays; + ti->sort_priority = value; + + sprintf(identifier, "%d", value); + sprintf(name, "%s", text); + + setString(&ti->identifier, identifier); + setString(&ti->name, name); + setString(&ti->name_sorting, name); + setString(&ti->infotext, "Scaling Type"); + + pushTreeInfo(&scroll_delays, ti); + } + + /* sort scaling type values to start with lowest scaling type value */ + sortTreeInfo(&scroll_delays); + + /* set current scaling type value to configured scaling type value */ + scroll_delay_current = + getTreeInfoFromIdentifier(scroll_delays,i_to_a(setup.scroll_delay_value)); + + /* if that fails, set current scaling type to reliable default value */ + if (scroll_delay_current == NULL) + scroll_delay_current = + getTreeInfoFromIdentifier(scroll_delays, i_to_a(STD_SCROLL_DELAY)); + + /* if that also fails, set current scaling type to first available value */ + if (scroll_delay_current == NULL) + scroll_delay_current = scroll_delays; + } + + setup.scroll_delay_value = atoi(scroll_delay_current->identifier); + + /* needed for displaying scaling type text instead of identifier */ + scroll_delay_text = scroll_delay_current->name; +} + +static void execSetupGame() +{ + execSetupGame_setGameSpeeds(); + execSetupGame_setScrollDelays(); setup_mode = SETUP_MODE_GAME; @@ -4169,6 +4245,13 @@ static void execSetupChooseGameSpeed() DrawSetupScreen(); } +static void execSetupChooseScrollDelay() +{ + setup_mode = SETUP_MODE_CHOOSE_SCROLL_DELAY; + + DrawSetupScreen(); +} + static void execSetupEditor() { setup_mode = SETUP_MODE_EDITOR; @@ -4261,6 +4344,56 @@ static void execSetupGraphics_setWindowSizes(boolean update_list) window_size_text = window_size_current->name; } +static void execSetupGraphics_setScalingTypes() +{ + if (scaling_types == NULL) + { + int i; + + for (i = 0; scaling_types_list[i].value != NULL; i++) + { + TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED); + char identifier[32], name[32]; + char *value = scaling_types_list[i].value; + char *text = scaling_types_list[i].text; + + ti->node_top = &scaling_types; + ti->sort_priority = i; + + sprintf(identifier, "%s", value); + sprintf(name, "%s", text); + + setString(&ti->identifier, identifier); + setString(&ti->name, name); + setString(&ti->name_sorting, name); + setString(&ti->infotext, "Anti-Aliasing"); + + pushTreeInfo(&scaling_types, ti); + } + + /* sort scaling type values to start with lowest scaling type value */ + sortTreeInfo(&scaling_types); + + /* set current scaling type value to configured scaling type value */ + scaling_type_current = + getTreeInfoFromIdentifier(scaling_types, setup.window_scaling_quality); + + /* if that fails, set current scaling type to reliable default value */ + if (scaling_type_current == NULL) + scaling_type_current = + getTreeInfoFromIdentifier(scaling_types, SCALING_QUALITY_DEFAULT); + + /* if that also fails, set current scaling type to first available value */ + if (scaling_type_current == NULL) + scaling_type_current = scaling_types; + } + + setup.window_scaling_quality = scaling_type_current->identifier; + + /* needed for displaying scaling type text instead of identifier */ + scaling_type_text = scaling_type_current->name; +} + static void execSetupGraphics_setScreenModes() { // if (screen_modes == NULL && video.fullscreen_available) @@ -4322,72 +4455,34 @@ static void execSetupGraphics_setScreenModes() } } -static void execSetupGraphics_setScrollDelays() +static void execSetupGraphics() { - if (scroll_delays == NULL) + if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE) { - int i; - - for (i = 0; scroll_delays_list[i].value != -1; i++) - { - TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED); - char identifier[32], name[32]; - int value = scroll_delays_list[i].value; - char *text = scroll_delays_list[i].text; - - ti->node_top = &scroll_delays; - ti->sort_priority = value; - - sprintf(identifier, "%d", value); - sprintf(name, "%s", text); - - setString(&ti->identifier, identifier); - setString(&ti->name, name); - setString(&ti->name_sorting, name); - setString(&ti->infotext, "Scroll Delay"); - - pushTreeInfo(&scroll_delays, ti); - } - - /* sort scroll delay values to start with lowest scroll delay value */ - sortTreeInfo(&scroll_delays); - - /* set current scroll delay value to configured scroll delay value */ - scroll_delay_current = - getTreeInfoFromIdentifier(scroll_delays,i_to_a(setup.scroll_delay_value)); - - /* if that fails, set current scroll delay to reliable default value */ - if (scroll_delay_current == NULL) - scroll_delay_current = - getTreeInfoFromIdentifier(scroll_delays, i_to_a(STD_SCROLL_DELAY)); - - /* if that also fails, set current scroll delay to first available value */ - if (scroll_delay_current == NULL) - scroll_delay_current = scroll_delays; + // update "setup.window_scaling_percent" from list selection + execSetupGraphics_setWindowSizes(FALSE); + } + else + { + // update list selection from "setup.window_scaling_percent" + execSetupGraphics_setWindowSizes(TRUE); } - setup.scroll_delay_value = atoi(scroll_delay_current->identifier); - - /* needed for displaying scroll delay text instead of identifier */ - scroll_delay_text = scroll_delay_current->name; -} - -static void execSetupGraphics() -{ - // update "setup.window_scaling_percent" from list selection - execSetupGraphics_setWindowSizes(FALSE); - // maybe remove non-preset value (if standard value was selected) - execSetupGraphics_setWindowSizes(TRUE); - + execSetupGraphics_setScalingTypes(); execSetupGraphics_setScreenModes(); - execSetupGraphics_setScrollDelays(); setup_mode = SETUP_MODE_GRAPHICS; DrawSetupScreen(); +#if defined(TARGET_SDL2) // window scaling may have changed at this point ToggleFullscreenOrChangeWindowScalingIfNeeded(); + + // window scaling quality may have changed at this point + if (!strEqual(setup.window_scaling_quality, video.window_scaling_quality)) + SDLSetWindowScalingQuality(setup.window_scaling_quality); +#endif } #if !defined(PLATFORM_ANDROID) @@ -4403,6 +4498,13 @@ static void execSetupChooseWindowSize() DrawSetupScreen(); } + +static void execSetupChooseScalingType() +{ + setup_mode = SETUP_MODE_CHOOSE_SCALING_TYPE; + + DrawSetupScreen(); +} #else static void execSetupChooseScreenMode() { @@ -4416,13 +4518,6 @@ static void execSetupChooseScreenMode() #endif #endif -static void execSetupChooseScrollDelay() -{ - setup_mode = SETUP_MODE_CHOOSE_SCROLL_DELAY; - - DrawSetupScreen(); -} - static void execSetupChooseVolumeSimple() { setup_mode = SETUP_MODE_CHOOSE_VOLUME_SIMPLE; @@ -4723,6 +4818,10 @@ static struct TokenInfo setup_info_game[] = { TYPE_SWITCH, &setup.autorecord, "Auto-Record Tapes:" }, { TYPE_ENTER_LIST, execSetupChooseGameSpeed, "Game Speed:" }, { TYPE_STRING, &game_speed_text, "" }, +#if 1 + { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" }, + { TYPE_STRING, &scroll_delay_text, "" }, +#endif { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execSetupMain, "Back" }, @@ -4769,6 +4868,10 @@ static struct TokenInfo setup_info_graphics[] = #if defined(TARGET_SDL2) { TYPE_ENTER_LIST, execSetupChooseWindowSize, "Window Scaling:" }, { TYPE_STRING, &window_size_text, "" }, +#if 1 + { TYPE_ENTER_LIST, execSetupChooseScalingType, "Anti-Aliasing:" }, + { TYPE_STRING, &scaling_type_text, "" }, +#endif #else { TYPE_ENTER_LIST, execSetupChooseScreenMode, "Fullscreen Mode:" }, { TYPE_STRING, &screen_mode_text, "" }, @@ -4777,8 +4880,10 @@ static struct TokenInfo setup_info_graphics[] = #if 0 { TYPE_SWITCH, &setup.scroll_delay, "Scroll Delay:" }, #endif +#if 0 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay Value:" }, { TYPE_STRING, &scroll_delay_text, "" }, +#endif #if 0 { TYPE_SWITCH, &setup.soft_scrolling, "Soft Scrolling:" }, #endif @@ -5299,7 +5404,8 @@ static void DrawSetupScreen_Generic() (value_ptr == &setup.sound_music && !audio.music_available) || (value_ptr == &setup.fullscreen && !video.fullscreen_available) || (value_ptr == &screen_mode_text && !video.fullscreen_available) || - (value_ptr == &window_size_text && !video.window_scaling_available)) + (value_ptr == &window_size_text && !video.window_scaling_available) || + (value_ptr == &scaling_type_text && !video.window_scaling_available)) setup_info[i].type |= TYPE_GHOSTED; if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST)) @@ -5364,7 +5470,8 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button) { PlaySound(SND_MENU_ITEM_SELECTING); - for (y = 0; y < num_setup_info; y++) + // for (y = 0; y < num_setup_info; y++) + for (y = 0; setup_info[y].type != 0; y++) { if (setup_info[y].type & TYPE_LEAVE_MENU) { @@ -6133,12 +6240,14 @@ void DrawSetupScreen() DrawSetupScreen_Input(); else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED) DrawChooseTree(&game_speed_current); + else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY) + DrawChooseTree(&scroll_delay_current); else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE) DrawChooseTree(&screen_mode_current); else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE) DrawChooseTree(&window_size_current); - else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY) - DrawChooseTree(&scroll_delay_current); + else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE) + DrawChooseTree(&scaling_type_current); else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS) DrawChooseTree(&artwork.gfx_current); else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS) @@ -6164,7 +6273,7 @@ void RedrawSetupScreenAfterFullscreenToggle() if (setup_mode == SETUP_MODE_GRAPHICS || setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE) { - // update "setup.window_scaling_percent" from list selection + // update list selection from "setup.window_scaling_percent" execSetupGraphics_setWindowSizes(TRUE); DrawSetupScreen(); @@ -6181,12 +6290,14 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) HandleSetupScreen_Input(mx, my, dx, dy, button); else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED) HandleChooseTree(mx, my, dx, dy, button, &game_speed_current); + else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY) + HandleChooseTree(mx, my, dx, dy, button, &scroll_delay_current); else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE) HandleChooseTree(mx, my, dx, dy, button, &screen_mode_current); else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE) HandleChooseTree(mx, my, dx, dy, button, &window_size_current); - else if (setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY) - HandleChooseTree(mx, my, dx, dy, button, &scroll_delay_current); + else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE) + HandleChooseTree(mx, my, dx, dy, button, &scaling_type_current); else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS) HandleChooseTree(mx, my, dx, dy, button, &artwork.gfx_current); else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS) diff --git a/src/tools.c b/src/tools.c index 34006e7d..6f67e143 100644 --- a/src/tools.c +++ b/src/tools.c @@ -2465,12 +2465,12 @@ void DrawMiniElementOrWall(int sx, int sy, int scroll_x, int scroll_y) DrawMiniGraphic(sx, sy, el2edimg(getBorderElement(x, y))); } -void DrawEnvelopeBackground(int envelope_nr, int startx, int starty, - int x, int y, int xsize, int ysize, int font_nr) +void DrawEnvelopeBackground(int graphic, int startx, int starty, + int x, int y, int xsize, int ysize, int font_nr, + int line_spacing) { int font_width = getFontWidth(font_nr); - int font_height = getFontHeight(font_nr); - int graphic = IMG_BACKGROUND_ENVELOPE_1 + envelope_nr; + int font_height = getFontHeight(font_nr) + line_spacing; Bitmap *src_bitmap; int src_x, src_y; int dst_x = SX + startx + x * font_width; @@ -2549,8 +2549,10 @@ void AnimateEnvelope(int envelope_nr, int anim_mode, int action) SetDrawtoField(DRAW_BACKBUFFER); - for (yy = 0; yy < ysize; yy++) for (xx = 0; xx < xsize; xx++) - DrawEnvelopeBackground(envelope_nr, sx,sy, xx,yy, xsize, ysize, font_nr); + for (yy = 0; yy < ysize; yy++) + for (xx = 0; xx < xsize; xx++) + DrawEnvelopeBackground(graphic, sx,sy, xx,yy, xsize, ysize, + font_nr, 0); #if 1 DrawTextBuffer(SX + sx + font_width, SY + sy + font_height, @@ -2571,19 +2573,23 @@ void AnimateEnvelope(int envelope_nr, int anim_mode, int action) } } -void AnimateEnvelopeDoor(char *text, int anim_mode, int action) +void AnimateEnvelopeRequest(char *text, int anim_mode, int action) { -#if 1 +#if 0 int envelope_nr = 0; #endif +#if 1 + int graphic = IMG_BACKGROUND_REQUEST; +#else int graphic = IMG_BACKGROUND_ENVELOPE_1 + envelope_nr; +#endif Bitmap *src_bitmap = graphic_info[graphic].bitmap; int mask_mode = (src_bitmap != NULL ? BLIT_MASKED : BLIT_ON_BACKGROUND); boolean ffwd_delay = (tape.playing && tape.fast_forward); boolean no_delay = (tape.warp_forward); unsigned int anim_delay = 0; int frame_delay_value = (ffwd_delay ? FfwdFrameDelay : GameFrameDelay); - int anim_delay_value = (no_delay ? 0 : frame_delay_value); + int anim_delay_value = (no_delay ? 0 : frame_delay_value + 500 * 0); #if 1 int max_word_len = maxWordLengthInString(text); int font_nr = (max_word_len > 7 ? FONT_TEXT_1 : FONT_TEXT_2); @@ -2592,11 +2598,13 @@ void AnimateEnvelopeDoor(char *text, int anim_mode, int action) #endif int font_width = getFontWidth(font_nr); int font_height = getFontHeight(font_nr); + int line_spacing = 2 * 1; #if 1 #if 1 int max_xsize = DXSIZE / font_width; - int max_ysize = DYSIZE / font_height; + // int max_ysize = DYSIZE / font_height; + int max_ysize = DYSIZE / (font_height + line_spacing); #else int max_xsize = 7; /* tools.c: MAX_REQUEST_LINE_FONT1_LEN == 7 */ int max_ysize = 13; /* tools.c: MAX_REQUEST_LINES == 13 */ @@ -2667,7 +2675,8 @@ void AnimateEnvelopeDoor(char *text, int anim_mode, int action) int xsize = (action == ACTION_CLOSING ? xend - (x - xstart) : x) + 2; int ysize = (action == ACTION_CLOSING ? yend - (y - ystart) : y) + 2; int sx = (SXSIZE - xsize * font_width) / 2; - int sy = (SYSIZE - ysize * font_height) / 2; + // int sy = (SYSIZE - ysize * font_height) / 2; + int sy = (SYSIZE - ysize * (font_height + line_spacing)) / 2; int xx, yy; #if 1 @@ -2684,15 +2693,17 @@ void AnimateEnvelopeDoor(char *text, int anim_mode, int action) SetDrawtoField(DRAW_BACKBUFFER); #endif - for (yy = 0; yy < ysize; yy++) for (xx = 0; xx < xsize; xx++) - DrawEnvelopeBackground(envelope_nr, sx,sy, xx,yy, xsize, ysize, font_nr); + for (yy = 0; yy < ysize; yy++) + for (xx = 0; xx < xsize; xx++) + DrawEnvelopeBackground(graphic, sx,sy, xx,yy, xsize, ysize, + font_nr, line_spacing); #if 1 #if 1 DrawTextBuffer(SX + sx + font_width, SY + sy + font_height + 8, text_copy, font_nr, max_xsize, - xsize - 2, ysize - 2, 2, mask_mode, + xsize - 2, ysize - 2, line_spacing, mask_mode, FALSE, TRUE, FALSE); #else DrawTextBuffer(SX + sx + font_width, SY + sy + font_height, @@ -2710,6 +2721,7 @@ void AnimateEnvelopeDoor(char *text, int anim_mode, int action) /* copy request gadgets to door backbuffer */ #if 1 + /* if ((ysize - 2) > 13) BlitBitmap(bitmap_db_door, drawto, DOOR_GFX_PAGEX1 + (DXSIZE - (xsize - 2) * font_width) / 2, @@ -2718,6 +2730,15 @@ void AnimateEnvelopeDoor(char *text, int anim_mode, int action) (ysize - 2 - 13) * font_height, SX + sx + font_width, SY + sy + font_height * (1 + 13)); + */ + if ((ysize - 2) > 13) + BlitBitmap(bitmap_db_door, drawto, + DOOR_GFX_PAGEX1 + (DXSIZE - (xsize - 2) * font_width) / 2, + DOOR_GFX_PAGEY1 + 11 * (font_height + line_spacing * 0), + (xsize - 2) * font_width, + (ysize - 2 - 13) * (font_height + line_spacing), + SX + sx + font_width, + SY + sy + (font_height + line_spacing) * (1 + 13)); #else if ((ysize - 2) > 13) BlitBitmap(bitmap_db_door, drawto, @@ -2795,17 +2816,23 @@ void ShowEnvelope(int envelope_nr) BackToFront(); } -void ShowEnvelopeDoor(char *text, int action) +void ShowEnvelopeRequest(char *text, int action) { #if 1 int last_game_status = game_status; /* save current game status */ // int last_draw_background_mask = gfx.draw_background_mask; - int envelope_nr = 0; #endif +#if 1 + int graphic = IMG_BACKGROUND_REQUEST; + int sound_opening = SND_REQUEST_OPENING; + int sound_closing = SND_REQUEST_CLOSING; +#else + int envelope_nr = 0; int element = EL_ENVELOPE_1 + envelope_nr; int graphic = IMG_BACKGROUND_ENVELOPE_1 + envelope_nr; int sound_opening = element_info[element].sound[ACTION_OPENING]; int sound_closing = element_info[element].sound[ACTION_CLOSING]; +#endif #if 0 boolean ffwd_delay = (tape.playing && tape.fast_forward); boolean no_delay = (tape.warp_forward); @@ -2852,9 +2879,9 @@ void ShowEnvelopeDoor(char *text, int action) PlayMenuSoundStereo(sound_opening, SOUND_MIDDLE); if (anim_mode == ANIM_DEFAULT) - AnimateEnvelopeDoor(text, ANIM_DEFAULT, ACTION_OPENING); + AnimateEnvelopeRequest(text, ANIM_DEFAULT, ACTION_OPENING); - AnimateEnvelopeDoor(text, main_anim_mode, ACTION_OPENING); + AnimateEnvelopeRequest(text, main_anim_mode, ACTION_OPENING); #if 0 if (tape.playing) @@ -2868,10 +2895,10 @@ void ShowEnvelopeDoor(char *text, int action) PlayMenuSoundStereo(sound_closing, SOUND_MIDDLE); if (anim_mode != ANIM_NONE) - AnimateEnvelopeDoor(text, main_anim_mode, ACTION_CLOSING); + AnimateEnvelopeRequest(text, main_anim_mode, ACTION_CLOSING); if (anim_mode == ANIM_DEFAULT) - AnimateEnvelopeDoor(text, ANIM_DEFAULT, ACTION_CLOSING); + AnimateEnvelopeRequest(text, ANIM_DEFAULT, ACTION_CLOSING); } game.envelope_active = FALSE; @@ -3886,8 +3913,8 @@ boolean Request(char *text, unsigned int req_state) char *text_ptr; int i; -#if 1 - global.use_envelope_request = 0; +#if 0 + global.use_envelope_request = 1; #endif #if 1 @@ -4048,7 +4075,7 @@ boolean Request(char *text, unsigned int req_state) #if 1 if (global.use_envelope_request) { - ShowEnvelopeDoor(text, ACTION_OPENING); + ShowEnvelopeRequest(text, ACTION_OPENING); for (i = 0; i < NUM_TOOL_BUTTONS; i++) { @@ -4269,7 +4296,7 @@ boolean Request(char *text, unsigned int req_state) #if 1 if (global.use_envelope_request) - ShowEnvelopeDoor(text, ACTION_CLOSING); + ShowEnvelopeRequest(text, ACTION_CLOSING); #endif #if 1 -- 2.34.1