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
00021
00022 void BuildLinkStatsLegend();
00023
00024 void BuildIndustriesLegend();
00025 void ShowSmallMap();
00026 void BuildLandLegend();
00027 void BuildOwnerLegend();
00028
00030 struct LegendAndColour {
00031 uint8 colour;
00032 StringID legend;
00033 IndustryType type;
00034 uint8 height;
00035 CompanyID company;
00036 bool show_on_map;
00037 bool end;
00038 bool col_break;
00039 };
00040
00042 enum SmallMapWindowWidgets {
00043 SM_WIDGET_CAPTION,
00044 SM_WIDGET_MAP_BORDER,
00045 SM_WIDGET_MAP,
00046 SM_WIDGET_LEGEND,
00047 SM_WIDGET_BLANK,
00048 SM_WIDGET_ZOOM_IN,
00049 SM_WIDGET_ZOOM_OUT,
00050 SM_WIDGET_CONTOUR,
00051 SM_WIDGET_VEHICLES,
00052 SM_WIDGET_INDUSTRIES,
00053 SM_WIDGET_LINKSTATS,
00054 SM_WIDGET_ROUTES,
00055 SM_WIDGET_VEGETATION,
00056 SM_WIDGET_OWNERS,
00057 SM_WIDGET_CENTERMAP,
00058 SM_WIDGET_TOGGLETOWNNAME,
00059 SM_WIDGET_SELECT_BUTTONS,
00060 SM_WIDGET_ENABLE_ALL,
00061 SM_WIDGET_DISABLE_ALL,
00062 SM_WIDGET_SHOW_HEIGHT,
00063 };
00064
00066 class SmallMapWindow : public Window {
00067 protected:
00069 enum SmallMapType {
00070 SMT_CONTOUR,
00071 SMT_VEHICLES,
00072 SMT_INDUSTRY,
00073 SMT_LINKSTATS,
00074 SMT_ROUTES,
00075 SMT_VEGETATION,
00076 SMT_OWNER,
00077 };
00078
00080 enum ZoomLevelChange {
00081 ZLC_INITIALIZE,
00082 ZLC_ZOOM_OUT,
00083 ZLC_ZOOM_IN,
00084 };
00085
00086 static SmallMapType map_type;
00087 static bool show_towns;
00088
00089 static const uint LEGEND_BLOB_WIDTH = 8;
00090 static const uint INDUSTRY_MIN_NUMBER_OF_COLUMNS = 2;
00091 static const uint8 FORCE_REFRESH_PERIOD = 0x1F;
00092
00093 uint min_number_of_fixed_rows;
00094 uint column_width;
00095
00096 int32 scroll_x;
00097 int32 scroll_y;
00098 int32 subscroll;
00099 int zoom;
00100
00101 uint8 refresh;
00102 LinkGraphOverlay *overlay;
00103
00104 Point SmallmapRemapCoords(int x, int y) const;
00105
00112 static inline void DrawVertMapIndicator(int x, int y, int y2)
00113 {
00114 GfxFillRect(x, y, x, y + 3, PC_VERY_LIGHT_YELLOW);
00115 GfxFillRect(x, y2 - 3, x, y2, PC_VERY_LIGHT_YELLOW);
00116 }
00117
00124 static inline void DrawHorizMapIndicator(int x, int x2, int y)
00125 {
00126 GfxFillRect(x, y, x + 3, y, PC_VERY_LIGHT_YELLOW);
00127 GfxFillRect(x2 - 3, y, x2, y, PC_VERY_LIGHT_YELLOW);
00128 }
00129
00130 void DrawMapIndicators() const;
00131 void DrawSmallMapColumn(void *dst, uint xc, uint yc, int pitch, int reps, int start_pos, int end_pos, Blitter *blitter) const;
00132 void DrawVehicles(const DrawPixelInfo *dpi, Blitter *blitter) const;
00133 void DrawTowns(const DrawPixelInfo *dpi) const;
00134 void DrawSmallMap(DrawPixelInfo *dpi) const;
00135
00136 Point RemapTile(int tile_x, int tile_y) const;
00137 Point PixelToTile(int px, int py, int *sub, bool add_sub = true) const;
00138 Point ComputeScroll(int tx, int ty, int x, int y, int *sub);
00139 void SetZoomLevel(ZoomLevelChange change, const Point *zoom_pt);
00140 void SetOverlayCargoMask();
00141 void SetupWidgetData();
00142 uint32 GetTileColours(const TileArea &ta) const;
00143
00144 public:
00145 uint min_number_of_columns;
00146
00147 SmallMapWindow(const WindowDesc *desc, int window_number);
00148 virtual ~SmallMapWindow() {delete this->overlay;}
00149
00154 inline uint GetMinLegendWidth() const
00155 {
00156 return WD_FRAMERECT_LEFT + this->min_number_of_columns * this->column_width;
00157 }
00158
00163 inline uint GetNumberColumnsLegend(uint width) const
00164 {
00165 return width / this->column_width;
00166 }
00167
00173 inline uint GetLegendHeight(uint num_columns) const
00174 {
00175 return WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM +
00176 this->GetNumberRowsLegend(num_columns) * FONT_HEIGHT_SMALL;
00177 }
00178
00179 uint GetNumberRowsLegend(uint columns) const;
00180 Point GetStationMiddle(const Station *st) const;
00181 void SwitchMapType(SmallMapType map_type);
00182 void SetNewScroll(int sx, int sy, int sub);
00183 void SelectLegendItem(int click_pos, LegendAndColour *legend, int end_legend_item, int begin_legend_item = 0);
00184 void SmallMapCenterOnCurrentPos();
00185
00186 virtual void SetStringParameters(int widget) const;
00187 virtual void OnInit();
00188 virtual void OnPaint();
00189 virtual void DrawWidget(const Rect &r, int widget) const;
00190 virtual void OnClick(Point pt, int widget, int click_count);
00191 virtual void OnInvalidateData(int data = 0, bool gui_scope = true);
00192 virtual bool OnRightClick(Point pt, int widget);
00193 virtual void OnMouseWheel(int wheel);
00194 virtual void OnTick();
00195 virtual void OnScroll(Point delta);
00196 };
00197
00198 #endif