Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding

Reply
 
Thread Tools Display Modes
Old 07-23-2012, 11:55 AM   #1
frostcat
 
Join Date: Aug 2007
Reputation: 9
Posts: 567
VGUI usage questions



I am attempting to have one checkbutton disable the other when it is checked.
I know how to control each element in my panel.cpp:

Code:
	
///Constructor of my panel
m_pTime = new vgui::CheckButton(this, "Check1", "Test");
	m_pTime->SetPos(100, 400);
	m_pTime->SetSize(200, 50);

	m_pTime2 = new vgui::CheckButton(this, "Check2", "Test2");
	m_pTime2->SetPos(100, 600);
	m_pTime2->SetSize(200, 50);	
	m_pTime2->SetEnabled(false);

But how to I call SetEnabled for a checkbutton based on interaction with another element? I found this function in checkbutton.cpp which looks useful:
Code:
void CheckButton::OnCheckButtonChecked(Panel *panel)
{
}
How am I supposed to use it? Am I a supposed to derive my own clone for each element?
frostcat is offline  
Reply With Quote
Old 07-24-2012, 03:50 PM   #2
frostcat
 
Join Date: Aug 2007
Reputation: 9
Posts: 567
Investigated a bit more and found OnMousePressed in the Panel class. When I want to call it in Checkbutton it says ERROR: inherited member is not allowed




Code:
void CheckButton::OnMousePressed(MouseCode code)
{
}

Checkbutton should inherit all public functions from panel or am I not getting something?
frostcat is offline   Reply With Quote
Old 07-25-2012, 12:23 PM   #3
frostcat
 
Join Date: Aug 2007
Reputation: 9
Posts: 567
After more research I got this far:

In my panel class
Code:
 private:
 	//Other used VGUI control Elements:
	vgui::CheckButton* m_pTime; // Panel class declaration, private section
	vgui::CheckButton* m_pTime2; 

	vgui::Button	*exitbutton;

 public:
	 MESSAGE_FUNC_PARAMS( OnCheck1Checked, "CheckButtonChecked", data );

Code:
MESSAGE_FUNC_PARAMS( OnCheck1Checked, "CheckButtonChecked", data );
I do not understand this piece but I know that it successfully detects wether the check buttons are pressed. The problem is, it fires for every checkbutton.



Code:
void CMyPanel::OnCheck1Checked( KeyValues *data )
{
	//check which checkbutton pointer is used so that it can fire different things depending on which checkbutton was checked.
}
So, how to check within this function which checkbutton is checked? I basically need to check wether it was m_pTime or m_pTime2.
frostcat is offline   Reply With Quote
Old 07-26-2012, 12:26 AM   #4
Sandern
 
 
 
Join Date: Jun 2009
Reputation: 34
Posts: 101
CheckButtonList.cpp contains an example on how to use that message function.

You can get the checkbutton from the panel parameter:
Code:
vgui::Panel *pPanel = (vgui::Panel *)data->GetPtr( "panel" );
Sandern is offline   Reply With Quote
Old 07-26-2012, 04:48 AM   #5
frostcat
 
Join Date: Aug 2007
Reputation: 9
Posts: 567
Using it as is crashes the game in the main menu which I think is a broken pointer.



Code:
void CMyPanel::OnCheck1Checked( KeyValues *data )
{
	vgui::Panel *pPanel = (vgui::Panel *)data->GetPtr( "panel" );

	if ( FStrEq( pPanel->GetName(), "Check1" ) )	
	{
	Msg("Name is check1\n");
	}
	else
	{
		Msg("Name is not check1\n");
	}
	
		
}
frostcat is offline   Reply With Quote
Old 07-26-2012, 01:38 PM   #6
frostcat
 
Join Date: Aug 2007
Reputation: 9
Posts: 567
Fixed the problem after reading the VGUI documentation closely, a few times.
https://developer.valvesoftware.com/..._Documentation

Another problem I have is that I want to create a CModelPanel. However the compiler says:
error C2039: 'CModelPanel' : is not a member of 'vgui'


The problem has to be a missing include or something.

Class declaration my panel
Code:
 private:
 	//Other used VGUI control Elements:
	vgui::CheckButton* m_pTime; // Panel class declaration, private section
	vgui::CheckButton* m_pTime2; 

	vgui::Button	*exitbutton;
	vgui::ComboBox	*calibercombo;
	vgui::CModelPanel	*bulletpanel;
All of them work excetp CModel. I have checked where it is declared and I included all includes from basemodelpanel.cpp and it still can not find it.
frostcat is offline   Reply With Quote
Old 07-27-2012, 08:22 AM   #7
frostcat
 
Join Date: Aug 2007
Reputation: 9
Posts: 567
Again ran into this error:

ERROR: inherited member is not allowed

In my panel
Code:
void CMyPanel::ApplySchemeSettings(IScheme *pScheme)
{
	BaseClass::ApplySchemeSettings(pScheme);

	pScheme->GetFont( "Trebuchet18" );
}
Header file
Code:
class MyPanel
{
public:
	virtual void		Create( vgui::VPANEL parent ) = 0;
	virtual void		Destroy( void ) = 0;

protected:
	virtual void		ApplySchemeSettings( vgui::IScheme *pScheme );
	
	
	
};
What is causing it? I checked an compared my code to other occurences in the code who use it in the exact same way.
frostcat is offline   Reply With Quote
Reply

Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -7. The time now is 04:59 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site Content Copyright Valve Corporation 1998-2014, All Rights Reserved.