void UJavascriptWidget::OnListenForInputAction(FName ActionName, TEnumAsByte< EInputEvent > EventType, bool bConsume) { if (!InputComponent) { #if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION < 12 if (APlayerController* Controller = GetOwningPlayer()) { InputComponent = NewObject< UInputComponent >(this, NAME_None, RF_Transient); InputComponent->bBlockInput = bStopAction; InputComponent->Priority = Priority; Controller->PushInputComponent(InputComponent); } #else InitializeInputComponent(); #endif } if (InputComponent) { FInputActionBinding NewBinding(ActionName, EventType.GetValue()); NewBinding.bConsumeInput = bConsume; NewBinding.ActionDelegate.GetDelegateForManualSet().BindUObject(this, &ThisClass::OnInputActionByName, ActionName); InputComponent->AddActionBinding(NewBinding); } }
void UUIMain::OnBTCTRed() { SCREENDEBUG("REDDDDD"); Cast<ANPPlayerController>(GetOwningPlayer())->OnClickTeam(EFightGroup::GROUP_TEAM_RED); }
void UMainMenuWidget::OnCreditsClicked() { AMainMenuHUD* HUD = Cast<AMainMenuHUD>(GetOwningPlayer()->GetHUD()); if (HUD) { HUD->ShowCredits(); } }
void UUIMain::OnBTCTBlue() { SCREENDEBUG("ON CLICK BLUE") Cast<ANPPlayerController>(GetOwningPlayer())->OnClickTeam(EFightGroup::GROUP_TEAM_BLUE); }
class APawn* UUserWidget::GetOwningPlayerPawn() const { if ( APlayerController* PC = GetOwningPlayer() ) { return PC->GetPawn(); } return nullptr; }
void UTableListRow::BuildRow() { UHorizontalBox* HorizontalBox = GetRowContainer(); if (HorizontalBox != nullptr) { // DataList and ColumnRatios are assumed and guaranteed to be in sync for (int i = 0; i < DataList.Num(); ++i) { UTextBlockWrapper* cellText = CreateWidget<UTextBlockWrapper>(GetOwningPlayer(), TextBlockWrapperClass); if (cellText != nullptr) { cellText->Label = DataList[i].Label; cellText->Tag = DataList[i].Tag; FSlateChildSize childSize; childSize.SizeRule = ESlateSizeRule::Fill; childSize.Value = ColumnRatios[i]; cellText->SetVisibility(ESlateVisibility::HitTestInvisible); UHorizontalBoxSlot* HorizontalSlot = HorizontalBox->AddChildToHorizontalBox(cellText); HorizontalSlot->SetSize(childSize); UTextBlock* textBlock = cellText->GetTextBlock(); if (textBlock != nullptr) { //textBlock->SetText(DataList[i].Label); } else { UE_LOG(LogUMGEx, Error, TEXT("UTableListRow::BuildRow unable to get text block from child widget. GetTextBlock not assigned?")); } UE_LOG(LogUMGEx, VeryVerbose, TEXT("UTableListRow::BuildRow created text block with text %s with size %f"), *DataList[i].Label.ToString(), ColumnRatios[i]); } else { UE_LOG(LogUMGEx, Error, TEXT("UTableListRow::BuildRow unable to create a text block. Bad Text Block Wrapper Class?")); } } } else { UE_LOG(LogUMGEx, Error, TEXT("UTableListRow::BuildRow was called with GetRowContainer unbound. Make sure all user defined TableListRow widgets have GetRowContainer bound to get a Horizontal Box widget.")); } UCanvasPanelSlot* CanvasSlot = Cast<UCanvasPanelSlot>(HorizontalBox->GetParent()->GetParent()->Slot); if (CanvasSlot != nullptr) { //CanvasSlot->RebaseLayout(); } }
void UGUIDynamicCanvas::UpdateAttachedWidget(const FAttachedWidgetData& Data) { if (Data.IsValid() == false) { AttachedWidgetDataListIsDirty = true; return; } FVector WorldLocation = Data.SceneComponent->GetSocketLocation(Data.SocketName); FVector2D ScreenLocation; UGameplayStatics::ProjectWorldToScreen(GetOwningPlayer(), WorldLocation, ScreenLocation); FVector2D Location = ScreenLocation / UWidgetLayoutLibrary::GetViewportScale(this); Location = Location + Data.ScreenOffset; UCanvasPanelSlot* Slot = Data.GetSlot(); Slot->SetPosition(Location); }
void UUICharacterSelection::OnClickChar2() { Cast<ANPPlayerController>(GetOwningPlayer())->GetUIManager()->AssignCharacter(GetOwningPlayer()->PlayerState,character_2_); }
void UUICharacterSelection::OnClickChar1() { // Cast<ANPGameState>(GetWorld()->GetGameState())->AssignCharacter(GetOwningPlayer()->PlayerState, character_1_); Cast<ANPPlayerController>(GetOwningPlayer())->GetUIManager()->AssignCharacter(GetOwningPlayer()->PlayerState,character_1_); }
AGUIPlayerController* UGUIWidget::GetGUIPlayerController() const { return CastChecked<AGUIPlayerController>(GetOwningPlayer()); }