diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index b7d3850308..59fa02e03f 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -431,15 +431,21 @@ struct AISettingsWindow : public Window { const ScriptConfigItem config_item = **it; if (_game_mode == GM_NORMAL && ((this->slot == OWNER_DEITY) || Company::IsValidID(this->slot)) && (config_item.flags & SCRIPTCONFIG_INGAME) == 0) return; + if (this->clicked_row != num) { + DeleteChildWindows(WC_QUERY_STRING); + this->clicked_row = num; + } + bool bool_item = (config_item.flags & SCRIPTCONFIG_BOOLEAN) != 0; int x = pt.x - wid->pos_x; if (_current_text_dir == TD_RTL) x = wid->current_x - x; x -= 4; + /* One of the arrows is clicked (or green/red rect in case of bool value) */ + int old_val = this->ai_config->GetSetting(config_item.name); if (IsInsideMM(x, 0, 21)) { - int new_val = this->ai_config->GetSetting(config_item.name); - int old_val = new_val; + int new_val = old_val; if (bool_item) { new_val = !new_val; } else if (x >= 10) { @@ -463,8 +469,7 @@ struct AISettingsWindow : public Window { } } else if (!bool_item) { /* Display a query box so users can enter a custom value. */ - this->clicked_row = num; - SetDParam(0, this->ai_config->GetSetting(config_item.name)); + SetDParam(0, old_val); ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 10, this, CS_NUMERAL, QSF_NONE); } this->SetDirty(); diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 8755f8cd9d..c012e1f605 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -1298,8 +1298,8 @@ struct QueryWindow : public Window { if (widget != WID_Q_TEXT) return; Dimension d = GetStringMultiLineBoundingBox(this->message, *size); - d.width += padding.width; - d.height += padding.height; + d.width += WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT; + d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; *size = d; } @@ -1307,7 +1307,8 @@ struct QueryWindow : public Window { { if (widget != WID_Q_TEXT) return; - DrawStringMultiLine(r.left, r.right, r.top, r.bottom, this->message, TC_FROMSTRING, SA_CENTER); + DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, r.top + WD_FRAMERECT_TOP, r.bottom - WD_FRAMERECT_BOTTOM, + this->message, TC_FROMSTRING, SA_CENTER); } virtual void OnClick(Point pt, int widget, int click_count) diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 1b713a24a4..c7c0e371d8 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -326,9 +326,9 @@ struct NewGRFParametersWindow : public Window { if (par_info == NULL) par_info = GetDummyParameterInfo(num); /* One of the arrows is clicked */ + uint32 old_val = par_info->GetValue(this->grf_config); if (IsInsideMM(x, 0, 21)) { - uint32 val = par_info->GetValue(this->grf_config); - uint32 old_val = val; + uint32 val = old_val; if (par_info->type == PTYPE_BOOL) { val = !val; } else { @@ -350,7 +350,7 @@ struct NewGRFParametersWindow : public Window { } } else if (par_info->type == PTYPE_UINT_ENUM && click_count >= 2) { /* Display a query box so users can enter a custom value. */ - SetDParam(0, this->grf_config->param[num]); + SetDParam(0, old_val); ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 10, this, CS_NUMERAL, QSF_NONE); } this->SetDirty(); diff --git a/src/object_gui.cpp b/src/object_gui.cpp index 390adc8d0a..8ac9c7bf6c 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -174,6 +174,13 @@ public: const ObjectSpec *spec = ObjectClass::Get(_selected_object_class, _selected_object_index); if (spec == NULL) break; + /* Height of the selection matrix. + * Depending on the number of views, the matrix has a 1x1, 1x2, 2x1 or 2x2 layout. To make the previews + * look nice in all layouts, we use the 4x4 layout (smallest previews) as starting point. For the bigger + * previews in the layouts with less views we add space homogenously on all sides, so the 4x4 preview-rectangle + * is centered in the 2x1, 1x2 resp. 1x1 buttons. */ + uint matrix_height = this->GetWidget(WID_BO_OBJECT_MATRIX)->current_y; + DrawPixelInfo tmp_dpi; /* Set up a clipping area for the preview. */ if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) { @@ -182,9 +189,9 @@ public: if (spec->grf_prop.grffile == NULL) { extern const DrawTileSprites _objects[]; const DrawTileSprites *dts = &_objects[spec->grf_prop.local_id]; - DrawOrigTileSeqInGUI((r.right - r.left) / 2 - 1, r.bottom - r.top - OBJECT_MARGIN - TILE_PIXELS, dts, PAL_NONE); + DrawOrigTileSeqInGUI((r.right - r.left) / 2 - 1, (r.bottom - r.top + matrix_height / 2) / 2 - OBJECT_MARGIN - TILE_PIXELS, dts, PAL_NONE); } else { - DrawNewObjectTileInGUI((r.right - r.left) / 2 - 1, r.bottom - r.top - OBJECT_MARGIN - TILE_PIXELS, spec, GB(widget, 16, 16)); + DrawNewObjectTileInGUI((r.right - r.left) / 2 - 1, (r.bottom - r.top + matrix_height / 2) / 2 - OBJECT_MARGIN - TILE_PIXELS, spec, GB(widget, 16, 16)); } _cur_dpi = old_dpi; }