/* * Portions of this file are copyright Rebirth contributors and licensed as * described in COPYING.txt. * Portions of this file are copyright Parallax Software and licensed * according to the Parallax license below. * See COPYING.txt for license details. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* * * Kill matrix displayed at end of level. * */ #include #include #include #include #include #include "dxxerror.h" #include "pstypes.h" #include "gr.h" #include "window.h" #include "key.h" #include "palette.h" #include "game.h" #include "gameseq.h" #include "window.h" #include "physfsx.h" #include "gamefont.h" #include "u_mem.h" #include "newmenu.h" #include "menu.h" #include "player.h" #include "screens.h" #include "cntrlcen.h" #include "mouse.h" #include "joy.h" #include "timer.h" #include "text.h" #include "rbaudio.h" #include "multi.h" #include "kmatrix.h" #include "gauges.h" #include "pcx.h" #include "object.h" #include "args.h" #include "compiler-range_for.h" #ifdef OGL #include "ogl_init.h" #endif #define CENTERING_OFFSET(x) ((300 - (70 + (x)*25 ))/2) #define CENTERSCREEN (SWIDTH/2) #define KMATRIX_VIEW_SEC 7 // Time after reactor explosion until new level - in seconds static void kmatrix_redraw_coop(); static void kmatrix_draw_item(int i, playernum_array_t &sorted) { int x, y; char temp[10]; y = FSPACY(50+i*9); const auto &&fspacx = FSPACX(); gr_string(fspacx(CENTERING_OFFSET(N_players)), y, static_cast(Players[sorted[i]].callsign)); for (int j=0; j(Players[sorted[i]].callsign)); x = CENTERSCREEN; gr_set_fontcolor( BM_XRGB(60,40,10),-1 ); gr_printf( x, y, "%d", Players[sorted[i]].score ); x = CENTERSCREEN + fspacx(50); gr_set_fontcolor( BM_XRGB(60,40,10),-1 ); gr_printf( x, y, "%d", Players[sorted[i]].net_killed_total); } static void kmatrix_draw_names(playernum_array_t &sorted) { int x; const auto &&fspacx = FSPACX(); const auto &&fspacy = FSPACY(); for (int j=0; jbackground); if (Game_mode & GM_MULTI_COOP) { kmatrix_redraw_coop(); } else { multi_sort_kill_list(); gr_set_curfont(MEDIUM3_FONT); const auto title = #if defined(DXX_BUILD_DESCENT_II) game_mode_capture_flag() ? "CAPTURE THE FLAG SUMMARY" : game_mode_hoard() ? "HOARD SUMMARY" : #endif TXT_KILL_MATRIX_TITLE; gr_string(0x8000, FSPACY(10), title); gr_set_curfont(GAME_FONT); multi_get_kill_list(sorted); kmatrix_draw_names(sorted); for (int i=0; i nm_message_items{{ nm_item_menu(TXT_YES), nm_item_menu(TXT_NO), }}; choice = newmenu_do( NULL, TXT_ABORT_GAME, nm_message_items, km->network ? multi_endlevel_poll2 : unused_newmenu_subfunction, unused_newmenu_userdata ); } if (choice==0) { get_local_player().connected=CONNECT_DISCONNECTED; if (km->network) multi_send_endlevel_packet(); multi_leave_game(); km->aborted = 1; return window_event_result::close; } return window_event_result::handled; default: break; } break; case EVENT_WINDOW_DRAW: timer_delay2(50); if (km->network) multi_do_protocol_frame(0, 1); km->playing = 0; // Check if all connected players are also looking at this screen ... range_for (auto &i, Players) if (i.connected) if (i.connected != CONNECT_END_MENU && i.connected != CONNECT_DIED_IN_MINE) { km->playing = 1; break; } // ... and let the reactor blow sky high! if (!km->playing) Countdown_seconds_left = -1; // If Reactor is finished and end_time not inited, set the time when we will exit this loop if (km->end_time == -1 && Countdown_seconds_left < 0 && !km->playing) km->end_time = timer_query() + (KMATRIX_VIEW_SEC * F1_0); // Check if end_time has been reached and exit loop if (timer_query() >= km->end_time && km->end_time != -1) { if (km->network) multi_send_endlevel_packet(); // make sure #if defined(DXX_BUILD_DESCENT_II) if (is_D2_OEM) { if (Current_level_num==8) { get_local_player().connected=CONNECT_DISCONNECTED; if (km->network) multi_send_endlevel_packet(); multi_leave_game(); km->aborted = 1; return window_event_result::close; } } #endif return window_event_result::close; } kmatrix_redraw(km); if (km->playing) kmatrix_status_msg(Countdown_seconds_left, 1); else kmatrix_status_msg(f2i(timer_query()-km->end_time), 0); break; case EVENT_WINDOW_CLOSE: game_flush_inputs(); newmenu_free_background(); break; default: break; } return window_event_result::ignored; } kmatrix_result kmatrix_view(int network) { window *wind; kmatrix_screen km; gr_init_bitmap_data(km.background); if (pcx_read_bitmap(STARS_BACKGROUND, km.background, BM_LINEAR, gr_palette) != PCX_ERROR_NONE) { return kmatrix_result::abort; } gr_palette_load(gr_palette); km.network = network; km.end_time = -1; km.playing = 0; km.aborted = 0; set_screen_mode( SCREEN_MENU ); game_flush_inputs(); range_for (auto &i, Players) if (i.objnum != object_none) digi_kill_sound_linked_to_object(vcobjptridx(i.objnum)); wind = window_create(&grd_curscreen->sc_canvas, 0, 0, SWIDTH, SHEIGHT, kmatrix_handler, &km); if (!wind) { return kmatrix_result::abort; } while (window_exists(wind)) event_process(); gr_free_bitmap_data(km.background); return (km.aborted ? kmatrix_result::abort : kmatrix_result::proceed); }