예제 #1
0
파일: snap.c 프로젝트: anvil0fcrom/cabrio
int snap_set( struct game *game ) {
	const struct config_snap *config = &config_get()->iface.theme.snap;
	char *filename;

	snap_clear();
	texture = NULL;
	video = 0;
	
	platform_texture = game->platform->texture;
	
	filename = game_media_get( game, MEDIA_VIDEO, NULL );
	if( filename && filename[0] ) {
		if( video_open( filename ) == 0 ) {
			video = 1;
			texture = video_texture();
		}
	}
	
	if( !texture ) {
		filename = game_media_get( game, MEDIA_IMAGE, image_type_name(IMAGE_SCREENSHOT) );
		if( filename && filename[0] ) {
			texture = sdl_create_texture( filename );
		}
		else {
			return -1;
		}
	}

	if( texture ) {
		if( config->fix_aspect_ratio ) {
			if( texture->width > texture->height ) {
				/* Landscape */
				width = MAX_SIZE;
				height = MAX_SIZE / ogl_aspect_ratio();
			}
			else {
				/* Portrait */
				height = MAX_SIZE;
				width = MAX_SIZE / ogl_aspect_ratio();
			}				
		}
		else {
			if( texture->width > texture->height ) {
				/* Landscape */
				height = (int)(float)texture->height/((float)texture->width/MAX_SIZE);
				width = MAX_SIZE;
			}
			else {
				/* Portrait */
				width = (int)(float)texture->width/((float)texture->height/MAX_SIZE);
				height = MAX_SIZE;
			}
		}
		return 0;
	}

	return -1;
}
예제 #2
0
파일: game.c 프로젝트: psychomantys/cabrio
int game_load_texture( struct game *game ) {	
	const char *filename = game_media_get( game, MEDIA_IMAGE, game_image_type );
	
	if( game->texture ) {
		game_free_texture( game );
	}

	if( game && filename ) {
		game->texture = sdl_create_texture( filename );
	}
	if( game->texture == NULL ) {
		if( game && game->name && *game->name ) {
			game->texture = font_create_texture( game->name );
		}
		else {
			game->texture = font_create_texture( "<No Name>" );
		}
	}

	if( game->texture == NULL ) {
		return -1;
	}
	else {
		if( game->texture->width > game->texture->height ) {
			/* Landscape */
			if( game->texture->width > IMAGE_MAX_WIDTH ) {
				game->texture->height = (int)(float)game->texture->height/((float)game->texture->width/IMAGE_MAX_WIDTH);
				game->texture->width = IMAGE_MAX_WIDTH;
			}
		}
		else {
			/* Portrait (or square) */
			if( game->texture->height > IMAGE_MAX_HEIGHT ) {
				game->texture->width = (int)(float)game->texture->width/((float)game->texture->height/IMAGE_MAX_HEIGHT);
				game->texture->height = IMAGE_MAX_HEIGHT;
			}
		}
	}

	return 0;
}
예제 #3
0
void game_sel_draw( void ) {
	if( idle_counter && !game_sel_busy() ) {
		idle_counter--;
		if( idle_counter == 0 && game_tile_current->game ) {
			bg_set( game_media_get( game_tile_current->game, MEDIA_IMAGE, image_type_name(IMAGE_BACKGROUND) ) );
			snap_set( game_tile_current->game );
		}
	}
	if( visible ) {
		if( scroll_direction != 0 ) {
			step += scroll_direction;
			if( step > steps-1 ) {
				game_sel_shuffle_forward( 1 );
				if( game_tile_current->next )
					game_tile_current = game_tile_current->next;
				step = 0;
			}
			game_sel_draw_step( step );
			if( step == 0 ) {
				scroll_direction = 0;
				idle_counter = idle_time;
			}
		}
		else {
			step += -hide_direction;
			game_sel_draw_step( step );
			if( step > steps-1 || step == 0 ) {
				if( hide_direction < 0 ) {
					visible = 0;
					game_sel_free_textures();
				}
				hide_direction = 0;
				if( skipping != 0 ) {
					game_sel_do_skip();
					idle_counter = idle_time;
				}
			}
		}
	}
}