Beispiel #1
0
 void DiEditorManager::SetCurrentFileName(const DiString& name)
 {
     mFxFileName = name;
     
     DiString title = "Hon Fxer";
     if(!name.empty())
         title.Format("Hon Fxer - %s",name.ExtractFileName().c_str());
     
     DiBase::Driver->GetMainRenderWindow()->GetWindow()->SetTitle(title.c_str());
 }
Beispiel #2
0
void DiFileLogger::OutputLog(const char* szMessage, const char* levelInfo,
                           const char* fileName, long line)
{
    DiString datetime = DiTimer::GetCurrentTime();

    DiString log;
    log.Format( "[%s] %s%s", datetime.c_str(), levelInfo, szMessage);
    mFile << log.c_str();

    if (fileName)
    {
        DiString file = fileName;
        file = file.ExtractFileName();
        mFile << ", " << file.c_str() << "(" << line << ")";
    }

    mFile << std::endl;
}
Beispiel #3
0
 void DiEditorManager::OpenFx(const DiString& fxFileName)
 {
     DiString base = fxFileName.ExtractFileName();
     if(!DiAssetManager::GetInstance().HasArchive(base))
     {
         DiString message;
         message.Format("Cannot find the effect file(%s) in our media folders!", base.c_str());
         MyGUI::Message::createMessageBox("Message", "Error", message.c_str(),
                                          MyGUI::MessageBoxStyle::Ok|MyGUI::MessageBoxStyle::IconError);
         
         return;
     }
     
     DiFxTokensParser parser;
     
     auto stream = DiAssetManager::GetInstance().OpenArchive(base);
     shared_ptr<DiXMLFile> xmlfile(DI_NEW DiXMLFile());
     xmlfile->Load(stream->GetAsString());
     DiXMLElement root = xmlfile->GetRoot();
     
     if (!root.CheckName("Effects"))
     {
         DI_WARNING("Bad effect file: %s", base.c_str());
         return;
     }
     
     auto child = root.GetChild();
     while (child)
     {
         if (child.CheckName("ParticleSystem"))
         {
             auto ps = parser.ReadSystem(child);
             LoadParticleSystem(ps);
         }
         else if(child.CheckName("ReferenceModel"))
         {
             LoadRefModel(child);
         }
         
         child = child.GetNext();
     }
     
     SetCurrentFileName(fxFileName);
 }
