| 1478 | } |
| 1479 | |
| 1480 | void Draw() |
| 1481 | { |
| 1482 | if (type == OT_HEADING) { |
| 1483 | if (label != NULL) { |
| 1484 | ImGui::SeparatorText( label ); |
| 1485 | } |
| 1486 | } else if (cvar != nullptr) { |
| 1487 | switch(type) { |
| 1488 | case OT_BOOL: |
| 1489 | { |
| 1490 | bool b = cvar->GetBool(); |
| 1491 | bool bOrig = b; |
| 1492 | ImGui::Checkbox( label, &b ); |
| 1493 | AddCVarOptionTooltips( *cvar ); |
| 1494 | if (b != bOrig) { |
| 1495 | cvar->SetBool(b); |
| 1496 | } |
| 1497 | break; |
| 1498 | } |
| 1499 | case OT_FLOAT: |
| 1500 | { |
| 1501 | float f = cvar->GetFloat(); |
| 1502 | float fOrig = f; |
| 1503 | // TODO: make format configurable? |
| 1504 | ImGui::SliderFloat(label, &f, minVal, maxVal, "%.2f", 0); |
| 1505 | AddCVarOptionTooltips( *cvar ); |
| 1506 | if(f != fOrig) { |
| 1507 | cvar->SetFloat(f); |
| 1508 | } |
| 1509 | break; |
| 1510 | } |
| 1511 | case OT_INT: |
| 1512 | { |
| 1513 | int i = cvar->GetInteger(); |
| 1514 | int iOrig = i; |
| 1515 | ImGui::SliderInt(label, &i, minVal, maxVal); |
| 1516 | AddCVarOptionTooltips( *cvar ); |
| 1517 | if (i != iOrig) { |
| 1518 | cvar->SetInteger(i); |
| 1519 | } |
| 1520 | break; |
| 1521 | } |
| 1522 | case OT_CUSTOM: |
| 1523 | if (drawCallback != nullptr) { |
| 1524 | drawCallback(*cvar); |
| 1525 | } |
| 1526 | break; |
| 1527 | } |
| 1528 | } |
| 1529 | } |
| 1530 | }; |
| 1531 | |
| 1532 | static void InitOptions(CVarOption options[], int numOptions) |
no test coverage detected