Esempio n. 1
0
static void draw_inventory_item(
	char *text, 
	short count, 
	short offset, 
	boolean erase_first,
	boolean valid_in_this_environment)
{
	screen_rectangle destination, text_destination;
	char count_text[10];
	short color;

	calculate_inventory_rectangle_from_offset(&destination, offset);

	/* Select the color for the text.. */
	color= (valid_in_this_environment) ? (_inventory_text_color) : (_invalid_weapon_color);

	/* Erase on items that changed only in count.. */
	if(erase_first)
	{
		_fill_rect(&destination, _inventory_background_color);
	} else {
		/* Unfortunately, we must always erase the numbers.. */
		text_destination= destination;
		text_destination.right= text_destination.left+NAME_OFFSET+TEXT_INSET;
		_fill_rect(&text_destination, _inventory_background_color);
	}

	/* Draw the text name.. */
	text_destination= destination;
	text_destination.left+= NAME_OFFSET+TEXT_INSET;
	_draw_screen_text(text, &text_destination, _center_vertical, _interface_font, color);

	/* Draw the text count-> Change the font!! */
	text_destination= destination;
	text_destination.left+= TEXT_INSET;
	sprintf(count_text, "%3d", count);
	_draw_screen_text(count_text, &text_destination, _center_vertical, _interface_item_count_font, color);
}
Esempio n. 2
0
/* far left.  Headers also have their backgrounds erased first */
static void draw_inventory_header(
	char *text, 
	short offset)
{
	screen_rectangle destination;

	calculate_inventory_rectangle_from_offset(&destination, offset);

	/* Erase.. */
	_fill_rect(&destination, _inventory_header_background_color);

	/* Now draw the text. */	
	destination.left+= TEXT_INSET;
	_draw_screen_text(text, &destination, _center_vertical, _interface_font,
		_inventory_text_color);
		
	return;
}
Esempio n. 3
0
/* This should probably go to a gworld first, or something */
static void update_inventory_panel(
	boolean force_redraw)
{
	short section_items[NUMBER_OF_ITEMS];
	short section_counts[NUMBER_OF_ITEMS];
	short section_count, loop;
	short item_type, current_row;

	if(INVENTORY_IS_DIRTY(current_player) || force_redraw)
	{
		screen_rectangle *destination= get_interface_rectangle(_inventory_rect);
		screen_rectangle text_rectangle;
		short total_inventory_line_count= count_inventory_lines(current_player_index);
		short max_lines= max_displayable_inventory_lines();
	
		/* Recalculate and redraw.. */
		item_type= GET_CURRENT_INVENTORY_SCREEN(current_player);
					
		/* Reset the row.. */
		current_row= 0;
		if(item_type!=_network_statistics)
		{
			/* Get the types and names */
			calculate_player_item_array(current_player_index, item_type,
				section_items, section_counts, &section_count);
		}

		/* Draw the header. */
		get_header_name(temporary, item_type);
		draw_inventory_header(temporary, current_row++);

		/* Draw the network time elapsed if timed game. */
		if (item_type==_network_statistics && dynamic_world->game_information.game_time_remaining<60*60*TICKS_PER_SECOND)
		{
			long seconds= dynamic_world->game_information.game_time_remaining/TICKS_PER_SECOND;
			screen_rectangle destination;
			
			sprintf(temporary, "% 2d:%02d", seconds/60, seconds%60);

			calculate_inventory_rectangle_from_offset(&destination, current_row-1);
			destination.top -= 2;		//<6/17/96 AMR> Sick hack
			destination.bottom -= 2;

			/* Now draw the text. */	
			destination.left+= TEXT_INSET;
			_draw_screen_text(temporary, &destination, _right_justified, _interface_font,
				_inventory_text_color);
		}
				
		/* Erase the panel.. */
		text_rectangle= *destination;
		text_rectangle.top+= _get_font_line_height(_interface_font);
		_fill_rect(&text_rectangle, _inventory_background_color);

		if(item_type==_network_statistics)
		{
			struct player_ranking_data rankings[MAXIMUM_NUMBER_OF_PLAYERS];
	
			calculate_player_rankings(rankings);
		
			/* Calculate the network statistics. */
			for(loop= 0; loop<dynamic_world->player_count; ++loop)
			{
				screen_rectangle dest_rect;
				struct player_data *player= get_player_data(rankings[loop].player_index);
				short width;
				
				calculate_inventory_rectangle_from_offset(&dest_rect, current_row++);
				calculate_ranking_text(temporary, rankings[loop].ranking);

				/* Draw the player name.. */
				width= _text_width(temporary, _interface_font);
				dest_rect.right-= width;
				dest_rect.left+= TEXT_INSET;
				_draw_screen_text(player->name, &dest_rect, _center_vertical, 
					_interface_font, PLAYER_COLOR_BASE_INDEX+player->color);

				/* Now draw the ranking_text */
				dest_rect.right+= width;
				dest_rect.left= dest_rect.right-width;
				_draw_screen_text(temporary, &dest_rect, _center_vertical, 
					_interface_font, PLAYER_COLOR_BASE_INDEX+player->color);
			}
		} else {
			/* Draw the items. */
			for(loop= 0; loop<section_count && current_row<max_lines; ++loop)
			{
				boolean valid_in_this_environment;
			
				/* Draw the item */
				get_item_name(temporary, section_items[loop], (section_counts[loop]!=1));
				valid_in_this_environment= item_valid_in_current_environment(section_items[loop]);
				draw_inventory_item(temporary, section_counts[loop], current_row++, FALSE, valid_in_this_environment);
			}
		}
		
		SET_INVENTORY_DIRTY_STATE(current_player, FALSE);
	}

	return;
}
Esempio n. 4
0
/* A change of weapon has occurred, change the weapon display panel */
static void update_weapon_panel(
	boolean force_redraw)
{
	if(force_redraw || interface_state.weapon_is_dirty)
	{
		char weapon_name[90];
		struct weapon_interface_data *definition;
		screen_rectangle *destination= get_interface_rectangle(_weapon_display_rect);
		screen_rectangle source;
		short desired_weapon= get_player_desired_weapon(current_player_index);

		/* Now we have to erase, because the panel won't do it for us.. */
		_fill_rect(destination, _inventory_background_color);
	
		if(desired_weapon != NONE)
		{
			assert(desired_weapon>=0 && desired_weapon<MAXIMUM_WEAPON_INTERFACE_DEFINITIONS);

			definition= weapon_interface_definitions+desired_weapon;
	
			/* Check if it is a multi weapon - actually special cased for the magnum... */
			if(definition->multi_weapon)
			{
#define MAGNUM_DELTA_X 97
				if(definition->item_id==_i_magnum)
				{
					/* Either way, draw the single */
					_draw_screen_shape_at_x_y(definition->weapon_panel_shape, 
						definition->standard_weapon_panel_left, 
						definition->standard_weapon_panel_top);

					if(current_player->items[definition->item_id]>1)
					{
						_draw_screen_shape_at_x_y(
							BUILD_DESCRIPTOR(_collection_interface, _left_magnum), 
							definition->standard_weapon_panel_left-MAGNUM_DELTA_X, 
							definition->standard_weapon_panel_top);
					} 
					else 
					{
						/* Draw the empty one.. */
						_draw_screen_shape_at_x_y(
							BUILD_DESCRIPTOR(_collection_interface, _left_magnum_unusable), 
							definition->standard_weapon_panel_left-MAGNUM_DELTA_X, 
							definition->standard_weapon_panel_top);
					}
				} 
				else if(definition->item_id==_i_shotgun)
				{
					if(current_player->items[definition->item_id]>1)
					{
						_draw_screen_shape_at_x_y(
							BUILD_DESCRIPTOR(_collection_interface, _double_shotgun), 
							definition->standard_weapon_panel_left, 
							definition->standard_weapon_panel_top-12);
					} else {
						_draw_screen_shape_at_x_y(definition->weapon_panel_shape, 
							definition->standard_weapon_panel_left, 
							definition->standard_weapon_panel_top);
					}
				}
			} else {
				/* Slam it to the screen! */
				if(definition->weapon_panel_shape != NONE)
				{
					_draw_screen_shape_at_x_y(definition->weapon_panel_shape, 
						definition->standard_weapon_panel_left, 
						definition->standard_weapon_panel_top);
				}
			}
		
			/* Get the weapon name.. */
			if(desired_weapon != _weapon_ball)
			{
#define strWEAPON_NAME_LIST 137
				getcstr(weapon_name, strWEAPON_NAME_LIST, desired_weapon);
			} else {
				short item_index;
				
				/* Which ball do they actually have? */
				for(item_index= BALL_ITEM_BASE; item_index<BALL_ITEM_BASE+MAXIMUM_NUMBER_OF_PLAYERS; ++item_index)
				{
					if(current_player->items[item_index]>0) break;
				}
				assert(item_index != BALL_ITEM_BASE+MAXIMUM_NUMBER_OF_PLAYERS);
				get_item_name(weapon_name, item_index, FALSE);
			}

			/* Draw the weapon name.. */
			source= *destination;
			source.top= definition->weapon_name_start_y;
			source.bottom= definition->weapon_name_end_y;
			if(definition->weapon_name_start_x != NONE)
			{
				source.left= definition->weapon_name_start_x;
			}
			
			if(definition->weapon_name_end_x != NONE)
			{
				source.right= definition->weapon_name_end_x;
			}
			
			_draw_screen_text(weapon_name, &source, _center_horizontal|_center_vertical|_wrap_text,
				_weapon_name_font, _inventory_text_color);
				
			/* And make sure that the ammo knows it needs to update */
			interface_state.ammo_is_dirty= TRUE;
		} 
		interface_state.weapon_is_dirty= FALSE;
	}
}
Esempio n. 5
0
static void draw_ammo_display_in_panel(
	short trigger_id)
{
	struct weapon_interface_data *current_weapon_data;
	struct weapon_interface_ammo_data *current_ammo_data;
	struct player_data *player= get_player_data(current_player_index);
	short ammunition_count;
	short desired_weapon= get_player_desired_weapon(current_player_index);

	/* Based on desired weapon, so we can get ammo updates as soon as we change */
	if(desired_weapon != NONE)
	{
		current_weapon_data= weapon_interface_definitions+desired_weapon;
		current_ammo_data= &current_weapon_data->ammo_data[trigger_id];

		if(trigger_id==_primary_interface_ammo)
		{
			ammunition_count= get_player_weapon_ammo_count(current_player_index, desired_weapon, _primary_weapon);
		} else {
			ammunition_count= get_player_weapon_ammo_count(current_player_index, desired_weapon, _secondary_weapon);
		}
		
		/* IF we have ammo for this trigger.. */
		if(current_ammo_data->type!=_unused_interface_data && ammunition_count!=NONE)
		{
			if(current_ammo_data->type==_uses_energy)
			{
				/* Energy beam weapon-> progress bar type.. */
				short  fill_height;
				screen_rectangle bounds;

				/* Pin it.. */
				ammunition_count= PIN(ammunition_count, 0, current_ammo_data->ammo_across);
				fill_height= (ammunition_count*(current_ammo_data->delta_y-2))/current_ammo_data->ammo_across;
				
				/* Setup the energy left bar... */				
				bounds.left= current_ammo_data->screen_left;
				bounds.right= current_ammo_data->screen_left+current_ammo_data->delta_x;
				bounds.bottom= current_ammo_data->screen_top+current_ammo_data->delta_y;
				bounds.top= current_ammo_data->screen_top;
				
				/* Frame the rectangle */
				_frame_rect(&bounds, current_ammo_data->bullet);
				
				/* Inset the rectangle.. */
				bounds.left+=1; bounds.right-=1; bounds.bottom-= 1; bounds.top+=1;
				
				/* Fill with the full stuff.. */
				bounds.top= bounds.bottom-fill_height;
				_fill_rect(&bounds, current_ammo_data->bullet);

				/* Now erase the rest of the rectangle */
				bounds.bottom= bounds.top;
				bounds.top= current_ammo_data->screen_top+1;
				
				/* Fill it. */
				_fill_rect(&bounds, current_ammo_data->empty_bullet);
				
				/* We be done.. */
			} else {
				/* Uses ammunition, a little trickier.. */
				short row, x, y;
				screen_rectangle destination, source;
				short max, partial_row_count;
				
				x= current_ammo_data->screen_left;
				y= current_ammo_data->screen_top;
				
				destination.left= x;
				destination.top= y;
				
				/* Pin it.. */
				max= current_ammo_data->ammo_down*current_ammo_data->ammo_across;
				ammunition_count= PIN(ammunition_count, 0, max);
									
				/* Draw all of the full rows.. */
				for(row=0; row<(ammunition_count/current_ammo_data->ammo_across); ++row)
				{
					_draw_screen_shape_at_x_y(current_ammo_data->bullet,
						x, y);
					y+= current_ammo_data->delta_y;
				}
				
				/* Draw the partially used row.. */
				partial_row_count= ammunition_count%current_ammo_data->ammo_across;
				if(partial_row_count)
				{
					/* If we use ammo from right to left.. */
					if(current_ammo_data->right_to_left)
					{
						/* Draw the unused part of the row.. */
						destination.left= x, destination.top= y;
						destination.right= x+(partial_row_count*current_ammo_data->delta_x);
						destination.bottom= y+current_ammo_data->delta_y;
						source= destination;
						_offset_screen_rect(&source, -source.left, -source.top);
						_draw_screen_shape(current_ammo_data->bullet, &destination, &source);
						
						/* Draw the used part of the row.. */
						destination.left= destination.right, 
						destination.right= destination.left+(current_ammo_data->ammo_across-partial_row_count)*current_ammo_data->delta_x;
						source= destination;
						_offset_screen_rect(&source, -source.left, -source.top);
						_draw_screen_shape(current_ammo_data->empty_bullet, &destination, &source);
					} else {
						/* Draw the used part of the row.. */
						destination.left= x, destination.top= y;
						destination.right= x+(current_ammo_data->ammo_across-partial_row_count)*current_ammo_data->delta_x;
						destination.bottom= y+current_ammo_data->delta_y;
						source= destination;
						_offset_screen_rect(&source, -source.left, -source.top);
						_draw_screen_shape(current_ammo_data->empty_bullet, &destination, &source);
						
						/* Draw the unused part of the row */
						destination.left= destination.right;
						destination.right= destination.left+(partial_row_count*current_ammo_data->delta_x);
						source= destination;
						_offset_screen_rect(&source, -source.left, -source.top);
						_draw_screen_shape(current_ammo_data->bullet, &destination, &source);
					}
					y+= current_ammo_data->delta_y;
				}
				
				/* Draw the remaining rows. */
				x= current_ammo_data->screen_left;
				for(row=0; row<(max-ammunition_count)/current_ammo_data->ammo_across; ++row)
				{
					_draw_screen_shape_at_x_y(current_ammo_data->empty_bullet,
						x, y);
					y+= current_ammo_data->delta_y;
				}
			}
		}
	}
}
void HUD_SW_Class::FillRect(screen_rectangle *r, short color_index)
{
	_fill_rect(r, color_index);
}
Esempio n. 7
0
void _erase_screen(short color_index)
{
	_fill_rect(NULL, color_index);
}
Esempio n. 8
0
void _fill_screen_rectangle(screen_rectangle *rectangle, short color_index)
{
	_fill_rect(rectangle, color_index);
}