00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef SMALLMAP_GUI_H
00013 #define SMALLMAP_GUI_H
00014
00015 #include "industry_type.h"
00016 #include "window_gui.h"
00017 #include "strings_func.h"
00018 #include "blitter/factory.hpp"
00019 #include "linkgraph_gui.h"
00020 #include "widgets/smallmap_widget.h"
00021
00022
00023 void BuildLinkStatsLegend();
00024
00025 void BuildIndustriesLegend();
00026 void ShowSmallMap();
00027 void BuildLandLegend();
00028 void BuildOwnerLegend();
00029
00031 struct LegendAndColour {
00032 uint8 colour;
00033 StringID legend;
00034 IndustryType type;
00035 uint8 height;
00036 CompanyID company;
00037 bool show_on_map;
00038 bool end;
00039 bool col_break;
00040 };
00041
00043 class SmallMapWindow : public Window {
00044 protected:
00046 enum SmallMapType {
00047 SMT_CONTOUR,
00048 SMT_VEHICLES,
00049 SMT_INDUSTRY,
00050 SMT_LINKSTATS,
00051 SMT_ROUTES,
00052 SMT_VEGETATION,
00053 SMT_OWNER,
00054 };
00055
00057 enum ZoomLevelChange {
00058 ZLC_INITIALIZE,
00059 ZLC_ZOOM_OUT,
00060 ZLC_ZOOM_IN,
00061 };
00062
00063 static SmallMapType map_type;
00064 static bool show_towns;
00065
00066 static const uint LEGEND_BLOB_WIDTH = 8;
00067 static const uint INDUSTRY_MIN_NUMBER_OF_COLUMNS = 2;
00068 static const uint8 FORCE_REFRESH_PERIOD = 0x1F;
00069
00070 uint min_number_of_fixed_rows;
00071 uint column_width;
00072
00073 int32 scroll_x;
00074 int32 scroll_y;
00075 int32 subscroll;
00076 int zoom;
00077
00078 uint8 refresh;
00079 LinkGraphOverlay *overlay;
00080
00081 Point SmallmapRemapCoords(int x, int y) const;
00082
00089 static inline void DrawVertMapIndicator(int x, int y, int y2)
00090 {
00091 GfxFillRect(x, y, x, y + 3, PC_VERY_LIGHT_YELLOW);
00092 GfxFillRect(x, y2 - 3, x, y2, PC_VERY_LIGHT_YELLOW);
00093 }
00094
00101 static inline void DrawHorizMapIndicator(int x, int x2, int y)
00102 {
00103 GfxFillRect(x, y, x + 3, y, PC_VERY_LIGHT_YELLOW);
00104 GfxFillRect(x2 - 3, y, x2, y, PC_VERY_LIGHT_YELLOW);
00105 }
00106
00107 void DrawMapIndicators() const;
00108 void DrawSmallMapColumn(void *dst, uint xc, uint yc, int pitch, int reps, int start_pos, int end_pos, Blitter *blitter) const;
00109 void DrawVehicles(const DrawPixelInfo *dpi, Blitter *blitter) const;
00110 void DrawTowns(const DrawPixelInfo *dpi) const;
00111 void DrawSmallMap(DrawPixelInfo *dpi) const;
00112
00113 Point RemapTile(int tile_x, int tile_y) const;
00114 Point PixelToTile(int px, int py, int *sub, bool add_sub = true) const;
00115 Point ComputeScroll(int tx, int ty, int x, int y, int *sub);
00116 void SetZoomLevel(ZoomLevelChange change, const Point *zoom_pt);
00117 void SetOverlayCargoMask();
00118 void SetupWidgetData();
00119 uint32 GetTileColours(const TileArea &ta) const;
00120
00121 public:
00122 uint min_number_of_columns;
00123
00124 SmallMapWindow(const WindowDesc *desc, int window_number);
00125 virtual ~SmallMapWindow() {delete this->overlay;}
00126
00131 inline uint GetMinLegendWidth() const
00132 {
00133 return WD_FRAMERECT_LEFT + this->min_number_of_columns * this->column_width;
00134 }
00135
00140 inline uint GetNumberColumnsLegend(uint width) const
00141 {
00142 return width / this->column_width;
00143 }
00144
00150 inline uint GetLegendHeight(uint num_columns) const
00151 {
00152 return WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM +
00153 this->GetNumberRowsLegend(num_columns) * FONT_HEIGHT_SMALL;
00154 }
00155
00156 uint GetNumberRowsLegend(uint columns) const;
00157 Point GetStationMiddle(const Station *st) const;
00158 void SwitchMapType(SmallMapType map_type);
00159 void SetNewScroll(int sx, int sy, int sub);
00160 void SelectLegendItem(int click_pos, LegendAndColour *legend, int end_legend_item, int begin_legend_item = 0);
00161 void SmallMapCenterOnCurrentPos();
00162
00163 virtual void SetStringParameters(int widget) const;
00164 virtual void OnInit();
00165 virtual void OnPaint();
00166 virtual void DrawWidget(const Rect &r, int widget) const;
00167 virtual void OnClick(Point pt, int widget, int click_count);
00168 virtual void OnInvalidateData(int data = 0, bool gui_scope = true);
00169 virtual bool OnRightClick(Point pt, int widget);
00170 virtual void OnMouseWheel(int wheel);
00171 virtual void OnTick();
00172 virtual void OnScroll(Point delta);
00173 };
00174
00175 #endif