iGpuProgram* cGpuProgramManager::CreateProgram(const tString& asName,const tString& asEntry,
        eGpuProgramType aType)
{
    tString sPath;
    iGpuProgram* pProgram;
    pProgram = static_cast<iGpuProgram*>(FindLoadedResource(asName,sPath));

    BeginLoad(asName);

    if(pProgram==NULL && sPath!="")
        {
            pProgram = mpLowLevelGraphics->CreateGpuProgram(asName, aType);

            if(pProgram->CreateFromFile(sPath,asEntry)==false)
                {
                    Error("Couldn't create program '%s'\n",asName.c_str());
                    hplDelete(pProgram);
                    EndLoad();
                    return NULL;
                }

            AddResource(pProgram);
        }

    if(pProgram)pProgram->IncUserCount();
    else Error("Couldn't load program '%s'\n",asName.c_str());

    EndLoad();
    return pProgram;
}
	iResourceBase* cImageEntityManager::Create(const tString& asName)
	{
		tString sPath;
		cImageEntityData* pIEData;
		tString asNewName;

		BeginLoad(asName);

		asNewName = cString::SetFileExt(asName,"hed");

		pIEData = static_cast<cImageEntityData*>(FindLoadedResource(asNewName,sPath));

		if(pIEData==NULL && sPath!="")
		{
			pIEData = hplNew( cImageEntityData, (asNewName,mpGraphics,mpResources) );

			if(pIEData->CreateFromFile(sPath,mvImageHandle)==false){
				EndLoad();
				return NULL;
			}

			if(pIEData)AddResource(pIEData);
		}
		else
		{
		}

		if(pIEData)pIEData->IncUserCount();
		else Error("Couldn't load image entity data '%s'\n",asNewName.c_str());
		
		EndLoad();
		return pIEData;
	}
iVideoStream* cVideoManager::CreateVideo(const tString& asName)
{
    BeginLoad(asName);

    tString sPath = mpFileSearcher->GetFilePath(asName);
    if(sPath == "")
        {
            EndLoad();
            Error("Video file '%s' could not be found!\n",asName.c_str());
            return NULL;
        }

    iVideoStreamLoader *pLoader = GetLoader(asName);
    if(pLoader==NULL)
        {
            Error("Could not find a loader for '%s'\n",asName.c_str());
            return NULL;
        }

    iVideoStream *pVideo = pLoader->Create(asName);

    if(pVideo->LoadFromFile(sPath)==false)
        {
            EndLoad();
            hplDelete(pVideo);
            Error("Could not load video '%s'\n",asName.c_str());
            return NULL;
        }

    AddResource(pVideo);

    EndLoad();
    return pVideo;
}
	cSoundEntityData* cSoundEntityManager::CreateSoundEntity(const tString& asName)
	{
		tString sPath;
		cSoundEntityData* pSoundEntity;
		tString asNewName;
		
		BeginLoad(asName);

		asNewName = cString::SetFileExt(asName,"snt");
		
		pSoundEntity = static_cast<cSoundEntityData*>(this->FindLoadedResource(asNewName,sPath));

		if(pSoundEntity==NULL && sPath!="")
		{
			pSoundEntity = hplNew( cSoundEntityData, (asNewName) );

			if(pSoundEntity->CreateFromFile(sPath))
			{
				AddResource(pSoundEntity);
			}
			else
			{
				hplDelete(pSoundEntity);
				pSoundEntity =NULL;
			}
		}
		
		if(pSoundEntity)pSoundEntity->IncUserCount();
		else Error("Couldn't create SoundEntity '%s'\n",asNewName.c_str());
		
		EndLoad();
		return pSoundEntity;
	}
