Clip to boundaries when there are no suggested values for Prop_int. Revert r3986 as this commit fixes the problem in a different way.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3996
This commit is contained in:
parent
cadf69ac32
commit
07f461da7e
3 changed files with 56 additions and 15 deletions
|
@ -129,19 +129,26 @@ public:
|
|||
virtual bool SetValue(std::string const& str)=0;
|
||||
Value const& GetValue() const { return value;}
|
||||
Value const& Get_Default_Value() const { return default_value; }
|
||||
//CheckValue returns true if value is in suggested_values;
|
||||
//CheckValue returns true, if value is in suggested_values;
|
||||
//Type specific properties are encouraged to override this and check for type
|
||||
//specific features.
|
||||
virtual bool CheckValue(Value const& in, bool warn);
|
||||
//Set interval value to in or default if in is invalid. force always sets the value.
|
||||
bool SetVal(Value const& in, bool forced,bool warn=true) {
|
||||
if(forced || CheckValue(in,warn)) {value = in; return true;} else { value = default_value; return false;}}
|
||||
public:
|
||||
virtual ~Property(){ }
|
||||
virtual const std::vector<Value>& GetValues() const;
|
||||
Value::Etype Get_type(){return default_value.type;}
|
||||
Changeable::Value getChange() {return change;}
|
||||
|
||||
protected:
|
||||
//Set interval value to in or default if in is invalid. force always sets the value.
|
||||
//Can be overriden to set a different value if invalid.
|
||||
virtual bool SetVal(Value const& in, bool forced,bool warn=true) {
|
||||
if(forced || CheckValue(in,warn)) {
|
||||
value = in; return true;
|
||||
} else {
|
||||
value = default_value; return false;
|
||||
}
|
||||
}
|
||||
Value value;
|
||||
std::vector<Value> suggested_values;
|
||||
typedef std::vector<Value>::iterator iter;
|
||||
|
@ -168,6 +175,9 @@ public:
|
|||
bool SetValue(std::string const& in);
|
||||
~Prop_int(){ }
|
||||
virtual bool CheckValue(Value const& in, bool warn);
|
||||
// Override SetVal, so it takes min,max in account when there are no suggested values
|
||||
virtual bool SetVal(Value const& in, bool forced,bool warn=true);
|
||||
|
||||
private:
|
||||
Value min,max;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue