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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user