iResourceBase* cTileSetManager::Create(const tString& asName)
{
    tString sPath;
    cTileSet* pTileSet;
    tString asNewName;

    BeginLoad(asName);

    asNewName = cString::SetFileExt(asName,"tsd");

    pTileSet = static_cast<cTileSet*>(this->FindLoadedResource(asNewName,sPath));

    if(pTileSet==NULL && sPath!="")
        {
            pTileSet = hplNew( cTileSet, (asNewName,mpGraphics,mpResources) );

            if(pTileSet->CreateFromFile(sPath)==false)
                {
                    EndLoad();
                    return NULL;
                }

            AddResource(pTileSet);
        }

    if(pTileSet)pTileSet->IncUserCount();
    else Error("Couldn't load tileset '%s'\n",asNewName.c_str());

    EndLoad();
    return pTileSet;
}
Exemple #6
0
bool Resource::Load(Stream& source)
{
    bool success = BeginLoad(source);
    if (success)
        success &= EndLoad();

    return success;
}
Exemple #7
0
	iFontData* cFontManager::CreateFontData(const tString& asName, int alSize,unsigned short alFirstChar,
											unsigned short alLastChar)
	{
		tString sPath;
		iFontData* pFont;
		tString asNewName = cString::ToLowerCase(asName);

		BeginLoad(asName);
		
		//asNewName = cString::SetFileExt(asName,"ttf");

		pFont = static_cast<iFontData*>(this->FindLoadedResource(asNewName,sPath));

		if(pFont==NULL && sPath!="")
		{
			pFont = mpGraphics->GetLowLevel()->CreateFontData(asNewName);
			pFont->SetUp(mpGraphics->GetDrawer(),mpLowLevelResources,mpGui);
			
			tString sExt = cString::ToLowerCase(cString::GetFileExt(asName));

			//True Type Font
			if(sExt == "ttf")
			{
				if(pFont->CreateFromFontFile(sPath,alSize,alFirstChar,alLastChar)==false){
					hplDelete(pFont);
					EndLoad();
					return NULL;
				}
			}
			//Angel code font type
			else if(sExt == "fnt")
			{
				if(pFont->CreateFromBitmapFile(sPath)==false){
					hplDelete(pFont);
					EndLoad();
					return NULL;
				}
			}
			else
			{
				Error("Font '%s' has an unkown extension!\n",asName.c_str());
				hplDelete(pFont);
				EndLoad();
				return NULL;
			}
			
			//mpResources->GetImageManager()->FlushAll();
			AddResource(pFont);
		}

		if(pFont)pFont->IncUserCount();
		else Error("Couldn't create font '%s'\n",asNewName.c_str());
		
		EndLoad();
		return pFont;
	}
Exemple #8
0
	cMesh* cMeshManager::CreateMesh(const tString& asName)
	{
		tString sPath;
		cMesh* pMesh;
		tString asNewName;

		BeginLoad(asName);

		asNewName = asName;//cString::SetFileExt(asName,"mesh");
		
		//If the file is missing an extension, search for an existing file.
		if(cString::GetFileExt(asNewName) == "")
		{
			bool bFound = false;
			tStringVec *pTypes = mpResources->GetMeshLoaderHandler()->GetSupportedTypes();
			for(size_t i=0; i< pTypes->size(); i++)
			{
				asNewName = cString::SetFileExt(asNewName, (*pTypes)[i]);
				tString sPath = mpResources->GetFileSearcher()->GetFilePath(asNewName);
				if(sPath != "")
				{
					bFound = true;
					break;
				}
			}

			if(bFound == false){
				Error("Couldn't create mesh '%s'\n",asName.c_str());
				EndLoad();
				return NULL;
			}
		}

		pMesh = static_cast<cMesh*>(this->FindLoadedResource(asNewName,sPath));

		if(pMesh==NULL && sPath!="")
		{
			pMesh = mpResources->GetMeshLoaderHandler()->LoadMesh(sPath,0);
			if(pMesh == NULL)
			{
				EndLoad();
				return NULL;
			}

			AddResource(pMesh);
		}

		if(pMesh)pMesh->IncUserCount();
		else Error("Couldn't create mesh '%s'\n",asNewName.c_str());
		
		EndLoad();
		return pMesh;
	}
