diff --git a/simgear/props/AtomicChangeListener.cxx b/simgear/props/AtomicChangeListener.cxx index 4409e135..7d7f31f3 100644 --- a/simgear/props/AtomicChangeListener.cxx +++ b/simgear/props/AtomicChangeListener.cxx @@ -59,6 +59,12 @@ void AtomicChangeListener::fireChangeListeners() listeners.clear(); } +void AtomicChangeListener::clearPendingChanges() +{ + auto& listeners = ListenerListSingleton::instance()->listeners; + listeners.clear(); +} + void AtomicChangeListener::valueChangedImplementation() { if (!_dirty) { diff --git a/simgear/props/AtomicChangeListener.hxx b/simgear/props/AtomicChangeListener.hxx index 1c2a9750..191ee5ac 100644 --- a/simgear/props/AtomicChangeListener.hxx +++ b/simgear/props/AtomicChangeListener.hxx @@ -52,7 +52,17 @@ public: bool isDirty() { return _dirty; } bool isValid() { return _valid; } virtual void unregister_property(SGPropertyNode* node) override; + static void fireChangeListeners(); + + /** + * @brief Ensure we've deleted any pending changes. + * + * This is important in shutdown and reset, to avoid holding + * property listeners around after the property tree is destroyed + */ + static void clearPendingChanges(); + private: virtual void valueChangedImplementation() override; virtual void valuesChanged(); diff --git a/simgear/structure/SGAction.cxx b/simgear/structure/SGAction.cxx new file mode 100644 index 00000000..cd828a4a --- /dev/null +++ b/simgear/structure/SGAction.cxx @@ -0,0 +1,86 @@ + + +#if 0 + +set bindings for action seperate from defintion ? + - in XML, especially aircraft XML + +define actions from command / Nasal +add behaviours from Nasal + +define keymapping + - manager of keybindings defined against actions? + - for a toggle or enum, define behaviour + - each key repeat cycles + - alternate key to go the other way (G/shift-G) + +release bindings for momentary actions: + button up / key-up + +send activate, release + + send deactivate, release for 'alternate' action + +#endif + + +void SGAction::setValueExpression() +{ + // watch all the properties +} + +void SGAction::setValueCondition() +{ + // +} + +void SGAction::updateProperties() +{ + // + _node->setBoolValue("enabled", isEnabled()); + switch (_type) { + case Momentary: + case Toggle: + _node->setBoolValue("value", getValue()); + break; + + case Enumerated: + if (!_valueEnumeration.empty()) { + // map to the string value + _node->setStringValue("value", _valueEnumeration.at(getValue())); + } else { + // set as an integer + _node->setIntValue("value", getValue()); + } + } + + // set description +} + +bool SGAction::isEnabled() +{ + if (_enableCondition) { + + } else { + return _enabled; + } + + updateProperties(); +} + +int SGAction::getValue() +{ + if (type == Enumerated) { + if (_valueExpression) { + // invoke it + } + } else { + if (_valueCondition) { + return _valueCondition.test(); + } + } + + return _value; +} + +// commands enable-action, disable-action