Skip to content

Commit

Permalink
Added array versions of per-key BP functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmpreussner committed Nov 7, 2016
1 parent 7e99b77 commit 9253798
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 13 deletions.
63 changes: 63 additions & 0 deletions Source/LogiLed/Private/LogiLedBlueprintLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,15 @@ void ULogiLedBlueprintLibrary::LogiLedFlashLightingForKey(ELogiLedKeys Key, FLin
}


void ULogiLedBlueprintLibrary::LogiLedFlashLightingForKeys(const TArray<ELogiLedKeys> Keys, FLinearColor Color, FTimespan Duration, FTimespan Interval)
{
for (const auto& Key : Keys)
{
LogiLedFlashLightingForKey(Key, Color, Duration, Interval);
}
}


void ULogiLedBlueprintLibrary::LogiLedPulseLightingForKey(ELogiLedKeys Key, FLinearColor StartColor, FLinearColor EndColor, FTimespan Duration, bool Infinite)
{
const FLinearColor StartPercentage = StartColor.GetClamped() * 100.0f;
Expand All @@ -260,6 +269,15 @@ void ULogiLedBlueprintLibrary::LogiLedPulseLightingForKey(ELogiLedKeys Key, FLin
}


void ULogiLedBlueprintLibrary::LogiLedPulseLightingForKeys(const TArray<ELogiLedKeys>& Keys, FLinearColor StartColor, FLinearColor EndColor, FTimespan Duration, bool Infinite)
{
for (const auto& Key : Keys)
{
LogiLedPulseLightingForKey(Key, StartColor, EndColor, Duration, Infinite);
}
}


void ULogiLedBlueprintLibrary::LogiLedRestoreLightingForKey(ELogiLedKeys Key)
{
if (!::LogiLedRestoreLightingForKey((LogiLed::KeyName)LogiLedKeyName[(int)Key]))
Expand All @@ -269,6 +287,15 @@ void ULogiLedBlueprintLibrary::LogiLedRestoreLightingForKey(ELogiLedKeys Key)
}


void ULogiLedBlueprintLibrary::LogiLedRestoreLightingForKeys(const TArray<ELogiLedKeys>& Keys)
{
for (const auto& Key : Keys)
{
LogiLedRestoreLightingForKey(Key);
}
}


void ULogiLedBlueprintLibrary::LogiLedSaveLightingForKey(ELogiLedKeys Key)
{
if (!::LogiLedSaveLightingForKey((LogiLed::KeyName)LogiLedKeyName[(int)Key]))
Expand All @@ -278,12 +305,30 @@ void ULogiLedBlueprintLibrary::LogiLedSaveLightingForKey(ELogiLedKeys Key)
}


void ULogiLedBlueprintLibrary::LogiLedSaveLightingForKeys(const TArray<ELogiLedKeys>& Keys)
{
for (const auto& Key : Keys)
{
LogiLedSaveLightingForKey(Key);
}
}


void ULogiLedBlueprintLibrary::LogiLedSetLightingCurveForKey(ELogiLedKeys Key, UCurveLinearColor* ColorCurve)
{
Manager.PlayAnimation((LogiLed::KeyName)LogiLedKeyName[(int)Key], ColorCurve);
}


void ULogiLedBlueprintLibrary::LogiLedSetLightingCurveForKeys(const TArray<ELogiLedKeys>& Keys, UCurveLinearColor* ColorCurve)
{
for (const auto& Key : Keys)
{
LogiLedSetLightingCurveForKey(Key, ColorCurve);
}
}


void ULogiLedBlueprintLibrary::LogiLedSetLightingForKey(ELogiLedKeys Key, FLinearColor Color)
{
const FLinearColor Percentage = Color.GetClamped() * 100.0f;
Expand All @@ -295,6 +340,15 @@ void ULogiLedBlueprintLibrary::LogiLedSetLightingForKey(ELogiLedKeys Key, FLinea
}


void ULogiLedBlueprintLibrary::LogiLedSetLightingForKeys(const TArray<ELogiLedKeys>& Keys, FLinearColor Color)
{
for (const auto& Key : Keys)
{
LogiLedSetLightingForKey(Key, Color);
}
}


void ULogiLedBlueprintLibrary::LogiLedSetLightingFromTexture(UTexture* Texture)
{
if ((Texture == nullptr) || (Texture->Resource == nullptr))
Expand Down Expand Up @@ -324,3 +378,12 @@ void ULogiLedBlueprintLibrary::LogiLedStopEffectForKey(ELogiLedKeys Key)
UE_LOG(LogLogiLed, Verbose, TEXT("Failed to stop effects for key %s"), *LogiLedKeyToString(Key));
}
}


void ULogiLedBlueprintLibrary::LogiLedStopEffectForKeys(const TArray<ELogiLedKeys>& Keys)
{
for (const auto& Key : Keys)
{
LogiLedStopEffectForKey(Key);
}
}
87 changes: 74 additions & 13 deletions Source/LogiLed/Private/LogiLedBlueprintLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ class ULogiLedBlueprintLibrary
* @param Color The flash color.
* @param Duration Duration of the effect.
* @param Interval Flashing interval.
* @return true on success, false otherwise.
* @see LogiLedFlashSingleKey, LogiLedPulseLighting, LogiLedSetLighting, LogiLedSetTargetDevice, LogiLedStopEffects
*/
UFUNCTION(BlueprintCallable, Category="LogiLed|General")
Expand All @@ -263,7 +262,6 @@ class ULogiLedBlueprintLibrary
* @param Color The pulse color.
* @param Duration Duration of the effect.
* @param Interval Flashing interval.
* @return true on success, false otherwise.
* @see LogiLedFlashLighting, LogiLedPulseSingleKey, LogiLedSetLighting, LogiLedSetTargetDevice, LogiLedStopEffects
*/
UFUNCTION(BlueprintCallable, Category="LogiLed|General")
Expand Down Expand Up @@ -323,25 +321,35 @@ class ULogiLedBlueprintLibrary
* Set a collection of keys to ignore when setting lighting from a bitmap.
*
* @param Keys The keys to exclude.
* @return true on success, false otherwise.
* @see LogiLedSetLightingFromTexture
*/
UFUNCTION(BlueprintCallable, Category="LogiLed|PerKey")
static void LogiLedExcludeKeysFromTexture(TArray<ELogiLedKeys> Keys);

/**
* Play a flashing effect on the targeted devices.
* Play a flashing effect on the specified key.
*
* @param Key The key to flash.
* @param Color The flash color.
* @param Duration Duration of the effect.
* @param Interval Flashing interval.
* @return true on success, false otherwise.
* @see LogiLedFlashLighting. LogiLedPulseSingleKey, LogiLedSetTargetDevice, LogiLedStopEffects, LogiLedStopEffectsOnKey
*/
UFUNCTION(BlueprintCallable, Category="LogiLed|PerKey")
static void LogiLedFlashLightingForKey(ELogiLedKeys Key, FLinearColor Color, FTimespan Duration, FTimespan Interval);

/**
* Play a flashing effect on the specified keys.
*
* @param Keys The keys to flash.
* @param Color The flash color.
* @param Duration Duration of the effect.
* @param Interval Flashing interval.
* @see LogiLedFlashLighting. LogiLedPulseSingleKey, LogiLedSetTargetDevice, LogiLedStopEffects, LogiLedStopEffectsOnKey
*/
UFUNCTION(BlueprintCallable, Category="LogiLed|PerKey")
static void LogiLedFlashLightingForKeys(const TArray<ELogiLedKeys> Keys, FLinearColor Color, FTimespan Duration, FTimespan Interval);

/**
* Play a pulsing effect on the specified key.
*
Expand All @@ -350,61 +358,105 @@ class ULogiLedBlueprintLibrary
* @param EndColor The pulse color to finish with.
* @param Duration Duration of the effect.
* @param Infinite Whether to loop the effect until LogiLedStopEffectsOnKey or LogiLedStopEffects is called.
* @return true on success, false otherwise.
* @see LogiLedFlashSingleKey, LogiLedPulseLighting, LogiLedSetTargetDevice, LogiLedStopEffects, LogiLedStopEffectsOnKey
*/
UFUNCTION(BlueprintCallable, Category="LogiLed|PerKey")
static void LogiLedPulseLightingForKey(ELogiLedKeys Key, FLinearColor StartColor, FLinearColor EndColor, FTimespan Duration, bool Infinite);

/**
* Play a pulsing effect on the specified keys.
*
* @param Keys The keys to pulse.
* @param StartColor The pulse color to start with.
* @param EndColor The pulse color to finish with.
* @param Duration Duration of the effect.
* @param Infinite Whether to loop the effect until LogiLedStopEffectsOnKey or LogiLedStopEffects is called.
* @see LogiLedFlashSingleKey, LogiLedPulseLighting, LogiLedSetTargetDevice, LogiLedStopEffects, LogiLedStopEffectsOnKey
*/
UFUNCTION(BlueprintCallable, Category="LogiLed|PerKey")
static void LogiLedPulseLightingForKeys(const TArray<ELogiLedKeys>& Keys, FLinearColor StartColor, FLinearColor EndColor, FTimespan Duration, bool Infinite);

/**
* Restore a previously saved lighting for the specified key.
*
* @return true on success, false otherwise.
* @return true on success, false otherwise.
* @param Key The key to restore.
* @see LogiLedRestoreLighting, LogiLedSaveLightingForKey, LogiLedSetTargetDevice
*/
UFUNCTION(BlueprintCallable, Category="LogiLed|PerKey")
static void LogiLedRestoreLightingForKey(ELogiLedKeys Key);

/**
* Restore a previously saved lighting for the specified keys.
*
* @param Keys The keys to restore.
* @see LogiLedRestoreLighting, LogiLedSaveLightingForKey, LogiLedSetTargetDevice
*/
UFUNCTION(BlueprintCallable, Category="LogiLed|PerKey")
static void LogiLedRestoreLightingForKeys(const TArray<ELogiLedKeys>& Keys);

/**
* Save the current lighting for the specified key so that it can be restored.
*
* @return true on success, false otherwise.
* @return true on success, false otherwise.
* @param Key The key to restore.
* @see LogiLedRestoreLightingForKey, LogiLedSaveLighting, LogiLedSetTargetDevice
*/
UFUNCTION(BlueprintCallable, Category="LogiLed|PerKey")
static void LogiLedSaveLightingForKey(ELogiLedKeys Key);

/**
* Save the current lighting for the specified keys so that it can be restored.
*
* @param Keys The keys to restore.
* @see LogiLedRestoreLightingForKey, LogiLedSaveLighting, LogiLedSetTargetDevice
*/
UFUNCTION(BlueprintCallable, Category="LogiLed|PerKey")
static void LogiLedSaveLightingForKeys(const TArray<ELogiLedKeys>& Keys);

/**
* Play a color curve on the specified key.
*
* @param Key The key to play the color curve on.
* @param ColorCurve The color curve to play.
* @return true on success, false otherwise.
* @see LogiledAnimateLighting, LogiLedSetTargetDevice
*/
UFUNCTION(BlueprintCallable, Category="LogiLed|PerKey")
static void LogiLedSetLightingCurveForKey(ELogiLedKeys Key, UCurveLinearColor* ColorCurve);

/**
* Play a color curve on the specified keys.
*
* @param Keys The keys to play the color curve on.
* @param ColorCurve The color curve to play.
* @see LogiledAnimateLighting, LogiLedSetTargetDevice
*/
UFUNCTION(BlueprintCallable, Category="LogiLed|PerKey")
static void LogiLedSetLightingCurveForKeys(const TArray<ELogiLedKeys>& Keys, UCurveLinearColor* ColorCurve);

/**
* Set the lighting on the specified key.
*
* @param Key The key to set the lighting on.
* @param Color The lighting color to set.
*
*/
UFUNCTION(BlueprintCallable, Category="LogiLed|PerKey")
static void LogiLedSetLightingForKey(ELogiLedKeys Key, FLinearColor Color);

/**
* Set the lighting on the specified keys.
*
* @param Keys The keys to set the lighting on.
* @param Color The lighting color to set.
*/
UFUNCTION(BlueprintCallable, Category="LogiLed|PerKey")
static void LogiLedSetLightingForKeys(const TArray<ELogiLedKeys>& Keys, FLinearColor Color);

/**
* Set the lighting of keys on the target device based on pixels in a texture.
*
* The texture is organized as an array of 21x6 RGBA pixels, representing the
* keys on the target device.
*
* @param Texture The texture containing the lighting color values.
* @return true on success, false otherwise.
* @see LogiLedExcludeKeysFromTexture
*/
UFUNCTION(BlueprintCallable, Category="LogiLed|PerKey")
Expand All @@ -419,6 +471,15 @@ class ULogiLedBlueprintLibrary
UFUNCTION(BlueprintCallable, Category="LogiLed|PerKey")
static void LogiLedStopEffectForKey(ELogiLedKeys Key);

/**
* Stop any active flashing, pulsing, or curve effect on the specified keys.
*
* @param Keys The keys to stop the effect on.
* @see LogiLedFlashSingleKey, LogiLedPulseSingleKey, LogiLedSetTargetDevice, LogiLedStopEffects
*/
UFUNCTION(BlueprintCallable, Category="LogiLed|PerKey")
static void LogiLedStopEffectForKeys(const TArray<ELogiLedKeys>& Keys);

private:

/** State and timing manager. */
Expand Down

0 comments on commit 9253798

Please sign in to comment.