improvements to the title screen
This commit is contained in:
parent
803f389782
commit
0953fcf905
3 changed files with 31 additions and 28 deletions
|
@ -230,13 +230,15 @@ SDL_Surface* get_image(const std::string& filename, TYPE type, COLOUR_ADJUSTMENT
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if(pixel_format != NULL) {
|
||||
SDL_Surface* const conv = SDL_DisplayFormat(surf);
|
||||
SDL_FreeSurface(surf);
|
||||
surf = conv;
|
||||
}
|
||||
if(adjust_colour != NO_FORMAT_ADJUSTMENT) {
|
||||
if(pixel_format != NULL) {
|
||||
SDL_Surface* const conv = SDL_DisplayFormat(surf);
|
||||
SDL_FreeSurface(surf);
|
||||
surf = conv;
|
||||
}
|
||||
|
||||
SDL_SetColorKey(surf,SDL_SRCCOLORKEY,SDL_MapRGB(surf->format,0,0,0));
|
||||
SDL_SetColorKey(surf,SDL_SRCCOLORKEY,SDL_MapRGB(surf->format,0,0,0));
|
||||
}
|
||||
|
||||
i = images_.insert(std::pair<std::string,SDL_Surface*>(filename,surf)).first;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace image {
|
|||
|
||||
enum TYPE { UNSCALED, SCALED, FOGGED, GREYED, BRIGHTENED };
|
||||
|
||||
enum COLOUR_ADJUSTMENT { ADJUST_COLOUR, NO_ADJUST_COLOUR };
|
||||
enum COLOUR_ADJUSTMENT { ADJUST_COLOUR, NO_ADJUST_COLOUR, NO_FORMAT_ADJUSTMENT };
|
||||
|
||||
//function to get the surface corresponding to an image.
|
||||
//note that this surface must be freed by the user by calling
|
||||
|
|
|
@ -736,47 +736,48 @@ network::connection network_data_dialog(display& disp, const std::string& msg, c
|
|||
|
||||
void fade_logo(display& screen, int xpos, int ypos)
|
||||
{
|
||||
const scoped_sdl_surface logo_unscaled(image::get_image(game_config::game_logo,image::UNSCALED));
|
||||
if(logo_unscaled == NULL) {
|
||||
const scoped_sdl_surface logo(image::get_image(game_config::game_logo,image::UNSCALED,image::NO_FORMAT_ADJUSTMENT));
|
||||
if(logo == NULL) {
|
||||
std::cerr << "Could not find game logo\n";
|
||||
return;
|
||||
}
|
||||
|
||||
const scoped_sdl_surface logo(scale_surface(logo_unscaled,(logo_unscaled->w*screen.x())/1024,(logo_unscaled->h*screen.y())/768));
|
||||
if(logo == NULL) {
|
||||
std::cerr << "Could not find game logo\n";
|
||||
SDL_Surface* const fb = screen.video().getSurface();
|
||||
|
||||
if(xpos < 0 || ypos < 0 || xpos + logo->w > fb->w || ypos + logo->h > fb->h) {
|
||||
return;
|
||||
}
|
||||
|
||||
//only once, when the game is first started, the logo fades in
|
||||
static bool faded_in = false;
|
||||
|
||||
if(!faded_in) {
|
||||
faded_in = true;
|
||||
CKey key;
|
||||
CKey key;
|
||||
bool last_button = key[SDLK_ESCAPE] || key[SDLK_SPACE];
|
||||
|
||||
bool last_button = key[SDLK_ESCAPE] || key[SDLK_SPACE];
|
||||
for(int x = 0; x != logo->w; ++x) {
|
||||
SDL_Rect srcrect = {x,0,1,logo->h};
|
||||
SDL_Rect dstrect = {xpos+x,ypos,1,logo->h};
|
||||
|
||||
for(int i = 0; i < 170; i += 5) {
|
||||
SDL_BlitSurface(logo,&srcrect,fb,&dstrect);
|
||||
|
||||
update_rect(dstrect);
|
||||
|
||||
if(!faded_in && (x%5) == 0) {
|
||||
const bool new_button = key[SDLK_ESCAPE] || key[SDLK_SPACE];
|
||||
if(new_button && !last_button)
|
||||
break;
|
||||
if(new_button && !last_button) {
|
||||
faded_in = true;
|
||||
}
|
||||
|
||||
last_button = new_button;
|
||||
|
||||
SDL_SetAlpha(logo,SDL_SRCALPHA,i);
|
||||
screen.blit_surface(xpos,ypos,logo);
|
||||
update_rect(xpos,ypos,logo->w,logo->h);
|
||||
screen.video().flip();
|
||||
SDL_Delay(20);
|
||||
screen.update_display();
|
||||
|
||||
SDL_Delay(10);
|
||||
events::pump();
|
||||
}
|
||||
}
|
||||
|
||||
SDL_SetAlpha(logo,SDL_SRCALPHA,255);
|
||||
screen.blit_surface(xpos,ypos,logo);
|
||||
update_rect(xpos,ypos,logo->w,logo->h);
|
||||
screen.video().flip();
|
||||
faded_in = true;
|
||||
}
|
||||
|
||||
TITLE_RESULT show_title(display& screen)
|
||||
|
|
Loading…
Add table
Reference in a new issue