Ejemplo n.º 1
0
BOOL VPrefab::Instantiate(VPrefabInstanceInfo &info)
{
  EnsureLoaded();
  if (!IsLoaded())
    return FALSE;

  // serialize from memory block (class VPrefabShapesArchive provides with transformation)
  VMemBlockWrapperStream inStream(m_BinaryBlock.GetBuffer(), m_iSize);
  VPrefabShapesArchive ar(&inStream, info);
  ar.SetLoadingVersion(m_Header.m_iArchiveVersion);

  if (info.m_bOutputInstances)
    info.m_Instances.EnsureSize(m_Header.m_iRootObjectCount);

  info.m_iInstanceCount = m_Header.m_iRootObjectCount;
  for (int i=0;i<m_Header.m_iRootObjectCount;i++)
  {
    VTypedObject *pObj = ar.ReadObject(NULL);
    if (info.m_bOutputInstances)
      info.m_Instances[i] = pObj;
    if (info.m_pParentObject!=NULL && pObj!=NULL && pObj->IsOfType(V_RUNTIME_CLASS(VisObject3D_cl)))
    {
      VisObject3D_cl *pObj3D = (VisObject3D_cl *)pObj;
      if (pObj3D->GetParent()==NULL) // this is how we identify the root elements
        pObj3D->AttachToParent(info.m_pParentObject);
    }
  }

  ar.Close();

  return TRUE;
}
Ejemplo n.º 2
0
bool C4Startup::Execute()
	{
	// ensure gfx are loaded
	C4Startup *pStartup = EnsureLoaded();
	if (!pStartup) return false;
	// exec it
	bool fResult = pStartup->DoStartup();
	return fResult;
	}
