mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-19 18:32:35 +01:00
Codechange: Move settings entry size global variables. (#14644)
_setting_circle_size and (the incorrectly named) SETTING_HEIGHT variables are now static members of BaseSettingEntry. Neither of these are constants, so they no longer use constant naming style.
This commit is contained in:
@@ -84,8 +84,6 @@ static const uint32_t _autosave_dropdown_to_minutes[] = {
|
||||
120,
|
||||
};
|
||||
|
||||
Dimension _setting_circle_size; ///< Dimension of the circle +/- icon. This is here as not all users are within the class of the settings window.
|
||||
|
||||
/**
|
||||
* Get index of the current screen resolution.
|
||||
* @return Index of the current screen resolution if it is a known resolution, _resolutions.size() otherwise.
|
||||
@@ -363,8 +361,6 @@ std::unique_ptr<NWidgetBase> MakeNWidgetSocialPlugins()
|
||||
return std::make_unique<NWidgetSocialPlugins>();
|
||||
}
|
||||
|
||||
int SETTING_HEIGHT = 11; ///< Height of a single setting in the tree view in pixels
|
||||
|
||||
static const StringID _game_settings_restrict_dropdown[] = {
|
||||
STR_CONFIG_SETTING_RESTRICT_BASIC, // RM_BASIC
|
||||
STR_CONFIG_SETTING_RESTRICT_ADVANCED, // RM_ADVANCED
|
||||
@@ -453,7 +449,9 @@ struct GameOptionsWindow : Window {
|
||||
|
||||
void OnInit() override
|
||||
{
|
||||
_setting_circle_size = maxdim(GetSpriteSize(SPR_CIRCLE_FOLDED), GetSpriteSize(SPR_CIRCLE_UNFOLDED));
|
||||
BaseSettingEntry::circle_size = maxdim(GetSpriteSize(SPR_CIRCLE_FOLDED), GetSpriteSize(SPR_CIRCLE_UNFOLDED));
|
||||
BaseSettingEntry::line_height = std::max({static_cast<int>(BaseSettingEntry::circle_size.height), SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)}) + WidgetDimensions::scaled.vsep_normal;
|
||||
|
||||
this->gui_scale = _gui_scale;
|
||||
}
|
||||
|
||||
@@ -709,7 +707,7 @@ struct GameOptionsWindow : Window {
|
||||
|
||||
case WID_GO_OPTIONSPANEL: {
|
||||
Rect tr = r.Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect);
|
||||
tr.top += this->warn_lines * SETTING_HEIGHT;
|
||||
tr.top += this->warn_lines * BaseSettingEntry::line_height;
|
||||
uint last_row = this->vscroll->GetPosition() + this->vscroll->GetCapacity() - this->warn_lines;
|
||||
int next_row = GetSettingsTree().Draw(settings_ptr, tr.left, tr.right, tr.top,
|
||||
this->vscroll->GetPosition(), last_row, this->last_clicked);
|
||||
@@ -858,7 +856,7 @@ struct GameOptionsWindow : Window {
|
||||
}
|
||||
|
||||
case WID_GO_OPTIONSPANEL:
|
||||
fill.height = resize.height = SETTING_HEIGHT = std::max({(int)_setting_circle_size.height, SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)}) + WidgetDimensions::scaled.vsep_normal;
|
||||
fill.height = resize.height = BaseSettingEntry::line_height;
|
||||
resize.width = 1;
|
||||
|
||||
size.height = 8 * resize.height + WidgetDimensions::scaled.framerect.Vertical();
|
||||
@@ -1271,7 +1269,7 @@ struct GameOptionsWindow : Window {
|
||||
Rect wi_rect;
|
||||
wi_rect.left = pt.x - (_current_text_dir == TD_RTL ? SETTING_BUTTON_WIDTH - 1 - x : x);
|
||||
wi_rect.right = wi_rect.left + SETTING_BUTTON_WIDTH - 1;
|
||||
wi_rect.top = pt.y - rel_y + (SETTING_HEIGHT - SETTING_BUTTON_HEIGHT) / 2;
|
||||
wi_rect.top = pt.y - rel_y + (BaseSettingEntry::line_height - SETTING_BUTTON_HEIGHT) / 2;
|
||||
wi_rect.bottom = wi_rect.top + SETTING_BUTTON_HEIGHT - 1;
|
||||
|
||||
/* For dropdowns we also have to check the y position thoroughly, the mouse may not above the just opening dropdown */
|
||||
|
||||
Reference in New Issue
Block a user