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
00110 static inline void DrawVertMapIndicator(int x, int y, int y2)
00111 {
00112 GfxFillRect(x, y, x, y + 3, PC_VERY_LIGHT_YELLOW);
00113 GfxFillRect(x, y2 - 3, x, y2, PC_VERY_LIGHT_YELLOW);
00114 }
00115
00122 static inline void DrawHorizMapIndicator(int x, int x2, int y)
00123 {
00124 GfxFillRect(x, y, x + 3, y, PC_VERY_LIGHT_YELLOW);
00125 GfxFillRect(x2 - 3, y, x2, y, PC_VERY_LIGHT_YELLOW);
00126 }
00127
00128 void DrawMapIndicators() const;
00129 void DrawSmallMapColumn(void *dst, uint xc, uint yc, int pitch, int reps, int start_pos, int end_pos, Blitter *blitter) const;
00130 void DrawVehicles(const DrawPixelInfo *dpi, Blitter *blitter) const;
00131 void DrawTowns(const DrawPixelInfo *dpi) const;
00132 void DrawSmallMap(DrawPixelInfo *dpi) const;
00133
00134 Point RemapTile(int tile_x, int tile_y) const;
00135 Point PixelToTile(int px, int py, int *sub, bool add_sub = true) const;
00136 Point ComputeScroll(int tx, int ty, int x, int y, int *sub);
00137 void SetZoomLevel(ZoomLevelChange change, const Point *zoom_pt);
00138 void SetOverlayCargoMask();
00139 void SetupWidgetData();
00140 uint32 GetTileColours(const TileArea &ta) const;
00141
00142 public:
00143 uint min_number_of_columns;
00144
00145 SmallMapWindow(const WindowDesc *desc, int window_number);
00146 virtual ~SmallMapWindow() {delete this->overlay;}
00147
00152 inline uint GetMinLegendWidth() const
00153 {
00154 return WD_FRAMERECT_LEFT + this->min_number_of_columns * this->column_width;
00155 }
00156
00161 inline uint GetNumberColumnsLegend(uint width) const
00162 {
00163 return width / this->column_width;
00164 }
00165
00171 inline uint GetLegendHeight(uint num_columns) const
00172 {
00173 return WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM +
00174 this->GetNumberRowsLegend(num_columns) * FONT_HEIGHT_SMALL;
00175 }
00176
00177 uint GetNumberRowsLegend(uint columns) const;
00178 Point GetStationMiddle(const Station *st) const;
00179 void SwitchMapType(SmallMapType map_type);
00180 void SetNewScroll(int sx, int sy, int sub);
00181 void SelectLegendItem(int click_pos, LegendAndColour *legend, int end_legend_item, int begin_legend_item = 0);
00182 void SmallMapCenterOnCurrentPos();
00183
00184 virtual void SetStringParameters(int widget) const;
00185 virtual void OnInit();
00186 virtual void OnPaint();
00187 virtual void DrawWidget(const Rect &r, int widget) const;
00188 virtual void OnClick(Point pt, int widget, int click_count);
00189 virtual void OnInvalidateData(int data = 0, bool gui_scope = true);
00190 virtual bool OnRightClick(Point pt, int widget);
00191 virtual void OnMouseWheel(int wheel);
00192 virtual void OnTick();
00193 virtual void OnScroll(Point delta);
00194 };
00195
00196 #endif