feat: initial commit, only bugs remaining
This commit is contained in:
		| @@ -11,6 +11,7 @@ | ||||
| #include "InputActionValue.h" | ||||
| #include "EnhancedInputSubsystems.h" | ||||
| #include "Engine/LocalPlayer.h" | ||||
| #include "Blueprint/UserWidget.h" | ||||
|  | ||||
| DEFINE_LOG_CATEGORY(LogTemplateCharacter); | ||||
|  | ||||
| @@ -26,6 +27,9 @@ void AUTAD_UIPlayerController::BeginPlay() | ||||
| { | ||||
| 	// Call the base class | ||||
| 	Super::BeginPlay(); | ||||
|  | ||||
| 	// Create and show the main HUD | ||||
| 	ShowMainHUD(); | ||||
| } | ||||
|  | ||||
| void AUTAD_UIPlayerController::SetupInputComponent() | ||||
| @@ -72,6 +76,14 @@ void AUTAD_UIPlayerController::SetupInputComponent() | ||||
| 		EnhancedInputComponent->BindAction( | ||||
| 			SetDestinationTouchAction, ETriggerEvent::Canceled, this, | ||||
| 			&AUTAD_UIPlayerController::OnTouchReleased); | ||||
|  | ||||
| 		// Setup skill tree input | ||||
| 		if (OpenSkillTreeAction) | ||||
| 		{ | ||||
| 			EnhancedInputComponent->BindAction( | ||||
| 				OpenSkillTreeAction, ETriggerEvent::Triggered, this, | ||||
| 				&AUTAD_UIPlayerController::OnOpenSkillTree); | ||||
| 		} | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| @@ -154,3 +166,66 @@ void AUTAD_UIPlayerController::OnTouchReleased() | ||||
| 	bIsTouch = false; | ||||
| 	OnSetDestinationReleased(); | ||||
| } | ||||
|  | ||||
| void AUTAD_UIPlayerController::OnOpenSkillTree() | ||||
| { | ||||
| 	ToggleSkillTree(); | ||||
| } | ||||
|  | ||||
| void AUTAD_UIPlayerController::ShowMainHUD() | ||||
| { | ||||
| 	if (MainHUDClass && !MainHUDWidget) | ||||
| 	{ | ||||
| 		MainHUDWidget = CreateWidget<UUserWidget>(this, MainHUDClass); | ||||
| 		if (MainHUDWidget) | ||||
| 		{ | ||||
| 			MainHUDWidget->AddToViewport(0); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void AUTAD_UIPlayerController::ShowSkillTree() | ||||
| { | ||||
| 	if (!SkillTreeWidget && SkillTreeWidgetClass) | ||||
| 	{ | ||||
| 		SkillTreeWidget = CreateWidget<UUserWidget>(this, SkillTreeWidgetClass); | ||||
| 	} | ||||
|  | ||||
| 	if (SkillTreeWidget && !SkillTreeWidget->IsInViewport()) | ||||
| 	{ | ||||
| 		SkillTreeWidget->AddToViewport(1); | ||||
|  | ||||
| 		// Set input mode to Game and UI | ||||
| 		FInputModeGameAndUI InputMode; | ||||
| 		InputMode.SetWidgetToFocus(SkillTreeWidget->TakeWidget()); | ||||
| 		InputMode.SetLockMouseToViewportBehavior(EMouseLockMode::DoNotLock); | ||||
| 		SetInputMode(InputMode); | ||||
| 		bShowMouseCursor = true; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void AUTAD_UIPlayerController::HideSkillTree() | ||||
| { | ||||
| 	if (SkillTreeWidget && SkillTreeWidget->IsInViewport()) | ||||
| 	{ | ||||
| 		SkillTreeWidget->RemoveFromParent(); | ||||
|  | ||||
| 		// Set input mode back to game only | ||||
| 		FInputModeGameOnly InputMode; | ||||
| 		SetInputMode(InputMode); | ||||
| 		// Keep mouse cursor visible for top-down game | ||||
| 		bShowMouseCursor = true; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void AUTAD_UIPlayerController::ToggleSkillTree() | ||||
| { | ||||
| 	if (SkillTreeWidget && SkillTreeWidget->IsInViewport()) | ||||
| 	{ | ||||
| 		HideSkillTree(); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		ShowSkillTree(); | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user