1 /*
2 * Copyright (C) 2004 Tom Bradley
3 * tojabr@shiftygames.com
4 *
5 * file: logo.c
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software Foundation,
19 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 *
21 */
22
23 #include "ShiftyEngine.h"
24
25 extern void SE_Redraw();
26
27 static SDL_Surface * mainScreen = 0;
28 static SDL_Surface * logo = 0;
29 static SDL_Surface * icon = 0;
30
31 static Uint32 init = 0;
32 Uint32 logoShowing = 0;
33
34 Sint32 ICON_X = 0;
35 Sint32 ICON_Y = 0;
36 Sint32 ICON_W = 0;
37 Sint32 ICON_H = 0;
38
39 /*****************************************************
40 ****************************************************/
showIcon()41 void showIcon()
42 {
43 SDL_Rect dest;
44
45 if(!init) {
46 SE_Error("Logo module has not been initialized yet.");
47 return;
48 }
49
50 dest.x = ICON_X;
51 dest.y = ICON_Y;
52 if(SDL_BlitSurface(icon, 0, mainScreen, &dest) != 0)
53 SE_Error("A Blit failed.");
54 }
55
56 /*****************************************************
57 ****************************************************/
showLogo()58 static void showLogo()
59 {
60 SDL_Rect dest;
61
62 logoShowing = 1;
63
64 dest.x = (mainScreen->w/2) - (logo->w/2) ;
65 dest.y = (mainScreen->h/2) - (logo->h/2) ;
66 if(SDL_BlitSurface(logo, 0, mainScreen, &dest) != 0)
67 SE_Error("A Blit failed.");
68 }
69
70 /*****************************************************
71 ****************************************************/
hideLogo()72 static void hideLogo()
73 {
74 logoShowing = 0;
75 }
76
77 /*****************************************************
78 ****************************************************/
logoClicked()79 void logoClicked()
80 {
81 if(!init) {
82 SE_Error("Logo module has not been initialized yet.");
83 return;
84 }
85
86 if(!logoShowing) {
87 showLogo();
88 SDL_UpdateRect(mainScreen, 0, 0, 0, 0);
89 }
90 else {
91 hideLogo();
92 SE_Redraw();
93 }
94 }
95
96 /*****************************************************
97 ****************************************************/
initLogo(SDL_Surface * surface)98 void initLogo(SDL_Surface * surface)
99 {
100 logo = loadPNGDisplay("pics/shiftygames.png");
101 icon = loadPNG("pics/sg_icon.png");
102
103 mainScreen = surface;
104
105 ICON_H = icon->h;
106 ICON_W = icon->w - 15;
107 ICON_X = 0;
108 ICON_Y = mainScreen->h - ICON_H;
109
110 init = 1;
111 }
112