mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 01:29:43 +01:00
Add border to indicate taking screenshot
Originally, I was thinking of adding a notification text that you took a screenshot, but this is better because it is language-agnostic and it doesn't contribute to potential UI clutter/clashing. It flashes yellow if the screenshot successfully saved, and red if it didn't.
This commit is contained in:
parent
93ec2c6cca
commit
40f6f83328
5 changed files with 58 additions and 1 deletions
|
@ -364,6 +364,10 @@ void Game::init(void)
|
|||
old_mode_indicator_timer = 0;
|
||||
mode_indicator_timer = 0;
|
||||
|
||||
old_screenshot_border_timer = 0;
|
||||
screenshot_border_timer = 0;
|
||||
screenshot_saved_success = false;
|
||||
|
||||
setdefaultcontrollerbuttons();
|
||||
}
|
||||
|
||||
|
|
|
@ -592,6 +592,10 @@ public:
|
|||
|
||||
int old_mode_indicator_timer;
|
||||
int mode_indicator_timer;
|
||||
|
||||
int old_screenshot_border_timer;
|
||||
int screenshot_border_timer;
|
||||
bool screenshot_saved_success;
|
||||
};
|
||||
|
||||
#ifndef GAME_DEFINITION
|
||||
|
|
|
@ -3345,6 +3345,8 @@ void Graphics::screenshake(void)
|
|||
|
||||
copy_texture(gameTexture, NULL, &shake);
|
||||
|
||||
draw_screenshot_border();
|
||||
|
||||
set_render_target(gameTexture);
|
||||
clear();
|
||||
|
||||
|
@ -3370,6 +3372,8 @@ void Graphics::updatescreenshake(void)
|
|||
|
||||
void Graphics::render(void)
|
||||
{
|
||||
draw_screenshot_border();
|
||||
|
||||
if (gameScreen.badSignalEffect)
|
||||
{
|
||||
ApplyFilter(&tempFilterSrc, &tempFilterDest);
|
||||
|
@ -3423,6 +3427,46 @@ void Graphics::renderfixedpost(void)
|
|||
{
|
||||
--game.screenshake;
|
||||
}
|
||||
|
||||
game.old_screenshot_border_timer = game.screenshot_border_timer;
|
||||
if (game.screenshot_border_timer > 0)
|
||||
{
|
||||
game.screenshot_border_timer -= 15;
|
||||
}
|
||||
}
|
||||
|
||||
void Graphics::draw_screenshot_border(void)
|
||||
{
|
||||
const int border_alpha = lerp(game.old_screenshot_border_timer, game.screenshot_border_timer);
|
||||
|
||||
if (border_alpha <= 100)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
int result = query_texture(gameTexture, NULL, NULL, &width, &height);
|
||||
if (result != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const SDL_Rect rect_inner = {1, 1, width - 2, height - 2};
|
||||
|
||||
if (game.screenshot_saved_success)
|
||||
{
|
||||
set_color(196, 196, 20, border_alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
set_color(196, 20, 20, border_alpha);
|
||||
}
|
||||
|
||||
set_blendmode(SDL_BLENDMODE_BLEND);
|
||||
draw_rect(NULL);
|
||||
draw_rect(&rect_inner);
|
||||
set_blendmode(SDL_BLENDMODE_NONE);
|
||||
}
|
||||
|
||||
void Graphics::drawtele(int x, int y, int t, const SDL_Color color)
|
||||
|
|
|
@ -252,6 +252,8 @@ public:
|
|||
void renderfixedpre(void);
|
||||
void renderfixedpost(void);
|
||||
|
||||
void draw_screenshot_border(void);
|
||||
|
||||
bool Hitest(SDL_Surface* surface1, SDL_Point p1, SDL_Surface* surface2, SDL_Point p2);
|
||||
|
||||
void drawentities(void);
|
||||
|
|
|
@ -186,7 +186,10 @@ void KeyPoll::Poll(void)
|
|||
|
||||
if (evt.key.keysym.sym == SDLK_F6 && !evt.key.repeat)
|
||||
{
|
||||
SaveScreenshot();
|
||||
const bool success = SaveScreenshot();
|
||||
game.old_screenshot_border_timer = 255;
|
||||
game.screenshot_border_timer = 255;
|
||||
game.screenshot_saved_success = success;
|
||||
}
|
||||
|
||||
BUTTONGLYPHS_keyboard_set_active(true);
|
||||
|
|
Loading…
Reference in a new issue