mirror of
https://github.com/Ed94/Cog.git
synced 2026-07-31 11:50:06 +00:00
starting to add the hud in the sample
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user