X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fscreens.c;h=4dcaef34e2a133b1ea575052dacad39d61270173;hb=576a46a06a23264fbc2345cf591a0dbe7fd2a767;hp=0937577f26b411e625a05550634257599f7482c8;hpb=7edc7ca00edb91a62392337dc612ae8156d3eb2a;p=rocksndiamonds.git diff --git a/src/screens.c b/src/screens.c index 0937577f..4dcaef34 100644 --- a/src/screens.c +++ b/src/screens.c @@ -1957,6 +1957,16 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) } } +static void HandleMainMenu_ToggleTeamMode(void) +{ + setup.team_mode = !setup.team_mode; + + InitializeMainControls(); + DrawCursorAndText_Main(MAIN_CONTROL_NAME, TRUE, FALSE); + + DrawPreviewPlayers(); +} + static void HandleMainMenu_SelectLevel(int step, int direction, int selected_level_nr) { @@ -2106,9 +2116,16 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) } else if (dx != 0) { - if (choice != MAIN_CONTROL_INFO && - choice != MAIN_CONTROL_SETUP) + if (choice == MAIN_CONTROL_NAME) + { + // special case: cursor left or right pressed -- toggle team mode + HandleMainMenu_ToggleTeamMode(); + } + else if (choice != MAIN_CONTROL_INFO && + choice != MAIN_CONTROL_SETUP) + { HandleMainMenu_SelectLevel(1, dx, NO_DIRECT_LEVEL_SELECT); + } } } else @@ -2121,12 +2138,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) insideTextPosRect(main_controls[i].pos_text, mx - mSX, my - mSY)) { // special case: menu text "name/team" clicked -- toggle team mode - setup.team_mode = !setup.team_mode; - - InitializeMainControls(); - DrawCursorAndText_Main(choice, TRUE, FALSE); - - DrawPreviewPlayers(); + HandleMainMenu_ToggleTeamMode(); } else { @@ -2172,7 +2184,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) SetGameStatus(GAME_MODE_SCORES); - DrawHallOfFame(level_nr, -1); + DrawHallOfFame(level_nr); } else if (pos == MAIN_CONTROL_EDITOR) { @@ -5029,7 +5041,7 @@ void HandleChooseLevelNr(int mx, int my, int dx, int dy, int button) HandleChooseTree(mx, my, dx, dy, button, &level_number_current); } -void DrawHallOfFame(int level_nr, int highlight_position) +void DrawHallOfFame(int level_nr) { int fade_mask = REDRAW_FIELD; @@ -5046,9 +5058,9 @@ void DrawHallOfFame(int level_nr, int highlight_position) SetDrawDeactivationMask(REDRAW_NONE); SetDrawBackgroundMask(REDRAW_FIELD); - if (highlight_position < 0) - LoadScore(level_nr); - else + LoadLocalAndServerScore(level_nr, TRUE); + + if (scores.last_added >= 0) SetAnimStatus(GAME_MODE_PSEUDO_SCORESNEW); FadeSetEnterScreen(); @@ -5062,40 +5074,47 @@ void DrawHallOfFame(int level_nr, int highlight_position) OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); - HandleHallOfFame(level_nr, highlight_position, 0, 0, MB_MENU_INITIALIZE); + HandleHallOfFame(level_nr, 0, 0, 0, MB_MENU_INITIALIZE); DrawMaskedBorder(fade_mask); FadeIn(fade_mask); } -static char *getHallOfFameScoreText(int nr) +static int getHallOfFameFirstEntry(int first_entry, int step) { - // use playing time instead of score for Supaplex levels - if (level.game_engine_type == GAME_ENGINE_TYPE_SP) - { - static char score_text[10]; - int time_final_max = 999; - int time_seconds = scores.entry[nr].time / FRAMES_PER_SECOND; - int score = scores.entry[nr].score; + if (step == 0) + first_entry = scores.last_added - (NUM_MENU_ENTRIES_ON_SCREEN + 1) / 2 + 1; + else + first_entry += step; - // convert old score file entries without playing time - if (time_seconds == 0 && score > 0 && score < time_final_max) - time_seconds = time_final_max - score - 1; + if (first_entry < 0) + first_entry = 0; + else if (first_entry > MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN) + first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN); - int mm = (time_seconds / 60) % 60; - int ss = (time_seconds % 60); + return first_entry; +} - sprintf(score_text, "%02d:%02d", mm, ss); +static char *getHallOfFameScoreText(int nr) +{ + if (!level.rate_time_over_score) + return int2str(scores.entry[nr].score, 5); // show normal score - return score_text; - } + if (level.use_step_counter) + return int2str(scores.entry[nr].time, 5); // show number of steps + + static char score_text[10]; + int time_seconds = scores.entry[nr].time / FRAMES_PER_SECOND; + int mm = (time_seconds / 60) % 60; + int ss = (time_seconds % 60); + + sprintf(score_text, "%02d:%02d", mm, ss); // show playing time - return int2str(scores.entry[nr].score, 5); + return score_text; } -static void drawHallOfFameList(int level_nr, int first_entry, - int highlight_position) +static void drawHallOfFameList(int level_nr, int first_entry) { int i, j; @@ -5109,7 +5128,8 @@ static void drawHallOfFameList(int level_nr, int first_entry, for (i = 0; i < NUM_MENU_ENTRIES_ON_SCREEN; i++) { int entry = first_entry + i; - boolean active = (entry == highlight_position); + boolean active = (entry == scores.last_added); + boolean forced = (scores.force_last_added && active); int font_nr1 = (active ? FONT_TEXT_1_ACTIVE : FONT_TEXT_1); int font_nr2 = (active ? FONT_TEXT_2_ACTIVE : FONT_TEXT_2); int font_nr3 = (active ? FONT_TEXT_3_ACTIVE : FONT_TEXT_3); @@ -5120,8 +5140,9 @@ static void drawHallOfFameList(int level_nr, int first_entry, 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; + char *pos_text = (forced ? "???" : int2str(entry + 1, 3)); - DrawText(mSX, sy, int2str(entry + 1, 3), font_nr1); + DrawText(mSX, sy, pos_text, font_nr1); DrawText(mSX + dx1, sy, ".", font_nr1); for (j = 0; j < num_dots; j++) @@ -5140,22 +5161,23 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button) { static int level_nr = 0; static int first_entry = 0; - static int highlight_position = 0; int step = (button == 1 ? 1 : button == 2 ? 5 : 10); if (button == MB_MENU_INITIALIZE) { level_nr = mx; - highlight_position = my; - first_entry = highlight_position - (NUM_MENU_ENTRIES_ON_SCREEN + 1) / 2 + 1; + if (server_scores.updated) + { + // reload scores, using updated server score cache file + LoadLocalAndServerScore(level_nr, FALSE); + + server_scores.updated = FALSE; + } - if (first_entry < 0) - first_entry = 0; - else if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES) - first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN); + first_entry = getHallOfFameFirstEntry(0, 0); - drawHallOfFameList(level_nr, first_entry, highlight_position); + drawHallOfFameList(level_nr, first_entry); return; } @@ -5165,25 +5187,15 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button) if (dy < 0) { - if (first_entry > 0) - { - first_entry -= step; - if (first_entry < 0) - first_entry = 0; + first_entry = getHallOfFameFirstEntry(first_entry, -step); - drawHallOfFameList(level_nr, first_entry, highlight_position); - } + drawHallOfFameList(level_nr, first_entry); } else if (dy > 0) { - if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES) - { - first_entry += step; - if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES) - first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN); + first_entry = getHallOfFameFirstEntry(first_entry, step); - drawHallOfFameList(level_nr, first_entry, highlight_position); - } + drawHallOfFameList(level_nr, first_entry); } else if (button == MB_MENU_LEAVE || button == MB_MENU_CHOICE) { @@ -5206,6 +5218,17 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button) DrawMainMenu(); } } + else if (server_scores.updated) + { + // reload scores, using updated server score cache file + LoadLocalAndServerScore(level_nr, FALSE); + + server_scores.updated = FALSE; + + first_entry = getHallOfFameFirstEntry(0, 0); + + drawHallOfFameList(level_nr, first_entry); + } if (game_status == GAME_MODE_SCORES) PlayMenuSoundIfLoop(); @@ -6747,6 +6770,8 @@ 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.api_server, "Use Highscore Server:" }, + { TYPE_SWITCH, &setup.only_show_local_scores, "Only Show Local Scores:" }, { 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:" }, @@ -6769,7 +6794,8 @@ static struct TokenInfo setup_info_game[] = #endif { TYPE_ENTER_LIST, execSetupChooseSnapshotMode,"Game Engine Snapshot Mode:" }, { TYPE_STRING, &snapshot_mode_text, "" }, - { TYPE_SWITCH, &setup.show_snapshot_buttons,"Show Snapshot Buttons:" }, + { TYPE_SWITCH, &setup.show_load_save_buttons,"Show Load/Save Buttons:" }, + { TYPE_SWITCH, &setup.show_undo_redo_buttons,"Show Undo/Redo Buttons:" }, { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execSetupMain, "Back" }, @@ -7348,6 +7374,10 @@ static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx) if (si->value == &setup.network_mode) ToggleNetworkModeIfNeeded(); + // API server mode may have changed at this point + if (si->value == &setup.api_server) + runtime.api_server = setup.api_server; + // game speed list may have changed at this point if (si->value == &setup.game_speed_extended) ToggleGameSpeedsListIfNeeded();