void scores_maybe_add_player(int abort_flag) { char text1[COOL_MESSAGE_LEN+10]; newmenu_item m[10]; int i,position; #ifdef APPLE_DEMO // no high scores in apple oem version return; #endif if ((gameData.app.nGameMode & GM_MULTI) && !(gameData.app.nGameMode & GM_MULTI_COOP)) return; scores_read(); position = MAX_HIGH_SCORES; for (i=0; i<MAX_HIGH_SCORES; i++ ) { if ( gameData.multi.players[gameData.multi.nLocalPlayer].score > Scores.stats[i].score ) { position = i; break; } } if ( position == MAX_HIGH_SCORES ) { if (abort_flag) return; scores_fill_struct( &Last_game ); } else { //-- if ( gameStates.app.nDifficultyLevel < 1 ) { //-- ExecMessageBox( "GRADUATION TIME!", 1, "Ok", "If you would had been\nplaying at a higher difficulty\nlevel, you would have placed\n#%d on the high score list.", position+1 ); //-- return; //-- } memset (m, 0, sizeof (m)); if ( position==0 ) { strcpy( text1, "" ); m[0].type = NM_TYPE_TEXT; m[0].text = TXT_COOL_SAYING; m[1].type = NM_TYPE_INPUT; m[1].text = text1; m[1].text_len = COOL_MESSAGE_LEN-5; ExecMenu( TXT_HIGH_SCORE, TXT_YOU_PLACED_1ST, 2, m, NULL, NULL ); strncpy( Scores.cool_saying, text1, COOL_MESSAGE_LEN ); if (strlen(Scores.cool_saying)<1) sprintf( Scores.cool_saying, TXT_NO_COMMENT ); } else { ExecMessageBox( TXT_HIGH_SCORE, NULL, 1, TXT_OK, "%s %s!", TXT_YOU_PLACED, GAMETEXT (57 + position)); } // move everyone down... for ( i=MAX_HIGH_SCORES-1; i>position; i-- ) { Scores.stats[i] = Scores.stats[i-1]; } scores_fill_struct( &Scores.stats[position] ); scores_write(); } scores_view(position); }
void scores_maybe_add_player(int abort_flag) { char text1[COOL_MESSAGE_LEN+10]; newmenu_item m[10]; int i,position; #ifdef APPLE_DEMO // no high scores in apple oem version return; #endif if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP)) return; scores_read(); position = MAX_HIGH_SCORES; for (i=0; i<MAX_HIGH_SCORES; i++ ) { if ( Players[Player_num].score > Scores.stats[i].score ) { position = i; break; } } if ( position == MAX_HIGH_SCORES ) { if (abort_flag) return; scores_fill_struct( &Last_game ); } else { //-- if ( Difficulty_level < 1 ) { //-- nm_messagebox( "GRADUATION TIME!", 1, "Ok", "If you would had been\nplaying at a higher difficulty\nlevel, you would have placed\n#%d on the high score list.", position+1 ); //-- return; //-- } if ( position==0 ) { strcpy( text1, "" ); m[0].type = NM_TYPE_TEXT; m[0].text = TXT_COOL_SAYING; m[1].type = NM_TYPE_INPUT; m[1].text = text1; m[1].text_len = COOL_MESSAGE_LEN-5; newmenu_do( TXT_HIGH_SCORE, TXT_YOU_PLACED_1ST, 2, m, NULL ); strncpy( Scores.cool_saying, text1, COOL_MESSAGE_LEN ); if (strlen(Scores.cool_saying)<1) sprintf( Scores.cool_saying, "No Comment" ); } else { nm_messagebox( TXT_HIGH_SCORE, 1, TXT_OK, "%s %s!", TXT_YOU_PLACED, *(&TXT_1ST + position) ); } // move everyone down... for ( i=MAX_HIGH_SCORES-1; i>position; i-- ) { Scores.stats[i] = Scores.stats[i-1]; } scores_fill_struct( &Scores.stats[position] ); scores_write(); } scores_view(position); }
void scores_maybe_add_player(int abort_flag) { char text1[COOL_MESSAGE_LEN+10]; newmenu_item m[10]; int i,position; all_scores scores; stats_info last_game; if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP)) return; scores_read(&scores); position = MAX_HIGH_SCORES; for (i=0; i<MAX_HIGH_SCORES; i++ ) { if ( Players[Player_num].score > scores.stats[i].score ) { position = i; break; } } if ( position == MAX_HIGH_SCORES ) { if (abort_flag) return; scores_fill_struct( &last_game ); } else { if ( position==0 ) { strcpy( text1, "" ); m[0].type = NM_TYPE_TEXT; m[0].text = TXT_COOL_SAYING; m[1].type = NM_TYPE_INPUT; m[1].text = text1; m[1].text_len = COOL_MESSAGE_LEN-5; newmenu_do( TXT_HIGH_SCORE, TXT_YOU_PLACED_1ST, 2, m, NULL, NULL ); strncpy( scores.cool_saying, text1, COOL_MESSAGE_LEN ); if (strlen(scores.cool_saying)<1) sprintf( scores.cool_saying, "No Comment" ); } else { nm_messagebox( TXT_HIGH_SCORE, 1, TXT_OK, "%s %s!", TXT_YOU_PLACED, *(&TXT_1ST + position) ); } // move everyone down... for ( i=MAX_HIGH_SCORES-1; i>position; i-- ) { scores.stats[i] = scores.stats[i-1]; } scores_fill_struct( &scores.stats[position] ); scores_write(&scores); } scores_view(&last_game, position); if (Game_wind) window_close(Game_wind); // prevent the next game from doing funny things }
//returns flag, true means quit menu void do_option ( int select) { switch (select) { case MENU_NEW_GAME: do_new_game_menu(); break; case MENU_GAME: break; case MENU_DEMO_PLAY: { char demo_file[16]; if (newmenu_get_filename( TXT_SELECT_DEMO, "*.dem", demo_file, 1 )) { newdemo_start_playback(demo_file); } } break; case MENU_LOAD_GAME: #ifdef SHAREWARE do_load_game_menu(); #else state_restore_all(0); #endif break; #ifdef EDITOR case MENU_EDITOR: Function_mode = FMODE_EDITOR; init_cockpit(); break; #endif case MENU_VIEW_SCORES: gr_palette_fade_out( gr_palette,32,0 ); scores_view(-1); break; #ifdef SHAREWARE case MENU_ORDER_INFO: show_order_form(); break; #endif case MENU_QUIT: #ifdef EDITOR if (! SafetyCheck()) break; #endif gr_palette_fade_out( gr_palette,32,0); Function_mode = FMODE_EXIT; break; case MENU_NEW_PLAYER: RegisterPlayer(); //1 == allow escape out of menu break; case MENU_HELP: do_show_help(); break; #ifndef RELEASE case MENU_PLAY_SONG: { int i; char * m[MAX_SONGS]; for (i=0;i<MAX_SONGS;i++) { m[i] = Songs[i].filename; } i = newmenu_listbox( "Select Song", MAX_SONGS, m, 1, NULL ); if ( i > -1 ) { songs_play_song( i, 0 ); } } break; case MENU_LOAD_LEVEL: { newmenu_item m; char text[10]=""; int new_level_num; m.type=NM_TYPE_INPUT; m.text_len = 10; m.text = text; newmenu_do( NULL, "Enter level to load", 1, &m, NULL ); new_level_num = atoi(m.text); if (new_level_num!=0 && new_level_num>=Last_secret_level && new_level_num<=Last_level) { gr_palette_fade_out( gr_palette, 32, 0 ); StartNewGame(new_level_num); } break; } #endif case MENU_START_NETGAME: #ifdef NETWORK //temp! #ifndef SHAREWARE load_mission(0); #endif read_player_file(); network_start_game(); #endif break; case MENU_JOIN_NETGAME: //temp! #ifdef NETWORK #ifndef SHAREWARE load_mission(0); #endif read_player_file(); network_join_game(); #endif break; #ifdef NETWORK case MENU_IPX_MULTIPLAYER: do_ipx_multi_player_menu(); break; case MENU_KALI_MULTIPLAYER: do_kali_multi_player_menu(); break; #ifdef SUPPORTS_NET_IP case MENU_IP_MULTIPLAYER: do_ip_multi_player_menu(); break; case MENU_IP_SERV_CONNECT: do_ip_serv_connect_menu(); break; case MENU_MANUAL_IP_JOIN: do_ip_manual_join_menu(); break; #endif case MENU_START_SERIAL: com_main_menu(); break; case MENU_MULTIPLAYER: do_multi_player_menu(); break; #endif //NETWORK case MENU_CONFIG: do_options_menu(); break; case MENU_SHOW_CREDITS: gr_palette_fade_out( gr_palette,32,0); credits_show(); break; default: Error("Unknown option %d in do_option",select); break; } }
int scores_handler(window *wind, d_event *event, scores_menu *menu) { int i; int k; sbyte fades[64] = { 1,1,1,2,2,3,4,4,5,6,8,9,10,12,13,15,16,17,19,20,22,23,24,26,27,28,28,29,30,30,31,31,31,31,31,30,30,29,28,28,27,26,24,23,22,20,19,17,16,15,13,12,10,9,8,6,5,4,4,3,2,2,1,1 }; int w = FSPACX(290), h = FSPACY(170); switch (event->type) { case EVENT_WINDOW_ACTIVATED: game_flush_inputs(); break; case EVENT_KEY_COMMAND: k = event_key_get(event); switch( k ) { case KEY_CTRLED+KEY_R: if ( menu->citem < 0 ) { // Reset scores... if ( nm_messagebox( NULL, 2, TXT_NO, TXT_YES, TXT_RESET_HIGH_SCORES )==1 ) { PHYSFS_delete(SCORES_FILENAME); scores_view(&menu->last_game, menu->citem); // create new scores window window_close(wind); // then remove the old one } } return 1; case KEY_ENTER: case KEY_SPACEBAR: case KEY_ESC: window_close(wind); return 1; } break; case EVENT_MOUSE_BUTTON_DOWN: case EVENT_MOUSE_BUTTON_UP: if (event_mouse_get_button(event) == MBTN_LEFT || event_mouse_get_button(event) == MBTN_RIGHT) { window_close(wind); return 1; } break; case EVENT_IDLE: timer_delay2(50); break; case EVENT_WINDOW_DRAW: gr_set_current_canvas(NULL); nm_draw_background(((SWIDTH-w)/2)-BORDERX,((SHEIGHT-h)/2)-BORDERY,((SWIDTH-w)/2)+w+BORDERX,((SHEIGHT-h)/2)+h+BORDERY); gr_set_current_canvas(window_get_canvas(wind)); grd_curcanv->cv_font = MEDIUM3_FONT; gr_string( 0x8000, FSPACY(15), TXT_HIGH_SCORES ); grd_curcanv->cv_font = GAME_FONT; gr_set_fontcolor( BM_XRGB(31,26,5), -1 ); gr_string( FSPACX( 71), FSPACY(50), TXT_NAME ); gr_string( FSPACX(122), FSPACY(50), TXT_SCORE ); gr_string( FSPACX(167), FSPACY(50), TXT_SKILL ); gr_string( FSPACX(210), FSPACY(50), TXT_LEVELS ); gr_string( FSPACX(253), FSPACY(50), TXT_TIME ); if ( menu->citem < 0 ) gr_string( 0x8000, FSPACY(175), TXT_PRESS_CTRL_R ); gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); gr_printf( 0x8000, FSPACY(31), "%c%s%c - %s", 34, menu->scores.cool_saying, 34, menu->scores.stats[0].name ); for (i=0; i<MAX_HIGH_SCORES; i++ ) { gr_set_fontcolor( BM_XRGB(28-i*2,28-i*2,28-i*2), -1 ); scores_draw_item( i, &menu->scores.stats[i] ); } if ( menu->citem > -1 ) { gr_set_fontcolor( BM_XRGB(7+fades[menu->looper],7+fades[menu->looper],7+fades[menu->looper]), -1 ); if (timer_query() >= menu->t1+F1_0/128) { menu->t1 = timer_query(); menu->looper++; if (menu->looper>63) menu->looper=0; } if ( menu->citem == MAX_HIGH_SCORES ) scores_draw_item( MAX_HIGH_SCORES, &menu->last_game ); else scores_draw_item( menu->citem, &menu->scores.stats[menu->citem] ); } gr_set_current_canvas(NULL); break; case EVENT_WINDOW_CLOSE: d_free(menu); break; default: break; } return 0; }