// Copyright Epic Games, Inc. All Rights Reserved.
#include "DesktopPlatformBase.h"
#include "HAL/FileManager.h"
#include "Misc/FileHelper.h"
#include "Misc/Paths.h"
#include "Misc/Guid.h"
#include "Misc/ConfigCacheIni.h"
#include "Misc/FeedbackContext.h"
#include "Misc/App.h"
#include "Misc/EngineVersion.h"
#include "Serialization/JsonTypes.h"
#include "Serialization/JsonReader.h"
#include "Serialization/JsonSerializer.h"
#include "Modules/ModuleManager.h"
#include "DesktopPlatformPrivate.h"
#include "Misc/OutputDeviceRedirector.h"
#define LOCTEXT_NAMESPACE "DesktopPlatform"
FDesktopPlatformBase::FDesktopPlatformBase()
{
LauncherInstallationTimestamp = FDateTime::MinValue();
}
FString FDesktopPlatformBase::GetEngineDescription(const FString& Identifier)
{
// Official release versions just have a version number
if(IsStockEngineRelease(Identifier))
{
return Identifier;
}
// Otherwise get the path
FString RootDir;
if(!GetEngineRootDirFromIdentifier(Identifier, RootDir))
{
return FString();
}
// Convert it to a platform directory
FString PlatformRootDir = RootDir;
FPaths::MakePlatformFilename(PlatformRootDir);
// Perforce build
if (IsSourceDistribution(RootDir))
{
return FString::Printf(TEXT("Source build at %s"), *PlatformRootDir);
}
else
{
return FString::Printf(TEXT("Binary build at %s"), *PlatformRootDir);
}
}
FString FDesktopPlatformBase::GetCurrentEngineIdentifier()
{
if(CurrentEngineIdentifier.Len() == 0 && !GetEngineIdentifierFromRootDir(FPlatformMisc::RootDir(), CurrentEngineIdentifier))
{
CurrentEngineIdentifier.Empty();
}
return CurrentEngineIdentifier;
}
void FDesktopPlatformBase::EnumerateLauncherEngineInstallations(TMap<FString, FString> &OutInstallations)
{
// Cache the launcher install list if necessary
ReadLauncherInstallationList();
// We've got a list of launcher installations. Filter it by the engine installations.
for(TMap<FString, FString>::TConstIterator Iter(LauncherInstallationList); Iter; ++Iter)
{
FString AppName = Iter.Key();
if(AppName.RemoveFromStart(TEXT("UE_"), ESearchCase::CaseSensitive))
{
OutInstallations.Add(AppName, Iter.Value());
}
}
}
void FDesktopPlatformBase::EnumerateLauncherSampleInstallations(TArray<FString> &OutInstallations)
{
// Cache the launcher install list if necessary
ReadLauncherInstallationList();
// We've got a list of launcher installations. Filter it by the engine installations.
for(TMap<FString, FString>::TConstIterator Iter(LauncherInstallationList); Iter; ++Iter)
{
FString AppName = Iter.Key();
if(!AppName.StartsWith(TEXT("UE_"), ESearchCase::CaseSensitive))
{
OutInstallations.Add(Iter.Value());
}
}
}
void FDesktopPlatformBase::EnumerateLauncherSampleProjects(TArray<FString> &OutFileNames)
{
// Enumerate all the sample installation directories
TArray<FString> LauncherSampleDirectories;
EnumerateLauncherSampleInstallations(LauncherSampleDirectories);
// Find all the project files within them
for(int32 Idx = 0; Idx < LauncherSampleDirectories.Num(); Idx++)
{
TArray<FString> FileNames;
IFileManager::Get().FindFiles(FileNames, *(LauncherSampleDirectories[Idx] / TEXT("*.uproject")), true, false);
OutFileNames.Append(FileNames);
}
}
bool FDesktopPlatformBase::GetEngineRootDirFromIdentifier(const FString &Identifier, FString &OutRootDir)
{
// Get all the installations
TMap<FString, FString> Installations;
EnumerateEngineInstallations(Installations);
// Find the one with the right identifier
for (TMap<FString, FString>::TConstIterator Iter(Installations); Iter; ++Iter)
{
if (Iter->Key == Identifier)
{
OutRootDir = Iter->Value;
return true;
}
}
return false;
}
bool FDesktopPlatformBase::GetEngineIdentifierFromRootDir(const FString &RootDir, FString &OutIdentifier)
{
// Get all the installations
TMap<FString, FString> Installations;
EnumerateEngineInstallations(Installations);
// Normalize the root directory
FString NormalizedRootDir = RootDir;
FPaths::CollapseRelativeDirectories(NormalizedRootDir);
FPaths::NormalizeDirectoryName(NormalizedRootDir);
// Find the label for the given directory
for (TMap<FString, FString>::TConstIterator Iter(Installations); Iter; ++Iter)
{
if (Iter->Value == NormalizedRootDir)
{
OutIdentifier = Iter->Key;
return true;
}
}
// Otherwise just try to add it
return RegisterEngineInstallation(RootDir, OutIdentifier);
}
bool FDesktopPlatformBase::GetDefaultEngineIdentifier(FString &OutId)
{
TMap<FString, FString> Installations;
EnumerateEngineInstallations(Installations);
bool bRes = false;
if (Installations.Num() > 0)
{
// Default to the first install
TMap<FString, FString>::TConstIterator Iter(Installations);
OutId = Iter.Key();
++Iter;
// Try to find the most preferred install
for(; Iter; ++Iter)
{
if(IsPreferredEngineIdentifier(Iter.Key(), OutId))
{
OutId = Iter.Key();
}
}
}
return bRes;
}
bool FDesktopPlatformBase::GetDefaultEngineRootDir(FString &OutDirName)
{
FString Identifier;
return GetDefaultEngineIdentifier(Identifier) && GetEngineRootDirFromIdentifier(Identifier, OutDirName);
}
bool FDesktopPlatformBase::IsPreferredEngineIdentifier(const FString &Identifier, const FString &OtherIdentifier)
{
int32 Version = ParseReleaseVersion(Identifier);
int32 OtherVersion = ParseReleaseVersion(OtherIdentifier);
if(Version != OtherVersion)
{
return Version > OtherVersion;
}
else
{
return Identifier > OtherIdentifier;
}
}
bool FDesktopPlatformBase::TryGetEngineVersion(const FString& RootDir, FEngineVersion& OutVersion)
{
// Read the file to a string
FString VersionText;
if(FFileHelper::LoadFileToString(VersionText, *(RootDir / TEXT("Engine/Build/Build.version"))))
{
// Deserialize a JSON object from the string
TSharedPtr< FJsonObject > Object;
TSharedRef< TJsonReader<> > Reader = TJsonReaderFactory<>::Create(VersionText);
if(FJsonSerializer::Deserialize(Reader, Object) && Object.IsValid())
{
int32 MajorVersion = 0;
int32 MinorVersion = 0;
int32 PatchVersion = 0;
if(Object->TryGetNumberField(TEXT("MajorVersion"), MajorVersion) && Object->TryGetNumberField(TEXT("MinorVersion"), MinorVersion) && Object->TryGetNumberField(TEXT("PatchVersion"), PatchVersion))
{
int32 Changelist = 0;
if(!Object->TryGetNumberField(TEXT("Changelist"), Changelist))
{
Changelist = 0;
}
int32 IsLicenseeVersion = 0;
if(!Object->TryGetNumberField(TEXT("IsLicenseeVersion"), IsLicenseeVersion))
{
IsLicenseeVersion = 0;
}
FString BranchName;
if(!Object->TryGetStringField(TEXT("BranchName"), BranchName))
{
BranchName = FString();
}
int EncodedChangelist = (IsLicenseeVersion == 0)? Changelist : FEngineVersionBase::EncodeLicenseeChangelist(Changelist);
OutVersion = FEngineVersion(MajorVersion, MinorVersion, PatchVersion, EncodedChangelist, BranchName);
return true;
}
}
}
// Try to read the version file
FString VersionHeader;
if(FFileHelper::LoadFileToString(VersionHeader, *(RootDir / TEXT("Engine/Source/Runtime/Launch/Resources/Version.h"))))
{
int32 MajorVersion = -1;
int32 MinorVersion = -1;
int32 PatchVersion = -1;
int32 Changelist = 0;
int32 IsLicenseeVersion = 0;
FString BranchName;
// Scan the file for version defines
const TCHAR* TextPos = *VersionHeader;
while(*TextPos)
{
// Skip over any newlines
while(FChar::IsWhitespace(*TextPos))
{
TextPos++;
}
// Buffer up a line of tokens
TArray<FString> Tokens;
while(*TextPos != '\n' && *TextPos != 0)
{
if(*TextPos == ' ' || *TextPos == '\t' || *TextPos == '\r')
{
// Skip over whitespace
TextPos++;
}
else if(FC
没有合适的资源?快使用搜索试试~ 我知道了~
UE4文件选择窗口的插件
共65个文件
h:32个
cpp:27个
cs:4个
需积分: 34 32 下载量 182 浏览量
2021-07-16
11:24:58
上传
评论 1
收藏 136KB RAR 举报
温馨提示
UE4插件,使用OpenFileDialog打开文件选择窗口,解决了shipping打包后调用崩溃的问题。
资源详情
资源评论
资源推荐
收起资源包目录
WinSelectedDialog.rar (65个子文件)
WinSelectedDialog
WinSelectedDialog.uplugin 1KB
Resources
Icon128.png 12KB
Source
MySlateFileDialogs
Public
SlateFileDialogs.h 1KB
SlateFileDialogsStyles.h 786B
ISlateFileDialogModule.h 1KB
MySlateFileDialogs.Build.cs 719B
Private
SlateFileDialogsStyles.cpp 5KB
SlateFileDialogsModule.cpp 2KB
SlateFileDlgWindow.h 11KB
SlateFileDlgWindow.cpp 44KB
SlateFileDialogsPrivate.h 227B
WinSelectedDialog
FileDialogBPFunctionLibs.h 438B
FileDialogBPFunctionLibs.cpp 1KB
Public
WinSelectedDialog.h 336B
Private
WinSelectedDialog.cpp 653B
WinSelectedDialog.Build.cs 1KB
MyDesktopPlatform
MyDesktopPlatform.Build.cs 745B
Public
TargetReceipt.h 3KB
IDesktopPlatform.h 18KB
DesktopPlatformModule.h 696B
PlatformInfo.h 9KB
Private
Mac
DesktopPlatformMac.h 2KB
MacNativeFeedbackContext.h 2KB
MacNativeFeedbackContext.cpp 15KB
DesktopPlatformMac.cpp 19KB
DesktopPlatformBase.h 5KB
Windows
DesktopPlatformWindows.cpp 23KB
DesktopPlatformWindows.h 3KB
WindowsNativeFeedbackContext.h 2KB
WindowsRegistry.h 2KB
WindowsRegistry.cpp 9KB
WindowsNativeFeedbackContext.cpp 13KB
PlatformInfo.cpp 17KB
Linux
DesktopPlatformLinux.h 2KB
DesktopPlatformLinux.cpp 16KB
DesktopPlatformPrivate.h 396B
DesktopPlatformBase.cpp 48KB
TargetReceipt.cpp 7KB
DesktopPlatformModule.cpp 481B
DesktopPlatformStub.h 2KB
MyDirectoryWatcher
Public
IDirectoryWatcher.h 2KB
DirectoryWatcherModule.h 813B
FileCacheUtilities.h 5KB
FileCache.h 19KB
Private
Mac
DirectoryWatchRequestMac.cpp 7KB
DirectoryWatcherMac.h 1KB
DirectoryWatcherMac.cpp 3KB
DirectoryWatchRequestMac.h 2KB
DirectoryWatcherTests.cpp 13KB
DirectoryWatcherProxy.cpp 5KB
DirectoryWatcherModule.cpp 832B
FileCacheUtilities.cpp 3KB
Windows
DirectoryWatchRequestWindows.h 2KB
DirectoryWatcherWindows.h 1KB
DirectoryWatcherWindows.cpp 5KB
DirectoryWatchRequestWindows.cpp 9KB
Linux
DirectoryWatchRequestLinux.cpp 10KB
DirectoryWatcherLinux.h 989B
DirectoryWatchRequestLinux.h 3KB
DirectoryWatcherLinux.cpp 3KB
FileCache.cpp 31KB
DirectoryWatcherPrivate.h 534B
Tests
DirectoryWatchterRunTests.cpp 2KB
DirectoryWatcherProxy.h 2KB
MyDirectoryWatcher.Build.cs 317B
Content
共 65 条
- 1
DvLee1024
- 粉丝: 4015
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0