gfx_func.h

Go to the documentation of this file.
00001 /* $Id: gfx_func.h 15425 2009-02-09 02:09:47Z rubidium $ */
00002 
00035 #ifndef GFX_FUNC_H
00036 #define GFX_FUNC_H
00037 
00038 #include "gfx_type.h"
00039 #include "strings_type.h"
00040 
00041 void GameLoop();
00042 
00043 void CreateConsole();
00044 
00045 extern byte _dirkeys;        
00046 extern bool _fullscreen;
00047 extern CursorVars _cursor;
00048 extern bool _ctrl_pressed;   
00049 extern bool _shift_pressed;  
00050 extern byte _fast_forward;
00051 
00052 extern bool _left_button_down;
00053 extern bool _left_button_clicked;
00054 extern bool _right_button_down;
00055 extern bool _right_button_clicked;
00056 
00057 extern DrawPixelInfo _screen;
00058 extern bool _screen_disable_anim;   
00059 
00060 extern int _pal_first_dirty;
00061 extern int _pal_count_dirty;
00062 extern int _num_resolutions;
00063 extern Dimension _resolutions[32];
00064 extern Dimension _cur_resolution;
00065 extern Colour _cur_palette[256]; 
00066 
00067 void HandleKeypress(uint32 key);
00068 void HandleCtrlChanged();
00069 void HandleMouseEvents();
00070 void CSleep(int milliseconds);
00071 void UpdateWindows();
00072 
00073 void DrawMouseCursor();
00074 void ScreenSizeChanged();
00075 void GameSizeChanged();
00076 void UndrawMouseCursor();
00077 
00078 enum {
00079   /* Size of the buffer used for drawing strings. */
00080   DRAW_STRING_BUFFER = 2048,
00081 };
00082 
00083 void RedrawScreenRect(int left, int top, int right, int bottom);
00084 void GfxScroll(int left, int top, int width, int height, int xo, int yo);
00085 
00086 void DrawSprite(SpriteID img, SpriteID pal, int x, int y, const SubSprite *sub = NULL);
00087 
00088 int DrawStringCentered(int x, int y, StringID str, TextColour colour);
00089 int DrawStringCenteredTruncated(int xl, int xr, int y, StringID str, TextColour colour);
00090 int DoDrawStringCentered(int x, int y, const char *str, TextColour colour);
00091 
00092 int DrawString(int x, int y, StringID str, TextColour colour);
00093 int DrawStringTruncated(int x, int y, StringID str, TextColour colour, uint maxw);
00094 
00095 int DoDrawString(const char *string, int x, int y, TextColour colour, bool parse_string_also_when_clipped = false);
00096 int DoDrawStringTruncated(const char *str, int x, int y, TextColour colour, uint maxw);
00097 
00098 void DrawStringCenterUnderline(int x, int y, StringID str, TextColour colour);
00099 void DrawStringCenterUnderlineTruncated(int xl, int xr, int y, StringID str, TextColour colour);
00100 
00101 int DrawStringRightAligned(int x, int y, StringID str, TextColour colour);
00102 void DrawStringRightAlignedTruncated(int x, int y, StringID str, TextColour colour, uint maxw);
00103 void DrawStringRightAlignedUnderline(int x, int y, StringID str, TextColour colour);
00104 
00105 void DrawCharCentered(uint32 c, int x, int y, TextColour colour);
00106 
00107 void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode = FILLRECT_OPAQUE);
00108 void GfxDrawLine(int left, int top, int right, int bottom, int colour);
00109 void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3);
00110 
00111 Dimension GetStringBoundingBox(const char *str);
00112 uint32 FormatStringLinebreaks(char *str, int maxw);
00113 int GetStringHeight(StringID str, int maxw);
00114 void LoadStringWidthTable();
00115 void DrawStringMultiCenter(int x, int y, StringID str, int maxw);
00116 uint DrawStringMultiLine(int x, int y, StringID str, int maxw, int maxh = -1);
00117 
00123 void DrawDirtyBlocks();
00124 
00130 void SetDirtyBlocks(int left, int top, int right, int bottom);
00131 
00137 void MarkWholeScreenDirty();
00138 
00139 void GfxInitPalettes();
00140 
00141 bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height);
00142 
00143 /* window.cpp */
00144 void DrawOverlappedWindowForAll(int left, int top, int right, int bottom);
00145 
00146 void SetMouseCursor(SpriteID sprite, SpriteID pal);
00147 void SetAnimatedMouseCursor(const AnimCursor *table);
00148 void CursorTick();
00149 bool ChangeResInGame(int w, int h);
00150 void SortResolutions(int count);
00151 bool ToggleFullScreen(bool fs);
00152 
00153 /* gfx.cpp */
00154 #define ASCII_LETTERSTART 32
00155 extern FontSize _cur_fontsize;
00156 
00157 byte GetCharacterWidth(FontSize size, uint32 key);
00158 
00164 static inline byte GetCharacterHeight(FontSize size)
00165 {
00166   switch (size) {
00167     default: NOT_REACHED();
00168     case FS_NORMAL: return 10;
00169     case FS_SMALL:  return 6;
00170     case FS_LARGE:  return 18;
00171   }
00172 }
00173 
00174 extern DrawPixelInfo *_cur_dpi;
00175 
00180 extern byte _colour_gradient[COLOUR_END][8];
00181 
00182 extern PaletteType _use_palette;
00183 extern bool _palette_remap_grf[];
00184 extern const byte *_palette_remap;
00185 extern const byte *_palette_reverse_remap;
00186 
00187 #endif /* GFX_FUNC_H */

Generated on Mon Mar 9 23:33:47 2009 for openttd by  doxygen 1.5.6