Merge pull request 'Merge some UI improvements' (#8) from feature-ui-improvements into dev
Reviewed-on: #8pull/2/head
commit
e8e6d37dad
@ -1,7 +1,10 @@
|
||||
|
||||
[/Script/EngineSettings.GeneralProjectSettings]
|
||||
ProjectID=D68B8A08410D0195272328B9EAD1AE41
|
||||
bShouldWindowPreserveAspectRatio=False
|
||||
bUseBorderlessWindow=False
|
||||
|
||||
[StartupActions]
|
||||
bAddPacks=True
|
||||
InsertPack=(PackSource="StarterContent.upack",PackName="StarterContent")
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,63 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#include "BattleUI.h"
|
||||
#include "Components/Button.h"
|
||||
#include "Components/TextBlock.h"
|
||||
#include "BattlePlayerController.h"
|
||||
#include "BattlePlayerState.h"
|
||||
|
||||
|
||||
void UBattleUI::NativeConstruct() {
|
||||
Super::NativeConstruct();
|
||||
EndTurnButton->OnClicked.AddDynamic(this, &ThisClass::OnEndTurnClicked);
|
||||
ButtonAction_0->OnClicked.AddDynamic(this, &ThisClass::OnActionSwitched_0);
|
||||
ButtonAction_1->OnClicked.AddDynamic(this, &ThisClass::OnActionSwitched_1);
|
||||
ButtonAction_2->OnClicked.AddDynamic(this, &ThisClass::OnActionSwitched_2);
|
||||
}
|
||||
|
||||
void UBattleUI::SetWidgetText_Implementation(const FString &Text) {
|
||||
InformationText->SetText(FText::FromString(Text));
|
||||
}
|
||||
|
||||
void UBattleUI::SetWhoseTurnText_Implementation(bool IsThisPlayerTurn) {
|
||||
if (IsThisPlayerTurn) {
|
||||
SetWidgetText(TEXT("Your turn!"));
|
||||
} else {
|
||||
SetWidgetText(TEXT("Opponent's turn"));
|
||||
}
|
||||
}
|
||||
|
||||
void UBattleUI::OnEndTurnClicked() {
|
||||
Cast<ABattlePlayerController>(GetWorld()->GetFirstPlayerController())->
|
||||
EndTurn();
|
||||
}
|
||||
|
||||
void UBattleUI::OnActionSwitched_0() {
|
||||
ButtonAction_0->SetIsEnabled(false);
|
||||
ButtonAction_1->SetIsEnabled(true);
|
||||
ButtonAction_2->SetIsEnabled(true);
|
||||
ActionType = 0;
|
||||
OnActionSwitched();
|
||||
}
|
||||
|
||||
void UBattleUI::OnActionSwitched_1() {
|
||||
ButtonAction_0->SetIsEnabled(true);
|
||||
ButtonAction_1->SetIsEnabled(false);
|
||||
ButtonAction_2->SetIsEnabled(true);
|
||||
ActionType = 1;
|
||||
OnActionSwitched();
|
||||
}
|
||||
|
||||
void UBattleUI::OnActionSwitched_2() {
|
||||
ButtonAction_0->SetIsEnabled(true);
|
||||
ButtonAction_1->SetIsEnabled(true);
|
||||
ButtonAction_2->SetIsEnabled(false);
|
||||
ActionType = 2;
|
||||
OnActionSwitched();
|
||||
}
|
||||
|
||||
void UBattleUI::OnActionSwitched() const {
|
||||
Cast<ABattlePlayerController>(GetWorld()->GetFirstPlayerController())->
|
||||
GetPlayerState<ABattlePlayerState>()->SetCurrentAction(ActionType);
|
||||
}
|
||||
|
@ -0,0 +1,58 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "BattleUI.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class TURNBASEDTUTORIAL_API UBattleUI : public UUserWidget {
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
virtual void NativeConstruct() override;
|
||||
|
||||
UFUNCTION(Client, Reliable)
|
||||
void SetWhoseTurnText(bool IsThisPlayerTurn);
|
||||
|
||||
UFUNCTION(Client, Reliable)
|
||||
void SetWidgetText(const FString &Text);
|
||||
|
||||
protected:
|
||||
int ActionType = 0;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(BindWidget))
|
||||
class UButton *EndTurnButton;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(BindWidget))
|
||||
class UButton *ButtonAction_0;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(BindWidget))
|
||||
class UButton *ButtonAction_1;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(BindWidget))
|
||||
class UButton *ButtonAction_2;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(BindWidget))
|
||||
class UTextBlock *InformationText;
|
||||
|
||||
UFUNCTION()
|
||||
void OnEndTurnClicked();
|
||||
|
||||
UFUNCTION()
|
||||
void OnActionSwitched_0();
|
||||
|
||||
UFUNCTION()
|
||||
void OnActionSwitched_1();
|
||||
|
||||
UFUNCTION()
|
||||
void OnActionSwitched_2();
|
||||
|
||||
UFUNCTION()
|
||||
void OnActionSwitched() const;
|
||||
|
||||
};
|
@ -0,0 +1,27 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#include "ManageSquadWidget.h"
|
||||
|
||||
#include "ManageSquadGameState.h"
|
||||
#include "SelectedTrooperSaveGame.h"
|
||||
#include "Components/Button.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
||||
|
||||
void UManageSquadWidget::NativeConstruct() {
|
||||
Super::NativeConstruct();
|
||||
BackButton->OnClicked.AddDynamic(
|
||||
this, &ThisClass::UManageSquadWidget::OnBackButtonClicked);
|
||||
}
|
||||
|
||||
void UManageSquadWidget::OnBackButtonClicked() {
|
||||
USelectedTrooperSaveGame *SaveGameInstance = Cast<USelectedTrooperSaveGame>(
|
||||
UGameplayStatics::CreateSaveGameObject(
|
||||
USelectedTrooperSaveGame::StaticClass()));
|
||||
SaveGameInstance->SelectedTroopers = GetWorld()->GetGameState<
|
||||
AManageSquadGameState>()->GetSquad();
|
||||
UGameplayStatics::SaveGameToSlot(
|
||||
SaveGameInstance,TEXT("Selected troopers"), 0);
|
||||
UGameplayStatics::OpenLevel(GetWorld(), "MainMenuLevel");
|
||||
RemoveFromParent();
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "ManageSquadWidget.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class TURNBASEDTUTORIAL_API UManageSquadWidget : public UUserWidget {
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
virtual void NativeConstruct() override;
|
||||
|
||||
protected:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(BindWidget))
|
||||
class UButton *BackButton;
|
||||
|
||||
UFUNCTION()
|
||||
void OnBackButtonClicked();
|
||||
};
|
@ -0,0 +1,8 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "SelectedTrooperSaveGame.h"
|
||||
|
||||
USelectedTrooperSaveGame::USelectedTrooperSaveGame()
|
||||
: Super() {
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/SaveGame.h"
|
||||
#include "SelectedTrooperSaveGame.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class TURNBASEDTUTORIAL_API USelectedTrooperSaveGame : public USaveGame {
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, Category=Basic)
|
||||
TArray<uint8> SelectedTroopers;
|
||||
|
||||
USelectedTrooperSaveGame();
|
||||
};
|
Loading…
Reference in new issue