Now showing svn revision in title bar and on title screen

This commit is contained in:
Rob Pearce 2008-10-30 21:55:26 +00:00
parent 9fccd26f15
commit 9d89611be0
5 changed files with 41 additions and 5 deletions

View File

@ -1,10 +1,10 @@
all: rc edit all: rc edit
rc: rc.c shared.c rc.h shared.h globals.h defs.h rc: rc.c shared.c rc.h shared.h globals.h defs.h
gcc -Wall -o rc -g rc.c shared.c `sdl-config --cflags --libs` -I/usr/local/include -L/usr/local/lib -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf -lSDL_mixer gcc -Wall -DREV=`./getsvnrev.sh` -o rc -g rc.c shared.c `sdl-config --cflags --libs` -I/usr/local/include -L/usr/local/lib -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf -lSDL_mixer
edit: edit.c shared.c edit.h shared.h globals.h defs.h edit: edit.c shared.c edit.h shared.h globals.h defs.h
gcc -D__EDITOR -Wall -o edit -g edit.c shared.c `sdl-config --cflags --libs` -I/usr/local/include -L/usr/local/lib -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf gcc -D__EDITOR -DREV=`./getsvnrev.sh` -Wall -o edit -g edit.c shared.c `sdl-config --cflags --libs` -I/usr/local/include -L/usr/local/lib -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf
app: rc app: rc
./makeapp.sh ./makeapp.sh

3
defs.h
View File

