00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef VIEWPORT_FUNC_H
00013 #define VIEWPORT_FUNC_H
00014
00015 #include "gfx_type.h"
00016 #include "viewport_type.h"
00017 #include "window_type.h"
00018 #include "tile_type.h"
00019
00020 static const int TILE_HEIGHT_STEP = 50;
00021
00038 enum ScrollMaxOutsideMap {
00039 MAXSCROLL_OLD = 0,
00040 MAXSCROLL_NEW = 3424,
00041 };
00042
00043 void SetSelectionRed(bool);
00044
00045 void DeleteWindowViewport(Window *w);
00046 void InitializeWindowViewport(Window *w, int x, int y, int width, int height, uint32 follow_flags, ZoomLevel zoom);
00047 ViewPort *IsPtInWindowViewport(const Window *w, int x, int y);
00048 Point GetTileBelowCursor();
00049 void UpdateViewportPosition(Window *w);
00050
00051 void MarkAllViewportsDirty(int left, int top, int right, int bottom);
00052
00053 bool DoZoomInOutWindow(ZoomStateChange how, Window *w);
00054 void ZoomInOrOutToCursorWindow(bool in, Window * w);
00055 Point GetTileZoomCenterWindow(bool in, Window * w);
00056 void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out);
00057
00064 static inline void MaxZoomInOut(ZoomStateChange how, Window *w)
00065 {
00066 while (DoZoomInOutWindow(how, w)) {};
00067 }
00068
00069 void OffsetGroundSprite(int x, int y);
00070
00071 void DrawGroundSprite(SpriteID image, PaletteID pal, const SubSprite *sub = NULL, int extra_offs_x = 0, int extra_offs_y = 0);
00072 void DrawGroundSpriteAt(SpriteID image, PaletteID pal, int32 x, int32 y, int z, const SubSprite *sub = NULL, int extra_offs_x = 0, int extra_offs_y = 0);
00073 void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w, int h, int dz, int z, bool transparent = false, int bb_offset_x = 0, int bb_offset_y = 0, int bb_offset_z = 0, const SubSprite *sub = NULL);
00074 void AddChildSpriteScreen(SpriteID image, PaletteID pal, int x, int y, bool transparent = false, const SubSprite *sub = NULL);
00075 void ViewportAddString(const DrawPixelInfo *dpi, ZoomLevel small_from, const ViewportSign *sign, StringID string_normal, StringID string_small, StringID string_small_shadow, uint64 params_1, uint64 params_2 = 0, Colours colour = INVALID_COLOUR);
00076
00077 void StartSpriteCombine();
00078 void EndSpriteCombine();
00079
00080 bool HandleViewportClicked(const ViewPort *vp, int x, int y);
00081 void SetRedErrorSquare(TileIndex tile);
00082 void SetTileSelectSize(int w, int h);
00083 void SetTileSelectBigSize(int ox, int oy, int sx, int sy);
00084
00085 void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom);
00086
00087 bool ScrollWindowToTile(TileIndex tile, Window *w, bool instant = false);
00088 bool ScrollWindowTo(int x, int y, int z, Window *w, bool instant = false);
00089 uint16 GetMaxScrollOutsideMap();
00090
00091 bool ScrollMainWindowToTile(TileIndex tile, bool instant = false);
00092 bool ScrollMainWindowTo(int x, int y, int z = -1, bool instant = false);
00093
00094 void UpdateAllVirtCoords();
00095
00096 extern Point _tile_fract_coords;
00097
00098 void MarkTileDirtyByTile(TileIndex tile);
00099 void MarkTileDirtyByTileOutsideMap(int x, int y);
00100
00101 int GetRowAtTile(int viewport_y, Point tile);
00102
00103 #endif