31. Aura HUD (plus other stuff)
- Enabled a few more plugins - Added clang formatting straight from the GasaGen cpp. - Setup auto-generation of the DevOptionsCache - Messed around with generating widgettree hiearchy from template widget
This commit is contained in:
parent
466adc5bd9
commit
6765478a9d
43
.editorconfig
Normal file
43
.editorconfig
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
tab_width = 4
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
max_line_length = 150
|
||||||
|
|
||||||
|
# MSBuild
|
||||||
|
[*.{csproj,proj,projitems,shproj,fsproj,target,props}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
# XML config files
|
||||||
|
[*.{config,nuspec,resx,natvis}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.{h, c, hpp, cpp}]
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[*.{ps1, psm1}]
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
|
||||||
|
[*.{natvis, natstepfilter}]
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
# Settings for Verse source files
|
||||||
|
[*.{verse,versetest}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
tab_width = 4
|
||||||
|
max_line_length = off
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -26,3 +26,5 @@ Project/Binaries/GasaGen.map
|
|||||||
Project/Binaries/GasaGen.obj
|
Project/Binaries/GasaGen.obj
|
||||||
Project/Binaries/vc140.pdb
|
Project/Binaries/vc140.pdb
|
||||||
Project/Saved/Config/ConsoleHistory.ini
|
Project/Saved/Config/ConsoleHistory.ini
|
||||||
|
*.pdb
|
||||||
|
Project/Saved/Diff
|
||||||
|
19
.vscode/c_cpp_properties.json
vendored
Normal file
19
.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Win32",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/**"
|
||||||
|
],
|
||||||
|
"defines": [
|
||||||
|
"_DEBUG",
|
||||||
|
"UNICODE",
|
||||||
|
"_UNICODE",
|
||||||
|
"GASA_INTELLISENSE_DIRECTIVES=1"
|
||||||
|
],
|
||||||
|
"windowsSdkVersion": "10.0.22621.0",
|
||||||
|
"compilerPath": "cl.exe"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -10,7 +10,7 @@
|
|||||||
"name": "Debug GenGas vsdbg",
|
"name": "Debug GenGas vsdbg",
|
||||||
"program": "${workspaceFolder}/Project/Binaries/GasaGen.exe",
|
"program": "${workspaceFolder}/Project/Binaries/GasaGen.exe",
|
||||||
"args": [],
|
"args": [],
|
||||||
"cwd": "${workspaceFolder}/Project/",
|
"cwd": "${workspaceFolder}",
|
||||||
"visualizerFile": "${workspaceFolder}/scripts/gencpp.natvis"
|
"visualizerFile": "${workspaceFolder}/scripts/gencpp.natvis"
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -7,6 +7,9 @@ CopyrightNotice=
|
|||||||
[/Script/Gasa.GasaDevOptions]
|
[/Script/Gasa.GasaDevOptions]
|
||||||
Tag_PPV=Global_PPV
|
Tag_PPV=Global_PPV
|
||||||
Tag_GlobalPPV=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
|
||||||
|
|
||||||
[/Script/GameplayAbilities.AbilitySystemGlobals]
|
[/Script/GameplayAbilities.AbilitySystemGlobals]
|
||||||
bUseDebugTargetFromHud=true
|
bUseDebugTargetFromHud=true
|
||||||
|
|
||||||
|
@ -304,6 +304,46 @@
|
|||||||
{
|
{
|
||||||
"Name": "GitSourceControl",
|
"Name": "GitSourceControl",
|
||||||
"Enabled": true
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "SlateInsights",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "TraceUtilities",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "NetworkPredictionInsights",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "TraceSourceFilters",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "GameplayInsights",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "RenderGraphInsights",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "BlueprintStats",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "ColorCorrectRegions",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "ControlFlows",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "LiveUpdateForSlate",
|
||||||
|
"Enabled": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -33,9 +33,10 @@ void UGasaAttributeSet::Client_OnRep_MaxMana( FGameplayAttributeData& PrevMaxMan
|
|||||||
GAMEPLAYATTRIBUTE_REPNOTIFY( UGasaAttributeSet, MaxMana, PrevMaxMana )
|
GAMEPLAYATTRIBUTE_REPNOTIFY( UGasaAttributeSet, MaxMana, PrevMaxMana )
|
||||||
}
|
}
|
||||||
|
|
||||||
void UGasaAttributeSet::GetLifetimeReplicatedProps( TArray< FLifetimeProperty >& OutLifetimeProps ) const
|
void UGasaAttributeSet::GetLifetimeReplicatedProps( TArray<FLifetimeProperty>& OutLifetimeProps ) const
|
||||||
{
|
{
|
||||||
Super::GetLifetimeReplicatedProps( OutLifetimeProps );
|
Super::GetLifetimeReplicatedProps( OutLifetimeProps );
|
||||||
|
|
||||||
DOREPLIFETIME_DEFAULT_GAS( UGasaAttributeSet, Health );
|
DOREPLIFETIME_DEFAULT_GAS( UGasaAttributeSet, Health );
|
||||||
DOREPLIFETIME_DEFAULT_GAS( UGasaAttributeSet, MaxHealth );
|
DOREPLIFETIME_DEFAULT_GAS( UGasaAttributeSet, MaxHealth );
|
||||||
DOREPLIFETIME_DEFAULT_GAS( UGasaAttributeSet, Mana );
|
DOREPLIFETIME_DEFAULT_GAS( UGasaAttributeSet, Mana );
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
#include "AbilitySystemComponent.h"
|
#include "AbilitySystemComponent.h"
|
||||||
#include "GasaAttributeSet.generated.h"
|
#include "GasaAttributeSet.generated.h"
|
||||||
|
|
||||||
UCLASS() class GASA_API UGasaAttributeSet : public UAttributeSet
|
UCLASS()
|
||||||
|
class GASA_API UGasaAttributeSet : public UAttributeSet
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
public:
|
public:
|
||||||
@ -21,6 +22,7 @@ public:
|
|||||||
FGameplayAttributeData MaxMana;
|
FGameplayAttributeData MaxMana;
|
||||||
|
|
||||||
UGasaAttributeSet();
|
UGasaAttributeSet();
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void Client_OnRep_Health( FGameplayAttributeData& PrevHealth );
|
void Client_OnRep_Health( FGameplayAttributeData& PrevHealth );
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
@ -31,55 +33,35 @@ public:
|
|||||||
void Client_OnRep_MaxMana( FGameplayAttributeData& PrevMaxMana );
|
void Client_OnRep_MaxMana( FGameplayAttributeData& PrevMaxMana );
|
||||||
|
|
||||||
#pragma region Getters
|
#pragma region Getters
|
||||||
|
|
||||||
static FGameplayAttribute GetHealthAttribute()
|
static FGameplayAttribute GetHealthAttribute()
|
||||||
{
|
{
|
||||||
static FProperty* Prop = FindFieldChecked< FProperty >( UGasaAttributeSet::StaticClass(), GET_MEMBER_NAME_CHECKED( UGasaAttributeSet, Health ) );
|
static FProperty* Prop = FindFieldChecked<FProperty>( UGasaAttributeSet::StaticClass(), GET_MEMBER_NAME_CHECKED( UGasaAttributeSet, Health ) );
|
||||||
return Prop;
|
return Prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FGameplayAttribute GetMaxHealthAttribute()
|
static FGameplayAttribute GetMaxHealthAttribute()
|
||||||
{
|
{
|
||||||
static FProperty* Prop = FindFieldChecked< FProperty >( UGasaAttributeSet::StaticClass(), GET_MEMBER_NAME_CHECKED( UGasaAttributeSet, MaxHealth ) );
|
static FProperty* Prop = FindFieldChecked<FProperty>( UGasaAttributeSet::StaticClass(), GET_MEMBER_NAME_CHECKED( UGasaAttributeSet, MaxHealth ) );
|
||||||
return Prop;
|
return Prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FGameplayAttribute GetManaAttribute()
|
static FGameplayAttribute GetManaAttribute()
|
||||||
{
|
{
|
||||||
static FProperty* Prop = FindFieldChecked< FProperty >( UGasaAttributeSet::StaticClass(), GET_MEMBER_NAME_CHECKED( UGasaAttributeSet, Mana ) );
|
static FProperty* Prop = FindFieldChecked<FProperty>( UGasaAttributeSet::StaticClass(), GET_MEMBER_NAME_CHECKED( UGasaAttributeSet, Mana ) );
|
||||||
return Prop;
|
return Prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FGameplayAttribute GetMaxManaAttribute()
|
static FGameplayAttribute GetMaxManaAttribute()
|
||||||
{
|
{
|
||||||
static FProperty* Prop = FindFieldChecked< FProperty >( UGasaAttributeSet::StaticClass(), GET_MEMBER_NAME_CHECKED( UGasaAttributeSet, MaxMana ) );
|
static FProperty* Prop = FindFieldChecked<FProperty>( UGasaAttributeSet::StaticClass(), GET_MEMBER_NAME_CHECKED( UGasaAttributeSet, MaxMana ) );
|
||||||
return Prop;
|
return Prop;
|
||||||
}
|
}
|
||||||
|
FORCEINLINE float GetHealth() const { return Health.GetCurrentValue(); }
|
||||||
FORCEINLINE float GetHealth() const
|
FORCEINLINE float GetMaxHealth() const { return MaxHealth.GetCurrentValue(); }
|
||||||
{
|
FORCEINLINE float GetMana() const { return Mana.GetCurrentValue(); }
|
||||||
return Health.GetCurrentValue();
|
FORCEINLINE float GetMaxMana() const { return MaxMana.GetCurrentValue(); }
|
||||||
}
|
#pragma endregion Getters
|
||||||
|
|
||||||
FORCEINLINE float GetMaxHealth() const
|
|
||||||
{
|
|
||||||
return MaxHealth.GetCurrentValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCEINLINE float GetMana() const
|
|
||||||
{
|
|
||||||
return Mana.GetCurrentValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCEINLINE float GetMaxMana() const
|
|
||||||
{
|
|
||||||
return MaxMana.GetCurrentValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma endregion Getters
|
|
||||||
|
|
||||||
#pragma region Setters
|
#pragma region Setters
|
||||||
FORCEINLINE void SetHealth( float NewVal )
|
FORCEINLINE void
|
||||||
|
SetHealth( float NewVal )
|
||||||
{
|
{
|
||||||
UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent();
|
UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent();
|
||||||
if ( ensure( AbilityComp ) )
|
if ( ensure( AbilityComp ) )
|
||||||
@ -87,7 +69,6 @@ public:
|
|||||||
AbilityComp->SetNumericAttributeBase( GetHealthAttribute(), NewVal );
|
AbilityComp->SetNumericAttributeBase( GetHealthAttribute(), NewVal );
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCEINLINE void SetMaxHealth( float NewVal )
|
FORCEINLINE void SetMaxHealth( float NewVal )
|
||||||
{
|
{
|
||||||
UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent();
|
UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent();
|
||||||
@ -96,7 +77,6 @@ public:
|
|||||||
AbilityComp->SetNumericAttributeBase( GetMaxHealthAttribute(), NewVal );
|
AbilityComp->SetNumericAttributeBase( GetMaxHealthAttribute(), NewVal );
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCEINLINE void SetMana( float NewVal )
|
FORCEINLINE void SetMana( float NewVal )
|
||||||
{
|
{
|
||||||
UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent();
|
UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent();
|
||||||
@ -105,7 +85,6 @@ public:
|
|||||||
AbilityComp->SetNumericAttributeBase( GetManaAttribute(), NewVal );
|
AbilityComp->SetNumericAttributeBase( GetManaAttribute(), NewVal );
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCEINLINE void SetMaxMana( float NewVal )
|
FORCEINLINE void SetMaxMana( float NewVal )
|
||||||
{
|
{
|
||||||
UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent();
|
UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent();
|
||||||
@ -114,44 +93,39 @@ public:
|
|||||||
AbilityComp->SetNumericAttributeBase( GetMaxManaAttribute(), NewVal );
|
AbilityComp->SetNumericAttributeBase( GetMaxManaAttribute(), NewVal );
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCEINLINE void InitHealth( float NewVal )
|
FORCEINLINE void InitHealth( float NewVal )
|
||||||
{
|
{
|
||||||
Health.SetBaseValue( NewVal );
|
Health.SetBaseValue( NewVal );
|
||||||
Health.SetCurrentValue( NewVal );
|
Health.SetCurrentValue( NewVal );
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCEINLINE void InitMaxHealth( float NewVal )
|
FORCEINLINE void InitMaxHealth( float NewVal )
|
||||||
{
|
{
|
||||||
MaxHealth.SetBaseValue( NewVal );
|
MaxHealth.SetBaseValue( NewVal );
|
||||||
MaxHealth.SetCurrentValue( NewVal );
|
MaxHealth.SetCurrentValue( NewVal );
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCEINLINE void InitMana( float NewVal )
|
FORCEINLINE void InitMana( float NewVal )
|
||||||
{
|
{
|
||||||
Mana.SetBaseValue( NewVal );
|
Mana.SetBaseValue( NewVal );
|
||||||
Mana.SetCurrentValue( NewVal );
|
Mana.SetCurrentValue( NewVal );
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCEINLINE void InitMaxMana( float NewVal )
|
FORCEINLINE void InitMaxMana( float NewVal )
|
||||||
{
|
{
|
||||||
MaxMana.SetBaseValue( NewVal );
|
MaxMana.SetBaseValue( NewVal );
|
||||||
MaxMana.SetCurrentValue( NewVal );
|
MaxMana.SetCurrentValue( NewVal );
|
||||||
}
|
}
|
||||||
|
#pragma endregion Setters
|
||||||
#pragma endregion Setters
|
|
||||||
|
|
||||||
#pragma region UObject
|
#pragma region UObject
|
||||||
|
|
||||||
void GetLifetimeReplicatedProps( TArray< FLifetimeProperty >& OutLifetimeProps ) const override;
|
void
|
||||||
|
GetLifetimeReplicatedProps( TArray<FLifetimeProperty>& OutLifetimeProps ) const override;
|
||||||
#pragma endregion UObject
|
#pragma endregion UObject
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Gasa
|
namespace Gasa
|
||||||
{
|
{
|
||||||
inline UGasaAttributeSet const* GetAttributeSet( UAbilitySystemComponent* ASC )
|
inline UGasaAttributeSet const* GetAttributeSet( UAbilitySystemComponent* ASC )
|
||||||
{
|
{
|
||||||
return Cast< UGasaAttributeSet >( ASC->GetAttributeSet( UGasaAttributeSet::StaticClass() ) );
|
return Cast<UGasaAttributeSet>( ASC->GetAttributeSet( UGasaAttributeSet::StaticClass() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "Engine/LocalPlayer.h"
|
#include "Engine/LocalPlayer.h"
|
||||||
#include "EnhancedInputComponent.h"
|
#include "EnhancedInputComponent.h"
|
||||||
#include "EnhancedInputSubsystems.h"
|
#include "EnhancedInputSubsystems.h"
|
||||||
|
#include "GasaDevOptions.h"
|
||||||
#include "GasaPlayerState.h"
|
#include "GasaPlayerState.h"
|
||||||
#include "Actors/CameraMount.h"
|
#include "Actors/CameraMount.h"
|
||||||
#include "Camera/CameraComponent.h"
|
#include "Camera/CameraComponent.h"
|
||||||
@ -12,6 +13,8 @@
|
|||||||
#include "GameFramework/SpringArmComponent.h"
|
#include "GameFramework/SpringArmComponent.h"
|
||||||
#include "Kismet/KismetSystemLibrary.h"
|
#include "Kismet/KismetSystemLibrary.h"
|
||||||
|
|
||||||
|
using namespace Gasa;
|
||||||
|
|
||||||
AGasaPlayerController::AGasaPlayerController()
|
AGasaPlayerController::AGasaPlayerController()
|
||||||
{
|
{
|
||||||
PrimaryActorTick.bCanEverTick = true;
|
PrimaryActorTick.bCanEverTick = true;
|
||||||
@ -21,11 +24,14 @@ AGasaPlayerController::AGasaPlayerController()
|
|||||||
bReplicates = true;
|
bReplicates = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma region Input
|
||||||
void AGasaPlayerController::Move(FInputActionValue const& ActionValue)
|
void AGasaPlayerController::Move(FInputActionValue const& ActionValue)
|
||||||
{
|
{
|
||||||
APawn* pawn = GetPawn<APawn>();
|
APawn* pawn = GetPawn<APawn>();
|
||||||
if (pawn == nullptr )
|
if (pawn == nullptr )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Note(Ed): I did the follow optimization for practice, they are completely unnecessary for this context.
|
// Note(Ed): I did the follow optimization for practice, they are completely unnecessary for this context.
|
||||||
#if 0
|
#if 0
|
||||||
@ -63,6 +69,13 @@ void AGasaPlayerController::Move(FInputActionValue const& ActionValue)
|
|||||||
pawn->AddMovementInput( MoveDir );
|
pawn->AddMovementInput( MoveDir );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#pragma endregion Input
|
||||||
|
|
||||||
|
#pragma region PlayerController
|
||||||
|
void AGasaPlayerController::SpawnDefaultHUD()
|
||||||
|
{
|
||||||
|
Super::SpawnDefaultHUD();
|
||||||
|
}
|
||||||
|
|
||||||
void AGasaPlayerController::OnPossess(APawn* InPawn)
|
void AGasaPlayerController::OnPossess(APawn* InPawn)
|
||||||
{
|
{
|
||||||
@ -86,7 +99,6 @@ void AGasaPlayerController::OnUnPossess()
|
|||||||
Super::OnUnPossess();
|
Super::OnUnPossess();
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma region PlayerController
|
|
||||||
void AGasaPlayerController::PlayerTick(float DeltaTime)
|
void AGasaPlayerController::PlayerTick(float DeltaTime)
|
||||||
{
|
{
|
||||||
Super::PlayerTick(DeltaTime);
|
Super::PlayerTick(DeltaTime);
|
||||||
@ -162,7 +174,7 @@ void AGasaPlayerController::PostInitializeComponents()
|
|||||||
{
|
{
|
||||||
Super::PostInitializeComponents();
|
Super::PostInitializeComponents();
|
||||||
|
|
||||||
Cam = GetWorld()->SpawnActor<ACameraMount>(CamClass, FActorSpawnParameters() );
|
Cam = GetWorld()->SpawnActor<ACameraMount>(GetDevOptions()->Template_PlayerCamera.Get(), FActorSpawnParameters() );
|
||||||
SetViewTarget(Cam);
|
SetViewTarget(Cam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,9 +12,6 @@ class GASA_API AGasaPlayerController : public APlayerController
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
public:
|
public:
|
||||||
#pragma region Camera
|
#pragma region Camera
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
||||||
TSubclassOf<ACameraMount> CamClass;
|
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
TObjectPtr<ACameraMount> Cam;
|
TObjectPtr<ACameraMount> Cam;
|
||||||
#pragma endregion Camera
|
#pragma endregion Camera
|
||||||
@ -60,6 +57,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#pragma region PlayerController
|
#pragma region PlayerController
|
||||||
|
void SpawnDefaultHUD() override;
|
||||||
|
|
||||||
void OnPossess(APawn* InPawn) override;
|
void OnPossess(APawn* InPawn) override;
|
||||||
|
|
||||||
void OnUnPossess() override;
|
void OnUnPossess() override;
|
||||||
|
1
Project/Source/Gasa/Game/GasaViewport.cpp
Normal file
1
Project/Source/Gasa/Game/GasaViewport.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "GasaViewport.h"
|
12
Project/Source/Gasa/Game/GasaViewport.h
Normal file
12
Project/Source/Gasa/Game/GasaViewport.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Engine/GameViewportClient.h"
|
||||||
|
|
||||||
|
#include "GasaViewport.generated.h"
|
||||||
|
|
||||||
|
UCLASS()
|
||||||
|
class GASA_API UGasaViewport : public UGameViewportClient
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
public:
|
||||||
|
};
|
@ -33,9 +33,17 @@ public class Gasa : ModuleRules
|
|||||||
"NetCore",
|
"NetCore",
|
||||||
"Niagara",
|
"Niagara",
|
||||||
"SlateCore",
|
"SlateCore",
|
||||||
"UMG",
|
"UMG",
|
||||||
});
|
});
|
||||||
#endregion Engine
|
|
||||||
|
if (Target.bBuildEditor)
|
||||||
|
{
|
||||||
|
PrivateDependencyModuleNames.AddRange( new string[] {
|
||||||
|
"UnrealEd",
|
||||||
|
"UMGEditor",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
#endregion Engine
|
||||||
|
|
||||||
#region Plugins
|
#region Plugins
|
||||||
if (Target.Configuration != UnrealTargetConfiguration.Shipping && Target.Type != TargetRules.TargetType.Server)
|
if (Target.Configuration != UnrealTargetConfiguration.Shipping && Target.Type != TargetRules.TargetType.Server)
|
||||||
@ -66,5 +74,6 @@ public class Gasa : ModuleRules
|
|||||||
#endregion Plugins
|
#endregion Plugins
|
||||||
|
|
||||||
PublicIncludePaths.Add("Gasa");
|
PublicIncludePaths.Add("Gasa");
|
||||||
|
PublicIncludePathModuleNames.Add("Gasa");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ class UGasaImage;
|
|||||||
class UGasaOverlay;
|
class UGasaOverlay;
|
||||||
class UGasaProgressBar;
|
class UGasaProgressBar;
|
||||||
class UGasaSizeBox;
|
class UGasaSizeBox;
|
||||||
|
class UUI_HostWidget;
|
||||||
#pragma endregion Forwards
|
#pragma endregion Forwards
|
||||||
|
|
||||||
#pragma region Logging
|
#pragma region Logging
|
||||||
@ -98,7 +99,7 @@ DECLARE_LOG_CATEGORY_EXTERN(LogGasa, Log, All);
|
|||||||
namespace Gasa
|
namespace Gasa
|
||||||
{
|
{
|
||||||
using ELogV = EGasaVerbosity;
|
using ELogV = EGasaVerbosity;
|
||||||
|
|
||||||
//◞ ‸ ◟//
|
//◞ ‸ ◟//
|
||||||
// Works for Unreal 5.4, Win64 MSVC (untested in other scenarios, for now)
|
// Works for Unreal 5.4, Win64 MSVC (untested in other scenarios, for now)
|
||||||
inline
|
inline
|
||||||
@ -111,7 +112,7 @@ namespace Gasa
|
|||||||
{
|
{
|
||||||
#if !UE_BUILD_SHIPPING && !NO_LOGGING
|
#if !UE_BUILD_SHIPPING && !NO_LOGGING
|
||||||
ELogVerbosity::Type EngineVerbosity = (ELogVerbosity::Type) Verbosity;
|
ELogVerbosity::Type EngineVerbosity = (ELogVerbosity::Type) Verbosity;
|
||||||
|
|
||||||
static UE::Logging::Private::FStaticBasicLogDynamicData LOG_Dynamic;
|
static UE::Logging::Private::FStaticBasicLogDynamicData LOG_Dynamic;
|
||||||
static UE::Logging::Private::FStaticBasicLogRecord
|
static UE::Logging::Private::FStaticBasicLogRecord
|
||||||
LOG_Static(TEXT("%s -- %hs %hs(%d)"), File, Line, EngineVerbosity, LOG_Dynamic);
|
LOG_Static(TEXT("%s -- %hs %hs(%d)"), File, Line, EngineVerbosity, LOG_Dynamic);
|
||||||
@ -132,13 +133,13 @@ namespace Gasa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GASA_Fatal(Message) UE_LOG( Gasa, Fatal, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_FILE(), __func__, __builtin_LINE() );
|
#define GASA_Fatal(Message) UE_LOG( LogGasa, Fatal, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_FILE(), __func__, __builtin_LINE() );
|
||||||
#define GASA_Error(Message) UE_LOG( Gasa, Error, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() );
|
#define GASA_Error(Message) UE_LOG( LogGasa, Error, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() );
|
||||||
#define GASA_Warning(Message) UE_LOG( Gasa, Warning, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() );
|
#define GASA_Warning(Message) UE_LOG( LogGasa, Warning, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() );
|
||||||
#define GASA_Display(Message) UE_LOG( Gasa, Display, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() );
|
#define GASA_Display(Message) UE_LOG( LogGasa, Display, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() );
|
||||||
#define GASA_Log(Message) UE_LOG( Gasa, Log, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() );
|
#define GASA_Log(Message) UE_LOG( LogGasa, Log, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() );
|
||||||
#define GASA_Verbose(Message) UE_LOG( Gasa, Verbose, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() );
|
#define GASA_Verbose(Message) UE_LOG( LogGasa, Verbose, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() );
|
||||||
#define GASA_VeryVerbose(Message) UE_LOG( Gasa, VeryVerbose, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() );
|
#define GASA_VeryVerbose(Message) UE_LOG( LogGasa, VeryVerbose, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() );
|
||||||
#pragma endregion Logging
|
#pragma endregion Logging
|
||||||
|
|
||||||
#pragma region Timing
|
#pragma region Timing
|
||||||
@ -154,8 +155,8 @@ namespace Gasa
|
|||||||
constexpr float _80Hz = .013f;
|
constexpr float _80Hz = .013f;
|
||||||
constexpr float _90Hz = .011f;
|
constexpr float _90Hz = .011f;
|
||||||
constexpr float _100Hz = .010f;
|
constexpr float _100Hz = .010f;
|
||||||
constexpr float _120Hz = .083f;
|
constexpr float _120Hz = .008f;
|
||||||
constexpr float _240Hz = .004f;
|
constexpr float _240Hz = .004f;
|
||||||
constexpr float _480Hz = .002f;
|
constexpr float _480Hz = .002f;
|
||||||
}
|
}
|
||||||
#pragma endregion Timing
|
#pragma endregion Timing
|
||||||
|
@ -1,18 +1,11 @@
|
|||||||
#include "GasaDevOptions.h"
|
#include "GasaDevOptions.h"
|
||||||
|
|
||||||
#include "GasaDevOptionsCache.h"
|
#include "Actors/CameraMount.h"
|
||||||
|
#include "UI/UI_HostWidget.h"
|
||||||
|
|
||||||
|
using namespace Gasa;
|
||||||
|
|
||||||
namespace Gasa
|
namespace Gasa
|
||||||
{
|
{
|
||||||
global FName Tag_GlobalPPV;
|
global FName Tag_GlobalPPV;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGasaDevOptionsCache::CachedDevOptions()
|
|
||||||
{
|
|
||||||
using namespace Gasa;
|
|
||||||
|
|
||||||
UGasaDevOptions const* DevOs = GetDevOptions();
|
|
||||||
Tag_GlobalPPV = DevOs->Tag_GlobalPPV;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Engine/DeveloperSettings.h"
|
#include "Engine/DeveloperSettings.h"
|
||||||
|
|
||||||
|
#include "GasaCommon.h"
|
||||||
|
|
||||||
#include "GasaDevOptions.generated.h"
|
#include "GasaDevOptions.generated.h"
|
||||||
|
|
||||||
UCLASS(Config=Game, DefaultConfig, meta=(DisplayName="Gasa"))
|
UCLASS(Config=Game, DefaultConfig, meta=(DisplayName="Gasa"))
|
||||||
@ -9,6 +11,16 @@ class GASA_API UGasaDevOptions : public UDeveloperSettings
|
|||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
// NOTE(Ed): Any Soft-References must have their includes defined in GasaDevOptions.cpp
|
||||||
|
// They are used by GasaGen for the GasaDevOptionsCache
|
||||||
|
|
||||||
|
UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category="UI")
|
||||||
|
TSoftClassPtr<ACameraMount> Template_PlayerCamera;
|
||||||
|
|
||||||
|
UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category="UI")
|
||||||
|
TSoftClassPtr<UUI_HostWidget> Template_HUD_HostUI;
|
||||||
|
|
||||||
UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category="Tags")
|
UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category="Tags")
|
||||||
FName Tag_GlobalPPV;
|
FName Tag_GlobalPPV;
|
||||||
};
|
};
|
||||||
@ -19,11 +31,11 @@ namespace Gasa
|
|||||||
|
|
||||||
FORCEINLINE
|
FORCEINLINE
|
||||||
UGasaDevOptions const* GetDevOptions() {
|
UGasaDevOptions const* GetDevOptions() {
|
||||||
return GetDefault<UGasaDevOptions>();
|
return GetDefault<UGasaDevOptions>();
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCEINLINE
|
FORCEINLINE
|
||||||
UGasaDevOptions* GetMutDevOptions() {
|
UGasaDevOptions* GetMutDevOptions() {
|
||||||
return GetMutableDefault<UGasaDevOptions>();
|
return GetMutableDefault<UGasaDevOptions>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
17
Project/Source/Gasa/GasaDevOptionsCache.cpp
Normal file
17
Project/Source/Gasa/GasaDevOptionsCache.cpp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// This was generated by GasaGen/GasaGen.cpp
|
||||||
|
#include "GasaDevOptionsCache.h"
|
||||||
|
|
||||||
|
#include "GasaDevOptions.h"
|
||||||
|
#include "Actors/CameraMount.h"
|
||||||
|
#include "UI/UI_HostWidget.h"
|
||||||
|
using namespace Gasa;
|
||||||
|
|
||||||
|
void FGasaDevOptionsCache::CachedDevOptions()
|
||||||
|
{
|
||||||
|
UGasaDevOptions* DevOpts = GetMutDevOptions();
|
||||||
|
|
||||||
|
Template_PlayerCamera = DevOpts->Template_PlayerCamera.LoadSynchronous();
|
||||||
|
Template_HUD_HostUI = DevOpts->Template_HUD_HostUI.LoadSynchronous();
|
||||||
|
|
||||||
|
Tag_GlobalPPV = DevOpts->Tag_GlobalPPV;
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
// This was generated by GasaGen/GasaGen.cpp
|
||||||
|
#pragma once
|
||||||
#include "GasaCommon.h"
|
|
||||||
|
|
||||||
#include "GasaDevOptionsCache.generated.h"
|
#include "GasaDevOptionsCache.generated.h"
|
||||||
|
|
||||||
@ -8,6 +7,11 @@ USTRUCT()
|
|||||||
struct GASA_API FGasaDevOptionsCache
|
struct GASA_API FGasaDevOptionsCache
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
UClass* Template_PlayerCamera;
|
||||||
|
UPROPERTY()
|
||||||
|
UClass* Template_HUD_HostUI;
|
||||||
|
|
||||||
void CachedDevOptions();
|
void CachedDevOptions();
|
||||||
};
|
};
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "Blueprint/GameViewportSubsystem.h"
|
#include "Blueprint/GameViewportSubsystem.h"
|
||||||
|
|
||||||
#include "GasaViewport.generated.h"
|
#include "GasaViewportSubsystem.generated.h"
|
||||||
|
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class GASA_API UGasaViewportSubsystem : public UGameViewportSubsystem
|
class GASA_API UGasaViewportSubsystem : public UGameViewportSubsystem
|
||||||
@ -12,4 +12,4 @@ public:
|
|||||||
// UGasaViewportSubsystem();
|
// UGasaViewportSubsystem();
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
@ -1,9 +0,0 @@
|
|||||||
// Don't keep this included anywhere
|
|
||||||
// Purely for inspection purposes
|
|
||||||
|
|
||||||
#include "GasaCommon.h"
|
|
||||||
|
|
||||||
void test()
|
|
||||||
{
|
|
||||||
UObject::StaticClass()->PropertiesSize
|
|
||||||
}
|
|
1
Project/Source/Gasa/UI/GasaCanvas.cpp
Normal file
1
Project/Source/Gasa/UI/GasaCanvas.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "GasaCanvas.h"
|
12
Project/Source/Gasa/UI/GasaCanvas.h
Normal file
12
Project/Source/Gasa/UI/GasaCanvas.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Engine/Canvas.h"
|
||||||
|
|
||||||
|
#include "GasaCanvas.generated.h"
|
||||||
|
|
||||||
|
UCLASS()
|
||||||
|
class GASA_API UGasaCanvas : public UCanvas
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
public:
|
||||||
|
};
|
1
Project/Source/Gasa/UI/GasaCanvasPanel.cpp
Normal file
1
Project/Source/Gasa/UI/GasaCanvasPanel.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "GasaCanvasPanel.h"
|
12
Project/Source/Gasa/UI/GasaCanvasPanel.h
Normal file
12
Project/Source/Gasa/UI/GasaCanvasPanel.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Components/CanvasPanel.h"
|
||||||
|
|
||||||
|
#include "GasaCanvasPanel.generated.h"
|
||||||
|
|
||||||
|
UCLASS()
|
||||||
|
class GASA_API UGasaCanvasPanel : public UCanvasPanel
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
public:
|
||||||
|
};
|
31
Project/Source/Gasa/UI/GasaHUD.cpp
Normal file
31
Project/Source/Gasa/UI/GasaHUD.cpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#include "GasaHUD.h"
|
||||||
|
|
||||||
|
#include "GasaDevOptions.h"
|
||||||
|
#include "UI_HostWidget.h"
|
||||||
|
#include "Blueprint/UserWidget.h"
|
||||||
|
|
||||||
|
using namespace Gasa;
|
||||||
|
|
||||||
|
|
||||||
|
#pragma region HUD
|
||||||
|
void AGasaHUD::ShowHUD()
|
||||||
|
{
|
||||||
|
Super::ShowHUD();
|
||||||
|
}
|
||||||
|
#pragma endregion HUD
|
||||||
|
|
||||||
|
#pragma region Actor
|
||||||
|
UE_DISABLE_OPTIMIZATION
|
||||||
|
void AGasaHUD::BeginPlay()
|
||||||
|
{
|
||||||
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
HostWidget = CreateWidget<UUI_HostWidget>( 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
|
25
Project/Source/Gasa/UI/GasaHUD.h
Normal file
25
Project/Source/Gasa/UI/GasaHUD.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GasaCommon.h"
|
||||||
|
#include "GameFramework/HUD.h"
|
||||||
|
|
||||||
|
#include "GasaHUD.generated.h"
|
||||||
|
|
||||||
|
|
||||||
|
UCLASS()
|
||||||
|
class GASA_API AGasaHUD : public AHUD
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
public:
|
||||||
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
|
||||||
|
TObjectPtr<UUI_HostWidget> HostWidget;
|
||||||
|
|
||||||
|
#pragma region HUD
|
||||||
|
void ShowHUD() override;
|
||||||
|
#pragma endregion HUD
|
||||||
|
|
||||||
|
#pragma region Actor
|
||||||
|
void BeginPlay() override;
|
||||||
|
|
||||||
|
#pragma endregion Actor
|
||||||
|
};
|
22
Project/Source/Gasa/UI/GasaProgressBar.cpp
Normal file
22
Project/Source/Gasa/UI/GasaProgressBar.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include "GasaProgressBar.h"
|
||||||
|
|
||||||
|
#include "GasaCommon.h"
|
||||||
|
|
||||||
|
using namespace Gasa;
|
||||||
|
|
||||||
|
#pragma region Object
|
||||||
|
void UGasaProgressBar::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
|
||||||
|
{
|
||||||
|
Super::PostEditChangeProperty(PropertyChangedEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UGasaProgressBar::Serialize(FArchive& Ar)
|
||||||
|
{
|
||||||
|
Super::Serialize(Ar);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UGasaProgressBar::Serialize(FStructuredArchive::FRecord Record)
|
||||||
|
{
|
||||||
|
Super::Serialize(Record);
|
||||||
|
}
|
||||||
|
#pragma endregion Object
|
@ -10,4 +10,10 @@ class GASA_API UGasaProgressBar : public UProgressBar
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
#pragma region Object
|
||||||
|
void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
|
||||||
|
|
||||||
|
void Serialize(FArchive& Ar) override;
|
||||||
|
void Serialize(FStructuredArchive::FRecord Record) override;
|
||||||
|
#pragma endregion Object
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,310 @@
|
|||||||
#include "GasaUserWidget.h"
|
#include "GasaUserWidget.h"
|
||||||
|
|
||||||
|
#include "Blueprint/WidgetBlueprintGeneratedClass.h"
|
||||||
|
#include "Blueprint/WidgetTree.h"
|
||||||
|
#include "Components/HorizontalBoxSlot.h"
|
||||||
|
#include "Components/Overlay.h"
|
||||||
|
#include "Components/OverlaySlot.h"
|
||||||
|
#include "Components/ScaleBoxSlot.h"
|
||||||
|
#include "Components/ScrollBoxSlot.h"
|
||||||
|
#include "Components/SizeBoxSlot.h"
|
||||||
|
#include "Components/VerticalBoxSlot.h"
|
||||||
|
|
||||||
|
#if WITH_EDITOR
|
||||||
|
#include "WidgetBlueprint.h"
|
||||||
|
#include "Kismet2/BlueprintEditorUtils.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
UWidget* UMyModalDialog::DeepDuplicateWidget(UWidget *pUWidget)
|
||||||
|
{
|
||||||
|
UWidget *pNewWidget = DuplicateObject<UWidget>(pUWidget, this);
|
||||||
|
UPanelWidget *pNewUPanelWidget = Cast<UPanelWidget>(pNewWidget);
|
||||||
|
if (pNewUPanelWidget)
|
||||||
|
{
|
||||||
|
const TArray<UPanelSlot*>& slots = pNewUPanelWidget->GetSlots();
|
||||||
|
for (int32 iSlotNum = 0; iSlotNum < slots.Num(); ++iSlotNum)
|
||||||
|
{
|
||||||
|
slots[iSlotNum]->Content = nullptr;
|
||||||
|
}
|
||||||
|
pNewUPanelWidget->ClearChildren();
|
||||||
|
UPanelWidget *pUPanelWidget = Cast<UPanelWidget>(pUWidget);
|
||||||
|
for (int ii = 0; ii < pUPanelWidget->GetChildrenCount(); ++ii)
|
||||||
|
{
|
||||||
|
UWidget *pChildUWidget = pUPanelWidget->GetChildAt(ii);
|
||||||
|
UWidget *pNewChildWidget = DeepDuplicateWidget(pChildUWidget);
|
||||||
|
UPanelSlot *pUPanelSlot = pNewUPanelWidget->AddChild(pNewChildWidget);
|
||||||
|
UHorizontalBoxSlot *pNewUHorizontalBoxSlot = Cast<UHorizontalBoxSlot>(pUPanelSlot);
|
||||||
|
if (pNewUHorizontalBoxSlot)
|
||||||
|
{
|
||||||
|
UHorizontalBoxSlot *pUHorizontalBoxSlot = Cast<UHorizontalBoxSlot>(pChildUWidget->Slot);
|
||||||
|
pNewUHorizontalBoxSlot->SetHorizontalAlignment(pUHorizontalBoxSlot->HorizontalAlignment);
|
||||||
|
pNewUHorizontalBoxSlot->SetVerticalAlignment(pUHorizontalBoxSlot->VerticalAlignment);
|
||||||
|
}
|
||||||
|
USizeBoxSlot *pNewUSizeBoxSlot = Cast<USizeBoxSlot>(pUPanelSlot);
|
||||||
|
if (pNewUSizeBoxSlot)
|
||||||
|
{
|
||||||
|
USizeBoxSlot *pUSizeBoxSlot = Cast<USizeBoxSlot>(pChildUWidget->Slot);
|
||||||
|
pNewUSizeBoxSlot->SetHorizontalAlignment(pUSizeBoxSlot->HorizontalAlignment);
|
||||||
|
pNewUSizeBoxSlot->SetVerticalAlignment(pUSizeBoxSlot->VerticalAlignment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pNewWidget;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void UGasaUserWidget::OnLooseParentCompiled(UBlueprint* BP)
|
||||||
|
{
|
||||||
|
GenerateParentHierarchyFromLooseParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
// This was just an experiment to see how possible it would be to generate a WidgetTree from a parent reference without using the usual blueprint inheritance.
|
||||||
|
void UGasaUserWidget::GenerateParentHierarchyFromLooseParent()
|
||||||
|
{
|
||||||
|
#if WITH_EDITOR
|
||||||
|
UWidgetBlueprintGeneratedClass* WBG_ParentClass = Cast<UWidgetBlueprintGeneratedClass>(LooseParent);
|
||||||
|
UWidgetBlueprintGeneratedClass* WBG_Class = Cast<UWidgetBlueprintGeneratedClass>(GetClass());
|
||||||
|
if (WBG_ParentClass == nullptr)
|
||||||
|
return;
|
||||||
|
if (WBG_Class == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
UPackage* Package = WBG_Class->GetPackage();
|
||||||
|
UWidgetBlueprint* BP = Cast<UWidgetBlueprint>(Package->FindAssetInPackage());
|
||||||
|
UWidgetTree* WT = BP->WidgetTree;
|
||||||
|
|
||||||
|
UPackage* UserParentPackage = WBG_ParentClass->GetPackage();
|
||||||
|
UWidgetBlueprint* UserParentBP = Cast<UWidgetBlueprint>(UserParentPackage->FindAssetInPackage());
|
||||||
|
UWidgetTree* UserParentWT = UserParentBP->WidgetTree;
|
||||||
|
|
||||||
|
TArray<UWidget*> UserParentWidgets;
|
||||||
|
UserParentWT->GetAllWidgets(UserParentWidgets);
|
||||||
|
for (UWidget* UserParentWidget : UserParentWidgets)
|
||||||
|
{
|
||||||
|
UWidget* OldWidget = nullptr;
|
||||||
|
UWidget* Widget = WT->FindWidget(UserParentWidget->GetFName());
|
||||||
|
TArray<UWidget*> Children;
|
||||||
|
UPanelWidget* Parent = nullptr;
|
||||||
|
|
||||||
|
if (Widget == nullptr)
|
||||||
|
{
|
||||||
|
if (UserParentWidget->GetClass()->IsChildOf(UUserWidget::StaticClass()))
|
||||||
|
Widget = CreateWidget<UUserWidget>(WT, UserParentWidget->GetClass(), UserParentWidget->GetFName());
|
||||||
|
else
|
||||||
|
Widget = NewObject<UWidget>(WT, UserParentWidget->GetClass(), UserParentWidget->GetFName(), RF_Transactional, UserParentWidget);
|
||||||
|
|
||||||
|
if (WT->RootWidget == nullptr)
|
||||||
|
{
|
||||||
|
WT->RootWidget = Widget;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Parent = WT->FindWidget<UPanelWidget>(UserParentWidget->GetParent()->GetFName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The widget existed previously (most likely already ran this before or manually created)
|
||||||
|
// Try to preserve widget heiarchy attached to this if possible
|
||||||
|
Parent = Widget->GetParent();
|
||||||
|
|
||||||
|
UPanelWidget* Panel = Cast<UPanelWidget>(Widget);
|
||||||
|
if (Panel)
|
||||||
|
{
|
||||||
|
Children = Panel->GetAllChildren();
|
||||||
|
}
|
||||||
|
|
||||||
|
OldWidget = Widget;
|
||||||
|
Widget = DuplicateObject<UWidget>(UserParentWidget, WT, UserParentWidget->GetFName());
|
||||||
|
}
|
||||||
|
|
||||||
|
UPanelWidget* NewPanel = Cast<UPanelWidget>(Widget);
|
||||||
|
if (NewPanel)
|
||||||
|
{
|
||||||
|
const TArray<UPanelSlot*>& Slots = NewPanel->GetSlots();
|
||||||
|
for (int32 Id = 0; Id < Slots.Num(); ++Id)
|
||||||
|
{
|
||||||
|
Slots[Id]->Content = nullptr;
|
||||||
|
}
|
||||||
|
NewPanel->ClearChildren();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Parent)
|
||||||
|
{
|
||||||
|
UPanelSlot* PSlot = Parent->AddChild(Widget);
|
||||||
|
UScaleBoxSlot* SlotScale = Cast<UScaleBoxSlot>(PSlot);
|
||||||
|
UScrollBoxSlot* SlotScroll = Cast<UScrollBoxSlot>(PSlot);
|
||||||
|
UOverlaySlot* SlotOverlay = Cast<UOverlaySlot>(PSlot);
|
||||||
|
UHorizontalBoxSlot* SlotHB = Cast<UHorizontalBoxSlot>(PSlot);
|
||||||
|
USizeBoxSlot* SlotSB = Cast<USizeBoxSlot>(PSlot);
|
||||||
|
UVerticalBoxSlot* SlobVB = Cast<UVerticalBoxSlot>(PSlot);
|
||||||
|
|
||||||
|
if (SlotOverlay)
|
||||||
|
{
|
||||||
|
UOverlay* UPW_ParentOverlay = Cast<UOverlay>(UserParentWidget->GetParent());
|
||||||
|
UOverlaySlot* ParentSlot = Cast<UOverlaySlot>(UPW_ParentOverlay->GetSlots()[Parent->GetSlots().Num() - 1]);
|
||||||
|
SlotOverlay->SetPadding( ParentSlot->GetPadding());
|
||||||
|
SlotOverlay->SetHorizontalAlignment( ParentSlot->GetHorizontalAlignment());
|
||||||
|
SlotOverlay->SetVerticalAlignment( ParentSlot->GetVerticalAlignment());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//This may not need to happen since the children check to see if they need to be added back.
|
||||||
|
for (UWidget* Child : Children)
|
||||||
|
{
|
||||||
|
if (UserParentWT->FindWidget(Child->GetFName()))
|
||||||
|
continue;
|
||||||
|
UPanelSlot* PSlot = Cast<UPanelWidget>(Widget)->AddChild(Child);
|
||||||
|
UScaleBoxSlot* SlotScale = Cast<UScaleBoxSlot>(PSlot);
|
||||||
|
UScrollBoxSlot* SlotScroll = Cast<UScrollBoxSlot>(PSlot);
|
||||||
|
UOverlaySlot* SlotOverlay = Cast<UOverlaySlot>(PSlot);
|
||||||
|
UHorizontalBoxSlot* SlotHB = Cast<UHorizontalBoxSlot>(PSlot);
|
||||||
|
USizeBoxSlot* SlotSB = Cast<USizeBoxSlot>(PSlot);
|
||||||
|
UVerticalBoxSlot* SlobVB = Cast<UVerticalBoxSlot>(PSlot);
|
||||||
|
|
||||||
|
// I'm not entirely sure if this is possible this way...
|
||||||
|
if (SlotOverlay)
|
||||||
|
{
|
||||||
|
UOverlay* ParentOverlay = Cast<UOverlay>(OldWidget->GetParent());
|
||||||
|
UOverlaySlot* ParentSlot = Cast<UOverlaySlot>(ParentOverlay->GetSlots()[Parent->GetSlots().Num() - 1]);
|
||||||
|
SlotOverlay->SetPadding( ParentSlot->GetPadding());
|
||||||
|
SlotOverlay->SetHorizontalAlignment( ParentSlot->GetHorizontalAlignment());
|
||||||
|
SlotOverlay->SetVerticalAlignment( ParentSlot->GetVerticalAlignment());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OldWidget)
|
||||||
|
OldWidget->RemoveFromParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
BP->Modify();
|
||||||
|
FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(BP);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
UGasaUserWidget::UGasaUserWidget(FObjectInitializer const& ObjectInitializer)
|
UGasaUserWidget::UGasaUserWidget(FObjectInitializer const& ObjectInitializer)
|
||||||
: UUserWidget(ObjectInitializer)
|
: UUserWidget(ObjectInitializer)
|
||||||
{
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UGasaUserWidget::Initialize()
|
||||||
|
{
|
||||||
|
// If it's not initialized initialize it, as long as it's not the CDO, we never initialize the CDO.
|
||||||
|
if (!bInitialized && !HasAnyFlags(RF_ClassDefaultObject))
|
||||||
|
{
|
||||||
|
// If this is a sub-widget of another UserWidget, default designer flags and player context to match those of the owning widget
|
||||||
|
if (UUserWidget* OwningUserWidget = GetTypedOuter<UUserWidget>())
|
||||||
|
{
|
||||||
|
#if WITH_EDITOR
|
||||||
|
SetDesignerFlags(OwningUserWidget->GetDesignerFlags());
|
||||||
|
#endif
|
||||||
|
SetPlayerContext(OwningUserWidget->GetPlayerContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
UWidgetBlueprintGeneratedClass* BGClass = Cast<UWidgetBlueprintGeneratedClass>(GetClass());
|
||||||
|
// Only do this if this widget is of a blueprint class
|
||||||
|
if (BGClass)
|
||||||
|
{
|
||||||
|
BGClass->InitializeWidget(this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InitializeNativeClassData();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( WidgetTree == nullptr )
|
||||||
|
{
|
||||||
|
WidgetTree = NewObject<UWidgetTree>(this, TEXT("WidgetTree"), RF_Transient);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WidgetTree->SetFlags(RF_Transient);
|
||||||
|
|
||||||
|
InitializeNamedSlots();
|
||||||
|
}
|
||||||
|
|
||||||
|
// For backward compatibility, run the initialize event on widget that doesn't have a player context only when the class authorized it.
|
||||||
|
bool bClassWantsToRunInitialized = BGClass && BGClass->bCanCallInitializedWithoutPlayerContext;
|
||||||
|
if (!IsDesignTime() && (PlayerContext.IsValid() || bClassWantsToRunInitialized))
|
||||||
|
{
|
||||||
|
NativeOnInitialized();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if WITH_EDITOR
|
||||||
|
if (LooseParent && bUpdateOnParentCompile)
|
||||||
|
{
|
||||||
|
UWidgetBlueprintGeneratedClass* WBG_ParentClass = Cast<UWidgetBlueprintGeneratedClass>(LooseParent);
|
||||||
|
UPackage* UserParentPackage = WBG_ParentClass->GetPackage();
|
||||||
|
UWidgetBlueprint* UserParentBP = Cast<UWidgetBlueprint>(UserParentPackage->FindAssetInPackage());
|
||||||
|
UWidgetTree* UserParentWT = UserParentBP->WidgetTree;
|
||||||
|
|
||||||
|
if ( ! UserParentBP->OnCompiled().IsBoundToObject(this))
|
||||||
|
{
|
||||||
|
UserParentBP->OnCompiled().AddUObject(this, & ThisClass::OnLooseParentCompiled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bInitialized = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UGasaUserWidget::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
|
||||||
|
{
|
||||||
|
Super::PostEditChangeProperty(PropertyChangedEvent);
|
||||||
|
|
||||||
|
FName PropertyName = (PropertyChangedEvent.Property != NULL) ? PropertyChangedEvent.Property->GetFName() : NAME_None;
|
||||||
|
if (PropertyName == GET_MEMBER_NAME_CHECKED(UGasaUserWidget, LooseParent)
|
||||||
|
|| PropertyName == GET_MEMBER_NAME_CHECKED(UGasaUserWidget, bUpdateOnParentCompile) )
|
||||||
|
{
|
||||||
|
#if WITH_EDITOR
|
||||||
|
if (LooseParent && bUpdateOnParentCompile)
|
||||||
|
{
|
||||||
|
UWidgetBlueprintGeneratedClass* WBG_ParentClass = Cast<UWidgetBlueprintGeneratedClass>(LooseParent);
|
||||||
|
if (WBG_ParentClass == nullptr)
|
||||||
|
return;
|
||||||
|
UPackage* UserParentPackage = WBG_ParentClass->GetPackage();
|
||||||
|
UWidgetBlueprint* UserParentBP = Cast<UWidgetBlueprint>(UserParentPackage->FindAssetInPackage());
|
||||||
|
UWidgetTree* UserParentWT = UserParentBP->WidgetTree;
|
||||||
|
|
||||||
|
if ( ! UserParentBP->OnCompiled().IsBoundToObject(this))
|
||||||
|
{
|
||||||
|
UserParentBP->OnCompiled().AddUObject(this, & ThisClass::OnLooseParentCompiled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UGasaUserWidget::NativeOnInitialized()
|
||||||
|
{
|
||||||
|
Super::NativeOnInitialized();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void UGasaUserWidget::NativePreConstruct()
|
||||||
|
{
|
||||||
|
Super::NativePreConstruct();
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (LooseParent)
|
||||||
|
{
|
||||||
|
UWidgetBlueprintGeneratedClass* WBG_ParentClass = Cast<UWidgetBlueprintGeneratedClass>(LooseParent);
|
||||||
|
UPackage* UserParentPackage = WBG_ParentClass->GetPackage();
|
||||||
|
UWidgetBlueprint* UserParentBP = Cast<UWidgetBlueprint>(UserParentPackage->FindAssetInPackage());
|
||||||
|
UWidgetTree* UserParentWT = UserParentBP->WidgetTree;
|
||||||
|
|
||||||
|
UserParentBP->OnCompiled().AddLambda( [this](UBlueprint* BP) {
|
||||||
|
if (this)
|
||||||
|
{
|
||||||
|
this->GenerateParentHierarchyFromLooseParent();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,19 @@ class GASA_API UGasaUserWidget : public UUserWidget
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void OnLooseParentCompiled(UBlueprint* BP);
|
||||||
|
|
||||||
|
UFUNCTION(CallInEditor, Category="Parent (Expriemental)", meta=(
|
||||||
|
ToolTip="Exprimental: This will overrite the current LooseParent widgets or create them in this user widget. Beware it will be destructive changes"))
|
||||||
|
void GenerateParentHierarchyFromLooseParent();
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Parent (Expriemental)")
|
||||||
|
bool bUpdateOnParentCompile = false;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Parent (Expriemental)")
|
||||||
|
TSubclassOf<UGasaUserWidget> LooseParent;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadOnly)
|
UPROPERTY(BlueprintReadOnly)
|
||||||
TObjectPtr<UObject> WidgetController;
|
TObjectPtr<UObject> WidgetController;
|
||||||
|
|
||||||
@ -23,4 +36,13 @@ public:
|
|||||||
|
|
||||||
UFUNCTION(BlueprintImplementableEvent)
|
UFUNCTION(BlueprintImplementableEvent)
|
||||||
void OnWidgetControllerSet();
|
void OnWidgetControllerSet();
|
||||||
|
|
||||||
|
#pragma region UserWidget
|
||||||
|
bool Initialize() override;
|
||||||
|
|
||||||
|
void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
|
||||||
|
|
||||||
|
void NativeOnInitialized() override;
|
||||||
|
void NativePreConstruct() override;
|
||||||
|
#pragma endregion UserWidget
|
||||||
};
|
};
|
||||||
|
@ -1,17 +1,70 @@
|
|||||||
#include "GlobeProgressBar.h"
|
#include "GlobeProgressBar.h"
|
||||||
|
|
||||||
#include "GasaImage.h"
|
#include "GasaImage.h"
|
||||||
|
#include "GasaOverlay.h"
|
||||||
#include "GasaProgressBar.h"
|
#include "GasaProgressBar.h"
|
||||||
#include "GasaSizeBox.h"
|
#include "GasaSizeBox.h"
|
||||||
|
|
||||||
#include "Components/OverlaySlot.h"
|
#include "Components/OverlaySlot.h"
|
||||||
|
#include "Blueprint/WidgetBlueprintGeneratedClass.h"
|
||||||
|
#include "Blueprint/WidgetTree.h"
|
||||||
|
#include "Extensions/WidgetBlueprintGeneratedClassExtension.h"
|
||||||
|
|
||||||
|
#if WITH_EDITOR
|
||||||
|
#include "WidgetBlueprint.h"
|
||||||
|
#include "Kismet2/BlueprintEditorUtils.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace Gasa;
|
||||||
|
|
||||||
// UGlobeProgressBar::UGlobeProgressBar(FObjectInitializer const& ObjectInitializer)
|
// UGlobeProgressBar::UGlobeProgressBar(FObjectInitializer const& ObjectInitializer)
|
||||||
// {
|
// {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
void UGlobeProgressBar::SetBackgroundStyle(FSlateBrush brush)
|
void UGlobeProgressBar::GenerateDesignerWidgetTemplate()
|
||||||
{
|
{
|
||||||
BG->SetBrush( brush );
|
#if WITH_EDITOR
|
||||||
|
UWidgetBlueprintGeneratedClass* WBG_Class = Cast<UWidgetBlueprintGeneratedClass>(GetClass());
|
||||||
|
|
||||||
|
UPackage* Package = WBG_Class->GetPackage();
|
||||||
|
UWidgetBlueprint* AssetBP = Cast<UWidgetBlueprint>(Package->FindAssetInPackage());
|
||||||
|
UWidgetTree* WT = AssetBP->WidgetTree;
|
||||||
|
|
||||||
|
UWidget* AssetRoot = AssetBP->WidgetTree->RootWidget;
|
||||||
|
|
||||||
|
UGasaSizeBox* Asset_SB = WT->FindWidget<UGasaSizeBox>("Root");
|
||||||
|
UGasaOverlay* Asset_Overlay = WT->FindWidget<UGasaOverlay>("Overlay");
|
||||||
|
UGasaImage* Asset_Bezel = WT->FindWidget<UGasaImage>("Bezel");
|
||||||
|
UGasaImage* Asset_Glass = WT->FindWidget<UGasaImage>("Glass");
|
||||||
|
UGasaProgressBar* Asset_Bar = WT->FindWidget<UGasaProgressBar>("Bar");
|
||||||
|
if (Root_SB == nullptr)
|
||||||
|
Asset_SB = WT->ConstructWidget<UGasaSizeBox>(UGasaSizeBox::StaticClass(), FName("Root_SB"));
|
||||||
|
if (Overlay == nullptr)
|
||||||
|
Asset_Overlay = WT->ConstructWidget<UGasaOverlay>(UGasaOverlay::StaticClass(), FName("Overlay"));
|
||||||
|
if (Bezel == nullptr)
|
||||||
|
Asset_Bezel = WT->ConstructWidget<UGasaImage>(UGasaImage::StaticClass(), FName("Bezel"));
|
||||||
|
if (Glass == nullptr)
|
||||||
|
Asset_Glass = WT->ConstructWidget<UGasaImage>(UGasaImage::StaticClass(), FName("Glass"));
|
||||||
|
if (Bar == nullptr)
|
||||||
|
Asset_Bar = WT->ConstructWidget<UGasaProgressBar>(UGasaProgressBar::StaticClass(), FName("Bar"));
|
||||||
|
|
||||||
|
WT->RootWidget = Asset_SB;
|
||||||
|
Asset_SB->ClearChildren();
|
||||||
|
Asset_Overlay->ClearChildren();
|
||||||
|
Asset_SB->AddChild(Asset_Overlay);
|
||||||
|
Asset_Overlay->AddChild(Asset_Bezel);
|
||||||
|
Asset_Overlay->AddChild(Asset_Glass);
|
||||||
|
Asset_Overlay->AddChild(Asset_Bar);
|
||||||
|
|
||||||
|
AssetBP->Modify();
|
||||||
|
FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(AssetBP);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma region Bindings
|
||||||
|
void UGlobeProgressBar::SetBezelStyle(FSlateBrush brush)
|
||||||
|
{
|
||||||
|
Bezel->SetBrush( brush );
|
||||||
}
|
}
|
||||||
|
|
||||||
void UGlobeProgressBar::SetBarPadding(FMargin margin )
|
void UGlobeProgressBar::SetBarPadding(FMargin margin )
|
||||||
@ -38,24 +91,52 @@ void UGlobeProgressBar::SetGlassStyle(FSlateBrush brush)
|
|||||||
|
|
||||||
void UGlobeProgressBar::SetSize(float width, float height)
|
void UGlobeProgressBar::SetSize(float width, float height)
|
||||||
{
|
{
|
||||||
SizeBox_Root->SetWidthOverride( width );
|
Root_SB->SetWidthOverride( width );
|
||||||
SizeBox_Root->SetHeightOverride( height );
|
Root_SB->SetHeightOverride( height );
|
||||||
|
}
|
||||||
|
#pragma endregion Bindings
|
||||||
|
|
||||||
|
#pragma region Widget
|
||||||
|
void UGlobeProgressBar::SynchronizeProperties()
|
||||||
|
{
|
||||||
|
Super::SynchronizeProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
void UGlobeProgressBar::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
|
||||||
void UGlobeProgressBar::UpdateSize()
|
|
||||||
{
|
{
|
||||||
|
Super::PostEditChangeProperty(PropertyChangedEvent);
|
||||||
}
|
}
|
||||||
|
#pragma endregion Widget
|
||||||
void UGlobeProgressBar::UpdateBackground()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#pragma region UserWidget
|
#pragma region UserWidget
|
||||||
void UGlobeProgressBar::NativePreConstruct()
|
void UGlobeProgressBar::NativePreConstruct()
|
||||||
{
|
{
|
||||||
Super::NativePreConstruct();
|
// Super::NativePreConstruct(); - Inlined
|
||||||
|
LLM_SCOPE_BYTAG(UI_UMG);
|
||||||
|
const bool bIsDesignTime = IsDesignTime();
|
||||||
|
|
||||||
|
UWidgetBlueprintGeneratedClass* WBG_Class = Cast<UWidgetBlueprintGeneratedClass>(GetClass());
|
||||||
|
if (WBG_Class)
|
||||||
|
{
|
||||||
|
WBG_Class->ForEachExtension([this, bIsDesignTime](UWidgetBlueprintGeneratedClassExtension* Extension)
|
||||||
|
{
|
||||||
|
Extension->PreConstruct(this, bIsDesignTime);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
DesiredFocusWidget.Resolve(WidgetTree);
|
||||||
|
|
||||||
|
// Blueprint Callback
|
||||||
|
PreConstruct(bIsDesignTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UGlobeProgressBar::Serialize(FArchive& Ar)
|
||||||
|
{
|
||||||
|
Super::Serialize(Ar);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UGlobeProgressBar::Serialize(FStructuredArchive::FRecord Record)
|
||||||
|
{
|
||||||
|
Super::Serialize(Record);
|
||||||
}
|
}
|
||||||
#pragma endregion UserWidget
|
#pragma endregion UserWidget
|
||||||
|
@ -11,25 +11,29 @@ class GASA_API UGlobeProgressBar : public UGasaUserWidget
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidget), Category="Globe")
|
|
||||||
UGasaSizeBox* SizeBox_Root;
|
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidget), Category="Globe")
|
// Just learning: https://benui.ca/unreal/build-widgets-in-editor/?utm_medium=social&utm_source=Discord
|
||||||
UGasaOverlay* Overlay_Root;
|
UFUNCTION(CallInEditor, Category="Generate Designer Widget Template")
|
||||||
|
void GenerateDesignerWidgetTemplate();
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidget), Category="Globe")
|
#pragma region Bindings
|
||||||
UGasaImage* Glass;
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidgetOptional), Category="Globe")
|
||||||
|
UGasaSizeBox* Root_SB;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidgetOptional), Category="Globe")
|
||||||
|
UGasaOverlay* Overlay;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidget), Category="Globe")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidgetOptional), Category="Globe")
|
||||||
UGasaImage* BG;
|
UGasaImage* Bezel;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidget), Category="Globe")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidgetOptional), Category="Globe")
|
||||||
UGasaProgressBar* Bar;
|
UGasaProgressBar* Bar;
|
||||||
|
|
||||||
// UGlobeProgressBar(FObjectInitializer const& ObjectInitializer);
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidgetOptional), Category="Globe")
|
||||||
|
UGasaImage* Glass;
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="Globe")
|
UFUNCTION(BlueprintCallable, Category="Globe")
|
||||||
void SetBackgroundStyle(FSlateBrush brush);
|
void SetBezelStyle(FSlateBrush brush);
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="Globe")
|
UFUNCTION(BlueprintCallable, Category="Globe")
|
||||||
void SetBarPadding( FMargin margin );
|
void SetBarPadding( FMargin margin );
|
||||||
@ -45,16 +49,22 @@ public:
|
|||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="Globe")
|
UFUNCTION(BlueprintCallable, Category="Globe")
|
||||||
void SetSize(float width, float height);
|
void SetSize(float width, float height);
|
||||||
|
#pragma endregion Bindings
|
||||||
#if 0
|
|
||||||
UFUNCTION(BlueprintCallable, Category="Globe")
|
|
||||||
void UpdateSize();
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="Globe")
|
// UGlobeProgressBar(FObjectInitializer const& ObjectInitializer);
|
||||||
void UpdateBackground();
|
|
||||||
#endif
|
#pragma region Widget
|
||||||
|
void SynchronizeProperties() override;
|
||||||
|
#pragma endregion Widget
|
||||||
|
|
||||||
|
void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
|
||||||
|
|
||||||
#pragma region UserWidget
|
#pragma region UserWidget
|
||||||
void NativePreConstruct() override;
|
void NativePreConstruct() override;
|
||||||
#pragma endregion UserWidget
|
#pragma endregion UserWidget
|
||||||
|
|
||||||
|
#pragma region Object
|
||||||
|
void Serialize(FArchive& Ar) override;
|
||||||
|
void Serialize(FStructuredArchive::FRecord Record) override;
|
||||||
|
#pragma endregion Object
|
||||||
};
|
};
|
||||||
|
1
Project/Source/Gasa/UI/UI_HostWidget.cpp
Normal file
1
Project/Source/Gasa/UI/UI_HostWidget.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "UI_HostWidget.h"
|
13
Project/Source/Gasa/UI/UI_HostWidget.h
Normal file
13
Project/Source/Gasa/UI/UI_HostWidget.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GasaUserWidget.h"
|
||||||
|
|
||||||
|
#include "UI_HostWidget.generated.h"
|
||||||
|
|
||||||
|
UCLASS()
|
||||||
|
class GASA_API UUI_HostWidget : public UGasaUserWidget
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
public:
|
||||||
|
// #pragma region
|
||||||
|
};
|
@ -4,7 +4,7 @@
|
|||||||
#include "WidgetController.generated.h"
|
#include "WidgetController.generated.h"
|
||||||
|
|
||||||
UCLASS(BlueprintType)
|
UCLASS(BlueprintType)
|
||||||
class GASA_API UWdgetController : public UObject
|
class GASA_API UWidgetController : public UObject
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
public:
|
public:
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime;
|
||||||
using BuildSettingsVersion = UnrealBuildTool.BuildSettingsVersion;
|
using BuildSettingsVersion = UnrealBuildTool.BuildSettingsVersion;
|
||||||
using TargetInfo = UnrealBuildTool.TargetInfo;
|
using TargetInfo = UnrealBuildTool.TargetInfo;
|
||||||
using TargetRules = UnrealBuildTool.TargetRules;
|
using TargetRules = UnrealBuildTool.TargetRules;
|
||||||
@ -11,10 +15,15 @@ public class GasaEditorTarget : TargetRules
|
|||||||
|
|
||||||
DefaultBuildSettings = BuildSettingsVersion.Latest;
|
DefaultBuildSettings = BuildSettingsVersion.Latest;
|
||||||
|
|
||||||
// bUseUnityBuild = false;
|
bUseUnityBuild = true;
|
||||||
// bUseXGEController = false;
|
// bUseXGEController = false;
|
||||||
|
|
||||||
ExtraModuleNames.Add("Gasa");
|
ExtraModuleNames.Add("Gasa");
|
||||||
ExtraModuleNames.Add("GasaEditor");
|
ExtraModuleNames.Add("GasaEditor");
|
||||||
|
|
||||||
|
DirectoryInfo di_uproject = new DirectoryInfo(Path.GetDirectoryName(ProjectFile.ToString())).Parent;
|
||||||
|
string path_uproject = di_uproject.FullName;
|
||||||
|
string path_scripts = Path.Combine(path_uproject, "scripts");
|
||||||
|
string ps_gen_pass_gasa = Path.Combine(path_scripts, "gen_pass_gasa.ps1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,171 @@
|
|||||||
|
#include "GlobeProgressBarDetails.h"
|
||||||
|
|
||||||
|
#include "BaseWidgetBlueprint.h"
|
||||||
|
#include "BlueprintEditor.h"
|
||||||
|
#include "GasaEditorCommon.h"
|
||||||
|
#include "DetailCategoryBuilder.h"
|
||||||
|
#include "DetailLayoutBuilder.h"
|
||||||
|
#include "DetailWidgetRow.h"
|
||||||
|
#include "PropertyCustomizationHelpers.h"
|
||||||
|
#include "Blueprint/WidgetBlueprintGeneratedClass.h"
|
||||||
|
#include "Blueprint/WidgetTree.h"
|
||||||
|
#include "Components/ProgressBar.h"
|
||||||
|
#include "Gasa/UI/GlobeProgressBar.h"
|
||||||
|
#include "Kismet2/BlueprintEditorUtils.h"
|
||||||
|
#include "UI/GasaProgressBar.h"
|
||||||
|
|
||||||
|
UE_DISABLE_OPTIMIZATION
|
||||||
|
void FGlobeProgressBarDetails::CustomizeDetails(IDetailLayoutBuilder& LayoutBuilder)
|
||||||
|
{
|
||||||
|
IDetailCategoryBuilder& GlobeCategory = LayoutBuilder.EditCategory("Globe");
|
||||||
|
|
||||||
|
UObject* GlobeBar = nullptr;
|
||||||
|
UGlobeProgressBar* Globe = nullptr;
|
||||||
|
for (TWeakObjectPtr<UObject> Object : LayoutBuilder.GetSelectedObjects())
|
||||||
|
{
|
||||||
|
if ( ! Object.IsValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Globe = Cast<UGlobeProgressBar>(Object.Get());
|
||||||
|
if (Globe)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Globe && Globe->Bar)
|
||||||
|
{
|
||||||
|
auto StyleFillImage = Globe->Bar->GetWidgetStyle().FillImage.GetResourceObject();
|
||||||
|
Thumbnail = MakeShareable(new FAssetThumbnail(FAssetData(StyleFillImage), 64, 64, LayoutBuilder.GetThumbnailPool()));
|
||||||
|
}
|
||||||
|
|
||||||
|
TSharedPtr<IPropertyHandle>
|
||||||
|
ProgressBarStyle = LayoutBuilder.GetProperty(GET_MEMBER_NAME_CHECKED(UGlobeProgressBar, Bar), UGlobeProgressBar::StaticClass());
|
||||||
|
ProgressBarStyle->GetValue(GlobeBar);
|
||||||
|
if (ProgressBarStyle && ! ProgressBarStyle->IsValidHandle())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// This can't be done, UE widget parenting forces the parent widget's hierarchy to be immutable at 'design time'.
|
||||||
|
// This is because a proper clone of the UWidgetBlueprintGeneratedClass parent's widget tree is not done.
|
||||||
|
// Instead... I don't even know what they are even doing with the widget tree because somehow they still have a unique widget tree
|
||||||
|
// for at least the child widget.
|
||||||
|
// All code paths related to this are not navigable in a reasonable amount of time.
|
||||||
|
// So I don't even know why this failure point exist architecturally...
|
||||||
|
#if 0
|
||||||
|
// TSharedPtr<IPropertyHandle> WidgetStyle = ProgressBarStyleHandle->GetChildHandle("WidgetStyle");
|
||||||
|
// if ( ! WidgetStyle.IsValid())
|
||||||
|
// return;
|
||||||
|
IDetailPropertyRow& ProgressBarRow = LayoutBuilder.AddPropertyToCategory(ProgressBarStyle);
|
||||||
|
|
||||||
|
FDetailWidgetRow& RowWidget = ProgressBarRow.CustomWidget();
|
||||||
|
{
|
||||||
|
FDetailWidgetDecl& RowNameWidget = RowWidget.NameContent();
|
||||||
|
{
|
||||||
|
TSharedRef<STextBlock>
|
||||||
|
TextBlock = SNew(STextBlock);
|
||||||
|
TextBlock->SetText(FText::FromString(TEXT("Bar Fill Material")));
|
||||||
|
TextBlock->SetFont(LayoutBuilder.GetDetailFont());
|
||||||
|
RowNameWidget.Widget = TextBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
FDetailWidgetDecl& RowValueWidget = RowWidget.ValueContent();
|
||||||
|
TSharedRef<SHorizontalBox> HBox = SNew(SHorizontalBox);
|
||||||
|
{
|
||||||
|
SHorizontalBox::FSlot::FSlotArguments ThumbnailSlot = SHorizontalBox::Slot();
|
||||||
|
{
|
||||||
|
TSharedRef<SBox> ThumbnailBox = SNew(SBox);
|
||||||
|
ThumbnailBox->SetWidthOverride(64);
|
||||||
|
ThumbnailBox->SetHeightOverride(64);
|
||||||
|
|
||||||
|
if ( Thumbnail.IsValid() )
|
||||||
|
ThumbnailBox->SetContent( Thumbnail->MakeThumbnailWidget());
|
||||||
|
else
|
||||||
|
ThumbnailBox->SetContent( SNullWidget::NullWidget );
|
||||||
|
|
||||||
|
ThumbnailSlot.AutoWidth();
|
||||||
|
ThumbnailSlot.AttachWidget( ThumbnailBox );
|
||||||
|
}
|
||||||
|
|
||||||
|
SHorizontalBox::FSlot::FSlotArguments DropDownSlot = SHorizontalBox::Slot();
|
||||||
|
{
|
||||||
|
TSharedRef<SObjectPropertyEntryBox> EntryBox = SNew(SObjectPropertyEntryBox);
|
||||||
|
{
|
||||||
|
SObjectPropertyEntryBox::FArguments Args;
|
||||||
|
Args.PropertyHandle(ProgressBarStyle);
|
||||||
|
Args.AllowClear(false);
|
||||||
|
// Args.OnShouldFilterAsset_Lambda( [&](FAssetData const& Asset) -> bool
|
||||||
|
// {
|
||||||
|
// FString const AssetPath = Asset.ObjectPath.ToString();
|
||||||
|
// // Add conditional filters here
|
||||||
|
// return true;
|
||||||
|
// });
|
||||||
|
Args.DisplayThumbnail(false);
|
||||||
|
Args.OnObjectChanged_Lambda( [this, Globe, &ProgressBarStyle, &LayoutBuilder](FAssetData const& Asset)
|
||||||
|
{
|
||||||
|
if ( ! Asset.IsValid() || ! Thumbnail.IsValid() || ! Globe || ! Globe->Bar )
|
||||||
|
return;
|
||||||
|
|
||||||
|
FProgressBarStyle
|
||||||
|
Style = Globe->Bar->GetWidgetStyle();
|
||||||
|
Style.FillImage.SetResourceObject(Asset.GetAsset());
|
||||||
|
|
||||||
|
// Get the Blueprint that owns this widget and mark it as modified
|
||||||
|
UBaseWidgetBlueprint* GlobeBP = Cast<UBaseWidgetBlueprint>(Globe->WidgetGeneratedBy);
|
||||||
|
if (GlobeBP != nullptr)
|
||||||
|
{
|
||||||
|
GlobeBP->Modify();
|
||||||
|
UObject* CDO = GlobeBP->GeneratedClass->GetDefaultObject();
|
||||||
|
UGlobeProgressBar* GlobeCDO = Cast<UGlobeProgressBar>(CDO);
|
||||||
|
|
||||||
|
UWidget* PossibleWidget = Cast<UBaseWidgetBlueprint>(GlobeBP)->WidgetTree->FindWidget("Bar");
|
||||||
|
if (PossibleWidget)
|
||||||
|
{
|
||||||
|
UGasaProgressBar* BarWidget = Cast<UGasaProgressBar>(PossibleWidget);
|
||||||
|
BarWidget->SetWidgetStyle(Style);
|
||||||
|
GlobeBP->MarkPackageDirty();
|
||||||
|
}
|
||||||
|
else // Its parent is it.
|
||||||
|
{
|
||||||
|
UWidgetBlueprintGeneratedClass* Parent = Cast<UWidgetBlueprintGeneratedClass>(GlobeBP->ParentClass);
|
||||||
|
UPackage* Pkg = Parent->GetOuterUPackage();
|
||||||
|
|
||||||
|
PossibleWidget = Parent->GetWidgetTreeArchetype()->FindWidget("Bar");
|
||||||
|
if (PossibleWidget)
|
||||||
|
{
|
||||||
|
GlobeCDO->Bar = GlobeCDO->WidgetTree->ConstructWidget<UGasaProgressBar>( PossibleWidget->GetClass(), "Bar" );
|
||||||
|
Globe->Bar = GlobeCDO->Bar;
|
||||||
|
GlobeCDO->Modify();
|
||||||
|
GlobeCDO->MarkPackageDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Globe->SetBarStyle(Style);
|
||||||
|
Globe->Bar->Modify();
|
||||||
|
Globe->Modify();
|
||||||
|
|
||||||
|
Thumbnail->SetAsset(Asset);
|
||||||
|
Thumbnail->RefreshThumbnail();
|
||||||
|
});
|
||||||
|
// Args.CustomResetToDefault(FResetToDefaultOverride::Hide());
|
||||||
|
Args.DisplayBrowse(true);
|
||||||
|
EntryBox->Construct(Args);
|
||||||
|
}
|
||||||
|
|
||||||
|
DropDownSlot.AutoWidth();
|
||||||
|
DropDownSlot.AttachWidget(EntryBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
SHorizontalBox::FArguments Args = SHorizontalBox::FArguments();
|
||||||
|
Args.operator+(ThumbnailSlot);
|
||||||
|
Args.operator+(DropDownSlot);
|
||||||
|
HBox->Construct(Args);
|
||||||
|
RowValueWidget.Widget = HBox;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FGlobeProgressBarDetails::CheckAsset(FAssetData const& Asset)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
UE_ENABLE_OPTIMIZATION
|
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "IDetailCustomization.h"
|
||||||
|
|
||||||
|
|
||||||
|
class FGlobeProgressBarDetails : public IDetailCustomization
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static TSharedRef<IDetailCustomization> MakeInstance() { return MakeShareable(new FGlobeProgressBarDetails); }
|
||||||
|
|
||||||
|
void CustomizeDetails(IDetailLayoutBuilder& DetailBuilder) override;
|
||||||
|
|
||||||
|
static bool CheckAsset(FAssetData const& Asset);
|
||||||
|
TSharedPtr<FAssetThumbnail> Thumbnail;
|
||||||
|
};
|
@ -8,12 +8,22 @@ public class GasaEditor : ModuleRules
|
|||||||
#region Engine
|
#region Engine
|
||||||
PrivateIncludePathModuleNames.AddRange(new string[] {
|
PrivateIncludePathModuleNames.AddRange(new string[] {
|
||||||
"Core",
|
"Core",
|
||||||
|
"CoreUObject",
|
||||||
|
"Engine",
|
||||||
});
|
});
|
||||||
PrivateDependencyModuleNames.AddRange(new string[] {
|
PrivateDependencyModuleNames.AddRange(new string[] {
|
||||||
"Core",
|
"Core",
|
||||||
|
"Engine",
|
||||||
|
"CoreUObject",
|
||||||
|
"PropertyEditor",
|
||||||
|
"SlateCore",
|
||||||
|
"Slate",
|
||||||
|
"UMG",
|
||||||
|
"UnrealEd",
|
||||||
});
|
});
|
||||||
#endregion Engine
|
#endregion Engine
|
||||||
|
|
||||||
PublicIncludePathModuleNames.Add("Gasa");
|
PublicIncludePaths.Add("GasaEditor");
|
||||||
|
PrivateDependencyModuleNames.Add("Gasa");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
Project/Source/GasaEditor/GasaEditorCommon.cpp
Normal file
3
Project/Source/GasaEditor/GasaEditorCommon.cpp
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#include "GasaEditorCommon.h"
|
||||||
|
|
||||||
|
DEFINE_LOG_CATEGORY(LogGasaEditor);
|
68
Project/Source/GasaEditor/GasaEditorCommon.h
Normal file
68
Project/Source/GasaEditor/GasaEditorCommon.h
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Gasa/GasaCommon.h"
|
||||||
|
|
||||||
|
#pragma region Engine Forwards
|
||||||
|
#pragma endregion Engine Forwards
|
||||||
|
|
||||||
|
#pragma region Engine Plugin Forwards
|
||||||
|
#pragma endregion Engine Plugin Forwards
|
||||||
|
|
||||||
|
// Gasa Editor
|
||||||
|
|
||||||
|
#pragma region Forwards
|
||||||
|
#pragma endregion Forwards
|
||||||
|
|
||||||
|
#pragma region Logging
|
||||||
|
DECLARE_LOG_CATEGORY_EXTERN(LogGasaEditor, Log, All);
|
||||||
|
|
||||||
|
namespace Gasa
|
||||||
|
{
|
||||||
|
using ELogV = EGasaVerbosity;
|
||||||
|
|
||||||
|
//◞ ‸ ◟//
|
||||||
|
// Works for Unreal 5.4, Win64 MSVC (untested in other scenarios, for now)
|
||||||
|
inline
|
||||||
|
void LogEditor( FString Message, EGasaVerbosity Verbosity = EGasaVerbosity::Log
|
||||||
|
, FLogCategoryBase& Category = LogGasaEditor
|
||||||
|
, bool DumpStack = false
|
||||||
|
, int32 Line = __builtin_LINE()
|
||||||
|
, const ANSICHAR* File = __builtin_FILE()
|
||||||
|
, const ANSICHAR* Func = __builtin_FUNCTION() )
|
||||||
|
{
|
||||||
|
#if !UE_BUILD_SHIPPING && !NO_LOGGING
|
||||||
|
ELogVerbosity::Type EngineVerbosity = (ELogVerbosity::Type) Verbosity;
|
||||||
|
|
||||||
|
static UE::Logging::Private::FStaticBasicLogDynamicData LOG_Dynamic;
|
||||||
|
static UE::Logging::Private::FStaticBasicLogRecord
|
||||||
|
LOG_Static(TEXT("%80s -- %hs %hs(%d)"), File, Line, EngineVerbosity, LOG_Dynamic);
|
||||||
|
|
||||||
|
if ((EngineVerbosity & ELogVerbosity::VerbosityMask) <= ELogVerbosity::COMPILED_IN_MINIMUM_VERBOSITY)
|
||||||
|
{
|
||||||
|
if ((EngineVerbosity & ELogVerbosity::VerbosityMask) <= Category.GetVerbosity())
|
||||||
|
{
|
||||||
|
if ( ! Category.IsSuppressed(EngineVerbosity))
|
||||||
|
{
|
||||||
|
if (DumpStack)
|
||||||
|
FDebug::DumpStackTraceToLog(EngineVerbosity);
|
||||||
|
BasicLog(Category, &LOG_Static, *Message, File, Func, Line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define GasaEd_Fatal(Message) UE_LOG( LogGasaEditor, Fatal, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_FILE(), __func__, __builtin_LINE() );
|
||||||
|
#define GasaEd_Error(Message) UE_LOG( LogGasaEditor, Error, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() );
|
||||||
|
#define GasaEd_Warning(Message) UE_LOG( LogGasaEditor, Warning, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() );
|
||||||
|
#define GasaEd_Display(Message) UE_LOG( LogGasaEditor, Display, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() );
|
||||||
|
#define GasaEd_Log(Message) UE_LOG( LogGasaEditor, Log, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() );
|
||||||
|
#define GasaEd_Verbose(Message) UE_LOG( LogGasaEditor, Verbose, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() );
|
||||||
|
#define GasaEd_VeryVerbose(Message) UE_LOG( LogGasaEditor, VeryVerbose, TEXT("%s -- %hs %hs(%d)"), *Message, __builtin_File(), __func__, __builtin_LINE() );
|
||||||
|
#pragma endregion Logging
|
||||||
|
|
||||||
|
#pragma region Timing
|
||||||
|
#pragma endregion Timing
|
@ -1,14 +1,25 @@
|
|||||||
#include "GasaEditorModule.h"
|
#include "GasaEditorModule.h"
|
||||||
|
|
||||||
|
#include "EditorDetails/GlobeProgressBarDetails.h"
|
||||||
|
#include "UI/GlobeProgressBar.h"
|
||||||
|
|
||||||
IMPLEMENT_PRIMARY_GAME_MODULE(FGasaEditorModule, GasaEditor, GasaEditor);
|
IMPLEMENT_PRIMARY_GAME_MODULE(FGasaEditorModule, GasaEditor, GasaEditor);
|
||||||
|
|
||||||
void FGasaEditorModule::StartupModule()
|
void FGasaEditorModule::StartupModule()
|
||||||
{
|
{
|
||||||
|
FPropertyEditorModule& PropertyEditor = FModuleManager::LoadModuleChecked<FPropertyEditorModule>("PropertyEditor");
|
||||||
|
|
||||||
|
PropertyEditor.RegisterCustomClassLayout( UGlobeProgressBar::StaticClass()->GetFName()
|
||||||
|
, FOnGetDetailCustomizationInstance::CreateStatic(& FGlobeProgressBarDetails::MakeInstance)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGasaEditorModule::ShutdownModule()
|
void FGasaEditorModule::ShutdownModule()
|
||||||
{
|
{
|
||||||
|
if (FModuleManager::Get().IsModuleLoaded("PropertyEditor"))
|
||||||
|
{
|
||||||
|
FPropertyEditorModule& PropertyEditor = FModuleManager::GetModuleChecked<FPropertyEditorModule>("PropertyEditor");
|
||||||
|
PropertyEditor.UnregisterCustomClassLayout(UGlobeProgressBar::StaticClass()->GetFName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5,109 +5,84 @@
|
|||||||
#define GEN_IMPLEMENTATION
|
#define GEN_IMPLEMENTATION
|
||||||
#include "gen.cpp"
|
#include "gen.cpp"
|
||||||
#include "gen.builder.cpp"
|
#include "gen.builder.cpp"
|
||||||
#include "gen.scanner.hpp"
|
// #include "gen.scanner.hpp"
|
||||||
using namespace gen;
|
using namespace gen;
|
||||||
|
|
||||||
|
#ifdef GEN_SYSTEM_WINDOWS
|
||||||
|
#include <process.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "GasaGenCommon.cpp"
|
#include "GasaGenCommon.cpp"
|
||||||
#include "GasaGen_ue_parse_testing.cpp"
|
#include "GasaGen_ue_parse_testing.cpp"
|
||||||
#include "GasaGen_UGasaAttributeSet.cpp"
|
#include "GasaGen_UGasaAttributeSet.cpp"
|
||||||
#include "GasaGen_ChangeBPActionMenu.cpp"
|
#include "GasaGen_ChangeBPActionMenu.cpp"
|
||||||
|
#include "GasaGen_DevOptionsCache.cpp"
|
||||||
|
|
||||||
int gen_main()
|
int gen_main()
|
||||||
{
|
{
|
||||||
gen::init();
|
gen::init();
|
||||||
log_fmt("Generating code for the Gasa module");
|
log_fmt("Generating code for the Gasa module\n");
|
||||||
|
|
||||||
// Initialize Globals
|
// Initialize Globals
|
||||||
umeta_uclass = code_str( UCLASS() );
|
{
|
||||||
umeta_generated_body = code_str( GENERATED_BODY() );
|
UHT_UCLASS = code_str( UCLASS() );
|
||||||
gasa_api = code_str( GASA_API );
|
UHT_UPROPERTY = code_str( UPROPERTY() );
|
||||||
|
UHT_USTRUCT = code_str( USTRUCT() );
|
||||||
|
UHT_GENERATED_BODY = code_str( GENERATED_BODY()\n );
|
||||||
|
UModule_GASA_API = code_str( GASA_API );
|
||||||
|
}
|
||||||
|
|
||||||
StrC str_GENERATED_BODY = txt("GENERATED_BODY(");
|
// Populate Defines
|
||||||
StrC str_GENERATED_UCLASS_BODY = txt("GENERATED_UCLASS_BODY(");
|
{
|
||||||
StrC str_PROPERTY_BINDING_IMPLEMENTATION = txt("PROPERTY_BINDING_IMPLEMENTATION(");
|
PreprocessorDefines.append( get_cached_string(str_DECLARE_CLASS));
|
||||||
StrC str_UCLASS = txt("UCLASS(");
|
PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_RetVal_OneParam));
|
||||||
StrC str_UFUNCTION = txt("UFUNCTION(");
|
PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_RetVal_ThreeParams));
|
||||||
StrC str_UPROPERTY = txt("UPROPERTY(");
|
PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_SixParams));
|
||||||
StrC str_DECLARE_LOG_CATEGORY_EXTERN = txt("DECLARE_LOG_CATEGORY_EXTERN(");
|
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams));
|
||||||
StrC str_ENUM_CLASS_FLAGS = txt("ENUM_CLASS_FLAGS(");
|
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams));
|
||||||
StrC str_DECLARE_CLASS = txt("DECLARE_CLASS(");
|
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams));
|
||||||
StrC str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL = txt("DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL(");
|
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam));
|
||||||
StrC str_TEXT = txt("TEXT(");
|
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams));
|
||||||
StrC str_DECLARE_MULTICAST_DELEGATE_OneParam = txt("DECLARE_MULTICAST_DELEGATE_OneParam(");
|
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams));
|
||||||
StrC str_DECLARE_MULTICAST_DELEGATE_TwoParams = txt("DECLARE_MULTICAST_DELEGATE_TwoParams(");
|
PreprocessorDefines.append( get_cached_string(str_DECLARE_EVENT_ThreeParams));
|
||||||
StrC str_DECLARE_MULTICAST_DELEGATE_ThreeParams = txt("DECLARE_MULTICAST_DELEGATE_ThreeParams(");
|
PreprocessorDefines.append( get_cached_string(str_DECLARE_EVENT_TwoParams));
|
||||||
StrC str_DECLARE_DELEGATE_RetVal_OneParam = txt("DECLARE_DELEGATE_RetVal_OneParam(");
|
PreprocessorDefines.append( get_cached_string(str_DECLARE_FUNCTION));
|
||||||
StrC str_DECLARE_FUNCTION = txt("DECLARE_FUNCTION(");
|
PreprocessorDefines.append( get_cached_string(str_DECLARE_LOG_CATEGORY_EXTERN));
|
||||||
StrC str_RESULT_DECL = txt("RESULT_DECL");
|
PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_OneParam));
|
||||||
StrC str_FORCEINLINE = txt("FORCEINLINE");
|
PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_ThreeParams));
|
||||||
StrC str_UENUM = txt("UENUM(");
|
PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_TwoParams));
|
||||||
StrC str_UMETA = txt("UMETA(");
|
PreprocessorDefines.append( get_cached_string(str_DEFINE_ACTORDESC_TYPE));
|
||||||
StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams(");
|
PreprocessorDefines.append( get_cached_string(str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL));
|
||||||
StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams(");
|
PreprocessorDefines.append( get_cached_string(str_ENUM_CLASS_FLAGS));
|
||||||
StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams(");
|
PreprocessorDefines.append( get_cached_string(str_FORCEINLINE_DEBUGGABLE));
|
||||||
StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams(");
|
PreprocessorDefines.append( get_cached_string(str_FORCEINLINE));
|
||||||
StrC str_DECLARE_DELEGATE_SixParams = txt("DECLARE_DELEGATE_SixParams(");
|
PreprocessorDefines.append( get_cached_string(str_GENERATED_BODY));
|
||||||
StrC str_DECLARE_EVENT_TwoParams = txt("DECLARE_EVENT_TwoParams(");
|
PreprocessorDefines.append( get_cached_string(str_GENERATED_UCLASS_BODY));
|
||||||
StrC str_DECLARE_DELEGATE_RetVal_ThreeParams = txt("DECLARE_DELEGATE_RetVal_ThreeParams(");
|
PreprocessorDefines.append( get_cached_string(str_GENERATED_USTRUCT_BODY));
|
||||||
StrC str_PRAGMA_DISABLE_DEPRECATION_WARNINGS = txt("PRAGMA_DISABLE_DEPRECATION_WARNINGS");
|
PreprocessorDefines.append( get_cached_string(str_PRAGMA_DISABLE_DEPRECATION_WARNINGS));
|
||||||
StrC str_PRAGMA_ENABLE_DEPRECATION_WARNINGS = txt("PRAGMA_ENABLE_DEPRECATION_WARNINGS");
|
PreprocessorDefines.append( get_cached_string(str_PRAGMA_ENABLE_DEPRECATION_WARNINGS));
|
||||||
StrC str_DEFINE_ACTORDESC_TYPE = txt("DEFINE_ACTORDESC_TYPE(");
|
PreprocessorDefines.append( get_cached_string(str_PROPERTY_BINDING_IMPLEMENTATION));
|
||||||
StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams(");
|
PreprocessorDefines.append( get_cached_string(str_RESULT_DECL));
|
||||||
StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(");
|
PreprocessorDefines.append( get_cached_string(str_SLATE_BEGIN_ARGS));
|
||||||
StrC str_UPARAM = txt("UPARAM(");
|
PreprocessorDefines.append( get_cached_string(str_SLATE_END_ARGS));
|
||||||
StrC str_FORCEINLINE_DEBUGGABLE = txt("FORCEINLINE_DEBUGGABLE");
|
PreprocessorDefines.append( get_cached_string(str_TEXT));
|
||||||
StrC str_DECLARE_EVENT_ThreeParams = txt("DECLARE_EVENT_ThreeParams(");
|
PreprocessorDefines.append( get_cached_string(str_UCLASS));
|
||||||
StrC str_USTRUCT = txt("USTRUCT(");
|
PreprocessorDefines.append( get_cached_string(str_UENUM));
|
||||||
StrC str_GENERATED_USTRUCT_BODY = txt("GENERATED_USTRUCT_BODY(");
|
PreprocessorDefines.append( get_cached_string(str_UFUNCTION));
|
||||||
StrC str_SLATE_BEGIN_ARGS = txt("SLATE_BEGIN_ARGS(");
|
PreprocessorDefines.append( get_cached_string(str_UMETA));
|
||||||
StrC str_SLATE_END_ARGS = txt("SLATE_END_ARGS(");
|
PreprocessorDefines.append( get_cached_string(str_UPARAM));
|
||||||
|
PreprocessorDefines.append( get_cached_string(str_UPROPERTY));
|
||||||
PreprocessorDefines.append( get_cached_string(str_GENERATED_BODY));
|
PreprocessorDefines.append( get_cached_string(str_USTRUCT));
|
||||||
PreprocessorDefines.append( get_cached_string(str_GENERATED_UCLASS_BODY));
|
}
|
||||||
PreprocessorDefines.append( get_cached_string(str_PROPERTY_BINDING_IMPLEMENTATION));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_UCLASS));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_UFUNCTION));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_UPROPERTY));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_LOG_CATEGORY_EXTERN));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_ENUM_CLASS_FLAGS));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_CLASS));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_TEXT));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_OneParam));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_TwoParams));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_ThreeParams));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_RetVal_OneParam));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_FUNCTION));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_RESULT_DECL));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_FORCEINLINE));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_UENUM));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_UMETA));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_SixParams));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_EVENT_TwoParams));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_RetVal_ThreeParams));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_PRAGMA_DISABLE_DEPRECATION_WARNINGS));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_PRAGMA_ENABLE_DEPRECATION_WARNINGS));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_DEFINE_ACTORDESC_TYPE));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_UPARAM));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_FORCEINLINE_DEBUGGABLE));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_DECLARE_EVENT_ThreeParams));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_USTRUCT));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_GENERATED_USTRUCT_BODY));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_SLATE_BEGIN_ARGS));
|
|
||||||
PreprocessorDefines.append( get_cached_string(str_SLATE_END_ARGS));
|
|
||||||
|
|
||||||
// ue_parse_testing();
|
|
||||||
|
|
||||||
StrC str_gasa_api = txt("GASA_API");
|
|
||||||
|
|
||||||
gen_UGasaAttributeSet();
|
gen_UGasaAttributeSet();
|
||||||
swap_SBlueprintActionMenu_Construct();
|
gen_FGasaDevOptionsCache();
|
||||||
|
|
||||||
|
// One offs
|
||||||
|
if (0)
|
||||||
|
{
|
||||||
|
ue_parse_testing();
|
||||||
|
swap_SBlueprintActionMenu_Construct();
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,95 @@
|
|||||||
#pragma once
|
// Used in the GasaGen.cpp translation unit
|
||||||
|
#if GASA_INTELLISENSE_DIRECTIVES
|
||||||
|
#pragma once
|
||||||
|
#include "gen.hpp"
|
||||||
|
#include "GasaGenCommon.cpp"
|
||||||
|
using namespace gen;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Program assumes its working directory is the project
|
// Program assumes its working directory is the project
|
||||||
#define path_config "./Source/Config/"
|
#define path_root ""
|
||||||
#define path_module_gasa "./Source/Gasa/"
|
#define path_project path_root "Project/"
|
||||||
|
#define path_source path_project "Source/"
|
||||||
|
#define path_config path_source "Config/"
|
||||||
|
#define path_module_gasa path_source "Gasa/"
|
||||||
#define path_gasa_ability_system path_module_gasa "AbilitySystem/"
|
#define path_gasa_ability_system path_module_gasa "AbilitySystem/"
|
||||||
|
|
||||||
|
constexpr StrC str_DECLARE_CLASS = txt("DECLARE_CLASS(");
|
||||||
|
constexpr StrC str_DECLARE_DELEGATE_RetVal_OneParam = txt("DECLARE_DELEGATE_RetVal_OneParam(");
|
||||||
|
constexpr StrC str_DECLARE_DELEGATE_RetVal_ThreeParams = txt("DECLARE_DELEGATE_RetVal_ThreeParams(");
|
||||||
|
constexpr StrC str_DECLARE_DELEGATE_SixParams = txt("DECLARE_DELEGATE_SixParams(");
|
||||||
|
constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams(");
|
||||||
|
constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams(");
|
||||||
|
constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams(");
|
||||||
|
constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(");
|
||||||
|
constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams(");
|
||||||
|
constexpr StrC str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams = txt("DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams(");
|
||||||
|
constexpr StrC str_DECLARE_EVENT_ThreeParams = txt("DECLARE_EVENT_ThreeParams(");
|
||||||
|
constexpr StrC str_DECLARE_EVENT_TwoParams = txt("DECLARE_EVENT_TwoParams(");
|
||||||
|
constexpr StrC str_DECLARE_FUNCTION = txt("DECLARE_FUNCTION(");
|
||||||
|
constexpr StrC str_DECLARE_LOG_CATEGORY_EXTERN = txt("DECLARE_LOG_CATEGORY_EXTERN(");
|
||||||
|
constexpr StrC str_DECLARE_MULTICAST_DELEGATE_OneParam = txt("DECLARE_MULTICAST_DELEGATE_OneParam(");
|
||||||
|
constexpr StrC str_DECLARE_MULTICAST_DELEGATE_ThreeParams = txt("DECLARE_MULTICAST_DELEGATE_ThreeParams(");
|
||||||
|
constexpr StrC str_DECLARE_MULTICAST_DELEGATE_TwoParams = txt("DECLARE_MULTICAST_DELEGATE_TwoParams(");
|
||||||
|
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_DEBUGGABLE = txt("FORCEINLINE_DEBUGGABLE");
|
||||||
|
constexpr StrC str_GENERATED_BODY = txt("GENERATED_BODY(");
|
||||||
|
constexpr StrC str_GENERATED_UCLASS_BODY = txt("GENERATED_UCLASS_BODY(");
|
||||||
|
constexpr StrC str_GENERATED_USTRUCT_BODY = txt("GENERATED_USTRUCT_BODY(");
|
||||||
|
constexpr StrC str_PRAGMA_DISABLE_DEPRECATION_WARNINGS = txt("PRAGMA_DISABLE_DEPRECATION_WARNINGS");
|
||||||
|
constexpr StrC str_PRAGMA_ENABLE_DEPRECATION_WARNINGS = txt("PRAGMA_ENABLE_DEPRECATION_WARNINGS");
|
||||||
|
constexpr StrC str_PROPERTY_BINDING_IMPLEMENTATION = txt("PROPERTY_BINDING_IMPLEMENTATION(");
|
||||||
|
constexpr StrC str_RESULT_DECL = txt("RESULT_DECL");
|
||||||
|
constexpr StrC str_SLATE_BEGIN_ARGS = txt("SLATE_BEGIN_ARGS(");
|
||||||
|
constexpr StrC str_SLATE_END_ARGS = txt("SLATE_END_ARGS(");
|
||||||
|
constexpr StrC str_TEXT = txt("TEXT(");
|
||||||
|
constexpr StrC str_UCLASS = txt("UCLASS(");
|
||||||
|
constexpr StrC str_UENUM = txt("UENUM(");
|
||||||
|
constexpr StrC str_UFUNCTION = txt("UFUNCTION(");
|
||||||
|
constexpr StrC str_UMETA = txt("UMETA(");
|
||||||
|
constexpr StrC str_UPARAM = txt("UPARAM(");
|
||||||
|
constexpr StrC str_UPROPERTY = txt("UPROPERTY(");
|
||||||
|
constexpr StrC str_USTRUCT = txt("USTRUCT(");
|
||||||
|
|
||||||
|
constexpr StrC str_GASA_API = txt("GASA_API");
|
||||||
|
|
||||||
#pragma region Globals
|
#pragma region Globals
|
||||||
// These Code objects are created before anything else after gencpp does its initializatioon
|
// These Code objects are created before anything else after gencpp does its initializatioon
|
||||||
global Code umeta_uclass;
|
global Code UHT_GENERATED_BODY;
|
||||||
global Code umeta_generated_body;
|
global Code UHT_UCLASS;
|
||||||
global Code gasa_api;
|
global Code UHT_UPROPERTY;
|
||||||
|
global Code UHT_USTRUCT;
|
||||||
|
global Code UModule_GASA_API;
|
||||||
#pragma endregion Globals
|
#pragma endregion Globals
|
||||||
|
|
||||||
|
inline
|
||||||
|
CodeBody parse_file( char const* path ) {
|
||||||
|
FileContents content = file_read_contents( GlobalAllocator, true, path );
|
||||||
|
CodeBody code = parse_global_body( StrC { content.size, (char const*)content.data });
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
void format_file( char const* path )
|
||||||
|
{
|
||||||
|
// Need to execute clang format on the generated file to get it to match the original.
|
||||||
|
#define clang_format "clang-format "
|
||||||
|
#define cf_format_inplace "-i "
|
||||||
|
#define cf_style "-style=file:" "./scripts/.clang-format "
|
||||||
|
#define cf_verbose "-verbose "
|
||||||
|
String command = String::make( GlobalAllocator, clang_format );
|
||||||
|
command.append( cf_format_inplace );
|
||||||
|
command.append( cf_style );
|
||||||
|
command.append( cf_verbose );
|
||||||
|
command.append( path );
|
||||||
|
log_fmt("\tRunning clang-format on file:\n");
|
||||||
|
system( command );
|
||||||
|
log_fmt("\tclang-format finished reformatting.\n");
|
||||||
|
#undef cf_cmd
|
||||||
|
#undef cf_format_inplace
|
||||||
|
#undef cf_style
|
||||||
|
#undef cf_verbse
|
||||||
|
}
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
// Used in the GasaGen.cpp translation unit
|
||||||
|
#if GASA_INTELLISENSE_DIRECTIVES
|
||||||
|
#pragma once
|
||||||
|
#define GEN_EXPOSE_BACKEND
|
||||||
|
#include "gen.hpp"
|
||||||
|
#include "gen.builder.hpp"
|
||||||
|
#include "GasaGenCommon.cpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
constexpr StrC SBlueprintActionMenu_Construct_Replacement = txt(R"(
|
constexpr StrC SBlueprintActionMenu_Construct_Replacement = txt(R"(
|
||||||
void SBlueprintActionMenu::Construct( const FArguments& InArgs, TSharedPtr<FBlueprintEditor> InEditor )
|
void SBlueprintActionMenu::Construct( const FArguments& InArgs, TSharedPtr<FBlueprintEditor> InEditor )
|
||||||
{
|
{
|
||||||
@ -255,19 +264,22 @@ void swap_SBlueprintActionMenu_Construct()
|
|||||||
using namespace ECode;
|
using namespace ECode;
|
||||||
case Function:
|
case Function:
|
||||||
CodeFn function_def = code.cast<CodeFn>();
|
CodeFn function_def = code.cast<CodeFn>();
|
||||||
log_fmt("%S\n", function_def->Name);
|
|
||||||
|
|
||||||
if ( String::are_equal(function_def->Name, signature_to_change->Name)
|
if ( String::are_equal(function_def->Name, signature_to_change->Name)
|
||||||
&& function_def->Params.is_equal(signature_to_change->Params))
|
&& function_def->Params.is_equal(signature_to_change->Params))
|
||||||
{
|
{
|
||||||
code = parse_function( SBlueprintActionMenu_Construct_Replacement );
|
code = parse_function( SBlueprintActionMenu_Construct_Replacement );
|
||||||
|
log_fmt("Swapped: %S", function_def->Name);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
changed_SBlueprintActionMenu.append(code);
|
changed_SBlueprintActionMenu.append(code);
|
||||||
}
|
}
|
||||||
|
log_fmt("\n");
|
||||||
|
|
||||||
Builder SBlueprintActionMenu_Changed = Builder::open(path_SBlueprintActionMenuCpp);
|
Builder SBlueprintActionMenu_Changed = Builder::open(path_SBlueprintActionMenuCpp);
|
||||||
|
SBlueprintActionMenu_Changed.print( def_comment(txt("This file was regenerated by GasaGen.cpp")));
|
||||||
SBlueprintActionMenu_Changed.print(changed_SBlueprintActionMenu);
|
SBlueprintActionMenu_Changed.print(changed_SBlueprintActionMenu);
|
||||||
SBlueprintActionMenu_Changed.write();
|
SBlueprintActionMenu_Changed.write();
|
||||||
}
|
format_file(path_SBlueprintActionMenuCpp);
|
||||||
|
}
|
||||||
|
135
Project/Source/GasaGen/GasaGen_DevOptionsCache.cpp
Normal file
135
Project/Source/GasaGen/GasaGen_DevOptionsCache.cpp
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
// Used in the GasaGen.cpp translation unit
|
||||||
|
#if GASA_INTELLISENSE_DIRECTIVES
|
||||||
|
#pragma once
|
||||||
|
#define GEN_EXPOSE_BACKEND
|
||||||
|
#include "gen.hpp"
|
||||||
|
#include "gen.builder.hpp"
|
||||||
|
#include "GasaGenCommon.cpp"
|
||||||
|
using namespace gen;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void gen_FGasaDevOptionsCache()
|
||||||
|
{
|
||||||
|
Array<CodeVar> GasaDevOptions_UPROPERTIES = Array<CodeVar>::init(GlobalAllocator);
|
||||||
|
{
|
||||||
|
CodeBody header_GasaDevOptions = parse_file( path_module_gasa "GasaDevOptions.h" );
|
||||||
|
CodeClass UGasaDevOptions = NoCode;
|
||||||
|
for (Code entry : header_GasaDevOptions)
|
||||||
|
{
|
||||||
|
if ( entry->Type == ECode::Class && entry->Name.starts_with( txt("UGasaDevOptions")) )
|
||||||
|
{
|
||||||
|
UGasaDevOptions = entry.cast<CodeClass>();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Code member = UGasaDevOptions->Body.begin(); member != UGasaDevOptions->Body.end(); ++ member)
|
||||||
|
{
|
||||||
|
if ( member->Type == ECode::Untyped && member->Name.starts_with(str_UPROPERTY) )
|
||||||
|
++ member;
|
||||||
|
if ( member->Type == ECode::Variable
|
||||||
|
&& ( member->ValueType->Name.starts_with( txt("TSoftClassPtr"))
|
||||||
|
|| member->ValueType->Name.starts_with( txt("TSoftObjectPtr")) )
|
||||||
|
)
|
||||||
|
GasaDevOptions_UPROPERTIES.append(member.cast<CodeVar>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CodeComment generation_notice = def_comment(txt("This was generated by GasaGen/GasaGen.cpp"));
|
||||||
|
|
||||||
|
Builder header = Builder::open( path_module_gasa "GasaDevOptionsCache.h" );
|
||||||
|
{
|
||||||
|
header.print( generation_notice );
|
||||||
|
header.print( pragma_once );
|
||||||
|
header.print( fmt_newline );
|
||||||
|
header.print( def_include(txt("GasaDevOptionsCache.generated.h")));
|
||||||
|
header.print( fmt_newline );
|
||||||
|
|
||||||
|
header.print( UHT_USTRUCT );
|
||||||
|
CodeStruct FGasaDevOptionsCache;
|
||||||
|
{
|
||||||
|
CodeBody body = def_body(ECode::Struct_Body);
|
||||||
|
{
|
||||||
|
CodeType t_UClassPtr = parse_type(code(UClass*));
|
||||||
|
CodeType t_UObjectPtr = parse_type(code(UObject*));
|
||||||
|
|
||||||
|
body.append(UHT_GENERATED_BODY);
|
||||||
|
body.append(fmt_newline);
|
||||||
|
for (CodeVar var : GasaDevOptions_UPROPERTIES)
|
||||||
|
{
|
||||||
|
if ( var->ValueType->Name.starts_with( txt("TSoftClassPtr") )) {
|
||||||
|
body.append(UHT_UPROPERTY);
|
||||||
|
body.append( def_variable(t_UClassPtr, var->Name));
|
||||||
|
}
|
||||||
|
if ( var->ValueType->Name.starts_with( txt("TSoftObjectPtr") )) {
|
||||||
|
body.append(UHT_UPROPERTY);
|
||||||
|
body.append( def_variable(t_UObjectPtr, var->Name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
body.append(fmt_newline);
|
||||||
|
body.append( parse_function(code( void CachedDevOptions(); )));
|
||||||
|
}
|
||||||
|
FGasaDevOptionsCache = parse_struct( token_fmt( "body", (StrC)body.to_string(), stringize(
|
||||||
|
struct GASA_API FGasaDevOptionsCache {
|
||||||
|
<body>
|
||||||
|
};
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
header.print(FGasaDevOptionsCache);
|
||||||
|
header.print( fmt_newline );
|
||||||
|
header.write();
|
||||||
|
format_file( path_module_gasa "GasaDevOptionsCache.h" );
|
||||||
|
}
|
||||||
|
|
||||||
|
Builder source = Builder::open( path_module_gasa "GasaDevOptionsCache.cpp" );
|
||||||
|
{
|
||||||
|
Array<CodeInclude> GasaDevOptions_Includes = Array<CodeInclude>::init(GlobalAllocator);
|
||||||
|
{
|
||||||
|
CodeBody source_GasaDevOptions = parse_file( path_module_gasa "GasaDevOptions.cpp");
|
||||||
|
for ( Code entry : source_GasaDevOptions )
|
||||||
|
{
|
||||||
|
if ( entry->Type == ECode::Preprocess_Include )
|
||||||
|
GasaDevOptions_Includes.append( entry.cast<CodeInclude>() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
source.print( generation_notice );
|
||||||
|
source.print( def_include(txt("GasaDevOptionsCache.h")));
|
||||||
|
source.print(fmt_newline);
|
||||||
|
for ( CodeInclude include : GasaDevOptions_Includes ) {
|
||||||
|
source.print( include );
|
||||||
|
}
|
||||||
|
source.print( parse_using(code( using namespace Gasa; )));
|
||||||
|
source.print(fmt_newline);
|
||||||
|
|
||||||
|
CodeBody cached_property_assignments = def_body(ECode::Function_Body);
|
||||||
|
{
|
||||||
|
cached_property_assignments.append(fmt_newline);
|
||||||
|
cached_property_assignments.append(fmt_newline);
|
||||||
|
for (CodeVar var : GasaDevOptions_UPROPERTIES)
|
||||||
|
{
|
||||||
|
Code assignment = code_fmt( "property", (StrC)var->Name, stringize(
|
||||||
|
<property> = DevOpts-> <property>.LoadSynchronous();
|
||||||
|
));
|
||||||
|
cached_property_assignments.append(assignment);
|
||||||
|
}
|
||||||
|
cached_property_assignments.append(fmt_newline);
|
||||||
|
cached_property_assignments.append(fmt_newline);
|
||||||
|
}
|
||||||
|
|
||||||
|
CodeFn CachedDevOptions = parse_function( token_fmt(
|
||||||
|
"cached_property_assignments", (StrC)cached_property_assignments.to_string(),
|
||||||
|
stringize(
|
||||||
|
void FGasaDevOptionsCache::CachedDevOptions()
|
||||||
|
{
|
||||||
|
UGasaDevOptions* DevOpts = GetMutDevOptions();
|
||||||
|
|
||||||
|
<cached_property_assignments>
|
||||||
|
|
||||||
|
Tag_GlobalPPV = DevOpts->Tag_GlobalPPV;
|
||||||
|
})
|
||||||
|
));
|
||||||
|
source.print(CachedDevOptions);
|
||||||
|
source.write();
|
||||||
|
format_file( path_module_gasa "GasaDevOptionsCache.cpp" );
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,11 @@
|
|||||||
// Used in the GasaGen.cpp translation unit
|
// Used in the GasaGen.cpp translation unit
|
||||||
|
#if GASA_INTELLISENSE_DIRECTIVES
|
||||||
|
#pragma once
|
||||||
|
#define GEN_EXPOSE_BACKEND
|
||||||
|
#include "gen.hpp"
|
||||||
|
#include "gen.builder.hpp"
|
||||||
|
#include "GasaGenCommon.cpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
void def_attribute_properties ( CodeBody body, Array<StringCached> properties );
|
void def_attribute_properties ( CodeBody body, Array<StringCached> properties );
|
||||||
void def_attribute_field_on_reps ( CodeBody body, Array<StringCached> properties );
|
void def_attribute_field_on_reps ( CodeBody body, Array<StringCached> properties );
|
||||||
@ -30,20 +37,20 @@ void gen_UGasaAttributeSet()
|
|||||||
CodeInclude Include_AbilitySystemComponent = def_include(txt("AbilitySystemComponent.h"));
|
CodeInclude Include_AbilitySystemComponent = def_include(txt("AbilitySystemComponent.h"));
|
||||||
CodeInclude Include_GasaAttributeSet_Generated = def_include(txt("GasaAttributeSet.generated.h"));
|
CodeInclude Include_GasaAttributeSet_Generated = def_include(txt("GasaAttributeSet.generated.h"));
|
||||||
|
|
||||||
CodeAttributes api_attribute= def_attributes( gasa_api->Name);
|
CodeAttributes api_attribute= def_attributes( UModule_GASA_API->Name);
|
||||||
|
|
||||||
CodeClass GasaAttributeSet = {};
|
CodeClass GasaAttributeSet = {};
|
||||||
{
|
{
|
||||||
CodeBody body = def_body( CodeT::Class_Body );
|
CodeBody body = def_body( CodeT::Class_Body );
|
||||||
{
|
{
|
||||||
body.append( umeta_generated_body);
|
body.append( UHT_GENERATED_BODY);
|
||||||
body.append( fmt_newline);
|
|
||||||
body.append( access_public );
|
body.append( access_public );
|
||||||
|
|
||||||
def_attribute_properties( body, attribute_fields);
|
def_attribute_properties( body, attribute_fields);
|
||||||
|
|
||||||
body.append(fmt_newline);
|
body.append(fmt_newline);
|
||||||
body.append( def_constructor() );
|
body.append( def_constructor() );
|
||||||
|
body.append(fmt_newline);
|
||||||
|
|
||||||
def_attribute_field_on_reps( body, attribute_fields);
|
def_attribute_field_on_reps( body, attribute_fields);
|
||||||
|
|
||||||
@ -90,11 +97,12 @@ void gen_UGasaAttributeSet()
|
|||||||
header.print( Include_AbilitySystemComponent);
|
header.print( Include_AbilitySystemComponent);
|
||||||
header.print( Include_GasaAttributeSet_Generated);
|
header.print( Include_GasaAttributeSet_Generated);
|
||||||
header.print( fmt_newline);
|
header.print( fmt_newline);
|
||||||
header.print(umeta_uclass);
|
header.print( UHT_UCLASS );
|
||||||
header.print(GasaAttributeSet);
|
header.print(GasaAttributeSet);
|
||||||
header.print(ns_gasa);
|
header.print(ns_gasa);
|
||||||
}
|
}
|
||||||
header.write();
|
header.write();
|
||||||
|
format_file(path_gasa_ability_system "GasaAttributeSet.h");
|
||||||
}
|
}
|
||||||
|
|
||||||
Builder source = Builder::open( path_gasa_ability_system "GasaAttributeSet.cpp" );
|
Builder source = Builder::open( path_gasa_ability_system "GasaAttributeSet.cpp" );
|
||||||
@ -119,15 +127,15 @@ void gen_UGasaAttributeSet()
|
|||||||
InitMaxMana( 50.f );
|
InitMaxMana( 50.f );
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
body.append(constructor_for_UGasaAttributeSet );
|
body.append(constructor_for_UGasaAttributeSet );
|
||||||
body.append(fmt_newline);
|
|
||||||
|
|
||||||
impl_attribute_fields( body, class_name, attribute_fields);
|
impl_attribute_fields( body, class_name, attribute_fields);
|
||||||
|
|
||||||
CodeFn GetLifetimeOfReplicatedProps;
|
CodeFn GetLifetimeOfReplicatedProps;
|
||||||
{
|
{
|
||||||
CodeBody field_lifetimes = def_body( CodeT::Function_Body);
|
CodeBody field_lifetimes = def_body( CodeT::Function_Body);
|
||||||
|
field_lifetimes.append(fmt_newline);
|
||||||
|
field_lifetimes.append(fmt_newline);
|
||||||
for (StringCached field : attribute_fields)
|
for (StringCached field : attribute_fields)
|
||||||
{
|
{
|
||||||
field_lifetimes.append( code_fmt( "field", (StrC)field, stringize(
|
field_lifetimes.append( code_fmt( "field", (StrC)field, stringize(
|
||||||
@ -148,6 +156,7 @@ void gen_UGasaAttributeSet()
|
|||||||
source.print(body);
|
source.print(body);
|
||||||
}
|
}
|
||||||
source.write();
|
source.write();
|
||||||
|
format_file(path_gasa_ability_system "GasaAttributeSet.cpp");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,12 +209,12 @@ void def_attribute_field_property_getters( CodeBody body, StrC class_name, Array
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma push_macro("FORCEINLINE")
|
||||||
|
#undef FORCEINLINE
|
||||||
void def_attribute_field_value_getters( CodeBody body, Array<StringCached> properties )
|
void def_attribute_field_value_getters( CodeBody body, Array<StringCached> properties )
|
||||||
{
|
{
|
||||||
for ( String property : properties )
|
for ( String property : properties )
|
||||||
{
|
{
|
||||||
#pragma push_macro(FORCEINLINE)
|
|
||||||
#undef FORCEINLINE
|
|
||||||
body.append( code_fmt( "property", (StrC)property,
|
body.append( code_fmt( "property", (StrC)property,
|
||||||
stringize(
|
stringize(
|
||||||
FORCEINLINE float Get<property>() const
|
FORCEINLINE float Get<property>() const
|
||||||
@ -213,7 +222,6 @@ void def_attribute_field_value_getters( CodeBody body, Array<StringCached> prope
|
|||||||
return <property>.GetCurrentValue();
|
return <property>.GetCurrentValue();
|
||||||
}
|
}
|
||||||
)));
|
)));
|
||||||
#pragma pop_macro(FORCEINLINE)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,3 +275,4 @@ void impl_attribute_fields( CodeBody body, StrC class_name, Array<StringCached>
|
|||||||
body.append( field_impl );
|
body.append( field_impl );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma pop_macro("FORCEINLINE")
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
// Used in the GasaGen.cpp translation unit
|
||||||
|
#if GASA_INTELLISENSE_DIRECTIVES
|
||||||
|
#pragma once
|
||||||
|
#define GEN_EXPOSE_BACKEND
|
||||||
|
#include "gen.hpp"
|
||||||
|
#include "gen.builder.hpp"
|
||||||
|
#include "GasaGenCommon.cpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
void ue_parse_testing()
|
void ue_parse_testing()
|
||||||
{
|
{
|
||||||
FileContents content;
|
FileContents content;
|
||||||
@ -5,7 +14,7 @@ void ue_parse_testing()
|
|||||||
#define path_UProgressBar \
|
#define path_UProgressBar \
|
||||||
"C:/projects/Unreal/Surgo/UE/Engine/Source/Runtime/UMG/Public/Components/ProgressBar.h"
|
"C:/projects/Unreal/Surgo/UE/Engine/Source/Runtime/UMG/Public/Components/ProgressBar.h"
|
||||||
|
|
||||||
#if 0
|
#if 1
|
||||||
content = file_read_contents( GlobalAllocator, true, path_UProgressBar );
|
content = file_read_contents( GlobalAllocator, true, path_UProgressBar );
|
||||||
CodeBody parsed_uprogressbar = parse_global_body( StrC { content.size, (char const*)content.data });
|
CodeBody parsed_uprogressbar = parse_global_body( StrC { content.size, (char const*)content.data });
|
||||||
|
|
||||||
@ -40,7 +49,7 @@ void ue_parse_testing()
|
|||||||
#define path_UObject \
|
#define path_UObject \
|
||||||
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Runtime\CoreUObject\Public\UObject\Object.h)"
|
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Runtime\CoreUObject\Public\UObject\Object.h)"
|
||||||
|
|
||||||
#if 0
|
#if 1
|
||||||
content = file_read_contents( GlobalAllocator, true, path_UObject );
|
content = file_read_contents( GlobalAllocator, true, path_UObject );
|
||||||
CodeBody parsed_uobject = parse_global_body( StrC { content.size, (char const*)content.data });
|
CodeBody parsed_uobject = parse_global_body( StrC { content.size, (char const*)content.data });
|
||||||
|
|
||||||
@ -78,7 +87,7 @@ void ue_parse_testing()
|
|||||||
#define path_AActor \
|
#define path_AActor \
|
||||||
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Runtime\Engine\Classes\GameFramework\Actor.h)"
|
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Runtime\Engine\Classes\GameFramework\Actor.h)"
|
||||||
|
|
||||||
#if 0
|
#if 1
|
||||||
content = file_read_contents( GlobalAllocator, true, path_AActor );
|
content = file_read_contents( GlobalAllocator, true, path_AActor );
|
||||||
CodeBody parsed_aactor = parse_global_body( StrC { content.size, (char const*)content.data });
|
CodeBody parsed_aactor = parse_global_body( StrC { content.size, (char const*)content.data });
|
||||||
|
|
||||||
@ -112,7 +121,7 @@ void ue_parse_testing()
|
|||||||
#define path_ActorComponent \
|
#define path_ActorComponent \
|
||||||
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Runtime\Engine\Classes\Components\ActorComponent.h)"
|
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Runtime\Engine\Classes\Components\ActorComponent.h)"
|
||||||
|
|
||||||
#if 0
|
#if 1
|
||||||
content = file_read_contents( GlobalAllocator, true, path_ActorComponent );
|
content = file_read_contents( GlobalAllocator, true, path_ActorComponent );
|
||||||
CodeBody parsed_actor_component = parse_global_body( StrC { content.size, (char const*)content.data });
|
CodeBody parsed_actor_component = parse_global_body( StrC { content.size, (char const*)content.data });
|
||||||
|
|
||||||
@ -146,7 +155,7 @@ void ue_parse_testing()
|
|||||||
#define path_SceneComponent \
|
#define path_SceneComponent \
|
||||||
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Runtime\Engine\Classes\Components\SceneComponent.h)"
|
R"(C:\projects\Unreal\Surgo\UE\Engine\Source\Runtime\Engine\Classes\Components\SceneComponent.h)"
|
||||||
|
|
||||||
#if 0
|
#if 1
|
||||||
content = file_read_contents( GlobalAllocator, true, path_SceneComponent );
|
content = file_read_contents( GlobalAllocator, true, path_SceneComponent );
|
||||||
CodeBody parsed_scene_component = parse_global_body( StrC { content.size, (char const*)content.data });
|
CodeBody parsed_scene_component = parse_global_body( StrC { content.size, (char const*)content.data });
|
||||||
|
|
||||||
@ -180,7 +189,7 @@ void ue_parse_testing()
|
|||||||
#define path_AttributeSet \
|
#define path_AttributeSet \
|
||||||
R"(C:\projects\Unreal\Surgo\UE\Engine\Plugins\Runtime\GameplayAbilities\Source\GameplayAbilities\Public\AttributeSet.h)"
|
R"(C:\projects\Unreal\Surgo\UE\Engine\Plugins\Runtime\GameplayAbilities\Source\GameplayAbilities\Public\AttributeSet.h)"
|
||||||
|
|
||||||
#if 0
|
#if 1
|
||||||
content = file_read_contents( GlobalAllocator, true, path_AttributeSet );
|
content = file_read_contents( GlobalAllocator, true, path_AttributeSet );
|
||||||
CodeBody parsed_attribute_set = parse_global_body( StrC { content.size, (char const*)content.data });
|
CodeBody parsed_attribute_set = parse_global_body( StrC { content.size, (char const*)content.data });
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ Builder Builder::open( char const* path )
|
|||||||
log_failure( "gen::File::open - Could not open file: %s", path );
|
log_failure( "gen::File::open - Could not open file: %s", path );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Buffer = String::make_reserve( GlobalAllocator, Builder_StrBufferReserve );
|
result.Buffer = String::make_reserve( GlobalAllocator, Builder_StrBufferReserve );
|
||||||
|
|
||||||
// log_fmt("$Builder - Opened file: %s\n", result.File.filename );
|
// log_fmt("$Builder - Opened file: %s\n", result.File.filename );
|
||||||
@ -37,7 +36,7 @@ void Builder::print( Code code )
|
|||||||
void Builder::print_fmt( char const* fmt, ... )
|
void Builder::print_fmt( char const* fmt, ... )
|
||||||
{
|
{
|
||||||
sw res;
|
sw res;
|
||||||
char buf[ GEN_PRINTF_MAXLEN ] = { 0 };
|
char buf[GEN_PRINTF_MAXLEN] = { 0 };
|
||||||
|
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start( va, fmt );
|
va_start( va, fmt );
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -192,7 +192,7 @@ s64 str_to_i64( const char* str, char** end_ptr, s32 base )
|
|||||||
|
|
||||||
len = _scan_zpl_i64( str, base, &value );
|
len = _scan_zpl_i64( str, base, &value );
|
||||||
if ( end_ptr )
|
if ( end_ptr )
|
||||||
*end_ptr = ( char* )str + len;
|
*end_ptr = (char*)str + len;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ void i64_to_str( s64 value, char* string, s32 base )
|
|||||||
{
|
{
|
||||||
while ( v > 0 )
|
while ( v > 0 )
|
||||||
{
|
{
|
||||||
*buf++ = _num_to_char_table[ v % base ];
|
*buf++ = _num_to_char_table[v % base];
|
||||||
v /= base;
|
v /= base;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -235,7 +235,7 @@ void u64_to_str( u64 value, char* string, s32 base )
|
|||||||
{
|
{
|
||||||
while ( value > 0 )
|
while ( value > 0 )
|
||||||
{
|
{
|
||||||
*buf++ = _num_to_char_table[ value % base ];
|
*buf++ = _num_to_char_table[value % base];
|
||||||
value /= base;
|
value /= base;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -442,8 +442,8 @@ internal sw _print_string( char* text, sw max_len, _format_info* info, char cons
|
|||||||
|
|
||||||
internal sw _print_char( char* text, sw max_len, _format_info* info, char arg )
|
internal sw _print_char( char* text, sw max_len, _format_info* info, char arg )
|
||||||
{
|
{
|
||||||
char str[ 2 ] = "";
|
char str[2] = "";
|
||||||
str[ 0 ] = arg;
|
str[0] = arg;
|
||||||
return _print_string( text, max_len, info, str );
|
return _print_string( text, max_len, info, str );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -460,14 +460,14 @@ internal sw _print_repeated_char( char* text, sw max_len, _format_info* info, ch
|
|||||||
|
|
||||||
internal sw _print_i64( char* text, sw max_len, _format_info* info, s64 value )
|
internal sw _print_i64( char* text, sw max_len, _format_info* info, s64 value )
|
||||||
{
|
{
|
||||||
char num[ 130 ];
|
char num[130];
|
||||||
i64_to_str( value, num, info ? info->base : 10 );
|
i64_to_str( value, num, info ? info->base : 10 );
|
||||||
return _print_string( text, max_len, info, num );
|
return _print_string( text, max_len, info, num );
|
||||||
}
|
}
|
||||||
|
|
||||||
internal sw _print_u64( char* text, sw max_len, _format_info* info, u64 value )
|
internal sw _print_u64( char* text, sw max_len, _format_info* info, u64 value )
|
||||||
{
|
{
|
||||||
char num[ 130 ];
|
char num[130];
|
||||||
u64_to_str( value, num, info ? info->base : 10 );
|
u64_to_str( value, num, info ? info->base : 10 );
|
||||||
return _print_string( text, max_len, info, num );
|
return _print_string( text, max_len, info, num );
|
||||||
}
|
}
|
||||||
@ -564,7 +564,7 @@ internal sw _print_f64( char* text, sw max_len, _format_info* info, b32 is_hexad
|
|||||||
while ( len-- )
|
while ( len-- )
|
||||||
{
|
{
|
||||||
if ( text_begin + len < end )
|
if ( text_begin + len < end )
|
||||||
text_begin[ len ] = fill;
|
text_begin[len] = fill;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -857,7 +857,7 @@ neverinline sw str_fmt_va( char* text, sw max_len, char const* fmt, va_list va )
|
|||||||
|
|
||||||
char* str_fmt_buf_va( char const* fmt, va_list va )
|
char* str_fmt_buf_va( char const* fmt, va_list va )
|
||||||
{
|
{
|
||||||
local_persist thread_local char buffer[ GEN_PRINTF_MAXLEN ];
|
local_persist thread_local char buffer[GEN_PRINTF_MAXLEN];
|
||||||
str_fmt_va( buffer, size_of( buffer ), fmt, va );
|
str_fmt_va( buffer, size_of( buffer ), fmt, va );
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
@ -874,7 +874,7 @@ char* str_fmt_buf( char const* fmt, ... )
|
|||||||
|
|
||||||
sw str_fmt_file_va( struct FileInfo* f, char const* fmt, va_list va )
|
sw str_fmt_file_va( struct FileInfo* f, char const* fmt, va_list va )
|
||||||
{
|
{
|
||||||
local_persist thread_local char buf[ GEN_PRINTF_MAXLEN ];
|
local_persist thread_local char buf[GEN_PRINTF_MAXLEN];
|
||||||
sw len = str_fmt_va( buf, size_of( buf ), fmt, va );
|
sw len = str_fmt_va( buf, size_of( buf ), fmt, va );
|
||||||
b32 res = file_write( f, buf, len - 1 ); // NOTE: prevent extra whitespace
|
b32 res = file_write( f, buf, len - 1 ); // NOTE: prevent extra whitespace
|
||||||
return res ? len : -1;
|
return res ? len : -1;
|
||||||
@ -924,7 +924,7 @@ sw str_fmt_out_err( char const* fmt, ... )
|
|||||||
|
|
||||||
#pragma region Hashing
|
#pragma region Hashing
|
||||||
|
|
||||||
global u32 const _crc32_table[ 256 ] = {
|
global u32 const _crc32_table[256] = {
|
||||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b,
|
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b,
|
||||||
0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0,
|
0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0,
|
||||||
0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd,
|
0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd,
|
||||||
@ -953,11 +953,11 @@ u32 crc32( void const* data, sw len )
|
|||||||
u32 result = ~( zpl_cast( u32 ) 0 );
|
u32 result = ~( zpl_cast( u32 ) 0 );
|
||||||
u8 const* c = zpl_cast( u8 const* ) data;
|
u8 const* c = zpl_cast( u8 const* ) data;
|
||||||
for ( remaining = len; remaining--; c++ )
|
for ( remaining = len; remaining--; c++ )
|
||||||
result = ( result >> 8 ) ^ ( _crc32_table[ ( result ^ *c ) & 0xff ] );
|
result = ( result >> 8 ) ^ ( _crc32_table[( result ^ *c ) & 0xff] );
|
||||||
return ~result;
|
return ~result;
|
||||||
}
|
}
|
||||||
|
|
||||||
global u64 const _crc64_table[ 256 ] = {
|
global u64 const _crc64_table[256] = {
|
||||||
0x0000000000000000ull, 0x7ad870c830358979ull, 0xf5b0e190606b12f2ull, 0x8f689158505e9b8bull, 0xc038e5739841b68full, 0xbae095bba8743ff6ull,
|
0x0000000000000000ull, 0x7ad870c830358979ull, 0xf5b0e190606b12f2ull, 0x8f689158505e9b8bull, 0xc038e5739841b68full, 0xbae095bba8743ff6ull,
|
||||||
0x358804e3f82aa47dull, 0x4f50742bc81f2d04ull, 0xab28ecb46814fe75ull, 0xd1f09c7c5821770cull, 0x5e980d24087fec87ull, 0x24407dec384a65feull,
|
0x358804e3f82aa47dull, 0x4f50742bc81f2d04ull, 0xab28ecb46814fe75ull, 0xd1f09c7c5821770cull, 0x5e980d24087fec87ull, 0x24407dec384a65feull,
|
||||||
0x6b1009c7f05548faull, 0x11c8790fc060c183ull, 0x9ea0e857903e5a08ull, 0xe478989fa00bd371ull, 0x7d08ff3b88be6f81ull, 0x07d08ff3b88be6f8ull,
|
0x6b1009c7f05548faull, 0x11c8790fc060c183ull, 0x9ea0e857903e5a08ull, 0xe478989fa00bd371ull, 0x7d08ff3b88be6f81ull, 0x07d08ff3b88be6f8ull,
|
||||||
@ -1009,7 +1009,7 @@ u64 crc64( void const* data, sw len )
|
|||||||
u64 result = ( zpl_cast( u64 ) 0 );
|
u64 result = ( zpl_cast( u64 ) 0 );
|
||||||
u8 const* c = zpl_cast( u8 const* ) data;
|
u8 const* c = zpl_cast( u8 const* ) data;
|
||||||
for ( remaining = len; remaining--; c++ )
|
for ( remaining = len; remaining--; c++ )
|
||||||
result = ( result >> 8 ) ^ ( _crc64_table[ ( result ^ *c ) & 0xff ] );
|
result = ( result >> 8 ) ^ ( _crc64_table[( result ^ *c ) & 0xff] );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1363,7 +1363,7 @@ void* Arena::allocator_proc( void* allocator_data, AllocType type, sw size, sw a
|
|||||||
sw total_size = align_forward_i64( size, alignment );
|
sw total_size = align_forward_i64( size, alignment );
|
||||||
|
|
||||||
// NOTE: Out of memory
|
// NOTE: Out of memory
|
||||||
if ( arena->TotalUsed + total_size > ( sw )arena->TotalSize )
|
if ( arena->TotalUsed + total_size > (sw)arena->TotalSize )
|
||||||
{
|
{
|
||||||
// zpl__printf_err("%s", "Arena out of memory\n");
|
// zpl__printf_err("%s", "Arena out of memory\n");
|
||||||
GEN_FATAL( "Arena out of memory! (Possibly could not fit for the largest size Arena!!)" );
|
GEN_FATAL( "Arena out of memory! (Possibly could not fit for the largest size Arena!!)" );
|
||||||
@ -1495,13 +1495,13 @@ Pool Pool::init_align( AllocatorInfo backing, sw num_blocks, sw block_size, sw b
|
|||||||
curr = data;
|
curr = data;
|
||||||
for ( block_index = 0; block_index < num_blocks - 1; block_index++ )
|
for ( block_index = 0; block_index < num_blocks - 1; block_index++ )
|
||||||
{
|
{
|
||||||
uptr* next = ( uptr* )curr;
|
uptr* next = (uptr*)curr;
|
||||||
*next = ( uptr )curr + actual_block_size;
|
*next = (uptr)curr + actual_block_size;
|
||||||
curr = pointer_add( curr, actual_block_size );
|
curr = pointer_add( curr, actual_block_size );
|
||||||
}
|
}
|
||||||
|
|
||||||
end = ( uptr* )curr;
|
end = (uptr*)curr;
|
||||||
*end = ( uptr )NULL;
|
*end = (uptr)NULL;
|
||||||
|
|
||||||
pool.PhysicalStart = data;
|
pool.PhysicalStart = data;
|
||||||
pool.FreeList = data;
|
pool.FreeList = data;
|
||||||
@ -1520,13 +1520,13 @@ void Pool::clear()
|
|||||||
curr = PhysicalStart;
|
curr = PhysicalStart;
|
||||||
for ( block_index = 0; block_index < NumBlocks - 1; block_index++ )
|
for ( block_index = 0; block_index < NumBlocks - 1; block_index++ )
|
||||||
{
|
{
|
||||||
uptr* next = ( uptr* )curr;
|
uptr* next = (uptr*)curr;
|
||||||
*next = ( uptr )curr + actual_block_size;
|
*next = (uptr)curr + actual_block_size;
|
||||||
curr = pointer_add( curr, actual_block_size );
|
curr = pointer_add( curr, actual_block_size );
|
||||||
}
|
}
|
||||||
|
|
||||||
end = ( uptr* )curr;
|
end = (uptr*)curr;
|
||||||
*end = ( uptr )NULL;
|
*end = (uptr)NULL;
|
||||||
|
|
||||||
FreeList = PhysicalStart;
|
FreeList = PhysicalStart;
|
||||||
}
|
}
|
||||||
@ -1565,7 +1565,7 @@ String String::make_length( AllocatorInfo allocator, char const* str, sw length
|
|||||||
else
|
else
|
||||||
mem_set( result, 0, alloc_size - header_size );
|
mem_set( result, 0, alloc_size - header_size );
|
||||||
|
|
||||||
result[ length ] = '\0';
|
result[length] = '\0';
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1593,7 +1593,7 @@ String String::make_reserve( AllocatorInfo allocator, sw capacity )
|
|||||||
|
|
||||||
String String::fmt_buf( AllocatorInfo allocator, char const* fmt, ... )
|
String String::fmt_buf( AllocatorInfo allocator, char const* fmt, ... )
|
||||||
{
|
{
|
||||||
local_persist thread_local char buf[ GEN_PRINTF_MAXLEN ] = { 0 };
|
local_persist thread_local char buf[GEN_PRINTF_MAXLEN] = { 0 };
|
||||||
|
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start( va, fmt );
|
va_start( va, fmt );
|
||||||
@ -1606,7 +1606,7 @@ String String::fmt_buf( AllocatorInfo allocator, char const* fmt, ... )
|
|||||||
bool String::append_fmt( char const* fmt, ... )
|
bool String::append_fmt( char const* fmt, ... )
|
||||||
{
|
{
|
||||||
sw res;
|
sw res;
|
||||||
char buf[ GEN_PRINTF_MAXLEN ] = { 0 };
|
char buf[GEN_PRINTF_MAXLEN] = { 0 };
|
||||||
|
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start( va, fmt );
|
va_start( va, fmt );
|
||||||
@ -1694,7 +1694,7 @@ internal wchar_t* _alloc_utf8_to_ucs2( AllocatorInfo a, char const* text, sw* w_
|
|||||||
*w_len_ = 0;
|
*w_len_ = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
w_text[ w_len ] = 0;
|
w_text[w_len] = 0;
|
||||||
if ( w_len_ )
|
if ( w_len_ )
|
||||||
*w_len_ = w_len;
|
*w_len_ = w_len;
|
||||||
return w_text;
|
return w_text;
|
||||||
@ -1928,8 +1928,8 @@ neverinline GEN_FILE_OPEN_PROC( _posix_file_open )
|
|||||||
internal void _dirinfo_free_entry( DirEntry* entry );
|
internal void _dirinfo_free_entry( DirEntry* entry );
|
||||||
|
|
||||||
// TODO : Is this a bad idea?
|
// TODO : Is this a bad idea?
|
||||||
global b32 _std_file_set = false;
|
global b32 _std_file_set = false;
|
||||||
global FileInfo _std_files[ EFileStandard_COUNT ] = {
|
global FileInfo _std_files[EFileStandard_COUNT] = {
|
||||||
{ { nullptr, nullptr, nullptr, nullptr }, { nullptr }, 0, nullptr, 0, nullptr }
|
{ { nullptr, nullptr, nullptr, nullptr }, { nullptr }, 0, nullptr, 0, nullptr }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1940,15 +1940,15 @@ FileInfo* file_get_standard( FileStandardType std )
|
|||||||
if ( ! _std_file_set )
|
if ( ! _std_file_set )
|
||||||
{
|
{
|
||||||
#define GEN__SET_STD_FILE( type, v ) \
|
#define GEN__SET_STD_FILE( type, v ) \
|
||||||
_std_files[ type ].fd.p = v; \
|
_std_files[type].fd.p = v; \
|
||||||
_std_files[ type ].ops = default_file_operations
|
_std_files[type].ops = default_file_operations
|
||||||
GEN__SET_STD_FILE( EFileStandard_INPUT, GetStdHandle( STD_INPUT_HANDLE ) );
|
GEN__SET_STD_FILE( EFileStandard_INPUT, GetStdHandle( STD_INPUT_HANDLE ) );
|
||||||
GEN__SET_STD_FILE( EFileStandard_OUTPUT, GetStdHandle( STD_OUTPUT_HANDLE ) );
|
GEN__SET_STD_FILE( EFileStandard_OUTPUT, GetStdHandle( STD_OUTPUT_HANDLE ) );
|
||||||
GEN__SET_STD_FILE( EFileStandard_ERROR, GetStdHandle( STD_ERROR_HANDLE ) );
|
GEN__SET_STD_FILE( EFileStandard_ERROR, GetStdHandle( STD_ERROR_HANDLE ) );
|
||||||
#undef GEN__SET_STD_FILE
|
#undef GEN__SET_STD_FILE
|
||||||
_std_file_set = true;
|
_std_file_set = true;
|
||||||
}
|
}
|
||||||
return &_std_files[ std ];
|
return &_std_files[std];
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // POSIX
|
#else // POSIX
|
||||||
@ -1958,15 +1958,15 @@ FileInfo* file_get_standard( FileStandardType std )
|
|||||||
if ( ! _std_file_set )
|
if ( ! _std_file_set )
|
||||||
{
|
{
|
||||||
#define GEN__SET_STD_FILE( type, v ) \
|
#define GEN__SET_STD_FILE( type, v ) \
|
||||||
_std_files[ type ].fd.i = v; \
|
_std_files[type].fd.i = v; \
|
||||||
_std_files[ type ].ops = default_file_operations
|
_std_files[type].ops = default_file_operations
|
||||||
GEN__SET_STD_FILE( EFileStandard_INPUT, 0 );
|
GEN__SET_STD_FILE( EFileStandard_INPUT, 0 );
|
||||||
GEN__SET_STD_FILE( EFileStandard_OUTPUT, 1 );
|
GEN__SET_STD_FILE( EFileStandard_OUTPUT, 1 );
|
||||||
GEN__SET_STD_FILE( EFileStandard_ERROR, 2 );
|
GEN__SET_STD_FILE( EFileStandard_ERROR, 2 );
|
||||||
#undef GEN__SET_STD_FILE
|
#undef GEN__SET_STD_FILE
|
||||||
_std_file_set = true;
|
_std_file_set = true;
|
||||||
}
|
}
|
||||||
return &_std_files[ std ];
|
return &_std_files[std];
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -2082,8 +2082,8 @@ FileContents file_read_contents( AllocatorInfo a, b32 zero_terminate, char const
|
|||||||
file_read_at( &file, result.data, result.size, 0 );
|
file_read_at( &file, result.data, result.size, 0 );
|
||||||
if ( zero_terminate )
|
if ( zero_terminate )
|
||||||
{
|
{
|
||||||
u8* str = zpl_cast( u8* ) result.data;
|
u8* str = zpl_cast( u8* ) result.data;
|
||||||
str[ fsize ] = '\0';
|
str[fsize] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_close( &file );
|
file_close( &file );
|
||||||
@ -2111,13 +2111,13 @@ GEN_DEF_INLINE _memory_fd* _file_stream_from_fd( FileDescriptor fd );
|
|||||||
GEN_IMPL_INLINE FileDescriptor _file_stream_fd_make( _memory_fd* d )
|
GEN_IMPL_INLINE FileDescriptor _file_stream_fd_make( _memory_fd* d )
|
||||||
{
|
{
|
||||||
FileDescriptor fd = { 0 };
|
FileDescriptor fd = { 0 };
|
||||||
fd.p = ( void* )d;
|
fd.p = (void*)d;
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
GEN_IMPL_INLINE _memory_fd* _file_stream_from_fd( FileDescriptor fd )
|
GEN_IMPL_INLINE _memory_fd* _file_stream_from_fd( FileDescriptor fd )
|
||||||
{
|
{
|
||||||
_memory_fd* d = ( _memory_fd* )fd.p;
|
_memory_fd* d = (_memory_fd*)fd.p;
|
||||||
GEN_ASSERT( d->magic == GEN__FILE_STREAM_FD_MAGIC );
|
GEN_ASSERT( d->magic == GEN__FILE_STREAM_FD_MAGIC );
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
@ -2126,7 +2126,7 @@ b8 file_stream_new( FileInfo* file, AllocatorInfo allocator )
|
|||||||
{
|
{
|
||||||
GEN_ASSERT_NOT_NULL( file );
|
GEN_ASSERT_NOT_NULL( file );
|
||||||
|
|
||||||
_memory_fd* d = ( _memory_fd* )alloc( allocator, size_of( _memory_fd ) );
|
_memory_fd* d = (_memory_fd*)alloc( allocator, size_of( _memory_fd ) );
|
||||||
|
|
||||||
if ( ! d )
|
if ( ! d )
|
||||||
return false;
|
return false;
|
||||||
@ -2136,7 +2136,7 @@ b8 file_stream_new( FileInfo* file, AllocatorInfo allocator )
|
|||||||
d->allocator = allocator;
|
d->allocator = allocator;
|
||||||
d->flags = EFileStream_CLONE_WRITABLE;
|
d->flags = EFileStream_CLONE_WRITABLE;
|
||||||
d->cap = 0;
|
d->cap = 0;
|
||||||
d->buf = Array< u8 >::init( allocator );
|
d->buf = Array<u8>::init( allocator );
|
||||||
|
|
||||||
if ( ! d->buf )
|
if ( ! d->buf )
|
||||||
return false;
|
return false;
|
||||||
@ -2153,7 +2153,7 @@ b8 file_stream_new( FileInfo* file, AllocatorInfo allocator )
|
|||||||
b8 file_stream_open( FileInfo* file, AllocatorInfo allocator, u8* buffer, sw size, FileStreamFlags flags )
|
b8 file_stream_open( FileInfo* file, AllocatorInfo allocator, u8* buffer, sw size, FileStreamFlags flags )
|
||||||
{
|
{
|
||||||
GEN_ASSERT_NOT_NULL( file );
|
GEN_ASSERT_NOT_NULL( file );
|
||||||
_memory_fd* d = ( _memory_fd* )alloc( allocator, size_of( _memory_fd ) );
|
_memory_fd* d = (_memory_fd*)alloc( allocator, size_of( _memory_fd ) );
|
||||||
if ( ! d )
|
if ( ! d )
|
||||||
return false;
|
return false;
|
||||||
zero_item( file );
|
zero_item( file );
|
||||||
@ -2162,8 +2162,8 @@ b8 file_stream_open( FileInfo* file, AllocatorInfo allocator, u8* buffer, sw siz
|
|||||||
d->flags = flags;
|
d->flags = flags;
|
||||||
if ( d->flags & EFileStream_CLONE_WRITABLE )
|
if ( d->flags & EFileStream_CLONE_WRITABLE )
|
||||||
{
|
{
|
||||||
Array< u8 > arr = Array< u8 >::init_reserve( allocator, size );
|
Array<u8> arr = Array<u8>::init_reserve( allocator, size );
|
||||||
d->buf = arr;
|
d->buf = arr;
|
||||||
|
|
||||||
if ( ! d->buf )
|
if ( ! d->buf )
|
||||||
return false;
|
return false;
|
||||||
@ -2236,11 +2236,11 @@ internal GEN_FILE_WRITE_AT_PROC( _memory_file_write )
|
|||||||
|
|
||||||
if ( d->flags & EFileStream_CLONE_WRITABLE )
|
if ( d->flags & EFileStream_CLONE_WRITABLE )
|
||||||
{
|
{
|
||||||
Array< u8 > arr = { d->buf };
|
Array<u8> arr = { d->buf };
|
||||||
|
|
||||||
if ( arr.get_header()->Capacity < new_cap )
|
if ( arr.get_header()->Capacity < new_cap )
|
||||||
{
|
{
|
||||||
if ( ! arr.grow( ( s64 )( new_cap ) ) )
|
if ( ! arr.grow( (s64)( new_cap ) ) )
|
||||||
return false;
|
return false;
|
||||||
d->buf = arr;
|
d->buf = arr;
|
||||||
}
|
}
|
||||||
@ -2250,7 +2250,7 @@ internal GEN_FILE_WRITE_AT_PROC( _memory_file_write )
|
|||||||
|
|
||||||
if ( ( d->flags & EFileStream_CLONE_WRITABLE ) && extralen > 0 )
|
if ( ( d->flags & EFileStream_CLONE_WRITABLE ) && extralen > 0 )
|
||||||
{
|
{
|
||||||
Array< u8 > arr = { d->buf };
|
Array<u8> arr = { d->buf };
|
||||||
|
|
||||||
mem_copy( d->buf + offset + rwlen, pointer_add_const( buffer, rwlen ), extralen );
|
mem_copy( d->buf + offset + rwlen, pointer_add_const( buffer, rwlen ), extralen );
|
||||||
d->cap = new_cap;
|
d->cap = new_cap;
|
||||||
@ -2273,7 +2273,7 @@ internal GEN_FILE_CLOSE_PROC( _memory_file_close )
|
|||||||
|
|
||||||
if ( d->flags & EFileStream_CLONE_WRITABLE )
|
if ( d->flags & EFileStream_CLONE_WRITABLE )
|
||||||
{
|
{
|
||||||
Array< u8 > arr = { d->buf };
|
Array<u8> arr = { d->buf };
|
||||||
arr.free();
|
arr.free();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2329,7 +2329,7 @@ u64 read_cpu_time_stamp_counter( void )
|
|||||||
#elif defined( GEN_SYSTEM_EMSCRIPTEN )
|
#elif defined( GEN_SYSTEM_EMSCRIPTEN )
|
||||||
u64 read_cpu_time_stamp_counter( void )
|
u64 read_cpu_time_stamp_counter( void )
|
||||||
{
|
{
|
||||||
return ( u64 )( emscripten_get_now() * 1e+6 );
|
return (u64)( emscripten_get_now() * 1e+6 );
|
||||||
}
|
}
|
||||||
#elif defined( GEN_CPU_ARM ) && ! defined( GEN_COMPILER_TINYC )
|
#elif defined( GEN_CPU_ARM ) && ! defined( GEN_COMPILER_TINYC )
|
||||||
u64 read_cpu_time_stamp_counter( void )
|
u64 read_cpu_time_stamp_counter( void )
|
||||||
@ -2352,7 +2352,7 @@ u64 read_cpu_time_stamp_counter( void )
|
|||||||
{ // Is it counting?
|
{ // Is it counting?
|
||||||
asm volatile( "mrc p15, 0, %0, c9, c13, 0" : "=r"( pmccntr ) );
|
asm volatile( "mrc p15, 0, %0, c9, c13, 0" : "=r"( pmccntr ) );
|
||||||
// The counter is set up to count every 64th cycle
|
// The counter is set up to count every 64th cycle
|
||||||
return ( ( int64_t )pmccntr ) * 64; // Should optimize to << 6
|
return ( (int64_t)pmccntr ) * 64; // Should optimize to << 6
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -2441,7 +2441,7 @@ u64 time_rel_ms( void )
|
|||||||
|
|
||||||
f64 time_rel( void )
|
f64 time_rel( void )
|
||||||
{
|
{
|
||||||
return ( f64 )( time_rel_ms() * 1e-3 );
|
return (f64)( time_rel_ms() * 1e-3 );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -170,10 +170,10 @@ GEN_NS_BEGIN
|
|||||||
|
|
||||||
// Casting
|
// Casting
|
||||||
|
|
||||||
#define ccast( Type, Value ) ( *const_cast< Type* >( &( Value ) ) )
|
#define ccast( Type, Value ) ( *const_cast<Type*>( &( Value ) ) )
|
||||||
#define pcast( Type, Value ) ( *reinterpret_cast< Type* >( &( Value ) ) )
|
#define pcast( Type, Value ) ( *reinterpret_cast<Type*>( &( Value ) ) )
|
||||||
#define rcast( Type, Value ) reinterpret_cast< Type >( Value )
|
#define rcast( Type, Value ) reinterpret_cast<Type>( Value )
|
||||||
#define scast( Type, Value ) static_cast< Type >( Value )
|
#define scast( Type, Value ) static_cast<Type>( Value )
|
||||||
|
|
||||||
// Num Arguments (Varadics)
|
// Num Arguments (Varadics)
|
||||||
// #if defined(__GNUC__) || defined(__clang__)
|
// #if defined(__GNUC__) || defined(__clang__)
|
||||||
@ -461,19 +461,19 @@ GEN_NS_BEGIN
|
|||||||
#define labeled_scope_end }
|
#define labeled_scope_end }
|
||||||
|
|
||||||
#define clamp( x, lower, upper ) min( max( ( x ), ( lower ) ), ( upper ) )
|
#define clamp( x, lower, upper ) min( max( ( x ), ( lower ) ), ( upper ) )
|
||||||
#define count_of( x ) ( ( size_of( x ) / size_of( 0 [ x ] ) ) / ( ( sw )( ! ( size_of( x ) % size_of( 0 [ x ] ) ) ) ) )
|
#define count_of( x ) ( ( size_of( x ) / size_of( 0 [x] ) ) / ( (sw)( ! ( size_of( x ) % size_of( 0 [x] ) ) ) ) )
|
||||||
#define is_between( x, lower, upper ) ( ( ( lower ) <= ( x ) ) && ( ( x ) <= ( upper ) ) )
|
#define is_between( x, lower, upper ) ( ( ( lower ) <= ( x ) ) && ( ( x ) <= ( upper ) ) )
|
||||||
#define max( a, b ) ( ( a ) > ( b ) ? ( a ) : ( b ) )
|
#define max( a, b ) ( ( a ) > ( b ) ? ( a ) : ( b ) )
|
||||||
#define min( a, b ) ( ( a ) < ( b ) ? ( a ) : ( b ) )
|
#define min( a, b ) ( ( a ) < ( b ) ? ( a ) : ( b ) )
|
||||||
#define size_of( x ) ( sw )( sizeof( x ) )
|
#define size_of( x ) ( sw )( sizeof( x ) )
|
||||||
|
|
||||||
#if defined( _MSC_VER ) || defined( GEN_COMPILER_TINYC )
|
#if defined( _MSC_VER ) || defined( GEN_COMPILER_TINYC )
|
||||||
#define offset_of( Type, element ) ( ( GEN_NS( gen_sw ) ) & ( ( ( Type* )0 )->element ) )
|
#define offset_of( Type, element ) ( ( GEN_NS( gen_sw ) ) & ( ( (Type*)0 )->element ) )
|
||||||
#else
|
#else
|
||||||
#define offset_of( Type, element ) __builtin_offsetof( Type, element )
|
#define offset_of( Type, element ) __builtin_offsetof( Type, element )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template< class Type >
|
template<class Type>
|
||||||
void swap( Type& a, Type& b )
|
void swap( Type& a, Type& b )
|
||||||
{
|
{
|
||||||
Type tmp = a;
|
Type tmp = a;
|
||||||
@ -640,13 +640,13 @@ s32 assert_crash( char const* condition );
|
|||||||
void process_exit( u32 code );
|
void process_exit( u32 code );
|
||||||
|
|
||||||
#if Build_Debug
|
#if Build_Debug
|
||||||
#define GEN_FATAL( ... ) \
|
#define GEN_FATAL( ... ) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
local_persist thread_local char buf[ GEN_PRINTF_MAXLEN ] = { 0 }; \
|
local_persist thread_local char buf[GEN_PRINTF_MAXLEN] = { 0 }; \
|
||||||
\
|
\
|
||||||
str_fmt( buf, GEN_PRINTF_MAXLEN, __VA_ARGS__ ); \
|
str_fmt( buf, GEN_PRINTF_MAXLEN, __VA_ARGS__ ); \
|
||||||
GEN_PANIC( buf ); \
|
GEN_PANIC( buf ); \
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -662,10 +662,10 @@ void process_exit( u32 code );
|
|||||||
|
|
||||||
#pragma region Memory
|
#pragma region Memory
|
||||||
|
|
||||||
#define kilobytes( x ) ( ( x ) * ( s64 )( 1024 ) )
|
#define kilobytes( x ) ( ( x ) * (s64)( 1024 ) )
|
||||||
#define megabytes( x ) ( kilobytes( x ) * ( s64 )( 1024 ) )
|
#define megabytes( x ) ( kilobytes( x ) * (s64)( 1024 ) )
|
||||||
#define gigabytes( x ) ( megabytes( x ) * ( s64 )( 1024 ) )
|
#define gigabytes( x ) ( megabytes( x ) * (s64)( 1024 ) )
|
||||||
#define terabytes( x ) ( gigabytes( x ) * ( s64 )( 1024 ) )
|
#define terabytes( x ) ( gigabytes( x ) * (s64)( 1024 ) )
|
||||||
|
|
||||||
#define GEN__ONES ( zpl_cast( uw ) - 1 / GEN_U8_MAX )
|
#define GEN__ONES ( zpl_cast( uw ) - 1 / GEN_U8_MAX )
|
||||||
#define GEN__HIGHS ( GEN__ONES * ( GEN_U8_MAX / 2 + 1 ) )
|
#define GEN__HIGHS ( GEN__ONES * ( GEN_U8_MAX / 2 + 1 ) )
|
||||||
@ -759,10 +759,10 @@ GEN_DEF_INLINE void* resize( AllocatorInfo a, void* ptr, sw old_size, sw new_siz
|
|||||||
GEN_DEF_INLINE void* resize_align( AllocatorInfo a, void* ptr, sw old_size, sw new_size, sw alignment );
|
GEN_DEF_INLINE void* resize_align( AllocatorInfo a, void* ptr, sw old_size, sw new_size, sw alignment );
|
||||||
|
|
||||||
//! Allocate memory for an item.
|
//! Allocate memory for an item.
|
||||||
#define alloc_item( allocator_, Type ) ( Type* )alloc( allocator_, size_of( Type ) )
|
#define alloc_item( allocator_, Type ) (Type*)alloc( allocator_, size_of( Type ) )
|
||||||
|
|
||||||
//! Allocate memory for an array of items.
|
//! Allocate memory for an array of items.
|
||||||
#define alloc_array( allocator_, Type, count ) ( Type* )alloc( allocator_, size_of( Type ) * ( count ) )
|
#define alloc_array( allocator_, Type, count ) (Type*)alloc( allocator_, size_of( Type ) * ( count ) )
|
||||||
|
|
||||||
/* heap memory analysis tools */
|
/* heap memory analysis tools */
|
||||||
/* define GEN_HEAP_ANALYSIS to enable this feature */
|
/* define GEN_HEAP_ANALYSIS to enable this feature */
|
||||||
@ -873,7 +873,7 @@ GEN_IMPL_INLINE void* mem_move( void* dest, void const* source, sw n )
|
|||||||
{
|
{
|
||||||
if ( ! n-- )
|
if ( ! n-- )
|
||||||
return dest;
|
return dest;
|
||||||
d[ n ] = s[ n ];
|
d[n] = s[n];
|
||||||
}
|
}
|
||||||
while ( n >= size_of( sw ) )
|
while ( n >= size_of( sw ) )
|
||||||
{
|
{
|
||||||
@ -882,7 +882,7 @@ GEN_IMPL_INLINE void* mem_move( void* dest, void const* source, sw n )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ( n )
|
while ( n )
|
||||||
n--, d[ n ] = s[ n ];
|
n--, d[n] = s[n];
|
||||||
}
|
}
|
||||||
|
|
||||||
return dest;
|
return dest;
|
||||||
@ -897,18 +897,18 @@ GEN_IMPL_INLINE void* mem_set( void* dest, u8 c, sw n )
|
|||||||
|
|
||||||
u8* s = zpl_cast( u8* ) dest;
|
u8* s = zpl_cast( u8* ) dest;
|
||||||
sw k;
|
sw k;
|
||||||
u32 c32 = ( ( u32 )-1 ) / 255 * c;
|
u32 c32 = ( (u32)-1 ) / 255 * c;
|
||||||
|
|
||||||
if ( n == 0 )
|
if ( n == 0 )
|
||||||
return dest;
|
return dest;
|
||||||
s[ 0 ] = s[ n - 1 ] = c;
|
s[0] = s[n - 1] = c;
|
||||||
if ( n < 3 )
|
if ( n < 3 )
|
||||||
return dest;
|
return dest;
|
||||||
s[ 1 ] = s[ n - 2 ] = c;
|
s[1] = s[n - 2] = c;
|
||||||
s[ 2 ] = s[ n - 3 ] = c;
|
s[2] = s[n - 3] = c;
|
||||||
if ( n < 7 )
|
if ( n < 7 )
|
||||||
return dest;
|
return dest;
|
||||||
s[ 3 ] = s[ n - 4 ] = c;
|
s[3] = s[n - 4] = c;
|
||||||
if ( n < 9 )
|
if ( n < 9 )
|
||||||
return dest;
|
return dest;
|
||||||
|
|
||||||
@ -1081,7 +1081,7 @@ struct Arena
|
|||||||
GEN_ASSERT( is_power_of_two( alignment ) );
|
GEN_ASSERT( is_power_of_two( alignment ) );
|
||||||
|
|
||||||
alignment_offset = 0;
|
alignment_offset = 0;
|
||||||
result_pointer = ( sw )PhysicalStart + TotalUsed;
|
result_pointer = (sw)PhysicalStart + TotalUsed;
|
||||||
mask = alignment - 1;
|
mask = alignment - 1;
|
||||||
|
|
||||||
if ( result_pointer & mask )
|
if ( result_pointer & mask )
|
||||||
@ -1124,7 +1124,7 @@ struct Arena
|
|||||||
|
|
||||||
// Just a wrapper around using an arena with memory associated with its scope instead of from an allocator.
|
// Just a wrapper around using an arena with memory associated with its scope instead of from an allocator.
|
||||||
// Used for static segment or stack allocations.
|
// Used for static segment or stack allocations.
|
||||||
template< s32 Size >
|
template<s32 Size>
|
||||||
struct FixedArena
|
struct FixedArena
|
||||||
{
|
{
|
||||||
static FixedArena init()
|
static FixedArena init()
|
||||||
@ -1144,21 +1144,21 @@ struct FixedArena
|
|||||||
}
|
}
|
||||||
|
|
||||||
Arena arena;
|
Arena arena;
|
||||||
char memory[ Size ];
|
char memory[Size];
|
||||||
};
|
};
|
||||||
|
|
||||||
using Arena_1KB = FixedArena< kilobytes( 1 ) >;
|
using Arena_1KB = FixedArena<kilobytes( 1 )>;
|
||||||
using Arena_4KB = FixedArena< kilobytes( 4 ) >;
|
using Arena_4KB = FixedArena<kilobytes( 4 )>;
|
||||||
using Arena_8KB = FixedArena< kilobytes( 8 ) >;
|
using Arena_8KB = FixedArena<kilobytes( 8 )>;
|
||||||
using Arena_16KB = FixedArena< kilobytes( 16 ) >;
|
using Arena_16KB = FixedArena<kilobytes( 16 )>;
|
||||||
using Arena_32KB = FixedArena< kilobytes( 32 ) >;
|
using Arena_32KB = FixedArena<kilobytes( 32 )>;
|
||||||
using Arena_64KB = FixedArena< kilobytes( 64 ) >;
|
using Arena_64KB = FixedArena<kilobytes( 64 )>;
|
||||||
using Arena_128KB = FixedArena< kilobytes( 128 ) >;
|
using Arena_128KB = FixedArena<kilobytes( 128 )>;
|
||||||
using Arena_256KB = FixedArena< kilobytes( 256 ) >;
|
using Arena_256KB = FixedArena<kilobytes( 256 )>;
|
||||||
using Arena_512KB = FixedArena< kilobytes( 512 ) >;
|
using Arena_512KB = FixedArena<kilobytes( 512 )>;
|
||||||
using Arena_1MB = FixedArena< megabytes( 1 ) >;
|
using Arena_1MB = FixedArena<megabytes( 1 )>;
|
||||||
using Arena_2MB = FixedArena< megabytes( 2 ) >;
|
using Arena_2MB = FixedArena<megabytes( 2 )>;
|
||||||
using Arena_4MB = FixedArena< megabytes( 4 ) >;
|
using Arena_4MB = FixedArena<megabytes( 4 )>;
|
||||||
|
|
||||||
struct Pool
|
struct Pool
|
||||||
{
|
{
|
||||||
@ -1313,7 +1313,7 @@ GEN_IMPL_INLINE s32 str_compare( const char* s1, const char* s2 )
|
|||||||
{
|
{
|
||||||
s1++, s2++;
|
s1++, s2++;
|
||||||
}
|
}
|
||||||
return *( u8* )s1 - *( u8* )s2;
|
return *(u8*)s1 - *(u8*)s2;
|
||||||
}
|
}
|
||||||
|
|
||||||
GEN_IMPL_INLINE s32 str_compare( const char* s1, const char* s2, sw len )
|
GEN_IMPL_INLINE s32 str_compare( const char* s1, const char* s2, sw len )
|
||||||
@ -1417,11 +1417,11 @@ GEN_IMPL_INLINE char const* str_skip( char const* str, char c )
|
|||||||
|
|
||||||
GEN_IMPL_INLINE char const* str_skip_any( char const* str, char const* char_list )
|
GEN_IMPL_INLINE char const* str_skip_any( char const* str, char const* char_list )
|
||||||
{
|
{
|
||||||
char const* closest_ptr = zpl_cast( char const* ) pointer_add( ( void* )str, str_len( str ) );
|
char const* closest_ptr = zpl_cast( char const* ) pointer_add( (void*)str, str_len( str ) );
|
||||||
sw char_list_count = str_len( char_list );
|
sw char_list_count = str_len( char_list );
|
||||||
for ( sw i = 0; i < char_list_count; i++ )
|
for ( sw i = 0; i < char_list_count; i++ )
|
||||||
{
|
{
|
||||||
char const* p = str_skip( str, char_list[ i ] );
|
char const* p = str_skip( str, char_list[i] );
|
||||||
closest_ptr = min( closest_ptr, p );
|
closest_ptr = min( closest_ptr, p );
|
||||||
}
|
}
|
||||||
return closest_ptr;
|
return closest_ptr;
|
||||||
@ -1497,34 +1497,34 @@ inline sw log_fmt( char const* fmt, ... )
|
|||||||
|
|
||||||
#pragma region Containers
|
#pragma region Containers
|
||||||
|
|
||||||
template< class TType >
|
template<class TType>
|
||||||
struct RemoveConst
|
struct RemoveConst
|
||||||
{
|
{
|
||||||
typedef TType Type;
|
typedef TType Type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class TType >
|
template<class TType>
|
||||||
struct RemoveConst< const TType >
|
struct RemoveConst<const TType>
|
||||||
{
|
{
|
||||||
typedef TType Type;
|
typedef TType Type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class TType >
|
template<class TType>
|
||||||
struct RemoveConst< const TType[] >
|
struct RemoveConst<const TType[]>
|
||||||
{
|
{
|
||||||
typedef TType Type[];
|
typedef TType Type[];
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class TType, uw Size >
|
template<class TType, uw Size>
|
||||||
struct RemoveConst< const TType[ Size ] >
|
struct RemoveConst<const TType[Size]>
|
||||||
{
|
{
|
||||||
typedef TType Type[ Size ];
|
typedef TType Type[Size];
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class TType >
|
template<class TType>
|
||||||
using TRemoveConst = typename RemoveConst< TType >::Type;
|
using TRemoveConst = typename RemoveConst<TType>::Type;
|
||||||
|
|
||||||
template< class Type >
|
template<class Type>
|
||||||
struct Array
|
struct Array
|
||||||
{
|
{
|
||||||
struct Header
|
struct Header
|
||||||
@ -1570,7 +1570,7 @@ struct Array
|
|||||||
header = get_header();
|
header = get_header();
|
||||||
}
|
}
|
||||||
|
|
||||||
Data[ header->Num ] = value;
|
Data[header->Num] = value;
|
||||||
header->Num++;
|
header->Num++;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -1617,7 +1617,6 @@ struct Array
|
|||||||
mem_move( target + 1, target, ( header->Num - idx ) * sizeof( Type ) );
|
mem_move( target + 1, target, ( header->Num - idx ) * sizeof( Type ) );
|
||||||
header->Num++;
|
header->Num++;
|
||||||
|
|
||||||
Data[ idx ] = item;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1651,7 +1650,7 @@ struct Array
|
|||||||
Type& back( void )
|
Type& back( void )
|
||||||
{
|
{
|
||||||
Header& header = *get_header();
|
Header& header = *get_header();
|
||||||
return Data[ header.Num - 1 ];
|
return Data[header.Num - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear( void )
|
void clear( void )
|
||||||
@ -1669,7 +1668,7 @@ struct Array
|
|||||||
|
|
||||||
for ( sw idx = begin; idx < end; idx++ )
|
for ( sw idx = begin; idx < end; idx++ )
|
||||||
{
|
{
|
||||||
Data[ idx ] = value;
|
Data[idx] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -1684,8 +1683,8 @@ struct Array
|
|||||||
|
|
||||||
Header* get_header( void )
|
Header* get_header( void )
|
||||||
{
|
{
|
||||||
using NonConstType = TRemoveConst< Type >;
|
using NonConstType = TRemoveConst<Type>;
|
||||||
return rcast( Header*, const_cast< NonConstType* >( Data ) ) - 1;
|
return rcast( Header*, const_cast<NonConstType*>( Data ) ) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool grow( uw min_capacity )
|
bool grow( uw min_capacity )
|
||||||
@ -1804,7 +1803,7 @@ struct Array
|
|||||||
|
|
||||||
// TODO(Ed) : This thing needs ALOT of work.
|
// TODO(Ed) : This thing needs ALOT of work.
|
||||||
|
|
||||||
template< typename Type >
|
template<typename Type>
|
||||||
struct HashTable
|
struct HashTable
|
||||||
{
|
{
|
||||||
struct FindResult
|
struct FindResult
|
||||||
@ -1823,22 +1822,22 @@ struct HashTable
|
|||||||
|
|
||||||
static HashTable init( AllocatorInfo allocator )
|
static HashTable init( AllocatorInfo allocator )
|
||||||
{
|
{
|
||||||
HashTable< Type > result = { { nullptr }, { nullptr } };
|
HashTable<Type> result = { { nullptr }, { nullptr } };
|
||||||
|
|
||||||
result.Hashes = Array< sw >::init( allocator );
|
result.Hashes = Array<sw>::init( allocator );
|
||||||
result.Entries = Array< Entry >::init( allocator );
|
result.Entries = Array<Entry>::init( allocator );
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HashTable init_reserve( AllocatorInfo allocator, uw num )
|
static HashTable init_reserve( AllocatorInfo allocator, uw num )
|
||||||
{
|
{
|
||||||
HashTable< Type > result = { { nullptr }, { nullptr } };
|
HashTable<Type> result = { { nullptr }, { nullptr } };
|
||||||
|
|
||||||
result.Hashes = Array< sw >::init_reserve( allocator, num );
|
result.Hashes = Array<sw>::init_reserve( allocator, num );
|
||||||
result.Hashes.get_header()->Num = num;
|
result.Hashes.get_header()->Num = num;
|
||||||
|
|
||||||
result.Entries = Array< Entry >::init_reserve( allocator, num );
|
result.Entries = Array<Entry>::init_reserve( allocator, num );
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1846,7 +1845,7 @@ struct HashTable
|
|||||||
void clear( void )
|
void clear( void )
|
||||||
{
|
{
|
||||||
for ( sw idx = 0; idx < Hashes.num(); idx++ )
|
for ( sw idx = 0; idx < Hashes.num(); idx++ )
|
||||||
Hashes[ idx ] = -1;
|
Hashes[idx] = -1;
|
||||||
|
|
||||||
Hashes.clear();
|
Hashes.clear();
|
||||||
Entries.clear();
|
Entries.clear();
|
||||||
@ -1865,7 +1864,7 @@ struct HashTable
|
|||||||
{
|
{
|
||||||
sw idx = find( key ).EntryIndex;
|
sw idx = find( key ).EntryIndex;
|
||||||
if ( idx >= 0 )
|
if ( idx >= 0 )
|
||||||
return &Entries[ idx ].Value;
|
return &Entries[idx].Value;
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -1878,7 +1877,7 @@ struct HashTable
|
|||||||
|
|
||||||
for ( sw idx = 0; idx < Entries.num(); idx++ )
|
for ( sw idx = 0; idx < Entries.num(); idx++ )
|
||||||
{
|
{
|
||||||
map_proc( Entries[ idx ].Key, Entries[ idx ].Value );
|
map_proc( Entries[idx].Key, Entries[idx].Value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1890,13 +1889,13 @@ struct HashTable
|
|||||||
|
|
||||||
for ( sw idx = 0; idx < Entries.num(); idx++ )
|
for ( sw idx = 0; idx < Entries.num(); idx++ )
|
||||||
{
|
{
|
||||||
map_proc( Entries[ idx ].Key, &Entries[ idx ].Value );
|
map_proc( Entries[idx].Key, &Entries[idx].Value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void grow()
|
void grow()
|
||||||
{
|
{
|
||||||
sw new_num = Array< Entry >::grow_formula( Entries.num() );
|
sw new_num = Array<Entry>::grow_formula( Entries.num() );
|
||||||
rehash( new_num );
|
rehash( new_num );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1905,34 +1904,34 @@ struct HashTable
|
|||||||
sw idx;
|
sw idx;
|
||||||
sw last_added_index;
|
sw last_added_index;
|
||||||
|
|
||||||
HashTable< Type > new_ht = init_reserve( Hashes.get_header()->Allocator, new_num );
|
HashTable<Type> new_ht = init_reserve( Hashes.get_header()->Allocator, new_num );
|
||||||
|
|
||||||
Array< sw >::Header* hash_header = new_ht.Hashes.get_header();
|
Array<sw>::Header* hash_header = new_ht.Hashes.get_header();
|
||||||
|
|
||||||
for ( idx = 0; idx < new_ht.Hashes.num(); ++idx )
|
for ( idx = 0; idx < new_ht.Hashes.num(); ++idx )
|
||||||
new_ht.Hashes[ idx ] = -1;
|
new_ht.Hashes[idx] = -1;
|
||||||
|
|
||||||
for ( idx = 0; idx < Entries.num(); ++idx )
|
for ( idx = 0; idx < Entries.num(); ++idx )
|
||||||
{
|
{
|
||||||
Entry& entry = Entries[ idx ];
|
Entry& entry = Entries[idx];
|
||||||
|
|
||||||
FindResult find_result;
|
FindResult find_result;
|
||||||
|
|
||||||
if ( new_ht.Hashes.num() == 0 )
|
if ( new_ht.Hashes.num() == 0 )
|
||||||
new_ht.grow();
|
new_ht.grow();
|
||||||
|
|
||||||
entry = Entries[ idx ];
|
entry = Entries[idx];
|
||||||
find_result = new_ht.find( entry.Key );
|
find_result = new_ht.find( entry.Key );
|
||||||
last_added_index = new_ht.add_entry( entry.Key );
|
last_added_index = new_ht.add_entry( entry.Key );
|
||||||
|
|
||||||
if ( find_result.PrevIndex < 0 )
|
if ( find_result.PrevIndex < 0 )
|
||||||
new_ht.Hashes[ find_result.HashIndex ] = last_added_index;
|
new_ht.Hashes[find_result.HashIndex] = last_added_index;
|
||||||
|
|
||||||
else
|
else
|
||||||
new_ht.Entries[ find_result.PrevIndex ].Next = last_added_index;
|
new_ht.Entries[find_result.PrevIndex].Next = last_added_index;
|
||||||
|
|
||||||
new_ht.Entries[ last_added_index ].Next = find_result.EntryIndex;
|
new_ht.Entries[last_added_index].Next = find_result.EntryIndex;
|
||||||
new_ht.Entries[ last_added_index ].Value = entry.Value;
|
new_ht.Entries[last_added_index].Value = entry.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy();
|
destroy();
|
||||||
@ -1944,23 +1943,23 @@ struct HashTable
|
|||||||
sw idx;
|
sw idx;
|
||||||
|
|
||||||
for ( idx = 0; idx < Entries.num(); idx++ )
|
for ( idx = 0; idx < Entries.num(); idx++ )
|
||||||
Entries[ idx ].Next = -1;
|
Entries[idx].Next = -1;
|
||||||
|
|
||||||
for ( idx = 0; idx < Hashes.num(); idx++ )
|
for ( idx = 0; idx < Hashes.num(); idx++ )
|
||||||
Hashes[ idx ] = -1;
|
Hashes[idx] = -1;
|
||||||
|
|
||||||
for ( idx = 0; idx < Entries.num(); idx++ )
|
for ( idx = 0; idx < Entries.num(); idx++ )
|
||||||
{
|
{
|
||||||
Entry* entry;
|
Entry* entry;
|
||||||
FindResult find_result;
|
FindResult find_result;
|
||||||
|
|
||||||
entry = &Entries[ idx ];
|
entry = &Entries[idx];
|
||||||
find_result = find( entry->Key );
|
find_result = find( entry->Key );
|
||||||
|
|
||||||
if ( find_result.PrevIndex < 0 )
|
if ( find_result.PrevIndex < 0 )
|
||||||
Hashes[ find_result.HashIndex ] = idx;
|
Hashes[find_result.HashIndex] = idx;
|
||||||
else
|
else
|
||||||
Entries[ find_result.PrevIndex ].Next = idx;
|
Entries[find_result.PrevIndex].Next = idx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2000,15 +1999,15 @@ struct HashTable
|
|||||||
|
|
||||||
if ( find_result.PrevIndex >= 0 )
|
if ( find_result.PrevIndex >= 0 )
|
||||||
{
|
{
|
||||||
Entries[ find_result.PrevIndex ].Next = idx;
|
Entries[find_result.PrevIndex].Next = idx;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Hashes[ find_result.HashIndex ] = idx;
|
Hashes[find_result.HashIndex] = idx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Entries[ idx ].Value = value;
|
Entries[idx].Value = value;
|
||||||
|
|
||||||
if ( full() )
|
if ( full() )
|
||||||
grow();
|
grow();
|
||||||
@ -2017,14 +2016,14 @@ struct HashTable
|
|||||||
sw slot( u64 key )
|
sw slot( u64 key )
|
||||||
{
|
{
|
||||||
for ( sw idx = 0; idx < Hashes.num(); ++idx )
|
for ( sw idx = 0; idx < Hashes.num(); ++idx )
|
||||||
if ( Hashes[ idx ] == key )
|
if ( Hashes[idx] == key )
|
||||||
return idx;
|
return idx;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array< sw > Hashes;
|
Array<sw> Hashes;
|
||||||
Array< Entry > Entries;
|
Array<Entry> Entries;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
sw add_entry( u64 key )
|
sw add_entry( u64 key )
|
||||||
@ -2044,15 +2043,15 @@ protected:
|
|||||||
if ( Hashes.num() > 0 )
|
if ( Hashes.num() > 0 )
|
||||||
{
|
{
|
||||||
result.HashIndex = key % Hashes.num();
|
result.HashIndex = key % Hashes.num();
|
||||||
result.EntryIndex = Hashes[ result.HashIndex ];
|
result.EntryIndex = Hashes[result.HashIndex];
|
||||||
|
|
||||||
while ( result.EntryIndex >= 0 )
|
while ( result.EntryIndex >= 0 )
|
||||||
{
|
{
|
||||||
if ( Entries[ result.EntryIndex ].Key == key )
|
if ( Entries[result.EntryIndex].Key == key )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
result.PrevIndex = result.EntryIndex;
|
result.PrevIndex = result.EntryIndex;
|
||||||
result.EntryIndex = Entries[ result.EntryIndex ].Next;
|
result.EntryIndex = Entries[result.EntryIndex].Next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2082,6 +2081,11 @@ struct StrC
|
|||||||
sw Len;
|
sw Len;
|
||||||
char const* Ptr;
|
char const* Ptr;
|
||||||
|
|
||||||
|
char const& operator[]( sw index ) const
|
||||||
|
{
|
||||||
|
return Ptr[index];
|
||||||
|
}
|
||||||
|
|
||||||
operator char const*() const
|
operator char const*() const
|
||||||
{
|
{
|
||||||
return Ptr;
|
return Ptr;
|
||||||
@ -2144,7 +2148,7 @@ struct String
|
|||||||
|
|
||||||
for ( sw idx = 0; idx < num_parts; ++idx )
|
for ( sw idx = 0; idx < num_parts; ++idx )
|
||||||
{
|
{
|
||||||
result.append( parts[ idx ] );
|
result.append( parts[idx] );
|
||||||
|
|
||||||
if ( idx < num_parts - 1 )
|
if ( idx < num_parts - 1 )
|
||||||
result.append( glue );
|
result.append( glue );
|
||||||
@ -2159,7 +2163,19 @@ struct String
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
for ( sw idx = 0; idx < lhs.length(); ++idx )
|
for ( sw idx = 0; idx < lhs.length(); ++idx )
|
||||||
if ( lhs[ idx ] != rhs[ idx ] )
|
if ( lhs[idx] != rhs[idx] )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool are_equal( String lhs, StrC rhs )
|
||||||
|
{
|
||||||
|
if ( lhs.length() != (rhs.Len - 1) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for ( sw idx = 0; idx < lhs.length(); ++idx )
|
||||||
|
if ( lhs[idx] != rhs[idx] )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -2190,9 +2206,9 @@ struct String
|
|||||||
|
|
||||||
mem_copy( Data + curr_len, str, length );
|
mem_copy( Data + curr_len, str, length );
|
||||||
|
|
||||||
Data[ curr_len + length ] = '\0';
|
Data[curr_len + length] = '\0';
|
||||||
|
|
||||||
header.Length = curr_len + length;
|
header.Length = curr_len + length;
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
@ -2218,7 +2234,7 @@ struct String
|
|||||||
|
|
||||||
char& back()
|
char& back()
|
||||||
{
|
{
|
||||||
return Data[ length() - 1 ];
|
return Data[length() - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
sw capacity() const
|
sw capacity() const
|
||||||
@ -2233,6 +2249,24 @@ struct String
|
|||||||
get_header().Length = 0;
|
get_header().Length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
b32 starts_with( StrC substring ) const
|
||||||
|
{
|
||||||
|
if (substring.Len > length())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
b32 result = str_compare(Data, substring.Ptr, substring.Len ) == 0;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
b32 starts_with( String substring ) const
|
||||||
|
{
|
||||||
|
if (substring.length() > length())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
b32 result = str_compare(Data, substring, substring.length() - 1 ) == 0;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
String duplicate( AllocatorInfo allocator ) const
|
String duplicate( AllocatorInfo allocator ) const
|
||||||
{
|
{
|
||||||
return make_length( allocator, Data, length() );
|
return make_length( allocator, Data, length() );
|
||||||
@ -2250,7 +2284,7 @@ struct String
|
|||||||
|
|
||||||
Header& get_header()
|
Header& get_header()
|
||||||
{
|
{
|
||||||
return *( Header* )( Data - sizeof( Header ) );
|
return *(Header*)( Data - sizeof( Header ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
sw length() const
|
sw length() const
|
||||||
@ -2298,7 +2332,7 @@ struct String
|
|||||||
read_pos++;
|
read_pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
write_pos[ 0 ] = '\0'; // Null-terminate the modified string
|
write_pos[0] = '\0'; // Null-terminate the modified string
|
||||||
|
|
||||||
// Update the length if needed
|
// Update the length if needed
|
||||||
get_header().Length = write_pos - Data;
|
get_header().Length = write_pos - Data;
|
||||||
@ -2322,7 +2356,7 @@ struct String
|
|||||||
if ( Data != start_pos )
|
if ( Data != start_pos )
|
||||||
mem_move( Data, start_pos, len );
|
mem_move( Data, start_pos, len );
|
||||||
|
|
||||||
Data[ len ] = '\0';
|
Data[len] = '\0';
|
||||||
|
|
||||||
get_header().Length = len;
|
get_header().Length = len;
|
||||||
}
|
}
|
||||||
@ -2335,7 +2369,7 @@ struct String
|
|||||||
// Debug function that provides a copy of the string with whitespace characters visualized.
|
// Debug function that provides a copy of the string with whitespace characters visualized.
|
||||||
String visualize_whitespace() const
|
String visualize_whitespace() const
|
||||||
{
|
{
|
||||||
Header* header = ( Header* )( Data - sizeof( Header ) );
|
Header* header = (Header*)( Data - sizeof( Header ) );
|
||||||
|
|
||||||
String result = make_reserve( header->Allocator, length() * 2 ); // Assume worst case for space requirements.
|
String result = make_reserve( header->Allocator, length() * 2 ); // Assume worst case for space requirements.
|
||||||
|
|
||||||
@ -2420,12 +2454,12 @@ struct String
|
|||||||
|
|
||||||
char& operator[]( sw index )
|
char& operator[]( sw index )
|
||||||
{
|
{
|
||||||
return Data[ index ];
|
return Data[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
char const& operator[]( sw index ) const
|
char const& operator[]( sw index ) const
|
||||||
{
|
{
|
||||||
return Data[ index ];
|
return Data[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
char* Data;
|
char* Data;
|
||||||
@ -2439,7 +2473,7 @@ struct String_POD
|
|||||||
static_assert( sizeof( String_POD ) == sizeof( String ), "String is not a POD" );
|
static_assert( sizeof( String_POD ) == sizeof( String ), "String is not a POD" );
|
||||||
|
|
||||||
// Implements basic string interning. Data structure is based off the ZPL Hashtable.
|
// Implements basic string interning. Data structure is based off the ZPL Hashtable.
|
||||||
using StringTable = HashTable< String const >;
|
using StringTable = HashTable<String const>;
|
||||||
|
|
||||||
// Represents strings cached with the string table.
|
// Represents strings cached with the string table.
|
||||||
// Should never be modified, if changed string is desired, cache_string( str ) another.
|
// Should never be modified, if changed string is desired, cache_string( str ) another.
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -25,7 +25,7 @@ u8 adt_make_branch( ADT_Node* node, AllocatorInfo backing, char const* name, b32
|
|||||||
node->type = type;
|
node->type = type;
|
||||||
node->name = name;
|
node->name = name;
|
||||||
node->parent = parent;
|
node->parent = parent;
|
||||||
node->nodes = Array< ADT_Node >::init( backing );
|
node->nodes = Array<ADT_Node>::init( backing );
|
||||||
|
|
||||||
if ( ! node->nodes )
|
if ( ! node->nodes )
|
||||||
return EADT_ERROR_OUT_OF_MEMORY;
|
return EADT_ERROR_OUT_OF_MEMORY;
|
||||||
@ -70,7 +70,7 @@ ADT_Node* adt_find( ADT_Node* node, char const* name, b32 deep_search )
|
|||||||
|
|
||||||
for ( sw i = 0; i < node->nodes.num(); i++ )
|
for ( sw i = 0; i < node->nodes.num(); i++ )
|
||||||
{
|
{
|
||||||
if ( ! str_compare( node->nodes[ i ].name, name ) )
|
if ( ! str_compare( node->nodes[i].name, name ) )
|
||||||
{
|
{
|
||||||
return ( node->nodes + i );
|
return ( node->nodes + i );
|
||||||
}
|
}
|
||||||
@ -106,17 +106,17 @@ internal ADT_Node* _adt_get_value( ADT_Node* node, char const* value )
|
|||||||
case EADT_TYPE_INTEGER :
|
case EADT_TYPE_INTEGER :
|
||||||
case EADT_TYPE_REAL :
|
case EADT_TYPE_REAL :
|
||||||
{
|
{
|
||||||
char back[ 4096 ] = { 0 };
|
char back[4096] = { 0 };
|
||||||
FileInfo tmp;
|
FileInfo tmp;
|
||||||
|
|
||||||
/* allocate a file descriptor for a memory-mapped number to string conversion, input source buffer is not cloned, however. */
|
/* allocate a file descriptor for a memory-mapped number to string conversion, input source buffer is not cloned, however. */
|
||||||
file_stream_open( &tmp, heap(), ( u8* )back, size_of( back ), EFileStream_WRITABLE );
|
file_stream_open( &tmp, heap(), (u8*)back, size_of( back ), EFileStream_WRITABLE );
|
||||||
adt_print_number( &tmp, node );
|
adt_print_number( &tmp, node );
|
||||||
|
|
||||||
sw fsize = 0;
|
sw fsize = 0;
|
||||||
u8* buf = file_stream_buf( &tmp, &fsize );
|
u8* buf = file_stream_buf( &tmp, &fsize );
|
||||||
|
|
||||||
if ( ! str_compare( ( char const* )buf, value ) )
|
if ( ! str_compare( (char const*)buf, value ) )
|
||||||
{
|
{
|
||||||
file_close( &tmp );
|
file_close( &tmp );
|
||||||
return node;
|
return node;
|
||||||
@ -136,9 +136,9 @@ internal ADT_Node* _adt_get_field( ADT_Node* node, char* name, char* value )
|
|||||||
{
|
{
|
||||||
for ( sw i = 0; i < node->nodes.num(); i++ )
|
for ( sw i = 0; i < node->nodes.num(); i++ )
|
||||||
{
|
{
|
||||||
if ( ! str_compare( node->nodes[ i ].name, name ) )
|
if ( ! str_compare( node->nodes[i].name, name ) )
|
||||||
{
|
{
|
||||||
ADT_Node* child = &node->nodes[ i ];
|
ADT_Node* child = &node->nodes[i];
|
||||||
if ( _adt_get_value( child, value ) )
|
if ( _adt_get_value( child, value ) )
|
||||||
{
|
{
|
||||||
return node; /* this object does contain a field of a specified value! */
|
return node; /* this object does contain a field of a specified value! */
|
||||||
@ -172,19 +172,19 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri )
|
|||||||
str_fmt_out( "uri: %s\n", uri );
|
str_fmt_out( "uri: %s\n", uri );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char * p = ( char* )uri, *b = p, *e = p;
|
char * p = (char*)uri, *b = p, *e = p;
|
||||||
ADT_Node* found_node = NULL;
|
ADT_Node* found_node = NULL;
|
||||||
|
|
||||||
b = p;
|
b = p;
|
||||||
p = e = ( char* )str_skip( p, '/' );
|
p = e = (char*)str_skip( p, '/' );
|
||||||
char* buf = str_fmt_buf( "%.*s", ( int )( e - b ), b );
|
char* buf = str_fmt_buf( "%.*s", (int)( e - b ), b );
|
||||||
|
|
||||||
/* handle field value lookup */
|
/* handle field value lookup */
|
||||||
if ( *b == '[' )
|
if ( *b == '[' )
|
||||||
{
|
{
|
||||||
char *l_p = buf + 1, *l_b = l_p, *l_e = l_p, *l_b2 = l_p, *l_e2 = l_p;
|
char *l_p = buf + 1, *l_b = l_p, *l_e = l_p, *l_b2 = l_p, *l_e2 = l_p;
|
||||||
l_e = ( char* )str_skip( l_p, '=' );
|
l_e = (char*)str_skip( l_p, '=' );
|
||||||
l_e2 = ( char* )str_skip( l_p, ']' );
|
l_e2 = (char*)str_skip( l_p, ']' );
|
||||||
|
|
||||||
if ( ( ! *l_e && node->type != EADT_TYPE_ARRAY ) || ! *l_e2 )
|
if ( ( ! *l_e && node->type != EADT_TYPE_ARRAY ) || ! *l_e2 )
|
||||||
{
|
{
|
||||||
@ -211,7 +211,7 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri )
|
|||||||
{
|
{
|
||||||
for ( sw i = 0; i < node->nodes.num(); i++ )
|
for ( sw i = 0; i < node->nodes.num(); i++ )
|
||||||
{
|
{
|
||||||
ADT_Node* child = &node->nodes[ i ];
|
ADT_Node* child = &node->nodes[i];
|
||||||
if ( child->type != EADT_TYPE_OBJECT )
|
if ( child->type != EADT_TYPE_OBJECT )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@ -229,7 +229,7 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri )
|
|||||||
{
|
{
|
||||||
for ( sw i = 0; i < node->nodes.num(); i++ )
|
for ( sw i = 0; i < node->nodes.num(); i++ )
|
||||||
{
|
{
|
||||||
ADT_Node* child = &node->nodes[ i ];
|
ADT_Node* child = &node->nodes[i];
|
||||||
if ( _adt_get_value( child, l_b2 ) )
|
if ( _adt_get_value( child, l_b2 ) )
|
||||||
{
|
{
|
||||||
found_node = child;
|
found_node = child;
|
||||||
@ -258,10 +258,10 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri )
|
|||||||
/* handle array index lookup */
|
/* handle array index lookup */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sw idx = ( sw )str_to_i64( buf, NULL, 10 );
|
sw idx = (sw)str_to_i64( buf, NULL, 10 );
|
||||||
if ( idx >= 0 && idx < node->nodes.num() )
|
if ( idx >= 0 && idx < node->nodes.num() )
|
||||||
{
|
{
|
||||||
found_node = &node->nodes[ idx ];
|
found_node = &node->nodes[idx];
|
||||||
|
|
||||||
/* go deeper if uri continues */
|
/* go deeper if uri continues */
|
||||||
if ( *e )
|
if ( *e )
|
||||||
@ -366,15 +366,15 @@ void adt_swap_nodes( ADT_Node* node, ADT_Node* other_node )
|
|||||||
{
|
{
|
||||||
GEN_ASSERT_NOT_NULL( node );
|
GEN_ASSERT_NOT_NULL( node );
|
||||||
GEN_ASSERT_NOT_NULL( other_node );
|
GEN_ASSERT_NOT_NULL( other_node );
|
||||||
ADT_Node* parent = node->parent;
|
ADT_Node* parent = node->parent;
|
||||||
ADT_Node* other_parent = other_node->parent;
|
ADT_Node* other_parent = other_node->parent;
|
||||||
sw index = ( pointer_diff( parent->nodes, node ) / size_of( ADT_Node ) );
|
sw index = ( pointer_diff( parent->nodes, node ) / size_of( ADT_Node ) );
|
||||||
sw index2 = ( pointer_diff( other_parent->nodes, other_node ) / size_of( ADT_Node ) );
|
sw index2 = ( pointer_diff( other_parent->nodes, other_node ) / size_of( ADT_Node ) );
|
||||||
ADT_Node temp = parent->nodes[ index ];
|
ADT_Node temp = parent->nodes[index];
|
||||||
temp.parent = other_parent;
|
temp.parent = other_parent;
|
||||||
other_parent->nodes[ index2 ].parent = parent;
|
other_parent->nodes[index2].parent = parent;
|
||||||
parent->nodes[ index ] = other_parent->nodes[ index2 ];
|
parent->nodes[index] = other_parent->nodes[index2];
|
||||||
other_parent->nodes[ index2 ] = temp;
|
other_parent->nodes[index2] = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void adt_remove_node( ADT_Node* node )
|
void adt_remove_node( ADT_Node* node )
|
||||||
@ -483,28 +483,28 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
|
|||||||
return ++base_str;
|
return ++base_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
node_type = EADT_TYPE_INTEGER;
|
node_type = EADT_TYPE_INTEGER;
|
||||||
neg_zero = false;
|
neg_zero = false;
|
||||||
|
|
||||||
sw ib = 0;
|
sw ib = 0;
|
||||||
char buf[ 48 ] = { 0 };
|
char buf[48] = { 0 };
|
||||||
|
|
||||||
if ( *e == '+' )
|
if ( *e == '+' )
|
||||||
++e;
|
++e;
|
||||||
else if ( *e == '-' )
|
else if ( *e == '-' )
|
||||||
{
|
{
|
||||||
buf[ ib++ ] = *e++;
|
buf[ib++] = *e++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( *e == '.' )
|
if ( *e == '.' )
|
||||||
{
|
{
|
||||||
node_type = EADT_TYPE_REAL;
|
node_type = EADT_TYPE_REAL;
|
||||||
node_props = EADT_PROPS_IS_PARSED_REAL;
|
node_props = EADT_PROPS_IS_PARSED_REAL;
|
||||||
lead_digit = false;
|
lead_digit = false;
|
||||||
buf[ ib++ ] = '0';
|
buf[ib++] = '0';
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
buf[ ib++ ] = *e;
|
buf[ib++] = *e;
|
||||||
} while ( char_is_digit( *++e ) );
|
} while ( char_is_digit( *++e ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -522,7 +522,7 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
|
|||||||
|
|
||||||
while ( char_is_hex_digit( *e ) || char_to_lower( *e ) == 'x' )
|
while ( char_is_hex_digit( *e ) || char_to_lower( *e ) == 'x' )
|
||||||
{
|
{
|
||||||
buf[ ib++ ] = *e++;
|
buf[ib++] = *e++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( *e == '.' )
|
if ( *e == '.' )
|
||||||
@ -533,13 +533,13 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
buf[ ib++ ] = *e;
|
buf[ib++] = *e;
|
||||||
++step;
|
++step;
|
||||||
} while ( char_is_digit( *++e ) );
|
} while ( char_is_digit( *++e ) );
|
||||||
|
|
||||||
if ( step < 2 )
|
if ( step < 2 )
|
||||||
{
|
{
|
||||||
buf[ ib++ ] = '0';
|
buf[ib++] = '0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -550,9 +550,9 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
|
|||||||
return ++base_str;
|
return ++base_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
f32 eb = 10;
|
f32 eb = 10;
|
||||||
char expbuf[ 6 ] = { 0 };
|
char expbuf[6] = { 0 };
|
||||||
sw expi = 0;
|
sw expi = 0;
|
||||||
|
|
||||||
if ( *e && ! ! str_find( "eE", *e ) )
|
if ( *e && ! ! str_find( "eE", *e ) )
|
||||||
{
|
{
|
||||||
@ -569,11 +569,11 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
|
|||||||
}
|
}
|
||||||
while ( char_is_digit( *e ) )
|
while ( char_is_digit( *e ) )
|
||||||
{
|
{
|
||||||
expbuf[ expi++ ] = *e++;
|
expbuf[expi++] = *e++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
orig_exp = exp = ( u8 )str_to_i64( expbuf, NULL, 10 );
|
orig_exp = exp = (u8)str_to_i64( expbuf, NULL, 10 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( node_type == EADT_TYPE_INTEGER )
|
if ( node_type == EADT_TYPE_INTEGER )
|
||||||
@ -581,14 +581,14 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
|
|||||||
node->integer = str_to_i64( buf, 0, 0 );
|
node->integer = str_to_i64( buf, 0, 0 );
|
||||||
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
||||||
/* special case: negative zero */
|
/* special case: negative zero */
|
||||||
if ( node->integer == 0 && buf[ 0 ] == '-' )
|
if ( node->integer == 0 && buf[0] == '-' )
|
||||||
{
|
{
|
||||||
neg_zero = true;
|
neg_zero = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
while ( orig_exp-- > 0 )
|
while ( orig_exp-- > 0 )
|
||||||
{
|
{
|
||||||
node->integer *= ( s64 )eb;
|
node->integer *= (s64)eb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -604,8 +604,8 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
|
|||||||
while ( *base_string_off++ == '0' )
|
while ( *base_string_off++ == '0' )
|
||||||
base2_offset++;
|
base2_offset++;
|
||||||
|
|
||||||
base = ( s32 )str_to_i64( q, 0, 0 );
|
base = (s32)str_to_i64( q, 0, 0 );
|
||||||
base2 = ( s32 )str_to_i64( base_string2, 0, 0 );
|
base2 = (s32)str_to_i64( base_string2, 0, 0 );
|
||||||
if ( exp )
|
if ( exp )
|
||||||
{
|
{
|
||||||
exp = exp * ( ! ( eb == 10.0f ) ? -1 : 1 );
|
exp = exp * ( ! ( eb == 10.0f ) ? -1 : 1 );
|
||||||
@ -613,7 +613,7 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* special case: negative zero */
|
/* special case: negative zero */
|
||||||
if ( base == 0 && buf[ 0 ] == '-' )
|
if ( base == 0 && buf[0] == '-' )
|
||||||
{
|
{
|
||||||
neg_zero = true;
|
neg_zero = true;
|
||||||
}
|
}
|
||||||
@ -667,11 +667,11 @@ ADT_Error adt_print_number( FileInfo* file, ADT_Node* node )
|
|||||||
{
|
{
|
||||||
if ( node->props == EADT_PROPS_IS_HEX )
|
if ( node->props == EADT_PROPS_IS_HEX )
|
||||||
{
|
{
|
||||||
_adt_fprintf( file, "0x%llx", ( long long )node->integer );
|
_adt_fprintf( file, "0x%llx", (long long)node->integer );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_adt_fprintf( file, "%lld", ( long long )node->integer );
|
_adt_fprintf( file, "%lld", (long long)node->integer );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -709,14 +709,14 @@ ADT_Error adt_print_number( FileInfo* file, ADT_Node* node )
|
|||||||
}
|
}
|
||||||
else if ( node->props == EADT_PROPS_IS_EXP )
|
else if ( node->props == EADT_PROPS_IS_EXP )
|
||||||
{
|
{
|
||||||
_adt_fprintf( file, "%lld.%0*d%llde%lld", ( long long )node->base, node->base2_offset, 0, ( long long )node->base2, ( long long )node->exp );
|
_adt_fprintf( file, "%lld.%0*d%llde%lld", (long long)node->base, node->base2_offset, 0, (long long)node->base2, (long long)node->exp );
|
||||||
}
|
}
|
||||||
else if ( node->props == EADT_PROPS_IS_PARSED_REAL )
|
else if ( node->props == EADT_PROPS_IS_PARSED_REAL )
|
||||||
{
|
{
|
||||||
if ( ! node->lead_digit )
|
if ( ! node->lead_digit )
|
||||||
_adt_fprintf( file, ".%0*d%lld", node->base2_offset, 0, ( long long )node->base2 );
|
_adt_fprintf( file, ".%0*d%lld", node->base2_offset, 0, (long long)node->base2 );
|
||||||
else
|
else
|
||||||
_adt_fprintf( file, "%lld.%0*d%lld", ( long long int )node->base2_offset, 0, ( int )node->base, ( long long )node->base2 );
|
_adt_fprintf( file, "%lld.%0*d%lld", (long long int)node->base2_offset, 0, (int)node->base, (long long)node->base2 );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -772,7 +772,7 @@ ADT_Error adt_str_to_number( ADT_Node* node )
|
|||||||
return EADT_ERROR_INVALID_TYPE;
|
return EADT_ERROR_INVALID_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
adt_parse_number( node, ( char* )node->string );
|
adt_parse_number( node, (char*)node->string );
|
||||||
|
|
||||||
return EADT_ERROR_NONE;
|
return EADT_ERROR_NONE;
|
||||||
}
|
}
|
||||||
@ -788,7 +788,7 @@ ADT_Error adt_str_to_number_strict( ADT_Node* node )
|
|||||||
return EADT_ERROR_INVALID_TYPE;
|
return EADT_ERROR_INVALID_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
adt_parse_number_strict( node, ( char* )node->string );
|
adt_parse_number_strict( node, (char*)node->string );
|
||||||
|
|
||||||
return EADT_ERROR_NONE;
|
return EADT_ERROR_NONE;
|
||||||
}
|
}
|
||||||
@ -922,7 +922,7 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
|||||||
char* num_p = beginChar;
|
char* num_p = beginChar;
|
||||||
|
|
||||||
// We only consider hexadecimal values if they start with 0x
|
// We only consider hexadecimal values if they start with 0x
|
||||||
if ( str_len( num_p ) > 2 && num_p[ 0 ] == '0' && ( num_p[ 1 ] == 'x' || num_p[ 1 ] == 'X' ) )
|
if ( str_len( num_p ) > 2 && num_p[0] == '0' && ( num_p[1] == 'x' || num_p[1] == 'X' ) )
|
||||||
{
|
{
|
||||||
num_p += 2; // skip '0x' prefix
|
num_p += 2; // skip '0x' prefix
|
||||||
do
|
do
|
||||||
@ -950,7 +950,7 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
|||||||
adt_append_arr( root, NULL );
|
adt_append_arr( root, NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
root->nodes[ columnIndex ].nodes.append( rowItem );
|
root->nodes[columnIndex].nodes.append( rowItem );
|
||||||
|
|
||||||
if ( delimiter == delim )
|
if ( delimiter == delim )
|
||||||
{
|
{
|
||||||
@ -1059,17 +1059,17 @@ void csv_write_delimiter( FileInfo* file, CSV_Object* obj, char delimiter )
|
|||||||
if ( cols == 0 )
|
if ( cols == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sw rows = obj->nodes[ 0 ].nodes.num();
|
sw rows = obj->nodes[0].nodes.num();
|
||||||
if ( rows == 0 )
|
if ( rows == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
b32 has_headers = obj->nodes[ 0 ].name != NULL;
|
b32 has_headers = obj->nodes[0].name != NULL;
|
||||||
|
|
||||||
if ( has_headers )
|
if ( has_headers )
|
||||||
{
|
{
|
||||||
for ( sw i = 0; i < cols; i++ )
|
for ( sw i = 0; i < cols; i++ )
|
||||||
{
|
{
|
||||||
_csv_write_header( file, &obj->nodes[ i ] );
|
_csv_write_header( file, &obj->nodes[i] );
|
||||||
if ( i + 1 != cols )
|
if ( i + 1 != cols )
|
||||||
{
|
{
|
||||||
str_fmt_file( file, "%c", delimiter );
|
str_fmt_file( file, "%c", delimiter );
|
||||||
@ -1082,7 +1082,7 @@ void csv_write_delimiter( FileInfo* file, CSV_Object* obj, char delimiter )
|
|||||||
{
|
{
|
||||||
for ( sw i = 0; i < cols; i++ )
|
for ( sw i = 0; i < cols; i++ )
|
||||||
{
|
{
|
||||||
_csv_write_record( file, &obj->nodes[ i ].nodes[ r ] );
|
_csv_write_record( file, &obj->nodes[i].nodes[r] );
|
||||||
if ( i + 1 != cols )
|
if ( i + 1 != cols )
|
||||||
{
|
{
|
||||||
str_fmt_file( file, "%c", delimiter );
|
str_fmt_file( file, "%c", delimiter );
|
||||||
@ -1099,7 +1099,7 @@ String csv_write_string_delimiter( AllocatorInfo a, CSV_Object* obj, char delimi
|
|||||||
csv_write_delimiter( &tmp, obj, delimiter );
|
csv_write_delimiter( &tmp, obj, delimiter );
|
||||||
sw fsize;
|
sw fsize;
|
||||||
u8* buf = file_stream_buf( &tmp, &fsize );
|
u8* buf = file_stream_buf( &tmp, &fsize );
|
||||||
String output = String::make_length( a, ( char* )buf, fsize );
|
String output = String::make_length( a, (char*)buf, fsize );
|
||||||
file_close( &tmp );
|
file_close( &tmp );
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -86,8 +86,8 @@ struct ADT_Node
|
|||||||
/* adt data */
|
/* adt data */
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
char const* string;
|
char const* string;
|
||||||
Array< ADT_Node > nodes; ///< zpl_array
|
Array<ADT_Node> nodes; ///< zpl_array
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@ AlignAfterOpenBracket: BlockIndent
|
|||||||
AlignArrayOfStructures: Left
|
AlignArrayOfStructures: Left
|
||||||
AlignConsecutiveAssignments:
|
AlignConsecutiveAssignments:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
AcrossEmptyLines: true
|
AcrossEmptyLines: false
|
||||||
AcrossComments: false
|
AcrossComments: false
|
||||||
AlignCompound: true
|
AlignCompound: true
|
||||||
PadOperators: true
|
PadOperators: true
|
||||||
@ -24,17 +24,16 @@ AlignConsecutiveMacros:
|
|||||||
AcrossComments: false
|
AcrossComments: false
|
||||||
AlignEscapedNewlines: Left
|
AlignEscapedNewlines: Left
|
||||||
AlignOperands: DontAlign
|
AlignOperands: DontAlign
|
||||||
|
|
||||||
AlignTrailingComments: true
|
AlignTrailingComments: true
|
||||||
|
|
||||||
AllowAllArgumentsOnNextLine: false
|
AllowAllArgumentsOnNextLine: true
|
||||||
AllowAllConstructorInitializersOnNextLine: false
|
AllowAllConstructorInitializersOnNextLine: false
|
||||||
AllowAllParametersOfDeclarationOnNextLine: false
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
AllowShortBlocksOnASingleLine: Never
|
AllowShortBlocksOnASingleLine: Empty
|
||||||
AllowShortCaseLabelsOnASingleLine: false
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
AllowShortLambdasOnASingleLine: None
|
AllowShortLambdasOnASingleLine: None
|
||||||
AllowShortEnumsOnASingleLine: false
|
AllowShortEnumsOnASingleLine: false
|
||||||
AllowShortFunctionsOnASingleLine: None
|
AllowShortFunctionsOnASingleLine: Inline
|
||||||
AllowShortIfStatementsOnASingleLine: Never
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
AllowShortLoopsOnASingleLine: false
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
|
||||||
@ -60,16 +59,17 @@ BraceWrapping:
|
|||||||
AfterExternBlock: false
|
AfterExternBlock: false
|
||||||
BeforeCatch: false
|
BeforeCatch: false
|
||||||
BeforeElse: false
|
BeforeElse: false
|
||||||
|
BeforeWhile: false
|
||||||
IndentBraces: false
|
IndentBraces: false
|
||||||
SplitEmptyFunction: false
|
SplitEmptyFunction: false
|
||||||
SplitEmptyRecord: false
|
SplitEmptyRecord: false
|
||||||
SplitEmptyNamespace: false
|
SplitEmptyNamespace: false
|
||||||
BeforeLambdaBody: false
|
BeforeLambdaBody: false
|
||||||
BeforeWhile: false
|
|
||||||
|
|
||||||
BreakAfterAttributes: Always
|
BreakAfterAttributes: Always
|
||||||
BreakArrays: true
|
BreakArrays: true
|
||||||
# BreakBeforeInlineASMColon: OnlyMultiline
|
BreakBeforeInlineASMColon: OnlyMultiline
|
||||||
BreakBeforeBinaryOperators: NonAssignment
|
BreakBeforeBinaryOperators: NonAssignment
|
||||||
BreakBeforeBraces: Allman
|
BreakBeforeBraces: Allman
|
||||||
BreakBeforeInheritanceComma: true
|
BreakBeforeInheritanceComma: true
|
||||||
@ -79,7 +79,7 @@ BreakBeforeTernaryOperators: true
|
|||||||
BreakConstructorInitializers: BeforeComma
|
BreakConstructorInitializers: BeforeComma
|
||||||
BreakStringLiterals: true
|
BreakStringLiterals: true
|
||||||
|
|
||||||
ColumnLimit: 160
|
ColumnLimit: 240
|
||||||
|
|
||||||
CompactNamespaces: true
|
CompactNamespaces: true
|
||||||
|
|
||||||
@ -92,6 +92,7 @@ Cpp11BracedListStyle: false
|
|||||||
|
|
||||||
DeriveLineEnding: true
|
DeriveLineEnding: true
|
||||||
|
|
||||||
|
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||||
ExperimentalAutoDetectBinPacking: false
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
|
||||||
FixNamespaceComments: true
|
FixNamespaceComments: true
|
||||||
@ -102,7 +103,7 @@ IndentCaseBlocks: false
|
|||||||
IndentCaseLabels: true
|
IndentCaseLabels: true
|
||||||
IndentExternBlock: AfterExternBlock
|
IndentExternBlock: AfterExternBlock
|
||||||
IndentGotoLabels: true
|
IndentGotoLabels: true
|
||||||
IndentPPDirectives: None
|
IndentPPDirectives: BeforeHash
|
||||||
IndentRequires: true
|
IndentRequires: true
|
||||||
IndentWidth: 4
|
IndentWidth: 4
|
||||||
IndentWrappedFunctionNames: true
|
IndentWrappedFunctionNames: true
|
||||||
@ -126,9 +127,9 @@ ReferenceAlignment: Left
|
|||||||
|
|
||||||
ReflowComments: true
|
ReflowComments: true
|
||||||
|
|
||||||
# RequiresExpressionIndentation: OuterScope
|
RequiresExpressionIndentation: OuterScope
|
||||||
|
|
||||||
SeparateDefinitionBlocks: Always
|
SeparateDefinitionBlocks: Leave
|
||||||
|
|
||||||
ShortNamespaceLines: 40
|
ShortNamespaceLines: 40
|
||||||
|
|
||||||
@ -163,7 +164,9 @@ SpacesInLineCommentPrefix:
|
|||||||
SpacesInParentheses: true
|
SpacesInParentheses: true
|
||||||
SpacesInSquareBrackets: false
|
SpacesInSquareBrackets: false
|
||||||
|
|
||||||
Standard: c++17
|
Standard: c++20
|
||||||
|
|
||||||
|
StatementMacros: ['UPROPERTY', 'UFUNCTION', 'UCLASS', 'USTRUCT', 'UENUM', 'UINTERFACE', 'GENERATED_BODY']
|
||||||
|
|
||||||
TabWidth: 4
|
TabWidth: 4
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
Clear-Host
|
|
||||||
|
|
||||||
$path_scripts = $PSScriptRoot
|
$path_scripts = $PSScriptRoot
|
||||||
$path_helpers = join-path $path_scripts 'helpers'
|
$path_helpers = join-path $path_scripts 'helpers'
|
||||||
$path_root = split-path -Parent -Path $path_scripts
|
$path_root = split-path -Parent -Path $path_scripts
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
Clear-Host
|
|
||||||
|
|
||||||
$target_arch = Join-Path $PSScriptRoot 'helpers/target_arch.psm1'
|
$target_arch = Join-Path $PSScriptRoot 'helpers/target_arch.psm1'
|
||||||
$devshell = Join-Path $PSScriptRoot 'helpers/devshell.ps1'
|
$devshell = Join-Path $PSScriptRoot 'helpers/devshell.ps1'
|
||||||
$format_cpp = Join-Path $PSScriptRoot 'helpers/format_cpp.psm1'
|
$format_cpp = Join-Path $PSScriptRoot 'helpers/format_cpp.psm1'
|
||||||
@ -7,7 +5,7 @@ $incremental_checks = Join-Path $PSScriptRoot 'helpers/incremental_checks.ps1'
|
|||||||
$vendor_toolchain = Join-Path $PSScriptRoot 'helpers/vendor_toolchain.ps1'
|
$vendor_toolchain = Join-Path $PSScriptRoot 'helpers/vendor_toolchain.ps1'
|
||||||
$update_deps = Join-Path $PSScriptRoot 'update_deps.ps1'
|
$update_deps = Join-Path $PSScriptRoot 'update_deps.ps1'
|
||||||
|
|
||||||
$path_root = git rev-parse --show-toplevel
|
$path_root = git rev-parse --show-toplevel
|
||||||
|
|
||||||
Import-Module $target_arch
|
Import-Module $target_arch
|
||||||
Import-Module $format_cpp
|
Import-Module $format_cpp
|
||||||
@ -91,7 +89,7 @@ build-gengasa
|
|||||||
|
|
||||||
function run-gengasa
|
function run-gengasa
|
||||||
{
|
{
|
||||||
Push-Location $path_project
|
Push-Location $path_root
|
||||||
if ( Test-Path( $exe_gasagen ) ) {
|
if ( Test-Path( $exe_gasagen ) ) {
|
||||||
write-host "`nRunning GasaGen"
|
write-host "`nRunning GasaGen"
|
||||||
$time_taken = Measure-Command { & $exe_gasagen
|
$time_taken = Measure-Command { & $exe_gasagen
|
||||||
@ -102,15 +100,5 @@ function run-gengasa
|
|||||||
write-host "`GasaGen completed in $($time_taken.TotalMilliseconds) ms"
|
write-host "`GasaGen completed in $($time_taken.TotalMilliseconds) ms"
|
||||||
}
|
}
|
||||||
Pop-Location
|
Pop-Location
|
||||||
|
|
||||||
$path_AbilitySystem = join-path $path_gasa 'AbilitySystem'
|
|
||||||
$include = @(
|
|
||||||
'GasaAttributeSet.h', 'GasaAttributeSet.cpp'
|
|
||||||
)
|
|
||||||
format-cpp $path_AbilitySystem $include $null
|
|
||||||
|
|
||||||
$path_KismetPrivate = 'C:\projects\Unreal\Surgo\UE\Engine\Source\Editor\Kismet\Private\'
|
|
||||||
$include = @( 'SBlueprintActionMenu.cpp' )
|
|
||||||
format-cpp $path_KismetPrivate $include $null
|
|
||||||
}
|
}
|
||||||
run-gengasa
|
run-gengasa
|
||||||
|
@ -171,8 +171,8 @@ if ( $vendor -match "clang" )
|
|||||||
$map = join-path $path_output (split-path $map -Leaf)
|
$map = join-path $path_output (split-path $map -Leaf)
|
||||||
|
|
||||||
# This allows dll reloads at runtime to work (jankily, use below if not interested)
|
# This allows dll reloads at runtime to work (jankily, use below if not interested)
|
||||||
$pdb = $binary -replace '\.(exe|dll)$', "_$(get-random).pdb"
|
# $pdb = $binary -replace '\.(exe|dll)$', "_$(get-random).pdb"
|
||||||
# $pdb = $binary -replace '\.(exe|dll)$', ".pdb"
|
$pdb = $binary -replace '\.(exe|dll)$', ".pdb"
|
||||||
|
|
||||||
$compiler_args += @(
|
$compiler_args += @(
|
||||||
$flag_no_color_diagnostics,
|
$flag_no_color_diagnostics,
|
||||||
@ -250,8 +250,8 @@ if ( $vendor -match "clang" )
|
|||||||
$map = join-path $path_output (split-path $map -Leaf)
|
$map = join-path $path_output (split-path $map -Leaf)
|
||||||
|
|
||||||
# This allows dll reloads at runtime to work (jankily, use below if not interested)
|
# This allows dll reloads at runtime to work (jankily, use below if not interested)
|
||||||
$pdb = $binary -replace '\.(exe|dll)$', "_$(get-random).pdb"
|
# $pdb = $binary -replace '\.(exe|dll)$', "_$(get-random).pdb"
|
||||||
# $pdb = $binary -replace '\.(exe|dll)$', ".pdb"
|
$pdb = $binary -replace '\.(exe|dll)$', ".pdb"
|
||||||
|
|
||||||
$compiler_args += @(
|
$compiler_args += @(
|
||||||
$flag_no_color_diagnostics,
|
$flag_no_color_diagnostics,
|
||||||
@ -369,8 +369,8 @@ if ( $vendor -match "msvc" )
|
|||||||
$map = join-path $path_output (split-path $map -Leaf)
|
$map = join-path $path_output (split-path $map -Leaf)
|
||||||
|
|
||||||
# This allows dll reloads at runtime to work (jankily, use below if not interested)
|
# This allows dll reloads at runtime to work (jankily, use below if not interested)
|
||||||
$pdb = $binary -replace '\.(exe|dll)$', "_$(get-random).pdb"
|
# $pdb = $binary -replace '\.(exe|dll)$', "_$(get-random).pdb"
|
||||||
# $pdb = $binary -replace '\.(exe|dll)$', ".pdb"
|
$pdb = $binary -replace '\.(exe|dll)$', ".pdb"
|
||||||
|
|
||||||
$compiler_args += @(
|
$compiler_args += @(
|
||||||
$flag_nologo,
|
$flag_nologo,
|
||||||
@ -455,8 +455,8 @@ if ( $vendor -match "msvc" )
|
|||||||
$map = join-path $path_output (split-path $map -Leaf)
|
$map = join-path $path_output (split-path $map -Leaf)
|
||||||
|
|
||||||
# This allows dll reloads at runtime to work (jankily, use below if not interested)
|
# This allows dll reloads at runtime to work (jankily, use below if not interested)
|
||||||
$pdb = $binary -replace '\.(exe|dll)$', "_$(get-random).pdb"
|
# $pdb = $binary -replace '\.(exe|dll)$', "_$(get-random).pdb"
|
||||||
# $pdb = $binary -replace '\.(exe|dll)$', ".pdb"
|
$pdb = $binary -replace '\.(exe|dll)$', ".pdb"
|
||||||
|
|
||||||
$compiler_args += @(
|
$compiler_args += @(
|
||||||
$flag_nologo,
|
$flag_nologo,
|
||||||
|
Loading…
Reference in New Issue
Block a user