Still working on event handling for hotkey widgets

This commit is contained in:
2025-05-23 15:33:18 -04:00
parent 28f1c4c819
commit 40da211985
32 changed files with 254 additions and 158 deletions

View File

@@ -349,48 +349,6 @@ ALuprexGameModeBase *ALuprexGameModeBase::FromContext(const UObject *context) {
return result;
}
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, UlxLookAtWidget *Widget)
{
ALuprexGameModeBase *Mode = FromContext(Context);
if (Mode->LookAtWidget != Widget)
{
ClearLookAtWidget(Context);
}
Mode->LookAtWidget = Widget;
}
UlxLookAtWidget *ALuprexGameModeBase::CreateLookAtWidgetByName(UObject *Context, const FString &BlueprintName,
ElxFoundOrNotFound &Result, bool ErrorIfNotFound, bool AddToViewport, bool SetLookAtWidget)
{
ALuprexGameModeBase *Mode = FromContext(Context);
Result = ElxFoundOrNotFound::NotFound;
auto Blueprint = UlxAssetLookup::GetLookAtWidgetByName(Context, BlueprintName, ErrorIfNotFound);
if (Blueprint == nullptr) return nullptr;
APlayerController *pc = Context->GetWorld()->GetFirstPlayerController();
UlxLookAtWidget *Widget = Cast<UlxLookAtWidget>(UWidgetBlueprintLibrary::Create(Context, Blueprint, pc));
check(Widget != nullptr);
if (AddToViewport)
{
Widget->AddToViewport(100);
}
if (SetLookAtWidget)
{
Mode->SetLookAtWidget(Context, Widget);
}
Result = ElxFoundOrNotFound::Found;
return Widget;
}
void ALuprexGameModeBase::SetLookAt(const UObject *Context, const FHitResult &HitResult)
{
@@ -402,7 +360,6 @@ void ALuprexGameModeBase::SetLookAt(const UObject *Context, const FHitResult &Hi
Mode->CurrentLookAt = HitResult;
}
FVector2D ALuprexGameModeBase::GetLookAtPixel(const UObject *Context)
{
ALuprexGameModeBase *Mode = FromContext(Context);