Codechange: Remove direct access to _colour_gradient.

Access is now through GetColourGradient, which ensures parameters are in range.
This commit is contained in:
Peter Nelson
2023-12-24 22:51:55 +00:00
committed by Peter Nelson
parent 56cf89d189
commit 0463d4c198
23 changed files with 98 additions and 65 deletions

View File

@@ -1414,7 +1414,7 @@ uint BaseSettingEntry::Draw(GameSettings *settings_ptr, int left, int right, int
int x = rtl ? right : left;
if (cur_row >= first_row) {
int colour = _colour_gradient[COLOUR_ORANGE][4];
int colour = GetColourGradient(COLOUR_ORANGE, 4);
y += (cur_row - first_row) * SETTING_HEIGHT; // Compute correct y start position
/* Draw vertical for parent nesting levels */
@@ -2909,7 +2909,7 @@ void ShowGameSettings()
*/
void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
{
int colour = _colour_gradient[button_colour][2];
int colour = GetColourGradient(button_colour, 2);
Dimension dim = NWidgetScrollbar::GetHorizontalDimension();
Rect lr = {x, y, x + (int)dim.width - 1, y + (int)dim.height - 1};
@@ -2940,7 +2940,7 @@ void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clic
*/
void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
{
int colour = _colour_gradient[button_colour][2];
int colour = GetColourGradient(button_colour, 2);
Rect r = {x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1};