FString FChunkManifestGenerator::CreateCookerFileOrderString(const TMap<FName, FAssetData*>& InAssetData, const TArray<FName>& InMaps)
{
	FString FileOrderString;
	TArray<FAssetData*> TopLevelNodes;

	for (auto Asset : InAssetData)
	{
		auto PackageName = Asset.Value->PackageName;
		TArray<FName> Referencers;
		AssetRegistry.GetReferencers(PackageName, Referencers);

		bool bIsTopLevel = true;
		bool bIsMap = InMaps.Contains(PackageName);

		if (!bIsMap && Referencers.Num() > 0)
		{
			for (auto ReferencerName : Referencers)
			{
				if (InAssetData.Contains(ReferencerName))
				{
					bIsTopLevel = false;
					break;
				}
			}
		}

		if (bIsTopLevel)
		{
			if (bIsMap)
			{
				TopLevelNodes.Insert(Asset.Value, 0);
			}
			else
			{
				TopLevelNodes.Insert(Asset.Value, TopLevelNodes.Num());
			}
		}
	}

	TArray<FName> FileOrder;
	TArray<FName> EncounteredNames;
	for (auto Asset : TopLevelNodes)
	{
		AddAssetToFileOrderRecursive(Asset, FileOrder, EncounteredNames, InAssetData, InMaps);
	}

	int32 CurrentIndex = 0;
	for (auto PackageName : FileOrder)
	{
		auto Asset = InAssetData[PackageName];
		bool bIsMap = InMaps.Contains(Asset->PackageName);
		auto Filename = FPackageName::LongPackageNameToFilename(Asset->PackageName.ToString(), bIsMap ? FPackageName::GetMapPackageExtension() : FPackageName::GetAssetPackageExtension());

		ConvertFilenameToPakFormat(Filename);
		auto Line = FString::Printf(TEXT("\"%s\" %i\n"), *Filename, CurrentIndex++);
		FileOrderString.Append(Line);
	}

	return FileOrderString;
}
void FSlateWindowHelper::ArrangeWindowToFront( TArray< TSharedRef<SWindow> >& Windows, const TSharedRef<SWindow>& WindowToBringToFront )
{
	Windows.Remove(WindowToBringToFront);

	if ((Windows.Num() == 0) || WindowToBringToFront->IsTopmostWindow())
	{
		Windows.Add(WindowToBringToFront);
	}
	else
	{
		bool PerformedInsert = false;

		for (int WindowIndex = Windows.Num() - 1; WindowIndex >= 0; --WindowIndex)
		{
			if (!Windows[WindowIndex]->IsTopmostWindow())
			{
				Windows.Insert(WindowToBringToFront, WindowIndex + 1);
				PerformedInsert = true;

				break;
			}
		}

		if (!PerformedInsert)
		{
			Windows.Insert(WindowToBringToFront, 0);
		}
	}
}
		/**
		 * Recursively look for `TargetItem` in `InsertInto` and any of the descendants.
		 * Insert `ItemToInsert` relative to the target.
		 * Relative positioning dictated by `RelativeLocation`.
		 *
		 * @return true when successful.
		 */
		static bool InsertRecursive(TArray< TSharedPtr< FTestData > >& InsertInto, const TSharedRef<FTestData>& ItemToInsert, const TSharedRef<FTestData>& TargetItem, EItemDropZone RelativeLocation)
		{
			const int32 TargetIndex = InsertInto.Find(TargetItem);
			if (TargetIndex != INDEX_NONE)
			{
				if (RelativeLocation == EItemDropZone::AboveItem)
				{
					InsertInto.Insert(ItemToInsert, TargetIndex);
				}
				else if (RelativeLocation == EItemDropZone::BelowItem)
				{
					InsertInto.Insert(ItemToInsert, TargetIndex + 1);
				}
				else
				{
					ensure(RelativeLocation == EItemDropZone::OntoItem);
					InsertInto[TargetIndex]->Children.Insert(ItemToInsert, 0);
				}				
				return true;
			}

			// Did not successfully remove an item. Try all the children.
			for (int32 ItemIndex = 0; ItemIndex < InsertInto.Num(); ++ItemIndex)
			{
				if (InsertRecursive(InsertInto[ItemIndex]->Children, ItemToInsert, TargetItem, RelativeLocation))
				{
					return true;
				}
			}

			return false;
		}
/**
* This function parses the Json response after uploading the save file to obtain the 
* URL of the save file.
*
* @param JsonString              Json string to parse
* @param PlayerControllerId      Player controller ID of the player who is saving the file
*
*/
void CloudyWebConnectorImpl::ReadAndStoreSaveFileURL(FString JsonString, int32 PlayerControllerId)
{
    JsonString = JsonString.Replace(TEXT("["), TEXT(""));
    JsonString = JsonString.Replace(TEXT("]"), TEXT(""));
    
    TSharedPtr<FJsonObject> JsonObject = MakeShareable(new FJsonObject());
    TSharedRef<TJsonReader<TCHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(JsonString);
    FJsonSerializer::Deserialize(JsonReader, JsonObject);

    // More player controllers than the TArray size
    if (PlayerControllerId >= SaveFileUrls.Num())
    {
        SaveFileUrls.AddUninitialized(PlayerControllerId - SaveFileUrls.Num() + 1);
    }
    if (JsonObject->HasField("saved_file"))
    {
        UE_LOG(CloudyWebConnectorLog, Error, TEXT("Json saved_file field found."));
        SaveFileUrls.Insert(JsonObject->GetStringField("saved_file"), PlayerControllerId);
    }
    else
    {
        UE_LOG(CloudyWebConnectorLog, Error, TEXT("Json saved_file field NOT found."));
        SaveFileUrls.Insert("", PlayerControllerId);
    }
}
Exemple #5
0
void CMapGridPainter::AddRegion (const CVector &vCenter, Metric rWidth, Metric rHeight)

//	AddRegion
//
//	Adds a rectangular region to paint. We combine this appropriately with any
//	previously added regions.

	{
	int x, y;

	Metric rHalfWidth = 0.5 * rWidth;
	Metric rHalfHeight = 0.5 * rHeight;

	int xFrom = (int)floor((vCenter.GetX() - rHalfWidth) / GRID_SIZE);
	int xTo = (int)floor((vCenter.GetX() + rHalfWidth) / GRID_SIZE);
	int yFrom = (int)floor((vCenter.GetY() - rHalfHeight) / GRID_SIZE);
	int yTo = (int)floor((vCenter.GetY() + rHalfHeight) / GRID_SIZE);

	//	Null case

	if (xFrom == xTo || yFrom == yTo)
		return;

	//	Start with vertical lines

	TArray<SLine> NewLines;
	for (x = xFrom; x <= xTo; x++)
		{
		SLine *pNewLine = NewLines.Insert();
		pNewLine->xyKey = x;
		pNewLine->xyFrom = yFrom;
		pNewLine->xyTo = yTo;
		}

	AddLines(NewLines, &m_VertLines);

	//	Add horizontal lines

	NewLines.DeleteAll();
	for (y = yFrom; y <= yTo; y++)
		{
		SLine *pNewLine = NewLines.Insert();
		pNewLine->xyKey = y;
		pNewLine->xyFrom = xFrom;
		pNewLine->xyTo = xTo;
		}

	AddLines(NewLines, &m_HorzLines);

	m_bRecalcNeeded = true;
	}
Exemple #6
0
void CSystemCreateStats::AddLabelExpansion (const CString &sAttributes, const CString &sPrefix)

//	AddLabelExpansion
//
//	Expands and adds the given attributes to the label counter

	{
	int i;

	TArray<CString> Attribs;
	ParseAttributes(sAttributes, &Attribs);

	//	Add each of the attributes alone (and make a list of permutations)

	TArray<CString> Permutable;
	for (i = 0; i < Attribs.GetCount(); i++)
		{
		if (m_PermuteAttribs.Find(Attribs[i]))
			Permutable.Insert(Attribs[i]);
		else
			AddEntry(Attribs[i]);
		}

	//	Now add all permutations

	if (Permutable.GetCount() >= 1)
		AddEntryPermutations(NULL_STR, Permutable, 0);
	}
ALERROR CLevelTableOfItemGenerators::LoadFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc)

//	LoadFromXML
//
//	Load table from XML

	{
	int i;
	ALERROR error;

	for (i = 0; i < pDesc->GetContentElementCount(); i++)
		{
		CXMLElement *pEntry = pDesc->GetContentElement(i);
		SEntry *pNewEntry = m_Table.Insert();

		pNewEntry->sLevelFrequency = pEntry->GetAttribute(LEVEL_FREQUENCY_ATTRIB);

		pNewEntry->Count.LoadFromXML(pEntry->GetAttribute(COUNT_ATTRIB));
		if (pNewEntry->Count.IsEmpty())
			pNewEntry->Count.SetConstant(1);

		if (error = IItemGenerator::CreateFromXML(Ctx, pEntry, &pNewEntry->pEntry))
			return error;
		}

	m_iComputedLevel = -1;

	return NOERROR;
	}
Exemple #8
0
void CComplexArea::AddRect (TArray<SRect> &Array, int x, int y, int cxWidth, int cyHeight, int iRotation)

//	AddRect
//
//	Adds the rect

{
    int i;

    if (cxWidth <= 0 || cyHeight <= 0)
        return;

    //	See if we already have a rect like this

    for (i = 0; i < Array.GetCount(); i++)
    {
        SRect &Test = Array[i];
        if (Test.x == x
                && Test.y == y
                && Test.iRotation == iRotation
                && Test.cxWidth == cxWidth
                && Test.cyHeight == cyHeight)
            return;
    }

    //	Add it

    SRect *pRect = Array.Insert();
    pRect->x = x;
    pRect->y = y;
    pRect->cxWidth = cxWidth;
    pRect->cyHeight = cyHeight;
    pRect->iRotation = (iRotation > 0 ? (iRotation % 360) : 0);

    //	Add to bounds

    if (iRotation > 0)
    {
        int xLL = 0;
        int yLL = 0;

        int xLR, yLR;
        IntPolarToVector(iRotation, cxWidth, &xLR, &yLR);

        int xUL, yUL;
        IntPolarToVector(iRotation + 90, cyHeight, &xUL, &yUL);

        int xUR = xUL + xLR;
        int yUR = yUL + yLR;

        int xLeft = Min(Min(xLL, xLR), Min(xUL, xUR));
        int xRight = Max(Max(xLL, xLR), Max(xUL, xUR));
        int yTop = Max(Max(yLL, yLR), Max(yUL, yUR));
        int yBottom = Min(Min(yLL, yLR), Min(yUL, yUR));

        AddToBounds(x + xLeft, y + yTop, x + xRight, y + yBottom);
    }
    else
        AddToBounds(x, y + cyHeight, x + cxWidth, y);
}
Exemple #9
0
bool FTimespan::Parse( const FString& TimespanString, FTimespan& OutTimespan )
{
	// @todo gmp: implement stricter FTimespan parsing; this implementation is too forgiving.
	FString TokenString = TimespanString.Replace(TEXT("."), TEXT(":"));

	bool Negative = TokenString.StartsWith(TEXT("-"));

	TokenString.ReplaceInline(TEXT("-"), TEXT(":"), ESearchCase::CaseSensitive);

	TArray<FString> Tokens;
	TokenString.ParseIntoArray(Tokens, TEXT(":"), true);

	if (Tokens.Num() == 4)
	{
		Tokens.Insert(TEXT("0"), 0);
	}

	if (Tokens.Num() == 5)
	{
		OutTimespan.Assign(FCString::Atoi(*Tokens[0]), FCString::Atoi(*Tokens[1]), FCString::Atoi(*Tokens[2]), FCString::Atoi(*Tokens[3]), FCString::Atoi(*Tokens[4]));

		if (Negative)
		{
			OutTimespan.Ticks *= -1;
		}

		return true;
	}

	return false;
}
Exemple #10
0
void CSpaceObjectList::Subtract (const CSpaceObjectList &List)

//	Subtract
//
//	Removes all objects in List from the current list

	{
	int i;

	//	Mark all current objects

	int iCount = GetCount();
	for (i = 0; i < iCount; i++)
		GetObj(i)->SetMarked(true);

	//	Clear marks on all objects to remove

	for (i = 0; i < List.GetCount(); i++)
		List.GetObj(i)->SetMarked(false);

	//	Create a new list with the remaining objects

	TArray<CSpaceObject *> NewList;
	for (i = 0; i < iCount; i++)
		if (GetObj(i)->IsMarked())
			NewList.Insert(GetObj(i));

	m_List.TakeHandoff(NewList);
	}
ALERROR CGroupOfDeviceGenerators::LoadFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc)

//	LoadFromXML
//
//	Load from XML

	{
	int i;
	ALERROR error;

	m_Count.LoadFromXML(pDesc->GetAttribute(COUNT_ATTRIB));
	if (m_Count.IsEmpty())
		m_Count.SetConstant(1);

	//	Load either a <DeviceSlot> element or another device generator.

	for (i = 0; i < pDesc->GetContentElementCount(); i++)
		{
		CXMLElement *pEntry = pDesc->GetContentElement(i);

		if (strEquals(pEntry->GetTag(), DEVICE_SLOT_TAG))
			{
			SSlotDesc *pSlotDesc = m_SlotDesc.Insert();

			CItem::ParseCriteria(pEntry->GetAttribute(CRITERIA_ATTRIB), &pSlotDesc->Criteria);

			if (error = IDeviceGenerator::InitDeviceDescFromXML(Ctx, pEntry, &pSlotDesc->DefaultDesc))
				return error;

			pSlotDesc->iMaxCount = pEntry->GetAttributeIntegerBounded(MAX_COUNT_ATTRIB, 0, -1, -1);
			}
		else
			{
			SEntry *pTableEntry = m_Table.Insert();

			pTableEntry->iChance = pEntry->GetAttributeIntegerBounded(CHANCE_ATTRIB, 0, -1, 100);
			if (error = IDeviceGenerator::CreateFromXML(Ctx, pEntry, &pTableEntry->pDevice))
				{
				pTableEntry->pDevice = NULL;
				return error;
				}
			}
		}

	return NOERROR;
	}
Exemple #12
0
void CDatum::RegisterMarkProc (MARKPROC fnProc)

//	RegisterMarkProc
//
//	Register a procedure that will mark data in use

	{
	g_MarkList.Insert(fnProc);
	}
void PropertyHandleToPropertyPath(const UClass* OwnerClass, const IPropertyHandle& InPropertyHandle, TArray<UProperty*>& PropertyPath)
{
	PropertyPath.Add(InPropertyHandle.GetProperty());
	TSharedPtr<IPropertyHandle> CurrentHandle = InPropertyHandle.GetParentHandle();
	while (CurrentHandle.IsValid() && CurrentHandle->GetProperty() != nullptr)
	{
		PropertyPath.Insert(CurrentHandle->GetProperty(), 0);
		CurrentHandle = CurrentHandle->GetParentHandle();
	}
}
Exemple #14
0
	// This will insert a mount point at the head of the search chain (so it can overlap an existing mount point and win)
	void InsertMountPoint(const FString& RootPath, const FString& ContentPath)
	{
		// Make sure the content path is stored as a relative path, consistent with the other paths we have
		FString RelativeContentPath = IFileManager::Get().ConvertToRelativePath( *ContentPath );

		// Make sure the path ends in a trailing path separator.  We are expecting that in the InternalFilenameToLongPackageName code.
		if( !RelativeContentPath.EndsWith( TEXT( "/" ) ) )
		{
			RelativeContentPath += TEXT( "/" );
		}

		FPathPair Pair(RootPath, RelativeContentPath);
		ContentRootToPath.Insert(Pair, 0);
		ContentPathToRoot.Insert(Pair, 0);
		MountPointRootPaths.Add( RootPath );

		// Let subscribers know that a new content path was mounted
		FPackageName::OnContentPathMounted().Broadcast( RootPath, ContentPath );
	}
Exemple #15
0
bool CDeviceClass::AccumulateEnhancements (CItemCtx &Device, CInstalledDevice *pTarget, TArray<CString> &EnhancementIDs, CItemEnhancementStack *pEnhancements)

//	AccumulateEnhancements
//
//	If this device can enhance pTarget, then we add to the list of enhancements.

	{
	int i;
	bool bEnhanced = false;

	CInstalledDevice *pDevice = Device.GetDevice();
	CSpaceObject *pSource = Device.GetSource();

	//	See if we can enhance the target device

	if (pDevice == NULL 
			|| (pDevice->IsEnabled() && !pDevice->IsDamaged()))
		{
		for (i = 0; i < m_Enhancements.GetCount(); i++)
			{
			//	If this type of enhancement has already been applied, skip it

			if (!m_Enhancements[i].sType.IsBlank()
					&& EnhancementIDs.Find(m_Enhancements[i].sType))
				continue;

			//	If we don't match the criteria, skip it.

			if (pSource 
					&& pTarget
					&& !pSource->GetItemForDevice(pTarget).MatchesCriteria(m_Enhancements[i].Criteria))
				continue;

			//	Add the enhancement

			pEnhancements->Insert(m_Enhancements[i].Enhancement);
			bEnhanced = true;

			//	Remember that we added this enhancement class

			if (!m_Enhancements[i].sType.IsBlank())
				EnhancementIDs.Insert(m_Enhancements[i].sType);
			}
		}

	//	Let sub-classes add their own

	if (OnAccumulateEnhancements(Device, pTarget, EnhancementIDs, pEnhancements))
		bEnhanced = true;

	//	Done

	return bEnhanced;
	}
Exemple #16
0
FName BuildCurveName( TSharedPtr<FSectionKeyAreaNode> KeyAreaNode )
{
	FString CurveName;
	TSharedPtr<FSequencerDisplayNode> CurrentNameNode = KeyAreaNode;
	TArray<FString> NameParts;
	while ( CurrentNameNode.IsValid() )
	{
		NameParts.Insert( CurrentNameNode->GetDisplayName().ToString(), 0);
		CurrentNameNode = CurrentNameNode->GetParent();
	}
	return FName(*FString::Join(NameParts, TEXT(" - ")));
}
void CSpaceObjectAddressResolver::InsertRef (DWORD dwObjID, CSpaceObject **ppAddr)

//	InsertRef
//
//	Insert a reference

	{
	TArray<SEntry> *pList = m_List.SetAt(dwObjID);
	SEntry *pEntry = pList->Insert();
	pEntry->pCtx = ppAddr;
	pEntry->pfnResolveProc = NULL;
	}
void CSpaceObjectAddressResolver::InsertRef (DWORD dwObjID, void *pCtx, PRESOLVEOBJIDPROC pfnResolveProc)

//	InsertRef
//
//	Insert a reference

	{
	TArray<SEntry> *pList = m_List.SetAt(dwObjID);
	SEntry *pEntry = pList->Insert();
	pEntry->pCtx = pCtx;
	pEntry->pfnResolveProc = pfnResolveProc;
	}
Exemple #19
0
bool CAeonEngine::OpenTableDefinitions (void)

//	OpenTableDefinitions
//
//	Opens and reads all tables in all volumes. Note that we have no idea what
//	could have happened since our last boot--someone could have copied files
//	all over the place. We make almost no assumptions.

	{
	CSmartLock Lock(m_cs);

	int i, j;
	CString sError;

	//	Loop over all volumes and end up with a list of tables and volumes

	TSortMap<CString, TArray<CString>> Tables;
	for (i = 0; i < m_LocalVolumes.GetCount(); i++)
		{
		CString sVolume = m_LocalVolumes.GetVolume(i);

		TArray<CString> Dirs;
		fileGetFileList(fileAppend(m_LocalVolumes.GetPath(i), FILESPEC_TABLE_DIR_FILTER), FFL_FLAG_DIRECTORIES_ONLY | FFL_FLAG_RELATIVE_FILESPEC, &Dirs);

		for (j = 0; j < Dirs.GetCount(); j++)
			{
			TArray<CString> *pList = Tables.SetAt(Dirs[j]);
			pList->Insert(sVolume);
			}
		}

	//	Open all tables

	for (i = 0; i < Tables.GetCount(); i++)
		{
		CString sName = Tables.GetKey(i);

		CAeonTable *pTable = new CAeonTable;
		if (!pTable->Open(GetProcessCtx(), &m_LocalVolumes, sName, Tables[i], &sError))
			{
			Log(MSG_LOG_ERROR, strPattern("Unable to load %s: %s", sName, sError));
			delete pTable;
			continue;
			}

		m_Tables.Insert(sName, pTable);
		}

	//	Done

	return true;
	}
void CPlayerGameStats::OnKeyEvent (EEventTypes iType, CSpaceObject *pObj, DWORD dwCauseUNID)

//	OnKeyEvent
//
//	Adds a key event involving an object

	{
	ASSERT(pObj);

	CSystem *pSystem = pObj->GetSystem();
	if (pSystem == NULL)
		return;

	//	Get the NodeID where the event happened

	CTopologyNode *pNode = pSystem->GetTopology();
	if (pNode == NULL)
		return;

	const CString &sNodeID = pNode->GetID();

	//	Get the object's type

	CDesignType *pType = pObj->GetType();
	if (pType == NULL)
		return;

	//	Get the object's name

	DWORD dwNameFlags;
	CString sName = pObj->GetName(&dwNameFlags);
	
	//	If the object name is the same as the type name then we don't bother
	//	storing it in the event (to save memory)

	if (strEquals(sName, pType->GetTypeName()))
		{
		sName = NULL_STR;
		dwNameFlags = 0;
		}

	//	Look for the list of events for this NodeID

	TArray<SKeyEventStats> *pEventList = m_KeyEventStats.Set(sNodeID);
	SKeyEventStats *pStats = pEventList->Insert();
	pStats->iType = iType;
	pStats->dwTime = g_pUniverse->GetTicks();
	pStats->dwObjUNID = pObj->GetType()->GetUNID();
	pStats->sObjName = sName;
	pStats->dwObjNameFlags = dwNameFlags;
	pStats->dwCauseUNID = dwCauseUNID;
	}
Exemple #21
0
CMultiverseNewsEntry *CMultiverseModel::GetNextNewsEntry (void)

//	GetNextNewsEntry
//
//	Returns the next news entry to display.
//
//	NOTE: We return a copy which the callers are responsible for freeing.
	
	{
	CSmartLock Lock(m_cs);
	int i;

	//	First make a list of all available news entries

	TArray<CMultiverseNewsEntry *> Available;
	for (i = 0; i < m_News.GetCount(); i++)
		{
		CMultiverseNewsEntry *pEntry = m_News.GetEntry(i);

		//	If we've already shown this entry, skip it.

		if (pEntry->IsShown())
			continue;

		//	If this entry does not match the collection criteria, then skip it.

		if (m_Collection.HasAnyUNID(pEntry->GetExcludedUNIDs()))
			continue;

		if (!m_Collection.HasAllUNIDs(pEntry->GetRequiredUNIDs()))
			continue;

		Available.Insert(pEntry);
		}

	//	If none available, nothing

	if (Available.GetCount() == 0)
		return NULL;

	//	Pick a random entry

	CMultiverseNewsEntry *pEntry = Available[mathRandom(0, Available.GetCount() - 1)];

	//	Mark the entry as having been shown

	m_News.ShowNews(pEntry);

	//	return this entry

	return new CMultiverseNewsEntry(*pEntry);
	}
void FLevelViewportCommands::HandleNewStat(const FName& InStatName, const FName& InStatCategory, const FText& InStatDescription)
{
	FString CommandName = InStatName.ToString();
	if (CommandName.RemoveFromStart(TEXT("STATGROUP_")) || CommandName.RemoveFromStart(TEXT("STAT_")))
	{
		// Trim the front to get our category name
		FString GroupCategory = InStatCategory.ToString();
		if (!GroupCategory.RemoveFromStart(TEXT("STATCAT_")))
		{
			GroupCategory.Empty();
		}

		// If we already have an entry (which can happen if a category has changed [when loading older saved stat data]) or we don't have a valid category then skip adding
		if (!FInputBindingManager::Get().FindCommandInContext(this->GetContextName(), InStatName).IsValid() && !GroupCategory.IsEmpty())
		{
			// Find or Add the category
			TArray< FShowMenuCommand >* ShowStatCommands = ShowStatCatCommands.Find(GroupCategory);
			if (!ShowStatCommands)
			{
				// New category means we'll need to resort
				ShowStatCatCommands.Add(GroupCategory);
				ShowStatCatCommands.KeySort(TLess<FString>());
				ShowStatCommands = ShowStatCatCommands.Find(GroupCategory);
			}

			const int32 NewIndex = FindStatIndex(ShowStatCommands, CommandName);
			if (NewIndex != INDEX_NONE)
			{
				const FText DisplayName = FText::FromString(CommandName);

				FText DescriptionName = InStatDescription;
				FFormatNamedArguments Args;
				Args.Add(TEXT("StatName"), DisplayName);
				if (DescriptionName.IsEmpty())
				{
					DescriptionName = FText::Format(NSLOCTEXT("UICommands", "StatShowCommandName", "Show {StatName} Stat"), Args);
				}

				TSharedPtr<FUICommandInfo> StatCommand
					= FUICommandInfoDecl(this->AsShared(), InStatName, FText::GetEmpty(), DescriptionName)
					.UserInterfaceType(EUserInterfaceActionType::ToggleButton);

				FLevelViewportCommands::FShowMenuCommand ShowStatCommand(StatCommand, DisplayName);
				ShowStatCommands->Insert(ShowStatCommand, NewIndex);
				NewStatCommandDelegate.Broadcast(ShowStatCommand.ShowMenuItem, ShowStatCommand.LabelOverride.ToString());
			}
		}
	}
}
/**
* This function parses the Json response after uploading the save file to obtain the 
* URL of the save file.
*
* @param JsonString              Json string to parse
* @param PlayerControllerId      Player controller ID of the player who is saving the file
*
*/
void CloudyWebAPIImpl::ReadAndStoreSaveFileURL(FString JsonString, int32 PlayerControllerId)
{
    JsonString = JsonString.Replace(TEXT("["), TEXT(""));
    JsonString = JsonString.Replace(TEXT("]"), TEXT(""));
    
    TSharedPtr<FJsonObject> JsonObject = MakeShareable(new FJsonObject());
    TSharedRef<TJsonReader<TCHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(JsonString);
    FJsonSerializer::Deserialize(JsonReader, JsonObject);

    // More player controllers than the TArray size
    if (PlayerControllerId >= SaveFileUrls.Num())
    {
        SaveFileUrls.AddUninitialized(PlayerControllerId - InitialArraySize + 1);
    }

    SaveFileUrls.Insert(JsonObject->GetStringField("saved_file"), PlayerControllerId);
}
void CEnergyFieldList::GetList (TArray<CEnergyField *> &List)

