Optimizing gameinstance
This commit is contained in:
parent
3e85af79ae
commit
4e94aaaf96
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.
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.
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.
@ -6,6 +6,9 @@
|
|||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
#include "UI/GameUserWidget.h"
|
#include "UI/GameUserWidget.h"
|
||||||
#include "Kismet/KismetSystemLibrary.h"
|
#include "Kismet/KismetSystemLibrary.h"
|
||||||
|
#include "GameFramework/GameUserSettings.h"
|
||||||
|
#include "Kismet/KismetMathLibrary.h"
|
||||||
|
#include "FunctionLibraries/LuckyRobotsFunctionLibrary.h"
|
||||||
|
|
||||||
void ULuckyRobotsGameInstance::DoSendMessage(const FString& SendValue)
|
void ULuckyRobotsGameInstance::DoSendMessage(const FString& SendValue)
|
||||||
{
|
{
|
||||||
@ -133,6 +136,85 @@ void ULuckyRobotsGameInstance::DoSetTempTaskValueChange(bool bIsClear)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ULuckyRobotsGameInstance::DoResolutionChange(bool bIsFullscreen)
|
||||||
|
{
|
||||||
|
UGameUserSettings* GameUserSettings = UGameUserSettings::GetGameUserSettings();
|
||||||
|
if (!GameUserSettings)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FIntPoint LastResolution = FIntPoint(1280, 720);
|
||||||
|
if (bIsFullscreen)
|
||||||
|
{
|
||||||
|
TArray<FIntPoint> SupportedResolutions;
|
||||||
|
if (UKismetSystemLibrary::GetSupportedFullscreenResolutions(SupportedResolutions))
|
||||||
|
{
|
||||||
|
if (SupportedResolutions.Num() > 0)
|
||||||
|
{
|
||||||
|
LastResolution = SupportedResolutions.Last();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FString PlatformName = UGameplayStatics::GetPlatformName();
|
||||||
|
if(PlatformName == "Linux")
|
||||||
|
{
|
||||||
|
LastResolution = FIntPoint(720, 405);
|
||||||
|
}
|
||||||
|
else if (PlatformName == "Mac")
|
||||||
|
{
|
||||||
|
LastResolution = FIntPoint(720, 405);
|
||||||
|
}
|
||||||
|
else if(PlatformName == "Windows")
|
||||||
|
{
|
||||||
|
LastResolution = FIntPoint(1280, 720);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GameUserSettings->SetScreenResolution(LastResolution);
|
||||||
|
GameUserSettings->SetFullscreenMode(bIsFullscreen ? EWindowMode::Fullscreen : EWindowMode::Windowed);
|
||||||
|
GameUserSettings->ApplyResolutionSettings(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FString ULuckyRobotsGameInstance::DoRandomString(FString StartString)
|
||||||
|
{
|
||||||
|
FString TempString = "";
|
||||||
|
for (int32 Index = 0; Index < 7; Index++)
|
||||||
|
{
|
||||||
|
int32 RandomIndex = UKismetMathLibrary::RandomInteger(AlphabetForRandomList.Num());
|
||||||
|
if (AlphabetForRandomList.IsValidIndex(RandomIndex))
|
||||||
|
{
|
||||||
|
TempString.Append(AlphabetForRandomList[RandomIndex]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return StartString + "#" + TempString;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULuckyRobotsGameInstance::UpdateQualitySettings()
|
||||||
|
{
|
||||||
|
if (UGameUserSettings* GameUserSettings = GEngine->GetGameUserSettings())
|
||||||
|
{
|
||||||
|
GameUserSettings->SetOverallScalabilityLevel(static_cast<int32>(CurrentSelectQuality));
|
||||||
|
GameUserSettings->SaveSettings();
|
||||||
|
GameUserSettings->ApplySettings(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULuckyRobotsGameInstance::DoQualitySettings(int32 Quality, bool Auto)
|
||||||
|
{
|
||||||
|
if (Auto)
|
||||||
|
{
|
||||||
|
bIsFirstOpenGame = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UpdateQualitySettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ULuckyRobotsGameInstance::SetCurrentFolderName(const FString& FolderName)
|
void ULuckyRobotsGameInstance::SetCurrentFolderName(const FString& FolderName)
|
||||||
{
|
{
|
||||||
CurrentCaptureSettingsData.FolderName = FText::FromString(FolderName);
|
CurrentCaptureSettingsData.FolderName = FText::FromString(FolderName);
|
||||||
@ -292,3 +374,13 @@ int32 ULuckyRobotsGameInstance::GetCurrentCaptureNumber() const
|
|||||||
{
|
{
|
||||||
return FCString::Atoi(*CurrentCaptureSettingsData.NumberOfCaptures.ToString());
|
return FCString::Atoi(*CurrentCaptureSettingsData.NumberOfCaptures.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ULuckyRobotsGameInstance::SetWidgetTotalHit(int32 Value)
|
||||||
|
{
|
||||||
|
WidgetTotalHit = Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 ULuckyRobotsGameInstance::GetWidgetTotalHit() const
|
||||||
|
{
|
||||||
|
return WidgetTotalHit;
|
||||||
|
}
|
@ -64,12 +64,7 @@ void ULuckyRobotsFunctionLibrary::UpdateQualitySettings(const UObject* WorldCont
|
|||||||
{
|
{
|
||||||
if (ULuckyRobotsGameInstance* GameInstance = GetLuckyRobotsGameInstance(WorldContextObject))
|
if (ULuckyRobotsGameInstance* GameInstance = GetLuckyRobotsGameInstance(WorldContextObject))
|
||||||
{
|
{
|
||||||
if (UGameUserSettings* GameUserSettings = GEngine->GetGameUserSettings())
|
GameInstance->UpdateQualitySettings();
|
||||||
{
|
|
||||||
GameUserSettings->SetOverallScalabilityLevel(static_cast<int32>(GameInstance->CurrentSelectQuality));
|
|
||||||
GameUserSettings->SaveSettings();
|
|
||||||
GameUserSettings->ApplySettings(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,11 +40,37 @@ public:
|
|||||||
UDataTable* BathroomDataTable;
|
UDataTable* BathroomDataTable;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
|
||||||
|
TArray<FString> AlphabetForRandomList;
|
||||||
|
|
||||||
|
public:
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Resulation")
|
||||||
bool bIsFirstOpenGame;
|
bool bIsFirstOpenGame;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "WebSocket")
|
||||||
|
bool bIsStartConnect;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
|
ESaveDataType SelectSaveDataType;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
bool bIsDebug;
|
bool bIsDebug;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
bool bIsWidgetTestMode;
|
bool bIsWidgetTestMode;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
bool bIsShowPath;
|
bool bIsShowPath;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
|
int32 WidgetTotalHit;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
|
bool bInfiniteTime;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
|
float FastEndTaskTime = 180.0f;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Capture")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Capture")
|
||||||
bool bIsCapture;
|
bool bIsCapture;
|
||||||
@ -143,6 +169,17 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void DoSetTempTaskValueChange(bool bIsClear);
|
void DoSetTempTaskValueChange(bool bIsClear);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Resolution")
|
||||||
|
void DoResolutionChange(bool bIsFullscreen);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
FString DoRandomString(FString StartString);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void UpdateQualitySettings();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void DoQualitySettings(int32 Quality, bool Auto);
|
||||||
public:
|
public:
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void SetCurrentFolderName(const FString& FolderName);
|
void SetCurrentFolderName(const FString& FolderName);
|
||||||
@ -241,6 +278,13 @@ public:
|
|||||||
UFUNCTION(BlueprintPure)
|
UFUNCTION(BlueprintPure)
|
||||||
int32 GetCurrentCaptureNumber() const;
|
int32 GetCurrentCaptureNumber() const;
|
||||||
|
|
||||||
|
public:
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void SetWidgetTotalHit(int32 Value);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintPure)
|
||||||
|
int32 GetWidgetTotalHit() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UFUNCTION(BlueprintImplementableEvent)
|
UFUNCTION(BlueprintImplementableEvent)
|
||||||
void DoGetDispatch(const FString& EventName, USIOJsonValue* EventData);
|
void DoGetDispatch(const FString& EventName, USIOJsonValue* EventData);
|
||||||
|
@ -100,11 +100,11 @@ enum class EGoalType : uint8
|
|||||||
UENUM(BlueprintType)
|
UENUM(BlueprintType)
|
||||||
enum class ESaveDataType : uint8
|
enum class ESaveDataType : uint8
|
||||||
{
|
{
|
||||||
file UMETA(DisplayName = "file"),
|
None UMETA(DisplayName = "None"),
|
||||||
webserver UMETA(DisplayName = "webserver"),
|
File UMETA(DisplayName = "File"),
|
||||||
http UMETA(DisplayName = "http"),
|
Webserver UMETA(DisplayName = "Webserver"),
|
||||||
debug UMETA(DisplayName = "debug"),
|
Http UMETA(DisplayName = "Http"),
|
||||||
none UMETA(DisplayName = "none")
|
Debug UMETA(DisplayName = "Debug")
|
||||||
};
|
};
|
||||||
|
|
||||||
UENUM(BlueprintType)
|
UENUM(BlueprintType)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user