1
0
Fork 0

(svn r17797) -Codechange: Use parameters of new function, introduce constants for hardcoded numbers.

release/1.0
alberth 2009-10-18 13:56:09 +00:00
parent 29028b3f8a
commit 00723e694f
1 changed files with 23 additions and 23 deletions

View File

@ -505,7 +505,7 @@ public:
{ {
Industry *i = Industry::Get(this->window_number); Industry *i = Industry::Get(this->window_number);
const IndustrySpec *ind = GetIndustrySpec(i->type); const IndustrySpec *ind = GetIndustrySpec(i->type);
int y = this->widget[IVW_INFO].top + 1; int y = top + WD_FRAMERECT_TOP;
bool first = true; bool first = true;
bool has_accept = false; bool has_accept = false;
@ -514,15 +514,15 @@ public:
if (i->accepts_cargo[j] == CT_INVALID) continue; if (i->accepts_cargo[j] == CT_INVALID) continue;
has_accept = true; has_accept = true;
if (first) { if (first) {
DrawString(2, this->widget[IVW_INFO].right, y, STR_INDUSTRY_VIEW_WAITING_FOR_PROCESSING); DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_WAITING_FOR_PROCESSING);
y += 10; y += FONT_HEIGHT_NORMAL;
first = false; first = false;
} }
SetDParam(0, i->accepts_cargo[j]); SetDParam(0, i->accepts_cargo[j]);
SetDParam(1, i->incoming_cargo_waiting[j]); SetDParam(1, i->incoming_cargo_waiting[j]);
SetDParam(2, GetCargoSuffix(j, CST_VIEW, i, i->type, ind)); SetDParam(2, GetCargoSuffix(j, CST_VIEW, i, i->type, ind));
DrawString(4, this->widget[IVW_INFO].right, y, STR_INDUSTRY_VIEW_WAITING_STOCKPILE_CARGO); DrawString(left + WD_FRAMETEXT_LEFT, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_WAITING_STOCKPILE_CARGO);
y += 10; y += FONT_HEIGHT_NORMAL;
} }
} else { } else {
StringID str = STR_INDUSTRY_VIEW_REQUIRES_CARGO; StringID str = STR_INDUSTRY_VIEW_REQUIRES_CARGO;
@ -535,8 +535,8 @@ public:
SetDParam(p++, GetCargoSuffix(j, CST_VIEW, i, i->type, ind)); SetDParam(p++, GetCargoSuffix(j, CST_VIEW, i, i->type, ind));
} }
if (has_accept) { if (has_accept) {
DrawString(2, this->widget[IVW_INFO].right, y, str); DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, str);
y += 10; y += FONT_HEIGHT_NORMAL;
} }
} }
@ -545,8 +545,8 @@ public:
if (i->produced_cargo[j] == CT_INVALID) continue; if (i->produced_cargo[j] == CT_INVALID) continue;
if (first) { if (first) {
if (has_accept) y += 10; if (has_accept) y += 10;
DrawString(2, this->widget[IVW_INFO].right, y, STR_INDUSTRY_VIEW_PRODUCTION_LAST_MONTH_TITLE); DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_PRODUCTION_LAST_MONTH_TITLE);
y += 10; y += FONT_HEIGHT_NORMAL;
this->production_offset_y = y; this->production_offset_y = y;
first = false; first = false;
} }
@ -556,14 +556,14 @@ public:
SetDParam(2, GetCargoSuffix(j + 3, CST_VIEW, i, i->type, ind)); SetDParam(2, GetCargoSuffix(j + 3, CST_VIEW, i, i->type, ind));
SetDParam(3, ToPercent8(i->last_month_pct_transported[j])); SetDParam(3, ToPercent8(i->last_month_pct_transported[j]));
uint x = 4 + (IsProductionAlterable(i) ? 30 : 0); uint x = left + WD_FRAMETEXT_LEFT + (IsProductionAlterable(i) ? 30 : 0);
DrawString(x, this->widget[IVW_INFO].right, y, STR_INDUSTRY_VIEW_TRANSPORTED); DrawString(x, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_TRANSPORTED);
/* Let's put out those buttons.. */ /* Let's put out those buttons.. */
if (IsProductionAlterable(i)) { if (IsProductionAlterable(i)) {
DrawArrowButtons(5, y, COLOUR_YELLOW, (this->clicked_line == j + 1) ? this->clicked_button : 0, DrawArrowButtons(left + WD_FRAMETEXT_LEFT, y, COLOUR_YELLOW, (this->clicked_line == j + 1) ? this->clicked_button : 0,
!IsProductionMinimum(i, j), !IsProductionMaximum(i, j)); !IsProductionMinimum(i, j), !IsProductionMaximum(i, j));
} }
y += 10; y += FONT_HEIGHT_NORMAL;
} }
/* Get the extra message for the GUI */ /* Get the extra message for the GUI */
@ -572,14 +572,13 @@ public:
if (callback_res != CALLBACK_FAILED) { if (callback_res != CALLBACK_FAILED) {
StringID message = GetGRFStringID(ind->grf_prop.grffile->grfid, 0xD000 + callback_res); StringID message = GetGRFStringID(ind->grf_prop.grffile->grfid, 0xD000 + callback_res);
if (message != STR_NULL && message != STR_UNDEFINED) { if (message != STR_NULL && message != STR_UNDEFINED) {
const Widget *wi = &this->widget[IVW_INFO];
y += 10; y += 10;
PrepareTextRefStackUsage(6); PrepareTextRefStackUsage(6);
/* Use all the available space left from where we stand up to the /* Use all the available space left from where we stand up to the
* end of the window. We ALSO enlarge the window if needed, so we * end of the window. We ALSO enlarge the window if needed, so we
* can 'go' wild with the bottom of the window. */ * can 'go' wild with the bottom of the window. */
y = DrawStringMultiLine(wi->left + 2, wi->right - 2, y, UINT16_MAX, message); y = DrawStringMultiLine(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, UINT16_MAX, message);
StopTextRefStackUsage(); StopTextRefStackUsage();
} }
} }
@ -610,18 +609,19 @@ public:
switch (widget) { switch (widget) {
case IVW_INFO: { case IVW_INFO: {
int line, x;
i = Industry::Get(this->window_number); i = Industry::Get(this->window_number);
/* We should work if needed.. */ /* We should work if needed.. */
if (!IsProductionAlterable(i)) return; if (!IsProductionAlterable(i)) return;
x = pt.x; uint x = pt.x;
line = (pt.y - this->production_offset_y) / 10; int line = (pt.y - this->production_offset_y) / FONT_HEIGHT_NORMAL;
if (pt.y >= this->production_offset_y && IsInsideMM(line, 0, 2) && i->produced_cargo[line] != CT_INVALID) { if (pt.y >= this->production_offset_y && IsInsideMM(line, 0, 2) && i->produced_cargo[line] != CT_INVALID) {
if (IsInsideMM(x, 5, 25) ) { Widget *wi = &this->widget[widget];
uint left = wi->left + WD_FRAMETEXT_LEFT;
uint right = wi->right - WD_FRAMERECT_RIGHT;
if (IsInsideMM(x, left, left + 20) ) {
/* Clicked buttons, decrease or increase production */ /* Clicked buttons, decrease or increase production */
if (x < 15) { if (x < left + 10) {
if (IsProductionMinimum(i, line)) return; if (IsProductionMinimum(i, line)) return;
i->production_rate[line] = max(i->production_rate[line] / 2, 0); i->production_rate[line] = max(i->production_rate[line] / 2, 0);
} else { } else {
@ -635,8 +635,8 @@ public:
this->SetDirty(); this->SetDirty();
this->flags4 |= WF_TIMEOUT_BEGIN; this->flags4 |= WF_TIMEOUT_BEGIN;
this->clicked_line = line + 1; this->clicked_line = line + 1;
this->clicked_button = (x < 15 ? 1 : 2); this->clicked_button = (x < left + 10 ? 1 : 2);
} else if (IsInsideMM(x, 34, 160)) { } else if (IsInsideMM(x, left + 30, right)) {
/* clicked the text */ /* clicked the text */
this->editbox_line = line; this->editbox_line = line;
SetDParam(0, i->production_rate[line] * 8); SetDParam(0, i->production_rate[line] * 8);