Changeset - r8123:dde0a9a84019
[Not reviewed]
master
! ! !
rubidium - 16 years ago 2007-12-23 10:56:02
rubidium@openttd.org
(svn r11684) -Codechange: split gfx.h in a type and functional header.
66 files changed with 578 insertions and 522 deletions:
0 comments (0 inline, 0 general)
src/blitter/32bpp_anim.cpp
Show inline comments
 
/* $Id$ */
 

	
 
#include "../stdafx.h"
 
#include "../zoom.hpp"
 
#include "../gfx.h"
 
#include "../helpers.hpp"
 
#include "../gfx_func.h"
 
#include "../zoom_func.h"
 
#include "../debug.h"
 
#include "../table/sprites.h"
 
#include "../video/video_driver.hpp"
src/blitter/32bpp_base.cpp
Show inline comments
 
/* $Id$ */
 

	
 
#include "../stdafx.h"
 
#include "../gfx.h"
 
#include "../gfx_func.h"
 
#include "32bpp_base.hpp"
 

	
 
void *Blitter_32bppBase::MoveTo(const void *video, int x, int y)
src/blitter/32bpp_optimized.cpp
Show inline comments
 
/* $Id$ */
 

	
 
#include "../stdafx.h"
 
#include "../zoom.hpp"
 
#include "../gfx.h"
 
#include "../zoom_func.h"
 
#include "../gfx_func.h"
 
#include "../debug.h"
 
#include "../table/sprites.h"
 
#include "32bpp_optimized.hpp"
src/blitter/32bpp_simple.cpp
Show inline comments
 
/* $Id$ */
 

	
 
#include "../stdafx.h"
 
#include "../zoom.hpp"
 
#include "../gfx.h"
 
#include "../gfx_func.h"
 
#include "../zoom_func.h"
 
#include "../debug.h"
 
#include "../table/sprites.h"
 
#include "32bpp_simple.hpp"
src/blitter/8bpp_base.cpp
Show inline comments
 
/* $Id$ */
 

	
 
#include "../stdafx.h"
 
#include "../gfx.h"
 
#include "../gfx_func.h"
 
#include "8bpp_base.hpp"
 

	
 
void Blitter_8bppBase::DrawColorMappingRect(void *dst, int width, int height, int pal)
src/blitter/8bpp_debug.cpp
Show inline comments
 
@@ -3,8 +3,7 @@
 
/** @file 8bpp_debug.cpp */
 

	
 
#include "../stdafx.h"
 
#include "../zoom.hpp"
 
#include "../gfx.h"
 
#include "../zoom_func.h"
 
#include "../functions.h"
 
#include "8bpp_debug.hpp"
 

	
src/blitter/8bpp_optimized.cpp
Show inline comments
 
@@ -3,9 +3,9 @@
 
/** @file 8bpp_optimized.cpp */
 

	
 
#include "../stdafx.h"
 
#include "../zoom.hpp"
 
#include "../gfx.h"
 
#include "../zoom_func.h"
 
#include "../debug.h"
 
#include "../helpers.hpp"
 
#include "8bpp_optimized.hpp"
 

	
 
static FBlitter_8bppOptimized iFBlitter_8bppOptimized;
src/blitter/8bpp_simple.cpp
Show inline comments
 
@@ -3,8 +3,7 @@
 
/** @file 8bpp_simple.cpp */
 

	
 
#include "../stdafx.h"
 
#include "../zoom.hpp"
 
#include "../gfx.h"
 
#include "../zoom_func.h"
 
#include "8bpp_simple.hpp"
 

	
 
static FBlitter_8bppSimple iFBlitter_8bppSimple;
src/blitter/base.hpp
Show inline comments
 
@@ -5,7 +5,7 @@
 

	
 
#include "../spritecache.h"
 
#include "../spriteloader/spriteloader.hpp"
 
#include "../zoom.hpp"
 
#include "../zoom_type.h"
 

	
 
enum BlitterMode {
 
	BM_NORMAL,
src/bmp.cpp
Show inline comments
 
@@ -4,7 +4,6 @@
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "gfx.h"
 
#include "bmp.h"
 
#include "core/bitmath_func.hpp"
 

	
src/bmp.h
Show inline comments
 
@@ -5,6 +5,8 @@
 
#ifndef BMP_H
 
#define BMP_H
 

	
 
#include "gfx_type.h"
 

	
 
struct BmpInfo {
 