//	GetList
//
//	Returns all the fields in an array

	{
	List.DeleteAll();

	CEnergyField *pField = m_pFirst;
	while (pField)
		{
		if (!pField->IsDestroyed())
			List.Insert(pField);

		pField = pField->GetNext();
		}
	}
void FieldVariableDescriptor::MergeArrays(TArray<FieldVariableDescriptor> & dest, const TArray<FieldVariableDescriptor> & source)
{
	// in case of a performance loss this function should be rewritten with dictionaries (maps) and hash codes
	for(int j = 1; j <= source.Length(); j++)
	{
		const FieldVariableDescriptor & fvd = source(j);
		int i;
		int cmp = 1;
		for(i = 1; i <= dest.Length(); i++)
		{
			cmp = fvd.Compare(dest(i));
			if(cmp != 1)
				break;	// found either the same entry or the point where this entry is to be inserted
		}
		if(cmp != 0)
			dest.Insert(i, fvd);
	}
}
bool FOnlineUserCloudOculus::ReadUserFile(const FUniqueNetId& UserId, const FString& FileName)
{
	auto LoggedInPlayerId = OculusSubsystem.GetIdentityInterface()->GetUniquePlayerId(0);
	if (!LoggedInPlayerId.IsValid() || UserId != *LoggedInPlayerId)
	{
		UE_LOG_ONLINE(Warning, TEXT("Can only read data for logged in player"));
		return false;
	}

	FString BucketName;
	FString Key;
	if (!(FileName.Split(SEPARATOR, &BucketName, &Key)))
	{
		BucketName = DefaultBucket;
		Key = FileName;
	}

	OculusSubsystem.AddRequestDelegate(
		ovr_CloudStorage_Load(TCHAR_TO_UTF8(*BucketName), TCHAR_TO_UTF8(*Key)),
		FOculusMessageOnCompleteDelegate::CreateLambda([this, BucketName, Key, LoggedInPlayerId, FileName](ovrMessageHandle Message, bool bIsError)
	{
		ovrCloudStorageDataHandle response = ovr_Message_GetCloudStorageData(Message);
		check(BucketName == UTF8_TO_TCHAR(ovr_CloudStorageData_GetBucket(response)));
		check(Key == UTF8_TO_TCHAR(ovr_CloudStorageData_GetKey(response)));

		if (bIsError)
		{
			UE_LOG_ONLINE(Warning, TEXT("Failed to Load: %s%s%s"), *BucketName, *SEPARATOR, *Key);
		}
		else
		{
			int64 BlobSize = ovr_CloudStorageData_GetDataSize(response);
			const void* RawBlob = ovr_CloudStorageData_GetData(response);

			TArray<uint8> Blob;
			Blob.Insert(static_cast<const uint8 *>(RawBlob), BlobSize, 0);

			ReadCache.Add(FileName, MoveTemp(Blob));
		}
		TriggerOnReadUserFileCompleteDelegates(!bIsError, *LoggedInPlayerId, FileName);
	}));

	return true;
}
Exemple #27
0
CDatum CAeonView::ComputeColumns (CHexeProcess &Process, CDatum dRowData)

