Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool AMyPawn::LoadMap(const FString& filename, const FString& levelname, const FString& mountPoint, const FString& mountPath)
- {
- FString StandardFilename(filename);
- FPaths::MakeStandardFilename(StandardFilename);
- StandardFilename = FPaths::GetPath(StandardFilename);
- IPlatformFile& InnerPlatform = FPlatformFileManager::Get().GetPlatformFile();
- FPakPlatformFile* PakPlatform = new FPakPlatformFile();
- PakPlatform->Initialize(&InnerPlatform, TEXT(""));
- FPlatformFileManager::Get().SetPlatformFile(*PakPlatform);
- bool ret = false;
- FPakFile pakFile(PakPlatform, *filename, false);
- if (pakFile.IsValid()) {
- pakFile.SetMountPoint(*mountPoint);
- const int32 PakOrder = 0;
- if (PakPlatform->Mount(*filename, PakOrder, *mountPoint)) {
- UE_LOG(LogTemp, Warning, TEXT(" loaded and mounted, listing..."));//@@
- struct Dump : public IPlatformFile::FDirectoryVisitor {
- virtual bool Visit(const TCHAR* FilenameOrDirectory, bool bIsDirectory) {
- if (bIsDirectory) {
- UE_LOG(LogTemp, Warning, TEXT("Directory: %s"), FilenameOrDirectory);
- }
- else {
- UE_LOG(LogTemp, Warning, TEXT("File: %s"), FilenameOrDirectory);
- }
- return true;
- }
- };
- Dump visitor;
- if (mountPoint.Len() > 0) {
- PakPlatform->IterateDirectoryRecursively(*mountPoint, visitor);
- }
- else {
- PakPlatform->IterateDirectoryRecursively(TEXT("/Game/"), visitor);
- }
- ret = true;
- }
- else {
- UE_LOG(LogTemp, Warning, TEXT(" failed to mount pak file"));
- }
- }
- else {
- UE_LOG(LogTemp, Warning, TEXT(" failed to load pak file"));
- }
- FString ln;
- if (mountPoint.Len() > 0 && mountPath.Len() > 0) {
- FPackageName::RegisterMountPoint(mountPoint, mountPath);
- ln = levelname;
- }
- else {
- ln = levelname;
- }
- FName level(*ln);
- UGameplayStatics::OpenLevel(GetWorld(), level);
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement