diff --git a/Config/DefaultGame.ini b/Config/DefaultGame.ini index c809543..2c67ad5 100644 --- a/Config/DefaultGame.ini +++ b/Config/DefaultGame.ini @@ -1,7 +1,82 @@ - -[/Script/EngineSettings.GeneralProjectSettings] -ProjectID=4C5E5CFA41A35A1F55DA489142C41F76 - -[StartupActions] -bAddPacks=True -InsertPack=(PackSource="StarterContent.upack",PackName="StarterContent") + + +[/Script/EngineSettings.GeneralProjectSettings] +ProjectID=4C5E5CFA41A35A1F55DA489142C41F76 + +[StartupActions] +bAddPacks=True +InsertPack=(PackSource="StarterContent.upack",PackName="StarterContent") + +[/Script/UnrealEd.ProjectPackagingSettings] +Build=IfProjectHasCode +BuildConfiguration=PPBC_Development +BuildTarget= +StagingDirectory=(Path="") +FullRebuild=False +ForDistribution=False +IncludeDebugFiles=False +BlueprintNativizationMethod=Disabled +bIncludeNativizedAssetsInProjectGeneration=False +bExcludeMonolithicEngineHeadersInNativizedCode=False +UsePakFile=True +bUseIoStore=False +bMakeBinaryConfig=False +bGenerateChunks=False +bGenerateNoChunks=False +bChunkHardReferencesOnly=False +bForceOneChunkPerFile=False +MaxChunkSize=0 +bBuildHttpChunkInstallData=False +HttpChunkInstallDataDirectory=(Path="") +bCompressed=True +PakFileCompressionFormats=Oodle +bForceUseProjectCompressionFormatIgnoreHardwareOverride=False +PakFileAdditionalCompressionOptions=-compressionblocksize=256KB +PakFileCompressionMethod=Kraken +PakFileCompressionLevel_DebugDevelopment=3 +PakFileCompressionLevel_TestShipping=5 +PakFileCompressionLevel_Distribution=7 +HttpChunkInstallDataVersion= +IncludePrerequisites=True +IncludeAppLocalPrerequisites=False +bShareMaterialShaderCode=True +bDeterministicShaderCodeOrder=False +bSharedMaterialNativeLibraries=True +ApplocalPrerequisitesDirectory=(Path="") +IncludeCrashReporter=False +InternationalizationPreset=English +-CulturesToStage=en ++CulturesToStage=en +LocalizationTargetCatchAllChunkId=0 +bCookAll=False +bCookMapsOnly=False +bSkipEditorContent=False +bSkipMovies=False +-IniKeyBlacklist=KeyStorePassword +-IniKeyBlacklist=KeyPassword +-IniKeyBlacklist=rsa.privateexp +-IniKeyBlacklist=rsa.modulus +-IniKeyBlacklist=rsa.publicexp +-IniKeyBlacklist=aes.key +-IniKeyBlacklist=SigningPublicExponent +-IniKeyBlacklist=SigningModulus +-IniKeyBlacklist=SigningPrivateExponent +-IniKeyBlacklist=EncryptionKey +-IniKeyBlacklist=IniKeyBlacklist +-IniKeyBlacklist=IniSectionBlacklist ++IniKeyBlacklist=KeyStorePassword ++IniKeyBlacklist=KeyPassword ++IniKeyBlacklist=rsa.privateexp ++IniKeyBlacklist=rsa.modulus ++IniKeyBlacklist=rsa.publicexp ++IniKeyBlacklist=aes.key ++IniKeyBlacklist=SigningPublicExponent ++IniKeyBlacklist=SigningModulus ++IniKeyBlacklist=SigningPrivateExponent ++IniKeyBlacklist=EncryptionKey ++IniKeyBlacklist=IniKeyBlacklist ++IniKeyBlacklist=IniSectionBlacklist ++MapsToCook=(FilePath="/Game/StarterContent/Maps/Minimal_Default") ++MapsToCook=(FilePath="/Game/Levels/MainMenu") ++MapsToCook=(FilePath="/Game/Levels/YannTest") + diff --git a/Config/DefaultInput.ini b/Config/DefaultInput.ini new file mode 100644 index 0000000..73c48a4 --- /dev/null +++ b/Config/DefaultInput.ini @@ -0,0 +1,87 @@ +[/Script/Engine.InputSettings] +-AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) +-AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) +-AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) +-AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) +-AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f)) +-AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f)) +-AxisConfig=(AxisKeyName="Mouse2D",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f)) ++AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Mouse2D",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MouseWheelAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Gamepad_LeftTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Gamepad_RightTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Gamepad_Special_Left_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Gamepad_Special_Left_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Daydream_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Daydream_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Daydream_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Daydream_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Vive_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Vive_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Vive_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Vive_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Vive_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="Vive_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MixedReality_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MixedReality_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MixedReality_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MixedReality_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MixedReality_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MixedReality_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MixedReality_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MixedReality_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MixedReality_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="MixedReality_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="OculusTouch_Left_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="OculusTouch_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="OculusTouch_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="OculusTouch_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="OculusTouch_Right_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="OculusTouch_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="OculusTouch_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="OculusTouch_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Left_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Left_Grip_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_Touch",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Right_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Right_Grip_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) ++AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) +bAltEnterTogglesFullscreen=True +bF11TogglesFullscreen=True +bUseMouseForTouch=False +bEnableMouseSmoothing=True +bEnableFOVScaling=True +bCaptureMouseOnLaunch=True +bAlwaysShowTouchInterface=False +bShowConsoleOnFourFingerTap=True +bEnableGestureRecognizer=False +bUseAutocorrect=False +DefaultViewportMouseCaptureMode=CapturePermanently_IncludingInitialMouseDown +DefaultViewportMouseLockMode=LockOnCapture +FOVScale=0.011110 +DoubleClickTime=0.200000 ++ActionMappings=(ActionName="PauseAction",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=M) ++ActionMappings=(ActionName="PauseAction",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Escape) +DefaultPlayerInputClass=/Script/Engine.PlayerInput +DefaultInputComponentClass=/Script/Engine.InputComponent +DefaultTouchInterface=/Engine/MobileResources/HUD/DefaultVirtualJoysticks.DefaultVirtualJoysticks +-ConsoleKeys=Tilde ++ConsoleKeys=Tilde + diff --git a/Content/BP/BP_MyGameInstances.uasset b/Content/BP/BP_MyGameInstances.uasset index b674a52..99d70b7 100644 Binary files a/Content/BP/BP_MyGameInstances.uasset and b/Content/BP/BP_MyGameInstances.uasset differ diff --git a/Content/BP/WBP_MainMenu.uasset b/Content/BP/WBP_MainMenu.uasset new file mode 100644 index 0000000..d6e850e Binary files /dev/null and b/Content/BP/WBP_MainMenu.uasset differ diff --git a/Content/BP/WBP_MusicHUD.uasset b/Content/BP/WBP_MusicHUD.uasset index 2e24ef0..fc7405d 100644 Binary files a/Content/BP/WBP_MusicHUD.uasset and b/Content/BP/WBP_MusicHUD.uasset differ diff --git a/Content/BP/WBP_RaceHUD.uasset b/Content/BP/WBP_RaceHUD.uasset index ecf0489..b800634 100644 Binary files a/Content/BP/WBP_RaceHUD.uasset and b/Content/BP/WBP_RaceHUD.uasset differ diff --git a/Content/Img/UI/MarioKart8/src/BeachCheepCheepWallpaper.uasset b/Content/Img/UI/MarioKart8/src/BeachCheepCheepWallpaper.uasset new file mode 100644 index 0000000..3656b8c Binary files /dev/null and b/Content/Img/UI/MarioKart8/src/BeachCheepCheepWallpaper.uasset differ diff --git a/Content/Img/UI/MarioKartDS/8x/6859_a.uasset b/Content/Img/UI/MarioKartDS/8x/6859_a.uasset new file mode 100644 index 0000000..0cec76e Binary files /dev/null and b/Content/Img/UI/MarioKartDS/8x/6859_a.uasset differ diff --git a/Content/Img/UI/MarioKartDS/8x/LongButtonSideRight.uasset b/Content/Img/UI/MarioKartDS/8x/LongButtonSideRight.uasset new file mode 100644 index 0000000..dd9cf54 Binary files /dev/null and b/Content/Img/UI/MarioKartDS/8x/LongButtonSideRight.uasset differ diff --git a/Content/Img/UI/MarioKartDS/8x/LongButtonSideRightHover.uasset b/Content/Img/UI/MarioKartDS/8x/LongButtonSideRightHover.uasset new file mode 100644 index 0000000..d3ac516 Binary files /dev/null and b/Content/Img/UI/MarioKartDS/8x/LongButtonSideRightHover.uasset differ diff --git a/Content/Img/UI/MarioKartDS/src/6859.uasset b/Content/Img/UI/MarioKartDS/src/6859.uasset new file mode 100644 index 0000000..2a75fd3 Binary files /dev/null and b/Content/Img/UI/MarioKartDS/src/6859.uasset differ diff --git a/Content/Img/UI/MarioKartDS/src/6859_a.uasset b/Content/Img/UI/MarioKartDS/src/6859_a.uasset new file mode 100644 index 0000000..7cebe37 Binary files /dev/null and b/Content/Img/UI/MarioKartDS/src/6859_a.uasset differ diff --git a/Content/Levels/MainMenu.umap b/Content/Levels/MainMenu.umap new file mode 100644 index 0000000..6cbeba4 Binary files /dev/null and b/Content/Levels/MainMenu.umap differ diff --git a/Source/KO_Racing/MyMainMenuUserWidget.cpp b/Source/KO_Racing/MyMainMenuUserWidget.cpp new file mode 100644 index 0000000..bf048ae --- /dev/null +++ b/Source/KO_Racing/MyMainMenuUserWidget.cpp @@ -0,0 +1,5 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "MyMainMenuUserWidget.h" + diff --git a/Source/KO_Racing/MyMainMenuUserWidget.h b/Source/KO_Racing/MyMainMenuUserWidget.h new file mode 100644 index 0000000..8663d54 --- /dev/null +++ b/Source/KO_Racing/MyMainMenuUserWidget.h @@ -0,0 +1,17 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Blueprint/UserWidget.h" +#include "MyMainMenuUserWidget.generated.h" + +/** + * + */ +UCLASS() +class KO_RACING_API UMyMainMenuUserWidget : public UUserWidget +{ + GENERATED_BODY() + +}; diff --git a/Source/KO_Racing/MyRaceUserWidget.cpp b/Source/KO_Racing/MyRaceUserWidget.cpp index 57d2674..74ad8bf 100644 --- a/Source/KO_Racing/MyRaceUserWidget.cpp +++ b/Source/KO_Racing/MyRaceUserWidget.cpp @@ -3,6 +3,19 @@ #include "MyRaceUserWidget.h" +#include "Runtime/Engine/Classes/Kismet/GameplayStatics.h" + +void UMyRaceUserWidget::Init() +{ + _speedTxt->ChangeValue(0); + _rankTxt->ChangeValue(0); + _lapTxt->ChangeValue(1); + SetLapMax(3); + _beforeStartTimerTxt->ChangeValue(3); + _pauseTxt->SetVisibility(ESlateVisibility::Hidden); + UGameplayStatics::GetPlayerController(GetWorld(), 0)->InputComponent->BindAction("PauseAction", IE_Pressed, this, &UMyRaceUserWidget::TogglePause).bExecuteWhenPaused = true; +} + void UMyRaceUserWidget::ChangeRankValue(float value) { _rankTxt->ChangeValue(value); @@ -28,6 +41,7 @@ void UMyRaceUserWidget::ChangeSpeedValue(float value) void UMyRaceUserWidget::StartTimer() { _timer = 0; + _beforeStart = 3; _timerIsStarted = true; } @@ -51,8 +65,17 @@ void UMyRaceUserWidget::ResumeTimer() void UMyRaceUserWidget::UpdateTimer(float deltaTime) { if (_timerIsStarted) { - _timer += deltaTime; - _timerTxt->SetText(FText::FromString(GenTimerFString(_timer))); + if (_beforeStart <= 0) { + _timer += deltaTime; + _timerTxt->SetText(FText::FromString(GenTimerFString(_timer))); + } else { + _beforeStart -= deltaTime; + _beforeStartTimerTxt->ChangeValue(_beforeStart + 1); + if (_beforeStart <= 0) { + _raceAsStarted = true; + _beforeStartTimerTxt->SetVisibility(ESlateVisibility::Hidden); + } + } } } @@ -71,6 +94,14 @@ FString UMyRaceUserWidget::GenTimerFString(float time) return FString(GenTimerString(time).c_str()); } +void UMyRaceUserWidget::TogglePause() +{ + _isPaused = !_isPaused; + _pauseTxt->SetVisibility((_isPaused) ? ESlateVisibility::Visible : ESlateVisibility::Hidden); + (!_isPaused) ? ResumeTimer() : PauseTimer(); + UGameplayStatics::SetGamePaused(GetWorld(), _isPaused); +} + std::string UMyRaceUserWidget::GenTimerString(float time) { int minute = time / 60; diff --git a/Source/KO_Racing/MyRaceUserWidget.h b/Source/KO_Racing/MyRaceUserWidget.h index 58c97f5..20213f9 100644 --- a/Source/KO_Racing/MyRaceUserWidget.h +++ b/Source/KO_Racing/MyRaceUserWidget.h @@ -20,6 +20,8 @@ class KO_RACING_API UMyRaceUserWidget : public UUserWidget GENERATED_BODY() public: + UFUNCTION(BlueprintCallable) + void Init(); UFUNCTION(BlueprintCallable) void ChangeRankValue(float value); UFUNCTION(BlueprintCallable) @@ -44,6 +46,8 @@ class KO_RACING_API UMyRaceUserWidget : public UUserWidget TArray GetLapTime(); UFUNCTION(BlueprintCallable) static FString GenTimerFString(float time); + UFUNCTION(BlueprintCallable) + void TogglePause(); // All my variables UPROPERTY(Category = TextColorChanger, EditAnywhere, BlueprintReadWrite) @@ -54,11 +58,20 @@ class KO_RACING_API UMyRaceUserWidget : public UUserWidget UMyTextBlockColorChanger *_speedTxt; UPROPERTY(Category = Text, EditAnywhere, BlueprintReadWrite) UTextBlock *_timerTxt; + UPROPERTY(Category = TextColorChanger, EditAnywhere, BlueprintReadWrite) + UMyTextBlockColorChanger* _beforeStartTimerTxt; + UPROPERTY(Category = ForExternalUse, EditAnywhere, BlueprintReadWrite) + bool _raceAsStarted; + UPROPERTY(Category = ForExternalUse, EditAnywhere, BlueprintReadWrite) + bool _isPaused = false; + UPROPERTY(Category = Text, EditAnywhere, BlueprintReadWrite) + UTextBlock* _pauseTxt; protected: static std::string GenTimerString(float time); - float _timer; - bool _timerIsStarted; + float _timer = 0; + float _beforeStart = 3; + bool _timerIsStarted = false; TArray _lapTime; float _lastLapTimer = 0; }; diff --git a/Source/KO_Racing/MySlidingButton.cpp b/Source/KO_Racing/MySlidingButton.cpp new file mode 100644 index 0000000..06bdbd3 --- /dev/null +++ b/Source/KO_Racing/MySlidingButton.cpp @@ -0,0 +1,77 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "MySlidingButton.h" + +void UMySlidingButton::Init() +{ + _startingX = RenderTransform.Translation.X; + _slidedX = _startingX - _maxOffset; + _timer = 0; +} + +void UMySlidingButton::Tick(float deltaTime) +{ + Move(deltaTime); +} + +void UMySlidingButton::Move(float deltaTime) +{ + if (IsHovered()) { + if (!_wasHovered) { + _timer = 0; + _wasHovered = true; + } + _timer += deltaTime; + if (_timer < _timeToTransition) { + FVector2D btnTxtPos = _btnTxt->RenderTransform.Translation; + FVector2D btnPos = RenderTransform.Translation; + float resX = (btnPos.X - _slidedX) * (_timer / _timeToTransition); + btnTxtPos.X += resX; + btnPos.X -= resX; + _btnTxt->SetRenderTranslation(btnTxtPos); + SetRenderTranslation(btnPos); + } else { + FVector2D btnTxtPos = _btnTxt->RenderTransform.Translation; + FVector2D btnPos = RenderTransform.Translation; + float resX = btnPos.X - _slidedX; + btnTxtPos.X += resX; + btnPos.X -= resX; + _btnTxt->SetRenderTranslation(btnTxtPos); + SetRenderTranslation(btnPos); + } + } else { + if (_wasHovered) { + _timer = 0; + _wasHovered = false; + } + _timer += deltaTime; + if (_timer < _timeToTransition) { + FVector2D btnTxtPos = _btnTxt->RenderTransform.Translation; + FVector2D btnPos = RenderTransform.Translation; + float resX = (_startingX - btnPos.X) * (_timer / _timeToTransition); + btnTxtPos.X -= resX; + btnPos.X += resX; + _btnTxt->SetRenderTranslation(btnTxtPos); + SetRenderTranslation(btnPos); + } else { + FVector2D btnTxtPos = _btnTxt->RenderTransform.Translation; + FVector2D btnPos = RenderTransform.Translation; + float resX = _startingX - btnPos.X; + btnTxtPos.X -= resX; + btnPos.X += resX; + _btnTxt->SetRenderTranslation(btnTxtPos); + SetRenderTranslation(btnPos); + } + } +} + +void UMySlidingButton::LoadNextLevel() +{ + GetWorld()->ServerTravel(_nextLevelPath); +} + +void UMySlidingButton::QuitGame() +{ + FGenericPlatformMisc::RequestExit(false); +} diff --git a/Source/KO_Racing/MySlidingButton.h b/Source/KO_Racing/MySlidingButton.h new file mode 100644 index 0000000..3f1cf9c --- /dev/null +++ b/Source/KO_Racing/MySlidingButton.h @@ -0,0 +1,49 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Components/Button.h" + +#include "Engine/Texture.h" +#include "Components/TextBlock.h" +#include "Components/Image.h" + +#include "MySlidingButton.generated.h" + +/** + * + */ +UCLASS() +class KO_RACING_API UMySlidingButton : public UButton +{ + GENERATED_BODY() + +public: + UFUNCTION(BlueprintCallable) + void Init(); + UFUNCTION(BlueprintCallable) + void Tick(float deltaTime); + UFUNCTION(BlueprintCallable) + void Move(float deltaTime); + UFUNCTION(BlueprintCallable) + void LoadNextLevel(); + UFUNCTION(BlueprintCallable) + void QuitGame(); + + UPROPERTY(Category = Sliding, EditAnywhere, BlueprintReadWrite) + float _timeToTransition; + UPROPERTY(Category = Sliding, EditAnywhere, BlueprintReadWrite) + float _speed; + UPROPERTY(Category = Sliding, EditAnywhere, BlueprintReadWrite) + float _maxOffset; + UPROPERTY(Category = BtnTxt, EditAnywhere, BlueprintReadWrite) + UTextBlock* _btnTxt; + UPROPERTY(Category = OnClickOptional, EditAnywhere, BlueprintReadWrite) + FString _nextLevelPath; +protected: + float _startingX; + float _slidedX; + float _timer; + bool _wasHovered; +};