Ejemplo n.º 3
0
void
DataFieldFileReader::Inc()
{
  EnsureLoaded();

  if (mValue < files.size() - 1) {
    mValue++;
    Modified();
  }
}
Ejemplo n.º 4
0
void
FileDataField::Inc()
{
  EnsureLoaded();

  if (current_index < files.size() - 1) {
    current_index++;
    Modified();
  }
}
Ejemplo n.º 5
0
void
DataFieldFileReader::Inc(void)
{
  EnsureLoaded();

  if (mValue < files.size() - 1) {
    mValue++;
    if (mOnDataAccess != NULL)
      mOnDataAccess(this, daChange);
  }
}
Ejemplo n.º 6
0
pmath::Vec4 Image::GetPixel(unsigned int x, unsigned int y)
{
    EnsureLoaded();
    assert(x < m_size.x && y < m_size.y);

    const unsigned int start = static_cast<unsigned int>(4 * ((y * m_size.x) + x));

    return pmath::Vec4(static_cast<float>(m_pixels[start]),
                       static_cast<float>(m_pixels[start + 1]),
                       static_cast<float>(m_pixels[start + 2]),
                       static_cast<float>(m_pixels[start + 3]));
}
Ejemplo n.º 7
0
void
DataFieldFileReader::Set(unsigned Value)
{
  if (Value > 0)
    EnsureLoaded();
  else
    postponed_value.clear();

  if (Value < files.size()) {
    mValue = Value;
    Modified();
  }
}
Ejemplo n.º 8
0
void
FileDataField::Set(unsigned new_value)
{
  if (new_value > 0)
    EnsureLoaded();
  else
    postponed_value.clear();

  if (new_value < files.size()) {
    current_index = new_value;
    Modified();
  }
}
Ejemplo n.º 9
0
void
DataFieldFileReader::Set(int Value)
{
  if (Value > 0)
    EnsureLoaded();
  else
    postponed_value.clear();

  if ((unsigned)Value < files.size()) {
    mValue = Value;
    if (mOnDataAccess != NULL)
      mOnDataAccess(this, daChange);
  }
}
Ejemplo n.º 10
0
void
FileDataField::Lookup(const TCHAR *text)
{
  if (!loaded) {
    if (_tcslen(text) < postponed_value.capacity()) {
      postponed_value = text;
      return;
    } else
      EnsureLoaded();
  }

  auto i = Find(text);
  if (i >= 0)
    current_index = i;
}
Ejemplo n.º 11
0
void
DataFieldFileReader::ScanDirectoryTop(const TCHAR* filter)
{
  if (!loaded) {
    if (!postponed_patterns.full() &&
        _tcslen(filter) < PatternList::value_type::MAX_SIZE) {
      postponed_patterns.append() = filter;
      return;
    } else
      EnsureLoaded();
  }

  FileVisitor fv(*this);
  VisitDataFiles(filter, fv);

  Sort();
}
Ejemplo n.º 12
0
void
FileDataField::ForceModify(const TCHAR *path)
{
  EnsureLoaded();

  auto i = Find(path);
  if (i >= 0) {
    if (unsigned(i) == current_index)
      return;
  } else {
    auto &item = files.full() ? files.back() : files.append();
    item.Set(path);
    i = files.size() - 1;
  }

  current_index = i;
  Modified();
}
Ejemplo n.º 13
0
void Image::flipVertical()
{
    EnsureLoaded();
    if (!m_pixels.empty())
    {
        std::size_t rowSize = static_cast<std::size_t>(m_size.x) * 4;

        std::vector<BYTE>::iterator top = m_pixels.begin();
        std::vector<BYTE>::iterator bottom = m_pixels.end() - rowSize;

        for (std::size_t y = 0; y < m_size.y / 2; ++y)
        {
            std::swap_ranges(top, top + rowSize, bottom);

            top += rowSize;
            bottom -= rowSize;
        }
    }
}
Ejemplo n.º 14
0
VDialog *VDialogResource::CreateInstance(IVGUIContext *pContext, VDialog *pParent, int iFlags)
{
  VISION_PROFILE_FUNCTION(VGUIManager::PROFILING_BUILD);
  EnsureLoaded();

  if (!m_pXMLNode || !IsLoaded()) // couldn't load XML file?
  {
    VASSERT(!"VDialogResource::CreateInstance failed because dialog resource is invalid");
    return NULL;
  }

  char szPath[FS_MAX_PATH];
  GetFilePath(szPath);

  const char *szClass = XMLHelper::Exchange_String(m_pXMLNode,"class",NULL,false);
  if (!szClass || !szClass[0])
    szClass = "VDialog";

  VType *pType = Vision::GetTypeManager()->GetType(szClass);
  if (!pType)
  {
    VASSERT(!"VDialogResource::CreateInstance failed because dialog class does not exist in type manager");
    return NULL;
  }
  VDialog *pDlg = (VDialog *)pType->CreateInstance();
  
  // sanity check
  if (!pDlg->IsOfType(Vision::GetTypeManager()->GetType("VDialog")))
    Vision::Error.FatalError("class '%s' is not derived from base class VDialog",szClass);

  VASSERT(pParent==NULL || pParent->m_pContext==pContext);

  pDlg->InitDialog(pContext, this, pParent, iFlags);
  if (!pDlg->Build(m_pXMLNode, szPath,false))
  {
    VASSERT(!"VDialogResource::CreateInstance failed because Build from XML node failed");
    return NULL;
  }
  pDlg->OnBuildFinished();
  pDlg->OnInitDialog();

  return pDlg;
}
Ejemplo n.º 15
0
void
DataFieldFileReader::Lookup(const TCHAR *Text)
{
  if (!loaded) {
    if (_tcslen(Text) < postponed_value.MAX_SIZE) {
      postponed_value = Text;
      return;
    } else
      EnsureLoaded();
  }

  mValue = 0;
  // Iterate through the filelist
  for (unsigned i = 1; i < files.size(); i++) {
    // If Text == pathfile
    if (_tcscmp(Text, files[i].path) == 0) {
      // -> set selection to current element
      mValue = i;
    }
  }
}
Ejemplo n.º 16
0
void Image::flipHorizontal()
{
    EnsureLoaded();
    if (!m_pixels.empty())
    {
        std::size_t rowSize = static_cast<std::size_t>(m_size.x) * m_depth;

        for (std::size_t y = 0; y < m_size.y; ++y)
        {
            std::vector<BYTE>::iterator left = m_pixels.begin() + y * rowSize;
            std::vector<BYTE>::iterator right = m_pixels.begin() + (y + 1) * rowSize - m_depth;

            for (std::size_t x = 0; x < m_size.x / 2; ++x)
            {
                std::swap_ranges(left, left + m_depth, right);

                left += m_depth;
                right -= m_depth;
            }
        }
    }
}
Ejemplo n.º 17
0
 /// \brief
 ///   Increases the lock counter of the resource. 
 /// 
 /// A locked resource cannot be unloaded. Calling EnsureUnloaded on a locked resource will cause
 /// an assertion. This function will also call EnsureLoaded() which is useful in most cases.
 /// 
 /// \sa V_LOCK_RESOURCE
 /// \sa VManagedResource::CanUnload()
 /// \sa VManagedResource::EnsureUnloaded()
 /// \sa VManagedResource::AddLockNoLoad()
 /// \sa VManagedResource::ReleaseLock()
 /// \sa VManagedResource::IsLocked()
 inline void AddLock()         {m_iLockCounter++;EnsureLoaded();}
Ejemplo n.º 18
0
 TERRAIN_IMPEXP virtual void PrepareSector() 
 {
   m_bPrepared=true;
   EnsureLoaded();
 }