Exemple #9
0
	iResourceBase* cImageManager::CreateInFrame(const tString& asName, int alFrameHandle)
	{
		cResourceImage *pImage = NULL;
		tString sPath;

		BeginLoad(asName);

		pImage = FindImage(asName, sPath);
		if(!pImage)
		{
			if(sPath != "")
			{
				iBitmap2D *pBmp;
				pBmp = mpLowLevelResources->LoadBitmap2D(sPath);
				if(pBmp==NULL){
					Error("Imagemanager Couldn't load bitmap '%s'\n", sPath.c_str());
					EndLoad();
					return NULL;
				}
				
				pImage = AddToFrame(pBmp, alFrameHandle);

				hplDelete(pBmp);

				if(pImage==NULL){
					Error("Imagemanager couldn't create image '%s'\n", asName.c_str());
				}
				
				if(pImage) AddResource(pImage);
 			}
		}
		else
		{
			//Log("Found '%s' in stock!\n",asName.c_str());
		}

		if(pImage)pImage->IncUserCount();
		else Error("Couldn't load image '%s'\n",asName.c_str());

		//Log("Loaded image %s, it has %d users!\n", pImage->GetName().c_str(),pImage->GetUserCount());
		//Log(" frame has %d pics\n", pImage->GetFrameTexture()->GetPicCount());

		EndLoad();
        return pImage;
	}
Exemple #10
0
	iFontData *cFontManager::CreateFontData(const tString &a_sName, int a_lSize, unsigned short a_lFirstChar,
								unsigned short a_lLastChar)
	{
		tString sPath;
		iFontData *pFont;
		tString a_sNewName = cString::ToLowerCase(a_sName);

		BeginLoad(a_sName);

		pFont = static_cast<iFontData*>(this->FindLoadedResource(a_sNewName, sPath));

		if (pFont==NULL && sPath!="")
		{
			pFont = m_pGraphics->GetLowLevel()->CreateFontData(a_sNewName);
			pFont->SetUp(m_pGraphics->GetDrawer(), m_pLowLevelResources, m_pGui);

			tString sExt = cString::ToLowerCase(cString::GetFileExt(a_sName));

			if (sExt == "ttf")
			{
				if (pFont->CreateFromFontFile(sPath, a_lSize, a_lFirstChar, a_lLastChar)==false)
				{
					efeDelete(pFont);
					EndLoad();
					return NULL;
				}
			}
			else
			{
				Error("Font '%s' has an uknown extension!\n", a_sName.c_str());
				efeDelete(pFont);
				EndLoad();
				return NULL;
			}
			AddResource(pFont);
		}

		if (pFont)pFont->IncUserCount();
		else Error("Couldn't create font '%s'\n", a_sName.c_str());

		EndLoad();
		return pFont;
	}
Exemple #11
0
	iSoundData *cSoundManager::CreateSoundData(const tString &a_sName, bool a_bStream, bool a_bLoopStream)
	{
		tString sPath;
		iSoundData *pSound = NULL;

		BeginLoad(a_sName);

		pSound = FindData(a_sName, sPath);

		if (pSound == NULL && sPath != "")
		{
			pSound = m_pSound->GetLowLevel()->LoadSoundData(cString::GetFilePath(a_sName),sPath,"", a_bStream,a_bLoopStream);

			if (pSound)
			{
				AddResource(pSound);
				pSound->SetSoundManager(m_pResources->GetSoundManager());
			}
		}

		EndLoad();
		return pSound;
	}
