Files @ r5469:9c38e5ce3f50
Branch filter:

Location: cpp/openttd-patchpack/source/gfx.h - annotation

rubidium
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
r2186:5ee653b1b5e1
r2186:5ee653b1b5e1
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2062:c4c0326f1777
r0:d63b455452f6
r0:d63b455452f6
r2062:c4c0326f1777
r0:d63b455452f6
r0:d63b455452f6
r193:6aa65dc5a4b4
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r3312:4a98cf52081a
r3312:4a98cf52081a
r3312:4a98cf52081a
r0:d63b455452f6
r3312:4a98cf52081a
r3312:4a98cf52081a
r3312:4a98cf52081a
r0:d63b455452f6
r3312:4a98cf52081a
r3312:4a98cf52081a
r3312:4a98cf52081a
r3312:4a98cf52081a
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r3798:2d0f061b855c
r3798:2d0f061b855c
r3798:2d0f061b855c
r3798:2d0f061b855c
r3798:2d0f061b855c
r3798:2d0f061b855c
r3798:2d0f061b855c
r3798:2d0f061b855c
r0:d63b455452f6
r0:d63b455452f6
r2097:498a22d4bee9
r2406:ca53e91ceee1
r2406:ca53e91ceee1
r2406:ca53e91ceee1
r5108:28640689af54
r5108:28640689af54
r2406:ca53e91ceee1
r2406:ca53e91ceee1
r2097:498a22d4bee9
r2113:600d6ea0d897
r2134:f272effb5e6e
r2097:498a22d4bee9
r2097:498a22d4bee9
r2097:498a22d4bee9
r2097:498a22d4bee9
r1323:29249e0649f7
r2097:498a22d4bee9
r2097:498a22d4bee9
r2097:498a22d4bee9
r2113:600d6ea0d897
r2097:498a22d4bee9
r4314:b44be03a57b9
r2097:498a22d4bee9
r4314:b44be03a57b9
r2097:498a22d4bee9
r193:6aa65dc5a4b4
r193:6aa65dc5a4b4
r0:d63b455452f6
r4609:43908f0c2b9c
r4954:09db4a1c3b05
r1093:18f56ef2d029
r2634:a3ccca486bdf
r4928:b82ce7c78321
r1093:18f56ef2d029
r0:d63b455452f6
r1093:18f56ef2d029
r0:d63b455452f6
r1093:18f56ef2d029
r0:d63b455452f6
r4429:9a1fdade8310
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1914:63c34ade2fdf
r1093:18f56ef2d029
r1093:18f56ef2d029
r1093:18f56ef2d029
r1093:18f56ef2d029
r0:d63b455452f6
r1806:b8cc32d167b3
r1829:3dfbdb5a9e01
r0:d63b455452f6
r0:d63b455452f6
r1390:bd550d5f6790
r3798:2d0f061b855c
r3798:2d0f061b855c
r5108:28640689af54
r3798:2d0f061b855c
r3798:2d0f061b855c
r3798:2d0f061b855c
r3798:2d0f061b855c
r3798:2d0f061b855c
r3798:2d0f061b855c
r3798:2d0f061b855c
r3798:2d0f061b855c
r3798:2d0f061b855c
r1391:4c60d2b628fd
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r4444:45a8e5f3ceff
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r614:5ada491fc357
r614:5ada491fc357
r1991:24313d1020cd
r1991:24313d1020cd
r1991:24313d1020cd
r1991:24313d1020cd
r1991:24313d1020cd
r1991:24313d1020cd
r1991:24313d1020cd
r0:d63b455452f6
r657:a82164fd2bbd
r657:a82164fd2bbd
r657:a82164fd2bbd
r657:a82164fd2bbd
r657:a82164fd2bbd
r2649:e3cea2f1dbaf
r2649:e3cea2f1dbaf
r2649:e3cea2f1dbaf
r2649:e3cea2f1dbaf
r2436:963efe8b84cc
/* $Id$ */

#ifndef GFX_H
#define GFX_H

typedef byte Pixel;

struct DrawPixelInfo {
	Pixel *dst_ptr;
	int left, top, width, height;
	int pitch;
	uint16 zoom;
};


typedef struct CursorVars {
	Point pos, size, offs, delta; ///< position, size, offset from top-left, and movement
	Point draw_pos, draw_size;    ///< position and size bounding-box for drawing
	CursorID sprite; ///< current image of cursor

	int wheel;       ///< mouse wheel movement
	const CursorID *animate_list, *animate_cur; ///< in case of animated cursor, list of frames
	uint animate_timeout;                       ///< current frame in list of animated cursor

	bool visible;    ///< cursor is visible
	bool dirty;      ///< the rect occupied by the mouse is dirty (redraw)
	bool fix_at;     ///< mouse is moving, but cursor is not (used for scrolling)
	bool in_window;  ///< mouse inside this window, determines drawing logic
} CursorVars;


