Modify the property-assign command to optionally copy a value from
another property (suggested by Jim Wilson).
This commit is contained in:
parent
7cc894be4b
commit
ea6448c956
1 changed files with 9 additions and 25 deletions
|
@ -382,38 +382,22 @@ do_property_toggle (const SGPropertyNode * arg)
|
||||||
* Built-in command: assign a value to a property.
|
* Built-in command: assign a value to a property.
|
||||||
*
|
*
|
||||||
* property: the name of the property to assign.
|
* property: the name of the property to assign.
|
||||||
* value: the value to assign.
|
* value: the value to assign; or
|
||||||
|
* property[1]: the property to copy from.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
do_property_assign (const SGPropertyNode * arg)
|
do_property_assign (const SGPropertyNode * arg)
|
||||||
{
|
{
|
||||||
SGPropertyNode * prop = get_prop(arg);
|
SGPropertyNode * prop = get_prop(arg);
|
||||||
|
const SGPropertyNode * prop2 = get_prop2(arg);
|
||||||
const SGPropertyNode * value = arg->getNode("value");
|
const SGPropertyNode * value = arg->getNode("value");
|
||||||
|
|
||||||
switch (prop->getType()) {
|
if (value != 0)
|
||||||
|
return prop->setUnspecifiedValue(value->getStringValue());
|
||||||
case SGPropertyNode::BOOL:
|
else if (prop2)
|
||||||
return prop->setBoolValue(value->getBoolValue());
|
return prop->setUnspecifiedValue(prop2->getStringValue());
|
||||||
|
else
|
||||||
case SGPropertyNode::INT:
|
return false;
|
||||||
return prop->setIntValue(value->getIntValue());
|
|
||||||
|
|
||||||
case SGPropertyNode::LONG:
|
|
||||||
return prop->setLongValue(value->getLongValue());
|
|
||||||
|
|
||||||
case SGPropertyNode::FLOAT:
|
|
||||||
return prop->setFloatValue(value->getFloatValue());
|
|
||||||
|
|
||||||
case SGPropertyNode::DOUBLE:
|
|
||||||
return prop->setDoubleValue(value->getDoubleValue());
|
|
||||||
|
|
||||||
case SGPropertyNode::STRING:
|
|
||||||
return prop->setStringValue(value->getStringValue());
|
|
||||||
|
|
||||||
default:
|
|
||||||
return prop->setUnspecifiedValue(value->getStringValue());
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue