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); } }
void set_interface_microphone_recording_state( boolean state) { #pragma unused (state) #ifdef OBSOLETE const short sounds[]={MICROPHONE_STOP_CLICK_SOUND, MICROPHONE_START_CLICK_SOUND}; const short shapes[]={_mike_button_unpressed, _mike_button_pressed}; screen_rectangle *rectangle= get_interface_rectangle(_microphone_rect); play_local_sound(sounds[state]); if(!game_window_is_full_screen()) { _draw_screen_shape(BUILD_DESCRIPTOR(_collection_interface, shapes[state]), rectangle, NULL); } #endif }
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::DrawShape(shape_descriptor shape, screen_rectangle *dest, screen_rectangle *src) { _draw_screen_shape(shape, dest, src); }