|
@@ -22,6 +22,7 @@
|
|
|
#include "buttonEventList.h"
|
|
#include "buttonEventList.h"
|
|
|
#include "dataNodeTransmit.h"
|
|
#include "dataNodeTransmit.h"
|
|
|
#include "throw_event.h"
|
|
#include "throw_event.h"
|
|
|
|
|
+#include "event.h"
|
|
|
#include "indent.h"
|
|
#include "indent.h"
|
|
|
#include "dcast.h"
|
|
#include "dcast.h"
|
|
|
|
|
|
|
@@ -89,6 +90,44 @@ get_prefix() const {
|
|
|
return _prefix;
|
|
return _prefix;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+// Function: ButtonThrower::add_parameter
|
|
|
|
|
+// Access: Public
|
|
|
|
|
+// Description: Adds the indicated parameter to the list of
|
|
|
|
|
+// parameters that will be passed with each event
|
|
|
|
|
+// generated by this ButtonThrower.
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+void ButtonThrower::
|
|
|
|
|
+add_parameter(const EventParameter &obj) {
|
|
|
|
|
+ _parameters.push_back(obj);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+// Function: ButtonThrower::get_num_parameters
|
|
|
|
|
+// Access: Public
|
|
|
|
|
+// Description: Returns the number of parameters that have been added
|
|
|
|
|
+// to the list of parameters to be passed with each
|
|
|
|
|
+// event generated by this ButtonThrower.
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+int ButtonThrower::
|
|
|
|
|
+get_num_parameters() const {
|
|
|
|
|
+ return _parameters.size();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+// Function: ButtonThrower::get_parameter
|
|
|
|
|
+// Access: Public
|
|
|
|
|
+// Description: Returns the nth parameter that has been added to the
|
|
|
|
|
+// list of parameters passed with each event generated
|
|
|
|
|
+// by this ButtonThrower.
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+EventParameter ButtonThrower::
|
|
|
|
|
+get_parameter(int n) const {
|
|
|
|
|
+ nassertr(n >= 0 && n < (int)_parameters.size(), EventParameter(0));
|
|
|
|
|
+ return _parameters[n];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
// Function: ButtonThrower::get_modifier_buttons
|
|
// Function: ButtonThrower::get_modifier_buttons
|
|
|
// Access: Published
|
|
// Access: Published
|
|
@@ -324,6 +363,24 @@ write(ostream &out, int indent_level) const {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+// Function: ButtonThrower::do_throw_event
|
|
|
|
|
+// Access: Private
|
|
|
|
|
+// Description: Generates an event of the indicated name, adding on
|
|
|
|
|
+// all of the user-requested parameters.
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+void ButtonThrower::
|
|
|
|
|
+do_throw_event(const string &event_name) {
|
|
|
|
|
+ Event *event = new Event(_prefix + event_name);
|
|
|
|
|
+
|
|
|
|
|
+ ParameterList::const_iterator pi;
|
|
|
|
|
+ for (pi = _parameters.begin(); pi != _parameters.end(); ++pi) {
|
|
|
|
|
+ event->add_parameter(*pi);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ throw_event(event);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
// Function: ButtonThrower::do_transmit_data
|
|
// Function: ButtonThrower::do_transmit_data
|
|
|
// Access: Protected, Virtual
|
|
// Access: Protected, Virtual
|
|
@@ -362,7 +419,7 @@ do_transmit_data(const DataNodeTransmit &input, DataNodeTransmit &output) {
|
|
|
|
|
|
|
|
if (!_throw_buttons_active || has_throw_button(_mods, be._button)) {
|
|
if (!_throw_buttons_active || has_throw_button(_mods, be._button)) {
|
|
|
// Process this button.
|
|
// Process this button.
|
|
|
- throw_event(_prefix + event_name);
|
|
|
|
|
|
|
+ do_throw_event(event_name);
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
// Don't process this button; instead, pass it down to future
|
|
// Don't process this button; instead, pass it down to future
|
|
@@ -385,7 +442,7 @@ do_transmit_data(const DataNodeTransmit &input, DataNodeTransmit &output) {
|
|
|
// definition for the button at all, regardless of the state
|
|
// definition for the button at all, regardless of the state
|
|
|
// of the modifier keys.
|
|
// of the modifier keys.
|
|
|
if (!_throw_buttons_active || has_throw_button(be._button)) {
|
|
if (!_throw_buttons_active || has_throw_button(be._button)) {
|
|
|
- throw_event(_prefix + event_name + "-up");
|
|
|
|
|
|
|
+ do_throw_event(event_name + "-up");
|
|
|
}
|
|
}
|
|
|
if (_throw_buttons_active) {
|
|
if (_throw_buttons_active) {
|
|
|
// Now pass the event on to future generations. We always
|
|
// Now pass the event on to future generations. We always
|