Talk:VGUI2: Creating a panel
Hopefully somebody will reformat the text. Btw.: There is still no <cpp> tag!
Text reformatted. --AiusEpsi 15:19, 3 Jul 2005 (PDT)
- There is a <code> tag. MightyMooquack 15:32, 3 Jul 2005 (PDT)
- And a cpp tag is much cooler: It has C++ syntax highlighting. Examples: SourceWiki.org --Leon Grapenthin 09:35, 6 Jul 2005 (PDT)
- Is SourceWiki down? Because I can't access it anymore --Pon
- I used <source lang="cpp"> --M3t0r 20:56, 28 January 2010 (UTC)
- And a cpp tag is much cooler: It has C++ syntax highlighting. Examples: SourceWiki.org --Leon Grapenthin 09:35, 6 Jul 2005 (PDT)
Has anybody been able to follow this and get it to work? I'm having trouble and getting a error...
MyPanel.cpp(78) : fatal error C1010: unexpected end of file while looking for precompiled header directive
I tried compiling it after the modification to vgui_int.cpp when it says to run the game. Anybody having the same problem or am I just royally screwing up?
you need to #include "cbase.h" Ts2do
solution??
This is how I solved the previous problem:
fatal error C1010: unexpected end of file while looking for precompiled header directive
- name your file CMyPanel.cpp not a MyPanel.cpp
- add following headers:
#include "cbase.h" #include "IMyPanel.h" using namespace vgui; #include <vgui/IVGui.h> #include <vgui_controls/Frame.h>
- comment following virtual functions (there is no implementation??):
// virtual void OnTick(); // virtual void OnCommand(const char* pcCommand);
- Warning: Commenting out 'virtual void OnTick(); will prevent you from making a console command for the panel. --Brad Newsom 18:45, 3 Jan 2009 (PST)
IMyPanel.h
Why IMyPanel.h? Why not just MyPanel.h? Wouldn't it be less confusing if we took out the random insignificant things that make people needlessly wonder "why"? Isn't it best to keep things simple and straight forward? Especialy in tutorials? --Gijimbo 09:02, 1 June 2007 (MDT)
Ok so I'm guessing it's because they were following the "IClientPanel.h" and other "Iblahblah.h" naming conventions. But I still have the same question: why? --Gijimbo 09:20, 1 June 2007 (MDT)
Ok, what's the deal with IMyPanel.h in general, does it just provide a supporting class? Do all panels need an I(nterface)? --TheDistur 21:53, 18 Aug 2007 (PDT)
- Basically, it's an include that gives the other source files access to the panel you've created. That's what the
extern
part is doing - giving any code that#include
's the file access to the panel. --Daedalus 02:28, 19 Aug 2007 (PDT)- It just exposes the create(parent) and destroy() functions eh? If I have any more questions can I just shoot an email to the address on your user page? I don't want to talk about what might be obvious to most of you coders forever on the Talk page. --TheDistur 12:50, 19 Aug 2007 (PDT)
- Correct. Basically, for a panel to be able to be used, it must be created (
mypanel->Create(gameParent);
) and to stop memory leaks, destroyed when no longer used. - As to posting further questions, I'd prefer if you asked the questions here, because other people might have exactly the same questions as yourself, and the answers would help them too. --Daedalus 05:32, 20 Aug 2007 (PDT)
- Correct. Basically, for a panel to be able to be used, it must be created (
- It just exposes the create(parent) and destroy() functions eh? If I have any more questions can I just shoot an email to the address on your user page? I don't want to talk about what might be obvious to most of you coders forever on the Talk page. --TheDistur 12:50, 19 Aug 2007 (PDT)
Calling the panel
Ok so after following the different bits and pieces of corrections and helps that you guys have offered, I finaly got it to compile. Alas, the game menu was no different and "MyPanel" was nowhere to be found. I have the feeling that the "calling the panel" section is what needs attention; serious attention. If someone who has gotten the tut to work would post their whole modified working vgui_int.cpp file, I wouldn't mind revising the "calling the panel" section to make it more understandable/workable. --Gijimbo 09:08, 1 June 2007 (MDT)
I got the panel to show up but when increase the screen resolution the title of the panel becomes huge. When I open the panel editor it's title and numerous other text areas are huge as well. Any suggestions? I'm guessing it's in one of the res files used. --Gijimbo 10:14, 1 June 2007 (MDT)
Adding mypanel->Create(gameParent);
(This is Inside of Calling the Panel)
Where is this added? It just says "Add it after you include" (which never tells you what to include, I'm assuming were including IMyPanel.h)
Can anyone point me to what line or section it should be added into?
--LordNed
Menu Call Is not working
I followed this guide and added the code to make it called from a main menu option, but when I click on the option nothing happens, I just get the click sound. Is the coding for Orange Box different somehow for menu calls?
EDIT:
I got it, keep forgetting my bins copy to a different folder then my mod lol. Moved em over, added a few res files and now it works.
Calling Panel In game.
I have looked around and I can not seem to figure out where to put the code for showing the panel in game. Any help with this would be very helpful.
--Xioyn
My panel won't show up in Debug mode
So...i created the panel, had a resource file for it and all that but, when i run debug mode, i get the console, bring up the editor (Ctrl+Shift+alt+B) list the panel hierarchy and...nothing (i get the hierarchy but my panel doesn't show up anywhere in there). Does anyone have any idea why that might be happening? Sorry for the novice question, i am new to Source SDK.
error LNK2001: unresolved external symbol
.. have some errors on Visual Studio 2010:
Error 1 error LNK2001: unresolved external symbol "protected: virtual void __thiscall CMyPanel::OnCommand(char const *)" (?OnCommand@CMyPanel@@MAEXPBD@Z) C:\Program Files\....\client\MyPanel.obj Client Episodic
Error 2 error LNK2001: unresolved external symbol "protected: virtual void __thiscall CMyPanel::OnTick(void)" (?OnTick@CMyPanel@@MAEXXZ) C:\Program Files\....\client\MyPanel.obj Client Episodic
Error 3 error LNK2001: unresolved external symbol "class IMyPanel * mypanel" (?mypanel@@3PAVIMyPanel@@A) C:\Program Files\....\client\vgui_int.obj Client Episodic
Error 4 error LNK1120: 3 unresolved externals C:\Program Files\....\Release_episodic\Client.dll 1 1 Client Episodic
I add "kernel32.lib;user32.lib;" in Additional Dependencies (Linker -> Input), but it's not help.
Error is confirmed on Visual C++ Express 2008 too.
But I only have the two protected functions as error.
HL2MP Code, Source 2007 Engine. These are the only errors or warning I have in my code.
BuyPanel.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CBuyPanel::OnCommand(char const *)" (?OnCommand@CBuyPanel@@UAEXPBD@Z)
BuyPanel.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CBuyPanel::OnTick(void)" (?OnTick@CBuyPanel@@UAEXXZ)
Quick Fix
This error is because you have told the compiler that you are going to override these functions (OnTick and OnCommand) but you have not provided any definitions. The linker can't find them because you haven't written them. Put a pair of brackets '{}' after the definition, or define the functions at the bottom of your panel cpp page. as in:
//CMyPanel.cpp
#include "cbase.h"
...
class CMyPanel : public vgui::Frame
{
...
protected:
// VGUI overrides
virtual void OnTick();
virtual void OnCommand(const char* pcCommand);
...
};
void CMyPanel::OnTick()
{
BaseClass::OnTick();
}
void CMyPanel::OnCommand(const char* pcCommand)
{
BaseClass::onCommand(pcCommand);
}
Chezz 20:55, 12 November 2010 (UTC)
Thank! But I still get the "error LNK2001: unresolved external symbol "class IMyPanel * mypanel" (?mypanel@@3PAVIMyPanel@@A) C:\Program Files\....\client\vgui_int.obj" error, Can anyone else help?
OKKWAMOS 02:57 02 April 2012 (GMT)
- That might seem a bit late since your post was 2 years ago, but I just had the same problem. In my case, that error showed up on the Episodic project, because I was working on HL2 only. After copying header and source files into the Episodic project the error went away. vgui_int.cpp is the same in both projects, but initially the external symbol was defined only within HL2. Hope that clears things up a bit. --ArmsOfSorrow 16:39, 14 April 2014 (UTC)
Panel wont disapear
I'm pretty sure all the codes in, the panel apears in game but if i assign a button with the command turnoff it wont disapear when i press it
.res File Names
In December 2013, the resource file had to have an all-lower-case name to get the VGUI Build Mode Editor use it. If not, the editor would create an all-lower-case.res file and put its changes in that. --dave
Not able to load client DLL after finishing this tutorial
After I added the code from this tutorial to my mod and built it, the engine stoped being able to load my game DLLs. I have no idea why this could be happening to me and from what I have seen, I'm the only one this seems to be happening to. If anyone can help what would be great. -TwoTails
EDIT: I fixed it. it turns out I put some code in the wrong spot lol -TwoTails
an error
apparently some command fails while compiling
this is the full error:
The command "if EXIST ..\lib\public\.\mathlib.lib ( for /f "delims=" %%A in ('attrib "..\lib\public\.\mathlib.lib"') do set valveTmpIsReadOnly="%%A" ) else ( if not EXIST ..\lib\public\. mkdir ..\lib\public\. ) set valveTmpIsReadOnlyLetter=%valveTmpIsReadOnly:~6,1% if "%valveTmpIsReadOnlyLetter%"=="R" ( attrib -r ..\lib\public\.\mathlib.lib ..\devtools\bin\gnu\touch.exe -d "1999-01-01" ..\lib\public\.\mathlib.lib attrib +r ..\lib\public\.\mathlib.lib ) if exist "..\devtools\bin\vpc.exe" "..\devtools\bin\vpc.exe" -crc2 "mathlib.vcxproj" if ERRORLEVEL 1 exit /b 1 :VCEnd" exited with code 1.
i am very new to this, can anyone help? -trolleybus
edit: apparently its not an issue with the panel code, i still need help though
Potentially Too Verbose?
Some sections could be helped by removing unnecessary code blocks, and simplifying the instructions (and being more specific).
Instead of saying...
Place this code
void ArbitraryFunctionB( void )
{
//something...
}
Beneath this code
void ArbitraryFunctionA( void )
{
//something else...
}
It may be better to just say
Place the following code beneath ArbitraryFunctionA( void ) inside RelevantClass()
void ArbitraryFunctionB( void )
{
//something...
}
Just a thought, since I got confused first time reading later sections of the tutorial. Many pages suffer from this in my opinion, at least when it comes to people like me who easily trip over words, haha. I see that similar problems have come up so it does seem this page could benefit. --KaliDitzy (talk) 13:02, 21 December 2023 (PST)