diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index c141daf6..fd2bb98c 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -82,3 +82,6 @@ UIScaleCurve=(EditorCurveData=(Keys=((Time=480.000000,Value=0.444000),(Time=720. +CollisionChannelRedirects=(OldName="PawnMovement",NewName="Pawn") +CollisionChannelRedirects=(OldName="Clickable",NewName="LookAtDetection") +[/Script/Engine.Engine] +GameViewportClientClassName=/Script/CommonUI.CommonGameViewportClient + diff --git a/Content/Luprex/CIBD.uasset b/Content/Luprex/CIBD.uasset new file mode 100644 index 00000000..acfda637 --- /dev/null +++ b/Content/Luprex/CIBD.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e0c36249548c314ec05f43d76188e8375e5741ba1f09a8e3d061c9f0e491d026 +size 5227 diff --git a/Content/Luprex/lxGameMode.uasset b/Content/Luprex/lxGameMode.uasset index a77cac3d..b50a7925 100644 --- a/Content/Luprex/lxGameMode.uasset +++ b/Content/Luprex/lxGameMode.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:79f17c44c9326d2ec6bcf58132d59b0600708dce86a9965d6fe1050b0e9690c6 -size 129807 +oid sha256:69964add7c0799d602e46a0e17d624d4bda0dca7314249f78a609b0f382c4966 +size 137786 diff --git a/Content/Tangibles/TAN_Character.uasset b/Content/Tangibles/TAN_Character.uasset index 71302314..b9acff4c 100644 --- a/Content/Tangibles/TAN_Character.uasset +++ b/Content/Tangibles/TAN_Character.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:85529b29f1e91b3eef85d9a6d027db4623adc7ba4602b6fb520ee2c4e3ed17ac -size 317298 +oid sha256:bdee0a31de1029878f085a66a119a27473dd1edf48cfce01c4b6f95e240e08bc +size 318884 diff --git a/Content/Widgets/WB_Crosshair.uasset b/Content/Widgets/WB_Crosshair.uasset index 863d4c82..912a3dd1 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:d34efb7d4caebfa5f4437012dbf0e5b6a20e8b121b51d189ea411af7d47f58df -size 54264 +oid sha256:bc85285926aca6cd91e15b94daf309f894f11d0bb53c6003cda9f66a603d9e0f +size 65489 diff --git a/Content/Widgets/WB_Crosshair1.uasset b/Content/Widgets/WB_Crosshair1.uasset deleted file mode 100644 index 5663835e..00000000 --- a/Content/Widgets/WB_Crosshair1.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ab5a1cf39a7ce3ecdb6b2ab102d6109ac2eb5ab7f4422875d277a92475df5b90 -size 54933 diff --git a/Content/Widgets/WB_Hotkeys.uasset b/Content/Widgets/WB_Hotkeys.uasset index aaecf1eb..bf3ae106 100644 --- a/Content/Widgets/WB_Hotkeys.uasset +++ b/Content/Widgets/WB_Hotkeys.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b4161ddd9f32beaffc9c89a49104a114b496e5a08430671aa11972f6e3c089fc -size 53013 +oid sha256:c25dfb777ff50c51f3b9a6b66a16fbac0e221195c54a6d859af99c02c11bcfb5 +size 52546 diff --git a/Source/Integration/UtilityLibrary.cpp b/Source/Integration/UtilityLibrary.cpp index 145d8eaa..2df84332 100644 --- a/Source/Integration/UtilityLibrary.cpp +++ b/Source/Integration/UtilityLibrary.cpp @@ -6,6 +6,8 @@ #include "EnhancedInputSubsystems.h" #include "Kismet/KismetSystemLibrary.h" #include "Kismet/GameplayStatics.h" +#include "Blueprint/UserWidget.h" +#include "Components/GridPanel.h" #define LOCTEXT_NAMESPACE "Luprex Utility" @@ -146,3 +148,64 @@ bool UlxUtilityLibrary::LineTraceThroughPixel(const APlayerController* PlayerCon HitResult.Init(); return false; } + +void UlxUtilityLibrary::SetPositionOfGridPanelMiddleCell(UGridPanel *GridPanel, FVector2D UpperLeftXY, FVector2D LowerRightXY) +{ + if ((GridPanel == nullptr) || (GridPanel->ColumnFill.Num() != 3) || (GridPanel->RowFill.Num() != 3)) + { + UE_LOG(LogBlueprint, Error, TEXT("SetPositionOfGridPanelMiddleCell only works on 3x3 GridPanels.")); + return; + } + + if ((LowerRightXY.X < UpperLeftXY.X) || (LowerRightXY.Y < UpperLeftXY.Y)) + { + UE_LOG(LogBlueprint, Error, TEXT("LowerRightXY must be greater than or equal to UpperLeftXY")); + return; + } + + UpperLeftXY.X = FMath::Clamp(UpperLeftXY.X, 0.0f, 1.0f); + UpperLeftXY.Y = FMath::Clamp(UpperLeftXY.Y, 0.0f, 1.0f); + LowerRightXY.X = FMath::Clamp(LowerRightXY.X, 0.0f, 1.0f); + LowerRightXY.Y = FMath::Clamp(LowerRightXY.Y, 0.0f, 1.0f); + + GridPanel->SetRowFill(0, UpperLeftXY.Y); + GridPanel->SetRowFill(1, LowerRightXY.Y - UpperLeftXY.Y); + GridPanel->SetRowFill(2, 1.0 - LowerRightXY.Y); + + GridPanel->SetColumnFill(0, UpperLeftXY.X); + GridPanel->SetColumnFill(1, LowerRightXY.X - UpperLeftXY.X); + GridPanel->SetColumnFill(2, 1.0 - LowerRightXY.X); +} + +void UlxUtilityLibrary::GetPositionOfGridPanelMiddleCell(UGridPanel *GridPanel, FVector2D &UpperLeftXY, FVector2D &LowerRightXY) +{ + TArray &Col = GridPanel->ColumnFill; + TArray &Row = GridPanel->RowFill; + + // Set default return value for error situations. + UpperLeftXY.X = 0.0; + LowerRightXY.X = 1.0; + UpperLeftXY.Y = 0.0; + LowerRightXY.Y = 1.0; + + if ((GridPanel == nullptr) || (Row.Num() != 3) || (Col.Num() != 3)) + { + UE_LOG(LogBlueprint, Error, TEXT("SetPositionOfGridPanelMiddleCell only works on 3x3 GridPanels.")); + return; + } + + double TotalX = Col[0] + Col[1] + Col[2]; + double TotalY = Row[0] + Row[1] + Row[2]; + + if (TotalX > 0) + { + UpperLeftXY.X = Col[0] / TotalX; + LowerRightXY.X = (Col[0] + Col[1]) / TotalX; + } + + if (TotalY > 0) + { + UpperLeftXY.Y = Row[0] / TotalY; + LowerRightXY.Y = (Row[0] + Row[1]) / TotalY; + } +} diff --git a/Source/Integration/UtilityLibrary.h b/Source/Integration/UtilityLibrary.h index abb760bf..5e9e5293 100644 --- a/Source/Integration/UtilityLibrary.h +++ b/Source/Integration/UtilityLibrary.h @@ -85,4 +85,51 @@ public: FVector2D PixelXY, double MaxDistanceFromCamera, ETraceTypeQuery TraceChannel, bool bTraceComplex, EDrawDebugTrace::Type DrawDebugType, bool bIgnorePlayerPawn, const TArray& ActorsToIgnore, FHitResult& HitResult); + + // Set Position of GridPanel Middle Cell + // + // Sometimes, you want to specify the position of a widget, and you + // don't want to specify the position in slate units, instead, you + // want to specify the position using fractions: ie, (0,0) is the + // upper left corner of the screen, and (1,1) is the lower-right corner. + // + // One way to accomplish this is to put your widget in the middle cell + // of a 3x3 GridPanel. Then, you can position it by adjusting the grid + // fill rules. This utility routine can do the math necessary to + // correctly populate those fill rules. + // + // This routine must be passed a 3x3 GridPanel. This will reposition + // the middle cell. You must specify the upper-left and lower-right + // corners of the middle cell as fractions between (0,0) and (1,1). + // + // Be aware that if the content of a grid cell overflows the amount of + // space allocated for it, then the grid will adjust to make room. + // But that will mean that the grid is no longer faithful to the + // positions specified in its fill rules. One way to ensure that the + // grid remains faithful to its fill rules is to put an Overlay + // into the GridPanel cell, then put -1000 padding into the + // Overlay's GridPanel slot, then put +1000 padding into the Overlay + // slot. The two paddings cancel each other out, leaving the item in + // the Overlay at the originally-intended position. But if the item + // in the overlay overflows, it doesn't cause the Grid to deform. + // Instead, the item exceeds the bounds of the grid cell, but it leaves + // the grid cell where it belongs. + // + UFUNCTION(BlueprintCallable, Category="Widget") + static void SetPositionOfGridPanelMiddleCell(UGridPanel *GridPanel, FVector2D UpperLeftXY, FVector2D LowerRightXY); + + // Get Position of GridPanel Middle Cell + // + // The routine must be passed a 3x3 GridPanel. This will return the + // position of the middle cell of the gridpanel, expressed on a scale + // from (0,0) to (1,1). + // + // The numbers returned by this routine are based entirely on the + // GridPanel fill rules. If an item in the grid is overflowing its + // allocated space, causing the grid to deform, then that won't be + // reflected in the output of this routine. + // + UFUNCTION(BlueprintPure, Category="Widget") + static void GetPositionOfGridPanelMiddleCell(UGridPanel *GridPanel, FVector2D &UpperLeftXY, FVector2D &LowerRightXY); + }; diff --git a/luprex/lua/login.lua b/luprex/lua/login.lua index 3ebe8ff8..78846b14 100644 --- a/luprex/lua/login.lua +++ b/luprex/lua/login.lua @@ -31,7 +31,11 @@ end function engio.getlookat() local class = tangible.getclass(tangible.place()) - if class == nil then return end + + -- if the tangible is not of any class, return empty string. + if class == nil then + return "" + end -- if the class has a function 'lookhotkeys', then the correct -- look-at widget is 'hotkeys'. We're going to automatically @@ -47,5 +51,8 @@ function engio.getlookat() if class.getlookat ~= nil then return class.getlookat() end + + -- by default, return the empty string. + return "" end