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 "cntrlcen.h"
|
|
|
|
#include "mouse.h"
|
|
|
|
#include "joy.h"
|
|
|
|
#include "timer.h"
|
|
|
|
#include "text.h"
|
2009-03-03 12:55:27 +00:00
|
|
|
#include "rbaudio.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "multi.h"
|
|
|
|
#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"
|
|
|
|
|
2016-09-24 18:06:11 +00:00
|
|
|
#if DXX_USE_OGL
|
2007-03-22 11:32:22 +00:00
|
|
|
#include "ogl_init.h"
|
|
|
|
#endif
|
|
|
|
|
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
|
2017-07-26 03:15:59 +00:00
|
|
|
static void kmatrix_redraw_coop(fvcobjptr &vcobjptr);
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2018-05-19 23:21:42 +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)
|
2009-11-24 09:48:53 +00:00
|
|
|
{
|
2014-09-26 02:42:09 +00:00
|
|
|
int x, y;
|
2009-11-24 09:48:53 +00:00
|
|
|
|
|
|
|
y = FSPACY(50+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
|
|
|
{
|
2015-06-13 22:42:20 +00:00
|
|
|
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
|
|
|
|
2015-06-13 22:42:20 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-05-19 23:21:42 +00:00
|
|
|
static void kmatrix_draw_names(grs_canvas &canvas, const grs_font &cv_font, const playernum_array_t &sorted)
|
2009-11-24 09:48:53 +00:00
|
|
|
{
|
2015-03-09 03:33:07 +00:00
|
|
|
int x;
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2015-06-13 22:42:20 +00:00
|
|
|
const auto &&fspacx = FSPACX();
|
2015-06-13 22:42:20 +00:00
|
|
|
const auto &&fspacy = FSPACY();
|
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
|
|
|
{
|
2015-06-13 22:42:20 +00:00
|
|
|
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);
|
2018-05-19 23:21:42 +00:00
|
|
|
gr_printf(canvas, cv_font, x, fspacy(40), "%c", p.callsign[0u]);
|
2009-11-24 09:48:53 +00:00
|
|
|
}
|
|
|
|
|
2015-06-13 22:42:20 +00:00
|
|
|
x = fspacx(72 + CENTERING_OFFSET(N_players) + N_players * 25);
|
2017-03-11 19:56:28 +00:00
|
|
|
gr_set_fontcolor(canvas, rgb31, -1);
|
2018-05-19 23:21:42 +00:00
|
|
|
gr_string(canvas, cv_font, x, fspacy(40), "K/E");
|
2009-11-24 09:48:53 +00:00
|
|
|
}
|
|
|
|
|
2018-05-19 23:21:42 +00:00
|
|
|
static void kmatrix_draw_coop_names(grs_canvas &canvas, const grs_font &cv_font)
|
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 &&fspacy40 = FSPACY(40);
|
|
|
|
const auto centerscreen = CENTERSCREEN;
|
2018-05-19 23:21:42 +00:00
|
|
|
gr_string(canvas, cv_font, centerscreen, fspacy40, "SCORE");
|
|
|
|
gr_string(canvas, cv_font, centerscreen + FSPACX(50), fspacy40, "DEATHS");
|
2009-11-24 09:48:53 +00:00
|
|
|
}
|
|
|
|
|
2017-03-11 19:56:28 +00:00
|
|
|
static void kmatrix_status_msg(grs_canvas &canvas, const fix time, const int reactor)
|
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;
|
|
|
|
gr_printf(canvas, game_font, 0x8000, SHEIGHT - LINE_SPACING(game_font, game_font), reactor
|
2017-02-11 21:42:35 +00:00
|
|
|
? "Waiting for players to finish level. Reactor time: T-%d"
|
|
|
|
: "Level finished. Wait (%d) to proceed or ESC to Quit."
|
|
|
|
, time);
|
2009-11-24 09:48:53 +00:00
|
|
|
}
|
|
|
|
|
2015-08-12 03:11:46 +00:00
|
|
|
namespace {
|
|
|
|
|
2014-09-07 18:06:59 +00:00
|
|
|
struct kmatrix_screen : ignore_window_pointer_t
|
2009-11-24 09:48:53 +00:00
|
|
|
{
|
2016-10-29 23:16:15 +00:00
|
|
|
grs_main_bitmap background;
|
2010-07-27 11:41:43 +00:00
|
|
|
int network;
|
2010-12-10 23:18:17 +00:00
|
|
|
fix64 end_time;
|
2010-07-27 11:41:43 +00:00
|
|
|
int playing;
|
2015-03-23 02:03:22 +00:00
|
|
|
int aborted;
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2015-08-12 03:11:46 +00:00
|
|
|
}
|
|
|
|
|
2016-08-25 04:05:32 +00:00
|
|
|
namespace dsx {
|
2013-10-27 22:00:14 +00:00
|
|
|
static void kmatrix_redraw(kmatrix_screen *km)
|
2010-07-27 11:41:43 +00:00
|
|
|
{
|
2014-09-21 22:10:12 +00:00
|
|
|
playernum_array_t sorted;
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2017-11-05 20:49:08 +00:00
|
|
|
gr_set_default_canvas();
|
2017-03-10 01:22:33 +00:00
|
|
|
auto &canvas = *grd_curcanv;
|
|
|
|
show_fullscr(canvas, km->background);
|
2010-07-27 11:41:43 +00:00
|
|
|
|
2009-11-24 09:48:53 +00:00
|
|
|
if (Game_mode & GM_MULTI_COOP)
|
|
|
|
{
|
2017-07-26 03:15:59 +00:00
|
|
|
kmatrix_redraw_coop(vcobjptr);
|
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);
|
2018-05-19 23:21:42 +00:00
|
|
|
kmatrix_draw_names(canvas, game_font, sorted);
|
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
|
|
|
}
|
2018-05-19 23:21:42 +00:00
|
|
|
kmatrix_draw_item(vcobjptr, canvas, game_font, i, sorted);
|
2009-11-24 09:48:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gr_palette_load(gr_palette);
|
|
|
|
}
|
2016-08-25 04:05:32 +00:00
|
|
|
}
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2017-07-26 03:15:59 +00:00
|
|
|
static void kmatrix_redraw_coop(fvcobjptr &vcobjptr)
|
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();
|
2017-03-10 01:22:33 +00:00
|
|
|
auto &canvas = *grd_curcanv;
|
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;
|
|
|
|
kmatrix_draw_coop_names(canvas, game_font);
|
2016-10-15 00:53:14 +00:00
|
|
|
const auto &&fspacx = FSPACX();
|
|
|
|
const auto &&fspacy = FSPACY();
|
|
|
|
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
|
|
|
|
2016-10-15 00:53:14 +00:00
|
|
|
const auto &&y = fspacy(50 + 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);
|
|
|
|
}
|
|
|
|
|
2016-08-25 04:05:32 +00:00
|
|
|
namespace dsx {
|
2016-10-04 06:05:44 +00:00
|
|
|
static window_event_result kmatrix_handler(window *, const d_event &event, kmatrix_screen *km)
|
2010-03-20 13:21:53 +00:00
|
|
|
{
|
2014-09-20 23:47:27 +00:00
|
|
|
int k = 0, choice = 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:
|
|
|
|
{
|
2015-03-22 18:49:21 +00:00
|
|
|
array<newmenu_item, 2> nm_message_items{{
|
2015-01-18 01:58:31 +00:00
|
|
|
nm_item_menu(TXT_YES),
|
|
|
|
nm_item_menu(TXT_NO),
|
2015-03-22 18:49:21 +00:00
|
|
|
}};
|
2016-01-26 03:45:06 +00:00
|
|
|
choice = newmenu_do(nullptr, TXT_ABORT_GAME, nm_message_items, km->network ? get_multi_endlevel_poll2() : unused_newmenu_subfunction, unused_newmenu_userdata);
|
2010-03-20 13:21:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (choice==0)
|
|
|
|
{
|
2015-07-25 23:10:46 +00:00
|
|
|
get_local_player().connected=CONNECT_DISCONNECTED;
|
2010-03-20 13:21:53 +00:00
|
|
|
|
|
|
|
if (km->network)
|
|
|
|
multi_send_endlevel_packet();
|
|
|
|
|
|
|
|
multi_leave_game();
|
2015-03-23 02:03:22 +00:00
|
|
|
km->aborted = 1;
|
|
|
|
|
2014-08-06 02:10:49 +00:00
|
|
|
return window_event_result::close;
|
2010-03-20 13:21:53 +00:00
|
|
|
}
|
2014-08-06 02:10:49 +00:00
|
|
|
return window_event_result::handled;
|
2010-03-20 13:21:53 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-01-14 21:56:00 +00:00
|
|
|
case EVENT_WINDOW_DRAW:
|
2010-03-20 13:21:53 +00:00
|
|
|
timer_delay2(50);
|
|
|
|
|
|
|
|
if (km->network)
|
|
|
|
multi_do_protocol_frame(0, 1);
|
|
|
|
|
2010-03-27 02:54:41 +00:00
|
|
|
km->playing = 0;
|
|
|
|
|
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)
|
|
|
|
{
|
2010-03-20 13:21:53 +00:00
|
|
|
km->playing = 1;
|
2015-02-14 22:48:27 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-03-20 13:21:53 +00:00
|
|
|
|
|
|
|
// ... 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)
|
2010-12-10 23:18:17 +00:00
|
|
|
km->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
|
2010-12-10 23:18:17 +00:00
|
|
|
if (timer_query() >= km->end_time && km->end_time != -1)
|
2010-03-20 13:21:53 +00:00
|
|
|
{
|
|
|
|
if (km->network)
|
|
|
|
multi_send_endlevel_packet(); // make sure
|
|
|
|
|
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
|
|
|
|
|
|
|
if (km->network)
|
|
|
|
multi_send_endlevel_packet();
|
|
|
|
|
|
|
|
multi_leave_game();
|
2015-03-23 02:03:22 +00:00
|
|
|
km->aborted = 1;
|
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
|
2014-08-06 02:10:49 +00:00
|
|
|
return window_event_result::close;
|
2010-03-20 13:21:53 +00:00
|
|
|
}
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2010-07-27 11:41:43 +00:00
|
|
|
kmatrix_redraw(km);
|
2017-03-11 19:56:29 +00:00
|
|
|
kmatrix_status_msg(*grd_curcanv, km->playing ? Countdown_seconds_left : f2i(timer_query() - km->end_time), km->playing);
|
2010-03-20 13:21:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EVENT_WINDOW_CLOSE:
|
|
|
|
game_flush_inputs();
|
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
|
|
|
}
|
2016-08-25 04:05:32 +00:00
|
|
|
}
|
2009-11-24 09:48:53 +00:00
|
|
|
|
2015-03-24 02:07:42 +00:00
|
|
|
kmatrix_result kmatrix_view(int network)
|
2010-03-20 13:21:53 +00:00
|
|
|
{
|
2013-12-08 16:50:19 +00:00
|
|
|
kmatrix_screen km;
|
2016-05-28 17:31:26 +00:00
|
|
|
if (pcx_read_bitmap(STARS_BACKGROUND, km.background, gr_palette) != PCX_ERROR_NONE)
|
2010-07-27 11:41:43 +00:00
|
|
|
{
|
2015-03-24 02:07:42 +00:00
|
|
|
return kmatrix_result::abort;
|
2010-07-27 11:41:43 +00:00
|
|
|
}
|
|
|
|
gr_palette_load(gr_palette);
|
|
|
|
|
2013-12-08 16:50:19 +00:00
|
|
|
km.network = network;
|
|
|
|
km.end_time = -1;
|
|
|
|
km.playing = 0;
|
2015-03-23 02:03:22 +00:00
|
|
|
km.aborted = 0;
|
2010-03-20 13:21:53 +00:00
|
|
|
|
|
|
|
set_screen_mode( SCREEN_MENU );
|
2009-11-24 09:48:53 +00:00
|
|
|
game_flush_inputs();
|
|
|
|
|
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-15 00:53:20 +00:00
|
|
|
const auto wind = window_create(grd_curscreen->sc_canvas, 0, 0, SWIDTH, SHEIGHT, kmatrix_handler, &km);
|
2010-03-20 13:21:53 +00:00
|
|
|
if (!wind)
|
|
|
|
{
|
2015-03-24 02:07:42 +00:00
|
|
|
return kmatrix_result::abort;
|
2009-11-24 09:48:53 +00:00
|
|
|
}
|
2010-03-20 13:21:53 +00:00
|
|
|
|
2016-10-29 12:06:01 +00:00
|
|
|
event_process_all();
|
2016-10-28 07:27:45 +00:00
|
|
|
|
2015-03-24 02:07:42 +00:00
|
|
|
return (km.aborted ? kmatrix_result::abort : kmatrix_result::proceed);
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|