void FPackageDependencyInfo::RecursiveDeterminePackageDependentTimeStamp(const TCHAR* InPackageName, FDateTime& OutNewestTime, bool& bOutHadCircularReferences)
{
    // Find the package info...
    FPackageDependencyTrackingInfo** pPkgInfo = PackageInformation.Find(InPackageName);
    if ((pPkgInfo != NULL) && (*pPkgInfo != NULL))
    {
        FPackageDependencyTrackingInfo* PkgInfo = *pPkgInfo;
        if (PkgInfo->bBeingProcessed == true)
        {
            // Circular reference??
            bOutHadCircularReferences = true;
            return;
        }

        checkf((PkgInfo->DependentTimeStamp == FDateTime::MinValue()), TEXT("RecursiveDeterminePackageDependentTimeStamp: Package already processed: %s"), InPackageName);

        // We have the package info, so process the actual package.
        BeginLoad();
        ULinkerLoad* Linker = GetPackageLinker(NULL, InPackageName, LOAD_NoVerify, NULL, NULL);
        EndLoad();
        if (Linker != NULL)
        {
            PkgInfo->bBeingProcessed = true;

            // Start off with setting the dependent time to the package itself
            PkgInfo->DependentTimeStamp = PkgInfo->TimeStamp;

            // Map? Code (ie blueprint)?
            PkgInfo->bContainsMap = Linker->ContainsMap();
            PkgInfo->bContainsBlueprints = Linker->ContainsCode();

            FName CheckMaterial = FName(TEXT("Material"));
            FName CheckMIC = FName(TEXT("MaterialInstanceConstant"));
            FName CheckMID = FName(TEXT("MaterialInstanceDynamic"));
            FName CheckLMIC = FName(TEXT("LandscapeMaterialInstanceConstant"));
            FName CheckWorld = FName(TEXT("World"));
            FName CheckBlueprint = FName(TEXT("Blueprint"));
            FName CheckAnimBlueprint = FName(TEXT("AnimBlueprint"));


            // Check the export map for material interfaces
            for (int32 ExpIdx = 0; ExpIdx < Linker->ExportMap.Num(); ExpIdx++)
            {
                FObjectExport& ObjExp = Linker->ExportMap[ExpIdx];
                FName ExpClassName = Linker->GetExportClassName(ExpIdx);
                if ((ExpClassName == CheckMaterial) ||
                        (ExpClassName == CheckMIC) ||
                        (ExpClassName == CheckMID) ||
                        (ExpClassName == CheckLMIC))
                {
                    PkgInfo->bContainsShaders = true;
                    if (PkgInfo->DependentTimeStamp < ShaderSourceTimeStamp)
                    {
                        PkgInfo->DependentTimeStamp = ShaderSourceTimeStamp;
                    }
                    PkgInfo->DependentPackages.Add(ShaderSourcePkgName, ShaderSourcePkgInfo);
                    AllPackages.Add(ShaderSourcePkgInfo);
                }
                else if (ExpClassName == CheckWorld)
                {
                    PkgInfo->bContainsMap = true;
                }
                else if ((ExpClassName == CheckBlueprint) ||
                         (ExpClassName == CheckAnimBlueprint))
                {
                    PkgInfo->bContainsBlueprints = true;
                    if (PkgInfo->DependentTimeStamp < ScriptSourceTimeStamp)
                    {
                        PkgInfo->DependentTimeStamp = ScriptSourceTimeStamp;
                    }
                    PkgInfo->DependentPackages.Add(ScriptSourcePkgName, ScriptSourcePkgInfo);
                    AllPackages.Add(ScriptSourcePkgInfo);
                }
            }

            // Check the dependencies
            //@todo. Make this a function of the linker? Almost the exact same code is used in PkgInfo commandlet...
            FName LinkerName = Linker->LinkerRoot->GetFName();
            TArray<FName> DependentPackages;
            for (int32 ImpIdx = 0; ImpIdx < Linker->ImportMap.Num(); ImpIdx++)
            {
                FObjectImport& ObjImp = Linker->ImportMap[ImpIdx];

                FName PackageName = NAME_None;
                FName OuterName = NAME_None;
                if (!ObjImp.OuterIndex.IsNull())
                {
                    // Find the package which contains this import.  import.SourceLinker is cleared in EndLoad, so we'll need to do this manually now.
                    FPackageIndex OutermostLinkerIndex = ObjImp.OuterIndex;
                    for (FPackageIndex LinkerIndex = ObjImp.OuterIndex; !LinkerIndex.IsNull();)
                    {
                        OutermostLinkerIndex = LinkerIndex;
                        LinkerIndex = Linker->ImpExp(LinkerIndex).OuterIndex;
                    }
                    PackageName = Linker->ImpExp(OutermostLinkerIndex).ObjectName;
                }

                if (PackageName == NAME_None && ObjImp.ClassName == NAME_Package)
                {
                    PackageName = ObjImp.ObjectName;
                }

                if ((PackageName != NAME_None) && (PackageName != LinkerName))
                {
                    DependentPackages.AddUnique(PackageName);
                }

                if ((ObjImp.ClassPackage != NAME_None) && (ObjImp.ClassPackage != LinkerName))
                {
                    DependentPackages.AddUnique(ObjImp.ClassPackage);
                }
            }

            for (int32 DependentIdx = 0; DependentIdx < DependentPackages.Num(); DependentIdx++)
            {
                FString PkgName = DependentPackages[DependentIdx].ToString();
                FText Reason;
                if (!FPackageName::IsValidLongPackageName(PkgName, true, &Reason))
                {
                    //UE_LOG(LogPackageDependencyInfo, Display, TEXT("%s --> %s"), *PkgName, *Reason.ToString());
                    continue;
                }
                FString LongName = FPackageName::LongPackageNameToFilename(PkgName);
                //UE_LOG(LogPackageDependencyInfo, Display, TEXT("%s --> %s"), *PkgName, *LongName);
                // Is it already in the list
                FPackageDependencyTrackingInfo** pDepPkgInfo = PackageInformation.Find(LongName);
                if ((pDepPkgInfo == NULL) || (*pDepPkgInfo == NULL))
                {
                    continue;
                }

                FPackageDependencyTrackingInfo* DepPkgInfo = *pDepPkgInfo;
                if (DepPkgInfo->bBeingProcessed == true)
                {
                    bOutHadCircularReferences = true;
                    // Circular reference
                    // For now, store it off and we will resolve when completed
                    PkgInfo->DependentPackages.Add(LongName, DepPkgInfo);
                    PkgInfo->bHasCircularReferences = true;
                    AllPackages.Add(PkgInfo);
                    continue;
                }

                if (DepPkgInfo->DependentTimeStamp == FDateTime::MinValue())
                {
                    FDateTime TempTime;
                    RecursiveDeterminePackageDependentTimeStamp(*LongName, TempTime, bOutHadCircularReferences);
                }

                PkgInfo->DependentPackages.Add(LongName, DepPkgInfo);
                AllPackages.Add(DepPkgInfo);

                if (DepPkgInfo->DependentTimeStamp != FDateTime::MinValue())
                {
                    if (PkgInfo->DependentTimeStamp < DepPkgInfo->DependentTimeStamp)
                    {
                        PkgInfo->DependentTimeStamp = DepPkgInfo->DependentTimeStamp;
                    }
                }
            }

            PkgInfo->bBeingProcessed = false;
            OutNewestTime = PkgInfo->DependentTimeStamp;
        }
        else
        {
            UE_LOG(LogPackageDependencyInfo, Display, TEXT("RecursiveDeterminePackageDependentTimeStamp: Failed to find linker for %s"), InPackageName);
        }
    }
    else
    {
        UE_LOG(LogPackageDependencyInfo, Display, TEXT("RecursiveDeterminePackageDependentTimeStamp: Failed to find package info for %s"), InPackageName);
    }
}