Lots of work on look-at widgets
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "Tangible.h"
|
||||
#include "TangibleManager.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
||||
#include "CommonTypes.h"
|
||||
#include "AnimQueue.h"
|
||||
@@ -355,21 +356,46 @@ void ALuprexGameModeBase::ClearLookAtWidget(const UObject *Context)
|
||||
}
|
||||
}
|
||||
|
||||
void ALuprexGameModeBase::SetLookAtWidget(const UObject *Context, UUserWidget *Widget, int ZOrder)
|
||||
void ALuprexGameModeBase::SetLookAtWidget(const UObject *Context, UlxLookAtWidget *Widget)
|
||||
{
|
||||
ALuprexGameModeBase *Mode = FromContext(Context);
|
||||
if (Mode->LookAtWidget != Widget)
|
||||
{
|
||||
ClearLookAtWidget(Context);
|
||||
}
|
||||
if (Widget != nullptr)
|
||||
if (!Widget->IsInViewport())
|
||||
{
|
||||
Widget->RemoveFromParent();
|
||||
Widget->AddToViewport(ZOrder);
|
||||
Widget->AddToViewport(100);
|
||||
}
|
||||
Mode->LookAtWidget = Widget;
|
||||
}
|
||||
|
||||
void ALuprexGameModeBase::SetLookAt(const UObject *Context, const FHitResult &HitResult)
|
||||
{
|
||||
ALuprexGameModeBase *Mode = FromContext(Context);
|
||||
Mode->CurrentLookAt = HitResult;
|
||||
}
|
||||
|
||||
FVector2D ALuprexGameModeBase::GetLookAtPixel(const UObject *Context)
|
||||
{
|
||||
ALuprexGameModeBase *Mode = FromContext(Context);
|
||||
APlayerController *pc = Context->GetWorld()->GetFirstPlayerController();
|
||||
if (pc == nullptr) return FVector2D();
|
||||
FVector2D ScreenPosition;
|
||||
UGameplayStatics::ProjectWorldToScreen(pc, Mode->CurrentLookAt.Location, ScreenPosition, false);
|
||||
return ScreenPosition;
|
||||
}
|
||||
|
||||
FVector2D ALuprexGameModeBase::GetPreviousLookAtPixel(const UObject *Context)
|
||||
{
|
||||
ALuprexGameModeBase *Mode = FromContext(Context);
|
||||
APlayerController *pc = Context->GetWorld()->GetFirstPlayerController();
|
||||
if (pc == nullptr) return FVector2D();
|
||||
FVector2D ScreenPosition;
|
||||
UGameplayStatics::ProjectWorldToScreen(pc, Mode->PreviousLookAt.Location, ScreenPosition, false);
|
||||
return ScreenPosition;
|
||||
}
|
||||
|
||||
void ALuprexGameModeBase::UpdateLookAt() {
|
||||
// Rotate the variables.
|
||||
PreviousLookAt = CurrentLookAt;
|
||||
|
||||
Reference in New Issue
Block a user