Navigation Menu

Skip to content

Commit

Permalink
#6092: Add isNull() check method to FxDeclaration interface
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Sep 7, 2022
1 parent 306877d commit 322a2ad
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 45 deletions.
2 changes: 1 addition & 1 deletion include/ifx.h
Expand Up @@ -73,7 +73,7 @@ class IFxAction
// Fade in the RGB of the light or model over <time> seconds
virtual float getFadeInTimeInSeconds() = 0;

// Fade out the light/model. Ignored if fadeIn is set, you can use 2 seperate
// Fade out the light/model. Ignored if fadeIn is set, you can use 2 separate
// actions (tied together with uselight) if you want a light to fade in and out.
virtual float getFadeOutTimeInSeconds() = 0;

Expand Down
90 changes: 46 additions & 44 deletions install/scripts/test.py
Expand Up @@ -30,50 +30,52 @@ def visit(self, decl):
# FX interface
fx = GlobalFxManager.findFx("fx/sparks")

# An FX declaration inherits all the Declaration methods and properties
print("Name: " + fx.getDeclName())
print("Type: " + str(fx.getDeclType()))
print("Defined in: " + str(fx.getDeclFilePath()))
print("Definition: " + fx.getBlockSyntax().contents)

print("Number of actions: " + str(fx.getNumActions()))
print("Action with Index 1 (the second):")
action = fx.getAction(1)
print("Action #1 has Type: " + str(action.getActionType()))
print("Action #1 has Name: " + str(action.getName()))
print("Action #1 has Delay: " + str(action.getDelayInSeconds()))
print("Action #1 has Duration: " + str(action.getDurationInSeconds()))
print("Action #1 has IgnoreMaster: " + str(action.getIgnoreMaster()))
print("Action #1 has ShakeTime: " + str(action.getShakeTimeInSeconds()))
print("Action #1 has ShakeAmplitude: " + str(action.getShakeAmplitude()))
print("Action #1 has ShakeDistance: " + str(action.getShakeDistance()))
print("Action #1 has ShakeFalloff: " + str(action.getShakeFalloff()))
print("Action #1 has ShakeImpulse: " + str(action.getShakeImpulse()))
print("Action #1 has NoShadows: " + str(action.getNoShadows()))
print("Action #1 has FireSiblingAction: " + str(action.getFireSiblingAction()))
print("Action #1 has RandomDelay: " + str(action.getRandomDelay()))
print("Action #1 has Rotate: " + str(action.getRotate()))
print("Action #1 has TrackOrigin: " + str(action.getTrackOrigin()))
print("Action #1 has Restart: " + str(action.getRestart()))
print("Action #1 has FadeInTimeInSeconds: " + str(action.getFadeInTimeInSeconds()))
print("Action #1 has FadeOutTimeInSeconds: " + str(action.getFadeOutTimeInSeconds()))
print("Action #1 has DecalSize: " + str(action.getDecalSize()))
print("Action #1 has Offset: " + str(action.getOffset()))
print("Action #1 has Axis: " + str(action.getAxis()))
print("Action #1 has Angle: " + str(action.getAngle()))
print("Action #1 has UseLight: " + str(action.getUseLight()))
print("Action #1 has UseModel: " + str(action.getUseModel()))
print("Action #1 has AttachLight: " + str(action.getAttachLight()))
print("Action #1 has AttachEntity: " + str(action.getAttachEntity()))
print("Action #1 has LaunchProjectileDef: " + str(action.getLaunchProjectileDef()))
print("Action #1 has LightMaterialName: " + str(action.getLightMaterialName()))
print("Action #1 has LightRgbColour: " + str(action.getLightRgbColour()))
print("Action #1 has LightRadius: " + str(action.getLightRadius()))
print("Action #1 has ModelName: " + str(action.getModelName()))
print("Action #1 has DecalMaterialName: " + str(action.getDecalMaterialName()))
print("Action #1 has ParticleTrackVelocity: " + str(action.getParticleTrackVelocity()))
print("Action #1 has SoundShaderName: " + str(action.getSoundShaderName()))
print("Action #1 has ShockwaveDefName: " + str(action.getShockwaveDefName()))
if not fx.isNull():
# An FX declaration inherits all the Declaration methods and properties
print("Name: " + fx.getDeclName())
print("Type: " + str(fx.getDeclType()))
print("Defined in: " + str(fx.getDeclFilePath()))
print("Definition: " + fx.getBlockSyntax().contents)