Beispiel #4
0
void DiFileLogger::OutputLog(const char* szMessage, const char* levelInfo,
                           const char* fileName, long line)
{
    DiString datetime = DiTimer::GetCurrentDateTime();

    DiString logPre;

    DiString file = fileName;
    file = file.ExtractFileName();
    DiString log;
    log.Format(
        "%s %s(%d)\r\n"
        "[%s] : %s\r\n\r\n", 
        datetime.c_str(),
        file.c_str(), line,
        levelInfo, szMessage);

    log = logPre + log;

    mFile << log.c_str();
}
Beispiel #5
0
void parseArgs(int numArgs, char **args)
{
	srcName = args[1];
	srcName.ToLower();
	if(srcName.CheckFileExtension("skeleton") ||
		srcName.CheckFileExtension("skeleton"))
	{
		isAnimation = true;
	}

	if(numArgs == 2)
	{
		destName = srcName.ExtractDirName();
		DiString temp = srcName.ExtractFileName().ExtractBaseName();
		destName.append(temp);
		destName.append(!isAnimation?".model":".motion");
	}
	else if(numArgs == 3)
	{
		destName = args[2];
	}
}
void TextureBrowseCell::update(const MyGUI::IBDrawItemInfo& _info, std::pair<std::string,std::string> _dataPair)
{
    std::string _data = _dataPair.first;
    std::string _forceTexture = _dataPair.second;
    if (_info.update)
    {
        DiString filename = _data.c_str();
        mTextureName->setCaption(filename.ExtractFileName().c_str());
        const MyGUI::IntSize textureSize = MyGUI::texture_utility::getTextureSize(_forceTexture.empty() ? _data : _forceTexture);

        if (textureSize.width != 0 && textureSize.height != 0)
        {
            mBack->setVisible(true);
            mImage->setImageTexture(_forceTexture.empty() ? _data : _forceTexture);

            const MyGUI::IntSize& targetSize = mParentBack->getSize();

            float k1 = (float)targetSize.width / textureSize.width;
            float k2 = (float)targetSize.height / textureSize.height;
            float k = std::min( k1, k2);
            MyGUI::IntSize size = MyGUI::IntSize((int)(k *  (float)textureSize.width), (int)(k *  (float)textureSize.height));

            MyGUI::IntSize parentSize = mBack->getParent()->getSize();
            mBack->setCoord((parentSize.width - size.width) / 2, (parentSize.height - size.height) / 2, size.width, size.height);
        }
        else
        {
            mBack->setVisible(false);
        }
    }

    if (_info.select)
        mSelector->setAlpha(1);
    else
        mSelector->setAlpha(0);
}
Beispiel #7
0
    DiTexturePtr DiK2Configs::GetTexture(const DiString& relPath)
    {
        DiString baseName = relPath.ExtractFileName();
        if (baseName.empty() || baseName[0] == '$')
            return DiK2Configs::GetSpecialTexture(baseName);

        DiTexturePtr ret = DiAssetManager::GetInstance().FindAsset<DiTexture>(relPath);
        if (ret)
            return ret;
        
        bool needprefix = !TEXTURE_PACK_PREFIX_FOLDER.empty();
        if(DiString::StartsWith(relPath, TEXTURE_PACK_PREFIX_FOLDER))
        {
            needprefix = false;
        }

        DiString full = GetK2MediaPath(relPath, true);
        if(full.empty())
        {
            DI_WARNING("Empty texture file!, using default texture instead");
            return DiTexture::GetDefaultTexture();
        }
        
#if 0
        if (TEXTURE_PACK && full[0] != '\\' && full[0] != '/')
        {
            full = "/"+full;
        }
#endif

        DiString tgaExt = ".tga";
#if DEMI_PLATFORM == DEMI_PLATFORM_IOS
        DiString compExt = ".pvr";
#else
        DiString compExt = ".dds";
#endif

        DiString tgaFile = full + tgaExt;
        DiString ddsFile = full + compExt;
        bool useTga = false;

        if (TEXTURE_PACK)
        {
            DiDataStreamPtr data;
            
            /// TODO read the descriptor file
            if(needprefix)
            {
                tgaFile = DiK2Configs::TEXTURE_PACK_PREFIX_FOLDER + tgaFile;
                ddsFile = DiK2Configs::TEXTURE_PACK_PREFIX_FOLDER + ddsFile;
            }

            if (TEXTURE_PACK->HasFile(ddsFile))
                data = TEXTURE_PACK->Open(ddsFile);
            else
            {
                data = TEXTURE_PACK->Open(tgaFile);
                useTga = true;
            }

            if (!data)
            {
                DI_WARNING("Cannot open the texture file: %s, using default texture", ddsFile.c_str());
                return DiTexture::GetDefaultTexture();
            }

#ifdef _K2_RECORD_USED_RESOURCE
            sUsedResources.insert(relPath + (useTga ? tgaExt : compExt));
#endif
            ret = DiAssetManager::GetInstance().CreateOrReplaceAsset<DiTexture>(relPath);
            ret->Load(data);
            return ret;
        }
        else
        {
            FILE* fp = nullptr;

            // try dds
            fp = fopen(ddsFile.c_str(), "rb");

            // try tga
            if (!fp)
            {
                fp = fopen(tgaFile.c_str(), "rb");
                useTga = true;
            }

            if (!fp)
            {
                DI_WARNING("Cannot open the texture file: %s, using default texture", ddsFile.c_str());
                return DiTexture::GetDefaultTexture();
            }

#ifdef _K2_RECORD_USED_RESOURCE
            sUsedResources.insert(relPath + (useTga ? tgaExt : compExt));
#endif
            DiDataStreamPtr texData(DI_NEW DiFileHandleDataStream(relPath, fp));

            ret = DiAssetManager::GetInstance().CreateOrReplaceAsset<DiTexture>(relPath);
            ret->Load(texData);
            return ret;
        }
    }