tron@2186: /* $Id$ */ tron@2186: truelight@0: #ifndef GFX_H truelight@0: #define GFX_H truelight@0: tron@2062: typedef byte Pixel; truelight@0: truelight@0: struct DrawPixelInfo { tron@2062: Pixel *dst_ptr; truelight@0: int left, top, width, height; truelight@0: int pitch; truelight@193: uint16 zoom; truelight@0: }; truelight@0: truelight@0: truelight@0: typedef struct CursorVars { Darkvater@3312: Point pos, size, offs, delta; ///< position, size, offset from top-left, and movement Darkvater@3312: Point draw_pos, draw_size; ///< position and size bounding-box for drawing Darkvater@3312: CursorID sprite; ///< current image of cursor truelight@0: Darkvater@3312: int wheel; ///< mouse wheel movement Darkvater@3312: const CursorID *animate_list, *animate_cur; ///< in case of animated cursor, list of frames Darkvater@3312: uint animate_timeout; ///< current frame in list of animated cursor truelight@0: Darkvater@3312: bool visible; ///< cursor is visible Darkvater@3312: bool dirty; ///< the rect occupied by the mouse is dirty (redraw) Darkvater@3312: bool fix_at; ///< mouse is moving, but cursor is not (used for scrolling) Darkvater@3312: bool in_window; ///< mouse inside this window, determines drawing logic truelight@0: } CursorVars; truelight@0: truelight@0: peter1138@3798: typedef enum FontSizes { peter1138@3798: FS_NORMAL, peter1138@3798: FS_SMALL, peter1138@3798: FS_LARGE, peter1138@3798: FS_END, peter1138@3798: } FontSize; peter1138@3798: peter1138@3798: truelight@0: void RedrawScreenRect(int left, int top, int right, int bottom); truelight@0: void GfxScroll(int left, int top, int width, int height, int xo, int yo); Darkvater@2097: tron@2406: tron@2406: // XXX doesn't really belong here, but the only tron@2406: // consumers always use it in conjunction with DoDrawString() peter1138@5108: #define UPARROW "\xEE\x8A\x80" peter1138@5108: #define DOWNARROW "\xEE\x8A\xAA" tron@2406: tron@2406: Darkvater@2097: int DrawStringCentered(int x, int y, StringID str, uint16 color); Darkvater@2113: int DrawStringCenteredTruncated(int xl, int xr, int y, StringID str, uint16 color); Darkvater@2134: int DoDrawStringCentered(int x, int y, const char *str, uint16 color); Darkvater@2097: Darkvater@2097: int DrawString(int x, int y, StringID str, uint16 color); Darkvater@2097: int DrawStringTruncated(int x, int y, StringID str, uint16 color, uint maxw); Darkvater@2097: tron@1323: int DoDrawString(const char *string, int x, int y, uint16 color); Darkvater@2097: int DoDrawStringTruncated(const char *str, int x, int y, uint16 color, uint maxw); Darkvater@2097: Darkvater@2097: void DrawStringCenterUnderline(int x, int y, StringID str, uint16 color); Darkvater@2113: void DrawStringCenterUnderlineTruncated(int xl, int xr, int y, StringID str, uint16 color); Darkvater@2097: rubidium@4314: int DrawStringRightAligned(int x, int y, StringID str, uint16 color); Darkvater@2097: void DrawStringRightAlignedTruncated(int x, int y, StringID str, uint16 color, uint maxw); rubidium@4314: void DrawStringRightAlignedUnderline(int x, int y, StringID str, uint16 color); Darkvater@2097: truelight@193: void GfxFillRect(int left, int top, int right, int bottom, int color); truelight@193: void GfxDrawLine(int left, int top, int right, int bottom, int color); truelight@0: Darkvater@4609: BoundingRect GetStringBoundingBox(const char *str); Darkvater@4954: uint32 FormatStringLinebreaks(char *str, int maxw); tron@1093: void LoadStringWidthTable(void); tron@2634: void DrawStringMultiCenter(int x, int y, StringID str, int maxw); peter1138@4928: uint DrawStringMultiLine(int x, int y, StringID str, int maxw); tron@1093: void DrawDirtyBlocks(void); truelight@0: void SetDirtyBlocks(int left, int top, int right, int bottom); tron@1093: void MarkWholeScreenDirty(void); truelight@0: tron@1093: void GfxInitPalettes(void); truelight@0: tron@4429: bool FillDrawPixelInfo(DrawPixelInfo* n, int left, int top, int width, int height); truelight@0: truelight@0: /* window.c */ truelight@0: void DrawOverlappedWindowForAll(int left, int top, int right, int bottom); truelight@0: truelight@0: void SetMouseCursor(uint cursor); Darkvater@1914: void SetAnimatedMouseCursor(const CursorID *table); tron@1093: void CursorTick(void); tron@1093: void DrawMouseCursor(void); tron@1093: void ScreenSizeChanged(void); tron@1093: void UndrawMouseCursor(void); truelight@0: bool ChangeResInGame(int w, int h); Darkvater@1806: void SortResolutions(int count); Darkvater@1829: void ToggleFullScreen(bool fs); truelight@0: truelight@0: /* gfx.c */ Darkvater@1390: #define ASCII_LETTERSTART 32 peter1138@3798: extern FontSize _cur_fontsize; peter1138@3798: peter1138@5108: byte GetCharacterWidth(FontSize size, uint32 key); peter1138@3798: peter1138@3798: static inline byte GetCharacterHeight(FontSize size) peter1138@3798: { peter1138@3798: switch (size) { peter1138@3798: default: NOT_REACHED(); peter1138@3798: case FS_NORMAL: return 10; peter1138@3798: case FS_SMALL: return 6; peter1138@3798: case FS_LARGE: return 18; peter1138@3798: } Darkvater@1391: } truelight@0: truelight@0: VARDEF DrawPixelInfo _screen; truelight@0: VARDEF DrawPixelInfo *_cur_dpi; truelight@0: VARDEF CursorVars _cursor; truelight@0: tron@4444: enum { tron@4444: COLOUR_DARK_BLUE, tron@4444: COLOUR_PALE_GREEN, tron@4444: COLOUR_PINK, tron@4444: COLOUR_YELLOW, tron@4444: COLOUR_RED, tron@4444: COLOUR_LIGHT_BLUE, tron@4444: COLOUR_GREEN, tron@4444: COLOUR_DARK_GREEN, tron@4444: COLOUR_BLUE, tron@4444: COLOUR_CREAM, tron@4444: COLOUR_MAUVE, tron@4444: COLOUR_PURPLE, tron@4444: COLOUR_ORANGE, tron@4444: COLOUR_BROWN, tron@4444: COLOUR_GREY, tron@4444: COLOUR_WHITE tron@4444: }; tron@4444: tron@4444: /** tron@4444: * All 16 colour gradients tron@4444: * 8 colours per gradient from darkest (0) to lightest (7) tron@4444: */ tron@4444: VARDEF byte _colour_gradient[16][8]; tron@4444: truelight@0: VARDEF int _pal_first_dirty; truelight@0: VARDEF int _pal_last_dirty; truelight@0: dominik@614: VARDEF bool _use_dos_palette; dominik@614: tron@1991: typedef struct Colour { tron@1991: byte r; tron@1991: byte g; tron@1991: byte b; tron@1991: } Colour; tron@1991: tron@1991: extern Colour _cur_palette[256]; truelight@0: dominik@657: dominik@657: typedef enum StringColorFlags { dominik@657: IS_PALETTE_COLOR = 0x100, // color value is already a real palette color index, not an index of a StringColor dominik@657: } StringColorFlags; dominik@657: tron@2649: #ifdef _DEBUG tron@2649: extern bool _dbg_screen_rect; tron@2649: #endif tron@2649: Darkvater@2436: #endif /* GFX_H */