(svn r11684) -Codechange: split gfx.h in a type and functional header.

This commit is contained in:
rubidium 2007-12-23 10:56:02 +00:00
parent a3693160cf
commit 507463e420
64 changed files with 343 additions and 287 deletions

View File

@ -1,8 +1,9 @@
/* $Id$ */ /* $Id$ */
#include "../stdafx.h" #include "../stdafx.h"
#include "../zoom.hpp" #include "../helpers.hpp"
#include "../gfx.h" #include "../gfx_func.h"
#include "../zoom_func.h"
#include "../debug.h" #include "../debug.h"
#include "../table/sprites.h" #include "../table/sprites.h"
#include "../video/video_driver.hpp" #include "../video/video_driver.hpp"

View File

@ -1,7 +1,7 @@
/* $Id$ */ /* $Id$ */
#include "../stdafx.h" #include "../stdafx.h"
#include "../gfx.h" #include "../gfx_func.h"
#include "32bpp_base.hpp" #include "32bpp_base.hpp"
void *Blitter_32bppBase::MoveTo(const void *video, int x, int y) void *Blitter_32bppBase::MoveTo(const void *video, int x, int y)

View File

@ -1,8 +1,8 @@
/* $Id$ */ /* $Id$ */
#include "../stdafx.h" #include "../stdafx.h"
#include "../zoom.hpp" #include "../zoom_func.h"
#include "../gfx.h" #include "../gfx_func.h"
#include "../debug.h" #include "../debug.h"
#include "../table/sprites.h" #include "../table/sprites.h"
#include "32bpp_optimized.hpp" #include "32bpp_optimized.hpp"

View File

@ -1,8 +1,8 @@
/* $Id$ */ /* $Id$ */
#include "../stdafx.h" #include "../stdafx.h"
#include "../zoom.hpp" #include "../gfx_func.h"
#include "../gfx.h" #include "../zoom_func.h"
#include "../debug.h" #include "../debug.h"
#include "../table/sprites.h" #include "../table/sprites.h"
#include "32bpp_simple.hpp" #include "32bpp_simple.hpp"

View File

@ -1,7 +1,7 @@
/* $Id$ */ /* $Id$ */
#include "../stdafx.h" #include "../stdafx.h"
#include "../gfx.h" #include "../gfx_func.h"
#include "8bpp_base.hpp" #include "8bpp_base.hpp"
void Blitter_8bppBase::DrawColorMappingRect(void *dst, int width, int height, int pal) void Blitter_8bppBase::DrawColorMappingRect(void *dst, int width, int height, int pal)

View File

@ -3,8 +3,7 @@
/** @file 8bpp_debug.cpp */ /** @file 8bpp_debug.cpp */
#include "../stdafx.h" #include "../stdafx.h"
#include "../zoom.hpp" #include "../zoom_func.h"
#include "../gfx.h"
#include "../functions.h" #include "../functions.h"
#include "8bpp_debug.hpp" #include "8bpp_debug.hpp"

View File

@ -3,9 +3,9 @@
/** @file 8bpp_optimized.cpp */ /** @file 8bpp_optimized.cpp */
#include "../stdafx.h" #include "../stdafx.h"
#include "../zoom.hpp" #include "../zoom_func.h"
#include "../gfx.h"
#include "../debug.h" #include "../debug.h"
#include "../helpers.hpp"
#include "8bpp_optimized.hpp" #include "8bpp_optimized.hpp"
static FBlitter_8bppOptimized iFBlitter_8bppOptimized; static FBlitter_8bppOptimized iFBlitter_8bppOptimized;

View File

@ -3,8 +3,7 @@
/** @file 8bpp_simple.cpp */ /** @file 8bpp_simple.cpp */
#include "../stdafx.h" #include "../stdafx.h"
#include "../zoom.hpp" #include "../zoom_func.h"
#include "../gfx.h"
#include "8bpp_simple.hpp" #include "8bpp_simple.hpp"
static FBlitter_8bppSimple iFBlitter_8bppSimple; static FBlitter_8bppSimple iFBlitter_8bppSimple;

View File

