Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving possible conflict with None definition and Fixing crash when running on Server Code via Editor (No Player Input) #38

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Plugins/Cog/Source/CogDebug/Private/CogDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,17 @@ FColor FCogDebug::ModulateDebugColor(const UWorld* World, const FColor& Color, b

switch (Settings.RecolorMode)
{
case ECogDebugRecolorMode::None:
case ECogDebugRecolorMode::CDRM_None:
{
return Color;
}

case ECogDebugRecolorMode::Color:
case ECogDebugRecolorMode::CDRM_Color:
{
return UKismetMathLibrary::LinearColorLerp(Color, Settings.RecolorColor, Settings.RecolorIntensity).ToFColor(true);
}

case ECogDebugRecolorMode::HueOverTime:
case ECogDebugRecolorMode::CDRM_HueOverTime:
{
const FLinearColor BaseColor(Color);

Expand All @@ -219,7 +219,7 @@ FColor FCogDebug::ModulateDebugColor(const UWorld* World, const FColor& Color, b
return BlendColor.ToFColor(true);
}

case ECogDebugRecolorMode::HueOverFrames:
case ECogDebugRecolorMode::CDRM_HueOverFrames:
{
const FLinearColor BaseColor(Color);
const float Factor = (Settings.RecolorFrameCycle > 0) ? (GFrameCounter % Settings.RecolorFrameCycle) / (float)Settings.RecolorFrameCycle : 0.0f;
Expand Down
10 changes: 5 additions & 5 deletions Plugins/Cog/Source/CogDebug/Public/CogDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ struct FCogDebugDrawSweepParams;
UENUM()
enum ECogDebugRecolorMode : uint8
{
None,
Color,
HueOverTime,
HueOverFrames,
CDRM_None,
CDRM_Color,
CDRM_HueOverTime,
CDRM_HueOverFrames,
};

USTRUCT()
Expand Down Expand Up @@ -63,7 +63,7 @@ struct FCogDebugSettings
float AxesScale = 1.0f;

UPROPERTY(Config)
TEnumAsByte<ECogDebugRecolorMode> RecolorMode = None;
TEnumAsByte<ECogDebugRecolorMode> RecolorMode = CDRM_None;

UPROPERTY(Config)
float RecolorIntensity = 0.0f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void FCogEngineWindow_DebugSettings::RenderContent()
ImGui::SetTooltip("How the debug element should be recolored.");
}

if (Settings.RecolorMode != ECogDebugRecolorMode::None)
if (Settings.RecolorMode != ECogDebugRecolorMode::CDRM_None)
{
FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Recolor Intensity", &Settings.RecolorIntensity, 0.01f, 0.0f, 1.0f, "%.2f");
Expand All @@ -198,11 +198,11 @@ void FCogEngineWindow_DebugSettings::RenderContent()
}
}

if (Settings.RecolorMode == ECogDebugRecolorMode::Color)
if (Settings.RecolorMode == ECogDebugRecolorMode::CDRM_Color)
{
FCogImguiHelper::ColorEdit4("Recolor Color", Settings.RecolorColor, ColorEditFlags);
}
else if (Settings.RecolorMode == HueOverTime)
else if (Settings.RecolorMode == CDRM_HueOverTime)
{
FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragFloat("Recolor Speed", &Settings.RecolorTimeSpeed, 0.1f, 0.0f, 10.0f, "%.1f");
Expand All @@ -211,7 +211,7 @@ void FCogEngineWindow_DebugSettings::RenderContent()
ImGui::SetTooltip("The speed of the recolor.");
}
}
else if (Settings.RecolorMode == ECogDebugRecolorMode::HueOverFrames)
else if (Settings.RecolorMode == ECogDebugRecolorMode::CDRM_HueOverFrames)
{
FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::DragInt("Recolor Cycle", &Settings.RecolorFrameCycle, 1, 2, 100);
Expand Down
11 changes: 11 additions & 0 deletions Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,11 @@ bool UCogWindowManager::RegisterDefaultCommandBindings()
}

UPlayerInput* PlayerInput = FCogImguiInputHelper::GetPlayerInput(*GetWorld());
if (PlayerInput == nullptr)
{
UE_LOG(LogCogImGui, Warning, TEXT("UCogWindowManager::AddCommand: PlayerInput is null"));
return false;
}

AddCommand(PlayerInput, "Cog.ToggleInput", EKeys::F1);
AddCommand(PlayerInput, "Cog.LoadLayout 1", EKeys::F2);
Expand All @@ -697,6 +702,12 @@ bool UCogWindowManager::RegisterDefaultCommandBindings()
//--------------------------------------------------------------------------------------------------------------------------
void UCogWindowManager::AddCommand(UPlayerInput* PlayerInput, const FString& Command, const FKey& Key)
{
if (!PlayerInput)
{
UE_LOG(LogCogImGui, Warning, TEXT("UCogWindowManager::AddCommand: PlayerInput is null"));
return;
}

//---------------------------------------------------
// Reassign conflicting commands
//---------------------------------------------------
Expand Down