X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fscreens.c;h=3c9d2386f165c1d4166f1f00360ff314ea245db9;hb=b06464b4dc26c0e31ef0bca48b31a4dfbdd549e6;hp=2392bcf0a159648444733d651b82ce164d379e61;hpb=faad97c450f035fb84748e8ca72048e53c92de78;p=rocksndiamonds.git diff --git a/src/screens.c b/src/screens.c index 2392bcf0..3c9d2386 100644 --- a/src/screens.c +++ b/src/screens.c @@ -59,15 +59,16 @@ /* 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_SCROLL_DELAY 17 -#define SETUP_MODE_CHOOSE_GRAPHICS 18 -#define SETUP_MODE_CHOOSE_SOUNDS 19 -#define SETUP_MODE_CHOOSE_MUSIC 20 -#define SETUP_MODE_CHOOSE_VOLUME_SIMPLE 21 -#define SETUP_MODE_CHOOSE_VOLUME_LOOPS 22 -#define SETUP_MODE_CHOOSE_VOLUME_MUSIC 23 +#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 24 +#define MAX_SETUP_MODES 25 /* for input setup functions */ #define SETUPINPUT_SCREEN_POS_START 0 @@ -174,6 +175,9 @@ static int setup_mode = SETUP_MODE_MAIN; static TreeInfo *screen_modes = NULL; static TreeInfo *screen_mode_current = NULL; +static TreeInfo *window_sizes = NULL; +static TreeInfo *window_size_current = NULL; + static TreeInfo *scroll_delays = NULL; static TreeInfo *scroll_delay_current = NULL; @@ -192,6 +196,28 @@ static TreeInfo *volume_music_current = NULL; static TreeInfo *level_number = NULL; static TreeInfo *level_number_current = NULL; +static struct +{ + int value; + char *text; +} window_sizes_list[] = +{ + { 50, "50 %" }, + { 80, "80 %" }, + { 90, "90 %" }, + { 100, "100 % (Default)" }, + { 110, "110 %" }, + { 120, "120 %" }, + { 130, "130 %" }, + { 140, "140 %" }, + { 150, "150 %" }, + { 200, "200 %" }, + { 250, "250 %" }, + { 300, "300 %" }, + + { -1, NULL }, +}; + static struct { int value; @@ -3590,6 +3616,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED) execSetupGame(); else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE || + setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE || setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY) execSetupGraphics(); else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE || @@ -3780,6 +3807,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED) execSetupGame(); else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE || + setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE || setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY) execSetupGraphics(); else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE || @@ -4046,6 +4074,7 @@ static struct TokenInfo *setup_info; static int num_setup_info; static char *screen_mode_text; +static char *window_size_text; static char *scroll_delay_text; static char *game_speed_text; static char *graphics_set_name; @@ -4132,7 +4161,8 @@ static void execSetupEditor() static void execSetupGraphics() { - if (video.fullscreen_available && screen_modes == NULL) + // if (screen_modes == NULL && video.fullscreen_available) + if (screen_modes == NULL && video.fullscreen_modes != NULL) { int i; @@ -4180,7 +4210,8 @@ static void execSetupGraphics() video.fullscreen_available = FALSE; } - if (video.fullscreen_available) + // if (video.fullscreen_available) + if (screen_mode_current != NULL) { setup.fullscreen_mode = screen_mode_current->identifier; @@ -4188,6 +4219,55 @@ static void execSetupGraphics() screen_mode_text = screen_mode_current->name; } + if (window_sizes == NULL) + { + int i; + + for (i = 0; window_sizes_list[i].value != -1; i++) + { + TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED); + char identifier[32], name[32]; + int value = window_sizes_list[i].value; + char *text = window_sizes_list[i].text; + + ti->node_top = &window_sizes; + 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, "Window Scaling"); + + pushTreeInfo(&window_sizes, ti); + } + + /* sort window size values to start with lowest window size value */ + sortTreeInfo(&window_sizes); + + /* set current window size value to configured window size value */ + window_size_current = + getTreeInfoFromIdentifier(window_sizes, + i_to_a(setup.window_scaling_percent)); + + /* if that fails, set current window size to reliable default value */ + if (window_size_current == NULL) + window_size_current = + getTreeInfoFromIdentifier(window_sizes, + i_to_a(STD_WINDOW_SCALING_PERCENT)); + + /* if that also fails, set current window size to first available value */ + if (window_size_current == NULL) + window_size_current = window_sizes; + } + + setup.window_scaling_percent = atoi(window_size_current->identifier); + + /* needed for displaying window size text instead of identifier */ + window_size_text = window_size_current->name; + #if 1 if (scroll_delays == NULL) { @@ -4242,7 +4322,20 @@ static void execSetupGraphics() DrawSetupScreen(); } -#if !defined(TARGET_SDL2) +#if !defined(PLATFORM_ANDROID) +#if defined(TARGET_SDL2) +static void execSetupChooseWindowSize() +{ +#if 0 + if (!video.window_scaling_available) + return; +#endif + + setup_mode = SETUP_MODE_CHOOSE_WINDOW_SIZE; + + DrawSetupScreen(); +} +#else static void execSetupChooseScreenMode() { if (!video.fullscreen_available) @@ -4253,6 +4346,7 @@ static void execSetupChooseScreenMode() DrawSetupScreen(); } #endif +#endif static void execSetupChooseScrollDelay() { @@ -4602,11 +4696,16 @@ static struct TokenInfo setup_info_editor[] = static struct TokenInfo setup_info_graphics[] = { +#if !defined(PLATFORM_ANDROID) { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" }, -#if !defined(TARGET_SDL2) +#if defined(TARGET_SDL2) + { TYPE_ENTER_LIST, execSetupChooseWindowSize, "Window Scaling:" }, + { TYPE_STRING, &window_size_text, "" }, +#else { TYPE_ENTER_LIST, execSetupChooseScreenMode, "Fullscreen Mode:" }, { TYPE_STRING, &screen_mode_text, "" }, #endif +#endif #if 0 { TYPE_SWITCH, &setup.scroll_delay, "Scroll Delay:" }, #endif @@ -5127,7 +5226,8 @@ static void DrawSetupScreen_Generic() (value_ptr == &setup.sound_loops && !audio.loops_available) || (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 == &screen_mode_text && !video.fullscreen_available) || + (value_ptr == &window_size_text && !video.window_scaling_available)) setup_info[i].type |= TYPE_GHOSTED; if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST)) @@ -5963,6 +6063,8 @@ void DrawSetupScreen() DrawChooseTree(&game_speed_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_GRAPHICS) @@ -5998,6 +6100,8 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) HandleChooseTree(mx, my, dx, dy, button, &game_speed_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_GRAPHICS)