| e8555c89 Andy McCall |
1 |
#include "IntegerSetting.hh" |
| 2 |
|
| 3 |
namespace openmsx { |
| 4 |
|
| 5 |
IntegerSetting::IntegerSetting(CommandController& commandController_, |
| 6 |
std::string_view name_, static_string_view description_, |
| 7 |
int initialValue, int minValue_, int maxValue_, |
| 8 |
Save save_) |
| 9 |
: Setting(commandController_, name_, description_, |
| 10 |
TclObject(initialValue), save_) |
| 11 |
, minValue(minValue_) |
| 12 |
, maxValue(maxValue_) |
| 13 |
{ |
| 14 |
auto& interp = getInterpreter(); |
| 15 |
setChecker([this, &interp](TclObject& newValue) { |
| 16 |
int val = newValue.getInt(interp); |
| 17 |
newValue = std::clamp(val, minValue, maxValue); |
| 18 |
}); |
| 19 |
init(); |
| 20 |
} |
| 21 |
|
| 22 |
std::string_view IntegerSetting::getTypeString() const |
| 23 |
{ |
| 24 |
return "integer"; |
| 25 |
} |
| 26 |
|
| 27 |
void IntegerSetting::additionalInfo(TclObject& result) const |
| 28 |
{ |
| 29 |
result.addListElement(makeTclList(minValue, maxValue)); |
| 30 |
} |
| 31 |
|
| 32 |
void IntegerSetting::setInt(int i) |
| 33 |
{ |
| 34 |
setValue(TclObject(i)); |
| 35 |
} |
| 36 |
|
| 37 |
} |