CogWindow: Rename CreateWindow to AddWindow to prevent name conflict with windows headers

CogSample : Projectile progress
This commit is contained in:
Arnaud Jamin
2023-10-30 23:44:24 -04:00
parent 315782183d
commit 7f88f5d53a
10 changed files with 73 additions and 47 deletions
@@ -53,12 +53,12 @@ void UCogWindowManager::InitializeInternal()
IniHandler.UserData = this;
ImGui::AddSettingsHandler(&IniHandler);
SpaceWindows.Add(CreateWindow<FCogWindow_Spacing>("Spacing 1", false));
SpaceWindows.Add(CreateWindow<FCogWindow_Spacing>("Spacing 2", false));
SpaceWindows.Add(CreateWindow<FCogWindow_Spacing>("Spacing 3", false));
SpaceWindows.Add(CreateWindow<FCogWindow_Spacing>("Spacing 4", false));
SpaceWindows.Add(AddWindow<FCogWindow_Spacing>("Spacing 1", false));
SpaceWindows.Add(AddWindow<FCogWindow_Spacing>("Spacing 2", false));
SpaceWindows.Add(AddWindow<FCogWindow_Spacing>("Spacing 3", false));
SpaceWindows.Add(AddWindow<FCogWindow_Spacing>("Spacing 4", false));
SettingsWindow = CreateWindow<FCogWindow_Settings>("Window.Settings", false);
SettingsWindow = AddWindow<FCogWindow_Settings>("Window.Settings", false);
ConsoleCommands.Add(IConsoleManager::Get().RegisterConsoleCommand(
*ToggleInputCommand,
@@ -85,7 +85,7 @@ public:
const UObject* GetAsset(const TSubclassOf<UObject> AssetClass);
template<class T>
T* CreateWindow(const FString& Name, bool AddToMainMenu = true)
T* AddWindow(const FString& Name, bool AddToMainMenu = true)
{
T* Window = new T();
AddWindow(Window, Name, AddToMainMenu);
+27 -27
View File
@@ -123,15 +123,15 @@ void ACogSampleGameState::InitializeCog()
//---------------------------------------
// Engine
//---------------------------------------
CogWindowManager->CreateWindow<FCogEngineWindow_Collisions>("Engine.Collision");
CogWindowManager->AddWindow<FCogEngineWindow_Collisions>("Engine.Collision");
CogWindowManager->CreateWindow<FCogEngineWindow_CommandBindings>("Engine.Command Bindings");
CogWindowManager->AddWindow<FCogEngineWindow_CommandBindings>("Engine.Command Bindings");
CogWindowManager->CreateWindow<FCogEngineWindow_DebugSettings>("Engine.Debug Settings");
CogWindowManager->AddWindow<FCogEngineWindow_DebugSettings>("Engine.Debug Settings");
CogWindowManager->CreateWindow<FCogEngineWindow_ImGui>("Engine.ImGui");
CogWindowManager->AddWindow<FCogEngineWindow_ImGui>("Engine.ImGui");
FCogEngineWindow_Inspector* Inspector = CogWindowManager->CreateWindow<FCogEngineWindow_Inspector>("Engine.Inspector");
FCogEngineWindow_Inspector* Inspector = CogWindowManager->AddWindow<FCogEngineWindow_Inspector>("Engine.Inspector");
Inspector->AddFavorite(GEngine->GetGameUserSettings(), [](UObject* Object)
{
if (UGameUserSettings* UserSettings = Cast<UGameUserSettings>(Object))
@@ -140,60 +140,60 @@ void ACogSampleGameState::InitializeCog()
}
});
CogWindowManager->CreateWindow<FCogEngineWindow_LogCategories>("Engine.Log Categories");
CogWindowManager->AddWindow<FCogEngineWindow_LogCategories>("Engine.Log Categories");
CogWindowManager->CreateWindow<FCogEngineWindow_NetEmulation>("Engine.Net Emulation");
CogWindowManager->AddWindow<FCogEngineWindow_NetEmulation>("Engine.Net Emulation");
CogWindowManager->CreateWindow<FCogEngineWindow_OutputLog>("Engine.Output Log");
CogWindowManager->AddWindow<FCogEngineWindow_OutputLog>("Engine.Output Log");
CogWindowManager->CreateWindow<FCogEngineWindow_Metrics>("Engine.Metrics");
CogWindowManager->AddWindow<FCogEngineWindow_Metrics>("Engine.Metrics");
CogWindowManager->CreateWindow<FCogEngineWindow_Plots>("Engine.Plots");
CogWindowManager->AddWindow<FCogEngineWindow_Plots>("Engine.Plots");
FCogEngineWindow_Selection* SelectionWindow = CogWindowManager->CreateWindow<FCogEngineWindow_Selection>("Engine.Selection");
FCogEngineWindow_Selection* SelectionWindow = CogWindowManager->AddWindow<FCogEngineWindow_Selection>("Engine.Selection");
SelectionWindow->SetActorClasses({ ACharacter::StaticClass(), AActor::StaticClass(), AGameModeBase::StaticClass(), AGameStateBase::StaticClass() });
SelectionWindow->SetTraceType(UEngineTypes::ConvertToTraceType(ECollisionChannel::ECC_Pawn));
CogWindowManager->CreateWindow<FCogEngineWindow_Scalability>("Engine.Scalability");
CogWindowManager->AddWindow<FCogEngineWindow_Scalability>("Engine.Scalability");
CogWindowManager->CreateWindow<FCogEngineWindow_Skeleton>("Engine.Skeleton");
CogWindowManager->AddWindow<FCogEngineWindow_Skeleton>("Engine.Skeleton");
CogWindowManager->CreateWindow<FCogEngineWindow_Spawns>("Engine.Spawns");
CogWindowManager->AddWindow<FCogEngineWindow_Spawns>("Engine.Spawns");
FCogEngineWindow_Stats* StatsWindow = CogWindowManager->CreateWindow<FCogEngineWindow_Stats>("Engine.Stats");
FCogEngineWindow_Stats* StatsWindow = CogWindowManager->AddWindow<FCogEngineWindow_Stats>("Engine.Stats");
CogWindowManager->CreateWindow<FCogEngineWindow_TimeScale>("Engine.Time Scale");
CogWindowManager->AddWindow<FCogEngineWindow_TimeScale>("Engine.Time Scale");
//---------------------------------------
// Abilities
//---------------------------------------
CogWindowManager->CreateWindow<FCogAbilityWindow_Abilities>("Gameplay.Abilities");
CogWindowManager->AddWindow<FCogAbilityWindow_Abilities>("Gameplay.Abilities");
CogWindowManager->CreateWindow<FCogAbilityWindow_Attributes>("Gameplay.Attributes");
CogWindowManager->AddWindow<FCogAbilityWindow_Attributes>("Gameplay.Attributes");
CogWindowManager->CreateWindow<FCogAbilityWindow_Cheats>("Gameplay.Cheats");
CogWindowManager->AddWindow<FCogAbilityWindow_Cheats>("Gameplay.Cheats");
CogWindowManager->CreateWindow<FCogAbilityWindow_Effects>("Gameplay.Effects");
CogWindowManager->AddWindow<FCogAbilityWindow_Effects>("Gameplay.Effects");
CogWindowManager->CreateWindow<FCogAbilityWindow_Pools>("Gameplay.Pools");
CogWindowManager->AddWindow<FCogAbilityWindow_Pools>("Gameplay.Pools");
CogWindowManager->CreateWindow<FCogAbilityWindow_Tags>("Gameplay.Tags");
CogWindowManager->AddWindow<FCogAbilityWindow_Tags>("Gameplay.Tags");
CogWindowManager->CreateWindow<FCogAbilityWindow_Tweaks>("Gameplay.Tweaks");
CogWindowManager->AddWindow<FCogAbilityWindow_Tweaks>("Gameplay.Tweaks");
//---------------------------------------
// AI
//---------------------------------------
CogWindowManager->CreateWindow<FCogAIWindow_BehaviorTree>("AI.Behavior Tree");
CogWindowManager->AddWindow<FCogAIWindow_BehaviorTree>("AI.Behavior Tree");
CogWindowManager->CreateWindow<FCogAIWindow_Blackboard>("AI.Blackboard");
CogWindowManager->AddWindow<FCogAIWindow_Blackboard>("AI.Blackboard");
//---------------------------------------
// Input
//---------------------------------------
CogWindowManager->CreateWindow<FCogInputWindow_Actions>("Input.Actions");
CogWindowManager->AddWindow<FCogInputWindow_Actions>("Input.Actions");
CogWindowManager->CreateWindow<FCogInputWindow_Gamepad>("Input.Gamepad");
CogWindowManager->AddWindow<FCogInputWindow_Gamepad>("Input.Gamepad");
//---------------------------------------
// Main Menu Widget
@@ -226,6 +226,8 @@ const ACogSamplePlayerController* ACogSamplePlayerController::GetFirstLocalPlaye
//--------------------------------------------------------------------------------------------------------------------------
float ACogSamplePlayerController::GetClientLag() const
{
return (PlayerState != nullptr && GetNetMode() != NM_Standalone) ? (0.0001f * 0.5f * PlayerState->ExactPing) : 0.f;
const float Ping = (PlayerState != nullptr && GetNetMode() != NM_Standalone) ? PlayerState->ExactPing : 0.0f;
const float HalfPingInSeconds = Ping * 0.0001f * 0.5f;
return HalfPingInSeconds;
}
@@ -82,6 +82,8 @@ void UCogSampleProjectileComponent::BeginPlay()
Creator = UCogSampleFunctionLibrary_Gameplay::GetCreator(GetOwner());
SpawnPrediction = GetOwner()->FindComponentByClass<UCogSampleSpawnPredictionComponent>();
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s - Role:%s - IsActive:%d"), *GetNameSafe(GetOwner()), *GetRoleName(), IsActive());
RegisterAllEffects();
Collision = Cast<USphereComponent>(CollisionReference.GetComponent(GetOwner()));
@@ -98,13 +100,17 @@ void UCogSampleProjectileComponent::BeginPlay()
if (GetOwner()->GetLocalRole() != ROLE_Authority)
{
Activate(false);
//-----------------------------------------------------------------------------------------------
// Must force the activation because the server might have already replicated the IsActive flag.
//-----------------------------------------------------------------------------------------------
Activate(true);
}
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogSampleProjectileComponent::Activate(bool bReset)
{
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s - Role:%s - bReset:%d"), *GetNameSafe(GetOwner()), *GetRoleName(), bReset);
//------------------------------------------------------------------------------------------------
// Save the spawn location and rotation and get them replicated because, we want remote clients
@@ -126,8 +132,6 @@ void UCogSampleProjectileComponent::Activate(bool bReset)
Velocity = ServerSpawnVelocity;
}
Super::Activate(bReset);
#if ENABLE_COG
DrawDebugCurrentState(FColor::Green);
if (FCogDebugLog::IsLogCategoryActive(LogCogProjectile))
@@ -148,6 +152,7 @@ void UCogSampleProjectileComponent::Activate(bool bReset)
}
}
Super::Activate(bReset);
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -205,7 +210,7 @@ void UCogSampleProjectileComponent::TickComponent(float DeltaTime, enum ELevelTi
//--------------------------------------------------------------------------------------------------------------------------
void UCogSampleProjectileComponent::Catchup(float CatchupDuration)
{
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s - Role:%s - CatchupDuration:%0.2f"), *GetName(), *GetRoleName(), CatchupDuration);
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s - Role:%s - CatchupDuration:%dms"), *GetNameSafe(GetOwner()), *GetRoleName(), (int32)(CatchupDuration * 1000));
IsCatchingUp = true;
TickComponent(CatchupDuration, LEVELTICK_All, nullptr);
@@ -319,10 +324,10 @@ bool UCogSampleProjectileComponent::ShouldProcessOverlap(AActor* OtherActor, UPr
void UCogSampleProjectileComponent::OnCollisionOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool IsFromSweep, const FHitResult& SweepHit)
{
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s - Role:%s - Other:%s - Comp:%s"),
*GetName(),
*GetNameSafe(GetOwner()),
*GetRoleName(),
OtherActor != nullptr ? *OtherActor->GetName() : TEXT("NULL"),
OtherComp != nullptr ? *OtherComp->GetName() : TEXT("NULL"));
*GetNameSafe(OtherActor),
*GetNameSafe(OtherComp));
if (ShouldProcessOverlap(OtherActor, OtherComp, false) == false)
{
@@ -379,10 +384,10 @@ void UCogSampleProjectileComponent::OnCollisionOverlapBegin(UPrimitiveComponent*
void UCogSampleProjectileComponent::OnAssistanceOverlapBegin(UPrimitiveComponent* overlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool IsFromSweep, const FHitResult& Hit)
{
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s - Role:%s - Other:%s - Comp:%s"),
*GetName(),
*GetNameSafe(GetOwner()),
*GetRoleName(),
OtherActor != nullptr ? *OtherActor->GetName() : TEXT("NULL"),
OtherComp != nullptr ? *OtherComp->GetName() : TEXT("NULL"));
*GetNameSafe(OtherActor),
*GetNameSafe(OtherComp));
//-------------------------------------------------------------------------------------
// Call ShouldProcessOverlap with a requirement of a valid actor because the
@@ -432,10 +437,10 @@ void UCogSampleProjectileComponent::OnAssistanceOverlapBegin(UPrimitiveComponent
void UCogSampleProjectileComponent::TryHit(const FHitResult& HitResult)
{
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s - Role:%s - Other:%s - Comp:%s - Bone:%s"),
*GetName(),
*GetNameSafe(GetOwner()),
*GetRoleName(),
HitResult.GetActor() != nullptr ? *HitResult.GetActor()->GetName() : TEXT("NULL"),
HitResult.GetComponent() != nullptr ? *HitResult.GetComponent()->GetName() : TEXT("NULL"),
*GetNameSafe(HitResult.GetActor()),
*GetNameSafe(HitResult.GetComponent()),
*HitResult.BoneName.ToString());
//-----------------------------------------------------------------------------------------
@@ -461,6 +466,19 @@ void UCogSampleProjectileComponent::TryHit(const FHitResult& HitResult)
}
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogSampleProjectileComponent::StopSimulating(const FHitResult& HitResult)
{
COG_LOG_OBJECT(LogCogProjectile, ELogVerbosity::Verbose, Creator.Get(), TEXT("Projectile:%s - Role:%s - Other:%s - Comp:%s - Bone:%s"),
*GetNameSafe(GetOwner()),
*GetRoleName(),
*GetNameSafe(HitResult.GetActor()),
*GetNameSafe(HitResult.GetComponent()),
*HitResult.BoneName.ToString());
Super::StopSimulating(HitResult);
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogSampleProjectileComponent::ClearHitActors()
{
@@ -534,3 +552,5 @@ FString UCogSampleProjectileComponent::GetRoleName() const
return SpawnPrediction->GetRoleName();
}
@@ -57,6 +57,9 @@ public:
virtual void Activate(bool bReset) override;
virtual void StopSimulating(const FHitResult& HitResult) override;
UFUNCTION(BlueprintCallable)
void ClearHitActors();
+1
View File
@@ -11,6 +11,7 @@
- CogEngine: make a better widget for CheckBoxState for input shortcuts
- CogEngine: save active log categories
- CogEngine: add menu on the PlotWindow wih the controls
- CogEngine: Improve collision window: Add Query Type, Single or Multi, By Channel or Object Type, Object Type.
- CogSample: Add a custom window in sample (changing the character faction)
- CogSample: Create more abilities