static short max_displayable_inventory_lines( void) { screen_rectangle *destination= get_interface_rectangle(_inventory_rect); return (destination->bottom-destination->top)/_get_font_line_height(_interface_font); }
static void update_suit_oxygen( short time_elapsed) { static short delay_time= 0; /* Redraw the oxygen only if the interface is visible and only if enough delay has passed.. */ if(((delay_time-= time_elapsed)<0) || time_elapsed==NONE || interface_state.oxygen_is_dirty) { screen_rectangle *oxygen_rect= get_interface_rectangle(_oxygen_rect); short width, actual_width; short suit_oxygen; suit_oxygen= MIN(current_player->suit_oxygen, PLAYER_MAXIMUM_SUIT_OXYGEN); width= oxygen_rect->right-oxygen_rect->left; actual_width= (suit_oxygen*width)/PLAYER_MAXIMUM_SUIT_OXYGEN; draw_bar(oxygen_rect, actual_width, BUILD_DESCRIPTOR(_collection_interface, _oxygen_bar_right), BUILD_DESCRIPTOR(_collection_interface, _oxygen_bar), BUILD_DESCRIPTOR(_collection_interface, _empty_oxygen_bar)); delay_time= DELAY_TICKS_BETWEEN_OXYGEN_REDRAW; interface_state.oxygen_is_dirty= FALSE; } return; }
static void draw_player_name( void) { struct player_data *player= get_player_data(current_player_index); screen_rectangle *player_name_rect= get_interface_rectangle(_player_name_rect); _draw_screen_text(player->name, player_name_rect, _center_vertical | _center_horizontal, _player_name_font, player->color+PLAYER_COLOR_BASE_INDEX); }
static void calculate_inventory_rectangle_from_offset( screen_rectangle *r, short offset) { screen_rectangle *inventory_rect= get_interface_rectangle(_inventory_rect); short line_height= _get_font_line_height(_interface_font); *r= *inventory_rect; r->top += offset*line_height; r->bottom= r->top + line_height; }
/* ---------- private code */ static void update_suit_energy( short time_elapsed) { /* time_elapsed==NONE means force redraw */ if (time_elapsed==NONE || (interface_state.shield_is_dirty)) { screen_rectangle *shield_rect= get_interface_rectangle(_shield_rect); short width= shield_rect->right-shield_rect->left; short actual_width, suit_energy; short background_shape_id, bar_shape_id, bar_top_shape_id; suit_energy = current_player->suit_energy%PLAYER_MAXIMUM_SUIT_ENERGY; if( !suit_energy && current_player->suit_energy==PLAYER_MAXIMUM_SUIT_ENERGY || current_player->suit_energy==2*PLAYER_MAXIMUM_SUIT_ENERGY || current_player->suit_energy==3*PLAYER_MAXIMUM_SUIT_ENERGY) { suit_energy= PLAYER_MAXIMUM_SUIT_ENERGY; } actual_width= (suit_energy*width)/PLAYER_MAXIMUM_SUIT_ENERGY; /* Setup the bars.. */ if(current_player->suit_energy>2*PLAYER_MAXIMUM_SUIT_ENERGY) { background_shape_id= _double_energy_bar; bar_shape_id= _triple_energy_bar; bar_top_shape_id= _triple_energy_bar_right; } else if(current_player->suit_energy>PLAYER_MAXIMUM_SUIT_ENERGY) { background_shape_id= _energy_bar; bar_shape_id= _double_energy_bar; bar_top_shape_id= _double_energy_bar_right; } else { background_shape_id= _empty_energy_bar; bar_shape_id= _energy_bar; bar_top_shape_id= _energy_bar_right; if(current_player->suit_energy<0) actual_width= 0; } draw_bar(shield_rect, actual_width, BUILD_DESCRIPTOR(_collection_interface, bar_top_shape_id), BUILD_DESCRIPTOR(_collection_interface, bar_shape_id), BUILD_DESCRIPTOR(_collection_interface, background_shape_id)); interface_state.shield_is_dirty= FALSE; } return; }
void HUD_SW_Class::update_motion_sensor(short time_elapsed) { if (!(GET_GAME_OPTIONS() & _motion_sensor_does_not_work) && MotionSensorActive) { if (motion_sensor_has_changed() || time_elapsed == NONE) { render_motion_sensor(time_elapsed); ForceUpdate = true; screen_rectangle *r = get_interface_rectangle(_motion_sensor_rect); DrawShapeAtXY(BUILD_DESCRIPTOR(_collection_interface, _motion_sensor_mount), r->left, r->top); } } }
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 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; }
/* 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, §ion_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; }
/* 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; } }