X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fscreens.c;h=716bf3c56c2f37508280f8b7893854292d52ea52;hp=43198fa8a2d5138fdd78c631588cd19802985b79;hb=24b64f626ba95db5e0529b63bf29909834fe3034;hpb=6e9813476a7d45f1f6fba23357e10b3aff33c0c2 diff --git a/src/screens.c b/src/screens.c index 43198fa8..716bf3c5 100644 --- a/src/screens.c +++ b/src/screens.c @@ -4751,7 +4751,7 @@ static void execSetupMain(void) DrawSetupScreen(); } -static void execSetupGame_setGameSpeeds(void) +static void execSetupGame_setGameSpeeds(boolean update_value) { if (game_speeds == NULL) { @@ -4781,6 +4781,11 @@ static void execSetupGame_setGameSpeeds(void) /* sort game speed values to start with slowest game speed */ sortTreeInfo(&game_speeds); + update_value = TRUE; + } + + if (update_value) + { /* set current game speed to configured game speed value */ game_speed_current = getTreeInfoFromIdentifier(game_speeds, i_to_a(setup.game_frame_delay)); @@ -4918,9 +4923,32 @@ static void execSetupGame_setNetworkServerText(void) network_server_text = network_server_hostname; } +static void CheckGameSpeedForVsync(boolean force_vsync_game_speed) +{ + if (strEqual(setup.vsync_mode, STR_VSYNC_MODE_OFF) || + setup.game_frame_delay <= MAX_VSYNC_FRAME_DELAY) + return; + + if (force_vsync_game_speed) + { + /* set game speed to existing list value that is fast enough for vsync */ + setup.game_frame_delay = 15; + + execSetupGame_setGameSpeeds(TRUE); + + Request("Game speed was set to \"fast\" for VSync to work!", REQ_CONFIRM); + } + else + { + Request("Warning! Game speed too low for VSync to work!", REQ_CONFIRM); + } +} + static void execSetupGame(void) { - execSetupGame_setGameSpeeds(); + boolean check_vsync_game_speed = (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED); + + execSetupGame_setGameSpeeds(FALSE); execSetupGame_setScrollDelays(); execSetupGame_setSnapshotModes(); @@ -4929,6 +4957,10 @@ static void execSetupGame(void) setup_mode = SETUP_MODE_GAME; DrawSetupScreen(); + + // check if game speed is high enough for 60 Hz vsync to work + if (check_vsync_game_speed) + CheckGameSpeedForVsync(FALSE); } static void execSetupChooseGameSpeed(void) @@ -5197,6 +5229,8 @@ static void execSetupGraphics_setVsyncModes(void) static void execSetupGraphics(void) { + boolean check_vsync_game_speed = (setup_mode == SETUP_MODE_CHOOSE_VSYNC); + // 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) @@ -5214,6 +5248,10 @@ static void execSetupGraphics(void) DrawSetupScreen(); + // check if game speed is high enough for 60 Hz vsync to work + if (check_vsync_game_speed) + CheckGameSpeedForVsync(TRUE); + #if defined(TARGET_SDL2) // window scaling may have changed at this point ToggleFullscreenOrChangeWindowScalingIfNeeded(); @@ -6489,10 +6527,12 @@ static void drawSetupValue(int screen_pos, int setup_info_pos_raw) int ypos = MENU_SCREEN_START_YPOS + screen_pos; int startx = mSX + xpos * 32; int starty = mSY + ypos * 32; - int font_nr, font_nr_default, font_width_default; int type = si->type; void *value = si->value; char *value_string = getSetupValue(type, value); + int font_nr_default = getSetupValueFont(type, value); + int font_width_default = getFontWidth(font_nr_default); + int font_nr = font_nr_default; int i; if (value_string == NULL) @@ -6507,7 +6547,7 @@ static void drawSetupValue(int screen_pos, int setup_info_pos_raw) } else if (type & TYPE_STRING) { - int max_value_len = (SCR_FIELDX - 2) * 2; + int max_value_len = (SXSIZE - 2 * TILEX) / font_width_default; xpos = MENU_SCREEN_START_XPOS; @@ -6527,10 +6567,6 @@ static void drawSetupValue(int screen_pos, int setup_info_pos_raw) startx = mSX + xpos * 32; starty = mSY + ypos * 32; - font_nr_default = getSetupValueFont(type, value); - font_width_default = getFontWidth(font_nr_default); - - font_nr = font_nr_default; // special check if right-side setup values moved left due to scrollbar if (scrollbar_needed && xpos > MENU_SCREEN_START_XPOS) @@ -6596,10 +6632,17 @@ static void drawSetupValue(int screen_pos, int setup_info_pos_raw) if (type & TYPE_PLAYER) { + struct FontBitmapInfo *font = getFontBitmapInfo(font_nr); int player_nr = *(int *)value; - int xoff = getFontWidth(font_nr); + int xoff = font->draw_xoffset + getFontWidth(font_nr); + int yoff = font->draw_yoffset + (getFontHeight(font_nr) - TILEY) / 2; + int startx2 = startx + xoff; + int starty2 = starty + yoff; + + if (DrawingOnBackground(startx2, starty2)) + ClearRectangleOnBackground(drawto, startx2, starty2, TILEX, TILEY); - DrawFixedGraphicThruMaskExt(drawto, startx + xoff, starty, + DrawFixedGraphicThruMaskExt(drawto, startx2, starty2, PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0); }