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: typedef struct ColorList { truelight@0: byte unk0, unk1, unk2; truelight@0: byte window_color_1a, window_color_1b; truelight@0: byte window_color_bga, window_color_bgb; truelight@0: byte window_color_2; truelight@0: } ColorList; 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 { truelight@0: Point pos, size, offs, delta; truelight@0: Point draw_pos, draw_size; Darkvater@1914: CursorID sprite; truelight@0: truelight@0: int wheel; // mouse wheel movement Darkvater@1914: const CursorID *animate_list, *animate_cur; truelight@0: uint animate_timeout; truelight@0: truelight@0: bool visible; truelight@0: bool dirty; truelight@0: bool fix_at; truelight@0: } CursorVars; truelight@0: truelight@0: 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() tron@2407: #define UPARROW "\x80" tron@2406: #define DOWNARROW "\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: Darkvater@2097: void DrawStringRightAligned(int x, int y, StringID str, uint16 color); Darkvater@2097: void DrawStringRightAlignedTruncated(int x, int y, StringID str, uint16 color, uint maxw); 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: void DrawFrameRect(int left, int top, int right, int bottom, int color, int flags); Darkvater@2436: uint16 GetDrawStringPlayerColor(PlayerID player); truelight@0: tron@1323: int GetStringWidth(const char *str); tron@1093: void LoadStringWidthTable(void); truelight@0: void DrawStringMultiCenter(int x, int y, uint16 str, int maxw); truelight@0: void DrawStringMultiLine(int x, int y, uint16 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@2548: bool FillDrawPixelInfo(DrawPixelInfo* n, const DrawPixelInfo* o, 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 truelight@0: VARDEF int _stringwidth_base; truelight@0: VARDEF byte _stringwidth_table[0x2A0]; Darkvater@1391: static inline byte GetCharacterWidth(uint key) Darkvater@1391: { Darkvater@1391: assert(key >= ASCII_LETTERSTART && key - ASCII_LETTERSTART < lengthof(_stringwidth_table)); Darkvater@1391: return _stringwidth_table[key - ASCII_LETTERSTART]; Darkvater@1391: } truelight@0: truelight@0: VARDEF DrawPixelInfo _screen; truelight@0: VARDEF DrawPixelInfo *_cur_dpi; truelight@0: VARDEF ColorList _color_list[16]; truelight@0: VARDEF CursorVars _cursor; truelight@0: 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: Darkvater@2436: #endif /* GFX_H */