Exemplo n.º 1
0
bool ResourceStream::LoadDataFromFile(const char* path, ResourceType_t type) {
	ASSERT(!m_File.IsOpen());
	ASSERT(CanLoad());

	if (!CanLoad()) {
		return false;
	}
	
	if (m_FileSysPtr->AsyncInProgress()) {
		return false;
	}

	bool openRes = m_File.Open(path, kPlatformFileRead);

	if (!openRes) {
		return false;
	}

	m_FileSysPtr->AsyncRead(m_File, 0, m_BackBuffer->data, kResourceLoadSizeMax);

	m_BackBuffer->status = kResourceBufferProgress;

	m_BackBuffer->type = type;
	m_BackBuffer->path = path;

	return true;
}
Exemplo n.º 2
0
int wxArchive::LoadInt()
{
	wxUint8 intsize = 0;
	int tmpval = 0;

	if(CanLoad())
	{
		// get size
		intsize = LoadChar();
		switch(intsize)
		{
		case 1:	// 8 bits
			tmpval = (int)LoadChar();
			break;
		case 2:	// 16 bits
			tmpval = (int)LoadUint16();
			break;
		case 4:	// 32 bits
			tmpval = (int)LoadUint32();
			break;
		case 8:	// 64 bits
			tmpval = (int)LoadUint64();
			break;

		default:
			LogError(wxARCHIVE_ERR_ILL, wxARCHIVE_ERR_STR_RINTSIZE);
			break;
		}
	}

	return tmpval;
}
Exemplo n.º 3
0
bool wxArchive::EnterObject()
{
	// increments the level. This will also mean
	// that with reading we expect to read this level. We skip all
	// headers until we get this level.

	if(IsOk())
	{
		if(!m_writeMode)
		{
			if(CanLoad())
			{
				m_objectLevel ++;
				FindCurrentEnterLevel();
			}
			else
				return false;	// we did not enter
		}
		else
		{
			if(CanStore())
			{
				m_objectLevel++;
				SaveChar(wxARCHIVE_HDR_ENTER);
			}
			else
				return false;	// we did not enter
		}
	}

	return IsOk();
}
Exemplo n.º 4
0
int wxArchive::LoadChunkHeader(int expheader)
{
	int hdr = 0;

    if(CanLoad())
	{
		if(m_haveBoundary)
			return 0;

		hdr = (int)LoadChar();
		if(hdr == wxARCHIVE_HDR_ENTER || hdr == wxARCHIVE_HDR_LEAVE)
		{
			// remember this state
			m_lastBoundary = hdr;
			m_haveBoundary = true;
			return 0;
		}

        // when header is not ok
        if(hdr != expheader)
        {
        	LogError(wxARCHIVE_ERR_ILL, wxARCHIVE_ERR_STR_WRONGCHUNK_s1_s2,
        	         GetHeaderName(expheader), GetHeaderName(hdr));
        	return -1;
        }
    }

    return hdr;
}
Exemplo n.º 5
0
wxString wxArchive::LoadString()
{
    wxString str;

	if(CanLoad())
	{
		size_t len = LoadUint32();

        //wxLogDebug(wxString::Format(wxT("LoadString len %i"), len));

		if (len > 0)
		{
            // embarassing how I am doing this, but I cannot be certain which
            // unicode method reads a multibyte array and converts it so I will
            // do it per wxInt16 converted to wxChar. When bytes get lost in the
            // conversion then it's tough luck as this build is not unicode then
            str.Alloc(len+1);
            wxInt16 *buf = new wxInt16[len+1];
            for(int i = 0; i < len; i++)
            {
                // we need to load per 16 bits because they
                // need to optionally be swapped to convert
                buf[i] = LoadUint16();
                str.Append((wxChar)buf[i]);
            }

            delete[] buf;
		}
	}

	return str;
}
Exemplo n.º 6
0
	void Resource::Reload()
	{
		if (CanLoad())
		{
			Unload();
			Load();
		}
	}
Exemplo n.º 7
0
void wxArchive::Load(wxCharBuffer &buf)
{
	if(CanLoad())
	{
		wxUint32 size = LoadUint32();
		if(size > 0)
			m_idstr.Read(buf.data(), size);
	}
}
Exemplo n.º 8
0
	void MActorRes::Reload()
	{
		if (CanLoad() && mLoadState == LOADED)
		{
			Unload();
			Load();
		}

		mLoadState = LOADED;
	}
Exemplo n.º 9
0
	void MActorRes::Unload()
	{
		if (CanLoad() && mLoadState == LOADED)
		{
			_shutdown();

			OnResourceUnloaded(this, NULL);

			mLoadState = UNLOADED;
		}
	}
Exemplo n.º 10
0
	void Resource::Load()
	{
		if (mLoadState != Resource::UNLOADED)
			return ;

		mLoadState = LOADING;

		if (CanLoad())
			ResourceManager::Instance()->GetResourceLoader()->Load(this);
		else
			OnLoad();
	}
