CameraMode, better settings, CustomGlobalInstance, another ports

This commit is contained in:
Oleg Petruny 2024-05-03 14:33:49 +02:00
parent 0b93ede282
commit b63299c50d
41 changed files with 396 additions and 42 deletions

View File

@ -0,0 +1,10 @@
[/Script/LiveCoding.LiveCodingSettings]
bEnabled=False
Startup=AutomaticButHidden
bEnableReinstancing=True
bAutomaticallyCompileNewClasses=True
bPreloadEngineModules=False
bPreloadEnginePluginModules=False
bPreloadProjectModules=True
bPreloadProjectPluginModules=True

View File

@ -4,6 +4,8 @@
GameDefaultMap=/Engine/Maps/Templates/OpenWorld
EditorStartupMap=/Game/Levels/Test/L_Test.L_Test
bUseSplitscreen=False
GlobalDefaultGameMode=/Game/Blueprints/GameModes/BP_MainGameMode.BP_MainGameMode_C
GameInstanceClass=/Game/Blueprints/Other/BP_CustomGameInstance.BP_CustomGameInstance_C
[/Script/WindowsTargetPlatform.WindowsTargetSettings]
DefaultGraphicsRHI=DefaultGraphicsRHI_DX12
@ -55,6 +57,7 @@ CommandletClass=Class'/Script/UnrealEd.WorldPartitionConvertCommandlet'
+ActiveGameNameRedirects=(OldGameName="TP_Blank",NewGameName="/Script/Lost_Edge")
+ActiveGameNameRedirects=(OldGameName="/Script/TP_Blank",NewGameName="/Script/Lost_Edge")
+ActiveClassRedirects=(OldClassName="TP_BlankGameModeBase",NewClassName="Lost_EdgeGameModeBase")
GameUserSettingsClassName=/Script/Lost_Edge.CustomGameUserSettings
[/Script/AndroidFileServerEditor.AndroidFileServerRuntimeSettings]
bEnablePlugin=True

View File

@ -0,0 +1,35 @@
[/Script/Lost_Edge.CustomGameUserSettings]
bUseMotionBlur=False
bShowFps=False
bMouseInverted=False
fMouseSensetivity=1.000000
bUseVSync=False
bUseDynamicResolution=False
ResolutionSizeX=1920
ResolutionSizeY=1080
LastUserConfirmedResolutionSizeX=1920
LastUserConfirmedResolutionSizeY=1080
WindowPosX=-1
WindowPosY=-1
FullscreenMode=1
LastConfirmedFullscreenMode=1
PreferredFullscreenMode=1
Version=5
AudioQualityLevel=0
LastConfirmedAudioQualityLevel=0
FrameRateLimit=0.000000
DesiredScreenWidth=1280
DesiredScreenHeight=720
LastUserConfirmedDesiredScreenWidth=1280
LastUserConfirmedDesiredScreenHeight=720
LastRecommendedScreenWidth=-1.000000
LastRecommendedScreenHeight=-1.000000
LastCPUBenchmarkResult=-1.000000
LastGPUBenchmarkResult=-1.000000
LastGPUBenchmarkMultiplier=1.000000
bUseHDRDisplayOutput=False
HDRDisplayOutputNits=1000
[/Script/Engine.GameUserSettings]
bUseDesiredScreenHeight=False

View File

@ -67,6 +67,7 @@ bCaptureMouseOnLaunch=True
bEnableLegacyInputScales=True
bEnableMotionControls=True
bFilterInputByPlatformUser=False
bEnableInputDeviceSubsystem=True
bShouldFlushPressedKeysOnViewportFocusLost=True
bEnableDynamicComponentInputBinding=True
bAlwaysShowTouchInterface=False
@ -77,21 +78,6 @@ DefaultViewportMouseCaptureMode=CapturePermanently_IncludingInitialMouseDown
DefaultViewportMouseLockMode=LockOnCapture
FOVScale=0.011110
DoubleClickTime=0.200000
+ActionMappings=(ActionName="Pause",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Escape)
+ActionMappings=(ActionName="Pause",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=P)
+ActionMappings=(ActionName="Interact",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=E)
+ActionMappings=(ActionName="SkipAny",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=SpaceBar)
+ActionMappings=(ActionName="Run",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftShift)
+ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=SpaceBar)
+ActionMappings=(ActionName="ChangeCamera",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=V)
+ActionMappings=(ActionName="Crouch",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftControl)
+ActionMappings=(ActionName="Crouch",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=C)
+AxisMappings=(AxisName="RotateX",Scale=1.000000,Key=MouseX)
+AxisMappings=(AxisName="RotateY",Scale=-1.000000,Key=MouseY)
+AxisMappings=(AxisName="MoveFB",Scale=1.000000,Key=W)
+AxisMappings=(AxisName="MoveLR",Scale=1.000000,Key=A)
+AxisMappings=(AxisName="MoveFB",Scale=-1.000000,Key=S)
+AxisMappings=(AxisName="MoveLR",Scale=-1.000000,Key=D)
DefaultPlayerInputClass=/Script/EnhancedInput.EnhancedPlayerInput
DefaultInputComponentClass=/Script/EnhancedInput.EnhancedInputComponent
DefaultTouchInterface=/Engine/MobileResources/HUD/DefaultVirtualJoysticks.DefaultVirtualJoysticks
@ -99,3 +85,15 @@ DefaultTouchInterface=/Engine/MobileResources/HUD/DefaultVirtualJoysticks.Defaul
+ConsoleKeys=Tilde
+ConsoleKeys=Caret
[/Script/EnhancedInput.EnhancedInputDeveloperSettings]
UserSettingsClass=/Script/EnhancedInput.EnhancedInputUserSettings
DefaultPlayerMappableKeyProfileClass=/Script/EnhancedInput.EnhancedPlayerMappableKeyProfile
DefaultWorldInputClass=/Script/EnhancedInput.EnhancedPlayerInput
bSendTriggeredEventsWhenInputIsFlushed=True
bEnableUserSettings=False
EnhancedInput.EnableDefaultMappingContexts=True
EnhancedInput.OnlyTriggerLastActionInChord=True
bLogOnDeprecatedConfigUsed=True
bEnableWorldSubsystem=False
EnhancedInput.bShouldLogAllWorldSubsystemInputs=False

Binary file not shown.

Binary file not shown.

BIN
Content/Fonts/FF_good_timing_bd_Raymond_Larabie_Font.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Fonts/FontFaces/FF_bowhouse_bold_Takuminokami.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Content/Fonts/Font_bowhouse_bold_Takuminokami_Font.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Fonts/Font_bowhouse_regular_Takuminokami_Font.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Fonts/Font_good_times_rg_Raymond_Larabie_Font.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

BIN
Content/Fonts/Font_primer_print_Raymond_Larabie_Font.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Content/Models/GrayBoxes/Materials/M_Gray.uasset (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1,13 +1,16 @@
{
"FileVersion": 3,
"EngineAssociation": "5.3",
"EngineAssociation": "{1596D39D-4A14-8FE8-BC5C-21A6B54321BE}",
"Category": "",
"Description": "",
"Modules": [
{
"Name": "Lost_Edge",
"Type": "Runtime",
"LoadingPhase": "Default"
"LoadingPhase": "Default",
"AdditionalDependencies": [
"Engine"
]
}
],
"Plugins": [

View File

@ -3,11 +3,13 @@
#include "APlayerBase.h"
#include "Camera/CameraComponent.h"
#include "CustomGameUserSettings.h"
#include "EnhancedInputSubsystems.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "Kismet/GameplayStatics.h"
#include "Kismet/KismetMathLibrary.h"
#include "MainGameModeBase.h"
APlayerBase::APlayerBase()
{
@ -34,12 +36,6 @@ void APlayerBase::BeginPlay()
camera->PostProcessSettings.MotionBlurAmount = gameSettings->bUseMotionBlur ? 1.0f : 0.0f;
}
if(gameSettings->bShowFps)
world->Exec(world, TEXT("show stats"));
mouseInvert = gameSettings->bMouseInverted;
mouseSensetivity = gameSettings->GetMouseSensetivity();
if(inputMapping)
{
if(auto player = Cast<APlayerController>(GetController()))
@ -47,7 +43,7 @@ void APlayerBase::BeginPlay()
if(auto inputSubsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(player->GetLocalPlayer()))
{
inputSubsystem->ClearAllMappings();
inputSubsystem->AddMappingContext(inputMapping, 0);
inputSubsystem->AddMappingContext(inputMapping.LoadSynchronous(), 0);
}
}
}
@ -65,7 +61,17 @@ void APlayerBase::Tick(float DeltaTime)
void APlayerBase::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}
void APlayerBase::SwitchToCameraPawn()
{
if(auto gamemode_base = UGameplayStatics::GetGameMode(GetWorld()))
{
if(auto gamemode = Cast<AMainGameModeBase>(gamemode_base))
{
gamemode->SwitchCameraMode();
}
}
}
void APlayerBase::MoveCamera(FVector2D value)
@ -73,11 +79,6 @@ void APlayerBase::MoveCamera(FVector2D value)
if(cameraLocked)
return;
if(mouseInvert)
value.Y *= -1;
value *= mouseSensetivity;
AddControllerYawInput(value.X);
AddControllerPitchInput(value.Y);
}

