cheats and window menu persistence

This commit is contained in:
Arnaud Jamin
2023-10-10 02:10:18 -04:00
parent c9a3013bb9
commit 2d5e764e19
32 changed files with 154 additions and 85 deletions
@@ -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) void UCogAbilityWindow_Cheats::SetCheatsAsset(const UCogAbilityDataAsset_Cheats* Value)
{ {
CheatsAsset = Value; CheatsAsset = Value;
if (bReapplyCheatsBetweenPlays == false)
{
return;
}
static int32 IsFirstLaunch = true;
if (IsFirstLaunch && bReapplyCheatsBetweenLaunches == false)
{
return;
}
IsFirstLaunch = false;
if (CheatsAsset == nullptr) if (CheatsAsset == nullptr)
{ {
return; return;
@@ -76,13 +94,30 @@ void UCogAbilityWindow_Cheats::RenderContent()
return; return;
} }
APawn* ControlledActor = GetLocalPlayerPawn(); if (ImGui::BeginMenuBar())
if (SelectedActor == ControlledActor)
{ {
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)) if (ImGui::BeginTable("Cheats", 2, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize))
{ {
ImGui::TableSetupColumn("Toggle", ImGuiTableColumnFlags_WidthStretch); ImGui::TableSetupColumn("Toggle", ImGuiTableColumnFlags_WidthStretch);
@@ -91,15 +126,34 @@ void UCogAbilityWindow_Cheats::RenderContent()
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
bool bHasChanged = false;
int Index = 0; int Index = 0;
for (const FCogAbilityCheat& CheatEffect : CheatsAsset->PersistentEffects) for (const FCogAbilityCheat& CheatEffect : CheatsAsset->PersistentEffects)
{ {
ImGui::PushID(Index); ImGui::PushID(Index);
AddCheat(ControlledActor, SelectedActor, CheatEffect, true); bHasChanged |= AddCheat(ControlledActor, SelectedActor, CheatEffect, true);
ImGui::PopID(); ImGui::PopID();
Index++; 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(); ImGui::TableNextColumn();
for (const FCogAbilityCheat& CheatEffect : CheatsAsset->InstantEffects) 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) if (Cheat.Effect == nullptr)
{ {
return; return false;
} }
bool bIsPressed = false;
const FGameplayTagContainer& Tags = Cheat.Effect->GetDefaultObject<UGameplayEffect>()->InheritableGameplayEffectTags.CombinedTags; const FGameplayTagContainer& Tags = Cheat.Effect->GetDefaultObject<UGameplayEffect>()->InheritableGameplayEffectTags.CombinedTags;
FLinearColor Color; FLinearColor Color;
@@ -146,11 +202,7 @@ void UCogAbilityWindow_Cheats::AddCheat(AActor* ControlledActor, AActor* Selecte
if (ImGui::Checkbox(TCHAR_TO_ANSI(*Cheat.Name), &isEnabled)) if (ImGui::Checkbox(TCHAR_TO_ANSI(*Cheat.Name), &isEnabled))
{ {
RequestCheat(ControlledActor, SelectedActor, Cheat); RequestCheat(ControlledActor, SelectedActor, Cheat);
} bIsPressed = true;
if (isEnabled && SelectedActor == ControlledActor)
{
AppliedCheats.Add(Cheat.Name);
} }
} }
else else
@@ -158,6 +210,7 @@ void UCogAbilityWindow_Cheats::AddCheat(AActor* ControlledActor, AActor* Selecte
if (ImGui::Button(TCHAR_TO_ANSI(*Cheat.Name), ImVec2(-1, 0))) if (ImGui::Button(TCHAR_TO_ANSI(*Cheat.Name), ImVec2(-1, 0)))
{ {
RequestCheat(ControlledActor, SelectedActor, Cheat); RequestCheat(ControlledActor, SelectedActor, Cheat);
bIsPressed = true;
} }
} }
@@ -176,6 +229,8 @@ void UCogAbilityWindow_Cheats::AddCheat(AActor* ControlledActor, AActor* Selecte
} }
FCogWindowWidgets::PopBackColor(); 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;
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -15,14 +15,14 @@ class COGABILITY_API UCogAbilityWindow_Abilities : public UCogWindow
public: public:
UCogAbilityWindow_Abilities();
TWeakObjectPtr<UCogAbilityDataAsset_Abilities> AbilitiesAsset; TWeakObjectPtr<UCogAbilityDataAsset_Abilities> AbilitiesAsset;
protected: protected:
virtual void RenderHelp() override; virtual void RenderHelp() override;
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
virtual void RenderTick(float DetlaTime) override; virtual void RenderTick(float DetlaTime) override;
virtual void RenderContent() override; virtual void RenderContent() override;
@@ -9,12 +9,14 @@ class COGABILITY_API UCogAbilityWindow_Attributes : public UCogWindow
{ {
GENERATED_BODY() GENERATED_BODY()
public:
UCogAbilityWindow_Attributes();
protected: protected:
virtual void RenderHelp() override; virtual void RenderHelp() override;
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
virtual void RenderContent() override; virtual void RenderContent() override;
virtual void DrawAttributeInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute); virtual void DrawAttributeInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute);
@@ -15,6 +15,8 @@ class COGABILITY_API UCogAbilityWindow_Cheats : public UCogWindow
public: public:
UCogAbilityWindow_Cheats();
const UCogAbilityDataAsset_Cheats* GetCheatsAsset() const { return CheatsAsset.Get(); } const UCogAbilityDataAsset_Cheats* GetCheatsAsset() const { return CheatsAsset.Get(); }
void SetCheatsAsset(const UCogAbilityDataAsset_Cheats* Value); void SetCheatsAsset(const UCogAbilityDataAsset_Cheats* Value);
@@ -27,10 +29,16 @@ protected:
private: 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); void RequestCheat(AActor* ControlledActor, AActor* TargetActor, const FCogAbilityCheat& CheatEffect);
UPROPERTY(Config)
bool bReapplyCheatsBetweenPlays = true;
UPROPERTY(Config)
bool bReapplyCheatsBetweenLaunches = true;
UPROPERTY(Config) UPROPERTY(Config)
TArray<FString> AppliedCheats; TArray<FString> AppliedCheats;
@@ -12,6 +12,8 @@ class COGABILITY_API UCogAbilityWindow_Effects : public UCogWindow
public: public:
UCogAbilityWindow_Effects();
FGameplayTag NegativeEffectTag; FGameplayTag NegativeEffectTag;
FGameplayTag PositiveEffectTag; FGameplayTag PositiveEffectTag;
@@ -20,8 +22,6 @@ protected:
virtual void RenderHelp() override; virtual void RenderHelp() override;
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
virtual void RenderContent() override; virtual void RenderContent() override;
virtual void RenderEffectsTable(); virtual void RenderEffectsTable();
@@ -9,10 +9,13 @@ class COGABILITY_API UCogAbilityWindow_Tags : public UCogWindow
{ {
GENERATED_BODY() GENERATED_BODY()
protected: public:
virtual void RenderHelp() override;
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override; UCogAbilityWindow_Tags();
protected:
virtual void RenderHelp() override;
virtual void RenderContent() override; virtual void RenderContent() override;
@@ -22,9 +22,9 @@ void UCogEngineWindow_Collisions::RenderHelp()
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void UCogEngineWindow_Collisions::PreRender(ImGuiWindowFlags& WindowFlags) UCogEngineWindow_Collisions::UCogEngineWindow_Collisions()
{ {
WindowFlags = ImGuiWindowFlags_MenuBar; bHasMenu = true;
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -57,9 +57,9 @@ void UCogEngineWindow_DebugSettings::PreSaveConfig()
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void UCogEngineWindow_DebugSettings::PreRender(ImGuiWindowFlags& WindowFlags) UCogEngineWindow_DebugSettings::UCogEngineWindow_DebugSettings()
{ {
WindowFlags = ImGuiWindowFlags_MenuBar; bHasMenu = true;
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -18,9 +18,9 @@ void UCogEngineWindow_LogCategories::RenderHelp()
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void UCogEngineWindow_LogCategories::PreRender(ImGuiWindowFlags& WindowFlags) UCogEngineWindow_LogCategories::UCogEngineWindow_LogCategories()
{ {
WindowFlags = ImGuiWindowFlags_MenuBar; bHasMenu = true;
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -32,9 +32,9 @@ void UCogEngineWindow_Metrics::PreSaveConfig()
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void UCogEngineWindow_Metrics::PreRender(ImGuiWindowFlags& WindowFlags) UCogEngineWindow_Metrics::UCogEngineWindow_Metrics()
{ {
WindowFlags = ImGuiWindowFlags_MenuBar; bHasMenu = true;
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -37,6 +37,7 @@ void UCogLogOutputDevice::Serialize(const TCHAR* Message, ELogVerbosity::Type Ve
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
UCogEngineWindow_OutputLog::UCogEngineWindow_OutputLog() UCogEngineWindow_OutputLog::UCogEngineWindow_OutputLog()
{ {
bHasMenu = true;
OutputDevice.OutputLog = this; OutputDevice.OutputLog = this;
} }
@@ -148,12 +149,6 @@ void UCogEngineWindow_OutputLog::DrawRow(const char* BufferStart, const FLineInf
ImGui::PopStyleColor(); ImGui::PopStyleColor();
} }
//--------------------------------------------------------------------------------------------------------------------------
void UCogEngineWindow_OutputLog::PreRender(ImGuiWindowFlags& WindowFlags)
{
WindowFlags = ImGuiWindowFlags_MenuBar;
}
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void UCogEngineWindow_OutputLog::RenderContent() void UCogEngineWindow_OutputLog::RenderContent()
{ {
@@ -20,9 +20,9 @@ void UCogEngineWindow_Selection::RenderHelp()
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void UCogEngineWindow_Selection::PreRender(ImGuiWindowFlags& WindowFlags) UCogEngineWindow_Selection::UCogEngineWindow_Selection()
{ {
WindowFlags = ImGuiWindowFlags_MenuBar; bHasMenu = true;
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -475,7 +475,7 @@ void UCogEngineWindow_Selection::DrawMainMenuWidget(bool Draw, float& Width)
ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyleColorVec4((ImGuiCol_FrameBg))); ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyleColorVec4((ImGuiCol_FrameBg)));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImGui::GetStyleColorVec4((ImGuiCol_FrameBgActive))); ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImGui::GetStyleColorVec4((ImGuiCol_FrameBgActive)));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetStyleColorVec4((ImGuiCol_FrameBgHovered))); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetStyleColorVec4((ImGuiCol_FrameBgHovered)));
ImGui::SameLine(ImGui::GetCursorPos().x - ResetButtonWidth + (ImGui::GetStyle().WindowPadding.x - 2) * ImGui::GetWindowDpiScale()); ImGui::SameLine();
if (ImGui::Button("X", ImVec2(ResetButtonWidth, 0))) if (ImGui::Button("X", ImVec2(ResetButtonWidth, 0)))
{ {
FCogDebugSettings::SetSelection(nullptr); FCogDebugSettings::SetSelection(nullptr);
@@ -8,12 +8,7 @@
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
UCogEngineWindow_Skeleton::UCogEngineWindow_Skeleton() UCogEngineWindow_Skeleton::UCogEngineWindow_Skeleton()
{ {
} bHasMenu = true;
//--------------------------------------------------------------------------------------------------------------------------
void UCogEngineWindow_Skeleton::PreRender(ImGuiWindowFlags& WindowFlags)
{
WindowFlags = ImGuiWindowFlags_MenuBar;
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -10,12 +10,6 @@ void UCogEngineWindow_Spawns::RenderHelp()
); );
} }
//--------------------------------------------------------------------------------------------------------------------------
void UCogEngineWindow_Spawns::PreRender(ImGuiWindowFlags& WindowFlags)
{
Super::PreRender(WindowFlags);
}
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void UCogEngineWindow_Spawns::RenderContent() void UCogEngineWindow_Spawns::RenderContent()
{ {
@@ -13,14 +13,14 @@ class COGENGINE_API UCogEngineWindow_Collisions : public UCogWindow
public: public:
UCogEngineWindow_Collisions();
void SetCollisionsAsset(const UCogEngineDataAsset_Collisions* Asset); void SetCollisionsAsset(const UCogEngineDataAsset_Collisions* Asset);
private: private:
virtual void RenderHelp() override; virtual void RenderHelp() override;
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
virtual void RenderContent() override; virtual void RenderContent() override;
struct FChannel struct FChannel
@@ -9,6 +9,10 @@ class COGENGINE_API UCogEngineWindow_DebugSettings : public UCogWindow
{ {
GENERATED_BODY() GENERATED_BODY()
public:
UCogEngineWindow_DebugSettings();
protected: protected:
virtual void RenderHelp() override; virtual void RenderHelp() override;
@@ -17,8 +21,6 @@ protected:
virtual void PostInitProperties() override; virtual void PostInitProperties() override;
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
virtual void RenderContent() override; virtual void RenderContent() override;
private: private:
@@ -11,9 +11,9 @@ class COGENGINE_API UCogEngineWindow_LogCategories : public UCogWindow
public: public:
virtual void RenderHelp() override; UCogEngineWindow_LogCategories();
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override; virtual void RenderHelp() override;
virtual void RenderContent() override; virtual void RenderContent() override;
}; };
@@ -14,6 +14,8 @@ class COGENGINE_API UCogEngineWindow_Metrics : public UCogWindow
public: public:
UCogEngineWindow_Metrics();
protected: protected:
virtual void PostInitProperties() override; virtual void PostInitProperties() override;
@@ -22,8 +24,6 @@ protected:
virtual void RenderHelp() override; virtual void RenderHelp() override;
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
virtual void RenderContent() override; virtual void RenderContent() override;
virtual void RenderTick(float DeltaTime) override; virtual void RenderTick(float DeltaTime) override;
@@ -40,8 +40,6 @@ protected:
virtual void RenderHelp() override; virtual void RenderHelp() override;
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
virtual void RenderContent() override; virtual void RenderContent() override;
private: private:
@@ -12,6 +12,8 @@ class COGENGINE_API UCogEngineWindow_Selection : public UCogWindow
public: public:
UCogEngineWindow_Selection();
bool GetIsSelecting() const { return bSelectionModeActive; } bool GetIsSelecting() const { return bSelectionModeActive; }
void SetCurrentActorSubClass(TSubclassOf<AActor> Value) { SelectedSubClass = Value; } void SetCurrentActorSubClass(TSubclassOf<AActor> Value) { SelectedSubClass = Value; }
@@ -32,8 +34,6 @@ protected:
virtual void RenderTick(float DeltaTime) override; virtual void RenderTick(float DeltaTime) override;
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
virtual void RenderContent() override; virtual void RenderContent() override;
virtual void DrawMainMenuWidget(bool Draw, float& Width) override; virtual void DrawMainMenuWidget(bool Draw, float& Width) override;
@@ -35,7 +35,7 @@ public:
virtual void RenderTick(float DeltaTime) override; virtual void RenderTick(float DeltaTime) override;
protected: protected:
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
virtual void OnSelectionChanged(AActor* OldSelection, AActor* NewSelection) override; virtual void OnSelectionChanged(AActor* OldSelection, AActor* NewSelection) override;
private: private:
@@ -12,7 +12,7 @@ class COGENGINE_API UCogEngineWindow_Spawns : public UCogWindow
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
const UCogEngineDataAsset_Spawns* GetSpawnsAsset() const { return SpawnAsset; } const UCogEngineDataAsset_Spawns* GetSpawnsAsset() const { return SpawnAsset; }
@@ -22,8 +22,6 @@ protected:
virtual void RenderHelp(); virtual void RenderHelp();
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
virtual void RenderContent() override; virtual void RenderContent() override;
virtual void RenderSpawnGroup(const FCogEngineSpawnGroup& SpawnGroup); virtual void RenderSpawnGroup(const FCogEngineSpawnGroup& SpawnGroup);
@@ -20,9 +20,9 @@ void UCogInputWindow_Actions::RenderHelp()
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void UCogInputWindow_Actions::PreRender(ImGuiWindowFlags& WindowFlags) UCogInputWindow_Actions::UCogInputWindow_Actions()
{ {
WindowFlags = ImGuiWindowFlags_MenuBar; bHasMenu = true;
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -237,10 +237,6 @@ void UCogInputWindow_Gamepad::RenderContent()
} }
} }
} }
else
{
ImGui::Text("No Actions in Action Asset");
}
} }
else else
{ {
@@ -15,14 +15,14 @@ class COGINPUT_API UCogInputWindow_Actions : public UCogWindow
public: public:
TWeakObjectPtr<UCogInputDataAsset_Actions> ActionsAsset; UCogInputWindow_Actions();
TWeakObjectPtr<UCogInputDataAsset_Actions> ActionsAsset;
protected: protected:
void RenderHelp(); void RenderHelp();
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
virtual void RenderContent() override; virtual void RenderContent() override;
virtual void RenderTick(float DeltaSeconds) override; virtual void RenderTick(float DeltaSeconds) override;
@@ -13,10 +13,13 @@ class COGINPUT_API UCogInputWindow_Gamepad : public UCogWindow
GENERATED_BODY() GENERATED_BODY()
public: public:
UCogInputWindow_Gamepad(); UCogInputWindow_Gamepad();
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override; virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
virtual void RenderContent() override; virtual void RenderContent() override;
virtual void RenderTick(float DeltaSeconds) override; virtual void RenderTick(float DeltaSeconds) override;
TWeakObjectPtr<UCogInputDataAsset_Actions> ActionsAsset; TWeakObjectPtr<UCogInputDataAsset_Actions> ActionsAsset;
@@ -56,6 +56,11 @@ void UCogWindow::Render(float DeltaTime)
const FString WindowTitle = GetTitle() + "##" + Name; const FString WindowTitle = GetTitle() + "##" + Name;
if (bHasMenu && bHideMenu == false)
{
WindowFlags |= ImGuiWindowFlags_MenuBar;
}
if (ImGui::Begin(TCHAR_TO_ANSI(*WindowTitle), &bIsVisible, WindowFlags)) if (ImGui::Begin(TCHAR_TO_ANSI(*WindowTitle), &bIsVisible, WindowFlags))
{ {
if (Owner->GetShowHelp()) if (Owner->GetShowHelp())
@@ -77,6 +82,16 @@ void UCogWindow::Render(float DeltaTime)
} }
} }
if (bHasMenu)
{
if (ImGui::BeginPopupContextWindow())
{
ImGui::Checkbox("Hide Menu", &bHideMenu);
ImGui::EndPopup();
}
}
RenderContent(); RenderContent();
ImGui::End(); ImGui::End();
} }
@@ -77,12 +77,17 @@ protected:
ULocalPlayer* GetLocalPlayer(); ULocalPlayer* GetLocalPlayer();
UPROPERTY(Config)
bool bHasMenu = false;
private: private:
bool bIsVisible = false; bool bIsVisible = false;
bool bShowInsideMenu = true; bool bShowInsideMenu = true;
bool bHideMenu = false;
ImGuiID ID; ImGuiID ID;
FString FullName; FString FullName;