CogAbility: Plot Window minor UI tweak

This commit is contained in:
Arnaud Jamin
2025-01-17 11:27:17 -05:00
parent 6d8f7cb975
commit d7bd68618f
6 changed files with 175 additions and 187 deletions
@@ -157,9 +157,9 @@ void FCogEngineWindow_Cheats::TryReapplyCheats()
//--------------------------------------------------------------------------------------------------------------------------
bool FCogEngineWindow_Cheats::DrawTable()
{
const bool Open = ImGui::BeginTable("Cheats", 2, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize);
ImGui::TableSetupColumn("Toggle", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("Instant", ImGuiTableColumnFlags_WidthStretch);
const bool Open = ImGui::BeginTable("Cheats", 2, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize);
ImGui::TableSetupColumn("Toggle", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("Instant", ImGuiTableColumnFlags_WidthStretch);
return Open;
}
@@ -203,7 +203,7 @@ void FCogEngineWindow_Cheats::RenderContent()
ImGui::BeginDisabled();
}
ImGui::Checkbox("Reapply Cheats Between Launches", &Config->bReapplyCheatsBetweenLaunches);
ImGui::Checkbox("Reapply Cheats Between Launches", &Config->bReapplyCheatsBetweenLaunches);
if (Config->bReapplyCheatsBetweenPlays == false)
{
ImGui::EndDisabled();
@@ -232,7 +232,7 @@ void FCogEngineWindow_Cheats::RenderContent()
{
if (IsSelected)
{
Config->SelectedCategories.Add(CheatCategory.Name);
Config->SelectedCategories.Add(CheatCategory.Name);
}
else
{
@@ -254,7 +254,7 @@ void FCogEngineWindow_Cheats::RenderContent()
if (Config->bGroupByCategories == false && Config->bUseTwoColumns)
{
OpenTable = DrawTable();
}
}
for (const FCogEngineCheatCategory& CheatCategory : Asset->CheatCategories)
{
@@ -266,73 +266,67 @@ void FCogEngineWindow_Cheats::RenderContent()
bool Open = true;
if (Config->bGroupByCategories)
{
ImGui::PushStyleColor(ImGuiCol_Header, IM_COL32(66, 66, 66, 79));
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, IM_COL32(62, 62, 62, 204));
ImGui::PushStyleColor(ImGuiCol_HeaderActive, IM_COL32(86, 86, 86, 255));
Open = FCogWindowWidgets::DarkCollapsingHeader(CategoryStr.Get(), ImGuiTreeNodeFlags_DefaultOpen);
Open = ImGui::CollapsingHeader(CategoryStr.Get(), ImGuiTreeNodeFlags_DefaultOpen);
ImGui::PopStyleColor(3);
if (Open && Config->bUseTwoColumns)
{
DrawTable();
}
if (Open && Config->bUseTwoColumns)
{
DrawTable();
}
}
if (Open)
{
if (Open)
{
if (Config->bUseTwoColumns)
{
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TableNextRow();
ImGui::TableNextColumn();
}
int Index = 0;
for (const FCogEngineCheat& Cheat : CheatCategory.PersistentEffects)
{
AddCheat(Index, ControlledActor, SelectedActor, Cheat, true);
Index++;
}
int Index = 0;
for (const FCogEngineCheat& Cheat : CheatCategory.PersistentEffects)
{
AddCheat(Index, ControlledActor, SelectedActor, Cheat, true);
Index++;
}
//----------------------------------------------------------------------------
// Update the config of applied cheat to reapply them on the next launch.
// We do not update them only when the user input is pressed because
// the state of the cheat is lagging when connected to a server.
// So we check if the array should be updated all the time.
//----------------------------------------------------------------------------
if (SelectedActor == ControlledActor)
{
for (const FCogEngineCheat& Cheat : CheatCategory.PersistentEffects)
{
TArray<AActor*> Targets = { SelectedActor };
if (ACogEngineReplicator::IsCheatActiveOnTargets(Targets, Cheat) == ECogEngineCheat_ActiveState::Active)
{
Config->AppliedCheats.AddUnique(Cheat.Name);
}
else
{
Config->AppliedCheats.Remove(Cheat.Name);
}
}
}
//----------------------------------------------------------------------------
// Update the config of applied cheat to reapply them on the next launch.
// We do not update them only when the user input is pressed because
// the state of the cheat is lagging when connected to a server.
// So we check if the array should be updated all the time.
//----------------------------------------------------------------------------
if (SelectedActor == ControlledActor)
{
for (const FCogEngineCheat& Cheat : CheatCategory.PersistentEffects)
{
TArray<AActor*> Targets = { SelectedActor };
if (ACogEngineReplicator::IsCheatActiveOnTargets(Targets, Cheat) == ECogEngineCheat_ActiveState::Active)
{
Config->AppliedCheats.AddUnique(Cheat.Name);
}
else
{
Config->AppliedCheats.Remove(Cheat.Name);
}
}
}
ImGui::TableNextColumn();
ImGui::TableNextColumn();
Index = 0;
for (const FCogEngineCheat& Cheat : CheatCategory.InstantEffects)
{
AddCheat(Index, ControlledActor, SelectedActor, Cheat, false);
Index++;
}
Index = 0;
for (const FCogEngineCheat& Cheat : CheatCategory.InstantEffects)
{
AddCheat(Index, ControlledActor, SelectedActor, Cheat, false);
Index++;
}
if (Config->bGroupByCategories && Config->bUseTwoColumns)
{
ImGui::EndTable();
ImGui::EndTable();
}
}
}
}
}
if (OpenTable)
{
@@ -350,7 +344,7 @@ bool FCogEngineWindow_Cheats::AddCheat(const int32 Index, AActor* ControlledActo
ImGui::PushID(Index);
FCogWindowWidgets::PushBackColor(FCogImguiHelper::ToImVec4(Cheat.CustomColor));
FCogWindowWidgets::PushBackColor(FCogImguiHelper::ToImVec4(Cheat.CustomColor));
const bool IsShiftDown = (ImGui::GetCurrentContext()->IO.KeyMods & ImGuiMod_Shift) != 0;
const bool IsAltDown = (ImGui::GetCurrentContext()->IO.KeyMods & ImGuiMod_Alt) != 0;
@@ -386,7 +380,7 @@ bool FCogEngineWindow_Cheats::AddCheat(const int32 Index, AActor* ControlledActo
ImGui::EndTooltip();
}
FCogWindowWidgets::PopBackColor();
FCogWindowWidgets::PopBackColor();
ImGui::PopID();
@@ -455,19 +449,19 @@ const FCogEngineCheat* FCogEngineWindow_Cheats::FindCheatByName(const FString& C
if (OnlyPersistentCheats)
{
continue;
continue;
}
for (const FCogEngineCheat& Cheat : CheatCategory.InstantEffects)
{
if (Cheat.Name == CheatName)
{
return &Cheat;
}
}
for (const FCogEngineCheat& Cheat : CheatCategory.InstantEffects)
{
if (Cheat.Name == CheatName)
{
return &Cheat;
}
}
}
}
return nullptr;
}
@@ -17,7 +17,7 @@ void FCogEngineWindow_Plots::Initialize()
Config = GetConfig<UCogEngineConfig_Plots>();
FCogDebugPlot::Clear();
FCogDebugPlot::Clear();
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -173,30 +173,30 @@ void FCogEngineWindow_Plots::RenderMenu()
//--------------------------------------------------------------------------------------------------------------------------
void FCogEngineWindow_Plots::RenderEntryName(const int Index, FCogDebugPlotEntry& Entry)
{
ImGui::PushID(Index);
ImGui::PushID(Index);
const bool IsAssignedToRow = Entry.GraphIndex != INDEX_NONE;
if (ImGui::Selectable(TCHAR_TO_ANSI(*Entry.Name.ToString()), IsAssignedToRow, ImGuiSelectableFlags_AllowDoubleClick))
{
if (IsAssignedToRow)
{
const bool IsAssignedToRow = Entry.GraphIndex != INDEX_NONE;
if (ImGui::Selectable(TCHAR_TO_ANSI(*Entry.Name.ToString()), IsAssignedToRow, ImGuiSelectableFlags_AllowDoubleClick))
{
if (IsAssignedToRow)
{
Entry.ResetGraphAndAxis();
}
else
{
}
else
{
Entry.AssignGraphAndAxis(0, ImAxis_Y1);
}
}
}
}
if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_None))
{
const auto EntryName = StringCast<ANSICHAR>(*Entry.Name.ToString());
ImGui::SetDragDropPayload("DragAndDrop", EntryName.Get(), EntryName.Length() + 1);
ImGui::Text("%s", EntryName.Get());
ImGui::EndDragDropSource();
}
if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_None))
{
const auto EntryName = StringCast<ANSICHAR>(*Entry.Name.ToString());
ImGui::SetDragDropPayload("DragAndDrop", EntryName.Get(), EntryName.Length() + 1);
ImGui::Text("%s", EntryName.Get());
ImGui::EndDragDropSource();
}
ImGui::PopID();
ImGui::PopID();
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -211,30 +211,23 @@ void FCogEngineWindow_Plots::RenderAllEntriesNames(const ImVec2& InSize)
int Index = 0;
ImGui::PushStyleColor(ImGuiCol_Header, IM_COL32(66, 66, 66, 79));
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, IM_COL32(62, 62, 62, 204));
ImGui::PushStyleColor(ImGuiCol_HeaderActive, IM_COL32(86, 86, 86, 255));
if (ImGui::CollapsingHeader("Events", ImGuiTreeNodeFlags_DefaultOpen))
if (FCogWindowWidgets::DarkCollapsingHeader("Events", ImGuiTreeNodeFlags_DefaultOpen))
{
if (FCogDebugPlot::Events.IsEmpty())
{
ImGui::TextDisabled("No event added yet");
}
if (FCogDebugPlot::Events.IsEmpty())
{
ImGui::TextDisabled("No event added yet");
}
else
{
for (FCogDebugPlotEntry& Event : FCogDebugPlot::Events)
{
RenderEntryName(Index, Event);
Index++;
}
for (FCogDebugPlotEntry& Event : FCogDebugPlot::Events)
{
RenderEntryName(Index, Event);
Index++;
}
}
}
ImGui::PopStyleColor(3);
ImGui::PushStyleColor(ImGuiCol_Header, IM_COL32(66, 66, 66, 79));
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, IM_COL32(62, 62, 62, 204));
ImGui::PushStyleColor(ImGuiCol_HeaderActive, IM_COL32(86, 86, 86, 255));
if (ImGui::CollapsingHeader("Plots", ImGuiTreeNodeFlags_DefaultOpen))
if (FCogWindowWidgets::DarkCollapsingHeader("Plots", ImGuiTreeNodeFlags_DefaultOpen))
{
if (FCogDebugPlot::Plots.IsEmpty())
{
@@ -242,14 +235,13 @@ void FCogEngineWindow_Plots::RenderAllEntriesNames(const ImVec2& InSize)
}
else
{
for (FCogDebugPlotEntry& Plot : FCogDebugPlot::Plots)
{
RenderEntryName(Index, Plot);
Index++;
}
for (FCogDebugPlotEntry& Plot : FCogDebugPlot::Plots)
{
RenderEntryName(Index, Plot);
Index++;
}
}
}
ImGui::PopStyleColor(3);
if (Config->DockEntries)
{
@@ -56,14 +56,10 @@ void FCogEngineWindow_Spawns::RenderContent()
//--------------------------------------------------------------------------------------------------------------------------
void FCogEngineWindow_Spawns::RenderSpawnGroup(ACogEngineReplicator& Replicator, const FCogEngineSpawnGroup& SpawnGroup)
{
ImGui::PushStyleColor(ImGuiCol_Header, IM_COL32(66, 66, 66, 79));
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, IM_COL32(62, 62, 62, 204));
ImGui::PushStyleColor(ImGuiCol_HeaderActive, IM_COL32(86, 86, 86, 255));
if (ImGui::CollapsingHeader(TCHAR_TO_ANSI(*SpawnGroup.Name), ImGuiTreeNodeFlags_DefaultOpen))
if (FCogWindowWidgets::DarkCollapsingHeader(TCHAR_TO_ANSI(*SpawnGroup.Name), ImGuiTreeNodeFlags_DefaultOpen))
{
int32 GroupIndex = 0;
ImGui::PushID(GroupIndex);
int32 GroupIndex = 0;
ImGui::PushID(GroupIndex);
const bool PushColor = (SpawnGroup.Color != FColor::Transparent);
if (PushColor)
@@ -92,8 +88,6 @@ void FCogEngineWindow_Spawns::RenderSpawnGroup(ACogEngineReplicator& Replicator,
ImGui::PopID();
GroupIndex++;
}
ImGui::PopStyleColor(3);
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -117,7 +111,7 @@ bool FCogEngineWindow_Spawns::RenderSpawnAsset(ACogEngineReplicator& Replicator,
if (ImGui::Button(TCHAR_TO_ANSI(*EntryName), ImVec2(-1, 0)))
{
IsPressed = true;
Replicator.Server_Spawn(SpawnEntry);
Replicator.Server_Spawn(SpawnEntry);
}
ImGui::PopStyleVar(1);