1
0
Fork 0

(svn r24420) [1.2] -Backport from trunk:

- Fix: Make the AI settings window behave more like the other settings window by closing the query window whenever selecting a different row (r24315)
- Fix: Editing NewGRF parameters using the query window showed wrong values, if there was no direct relation between parameter index and parameter register (r24314)
- Fix: Center object previews in 1- and 2-view selectors based on the 4-view selector layout [FS#5057] (r24299)
- Fix: Increase the left and right margins of the text in the yes/no query window (r24293)
release/1.2
rubidium 2012-07-20 19:31:09 +00:00
parent caa1a6fdeb
commit 1971a5a2fe
4 changed files with 25 additions and 12 deletions

View File

@ -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();

View File

@ -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)

View File

@ -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();

View File

@ -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<NWidgetMatrix>(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;
}