178 lines
4 KiB
C++
178 lines
4 KiB
C++
#pragma once
|
|
|
|
#include "Component.h"
|
|
|
|
// region User header
|
|
|
|
// endregion
|
|
|
|
namespace Soundwich
|
|
{
|
|
class StopMenuMusic : public Component
|
|
{
|
|
// region Class name
|
|
|
|
public:
|
|
static const Util::String& GetType( )
|
|
{
|
|
static const Util::String type = "StopMenuMusic";
|
|
return type;
|
|
}
|
|
|
|
const Util::String& GetDerivedType( ) const
|
|
{
|
|
return GetType( );
|
|
}
|
|
|
|
// endregion
|
|
|
|
// region Data
|
|
|
|
public:
|
|
struct Data : public Component::Data
|
|
{
|
|
Data( flt32 fadeOutDuration = 0.0f )
|
|
{
|
|
FadeOutDuration = fadeOutDuration;
|
|
};
|
|
|
|
flt32 FadeOutDuration;
|
|
};
|
|
|
|
// endregion
|
|
|
|
// region Constructor/Destructor
|
|
|
|
public:
|
|
StopMenuMusic( Synth* synth, const Util::String& name, const Data& data )
|
|
: Component( synth, name )
|
|
, _data( data ) { Init( ); }
|
|
|
|
StopMenuMusic( Synth* synth, const Util::String& name )
|
|
: Component( synth, name ) { Init( ); }
|
|
|
|
~StopMenuMusic( );
|
|
|
|
bool Init( );
|
|
|
|
static void Create( Synth* synth, const Util::String& name, Component** component )
|
|
{
|
|
*component = new StopMenuMusic( synth, name );
|
|
}
|
|
|
|
// Binary Serialization
|
|
|
|
void Serialize( Util::BinaryWriter& writer )
|
|
{
|
|
writer.Write< flt32 >( _data.FadeOutDuration );
|
|
}
|
|
|
|
bool Deserialize( Util::BinaryReader& reader )
|
|
{
|
|
bool success = true;
|
|
|
|
success &= reader.Read< flt32 >( _data.FadeOutDuration );
|
|
|
|
success &= Component::Deserialize( reader );
|
|
|
|
return success;
|
|
}
|
|
|
|
// Xml Serialization
|
|
|
|
void Serialize( Util::XmlWriter& writer )
|
|
{
|
|
writer.WriteAttribute< flt32 >( "FadeOutDuration", _data.FadeOutDuration );
|
|
}
|
|
|
|
bool Deserialize( Util::XmlReader& reader )
|
|
{
|
|
bool success = true;
|
|
|
|
success &= reader.ReadAttribute< flt32 >( "FadeOutDuration", _data.FadeOutDuration );
|
|
|
|
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, StopMenuMusic::eNumInputEvents > _inputEvents;
|
|
|
|
int32 GetEventInIndex( const Util::String& name )
|
|
{
|
|
if( name == "In" )
|
|
{
|
|
return InEventIn;
|
|
}
|
|
else
|
|
{
|
|
AssertMessage( 0, "Unknown StopMenuMusic 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 StopMenuMusic port index %d", index );
|
|
|
|
static Util::String name = "Undefined";
|
|
return name;
|
|
}
|
|
};
|
|
|
|
// endregion
|
|
|
|
// region User methods
|
|
|
|
public:
|
|
static void RegisterCallback( IJustDanceStopMenuMusicCallback* cb );
|
|
static void UnregisterCallback( IJustDanceStopMenuMusicCallback* cb );
|
|
void ExecuteCallbacks( );
|
|
|
|
// endregion
|
|
|
|
// region Member variables
|
|
|
|
private:
|
|
Data _data;
|
|
|
|
// endregion
|
|
|
|
// region User member variables
|
|
|
|
private:
|
|
static Util::DynamicArray< IJustDanceStopMenuMusicCallback* > m_callbacks;
|
|
|
|
// endregion
|
|
};
|
|
}
|