diff --git a/Project/Binaries/Win64/UnrealEditor-Gasa.dll b/Project/Binaries/Win64/UnrealEditor-Gasa.dll index 7fedcfd..f72d045 100644 --- a/Project/Binaries/Win64/UnrealEditor-Gasa.dll +++ b/Project/Binaries/Win64/UnrealEditor-Gasa.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9d88f8977429788493a9f6ad0d8a7f6669c736619e6119d0eb2388ec4a015ff1 -size 572416 +oid sha256:839a8eeeb78730a282fab857d06caf01eefc94b90c8814a9aaa2c4b8354e7f2b +size 585216 diff --git a/Project/Binaries/Win64/UnrealEditor-Gasa.pdb b/Project/Binaries/Win64/UnrealEditor-Gasa.pdb index 0958a4d..5a83b60 100644 Binary files a/Project/Binaries/Win64/UnrealEditor-Gasa.pdb and b/Project/Binaries/Win64/UnrealEditor-Gasa.pdb differ diff --git a/Project/Binaries/Win64/UnrealEditor-GasaEditor.dll b/Project/Binaries/Win64/UnrealEditor-GasaEditor.dll index 2e9273f..0092aa3 100644 --- a/Project/Binaries/Win64/UnrealEditor-GasaEditor.dll +++ b/Project/Binaries/Win64/UnrealEditor-GasaEditor.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:845396792181c6a0bed933e479e351823043bef9b7a8fa173a00137698a4cc20 +oid sha256:e9141dea5d29e14a1cf866fe6323fc1e6ca94cb24fef1d1c8b69aad83bd820d4 size 79360 diff --git a/Project/Binaries/Win64/UnrealEditor-GasaEditor.pdb b/Project/Binaries/Win64/UnrealEditor-GasaEditor.pdb index cf3af54..9f59f37 100644 Binary files a/Project/Binaries/Win64/UnrealEditor-GasaEditor.pdb and b/Project/Binaries/Win64/UnrealEditor-GasaEditor.pdb differ diff --git a/Project/Config/DefaultEngine.ini b/Project/Config/DefaultEngine.ini index 4d2482c..a56d027 100644 --- a/Project/Config/DefaultEngine.ini +++ b/Project/Config/DefaultEngine.ini @@ -131,3 +131,6 @@ ManualIPAddress= +CollisionChannelRedirects=(OldName="VehicleMovement",NewName="Vehicle") +CollisionChannelRedirects=(OldName="PawnMovement",NewName="Pawn") + +[CoreRedirects] ++ClassRedirects=(OldName="/Script/Gasa.UI_HostWidget",NewName="/Script/Gasa.HUDHostWidget") \ No newline at end of file diff --git a/Project/Config/DefaultGame.ini b/Project/Config/DefaultGame.ini index ebc12cf..41d3140 100644 --- a/Project/Config/DefaultGame.ini +++ b/Project/Config/DefaultGame.ini @@ -9,6 +9,7 @@ Tag_PPV=Global_PPV Tag_GlobalPPV=Global_PPV Template_PlayerCamera=/Game/Actors/BP_CameraMount.BP_CameraMount_C Template_HUD_HostUI=/Game/UI/UI_Host.UI_Host_C +Template_HostWidgetController=/Game/Core/BP_HostWidgetController.BP_HostWidgetController_C [/Script/GameplayAbilities.AbilitySystemGlobals] bUseDebugTargetFromHud=true diff --git a/Project/Content/Core/BP_HostWidgetController.uasset b/Project/Content/Core/BP_HostWidgetController.uasset new file mode 100644 index 0000000..c6ca494 --- /dev/null +++ b/Project/Content/Core/BP_HostWidgetController.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c68d5033e743303705737b5c05a6bf2a1f9c44e8cddfc0e293747aa7ff70631a +size 5831 diff --git a/Project/Content/UI/UI_Host.uasset b/Project/Content/UI/UI_Host.uasset index 038ace1..33c0dfd 100644 --- a/Project/Content/UI/UI_Host.uasset +++ b/Project/Content/UI/UI_Host.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4a92e8df58c2f62bf23279be15b3bba3e5f56f43780629591e0f6f43a89f8d95 -size 14310 +oid sha256:6e4ab0b203358ec7e87d3449f3ce6a934967dcaba234f8dc6eb3f3b60c6b9c4f +size 25232 diff --git a/Project/Source/Gasa/AbilitySystem/GasaAbilitySystemComponent.h b/Project/Source/Gasa/AbilitySystem/GasaAbilitySystemComponent.h index 4d91ba0..8ec5d5e 100644 --- a/Project/Source/Gasa/AbilitySystem/GasaAbilitySystemComponent.h +++ b/Project/Source/Gasa/AbilitySystem/GasaAbilitySystemComponent.h @@ -1,7 +1,6 @@ #pragma once #include "AbilitySystemComponent.h" -#include "AbilitySystemInterface.h" #include "GasaCommon.h" @@ -14,16 +13,3 @@ class GASA_API UGasaAbilitySystemComp : public UAbilitySystemComponent GENERATED_BODY() public: }; - -namespace Gasa -{ - inline - UGasaAbilitySystemComp* GetAbilitySystem(UObject* Object) - { - if (Object->Implements()) - { - return Cast( Cast(Object)->GetAbilitySystemComponent() ); - } - return nullptr; - } -} diff --git a/Project/Source/Gasa/AbilitySystem/GasaAbilitySystemComponent_Inlines.h b/Project/Source/Gasa/AbilitySystem/GasaAbilitySystemComponent_Inlines.h new file mode 100644 index 0000000..10d2f57 --- /dev/null +++ b/Project/Source/Gasa/AbilitySystem/GasaAbilitySystemComponent_Inlines.h @@ -0,0 +1,16 @@ +#pragma once +#include "GasaAbilitySystemComponent.h" +#include "AbilitySystemInterface.h" + +namespace Gasa +{ + inline + UGasaAbilitySystemComp* GetAbilitySystem(UObject* Object) + { + if (Object->Implements()) + { + return Cast( Cast(Object)->GetAbilitySystemComponent() ); + } + return nullptr; + } +} diff --git a/Project/Source/Gasa/AbilitySystem/GasaAttributeSet.cpp b/Project/Source/Gasa/AbilitySystem/GasaAttributeSet.cpp index cf9577a..03c3d33 100644 --- a/Project/Source/Gasa/AbilitySystem/GasaAttributeSet.cpp +++ b/Project/Source/Gasa/AbilitySystem/GasaAttributeSet.cpp @@ -1,5 +1,6 @@ -// This was generated by GasaGen/GasaGen.cpp +// Generated by GasaGen/GasaGen_UGasaAttributeSet.cpp #include "GasaAttributeSet.h" +#include "GasaAttributeSet_Inlines.h" #include "AbilitySystemComponent.h" #include "Net/UnrealNetwork.h" diff --git a/Project/Source/Gasa/AbilitySystem/GasaAttributeSet.h b/Project/Source/Gasa/AbilitySystem/GasaAttributeSet.h index 3faf0d7..b279735 100644 --- a/Project/Source/Gasa/AbilitySystem/GasaAttributeSet.h +++ b/Project/Source/Gasa/AbilitySystem/GasaAttributeSet.h @@ -1,7 +1,7 @@ -// This was generated by GasaGen/GasaGen.cpp +// Generated by GasaGen/GasaGen_UGasaAttributeSet.cpp +#pragma once #include "AttributeSet.h" -#include "AbilitySystemComponent.h" #include "GasaAttributeSet.generated.h" UCLASS() @@ -53,6 +53,7 @@ public: static FProperty* Prop = FindFieldChecked( UGasaAttributeSet::StaticClass(), GET_MEMBER_NAME_CHECKED( UGasaAttributeSet, MaxMana ) ); return Prop; } + FORCEINLINE float GetHealth() const { return Health.GetCurrentValue(); } FORCEINLINE float GetMaxHealth() const { return MaxHealth.GetCurrentValue(); } FORCEINLINE float GetMana() const { return Mana.GetCurrentValue(); } @@ -61,38 +62,11 @@ public: #pragma region Setters FORCEINLINE void - SetHealth( float NewVal ) - { - UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent(); - if ( ensure( AbilityComp ) ) - { - AbilityComp->SetNumericAttributeBase( GetHealthAttribute(), NewVal ); - }; - } - FORCEINLINE void SetMaxHealth( float NewVal ) - { - UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent(); - if ( ensure( AbilityComp ) ) - { - AbilityComp->SetNumericAttributeBase( GetMaxHealthAttribute(), NewVal ); - }; - } - FORCEINLINE void SetMana( float NewVal ) - { - UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent(); - if ( ensure( AbilityComp ) ) - { - AbilityComp->SetNumericAttributeBase( GetManaAttribute(), NewVal ); - }; - } - FORCEINLINE void SetMaxMana( float NewVal ) - { - UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent(); - if ( ensure( AbilityComp ) ) - { - AbilityComp->SetNumericAttributeBase( GetMaxManaAttribute(), NewVal ); - }; - } + SetHealth( float NewVal ); + FORCEINLINE void SetMaxHealth( float NewVal ); + FORCEINLINE void SetMana( float NewVal ); + FORCEINLINE void SetMaxMana( float NewVal ); + FORCEINLINE void InitHealth( float NewVal ) { Health.SetBaseValue( NewVal ); @@ -121,11 +95,3 @@ public: GetLifetimeReplicatedProps( TArray& OutLifetimeProps ) const override; #pragma endregion UObject }; -namespace Gasa -{ - inline UGasaAttributeSet const* GetAttributeSet( UAbilitySystemComponent* ASC ) - { - return Cast( ASC->GetAttributeSet( UGasaAttributeSet::StaticClass() ) ); - } - -} diff --git a/Project/Source/Gasa/AbilitySystem/GasaAttributeSet_Inlines.h b/Project/Source/Gasa/AbilitySystem/GasaAttributeSet_Inlines.h new file mode 100644 index 0000000..bad1e43 --- /dev/null +++ b/Project/Source/Gasa/AbilitySystem/GasaAttributeSet_Inlines.h @@ -0,0 +1,51 @@ +// Generated by GasaGen/GasaGen_UGasaAttributeSet.cpp +#pragma once + +#include "GasaAttributeSet.h" +#include "AbilitySystemComponent.h" + +FORCEINLINE +void UGasaAttributeSet::SetHealth( float NewVal ) +{ + UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent(); + if ( ensure( AbilityComp ) ) + { + AbilityComp->SetNumericAttributeBase( GetHealthAttribute(), NewVal ); + }; +} +FORCEINLINE +void UGasaAttributeSet::SetMaxHealth( float NewVal ) +{ + UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent(); + if ( ensure( AbilityComp ) ) + { + AbilityComp->SetNumericAttributeBase( GetMaxHealthAttribute(), NewVal ); + }; +} +FORCEINLINE +void UGasaAttributeSet::SetMana( float NewVal ) +{ + UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent(); + if ( ensure( AbilityComp ) ) + { + AbilityComp->SetNumericAttributeBase( GetManaAttribute(), NewVal ); + }; +} +FORCEINLINE +void UGasaAttributeSet::SetMaxMana( float NewVal ) +{ + UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent(); + if ( ensure( AbilityComp ) ) + { + AbilityComp->SetNumericAttributeBase( GetMaxManaAttribute(), NewVal ); + }; +} + +namespace Gasa +{ + inline UGasaAttributeSet const* GetAttributeSet( UAbilitySystemComponent* ASC ) + { + return Cast( ASC->GetAttributeSet( UGasaAttributeSet::StaticClass() ) ); + } + +} diff --git a/Project/Source/Gasa/AbilitySystem/GasaEffectActor.cpp b/Project/Source/Gasa/AbilitySystem/GasaEffectActor.cpp index 589f617..82b26ee 100644 --- a/Project/Source/Gasa/AbilitySystem/GasaEffectActor.cpp +++ b/Project/Source/Gasa/AbilitySystem/GasaEffectActor.cpp @@ -1,8 +1,8 @@ #include "GasaEffectActor.h" -#include "AbilitySystemComponent.h" #include "AbilitySystemInterface.h" #include "GasaAttributeSet.h" +#include "GasaAttributeSet_Inlines.h" #include "Components/SphereComponent.h" diff --git a/Project/Source/Gasa/Characters/PlayerCharacter.cpp b/Project/Source/Gasa/Characters/PlayerCharacter.cpp index 849cbf8..34a830e 100644 --- a/Project/Source/Gasa/Characters/PlayerCharacter.cpp +++ b/Project/Source/Gasa/Characters/PlayerCharacter.cpp @@ -1,6 +1,9 @@ #include "PlayerCharacter.h" #include "AbilitySystemComponent.h" +#include "Game/GasaPlayerController.h" +#include "UI/GasaHUD.h" +#include "UI/WidgetController.h" APlayerCharacter::APlayerCharacter() { @@ -9,6 +12,7 @@ APlayerCharacter::APlayerCharacter() bAutoAbilitySystem = false; } +// TODO(Ed): We need to setup Net Slime... void APlayerCharacter::PossessedBy(AController* NewController) { Super::PossessedBy(NewController); @@ -20,8 +24,14 @@ void APlayerCharacter::PossessedBy(AController* NewController) Attributes = PS->Attributes; AbilitySystem->InitAbilityActorInfo(PS, this); } + + AGasaPlayerController* PC = GetController(); + AGasaHUD* HUD = PC->GetHUD(); + FWidgetControllerData Data = { PC, PS, AbilitySystem, Attributes }; + HUD->InitOverlay(& Data); } +// TODO(Ed): We need to setup Net Slime... void APlayerCharacter::OnRep_PlayerState() { Super::OnRep_PlayerState(); @@ -33,4 +43,12 @@ void APlayerCharacter::OnRep_PlayerState() Attributes = PS->Attributes; AbilitySystem->InitAbilityActorInfo(PS, this); } + + if (IsLocallyControlled()) + { + AGasaPlayerController* PC = GetController(); + AGasaHUD* HUD = PC->GetHUD(); + FWidgetControllerData Data = { PC, PS, AbilitySystem, Attributes }; + HUD->InitOverlay(& Data); + } } diff --git a/Project/Source/Gasa/Game/GasaPlayerController.cpp b/Project/Source/Gasa/Game/GasaPlayerController.cpp index 8006539..994de32 100644 --- a/Project/Source/Gasa/Game/GasaPlayerController.cpp +++ b/Project/Source/Gasa/Game/GasaPlayerController.cpp @@ -1,4 +1,5 @@ #include "GasaPlayerController.h" +#include "GasaPlayerController_Inlines.h" #include "AbilitySystemComponent.h" #include "Engine/LocalPlayer.h" @@ -12,7 +13,6 @@ #include "Components/CapsuleComponent.h" #include "GameFramework/SpringArmComponent.h" #include "Kismet/KismetSystemLibrary.h" - using namespace Gasa; AGasaPlayerController::AGasaPlayerController() @@ -24,6 +24,8 @@ AGasaPlayerController::AGasaPlayerController() bReplicates = true; } + + #pragma region Input void AGasaPlayerController::Move(FInputActionValue const& ActionValue) { @@ -31,8 +33,6 @@ void AGasaPlayerController::Move(FInputActionValue const& ActionValue) if (pawn == nullptr ) return; - - // Note(Ed): I did the follow optimization for practice, they are completely unnecessary for this context. #if 0 FVector2D AxisV = ActionValue.Get(); @@ -77,6 +77,7 @@ void AGasaPlayerController::SpawnDefaultHUD() Super::SpawnDefaultHUD(); } +// TODO(Ed): We need to setup Net Slime... void AGasaPlayerController::OnPossess(APawn* InPawn) { Super::OnPossess(InPawn); diff --git a/Project/Source/Gasa/Game/GasaPlayerController.h b/Project/Source/Gasa/Game/GasaPlayerController.h index 08c5025..9674b86 100644 --- a/Project/Source/Gasa/Game/GasaPlayerController.h +++ b/Project/Source/Gasa/Game/GasaPlayerController.h @@ -1,7 +1,6 @@ #pragma once #include "GasaCommon.h" -#include "GasaPlayerState.h" #include "GameFramework/PlayerController.h" #include "GasaPlayerController.generated.h" @@ -51,10 +50,7 @@ public: AGasaPlayerController(); - AGasaPlayerState* GetPlayerState() - { - return Cast( PlayerState ); - } + inline AGasaPlayerState* GetPlayerState(); #pragma region PlayerController void SpawnDefaultHUD() override; diff --git a/Project/Source/Gasa/Game/GasaPlayerController_Inlines.h b/Project/Source/Gasa/Game/GasaPlayerController_Inlines.h new file mode 100644 index 0000000..0f88c2a --- /dev/null +++ b/Project/Source/Gasa/Game/GasaPlayerController_Inlines.h @@ -0,0 +1,8 @@ +#include "GasaPlayerController.h" +#include "GasaPlayerState.h" + +inline +AGasaPlayerState* AGasaPlayerController::GetPlayerState() +{ + return Cast( PlayerState ); +} diff --git a/Project/Source/Gasa/GasaCommon.h b/Project/Source/Gasa/GasaCommon.h index dd0ab7a..2ca622e 100644 --- a/Project/Source/Gasa/GasaCommon.h +++ b/Project/Source/Gasa/GasaCommon.h @@ -40,6 +40,7 @@ class AGasaGameInstance; class AGasaGameState; class AGasaLevelScriptActor; class AGasaPlayerController; +class AGasaPlayerState; class UGasaAbilitySystemComp; class UGasaAttributeSet; @@ -48,7 +49,11 @@ class UGasaImage; class UGasaOverlay; class UGasaProgressBar; class UGasaSizeBox; -class UUI_HostWidget; +class UHostWidgetController; +class UHUDHostWidget; +class UWidgetController; + +struct FWidgetControllerData; #pragma endregion Forwards #pragma region Logging diff --git a/Project/Source/Gasa/GasaDevOptions.cpp b/Project/Source/Gasa/GasaDevOptions.cpp index ffd96d1..b31e8df 100644 --- a/Project/Source/Gasa/GasaDevOptions.cpp +++ b/Project/Source/Gasa/GasaDevOptions.cpp @@ -1,7 +1,8 @@ #include "GasaDevOptions.h" #include "Actors/CameraMount.h" -#include "UI/UI_HostWidget.h" +#include "UI/HUDHostWidget.h" +#include "UI/HostWidgetController.h" using namespace Gasa; diff --git a/Project/Source/Gasa/GasaDevOptions.h b/Project/Source/Gasa/GasaDevOptions.h index 0415792..1f125be 100644 --- a/Project/Source/Gasa/GasaDevOptions.h +++ b/Project/Source/Gasa/GasaDevOptions.h @@ -19,7 +19,10 @@ public: TSoftClassPtr Template_PlayerCamera; UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category="UI") - TSoftClassPtr Template_HUD_HostUI; + TSoftClassPtr Template_HUD_HostUI; + + UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category="UI") + TSoftClassPtr Template_HostWidgetController; UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category="Tags") FName Tag_GlobalPPV; diff --git a/Project/Source/Gasa/GasaDevOptionsCache.cpp b/Project/Source/Gasa/GasaDevOptionsCache.cpp index 3983ed2..8517248 100644 --- a/Project/Source/Gasa/GasaDevOptionsCache.cpp +++ b/Project/Source/Gasa/GasaDevOptionsCache.cpp @@ -1,9 +1,10 @@ -// This was generated by GasaGen/GasaGen.cpp +// Generated by GasaGen/GasaGen_DevOptionsCache.cpp #include "GasaDevOptionsCache.h" #include "GasaDevOptions.h" #include "Actors/CameraMount.h" -#include "UI/UI_HostWidget.h" +#include "UI/HUDHostWidget.h" +#include "UI/HostWidgetController.h" using namespace Gasa; void FGasaDevOptionsCache::CachedDevOptions() @@ -11,7 +12,13 @@ void FGasaDevOptionsCache::CachedDevOptions() UGasaDevOptions* DevOpts = GetMutDevOptions(); Template_PlayerCamera = DevOpts->Template_PlayerCamera.LoadSynchronous(); - Template_HUD_HostUI = DevOpts->Template_HUD_HostUI.LoadSynchronous(); + ensureMsgf( Template_PlayerCamera != nullptr, TEXT( "Template_PlayerCamera is null, DO NOT RUN PIE or else you may get a crash if not handled in BP or C++" ) ); + + Template_HUD_HostUI = DevOpts->Template_HUD_HostUI.LoadSynchronous(); + ensureMsgf( Template_HUD_HostUI != nullptr, TEXT( "Template_HUD_HostUI is null, DO NOT RUN PIE or else you may get a crash if not handled in BP or C++" ) ); + + Template_HostWidgetController = DevOpts->Template_HostWidgetController.LoadSynchronous(); + ensureMsgf( Template_HostWidgetController != nullptr, TEXT( "Template_HostWidgetController is null, DO NOT RUN PIE or else you may get a crash if not handled in BP or C++" ) ); Tag_GlobalPPV = DevOpts->Tag_GlobalPPV; } diff --git a/Project/Source/Gasa/GasaDevOptionsCache.h b/Project/Source/Gasa/GasaDevOptionsCache.h index fb6ed94..04d842d 100644 --- a/Project/Source/Gasa/GasaDevOptionsCache.h +++ b/Project/Source/Gasa/GasaDevOptionsCache.h @@ -1,4 +1,4 @@ -// This was generated by GasaGen/GasaGen.cpp +// Generated by GasaGen/GasaGen_DevOptionsCache.cpp #pragma once #include "GasaDevOptionsCache.generated.h" @@ -12,6 +12,8 @@ struct GASA_API FGasaDevOptionsCache UClass* Template_PlayerCamera; UPROPERTY() UClass* Template_HUD_HostUI; + UPROPERTY() + UClass* Template_HostWidgetController; void CachedDevOptions(); }; diff --git a/Project/Source/Gasa/UI/GasaHUD.cpp b/Project/Source/Gasa/UI/GasaHUD.cpp index eb78a1a..eb2093e 100644 --- a/Project/Source/Gasa/UI/GasaHUD.cpp +++ b/Project/Source/Gasa/UI/GasaHUD.cpp @@ -1,11 +1,21 @@ #include "GasaHUD.h" +#include "GasaHUD_Inlines.h" #include "GasaDevOptions.h" -#include "UI_HostWidget.h" +#include "HUDHostWidget.h" #include "Blueprint/UserWidget.h" - using namespace Gasa; +void AGasaHUD::InitOverlay(FWidgetControllerData const* WidgetControllerData) +{ + HostWidget = CreateWidget( GetWorld() + , GetDevOptions()->Template_HUD_HostUI.LoadSynchronous() ); + + HostWidgetController = NewObject(this, GetDevOptions()->Template_HostWidgetController.Get()); + HostWidget->SetWidgetController(HostWidgetController); + + HostWidget->AddToViewport(); +} #pragma region HUD void AGasaHUD::ShowHUD() @@ -15,17 +25,8 @@ void AGasaHUD::ShowHUD() #pragma endregion HUD #pragma region Actor -UE_DISABLE_OPTIMIZATION void AGasaHUD::BeginPlay() { Super::BeginPlay(); - - HostWidget = CreateWidget( GetWorld() - , GetDevOptions()->Template_HUD_HostUI.LoadSynchronous() ); - HostWidget->AddToViewport(); - - bool bHostVis = HostWidget->IsVisible(); - Log(FString::Printf(TEXT("HostVIs: %s"), *FString::FromInt(bHostVis))); } -UE_ENABLE_OPTIMIZATION #pragma endregion Actor diff --git a/Project/Source/Gasa/UI/GasaHUD.h b/Project/Source/Gasa/UI/GasaHUD.h index 2de69eb..bc4543c 100644 --- a/Project/Source/Gasa/UI/GasaHUD.h +++ b/Project/Source/Gasa/UI/GasaHUD.h @@ -12,14 +12,20 @@ class GASA_API AGasaHUD : public AHUD GENERATED_BODY() public: UPROPERTY(VisibleAnywhere, BlueprintReadWrite) - TObjectPtr HostWidget; + TObjectPtr HostWidget; + // This should only be accessed AFTER InitOverlay is called. Otherwise, it will be null + // See references to InitOverlay or docs for lifetime. + UPROPERTY(VisibleAnywhere, BlueprintReadWrite) + TObjectPtr HostWidgetController; + + void InitOverlay(FWidgetControllerData const* WidgetControllerData); + #pragma region HUD void ShowHUD() override; #pragma endregion HUD #pragma region Actor void BeginPlay() override; - #pragma endregion Actor }; diff --git a/Project/Source/Gasa/UI/GasaHUD_Inlines.h b/Project/Source/Gasa/UI/GasaHUD_Inlines.h new file mode 100644 index 0000000..9b86bb4 --- /dev/null +++ b/Project/Source/Gasa/UI/GasaHUD_Inlines.h @@ -0,0 +1,5 @@ +#pragma once +#include "GasaHUD.h" +#include "GasaDevOptions.h" +#include "HostWidgetController.h" +#include "HUDHostWidget.h" diff --git a/Project/Source/Gasa/UI/GasaUserWidget.h b/Project/Source/Gasa/UI/GasaUserWidget.h index 7b3cbd1..5cb249a 100644 --- a/Project/Source/Gasa/UI/GasaUserWidget.h +++ b/Project/Source/Gasa/UI/GasaUserWidget.h @@ -1,8 +1,10 @@ #pragma once #include "Blueprint/UserWidget.h" +#include "GasaCommon.h" #include "GasaUserWidget.generated.h" + UCLASS(Blueprintable) class GASA_API UGasaUserWidget : public UUserWidget { @@ -23,12 +25,15 @@ public: TSubclassOf LooseParent; UPROPERTY(BlueprintReadOnly) - TObjectPtr WidgetController; + TObjectPtr WidgetController; UGasaUserWidget(FObjectInitializer const& ObjectInitializer); + template + FORCEINLINE WidgetControllerType* GetWidgetController() { return Cast(WidgetController); } + UFUNCTION(BlueprintCallable) - void SetWidgetController(UObject* Controller) + void SetWidgetController(UWidgetController* Controller) { WidgetController = Controller; OnWidgetControllerSet(); diff --git a/Project/Source/Gasa/UI/HUDHostWidget.cpp b/Project/Source/Gasa/UI/HUDHostWidget.cpp new file mode 100644 index 0000000..86764b4 --- /dev/null +++ b/Project/Source/Gasa/UI/HUDHostWidget.cpp @@ -0,0 +1 @@ +#include "HUDHostWidget.h" diff --git a/Project/Source/Gasa/UI/UI_HostWidget.h b/Project/Source/Gasa/UI/HUDHostWidget.h similarity index 53% rename from Project/Source/Gasa/UI/UI_HostWidget.h rename to Project/Source/Gasa/UI/HUDHostWidget.h index ca8dd31..7f50d82 100644 --- a/Project/Source/Gasa/UI/UI_HostWidget.h +++ b/Project/Source/Gasa/UI/HUDHostWidget.h @@ -2,10 +2,10 @@ #include "GasaUserWidget.h" -#include "UI_HostWidget.generated.h" +#include "HUDHostWidget.generated.h" UCLASS() -class GASA_API UUI_HostWidget : public UGasaUserWidget +class GASA_API UHUDHostWidget : public UGasaUserWidget { GENERATED_BODY() public: diff --git a/Project/Source/Gasa/UI/HostWIdgetController.cpp b/Project/Source/Gasa/UI/HostWIdgetController.cpp new file mode 100644 index 0000000..27f22a5 --- /dev/null +++ b/Project/Source/Gasa/UI/HostWIdgetController.cpp @@ -0,0 +1 @@ +#include "HostWidgetController.h" diff --git a/Project/Source/Gasa/UI/HostWidgetController.h b/Project/Source/Gasa/UI/HostWidgetController.h new file mode 100644 index 0000000..571711a --- /dev/null +++ b/Project/Source/Gasa/UI/HostWidgetController.h @@ -0,0 +1,12 @@ +#pragma once + +#include "WidgetController.h" + +#include "HostWidgetController.generated.h" + +UCLASS() +class GASA_API UHostWidgetController : public UWidgetController +{ + GENERATED_BODY() +public: +}; diff --git a/Project/Source/Gasa/UI/UI_HostWidget.cpp b/Project/Source/Gasa/UI/UI_HostWidget.cpp deleted file mode 100644 index 98d05ff..0000000 --- a/Project/Source/Gasa/UI/UI_HostWidget.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "UI_HostWidget.h" diff --git a/Project/Source/Gasa/UI/WidgetController.h b/Project/Source/Gasa/UI/WidgetController.h index fcddb47..8c678d4 100644 --- a/Project/Source/Gasa/UI/WidgetController.h +++ b/Project/Source/Gasa/UI/WidgetController.h @@ -3,17 +3,37 @@ #include "GasaCommon.h" #include "WidgetController.generated.h" -UCLASS(BlueprintType) -class GASA_API UWidgetController : public UObject +USTRUCT(BlueprintType) +struct GASA_API FWidgetControllerData { GENERATED_BODY() -public: + + FWidgetControllerData() = default; + + FWidgetControllerData(AGasaPlayerController* Controller + , AGasaPlayerState* PlayerState + , UAbilitySystemComponent* AbilitySystem + , UAttributeSet* Attributes ) +#if 1 + : Controller(Controller) + , PlayerState(PlayerState) + , AbilitySystem(AbilitySystem) + , Attributes(Attributes) +#endif + { +#if 0 + this->Controller = Controller; + this->PlayerState = PlayerState; + this->AbilitySystem = AbilitySystem; + this->Attributes = Attributes; +#endif + } + + UPROPERTY(BlueprintReadOnly, Category="Player") + TObjectPtr Controller; UPROPERTY(BlueprintReadOnly, Category="Player") - TObjectPtr Controller; - - UPROPERTY(BlueprintReadOnly, Category="Player") - TObjectPtr PlayerState; + TObjectPtr PlayerState; UPROPERTY(BlueprintReadOnly, Category="Player") TObjectPtr AbilitySystem; @@ -21,3 +41,13 @@ public: UPROPERTY(BlueprintReadOnly, Category="Player") TObjectPtr Attributes; }; + +UCLASS(Blueprintable) +class GASA_API UWidgetController : public UObject +{ + GENERATED_BODY() +public: + + UPROPERTY(BlueprintReadOnly, Category="Player") + FWidgetControllerData Data; +}; diff --git a/Project/Source/GasaGen/GasaGen.cpp b/Project/Source/GasaGen/GasaGen.cpp index 83b03c8..72ed2db 100644 --- a/Project/Source/GasaGen/GasaGen.cpp +++ b/Project/Source/GasaGen/GasaGen.cpp @@ -55,7 +55,7 @@ int gen_main() PreprocessorDefines.append( get_cached_string(str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL)); PreprocessorDefines.append( get_cached_string(str_ENUM_CLASS_FLAGS)); PreprocessorDefines.append( get_cached_string(str_FORCEINLINE_DEBUGGABLE)); - PreprocessorDefines.append( get_cached_string(str_FORCEINLINE)); + // PreprocessorDefines.append( get_cached_string(str_FORCEINLINE)); PreprocessorDefines.append( get_cached_string(str_GENERATED_BODY)); PreprocessorDefines.append( get_cached_string(str_GENERATED_UCLASS_BODY)); PreprocessorDefines.append( get_cached_string(str_GENERATED_USTRUCT_BODY)); diff --git a/Project/Source/GasaGen/GasaGenCommon.cpp b/Project/Source/GasaGen/GasaGenCommon.cpp index a606e06..cd87619 100644 --- a/Project/Source/GasaGen/GasaGenCommon.cpp +++ b/Project/Source/GasaGen/GasaGenCommon.cpp @@ -34,7 +34,7 @@ constexpr StrC str_DECLARE_MULTICAST_DELEGATE_TwoParams = txt(" constexpr StrC str_DEFINE_ACTORDESC_TYPE = txt("DEFINE_ACTORDESC_TYPE("); constexpr StrC str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL = txt("DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL("); constexpr StrC str_ENUM_CLASS_FLAGS = txt("ENUM_CLASS_FLAGS("); -constexpr StrC str_FORCEINLINE = txt("FORCEINLINE"); +// constexpr StrC str_FORCEINLINE = txt("FORCEINLINE"); constexpr StrC str_FORCEINLINE_DEBUGGABLE = txt("FORCEINLINE_DEBUGGABLE"); constexpr StrC str_GENERATED_BODY = txt("GENERATED_BODY("); constexpr StrC str_GENERATED_UCLASS_BODY = txt("GENERATED_UCLASS_BODY("); diff --git a/Project/Source/GasaGen/GasaGen_DevOptionsCache.cpp b/Project/Source/GasaGen/GasaGen_DevOptionsCache.cpp index f99c0c1..0574277 100644 --- a/Project/Source/GasaGen/GasaGen_DevOptionsCache.cpp +++ b/Project/Source/GasaGen/GasaGen_DevOptionsCache.cpp @@ -34,7 +34,7 @@ void gen_FGasaDevOptionsCache() } } - CodeComment generation_notice = def_comment(txt("This was generated by GasaGen/GasaGen.cpp")); + CodeComment generation_notice = def_comment(txt("Generated by GasaGen/GasaGen_DevOptionsCache.cpp")); Builder header = Builder::open( path_module_gasa "GasaDevOptionsCache.h" ); { @@ -107,13 +107,17 @@ void gen_FGasaDevOptionsCache() cached_property_assignments.append(fmt_newline); for (CodeVar var : GasaDevOptions_UPROPERTIES) { + #pragma push_macro("TEXT") + #undef TEXT Code assignment = code_fmt( "property", (StrC)var->Name, stringize( = DevOpts-> .LoadSynchronous(); + ensureMsgf( != nullptr, TEXT(" is null, DO NOT RUN PIE or else you may get a crash if not handled in BP or C++")); )); + #pragma pop_macro("TEXT") cached_property_assignments.append(assignment); + cached_property_assignments.append(fmt_newline); + cached_property_assignments.append(fmt_newline); } - cached_property_assignments.append(fmt_newline); - cached_property_assignments.append(fmt_newline); } CodeFn CachedDevOptions = parse_function( token_fmt( diff --git a/Project/Source/GasaGen/GasaGen_UGasaAttributeSet.cpp b/Project/Source/GasaGen/GasaGen_UGasaAttributeSet.cpp index c775a16..a6f2e70 100644 --- a/Project/Source/GasaGen/GasaGen_UGasaAttributeSet.cpp +++ b/Project/Source/GasaGen/GasaGen_UGasaAttributeSet.cpp @@ -7,18 +7,19 @@ #include "GasaGenCommon.cpp" #endif -void def_attribute_properties ( CodeBody body, Array properties ); -void def_attribute_field_on_reps ( CodeBody body, Array properties ); -void def_attribute_field_property_getters( CodeBody body, StrC class_name, Array properties ); -void def_attribute_field_value_getters ( CodeBody body, Array properties ); -void def_attribute_field_value_setters ( CodeBody body, Array properties ); -void def_attribute_field_initers ( CodeBody body, Array properties ); -void impl_attribute_fields ( CodeBody body, StrC class_name, Array properties ); +void def_attribute_properties ( CodeBody body, Array properties ); +void def_attribute_field_on_reps ( CodeBody body, Array properties ); +void def_attribute_field_property_getters ( CodeBody body, StrC class_name, Array properties ); +void def_attribute_field_value_getters ( CodeBody body, Array properties ); +void def_attribute_field_value_setters ( CodeBody body, Array properties ); +void def_attribute_field_property_setter_inlines( CodeBody body, StrC class_name, Array properties ); +void def_attribute_field_initers ( CodeBody body, Array properties ); +void impl_attribute_fields ( CodeBody body, StrC class_name, Array properties ); void gen_UGasaAttributeSet() { CodeType type_UAttributeSet = def_type( txt("UAttributeSet") ); - CodeComment generation_notice = def_comment(txt("This was generated by GasaGen/GasaGen.cpp")); + CodeComment generation_notice = def_comment(txt("Generated by GasaGen/GasaGen_UGasaAttributeSet.cpp")); Array attribute_fields = Array::init( GlobalAllocator); attribute_fields.append( get_cached_string(txt("Health"))); @@ -31,10 +32,10 @@ void gen_UGasaAttributeSet() Builder header = Builder::open( path_gasa_ability_system "GasaAttributeSet.h"); { header.print(generation_notice); + header.print(pragma_once); header.print(fmt_newline); { CodeInclude Include_AttributeSet = def_include(txt("AttributeSet.h")); - CodeInclude Include_AbilitySystemComponent = def_include(txt("AbilitySystemComponent.h")); CodeInclude Include_GasaAttributeSet_Generated = def_include(txt("GasaAttributeSet.generated.h")); CodeAttributes api_attribute= def_attributes( UModule_GASA_API->Name); @@ -59,12 +60,15 @@ void gen_UGasaAttributeSet() body.append( fmt_newline ); body.append( def_pragma(code( region Getters ))); def_attribute_field_property_getters( body, class_name, attribute_fields ); + body.append( fmt_newline ); def_attribute_field_value_getters( body, attribute_fields ); body.append( def_pragma(code( endregion Getters ))); body.append( fmt_newline ); body.append( def_pragma(code( region Setters ))); def_attribute_field_value_setters( body, attribute_fields ); + body.append( fmt_newline ); + body.append( fmt_newline ); def_attribute_field_initers( body, attribute_fields ); body.append( def_pragma(code( endregion Setters ))); body.append( fmt_newline ); @@ -82,34 +86,54 @@ void gen_UGasaAttributeSet() ); } - CodeNS ns_gasa = parse_namespace( code( - namespace Gasa - { - inline - UGasaAttributeSet const* GetAttributeSet( UAbilitySystemComponent* ASC ) - { - return Cast(ASC->GetAttributeSet( UGasaAttributeSet::StaticClass() )); - } - } - )); - header.print( Include_AttributeSet); - header.print( Include_AbilitySystemComponent); header.print( Include_GasaAttributeSet_Generated); header.print( fmt_newline); header.print( UHT_UCLASS ); header.print(GasaAttributeSet); - header.print(ns_gasa); } header.write(); format_file(path_gasa_ability_system "GasaAttributeSet.h"); } + Builder inlines = Builder::open( path_gasa_ability_system "GasaAttributeSet_Inlines.h"); + { + inlines.print(generation_notice); + inlines.print(pragma_once); + inlines.print(fmt_newline); + inlines.print( def_include( txt("GasaAttributeSet.h"))); + inlines.print( def_include(txt("AbilitySystemComponent.h"))); + inlines.print(fmt_newline); + + CodeBody body = def_body(CodeT::Global_Body); + { + def_attribute_field_property_setter_inlines( body, class_name, attribute_fields ); + } + inlines.print(body); + inlines.print(fmt_newline); + + CodeNS ns_gasa = parse_namespace( code( + namespace Gasa + { + inline + UGasaAttributeSet const* GetAttributeSet( UAbilitySystemComponent* ASC ) + { + return Cast(ASC->GetAttributeSet( UGasaAttributeSet::StaticClass() )); + } + } + )); + + inlines.print(ns_gasa); + inlines.write(); + format_file(path_gasa_ability_system "GasaAttributeSet_Inlines.h"); + } + Builder source = Builder::open( path_gasa_ability_system "GasaAttributeSet.cpp" ); { source.print(generation_notice); header.print(fmt_newline); source.print( def_include( txt("GasaAttributeSet.h"))); + source.print( def_include( txt("GasaAttributeSet_Inlines.h"))); source.print(fmt_newline); source.print( def_include( txt("AbilitySystemComponent.h"))); source.print( def_include( txt("Net/UnrealNetwork.h"))); @@ -231,18 +255,31 @@ void def_attribute_field_value_setters( CodeBody body, Array prope { body.append( code_fmt( "property", (StrC)property, stringize( - FORCEINLINE void Set(float NewVal) - { - UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent(); - if (ensure(AbilityComp)) - { - AbilityComp->SetNumericAttributeBase(GetAttribute(), NewVal); - }; - } + FORCEINLINE void Set(float NewVal); ))); } } +void def_attribute_field_property_setter_inlines( CodeBody body, StrC class_name, Array properties ) +{ + for ( String property : properties ) + { + CodeFn generated_get_attribute = parse_function( + token_fmt( "class_name", class_name, "property", (StrC)property, + stringize( + FORCEINLINE void ::Set(float NewVal) + { + UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent(); + if (ensure(AbilityComp)) + { + AbilityComp->SetNumericAttributeBase(GetAttribute(), NewVal); + }; + } + ))); + body.append( generated_get_attribute ); + } +} + void def_attribute_field_initers ( CodeBody body, Array properties ) { for ( String property : properties ) diff --git a/Project/Source/GasaGen/gen.cpp b/Project/Source/GasaGen/gen.cpp index 3d8187d..c1e185f 100644 --- a/Project/Source/GasaGen/gen.cpp +++ b/Project/Source/GasaGen/gen.cpp @@ -81,7 +81,7 @@ global CodeSpecifiers spec_constexpr; global CodeSpecifiers spec_constinit; global CodeSpecifiers spec_extern_linkage; global CodeSpecifiers spec_final; -global CodeSpecifiers spec_forceinline; +global CodeSpecifiers spec_FORCEINLINE; global CodeSpecifiers spec_global; global CodeSpecifiers spec_inline; global CodeSpecifiers spec_internal_linkage; @@ -2988,12 +2988,12 @@ internal void define_constants() spec_##Type_ = def_specifiers( num_args( __VA_ARGS__ ), __VA_ARGS__ ); \ spec_##Type_.set_global(); -#pragma push_macro( "forceinline" ) +#pragma push_macro( "FORCEINLINE" ) #pragma push_macro( "global" ) #pragma push_macro( "internal" ) #pragma push_macro( "local_persist" ) #pragma push_macro( "neverinline" ) -#undef forceinline +#undef FORCEINLINE #undef global #undef internal #undef local_persist @@ -3004,7 +3004,7 @@ internal void define_constants() def_constant_spec( constinit, ESpecifier::Constinit ); def_constant_spec( extern_linkage, ESpecifier::External_Linkage ); def_constant_spec( final, ESpecifier::Final ); - def_constant_spec( forceinline, ESpecifier::ForceInline ); + def_constant_spec( FORCEINLINE, ESpecifier::ForceInline ); def_constant_spec( global, ESpecifier::Global ); def_constant_spec( inline, ESpecifier::Inline ); def_constant_spec( internal_linkage, ESpecifier::Internal_Linkage ); @@ -3025,7 +3025,7 @@ internal void define_constants() spec_local_persist = def_specifiers( 1, ESpecifier::Local_Persist ); spec_local_persist.set_global(); -#pragma pop_macro( "forceinline" ) +#pragma pop_macro( "FORCEINLINE" ) #pragma pop_macro( "global" ) #pragma pop_macro( "internal" ) #pragma pop_macro( "local_persist" ) @@ -5840,7 +5840,7 @@ namespace parser { sizeof( "explicit" ), "explicit" }, { sizeof( "extern" ), "extern" }, { sizeof( "final" ), "final" }, - { sizeof( "forceinline" ), "forceinline" }, + { sizeof( "FORCEINLINE" ), "FORCEINLINE" }, { sizeof( "global" ), "global" }, { sizeof( "inline" ), "inline" }, { sizeof( "internal" ), "internal" }, @@ -6059,7 +6059,7 @@ namespace parser } }; - global Arena_128KB defines_map_arena; + global Arena_256KB defines_map_arena; global HashTable defines; global Array Tokens; @@ -6110,7 +6110,7 @@ namespace parser Lex_ReturnNull, }; - forceinline s32 lex_preprocessor_directive( StrC& content, s32& left, char const*& scanner, s32& line, s32& column, HashTable& defines, Token& token ) + FORCEINLINE s32 lex_preprocessor_directive( StrC& content, s32& left, char const*& scanner, s32& line, s32& column, HashTable& defines, Token& token ) { char const* hash = scanner; Tokens.append( { hash, 1, TokType::Preprocess_Hash, line, column, TF_Preprocess } ); @@ -6344,7 +6344,7 @@ namespace parser return Lex_Continue; // Skip found token, its all handled here. } - forceinline void lex_found_token( StrC& content, s32& left, char const*& scanner, s32& line, s32& column, HashTable& defines, Token& token ) + FORCEINLINE void lex_found_token( StrC& content, s32& left, char const*& scanner, s32& line, s32& column, HashTable& defines, Token& token ) { if ( token.Type != TokType::Invalid ) { @@ -7255,7 +7255,7 @@ namespace parser { Tokens = Array::init_reserve( LexArena, ( LexAllocator_Size - sizeof( Array::Header ) ) / sizeof( Token ) ); - defines_map_arena = Arena_128KB::init(); + defines_map_arena = Arena_256KB::init(); defines = HashTable::init( defines_map_arena ); } diff --git a/Project/Source/GasaGen/gen.dep.hpp b/Project/Source/GasaGen/gen.dep.hpp index 5de3ec6..a0423a5 100644 --- a/Project/Source/GasaGen/gen.dep.hpp +++ b/Project/Source/GasaGen/gen.dep.hpp @@ -145,21 +145,21 @@ GEN_NS_BEGIN #define local_persist static // Local Persisting variables #ifdef GEN_COMPILER_MSVC -#define forceinline __forceinline +#define FORCEINLINE __forceinline #define neverinline __declspec( noinline ) #elif defined( GEN_COMPILER_GCC ) -#define forceinline inline __attribute__( ( __always_inline__ ) ) +#define FORCEINLINE inline __attribute__( ( __always_inline__ ) ) #define neverinline __attribute__( ( __noinline__ ) ) #elif defined( GEN_COMPILER_CLANG ) #if __has_attribute( __always_inline__ ) -#define forceinline inline __attribute__( ( __always_inline__ ) ) +#define FORCEINLINE inline __attribute__( ( __always_inline__ ) ) #define neverinline __attribute__( ( __noinline__ ) ) #else -#define forceinline +#define FORCEINLINE #define neverinline #endif #else -#define forceinline +#define FORCEINLINE #define neverinline #endif diff --git a/Project/Source/GasaGen/gen.hpp b/Project/Source/GasaGen/gen.hpp index 2233962..34ef386 100644 --- a/Project/Source/GasaGen/gen.hpp +++ b/Project/Source/GasaGen/gen.hpp @@ -451,7 +451,7 @@ namespace ESpecifier { sizeof( "constinit" ), "constinit" }, { sizeof( "explicit" ), "explicit" }, { sizeof( "extern" ), "extern" }, - { sizeof( "forceinline" ), "forceinline" }, + { sizeof( "FORCEINLINE" ), "FORCEINLINE" }, { sizeof( "global" ), "global" }, { sizeof( "inline" ), "inline" }, { sizeof( "internal" ), "internal" }, @@ -671,7 +671,7 @@ struct Code Using_Code( Code ); template - forceinline Type cast() + FORCEINLINE Type cast() { return *rcast( Type*, this ); } @@ -761,7 +761,7 @@ struct AST neverinline void to_string( String& result ); template - forceinline Type cast() + FORCEINLINE Type cast() { return *this; } @@ -6397,7 +6397,7 @@ extern CodeSpecifiers spec_constexpr; extern CodeSpecifiers spec_constinit; extern CodeSpecifiers spec_extern_linkage; extern CodeSpecifiers spec_final; -extern CodeSpecifiers spec_forceinline; +extern CodeSpecifiers spec_FORCEINLINE; extern CodeSpecifiers spec_global; extern CodeSpecifiers spec_inline; extern CodeSpecifiers spec_internal_linkage;