mirror of https://github.com/OpenTTD/OpenTTD
(svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
parent
d9bc99658b
commit
fcee426b80
|
@ -819,12 +819,19 @@ struct PatchesSelectionWindow : Window {
|
|||
int y = SETTINGTREE_TOP_OFFSET;
|
||||
for (i = 0; i != page->num; i++) {
|
||||
const SettingDesc *sd = page->entries[i].setting;
|
||||
DrawPatch(patches_ptr, sd, x, y, this->click - (i * 2));
|
||||
y += SETTING_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
void DrawPatch(GameSettings *patches_ptr, const SettingDesc *sd, int x, int y, int state)
|
||||
{
|
||||
const SettingDescBase *sdb = &sd->desc;
|
||||
const void *var = GetVariableAddress(patches_ptr, &sd->save);
|
||||
bool editable = true;
|
||||
bool disabled = false;
|
||||
|
||||
// We do not allow changes of some items when we are a client in a networkgame
|
||||
/* We do not allow changes of some items when we are a client in a networkgame */
|
||||
if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) editable = false;
|
||||
if ((sdb->flags & SGF_NETWORK_ONLY) && !_networking) editable = false;
|
||||
if ((sdb->flags & SGF_NO_NETWORK) && _networking) editable = false;
|
||||
|
@ -842,7 +849,7 @@ struct PatchesSelectionWindow : Window {
|
|||
value = (int32)ReadValue(var, sd->save.conv);
|
||||
|
||||
/* Draw [<][>] boxes for settings of an integer-type */
|
||||
DrawArrowButtons(x, y, COLOUR_YELLOW, this->click - (i * 2), (editable && value != sdb->min), (editable && value != sdb->max));
|
||||
DrawArrowButtons(x, y, COLOUR_YELLOW, state, (editable && value != sdb->min), (editable && value != sdb->max));
|
||||
|
||||
disabled = (value == 0) && (sdb->flags & SGF_0ISDISABLED);
|
||||
if (disabled) {
|
||||
|
@ -859,8 +866,6 @@ struct PatchesSelectionWindow : Window {
|
|||
}
|
||||
}
|
||||
DrawString(x + 25, y, (sdb->str) + disabled, TC_FROMSTRING);
|
||||
y += SETTING_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnClick(Point pt, int widget)
|
||||
|
|
Loading…
Reference in New Issue