72 lines
1.9 KiB
C++
72 lines
1.9 KiB
C++
|
|
/* RJIntProperty.cpp */
|
|
|
|
#include "RJIntProperty.h"
|
|
|
|
// Registers fields, signals and methods for Godot
|
|
void RJIntProperty::_bind_methods()
|
|
{
|
|
// value: int
|
|
ClassDB::bind_method( D_METHOD( "set_value", "value" ), &RJIntProperty::set_value );
|
|
ClassDB::bind_method( D_METHOD( "get_value"), &RJIntProperty::get_value);
|
|
ADD_PROPERTY(PropertyInfo( Variant::INT, "value" ), "set_value", "get_value" );
|
|
|
|
ADD_SIGNAL (MethodInfo( "valueChanged" ) );
|
|
// onValueChanged: RJAction*
|
|
ClassDB::bind_method( D_METHOD( "set_onValueChanged", "onValueChanged" ), &RJIntProperty::set_onValueChanged );
|
|
ClassDB::bind_method( D_METHOD( "get_onValueChanged"), &RJIntProperty::get_onValueChanged);
|
|
ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "onValueChanged", PROPERTY_HINT_NODE_TYPE ), "set_onValueChanged", "get_onValueChanged" );
|
|
|
|
ClassDB::bind_method( D_METHOD( "dispatchValueChanged" ) , &RJIntProperty::dispatchValueChanged );
|
|
ClassDB::bind_method( D_METHOD( "setValueSilent" ) , &RJIntProperty::setValueSilent );
|
|
}
|
|
|
|
// Constructor
|
|
RJIntProperty::RJIntProperty()
|
|
{
|
|
|
|
}
|
|
|
|
// Destructor
|
|
RJIntProperty::~RJIntProperty()
|
|
{
|
|
|
|
}
|
|
|
|
// value: int
|
|
int RJIntProperty::get_value() { return value; }
|
|
void RJIntProperty::set_value( int p_value )
|
|
{
|
|
value = p_value;
|
|
|
|
emit_signal( SNAME( "valueChanged" ) );
|
|
|
|
if ( onValueChanged != NULL )
|
|
{
|
|
onValueChanged->trigger();
|
|
}
|
|
}
|
|
|
|
// onValueChanged: RJAction*
|
|
RJAction* RJIntProperty::get_onValueChanged() const { return onValueChanged; }
|
|
void RJIntProperty::set_onValueChanged( RJAction* p_onValueChanged ) { onValueChanged = p_onValueChanged; }
|
|
|
|
// dispatchValueChanged() : void
|
|
void RJIntProperty::dispatchValueChanged()
|
|
{
|
|
emit_signal( SNAME( "valueChanged" ) );
|
|
|
|
if ( onValueChanged != NULL )
|
|
{
|
|
onValueChanged->trigger();
|
|
}
|
|
}
|
|
|
|
// setValueSilent( int p_value ) : void
|
|
void RJIntProperty::setValueSilent( int p_value )
|
|
{
|
|
value = p_value;
|
|
}
|
|
|
|
|