Fixing VGUI Screens in Source 2013 Singleplayer

From Valve Developer Community
Revision as of 23:41, 29 October 2013 by HenryDorsett (talk | contribs) (Created page with "== About == This is a comprehensive guide to fixing the Source SDK 2013 mod in-game VGUI screens. Unlike my previous tutorial, for SDK 2013, this one does not give step-by-step ...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

About

This is a comprehensive guide to fixing the Source SDK 2013 mod in-game VGUI screens. Unlike my previous tutorial, for SDK 2013, this one does not give step-by-step directions on implementing the other two required fixes. This will be changed in the future, after I can put together the steps from between them into one well-written, cohesive, easy-to-understand set of instructions.

Step 1: Crash Fix

Follow the directions here: VGUI_Screen_Creation

Step 2: Interactivity

Follow the directions here: Interactive_Ingame_VGUI_Panels

Step 3: Client-Server Interface

So as to aid in the readability of this page, I've opted to put the actual code for the additional VGUI screen changes on my website. Simply download these and use them to replace your current ones: c_vguiscreen.cpp c_vguiscreen.h vguiscreen.cpp vguiscreen.h

Once that's done, create a new project in your solution (or do the equivalent, if you're not using Visual Studio), and configure it to be a DLL file. I called mine XMem, meaning "Cross-Memory." Then add to it the following files: xmem.cpp xmem.h xmem.def

Next, tell both the client and server projects to reference your new DLL, and add xmem.h to both the client and server projects.

Step 4: FGDs & RES's

Lastly, open up your mod's FGD (I just took Valve's base.fgd and copied it into my mod's bin folder) and use this to replace the existing VGUI screen entry:

@BaseClass base(Targetname, Parentname, Angles) = vgui_screen_base
[
	panelname(string) : "Panel Name"
	overlaymaterial(string) : "Overlay Material" : "" : "Name of a material to overlay over the top of the VGUI screen. NOTE: This material must write Z for the VGUI screen to work."
	width(integer) : "Panel Width in World" : 32 : "Width of the panel in units."
	height(integer) : "Panel Height in World" : 32 : "Height of the panel in units."

	// Inputs
	input SetActive(void) : "Make the vgui screen visible."
	input SetInactive(void) : "Make the vgui screen invisible."
	output Output1(void) : "Fire output 1."
	output Output2(void) : "Fire output 2."
	output Output3(void) : "Fire output 3."
	output Output4(void) : "Fire output 4."
	output Output5(void) : "Fire output 5."
	output Output6(void) : "Fire output 6."
	output Output7(void) : "Fire output 7."
	output Output8(void) : "Fire output 8."
	output Output9(void) : "Fire output 9."
	output Output10(void) : "Fire output 10."
	output Output11(void) : "Fire output 11."
	output Output12(void) : "Fire output 12."
	output Output13(void) : "Fire output 13."
	output Output14(void) : "Fire output 14."
	output Output15(void) : "Fire output 15."
	output Output16(void) : "Fire output 16."
]

Next, you'll need to create the actual screen configurations, stored in scripts/screens/*.res. Here's an example, followed by a brief explanation on how to make the outputs work:

"screen_basic.res"
{
	"Background"
	{
		"ControlName"	"MaterialImage"
		"fieldName"		"Background"
		"xpos"			"0"
		"ypos"			"0"
		"zpos"			"-2"
		"wide"			"480"
		"tall"			"240"

		"material"		"vgui/screens/vgui_bg"
	}
	"DismantleButton"
	{
		"ControlName"	"MaterialButton"
		"fieldName"		"Dismantle"
		"xpos"			"78"
		"ypos"			"160"
		"wide"			"324"
		"tall"			"48"
		"autoResize"	"0"
		"pinCorner"		"0"
		"visible"		"1"
		"enabled"		"1"
		"tabPosition"	"2"
		"labelText"		"Dismantle"
		"textAlignment"	"center"
		"dulltext"		"0"
		"brighttext"	"0"
		"Default"		"0"
		"command"		"1"
		"paintborder"	"0"

		"enabledImage"
		{
			"material"	"vgui/screens/vgui_button_enabled"
			"color" "255 255 255 255"
		}

		"mouseOverImage"
		{
			"material"	"vgui/screens/vgui_button_hover"
			"color" "255 255 255 255"
		}

		"pressedImage"
		{
			"material"	"vgui/screens/vgui_button_pushed"
			"color" "255 255 255 255"
		}

		"disabledImage"
		{
			"material"	"vgui/screens/vgui_button_disabled"
			"color" "255 255 255 255"
		}
	}
}

In the "DismantleButton" section, you'll notice the field "command" "1". The VGUI screens, as implemented support a total of 16 outputs, and the command value is the ASCII representation of the number of the output you wish to fire. For example, "1" fires Output1. So long as you keep this pattern (integer values between 1 and 16, inclusive), things should work just fine.

Summary

If everything was done right, the in-game VGUI screens should now respond to input, fire output, be easily addressable in Hammer, and everything should be dandy. If there are any problems, bring them up in the discussion page and I'll do my best to address them as promptly as time allows.

Credits

VGUI_Screen_Creation

Interactive_Ingame_VGUI_Panels