2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2007-12-23 10:56:02 +00:00
|
|
|
/** @file gfx_func.h Functions related to the gfx engine. */
|
2007-03-01 01:24:44 +00:00
|
|
|
|
2007-09-09 10:13:17 +00:00
|
|
|
/**
|
|
|
|
* @defgroup dirty Dirty
|
|
|
|
*
|
|
|
|
* Handles the repaint of some part of the screen.
|
|
|
|
*
|
|
|
|
* Some places in the code are called functions which makes something "dirty".
|
|
|
|
* This has nothing to do with making a Tile or Window darker or less visible.
|
|
|
|
* This term comes from memory caching and is used to define an object must
|
|
|
|
* be repaint. If some data of an object (like a Tile, Window, Vehicle, whatever)
|
|
|
|
* are changed which are so extensive the object must be repaint its marked
|
|
|
|
* as "dirty". The video driver repaint this object instead of the whole screen
|
|
|
|
* (this is btw. also possible if needed). This is used to avoid a
|
|
|
|
* flickering of the screen by the video driver constantly repainting it.
|
|
|
|
*
|
|
|
|
* This whole mechanism is controlled by an rectangle defined in #_invalid_rect. This
|
|
|
|
* rectangle defines the area on the screen which must be repaint. If a new object
|
|
|
|
* needs to be repainted this rectangle is extended to 'catch' the object on the
|
|
|
|
* screen. At some point (which is normaly uninteressted for patch writers) this
|
|
|
|
* rectangle is send to the video drivers method
|
|
|
|
* VideoDriver::MakeDirty and it is truncated back to an empty rectangle. At some
|
|
|
|
* later point (which is uninteressted, too) the video driver
|
|
|
|
* repaints all these saved rectangle instead of the whole screen and drop the
|
|
|
|
* rectangle informations. Then a new round begins by marking objects "dirty".
|
|
|
|
*
|
|
|
|
* @see VideoDriver::MakeDirty
|
|
|
|
* @see _invalid_rect
|
|
|
|
* @see _screen
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2007-12-23 10:56:02 +00:00
|
|
|
#ifndef GFX_FUNC_H
|
|
|
|
#define GFX_FUNC_H
|
|
|
|
|
|
|
|
#include "gfx_type.h"
|
|
|
|
#include "strings_type.h"
|
2007-01-13 14:43:46 +00:00
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void GameLoop();
|
2007-01-13 14:43:46 +00:00
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void CreateConsole();
|
2007-01-13 14:43:46 +00:00
|
|
|
|
2007-03-01 01:24:44 +00:00
|
|
|
extern byte _dirkeys; ///< 1 = left, 2 = up, 4 = right, 8 = down
|
2007-01-13 14:43:46 +00:00
|
|
|
extern bool _fullscreen;
|
|
|
|
extern CursorVars _cursor;
|
2007-03-01 01:24:44 +00:00
|
|
|
extern bool _ctrl_pressed; ///< Is Ctrl pressed?
|
|
|
|
extern bool _shift_pressed; ///< Is Shift pressed?
|
2007-01-13 14:43:46 +00:00
|
|
|
extern byte _fast_forward;
|
|
|
|
|
|
|
|
extern bool _left_button_down;
|
|
|
|
extern bool _left_button_clicked;
|
|
|
|
extern bool _right_button_down;
|
|
|
|
extern bool _right_button_clicked;
|
|
|
|
|
|
|
|
extern DrawPixelInfo _screen;
|
2008-01-11 17:12:41 +00:00
|
|
|
extern bool _screen_disable_anim; ///< Disable palette animation (important for 32bpp-anim blitter during giant screenshot)
|
2007-01-13 14:43:46 +00:00
|
|
|
|
|
|
|
extern int _pal_first_dirty;
|
2007-06-19 15:04:08 +00:00
|
|
|
extern int _pal_count_dirty;
|
2007-01-13 14:43:46 +00:00
|
|
|
extern int _num_resolutions;
|
|
|
|
extern uint16 _resolutions[32][2];
|
|
|
|
extern uint16 _cur_resolution[2];
|
|
|
|
extern Colour _cur_palette[256];
|
|
|
|
|
|
|
|
void HandleKeypress(uint32 key);
|
2008-02-17 17:00:43 +00:00
|
|
|
void HandleCtrlChanged();
|
2007-03-07 11:47:46 +00:00
|
|
|
void HandleMouseEvents();
|
2007-01-13 14:43:46 +00:00
|
|
|
void CSleep(int milliseconds);
|
2007-03-07 11:47:46 +00:00
|
|
|
void UpdateWindows();
|
2007-01-13 14:43:46 +00:00
|
|
|
|
2007-08-19 09:38:30 +00:00
|
|
|
void DrawChatMessage();
|
2007-03-07 11:47:46 +00:00
|
|
|
void DrawMouseCursor();
|
|
|
|
void ScreenSizeChanged();
|
|
|
|
void HandleExitGameRequest();
|
|
|
|
void GameSizeChanged();
|
|
|
|
void UndrawMouseCursor();
|
2007-01-13 14:43:46 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
void RedrawScreenRect(int left, int top, int right, int bottom);
|
|
|
|
void GfxScroll(int left, int top, int width, int height, int xo, int yo);
|
2005-07-17 15:54:57 +00:00
|
|
|
|
2007-10-05 21:49:15 +00:00
|
|
|
void DrawSprite(SpriteID img, SpriteID pal, int x, int y, const SubSprite *sub = NULL);
|
2005-09-10 07:38:03 +00:00
|
|
|
|
2005-07-17 15:54:57 +00:00
|
|
|
int DrawStringCentered(int x, int y, StringID str, uint16 color);
|
2005-07-17 19:23:18 +00:00
|
|
|
int DrawStringCenteredTruncated(int xl, int xr, int y, StringID str, uint16 color);
|
2005-07-19 22:12:04 +00:00
|
|
|
int DoDrawStringCentered(int x, int y, const char *str, uint16 color);
|
2005-07-17 15:54:57 +00:00
|
|
|
|
|
|
|
int DrawString(int x, int y, StringID str, uint16 color);
|
|
|
|
int DrawStringTruncated(int x, int y, StringID str, uint16 color, uint maxw);
|
|
|
|
|
2005-02-06 18:30:45 +00:00
|
|
|
int DoDrawString(const char *string, int x, int y, uint16 color);
|
2005-07-17 15:54:57 +00:00
|
|
|
int DoDrawStringTruncated(const char *str, int x, int y, uint16 color, uint maxw);
|
|
|
|
|
|
|
|
void DrawStringCenterUnderline(int x, int y, StringID str, uint16 color);
|
2005-07-17 19:23:18 +00:00
|
|
|
void DrawStringCenterUnderlineTruncated(int xl, int xr, int y, StringID str, uint16 color);
|
2005-07-17 15:54:57 +00:00
|
|
|
|
2006-08-20 10:50:23 +00:00
|
|
|
int DrawStringRightAligned(int x, int y, StringID str, uint16 color);
|
2005-07-17 15:54:57 +00:00
|
|
|
void DrawStringRightAlignedTruncated(int x, int y, StringID str, uint16 color, uint maxw);
|
2006-08-20 10:50:23 +00:00
|
|
|
void DrawStringRightAlignedUnderline(int x, int y, StringID str, uint16 color);
|
2005-07-17 15:54:57 +00:00
|
|
|
|
2008-03-26 10:08:17 +00:00
|
|
|
void DrawCharCentered(uint32 c, int x, int y, uint16 color);
|
|
|
|
|
2004-09-10 19:02:27 +00:00
|
|
|
void GfxFillRect(int left, int top, int right, int bottom, int color);
|
|
|
|
void GfxDrawLine(int left, int top, int right, int bottom, int color);
|
2007-09-26 19:27:29 +00:00
|
|
|
void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-12-22 23:30:28 +00:00
|
|
|
Dimension GetStringBoundingBox(const char *str);
|
2006-10-27 09:55:38 +00:00
|
|
|
uint32 FormatStringLinebreaks(char *str, int maxw);
|
2007-03-07 11:47:46 +00:00
|
|
|
void LoadStringWidthTable();
|
2005-11-13 21:16:34 +00:00
|
|
|
void DrawStringMultiCenter(int x, int y, StringID str, int maxw);
|
2007-03-25 16:09:36 +00:00
|
|
|
uint DrawStringMultiLine(int x, int y, StringID str, int maxw, int maxh = -1);
|
2007-09-09 10:13:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Let the dirty blocks repainting by the video driver.
|
|
|
|
*
|
|
|
|
* @ingroup dirty
|
|
|
|
*/
|
2007-03-07 11:47:46 +00:00
|
|
|
void DrawDirtyBlocks();
|
2007-09-09 10:13:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a new dirty block.
|
|
|
|
*
|
|
|
|
* @ingroup dirty
|
|
|
|
*/
|
2004-08-09 17:04:08 +00:00
|
|
|
void SetDirtyBlocks(int left, int top, int right, int bottom);
|
2007-09-09 10:13:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Marks the whole screen as dirty.
|
|
|
|
*
|
|
|
|
* @ingroup dirty
|
|
|
|
*/
|
2007-03-07 11:47:46 +00:00
|
|
|
void MarkWholeScreenDirty();
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void GfxInitPalettes();
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-28 07:33:51 +00:00
|
|
|
bool FillDrawPixelInfo(DrawPixelInfo* n, int left, int top, int width, int height);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-01 01:24:44 +00:00
|
|
|
/* window.cpp */
|
2004-08-09 17:04:08 +00:00
|
|
|
void DrawOverlappedWindowForAll(int left, int top, int right, int bottom);
|
|
|
|
|
2007-01-14 19:57:49 +00:00
|
|
|
void SetMouseCursor(SpriteID sprite, SpriteID pal);
|
2007-02-24 15:05:14 +00:00
|
|
|
void SetAnimatedMouseCursor(const AnimCursor *table);
|
2007-03-07 11:47:46 +00:00
|
|
|
void CursorTick();
|
|
|
|
void DrawMouseCursor();
|
|
|
|
void ScreenSizeChanged();
|
|
|
|
void UndrawMouseCursor();
|
2004-08-09 17:04:08 +00:00
|
|
|
bool ChangeResInGame(int w, int h);
|
2005-05-14 21:01:57 +00:00
|
|
|
void SortResolutions(int count);
|
2008-01-01 14:20:48 +00:00
|
|
|
bool ToggleFullScreen(bool fs);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-01 01:24:44 +00:00
|
|
|
/* gfx.cpp */
|
2005-02-21 18:59:54 +00:00
|
|
|
#define ASCII_LETTERSTART 32
|
2006-05-09 13:23:04 +00:00
|
|
|
extern FontSize _cur_fontsize;
|
|
|
|
|
2006-11-16 22:05:33 +00:00
|
|
|
byte GetCharacterWidth(FontSize size, uint32 key);
|
2006-05-09 13:23:04 +00:00
|
|
|
|
|
|
|
static inline byte GetCharacterHeight(FontSize size)
|
2005-02-21 19:14:16 +00:00
|
|
|
{
|
2006-05-09 13:23:04 +00:00
|
|
|
switch (size) {
|
|
|
|
default: NOT_REACHED();
|
|
|
|
case FS_NORMAL: return 10;
|
|
|
|
case FS_SMALL: return 6;
|
|
|
|
case FS_LARGE: return 18;
|
|
|
|
}
|
2005-02-21 19:14:16 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-12-23 10:56:02 +00:00
|
|
|
extern DrawPixelInfo *_cur_dpi;
|
2007-11-04 00:08:57 +00:00
|
|
|
|
2006-08-29 19:26:13 +00:00
|
|
|
/**
|
|
|
|
* All 16 colour gradients
|
|
|
|
* 8 colours per gradient from darkest (0) to lightest (7)
|
|
|
|
*/
|
2007-12-23 10:56:02 +00:00
|
|
|
extern byte _colour_gradient[16][8];
|
2004-12-12 20:36:24 +00:00
|
|
|
|
2007-12-23 10:56:02 +00:00
|
|
|
extern bool _use_dos_palette;
|
2004-12-14 20:54:01 +00:00
|
|
|
|
2007-12-23 10:56:02 +00:00
|
|
|
#endif /* GFX_FUNC_H */
|