mirror of
https://github.com/Ed94/Cog.git
synced 2026-08-05 15:18:47 +00:00
Add spawning window
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "CogAbilityDataAsset_Cheats.h"
|
||||
#include "CogDebugAllegianceInterface.h"
|
||||
#include "CogDebugDraw.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "EngineUtils.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "imgui.h"
|
||||
@@ -86,13 +87,7 @@ void UCogAbilityWindow_Cheats::AddCheat(AActor* CheatInstigator, AActor* Selecte
|
||||
Color = CheatsAsset->NeutralEffectColor;
|
||||
}
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(Color.R, Color.G, Color.B, 0.2f * Color.A));
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(Color.R, Color.G, Color.B, 0.3f * Color.A));
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(Color.R, Color.G, Color.B, 0.5f * Color.A));
|
||||
ImGui::PushStyleColor(ImGuiCol_CheckMark, ImVec4(Color.R, Color.G, Color.B, 0.8f * Color.A));
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(Color.R, Color.G, Color.B, 0.2f * Color.A));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(Color.R, Color.G, Color.B, 0.3f * Color.A));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(Color.R, Color.G, Color.B, 0.5f * Color.A));
|
||||
FCogWindowWidgets::PushBackColor(FCogImguiHelper::ToImVec4(Color));
|
||||
|
||||
if (IsPersistent)
|
||||
{
|
||||
@@ -124,7 +119,7 @@ void UCogAbilityWindow_Cheats::AddCheat(AActor* CheatInstigator, AActor* Selecte
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
ImGui::PopStyleColor(7);
|
||||
FCogWindowWidgets::PopBackColor();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -126,11 +126,11 @@ static void DrawRow(const char* Title, float MitigatedValue, float UnmitigatedVa
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
static void DrawDamages(FCogDamageStats& Damage)
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBg, IM_COL32(150, 150, 150, 60));
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, IM_COL32(150, 150, 150, 80));
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgActive, IM_COL32(150, 150, 150, 120));
|
||||
ImGui::PushStyleColor(ImGuiCol_CheckMark, IM_COL32(150, 150, 150, 200));
|
||||
ImGui::PushStyleColor(ImGuiCol_PlotHistogram, IM_COL32(120, 120, 120, 255));
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBg, IM_COL32(150, 150, 150, 60));
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, IM_COL32(150, 150, 150, 80));
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgActive, IM_COL32(150, 150, 150, 120));
|
||||
ImGui::PushStyleColor(ImGuiCol_CheckMark, IM_COL32(150, 150, 150, 200));
|
||||
ImGui::PushStyleColor(ImGuiCol_PlotHistogram, IM_COL32(120, 120, 120, 255));
|
||||
|
||||
if (ImGui::BeginTable("Damages", 4, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize | ImGuiTableFlags_RowBg))
|
||||
{
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
void UCogAbilityWindow_Effects::PreRender(ImGuiWindowFlags& WindowFlags)
|
||||
{
|
||||
Super::PreRender(WindowFlags);
|
||||
|
||||
WindowFlags |= ImGuiWindowFlags_MenuBar;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -21,6 +19,12 @@ void UCogAbilityWindow_Effects::RenderContent()
|
||||
{
|
||||
Super::RenderContent();
|
||||
|
||||
RenderEffectsTable();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityWindow_Effects::RenderEffectsTable()
|
||||
{
|
||||
UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true);
|
||||
if (AbilitySystemComponent == nullptr)
|
||||
{
|
||||
@@ -40,14 +44,14 @@ void UCogAbilityWindow_Effects::RenderContent()
|
||||
FGameplayEffectQuery Query;
|
||||
for (const FActiveGameplayEffectHandle& ActiveHandle : AbilitySystemComponent->GetActiveEffects(Query))
|
||||
{
|
||||
DrawEffectRow(*AbilitySystemComponent, ActiveHandle, Index, SelectedIndex);
|
||||
RenderEffectRow(*AbilitySystemComponent, ActiveHandle, Index, SelectedIndex);
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityWindow_Effects::DrawEffectRow(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffectHandle& ActiveHandle, int32 Index, int32& Selected)
|
||||
void UCogAbilityWindow_Effects::RenderEffectRow(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffectHandle& ActiveHandle, int32 Index, int32& Selected)
|
||||
{
|
||||
ImGui::PushID(Index);
|
||||
|
||||
@@ -104,7 +108,7 @@ void UCogAbilityWindow_Effects::DrawEffectRow(const UAbilitySystemComponent& Abi
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
FCogWindowWidgets::BeginTableTooltip();
|
||||
DrawEffectInfo(AbilitySystemComponent, ActiveEffect, Effect);
|
||||
RenderEffectInfo(AbilitySystemComponent, ActiveEffect, Effect);
|
||||
FCogWindowWidgets::EndTableTooltip();
|
||||
}
|
||||
|
||||
@@ -113,7 +117,7 @@ void UCogAbilityWindow_Effects::DrawEffectRow(const UAbilitySystemComponent& Abi
|
||||
//------------------------
|
||||
if (ImGui::BeginPopupContextItem())
|
||||
{
|
||||
if (ImGui::Button("Open Properties"))
|
||||
if (ImGui::Button("Open"))
|
||||
{
|
||||
//GetOwner()->GetPropertyGrid()->Open(EffectPtr);
|
||||
ImGui::CloseCurrentPopup();
|
||||
@@ -125,26 +129,26 @@ void UCogAbilityWindow_Effects::DrawEffectRow(const UAbilitySystemComponent& Abi
|
||||
// Remaining Time
|
||||
//------------------------
|
||||
ImGui::TableNextColumn();
|
||||
DrawRemainingTime(AbilitySystemComponent, ActiveEffect);
|
||||
RenderRemainingTime(AbilitySystemComponent, ActiveEffect);
|
||||
|
||||
//------------------------
|
||||
// Stacks
|
||||
//------------------------
|
||||
ImGui::TableNextColumn();
|
||||
DrawStacks(ActiveEffect, Effect);
|
||||
RenderStacks(ActiveEffect, Effect);
|
||||
|
||||
//------------------------
|
||||
// Prediction
|
||||
//------------------------
|
||||
ImGui::TableNextColumn();
|
||||
DrawPrediction(ActiveEffect, true);
|
||||
RenderPrediction(ActiveEffect, true);
|
||||
|
||||
ImGui::PopID();
|
||||
Index++;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityWindow_Effects::DrawEffectInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffect& ActiveEffect, const UGameplayEffect& Effect)
|
||||
void UCogAbilityWindow_Effects::RenderEffectInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffect& ActiveEffect, const UGameplayEffect& Effect)
|
||||
{
|
||||
if (ImGui::BeginTable("Effect", 2, ImGuiTableFlags_Borders))
|
||||
{
|
||||
@@ -178,7 +182,7 @@ void UCogAbilityWindow_Effects::DrawEffectInfo(const UAbilitySystemComponent& Ab
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Remaining Time");
|
||||
ImGui::TableNextColumn();
|
||||
DrawRemainingTime(AbilitySystemComponent, ActiveEffect);
|
||||
RenderRemainingTime(AbilitySystemComponent, ActiveEffect);
|
||||
|
||||
//------------------------
|
||||
// Period
|
||||
@@ -196,7 +200,7 @@ void UCogAbilityWindow_Effects::DrawEffectInfo(const UAbilitySystemComponent& Ab
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Stacks");
|
||||
ImGui::TableNextColumn();
|
||||
DrawStacks(ActiveEffect, Effect);
|
||||
RenderStacks(ActiveEffect, Effect);
|
||||
|
||||
//------------------------
|
||||
// Prediction
|
||||
@@ -205,7 +209,7 @@ void UCogAbilityWindow_Effects::DrawEffectInfo(const UAbilitySystemComponent& Ab
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Prediction");
|
||||
ImGui::TableNextColumn();
|
||||
DrawPrediction(ActiveEffect, false);
|
||||
RenderPrediction(ActiveEffect, false);
|
||||
|
||||
//------------------------
|
||||
// Dynamic Asset Tags
|
||||
@@ -214,7 +218,7 @@ void UCogAbilityWindow_Effects::DrawEffectInfo(const UAbilitySystemComponent& Ab
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Dynamic Asset Tags");
|
||||
ImGui::TableNextColumn();
|
||||
DrawTagContainer(ActiveEffect.Spec.GetDynamicAssetTags());
|
||||
RenderTagContainer(ActiveEffect.Spec.GetDynamicAssetTags());
|
||||
|
||||
//------------------------
|
||||
// All Asset Tags
|
||||
@@ -225,7 +229,7 @@ void UCogAbilityWindow_Effects::DrawEffectInfo(const UAbilitySystemComponent& Ab
|
||||
ImGui::TableNextColumn();
|
||||
FGameplayTagContainer AllAssetTagsContainer;
|
||||
ActiveEffect.Spec.GetAllAssetTags(AllAssetTagsContainer);
|
||||
DrawTagContainer(AllAssetTagsContainer);
|
||||
RenderTagContainer(AllAssetTagsContainer);
|
||||
|
||||
//------------------------
|
||||
// All Granted Tags
|
||||
@@ -236,7 +240,7 @@ void UCogAbilityWindow_Effects::DrawEffectInfo(const UAbilitySystemComponent& Ab
|
||||
ImGui::TableNextColumn();
|
||||
FGameplayTagContainer AllGrantedTagsContainer;
|
||||
ActiveEffect.Spec.GetAllGrantedTags(AllGrantedTagsContainer);
|
||||
DrawTagContainer(AllGrantedTagsContainer);
|
||||
RenderTagContainer(AllGrantedTagsContainer);
|
||||
|
||||
//------------------------
|
||||
// Modifiers
|
||||
@@ -262,7 +266,7 @@ void UCogAbilityWindow_Effects::DrawEffectInfo(const UAbilitySystemComponent& Ab
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityWindow_Effects::DrawTagContainer(const FGameplayTagContainer& Container)
|
||||
void UCogAbilityWindow_Effects::RenderTagContainer(const FGameplayTagContainer& Container)
|
||||
{
|
||||
TArray<FGameplayTag> GameplayTags;
|
||||
Container.GetGameplayTagArray(GameplayTags);
|
||||
@@ -280,7 +284,7 @@ FString UCogAbilityWindow_Effects::GetEffectName(const UGameplayEffect& Effect)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityWindow_Effects::DrawRemainingTime(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffect& ActiveEffect)
|
||||
void UCogAbilityWindow_Effects::RenderRemainingTime(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffect& ActiveEffect)
|
||||
{
|
||||
float StartTime = ActiveEffect.StartWorldTime;
|
||||
float Duration = ActiveEffect.GetDuration();
|
||||
@@ -302,7 +306,7 @@ void UCogAbilityWindow_Effects::DrawRemainingTime(const UAbilitySystemComponent&
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityWindow_Effects::DrawStacks(const FActiveGameplayEffect& ActiveEffect, const UGameplayEffect& Effect)
|
||||
void UCogAbilityWindow_Effects::RenderStacks(const FActiveGameplayEffect& ActiveEffect, const UGameplayEffect& Effect)
|
||||
{
|
||||
const int32 CurrentStackCount = ActiveEffect.Spec.StackCount;
|
||||
if (Effect.StackLimitCount <= 0)
|
||||
@@ -320,7 +324,7 @@ void UCogAbilityWindow_Effects::DrawStacks(const FActiveGameplayEffect& ActiveEf
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityWindow_Effects::DrawPrediction(const FActiveGameplayEffect& ActiveEffect, bool Short)
|
||||
void UCogAbilityWindow_Effects::RenderPrediction(const FActiveGameplayEffect& ActiveEffect, bool Short)
|
||||
{
|
||||
FString PredictionString;
|
||||
if (ActiveEffect.PredictionKey.IsValidKey())
|
||||
|
||||
@@ -22,20 +22,12 @@ void DrawTweak(ACogAbilityReplicator* Replicator, const UCogAbilityDataAsset_Twe
|
||||
}
|
||||
|
||||
const FCogAbilityTweakCategory& Category = TweaksAsset->TweaksCategories[TweakCategoryIndex];
|
||||
const FLinearColor& Color = Category.Color;
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(Color.R, Color.G, Color.B, Color.A * 0.25f));
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(Color.R, Color.G, Color.B, Color.A * 0.3f));
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(Color.R, Color.G, Color.B, Color.A * 0.5f));
|
||||
ImGui::PushStyleColor(ImGuiCol_SliderGrab, ImVec4(Color.R, Color.G, Color.B, Color.A * 0.8f));
|
||||
ImGui::PushStyleColor(ImGuiCol_SliderGrabActive, ImVec4(Color.R, Color.G, Color.B, Color.A * 1.0f));
|
||||
|
||||
|
||||
FCogWindowWidgets::PushBackColor(FCogImguiHelper::ToImVec4(Category.Color));
|
||||
ImGui::PushItemWidth(-1);
|
||||
ImGui::SliderFloat("##Value", Value, TweaksAsset->TweakMinValue, TweaksAsset->TweakMaxValue, "%+0.0f%%", 1.0f);
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
ImGui::PopStyleColor(5);
|
||||
FCogWindowWidgets::PopBackColor();
|
||||
|
||||
bool bUpdateValue = ImGui::IsItemDeactivatedAfterEdit();
|
||||
|
||||
|
||||
@@ -22,17 +22,19 @@ protected:
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
virtual void DrawEffectRow(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffectHandle& ActiveHandle, int32 Index, int32& Selected);
|
||||
virtual void RenderEffectsTable();
|
||||
|
||||
virtual void DrawEffectInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffect& ActiveEffect, const UGameplayEffect& Effect);
|
||||
virtual void RenderEffectRow(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffectHandle& ActiveHandle, int32 Index, int32& Selected);
|
||||
|
||||
virtual void RenderEffectInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffect& ActiveEffect, const UGameplayEffect& Effect);
|
||||
|
||||
virtual void DrawTagContainer(const FGameplayTagContainer& Container);
|
||||
virtual void RenderTagContainer(const FGameplayTagContainer& Container);
|
||||
|
||||
virtual void RenderRemainingTime(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffect& ActiveEffect);
|
||||
|
||||
virtual void RenderStacks(const FActiveGameplayEffect& ActiveEffect, const UGameplayEffect& Effect);
|
||||
|
||||
virtual void RenderPrediction(const FActiveGameplayEffect& ActiveEffect, bool Short);
|
||||
|
||||
virtual FString GetEffectName(const UGameplayEffect& Effect);
|
||||
|
||||
virtual void DrawRemainingTime(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffect& ActiveEffect);
|
||||
|
||||
virtual void DrawStacks(const FActiveGameplayEffect& ActiveEffect, const UGameplayEffect& Effect);
|
||||
|
||||
virtual void DrawPrediction(const FActiveGameplayEffect& ActiveEffect, bool Short);
|
||||
};
|
||||
|
||||
@@ -22,12 +22,6 @@ ACogEngineReplicator::ACogEngineReplicator(const FObjectInitializer& ObjectIniti
|
||||
{
|
||||
#if !UE_BUILD_SHIPPING
|
||||
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
PrimaryActorTick.bAllowTickOnDedicatedServer = true;
|
||||
PrimaryActorTick.bTickEvenWhenPaused = true;
|
||||
PrimaryActorTick.bStartWithTickEnabled = true;
|
||||
PrimaryActorTick.TickGroup = TG_PrePhysics;
|
||||
|
||||
bHasAuthority = false;
|
||||
bIsLocal = false;
|
||||
bReplicates = true;
|
||||
@@ -65,26 +59,42 @@ void ACogEngineReplicator::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>&
|
||||
{
|
||||
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||||
|
||||
#if !UE_BUILD_SHIPPING
|
||||
|
||||
FDoRepLifetimeParams Params;
|
||||
Params.bIsPushBased = true;
|
||||
|
||||
DOREPLIFETIME_WITH_PARAMS_FAST(ACogEngineReplicator, TimeDilation, Params);
|
||||
|
||||
#endif // !UE_BUILD_SHIPPING
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void ACogEngineReplicator::TickSpawnActions()
|
||||
void ACogEngineReplicator::Server_Spawn_Implementation(const FCogEngineSpawnEntry& SpawnEntry)
|
||||
{
|
||||
#if !UE_BUILD_SHIPPING
|
||||
|
||||
if (OwnerPlayerController == nullptr)
|
||||
if (GetWorld() == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int32 i = SpawnActions.Num() - 1; i >= 0; --i)
|
||||
if (SpawnFunction)
|
||||
{
|
||||
const FCogEngineReplicatorSpawnAction& SpawnInfo = SpawnActions[i];
|
||||
SpawnActions.RemoveAt(i);
|
||||
SpawnFunction(SpawnEntry);
|
||||
}
|
||||
else
|
||||
{
|
||||
FTransform Transform(FTransform::Identity);
|
||||
if (APawn* Pawn = GetPlayerController()->GetPawn())
|
||||
{
|
||||
Transform = Pawn->GetTransform();
|
||||
Transform.SetLocation(Transform.GetLocation() + Transform.GetUnitAxis(EAxis::X) * 200.0f);
|
||||
Transform.SetScale3D(FVector(1.0f));
|
||||
}
|
||||
|
||||
FActorSpawnParameters Params;
|
||||
Params.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn;
|
||||
GetWorld()->SpawnActor(SpawnEntry.Class, &Transform, Params);
|
||||
}
|
||||
|
||||
#endif // !UE_BUILD_SHIPPING
|
||||
@@ -118,3 +128,4 @@ void ACogEngineReplicator::OnRep_TimeDilation()
|
||||
|
||||
#endif // !UE_BUILD_SHIPPING
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
#include "CogEngineWindow_Spawn.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogEngineWindow_Spawn::PreRender(ImGuiWindowFlags& WindowFlags)
|
||||
{
|
||||
Super::PreRender(WindowFlags);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogEngineWindow_Spawn::RenderContent()
|
||||
{
|
||||
Super::RenderContent();
|
||||
|
||||
if (Asset == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (const FCogEngineSpawnGroup& SpawnGroup : Asset->SpawnGroups)
|
||||
{
|
||||
RenderSpawnGroup(SpawnGroup);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogEngineWindow_Spawn::RenderSpawnGroup(const FCogEngineSpawnGroup& SpawnGroup)
|
||||
{
|
||||
int32 GroupIndex = 0;
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Header, IM_COL32(66, 66, 66, 79));
|
||||
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, IM_COL32(62, 62, 62, 204));
|
||||
ImGui::PushStyleColor(ImGuiCol_HeaderActive, IM_COL32(86, 86, 86, 255));
|
||||
|
||||
if (ImGui::CollapsingHeader(TCHAR_TO_ANSI(*SpawnGroup.Name), ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
ImGui::PushID(GroupIndex);
|
||||
|
||||
const bool PushColor = (SpawnGroup.Color != FColor::Transparent);
|
||||
if (PushColor)
|
||||
{
|
||||
FCogWindowWidgets::PushBackColor(FCogImguiHelper::ToImVec4(SpawnGroup.Color));
|
||||
}
|
||||
|
||||
static int32 SelectedAssetIndex = -1;
|
||||
int32 AssetIndex = 0;
|
||||
|
||||
for (const FCogEngineSpawnEntry& SpawnEntry : SpawnGroup.Spawns)
|
||||
{
|
||||
if (RenderSpawnAsset(SpawnEntry, SelectedAssetIndex == GroupIndex))
|
||||
{
|
||||
SelectedAssetIndex = AssetIndex;
|
||||
}
|
||||
|
||||
AssetIndex++;
|
||||
}
|
||||
|
||||
if (PushColor)
|
||||
{
|
||||
FCogWindowWidgets::PopBackColor();
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
GroupIndex++;
|
||||
}
|
||||
|
||||
ImGui::PopStyleColor(3);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool UCogEngineWindow_Spawn::RenderSpawnAsset(const FCogEngineSpawnEntry& SpawnEntry, bool IsLastSelected)
|
||||
{
|
||||
bool IsPressed = false;
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, IsLastSelected ? ImGui::GetStyleColorVec4(ImGuiCol_ButtonActive) : ImGui::GetStyleColorVec4(ImGuiCol_Button));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.5f));
|
||||
|
||||
FString EntryName;
|
||||
if (SpawnEntry.Asset != nullptr)
|
||||
{
|
||||
EntryName = SpawnEntry.Asset->GetName();
|
||||
}
|
||||
else
|
||||
{
|
||||
EntryName = GetNameSafe(SpawnEntry.Class);
|
||||
}
|
||||
|
||||
if (ImGui::Button(TCHAR_TO_ANSI(*EntryName), ImVec2(-1, 0)))
|
||||
{
|
||||
if (ACogEngineReplicator* Replicator = FCogEngineModule::Get().GetLocalReplicator())
|
||||
{
|
||||
Replicator->Server_Spawn(SpawnEntry);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar(1);
|
||||
ImGui::PopStyleColor(1);
|
||||
|
||||
return IsPressed;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "CogEngineDataAsset_Spawns.generated.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
USTRUCT()
|
||||
struct COGENGINE_API FCogEngineSpawnEntry
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
TSubclassOf<AActor> Class;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
TObjectPtr<const UObject> Asset = nullptr;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
USTRUCT()
|
||||
struct COGENGINE_API FCogEngineSpawnGroup
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
FString Name;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
FLinearColor Color = FLinearColor(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
TArray<FCogEngineSpawnEntry> Spawns;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UCLASS(Blueprintable)
|
||||
class COGENGINE_API UCogEngineDataAsset_Spawns : public UPrimaryDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(EditAnywhere, meta = (TitleProperty = "Name"))
|
||||
TArray<FCogEngineSpawnGroup> SpawnGroups;
|
||||
};
|
||||
@@ -8,15 +8,7 @@
|
||||
|
||||
class APlayerController;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
USTRUCT()
|
||||
struct FCogEngineReplicatorSpawnAction
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
bool Control = false;
|
||||
bool Select = false;
|
||||
};
|
||||
using FCogEnineSpawnFunction = TFunction<void(const FCogEngineSpawnEntry& SpawnEntry)>;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UCLASS(NotBlueprintable, NotBlueprintType, notplaceable, noteditinlinenew, hidedropdown, Transient)
|
||||
@@ -31,30 +23,32 @@ public:
|
||||
|
||||
APlayerController* GetPlayerController() const { return OwnerPlayerController.Get(); }
|
||||
|
||||
bool IsLocal() const { return bIsLocal; }
|
||||
FCogEnineSpawnFunction GetSpawnFunction() const { return SpawnFunction; }
|
||||
|
||||
void SetSpawnFunction(FCogEnineSpawnFunction Value) { SpawnFunction = Value; }
|
||||
|
||||
UFUNCTION(Server, Reliable)
|
||||
void Server_Spawn(const FCogEngineSpawnEntry& SpawnEntry);
|
||||
|
||||
float GetTimeDilation() const { return TimeDilation; }
|
||||
|
||||
UFUNCTION(Server, Reliable)
|
||||
void Server_SetTimeDilation(float Value);
|
||||
|
||||
float GetTimeDilation() const { return TimeDilation; }
|
||||
|
||||
protected:
|
||||
|
||||
void TickSpawnActions();
|
||||
|
||||
UFUNCTION()
|
||||
void OnRep_TimeDilation();
|
||||
|
||||
UPROPERTY()
|
||||
TArray<FCogEngineReplicatorSpawnAction> SpawnActions;
|
||||
|
||||
TObjectPtr<APlayerController> OwnerPlayerController;
|
||||
|
||||
uint32 bHasAuthority : 1;
|
||||
uint32 bIsLocal : 1;
|
||||
|
||||
private:
|
||||
|
||||
UPROPERTY(ReplicatedUsing = OnRep_TimeDilation)
|
||||
float TimeDilation = 1.0f;
|
||||
|
||||
FCogEnineSpawnFunction SpawnFunction;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogWindow.h"
|
||||
#include "CogEngineWindow_Spawn.generated.h"
|
||||
|
||||
class UCogEngineDataAsset_Spawns;
|
||||
struct FCogEngineSpawnGroup;
|
||||
|
||||
UCLASS()
|
||||
class COGENGINE_API UCogEngineWindow_Spawn : public UCogWindow
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
const UCogEngineDataAsset_Spawns* GetSpawnsAsset() const { return Asset; }
|
||||
|
||||
void SetSpawnsAsset(const UCogEngineDataAsset_Spawns* Value) { Asset = Value; }
|
||||
|
||||
protected:
|
||||
|
||||
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
virtual void RenderSpawnGroup(const FCogEngineSpawnGroup& SpawnGroup);
|
||||
|
||||
virtual bool RenderSpawnAsset(const FCogEngineSpawnEntry& SpawnEntry, bool IsLastSelected);
|
||||
|
||||
private:
|
||||
|
||||
const UCogEngineDataAsset_Spawns* Asset = nullptr;
|
||||
};
|
||||
@@ -37,7 +37,7 @@ void FCogImguiModule::Initialize()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
TSharedPtr<SCogImguiWidget> FCogImguiModule::CreateImGuiViewport(UGameViewportClient* GameViewport, FCogImguiRender Render, ImFontAtlas* FontAtlas /*= nullptr*/)
|
||||
TSharedPtr<SCogImguiWidget> FCogImguiModule::CreateImGuiViewport(UGameViewportClient* GameViewport, FCogImguiRenderFunction Render, ImFontAtlas* FontAtlas /*= nullptr*/)
|
||||
{
|
||||
if (bIsInitialized == false)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
virtual void ShutdownModule() override;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
TSharedPtr<SCogImguiWidget> CreateImGuiViewport(UGameViewportClient* GameViewport, FCogImguiRender Render, ImFontAtlas* FontAtlas = nullptr);
|
||||
TSharedPtr<SCogImguiWidget> CreateImGuiViewport(UGameViewportClient* GameViewport, FCogImguiRenderFunction Render, ImFontAtlas* FontAtlas = nullptr);
|
||||
|
||||
FCogImguiTextureManager& GetTextureManager() { return TextureManager; }
|
||||
ImFontAtlas& GetDefaultFontAtlas() { return DefaultFontAtlas; }
|
||||
|
||||
@@ -13,7 +13,7 @@ struct ImFontAtlas;
|
||||
struct ImGuiContext;
|
||||
struct ImPlotContext;
|
||||
|
||||
using FCogImguiRender = TFunction<void(float DeltaTime)>;
|
||||
using FCogImguiRenderFunction = TFunction<void(float DeltaTime)>;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
class COGIMGUI_API SCogImguiWidget : public SCompoundWidget
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
SLATE_BEGIN_ARGS(SCogImguiWidget) {}
|
||||
SLATE_ARGUMENT(UGameViewportClient*, GameViewport)
|
||||
SLATE_ARGUMENT(ImFontAtlas*, FontAtlas)
|
||||
SLATE_ARGUMENT(FCogImguiRender, Render)
|
||||
SLATE_ARGUMENT(FCogImguiRenderFunction, Render)
|
||||
SLATE_END_ARGS()
|
||||
|
||||
void Construct(const FArguments& InArgs);
|
||||
@@ -103,7 +103,7 @@ protected:
|
||||
|
||||
ImPlotContext* ImPlotContext = nullptr;
|
||||
|
||||
FCogImguiRender Render;
|
||||
FCogImguiRenderFunction Render;
|
||||
|
||||
float DpiScale = 1.f;
|
||||
|
||||
|
||||
@@ -266,6 +266,15 @@ void UCogWindowManager::DrawMainMenu()
|
||||
}
|
||||
FCogWindowWidgets::PopStyleCompact();
|
||||
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::TextUnformatted("Change DPi Scale [Mouse Wheel]");
|
||||
ImGui::TextUnformatted("Reset DPi Scale [Middle Mouse]");
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
|
||||
@@ -178,4 +178,22 @@ void FCogWindowWidgets::MenuSearchBar(ImGuiTextFilter& Filter)
|
||||
ImGui::SetCursorPosX(Pos2);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindowWidgets::PushBackColor(const ImVec4& Color)
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.25f));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.3f));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.5f));
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.25f));
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.3f));
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.5f));
|
||||
ImGui::PushStyleColor(ImGuiCol_SliderGrab, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.8f));
|
||||
ImGui::PushStyleColor(ImGuiCol_SliderGrabActive, ImVec4(Color.x, Color.y, Color.z, Color.w * 1.0f));
|
||||
ImGui::PushStyleColor(ImGuiCol_CheckMark, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.8f));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogWindowWidgets::PopBackColor()
|
||||
{
|
||||
ImGui::PopStyleColor(9);
|
||||
}
|
||||
@@ -30,4 +30,8 @@ public:
|
||||
static float TextBaseHeight;
|
||||
|
||||
static void MenuSearchBar(ImGuiTextFilter& Filter);
|
||||
|
||||
static void PushBackColor(const ImVec4& Color);
|
||||
|
||||
static void PopBackColor();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user