diff options
-rw-r--r-- | README | 6 | ||||
-rw-r--r-- | bitmap.c | 99 | ||||
-rw-r--r-- | bitmap.h | 12 | ||||
-rw-r--r-- | deck.c | 9 | ||||
-rw-r--r-- | game.c | 19 | ||||
-rw-r--r-- | game.h | 11 |
6 files changed, 13 insertions, 143 deletions
@@ -9,6 +9,12 @@ Latest version available at: http://toms-cafe.de/vdr/spider See the file COPYING for license information. +Requirements: +------------- + +- VDR >= 1.3.47 + + Description: ------------ @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: bitmap.c 2 2005-05-14 22:25:56Z tom $ + * $Id: bitmap.c 22 2006-04-24 23:26:30Z tom $ */ #include "bitmap.h" @@ -12,13 +12,6 @@ #include <vdr/osd.h> #include <ctype.h> -// Compatibility to older vdr versions -#if VDRVERSNUM < 10307 - #define tColor eDvbColor - #define DrawRectangle Fill - #define DrawPixel SetPixel -#endif - /** --- class Bitmap ------------------------------------------------------- **/ @@ -62,31 +55,6 @@ void Bitmap::text(const char* text, bool centered) { DrawRectangle(0, 0, Width() - 1, Height() - 1, clrWhite); frame(0, 0, Width() - 1, Height() - 1, clrRed); - -#if VDRVERSNUM < 10307 - SetFont(fontOsd); - int lineCount; - char* wrapper = textWrapper(text, &lineCount); - int y = max((Height() - lineCount * cOsd::LineHeight()) / 2, 0); - char* line = wrapper; - while (*line) - { - char* newline = strchr(line, '\n'); - if (newline) - *newline = 0; - int x = 0; - if (centered) - x = max((Width() - Width(line)) / 2, 0); - Text(x, y, line, clrBlack, clrWhite); - if (newline) - *newline = '\n'; - if (!newline) - break; - line = newline + 1; - y += cOsd::LineHeight(); - } - free(wrapper); -#else const cFont* font = cFont::GetFont(fontOsd); cTextWrapper wrapper(text, font, Width()); int y = max((Height() - wrapper.Lines() * font->Height()) / 2, 0); @@ -97,7 +65,6 @@ void Bitmap::text(const char* text, bool centered) x = max((Width() - font->Width(wrapper.GetLine(l))) / 2, 0); DrawText(x, y, wrapper.GetLine(l), clrBlack, clrWhite, font); } -#endif } /** Draw a frame into the bitmap */ @@ -173,11 +140,7 @@ bool Bitmap::loadXpm(const char* FileName, tColor NoneColor) ptr += 2; if (*ptr == '#') { int col = strtoul(++ptr, NULL, 16); -#if VDRVERSNUM < 10307 - pal[temp] = 0xff000000 | ((col & 0xff) << 16) | (col & 0xff00) | ((col & 0xff0000) >> 16); -#else pal[temp] = 0xff000000 | col; -#endif } else { pal[temp] = NoneColor; @@ -211,63 +174,3 @@ bool Bitmap::loadXpm(const char* FileName, tColor NoneColor) } return bRet; } - -#if VDRVERSNUM < 10307 -/** Wrap the text to fit into the bitmap - taken from font.c in VDR 1.3.7 */ -char *Bitmap::textWrapper(const char *Text, int *p_lines) -{ - char *text = strdup(Text); - int lines = 1; - - char *Blank = NULL; - char *Delim = NULL; - int w = 0; - - stripspace(text); // strips trailing newlines - - for (char *p = text; *p; ) { - if (*p == '\n') { - lines++; - w = 0; - Blank = Delim = NULL; - p++; - continue; - } - else if (isspace(*p)) - Blank = p; - int cw = Width(*p); - if (w + cw > Width()) { - if (Blank) { - *Blank = '\n'; - p = Blank; - continue; - } - else { - // Here's the ugly part, where we don't have any whitespace to - // punch in a newline, so we need to make room for it: - if (Delim) - p = Delim + 1; // let's fall back to the most recent delimiter - char *s = MALLOC(char, strlen(text) + 2); // The additional '\n' plus the terminating '\0' - int l = p - text; - strncpy(s, text, l); - s[l] = '\n'; - strcpy(s + l + 1, p); - free(text); - text = s; - p = text + l; - continue; - } - } - else - w += cw; - if (strchr("-.,:;!?_", *p)) { - Delim = p; - Blank = NULL; - } - p++; - } - if (p_lines != NULL) - *p_lines = lines; - return text; -} -#endif @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: bitmap.h 5 2005-05-15 18:40:40Z tom $ + * $Id: bitmap.h 22 2006-04-24 23:26:30Z tom $ */ #ifndef VDR_SPIDER_BITMAP_H @@ -14,11 +14,6 @@ #include <vdr/osdbase.h> #include <vdr/osd.h> -// Compatibility to older vdr versions -#if VDRVERSNUM < 10307 - #define tColor eDvbColor -#endif - /** --- class Bitmap ------------------------------------------------------- **/ @@ -47,11 +42,6 @@ public: /** Load a bitmap from an xpm file - taken from ElchiAIO4d patch */ bool loadXpm(const char* FileName, tColor NoneColor = clrTransparent); - -#if VDRVERSNUM < 10307 - /** Wrap the text to fit into the bitmap - taken from font.c in VDR 1.3.7 */ - char *textWrapper(const char *Text, int *p_lines); -#endif }; #endif // VDR_SPIDER_BITMAP_H @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: deck.c 2 2005-05-14 22:25:56Z tom $ + * $Id: deck.c 22 2006-04-24 23:26:30Z tom $ */ #include "deck.h" @@ -15,12 +15,7 @@ /** Random number 0 .. max-1 */ unsigned int rand(unsigned int max) { - static unsigned int seed = -#if VDRVERSNUM >= 10318 - cTimeMs::Now(); -#else - time_ms(); -#endif + static unsigned int seed = cTimeMs::Now(); return (unsigned int)((double)max * rand_r(&seed) / (RAND_MAX + 1.0)); } @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: game.c 7 2005-05-16 14:11:51Z tom $ + * $Id: game.c 22 2006-04-24 23:26:30Z tom $ */ #include "game.h" @@ -17,23 +17,6 @@ #include <vdr/osdbase.h> #include <vdr/osd.h> -// Compatibility to older vdr versions -#if VDRVERSNUM < 10307 - #define tColor eDvbColor - #define DrawRectangle Fill - #define DrawBitmap SetBitmap - #define cOsdProvider cOsd - #define NewOsd OpenRaw - struct tArea { int x1, y1, x2, y2, bpp; }; - #define SetAreas(a,n) Create(a->x1, a->y1,\ - a->x2 - a->x1 + 1, a->y2 - a->y1 + 1,\ - a->bpp, true) - #define clrGray50 clrBackground - #define Color GetColor - #define savePalette(bitmap) savePalette(2) - #define SetPalette(palette, area) Width('X') -#endif - // Defintions for bitmaps const int cursorWidth = 16; @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: game.h 5 2005-05-15 18:40:40Z tom $ + * $Id: game.h 22 2006-04-24 23:26:30Z tom $ */ #ifndef VDR_SPIDER_GAME_H @@ -19,13 +19,6 @@ class Bitmap; #include <vdr/osdbase.h> #include <vdr/osd.h> -// Compatibility to older vdr versions -#if VDRVERSNUM < 10307 - #define cOsd_ cOsdBase -#else - #define cOsd_ cOsd -#endif - /** --- class SpiderGame --------------------------------------------------- **/ @@ -37,7 +30,7 @@ private: int width, height; int xPos, yPos; int xDist, yDist; - cOsd_* osd; + cOsd* osd; Bitmap* info; const char* infoText; Deck* deck; |