mirror of
https://github.com/Theaninova/BeatLanguageMapper.git
synced 2026-01-19 08:22:56 +00:00
Mk2
uh stuff. i'm putting it in the readme.
This commit is contained in:
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
By Rama for You
|
||||
|
||||
You are welcome to use this code anywhere as long as you include this notice.
|
||||
|
||||
copyright 2015
|
||||
*/
|
||||
#include "VictoryUMGPrivatePCH.h"
|
||||
#include "JoyColorWheel.h"
|
||||
|
||||
//LOCTEXT
|
||||
#define LOCTEXT_NAMESPACE "UMG"
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// UJoyColorWheel
|
||||
|
||||
#if WITH_EDITOR
|
||||
/*
|
||||
const FSlateBrush* UJoyColorWheel::GetEditorIcon()
|
||||
{
|
||||
return FUMGStyle::Get().GetBrush("Widget.Image");
|
||||
}
|
||||
*/
|
||||
|
||||
const FText UJoyColorWheel::GetPaletteCategory()
|
||||
{
|
||||
return LOCTEXT("Victory UMG", "Victory UMG");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
UJoyColorWheel::UJoyColorWheel(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
, JoyColor(FLinearColor::Red)
|
||||
{
|
||||
//Default Values Set Here, see above
|
||||
}
|
||||
|
||||
//Rebuild
|
||||
TSharedRef<SWidget> UJoyColorWheel::RebuildWidget()
|
||||
{
|
||||
FColorPickerArgs Args;
|
||||
|
||||
//Initial Color
|
||||
Args.InitialColorOverride = JoyColor;
|
||||
|
||||
Args.bUseAlpha = true;
|
||||
Args.bOnlyRefreshOnOk = false;
|
||||
Args.bOnlyRefreshOnMouseUp = false;
|
||||
|
||||
//Delegates!
|
||||
Args.OnColorCommitted = FOnLinearColorValueChanged::CreateUObject( this, &UJoyColorWheel::ColorUpdated);
|
||||
Args.OnColorPickerCancelled = FOnColorPickerCancelled::CreateUObject( this, &UJoyColorWheel::ColorPickCancelled);
|
||||
|
||||
//~~~
|
||||
|
||||
ColorPicker = SNew(SJoyColorPicker)
|
||||
.TargetColorAttribute(Args.InitialColorOverride)
|
||||
.TargetFColors(Args.ColorArray ? *Args.ColorArray : TArray<FColor*>())
|
||||
.TargetLinearColors(Args.LinearColorArray ? *Args.LinearColorArray : TArray<FLinearColor*>())
|
||||
.TargetColorChannels(Args.ColorChannelsArray ? *Args.ColorChannelsArray : TArray<FColorChannels>())
|
||||
.UseAlpha(Args.bUseAlpha)
|
||||
.ExpandAdvancedSection(Args.bExpandAdvancedSection)
|
||||
.OnlyRefreshOnMouseUp(Args.bOnlyRefreshOnMouseUp && !Args.bIsModal)
|
||||
.OnlyRefreshOnOk(Args.bOnlyRefreshOnOk || Args.bIsModal)
|
||||
.OnColorCommitted(Args.OnColorCommitted)
|
||||
.PreColorCommitted(Args.PreColorCommitted)
|
||||
.OnColorPickerCancelled(Args.OnColorPickerCancelled)
|
||||
.OnInteractivePickBegin(Args.OnInteractivePickBegin)
|
||||
.OnInteractivePickEnd(Args.OnInteractivePickEnd)
|
||||
.DisplayGamma(Args.DisplayGamma);
|
||||
|
||||
//Skip Animation?
|
||||
if(bSkipAnimationOnConstruction)
|
||||
{
|
||||
SetColor(JoyColor, true); //Skip
|
||||
}
|
||||
|
||||
return ColorPicker.ToSharedRef();
|
||||
}
|
||||
//Release
|
||||
void UJoyColorWheel::ReleaseSlateResources(bool bReleaseChildren)
|
||||
{
|
||||
Super::ReleaseSlateResources(bReleaseChildren);
|
||||
|
||||
ColorPicker.Reset();
|
||||
}
|
||||
|
||||
#if WITH_EDITOR
|
||||
void UJoyColorWheel::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
|
||||
{
|
||||
Super::PostEditChangeProperty(PropertyChangedEvent);
|
||||
|
||||
FName PropertyName = (PropertyChangedEvent.Property != NULL) ? PropertyChangedEvent.Property->GetFName() : NAME_None;
|
||||
|
||||
//Update Picker to JoyColor property change!
|
||||
if (PropertyName == TEXT("JoyColor"))
|
||||
{
|
||||
if(ColorPicker.IsValid())
|
||||
{
|
||||
ColorPicker->SetColorRGB(JoyColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~
|
||||
// BP Exposed
|
||||
//~~~~~~~~~~~~~~~~~~
|
||||
FLinearColor UJoyColorWheel::GetColor()
|
||||
{
|
||||
return JoyColor;
|
||||
}
|
||||
void UJoyColorWheel::SetColor(FLinearColor NewColor, bool SkipAnimation )
|
||||
{
|
||||
if(!ColorPicker.IsValid()) return;
|
||||
|
||||
//Skip Anim?
|
||||
if(SkipAnimation)
|
||||
{
|
||||
ColorPicker->InstantColor = NewColor;
|
||||
ColorPicker->Animation_SkipToFinalForOneTick = true; //See SJoyColorPicker.h
|
||||
}
|
||||
else
|
||||
{
|
||||
//Set!
|
||||
ColorPicker->SetColorRGB(NewColor);
|
||||
}
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~
|
||||
// Color Picker Internal
|
||||
//~~~~~~~~~~~~~~~~~~~~
|
||||
void UJoyColorWheel::ColorUpdated(FLinearColor NewValue)
|
||||
{
|
||||
JoyColor = NewValue;
|
||||
|
||||
if(OnColorChanged.IsBound())
|
||||
{
|
||||
OnColorChanged.Broadcast(JoyColor);
|
||||
}
|
||||
}
|
||||
void UJoyColorWheel::ColorPickCancelled(FLinearColor NewValue)
|
||||
{
|
||||
//Color Picking Cancelled!
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
By Rama for You
|
||||
|
||||
You are welcome to use this code anywhere as long as you include this notice.
|
||||
|
||||
copyright 2015
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//UE4 Color Picker
|
||||
// Requires public module in build.cs
|
||||
// APPFRAMEWORK
|
||||
#include "SColorPicker.h"
|
||||
|
||||
class SJoyColorPicker
|
||||
: public SColorPicker
|
||||
{
|
||||
typedef SColorPicker Super;
|
||||
|
||||
public: //! <~~~~~
|
||||
FORCEINLINE void SetColorRGB(const FLinearColor& NewColor)
|
||||
{
|
||||
//This is protected in SColorPicker
|
||||
// so can't call it from UMG component
|
||||
SetNewTargetColorRGB( NewColor, true ); //Force Update
|
||||
}
|
||||
|
||||
|
||||
//Animation
|
||||
public:
|
||||
|
||||
FLinearColor InstantColor;
|
||||
bool Animation_SkipToFinalForOneTick = false;
|
||||
virtual void Tick( const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime ) override
|
||||
{
|
||||
//Skip to final, then resume normal animation behavior
|
||||
if(Animation_SkipToFinalForOneTick)
|
||||
{
|
||||
Animation_SkipToFinalForOneTick = false;
|
||||
Super::Tick(AllottedGeometry, InCurrentTime, 10000); //<~~~ because all the required vars like CurrentTime are private :)
|
||||
SetNewTargetColorRGB(InstantColor,true);
|
||||
return;
|
||||
//~~~~
|
||||
}
|
||||
|
||||
//Animate normally!
|
||||
Super::Tick(AllottedGeometry, InCurrentTime, InDeltaTime);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
By Rama for You
|
||||
|
||||
You are welcome to use this code anywhere as long as you include this notice.
|
||||
|
||||
copyright 2015
|
||||
*/
|
||||
#include "VictoryUMGPrivatePCH.h"
|
||||
|
||||
DEFINE_LOG_CATEGORY(VictoryUMG)
|
||||
|
||||
IMPLEMENT_MODULE(FDefaultGameModuleImpl, VictoryUMG);
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
By Rama for You
|
||||
|
||||
You are welcome to use this code anywhere as long as you include this notice.
|
||||
|
||||
copyright 2015
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "Engine.h"
|
||||
#include "VictoryUMGClasses.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(VictoryUMG, Log, All);
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
JoyColorWheel by Rama
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
//~~~~~~~~~~~~ UMG ~~~~~~~~~~~~~~~~
|
||||
#include "Runtime/UMG/Public/UMG.h"
|
||||
#include "Runtime/UMG/Public/UMGStyle.h"
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
//UE4 Color Picker
|
||||
#include "SJoyColorPicker.h"
|
||||
|
||||
#include "JoyColorWheel.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnJoyColorChangedEvent, const FLinearColor&, NewColor);
|
||||
|
||||
UCLASS()
|
||||
class VICTORYUMG_API UJoyColorWheel : public UWidget
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
//Color Picker Slate
|
||||
protected:
|
||||
TSharedPtr<SJoyColorPicker> ColorPicker;
|
||||
|
||||
//~~~~~~~~~~~~~~
|
||||
// BP Exposed Core
|
||||
//~~~~~~~~~~~~~~
|
||||
public:
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Joy Color Wheel")
|
||||
FLinearColor JoyColor;
|
||||
|
||||
/** Should the color picker jump instantly to the chosen JoyColor when it is first created? */
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Joy Color Wheel")
|
||||
bool bSkipAnimationOnConstruction = false;
|
||||
|
||||
|
||||
/** Called whenever the color is changed! Yay! */
|
||||
UPROPERTY(BlueprintAssignable, Category="Widget Event", meta=(DisplayName="OnColorChanged (Joy Color Wheel)"))
|
||||
FOnJoyColorChangedEvent OnColorChanged;
|
||||
|
||||
/** Get Color! */
|
||||
UFUNCTION(BlueprintPure, Category="Joy Color Wheel")
|
||||
FLinearColor GetColor();
|
||||
|
||||
/** Set Color Picker's Color! */
|
||||
UFUNCTION(BlueprintCallable, Category="Joy Color Wheel")
|
||||
void SetColor(FLinearColor NewColor, bool SkipAnimation = false );
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~
|
||||
// Color Picker Internal
|
||||
//~~~~~~~~~~~~~~~~~~
|
||||
public:
|
||||
void ColorUpdated(FLinearColor NewValue);
|
||||
void ColorPickCancelled(FLinearColor NewValue);
|
||||
|
||||
//~~~~~~~~~~~~~~
|
||||
// UMG Component
|
||||
//~~~~~~~~~~~~~~
|
||||
public:
|
||||
|
||||
// UVisual interface
|
||||
virtual void ReleaseSlateResources(bool bReleaseChildren) override;
|
||||
// End of UVisual interface
|
||||
|
||||
protected:
|
||||
// UWidget interface
|
||||
virtual TSharedRef<SWidget> RebuildWidget() override;
|
||||
// End of UWidget interface
|
||||
|
||||
#if WITH_EDITOR
|
||||
// UWidget interface
|
||||
//virtual const FSlateBrush* GetEditorIcon() override;
|
||||
virtual const FText GetPaletteCategory() override;
|
||||
// End UWidget interface
|
||||
|
||||
// UObject interface
|
||||
virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override;
|
||||
// End of UObject interface
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
36
Plugins/PluginPackaged/Source/VictoryUMG/VictoryUMG.Build.cs
Normal file
36
Plugins/PluginPackaged/Source/VictoryUMG/VictoryUMG.Build.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
By Rama for You
|
||||
|
||||
You are welcome to use this code anywhere as long as you include this notice.
|
||||
|
||||
copyright 2015
|
||||
*/
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class VictoryUMG : ModuleRules
|
||||
{
|
||||
public VictoryUMG(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[] {
|
||||
"Core",
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"InputCore",
|
||||
|
||||
"RHI",
|
||||
"RenderCore",
|
||||
|
||||
"UMG", "Slate", "SlateCore",
|
||||
|
||||
"APPFRAMEWORK" //for color picker! -Rama
|
||||
|
||||
}
|
||||
);
|
||||
//Private Paths
|
||||
PrivateIncludePaths.AddRange(new string[] {
|
||||
"VictoryUMG/Public",
|
||||
"VictoryUMG/Private"
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user