@ -5,7 +5,7 @@
#include "../spritecache.h" #include "../spritecache.h"
#include "../spriteloader/spriteloader.hpp" #include "../spriteloader/spriteloader.hpp"
#include "../zoom.hpp" #include "../zoom_type.h"
enum BlitterMode { enum BlitterMode {
BM_NORMAL, BM_NORMAL,

View File

@ -4,7 +4,6 @@
#include "stdafx.h" #include "stdafx.h"
#include "openttd.h" #include "openttd.h"
#include "gfx.h"
#include "bmp.h" #include "bmp.h"
#include "core/bitmath_func.hpp" #include "core/bitmath_func.hpp"

View File

@ -5,6 +5,8 @@
#ifndef BMP_H #ifndef BMP_H
#define BMP_H #define BMP_H
#include "gfx_type.h"
struct BmpInfo { struct BmpInfo {
uint32 offset; ///< offset of bitmap data from .bmp file begining uint32 offset; ///< offset of bitmap data from .bmp file begining
uint32 width; ///< bitmap width uint32 width; ///< bitmap width

View File

@ -5,6 +5,8 @@
#ifndef BRIDGE_H #ifndef BRIDGE_H
#define BRIDGE_H #define BRIDGE_H
#include "gfx_type.h"
enum { enum {
MAX_BRIDGES = 13 MAX_BRIDGES = 13
}; };

View File

@ -6,6 +6,7 @@
#define CARGOTYPE_H #define CARGOTYPE_H
#include "cargo_type.h" #include "cargo_type.h"
#include "gfx_type.h"
typedef uint32 CargoLabel; typedef uint32 CargoLabel;

View File

@ -17,6 +17,7 @@
#include "genworld.h" #include "genworld.h"
#include "newgrf_storage.h" #include "newgrf_storage.h"
#include "strings_func.h" #include "strings_func.h"
#include "gfx_func.h"
const char *_cmd_text = NULL; const char *_cmd_text = NULL;

View File

@ -7,6 +7,7 @@
#include "economy_type.h" #include "economy_type.h"
#include "strings_type.h" #include "strings_type.h"
#include "tile_type.h"
/** /**
* Common return value for all commands. Wraps the cost and * Common return value for all commands. Wraps the cost and

View File

@ -17,12 +17,6 @@
#undef abs #undef abs
#endif #endif
/**
* The largest value that can be entered in a variable
* @param type the type of the variable
*/
#define MAX_UVALUE(type) ((type)~(type)0)
/** /**
* Returns the maximum of two values. * Returns the maximum of two values.
* *

View File

@ -10,6 +10,7 @@
#include "cargo_type.h" #include "cargo_type.h"
#include "vehicle_type.h" #include "vehicle_type.h"
#include "command_type.h" #include "command_type.h"
#include "gfx_type.h"
#include "sound.h" #include "sound.h"
enum RailVehicleTypes { enum RailVehicleTypes {

View File

@ -14,6 +14,7 @@
#include "helpers.hpp" #include "helpers.hpp"
#include "spriteloader/spriteloader.hpp" #include "spriteloader/spriteloader.hpp"
#include "blitter/factory.hpp" #include "blitter/factory.hpp"
#include "gfx_func.h"
#ifdef WITH_FREETYPE #ifdef WITH_FREETYPE

View File

@ -3,7 +3,7 @@
#ifndef FONTCACHE_H #ifndef FONTCACHE_H
#define FONTCACHE_H #define FONTCACHE_H
#include "gfx.h" #include "gfx_type.h"
/** Get the SpriteID mapped to the given font size and key */ /** Get the SpriteID mapped to the given font size and key */
SpriteID GetUnicodeGlyph(FontSize size, uint32 key); SpriteID GetUnicodeGlyph(FontSize size, uint32 key);

View File

@ -8,6 +8,7 @@
#include "core/random_func.hpp" #include "core/random_func.hpp"
#include "command_type.h" #include "command_type.h"
#include "window_type.h" #include "window_type.h"
#include "openttd.h"
void UpdateTownMaxPass(Town *t); void UpdateTownMaxPass(Town *t);

View File

@ -5,7 +5,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "openttd.h" #include "openttd.h"
#include "functions.h" #include "functions.h"
#include "gfx.h" #include "gfx_func.h"
#include "spritecache.h" #include "spritecache.h"
#include "string.h" #include "string.h"
#include "table/palettes.h" #include "table/palettes.h"
@ -15,7 +15,7 @@
#include "fontcache.h" #include "fontcache.h"
#include "genworld.h" #include "genworld.h"
#include "debug.h" #include "debug.h"
#include "zoom.hpp" #include "zoom_func.h"
#include "texteff.hpp" #include "texteff.hpp"
#include "blitter/factory.hpp" #include "blitter/factory.hpp"
#include "video/video_driver.hpp" #include "video/video_driver.hpp"
@ -41,6 +41,9 @@ int _pal_count_dirty;
Colour _cur_palette[256]; Colour _cur_palette[256];
byte _stringwidth_table[FS_END][224]; byte _stringwidth_table[FS_END][224];
DrawPixelInfo *_cur_dpi;
byte _colour_gradient[16][8];
bool _use_dos_palette;
static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub = NULL); static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub = NULL);
@ -561,7 +564,7 @@ Dimension GetStringBoundingBox(const char *str)
* @param x offset from left side of the screen, if negative offset from the right side * @param x offset from left side of the screen, if negative offset from the right side
* @param y offset from top side of the screen, if negative offset from the bottom * @param y offset from top side of the screen, if negative offset from the bottom
* @param real_color colour of the string, see _string_colormap in * @param real_color colour of the string, see _string_colormap in
* table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx.h * table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h
* @return the x-coordinates where the drawing has finished. If nothing is drawn * @return the x-coordinates where the drawing has finished. If nothing is drawn
* the originally passed x-coordinate is returned */ * the originally passed x-coordinate is returned */
int DoDrawString(const char *string, int x, int y, uint16 real_color) int DoDrawString(const char *string, int x, int y, uint16 real_color)

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/** @file gfx.h */ /** @file gfx_func.h Functions related to the gfx engine. */
/** /**
* @defgroup dirty Dirty * @defgroup dirty Dirty
@ -32,150 +32,16 @@
*/ */
#ifndef GFX_H #ifndef GFX_FUNC_H
#define GFX_H #define GFX_FUNC_H
#include "openttd.h" #include "gfx_type.h"
#include "core/math_func.hpp" #include "strings_type.h"
#include "core/geometry_type.hpp"
#include "core/enum_type.hpp"
#include "zoom.hpp"
enum WindowKeyCodes {
WKC_SHIFT = 0x8000,
WKC_CTRL = 0x4000,
WKC_ALT = 0x2000,
WKC_META = 0x1000,
/* Special ones */
WKC_NONE = 0,
WKC_ESC = 1,
WKC_BACKSPACE = 2,
WKC_INSERT = 3,
WKC_DELETE = 4,
WKC_PAGEUP = 5,
WKC_PAGEDOWN = 6,
WKC_END = 7,
WKC_HOME = 8,
/* Arrow keys */
WKC_LEFT = 9,
WKC_UP = 10,
WKC_RIGHT = 11,
WKC_DOWN = 12,
/* Return & tab */
WKC_RETURN = 13,
WKC_TAB = 14,
/* Space */
WKC_SPACE = 32,
/* Function keys */
WKC_F1 = 33,
WKC_F2 = 34,
WKC_F3 = 35,
WKC_F4 = 36,
WKC_F5 = 37,
WKC_F6 = 38,
WKC_F7 = 39,
WKC_F8 = 40,
WKC_F9 = 41,
WKC_F10 = 42,
WKC_F11 = 43,
WKC_F12 = 44,
/* Backquote is the key left of "1"
* we only store this key here, no matter what character is really mapped to it
* on a particular keyboard. (US keyboard: ` and ~ ; German keyboard: ^ and °) */
WKC_BACKQUOTE = 45,
WKC_PAUSE = 46,
/* 0-9 are mapped to 48-57
* A-Z are mapped to 65-90
* a-z are mapped to 97-122 */
/* Numerical keyboard */
WKC_NUM_0 = 128,
WKC_NUM_1 = 129,
WKC_NUM_2 = 130,
WKC_NUM_3 = 131,
WKC_NUM_4 = 132,
WKC_NUM_5 = 133,
WKC_NUM_6 = 134,
WKC_NUM_7 = 135,
WKC_NUM_8 = 136,
WKC_NUM_9 = 137,
WKC_NUM_DIV = 138,
WKC_NUM_MUL = 139,
WKC_NUM_MINUS = 140,
WKC_NUM_PLUS = 141,
WKC_NUM_ENTER = 142,
WKC_NUM_DECIMAL = 143,
/* Other keys */
WKC_SLASH = 144, ///< / Forward slash
WKC_SEMICOLON = 145, ///< ; Semicolon
WKC_EQUALS = 146, ///< = Equals
WKC_L_BRACKET = 147, ///< [ Left square bracket
WKC_BACKSLASH = 148, ///< \ Backslash
WKC_R_BRACKET = 149, ///< ] Right square bracket
WKC_SINGLEQUOTE = 150, ///< ' Single quote
WKC_COMMA = 151, ///< , Comma
WKC_PERIOD = 152, ///< . Period
WKC_MINUS = 153, ///< - Minus
};
void GameLoop(); void GameLoop();
void CreateConsole(); void CreateConsole();
/** A single sprite of a list of animated cursors */
struct AnimCursor {
static const CursorID LAST = MAX_UVALUE(CursorID);
CursorID sprite; ///< Must be set to LAST_ANIM when it is the last sprite of the loop
byte display_time; ///< Amount of ticks this sprite will be shown
};
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
SpriteID sprite; ///< current image of cursor
SpriteID pal;
int wheel; ///< mouse wheel movement
/* We need two different vars to keep track of how far the scrollwheel moved.
* OSX uses this for scrolling around the map. */
int v_wheel;
int h_wheel;
const AnimCursor *animate_list; ///< in case of animated cursor, list of frames
const AnimCursor *animate_cur; ///< in case of animated cursor, current frame
uint animate_timeout; ///< in case of animated cursor, number of ticks to show the current 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
};
struct DrawPixelInfo {
void *dst_ptr;
int left, top, width, height;
int pitch;
ZoomLevel zoom;
};
struct Colour {
byte r;
byte g;
byte b;
};
extern byte _dirkeys; ///< 1 = left, 2 = up, 4 = right, 8 = down extern byte _dirkeys; ///< 1 = left, 2 = up, 4 = right, 8 = down
extern bool _fullscreen; extern bool _fullscreen;
extern CursorVars _cursor; extern CursorVars _cursor;
@ -211,26 +77,9 @@ void HandleExitGameRequest();
void GameSizeChanged(); void GameSizeChanged();
void UndrawMouseCursor(); void UndrawMouseCursor();
enum FontSize {
FS_NORMAL,
FS_SMALL,
FS_LARGE,
FS_END,
};
DECLARE_POSTFIX_INCREMENT(FontSize);
void RedrawScreenRect(int left, int top, int right, int bottom); void RedrawScreenRect(int left, int top, int right, int bottom);
void GfxScroll(int left, int top, int width, int height, int xo, int yo); void GfxScroll(int left, int top, int width, int height, int xo, int yo);
/**
* Used to only draw a part of the sprite.
* Draw the subsprite in the rect (sprite_x_offset + left, sprite_y_offset + top) to (sprite_x_offset + right, sprite_y_offset + bottom).
* Both corners are included in the drawing area.
*/
struct SubSprite {
int left, top, right, bottom;
};
void DrawSprite(SpriteID img, SpriteID pal, int x, int y, const SubSprite *sub = NULL); void DrawSprite(SpriteID img, SpriteID pal, int x, int y, const SubSprite *sub = NULL);
/* XXX doesn't really belong here, but the only /* XXX doesn't really belong here, but the only
@ -320,59 +169,14 @@ static inline byte GetCharacterHeight(FontSize size)
} }
} }
VARDEF DrawPixelInfo *_cur_dpi; extern DrawPixelInfo *_cur_dpi;
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
};
/** Colour of the strings, see _string_colormap in table/palettes.h or docs/ottd-colourtext-palette.png */
enum TextColour {
TC_FROMSTRING = 0x00,
TC_BLUE = 0x00,
TC_SILVER = 0x01,
TC_GOLD = 0x02,
TC_RED = 0x03,
TC_PURPLE = 0x04,
TC_LIGHT_BROWN = 0x05,
TC_ORANGE = 0x06,
TC_GREEN = 0x07,
TC_YELLOW = 0x08,
TC_DARK_GREEN = 0x09,
TC_CREAM = 0x0A,
TC_BROWN = 0x0B,
TC_WHITE = 0x0C,
TC_LIGHT_BLUE = 0x0D,
TC_GREY = 0x0E,
TC_DARK_BLUE = 0x0F,
TC_BLACK = 0x10,
};
/** /**
* All 16 colour gradients * All 16 colour gradients
* 8 colours per gradient from darkest (0) to lightest (7) * 8 colours per gradient from darkest (0) to lightest (7)
*/ */
VARDEF byte _colour_gradient[16][8]; extern byte _colour_gradient[16][8];
VARDEF bool _use_dos_palette; extern bool _use_dos_palette;
enum StringColorFlags { #endif /* GFX_FUNC_H */
IS_PALETTE_COLOR = 0x100, ///< color value is already a real palette color index, not an index of a StringColor
};
#endif /* GFX_H */

210
src/gfx_type.h Normal file
View File

@ -0,0 +1,210 @@
/* $Id$ */
/** @file gfx_type.h Types related to the graphics and/or input devices. */
#ifndef GFX_TYPE_H
#define GFX_TYPE_H
#include "core/enum_type.hpp"
#include "core/geometry_type.hpp"
#include "zoom_type.h"
typedef uint32 SpriteID; ///< The number of a sprite, without mapping bits and colortables
struct PalSpriteID {
SpriteID sprite;
SpriteID pal;
};
typedef int32 CursorID;
enum WindowKeyCodes {
WKC_SHIFT = 0x8000,
WKC_CTRL = 0x4000,
WKC_ALT = 0x2000,
WKC_META = 0x1000,
/* Special ones */
WKC_NONE = 0,
WKC_ESC = 1,
WKC_BACKSPACE = 2,
WKC_INSERT = 3,
WKC_DELETE = 4,
WKC_PAGEUP = 5,
WKC_PAGEDOWN = 6,
WKC_END = 7,
WKC_HOME = 8,
/* Arrow keys */
WKC_LEFT = 9,
WKC_UP = 10,
WKC_RIGHT = 11,
WKC_DOWN = 12,
/* Return & tab */
WKC_RETURN = 13,
WKC_TAB = 14,
/* Space */
WKC_SPACE = 32,
/* Function keys */
WKC_F1 = 33,
WKC_F2 = 34,
WKC_F3 = 35,
WKC_F4 = 36,
WKC_F5 = 37,
WKC_F6 = 38,
WKC_F7 = 39,
WKC_F8 = 40,
WKC_F9 = 41,
WKC_F10 = 42,
WKC_F11 = 43,
WKC_F12 = 44,
/* Backquote is the key left of "1"
* we only store this key here, no matter what character is really mapped to it
* on a particular keyboard. (US keyboard: ` and ~ ; German keyboard: ^ and °) */
WKC_BACKQUOTE = 45,
WKC_PAUSE = 46,
/* 0-9 are mapped to 48-57
* A-Z are mapped to 65-90
* a-z are mapped to 97-122 */
/* Numerical keyboard */
WKC_NUM_0 = 128,
WKC_NUM_1 = 129,
WKC_NUM_2 = 130,
WKC_NUM_3 = 131,
WKC_NUM_4 = 132,
WKC_NUM_5 = 133,
WKC_NUM_6 = 134,
WKC_NUM_7 = 135,
WKC_NUM_8 = 136,
WKC_NUM_9 = 137,
WKC_NUM_DIV = 138,
WKC_NUM_MUL = 139,
WKC_NUM_MINUS = 140,
WKC_NUM_PLUS = 141,
WKC_NUM_ENTER = 142,
WKC_NUM_DECIMAL = 143,
/* Other keys */
WKC_SLASH = 144, ///< / Forward slash
WKC_SEMICOLON = 145, ///< ; Semicolon
WKC_EQUALS = 146, ///< = Equals
WKC_L_BRACKET = 147, ///< [ Left square bracket
WKC_BACKSLASH = 148, ///< \ Backslash
WKC_R_BRACKET = 149, ///< ] Right square bracket
WKC_SINGLEQUOTE = 150, ///< ' Single quote
WKC_COMMA = 151, ///< , Comma
WKC_PERIOD = 152, ///< . Period
WKC_MINUS = 153, ///< - Minus
};
/** A single sprite of a list of animated cursors */
struct AnimCursor {
static const CursorID LAST = MAX_UVALUE(CursorID);
CursorID sprite; ///< Must be set to LAST_ANIM when it is the last sprite of the loop
byte display_time; ///< Amount of ticks this sprite will be shown
};
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
SpriteID sprite; ///< current image of cursor
SpriteID pal;
int wheel; ///< mouse wheel movement
/* We need two different vars to keep track of how far the scrollwheel moved.
* OSX uses this for scrolling around the map. */
int v_wheel;
int h_wheel;
const AnimCursor *animate_list; ///< in case of animated cursor, list of frames
const AnimCursor *animate_cur; ///< in case of animated cursor, current frame
uint animate_timeout; ///< in case of animated cursor, number of ticks to show the current 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
};
struct DrawPixelInfo {
void *dst_ptr;
int left, top, width, height;
int pitch;
ZoomLevel zoom;
};
struct Colour {
byte r;
byte g;
byte b;
};
enum FontSize {
FS_NORMAL,
FS_SMALL,
FS_LARGE,
FS_END,
};
DECLARE_POSTFIX_INCREMENT(FontSize);
/**
* Used to only draw a part of the sprite.
* Draw the subsprite in the rect (sprite_x_offset + left, sprite_y_offset + top) to (sprite_x_offset + right, sprite_y_offset + bottom).
* Both corners are included in the drawing area.
*/
struct SubSprite {
int left, top, right, bottom;
};
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
};
/** Colour of the strings, see _string_colormap in table/palettes.h or docs/ottd-colourtext-palette.png */
enum TextColour {
TC_FROMSTRING = 0x00,
TC_BLUE = 0x00,
TC_SILVER = 0x01,
TC_GOLD = 0x02,
TC_RED = 0x03,
TC_PURPLE = 0x04,
TC_LIGHT_BROWN = 0x05,
TC_ORANGE = 0x06,
TC_GREEN = 0x07,
TC_YELLOW = 0x08,
TC_DARK_GREEN = 0x09,
TC_CREAM = 0x0A,
TC_BROWN = 0x0B,
TC_WHITE = 0x0C,
TC_LIGHT_BLUE = 0x0D,
TC_GREY = 0x0E,
TC_DARK_BLUE = 0x0F,
TC_BLACK = 0x10,
};
enum StringColorFlags {
IS_PALETTE_COLOR = 0x100, ///< color value is already a real palette color index, not an index of a StringColor
};
#endif /* GFX_TYPE_H */

View File

@ -16,6 +16,7 @@
#include "md5.h" #include "md5.h"
#include "variables.h" #include "variables.h"
#include "fontcache.h" #include "fontcache.h"
#include "gfx_func.h"
#include <string.h> #include <string.h>
struct MD5File { struct MD5File {

View File

@ -5,6 +5,8 @@
#ifndef GFXINIT_H #ifndef GFXINIT_H
#define GFXINIT_H #define GFXINIT_H
#include "gfx_type.h"
void CheckExternalFiles(); void CheckExternalFiles();
void GfxLoadSprites(); void GfxLoadSprites();
void LoadSpritesIndexed(int file_index, uint *sprite_id, const SpriteID *index_tbl); void LoadSpritesIndexed(int file_index, uint *sprite_id, const SpriteID *index_tbl);

View File

@ -8,7 +8,7 @@
#include "string.h" #include "string.h"
#include "window_type.h" #include "window_type.h"
#include "vehicle_type.h" #include "vehicle_type.h"
#include "gfx.h" #include "gfx_type.h"
/* main_gui.cpp */ /* main_gui.cpp */
void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2); void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2);

View File

@ -15,6 +15,7 @@
#include "saveload.h" #include "saveload.h"
#include "bmp.h" #include "bmp.h"
#include "helpers.hpp" #include "helpers.hpp"
#include "gfx_func.h"
/** /**
* Convert RGB colors to Grayscale using 29.9% Red, 58.7% Green, 11.4% Blue * Convert RGB colors to Grayscale using 29.9% Red, 58.7% Green, 11.4% Blue

View File

@ -50,6 +50,7 @@
#include "industry.h" #include "industry.h"
#include "transparency.h" #include "transparency.h"
#include "strings_func.h" #include "strings_func.h"
#include "zoom_func.h"
static int _rename_id = 1; static int _rename_id = 1;
static int _rename_what = -1; static int _rename_what = -1;

View File

@ -25,6 +25,7 @@
#include "group.h" #include "group.h"
#include "viewport.h" #include "viewport.h"
#include "economy_func.h" #include "economy_func.h"
#include "zoom_func.h"
char _name_array[512][32]; char _name_array[512][32];

View File

@ -2,6 +2,7 @@
/** @file dbg_helpers.cpp */ /** @file dbg_helpers.cpp */
#include "../stdafx.h" #include "../stdafx.h"
#include "../openttd.h"
#include "../direction_type.h" #include "../direction_type.h"
#include "../rail.h" #include "../rail.h"
#include "../rail_map.h" #include "../rail_map.h"

