diff --git a/Config/DefaultInput.ini b/Config/DefaultInput.ini index 411619e..ca152e1 100644 --- a/Config/DefaultInput.ini +++ b/Config/DefaultInput.ini @@ -61,8 +61,8 @@ bAltEnterTogglesFullscreen=True bF11TogglesFullscreen=True bUseMouseForTouch=False -bEnableMouseSmoothing=True -bEnableFOVScaling=True +bEnableMouseSmoothing=False +bEnableFOVScaling=False bCaptureMouseOnLaunch=True bEnableLegacyInputScales=True bEnableMotionControls=True diff --git a/Content/Blueprints/GameModes/BP_MainGameMode.uasset b/Content/Blueprints/GameModes/BP_MainGameMode.uasset new file mode 100644 index 0000000..9135344 Binary files /dev/null and b/Content/Blueprints/GameModes/BP_MainGameMode.uasset differ diff --git a/Content/StarterContent/Textures/T_Ground_Gravel_D.uasset b/Content/StarterContent/Textures/T_Ground_Gravel_D.uasset new file mode 100644 index 0000000..a9f9cc6 Binary files /dev/null and b/Content/StarterContent/Textures/T_Ground_Gravel_D.uasset differ diff --git a/Content/StarterContent/Textures/T_Ground_Gravel_N.uasset b/Content/StarterContent/Textures/T_Ground_Gravel_N.uasset new file mode 100644 index 0000000..08ca85e Binary files /dev/null and b/Content/StarterContent/Textures/T_Ground_Gravel_N.uasset differ diff --git a/Content/StarterContent/Textures/T_MacroVariation.uasset b/Content/StarterContent/Textures/T_MacroVariation.uasset new file mode 100644 index 0000000..0096f2d Binary files /dev/null and b/Content/StarterContent/Textures/T_MacroVariation.uasset differ diff --git a/Content/UI/Blueprints/UI_Crosshair.uasset b/Content/UI/Blueprints/UI_Crosshair.uasset new file mode 100644 index 0000000..6edc669 Binary files /dev/null and b/Content/UI/Blueprints/UI_Crosshair.uasset differ diff --git a/Content/UI/Blueprints/UI_DevelopBuildWarning.uasset b/Content/UI/Blueprints/UI_DevelopBuildWarning.uasset new file mode 100644 index 0000000..623edfb Binary files /dev/null and b/Content/UI/Blueprints/UI_DevelopBuildWarning.uasset differ diff --git a/Lost_Edge.uproject b/Lost_Edge.uproject index 0f253f9..13b827c 100644 --- a/Lost_Edge.uproject +++ b/Lost_Edge.uproject @@ -9,7 +9,10 @@ "Type": "Runtime", "LoadingPhase": "Default", "AdditionalDependencies": [ - "Engine" + "Engine", + "Slate", + "SlateCore", + "UMG" ] } ], diff --git a/Source/Lost_Edge/Lost_Edge.Build.cs b/Source/Lost_Edge/Lost_Edge.Build.cs index 542bd5f..abe6f48 100644 --- a/Source/Lost_Edge/Lost_Edge.Build.cs +++ b/Source/Lost_Edge/Lost_Edge.Build.cs @@ -6,16 +6,15 @@ public class Lost_Edge : ModuleRules { public Lost_Edge(ReadOnlyTargetRules Target) : base(Target) { PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; - PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput" }); + PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" }); - PrivateDependencyModuleNames.AddRange(new string[] { }); - - // Uncomment if you are using Slate UI - // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" }); + PrivateDependencyModuleNames.AddRange(new string[] { "EnhancedInput", "UMG" }); //"Slate", "SlateCore" // Uncomment if you are using online features // PrivateDependencyModuleNames.Add("OnlineSubsystem"); // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true + + // GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Yellow, FString::Printf(TEXT("Rescaled: %f"), scale)); } } diff --git a/Source/Lost_Edge/Private/APlayerBase.cpp b/Source/Lost_Edge/Private/APlayerBase.cpp index 845fa6e..2e05e59 100644 --- a/Source/Lost_Edge/Private/APlayerBase.cpp +++ b/Source/Lost_Edge/Private/APlayerBase.cpp @@ -38,9 +38,9 @@ void APlayerBase::BeginPlay() if(inputMapping) { - if(auto player = Cast(GetController())) + if(auto PC = Cast(GetController())) { - if(auto inputSubsystem = ULocalPlayer::GetSubsystem(player->GetLocalPlayer())) + if(auto inputSubsystem = ULocalPlayer::GetSubsystem(PC->GetLocalPlayer())) { inputSubsystem->ClearAllMappings(); inputSubsystem->AddMappingContext(inputMapping.LoadSynchronous(), 0); diff --git a/Source/Lost_Edge/Private/APlayerBase.h b/Source/Lost_Edge/Private/APlayerBase.h index d66c6cf..7fe2179 100644 --- a/Source/Lost_Edge/Private/APlayerBase.h +++ b/Source/Lost_Edge/Private/APlayerBase.h @@ -36,9 +36,9 @@ protected: UPROPERTY(EditDefaultsOnly) TSoftObjectPtr inputMapping; - UPROPERTY(EditDefaultsOnly) + UPROPERTY(EditAnywhere) float moveSpeed = 200; - UPROPERTY(EditDefaultsOnly) + UPROPERTY(EditAnywhere) float runSpeedMultiplier = 4; UPROPERTY(EditAnywhere) @@ -48,9 +48,9 @@ protected: UPROPERTY(EditAnywhere) bool runLocked = false; - UPROPERTY(EditDefaultsOnly) + UPROPERTY(EditAnywhere) float minPitch = -80; - UPROPERTY(EditDefaultsOnly) + UPROPERTY(EditAnywhere) float maxPitch = 65; // not visible :( diff --git a/Source/Lost_Edge/Private/CameraModeBase.cpp b/Source/Lost_Edge/Private/CameraModeBase.cpp index de81cfa..fb0f45d 100644 --- a/Source/Lost_Edge/Private/CameraModeBase.cpp +++ b/Source/Lost_Edge/Private/CameraModeBase.cpp @@ -35,9 +35,9 @@ void ACameraModeBase::BeginPlay() if(inputMapping) { - if(auto player = Cast(GetController())) + if(auto PC = Cast(GetController())) { - if(auto inputSubsystem = ULocalPlayer::GetSubsystem(player->GetLocalPlayer())) + if(auto inputSubsystem = ULocalPlayer::GetSubsystem(PC->GetLocalPlayer())) { inputSubsystem->ClearAllMappings(); inputSubsystem->AddMappingContext(inputMapping.LoadSynchronous(), 0); diff --git a/Source/Lost_Edge/Private/CustomGameInstanceBase.cpp b/Source/Lost_Edge/Private/CustomGameInstanceBase.cpp index 034485c..b339581 100644 --- a/Source/Lost_Edge/Private/CustomGameInstanceBase.cpp +++ b/Source/Lost_Edge/Private/CustomGameInstanceBase.cpp @@ -8,7 +8,7 @@ void UCustomGameInstanceBase::Init() { - //Super::Init(); + UGameInstance::Init(); ApplyMouseSettings(); } @@ -32,7 +32,7 @@ void UCustomGameInstanceBase::ApplyMouseSettings() } if(auto scalar_modifier = Cast(*modifiers_it)) { - scalar_modifier->Scalar = FVector{ gameSettings->GetMouseSensetivity() }; + scalar_modifier->Scalar = FVector{ gameSettings->GetMouseSensetivity() * 0.5 }; } } } diff --git a/Source/Lost_Edge/Private/CustomGameUserSettings.cpp b/Source/Lost_Edge/Private/CustomGameUserSettings.cpp index 7f31e74..8192440 100644 --- a/Source/Lost_Edge/Private/CustomGameUserSettings.cpp +++ b/Source/Lost_Edge/Private/CustomGameUserSettings.cpp @@ -21,7 +21,7 @@ UCustomGameUserSettings* UCustomGameUserSettings::GetCustomGameUserSettings() void UCustomGameUserSettings::SetMouseSensetivity(float value) { - fMouseSensetivity = FMath::Clamp(value, 0.1f, 1.0f); + fMouseSensetivity = FMath::Clamp(value, 0.1f, 2.0f); } float UCustomGameUserSettings::GetMouseSensetivity() const diff --git a/Source/Lost_Edge/Private/CustomGameUserSettings.h b/Source/Lost_Edge/Private/CustomGameUserSettings.h index 6400696..ae25dfb 100644 --- a/Source/Lost_Edge/Private/CustomGameUserSettings.h +++ b/Source/Lost_Edge/Private/CustomGameUserSettings.h @@ -17,11 +17,11 @@ public: static UCustomGameUserSettings* GetCustomGameUserSettings(); // Sets mouse sensetivity multiplier - // @param value [0.1 - 1.0] + // @param value [0.1 - 2.0] UFUNCTION(BlueprintCallable, Category = Settings) void SetMouseSensetivity(float value); - // Returns mouse sensetivity multiplier in [0.1 - 1.0] + // Returns mouse sensetivity multiplier in [0.1 - 2.0] UFUNCTION(BlueprintCallable, Category = Settings) float GetMouseSensetivity() const; diff --git a/Source/Lost_Edge/Private/MainGameModeBase.cpp b/Source/Lost_Edge/Private/MainGameModeBase.cpp index cdd4fbf..4c2750d 100644 --- a/Source/Lost_Edge/Private/MainGameModeBase.cpp +++ b/Source/Lost_Edge/Private/MainGameModeBase.cpp @@ -7,35 +7,119 @@ #include "GameFramework/SpectatorPawn.h" #include "Kismet/GameplayStatics.h" +void AMainGameModeBase::StartPlay() +{ + AGameModeBase::StartPlay(); + + InstantiateOverlayWidgets(); +} + +bool AMainGameModeBase::SetPause(APlayerController* PC, FCanUnpause CanUnpauseDelegate) +{ + if(IsPaused()) + { + HideOverlayWidgets(); + } + else + { + ShowOverlayWidgets(); + } + + return AGameModeBase::SetPause(PC, CanUnpauseDelegate); +} + void AMainGameModeBase::SwitchCameraMode() { - if(!_player_pawn) + static TWeakObjectPtr _playerPawn = nullptr; + + if(auto PC = UGameplayStatics::GetPlayerController(GetWorld(), 0)) { - if(auto controller = UGameplayStatics::GetPlayerController(GetWorld(), 0)) + if(auto pawn = PC->GetPawn()) { - if(auto pawn = controller->GetPawn()) + if(_playerPawn.IsValid()) { auto spawnLoc = pawn->GetActorLocation(); auto spawnRot = pawn->GetActorRotation(); if(auto cameraPawn = GetWorld()->SpawnActor(SpectatorClass, spawnLoc, spawnRot)) { - _player_pawn = pawn; - controller->Possess(cameraPawn); - cameraPawn->BeginPlay(); + _playerPawn = pawn; + PC->Possess(cameraPawn); } } - } - } - else - { - if(auto controller = UGameplayStatics::GetPlayerController(GetWorld(), 0)) - { - if(auto pawn = controller->GetPawn()) + else { - controller->Possess(_player_pawn); + PC->Possess(_playerPawn.Get()); pawn->Destroy(); + _playerPawn = nullptr; } } } + UpdateOverlayWidgetsOwner(); +} + +void AMainGameModeBase::InstantiateOverlayWidgets() +{ + if(auto PC = UGameplayStatics::GetPlayerController(GetWorld(), 0)) + { + for(auto widget : permaOverlayWidgets) + { + if(auto instance = CreateWidget(PC, widget)) + { + permaOverlayWidgetsInstances.Add(instance); + instance->AddToViewport(); + } + } + for(auto widget : overlayWidgets) + { + if(auto instance = CreateWidget(PC, widget)) + { + overlayWidgetsInstances.Add(instance); + instance->AddToViewport(); + } + } + } +} + +void AMainGameModeBase::HideOverlayWidgets() +{ + for(auto widget : overlayWidgetsInstances) + { + if(widget.IsValid()) + { + widget->SetVisibility(ESlateVisibility::Hidden); + } + } +} + +void AMainGameModeBase::ShowOverlayWidgets() +{ + for(auto widget : overlayWidgetsInstances) + { + if(widget.IsValid()) + { + widget->SetVisibility(ESlateVisibility::Visible); + } + } +} + +void AMainGameModeBase::UpdateOverlayWidgetsOwner() +{ + if(auto PC = UGameplayStatics::GetPlayerController(GetWorld(), 0)) + { + for(auto widget : permaOverlayWidgetsInstances) + { + if(widget.IsValid()) + { + widget->SetOwningPlayer(PC); + } + } + for(auto widget : overlayWidgetsInstances) + { + if(widget.IsValid()) + { + widget->SetOwningPlayer(PC); + } + } + } } \ No newline at end of file diff --git a/Source/Lost_Edge/Private/MainGameModeBase.h b/Source/Lost_Edge/Private/MainGameModeBase.h index caf2255..4aadc7c 100644 --- a/Source/Lost_Edge/Private/MainGameModeBase.h +++ b/Source/Lost_Edge/Private/MainGameModeBase.h @@ -2,6 +2,7 @@ #pragma once +#include "Blueprint/UserWidget.h" #include "CoreMinimal.h" #include "GameFramework/GameModeBase.h" #include "GameFramework/Pawn.h" @@ -14,10 +15,26 @@ class AMainGameModeBase : public AGameModeBase GENERATED_BODY() public: + virtual void StartPlay() override; + virtual bool SetPause(APlayerController* PC, FCanUnpause CanUnpauseDelegate = FCanUnpause()) override; + void SwitchCameraMode(); + protected: + UPROPERTY(EditDefaultsOnly) + TArray> permaOverlayWidgets; // never hidden + TArray> permaOverlayWidgetsInstances; + + UPROPERTY(EditDefaultsOnly) + TArray> overlayWidgets; // hidden in pause + TArray> overlayWidgetsInstances; + private: - APawn* _player_pawn = nullptr; + inline void InstantiateOverlayWidgets(); + + void HideOverlayWidgets(); + void ShowOverlayWidgets(); + void UpdateOverlayWidgetsOwner(); }; diff --git a/Source/Lost_Edge/Private/ResolutionResponsiveUserWidget.cpp b/Source/Lost_Edge/Private/ResolutionResponsiveUserWidget.cpp new file mode 100644 index 0000000..43fe3a5 --- /dev/null +++ b/Source/Lost_Edge/Private/ResolutionResponsiveUserWidget.cpp @@ -0,0 +1,40 @@ +// Oleg Petruny proprietary. + + +#include "ResolutionResponsiveUserWidget.h" + +#include "Components/PanelSlot.h" +#include "UnrealClient.h" + +bool UResolutionResponsiveUserWidget::Initialize() +{ + _viewportResizedEventHandle = FViewport::ViewportResizedEvent.AddUObject(this, &UResolutionResponsiveUserWidget::Rescale); + + return UUserWidget::Initialize(); +} + +void UResolutionResponsiveUserWidget::BeginDestroy() +{ + if(_viewportResizedEventHandle.IsValid()) + { + FViewport::ViewportResizedEvent.Remove(_viewportResizedEventHandle); + } + + UUserWidget::BeginDestroy(); +} + +void UResolutionResponsiveUserWidget::Rescale(FViewport* ViewPort, uint32 val) +{ + _scale = (float)defaultResolution / ViewPort->GetSizeXY().GetMin(); + Rescale(); +} + +void UResolutionResponsiveUserWidget::Rescale_Implementation() +{ + SetRenderScale(FVector2D{ _scale }); +} + +float UResolutionResponsiveUserWidget::GetScale() const +{ + return _scale; +} \ No newline at end of file diff --git a/Source/Lost_Edge/Private/ResolutionResponsiveUserWidget.h b/Source/Lost_Edge/Private/ResolutionResponsiveUserWidget.h new file mode 100644 index 0000000..b6c15f1 --- /dev/null +++ b/Source/Lost_Edge/Private/ResolutionResponsiveUserWidget.h @@ -0,0 +1,37 @@ +// Oleg Petruny proprietary. + +#pragma once + +#include "Blueprint/UserWidget.h" +#include "CoreMinimal.h" + +#include "ResolutionResponsiveUserWidget.generated.h" + +UCLASS() +class UResolutionResponsiveUserWidget : public UUserWidget +{ + GENERATED_BODY() + +public: + //UResolutionResponsiveUserWidget(const FObjectInitializer& ObjectInitializer); + virtual bool Initialize() override; + virtual void BeginDestroy() override; + +protected: + void Rescale(FViewport* ViewPort, uint32 val); + + UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = ResolutionResponsiveWidget) + void Rescale(); + virtual void Rescale_Implementation(); + + UPROPERTY(EditDefaultsOnly) + int32 defaultResolution = 1080; + + UFUNCTION(BlueprintCallable, Category = ResolutionResponsiveWidget) + float GetScale() const; + +private: + float _scale; + + FDelegateHandle _viewportResizedEventHandle; +};