You've already forked LuckyWorld
Optimizing gameinstance
This commit is contained in:
@ -6,6 +6,9 @@
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "UI/GameUserWidget.h"
|
||||
#include "Kismet/KismetSystemLibrary.h"
|
||||
#include "GameFramework/GameUserSettings.h"
|
||||
#include "Kismet/KismetMathLibrary.h"
|
||||
#include "FunctionLibraries/LuckyRobotsFunctionLibrary.h"
|
||||
|
||||
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)
|
||||
{
|
||||
CurrentCaptureSettingsData.FolderName = FText::FromString(FolderName);
|
||||
@ -292,3 +374,13 @@ int32 ULuckyRobotsGameInstance::GetCurrentCaptureNumber() const
|
||||
{
|
||||
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 (UGameUserSettings* GameUserSettings = GEngine->GetGameUserSettings())
|
||||
{
|
||||
GameUserSettings->SetOverallScalabilityLevel(static_cast<int32>(GameInstance->CurrentSelectQuality));
|
||||
GameUserSettings->SaveSettings();
|
||||
GameUserSettings->ApplySettings(true);
|
||||
}
|
||||
GameInstance->UpdateQualitySettings();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,11 +40,37 @@ public:
|
||||
UDataTable* BathroomDataTable;
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
|
||||
TArray<FString> AlphabetForRandomList;
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Resulation")
|
||||
bool bIsFirstOpenGame;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "WebSocket")
|
||||
bool bIsStartConnect;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
ESaveDataType SelectSaveDataType;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
bool bIsDebug;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
bool bIsWidgetTestMode;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
bool bIsShowPath;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
int32 WidgetTotalHit;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
bool bInfiniteTime;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
float FastEndTaskTime = 180.0f;
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Capture")
|
||||
bool bIsCapture;
|
||||
@ -143,6 +169,17 @@ public:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
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:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetCurrentFolderName(const FString& FolderName);
|
||||
@ -241,6 +278,13 @@ public:
|
||||
UFUNCTION(BlueprintPure)
|
||||
int32 GetCurrentCaptureNumber() const;
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetWidgetTotalHit(int32 Value);
|
||||
|
||||
UFUNCTION(BlueprintPure)
|
||||
int32 GetWidgetTotalHit() const;
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void DoGetDispatch(const FString& EventName, USIOJsonValue* EventData);
|
||||
|
@ -100,11 +100,11 @@ enum class EGoalType : uint8
|
||||
UENUM(BlueprintType)
|
||||
enum class ESaveDataType : uint8
|
||||
{
|
||||
file UMETA(DisplayName = "file"),
|
||||
webserver UMETA(DisplayName = "webserver"),
|
||||
http UMETA(DisplayName = "http"),
|
||||
debug UMETA(DisplayName = "debug"),
|
||||
none UMETA(DisplayName = "none")
|
||||
None UMETA(DisplayName = "None"),
|
||||
File UMETA(DisplayName = "File"),
|
||||
Webserver UMETA(DisplayName = "Webserver"),
|
||||
Http UMETA(DisplayName = "Http"),
|
||||
Debug UMETA(DisplayName = "Debug")
|
||||
};
|
||||
|
||||
UENUM(BlueprintType)
|
||||
|
Reference in New Issue
Block a user