Exemplo n.º 1
0
//-----------------------------------------------------------------------------
// initialization
//-----------------------------------------------------------------------------
bool CBitmapPanel::Init(KeyValues* pInitData)
{
    Assert(pInitData);

    // modulation color
    if (!ParseRGBA(pInitData, "color", m_r, m_g, m_b, m_a))
        return false;

    int x, y, w, h;
    if (!ParseRect(pInitData, "position", x, y, w, h))
        return false;

    const char *mouseover = pInitData->GetString("mousehint", "");
    if (mouseover && mouseover[0])
    {
        Q_strncpy(m_szMouseOverText, mouseover, sizeof(m_szMouseOverText));
    }

    // Set the size...
    SetPos(x, y);
    SetSize(w, h);

    char const* pClassImage = pInitData->GetString("material");
    if (!pClassImage || !pClassImage[0])
        return false;

    // hook in the bitmap
    m_pImage = new BitmapImage(GetVPanel(), pClassImage);
    m_bOwnsImage = true;

    return true;
}
BOOL CBCGPTagManager::ReadRect  (const CString& strValue, CRect& value)
{
	CString strItem;

	if (ExcludeTag (strValue, strItem))
	{
		return ParseRect (strItem, value);
	}

	return FALSE;
}
Exemplo n.º 3
0
//-----------------------------------------------------------------------------
// Purpose: Parse values from the file
//-----------------------------------------------------------------------------
bool CHealthBarPanel::Init( KeyValues* pInitData )
{
	if (!pInitData)
		return false;

	if (!ParseRGBA(pInitData, "okcolor", m_Ok ))
		return false;

	if (!ParseRGBA(pInitData, "badcolor", m_Bad ))
		return false;

	int x, y, w, h;
	if (!ParseRect(pInitData, "position", x, y, w, h ))
		return false;
	SetPos( x, y );
	SetSize( w, h );
	SetCursor( NULL );

	return true;
}
//-----------------------------------------------------------------------------
// Initialization 
//-----------------------------------------------------------------------------
bool CHudPlayerOverlaySquad::Init( KeyValues* pInitData )
{
	if (!pInitData)
		return false;

	SetContentAlignment( vgui::Label::a_west );

	if (!ParseRGBA(pInitData, "fgcolor", m_fgColor ))
		return false;

	if (!ParseRGBA(pInitData, "bgcolor", m_bgColor))
		return false;

	int x, y, w, h;
	if (!ParseRect(pInitData, "position", x, y, w, h ))
		return false;
	SetPos( x, y );
	SetSize( w, h );

	return true;
}
Exemplo n.º 5
0
bool CSkin::ReadButton(const char *skinFile, int num)
{
  char buffer[2048];

  CString path = skinFile;
  int index = path.ReverseFind('\\');
  if(index != -1) {
    path = path.Left(index+1);
  }
  sprintf(buffer, "button-%d", num);
  CString name = buffer;
  
  if(!GetPrivateProfileString(name, "normal", "", buffer, 2048, skinFile)) {
    m_error = "Missing button bitmap for " + name;
    return false;
  }
  
  CString normalBmp = path + buffer;

  HBITMAP bmp = LoadImage(normalBmp);
  if(!bmp) {
    m_error = "Error loading button bitmap " + normalBmp;
    return false;
  }
  m_buttons[num].SetNormalBitmap(bmp);

  if(!GetPrivateProfileString(name, "down", "", buffer, 2048, skinFile)) {
    m_error = "Missing button down bitmap " + name;
    return false;
  }
  
  CString downBmp = path + buffer;

  bmp = LoadImage(downBmp);

  if (!bmp) {
    m_error = "Error loading button down bitmap " + downBmp;
    return false;
  }
  m_buttons[num].SetDownBitmap(bmp);

  if(GetPrivateProfileString(name, "over", "", buffer, 2048, skinFile)) {
    CString overBmp = path + buffer;

    bmp = LoadImage(overBmp);

    if (!bmp) {
      m_error = "Error loading button over bitmap " + overBmp;
      return false;
    }
    m_buttons[num].SetOverBitmap(bmp);
  }

  if(GetPrivateProfileString(name, "region", "", buffer, 2048, skinFile)) {
    CString region = path + buffer;
    
    HRGN rgn = LoadRegion(region);
    if(!rgn) {
      m_error = "Error loading button region " + region;
      return false;
    }
    m_buttons[num].SetRegion(rgn);
  }

  if(!GetPrivateProfileString(name, "id", "", buffer, 2048, skinFile)) {
    "Missing button ID for " + name;
    return false;
  }
  m_buttons[num].SetId(buffer);

  if(!GetPrivateProfileString(name, "rect", "", buffer, 2048, skinFile)) {
    m_error = "Missing button rectangle for " + name;
    return false;
  }
  
  RECT r;
  if(!ParseRect(buffer, r)) {
    m_error = "Invalid button rectangle for " + name;
    return false;
  }
  m_buttons[num].SetRect(r);

  return true;
}
Exemplo n.º 6
0
// ----------------------------------------------------------------------------
// skin retrieval helper
// ----------------------------------------------------------------------------
bool CSkin::GetSkinData(const char *skinFile)
{
  // -------------------------------------------------
  // retrieve the skin bitmap from resource.
  // -------------------------------------------------

  char buffer[2048];

  if(!GetPrivateProfileString("skin", "image", "", buffer, 2048, skinFile)) {
    m_error = "Missing skin bitmap";
    return false;
  }
  CString bmpName = buffer;
  CString rgn = "";
  if(GetPrivateProfileString("skin", "region", "", buffer, 2048, skinFile)) {
    rgn = buffer;
  }

  if(!GetPrivateProfileString("skin", "draw", "", buffer, 2048, skinFile)) {
    m_error = "Missing draw rectangle";
    return false;
  }
  
  if(!ParseRect(buffer, m_rect)) {
    m_error = "Invalid draw rectangle";
    return false;
  }

  m_nButtons = GetPrivateProfileInt("skin", "buttons", 0, skinFile);

  if(m_nButtons) {
    m_buttons = new SkinButton[m_nButtons];
    for(int i = 0; i < m_nButtons; i++) {
      if(!ReadButton(skinFile, i))
        return false;
    }
  }
  
  CString path = skinFile;
  int index = path.ReverseFind('\\');
  if(index != -1) {
    path = path.Left(index+1);
  }

  bmpName = path + bmpName;
  if(strcmp(rgn, ""))
    rgn = path + rgn;

  m_hBmp = LoadImage(bmpName);

  if (!m_hBmp) {
    m_error = "Error loading skin bitmap " + bmpName;
    return false;
  }

  // get skin info
  BITMAP bmp;
  GetObject(m_hBmp, sizeof(bmp), &bmp);

  // get skin dimensions
  m_iWidth = bmp.bmWidth;
  m_iHeight = bmp.bmHeight;

  if(strcmp(rgn, "")) {
    m_rgnSkin = LoadRegion(rgn);
    if(m_rgnSkin == NULL) {
      m_error = "Error loading skin region " + rgn;
      return false;
    }
  }

  // -------------------------------------------------
  // well, things are looking good...
  // as a quick providence, just create and keep
  // a device context for our later blittings.
  // -------------------------------------------------

  // create a context compatible with the user desktop
  m_dcSkin = CreateCompatibleDC(0);
  if (!m_dcSkin) return false;

  // select our bitmap
  m_hOldBmp = (HBITMAP)SelectObject(m_dcSkin, m_hBmp);


  // -------------------------------------------------
  // done
  // -------------------------------------------------
  return true;
}