static void draw_message_area( short time_elapsed) { if(time_elapsed==NONE) { _draw_screen_shape_at_x_y( BUILD_DESCRIPTOR(_collection_interface, _network_panel), MESSAGE_AREA_X_OFFSET, MESSAGE_AREA_Y_OFFSET); draw_player_name(); } }
static void draw_bar( screen_rectangle *rectangle, short width, shape_descriptor top_piece, shape_descriptor full_bar, shape_descriptor background_texture) { screen_rectangle destination= *rectangle; screen_rectangle source; screen_rectangle bar_section; /* Draw the background (right). */ destination.left+= width; source= destination; _offset_screen_rect(&source, -rectangle->left, -rectangle->top); _draw_screen_shape(background_texture, &destination, &source); /* Draw the top bit.. */ if(width>2*TOP_OF_BAR_WIDTH) { _draw_screen_shape_at_x_y(top_piece, rectangle->left+width-TOP_OF_BAR_WIDTH, rectangle->top); } else { destination= *rectangle; /* Gotta take lines off the top, so that the bottom stuff is still visible.. */ destination.left= rectangle->left+width/2+width%2; destination.right= destination.left+width/2; source= destination; _offset_screen_rect(&source, -source.left+TOP_OF_BAR_WIDTH-width/2, -source.top); _draw_screen_shape(top_piece, &destination, &source); } /* Copy the bar.. */ bar_section= *rectangle; bar_section.right= bar_section.left+width-TOP_OF_BAR_WIDTH; if(bar_section.left<bar_section.right) { screen_rectangle bar_section_source= bar_section; _offset_screen_rect(&bar_section_source, -rectangle->left, -rectangle->top); _draw_screen_shape(full_bar, &bar_section, &bar_section_source); } }
static void update_motion_sensor( short time_elapsed) { if(!(GET_GAME_OPTIONS() & _motion_sensor_does_not_work)) { if (time_elapsed==NONE) { reset_motion_sensor(current_player_index); } motion_sensor_scan(time_elapsed); if (motion_sensor_has_changed()) { screen_rectangle *destination= get_interface_rectangle(_motion_sensor_rect); _draw_screen_shape_at_x_y(BUILD_DESCRIPTOR(_collection_interface, _motion_sensor_mount), destination->left, destination->top); } } return; }
/* 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; } }
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= ¤t_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::DrawShapeAtXY(shape_descriptor shape, short x, short y, bool transparency) { // "transparency" is only used for OpenGL motion sensor _draw_screen_shape_at_x_y(shape, x, y); }