本文整理汇总了C++中FString类的典型用法代码示例。如果您正苦于以下问题:C++ FString类的具体用法?C++ FString怎么用?C++ FString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetObjectPropertyClass
void SPropertyEditorAsset::Construct( const FArguments& InArgs, const TSharedPtr<FPropertyEditor>& InPropertyEditor )
{
PropertyEditor = InPropertyEditor;
PropertyHandle = InArgs._PropertyHandle;
OnSetObject = InArgs._OnSetObject;
OnShouldFilterAsset = InArgs._OnShouldFilterAsset;
UProperty* Property = nullptr;
if(PropertyEditor.IsValid())
{
Property = PropertyEditor->GetPropertyNode()->GetProperty();
bAllowClear = !(Property->PropertyFlags & CPF_NoClear);
ObjectClass = GetObjectPropertyClass(Property);
bIsActor = ObjectClass->IsChildOf( AActor::StaticClass() );
}
else
{
bAllowClear = InArgs._AllowClear;
ObjectPath = InArgs._ObjectPath;
ObjectClass = InArgs._Class;
bIsActor = ObjectClass->IsChildOf( AActor::StaticClass() );
if (PropertyHandle.IsValid() && PropertyHandle->IsValidHandle())
{
Property = PropertyHandle->GetProperty();
}
else
{
CustomClassFilters.Add(ObjectClass);
}
}
// Account for the allowed classes specified in the property metadata
if (Property)
{
FString ClassFilterString;
if (UArrayProperty* ArrayParent = Cast<UArrayProperty>(Property->GetOuter()))
{
ClassFilterString = ArrayParent->GetMetaData("AllowedClasses");
}
else
{
ClassFilterString = Property->GetMetaData("AllowedClasses");
}
if (ClassFilterString.IsEmpty())
{
CustomClassFilters.Add(ObjectClass);
}
else
{
TArray<FString> CustomClassFilterNames;
ClassFilterString.ParseIntoArray(CustomClassFilterNames, TEXT(","), true);
for (auto It = CustomClassFilterNames.CreateIterator(); It; ++It)
{
FString& ClassName = *It;
// User can potentially list class names with leading or trailing whitespace
ClassName.Trim();
ClassName.TrimTrailing();
UClass* Class = FindObject<UClass>(ANY_PACKAGE, *ClassName);
if (!Class)
{
Class = LoadObject<UClass>(nullptr, *ClassName);
}
if (Class)
{
// If the class is an interface, expand it to be all classes in memory that implement the class.
if (Class->HasAnyClassFlags(CLASS_Interface))
{
for (TObjectIterator<UClass> ClassIt; ClassIt; ++ClassIt)
{
UClass* const ClassWithInterface = (*ClassIt);
if (ClassWithInterface->ImplementsInterface(Class))
{
CustomClassFilters.Add(ClassWithInterface);
}
}
}
else
{
CustomClassFilters.Add(Class);
}
}
}
}
}
if (InArgs._NewAssetFactories.IsSet())
{
NewAssetFactories = InArgs._NewAssetFactories.GetValue();
}
else if (CustomClassFilters.Num() > 1 || !CustomClassFilters.Contains(UObject::StaticClass()))
{
NewAssetFactories = PropertyCustomizationHelpers::GetNewAssetFactoriesForClasses(CustomClassFilters);
}
//.........这里部分代码省略.........
示例2: TEXT
void FPropertyTable::PasteTextAtCell( const FString& Text, const TSharedRef< IPropertyTableCell >& Cell )
{
if ( !SelectedCells.Contains( Cell ) )
{
return;
}
int32 CurrentRowIdx = 0;
int32 CurrentColumnIdx = 0;
TSharedPtr< IPropertyTableCell > FirstCellInRow = Cell;
TSharedPtr< IPropertyTableCell > TargetCell = Cell;
// Parse into row strings
TArray<FString> RowStrings;
Text.ParseIntoArray(RowStrings, TEXT("\n"), true);
// Parse row strings into individual cell strings
TArray<FString> CellStrings;
RowStrings[CurrentRowIdx++].ParseIntoArray(CellStrings, TEXT("\t"), false);
// Get the maximum paste operations before displaying the slow task
int32 NumPasteOperationsBeforeWarning = GetDefault<UEditorPerProjectUserSettings>()->PropertyMatrix_NumberOfPasteOperationsBeforeWarning;
const bool bShowCancelButton = false;
const bool bShowProgressDialog = SelectedCells.Num() > NumPasteOperationsBeforeWarning;
GWarn->BeginSlowTask(LOCTEXT("UpdatingPropertiesSlowTaskLabel", "Updating properties..."), bShowProgressDialog, bShowCancelButton);
if ( RowStrings.Num() == 1 && CellStrings.Num() == 1 )
{
int32 CurrentCellIndex = 0;
for( auto CellIter = SelectedCells.CreateIterator(); CellIter; ++CellIter )
{
SetCellValue( *CellIter, CellStrings[0] );
if ( bShowProgressDialog )
{
GWarn->UpdateProgress(CurrentCellIndex, SelectedCells.Num());
CurrentCellIndex++;
}
}
}
else if ( StartingCellSelectionRange.IsValid() && EndingCellSelectionRange.IsValid() )
{
// Paste values into cells
while ( TargetCell.IsValid() && SelectedCells.Contains( TargetCell.ToSharedRef() ) && CurrentColumnIdx < CellStrings.Num() )
{
SetCellValue( TargetCell.ToSharedRef(), CellStrings[CurrentColumnIdx++] );
// Move to next column
TargetCell = GetNextCellInRow(TargetCell.ToSharedRef());
if ( ( !TargetCell.IsValid() || !SelectedCells.Contains( TargetCell.ToSharedRef() ) || CurrentColumnIdx == CellStrings.Num() ) && CurrentRowIdx < RowStrings.Num() )
{
// Move to next row
TargetCell = GetNextCellInColumn(FirstCellInRow.ToSharedRef());
if ( TargetCell.IsValid() && SelectedCells.Contains( TargetCell.ToSharedRef() ) )
{
// Prepare data to operate on next row
CurrentColumnIdx = 0;
FirstCellInRow = TargetCell;
RowStrings[CurrentRowIdx++].ParseIntoArray(CellStrings, TEXT("\t"), false);
if ( bShowProgressDialog )
{
GWarn->UpdateProgress(CurrentRowIdx, RowStrings.Num());
}
}
}
}
}
GWarn->EndSlowTask();
}
示例3: UE_LOG
bool UGatherTextFromSourceCommandlet::FMacroDescriptor::ParseArgsFromMacro(const FString& Text, TArray<FString>& Args, FSourceFileParseContext& Context) const
{
// Attempt to parse something of the format
// NAME(param0, param1, param2, etc)
bool Success = false;
FString RemainingText = Text.RightChop(GetToken().Len()).Trim();
int32 OpenBracketIdx = RemainingText.Find(TEXT("("));
if (0 > OpenBracketIdx)
{
UE_LOG(LogGatherTextFromSourceCommandlet, Warning, TEXT("Missing bracket '(' in %s macro in %s(%d):%s"), *GetToken(), *Context.Filename, Context.LineNumber, *MungeLogOutput(Context.LineText));
//Dont assume this is an error. It's more likely trying to parse something it shouldn't be.
return false;
}
else
{
Args.Empty();
bool bInDblQuotes = false;
bool bInSglQuotes = false;
int32 BracketStack = 1;
bool bEscapeNextChar = false;
const TCHAR* ArgStart = *RemainingText + OpenBracketIdx + 1;
const TCHAR* Cursor = ArgStart;
for (; 0 < BracketStack && '\0' != *Cursor; ++Cursor)
{
if (bEscapeNextChar)
{
bEscapeNextChar = false;
}
else if ((bInDblQuotes || bInSglQuotes) && !bEscapeNextChar && '\\' == *Cursor)
{
bEscapeNextChar = true;
}
else if (bInDblQuotes)
{
if ('\"' == *Cursor)
{
bInDblQuotes = false;
}
}
else if (bInSglQuotes)
{
if ('\'' == *Cursor)
{
bInSglQuotes = false;
}
}
else if ('\"' == *Cursor)
{
bInDblQuotes = true;
}
else if ('\'' == *Cursor)
{
bInSglQuotes = true;
}
else if ('(' == *Cursor)
{
++BracketStack;
}
else if (')' == *Cursor)
{
--BracketStack;
if (0 > BracketStack)
{
UE_LOG(LogGatherTextFromSourceCommandlet, Warning, TEXT("Unexpected bracket ')' in %s macro in %s(%d):%s"), *GetToken(), *Context.Filename, Context.LineNumber, *MungeLogOutput(Context.LineText));
return false;
}
}
else if (1 == BracketStack && ',' == *Cursor)
{
// create argument from ArgStart to Cursor and set Start next char
Args.Add(FString(Cursor - ArgStart, ArgStart));
ArgStart = Cursor + 1;
}
}
if (0 == BracketStack)
{
Args.Add(FString(Cursor - ArgStart - 1, ArgStart));
}
else
{
Args.Add(FString(ArgStart));
}
Success = 0 < Args.Num() ? true : false;
}
return Success;
}
示例4: Clear
bool FXmlFile::LoadFile(const FString& InFile, EConstructMethod::Type ConstructMethod)
{
// Remove any file stuff if it already exists
Clear();
// So far no error (Early so it can be overwritten below by errors)
ErrorMessage = NSLOCTEXT("XmlParser", "LoadSuccess", "XmlFile was loaded successfully").ToString();
TArray<FString> Input;
if(ConstructMethod == EConstructMethod::ConstructFromFile)
{
// Create file reader
TUniquePtr<FArchive> FileReader(IFileManager::Get().CreateFileReader(*InFile));
if(!FileReader)
{
ErrorMessage = NSLOCTEXT("XmlParser", "FileLoadFail", "Failed to load the file").ToString();
ErrorMessage += TEXT("\"");
ErrorMessage += InFile;
ErrorMessage += TEXT("\"");
return false;
}
// Create buffer for file input
uint32 BufferSize = FileReader->TotalSize();
void* Buffer = FMemory::Malloc(BufferSize);
FileReader->Serialize(Buffer, BufferSize);
// Parse file buffer into an array of lines
if (!FindCharSizeAndSplitLines(Input, Buffer, BufferSize))
{
ErrorMessage = NSLOCTEXT("XmlParser", "InvalidFormatFail", "Failed to parse the file (Unsupported character encoding)").ToString();
ErrorMessage += TEXT("\"");
ErrorMessage += InFile;
ErrorMessage += TEXT("\"");
return false;
}
// Release resources
FMemory::Free(Buffer);
}
else
{
// Parse input buffer into an array of lines
SplitLines(Input, *InFile, *InFile + InFile.Len());
}
// Pre-process the input
PreProcessInput(Input);
// Tokenize the input
TArray<FString> Tokens = Tokenize(Input);
// Parse the input & create the nodes
CreateNodes(Tokens);
// All done with creation, set up necessary information
if(bFileLoaded == true)
{
if(ConstructMethod == EConstructMethod::ConstructFromFile)
{
LoadedFile = InFile;
}
}
else
{
LoadedFile = TEXT("");
RootNode = nullptr;
}
// Now check the status flag of the creation. It may have actually failed, but given us a
// partially created representation
if(bCreationFailed)
{
Clear();
}
return bFileLoaded;
}
示例5: SplitPackagePathAndAssetName
/**
* A utility function to help separate a package name and asset name out
* from a full asset object path.
*
* @param AssetObjPathIn The asset object path you want split.
* @param PackagePathOut The first half of the in string (the package portion).
* @param AssetNameOut The second half of the in string (the asset name portion).
*/
static void SplitPackagePathAndAssetName(FString const& AssetObjPathIn, FString& PackagePathOut, FString& AssetNameOut)
{
AssetObjPathIn.Split(TEXT("."), &PackagePathOut, &AssetNameOut);
}
示例6: GetNormalizedError
DWORD CDirEnumerator::GetNextFile(NFind::CFileInfo &fi, bool &filled, FString &resPath)
{
filled = false;
resPath.Empty();
for (;;)
{
if (Enumerators.IsEmpty())
{
if (Index >= FilePaths.Size())
return S_OK;
const FString &path = FilePaths[Index++];
int pos = path.ReverseFind(FCHAR_PATH_SEPARATOR);
if (pos >= 0)
resPath.SetFrom(path, pos + 1);
#ifdef _WIN32
if (BasePrefix.IsEmpty() && path.Len() == 2 && path[1] == ':')
{
// we use "c:" item as directory item
fi.Clear();
fi.Name = path;
fi.SetAsDir();
fi.Size = 0;
}
else
#endif
if (!fi.Find(BasePrefix + path))
{
DWORD error = GetNormalizedError();
resPath = path;
return error;
}
break;
}
bool found;
if (Enumerators.Back().Next(fi, found))
{
if (found)
{
resPath = Prefixes.Back();
break;
}
}
else
{
DWORD error = GetNormalizedError();
resPath = Prefixes.Back();
Enumerators.DeleteBack();
Prefixes.DeleteBack();
return error;
}
Enumerators.DeleteBack();
Prefixes.DeleteBack();
}
resPath += fi.Name;
if (EnterToDirs && fi.IsDir())
{
FString s = resPath;
s += FCHAR_PATH_SEPARATOR;
Prefixes.Add(s);
s += FCHAR_ANY_MASK;
Enumerators.Add(NFind::CEnumerator(BasePrefix + s));
}
filled = true;
return S_OK;
}
示例7: GetEngineSavedConfigDirectory
bool FDesktopPlatformBase::EnumerateProjectsKnownByEngine(const FString &Identifier, bool bIncludeNativeProjects, TArray<FString> &OutProjectFileNames)
{
// Get the engine root directory
FString RootDir;
if (!GetEngineRootDirFromIdentifier(Identifier, RootDir))
{
return false;
}
FString GameAgnosticConfigDir = GetEngineSavedConfigDirectory(Identifier);
if (GameAgnosticConfigDir.Len() == 0)
{
return false;
}
// Find all the created project directories. Start with the default project creation path.
TArray<FString> SearchDirectories;
SearchDirectories.AddUnique(GetDefaultProjectCreationPath());
// Load the config file
FConfigFile GameAgnosticConfig;
FConfigCacheIni::LoadExternalIniFile(GameAgnosticConfig, TEXT("EditorSettings"), NULL, *GameAgnosticConfigDir, false);
// Find the editor game-agnostic settings
FConfigSection* Section = GameAgnosticConfig.Find(TEXT("/Script/UnrealEd.EditorSettings"));
if (Section == NULL)
{
FConfigCacheIni::LoadExternalIniFile(GameAgnosticConfig, TEXT("EditorGameAgnostic"), NULL, *GameAgnosticConfigDir, false);
Section = GameAgnosticConfig.Find(TEXT("/Script/UnrealEd.EditorGameAgnosticSettings"));
}
if(Section != NULL)
{
// Add in every path that the user has ever created a project file. This is to catch new projects showing up in the user's project folders
TArray<FString> AdditionalDirectories;
Section->MultiFind(TEXT("CreatedProjectPaths"), AdditionalDirectories);
for(int Idx = 0; Idx < AdditionalDirectories.Num(); Idx++)
{
FPaths::NormalizeDirectoryName(AdditionalDirectories[Idx]);
SearchDirectories.AddUnique(AdditionalDirectories[Idx]);
}
// Also add in all the recently opened projects
TArray<FString> RecentlyOpenedFiles;
Section->MultiFind(TEXT("RecentlyOpenedProjectFiles"), RecentlyOpenedFiles);
for(int Idx = 0; Idx < RecentlyOpenedFiles.Num(); Idx++)
{
FPaths::NormalizeFilename(RecentlyOpenedFiles[Idx]);
OutProjectFileNames.AddUnique(RecentlyOpenedFiles[Idx]);
}
}
// Find all the other projects that are in the search directories
for(int Idx = 0; Idx < SearchDirectories.Num(); Idx++)
{
TArray<FString> ProjectFolders;
IFileManager::Get().FindFiles(ProjectFolders, *(SearchDirectories[Idx] / TEXT("*")), false, true);
for(int32 FolderIdx = 0; FolderIdx < ProjectFolders.Num(); FolderIdx++)
{
TArray<FString> ProjectFiles;
IFileManager::Get().FindFiles(ProjectFiles, *(SearchDirectories[Idx] / ProjectFolders[FolderIdx] / TEXT("*.uproject")), true, false);
for(int32 FileIdx = 0; FileIdx < ProjectFiles.Num(); FileIdx++)
{
OutProjectFileNames.AddUnique(SearchDirectories[Idx] / ProjectFolders[FolderIdx] / ProjectFiles[FileIdx]);
}
}
}
// Find all the native projects, and either add or remove them from the list depending on whether we want native projects
const FUProjectDictionary &Dictionary = GetCachedProjectDictionary(RootDir);
if(bIncludeNativeProjects)
{
TArray<FString> NativeProjectPaths = Dictionary.GetProjectPaths();
for(int Idx = 0; Idx < NativeProjectPaths.Num(); Idx++)
{
if(!NativeProjectPaths[Idx].Contains(TEXT("/Templates/")))
{
OutProjectFileNames.AddUnique(NativeProjectPaths[Idx]);
}
}
}
else
{
TArray<FString> NativeProjectPaths = Dictionary.GetProjectPaths();
for(int Idx = 0; Idx < NativeProjectPaths.Num(); Idx++)
{
OutProjectFileNames.Remove(NativeProjectPaths[Idx]);
}
}
return true;
}
示例8: IntFromString
int IntFromString(const FString& InStr)
{
return std::atoi(InStr.c_str());
}
示例9: check
bool FAssetEditorManager::OpenEditorForAsset(UObject* Asset, const EToolkitMode::Type ToolkitMode, TSharedPtr< IToolkitHost > OpenedFromLevelEditor )
{
check(Asset);
// @todo toolkit minor: When "Edit Here" happens in a different level editor from the one that an asset is already
// being edited within, we should decide whether to disallow "Edit Here" in that case, or to close the old asset
// editor and summon it in the new level editor, or to just foreground the old level editor (current behavior)
const bool bBringToFrontIfOpen = true;
// Don't open asset editors for cooked packages
if (UPackage* Package = Asset->GetOutermost())
{
if (Package->bIsCookedForEditor)
{
return false;
}
}
AssetEditorRequestOpenEvent.Broadcast(Asset);
if( FindEditorForAsset(Asset, bBringToFrontIfOpen) != nullptr )
{
// This asset is already open in an editor! (the call to FindEditorForAsset above will bring it to the front)
return true;
}
else
{
GWarn->BeginSlowTask( LOCTEXT("OpenEditor", "Opening Editor..."), true);
}
FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>(TEXT("AssetTools"));
TWeakPtr<IAssetTypeActions> AssetTypeActions = AssetToolsModule.Get().GetAssetTypeActionsForClass( Asset->GetClass() );
auto ActualToolkitMode = ToolkitMode;
if( AssetTypeActions.IsValid() )
{
if( AssetTypeActions.Pin()->ShouldForceWorldCentric() )
{
// This asset type prefers a specific toolkit mode
ActualToolkitMode = EToolkitMode::WorldCentric;
if( !OpenedFromLevelEditor.IsValid() )
{
// We don't have a level editor to spawn in world-centric mode, so we'll find one now
// @todo sequencer: We should eventually eliminate this code (incl include dependencies) or change it to not make assumptions about a single level editor
OpenedFromLevelEditor = FModuleManager::LoadModuleChecked< FLevelEditorModule >( "LevelEditor" ).GetFirstLevelEditor();
}
}
}
if( ActualToolkitMode != EToolkitMode::WorldCentric && OpenedFromLevelEditor.IsValid() )
{
// @todo toolkit minor: Kind of lame use of a static variable here to prime the new asset editor. This was done to avoid refactoring a few dozen files for a very minor change.
FAssetEditorToolkit::SetPreviousWorldCentricToolkitHostForNewAssetEditor( OpenedFromLevelEditor.ToSharedRef() );
}
// Disallow opening an asset editor for classes
bool bCanSummonSimpleAssetEditor = !Asset->IsA<UClass>();
if( AssetTypeActions.IsValid() )
{
TArray<UObject*> AssetsToEdit;
AssetsToEdit.Add(Asset);
// Some assets (like UWorlds) may be destroyed and recreated as part of opening. To protect against this, keep the path to the asset and try to re-find it if it disappeared.
TWeakObjectPtr<UObject> WeakAsset = Asset;
const FString AssetPath = Asset->GetPathName();
AssetTypeActions.Pin()->OpenAssetEditor(AssetsToEdit, ActualToolkitMode == EToolkitMode::WorldCentric ? OpenedFromLevelEditor : TSharedPtr<IToolkitHost>());
// If the Asset was destroyed, attempt to find it if it was recreated
if ( !WeakAsset.IsValid() && !AssetPath.IsEmpty() )
{
Asset = FindObject<UObject>(nullptr, *AssetPath);
}
AssetEditorOpenedEvent.Broadcast(Asset);
}
else if( bCanSummonSimpleAssetEditor )
{
// No asset type actions for this asset. Just use a properties editor.
FSimpleAssetEditor::CreateEditor(ActualToolkitMode, ActualToolkitMode == EToolkitMode::WorldCentric ? OpenedFromLevelEditor : TSharedPtr<IToolkitHost>(), Asset);
}
GWarn->EndSlowTask();
return true;
}
示例10: RemoveUniformBuffersFromSource
bool RemoveUniformBuffersFromSource(FString& SourceCode)
{
static const FString StaticStructToken(TEXT("static const struct"));
int32 StaticStructTokenPos = SourceCode.Find(StaticStructToken, ESearchCase::CaseSensitive, ESearchDir::FromStart);
while (StaticStructTokenPos != INDEX_NONE)
{
static const FString CloseBraceSpaceToken(TEXT("} "));
int32 CloseBraceSpaceTokenPos = SourceCode.Find(CloseBraceSpaceToken, ESearchCase::CaseSensitive, ESearchDir::FromStart, StaticStructTokenPos + StaticStructToken.Len());
if (CloseBraceSpaceTokenPos == INDEX_NONE)
{
check(0); //@todo-rco: ERROR
return false;
}
int32 NamePos = CloseBraceSpaceTokenPos + CloseBraceSpaceToken.Len();
static const FString SpaceEqualsToken(TEXT(" ="));
int32 SpaceEqualsTokenPos = SourceCode.Find(SpaceEqualsToken, ESearchCase::CaseSensitive, ESearchDir::FromStart, NamePos);
if (SpaceEqualsTokenPos == INDEX_NONE)
{
check(0); //@todo-rco: ERROR
return false;
}
FString UniformBufferName = SourceCode.Mid(NamePos, SpaceEqualsTokenPos - NamePos);
check(UniformBufferName.Len() > 0);
static const FString CloseBraceSemicolorToken(TEXT("};"));
int32 CloseBraceSemicolonTokenPos = SourceCode.Find(CloseBraceSemicolorToken, ESearchCase::CaseSensitive, ESearchDir::FromStart, SpaceEqualsTokenPos + SpaceEqualsToken.Len());
if (CloseBraceSemicolonTokenPos == INDEX_NONE)
{
check(0); //@todo-rco: ERROR
return false;
}
// Comment out this UB
auto& SourceCharArray = SourceCode.GetCharArray();
SourceCharArray[StaticStructTokenPos] = TCHAR('/');
SourceCharArray[StaticStructTokenPos + 1] = TCHAR('*');
SourceCharArray[CloseBraceSemicolonTokenPos] = TCHAR('*');
SourceCharArray[CloseBraceSemicolonTokenPos + 1] = TCHAR('/');
// Find & Replace this UB
FString UBSource = UniformBufferName + FString(TEXT("."));
FString UBDest = UniformBufferName + FString(TEXT("_"));
SourceCode.ReplaceInline(*UBSource, *UBDest, ESearchCase::CaseSensitive);
// Find next UB
StaticStructTokenPos = SourceCode.Find(StaticStructToken, ESearchCase::CaseSensitive, ESearchDir::FromStart, CloseBraceSemicolonTokenPos + 2);
}
return true;
}
示例11: ParseOpenBrace
void FMapInfoParser::ParseDoomEdNums()
{
TMap<int, bool> defined;
int error = 0;
MapinfoEdMapItem editem;
editem.filename = sc.ScriptName;
ParseOpenBrace();
while (true)
{
if (sc.CheckString("}")) return;
else if (sc.CheckNumber())
{
int ednum = sc.Number;
sc.MustGetStringName("=");
sc.MustGetString();
bool *def = defined.CheckKey(ednum);
if (def != NULL)
{
sc.ScriptMessage("Editor Number %d defined more than once", ednum);
error++;
}
defined[ednum] = true;
if (sc.String[0] == '$')
{
// todo: add special stuff like playerstarts and sound sequence overrides here, too.
editem.classname = NAME_None;
editem.special = sc.MustMatchString(SpecialMapthingNames) + 1; // todo: assign proper constants
}
else
{
editem.classname = sc.String;
editem.special = -1;
}
memset(editem.args, 0, sizeof(editem.args));
editem.argsdefined = 0;
int minargs = 0;
int maxargs = 5;
FString specialname;
if (sc.CheckString(","))
{
editem.argsdefined = 5; // mark args as used - if this is done we need to prevent assignment of map args in P_SpawnMapThing.
if (editem.special < 0) editem.special = 0;
if (!sc.CheckNumber())
{
sc.MustGetString();
specialname = sc.String; // save for later error reporting.
editem.special = P_FindLineSpecial(sc.String, &minargs, &maxargs);
if (editem.special == 0 || minargs == -1)
{
sc.ScriptMessage("Invalid special %s for Editor Number %d", sc.String, ednum);
error++;
minargs = 0;
maxargs = 5;
}
if (!sc.CheckString(","))
{
// special case: Special without arguments
if (minargs != 0)
{
sc.ScriptMessage("Incorrect number of args for special %s, min = %d, max = %d, found = 0", specialname.GetChars(), minargs, maxargs);
error++;
}
DoomEdFromMapinfo.Insert(ednum, editem);
continue;
}
sc.MustGetNumber();
}
int i = 0;
while (i < 5)
{
editem.args[i] = sc.Number;
i++;
if (!sc.CheckString(",")) break;
// special check for the ambient sounds which combine the arg being set here with the ones on the mapthing.
if (sc.CheckString("+"))
{
editem.argsdefined = i;
break;
}
sc.MustGetNumber();
}
if (specialname.IsNotEmpty() && (i < minargs || i > maxargs))
{
sc.ScriptMessage("Incorrect number of args for special %s, min = %d, max = %d, found = %d", specialname.GetChars(), minargs, maxargs, i);
error++;
}
}
DoomEdFromMapinfo.Insert(ednum, editem);
}
else
{
sc.ScriptError("Number expected");
}
}
//.........这里部分代码省略.........
示例12: if
MapData *P_OpenMapData(const char * mapname, bool justcheck)
{
MapData * map = new MapData;
FileReader * wadReader = nullptr;
bool externalfile = !strnicmp(mapname, "file:", 5);
if (externalfile)
{
mapname += 5;
if (!FileExists(mapname))
{
delete map;
return NULL;
}
map->resource = FResourceFile::OpenResourceFile(mapname, true);
wadReader = map->resource->GetReader();
}
else
{
FString fmt;
int lump_wad;
int lump_map;
int lump_name = -1;
// Check for both *.wad and *.map in order to load Build maps
// as well. The higher one will take precedence.
// Names with more than 8 characters will only be checked as .wad and .map.
if (strlen(mapname) <= 8) lump_name = Wads.CheckNumForName(mapname);
fmt.Format("maps/%s.wad", mapname);
lump_wad = Wads.CheckNumForFullName(fmt);
fmt.Format("maps/%s.map", mapname);
lump_map = Wads.CheckNumForFullName(fmt);
if (lump_name > lump_wad && lump_name > lump_map && lump_name != -1)
{
int lumpfile = Wads.GetLumpFile(lump_name);
int nextfile = Wads.GetLumpFile(lump_name+1);
map->lumpnum = lump_name;
if (lumpfile != nextfile)
{
// The following lump is from a different file so whatever this is,
// it is not a multi-lump Doom level so let's assume it is a Build map.
map->MapLumps[0].Reader = Wads.ReopenLumpReader(lump_name);
if (!P_IsBuildMap(map))
{
delete map;
return NULL;
}
return map;
}
// This case can only happen if the lump is inside a real WAD file.
// As such any special handling for other types of lumps is skipped.
map->MapLumps[0].Reader = Wads.ReopenLumpReader(lump_name);
strncpy(map->MapLumps[0].Name, Wads.GetLumpFullName(lump_name), 8);
map->Encrypted = Wads.IsEncryptedFile(lump_name);
map->InWad = true;
if (map->Encrypted)
{ // If it's encrypted, then it's a Blood file, presumably a map.
if (!P_IsBuildMap(map))
{
delete map;
return NULL;
}
return map;
}
int index = 0;
if (stricmp(Wads.GetLumpFullName(lump_name + 1), "TEXTMAP") != 0)
{
for(int i = 1;; i++)
{
// Since levels must be stored in WADs they can't really have full
// names and for any valid level lump this always returns the short name.
const char * lumpname = Wads.GetLumpFullName(lump_name + i);
try
{
index = GetMapIndex(mapname, index, lumpname, !justcheck);
}
catch(...)
{
delete map;
throw;
}
if (index == -2)
{
delete map;
return NULL;
}
if (index == ML_BEHAVIOR) map->HasBehavior = true;
// The next lump is not part of this map anymore
if (index < 0) break;
map->MapLumps[index].Reader = Wads.ReopenLumpReader(lump_name + i);
strncpy(map->MapLumps[index].Name, lumpname, 8);
//.........这里部分代码省略.........
示例13: FString
void UJanusExporterTool::Export()
{
TArray<UObject*> ObjectsToExport;
FString Root = FString(ExportPath); // copy so we dont mess with the original reference
FString Index = "<html>\n\t<head>\n\t\t<title>Unreal Export</title>\n\t</head>\n\t<body>\n\t\t<FireBoxRoom>\n\t\t\t<Assets>";
TArray<AActor*> ActorsExported;
TArray<UStaticMesh*> StaticMeshesExp;
TArray<FString> TexturesExp;
TArray<FString> MaterialsExported;
for (TObjectIterator<AActor> Itr; Itr; ++Itr)
{
AActor *Actor = *Itr;
FString Name = Actor->GetName();
/*if (!Name.StartsWith("SM_Floor_R"))
{
continue;
}*/
if (Actor->IsHiddenEd())
{
continue;
}
ActorsExported.Add(Actor);
TArray<UStaticMeshComponent*> StaticMeshes;
Actor->GetComponents<UStaticMeshComponent>(StaticMeshes);
for (int32 i = 0; i < StaticMeshes.Num(); i++)
{
UStaticMeshComponent* Component = StaticMeshes[i];
UStaticMesh *Mesh = Component->StaticMesh;
if (!Mesh)
{
continue;
}
if (Component->LODData.Num() > 0)
//if (false)
{
FStaticMeshComponentLODInfo* LODInfo = &Component->LODData[0];
FLightMap* LightMap = LODInfo->LightMap;
FShadowMap* ShadowMap = LODInfo->ShadowMap;
if (LightMap != NULL)
{
FLightMap2D* LightMap2D = LightMap->GetLightMap2D();
UTexture2D* Texture = LightMap2D->GetTexture(0); // 0 = HQ LightMap
FString TexName = Texture->GetName();
if (TexturesExp.Contains(TexName))
{
continue;
}
TexturesExp.Add(TexName);
ExportPNG(Texture, Root);
}
if (ShadowMap != NULL)
{
FShadowMap2D* ShadowMap2D = ShadowMap->GetShadowMap2D();
UShadowMapTexture2D* ShadowTex = ShadowMap2D->GetTexture();
FString TexName = ShadowTex->GetName();
if (TexturesExp.Contains(TexName))
{
continue;
}
TexturesExp.Add(TexName);
ExportPNG(ShadowTex, Root);
}
}
if (!StaticMeshesExp.Contains(Mesh))
{
StaticMeshesExp.Add(Mesh);
ExportFBX(Mesh, Root);
}
TArray<UMaterialInterface*> Materials = Component->GetMaterials();
for (int32 j = 0; j < Materials.Num(); j++)
{
UMaterialInterface* Material = Materials[j];
if (!Material)
{
continue;
}
FString MatName = Material->GetName();
if (MaterialsExported.Contains(MatName))
{
continue;
}
MaterialsExported.Add(MatName);
ExportMaterial(Root, Material, &TexturesExp);
}
}
//.........这里部分代码省略.........
示例14: GetConfigFile
bool UOnlineHotfixManager::HotfixIniFile(const FString& FileName, const FString& IniData)
{
FConfigFile* ConfigFile = GetConfigFile(FileName);
// Merge the string into the config file
ConfigFile->CombineFromBuffer(IniData);
TArray<UClass*> Classes;
TArray<UObject*> PerObjectConfigObjects;
int32 StartIndex = 0;
int32 EndIndex = 0;
// Find the set of object classes that were affected
while (StartIndex >= 0 && StartIndex < IniData.Len() && EndIndex >= StartIndex)
{
// Find the next section header
StartIndex = IniData.Find(TEXT("["), ESearchCase::IgnoreCase, ESearchDir::FromStart, StartIndex);
if (StartIndex > -1)
{
// Find the ending section identifier
EndIndex = IniData.Find(TEXT("]"), ESearchCase::IgnoreCase, ESearchDir::FromStart, StartIndex);
if (EndIndex > StartIndex)
{
int32 PerObjectNameIndex = IniData.Find(TEXT(" "), ESearchCase::IgnoreCase, ESearchDir::FromStart, StartIndex);
// Per object config entries will have a space in the name, but classes won't
if (PerObjectNameIndex == -1 || PerObjectNameIndex > EndIndex)
{
if (IniData.StartsWith(TEXT("[/Script/"), ESearchCase::IgnoreCase))
{
const int32 ScriptSectionTag = 9;
// Snip the text out and try to find the class for that
const FString PackageClassName = IniData.Mid(StartIndex + ScriptSectionTag, EndIndex - StartIndex - ScriptSectionTag);
// Find the class for this so we know what to update
UClass* Class = FindObject<UClass>(nullptr, *PackageClassName, true);
if (Class)
{
// Add this to the list to check against
Classes.Add(Class);
}
}
}
// Handle the per object config case by finding the object for reload
else
{
const int32 Count = PerObjectNameIndex - StartIndex - 1;
const FString PerObjectName = IniData.Mid(StartIndex + 1, Count);
// Explicitly search the transient package (won't update non-transient objects)
UObject* PerObject = FindObject<UObject>(ANY_PACKAGE, *PerObjectName, false);
if (PerObject != nullptr)
{
PerObjectConfigObjects.Add(PerObject);
}
}
StartIndex = EndIndex;
}
}
}
int32 NumObjectsReloaded = 0;
const double StartTime = FPlatformTime::Seconds();
if (Classes.Num())
{
// Now that we have a list of classes to update, we can iterate objects and reload
for (FObjectIterator It; It; ++It)
{
UClass* Class = It->GetClass();
if (Class->HasAnyClassFlags(CLASS_Config))
{
// Check to see if this class is in our list (yes, potentially n^2, but not in practice)
for (int32 ClassIndex = 0; ClassIndex < Classes.Num(); ClassIndex++)
{
if (It->IsA(Classes[ClassIndex]))
{
// Force a reload of the config vars
It->ReloadConfig();
NumObjectsReloaded++;
break;
}
}
}
}
}
// Reload any PerObjectConfig objects that were affected
for (auto ReloadObject : PerObjectConfigObjects)
{
ReloadObject->ReloadConfig();
NumObjectsReloaded++;
}
UE_LOG(LogHotfixManager, Log, TEXT("Updating config from %s took %f seconds and reloaded %d objects"),
*FileName, FPlatformTime::Seconds() - StartTime, NumObjectsReloaded);
return true;
}
示例15: Open
bool FAndroidMediaPlayer::Open(const FString& Url)
{
if (Url.IsEmpty())
{
return false;
}
if (MediaState != EMediaState::Idle)
{
return false;
}
if (Url.StartsWith(TEXT("http:")) || Url.StartsWith(TEXT("https:")) ||
Url.StartsWith(TEXT("rtsp:")) || Url.StartsWith(TEXT("file:")))
{
// Direct open media at a "remote" URL.
JavaMediaPlayer->SetDataSource(Url);
MediaState = EMediaState::Initialized;
}
else
{
// Use the platform file layer to open the media file. We
// need to access Android specific information to allow
// for playing media that is embedded in the APK, OBBs,
// and/or PAKs.
// Construct a canonical path for the movie.
FString MoviePath = Url;
FPaths::NormalizeFilename(MoviePath);
// Don't bother trying to play it if we can't find it.
if (!IAndroidPlatformFile::GetPlatformPhysical().FileExists(*MoviePath))
{
return false;
}
// Get information about the movie.
int64 FileOffset = IAndroidPlatformFile::GetPlatformPhysical().FileStartOffset(*MoviePath);
int64 FileSize = IAndroidPlatformFile::GetPlatformPhysical().FileSize(*MoviePath);
FString FileRootPath = IAndroidPlatformFile::GetPlatformPhysical().FileRootPath(*MoviePath);
// Play the movie as a file or asset.
if (IAndroidPlatformFile::GetPlatformPhysical().IsAsset(*MoviePath))
{
if (JavaMediaPlayer->SetDataSource(
IAndroidPlatformFile::GetPlatformPhysical().GetAssetManager(),
FileRootPath, FileOffset, FileSize))
{
MediaState = EMediaState::Initialized;
}
}
else
{
if (JavaMediaPlayer->SetDataSource(FileRootPath, FileOffset, FileSize))
{
MediaState = EMediaState::Initialized;
}
}
}
if (MediaState == EMediaState::Initialized)
{
MediaUrl = Url;
JavaMediaPlayer->Prepare();
MediaState = EMediaState::Prepared;
}
if (MediaState == EMediaState::Prepared)
{
// Use the extension as a rough guess as to what tracks
// to use.
FString Extension = FPaths::GetExtension(MediaUrl);
if (Extension.Equals(TEXT("3gpp"), ESearchCase::IgnoreCase) ||
Extension.Equals(TEXT("mp4"), ESearchCase::IgnoreCase))
{
// For video we add video track and disable audio
JavaMediaPlayer->SetAudioEnabled(false);
// AudioTracks.Add(MakeShareable(new AudioTrack(*this, AudioTracks.Num())));
VideoTracks.Add(MakeShareable(new VideoTrack(*this, VideoTracks.Num())));
}
else if (Extension.Equals(TEXT("aac"), ESearchCase::IgnoreCase))
{
AudioTracks.Add(MakeShareable(new AudioTrack(*this, AudioTracks.Num())));
}
TracksChangedEvent.Broadcast();
}
if (MediaState == EMediaState::Prepared)
{
OpenedEvent.Broadcast(MediaUrl);
}
return MediaState == EMediaState::Prepared;
}