typedef enum FontSizes {
	FS_NORMAL,
	FS_SMALL,
	FS_LARGE,
	FS_END,
} FontSize;


void RedrawScreenRect(int left, int top, int right, int bottom);
void GfxScroll(int left, int top, int width, int height, int xo, int yo);


// XXX doesn't really belong here, but the only
// consumers always use it in conjunction with DoDrawString()
#define UPARROW   "\xEE\x8A\x80"
#define DOWNARROW "\xEE\x8A\xAA"


int DrawStringCentered(int x, int y, StringID str, uint16 color);
int DrawStringCenteredTruncated(int xl, int xr, int y, StringID str, uint16 color);
int DoDrawStringCentered(int x, int y, const char *str, uint16 color);

int DrawString(int x, int y, StringID str, uint16 color);
int DrawStringTruncated(int x, int y, StringID str, uint16 color, uint maxw);

int DoDrawString(const char *string, int x, int y, uint16 color);
int DoDrawStringTruncated(const char *str, int x, int y, uint16 color, uint maxw);

void DrawStringCenterUnderline(int x, int y, StringID str, uint16 color);
void DrawStringCenterUnderlineTruncated(int xl, int xr, int y, StringID str, uint16 color);

int DrawStringRightAligned(int x, int y, StringID str, uint16 color);
void DrawStringRightAlignedTruncated(int x, int y, StringID str, uint16 color, uint maxw);
void DrawStringRightAlignedUnderline(int x, int y, StringID str, uint16 color);

void GfxFillRect(int left, int top, int right, int bottom, int color);
void GfxDrawLine(int left, int top, int right, int bottom, int color);

BoundingRect GetStringBoundingBox(const char *str);
uint32 FormatStringLinebreaks(char *str, int maxw);
void LoadStringWidthTable(void);
void DrawStringMultiCenter(int x, int y, StringID str, int maxw);
uint DrawStringMultiLine(int x, int y, StringID str, int maxw);
void DrawDirtyBlocks(void);
void SetDirtyBlocks(int left, int top, int right, int bottom);
void MarkWholeScreenDirty(void);

void GfxInitPalettes(void);

bool FillDrawPixelInfo(DrawPixelInfo* n, int left, int top, int width, int height);

/* window.c */
void DrawOverlappedWindowForAll(int left, int top, int right, int bottom);

void SetMouseCursor(uint cursor);
void SetAnimatedMouseCursor(const CursorID *table);
void CursorTick(void);
void DrawMouseCursor(void);
void ScreenSizeChanged(void);
void UndrawMouseCursor(void);
bool ChangeResInGame(int w, int h);
void SortResolutions(int count);
void ToggleFullScreen(bool fs);

/* gfx.c */
#define ASCII_LETTERSTART 32
extern FontSize _cur_fontsize;

byte GetCharacterWidth(FontSize size, uint32 key);

static inline byte GetCharacterHeight(FontSize size)
{
	switch (size) {
		default: NOT_REACHED();
		case FS_NORMAL: return 10;
		case FS_SMALL:  return 6;
		case FS_LARGE:  return 18;
	}
}

VARDEF DrawPixelInfo _screen;
VARDEF DrawPixelInfo *_cur_dpi;
VARDEF CursorVars _cursor;

enum {
	COLOUR_DARK_BLUE,
	COLOUR_PALE_GREEN,
	COLOUR_PINK,
	COLOUR_YELLOW,
	COLOUR_RED,
	COLOUR_LIGHT_BLUE,
	COLOUR_GREEN,
	COLOUR_DARK_GREEN,
	COLOUR_BLUE,
	COLOUR_CREAM,
	COLOUR_MAUVE,
	COLOUR_PURPLE,
	COLOUR_ORANGE,
	COLOUR_BROWN,
	COLOUR_GREY,
	COLOUR_WHITE
};

/**
 * All 16 colour gradients
 * 8 colours per gradient from darkest (0) to lightest (7)
 */
VARDEF byte _colour_gradient[16][8];

VARDEF int _pal_first_dirty;
VARDEF int _pal_last_dirty;

VARDEF bool _use_dos_palette;

typedef struct Colour {
	byte r;
	byte g;
	byte b;
} Colour;

extern Colour _cur_palette[256];


typedef enum StringColorFlags {
	IS_PALETTE_COLOR = 0x100, // color value is already a real palette color index, not an index of a StringColor
} StringColorFlags;

#ifdef _DEBUG
extern bool _dbg_screen_rect;
#endif

#endif /* GFX_H */