Exemplo n.º 11
0
wxUint64 wxArchive::LoadUint64()
{
	wxUint64 value = 0;

	// reads a character from the stream
	if(CanLoad())
	{
		m_idstr.Read((void *)&value, sizeof(wxUint64));
		return wxUINT64_SWAP_ON_LE(value);
	}

	return value;
}
Exemplo n.º 12
0
wxUint32 wxArchive::LoadUint32()
{
	wxUint32 value = 0;

	// reads a 32bits from the stream
	if(CanLoad())
	{
		m_idstr.Read((void *)&value, sizeof(wxUint32));
		return wxUINT32_SWAP_ON_LE(value);
	}

	return value;
}
Exemplo n.º 13
0
wxUint16 wxArchive::LoadUint16()
{
	wxUint16 value = 0;

	// reads a 16bits from the stream
	if(CanLoad())
	{
		m_idstr.Read((void *)&value, sizeof(wxUint16));
		return wxUINT16_SWAP_ON_LE(value);
	}

	return value;
}
Exemplo n.º 14
0
wxArrayString wxArchive::LoadArrayString()
{
	wxArrayString str;

	if(CanLoad())
	{
		wxUint32 count = LoadUint32();

		for(wxUint32 i = 0; i < count; i++)
			str.Add(LoadString());
	}

	return str;
}
Exemplo n.º 15
0
wxUint8 wxArchive::LoadChar()
{
	wxUint8 value = '\0';

	// reads a character from the stream
	if(CanLoad())
	{
		// load unsigned char through ptr to
		// make sure we have no signed / unsigned crap
	    m_idstr.Read((void *)&value, sizeof(wxUint8));
	}

	return value;
}
Exemplo n.º 16
0
bool wxArchive::LoadBool()
{
	bool value = false;
	wxUint8 chr;

	if(CanLoad())
	{
		chr = LoadChar();
		if(IsOk())
		    value = (chr != 0);
	}

	return value;
}
Exemplo n.º 17
0
	void Resource::EnsureLoad()
	{
		if (mLoadState == Resource::LOADED)
			return ;

		if (CanLoad())
		{
			if (mLoadState == LOADING)
				Unload();

			mLoadState = LOADING;
			ResourceManager::Instance()->GetResourceLoader()->ForceLoad(this);
		}
		else
		{
			mLoadState = Resource::LOADED;
		}
	}
Exemplo n.º 18
0
	void MActorRes::Load()
	{
		if (CanLoad() && mLoadState == UNLOADED)
		{
			ResourceManager::Instance()->GetResourceLoader()->Load(this);

			OnResourceLoaded(this, NULL);

			{
				// 
				TString128 motionPath = File::GetFileDir(mSourceName);

				d_assert (motionPath != "");

				motionPath += "\\Motion\\";

				Archive::FileInfoList motionList; 

				ResourceManager::Instance()->GetFileInfosByFloder(motionList, motionPath);

				mMotionCount = motionList.Size();

				if (mMotionCount != 0)
				{
					mMotionSet = new MMotion[mMotionCount];

					Archive::FileInfoList::Iterator whr = motionList.Begin();
					Archive::FileInfoList::Iterator end = motionList.End();

					int index = 0;

					while (whr != end)
					{
						mMotionSet[index++]._Load(whr->name);

						++whr;
					}
				}
			}
		}

		mLoadState = LOADED;
	}
Exemplo n.º 19
0
double wxArchive::LoadDouble()
{
	double value = 0;

	// reads a character from the stream
	if(CanLoad())
	{
#if wxUSE_APPLE_IEEE
		unsigned char buf[10];

		m_idstr.Read((void *)buf, 10);
		value = ConvertFromIeeeExtended(buf);
#else
		#pragma warning "wxArchive::LoadDouble() not using IeeeExtended - will not work!"
#endif
	}

	return value;
}
Exemplo n.º 20
0
bool CGUITextureManager::HasTexture(const std::string &textureName, std::string *path, int *bundle, int *size)
{
  CSingleLock lock(m_section);

  // default values
  if (bundle) *bundle = -1;
  if (size) *size = 0;
  if (path) *path = textureName;

  if (textureName.empty())
    return false;

  if (!CanLoad(textureName))
    return false;

  // Check our loaded and bundled textures - we store in bundles using \\.
  std::string bundledName = CTextureBundle::Normalize(textureName);
  for (int i = 0; i < (int)m_vecTextures.size(); ++i)
  {
    CTextureMap *pMap = m_vecTextures[i];
    if (pMap->GetName() == textureName)
    {
      if (size) *size = 1;
      return true;
    }
  }

  for (int i = 0; i < 2; i++)
  {
    if (m_TexBundle[i].HasFile(bundledName))
    {
      if (bundle) *bundle = i;
      return true;
    }
  }

  std::string fullPath = GetTexturePath(textureName);
  if (path)
    *path = fullPath;

  return !fullPath.empty();
}
Exemplo n.º 21
0
bool wxArchive::LeaveObject()
{
	// increments the level. This will also mean
	// that with reading we expect to read this level. We skip all
	// headers until we get this level.

	if(IsOk())
	{
		if(!m_writeMode)
		{
			if(CanLoad())
			{
				m_objectLevel --;
				if(m_objectLevel < 0)
					LogError(wxARCHIVE_ERR_ILL, wxARCHIVE_ERR_STR_ILL_LEVEL);
				else
					FindCurrentLeaveLevel();
			}
			else
				return false;	// we did not enter
		}
		else
		{
			if(CanStore())
			{
				m_objectLevel--;
				if(m_objectLevel < 0)
					LogError(wxARCHIVE_ERR_ILL, wxARCHIVE_ERR_STR_ILL_LEVEL);
				else
					SaveChar(wxARCHIVE_HDR_LEAVE);
			}
			else
				return false;	// we did not enter
		}
	}

	return IsOk();
}