Optimizing WB_GameWidget
This commit is contained in:
parent
55fabb31e8
commit
d188cb846e
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.
@ -344,6 +344,41 @@ void ULuckyRobotsGameInstance::GetMessageParse(FString Json)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FParsedData ULuckyRobotsGameInstance::DoJsonParse(const FString& JsonString)
|
||||||
|
{
|
||||||
|
FParsedData ParsedData;
|
||||||
|
|
||||||
|
auto VaRestSubsystem = CastChecked<UVaRestSubsystem>(USubsystemBlueprintLibrary::GetEngineSubsystem(UVaRestSubsystem::StaticClass()), ECastCheckedType::NullChecked);
|
||||||
|
|
||||||
|
if (!VaRestSubsystem)
|
||||||
|
{
|
||||||
|
return ParsedData;
|
||||||
|
}
|
||||||
|
|
||||||
|
UVaRestJsonObject* VaRestJsonObject = VaRestSubsystem->ConstructVaRestJsonObject();
|
||||||
|
if (!VaRestJsonObject)
|
||||||
|
{
|
||||||
|
return ParsedData;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (VaRestJsonObject->DecodeJson(JsonString, true))
|
||||||
|
{
|
||||||
|
UVaRestJsonObject* TempJsonObject = VaRestJsonObject->GetObjectField("startup_instructions");
|
||||||
|
if (TempJsonObject)
|
||||||
|
{
|
||||||
|
ParsedData.LevelName = TempJsonObject->GetStringField("level");
|
||||||
|
ParsedData.CharacterName = TempJsonObject->GetStringField("character");
|
||||||
|
ParsedData.Quality = TempJsonObject->GetStringField("quality");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Error, TEXT("Parse Problem"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ParsedData;
|
||||||
|
}
|
||||||
|
|
||||||
void ULuckyRobotsGameInstance::SetCurrentFolderName(const FString& FolderName)
|
void ULuckyRobotsGameInstance::SetCurrentFolderName(const FString& FolderName)
|
||||||
{
|
{
|
||||||
CurrentCaptureSettingsData.FolderName = FText::FromString(FolderName);
|
CurrentCaptureSettingsData.FolderName = FText::FromString(FolderName);
|
||||||
|
@ -177,47 +177,12 @@ void UMainScreenUserWidget::UpdateSelectQuality()
|
|||||||
BPUpdateSelectQuality();
|
BPUpdateSelectQuality();
|
||||||
}
|
}
|
||||||
|
|
||||||
FParsedData UMainScreenUserWidget::DoJsonParse(const FString& JsonString)
|
|
||||||
{
|
|
||||||
FParsedData ParsedData;
|
|
||||||
|
|
||||||
auto VaRestSubsystem = CastChecked<UVaRestSubsystem>(USubsystemBlueprintLibrary::GetEngineSubsystem(UVaRestSubsystem::StaticClass()), ECastCheckedType::NullChecked);
|
|
||||||
|
|
||||||
if (!VaRestSubsystem)
|
|
||||||
{
|
|
||||||
return ParsedData;
|
|
||||||
}
|
|
||||||
|
|
||||||
UVaRestJsonObject* VaRestJsonObject = VaRestSubsystem->ConstructVaRestJsonObject();
|
|
||||||
if (!VaRestJsonObject)
|
|
||||||
{
|
|
||||||
return ParsedData;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (VaRestJsonObject->DecodeJson(JsonString, true))
|
|
||||||
{
|
|
||||||
UVaRestJsonObject* TempJsonObject = VaRestJsonObject->GetObjectField("startup_instructions");
|
|
||||||
if (TempJsonObject)
|
|
||||||
{
|
|
||||||
ParsedData.LevelName = TempJsonObject->GetStringField("level");
|
|
||||||
ParsedData.CharacterName = TempJsonObject->GetStringField("character");
|
|
||||||
ParsedData.Quality = TempJsonObject->GetStringField("quality");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UE_LOG(LogTemp, Error, TEXT("Parse Problem"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return ParsedData;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UMainScreenUserWidget::OnMessageDispatchedHandler(const FString& Message)
|
void UMainScreenUserWidget::OnMessageDispatchedHandler(const FString& Message)
|
||||||
{
|
{
|
||||||
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||||
if (GameInstance)
|
if (GameInstance)
|
||||||
{
|
{
|
||||||
FParsedData ParsedData = DoJsonParse(Message);
|
FParsedData ParsedData = GameInstance->DoJsonParse(Message);
|
||||||
if (ParsedData.CharacterName == "DRONE")
|
if (ParsedData.CharacterName == "DRONE")
|
||||||
{
|
{
|
||||||
GameInstance->CurrentSelectRobot = ERobotsName::LuckyDrone;
|
GameInstance->CurrentSelectRobot = ERobotsName::LuckyDrone;
|
||||||
|
@ -14,3 +14,38 @@ void UGameUserWidget::NativeConstruct()
|
|||||||
GameInstance->GameUserWidget = this;
|
GameInstance->GameUserWidget = this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UGameUserWidget::DoWaitSecond()
|
||||||
|
{
|
||||||
|
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||||
|
if (GameInstance)
|
||||||
|
{
|
||||||
|
if (GameInstance->bIsFirstOpenGame)
|
||||||
|
{
|
||||||
|
DownCount = 3;
|
||||||
|
GetWorld()->GetTimerManager().ClearTimer(UpdateDownCountTimerHandle);
|
||||||
|
GetWorld()->GetTimerManager().SetTimer(UpdateDownCountTimerHandle, this, &UGameUserWidget::UpdateDownCount, 1.0f, true);
|
||||||
|
|
||||||
|
UpdateDownCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UGameUserWidget::UpdateDownCount()
|
||||||
|
{
|
||||||
|
if (DownCount > 0)
|
||||||
|
{
|
||||||
|
DownCountStr = FString::FromInt(DownCount);
|
||||||
|
DownCount--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DownCountStr = "";
|
||||||
|
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||||
|
if (GameInstance)
|
||||||
|
{
|
||||||
|
GameInstance->DoQualitySettings(0, true);
|
||||||
|
}
|
||||||
|
GetWorld()->GetTimerManager().ClearTimer(UpdateDownCountTimerHandle);
|
||||||
|
}
|
||||||
|
}
|
@ -203,6 +203,9 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void GetMessageParse(FString Json);
|
void GetMessageParse(FString Json);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
FParsedData DoJsonParse(const FString& JsonString);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void SetCurrentFolderName(const FString& FolderName);
|
void SetCurrentFolderName(const FString& FolderName);
|
||||||
|
@ -79,7 +79,6 @@ public:
|
|||||||
void UpdateSelectQuality();
|
void UpdateSelectQuality();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FParsedData DoJsonParse(const FString& JsonString);
|
|
||||||
void OnMessageDispatchedHandler(const FString& Message);
|
void OnMessageDispatchedHandler(const FString& Message);
|
||||||
void DoSendReadyJson();
|
void DoSendReadyJson();
|
||||||
|
|
||||||
|
@ -19,9 +19,32 @@ protected:
|
|||||||
virtual void NativeConstruct() override;
|
virtual void NativeConstruct() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UFUNCTION(BlueprintImplementableEvent)
|
FTimerHandle UpdateDownCountTimerHandle;
|
||||||
|
|
||||||
|
public:
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
|
bool bIsCrash;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
|
bool bIsGoalMenuVis;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
|
bool bIsTracing;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
|
int32 DownCount = 0;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
|
FString DownCountStr;
|
||||||
|
public:
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void DoWaitSecond();
|
||||||
|
|
||||||
|
void UpdateDownCount();
|
||||||
|
public:
|
||||||
|
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
|
||||||
void DoLogItemAdd(const FString& Topic, const FString& MsgText, ELogItemType LogItemType);
|
void DoLogItemAdd(const FString& Topic, const FString& MsgText, ELogItemType LogItemType);
|
||||||
|
|
||||||
UFUNCTION(BlueprintImplementableEvent)
|
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
|
||||||
void DoRefreshListView();
|
void DoRefreshListView();
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user