From: Holger Schemel Date: Wed, 2 Aug 2006 19:31:35 +0000 (+0200) Subject: rnd-20060802-3-src X-Git-Tag: 3.2.1^2~26 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=22f539028eb272b70d339e1f37552a2a89f37dd6;p=rocksndiamonds.git rnd-20060802-3-src * added selection of preferred fullscreen mode to setup / graphics menu (useful if default mode 800 x 600 does not match screen aspect ratio) --- diff --git a/ChangeLog b/ChangeLog index d90c4d41..27efedea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-08-01 + * added selection of preferred fullscreen mode to setup / graphics menu + (useful if default mode 800 x 600 does not match screen aspect ratio) + 2006-07-30 * improved down-scaling of images for better level and preview graphics * changed user data directory for Mac OS X from Unix style to new place diff --git a/src/conftime.h b/src/conftime.h index 81bf69db..c5375e16 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2006-08-02 19:10]" +#define COMPILE_DATE_STRING "[2006-08-02 21:27]" diff --git a/src/files.c b/src/files.c index dd841f48..0185e4f6 100644 --- a/src/files.c +++ b/src/files.c @@ -6977,7 +6977,7 @@ static struct TokenInfo global_setup_tokens[] = { TYPE_SWITCH, &si.skip_levels, "skip_levels" }, { TYPE_SWITCH, &si.time_limit, "time_limit" }, { TYPE_SWITCH, &si.fullscreen, "fullscreen" }, - { TYPE_SWITCH, &si.fullscreen_mode, "fullscreen_mode" }, + { TYPE_STRING, &si.fullscreen_mode, "fullscreen_mode" }, { 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" }, diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 1ea2a2ed..0d19ff9c 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1923,6 +1923,25 @@ struct ScreenModeInfo *get_screen_mode_from_string(char *screen_mode_string) return &screen_mode; } +void get_aspect_ratio_from_screen_mode(struct ScreenModeInfo *screen_mode, + int *x, int *y) +{ + float aspect_ratio = (float)screen_mode->width / (float)screen_mode->height; + float aspect_ratio_new; + int i = 1; + + do + { + *x = i * aspect_ratio; + *y = i; + + aspect_ratio_new = (float)*x / (float)*y; + + i++; + } + while (aspect_ratio_new != aspect_ratio && *x < screen_mode->width); +} + static void FreeCustomArtworkList(struct ArtworkListInfo *, struct ListNodeInfo ***, int *); diff --git a/src/libgame/misc.h b/src/libgame/misc.h index a410a111..4319ceed 100644 --- a/src/libgame/misc.h +++ b/src/libgame/misc.h @@ -181,6 +181,7 @@ int get_parameter_value(char *, char *, int); int get_auto_parameter_value(char *, char *); struct ScreenModeInfo *get_screen_mode_from_string(char *); +void get_aspect_ratio_from_screen_mode(struct ScreenModeInfo *, int *x, int *y); struct FileInfo *getFileListFromConfigList(struct ConfigInfo *, struct ConfigTypeInfo *, diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index e384f45c..e478e8aa 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -41,6 +41,9 @@ static void setFullscreenParameters() fullscreen_mode = get_screen_mode_from_string(setup.fullscreen_mode); + if (fullscreen_mode == NULL) + return; + for (i = 0; video.fullscreen_modes[i].width != -1; i++) { if (fullscreen_mode->width == video.fullscreen_modes[i].width && diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 2cafc863..4fea0cde 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -1176,7 +1176,7 @@ char *getCommonDataDir(void) if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_COMMON_DOCUMENTS, NULL, 0, dir)) && !strEqual(dir, "")) /* empty for Windows 95/98 */ - common_data_dir = getPath2(dir, program.userdata_directory); + common_data_dir = getPath2(dir, program.userdata_subdir); else common_data_dir = options.rw_base_directory; } diff --git a/src/libgame/system.c b/src/libgame/system.c index 14d4f1c0..632dd451 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -329,6 +329,7 @@ void InitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window, video.fullscreen_available = FULLSCREEN_STATUS; video.fullscreen_enabled = FALSE; video.fullscreen_modes = NULL; + video.fullscreen_mode_current = NULL; #if defined(TARGET_SDL) SDLInitVideoBuffer(backbuffer, window, fullscreen); diff --git a/src/libgame/system.h b/src/libgame/system.h index 6161b274..4fde8ea6 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -597,9 +597,11 @@ struct VideoSystemInfo { int default_depth; int width, height, depth; + boolean fullscreen_available; boolean fullscreen_enabled; struct ScreenModeInfo *fullscreen_modes; + char *fullscreen_mode_current; }; struct AudioSystemInfo diff --git a/src/screens.c b/src/screens.c index 6655bd88..fbe80072 100644 --- a/src/screens.c +++ b/src/screens.c @@ -231,12 +231,20 @@ void DrawHeadline() static void ToggleFullscreenIfNeeded() { - if (setup.fullscreen != video.fullscreen_enabled) + if (setup.fullscreen != video.fullscreen_enabled || + setup.fullscreen_mode != video.fullscreen_mode_current) { /* save old door content */ BlitBitmap(backbuffer, bitmap_db_door, DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1); + if (setup.fullscreen && video.fullscreen_enabled) + { + /* keep fullscreen mode, but change screen mode */ + video.fullscreen_mode_current = setup.fullscreen_mode; + video.fullscreen_enabled = FALSE; + } + /* toggle fullscreen */ ChangeVideoModeIfNeeded(setup.fullscreen); setup.fullscreen = video.fullscreen_enabled; @@ -2563,12 +2571,15 @@ static void execSetupGraphics() char identifier[20], name[20]; int x = video.fullscreen_modes[i].width; int y = video.fullscreen_modes[i].height; + int xx, yy; + + get_aspect_ratio_from_screen_mode(&video.fullscreen_modes[i], &xx, &yy); ti->node_top = &screen_modes; ti->sort_priority = x * y; sprintf(identifier, "%dx%d", x, y); - sprintf(name, "%d x %d", x, y); + sprintf(name, "%d x %d [%d:%d]", x, y, xx, yy); setString(&ti->identifier, identifier); setString(&ti->name, name); @@ -2578,11 +2589,19 @@ static void execSetupGraphics() pushTreeInfo(&screen_modes, ti); } + /* sort fullscreen modes to start with lowest available screen resolution */ sortTreeInfo(&screen_modes); - /* set current screen mode for fullscreen mode to reliable default value */ + /* set current screen mode for fullscreen mode to configured setup value */ screen_mode_current = getTreeInfoFromIdentifier(screen_modes, - DEFAULT_FULLSCREEN_MODE); + setup.fullscreen_mode); + + /* if that fails, set current screen mode to reliable default value */ + if (screen_mode_current == NULL) + screen_mode_current = getTreeInfoFromIdentifier(screen_modes, + DEFAULT_FULLSCREEN_MODE); + + /* if that also fails, set current screen mode to first available mode */ if (screen_mode_current == NULL) screen_mode_current = screen_modes;