View File

@ -2,7 +2,6 @@
#pragma once
#include "Camera/CameraComponent.h"
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "InputMappingContext.h"
@ -18,12 +17,14 @@ public:
APlayerBase();
virtual void Tick(float DeltaTime) override;
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
protected:
virtual void BeginPlay() override;
UFUNCTION(BlueprintCallable, Category = CameraMode)
void SwitchToCameraPawn();
UFUNCTION(BlueprintCallable, Category = Character)
void MoveCamera(FVector2D value);
UFUNCTION(BlueprintCallable, Category = Character)
@ -33,7 +34,7 @@ protected:
void SwitchRun(bool run);
UPROPERTY(EditDefaultsOnly)
UInputMappingContext* inputMapping;
TSoftObjectPtr<UInputMappingContext> inputMapping;
UPROPERTY(EditDefaultsOnly)
float moveSpeed = 200;
@ -55,9 +56,6 @@ protected:
// not visible :(
//UPROPERTY(EditDefaultsOnly)
//UCameraComponent* camera;
bool mouseInvert = false;
float mouseSensetivity = 1.0f;
UPROPERTY(EditAnywhere)
bool cameraLocked = false;

View File

@ -0,0 +1,85 @@
// Oleg Petruny proprietary.
#include "CameraModeBase.h"
#include "Camera/CameraComponent.h"
#include "CustomGameUserSettings.h"
#include "EnhancedInputSubsystems.h"
#include "GameFramework/Character.h"
#include "GameFramework/PawnMovementComponent.h"
#include "Kismet/GameplayStatics.h"
#include "MainGameModeBase.h"
ACameraModeBase::ACameraModeBase()
{
PrimaryActorTick.bCanEverTick = true;
}
void ACameraModeBase::BeginPlay()
{
Super::BeginPlay();
auto world = GetWorld();
//GetMovementComponent()->speed
// GetCharacterMovement()->MaxWalkSpeed = moveSpeed;
auto gameSettings = UCustomGameUserSettings::GetCustomGameUserSettings();
if(auto camera = FindComponentByClass<UCameraComponent>())
{
camera->PostProcessSettings.MotionBlurAmount = gameSettings->bUseMotionBlur ? 1.0f : 0.0f;
}
if(inputMapping)
{
if(auto player = Cast<APlayerController>(GetController()))
{
if(auto inputSubsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(player->GetLocalPlayer()))
{
inputSubsystem->ClearAllMappings();
inputSubsystem->AddMappingContext(inputMapping.LoadSynchronous(), 0);
}
}
}
}
void ACameraModeBase::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
// stabilize move speed by fps
AddActorLocalOffset(ConsumeMovementInputVector() * DeltaTime);
}
void ACameraModeBase::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}
void ACameraModeBase::SwitchToPlayerPawn()
{
if(auto gamemode_base = UGameplayStatics::GetGameMode(GetWorld()))
{
if(auto gamemode = Cast<AMainGameModeBase>(gamemode_base))
{
gamemode->SwitchCameraMode();
}
}
}
void ACameraModeBase::ElevatePawn(float value)
{
AddMovementInput(FVector::UpVector, value);
}
void ACameraModeBase::SwitchRun(bool run)
{
//if(run)
// GetMovement()->MaxWalkSpeed = moveSpeed * runSpeedMultiplier;
//else
// GetCharacterMovement()->MaxWalkSpeed = moveSpeed;
}

View File

@ -0,0 +1,43 @@
// Oleg Petruny proprietary.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/SpectatorPawn.h"
#include "InputMappingContext.h"
#include "CameraModeBase.generated.h"
UCLASS()
class ACameraModeBase : public ASpectatorPawn
{
GENERATED_BODY()
public:
ACameraModeBase();
virtual void Tick(float DeltaTime) override;
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
protected:
virtual void BeginPlay() override;
UFUNCTION(BlueprintCallable, Category = CameraMode)
void SwitchToPlayerPawn();
UFUNCTION(BlueprintCallable, Category = Pawn)
void ElevatePawn(float value);
UFUNCTION(BlueprintCallable, Category = Pawn)
void SwitchRun(bool run);
UPROPERTY(EditDefaultsOnly)
TSoftObjectPtr<UInputMappingContext> inputMapping;
UPROPERTY(EditDefaultsOnly)
float moveSpeed = 200;
UPROPERTY(EditDefaultsOnly)
float runSpeedMultiplier = 4;
private:
};

View File

