Manipulating the game menu items

From Valve Developer Community
Revision as of 02:11, 23 October 2005 by Ts2do (talk | contribs)

Jump to: navigation, search

This tutorial will show you how to add new game menu items to the main HL2 game menu that will execute the console commands to hide and show the current FPS. Changing the game menu items of the HL2 GUI is as easy as changing the values in the SteamApps\YourMod\Resource\GameMenu.res using notepad. If you have not started to create your own HL2 mod you will need to extract the GameMenu.res file from the SteamApps\source engine.gcf group file. I personally use GCFScape. to extract the files I need. Look under root\hl2\resource\GameMenu.res to find the file. You will need to extract the GameMenu.res file into the SteamApps\youremail\half-life2\hl2\resource folder. Or if you want to customize your own mod then extract the file to SteamApps\YourMod\Resource\GameMenu.res.

Once you have opened the SteamApps\YourMod\Resource\GameMenu.res file scroll down to the bottom and add the following lines before the last curly bracket } at the end of the file ...

	"14"
	{
		"label" "Show FPS"
		"command" "engine cl_showfps 1"
	}
	"15"
	{
		"label" "Hide FPS"
		"command" "engine cl_showfps 0"
	}

From the example above you can see that we have added 2 new label entries. The first entry "Show FPS" will set cl_showfps to 1 which will display the current FPS on the screen. The second entry will hide the current FPS.


You may also notice that the label for the quit item is "#GameUI_GameMenu_Quit". That is because it is a localized string in Resource\gameui_english.txt . (A copy of gameui_english.txt can be found in the SteamApps\source engine.gcf group file) You can also add your own strings in gameui_english.txt or HL2_english.txt and use them to label your game menu items. NOTE: That if you are making your own mod then you will need to make sure that you make a copy of the Resource\HL2_english.txt file and rename it to Resource\NameOfYourMod_english.txt. (Replace NameOfYourMod with the name of your mod) Otherwise HL2 will not be able to locate your string file.