(svn r23757) -Codechange: Unify the drawing of toggle buttons for boolean settings.
This commit is contained in:
@@ -1197,11 +1197,10 @@ void SettingEntry::DrawSetting(GameSettings *settings_ptr, const SettingDesc *sd
|
||||
if ((sdb->flags & SGF_NO_NETWORK) && _networking) editable = false;
|
||||
|
||||
if (sdb->cmd == SDT_BOOLX) {
|
||||
static const Colours _bool_ctabs[2][2] = {{COLOUR_CREAM, COLOUR_RED}, {COLOUR_DARK_GREEN, COLOUR_GREEN}};
|
||||
/* Draw checkbox for boolean-value either on/off */
|
||||
bool on = ReadValue(var, sd->save.conv) != 0;
|
||||
|
||||
DrawFrameRect(buttons_left, button_y, buttons_left + 19, button_y + 8, _bool_ctabs[!!on][!!editable], on ? FR_LOWERED : FR_NONE);
|
||||
DrawBoolButton(buttons_left, button_y, on, editable);
|
||||
SetDParam(0, on ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
|
||||
} else {
|
||||
int32 value;
|
||||
@@ -1822,6 +1821,19 @@ void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clic
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a toggle button.
|
||||
* @param x the x position to draw
|
||||
* @param y the y position to draw
|
||||
* @param state true = lowered
|
||||
* @param clickable is the button clickable?
|
||||
*/
|
||||
void DrawBoolButton(int x, int y, bool state, bool clickable)
|
||||
{
|
||||
static const Colours _bool_ctabs[2][2] = {{COLOUR_CREAM, COLOUR_RED}, {COLOUR_DARK_GREEN, COLOUR_GREEN}};
|
||||
DrawFrameRect(x, y + 1, x + 19, y + 9, _bool_ctabs[state][clickable], state ? FR_LOWERED : FR_NONE);
|
||||
}
|
||||
|
||||
struct CustomCurrencyWindow : Window {
|
||||
int query_widget;
|
||||
|
||||
|
Reference in New Issue
Block a user