Merge branch 'main' into new-windows

This commit is contained in:
Arnaud Jamin
2024-01-08 01:36:47 -05:00
11 changed files with 279 additions and 129 deletions
Binary file not shown.
@@ -5,7 +5,6 @@
#include "DrawDebugHelpers.h"
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakePoint(const FVector& Location, const float Size, const FColor& Color, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
@@ -21,7 +20,6 @@ FCogDebugShape FCogDebugShape::MakePoint(const FVector& Location, const float Si
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawPoint(UWorld* World) const
{
#if ENABLE_COG
@@ -42,7 +40,6 @@ void FCogDebugShape::DrawPoint(UWorld* World) const
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeSegment(const FVector& StartLocation, const FVector& EndLocation, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
@@ -59,7 +56,6 @@ FCogDebugShape FCogDebugShape::MakeSegment(const FVector& StartLocation, const F
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawSegment(UWorld* World) const
{
#if ENABLE_COG
@@ -81,7 +77,6 @@ void FCogDebugShape::DrawSegment(UWorld* World) const
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeArrow(const FVector& StartLocation, const FVector& EndLocation, const float HeadSize, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
@@ -99,7 +94,6 @@ FCogDebugShape FCogDebugShape::MakeArrow(const FVector& StartLocation, const FVe
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawArrow(UWorld* World) const
{
#if ENABLE_COG
@@ -122,7 +116,6 @@ void FCogDebugShape::DrawArrow(UWorld* World) const
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeAxes(const FVector& Location, const FRotator& Rotation, const float HeadSize, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
@@ -140,7 +133,6 @@ FCogDebugShape FCogDebugShape::MakeAxes(const FVector& Location, const FRotator&
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawAxes(UWorld* World) const
{
#if ENABLE_COG
@@ -162,7 +154,6 @@ void FCogDebugShape::DrawAxes(UWorld* World) const
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeBox(const FVector& Center, const FRotator& Rotation, const FVector& Extent, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
@@ -180,7 +171,6 @@ FCogDebugShape FCogDebugShape::MakeBox(const FVector& Center, const FRotator& Ro
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawBox(UWorld* World) const
{
#if ENABLE_COG
@@ -203,7 +193,6 @@ void FCogDebugShape::DrawBox(UWorld* World) const
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeSolidBox(const FVector& Center, const FRotator& Rotation, const FVector& Extent, const FColor& Color, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
@@ -241,7 +230,6 @@ void FCogDebugShape::DrawSolidBox(UWorld* World) const
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeCone(const FVector& Location, const FVector& Direction, const float Length, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
@@ -259,7 +247,6 @@ FCogDebugShape FCogDebugShape::MakeCone(const FVector& Location, const FVector&
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawCone(UWorld* World) const
{
#if ENABLE_COG
@@ -286,7 +273,6 @@ void FCogDebugShape::DrawCone(UWorld* World) const
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeCylinder(const FVector& Center, const float Radius, const float HalfHeight, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
@@ -326,7 +312,6 @@ void FCogDebugShape::DrawCylinder(UWorld* World) const
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeCircle(const FVector& Center, const FRotator& Rotation, const float Radius, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
@@ -344,7 +329,6 @@ FCogDebugShape FCogDebugShape::MakeCircle(const FVector& Center, const FRotator&
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawCicle(UWorld* World) const
{
#if ENABLE_COG
@@ -368,7 +352,6 @@ void FCogDebugShape::DrawCicle(UWorld* World) const
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeCircleArc(const FVector& Center, const FRotator& Rotation, const float InnerRadius, const float OuterRadius, const float Angle, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
@@ -386,7 +369,6 @@ FCogDebugShape FCogDebugShape::MakeCircleArc(const FVector& Center, const FRotat
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawCicleArc(UWorld* World) const
{
#if ENABLE_COG
@@ -411,7 +393,6 @@ void FCogDebugShape::DrawCicleArc(UWorld* World) const
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeCapsule(const FVector& Center, const FQuat& Rotation, const float Radius, const float HalfHeight, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
@@ -429,7 +410,6 @@ FCogDebugShape FCogDebugShape::MakeCapsule(const FVector& Center, const FQuat& R
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawCapsule(UWorld* World) const
{
#if ENABLE_COG
@@ -453,7 +433,6 @@ void FCogDebugShape::DrawCapsule(UWorld* World) const
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeFlatCapsule(const FVector2D& Start, const FVector2D& End, const float Radius, const float Z, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
@@ -496,7 +475,6 @@ void FCogDebugShape::DrawFlatCapsule(UWorld* World) const
}
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakeBone(const FVector& BoneLocation, const FVector& ParentLocation, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
@@ -513,7 +491,6 @@ FCogDebugShape FCogDebugShape::MakeBone(const FVector& BoneLocation, const FVect
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawBone(UWorld* World) const
{
#if ENABLE_COG
@@ -545,7 +522,6 @@ void FCogDebugShape::DrawBone(UWorld* World) const
//--------------------------------------------------------------------------------------------------------------------------
FCogDebugShape FCogDebugShape::MakePolygon(const TArray<FVector>& Verts, const FColor& Color, const bool bPersistent, const uint8 DepthPriority)
{
FCogDebugShape NewElement;
@@ -559,7 +535,6 @@ FCogDebugShape FCogDebugShape::MakePolygon(const TArray<FVector>& Verts, const F
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::DrawPolygon(UWorld* World) const
{
#if ENABLE_COG
@@ -589,7 +564,6 @@ void FCogDebugShape::DrawPolygon(UWorld* World) const
//--------------------------------------------------------------------------------------------------------------------------
void FCogDebugShape::Draw(UWorld* World) const
{
switch (Type)
@@ -612,7 +586,6 @@ void FCogDebugShape::Draw(UWorld* World) const
}
//--------------------------------------------------------------------------------------------------------------------------
FArchive& operator<<(FArchive& Ar, FCogDebugShape& Shape)
{
Ar << Shape.ShapeData;
@@ -37,9 +37,8 @@ void FCogImguiContext::Initialize()
SAssignNew(MainWidget, SCogImguiWidget)
.Context(this);
GameViewport->AddViewportWidgetContent(MainWidget.ToSharedRef(), TNumericLimits<int32>::Max());
//--------------------------------------------------------------------
// Register input processor to forward input events to imgui
//--------------------------------------------------------------------
@@ -275,6 +274,8 @@ bool FCogImguiContext::BeginFrame(float InDeltaTime)
IO.AddMousePosEvent(TransformedMousePosition.X, TransformedMousePosition.Y);
}
bWantCaptureMouse = ImGui::GetIO().WantCaptureMouse || (CaptureMouseCount > 0);
//-------------------------------------------------------------------------------------------------------
//
//-------------------------------------------------------------------------------------------------------
@@ -561,7 +562,7 @@ void FCogImguiContext::ImGui_RenderWindow(ImGuiViewport* Viewport, void* Data)
}
//--------------------------------------------------------------------------------------------------------------------------
static UPlayerInput* GetPlayerInput(const UWorld* World)
static APlayerController* GetLocalPlayerController(const UWorld* World)
{
if (World == nullptr)
{
@@ -574,11 +575,22 @@ static UPlayerInput* GetPlayerInput(const UWorld* World)
APlayerController* ItPlayerController = Iterator->Get();
if (ItPlayerController->IsLocalController())
{
PlayerController = ItPlayerController;
break;
return ItPlayerController;
}
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------------------------------
static UPlayerInput* GetPlayerInput(const UWorld* World)
{
if (World == nullptr)
{
return nullptr;
}
APlayerController* PlayerController = GetLocalPlayerController(World);
if (PlayerController == nullptr)
{
return nullptr;
@@ -620,12 +632,47 @@ void FCogImguiContext::SetEnableInput(bool Value)
}
}
RefreshMouseCursor();
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogImguiContext::SetShareMouse(bool Value)
void FCogImguiContext::SetShowCursorWhenSharingMouse(bool Value)
{
bShareMouse = Value;
bShowCursorWhenSharingMouse = Value;
RefreshMouseCursor();
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogImguiContext::SetShareMouse(bool Value)
{
bShareMouse = Value;
RefreshMouseCursor();
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogImguiContext::RefreshMouseCursor()
{
if (bEnableInput)
{
if (bShareMouse && bShowCursorWhenSharingMouse)
{
if (APlayerController* PlayerController = GetLocalPlayerController(GameViewport->GetWorld()))
{
bPlayerControllerShowMouse = PlayerController->ShouldShowMouseCursor();
PlayerController->SetShowMouseCursor(true);
}
}
}
else
{
if (bShareMouse && bShowCursorWhenSharingMouse)
{
if (APlayerController* PlayerController = GetLocalPlayerController(GameViewport->GetWorld()))
{
PlayerController->SetShowMouseCursor(bPlayerControllerShowMouse);
}
}
}
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -138,32 +138,29 @@ FReply SCogImguiWidget::HandleKeyEvent(const FKeyEvent& KeyEvent, bool Down)
{
return FReply::Unhandled();
}
if (KeyEvent.GetKey().IsGamepadKey())
{
//if (bShareGamepad)
//{
// // TODO: handle imgui gamepad
// return FReply::Unhandled();
//}
return FReply::Unhandled();
}
else
{
if (FCogImguiInputHelper::IsKeyEventHandled(Context->GetGameViewport()->GetWorld(), KeyEvent) == false)
{
return FReply::Unhandled();
}
ImGuiIO& IO = ImGui::GetIO();
IO.AddKeyEvent(FCogImguiInputHelper::ToImKey(KeyEvent.GetKey()), Down);
IO.AddKeyEvent(ImGuiMod_Ctrl, KeyEvent.IsControlDown());
IO.AddKeyEvent(ImGuiMod_Shift, KeyEvent.IsShiftDown());
IO.AddKeyEvent(ImGuiMod_Alt, KeyEvent.IsAltDown());
IO.AddKeyEvent(ImGuiMod_Super, KeyEvent.IsCommandDown());
//if (bShareKeyboard)
//{
// return FReply::Unhandled();
//}
if (FCogImguiInputHelper::IsKeyEventHandled(Context->GetGameViewport()->GetWorld(), KeyEvent) == false)
{
return FReply::Unhandled();
}
ImGuiIO& IO = ImGui::GetIO();
IO.AddKeyEvent(FCogImguiInputHelper::ToImKey(KeyEvent.GetKey()), Down);
IO.AddKeyEvent(ImGuiMod_Ctrl, KeyEvent.IsControlDown());
IO.AddKeyEvent(ImGuiMod_Shift, KeyEvent.IsShiftDown());
IO.AddKeyEvent(ImGuiMod_Alt, KeyEvent.IsAltDown());
IO.AddKeyEvent(ImGuiMod_Super, KeyEvent.IsCommandDown());
if (IO.WantCaptureKeyboard == false && Context->GetShareKeyboard())
{
return FReply::Unhandled();
}
return FReply::Handled();
}
@@ -172,12 +169,6 @@ FReply SCogImguiWidget::OnAnalogValueChanged(const FGeometry& MyGeometry, const
{
if (AnalogInputEvent.GetKey().IsGamepadKey())
{
//if (bShareGamepad)
//{
// // TODO: handle imgui gamepad
// return FReply::Unhandled();
//}
return FReply::Unhandled();
}
@@ -263,12 +254,26 @@ FReply SCogImguiWidget::OnFocusReceived(const FGeometry& MyGeometry, const FFocu
//--------------------------------------------------------------------------------------------------------------------------
void SCogImguiWidget::RefreshVisibility()
{
EVisibility DesiredVisiblity = EVisibility::SelfHitTestInvisible;
if (Context->GetEnableInput())
{
SetVisibility(EVisibility::Visible);
if (Context->GetShareMouse() && Context->GetWantCaptureMouse() == false)
{
DesiredVisiblity = EVisibility::SelfHitTestInvisible;
}
else
{
DesiredVisiblity = EVisibility::Visible;
}
}
else
{
SetVisibility(EVisibility::SelfHitTestInvisible);
DesiredVisiblity = EVisibility::SelfHitTestInvisible;
}
if (DesiredVisiblity != GetVisibility())
{
SetVisibility(DesiredVisiblity);
}
}
@@ -10,6 +10,7 @@ class FCogImguiContext;
class IInputProcessor;
class SCogImguiWidget;
class SCogImguiWidget;
class SCogImguiInputCatcherWidget;
class SWidget;
class SWindow;
class UGameViewportClient;
@@ -36,10 +37,20 @@ public:
void SetEnableInput(bool Value);
bool GetWantCaptureMouse() const { return bWantCaptureMouse; }
bool GetShareMouse() const { return bShareMouse; }
void SetShareMouse(bool Value);
bool GetShowCursorWhenSharingMouse() const { return bShowCursorWhenSharingMouse; }
void SetShowCursorWhenSharingMouse(bool Value);
bool GetShareKeyboard() const { return bShareKeyboard; }
void SetShareKeyboard(bool Value) { bShareKeyboard = Value; }
bool BeginFrame(float InDeltaTime);
void EndFrame();
@@ -48,6 +59,10 @@ public:
void SetDPIScale(float Value);
void PushCaptureMouse();
void PopCaptureMouse();
TObjectPtr<const UGameViewportClient> GetGameViewport() const { return GameViewport; }
TSharedPtr<const SCogImguiWidget> GetMainWidget() const { return MainWidget; }
@@ -62,6 +77,8 @@ private:
void BuildFont();
void RefreshMouseCursor();
ULocalPlayer* GetLocalPlayer() const;
static void ImGui_CreateWindow(ImGuiViewport* Viewport);
@@ -101,6 +118,8 @@ private:
TSharedPtr<SCogImguiWidget> MainWidget = nullptr;
TSharedPtr<SCogImguiInputCatcherWidget> InputCatcherWidget = nullptr;
TWeakPtr<SWidget> PreviousMouseCaptor = nullptr;
TObjectPtr<UGameViewportClient> GameViewport = nullptr;
@@ -113,7 +132,13 @@ private:
bool bEnableInput = false;
bool bShareMouse = true;
bool bShareMouse = false;
bool bShowCursorWhenSharingMouse = false;
bool bPlayerControllerShowMouse = false;
bool bShareKeyboard = false;
bool bRefreshDPIScale = false;
@@ -121,6 +146,9 @@ private:
bool bIsFirstFrame = true;
float DpiScale = 1.f;
bool bWantCaptureMouse = false;
int32 CaptureMouseCount = 0;
float DpiScale = 1.f;
};
@@ -79,25 +79,6 @@ void FCogWindow::Render(float DeltaTime)
ImGui::PopStyleVar(1);
}
if (GetOwner()->GetSettingsWindow()->GetSettingsConfig()->bShowHelp)
{
if (ImGui::IsItemHovered())
{
ImGui::PushStyleColor(ImGuiCol_PopupBg, IM_COL32(29, 42, 62, 240));
const float HelpWidth = FCogWindowWidgets::GetFontWidth() * 80;
ImGui::SetNextWindowSizeConstraints(ImVec2(HelpWidth / 2.0f, 0.0f),
ImVec2(HelpWidth, FLT_MAX));
if (ImGui::BeginTooltip())
{
ImGui::PushTextWrapPos(HelpWidth - 1 * FCogWindowWidgets::GetFontWidth());
RenderHelp();
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
ImGui::PopStyleColor();
}
}
if (ImGui::BeginPopupContextWindow())
{
if (bHasMenu)
@@ -215,4 +196,3 @@ UWorld* FCogWindow::GetWorld() const
{
return Owner->GetWorld();
}
@@ -166,6 +166,7 @@ void UCogWindowManager::Render(float DeltaTime)
ImGui::DockSpaceOverViewport(0, ImGuiDockNodeFlags_PassthruCentralNode | ImGuiDockNodeFlags_NoDockingInCentralNode | ImGuiDockNodeFlags_AutoHideTabBar);
ImGui::PopStyleColor(1);
const bool bCompactSaved = SettingsWindow->GetSettingsConfig()->bCompactMode;
if (bCompactSaved)
{
@@ -518,6 +519,8 @@ void UCogWindowManager::RenderMenuItem(FCogWindow& Window, const char* MenuItemN
{
Window.SetIsVisible(!Window.GetIsVisible());
}
RenderMenuItemHelp(Window);
}
else
{
@@ -526,6 +529,37 @@ void UCogWindowManager::RenderMenuItem(FCogWindow& Window, const char* MenuItemN
{
Window.SetIsVisible(bIsVisible);
}
RenderMenuItemHelp(Window);
}
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogWindowManager::RenderMenuItemHelp(FCogWindow& Window)
{
if (SettingsWindow->GetSettingsConfig()->bShowHelp)
{
ImGui::SameLine();
ImGui::SetCursorPosX(ImGui::GetCursorPosX() - FCogWindowWidgets::GetFontWidth() * 3.0f);
ImGui::TextDisabled("(?)");
if (ImGui::IsItemHovered())
{
ImGui::PushStyleColor(ImGuiCol_PopupBg, IM_COL32(29, 42, 62, 240));
const float HelpWidth = FCogWindowWidgets::GetFontWidth() * 80;
ImGui::SetNextWindowSizeConstraints(ImVec2(HelpWidth / 2.0f, 0.0f), ImVec2(HelpWidth, FLT_MAX));
if (ImGui::BeginTooltip())
{
ImGui::PushTextWrapPos(HelpWidth - 1 * FCogWindowWidgets::GetFontWidth());
Window.RenderHelp();
ImGui::Separator();
ImGui::TextDisabled("Help can be hidden in Window/Settings.");
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
ImGui::PopStyleColor();
}
ImGui::SameLine();
ImGui::Dummy(ImVec2(FCogWindowWidgets::GetFontWidth() * 1, 0));
}
}
@@ -753,4 +787,5 @@ void UCogWindowManager::ToggleInputMode()
{
UE_LOG(LogCogImGui, Verbose, TEXT("UCogWindowManager::ToggleInputMode"));
Context.SetEnableInput(!Context.GetEnableInput());
}
}
@@ -18,17 +18,19 @@ void FCogWindow_Settings::Initialize()
ImGuiIO& IO = ImGui::GetIO();
FCogImguiHelper::SetFlags(IO.ConfigFlags, ImGuiConfigFlags_ViewportsEnable, Config->bEnableViewports);
FCogImguiHelper::SetFlags(IO.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard, Config->bNavEnableKeyboard);
//FCogImguiHelper::SetFlags(IO.ConfigFlags, ImGuiConfigFlags_NavEnableGamepad, Config->bNavEnableGamepad);
//FCogImguiHelper::SetFlags(IO.ConfigFlags, ImGuiConfigFlags_NavNoCaptureKeyboard, Config->bNavNoCaptureInput);
GetOwner()->GetContext().SetDPIScale(Config->DPIScale);
FCogImguiContext& Context = GetOwner()->GetContext();
Context.SetEnableInput(Config->bEnableInput);
//Context.SetShareMouse(Config->bShareMouse);
Context.SetShareKeyboard(Config->bShareKeyboard);
Context.SetShareMouse(Config->bShareMouse);
Context.SetShowCursorWhenSharingMouse(Config->bShowCursorWhenSharingMouse);
//FCogImguiHelper::SetFlags(IO.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard, Config->bNavEnableKeyboard);
//FCogImguiHelper::SetFlags(IO.ConfigFlags, ImGuiConfigFlags_NavEnableGamepad, Config->bNavEnableGamepad);
//FCogImguiHelper::SetFlags(IO.ConfigFlags, ImGuiConfigFlags_NavNoCaptureKeyboard, Config->bNavNoCaptureInput);
//FCogImguiHelper::SetFlags(IO.ConfigFlags, ImGuiConfigFlags_NoMouseCursorChange, Config->bNoMouseCursorChange);
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -36,15 +38,16 @@ void FCogWindow_Settings::PreSaveConfig()
{
Super::PreSaveConfig();
//ImGuiIO& IO = ImGui::GetIO();
//Config->bNavEnableKeyboard = IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard;
ImGuiIO& IO = ImGui::GetIO();
Config->bNavEnableKeyboard = IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard;
//Config->bNavEnableGamepad = IO.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad;
//Config->bNavNoCaptureInput = IO.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard;
//Config->bNoMouseCursorChange = IO.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange;
const FCogImguiContext& Context = GetOwner()->GetContext();
Config->bEnableInput = Context.GetEnableInput();
//Config->bShareMouse = Context.GetShareMouse();
Config->bShareKeyboard = Context.GetShareKeyboard();
Config->bShareMouse = Context.GetShareMouse();
Config->bShowCursorWhenSharingMouse = Context.GetShowCursorWhenSharingMouse();
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -67,11 +70,16 @@ void FCogWindow_Settings::RenderContent()
ImGuiIO& IO = ImGui::GetIO();
FCogImguiContext& Context = GetOwner()->GetContext();
//-----------------------------
// bEnableInput
//-----------------------------
bool bEnableInput = Context.GetEnableInput();
if (ImGui::Checkbox("Enable Input", &bEnableInput))
{
Context.SetEnableInput(bEnableInput);
}
ImGui::SetItemTooltip("Enable ImGui inputs. When enabled the ImGui menu is shown and inputs are forwarded to ImGui.");
const auto ShortcutText = StringCast<ANSICHAR>(*FCogImguiInputHelper::CommandToString(PlayerInput, UCogWindowManager::ToggleInputCommand));
const float ShortcutWidth = (ShortcutText.Get() != nullptr && ShortcutText.Get()[0]) ? ImGui::CalcTextSize(ShortcutText.Get(), NULL).x : 0.0f;
@@ -84,55 +92,109 @@ void FCogWindow_Settings::RenderContent()
ImGui::PopStyleColor();
}
//-----------------------------
// ShareKeyboard
//-----------------------------
bool bShareKeyboard = Context.GetShareKeyboard();
if (ImGui::Checkbox("Share Keyboard", &bShareKeyboard))
{
Context.SetShareKeyboard(bShareKeyboard);
}
ImGui::SetItemTooltip("Forward the keyboard inputs to the game when ImGui does not need them.");
//-----------------------------
// ShareMouse
//-----------------------------
bool bShareMouse = Context.GetShareMouse();
if (ImGui::Checkbox("Share Mouse", &bShareMouse))
{
Context.SetShareMouse(bShareMouse);
}
ImGui::SetItemTooltip("Forward mouse inputs to the game when ImGui does not need them.");
//-----------------------------
// ShowCursorWhenSharingMouse
//-----------------------------
if (bShareMouse == false)
{
ImGui::BeginDisabled();
}
bool bShowCursorWhenSharingMouse = Context.GetShowCursorWhenSharingMouse();
if (ImGui::Checkbox("Show Cursor When Sharing Mouse", &bShowCursorWhenSharingMouse))
{
Context.SetShowCursorWhenSharingMouse(bShowCursorWhenSharingMouse);
}
ImGui::SetItemTooltip("Show the mouse cursor when ImGui share the mouse with the game. Useful for games that require the cursor to be hidden.");
if (bShareMouse == false)
{
ImGui::EndDisabled();
}
//-----------------------------
// NavEnableKeyboard
//-----------------------------
ImGui::CheckboxFlags("Keyboard Navigation", &IO.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard);
ImGui::SetItemTooltip("Use the keyboard to navigate in ImGui windows with the following keys : Tab, Directional Arrows, Space, Enter.");
//-----------------------------
// NavEnableGamepad
//-----------------------------
//ImGui::CheckboxFlags("Gamepad Navigation", &IO.ConfigFlags, ImGuiConfigFlags_NavEnableGamepad);
//ImGui::SetItemTooltip("Use the gamepad to navigate in ImGui windows.");
ImGui::Separator();
//-----------------------------
// DPI
//-----------------------------
FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::SliderFloat("DPI Scale", &Config->DPIScale, 0.5f, 2.0f, "%.1f");
if (ImGui::IsItemDeactivatedAfterEdit())
{
SetDPIScale(Config->DPIScale);
}
if (ImGui::IsItemHovered())
if (ImGui::BeginItemTooltip())
{
ImGui::BeginTooltip();
ImGui::TextUnformatted("Change DPi Scale [Mouse Wheel]");
ImGui::TextUnformatted("Reset DPi Scale [Middle Mouse]");
ImGui::EndTooltip();
}
//-----------------------------
// EnableViewports
//-----------------------------
if (ImGui::Checkbox("Enable Viewports", &Config->bEnableViewports))
{
FCogImguiHelper::SetFlags(IO.ConfigFlags, ImGuiConfigFlags_ViewportsEnable, Config->bEnableViewports);
}
ImGui::SetItemTooltip("Enable moving ImGui windows outside of the main viewport.");
if (ImGui::IsItemHovered())
{
ImGui::SetTooltip("Cog imgui viewport integration in Unreal is still experimental");
}
//-----------------------------
// CompactMode
//-----------------------------
ImGui::Checkbox("Compact Mode", &Config->bCompactMode);
ImGui::Checkbox("Show Windows In Main Menu", &Config->bShowWindowsInMainMenu);
ImGui::Checkbox("Show Window Help", &Config->bShowHelp);
ImGui::SetItemTooltip("Enable compact mode.");
//bool bShareMouse = Context.GetShareMouse();
//if (ImGui::Checkbox("Share Mouse", &bShareMouse))
//{
// Context.SetShareMouse(bShareMouse);
//}
//-----------------------------
// ShowWindowsInMainMenu
//-----------------------------
ImGui::Checkbox("Show Windows In Main Menu", &Config->bShowWindowsInMainMenu);
ImGui::SetItemTooltip("Show the content of the windows when hovering the window menu item.");
//ImGui::CheckboxFlags("Keyboard Navigation", &IO.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard);
//ImGui::CheckboxFlags("Gamepad Navigation", &IO.ConfigFlags, ImGuiConfigFlags_NavEnableGamepad);
//ImGui::CheckboxFlags("Navigation No Capture", &IO.ConfigFlags, ImGuiConfigFlags_NavNoCaptureKeyboard);
//ImGui::CheckboxFlags("No Mouse Cursor Change", &IO.ConfigFlags, ImGuiConfigFlags_NoMouseCursorChange);
//-----------------------------
// ShowHelp
//-----------------------------
ImGui::Checkbox("Show Help", &Config->bShowHelp);
ImGui::SetItemTooltip("Show windows help on the window menu items.");
ImGui::Separator();
if (ImGui::Button("Reset All Windows Config"))
if (ImGui::Button("Reset All Windows Config", ImVec2(-1.0f, 0.0f)))
{
GetOwner()->ResetAllWindowsConfig();
}
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -101,6 +101,8 @@ protected:
virtual void RenderMenuItem(FCogWindow& Window, const char* MenuItemName);
void RenderMenuItemHelp(FCogWindow& Window);
virtual void ToggleInputMode();
static void SettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandler*);
@@ -66,6 +66,12 @@ public:
UPROPERTY(Config)
bool bShareMouse = false;
UPROPERTY(Config)
bool bShowCursorWhenSharingMouse = false;
UPROPERTY(Config)
bool bShareKeyboard = false;
UPROPERTY(Config)
bool bNavEnableKeyboard = false;
@@ -90,9 +96,9 @@ public:
bShowWindowsInMainMenu = true;
bEnableInput = false;
bShareMouse = false;
bShareKeyboard = false;
bNavEnableKeyboard = false;
bNavEnableGamepad = false;
bNavNoCaptureInput = true;
bNoMouseCursorChange = false;
//bNavEnableGamepad = false;
//bNavNoCaptureInput = true;
}
};
+20 -8
View File
@@ -15,8 +15,8 @@ Cog provides:
General Info:
- Cog can be used both in editor and package builds. It is disabled by default on shipping builds.
- Press the `[F1]` key or use the `Cog.ToggleInput` console command to open the ImGui Main Menu.
- Mouse over a window title to display its help.
- Most windows display their contents based on a selected actor. The selector actor can be chosen using the `Engine/Selection` window or widget.
- Many windows display their contents based on a selected actor. The selector actor can be chosen using the `Engine/Selection` window or widget.
- Widgets such as Stats (FPS, Ping), or Actor Selection, can be added in the main menu bar from the 'Window/Widgets" menu.
## Cog Windows
@@ -65,12 +65,17 @@ Used to apply cheats to the selected actor.
- `[ALT]` Apply the cheat to the allies of the selected actor
- `[SHIFT]` Apply the cheat to the enemies of the selected actor
### Collisions
Used to inspect collisions by performing a collision query with the selected channels.
### Collisions Tester
Used to test a collision query
![Collisions](https://github.com/arnaud-jamin/Cog/assets/13844285/ccee855b-b33b-4dfc-ba14-dff87e1150cf)
![Collisions Tester](https://github.com/arnaud-jamin/Cog/assets/13844285/12f7cb7e-13c9-4eed-8ea4-f3eb7475cf34)
![Collisions Tester](https://github.com/arnaud-jamin/Cog/assets/13844285/4d01fd01-d0b3-41a7-9344-662f190ebaf0)
### Collisions Viewer
Used to inspect collisions in the world
![Collisions Viewer](https://github.com/arnaud-jamin/Cog/assets/13844285/ccee855b-b33b-4dfc-ba14-dff87e1150cf)
- The query can be configured in the options.
- The displayed collision channels can be configured in a Data Asset.
- It can be used to better understand what object collisions are blocking a raycast.
### Command Bindings
@@ -86,7 +91,7 @@ Used to configure the command bindings.
### Debug Settings
Used to tweak how the debug display is drawn.
![Debug Settings](https://github.com/arnaud-jamin/Cog/assets/13844285/e55c8d07-133e-48ab-a974-ed076f3d4a58)
![Debug Settings](https://github.com/arnaud-jamin/Cog/assets/13844285/1c078311-2395-45e6-9a13-ddc405e1c914)
### Effects
Displays the gameplay effects of the selected actor.
@@ -129,7 +134,6 @@ Gather various values sent by the selected actor and compute their rate per seco
FCogDebugMetric::AddMetric(this, "Damage Dealt", MitigatedDamage, UnmitigatedDamage, false);
```
### Net Emulation
Used to configure the network emulation
@@ -215,6 +219,14 @@ Used to change the game global time scale.
![Time Scale](https://github.com/arnaud-jamin/Cog/assets/13844285/d19198c5-37dd-400d-a09f-7a5077eb2511)
- If changed on a client the time scale is also modified on the game server, and replicated to the other clients.
### Transform
Used to read and set the selected actor transform.
![Transform](https://github.com/arnaud-jamin/Cog/assets/13844285/f4fa2aeb-2e06-4820-8500-6eb14536b5b3)
- A gizmo in the viewport can also be used to change the transform.
![Transform](https://github.com/arnaud-jamin/Cog/assets/13844285/34657828-9fda-4af4-bdd0-4ea4514c23a0)
### Tweaks
Used to apply tweaks to all the spawned actors