@ -39,6 +39,7 @@
// text sizes // text sizes
#define TEXTSIZE_POINTS 10 #define TEXTSIZE_POINTS 10
#define TEXTSIZE_VER 13
#define TEXTSIZE_SCORE 14 #define TEXTSIZE_SCORE 14
#define TEXTSIZE_BONUS 20 #define TEXTSIZE_BONUS 20
#define TEXTSIZE_HELP 20 #define TEXTSIZE_HELP 20
@ -805,6 +806,7 @@ typedef struct imageset_s {
imageset_t imageset[MAXPTYPES]; imageset_t imageset[MAXPTYPES];
/* external globals */ /* external globals */
extern char progname[];
extern SDL_Color black; extern SDL_Color black;
extern SDL_Surface *screen, *temps, *levelbg, *head, *head5, *icecube; extern SDL_Surface *screen, *temps, *levelbg, *head, *head5, *icecube;
extern SDL_Surface *healthbar[]; extern SDL_Surface *healthbar[];
@ -840,6 +842,7 @@ extern char *deathtext[];
extern char *bifftext[]; extern char *bifftext[];
extern spriteinfo_t spriteinfo[]; extern spriteinfo_t spriteinfo[];
extern int gotcard; extern int gotcard;
extern int curcard; extern int curcard;
extern int deck[]; extern int deck[];

2
getsvnrev.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
svn info | grep Revision | cut -d " " -f 2

View File

@ -13,6 +13,8 @@ int gamemode; // easy or hard?
spriteinfo_t spriteinfo[MAXPTYPES]; spriteinfo_t spriteinfo[MAXPTYPES];
char progname[MIDBUFLEN];
char *datadir; char *datadir;
int gotcard; // got a card yet this level? int gotcard; // got a card yet this level?

35
rc.c
View File

@ -153,6 +153,8 @@ SDL_Color grey2 = {90, 90, 90, 0};
SDL_Color green = {0, 255, 0, 0}; SDL_Color green = {0, 255, 0, 0};
SDL_Color green2 = {0, 150, 0, 0}; SDL_Color green2 = {0, 150, 0, 0};
SDL_Color yellow = {255, 255, 0, 0}; SDL_Color yellow = {255, 255, 0, 0};
SDL_Color greenish = {82, 125, 74, 0};
int vidargs = 0; int vidargs = 0;
@ -245,6 +247,9 @@ int main (int argc, char **argv) {
datadir = strdup("data"); datadir = strdup("data");
} }
// set program name (including version string)
sprintf(progname, "Rat Catcher v0.%d", REV);
initsdl(); initsdl();
if (TTF_Init()) { if (TTF_Init()) {
printf("TTF_Init: %s\n", TTF_GetError()); printf("TTF_Init: %s\n", TTF_GetError());
@ -6390,15 +6395,19 @@ void togglefullscreen(void) {
//SDL_Quit(); //SDL_Quit();
// set fullscreen variable // set fullscreen variable
/*
if (fullscreen) { if (fullscreen) {
fullscreen = B_FALSE; fullscreen = B_FALSE;
} else { } else {
fullscreen = B_TRUE; fullscreen = B_TRUE;
} }
*/
screen=SDL_SetVideoMode(screen->w,screen->h,screen->format->BitsPerPixel,SDL_SWSURFACE|(screen->flags&SDL_FULLSCREEN?0:SDL_FULLSCREEN)); screen=SDL_SetVideoMode(screen->w,screen->h,screen->format->BitsPerPixel,SDL_SWSURFACE|(screen->flags&SDL_FULLSCREEN?0:SDL_FULLSCREEN));
// set title bar if required
if (!fullscreen) {
SDL_WM_SetCaption(progname, progname);
}
// redraw background // redraw background
SDL_BlitSurface(temps, NULL, screen, NULL); SDL_BlitSurface(temps, NULL, screen, NULL);
/* redo framerate manager */ /* redo framerate manager */
@ -6430,6 +6439,8 @@ void initsdl(void) {
screen = SDL_SetVideoMode(640,480,16,SDL_SWSURFACE|vidargs); screen = SDL_SetVideoMode(640,480,16,SDL_SWSURFACE|vidargs);
#endif #endif
// set title bar
SDL_WM_SetCaption(progname, progname);
if (!screen) { if (!screen) {
printf("Failed to open window: %s\n", SDL_GetError()); printf("Failed to open window: %s\n", SDL_GetError());
@ -7794,8 +7805,9 @@ void docannoneffect(void) {
void dotitlescreen(void) { void dotitlescreen(void) {
char tempst[BUFLEN]; char tempst[BUFLEN];
char svnver[MIDBUFLEN];
SDL_Surface *titlebg; SDL_Surface *titlebg;
SDL_Surface *cointext, *text, *text2, *easy, *norm; SDL_Surface *cointext, *text, *text2, *easy, *norm, *ver;
SDL_Event event; SDL_Event event;
SDL_Rect area; SDL_Rect area;
int timer = 0; int timer = 0;
@ -7822,6 +7834,10 @@ void dotitlescreen(void) {
easy = TTF_RenderText_Solid(font[TEXTSIZE_TITLE], "Easy Mode", red2); easy = TTF_RenderText_Solid(font[TEXTSIZE_TITLE], "Easy Mode", red2);
norm = TTF_RenderText_Solid(font[TEXTSIZE_TITLE], "Normal Mode", red2); norm = TTF_RenderText_Solid(font[TEXTSIZE_TITLE], "Normal Mode", red2);
sprintf(svnver, "v0.%d",REV);
ver = TTF_RenderText_Solid(font[TEXTSIZE_VER], svnver, greenish);
if (credits > 0) { if (credits > 0) {
titlemode = TS_WAIT1UP; titlemode = TS_WAIT1UP;
} else { } else {
@ -7876,6 +7892,19 @@ void dotitlescreen(void) {
SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
} }
if (titlemode != TS_HISCORES) {
// version number
area.x = 640 - (ver->w) - 10;
area.y = 150;
SDL_SetColors(ver, &black, 1, 1);
SDL_BlitSurface(ver, NULL, screen, &area);
area.x -= 2;
area.y -= 2;
SDL_SetColors(ver, &greenish, 1, 1);
SDL_BlitSurface(ver, NULL, screen, &area);
}
// mode-specific text // mode-specific text
if ((titlemode == TS_INSERTCOIN) || (titlemode == TS_HISCORES)) { if ((titlemode == TS_INSERTCOIN) || (titlemode == TS_HISCORES)) {
if (texton) { if (texton) {