2006-03-20 17:12:09 +00:00
|
|
|
/*
|
2014-06-01 17:55:23 +00:00
|
|
|
* 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.
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
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 <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2012-07-07 18:35:06 +00:00
|
|
|
#include "dxxerror.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "pstypes.h"
|
|
|
|
#include "gr.h"
|
2010-03-20 13:21:53 +00:00
|
|
|
#include "window.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "key.h"
|
|
|
|
#include "palette.h"
|
|
|
|
#include "game.h"
|
2013-12-26 04:18:28 +00:00
|
|
|
#include "gameseq.h"
|
2010-01-27 04:30:31 +00:00
|
|
|
#include "window.h"
|
2014-07-20 01:09:55 +00:00
|
|
|
#include "physfsx.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "gamefont.h"
|
|
|
|
#include "u_mem.h"
|
|
|
|
#include "newmenu.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "player.h"
|
|
|
|
#include "screens.h"
|
|
|
|
#include "joy.h"
|
|
|
|
#include "timer.h"
|
|
|
|
#include "text.h"
|
2020-12-20 20:39:07 +00:00
|
|
|
#include "net_udp.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "kmatrix.h"
|
|
|
|
#include "gauges.h"
|
|
|
|
#include "pcx.h"
|
2014-12-13 17:47:06 +00:00
|
|
|
#include "object.h"
|
2013-03-03 19:41:09 +00:00
|
|
|
#include "args.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-12-13 17:47:06 +00:00
|
|
|
#include "compiler-range_for.h"
|
2020-08-10 03:45:14 +00:00
|
|
|
#include "d_levelstate.h"
|
2014-12-13 17:47:06 +00:00
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
#define CENTERING_OFFSET(x) ((300 - (70 + (x)*25 ))/2)
|
2007-01-12 14:21:05 +00:00
|
|
|
#define CENTERSCREEN (SWIDTH/2)
|
2009-11-24 09:48:53 +00:00
|
|
|
#define KMATRIX_VIEW_SEC 7 // Time after reactor explosion until new level - in seconds
|
2020-12-26 21:17:29 +00:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
enum class kmatrix_status_mode
|
|
|
|
{
|
|
|
|
reactor_countdown_running,
|
|
|
|
level_finished,
|
2020-12-26 21:17:29 +00:00
|
|
|
mission_finished,
|
2020-12-26 21:17:29 +00:00
|
|
|
};
|
|
|
|
|
2021-09-12 16:20:52 +00:00
|
|
|
static void kmatrix_redraw_coop(grs_canvas &canvas, fvcobjptr &vcobjptr, font_y_scale_float);
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2020-12-26 21:17:29 +00:00
|
|
|
static void kmatrix_draw_item(fvcobjptr &vcobjptr, grs_canvas &canvas, const grs_font &cv_font, const int i, const playernum_array_t &sorted, const font_y_scale_float fspacy)
|
2009-11-24 09:48:53 +00:00
|
|
|
{
|
2020-12-26 21:17:29 +00:00
|
|
|
const auto y = fspacy(80 + i * 9);
|
2015-06-13 22:42:20 +00:00
|
|
|
const auto &&fspacx = FSPACX();
|
2017-08-13 20:38:32 +00:00
|
|
|
auto &p = *vcplayerptr(sorted[i]);
|
2018-05-19 23:21:42 +00:00
|
|
|
gr_string(canvas, cv_font, fspacx(CENTERING_OFFSET(N_players)), y, static_cast<const char *>(p.callsign));
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2016-10-15 00:53:16 +00:00
|
|
|
const auto &&rgb10 = BM_XRGB(10, 10, 10);
|
|
|
|
const auto &&rgb25 = BM_XRGB(25, 25, 25);
|
2014-09-26 02:42:09 +00:00
|
|
|
for (int j=0; j<N_players; j++)
|
2009-11-24 09:48:53 +00:00
|
|
|
{
|
2020-12-26 21:17:29 +00:00
|
|
|
const auto x = fspacx(70 + CENTERING_OFFSET(N_players) + j * 25);
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2014-12-06 23:30:55 +00:00
|
|
|
const auto kmij = kill_matrix[sorted[i]][sorted[j]];
|
2009-11-24 09:48:53 +00:00
|
|
|
if (sorted[i]==sorted[j])
|
|
|
|
{
|
2014-12-06 23:30:55 +00:00
|
|
|
if (kmij == 0)
|
2009-11-24 09:48:53 +00:00
|
|
|
{
|
2017-03-11 19:56:28 +00:00
|
|
|
gr_set_fontcolor(canvas, rgb10, -1);
|
2018-05-19 23:21:42 +00:00
|
|
|
gr_string(canvas, cv_font, x, y, "0");
|
2009-11-24 09:48:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-11 19:56:28 +00:00
|
|
|
gr_set_fontcolor(canvas, rgb25, -1);
|
2018-05-19 23:21:42 +00:00
|
|
|
gr_printf(canvas, cv_font, x, y, "-%hu", kmij);
|
2009-11-24 09:48:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-11 19:56:28 +00:00
|
|
|
gr_set_fontcolor(canvas, kmij <= 0 ? rgb10 : rgb25, -1);
|
2018-05-19 23:21:42 +00:00
|
|
|
gr_printf(canvas, cv_font, x, y, "%hu", kmij);
|
2009-11-24 09:48:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-12 18:10:07 +00:00
|
|
|
auto &player_info = vcobjptr(p.objnum)->ctype.player_info;
|
2016-11-12 18:10:07 +00:00
|
|
|
const int eff = (player_info.net_killed_total + player_info.net_kills_total <= 0)
|
2015-12-18 04:08:23 +00:00
|
|
|
? 0
|
|
|
|
: static_cast<int>(
|
2016-11-12 18:10:07 +00:00
|
|
|
static_cast<float>(player_info.net_kills_total) / (
|
|
|
|
static_cast<float>(player_info.net_killed_total) + static_cast<float>(player_info.net_kills_total)
|
2015-12-18 04:08:23 +00:00
|
|
|
) * 100.0
|
|
|
|
);
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2020-12-26 21:17:29 +00:00
|
|
|
const auto x = fspacx(60 + CENTERING_OFFSET(N_players) + N_players * 25);
|
2017-03-11 19:56:28 +00:00
|
|
|
gr_set_fontcolor(canvas, rgb25, -1);
|
2018-05-19 23:21:42 +00:00
|
|
|
gr_printf(canvas, cv_font, x, y, "%4d/%i%%", player_info.net_kills_total, eff <= 0 ? 0 : eff);
|
2009-11-24 09:48:53 +00:00
|
|
|
}
|
|
|
|
|
2020-12-26 21:17:29 +00:00
|
|
|
static void kmatrix_draw_names(grs_canvas &canvas, const grs_font &cv_font, const playernum_array_t &sorted, const font_y_scale_float fspacy)
|
2009-11-24 09:48:53 +00:00
|
|
|
{
|
2015-06-13 22:42:20 +00:00
|
|
|
const auto &&fspacx = FSPACX();
|
2020-12-26 21:17:29 +00:00
|
|
|
const auto &&fspacy_header = fspacy(65);
|
2016-10-15 00:53:16 +00:00
|
|
|
const auto &&rgb31 = BM_XRGB(31, 31, 31);
|
2014-09-26 02:42:09 +00:00
|
|
|
for (int j=0; j<N_players; j++)
|
2009-11-24 09:48:53 +00:00
|
|
|
{
|
2020-12-26 21:17:29 +00:00
|
|
|
const auto x = fspacx(70 + CENTERING_OFFSET(N_players) + j * 25);
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2016-10-15 00:53:16 +00:00
|
|
|
color_t c;
|
2017-08-13 20:38:32 +00:00
|
|
|
auto &p = *vcplayerptr(sorted[j]);
|
|
|
|
if (p.connected==CONNECT_DISCONNECTED)
|
2016-10-15 00:53:16 +00:00
|
|
|
c = rgb31;
|
2009-11-24 09:48:53 +00:00
|
|
|
else
|
2015-03-09 03:33:07 +00:00
|
|
|
{
|
|
|
|
const auto color = get_player_or_team_color(sorted[j]);
|
2016-10-15 00:53:16 +00:00
|
|
|
const auto &rgb = player_rgb[color];
|
|
|
|
c = BM_XRGB(rgb.r, rgb.g, rgb.b);
|
2015-03-09 03:33:07 +00:00
|
|
|
}
|
2017-03-11 19:56:28 +00:00
|
|
|
gr_set_fontcolor(canvas, c, -1);
|
2020-12-26 21:17:29 +00:00
|
|
|
gr_printf(canvas, cv_font, x, fspacy_header, "%c", p.callsign[0u]);
|
2009-11-24 09:48:53 +00:00
|
|
|
}
|
2020-12-26 21:17:29 +00:00
|
|
|
const auto x = fspacx(72 + CENTERING_OFFSET(N_players) + N_players * 25);
|
2017-03-11 19:56:28 +00:00
|
|
|
gr_set_fontcolor(canvas, rgb31, -1);
|
2020-12-26 21:17:29 +00:00
|
|
|
gr_string(canvas, cv_font, x, fspacy_header, "K/E");
|
|
|
|
if (const auto m = Current_mission.get())
|
|
|
|
{
|
|
|
|
gr_string(canvas, cv_font, 0x8000, fspacy(30), m->mission_name.data());
|
|
|
|
if (const auto level_num = Current_level_num; level_num > 0 && level_num <= m->last_level)
|
|
|
|
gr_printf(canvas, cv_font, 0x8000, fspacy(42), "%s [%u/%u]", Current_level_name.line().data(), level_num, m->last_level);
|
|
|
|
}
|
2009-11-24 09:48:53 +00:00
|
|
|
}
|
|
|
|
|
2020-12-26 21:17:29 +00:00
|
|
|
static void kmatrix_draw_coop_names(grs_canvas &canvas, const grs_font &cv_font, const font_y_scale_float fspacy)
|
2009-11-24 09:48:53 +00:00
|
|
|
{
|
2017-03-11 19:56:28 +00:00
|
|
|
gr_set_fontcolor(canvas, BM_XRGB(63, 31, 31),-1);
|
2016-10-15 00:53:15 +00:00
|
|
|
const auto centerscreen = CENTERSCREEN;
|
2020-12-26 21:17:29 +00:00
|
|
|
if (const auto m = Current_mission.get())
|
|
|
|
{
|
|
|
|
gr_string(canvas, cv_font, 0x8000, fspacy(30), m->mission_name.data());
|
|
|
|
if (const auto level_num = Current_level_num; level_num > 0 && level_num <= m->last_level)
|
|
|
|
gr_printf(canvas, cv_font, 0x8000, fspacy(42), "%s [%u/%u]", Current_level_name.line().data(), level_num, m->last_level);
|
|
|
|
}
|
|
|
|
const auto &&fspacy_header = fspacy(58);
|
|
|
|
gr_string(canvas, cv_font, centerscreen, fspacy_header, "SCORE");
|
|
|
|
gr_string(canvas, cv_font, centerscreen + FSPACX(50), fspacy_header, "DEATHS");
|
2009-11-24 09:48:53 +00:00
|
|
|
}
|
|
|
|
|
2020-12-26 21:17:29 +00:00
|
|
|
static void kmatrix_status_msg(grs_canvas &canvas, const fix time, const kmatrix_status_mode message_mode)
|
2009-11-24 09:48:53 +00:00
|
|
|
{
|
2017-03-11 19:56:28 +00:00
|
|
|
gr_set_fontcolor(canvas, gr_find_closest_color(255, 255, 255),-1);
|
2018-05-19 23:21:42 +00:00
|
|
|
auto &game_font = *GAME_FONT;
|
2020-12-26 21:17:29 +00:00
|
|
|
gr_printf(canvas, game_font, 0x8000, SHEIGHT - LINE_SPACING(game_font, game_font),
|
|
|
|
message_mode == kmatrix_status_mode::reactor_countdown_running
|
2017-02-11 21:42:35 +00:00
|
|
|
? "Waiting for players to finish level. Reactor time: T-%d"
|
2020-12-26 21:17:29 +00:00
|
|
|
: (
|
|
|
|
message_mode == kmatrix_status_mode::level_finished
|
2021-01-17 22:23:22 +00:00
|
|
|
? (
|
|
|
|
time > 0
|
|
|
|
? "Level finished. Wait %d seconds to proceed or press ESC to Quit."
|
|
|
|
: "Level finished. Focus score screen to proceed."
|
|
|
|
)
|
2020-12-26 21:17:29 +00:00
|
|
|
: "Mission finished. Press ESC to Quit."
|
|
|
|
)
|
2017-02-11 21:42:35 +00:00
|
|
|
, time);
|
2009-11-24 09:48:53 +00:00
|
|
|
}
|
|
|
|
|
2020-12-26 21:17:29 +00:00
|
|
|
}
|
|
|
|
|
2020-08-28 00:18:45 +00:00
|
|
|
namespace dcx {
|
|
|
|
|
2015-08-12 03:11:46 +00:00
|
|
|
namespace {
|
|
|
|
|
2020-08-28 00:18:45 +00:00
|
|
|
struct kmatrix_window : window
|
2009-11-24 09:48:53 +00:00
|
|
|
{
|
2020-12-26 21:17:29 +00:00
|
|
|
kmatrix_window(grs_canvas &src, int x, int y, int w, int h, kmatrix_result &result) :
|
|
|
|
window(src, x, y, w, h), result(result)
|
|
|
|
{
|
|
|
|
}
|
2016-10-29 23:16:15 +00:00
|
|
|
grs_main_bitmap background;
|
2020-08-28 00:18:45 +00:00
|
|
|
fix64 end_time = -1;
|
2022-01-18 15:33:54 +00:00
|
|
|
fix64 last_endlevel_time = 0;
|
2020-08-28 00:18:45 +00:00
|
|
|
kmatrix_network network;
|
2020-12-26 21:17:29 +00:00
|
|
|
kmatrix_result &result;
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2015-08-12 03:11:46 +00:00
|
|
|
}
|
|
|
|
|
2020-08-28 00:18:45 +00:00
|
|
|
}
|
|
|
|
|
2016-08-25 04:05:32 +00:00
|
|
|
namespace dsx {
|
2020-08-28 00:18:45 +00:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
struct kmatrix_window : ::dcx::kmatrix_window
|
|
|
|
{
|
|
|
|
using ::dcx::kmatrix_window::kmatrix_window;
|
|
|
|
virtual window_event_result event_handler(const d_event &) override;
|
|
|
|
};
|
|
|
|
|
2021-09-12 16:20:52 +00:00
|
|
|
static void kmatrix_redraw(grs_canvas &canvas, kmatrix_window *const km)
|
2010-07-27 11:41:43 +00:00
|
|
|
{
|
2019-03-03 00:31:08 +00:00
|
|
|
auto &Objects = LevelUniqueObjectState.Objects;
|
|
|
|
auto &vcobjptr = Objects.vcptr;
|
2014-09-21 22:10:12 +00:00
|
|
|
playernum_array_t sorted;
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2017-03-10 01:22:33 +00:00
|
|
|
show_fullscr(canvas, km->background);
|
2020-12-26 21:17:29 +00:00
|
|
|
const auto &&fspacy = FSPACY();
|
2010-07-27 11:41:43 +00:00
|
|
|
|
2009-11-24 09:48:53 +00:00
|
|
|
if (Game_mode & GM_MULTI_COOP)
|
|
|
|
{
|
2021-09-12 16:20:52 +00:00
|
|
|
kmatrix_redraw_coop(canvas, vcobjptr, fspacy);
|
2009-11-24 09:48:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
multi_sort_kill_list();
|
2015-06-13 22:42:20 +00:00
|
|
|
const auto title =
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_II)
|
2015-06-13 22:42:20 +00:00
|
|
|
game_mode_capture_flag()
|
|
|
|
? "CAPTURE THE FLAG SUMMARY"
|
|
|
|
: game_mode_hoard()
|
|
|
|
? "HOARD SUMMARY"
|
|
|
|
:
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2015-06-13 22:42:20 +00:00
|
|
|
TXT_KILL_MATRIX_TITLE;
|
2018-05-19 23:21:42 +00:00
|
|
|
auto &medium3_font = *MEDIUM3_FONT;
|
|
|
|
gr_string(canvas, medium3_font, 0x8000, FSPACY(10), title);
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2018-05-19 23:21:42 +00:00
|
|
|
auto &game_font = *GAME_FONT;
|
2009-11-24 09:48:53 +00:00
|
|
|
multi_get_kill_list(sorted);
|
2020-12-26 21:17:29 +00:00
|
|
|
kmatrix_draw_names(canvas, game_font, sorted, fspacy);
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2014-09-26 02:42:09 +00:00
|
|
|
for (int i=0; i<N_players; i++ )
|
2009-11-24 09:48:53 +00:00
|
|
|
{
|
2017-08-13 20:38:32 +00:00
|
|
|
if (vcplayerptr(sorted[i])->connected == CONNECT_DISCONNECTED)
|
2017-03-10 01:22:33 +00:00
|
|
|
gr_set_fontcolor(canvas, gr_find_closest_color(31, 31, 31),-1);
|
2009-11-24 09:48:53 +00:00
|
|
|
else
|
2015-03-09 03:33:07 +00:00
|
|
|
{
|
|
|
|
const auto color = get_player_or_team_color(sorted[i]);
|
2017-03-10 01:22:33 +00:00
|
|
|
gr_set_fontcolor(canvas, BM_XRGB(player_rgb[color].r, player_rgb[color].g, player_rgb[color].b),-1);
|
2015-03-09 03:33:07 +00:00
|
|
|
}
|
2020-12-26 21:17:29 +00:00
|
|
|
kmatrix_draw_item(vcobjptr, canvas, game_font, i, sorted, fspacy);
|
2009-11-24 09:48:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gr_palette_load(gr_palette);
|
|
|
|
}
|
2020-08-28 00:18:45 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-08-25 04:05:32 +00:00
|
|
|
}
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2020-12-26 21:17:29 +00:00
|
|
|
namespace {
|
|
|
|
|
2021-09-12 16:20:52 +00:00
|
|
|
static void kmatrix_redraw_coop(grs_canvas &canvas, fvcobjptr &vcobjptr, const font_y_scale_float fspacy)
|
2009-11-24 09:48:53 +00:00
|
|
|
{
|
2014-09-21 22:10:12 +00:00
|
|
|
playernum_array_t sorted;
|
2009-11-24 09:48:53 +00:00
|
|
|
|
|
|
|
multi_sort_kill_list();
|
2018-05-19 23:21:42 +00:00
|
|
|
auto &medium3_font = *MEDIUM3_FONT;
|
|
|
|
gr_string(canvas, medium3_font, 0x8000, FSPACY(10), "COOPERATIVE SUMMARY");
|
2009-11-24 09:48:53 +00:00
|
|
|
multi_get_kill_list(sorted);
|
2018-05-19 23:21:42 +00:00
|
|
|
auto &game_font = *GAME_FONT;
|
2016-10-15 00:53:14 +00:00
|
|
|
const auto &&fspacx = FSPACX();
|
2020-12-26 21:17:29 +00:00
|
|
|
kmatrix_draw_coop_names(canvas, game_font, fspacy);
|
2016-10-15 00:53:14 +00:00
|
|
|
const auto x_callsign = fspacx(CENTERING_OFFSET(N_players));
|
|
|
|
const auto x_centerscreen = CENTERSCREEN;
|
|
|
|
const auto &&fspacx50 = fspacx(50);
|
|
|
|
const auto rgb60_40_10 = BM_XRGB(60, 40, 10);
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2014-09-21 22:10:12 +00:00
|
|
|
for (playernum_t i = 0; i < N_players; ++i)
|
2009-11-24 09:48:53 +00:00
|
|
|
{
|
2017-08-13 20:38:32 +00:00
|
|
|
auto &plr = *vcplayerptr(sorted[i]);
|
2016-10-15 00:53:15 +00:00
|
|
|
int r, g, b;
|
2016-10-15 00:53:14 +00:00
|
|
|
if (plr.connected == CONNECT_DISCONNECTED)
|
2016-10-15 00:53:15 +00:00
|
|
|
r = g = b = 31;
|
2009-11-24 09:48:53 +00:00
|
|
|
else
|
2015-03-09 03:33:07 +00:00
|
|
|
{
|
2015-03-09 03:33:07 +00:00
|
|
|
auto &color = player_rgb_normal[get_player_color(sorted[i])];
|
2016-10-15 00:53:15 +00:00
|
|
|
r = color.r * 2;
|
|
|
|
g = color.g * 2;
|
|
|
|
b = color.b * 2;
|
2015-03-09 03:33:07 +00:00
|
|
|
}
|
2017-03-10 01:22:33 +00:00
|
|
|
gr_set_fontcolor(canvas, gr_find_closest_color(r, g, b), -1);
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2020-12-26 21:17:29 +00:00
|
|
|
const auto &&y = fspacy(80 + i * 9);
|
2018-05-19 23:21:42 +00:00
|
|
|
gr_string(canvas, game_font, x_callsign, y, static_cast<const char *>(plr.callsign));
|
2017-03-10 01:22:33 +00:00
|
|
|
gr_set_fontcolor(canvas, rgb60_40_10, -1);
|
2016-10-15 00:53:19 +00:00
|
|
|
auto &player_info = vcobjptr(plr.objnum)->ctype.player_info;
|
2018-05-19 23:21:42 +00:00
|
|
|
gr_printf(canvas, game_font, x_centerscreen, y, "%d", player_info.mission.score);
|
|
|
|
gr_printf(canvas, game_font, x_centerscreen + fspacx50, y, "%d", player_info.net_killed_total);
|
2009-11-24 09:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gr_palette_load(gr_palette);
|
|
|
|
}
|
|
|
|
|
2020-12-26 21:17:29 +00:00
|
|
|
}
|
|
|
|
|
2016-08-25 04:05:32 +00:00
|
|
|
namespace dsx {
|
2020-08-28 00:18:45 +00:00
|
|
|
|
|
|
|
window_event_result kmatrix_window::event_handler(const d_event &event)
|
2010-03-20 13:21:53 +00:00
|
|
|
{
|
2019-08-15 01:34:22 +00:00
|
|
|
auto &LevelUniqueControlCenterState = LevelUniqueObjectState.ControlCenterState;
|
2020-12-27 22:03:09 +00:00
|
|
|
int k = 0;
|
2010-03-20 13:21:53 +00:00
|
|
|
|
2014-10-04 21:47:13 +00:00
|
|
|
switch (event.type)
|
2009-11-24 09:48:53 +00:00
|
|
|
{
|
2010-03-20 13:21:53 +00:00
|
|
|
case EVENT_KEY_COMMAND:
|
2011-01-14 09:51:13 +00:00
|
|
|
k = event_key_get(event);
|
2010-03-20 13:21:53 +00:00
|
|
|
switch( k )
|
|
|
|
{
|
|
|
|
case KEY_ESC:
|
|
|
|
{
|
2020-12-27 22:03:09 +00:00
|
|
|
using items_type = std::array<newmenu_item, 2>;
|
|
|
|
struct abort_game_menu : items_type, passive_newmenu
|
|
|
|
{
|
2021-09-12 16:20:52 +00:00
|
|
|
abort_game_menu(grs_canvas &canvas) :
|
2020-12-27 22:03:09 +00:00
|
|
|
items_type{{
|
2021-06-28 03:37:49 +00:00
|
|
|
newmenu_item::nm_item_menu{TXT_YES},
|
|
|
|
newmenu_item::nm_item_menu{TXT_NO},
|
2020-12-27 22:03:09 +00:00
|
|
|
}},
|
2021-09-12 16:20:52 +00:00
|
|
|
passive_newmenu(menu_title{nullptr}, menu_subtitle{TXT_ABORT_GAME}, menu_filename{nullptr}, tiny_mode_flag::normal, tab_processing_flag::ignore, adjusted_citem::create(*static_cast<items_type *>(this), 0), canvas)
|
2020-12-27 22:03:09 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
2021-09-12 16:20:52 +00:00
|
|
|
if (run_blocking_newmenu<abort_game_menu>(*grd_curcanv) != 0)
|
2020-12-27 22:03:09 +00:00
|
|
|
return window_event_result::handled;
|
2010-03-20 13:21:53 +00:00
|
|
|
}
|
|
|
|
{
|
2015-07-25 23:10:46 +00:00
|
|
|
get_local_player().connected=CONNECT_DISCONNECTED;
|
2010-03-20 13:21:53 +00:00
|
|
|
|
2020-08-28 00:18:45 +00:00
|
|
|
if (network != kmatrix_network::offline)
|
2020-12-20 20:39:07 +00:00
|
|
|
multi::dispatch->send_endlevel_packet();
|
2010-03-20 13:21:53 +00:00
|
|
|
|
|
|
|
multi_leave_game();
|
2020-08-28 00:18:45 +00:00
|
|
|
this->result = kmatrix_result::abort;
|
2015-03-23 02:03:22 +00:00
|
|
|
|
2014-08-06 02:10:49 +00:00
|
|
|
return window_event_result::close;
|
2010-03-20 13:21:53 +00:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-01-14 21:56:00 +00:00
|
|
|
case EVENT_WINDOW_DRAW:
|
2019-08-15 01:34:22 +00:00
|
|
|
{
|
2010-03-20 13:21:53 +00:00
|
|
|
timer_delay2(50);
|
2021-09-12 16:20:52 +00:00
|
|
|
gr_set_default_canvas();
|
|
|
|
kmatrix_redraw(*grd_curcanv, this);
|
2010-03-20 13:21:53 +00:00
|
|
|
|
2020-08-28 00:18:45 +00:00
|
|
|
if (network != kmatrix_network::offline)
|
2020-12-20 20:39:07 +00:00
|
|
|
multi::dispatch->do_protocol_frame(0, 1);
|
2020-12-26 21:17:29 +00:00
|
|
|
kmatrix_status_mode playing = (Current_level_num == Current_mission->last_level)
|
|
|
|
? kmatrix_status_mode::mission_finished
|
|
|
|
: kmatrix_status_mode::level_finished;
|
2010-03-27 02:54:41 +00:00
|
|
|
|
2010-03-20 13:21:53 +00:00
|
|
|
// Check if all connected players are also looking at this screen ...
|
2015-02-14 22:48:27 +00:00
|
|
|
range_for (auto &i, Players)
|
|
|
|
if (i.connected)
|
|
|
|
if (i.connected != CONNECT_END_MENU && i.connected != CONNECT_DIED_IN_MINE)
|
|
|
|
{
|
2020-12-26 21:17:29 +00:00
|
|
|
playing = kmatrix_status_mode::reactor_countdown_running;
|
2015-02-14 22:48:27 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-03-20 13:21:53 +00:00
|
|
|
|
|
|
|
// ... and let the reactor blow sky high!
|
2020-12-26 21:17:29 +00:00
|
|
|
if (playing != kmatrix_status_mode::reactor_countdown_running)
|
|
|
|
{
|
2019-08-15 01:34:22 +00:00
|
|
|
LevelUniqueControlCenterState.Countdown_seconds_left = -1;
|
2010-03-20 13:21:53 +00:00
|
|
|
|
|
|
|
// If Reactor is finished and end_time not inited, set the time when we will exit this loop
|
2020-12-26 21:17:29 +00:00
|
|
|
if (end_time == -1)
|
|
|
|
end_time = timer_query() + (KMATRIX_VIEW_SEC * F1_0);
|
|
|
|
}
|
|
|
|
|
2010-03-20 13:21:53 +00:00
|
|
|
// Check if end_time has been reached and exit loop
|
2020-12-27 22:03:09 +00:00
|
|
|
if (end_time != -1 && timer_query() >= end_time && this == window_get_front())
|
2010-03-20 13:21:53 +00:00
|
|
|
{
|
2020-08-28 00:18:45 +00:00
|
|
|
if (network != kmatrix_network::offline)
|
2020-12-20 20:39:07 +00:00
|
|
|
multi::dispatch->send_endlevel_packet(); // make sure
|
2020-12-26 21:17:29 +00:00
|
|
|
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_II)
|
2010-03-20 13:21:53 +00:00
|
|
|
if (is_D2_OEM)
|
2009-11-24 09:48:53 +00:00
|
|
|
{
|
2010-03-20 13:21:53 +00:00
|
|
|
if (Current_level_num==8)
|
|
|
|
{
|
2015-07-25 23:10:46 +00:00
|
|
|
get_local_player().connected=CONNECT_DISCONNECTED;
|
2010-03-20 13:21:53 +00:00
|
|
|
multi_leave_game();
|
2020-08-28 00:18:45 +00:00
|
|
|
this->result = kmatrix_result::abort;
|
2010-03-20 13:21:53 +00:00
|
|
|
}
|
2009-11-24 09:48:53 +00:00
|
|
|
}
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2020-12-26 21:17:29 +00:00
|
|
|
if (playing != kmatrix_status_mode::mission_finished)
|
|
|
|
return window_event_result::close;
|
2010-03-20 13:21:53 +00:00
|
|
|
}
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2022-01-18 15:33:54 +00:00
|
|
|
// If Control_center_destroyed is still true this is handled by do_protocol_frame
|
|
|
|
if (timer_query() >= last_endlevel_time + F1_0 && !LevelUniqueObjectState.ControlCenterState.Control_center_destroyed)
|
|
|
|
{
|
|
|
|
last_endlevel_time = timer_query();
|
|
|
|
multi::dispatch->send_endlevel_packet();
|
|
|
|
}
|
|
|
|
|
2021-01-17 22:23:22 +00:00
|
|
|
kmatrix_status_msg(*grd_curcanv, playing == kmatrix_status_mode::reactor_countdown_running ? LevelUniqueControlCenterState.Countdown_seconds_left : f2i(end_time - timer_query()), playing);
|
2010-03-20 13:21:53 +00:00
|
|
|
break;
|
2019-08-15 01:34:22 +00:00
|
|
|
}
|
2010-03-20 13:21:53 +00:00
|
|
|
|
|
|
|
case EVENT_WINDOW_CLOSE:
|
2020-10-12 03:28:26 +00:00
|
|
|
game_flush_inputs(Controls);
|
2010-07-31 12:09:38 +00:00
|
|
|
newmenu_free_background();
|
2010-03-20 13:21:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2009-11-24 09:48:53 +00:00
|
|
|
}
|
2014-08-06 02:10:49 +00:00
|
|
|
return window_event_result::ignored;
|
2010-03-20 13:21:53 +00:00
|
|
|
}
|
2020-08-28 00:18:45 +00:00
|
|
|
|
2020-10-12 03:28:26 +00:00
|
|
|
kmatrix_result kmatrix_view(const kmatrix_network network, control_info &Controls)
|
2010-03-20 13:21:53 +00:00
|
|
|
{
|
2019-03-03 00:31:08 +00:00
|
|
|
auto &Objects = LevelUniqueObjectState.Objects;
|
|
|
|
auto &vcobjptridx = Objects.vcptridx;
|
2020-12-26 21:17:29 +00:00
|
|
|
kmatrix_result result = kmatrix_result::proceed;
|
|
|
|
{
|
|
|
|
const auto pkm = window_create<kmatrix_window>(grd_curscreen->sc_canvas, 0, 0, SWIDTH, SHEIGHT, result);
|
2020-08-28 00:18:45 +00:00
|
|
|
auto &km = *pkm;
|
2020-12-26 21:17:29 +00:00
|
|
|
pcx_read_bitmap_or_default(STARS_BACKGROUND, km.background, gr_palette);
|
2010-07-27 11:41:43 +00:00
|
|
|
gr_palette_load(gr_palette);
|
2020-08-28 00:18:45 +00:00
|
|
|
|
2013-12-08 16:50:19 +00:00
|
|
|
km.network = network;
|
2010-03-20 13:21:53 +00:00
|
|
|
|
|
|
|
set_screen_mode( SCREEN_MENU );
|
2020-10-12 03:28:26 +00:00
|
|
|
game_flush_inputs(Controls);
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2014-12-13 17:47:06 +00:00
|
|
|
range_for (auto &i, Players)
|
|
|
|
if (i.objnum != object_none)
|
|
|
|
digi_kill_sound_linked_to_object(vcobjptridx(i.objnum));
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2016-10-29 12:06:01 +00:00
|
|
|
event_process_all();
|
2020-12-26 21:17:29 +00:00
|
|
|
}
|
|
|
|
/* After event_process_all returns, kmatrix_window has been freed
|
|
|
|
* and cannot be accessed. The result is therefore stored in a
|
|
|
|
* stack local, which will persist.
|
|
|
|
*/
|
|
|
|
return result;
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
2020-08-28 00:18:45 +00:00
|
|
|
|
|
|
|
}
|