diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Audio.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Audio.cpp index db9ed3a..5db3d27 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Audio.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Audio.cpp @@ -3,7 +3,7 @@ #include "Engine/Engine.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Audio::RenderHelp() +void FCogEngineWindow_Audio::RenderHelp() { ImGui::Text( "This window displays audio settings. " @@ -11,9 +11,7 @@ void UCogEngineWindow_Audio::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Audio::RenderContent() +void FCogEngineWindow_Audio::RenderContent() { Super::RenderContent(); - - } diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Collisions.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Collisions.cpp index 99b4b87..96f1ce9 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Collisions.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Collisions.cpp @@ -13,8 +13,21 @@ #include "imgui.h" #include "Kismet/GameplayStatics.h" + //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Collisions::RenderHelp() +void FCogEngineWindow_Collisions::Initialize() +{ + Super::Initialize(); + + bHasMenu = true; + + SetAsset(GetAsset()); + + Config = GetConfig(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogEngineWindow_Collisions::RenderHelp() { ImGui::Text("This window is used to inspect collisions by performing a collision query with the selected channels. " "The query can be configured in the options. " @@ -24,30 +37,15 @@ void UCogEngineWindow_Collisions::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -UCogEngineWindow_Collisions::UCogEngineWindow_Collisions() -{ - bHasMenu = true; - - SetAsset(FCogWindowHelper::GetFirstAssetByClass()); -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Collisions::ResetConfig() +void FCogEngineWindow_Collisions::ResetConfig() { Super::ResetConfig(); - ObjectTypesToQuery = 0; - ProfileIndex = 0; - QueryType = 0; - QueryDistance = 5000.0f; - QueryThickness = 0.0f; - UseComplexCollisions = false; - ShowActorsNames = false; - ShowQuery = false; + Config->Reset(); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Collisions::RenderContent() +void FCogEngineWindow_Collisions::RenderContent() { Super::RenderContent(); @@ -77,7 +75,7 @@ void UCogEngineWindow_Collisions::RenderContent() //------------------------------------------------- // Query Mode //------------------------------------------------- - ImGui::Combo("Query", &QueryType, + ImGui::Combo("Query", &Config->QueryType, "Sphere\0" "Raycast Crosshair\0" "Raycast Cursor\0" @@ -87,30 +85,30 @@ void UCogEngineWindow_Collisions::RenderContent() //------------------------------------------------- // Query Distance //------------------------------------------------- - ImGui::SliderFloat("Distance", &QueryDistance, 0.0f, 20000.0f, "%0.f"); + ImGui::SliderFloat("Distance", &Config->QueryDistance, 0.0f, 20000.0f, "%0.f"); //------------------------------------------------- // Query Thickness //------------------------------------------------- - if (QueryType == 1 || QueryType == 2) + if (Config->QueryType == 1 || Config->QueryType == 2) { - ImGui::SliderFloat("Thickness", &QueryThickness, 0.0f, 1000.0f, "%0.f"); + ImGui::SliderFloat("Thickness", &Config->QueryThickness, 0.0f, 1000.0f, "%0.f"); } //------------------------------------------------- // Query Use Complex Collisions //------------------------------------------------- - ImGui::Checkbox("Use Complex Collisions", &UseComplexCollisions); + ImGui::Checkbox("Use Complex Collisions", &Config->UseComplexCollisions); //------------------------------------------------- // Show Names //------------------------------------------------- - ImGui::Checkbox("Show Actors Names", &ShowActorsNames); + ImGui::Checkbox("Show Actors Names", &Config->ShowActorsNames); //------------------------------------------------- // Show Query //------------------------------------------------- - ImGui::Checkbox("Show Query", &ShowQuery); + ImGui::Checkbox("Show Query", &Config->ShowQuery); ImGui::EndMenu(); } @@ -121,7 +119,7 @@ void UCogEngineWindow_Collisions::RenderContent() //------------------------------------------------- // Profile //------------------------------------------------- - const FCollisionResponseTemplate* SelectedProfile = CollisionProfile->GetProfileByIndex(ProfileIndex); + const FCollisionResponseTemplate* SelectedProfile = CollisionProfile->GetProfileByIndex(Config->ProfileIndex); FName SelectedProfileName = SelectedProfile != nullptr ? SelectedProfile->Name : FName("Custom"); if (ImGui::BeginCombo("Profile", TCHAR_TO_ANSI(*SelectedProfileName.ToString()), ImGuiComboFlags_HeightLargest)) @@ -131,9 +129,9 @@ void UCogEngineWindow_Collisions::RenderContent() const FCollisionResponseTemplate* Profile = CollisionProfile->GetProfileByIndex(i); if (ImGui::Selectable(TCHAR_TO_ANSI(*Profile->Name.ToString()), false)) { - ProfileIndex = i; - ObjectTypesToQuery = 0; - SelectedProfile = CollisionProfile->GetProfileByIndex(ProfileIndex); + Config->ProfileIndex = i; + Config->ObjectTypesToQuery = 0; + SelectedProfile = CollisionProfile->GetProfileByIndex(Config->ProfileIndex); if (Profile->CollisionEnabled != ECollisionEnabled::NoCollision) { @@ -142,7 +140,7 @@ void UCogEngineWindow_Collisions::RenderContent() ECollisionResponse Response = Profile->ResponseToChannels.GetResponse((ECollisionChannel)j); if (Response != ECR_Ignore) { - ObjectTypesToQuery |= ECC_TO_BITFIELD(j); + Config->ObjectTypesToQuery |= ECC_TO_BITFIELD(j); } } } @@ -169,19 +167,19 @@ void UCogEngineWindow_Collisions::RenderContent() ImGui::ColorEdit4("Color", (float*)&Color.Value, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel); ImGui::SameLine(); - bool IsCollisionActive = (ObjectTypesToQuery & ECC_TO_BITFIELD(ChannelIndex)) > 0; + bool IsCollisionActive = (Config->ObjectTypesToQuery & ECC_TO_BITFIELD(ChannelIndex)) > 0; const FName ChannelName = CollisionProfile->ReturnChannelNameFromContainerIndex(ChannelIndex); if (ImGui::Checkbox(TCHAR_TO_ANSI(*ChannelName.ToString()), &IsCollisionActive)) { if (IsCollisionActive) { - ObjectTypesToQuery |= ECC_TO_BITFIELD(ChannelIndex); - ProfileIndex = INDEX_NONE; + Config->ObjectTypesToQuery |= ECC_TO_BITFIELD(ChannelIndex); + Config->ProfileIndex = INDEX_NONE; } else { - ObjectTypesToQuery &= ~ECC_TO_BITFIELD(ChannelIndex); - ProfileIndex = INDEX_NONE; + Config->ObjectTypesToQuery &= ~ECC_TO_BITFIELD(ChannelIndex); + Config->ProfileIndex = INDEX_NONE; } } @@ -191,7 +189,7 @@ void UCogEngineWindow_Collisions::RenderContent() //------------------------------------------------- // Perform Query //------------------------------------------------- - if (ObjectTypesToQuery == 0) + if (Config->ObjectTypesToQuery == 0) { return; } @@ -200,7 +198,7 @@ void UCogEngineWindow_Collisions::RenderContent() FVector QueryEnd; float QueryRadius = 0.0f; - switch (QueryType) + switch (Config->QueryType) { case 0: { @@ -210,7 +208,7 @@ void UCogEngineWindow_Collisions::RenderContent() Location = Pawn->GetActorLocation(); } - QueryRadius = QueryDistance; + QueryRadius = Config->QueryDistance; QueryStart = Location; QueryEnd = QueryStart; break; @@ -222,8 +220,8 @@ void UCogEngineWindow_Collisions::RenderContent() FRotator Rotation; PlayerController->GetPlayerViewPoint(Location, Rotation); QueryStart = Location; - QueryEnd = QueryStart + Rotation.Vector() * QueryDistance; - QueryRadius = QueryThickness; + QueryEnd = QueryStart + Rotation.Vector() * Config->QueryDistance; + QueryRadius = Config->QueryThickness; break; } @@ -231,17 +229,17 @@ void UCogEngineWindow_Collisions::RenderContent() { FVector Direction; UGameplayStatics::DeprojectScreenToWorld(PlayerController, FCogImguiHelper::ToVector2D(ImGui::GetMousePos()), QueryStart, Direction); - QueryEnd = QueryStart + Direction * QueryDistance; - QueryRadius = QueryThickness; + QueryEnd = QueryStart + Direction * Config->QueryDistance; + QueryRadius = Config->QueryThickness; break; } } static const FName TraceTag(TEXT("FCogWindow_Collision")); - FCollisionQueryParams QueryParams(TraceTag, SCENE_QUERY_STAT_ONLY(CogHitDetection), UseComplexCollisions); + FCollisionQueryParams QueryParams(TraceTag, SCENE_QUERY_STAT_ONLY(CogHitDetection), Config->UseComplexCollisions); FCollisionObjectQueryParams QueryObjectParams; - QueryObjectParams.ObjectTypesToQuery = ObjectTypesToQuery; + QueryObjectParams.ObjectTypesToQuery = Config->ObjectTypesToQuery; FCollisionShape QueryShape; QueryShape.SetSphere(QueryRadius); @@ -257,7 +255,7 @@ void UCogEngineWindow_Collisions::RenderContent() QueryShape, QueryParams); - if (ShowQuery) + if (Config->ShowQuery) { FCogDebugDrawHelper::DrawCapsuleCastMulti(World, QueryStart, QueryEnd, FQuat::Identity, 0.0f, QueryRadius, EDrawDebugTrace::ForOneFrame, false, QueryHits, FLinearColor::White, FLinearColor::Red, FCogDebugSettings::GetDebugDuration(true)); } @@ -283,7 +281,7 @@ void UCogEngineWindow_Collisions::RenderContent() //------------------------------------------------------- // Draw Name //------------------------------------------------------- - if (ShowActorsNames) + if (Config->ShowActorsNames) { const AActor* Actor = HitResult.GetActor(); if (Actor != nullptr) @@ -386,7 +384,7 @@ void UCogEngineWindow_Collisions::RenderContent() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Collisions::SetAsset(const UCogEngineDataAsset* Value) +void FCogEngineWindow_Collisions::SetAsset(const UCogEngineDataAsset* Value) { Asset = Value; diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CommandBindings.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CommandBindings.cpp index 33d6523..b720bbb 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CommandBindings.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CommandBindings.cpp @@ -6,7 +6,7 @@ #include "imgui.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_CommandBindings::RenderHelp() +void FCogEngineWindow_CommandBindings::RenderHelp() { ImGui::Text( "This window can be used to configure the command bindings. " @@ -15,12 +15,7 @@ void UCogEngineWindow_CommandBindings::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -UCogEngineWindow_CommandBindings::UCogEngineWindow_CommandBindings() -{ -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_CommandBindings::RenderContent() +void FCogEngineWindow_CommandBindings::RenderContent() { Super::RenderContent(); @@ -64,7 +59,7 @@ void UCogEngineWindow_CommandBindings::RenderContent() "[F5] Cog.ToggleSelectionMode\n" )) { - Owner->RegisterDefaultCommands(); + GetOwner()->RegisterDefaultCommands(); } for (FKeyBind& KeyBind : PlayerInput->DebugExecBindings) diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp index f414d25..f9d977d 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp @@ -4,7 +4,7 @@ #include "CogWindowWidgets.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_DebugSettings::RenderHelp() +void FCogEngineWindow_DebugSettings::RenderHelp() { ImGui::Text( "This window can be used to tweak how the debug display is drawn. " @@ -13,79 +13,63 @@ void UCogEngineWindow_DebugSettings::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_DebugSettings::ResetConfig() +void FCogEngineWindow_DebugSettings::Initialize() +{ + Super::Initialize(); + + bHasMenu = true; + + Config = GetConfig(); + + FCogDebugSettings::Persistent = Config->Persistent; + FCogDebugSettings::TextShadow = Config->TextShadow; + FCogDebugSettings::Fade2D = Config->Fade2D; + FCogDebugSettings::Duration = Config->Duration; + FCogDebugSettings::DepthPriority = Config->DepthPriority; + FCogDebugSettings::Segments = Config->Segments; + FCogDebugSettings::Thickness = Config->Thickness; + FCogDebugSettings::ServerThickness = Config->ServerThickness; + FCogDebugSettings::ServerColorMultiplier = Config->ServerColorMultiplier; + FCogDebugSettings::ArrowSize = Config->ArrowSize; + FCogDebugSettings::AxesScale = Config->AxesScale; + FCogDebugSettings::GradientColorIntensity = Config->GradientColorIntensity; + FCogDebugSettings::GradientColorSpeed = Config->GradientColorSpeed; + FCogDebugSettings::TextSize = Config->TextSize; + + FCogDebugSettings::SetIsFilteringBySelection(GetWorld(), Config->bIsFilteringBySelection); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogEngineWindow_DebugSettings::ResetConfig() { Super::ResetConfig(); - bIsFilteringBySelection = true; - Persistent = false; - TextShadow = true; - Fade2D = true; - Duration = 3.0f; - DepthPriority = 0; - Segments = 12; - Thickness = 0.0f; - ServerThickness = 2.0f; - ServerColorMultiplier = 0.8f; - ArrowSize = 10.0f; - AxesScale = 1.0f; - GradientColorIntensity = 0.0f; - GradientColorSpeed = 2.0f; - TextSize = 1.0f; + Config->Reset(); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_DebugSettings::PostInitProperties() -{ - Super::PostInitProperties(); - - FCogDebugSettings::Persistent = Persistent; - FCogDebugSettings::TextShadow = TextShadow; - FCogDebugSettings::Fade2D = Fade2D; - FCogDebugSettings::Duration = Duration; - FCogDebugSettings::DepthPriority = DepthPriority; - FCogDebugSettings::Segments = Segments; - FCogDebugSettings::Thickness = Thickness; - FCogDebugSettings::ServerThickness = ServerThickness; - FCogDebugSettings::ServerColorMultiplier = ServerColorMultiplier; - FCogDebugSettings::ArrowSize = ArrowSize; - FCogDebugSettings::AxesScale = AxesScale; - FCogDebugSettings::GradientColorIntensity = GradientColorIntensity; - FCogDebugSettings::GradientColorSpeed = GradientColorSpeed; - FCogDebugSettings::TextSize = TextSize; - - FCogDebugSettings::SetIsFilteringBySelection(GetWorld(), bIsFilteringBySelection); -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_DebugSettings::PreSaveConfig() +void FCogEngineWindow_DebugSettings::PreSaveConfig() { Super::PreSaveConfig(); - Persistent = FCogDebugSettings::Persistent; - TextShadow = FCogDebugSettings::TextShadow; - Fade2D = FCogDebugSettings::Fade2D; - Duration = FCogDebugSettings::Duration; - DepthPriority = FCogDebugSettings::DepthPriority; - Segments = FCogDebugSettings::Segments; - Thickness = FCogDebugSettings::Thickness; - ServerThickness = FCogDebugSettings::ServerThickness; - ServerColorMultiplier = FCogDebugSettings::ServerColorMultiplier; - ArrowSize = FCogDebugSettings::ArrowSize; - AxesScale = FCogDebugSettings::AxesScale; - GradientColorIntensity = FCogDebugSettings::GradientColorIntensity; - GradientColorSpeed = FCogDebugSettings::GradientColorSpeed; - TextSize = FCogDebugSettings::TextSize; + Config->Persistent = FCogDebugSettings::Persistent; + Config->TextShadow = FCogDebugSettings::TextShadow; + Config->Fade2D = FCogDebugSettings::Fade2D; + Config->Duration = FCogDebugSettings::Duration; + Config->DepthPriority = FCogDebugSettings::DepthPriority; + Config->Segments = FCogDebugSettings::Segments; + Config->Thickness = FCogDebugSettings::Thickness; + Config->ServerThickness = FCogDebugSettings::ServerThickness; + Config->ServerColorMultiplier = FCogDebugSettings::ServerColorMultiplier; + Config->ArrowSize = FCogDebugSettings::ArrowSize; + Config->AxesScale = FCogDebugSettings::AxesScale; + Config->GradientColorIntensity = FCogDebugSettings::GradientColorIntensity; + Config->GradientColorSpeed = FCogDebugSettings::GradientColorSpeed; + Config->TextSize = FCogDebugSettings::TextSize; } //-------------------------------------------------------------------------------------------------------------------------- -UCogEngineWindow_DebugSettings::UCogEngineWindow_DebugSettings() -{ - bHasMenu = true; -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_DebugSettings::RenderContent() +void FCogEngineWindow_DebugSettings::RenderContent() { Super::RenderContent(); @@ -99,10 +83,10 @@ void UCogEngineWindow_DebugSettings::RenderContent() ImGui::EndMenuBar(); } - bIsFilteringBySelection = FCogDebugSettings::GetIsFilteringBySelection(); - if (ImGui::Checkbox("Filter by selection", &bIsFilteringBySelection)) + Config->bIsFilteringBySelection = FCogDebugSettings::GetIsFilteringBySelection(); + if (ImGui::Checkbox("Filter by selection", &Config->bIsFilteringBySelection)) { - FCogDebugSettings::SetIsFilteringBySelection(GetWorld(), bIsFilteringBySelection); + FCogDebugSettings::SetIsFilteringBySelection(GetWorld(), Config->bIsFilteringBySelection); } if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) { diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_ImGui.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_ImGui.cpp index 5b08863..b002151 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_ImGui.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_ImGui.cpp @@ -4,12 +4,7 @@ #include "implot.h" //-------------------------------------------------------------------------------------------------------------------------- -UCogEngineWindow_ImGui::UCogEngineWindow_ImGui() -{ -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_ImGui::RenderTick(float DeltaTime) +void FCogEngineWindow_ImGui::RenderTick(float DeltaTime) { Super::RenderTick(DeltaTime); @@ -42,7 +37,7 @@ void UCogEngineWindow_ImGui::RenderTick(float DeltaTime) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_ImGui::RenderContent() +void FCogEngineWindow_ImGui::RenderContent() { Super::RenderContent(); diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Inspector.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Inspector.cpp index 9c28674..ff38308 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Inspector.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Inspector.cpp @@ -9,7 +9,17 @@ #include "UObject/UnrealType.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Inspector::RenderHelp() +void FCogEngineWindow_Inspector::Initialize() +{ + Super::Initialize(); + + bHasMenu = true; + + Config = GetConfig(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogEngineWindow_Inspector::RenderHelp() { ImGui::Text( "This window can be used to inspect the properties of a UObject. " @@ -17,13 +27,7 @@ void UCogEngineWindow_Inspector::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -UCogEngineWindow_Inspector::UCogEngineWindow_Inspector() -{ - bHasMenu = true; -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Inspector::SetInspectedObject(UObject* Value) +void FCogEngineWindow_Inspector::SetInspectedObject(UObject* Value) { if (InspectedObject == Value) { @@ -34,7 +38,7 @@ void UCogEngineWindow_Inspector::SetInspectedObject(UObject* Value) if (InspectedObject != GetSelection()) { - bSyncWithSelection = false; + Config->bSyncWithSelection = false; } if (HistoryIndex != History.Num() - 1) @@ -51,14 +55,14 @@ void UCogEngineWindow_Inspector::SetInspectedObject(UObject* Value) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Inspector::AddFavorite(UObject* Object) +void FCogEngineWindow_Inspector::AddFavorite(UObject* Object) { Favorite& Favorite = Favorites.AddDefaulted_GetRef(); Favorite.Object = Object; } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Inspector::AddFavorite(UObject* Object, FCogEngineInspectorApplyFunction ApplyFunction) +void FCogEngineWindow_Inspector::AddFavorite(UObject* Object, FCogEngineInspectorApplyFunction ApplyFunction) { Favorite& Favorite = Favorites.AddDefaulted_GetRef(); Favorite.Object = Object; @@ -66,7 +70,7 @@ void UCogEngineWindow_Inspector::AddFavorite(UObject* Object, FCogEngineInspecto } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Inspector::RenderContent() +void FCogEngineWindow_Inspector::RenderContent() { Super::RenderContent(); @@ -76,7 +80,7 @@ void UCogEngineWindow_Inspector::RenderContent() // Objects to inspect Combo //-------------------------- - if (bSyncWithSelection || InspectedObject == nullptr) + if (Config->bSyncWithSelection || InspectedObject == nullptr) { SetInspectedObject(GetSelection()); } @@ -104,7 +108,7 @@ void UCogEngineWindow_Inspector::RenderContent() } //-------------------------------------------------------------------------------------------------------------------------- -FCogEngineInspectorApplyFunction UCogEngineWindow_Inspector::FindObjectApplyFunction(const UObject* Object) const +FCogEngineInspectorApplyFunction FCogEngineWindow_Inspector::FindObjectApplyFunction(const UObject* Object) const { for (const Favorite& Favorite : Favorites) { @@ -118,7 +122,7 @@ FCogEngineInspectorApplyFunction UCogEngineWindow_Inspector::FindObjectApplyFunc } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Inspector::RenderMenu() +void FCogEngineWindow_Inspector::RenderMenu() { bCollapseAllCategories = false; bExpandAllCategories = false; @@ -239,7 +243,7 @@ void UCogEngineWindow_Inspector::RenderMenu() { HistoryIndex = NewHistoryIndex; InspectedObject = History[HistoryIndex]; - bSyncWithSelection = false; + Config->bSyncWithSelection = false; } } @@ -253,7 +257,7 @@ void UCogEngineWindow_Inspector::RenderMenu() //----------------------------------- if (ImGui::BeginMenu("Options")) { - ImGui::Checkbox("Sync With Selection", &bSyncWithSelection); + ImGui::Checkbox("Sync With Selection", &Config->bSyncWithSelection); if (ImGui::IsItemHovered()) { ImGui::SetTooltip("Should the inspector be synced with the actor selection ?"); @@ -261,19 +265,19 @@ void UCogEngineWindow_Inspector::RenderMenu() ImGui::Separator(); - ImGui::Checkbox("Sort by name", &bSortByName); - ImGui::Checkbox("Show background", &bShowRowBackground); - ImGui::Checkbox("Show borders", &bShowBorders); + ImGui::Checkbox("Sort by name", &Config->bSortByName); + ImGui::Checkbox("Show background", &Config->bShowRowBackground); + ImGui::Checkbox("Show borders", &Config->bShowBorders); #if WITH_EDITORONLY_DATA - ImGui::Checkbox("Show display name", &bShowDisplayName); - ImGui::Checkbox("Show categories", &bShowCategories); + ImGui::Checkbox("Show display name", &Config->bShowDisplayName); + ImGui::Checkbox("Show categories", &Config->bShowCategories); ImGui::Separator(); - if (ImGui::MenuItem("Collapse all categories", nullptr, false, bShowCategories)) + if (ImGui::MenuItem("Collapse all categories", nullptr, false, Config->bShowCategories)) { bCollapseAllCategories = true; } - if (ImGui::MenuItem("Expand all categories", nullptr, false, bShowCategories)) + if (ImGui::MenuItem("Expand all categories", nullptr, false, Config->bShowCategories)) { bExpandAllCategories = true; } @@ -287,7 +291,7 @@ void UCogEngineWindow_Inspector::RenderMenu() } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::RenderInspector() +bool FCogEngineWindow_Inspector::RenderInspector() { const UObject* Object = GetInspectedObject(); if (Object == nullptr) @@ -315,7 +319,7 @@ bool UCogEngineWindow_Inspector::RenderInspector() // Render properties with categories //---------------------------------------------------------------------- - if ((bShowCategories) != 0) + if ((Config->bShowCategories) != 0) { IsPropertyGridRendered = true; @@ -369,12 +373,12 @@ bool UCogEngineWindow_Inspector::RenderInspector() } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::RenderBegin() +bool FCogEngineWindow_Inspector::RenderBegin() { FCogWindowWidgets::PushStyleCompact(); ImGuiTableFlags TableFlags = ImGuiTableFlags_Resizable; - if ((bShowBorders) != 0) + if ((Config->bShowBorders) != 0) { TableFlags |= ImGuiTableFlags_Borders; } @@ -383,7 +387,7 @@ bool UCogEngineWindow_Inspector::RenderBegin() TableFlags |= ImGuiTableFlags_NoBordersInBodyUntilResize; } - if ((bShowRowBackground) != 0) + if ((Config->bShowRowBackground) != 0) { TableFlags |= ImGuiTableFlags_RowBg; } @@ -399,18 +403,18 @@ bool UCogEngineWindow_Inspector::RenderBegin() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Inspector::RenderEnd() +void FCogEngineWindow_Inspector::RenderEnd() { ImGui::EndTable(); FCogWindowWidgets::PopStyleCompact(); } //-------------------------------------------------------------------------------------------------------------------------- -FString UCogEngineWindow_Inspector::GetPropertyName(const FProperty& Property) +FString FCogEngineWindow_Inspector::GetPropertyName(const FProperty& Property) { #if WITH_EDITORONLY_DATA - if (bShowDisplayName && Property.GetDisplayNameText().IsEmpty() == false) + if (Config->bShowDisplayName && Property.GetDisplayNameText().IsEmpty() == false) { return Property.GetDisplayNameText().ToString(); } @@ -425,9 +429,9 @@ FString UCogEngineWindow_Inspector::GetPropertyName(const FProperty& Property) } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::RenderPropertyList(TArray& Properties, uint8* PointerToValue) +bool FCogEngineWindow_Inspector::RenderPropertyList(TArray& Properties, uint8* PointerToValue) { - if (bSortByName) + if (Config->bSortByName) { Properties.Sort([this](const FProperty& Lhs, const FProperty& Rhs) { return GetPropertyName(Lhs) < GetPropertyName(Rhs); }); } @@ -446,7 +450,7 @@ bool UCogEngineWindow_Inspector::RenderPropertyList(TArray& Pr } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::RenderProperty(const FProperty* Property, uint8* PointerToValue, int IndexInArray) +bool FCogEngineWindow_Inspector::RenderProperty(const FProperty* Property, uint8* PointerToValue, int IndexInArray) { bool HasChanged = false; @@ -647,7 +651,7 @@ bool UCogEngineWindow_Inspector::RenderProperty(const FProperty* Property, uint8 } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::RenderBool(const FBoolProperty* BoolProperty, uint8* PointerToValue) +bool FCogEngineWindow_Inspector::RenderBool(const FBoolProperty* BoolProperty, uint8* PointerToValue) { bool HasChanged = false; @@ -662,7 +666,7 @@ bool UCogEngineWindow_Inspector::RenderBool(const FBoolProperty* BoolProperty, u } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::RenderByte(const FByteProperty* ByteProperty, uint8* PointerToValue) +bool FCogEngineWindow_Inspector::RenderByte(const FByteProperty* ByteProperty, uint8* PointerToValue) { bool HasChanged = false; @@ -677,7 +681,7 @@ bool UCogEngineWindow_Inspector::RenderByte(const FByteProperty* ByteProperty, u } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::RenderInt8(const FInt8Property* Int8Property, uint8* PointerToValue) +bool FCogEngineWindow_Inspector::RenderInt8(const FInt8Property* Int8Property, uint8* PointerToValue) { bool HasChanged = false; @@ -692,7 +696,7 @@ bool UCogEngineWindow_Inspector::RenderInt8(const FInt8Property* Int8Property, u } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::RenderInt(const FIntProperty* IntProperty, uint8* PointerToValue) +bool FCogEngineWindow_Inspector::RenderInt(const FIntProperty* IntProperty, uint8* PointerToValue) { bool HasChanged = false; @@ -707,7 +711,7 @@ bool UCogEngineWindow_Inspector::RenderInt(const FIntProperty* IntProperty, uint } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::RenderInt64(const FInt64Property* Int64Property, uint8* PointerToValue) +bool FCogEngineWindow_Inspector::RenderInt64(const FInt64Property* Int64Property, uint8* PointerToValue) { bool HasChanged = false; @@ -722,7 +726,7 @@ bool UCogEngineWindow_Inspector::RenderInt64(const FInt64Property* Int64Property } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::RenderUInt32(const FUInt32Property* UInt32Property, uint8* PointerToValue) +bool FCogEngineWindow_Inspector::RenderUInt32(const FUInt32Property* UInt32Property, uint8* PointerToValue) { bool HasChanged = false; @@ -737,7 +741,7 @@ bool UCogEngineWindow_Inspector::RenderUInt32(const FUInt32Property* UInt32Prope } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::RenderFloat(const FFloatProperty* FloatProperty, uint8* PointerToValue) +bool FCogEngineWindow_Inspector::RenderFloat(const FFloatProperty* FloatProperty, uint8* PointerToValue) { bool HasChanged = false; @@ -752,7 +756,7 @@ bool UCogEngineWindow_Inspector::RenderFloat(const FFloatProperty* FloatProperty } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::RenderDouble(const FDoubleProperty* DoubleProperty, uint8* PointerToValue) +bool FCogEngineWindow_Inspector::RenderDouble(const FDoubleProperty* DoubleProperty, uint8* PointerToValue) { bool HasChanged = false; @@ -767,13 +771,13 @@ bool UCogEngineWindow_Inspector::RenderDouble(const FDoubleProperty* DoublePrope } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::RenderEnum(const FEnumProperty* EnumProperty, uint8* PointerToValue) +bool FCogEngineWindow_Inspector::RenderEnum(const FEnumProperty* EnumProperty, uint8* PointerToValue) { return FCogWindowWidgets::ComboboxEnum("##Enum", EnumProperty, PointerToValue); } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::RenderString(const FStrProperty* StrProperty, uint8* PointerToValue) +bool FCogEngineWindow_Inspector::RenderString(const FStrProperty* StrProperty, uint8* PointerToValue) { FString Text; StrProperty->ExportTextItem_Direct(Text, PointerToValue, nullptr, nullptr, PPF_None, nullptr); @@ -792,7 +796,7 @@ bool UCogEngineWindow_Inspector::RenderString(const FStrProperty* StrProperty, u } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::RenderName(const FNameProperty* NameProperty, uint8* PointerToValue) +bool FCogEngineWindow_Inspector::RenderName(const FNameProperty* NameProperty, uint8* PointerToValue) { FString NameValue; NameProperty->ExportTextItem_Direct(NameValue, PointerToValue, nullptr, nullptr, PPF_None, nullptr); @@ -804,7 +808,7 @@ bool UCogEngineWindow_Inspector::RenderName(const FNameProperty* NameProperty, u } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::RenderText(const FTextProperty* TextProperty, uint8* PointerToValue) +bool FCogEngineWindow_Inspector::RenderText(const FTextProperty* TextProperty, uint8* PointerToValue) { FString Text; TextProperty->ExportTextItem_Direct(Text, PointerToValue, nullptr, nullptr, PPF_None, nullptr); @@ -816,7 +820,7 @@ bool UCogEngineWindow_Inspector::RenderText(const FTextProperty* TextProperty, u } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::RenderObject(UObject* Object, bool ShowChildren) +bool FCogEngineWindow_Inspector::RenderObject(UObject* Object, bool ShowChildren) { if (Object == nullptr) { @@ -856,7 +860,7 @@ bool UCogEngineWindow_Inspector::RenderObject(UObject* Object, bool ShowChildren } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::RenderStruct(const FStructProperty* StructProperty, uint8* PointerToValue, bool ShowChildren) +bool FCogEngineWindow_Inspector::RenderStruct(const FStructProperty* StructProperty, uint8* PointerToValue, bool ShowChildren) { ImGui::BeginDisabled(); ImGui::Text("%s", TCHAR_TO_ANSI(*StructProperty->Struct->GetClass()->GetName())); @@ -881,7 +885,7 @@ bool UCogEngineWindow_Inspector::RenderStruct(const FStructProperty* StructPrope } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::RenderClass(const FClassProperty* ClassProperty) +bool FCogEngineWindow_Inspector::RenderClass(const FClassProperty* ClassProperty) { if (ClassProperty->MetaClass == nullptr) { @@ -900,7 +904,7 @@ bool UCogEngineWindow_Inspector::RenderClass(const FClassProperty* ClassProperty } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::RenderInterface(const FInterfaceProperty* InterfaceProperty) +bool FCogEngineWindow_Inspector::RenderInterface(const FInterfaceProperty* InterfaceProperty) { UClass* Class = InterfaceProperty->InterfaceClass; if (Class == nullptr) @@ -920,7 +924,7 @@ bool UCogEngineWindow_Inspector::RenderInterface(const FInterfaceProperty* Inter } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::RenderArray(const FArrayProperty* ArrayProperty, uint8* PointerToValue, bool ShowChildren) +bool FCogEngineWindow_Inspector::RenderArray(const FArrayProperty* ArrayProperty, uint8* PointerToValue, bool ShowChildren) { FScriptArrayHelper Helper(ArrayProperty, PointerToValue); int32 Num = Helper.Num(); @@ -946,7 +950,7 @@ bool UCogEngineWindow_Inspector::RenderArray(const FArrayProperty* ArrayProperty } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Inspector::HasPropertyAnyChildren(const FProperty* Property, uint8* PointerToValue) +bool FCogEngineWindow_Inspector::HasPropertyAnyChildren(const FProperty* Property, uint8* PointerToValue) { if (const FStructProperty* StructProperty = CastField(Property)) { diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_LogCategories.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_LogCategories.cpp index 55b01a5..89eab00 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_LogCategories.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_LogCategories.cpp @@ -6,7 +6,15 @@ #include "CogDebugLog.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_LogCategories::RenderHelp() +void FCogEngineWindow_LogCategories::Initialize() +{ + Super::Initialize(); + + bHasMenu = true; +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogEngineWindow_LogCategories::RenderHelp() { ImGui::Text( "This window can be used to activate and deactivate log categories." @@ -19,13 +27,7 @@ void UCogEngineWindow_LogCategories::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -UCogEngineWindow_LogCategories::UCogEngineWindow_LogCategories() -{ - bHasMenu = true; -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_LogCategories::ResetConfig() +void FCogEngineWindow_LogCategories::ResetConfig() { Super::ResetConfig(); @@ -33,7 +35,7 @@ void UCogEngineWindow_LogCategories::ResetConfig() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_LogCategories::RenderContent() +void FCogEngineWindow_LogCategories::RenderContent() { Super::RenderContent(); diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp index fed02b7..173d4c8 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp @@ -6,7 +6,20 @@ #include "imgui.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Metrics::RenderHelp() +void FCogEngineWindow_Metrics::Initialize() +{ + Super::Initialize(); + + bHasMenu = true; + + Config = GetConfig(); + + FCogDebugMetric::MaxDurationSetting = Config->MaxDurationSetting; + FCogDebugMetric::RestartDelaySetting = Config->RestartDelaySetting; +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogEngineWindow_Metrics::RenderHelp() { ImGui::Text( "This window gather events generated by the selected actor to compute how much output it produces or receives per second. " @@ -15,41 +28,24 @@ void UCogEngineWindow_Metrics::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Metrics::ResetConfig() +void FCogEngineWindow_Metrics::ResetConfig() { Super::ResetConfig(); - MaxDurationSetting = 0.0f; - RestartDelaySetting = 5.0f; - PostInitProperties(); + Config->Reset(); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Metrics::PostInitProperties() -{ - Super::PostInitProperties(); - - FCogDebugMetric::MaxDurationSetting = MaxDurationSetting; - FCogDebugMetric::RestartDelaySetting = RestartDelaySetting; -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Metrics::PreSaveConfig() +void FCogEngineWindow_Metrics::PreSaveConfig() { Super::PreSaveConfig(); - MaxDurationSetting = FCogDebugMetric::MaxDurationSetting; - RestartDelaySetting = FCogDebugMetric::RestartDelaySetting; + Config->MaxDurationSetting = FCogDebugMetric::MaxDurationSetting; + Config->RestartDelaySetting = FCogDebugMetric::RestartDelaySetting; } //-------------------------------------------------------------------------------------------------------------------------- -UCogEngineWindow_Metrics::UCogEngineWindow_Metrics() -{ - bHasMenu = true; -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Metrics::RenderTick(float DeltaTime) +void FCogEngineWindow_Metrics::RenderTick(float DeltaTime) { Super::RenderTick(DeltaTime); FCogDebugMetric::IsVisible = GetIsVisible(); @@ -58,7 +54,7 @@ void UCogEngineWindow_Metrics::RenderTick(float DeltaTime) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Metrics::RenderContent() +void FCogEngineWindow_Metrics::RenderContent() { Super::RenderContent(); @@ -112,7 +108,7 @@ void UCogEngineWindow_Metrics::RenderContent() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Metrics::DrawMetric(FCogDebugMetricEntry& Metric) +void FCogEngineWindow_Metrics::DrawMetric(FCogDebugMetricEntry& Metric) { FCogWindowWidgets::PushBackColor(ImVec4(0.8f, 0.8f, 0.8f, 1.0f)); @@ -164,7 +160,7 @@ void UCogEngineWindow_Metrics::DrawMetric(FCogDebugMetricEntry& Metric) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Metrics::DrawMetricRow(const char* RowTitle, float MitigatedValue, float UnmitigatedValue, const ImVec4& Color) +void FCogEngineWindow_Metrics::DrawMetricRow(const char* RowTitle, float MitigatedValue, float UnmitigatedValue, const ImVec4& Color) { ImGui::TableNextRow(); ImGui::TableNextColumn(); diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_NetEmulation.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_NetEmulation.cpp index b63e7ca..8e7c95c 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_NetEmulation.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_NetEmulation.cpp @@ -9,13 +9,13 @@ #include "GameFramework/PlayerState.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_NetEmulation::RenderHelp() +void FCogEngineWindow_NetEmulation::RenderHelp() { ImGui::Text("This window is used to configure the network emulation."); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_NetEmulation::RenderContent() +void FCogEngineWindow_NetEmulation::RenderContent() { Super::RenderContent(); @@ -27,7 +27,7 @@ void UCogEngineWindow_NetEmulation::RenderContent() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_NetEmulation::DrawStats() +void FCogEngineWindow_NetEmulation::DrawStats() { const APlayerController* PlayerController = GetLocalPlayerController(); if (PlayerController == nullptr) @@ -40,7 +40,7 @@ void UCogEngineWindow_NetEmulation::DrawStats() const float Ping = PlayerState->GetPingInMilliseconds(); ImGui::Text("Ping "); ImGui::SameLine(); - ImGui::TextColored(UCogEngineWindow_Stats::GetPingColor(Ping), "%0.0fms", Ping); + ImGui::TextColored(FCogEngineWindow_Stats::GetPingColor(Ping), "%0.0fms", Ping); } if (UNetConnection* Connection = PlayerController->GetNetConnection()) @@ -48,17 +48,17 @@ void UCogEngineWindow_NetEmulation::DrawStats() const float OutPacketLost = Connection->GetOutLossPercentage().GetAvgLossPercentage() * 100.0f; ImGui::Text("Packet Loss Out "); ImGui::SameLine(); - ImGui::TextColored(UCogEngineWindow_Stats::GetPacketLossColor(OutPacketLost), "%0.0f%%", OutPacketLost); + ImGui::TextColored(FCogEngineWindow_Stats::GetPacketLossColor(OutPacketLost), "%0.0f%%", OutPacketLost); const float InPacketLost = Connection->GetInLossPercentage().GetAvgLossPercentage() * 100.0f; ImGui::Text("Packet Loss In "); ImGui::SameLine(); - ImGui::TextColored(UCogEngineWindow_Stats::GetPacketLossColor(InPacketLost), "%0.0f%%", InPacketLost); + ImGui::TextColored(FCogEngineWindow_Stats::GetPacketLossColor(InPacketLost), "%0.0f%%", InPacketLost); } } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_NetEmulation::DrawControls() +void FCogEngineWindow_NetEmulation::DrawControls() { FWorldContext& WorldContext = GEngine->GetWorldContextFromWorldChecked(GetWorld()); diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_OutputLog.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_OutputLog.cpp index a04b59e..5ee702e 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_OutputLog.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_OutputLog.cpp @@ -8,43 +8,44 @@ char ImGuiTextBuffer::EmptyString[1] = { 0 }; //-------------------------------------------------------------------------------------------------------------------------- -// FCogWindow_Log +// UCogEngineWindow_OutputLog //-------------------------------------------------------------------------------------------------------------------------- -UCogEngineWindow_OutputLog::UCogEngineWindow_OutputLog() -{ +void FCogEngineWindow_OutputLog::Initialize() +{ + Super::Initialize(); + bHasMenu = true; OutputDevice.OutputLog = this; + + Config = GetConfig(); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_OutputLog::RenderHelp() +void FCogEngineWindow_OutputLog::RenderHelp() { ImGui::Text( "This window output the log based on each log categories verbosity. " "The verbosity of each log category can be configured in the 'Log Categories' window. " ); } + //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_OutputLog::ResetConfig() +void FCogEngineWindow_OutputLog::ResetConfig() { Super::ResetConfig(); - AutoScroll = true; - ShowFrame = true; - ShowCategory = true; - ShowVerbosity = false; - ShowAsTable = false; + Config->Reset(); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_OutputLog::Clear() +void FCogEngineWindow_OutputLog::Clear() { TextBuffer.clear(); LineInfos.Empty(); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_OutputLog::AddLog(const TCHAR* Message, ELogVerbosity::Type Verbosity, const class FName& Category) +void FCogEngineWindow_OutputLog::AddLog(const TCHAR* Message, ELogVerbosity::Type Verbosity, const class FName& Category) { static TAnsiStringBuilder<512> Format; @@ -68,7 +69,7 @@ void UCogEngineWindow_OutputLog::AddLog(const TCHAR* Message, ELogVerbosity::Typ } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_OutputLog::DrawRow(const char* BufferStart, const FLineInfo& LineInfo, bool IsTableShown) +void FCogEngineWindow_OutputLog::DrawRow(const char* BufferStart, const FLineInfo& LineInfo, bool IsTableShown) { ImU32 Color; switch (LineInfo.Verbosity) @@ -84,19 +85,19 @@ void UCogEngineWindow_OutputLog::DrawRow(const char* BufferStart, const FLineInf { ImGui::TableNextRow(); - if (ShowFrame) + if (Config->ShowFrame) { ImGui::TableNextColumn(); ImGui::Text("%3d", LineInfo.Frame); } - if (ShowCategory) + if (Config->ShowCategory) { ImGui::TableNextColumn(); ImGui::Text("%s", TCHAR_TO_ANSI(*LineInfo.Category.ToString())); } - if (ShowVerbosity) + if (Config->ShowVerbosity) { ImGui::TableNextColumn(); ImGui::Text("%s", TCHAR_TO_ANSI(ToString(LineInfo.Verbosity))); @@ -109,19 +110,19 @@ void UCogEngineWindow_OutputLog::DrawRow(const char* BufferStart, const FLineInf } else { - if (ShowFrame) + if (Config->ShowFrame) { ImGui::Text("[%3d] ", LineInfo.Frame); ImGui::SameLine(); } - if (ShowCategory) + if (Config->ShowCategory) { ImGui::Text("%s: ", TCHAR_TO_ANSI(*LineInfo.Category.ToString())); ImGui::SameLine(); } - if (ShowVerbosity) + if (Config->ShowVerbosity) { ImGui::Text("%s: ", TCHAR_TO_ANSI(ToString(LineInfo.Verbosity))); ImGui::SameLine(); @@ -136,7 +137,7 @@ void UCogEngineWindow_OutputLog::DrawRow(const char* BufferStart, const FLineInf } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_OutputLog::RenderContent() +void FCogEngineWindow_OutputLog::RenderContent() { Super::RenderContent(); @@ -153,11 +154,11 @@ void UCogEngineWindow_OutputLog::RenderContent() } ImGui::Separator(); - ImGui::Checkbox("Auto Scroll", &AutoScroll); - ImGui::Checkbox("Show Frame", &ShowFrame); - ImGui::Checkbox("Show Category", &ShowCategory); - ImGui::Checkbox("Show Verbosity", &ShowVerbosity); - ImGui::Checkbox("Show As Table", &ShowAsTable); + ImGui::Checkbox("Auto Scroll", &Config->AutoScroll); + ImGui::Checkbox("Show Frame", &Config->ShowFrame); + ImGui::Checkbox("Show Category", &Config->ShowCategory); + ImGui::Checkbox("Show Verbosity", &Config->ShowVerbosity); + ImGui::Checkbox("Show As Table", &Config->ShowAsTable); ImGui::EndMenu(); } @@ -172,16 +173,16 @@ void UCogEngineWindow_OutputLog::RenderContent() ImGui::SameLine(); ImGui::SetNextItemWidth(ImGui::GetFontSize() * 9); - if (ImGui::BeginCombo("##Verbosity", FCogDebugHelper::VerbosityToString((ELogVerbosity::Type)VerbosityFilter))) + if (ImGui::BeginCombo("##Verbosity", FCogDebugHelper::VerbosityToString((ELogVerbosity::Type)Config->VerbosityFilter))) { for (int32 i = (int32)ELogVerbosity::Error; i <= (int32)ELogVerbosity::VeryVerbose; ++i) { - bool IsSelected = i == VerbosityFilter; + bool IsSelected = i == Config->VerbosityFilter; ELogVerbosity::Type Verbosity = (ELogVerbosity::Type)i; if (ImGui::Selectable(FCogDebugHelper::VerbosityToString(Verbosity), IsSelected)) { - VerbosityFilter = i; + Config->VerbosityFilter = i; } } ImGui::EndCombo(); @@ -193,27 +194,27 @@ void UCogEngineWindow_OutputLog::RenderContent() } int32 ColumnCount = 1; - ColumnCount += (int32)ShowFrame; - ColumnCount += (int32)ShowCategory; - ColumnCount += (int32)ShowVerbosity; + ColumnCount += (int32)Config->ShowFrame; + ColumnCount += (int32)Config->ShowCategory; + ColumnCount += (int32)Config->ShowVerbosity; bool IsTableShown = false; - if (ShowAsTable) + if (Config->ShowAsTable) { if (ImGui::BeginTable("LogTable", ColumnCount, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ScrollX)) { IsTableShown = true; - if (ShowFrame) + if (Config->ShowFrame) { ImGui::TableSetupColumn("Frame", ImGuiTableColumnFlags_WidthFixed, FCogWindowWidgets::GetFontWidth() * 4); } - if (ShowCategory) + if (Config->ShowCategory) { ImGui::TableSetupColumn("Category", ImGuiTableColumnFlags_WidthFixed, FCogWindowWidgets::GetFontWidth() * 10); } - if (ShowVerbosity) + if (Config->ShowVerbosity) { ImGui::TableSetupColumn("Verbosity", ImGuiTableColumnFlags_WidthFixed, FCogWindowWidgets::GetFontWidth() * 10); } @@ -242,13 +243,13 @@ void UCogEngineWindow_OutputLog::RenderContent() } } } - else if (VerbosityFilter != ELogVerbosity::VeryVerbose) + else if (Config->VerbosityFilter != ELogVerbosity::VeryVerbose) { for (int32 LineIndex = 0; LineIndex < LineInfos.Num(); LineIndex++) { const FLineInfo& LineInfo = LineInfos[LineIndex]; - if (LineInfo.Verbosity <= (ELogVerbosity::Type)VerbosityFilter) + if (LineInfo.Verbosity <= (ELogVerbosity::Type)Config->VerbosityFilter) { const char* LineStart = BufferStart + LineInfo.Start; const char* LineEnd = BufferStart + LineInfo.End; @@ -274,7 +275,7 @@ void UCogEngineWindow_OutputLog::RenderContent() Clipper.End(); } - if (AutoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) + if (Config->AutoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) { ImGui::SetScrollHereY(1.0f); } @@ -302,13 +303,13 @@ void UCogEngineWindow_OutputLog::RenderContent() //-------------------------------------------------------------------------------------------------------------------------- // FCogLogOutputDevice //-------------------------------------------------------------------------------------------------------------------------- -UCogLogOutputDevice::UCogLogOutputDevice() +FCogLogOutputDevice::FCogLogOutputDevice() { GLog->AddOutputDevice(this); } //-------------------------------------------------------------------------------------------------------------------------- -UCogLogOutputDevice::~UCogLogOutputDevice() +FCogLogOutputDevice::~FCogLogOutputDevice() { if (GLog != nullptr) { @@ -317,7 +318,7 @@ UCogLogOutputDevice::~UCogLogOutputDevice() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogLogOutputDevice::Serialize(const TCHAR* Message, ELogVerbosity::Type Verbosity, const class FName& Category) +void FCogLogOutputDevice::Serialize(const TCHAR* Message, ELogVerbosity::Type Verbosity, const class FName& Category) { if (OutputLog != nullptr) { diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp index 33f68f8..5030fb5 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp @@ -8,7 +8,7 @@ #include "Kismet/GameplayStatics.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Plots::RenderHelp() +void FCogEngineWindow_Plots::RenderHelp() { ImGui::Text( "This window plots values overtime. When applicable, only the values of the selected actor are displayed." @@ -16,14 +16,14 @@ void UCogEngineWindow_Plots::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Plots::RenderTick(float DeltaTime) +void FCogEngineWindow_Plots::RenderTick(float DeltaTime) { Super::RenderTick(DeltaTime); FCogDebugPlot::IsVisible = GetIsVisible(); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Plots::RenderContent() +void FCogEngineWindow_Plots::RenderContent() { Super::RenderContent(); diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Scalability.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Scalability.cpp index f2c6dc2..af30e32 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Scalability.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Scalability.cpp @@ -10,7 +10,7 @@ //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Scalability::RenderHelp() +void FCogEngineWindow_Scalability::RenderHelp() { ImGui::Text( "This window can be used to configure the rendering quality." @@ -18,7 +18,7 @@ void UCogEngineWindow_Scalability::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Scalability::RenderContent() +void FCogEngineWindow_Scalability::RenderContent() { Super::RenderContent(); diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Selection.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Selection.cpp index 8b203b5..bb39480 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Selection.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Selection.cpp @@ -13,10 +13,29 @@ #include "imgui.h" #include "Kismet/GameplayStatics.h" -FString UCogEngineWindow_Selection::ToggleSelectionModeCommand = TEXT("Cog.ToggleSelectionMode"); +FString FCogEngineWindow_Selection::ToggleSelectionModeCommand = TEXT("Cog.ToggleSelectionMode"); //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Selection::RenderHelp() +void FCogEngineWindow_Selection::Initialize() +{ + Super::Initialize(); + + bHasMenu = true; + ActorClasses = { AActor::StaticClass(), ACharacter::StaticClass() }; + + Config = GetConfig(); + + ConsoleCommands.Add(IConsoleManager::Get().RegisterConsoleCommand( + *ToggleSelectionModeCommand, + TEXT("Toggle the actor selection mode"), + FConsoleCommandWithArgsDelegate::CreateLambda([this](const TArray& Args) { ToggleSelectionMode(); }), + ECVF_Cheat)); + + TryReapplySelection(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogEngineWindow_Selection::RenderHelp() { ImGui::Text( "This window can be used to select an actor either by picking an actor in the world, " @@ -27,51 +46,32 @@ void UCogEngineWindow_Selection::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -UCogEngineWindow_Selection::UCogEngineWindow_Selection() +void FCogEngineWindow_Selection::Shutdown() { - bHasMenu = true; - ActorClasses = { AActor::StaticClass(), ACharacter::StaticClass() }; - - ConsoleCommands.Add(IConsoleManager::Get().RegisterConsoleCommand( - *ToggleSelectionModeCommand, - TEXT("Toggle the actor selection mode"), - FConsoleCommandWithArgsDelegate::CreateLambda([this](const TArray& Args) { ToggleSelectionMode(); }), - ECVF_Cheat)); -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Selection::ResetConfig() -{ - Super::ResetConfig(); - for (IConsoleObject* ConsoleCommand : ConsoleCommands) { IConsoleManager::Get().UnregisterConsoleObject(ConsoleCommand); } - - SelectedClassIndex = 0; - SelectionName = FString(); - bReapplySelection = true; } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Selection::PreSaveConfig() +void FCogEngineWindow_Selection::ResetConfig() +{ + Super::ResetConfig(); + + Config->Reset(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogEngineWindow_Selection::PreSaveConfig() { Super::PreSaveConfig(); - SelectionName = GetNameSafe(GetSelection()); + Config->SelectionName = GetNameSafe(GetSelection()); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Selection::PostInitProperties() -{ - Super::PostInitProperties(); - - TryReapplySelection(); -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Selection::TryReapplySelection() const +void FCogEngineWindow_Selection::TryReapplySelection() const { UWorld* World = GetWorld(); if (World == nullptr) @@ -79,12 +79,12 @@ void UCogEngineWindow_Selection::TryReapplySelection() const return; } - if (bReapplySelection == false) + if (Config->bReapplySelection == false) { return; } - if (SelectionName.IsEmpty()) + if (Config->SelectionName.IsEmpty()) { return; } @@ -99,7 +99,7 @@ void UCogEngineWindow_Selection::TryReapplySelection() const for (TActorIterator It(World, SelectedClass); It; ++It) { AActor* Actor = *It; - if (GetNameSafe(Actor) == SelectionName) + if (GetNameSafe(Actor) == Config->SelectionName) { SetGlobalSelection(Actor); } @@ -107,19 +107,19 @@ void UCogEngineWindow_Selection::TryReapplySelection() const } //-------------------------------------------------------------------------------------------------------------------------- -TSubclassOf UCogEngineWindow_Selection::GetSelectedActorClass() const +TSubclassOf FCogEngineWindow_Selection::GetSelectedActorClass() const { TSubclassOf SelectedClass = AActor::StaticClass(); - if (ActorClasses.IsValidIndex(SelectedClassIndex)) + if (ActorClasses.IsValidIndex(Config->SelectedClassIndex)) { - SelectedClass = ActorClasses[SelectedClassIndex]; + SelectedClass = ActorClasses[Config->SelectedClassIndex]; } return SelectedClass; } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Selection::ToggleSelectionMode() +void FCogEngineWindow_Selection::ToggleSelectionMode() { if (bSelectionModeActive) { @@ -132,7 +132,7 @@ void UCogEngineWindow_Selection::ToggleSelectionMode() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Selection::ActivateSelectionMode() +void FCogEngineWindow_Selection::ActivateSelectionMode() { bSelectionModeActive = true; bImGuiHadInputBeforeEnteringSelectionMode = FCogImguiModule::Get().GetEnableInput(); @@ -142,13 +142,13 @@ void UCogEngineWindow_Selection::ActivateSelectionMode() //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Selection::HackWaitInputRelease() +void FCogEngineWindow_Selection::HackWaitInputRelease() { WaitInputReleased = 1; } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Selection::DeactivateSelectionMode() +void FCogEngineWindow_Selection::DeactivateSelectionMode() { bSelectionModeActive = false; @@ -166,7 +166,7 @@ void UCogEngineWindow_Selection::DeactivateSelectionMode() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Selection::RenderTick(float DeltaTime) +void FCogEngineWindow_Selection::RenderTick(float DeltaTime) { Super::RenderTick(DeltaTime); @@ -190,7 +190,7 @@ void UCogEngineWindow_Selection::RenderTick(float DeltaTime) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Selection::RenderContent() +void FCogEngineWindow_Selection::RenderContent() { Super::RenderContent(); @@ -210,7 +210,7 @@ void UCogEngineWindow_Selection::RenderContent() } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Selection::DrawSelectionCombo() +bool FCogEngineWindow_Selection::DrawSelectionCombo() { bool SelectionChanged = false; @@ -230,7 +230,7 @@ bool UCogEngineWindow_Selection::DrawSelectionCombo() TSubclassOf SubClass = ActorClasses[i]; if (ImGui::Selectable(TCHAR_TO_ANSI(*GetNameSafe(SubClass)), false)) { - SelectedClassIndex = i; + Config->SelectedClassIndex = i; SelectedClass = SubClass; } } @@ -297,7 +297,7 @@ bool UCogEngineWindow_Selection::DrawSelectionCombo() } //-------------------------------------------------------------------------------------------------------------------------- -FString UCogEngineWindow_Selection::GetActorName(const AActor* Actor) const +FString FCogEngineWindow_Selection::GetActorName(const AActor* Actor) const { if (Actor == nullptr) { @@ -308,11 +308,11 @@ FString UCogEngineWindow_Selection::GetActorName(const AActor* Actor) const } //-------------------------------------------------------------------------------------------------------------------------- -FString UCogEngineWindow_Selection::GetActorName(const AActor& Actor) const +FString FCogEngineWindow_Selection::GetActorName(const AActor& Actor) const { #if WITH_EDITOR - return bDisplayActorLabel ? Actor.GetActorLabel() : Actor.GetName(); + return Config->bDisplayActorLabel ? Actor.GetActorLabel() : Actor.GetName(); #else //WITH_EDITOR @@ -322,7 +322,7 @@ FString UCogEngineWindow_Selection::GetActorName(const AActor& Actor) const } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Selection::DrawActorContextMenu(AActor* Actor) +void FCogEngineWindow_Selection::DrawActorContextMenu(AActor* Actor) { //------------------------ // ContextMenu @@ -372,15 +372,15 @@ void UCogEngineWindow_Selection::DrawActorContextMenu(AActor* Actor) ImGui::Separator(); - ImGui::Checkbox("Save selection", &bReapplySelection); - ImGui::Checkbox("Display Actor Label", &bDisplayActorLabel); + ImGui::Checkbox("Save selection", &Config->bReapplySelection); + ImGui::Checkbox("Display Actor Label", &Config->bDisplayActorLabel); ImGui::EndPopup(); } } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Selection::TickSelectionMode() +void FCogEngineWindow_Selection::TickSelectionMode() { if (ImGui::IsMouseClicked(ImGuiMouseButton_Right)) { @@ -463,7 +463,7 @@ void UCogEngineWindow_Selection::TickSelectionMode() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Selection::DrawActorFrame(const AActor& Actor) +void FCogEngineWindow_Selection::DrawActorFrame(const AActor& Actor) { APlayerController* PlayerController = GetWorld()->GetFirstPlayerController(); if (PlayerController == nullptr) @@ -516,7 +516,7 @@ void UCogEngineWindow_Selection::DrawActorFrame(const AActor& Actor) } //----------------------------------------------------------------------------------------- -bool UCogEngineWindow_Selection::ComputeBoundingBoxScreenPosition(const APlayerController* PlayerController, const FVector& Origin, const FVector& Extent, FVector2D& Min, FVector2D& Max) +bool FCogEngineWindow_Selection::ComputeBoundingBoxScreenPosition(const APlayerController* PlayerController, const FVector& Origin, const FVector& Extent, FVector2D& Min, FVector2D& Max) { FVector Corners[8]; Corners[0].Set(-Extent.X, -Extent.Y, -Extent.Z); // - - - @@ -558,7 +558,7 @@ bool UCogEngineWindow_Selection::ComputeBoundingBoxScreenPosition(const APlayerC } //-------------------------------------------------------------------------------------------------------------------------- -float UCogEngineWindow_Selection::GetMainMenuWidgetWidth(int32 SubWidgetIndex, float MaxWidth) +float FCogEngineWindow_Selection::GetMainMenuWidgetWidth(int32 SubWidgetIndex, float MaxWidth) { switch (SubWidgetIndex) { @@ -572,7 +572,7 @@ float UCogEngineWindow_Selection::GetMainMenuWidgetWidth(int32 SubWidgetIndex, f //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Selection::RenderMainMenuWidget(int32 SubWidgetIndex, float Width) +void FCogEngineWindow_Selection::RenderMainMenuWidget(int32 SubWidgetIndex, float Width) { //----------------------------------- // Pick Button @@ -658,13 +658,13 @@ void UCogEngineWindow_Selection::RenderMainMenuWidget(int32 SubWidgetIndex, floa } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Selection::SetGlobalSelection(AActor* Value) const +void FCogEngineWindow_Selection::SetGlobalSelection(AActor* Value) const { FCogDebugSettings::SetSelection(GetWorld(), Value); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Selection::RenderPickButtonTooltip() +void FCogEngineWindow_Selection::RenderPickButtonTooltip() { if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) { diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Skeleton.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Skeleton.cpp index 780e4a8..7742c00 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Skeleton.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Skeleton.cpp @@ -1,18 +1,22 @@ #include "CogEngineWindow_Skeleton.h" #include "CogDebugSettings.h" +#include "CogWindowWidgets.h" #include "Components/LineBatchComponent.h" #include "Components/SkeletalMeshComponent.h" #include "Engine/SkeletalMesh.h" +#include "imgui_internal.h" //-------------------------------------------------------------------------------------------------------------------------- -UCogEngineWindow_Skeleton::UCogEngineWindow_Skeleton() +void FCogEngineWindow_Skeleton::Initialize() { + Super::Initialize(); + bHasMenu = true; } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Skeleton::RenderHelp() +void FCogEngineWindow_Skeleton::RenderHelp() { ImGui::Text( "This window display the bone hierarchy and the skeleton debug draw of the selected actor if it has a Skeletal Mesh. " @@ -23,13 +27,13 @@ void UCogEngineWindow_Skeleton::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Skeleton::OnSelectionChanged(AActor* OldSelection, AActor* NewSelection) +void FCogEngineWindow_Skeleton::OnSelectionChanged(AActor* OldSelection, AActor* NewSelection) { RefreshSkeleton(); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Skeleton::RenderTick(float DeltaTime) +void FCogEngineWindow_Skeleton::RenderTick(float DeltaTime) { Super::RenderTick(DeltaTime); @@ -43,7 +47,7 @@ void UCogEngineWindow_Skeleton::RenderTick(float DeltaTime) //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Skeleton::RefreshSkeleton() +void FCogEngineWindow_Skeleton::RefreshSkeleton() { CurrentSkeleton = nullptr; BonesInfos.Empty(); @@ -88,7 +92,7 @@ void UCogEngineWindow_Skeleton::RefreshSkeleton() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Skeleton::RenderContent() +void FCogEngineWindow_Skeleton::RenderContent() { Super::RenderContent(); @@ -120,7 +124,7 @@ void UCogEngineWindow_Skeleton::RenderContent() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Skeleton::RenderBoneEntry(int32 BoneIndex, bool OpenAllChildren) +void FCogEngineWindow_Skeleton::RenderBoneEntry(int32 BoneIndex, bool OpenAllChildren) { if (BonesInfos.IsValidIndex(BoneIndex) == false) { @@ -257,7 +261,7 @@ void UCogEngineWindow_Skeleton::RenderBoneEntry(int32 BoneIndex, bool OpenAllChi } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Skeleton::SetChildrenVisibility(int32 BoneIndex, bool IsVisible) +void FCogEngineWindow_Skeleton::SetChildrenVisibility(int32 BoneIndex, bool IsVisible) { if (BonesInfos.IsValidIndex(BoneIndex) == false) { @@ -274,7 +278,7 @@ void UCogEngineWindow_Skeleton::SetChildrenVisibility(int32 BoneIndex, bool IsVi } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Skeleton::DrawSkeleton() +void FCogEngineWindow_Skeleton::DrawSkeleton() { if (CurrentSkeleton == nullptr || CurrentSkeleton->GetWorld() == nullptr) { diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Spawns.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Spawns.cpp index bdb5414..d6a57d4 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Spawns.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Spawns.cpp @@ -6,15 +6,16 @@ #include "CogWindowHelper.h" #include "CogWindowWidgets.h" - //-------------------------------------------------------------------------------------------------------------------------- -UCogEngineWindow_Spawns::UCogEngineWindow_Spawns() +void FCogEngineWindow_Spawns::Initialize() { - Asset = FCogWindowHelper::GetFirstAssetByClass(); + Super::Initialize(); + + Asset = GetAsset(); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Spawns::RenderHelp() +void FCogEngineWindow_Spawns::RenderHelp() { ImGui::Text( "This window can be used to spawn new actors in the world. " @@ -24,7 +25,7 @@ void UCogEngineWindow_Spawns::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Spawns::RenderContent() +void FCogEngineWindow_Spawns::RenderContent() { Super::RenderContent(); @@ -40,7 +41,7 @@ void UCogEngineWindow_Spawns::RenderContent() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Spawns::RenderSpawnGroup(const FCogEngineSpawnGroup& SpawnGroup) +void FCogEngineWindow_Spawns::RenderSpawnGroup(const FCogEngineSpawnGroup& SpawnGroup) { int32 GroupIndex = 0; @@ -84,7 +85,7 @@ void UCogEngineWindow_Spawns::RenderSpawnGroup(const FCogEngineSpawnGroup& Spawn } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Spawns::RenderSpawnAsset(const FCogEngineSpawnEntry& SpawnEntry, bool IsLastSelected) +bool FCogEngineWindow_Spawns::RenderSpawnAsset(const FCogEngineSpawnEntry& SpawnEntry, bool IsLastSelected) { bool IsPressed = false; diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Stats.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Stats.cpp index 1386c81..d9af25c 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Stats.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Stats.cpp @@ -12,7 +12,7 @@ ImVec4 StatOrangeColor(1.0f, 0.7f, 0.4f, 1.0f); ImVec4 StatGreenColor(0.5f, 1.0f, 0.6f, 1.0f); //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Stats::RenderHelp() +void FCogEngineWindow_Stats::RenderHelp() { ImGui::Text( "This window displays engine stats such as FPS, Ping, Packet Loss. " @@ -20,7 +20,7 @@ void UCogEngineWindow_Stats::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Stats::RenderContent() +void FCogEngineWindow_Stats::RenderContent() { Super::RenderContent(); @@ -55,7 +55,7 @@ void UCogEngineWindow_Stats::RenderContent() } //-------------------------------------------------------------------------------------------------------------------------- -float UCogEngineWindow_Stats::GetMainMenuWidgetWidth(int32 WidgetIndex, float MaxWidth) +float FCogEngineWindow_Stats::GetMainMenuWidgetWidth(int32 WidgetIndex, float MaxWidth) { const APlayerController* PlayerController = GetLocalPlayerController(); const UNetConnection* Connection = PlayerController != nullptr ? PlayerController->GetNetConnection() : nullptr; @@ -71,7 +71,7 @@ float UCogEngineWindow_Stats::GetMainMenuWidgetWidth(int32 WidgetIndex, float Ma } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Stats::RenderMainMenuWidget(int32 WidgetIndex, float Width) +void FCogEngineWindow_Stats::RenderMainMenuWidget(int32 WidgetIndex, float Width) { switch (WidgetIndex) { @@ -82,7 +82,7 @@ void UCogEngineWindow_Stats::RenderMainMenuWidget(int32 WidgetIndex, float Width } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Stats::RenderMainMenuWidgetFramerate(float Width) +void FCogEngineWindow_Stats::RenderMainMenuWidgetFramerate(float Width) { extern ENGINE_API float GAverageFPS; int32 Fps = (int32)GAverageFPS; @@ -119,7 +119,7 @@ void UCogEngineWindow_Stats::RenderMainMenuWidgetFramerate(float Width) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Stats::RenderMainMenuWidgetPing(float Width) +void FCogEngineWindow_Stats::RenderMainMenuWidgetPing(float Width) { const APlayerController* PlayerController = GetLocalPlayerController(); const APlayerState* PlayerState = PlayerController != nullptr ? PlayerController->GetPlayerState() : nullptr; @@ -168,7 +168,7 @@ void UCogEngineWindow_Stats::RenderMainMenuWidgetPing(float Width) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Stats::RenderMainMenuWidgetPacketLoss(float Width) +void FCogEngineWindow_Stats::RenderMainMenuWidgetPacketLoss(float Width) { const APlayerController* PlayerController = GetLocalPlayerController(); UNetConnection* Connection = PlayerController != nullptr ? PlayerController->GetNetConnection() : nullptr; @@ -222,7 +222,7 @@ void UCogEngineWindow_Stats::RenderMainMenuWidgetPacketLoss(float Width) } //-------------------------------------------------------------------------------------------------------------------------- -ImVec4 UCogEngineWindow_Stats::GetFpsColor(float Value, float Good /*= 50.0f*/, float Medium /*= 30.0f*/) +ImVec4 FCogEngineWindow_Stats::GetFpsColor(float Value, float Good /*= 50.0f*/, float Medium /*= 30.0f*/) { if (Value > Good) { @@ -238,7 +238,7 @@ ImVec4 UCogEngineWindow_Stats::GetFpsColor(float Value, float Good /*= 50.0f*/, } //-------------------------------------------------------------------------------------------------------------------------- -ImVec4 UCogEngineWindow_Stats::GetPingColor(float Value, float Good /*= 100.0f*/, float Medium /*= 200.0f*/) +ImVec4 FCogEngineWindow_Stats::GetPingColor(float Value, float Good /*= 100.0f*/, float Medium /*= 200.0f*/) { if (Value > Medium) { @@ -254,7 +254,7 @@ ImVec4 UCogEngineWindow_Stats::GetPingColor(float Value, float Good /*= 100.0f*/ } //-------------------------------------------------------------------------------------------------------------------------- -ImVec4 UCogEngineWindow_Stats::GetPacketLossColor(float Value, float Good /*= 10.0f*/, float Medium /*= 20.0f*/) +ImVec4 FCogEngineWindow_Stats::GetPacketLossColor(float Value, float Good /*= 10.0f*/, float Medium /*= 20.0f*/) { if (Value > Medium) { diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_TimeScale.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_TimeScale.cpp index a484e60..529b8f0 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_TimeScale.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_TimeScale.cpp @@ -6,17 +6,10 @@ #include "Engine/World.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_TimeScale::RenderHelp() +void FCogEngineWindow_TimeScale::Initialize() { - ImGui::Text( - "This window can be used to change the game global time scale. " - "If changed on a client the time scale is also modified on the game server. " - ); -} + Super::Initialize(); -//-------------------------------------------------------------------------------------------------------------------------- -UCogEngineWindow_TimeScale::UCogEngineWindow_TimeScale() -{ TimingScales.Add(0.00f); TimingScales.Add(0.01f); TimingScales.Add(0.10f); @@ -28,7 +21,16 @@ UCogEngineWindow_TimeScale::UCogEngineWindow_TimeScale() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_TimeScale::RenderContent() +void FCogEngineWindow_TimeScale::RenderHelp() +{ + ImGui::Text( + "This window can be used to change the game global time scale. " + "If changed on a client the time scale is also modified on the game server. " + ); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogEngineWindow_TimeScale::RenderContent() { Super::RenderContent(); diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Audio.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Audio.h index e297aa9..e1bffcd 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Audio.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Audio.h @@ -2,12 +2,10 @@ #include "CoreMinimal.h" #include "CogWindow.h" -#include "CogEngineWindow_Audio.generated.h" -UCLASS() -class COGENGINE_API UCogEngineWindow_Audio : public UCogWindow +class COGENGINE_API FCogEngineWindow_Audio : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Collisions.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Collisions.h index 9a7b653..05fef8f 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Collisions.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Collisions.h @@ -2,18 +2,20 @@ #include "CoreMinimal.h" #include "CogWindow.h" +#include "CogWindowConfig.h" #include "CogEngineWindow_Collisions.generated.h" +class UCogEngineConfig_Collisions; class UCogEngineDataAsset; -UCLASS(Config = Cog) -class COGENGINE_API UCogEngineWindow_Collisions : public UCogWindow +//-------------------------------------------------------------------------------------------------------------------------- +class COGENGINE_API FCogEngineWindow_Collisions : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogEngineWindow_Collisions(); + virtual void Initialize() override; protected: @@ -33,6 +35,19 @@ protected: FChannel Channels[ECC_MAX]; + TObjectPtr Asset = nullptr; + + TObjectPtr Config = nullptr; +}; + +//-------------------------------------------------------------------------------------------------------------------------- +UCLASS(Config = Cog) +class UCogEngineConfig_Collisions : public UCogWindowConfig +{ + GENERATED_BODY() + +public: + UPROPERTY(Config) int32 ObjectTypesToQuery = 0; @@ -41,22 +56,33 @@ protected: UPROPERTY(Config) int QueryType = 0; - + UPROPERTY(Config) float QueryDistance = 5000.0f; - + UPROPERTY(Config) float QueryThickness = 0.0f; - + UPROPERTY(Config) bool UseComplexCollisions = false; - + UPROPERTY(Config) bool ShowActorsNames = false; UPROPERTY(Config) bool ShowQuery = false; - UPROPERTY() - TObjectPtr Asset = nullptr; -}; + virtual void Reset() override + { + Super::Reset(); + + ObjectTypesToQuery = 0; + ProfileIndex = 0; + QueryType = 0; + QueryDistance = 5000.0f; + QueryThickness = 0.0f; + UseComplexCollisions = false; + ShowActorsNames = false; + ShowQuery = false; + } +}; \ No newline at end of file diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CommandBindings.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CommandBindings.h index 25a1451..fa0eda1 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CommandBindings.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CommandBindings.h @@ -2,20 +2,13 @@ #include "CoreMinimal.h" #include "CogWindow.h" -#include "CogEngineWindow_CommandBindings.generated.h" -class UPlayerInput; -struct FKeyBind; - -UCLASS(Config = Cog) -class COGENGINE_API UCogEngineWindow_CommandBindings : public UCogWindow +class COGENGINE_API FCogEngineWindow_CommandBindings : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogEngineWindow_CommandBindings(); - protected: virtual void RenderHelp() override; diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_DebugSettings.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_DebugSettings.h index 237c540..70d2368 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_DebugSettings.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_DebugSettings.h @@ -2,16 +2,17 @@ #include "CoreMinimal.h" #include "CogWindow.h" +#include "CogWindowConfig.h" #include "CogEngineWindow_DebugSettings.generated.h" -UCLASS(Config = Cog) -class COGENGINE_API UCogEngineWindow_DebugSettings : public UCogWindow +//-------------------------------------------------------------------------------------------------------------------------- +class COGENGINE_API FCogEngineWindow_DebugSettings : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogEngineWindow_DebugSettings(); + virtual void Initialize() override; protected: @@ -21,12 +22,22 @@ protected: virtual void PreSaveConfig() override; - virtual void PostInitProperties() override; - virtual void RenderContent() override; private: + TWeakObjectPtr Config = nullptr; + +}; + +//-------------------------------------------------------------------------------------------------------------------------- +UCLASS(Config = Cog) +class UCogEngineConfig_DebugSettings : public UCogWindowConfig +{ + GENERATED_BODY() + +public: + UPROPERTY(Config) bool bIsFilteringBySelection = true; @@ -71,4 +82,25 @@ private: UPROPERTY(Config) float TextSize = 1.0f; -}; + + virtual void Reset() override + { + Super::Reset(); + + bIsFilteringBySelection = true; + Persistent = false; + TextShadow = true; + Fade2D = true; + Duration = 3.0f; + DepthPriority = 0; + Segments = 12; + Thickness = 0.0f; + ServerThickness = 2.0f; + ServerColorMultiplier = 0.8f; + ArrowSize = 10.0f; + AxesScale = 1.0f; + GradientColorIntensity = 0.0f; + GradientColorSpeed = 2.0f; + TextSize = 1.0f; + } +}; \ No newline at end of file diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_ImGui.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_ImGui.h index f7693bd..67cde25 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_ImGui.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_ImGui.h @@ -2,17 +2,17 @@ #include "CoreMinimal.h" #include "CogWindow.h" -#include "CogEngineWindow_ImGui.generated.h" -UCLASS() -class COGENGINE_API UCogEngineWindow_ImGui : public UCogWindow +class COGENGINE_API FCogEngineWindow_ImGui : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogEngineWindow_ImGui(); + +protected: virtual void RenderTick(float DeltaTime) override; + virtual void RenderContent() override; private: diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Inspector.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Inspector.h index 438f309..8b05e0c 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Inspector.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Inspector.h @@ -2,19 +2,21 @@ #include "CoreMinimal.h" #include "CogWindow.h" +#include "CogWindowConfig.h" #include "imgui.h" #include "CogEngineWindow_Inspector.generated.h" +class UCogEngineConfig_Inspector; using FCogEngineInspectorApplyFunction = TFunction; -UCLASS(Config = Cog) -class COGENGINE_API UCogEngineWindow_Inspector : public UCogWindow +//-------------------------------------------------------------------------------------------------------------------------- +class COGENGINE_API FCogEngineWindow_Inspector : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogEngineWindow_Inspector(); + virtual void Initialize() override; virtual UObject* GetInspectedObject() const { return InspectedObject.Get(); } @@ -24,24 +26,6 @@ public: virtual void AddFavorite(UObject* Object, FCogEngineInspectorApplyFunction ApplyFunction); - UPROPERTY(Config) - bool bSyncWithSelection = true; - - UPROPERTY(Config) - bool bShowDisplayName = true; - - UPROPERTY(Config) - bool bShowRowBackground = true; - - UPROPERTY(Config) - bool bShowBorders = false; - - UPROPERTY(Config) - bool bShowCategories = true; - - UPROPERTY(Config) - bool bSortByName = true; - protected: virtual void RenderHelp() override; @@ -120,4 +104,45 @@ protected: TArray> History; int32 HistoryIndex = INDEX_NONE; + + TWeakObjectPtr Config = nullptr; }; + +//-------------------------------------------------------------------------------------------------------------------------- +UCLASS(Config = Cog) +class UCogEngineConfig_Inspector : public UCogWindowConfig +{ + GENERATED_BODY() + +public: + + UPROPERTY(Config) + bool bSyncWithSelection = true; + + UPROPERTY(Config) + bool bShowDisplayName = true; + + UPROPERTY(Config) + bool bShowRowBackground = true; + + UPROPERTY(Config) + bool bShowBorders = false; + + UPROPERTY(Config) + bool bShowCategories = true; + + UPROPERTY(Config) + bool bSortByName = true; + + virtual void Reset() override + { + Super::Reset(); + + bSyncWithSelection = true; + bShowDisplayName = true; + bShowRowBackground = true; + bShowBorders = false; + bShowCategories = true; + bSortByName = true; + } +}; \ No newline at end of file diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_LogCategories.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_LogCategories.h index db4b440..6b7c1db 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_LogCategories.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_LogCategories.h @@ -2,16 +2,16 @@ #include "CoreMinimal.h" #include "CogWindow.h" -#include "CogEngineWindow_LogCategories.generated.h" -UCLASS() -class COGENGINE_API UCogEngineWindow_LogCategories : public UCogWindow +class COGENGINE_API FCogEngineWindow_LogCategories : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogEngineWindow_LogCategories(); + virtual void Initialize() override; + +protected: virtual void ResetConfig() override; diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Metrics.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Metrics.h index 5a6c852..4ec0a9d 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Metrics.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Metrics.h @@ -2,26 +2,25 @@ #include "CoreMinimal.h" #include "CogWindow.h" +#include "CogWindowConfig.h" #include "CogEngineWindow_Metrics.generated.h" struct FCogDebugMetricEntry; +class UCogEngineConfig_Metrics; //-------------------------------------------------------------------------------------------------------------------------- -UCLASS(Config = Cog) -class COGENGINE_API UCogEngineWindow_Metrics : public UCogWindow +class COGENGINE_API FCogEngineWindow_Metrics : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogEngineWindow_Metrics(); + virtual void Initialize() override; protected: virtual void ResetConfig() override; - virtual void PostInitProperties() override; - virtual void PreSaveConfig() override; virtual void RenderHelp() override; @@ -36,9 +35,29 @@ protected: private: + TObjectPtr Config = nullptr; + +}; + +//-------------------------------------------------------------------------------------------------------------------------- +UCLASS(Config = Cog) +class UCogEngineConfig_Metrics : public UCogWindowConfig +{ + GENERATED_BODY() + +public: + UPROPERTY(Config) float MaxDurationSetting = 0.0f; UPROPERTY(Config) float RestartDelaySetting = 5.0f; -}; + + virtual void Reset() override + { + Super::Reset(); + + MaxDurationSetting = 0.0f; + RestartDelaySetting = 5.0f; + } +}; \ No newline at end of file diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_NetEmulation.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_NetEmulation.h index b2923c4..8651c59 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_NetEmulation.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_NetEmulation.h @@ -2,12 +2,10 @@ #include "CoreMinimal.h" #include "CogWindow.h" -#include "CogEngineWindow_NetEmulation.generated.h" -UCLASS() -class COGENGINE_API UCogEngineWindow_NetEmulation : public UCogWindow +class COGENGINE_API FCogEngineWindow_NetEmulation : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; protected: diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_OutputLog.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_OutputLog.h index 94541d7..9ff419d 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_OutputLog.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_OutputLog.h @@ -2,35 +2,36 @@ #include "CoreMinimal.h" #include "CogWindow.h" +#include "CogWindowConfig.h" #include "imgui.h" #include "Misc/OutputDevice.h" #include "CogEngineWindow_OutputLog.generated.h" -class UCogEngineWindow_OutputLog; +class FCogEngineWindow_OutputLog; +class UCogEngineConfig_OutputLog; //-------------------------------------------------------------------------------------------------------------------------- -class UCogLogOutputDevice : public FOutputDevice +class FCogLogOutputDevice : public FOutputDevice { public: - friend class UCogEngineWindow_OutputLog; + friend class FCogEngineWindow_OutputLog; - UCogLogOutputDevice(); - ~UCogLogOutputDevice(); + FCogLogOutputDevice(); + ~FCogLogOutputDevice(); virtual void Serialize(const TCHAR* Message, ELogVerbosity::Type Verbosity, const FName& Category) override; - UCogEngineWindow_OutputLog* OutputLog = nullptr; + FCogEngineWindow_OutputLog* OutputLog = nullptr; }; //-------------------------------------------------------------------------------------------------------------------------- -UCLASS(Config = Cog) -class COGENGINE_API UCogEngineWindow_OutputLog : public UCogWindow +class COGENGINE_API FCogEngineWindow_OutputLog : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogEngineWindow_OutputLog(); + virtual void Initialize() override; void AddLog(const TCHAR* Message, ELogVerbosity::Type Verbosity, const FName& Category); @@ -57,6 +58,25 @@ private: void DrawRow(const char* BufferStart, const FLineInfo& Info, bool IsTableShown); + ImGuiTextBuffer TextBuffer; + + ImGuiTextFilter Filter; + + TArray LineInfos; + + FCogLogOutputDevice OutputDevice; + + TObjectPtr Config = nullptr; +}; + +//-------------------------------------------------------------------------------------------------------------------------- +UCLASS(Config = Cog) +class UCogEngineConfig_OutputLog : public UCogWindowConfig +{ + GENERATED_BODY() + +public: + UPROPERTY(Config) bool AutoScroll = true; @@ -71,15 +91,19 @@ private: UPROPERTY(Config) bool ShowAsTable = false; - + UPROPERTY(Config) int32 VerbosityFilter = ELogVerbosity::VeryVerbose; - ImGuiTextBuffer TextBuffer; + virtual void Reset() override + { + Super::Reset(); - ImGuiTextFilter Filter; - - TArray LineInfos; - - UCogLogOutputDevice OutputDevice; -}; + AutoScroll = true; + ShowFrame = true; + ShowCategory = true; + ShowVerbosity = false; + ShowAsTable = false; + VerbosityFilter = ELogVerbosity::VeryVerbose; + } +}; \ No newline at end of file diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Plots.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Plots.h index 36e193f..63df402 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Plots.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Plots.h @@ -2,12 +2,10 @@ #include "CoreMinimal.h" #include "CogWindow.h" -#include "CogEngineWindow_Plots.generated.h" -UCLASS() -class COGENGINE_API UCogEngineWindow_Plots : public UCogWindow +class COGENGINE_API FCogEngineWindow_Plots : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; protected: diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Scalability.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Scalability.h index eea7c87..7eda158 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Scalability.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Scalability.h @@ -2,12 +2,10 @@ #include "CoreMinimal.h" #include "CogWindow.h" -#include "CogEngineWindow_Scalability.generated.h" -UCLASS() -class COGENGINE_API UCogEngineWindow_Scalability : public UCogWindow +class COGENGINE_API FCogEngineWindow_Scalability : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Selection.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Selection.h index f15beb0..403950a 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Selection.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Selection.h @@ -3,20 +3,24 @@ #include "CoreMinimal.h" #include "GameFramework/Actor.h" #include "CogWindow.h" +#include "CogWindowConfig.h" #include "CogEngineWindow_Selection.generated.h" class IConsoleObject; +class UCogEngineConfig_Selection; -UCLASS(Config = Cog) -class COGENGINE_API UCogEngineWindow_Selection : public UCogWindow +//-------------------------------------------------------------------------------------------------------------------------- +class COGENGINE_API FCogEngineWindow_Selection : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: static FString ToggleSelectionModeCommand; - UCogEngineWindow_Selection(); + virtual void Initialize() override; + + virtual void Shutdown() override; bool GetIsSelecting() const { return bSelectionModeActive; } @@ -42,8 +46,6 @@ protected: virtual void PreSaveConfig() override; - virtual void PostInitProperties() override; - virtual void RenderHelp() override; virtual void RenderTick(float DeltaTime) override; @@ -76,18 +78,6 @@ protected: bool ComputeBoundingBoxScreenPosition(const APlayerController* PlayerController, const FVector& Origin, const FVector& Extent, FVector2D& Min, FVector2D& Max); - UPROPERTY(Config) - bool bReapplySelection = true; - - UPROPERTY(Config) - bool bDisplayActorLabel = true; - - UPROPERTY(Config) - FString SelectionName; - - UPROPERTY(Config) - int32 SelectedClassIndex = 0; - FVector LastSelectedActorLocation = FVector::ZeroVector; bool bSelectionModeActive = false; @@ -101,4 +91,37 @@ protected: ETraceTypeQuery TraceType = TraceTypeQuery1; TArray ConsoleCommands; + + TObjectPtr Config; }; + +//-------------------------------------------------------------------------------------------------------------------------- +UCLASS(Config = Cog) +class UCogEngineConfig_Selection : public UCogWindowConfig +{ + GENERATED_BODY() + +public: + + UPROPERTY(Config) + bool bReapplySelection = true; + + UPROPERTY(Config) + bool bDisplayActorLabel = true; + + UPROPERTY(Config) + FString SelectionName; + + UPROPERTY(Config) + int32 SelectedClassIndex = 0; + + virtual void Reset() override + { + Super::Reset(); + + bReapplySelection = true; + bDisplayActorLabel = true; + SelectionName; + SelectedClassIndex = 0; + } +}; \ No newline at end of file diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Skeleton.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Skeleton.h index fc2c214..3c46f98 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Skeleton.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Skeleton.h @@ -3,38 +3,48 @@ #include "CoreMinimal.h" #include "GameFramework/Actor.h" #include "CogWindow.h" -#include "CogEngineWindow_Skeleton.generated.h" class USkeletalMeshComponent; +//-------------------------------------------------------------------------------------------------------------------------- struct FBoneInfo { FName Name; + TArray Children; + int32 Index = 0; + int32 ParentIndex = INDEX_NONE; + FVector LastLocation = FVector::ZeroVector; + bool IsSecondaryBone = false; bool ShowBone = true; + bool ShowName = false; + bool ShowLocalVelocity = false; + bool ShowAxes = false; + bool ShowTrajectory = false; }; -UCLASS() -class COGENGINE_API UCogEngineWindow_Skeleton : public UCogWindow +//-------------------------------------------------------------------------------------------------------------------------- +class COGENGINE_API FCogEngineWindow_Skeleton : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogEngineWindow_Skeleton(); - virtual void RenderHelp() override; + virtual void Initialize() override; protected: + virtual void RenderHelp() override; + virtual void RenderContent() override; virtual void RenderTick(float DeltaTime) override; @@ -43,18 +53,30 @@ protected: private: void RenderBoneEntry(int32 BoneIndex, bool OpenAllChildren); + void SetChildrenVisibility(int32 BoneIndex, bool IsVisible); + void DrawSkeleton(); + void RefreshSkeleton(); TWeakObjectPtr CurrentSkeleton = nullptr; + bool ShowBones = true; + bool ShowNames = false; + bool ShowAxes = false; + bool ShowVelocities = false; + bool ShowTrajectories = false; + bool HideSecondaryBones = true; + int32 HoveredBoneIndex = INDEX_NONE; + TArray BonesInfos; + ImGuiTextFilter Filter; }; \ No newline at end of file diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Spawns.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Spawns.h index 2e16afc..6fdb159 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Spawns.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Spawns.h @@ -2,20 +2,18 @@ #include "CoreMinimal.h" #include "CogWindow.h" -#include "CogEngineWindow_Spawns.generated.h" class UCogEngineDataAsset; struct FCogEngineSpawnGroup; struct FCogEngineSpawnEntry; -UCLASS() -class COGENGINE_API UCogEngineWindow_Spawns : public UCogWindow +class COGENGINE_API FCogEngineWindow_Spawns : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogEngineWindow_Spawns(); + virtual void Initialize() override; protected: @@ -29,6 +27,5 @@ protected: private: - UPROPERTY() TObjectPtr Asset = nullptr; }; diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Stats.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Stats.h index c29b4fe..9e41e8b 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Stats.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Stats.h @@ -2,12 +2,10 @@ #include "CoreMinimal.h" #include "CogWindow.h" -#include "CogEngineWindow_Stats.generated.h" -UCLASS() -class COGENGINE_API UCogEngineWindow_Stats : public UCogWindow +class COGENGINE_API FCogEngineWindow_Stats : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: @@ -26,7 +24,10 @@ protected: virtual float GetMainMenuWidgetWidth(int32 SubWidgetIndex, float MaxWidth) override; virtual void RenderMainMenuWidget(int32 SubWidgetIndex, float Width) override; - void RenderMainMenuWidgetPacketLoss(float Width); - void RenderMainMenuWidgetPing(float Width); - void RenderMainMenuWidgetFramerate(float Width); + + virtual void RenderMainMenuWidgetPacketLoss(float Width); + + virtual void RenderMainMenuWidgetPing(float Width); + + virtual void RenderMainMenuWidgetFramerate(float Width); }; diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_TimeScale.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_TimeScale.h index e76362a..9c0b152 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_TimeScale.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_TimeScale.h @@ -2,18 +2,14 @@ #include "CoreMinimal.h" #include "CogWindow.h" -#include "CogEngineWindow_TimeScale.generated.h" -class ACogEngineReplicator; - -UCLASS() -class COGENGINE_API UCogEngineWindow_TimeScale : public UCogWindow +class COGENGINE_API FCogEngineWindow_TimeScale : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogEngineWindow_TimeScale(); + void Initialize(); protected: diff --git a/Plugins/Cog/Source/CogImgui/Private/CogImguiWidget.cpp b/Plugins/Cog/Source/CogImgui/Private/CogImguiWidget.cpp index a510798..27147f6 100644 --- a/Plugins/Cog/Source/CogImgui/Private/CogImguiWidget.cpp +++ b/Plugins/Cog/Source/CogImgui/Private/CogImguiWidget.cpp @@ -47,8 +47,23 @@ END_SLATE_FUNCTION_BUILD_OPTIMIZATION //-------------------------------------------------------------------------------------------------------------------------- SCogImguiWidget::~SCogImguiWidget() { - ImPlot::DestroyContext(ImPlotContext); - ImGui::DestroyContext(ImGuiContext); + DestroyImGuiContext(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void SCogImguiWidget::DestroyImGuiContext() +{ + if (ImPlotContext != nullptr) + { + ImPlot::DestroyContext(ImPlotContext); + ImPlotContext = nullptr; + } + + if (ImGuiContext != nullptr) + { + ImGui::DestroyContext(ImGuiContext); + ImGuiContext = nullptr; + } } //-------------------------------------------------------------------------------------------------------------------------- diff --git a/Plugins/Cog/Source/CogImgui/Public/CogImguiWidget.h b/Plugins/Cog/Source/CogImgui/Public/CogImguiWidget.h index 371e098..498cb87 100644 --- a/Plugins/Cog/Source/CogImgui/Public/CogImguiWidget.h +++ b/Plugins/Cog/Source/CogImgui/Public/CogImguiWidget.h @@ -67,6 +67,8 @@ public: TWeakObjectPtr GetGameViewport() const { return GameViewport; } + void DestroyImGuiContext(); + protected: FVector2D TransformScreenPointToImGui(const FGeometry& MyGeometry, const FVector2D& Point) const; diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindow.cpp b/Plugins/Cog/Source/CogWindow/Private/CogWindow.cpp index d3781b2..b19b23b 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindow.cpp +++ b/Plugins/Cog/Source/CogWindow/Private/CogWindow.cpp @@ -8,7 +8,7 @@ #include "imgui_internal.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindow::SetFullName(const FString& InFullName) +void FCogWindow::SetFullName(const FString& InFullName) { FullName = InFullName; @@ -29,7 +29,7 @@ void UCogWindow::SetFullName(const FString& InFullName) } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogWindow::CheckEditorVisibility() +bool FCogWindow::CheckEditorVisibility() { const UWorld* World = GetWorld(); if (World == nullptr) @@ -51,7 +51,7 @@ bool UCogWindow::CheckEditorVisibility() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindow::Render(float DeltaTime) +void FCogWindow::Render(float DeltaTime) { ImGuiWindowFlags WindowFlags = 0; PreRender(WindowFlags); @@ -65,7 +65,7 @@ void UCogWindow::Render(float DeltaTime) if (ImGui::Begin(TCHAR_TO_ANSI(*WindowTitle), &bIsVisible, WindowFlags)) { - if (Owner->GetShowHelp()) + if (GetOwner()->GetShowHelp()) { if (ImGui::IsItemHovered()) { @@ -107,24 +107,24 @@ void UCogWindow::Render(float DeltaTime) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindow::RenderHelp() +void FCogWindow::RenderHelp() { ImGui::Text("No help available."); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindow::RenderTick(float DeltaTime) +void FCogWindow::RenderTick(float DeltaTime) { SetSelection(FCogDebugSettings::GetSelection()); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindow::GameTick(float DeltaTime) +void FCogWindow::GameTick(float DeltaTime) { } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindow::SetSelection(AActor* NewSelection) +void FCogWindow::SetSelection(AActor* NewSelection) { if (CurrentSelection == NewSelection) { @@ -138,7 +138,7 @@ void UCogWindow::SetSelection(AActor* NewSelection) } //-------------------------------------------------------------------------------------------------------------------------- -APawn* UCogWindow::GetLocalPlayerPawn() +APawn* FCogWindow::GetLocalPlayerPawn() { APlayerController* LocalPlayerController = GetLocalPlayerController(); @@ -153,7 +153,7 @@ APawn* UCogWindow::GetLocalPlayerPawn() } //-------------------------------------------------------------------------------------------------------------------------- -APlayerController* UCogWindow::GetLocalPlayerController() +APlayerController* FCogWindow::GetLocalPlayerController() { ULocalPlayer* LocalPlayer = GetLocalPlayer(); if (LocalPlayer == nullptr) @@ -165,7 +165,7 @@ APlayerController* UCogWindow::GetLocalPlayerController() } //-------------------------------------------------------------------------------------------------------------------------- -ULocalPlayer* UCogWindow::GetLocalPlayer() +ULocalPlayer* FCogWindow::GetLocalPlayer() { const UWorld* World = GetWorld(); if (World == nullptr) @@ -175,3 +175,22 @@ ULocalPlayer* UCogWindow::GetLocalPlayer() return World->GetFirstLocalPlayerFromController(); } + +//-------------------------------------------------------------------------------------------------------------------------- +UCogWindowConfig* FCogWindow::GetConfig(const TSubclassOf ConfigClass) +{ + return GetOwner()->GetConfig(ConfigClass); +} + +//-------------------------------------------------------------------------------------------------------------------------- +const UObject* FCogWindow::GetAsset(const TSubclassOf AssetClass) +{ + return GetOwner()->GetAsset(AssetClass); +} + +//-------------------------------------------------------------------------------------------------------------------------- +UWorld* FCogWindow::GetWorld() const +{ + return Owner->GetWorld(); +} + diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp b/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp index 25271f8..9c8cb1b 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp +++ b/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp @@ -1,11 +1,13 @@ #include "CogWindowManager.h" #include "CogDebugDrawImGui.h" -#include "CogImguiModule.h" #include "CogImguiInputHelper.h" +#include "CogImguiModule.h" #include "CogImguiWidget.h" #include "CogWindow_Settings.h" #include "CogWindow_Spacing.h" +#include "CogWindowConfig.h" +#include "CogWindowHelper.h" #include "CogWindowWidgets.h" #include "Engine/Engine.h" #include "HAL/IConsoleManager.h" @@ -51,12 +53,12 @@ void UCogWindowManager::InitializeInternal() IniHandler.UserData = this; ImGui::AddSettingsHandler(&IniHandler); - SpaceWindows.Add(CreateWindow("Spacing 1", false)); - SpaceWindows.Add(CreateWindow("Spacing 2", false)); - SpaceWindows.Add(CreateWindow("Spacing 3", false)); - SpaceWindows.Add(CreateWindow("Spacing 4", false)); + SpaceWindows.Add(CreateWindow("Spacing 1", false)); + SpaceWindows.Add(CreateWindow("Spacing 2", false)); + SpaceWindows.Add(CreateWindow("Spacing 3", false)); + SpaceWindows.Add(CreateWindow("Spacing 4", false)); - SettingsWindow = CreateWindow("Window.Settings", false); + SettingsWindow = CreateWindow("Window.Settings", false); ConsoleCommands.Add(IConsoleManager::Get().RegisterConsoleCommand( *ToggleInputCommand, @@ -87,10 +89,25 @@ void UCogWindowManager::InitializeInternal() //-------------------------------------------------------------------------------------------------------------------------- void UCogWindowManager::Shutdown() { - for (UCogWindow* Window : Windows) + //------------------------------------------------------------ + // Destroy ImGui before destroying the windows to make sure + // imgui serialize their visibility state in imgui.ini + //------------------------------------------------------------ + ImGuiWidget->DestroyImGuiContext(); + + SaveConfig(); + + for (FCogWindow* Window : Windows) { Window->PreSaveConfig(); - Window->SaveConfig(); + Window->Shutdown(); + delete Window; + } + Windows.Empty(); + + for (UCogWindowConfig* Config : Configs) + { + Config->SaveConfig(); } for (IConsoleObject* ConsoleCommand : ConsoleCommands) @@ -99,8 +116,6 @@ void UCogWindowManager::Shutdown() } FCogImguiModule::Get().DestroyImGuiWidget(ImGuiWidget); - - SaveConfig(); } //-------------------------------------------------------------------------------------------------------------------------- @@ -129,7 +144,7 @@ void UCogWindowManager::Tick(float DeltaTime) bRefreshDPIScale = false; } - for (UCogWindow* Window : Windows) + for (FCogWindow* Window : Windows) { Window->GameTick(DeltaTime); } @@ -156,7 +171,7 @@ void UCogWindowManager::Render(float DeltaTime) } } - for (UCogWindow* Window : Windows) + for (FCogWindow* Window : Windows) { Window->RenderTick(DeltaTime); @@ -183,9 +198,11 @@ void UCogWindowManager::Render(float DeltaTime) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::AddWindow(UCogWindow* Window, bool AddToMainMenu /*= true*/) +void UCogWindowManager::AddWindow(FCogWindow* Window, const FString& Name, bool AddToMainMenu /*= true*/) { + Window->SetFullName(Name); Window->SetOwner(this); + Window->Initialize(); Windows.Add(Window); if (AddToMainMenu) @@ -198,16 +215,16 @@ void UCogWindowManager::AddWindow(UCogWindow* Window, bool AddToMainMenu /*= tru } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::AddMainMenuWidget(UCogWindow* Window) +void UCogWindowManager::AddMainMenuWidget(FCogWindow* Window) { Window->SetOwner(this); MainMenuWidgets.Add(Window); } //-------------------------------------------------------------------------------------------------------------------------- -UCogWindow* UCogWindowManager::FindWindowByID(ImGuiID ID) +FCogWindow* UCogWindowManager::FindWindowByID(ImGuiID ID) { - for (UCogWindow* Window : Windows) + for (FCogWindow* Window : Windows) { if (Window->GetID() == ID) { @@ -227,16 +244,18 @@ void UCogWindowManager::SetHideAllWindows(bool Value) //-------------------------------------------------------------------------------------------------------------------------- void UCogWindowManager::ResetLayout() { - for (UCogWindow* Window : Windows) + for (FCogWindow* Window : Windows) { ImGui::SetWindowPos(TCHAR_TO_ANSI(*Window->GetName()), ImVec2(10, 10), ImGuiCond_Always); } + + ImGui::ClearIniSettings(); } //-------------------------------------------------------------------------------------------------------------------------- void UCogWindowManager::CloseAllWindows() { - for (UCogWindow* Window : Windows) + for (FCogWindow* Window : Windows) { Window->SetIsVisible(false); } @@ -245,7 +264,7 @@ void UCogWindowManager::CloseAllWindows() //-------------------------------------------------------------------------------------------------------------------------- void UCogWindowManager::LoadLayout(int32 LayoutIndex) { - for (UCogWindow* Window : Windows) + for (FCogWindow* Window : Windows) { Window->SetIsVisible(false); } @@ -265,12 +284,10 @@ void UCogWindowManager::SortMainMenu() { MainMenu.SubMenus.Empty(); - Windows.Sort(); + TArray SortedWindows = Windows; + SortedWindows.Sort([](FCogWindow& Lhs, FCogWindow& Rhs) { return Lhs.GetFullName() < Rhs.GetFullName(); }); - TArray SortedWindows = Windows; - SortedWindows.Sort([](UCogWindow& Lhs, UCogWindow& Rhs) { return Lhs.GetFullName() < Rhs.GetFullName(); }); - - for (UCogWindow* Window : SortedWindows) + for (FCogWindow* Window : SortedWindows) { if (FMenu* Menu = AddMenu(Window->GetFullName())) { @@ -360,7 +377,7 @@ void UCogWindowManager::RenderMainMenu() if (ImGui::BeginMenu("Spacing")) { - for (UCogWindow* SpaceWindow : SpaceWindows) + for (FCogWindow* SpaceWindow : SpaceWindows) { bool bSpaceVisible = SpaceWindow->GetIsVisible(); if (ImGui::MenuItem(TCHAR_TO_ANSI(*SpaceWindow->GetName()), nullptr, &bSpaceVisible)) @@ -382,7 +399,7 @@ void UCogWindowManager::RenderMainMenu() const float MinCursorX = ImGui::GetCursorPosX(); float CursorX = ImGui::GetWindowWidth(); - for (UCogWindow* Window : MainMenuWidgets) + for (FCogWindow* Window : MainMenuWidgets) { TArray SubWidgetsWidths; float SimCursorX = CursorX; @@ -483,7 +500,7 @@ void UCogWindowManager::RenderOptionMenu(UCogWindowManager::FMenu& Menu) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::RenderMenuItem(UCogWindow& Window, const char* MenuItemName) +void UCogWindowManager::RenderMenuItem(FCogWindow& Window, const char* MenuItemName) { if (bShowWindowsInMainMenu) { @@ -561,7 +578,7 @@ void UCogWindowManager::SettingsHandler_ReadLine(ImGuiContext* Context, ImGuiSet if (sscanf_s(Line, "0x%08X", &Id) == 1) { UCogWindowManager* Manager = (UCogWindowManager*)Handler->UserData; - if (UCogWindow* Window = Manager->FindWindowByID(Id)) + if (FCogWindow* Window = Manager->FindWindowByID(Id)) { Window->SetIsVisible(true); } @@ -574,7 +591,7 @@ void UCogWindowManager::SettingsHandler_WriteAll(ImGuiContext* Context, ImGuiSet const UCogWindowManager* Manager = (UCogWindowManager*)Handler->UserData; Buffer->appendf("[%s][Windows]\n", Handler->TypeName); - for (UCogWindow* Window : Manager->Windows) + for (FCogWindow* Window : Manager->Windows) { if (Window->GetIsVisible()) { @@ -598,7 +615,7 @@ void UCogWindowManager::SetDPIScale(float Value) //-------------------------------------------------------------------------------------------------------------------------- void UCogWindowManager::ResetAllWindowsConfig() { - for (UCogWindow* Window : Windows) + for (FCogWindow* Window : Windows) { Window->ResetConfig(); } @@ -671,3 +688,45 @@ void UCogWindowManager::SortCommands(UPlayerInput* PlayerInput) return Key1.Command.Compare(Key2.Command) < 0; }); } + +//-------------------------------------------------------------------------------------------------------------------------- +UCogWindowConfig* UCogWindowManager::GetConfig(const TSubclassOf ConfigClass) +{ + const UClass* Class = ConfigClass.Get(); + + for (UCogWindowConfig* Config : Configs) + { + if (Config && Config->IsA(Class)) + { + return Cast(Config); + } + } + + UCogWindowConfig* Config = NewObject(this, Class); + Configs.Add(Config); + return Config; +} + +//-------------------------------------------------------------------------------------------------------------------------- +const UObject* UCogWindowManager::GetAsset(const TSubclassOf AssetClass) +{ + const UClass* Class = AssetClass.Get(); + + for (const UObject* Asset : Assets) + { + if (Asset && Asset->IsA(Class)) + { + return Asset; + } + } + + const UObject* Asset = FCogWindowHelper::GetFirstAssetByClass(AssetClass); + if (Asset == nullptr) + { + return nullptr; + } + + Assets.Add(Asset); + + return Asset; +} \ No newline at end of file diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindow_Settings.cpp b/Plugins/Cog/Source/CogWindow/Private/CogWindow_Settings.cpp index 718f720..484df05 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindow_Settings.cpp +++ b/Plugins/Cog/Source/CogWindow/Private/CogWindow_Settings.cpp @@ -6,19 +6,15 @@ #include "InputCoreTypes.h" //-------------------------------------------------------------------------------------------------------------------------- -UCogWindow_Settings::UCogWindow_Settings() +void FCogWindow_Settings::Initialize() { + Super::Initialize(); + bHasMenu = false; } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindow_Settings::PostInitProperties() -{ - Super::PostInitProperties(); -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogWindow_Settings::RenderContent() +void FCogWindow_Settings::RenderContent() { FCogWindowWidgets::SetNextItemToShortWidth(); ImGui::SliderFloat("DPI Scale", &GetOwner()->DPIScale, 0.5f, 2.0f, "%.1f"); diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindow_Spacing.cpp b/Plugins/Cog/Source/CogWindow/Private/CogWindow_Spacing.cpp index 828b37d..68974e4 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindow_Spacing.cpp +++ b/Plugins/Cog/Source/CogWindow/Private/CogWindow_Spacing.cpp @@ -1,13 +1,13 @@ #include "CogWindow_Spacing.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindow_Spacing::PreRender(ImGuiWindowFlags& WindowFlags) +void FCogWindow_Spacing::PreRender(ImGuiWindowFlags& WindowFlags) { ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0)); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindow_Spacing::PostRender() +void FCogWindow_Spacing::PostRender() { ImGui::PopStyleColor(1); } diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindow.h b/Plugins/Cog/Source/CogWindow/Public/CogWindow.h index 6248a35..a338a6a 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindow.h +++ b/Plugins/Cog/Source/CogWindow/Public/CogWindow.h @@ -2,21 +2,23 @@ #include "CoreMinimal.h" #include "imgui.h" -#include "CogWindow.generated.h" -class UCogWindowManager; class APawn; class APlayerController; +class UCogWindowConfig; +class UCogWindowManager; +class UWorld; -UCLASS(Config = Cog) -class COGWINDOW_API UCogWindow : public UObject +class COGWINDOW_API FCogWindow { - GENERATED_BODY() - public: + virtual ~FCogWindow() {} + virtual void Initialize() {} + virtual void Shutdown() {} + virtual void ResetConfig() {} virtual void PreSaveConfig() {} @@ -58,12 +60,24 @@ public: UCogWindowManager* GetOwner() const { return Owner; } + template + T* GetConfig() { return Cast(GetConfig(T::StaticClass())); } + + UCogWindowConfig* GetConfig(const TSubclassOf ConfigClass); + + template + const T* GetAsset() { return Cast(GetAsset(T::StaticClass())); } + + const UObject* GetAsset(const TSubclassOf AssetClass); + protected: friend class UCogWindowManager; virtual const FString& GetTitle() const { return Title; } + virtual UWorld* GetWorld() const; + virtual void RenderHelp(); virtual void PreRender(ImGuiWindowFlags& WindowFlags) {} @@ -105,3 +119,4 @@ protected: TWeakObjectPtr OverridenSelection; }; + diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindowConfig.h b/Plugins/Cog/Source/CogWindow/Public/CogWindowConfig.h new file mode 100644 index 0000000..15034c8 --- /dev/null +++ b/Plugins/Cog/Source/CogWindow/Public/CogWindowConfig.h @@ -0,0 +1,20 @@ +#pragma once + +#include "CoreMinimal.h" +#include "CogWindowConfig.generated.h" + +UCLASS(Config = Cog) +class COGWINDOW_API UCogWindowConfig : public UObject +{ + GENERATED_BODY() + +public: + + UPROPERTY(Config) + bool bHideMenu = false; + + virtual void Reset() + { + bHideMenu = true; + } +}; diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindowHelper.h b/Plugins/Cog/Source/CogWindow/Public/CogWindowHelper.h index cbab1e3..17699a6 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindowHelper.h +++ b/Plugins/Cog/Source/CogWindow/Public/CogWindowHelper.h @@ -8,20 +8,26 @@ class COGWINDOW_API FCogWindowHelper { public: + //---------------------------------------------------------------------------------------------------------------------- template - static T* GetFirstAssetByClass() + static const T* GetFirstAssetByClass() + { + return Cast(GetFirstAssetByClass(T::StaticClass())); + } + + //---------------------------------------------------------------------------------------------------------------------- + static const UObject* GetFirstAssetByClass(const TSubclassOf AssetClass) { IAssetRegistry& AssetRegistry = FModuleManager::LoadModuleChecked(TEXT("AssetRegistry")).Get(); TArray Assets; - AssetRegistry.GetAssetsByClass(T::StaticClass()->GetClassPathName(), Assets, true); + AssetRegistry.GetAssetsByClass(AssetClass->GetClassPathName(), Assets, true); if (Assets.Num() == 0) { return nullptr; } UObject* Asset = Assets[0].GetAsset(); - T* CastedAsset = Cast(Asset); - return CastedAsset; + return Asset; } }; diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindowManager.h b/Plugins/Cog/Source/CogWindow/Public/CogWindowManager.h index 5576cd5..fc113ca 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindowManager.h +++ b/Plugins/Cog/Source/CogWindow/Public/CogWindowManager.h @@ -1,14 +1,14 @@ #pragma once #include "CoreMinimal.h" -#include "CogWindow.h" #include "imgui.h" #include "CogWindowManager.generated.h" class IConsoleObject; class SCogImguiWidget; -class UCogWindow; -class UCogWindow_Settings; +class FCogWindow; +class FCogWindow_Settings; +class UCogWindowConfig; class UPlayerInput; class UWorld; struct ImGuiSettingsHandler; @@ -38,21 +38,11 @@ public: virtual void Tick(float DeltaTime); - template - T* CreateWindow(const FString& Name, bool AddToMainMenu = true) - { - T* Window = NewObject(this); - Window->SetFullName(Name); - Window->Initialize(); - AddWindow(Window, AddToMainMenu); - return Window; - } + virtual void AddWindow(FCogWindow* Window, const FString& Name, bool AddToMainMenu = true); - virtual void AddWindow(UCogWindow* Window, bool AddToMainMenu = true); + virtual void AddMainMenuWidget(FCogWindow* Window); - virtual void AddMainMenuWidget(UCogWindow* Window); - - virtual UCogWindow* FindWindowByID(ImGuiID ID); + virtual FCogWindow* FindWindowByID(ImGuiID ID); virtual void CloseAllWindows(); @@ -90,14 +80,39 @@ public: static void SortCommands(UPlayerInput* PlayerInput); + UCogWindowConfig* GetConfig(const TSubclassOf ConfigClass); + + const UObject* GetAsset(const TSubclassOf AssetClass); + + template + T* CreateWindow(const FString& Name, bool AddToMainMenu = true) + { + T* Window = new T(); + AddWindow(Window, Name, AddToMainMenu); + return Window; + } + + template + T* GetConfig() + { + static_assert(TPointerIsConvertibleFromTo::Value); + return Cast(&GetConfig(T::StaticClass())); + } + + template + static T* GetAsset() + { + return Cast(GetAsset(T::StaticClass())); + } + protected: - friend class UCogWindow_Settings; + friend class FCogWindow_Settings; struct FMenu { FString Name; - UCogWindow* Window = nullptr; + FCogWindow* Window = nullptr; TArray SubMenus; }; @@ -111,7 +126,7 @@ protected: virtual void RenderOptionMenu(FMenu& Menu); - virtual void RenderMenuItem(UCogWindow& Window, const char* MenuItemName); + virtual void RenderMenuItem(FCogWindow& Window, const char* MenuItemName); virtual void RenderLoadLayoutMenuItem(const UPlayerInput* PlayerInput, int LayoutIndex); @@ -130,16 +145,10 @@ protected: void TickDPI(); UPROPERTY() - TArray Windows; + mutable TArray Configs; UPROPERTY() - TArray SpaceWindows; - - UPROPERTY() - UCogWindow_Settings* SettingsWindow = nullptr; - - UPROPERTY() - TArray MainMenuWidgets; + mutable TArray Assets; UPROPERTY(Config) bool bCompactMode = false; @@ -161,6 +170,14 @@ protected: TSharedPtr ImGuiWidget = nullptr; + TArray Windows; + + TArray SpaceWindows; + + FCogWindow_Settings* SettingsWindow = nullptr; + + TArray MainMenuWidgets; + FMenu MainMenu; int32 LayoutToLoad = -1; diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindow_Settings.h b/Plugins/Cog/Source/CogWindow/Public/CogWindow_Settings.h index a427e20..4ad0178 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindow_Settings.h +++ b/Plugins/Cog/Source/CogWindow/Public/CogWindow_Settings.h @@ -3,22 +3,17 @@ #include "CoreMinimal.h" #include "CogWindow.h" #include "CogImGuiKeyInfo.h" -#include "CogWindow_Settings.generated.h" - -UCLASS(Config = Cog) -class COGWINDOW_API UCogWindow_Settings : public UCogWindow +class COGWINDOW_API FCogWindow_Settings : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogWindow_Settings(); + virtual void Initialize() override; protected: - virtual void PostInitProperties() override; - virtual void RenderContent() override; private: diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindow_Spacing.h b/Plugins/Cog/Source/CogWindow/Public/CogWindow_Spacing.h index 9b924e3..15997a2 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindow_Spacing.h +++ b/Plugins/Cog/Source/CogWindow/Public/CogWindow_Spacing.h @@ -2,12 +2,10 @@ #include "CoreMinimal.h" #include "CogWindow.h" -#include "CogWindow_Spacing.generated.h" -UCLASS() -class COGWINDOW_API UCogWindow_Spacing : public UCogWindow +class COGWINDOW_API FCogWindow_Spacing : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: diff --git a/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_BehaviorTree.cpp b/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_BehaviorTree.cpp index edeed03..7f4a648 100644 --- a/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_BehaviorTree.cpp +++ b/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_BehaviorTree.cpp @@ -14,8 +14,19 @@ #include "GameFramework/Pawn.h" #include "imgui_internal.h" + //-------------------------------------------------------------------------------------------------------------------------- -void UCogAIWindow_BehaviorTree::RenderHelp() +void FCogAIWindow_BehaviorTree::Initialize() +{ + Super::Initialize(); + + bHasMenu = true; + + Config = GetConfig(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAIWindow_BehaviorTree::RenderHelp() { ImGui::Text( "This window displays the behavior tree of the selected actor. " @@ -23,13 +34,7 @@ void UCogAIWindow_BehaviorTree::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -UCogAIWindow_BehaviorTree::UCogAIWindow_BehaviorTree() -{ - bHasMenu = true; -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogAIWindow_BehaviorTree::GameTick(float DeltaTime) +void FCogAIWindow_BehaviorTree::GameTick(float DeltaTime) { Super::GameTick(DeltaTime); @@ -72,9 +77,9 @@ void UCogAIWindow_BehaviorTree::GameTick(float DeltaTime) if (i > 0) { - FCogDebugDraw::Arrow(LogCogAI, this, LastLocation, Location, FColor::White, false, 0); - FCogDebugDraw::Point(LogCogAI, this, LastLocation, 10.0f, FColor::White, false, 0); - FCogDebugDraw::Point(LogCogAI, this, Location, 10.0f, FColor::White, false, 0); + FCogDebugDraw::Arrow(LogCogAI, Pawn, LastLocation, Location, FColor::White, false, 0); + FCogDebugDraw::Point(LogCogAI, Pawn, LastLocation, 10.0f, FColor::White, false, 0); + FCogDebugDraw::Point(LogCogAI, Pawn, Location, 10.0f, FColor::White, false, 0); } LastLocation = Location; @@ -118,16 +123,22 @@ void UCogAIWindow_BehaviorTree::GameTick(float DeltaTime) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAIWindow_BehaviorTree::RenderContent() +void FCogAIWindow_BehaviorTree::RenderContent() { Super::RenderContent(); + if (Config == nullptr) + { + ImGui::TextDisabled("No Config"); + return; + } + if (ImGui::BeginMenuBar()) { if (ImGui::BeginMenu("Options")) { - ImGui::ColorEdit4("Active Color", (float*)&ActiveColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); - ImGui::ColorEdit4("Inactive Color", (float*)&InactiveColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); + ImGui::ColorEdit4("Active Color", (float*)&Config->ActiveColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); + ImGui::ColorEdit4("Inactive Color", (float*)&Config->InactiveColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); ImGui::EndMenu(); } @@ -206,7 +217,7 @@ void UCogAIWindow_BehaviorTree::RenderContent() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAIWindow_BehaviorTree::RenderNode(UBehaviorTreeComponent& BehaviorTreeComponent, UBTNode* Node, bool OpenAllChildren) +void FCogAIWindow_BehaviorTree::RenderNode(UBehaviorTreeComponent& BehaviorTreeComponent, UBTNode* Node, bool OpenAllChildren) { const char* NodeName = TCHAR_TO_ANSI(*Node->GetNodeName()); const bool ShowNode = Filter.PassFilter(NodeName); @@ -346,7 +357,7 @@ void UCogAIWindow_BehaviorTree::RenderNode(UBehaviorTreeComponent& BehaviorTreeC // Name //------------------------ ImGui::SameLine(); - const ImVec4 NameColor = IsActive ? FCogImguiHelper::ToImVec4(ActiveColor) : FCogImguiHelper::ToImVec4(InactiveColor); + const ImVec4 NameColor = IsActive ? FCogImguiHelper::ToImVec4(Config->ActiveColor) : FCogImguiHelper::ToImVec4(Config->InactiveColor); ImGui::TextColored(NameColor, "%s", NodeName); } diff --git a/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp b/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp index 041dda6..ec9197c 100644 --- a/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp +++ b/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp @@ -6,9 +6,18 @@ #include "GameFramework/Pawn.h" #include "BehaviorTree/BlackboardComponent.h" +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAIWindow_Blackboard::Initialize() +{ + Super::Initialize(); + + bHasMenu = true; + + Config = GetConfig(); +} //-------------------------------------------------------------------------------------------------------------------------- -void UCogAIWindow_Blackboard::RenderHelp() +void FCogAIWindow_Blackboard::RenderHelp() { ImGui::Text( "This window displays the blackboard of the selected actor. " @@ -16,22 +25,23 @@ void UCogAIWindow_Blackboard::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -UCogAIWindow_Blackboard::UCogAIWindow_Blackboard() +void FCogAIWindow_Blackboard::ResetConfig() { - bHasMenu = true; + Super::ResetConfig(); + + Config->Reset(); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAIWindow_Blackboard::RenderContent() +void FCogAIWindow_Blackboard::RenderContent() { Super::RenderContent(); - if (ImGui::BeginMenuBar()) { if (ImGui::BeginMenu("Options")) { - ImGui::Checkbox("Sort by name", &bSortByName); + ImGui::Checkbox("Sort by name", &Config->bSortByName); ImGui::EndMenu(); } @@ -96,7 +106,7 @@ void UCogAIWindow_Blackboard::RenderContent() Offset += It->Keys.Num(); } - if (bSortByName) + if (Config->bSortByName) { Keys.Sort([](const FBlackboardEntry& Key1, const FBlackboardEntry& Key2) { diff --git a/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_BehaviorTree.h b/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_BehaviorTree.h index 16bff43..e49fc80 100644 --- a/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_BehaviorTree.h +++ b/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_BehaviorTree.h @@ -2,19 +2,21 @@ #include "CoreMinimal.h" #include "CogWindow.h" +#include "CogWindowConfig.h" #include "CogAIWindow_BehaviorTree.generated.h" class UBehaviorTreeComponent; class UBTNode; +class UCogAIConfig_BehaviorTree; -UCLASS(Config = Cog) -class COGAI_API UCogAIWindow_BehaviorTree : public UCogWindow +//-------------------------------------------------------------------------------------------------------------------------- +class COGAI_API FCogAIWindow_BehaviorTree : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogAIWindow_BehaviorTree(); + virtual void Initialize() override; protected: @@ -28,11 +30,30 @@ protected: private: + ImGuiTextFilter Filter; + + TObjectPtr Config = nullptr; +}; + +//-------------------------------------------------------------------------------------------------------------------------- +UCLASS(Config = Cog) +class UCogAIConfig_BehaviorTree : public UCogWindowConfig +{ + GENERATED_BODY() + +public: + UPROPERTY(Config) FVector4f ActiveColor = FVector4f(1.0f, 1.0f, 1.0f, 1.0f); UPROPERTY(Config) FVector4f InactiveColor = FVector4f(1.0f, 1.0f, 1.0f, 0.2f); - ImGuiTextFilter Filter; -}; + virtual void Reset() override + { + Super::Reset(); + + ActiveColor = FVector4f(1.0f, 1.0f, 1.0f, 1.0f); + InactiveColor = FVector4f(1.0f, 1.0f, 1.0f, 0.2f); + } +}; \ No newline at end of file diff --git a/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_Blackboard.h b/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_Blackboard.h index a1e108b..5e844a9 100644 --- a/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_Blackboard.h +++ b/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_Blackboard.h @@ -2,27 +2,50 @@ #include "CoreMinimal.h" #include "CogWindow.h" +#include "CogWindowConfig.h" #include "CogAIWindow_Blackboard.generated.h" -UCLASS(Config = Cog) -class COGAI_API UCogAIWindow_Blackboard : public UCogWindow +class UCogAIConfig_Blackboard; + +//-------------------------------------------------------------------------------------------------------------------------- +class COGAI_API FCogAIWindow_Blackboard : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogAIWindow_Blackboard(); + virtual void Initialize() override; protected: - void RenderHelp(); + virtual void ResetConfig() override; + + virtual void RenderHelp() override; virtual void RenderContent() override; private: + ImGuiTextFilter Filter; + + TObjectPtr Config; +}; + +//-------------------------------------------------------------------------------------------------------------------------- +UCLASS(Config = Cog) +class UCogAIConfig_Blackboard : public UCogWindowConfig +{ + GENERATED_BODY() + +public: + UPROPERTY(Config) bool bSortByName = true; - ImGuiTextFilter Filter; -}; + virtual void Reset() override + { + Super::Reset(); + + bSortByName = true; + } +}; \ No newline at end of file diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityModule.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityModule.cpp index f7eaa4b..9c084fa 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityModule.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityModule.cpp @@ -1,7 +1,5 @@ #include "CogAbilityModule.h" -#include "CogAbilityReplicator.h" - #define LOCTEXT_NAMESPACE "FCogAbilityModule" //-------------------------------------------------------------------------------------------------------------------------- @@ -12,8 +10,9 @@ void FCogAbilityModule::StartupModule() //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityModule::ShutdownModule() { + } #undef LOCTEXT_NAMESPACE - + IMPLEMENT_MODULE(FCogAbilityModule, CogAbility) diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp index 15def05..7983d3f 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp @@ -12,7 +12,17 @@ #include "imgui_internal.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Abilities::RenderHelp() +void FCogAbilityWindow_Abilities::Initialize() +{ + Super::Initialize(); + + bHasMenu = true; + + Asset = GetAsset(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Abilities::RenderHelp() { ImGui::Text( "This window displays the gameplay abilities of the selected actor. " @@ -23,15 +33,7 @@ void UCogAbilityWindow_Abilities::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -UCogAbilityWindow_Abilities::UCogAbilityWindow_Abilities() -{ - bHasMenu = true; - - Asset = FCogWindowHelper::GetFirstAssetByClass(); -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Abilities::RenderTick(float DetlaTime) +void FCogAbilityWindow_Abilities::RenderTick(float DetlaTime) { Super::RenderTick(DetlaTime); @@ -39,7 +41,7 @@ void UCogAbilityWindow_Abilities::RenderTick(float DetlaTime) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Abilities::RenderOpenAbilities() +void FCogAbilityWindow_Abilities::RenderOpenAbilities() { AActor* Selection = GetSelection(); if (Selection == nullptr) @@ -84,7 +86,7 @@ void UCogAbilityWindow_Abilities::RenderOpenAbilities() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Abilities::RenderContent() +void FCogAbilityWindow_Abilities::RenderContent() { Super::RenderContent(); @@ -106,7 +108,7 @@ void UCogAbilityWindow_Abilities::RenderContent() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Abilities::RenderAbiltiesMenu(AActor* Selection) +void FCogAbilityWindow_Abilities::RenderAbiltiesMenu(AActor* Selection) { if (ImGui::BeginMenuBar()) { @@ -140,7 +142,7 @@ void UCogAbilityWindow_Abilities::RenderAbiltiesMenu(AActor* Selection) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent& AbilitySystemComponent) +void FCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent& AbilitySystemComponent) { TArray& Abilities = AbilitySystemComponent.GetActivatableAbilities(); @@ -253,7 +255,7 @@ void UCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent& } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Abilities::RenderAbilityCooldown(const UAbilitySystemComponent& AbilitySystemComponent, UGameplayAbility& Ability) +void FCogAbilityWindow_Abilities::RenderAbilityCooldown(const UAbilitySystemComponent& AbilitySystemComponent, UGameplayAbility& Ability) { FGameplayAbilitySpec* Spec = Ability.GetCurrentAbilitySpec(); @@ -275,7 +277,7 @@ void UCogAbilityWindow_Abilities::RenderAbilityCooldown(const UAbilitySystemComp } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Abilities::RenderAbilityContextMenu(UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec, int Index) +void FCogAbilityWindow_Abilities::RenderAbilityContextMenu(UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec, int Index) { if (ImGui::BeginPopupContextItem()) { @@ -303,19 +305,19 @@ void UCogAbilityWindow_Abilities::RenderAbilityContextMenu(UAbilitySystemCompone } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Abilities::OpenAbility(const FGameplayAbilitySpecHandle& Handle) +void FCogAbilityWindow_Abilities::OpenAbility(const FGameplayAbilitySpecHandle& Handle) { OpenedAbilities.AddUnique(Handle); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Abilities::CloseAbility(const FGameplayAbilitySpecHandle& Handle) +void FCogAbilityWindow_Abilities::CloseAbility(const FGameplayAbilitySpecHandle& Handle) { OpenedAbilities.Remove(Handle); } //-------------------------------------------------------------------------------------------------------------------------- -FString UCogAbilityWindow_Abilities::GetAbilityName(const UGameplayAbility* Ability) +FString FCogAbilityWindow_Abilities::GetAbilityName(const UGameplayAbility* Ability) { if (Ability == nullptr) { @@ -327,7 +329,7 @@ FString UCogAbilityWindow_Abilities::GetAbilityName(const UGameplayAbility* Abil } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Abilities::RenderAbilityInfo(const UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec) +void FCogAbilityWindow_Abilities::RenderAbilityInfo(const UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec) { UGameplayAbility* Ability = Spec.GetPrimaryInstance(); if (Ability == nullptr) @@ -438,7 +440,7 @@ void UCogAbilityWindow_Abilities::RenderAbilityInfo(const UAbilitySystemComponen } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Abilities::GameTick(float DeltaTime) +void FCogAbilityWindow_Abilities::GameTick(float DeltaTime) { if (AbilityHandleToActivate.IsValid()) { @@ -461,7 +463,7 @@ void UCogAbilityWindow_Abilities::GameTick(float DeltaTime) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Abilities::ProcessAbilityActivation(const FGameplayAbilitySpecHandle& Handle) +void FCogAbilityWindow_Abilities::ProcessAbilityActivation(const FGameplayAbilitySpecHandle& Handle) { AActor* Selection = GetSelection(); if (Selection == nullptr) @@ -492,14 +494,14 @@ void UCogAbilityWindow_Abilities::ProcessAbilityActivation(const FGameplayAbilit } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Abilities::ActivateAbility(UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec) +void FCogAbilityWindow_Abilities::ActivateAbility(UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec) { Spec.InputPressed = true; AbilitySystemComponent.TryActivateAbility(Spec.Handle); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Abilities::DeactivateAbility(UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec) +void FCogAbilityWindow_Abilities::DeactivateAbility(UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec) { Spec.InputPressed = false; AbilitySystemComponent.CancelAbilityHandle(Spec.Handle); diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp index b1de8d6..f11ba7f 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp @@ -12,7 +12,18 @@ #include "GameFramework/Character.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Attributes::RenderHelp() +void FCogAbilityWindow_Attributes::Initialize() +{ + Super::Initialize(); + + bHasMenu = true; + + Asset = GetAsset(); + Config = GetConfig(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Attributes::RenderHelp() { ImGui::Text( "This window displays the gameplay attributes of the selected actor. " @@ -24,26 +35,15 @@ void UCogAbilityWindow_Attributes::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -UCogAbilityWindow_Attributes::UCogAbilityWindow_Attributes() -{ - bHasMenu = true; - - Asset = FCogWindowHelper::GetFirstAssetByClass(); -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Attributes::ResetConfig() +void FCogAbilityWindow_Attributes::ResetConfig() { Super::ResetConfig(); - bSortByName = true; - bGroupByAttributeSet = false; - bGroupByCategory = false; - bShowOnlyModified = false; + Config->Reset(); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Attributes::RenderContent() +void FCogAbilityWindow_Attributes::RenderContent() { Super::RenderContent(); @@ -57,10 +57,10 @@ void UCogAbilityWindow_Attributes::RenderContent() { if (ImGui::BeginMenu("Options")) { - ImGui::Checkbox("Sort by name", &bSortByName); - ImGui::Checkbox("Group by attribute set", &bGroupByAttributeSet); - ImGui::Checkbox("Group by category", &bGroupByCategory); - ImGui::Checkbox("Show Only Modified", &bShowOnlyModified); + ImGui::Checkbox("Sort by name", &Config->SortByName); + ImGui::Checkbox("Group by attribute set", &Config->GroupByAttributeSet); + ImGui::Checkbox("Group by category", &Config->GroupByCategory); + ImGui::Checkbox("Show Only Modified", &Config->ShowOnlyModified); ImGui::EndMenu(); } @@ -69,8 +69,8 @@ void UCogAbilityWindow_Attributes::RenderContent() ImGui::EndMenuBar(); } - bool bGroupByAttributeSetValue = Filter.IsActive() == false && bShowOnlyModified == false && bGroupByAttributeSet; - bool bGroupByCategoryValue = Filter.IsActive() == false && bShowOnlyModified == false && bGroupByCategory; + bool bGroupByAttributeSetValue = Filter.IsActive() == false && Config->ShowOnlyModified == false && Config->GroupByAttributeSet; + bool bGroupByCategoryValue = Filter.IsActive() == false && Config->ShowOnlyModified == false && Config->GroupByCategory; if (ImGui::BeginTable("Attributes", 3, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable @@ -178,7 +178,7 @@ void UCogAbilityWindow_Attributes::RenderContent() //------------------------------------------------------------------------------------------ // Sort attributes within a category by their name //------------------------------------------------------------------------------------------ - if (bSortByName) + if (Config->SortByName) { AttributesInCategory.Sort([](const FGameplayAttribute& Lhs, const FGameplayAttribute& Rhs) { @@ -207,7 +207,7 @@ void UCogAbilityWindow_Attributes::RenderContent() const float BaseValue = AbilitySystemComponent->GetNumericAttributeBase(Attribute); const float CurrentValue = AbilitySystemComponent->GetNumericAttribute(Attribute); - if (bShowOnlyModified && FMath::IsNearlyEqual(CurrentValue, BaseValue)) + if (Config->ShowOnlyModified && FMath::IsNearlyEqual(CurrentValue, BaseValue)) { continue; } @@ -293,7 +293,7 @@ void UCogAbilityWindow_Attributes::RenderContent() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Attributes::DrawAttributeInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute) +void FCogAbilityWindow_Attributes::DrawAttributeInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute) { if (ImGui::BeginTable("Attribute", 2, ImGuiTableFlags_Borders)) { @@ -371,7 +371,7 @@ void UCogAbilityWindow_Attributes::DrawAttributeInfo(const UAbilitySystemCompone } //-------------------------------------------------------------------------------------------------------------------------- -ImVec4 UCogAbilityWindow_Attributes::GetAttributeColor(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute) const +ImVec4 FCogAbilityWindow_Attributes::GetAttributeColor(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute) const { const float BaseValue = AbilitySystemComponent.GetNumericAttributeBase(Attribute); const float CurrentValue = AbilitySystemComponent.GetNumericAttribute(Attribute); @@ -380,7 +380,7 @@ ImVec4 UCogAbilityWindow_Attributes::GetAttributeColor(const UAbilitySystemCompo } //-------------------------------------------------------------------------------------------------------------------------- -ImVec4 UCogAbilityWindow_Attributes::GetEffectModifierColor(const FModifierSpec& ModSpec, const FGameplayModifierInfo& ModInfo, float BaseValue) const +ImVec4 FCogAbilityWindow_Attributes::GetEffectModifierColor(const FModifierSpec& ModSpec, const FGameplayModifierInfo& ModInfo, float BaseValue) const { const float ModValue = ModSpec.GetEvaluatedMagnitude(); return FCogAbilityHelper::GetEffectModifierColor(Asset.Get(), ModSpec.GetEvaluatedMagnitude(), ModInfo.ModifierOp, BaseValue); diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp index 030691f..ecb5bdb 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp @@ -14,7 +14,18 @@ #include "imgui_internal.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Cheats::RenderHelp() +void FCogAbilityWindow_Cheats::Initialize() +{ + Super::Initialize(); + + bHasMenu = true; + + Asset = GetAsset(); + Config = GetConfig(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Cheats::RenderHelp() { ImGui::Text( "This window can be used to apply cheats to the selected actor (by default). " @@ -28,31 +39,15 @@ void UCogAbilityWindow_Cheats::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -UCogAbilityWindow_Cheats::UCogAbilityWindow_Cheats() -{ - bHasMenu = true; - - SetAsset(FCogWindowHelper::GetFirstAssetByClass()); -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Cheats::ResetConfig() +void FCogAbilityWindow_Cheats::ResetConfig() { Super::ResetConfig(); - bReapplyCheatsBetweenPlays = true; - bReapplyCheatsBetweenLaunches = true; + Config->Reset(); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Cheats::SetAsset(const UCogAbilityDataAsset* Value) -{ - Asset = Value; -} - - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Cheats::GameTick(float DeltaTime) +void FCogAbilityWindow_Cheats::GameTick(float DeltaTime) { Super::GameTick(DeltaTime); @@ -60,20 +55,25 @@ void UCogAbilityWindow_Cheats::GameTick(float DeltaTime) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Cheats::TryReapplyCheats() +void FCogAbilityWindow_Cheats::TryReapplyCheats() { + if (Config == nullptr) + { + return; + } + if (bHasReappliedCheats) { return; } - if (bReapplyCheatsBetweenPlays == false) + if (Config->bReapplyCheatsBetweenPlays == false) { return; } static int32 IsFirstLaunch = true; - if (IsFirstLaunch && bReapplyCheatsBetweenLaunches == false) + if (IsFirstLaunch && Config->bReapplyCheatsBetweenLaunches == false) { return; } @@ -98,7 +98,7 @@ void UCogAbilityWindow_Cheats::TryReapplyCheats() TArray Targets { LocalPawn }; - for (const FString& AppliedCheatName : AppliedCheats) + for (const FString& AppliedCheatName : Config->AppliedCheats) { if (const FCogAbilityCheat* Cheat = Asset->PersistentEffects.FindByPredicate( [AppliedCheatName](const FCogAbilityCheat& Cheat) { return Cheat.Name == AppliedCheatName; })) @@ -111,14 +111,20 @@ void UCogAbilityWindow_Cheats::TryReapplyCheats() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Cheats::RenderContent() +void FCogAbilityWindow_Cheats::RenderContent() { Super::RenderContent(); + if (Config == nullptr) + { + ImGui::Text("Invalid Config"); + return; + } + AActor* SelectedActor = GetSelection(); if (SelectedActor == nullptr) { - ImGui::Text("Invlid Selection"); + ImGui::Text("Invalid Selection"); return; } @@ -132,15 +138,15 @@ void UCogAbilityWindow_Cheats::RenderContent() { if (ImGui::BeginMenu("Options")) { - ImGui::Checkbox("Reapply Cheats Between Plays", &bReapplyCheatsBetweenPlays); + ImGui::Checkbox("Reapply Cheats Between Plays", &Config->bReapplyCheatsBetweenPlays); - if (bReapplyCheatsBetweenPlays == false) + if (Config->bReapplyCheatsBetweenPlays == false) { ImGui::BeginDisabled(); } - ImGui::Checkbox("Reapply Cheats Between Launches", &bReapplyCheatsBetweenLaunches); + ImGui::Checkbox("Reapply Cheats Between Launches", &Config->bReapplyCheatsBetweenLaunches); - if (bReapplyCheatsBetweenPlays == false) + if (Config->bReapplyCheatsBetweenPlays == false) { ImGui::EndDisabled(); } @@ -177,13 +183,13 @@ void UCogAbilityWindow_Cheats::RenderContent() //---------------------------------------------------------------- if (bHasChanged && SelectedActor == ControlledActor) { - AppliedCheats.Empty(); + Config->AppliedCheats.Empty(); for (const FCogAbilityCheat& CheatEffect : Asset->PersistentEffects) { if (ACogAbilityReplicator::IsCheatActive(SelectedActor, CheatEffect)) { - AppliedCheats.Add(CheatEffect.Name); + Config->AppliedCheats.Add(CheatEffect.Name); } } } @@ -203,7 +209,7 @@ void UCogAbilityWindow_Cheats::RenderContent() } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogAbilityWindow_Cheats::AddCheat(AActor* ControlledActor, AActor* SelectedActor, const FCogAbilityCheat& Cheat, bool IsPersistent) +bool FCogAbilityWindow_Cheats::AddCheat(AActor* ControlledActor, AActor* SelectedActor, const FCogAbilityCheat& Cheat, bool IsPersistent) { if (Cheat.Effect == nullptr) { @@ -268,7 +274,7 @@ bool UCogAbilityWindow_Cheats::AddCheat(AActor* ControlledActor, AActor* Selecte } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Cheats::RequestCheat(AActor* ControlledActor, AActor* SelectedActor, const FCogAbilityCheat& Cheat) +void FCogAbilityWindow_Cheats::RequestCheat(AActor* ControlledActor, AActor* SelectedActor, const FCogAbilityCheat& Cheat) { const bool IsShiftDown = (ImGui::GetCurrentContext()->IO.KeyMods & ImGuiMod_Shift) != 0; const bool IsAltDown = (ImGui::GetCurrentContext()->IO.KeyMods & ImGuiMod_Alt) != 0; diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp index 8046a9d..74f72d5 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp @@ -12,7 +12,17 @@ #include "GameFramework/Character.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Effects::RenderHelp() +void FCogAbilityWindow_Effects::Initialize() +{ + Super::Initialize(); + + bHasMenu = false; + + Asset = GetAsset(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Effects::RenderHelp() { ImGui::Text( "This window displays the gameplay effects of the selected actor. " @@ -21,15 +31,7 @@ void UCogAbilityWindow_Effects::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -UCogAbilityWindow_Effects::UCogAbilityWindow_Effects() -{ - bHasMenu = false; - - Asset = FCogWindowHelper::GetFirstAssetByClass(); -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Effects::RenderContent() +void FCogAbilityWindow_Effects::RenderContent() { Super::RenderContent(); @@ -37,7 +39,7 @@ void UCogAbilityWindow_Effects::RenderContent() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Effects::RenderEffectsTable() +void FCogAbilityWindow_Effects::RenderEffectsTable() { UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true); if (AbilitySystemComponent == nullptr) @@ -65,7 +67,7 @@ void UCogAbilityWindow_Effects::RenderEffectsTable() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Effects::RenderEffectRow(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffectHandle& ActiveHandle, int32 Index, int32& Selected) +void FCogAbilityWindow_Effects::RenderEffectRow(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffectHandle& ActiveHandle, int32 Index, int32& Selected) { ImGui::PushID(Index); @@ -146,7 +148,7 @@ void UCogAbilityWindow_Effects::RenderEffectRow(const UAbilitySystemComponent& A } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Effects::RenderEffectInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffect& ActiveEffect, const UGameplayEffect& Effect) +void FCogAbilityWindow_Effects::RenderEffectInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffect& ActiveEffect, const UGameplayEffect& Effect) { if (ImGui::BeginTable("Effect", 2, ImGuiTableFlags_Borders)) { @@ -265,7 +267,7 @@ void UCogAbilityWindow_Effects::RenderEffectInfo(const UAbilitySystemComponent& } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Effects::RenderTagContainer(const FGameplayTagContainer& Container) +void FCogAbilityWindow_Effects::RenderTagContainer(const FGameplayTagContainer& Container) { TArray GameplayTags; Container.GetGameplayTagArray(GameplayTags); @@ -276,14 +278,14 @@ void UCogAbilityWindow_Effects::RenderTagContainer(const FGameplayTagContainer& } //-------------------------------------------------------------------------------------------------------------------------- -FString UCogAbilityWindow_Effects::GetEffectName(const UGameplayEffect& Effect) +FString FCogAbilityWindow_Effects::GetEffectName(const UGameplayEffect& Effect) { FString Str = FCogAbilityHelper::CleanupName(Effect.GetName()); return Str; } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Effects::RenderRemainingTime(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffect& ActiveEffect) +void FCogAbilityWindow_Effects::RenderRemainingTime(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffect& ActiveEffect) { const float StartTime = ActiveEffect.StartWorldTime; const float Duration = ActiveEffect.GetDuration(); @@ -301,7 +303,7 @@ void UCogAbilityWindow_Effects::RenderRemainingTime(const UAbilitySystemComponen } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Effects::RenderStacks(const FActiveGameplayEffect& ActiveEffect, const UGameplayEffect& Effect) +void FCogAbilityWindow_Effects::RenderStacks(const FActiveGameplayEffect& ActiveEffect, const UGameplayEffect& Effect) { const int32 CurrentStackCount = ActiveEffect.Spec.StackCount; if (Effect.StackLimitCount <= 0) @@ -319,7 +321,7 @@ void UCogAbilityWindow_Effects::RenderStacks(const FActiveGameplayEffect& Active } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Effects::RenderPrediction(const FActiveGameplayEffect& ActiveEffect, bool Short) +void FCogAbilityWindow_Effects::RenderPrediction(const FActiveGameplayEffect& ActiveEffect, bool Short) { FString PredictionString; if (ActiveEffect.PredictionKey.IsValidKey()) @@ -342,13 +344,13 @@ void UCogAbilityWindow_Effects::RenderPrediction(const FActiveGameplayEffect& Ac } //-------------------------------------------------------------------------------------------------------------------------- -ImVec4 UCogAbilityWindow_Effects::GetEffectColor(const UGameplayEffect& Effect) const +ImVec4 FCogAbilityWindow_Effects::GetEffectColor(const UGameplayEffect& Effect) const { return FCogAbilityHelper::GetEffectColor(Asset.Get(), Effect); } //-------------------------------------------------------------------------------------------------------------------------- -ImVec4 UCogAbilityWindow_Effects::GetEffectModifierColor(const FModifierSpec& ModSpec, const FGameplayModifierInfo& ModInfo, float BaseValue) const +ImVec4 FCogAbilityWindow_Effects::GetEffectModifierColor(const FModifierSpec& ModSpec, const FGameplayModifierInfo& ModInfo, float BaseValue) const { const float ModValue = ModSpec.GetEvaluatedMagnitude(); return FCogAbilityHelper::GetEffectModifierColor(Asset.Get(), ModSpec.GetEvaluatedMagnitude(), ModInfo.ModifierOp, BaseValue); diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Pools.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Pools.cpp index f97588f..f2add4f 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Pools.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Pools.cpp @@ -9,13 +9,15 @@ #include "imgui_internal.h" //-------------------------------------------------------------------------------------------------------------------------- -UCogAbilityWindow_Pools::UCogAbilityWindow_Pools() +void FCogAbilityWindow_Pools::Initialize() { - Asset = FCogWindowHelper::GetFirstAssetByClass(); + Super::Initialize(); + + Asset = GetAsset(); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Pools::RenderHelp() +void FCogAbilityWindow_Pools::RenderHelp() { ImGui::Text( "This window displays attributes of the selected actor as pools. " @@ -25,7 +27,7 @@ void UCogAbilityWindow_Pools::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Pools::RenderContent() +void FCogAbilityWindow_Pools::RenderContent() { Super::RenderContent(); @@ -56,7 +58,7 @@ void UCogAbilityWindow_Pools::RenderContent() //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Pools::DrawPool(const UAbilitySystemComponent* AbilitySystemComponent, const FCogAbilityPool& Pool) +void FCogAbilityWindow_Pools::DrawPool(const UAbilitySystemComponent* AbilitySystemComponent, const FCogAbilityPool& Pool) { if (AbilitySystemComponent->HasAttributeSetForAttribute(Pool.Max) == false) { diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp index 934a5fb..2b454c9 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp @@ -6,19 +6,21 @@ #include "CogWindowWidgets.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Tags::RenderHelp() +void FCogAbilityWindow_Tags::Initialize() +{ + Super::Initialize(); + + bHasMenu = false; +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Tags::RenderHelp() { ImGui::Text("This window displays gameplay tags of the selected actor. "); } //-------------------------------------------------------------------------------------------------------------------------- -UCogAbilityWindow_Tags::UCogAbilityWindow_Tags() -{ - bHasMenu = false; -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Tags::RenderContent() +void FCogAbilityWindow_Tags::RenderContent() { Super::RenderContent(); @@ -36,7 +38,7 @@ void UCogAbilityWindow_Tags::RenderContent() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Tags::DrawTag(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayTag& Tag) +void FCogAbilityWindow_Tags::DrawTag(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayTag& Tag) { if (ImGui::BeginTable("Tag", 2, ImGuiTableFlags_Borders)) { @@ -94,7 +96,7 @@ void UCogAbilityWindow_Tags::DrawTag(const UAbilitySystemComponent& AbilitySyste } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Tags::DrawTagContainer(const FString& TagContainerName, const UAbilitySystemComponent& AbilitySystemComponent, FGameplayTagContainer& TagContainer) +void FCogAbilityWindow_Tags::DrawTagContainer(const FString& TagContainerName, const UAbilitySystemComponent& AbilitySystemComponent, FGameplayTagContainer& TagContainer) { if (ImGui::BeginTable(TCHAR_TO_ANSI(*TagContainerName), 2, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuterH | ImGuiTableFlags_BordersOuterV)) { diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tweaks.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tweaks.cpp index 452084f..99ca87c 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tweaks.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tweaks.cpp @@ -8,15 +8,17 @@ #include "CogWindowWidgets.h" //-------------------------------------------------------------------------------------------------------------------------- -UCogAbilityWindow_Tweaks::UCogAbilityWindow_Tweaks() +void FCogAbilityWindow_Tweaks::Initialize() { + Super::Initialize(); + bHasMenu = true; - Asset = FCogWindowHelper::GetFirstAssetByClass(); + Asset = GetAsset(); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Tweaks::RenderHelp() +void FCogAbilityWindow_Tweaks::RenderHelp() { ImGui::Text( "This window can be used to apply tweaks to all the loaded actors. " @@ -27,7 +29,7 @@ void UCogAbilityWindow_Tweaks::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Tweaks::RenderContent() +void FCogAbilityWindow_Tweaks::RenderContent() { Super::RenderContent(); @@ -124,7 +126,7 @@ void UCogAbilityWindow_Tweaks::RenderContent() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Tweaks::DrawTweak(ACogAbilityReplicator* Replicator, int32 TweakIndex, int32 TweakCategoryIndex) +void FCogAbilityWindow_Tweaks::DrawTweak(ACogAbilityReplicator* Replicator, int32 TweakIndex, int32 TweakCategoryIndex) { if (Asset->TweaksCategories.IsValidIndex(TweakCategoryIndex) == false) { diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityConfig.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityConfig.h new file mode 100644 index 0000000..daccc12 --- /dev/null +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityConfig.h @@ -0,0 +1,47 @@ +#pragma once + +//#include "CoreMinimal.h" +//#include "CogAbilityModule.h" +//#include "CogAbilityConfig.generated.h" +// +//USTRUCT() +//struct FCogAbilityAttributesConfig +//{ +// GENERATED_BODY() +// +//public: +// +// UPROPERTY(Config) +// bool SortByName = true; +// +// UPROPERTY(Config) +// bool GroupByAttributeSet = false; +// +// UPROPERTY(Config) +// bool GroupByCategory = false; +// +// UPROPERTY(Config) +// bool ShowOnlyModified = false; +// +// void Reset() +// { +// SortByName = true; +// GroupByAttributeSet = false; +// GroupByCategory = false; +// ShowOnlyModified = false; +// } +//}; +// +//UCLASS(Config = Cog) +//class COGABILITY_API UCogAbilityConfig : public UObject +//{ +// GENERATED_BODY() +// +//public: +// +// static inline UCogAbilityConfig* Get() { return FCogAbilityModule::Config; } +// +// UPROPERTY(Config) +// FCogAbilityAttributesConfig Attributes; +// +//}; diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityModule.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityModule.h index 4bce05e..e010a85 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityModule.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityModule.h @@ -11,7 +11,5 @@ public: /** IModuleInterface implementation */ virtual void StartupModule() override; - virtual void ShutdownModule() override; - }; diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Abilities.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Abilities.h index eb6bf70..89a0752 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Abilities.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Abilities.h @@ -3,24 +3,22 @@ #include "CoreMinimal.h" #include "CogWindow.h" #include "GameplayAbilitySpecHandle.h" -#include "CogAbilityWindow_Abilities.generated.h" class UAbilitySystemComponent; class UGameplayAbility; class UCogAbilityDataAsset; struct FGameplayAbilitySpec; -UCLASS() -class COGABILITY_API UCogAbilityWindow_Abilities : public UCogWindow +class COGABILITY_API FCogAbilityWindow_Abilities : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogAbilityWindow_Abilities(); + virtual void Initialize() override; protected: - + virtual void RenderHelp() override; virtual void RenderTick(float DetlaTime) override; @@ -61,6 +59,5 @@ private: TArray OpenedAbilities; - UPROPERTY() TObjectPtr Asset = nullptr; }; diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Attributes.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Attributes.h index f9990c2..6d50188 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Attributes.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Attributes.h @@ -2,6 +2,7 @@ #include "CoreMinimal.h" #include "CogWindow.h" +#include "CogWindowConfig.h" #include "CogAbilityWindow_Attributes.generated.h" class UAbilitySystemComponent; @@ -10,14 +11,14 @@ struct FGameplayAttribute; struct FModifierSpec; struct FGameplayModifierInfo; -UCLASS(Config = Cog) -class COGABILITY_API UCogAbilityWindow_Attributes : public UCogWindow +//-------------------------------------------------------------------------------------------------------------------------- +class COGABILITY_API FCogAbilityWindow_Attributes : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogAbilityWindow_Attributes(); + virtual void Initialize() override; protected: @@ -35,20 +36,40 @@ protected: private: - UPROPERTY(Config) - bool bSortByName = true; - - UPROPERTY(Config) - bool bGroupByAttributeSet = false; - - UPROPERTY(Config) - bool bGroupByCategory = false; - - UPROPERTY(Config) - bool bShowOnlyModified = false; - ImGuiTextFilter Filter; - UPROPERTY() TObjectPtr Asset = nullptr; + + TObjectPtr Config = nullptr; }; + +//-------------------------------------------------------------------------------------------------------------------------- +UCLASS(Config = Cog) +class UCogAbilityConfig_Attributes : public UCogWindowConfig +{ + GENERATED_BODY() + +public: + + UPROPERTY(Config) + bool SortByName = true; + + UPROPERTY(Config) + bool GroupByAttributeSet = false; + + UPROPERTY(Config) + bool GroupByCategory = false; + + UPROPERTY(Config) + bool ShowOnlyModified = false; + + virtual void Reset() override + { + Super::Reset(); + + SortByName = true; + GroupByAttributeSet = false; + GroupByCategory = false; + ShowOnlyModified = false; + } +}; \ No newline at end of file diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Cheats.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Cheats.h index 52021ea..88cc663 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Cheats.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Cheats.h @@ -2,24 +2,21 @@ #include "CoreMinimal.h" #include "CogWindow.h" +#include "CogWindowConfig.h" #include "CogAbilityWindow_Cheats.generated.h" class AActor; class UCogAbilityDataAsset; struct FCogAbilityCheat; -UCLASS(Config = Cog) -class COGABILITY_API UCogAbilityWindow_Cheats : public UCogWindow +//-------------------------------------------------------------------------------------------------------------------------- +class COGABILITY_API FCogAbilityWindow_Cheats : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogAbilityWindow_Cheats(); - - const UCogAbilityDataAsset* GetAsset() const { return Asset.Get(); } - - void SetAsset(const UCogAbilityDataAsset* Value); + virtual void Initialize() override; protected: @@ -37,6 +34,21 @@ protected: virtual void RequestCheat(AActor* ControlledActor, AActor* TargetActor, const FCogAbilityCheat& CheatEffect); + TObjectPtr Asset = nullptr; + + TObjectPtr Config = nullptr; + + bool bHasReappliedCheats = false; +}; + +//-------------------------------------------------------------------------------------------------------------------------- +UCLASS(Config = Cog) +class UCogAbilityConfig_Cheats : public UCogWindowConfig +{ + GENERATED_BODY() + +public: + UPROPERTY(Config) bool bReapplyCheatsBetweenPlays = true; @@ -46,8 +58,11 @@ protected: UPROPERTY(Config) TArray AppliedCheats; - UPROPERTY() - TObjectPtr Asset = nullptr; + virtual void Reset() override + { + Super::Reset(); - bool bHasReappliedCheats = false; + bReapplyCheatsBetweenPlays = true; + bReapplyCheatsBetweenLaunches = true; + } }; diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h index ccc740e..0c06385 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h @@ -4,7 +4,6 @@ #include "GameplayTagContainer.h" #include "CogWindow.h" #include "imgui.h" -#include "CogAbilityWindow_Effects.generated.h" class UAbilitySystemComponent; class UCogAbilityDataAsset; @@ -15,14 +14,14 @@ struct FGameplayModifierInfo; struct FModifierSpec; namespace EGameplayModOp { enum Type; }; -UCLASS() -class COGABILITY_API UCogAbilityWindow_Effects : public UCogWindow +//-------------------------------------------------------------------------------------------------------------------------- +class COGABILITY_API FCogAbilityWindow_Effects : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogAbilityWindow_Effects(); + virtual void Initialize() override; protected: @@ -50,6 +49,5 @@ protected: ImVec4 GetEffectModifierColor(const FModifierSpec& ModSpec, const FGameplayModifierInfo& ModInfo, float BaseValue) const; - UPROPERTY() TObjectPtr Asset = nullptr; }; diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Pools.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Pools.h index d4e68ca..bf66e8e 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Pools.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Pools.h @@ -3,20 +3,19 @@ #include "CoreMinimal.h" #include "GameplayTagContainer.h" #include "CogWindow.h" -#include "CogAbilityWindow_Pools.generated.h" class UCogAbilityDataAsset; class UAbilitySystemComponent; struct FCogAbilityPool; -UCLASS() -class COGABILITY_API UCogAbilityWindow_Pools : public UCogWindow +//-------------------------------------------------------------------------------------------------------------------------- +class COGABILITY_API FCogAbilityWindow_Pools : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - - UCogAbilityWindow_Pools(); + + virtual void Initialize() override; protected: @@ -26,6 +25,5 @@ protected: virtual void DrawPool(const UAbilitySystemComponent* AbilitySystemComponent, const FCogAbilityPool& Pool); - UPROPERTY() TObjectPtr Asset = nullptr; }; diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tags.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tags.h index 56e1bc2..53af4f7 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tags.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tags.h @@ -2,20 +2,19 @@ #include "CoreMinimal.h" #include "CogWindow.h" -#include "CogAbilityWindow_Tags.generated.h" class UAbilitySystemComponent; struct FGameplayTagContainer; struct FGameplayTag; -UCLASS() -class COGABILITY_API UCogAbilityWindow_Tags : public UCogWindow +//-------------------------------------------------------------------------------------------------------------------------- +class COGABILITY_API FCogAbilityWindow_Tags : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogAbilityWindow_Tags(); + virtual void Initialize() override; protected: diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tweaks.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tweaks.h index 39af65a..d84c04c 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tweaks.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tweaks.h @@ -2,19 +2,18 @@ #include "CoreMinimal.h" #include "CogWindow.h" -#include "CogAbilityWindow_Tweaks.generated.h" class ACogAbilityReplicator; class UCogAbilityDataAsset; -UCLASS() -class COGABILITY_API UCogAbilityWindow_Tweaks : public UCogWindow +//-------------------------------------------------------------------------------------------------------------------------- +class COGABILITY_API FCogAbilityWindow_Tweaks : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogAbilityWindow_Tweaks(); + virtual void Initialize() override; protected: @@ -26,6 +25,5 @@ protected: private: - UPROPERTY() TObjectPtr Asset = nullptr; }; diff --git a/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Actions.cpp b/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Actions.cpp index 820d7d7..7a32b3c 100644 --- a/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Actions.cpp +++ b/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Actions.cpp @@ -10,7 +10,18 @@ #include "InputMappingContext.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogInputWindow_Actions::RenderHelp() +void FCogInputWindow_Actions::Initialize() +{ + Super::Initialize(); + + bHasMenu = true; + + Asset = GetAsset(); + Config = GetConfig(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogInputWindow_Actions::RenderHelp() { ImGui::Text( "This window displays the current state of each Input Action. " @@ -21,21 +32,15 @@ void UCogInputWindow_Actions::RenderHelp() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogInputWindow_Actions::ResetConfig() +void FCogInputWindow_Actions::ResetConfig() { - RepeatPeriod = 0.5f; + Super::ResetConfig(); + + Config->Reset(); } //-------------------------------------------------------------------------------------------------------------------------- -UCogInputWindow_Actions::UCogInputWindow_Actions() -{ - bHasMenu = true; - - Asset = FCogWindowHelper::GetFirstAssetByClass(); -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogInputWindow_Actions::RenderContent() +void FCogInputWindow_Actions::RenderContent() { Super::RenderContent(); @@ -63,7 +68,7 @@ void UCogInputWindow_Actions::RenderContent() { if (ImGui::BeginMenu("Options")) { - ImGui::SliderFloat("##Repeat", &RepeatPeriod, 0.1f, 10.0f, "Repeat: %0.1fs"); + ImGui::SliderFloat("##Repeat", &Config->RepeatPeriod, 0.1f, 10.0f, "Repeat: %0.1fs"); ImGui::EndMenu(); } @@ -173,7 +178,7 @@ void UCogInputWindow_Actions::RenderContent() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogInputWindow_Actions::RenderTick(float DeltaSeconds) +void FCogInputWindow_Actions::RenderTick(float DeltaSeconds) { Super::RenderTick(DeltaSeconds); @@ -198,7 +203,7 @@ void UCogInputWindow_Actions::RenderTick(float DeltaSeconds) float WorldTime = GetWorld()->GetTimeSeconds(); if (RepeatTime < WorldTime) { - RepeatTime = WorldTime + RepeatPeriod; + RepeatTime = WorldTime + Config->RepeatPeriod; IsTimeToRepeat = true; } @@ -209,7 +214,7 @@ void UCogInputWindow_Actions::RenderTick(float DeltaSeconds) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogInputWindow_Actions::DrawAxis(const char* Format, const char* ActionName, float CurrentValue, float* InjectValue) +void FCogInputWindow_Actions::DrawAxis(const char* Format, const char* ActionName, float CurrentValue, float* InjectValue) { ImGui::PushID(Format); ImGui::TableNextRow(); diff --git a/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Gamepad.cpp b/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Gamepad.cpp index 4370ebc..66c1d62 100644 --- a/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Gamepad.cpp +++ b/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Gamepad.cpp @@ -10,15 +10,18 @@ #include "InputMappingContext.h" //-------------------------------------------------------------------------------------------------------------------------- -UCogInputWindow_Gamepad::UCogInputWindow_Gamepad() +void FCogInputWindow_Gamepad::Initialize() { - Asset = FCogWindowHelper::GetFirstAssetByClass(); + Super::Initialize(); + + Asset = GetAsset(); + Config = GetConfig(); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogInputWindow_Gamepad::PreRender(ImGuiWindowFlags& WindowFlags) +void FCogInputWindow_Gamepad::PreRender(ImGuiWindowFlags& WindowFlags) { - if (bShowAsOverlay) + if (Config->bShowAsOverlay) { WindowFlags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar @@ -29,24 +32,18 @@ void UCogInputWindow_Gamepad::PreRender(ImGuiWindowFlags& WindowFlags) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogInputWindow_Gamepad::ResetConfig() +void FCogInputWindow_Gamepad::ResetConfig() { Super::ResetConfig(); - bShowAsOverlay = false; - bInvertRightStickY = false; - bInvertLeftStickY = false; - BackgroundColor = FVector4f(0.03f, 0.03f, 0.03f, 1.0f); - ButtonColor = FVector4f(0.2f, 0.2f, 0.2f, 1.0f); - BorderColor = FVector4f(0.03f, 0.03f, 0.03f, 1.0f); - PressedColor = FVector4f(0.6f, 0.6f, 0.6f, 1.0f); - HoveredColor = FVector4f(0.3f, 0.3f, 0.3f, 1.0f); - InjectColor = FVector4f(1.0f, 0.5f, 0.0f, 0.5f); - Border = 0.02f; + if (Config != nullptr) + { + Config->Reset(); + } } //-------------------------------------------------------------------------------------------------------------------------- -void UCogInputWindow_Gamepad::InputContextMenu(const FKey& Key, FCogInjectActionInfo* ActionInfoButton, FCogInjectActionInfo* ActionInfo2D) +void FCogInputWindow_Gamepad::InputContextMenu(const FKey& Key, FCogInjectActionInfo* ActionInfoButton, FCogInjectActionInfo* ActionInfo2D) { if (ImGui::BeginPopupContextItem()) { @@ -57,7 +54,7 @@ void UCogInputWindow_Gamepad::InputContextMenu(const FKey& Key, FCogInjectAction { ImGui::Checkbox("Pressed", &ActionInfoButton->bPressed); ImGui::Checkbox("Repeat", &ActionInfoButton->bRepeat); - FCogWindowWidgets::SliderWithReset("Period", &RepeatPeriod, 0.0f, 10.0f, 0.5f, "%0.1fs"); + FCogWindowWidgets::SliderWithReset("Period", &Config->RepeatPeriod, 0.0f, 10.0f, 0.5f, "%0.1fs"); } if (ActionInfoButton != nullptr && ActionInfoButton->Action != nullptr && ActionInfoButton->Action->ValueType == EInputActionValueType::Axis1D) @@ -76,7 +73,7 @@ void UCogInputWindow_Gamepad::InputContextMenu(const FKey& Key, FCogInjectAction } //-------------------------------------------------------------------------------------------------------------------------- -void UCogInputWindow_Gamepad::OnButtonClicked(FCogInjectActionInfo* ActionInfo) +void FCogInputWindow_Gamepad::OnButtonClicked(FCogInjectActionInfo* ActionInfo) { if (ActionInfo == nullptr) { @@ -99,7 +96,7 @@ void UCogInputWindow_Gamepad::OnButtonClicked(FCogInjectActionInfo* ActionInfo) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogInputWindow_Gamepad::AddButton(const FKey& Key, const ImVec2& RelativePosition, const ImVec2& RelativeSize, const ImVec2& Alignment, float RelativeRounding, ImDrawFlags Flags) +void FCogInputWindow_Gamepad::AddButton(const FKey& Key, const ImVec2& RelativePosition, const ImVec2& RelativeSize, const ImVec2& Alignment, float RelativeRounding, ImDrawFlags Flags) { ImGui::PushID((void*)(&Key)); @@ -127,23 +124,23 @@ void UCogInputWindow_Gamepad::AddButton(const FKey& Key, const ImVec2& RelativeP OnButtonClicked(ActionInfo); } - ImU32 Color = FCogImguiHelper::ToImU32(ButtonColor); + ImU32 Color = FCogImguiHelper::ToImU32(Config->ButtonColor); if (IsPressed) { - Color = FCogImguiHelper::ToImU32(PressedColor); + Color = FCogImguiHelper::ToImU32(Config->PressedColor); } else if (ImGui::IsItemHovered()) { - Color = FCogImguiHelper::ToImU32(HoveredColor); + Color = FCogImguiHelper::ToImU32(Config->HoveredColor); } InputContextMenu(Key, ActionInfo, nullptr); - if (Border > 0.0f) + if (Config->Border > 0.0f) { const bool Inject = ActionInfo != nullptr && (ActionInfo->bPressed || ActionInfo->bRepeat); - const ImU32 BColor = Inject ? FCogImguiHelper::ToImU32(InjectColor) : FCogImguiHelper::ToImU32(BorderColor); - DrawList->AddRect(Position, Position + Size, BColor, RelativeRounding * CanvasSize.x, Flags, Border * CanvasSize.x); + const ImU32 BColor = Inject ? FCogImguiHelper::ToImU32(Config->InjectColor) : FCogImguiHelper::ToImU32(Config->BorderColor); + DrawList->AddRect(Position, Position + Size, BColor, RelativeRounding * CanvasSize.x, Flags, Config->Border * CanvasSize.x); } DrawList->AddRectFilled(Position, Position + Size, Color, RelativeRounding * CanvasSize.x, Flags); @@ -152,7 +149,7 @@ void UCogInputWindow_Gamepad::AddButton(const FKey& Key, const ImVec2& RelativeP } //-------------------------------------------------------------------------------------------------------------------------- -void UCogInputWindow_Gamepad::AddStick(const FKey& Key2D, const FKey& KeyBool, bool InvertY, float RelativeAmplitude, const ImVec2& RelativePosition, float RelativeRadius) +void FCogInputWindow_Gamepad::AddStick(const FKey& Key2D, const FKey& KeyBool, bool InvertY, float RelativeAmplitude, const ImVec2& RelativePosition, float RelativeRadius) { ImGui::PushID((void*)(&Key2D)); @@ -179,23 +176,23 @@ void UCogInputWindow_Gamepad::AddStick(const FKey& Key2D, const FKey& KeyBool, b OnButtonClicked(ActionInfoBool); } - ImU32 Color = FCogImguiHelper::ToImU32(ButtonColor); + ImU32 Color = FCogImguiHelper::ToImU32(Config->ButtonColor); if (Input->GetKeyValue(KeyBool) > 0.0f) { - Color = FCogImguiHelper::ToImU32(PressedColor); + Color = FCogImguiHelper::ToImU32(Config->PressedColor); } else if (ImGui::IsItemHovered()) { - Color = FCogImguiHelper::ToImU32(HoveredColor); + Color = FCogImguiHelper::ToImU32(Config->HoveredColor); } InputContextMenu(Key2D, ActionInfoBool, ActionInfo2D); - if (Border > 0.0f) + if (Config->Border > 0.0f) { const bool Inject = ActionInfoBool != nullptr && (ActionInfoBool->bPressed || ActionInfoBool->bRepeat); - const ImU32 BColor = Inject ? FCogImguiHelper::ToImU32(InjectColor) : FCogImguiHelper::ToImU32(BorderColor); - DrawList->AddCircle(StickPosition, Radius, BColor, 0, Border * CanvasSize.x); + const ImU32 BColor = Inject ? FCogImguiHelper::ToImU32(Config->InjectColor) : FCogImguiHelper::ToImU32(Config->BorderColor); + DrawList->AddCircle(StickPosition, Radius, BColor, 0, Config->Border * CanvasSize.x); } DrawList->AddCircleFilled(StickPosition, Radius, Color); @@ -205,7 +202,7 @@ void UCogInputWindow_Gamepad::AddStick(const FKey& Key2D, const FKey& KeyBool, b //-------------------------------------------------------------------------------------------------------------------------- -void UCogInputWindow_Gamepad::RenderContent() +void FCogInputWindow_Gamepad::RenderContent() { Super::RenderContent(); @@ -306,33 +303,33 @@ void UCogInputWindow_Gamepad::RenderContent() const ImVec2 ContentMin = ImGui::GetCursorScreenPos(); const ImVec2 ContentSize = ImGui::GetContentRegionAvail(); const ImVec2 ContentMax = ContentMin + ContentSize; - const ImVec2 OverlayOffset = ImVec2(0.0f, bShowAsOverlay ? ImGui::GetFrameHeight() : 0.0f); + const ImVec2 OverlayOffset = ImVec2(0.0f, Config->bShowAsOverlay ? ImGui::GetFrameHeight() : 0.0f); - const ImVec2 Padding = ImVec2(Border * 0.5f * ContentSize.x, Border * 0.5f * ContentSize.x); + const ImVec2 Padding = ImVec2(Config->Border * 0.5f * ContentSize.x, Config->Border * 0.5f * ContentSize.x); CanvasMin = ContentMin + OverlayOffset + Padding; CanvasSize = ImVec2(FMath::Max(ContentSize.x, 50.0f), ContentSize.x * AspectRatio) - (Padding * 2); CanvasMax = CanvasMin + CanvasSize + OverlayOffset; DrawList = ImGui::GetWindowDrawList(); - ImGui::Dummy(bShowAsOverlay ? CanvasMax - CanvasMin : ContentSize); + ImGui::Dummy(Config->bShowAsOverlay ? CanvasMax - CanvasMin : ContentSize); if (ImGui::BeginPopupContextItem("Gamepad")) { if (ImGui::Button("Close", ImVec2(-1.0f, 0))) { SetIsVisible(false); } - ImGui::Checkbox("Overlay", &bShowAsOverlay); + ImGui::Checkbox("Overlay", &Config->bShowAsOverlay); ImGui::Separator(); - ImGui::Checkbox("Invert Left Stick Y", &bInvertLeftStickY); - ImGui::Checkbox("Invert Right Stick Y", &bInvertRightStickY); + ImGui::Checkbox("Invert Left Stick Y", &Config->bInvertLeftStickY); + ImGui::Checkbox("Invert Right Stick Y", &Config->bInvertRightStickY); ImGui::Separator(); - ImGui::ColorEdit4("Background Color", (float*)&BackgroundColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); - ImGui::ColorEdit4("Border Color", (float*)&BorderColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); - ImGui::ColorEdit4("Button Color", (float*)&ButtonColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); - ImGui::ColorEdit4("Pressed Color", (float*)&PressedColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); - ImGui::ColorEdit4("Hovered Color", (float*)&HoveredColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); - ImGui::ColorEdit4("Inject Color", (float*)&InjectColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); - FCogWindowWidgets::SliderWithReset("Border", &Border, 0.0f, 0.1f, 0.02f, "%0.3f"); + ImGui::ColorEdit4("Background Color", (float*)&Config->BackgroundColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); + ImGui::ColorEdit4("Border Color", (float*)&Config->BorderColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); + ImGui::ColorEdit4("Button Color", (float*)&Config->ButtonColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); + ImGui::ColorEdit4("Pressed Color", (float*)&Config->PressedColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); + ImGui::ColorEdit4("Hovered Color", (float*)&Config->HoveredColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); + ImGui::ColorEdit4("Inject Color", (float*)&Config->InjectColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); + FCogWindowWidgets::SliderWithReset("Border", &Config->Border, 0.0f, 0.1f, 0.02f, "%0.3f"); ImGui::EndPopup(); } @@ -356,28 +353,28 @@ void UCogInputWindow_Gamepad::RenderContent() //------------------------------ // Gamepad //------------------------------ - if (Border > 0.0f) + if (Config->Border > 0.0f) { - DrawList->AddRect(CanvasMin + CanvasSize * ImVec2(0.0f, 0.16f), CanvasMin + CanvasSize * ImVec2(1.0f, 0.7f), FCogImguiHelper::ToImU32(BorderColor), GamepadRound * CanvasSize.x, 0, Border * CanvasSize.x); - DrawList->AddRect(CanvasMin + CanvasSize * ImVec2(0.0f, 0.16f), CanvasMin + CanvasSize * ImVec2(HandleWidth, 1.0f), FCogImguiHelper::ToImU32(BorderColor), GamepadRound * CanvasSize.x, 0, Border * CanvasSize.x); - DrawList->AddRect(CanvasMin + CanvasSize * ImVec2(1.0f - HandleWidth, 0.16f), CanvasMin + CanvasSize * ImVec2(1.0f, 1.0f), FCogImguiHelper::ToImU32(BorderColor), GamepadRound * CanvasSize.x, 0, Border * CanvasSize.x); + DrawList->AddRect(CanvasMin + CanvasSize * ImVec2(0.0f, 0.16f), CanvasMin + CanvasSize * ImVec2(1.0f, 0.7f), FCogImguiHelper::ToImU32(Config->BorderColor), GamepadRound * CanvasSize.x, 0, Config->Border * CanvasSize.x); + DrawList->AddRect(CanvasMin + CanvasSize * ImVec2(0.0f, 0.16f), CanvasMin + CanvasSize * ImVec2(HandleWidth, 1.0f), FCogImguiHelper::ToImU32(Config->BorderColor), GamepadRound * CanvasSize.x, 0, Config->Border * CanvasSize.x); + DrawList->AddRect(CanvasMin + CanvasSize * ImVec2(1.0f - HandleWidth, 0.16f), CanvasMin + CanvasSize * ImVec2(1.0f, 1.0f), FCogImguiHelper::ToImU32(Config->BorderColor), GamepadRound * CanvasSize.x, 0, Config->Border * CanvasSize.x); - DrawList->AddCircle(CanvasMin + CanvasSize * LS_Pos, StickBaseRadius* CanvasSize.x, FCogImguiHelper::ToImU32(BorderColor), 0, Border* CanvasSize.x); - DrawList->AddCircle(CanvasMin + CanvasSize * RS_Pos, StickBaseRadius* CanvasSize.x, FCogImguiHelper::ToImU32(BorderColor), 0, Border* CanvasSize.x); + DrawList->AddCircle(CanvasMin + CanvasSize * LS_Pos, StickBaseRadius* CanvasSize.x, FCogImguiHelper::ToImU32(Config->BorderColor), 0, Config->Border * CanvasSize.x); + DrawList->AddCircle(CanvasMin + CanvasSize * RS_Pos, StickBaseRadius* CanvasSize.x, FCogImguiHelper::ToImU32(Config->BorderColor), 0, Config->Border * CanvasSize.x); } - DrawList->AddRectFilled(CanvasMin + CanvasSize * ImVec2(0.0f, 0.16f), CanvasMin + CanvasSize * ImVec2(1.0f, 0.7f), FCogImguiHelper::ToImU32(BackgroundColor), GamepadRound * CanvasSize.x); - DrawList->AddRectFilled(CanvasMin + CanvasSize * ImVec2(0.0f, 0.16f), CanvasMin + CanvasSize * ImVec2(HandleWidth, 1.0f), FCogImguiHelper::ToImU32(BackgroundColor), GamepadRound * CanvasSize.x); - DrawList->AddRectFilled(CanvasMin + CanvasSize * ImVec2(1.0f - HandleWidth, 0.16f), CanvasMin + CanvasSize * ImVec2(1.0f, 1.0f), FCogImguiHelper::ToImU32(BackgroundColor), GamepadRound * CanvasSize.x); + DrawList->AddRectFilled(CanvasMin + CanvasSize * ImVec2(0.0f, 0.16f), CanvasMin + CanvasSize * ImVec2(1.0f, 0.7f), FCogImguiHelper::ToImU32(Config->BackgroundColor), GamepadRound * CanvasSize.x); + DrawList->AddRectFilled(CanvasMin + CanvasSize * ImVec2(0.0f, 0.16f), CanvasMin + CanvasSize * ImVec2(HandleWidth, 1.0f), FCogImguiHelper::ToImU32(Config->BackgroundColor), GamepadRound * CanvasSize.x); + DrawList->AddRectFilled(CanvasMin + CanvasSize * ImVec2(1.0f - HandleWidth, 0.16f), CanvasMin + CanvasSize * ImVec2(1.0f, 1.0f), FCogImguiHelper::ToImU32(Config->BackgroundColor), GamepadRound * CanvasSize.x); - DrawList->AddCircleFilled(CanvasMin + CanvasSize * LS_Pos, StickBaseRadius* CanvasSize.x, FCogImguiHelper::ToImU32(BackgroundColor)); - DrawList->AddCircleFilled(CanvasMin + CanvasSize * RS_Pos, StickBaseRadius* CanvasSize.x, FCogImguiHelper::ToImU32(BackgroundColor)); + DrawList->AddCircleFilled(CanvasMin + CanvasSize * LS_Pos, StickBaseRadius* CanvasSize.x, FCogImguiHelper::ToImU32(Config->BackgroundColor)); + DrawList->AddCircleFilled(CanvasMin + CanvasSize * RS_Pos, StickBaseRadius* CanvasSize.x, FCogImguiHelper::ToImU32(Config->BackgroundColor)); //------------------------------ // Sticks //------------------------------ - AddStick(EKeys::Gamepad_Left2D, EKeys::Gamepad_LeftThumbstick, bInvertLeftStickY, StickAmplitude, LS_Pos, StickRadius); - AddStick(EKeys::Gamepad_Right2D, EKeys::Gamepad_RightThumbstick, bInvertRightStickY, StickAmplitude, RS_Pos, StickRadius); + AddStick(EKeys::Gamepad_Left2D, EKeys::Gamepad_LeftThumbstick, Config->bInvertLeftStickY, StickAmplitude, LS_Pos, StickRadius); + AddStick(EKeys::Gamepad_Right2D, EKeys::Gamepad_RightThumbstick, Config->bInvertRightStickY, StickAmplitude, RS_Pos, StickRadius); //------------------------------ // DPad Buttons @@ -407,7 +404,7 @@ void UCogInputWindow_Gamepad::RenderContent() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogInputWindow_Gamepad::RenderTick(float DeltaSeconds) +void FCogInputWindow_Gamepad::RenderTick(float DeltaSeconds) { Super::RenderTick(DeltaSeconds); @@ -432,7 +429,7 @@ void UCogInputWindow_Gamepad::RenderTick(float DeltaSeconds) float WorldTime = GetWorld()->GetTimeSeconds(); if (RepeatTime < WorldTime) { - RepeatTime = WorldTime + RepeatPeriod; + RepeatTime = WorldTime + Config->RepeatPeriod; IsTimeToRepeat = true; } diff --git a/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Actions.h b/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Actions.h index 151fc42..b751de8 100644 --- a/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Actions.h +++ b/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Actions.h @@ -1,21 +1,23 @@ #pragma once #include "CoreMinimal.h" -#include "CogWindow.h" #include "CogInjectActionInfo.h" +#include "CogWindow.h" +#include "CogWindowConfig.h" #include "CogInputWindow_Actions.generated.h" class UInputAction; +class UCogInputConfig_Actions; class UCogInputDataAsset; -UCLASS(Config = Cog) -class COGINPUT_API UCogInputWindow_Actions : public UCogWindow +//-------------------------------------------------------------------------------------------------------------------------- +class COGINPUT_API FCogInputWindow_Actions : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogInputWindow_Actions(); + virtual void Initialize() override; protected: @@ -31,13 +33,30 @@ protected: private: - UPROPERTY(Config) - float RepeatPeriod = 0.5f; - float RepeatTime = 0.0f; - UPROPERTY() TObjectPtr Asset = nullptr; + TObjectPtr Config = nullptr; + TArray Actions; }; + +//-------------------------------------------------------------------------------------------------------------------------- +UCLASS(Config = Cog) +class UCogInputConfig_Actions : public UCogWindowConfig +{ + GENERATED_BODY() + +public: + + UPROPERTY(Config) + float RepeatPeriod = 0.5f; + + virtual void Reset() override + { + Super::Reset(); + + RepeatPeriod = 0.5f; + } +}; \ No newline at end of file diff --git a/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Gamepad.h b/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Gamepad.h index 8a65c5b..c2b30a8 100644 --- a/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Gamepad.h +++ b/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Gamepad.h @@ -3,20 +3,22 @@ #include "CoreMinimal.h" #include "CogInjectActionInfo.h" #include "CogWindow.h" +#include "CogWindowConfig.h" #include "CogInputWindow_Gamepad.generated.h" class UEnhancedPlayerInput; +class UCogInputConfig_Gamepad; class UCogInputDataAsset; struct ImDrawList; -UCLASS(Config = Cog) -class COGINPUT_API UCogInputWindow_Gamepad : public UCogWindow +//-------------------------------------------------------------------------------------------------------------------------- +class COGINPUT_API FCogInputWindow_Gamepad : public FCogWindow { - GENERATED_BODY() + typedef FCogWindow Super; public: - UCogInputWindow_Gamepad(); + virtual void Initialize() override; protected: @@ -38,6 +40,33 @@ private: void OnButtonClicked(FCogInjectActionInfo* ActionInfo); + TObjectPtr Asset; + + TObjectPtr Config; + + TMap Actions; + + UEnhancedPlayerInput* Input = nullptr; + + ImDrawList* DrawList = nullptr; + + float RepeatTime = 0.0f; + + ImVec2 CanvasMin; + + ImVec2 CanvasSize; + + ImVec2 CanvasMax; +}; + +//-------------------------------------------------------------------------------------------------------------------------- +UCLASS(Config = Cog) +class UCogInputConfig_Gamepad : public UCogWindowConfig +{ + GENERATED_BODY() + +public: + UPROPERTY(Config) bool bShowAsOverlay = false; @@ -71,20 +100,20 @@ private: UPROPERTY(Config) float RepeatPeriod = 0.5f; - UPROPERTY() - TObjectPtr Asset; - - TMap Actions; - - UEnhancedPlayerInput* Input = nullptr; - - ImDrawList* DrawList = nullptr; - - float RepeatTime = 0.0f; - - ImVec2 CanvasMin; - - ImVec2 CanvasSize; - - ImVec2 CanvasMax; -}; + virtual void Reset() override + { + Super::Reset(); + + bShowAsOverlay = false; + bInvertRightStickY = false; + bInvertLeftStickY = false; + BackgroundColor = FVector4f(0.03f, 0.03f, 0.03f, 1.0f); + ButtonColor = FVector4f(0.2f, 0.2f, 0.2f, 1.0f); + BorderColor = FVector4f(0.03f, 0.03f, 0.03f, 1.0f); + PressedColor = FVector4f(0.6f, 0.6f, 0.6f, 1.0f); + HoveredColor = FVector4f(0.3f, 0.3f, 0.3f, 1.0f); + InjectColor = FVector4f(1.0f, 0.5f, 0.0f, 0.5f); + Border = 0.02f; + RepeatPeriod = 0.5f; + } +}; \ No newline at end of file diff --git a/Source/CogSample/CogSampleGameState.cpp b/Source/CogSample/CogSampleGameState.cpp index 4344685..5d3b1c6 100644 --- a/Source/CogSample/CogSampleGameState.cpp +++ b/Source/CogSample/CogSampleGameState.cpp @@ -118,15 +118,15 @@ void ACogSampleGameState::InitializeCog() //--------------------------------------- // Engine //--------------------------------------- - CogWindowManager->CreateWindow("Engine.Collision"); + CogWindowManager->CreateWindow("Engine.Collision"); - CogWindowManager->CreateWindow("Engine.Command Bindings"); + CogWindowManager->CreateWindow("Engine.Command Bindings"); - CogWindowManager->CreateWindow("Engine.Debug Settings"); + CogWindowManager->CreateWindow("Engine.Debug Settings"); - CogWindowManager->CreateWindow("Engine.ImGui"); + CogWindowManager->CreateWindow("Engine.ImGui"); - UCogEngineWindow_Inspector* Inspector = CogWindowManager->CreateWindow("Engine.Inspector"); + FCogEngineWindow_Inspector* Inspector = CogWindowManager->CreateWindow("Engine.Inspector"); Inspector->AddFavorite(GEngine->GetGameUserSettings(), [](UObject* Object) { if (UGameUserSettings* UserSettings = Cast(Object)) @@ -135,65 +135,65 @@ void ACogSampleGameState::InitializeCog() } }); - CogWindowManager->CreateWindow("Engine.Log Categories"); + CogWindowManager->CreateWindow("Engine.Log Categories"); - CogWindowManager->CreateWindow("Engine.Net Emulation"); + CogWindowManager->CreateWindow("Engine.Net Emulation"); - CogWindowManager->CreateWindow("Engine.Output Log"); + CogWindowManager->CreateWindow("Engine.Output Log"); - CogWindowManager->CreateWindow("Engine.Metrics"); + CogWindowManager->CreateWindow("Engine.Metrics"); - CogWindowManager->CreateWindow("Engine.Plots"); + CogWindowManager->CreateWindow("Engine.Plots"); - SelectionWindow = CogWindowManager->CreateWindow("Engine.Selection"); + FCogEngineWindow_Selection* SelectionWindow = CogWindowManager->CreateWindow("Engine.Selection"); SelectionWindow->SetActorClasses({ ACharacter::StaticClass(), AActor::StaticClass(), AGameModeBase::StaticClass(), AGameStateBase::StaticClass() }); SelectionWindow->SetTraceType(UEngineTypes::ConvertToTraceType(ECollisionChannel::ECC_Pawn)); - CogWindowManager->CreateWindow("Engine.Scalability"); + CogWindowManager->CreateWindow("Engine.Scalability"); - CogWindowManager->CreateWindow("Engine.Skeleton"); + CogWindowManager->CreateWindow("Engine.Skeleton"); - CogWindowManager->CreateWindow("Engine.Spawns"); + CogWindowManager->CreateWindow("Engine.Spawns"); - UCogEngineWindow_Stats* StatsWindow = CogWindowManager->CreateWindow("Engine.Stats"); + FCogEngineWindow_Stats* StatsWindow = CogWindowManager->CreateWindow("Engine.Stats"); - CogWindowManager->CreateWindow("Engine.Time Scale"); + CogWindowManager->CreateWindow("Engine.Time Scale"); //--------------------------------------- // Abilities //--------------------------------------- - CogWindowManager->CreateWindow("Gameplay.Abilities"); + CogWindowManager->CreateWindow("Gameplay.Abilities"); - CogWindowManager->CreateWindow("Gameplay.Attributes"); + CogWindowManager->CreateWindow("Gameplay.Attributes"); - CogWindowManager->CreateWindow("Gameplay.Cheats"); + CogWindowManager->CreateWindow("Gameplay.Cheats"); - CogWindowManager->CreateWindow("Gameplay.Effects"); + CogWindowManager->CreateWindow("Gameplay.Effects"); - CogWindowManager->CreateWindow("Gameplay.Pools"); + CogWindowManager->CreateWindow("Gameplay.Pools"); - CogWindowManager->CreateWindow("Gameplay.Tags"); + CogWindowManager->CreateWindow("Gameplay.Tags"); - CogWindowManager->CreateWindow("Gameplay.Tweaks"); + CogWindowManager->CreateWindow("Gameplay.Tweaks"); //--------------------------------------- // AI //--------------------------------------- - CogWindowManager->CreateWindow("AI.Behavior Tree"); + CogWindowManager->CreateWindow("AI.Behavior Tree"); - CogWindowManager->CreateWindow("AI.Blackboard"); + CogWindowManager->CreateWindow("AI.Blackboard"); //--------------------------------------- // Input //--------------------------------------- - CogWindowManager->CreateWindow("Input.Actions"); + CogWindowManager->CreateWindow("Input.Actions"); - CogWindowManager->CreateWindow("Input.Gamepad"); + CogWindowManager->CreateWindow("Input.Gamepad"); //--------------------------------------- // Main Menu Widget //--------------------------------------- - CogWindowManager->AddMainMenuWidget(SelectionWindow.Get()); + CogWindowManager->AddMainMenuWidget(SelectionWindow); CogWindowManager->AddMainMenuWidget(StatsWindow); } diff --git a/Source/CogSample/CogSampleGameState.h b/Source/CogSample/CogSampleGameState.h index c3e8652..4547ddf 100644 --- a/Source/CogSample/CogSampleGameState.h +++ b/Source/CogSample/CogSampleGameState.h @@ -6,7 +6,6 @@ #include "CogSampleGameState.generated.h" class UCogWindowManager; -class UCogEngineWindow_Selection; class UCogSampleAbilitySystemComponent; UCLASS() @@ -41,12 +40,7 @@ private: void InitializeCog(); - void RegisterCommands(); - - void UnregisterCommands(); - TObjectPtr CogWindowManager = nullptr; - TObjectPtr SelectionWindow = nullptr; #endif //ENABLE_COG };