PDA

View Full Version : Parent Frame occludes sub frames


Penumbra
06-27-2007, 02:25 AM
Hello all,

I'm having some problems with the creation of a global frame that provides information to the user.

The frame is build up with two child frames. These child frames lie within the boundaries of the main panel. The child frames have their own res-file and should display their own content but whenever the main frame closes (pressing the x in the top-right corner) they should all set to invisible.

This is all well, except for the annoying thing that when a frame or panel gets focussed by the player it will move to the front. In this case the main frame comes to the front when you press close. When we want to open the same frames again, the main frame occludes the child frames because it is focussed... :o

I've tried to SetZPos, but this doesn't work for this case. I've also tried to override the function MoveToFront, with no luck...

Does anyone of you know how to solve this problem? Thanks in advance!

Sander88
06-27-2007, 09:53 AM
The subframes should be panels. Frames are seperated windows.

Penumbra
06-28-2007, 03:34 AM
OK, but then there is the problem of not being able to load a res file for the panels....

Is there another method-call for panels to do this..?

Sander88
06-28-2007, 04:08 AM
When you create a new panel, you give it a name. You can add this name as an entry in the res file of your parent frame I believe.

Penumbra
06-28-2007, 04:55 AM
OK, but should I then place all the content of the panel inside the parent res-file, or is there a way to load a res-file manually?

lodle
06-28-2007, 09:46 AM
What you need to do is make a new class that inherits from panel but in the constucter pass in the res file as a char string. So now when you go to create these panels you can do it dynamicly.

Truth be told it will be better in the long run to code each panel by it self thus being able to handle events and have its on res file.

Penumbra
06-28-2007, 05:11 PM
I have such a class, but the problem is that I don't know how to read in this res-file. Are you saying that I have to read it in by the FileSystem?

And I want your 'Truth be told' part of the post, since I'm in it for the long run! ;)

lodle
06-28-2007, 06:51 PM
just load it in the constructer like any other panel

Penumbra
06-29-2007, 02:44 AM
OK, this is just my question:

HOW?! I only know how to load it in via Frames: LoadControlSettings( const char * )

lodle
06-29-2007, 11:56 AM
add that to the panel. :P

A frame is a version of a panel in the end.

Penumbra
06-30-2007, 03:25 AM
Well, that's the problem!
A panel doesn't have this method!!! :D

It's only declared in a frame. Which is logical in a way. A button is also a panel and we don't want users to create a res-file for a button (thereby loading the button with internal crap like another button).

So, anything else. Or is there another method I'm not seeing?!

Ging
06-30-2007, 05:22 AM
Well, that's the problem!
A panel doesn't have this method!!! :D

...

So, anything else. Or is there another method I'm not seeing?!

What you need to do is make a new class that inherits from panel but in the constucter pass in the res file as a char string. So now when you go to create these panels you can do it dynamicly.

The important bit in lodle's post is the mention of inheritance - create a new type of panel that works in general as a panel, but with an implementation for LoadControlSettings.

Penumbra
06-30-2007, 12:04 PM
While checking the Frame class within the Everything_SDK, I found a better solution:

Frame has a base class: EditablePanel!! This class has the properties I wanted!!

But thanks for the advice! :cool:

Penumbra
06-30-2007, 12:15 PM
The only bump in the road is that I can't dynamically fill the panel with the VGUI editor. So now I need to place objects by means of editing the res-file in a text editor... :rolleyes:

Well, I'll have to take that for granted! :)

Penumbra
07-02-2007, 11:35 AM
OK, skip the "I'll take that for granted" part in my previous thread! :mad:

It is a lot of work to get all the objects right in place with only the text editor to alter the placement. Maybe some of you know a better way. I'll sketch the structure I have:

I have three classes: 1 frame called C_HudEvaluationReport and 2 sub panels called C_HudEvaluationGlobal & C_HudEvaluationVictim. These all have their res-file HudEvaluationReport, HudEvaluationGlobal & HudEvaluationVictim respectively.

In the constructor of C_HudEvaluationReport (which inherits CHudElement and Frame):
C_HudEvaluationReport::C_HudEvaluationReport( const char *pElementName ) : CHudElement( pElementName ), BaseClass( NULL, "HudEvaluationReport" )
{
// Hook this HUD to the screen
Panel *pParent = g_pClientMode->GetViewport();
SetParent( pParent );

// Create the other panels and link them to this frame
new C_HudEvaluationGlobal( "HudEvaluationGlobal", this );
new C_HudEvaluationVictim( "HudEvaluationVictim", this );

// Set the looks of this frame to the overall looks
vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFile( "resource/SourceScheme.res", "SourceScheme" );
SetScheme( scheme );
LoadControlSettings( "Resource/UI/HudEvaluationReport.res" );
The constructors of the C_HudEvaluationVictim (and also C_HudEvaluationGlobal, which both inherit from EditablePanel) looks like this:
C_HudEvaluationVictim::C_HudEvaluationVictim( const char *pElementName, Panel *pParent ) : BaseClass( pParent, "HudEvaluationVictim" )
{
// Set the looks of this frame to the overall looks
vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFile( "resource/SourceScheme.res", "SourceScheme" );
SetScheme( scheme );

// Initialise the panel
BaseClass::SetDragEnabled( false );
After this, the objects are initialized and the LoadControlSettings method is called.

When I open the frame in-game, I get the objects that I've used in the res-files at the location I've given them, but I cannot focus those objects in the editable panels to change them in the VGUI editor...

The rightmost combobox inside the editor contains BuildDialog, HudEvaluationGlobal and HudEvaluationVictim.. What this means, I don't know... :confused:

I can only add new objects (Buttons, Labels, etc.) to the HudEvaluationReport.res, instead of the other res-files.

Does anyone have an idea of what I'm doing wrong? It would help me a lot! :D

Penumbra
07-06-2007, 04:24 AM
Well, I've edited the panels by means of a text editor, so the problem is 'solved'.... :rolleyes:

It works, but I still can't access the panels via the VGUI editor. If someone in the near future has discovered what should be altered to acces the panels, would he or she post it here?

Thanks in advance! :D