From 4680a0f3f4f638184115b4225a4411037ba72493 Mon Sep 17 00:00:00 2001 From: jyelon Date: Sat, 25 Apr 2026 01:14:16 -0400 Subject: [PATCH] Crosshair is back --- .gitignore | 1 + Content/Widgets/WB_Crosshair.uasset | 4 +-- Source/Integration/FormatDataLibrary.cpp | 33 ++++++++++++++++++------ 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 4771453e..a56ce570 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,4 @@ GPF-output/** __pycache__/ .clangd-query/ COMMIT.txt +CLAUDE.md diff --git a/Content/Widgets/WB_Crosshair.uasset b/Content/Widgets/WB_Crosshair.uasset index c649a4dc..ab4e1d97 100644 --- a/Content/Widgets/WB_Crosshair.uasset +++ b/Content/Widgets/WB_Crosshair.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:43ed7d9eeab2b723ad3564402467d8781220121b23ce3fc4cfa978a9a3edef52 -size 52875 +oid sha256:ebf07775928343c1a455ea387c8b2a8fa48f2fa8977f1756f7cbeadc408d290e +size 70492 diff --git a/Source/Integration/FormatDataLibrary.cpp b/Source/Integration/FormatDataLibrary.cpp index dd4f1d1c..9e1a33fc 100644 --- a/Source/Integration/FormatDataLibrary.cpp +++ b/Source/Integration/FormatDataLibrary.cpp @@ -6,6 +6,8 @@ #include "Layout/Geometry.h" #include "Widgets/Layout/Anchors.h" #include "Common.h" +#include "Engine/GameViewportClient.h" +#include "Slate/SGameLayerManager.h" #include "Kismet/KismetTextLibrary.h" #include "UObject/UObjectIterator.h" @@ -246,17 +248,32 @@ FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataTransform(const FTra FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataGeometry(const FGeometry &AutoConvertedValue, const FString &Name) { - FVector2D LocalSize = AutoConvertedValue.GetLocalSize(); - FVector2D AbsPos = AutoConvertedValue.GetAbsolutePosition(); - FVector2D AbsSize = AutoConvertedValue.GetAbsoluteSize(); + FVector2D UL = AutoConvertedValue.GetAbsolutePosition(); + FVector2D LR = AutoConvertedValue.GetAbsolutePositionAtCoordinates(FVector2f(1.0f, 1.0f)); + if (GEngine && GEngine->GameViewport) + { + TSharedPtr GameLayerManager = GEngine->GameViewport->GetGameLayerManager(); + if (GameLayerManager.IsValid()) + { + const FGeometry ViewportGeometry = GameLayerManager->GetViewportWidgetHostGeometry(); + const FVector2D ViewportLocalSize = FVector2D(ViewportGeometry.GetLocalSize()); + FVector2D ViewportPixelSize; + GEngine->GameViewport->GetViewportSize(ViewportPixelSize); + if (ViewportLocalSize.X > 0.0 && ViewportLocalSize.Y > 0.0) + { + const FVector2D PixelScale = ViewportPixelSize / ViewportLocalSize; + UL = ViewportGeometry.AbsoluteToLocal(UL) * PixelScale; + LR = ViewportGeometry.AbsoluteToLocal(LR) * PixelScale; + } + } + } FFormatArgumentData Result; Result.ArgumentValueType = EFormatArgumentType::Text; Result.ArgumentName = Name; Result.ArgumentValue = FText::Format( - INVTEXT("Geom(Local={0}x{1} Abs={2}x{3} Pos={4},{5})"), - FText::AsNumber(LocalSize.X), FText::AsNumber(LocalSize.Y), - FText::AsNumber(AbsSize.X), FText::AsNumber(AbsSize.Y), - FText::AsNumber(AbsPos.X), FText::AsNumber(AbsPos.Y)); + INVTEXT("UL={0},{1} LR={2},{3}"), + FText::AsNumber(UL.X), FText::AsNumber(UL.Y), + FText::AsNumber(LR.X), FText::AsNumber(LR.Y)); return Result; } @@ -312,7 +329,7 @@ void UlxFormatDataLibrary::FormatLogMessageInternal(UObject *Context, ElxFormatL double Now = FPlatformTime::Seconds(); FString Key = Context->GetClass()->GetName() + TEXT("::") + InPattern; double &Last = LastLogTime.FindOrAdd(Key, 0.0); - if (Now - Last < 1.0) + if (Now - Last < 2.0) { return; }