//-----------------------------------------------------------------------------
// Purpose: Loads a .tga file and returns a pointer to the VGUI tga object
//-----------------------------------------------------------------------------
BitmapTGA *LoadTGAForRes( const char* pImageName )
{
	BitmapTGA	*pTGA;

	char sz[256];
	sprintf(sz, "%%d_%s", pImageName);
	pTGA = vgui_LoadTGA(GetTGANameForRes(sz));

	return pTGA;
}
コード例 #2
0
BitmapTGA *LoadTGANoRes( const char* pImageName )
{
   BitmapTGA   *pTGA;

   char sz[256];

   sprintf(sz, "gfx/vgui/%s.tga", pImageName);

   pTGA = vgui_LoadTGA(sz);

   return pTGA;
}
コード例 #3
0
ファイル: vgui_loadtga.cpp プロジェクト: as02700/NS
vgui::BitmapTGA* vgui_LoadTGANoInvertAlpha(char const *pFilename)
{ return vgui_LoadTGA(pFilename,false); }
コード例 #4
0
ファイル: UIManager.cpp プロジェクト: Arkshine/NS
bool UIManager::Initialize(const TRDescriptionList& inDesc, CSchemeManager* inSchemeManager)
{
	bool theSuccess = false;

	// Clear out everything in case we have already been used once
	this->Clear();

	// Now loop through entities found 
	for(TRDescriptionList::const_iterator theListIter = inDesc.begin(); theListIter != inDesc.end(); theListIter++)
	{
		// See if the factory knows how to create such a thing. It is giving the memory to us forever so take care of it.
		UIComponent* theCurrentComponent = this->mFactory->BuildComponent(*theListIter, inSchemeManager);

		// Tell it to set all the tags it knows about
		if(theCurrentComponent)
		{
			// Check for named root tag, look up that component and set it
            Panel* theRoot = NULL;
            string theRootName;
            
            if(theListIter->GetTagValue("root", theRootName))
            {
                UIComponent* theUIComponent = NULL;
                theUIComponent = this->GetComponentNamed(theRootName);
                if(theUIComponent)
                {
                    theRoot = theUIComponent->GetComponentPointer();
                }
            }

            // If none specified or it couldn't be found, use default
            if(!theRoot)
            {
                theRoot = (Panel*)VGui_GetPanel();
            }

            // Set the root
   			theCurrentComponent->GetComponentPointer()->setParent(theRoot);

            // Add to menu if specified
            string theMenuName;
            if(theListIter->GetTagValue(UITagMenuAddItem, theMenuName))
            {
                Menu* theParentMenu = NULL;
                if(this->GetVGUIComponentNamed(theMenuName, theParentMenu))
                {
                    theParentMenu->addMenuItem(theCurrentComponent->GetComponentPointer());
                }
            }
            
            // Set up scheme if specified
            if(inSchemeManager)
            {
                this->SetSchemeValues(*theListIter, theCurrentComponent, inSchemeManager);
            }

            // <sigh> If we are currently using the regular VGUI instead of the manager, translate
			// this component out of the way so it doesn't suck up input
			if(this->mUsingVGUI)
			{
				this->TranslateComponent(theCurrentComponent->GetComponentPointer(), true);
			}
			
			// If gamma aware, tell it immediately
			GammaAwareComponent* theGammaAwareComponent = dynamic_cast<GammaAwareComponent*>(theCurrentComponent->GetComponentPointer());
			if(theGammaAwareComponent)
			{
				theGammaAwareComponent->NotifyGammaChange(this->mGammaSlope);
			}

            // Save it. It is now part of the world.
			this->mComponentList.push_back(theCurrentComponent);
			
			// Return success if we found at least one component
			theSuccess = true;
		}
	}
	
	// Build default blank cursor
	this->mBlankCursor = new Cursor(vgui_LoadTGA("blank"), 0, 0);
	
    // Register for notification for all input events
    //this->AddInputSignal(this);
	
	return theSuccess;
}
コード例 #5
0
// it assumes that
// 20 <= (msg->effect) < 30
void CTips::LoadMsg( client_textmessage_t *msg )
{
	float curtime = gEngfuncs.GetClientTime();
//	gEngfuncs.Con_Printf("loaded\n");

	m_fShowTime = curtime;
	m_fHideTime = curtime + msg->holdtime;
	const char *pText = msg->pMessage;
	Font *pFont = FontFromMessage(pText);
	m_pText->setFont(pFont);
	m_pText->setText(pText);
	m_pText->setFgColor(msg->r1, msg->g1, msg->b1, 0);

	if (m_pBitmap) delete m_pBitmap;
	m_pBitmap = NULL;

	// load image
	//   (damn, instead of copying this block of code everywhere,
	//    i really need to create a single function to load images this way...)
	int iconnum = msg->effect - 20;

	static int resArray[] =
	{
		320, 400, 512, 640, 800,
		1024, 1152, 1280, 1600
	};

	//find current resolution
	int resArrayIndex = 0;
	int i = 0;
	while ((resArray[i] <= ScreenWidth) && (i < 9))
	{
		resArrayIndex = i;
		i++;
	}

	while(m_pBitmap == NULL && resArrayIndex >= 0)
	{
		char imgName[64];
		sprintf(imgName, "gfx/vgui/icon%d_%d.tga", iconnum, resArray[resArrayIndex]);
		m_pBitmap = vgui_LoadTGA(imgName);
		resArrayIndex--;
	}
	
	int iconWide = 0, iconTall = 0;
	if (!m_pBitmap)
	{
		if (!errorshows[iconnum]) // dont show error message for same icon wice
		{
			gEngfuncs.Con_Printf("Could not load icon gfx/vgui/icon%d_...\n", iconnum);
			errorshows[iconnum] = 1;
		}
	}
	else
	{
		m_pBitmap->getSize( iconWide, iconTall );
		m_pBitmap->setPos( TIPS_XSTEP, TIPS_BASE_HEIGHT - (iconTall / 2));
		iconWide += XRES(7);
	}
	
	m_pText->setPos( TIPS_XSTEP + iconWide, TIPS_BASE_HEIGHT - (pFont->getTall() / 2));	
}