void c4_FormatB::Define(int, const t4_byte **ptr_) {
  d4_assert(_memos.GetSize() == 0);

  if (ptr_ != 0) {
    _data.PullLocation(*ptr_);
    if (_data.ColSize() > 0)
      _sizeCol.PullLocation(*ptr_);
    _memoCol.PullLocation(*ptr_);
  }

  // everything below this point could be delayed until use
  // in that case, watch out that column space use is properly tracked

  InitOffsets(_sizeCol);

  if (_memoCol.ColSize() > 0) {
    c4_Bytes walk;
    _memoCol.FetchBytes(0, _memoCol.ColSize(), walk, true);

    const t4_byte *p = walk.Contents();

    for (int row = 0; p < walk.Contents() + walk.Size(); ++row) {
      row += c4_Column::PullValue(p);
      d4_assert(row < _memos.GetSize());

      c4_Column *mc = d4_new c4_Column(_data.Persist());
      d4_assert(mc != 0);
      _memos.SetAt(row, mc);

      mc->PullLocation(p);
    }

    d4_assert(p == walk.Contents() + walk.Size());
  }
}
Esempio n. 2
0
nuiGradientDecoration::nuiGradientDecoration(const nglString& rName)
: nuiDecoration(rName),
  mColor1(128, 128, 128),
  mColor2(0, 0, 0),
  mClientRect(0, 0, 0, 0),
  mStrokeSize(1),
  mStrokeColor(64, 64, 64),
  mShapeMode(eFillShape),
  mOrientation(nuiVertical)
{
  if (SetObjectClass(_T("nuiGradientDecoration")))
    InitAttributes();
  mGradientType = nuiGradient2Colors;
  mUserOffsets = false;
  InitOffsets();
}
Esempio n. 3
0
nuiGradientDecoration::nuiGradientDecoration(const nglString& rName, const nuiColor& rColor1, const nuiColor& rColor2, uint strokeSize, const nuiColor& rStrokeColor, nuiShapeMode shapeMode, nuiOrientation orientation, const nuiRect& rClientRect)
: nuiDecoration(rName),
  mColor1(rColor1),
  mColor2(rColor2),
  mStrokeSize(strokeSize),
  mStrokeColor(rStrokeColor),
  mShapeMode(shapeMode),
  mOrientation(orientation)
{
  if (SetObjectClass(_T("nuiGradientDecoration")))
    InitAttributes();

  mClientRect = rClientRect;
  mGradientType = nuiGradient2Colors;
  mUserOffsets = false;
  InitOffsets();
}
Esempio n. 4
0
void CRPGPlayer::Init( int clientIndex )
{	
	SetIndex( clientIndex );

	edict_t *pEdict = engine->PEntityOfEntIndex( clientIndex );
	if (!pEdict)
		return;

	SetEdict( pEdict );

	CBaseEntity *pEntity = pEdict->GetUnknown()->GetBaseEntity();
	//smutils->LogMessage(myself, "in");
	if (pEntity)
	{
		//smutils->LogMessage(myself, "in");
		SetBaseEntity(pEntity);
	}

	m_playerinfo = playerinfo->GetPlayerInfo(pEdict);

	InitOffsets();
	SetCachedTeam(-1);
	SetCachedClass(-1);
}
Esempio n. 5
0
void InitTCode()
{
  LK_VECTOR_Init(&Code,1024,sizeof(char));
  LK_VECTOR_Init(&Floats,32,sizeof(struct BCFloat));
  InitOffsets();
}
void c4_FormatB::OldDefine(char type_, c4_Persist &pers_) {
  int rows = Owner().NumRows();

  c4_ColOfInts sizes(_data.Persist());

  if (type_ == 'M') {
    InitOffsets(sizes);

    c4_ColOfInts szVec(_data.Persist());
    pers_.FetchOldLocation(szVec);
    szVec.SetRowCount(rows);

    c4_ColOfInts posVec(_data.Persist());
    pers_.FetchOldLocation(posVec);
    posVec.SetRowCount(rows);

    for (int r = 0; r < rows; ++r) {
      t4_i32 sz = szVec.GetInt(r);
      if (sz > 0) {
        c4_Column *mc = d4_new c4_Column(_data.Persist());
        d4_assert(mc != 0);
        _memos.SetAt(r, mc);

        mc->SetLocation(posVec.GetInt(r), sz);
      }
    }
  } else {
    pers_.FetchOldLocation(_data);

    if (type_ == 'B') {
      pers_.FetchOldLocation(sizes);

#if !q4_OLD_IS_ALWAYS_V2

      // WARNING - HUGE HACK AHEAD - THIS IS NOT 100% FULLPROOF!
      //
      // The above is correct for MK versions 2.0 and up, but *NOT*
      // for MK 1.8.6 datafiles, which store sizes first (OUCH!!!).
      // This means that there is not a 100% safe way to auto-convert
      // both 1.8.6 and 2.0 files - since there is no way to detect
      // unambiguously which version a datafile is.  All we can do,
      // is to carefully check both vectors, and *hope* that only one
      // of them is valid as sizes vector.  This problem applies to
      // the 'B' (bytes) property type only, and only pre 2.0 files.
      //
      // To build a version which *always* converts assuming 1.8.6,
      // add flag "-Dq4_OLD_IS_PRE_V2" to the compiler command line.
      // Conversely, "-Dq4_OLD_IS_ALWAYS_V2" forces 2.0 conversion.

      if (rows > 0) {
        t4_i32 s1 = sizes.ColSize();
        t4_i32 s2 = _data.ColSize();

#if !q4_OLD_IS_PRE_V2
        // if the size vector is clearly impossible, swap vectors
        bool fix = c4_ColOfInts::CalcAccessWidth(rows, s1) < 0;

        // if the other vector might be valid as well, check further
        if (!fix && c4_ColOfInts::CalcAccessWidth(rows, s2) >= 0) {
          sizes.SetRowCount(rows);
          t4_i32 total = 0;
          for (int i = 0; i < rows; ++i) {
            t4_i32 w = sizes.GetInt(i);
            if (w < 0 || total > s2) {
              total =  - 1;
              break;
            }
            total += w;
          }

          // if the sizes don't add up, swap vectors
          fix = total != s2;
        }

        if (fix)
#endif 
         {
          t4_i32 p1 = sizes.Position();
          t4_i32 p2 = _data.Position();
          _data.SetLocation(p1, s1);
          sizes.SetLocation(p2, s2);
        }
      }
#endif 
      InitOffsets(sizes);
    } else {
      d4_assert(type_ == 'S');

      sizes.SetRowCount(rows);

      t4_i32 pos = 0;
      t4_i32 lastEnd = 0;
      int k = 0;

      c4_ColIter iter(_data, 0, _data.ColSize());
      while (iter.Next()) {
        const t4_byte *p = iter.BufLoad();
        for (int j = 0; j < iter.BufLen(); ++j)
        if (!p[j]) {
          sizes.SetInt(k++, pos + j + 1-lastEnd);
          lastEnd = pos + j + 1;
        }

        pos += iter.BufLen();
      }

      d4_assert(pos == _data.ColSize());

      if (lastEnd < pos) {
        // last entry had no zero byte
        _data.InsertData(pos++, 1, true);
        sizes.SetInt(k, pos - lastEnd);
      }

      InitOffsets(sizes);

      // get rid of entries with just a null byte
      for (int r = 0; r < rows; ++r)
        if (c4_FormatB::ItemSize(r) == 1)
          SetOne(r, c4_Bytes());
    }
  }
}
Esempio n. 7
0
//virtual
void nuiGradientDecoration::Draw(nuiDrawContext* pContext, nuiWidget* pWidget, const nuiRect& rDestRect)
{
  nuiColor c1 = mColor1;
  nuiColor c2 = mColor2;
  nuiColor c3 = mColor3;
  nuiColor c4 = mColor4;
  nuiColor s = mStrokeColor;
  pContext->PushState();
  pContext->ResetState();
  
  pContext->EnableAntialiasing(false);
  pContext->EnableBlending(true);
  pContext->SetBlendFunc(nuiBlendTransp);
  pContext->EnableTexturing(false);

  
  if (mUseWidgetAlpha && pWidget)
  {
    float widgetAlpha = pWidget->GetMixedAlpha();
    c1.Multiply(widgetAlpha);
    c2.Multiply(widgetAlpha);
    s.Multiply(widgetAlpha);
  }
  
  pContext->SetFillColor(nuiColor(1, 1, 1, 1));
  pContext->SetStrokeColor(s);

  nuiGradient gradient;
  if (!mUserOffsets)
    InitOffsets();
  gradient.AddStop(c1, mOffset1);
  gradient.AddStop(c2, mOffset2);
  if (mGradientType == nuiGradient4Colors)
  {
    if (mUseWidgetAlpha && pWidget)
    {
      float widgetAlpha = pWidget->GetMixedAlpha();
      c3.Multiply(widgetAlpha);
      c4.Multiply(widgetAlpha);
    }

    gradient.AddStop(c3, mOffset3);
    gradient.AddStop(c4, mOffset4);
  }

  if (mOrientation == nuiVertical)
    pContext->DrawGradient(gradient, rDestRect, 0, rDestRect.Top(), 0, rDestRect.Bottom());
  else
  {
    pContext->DrawGradient(gradient, rDestRect, 0, rDestRect.Top(), rDestRect.Right(), rDestRect.Top());
  }
  
  if (((mShapeMode == eStrokeShape) || (mShapeMode == eStrokeAndFillShape)) && mStrokeSize)
  {
    pContext->SetFillColor(s);
    
    nuiRect rect(rDestRect.Left(), rDestRect.Top(), rDestRect.GetWidth(), mStrokeSize);
    pContext->DrawRect(rect, eFillShape);
    
    rect = nuiRect(rDestRect.Left(), rDestRect.Bottom()-mStrokeSize, rDestRect.GetWidth(), mStrokeSize);
    pContext->DrawRect(rect, eFillShape);
    
    rect = nuiRect(rDestRect.Left(), rDestRect.Top(), mStrokeSize, rDestRect.GetHeight());
    pContext->DrawRect(rect, eFillShape);
    
    rect = nuiRect(rDestRect.Right()-mStrokeSize, rDestRect.Top(), mStrokeSize, rDestRect.GetHeight());
    pContext->DrawRect(rect, eFillShape);
    
  }

  pContext->PopState();
}