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 uint FORCE_REFRESH_PERIOD = 0x1F;
00069 static const uint BLINK_PERIOD = 0x0F;
00070
00071 uint min_number_of_fixed_rows;
00072 uint column_width;
00073
00074 int32 scroll_x;
00075 int32 scroll_y;
00076 int32 subscroll;
00077 int zoom;
00078
00079 uint8 refresh;
00080 LinkGraphOverlay *overlay;
00081
00082 Point SmallmapRemapCoords(int x, int y) const;
00083
00090 static inline void DrawVertMapIndicator(int x, int y, int y2)
00091 {
00092 GfxFillRect(x, y, x, y + 3, PC_VERY_LIGHT_YELLOW);
00093 GfxFillRect(x, y2 - 3, x, y2, PC_VERY_LIGHT_YELLOW);
00094 }
00095
00102 static inline void DrawHorizMapIndicator(int x, int x2, int y)
00103 {
00104 GfxFillRect(x, y, x + 3, y, PC_VERY_LIGHT_YELLOW);
00105 GfxFillRect(x2 - 3, y, x2, y, PC_VERY_LIGHT_YELLOW);
00106 }
00107
00108 void DrawMapIndicators() const;
00109 void DrawSmallMapColumn(void *dst, uint xc, uint yc, int pitch, int reps, int start_pos, int end_pos, Blitter *blitter) const;
00110 void DrawVehicles(const DrawPixelInfo *dpi, Blitter *blitter) const;
00111 void DrawTowns(const DrawPixelInfo *dpi) const;
00112 void DrawSmallMap(DrawPixelInfo *dpi) const;
00113
00114 Point RemapTile(int tile_x, int tile_y) const;
00115 Point PixelToTile(int px, int py, int *sub, bool add_sub = true) const;
00116 Point ComputeScroll(int tx, int ty, int x, int y, int *sub);
00117 void SetZoomLevel(ZoomLevelChange change, const Point *zoom_pt);
00118 void SetOverlayCargoMask();
00119 void SetupWidgetData();
00120 uint32 GetTileColours(const TileArea &ta) const;
00121
00122 int GetPositionOnLegend(Point pt);
00123
00124
00125 public:
00126 uint min_number_of_columns;
00127
00128 SmallMapWindow(const WindowDesc *desc, int window_number);
00129 virtual ~SmallMapWindow() {delete this->overlay;}
00130
00135 inline uint GetMinLegendWidth() const
00136 {
00137 return WD_FRAMERECT_LEFT + this->min_number_of_columns * this->column_width;
00138 }
00139
00144 inline uint GetNumberColumnsLegend(uint width) const
00145 {
00146 return width / this->column_width;
00147 }
00148
00154 inline uint GetLegendHeight(uint num_columns) const
00155 {
00156 return WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM +
00157 this->GetNumberRowsLegend(num_columns) * FONT_HEIGHT_SMALL;
00158 }
00159
00160 uint GetNumberRowsLegend(uint columns) const;
00161 Point GetStationMiddle(const Station *st) const;
00162 void SwitchMapType(SmallMapType map_type);
00163 void SetNewScroll(int sx, int sy, int sub);
00164 void SelectLegendItem(int click_pos, LegendAndColour *legend, int end_legend_item, int begin_legend_item = 0);
00165 void SmallMapCenterOnCurrentPos();
00166
00167 virtual void SetStringParameters(int widget) const;
00168 virtual void OnInit();
00169 virtual void OnPaint();
00170 virtual void DrawWidget(const Rect &r, int widget) const;
00171 virtual void OnClick(Point pt, int widget, int click_count);
00172 virtual void OnInvalidateData(int data = 0, bool gui_scope = true);
00173 virtual bool OnRightClick(Point pt, int widget);
00174 virtual void OnMouseWheel(int wheel);
00175 virtual void OnTick();
00176 virtual void OnScroll(Point delta);
00177 virtual void OnMouseOver(Point pt, int widget);
00178 };
00179
00180 #endif