adding exit button
[drnoksnes] / platform / sdlvexit.cpp
1 #include <SDL.h>
2 #include <SDL_image.h>
3
4 #include "platform.h"
5 #include "sdlv.h"
6
7 #define DIE(format, ...) do { \
8                 fprintf(stderr, "Died at %s:%d: ", __FILE__, __LINE__ ); \
9                 fprintf(stderr, format "\n", ## __VA_ARGS__); \
10                 abort(); \
11         } while (0);
12
13 static SDL_Surface* buttonSrf = 0;
14 static SDL_Rect buttonRect;
15
16 static const unsigned long totalAnimLen = 1;
17
18 static unsigned long frameCounter = 0;
19
20 void exitReset()
21 {
22         frameCounter = 0;
23         if (!buttonSrf) {
24                 buttonSrf = IMG_Load("/usr/share/icons/hicolor/scalable/hildon/general_overlay_back.png");
25         }
26
27         buttonRect.x = GUI.Width - buttonSrf->w;
28         buttonRect.y = 0;
29         buttonRect.w = buttonSrf->w;
30         buttonRect.h = buttonSrf->h;
31 }
32
33 bool exitRequiresDraw()
34 {
35         if (!Config.fullscreen) return false;
36         if (frameCounter > totalAnimLen) {
37                 return false;
38         } else {
39                 frameCounter++;
40                 return true;
41         }
42         
43 };
44
45 void exitDraw(SDL_Surface* where)
46 {
47         SDL_BlitSurface(buttonSrf, 0, where, &buttonRect);
48 };
49