IICHAN::~IICHAN() { if(GetSpriteAllocator()) { delete GetSpriteAllocator(); SetSpriteAllocator(NULL); } if(GetEventAllocator()) { delete GetEventAllocator(); SetEventAllocator(NULL); } if(GetItemAllocator()) { delete GetItemAllocator(); SetItemAllocator(NULL); } if(GetScreenTextAllocator()) { delete GetScreenTextAllocator(); SetScreenTextAllocator(NULL); } if(GetInstanceAllocator()) { delete GetInstanceAllocator(); SetInstanceAllocator(NULL); } if(GetHUD()) { delete GetHUD(); SetHUD(NULL); } }
void HUDInterface::LANClick ( Button *button ) { if ( GetHUD ()->previoushighlight && strcmp ( GetHUD ()->previoushighlight, button->name ) == 0 ) game->GetInterface ()->GetLocalInterface ()->RunScreen ( SCREEN_NONE ); else game->GetInterface ()->GetLocalInterface ()->RunScreen ( SCREEN_LAN ); }
void IICHAN::Init() { IICHANSpriteAllocator* spr_alloc = new IICHANSpriteAllocator(); IICHANEventAllocator* event_alloc = new IICHANEventAllocator(); IICHANItemAllocator* item_alloc = new IICHANItemAllocator(); IICHANScreenTextAllocator* scr_text_alloc = new IICHANScreenTextAllocator(); IICHANInstanceAllocator* inst_alloc = new IICHANInstanceAllocator(); HUD* hud = new HUD(); SetItemAllocator(item_alloc); SetSpriteAllocator(spr_alloc); SetEventAllocator(event_alloc); SetScreenTextAllocator(scr_text_alloc); SetInstanceAllocator(inst_alloc); SetHUD(hud); GetItemAllocator()->SetHUD(hud); GetItemAllocator()->SetSpriteAllocator(GetSpriteAllocator()); GetItemAllocator()->SetInstanceAllocator(GetInstanceAllocator()); GetItemAllocator()->SetScreenTextAllocator(GetScreenTextAllocator()); GetEventAllocator()->SetItemAllocator(GetItemAllocator()); GetEventAllocator()->SetScreenTextAllocator(GetScreenTextAllocator()); GetEventAllocator()->SetInstanceAllocator(GetInstanceAllocator()); GetInstanceAllocator()->SetSpriteAllocator(GetSpriteAllocator()); GetInstanceAllocator()->SetScreenTextAllocator(GetScreenTextAllocator()); osl_Load_v_04("levels\\level1.txt"); PLAYER* player = (PLAYER*)GetItemAllocator()->GetFirstPlayer(); if(player) { for(int i = 0; i < player->GetHealth(); i++) { GetHUD()->AddHealth(); } for(int i = 0; i < player->GetAmmo(); i++) { GetHUD()->AddAmmo(); } for(int i = 0; i < player->GetScore(); i++) { GetHUD()->AddScore(); } } }
void ABaseGamePlatformClientPlayerController::ProcessMessage(FPlatformClientMessage message) { if (!platformHud) platformHud = StaticCast<ABaseGamePlatformClientHUD*>(GetHUD()); if (platformHud) { platformHud->ProcessPlatformClientMessage(message); } }
void ASPlayerController::ClientHUDStateChanged_Implementation(EHUDState NewState) { ASHUD* MyHUD = Cast<ASHUD>(GetHUD()); if (MyHUD) { MyHUD->OnStateChanged(NewState); } }
void AShooterPlayerController::ToggleChatWindow() { AShooterHUD* ShooterHUD = Cast<AShooterHUD>(GetHUD()); if (ShooterHUD) { ShooterHUD->ToggleChat(); } }
void IICHAN::Draw() { if(GetSpriteAllocator()) GetSpriteAllocator()->Draw(); if(GetScreenTextAllocator()) GetScreenTextAllocator()->Draw(); if(GetHUD()) { if(GetInstanceAllocator()) { if(GetInstanceAllocator()->GetHUDEnabled()) GetHUD()->Draw(); } else GetHUD()->Draw(); } }
void HUDInterface::UnHighlightToolbarButton () { if ( GetHUD ()->previoushighlight ) { // Get the button Button *button = EclGetButton ( GetHUD ()->previoushighlight ); if ( button ) { // Swap the highlighted/unhighlighted/clicked graphics around Image *new_standard = button->image_clicked; Image *new_highlighted = GetHUD ()->previousimage; Image *new_clicked = button->image_standard; GetHUD ()->previousimage = NULL; button->image_standard = new_standard; button->image_highlighted = new_highlighted; button->image_clicked = new_clicked; EclDirtyButton ( GetHUD ()->previoushighlight ); } // No button is now highlighted delete [] GetHUD ()->previoushighlight; GetHUD ()->previoushighlight = NULL; } }
void AKUIPlayerController::OnMouseMoved( const FVector2D& v2Delta ) { if ( GEngine != NULL && !GEngine->GameViewport->Viewport->HasFocus() ) return; AKUIInterface* const aHud = Cast<AKUIInterface>( GetHUD() ); if ( aHud != NULL ) aHud->OnMouseMove( aHud->GetCursorLocation(), aHud->GetCursorLocation() + ( FVector2D( v2Delta.X, -v2Delta.Y ) * 20.f ) ); // Some scaling }
void ASPlayerController::ClientHUDMessage_Implementation(EHUDMessage MessageID) { /* Turn the ID into a message for the HUD to display */ FText TextMessage = GetText(MessageID); ASHUD* MyHUD = Cast<ASHUD>(GetHUD()); if (MyHUD) { /* Implemented in SurvivalHUD Blueprint */ MyHUD->MessageReceived(TextMessage); } }
void HUDInterface::MissionClick ( Button *button ) { UplinkAssert ( button ); int index; sscanf ( button->name, "hud_mission %d", &index ); if ( !game->GetWorld()->GetPlayer()->missions.ValidIndex(index) ) { printf ( "HUDInterface WARNING: Tried to view a mission that didn't exist\n" ); EclRemoveButton ( button->name ); return; } if ( GetHUD ()->previoushighlight && strcmp ( GetHUD ()->previoushighlight, button->name ) == 0 ) game->GetInterface ()->GetLocalInterface ()->RunScreen ( SCREEN_NONE ); else game->GetInterface ()->GetLocalInterface ()->RunScreen ( SCREEN_MISSION, index ); }
void AMouseController::GetCameraRay(FVector& WorldOrigin, FVector& WorldDirection) { ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(Player); FVector2D MousePosition; if (LocalPlayer) { if (!LocalPlayer->ViewportClient->GetMousePosition(MousePosition)) { return; } } // Early out if we clicked on a HUD hitbox if (GetHUD() != NULL && GetHUD()->GetHitBoxAtCoordinates(MousePosition, true)) { return; } if (LocalPlayer != NULL && LocalPlayer->ViewportClient != NULL && LocalPlayer->ViewportClient->Viewport != NULL) { // Create a view family for the game viewport FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues( LocalPlayer->ViewportClient->Viewport, GetWorld()->Scene, LocalPlayer->ViewportClient->EngineShowFlags) .SetRealtimeUpdate(true)); // Calculate a view where the player is to update the streaming from the players start location FVector ViewLocation; FRotator ViewRotation; FSceneView* SceneView = LocalPlayer->CalcSceneView(&ViewFamily, /*out*/ ViewLocation, /*out*/ ViewRotation, LocalPlayer->ViewportClient->Viewport); if (SceneView) { SceneView->DeprojectFVector2D(MousePosition, WorldOrigin, WorldDirection); } } }
void AShooterPlayerController::ClientTeamMessage_Implementation( APlayerState* SenderPlayerState, const FString& S, FName Type, float MsgLifeTime ) { AShooterHUD* ShooterHUD = Cast<AShooterHUD>(GetHUD()); if (ShooterHUD) { if( Type == ServerSayString ) { if( SenderPlayerState != PlayerState ) { ShooterHUD->AddChatLine(S, false); } } } }
void ABaleroPlayerController::BeginPlay() { Super::BeginPlay(); AHUD* Hud = GetHUD(); bEnableClickEvents = true; bShowMouseCursor = true; Hud->EnableInput(this); UUnitGroup::SetWorld(GetWorld()); }
bool AKUIPlayerController::InputCharEvent( TCHAR chChar ) { if ( bHasPlayEnded ) return true; AKUIInterface* const aInterface = Cast<AKUIInterface>( GetHUD() ); //KUILog( "Char event: %s", *FString::Chr( chChar ) ); if ( aInterface == NULL ) return false; return aInterface->OnKeyChar( chChar ); }
void HUDInterface::HighlightToolbarButton ( char *bname ) { // Get the button Button *button = EclGetButton ( bname ); if ( button ) { // Swap the highlighted/unhighlighted/clicked graphics around GetHUD ()->previousimage = button->image_highlighted; Image *new_standard = button->image_clicked; Image *new_highlighted = button->image_clicked; Image *new_clicked = button->image_standard; button->image_standard = new_standard; button->image_highlighted = new_highlighted; button->image_clicked = new_clicked; EclDirtyButton ( bname ); // Remember this button was highlighted if ( GetHUD ()->previoushighlight ) delete [] GetHUD ()->previoushighlight; GetHUD ()->previoushighlight = new char [strlen(bname)+1]; UplinkSafeStrcpy ( GetHUD ()->previoushighlight, bname ); } else { printf ( "HUDInterface::HighlightToolbarButton, invalid button : %s\n", bname ); } }
bool AKUIPlayerController::InputKeyEvent( FKey eKey, EInputEvent eEventType ) { if ( bHasPlayEnded ) return true; AKUIInterface* const aInterface = Cast<AKUIInterface>( GetHUD() ); if ( aInterface == NULL ) return false; EMouseButtons::Type eButton = AKUIInterface::GetMouseButtonFromKey( eKey ); switch ( eEventType ) { case EInputEvent::IE_Pressed: if ( eButton != EMouseButtons::Invalid ) return aInterface->OnMouseButtonDown( eButton, aInterface->GetCursorLocation() ); else return aInterface->OnKeyDown( eKey ); break; case EInputEvent::IE_Released: if ( eButton != EMouseButtons::Invalid ) return aInterface->OnMouseButtonUp( eButton, aInterface->GetCursorLocation() ); else return aInterface->OnKeyUp( eKey ); break; case EInputEvent::IE_Repeat: if ( eButton == EMouseButtons::Invalid ) return aInterface->OnKeyRepeat( eKey ); break; } return false; }
void ASrPlayerPawn::BeginPlay() { Super::BeginPlay(); auto PlayerController = Cast<ASrPlayerController>(GetController()); if (PlayerController) { auto HUD = Cast<ASrHUD>(PlayerController->GetHUD()); if (HUD) { HUD->OnViewportSizeChangedEvent.AddUFunction(this, "OnViewportSizeChanged"); } } auto World = GetWorld(); if (World) { UpdateSpringArmLength(World); UpdateWorldToScreenCoef(World); } }
AShooterHUD* AShooterPlayerController::GetShooterHUD() const { return Cast<AShooterHUD>(GetHUD()); }
void HUDInterface::SoftwareClick ( Button *button ) { GetHUD ()->si.ToggleSoftwareMenu (); }
bool AAmbitionOfNobunagaPlayerController::InputKey(FKey Key, EInputEvent EventType, float AmountDepressed, bool bGamepad) { bool bResult = false; if(GEngine->HMDDevice.IsValid()) { bResult = GEngine->HMDDevice->HandleInputKey(PlayerInput, Key, EventType, AmountDepressed, bGamepad); if(bResult) { return bResult; } } if(PlayerInput) { bResult = PlayerInput->InputKey(Key, EventType, AmountDepressed, bGamepad); // TODO: Allow click key(s?) to be defined if(bEnableClickEvents && (Key == EKeys::LeftMouseButton || Key == EKeys::RightMouseButton)) { if (Key == EKeys::LeftMouseButton) { AAmbitionOfNobunagaPlayerController::OnMouseLButtonPressed1(); } else if (Key == EKeys::RightMouseButton) { AAmbitionOfNobunagaPlayerController::OnMouseRButtonPressed1(); } FVector2D MousePosition; if(CastChecked<ULocalPlayer>(Player)->ViewportClient->GetMousePosition(MousePosition)) { ClickedPrimitive = NULL; if(bEnableMouseOverEvents) { ClickedPrimitive = CurrentClickablePrimitive.Get(); } else { FHitResult HitResult; const bool bHit = GetHitResultAtScreenPosition(MousePosition, CurrentClickTraceChannel, true, HitResult); if(bHit) { ClickedPrimitive = HitResult.Component.Get(); } } if(GetHUD()) { if(GetHUD()->UpdateAndDispatchHitBoxClickEvents(MousePosition, EventType)) { ClickedPrimitive = NULL; } } if(ClickedPrimitive) { switch(EventType) { case IE_Pressed: case IE_DoubleClick: ClickedPrimitive->DispatchOnClicked(); break; case IE_Released: ClickedPrimitive->DispatchOnReleased(); break; case IE_Axis: case IE_Repeat: break; } } bResult = true; } if (Key == EKeys::LeftMouseButton) { AAmbitionOfNobunagaPlayerController::OnMouseLButtonPressed2(); } else if (Key == EKeys::RightMouseButton) { AAmbitionOfNobunagaPlayerController::OnMouseRButtonPressed2(); } } } return bResult; }