798 this->scroll_x = (y - x) & ~0xF; |
798 this->scroll_x = (y - x) & ~0xF; |
799 this->scroll_y = (x + y) & ~0xF; |
799 this->scroll_y = (x + y) & ~0xF; |
800 this->SetDirty(); |
800 this->SetDirty(); |
801 } |
801 } |
802 |
802 |
803 SmallMapWindow(const WindowDesc *desc, void *data, int window_number) : Window(desc, data, window_number) |
803 SmallMapWindow(const WindowDesc *desc, int window_number) : Window(desc, window_number) |
804 { |
804 { |
805 /* Resize the window to fit industries list */ |
805 /* Resize the window to fit industries list */ |
806 if (_industries_per_column > BASE_NB_PER_COLUMN) { |
806 if (_industries_per_column > BASE_NB_PER_COLUMN) { |
807 uint diff = ((_industries_per_column - BASE_NB_PER_COLUMN) * BASE_NB_PER_COLUMN) + 1; |
807 uint diff = ((_industries_per_column - BASE_NB_PER_COLUMN) * BASE_NB_PER_COLUMN) + 1; |
808 |
808 |
1119 EVW_SPACER2, |
1119 EVW_SPACER2, |
1120 EVW_RESIZE, |
1120 EVW_RESIZE, |
1121 }; |
1121 }; |
1122 |
1122 |
1123 public: |
1123 public: |
1124 ExtraViewportWindow(const WindowDesc *desc, void *data, int window_number) : Window(desc, data, window_number) |
1124 ExtraViewportWindow(const WindowDesc *desc, int window_number, TileIndex tile) : Window(desc, window_number) |
1125 { |
1125 { |
1126 /* New viewport start at (zero,zero) */ |
1126 /* New viewport start at (zero,zero) */ |
1127 InitializeWindowViewport(this, 3, 17, this->widget[EVW_VIEWPORT].right - this->widget[EVW_VIEWPORT].left - 1, this->widget[EVW_VIEWPORT].bottom - this->widget[EVW_VIEWPORT].top - 1, 0, ZOOM_LVL_VIEWPORT); |
1127 InitializeWindowViewport(this, 3, 17, this->widget[EVW_VIEWPORT].right - this->widget[EVW_VIEWPORT].left - 1, this->widget[EVW_VIEWPORT].bottom - this->widget[EVW_VIEWPORT].top - 1, 0, ZOOM_LVL_VIEWPORT); |
1128 |
1128 |
1129 this->DisableWidget(EVW_ZOOMIN); |
1129 this->DisableWidget(EVW_ZOOMIN); |
1130 this->FindWindowPlacementAndResize(desc); |
1130 this->FindWindowPlacementAndResize(desc); |
1131 |
1131 |
1132 Point pt; |
1132 Point pt; |
1133 TileIndex tile = *(TileIndex*)data; |
|
1134 if (tile == INVALID_TILE) { |
1133 if (tile == INVALID_TILE) { |
1135 /* the main window with the main view */ |
1134 /* the main window with the main view */ |
1136 const Window *w = FindWindowById(WC_MAIN_WINDOW, 0); |
1135 const Window *w = FindWindowById(WC_MAIN_WINDOW, 0); |
1137 |
1136 |
1138 /* center on same place as main window (zoom is maximum, no adjustment needed) */ |
1137 /* center on same place as main window (zoom is maximum, no adjustment needed) */ |
1233 int i = 0; |
1232 int i = 0; |
1234 |
1233 |
1235 /* find next free window number for extra viewport */ |
1234 /* find next free window number for extra viewport */ |
1236 while (FindWindowById(WC_EXTRA_VIEW_PORT, i) != NULL) i++; |
1235 while (FindWindowById(WC_EXTRA_VIEW_PORT, i) != NULL) i++; |
1237 |
1236 |
1238 AllocateWindowDescFront<ExtraViewportWindow>(&_extra_view_port_desc, i, &tile); |
1237 new ExtraViewportWindow(&_extra_view_port_desc, i, tile); |
1239 } |
1238 } |
1240 |
1239 |
1241 bool ScrollMainWindowTo(int x, int y, bool instant) |
1240 bool ScrollMainWindowTo(int x, int y, bool instant) |
1242 { |
1241 { |
1243 bool res = ScrollWindowTo(x, y, FindWindowById(WC_MAIN_WINDOW, 0), instant); |
1242 bool res = ScrollWindowTo(x, y, FindWindowById(WC_MAIN_WINDOW, 0), instant); |