X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fscreens.c;h=d6377c1d4254aa70921996e9aa79a2cbab898008;hp=2c19101321ecd273e24d0fe475a1c15ac51f525d;hb=4239ba2adc93afb81230b1a4ea42e7eaf68452c6;hpb=bb0b4d6b538a625aaa98a25190891ef1fb766168 diff --git a/src/screens.c b/src/screens.c index 2c191013..d6377c1d 100644 --- a/src/screens.c +++ b/src/screens.c @@ -63,17 +63,18 @@ #define SETUP_MODE_CHOOSE_SNAPSHOT_MODE 18 #define SETUP_MODE_CHOOSE_WINDOW_SIZE 19 #define SETUP_MODE_CHOOSE_SCALING_TYPE 20 -#define SETUP_MODE_CHOOSE_GRAPHICS 21 -#define SETUP_MODE_CHOOSE_SOUNDS 22 -#define SETUP_MODE_CHOOSE_MUSIC 23 -#define SETUP_MODE_CHOOSE_VOLUME_SIMPLE 24 -#define SETUP_MODE_CHOOSE_VOLUME_LOOPS 25 -#define SETUP_MODE_CHOOSE_VOLUME_MUSIC 26 -#define SETUP_MODE_CHOOSE_TOUCH_CONTROL 27 -#define SETUP_MODE_CHOOSE_MOVE_DISTANCE 28 -#define SETUP_MODE_CHOOSE_DROP_DISTANCE 29 - -#define MAX_SETUP_MODES 30 +#define SETUP_MODE_CHOOSE_RENDERING 21 +#define SETUP_MODE_CHOOSE_GRAPHICS 22 +#define SETUP_MODE_CHOOSE_SOUNDS 23 +#define SETUP_MODE_CHOOSE_MUSIC 24 +#define SETUP_MODE_CHOOSE_VOLUME_SIMPLE 25 +#define SETUP_MODE_CHOOSE_VOLUME_LOOPS 26 +#define SETUP_MODE_CHOOSE_VOLUME_MUSIC 27 +#define SETUP_MODE_CHOOSE_TOUCH_CONTROL 28 +#define SETUP_MODE_CHOOSE_MOVE_DISTANCE 29 +#define SETUP_MODE_CHOOSE_DROP_DISTANCE 30 + +#define MAX_SETUP_MODES 31 #define MAX_MENU_MODES MAX(MAX_INFO_MODES, MAX_SETUP_MODES) @@ -201,6 +202,9 @@ static TreeInfo *window_size_current = NULL; static TreeInfo *scaling_types = NULL; static TreeInfo *scaling_type_current = NULL; +static TreeInfo *rendering_modes = NULL; +static TreeInfo *rendering_mode_current = NULL; + static TreeInfo *scroll_delays = NULL; static TreeInfo *scroll_delay_current = NULL; @@ -269,6 +273,20 @@ static struct { NULL, NULL }, }; +static struct +{ + char *value; + char *text; +} rendering_modes_list[] = +{ + { STR_SPECIAL_RENDERING_OFF, "Off (May show artifacts, fast)" }, + { STR_SPECIAL_RENDERING_BITMAP, "Bitmap/Texture mode (slower)" }, + { STR_SPECIAL_RENDERING_TARGET, "Target Texture mode (slower)" }, + { STR_SPECIAL_RENDERING_DOUBLE, "Double Texture mode (slower)" }, + + { NULL, NULL }, +}; + static struct { int value; @@ -707,6 +725,13 @@ static int getTitleMessageGameMode(boolean initial) return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE); } +static int getTitleAnimMode(struct TitleControlInfo *tci) +{ + int base = (tci->initial ? GAME_MODE_TITLE_INITIAL_1 : GAME_MODE_TITLE_1); + + return base + tci->local_nr; +} + #if 0 static int getTitleScreenBackground(boolean initial) { @@ -1229,11 +1254,7 @@ static void drawCursorXY(int xpos, int ypos, int graphic) static void drawChooseTreeCursor(int ypos, boolean active) { - int last_game_status = game_status; /* save current game status */ - drawCursorExt(0, ypos, active, -1); - - SetGameStatus(last_game_status); /* restore current game status */ } void DrawHeadline() @@ -1291,13 +1312,12 @@ void DrawTitleScreenMessage(int nr, boolean initial) { char *filename = getLevelSetTitleMessageFilename(nr, initial); struct TitleMessageInfo *tmi = getTitleMessageInfo(nr, initial); - int last_game_status = game_status; /* save current game status */ if (filename == NULL) return; /* force TITLE font on title message screen */ - SetGameStatus(getTitleMessageGameMode(initial)); + SetFontStatus(getTitleMessageGameMode(initial)); /* if chars *and* width set to "-1", automatically determine width */ if (tmi->chars == -1 && tmi->width == -1) @@ -1336,7 +1356,7 @@ void DrawTitleScreenMessage(int nr, boolean initial) filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1, tmi->autowrap, tmi->centered, tmi->parse_comments); - SetGameStatus(last_game_status); /* restore current game status */ + ResetFontStatus(); } void DrawTitleScreen() @@ -1380,6 +1400,8 @@ void DrawMainMenu() UnmapAllGadgets(); FadeSoundsAndMusic(); + ExpireSoundLoops(FALSE); + KeyboardAutoRepeatOn(); ActivateJoystick(); @@ -1552,6 +1574,8 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) title_screen_nr = 0; tci = &title_controls[title_screen_nr]; + SetAnimStatus(getTitleAnimMode(tci)); + last_sound = SND_UNDEFINED; last_music = MUS_UNDEFINED; @@ -1572,7 +1596,6 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) DrawInfoScreen_NotAvailable("Title screen information:", "No title screen for this level set."); - return; } @@ -1633,10 +1656,13 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) } title_screen_nr++; - tci = &title_controls[title_screen_nr]; if (title_screen_nr < num_title_screens) { + tci = &title_controls[title_screen_nr]; + + SetAnimStatus(getTitleAnimMode(tci)); + sound = getTitleSound(tci); music = getTitleMusic(tci); @@ -3678,7 +3704,6 @@ static void drawChooseTreeList(int first_entry, int num_page_entries, int yoffset_setup = 16; int yoffset = (ti->type == TREE_TYPE_LEVEL_DIR || ti->type == TREE_TYPE_LEVEL_NR ? yoffset_sets : yoffset_setup); - int last_game_status = game_status; /* save current game status */ title_string = ti->infotext; @@ -3718,8 +3743,6 @@ static void drawChooseTreeList(int first_entry, int num_page_entries, initCursor(i, IMG_MENU_BUTTON); } - SetGameStatus(last_game_status); /* restore current game status */ - redraw_mask |= REDRAW_FIELD; } @@ -3767,7 +3790,6 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, int step = (button == 1 ? 1 : button == 2 ? 5 : 10); int num_entries = numTreeInfoInGroup(ti); int num_page_entries; - int last_game_status = game_status; /* save current game status */ boolean position_set_by_scrollbar = (dx == 999); if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN) @@ -3775,8 +3797,6 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, else num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN; - SetGameStatus(last_game_status); /* restore current game status */ - if (button == MB_MENU_INITIALIZE) { int num_entries = numTreeInfoInGroup(ti); @@ -3827,7 +3847,8 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, setup_mode == SETUP_MODE_CHOOSE_SNAPSHOT_MODE) execSetupGame(); else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE || - setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE) + setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE || + setup_mode == SETUP_MODE_CHOOSE_RENDERING) execSetupGraphics(); else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE || setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS || @@ -3859,12 +3880,8 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, if (mx || my) /* mouse input */ { - int last_game_status = game_status; /* save current game status */ - x = (mx - mSX) / 32; y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS; - - SetGameStatus(last_game_status); /* restore current game status */ } else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */ { @@ -4024,7 +4041,8 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, setup_mode == SETUP_MODE_CHOOSE_SNAPSHOT_MODE) execSetupGame(); else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE || - setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE) + setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE || + setup_mode == SETUP_MODE_CHOOSE_RENDERING) execSetupGraphics(); else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE || setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS || @@ -4289,6 +4307,7 @@ static int max_setup_info; /* total number of setup entries in list */ static char *window_size_text; static char *scaling_type_text; +static char *rendering_mode_text; static char *scroll_delay_text; static char *snapshot_mode_text; static char *game_speed_text; @@ -4381,31 +4400,31 @@ static void execSetupGame_setScrollDelays() setString(&ti->identifier, identifier); setString(&ti->name, name); setString(&ti->name_sorting, name); - setString(&ti->infotext, "Scaling Type"); + setString(&ti->infotext, "Scroll Delay"); pushTreeInfo(&scroll_delays, ti); } - /* sort scaling type values to start with lowest scaling type value */ + /* sort scroll delay values to start with lowest scroll delay value */ sortTreeInfo(&scroll_delays); - /* set current scaling type value to configured scaling type value */ + /* 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 scaling type to reliable default 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 scaling type to first available value */ + /* if that also fails, set current scroll delay 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 */ + /* needed for displaying scroll delay text instead of identifier */ scroll_delay_text = scroll_delay_current->name; } @@ -4633,6 +4652,57 @@ static void execSetupGraphics_setScalingTypes() scaling_type_text = scaling_type_current->name; } +static void execSetupGraphics_setRenderingModes() +{ + if (rendering_modes == NULL) + { + int i; + + for (i = 0; rendering_modes_list[i].value != NULL; i++) + { + TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED); + char identifier[32], name[32]; + char *value = rendering_modes_list[i].value; + char *text = rendering_modes_list[i].text; + + ti->node_top = &rendering_modes; + 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, "Special Rendering"); + + pushTreeInfo(&rendering_modes, ti); + } + + /* sort rendering mode values to start with lowest rendering mode value */ + sortTreeInfo(&rendering_modes); + + /* set current rendering mode value to configured rendering mode value */ + rendering_mode_current = + getTreeInfoFromIdentifier(rendering_modes, setup.screen_rendering_mode); + + /* if that fails, set current rendering mode to reliable default value */ + if (rendering_mode_current == NULL) + rendering_mode_current = + getTreeInfoFromIdentifier(rendering_modes, + STR_SPECIAL_RENDERING_DEFAULT); + + /* if that also fails, set current rendering mode to first available one */ + if (rendering_mode_current == NULL) + rendering_mode_current = rendering_modes; + } + + setup.screen_rendering_mode = rendering_mode_current->identifier; + + /* needed for displaying rendering mode text instead of identifier */ + rendering_mode_text = rendering_mode_current->name; +} + static void execSetupGraphics() { if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE) @@ -4647,6 +4717,7 @@ static void execSetupGraphics() } execSetupGraphics_setScalingTypes(); + execSetupGraphics_setRenderingModes(); setup_mode = SETUP_MODE_GRAPHICS; @@ -4659,6 +4730,9 @@ static void execSetupGraphics() // window scaling quality may have changed at this point if (!strEqual(setup.window_scaling_quality, video.window_scaling_quality)) SDLSetWindowScalingQuality(setup.window_scaling_quality); + + // screen rendering mode may have changed at this point + SDLSetScreenRenderingMode(setup.screen_rendering_mode); #endif } @@ -4676,6 +4750,13 @@ static void execSetupChooseScalingType() DrawSetupScreen(); } + +static void execSetupChooseRenderingMode() +{ + setup_mode = SETUP_MODE_CHOOSE_RENDERING; + + DrawSetupScreen(); +} #endif static void execSetupChooseVolumeSimple() @@ -5280,6 +5361,8 @@ static struct TokenInfo setup_info_graphics[] = { TYPE_STRING, &window_size_text, "" }, { TYPE_ENTER_LIST, execSetupChooseScalingType, "Anti-Aliasing:" }, { TYPE_STRING, &scaling_type_text, "" }, + { TYPE_ENTER_LIST, execSetupChooseRenderingMode, "Special Rendering:" }, + { TYPE_STRING, &rendering_mode_text, "" }, #endif #if 0 { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" }, @@ -5531,13 +5614,22 @@ static int getSetupValueFont(int type, void *value) return FONT_VALUE_1; } +static int getSetupValueFontNarrow(int type, int font_nr) +{ + return (font_nr == FONT_VALUE_1 ? FONT_VALUE_NARROW : + font_nr == FONT_OPTION_ON ? FONT_OPTION_ON_NARROW : + font_nr == FONT_OPTION_OFF ? FONT_OPTION_OFF_NARROW : + font_nr); +} + static void drawSetupValue(int screen_pos, int setup_info_pos_raw) { int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw); struct TokenInfo *si = &setup_info[si_pos]; boolean font_draw_xoffset_modified = FALSE; + boolean scrollbar_needed = (num_setup_info < max_setup_info); int font_draw_xoffset_old = -1; - int xoffset = (num_setup_info < max_setup_info ? -1 : 0); + int xoffset = (scrollbar_needed ? -1 : 0); int menu_screen_value_xpos = MENU_SCREEN_VALUE_XPOS + xoffset; int menu_screen_max_xpos = MENU_SCREEN_MAX_XPOS + xoffset; int xpos = menu_screen_value_xpos; @@ -5579,6 +5671,26 @@ static void drawSetupValue(int screen_pos, int setup_info_pos_raw) font_nr = getSetupValueFont(type, value); font_width = getFontWidth(font_nr); + // special check if right-side setup values moved left due to scrollbar + if (scrollbar_needed && xpos > MENU_SCREEN_START_XPOS) + { + int max_menu_text_length = 26; // maximum text length for classic menu + int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset; + int text_startx = mSX + MENU_SCREEN_START_XPOS * 32; + int text_font_nr = getMenuTextFont(FONT_MENU_2); + int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset; + int text_width = max_menu_text_length * getFontWidth(text_font_nr); + + if (startx + font_xoffset < text_startx + text_width + text_font_xoffset) + { + xpos += 1; + startx = mSX + xpos * 32; + + font_nr = getSetupValueFontNarrow(type, font_nr); + font_width = getFontWidth(font_nr); + } + } + /* downward compatibility correction for Juergen Bonhagen's menu settings */ if (setup_mode != SETUP_MODE_INPUT) { @@ -6418,6 +6530,8 @@ void DrawSetupScreen() DrawChooseTree(&window_size_current); else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE) DrawChooseTree(&scaling_type_current); + else if (setup_mode == SETUP_MODE_CHOOSE_RENDERING) + DrawChooseTree(&rendering_mode_current); else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS) DrawChooseTree(&artwork.gfx_current); else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS) @@ -6469,6 +6583,8 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) HandleChooseTree(mx, my, dx, dy, button, &window_size_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_RENDERING) + HandleChooseTree(mx, my, dx, dy, button, &rendering_mode_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) @@ -6817,14 +6933,10 @@ static void CreateScreenScrollbars() void CreateScreenGadgets() { - int last_game_status = game_status; /* save current game status */ - CreateScreenMenubuttons(); CreateScreenScrollbuttons(); CreateScreenScrollbars(); - - SetGameStatus(last_game_status); /* restore current game status */ } void FreeScreenGadgets()