mirror of
https://github.com/Ed94/Cog.git
synced 2026-08-04 22:58:45 +00:00
cheats and window menu persistence
This commit is contained in:
@@ -21,9 +21,9 @@ void UCogAbilityWindow_Abilities::RenderHelp()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityWindow_Abilities::PreRender(ImGuiWindowFlags& WindowFlags)
|
||||
UCogAbilityWindow_Abilities::UCogAbilityWindow_Abilities()
|
||||
{
|
||||
WindowFlags = ImGuiWindowFlags_MenuBar;
|
||||
bHasMenu = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -21,9 +21,9 @@ void UCogAbilityWindow_Attributes::RenderHelp()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityWindow_Attributes::PreRender(ImGuiWindowFlags& WindowFlags)
|
||||
UCogAbilityWindow_Attributes::UCogAbilityWindow_Attributes()
|
||||
{
|
||||
WindowFlags = ImGuiWindowFlags_MenuBar;
|
||||
bHasMenu = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -25,11 +25,29 @@ void UCogAbilityWindow_Cheats::RenderHelp()
|
||||
);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UCogAbilityWindow_Cheats::UCogAbilityWindow_Cheats()
|
||||
{
|
||||
bHasMenu = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityWindow_Cheats::SetCheatsAsset(const UCogAbilityDataAsset_Cheats* Value)
|
||||
{
|
||||
CheatsAsset = Value;
|
||||
|
||||
if (bReapplyCheatsBetweenPlays == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static int32 IsFirstLaunch = true;
|
||||
if (IsFirstLaunch && bReapplyCheatsBetweenLaunches == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
IsFirstLaunch = false;
|
||||
|
||||
if (CheatsAsset == nullptr)
|
||||
{
|
||||
return;
|
||||
@@ -76,13 +94,30 @@ void UCogAbilityWindow_Cheats::RenderContent()
|
||||
return;
|
||||
}
|
||||
|
||||
APawn* ControlledActor = GetLocalPlayerPawn();
|
||||
|
||||
if (SelectedActor == ControlledActor)
|
||||
if (ImGui::BeginMenuBar())
|
||||
{
|
||||
AppliedCheats.Empty();
|
||||
if (ImGui::BeginMenu("Options"))
|
||||
{
|
||||
ImGui::Checkbox("Reapply Cheats Between Plays", &bReapplyCheatsBetweenPlays);
|
||||
|
||||
if (bReapplyCheatsBetweenPlays == false)
|
||||
{
|
||||
ImGui::BeginDisabled();
|
||||
}
|
||||
ImGui::Checkbox("Reapply Cheats Between Launches", &bReapplyCheatsBetweenLaunches);
|
||||
|
||||
if (bReapplyCheatsBetweenPlays == false)
|
||||
{
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
APawn* ControlledActor = GetLocalPlayerPawn();
|
||||
|
||||
if (ImGui::BeginTable("Cheats", 2, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize))
|
||||
{
|
||||
ImGui::TableSetupColumn("Toggle", ImGuiTableColumnFlags_WidthStretch);
|
||||
@@ -91,15 +126,34 @@ void UCogAbilityWindow_Cheats::RenderContent()
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
bool bHasChanged = false;
|
||||
|
||||
int Index = 0;
|
||||
for (const FCogAbilityCheat& CheatEffect : CheatsAsset->PersistentEffects)
|
||||
{
|
||||
ImGui::PushID(Index);
|
||||
AddCheat(ControlledActor, SelectedActor, CheatEffect, true);
|
||||
bHasChanged |= AddCheat(ControlledActor, SelectedActor, CheatEffect, true);
|
||||
ImGui::PopID();
|
||||
Index++;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// When a persistent cheat has been changed, update the applied
|
||||
// cheats string array to be saved in the config later
|
||||
//----------------------------------------------------------------
|
||||
if (bHasChanged && SelectedActor == ControlledActor)
|
||||
{
|
||||
AppliedCheats.Empty();
|
||||
|
||||
for (const FCogAbilityCheat& CheatEffect : CheatsAsset->PersistentEffects)
|
||||
{
|
||||
if (ACogAbilityReplicator::IsCheatActive(SelectedActor, CheatEffect))
|
||||
{
|
||||
AppliedCheats.Add(CheatEffect.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
for (const FCogAbilityCheat& CheatEffect : CheatsAsset->InstantEffects)
|
||||
@@ -115,13 +169,15 @@ void UCogAbilityWindow_Cheats::RenderContent()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityWindow_Cheats::AddCheat(AActor* ControlledActor, AActor* SelectedActor, const FCogAbilityCheat& Cheat, bool IsPersistent)
|
||||
bool UCogAbilityWindow_Cheats::AddCheat(AActor* ControlledActor, AActor* SelectedActor, const FCogAbilityCheat& Cheat, bool IsPersistent)
|
||||
{
|
||||
if (Cheat.Effect == nullptr)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bIsPressed = false;
|
||||
|
||||
const FGameplayTagContainer& Tags = Cheat.Effect->GetDefaultObject<UGameplayEffect>()->InheritableGameplayEffectTags.CombinedTags;
|
||||
|
||||
FLinearColor Color;
|
||||
@@ -146,11 +202,7 @@ void UCogAbilityWindow_Cheats::AddCheat(AActor* ControlledActor, AActor* Selecte
|
||||
if (ImGui::Checkbox(TCHAR_TO_ANSI(*Cheat.Name), &isEnabled))
|
||||
{
|
||||
RequestCheat(ControlledActor, SelectedActor, Cheat);
|
||||
}
|
||||
|
||||
if (isEnabled && SelectedActor == ControlledActor)
|
||||
{
|
||||
AppliedCheats.Add(Cheat.Name);
|
||||
bIsPressed = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -158,6 +210,7 @@ void UCogAbilityWindow_Cheats::AddCheat(AActor* ControlledActor, AActor* Selecte
|
||||
if (ImGui::Button(TCHAR_TO_ANSI(*Cheat.Name), ImVec2(-1, 0)))
|
||||
{
|
||||
RequestCheat(ControlledActor, SelectedActor, Cheat);
|
||||
bIsPressed = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,6 +229,8 @@ void UCogAbilityWindow_Cheats::AddCheat(AActor* ControlledActor, AActor* Selecte
|
||||
}
|
||||
|
||||
FCogWindowWidgets::PopBackColor();
|
||||
|
||||
return bIsPressed;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -18,9 +18,9 @@ void UCogAbilityWindow_Effects::RenderHelp()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityWindow_Effects::PreRender(ImGuiWindowFlags& WindowFlags)
|
||||
UCogAbilityWindow_Effects::UCogAbilityWindow_Effects()
|
||||
{
|
||||
Super::PreRender(WindowFlags);
|
||||
bHasMenu = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -11,9 +11,9 @@ void UCogAbilityWindow_Tags::RenderHelp()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityWindow_Tags::PreRender(ImGuiWindowFlags& WindowFlags)
|
||||
UCogAbilityWindow_Tags::UCogAbilityWindow_Tags()
|
||||
{
|
||||
Super::PreRender(WindowFlags);
|
||||
bHasMenu = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -14,15 +14,15 @@ class COGABILITY_API UCogAbilityWindow_Abilities : public UCogWindow
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
|
||||
UCogAbilityWindow_Abilities();
|
||||
|
||||
TWeakObjectPtr<UCogAbilityDataAsset_Abilities> AbilitiesAsset;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void RenderHelp() override;
|
||||
|
||||
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
|
||||
|
||||
virtual void RenderTick(float DetlaTime) override;
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
@@ -9,12 +9,14 @@ class COGABILITY_API UCogAbilityWindow_Attributes : public UCogWindow
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UCogAbilityWindow_Attributes();
|
||||
|
||||
protected:
|
||||
|
||||
virtual void RenderHelp() override;
|
||||
|
||||
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
virtual void DrawAttributeInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute);
|
||||
|
||||
@@ -15,6 +15,8 @@ class COGABILITY_API UCogAbilityWindow_Cheats : public UCogWindow
|
||||
|
||||
public:
|
||||
|
||||
UCogAbilityWindow_Cheats();
|
||||
|
||||
const UCogAbilityDataAsset_Cheats* GetCheatsAsset() const { return CheatsAsset.Get(); }
|
||||
|
||||
void SetCheatsAsset(const UCogAbilityDataAsset_Cheats* Value);
|
||||
@@ -27,10 +29,16 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
void AddCheat(AActor* ControlledActor, AActor* TargetActor, const FCogAbilityCheat& CheatEffect, bool IsPersistent);
|
||||
bool AddCheat(AActor* ControlledActor, AActor* TargetActor, const FCogAbilityCheat& CheatEffect, bool IsPersistent);
|
||||
|
||||
void RequestCheat(AActor* ControlledActor, AActor* TargetActor, const FCogAbilityCheat& CheatEffect);
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool bReapplyCheatsBetweenPlays = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool bReapplyCheatsBetweenLaunches = true;
|
||||
|
||||
UPROPERTY(Config)
|
||||
TArray<FString> AppliedCheats;
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ class COGABILITY_API UCogAbilityWindow_Effects : public UCogWindow
|
||||
|
||||
public:
|
||||
|
||||
UCogAbilityWindow_Effects();
|
||||
|
||||
FGameplayTag NegativeEffectTag;
|
||||
|
||||
FGameplayTag PositiveEffectTag;
|
||||
@@ -20,8 +22,6 @@ protected:
|
||||
|
||||
virtual void RenderHelp() override;
|
||||
|
||||
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
virtual void RenderEffectsTable();
|
||||
|
||||
@@ -9,10 +9,13 @@ class COGABILITY_API UCogAbilityWindow_Tags : public UCogWindow
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
protected:
|
||||
virtual void RenderHelp() override;
|
||||
public:
|
||||
|
||||
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
|
||||
UCogAbilityWindow_Tags();
|
||||
|
||||
protected:
|
||||
|
||||
virtual void RenderHelp() override;
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user