	uint32 offset;       ///< offset of bitmap data from .bmp file begining
 
	uint32 width;        ///< bitmap width
src/bridge.h
Show inline comments
 
@@ -5,6 +5,8 @@
 
#ifndef BRIDGE_H
 
#define BRIDGE_H
 

	
 
#include "gfx_type.h"
 

	
 
enum {
 
	MAX_BRIDGES = 13
 
};
src/cargotype.h
Show inline comments
 
@@ -6,6 +6,7 @@
 
#define CARGOTYPE_H
 

	
 
#include "cargo_type.h"
 
#include "gfx_type.h"
 

	
 
typedef uint32 CargoLabel;
 

	
src/command.cpp
Show inline comments
 
@@ -17,6 +17,7 @@
 
#include "genworld.h"
 
#include "newgrf_storage.h"
 
#include "strings_func.h"
 
#include "gfx_func.h"
 

	
 
const char *_cmd_text = NULL;
 

	
src/command_type.h
Show inline comments
 
@@ -7,6 +7,7 @@
 

	
 
#include "economy_type.h"
 
#include "strings_type.h"
 
#include "tile_type.h"
 

	
 
/**
 
 * Common return value for all commands. Wraps the cost and
src/core/math_func.hpp
Show inline comments
 
@@ -18,12 +18,6 @@
 
#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.
 
 *
 
 * This function returns the greater value of two given values.
src/engine.h
Show inline comments
 
@@ -10,6 +10,7 @@
 
#include "cargo_type.h"
 
#include "vehicle_type.h"
 
#include "command_type.h"
 
#include "gfx_type.h"
 
#include "sound.h"
 

	
 
enum RailVehicleTypes {
src/fontcache.cpp
Show inline comments
 
@@ -14,6 +14,7 @@
 
#include "helpers.hpp"
 
#include "spriteloader/spriteloader.hpp"
 
#include "blitter/factory.hpp"
 
#include "gfx_func.h"
 

	
 
#ifdef WITH_FREETYPE
 

	
src/fontcache.h
Show inline comments
 
@@ -3,7 +3,7 @@
 
#ifndef FONTCACHE_H
 
#define FONTCACHE_H
 

	
 
#include "gfx.h"
 
#include "gfx_type.h"
 

	
 
/** Get the SpriteID mapped to the given font size and key */
 
SpriteID GetUnicodeGlyph(FontSize size, uint32 key);
src/functions.h
Show inline comments
 
@@ -8,6 +8,7 @@
 
#include "core/random_func.hpp"
 
#include "command_type.h"
 
#include "window_type.h"
 
#include "openttd.h"
 

	
 
void UpdateTownMaxPass(Town *t);
 

	
src/gfx.cpp
Show inline comments
 
@@ -5,7 +5,7 @@
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "functions.h"
 
#include "gfx.h"
 
#include "gfx_func.h"
 
#include "spritecache.h"
 
#include "string.h"
 
#include "table/palettes.h"
 
@@ -15,7 +15,7 @@
 
#include "fontcache.h"
 
#include "genworld.h"
 
#include "debug.h"
 
#include "zoom.hpp"
 
#include "zoom_func.h"
 
#include "texteff.hpp"
 
#include "blitter/factory.hpp"
 
#include "video/video_driver.hpp"
 
@@ -41,6 +41,9 @@ int _pal_count_dirty;
 

	
 
Colour _cur_palette[256];
 
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);
 

	
 
@@ -561,7 +564,7 @@ Dimension GetStringBoundingBox(const cha
 
 * @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 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
 
 * the originally passed x-coordinate is returned */
 
int DoDrawString(const char *string, int x, int y, uint16 real_color)
src/gfx.h
Show inline comments
 
deleted file
src/gfx_func.h
Show inline comments
 
new file 100644
 
/* $Id$ */
 

	
 
/** @file gfx_func.h Functions related to the gfx engine. */
 

	
 
/**
 
 * @defgroup dirty Dirty
 
 *
 
 * Handles the repaint of some part of the screen.
 
 *
 
 * Some places in the code are called functions which makes something "dirty".
 
 * This has nothing to do with making a Tile or Window darker or less visible.
 
 * This term comes from memory caching and is used to define an object must
 
 * be repaint. If some data of an object (like a Tile, Window, Vehicle, whatever)
 
 * are changed which are so extensive the object must be repaint its marked
 
 * as "dirty". The video driver repaint this object instead of the whole screen
 
 * (this is btw. also possible if needed). This is used to avoid a
 
 * flickering of the screen by the video driver constantly repainting it.
 
 *
 
 * This whole mechanism is controlled by an rectangle defined in #_invalid_rect. This
 
 * rectangle defines the area on the screen which must be repaint. If a new object
 
 * needs to be repainted this rectangle is extended to 'catch' the object on the
 
 * screen. At some point (which is normaly uninteressted for patch writers) this
 
 * rectangle is send to the video drivers method
 
 * VideoDriver::MakeDirty and it is truncated back to an empty rectangle. At some
 
 * later point (which is uninteressted, too) the video driver
 
 * repaints all these saved rectangle instead of the whole screen and drop the
 
 * rectangle informations. Then a new round begins by marking objects "dirty".
 
 *
 
 * @see VideoDriver::MakeDirty
 
 * @see _invalid_rect
 
 * @see _screen
 
 */
 

	
 

	
 
#ifndef GFX_FUNC_H
 
#define GFX_FUNC_H
 

	
 
#include "gfx_type.h"
 
#include "strings_type.h"
 

	
 
void GameLoop();
 

	
 
void CreateConsole();
 

	
 
extern byte _dirkeys;        ///< 1 = left, 2 = up, 4 = right, 8 = down
 
extern bool _fullscreen;
 
extern CursorVars _cursor;
 
extern bool _ctrl_pressed;   ///< Is Ctrl pressed?
 
extern bool _shift_pressed;  ///< Is Shift pressed?
 
extern byte _fast_forward;
 

	
 
extern bool _left_button_down;
 
extern bool _left_button_clicked;
 
extern bool _right_button_down;
 
extern bool _right_button_clicked;
 

	
 
extern DrawPixelInfo _screen;
 

	
 
extern int _pal_first_dirty;
 
extern int _pal_count_dirty;
 
extern int _num_resolutions;
 
extern uint16 _resolutions[32][2];
 
extern uint16 _cur_resolution[2];
 
extern Colour _cur_palette[256];
 

	
 
void HandleKeypress(uint32 key);
 
void HandleMouseEvents();
 
void CSleep(int milliseconds);
 
void UpdateWindows();
 

	
 
uint32 InteractiveRandom(); //< Used for random sequences that are not the same on the other end of the multiplayer link
 
uint InteractiveRandomRange(uint max);
 
void DrawChatMessage();
 
void DrawMouseCursor();
 
void ScreenSizeChanged();
 
void HandleExitGameRequest();
 
void GameSizeChanged();
 
void UndrawMouseCursor();
 

	
 
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 DrawSprite(SpriteID img, SpriteID pal, int x, int y, const SubSprite *sub = NULL);
 

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

	
 

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

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

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

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

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

	
 
void GfxFillRect(int left, int top, int right, int bottom, int color);
 
void GfxDrawLine(int left, int top, int right, int bottom, int color);
 
void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3);
 

	
 
Dimension GetStringBoundingBox(const char *str);
 
uint32 FormatStringLinebreaks(char *str, int maxw);
 
void LoadStringWidthTable();
 
void DrawStringMultiCenter(int x, int y, StringID str, int maxw);
 
uint DrawStringMultiLine(int x, int y, StringID str, int maxw, int maxh = -1);
 

	
 
/**
 
 * Let the dirty blocks repainting by the video driver.
 
 *
 
 * @ingroup dirty
 
 */
 
void DrawDirtyBlocks();
 

	
 
/**
 
 * Set a new dirty block.
 
 *
 
 * @ingroup dirty
 
 */
 
void SetDirtyBlocks(int left, int top, int right, int bottom);
 

	
 
/**
 
 * Marks the whole screen as dirty.
 
 *
 
 * @ingroup dirty
 
 */
 
void MarkWholeScreenDirty();
 

	
 
void GfxInitPalettes();
 

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

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

	
 
void SetMouseCursor(SpriteID sprite, SpriteID pal);
 
void SetAnimatedMouseCursor(const AnimCursor *table);
 
void CursorTick();
 
void DrawMouseCursor();
 
void ScreenSizeChanged();
 
void UndrawMouseCursor();
 
bool ChangeResInGame(int w, int h);
 
void SortResolutions(int count);
 
void ToggleFullScreen(bool fs);
 

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

	
 
byte GetCharacterWidth(FontSize size, uint32 key);
 

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

	
 
extern DrawPixelInfo *_cur_dpi;
 

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

	
 
extern bool _use_dos_palette;
 

	
 
#endif /* GFX_FUNC_H */
src/gfx_type.h
Show inline comments
 
new file 100644
 
/* $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 */
src/gfxinit.cpp
Show inline comments
 
@@ -16,6 +16,7 @@
 
#include "md5.h"
 
#include "variables.h"
 
#include "fontcache.h"
 
#include "gfx_func.h"
 
#include <string.h>
 

	
 
struct MD5File {
src/gfxinit.h
Show inline comments
 
@@ -5,6 +5,8 @@
 
#ifndef GFXINIT_H
 
#define GFXINIT_H
 

	
 
#include "gfx_type.h"
 

	
 
void CheckExternalFiles();
 
void GfxLoadSprites();
 
void LoadSpritesIndexed(int file_index, uint *sprite_id, const SpriteID *index_tbl);
src/gui.h
Show inline comments
 
@@ -8,7 +8,7 @@
 
#include "string.h"
 
#include "window_type.h"
 
#include "vehicle_type.h"
 
#include "gfx.h"
 
#include "gfx_type.h"
 

	
 
/* main_gui.cpp */
 
void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2);
src/heightmap.cpp
Show inline comments
 
@@ -15,6 +15,7 @@
 
#include "saveload.h"
 
#include "bmp.h"
 
#include "helpers.hpp"
 
#include "gfx_func.h"
 

	
 
/**
 
 * Convert RGB colors to Grayscale using 29.9% Red, 58.7% Green, 11.4% Blue
src/main_gui.cpp
Show inline comments
 
@@ -50,6 +50,7 @@
 
#include "industry.h"
 
#include "transparency.h"
 
#include "strings_func.h"
 
#include "zoom_func.h"
 

	
 
static int _rename_id = 1;
 
static int _rename_what = -1;
src/misc.cpp
Show inline comments
 
@@ -25,6 +25,7 @@
 
#include "group.h"
 
#include "viewport.h"
 
#include "economy_func.h"
 
#include "zoom_func.h"
 

	
 
char _name_array[512][32];
 

	
src/misc/dbg_helpers.cpp
Show inline comments
 
@@ -2,6 +2,7 @@
 

	
 
/** @file dbg_helpers.cpp */
 
#include "../stdafx.h"
 
#include "../openttd.h"
 
#include "../direction_type.h"
 
#include "../rail.h"
 
#include "../rail_map.h"
src/misc_cmd.cpp
Show inline comments
 
@@ -19,6 +19,7 @@
 
#include "player_face.h"
 
#include "strings_func.h"
 
#include "vehicle.h"
 
#include "gfx_func.h"
 

	
 
/** Change the player's face.
 
 * @param tile unused
src/misc_gui.cpp
Show inline comments
 
@@ -40,6 +40,7 @@
 
#include "fileio.h"
 
#include "fios.h"
 
#include "tile_cmd.h"
 
#include "zoom_func.h"
 

	
 
/* Variables to display file lists */
 
FiosItem *_fios_list;
src/network/network_gui.cpp
Show inline comments
 
@@ -19,7 +19,6 @@
 
#include "../gui.h"
 
#include "../window_gui.h"
 
#include "../textbuf_gui.h"
 
#include "../gfx.h"
 
#include "../variables.h"
 
#include "network_server.h"
 
#include "network_udp.h"
src/newgrf.cpp
Show inline comments
 
@@ -47,6 +47,7 @@
 
#include "fios.h"
 
#include "rail.h"
 
#include "strings_func.h"
 
#include "gfx_func.h"
 

	
 
/* TTDPatch extended GRF format codec
 
 * (c) Petr Baudis 2004 (GPL'd)
src/newgrf_station.cpp
Show inline comments
 
@@ -23,7 +23,7 @@
 
#include "cargotype.h"
 
#include "town_map.h"
 
#include "newgrf_town.h"
 
#include "gfx.h"
 
#include "gfx_func.h"
 

	
 
static StationClass station_classes[STAT_CLASS_MAX];
 

	
src/oldloader.cpp
Show inline comments
 
@@ -24,7 +24,7 @@
 
#include "newgrf_config.h"
 
#include "ai/ai.h"
 
#include "date.h"
 
#include "zoom.hpp"
 
#include "zoom_func.h"
 

	
 
enum {
 
	HEADER_SIZE = 49,
src/openttd.cpp
Show inline comments
 
@@ -64,6 +64,7 @@
 
#include "music/music_driver.hpp"
 
#include "video/video_driver.hpp"
 
#include "strings_func.h"
 
#include "zoom_func.h"
 

	
 
#include "bridge_map.h"
 
#include "clear_map.h"
src/openttd.h
Show inline comments
 
@@ -26,12 +26,6 @@ struct DrawPixelInfo;
 
struct Group;
 
typedef byte VehicleOrderID;  ///< The index of an order within its current vehicle (not pool related)
 
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 UnitID;
 

	
src/os/macosx/splash.cpp
Show inline comments
 
@@ -5,7 +5,7 @@
 
#include "../../variables.h"
 
#include "../../debug.h"
 
#include "../../functions.h"
 
#include "../../gfx.h"
 
#include "../../gfx_func.h"
 
#include "../../fileio.h"
 
#include "../../blitter/factory.hpp"
 

	
src/players.cpp
Show inline comments
 
@@ -29,7 +29,7 @@
 
#include "window_func.h"
 
#include "tile_map.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
src/rail.h
Show inline comments
 
@@ -8,9 +8,10 @@
 
#include "rail_type.h"
 
#include "track_type.h"
 
#include "vehicle_type.h"
 
#include "gfx_type.h"
 
#include "core/bitmath_func.hpp"
 
#include "economy_func.h"
 
#include "variables.h"
 
#include "economy_func.h"
 

	
 
/** This struct contains all the info that is needed to draw and construct tracks.
 
 */
src/saveload.cpp
Show inline comments
 
@@ -28,6 +28,7 @@
 
#include "table/strings.h"
 
#include "window_func.h"
 
#include "strings_func.h"
 
#include "gfx_func.h"
 
#include <list>
 

	
 
extern const uint16 SAVEGAME_VERSION = 83;
src/screenshot.cpp
Show inline comments
 
@@ -16,6 +16,7 @@
 
#include "blitter/factory.hpp"
 
#include "fileio.h"
 
#include "strings_func.h"
 
#include "zoom_func.h"
 

	
 
char _screenshot_format_name[8];
 
uint _num_screenshot_formats;
src/signs.cpp
Show inline comments
 
@@ -16,6 +16,7 @@
 
#include "misc/autoptr.hpp"
 
#include "strings_func.h"
 
#include "viewport.h"
 
#include "zoom_func.h"
 

	
 
SignID _new_sign_id;
 
uint _total_signs;
src/smallmap_gui.cpp
Show inline comments
 
@@ -27,6 +27,7 @@
 
#include "blitter/factory.hpp"
 
#include "tunnelbridge_map.h"
 
#include "strings_func.h"
 
#include "zoom_func.h"
 

	
 

	
 
static const Widget _smallmap_widgets[] = {
src/sprite.h
Show inline comments
 
@@ -5,6 +5,8 @@
 
#ifndef SPRITE_H
 
#define SPRITE_H
 

	
 
#include "gfx_type.h"
 

	
 
#define GENERAL_SPRITE_COLOR(color) ((color) + PALETTE_RECOLOR_START)
 
#define PLAYER_SPRITE_COLOR(owner) (GENERAL_SPRITE_COLOR(_player_colors[owner]))
 

	
src/spritecache.h
Show inline comments
 
@@ -5,6 +5,8 @@
 
#ifndef SPRITECACHE_H
 
#define SPRITECACHE_H
 

	
 
#include "gfx_type.h"
 

	
 
struct Sprite {
 
	byte height;
 
	uint16 width;
src/spriteloader/grf.cpp
Show inline comments
 
@@ -3,7 +3,7 @@
 
/** @file grf.cpp */
 

	
 
#include "../stdafx.h"
 
#include "../gfx.h"
 
#include "../gfx_func.h"
 
#include "../fileio.h"
 
#include "../debug.h"
 
#include "grf.hpp"
src/spriteloader/png.cpp
Show inline comments
 
@@ -5,7 +5,7 @@
 
#ifdef WITH_PNG
 

	
 
#include "../stdafx.h"
 
#include "../gfx.h"
 
#include "../gfx_func.h"
 
#include "../fileio.h"
 
#include "../variables.h"
 
#include "../debug.h"
src/station.cpp
Show inline comments
 
@@ -32,6 +32,7 @@
 
#include "cargotype.h"
 
#include "roadveh.h"
 
#include "station_gui.h"
 
#include "zoom_func.h"
 

	
 
Station::Station(TileIndex tile)
 
{
src/stdafx.h
Show inline comments
 
@@ -374,4 +374,10 @@ assert_compile(sizeof(uint8)  == 1);
 
	#define MAX_PATH 260
 
#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 */
src/table/sprites.h
Show inline comments
 
@@ -32,6 +32,8 @@
 
 * @todo Split the "Sprites" enum into smaller chunks and document them
 
 */
 

	
 
#include "../gfx_type.h"
 

	
 
enum Sprites {
 
	SPR_SELECT_TILE  = 752,
 
	SPR_DOT          = 774, // corner marker for lower/raise land
src/transparency.h
Show inline comments
 
@@ -5,6 +5,8 @@
 
#ifndef TRANSPARENCY_H
 
#define TRANSPARENCY_H
 

	
 
#include "gfx_func.h"
 

	
 
/**
 
 * 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.
src/vehicle.cpp
Show inline comments
 
@@ -42,6 +42,7 @@
 
#include "group.h"
 
#include "order.h"
 
#include "strings_func.h"
 
#include "zoom_func.h"
 

	
 
#define INVALID_COORD (0x7fffffff)
 
#define GEN_HASH(x, y) ((GB((y), 6, 6) << 6) + GB((x), 7, 6))
src/vehicle.h
Show inline comments
 
@@ -6,16 +6,17 @@
 
#define VEHICLE_H
 

	
 
#include "vehicle_type.h"
 
#include "oldpool.h"
 
#include "order.h"
 
#include "track_type.h"
 
#include "rail_type.h"
 
#include "road_type.h"
 
#include "cargo_type.h"
 
#include "window_type.h"
 
#include "gfx_type.h"
 
#include "command_type.h"
 
#include "oldpool.h"
 
#include "order.h"
 
#include "cargopacket.h"
 
#include "texteff.hpp"
 
#include "command_type.h"
 

	
 
/** Road vehicle states */
 
enum RoadVehicleStates {
src/video/dedicated_v.cpp
Show inline comments
 
@@ -7,7 +7,7 @@
 
#include "../openttd.h"
 
#include "../debug.h"
 
#include "../functions.h"
 
#include "../gfx.h"
 
#include "../gfx_func.h"
 
#include "../network/network.h"
 
#include "../console.h"
 
#include "../variables.h"
src/video/null_v.cpp
Show inline comments
 
@@ -2,7 +2,7 @@
 

	
 
#include "../stdafx.h"
 
#include "../openttd.h"
 
#include "../gfx.h"
 
#include "../gfx_func.h"
 
#include "../variables.h"
 
#include "../debug.h"
 
#include "../blitter/factory.hpp"
src/video/sdl_v.cpp
Show inline comments
 
@@ -7,7 +7,7 @@
 
#include "../openttd.h"
 
#include "../debug.h"
 
#include "../functions.h"
 
#include "../gfx.h"
 
#include "../gfx_func.h"
 
#include "../sdl.h"
 
#include "../variables.h"
 
#include "../blitter/factory.hpp"
src/video/win32_v.cpp
Show inline comments
 
@@ -3,7 +3,7 @@
 
#include "../stdafx.h"
 
#include "../openttd.h"
 
#include "../functions.h"
 
#include "../gfx.h"
 
#include "../gfx_func.h"
 
#include "../variables.h"
 
#include "../win32.h"
 
#include "../blitter/factory.hpp"
src/viewport.cpp
Show inline comments
 
@@ -25,6 +25,7 @@
 
#include "blitter/factory.hpp"
 
#include "transparency.h"
 
#include "strings_func.h"
 
#include "zoom_func.h"
 

	
 
#define VIEWPORT_DRAW_MEM (65536 * 2)
 

	
src/viewport.h
Show inline comments
 
@@ -5,10 +5,10 @@
 
#ifndef VIEWPORT_H
 
#define VIEWPORT_H
 

	
 
#include "zoom.hpp"
 
#include "zoom_type.h"
 
#include "window_type.h"
 
#include "vehicle_type.h"
 
#include "gfx.h"
 
#include "gfx_func.h"
 

	
 
struct ViewPort {
 
	int left,top;                       // screen coordinates for the viewport
src/window.cpp
Show inline comments
 
@@ -17,6 +17,7 @@
 
#include "helpers.hpp"
 
#include "blitter/factory.hpp"
 
#include "window_gui.h"
 
#include "zoom_func.h"
 

	
 
/* delta between mouse cursor and upper left corner of dragged window */
 
static Point _drag_delta;
src/zoom.hpp
Show inline comments
 
deleted file
src/zoom_func.h
Show inline comments
 
new file 100644
 
/* $Id$ */
 

	
 
/** @file zoom.hpp */
 

	
 
#ifndef ZOOM_FUNC_H
 
#define ZOOM_FUNC_H
 

	
 
#include "zoom_type.h"
 

	
 
extern ZoomLevel _saved_scrollpos_zoom;
 

	
 
/**
 
 * Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL)
 
 * When shifting right, value is rounded up
 
 * @param value value to shift
 
 * @param zoom  zoom level to shift to
 
 * @return shifted value
 
 */
 
static inline int ScaleByZoom(int value, ZoomLevel zoom)
 
{
 
	if (zoom == ZOOM_LVL_NORMAL) return value;
 
	int izoom = zoom - ZOOM_LVL_NORMAL;
 
	return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : (value + (1 << -izoom) - 1) >> -izoom;
 
}
 

	
 
/**
 
 * Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL)
 
 * When shifting right, value is rounded up
 
 * @param value value to shift
 
 * @param zoom  zoom level to shift to
 
 * @return shifted value
 
 */
 
static inline int UnScaleByZoom(int value, ZoomLevel zoom)
 
{
 
	if (zoom == ZOOM_LVL_NORMAL) return value;
 
	int izoom = zoom - ZOOM_LVL_NORMAL;
 
	return (zoom > ZOOM_LVL_NORMAL) ? (value + (1 << izoom) - 1) >> izoom : value << -izoom;
 
}
 

	
 
/**
 
 * Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL)
 
 * @param value value to shift
 
 * @param zoom  zoom level to shift to
 
 * @return shifted value
 
 */
 
static inline int ScaleByZoomLower(int value, ZoomLevel zoom)
 
{
 
	if (zoom == ZOOM_LVL_NORMAL) return value;
 
	int izoom = zoom - ZOOM_LVL_NORMAL;
 
	return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : value >> -izoom;
 
}
 

	
 
/**
 
 * Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL)
 
 * @param value value to shift
 
 * @param zoom  zoom level to shift to
 
 * @return shifted value
 
 */
 
static inline int UnScaleByZoomLower(int value, ZoomLevel zoom)
 
{
 
	if (zoom == ZOOM_LVL_NORMAL) return value;
 
	int izoom = zoom - ZOOM_LVL_NORMAL;
 
	return (zoom > ZOOM_LVL_NORMAL) ? value >> izoom : value << -izoom;
 
}
 

	
 
#endif /* ZOOM_FUNC_H */
src/zoom_type.h
Show inline comments
 
new file 100644
 
/* $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 */
0 comments (0 inline, 0 general)