void CVarSliderWidget_UpdateCVar(Widget &wi, Widget::Action action) { if(action != Widget::Modified) return; CVarSliderWidget &sldr = wi.as<CVarSliderWidget>(); cvartype_t varType = Con_GetVariableType(sldr.cvarPath()); if(CVT_NULL == varType) return; float value = sldr.value(); switch(varType) { case CVT_FLOAT: if(sldr.step() >= .01f) { Con_SetFloat2(sldr.cvarPath(), (int) (100 * value) / 100.0f, SVF_WRITE_OVERRIDE); } else { Con_SetFloat2(sldr.cvarPath(), value, SVF_WRITE_OVERRIDE); } break; case CVT_INT: Con_SetInteger2(sldr.cvarPath(), (int) value, SVF_WRITE_OVERRIDE); break; case CVT_BYTE: Con_SetInteger2(sldr.cvarPath(), (byte) value, SVF_WRITE_OVERRIDE); break; default: break; } }
void CVarToggleWidget_UpdateCVar(Widget &wi, Widget::Action action) { CVarToggleWidget *tog = &wi.as<CVarToggleWidget>(); if(action != Widget::Modified) return; tog->setText(tog->isDown()? tog->downText() : tog->upText()); if(Con_GetVariableType(tog->cvarPath()) == CVT_NULL) { return; } int value; if(int const valueMask = tog->cvarValueMask()) { value = Con_GetInteger(tog->cvarPath()); if(tog->isDown()) { value |= valueMask; } else { value &= ~valueMask; } } else { value = int(tog->state()); } Con_SetInteger2(tog->cvarPath(), value, SVF_WRITE_OVERRIDE); }