@ -0,0 +1,43 @@
// Oleg Petruny proprietary.
#include "CustomGameInstanceBase.h"
#include "CustomGameUserSettings.h"
#include "EnhancedInputLibrary.h"
void UCustomGameInstanceBase::Init()
{
//Super::Init();
ApplyMouseSettings();
}
void UCustomGameInstanceBase::ApplyMouseSettings()
{
if(auto gameSettings = UCustomGameUserSettings::GetCustomGameUserSettings())
{
for(auto context_it = defaultInputContexts.begin(); context_it != defaultInputContexts.end(); ++context_it)
{
auto& mappings = (*context_it).LoadSynchronous()->GetMappings();
for(auto mapping_it = mappings.begin(); mapping_it != mappings.end(); ++mapping_it)
{
if((*mapping_it).Key == EKeys::Mouse2D)
{
for(auto modifiers_it = (*mapping_it).Modifiers.begin(); modifiers_it != (*mapping_it).Modifiers.end(); ++modifiers_it)
{
if(auto negate_modifier = Cast<UInputModifierNegate>(*modifiers_it))
{
negate_modifier->bY = !gameSettings->bMouseInverted;
}
if(auto scalar_modifier = Cast<UInputModifierScalar>(*modifiers_it))
{
scalar_modifier->Scalar = FVector{ gameSettings->GetMouseSensetivity() };
}
}
}
}
UEnhancedInputLibrary::RequestRebuildControlMappingsUsingContext((*context_it).LoadSynchronous());
}
}
}

View File

@ -0,0 +1,25 @@
// Oleg Petruny proprietary.
#pragma once
#include "CoreMinimal.h"
#include "Engine/GameInstance.h"
#include "InputMappingContext.h"
#include "CustomGameInstanceBase.generated.h"
UCLASS()
class UCustomGameInstanceBase : public UGameInstance
{
GENERATED_BODY()
public:
virtual void Init() override;
UFUNCTION(BlueprintCallable, Category = Settings)
void ApplyMouseSettings();
protected:
UPROPERTY(EditDefaultsOnly)
TArray<TSoftObjectPtr<UInputMappingContext>> defaultInputContexts;
};

View File

@ -1,7 +1,11 @@
// Oleg Petruny proprietary.
#include "CustomGameUserSettings.h"
#include "CustomGameInstanceBase.h"
#include "Kismet/GameplayStatics.h"
UCustomGameUserSettings::UCustomGameUserSettings(const FObjectInitializer& ObjectInitializer) :Super(ObjectInitializer)
{
bUseMotionBlur = false;

View File

@ -7,9 +7,6 @@
#include "CustomGameUserSettings.generated.h"
/**
*
*/
UCLASS()
class UCustomGameUserSettings : public UGameUserSettings
{
@ -28,17 +25,17 @@ public:
UFUNCTION(BlueprintCallable, Category = Settings)
float GetMouseSensetivity() const;
UPROPERTY(config)
UPROPERTY(Config, BlueprintReadWrite)
bool bUseMotionBlur;
UPROPERTY(config)
UPROPERTY(Config, BlueprintReadWrite)
bool bShowFps;
UPROPERTY(config)
UPROPERTY(Config, BlueprintReadWrite)
bool bMouseInverted;
protected:
UPROPERTY(config)
UPROPERTY(Config)
float fMouseSensetivity;
};

View File

@ -0,0 +1,41 @@
// Oleg Petruny proprietary.
#include "MainGameModeBase.h"
#include "Engine/World.h"
#include "GameFramework/SpectatorPawn.h"
#include "Kismet/GameplayStatics.h"
void AMainGameModeBase::SwitchCameraMode()
{
if(!_player_pawn)
{
if(auto controller = UGameplayStatics::GetPlayerController(GetWorld(), 0))
{
if(auto pawn = controller->GetPawn())
{
auto spawnLoc = pawn->GetActorLocation();
auto spawnRot = pawn->GetActorRotation();
if(auto cameraPawn = GetWorld()->SpawnActor<APawn>(SpectatorClass, spawnLoc, spawnRot))
{
_player_pawn = pawn;
controller->Possess(cameraPawn);
cameraPawn->BeginPlay();
}
}
}
}
else
{
if(auto controller = UGameplayStatics::GetPlayerController(GetWorld(), 0))
{
if(auto pawn = controller->GetPawn())
{
controller->Possess(_player_pawn);
pawn->Destroy();
}
}
}
}

View File

@ -0,0 +1,23 @@
// Oleg Petruny proprietary.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "GameFramework/Pawn.h"
#include "MainGameModeBase.generated.h"
UCLASS()
class AMainGameModeBase : public AGameModeBase
{
GENERATED_BODY()
public:
void SwitchCameraMode();
protected:
private:
APawn* _player_pawn = nullptr;
};