//	ComputeColumns
//
//	Returns a new row struct containing any computed columns.

	{
	if (m_ComputedColumns.IsNil() || !m_ComputedColumns.CanInvoke())
		return dRowData;

	//	Compute columns. We should get back a struct of all new columns.

	TArray<CDatum> Args;
	Args.Insert(dRowData);

	CDatum dResult;
	CHexeProcess::ERunCodes iRun = Process.Run(m_ComputedColumns, Args, &dResult);

	switch (iRun)
		{
		case CHexeProcess::runOK:
			{
			//	dResult is a struct containing zero or more columns

			CDatum dNewRowData(new CComplexStruct(dRowData));
			dNewRowData.Append(dResult);
			return dNewRowData;
			}

		case CHexeProcess::runError:
			{
			CDatum dNewRowData(new CComplexStruct(dRowData));
			dNewRowData.SetElement(FIELD_ERROR, strPattern("ERROR: %s", dResult.AsString()));
			return dNewRowData;
			}

		default:
			{
			CDatum dNewRowData(new CComplexStruct(dRowData));
			dNewRowData.SetElement(FIELD_ERROR, ERR_COMPUTED_COLUMN);
			return dNewRowData;
			}
		}
	}
void SortTriangles_Random( int32 NumTriangles, const FSoftSkinVertex* Vertices, uint32* Indices )
{
	TArray<int32> Triangles;
	for( int32 i=0;i<NumTriangles;i++ )
	{
		Triangles.Insert(i, i > 0 ? FMath::Rand() % i : 0);
	}

	// export new draw order
	TArray<uint32> NewIndices;
	NewIndices.Empty(NumTriangles*3);
	for( int TriIndex=0;TriIndex<NumTriangles;TriIndex++ )
	{
		int32 tri = Triangles[TriIndex];
		NewIndices.Add(Indices[tri*3+0]);
		NewIndices.Add(Indices[tri*3+1]);
		NewIndices.Add(Indices[tri*3+2]);	
	}

	FMemory::Memcpy( Indices, NewIndices.GetData(), NewIndices.Num() * sizeof(uint32) );
}
void CTranscendenceWnd::DestroyIntroShips (void)

//	DestroyIntroShips
//
//	Destroys all ships of the same class as the POV

	{
	int i;

	CShip *pShip = g_pUniverse->GetPOV()->AsShip();
	if (pShip == NULL)
		return;

	//	Destroy all ships of the current class

	CSystem *pSystem = pShip->GetSystem();
	CShipClass *pClassToDestroy = pShip->GetClass();
	TArray<CSpaceObject *> ShipsToDestroy;
	CSpaceObject *pOtherShip = NULL;
	for (i = 0; i < pSystem->GetObjectCount(); i++)
		{
		CSpaceObject *pObj = pSystem->GetObject(i);
		CShip *pShip;
		if (pObj 
				&& !pObj->IsInactive()
				&& !pObj->IsVirtual()
				&& (pShip = pObj->AsShip()))
			{
			if (pShip->GetClass() == pClassToDestroy)
				ShipsToDestroy.Insert(pObj);
			else if (pOtherShip == NULL)
				pOtherShip = pObj;
			}
		}

	//	Destroy ships

	for (i = 0; i < ShipsToDestroy.GetCount(); i++)
		ShipsToDestroy[i]->Destroy(removedFromSystem, CDamageSource());
	}
Exemple #30
0
ICCItem *CCodeChain::CreateVectorGivenContent(TArray<int> vShape, CCLinkedList *pContentList)

//	CreateVectorGivenContent (new)
//
//	Creates a vector with given shape and content

{
	int i;
	CCVector *pVector;
	ICCItem *pItem;

	pItem = m_VectorPool.CreateItem(this);
	if (pItem->IsError())
		return pItem;
	pItem->Reset();

	pVector = dynamic_cast<CCVector *>(pItem);
	pVector->SetContext(this);

	pVector->SetShape(this, vShape);

	pItem = pContentList->GetFlattened(this, NULL);
	if (pItem->IsError())
	{ 
		pVector->Discard(this);
		return pItem;
	};
	CCLinkedList *pFlattenedContentList = dynamic_cast<CCLinkedList *>(pItem);

	TArray<double> vDataArray;
	for (i = 0; i < pFlattenedContentList->GetCount(); i++)
	{
		vDataArray.Insert(pFlattenedContentList->GetElement(i)->GetDoubleValue());
	};
	pVector->SetArrayData(this, vDataArray);

	//	Done
	pFlattenedContentList->Discard(this);
	return pVector->Reference();
}