X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fscreens.c;h=43ad44de0a8a49dbb03193ef71ddd87f745becb5;hb=04822a800bb5479087613b0730fdf7e765ba012c;hp=6543e1688174a3926e792a91652c81cd859c9d52;hpb=8bee1f8bc2232bd6775c402f9f630e92d901593f;p=rocksndiamonds.git diff --git a/src/screens.c b/src/screens.c index 6543e168..43ad44de 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; @@ -1317,6 +1334,8 @@ void DrawMainMenuExt(int fade_mask, boolean do_fading) static LevelDirTree *leveldir_last_valid = NULL; boolean levelset_has_changed = FALSE; + LimitScreenUpdates(FALSE); + FadeSetLeaveScreen(); /* do not fade out here -- function may continue and fade on editor screen */ @@ -1344,7 +1363,8 @@ void DrawMainMenuExt(int fade_mask, boolean do_fading) } /* needed if last screen was the setup screen and fullscreen state changed */ - ToggleFullscreenIfNeeded(); + // (moved to "execSetupGraphics()" to change fullscreen state directly) + // ToggleFullscreenOrChangeWindowScalingIfNeeded(); /* leveldir_current may be invalid (level group, parent link) */ if (!validLevelSeries(leveldir_current)) @@ -1367,8 +1387,11 @@ void DrawMainMenuExt(int fade_mask, boolean do_fading) #if 1 FadeOut(fade_mask); +#if 0 /* needed if last screen was the editor screen */ UndrawSpecialEditorDoor(); +#endif + #if 0 if (fade_mask == REDRAW_FIELD) BackToFront(); @@ -1380,6 +1403,11 @@ void DrawMainMenuExt(int fade_mask, boolean do_fading) ChangeViewportPropertiesIfNeeded(); #endif +#if 1 + /* needed if last screen was the editor screen */ + UndrawSpecialEditorDoor(); +#endif + #if defined(TARGET_SDL) SetDrawtoField(DRAW_BACKBUFFER); #endif @@ -1418,7 +1446,7 @@ void DrawMainMenuExt(int fade_mask, boolean do_fading) InitializeMainControls(); DrawCursorAndText_Main(-1, FALSE); - DrawPreviewLevel(TRUE); + DrawPreviewLevelInitial(); HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE); @@ -1735,7 +1763,7 @@ void HandleMainMenu_SelectLevel(int step, int direction) { /* skipping levels is only allowed when trying to skip single level */ if (setup.skip_levels && step == 1 && - Request("Level still unsolved ! Skip despite handicap ?", REQ_ASK)) + Request("Level still unsolved! Skip despite handicap?", REQ_ASK)) { leveldir_current->handicap_level++; SaveLevelSetup_SeriesInfo(); @@ -1757,13 +1785,13 @@ void HandleMainMenu_SelectLevel(int step, int direction) mci->pos_text->font); LoadLevel(level_nr); - DrawPreviewLevel(TRUE); + DrawPreviewLevelInitial(); TapeErase(); LoadTape(level_nr); DrawCompleteVideoDisplay(); - /* needed because DrawPreviewLevel() takes some time */ + /* needed because DrawPreviewLevelInitial() takes some time */ BackToFront(); SyncDisplay(); } @@ -1884,7 +1912,9 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) { if (leveldir_current->readonly && !strEqual(setup.player_name, "Artsoft")) - Request("This level is read only !", REQ_CONFIRM); + Request("This level is read only!", REQ_CONFIRM); + + CloseDoor(DOOR_CLOSE_2); game_status = GAME_MODE_EDITOR; @@ -1920,17 +1950,19 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) SaveLevelSetup_LastSeries(); SaveLevelSetup_SeriesInfo(); - if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED)) + if (Request("Do you really want to quit?", REQ_ASK | REQ_STAY_CLOSED)) game_status = GAME_MODE_QUIT; } } } +#if 0 if (game_status == GAME_MODE_MAIN) { - DrawPreviewLevel(FALSE); + DrawPreviewLevelAnimation(); DoAnimation(); } +#endif } @@ -3303,7 +3335,9 @@ void HandleInfoScreen(int mx, int my, int dx, int dy, int button) else HandleInfoScreen_Main(mx, my, dx, dy, button); +#if 0 DoAnimation(); +#endif } @@ -3613,11 +3647,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 || @@ -3808,11 +3843,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 || @@ -3849,7 +3885,9 @@ void HandleChooseLevelSet(int mx, int my, int dx, int dy, int button) { HandleChooseTree(mx, my, dx, dy, button, &leveldir_current); +#if 0 DoAnimation(); +#endif } void DrawChooseLevelNr() @@ -3920,7 +3958,9 @@ void HandleChooseLevelNr(int mx, int my, int dx, int dy, int button) HandleChooseTree(mx, my, dx, dy, button, &leveldir_current); #endif +#if 0 DoAnimation(); +#endif } void DrawHallOfFame(int highlight_position) @@ -4066,7 +4106,9 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button) if (game_status == GAME_MODE_SCORES) PlayMenuSoundIfLoop(); +#if 0 DoAnimation(); +#endif } @@ -4079,6 +4121,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; @@ -4095,7 +4138,7 @@ static void execSetupMain() DrawSetupScreen(); } -static void execSetupGame() +static void execSetupGame_setGameSpeeds() { if (game_speeds == NULL) { @@ -4143,6 +4186,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; @@ -4156,6 +4255,13 @@ static void execSetupChooseGameSpeed() DrawSetupScreen(); } +static void execSetupChooseScrollDelay() +{ + setup_mode = SETUP_MODE_CHOOSE_SCROLL_DELAY; + + DrawSetupScreen(); +} + static void execSetupEditor() { setup_mode = SETUP_MODE_EDITOR; @@ -4248,6 +4354,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) @@ -4309,69 +4465,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) @@ -4387,6 +4508,13 @@ static void execSetupChooseWindowSize() DrawSetupScreen(); } + +static void execSetupChooseScalingType() +{ + setup_mode = SETUP_MODE_CHOOSE_SCALING_TYPE; + + DrawSetupScreen(); +} #else static void execSetupChooseScreenMode() { @@ -4400,13 +4528,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; @@ -4707,6 +4828,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" }, @@ -4753,6 +4878,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, "" }, @@ -4761,8 +4890,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 @@ -5154,6 +5285,10 @@ static void changeSetupValue(int pos, int dx) } drawSetupValue(pos); + + // fullscreen state may have changed at this point + if (setup_info[pos].value == &setup.fullscreen) + ToggleFullscreenOrChangeWindowScalingIfNeeded(); } static void DrawCursorAndText_Setup(int pos, boolean active) @@ -5279,7 +5414,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)) @@ -5344,7 +5480,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) { @@ -6113,12 +6250,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) @@ -6144,7 +6283,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(); @@ -6161,12 +6300,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) @@ -6182,7 +6323,9 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) else HandleSetupScreen_Generic(mx, my, dx, dy, button); +#if 0 DoAnimation(); +#endif } void HandleGameActions()