summaryrefslogtreecommitdiff
path: root/src/industry_gui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/industry_gui.cpp')
-rw-r--r--src/industry_gui.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 9db4a5a94..58550b1e2 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -38,6 +38,7 @@
#include "smallmap_gui.h"
#include "widgets/dropdown_type.h"
#include "widgets/industry_widget.h"
+#include "cargodest_gui.h"
#include "table/strings.h"
@@ -653,8 +654,11 @@ class IndustryViewWindow : public Window
int production_offset_y; ///< The offset of the production texts/buttons
int info_height; ///< Height needed for the #WID_IV_INFO panel
+ CargoDestinationList dest_list; ///< Sorted list of demand destinations.
+ int dest_list_top; ///< Top coordinate of the destination list.
+
public:
- IndustryViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
+ IndustryViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(), dest_list(Industry::Get(window_number))
{
this->flags |= WF_DISABLE_VP_SCROLL;
this->editbox_line = IL_NONE;
@@ -792,6 +796,10 @@ public:
}
}
}
+
+ this->dest_list_top = y;
+ y = this->dest_list.DrawList(left, right, y);
+
return y + WD_FRAMERECT_BOTTOM;
}
@@ -811,6 +819,13 @@ public:
case WID_IV_INFO: {
Industry *i = Industry::Get(this->window_number);
InfoLine line = IL_NONE;
+ NWidgetBase *nwi = this->GetWidget<NWidgetBase>(widget);
+
+ /* Test for click on destination list. */
+ if (pt.y > this->dest_list_top) {
+ this->dest_list.OnClick(pt.y - this->dest_list_top);
+ return;
+ }
switch (this->editable) {
case EA_NONE: break;
@@ -835,7 +850,6 @@ public:
}
if (line == IL_NONE) return;
- NWidgetBase *nwi = this->GetWidget<NWidgetBase>(widget);
int left = nwi->pos_x + WD_FRAMETEXT_LEFT;
int right = nwi->pos_x + nwi->current_x - 1 - WD_FRAMERECT_RIGHT;
if (IsInsideMM(pt.x, left, left + SETTING_BUTTON_WIDTH)) {
@@ -963,6 +977,13 @@ public:
} else {
this->editable = EA_NONE;
}
+
+ /* Rebuild destination list if data is not zero, otherwise just resort. */
+ if (data != 0) {
+ this->dest_list.InvalidateData();
+ } else {
+ this->dest_list.Resort();
+ }
}
virtual bool IsNewGRFInspectable() const