mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
(svn r24312) -Change: Center the settings buttons in the AI and NewGRF config windows.
This commit is contained in:
parent
ceec32d2cc
commit
4dd9176cc5
@ -361,6 +361,7 @@ struct AISettingsWindow : public Window {
|
|||||||
|
|
||||||
|
|
||||||
int y = r.top;
|
int y = r.top;
|
||||||
|
int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
|
||||||
for (; this->vscroll->IsVisible(i) && it != visible_settings.end(); i++, it++) {
|
for (; this->vscroll->IsVisible(i) && it != visible_settings.end(); i++, it++) {
|
||||||
const ScriptConfigItem &config_item = **it;
|
const ScriptConfigItem &config_item = **it;
|
||||||
int current_value = config->GetSetting((config_item).name);
|
int current_value = config->GetSetting((config_item).name);
|
||||||
@ -385,10 +386,10 @@ struct AISettingsWindow : public Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((config_item.flags & SCRIPTCONFIG_BOOLEAN) != 0) {
|
if ((config_item.flags & SCRIPTCONFIG_BOOLEAN) != 0) {
|
||||||
DrawBoolButton(buttons_left, y + 2, current_value != 0, editable);
|
DrawBoolButton(buttons_left, y + button_y_offset, current_value != 0, editable);
|
||||||
SetDParam(idx++, current_value == 0 ? STR_CONFIG_SETTING_OFF : STR_CONFIG_SETTING_ON);
|
SetDParam(idx++, current_value == 0 ? STR_CONFIG_SETTING_OFF : STR_CONFIG_SETTING_ON);
|
||||||
} else {
|
} else {
|
||||||
DrawArrowButtons(buttons_left, y + 2, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, editable && current_value > config_item.min_value, editable && current_value < config_item.max_value);
|
DrawArrowButtons(buttons_left, y + button_y_offset, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, editable && current_value > config_item.min_value, editable && current_value < config_item.max_value);
|
||||||
if (config_item.labels != NULL && config_item.labels->Contains(current_value)) {
|
if (config_item.labels != NULL && config_item.labels->Contains(current_value)) {
|
||||||
SetDParam(idx++, STR_JUST_RAW_STRING);
|
SetDParam(idx++, STR_JUST_RAW_STRING);
|
||||||
SetDParamStr(idx++, config_item.labels->Find(current_value)->second);
|
SetDParamStr(idx++, config_item.labels->Find(current_value)->second);
|
||||||
|
@ -252,6 +252,7 @@ struct NewGRFParametersWindow : public Window {
|
|||||||
uint text_right = r.right - (rtl ? SETTING_BUTTON_WIDTH + 8 : WD_FRAMERECT_RIGHT);
|
uint text_right = r.right - (rtl ? SETTING_BUTTON_WIDTH + 8 : WD_FRAMERECT_RIGHT);
|
||||||
|
|
||||||
int y = r.top;
|
int y = r.top;
|
||||||
|
int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
|
||||||
for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++) {
|
for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++) {
|
||||||
GRFParameterInfo *par_info = (i < this->grf_config->param_info.Length()) ? this->grf_config->param_info[i] : NULL;
|
GRFParameterInfo *par_info = (i < this->grf_config->param_info.Length()) ? this->grf_config->param_info[i] : NULL;
|
||||||
if (par_info == NULL) par_info = GetDummyParameterInfo(i);
|
if (par_info == NULL) par_info = GetDummyParameterInfo(i);
|
||||||
@ -259,10 +260,10 @@ struct NewGRFParametersWindow : public Window {
|
|||||||
bool selected = (i == this->clicked_row);
|
bool selected = (i == this->clicked_row);
|
||||||
|
|
||||||
if (par_info->type == PTYPE_BOOL) {
|
if (par_info->type == PTYPE_BOOL) {
|
||||||
DrawBoolButton(buttons_left, y + 2, current_value != 0, this->editable);
|
DrawBoolButton(buttons_left, y + button_y_offset, current_value != 0, this->editable);
|
||||||
SetDParam(2, par_info->GetValue(this->grf_config) == 0 ? STR_CONFIG_SETTING_OFF : STR_CONFIG_SETTING_ON);
|
SetDParam(2, par_info->GetValue(this->grf_config) == 0 ? STR_CONFIG_SETTING_OFF : STR_CONFIG_SETTING_ON);
|
||||||
} else if (par_info->type == PTYPE_UINT_ENUM) {
|
} else if (par_info->type == PTYPE_UINT_ENUM) {
|
||||||
DrawArrowButtons(buttons_left, y + 2, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, this->editable && current_value > par_info->min_value, this->editable && current_value < par_info->max_value);
|
DrawArrowButtons(buttons_left, y + button_y_offset, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, this->editable && current_value > par_info->min_value, this->editable && current_value < par_info->max_value);
|
||||||
SetDParam(2, STR_JUST_INT);
|
SetDParam(2, STR_JUST_INT);
|
||||||
SetDParam(3, current_value);
|
SetDParam(3, current_value);
|
||||||
if (par_info->value_names.Contains(current_value)) {
|
if (par_info->value_names.Contains(current_value)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user