Example #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());
}
Example #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);
	}
}
Example #4
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());
}
Example #5
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);
        }
    }
}
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;
}
Example #7
0
///////////////////////////
// TreeFolder -> Panel //
///////////////////////////
void UITreeFolder::AllocateComponent(const TRDescription& inDesc)
{
    string thePathName = UIDefaultPathName;
    inDesc.GetTagValue(UITagPathName, thePathName);

    this->mUITreeFolder = new TreeFolder(thePathName.c_str());
}
Example #8
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;
}
Example #9
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;
}
Example #10
0
//////////////////////////
// ProgressBar -> Panel //
//////////////////////////
void UIProgressBar::AllocateComponent(const TRDescription& inDesc)
{
    int theSegmentCount = UIDefaultProgressBarSegments;

    inDesc.GetTagValue(UITagSegments, theSegmentCount);

    this->mUIProgressBar = new ProgressBar(theSegmentCount);
}
Example #11
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;
}
Example #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);
}
Example #13
0
// Read start block
// Set the name and type of the description
// Returns false if invalid format
bool TRFactory::readStartBlockLine(const string& inString, TRDescription& outDescription)
{
    bool theSuccess = false;
    char theType[maxLineLength];
    char theName[maxLineLength];

    memset(theType, ' ', maxLineLength);
    memset(theName, ' ', maxLineLength);

    // Read three tokens.  There should be "start" <type> <name>
    if(sscanf(inString.c_str(), "start %s %s", theType, theName) == 2)
    {
        outDescription.SetName(theName);
        outDescription.SetType(theType);
        theSuccess = true;
    }

    return theSuccess;
}
Example #14
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());
}
Example #15
0
bool TRFactory::WriteDescription(fstream& outfile, const TRDescription& inDescription)
{
    bool theSuccess = true;

    // Write out the start block
    outfile << "start" << " " << inDescription.GetType() << " " << inDescription.GetName() << std::endl;

    // Write out the property tags
    TRDescription::const_iterator theIter;
    for(theIter = inDescription.begin(); theIter != inDescription.end(); theIter++)
    {
        outfile << "    " << theIter->first << " = " << theIter->second << std:: endl;
    }

    // Write out the end block.
    outfile << "end" << std::endl;

    return theSuccess;
}
Example #16
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);
}
Example #17
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());
}
Example #18
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());
}
Example #19
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);
}
Example #20
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);
}
Example #21
0
bool TRFactory::readTagAndValueLine(const string& inString, TRDescription& outDescription)
{
    bool theSuccess = false;
    char theTag[maxLineLength];
    char theValue[maxLineLength];

    // Zero them out
    memset(theTag, ' ', maxLineLength);
    memset(theValue, ' ', maxLineLength);

    if((sscanf(inString.c_str(), "%s = %s", theTag, theValue)) == 2)
    {
        // Add it
        TRTagValuePair thePair(theTag, theValue);
        outDescription.AddPair(thePair);
        theSuccess = true;
    }

    return theSuccess;
}
Example #22
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;
}
Example #23
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;
}