| 975 | } |
| 976 | |
| 977 | bool ResourcePool::LoadParticle(const char* name, const std::wstring& path, const char* img_name, double a, double b, bool rect)LNOEXCEPT |
| 978 | { |
| 979 | LDEBUG_RESOURCETIMER; |
| 980 | |
| 981 | { |
| 982 | LDEBUG_RESOURCESCOPE; |
| 983 | |
| 984 | LASSERT(LAPP.GetRenderer()); |
| 985 | |
| 986 | if (m_ParticlePool.find(name) != m_ParticlePool.end()) |
| 987 | { |
| 988 | LWARNING("LoadParticle: ����'%m'�Ѵ��ڣ����ز����ѱ�ȡ��", name); |
| 989 | return true; |
| 990 | } |
| 991 | |
| 992 | fcyRefPointer<ResSprite> pSprite = m_pMgr->FindSprite(img_name); |
| 993 | fcyRefPointer<f2dSprite> pClone; |
| 994 | if (!pSprite) |
| 995 | { |
| 996 | LWARNING("LoadParticle: ��������'%m'ʧ��, ���ҵ�����'%m'", name, img_name); |
| 997 | return false; |
| 998 | } |
| 999 | else |
| 1000 | { |
| 1001 | // ��¡һ��������� |
| 1002 | if (FCYFAILED(LAPP.GetRenderer()->CreateSprite2D(pSprite->GetSprite()->GetTexture(), pSprite->GetSprite()->GetTexRect(), pSprite->GetSprite()->GetHotSpot(), &pClone))) |
| 1003 | { |
| 1004 | LERROR("LoadParticle: ��¡ͼƬ'%m'ʧ��", img_name); |
| 1005 | return false; |
| 1006 | } |
| 1007 | pClone->SetColor(0, pSprite->GetSprite()->GetColor(0U)); |
| 1008 | pClone->SetColor(1, pSprite->GetSprite()->GetColor(1U)); |
| 1009 | pClone->SetColor(2, pSprite->GetSprite()->GetColor(2U)); |
| 1010 | pClone->SetColor(3, pSprite->GetSprite()->GetColor(3U)); |
| 1011 | pClone->SetZ(pSprite->GetSprite()->GetZ()); |
| 1012 | } |
| 1013 | |
| 1014 | fcyRefPointer<fcyMemStream> outBuf; |
| 1015 | if (!LRES.LoadFile(path.c_str(), outBuf)) |
| 1016 | return false; |
| 1017 | if (outBuf->GetLength() != sizeof(ResParticle::ParticleInfo)) |
| 1018 | { |
| 1019 | LERROR("LoadParticle: ���Ӷ����ļ�'%s'��ʽ����ȷ", path.c_str()); |
| 1020 | return false; |
| 1021 | } |
| 1022 | |
| 1023 | try |
| 1024 | { |
| 1025 | ResParticle::ParticleInfo tInfo; |
| 1026 | memcpy(&tInfo, outBuf->GetInternalBuffer(), sizeof(ResParticle::ParticleInfo)); |
| 1027 | tInfo.iBlendInfo = (tInfo.iBlendInfo >> 16) & 0x00000003; |
| 1028 | |
| 1029 | BlendMode tBlendInfo = BlendMode::AddAlpha; |
| 1030 | if (tInfo.iBlendInfo & 1) // ADD |
| 1031 | { |
| 1032 | if (tInfo.iBlendInfo & 2) // ALPHA |
| 1033 | tBlendInfo = BlendMode::AddAlpha; |
| 1034 | else |
no test coverage detected