X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fscreens.c;h=6ece1110727fd797d8743884607b9a33c298c6d7;hp=94eb8895e723a87c1731916810607f865d30370e;hb=00383dd409fde133c6738231abfcee662c03087c;hpb=d0409bd76aa84a8745ec2ea6d8a5480c8bea0bcd diff --git a/src/screens.c b/src/screens.c index 94eb8895..6ece1110 100644 --- a/src/screens.c +++ b/src/screens.c @@ -18,7 +18,7 @@ #include "editor.h" #include "files.h" #include "tape.h" -#include "cartoons.h" +#include "anim.h" #include "network.h" #include "init.h" #include "config.h" @@ -278,7 +278,10 @@ static struct { { STR_SPECIAL_RENDERING_OFF, "Off (May show artifacts, fast)" }, { STR_SPECIAL_RENDERING_BITMAP, "Bitmap/Texture mode (slower)" }, +#if DEBUG + // this mode may work under certain conditions, but does not work on Windows { STR_SPECIAL_RENDERING_TARGET, "Target Texture mode (slower)" }, +#endif { STR_SPECIAL_RENDERING_DOUBLE, "Double Texture mode (slower)" }, { NULL, NULL }, @@ -380,6 +383,7 @@ static struct { { TOUCH_CONTROL_VIRTUAL_BUTTONS, "Virtual Buttons" }, { TOUCH_CONTROL_WIPE_GESTURES, "Wipe Gestures" }, + { TOUCH_CONTROL_FOLLOW_FINGER, "Follow Finger" }, { NULL, NULL }, }; @@ -1181,6 +1185,17 @@ static boolean insideTextPosRect(struct TextPosInfo *rect, int x, int y) y >= rect_y && y < rect_y + rect->height); } +static boolean insidePreviewRect(struct PreviewInfo *preview, int x, int y) +{ + int rect_width = preview->xsize * preview->tile_size; + int rect_height = preview->ysize * preview->tile_size; + int rect_x = ALIGNED_XPOS(preview->x, rect_width, preview->align); + int rect_y = ALIGNED_YPOS(preview->y, rect_height, preview->valign); + + return (x >= rect_x && x < rect_x + rect_width && + y >= rect_y && y < rect_y + rect_height); +} + static void AdjustScrollbar(int id, int items_max, int items_visible, int item_position) { @@ -1361,8 +1376,6 @@ void DrawTitleScreen() KeyboardAutoRepeatOff(); HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE); - - StopAnimation(); } boolean CheckTitleScreen(boolean levelset_has_changed) @@ -1448,9 +1461,6 @@ void DrawMainMenu() return; } - /* needed if different viewport properties defined for menues */ - ChangeViewportPropertiesIfNeeded(); - if (redraw_mask & REDRAW_ALL) fade_mask = REDRAW_ALL; @@ -1459,7 +1469,10 @@ void DrawMainMenu() FadeOut(fade_mask); - SetDrawtoField(DRAW_BACKBUFFER); + /* needed if different viewport properties defined for menues */ + ChangeViewportPropertiesIfNeeded(); + + SetDrawtoField(DRAW_TO_BACKBUFFER); /* level_nr may have been set to value over handicap with level editor */ if (setup.handicap && level_nr > leveldir_current->handicap_level) @@ -1521,8 +1534,6 @@ void DrawMainMenu() SetMouseCursor(CURSOR_DEFAULT); - InitAnimation(); - OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2); } @@ -1601,12 +1612,12 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) FadeOut(REDRAW_ALL); - /* only required to update logic for redrawing global border */ - ClearField(); - /* title screens may have different window size */ ChangeViewportPropertiesIfNeeded(); + /* only required to update logic for redrawing global border */ + ClearField(); + if (tci->is_image) DrawTitleScreenImage(tci->local_nr, tci->initial); else @@ -1663,9 +1674,9 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) sound = getTitleSound(tci); music = getTitleMusic(tci); - if (sound == SND_UNDEFINED || sound != last_sound) - FadeSounds(); - if (music == MUS_UNDEFINED || music != last_music) + if (last_sound != SND_UNDEFINED && sound != last_sound) + FadeSound(last_sound); + if (last_music != MUS_UNDEFINED && music != last_music) FadeMusic(); fading = getTitleFading(tci); @@ -1808,6 +1819,10 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) } } + /* check if level preview was clicked */ + if (insidePreviewRect(&preview, mx - SX, my - SY)) + pos = MAIN_CONTROL_GAME; + // handle pressed/unpressed state for active/inactive menu buttons // (if pos != -1, "i" contains index position corresponding to "pos") if (button && @@ -1848,14 +1863,10 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) } else if (pos == MAIN_CONTROL_LEVEL_NUMBER && !button) { - StopAnimation(); - CloseDoor(DOOR_CLOSE_2); SetGameStatus(GAME_MODE_LEVELNR); - ChangeViewportPropertiesIfNeeded(); - DrawChooseLevelNr(); } else if (pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT) @@ -1886,8 +1897,6 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) { if (leveldir_first) { - StopAnimation(); - CloseDoor(DOOR_CLOSE_2); SetGameStatus(GAME_MODE_LEVELS); @@ -1898,15 +1907,11 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) if (setup.internal.choose_from_top_leveldir) gotoTopLevelDir(); - ChangeViewportPropertiesIfNeeded(); - DrawChooseLevelSet(); } } else if (pos == MAIN_CONTROL_SCORES) { - StopAnimation(); - CloseDoor(DOOR_CLOSE_2); SetGameStatus(GAME_MODE_SCORES); @@ -1919,8 +1924,6 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) !strEqual(setup.player_name, "Artsoft")) Request("This level is read only!", REQ_CONFIRM); - StopAnimation(); - CloseDoor(DOOR_CLOSE_2); SetGameStatus(GAME_MODE_EDITOR); @@ -1931,36 +1934,26 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) } else if (pos == MAIN_CONTROL_INFO) { - StopAnimation(); - CloseDoor(DOOR_CLOSE_2); SetGameStatus(GAME_MODE_INFO); info_mode = INFO_MODE_MAIN; - ChangeViewportPropertiesIfNeeded(); - DrawInfoScreen(); } else if (pos == MAIN_CONTROL_GAME) { - StopAnimation(); - StartGameActions(options.network, setup.autorecord, level.random_seed); } else if (pos == MAIN_CONTROL_SETUP) { - StopAnimation(); - CloseDoor(DOOR_CLOSE_2); SetGameStatus(GAME_MODE_SETUP); setup_mode = SETUP_MODE_MAIN; - ChangeViewportPropertiesIfNeeded(); - DrawSetupScreen(); } else if (pos == MAIN_CONTROL_QUIT) @@ -2179,8 +2172,11 @@ static void DrawInfoScreen_Main() FadeOut(fade_mask); + /* needed if different viewport properties defined for info screen */ ChangeViewportPropertiesIfNeeded(); + SetMainBackgroundImage(IMG_BACKGROUND_INFO); + ClearField(); OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); @@ -2209,8 +2205,6 @@ static void DrawInfoScreen_Main() DrawMaskedBorder(fade_mask); FadeIn(fade_mask); - - InitAnimation(); } static void changeSetupValue(int, int, int); @@ -2708,8 +2702,6 @@ void DrawInfoScreen_Elements() HandleInfoScreen_Elements(MB_MENU_INITIALIZE); FadeIn(REDRAW_FIELD); - - InitAnimation(); } void HandleInfoScreen_Elements(int button) @@ -3520,8 +3512,6 @@ void HandleInfoScreen_LevelSet(int button) static void DrawInfoScreen() { - SetMainBackgroundImage(IMG_BACKGROUND_INFO); - if (info_mode == INFO_MODE_TITLE) DrawInfoScreen_TitleScreen(); else if (info_mode == INFO_MODE_ELEMENTS) @@ -3596,9 +3586,7 @@ void HandleTypeName(int newxpos, Key key) xpos = newxpos; -#if defined(TARGET_SDL2) - SDL_StartTextInput(); -#endif + StartTextInput(startx, starty, pos->width, pos->height); } else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN) { @@ -3645,9 +3633,7 @@ void HandleTypeName(int newxpos, Key key) DrawText(startx, starty, setup.player_name, font_nr); -#if defined(TARGET_SDL2) - SDL_StopTextInput(); -#endif + StopTextInput(); } } @@ -3679,6 +3665,14 @@ static void DrawChooseTree(TreeInfo **ti_ptr) FadeOut(fade_mask); + /* needed if different viewport properties defined for choosing level (set) */ + ChangeViewportPropertiesIfNeeded(); + + if (game_status == GAME_MODE_LEVELNR) + SetMainBackgroundImage(IMG_BACKGROUND_LEVELNR); + else if (game_status == GAME_MODE_LEVELS) + SetMainBackgroundImage(IMG_BACKGROUND_LEVELS); + ClearField(); OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); @@ -3689,8 +3683,6 @@ static void DrawChooseTree(TreeInfo **ti_ptr) DrawMaskedBorder(fade_mask); FadeIn(fade_mask); - - InitAnimation(); } static void drawChooseTreeList(int first_entry, int num_page_entries, @@ -4075,8 +4067,6 @@ void DrawChooseLevelSet() { FadeSoundsAndMusic(); - SetMainBackgroundImage(IMG_BACKGROUND_LEVELS); - DrawChooseTree(&leveldir_current); PlayMenuSound(); @@ -4138,8 +4128,6 @@ void DrawChooseLevelNr() if (level_number_current == NULL) level_number_current = level_number; - SetMainBackgroundImage(IMG_BACKGROUND_LEVELNR); - DrawChooseTree(&level_number_current); PlayMenuSound(); @@ -4155,9 +4143,6 @@ void DrawHallOfFame(int highlight_position) { int fade_mask = REDRAW_FIELD; - /* needed if different viewport properties defined for scores */ - ChangeViewportPropertiesIfNeeded(); - if (CheckIfGlobalBorderHasChanged()) fade_mask = REDRAW_ALL; @@ -4179,7 +4164,8 @@ void DrawHallOfFame(int highlight_position) FadeOut(fade_mask); - InitAnimation(); + /* needed if different viewport properties defined for scores */ + ChangeViewportPropertiesIfNeeded(); PlayMenuSound(); PlayMenuMusic(); @@ -4212,9 +4198,10 @@ static void drawHallOfFameList(int first_entry, int highlight_position) int font_nr2 = (active ? FONT_TEXT_2_ACTIVE : FONT_TEXT_2); int font_nr3 = (active ? FONT_TEXT_3_ACTIVE : FONT_TEXT_3); int font_nr4 = (active ? FONT_TEXT_4_ACTIVE : FONT_TEXT_4); + int dxoff = getFontDrawOffsetX(font_nr1); int dx1 = 3 * getFontWidth(font_nr1); int dx2 = dx1 + getFontWidth(font_nr1); - int dx3 = SXSIZE - 2 * (mSX - SX) - 5 * getFontWidth(font_nr4); + int dx3 = SXSIZE - 2 * (mSX - SX + dxoff) - 5 * getFontWidth(font_nr4); int num_dots = (dx3 - dx2) / getFontWidth(font_nr3); int sy = mSY + 64 + i * 32; @@ -4707,16 +4694,14 @@ static void execSetupGraphics_setRenderingModes() static void execSetupGraphics() { + // update "setup.window_scaling_percent" from list selection + // (in this case, window scaling was changed on setup screen) if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE) - { - // update "setup.window_scaling_percent" from list selection execSetupGraphics_setWindowSizes(FALSE); - } - else - { - // update list selection from "setup.window_scaling_percent" - execSetupGraphics_setWindowSizes(TRUE); - } + + // update list selection from "setup.window_scaling_percent" + // (window scaling may have changed by resizing the window) + execSetupGraphics_setWindowSizes(TRUE); execSetupGraphics_setScalingTypes(); execSetupGraphics_setRenderingModes(); @@ -5441,6 +5426,16 @@ static struct TokenInfo setup_info_input[] = }; static struct TokenInfo setup_info_touch[] = +{ + { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" }, + { TYPE_STRING, &touch_controls_text, "" }, + { TYPE_EMPTY, NULL, "" }, + { TYPE_LEAVE_MENU, execSetupMain, "Back" }, + + { 0, NULL, NULL } +}; + +static struct TokenInfo setup_info_touch_wipe_gestures[] = { { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" }, { TYPE_STRING, &touch_controls_text, "" }, @@ -5590,7 +5585,6 @@ static Key getSetupKey() } } - DoAnimation(); BackToFront(); } @@ -5798,6 +5792,11 @@ static void DrawSetupScreen_Generic() FadeOut(fade_mask); + /* needed if different viewport properties defined for setup screen */ + ChangeViewportPropertiesIfNeeded(); + + SetMainBackgroundImage(IMG_BACKGROUND_SETUP); + ClearField(); OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); @@ -5836,6 +5835,9 @@ static void DrawSetupScreen_Generic() { setup_info = setup_info_touch; title_string = "Setup Touch Ctrls"; + + if (strEqual(setup.touch.control_type, TOUCH_CONTROL_WIPE_GESTURES)) + setup_info = setup_info_touch_wipe_gestures; } else if (setup_mode == SETUP_MODE_SHORTCUTS) { @@ -5890,8 +5892,6 @@ static void DrawSetupScreen_Generic() DrawMaskedBorder(fade_mask); FadeIn(fade_mask); - - InitAnimation(); } void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button) @@ -5939,8 +5939,6 @@ void DrawSetupScreen_Input() HandleSetupScreen_Input(0, 0, 0, 0, MB_MENU_INITIALIZE); FadeIn(REDRAW_FIELD); - - InitAnimation(); } static void setJoystickDeviceToNr(char *device_name, int device_nr) @@ -6221,8 +6219,6 @@ void CustomizeKeyboard(int player_nr) FadeIn(REDRAW_FIELD); - InitAnimation(); - while (!finished) { if (PendingEvent()) /* got event */ @@ -6304,14 +6300,12 @@ void CustomizeKeyboard(int player_nr) } } - DoAnimation(); BackToFront(); } /* write new key bindings back to player setup */ setup.input[player_nr].key = custom_key; - StopAnimation(); DrawSetupScreen_Input(); } @@ -6375,7 +6369,6 @@ static boolean CalibrateJoystickMain(int player_nr) FadeIn(REDRAW_FIELD); while (Joystick(player_nr) & JOY_BUTTON); /* wait for released button */ - InitAnimation(); while (result < 0) { @@ -6457,7 +6450,6 @@ static boolean CalibrateJoystickMain(int player_nr) } } - DoAnimation(); BackToFront(); } @@ -6468,8 +6460,6 @@ static boolean CalibrateJoystickMain(int player_nr) new_joystick_xmiddle = joy_x; new_joystick_ymiddle = joy_y; - StopAnimation(); - /* wait until the last pressed button was released */ while (Joystick(player_nr) & JOY_BUTTON) { @@ -6514,8 +6504,6 @@ void DrawSetupScreen() { DeactivateJoystick(); - SetMainBackgroundImage(IMG_BACKGROUND_SETUP); - if (setup_mode == SETUP_MODE_INPUT) DrawSetupScreen_Input(); else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)