X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fscreens.c;h=040a45c56a47dbdadc2d61af9d8d63be172c2889;hb=5d60005061cc4800bdb15008663986f80041b12c;hp=0e97d4a7f42acab71d678476604d3146537d84bc;hpb=e7f55d5c910dda112a96f3cf9306a2cce1f7c77e;p=rocksndiamonds.git diff --git a/src/screens.c b/src/screens.c index 0e97d4a7..040a45c5 100644 --- a/src/screens.c +++ b/src/screens.c @@ -4,7 +4,7 @@ // (c) 1995-2014 by Artsoft Entertainment // Holger Schemel // info@artsoft.org -// http://www.artsoft.org/ +// https://www.artsoft.org/ // ---------------------------------------------------------------------------- // screens.c // ============================================================================ @@ -252,6 +252,7 @@ static void DrawChooseLevelSet(void); static void DrawChooseLevelNr(void); static void DrawInfoScreen(void); static void DrawSetupScreen(void); +static void DrawTypeName(void); static void DrawInfoScreen_NotAvailable(char *, char *); static void DrawInfoScreen_HelpAnim(int, int, boolean); @@ -540,7 +541,9 @@ static int align_yoffset = 0; #define DRAW_MODE(s) ((s) >= GAME_MODE_MAIN && \ (s) <= GAME_MODE_SETUP ? (s) : \ (s) == GAME_MODE_PSEUDO_TYPENAME ? \ - GAME_MODE_MAIN : GAME_MODE_DEFAULT) + GAME_MODE_MAIN : \ + (s) == GAME_MODE_PSEUDO_TYPENAMES ? \ + GAME_MODE_NAMES : GAME_MODE_DEFAULT) // (there are no draw offset definitions needed for INFO_MODE_TITLE) #define DRAW_MODE_INFO(i) ((i) >= INFO_MODE_TITLE && \ @@ -680,6 +683,8 @@ static char *main_text_title_1 = NULL; static char *main_text_title_2 = NULL; static char *main_text_title_3 = NULL; +extern char debug_xsn_mode[]; + struct MainControlInfo { int nr; @@ -928,10 +933,10 @@ static int getTitleSound(struct TitleControlInfo *tci) int sound_local = base + nr; #if 0 - printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n", - nr, initial, is_image, - sound_global, getSoundListEntry(sound_global)->filename, - sound_local, getSoundListEntry(sound_local)->filename); + Debug("screens:getTitleSound", "%d, %d, %d: %d ['%s'], %d ['%s']", + nr, initial, is_image, + sound_global, getSoundListEntry(sound_global)->filename, + sound_local, getSoundListEntry(sound_local)->filename); #endif if (!strEqual(getSoundListEntry(sound_local)->filename, UNDEFINED_FILENAME)) @@ -958,10 +963,10 @@ static int getTitleMusic(struct TitleControlInfo *tci) int music_local = base + nr; #if 0 - printf("::: %d, %d, %d: %d ['%s'], %d ['%s']\n", - nr, initial, is_image, - music_global, getMusicListEntry(music_global)->filename, - music_local, getMusicListEntry(music_local)->filename); + Debug("screens:getTitleMusic", "%d, %d, %d: %d ['%s'], %d ['%s']", + nr, initial, is_image, + music_global, getMusicListEntry(music_global)->filename, + music_local, getMusicListEntry(music_local)->filename); #endif if (!strEqual(getMusicListEntry(music_local)->filename, UNDEFINED_FILENAME)) @@ -1326,10 +1331,11 @@ static boolean insideTextPosRect(struct TextPosInfo *rect, int x, int y) int rect_y = ALIGNED_TEXT_YPOS(rect); #if 0 - printf("::: insideTextPosRect: (%d, %d), (%d, %d) [%d, %d] (%d, %d) => %d\n", - x, y, rect_x, rect_y, rect->x, rect->y, rect->width, rect->height, - (x >= rect_x && x < rect_x + rect->width && - y >= rect_y && y < rect_y + rect->height)); + Debug("screens:insideTextPosRect", + "(%d, %d), (%d, %d) [%d, %d] (%d, %d) => %d", + x, y, rect_x, rect_y, rect->x, rect->y, rect->width, rect->height, + (x >= rect_x && x < rect_x + rect->width && + y >= rect_y && y < rect_y + rect->height)); #endif return (x >= rect_x && x < rect_x + rect->width && @@ -1580,10 +1586,6 @@ void DrawMainMenu(void) return; } - // needed if last screen was the setup screen and fullscreen state changed - // (moved to "execSetupGraphics()" to change fullscreen state directly) - // ToggleFullscreenOrChangeWindowScalingIfNeeded(); - // leveldir_current may be invalid (level group, parent link) if (!validLevelSeries(leveldir_current)) leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid); @@ -2081,7 +2083,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) { SetGameStatus(GAME_MODE_PSEUDO_TYPENAME); - HandleTypeName(strlen(setup.player_name), 0); + DrawTypeName(); } } else if (pos == MAIN_CONTROL_LEVELS) @@ -3684,7 +3686,9 @@ static void DrawInfoScreen_Version(void) } DrawTextF(xstart1, ystart, font_head, "Platform"); - DrawTextF(xstart2, ystart, font_text, PLATFORM_STRING); + DrawTextF(xstart2, ystart, font_text, "%s (%s)", + PLATFORM_STRING, + PLATFORM_XX_BIT_STRING); ystart += ystep_line; DrawTextF(xstart1, ystart, font_head, "Target"); @@ -3693,6 +3697,10 @@ static void DrawInfoScreen_Version(void) DrawTextF(xstart1, ystart, font_head, "Source date"); DrawTextF(xstart2, ystart, font_text, getSourceDateString()); + ystart += ystep_line; + + DrawTextF(xstart1, ystart, font_head, "Commit hash"); + DrawTextF(xstart2, ystart, font_text, getSourceHashString()); ystart += ystep_para; DrawTextF(xstart1, ystart, font_head, "Library"); @@ -3762,16 +3770,26 @@ static void DrawInfoScreen_Version(void) DrawTextF(xstart3, ystart, font_head, "Used"); ystart += ystep_head; - driver_name = getStringCopyNStatic(SDL_GetVideoDriver(0), driver_name_len); + driver_name = + getStringCopyNStatic(SDLGetRendererName(), driver_name_len); + + DrawTextF(xstart1, ystart, font_text, "Render Driver"); + DrawTextF(xstart2, ystart, font_text, "%s", setup.system.sdl_renderdriver); + DrawTextF(xstart3, ystart, font_text, "%s", driver_name); + ystart += ystep_line; + + driver_name = + getStringCopyNStatic(SDL_GetCurrentVideoDriver(), driver_name_len); - DrawTextF(xstart1, ystart, font_text, "SDL_VideoDriver"); + DrawTextF(xstart1, ystart, font_text, "Video Driver"); DrawTextF(xstart2, ystart, font_text, "%s", setup.system.sdl_videodriver); DrawTextF(xstart3, ystart, font_text, "%s", driver_name); ystart += ystep_line; - driver_name = getStringCopyNStatic(SDL_GetAudioDriver(0), driver_name_len); + driver_name = + getStringCopyNStatic(SDL_GetCurrentAudioDriver(), driver_name_len); - DrawTextF(xstart1, ystart, font_text, "SDL_AudioDriver"); + DrawTextF(xstart1, ystart, font_text, "Audio Driver"); DrawTextF(xstart2, ystart, font_text, "%s", setup.system.sdl_audiodriver); DrawTextF(xstart3, ystart, font_text, "%s", driver_name); @@ -3945,7 +3963,7 @@ void HandleInfoScreen(int mx, int my, int dx, int dy, int button) // type name functions // ============================================================================ -void HandleTypeName(int newxpos, Key key) +static void HandleTypeNameExt(boolean initialize, Key key) { static char last_player_name[MAX_PLAYER_NAME_LEN + 1]; struct MainControlInfo *mci = getMainControlInfo(MAIN_CONTROL_NAME); @@ -3962,11 +3980,11 @@ void HandleTypeName(int newxpos, Key key) DrawBackgroundForFont(startx,starty, pos->width, pos->height, font_active_nr); - if (newxpos) + if (initialize) { strcpy(last_player_name, setup.player_name); - xpos = newxpos; + xpos = strlen(setup.player_name); StartTextInput(startx, starty, pos->width, pos->height); } @@ -4019,6 +4037,16 @@ void HandleTypeName(int newxpos, Key key) } } +static void DrawTypeName(void) +{ + HandleTypeNameExt(TRUE, 0); +} + +void HandleTypeName(Key key) +{ + HandleTypeNameExt(FALSE, key); +} + // ============================================================================ // tree menu functions @@ -5290,13 +5318,21 @@ static void execSetupGraphics(void) if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE) execSetupGraphics_setWindowSizes(FALSE); + // update "setup.vsync_mode" from list selection + // (in this case, vsync mode was changed on setup screen) + if (setup_mode == SETUP_MODE_CHOOSE_VSYNC) + execSetupGraphics_setVsyncModes(FALSE); + // update list selection from "setup.window_scaling_percent" // (window scaling may have changed by resizing the window) execSetupGraphics_setWindowSizes(TRUE); + // update list selection from "setup.vsync_mode" + // (vsync_mode may have changed by re-creating the renderer) + execSetupGraphics_setVsyncModes(TRUE); + execSetupGraphics_setScalingTypes(); execSetupGraphics_setRenderingModes(); - execSetupGraphics_setVsyncModes(FALSE); setup_mode = SETUP_MODE_GRAPHICS; @@ -5307,7 +5343,7 @@ static void execSetupGraphics(void) ModifyGameSpeedIfNeeded(); // window scaling may have changed at this point - ToggleFullscreenOrChangeWindowScalingIfNeeded(); + ChangeWindowScalingIfNeeded(); // window scaling quality may have changed at this point if (!strEqual(setup.window_scaling_quality, video.window_scaling_quality)) @@ -5316,8 +5352,23 @@ static void execSetupGraphics(void) // screen rendering mode may have changed at this point SDLSetScreenRenderingMode(setup.screen_rendering_mode); + int setup_vsync_mode = VSYNC_MODE_STR_TO_INT(setup.vsync_mode); + int video_vsync_mode = video.vsync_mode; + // screen vsync mode may have changed at this point - SDLSetScreenVsyncMode(setup.vsync_mode); + ChangeVsyncModeIfNeeded(); + + // check if setting vsync mode to selected value failed + if (setup_vsync_mode != video_vsync_mode && + setup_vsync_mode != video.vsync_mode) + { + // changing vsync mode to selected value failed -- reset displayed value + execSetupGraphics_setVsyncModes(TRUE); + + Request("Setting VSync failed!", REQ_CONFIRM); + + DrawSetupScreen(); + } } static void execSetupChooseWindowSize(void) @@ -5920,10 +5971,10 @@ static void execSetupTouch(void) static void execSetupArtwork(void) { #if 0 - printf("::: '%s', '%s', '%s'\n", - artwork.gfx_current->subdir, - artwork.gfx_current->fullpath, - artwork.gfx_current->basepath); + Debug("screens:execSetupArtwork", "'%s', '%s', '%s'", + artwork.gfx_current->subdir, + artwork.gfx_current->fullpath, + artwork.gfx_current->basepath); #endif setup.graphics_set = artwork.gfx_current->identifier; @@ -6258,6 +6309,7 @@ static struct TokenInfo setup_info_game[] = { TYPE_PLAYER, &setup.network_player_nr,"Preferred Network Player:" }, { TYPE_TEXT_INPUT, execGadgetNetworkServer, "Network Server Hostname:" }, { TYPE_STRING, &network_server_text, "" }, + { TYPE_SWITCH, &setup.multiple_users, "Multiple Users/Teams:" }, { TYPE_YES_NO, &setup.input_on_focus, "Only Move Focussed Player:" }, { TYPE_SWITCH, &setup.time_limit, "Time Limit:" }, { TYPE_SWITCH, &setup.handicap, "Handicap:" }, @@ -6355,6 +6407,7 @@ static struct TokenInfo setup_info_graphics[] = { TYPE_SWITCH, &setup.show_titlescreen,"Show Title Screens:" }, { TYPE_SWITCH, &setup.toons, "Show Menu Animations:" }, { TYPE_SWITCH, &setup.small_game_graphics, "Small Game Graphics:" }, + { TYPE_YES_NO_AUTO, &setup.debug.xsn_mode, debug_xsn_mode }, { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execSetupMain, "Back" }, @@ -6725,6 +6778,10 @@ static void drawSetupValue(int screen_pos, int setup_info_pos_raw) if (startx + font_xoffset < text_startx + text_width + text_font_xoffset) { + // when using narrow font, left-shifting text "auto" not needed + if (type & TYPE_YES_NO_AUTO) + xpos += 1; + xpos += 1; startx = mSX + xpos * 32; @@ -6841,7 +6898,7 @@ static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx) // fullscreen state may have changed at this point if (si->value == &setup.fullscreen) - ToggleFullscreenOrChangeWindowScalingIfNeeded(); + ToggleFullscreenIfNeeded(); // network mode may have changed at this point if (si->value == &setup.network_mode) @@ -7511,7 +7568,7 @@ static boolean ConfigureJoystickMapButtonsAndAxes(SDL_Joystick *joystick) Event event; int alpha = 200, alpha_step = -1; int alpha_ticks = 0; - char mapping[4096], temp[4096]; + char mapping[4096], temp[256]; int font_name = MENU_SETUP_FONT_TITLE; int font_info = MENU_SETUP_FONT_TEXT; int spacing_name = menu.line_spacing_setup[SETUP_MODE_INPUT]; @@ -7574,9 +7631,9 @@ static boolean ConfigureJoystickMapButtonsAndAxes(SDL_Joystick *joystick) #if DEBUG_JOYSTICKS // print info about the joystick we are watching - Error(ERR_DEBUG, "watching joystick %d: (%s)\n", + Debug("joystick", "watching joystick %d: (%s)", SDL_JoystickInstanceID(joystick), name); - Error(ERR_DEBUG, "joystick has %d axes, %d hats, %d balls, and %d buttons\n", + Debug("joystick", "joystick has %d axes, %d hats, %d balls, and %d buttons", SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick), SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick)); #endif @@ -7833,7 +7890,7 @@ static boolean ConfigureJoystickMapButtonsAndAxes(SDL_Joystick *joystick) if (success) { #if DEBUG_JOYSTICKS - Error(ERR_DEBUG, "New game controller mapping:\n\n%s\n\n", mapping); + Debug("joystick", "New game controller mapping:\n\n%s\n\n", mapping); #endif // activate mapping for this game @@ -7992,6 +8049,8 @@ static boolean ConfigureVirtualButtonsMain(void) overlay.grid_button_highlight = grid_button[step_nr]; + UnmapAllGadgets(); + FadeSetEnterMenu(); FadeOut(REDRAW_FIELD); @@ -8406,7 +8465,7 @@ void HandleGameActions(void) GameActions(); // main game loop if (tape.auto_play && !tape.playing) - AutoPlayTape(); // continue automatically playing next tape + AutoPlayTapes(); // continue automatically playing next tape } @@ -8680,7 +8739,7 @@ static void CreateScreenMenubuttons(void) GDI_END); if (gi == NULL) - Error(ERR_EXIT, "cannot create gadget"); + Fail("cannot create gadget"); screen_gadget[id] = gi; } @@ -8748,7 +8807,7 @@ static void CreateScreenScrollbuttons(void) GDI_END); if (gi == NULL) - Error(ERR_EXIT, "cannot create gadget"); + Fail("cannot create gadget"); screen_gadget[id] = gi; } @@ -8829,7 +8888,7 @@ static void CreateScreenScrollbars(void) GDI_END); if (gi == NULL) - Error(ERR_EXIT, "cannot create gadget"); + Fail("cannot create gadget"); screen_gadget[id] = gi; } @@ -8875,7 +8934,7 @@ static void CreateScreenTextInputGadgets(void) GDI_END); if (gi == NULL) - Error(ERR_EXIT, "cannot create gadget"); + Fail("cannot create gadget"); screen_gadget[id] = gi; }