View File

@ -19,6 +19,7 @@
#include "player_face.h" #include "player_face.h"
#include "strings_func.h" #include "strings_func.h"
#include "vehicle.h" #include "vehicle.h"
#include "gfx_func.h"
/** Change the player's face. /** Change the player's face.
* @param tile unused * @param tile unused

View File

@ -40,6 +40,7 @@
#include "fileio.h" #include "fileio.h"
#include "fios.h" #include "fios.h"
#include "tile_cmd.h" #include "tile_cmd.h"
#include "zoom_func.h"
/* Variables to display file lists */ /* Variables to display file lists */
FiosItem *_fios_list; FiosItem *_fios_list;

View File

@ -19,7 +19,6 @@
#include "../gui.h" #include "../gui.h"
#include "../window_gui.h" #include "../window_gui.h"
#include "../textbuf_gui.h" #include "../textbuf_gui.h"
#include "../gfx.h"
#include "../variables.h" #include "../variables.h"
#include "network_server.h" #include "network_server.h"
#include "network_udp.h" #include "network_udp.h"

View File

@ -47,6 +47,7 @@
#include "fios.h" #include "fios.h"
#include "rail.h" #include "rail.h"
#include "strings_func.h" #include "strings_func.h"
#include "gfx_func.h"
/* TTDPatch extended GRF format codec /* TTDPatch extended GRF format codec
* (c) Petr Baudis 2004 (GPL'd) * (c) Petr Baudis 2004 (GPL'd)

View File

@ -23,7 +23,7 @@
#include "cargotype.h" #include "cargotype.h"
#include "town_map.h" #include "town_map.h"
#include "newgrf_town.h" #include "newgrf_town.h"
#include "gfx.h" #include "gfx_func.h"
static StationClass station_classes[STAT_CLASS_MAX]; static StationClass station_classes[STAT_CLASS_MAX];

View File

@ -24,7 +24,7 @@
#include "newgrf_config.h" #include "newgrf_config.h"
#include "ai/ai.h" #include "ai/ai.h"
#include "date.h" #include "date.h"
#include "zoom.hpp" #include "zoom_func.h"
enum { enum {
HEADER_SIZE = 49, HEADER_SIZE = 49,

View File

@ -64,6 +64,7 @@
#include "music/music_driver.hpp" #include "music/music_driver.hpp"
#include "video/video_driver.hpp" #include "video/video_driver.hpp"
#include "strings_func.h" #include "strings_func.h"
#include "zoom_func.h"
#include "bridge_map.h" #include "bridge_map.h"
#include "clear_map.h" #include "clear_map.h"

View File

@ -26,12 +26,6 @@ struct DrawPixelInfo;
struct Group; struct Group;
typedef byte VehicleOrderID; ///< The index of an order within its current vehicle (not pool related) typedef byte VehicleOrderID; ///< The index of an order within its current vehicle (not pool related)
typedef byte LandscapeID; typedef byte LandscapeID;
typedef uint32 SpriteID; ///< The number of a sprite, without mapping bits and colortables
struct PalSpriteID {
SpriteID sprite;
SpriteID pal;
};
typedef int32 CursorID;
typedef uint16 EngineID; typedef uint16 EngineID;
typedef uint16 UnitID; typedef uint16 UnitID;

View File

@ -5,7 +5,7 @@
#include "../../variables.h" #include "../../variables.h"
#include "../../debug.h" #include "../../debug.h"
#include "../../functions.h" #include "../../functions.h"
#include "../../gfx.h" #include "../../gfx_func.h"
#include "../../fileio.h" #include "../../fileio.h"
#include "../../blitter/factory.hpp" #include "../../blitter/factory.hpp"

View File

@ -29,7 +29,7 @@
#include "window_func.h" #include "window_func.h"
#include "tile_map.h" #include "tile_map.h"
#include "strings_func.h" #include "strings_func.h"
#include "gfx.h" #include "gfx_func.h"
/** /**
* Sets the local player and updates the patch settings that are set on a * Sets the local player and updates the patch settings that are set on a

View File

@ -8,9 +8,10 @@
#include "rail_type.h" #include "rail_type.h"
#include "track_type.h" #include "track_type.h"
#include "vehicle_type.h" #include "vehicle_type.h"
#include "gfx_type.h"
#include "core/bitmath_func.hpp" #include "core/bitmath_func.hpp"
#include "variables.h"
#include "economy_func.h" #include "economy_func.h"
#include "variables.h"
/** This struct contains all the info that is needed to draw and construct tracks. /** This struct contains all the info that is needed to draw and construct tracks.
*/ */

