Manipulating the game menu items: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Added information about conditional menu items)
(Перевел на русский Максим Макаров)
Line 1: Line 1:
[[Category:Tutorials]] [[Category:Modding]]
[[Category:Tutorials]] [[Category:Modding]]
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 <code>../SteamApps/SourceMods/YourMod/Resource/GameMenu.res</code> using any [[text editor]]. If you have not started to create your own HL2 mod you will need to extract the GameMenu.res file from the <code>../SteamApps/source engine.gcf</code> group file using [[GCFScape]]. Look under <code>root/hl2/resource/GameMenu.res</code> to find the file. You will need to extract the GameMenu.res file into the <code>../SteamApps/<USERNAME>/half-life2/hl2/resource</code> folder. Or if you want to customize your own mod then extract the file to <code>../SteamApps/SourceMods/YourMod/Resource/GameMenu.res</code>.
"Этот урок научит вас создавать собственные новые пункты в меню своего мода, которые будут выполнять консольные команды. На данный момент рассмотрим как создать пункт, который будет включать и выключать показатель FPS. Это просто. Открываем <code>../SteamApps/SourceMods/YourMod/Resource/GameMenu.res</code> с помощью [[текстового редактора]]. Если файла нет, вы должны извлечь его из<code>../SteamApps/source engine.gcf</code> с помощью [[GCFScape]]. Зайдите в <code>root/hl2/resource/</code> и извлеките файл GameMenu.Res в директорию вашего мода <code>../SteamApps/SourceMods/YourMod/Resource/..</code>. Если хотите поменять меню в игре (HL2, TF2 и тд.), то вы должны так же извлечь этот файл из GCF игры.


Once you have opened the <code>../SteamApps/SourceMods/YourMod/Resource/GameMenu.res</code> file scroll down to the bottom and add the following lines before the last curly bracket } at the end of the file ...
После того, как вы открыли <code>../SteamApps/SourceMods/YourMod/Resource/GameMenu.res</code> файл, спуститесь до конца файла, до скобки }.  
<pre>
<pre>
"14"
"14"
{
{
"label" "Show FPS"
"label" "Показать FPS"
"command" "engine cl_showfps 1"
"command" "engine cl_showfps 1"
}
}
"15"
"15"
{
{
"label" "Hide FPS"
"label" "Убрать FPS"
"command" "engine cl_showfps 0"
"command" "engine cl_showfps 0"
}</pre>
}</pre>


{{note|To have a menu option show up only while in-game, use <code>"OnlyInGame" "1"</code>. To prevent a menu item showing up while in-game use, <code>"notmulti" "1"</code> and <code>"notsingle" "1"</code>.}}
{{note|Для того что-бы пункт меню появлялся только в игре, используйте <code>"OnlyInGame" "1"</code>. Чтобы пункт не был виден в мультиплеере, используйте <code>"notmulti" "1"</code> , если в одиночной игре, то <code>"notsingle" "1"</code>. Числа 14 и 15 указывают порядок пунктов в меню.}}


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.  
В приведенном примере мы создали два пункта меню. Первый "Показать FPS" с командой cl_showfps 1 которая будет включать FPS. Второй пункт будет выключать FPS.


----
----


You may also notice that the label for the quit item is "#GameUI_GameMenu_Quit". That is because it is a [[VGUI_Documentation#Localization|localized string]] in <code>../Resource/gameui_english.txt</code> . (A copy of <code>gameui_english.txt</code> can be found in the <code>../SteamApps/source engine.gcf</code> group file) You can also add your own strings in <code>gameui_english.txt</code> or <code>HL2_english.txt</code> and use them to label your game menu items.
Вы так же можете заметить, что в пункте выхода игры в строке label написано "#GameUI_GameMenu_Quit. Это потому что, это локализованные строки в <code>.. /Resourse/gameui_english.txt.</code> (Копию файла можно найти в ../SteamApps/ engine.gcf). Вы также можете добавить свои собственные строки в gameui_english.txt или HL2_english.txt и использовать их для обозначения ваших пунктов в меню игры.


{{note|If you are making your own mod then you will need to make sure that you make a copy of <code>../Resource/HL2_english.txt</code> and rename it to <code>../Resource/NameOfYourMod_english.txt</code>. Otherwise Source will not be able to locate it.}}
{{note|Если вы делаете ваш собственный мод, то вам необходимо убедиться, что вы делаете копию <code>../Resource/HL2_english.txt</code> и переименуете в <code>../Resource/НазваниеВашегоМода_english.txt</code>. В противном случае источник не сможет найти его.}}

Revision as of 05:43, 30 December 2011

"Этот урок научит вас создавать собственные новые пункты в меню своего мода, которые будут выполнять консольные команды. На данный момент рассмотрим как создать пункт, который будет включать и выключать показатель FPS. Это просто. Открываем ../SteamApps/SourceMods/YourMod/Resource/GameMenu.res с помощью текстового редактора. Если файла нет, вы должны извлечь его из../SteamApps/source engine.gcf с помощью GCFScape. Зайдите в root/hl2/resource/ и извлеките файл GameMenu.Res в директорию вашего мода ../SteamApps/SourceMods/YourMod/Resource/... Если хотите поменять меню в игре (HL2, TF2 и тд.), то вы должны так же извлечь этот файл из GCF игры.

После того, как вы открыли ../SteamApps/SourceMods/YourMod/Resource/GameMenu.res файл, спуститесь до конца файла, до скобки }.

	"14"
	{
		"label" "Показать FPS"
		"command" "engine cl_showfps 1"
	}
	"15"
	{
		"label" "Убрать FPS"
		"command" "engine cl_showfps 0"
	}
Note.pngNote:Для того что-бы пункт меню появлялся только в игре, используйте "OnlyInGame" "1". Чтобы пункт не был виден в мультиплеере, используйте "notmulti" "1" , если в одиночной игре, то "notsingle" "1". Числа 14 и 15 указывают порядок пунктов в меню.

В приведенном примере мы создали два пункта меню. Первый "Показать FPS" с командой cl_showfps 1 которая будет включать FPS. Второй пункт будет выключать FPS.


Вы так же можете заметить, что в пункте выхода игры в строке label написано "#GameUI_GameMenu_Quit. Это потому что, это локализованные строки в .. /Resourse/gameui_english.txt. (Копию файла можно найти в ../SteamApps/ engine.gcf). Вы также можете добавить свои собственные строки в gameui_english.txt или HL2_english.txt и использовать их для обозначения ваших пунктов в меню игры.

Note.pngNote:Если вы делаете ваш собственный мод, то вам необходимо убедиться, что вы делаете копию ../Resource/HL2_english.txt и переименуете в ../Resource/НазваниеВашегоМода_english.txt. В противном случае источник не сможет найти его.