summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-08-30 13:54:53 +0000
committerrubidium <rubidium@openttd.org>2009-08-30 13:54:53 +0000
commit0aab13bf448c5626030a63b3106b128c891a3aa1 (patch)
tree0c0329317a8a3f0c37c72f215e9401caa5bf7639
parent5fe9c448626836c704d5b452ab21a7e5b10b283d (diff)
downloadopenttd-0aab13bf448c5626030a63b3106b128c891a3aa1.tar.xz
(svn r17319) -Codechange: replace some magic numbers related to locations/sizes with the appropriate variables in the industry directory
-rw-r--r--src/industry_gui.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index f39aa1955..f829e821a 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -796,6 +796,7 @@ protected:
/* Runtime saved values */
static Listing last_sorting;
static const Industry *last_industry;
+ int industryline_height; ///< Height of a single industry line in the industry directory window.
/* Constants for sorting stations */
static const StringID sorter_names[];
@@ -908,8 +909,11 @@ public:
IndustryDirectoryWindow(const WindowDesc *desc, WindowNumber number) : Window(desc, number)
{
this->vscroll.cap = 16;
- this->resize.height = this->height - 6 * 10; // minimum 10 items
- this->resize.step_height = 10;
+
+ this->industryline_height = 10;
+ this->resize.height = this->height - 6 * this->industryline_height; // minimum 10 items
+
+ this->resize.step_height = this->industryline_height;
this->FindWindowPlacementAndResize(desc);
this->industries.SetListing(this->last_sorting);
@@ -931,7 +935,7 @@ public:
this->DrawSortButtonState(IDW_DROPDOWN_ORDER, this->industries.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
int max = min(this->vscroll.pos + this->vscroll.cap, this->industries.Length());
- int y = 28; // start of the list-widget
+ int y = this->widget[IDW_INDUSTRY_LIST].top + 2; // start of the list-widget
for (int n = this->vscroll.pos; n < max; ++n) {
const Industry *i = this->industries[n];
@@ -958,9 +962,9 @@ public:
/* Drawing the right string */
StringID str = STR_INDUSTRY_DIRECTORY_ITEM_NOPROD;
if (p != 1) str = (p == 5) ? STR_INDUSTRY_DIRECTORY_ITEM : STR_INDUSTRY_DIRECTORY_ITEM_TWO;
- DrawString(4, this->widget[IDW_INDUSTRY_LIST].right, y, str);
+ DrawString(this->widget[IDW_INDUSTRY_LIST].left + 2, this->widget[IDW_INDUSTRY_LIST].right - 2, y, str);
- y += 10;
+ y += this->industryline_height;
}
}
@@ -977,7 +981,7 @@ public:
break;
case IDW_INDUSTRY_LIST: {
- int y = (pt.y - 28) / 10;
+ int y = (pt.y - this->widget[IDW_INDUSTRY_LIST].top - 2) / this->industryline_height;
uint16 p;
if (!IsInsideMM(y, 0, this->vscroll.cap)) return;
@@ -1004,7 +1008,7 @@ public:
virtual void OnResize(Point delta)
{
- this->vscroll.cap += delta.y / 10;
+ this->vscroll.cap += delta.y / this->industryline_height;
}
virtual void OnHundredthTick()