void render_screen(short ticks_elapsed)
{
	// Make whatever changes are necessary to the world_view structure based on whichever player is frontmost
	world_view->ticks_elapsed = ticks_elapsed;
	world_view->tick_count = dynamic_world->tick_count;
	world_view->yaw = current_player->facing;
	world_view->pitch = current_player->elevation;
	world_view->maximum_depth_intensity = current_player->weapon_intensity;
	world_view->shading_mode = current_player->infravision_duration ? _shading_infravision : _shading_normal;

	// Suppress the overhead map if desired
	if (PLAYER_HAS_MAP_OPEN(current_player) && View_MapActive()) {
		if (!world_view->overhead_map_active)
			set_overhead_map_status(true);
	} else {
		if (world_view->overhead_map_active)
			set_overhead_map_status(false);
	}

	if(player_in_terminal_mode(current_player_index)) {
		if (!world_view->terminal_mode_active)
			set_terminal_status(true);
	} else {
		if (world_view->terminal_mode_active)
			set_terminal_status(false);
	}

	// Set rendering-window bounds for the current sort of display to render
	screen_mode_data *mode = &screen_mode;
	bool HighResolution;
	SDL_Rect ScreenRect = {0, 0, main_surface->w, main_surface->h};

	int msize = mode->size;
	assert(msize >= 0 && msize < NUMBER_OF_VIEW_SIZES);
	const ViewSizeData &VS = ViewSizes[msize];

	// Rectangle where the view is to go (must not overlap the HUD)
	int OverallWidth = VS.OverallWidth;
#ifdef PSP
	int OverallHeight = VS.OverallHeight - (TEST_FLAG(VS.flags, _view_show_HUD) ? 240 : 0);
#else
	int OverallHeight = VS.OverallHeight - (TEST_FLAG(VS.flags, _view_show_HUD) ? 160 : 0);
#endif
	int BufferWidth, BufferHeight;

	// Offsets for placement in the screen
	int ScreenOffsetWidth = ((ScreenRect.w - VS.OverallWidth) / 2) + ScreenRect.x;
	int ScreenOffsetHeight = ((ScreenRect.h - VS.OverallHeight) / 2) + ScreenRect.y;

	// HUD location
#ifdef PSP
	int HUD_Offset = 0;
	SDL_Rect HUD_DestRect = {ScreenOffsetWidth, OverallHeight + ScreenOffsetHeight, 480, 120};
#else
	int HUD_Offset = (OverallWidth - 640) / 2;
	SDL_Rect HUD_DestRect = {HUD_Offset + ScreenOffsetWidth, OverallHeight + ScreenOffsetHeight, 640, 160};
#endif

	bool ChangedSize = false;

	// Switching fullscreen mode requires much the same reinitialization as switching the screen size
	if (mode->fullscreen != PrevFullscreen) {
		PrevFullscreen = mode->fullscreen;
		ChangedSize = true;
	}

	// Each kind of display needs its own size
	if (world_view->terminal_mode_active) {
		// Standard terminal size
#ifdef PSP
		// MK: We need to scale the terminal
		//		to the PSP's max size
		BufferWidth = 480;
		BufferHeight = 272;
#else
		BufferWidth = 640;
		BufferHeight = 320;
#endif
		HighResolution = true;
	} else if (world_view->overhead_map_active) {
		// Fill the available space
		BufferWidth = OverallWidth;
		BufferHeight = OverallHeight;
		HighResolution = true;		
	} else {
		BufferWidth = VS.MainWidth;
		BufferHeight = VS.MainHeight;
		HighResolution = mode->high_resolution;
	}

	if (BufferWidth != PrevBufferWidth) {
		ChangedSize = true;
		PrevBufferWidth = BufferWidth;
	}
	if (BufferHeight != PrevBufferHeight) {
		ChangedSize = true;
		PrevBufferHeight = BufferHeight;
	}

	// Do the buffer/viewport rectangle setup:

	// First, the destination rectangle (viewport to be drawn in)
	int OffsetWidth = (OverallWidth - BufferWidth) / 2;
	int OffsetHeight = (OverallHeight - BufferHeight) / 2;
	SDL_Rect ViewRect = {OffsetWidth + ScreenOffsetWidth, OffsetHeight + ScreenOffsetHeight, BufferWidth, BufferHeight};

	if (OffsetWidth != PrevOffsetWidth) {
		ChangedSize = true;
		PrevOffsetWidth = OffsetWidth;
	}
	if (OffsetHeight != PrevOffsetHeight) {
		ChangedSize = true;
		PrevOffsetHeight = OffsetHeight;
	}

	// Now the buffer rectangle; be sure to shrink it as appropriate
	if (!HighResolution && screen_mode.acceleration == _no_acceleration) {
		BufferWidth >>= 1;
		BufferHeight >>= 1;
	}
Esempio n. 2
0
static void	change_panel_state(
	short player_index,
	short panel_side_index)
{
	short state, make_sound= FALSE;
	struct side_data *side= get_side_data(panel_side_index);
	struct player_data *player= get_player_data(player_index);
	struct control_panel_definition *definition= get_control_panel_definition(side->control_panel_type);

	state= GET_CONTROL_PANEL_STATUS(side);
	
	/* Do the right thing, based on the panel type.. */
	switch (definition->panel_class)
	{
		case _panel_is_oxygen_refuel:
		case _panel_is_shield_refuel:
		case _panel_is_double_shield_refuel:
		case _panel_is_triple_shield_refuel:
#ifndef VULCAN
			player->control_panel_side_index= player->control_panel_side_index==panel_side_index ? NONE : panel_side_index;
			state= get_recharge_status(panel_side_index);
			SET_CONTROL_PANEL_STATUS(side, state);
			if (!state) set_control_panel_texture(side);
#endif
			break;
		case _panel_is_computer_terminal:
#ifndef VULCAN
			if (get_game_state()==_game_in_progress && !PLAYER_HAS_CHEATED(player) && !PLAYER_HAS_MAP_OPEN(player))
			{
				/* this will handle changing levels, if necessary (i.e., if weÕre finished) */
				enter_computer_interface(player_index, side->control_panel_permutation, calculate_level_completion_state());
			}
#endif
			break;
		case _panel_is_tag_switch:
			if (definition->item==NONE || (!state && try_and_subtract_player_item(player_index, definition->item)))
			{
				state= !state;
				make_sound= set_tagged_light_statuses(side->control_panel_permutation, state);
				if (try_and_change_tagged_platform_states(side->control_panel_permutation, state)) make_sound= TRUE;
				if (!side->control_panel_permutation) make_sound= TRUE;
				if (make_sound)
				{
					SET_CONTROL_PANEL_STATUS(side, state);
					set_control_panel_texture(side);
				}
			}
			break;
		case _panel_is_light_switch:
			state= !state;
			make_sound= set_light_status(side->control_panel_permutation, state);
			break;
		case _panel_is_platform_switch:
			state= !state;
			make_sound= try_and_change_platform_state(get_polygon_data(side->control_panel_permutation)->permutation, state);
			break;
		case _panel_is_pattern_buffer:
#ifndef VULCAN
			if (dynamic_world->tick_count-player->ticks_at_last_successful_save>MINIMUM_RESAVE_TICKS &&
				player_controlling_game() && !PLAYER_HAS_CHEATED(local_player) && !game_is_networked)
			{
				play_control_panel_sound(panel_side_index, _activating_sound);
//				fade_out_background_music(30);

				/* Assume a successful save- prevents vidding of the save game key.. */
				player->ticks_at_last_successful_save= dynamic_world->tick_count;
				if (!save_game()) 
				{
					// AMR 3/12/97 vidding happens with InputSprocket with this here
					//player->ticks_at_last_successful_save= 0;
				}
//				fade_in_background_music(30);
			}
#endif
			break;

		default:
			halt();
	}
	
	if (make_sound)
	{
		play_control_panel_sound(panel_side_index, state ? _activating_sound : _deactivating_sound);
	}
	
	return;	
}