tron@2186: /* $Id$ */ tron@2186: rubidium@8619: /** @file gfx_func.h Functions related to the gfx engine. */ belugas@6505: rubidium@8041: /** rubidium@8041: * @defgroup dirty Dirty rubidium@8041: * rubidium@8041: * Handles the repaint of some part of the screen. rubidium@8041: * rubidium@8041: * Some places in the code are called functions which makes something "dirty". rubidium@8041: * This has nothing to do with making a Tile or Window darker or less visible. rubidium@8041: * This term comes from memory caching and is used to define an object must rubidium@8041: * be repaint. If some data of an object (like a Tile, Window, Vehicle, whatever) rubidium@8041: * are changed which are so extensive the object must be repaint its marked rubidium@8041: * as "dirty". The video driver repaint this object instead of the whole screen rubidium@8041: * (this is btw. also possible if needed). This is used to avoid a rubidium@8041: * flickering of the screen by the video driver constantly repainting it. rubidium@8041: * rubidium@8041: * This whole mechanism is controlled by an rectangle defined in #_invalid_rect. This rubidium@8041: * rectangle defines the area on the screen which must be repaint. If a new object rubidium@8041: * needs to be repainted this rectangle is extended to 'catch' the object on the rubidium@8041: * screen. At some point (which is normaly uninteressted for patch writers) this rubidium@8041: * rectangle is send to the video drivers method rubidium@8041: * VideoDriver::MakeDirty and it is truncated back to an empty rectangle. At some rubidium@8041: * later point (which is uninteressted, too) the video driver rubidium@8041: * repaints all these saved rectangle instead of the whole screen and drop the rubidium@8041: * rectangle informations. Then a new round begins by marking objects "dirty". rubidium@8041: * rubidium@8041: * @see VideoDriver::MakeDirty rubidium@8041: * @see _invalid_rect rubidium@8041: * @see _screen rubidium@8041: */ rubidium@8041: rubidium@8041: rubidium@8619: #ifndef GFX_FUNC_H rubidium@8619: #define GFX_FUNC_H KUDr@5887: rubidium@8619: #include "gfx_type.h" rubidium@8619: #include "strings_type.h" KUDr@5887: rubidium@6573: void GameLoop(); KUDr@5887: rubidium@6573: void CreateConsole(); KUDr@5887: belugas@6505: extern byte _dirkeys; ///< 1 = left, 2 = up, 4 = right, 8 = down KUDr@5887: extern bool _fullscreen; KUDr@5887: extern CursorVars _cursor; belugas@6505: extern bool _ctrl_pressed; ///< Is Ctrl pressed? belugas@6505: extern bool _shift_pressed; ///< Is Shift pressed? KUDr@5887: extern byte _fast_forward; KUDr@5887: KUDr@5887: extern bool _left_button_down; KUDr@5887: extern bool _left_button_clicked; KUDr@5887: extern bool _right_button_down; KUDr@5887: extern bool _right_button_clicked; KUDr@5887: KUDr@5887: extern DrawPixelInfo _screen; frosch@8745: extern bool _screen_disable_anim; ///< Disable palette animation (important for 32bpp-anim blitter during giant screenshot) KUDr@5887: KUDr@5887: extern int _pal_first_dirty; truelight@7456: extern int _pal_count_dirty; KUDr@5887: extern int _num_resolutions; smatz@10983: extern Dimension _resolutions[32]; smatz@10983: extern Dimension _cur_resolution; KUDr@5887: extern Colour _cur_palette[256]; KUDr@5887: KUDr@5887: void HandleKeypress(uint32 key); smatz@9082: void HandleCtrlChanged(); rubidium@6573: void HandleMouseEvents(); KUDr@5887: void CSleep(int milliseconds); rubidium@6573: void UpdateWindows(); KUDr@5887: rubidium@6573: void DrawMouseCursor(); rubidium@6573: void ScreenSizeChanged(); rubidium@6573: void GameSizeChanged(); rubidium@6573: void UndrawMouseCursor(); KUDr@5887: 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: rubidium@8177: void DrawSprite(SpriteID img, SpriteID pal, int x, int y, const SubSprite *sub = NULL); 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: rubidium@9233: void DrawCharCentered(uint32 c, int x, int y, uint16 color); rubidium@9233: 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); rubidium@8139: void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3); truelight@0: rubidium@8617: Dimension GetStringBoundingBox(const char *str); Darkvater@4954: uint32 FormatStringLinebreaks(char *str, int maxw); rubidium@6573: void LoadStringWidthTable(); tron@2634: void DrawStringMultiCenter(int x, int y, StringID str, int maxw); maedhros@6703: uint DrawStringMultiLine(int x, int y, StringID str, int maxw, int maxh = -1); rubidium@8041: rubidium@8041: /** rubidium@8041: * Let the dirty blocks repainting by the video driver. rubidium@8041: * rubidium@8041: * @ingroup dirty rubidium@8041: */ rubidium@6573: void DrawDirtyBlocks(); rubidium@8041: rubidium@8041: /** rubidium@8041: * Set a new dirty block. rubidium@8041: * rubidium@8041: * @ingroup dirty rubidium@8041: */ truelight@0: void SetDirtyBlocks(int left, int top, int right, int bottom); rubidium@8041: rubidium@8041: /** rubidium@8041: * Marks the whole screen as dirty. rubidium@8041: * rubidium@8041: * @ingroup dirty rubidium@8041: */ rubidium@6573: void MarkWholeScreenDirty(); truelight@0: rubidium@6573: void GfxInitPalettes(); truelight@0: tron@4429: bool FillDrawPixelInfo(DrawPixelInfo* n, int left, int top, int width, int height); truelight@0: belugas@6505: /* window.cpp */ truelight@0: void DrawOverlappedWindowForAll(int left, int top, int right, int bottom); truelight@0: peter1138@5919: void SetMouseCursor(SpriteID sprite, SpriteID pal); rubidium@6464: void SetAnimatedMouseCursor(const AnimCursor *table); rubidium@6573: void CursorTick(); truelight@0: bool ChangeResInGame(int w, int h); Darkvater@1806: void SortResolutions(int count); belugas@8667: bool ToggleFullScreen(bool fs); truelight@0: belugas@6505: /* gfx.cpp */ 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: rubidium@8619: extern DrawPixelInfo *_cur_dpi; belugas@8320: tron@4444: /** tron@4444: * All 16 colour gradients tron@4444: * 8 colours per gradient from darkest (0) to lightest (7) tron@4444: */ rubidium@8619: extern byte _colour_gradient[16][8]; dominik@614: rubidium@8619: extern bool _use_dos_palette; dominik@657: rubidium@8619: #endif /* GFX_FUNC_H */