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 .
*/
/*
*
* Inferno gauge drivers
*
*/
2012-11-11 22:12:51 +00:00
# include <algorithm>
2006-03-20 17:12:09 +00:00
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <stdarg.h>
# include "hudmsg.h"
# include "inferno.h"
# include "game.h"
# include "screens.h"
# include "gauges.h"
# include "physics.h"
2012-07-07 18:35:06 +00:00
# include "dxxerror.h"
2006-03-20 17:12:09 +00:00
# include "menu.h" // For the font.
# include "collide.h"
2014-11-23 04:36:58 +00:00
# include "object.h"
2006-03-20 17:12:09 +00:00
# include "newdemo.h"
# include "player.h"
# include "gamefont.h"
# include "bm.h"
# include "text.h"
# include "powerup.h"
# include "sounds.h"
# include "multi.h"
# include "endlevel.h"
# include "cntrlcen.h"
# include "controls.h"
# include "text.h"
# include "render.h"
# include "piggy.h"
# include "laser.h"
2015-07-25 23:10:45 +00:00
# include "weapon.h"
2013-09-24 01:59:09 +00:00
# include "common/3d/globvars.h"
2008-04-13 00:28:36 +00:00
# include "playsave.h"
2008-11-09 14:31:30 +00:00
# include "rle.h"
2006-03-20 17:12:09 +00:00
# ifdef OGL
# include "ogl_init.h"
# endif
2013-03-03 19:41:09 +00:00
# include "args.h"
2006-03-20 17:12:09 +00:00
2015-04-02 02:36:53 +00:00
# include "compiler-exchange.h"
2015-09-13 21:02:19 +00:00
# include "compiler-range_for.h"
# include "partial_range.h"
2015-04-02 02:36:53 +00:00
2012-11-11 22:12:51 +00:00
using std : : min ;
2015-04-26 20:15:53 +00:00
namespace {
2015-04-26 20:15:53 +00:00
class local_multires_gauge_graphic
2015-04-26 20:15:53 +00:00
{
2015-04-26 20:15:53 +00:00
bool hiresmode ;
2015-04-26 20:15:53 +00:00
public :
2015-04-26 20:15:53 +00:00
local_multires_gauge_graphic ( ) :
hiresmode ( HIRESMODE )
{
}
2015-04-26 20:15:53 +00:00
bool is_hires ( ) const
{
2015-04-26 20:15:53 +00:00
return hiresmode ;
2015-04-26 20:15:53 +00:00
}
2015-05-30 16:06:05 +00:00
template < typename T >
T get ( T h , T l ) const
2015-04-26 20:15:53 +00:00
{
return is_hires ( ) ? h : l ;
}
template < typename T >
const T & rget ( const T & h , const T & l ) const
{
return is_hires ( ) ? h : l ;
}
} ;
}
2006-03-20 17:12:09 +00:00
//bitmap numbers for gauges
# define GAUGE_SHIELDS 0 //0..9, in decreasing order (100%,90%...0%)
# define GAUGE_INVULNERABLE 10 //10..19
# define N_INVULNERABLE_FRAMES 10
# define GAUGE_ENERGY_LEFT 21
# define GAUGE_ENERGY_RIGHT 22
# define GAUGE_NUMERICAL 23
# define GAUGE_BLUE_KEY 24
# define GAUGE_GOLD_KEY 25
# define GAUGE_RED_KEY 26
# define GAUGE_BLUE_KEY_OFF 27
# define GAUGE_GOLD_KEY_OFF 28
# define GAUGE_RED_KEY_OFF 29
# define SB_GAUGE_BLUE_KEY 30
# define SB_GAUGE_GOLD_KEY 31
# define SB_GAUGE_RED_KEY 32
# define SB_GAUGE_BLUE_KEY_OFF 33
# define SB_GAUGE_GOLD_KEY_OFF 34
# define SB_GAUGE_RED_KEY_OFF 35
# define SB_GAUGE_ENERGY 36
2010-06-18 07:31:06 +00:00
# define GAUGE_LIVES 37
2006-08-30 18:12:04 +00:00
# define GAUGE_SHIPS 38
2006-03-20 17:12:09 +00:00
# define RETICLE_CROSS 46
# define RETICLE_PRIMARY 48
# define RETICLE_SECONDARY 51
# define GAUGE_HOMING_WARNING_ON 56
# define GAUGE_HOMING_WARNING_OFF 57
# define KEY_ICON_BLUE 68
# define KEY_ICON_YELLOW 69
2006-08-30 18:12:04 +00:00
# define KEY_ICON_RED 70
2013-03-03 01:03:33 +00:00
//Coordinats for gauges
# if defined(DXX_BUILD_DESCENT_I)
# define GAUGE_BLUE_KEY_X_L 45
# define GAUGE_BLUE_KEY_X_H 91
# define GAUGE_GOLD_KEY_X_L 44
# define GAUGE_GOLD_KEY_X_H 89
# define GAUGE_RED_KEY_X_L 43
# define GAUGE_RED_KEY_X_H 87
# define GAUGE_RED_KEY_Y_H 417
# define LEFT_ENERGY_GAUGE_X_H 137
2015-04-26 20:15:53 +00:00
# define RIGHT_ENERGY_GAUGE_X ((multires_gauge_graphic.get(380, 190)))
2013-03-03 01:03:33 +00:00
# elif defined(DXX_BUILD_DESCENT_II)
# define GAUGE_AFTERBURNER 20
2006-03-20 17:12:09 +00:00
# define SB_GAUGE_AFTERBURNER 71
# define FLAG_ICON_RED 72
# define FLAG_ICON_BLUE 73
# define GAUGE_BLUE_KEY_X_L 272
# define GAUGE_BLUE_KEY_X_H 535
2013-03-03 01:03:33 +00:00
# define GAUGE_GOLD_KEY_X_L 273
# define GAUGE_GOLD_KEY_X_H 537
# define GAUGE_RED_KEY_X_L 274
# define GAUGE_RED_KEY_X_H 539
# define GAUGE_RED_KEY_Y_H 416
# define LEFT_ENERGY_GAUGE_X_H 138
2015-04-26 20:15:53 +00:00
# define RIGHT_ENERGY_GAUGE_X ((multires_gauge_graphic.get(379, 190)))
2013-03-03 01:03:33 +00:00
# endif
# define GAUGE_BLUE_KEY_Y_L 152
2006-03-20 17:12:09 +00:00
# define GAUGE_BLUE_KEY_Y_H 374
2015-04-26 20:15:53 +00:00
# define GAUGE_BLUE_KEY_X ((multires_gauge_graphic.get(GAUGE_BLUE_KEY_X_H, GAUGE_BLUE_KEY_X_L)))
# define GAUGE_BLUE_KEY_Y ((multires_gauge_graphic.get(GAUGE_BLUE_KEY_Y_H, GAUGE_BLUE_KEY_Y_L)))
2006-03-20 17:12:09 +00:00
# define GAUGE_GOLD_KEY_Y_L 162
# define GAUGE_GOLD_KEY_Y_H 395
2015-04-26 20:15:53 +00:00
# define GAUGE_GOLD_KEY_X ((multires_gauge_graphic.get(GAUGE_GOLD_KEY_X_H, GAUGE_GOLD_KEY_X_L)))
# define GAUGE_GOLD_KEY_Y ((multires_gauge_graphic.get(GAUGE_GOLD_KEY_Y_H, GAUGE_GOLD_KEY_Y_L)))
2006-03-20 17:12:09 +00:00
# define GAUGE_RED_KEY_Y_L 172
2015-04-26 20:15:53 +00:00
# define GAUGE_RED_KEY_X ((multires_gauge_graphic.get(GAUGE_RED_KEY_X_H, GAUGE_RED_KEY_X_L)))
# define GAUGE_RED_KEY_Y ((multires_gauge_graphic.get(GAUGE_RED_KEY_Y_H, GAUGE_RED_KEY_Y_L)))
2006-03-20 17:12:09 +00:00
# define SB_GAUGE_KEYS_X_L 11
# define SB_GAUGE_KEYS_X_H 26
2015-04-26 20:15:53 +00:00
# define SB_GAUGE_KEYS_X ((multires_gauge_graphic.get(SB_GAUGE_KEYS_X_H, SB_GAUGE_KEYS_X_L)))
2006-03-20 17:12:09 +00:00
# define SB_GAUGE_BLUE_KEY_Y_L 153
# define SB_GAUGE_GOLD_KEY_Y_L 169
# define SB_GAUGE_RED_KEY_Y_L 185
# define SB_GAUGE_BLUE_KEY_Y_H 390
# define SB_GAUGE_GOLD_KEY_Y_H 422
# define SB_GAUGE_RED_KEY_Y_H 454
2015-04-26 20:15:53 +00:00
# define SB_GAUGE_BLUE_KEY_Y ((multires_gauge_graphic.get(SB_GAUGE_BLUE_KEY_Y_H, SB_GAUGE_BLUE_KEY_Y_L)))
# define SB_GAUGE_GOLD_KEY_Y ((multires_gauge_graphic.get(SB_GAUGE_GOLD_KEY_Y_H, SB_GAUGE_GOLD_KEY_Y_L)))
# define SB_GAUGE_RED_KEY_Y ((multires_gauge_graphic.get(SB_GAUGE_RED_KEY_Y_H, SB_GAUGE_RED_KEY_Y_L)))
2006-03-20 17:12:09 +00:00
# define LEFT_ENERGY_GAUGE_X_L 70
# define LEFT_ENERGY_GAUGE_Y_L 131
# define LEFT_ENERGY_GAUGE_W_L 64
# define LEFT_ENERGY_GAUGE_H_L 8
# define LEFT_ENERGY_GAUGE_Y_H 314
# define LEFT_ENERGY_GAUGE_W_H 133
# define LEFT_ENERGY_GAUGE_H_H 21
2015-04-26 20:15:53 +00:00
# define LEFT_ENERGY_GAUGE_X ((multires_gauge_graphic.get(LEFT_ENERGY_GAUGE_X_H, LEFT_ENERGY_GAUGE_X_L)))
# define LEFT_ENERGY_GAUGE_Y ((multires_gauge_graphic.get(LEFT_ENERGY_GAUGE_Y_H, LEFT_ENERGY_GAUGE_Y_L)))
# define LEFT_ENERGY_GAUGE_W ((multires_gauge_graphic.get(LEFT_ENERGY_GAUGE_W_H, LEFT_ENERGY_GAUGE_W_L)))
# define LEFT_ENERGY_GAUGE_H ((multires_gauge_graphic.get(LEFT_ENERGY_GAUGE_H_H, LEFT_ENERGY_GAUGE_H_L)))
# define RIGHT_ENERGY_GAUGE_Y ((multires_gauge_graphic.get(314, 131)))
# define RIGHT_ENERGY_GAUGE_W ((multires_gauge_graphic.get(133, 64)))
# define RIGHT_ENERGY_GAUGE_H ((multires_gauge_graphic.get(21, 8)))
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
2015-04-26 20:15:53 +00:00
# define SB_ENERGY_GAUGE_Y ((multires_gauge_graphic.get(390, 155)))
# define SB_ENERGY_GAUGE_H ((multires_gauge_graphic.get(82, 41)))
# define SB_ENERGY_NUM_Y ((multires_gauge_graphic.get(457, 190)))
# define SHIELD_GAUGE_Y ((multires_gauge_graphic.get(374, 155)))
# define SB_SHIELD_NUM_Y (SB_SHIELD_GAUGE_Y-((multires_gauge_graphic.get(16, 7)))) //156 -- MWA used to be hard coded to 156
# define NUMERICAL_GAUGE_Y ((multires_gauge_graphic.get(316, 130)))
# define PRIMARY_W_PIC_X ((multires_gauge_graphic.get(135, 64)))
# define SECONDARY_W_PIC_X ((multires_gauge_graphic.get(405, 234)))
# define SECONDARY_W_PIC_Y ((multires_gauge_graphic.get(370, 154)))
# define SECONDARY_W_TEXT_X HUD_SCALE_X((multires_gauge_graphic.get(462, 207)))
# define SECONDARY_W_TEXT_Y HUD_SCALE_Y((multires_gauge_graphic.get(400, 157)))
# define SECONDARY_AMMO_X HUD_SCALE_X((multires_gauge_graphic.get(475, 213)))
# define SECONDARY_AMMO_Y HUD_SCALE_Y((multires_gauge_graphic.get(425, 171)))
# define SB_LIVES_X ((multires_gauge_graphic.get(550, 266)))
# define SB_LIVES_Y ((multires_gauge_graphic.get(450, 185)))
2013-03-03 01:03:33 +00:00
# define SB_SCORE_RIGHT_H 605
2015-04-26 20:15:53 +00:00
# define BOMB_COUNT_X ((multires_gauge_graphic.get(468, 210)))
2013-03-03 01:03:33 +00:00
# define PRIMARY_W_BOX_RIGHT_H 241
# define SECONDARY_W_BOX_RIGHT_L 264 //(SECONDARY_W_BOX_LEFT+54)
# define SECONDARY_W_BOX_LEFT_H 403
# define SECONDARY_W_BOX_TOP_H 364
# define SECONDARY_W_BOX_RIGHT_H 531
# define SB_PRIMARY_W_BOX_TOP_L 154
# define SB_PRIMARY_W_BOX_BOT_L (195)
# define SB_SECONDARY_W_BOX_TOP_L 154
# define SB_SECONDARY_W_BOX_RIGHT_L (SB_SECONDARY_W_BOX_LEFT_L+54)
# define SB_SECONDARY_W_BOX_BOT_L (153+42)
2015-04-26 20:15:53 +00:00
# define SB_SECONDARY_AMMO_X HUD_SCALE_X(SB_SECONDARY_W_BOX_LEFT+((multires_gauge_graphic.get(14,11)))) //(212+9)
2013-03-03 01:03:33 +00:00
# define GET_GAUGE_INDEX(x) (Gauges[x].index)
# elif defined(DXX_BUILD_DESCENT_II)
2006-03-20 17:12:09 +00:00
# define AFTERBURNER_GAUGE_X_L 45-1
# define AFTERBURNER_GAUGE_Y_L 158
# define AFTERBURNER_GAUGE_H_L 32
# define AFTERBURNER_GAUGE_X_H 88
2007-10-05 23:47:16 +00:00
# define AFTERBURNER_GAUGE_Y_H 378
2006-03-20 17:12:09 +00:00
# define AFTERBURNER_GAUGE_H_H 65
2015-04-26 20:15:53 +00:00
# define AFTERBURNER_GAUGE_X ((multires_gauge_graphic.get(AFTERBURNER_GAUGE_X_H, AFTERBURNER_GAUGE_X_L)))
# define AFTERBURNER_GAUGE_Y ((multires_gauge_graphic.get(AFTERBURNER_GAUGE_Y_H, AFTERBURNER_GAUGE_Y_L)))
# define AFTERBURNER_GAUGE_H ((multires_gauge_graphic.get(AFTERBURNER_GAUGE_H_H, AFTERBURNER_GAUGE_H_L)))
# define SB_AFTERBURNER_GAUGE_X ((multires_gauge_graphic.get(196, 98)))
# define SB_AFTERBURNER_GAUGE_Y ((multires_gauge_graphic.get(445, 184)))
# define SB_AFTERBURNER_GAUGE_W ((multires_gauge_graphic.get(33, 16)))
# define SB_AFTERBURNER_GAUGE_H ((multires_gauge_graphic.get(29, 13)))
# define SB_ENERGY_GAUGE_Y ((multires_gauge_graphic.get(381, 155-2)))
# define SB_ENERGY_GAUGE_H ((multires_gauge_graphic.get(60, 29)))
# define SB_ENERGY_NUM_Y ((multires_gauge_graphic.get(457, 175)))
# define SHIELD_GAUGE_Y ((multires_gauge_graphic.get(375, 155)))
# define SB_SHIELD_NUM_Y (SB_SHIELD_GAUGE_Y-((multires_gauge_graphic.get(16, 8)))) //156 -- MWA used to be hard coded to 156
# define NUMERICAL_GAUGE_Y ((multires_gauge_graphic.get(314, 130)))
# define PRIMARY_W_PIC_X ((multires_gauge_graphic.get(135-10, 64)))
# define SECONDARY_W_PIC_X ((multires_gauge_graphic.get(466, 234)))
# define SECONDARY_W_PIC_Y ((multires_gauge_graphic.get(374, 154)))
# define SECONDARY_W_TEXT_X HUD_SCALE_X((multires_gauge_graphic.get(413, 207)))
# define SECONDARY_W_TEXT_Y HUD_SCALE_Y((multires_gauge_graphic.get(378, 157)))
# define SECONDARY_AMMO_X HUD_SCALE_X((multires_gauge_graphic.get(428, 213)))
# define SECONDARY_AMMO_Y HUD_SCALE_Y((multires_gauge_graphic.get(407, 171)))
# define SB_LIVES_X ((multires_gauge_graphic.get(550-10-3, 266)))
# define SB_LIVES_Y ((multires_gauge_graphic.get(450-3, 185)))
2013-03-03 01:03:33 +00:00
# define SB_SCORE_RIGHT_H (605+8)
2015-04-26 20:15:53 +00:00
# define BOMB_COUNT_X ((multires_gauge_graphic.get(546, 275)))
2013-03-03 01:03:33 +00:00
# define PRIMARY_W_BOX_RIGHT_H 242
# define SECONDARY_W_BOX_RIGHT_L 263 //(SECONDARY_W_BOX_LEFT+54)
# define SECONDARY_W_BOX_LEFT_H 404
# define SECONDARY_W_BOX_TOP_H 363
# define SECONDARY_W_BOX_RIGHT_H 529
# define SB_PRIMARY_W_BOX_TOP_L 153
# define SB_PRIMARY_W_BOX_BOT_L (195+1)
# define SB_SECONDARY_W_BOX_TOP_L 153
# define SB_SECONDARY_W_BOX_RIGHT_L (SB_SECONDARY_W_BOX_LEFT_L+54+1)
# define SB_SECONDARY_W_BOX_BOT_L (SB_SECONDARY_W_BOX_TOP_L+43)
2015-04-26 20:15:53 +00:00
# define SB_SECONDARY_AMMO_X HUD_SCALE_X(SB_SECONDARY_W_BOX_LEFT+((multires_gauge_graphic.get(14-4, 11)))) //(212+9)
# define GET_GAUGE_INDEX(x) ((multires_gauge_graphic.rget(Gauges_hires, Gauges)[x].index))
2013-03-03 01:03:33 +00:00
# endif
// MOVEME
2015-04-26 20:15:53 +00:00
# define HOMING_WARNING_X ((multires_gauge_graphic.get(13, 7)))
# define HOMING_WARNING_Y ((multires_gauge_graphic.get(416, 171)))
# define SB_ENERGY_GAUGE_X ((multires_gauge_graphic.get(196, 98)))
# define SB_ENERGY_GAUGE_W ((multires_gauge_graphic.get(32, 16)))
# define SHIP_GAUGE_X (SHIELD_GAUGE_X+((multires_gauge_graphic.get(11, 5))))
# define SHIP_GAUGE_Y (SHIELD_GAUGE_Y+((multires_gauge_graphic.get(10, 5))))
# define SHIELD_GAUGE_X ((multires_gauge_graphic.get(292, 146)))
# define SB_SHIELD_GAUGE_X ((multires_gauge_graphic.get(247, 123))) //139
# define SB_SHIELD_GAUGE_Y ((multires_gauge_graphic.get(395, 163)))
# define SB_SHIP_GAUGE_X (SB_SHIELD_GAUGE_X+((multires_gauge_graphic.get(11, 5))))
# define SB_SHIP_GAUGE_Y (SB_SHIELD_GAUGE_Y+((multires_gauge_graphic.get(10, 5))))
# define SB_SHIELD_NUM_X (SB_SHIELD_GAUGE_X+((multires_gauge_graphic.get(21, 12)))) //151
# define NUMERICAL_GAUGE_X ((multires_gauge_graphic.get(308, 154)))
# define PRIMARY_W_PIC_Y ((multires_gauge_graphic.get(370, 154)))
# define PRIMARY_W_TEXT_X HUD_SCALE_X((multires_gauge_graphic.get(182, 87)))
2015-08-18 17:17:24 +00:00
# define PRIMARY_W_TEXT_Y HUD_SCALE_Y((multires_gauge_graphic.get(378, 157)))
2015-04-26 20:15:53 +00:00
# define PRIMARY_AMMO_X HUD_SCALE_X((multires_gauge_graphic.get(186, 93)))
2015-08-18 17:17:24 +00:00
# define PRIMARY_AMMO_Y HUD_SCALE_Y((multires_gauge_graphic.get(407, 171)))
2015-04-26 20:15:53 +00:00
# define SB_LIVES_LABEL_X ((multires_gauge_graphic.get(475, 237)))
2006-03-20 17:12:09 +00:00
# define SB_SCORE_RIGHT_L 301
2015-04-26 20:15:53 +00:00
# define SB_SCORE_RIGHT ((multires_gauge_graphic.get(SB_SCORE_RIGHT_H, SB_SCORE_RIGHT_L)))
# define SB_SCORE_Y ((multires_gauge_graphic.get(398, 158)))
# define SB_SCORE_LABEL_X ((multires_gauge_graphic.get(475, 237)))
# define SB_SCORE_ADDED_RIGHT ((multires_gauge_graphic.get(SB_SCORE_RIGHT_H, SB_SCORE_RIGHT_L)))
# define SB_SCORE_ADDED_Y ((multires_gauge_graphic.get(413, 165)))
# define BOMB_COUNT_Y ((multires_gauge_graphic.get(445, 186)))
# define SB_BOMB_COUNT_X ((multires_gauge_graphic.get(342, 171)))
# define SB_BOMB_COUNT_Y ((multires_gauge_graphic.get(458, 191)))
2006-03-20 17:12:09 +00:00
// defining box boundries for weapon pictures
# define PRIMARY_W_BOX_LEFT_L 63
# define PRIMARY_W_BOX_TOP_L 151 //154
2013-03-03 01:03:33 +00:00
# define PRIMARY_W_BOX_RIGHT_L (PRIMARY_W_BOX_LEFT_L+58)
# define PRIMARY_W_BOX_BOT_L (PRIMARY_W_BOX_TOP_L+42)
2006-03-20 17:12:09 +00:00
# define PRIMARY_W_BOX_LEFT_H 121
# define PRIMARY_W_BOX_TOP_H 364
2013-03-03 01:03:33 +00:00
# define PRIMARY_W_BOX_BOT_H (PRIMARY_W_BOX_TOP_H+106) //470
2015-04-26 20:15:53 +00:00
# define PRIMARY_W_BOX_LEFT ((multires_gauge_graphic.get(PRIMARY_W_BOX_LEFT_H, PRIMARY_W_BOX_LEFT_L)))
# define PRIMARY_W_BOX_TOP ((multires_gauge_graphic.get(PRIMARY_W_BOX_TOP_H, PRIMARY_W_BOX_TOP_L)))
# define PRIMARY_W_BOX_RIGHT ((multires_gauge_graphic.get(PRIMARY_W_BOX_RIGHT_H, PRIMARY_W_BOX_RIGHT_L)))
# define PRIMARY_W_BOX_BOT ((multires_gauge_graphic.get(PRIMARY_W_BOX_BOT_H, PRIMARY_W_BOX_BOT_L)))
2006-03-20 17:12:09 +00:00
# define SECONDARY_W_BOX_LEFT_L 202 //207
# define SECONDARY_W_BOX_TOP_L 151
2013-03-03 01:03:33 +00:00
# define SECONDARY_W_BOX_BOT_L (SECONDARY_W_BOX_TOP_L+42)
# define SECONDARY_W_BOX_BOT_H (SECONDARY_W_BOX_TOP_H+106) //470
2015-04-26 20:15:53 +00:00
# define SECONDARY_W_BOX_LEFT ((multires_gauge_graphic.get(SECONDARY_W_BOX_LEFT_H, SECONDARY_W_BOX_LEFT_L)))
# define SECONDARY_W_BOX_TOP ((multires_gauge_graphic.get(SECONDARY_W_BOX_TOP_H, SECONDARY_W_BOX_TOP_L)))
# define SECONDARY_W_BOX_RIGHT ((multires_gauge_graphic.get(SECONDARY_W_BOX_RIGHT_H, SECONDARY_W_BOX_RIGHT_L)))
# define SECONDARY_W_BOX_BOT ((multires_gauge_graphic.get(SECONDARY_W_BOX_BOT_H, SECONDARY_W_BOX_BOT_L)))
2006-03-20 17:12:09 +00:00
# define SB_PRIMARY_W_BOX_LEFT_L 34 //50
2013-03-03 01:03:33 +00:00
# define SB_PRIMARY_W_BOX_RIGHT_L (SB_PRIMARY_W_BOX_LEFT_L+55)
2006-03-20 17:12:09 +00:00
# define SB_PRIMARY_W_BOX_LEFT_H 68
# define SB_PRIMARY_W_BOX_TOP_H 381
# define SB_PRIMARY_W_BOX_RIGHT_H 179
# define SB_PRIMARY_W_BOX_BOT_H 473
2015-04-26 20:15:53 +00:00
# define SB_PRIMARY_W_BOX_LEFT ((multires_gauge_graphic.get(SB_PRIMARY_W_BOX_LEFT_H, SB_PRIMARY_W_BOX_LEFT_L)))
2006-03-20 17:12:09 +00:00
# define SB_SECONDARY_W_BOX_LEFT_L 169
# define SB_SECONDARY_W_BOX_LEFT_H 338
# define SB_SECONDARY_W_BOX_TOP_H 381
# define SB_SECONDARY_W_BOX_RIGHT_H 449
# define SB_SECONDARY_W_BOX_BOT_H 473
2015-04-26 20:15:53 +00:00
# define SB_SECONDARY_W_BOX_LEFT ((multires_gauge_graphic.get(SB_SECONDARY_W_BOX_LEFT_H, SB_SECONDARY_W_BOX_LEFT_L))) //210
2006-03-20 17:12:09 +00:00
# define SB_PRIMARY_W_PIC_X (SB_PRIMARY_W_BOX_LEFT+1) //51
2015-04-26 20:15:53 +00:00
# define SB_PRIMARY_W_PIC_Y ((multires_gauge_graphic.get(382, 154)))
# define SB_PRIMARY_W_TEXT_X HUD_SCALE_X(SB_PRIMARY_W_BOX_LEFT+((multires_gauge_graphic.get(50, 24)))) //(51+23)
# define SB_PRIMARY_W_TEXT_Y HUD_SCALE_Y((multires_gauge_graphic.get(390, 157)))
# define SB_PRIMARY_AMMO_X HUD_SCALE_X(SB_PRIMARY_W_BOX_LEFT+((multires_gauge_graphic.get(58, 30)))) //((SB_PRIMARY_W_BOX_LEFT+33)-3) //(51+32)
# define SB_PRIMARY_AMMO_Y HUD_SCALE_Y((multires_gauge_graphic.get(410, 171)))
# define SB_SECONDARY_W_PIC_X ((multires_gauge_graphic.get(385, (SB_SECONDARY_W_BOX_LEFT+27)))) //(212+27)
# define SB_SECONDARY_W_PIC_Y ((multires_gauge_graphic.get(382, 154)))
2007-06-10 16:21:53 +00:00
# define SB_SECONDARY_W_TEXT_X HUD_SCALE_X(SB_SECONDARY_W_BOX_LEFT+2) //212
2015-04-26 20:15:53 +00:00
# define SB_SECONDARY_W_TEXT_Y HUD_SCALE_Y((multires_gauge_graphic.get(390, 157)))
# define SB_SECONDARY_AMMO_Y HUD_SCALE_Y((multires_gauge_graphic.get(414, 171)))
2008-02-24 14:41:27 +00:00
# define WS_SET 0 //in correct state
# define WS_FADING_OUT 1
# define WS_FADING_IN 2
# define FADE_SCALE (2*i2f(GR_FADE_LEVELS) / REARM_TIME) // fade out and back in REARM_TIME, in fade levels per seconds (int)
2015-04-26 20:15:53 +00:00
# define COCKPIT_PRIMARY_BOX ((multires_gauge_graphic.get(4, 0)))
# define COCKPIT_SECONDARY_BOX ((multires_gauge_graphic.get(5, 1)))
# define SB_PRIMARY_BOX ((multires_gauge_graphic.get(6, 2)))
# define SB_SECONDARY_BOX ((multires_gauge_graphic.get(7, 3)))
2008-02-24 14:41:27 +00:00
// scaling gauges
2015-04-26 20:15:53 +00:00
# define BASE_WIDTH ((multires_gauge_graphic.get(640, 320)))
# define BASE_HEIGHT ((multires_gauge_graphic.get(480, 200)))
2008-02-24 14:41:27 +00:00
# ifdef OGL
2015-03-22 18:49:21 +00:00
# define HUD_SCALE_X(x) static_cast<int>(static_cast<double>(x) * (static_cast<double>(grd_curscreen->get_screen_width()) / BASE_WIDTH) + 0.5)
# define HUD_SCALE_Y(y) static_cast<int>(static_cast<double>(y) * (static_cast<double>(grd_curscreen->get_screen_height()) / BASE_HEIGHT) + 0.5)
2008-11-09 14:31:30 +00:00
# define HUD_SCALE_X_AR(x) (HUD_SCALE_X(100) > HUD_SCALE_Y(100) ? HUD_SCALE_Y(x) : HUD_SCALE_X(x))
# define HUD_SCALE_Y_AR(y) (HUD_SCALE_Y(100) > HUD_SCALE_X(100) ? HUD_SCALE_X(y) : HUD_SCALE_Y(y))
2015-05-09 17:38:57 +00:00
# define draw_numerical_display(S,E,G) draw_numerical_display(S,E)
2008-02-24 14:41:27 +00:00
# else
2015-05-09 17:38:57 +00:00
# define HUD_SCALE_X(x) (static_cast<void>(multires_gauge_graphic), x)
# define HUD_SCALE_Y(y) (static_cast<void>(multires_gauge_graphic), y)
# define HUD_SCALE_X_AR(x) HUD_SCALE_X(x)
# define HUD_SCALE_Y_AR(y) HUD_SCALE_Y(y)
# define hud_bitblt_free(X,Y,W,H,B) hud_bitblt_free(X,Y,B)
# define hud_bitblt(X,Y,B,G) hud_bitblt(X,Y,B)
2008-02-24 14:41:27 +00:00
# endif
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
2015-02-14 22:48:30 +00:00
array < bitmap_index , MAX_GAUGE_BMS_MAC > Gauges ; // Array of all gauge bitmaps.
2015-04-26 20:15:53 +00:00
# define PAGE_IN_GAUGE(x,...) PAGE_IN_GAUGE(x)
2013-03-03 01:03:33 +00:00
# elif defined(DXX_BUILD_DESCENT_II)
2015-02-14 22:48:30 +00:00
array < bitmap_index , MAX_GAUGE_BMS > Gauges , // Array of all gauge bitmaps.
Gauges_hires ; // hires gauges
static array < int , 2 > weapon_box_user { { WBU_WEAPON , WBU_WEAPON } } ; //see WBU_ constants in gauges.h
2013-03-03 01:03:33 +00:00
# endif
2015-04-26 20:15:52 +00:00
static grs_bitmap deccpt ;
2014-07-22 02:50:01 +00:00
static array < grs_subbitmap_ptr , 2 > WinBoxOverlay ; // Overlay subbitmaps for both weapon boxes
2008-02-24 14:41:27 +00:00
2015-04-26 20:15:56 +00:00
static inline void PAGE_IN_GAUGE ( int x , const local_multires_gauge_graphic multires_gauge_graphic )
2008-02-24 14:41:27 +00:00
{
2015-04-26 20:15:52 +00:00
const auto & g =
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2015-04-26 20:15:53 +00:00
multires_gauge_graphic . is_hires ( ) ? Gauges_hires :
2008-02-24 14:41:27 +00:00
# endif
2015-04-26 20:15:52 +00:00
Gauges ;
PIGGY_PAGE_IN ( g [ x ] ) ;
2013-03-03 01:03:33 +00:00
}
2008-02-24 14:41:27 +00:00
2014-10-17 01:57:30 +00:00
static void draw_ammo_info ( int x , int y , int ammo_count ) ;
2008-02-24 14:41:27 +00:00
static int score_display ;
static fix score_time ;
2015-04-02 02:36:52 +00:00
static array < int , 2 > old_weapon { { - 1 , - 1 } } ;
2008-02-24 14:41:27 +00:00
static int old_laser_level = - 1 ;
2015-04-26 20:15:52 +00:00
static int invulnerable_frame ;
2015-04-02 02:36:52 +00:00
static array < int , 2 > weapon_box_states ;
static_assert ( WS_SET = = 0 , " weapon_box_states must start at zero " ) ;
static array < fix , 2 > weapon_box_fade_values ;
2008-02-24 14:41:27 +00:00
int Color_0_31_0 = - 1 ;
2006-03-20 17:12:09 +00:00
2015-10-30 02:52:54 +00:00
namespace {
2013-12-22 22:03:07 +00:00
struct gauge_box
{
2006-03-20 17:12:09 +00:00
int left , top ;
int right , bot ; //maximal box
2013-12-22 22:03:07 +00:00
} ;
2006-03-20 17:12:09 +00:00
2012-06-24 21:30:39 +00:00
const gauge_box gauge_boxes [ ] = {
2006-03-20 17:12:09 +00:00
// primary left/right low res
2007-06-10 16:21:53 +00:00
{ PRIMARY_W_BOX_LEFT_L , PRIMARY_W_BOX_TOP_L , PRIMARY_W_BOX_RIGHT_L , PRIMARY_W_BOX_BOT_L } ,
{ SECONDARY_W_BOX_LEFT_L , SECONDARY_W_BOX_TOP_L , SECONDARY_W_BOX_RIGHT_L , SECONDARY_W_BOX_BOT_L } ,
2006-03-20 17:12:09 +00:00
//sb left/right low res
2007-06-10 16:21:53 +00:00
{ SB_PRIMARY_W_BOX_LEFT_L , SB_PRIMARY_W_BOX_TOP_L , SB_PRIMARY_W_BOX_RIGHT_L , SB_PRIMARY_W_BOX_BOT_L } ,
{ SB_SECONDARY_W_BOX_LEFT_L , SB_SECONDARY_W_BOX_TOP_L , SB_SECONDARY_W_BOX_RIGHT_L , SB_SECONDARY_W_BOX_BOT_L } ,
2006-03-20 17:12:09 +00:00
// primary left/right hires
2007-06-10 16:21:53 +00:00
{ PRIMARY_W_BOX_LEFT_H , PRIMARY_W_BOX_TOP_H , PRIMARY_W_BOX_RIGHT_H , PRIMARY_W_BOX_BOT_H } ,
{ SECONDARY_W_BOX_LEFT_H , SECONDARY_W_BOX_TOP_H , SECONDARY_W_BOX_RIGHT_H , SECONDARY_W_BOX_BOT_H } ,
2006-03-20 17:12:09 +00:00
// sb left/right hires
2007-06-10 16:21:53 +00:00
{ SB_PRIMARY_W_BOX_LEFT_H , SB_PRIMARY_W_BOX_TOP_H , SB_PRIMARY_W_BOX_RIGHT_H , SB_PRIMARY_W_BOX_BOT_H } ,
{ SB_SECONDARY_W_BOX_LEFT_H , SB_SECONDARY_W_BOX_TOP_H , SB_SECONDARY_W_BOX_RIGHT_H , SB_SECONDARY_W_BOX_BOT_H } ,
2006-03-20 17:12:09 +00:00
} ;
2014-11-01 15:17:06 +00:00
struct span
{
unsigned l , r ;
} ;
2015-09-13 21:02:19 +00:00
struct dspan
{
span l , r ;
2008-02-24 14:41:27 +00:00
} ;
2007-10-05 23:47:16 +00:00
//store delta x values from left of box
2015-09-13 21:02:19 +00:00
const array < dspan , 43 > weapon_windows_lowres = { {
{ { 71 , 114 } , { 208 , 255 } } ,
{ { 69 , 116 } , { 206 , 257 } } ,
{ { 68 , 117 } , { 205 , 258 } } ,
{ { 66 , 118 } , { 204 , 259 } } ,
{ { 66 , 119 } , { 203 , 260 } } ,
{ { 66 , 119 } , { 203 , 260 } } ,
{ { 65 , 119 } , { 203 , 260 } } ,
{ { 65 , 119 } , { 203 , 260 } } ,
{ { 65 , 119 } , { 203 , 260 } } ,
{ { 65 , 119 } , { 203 , 261 } } ,
{ { 65 , 119 } , { 203 , 261 } } ,
{ { 65 , 119 } , { 203 , 261 } } ,
{ { 65 , 119 } , { 203 , 261 } } ,
{ { 65 , 119 } , { 203 , 261 } } ,
{ { 65 , 119 } , { 203 , 261 } } ,
{ { 64 , 119 } , { 203 , 261 } } ,
{ { 64 , 119 } , { 203 , 261 } } ,
{ { 64 , 119 } , { 203 , 261 } } ,
{ { 64 , 119 } , { 203 , 262 } } ,
{ { 64 , 119 } , { 203 , 262 } } ,
{ { 64 , 119 } , { 203 , 262 } } ,
{ { 64 , 119 } , { 203 , 262 } } ,
{ { 64 , 119 } , { 203 , 262 } } ,
{ { 64 , 119 } , { 203 , 262 } } ,
{ { 63 , 119 } , { 203 , 262 } } ,
{ { 63 , 118 } , { 203 , 262 } } ,
{ { 63 , 118 } , { 204 , 263 } } ,
{ { 63 , 118 } , { 204 , 263 } } ,
{ { 63 , 118 } , { 204 , 263 } } ,
{ { 63 , 118 } , { 204 , 263 } } ,
{ { 63 , 118 } , { 204 , 263 } } ,
{ { 63 , 118 } , { 204 , 263 } } ,
{ { 63 , 118 } , { 204 , 263 } } ,
{ { 63 , 118 } , { 204 , 263 } } ,
{ { 63 , 118 } , { 204 , 263 } } ,
{ { 63 , 118 } , { 204 , 263 } } ,
{ { 63 , 118 } , { 204 , 263 } } ,
{ { 63 , 117 } , { 204 , 263 } } ,
{ { 63 , 117 } , { 205 , 263 } } ,
{ { 64 , 116 } , { 206 , 262 } } ,
{ { 65 , 115 } , { 207 , 261 } } ,
{ { 66 , 113 } , { 208 , 260 } } ,
{ { 68 , 111 } , { 211 , 255 } } ,
} } ;
2007-10-05 23:47:16 +00:00
//store delta x values from left of box
2015-09-13 21:02:19 +00:00
const array < dspan , 107 > weapon_windows_hires = { {
{ { 141 , 231 } , { 416 , 509 } } ,
{ { 139 , 234 } , { 413 , 511 } } ,
{ { 137 , 235 } , { 412 , 513 } } ,
{ { 136 , 237 } , { 410 , 514 } } ,
{ { 135 , 238 } , { 409 , 515 } } ,
{ { 134 , 239 } , { 408 , 516 } } ,
{ { 133 , 240 } , { 407 , 517 } } ,
{ { 132 , 240 } , { 407 , 518 } } ,
{ { 131 , 241 } , { 406 , 519 } } ,
{ { 131 , 241 } , { 406 , 519 } } ,
{ { 130 , 242 } , { 405 , 520 } } ,
{ { 129 , 242 } , { 405 , 521 } } ,
{ { 129 , 242 } , { 405 , 521 } } ,
{ { 129 , 243 } , { 404 , 521 } } ,
{ { 128 , 243 } , { 404 , 522 } } ,
{ { 128 , 243 } , { 404 , 522 } } ,
{ { 128 , 243 } , { 404 , 522 } } ,
{ { 128 , 243 } , { 404 , 522 } } ,
{ { 128 , 243 } , { 404 , 522 } } ,
{ { 127 , 243 } , { 404 , 523 } } ,
{ { 127 , 243 } , { 404 , 523 } } ,
{ { 127 , 243 } , { 404 , 523 } } ,
{ { 127 , 243 } , { 404 , 523 } } ,
{ { 127 , 243 } , { 404 , 523 } } ,
{ { 127 , 243 } , { 404 , 523 } } ,
{ { 127 , 243 } , { 404 , 523 } } ,
{ { 127 , 243 } , { 404 , 523 } } ,
{ { 127 , 243 } , { 404 , 523 } } ,
{ { 127 , 243 } , { 404 , 523 } } ,
{ { 126 , 243 } , { 404 , 524 } } ,
{ { 126 , 243 } , { 404 , 524 } } ,
{ { 126 , 243 } , { 404 , 524 } } ,
{ { 126 , 243 } , { 404 , 524 } } ,
{ { 126 , 242 } , { 405 , 524 } } ,
{ { 126 , 242 } , { 405 , 524 } } ,
{ { 126 , 242 } , { 405 , 524 } } ,
{ { 126 , 242 } , { 405 , 524 } } ,
{ { 126 , 242 } , { 405 , 524 } } ,
{ { 126 , 242 } , { 405 , 524 } } ,
{ { 125 , 242 } , { 405 , 525 } } ,
{ { 125 , 242 } , { 405 , 525 } } ,
{ { 125 , 242 } , { 405 , 525 } } ,
{ { 125 , 242 } , { 405 , 525 } } ,
{ { 125 , 242 } , { 405 , 525 } } ,
{ { 125 , 242 } , { 405 , 525 } } ,
{ { 125 , 242 } , { 405 , 525 } } ,
{ { 125 , 242 } , { 405 , 525 } } ,
{ { 125 , 242 } , { 405 , 525 } } ,
{ { 125 , 242 } , { 405 , 525 } } ,
{ { 124 , 242 } , { 405 , 526 } } ,
{ { 124 , 242 } , { 405 , 526 } } ,
{ { 124 , 241 } , { 406 , 526 } } ,
{ { 124 , 241 } , { 406 , 526 } } ,
{ { 124 , 241 } , { 406 , 526 } } ,
{ { 124 , 241 } , { 406 , 526 } } ,
{ { 124 , 241 } , { 406 , 526 } } ,
{ { 124 , 241 } , { 406 , 526 } } ,
{ { 124 , 241 } , { 406 , 526 } } ,
{ { 124 , 241 } , { 406 , 526 } } ,
{ { 124 , 241 } , { 406 , 527 } } ,
{ { 123 , 241 } , { 406 , 527 } } ,
{ { 123 , 241 } , { 406 , 527 } } ,
{ { 123 , 241 } , { 406 , 527 } } ,
{ { 123 , 241 } , { 406 , 527 } } ,
{ { 123 , 241 } , { 406 , 527 } } ,
{ { 123 , 241 } , { 406 , 527 } } ,
{ { 123 , 241 } , { 406 , 527 } } ,
{ { 123 , 241 } , { 406 , 527 } } ,
{ { 123 , 241 } , { 406 , 527 } } ,
{ { 123 , 241 } , { 406 , 527 } } ,
{ { 123 , 241 } , { 406 , 527 } } ,
{ { 123 , 241 } , { 406 , 527 } } ,
{ { 122 , 241 } , { 406 , 528 } } ,
{ { 122 , 241 } , { 406 , 528 } } ,
{ { 122 , 240 } , { 407 , 528 } } ,
{ { 122 , 240 } , { 407 , 528 } } ,
{ { 122 , 240 } , { 407 , 528 } } ,
{ { 122 , 240 } , { 407 , 528 } } ,
{ { 122 , 240 } , { 407 , 528 } } ,
{ { 122 , 240 } , { 407 , 528 } } ,
{ { 122 , 240 } , { 407 , 528 } } ,
{ { 122 , 240 } , { 407 , 529 } } ,
{ { 121 , 240 } , { 407 , 529 } } ,
{ { 121 , 240 } , { 407 , 529 } } ,
{ { 121 , 240 } , { 407 , 529 } } ,
{ { 121 , 240 } , { 407 , 529 } } ,
{ { 121 , 240 } , { 407 , 529 } } ,
{ { 121 , 240 } , { 407 , 529 } } ,
{ { 121 , 240 } , { 407 , 529 } } ,
{ { 121 , 239 } , { 408 , 529 } } ,
{ { 121 , 239 } , { 408 , 529 } } ,
{ { 121 , 239 } , { 408 , 529 } } ,
{ { 121 , 238 } , { 409 , 529 } } ,
{ { 121 , 238 } , { 409 , 529 } } ,
{ { 121 , 238 } , { 409 , 529 } } ,
{ { 122 , 237 } , { 410 , 529 } } ,
{ { 122 , 237 } , { 410 , 528 } } ,
{ { 123 , 236 } , { 411 , 527 } } ,
{ { 123 , 235 } , { 412 , 527 } } ,
{ { 124 , 234 } , { 413 , 526 } } ,
{ { 125 , 233 } , { 414 , 525 } } ,
{ { 126 , 232 } , { 415 , 524 } } ,
{ { 126 , 231 } , { 416 , 524 } } ,
{ { 128 , 230 } , { 417 , 522 } } ,
{ { 130 , 228 } , { 419 , 521 } } ,
{ { 131 , 226 } , { 422 , 519 } } ,
{ { 133 , 223 } , { 424 , 518 } } ,
} } ;
2007-10-05 23:47:16 +00:00
2015-04-26 20:15:56 +00:00
static inline void hud_bitblt_free ( unsigned x , unsigned y , unsigned w , unsigned h , grs_bitmap & bm )
2008-11-09 14:31:30 +00:00
{
# ifdef OGL
2015-04-26 20:15:56 +00:00
ogl_ubitmapm_cs ( x , y , w , h , bm , - 1 , F1_0 ) ;
2008-11-09 14:31:30 +00:00
# else
2015-04-26 20:15:56 +00:00
gr_ubitmapm ( x , y , bm ) ;
2008-11-09 14:31:30 +00:00
# endif
}
2015-04-26 20:15:56 +00:00
static inline void hud_bitblt ( unsigned x , unsigned y , grs_bitmap & bm , const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
2015-04-26 20:15:56 +00:00
hud_bitblt_free ( x , y , HUD_SCALE_X ( bm . bm_w ) , HUD_SCALE_Y ( bm . bm_h ) , bm ) ;
2006-03-20 17:12:09 +00:00
}
2015-04-26 20:15:53 +00:00
static void hud_gauge_bitblt ( unsigned x , unsigned y , unsigned gauge , const local_multires_gauge_graphic multires_gauge_graphic )
2015-04-26 20:15:52 +00:00
{
2015-04-26 20:15:56 +00:00
PAGE_IN_GAUGE ( gauge , multires_gauge_graphic ) ;
2015-04-26 20:15:56 +00:00
hud_bitblt ( HUD_SCALE_X ( x ) , HUD_SCALE_Y ( y ) , GameBitmaps [ GET_GAUGE_INDEX ( gauge ) ] , multires_gauge_graphic ) ;
2015-04-26 20:15:52 +00:00
}
2015-10-30 02:52:54 +00:00
class draw_keys_state
{
2015-10-30 02:52:55 +00:00
const player_flags player_key_flags ;
2015-10-30 02:52:54 +00:00
protected :
draw_keys_state ( ) :
player_key_flags ( get_local_player ( ) . flags )
{
gr_set_current_canvas ( nullptr ) ;
}
2015-10-30 02:52:55 +00:00
void draw_one_key ( unsigned x , unsigned y , unsigned gauge , const local_multires_gauge_graphic multires_gauge_graphic , const PLAYER_FLAG flag ) const
2015-10-30 02:52:54 +00:00
{
hud_gauge_bitblt ( x , y , ( player_key_flags & flag ) ? gauge : ( gauge + 3 ) , multires_gauge_graphic ) ;
}
} ;
class draw_cockpit_keys_state : public draw_keys_state
{
public :
void draw_all_keys ( local_multires_gauge_graphic multires_gauge_graphic ) ;
} ;
class draw_statusbar_keys_state : public draw_keys_state
{
public :
void draw_all_keys ( local_multires_gauge_graphic multires_gauge_graphic ) ;
} ;
}
2013-10-27 22:00:14 +00:00
static void hud_show_score ( )
2006-03-20 17:12:09 +00:00
{
char score_str [ 20 ] ;
2010-07-13 06:35:25 +00:00
if ( HUD_toolong )
2006-03-20 17:12:09 +00:00
return ;
gr_set_curfont ( GAME_FONT ) ;
if ( ( ( Game_mode & GM_MULTI ) & & ! ( Game_mode & GM_MULTI_COOP ) ) ) {
2015-07-25 23:10:46 +00:00
sprintf ( score_str , " %s: %5d " , TXT_KILLS , get_local_player ( ) . net_kills_total ) ;
2006-03-20 17:12:09 +00:00
} else {
2015-07-25 23:10:46 +00:00
sprintf ( score_str , " %s: %5d " , TXT_SCORE , get_local_player ( ) . score ) ;
2006-03-20 17:12:09 +00:00
}
if ( Color_0_31_0 = = - 1 )
2008-02-24 14:41:27 +00:00
Color_0_31_0 = BM_XRGB ( 0 , 31 , 0 ) ;
2006-03-20 17:12:09 +00:00
gr_set_fontcolor ( Color_0_31_0 , - 1 ) ;
2015-09-29 02:41:22 +00:00
int w , h ;
gr_get_string_size ( score_str , & w , & h , nullptr ) ;
2015-09-29 02:41:22 +00:00
gr_string ( grd_curcanv - > cv_bitmap . bm_w - w - FSPACX ( 1 ) , FSPACY ( 1 ) , score_str , w , h ) ;
2008-02-24 14:41:27 +00:00
}
2006-03-20 17:12:09 +00:00
2013-10-27 22:00:14 +00:00
static void hud_show_timer_count ( )
2008-02-24 14:41:27 +00:00
{
2006-03-20 17:12:09 +00:00
char score_str [ 20 ] ;
2015-09-29 02:41:22 +00:00
int i ;
2006-03-20 17:12:09 +00:00
fix timevar = 0 ;
2010-07-13 06:35:25 +00:00
if ( HUD_toolong )
2006-03-20 17:12:09 +00:00
return ;
2008-02-24 14:41:27 +00:00
if ( ( Game_mode & GM_NETWORK ) & & Netgame . PlayTimeAllowed )
{
timevar = i2f ( Netgame . PlayTimeAllowed * 5 * 60 ) ;
i = f2i ( timevar - ThisLevelTime ) ;
i + + ;
2010-06-18 07:31:06 +00:00
2015-09-29 02:41:22 +00:00
if ( i > - 1 & & ! Control_center_destroyed )
{
2008-02-24 14:41:27 +00:00
sprintf ( score_str , " T - %5d " , i ) ;
2010-06-18 07:31:06 +00:00
2008-02-24 14:41:27 +00:00
if ( Color_0_31_0 = = - 1 )
Color_0_31_0 = BM_XRGB ( 0 , 31 , 0 ) ;
2006-03-20 17:12:09 +00:00
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( Color_0_31_0 , - 1 ) ;
2010-06-18 07:31:06 +00:00
2015-09-29 02:41:22 +00:00
int w , h ;
gr_get_string_size ( score_str , & w , & h , nullptr ) ;
2015-09-29 02:41:22 +00:00
gr_string ( grd_curcanv - > cv_bitmap . bm_w - w - FSPACX ( 12 ) , LINE_SPACING + FSPACY ( 1 ) , score_str , w , h ) ;
2015-09-29 02:41:22 +00:00
}
2008-02-24 14:41:27 +00:00
}
}
2006-03-20 17:12:09 +00:00
2013-10-27 22:00:14 +00:00
static void hud_show_score_added ( )
2006-03-20 17:12:09 +00:00
{
int color ;
char score_str [ 20 ] ;
2010-06-18 07:31:06 +00:00
if ( ( Game_mode & GM_MULTI ) & & ! ( Game_mode & GM_MULTI_COOP ) )
2006-03-20 17:12:09 +00:00
return ;
2007-03-21 12:35:35 +00:00
if ( score_display = = 0 )
2006-03-20 17:12:09 +00:00
return ;
gr_set_curfont ( GAME_FONT ) ;
score_time - = FrameTime ;
if ( score_time > 0 ) {
color = f2i ( score_time * 20 ) + 12 ;
if ( color < 10 ) color = 12 ;
if ( color > 31 ) color = 30 ;
2008-02-24 14:41:27 +00:00
color = color - ( color % 4 ) ;
2006-03-20 17:12:09 +00:00
2011-02-14 21:27:07 +00:00
if ( cheats . enabled )
2006-03-20 17:12:09 +00:00
sprintf ( score_str , " %s " , TXT_CHEATER ) ;
else
2007-03-21 12:35:35 +00:00
sprintf ( score_str , " %5d " , score_display ) ;
2006-03-20 17:12:09 +00:00
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 0 , color , 0 ) , - 1 ) ;
2015-09-29 02:41:22 +00:00
int w , h ;
gr_get_string_size ( score_str , & w , & h , nullptr ) ;
2015-09-29 02:41:22 +00:00
gr_string ( grd_curcanv - > cv_bitmap . bm_w - w - FSPACX ( 12 ) , LINE_SPACING + FSPACY ( 1 ) , score_str , w , h ) ;
2006-03-20 17:12:09 +00:00
} else {
score_time = 0 ;
2007-03-21 12:35:35 +00:00
score_display = 0 ;
2006-03-20 17:12:09 +00:00
}
}
2015-04-26 20:15:53 +00:00
static void sb_show_score ( const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
char score_str [ 20 ] ;
int x , y ;
2008-02-24 14:41:27 +00:00
gr_set_curfont ( GAME_FONT ) ;
gr_set_fontcolor ( BM_XRGB ( 0 , 20 , 0 ) , - 1 ) ;
2006-03-20 17:12:09 +00:00
2015-06-13 22:42:19 +00:00
gr_printf ( HUD_SCALE_X ( SB_SCORE_LABEL_X ) , HUD_SCALE_Y ( SB_SCORE_Y ) , " %s: " , ( Game_mode & GM_MULTI ) & & ! ( Game_mode & GM_MULTI_COOP ) ? TXT_KILLS : TXT_SCORE ) ;
2006-03-20 17:12:09 +00:00
gr_set_curfont ( GAME_FONT ) ;
2015-09-29 02:41:22 +00:00
auto & player = get_local_player ( ) ;
snprintf ( score_str , sizeof ( score_str ) , " %5d " ,
( Game_mode & GM_MULTI ) & & ! ( Game_mode & GM_MULTI_COOP )
? player . net_kills_total
: ( gr_set_fontcolor ( BM_XRGB ( 0 , 31 , 0 ) , - 1 ) , player . score ) ) ;
2015-09-29 02:41:22 +00:00
int w , h ;
gr_get_string_size ( score_str , & w , & h , nullptr ) ;
2006-03-20 17:12:09 +00:00
2008-02-24 14:41:27 +00:00
x = HUD_SCALE_X ( SB_SCORE_RIGHT ) - w - FSPACX ( 1 ) ;
2007-06-10 16:21:53 +00:00
y = HUD_SCALE_Y ( SB_SCORE_Y ) ;
2010-06-18 07:31:06 +00:00
2006-03-20 17:12:09 +00:00
//erase old score
gr_setcolor ( BM_XRGB ( 0 , 0 , 0 ) ) ;
2008-02-24 14:41:27 +00:00
gr_rect ( x , y , HUD_SCALE_X ( SB_SCORE_RIGHT ) , y + LINE_SPACING ) ;
2006-03-20 17:12:09 +00:00
2015-09-29 02:41:22 +00:00
gr_string ( x , y , score_str , w , h ) ;
2006-03-20 17:12:09 +00:00
}
2015-04-26 20:15:53 +00:00
static void sb_show_score_added ( const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
int color ;
char score_str [ 32 ] ;
2008-02-24 14:41:27 +00:00
static int x ;
2007-03-21 12:35:35 +00:00
static int last_score_display = - 1 ;
2008-02-24 14:41:27 +00:00
if ( ( Game_mode & GM_MULTI ) & & ! ( Game_mode & GM_MULTI_COOP ) )
2006-03-20 17:12:09 +00:00
return ;
2007-03-21 12:35:35 +00:00
if ( score_display = = 0 )
2006-03-20 17:12:09 +00:00
return ;
gr_set_curfont ( GAME_FONT ) ;
score_time - = FrameTime ;
if ( score_time > 0 ) {
2007-03-21 12:35:35 +00:00
if ( score_display ! = last_score_display )
last_score_display = score_display ;
2006-03-20 17:12:09 +00:00
color = f2i ( score_time * 20 ) + 10 ;
if ( color < 10 ) color = 10 ;
if ( color > 31 ) color = 31 ;
2011-02-14 21:27:07 +00:00
if ( cheats . enabled )
2006-03-20 17:12:09 +00:00
sprintf ( score_str , " %s " , TXT_CHEATER ) ;
else
2007-03-21 12:35:35 +00:00
sprintf ( score_str , " %5d " , score_display ) ;
2006-03-20 17:12:09 +00:00
2015-09-29 02:41:22 +00:00
int w , h ;
gr_get_string_size ( score_str , & w , & h , nullptr ) ;
2008-02-24 14:41:27 +00:00
x = HUD_SCALE_X ( SB_SCORE_ADDED_RIGHT ) - w - FSPACX ( 1 ) ;
gr_set_fontcolor ( BM_XRGB ( 0 , color , 0 ) , - 1 ) ;
2015-09-29 02:41:22 +00:00
gr_string ( x , HUD_SCALE_Y ( SB_SCORE_ADDED_Y ) , score_str , w , h ) ;
2006-03-20 17:12:09 +00:00
} else {
//erase old score
gr_setcolor ( BM_XRGB ( 0 , 0 , 0 ) ) ;
2008-02-24 14:41:27 +00:00
gr_rect ( x , HUD_SCALE_Y ( SB_SCORE_ADDED_Y ) , HUD_SCALE_X ( SB_SCORE_ADDED_RIGHT ) , HUD_SCALE_Y ( SB_SCORE_ADDED_Y ) + LINE_SPACING ) ;
2006-03-20 17:12:09 +00:00
score_time = 0 ;
2007-03-21 12:35:35 +00:00
score_display = 0 ;
2006-03-20 17:12:09 +00:00
}
}
// -----------------------------------------------------------------------------
void play_homing_warning ( void )
{
2010-12-22 00:17:59 +00:00
fix beep_delay ;
static fix64 Last_warning_beep_time = 0 ; // Time we last played homing missile warning beep.
2006-03-20 17:12:09 +00:00
if ( Endlevel_sequence | | Player_is_dead )
return ;
2015-07-25 23:10:46 +00:00
if ( get_local_player ( ) . homing_object_dist > = 0 ) {
beep_delay = get_local_player ( ) . homing_object_dist / 128 ;
2006-03-20 17:12:09 +00:00
if ( beep_delay > F1_0 )
beep_delay = F1_0 ;
else if ( beep_delay < F1_0 / 8 )
beep_delay = F1_0 / 8 ;
2010-12-22 00:17:59 +00:00
if ( GameTime64 - Last_warning_beep_time > beep_delay / 2 | | Last_warning_beep_time > GameTime64 ) {
2006-03-20 17:12:09 +00:00
digi_play_sample ( SOUND_HOMING_WARNING , F1_0 ) ;
2010-12-22 00:17:59 +00:00
Last_warning_beep_time = GameTime64 ;
2006-03-20 17:12:09 +00:00
}
}
}
// -----------------------------------------------------------------------------
2015-04-26 20:15:53 +00:00
static void show_homing_warning ( const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
2010-02-19 00:24:32 +00:00
if ( Endlevel_sequence )
{
2015-04-26 20:15:53 +00:00
hud_gauge_bitblt ( HOMING_WARNING_X , HOMING_WARNING_Y , GAUGE_HOMING_WARNING_OFF , multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
return ;
}
2007-03-21 11:32:33 +00:00
gr_set_current_canvas ( NULL ) ;
2006-03-20 17:12:09 +00:00
2015-07-25 23:10:46 +00:00
if ( get_local_player ( ) . homing_object_dist > = 0 )
2010-02-19 00:24:32 +00:00
{
2010-12-22 00:17:59 +00:00
if ( GameTime64 & 0x4000 )
2010-02-19 00:24:32 +00:00
{
2015-04-26 20:15:53 +00:00
hud_gauge_bitblt ( HOMING_WARNING_X , HOMING_WARNING_Y , GAUGE_HOMING_WARNING_ON , multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
}
2010-02-19 00:24:32 +00:00
else
{
2015-04-26 20:15:53 +00:00
hud_gauge_bitblt ( HOMING_WARNING_X , HOMING_WARNING_Y , GAUGE_HOMING_WARNING_OFF , multires_gauge_graphic ) ;
2010-02-19 00:24:32 +00:00
}
}
else
{
2015-04-26 20:15:53 +00:00
hud_gauge_bitblt ( HOMING_WARNING_X , HOMING_WARNING_Y , GAUGE_HOMING_WARNING_OFF , multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
}
}
2013-10-27 22:00:14 +00:00
static void hud_show_homing_warning ( void )
2006-03-20 17:12:09 +00:00
{
2015-07-25 23:10:46 +00:00
if ( get_local_player ( ) . homing_object_dist > = 0 ) {
2010-12-22 00:17:59 +00:00
if ( GameTime64 & 0x4000 ) {
2006-03-20 17:12:09 +00:00
gr_set_curfont ( GAME_FONT ) ;
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 0 , 31 , 0 ) , - 1 ) ;
2013-01-03 16:23:24 +00:00
gr_string ( 0x8000 , grd_curcanv - > cv_bitmap . bm_h - LINE_SPACING , TXT_LOCK ) ;
2006-03-20 17:12:09 +00:00
}
}
}
2015-04-26 20:15:53 +00:00
static void hud_show_keys ( const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
2015-10-30 02:52:55 +00:00
const auto player_key_flags = get_local_player ( ) . flags ;
if ( ! ( player_key_flags & ( PLAYER_FLAGS_BLUE_KEY | PLAYER_FLAGS_GOLD_KEY | PLAYER_FLAGS_RED_KEY ) ) )
2015-04-26 20:15:52 +00:00
return ;
class gauge_key
{
grs_bitmap * const bm ;
public :
2015-04-26 20:15:53 +00:00
gauge_key ( const unsigned key_icon , const local_multires_gauge_graphic multires_gauge_graphic ) :
2015-04-26 20:15:56 +00:00
bm ( & GameBitmaps [ static_cast < void > ( multires_gauge_graphic ) , PAGE_IN_GAUGE ( key_icon , multires_gauge_graphic ) , GET_GAUGE_INDEX ( key_icon ) ] )
2015-04-26 20:15:52 +00:00
{
}
grs_bitmap * operator - > ( ) const
{
return bm ;
}
2015-04-26 20:15:56 +00:00
operator grs_bitmap & ( ) const
2015-04-26 20:15:52 +00:00
{
2015-04-26 20:15:56 +00:00
return * bm ;
2015-04-26 20:15:52 +00:00
}
} ;
2015-04-26 20:15:53 +00:00
const gauge_key blue ( KEY_ICON_BLUE , multires_gauge_graphic ) ;
2008-11-09 14:31:30 +00:00
int y = HUD_SCALE_Y_AR ( GameBitmaps [ GET_GAUGE_INDEX ( GAUGE_LIVES ) ] . bm_h + 2 ) + FSPACY ( 1 ) ;
2006-03-20 17:12:09 +00:00
2015-06-13 22:42:20 +00:00
const auto & & fspacx2 = FSPACX ( 2 ) ;
2015-04-26 20:15:52 +00:00
if ( player_key_flags & PLAYER_FLAGS_BLUE_KEY )
2015-06-13 22:42:20 +00:00
hud_bitblt_free ( fspacx2 , y , HUD_SCALE_X_AR ( blue - > bm_w ) , HUD_SCALE_Y_AR ( blue - > bm_h ) , blue ) ;
2006-03-20 17:12:09 +00:00
2015-04-26 20:15:52 +00:00
if ( ! ( player_key_flags & ( PLAYER_FLAGS_GOLD_KEY | PLAYER_FLAGS_RED_KEY ) ) )
return ;
2015-04-26 20:15:53 +00:00
const gauge_key yellow ( KEY_ICON_YELLOW , multires_gauge_graphic ) ;
2015-04-26 20:15:52 +00:00
if ( player_key_flags & PLAYER_FLAGS_GOLD_KEY )
2015-06-13 22:42:20 +00:00
hud_bitblt_free ( fspacx2 + HUD_SCALE_X_AR ( blue - > bm_w + 3 ) , y , HUD_SCALE_X_AR ( yellow - > bm_w ) , HUD_SCALE_Y_AR ( yellow - > bm_h ) , yellow ) ;
2008-02-24 14:41:27 +00:00
2015-04-26 20:15:52 +00:00
if ( player_key_flags & PLAYER_FLAGS_RED_KEY )
{
2015-04-26 20:15:53 +00:00
const gauge_key red ( KEY_ICON_RED , multires_gauge_graphic ) ;
2015-06-13 22:42:20 +00:00
hud_bitblt_free ( fspacx2 + HUD_SCALE_X_AR ( blue - > bm_w + yellow - > bm_w + 6 ) , y , HUD_SCALE_X_AR ( red - > bm_w ) , HUD_SCALE_Y_AR ( red - > bm_h ) , red ) ;
2015-04-26 20:15:52 +00:00
}
2006-03-20 17:12:09 +00:00
}
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2015-04-26 20:15:53 +00:00
static void hud_show_orbs ( const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
2013-08-11 16:03:47 +00:00
if ( game_mode_hoard ( ) ) {
2015-06-13 22:42:20 +00:00
const auto & & fspacy1 = FSPACY ( 1 ) ;
int x = 0 , y = LINE_SPACING + fspacy1 ;
2010-01-28 00:04:29 +00:00
if ( PlayerCfg . CockpitMode [ 1 ] = = CM_FULL_COCKPIT ) {
2011-01-22 12:30:20 +00:00
x = ( SWIDTH / 18 ) ;
2006-03-20 17:12:09 +00:00
}
2010-01-28 00:04:29 +00:00
else if ( PlayerCfg . CockpitMode [ 1 ] = = CM_STATUS_BAR ) {
2008-02-24 14:41:27 +00:00
x = FSPACX ( 2 ) ;
2006-03-20 17:12:09 +00:00
}
2010-01-28 00:04:29 +00:00
else if ( PlayerCfg . CockpitMode [ 1 ] = = CM_FULL_SCREEN ) {
2015-06-13 22:42:20 +00:00
y = HUD_SCALE_Y_AR ( GameBitmaps [ GET_GAUGE_INDEX ( GAUGE_LIVES ) ] . bm_h + GameBitmaps [ GET_GAUGE_INDEX ( KEY_ICON_RED ) ] . bm_h + 4 ) + fspacy1 ;
2008-02-24 14:41:27 +00:00
x = FSPACX ( 2 ) ;
2006-03-20 17:12:09 +00:00
}
else
Int3 ( ) ; //what sort of cockpit?
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 0 , 31 , 0 ) , - 1 ) ;
2015-04-26 20:15:56 +00:00
auto & bm = Orb_icons [ multires_gauge_graphic . is_hires ( ) ] ;
hud_bitblt_free ( x , y , HUD_SCALE_Y_AR ( bm . bm_w ) , HUD_SCALE_Y_AR ( bm . bm_h ) , bm ) ;
2015-07-25 23:10:46 +00:00
gr_printf ( x + HUD_SCALE_X_AR ( bm . bm_w ) , y , " x %d " , get_local_player ( ) . secondary_ammo [ PROXIMITY_INDEX ] ) ;
2006-03-20 17:12:09 +00:00
}
}
2015-04-26 20:15:53 +00:00
static void hud_show_flag ( const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
2015-07-25 23:10:46 +00:00
if ( game_mode_capture_flag ( ) & & ( get_local_player ( ) . flags & PLAYER_FLAGS_FLAG ) ) {
2008-03-20 23:23:46 +00:00
int x = 0 , y = 0 , icon ;
2015-06-13 22:42:20 +00:00
const auto & & fspacy1 = FSPACY ( 1 ) ;
2010-01-28 00:04:29 +00:00
if ( PlayerCfg . CockpitMode [ 1 ] = = CM_FULL_COCKPIT ) {
2015-06-13 22:42:20 +00:00
y = HUD_SCALE_Y_AR ( GameBitmaps [ GET_GAUGE_INDEX ( GAUGE_LIVES ) ] . bm_h + 2 ) + fspacy1 ;
2008-02-24 14:41:27 +00:00
x = ( SWIDTH / 10 ) ;
2006-03-20 17:12:09 +00:00
}
2010-01-28 00:04:29 +00:00
else if ( PlayerCfg . CockpitMode [ 1 ] = = CM_STATUS_BAR ) {
2015-06-13 22:42:20 +00:00
y = HUD_SCALE_Y_AR ( GameBitmaps [ GET_GAUGE_INDEX ( GAUGE_LIVES ) ] . bm_h + 2 ) + fspacy1 ;
2008-02-24 14:41:27 +00:00
x = FSPACX ( 2 ) ;
2006-03-20 17:12:09 +00:00
}
2010-01-28 00:04:29 +00:00
else if ( PlayerCfg . CockpitMode [ 1 ] = = CM_FULL_SCREEN ) {
2015-06-13 22:42:20 +00:00
y = HUD_SCALE_Y_AR ( GameBitmaps [ GET_GAUGE_INDEX ( GAUGE_LIVES ) ] . bm_h + GameBitmaps [ GET_GAUGE_INDEX ( KEY_ICON_RED ) ] . bm_h + 4 ) + fspacy1 ;
2008-02-24 14:41:27 +00:00
x = FSPACX ( 2 ) ;
2006-03-20 17:12:09 +00:00
}
else
Int3 ( ) ; //what sort of cockpit?
icon = ( get_team ( Player_num ) = = TEAM_BLUE ) ? FLAG_ICON_RED : FLAG_ICON_BLUE ;
2015-04-26 20:15:56 +00:00
auto & bm = GameBitmaps [ GET_GAUGE_INDEX ( icon ) ] ;
2015-04-26 20:15:56 +00:00
PAGE_IN_GAUGE ( icon , multires_gauge_graphic ) ;
2015-04-26 20:15:56 +00:00
hud_bitblt_free ( x , y , HUD_SCALE_X_AR ( bm . bm_w ) , HUD_SCALE_Y_AR ( bm . bm_h ) , bm ) ;
2006-03-20 17:12:09 +00:00
}
}
# endif
2013-10-27 22:00:14 +00:00
static void hud_show_energy ( void )
2006-03-20 17:12:09 +00:00
{
2008-04-13 00:28:36 +00:00
if ( PlayerCfg . HudMode < 2 ) {
2006-09-29 00:57:57 +00:00
gr_set_curfont ( GAME_FONT ) ;
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 0 , 31 , 0 ) , - 1 ) ;
2015-06-13 22:42:22 +00:00
const auto & & line_spacing = LINE_SPACING ;
2015-07-25 23:10:46 +00:00
gr_printf ( FSPACX ( 1 ) , grd_curcanv - > cv_bitmap . bm_h - ( ( Game_mode & GM_MULTI ) ? ( line_spacing * 5 ) : line_spacing ) , " %s: %i " , TXT_ENERGY , f2ir ( get_local_player ( ) . energy ) ) ;
2006-09-29 00:57:57 +00:00
}
2006-03-20 17:12:09 +00:00
2010-07-15 05:40:25 +00:00
if ( Newdemo_state = = ND_STATE_RECORDING )
2015-07-25 23:10:46 +00:00
newdemo_record_player_energy ( f2ir ( get_local_player ( ) . energy ) ) ;
2006-03-20 17:12:09 +00:00
}
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
static inline void hud_show_afterburner ( void )
{
}
# define convert_1s(s)
# elif defined(DXX_BUILD_DESCENT_II)
2013-10-27 22:00:14 +00:00
static void hud_show_afterburner ( void )
2006-03-20 17:12:09 +00:00
{
int y ;
2015-07-25 23:10:46 +00:00
if ( ! ( get_local_player ( ) . flags & PLAYER_FLAGS_AFTERBURNER ) )
2006-03-20 17:12:09 +00:00
return ; //don't draw if don't have
gr_set_curfont ( GAME_FONT ) ;
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 0 , 31 , 0 ) , - 1 ) ;
2006-03-20 17:12:09 +00:00
2015-06-13 22:42:22 +00:00
const auto & & line_spacing = LINE_SPACING ;
y = ( Game_mode & GM_MULTI ) ? ( - 7 * line_spacing ) : ( - 3 * line_spacing ) ;
2006-03-20 17:12:09 +00:00
2008-02-24 14:41:27 +00:00
gr_printf ( FSPACX ( 1 ) , grd_curcanv - > cv_bitmap . bm_h + y , " burn: %d%% " , fixmul ( Afterburner_charge , 100 ) ) ;
2006-03-20 17:12:09 +00:00
2010-07-15 05:40:25 +00:00
if ( Newdemo_state = = ND_STATE_RECORDING )
newdemo_record_player_afterburner ( Afterburner_charge ) ;
2006-03-20 17:12:09 +00:00
}
2013-03-03 01:03:33 +00:00
//convert '1' characters to special wide ones
# define convert_1s(s) do {char *p=s; while ((p=strchr(p,'1')) != NULL) *p=132;} while(0)
# endif
2012-07-01 01:03:14 +00:00
static inline const char * SECONDARY_WEAPON_NAMES_VERY_SHORT ( const unsigned u )
{
switch ( u )
{
default :
2013-03-03 01:03:33 +00:00
Int3 ( ) ;
2013-06-09 16:39:19 +00:00
case CONCUSSION_INDEX : return TXT_CONCUSSION ;
case HOMING_INDEX : return TXT_HOMING ;
case PROXIMITY_INDEX : return TXT_PROXBOMB ;
case SMART_INDEX : return TXT_SMART ;
case MEGA_INDEX : return TXT_MEGA ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2013-06-09 16:39:19 +00:00
case SMISSILE1_INDEX : return " Flash " ;
case GUIDED_INDEX : return " Guided " ;
case SMART_MINE_INDEX : return " SmrtMine " ;
case SMISSILE4_INDEX : return " Mercury " ;
case SMISSILE5_INDEX : return " Shaker " ;
2013-03-03 01:03:33 +00:00
# endif
2012-07-01 01:03:14 +00:00
}
}
2006-03-20 17:12:09 +00:00
2013-09-22 22:26:27 +00:00
static void show_bomb_count ( int x , int y , int bg_color , int always_show , int right_align )
2006-03-20 17:12:09 +00:00
{
2015-09-29 02:41:22 +00:00
int bomb , count ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
if ( ! PlayerCfg . BombGauge )
return ;
# endif
2006-03-20 17:12:09 +00:00
bomb = which_bomb ( ) ;
2015-07-25 23:10:46 +00:00
count = get_local_player ( ) . secondary_ammo [ bomb ] ;
2006-03-20 17:12:09 +00:00
count = min ( count , 99 ) ; //only have room for 2 digits - cheating give 200
if ( always_show & & count = = 0 ) //no bombs, draw nothing on HUD
return ;
2015-09-29 02:41:22 +00:00
gr_set_fontcolor ( count
? ( bomb = = PROXIMITY_INDEX
? gr_find_closest_color ( 55 , 0 , 0 )
: BM_XRGB ( 59 , 50 , 21 )
)
: bg_color , //erase by drawing in background color
bg_color ) ;
2006-03-20 17:12:09 +00:00
2015-10-10 03:44:14 +00:00
char txt [ 5 ] ;
2009-12-01 14:50:09 +00:00
snprintf ( txt , sizeof ( txt ) , " B:%02d " , count ) ;
2015-10-10 03:44:14 +00:00
//convert to wide '1'
std : : replace ( & txt [ 2 ] , & txt [ 4 ] , ' 1 ' , ' \x84 ' ) ;
2006-03-20 17:12:09 +00:00
2015-09-29 02:41:22 +00:00
int w , h ;
gr_get_string_size ( txt , & w , & h , nullptr ) ;
gr_string ( right_align ? x - w : x , y , txt , w , h ) ;
2006-03-20 17:12:09 +00:00
}
2015-04-26 20:15:53 +00:00
static void draw_primary_ammo_info ( int ammo_count , const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
2010-01-28 00:04:29 +00:00
if ( PlayerCfg . CockpitMode [ 1 ] = = CM_STATUS_BAR )
2014-10-17 01:57:30 +00:00
draw_ammo_info ( SB_PRIMARY_AMMO_X , SB_PRIMARY_AMMO_Y , ammo_count ) ;
2006-03-20 17:12:09 +00:00
else
2014-10-17 01:57:30 +00:00
draw_ammo_info ( PRIMARY_AMMO_X , PRIMARY_AMMO_Y , ammo_count ) ;
2006-03-20 17:12:09 +00:00
}
2015-04-19 04:18:52 +00:00
__attribute_warn_unused_result
static color_t hud_get_rgb_red ( )
2012-11-04 02:52:44 +00:00
{
2015-04-19 04:18:52 +00:00
return BM_XRGB ( 20 , 0 , 0 ) ;
2012-11-04 02:52:44 +00:00
}
2015-04-19 04:18:52 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2015-04-19 04:18:52 +00:00
__attribute_warn_unused_result
static color_t hud_get_rgb_yellow ( )
2012-11-04 02:52:44 +00:00
{
2015-04-19 04:18:52 +00:00
return BM_XRGB ( 15 , 15 , 0 ) ;
2012-11-04 02:52:44 +00:00
}
2015-04-19 04:18:52 +00:00
# endif
2012-11-04 02:52:44 +00:00
2015-04-19 04:18:52 +00:00
__attribute_warn_unused_result
static color_t hud_get_rgb_green ( )
2012-11-04 02:52:44 +00:00
{
2015-04-19 04:18:52 +00:00
return BM_XRGB ( 0 , 15 , 0 ) ;
2012-11-04 02:52:44 +00:00
}
2015-04-19 04:18:52 +00:00
__attribute_warn_unused_result
static color_t hud_get_rgb_dimgreen ( )
2012-11-04 02:52:44 +00:00
{
2015-04-19 04:18:52 +00:00
return BM_XRGB ( 0 , 6 , 0 ) ;
2012-11-04 02:52:44 +00:00
}
2015-04-19 04:18:52 +00:00
__attribute_warn_unused_result
static color_t hud_get_rgb_gray ( )
2012-11-04 02:52:44 +00:00
{
2015-04-19 04:18:52 +00:00
return BM_XRGB ( 3 , 3 , 3 ) ;
2012-11-04 02:52:44 +00:00
}
2015-04-19 04:18:52 +00:00
__attribute_warn_unused_result
static color_t hud_get_primary_weapon_fontcolor ( const int consider_weapon )
2012-11-04 02:52:44 +00:00
{
if ( Primary_weapon = = consider_weapon )
2015-04-19 04:18:52 +00:00
return hud_get_rgb_red ( ) ;
2012-11-04 02:52:44 +00:00
else {
2015-04-19 04:18:50 +00:00
if ( player_has_primary_weapon ( consider_weapon ) . has_weapon ( ) )
2012-11-04 02:52:44 +00:00
{
# if defined(DXX_BUILD_DESCENT_II)
2015-04-19 04:18:52 +00:00
const auto is_super = ( consider_weapon > = 5 ) ;
2012-11-04 02:52:44 +00:00
const int base_weapon = is_super ? consider_weapon - 5 : consider_weapon ;
if ( Primary_last_was_super [ base_weapon ] )
{
if ( is_super )
2015-04-19 04:18:52 +00:00
return hud_get_rgb_green ( ) ;
2012-11-04 02:52:44 +00:00
else
2015-04-19 04:18:52 +00:00
return hud_get_rgb_yellow ( ) ;
2012-11-04 02:52:44 +00:00
}
2015-04-19 04:18:52 +00:00
else if ( is_super )
2015-04-19 04:18:52 +00:00
return hud_get_rgb_yellow ( ) ;
2012-11-04 02:52:44 +00:00
else
# endif
2015-04-19 04:18:52 +00:00
return hud_get_rgb_green ( ) ;
2012-11-04 02:52:44 +00:00
}
else
2015-04-19 04:18:52 +00:00
return hud_get_rgb_gray ( ) ;
2012-11-04 02:52:44 +00:00
}
}
2015-04-19 04:18:52 +00:00
static void hud_set_primary_weapon_fontcolor ( const int consider_weapon )
{
gr_set_fontcolor ( hud_get_primary_weapon_fontcolor ( consider_weapon ) , - 1 ) ;
}
__attribute_warn_unused_result
static color_t hud_get_secondary_weapon_fontcolor ( const int consider_weapon )
2012-11-04 02:52:44 +00:00
{
if ( Secondary_weapon = = consider_weapon )
2015-04-19 04:18:52 +00:00
return hud_get_rgb_red ( ) ;
2012-11-04 02:52:44 +00:00
else {
2015-07-25 23:10:46 +00:00
if ( get_local_player ( ) . secondary_ammo [ consider_weapon ] > 0 )
2012-11-04 02:52:44 +00:00
{
# if defined(DXX_BUILD_DESCENT_II)
2015-04-19 04:18:52 +00:00
const auto is_super = ( consider_weapon > = 5 ) ;
2012-11-04 02:52:44 +00:00
const int base_weapon = is_super ? consider_weapon - 5 : consider_weapon ;
if ( Secondary_last_was_super [ base_weapon ] )
{
if ( is_super )
2015-04-19 04:18:52 +00:00
return hud_get_rgb_green ( ) ;
2012-11-04 02:52:44 +00:00
else
2015-04-19 04:18:52 +00:00
return hud_get_rgb_yellow ( ) ;
2012-11-04 02:52:44 +00:00
}
2015-04-19 04:18:52 +00:00
else if ( is_super )
2015-04-19 04:18:52 +00:00
return hud_get_rgb_yellow ( ) ;
2012-11-04 02:52:44 +00:00
else
# endif
2015-04-19 04:18:52 +00:00
return hud_get_rgb_green ( ) ;
2012-11-04 02:52:44 +00:00
}
else
2015-04-19 04:18:52 +00:00
return hud_get_rgb_dimgreen ( ) ;
2012-11-04 02:52:44 +00:00
}
}
2015-04-19 04:18:52 +00:00
static void hud_set_secondary_weapon_fontcolor ( const int consider_weapon )
{
gr_set_fontcolor ( hud_get_secondary_weapon_fontcolor ( consider_weapon ) , - 1 ) ;
}
__attribute_warn_unused_result
static color_t hud_get_vulcan_ammo_fontcolor ( const unsigned has_weapon_uses_vulcan_ammo )
{
if ( weapon_index_uses_vulcan_ammo ( Primary_weapon ) )
return hud_get_rgb_red ( ) ;
else if ( has_weapon_uses_vulcan_ammo )
return hud_get_rgb_green ( ) ;
else
return hud_get_rgb_gray ( ) ;
}
static void hud_set_vulcan_ammo_fontcolor ( const unsigned has_weapon_uses_vulcan_ammo )
{
gr_set_fontcolor ( hud_get_vulcan_ammo_fontcolor ( has_weapon_uses_vulcan_ammo ) , - 1 ) ;
}
2012-11-04 02:52:44 +00:00
static void hud_printf_vulcan_ammo ( const int x , const int y )
{
if ( PlayerCfg . CockpitMode [ 1 ] ! = CM_FULL_SCREEN )
return ;
2015-07-25 23:10:46 +00:00
const unsigned primary_weapon_flags = get_local_player ( ) . primary_weapon_flags ;
2015-04-19 04:18:50 +00:00
const auto vulcan_mask = HAS_VULCAN_FLAG ;
2012-11-04 02:52:44 +00:00
# if defined(DXX_BUILD_DESCENT_I)
2015-04-19 04:18:50 +00:00
const auto gauss_mask = vulcan_mask ;
2012-11-04 02:52:44 +00:00
# elif defined(DXX_BUILD_DESCENT_II)
2015-04-19 04:18:50 +00:00
const auto gauss_mask = HAS_GAUSS_FLAG ;
2012-11-04 02:52:44 +00:00
# endif
2015-07-25 23:10:46 +00:00
const int fmt_vulcan_ammo = f2i ( ( unsigned int ) get_local_player ( ) . vulcan_ammo * VULCAN_AMMO_SCALE ) ;
2012-11-04 02:52:44 +00:00
const unsigned has_weapon_uses_vulcan_ammo = ( primary_weapon_flags & ( gauss_mask | vulcan_mask ) ) ;
if ( ! has_weapon_uses_vulcan_ammo & & ! fmt_vulcan_ammo )
return ;
2015-04-19 04:18:52 +00:00
hud_set_vulcan_ammo_fontcolor ( has_weapon_uses_vulcan_ammo ) ;
2012-11-04 02:52:44 +00:00
char c ;
# if defined(DXX_BUILD_DESCENT_II)
2015-10-18 21:01:18 +00:00
if ( ( primary_weapon_flags & gauss_mask ) & & ( Primary_last_was_super [ primary_weapon_index_t : : VULCAN_INDEX ] | | ! ( primary_weapon_flags & vulcan_mask ) ) )
2012-11-04 02:52:44 +00:00
c = ' G ' ;
else
# endif
if ( primary_weapon_flags & vulcan_mask )
c = ' V ' ;
else
c = ' A ' ;
gr_printf ( x , y , " %c:%i " , c , fmt_vulcan_ammo ) ;
}
2015-05-09 17:38:57 +00:00
static void hud_show_primary_weapons_mode ( int vertical , int orig_x , int orig_y )
{
2015-09-29 02:41:22 +00:00
int x = orig_x , y = orig_y ;
2008-11-09 14:31:30 +00:00
2015-06-13 22:42:22 +00:00
const auto & & line_spacing = LINE_SPACING ;
2006-03-20 17:12:09 +00:00
if ( vertical ) {
2015-06-13 22:42:22 +00:00
y + = line_spacing * 4 ;
2006-03-20 17:12:09 +00:00
}
2008-11-09 14:31:30 +00:00
2015-06-13 22:42:20 +00:00
const auto & & fspacx = FSPACX ( ) ;
2015-06-13 22:42:20 +00:00
const auto & & fspacx3 = fspacx ( 3 ) ;
const auto & & fspacy2 = FSPACY ( 2 ) ;
2015-05-09 17:38:57 +00:00
{
2015-04-19 04:18:53 +00:00
for ( uint_fast32_t ui = 5 ; ui - - ; )
{
const auto i = static_cast < primary_weapon_index_t > ( ui ) ;
2012-11-04 02:52:44 +00:00
const char * txtweapon ;
char weapon_str [ 10 ] ;
hud_set_primary_weapon_fontcolor ( i ) ;
2015-04-19 04:18:53 +00:00
switch ( i )
{
case primary_weapon_index_t : : LASER_INDEX :
2015-07-25 23:10:46 +00:00
snprintf ( weapon_str , sizeof ( weapon_str ) , " %c%i " , ( get_local_player ( ) . flags & PLAYER_FLAGS_QUAD_LASERS ) ? ' Q ' : ' L ' , get_local_player ( ) . laser_level + 1 ) ;
2012-11-04 02:52:44 +00:00
txtweapon = weapon_str ;
2008-11-09 14:31:30 +00:00
break ;
2015-04-19 04:18:53 +00:00
case primary_weapon_index_t : : VULCAN_INDEX :
2012-11-04 02:52:44 +00:00
txtweapon = " V " ;
2008-11-09 14:31:30 +00:00
break ;
2015-04-19 04:18:53 +00:00
case primary_weapon_index_t : : SPREADFIRE_INDEX :
2012-11-04 02:52:44 +00:00
txtweapon = " S " ;
break ;
2015-04-19 04:18:53 +00:00
case primary_weapon_index_t : : PLASMA_INDEX :
2012-11-04 02:52:44 +00:00
txtweapon = " P " ;
break ;
2015-04-19 04:18:53 +00:00
case primary_weapon_index_t : : FUSION_INDEX :
2012-11-04 02:52:44 +00:00
txtweapon = " F " ;
break ;
2014-11-02 16:18:24 +00:00
default :
continue ;
2006-03-20 17:12:09 +00:00
}
2015-09-29 02:41:22 +00:00
int w , h ;
gr_get_string_size ( txtweapon , & w , & h , nullptr ) ;
2008-11-09 14:31:30 +00:00
if ( vertical ) {
2015-06-13 22:42:20 +00:00
y - = h + fspacy2 ;
2008-11-09 14:31:30 +00:00
} else
2015-06-13 22:42:20 +00:00
x - = w + fspacx3 ;
2015-09-29 02:41:22 +00:00
gr_string ( x , y , txtweapon , w , h ) ;
2015-04-19 04:18:53 +00:00
if ( i = = primary_weapon_index_t : : VULCAN_INDEX & & ! vertical )
2012-11-04 02:52:44 +00:00
{
2015-06-13 22:42:22 +00:00
hud_printf_vulcan_ammo ( x , y - line_spacing ) ;
2012-11-04 02:52:44 +00:00
}
2006-03-20 17:12:09 +00:00
}
2008-11-09 14:31:30 +00:00
}
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2008-11-09 14:31:30 +00:00
x = orig_x ;
y = orig_y ;
if ( vertical )
{
2015-06-13 22:42:20 +00:00
x + = fspacx ( 15 ) ;
2015-06-13 22:42:22 +00:00
y + = line_spacing * 4 ;
2008-11-09 14:31:30 +00:00
}
else
{
2015-06-13 22:42:22 +00:00
y + = line_spacing ;
2008-11-09 14:31:30 +00:00
}
2015-05-09 17:38:57 +00:00
{
2015-04-19 04:18:53 +00:00
for ( uint_fast32_t ui = 10 ; ui - - ! = 5 ; )
{
const auto i = static_cast < primary_weapon_index_t > ( ui ) ;
2012-11-04 02:52:44 +00:00
const char * txtweapon ;
char weapon_str [ 10 ] ;
hud_set_primary_weapon_fontcolor ( i ) ;
2015-04-19 04:18:53 +00:00
switch ( i )
{
case primary_weapon_index_t : : SUPER_LASER_INDEX :
2012-11-04 02:52:44 +00:00
txtweapon = " " ;
2008-11-09 14:31:30 +00:00
break ;
2015-04-19 04:18:53 +00:00
case primary_weapon_index_t : : GAUSS_INDEX :
2012-11-04 02:52:44 +00:00
txtweapon = " G " ;
2008-11-09 14:31:30 +00:00
break ;
2015-04-19 04:18:53 +00:00
case primary_weapon_index_t : : HELIX_INDEX :
2012-11-04 02:52:44 +00:00
txtweapon = " H " ;
break ;
2015-04-19 04:18:53 +00:00
case primary_weapon_index_t : : PHOENIX_INDEX :
2012-11-04 02:52:44 +00:00
txtweapon = " P " ;
break ;
2015-04-19 04:18:53 +00:00
case primary_weapon_index_t : : OMEGA_INDEX :
2010-01-28 00:04:29 +00:00
if ( PlayerCfg . CockpitMode [ 1 ] = = CM_FULL_SCREEN )
2012-11-04 02:52:44 +00:00
{
snprintf ( weapon_str , sizeof ( weapon_str ) , " O%03i " , Omega_charge * 100 / MAX_OMEGA_CHARGE ) ;
txtweapon = weapon_str ;
}
2007-03-04 14:23:19 +00:00
else
2012-11-04 02:52:44 +00:00
txtweapon = " O " ;
2008-11-09 14:31:30 +00:00
break ;
2014-11-02 16:18:24 +00:00
default :
continue ;
2008-11-09 14:31:30 +00:00
}
2015-09-29 02:41:22 +00:00
int w , h ;
gr_get_string_size ( txtweapon , & w , & h , nullptr ) ;
2008-11-09 14:31:30 +00:00
if ( vertical ) {
2015-06-13 22:42:20 +00:00
y - = h + fspacy2 ;
2008-11-09 14:31:30 +00:00
} else
2015-06-13 22:42:20 +00:00
x - = w + fspacx3 ;
2015-04-19 04:18:53 +00:00
if ( i = = primary_weapon_index_t : : SUPER_LASER_INDEX )
2012-11-04 02:52:44 +00:00
{
if ( vertical )
hud_printf_vulcan_ammo ( x , y ) ;
continue ;
}
2015-09-29 02:41:22 +00:00
gr_string ( x , y , txtweapon , w , h ) ;
2008-11-09 14:31:30 +00:00
}
2015-05-09 17:38:57 +00:00
}
# endif
gr_set_fontcolor ( BM_XRGB ( 0 , 31 , 0 ) , - 1 ) ;
}
static void hud_show_secondary_weapons_mode ( int vertical , int orig_x , int orig_y )
{
2015-09-29 02:41:22 +00:00
int x = orig_x , y = orig_y ;
2015-05-09 17:38:57 +00:00
2015-06-13 22:42:22 +00:00
const auto & & line_spacing = LINE_SPACING ;
2015-05-09 17:38:57 +00:00
if ( vertical ) {
2015-06-13 22:42:22 +00:00
y + = line_spacing * 4 ;
2015-05-09 17:38:57 +00:00
}
2015-06-13 22:42:20 +00:00
const auto & & fspacx = FSPACX ( ) ;
2015-06-13 22:42:20 +00:00
const auto & & fspacx3 = fspacx ( 3 ) ;
const auto & & fspacy2 = FSPACY ( 2 ) ;
2015-05-09 17:38:57 +00:00
{
for ( uint_fast32_t ui = 5 ; ui - - ; )
{
const auto i = static_cast < secondary_weapon_index_t > ( ui ) ;
char weapon_str [ 10 ] ;
hud_set_secondary_weapon_fontcolor ( i ) ;
2015-07-25 23:10:46 +00:00
snprintf ( weapon_str , sizeof ( weapon_str ) , " %i " , get_local_player ( ) . secondary_ammo [ i ] ) ;
2015-09-29 02:41:22 +00:00
int w , h ;
gr_get_string_size ( weapon_str , & w , & h , nullptr ) ;
2015-05-09 17:38:57 +00:00
if ( vertical ) {
2015-06-13 22:42:20 +00:00
y - = h + fspacy2 ;
2015-05-09 17:38:57 +00:00
} else
2015-06-13 22:42:20 +00:00
x - = w + fspacx3 ;
2015-09-29 02:41:22 +00:00
gr_string ( x , y , weapon_str , w , h ) ;
2015-05-09 17:38:57 +00:00
}
}
# if defined(DXX_BUILD_DESCENT_II)
x = orig_x ;
y = orig_y ;
if ( vertical )
{
2015-06-13 22:42:20 +00:00
x + = fspacx ( 15 ) ;
2015-06-13 22:42:22 +00:00
y + = line_spacing * 4 ;
2015-05-09 17:38:57 +00:00
}
else
{
2015-06-13 22:42:22 +00:00
y + = line_spacing ;
2015-05-09 17:38:57 +00:00
}
{
2015-04-19 04:18:53 +00:00
for ( uint_fast32_t ui = 10 ; ui - - ! = 5 ; )
{
const auto i = static_cast < secondary_weapon_index_t > ( ui ) ;
2012-11-04 02:52:44 +00:00
char weapon_str [ 10 ] ;
hud_set_secondary_weapon_fontcolor ( i ) ;
2015-07-25 23:10:46 +00:00
snprintf ( weapon_str , sizeof ( weapon_str ) , " %i " , get_local_player ( ) . secondary_ammo [ i ] ) ;
2015-09-29 02:41:22 +00:00
int w , h ;
gr_get_string_size ( weapon_str , & w , & h , nullptr ) ;
2008-11-09 14:31:30 +00:00
if ( vertical ) {
2015-06-13 22:42:20 +00:00
y - = h + fspacy2 ;
2008-11-09 14:31:30 +00:00
} else
2015-06-13 22:42:20 +00:00
x - = w + fspacx3 ;
2015-09-29 02:41:22 +00:00
gr_string ( x , y , weapon_str , w , h ) ;
2006-03-20 17:12:09 +00:00
}
}
2013-03-03 01:03:33 +00:00
# endif
2008-11-09 14:31:30 +00:00
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 0 , 31 , 0 ) , - 1 ) ;
2006-03-20 17:12:09 +00:00
}
2013-10-27 22:00:14 +00:00
static void hud_show_weapons ( void )
2006-03-20 17:12:09 +00:00
{
int y ;
2012-07-01 01:03:14 +00:00
const char * weapon_name ;
2006-03-20 17:12:09 +00:00
char weapon_str [ 32 ] ;
gr_set_curfont ( GAME_FONT ) ;
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 0 , 31 , 0 ) , - 1 ) ;
2006-03-20 17:12:09 +00:00
2008-02-24 14:41:27 +00:00
y = grd_curcanv - > cv_bitmap . bm_h ;
2006-03-20 17:12:09 +00:00
2015-06-13 22:42:22 +00:00
const auto & & line_spacing = LINE_SPACING ;
2007-04-03 21:57:54 +00:00
if ( Game_mode & GM_MULTI )
2015-06-13 22:42:22 +00:00
y - = line_spacing * 4 ;
2007-04-03 21:57:54 +00:00
2008-04-13 00:28:36 +00:00
if ( PlayerCfg . HudMode = = 1 ) {
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
unsigned multiplier = 1 ;
# elif defined(DXX_BUILD_DESCENT_II)
unsigned multiplier = 2 ;
# endif
2015-06-13 22:42:22 +00:00
hud_show_primary_weapons_mode ( 0 , grd_curcanv - > cv_bitmap . bm_w , y - ( line_spacing * 2 * multiplier ) ) ;
hud_show_secondary_weapons_mode ( 0 , grd_curcanv - > cv_bitmap . bm_w , y - ( line_spacing * multiplier ) ) ;
2015-06-13 22:42:20 +00:00
return ;
2006-03-20 17:12:09 +00:00
}
2015-06-13 22:42:20 +00:00
const auto & & fspacx = FSPACX ( ) ;
if ( PlayerCfg . HudMode = = 2 ) {
2006-03-20 17:12:09 +00:00
int x1 , x2 ;
2015-09-29 02:41:22 +00:00
int w ;
gr_get_string_size ( " V1000 " , & w , nullptr , nullptr ) ;
gr_get_string_size ( " 0 " , & x2 , nullptr , nullptr ) ;
2008-11-09 14:31:30 +00:00
y = grd_curcanv - > cv_bitmap . bm_h / 1.75 ;
2015-06-13 22:42:20 +00:00
x1 = grd_curcanv - > cv_bitmap . bm_w / 2.1 - ( fspacx ( 40 ) + w ) ;
x2 = grd_curcanv - > cv_bitmap . bm_w / 1.9 + ( fspacx ( 42 ) + x2 ) ;
2015-05-09 17:38:57 +00:00
hud_show_primary_weapons_mode ( 1 , x1 , y ) ;
hud_show_secondary_weapons_mode ( 1 , x2 , y ) ;
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 14 , 14 , 23 ) , - 1 ) ;
2015-10-30 02:52:55 +00:00
gr_printf ( x2 , y - ( line_spacing * 4 ) , " %i " , f2ir ( get_local_player_shields ( ) ) ) ;
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 25 , 18 , 6 ) , - 1 ) ;
2015-07-25 23:10:46 +00:00
gr_printf ( x1 , y - ( line_spacing * 4 ) , " %i " , f2ir ( get_local_player ( ) . energy ) ) ;
2006-03-20 17:12:09 +00:00
}
2006-09-29 00:57:57 +00:00
else
{
2013-06-09 22:39:49 +00:00
const char * disp_primary_weapon_name ;
2010-06-18 07:31:06 +00:00
2013-03-03 01:03:33 +00:00
weapon_name = PRIMARY_WEAPON_NAMES_SHORT ( Primary_weapon ) ;
2006-09-29 00:57:57 +00:00
switch ( Primary_weapon ) {
2015-10-18 21:01:18 +00:00
case primary_weapon_index_t : : LASER_INDEX :
2015-07-25 23:10:46 +00:00
if ( get_local_player ( ) . flags & PLAYER_FLAGS_QUAD_LASERS )
sprintf ( weapon_str , " %s %s %i " , TXT_QUAD , weapon_name , get_local_player ( ) . laser_level + 1 ) ;
2006-09-29 00:57:57 +00:00
else
2015-07-25 23:10:46 +00:00
sprintf ( weapon_str , " %s %i " , weapon_name , get_local_player ( ) . laser_level + 1 ) ;
2013-06-09 22:39:49 +00:00
disp_primary_weapon_name = weapon_str ;
2006-09-29 00:57:57 +00:00
break ;
2010-06-18 07:31:06 +00:00
2015-10-18 21:01:18 +00:00
case primary_weapon_index_t : : VULCAN_INDEX :
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2015-10-18 21:01:18 +00:00
case primary_weapon_index_t : : GAUSS_INDEX :
2013-03-03 01:03:33 +00:00
# endif
2015-07-25 23:10:46 +00:00
sprintf ( weapon_str , " %s: %i " , weapon_name , f2i ( ( unsigned ) get_local_player ( ) . vulcan_ammo * ( unsigned ) VULCAN_AMMO_SCALE ) ) ;
2006-09-29 00:57:57 +00:00
convert_1s ( weapon_str ) ;
2013-06-09 22:39:49 +00:00
disp_primary_weapon_name = weapon_str ;
2006-09-29 00:57:57 +00:00
break ;
2010-06-18 07:31:06 +00:00
2015-10-18 21:01:18 +00:00
case primary_weapon_index_t : : SPREADFIRE_INDEX :
case primary_weapon_index_t : : PLASMA_INDEX :
case primary_weapon_index_t : : FUSION_INDEX :
2013-10-09 01:54:12 +00:00
disp_primary_weapon_name = weapon_name ;
break ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2015-10-18 21:01:18 +00:00
case primary_weapon_index_t : : HELIX_INDEX :
case primary_weapon_index_t : : PHOENIX_INDEX :
2013-06-09 22:39:49 +00:00
disp_primary_weapon_name = weapon_name ;
2006-09-29 00:57:57 +00:00
break ;
2015-10-18 21:01:18 +00:00
case primary_weapon_index_t : : OMEGA_INDEX :
2006-09-29 00:57:57 +00:00
sprintf ( weapon_str , " %s: %03i " , weapon_name , Omega_charge * 100 / MAX_OMEGA_CHARGE ) ;
convert_1s ( weapon_str ) ;
2013-06-09 22:39:49 +00:00
disp_primary_weapon_name = weapon_str ;
2006-09-29 00:57:57 +00:00
break ;
2013-10-09 01:54:12 +00:00
# endif
2010-06-18 07:31:06 +00:00
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2015-10-18 21:01:18 +00:00
case primary_weapon_index_t : : SUPER_LASER_INDEX : //no such thing as super laser
2013-03-03 01:03:33 +00:00
# endif
2013-06-09 22:39:49 +00:00
default :
Int3 ( ) ;
disp_primary_weapon_name = " " ;
break ;
2006-03-20 17:12:09 +00:00
}
2010-06-18 07:31:06 +00:00
2015-09-29 02:41:22 +00:00
int w , h ;
gr_get_string_size ( disp_primary_weapon_name , & w , & h , nullptr ) ;
2015-06-13 22:42:20 +00:00
const auto & & bmwx = grd_curcanv - > cv_bitmap . bm_w - fspacx ( 1 ) ;
2015-09-29 02:41:22 +00:00
gr_string ( bmwx - w , y - ( line_spacing * 2 ) , disp_primary_weapon_name , w , h ) ;
2013-03-03 01:03:33 +00:00
const char * disp_secondary_weapon_name ;
2010-06-18 07:31:06 +00:00
2013-03-03 01:03:33 +00:00
disp_secondary_weapon_name = SECONDARY_WEAPON_NAMES_VERY_SHORT ( Secondary_weapon ) ;
2010-06-18 07:31:06 +00:00
2015-07-25 23:10:46 +00:00
sprintf ( weapon_str , " %s %d " , disp_secondary_weapon_name , get_local_player ( ) . secondary_ammo [ Secondary_weapon ] ) ;
2015-09-29 02:41:22 +00:00
gr_get_string_size ( weapon_str , & w , & h , nullptr ) ;
2015-09-29 02:41:22 +00:00
gr_string ( bmwx - w , y - line_spacing , weapon_str , w , h ) ;
2010-06-18 07:31:06 +00:00
2015-06-13 22:42:22 +00:00
show_bomb_count ( bmwx , y - ( line_spacing * 3 ) , - 1 , 1 , 1 ) ;
2006-03-20 17:12:09 +00:00
}
}
2013-10-27 22:00:14 +00:00
static void hud_show_cloak_invuln ( void )
2006-03-20 17:12:09 +00:00
{
2015-07-25 23:10:46 +00:00
const auto & plr = get_local_player ( ) ;
2015-06-13 22:42:20 +00:00
const auto player_flags = plr . flags ;
if ( ! ( player_flags & ( PLAYER_FLAGS_CLOAKED | PLAYER_FLAGS_INVULNERABLE ) ) )
return ;
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 0 , 31 , 0 ) , - 1 ) ;
2015-06-13 22:42:20 +00:00
const auto & & line_spacing = LINE_SPACING ;
const auto base_y = grd_curcanv - > cv_bitmap . bm_h - ( ( Game_mode & GM_MULTI ) ? line_spacing * 8 : line_spacing * 4 ) ;
const auto gametime64 = GameTime64 ;
2015-06-13 22:42:20 +00:00
const auto & & fspacx1 = FSPACX ( 1 ) ;
2006-03-20 17:12:09 +00:00
2015-10-03 17:17:49 +00:00
const auto a = [ & ] ( const char * txt , const fix64 effect_end ) {
if ( PlayerCfg . CloakInvulTimer )
gr_printf ( fspacx1 , base_y , " %s: %lu " , txt , static_cast < unsigned long > ( effect_end / F1_0 ) ) ;
else
gr_string ( fspacx1 , base_y , txt ) ;
} ;
2015-06-13 22:42:20 +00:00
if ( player_flags & PLAYER_FLAGS_CLOAKED )
{
const fix64 effect_end = plr . cloak_time + CLOAK_TIME_MAX - gametime64 ;
if ( effect_end > F1_0 * 3 | | gametime64 & 0x8000 )
2007-10-28 20:14:25 +00:00
{
2015-10-03 17:17:49 +00:00
a ( TXT_CLOAKED , effect_end ) ;
2007-10-28 20:14:25 +00:00
}
2006-03-20 17:12:09 +00:00
}
2015-06-13 22:42:20 +00:00
if ( player_flags & PLAYER_FLAGS_INVULNERABLE )
{
const fix64 effect_end = plr . invulnerable_time + INVULNERABLE_TIME_MAX - gametime64 ;
if ( effect_end > F1_0 * 4 | | gametime64 & 0x8000 )
2007-10-28 20:14:25 +00:00
{
2015-10-03 17:17:49 +00:00
a ( TXT_INVULNERABLE , effect_end ) ;
2007-10-28 20:14:25 +00:00
}
2006-03-20 17:12:09 +00:00
}
}
2013-10-27 22:00:14 +00:00
static void hud_show_shield ( void )
2006-03-20 17:12:09 +00:00
{
2008-04-13 00:28:36 +00:00
if ( PlayerCfg . HudMode < 2 ) {
2006-09-29 00:57:57 +00:00
gr_set_curfont ( GAME_FONT ) ;
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 0 , 31 , 0 ) , - 1 ) ;
2010-06-18 07:31:06 +00:00
2015-06-13 22:42:22 +00:00
const auto & & line_spacing = LINE_SPACING ;
2015-10-30 02:52:55 +00:00
const auto & shields = get_local_player_shields ( ) ;
gr_printf ( FSPACX ( 1 ) , grd_curcanv - > cv_bitmap . bm_h - ( ( Game_mode & GM_MULTI ) ? line_spacing * 6 : line_spacing * 2 ) , " %s: %i " , TXT_SHIELD , shields > = 0 ? f2ir ( shields ) : 0 ) ;
2006-03-20 17:12:09 +00:00
}
2010-07-15 05:40:25 +00:00
if ( Newdemo_state = = ND_STATE_RECORDING )
2015-10-30 02:52:55 +00:00
newdemo_record_player_shields ( f2ir ( get_local_player_shields ( ) ) ) ;
2006-03-20 17:12:09 +00:00
}
//draw the icons for number of lives
2015-04-26 20:15:54 +00:00
static void hud_show_lives ( const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
2008-02-24 14:41:27 +00:00
int x ;
2010-07-13 06:35:25 +00:00
if ( HUD_toolong )
2006-03-20 17:12:09 +00:00
return ;
2010-01-28 00:04:29 +00:00
if ( PlayerCfg . CockpitMode [ 1 ] = = CM_FULL_COCKPIT )
2008-02-24 14:41:27 +00:00
x = HUD_SCALE_X ( 7 ) ;
else
x = FSPACX ( 2 ) ;
2006-03-20 17:12:09 +00:00
if ( Game_mode & GM_MULTI ) {
gr_set_curfont ( GAME_FONT ) ;
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 0 , 31 , 0 ) , - 1 ) ;
2015-07-25 23:10:46 +00:00
gr_printf ( x , FSPACY ( 1 ) , " %s: %d " , TXT_DEATHS , get_local_player ( ) . net_killed_total ) ;
2010-06-18 07:31:06 +00:00
}
2015-07-25 23:10:46 +00:00
else if ( get_local_player ( ) . lives > 1 ) {
2008-02-24 14:41:27 +00:00
gr_set_curfont ( GAME_FONT ) ;
gr_set_fontcolor ( BM_XRGB ( 0 , 20 , 0 ) , - 1 ) ;
2015-04-26 20:15:56 +00:00
PAGE_IN_GAUGE ( GAUGE_LIVES , multires_gauge_graphic ) ;
2015-04-26 20:15:56 +00:00
auto & bm = GameBitmaps [ GET_GAUGE_INDEX ( GAUGE_LIVES ) ] ;
2015-06-13 22:42:20 +00:00
const auto & & fspacy1 = FSPACY ( 1 ) ;
hud_bitblt_free ( x , fspacy1 , HUD_SCALE_X_AR ( bm . bm_w ) , HUD_SCALE_Y_AR ( bm . bm_h ) , bm ) ;
2015-07-25 23:10:46 +00:00
gr_printf ( HUD_SCALE_X_AR ( bm . bm_w ) + x , fspacy1 , " x %d " , get_local_player ( ) . lives - 1 ) ;
2006-03-20 17:12:09 +00:00
}
}
2015-04-26 20:15:54 +00:00
static void sb_show_lives ( const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
int x , y ;
x = SB_LIVES_X ;
y = SB_LIVES_Y ;
2006-09-29 00:57:57 +00:00
gr_set_curfont ( GAME_FONT ) ;
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 0 , 20 , 0 ) , - 1 ) ;
2015-06-13 22:42:19 +00:00
gr_printf ( HUD_SCALE_X ( SB_LIVES_LABEL_X ) , HUD_SCALE_Y ( y ) , " %s: " , ( Game_mode & GM_MULTI ) ? TXT_DEATHS : TXT_LIVES ) ;
2006-03-20 17:12:09 +00:00
if ( Game_mode & GM_MULTI )
{
char killed_str [ 20 ] ;
2015-04-02 02:36:52 +00:00
static array < int , 4 > last_x { { SB_SCORE_RIGHT_L , SB_SCORE_RIGHT_L , SB_SCORE_RIGHT_H , SB_SCORE_RIGHT_H } } ;
2006-03-20 17:12:09 +00:00
2015-07-25 23:10:46 +00:00
sprintf ( killed_str , " %5d " , get_local_player ( ) . net_killed_total ) ;
2006-03-20 17:12:09 +00:00
gr_setcolor ( BM_XRGB ( 0 , 0 , 0 ) ) ;
2015-09-29 02:41:22 +00:00
int w , h ;
gr_get_string_size ( killed_str , & w , & h , nullptr ) ;
2015-04-02 02:36:53 +00:00
const auto x = HUD_SCALE_X ( SB_SCORE_RIGHT ) - w - FSPACX ( 1 ) ;
2015-04-26 20:15:53 +00:00
gr_rect ( exchange ( last_x [ multires_gauge_graphic . is_hires ( ) ] , x ) , HUD_SCALE_Y ( y ) , HUD_SCALE_X ( SB_SCORE_RIGHT ) , HUD_SCALE_Y ( y ) + LINE_SPACING ) ;
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 0 , 20 , 0 ) , - 1 ) ;
2015-09-29 02:41:22 +00:00
gr_string ( x , HUD_SCALE_Y ( y ) , killed_str , w , h ) ;
2006-03-20 17:12:09 +00:00
return ;
}
2006-09-29 00:57:57 +00:00
//erase old icons
gr_setcolor ( BM_XRGB ( 0 , 0 , 0 ) ) ;
2015-04-26 20:15:56 +00:00
auto & bm = GameBitmaps [ GET_GAUGE_INDEX ( GAUGE_LIVES ) ] ;
gr_rect ( HUD_SCALE_X ( x ) , HUD_SCALE_Y ( y ) , HUD_SCALE_X ( SB_SCORE_RIGHT ) , HUD_SCALE_Y ( y + bm . bm_h ) ) ;
2006-03-20 17:12:09 +00:00
2015-07-25 23:10:46 +00:00
if ( get_local_player ( ) . lives - 1 > 0 ) {
2006-09-29 00:57:57 +00:00
gr_set_curfont ( GAME_FONT ) ;
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 0 , 20 , 0 ) , - 1 ) ;
2015-04-26 20:15:56 +00:00
PAGE_IN_GAUGE ( GAUGE_LIVES , multires_gauge_graphic ) ;
2015-04-26 20:15:56 +00:00
hud_bitblt_free ( HUD_SCALE_X ( x ) , HUD_SCALE_Y ( y ) , HUD_SCALE_X_AR ( bm . bm_w ) , HUD_SCALE_Y_AR ( bm . bm_h ) , bm ) ;
2015-07-25 23:10:46 +00:00
gr_printf ( HUD_SCALE_X ( x ) + HUD_SCALE_X_AR ( bm . bm_w ) , HUD_SCALE_Y ( y ) , " x %d " , get_local_player ( ) . lives - 1 ) ;
2006-03-20 17:12:09 +00:00
}
}
# ifndef RELEASE
2013-10-27 22:00:14 +00:00
static void show_time ( )
2006-03-20 17:12:09 +00:00
{
2015-07-25 23:10:46 +00:00
int secs = f2i ( get_local_player ( ) . time_level ) % 60 ;
int mins = f2i ( get_local_player ( ) . time_level ) / 60 ;
2006-03-20 17:12:09 +00:00
gr_set_curfont ( GAME_FONT ) ;
if ( Color_0_31_0 = = - 1 )
2008-02-24 14:41:27 +00:00
Color_0_31_0 = BM_XRGB ( 0 , 31 , 0 ) ;
2006-03-20 17:12:09 +00:00
gr_set_fontcolor ( Color_0_31_0 , - 1 ) ;
2015-08-16 13:37:30 +00:00
gr_printf ( FSPACX ( 2 ) , ( LINE_SPACING * 15 ) , " %d:%02d " , mins , secs ) ;
2006-03-20 17:12:09 +00:00
}
# endif
# define EXTRA_SHIP_SCORE 50000 //get new ship every this many points
2010-06-18 07:31:06 +00:00
void add_points_to_score ( int points )
2006-03-20 17:12:09 +00:00
{
int prev_score ;
score_time + = f1_0 * 2 ;
2007-03-21 12:35:35 +00:00
score_display + = points ;
2006-03-20 17:12:09 +00:00
if ( score_time > f1_0 * 4 ) score_time = f1_0 * 4 ;
2011-02-14 21:27:07 +00:00
if ( points = = 0 | | cheats . enabled )
2006-03-20 17:12:09 +00:00
return ;
if ( ( Game_mode & GM_MULTI ) & & ! ( Game_mode & GM_MULTI_COOP ) )
return ;
2015-07-25 23:10:46 +00:00
prev_score = get_local_player ( ) . score ;
2006-03-20 17:12:09 +00:00
2015-07-25 23:10:46 +00:00
get_local_player ( ) . score + = points ;
2006-03-20 17:12:09 +00:00
if ( Newdemo_state = = ND_STATE_RECORDING )
newdemo_record_player_score ( points ) ;
if ( Game_mode & GM_MULTI_COOP )
multi_send_score ( ) ;
if ( Game_mode & GM_MULTI )
return ;
2015-07-25 23:10:46 +00:00
if ( get_local_player ( ) . score / EXTRA_SHIP_SCORE ! = prev_score / EXTRA_SHIP_SCORE ) {
2006-03-20 17:12:09 +00:00
int snd ;
2015-07-25 23:10:46 +00:00
get_local_player ( ) . lives + = get_local_player ( ) . score / EXTRA_SHIP_SCORE - prev_score / EXTRA_SHIP_SCORE ;
2013-12-08 23:37:40 +00:00
powerup_basic_str ( 20 , 20 , 20 , 0 , TXT_EXTRA_LIFE ) ;
2006-03-20 17:12:09 +00:00
if ( ( snd = Powerup_info [ POW_EXTRA_LIFE ] . hit_sound ) > - 1 )
digi_play_sample ( snd , F1_0 ) ;
}
}
2010-06-18 07:31:06 +00:00
void add_bonus_points_to_score ( int points )
2006-03-20 17:12:09 +00:00
{
int prev_score ;
2011-02-14 21:27:07 +00:00
if ( points = = 0 | | cheats . enabled )
2006-03-20 17:12:09 +00:00
return ;
2015-07-25 23:10:46 +00:00
prev_score = get_local_player ( ) . score ;
2006-03-20 17:12:09 +00:00
2015-07-25 23:10:46 +00:00
get_local_player ( ) . score + = points ;
2006-03-20 17:12:09 +00:00
if ( Newdemo_state = = ND_STATE_RECORDING )
newdemo_record_player_score ( points ) ;
if ( Game_mode & GM_MULTI )
return ;
2015-07-25 23:10:46 +00:00
if ( get_local_player ( ) . score / EXTRA_SHIP_SCORE ! = prev_score / EXTRA_SHIP_SCORE ) {
2006-03-20 17:12:09 +00:00
int snd ;
2015-07-25 23:10:46 +00:00
get_local_player ( ) . lives + = get_local_player ( ) . score / EXTRA_SHIP_SCORE - prev_score / EXTRA_SHIP_SCORE ;
2006-03-20 17:12:09 +00:00
if ( ( snd = Powerup_info [ POW_EXTRA_LIFE ] . hit_sound ) > - 1 )
digi_play_sample ( snd , F1_0 ) ;
}
}
2008-11-09 14:31:30 +00:00
// Decode cockpit bitmap to deccpt and add alpha fields to weapon boxes (as it should have always been) so we later can render sub bitmaps over the window canvases
2015-04-26 20:15:54 +00:00
static void cockpit_decode_alpha ( grs_bitmap * const bm , const local_multires_gauge_graphic multires_gauge_graphic )
2008-11-09 14:31:30 +00:00
{
2009-02-23 10:15:23 +00:00
static unsigned char * cur = NULL ;
static short cur_w = 0 , cur_h = 0 ;
2008-11-09 14:31:30 +00:00
static unsigned char cockpitbuf [ 1024 * 1024 ] ;
// check if we processed this bitmap already
2009-02-23 10:15:23 +00:00
if ( cur = = bm - > bm_data & & cur_w = = bm - > bm_w & & cur_h = = bm - > bm_h )
2008-11-09 14:31:30 +00:00
return ;
2010-06-18 07:31:06 +00:00
2008-11-09 14:31:30 +00:00
memset ( cockpitbuf , 0 , 1024 * 1024 ) ;
// decode the bitmap
if ( bm - > bm_flags & BM_FLAG_RLE ) {
unsigned char * dbits ;
int i , data_offset ;
data_offset = 1 ;
if ( bm - > bm_flags & BM_FLAG_RLE_BIG )
data_offset = 2 ;
2014-12-02 03:24:38 +00:00
auto sbits = & bm - > get_bitmap_data ( ) [ 4 + ( bm - > bm_h * data_offset ) ] ;
2008-11-09 14:31:30 +00:00
dbits = cockpitbuf ;
for ( i = 0 ; i < bm - > bm_h ; i + + ) {
2014-11-13 03:41:38 +00:00
gr_rle_decode ( { sbits , dbits } , rle_end ( * bm , cockpitbuf ) ) ;
2008-11-09 14:31:30 +00:00
if ( bm - > bm_flags & BM_FLAG_RLE_BIG )
2015-06-13 22:42:21 +00:00
sbits + = GET_INTEL_SHORT ( & bm - > bm_data [ 4 + ( i * data_offset ) ] ) ;
2008-11-09 14:31:30 +00:00
else
sbits + = ( int ) bm - > bm_data [ 4 + i ] ;
dbits + = bm - > bm_w ;
}
}
2010-06-18 07:31:06 +00:00
else
{
memcpy ( & cockpitbuf , bm - > bm_data , sizeof ( unsigned char ) * ( bm - > bm_w * bm - > bm_h ) ) ;
}
2008-11-09 14:31:30 +00:00
// add alpha color to the pixels which are inside the window box spans
2015-04-26 20:15:53 +00:00
const unsigned lower_y = ( ( multires_gauge_graphic . get ( 364 , 151 ) ) ) ;
2015-09-13 21:02:19 +00:00
const unsigned bm_w = bm - > bm_w ;
unsigned i = bm_w * lower_y ;
const auto fill_alpha_one_line = [ ] ( unsigned o , const span & s ) {
std : : fill_n ( & cockpitbuf [ o + s . l ] , s . r - s . l + 1 , TRANSPARENCY_COLOR ) ;
} ;
2015-09-13 21:02:19 +00:00
range_for ( auto & s ,
multires_gauge_graphic . is_hires ( )
? make_range ( weapon_windows_hires )
: make_range ( weapon_windows_lowres )
)
2008-11-09 14:31:30 +00:00
{
2015-09-13 21:02:19 +00:00
fill_alpha_one_line ( i , s . l ) ;
fill_alpha_one_line ( i , s . r ) ;
2015-09-13 21:02:19 +00:00
i + = bm_w ;
2008-11-09 14:31:30 +00:00
}
# ifdef OGL
2014-11-30 22:09:20 +00:00
ogl_freebmtexture ( * bm ) ;
2008-11-09 14:31:30 +00:00
# endif
2014-11-30 22:09:20 +00:00
gr_init_bitmap ( deccpt , 0 , 0 , 0 , bm - > bm_w , bm - > bm_h , bm - > bm_w , cockpitbuf ) ;
2014-11-30 22:09:21 +00:00
gr_set_transparent ( deccpt , 1 ) ;
2008-11-09 14:31:30 +00:00
# ifdef OGL
2014-11-30 22:09:18 +00:00
ogl_ubitmapm_cs ( 0 , 0 , - 1 , - 1 , deccpt , 255 , F1_0 ) ; // render one time to init the texture
2008-11-09 14:31:30 +00:00
# endif
2014-11-30 22:09:21 +00:00
WinBoxOverlay [ 0 ] = gr_create_sub_bitmap ( deccpt , ( PRIMARY_W_BOX_LEFT ) - 2 , ( PRIMARY_W_BOX_TOP ) - 2 , ( PRIMARY_W_BOX_RIGHT - PRIMARY_W_BOX_LEFT + 4 ) , ( PRIMARY_W_BOX_BOT - PRIMARY_W_BOX_TOP + 4 ) ) ;
WinBoxOverlay [ 1 ] = gr_create_sub_bitmap ( deccpt , ( SECONDARY_W_BOX_LEFT ) - 2 , ( SECONDARY_W_BOX_TOP ) - 2 , ( SECONDARY_W_BOX_RIGHT - SECONDARY_W_BOX_LEFT ) + 4 , ( SECONDARY_W_BOX_BOT - SECONDARY_W_BOX_TOP ) + 4 ) ;
2010-06-18 07:31:06 +00:00
2014-12-02 03:24:38 +00:00
cur = bm - > get_bitmap_data ( ) ;
2009-02-23 10:15:23 +00:00
cur_w = bm - > bm_w ;
cur_h = bm - > bm_h ;
2008-11-09 14:31:30 +00:00
}
2015-04-26 20:15:54 +00:00
static void draw_wbu_overlay ( const local_multires_gauge_graphic multires_gauge_graphic )
2008-11-09 14:31:30 +00:00
{
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
unsigned cockpit_idx = PlayerCfg . CockpitMode [ 1 ] ;
# elif defined(DXX_BUILD_DESCENT_II)
2015-04-26 20:15:53 +00:00
unsigned cockpit_idx = PlayerCfg . CockpitMode [ 1 ] + ( multires_gauge_graphic . is_hires ( ) ? ( Num_cockpits / 2 ) : 0 ) ;
2013-03-03 01:03:33 +00:00
# endif
2013-07-13 02:34:56 +00:00
PIGGY_PAGE_IN ( cockpit_bitmap [ cockpit_idx ] ) ;
grs_bitmap * bm = & GameBitmaps [ cockpit_bitmap [ cockpit_idx ] . index ] ;
2010-06-18 07:31:06 +00:00
2015-04-26 20:15:54 +00:00
cockpit_decode_alpha ( bm , multires_gauge_graphic ) ;
2010-06-18 07:31:06 +00:00
2014-07-22 02:50:01 +00:00
if ( WinBoxOverlay [ 0 ] )
2015-04-26 20:15:56 +00:00
hud_bitblt ( HUD_SCALE_X ( PRIMARY_W_BOX_LEFT - 2 ) , HUD_SCALE_Y ( PRIMARY_W_BOX_TOP - 2 ) , * WinBoxOverlay [ 0 ] . get ( ) , multires_gauge_graphic ) ;
2014-07-22 02:50:01 +00:00
if ( WinBoxOverlay [ 1 ] )
2015-04-26 20:15:56 +00:00
hud_bitblt ( HUD_SCALE_X ( SECONDARY_W_BOX_LEFT - 2 ) , HUD_SCALE_Y ( SECONDARY_W_BOX_TOP - 2 ) , * WinBoxOverlay [ 1 ] . get ( ) , multires_gauge_graphic ) ;
2008-11-09 14:31:30 +00:00
}
2008-10-28 13:28:10 +00:00
void close_gauges ( )
2006-03-20 17:12:09 +00:00
{
2014-07-22 02:50:01 +00:00
WinBoxOverlay = { } ;
2006-03-20 17:12:09 +00:00
}
void init_gauges ( )
{
2007-03-21 12:35:35 +00:00
old_weapon [ 0 ] = old_weapon [ 1 ] = - 1 ;
2013-03-03 01:03:33 +00:00
old_laser_level = - 1 ;
# if defined(DXX_BUILD_DESCENT_II)
2006-03-20 17:12:09 +00:00
weapon_box_user [ 0 ] = weapon_box_user [ 1 ] = WBU_WEAPON ;
2013-03-03 01:03:33 +00:00
# endif
2006-03-20 17:12:09 +00:00
}
2015-04-26 20:15:54 +00:00
static void draw_energy_bar ( int energy , const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
2007-10-05 23:47:16 +00:00
int x1 , x2 , y ;
2015-04-26 20:15:53 +00:00
int not_energy = HUD_SCALE_X ( multires_gauge_graphic . is_hires ( ) ? ( 125 - ( energy * 125 ) / 100 ) : ( 63 - ( energy * 63 ) / 100 ) ) ;
2007-10-05 23:47:16 +00:00
double aplitscale = ( ( double ) ( HUD_SCALE_X ( 65 ) / HUD_SCALE_Y ( 8 ) ) / ( 65 / 8 ) ) ; //scale aplitude of energy bar to current resolution aspect
2006-03-20 17:12:09 +00:00
// Draw left energy bar
2015-04-26 20:15:53 +00:00
hud_gauge_bitblt ( LEFT_ENERGY_GAUGE_X , LEFT_ENERGY_GAUGE_Y , GAUGE_ENERGY_LEFT , multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
gr_setcolor ( BM_XRGB ( 0 , 0 , 0 ) ) ;
2007-10-05 23:47:16 +00:00
if ( energy < 100 )
for ( y = 0 ; y < HUD_SCALE_Y ( LEFT_ENERGY_GAUGE_H ) ; y + + ) {
x1 = HUD_SCALE_X ( LEFT_ENERGY_GAUGE_H - 2 ) - y * ( aplitscale ) ;
x2 = HUD_SCALE_X ( LEFT_ENERGY_GAUGE_H - 2 ) - y * ( aplitscale ) + not_energy ;
if ( x2 > HUD_SCALE_X ( LEFT_ENERGY_GAUGE_W ) - ( y * aplitscale ) / 3 )
x2 = HUD_SCALE_X ( LEFT_ENERGY_GAUGE_W ) - ( y * aplitscale ) / 3 ;
2010-06-18 07:31:06 +00:00
if ( x2 > x1 ) gr_uline ( i2f ( x1 + HUD_SCALE_X ( LEFT_ENERGY_GAUGE_X ) ) , i2f ( y + HUD_SCALE_Y ( LEFT_ENERGY_GAUGE_Y ) ) , i2f ( x2 + HUD_SCALE_X ( LEFT_ENERGY_GAUGE_X ) ) , i2f ( y + HUD_SCALE_Y ( LEFT_ENERGY_GAUGE_Y ) ) ) ;
2006-03-20 17:12:09 +00:00
}
2007-10-05 23:47:16 +00:00
2007-03-21 11:32:33 +00:00
gr_set_current_canvas ( NULL ) ;
2007-10-05 23:47:16 +00:00
2006-03-20 17:12:09 +00:00
// Draw right energy bar
2015-04-26 20:15:53 +00:00
hud_gauge_bitblt ( RIGHT_ENERGY_GAUGE_X , RIGHT_ENERGY_GAUGE_Y , GAUGE_ENERGY_RIGHT , multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
2007-10-05 23:47:16 +00:00
if ( energy < 100 )
for ( y = 0 ; y < HUD_SCALE_Y ( RIGHT_ENERGY_GAUGE_H ) ; y + + ) {
x1 = HUD_SCALE_X ( RIGHT_ENERGY_GAUGE_W - RIGHT_ENERGY_GAUGE_H + 2 ) + y * ( aplitscale ) - not_energy ;
x2 = HUD_SCALE_X ( RIGHT_ENERGY_GAUGE_W - RIGHT_ENERGY_GAUGE_H + 2 ) + y * ( aplitscale ) ;
if ( x1 < ( y * aplitscale ) / 3 )
x1 = ( y * aplitscale ) / 3 ;
2010-06-18 07:31:06 +00:00
if ( x2 > x1 ) gr_uline ( i2f ( x1 + HUD_SCALE_X ( RIGHT_ENERGY_GAUGE_X ) ) , i2f ( y + HUD_SCALE_Y ( RIGHT_ENERGY_GAUGE_Y ) ) , i2f ( x2 + HUD_SCALE_X ( RIGHT_ENERGY_GAUGE_X ) ) , i2f ( y + HUD_SCALE_Y ( RIGHT_ENERGY_GAUGE_Y ) ) ) ;
2006-03-20 17:12:09 +00:00
}
2007-10-05 23:47:16 +00:00
2007-03-21 11:32:33 +00:00
gr_set_current_canvas ( NULL ) ;
2006-03-20 17:12:09 +00:00
}
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2015-04-26 20:15:54 +00:00
static void draw_afterburner_bar ( int afterburner , const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
int not_afterburner ;
2011-09-26 23:31:19 +00:00
int i , j , y ;
2013-06-08 22:24:17 +00:00
static const ubyte afterburner_bar_table [ AFTERBURNER_GAUGE_H_L * 2 ] = { 3 , 11 , 3 , 11 , 3 , 11 , 3 , 11 , 3 , 11 , 3 , 11 , 2 , 11 , 2 , 10 , 2 , 10 , 2 , 10 , 2 , 10 , 2 , 10 , 2 , 10 , 1 , 10 , 1 , 10 , 1 , 10 , 1 , 9 , 1 , 9 , 1 , 9 , 1 , 9 , 0 , 9 , 0 , 9 , 0 , 8 , 0 , 8 , 0 , 8 , 0 , 8 , 1 , 8 , 2 , 8 , 3 , 8 , 4 , 8 , 5 , 8 , 6 , 7 } ;
static const ubyte afterburner_bar_table_hires [ AFTERBURNER_GAUGE_H_H * 2 ] = { 5 , 20 , 5 , 20 , 5 , 19 , 5 , 19 , 5 , 19 , 5 , 19 , 4 , 19 , 4 , 19 , 4 , 19 , 4 , 19 , 4 , 19 , 4 , 18 , 4 , 18 , 4 , 18 , 4 , 18 , 3 , 18 , 3 , 18 , 3 , 18 , 3 , 18 , 3 , 18 , 3 , 18 , 3 , 17 , 3 , 17 , 2 , 17 , 2 , 17 , 2 , 17 , 2 , 17 , 2 , 17 , 2 , 17 , 2 , 17 , 2 , 17 , 2 , 16 , 2 , 16 , 1 , 16 , 1 , 16 , 1 , 16 , 1 , 16 , 1 , 16 , 1 , 16 , 1 , 16 , 1 , 16 , 1 , 15 , 1 , 15 , 1 , 15 , 0 , 15 , 0 , 15 , 0 , 15 , 0 , 15 , 0 , 15 , 0 , 15 , 0 , 14 , 0 , 14 , 0 , 14 , 1 , 14 , 2 , 14 , 3 , 14 , 4 , 14 , 5 , 14 , 6 , 13 , 7 , 13 , 8 , 13 , 9 , 13 , 10 , 13 , 11 , 13 , 12 , 13 } ;
2015-04-26 20:15:53 +00:00
const ubyte * pabt = ( multires_gauge_graphic . is_hires ( ) ? afterburner_bar_table_hires : afterburner_bar_table ) ;
2006-03-20 17:12:09 +00:00
// Draw afterburner bar
2015-04-26 20:15:53 +00:00
hud_gauge_bitblt ( AFTERBURNER_GAUGE_X , AFTERBURNER_GAUGE_Y , GAUGE_AFTERBURNER , multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
gr_setcolor ( BM_XRGB ( 0 , 0 , 0 ) ) ;
not_afterburner = fixmul ( f1_0 - afterburner , AFTERBURNER_GAUGE_H ) ;
for ( y = 0 ; y < not_afterburner ; y + + ) {
for ( i = HUD_SCALE_Y ( y ) , j = HUD_SCALE_Y ( y + 1 ) ; i < j ; i + + ) {
gr_rect (
2010-06-18 07:31:06 +00:00
HUD_SCALE_X ( AFTERBURNER_GAUGE_X + pabt [ y * 2 ] ) ,
2006-03-20 17:12:09 +00:00
HUD_SCALE_Y ( AFTERBURNER_GAUGE_Y - 1 ) + i ,
2010-06-18 07:31:06 +00:00
HUD_SCALE_X ( AFTERBURNER_GAUGE_X + pabt [ y * 2 + 1 ] + 1 ) ,
2006-03-20 17:12:09 +00:00
HUD_SCALE_Y ( AFTERBURNER_GAUGE_Y ) + i ) ;
}
}
2007-03-21 11:32:33 +00:00
gr_set_current_canvas ( NULL ) ;
2006-03-20 17:12:09 +00:00
}
2013-03-03 01:03:33 +00:00
# endif
2006-03-20 17:12:09 +00:00
2015-04-26 20:15:54 +00:00
static void draw_shield_bar ( int shield , const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
int bm_num = shield > = 100 ? 9 : ( shield / 10 ) ;
2015-04-26 20:15:53 +00:00
hud_gauge_bitblt ( SHIELD_GAUGE_X , SHIELD_GAUGE_Y , GAUGE_SHIELDS + 9 - bm_num , multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
}
2015-10-03 17:17:49 +00:00
static void show_cockpit_cloak_invul_timer ( const fix64 effect_end , int y )
{
char countdown [ 8 ] ;
int ow , oh ;
snprintf ( countdown , sizeof ( countdown ) , " %lu " , static_cast < unsigned long > ( effect_end / F1_0 ) ) ;
gr_set_fontcolor ( BM_XRGB ( 31 , 31 , 31 ) , - 1 ) ;
gr_get_string_size ( countdown , & ow , & oh , nullptr ) ;
const int x = grd_curscreen - > get_screen_width ( ) / ( PlayerCfg . CockpitMode [ 1 ] = = CM_STATUS_BAR
? 2.266
: 1.951
) ;
gr_string ( x - ( ow / 2 ) , y , countdown , ow , oh ) ;
}
2006-03-20 17:12:09 +00:00
# define CLOAK_FADE_WAIT_TIME 0x400
2015-04-26 20:15:54 +00:00
static void draw_player_ship ( int cloak_state , int x , int y , const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
static fix cloak_fade_timer = 0 ;
static int cloak_fade_value = GR_FADE_LEVELS - 1 ;
2010-06-18 07:31:06 +00:00
2010-01-24 17:38:13 +00:00
if ( cloak_state )
2007-10-28 20:14:25 +00:00
{
2010-01-24 17:38:13 +00:00
static int step = 0 ;
2006-03-20 17:12:09 +00:00
2015-07-25 23:10:46 +00:00
if ( GameTime64 - get_local_player ( ) . cloak_time < F1_0 )
2010-01-24 17:38:13 +00:00
{
step = - 2 ;
}
2015-07-25 23:10:46 +00:00
else if ( get_local_player ( ) . cloak_time + CLOAK_TIME_MAX - GameTime64 < = F1_0 * 3 )
2010-01-24 17:38:13 +00:00
{
if ( cloak_fade_value > = ( GR_FADE_LEVELS - 1 ) )
{
step = - 2 ;
}
else if ( cloak_fade_value < = 0 )
{
step = 2 ;
}
}
else
{
step = 0 ;
cloak_fade_value = 0 ;
}
2006-03-20 17:12:09 +00:00
2010-01-24 17:38:13 +00:00
cloak_fade_timer - = FrameTime ;
2006-03-20 17:12:09 +00:00
2010-01-24 17:38:13 +00:00
while ( cloak_fade_timer < 0 )
{
cloak_fade_timer + = CLOAK_FADE_WAIT_TIME ;
cloak_fade_value + = step ;
2006-03-20 17:12:09 +00:00
}
2010-06-18 07:31:06 +00:00
2010-01-24 17:38:13 +00:00
if ( cloak_fade_value > ( GR_FADE_LEVELS - 1 ) )
cloak_fade_value = ( GR_FADE_LEVELS - 1 ) ;
if ( cloak_fade_value < = 0 )
2006-03-20 17:12:09 +00:00
cloak_fade_value = 0 ;
}
2010-01-24 17:38:13 +00:00
else
{
cloak_fade_timer = 0 ;
cloak_fade_value = GR_FADE_LEVELS - 1 ;
2006-03-20 17:12:09 +00:00
}
2007-03-24 04:37:33 +00:00
gr_set_current_canvas ( NULL ) ;
2015-04-26 20:15:56 +00:00
const auto color = get_player_or_team_color ( Player_num ) ;
2015-04-26 20:15:56 +00:00
PAGE_IN_GAUGE ( GAUGE_SHIPS + color , multires_gauge_graphic ) ;
2015-04-26 20:15:56 +00:00
auto & bm = GameBitmaps [ GET_GAUGE_INDEX ( GAUGE_SHIPS + color ) ] ;
2015-04-26 20:15:53 +00:00
hud_bitblt ( HUD_SCALE_X ( x ) , HUD_SCALE_Y ( y ) , bm , multires_gauge_graphic ) ;
2011-02-23 16:46:39 +00:00
gr_settransblend ( cloak_fade_value , GR_BLEND_NORMAL ) ;
2015-04-26 20:15:56 +00:00
gr_rect ( HUD_SCALE_X ( x - 3 ) , HUD_SCALE_Y ( y - 3 ) , HUD_SCALE_X ( x + bm . bm_w + 3 ) , HUD_SCALE_Y ( y + bm . bm_h + 3 ) ) ;
2011-02-23 16:46:39 +00:00
gr_settransblend ( GR_FADE_OFF , GR_BLEND_NORMAL ) ;
2007-03-21 11:32:33 +00:00
gr_set_current_canvas ( NULL ) ;
2015-09-27 08:51:37 +00:00
// Show Cloak Timer if enabled
if ( cloak_fade_value < GR_FADE_LEVELS / 2 & & PlayerCfg . CloakInvulTimer )
2015-10-03 17:17:49 +00:00
show_cockpit_cloak_invul_timer ( get_local_player ( ) . cloak_time + CLOAK_TIME_MAX - GameTime64 , HUD_SCALE_Y ( y + ( bm . bm_h / 2 ) ) ) ;
2006-03-20 17:12:09 +00:00
}
# define INV_FRAME_TIME (f1_0 / 10) //how long for each frame
2015-10-09 02:46:11 +00:00
static const char * get_gauge_width_string ( unsigned v )
{
if ( v > 199 )
return " 200 " ;
return & " 100 " [ ( v > 99 )
? 0
: ( v > 9 ) ? 1 : 2
] ;
}
2015-05-09 17:38:57 +00:00
static void draw_numerical_display ( int shield , int energy , const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
gr_set_curfont ( GAME_FONT ) ;
2007-10-18 14:44:02 +00:00
# ifndef OGL
2015-04-26 20:15:53 +00:00
hud_gauge_bitblt ( NUMERICAL_GAUGE_X , NUMERICAL_GAUGE_Y , GAUGE_NUMERICAL , multires_gauge_graphic ) ;
2007-10-18 14:44:02 +00:00
# endif
2008-02-24 14:41:27 +00:00
// cockpit is not 100% geometric so we need to divide shield and energy X position by 1.951 which should be most accurate
// gr_get_string_size is used so we can get the numbers finally in the correct position with sw and ew
2015-09-29 02:41:22 +00:00
const auto a = [ ] ( int xb , int v , int y ) {
int w ;
2015-10-09 02:46:11 +00:00
gr_get_string_size ( get_gauge_width_string ( v ) , & w , nullptr , nullptr ) ;
2015-09-29 02:41:22 +00:00
gr_printf ( xb - ( w / 2 ) , y , " %d " , v ) ;
} ;
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 14 , 14 , 23 ) , - 1 ) ;
2015-09-29 02:41:22 +00:00
const auto xb = grd_curscreen - > get_screen_width ( ) / 1.951 ;
const auto screen_height = grd_curscreen - > get_screen_height ( ) ;
a ( xb , shield , screen_height / 1.365 ) ;
2006-03-20 17:12:09 +00:00
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 25 , 18 , 6 ) , - 1 ) ;
2015-09-29 02:41:22 +00:00
a ( xb , energy , screen_height / 1.5 ) ;
2010-06-18 07:31:06 +00:00
2007-03-21 11:32:33 +00:00
gr_set_current_canvas ( NULL ) ;
2006-03-20 17:12:09 +00:00
}
2015-10-30 02:52:54 +00:00
void draw_cockpit_keys_state : : draw_all_keys ( const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
2015-10-30 02:52:54 +00:00
draw_one_key ( GAUGE_BLUE_KEY_X , GAUGE_BLUE_KEY_Y , GAUGE_BLUE_KEY , multires_gauge_graphic , PLAYER_FLAGS_BLUE_KEY ) ;
draw_one_key ( GAUGE_GOLD_KEY_X , GAUGE_GOLD_KEY_Y , GAUGE_GOLD_KEY , multires_gauge_graphic , PLAYER_FLAGS_GOLD_KEY ) ;
draw_one_key ( GAUGE_RED_KEY_X , GAUGE_RED_KEY_Y , GAUGE_RED_KEY , multires_gauge_graphic , PLAYER_FLAGS_RED_KEY ) ;
2006-03-20 17:12:09 +00:00
}
2015-04-26 20:15:55 +00:00
static void draw_weapon_info_sub ( int info_index , const gauge_box * box , int pic_x , int pic_y , const char * name , int text_x , int text_y , const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
//clear the window
gr_setcolor ( BM_XRGB ( 0 , 0 , 0 ) ) ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
gr_rect ( HUD_SCALE_X ( box - > left ) , HUD_SCALE_Y ( box - > top ) , HUD_SCALE_X ( box - > right ) , HUD_SCALE_Y ( box - > bot + 1 ) ) ;
# elif defined(DXX_BUILD_DESCENT_II)
2007-06-10 16:21:53 +00:00
gr_rect ( HUD_SCALE_X ( box - > left ) , HUD_SCALE_Y ( box - > top ) , HUD_SCALE_X ( box - > right ) , HUD_SCALE_Y ( box - > bot ) ) ;
2013-03-03 01:03:33 +00:00
# endif
2015-04-26 20:15:56 +00:00
const auto & picture =
# if defined(DXX_BUILD_DESCENT_II)
// !SHAREWARE
( Piggy_hamfile_version > = 3 & & multires_gauge_graphic . is_hires ( ) ) ?
Weapon_info [ info_index ] . hires_picture :
# endif
Weapon_info [ info_index ] . picture ;
PIGGY_PAGE_IN ( picture ) ;
2015-04-26 20:15:56 +00:00
auto & bm = GameBitmaps [ picture . index ] ;
2006-03-20 17:12:09 +00:00
2015-04-26 20:15:53 +00:00
hud_bitblt ( HUD_SCALE_X ( pic_x ) , HUD_SCALE_Y ( pic_y ) , bm , multires_gauge_graphic ) ;
2010-06-18 07:31:06 +00:00
2008-04-13 00:28:36 +00:00
if ( PlayerCfg . HudMode = = 0 )
2008-02-24 14:41:27 +00:00
{
gr_set_fontcolor ( BM_XRGB ( 0 , 20 , 0 ) , - 1 ) ;
2010-06-18 07:31:06 +00:00
2013-01-03 16:23:24 +00:00
gr_string ( text_x , text_y , name ) ;
2010-06-18 07:31:06 +00:00
2006-03-20 17:12:09 +00:00
// For laser, show level and quadness
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
2015-10-18 21:01:18 +00:00
if ( info_index = = primary_weapon_index_t : : LASER_INDEX )
2013-03-03 01:03:33 +00:00
# elif defined(DXX_BUILD_DESCENT_II)
2010-02-19 00:24:32 +00:00
if ( info_index = = LASER_ID | | info_index = = SUPER_LASER_ID )
2013-03-03 01:03:33 +00:00
# endif
2010-02-19 00:24:32 +00:00
{
2015-06-13 22:42:22 +00:00
const auto & & line_spacing = LINE_SPACING ;
2015-07-25 23:10:46 +00:00
gr_printf ( text_x , text_y + line_spacing , " %s: %i " , TXT_LVL , get_local_player ( ) . laser_level + 1 ) ;
if ( get_local_player ( ) . flags & PLAYER_FLAGS_QUAD_LASERS )
2015-06-13 22:42:22 +00:00
gr_string ( text_x , text_y + ( line_spacing * 2 ) , TXT_QUAD ) ;
2006-03-20 17:12:09 +00:00
}
}
}
2015-05-09 17:38:58 +00:00
static void draw_primary_weapon_info ( int weapon_num , int laser_level , const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
2015-01-18 01:58:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
( void ) laser_level ;
# endif
2013-03-03 01:03:33 +00:00
int x , y ;
2006-03-20 17:12:09 +00:00
int info_index ;
2015-05-09 17:38:58 +00:00
{
2006-03-20 17:12:09 +00:00
info_index = Primary_weapon_to_weapon_info [ weapon_num ] ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2006-03-20 17:12:09 +00:00
if ( info_index = = LASER_ID & & laser_level > MAX_LASER_LEVEL )
info_index = SUPER_LASER_ID ;
2013-03-03 01:03:33 +00:00
# endif
2006-03-20 17:12:09 +00:00
2010-01-28 00:04:29 +00:00
if ( PlayerCfg . CockpitMode [ 1 ] = = CM_STATUS_BAR )
2013-03-03 01:03:33 +00:00
{
2006-03-20 17:12:09 +00:00
draw_weapon_info_sub ( info_index ,
& gauge_boxes [ SB_PRIMARY_BOX ] ,
SB_PRIMARY_W_PIC_X , SB_PRIMARY_W_PIC_Y ,
PRIMARY_WEAPON_NAMES_SHORT ( weapon_num ) ,
2015-04-26 20:15:55 +00:00
SB_PRIMARY_W_TEXT_X , SB_PRIMARY_W_TEXT_Y , multires_gauge_graphic ) ;
2013-03-03 01:03:33 +00:00
x = SB_PRIMARY_AMMO_X ;
y = SB_PRIMARY_AMMO_Y ;
}
2006-03-20 17:12:09 +00:00
else
2013-03-03 01:03:33 +00:00
{
2006-03-20 17:12:09 +00:00
draw_weapon_info_sub ( info_index ,
& gauge_boxes [ COCKPIT_PRIMARY_BOX ] ,
PRIMARY_W_PIC_X , PRIMARY_W_PIC_Y ,
PRIMARY_WEAPON_NAMES_SHORT ( weapon_num ) ,
2015-04-26 20:15:55 +00:00
PRIMARY_W_TEXT_X , PRIMARY_W_TEXT_Y , multires_gauge_graphic ) ;
2013-03-03 01:03:33 +00:00
x = PRIMARY_AMMO_X ;
y = PRIMARY_AMMO_Y ;
}
if ( PlayerCfg . HudMode ! = 0 )
{
# if defined(DXX_BUILD_DESCENT_II)
2015-05-09 17:38:58 +00:00
if ( weapon_box_user [ 0 ] = = WBU_WEAPON )
2013-03-03 01:03:33 +00:00
# endif
2015-05-09 17:38:57 +00:00
hud_show_primary_weapons_mode ( 1 , x , y ) ;
2013-03-03 01:03:33 +00:00
}
2006-03-20 17:12:09 +00:00
}
2015-05-09 17:38:58 +00:00
}
static void draw_secondary_weapon_info ( int weapon_num , const local_multires_gauge_graphic multires_gauge_graphic )
{
int x , y ;
int info_index ;
2013-03-03 01:03:33 +00:00
{
2006-03-20 17:12:09 +00:00
info_index = Secondary_weapon_to_weapon_info [ weapon_num ] ;
2010-01-28 00:04:29 +00:00
if ( PlayerCfg . CockpitMode [ 1 ] = = CM_STATUS_BAR )
2013-03-03 01:03:33 +00:00
{
2006-03-20 17:12:09 +00:00
draw_weapon_info_sub ( info_index ,
& gauge_boxes [ SB_SECONDARY_BOX ] ,
SB_SECONDARY_W_PIC_X , SB_SECONDARY_W_PIC_Y ,
SECONDARY_WEAPON_NAMES_SHORT ( weapon_num ) ,
2015-04-26 20:15:55 +00:00
SB_SECONDARY_W_TEXT_X , SB_SECONDARY_W_TEXT_Y , multires_gauge_graphic ) ;
2013-03-03 01:03:33 +00:00
x = SB_SECONDARY_AMMO_X ;
y = SB_SECONDARY_AMMO_Y ;
}
2006-03-20 17:12:09 +00:00
else
2013-03-03 01:03:33 +00:00
{
2006-03-20 17:12:09 +00:00
draw_weapon_info_sub ( info_index ,
& gauge_boxes [ COCKPIT_SECONDARY_BOX ] ,
SECONDARY_W_PIC_X , SECONDARY_W_PIC_Y ,
SECONDARY_WEAPON_NAMES_SHORT ( weapon_num ) ,
2015-04-26 20:15:55 +00:00
SECONDARY_W_TEXT_X , SECONDARY_W_TEXT_Y , multires_gauge_graphic ) ;
2013-03-03 01:03:33 +00:00
x = SECONDARY_AMMO_X ;
y = SECONDARY_AMMO_Y ;
2006-03-20 17:12:09 +00:00
}
2013-03-03 01:03:33 +00:00
if ( PlayerCfg . HudMode ! = 0 )
{
# if defined(DXX_BUILD_DESCENT_II)
2015-05-09 17:38:58 +00:00
if ( weapon_box_user [ 1 ] = = WBU_WEAPON )
2013-03-03 01:03:33 +00:00
# endif
2015-05-09 17:38:57 +00:00
hud_show_secondary_weapons_mode ( 1 , x , y ) ;
2006-03-20 17:12:09 +00:00
}
}
}
2015-05-09 17:38:58 +00:00
static void draw_weapon_info ( int weapon_type , int weapon_num , int laser_level , const local_multires_gauge_graphic multires_gauge_graphic )
{
if ( weapon_type = = 0 )
draw_primary_weapon_info ( weapon_num , laser_level , multires_gauge_graphic ) ;
else
draw_secondary_weapon_info ( weapon_num , multires_gauge_graphic ) ;
}
2014-10-17 01:57:30 +00:00
static void draw_ammo_info ( int x , int y , int ammo_count )
2006-03-20 17:12:09 +00:00
{
2008-04-13 00:28:36 +00:00
if ( ! PlayerCfg . HudMode )
2006-03-20 17:12:09 +00:00
{
gr_setcolor ( BM_XRGB ( 0 , 0 , 0 ) ) ;
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 20 , 0 , 0 ) , - 1 ) ;
gr_printf ( x , y , " %03d " , ammo_count ) ;
2006-03-20 17:12:09 +00:00
}
}
2015-04-26 20:15:55 +00:00
static void draw_secondary_ammo_info ( int ammo_count , const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
2010-01-28 00:04:29 +00:00
if ( PlayerCfg . CockpitMode [ 1 ] = = CM_STATUS_BAR )
2014-10-17 01:57:30 +00:00
draw_ammo_info ( SB_SECONDARY_AMMO_X , SB_SECONDARY_AMMO_Y , ammo_count ) ;
2006-03-20 17:12:09 +00:00
else
2014-10-17 01:57:30 +00:00
draw_ammo_info ( SECONDARY_AMMO_X , SECONDARY_AMMO_Y , ammo_count ) ;
2006-03-20 17:12:09 +00:00
}
2013-10-27 22:00:14 +00:00
static void draw_weapon_box ( int weapon_type , int weapon_num )
2006-03-20 17:12:09 +00:00
{
int laser_level_changed ;
2007-03-24 04:37:33 +00:00
gr_set_current_canvas ( NULL ) ;
2006-03-20 17:12:09 +00:00
gr_set_curfont ( GAME_FONT ) ;
2015-10-18 21:01:18 +00:00
laser_level_changed = ( weapon_type = = 0 & & weapon_num = = primary_weapon_index_t : : LASER_INDEX & & ( get_local_player ( ) . laser_level ! = old_laser_level ) ) ;
2006-03-20 17:12:09 +00:00
2008-04-13 00:28:36 +00:00
if ( ( weapon_num ! = old_weapon [ weapon_type ] | | laser_level_changed ) & & weapon_box_states [ weapon_type ] = = WS_SET & & ( old_weapon [ weapon_type ] ! = - 1 ) & & ! PlayerCfg . HudMode )
2006-03-20 17:12:09 +00:00
{
weapon_box_states [ weapon_type ] = WS_FADING_OUT ;
weapon_box_fade_values [ weapon_type ] = i2f ( GR_FADE_LEVELS - 1 ) ;
}
2010-06-18 07:31:06 +00:00
2015-04-26 20:15:55 +00:00
const local_multires_gauge_graphic multires_gauge_graphic { } ;
2008-11-21 00:12:41 +00:00
if ( old_weapon [ weapon_type ] = = - 1 )
{
2015-07-25 23:10:46 +00:00
draw_weapon_info ( weapon_type , weapon_num , get_local_player ( ) . laser_level , multires_gauge_graphic ) ;
2008-11-21 00:12:41 +00:00
old_weapon [ weapon_type ] = weapon_num ;
weapon_box_states [ weapon_type ] = WS_SET ;
}
2010-06-18 07:31:06 +00:00
2006-03-20 17:12:09 +00:00
if ( weapon_box_states [ weapon_type ] = = WS_FADING_OUT ) {
2015-04-26 20:15:55 +00:00
draw_weapon_info ( weapon_type , old_weapon [ weapon_type ] , old_laser_level , multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
weapon_box_fade_values [ weapon_type ] - = FrameTime * FADE_SCALE ;
if ( weapon_box_fade_values [ weapon_type ] < = 0 ) {
weapon_box_states [ weapon_type ] = WS_FADING_IN ;
2007-03-21 12:35:35 +00:00
old_weapon [ weapon_type ] = weapon_num ;
2015-07-25 23:10:46 +00:00
old_laser_level = get_local_player ( ) . laser_level ;
2006-03-20 17:12:09 +00:00
weapon_box_fade_values [ weapon_type ] = 0 ;
}
}
else if ( weapon_box_states [ weapon_type ] = = WS_FADING_IN ) {
2007-03-21 12:35:35 +00:00
if ( weapon_num ! = old_weapon [ weapon_type ] ) {
2006-03-20 17:12:09 +00:00
weapon_box_states [ weapon_type ] = WS_FADING_OUT ;
}
else {
2015-07-25 23:10:46 +00:00
draw_weapon_info ( weapon_type , weapon_num , get_local_player ( ) . laser_level , multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
weapon_box_fade_values [ weapon_type ] + = FrameTime * FADE_SCALE ;
if ( weapon_box_fade_values [ weapon_type ] > = i2f ( GR_FADE_LEVELS - 1 ) ) {
weapon_box_states [ weapon_type ] = WS_SET ;
2007-03-21 12:35:35 +00:00
old_weapon [ weapon_type ] = - 1 ;
2006-03-20 17:12:09 +00:00
}
}
} else
2006-09-29 00:57:57 +00:00
{
2015-07-25 23:10:46 +00:00
draw_weapon_info ( weapon_type , weapon_num , get_local_player ( ) . laser_level , multires_gauge_graphic ) ;
2007-03-21 12:35:35 +00:00
old_weapon [ weapon_type ] = weapon_num ;
2015-07-25 23:10:46 +00:00
old_laser_level = get_local_player ( ) . laser_level ;
2006-09-29 00:57:57 +00:00
}
2006-03-20 17:12:09 +00:00
2008-11-21 00:12:41 +00:00
if ( weapon_box_states [ weapon_type ] ! = WS_SET ) //fade gauge
{
2006-03-20 17:12:09 +00:00
int fade_value = f2i ( weapon_box_fade_values [ weapon_type ] ) ;
2015-04-26 20:15:53 +00:00
const local_multires_gauge_graphic multires_gauge_graphic { } ;
2010-01-28 00:04:29 +00:00
int boxofs = ( PlayerCfg . CockpitMode [ 1 ] = = CM_STATUS_BAR ) ? SB_PRIMARY_BOX : COCKPIT_PRIMARY_BOX ;
2010-06-18 07:31:06 +00:00
2011-02-23 16:46:39 +00:00
gr_settransblend ( fade_value , GR_BLEND_NORMAL ) ;
2007-06-10 16:21:53 +00:00
gr_rect ( HUD_SCALE_X ( gauge_boxes [ boxofs + weapon_type ] . left ) , HUD_SCALE_Y ( gauge_boxes [ boxofs + weapon_type ] . top ) , HUD_SCALE_X ( gauge_boxes [ boxofs + weapon_type ] . right ) , HUD_SCALE_Y ( gauge_boxes [ boxofs + weapon_type ] . bot ) ) ;
2011-02-23 16:46:39 +00:00
gr_settransblend ( GR_FADE_OFF , GR_BLEND_NORMAL ) ;
2006-03-20 17:12:09 +00:00
}
2007-03-21 11:32:33 +00:00
gr_set_current_canvas ( NULL ) ;
2006-03-20 17:12:09 +00:00
}
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2015-04-02 02:36:52 +00:00
static array < fix , 2 > static_time ;
2006-03-20 17:12:09 +00:00
2015-04-26 20:15:55 +00:00
static void draw_static ( int win , const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
vclip * vc = & Vclip [ VCLIP_MONITOR_STATIC ] ;
int framenum ;
2010-01-28 00:04:29 +00:00
int boxofs = ( PlayerCfg . CockpitMode [ 1 ] = = CM_STATUS_BAR ) ? SB_PRIMARY_BOX : COCKPIT_PRIMARY_BOX ;
2006-10-20 16:38:04 +00:00
# ifndef OGL
int x , y ;
# endif
2006-03-20 17:12:09 +00:00
static_time [ win ] + = FrameTime ;
if ( static_time [ win ] > = vc - > play_time ) {
weapon_box_user [ win ] = WBU_WEAPON ;
return ;
}
framenum = static_time [ win ] * vc - > num_frames / vc - > play_time ;
PIGGY_PAGE_IN ( vc - > frames [ framenum ] ) ;
2007-03-24 04:37:33 +00:00
gr_set_current_canvas ( NULL ) ;
2015-04-26 20:15:56 +00:00
auto & bmp = GameBitmaps [ vc - > frames [ framenum ] . index ] ;
auto & box = gauge_boxes [ boxofs + win ] ;
2006-10-20 16:38:04 +00:00
# ifndef OGL
2015-04-26 20:15:56 +00:00
for ( x = box . left ; x < box . right ; x + = bmp . bm_w )
for ( y = box . top ; y < box . bot ; y + = bmp . bm_h )
gr_bitmap ( x , y , bmp ) ;
2006-10-20 16:38:04 +00:00
# else
2015-04-26 20:15:53 +00:00
if ( multires_gauge_graphic . is_hires ( ) )
2006-10-20 16:38:04 +00:00
{
2015-04-26 20:15:56 +00:00
hud_bitblt ( HUD_SCALE_X ( box . left ) , HUD_SCALE_Y ( box . top ) , bmp , multires_gauge_graphic ) ;
hud_bitblt ( HUD_SCALE_X ( box . left ) , HUD_SCALE_Y ( box . bot - bmp . bm_h ) , bmp , multires_gauge_graphic ) ;
hud_bitblt ( HUD_SCALE_X ( box . right - bmp . bm_w ) , HUD_SCALE_Y ( box . top ) , bmp , multires_gauge_graphic ) ;
hud_bitblt ( HUD_SCALE_X ( box . right - bmp . bm_w ) , HUD_SCALE_Y ( box . bot - bmp . bm_h ) , bmp , multires_gauge_graphic ) ;
2006-09-29 00:57:57 +00:00
}
2006-03-20 17:12:09 +00:00
2006-10-20 16:38:04 +00:00
# endif
2007-03-21 11:32:33 +00:00
gr_set_current_canvas ( NULL ) ;
2006-03-20 17:12:09 +00:00
}
2013-03-03 01:03:33 +00:00
# endif
2006-03-20 17:12:09 +00:00
2015-04-26 20:15:53 +00:00
static void draw_weapon_box0 ( const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
if ( weapon_box_user [ 0 ] = = WBU_WEAPON )
# endif
{
2007-10-18 14:44:02 +00:00
draw_weapon_box ( 0 , Primary_weapon ) ;
2006-03-20 17:12:09 +00:00
if ( weapon_box_states [ 0 ] = = WS_SET ) {
2015-04-26 20:15:53 +00:00
unsigned nd_ammo ;
unsigned ammo_count ;
if ( weapon_index_uses_vulcan_ammo ( Primary_weapon ) )
2006-03-20 17:12:09 +00:00
{
2015-07-25 23:10:46 +00:00
nd_ammo = get_local_player ( ) . vulcan_ammo ;
ammo_count = f2i ( ( unsigned ) VULCAN_AMMO_SCALE * ( unsigned ) get_local_player ( ) . vulcan_ammo ) ;
2006-03-20 17:12:09 +00:00
}
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2015-10-18 21:01:18 +00:00
else if ( Primary_weapon = = primary_weapon_index_t : : OMEGA_INDEX )
2006-03-20 17:12:09 +00:00
{
2015-04-26 20:15:53 +00:00
nd_ammo = Omega_charge ;
ammo_count = Omega_charge * 100 / MAX_OMEGA_CHARGE ;
2006-03-20 17:12:09 +00:00
}
2013-03-03 01:03:33 +00:00
# endif
2015-04-26 20:15:53 +00:00
else
return ;
if ( Newdemo_state = = ND_STATE_RECORDING )
newdemo_record_primary_ammo ( nd_ammo ) ;
2015-04-26 20:15:53 +00:00
draw_primary_ammo_info ( ammo_count , multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
}
}
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2006-03-20 17:12:09 +00:00
else if ( weapon_box_user [ 0 ] = = WBU_STATIC )
2015-04-26 20:15:55 +00:00
draw_static ( 0 , multires_gauge_graphic ) ;
2015-04-26 20:15:53 +00:00
# endif
}
2006-03-20 17:12:09 +00:00
2015-04-26 20:15:55 +00:00
static void draw_weapon_box1 ( const local_multires_gauge_graphic multires_gauge_graphic )
2015-04-26 20:15:53 +00:00
{
# if defined(DXX_BUILD_DESCENT_II)
2013-03-03 01:03:33 +00:00
if ( weapon_box_user [ 1 ] = = WBU_WEAPON )
# endif
{
2007-10-18 14:44:02 +00:00
draw_weapon_box ( 1 , Secondary_weapon ) ;
2006-03-20 17:12:09 +00:00
if ( weapon_box_states [ 1 ] = = WS_SET )
{
2015-07-25 23:10:46 +00:00
const auto ammo = get_local_player ( ) . secondary_ammo [ Secondary_weapon ] ;
2013-03-03 01:03:33 +00:00
if ( Newdemo_state = = ND_STATE_RECORDING )
2015-04-26 20:15:53 +00:00
newdemo_record_secondary_ammo ( ammo ) ;
2015-04-26 20:15:55 +00:00
draw_secondary_ammo_info ( ammo , multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
}
}
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2006-03-20 17:12:09 +00:00
else if ( weapon_box_user [ 1 ] = = WBU_STATIC )
2015-04-26 20:15:55 +00:00
draw_static ( 1 , multires_gauge_graphic ) ;
2013-03-03 01:03:33 +00:00
# endif
2006-03-20 17:12:09 +00:00
}
2015-04-26 20:15:53 +00:00
static void draw_weapon_boxes ( const local_multires_gauge_graphic multires_gauge_graphic )
2015-04-26 20:15:53 +00:00
{
2015-04-26 20:15:53 +00:00
draw_weapon_box0 ( multires_gauge_graphic ) ;
2015-04-26 20:15:55 +00:00
draw_weapon_box1 ( multires_gauge_graphic ) ;
2015-04-26 20:15:53 +00:00
}
2006-03-20 17:12:09 +00:00
2015-04-26 20:15:55 +00:00
static void sb_draw_energy_bar ( int energy , const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
2013-07-13 23:02:12 +00:00
int erase_height , i ;
2015-09-29 02:41:22 +00:00
int ew ;
2006-03-20 17:12:09 +00:00
2015-04-26 20:15:53 +00:00
hud_gauge_bitblt ( SB_ENERGY_GAUGE_X , SB_ENERGY_GAUGE_Y , SB_GAUGE_ENERGY , multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
2007-10-05 23:47:16 +00:00
erase_height = HUD_SCALE_Y ( ( 100 - energy ) * SB_ENERGY_GAUGE_H / 100 ) ;
gr_setcolor ( 0 ) ;
2008-06-04 19:30:43 +00:00
for ( i = 0 ; i < erase_height ; i + + )
gr_uline ( i2f ( HUD_SCALE_X ( SB_ENERGY_GAUGE_X - 1 ) ) , i2f ( HUD_SCALE_Y ( SB_ENERGY_GAUGE_Y ) + i ) , i2f ( HUD_SCALE_X ( SB_ENERGY_GAUGE_X + ( SB_ENERGY_GAUGE_W ) ) ) , i2f ( HUD_SCALE_Y ( SB_ENERGY_GAUGE_Y ) + i ) ) ;
2010-06-18 07:31:06 +00:00
2006-03-20 17:12:09 +00:00
//draw numbers
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 25 , 18 , 6 ) , - 1 ) ;
2015-10-09 02:46:11 +00:00
gr_get_string_size ( get_gauge_width_string ( energy ) , & ew , nullptr , nullptr ) ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
unsigned y = SB_ENERGY_NUM_Y ;
# elif defined(DXX_BUILD_DESCENT_II)
unsigned y = SB_ENERGY_GAUGE_Y + SB_ENERGY_GAUGE_H - GAME_FONT - > ft_h - ( GAME_FONT - > ft_h / 4 ) ;
# endif
2015-03-22 18:49:21 +00:00
gr_printf ( ( grd_curscreen - > get_screen_width ( ) / 3 ) - ( ew / 2 ) , HUD_SCALE_Y ( y ) , " %d " , energy ) ;
2006-03-20 17:12:09 +00:00
2007-03-21 11:32:33 +00:00
gr_set_current_canvas ( NULL ) ;
2006-03-20 17:12:09 +00:00
}
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2015-04-26 20:15:55 +00:00
static void sb_draw_afterburner ( const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
2015-09-29 02:41:22 +00:00
int erase_height , i ;
2015-04-02 02:36:52 +00:00
auto & ab_str = " AB " ;
2006-03-20 17:12:09 +00:00
2015-04-26 20:15:53 +00:00
hud_gauge_bitblt ( SB_AFTERBURNER_GAUGE_X , SB_AFTERBURNER_GAUGE_Y , SB_GAUGE_AFTERBURNER , multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
2007-10-05 23:47:16 +00:00
erase_height = HUD_SCALE_Y ( fixmul ( ( f1_0 - Afterburner_charge ) , SB_AFTERBURNER_GAUGE_H - 1 ) ) ;
gr_setcolor ( 0 ) ;
2008-06-04 19:30:43 +00:00
for ( i = 0 ; i < erase_height ; i + + )
gr_uline ( i2f ( HUD_SCALE_X ( SB_AFTERBURNER_GAUGE_X - 1 ) ) , i2f ( HUD_SCALE_Y ( SB_AFTERBURNER_GAUGE_Y ) + i ) , i2f ( HUD_SCALE_X ( SB_AFTERBURNER_GAUGE_X + ( SB_AFTERBURNER_GAUGE_W ) ) ) , i2f ( HUD_SCALE_Y ( SB_AFTERBURNER_GAUGE_Y ) + i ) ) ;
2006-03-20 17:12:09 +00:00
//draw legend
2015-07-25 23:10:46 +00:00
if ( get_local_player ( ) . flags & PLAYER_FLAGS_AFTERBURNER )
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 45 , 0 , 0 ) , - 1 ) ;
2010-06-18 07:31:06 +00:00
else
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 12 , 12 , 12 ) , - 1 ) ;
2006-03-20 17:12:09 +00:00
2015-09-29 02:41:22 +00:00
int w , h ;
gr_get_string_size ( ab_str , & w , & h , nullptr ) ;
2015-09-29 02:41:22 +00:00
gr_string ( HUD_SCALE_X ( SB_AFTERBURNER_GAUGE_X + ( SB_AFTERBURNER_GAUGE_W + 1 ) / 2 ) - ( w / 2 ) , HUD_SCALE_Y ( SB_AFTERBURNER_GAUGE_Y + ( SB_AFTERBURNER_GAUGE_H - GAME_FONT - > ft_h - ( GAME_FONT - > ft_h / 4 ) ) ) , " AB " , w , h ) ;
2007-03-21 11:32:33 +00:00
gr_set_current_canvas ( NULL ) ;
2006-03-20 17:12:09 +00:00
}
2013-03-03 01:03:33 +00:00
# endif
2006-03-20 17:12:09 +00:00
2015-04-26 20:15:55 +00:00
static void sb_draw_shield_num ( int shield , const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
//draw numbers
2015-09-29 02:41:22 +00:00
int sw ;
2006-03-20 17:12:09 +00:00
gr_set_curfont ( GAME_FONT ) ;
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 14 , 14 , 23 ) , - 1 ) ;
2006-03-20 17:12:09 +00:00
2015-10-09 02:46:11 +00:00
gr_get_string_size ( get_gauge_width_string ( shield ) , & sw , nullptr , nullptr ) ;
2015-03-22 18:49:21 +00:00
gr_printf ( ( grd_curscreen - > get_screen_width ( ) / 2.266 ) - ( sw / 2 ) , HUD_SCALE_Y ( SB_SHIELD_NUM_Y ) , " %d " , shield ) ;
2006-03-20 17:12:09 +00:00
}
2015-04-26 20:15:55 +00:00
static void sb_draw_shield_bar ( int shield , const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
int bm_num = shield > = 100 ? 9 : ( shield / 10 ) ;
2007-03-21 11:32:33 +00:00
gr_set_current_canvas ( NULL ) ;
2015-04-26 20:15:53 +00:00
hud_gauge_bitblt ( SB_SHIELD_GAUGE_X , SB_SHIELD_GAUGE_Y , GAUGE_SHIELDS + 9 - bm_num , multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
}
2015-10-30 02:52:54 +00:00
void draw_statusbar_keys_state : : draw_all_keys ( const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
2015-10-30 02:52:54 +00:00
draw_one_key ( SB_GAUGE_KEYS_X , SB_GAUGE_BLUE_KEY_Y , SB_GAUGE_BLUE_KEY , multires_gauge_graphic , PLAYER_FLAGS_BLUE_KEY ) ;
draw_one_key ( SB_GAUGE_KEYS_X , SB_GAUGE_GOLD_KEY_Y , SB_GAUGE_GOLD_KEY , multires_gauge_graphic , PLAYER_FLAGS_GOLD_KEY ) ;
draw_one_key ( SB_GAUGE_KEYS_X , SB_GAUGE_RED_KEY_Y , SB_GAUGE_RED_KEY , multires_gauge_graphic , PLAYER_FLAGS_RED_KEY ) ;
2006-03-20 17:12:09 +00:00
}
// Draws invulnerable ship, or maybe the flashing ship, depending on invulnerability time left.
2015-04-26 20:15:54 +00:00
static void draw_invulnerable_ship ( const local_multires_gauge_graphic multires_gauge_graphic )
2006-03-20 17:12:09 +00:00
{
2007-03-21 11:32:33 +00:00
gr_set_current_canvas ( NULL ) ;
2006-03-20 17:12:09 +00:00
2015-04-26 20:15:52 +00:00
const auto cmmode = PlayerCfg . CockpitMode [ 1 ] ;
2015-07-25 23:10:46 +00:00
if ( get_local_player ( ) . invulnerable_time + INVULNERABLE_TIME_MAX - GameTime64 > F1_0 * 4 | | GameTime64 & 0x8000 )
2007-10-28 20:14:25 +00:00
{
2015-04-26 20:15:52 +00:00
static fix time ;
auto ltime = time + FrameTime ;
const auto old_invulnerable_frame = invulnerable_frame ;
while ( ltime > INV_FRAME_TIME )
{
ltime - = INV_FRAME_TIME ;
2006-03-20 17:12:09 +00:00
if ( + + invulnerable_frame = = N_INVULNERABLE_FRAMES )
invulnerable_frame = 0 ;
}
2015-04-26 20:15:52 +00:00
time = ltime ;
unsigned x , y ;
if ( cmmode = = CM_STATUS_BAR )
{
x = SB_SHIELD_GAUGE_X ;
y = SB_SHIELD_GAUGE_Y ;
}
else
{
x = SHIELD_GAUGE_X ;
y = SHIELD_GAUGE_Y ;
}
2015-04-26 20:15:53 +00:00
hud_gauge_bitblt ( x , y , GAUGE_INVULNERABLE + old_invulnerable_frame , multires_gauge_graphic ) ;
2015-09-27 08:51:37 +00:00
// Show Invulnerability Timer if enabled
if ( PlayerCfg . CloakInvulTimer )
{
2015-10-03 17:17:49 +00:00
show_cockpit_cloak_invul_timer ( get_local_player ( ) . invulnerable_time + INVULNERABLE_TIME_MAX - GameTime64 , HUD_SCALE_Y ( y ) ) ;
2015-09-27 08:51:37 +00:00
}
2015-04-26 20:15:52 +00:00
} else if ( cmmode = = CM_STATUS_BAR )
2015-10-30 02:52:55 +00:00
sb_draw_shield_bar ( f2ir ( get_local_player_shields ( ) ) , multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
else
2015-10-30 02:52:55 +00:00
draw_shield_bar ( f2ir ( get_local_player_shields ( ) ) , multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
}
2015-03-09 03:33:07 +00:00
const rgb_array_t player_rgb_normal { {
2006-03-20 17:12:09 +00:00
{ 15 , 15 , 23 } ,
{ 27 , 0 , 0 } ,
{ 0 , 23 , 0 } ,
{ 30 , 11 , 31 } ,
{ 31 , 16 , 0 } ,
{ 24 , 17 , 6 } ,
{ 14 , 21 , 12 } ,
{ 29 , 29 , 0 } ,
2015-03-09 03:33:07 +00:00
} } ;
2006-03-20 17:12:09 +00:00
2013-12-22 22:03:07 +00:00
struct xy {
2006-03-20 17:12:09 +00:00
sbyte x , y ;
2013-12-22 22:03:07 +00:00
} ;
2006-03-20 17:12:09 +00:00
//offsets for reticle parts: high-big high-sml low-big low-sml
2015-04-02 02:36:52 +00:00
const array < xy , 4 > cross_offsets { {
{ - 8 , - 5 } ,
{ - 4 , - 2 } ,
{ - 4 , - 2 } ,
{ - 2 , - 1 }
} } ,
primary_offsets { {
{ - 30 , 14 } ,
{ - 16 , 6 } ,
{ - 15 , 6 } ,
{ - 8 , 2 }
} } ,
secondary_offsets { {
{ - 24 , 2 } ,
{ - 12 , 0 } ,
{ - 12 , 1 } ,
{ - 6 , - 2 }
} } ;
2006-03-20 17:12:09 +00:00
//draw the reticle
2011-02-10 19:53:23 +00:00
void show_reticle ( int reticle_type , int secondary_display )
2006-03-20 17:12:09 +00:00
{
2011-01-10 15:12:04 +00:00
int x , y , size ;
2015-04-19 04:18:50 +00:00
int laser_ready , missile_ready ;
2006-03-20 17:12:09 +00:00
int cross_bm_num , primary_bm_num , secondary_bm_num ;
2015-04-26 20:15:53 +00:00
int ofs , gauge_index ;
2006-03-20 17:12:09 +00:00
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2009-02-02 08:49:58 +00:00
if ( Newdemo_state = = ND_STATE_PLAYBACK & & Viewer - > type ! = OBJ_PLAYER )
2006-03-20 17:12:09 +00:00
return ;
2013-03-03 01:03:33 +00:00
# endif
2006-03-20 17:12:09 +00:00
2008-02-24 14:41:27 +00:00
x = grd_curcanv - > cv_bitmap . bm_w / 2 ;
y = grd_curcanv - > cv_bitmap . bm_h / 2 ;
2011-01-10 16:48:20 +00:00
size = ( grd_curcanv - > cv_bitmap . bm_h / ( 32 - ( PlayerCfg . ReticleSize * 4 ) ) ) ;
2006-03-20 17:12:09 +00:00
laser_ready = allowed_to_fire_laser ( ) ;
missile_ready = allowed_to_fire_missile ( ) ;
2015-04-19 04:18:50 +00:00
primary_bm_num = ( laser_ready & & player_has_primary_weapon ( Primary_weapon ) . has_all ( ) ) ;
secondary_bm_num = ( missile_ready & & player_has_secondary_weapon ( Secondary_weapon ) . has_all ( ) ) ;
2006-03-20 17:12:09 +00:00
2015-10-18 21:01:18 +00:00
if ( primary_bm_num & & Primary_weapon = = primary_weapon_index_t : : LASER_INDEX & & ( get_local_player ( ) . flags & PLAYER_FLAGS_QUAD_LASERS ) )
2006-03-20 17:12:09 +00:00
primary_bm_num + + ;
if ( Secondary_weapon_to_gun_num [ Secondary_weapon ] = = 7 )
secondary_bm_num + = 3 ; //now value is 0,1 or 3,4
else if ( secondary_bm_num & & ! ( Missile_gun & 1 ) )
secondary_bm_num + + ;
cross_bm_num = ( ( primary_bm_num > 0 ) | | ( secondary_bm_num > 0 ) ) ;
Assert ( primary_bm_num < = 2 ) ;
Assert ( secondary_bm_num < = 4 ) ;
Assert ( cross_bm_num < = 1 ) ;
2008-11-09 14:31:30 +00:00
2011-01-10 15:12:04 +00:00
gr_setcolor ( BM_XRGB ( PlayerCfg . ReticleRGBA [ 0 ] , PlayerCfg . ReticleRGBA [ 1 ] , PlayerCfg . ReticleRGBA [ 2 ] ) ) ;
2011-02-23 16:46:39 +00:00
gr_settransblend ( PlayerCfg . ReticleRGBA [ 3 ] , GR_BLEND_NORMAL ) ;
2008-11-09 14:31:30 +00:00
2011-01-10 15:12:04 +00:00
switch ( reticle_type )
{
case RET_TYPE_CLASSIC :
{
2015-04-26 20:15:53 +00:00
const local_multires_gauge_graphic multires_gauge_graphic { } ;
2015-04-26 20:15:53 +00:00
const auto use_hires_reticle = multires_gauge_graphic . is_hires ( ) ;
2011-01-10 15:12:04 +00:00
ofs = ( use_hires_reticle ? 0 : 2 ) ;
gauge_index = RETICLE_CROSS + cross_bm_num ;
2015-04-26 20:15:56 +00:00
PAGE_IN_GAUGE ( gauge_index , multires_gauge_graphic ) ;
2015-04-26 20:15:56 +00:00
auto & cross = GameBitmaps [ GET_GAUGE_INDEX ( gauge_index ) ] ;
hud_bitblt_free ( x + HUD_SCALE_X_AR ( cross_offsets [ ofs ] . x ) , y + HUD_SCALE_Y_AR ( cross_offsets [ ofs ] . y ) , HUD_SCALE_X_AR ( cross . bm_w ) , HUD_SCALE_Y_AR ( cross . bm_h ) , cross ) ;
2011-01-10 15:12:04 +00:00
gauge_index = RETICLE_PRIMARY + primary_bm_num ;
2015-04-26 20:15:56 +00:00
PAGE_IN_GAUGE ( gauge_index , multires_gauge_graphic ) ;
2015-04-26 20:15:56 +00:00
auto & primary = GameBitmaps [ GET_GAUGE_INDEX ( gauge_index ) ] ;
hud_bitblt_free ( x + HUD_SCALE_X_AR ( primary_offsets [ ofs ] . x ) , y + HUD_SCALE_Y_AR ( primary_offsets [ ofs ] . y ) , HUD_SCALE_X_AR ( primary . bm_w ) , HUD_SCALE_Y_AR ( primary . bm_h ) , primary ) ;
2011-01-10 15:12:04 +00:00
gauge_index = RETICLE_SECONDARY + secondary_bm_num ;
2015-04-26 20:15:56 +00:00
PAGE_IN_GAUGE ( gauge_index , multires_gauge_graphic ) ;
2015-04-26 20:15:56 +00:00
auto & secondary = GameBitmaps [ GET_GAUGE_INDEX ( gauge_index ) ] ;
hud_bitblt_free ( x + HUD_SCALE_X_AR ( secondary_offsets [ ofs ] . x ) , y + HUD_SCALE_Y_AR ( secondary_offsets [ ofs ] . y ) , HUD_SCALE_X_AR ( secondary . bm_w ) , HUD_SCALE_Y_AR ( secondary . bm_h ) , secondary ) ;
2011-01-10 15:12:04 +00:00
break ;
}
case RET_TYPE_CLASSIC_REBOOT :
{
# ifdef OGL
ogl_draw_vertex_reticle ( cross_bm_num , primary_bm_num , secondary_bm_num , BM_XRGB ( PlayerCfg . ReticleRGBA [ 0 ] , PlayerCfg . ReticleRGBA [ 1 ] , PlayerCfg . ReticleRGBA [ 2 ] ) , PlayerCfg . ReticleRGBA [ 3 ] , PlayerCfg . ReticleSize ) ;
# endif
break ;
2010-06-18 07:31:06 +00:00
2011-01-10 15:12:04 +00:00
}
case RET_TYPE_X :
2011-02-10 19:53:23 +00:00
gr_uline ( i2f ( x - ( size / 2 ) ) , i2f ( y - ( size / 2 ) ) , i2f ( x - ( size / 5 ) ) , i2f ( y - ( size / 5 ) ) ) ; // top-left
gr_uline ( i2f ( x + ( size / 2 ) ) , i2f ( y - ( size / 2 ) ) , i2f ( x + ( size / 5 ) ) , i2f ( y - ( size / 5 ) ) ) ; // top-right
gr_uline ( i2f ( x - ( size / 2 ) ) , i2f ( y + ( size / 2 ) ) , i2f ( x - ( size / 5 ) ) , i2f ( y + ( size / 5 ) ) ) ; // bottom-left
gr_uline ( i2f ( x + ( size / 2 ) ) , i2f ( y + ( size / 2 ) ) , i2f ( x + ( size / 5 ) ) , i2f ( y + ( size / 5 ) ) ) ; // bottom-right
if ( secondary_display & & secondary_bm_num = = 1 )
gr_uline ( i2f ( x - ( size / 2 ) - ( size / 5 ) ) , i2f ( y - ( size / 2 ) ) , i2f ( x - ( size / 5 ) - ( size / 5 ) ) , i2f ( y - ( size / 5 ) ) ) ;
else if ( secondary_display & & secondary_bm_num = = 2 )
gr_uline ( i2f ( x + ( size / 2 ) + ( size / 5 ) ) , i2f ( y - ( size / 2 ) ) , i2f ( x + ( size / 5 ) + ( size / 5 ) ) , i2f ( y - ( size / 5 ) ) ) ;
else if ( secondary_display & & secondary_bm_num = = 4 )
gr_uline ( i2f ( x + ( size / 2 ) ) , i2f ( y + ( size / 2 ) + ( size / 5 ) ) , i2f ( x + ( size / 5 ) ) , i2f ( y + ( size / 5 ) + ( size / 5 ) ) ) ;
2011-01-10 15:12:04 +00:00
break ;
case RET_TYPE_DOT :
2011-02-10 19:53:23 +00:00
gr_disk ( i2f ( x ) , i2f ( y ) , i2f ( size / 5 ) ) ;
if ( secondary_display & & secondary_bm_num = = 1 )
gr_uline ( i2f ( x - ( size / 2 ) - ( size / 5 ) ) , i2f ( y - ( size / 2 ) ) , i2f ( x - ( size / 5 ) - ( size / 5 ) ) , i2f ( y - ( size / 5 ) ) ) ;
else if ( secondary_display & & secondary_bm_num = = 2 )
gr_uline ( i2f ( x + ( size / 2 ) + ( size / 5 ) ) , i2f ( y - ( size / 2 ) ) , i2f ( x + ( size / 5 ) + ( size / 5 ) ) , i2f ( y - ( size / 5 ) ) ) ;
else if ( secondary_display & & secondary_bm_num = = 4 )
gr_uline ( i2f ( x ) , i2f ( y + ( size / 2 ) + ( size / 5 ) ) , i2f ( x ) , i2f ( y + ( size / 5 ) + ( size / 5 ) ) ) ;
2011-01-10 15:12:04 +00:00
break ;
case RET_TYPE_CIRCLE :
gr_ucircle ( i2f ( x ) , i2f ( y ) , i2f ( size / 4 ) ) ;
2011-02-10 19:53:23 +00:00
if ( secondary_display & & secondary_bm_num = = 1 )
gr_uline ( i2f ( x - ( size / 2 ) - ( size / 5 ) ) , i2f ( y - ( size / 2 ) ) , i2f ( x - ( size / 5 ) - ( size / 5 ) ) , i2f ( y - ( size / 5 ) ) ) ;
else if ( secondary_display & & secondary_bm_num = = 2 )
gr_uline ( i2f ( x + ( size / 2 ) + ( size / 5 ) ) , i2f ( y - ( size / 2 ) ) , i2f ( x + ( size / 5 ) + ( size / 5 ) ) , i2f ( y - ( size / 5 ) ) ) ;
else if ( secondary_display & & secondary_bm_num = = 4 )
gr_uline ( i2f ( x ) , i2f ( y + ( size / 2 ) + ( size / 5 ) ) , i2f ( x ) , i2f ( y + ( size / 5 ) + ( size / 5 ) ) ) ;
2011-01-10 15:12:04 +00:00
break ;
case RET_TYPE_CROSS_V1 :
2011-02-10 19:53:23 +00:00
gr_uline ( i2f ( x ) , i2f ( y - ( size / 2 ) ) , i2f ( x ) , i2f ( y + ( size / 2 ) + 1 ) ) ; // horiz
gr_uline ( i2f ( x - ( size / 2 ) ) , i2f ( y ) , i2f ( x + ( size / 2 ) + 1 ) , i2f ( y ) ) ; // vert
if ( secondary_display & & secondary_bm_num = = 1 )
gr_uline ( i2f ( x - ( size / 2 ) ) , i2f ( y - ( size / 2 ) ) , i2f ( x - ( size / 5 ) ) , i2f ( y - ( size / 5 ) ) ) ;
else if ( secondary_display & & secondary_bm_num = = 2 )
gr_uline ( i2f ( x + ( size / 2 ) ) , i2f ( y - ( size / 2 ) ) , i2f ( x + ( size / 5 ) ) , i2f ( y - ( size / 5 ) ) ) ;
else if ( secondary_display & & secondary_bm_num = = 4 )
gr_uline ( i2f ( x - ( size / 2 ) ) , i2f ( y + ( size / 2 ) ) , i2f ( x - ( size / 5 ) ) , i2f ( y + ( size / 5 ) ) ) ;
2011-01-10 15:12:04 +00:00
break ;
case RET_TYPE_CROSS_V2 :
2011-02-10 19:53:23 +00:00
gr_uline ( i2f ( x ) , i2f ( y - ( size / 2 ) ) , i2f ( x ) , i2f ( y - ( size / 6 ) ) ) ; // vert-top
gr_uline ( i2f ( x ) , i2f ( y + ( size / 2 ) ) , i2f ( x ) , i2f ( y + ( size / 6 ) ) ) ; // vert-bottom
gr_uline ( i2f ( x - ( size / 2 ) ) , i2f ( y ) , i2f ( x - ( size / 6 ) ) , i2f ( y ) ) ; // horiz-left
gr_uline ( i2f ( x + ( size / 2 ) ) , i2f ( y ) , i2f ( x + ( size / 6 ) ) , i2f ( y ) ) ; // horiz-right
if ( secondary_display & & secondary_bm_num = = 1 )
gr_uline ( i2f ( x - ( size / 2 ) ) , i2f ( y - ( size / 2 ) ) , i2f ( x - ( size / 5 ) ) , i2f ( y - ( size / 5 ) ) ) ;
else if ( secondary_display & & secondary_bm_num = = 2 )
gr_uline ( i2f ( x + ( size / 2 ) ) , i2f ( y - ( size / 2 ) ) , i2f ( x + ( size / 5 ) ) , i2f ( y - ( size / 5 ) ) ) ;
else if ( secondary_display & & secondary_bm_num = = 4 )
gr_uline ( i2f ( x - ( size / 2 ) ) , i2f ( y + ( size / 2 ) ) , i2f ( x - ( size / 5 ) ) , i2f ( y + ( size / 5 ) ) ) ;
2011-01-10 15:12:04 +00:00
break ;
case RET_TYPE_ANGLE :
2011-02-10 19:53:23 +00:00
gr_uline ( i2f ( x ) , i2f ( y ) , i2f ( x ) , i2f ( y + ( size / 2 ) ) ) ; // vert
gr_uline ( i2f ( x ) , i2f ( y ) , i2f ( x + ( size / 2 ) ) , i2f ( y ) ) ; // horiz
if ( secondary_display & & secondary_bm_num = = 1 )
gr_uline ( i2f ( x - ( size / 2 ) ) , i2f ( y - ( size / 2 ) ) , i2f ( x - ( size / 5 ) ) , i2f ( y - ( size / 5 ) ) ) ;
else if ( secondary_display & & secondary_bm_num = = 2 )
gr_uline ( i2f ( x + ( size / 2 ) ) , i2f ( y - ( size / 2 ) ) , i2f ( x + ( size / 5 ) ) , i2f ( y - ( size / 5 ) ) ) ;
else if ( secondary_display & & secondary_bm_num = = 4 )
gr_uline ( i2f ( x - ( size / 2 ) ) , i2f ( y + ( size / 2 ) ) , i2f ( x - ( size / 5 ) ) , i2f ( y + ( size / 5 ) ) ) ;
2011-01-10 15:12:04 +00:00
break ;
case RET_TYPE_NONE :
break ;
default :
break ;
2006-03-20 17:12:09 +00:00
}
2011-02-23 16:46:39 +00:00
gr_settransblend ( GR_FADE_OFF , GR_BLEND_NORMAL ) ;
2006-03-20 17:12:09 +00:00
}
2011-02-10 13:09:10 +00:00
void show_mousefs_indicator ( int mx , int my , int mz , int x , int y , int size )
2011-01-04 10:43:37 +00:00
{
2011-02-10 13:09:10 +00:00
int axscale = ( MOUSEFS_DELTA_RANGE * 2 ) / size , xaxpos = x + ( mx / axscale ) , yaxpos = y + ( my / axscale ) , zaxpos = y + ( mz / axscale ) ;
2011-01-04 10:43:37 +00:00
2011-01-10 15:12:04 +00:00
gr_setcolor ( BM_XRGB ( PlayerCfg . ReticleRGBA [ 0 ] , PlayerCfg . ReticleRGBA [ 1 ] , PlayerCfg . ReticleRGBA [ 2 ] ) ) ;
2011-02-23 16:46:39 +00:00
gr_settransblend ( PlayerCfg . ReticleRGBA [ 3 ] , GR_BLEND_NORMAL ) ;
2011-01-10 15:12:04 +00:00
gr_uline ( i2f ( xaxpos ) , i2f ( y - ( size / 2 ) ) , i2f ( xaxpos ) , i2f ( y - ( size / 4 ) ) ) ;
gr_uline ( i2f ( xaxpos ) , i2f ( y + ( size / 2 ) ) , i2f ( xaxpos ) , i2f ( y + ( size / 4 ) ) ) ;
gr_uline ( i2f ( x - ( size / 2 ) ) , i2f ( yaxpos ) , i2f ( x - ( size / 4 ) ) , i2f ( yaxpos ) ) ;
gr_uline ( i2f ( x + ( size / 2 ) ) , i2f ( yaxpos ) , i2f ( x + ( size / 4 ) ) , i2f ( yaxpos ) ) ;
2015-04-26 20:15:53 +00:00
const local_multires_gauge_graphic multires_gauge_graphic { } ;
2011-01-06 13:56:26 +00:00
gr_uline ( i2f ( x + ( size / 2 ) + HUD_SCALE_X_AR ( 2 ) ) , i2f ( y ) , i2f ( x + ( size / 2 ) + HUD_SCALE_X_AR ( 2 ) ) , i2f ( zaxpos ) ) ;
2011-02-23 16:46:39 +00:00
gr_settransblend ( GR_FADE_OFF , GR_BLEND_NORMAL ) ;
2011-01-04 10:43:37 +00:00
}
2013-10-27 22:00:14 +00:00
static void hud_show_kill_list ( )
2006-03-20 17:12:09 +00:00
{
2014-09-21 22:10:12 +00:00
playernum_t n_players ;
playernum_array_t player_list ;
2008-02-24 14:41:27 +00:00
int n_left , i , x0 , x1 , y , save_y ;
2006-03-20 17:12:09 +00:00
if ( Show_kill_list_timer > 0 )
{
Show_kill_list_timer - = FrameTime ;
if ( Show_kill_list_timer < 0 )
Show_kill_list = 0 ;
}
2010-06-18 07:31:06 +00:00
2006-03-20 17:12:09 +00:00
gr_set_curfont ( GAME_FONT ) ;
n_players = multi_get_kill_list ( player_list ) ;
if ( Show_kill_list = = 3 )
n_players = 2 ;
if ( n_players < = 4 )
n_left = n_players ;
else
n_left = ( n_players + 1 ) / 2 ;
2015-06-13 22:42:20 +00:00
const auto & & fspacx = FSPACX ( ) ;
2015-06-13 22:42:20 +00:00
const auto & & fspacx43 = fspacx ( 43 ) ;
x1 = fspacx43 ;
2006-03-20 17:12:09 +00:00
if ( Game_mode & GM_MULTI_COOP )
2015-06-13 22:42:20 +00:00
x1 = fspacx ( 31 ) ;
2006-03-20 17:12:09 +00:00
2015-06-13 22:42:22 +00:00
const auto & & line_spacing = LINE_SPACING ;
save_y = y = grd_curcanv - > cv_bitmap . bm_h - n_left * line_spacing ;
2006-03-20 17:12:09 +00:00
2010-01-28 00:04:29 +00:00
if ( PlayerCfg . CockpitMode [ 1 ] = = CM_FULL_COCKPIT ) {
2015-06-13 22:42:20 +00:00
save_y = y - = fspacx ( 6 ) ;
2006-03-20 17:12:09 +00:00
if ( Game_mode & GM_MULTI_COOP )
2015-06-13 22:42:20 +00:00
x1 = fspacx ( 33 ) ;
2006-03-20 17:12:09 +00:00
else
2015-06-13 22:42:20 +00:00
x1 = fspacx43 ;
2006-03-20 17:12:09 +00:00
}
2015-06-13 22:42:20 +00:00
const auto bm_w = grd_curcanv - > cv_bitmap . bm_w ;
const auto & & bmw_x0_cockpit = bm_w - ( PlayerCfg . CockpitMode [ 1 ] = = CM_FULL_COCKPIT ? fspacx ( 53 ) : fspacx ( 60 ) ) ;
// Right edge of name, change this for width problems
const auto & & bmw_x1_multi = bm_w - ( ( Game_mode & GM_MULTI_COOP ) ? fspacx ( 27 ) : fspacx ( 15 ) ) ;
const auto & & fspacx1 = fspacx ( 1 ) ;
const auto & & fspacx2 = fspacx ( 2 ) ;
const auto & & fspacx18 = fspacx ( 18 ) ;
x0 = fspacx1 ;
2006-03-20 17:12:09 +00:00
for ( i = 0 ; i < n_players ; i + + ) {
2014-09-21 22:10:12 +00:00
playernum_t player_num ;
2014-07-05 16:48:12 +00:00
callsign_t name ;
2006-03-20 17:12:09 +00:00
if ( i > = n_left ) {
2015-06-13 22:42:20 +00:00
x0 = bmw_x0_cockpit ;
x1 = bmw_x1_multi ;
2006-03-20 17:12:09 +00:00
if ( i = = n_left )
y = save_y ;
2008-02-24 14:41:27 +00:00
if ( Netgame . KillGoal | | Netgame . PlayTimeAllowed )
2015-06-13 22:42:20 +00:00
x1 - = fspacx18 ;
2008-02-24 14:41:27 +00:00
}
else if ( Netgame . KillGoal | | Netgame . PlayTimeAllowed )
{
2015-06-13 22:42:20 +00:00
x1 = fspacx43 ;
x1 - = fspacx18 ;
2006-03-20 17:12:09 +00:00
}
if ( Show_kill_list = = 3 )
player_num = i ;
else
player_num = player_list [ i ] ;
2015-03-09 03:33:07 +00:00
color_t fontcolor ;
2006-03-20 17:12:09 +00:00
if ( Show_kill_list = = 1 | | Show_kill_list = = 2 )
{
2009-11-24 09:48:53 +00:00
if ( Players [ player_num ] . connected ! = CONNECT_PLAYING )
2015-03-09 03:33:07 +00:00
fontcolor = BM_XRGB ( 12 , 12 , 12 ) ;
2006-03-20 17:12:09 +00:00
else {
2015-03-09 03:33:07 +00:00
auto & color = player_rgb [ get_player_or_team_color ( player_num ) ] ;
fontcolor = BM_XRGB ( color . r , color . g , color . b ) ;
2006-03-20 17:12:09 +00:00
}
2008-02-24 14:41:27 +00:00
}
else
2006-03-20 17:12:09 +00:00
{
2015-03-09 03:33:07 +00:00
auto & color = player_rgb_normal [ player_num ] ;
2015-03-09 03:33:07 +00:00
fontcolor = BM_XRGB ( color . r , color . g , color . b ) ;
2006-03-20 17:12:09 +00:00
}
2015-03-09 03:33:07 +00:00
gr_set_fontcolor ( fontcolor , - 1 ) ;
2006-03-20 17:12:09 +00:00
if ( Show_kill_list = = 3 )
2014-07-05 16:48:12 +00:00
name = Netgame . team_name [ i ] ;
2011-01-19 11:22:01 +00:00
else if ( Game_mode & GM_BOUNTY & & player_num = = Bounty_target & & GameTime64 & 0x10000 )
2014-07-05 16:48:12 +00:00
{
name = " [TARGET] " ;
}
2006-03-20 17:12:09 +00:00
else
2014-07-05 16:48:12 +00:00
name = Players [ player_num ] . callsign ; // Note link to above if!!
2015-09-29 02:41:22 +00:00
int sw , sh ;
gr_get_string_size ( static_cast < const char * > ( name ) , & sw , & sh , nullptr ) ;
2015-06-13 22:42:20 +00:00
{
2015-06-13 22:42:20 +00:00
const auto b = x1 - x0 - fspacx2 ;
2015-06-13 22:42:20 +00:00
if ( sw > b )
for ( char * e = & name . buffer ( ) [ strlen ( name ) ] ; ; )
{
* - - e = 0 ;
2015-09-29 02:41:22 +00:00
gr_get_string_size ( name , & sw , nullptr , nullptr ) ;
2015-06-13 22:42:20 +00:00
if ( ! ( sw > b ) )
break ;
}
2006-03-20 17:12:09 +00:00
}
2015-09-29 02:41:22 +00:00
gr_string ( x0 , y , name , sw , sh ) ;
2006-03-20 17:12:09 +00:00
if ( Show_kill_list = = 2 )
2008-02-24 14:41:27 +00:00
{
if ( Players [ player_num ] . net_killed_total + Players [ player_num ] . net_kills_total = = 0 )
2013-01-03 16:23:24 +00:00
gr_string ( x1 , y , " NA " ) ;
2008-02-24 14:41:27 +00:00
else
2010-06-18 07:31:06 +00:00
gr_printf ( x1 , y , " %d%% " , ( int ) ( ( float ) ( ( float ) Players [ player_num ] . net_kills_total / ( ( float ) Players [ player_num ] . net_killed_total + ( float ) Players [ player_num ] . net_kills_total ) ) * 100.0 ) ) ;
2008-02-24 14:41:27 +00:00
}
2010-06-18 07:31:06 +00:00
else if ( Show_kill_list = = 3 )
2006-03-20 17:12:09 +00:00
gr_printf ( x1 , y , " %3d " , team_kills [ i ] ) ;
else if ( Game_mode & GM_MULTI_COOP )
gr_printf ( x1 , y , " %-6d " , Players [ player_num ] . score ) ;
2008-02-24 14:41:27 +00:00
else if ( Netgame . PlayTimeAllowed | | Netgame . KillGoal )
gr_printf ( x1 , y , " %3d(%d) " , Players [ player_num ] . net_kills_total , Players [ player_num ] . KillGoalCount ) ;
else
2006-03-20 17:12:09 +00:00
gr_printf ( x1 , y , " %3d " , Players [ player_num ] . net_kills_total ) ;
2015-06-13 22:42:22 +00:00
y + = line_spacing ;
2006-03-20 17:12:09 +00:00
}
}
//returns true if viewer can see object
2013-10-27 22:00:14 +00:00
static int see_object ( int objnum )
2006-03-20 17:12:09 +00:00
{
fvi_query fq ;
int hit_type ;
fvi_info hit_data ;
//see if we can see this player
fq . p0 = & Viewer - > pos ;
fq . p1 = & Objects [ objnum ] . pos ;
fq . rad = 0 ;
fq . thisobjnum = Viewer - Objects ;
2012-04-18 09:28:23 +00:00
fq . flags = FQ_TRANSWALL | FQ_CHECK_OBJS | FQ_GET_SEGLIST ;
2006-03-20 17:12:09 +00:00
fq . startseg = Viewer - > segnum ;
2015-02-05 03:03:51 +00:00
fq . ignore_obj_list . first = nullptr ;
2006-03-20 17:12:09 +00:00
2015-01-20 02:46:42 +00:00
hit_type = find_vector_intersection ( fq , hit_data ) ;
2006-03-20 17:12:09 +00:00
return ( hit_type = = HIT_OBJECT & & hit_data . hit_object = = objnum ) ;
}
//show names of teammates & players carrying flags
void show_HUD_names ( )
{
2014-09-21 22:10:12 +00:00
for ( playernum_t pnum = 0 ; pnum < N_players ; pnum + + )
2011-04-15 23:12:04 +00:00
{
if ( pnum = = Player_num | | Players [ pnum ] . connected ! = CONNECT_PLAYING )
continue ;
// ridiculusly complex to check if we want to show something... but this is readable at least.
2006-03-20 17:12:09 +00:00
2015-07-12 01:04:20 +00:00
objnum_t objnum ;
2006-03-20 17:12:09 +00:00
if ( Newdemo_state = = ND_STATE_PLAYBACK ) {
2011-04-15 23:12:04 +00:00
//if this is a demo, the objnum in the player struct is wrong, so we search the object list for the objnum
2006-03-20 17:12:09 +00:00
for ( objnum = 0 ; objnum < = Highest_object_index ; objnum + + )
2015-07-12 01:04:20 +00:00
{
const auto & & objp = vcobjptr ( objnum ) ;
if ( objp - > type = = OBJ_PLAYER & & get_player_id ( objp ) = = pnum )
2006-03-20 17:12:09 +00:00
break ;
2015-07-12 01:04:20 +00:00
}
2011-04-15 23:12:04 +00:00
if ( objnum > Highest_object_index ) //not in list, thus not visible
continue ; //..so don't show name
2006-03-20 17:12:09 +00:00
}
else
2011-01-19 01:19:17 +00:00
objnum = Players [ pnum ] . objnum ;
2006-03-20 17:12:09 +00:00
2015-10-30 02:52:55 +00:00
const auto & pl_flags = Players [ pnum ] . flags ;
const auto is_friend = ( Game_mode & GM_MULTI_COOP | | ( Game_mode & GM_TEAM & & get_team ( pnum ) = = get_team ( Player_num ) ) ) ;
const auto show_friend_name = Show_reticle_name ;
const auto is_cloaked = pl_flags & PLAYER_FLAGS_CLOAKED ;
const auto show_enemy_name = Show_reticle_name & & Netgame . ShowEnemyNames & & ! is_cloaked ;
const auto show_name = is_friend ? show_friend_name : show_enemy_name ;
const auto show_typing = is_friend | | ! is_cloaked ;
const auto is_bounty_target = ( Game_mode & GM_BOUNTY ) & & pnum = = Bounty_target ;
const auto show_indi = ( is_friend | | ! is_cloaked ) & &
# if defined(DXX_BUILD_DESCENT_I)
is_bounty_target ;
# elif defined(DXX_BUILD_DESCENT_II)
( is_bounty_target | | ( ( game_mode_capture_flag ( ) | | game_mode_hoard ( ) ) & & ( pl_flags & PLAYER_FLAGS_FLAG ) ) ) ;
# endif
2011-04-15 23:12:04 +00:00
if ( ( show_name | | show_typing | | show_indi ) & & see_object ( objnum ) )
{
2014-11-13 03:41:29 +00:00
auto player_point = g3_rotate_point ( Objects [ objnum ] . pos ) ;
2011-04-15 23:12:04 +00:00
if ( player_point . p3_codes = = 0 ) //on screen
{
2014-11-13 03:21:33 +00:00
g3_project_point ( player_point ) ;
2011-04-15 23:12:04 +00:00
if ( ! ( player_point . p3_flags & PF_OVERFLOW ) )
{
2011-04-11 15:47:16 +00:00
fix x , y , dx , dy ;
2011-04-15 23:12:04 +00:00
char s [ CALLSIGN_LEN + 10 ] ;
2015-09-29 02:41:22 +00:00
int x1 , y1 ;
2010-06-18 07:31:06 +00:00
2006-03-20 17:12:09 +00:00
x = player_point . p3_sx ;
y = player_point . p3_sy ;
2011-04-11 15:47:16 +00:00
dy = - fixmuldiv ( fixmul ( Objects [ objnum ] . size , Matrix_scale . y ) , i2f ( grd_curcanv - > cv_bitmap . bm_h ) / 2 , player_point . p3_z ) ;
dx = fixmul ( dy , grd_curscreen - > sc_aspect ) ;
2011-04-15 23:12:04 +00:00
/* Set the text to show */
2013-12-13 20:39:57 +00:00
const char * name = NULL ;
2015-10-30 02:52:55 +00:00
if ( is_bounty_target )
2013-12-13 20:39:57 +00:00
name = " Target " ;
2011-04-15 23:12:04 +00:00
else if ( show_name )
2014-07-05 16:48:12 +00:00
name = static_cast < const char * > ( Players [ pnum ] . callsign ) ;
2013-12-13 20:39:57 +00:00
const char * trailer = NULL ;
2013-12-13 22:48:42 +00:00
if ( show_typing )
2011-04-15 23:12:04 +00:00
{
2013-12-13 22:48:42 +00:00
if ( multi_sending_message [ pnum ] = = msgsend_typing )
trailer = " Typing " ;
else if ( multi_sending_message [ pnum ] = = msgsend_automap )
trailer = " Map " ;
2011-04-15 23:12:04 +00:00
}
2013-12-13 20:39:57 +00:00
int written = snprintf ( s , sizeof ( s ) , " %s%s%s " , name ? name : " " , name & & trailer ? " , " : " " , trailer ? trailer : " " ) ;
if ( written )
2011-04-15 23:12:04 +00:00
{
2015-09-29 02:41:22 +00:00
int w , h ;
gr_get_string_size ( s , & w , & h , nullptr ) ;
2015-03-09 03:33:07 +00:00
const auto color = get_player_or_team_color ( pnum ) ;
gr_set_fontcolor ( BM_XRGB ( player_rgb [ color ] . r , player_rgb [ color ] . g , player_rgb [ color ] . b ) , - 1 ) ;
2006-03-20 17:12:09 +00:00
x1 = f2i ( x ) - w / 2 ;
2011-04-11 15:47:16 +00:00
y1 = f2i ( y - dy ) + FSPACY ( 1 ) ;
2015-09-29 02:41:22 +00:00
gr_string ( x1 , y1 , s , w , h ) ;
2006-03-20 17:12:09 +00:00
}
2010-06-18 07:31:06 +00:00
2011-01-19 01:19:17 +00:00
/* Draw box on HUD */
2011-04-15 23:12:04 +00:00
if ( show_indi )
2011-01-19 01:19:17 +00:00
{
2011-04-11 15:47:16 +00:00
fix w , h ;
2010-06-18 07:31:06 +00:00
2006-03-20 17:12:09 +00:00
w = dx / 4 ;
h = dy / 4 ;
2010-06-18 07:31:06 +00:00
2015-10-30 02:52:55 +00:00
{
struct {
int r , g , b ;
} c { } ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2013-08-11 16:03:47 +00:00
if ( game_mode_capture_flag ( ) )
2015-10-30 02:52:55 +00:00
( ( get_team ( pnum ) = = TEAM_BLUE ) ? c . r : c . b ) = 31 ;
2013-08-11 16:03:47 +00:00
else if ( game_mode_hoard ( ) )
2006-03-20 17:12:09 +00:00
{
2015-10-30 02:52:55 +00:00
( ( Game_mode & GM_TEAM )
? ( ( get_team ( pnum ) = = TEAM_RED ) ? c . r : c . b )
: c . g
) = 31 ;
2006-03-20 17:12:09 +00:00
}
2015-10-30 02:52:55 +00:00
else
2013-03-03 01:03:33 +00:00
# endif
2015-10-30 02:52:55 +00:00
{
auto & color = player_rgb [ get_player_color ( pnum ) ] ;
c = { color . r , color . g , color . b } ;
}
gr_setcolor ( BM_XRGB ( c . r , c . g , c . b ) ) ;
} ;
2006-03-20 17:12:09 +00:00
gr_line ( x + dx - w , y - dy , x + dx , y - dy ) ;
gr_line ( x + dx , y - dy , x + dx , y - dy + h ) ;
gr_line ( x - dx , y - dy , x - dx + w , y - dy ) ;
gr_line ( x - dx , y - dy , x - dx , y - dy + h ) ;
gr_line ( x + dx - w , y + dy , x + dx , y + dy ) ;
gr_line ( x + dx , y + dy , x + dx , y + dy - h ) ;
gr_line ( x - dx , y + dy , x - dx + w , y + dy ) ;
gr_line ( x - dx , y + dy , x - dx , y + dy - h ) ;
}
}
}
}
}
}
//draw all the things on the HUD
void draw_hud ( )
{
2013-06-09 23:07:00 +00:00
if ( Newdemo_state = = ND_STATE_RECORDING )
{
2015-10-18 21:01:18 +00:00
if ( Primary_weapon = = primary_weapon_index_t : : VULCAN_INDEX )
2015-07-25 23:10:46 +00:00
newdemo_record_primary_ammo ( get_local_player ( ) . vulcan_ammo ) ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2015-10-18 21:01:18 +00:00
if ( Primary_weapon = = primary_weapon_index_t : : OMEGA_INDEX )
2013-06-09 23:07:00 +00:00
newdemo_record_primary_ammo ( Omega_charge ) ;
2013-03-03 01:03:33 +00:00
# endif
2015-07-25 23:10:46 +00:00
newdemo_record_secondary_ammo ( get_local_player ( ) . secondary_ammo [ Secondary_weapon ] ) ;
2013-06-09 23:07:00 +00:00
}
2013-04-08 12:28:55 +00:00
if ( PlayerCfg . HudMode = = 3 ) // no hud, "immersion mode"
return ;
// Cruise speed
2015-07-12 01:04:20 +00:00
if ( Viewer - > type = = OBJ_PLAYER & & get_player_id ( vcobjptr ( Viewer ) ) = = Player_num & & PlayerCfg . CockpitMode [ 1 ] ! = CM_REAR_VIEW )
{
2013-04-08 12:28:55 +00:00
int x = FSPACX ( 1 ) ;
int y = grd_curcanv - > cv_bitmap . bm_h ;
gr_set_curfont ( GAME_FONT ) ;
gr_set_fontcolor ( BM_XRGB ( 0 , 31 , 0 ) , - 1 ) ;
if ( Cruise_speed > 0 ) {
2015-06-13 22:42:22 +00:00
const auto & & line_spacing = LINE_SPACING ;
2013-04-08 12:28:55 +00:00
if ( PlayerCfg . CockpitMode [ 1 ] = = CM_FULL_SCREEN ) {
if ( Game_mode & GM_MULTI )
2015-06-13 22:42:22 +00:00
y - = line_spacing * 10 ;
2013-04-08 12:28:55 +00:00
else
2015-06-13 22:42:22 +00:00
y - = line_spacing * 6 ;
2013-04-08 12:28:55 +00:00
} else if ( PlayerCfg . CockpitMode [ 1 ] = = CM_STATUS_BAR ) {
if ( Game_mode & GM_MULTI )
2015-06-13 22:42:22 +00:00
y - = line_spacing * 6 ;
2013-04-08 12:28:55 +00:00
else
2015-06-13 22:42:22 +00:00
y - = line_spacing * 1 ;
2013-04-08 12:28:55 +00:00
} else {
if ( Game_mode & GM_MULTI )
2015-06-13 22:42:22 +00:00
y - = line_spacing * 7 ;
2013-04-08 12:28:55 +00:00
else
2015-06-13 22:42:22 +00:00
y - = line_spacing * 2 ;
2013-04-08 12:28:55 +00:00
}
gr_printf ( x , y , " %s %2d%% " , TXT_CRUISE , f2i ( Cruise_speed ) ) ;
}
}
2006-03-20 17:12:09 +00:00
// Show score so long as not in rearview
2010-01-28 00:04:29 +00:00
if ( ! Rear_view & & PlayerCfg . CockpitMode [ 1 ] ! = CM_REAR_VIEW & & PlayerCfg . CockpitMode [ 1 ] ! = CM_STATUS_BAR ) {
2006-03-20 17:12:09 +00:00
hud_show_score ( ) ;
if ( score_time )
hud_show_score_added ( ) ;
}
2010-06-18 07:31:06 +00:00
if ( ! Rear_view & & PlayerCfg . CockpitMode [ 1 ] ! = CM_REAR_VIEW )
2008-02-24 14:41:27 +00:00
hud_show_timer_count ( ) ;
2006-03-20 17:12:09 +00:00
// Show other stuff if not in rearview or letterbox.
2012-04-24 09:55:16 +00:00
if ( ! Rear_view & & PlayerCfg . CockpitMode [ 1 ] ! = CM_REAR_VIEW )
{
show_HUD_names ( ) ;
2010-01-28 00:04:29 +00:00
if ( PlayerCfg . CockpitMode [ 1 ] = = CM_STATUS_BAR | | PlayerCfg . CockpitMode [ 1 ] = = CM_FULL_SCREEN )
2006-03-20 17:12:09 +00:00
hud_show_homing_warning ( ) ;
2015-04-26 20:15:53 +00:00
const local_multires_gauge_graphic multires_gauge_graphic = { } ;
2010-01-28 00:04:29 +00:00
if ( PlayerCfg . CockpitMode [ 1 ] = = CM_FULL_SCREEN ) {
2006-03-20 17:12:09 +00:00
hud_show_energy ( ) ;
hud_show_shield ( ) ;
hud_show_afterburner ( ) ;
hud_show_weapons ( ) ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
if ( ! PCSharePig )
# endif
2015-04-26 20:15:53 +00:00
hud_show_keys ( multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
hud_show_cloak_invuln ( ) ;
2010-07-15 05:40:25 +00:00
if ( Newdemo_state = = ND_STATE_RECORDING )
2015-10-30 02:52:55 +00:00
newdemo_record_player_flags ( get_local_player ( ) . flags . get_player_flags ( ) ) ;
2006-03-20 17:12:09 +00:00
}
2012-04-24 09:55:16 +00:00
# ifndef RELEASE
2008-09-30 00:07:07 +00:00
if ( ! ( Game_mode & GM_MULTI & & Show_kill_list ) )
2006-03-20 17:12:09 +00:00
show_time ( ) ;
2012-04-24 09:55:16 +00:00
# endif
2006-03-20 17:12:09 +00:00
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2010-01-28 00:04:29 +00:00
if ( PlayerCfg . CockpitMode [ 1 ] ! = CM_LETTERBOX & & PlayerCfg . CockpitMode [ 1 ] ! = CM_REAR_VIEW )
2011-01-19 01:19:17 +00:00
{
2015-04-26 20:15:53 +00:00
hud_show_flag ( multires_gauge_graphic ) ;
2015-04-26 20:15:53 +00:00
hud_show_orbs ( multires_gauge_graphic ) ;
2011-01-19 01:19:17 +00:00
}
2013-03-03 01:03:33 +00:00
# endif
2008-09-30 00:07:07 +00:00
HUD_render_message_frame ( ) ;
2006-03-20 17:12:09 +00:00
2010-01-28 00:04:29 +00:00
if ( PlayerCfg . CockpitMode [ 1 ] ! = CM_STATUS_BAR )
2015-04-26 20:15:54 +00:00
hud_show_lives ( multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
if ( Game_mode & GM_MULTI & & Show_kill_list )
hud_show_kill_list ( ) ;
2012-04-24 09:55:16 +00:00
if ( PlayerCfg . CockpitMode [ 1 ] ! = CM_LETTERBOX )
show_reticle ( PlayerCfg . ReticleType , 1 ) ;
if ( PlayerCfg . CockpitMode [ 1 ] ! = CM_LETTERBOX & & Newdemo_state ! = ND_STATE_PLAYBACK & & PlayerCfg . MouseFlightSim & & PlayerCfg . MouseFSIndicator )
show_mousefs_indicator ( Controls . raw_mouse_axis [ 0 ] , Controls . raw_mouse_axis [ 1 ] , Controls . raw_mouse_axis [ 2 ] , GWIDTH / 2 , GHEIGHT / 2 , GHEIGHT / 4 ) ;
2006-03-20 17:12:09 +00:00
}
2010-01-28 00:04:29 +00:00
if ( Rear_view & & PlayerCfg . CockpitMode [ 1 ] ! = CM_REAR_VIEW ) {
2006-03-20 17:12:09 +00:00
HUD_render_message_frame ( ) ;
gr_set_curfont ( GAME_FONT ) ;
2008-02-24 14:41:27 +00:00
gr_set_fontcolor ( BM_XRGB ( 0 , 31 , 0 ) , - 1 ) ;
2013-01-03 16:23:24 +00:00
gr_string ( 0x8000 , GHEIGHT - LINE_SPACING , TXT_REAR_VIEW ) ;
2006-03-20 17:12:09 +00:00
}
}
//print out some player statistics
void render_gauges ( )
{
2015-07-25 23:10:46 +00:00
int energy = f2ir ( get_local_player ( ) . energy ) ;
int cloak = ( ( get_local_player ( ) . flags & PLAYER_FLAGS_CLOAKED ) ! = 0 ) ;
2008-11-09 14:31:30 +00:00
2010-01-28 00:04:29 +00:00
Assert ( PlayerCfg . CockpitMode [ 1 ] = = CM_FULL_COCKPIT | | PlayerCfg . CockpitMode [ 1 ] = = CM_STATUS_BAR ) ;
2006-03-20 17:12:09 +00:00
2015-10-30 02:52:55 +00:00
auto shields = f2ir ( get_local_player_shields ( ) ) ;
2006-03-20 17:12:09 +00:00
if ( shields < 0 ) shields = 0 ;
2007-03-21 11:32:33 +00:00
gr_set_current_canvas ( NULL ) ;
2006-03-20 17:12:09 +00:00
gr_set_curfont ( GAME_FONT ) ;
if ( Newdemo_state = = ND_STATE_RECORDING )
2015-07-25 23:10:46 +00:00
if ( get_local_player ( ) . homing_object_dist > = 0 )
newdemo_record_homing_distance ( get_local_player ( ) . homing_object_dist ) ;
2006-03-20 17:12:09 +00:00
2015-04-26 20:15:53 +00:00
const local_multires_gauge_graphic multires_gauge_graphic { } ;
2015-04-26 20:15:53 +00:00
draw_weapon_boxes ( multires_gauge_graphic ) ;
2010-01-28 00:04:29 +00:00
if ( PlayerCfg . CockpitMode [ 1 ] = = CM_FULL_COCKPIT ) {
2010-07-15 05:40:25 +00:00
if ( Newdemo_state = = ND_STATE_RECORDING )
newdemo_record_player_energy ( energy ) ;
2015-04-26 20:15:54 +00:00
draw_energy_bar ( energy , multires_gauge_graphic ) ;
2015-05-09 17:38:57 +00:00
draw_numerical_display ( shields , energy , multires_gauge_graphic ) ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
if ( ! PlayerCfg . HudMode )
# elif defined(DXX_BUILD_DESCENT_II)
2010-07-15 05:40:25 +00:00
if ( Newdemo_state = = ND_STATE_RECORDING )
newdemo_record_player_afterburner ( Afterburner_charge ) ;
2015-04-26 20:15:54 +00:00
draw_afterburner_bar ( Afterburner_charge , multires_gauge_graphic ) ;
2013-03-03 01:03:33 +00:00
# endif
show_bomb_count ( HUD_SCALE_X ( BOMB_COUNT_X ) , HUD_SCALE_Y ( BOMB_COUNT_Y ) , gr_find_closest_color ( 0 , 0 , 0 ) , 0 , 0 ) ;
2015-04-26 20:15:54 +00:00
draw_player_ship ( cloak , SHIP_GAUGE_X , SHIP_GAUGE_Y , multires_gauge_graphic ) ;
2007-06-10 16:21:53 +00:00
2015-07-25 23:10:46 +00:00
if ( get_local_player ( ) . flags & PLAYER_FLAGS_INVULNERABLE )
2015-04-26 20:15:54 +00:00
draw_invulnerable_ship ( multires_gauge_graphic ) ;
2012-04-07 14:13:12 +00:00
else
2015-04-26 20:15:54 +00:00
draw_shield_bar ( shields , multires_gauge_graphic ) ;
2015-05-09 17:38:57 +00:00
draw_numerical_display ( shields , energy , multires_gauge_graphic ) ;
2010-06-18 07:31:06 +00:00
2010-07-15 05:40:25 +00:00
if ( Newdemo_state = = ND_STATE_RECORDING )
2012-04-07 14:13:12 +00:00
{
newdemo_record_player_shields ( shields ) ;
2015-10-30 02:52:55 +00:00
newdemo_record_player_flags ( get_local_player ( ) . flags . get_player_flags ( ) ) ;
2012-04-07 14:13:12 +00:00
}
2015-10-30 02:52:54 +00:00
draw_cockpit_keys_state ( ) . draw_all_keys ( multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
2015-04-26 20:15:53 +00:00
show_homing_warning ( multires_gauge_graphic ) ;
2015-04-26 20:15:54 +00:00
draw_wbu_overlay ( multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
2010-01-28 00:04:29 +00:00
} else if ( PlayerCfg . CockpitMode [ 1 ] = = CM_STATUS_BAR ) {
2006-03-20 17:12:09 +00:00
2010-07-15 05:40:25 +00:00
if ( Newdemo_state = = ND_STATE_RECORDING )
newdemo_record_player_energy ( energy ) ;
2015-04-26 20:15:55 +00:00
sb_draw_energy_bar ( energy , multires_gauge_graphic ) ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
if ( ! PlayerCfg . HudMode )
# elif defined(DXX_BUILD_DESCENT_II)
2010-07-15 05:40:25 +00:00
if ( Newdemo_state = = ND_STATE_RECORDING )
newdemo_record_player_afterburner ( Afterburner_charge ) ;
2015-04-26 20:15:55 +00:00
sb_draw_afterburner ( multires_gauge_graphic ) ;
2013-03-03 01:03:33 +00:00
if ( ! PlayerCfg . HudMode & & weapon_box_user [ 1 ] = = WBU_WEAPON )
# endif
show_bomb_count ( HUD_SCALE_X ( SB_BOMB_COUNT_X ) , HUD_SCALE_Y ( SB_BOMB_COUNT_Y ) , gr_find_closest_color ( 0 , 0 , 0 ) , 0 , 0 ) ;
2007-10-05 23:47:16 +00:00
2015-04-26 20:15:54 +00:00
draw_player_ship ( cloak , SB_SHIP_GAUGE_X , SB_SHIP_GAUGE_Y , multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
2015-07-25 23:10:46 +00:00
if ( get_local_player ( ) . flags & PLAYER_FLAGS_INVULNERABLE )
2015-04-26 20:15:54 +00:00
draw_invulnerable_ship ( multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
else
2015-04-26 20:15:55 +00:00
sb_draw_shield_bar ( shields , multires_gauge_graphic ) ;
2015-04-26 20:15:55 +00:00
sb_draw_shield_num ( shields , multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
2010-07-15 05:40:25 +00:00
if ( Newdemo_state = = ND_STATE_RECORDING )
2012-04-07 14:13:12 +00:00
{
newdemo_record_player_shields ( shields ) ;
2015-10-30 02:52:55 +00:00
newdemo_record_player_flags ( get_local_player ( ) . flags . get_player_flags ( ) ) ;
2012-04-07 14:13:12 +00:00
}
2015-10-30 02:52:54 +00:00
draw_statusbar_keys_state ( ) . draw_all_keys ( multires_gauge_graphic ) ;
2010-06-18 07:31:06 +00:00
2015-04-26 20:15:54 +00:00
sb_show_lives ( multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
if ( ( Game_mode & GM_MULTI ) & & ! ( Game_mode & GM_MULTI_COOP ) )
{
2015-04-26 20:15:53 +00:00
sb_show_score ( multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
}
else
{
2015-04-26 20:15:53 +00:00
sb_show_score ( multires_gauge_graphic ) ;
sb_show_score_added ( multires_gauge_graphic ) ;
2006-03-20 17:12:09 +00:00
}
}
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
else
2015-04-26 20:15:54 +00:00
draw_player_ship ( cloak , SB_SHIP_GAUGE_X , SB_SHIP_GAUGE_Y , multires_gauge_graphic ) ;
2013-03-03 01:03:33 +00:00
# endif
2006-03-20 17:12:09 +00:00
}
// ---------------------------------------------------------------------------------------------------------
// Call when picked up a laser powerup.
// If laser is active, set old_weapon[0] to -1 to force redraw.
void update_laser_weapon_info ( void )
{
2007-03-21 12:35:35 +00:00
if ( old_weapon [ 0 ] = = 0 )
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2015-07-25 23:10:46 +00:00
if ( ! ( get_local_player ( ) . laser_level > MAX_LASER_LEVEL & & old_laser_level < = MAX_LASER_LEVEL ) )
2013-03-03 01:03:33 +00:00
# endif
2007-03-21 12:35:35 +00:00
old_weapon [ 0 ] = - 1 ;
2006-03-20 17:12:09 +00:00
}
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2015-02-14 22:48:28 +00:00
static array < int , 2 > overlap_dirty ;
2006-03-20 17:12:09 +00:00
//draws a 3d view into one of the cockpit windows. win is 0 for left,
//1 for right. viewer is object. NULL object means give up window
//user is one of the WBU_ constants. If rear_view_flag is set, show a
//rear view. If label is non-NULL, print the label at the top of the
//window.
2015-04-02 02:36:57 +00:00
void do_cockpit_window_view ( int win , int user )
2015-02-14 22:48:28 +00:00
{
Assert ( user = = WBU_WEAPON | | user = = WBU_STATIC ) ;
if ( user = = WBU_STATIC & & weapon_box_user [ win ] ! = WBU_STATIC )
static_time [ win ] = 0 ;
if ( weapon_box_user [ win ] = = WBU_WEAPON | | weapon_box_user [ win ] = = WBU_STATIC )
return ; //already set
weapon_box_user [ win ] = user ;
if ( overlap_dirty [ win ] ) {
gr_set_current_canvas ( NULL ) ;
overlap_dirty [ win ] = 0 ;
}
}
2015-05-13 03:20:28 +00:00
void do_cockpit_window_view ( int win , const vobjptr_t viewer , int rear_view_flag , int user , const char * label )
2006-03-20 17:12:09 +00:00
{
grs_canvas window_canv ;
static grs_canvas overlap_canv ;
object * viewer_save = Viewer ;
int boxnum ;
static int window_x , window_y ;
2012-06-24 21:30:39 +00:00
const gauge_box * box ;
2006-03-20 17:12:09 +00:00
int rear_view_save = Rear_view ;
int w , h , dx ;
box = NULL ;
2014-12-18 04:12:38 +00:00
window_rendered_data window ;
update_rendered_data ( window , viewer , rear_view_flag ) ;
2006-03-20 17:12:09 +00:00
weapon_box_user [ win ] = user ; //say who's using window
2010-06-18 07:31:06 +00:00
2006-03-20 17:12:09 +00:00
Viewer = viewer ;
Rear_view = rear_view_flag ;
2015-04-26 20:15:53 +00:00
const local_multires_gauge_graphic multires_gauge_graphic { } ;
2010-01-28 00:04:29 +00:00
if ( PlayerCfg . CockpitMode [ 1 ] = = CM_FULL_SCREEN )
2006-03-20 17:12:09 +00:00
{
2015-04-26 20:15:53 +00:00
w = HUD_SCALE_X_AR ( ( multires_gauge_graphic . get ( 106 , 44 ) ) ) ;
h = HUD_SCALE_Y_AR ( ( multires_gauge_graphic . get ( 106 , 44 ) ) ) ;
2006-03-20 17:12:09 +00:00
dx = ( win = = 0 ) ? - ( w + ( w / 10 ) ) : ( w / 10 ) ;
2015-03-22 18:49:21 +00:00
window_x = grd_curscreen - > get_screen_width ( ) / 2 + dx ;
window_y = grd_curscreen - > get_screen_height ( ) - h - ( SHEIGHT / 15 ) ;
2006-03-20 17:12:09 +00:00
2015-01-17 18:31:40 +00:00
gr_init_sub_canvas ( window_canv , grd_curscreen - > sc_canvas , window_x , window_y , w , h ) ;
2006-03-20 17:12:09 +00:00
}
else {
2010-01-28 00:04:29 +00:00
if ( PlayerCfg . CockpitMode [ 1 ] = = CM_FULL_COCKPIT )
2006-03-20 17:12:09 +00:00
boxnum = ( COCKPIT_PRIMARY_BOX ) + win ;
2010-01-28 00:04:29 +00:00
else if ( PlayerCfg . CockpitMode [ 1 ] = = CM_STATUS_BAR )
2006-03-20 17:12:09 +00:00
boxnum = ( SB_PRIMARY_BOX ) + win ;
else
goto abort ;
box = & gauge_boxes [ boxnum ] ;
2015-01-17 18:31:40 +00:00
gr_init_sub_canvas ( window_canv , grd_curscreen - > sc_canvas , HUD_SCALE_X ( box - > left ) , HUD_SCALE_Y ( box - > top ) , HUD_SCALE_X ( box - > right - box - > left + 1 ) , HUD_SCALE_Y ( box - > bot - box - > top + 1 ) ) ;
2006-03-20 17:12:09 +00:00
}
gr_set_current_canvas ( & window_canv ) ;
2006-10-20 16:38:04 +00:00
2014-12-18 04:12:38 +00:00
render_frame ( 0 , window ) ;
2006-10-20 16:38:04 +00:00
2006-03-20 17:12:09 +00:00
// HACK! If guided missile, wake up robots as necessary.
if ( viewer - > type = = OBJ_WEAPON ) {
// -- Used to require to be GUIDED -- if (viewer->id == GUIDEDMISS_ID)
2014-12-18 04:12:38 +00:00
wake_up_rendered_objects ( viewer , window ) ;
2006-03-20 17:12:09 +00:00
}
if ( label ) {
gr_set_curfont ( GAME_FONT ) ;
if ( Color_0_31_0 = = - 1 )
2008-02-24 14:41:27 +00:00
Color_0_31_0 = BM_XRGB ( 0 , 31 , 0 ) ;
2006-03-20 17:12:09 +00:00
gr_set_fontcolor ( Color_0_31_0 , - 1 ) ;
2013-01-03 16:23:24 +00:00
gr_string ( 0x8000 , FSPACY ( 1 ) , label ) ;
2006-03-20 17:12:09 +00:00
}
if ( user = = WBU_GUIDED )
2011-02-10 19:53:23 +00:00
show_reticle ( RET_TYPE_CROSS_V1 , 0 ) ;
2006-03-20 17:12:09 +00:00
2010-01-28 00:04:29 +00:00
if ( PlayerCfg . CockpitMode [ 1 ] = = CM_FULL_SCREEN ) {
2006-03-20 17:12:09 +00:00
int small_window_bottom , big_window_bottom , extra_part_h ;
2010-06-18 07:31:06 +00:00
2006-03-20 17:12:09 +00:00
{
gr_setcolor ( BM_XRGB ( 0 , 0 , 32 ) ) ;
2011-02-03 00:10:30 +00:00
gr_ubox ( 0 , 0 , grd_curcanv - > cv_bitmap . bm_w , grd_curcanv - > cv_bitmap . bm_h ) ;
2006-03-20 17:12:09 +00:00
}
//if the window only partially overlaps the big 3d window, copy
//the extra part to the visible screen
2007-06-14 20:52:14 +00:00
big_window_bottom = SHEIGHT - 1 ;
2006-03-20 17:12:09 +00:00
if ( window_y > big_window_bottom ) {
//the small window is completely outside the big 3d window, so
//copy it to the visible screen
2007-03-21 11:32:33 +00:00
gr_set_current_canvas ( NULL ) ;
2006-03-20 17:12:09 +00:00
2014-12-02 03:35:01 +00:00
gr_bitmap ( window_x , window_y , window_canv . cv_bitmap ) ;
2006-03-20 17:12:09 +00:00
overlap_dirty [ win ] = 1 ;
}
else {
small_window_bottom = window_y + window_canv . cv_bitmap . bm_h - 1 ;
2010-06-18 07:31:06 +00:00
2006-03-20 17:12:09 +00:00
extra_part_h = small_window_bottom - big_window_bottom ;
if ( extra_part_h > 0 ) {
2015-01-17 18:31:40 +00:00
gr_init_sub_canvas ( overlap_canv , window_canv , 0 , window_canv . cv_bitmap . bm_h - extra_part_h , window_canv . cv_bitmap . bm_w , extra_part_h ) ;
2007-03-21 11:32:33 +00:00
gr_set_current_canvas ( NULL ) ;
2014-12-02 03:35:01 +00:00
gr_bitmap ( window_x , big_window_bottom + 1 , overlap_canv . cv_bitmap ) ;
2006-03-20 17:12:09 +00:00
overlap_dirty [ win ] = 1 ;
}
}
}
else {
2010-06-18 07:31:06 +00:00
2007-03-21 11:32:33 +00:00
gr_set_current_canvas ( NULL ) ;
2006-03-20 17:12:09 +00:00
}
//force redraw when done
2010-07-15 05:40:25 +00:00
old_weapon [ win ] = - 1 ;
2006-03-20 17:12:09 +00:00
2010-01-28 00:04:29 +00:00
if ( PlayerCfg . CockpitMode [ 1 ] = = CM_FULL_COCKPIT )
2015-04-26 20:15:54 +00:00
draw_wbu_overlay ( multires_gauge_graphic ) ;
2008-11-09 14:31:30 +00:00
2006-03-20 17:12:09 +00:00
abort : ;
Viewer = viewer_save ;
Rear_view = rear_view_save ;
}
2013-03-03 01:03:33 +00:00
# endif