Importing event input changes
diff --git a/include/rive/animation/event_input_change.hpp b/include/rive/animation/event_input_change.hpp
index 93e3796..ee3e724 100644
--- a/include/rive/animation/event_input_change.hpp
+++ b/include/rive/animation/event_input_change.hpp
@@ -1,10 +1,11 @@
#ifndef _RIVE_EVENT_INPUT_CHANGE_HPP_
#define _RIVE_EVENT_INPUT_CHANGE_HPP_
#include "rive/generated/animation/event_input_change_base.hpp"
-#include <stdio.h>
+
namespace rive {
class EventInputChange : public EventInputChangeBase {
public:
+ StatusCode import(ImportStack& importStack) override;
};
} // namespace rive
diff --git a/include/rive/animation/state_machine_event.hpp b/include/rive/animation/state_machine_event.hpp
index 55a2644..c59bc16 100644
--- a/include/rive/animation/state_machine_event.hpp
+++ b/include/rive/animation/state_machine_event.hpp
@@ -1,9 +1,17 @@
#ifndef _RIVE_STATE_MACHINE_EVENT_HPP_
#define _RIVE_STATE_MACHINE_EVENT_HPP_
#include "rive/generated/animation/state_machine_event_base.hpp"
-#include <stdio.h>
+
namespace rive {
+ class StateMachineEventImporter;
+ class EventInputChange;
class StateMachineEvent : public StateMachineEventBase {
+ friend class StateMachineEventImporter;
+
+ private:
+ std::vector<EventInputChange*> m_InputChanges;
+ void addInputChange(EventInputChange* inputChange);
+
public:
StatusCode import(ImportStack& importStack) override;
};
diff --git a/include/rive/importers/state_machine_event_importer.hpp b/include/rive/importers/state_machine_event_importer.hpp
new file mode 100644
index 0000000..64ac249
--- /dev/null
+++ b/include/rive/importers/state_machine_event_importer.hpp
@@ -0,0 +1,21 @@
+#ifndef _RIVE_STATE_MACHINE_EVENT_IMPORTER_HPP_
+#define _RIVE_STATE_MACHINE_EVENT_IMPORTER_HPP_
+
+#include "rive/importers/import_stack.hpp"
+
+namespace rive {
+ class StateMachineEvent;
+ class StateMachine;
+ class EventInputChange;
+ class StateMachineEventImporter : public ImportStackObject {
+ private:
+ StateMachineEvent* m_StateMachineEvent;
+
+ public:
+ StateMachineEventImporter(StateMachineEvent* event);
+ const StateMachineEvent* stateMachineEvent() const { return m_StateMachineEvent; }
+ void addInputChange(EventInputChange* change);
+ StatusCode resolve() override;
+ };
+} // namespace rive
+#endif
diff --git a/src/animation/event_input_change.cpp b/src/animation/event_input_change.cpp
new file mode 100644
index 0000000..d319855
--- /dev/null
+++ b/src/animation/event_input_change.cpp
@@ -0,0 +1,17 @@
+#include "rive/animation/state_machine_event.hpp"
+#include "rive/importers/import_stack.hpp"
+#include "rive/importers/state_machine_event_importer.hpp"
+#include "rive/animation/event_input_change.hpp"
+#include "rive/generated/animation/state_machine_base.hpp"
+
+using namespace rive;
+
+StatusCode EventInputChange::import(ImportStack& importStack) {
+ auto stateMachineEventImporter =
+ importStack.latest<StateMachineEventImporter>(StateMachineEventBase::typeKey);
+ if (stateMachineEventImporter == nullptr) {
+ return StatusCode::MissingObject;
+ }
+ stateMachineEventImporter->addInputChange(this);
+ return Super::import(importStack);
+}
diff --git a/src/animation/state_machine_event.cpp b/src/animation/state_machine_event.cpp
index d14c0ab..5eadc0f 100644
--- a/src/animation/state_machine_event.cpp
+++ b/src/animation/state_machine_event.cpp
@@ -5,6 +5,10 @@
using namespace rive;
+void StateMachineEvent::addInputChange(EventInputChange* inputChange) {
+ m_InputChanges.push_back(inputChange);
+}
+
StatusCode StateMachineEvent::import(ImportStack& importStack) {
auto stateMachineImporter = importStack.latest<StateMachineImporter>(StateMachineBase::typeKey);
if (stateMachineImporter == nullptr) {
diff --git a/src/file.cpp b/src/file.cpp
index a08c5d9..6a17dbb 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -14,6 +14,7 @@
#include "rive/importers/keyed_property_importer.hpp"
#include "rive/importers/linear_animation_importer.hpp"
#include "rive/importers/state_machine_importer.hpp"
+#include "rive/importers/state_machine_event_importer.hpp"
#include "rive/importers/state_machine_layer_importer.hpp"
#include "rive/importers/layer_state_importer.hpp"
#include "rive/importers/state_transition_importer.hpp"
@@ -221,6 +222,9 @@
stackObject = new StateTransitionImporter(object->as<StateTransition>());
stackType = StateTransition::typeKey;
break;
+ case StateMachineEvent::typeKey:
+ stackObject = new StateMachineEventImporter(object->as<StateMachineEvent>());
+ break;
case ImageAsset::typeKey:
stackObject = new FileAssetImporter(object->as<FileAsset>(), m_AssetResolver);
stackType = FileAsset::typeKey;
diff --git a/src/importers/state_machine_event_importer.cpp b/src/importers/state_machine_event_importer.cpp
new file mode 100644
index 0000000..9d8fd3c
--- /dev/null
+++ b/src/importers/state_machine_event_importer.cpp
@@ -0,0 +1,13 @@
+#include "rive/importers/state_machine_event_importer.hpp"
+#include "rive/animation/state_machine_event.hpp"
+
+using namespace rive;
+
+StateMachineEventImporter::StateMachineEventImporter(StateMachineEvent* event) :
+ m_StateMachineEvent(event) {}
+
+void StateMachineEventImporter::addInputChange(EventInputChange* change) {
+ m_StateMachineEvent->addInputChange(change);
+}
+
+StatusCode StateMachineEventImporter::resolve() { return StatusCode::Ok; }
\ No newline at end of file