Rewrite absurd implementation of lxCrosshairWidget to use FAnchors instead

This commit is contained in:
2025-04-02 23:22:16 -04:00
parent b4f918e15d
commit e81134473e
8 changed files with 119 additions and 26 deletions

View File

@@ -6,6 +6,8 @@
#include "ConsoleOutput.h"
#include "Tangible.h"
#include "TangibleManager.h"
#include "Blueprint/UserWidget.h"
#include "CommonTypes.h"
#include "AnimQueue.h"
#include <string>
@@ -337,11 +339,37 @@ ALuprexGameModeBase *ALuprexGameModeBase::FromContext(const UObject *context) {
return result;
}
bool ALuprexGameModeBase::IsLookAtChanged(UObject *context) {
bool ALuprexGameModeBase::IsLookAtChanged(const UObject *context) {
ALuprexGameModeBase *mode = FromContext(context);
return mode->CurrentLookAt.HitObjectHandle != mode->PreviousLookAt.HitObjectHandle;
}
void ALuprexGameModeBase::ClearLookAtWidget(const UObject *Context)
{
ALuprexGameModeBase *mode = FromContext(Context);
if (mode->LookAtWidget != nullptr)
{
mode->LookAtWidget->RemoveFromParent();
mode->LookAtWidget = nullptr;
}
}
void ALuprexGameModeBase::SetLookAtWidget(const UObject *Context, UUserWidget *Widget, int ZOrder)
{
ALuprexGameModeBase *Mode = FromContext(Context);
if (Mode->LookAtWidget != Widget)
{
ClearLookAtWidget(Context);
}
if (Widget != nullptr)
{
Widget->RemoveFromParent();
Widget->AddToViewport(ZOrder);
}
Mode->LookAtWidget = Widget;
}
void ALuprexGameModeBase::UpdateLookAt() {
// Rotate the variables.
PreviousLookAt = CurrentLookAt;
@@ -361,6 +389,7 @@ void ALuprexGameModeBase::UpdateLookAt() {
CalculateLookAt(pc);
if (IsLookAtChanged(this)) {
ClearLookAtWidget(this);
LookAtChanged();
}
}