From 9d89611be012faa23eacae873968fbd611c16267 Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Thu, 30 Oct 2008 21:55:26 +0000 Subject: [PATCH] Now showing svn revision in title bar and on title screen --- Makefile | 4 ++-- defs.h | 3 +++ getsvnrev.sh | 2 ++ globals.h | 2 ++ rc.c | 35 ++++++++++++++++++++++++++++++++--- 5 files changed, 41 insertions(+), 5 deletions(-) create mode 100755 getsvnrev.sh diff --git a/Makefile b/Makefile index a3593c7..63fb608 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ all: rc edit 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 - 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 ./makeapp.sh diff --git a/defs.h b/defs.h index 4ab3b1b..5c47308 100644 --- a/defs.h +++ b/defs.h @@ -39,6 +39,7 @@ // text sizes #define TEXTSIZE_POINTS 10 +#define TEXTSIZE_VER 13 #define TEXTSIZE_SCORE 14 #define TEXTSIZE_BONUS 20 #define TEXTSIZE_HELP 20 @@ -805,6 +806,7 @@ typedef struct imageset_s { imageset_t imageset[MAXPTYPES]; /* external globals */ +extern char progname[]; extern SDL_Color black; extern SDL_Surface *screen, *temps, *levelbg, *head, *head5, *icecube; extern SDL_Surface *healthbar[]; @@ -840,6 +842,7 @@ extern char *deathtext[]; extern char *bifftext[]; extern spriteinfo_t spriteinfo[]; + extern int gotcard; extern int curcard; extern int deck[]; diff --git a/getsvnrev.sh b/getsvnrev.sh new file mode 100755 index 0000000..f19af8d --- /dev/null +++ b/getsvnrev.sh @@ -0,0 +1,2 @@ +#!/bin/sh +svn info | grep Revision | cut -d " " -f 2 diff --git a/globals.h b/globals.h index 403b912..77fe83b 100644 --- a/globals.h +++ b/globals.h @@ -13,6 +13,8 @@ int gamemode; // easy or hard? spriteinfo_t spriteinfo[MAXPTYPES]; +char progname[MIDBUFLEN]; + char *datadir; int gotcard; // got a card yet this level? diff --git a/rc.c b/rc.c index 8b11cd2..924a6f3 100644 --- a/rc.c +++ b/rc.c @@ -153,6 +153,8 @@ SDL_Color grey2 = {90, 90, 90, 0}; SDL_Color green = {0, 255, 0, 0}; SDL_Color green2 = {0, 150, 0, 0}; SDL_Color yellow = {255, 255, 0, 0}; +SDL_Color greenish = {82, 125, 74, 0}; + int vidargs = 0; @@ -245,6 +247,9 @@ int main (int argc, char **argv) { datadir = strdup("data"); } + // set program name (including version string) + sprintf(progname, "Rat Catcher v0.%d", REV); + initsdl(); if (TTF_Init()) { printf("TTF_Init: %s\n", TTF_GetError()); @@ -6390,15 +6395,19 @@ void togglefullscreen(void) { //SDL_Quit(); // set fullscreen variable -/* if (fullscreen) { fullscreen = B_FALSE; } else { fullscreen = B_TRUE; } -*/ 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 SDL_BlitSurface(temps, NULL, screen, NULL); /* redo framerate manager */ @@ -6430,6 +6439,8 @@ void initsdl(void) { screen = SDL_SetVideoMode(640,480,16,SDL_SWSURFACE|vidargs); #endif + // set title bar + SDL_WM_SetCaption(progname, progname); if (!screen) { printf("Failed to open window: %s\n", SDL_GetError()); @@ -7794,8 +7805,9 @@ void docannoneffect(void) { void dotitlescreen(void) { char tempst[BUFLEN]; + char svnver[MIDBUFLEN]; SDL_Surface *titlebg; - SDL_Surface *cointext, *text, *text2, *easy, *norm; + SDL_Surface *cointext, *text, *text2, *easy, *norm, *ver; SDL_Event event; SDL_Rect area; int timer = 0; @@ -7822,6 +7834,10 @@ void dotitlescreen(void) { easy = TTF_RenderText_Solid(font[TEXTSIZE_TITLE], "Easy 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) { titlemode = TS_WAIT1UP; } else { @@ -7876,6 +7892,19 @@ void dotitlescreen(void) { 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 if ((titlemode == TS_INSERTCOIN) || (titlemode == TS_HISCORES)) { if (texton) {