Esempio n. 1
0
nuiSpriteDef::nuiSpriteDef(const nglPath& rSpriteDefPath)
{
  Init();
  nglString name(rSpriteDefPath.GetNodeName());
  SetObjectName(name);
  std::map<nglString, nuiSpriteDef*>::const_iterator it = mSpriteMap.find(name);
  if (it != mSpriteMap.end())
    it->second->Release();

  mSpriteMap[name] = this;

  {
    std::list<nglPath> children;
    rSpriteDefPath.GetChildren(&children);
    std::list<nglPath>::const_iterator it = children.begin();
    std::list<nglPath>::const_iterator end = children.end();
    for (; it != end; it++)
    {
      nuiSpriteAnimation* pAnim = new nuiSpriteAnimation(*it);
      if (pAnim->GetFrameCount())
        AddAnimation(pAnim);
      else
        delete pAnim;
    }
  }
}
Esempio n. 2
0
void nuiMimeMultiPart::AddFile(const nglPath& rPath, const nglString& rVarName, const nglString& rFileName, ContentTransfertEncoding encoding)
{
  nglString name(rFileName);
  if (name.IsNull())
    name = rPath.GetNodeName();
    
  nglIStream* pFile = rPath.OpenRead();
  if (!pFile)
    return;

  AddFile(pFile, rVarName, name, encoding);
}
Esempio n. 3
0
nuiSprite::nuiSprite(const nglPath& rSpriteDefPath, bool forceReplace)
: mColor(255, 255, 255), mAlpha(1.0f), mBlendFunc(nuiBlendTransp)
{
  mpSpriteDef = nuiSpriteDef::GetSprite(rSpriteDefPath.GetNodeName());
  if (!mpSpriteDef || forceReplace)
  {
    mpSpriteDef = new nuiSpriteDef(rSpriteDefPath);
    mpSpriteDef->Acquire();
  }

  NGL_ASSERT(mpSpriteDef);
  Init();  
}
Esempio n. 4
0
bool ProjectGenerator::CopyDirectory(const nglPath& targetPath, const nglPath& srcpath)
{
  // create folder
  if (!targetPath.Create())
  {
    nglString msg;
    msg.Format(_T("creating target folder '%ls'"), targetPath.GetChars());
    return MsgError(msg);
  }
  
  
  std::list<nglPath> children;
  srcpath.GetChildren(&children);
  std::list<nglPath>::iterator it;
  for (it = children.begin(); it != children.end(); ++it)
  {
    const nglPath& srcpath = *it;
    
    if (!srcpath.IsLeaf())
      continue;
    
    nglPath dstpath = targetPath;
    dstpath += srcpath.GetNodeName();
    
    nglString contents;
    
    nglIStream* piFile = srcpath.OpenRead();
    if (!piFile)
    {
      nglString msg;
      msg.Format(_T("opening for reading input file '%ls'"), srcpath.GetChars());
      return MsgError(msg);
    }
    
    nglOStream* poFile = dstpath.OpenWrite(false);
    if (!poFile)
    {
      nglString msg;
      msg.Format(_T("opening for writing output file '%ls'"), dstpath.GetChars());
      return MsgError(msg);
    }
    
    piFile->PipeTo(*poFile);
    delete poFile;
    delete piFile;
    
    NGL_OUT(_T("nui project generator : created file '%ls'\n"), dstpath.GetChars());
  }
  
  return true;
}
Esempio n. 5
0
bool nglZipPath::Decompose(const nglPath& rPath, std::list<nglPath>& rList)
{
  nglPath parent(rPath.GetParent());
  nglString tmp = rPath.GetNodeName();
  nglPath node(tmp.IsNull()? nglString::Empty : tmp);

  if (parent == rPath)
    return true;

  rList.push_front(node);
  return Decompose(parent, rList);

  return true;
}
Esempio n. 6
0
nglZipFS::nglZipFS(const nglPath& rPath)
: nglVolume(nglPath(rPath.GetNodeName()).GetRemovedExtension(), nglString::Empty, nglString::Empty, nglPathVolume::ReadOnly, nglPathVolume::eTypeZip),
  mRoot(_T(""), 0, 0, 0, false), mpFileFuncDef(NULL)
{
  mpStream = rPath.OpenRead();
  mOwnStream = true;
  SetValid(mpStream != NULL);

	if (mpStream)
		mpStream->SetEndian(eEndianIntel);
	
  mpPrivate = new nglZipPrivate();
  NGL_ASSERT(mpPrivate);
}
Esempio n. 7
0
nuiSpriteAnimation::nuiSpriteAnimation(const nglPath& rPath)
: mFPS(10)
{
  nglPath path(rPath);
  std::list<nglPath> children;
  path.GetChildren(&children);
  children.sort(nglCompareNaturalPath);
  std::list<nglPath>::const_iterator it = children.begin();
  std::list<nglPath>::const_iterator end = children.end();
  for (; it != end; it++)
  {
    nglPath p = *it;
    nglString pp = p.GetRemovedExtension();
    if (pp.GetRight(3) != _T("@2x"))
    {
      nuiSpriteFrame* pFrame = new nuiSpriteFrame();
      pFrame->SetTexture(p);
      AddFrame(pFrame);
    }
  }
  
  SetName(rPath.GetNodeName());
}