View File

@ -28,6 +28,7 @@
#include "table/strings.h" #include "table/strings.h"
#include "window_func.h" #include "window_func.h"
#include "strings_func.h" #include "strings_func.h"
#include "gfx_func.h"
#include <list> #include <list>
extern const uint16 SAVEGAME_VERSION = 83; extern const uint16 SAVEGAME_VERSION = 83;

View File

@ -16,6 +16,7 @@
#include "blitter/factory.hpp" #include "blitter/factory.hpp"
#include "fileio.h" #include "fileio.h"
#include "strings_func.h" #include "strings_func.h"
#include "zoom_func.h"
char _screenshot_format_name[8]; char _screenshot_format_name[8];
uint _num_screenshot_formats; uint _num_screenshot_formats;

View File

@ -16,6 +16,7 @@
#include "misc/autoptr.hpp" #include "misc/autoptr.hpp"
#include "strings_func.h" #include "strings_func.h"
#include "viewport.h" #include "viewport.h"
#include "zoom_func.h"
SignID _new_sign_id; SignID _new_sign_id;
uint _total_signs; uint _total_signs;

View File

@ -27,6 +27,7 @@
#include "blitter/factory.hpp" #include "blitter/factory.hpp"
#include "tunnelbridge_map.h" #include "tunnelbridge_map.h"
#include "strings_func.h" #include "strings_func.h"
#include "zoom_func.h"
static const Widget _smallmap_widgets[] = { static const Widget _smallmap_widgets[] = {

View File

@ -5,6 +5,8 @@
#ifndef SPRITE_H #ifndef SPRITE_H
#define SPRITE_H #define SPRITE_H
#include "gfx_type.h"
#define GENERAL_SPRITE_COLOR(color) ((color) + PALETTE_RECOLOR_START) #define GENERAL_SPRITE_COLOR(color) ((color) + PALETTE_RECOLOR_START)
#define PLAYER_SPRITE_COLOR(owner) (GENERAL_SPRITE_COLOR(_player_colors[owner])) #define PLAYER_SPRITE_COLOR(owner) (GENERAL_SPRITE_COLOR(_player_colors[owner]))

View File

@ -5,6 +5,8 @@
#ifndef SPRITECACHE_H #ifndef SPRITECACHE_H
#define SPRITECACHE_H #define SPRITECACHE_H
#include "gfx_type.h"
struct Sprite { struct Sprite {
byte height; byte height;
uint16 width; uint16 width;

View File

@ -3,7 +3,7 @@
/** @file grf.cpp */ /** @file grf.cpp */
#include "../stdafx.h" #include "../stdafx.h"
#include "../gfx.h" #include "../gfx_func.h"
#include "../fileio.h" #include "../fileio.h"
#include "../debug.h" #include "../debug.h"
#include "grf.hpp" #include "grf.hpp"

View File

@ -5,7 +5,7 @@
#ifdef WITH_PNG #ifdef WITH_PNG
#include "../stdafx.h" #include "../stdafx.h"
#include "../gfx.h" #include "../gfx_func.h"
#include "../fileio.h" #include "../fileio.h"
#include "../variables.h" #include "../variables.h"
#include "../debug.h" #include "../debug.h"

View File

@ -32,6 +32,7 @@
#include "cargotype.h" #include "cargotype.h"
#include "roadveh.h" #include "roadveh.h"
#include "station_gui.h" #include "station_gui.h"
#include "zoom_func.h"
Station::Station(TileIndex tile) Station::Station(TileIndex tile)
{ {

View File

@ -374,4 +374,10 @@ assert_compile(sizeof(uint8) == 1);
#define MAX_PATH 260 #define MAX_PATH 260
#endif #endif
/**
* The largest value that can be entered in a variable
* @param type the type of the variable
*/
#define MAX_UVALUE(type) ((type)~(type)0)
#endif /* STDAFX_H */ #endif /* STDAFX_H */

View File

@ -32,6 +32,8 @@
* @todo Split the "Sprites" enum into smaller chunks and document them * @todo Split the "Sprites" enum into smaller chunks and document them
*/ */
#include "../gfx_type.h"
enum Sprites { enum Sprites {
SPR_SELECT_TILE = 752, SPR_SELECT_TILE = 752,
SPR_DOT = 774, // corner marker for lower/raise land SPR_DOT = 774, // corner marker for lower/raise land

View File

@ -5,6 +5,8 @@
#ifndef TRANSPARENCY_H #ifndef TRANSPARENCY_H
#define TRANSPARENCY_H #define TRANSPARENCY_H
#include "gfx_func.h"
/** /**
* Transparency option bits: which position in _transparency_opt stands for which transparency. * Transparency option bits: which position in _transparency_opt stands for which transparency.
* If you change the order, change the order of the ShowTransparencyToolbar() stuff in transparency_gui.cpp too. * If you change the order, change the order of the ShowTransparencyToolbar() stuff in transparency_gui.cpp too.

View File

@ -42,6 +42,7 @@
#include "group.h" #include "group.h"
#include "order.h" #include "order.h"
#include "strings_func.h" #include "strings_func.h"
#include "zoom_func.h"
#define INVALID_COORD (0x7fffffff) #define INVALID_COORD (0x7fffffff)
#define GEN_HASH(x, y) ((GB((y), 6, 6) << 6) + GB((x), 7, 6)) #define GEN_HASH(x, y) ((GB((y), 6, 6) << 6) + GB((x), 7, 6))

View File

@ -6,16 +6,17 @@
#define VEHICLE_H #define VEHICLE_H
#include "vehicle_type.h" #include "vehicle_type.h"
#include "oldpool.h"
#include "order.h"
#include "track_type.h" #include "track_type.h"
#include "rail_type.h" #include "rail_type.h"
#include "road_type.h" #include "road_type.h"
#include "cargo_type.h" #include "cargo_type.h"
#include "window_type.h" #include "window_type.h"
#include "gfx_type.h"
#include "command_type.h"
#include "oldpool.h"
#include "order.h"
#include "cargopacket.h" #include "cargopacket.h"
#include "texteff.hpp" #include "texteff.hpp"
#include "command_type.h"
/** Road vehicle states */ /** Road vehicle states */
enum RoadVehicleStates { enum RoadVehicleStates {

View File

@ -7,7 +7,7 @@
#include "../openttd.h" #include "../openttd.h"
#include "../debug.h" #include "../debug.h"
#include "../functions.h" #include "../functions.h"
#include "../gfx.h" #include "../gfx_func.h"
#include "../network/network.h" #include "../network/network.h"
#include "../console.h" #include "../console.h"
#include "../variables.h" #include "../variables.h"

View File

@ -2,7 +2,7 @@
#include "../stdafx.h" #include "../stdafx.h"
#include "../openttd.h" #include "../openttd.h"
#include "../gfx.h" #include "../gfx_func.h"
#include "../variables.h" #include "../variables.h"
#include "../debug.h" #include "../debug.h"
#include "../blitter/factory.hpp" #include "../blitter/factory.hpp"

View File

@ -7,7 +7,7 @@
#include "../openttd.h" #include "../openttd.h"
#include "../debug.h" #include "../debug.h"
#include "../functions.h" #include "../functions.h"
#include "../gfx.h" #include "../gfx_func.h"
#include "../sdl.h" #include "../sdl.h"
#include "../variables.h" #include "../variables.h"
#include "../blitter/factory.hpp" #include "../blitter/factory.hpp"

View File

@ -3,7 +3,7 @@
#include "../stdafx.h" #include "../stdafx.h"
#include "../openttd.h" #include "../openttd.h"
#include "../functions.h" #include "../functions.h"
#include "../gfx.h" #include "../gfx_func.h"
#include "../variables.h" #include "../variables.h"
#include "../win32.h" #include "../win32.h"
#include "../blitter/factory.hpp" #include "../blitter/factory.hpp"

View File

@ -25,6 +25,7 @@
#include "blitter/factory.hpp" #include "blitter/factory.hpp"
#include "transparency.h" #include "transparency.h"
#include "strings_func.h" #include "strings_func.h"
#include "zoom_func.h"
#define VIEWPORT_DRAW_MEM (65536 * 2) #define VIEWPORT_DRAW_MEM (65536 * 2)

View File

@ -5,10 +5,10 @@
#ifndef VIEWPORT_H #ifndef VIEWPORT_H
#define VIEWPORT_H #define VIEWPORT_H
#include "zoom.hpp" #include "zoom_type.h"
#include "window_type.h" #include "window_type.h"
#include "vehicle_type.h" #include "vehicle_type.h"
#include "gfx.h" #include "gfx_func.h"
struct ViewPort { struct ViewPort {
int left,top; // screen coordinates for the viewport int left,top; // screen coordinates for the viewport

View File

@ -17,6 +17,7 @@
#include "helpers.hpp" #include "helpers.hpp"
#include "blitter/factory.hpp" #include "blitter/factory.hpp"
#include "window_gui.h" #include "window_gui.h"
#include "zoom_func.h"
/* delta between mouse cursor and upper left corner of dragged window */ /* delta between mouse cursor and upper left corner of dragged window */
static Point _drag_delta; static Point _drag_delta;

View File

@ -2,41 +2,13 @@
/** @file zoom.hpp */ /** @file zoom.hpp */
#ifndef ZOOM_HPP #ifndef ZOOM_FUNC_H
#define ZOOM_HPP #define ZOOM_FUNC_H
#include "core/enum_type.hpp" #include "zoom_type.h"
enum ZoomLevel {
/* Our possible zoom-levels */
ZOOM_LVL_BEGIN = 0,
ZOOM_LVL_NORMAL = 0,
ZOOM_LVL_OUT_2X,
ZOOM_LVL_OUT_4X,
ZOOM_LVL_OUT_8X,
ZOOM_LVL_END,
/* Here we define in which zoom viewports are */
ZOOM_LVL_VIEWPORT = ZOOM_LVL_NORMAL,
ZOOM_LVL_NEWS = ZOOM_LVL_NORMAL,
ZOOM_LVL_INDUSTRY = ZOOM_LVL_OUT_2X,
ZOOM_LVL_TOWN = ZOOM_LVL_OUT_2X,
ZOOM_LVL_AIRCRAFT = ZOOM_LVL_NORMAL,
ZOOM_LVL_SHIP = ZOOM_LVL_NORMAL,
ZOOM_LVL_TRAIN = ZOOM_LVL_NORMAL,
ZOOM_LVL_ROADVEH = ZOOM_LVL_NORMAL,
ZOOM_LVL_WORLD_SCREENSHOT = ZOOM_LVL_NORMAL,
ZOOM_LVL_DETAIL = ZOOM_LVL_OUT_2X, ///< All zoomlevels below or equal to this, will result in details on the screen, like road-work, ...
ZOOM_LVL_MIN = ZOOM_LVL_NORMAL,
ZOOM_LVL_MAX = ZOOM_LVL_OUT_8X,
};
extern ZoomLevel _saved_scrollpos_zoom; extern ZoomLevel _saved_scrollpos_zoom;
DECLARE_POSTFIX_INCREMENT(ZoomLevel)
/** /**
* Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL) * Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL)
* When shifting right, value is rounded up * When shifting right, value is rounded up
@ -91,4 +63,4 @@ static inline int UnScaleByZoomLower(int value, ZoomLevel zoom)
return (zoom > ZOOM_LVL_NORMAL) ? value >> izoom : value << -izoom; return (zoom > ZOOM_LVL_NORMAL) ? value >> izoom : value << -izoom;
} }
#endif /* ZOOM_HPP */ #endif /* ZOOM_FUNC_H */

37
src/zoom_type.h Normal file
View File

@ -0,0 +1,37 @@
/* $Id$ */
/** @file zoom_type.h Types related to zooming in and out. */
#ifndef ZOOM_TYPE_H
#define ZOOM_TYPE_H
#include "core/enum_type.hpp"
enum ZoomLevel {
/* Our possible zoom-levels */
ZOOM_LVL_BEGIN = 0,
ZOOM_LVL_NORMAL = 0,
ZOOM_LVL_OUT_2X,
ZOOM_LVL_OUT_4X,
ZOOM_LVL_OUT_8X,
ZOOM_LVL_END,
/* Here we define in which zoom viewports are */
ZOOM_LVL_VIEWPORT = ZOOM_LVL_NORMAL,
ZOOM_LVL_NEWS = ZOOM_LVL_NORMAL,
ZOOM_LVL_INDUSTRY = ZOOM_LVL_OUT_2X,
ZOOM_LVL_TOWN = ZOOM_LVL_OUT_2X,
ZOOM_LVL_AIRCRAFT = ZOOM_LVL_NORMAL,
ZOOM_LVL_SHIP = ZOOM_LVL_NORMAL,
ZOOM_LVL_TRAIN = ZOOM_LVL_NORMAL,
ZOOM_LVL_ROADVEH = ZOOM_LVL_NORMAL,
ZOOM_LVL_WORLD_SCREENSHOT = ZOOM_LVL_NORMAL,
ZOOM_LVL_DETAIL = ZOOM_LVL_OUT_2X, ///< All zoomlevels below or equal to this, will result in details on the screen, like road-work, ...
ZOOM_LVL_MIN = ZOOM_LVL_NORMAL,
ZOOM_LVL_MAX = ZOOM_LVL_OUT_8X,
};
DECLARE_POSTFIX_INCREMENT(ZoomLevel)
#endif /* ZOOM_TYPE_H */