print("Number of actions: " + str(fx.getNumActions()))

action = fx.getAction(1)
print("Action with Index 1 (this is the second):")
print("Action #1 has Type: " + str(action.getActionType()))
print("Action #1 has Name: " + str(action.getName()))
print("Action #1 has Delay: " + str(action.getDelayInSeconds()))
print("Action #1 has Duration: " + str(action.getDurationInSeconds()))
print("Action #1 has IgnoreMaster: " + str(action.getIgnoreMaster()))
print("Action #1 has ShakeTime: " + str(action.getShakeTimeInSeconds()))
print("Action #1 has ShakeAmplitude: " + str(action.getShakeAmplitude()))
print("Action #1 has ShakeDistance: " + str(action.getShakeDistance()))
print("Action #1 has ShakeFalloff: " + str(action.getShakeFalloff()))
print("Action #1 has ShakeImpulse: " + str(action.getShakeImpulse()))
print("Action #1 has NoShadows: " + str(action.getNoShadows()))
print("Action #1 has FireSiblingAction: " + str(action.getFireSiblingAction()))
print("Action #1 has RandomDelay: " + str(action.getRandomDelay()))
print("Action #1 has Rotate: " + str(action.getRotate()))
print("Action #1 has TrackOrigin: " + str(action.getTrackOrigin()))
print("Action #1 has Restart: " + str(action.getRestart()))
print("Action #1 has FadeInTimeInSeconds: " + str(action.getFadeInTimeInSeconds()))
print("Action #1 has FadeOutTimeInSeconds: " + str(action.getFadeOutTimeInSeconds()))
print("Action #1 has DecalSize: " + str(action.getDecalSize()))
print("Action #1 has Offset: " + str(action.getOffset()))
print("Action #1 has Axis: " + str(action.getAxis()))
print("Action #1 has Angle: " + str(action.getAngle()))
print("Action #1 has UseLight: " + str(action.getUseLight()))
print("Action #1 has UseModel: " + str(action.getUseModel()))
print("Action #1 has AttachLight: " + str(action.getAttachLight()))
print("Action #1 has AttachEntity: " + str(action.getAttachEntity()))
print("Action #1 has LaunchProjectileDef: " + str(action.getLaunchProjectileDef()))
print("Action #1 has LightMaterialName: " + str(action.getLightMaterialName()))
print("Action #1 has LightRgbColour: " + str(action.getLightRgbColour()))
print("Action #1 has LightRadius: " + str(action.getLightRadius()))
print("Action #1 has ModelName: " + str(action.getModelName()))
print("Action #1 has DecalMaterialName: " + str(action.getDecalMaterialName()))
print("Action #1 has ParticleTrackVelocity: " + str(action.getParticleTrackVelocity()))
print("Action #1 has SoundShaderName: " + str(action.getSoundShaderName()))
print("Action #1 has ShockwaveDefName: " + str(action.getShockwaveDefName()))

# Create a new material
myOwnMaterial = GlobalDeclarationManager.findOrCreateDeclaration(Declaration.Type.Material, "textures/myown_material")
Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/FxManagerInterface.cpp
Expand Up @@ -68,6 +68,7 @@ void FxManagerInterface::registerInterface(py::module& scope, py::dict& globals)
// Add the Fx Declaration interface
py::class_<ScriptFxDeclaration, ScriptDeclaration> fxDeclaration(scope, "Fx");
fxDeclaration.def(py::init<const fx::IFxDeclaration::Ptr&>());
fxDeclaration.def("isNull", &ScriptFxDeclaration::isNull);
fxDeclaration.def("getBindTo", &ScriptFxDeclaration::getBindTo);
fxDeclaration.def("getNumActions", &ScriptFxDeclaration::getNumActions);
fxDeclaration.def("getAction", &ScriptFxDeclaration::getAction);
Expand Down
5 changes: 5 additions & 0 deletions plugins/script/interfaces/FxManagerInterface.h
Expand Up @@ -204,6 +204,11 @@ class ScriptFxDeclaration :
_fx(fx)
{}

bool isNull()
{
return !_fx;
}

std::size_t getNumActions()
{
return _fx ? _fx->getNumActions() : 0;
Expand Down

0 comments on commit 322a2ad

Please sign in to comment.