189 lines
4.6 KiB
C++
189 lines
4.6 KiB
C++
#pragma once
|
|
|
|
#include "Component.h"
|
|
|
|
// region User header
|
|
|
|
// endregion
|
|
|
|
namespace Soundwich
|
|
{
|
|
class StopAllEventBusMixes : public Component
|
|
{
|
|
// region Class name
|
|
|
|
public:
|
|
static const Util::String& GetType()
|
|
{
|
|
static const Util::String type = "StopAllEventBusMixes";
|
|
return type;
|
|
}
|
|
|
|
const Util::String& GetDerivedType() const
|
|
{
|
|
return GetType();
|
|
}
|
|
|
|
// endregion
|
|
|
|
// region Data
|
|
|
|
public:
|
|
struct Data : public Component::Data
|
|
{
|
|
Data(bool includeMainBusMix = false, flt32 fadeDurationOverride = -1.0f)
|
|
{
|
|
IncludeMainBusMix = includeMainBusMix;
|
|
FadeDurationOverride = fadeDurationOverride;
|
|
};
|
|
|
|
bool IncludeMainBusMix;
|
|
flt32 FadeDurationOverride;
|
|
};
|
|
|
|
// endregion
|
|
|
|
// region Constructor/Destructor
|
|
|
|
public:
|
|
StopAllEventBusMixes(Synth* synth, const Util::String& name, const Data& data)
|
|
: Component(synth, name)
|
|
, _data(data) {
|
|
Init();
|
|
}
|
|
|
|
StopAllEventBusMixes(Synth* synth, const Util::String& name)
|
|
: Component(synth, name) {
|
|
Init();
|
|
}
|
|
|
|
~StopAllEventBusMixes();
|
|
|
|
bool Init();
|
|
|
|
static void Create(Synth* synth, const Util::String& name, Component** component)
|
|
{
|
|
*component = new StopAllEventBusMixes(synth, name);
|
|
}
|
|
|
|
// Binary Serialization
|
|
|
|
void Serialize(Util::BinaryWriter& writer)
|
|
{
|
|
writer.Write< bool >(_data.IncludeMainBusMix);
|
|
writer.Write< flt32 >(_data.FadeDurationOverride);
|
|
}
|
|
|
|
bool Deserialize(Util::BinaryReader& reader)
|
|
{
|
|
bool success = true;
|
|
|
|
success &= reader.Read< bool >(_data.IncludeMainBusMix);
|
|
success &= reader.Read< flt32 >(_data.FadeDurationOverride);
|
|
|
|
success &= Component::Deserialize(reader);
|
|
|
|
return success;
|
|
}
|
|
|
|
// Xml Serialization
|
|
|
|
void Serialize(Util::XmlWriter& writer)
|
|
{
|
|
writer.WriteAttribute< bool >("IncludeMainBusMix", _data.IncludeMainBusMix);
|
|
writer.WriteAttribute< flt32 >("FadeDurationOverride", _data.FadeDurationOverride);
|
|
}
|
|
|
|
bool Deserialize(Util::XmlReader& reader)
|
|
{
|
|
bool success = true;
|
|
|
|
success &= reader.ReadAttribute< bool >("IncludeMainBusMix", _data.IncludeMainBusMix);
|
|
success &= reader.ReadAttribute< flt32 >("FadeDurationOverride", _data.FadeDurationOverride);
|
|
|
|
success &= Component::Deserialize(reader);
|
|
|
|
return success;
|
|
}
|
|
|
|
// endregion
|
|
|
|
// region Input Events
|
|
|
|
public:
|
|
enum InputEvents
|
|
{
|
|
InEventIn,
|
|
eNumInputEvents
|
|
};
|
|
|
|
inline void AddEventIn(uint32 index, EventConnection* connection)
|
|
{
|
|
Assert(connection);
|
|
Assert(_inputEvents[index].Find(connection) == _inputEvents[index].End());
|
|
|
|
_inputEvents[index].PushBack(connection);
|
|
}
|
|
|
|
void PushEventIn(uint32 index, Component* from);
|
|
|
|
private:
|
|
Util::FixedArray< EventConnectionList, StopAllEventBusMixes::eNumInputEvents > _inputEvents;
|
|
|
|
int32 GetEventInIndex(const Util::String& name)
|
|
{
|
|
if (name == "In")
|
|
{
|
|
return InEventIn;
|
|
}
|
|
else
|
|
{
|
|
AssertMessage(0, "Unknown StopAllEventBusMixes port name %s", name.Chars());
|
|
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
const Util::String& GetEventInName(uint32 index)
|
|
{
|
|
if (index == InEventIn)
|
|
{
|
|
static Util::String name = "In";
|
|
return name;
|
|
}
|
|
else
|
|
{
|
|
AssertMessage(0, "Unknown StopAllEventBusMixes port index %d", index);
|
|
|
|
static Util::String name = "Undefined";
|
|
return name;
|
|
}
|
|
};
|
|
|
|
// endregion
|
|
|
|
// region User methods
|
|
|
|
public:
|
|
static void RegisterCallback(IJustDanceStopAllEventBusMixesCallback* cb);
|
|
static void UnregisterCallback(IJustDanceStopAllEventBusMixesCallback* cb);
|
|
void ExecuteCallbacks();
|
|
|
|
// endregion
|
|
|
|
// region Member variables
|
|
|
|
private:
|
|
Data _data;
|
|
|
|
// endregion
|
|
|
|
// region User member variables
|
|
|
|
private:
|
|
static Util::DynamicArray< IJustDanceStopAllEventBusMixesCallback* > m_callbacks;
|
|
|
|
// endregion
|
|
};
|
|
}
|
|
|