Change multi_remain to repeat last parsed value for non-string types if the next value is empty and of the same type as the last.
Use this to add an optional parameter to sensitivity which controls the y axis. When optional parameter is missing, x and y axis have the same value. Change limits on sensitivity to allow for negative values so the Mouse Y-axis can be inversed. Similar to patch #276. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4197
This commit is contained in:
parent
202bfa1155
commit
94113a7362
2 changed files with 46 additions and 16 deletions
|
@ -429,6 +429,9 @@ bool Prop_multival::SetValue(std::string const& input) {
|
|||
Property *p = section->Get_prop(0);
|
||||
//No properties in this section. do nothing
|
||||
if (!p) return false;
|
||||
Value::Etype prevtype = Value::V_NONE;
|
||||
string prevargument = "";
|
||||
|
||||
string::size_type loc = string::npos;
|
||||
while( (p = section->Get_prop(i++)) ) {
|
||||
//trim leading separators
|
||||
|
@ -443,13 +446,32 @@ bool Prop_multival::SetValue(std::string const& input) {
|
|||
in = local;
|
||||
local = "";
|
||||
}
|
||||
//Test Value. If it fails set default
|
||||
Value valtest (in,p->Get_type());
|
||||
if (!p->CheckValue(valtest,true)) {
|
||||
make_default_value();
|
||||
return false;
|
||||
|
||||
if (p->Get_type() == Value::V_STRING) {
|
||||
//Strings are only checked against the suggested values list.
|
||||
//Test Value. If it fails set default
|
||||
Value valtest (in,p->Get_type());
|
||||
if (!p->CheckValue(valtest,true)) {
|
||||
make_default_value();
|
||||
return false;
|
||||
}
|
||||
p->SetValue(in);
|
||||
} else {
|
||||
//Non-strings can have more things, conversion alone is not enough (as invalid values as converted to 0)
|
||||
bool r = p->SetValue(in);
|
||||
if (!r) {
|
||||
if (in.empty() && p->Get_type() == prevtype ) {
|
||||
//Nothing there, but same type of variable, so repeat it (sensitivity)
|
||||
in = prevargument;
|
||||
p->SetValue(in);
|
||||
} else {
|
||||
//Something was there to be parsed or not the same type. Invalidate entire property.
|
||||
make_default_value();
|
||||
}
|
||||
}
|
||||
}
|
||||
p->SetValue(in);
|
||||
prevtype = p->Get_type();
|
||||
prevargument = in;
|
||||
|
||||
}
|
||||
return retval;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue