src/gfx.h
author rubidium
Wed, 26 Sep 2007 19:27:29 +0000
changeset 7643 af32b07bc027
parent 7545 d44e19c5671e
child 7681 582e8912e8d1
permissions -rw-r--r--
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
Note that this is not completely glitch free, bounding boxes sometimes aren't removed properly. This is due to the fact that the bounding boxes sometimes are larger than the sprite, which causes a smaller part than the bounding box to be redrawn. This is NOT a bug, but a known implementation limit as we do not want to slow down normal games so the debug graphics are always 100% correct.
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2134
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2134
diff changeset
     2
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6146
diff changeset
     3
/** @file gfx.h */
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6146
diff changeset
     4
7545
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
     5
/**
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
     6
 * @defgroup dirty Dirty
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
     7
 *
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
     8
 * Handles the repaint of some part of the screen.
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
     9
 *
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    10
 * Some places in the code are called functions which makes something "dirty".
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    11
 * This has nothing to do with making a Tile or Window darker or less visible.
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    12
 * This term comes from memory caching and is used to define an object must
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    13
 * be repaint. If some data of an object (like a Tile, Window, Vehicle, whatever)
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    14
 * are changed which are so extensive the object must be repaint its marked
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    15
 * as "dirty". The video driver repaint this object instead of the whole screen
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    16
 * (this is btw. also possible if needed). This is used to avoid a
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    17
 * flickering of the screen by the video driver constantly repainting it.
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    18
 *
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    19
 * This whole mechanism is controlled by an rectangle defined in #_invalid_rect. This
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    20
 * rectangle defines the area on the screen which must be repaint. If a new object
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    21
 * needs to be repainted this rectangle is extended to 'catch' the object on the
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    22
 * screen. At some point (which is normaly uninteressted for patch writers) this
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    23
 * rectangle is send to the video drivers method
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    24
 * VideoDriver::MakeDirty and it is truncated back to an empty rectangle. At some
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    25
 * later point (which is uninteressted, too) the video driver
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    26
 * repaints all these saved rectangle instead of the whole screen and drop the
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    27
 * rectangle informations. Then a new round begins by marking objects "dirty".
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    28
 *
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    29
 * @see VideoDriver::MakeDirty
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    30
 * @see _invalid_rect
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    31
 * @see _screen
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    32
 */
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    33
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
    34
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
#ifndef GFX_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
#define GFX_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
6289
9f468eccc674 (svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents: 6248
diff changeset
    38
#include "openttd.h"
6624
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents: 6377
diff changeset
    39
#include "zoom.hpp"
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    40
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    41
enum WindowKeyCodes {
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    42
	WKC_SHIFT = 0x8000,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    43
	WKC_CTRL  = 0x4000,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    44
	WKC_ALT   = 0x2000,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    45
	WKC_META  = 0x1000,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    46
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6146
diff changeset
    47
	/* Special ones */
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    48
	WKC_NONE        =  0,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    49
	WKC_ESC         =  1,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    50
	WKC_BACKSPACE   =  2,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    51
	WKC_INSERT      =  3,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    52
	WKC_DELETE      =  4,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    53
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    54
	WKC_PAGEUP      =  5,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    55
	WKC_PAGEDOWN    =  6,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    56
	WKC_END         =  7,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    57
	WKC_HOME        =  8,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    58
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6146
diff changeset
    59
	/* Arrow keys */
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    60
	WKC_LEFT        =  9,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    61
	WKC_UP          = 10,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    62
	WKC_RIGHT       = 11,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    63
	WKC_DOWN        = 12,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    64
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6146
diff changeset
    65
	/* Return & tab */
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    66
	WKC_RETURN      = 13,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    67
	WKC_TAB         = 14,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    68
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6146
diff changeset
    69
	/* Space */
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    70
	WKC_SPACE       = 32,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    71
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6146
diff changeset
    72
	/* Function keys */
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    73
	WKC_F1          = 33,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    74
	WKC_F2          = 34,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    75
	WKC_F3          = 35,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    76
	WKC_F4          = 36,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    77
	WKC_F5          = 37,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    78
	WKC_F6          = 38,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    79
	WKC_F7          = 39,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    80
	WKC_F8          = 40,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    81
	WKC_F9          = 41,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    82
	WKC_F10         = 42,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    83
	WKC_F11         = 43,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    84
	WKC_F12         = 44,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    85
7311
fde7a4d92a39 (svn r10663) -Fix r10662: bad me, didn't comply with coding style, as penalty I updated the surrounding code to comply with coding style too; I will never do it again (I hope :p)
truelight
parents: 7310
diff changeset
    86
	/* Backquote is the key left of "1"
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6146
diff changeset
    87
	 * we only store this key here, no matter what character is really mapped to it
6729
302e2c8fff07 (svn r9961) -Fix (r7182): some file were still in iso8859-15 instead of utf8.
rubidium
parents: 6705
diff changeset
    88
	 * on a particular keyboard. (US keyboard: ` and ~ ; German keyboard: ^ and °) */
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    89
	WKC_BACKQUOTE   = 45,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    90
	WKC_PAUSE       = 46,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
    91
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6146
diff changeset
    92
	/* 0-9 are mapped to 48-57
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6146
diff changeset
    93
	 * A-Z are mapped to 65-90
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6146
diff changeset
    94
	 * a-z are mapped to 97-122 */
7310
eed5036fee1f (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 6999
diff changeset
    95
7541
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
    96
	/* Numerical keyboard */
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
    97
	WKC_NUM_0       = 128,
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
    98
	WKC_NUM_1       = 129,
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
    99
	WKC_NUM_2       = 130,
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   100
	WKC_NUM_3       = 131,
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   101
	WKC_NUM_4       = 132,
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   102
	WKC_NUM_5       = 133,
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   103
	WKC_NUM_6       = 134,
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   104
	WKC_NUM_7       = 135,
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   105
	WKC_NUM_8       = 136,
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   106
	WKC_NUM_9       = 137,
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   107
	WKC_NUM_DIV     = 138,
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   108
	WKC_NUM_MUL     = 139,
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   109
	WKC_NUM_MINUS   = 140,
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   110
	WKC_NUM_PLUS    = 141,
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   111
	WKC_NUM_ENTER   = 142,
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   112
	WKC_NUM_DECIMAL = 143,
7310
eed5036fee1f (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 6999
diff changeset
   113
7541
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   114
	/* Other keys */
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   115
	WKC_SLASH       = 144, ///< / Forward slash
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   116
	WKC_SEMICOLON   = 145, ///< ; Semicolon
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   117
	WKC_EQUALS      = 146, ///< = Equals
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   118
	WKC_L_BRACKET   = 147, ///< [ Left square bracket
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   119
	WKC_BACKSLASH   = 148, ///< \ Backslash
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   120
	WKC_R_BRACKET   = 149, ///< ] Right square bracket
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   121
	WKC_SINGLEQUOTE = 150, ///< ' Single quote
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   122
	WKC_COMMA       = 151, ///< , Comma
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   123
	WKC_PERIOD      = 152, ///< . Period
8086db74ec5b (svn r11061) -Fix [FS#1086]: [win32] some keys were handled twice
glx
parents: 7454
diff changeset
   124
	WKC_MINUS       = 153, ///< - Minus
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   125
};
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   126
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   127
enum GameModes {
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   128
	GM_MENU,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   129
	GM_NORMAL,
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   130
	GM_EDITOR
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   131
};
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   132
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   133
void GameLoop();
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   134
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   135
void CreateConsole();
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   136
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   137
typedef int32 CursorID;
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   138
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   139
struct Point {
7318
632cd0497770 (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents: 7311
diff changeset
   140
	int x, y;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   141
};
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   142
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   143
struct Rect {
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   144
	int left,top,right,bottom;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   145
};
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   146
6138
f1196498ef66 (svn r8880) -Codechange: make anim cursors an array of structs.
rubidium
parents: 5941
diff changeset
   147
/** A single sprite of a list of animated cursors */
f1196498ef66 (svn r8880) -Codechange: make anim cursors an array of structs.
rubidium
parents: 5941
diff changeset
   148
struct AnimCursor {
6146
179f7480cf6b (svn r8889) -Fix (r8880): a CursorID is not a SpriteID.
rubidium
parents: 6138
diff changeset
   149
	static const CursorID LAST = MAX_UVALUE(CursorID);
6138
f1196498ef66 (svn r8880) -Codechange: make anim cursors an array of structs.
rubidium
parents: 5941
diff changeset
   150
	CursorID sprite;   ///< Must be set to LAST_ANIM when it is the last sprite of the loop
f1196498ef66 (svn r8880) -Codechange: make anim cursors an array of structs.
rubidium
parents: 5941
diff changeset
   151
	byte display_time; ///< Amount of ticks this sprite will be shown
f1196498ef66 (svn r8880) -Codechange: make anim cursors an array of structs.
rubidium
parents: 5941
diff changeset
   152
};
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   153
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   154
struct CursorVars {
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   155
	Point pos, size, offs, delta; ///< position, size, offset from top-left, and movement
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   156
	Point draw_pos, draw_size;    ///< position and size bounding-box for drawing
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5636
diff changeset
   157
	SpriteID sprite; ///< current image of cursor
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5636
diff changeset
   158
	SpriteID pal;
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   159
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   160
	int wheel;       ///< mouse wheel movement
6289
9f468eccc674 (svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents: 6248
diff changeset
   161
9f468eccc674 (svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents: 6248
diff changeset
   162
	/* We need two different vars to keep track of how far the scrollwheel moved.
9f468eccc674 (svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents: 6248
diff changeset
   163
	 * OSX uses this for scrolling around the map. */
9f468eccc674 (svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents: 6248
diff changeset
   164
	int v_wheel;
9f468eccc674 (svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents: 6248
diff changeset
   165
	int h_wheel;
9f468eccc674 (svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents: 6248
diff changeset
   166
6138
f1196498ef66 (svn r8880) -Codechange: make anim cursors an array of structs.
rubidium
parents: 5941
diff changeset
   167
	const AnimCursor *animate_list; ///< in case of animated cursor, list of frames
f1196498ef66 (svn r8880) -Codechange: make anim cursors an array of structs.
rubidium
parents: 5941
diff changeset
   168
	const AnimCursor *animate_cur;  ///< in case of animated cursor, current frame
f1196498ef66 (svn r8880) -Codechange: make anim cursors an array of structs.
rubidium
parents: 5941
diff changeset
   169
	uint animate_timeout;           ///< in case of animated cursor, number of ticks to show the current cursor
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   170
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   171
	bool visible;    ///< cursor is visible
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   172
	bool dirty;      ///< the rect occupied by the mouse is dirty (redraw)
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   173
	bool fix_at;     ///< mouse is moving, but cursor is not (used for scrolling)
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   174
	bool in_window;  ///< mouse inside this window, determines drawing logic
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   175
};
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   176
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   177
struct DrawPixelInfo {
6878
5cefd3ac59c7 (svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents: 6729
diff changeset
   178
	void *dst_ptr;
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   179
	int left, top, width, height;
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   180
	int pitch;
6624
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents: 6377
diff changeset
   181
	ZoomLevel zoom;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   182
};
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   183
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   184
struct Colour {
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   185
	byte r;
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   186
	byte g;
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   187
	byte b;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   188
};
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   189
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   190
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   191
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6146
diff changeset
   192
extern byte _dirkeys;        ///< 1 = left, 2 = up, 4 = right, 8 = down
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   193
extern bool _fullscreen;
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   194
extern CursorVars _cursor;
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6146
diff changeset
   195
extern bool _ctrl_pressed;   ///< Is Ctrl pressed?
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6146
diff changeset
   196
extern bool _shift_pressed;  ///< Is Shift pressed?
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   197
extern byte _fast_forward;
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   198
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   199
extern bool _left_button_down;
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   200
extern bool _left_button_clicked;
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   201
extern bool _right_button_down;
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   202
extern bool _right_button_clicked;
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   203
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   204
extern DrawPixelInfo _screen;
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   205
extern bool _exit_game;
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   206
extern bool _networking;         ///< are we in networking mode?
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   207
extern byte _game_mode;
6231
ff7454d35935 (svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents: 6179
diff changeset
   208
extern byte _pause_game;
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   209
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   210
extern int _pal_first_dirty;
6960
356d856462b6 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 6937
diff changeset
   211
extern int _pal_count_dirty;
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   212
extern int _num_resolutions;
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   213
extern uint16 _resolutions[32][2];
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   214
extern uint16 _cur_resolution[2];
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   215
extern Colour _cur_palette[256];
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   216
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   217
void HandleKeypress(uint32 key);
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   218
void HandleMouseEvents();
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   219
void CSleep(int milliseconds);
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   220
void UpdateWindows();
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   221
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   222
uint32 InteractiveRandom(); //< Used for random sequences that are not the same on the other end of the multiplayer link
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   223
uint InteractiveRandomRange(uint max);
7454
e55eea8c05c7 (svn r10932) -Codechange: replace "text" with "chat" for the chat related function and variables.
rubidium
parents: 7318
diff changeset
   224
void DrawChatMessage();
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   225
void DrawMouseCursor();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   226
void ScreenSizeChanged();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   227
void HandleExitGameRequest();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   228
void GameSizeChanged();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   229
void UndrawMouseCursor();
5636
3c19b56dc982 (svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents: 5587
diff changeset
   230
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
   231
#include "helpers.hpp"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   232
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   233
enum FontSize {
3798
b1f5290b36b1 (svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents: 3312
diff changeset
   234
	FS_NORMAL,
b1f5290b36b1 (svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents: 3312
diff changeset
   235
	FS_SMALL,
b1f5290b36b1 (svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents: 3312
diff changeset
   236
	FS_LARGE,
b1f5290b36b1 (svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents: 3312
diff changeset
   237
	FS_END,
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   238
};
3798
b1f5290b36b1 (svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents: 3312
diff changeset
   239
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
   240
DECLARE_POSTFIX_INCREMENT(FontSize);
3798
b1f5290b36b1 (svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents: 3312
diff changeset
   241
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   242
void RedrawScreenRect(int left, int top, int right, int bottom);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   243
void GfxScroll(int left, int top, int width, int height, int xo, int yo);
2097
e95d19e1941f (svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents: 2062
diff changeset
   244
2406
8c873205483a (svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents: 2187
diff changeset
   245
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6146
diff changeset
   246
/* XXX doesn't really belong here, but the only
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6146
diff changeset
   247
 * consumers always use it in conjunction with DoDrawString() */
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 4954
diff changeset
   248
#define UPARROW   "\xEE\x8A\x80"
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 4954
diff changeset
   249
#define DOWNARROW "\xEE\x8A\xAA"
2406
8c873205483a (svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents: 2187
diff changeset
   250
8c873205483a (svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents: 2187
diff changeset
   251
2097
e95d19e1941f (svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents: 2062
diff changeset
   252
int DrawStringCentered(int x, int y, StringID str, uint16 color);
2113
be2f07df0dfa (svn r2623) - CodeChange: rework DrawStringCenteredTruncated() a bit. Instead of giving center + width you give the coordinates of the bounding box (left, right) it has to fit in (ludde)
Darkvater
parents: 2097
diff changeset
   253
int DrawStringCenteredTruncated(int xl, int xr, int y, StringID str, uint16 color);
2134
50fafe90c9f0 (svn r2644) - Fix: my name was mistyped ;p
Darkvater
parents: 2113
diff changeset
   254
int DoDrawStringCentered(int x, int y, const char *str, uint16 color);
2097
e95d19e1941f (svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents: 2062
diff changeset
   255
e95d19e1941f (svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents: 2062
diff changeset
   256
int DrawString(int x, int y, StringID str, uint16 color);
e95d19e1941f (svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents: 2062
diff changeset
   257
int DrawStringTruncated(int x, int y, StringID str, uint16 color, uint maxw);
e95d19e1941f (svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents: 2062
diff changeset
   258
1323
bac2e38e8b60 (svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents: 1093
diff changeset
   259
int DoDrawString(const char *string, int x, int y, uint16 color);
2097
e95d19e1941f (svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents: 2062
diff changeset
   260
int DoDrawStringTruncated(const char *str, int x, int y, uint16 color, uint maxw);
e95d19e1941f (svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents: 2062
diff changeset
   261
e95d19e1941f (svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents: 2062
diff changeset
   262
void DrawStringCenterUnderline(int x, int y, StringID str, uint16 color);
2113
be2f07df0dfa (svn r2623) - CodeChange: rework DrawStringCenteredTruncated() a bit. Instead of giving center + width you give the coordinates of the bounding box (left, right) it has to fit in (ludde)
Darkvater
parents: 2097
diff changeset
   263
void DrawStringCenterUnderlineTruncated(int xl, int xr, int y, StringID str, uint16 color);
2097
e95d19e1941f (svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents: 2062
diff changeset
   264
4314
5c816195d9d4 (svn r5967) -Change: use right alignment for the year in the player's balance window instead of centering (about) 'string width' / 2 from the right edge
rubidium
parents: 3798
diff changeset
   265
int DrawStringRightAligned(int x, int y, StringID str, uint16 color);
2097
e95d19e1941f (svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents: 2062
diff changeset
   266
void DrawStringRightAlignedTruncated(int x, int y, StringID str, uint16 color, uint maxw);
4314
5c816195d9d4 (svn r5967) -Change: use right alignment for the year in the player's balance window instead of centering (about) 'string width' / 2 from the right edge
rubidium
parents: 3798
diff changeset
   267
void DrawStringRightAlignedUnderline(int x, int y, StringID str, uint16 color);
2097
e95d19e1941f (svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents: 2062
diff changeset
   268
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 0
diff changeset
   269
void GfxFillRect(int left, int top, int right, int bottom, int color);
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 0
diff changeset
   270
void GfxDrawLine(int left, int top, int right, int bottom, int color);
7643
af32b07bc027 (svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents: 7545
diff changeset
   271
void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   272
4609
954fe701062f (svn r6462) -Codechange: Have GetStringWidth() return width as well as the height bounding
Darkvater
parents: 4444
diff changeset
   273
BoundingRect GetStringBoundingBox(const char *str);
4954
c1f059faa899 (svn r6953) -Codechange: Change FormatStringLinebreaks in such a way that if no whitespace was seen
Darkvater
parents: 4928
diff changeset
   274
uint32 FormatStringLinebreaks(char *str, int maxw);
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   275
void LoadStringWidthTable();
2634
0df9396b0067 (svn r3176) Use proper types, not some variants of int
tron
parents: 2548
diff changeset
   276
void DrawStringMultiCenter(int x, int y, StringID str, int maxw);
6377
c1bc323eaf0c (svn r9449) -Fix: Truncate the newgrf information text in the newgrf gui if it's too long.
maedhros
parents: 6289
diff changeset
   277
uint DrawStringMultiLine(int x, int y, StringID str, int maxw, int maxh = -1);
7545
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
   278
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
   279
/**
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
   280
 * Let the dirty blocks repainting by the video driver.
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
   281
 *
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
   282
 * @ingroup dirty
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
   283
 */
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   284
void DrawDirtyBlocks();
7545
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
   285
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
   286
/**
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
   287
 * Set a new dirty block.
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
   288
 *
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
   289
 * @ingroup dirty
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
   290
 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
void SetDirtyBlocks(int left, int top, int right, int bottom);
7545
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
   292
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
   293
/**
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
   294
 * Marks the whole screen as dirty.
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
   295
 *
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
   296
 * @ingroup dirty
d44e19c5671e (svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents: 7541
diff changeset
   297
 */
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   298
void MarkWholeScreenDirty();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   300
void GfxInitPalettes();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   301
4429
b4eb6d97996f (svn r6184) Remove the unused (because it was NULL in all callers) second parameter of FillDrawPixelInfo() and simplify some expressions
tron
parents: 4428
diff changeset
   302
bool FillDrawPixelInfo(DrawPixelInfo* n, int left, int top, int width, int height);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6146
diff changeset
   304
/* window.cpp */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
void DrawOverlappedWindowForAll(int left, int top, int right, int bottom);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5636
diff changeset
   307
void SetMouseCursor(SpriteID sprite, SpriteID pal);
6138
f1196498ef66 (svn r8880) -Codechange: make anim cursors an array of structs.
rubidium
parents: 5941
diff changeset
   308
void SetAnimatedMouseCursor(const AnimCursor *table);
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   309
void CursorTick();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   310
void DrawMouseCursor();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   311
void ScreenSizeChanged();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   312
void UndrawMouseCursor();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
bool ChangeResInGame(int w, int h);
1806
5a55d508c23e (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1391
diff changeset
   314
void SortResolutions(int count);
5941
adaea39e84ab (svn r8605) -Codechange: [OSX] changed all objective C to objective C++
bjarni
parents: 5668
diff changeset
   315
void ToggleFullScreen(bool fs);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6146
diff changeset
   317
/* gfx.cpp */
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1350
diff changeset
   318
#define ASCII_LETTERSTART 32
3798
b1f5290b36b1 (svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents: 3312
diff changeset
   319
extern FontSize _cur_fontsize;
b1f5290b36b1 (svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents: 3312
diff changeset
   320
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 4954
diff changeset
   321
byte GetCharacterWidth(FontSize size, uint32 key);
3798
b1f5290b36b1 (svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents: 3312
diff changeset
   322
b1f5290b36b1 (svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents: 3312
diff changeset
   323
static inline byte GetCharacterHeight(FontSize size)
b1f5290b36b1 (svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents: 3312
diff changeset
   324
{
b1f5290b36b1 (svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents: 3312
diff changeset
   325
	switch (size) {
b1f5290b36b1 (svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents: 3312
diff changeset
   326
		default: NOT_REACHED();
b1f5290b36b1 (svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents: 3312
diff changeset
   327
		case FS_NORMAL: return 10;
b1f5290b36b1 (svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents: 3312
diff changeset
   328
		case FS_SMALL:  return 6;
b1f5290b36b1 (svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents: 3312
diff changeset
   329
		case FS_LARGE:  return 18;
b1f5290b36b1 (svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents: 3312
diff changeset
   330
	}
1391
929b46b9e3cc (svn r1895) - Fix: add assert for charwidth getter just in case
Darkvater
parents: 1390
diff changeset
   331
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   332
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   333
VARDEF DrawPixelInfo *_cur_dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   334
4444
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   335
enum {
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   336
	COLOUR_DARK_BLUE,
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   337
	COLOUR_PALE_GREEN,
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   338
	COLOUR_PINK,
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   339
	COLOUR_YELLOW,
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   340
	COLOUR_RED,
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   341
	COLOUR_LIGHT_BLUE,
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   342
	COLOUR_GREEN,
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   343
	COLOUR_DARK_GREEN,
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   344
	COLOUR_BLUE,
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   345
	COLOUR_CREAM,
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   346
	COLOUR_MAUVE,
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   347
	COLOUR_PURPLE,
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   348
	COLOUR_ORANGE,
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   349
	COLOUR_BROWN,
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   350
	COLOUR_GREY,
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   351
	COLOUR_WHITE
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   352
};
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   353
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   354
/**
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   355
 * All 16 colour gradients
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   356
 * 8 colours per gradient from darkest (0) to lightest (7)
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   357
 */
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   358
VARDEF byte _colour_gradient[16][8];
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   359
614
b96f987dbf80 (svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents: 543
diff changeset
   360
VARDEF bool _use_dos_palette;
b96f987dbf80 (svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents: 543
diff changeset
   361
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   362
enum StringColorFlags {
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6146
diff changeset
   363
	IS_PALETTE_COLOR = 0x100, ///< color value is already a real palette color index, not an index of a StringColor
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   364
};
657
d4d36b4853ec (svn r1091) Fix: Finally station names use 100% the correct color in transparent mode
dominik
parents: 614
diff changeset
   365
2436
7d5df545bd5d (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2407
diff changeset
   366
#endif /* GFX_H */