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 }
int scoreboard_create(scene *scene) { // Init local data scoreboard_local *local = malloc(sizeof(scoreboard_local)); local->page = settings_get()->gameplay.rounds; // Load scores if(scores_read(&local->data) == 1) { scores_clear(&local->data); DEBUG("No score data found; using empty score array."); } // Check for pending score local->has_pending_data = 0; if(found_pending_score(scene)) { game_player *player = game_state_get_player(scene->gs, 0); unsigned int score = player->score.score; if(score_fits_scoreboard(local, score)) { local->has_pending_data = 1; local->pending_data.score = score; local->pending_data.har_id = player->har_id; local->pending_data.pilot_id = player->pilot_id; local->pending_data.name[0] = 0; } // Wipe old score data, whether it was written on scoreboard or not. chr_score_reset(game_player_get_score(player), 1); } // Create a surface that has an appropriate alpha for darkening the screen a bit surface_create(&local->black_surface, SURFACE_TYPE_RGBA, 32, 32); surface_fill(&local->black_surface, color_create(0,0,0,200)); // Set callbacks scene_set_userdata(scene, local); scene_set_event_cb(scene, scoreboard_event); scene_set_input_poll_cb(scene, scoreboard_input_tick); scene_set_render_overlay_cb(scene, scoreboard_render_overlay); scene_set_free_cb(scene, scoreboard_free); video_select_renderer(VIDEO_RENDERER_HW); // All done return 0; }
void scores_view(stats_info *last_game, int citem) { scores_menu *menu; MALLOC(menu, scores_menu, 1); if (!menu) return; menu->citem = citem; menu->t1 = timer_query(); menu->looper = 0; if (last_game) menu->last_game = *last_game; newmenu_free_background(); scores_read(&menu->scores); set_screen_mode(SCREEN_MENU); show_menus(); window_create(&grd_curscreen->sc_canvas, (SWIDTH - FSPACX(320))/2, (SHEIGHT - FSPACY(200))/2, FSPACX(320), FSPACY(200), (int (*)(window *, d_event *, void *))scores_handler, menu); }
void scores_view(int citem) { fix time_out_value; fix t1; int i,done,looper; int k; byte 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 }; ReshowScores: scores_read(); set_screen_mode(SCREEN_MENU); gr_set_current_canvas(NULL); nm_draw_background(0,0,grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h ); grd_curcanv->cv_font = Gamefonts[GFONT_MEDIUM_3]; gr_string( 0x8000, 15, TXT_HIGH_SCORES ); grd_curcanv->cv_font = Gamefonts[GFONT_SMALL]; gr_set_fontcolor( BM_XRGB(31,26,5), -1 ); gr_string( 31+33+XX, 46+7+YY, TXT_NAME ); gr_string( 82+33+XX, 46+7+YY, TXT_SCORE ); gr_string( 127+33+XX, 46+7+YY, TXT_SKILL ); gr_string( 170+33+XX, 46+7+YY, TXT_LEVELS ); // gr_string( 202, 46, "Kills" ); // gr_string( 234, 46, "Rescues" ); gr_string( 288-42+XX, 46+7+YY, TXT_TIME ); if ( citem < 0 ) gr_string( 0x8000, 175, TXT_PRESS_CTRL_R ); gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); gr_printf( 0x8000, 31, "%c%s%c - %s", 34, Scores.cool_saying, 34, Scores.stats[0].name ); for (i=0; i<MAX_HIGH_SCORES; i++ ) { if (i==0) { gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); } else { gr_set_fontcolor( gr_fade_table[BM_XRGB(28,28,28)+((28-i*2)*256)], -1 ); } scores_draw_item( i, &Scores.stats[i] ); } gr_palette_fade_in( gr_palette,32, 0); game_flush_inputs(); done = 0; looper = 0; time_out_value = timer_get_fixed_seconds()+i2f(60*5); while(!done) { if ( citem > -1 ) { t1 = timer_get_fixed_seconds(); if ( t1 > time_out_value ) done = 1; while ( timer_get_fixed_seconds() < t1+F1_0/128 ); gr_set_fontcolor( gr_fade_table[fades[looper]*256+BM_XRGB(28,28,28)], -1 ); looper++; if (looper>63) looper=0; if ( citem == MAX_HIGH_SCORES ) scores_draw_item( MAX_HIGH_SCORES, &Last_game ); else scores_draw_item( citem, &Scores.stats[citem] ); } for (i=0; i<4; i++ ) if (joy_get_button_down_cnt(i)>0) done=1; for (i=0; i<3; i++ ) if (mouse_button_down_count(i)>0) done=1; k = key_inkey(); switch( k ) { case KEY_CTRLED+KEY_R: if ( citem < 0 ) { // Reset scores... if ( nm_messagebox( NULL, 2, TXT_NO, TXT_YES, TXT_RESET_HIGH_SCORES )==1 ) { remove( get_scores_filename() ); gr_palette_fade_out( gr_palette, 32, 0 ); goto ReshowScores; } } break; case KEY_BACKSP: Int3(); k = 0; break; case KEY_PRINT_SCREEN: save_screen_shot(0); k = 0; break; case KEY_ENTER: case KEY_SPACEBAR: case KEY_ESC: done=1; break; } } // Restore background and exit gr_palette_fade_out( gr_palette, 32, 0 ); gr_set_current_canvas(NULL); game_flush_inputs(); }
void scores_view(int citem) { grs_canvas *center_canv; fix t1; int i,done,looper; 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 }; ReshowScores: scores_read(); set_screen_mode(SCREEN_MENU); gr_set_current_canvas(NULL); nm_draw_background(0, 0, GWIDTH-1, GHEIGHT-1); // args are x,y,x2,y2 NOT x,y,w,h center_canv = gr_create_sub_canvas(grd_curcanv, GWIDTH/2-LHX(160), 0, LHX(320), GHEIGHT); gr_set_current_canvas(center_canv); grd_curcanv->cv_font = MEDIUM3_FONT; gr_string( 0x8000, LHY(15), TXT_HIGH_SCORES ); grd_curcanv->cv_font = SMALL_FONT; gr_set_fontcolor( BM_XRGB(31,26,5), -1 ); gr_string( LHX(31+33+XX), LHY(46+7+YY), TXT_NAME ); gr_string( LHX(82+33+XX), LHY(46+7+YY), TXT_SCORE ); gr_string( LHX(127+33+XX), LHY(46+7+YY), TXT_SKILL ); gr_string( LHX(170+33+XX), LHY(46+7+YY), TXT_LEVELS ); // gr_string( 202, 46, "Kills" ); // gr_string( 234, 46, "Rescues" ); gr_string( LHX(288-42+XX), LHY(46+7+YY), TXT_TIME ); if ( citem < 0 ) gr_string( 0x8000, LHY(175), TXT_PRESS_CTRL_R ); gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); gr_printf( 0x8000, LHY(31), "%c%s%c - %s", 34, Scores.cool_saying, 34, Scores.stats[0].name ); for (i=0; i<MAX_HIGH_SCORES; i++ ) { //@@if (i==0) { //@@ gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); //@@} else { //@@ gr_set_fontcolor( gr_fade_table[BM_XRGB(28,28,28)+((28-i*2)*256)], -1 ); //@@} gr_set_fontcolor( BM_XRGB(28-i*2,28-i*2,28-i*2), -1 ); scores_draw_item( i, &Scores.stats[i] ); } gr_palette_fade_in( gr_palette,32, 0); #ifdef OGL vid_update(); #endif game_flush_inputs(); done = 0; looper = 0; while(!done) { if ( citem > -1 ) { t1 = timer_get_fixed_seconds(); while ( timer_get_fixed_seconds() < t1+F1_0/128 ); //@@gr_set_fontcolor( gr_fade_table[fades[looper]*256+BM_XRGB(28,28,28)], -1 ); gr_set_fontcolor( BM_XRGB(7+fades[looper],7+fades[looper],7+fades[looper]), -1 ); looper++; if (looper>63) looper=0; if ( citem == MAX_HIGH_SCORES ) scores_draw_item( MAX_HIGH_SCORES, &Last_game ); else scores_draw_item( citem, &Scores.stats[citem] ); vid_update(); } for (i=0; i<4; i++ ) if (joy_get_button_down_cnt(i)>0) done=1; for (i=0; i<3; i++ ) if (mouse_button_down_count(i)>0) done=1; //see if redbook song needs to be restarted songs_check_redbook_repeat(); k = newmenu_inkey(); switch( k ) { case KEY_CTRLED+KEY_R: if ( citem < 0 ) { // Reset scores... if ( nm_messagebox( NULL, 2, TXT_NO, TXT_YES, TXT_RESET_HIGH_SCORES )==1 ) { PHYSFS_delete(get_scores_filename()); gr_palette_fade_out( gr_palette, 32, 0 ); goto ReshowScores; } } break; case KEY_BACKSP: Int3(); k = 0; break; case KEY_PRINT_SCREEN: save_screen_shot(0); k = 0; break; case KEY_ENTER: case KEY_SPACEBAR: case KEY_ESC: done=1; break; } } // Restore background and exit gr_palette_fade_out( gr_palette, 32, 0 ); gr_set_current_canvas(NULL); gr_free_sub_canvas(center_canv); game_flush_inputs(); }
void scores_view(int citem) { fix t0 = 0, t1; int c,i,done,looper; int k, bRedraw = 0; 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 }; bkg bg; memset (&bg, 0, sizeof (bg)); ReshowScores: scores_read(); SetScreenMode(SCREEN_MENU); WINDOS( DDGrSetCurrentCanvas(NULL), GrSetCurrentCanvas(NULL) ); xOffs = (grdCurCanv->cv_bitmap.bm_props.w - 640) / 2; yOffs = (grdCurCanv->cv_bitmap.bm_props.h - 480) / 2; if (xOffs < 0) xOffs = 0; if (yOffs < 0) yOffs = 0; GameFlushInputs(); done = 0; looper = 0; while(!done) { if (!bRedraw || gameOpts->menus.nStyle) { NMDrawBackground(&bg,xOffs, yOffs, xOffs + 640, xOffs + 480, bRedraw); grdCurCanv->cv_font = MEDIUM3_FONT; WIN(DDGRLOCK(dd_grd_curcanv)); GrString( 0x8000, yOffs + LHY(15), TXT_HIGH_SCORES ); grdCurCanv->cv_font = SMALL_FONT; GrSetFontColorRGBi (RGBA_PAL (31,26,5), 1, 0, 0); GrString( xOffs + LHX(31+33+XX), yOffs + LHY(46+7+YY), TXT_NAME ); GrString( xOffs + LHX(82+33+XX), yOffs + LHY(46+7+YY), TXT_SCORE ); GrString( xOffs + LHX(127+33+XX), yOffs + LHY(46+7+YY), TXT_SKILL ); GrString( xOffs + LHX(170+33+XX), yOffs + LHY(46+7+YY), TXT_LEVELS ); // GrString( 202, 46, "Kills" ); // GrString( 234, 46, "Rescues" ); GrString( xOffs + LHX(288-42+XX), yOffs + LHY(46+7+YY), TXT_TIME ); if ( citem < 0 ) GrString( 0x8000, yOffs + LHY(175), TXT_PRESS_CTRL_R ); GrSetFontColorRGBi (RGBA_PAL (28,28,28), 1, 0, 0); //GrPrintF( 0x8000, yOffs + LHY(31), "%c%s%c - %s", 34, Scores.cool_saying, 34, Scores.stats[0].name ); WIN(DDGRUNLOCK(dd_grd_curcanv)); for (i=0; i<MAX_HIGH_SCORES; i++ ) { //@@if (i==0) { //@@ GrSetFontColorRGBi (RGBA_PAL (28,28,28), 1, 0, 0); //@@} else { //@@ GrSetFontColor( grFadeTable[BM_XRGB(28,28,28)+((28-i*2)*256)], 1, 0, 0); //@@} c = 28 - i * 2; GrSetFontColorRGBi (RGBA_PAL (c, c, c), 1, 0, 0); scores_draw_item( i, Scores.stats + i); } GrPaletteFadeIn( NULL,32, 0); #ifdef OGL if (citem < 0) GrUpdate (0); #endif bRedraw = 1; } if ( citem > -1 ) { t1 = TimerGetFixedSeconds(); //if (t1 - t0 >= F1_0/128 ) { t0 = t1; //@@GrSetFontColor( grFadeTable[fades[looper]*256+BM_XRGB(28,28,28)], -1 ); c = 7 + fades [looper]; GrSetFontColorRGBi (RGBA_PAL (c, c, c), 1, 0, 0); if (++looper > 63) looper=0; if ( citem == MAX_HIGH_SCORES ) scores_draw_item( MAX_HIGH_SCORES, &Last_game ); else scores_draw_item( citem, Scores.stats + citem ); } GrUpdate (0); } for (i=0; i<4; i++ ) if (joy_get_button_down_cnt(i)>0) done=1; for (i=0; i<3; i++ ) if (MouseButtonDownCount(i)>0) done=1; //see if redbook song needs to be restarted songs_check_redbook_repeat(); #ifdef WINDOWS { MSG msg; DoMessageStuff(&msg); if (_RedrawScreen) { _RedrawScreen = FALSE; goto ReshowScores; } DDGRRESTORE; } #endif k = KeyInKey(); switch( k ) { case KEY_CTRLED+KEY_R: if ( citem < 0 ) { // Reset scores... if ( ExecMessageBox( NULL, NULL, 2, TXT_NO, TXT_YES, TXT_RESET_HIGH_SCORES )==1 ) { CFDelete(get_scores_filename(), gameFolders.szDataDir); GrPaletteFadeOut (NULL, 32, 0 ); goto ReshowScores; } } break; case KEY_BACKSP: Int3(); k = 0; break; case KEY_PRINT_SCREEN: SaveScreenShot (NULL, 0); k = 0; break; case KEY_ENTER: case KEY_SPACEBAR: case KEY_ESC: done=1; break; } } // Restore background and exit GrPaletteFadeOut (NULL, 32, 0 ); #ifdef WINDOWS DDGRRESTORE; #endif WINDOS( DDGrSetCurrentCanvas(NULL), GrSetCurrentCanvas(NULL) ); GameFlushInputs(); NMRemoveBackground (&bg); }