VGUI HTML Screen In Multiplayer

From Valve Developer Community
Jump to: navigation, search
TTT - german einfachTTT Server Screen

This tutorial is an add-on to the VGUI HTML Screen tutorial. Like the original version, this tutorial aims at placing in-game viewable HTML screens, which have the added bonus of being able to trigger entity actions. The difference with this tutorial, is that it's written for Multiplayer, and works by sending the server a command to trigger it's entity.

This tutorial assumes you have read and fully understand how to implement the original document.

Special Thanks

Special thanks to Harm-Simon for coming to me with the proposal of a multiplayer version, for debugging, ideas and code that made the final version of this release. This is for you!

Changes

Singleplayer vs Multiplayer

The Singleplayer version of the VGUI HTML Screens is implemented entirely in the client - as the client has full control over the game world in that version.

Conversely, the Multiplayer version is implemented in a mixed client/server system. Displaying the screen is done on the client side, and any entity IO commands are sent to a new command placed in the Server project.

Code Changes

There have been a few changes to the code. Most notably, the entity parser has been changed to use the sv_ent_fire command to trigger entity actions. It is very similar to the ent fire command, except that cheats are not required to use it.

Compatibility

This code should work fine in singleplayer, but this has not been tested. It has been testing in multiplayer and has been seen to work perfectly. This code is considered superior to the singleplayer versiom, but the tutorial is much shorter.

Implementing the VGUI HTML View

Conventions used

A number of files are required to be added to various projects in the your src directory. Please note the following conventions:

  • Game_HL2MP refers to the Game_HL2MP-2003 or Game_HL2MP-2005 project. Use the one associated with the tools you have.
Note.pngNote:If using singleplayer, this will of course be Game_HL2-2003 and Game_HL2-2005
  • Similarly, Everything_SDK refers to the Everything_SDK-2003 or Everything_SDK-2005 project.

When adding files to a project, you have two options:

  • Save the file to the appropriate directory (specified below)
  • Create a new file with the appropriate name, and paste the contents of the file into it

The New Files

A number of new files need to be added to various projects.

Game_HL2MP

  • Add the following files to the client_hl2mp project (or client_hl2 in the case of singleplayer):
  • Add the following files to the server_hl2mp project (or server_hl2 in the case of singleplayer):

Everything_SDK

  • Add the following files to the vgui_controls project
  • EntHTML.cppbelongs in the src\vgui2\controls\ folder

Additionally, the following file needs to be placed in the src\public\ and src\public\vgui_controls\ folders:

Finishing Up

Lastly, a single file in the client project needs to be updated.

In the client_hl2mp (or client_hl2) project, open the file vgui_int.cpp.

Step 1: Adding the Include

Locate the following line:

#include "FileSystem.h"

Directly below this line, add:

#include "IHTMLView.h"

Step 2: Adding the Initialization

Locate the following line:

VPANEL toolParent = enginevgui->GetPanel( PANEL_TOOLS );

Directly below this line, add:

VPANEL gameParent = enginevgui->GetPanel( PANEL_INGAMESCREENS );
htmlview->Create(gameParent);

Step 3: Adding the Deconstructor

Locate the following line:

VGUI_DestroyClientDLLRootPanel();

Directory below this line, add:

htmlview->Destroy();

Finished

Now you're done!

Compile your project and you're ready.

Please post any errors or issues on the discussion page.

If you need more information on using these HTML screens, see the original article.

Notes on maps

Please note that you are now required to use the point_clientcommand instead of the point_servercommand entity to trigger the HTMLView.