1 /* 2 3 Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc. 4 and the "Aleph One" developers. 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 3 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 This license is contained in the file "COPYING", 17 which is included with this source code; it is available online at 18 http://www.gnu.org/licenses/gpl.html 19 20 */ 21 22 /* 23 * HUDRenderer.h - HUD rendering base class and data 24 * 25 * Written in 2001 by Christian Bauer 26 */ 27 28 #ifndef _HUD_RENDERER_H_ 29 #define _HUD_RENDERER_H_ 30 31 #include "cseries.h" 32 #include "map.h" 33 #include "interface.h" 34 #include "player.h" 35 #include "SoundManager.h" 36 #include "motion_sensor.h" 37 #include "items.h" 38 #include "weapons.h" 39 #include "network_games.h" 40 #include "screen_drawing.h" 41 42 /* --------- constants */ 43 44 #define TEXT_INSET 2 45 #define NAME_OFFSET 23 46 #define TOP_OF_BAR_WIDTH 8 47 48 #define MOTION_SENSOR_SIDE_LENGTH 123 49 #define DELAY_TICKS_BETWEEN_OXYGEN_REDRAW (2*TICKS_PER_SECOND) 50 #define RECORDING_LIGHT_FLASHING_DELAY (TICKS_PER_SECOND) 51 52 #define MICROPHONE_STOP_CLICK_SOUND ((short) 1250) 53 #define MICROPHONE_START_CLICK_SOUND ((short) 1280) 54 55 #define TOP_OF_BAR_HEIGHT 4 56 57 /* ---------- flag macros */ 58 /* Note for reference: */ 59 /* enum { _weapon, _ammunition, _powerup, NUMBER_OF_ITEM_TYPES }; */ 60 61 #define INVENTORY_MASK_BITS 0x0007 62 #define INVENTORY_DIRTY_BIT 0x0010 63 #define INTERFACE_DIRTY_BIT 0x0020 64 65 #define GET_CURRENT_INVENTORY_SCREEN(p) ((p)->interface_flags & INVENTORY_MASK_BITS) 66 67 #define INVENTORY_IS_DIRTY(p) ((p)->interface_flags & INVENTORY_DIRTY_BIT) 68 #define SET_INVENTORY_DIRTY_STATE(p, v) ((void)((v)?((p)->interface_flags|=(uint16)INVENTORY_DIRTY_BIT):((p)->interface_flags&=(uint16)~INVENTORY_DIRTY_BIT))) 69 70 #define INTERFACE_IS_DIRTY(p) ((p)->interface_flags & INTERFACE_DIRTY_BIT) 71 #define SET_INTERFACE_DIRTY_STATE(p, v) ((v)?((p)->interface_flags |= INTERFACE_DIRTY_BIT):(p)->interface_flags &= ~INTERFACE_DIRTY_BIT) 72 73 /* ---------- enums */ 74 /* texture id's */ 75 enum { 76 _empty_energy_bar=0, 77 _energy_bar, 78 _energy_bar_right, 79 _double_energy_bar, 80 _double_energy_bar_right, 81 _triple_energy_bar, 82 _triple_energy_bar_right, 83 _empty_oxygen_bar, 84 _oxygen_bar, 85 _oxygen_bar_right, 86 _motion_sensor_mount, 87 _motion_sensor_virgin_mount, 88 _motion_sensor_alien, 89 _motion_sensor_friend= _motion_sensor_alien+6, 90 _motion_sensor_enemy= _motion_sensor_friend+6, 91 _network_panel= _motion_sensor_enemy+6, 92 93 _magnum_bullet, 94 _magnum_casing, 95 _assault_rifle_bullet, 96 _assault_rifle_casing, 97 _alien_weapon_panel, 98 _flamethrower_panel, 99 _magnum_panel, 100 _left_magnum, 101 _zeus_panel, 102 _assault_panel, 103 _missile_panel, 104 _left_magnum_unusable, 105 _assault_rifle_grenade, 106 _assault_rifle_grenade_casing, 107 _shotgun_bullet, 108 _shotgun_casing, 109 _single_shotgun, 110 _double_shotgun, 111 _missile, 112 _missile_casing, 113 114 _network_compass_shape_nw, 115 _network_compass_shape_ne, 116 _network_compass_shape_sw, 117 _network_compass_shape_se, 118 119 _skull, 120 121 // LP additions: 122 _smg, 123 _smg_bullet, 124 _smg_casing, 125 126 127 /* These are NOT done. */ 128 _mike_button_unpressed, 129 _mike_button_pressed 130 }; 131 132 enum { 133 _unused_interface_data, 134 _uses_energy, 135 _uses_bullets 136 }; 137 138 enum { /* Passed to update_ammo_display_in_panel */ 139 _primary_interface_ammo, 140 _secondary_interface_ammo, 141 NUMBER_OF_WEAPON_INTERFACE_ITEMS 142 }; 143 144 /* ------------ structures */ 145 struct weapon_interface_ammo_data 146 { 147 short type; 148 short screen_left; 149 short screen_top; 150 short ammo_across; /* max energy for beam weapons */ 151 short ammo_down; /* Unused for energy weapons */ 152 short delta_x; /* Or width, if uses energy */ 153 short delta_y; /* Or height if uses energy */ 154 shape_descriptor bullet; /* or fill color index */ 155 shape_descriptor empty_bullet; /* or empty color index */ 156 bool right_to_left; /* Which way do the bullets go as they are used? */ 157 }; 158 159 struct weapon_interface_data 160 { 161 short item_id; 162 shape_descriptor weapon_panel_shape; 163 short weapon_name_start_y; 164 short weapon_name_end_y; 165 short weapon_name_start_x; /* NONE means center in the weapon rectangle */ 166 short weapon_name_end_x; /* NONE means center in the weapon rectangle */ 167 short standard_weapon_panel_top; 168 short standard_weapon_panel_left; 169 bool multi_weapon; 170 struct weapon_interface_ammo_data ammo_data[NUMBER_OF_WEAPON_INTERFACE_ITEMS]; 171 shape_descriptor multiple_shape; 172 shape_descriptor multiple_unusable_shape; 173 short multiple_delta_x; 174 short multiple_delta_y; 175 }; 176 177 struct interface_state_data 178 { 179 bool ammo_is_dirty; 180 bool weapon_is_dirty; 181 bool shield_is_dirty; 182 bool oxygen_is_dirty; 183 }; 184 185 #define MAXIMUM_WEAPON_INTERFACE_DEFINITIONS (sizeof(weapon_interface_definitions)/sizeof(struct weapon_interface_data)) 186 187 extern interface_state_data interface_state; 188 extern weapon_interface_data weapon_interface_definitions[10]; 189 190 struct point2d; 191 192 #if defined(__WIN32__) || defined(__MINGW32__) 193 #undef DrawText 194 #endif 195 196 // Base class for HUD renderer 197 class HUD_Class 198 { 199 public: HUD_Class()200 HUD_Class() : ForceUpdate(false) {} ~HUD_Class()201 virtual ~HUD_Class() {} 202 203 bool update_everything(short time_elapsed); 204 205 protected: 206 void update_suit_energy(short time_elapsed); 207 void update_suit_oxygen(short time_elapsed); 208 void update_weapon_panel(bool force_redraw); 209 void update_ammo_display(bool force_redraw); 210 void update_inventory_panel(bool force_redraw); 211 void draw_inventory_header(char *text, short offset); 212 void draw_inventory_time(char *text, short offset); 213 short max_displayable_inventory_lines(void); 214 void calculate_inventory_rectangle_from_offset(screen_rectangle *r, short offset); 215 void draw_bar(screen_rectangle *rectangle, short actual_height, 216 shape_descriptor top_piece, shape_descriptor full_bar, 217 shape_descriptor background_piece); 218 void draw_ammo_display_in_panel(short trigger_id); 219 void draw_inventory_item(char *text, short count, short offset, 220 bool erase_first, bool valid_in_this_environment); 221 void draw_player_name(void); 222 virtual void draw_message_area(short time_elapsed); 223 224 void draw_network_compass(void); 225 virtual void draw_all_entity_blips(void); 226 227 virtual void update_motion_sensor(short time_elapsed) = 0; 228 virtual void render_motion_sensor(short time_elapsed) = 0; 229 virtual void draw_or_erase_unclipped_shape(short x, short y, shape_descriptor shape, bool draw) = 0; 230 virtual void draw_entity_blip(point2d *location, shape_descriptor shape) = 0; 231 232 virtual void DrawShape(shape_descriptor shape, screen_rectangle *dest, screen_rectangle *src) = 0; 233 virtual void DrawShapeAtXY(shape_descriptor shape, short x, short y, bool transparency = false) = 0; 234 virtual void DrawText(const char *text, screen_rectangle *dest, short flags, short font_id, short text_color) = 0; 235 virtual void FillRect(screen_rectangle *r, short color_index) = 0; 236 virtual void FrameRect(screen_rectangle *r, short color_index) = 0; 237 238 virtual void DrawTexture(shape_descriptor shape, short texture_type, short x, short y, int size) = 0; 239 240 virtual void SetClipPlane(int x, int y, int c_x, int c_y, int radius) = 0; 241 virtual void DisableClipPlane(void) = 0; 242 243 protected: 244 bool ForceUpdate; 245 }; 246 247 #endif 248