Exemplo n.º 1
0
bool UISliderPlus::SetClassProperties(const TRDescription& inDesc, Panel* inPanel, CSchemeManager* inSchemeManager)
{
	UIPanel::SetClassProperties(inDesc, inPanel, inSchemeManager);
	
	// Read lower and upper limits
	int theLowerValue = 0;
	int theUpperValue = 20;
	
    inDesc.GetTagValue(UILowerValue, theLowerValue);
    inDesc.GetTagValue(UIUpperValue, theUpperValue);
	
	SliderPlus* theSlider = dynamic_cast<SliderPlus*>(inPanel);
	ASSERT(theSlider);
	theSlider->setRange(theLowerValue, theUpperValue);
	
	int theRangeWindow;
	if(inDesc.GetTagValue(UIRangeWindow, theRangeWindow))
	{
		// The range window is in pixels, the lower and upper values are in their own arbitrary scale
		//int theValueRange = theUpperValue - theLowerValue;
		//ASSERT(theRangeWindow < theValueRange);
		//theSlider->setRangeWindowEnabled(true);
		theSlider->setRangeWindow(theRangeWindow);
	}
	
	int theStartingValue;
	if(inDesc.GetTagValue(UIDefaultIntValue, theStartingValue))
	{
		theSlider->setValue(theStartingValue);
	}

	return true;
}
////////////////////////////////////
// AvHLogoutComponent -> StaticLabel //
////////////////////////////////////
void AvHUILogoutComponent::AllocateComponent(const TRDescription& inDesc)
{
    // Width and height (normalized screen coords)
    float theWidth = UIDefaultWidth;
    float theHeight = UIDefaultHeight;
    inDesc.GetTagValue(UITagWidth, theWidth);
    inDesc.GetTagValue(UITagHeight, theHeight);
	
    this->mLogoutComponent = new AvHLogoutComponent(theWidth*ScreenWidth(), theHeight*ScreenHeight());
}
Exemplo n.º 3
0
//////////////////////////
// SpritePanel -> Panel //
//////////////////////////
void UISpritePanel::AllocateComponent(const TRDescription& inDesc)
{
	string theBaseSpriteName;
    inDesc.GetTagValue(UIBaseSprite, theBaseSpriteName);

	string theRenderMode;
    inDesc.GetTagValue(UIRenderMode, theRenderMode);
	
    this->mUISpritePanel = new SpritePanel(theBaseSpriteName, theRenderMode);

	string theVAlignment;
    if(inDesc.GetTagValue(UIVAlignment, theVAlignment))
	{
		this->mUISpritePanel->SetVAlignment(theVAlignment);
	}
}
Exemplo n.º 4
0
bool AvHUIActionButtons::SetClassProperties(const TRDescription& inDesc, Panel* inComponent, CSchemeManager* inSchemeManager)
{
    bool theSuccess = false;
    AvHActionButtons* theActionButtons = dynamic_cast<AvHActionButtons*>(inComponent);
	ASSERT(theActionButtons);

    // read custom attributes here
    UIPanel::SetClassProperties(inDesc, inComponent, inSchemeManager);

    // Get tech font to use
    std::string theSchemeName;
    if(inDesc.GetTagValue(UITagScheme, theSchemeName))
    {
		const char* theSchemeCString = theSchemeName.c_str();
		SchemeHandle_t theSchemeHandle = inSchemeManager->getSchemeHandle(theSchemeCString);
		Font* theFont = inSchemeManager->getFont(theSchemeHandle);
		if(theFont)
		{
			theActionButtons->setFont(theFont);
		}
		
		theSuccess = true;
    }
	
    return theSuccess;
}
Exemplo n.º 5
0
bool AvHUITeamHierarchy::SetClassProperties(const TRDescription& inDesc, Panel* inComponent, CSchemeManager* inSchemeManager)
{
    bool theSuccess = false;

    // read custom attributes here
    UIStaticLabel::SetClassProperties(inDesc, inComponent, inSchemeManager);

    // Get font to use
    std::string theSchemeName;
    if(inDesc.GetTagValue(UITagScheme, theSchemeName))
    {
        AvHTeamHierarchy* theHierarchy = dynamic_cast<AvHTeamHierarchy*>(inComponent);
        if(theHierarchy)
        {
            const char* theSchemeCString = theSchemeName.c_str();
            SchemeHandle_t theSchemeHandle = inSchemeManager->getSchemeHandle(theSchemeCString);
        	Font* theFont = inSchemeManager->getFont(theSchemeHandle);
            if(theFont)
            {
                theHierarchy->setFont(theFont);
            }

            theSuccess = true;
        }
    }

    return theSuccess;
}
bool AvHUILogoutComponent::SetClassProperties(const TRDescription& inDesc, Panel* inPanel, CSchemeManager* inSchemeManager)
{
    AvHLogoutComponent* theLogoutComponent = (AvHLogoutComponent*)inPanel;
	
    bool theSuccess = UIStaticLabel::SetClassProperties(inDesc, inPanel, inSchemeManager);
    
    if(theSuccess)
    {
		// Get font to use
		std::string theSchemeName;
		if(inDesc.GetTagValue(UITagScheme, theSchemeName))
		{
			const char* theSchemeCString = theSchemeName.c_str();
			SchemeHandle_t theSchemeHandle = inSchemeManager->getSchemeHandle(theSchemeCString);
			Font* theFont = inSchemeManager->getFont(theSchemeHandle);
			if(theFont)
			{
				theLogoutComponent->setFont(theFont);
			}
		}
		theSuccess = true;
	}

	return theSuccess;
}
Exemplo n.º 7
0
///////////////////////////
// ColoredPanel -> Panel //
///////////////////////////
void UIColoredPanel::AllocateComponent(const TRDescription& inDesc)
{
    // Position (normalized screen coords)
    float theXPos = UIDefaultXPos;
    float theYPos = UIDefaultYPos;
    inDesc.GetTagValue(UITagXPos, theXPos);
    inDesc.GetTagValue(UITagYPos, theYPos);
	
    // Width and height (normalized screen coords)
    float theWidth = UIDefaultWidth;
    float theHeight = UIDefaultHeight;
    inDesc.GetTagValue(UITagWidth, theWidth);
    inDesc.GetTagValue(UITagHeight, theHeight);
	
    this->mUIColoredPanel = new ColoredPanel(theXPos*ScreenWidth(), theYPos*ScreenHeight(), theWidth*ScreenWidth(), theHeight*ScreenHeight());
}
Exemplo n.º 8
0
// Set up default scheme values if a scheme was specified (overrides other tags specified)
void UIManager::SetSchemeValues(const TRDescription& inDesc, UIComponent* inComponent, CSchemeManager* inSchemeManager)
{
    std::string theSchemeName;
    if(inDesc.GetTagValue(UITagScheme, theSchemeName))
    {
        // Get the vgui panel inside
        Panel* thePanelPointer = inComponent->GetComponentPointer();

        // Get the scheme specified in the layout
        const char* theSchemeCString = theSchemeName.c_str();
        SchemeHandle_t theSchemeHandle = inSchemeManager->getSchemeHandle(theSchemeCString);
        int r, g, b, a;
        
        // Set fg color
        inSchemeManager->getFgColor(theSchemeHandle, r, g, b, a);
        thePanelPointer->setFgColor(r, g, b, a);

        // Set bg color
        inSchemeManager->getBgColor(theSchemeHandle, r, g, b, a);
        thePanelPointer->setBgColor(r, g, b, a);

        // Set font if applicable
    	vgui::Font* theFont = inSchemeManager->getFont(theSchemeHandle);
        vgui::TextPanel* theTextPanel = dynamic_cast<vgui::TextPanel*>(thePanelPointer);
        if(theFont && theTextPanel)
        {
            theTextPanel->setFont(theFont);
        }
    }
}
Exemplo n.º 9
0
///////////////////////////
// TreeFolder -> Panel //
///////////////////////////
void UITreeFolder::AllocateComponent(const TRDescription& inDesc)
{
    string thePathName = UIDefaultPathName;
    inDesc.GetTagValue(UITagPathName, thePathName);

    this->mUITreeFolder = new TreeFolder(thePathName.c_str());
}
Exemplo n.º 10
0
bool UILabel::SetClassProperties(const TRDescription& inDesc, Panel* inPanel, CSchemeManager* inSchemeManager)
{
    bool theSuccess = true;
	
    Label* theLabel = (Label*)inPanel;
	
    theSuccess = UIPanel::SetClassProperties(inDesc, inPanel, inSchemeManager);
    
    if(theSuccess)
    {
        string theAlignmentString;
        if(inDesc.GetTagValue(UITagAlignment, theAlignmentString))
        {
            // Convert the alignment from a string to the label enum
            Label::Alignment theAlignment = vgui::Label::a_center;
            UIStringToAlignment(theAlignmentString, theAlignment);
            theLabel->setContentAlignment(theAlignment);
        }
		
        string theTitle;
        if(inDesc.GetTagValue(UITagText, theTitle))
        {
			string theDefaultText("");
			LocalizeString(theTitle.c_str(), theDefaultText);
			
			theLabel->setText((int)theDefaultText.length(), theDefaultText.c_str());
        }
		
		// Get font to use
		std::string theSchemeName;
		if(inDesc.GetTagValue(UITagScheme, theSchemeName))
		{
			const char* theSchemeCString = theSchemeName.c_str();
			SchemeHandle_t theSchemeHandle = inSchemeManager->getSchemeHandle(theSchemeCString);
			Font* theFont = inSchemeManager->getFont(theSchemeHandle);
			if(theFont)
			{
				theLabel->setFont(theFont);
			}
				
			theSuccess = true;
		}
    }
	
    return theSuccess;
}
Exemplo n.º 11
0
//////////////////////////
// ProgressBar -> Panel //
//////////////////////////
void UIProgressBar::AllocateComponent(const TRDescription& inDesc)
{
    int theSegmentCount = UIDefaultProgressBarSegments;

    inDesc.GetTagValue(UITagSegments, theSegmentCount);

    this->mUIProgressBar = new ProgressBar(theSegmentCount);
}
Exemplo n.º 12
0
/////////////////////////
// SliderPlus -> Panel //
/////////////////////////
void UISliderPlus::AllocateComponent(const TRDescription& inDesc)
{
	float theX = 0;
	float theY = 0;
	float theWidth = 50;
	float theHeight = 50;
	bool theIsVertical = false;
	
	inDesc.GetTagValue(UITagXPos, theX);
	inDesc.GetTagValue(UITagYPos, theY);
	inDesc.GetTagValue(UITagWidth, theWidth);
	inDesc.GetTagValue(UITagHeight, theHeight);
	inDesc.GetTagValue(UIIsVertical, theIsVertical);
	
	int theScreenWidth = ScreenWidth();
	int theScreenHeight = ScreenHeight();
    this->mUISliderPlus = new SliderPlus(theX*theScreenWidth, theY*theScreenHeight, theWidth*theScreenWidth, theHeight*theScreenHeight, theIsVertical);
}
Exemplo n.º 13
0
////////////////////
// Label -> Panel //
////////////////////
void UILabel::AllocateComponent(const TRDescription& inDesc)
{
	string theTitle;
    inDesc.GetTagValue(UITagText, theTitle);

    string theDefaultText;
	LocalizeString(theTitle.c_str(), theDefaultText);
	
    this->mUILabel = new Label(theDefaultText.c_str());
}
Exemplo n.º 14
0
/////////////////////////
// ImageLabel -> Label //
/////////////////////////
void UIImageLabel::AllocateComponent(const TRDescription& inDesc)
{
    float theXPos, theYPos;
    int theWidth, theHeight;
    string theImageName("ru");

    UIGetPosition(inDesc, theXPos, theYPos, theWidth, theHeight);
    inDesc.GetTagValue(UITagImage, theImageName);

    // Construct it!
    this->mUIImageLabel = new CImageLabel(theImageName.c_str(), theXPos*ScreenWidth(), theYPos*ScreenHeight(), theWidth, theHeight);
}
Exemplo n.º 15
0
void UIPieMenu::AllocateComponent(const TRDescription& inDesc)
{
    float theXPos, theYPos;
    int theWidth, theHeight;
    string theImageName("default");

    UIGetPosition(inDesc, theXPos, theYPos, theWidth, theHeight);

    string theRootName;
    inDesc.GetTagValue(UIRootName, theRootName);

    this->mPieMenu = new PieMenu(theRootName, theXPos*ScreenWidth(), theYPos*ScreenHeight(), theWidth*ScreenWidth(), theHeight*ScreenHeight());
}
Exemplo n.º 16
0
//////////////////////////
// StaticLabel -> Label //
//////////////////////////
void UIStaticLabel::AllocateComponent(const TRDescription& inDesc)
{
	string theTitle;
    inDesc.GetTagValue(UITagText, theTitle);

	string theDefaultText("");
	LocalizeString(theTitle.c_str(), theDefaultText);
	
    // Position (normalized screen coords)
    float theXPos = UIDefaultXPos;
    float theYPos = UIDefaultYPos;
    inDesc.GetTagValue(UITagXPos, theXPos);
    inDesc.GetTagValue(UITagYPos, theYPos);
	
    // Width and height (normalized screen coords)
    float theWidth = UIDefaultWidth;
    float theHeight = UIDefaultHeight;
    inDesc.GetTagValue(UITagWidth, theWidth);
    inDesc.GetTagValue(UITagHeight, theHeight);
	
    this->mUIStaticLabel = new StaticLabel(theDefaultText.c_str(), theXPos*ScreenWidth(), theYPos*ScreenHeight(), theWidth*ScreenWidth(), theHeight*ScreenHeight());
}
Exemplo n.º 17
0
/////////////////////
// Button -> Label //
/////////////////////
void UIButton::AllocateComponent(const TRDescription& inDesc)
{
    float theXPos, theYPos;
    int theWidth, theHeight;
    UIGetPosition(inDesc, theXPos, theYPos, theWidth, theHeight);
	
	string theTitle;
    inDesc.GetTagValue(UITagText, theTitle);

    string theDefaultText;
	LocalizeString(theTitle.c_str(), theDefaultText);
	
    this->mUIButton = new Button(theDefaultText.c_str(), theXPos*ScreenWidth(), theYPos*ScreenHeight(), theWidth, theHeight);
}
Exemplo n.º 18
0
/////////////////////////////////////
// FadingImageLabel -> CImageLabel //
/////////////////////////////////////
void UIFadingImageLabel::AllocateComponent(const TRDescription& inDesc)
{
    float theXPos, theYPos;
    int theWidth = ScreenWidth();
    int theHeight = ScreenHeight();
    string theImageName("default");

    UIGetPosition(inDesc, theXPos, theYPos, theWidth, theHeight);
    inDesc.GetTagValue(UITagImage, theImageName);

    // Construct it!
    //this->mUIFadingImageLabel = new FadingImageLabel(theImageName.c_str(), theXPos*ScreenWidth, theYPos*ScreenHeight, theWidth, theHeight);
    //this->mUIFadingImageLabel = new FadingImageLabel(theImageName.c_str(), theXPos*ScreenWidth, theYPos*ScreenHeight);
    //this->mUIFadingImageLabel = new FadingImageLabel(theXPos*ScreenWidth, theYPos*ScreenHeight);
    this->mUIFadingImageLabel = new FadingImageLabel(0, 0);
}
Exemplo n.º 19
0
// Not virtual, this is meant to act only on the class specified.  Operate on panel because that is
// the lowest level of hierarchy (not that we're going to do anything with it anyways)
bool UIPieMenu::SetClassProperties(const TRDescription& inDesc, Panel* inComponent, CSchemeManager* inSchemeManager)
{
    bool theSuccess;

    // Let parent classes go first
    theSuccess = UIPanel::SetClassProperties(inDesc, inComponent, inSchemeManager);

    if(theSuccess)
    {
        // Dynamic_cast inComponent to an PieMenu (will always succeed)
        PieMenu* thePieMenu = (PieMenu*)inComponent;

        // Read font if specified
        std::string theSchemeName;
        if(inDesc.GetTagValue(UITagScheme, theSchemeName))
        {
            if(thePieMenu)
            {
                const char* theSchemeCString = theSchemeName.c_str();
                SchemeHandle_t theSchemeHandle = inSchemeManager->getSchemeHandle(theSchemeCString);
                Font* theFont = inSchemeManager->getFont(theSchemeHandle);
                if(theFont)
                {
                    thePieMenu->SetFont(theFont);
                    thePieMenu->GetRootNode()->setFont(theFont);
                }
            }
        }

        // Set colors of root node to that of the pie menu
        Color theColor;
        thePieMenu->getFgColor(theColor);
        thePieMenu->GetRootNode()->setFgColor(theColor);

        thePieMenu->getBgColor(theColor);
        thePieMenu->GetRootNode()->setBgColor(theColor);

        // Read node distances
        float theNodeXDistance = 0.0f;
        inDesc.GetTagValue(kPieMenuNodeXDistance, theNodeXDistance);
        float theNodeYDistance = 0.0f;
        inDesc.GetTagValue(kPieMenuNodeYDistance, theNodeYDistance);
        thePieMenu->SetNodeDistance(theNodeXDistance, theNodeYDistance);

        // Set pop-up menu default image
        string theDefaultImage;
        if(inDesc.GetTagValue(kPieMenuDefaultImage, theDefaultImage))
        {
            thePieMenu->SetDefaultImage(theDefaultImage);
        }

        // Read specified image to use
        //string theNodeTargaName;
        //if(inDesc.GetTagValue(kNodeTarga, theNodeTargaName))
        //{
        //    thePieMenu->SetNodeTargaName(theNodeTargaName);
        //}

        // Now read in the nodes until there are no more.  Assumes first node is root.
        thePieMenu->GetRootNode()->SetSizeKeepCenter(theNodeXDistance*ScreenWidth(), theNodeYDistance*ScreenHeight());

        StringVector theNodeList;
        inDesc.GetTagStringList(kPieMenuNodePrefix, theNodeList);
        for(StringVector::iterator theIter = theNodeList.begin(); theIter != theNodeList.end(); theIter++)
        {
            thePieMenu->AddNode(*theIter);
        }

        // Set the connector, if any
        string theConnectorName;
        if(inDesc.GetTagValue(UIConnectorName, theConnectorName))
        {
            if(theConnectorName != "")
            {
                this->mPieMenu->SetConnectorName(theConnectorName);
            }
        }

        // Now have the piemenu recompute visible size for all nodes
        thePieMenu->RecomputeVisibleSize();

//        for(int i = 0; ; i++)
//        {
//            char theNum[4];
//            sprintf(theNum, "%d", i);
//            string theNodeName(kPieMenuNodePrefix + string(theNum));
//
//            string theNodeString;
//            if(inDesc.GetTagValue(theNodeName, theNodeString))
//            {
//                thePieMenu->AddNode(theNodeString);
//            }
//            else
//            {
//                break;
//            }
//        }

        // Tell it we're done
        thePieMenu->SetConstructionComplete();

        // Make sure to propagate new position to all children.  Children may have been added
        // after the position was set so just make sure to re-set the position before we leave now
        // that all children have been added.
    }

    return theSuccess;
}
Exemplo n.º 20
0
bool UIPanel::SetClassProperties(const TRDescription& inDesc, Panel* inPanel, CSchemeManager* inSchemeManager)
{
    bool theArgOne, theArgTwo;

    UIComponent::SetClassProperties(inDesc, inPanel, inSchemeManager);

    // Position (normalized screen coords)
    float theXPos = UIDefaultXPos;
    float theYPos = UIDefaultYPos;
    theArgOne = inDesc.GetTagValue(UITagXPos, theXPos);
    theArgTwo = inDesc.GetTagValue(UITagYPos, theYPos);
    if(theArgOne || theArgTwo)
    {
        inPanel->setPos(theXPos*ScreenWidth(), theYPos*ScreenHeight());
    }

    // Width and height (normalized screen coords)
    float theWidth = UIDefaultWidth;
    float theHeight = UIDefaultHeight;
    theArgOne = inDesc.GetTagValue(UITagWidth, theWidth);
    theArgTwo = inDesc.GetTagValue(UITagHeight, theHeight);
    if(theArgOne || theArgTwo)
    {
        inPanel->setSize(theWidth*ScreenWidth(), theHeight*ScreenHeight());
    }

    // Preferred size (normalized screen coords)
    float thePreferredWidth = UIDefaultPreferredWidth;
    float thePreferredHeight = UIDefaultPreferredHeight;
    theArgOne = inDesc.GetTagValue(UITagPreferredWidth, thePreferredWidth);
    theArgTwo = inDesc.GetTagValue(UITagPreferredHeight, thePreferredHeight);
    if(theArgOne || theArgTwo)
    {
        inPanel->setPreferredSize(thePreferredWidth*ScreenWidth(), thePreferredHeight*ScreenHeight());
    }

    // Background color (rgba)
    string theColorString;
    if(inDesc.GetTagValue(UITagBGColor, theColorString))
    {
        Color theColor;
        UIStringToColor(theColorString, theColor);
        inPanel->setBgColor(theColor);
    }

    // Foreground color (rgba)
    if(inDesc.GetTagValue(UITagFGColor, theColorString))
    {
        Color theColor;
        UIStringToColor(theColorString, theColor);
        inPanel->setFgColor(theColor);
    }

    // Default visibility (bool)
    bool theTempBool = UIDefaultVisibility;
    if(inDesc.GetTagValue(UITagVisible, theTempBool))
    {
        inPanel->setVisible(theTempBool);
    }

    // Remember the comp name
    this->SetName(inDesc.GetName());

    return true;
}