starting to add the hud in the sample

This commit is contained in:
Arnaud Jamin
2023-10-06 17:22:23 -04:00
parent 92396410d4
commit b18e62cd02
112 changed files with 707 additions and 333 deletions
@@ -153,12 +153,13 @@ void UCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent&
{
TArray<FGameplayAbilitySpec>& Abilities = AbilitySystemComponent.GetActivatableAbilities();
if (ImGui::BeginTable("Abilities", 4, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersH | ImGuiTableFlags_NoBordersInBody))
if (ImGui::BeginTable("Abilities", 5, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersH | ImGuiTableFlags_NoBordersInBody))
{
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("Ability");
ImGui::TableSetupColumn("Level");
ImGui::TableSetupColumn("Input");
ImGui::TableSetupColumn("Cooldown");
ImGui::TableHeadersRow();
static int SelectedIndex = -1;
@@ -240,6 +241,12 @@ void UCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent&
ImGui::Text("%d", Spec.InputPressed);
}
//------------------------
// Cooldown
//------------------------
ImGui::TableNextColumn();
RenderAbilityCooldown(AbilitySystemComponent, *Ability);
ImGui::PopStyleColor(1);
ImGui::PopID();
@@ -250,6 +257,21 @@ void UCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent&
}
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogAbilityWindow_Abilities::RenderAbilityCooldown(const UAbilitySystemComponent& AbilitySystemComponent, UGameplayAbility& Ability)
{
float RemainingTime, CooldownDuration;
Ability.GetCooldownTimeRemainingAndDuration(Ability.GetCurrentAbilitySpec()->Handle, AbilitySystemComponent.AbilityActorInfo.Get(), RemainingTime, CooldownDuration);
if (CooldownDuration > 0)
{
ImGui::PushStyleColor(ImGuiCol_PlotHistogram, IM_COL32(100, 100, 100, 255));
ImGui::PushStyleColor(ImGuiCol_FrameBg, IM_COL32(0, 0, 0, 100));
ImGui::ProgressBar(RemainingTime / CooldownDuration, ImVec2(-1, ImGui::GetTextLineHeightWithSpacing() * 0.8f), TCHAR_TO_ANSI(*FString::Printf(TEXT("%.2f / %.2f"), RemainingTime, CooldownDuration)));
ImGui::PopStyleColor(2);
}
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogAbilityWindow_Abilities::RenderAbilityContextMenu(UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec, int Index)
{
@@ -12,7 +12,7 @@
void UCogAbilityWindow_Attributes::RenderHelp()
{
ImGui::Text(
"This window display the gameplay attributes of the selected actor. "
"This window displays the gameplay attributes of the selected actor. "
"Attributes can be sorted by name, category or attribute set. "
"Attributes with the Current value greater than the Base value are displayed in green. "
"Attributes with the Current value lower than the Base value are displayed in red. "
@@ -309,7 +309,7 @@ void UCogAbilityWindow_Effects::RenderRemainingTime(const UAbilitySystemComponen
ImGui::PushStyleColor(ImGuiCol_PlotHistogram, IM_COL32(100, 100, 100, 255));
ImGui::PushStyleColor(ImGuiCol_FrameBg, IM_COL32(0, 0, 0, 100));
ImGui::ProgressBar(RemainingTime / Duration, ImVec2(FCogWindowWidgets::GetFontWidth() * 15, ImGui::GetTextLineHeightWithSpacing() * 0.8f), TCHAR_TO_ANSI(*FString::Printf(TEXT("%.2f / %.2f"), RemainingTime, Duration)));
ImGui::ProgressBar(RemainingTime / Duration, ImVec2(-1, ImGui::GetTextLineHeightWithSpacing() * 0.8f), TCHAR_TO_ANSI(*FString::Printf(TEXT("%.2f / %.2f"), RemainingTime, Duration)));
ImGui::PopStyleColor(2);
}
}
@@ -35,6 +35,8 @@ protected:
virtual void RenderAbilitiesTable(UAbilitySystemComponent& AbilitySystemComponent);
virtual void RenderAbilityCooldown(const UAbilitySystemComponent& AbilitySystemComponent, UGameplayAbility& Ability);
virtual void RenderAbilityContextMenu(UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec, int Index);
virtual void RenderOpenAbilities();
@@ -0,0 +1,19 @@
#include "CogEngineWindow_Audio.h"
#include "Engine/Engine.h"
//--------------------------------------------------------------------------------------------------------------------------
void UCogEngineWindow_Audio::RenderHelp()
{
ImGui::Text(
"This window displays audio settings. "
);
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogEngineWindow_Audio::RenderContent()
{
Super::RenderContent();
}
@@ -12,7 +12,7 @@ ImVec4 StatGreenColor(0.5f, 1.0f, 0.6f, 1.0f);
void UCogEngineWindow_Stats::RenderHelp()
{
ImGui::Text(
"This window display engine stats such as FPS, Ping, Packet Loss. "
"This window displays engine stats such as FPS, Ping, Packet Loss. "
);
}
@@ -0,0 +1,19 @@
#pragma once
#include "CoreMinimal.h"
#include "CogWindow.h"
#include "CogEngineWindow_Audio.generated.h"
UCLASS()
class COGENGINE_API UCogEngineWindow_Audio : public UCogWindow
{
GENERATED_BODY()
public:
protected:
virtual void RenderHelp() override;
virtual void RenderContent() override;
};
@@ -12,7 +12,7 @@
void UCogInputWindow_Actions::RenderHelp()
{
ImGui::Text(
"This window display the current state of each Input Action. "
"This window displays the current state of each Input Action. "
"It can also be used to inject inputs to help debugging. "
"The input action are read from a Input Mapping Context defined in '%s' data asset. "
, TCHAR_TO_ANSI(*GetNameSafe(ActionsAsset.Get()))