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"
 
#include "32bpp_anim.hpp"
 

	
 
static FBlitter_32bppAnim iFBlitter_32bppAnim;
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)
 
{
 
	return (uint32 *)video + x + y * _screen.pitch;
 
}
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"
 

	
 
static FBlitter_32bppOptimized iFBlitter_32bppOptimized;
 

	
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"
 

	
 
static FBlitter_32bppSimple iFBlitter_32bppSimple;
 

	
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)
 
{
 
	const uint8 *ctab = GetNonSprite(pal) + 1;
 

	
src/blitter/8bpp_debug.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file 8bpp_debug.cpp */
 

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

	
 
static FBlitter_8bppDebug iFBlitter_8bppDebug;
 

	
 
void Blitter_8bppDebug::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
src/blitter/8bpp_optimized.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @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;
 

	
 
void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
 
{
src/blitter/8bpp_simple.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @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;
 

	
 
void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
 
{
src/blitter/base.hpp
Show inline comments
 
@@ -2,13 +2,13 @@
 

	
 
#ifndef BLITTER_BASE_HPP
 
#define BLITTER_BASE_HPP
 

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

	
 
enum BlitterMode {
 
	BM_NORMAL,
 
	BM_COLOUR_REMAP,
 
	BM_TRANSPARENT,
 
};
src/bmp.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file bmp.cpp */
 

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

	
 
void BmpInitializeBuffer(BmpBuffer *buffer, FILE *file)
 
{
 
	buffer->pos      = -1;
src/bmp.h
Show inline comments
 
@@ -2,12 +2,14 @@
 

	
 
/** @file bmp.h */
 

	
 
#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
 
	uint32 height;       ///< bitmap height
 
	bool os2_bmp;        ///< true if OS/2 1.x or windows 2.x bitmap
 
	uint16 bpp;          ///< bits per pixel
src/bridge.h
Show inline comments
 
@@ -2,12 +2,14 @@
 

	
 
/** @file bridge.h Header file for bridges */
 

	
 
#ifndef BRIDGE_H
 
#define BRIDGE_H
 

	
 
#include "gfx_type.h"
 

	
 
enum {
 
	MAX_BRIDGES = 13
 
};
 

	
 
/** Struct containing information about a single bridge type
 
 */
src/cargotype.h
Show inline comments
 
@@ -3,12 +3,13 @@
 
/** @file cargotype.h */
 

	
 
#ifndef CARGOTYPE_H
 
#define CARGOTYPE_H
 

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

	
 
typedef uint32 CargoLabel;
 

	
 
enum TownEffect {
 
	TE_NONE,
 
	TE_PASSENGERS,
src/command.cpp
Show inline comments
 
@@ -14,12 +14,13 @@
 
#include "player.h"
 
#include "network/network.h"
 
#include "variables.h"
 
#include "genworld.h"
 
#include "newgrf_storage.h"
 
#include "strings_func.h"
 
#include "gfx_func.h"
 

	
 
const char *_cmd_text = NULL;
 

	
 
/**
 
 * Helper macro to define the header of all command handler macros.
 
 *
src/command_type.h
Show inline comments
 
@@ -4,12 +4,13 @@
 

	
 
#ifndef COMMAND_TYPE_H
 
#define COMMAND_TYPE_H
 

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

	
 
/**
 
 * Common return value for all commands. Wraps the cost and
 
 * a possible error message/state together.
 
 */
 
class CommandCost {
src/core/math_func.hpp
Show inline comments
 
@@ -15,18 +15,12 @@
 

	
 
#ifdef abs
 
#undef abs
 
#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.
 
 * If they are equal the value of a is returned.
 
 *
 
 * @param a The first value
src/engine.h
Show inline comments
 
@@ -7,12 +7,13 @@
 

	
 
#include "oldpool.h"
 
#include "rail_type.h"
 
#include "cargo_type.h"
 
#include "vehicle_type.h"
 
#include "command_type.h"
 
#include "gfx_type.h"
 
#include "sound.h"
 

	
 
enum RailVehicleTypes {
 
	RAILVEH_SINGLEHEAD,  ///< indicates a "standalone" locomotive
 
	RAILVEH_MULTIHEAD,   ///< indicates a combination of two locomotives
 
	RAILVEH_WAGON,       ///< simple wagon, not motorized
src/fontcache.cpp
Show inline comments
 
@@ -11,12 +11,13 @@
 
#include "spritecache.h"
 
#include "string.h"
 
#include "fontcache.h"
 
#include "helpers.hpp"
 
#include "spriteloader/spriteloader.hpp"
 
#include "blitter/factory.hpp"
 
#include "gfx_func.h"
 

	
 
#ifdef WITH_FREETYPE
 

	
 
#include <ft2build.h>
 
#include FT_FREETYPE_H
 
#include FT_GLYPH_H
src/fontcache.h
Show inline comments
 
/* $Id$ */
 

	
 
#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);
 

	
 
/** Map a SpriteID to the font size and key */
 
void SetUnicodeGlyph(FontSize size, uint32 key, SpriteID sprite);
src/functions.h
Show inline comments
 
@@ -5,12 +5,13 @@
 
#ifndef FUNCTIONS_H
 
#define FUNCTIONS_H
 

	
 
#include "core/random_func.hpp"
 
#include "command_type.h"
 
#include "window_type.h"
 
#include "openttd.h"
 

	
 
void UpdateTownMaxPass(Town *t);
 

	
 
/* clear_land.cpp */
 
void DrawHillyLandTile(const TileInfo *ti);
 
void DrawClearLandTile(const TileInfo *ti, byte set);
src/gfx.cpp
Show inline comments
 
@@ -2,23 +2,23 @@
 

	
 
/** @file gfx.cpp */
 

	
 
#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"
 
#include "table/sprites.h"
 
#include "variables.h"
 
#include "table/control_codes.h"
 
#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"
 
#include "strings_func.h"
 

	
 
byte _dirkeys;        ///< 1 = left, 2 = up, 4 = right, 8 = down
 
@@ -38,12 +38,15 @@ byte _game_mode;
 
byte _pause_game;
 
int _pal_first_dirty;
 
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);
 

	
 
FontSize _cur_fontsize;
 
static FontSize _last_fontsize;
 
static uint8 _cursor_backup[64 * 64 * 4];
 
@@ -558,13 +561,13 @@ Dimension GetStringBoundingBox(const cha
 

	
 
/** Draw a string at the given coordinates with the given colour
 
 * @param string the string to draw
 
 * @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)
 
{
 
	DrawPixelInfo *dpi = _cur_dpi;
 
	FontSize size = _cur_fontsize;
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
 
@@ -13,12 +13,13 @@
 
#include "fios.h"
 
#include "string.h"
 
#include "newgrf.h"
 
#include "md5.h"
 
#include "variables.h"
 
#include "fontcache.h"
 
#include "gfx_func.h"
 
#include <string.h>
 

	
 
struct MD5File {
 
	const char * filename;     ///< filename
 
	md5_byte_t hash[16];       ///< md5 sum of the file
 
};
src/gfxinit.h
Show inline comments
 
@@ -2,11 +2,13 @@
 

	
 
/** @file gfxinit.h */
 

	
 
#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);
 

	
 
#endif /* GFXINIT_H */
src/gui.h
Show inline comments
 
@@ -5,13 +5,13 @@
 
#ifndef GUI_H
 
#define GUI_H
 

	
 
#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);
 
void CcBuildCanal(bool success, TileIndex tile, uint32 p1, uint32 p2);
 
void CcTerraform(bool success, TileIndex tile, uint32 p1, uint32 p2);
 

	
src/heightmap.cpp
Show inline comments
 
@@ -12,12 +12,13 @@
 
#include "void_map.h"
 
#include "debug.h"
 
#include "gui.h"
 
#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
 
 *  (average luminosity formula) -- Dalestan
 
 * This in fact is the NTSC Color Space -- TrueLight
 
 */
src/main_gui.cpp
Show inline comments
 
@@ -47,12 +47,13 @@
 
#include "network/network_client.h"
 
#include "network/network_server.h"
 
#include "network/network_gui.h"
 
#include "industry.h"
 
#include "transparency.h"
 
#include "strings_func.h"
 
#include "zoom_func.h"
 

	
 
static int _rename_id = 1;
 
static int _rename_what = -1;
 

	
 
static byte _terraform_size = 1;
 
RailType _last_built_railtype;
src/misc.cpp
Show inline comments
 
@@ -22,12 +22,13 @@
 
#include "newgrf_house.h"
 
#include "date.h"
 
#include "cargotype.h"
 
#include "group.h"
 
#include "viewport.h"
 
#include "economy_func.h"
 
#include "zoom_func.h"
 

	
 
char _name_array[512][32];
 

	
 
void InitializeVehicles();
 
void InitializeWaypoints();
 
void InitializeDepots();
src/misc/dbg_helpers.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file dbg_helpers.cpp */
 
#include "../stdafx.h"
 
#include "../openttd.h"
 
#include "../direction_type.h"
 
#include "../rail.h"
 
#include "../rail_map.h"
 
#include "dbg_helpers.h"
 

	
 
/** Trackdir & TrackdirBits short names. */
src/misc_cmd.cpp
Show inline comments
 
@@ -16,12 +16,13 @@
 
#include "network/network.h"
 
#include "variables.h"
 
#include "livery.h"
 
#include "player_face.h"
 
#include "strings_func.h"
 
#include "vehicle.h"
 
#include "gfx_func.h"
 

	
 
/** Change the player's face.
 
 * @param tile unused
 
 * @param flags operation to perform
 
 * @param p1 unused
 
 * @param p2 face bitmasked
src/misc_gui.cpp
Show inline comments
 
@@ -37,12 +37,13 @@
 
#include "cargotype.h"
 
#include "player_face.h"
 
#include "strings_func.h"
 
#include "fileio.h"
 
#include "fios.h"
 
#include "tile_cmd.h"
 
#include "zoom_func.h"
 

	
 
/* Variables to display file lists */
 
FiosItem *_fios_list;
 
int _saveload_mode;
 

	
 

	
src/network/network_gui.cpp
Show inline comments
 
@@ -16,13 +16,12 @@
 
#include "network_client.h"
 
#include "network_gui.h"
 
#include "network_gamelist.h"
 
#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"
 
#include "../settings.h"
 
#include "../string.h"
 
#include "../town.h"
src/newgrf.cpp
Show inline comments
 
@@ -44,12 +44,13 @@
 
#include "newgrf_industries.h"
 
#include "table/landscape_sprite.h"
 
#include "gfxinit.h"
 
#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)
 
 * Changes by Florian octo Forster are (c) by the OpenTTD development team.
 
 *
 
 * Contains portions of documentation by TTDPatch team.
src/newgrf_station.cpp
Show inline comments
 
@@ -20,13 +20,13 @@
 
#include "newgrf_spritegroup.h"
 
#include "date.h"
 
#include "helpers.hpp"
 
#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];
 

	
 
enum {
 
	MAX_SPECLIST = 255,
 
};
src/oldloader.cpp
Show inline comments
 
@@ -21,13 +21,13 @@
 
#include "signs.h"
 
#include "debug.h"
 
#include "depot.h"
 
#include "newgrf_config.h"
 
#include "ai/ai.h"
 
#include "date.h"
 
#include "zoom.hpp"
 
#include "zoom_func.h"
 

	
 
enum {
 
	HEADER_SIZE = 49,
 
	BUFFER_SIZE = 4096,
 

	
 
	OLD_MAP_SIZE = 256 * 256
src/openttd.cpp
Show inline comments
 
@@ -61,12 +61,13 @@
 
#include "group.h"
 
#include "blitter/factory.hpp"
 
#include "sound/sound_driver.hpp"
 
#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"
 
#include "rail_map.h"
 
#include "road_map.h"
 
#include "water_map.h"
src/openttd.h
Show inline comments
 
@@ -23,18 +23,12 @@ struct Town;
 
struct NewsItem;
 
struct Industry;
 
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;
 

	
 
typedef EngineID *EngineList; ///< engine list type placeholder acceptable for C code (see helpers.cpp)
 

	
 
/* IDs used in Pools */
src/os/macosx/splash.cpp
Show inline comments
 
@@ -2,13 +2,13 @@
 

	
 
#include "../../stdafx.h"
 
#include "../../openttd.h"
 
#include "../../variables.h"
 
#include "../../debug.h"
 
#include "../../functions.h"
 
#include "../../gfx.h"
 
#include "../../gfx_func.h"
 
#include "../../fileio.h"
 
#include "../../blitter/factory.hpp"
 

	
 
#include "splash.h"
 

	
 
#ifdef WITH_PNG
src/players.cpp
Show inline comments
 
@@ -26,13 +26,13 @@
 
#include "player_face.h"
 
#include "group.h"
 
#include "settings.h"
 
#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
 
 * per-company (player) basis to reflect the core's state in the GUI.
 
 * @param new_player the new player
 
 * @pre IsValidPlayer(new_player) || new_player == PLAYER_SPECTATOR || new_player == OWNER_NONE
src/rail.h
Show inline comments
 
@@ -5,15 +5,16 @@
 
#ifndef RAIL_H
 
#define RAIL_H
 

	
 
#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.
 
 */
 
struct RailtypeInfo {
 
	/** Struct containing the main sprites. @note not all sprites are listed, but only
 
	 *  the ones used directly in the code */
src/saveload.cpp
Show inline comments
 
@@ -25,12 +25,13 @@
 
#include "saveload.h"
 
#include "network/network.h"
 
#include "variables.h"
 
#include "table/strings.h"
 
#include "window_func.h"
 
#include "strings_func.h"
 
#include "gfx_func.h"
 
#include <list>
 

	
 
extern const uint16 SAVEGAME_VERSION = 83;
 
uint16 _sl_version;       ///< the major savegame version identifier
 
byte   _sl_minor_version; ///< the minor savegame version, DO NOT USE!
 

	
src/screenshot.cpp
Show inline comments
 
@@ -13,12 +13,13 @@
 
#include "date.h"
 
#include "string.h"
 
#include "helpers.hpp"
 
#include "blitter/factory.hpp"
 
#include "fileio.h"
 
#include "strings_func.h"
 
#include "zoom_func.h"
 

	
 
char _screenshot_format_name[8];
 
uint _num_screenshot_formats;
 
uint _cur_screenshot_format;
 
ScreenshotType current_screenshot_type;
 

	
src/signs.cpp
Show inline comments
 
@@ -13,12 +13,13 @@
 
#include "command_func.h"
 
#include "variables.h"
 
#include "string.h"
 
#include "misc/autoptr.hpp"
 
#include "strings_func.h"
 
#include "viewport.h"
 
#include "zoom_func.h"
 

	
 
SignID _new_sign_id;
 
uint _total_signs;
 

	
 
/* Initialize the sign-pool */
 
DEFINE_OLD_POOL_GENERIC(Sign, Sign)
src/smallmap_gui.cpp
Show inline comments
 
@@ -24,12 +24,13 @@
 
#include "town.h"
 
#include "sound.h"
 
#include "variables.h"
 
#include "blitter/factory.hpp"
 
#include "tunnelbridge_map.h"
 
#include "strings_func.h"
 
#include "zoom_func.h"
 

	
 

	
 
static const Widget _smallmap_widgets[] = {
 
{  WWT_CLOSEBOX,   RESIZE_NONE,    13,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
 
{   WWT_CAPTION,  RESIZE_RIGHT,    13,    11,   337,     0,    13, STR_00B0_MAP,            STR_018C_WINDOW_TITLE_DRAG_THIS},
 
{ WWT_STICKYBOX,     RESIZE_LR,    13,   338,   349,     0,    13, 0x0,                     STR_STICKY_BUTTON},
src/sprite.h
Show inline comments
 
@@ -2,12 +2,14 @@
 

	
 
/** @file sprite.h */
 

	
 
#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]))
 

	
 
/**
 
 * Whether a sprite comes from the original graphics files or a new grf file
 
 * (either supplied by OpenTTD or supplied by the user).
src/spritecache.h
Show inline comments
 
@@ -2,12 +2,14 @@
 

	
 
/** @file spritecache.h */
 

	
 
#ifndef SPRITECACHE_H
 
#define SPRITECACHE_H
 

	
 
#include "gfx_type.h"
 

	
 
struct Sprite {
 
	byte height;
 
	uint16 width;
 
	int16 x_offs;
 
	int16 y_offs;
 
	byte data[VARARRAY_SIZE];
src/spriteloader/grf.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file grf.cpp */
 

	
 
#include "../stdafx.h"
 
#include "../gfx.h"
 
#include "../gfx_func.h"
 
#include "../fileio.h"
 
#include "../debug.h"
 
#include "grf.hpp"
 

	
 
bool SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite *sprite, const char *filename, uint8 file_slot, uint32 file_pos)
 
{
src/spriteloader/png.cpp
Show inline comments
 
@@ -2,13 +2,13 @@
 

	
 
/** @file grf.cpp */
 

	
 
#ifdef WITH_PNG
 

	
 
#include "../stdafx.h"
 
#include "../gfx.h"
 
#include "../gfx_func.h"
 
#include "../fileio.h"
 
#include "../variables.h"
 
#include "../debug.h"
 
#include "png.hpp"
 
#include <png.h>
 

	
src/station.cpp
Show inline comments
 
@@ -29,12 +29,13 @@
 
#include "yapf/yapf.h"
 
#include "date.h"
 
#include "helpers.hpp"
 
#include "cargotype.h"
 
#include "roadveh.h"
 
#include "station_gui.h"
 
#include "zoom_func.h"
 

	
 
Station::Station(TileIndex tile)
 
{
 
	DEBUG(station, cDebugCtorLevel, "I+%3d", index);
 

	
 
	xy = tile;
src/stdafx.h
Show inline comments
 
@@ -371,7 +371,13 @@ assert_compile(sizeof(uint8)  == 1);
 
#endif /* !defined(MORPHOS) && !defined(OPENBSD) */
 

	
 
#if !defined(MAX_PATH)
 
	#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
 
@@ -29,12 +29,14 @@
 
 * get a proper editor. If your Operating Systems don't have any decent editors,
 
 * get a proper Operating System.
 
 *
 
 * @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
 
	SPR_DOT_SMALL    = 4078,
 
	SPR_WHITE_POINT  = 4079,
 

	
src/transparency.h
Show inline comments
 
@@ -2,12 +2,14 @@
 

	
 
/** @file transparency.h */
 

	
 
#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.
 
 * If you add or remove an option don't forget to change the transparency 'hot keys' in main_gui.cpp.
 
 * If you add an option and have more then 8, change the typedef TransparencyOptionBits and
 
 * the save stuff (e.g. SLE_UINT8 to SLE_UINT16) in settings.cpp .
src/vehicle.cpp
Show inline comments
 
@@ -39,12 +39,13 @@
 
#include "newgrf_engine.h"
 
#include "newgrf_sound.h"
 
#include "helpers.hpp"
 
#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))
 

	
 

	
 
/* Tables used in vehicle.h to find the right command for a certain vehicle type */
src/vehicle.h
Show inline comments
 
@@ -3,22 +3,23 @@
 
/** @vehicle.h */
 

	
 
#ifndef VEHICLE_H
 
#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 {
 
	/*
 
	 * Lower 4 bits are used for vehicle track direction. (Trackdirs)
 
	 * When in a road stop (bit 5 or bit 6 set) these bits give the
src/video/dedicated_v.cpp
Show inline comments
 
@@ -4,13 +4,13 @@
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#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"
 
#include "../genworld.h"
 
#include "../fileio.h"
 
#include "../blitter/factory.hpp"
src/video/null_v.cpp
Show inline comments
 
/* $Id$ */
 

	
 
#include "../stdafx.h"
 
#include "../openttd.h"
 
#include "../gfx.h"
 
#include "../gfx_func.h"
 
#include "../variables.h"
 
#include "../debug.h"
 
#include "../blitter/factory.hpp"
 
#include "null_v.h"
 

	
 
static FVideoDriver_Null iFVideoDriver_Null;
src/video/sdl_v.cpp
Show inline comments
 
@@ -4,13 +4,13 @@
 

	
 
#ifdef WITH_SDL
 

	
 
#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"
 
#include "../network/network.h"
 
#include "sdl_v.h"
 
#include <SDL.h>
src/video/win32_v.cpp
Show inline comments
 
/* $Id$ */
 

	
 
#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"
 
#include "../network/network.h"
 
#include "win32_v.h"
 
#include <windows.h>
src/viewport.cpp
Show inline comments
 
@@ -22,12 +22,13 @@
 
#include "train.h"
 
#include "roadveh.h"
 
#include "vehicle_gui.h"
 
#include "blitter/factory.hpp"
 
#include "transparency.h"
 
#include "strings_func.h"
 
#include "zoom_func.h"
 

	
 
#define VIEWPORT_DRAW_MEM (65536 * 2)
 

	
 
ZoomLevel _saved_scrollpos_zoom;
 

	
 
/**
src/viewport.h
Show inline comments
 
@@ -2,16 +2,16 @@
 

	
 
/** @file viewport.h */
 

	
 
#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
 
	int width, height;                  // screen width/height for the viewport
 

	
 
	int virtual_left, virtual_top;      // virtual coordinates
src/window.cpp
Show inline comments
 
@@ -14,12 +14,13 @@
 
#include "variables.h"
 
#include "table/sprites.h"
 
#include "genworld.h"
 
#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;
 

	
 
static Window _windows[MAX_NUMBER_OF_WINDOWS];
 
Window *_z_windows[lengthof(_windows)];
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)