mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r20899) -Codechange: Switch order of if-tests in IndustryViewWindow::OnClick().
This commit is contained in:
parent
168b0a733f
commit
286aba3492
@ -802,6 +802,10 @@ public:
|
||||
Industry *i = Industry::Get(this->window_number);
|
||||
InfoLine line = IL_NONE;
|
||||
|
||||
switch (this->editable) {
|
||||
case EA_NONE: break;
|
||||
|
||||
case EA_RATE:
|
||||
if (pt.y >= this->production_offset_y) {
|
||||
int row = (pt.y - this->production_offset_y) / FONT_HEIGHT_NORMAL;
|
||||
for (uint j = 0; j < lengthof(i->produced_cargo); j++) {
|
||||
@ -813,16 +817,19 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (line == IL_NONE) return;
|
||||
|
||||
uint x = pt.x;
|
||||
if (this->editable == EA_RATE) {
|
||||
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(widget);
|
||||
uint left = nwi->pos_x + WD_FRAMETEXT_LEFT;
|
||||
uint right = nwi->pos_x + nwi->current_x - 1 - WD_FRAMERECT_RIGHT;
|
||||
if (IsInsideMM(x, left, left + 20) ) {
|
||||
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 + 20) ) {
|
||||
/* Clicked buttons, decrease or increase production */
|
||||
if (x < left + 10) {
|
||||
byte button = (pt.x < left + 10) ? 1 : 2;
|
||||
switch (this->editable) {
|
||||
case EA_RATE:
|
||||
if (button == 1) {
|
||||
if (i->production_rate[line - IL_RATE1] <= 0) return;
|
||||
i->production_rate[line - IL_RATE1] = max(i->production_rate[line - IL_RATE1] / 2, 0);
|
||||
} else {
|
||||
@ -831,17 +838,26 @@ public:
|
||||
int new_prod = i->production_rate[line - IL_RATE1] == 0 ? 1 : i->production_rate[line - IL_RATE1] * 2;
|
||||
i->production_rate[line - IL_RATE1] = minu(new_prod, 255);
|
||||
}
|
||||
break;
|
||||
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
UpdateIndustryProduction(i);
|
||||
this->SetDirty();
|
||||
this->flags4 |= WF_TIMEOUT_BEGIN;
|
||||
this->clicked_line = line;
|
||||
this->clicked_button = (x < left + 10 ? 1 : 2);
|
||||
} else if (IsInsideMM(x, left + 30, right)) {
|
||||
this->clicked_button = button;
|
||||
} else if (IsInsideMM(pt.x, left + 30, right)) {
|
||||
/* clicked the text */
|
||||
this->editbox_line = line;
|
||||
switch (this->editable) {
|
||||
case EA_RATE:
|
||||
SetDParam(0, i->production_rate[line - IL_RATE1] * 8);
|
||||
ShowQueryString(STR_JUST_INT, STR_CONFIG_GAME_PRODUCTION, 10, 100, this, CS_ALPHANUMERAL, QSF_NONE);
|
||||
break;
|
||||
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user