Thank you, i guess i do something similar already.
I sort the highscores and after this i check if the player score is higher then âALevel_ST[iLevelNr_IN].AHighscores_Score_ST.Last().iScoreâ. If so, i set the new score into and sort again (all clamped to be 10 entries) and finaly i save it.
Little Code Snipet
### Edit ###
I changed for testing the setup to use PDA´s/DA´s. Works pretty well for now. It is now based on selection. The base setup runs pure within cpp. LevelSet->GameMode->EachLevel->PDA::DA. This way i need for each Level 1DA that is stored and selected within 1PDA.
Looks like easy to do more or less. Still not understand fully on how only use DA´s without the Blueprint interaction and PDA´s. This is why i use it this way for now, and this works fine.
Was also thinking how to store the data, because it will load only once. Maybe an simple actor who stores only the structs for this? Still testing, but quite happy at the moment how it works.
Also want to change the whol function to run cpp pure. Was just running into problems with TSubclassOf<> to add the widgets the should be created. This is why it is mixed with Blueprint.
Here is the code if someone is interested in how it is done so far (still WIP and a little to much though)
Code to select data from a PDA based on Vars and previous selections with a function that can be called within Blueprints
void UCommonActivatableWidget_Base::FLevel_Challenges_ForScrollBox_PDA_IN(TArray<UGameMode_PrimaryDataAsset*> PDA_AsArray_IN, UGameMode_PrimaryDataAsset* PDA_IN, int iDif_IN,
FMenuST Images_ST_IN, TArray& AChallenges_OUT,
UTexture2D*& imgChallengeFinisehd_OUT, UTexture2D*& imgChallengeNotFinisehd_OUT, int& iDif_OUT,
FName& NameOfTheChallenge_OUT, float& fValueAlreadyFinished_OUT, float& fValueNeedToFinish_OUT)
{
// Get Selected GameMode Categorie( ?? Standard:: 1 = Story ?? )
int iGameModeSelected = DTS_GameInstance_Ref->GameProfile_ST.GameSettings_ST.iGameMode_Categorie_Selected;
// Get Selected Dif Level (Standard:: 0 = Normal)
int iDifSelected = DTS_GameInstance_Ref->GameProfile_ST.GameSettings_ST.iGameMode_Dif_Selected;
iDif_OUT = iDifSelected;
// Set the Number of the Level to Play (Get from GameInstance where Data is stored after loading Player/Game Profile)
int iLevelToPlayNr = DTS_GameInstance_Ref->GameProfile_ST.GameSettings_ST.iLevelToPlay_Nr;
// Zum feststellen wie lange der eigentliche Array ist der durchlaufen werden muss um aktive Challenges zu finden
// (bChallengeActive = true)
int iTMP_ArrayLenght_Challenges;
UE_LOG(LogTemp, Warning, TEXT("---> Selected Level to play Nr:: %d"), iLevelToPlayNr); // Debug
UE_LOG(LogTemp, Warning, TEXT("---> PDA Array.Num(%d)"), PDA_AsArray_IN.Num()); // Debug
// Check if Array lenght of selected iLevelToPlay is bigger then the Array lenght of the PDA_AsArray_IN[]
// Then check if the Data within PDA_AsArray_IN[] is valid (is the Array filled with an associated DA ?)
if (PDA_AsArray_IN.Num() > iLevelToPlayNr && PDA_AsArray_IN[iLevelToPlayNr] != nullptr)
{
//PDA_AsArray_IN[iLevelToPlayNr];
AChallenges_OUT = PDA_AsArray_IN[iLevelToPlayNr]->Challenges_ST.AChallenges_ST;
// GameMode wurde bereits "Selected" und in DTS_GameInstance festgelegt -> jetzt die Länge des Arrays mit allen Challenges "getten"
iTMP_ArrayLenght_Challenges = PDA_AsArray_IN[iLevelToPlayNr]->Challenges_ST.AChallenges_ST.Num();
// Alle gefunden Challenges zur verarbeitung im BP ausgeben mit "AChallenges_OUT"
AChallenges_OUT = PDA_AsArray_IN[iLevelToPlayNr]->Challenges_ST.AChallenges_ST;
// Get all available Challenges of the current Level and fill Array with Data
for (int i = 0; iTMP_ArrayLenght_Challenges > i; i++)
{
bool bChallengeActive = PDA_AsArray_IN[iLevelToPlayNr]->Challenges_ST.AChallenges_ST[i].bChallengeActive;
bool bChallengeFinished = PDA_AsArray_IN[iLevelToPlayNr]->Challenges_ST.AChallenges_ST[i].bChallengeFinished;
//UE_LOG(LogTemp, Display, TEXT("i before IF - %d"), i); // Debug
if (bChallengeActive == true)
{
NameOfTheChallenge_OUT = PDA_AsArray_IN[iLevelToPlayNr]->Challenges_ST.AChallenges_ST[i].nNameOfTheChallenge;
// Set Values for AlreadyFinished and NeedToFinish for selected Dif
PDA_AsArray_IN[iLevelToPlayNr]->Challenges_ST.AChallenges_ST[i].fChallenge_ValueAlreadyFinished_InUse =
PDA_AsArray_IN[iLevelToPlayNr]->Challenges_ST.AChallenges_ST[i].AfChallenge_ValueAlreadyFinished_Dif[iDifSelected];
PDA_AsArray_IN[iLevelToPlayNr]->Challenges_ST.AChallenges_ST[i].fChallenge_ValueNeedToFinish_InUse =
PDA_AsArray_IN[iLevelToPlayNr]->Challenges_ST.AChallenges_ST[i].AfChallenge_ValueNeedToFinish_Dif[iDifSelected];
// Set Values Bool if Challenge is finished for selected Dif
PDA_AsArray_IN[iLevelToPlayNr]->Challenges_ST.AChallenges_ST[i].bChallengeFinished =
PDA_AsArray_IN[iLevelToPlayNr]->Challenges_ST.AChallenges_ST[i].AbChallengeFinished_Dif[iDifSelected];
UE_LOG(LogTemp, Warning, TEXT("fChallenge_ValueAlreadyFinished_InUse -> Finished:: = %d"),
PDA_AsArray_IN[iLevelToPlayNr]->Challenges_ST.AChallenges_ST[i].fChallenge_ValueAlreadyFinished_InUse); // Debug
UE_LOG(LogTemp, Warning, TEXT("fChallenge_ValueNeedToFinish_InUse:: --> still to finish:: = %d"),
PDA_AsArray_IN[iLevelToPlayNr]->Challenges_ST.AChallenges_ST[i].fChallenge_ValueNeedToFinish_InUse); // Debug
// Set Test Value for debug only (check if new Value is written into DA)
PDA_AsArray_IN[iLevelToPlayNr]->Challenges_ST.AChallenges_ST[i].fChallenge_ValueNeedToFinish_InUse = 5000.0f; // Debug
// Set the all Values for the BP output to create Widgets inside the BP (ToDo:: change to cpp only)
AChallenges_OUT = PDA_AsArray_IN[iLevelToPlayNr]->Challenges_ST.AChallenges_ST;
UE_LOG(LogTemp, Error, TEXT(" Challenge Nr -> Array.Num( %d ) of the active Challenge"), i);
}
else
{
UE_LOG(LogTemp, Error, TEXT("ELSE :: Challenge --> Array.Num( %d ) NOT active "), i); // Debug
}
} // For Loop END
} // END ### if (PDA_AsArray_IN.Num() >= iLevelToPlayNr)
else
{
UE_LOG(LogTemp, Error, TEXT("NO Level(PDA[]) available for selected Level:: ( %d ) check if DA for selected Level is insert imto associated PDA Array Position ( %d )"), iLevelToPlayNr, iLevelToPlayNr); // Debug
}
UE_LOG(LogTemp, Warning, TEXT("AChallenges_OUT.SetNum() - %d"), iTMP_ArrayLenght_Challenges); // Debug
// Get Images from "BP Struct(Setup in Parrent)" as Input to Display if Challenge is Finished or not (BG Image)
imgChallengeFinisehd_OUT = Images_ST_IN.AImages_Challenges[0].imgChallenges_Finished;
imgChallengeNotFinisehd_OUT = Images_ST_IN.AImages_Challenges[0].imgChallenges_NotFinished;
}
Ok i noticed it is a little hard to read this way, but i guess you get at least the idea