这篇条目有关 Source引擎。如需详情,点击这里。

Zh/Gameinfo.txt: Difference between revisions

From Valve Developer Community
< Zh
Jump to navigation Jump to search
m (category fixes)
No edit summary
 
(23 intermediate revisions by 10 users not shown)
Line 1: Line 1:
<code>GameInfo.txt</code> 文件用来向 SDK 工具 和 Source 引擎 传递 MOD 或游戏中要使用到的文件. 这就是在运行 MOD 的时候 SDK 和 Source 引擎查看要调用的是 Half-Life 2, Counter-Strike, 还是 Half-Life 2: Deathmatch 中的内容. 这也是 SDK 工具来找到您的 MOD 所在文件夹的一种途径.
{{LanguageBar}}
{{Source topicon}}
<center style=color:white;font-size:20px;font-weight:bold;padding:5px>Game Definition Files</center>
{{TabsBar|main=Gameinfo.txt}}
{{seealso|[[:Category:Gameinfo]]}}
:''关于HL1/{{L|GoldSrc}},请查阅{{L|The liblist.gam File Structure|liblist.gam}}.''


{{note|对于 Half-Life 1 (GoldSrc), 请看 [[The liblist.gam File Structure|liblist.gam 的文件结构]].}}
{{toc-right}}


仅仅当一个程序员刚刚建立起一个 MOD 时, 才需要修改这个文件了. 在大多时间里, 您不需要修改此文件, 但是如果您希望您的 MOD 能够调用除了 Half-Life 2 之外的其他内容, 您就需要修改它了. 只要您 MOD 中的这个文件设置好了, 它就应该和您的 MOD 内容放置在一起. 当所有开发者工作时, 必须使用同一个 <code>gameinfo.txt</code>.
'''<code>gameinfo.txt</code>'''是一个描述起源游戏的配置文件。除了包含诸如模组名称或开发者网站链接之类的元数据外,它还定义了它所依赖的游戏/工具以及引擎用来读取资源的SearchPaths。它位于在MOD的根文件夹中。引擎、SDK工具和Steam都依赖于它。


== UI 设定 ==
SDK会在你开始制作一个MOD时,自动生成一个gameinfo文件. 这将会使得你有一个很好的开头, 但是别以为你可以一劳永逸,你还需要在适当的时候编辑它
许多的 UI 设定, 包括您的游戏标题, 都是由 <code>gameinfo.txt</code> 文件来控制的. 包含的关键字:


{{note|[[Boolean|布尔 (Boolean)]] 值是以整型 (int) 来表示.}}
{{Warning|金源游戏没有gameinfo.txt,使用Hammer 3.4版修改半条命地图}}
{{Note|布尔值表示为0或1。}}
{{Note|如果一个数值含有空格或者制表符,请使用 "引号"进行标注。}}


//基本信息
== 界面设置 ==
game "Game Title" // 这里的文字就是 Steam 游戏菜单中显示的内容.
=== 名字 ===
gamelogo boolean // 当打开这个选项的时候
影响菜单及窗口标题的关键字
// 显示的就不是 title/title2 的文本了
{{KV:zh-cn|Game|string|[[Wikipedia:ASCII|ASCII]]编码下Mod的名字。用于Steam和游戏窗口标题。只有当<code>Title</code>没有被指定时才用作主界面标题}}
//而是显示 <code>resource/GameLogo.res</code> 文件里面的内容.
{{KV:zh-cn|Title|string|显示在你mod主界面的一串[[Wikipedia:Unicode|Unicode]]字符串。你也可以通过添加另一个同名的Title键来换行菜单文本,但要在其上附加2或更高的数字。{{Note|数字越大,文字就越靠后。}}}}
// 设定将被读取到引擎的 VGUI
; {{KV:zh-cn|GameLogo|boolean|在主界面显示<code>resource\GameLogo.res</code>里指定的图标而不是<code>Title</code>里的内容,详见{{L|Adding Your Logo to the Menu|在菜单上添加你的logo}}。|since=EP2}}
// 以便使用 <code>gamelogo</code> 文件来修改.
title "Game Title" // 这是在游戏中的菜单上显示的实际内容.
title2 "..." // 副标题 (非必需)
type singleplayer_only // 也可以是 multiplayer_only .  帮助 GameUI 了解
// 在 选项 面板上哪些 UI 组件是要显示的.
// 如果 MOD 结合了 [[MP|多人模式]] 和 [[SP|单人模式]] 就可以忽略此项了.
// 如果设置了 <code>multiplayer_only</code>, 那么 多人游戏 标签 // 将显示在 选项 面板的最前面 // 否则, 如果没有 <code>singleplayer_only</code> 它会被添加到最后.


nodifficulty boolean // 在 选项 面板上隐藏 困难度标签
hasportals boolean // 在 选项 面板上显示 Portal 标签
//选项 面板上的 多人游戏 标签
nocrosshair boolean // 隐藏 准心选择 面板
nohimodel boolean // Hides cvar toggles checkbox for <code>cl_himodels</code>
// Only is displayed properly if <code>cl_himodels</code> is registered
nomodels boolean // 隐藏多人游戏中的 模型选择 标签
//Steam 游戏列表
developer "Team name" // 您的团队的名字 (或许只有您一人!)
developer_url "Web address" // 您团队的主页. 必须把 <nowiki>http://</nowiki> 卸载最前面.
manual "URL" // 游戏手册的地址; 也可以是本地目录.
// 安装文件可以修改这个值
// 以便在安装时修正文件位置.
icon "path/to/icon" // 图标必须为未压缩的 16x16 像素的 TGA 格式文件.
// 为了使透明度正常, TGA 文件必须以拥有 Alpha 通道的 32-bit 模式储存
// 路径为 相对 MOD 安装目录的 相对路径
// (就是 <code>gameinfo.txt</code> 文件)
// 还应该不含有 .TGA 扩展名.
//创建服务器会话
hidden_maps // 括号内的地图将不会显示
{ // 但是通过 自动完成 列表
"mapname" 1 // 和 <code>changelevel</code> 命令
"mapname" 1 // 可以打开.
}
nodegraph boolean // 告诉引擎是否要生成地图的 nodegraphs.


当您创建一个新 MOD 的时候, <code>gameinfo.txt</code> 文件内的 标题 (title) 和 游戏类型 (type) 都是空的, 别忘了自己写上.
=== 设置 ===
影响选项面板中显示选项卡和选项的关键字
{{KV:zh-cn|Type|string|这将决定在设置选项里是否会有单人和多人模式,该值一般为M<code>Singleplayer_Only</code>或<code>Multiplayer_Only</code>。如果您的模组同时具有单人和多人模式,请忽略此键值。}}
{{KV:zh-cn|NoDifficulty|boolean|隐藏难度设置(如果你的mod是多人游戏的话,该键值将自动生成。)}}
{{KV:zh-cn|HasPortals|boolean|显示传送门漏斗选项|since=EP2}}
{{KV:zh-cn|NoCrosshair|boolean|隐藏多人游戏中的准星设置界面}}
{{KV:zh-cn|AdvCrosshair|boolean|启用特殊的高级准星设置。{{Todo|如何使用?}} }}
{{KV:zh-cn|NoModels|boolean|隐藏多人游戏的玩家模型设置界面}}
{{KV:zh-cn|NoHIModel|boolean|隐藏在{{L|Goldsource|金源}}中使用的<code>cl_himodels</code> 切换复选框。只有在<code>cl_himodels</code>首先存在的情况下才会正常显示}}
{{KV:zh-cn|Hidden_Maps|subkey|子键值中的地图名不会出现在“创建服务器”界面中。不过这并不阻止玩家通过控制台读取地图。语法为<code>地图名 1</code>,每行一个条目。不需要包括扩展名,请记住使用 { } 开始和结束子键值。}}
{{KV:zh-cn|CommandLine|subkey|mod的启动参数列表。语法为<code>-launchoption "value"</code>,每行一个参数。请记住使用 { 和 } 开始和结束子键值。|only=Mapbase}}


{{note|在您更改 <code>resource/clientscheme.res</code>文件中 标题 所用的字体之前, 标题可能无法正常显示. [[Half-Life 2]] 使用一个独特定制的字体 ("HalfLife2") 里面只包含有一堆的特殊图形; 这个字体无法正常显示大多数的文本.  改变 clientscheme.res 文件内的 ClientTitleFontto 项的字体列表 来修正这个问题.}}


== SteamAppId ==
=== Steam游戏相关 ===
<code>GameInfo.txt</code> 文件内有用的还有 <code>SteamAppId</code> 的值. 如果您打开 GameInfo.txt, 您将看到这样的一块:
影响你的游戏或MOD在Steam库上的显示方式的键值
{{KV:zh-cn|Developer|string|MOD的开发者。通常是MOD团队的名字,或者作者的名字。在目前的Steam版本上不起作用。|deprecated=1}}
{{KV:zh-cn|Developer_URL|string|你的或者mod的主页链接。必须以<code><nowiki>http://</nowiki></code>为开头, 在目前的Steam版本上不起作用。|deprecated=1}}
{{KV:zh-cn|Manual|string|模组手册的网址,也可以是一个本地文件。在目前的Steam版本上不起作用。|deprecated=1}}
{{KV:zh-cn|Icon|string|一个未压缩的,位于游戏目录(通常相对于gameinfo.txt的目录)下的16x16像素大的TGA,该图标将在Steam中作为你的mod图标出现。不包括扩展名。在Steam的细节视图中出现的32像素大的图标应该位于同一目录,并称为<code>&lt;icon&gt;_big.tga</code>。{{Note|为了使半透明部分正常显示,TGA必须在拥有Alpha通道的情况下以32位模式下保存。}} }}


SteamAppId 215 //This will mount all the GCFs we need (240=CS:S, 220=HL2).


<code>SteamAppId</code> 的值制定了游戏要使用的内容 (就是 [[GCF]] 文件).
=== 引擎及工具相关 ===
影响引擎/创作工具的键值和工具本身的一些属性。
{{KV:zh-cn|Nodegraph|boolean|是否为地图启用{{L|nodegraph|路径点}}生成(格式为.ain的文件)|since=EP2}}
{{KV:zh-cn|GameData|string|{{L|FGD}}文件的路径,相对于{{L|Hammer}}的位置。必须指定该键值才能将{{L|Instances|实例}}编译进地图中,Hammer本身不使用它。}}
{{KV:zh-cn|InstancePath|string|查找{{L|Instances|实例}}VMF的默认位置。|since=2013}}
{{KV:zh-cn|SupportsDX8|boolean|当被禁用时,将阻止游戏在旧版{{L|DirectX_Versions|DirectX}}中运行,例如DX8及更低版本,因为它们不支持所有的视觉效果,还会阻止{{L|Studiomdl}}为模型生成<code>.sw.vtx</code>和<code>.dx80.vtx</code>文件,因为实际游戏并不需要它们|since=L4D}}
{{KV:zh-cn|SupportsVR|boolean|游戏是否支持在VR模式下运行。|since=2013}}
{{KV:zh-cn|SupportsXBox360|boolean|游戏是否支持 Xbox 360。{{Confirm|这是否能够让玩家在游戏中使用Xbox 360手柄?}}|since=L4D}}


{{note|所有的 MOD 应该都使用 <code>215</code> AppId, 除非有特殊的需要, 比如 218 是读取 the Orange Box Source 引擎.}}
{{warning|选择您的 MOD 所以依赖的游戏时, 注意 '''您将不能依赖于那些其他游戏没有共享的内容.'''}}
{{warning|'''要让 VAC 反作弊系统保护您的多人游戏 MOD, 请确定 MOD 是基于一个多人游戏'''. [[HL2DM]] 是个不错的选择.}}


Source 引擎游戏的 <code>SteamAppId</code> 的值可以在 [[Steam Application IDs]] 找到. 共享 GCFs 将在文件名中包含 'shared' , 这些文件可以随时被调用; 剩下的一切就是个人的问题了.
== 资源读取相关 ==
用于文件系统的键值
{{KV:zh-cn|SteamAppID|int|Mod本体的{{L|Steam Application IDs|Steam AppID}}。MOD可以访问该游戏/工具的所有内容,除非安装了被指定的游戏/工具,否则mod就无法运行,MOD也将和游戏本体同步运行。如果你正在将你的mod上传至Steam,则该键值应该为你mod的AppID。反之,如果你的mod本体是{{src13mp|4}},则该应为243750;如果你的mod本体是{{src13|4}},则应为243730;如果你的mod本体是{{as|4}},则应为630。如果你不进行源代码修改,则使用你mod的本体的AppID,
{{Note|大多数年代久远的起源mod会使用Source 2006的AppID 215和Source 2007的AppID 218。如果你正在制作一个新mod,你不应该使用这些AppID,因为它们显然是已过时的起源引擎分支,已被Source 2013和Alien Swarm所取代。只能用它们来支持旧版的功能。}}
{{Note|如果你的mod是单人游戏,则不会受到{{L|VAC}}的保护}} }}


== 文件系统 ==
{{KV:zh-cn|AdditionalContentId|int|mod可以访问的另一游戏的AppID。此功能已添加到源代码中,但不知何故从未在V社的其他游戏中使用;您必须进行代码修改才能使用此键值。如果您需要使用它读取多个游戏的资源,请进行{{L|Mounting multiple games|以下更改}}。|deprecated=1}}
这一段详细描述了文件系统中的大量组件
{{Bug|游戏可以理解此键值,但SDK工具不能。目前,最好的解决方案是将游戏内容复制到电脑上的某个位置并在<code>SearchPath</code>部分中添加其绝对路径。记得在发布mod之前删除这些路径。}}
{{KV:zh-cn|ToolsAppId|int|这是目前正在使用的SDK的AppID。|deprecated=1}}


=== ToolsAppId ===
所有 <code>GameInfo.txt</code> 文件都有这样的一行:


ToolsAppId 211 //Tools will load this (ie: source SDK caches) to get
== 搜索路径 ==
//things like materials\debug, materials\editor, etc.


这是一个特殊的设定, 这个值被工具读取, 用来看看那些内容要被工具使用, 这不被游戏使用.
<code>SearchPaths</code>是<code>FileSystem</code>中的一个子键值。它将每个搜索路径储存为一个键值。当引擎需要读取一个文件时,它会按顺序遍历搜索路径,在找到所需的文件后停止遍历,因此搜索路径的顺序非常重要。


=== SearchPaths ===
<code>GameInfo.txt</code> 文件中的 <code>SearchPaths</code> 片段描述了在哪里可以找到游戏内容, 在您的硬盘和 Steam 缓存文件内. 要理解这部分内容, 我们必须去看看程序员是怎样调用 Source 引擎来读取游戏文件的. 程序员要访问的所有文件中代码都必须拥有一个 <i>path ID</i>. path ID 表示了一个或多个您的硬盘或是虚拟的 Steam 文件系统的目录.


举个例子, 您的游戏中大多数像 脚本 (scripts), 音效 (sounds), 模型 (model) 文件, 和 材质 (materials) 这样的资源以 <code>"Game"</code> path ID 被访问. 一个程序员或许会说, "打开一个在 <code>'Game'</code> path ID 里面的 <code>scripts\weapon_m4a1.txt</code> 文件". 如果您的 MOD 位于 <code>C:\MyMod\Blasters</code>, 并且您使用了 <code>SteamAppId 240</code> 这将会读取 Counter-Strike: Source 的内容, 它将会在这几个地方搜寻文件:
{{Note|要记住的一点是,搜索路径的顺序很'''重要''',如果有2个同名的文件位于2个不同的搜索路径中,并且您将它们都写入了,则最顶部的搜索路径优先级最高}}


* <code>C:\MyMod\Blasters\scripts\weapon_m4a1.txt</code>
* <code><Steam install directory>\Steam\SteamApps\username\Counter-Strike Source\cstrike\scripts\weapon_m4a1.txt</code>
* <code><inside the virtual Steam file system>\cstrike\scripts\weapon_m4a1.txt</code>


使用 path IDs 来描述文件, 就可以让程序员和开发人员无需担心这些不懂的文件目录. 他们可以使用关联到游戏目录的名称 (比如 <code>scripts\weapon_m4a1.txt</code> 或者 <code>materials\brick\brickwall001a.vmt</code>) 引擎和工具会帮您搜寻这些文件的位置, 只要 <code>GameInfo.txt</code> 描述了 <code>"Game"</code> path ID 的意义.
=== 目录 ===


在 <code>GameInfo.txt</code> 文件里面, 有一个 <code>"SearchPaths"</code> 字段, 描述了 path IDs. 大多数的 MOD 无须改动这个路径, 他在您从 SDK launcher 运行 '''Create a Mod''' 的时候就建立了.
The directory, which is the value of the key, will either be relative to the <code>SteamAppID</code>'s root directory (i.e. where the executable of the game is located), relative to GameInfo.txt or absolute. A example of each one respectively would be this:


每一行的第一部分是 path ID 的名称, 第二部分是当 path ID 使用时要搜索的路径. 一个简单的例子是这样的:
Game      |All_Source_Engine_Paths|HL2 // Go to the executable directory, and mount a folder called HL2 in it.
Game      |GameInfo_Path|. // Go to the directory of where GameInfo.txt is located, and mount the folder it's in.
Game      "C:\MyFolderOfContent\content" // Mount this absolute directory, useful for mounting content temporarily.


SearchPaths
{{Note|In order to mount a {{L|VPK}} file, you need to add the VPK's name at the end of the directory with the <code>.vpk</code> extension. If the VPK is a multi-chunck VPK, then put the name of the VPK in without the "_dir" or "_###" at the end.}}
{
TestPathID C:\TestMod1
TestPathID C:\TestMod2
TestPathID C:\TestMod3
  }


如果一个程序员需要写代码到 scripts\weapon_m4a1.txt 并且使用了 "TestPathID" 作为代码中的 path ID , 引擎就会搜寻如下位置:
The 2 variables above will start the search in a certain directory, <code>|All_Source_Engine_Paths|</code> will start the directory within the root folder, and <code>|GameInfo_Path|</code> will start it in the folder where GameInfo.txt is located.  Both of these variables can be appended with any number of folders.  There are also some special commands you can append in addition to the folders and variables, the known ones are:


* <code>C:\TestMod1\scripts\weapon_m4a1.txt</code>
* <code>../</code> <br> Goes back one folder, this will useful for mounting other games' content like {{L|Portal}}, since AdditionalContentID is deprecated. If you wanted to mount Portal, and your game is in, say for example <code>"<SteamFolder>\SteamApps\Common\MyGame\FolderWhereGameInfoIs"</code>, you would create a search path like this to mount it's content:
* <code>C:\TestMod2\scripts\weapon_m4a1.txt</code>
* <code>C:\TestMod3\scripts\weapon_m4a1.txt</code>


Since the Source games access most of their content in the <code>"Game"</code> path ID, they do some things for you automatically if you have a path ID called <code>"Game"</code>. For each entry with a path ID of <code>"Game"</code>:
// Start in the executable directory, then go back one folder so we're in Common, and then go into Portal/portal and mount portal_pak.vpk
Game       |All_Source_Engine_Paths|../Portal/portal/portal_pak.vpk


# It adds a <code>"GameBin"</code> path ID, in <code><dir>\bin</code>
# It adds another <code>"Game"</code> path in front of it with <code>_<language></code> at the end. For example: <code>c:\hl2\cstrike</code> would get a <code>c:\hl2\cstrike_french</code> path added to it if you were running on a French-localized machine.


For the first <code>"Game"</code> search path:
Here is also an example of how to mount a {{L|Modification|SourceMod}}:


# It adds a search path called <code>"MOD"</code> under the same folder.
// Start in the executable directory, then go back two folders so we're in SteamApps, and then go into SourceMods and mount the MySourceMod folder.
# It adds a search path called <code>"DEFAULT_WRITE_PATH"</code>.
Game      |All_Source_Engine_Paths|../../SourceMods/MySourceMod


The default <code>SearchPaths</code> that would be used in most mods are like this:


SearchPaths
* <code>.</code> <br> This stops the search in the current directory, this should only be used if you want to directly mount where <code>|All_Source_Engine_Paths|</code> or <code>|GameInfo_Path|</code> areAn example of both:
{
Game        |gameinfo_path|.
Game        hl2
  }


Normally, a path specifier (the part on the right side) is relative to the base directory --The directory where <code>hl2.exe</code> is found. If <code>|gameinfo_path|</code> precedes the path, then it is relative to the directory where <code>GameInfo.txt</code> file instead. For example, if the <code>GameInfo.txt</code> file were in <code>C:\MyMod\Blasters</code>, and it had a path like <code><i>|gameinfo_path|SomeTestDirectory</i></code>, then the path ID you were creating would refer to:
// Mount both |All_Source_Engine_Paths| and |GameInfo_Path| variables' path.
Game      |All_Source_Engine_Paths|.
Game      |GameInfo_Path|.


<code>C:\MyMod\Blasters\SomeTestDirectory</code>


For Counter-Strike: Source, the <code>GameInfo.txt</code> file has a <code>SearchPaths</code> section that looks like the one above. If your Counter-Strike directory was:
* <code>/*</code> <br> Mount every sub-folder and {{L|VPK}} in the current directory, this command is what makes the custom folder work in most update to date Source games. An example of it's use:


<code>C:\Program Files\Valve\Steam\SteamApps\username\Counter-Strike Source</code>
// Mount the custom folder's sub-folders and VPKs.
Game      |GameInfo_Path|custom/*


then it would be saying to look in these two directories:
=== Keys ===


* <code>C:\Program Files\Valve\Steam\SteamApps\username\Counter-Strike Source\cstrike</code>
In most older Source games, the only keys for search pathing is <code>Game</code> and <code>Platform</code>, while these keys will suit most search pathing, in Source 2013 a few new keys where introduced that add more control.
because GameInfo.txt exists here.
* <code>C:\Program Files\Valve\Steam\SteamApps\username\Counter-Strike Source\hl2</code>
which only exists inside a virtual Steam file system.


[[category:Technical:zh-cn]]
{{Tip|{{L|Insurgency}} and {{L|Day of Infamy}} use the same search pathing system as Source 2013, so commands and keys that work in Source 2013 will work for them as well!}}
[[Category:Modding:zh-cn|MOD 制作]]
[[Category:Source SDK FAQ:zh-cn]]


{{otherlang:zh-cn}}
目前已知的关键字是:
{{otherlang:zh-cn:en|The GameInfo.txt File Structure}}
 
{{otherlang:zh-cn:ru|The GameInfo.txt File Structure:ru}}
* <code>Game</code> <br> Adds the path as a simple search path.  Will add any content it finds.  Also writes sound.cache file in each Game directory.
{{otherlang:zh-cn:pl|The GameInfo.txt File Structure:pl}}
* <code>Game_Write</code> {{2013 add:zh-cn}} <br> Marks the search path as a Game write path.  It marks the directory as the default directory for writing (what exactly?) for this game. {{confirm|Does this do anything?}}
{{otherlang:zh-cn:jp|The GameInfo.txt File Structure:jp}}
* <code>GameBin</code> {{2013 add:zh-cn}} <br> A special key that requires that the path lead to a game's binary files (where <code>Server.dll</code> and <code>Client.dll</code> are located), and will use any other DLL files it finds.  This should lead to your own mod's <code>Bin</code> folder, or the game you're basing it off's <code>Bin</code> folder if you're not building your own DLLs.
* <code>Platform</code> <br> Adds a special search path to the folder containing core engine files, this will usually lead to the game's <code>Platform</code> folder.
* <code>Mod</code> {{2013 add:zh-cn}} <br> Marks the search path as a Mod path.  This is usually where the game executable is.  Essential for displaying chapter list in New Game menu, and probably for something else.
* <code>Mod_Write</code> {{2013 add:zh-cn}} <br> Marks the search path as a Mod write path.  This is usually where GameInfo.txt is.  It marks the directory as the default directory for writing save files and downloadlists for this mod.
* <code>Default_Write_Path</code> <br> Marks the search path as a Default write path.  This is usually where GameInfo.txt is.  It marks the directory as the default directory for writing config.cfg, node graphs, screenshots and some other files for this mod.  Also a fallback for when either Mod_Write or Game_Write isn't specified.
* <code>VPK</code> {{Contagion add:zh-cn}} <br> Used to mount a {{L|VPK}} by name.  Do not put <code>.vpk</code> at the end.
 
 
In Source 2013, you may also append keys to each other by separating each key name by a <code>+</code> sign, this way if you need to use one directory for multiple keys, instead of writing this:
 
Game      |GameInfo_Path|MyFolder
Mod      |GameInfo_Path|MyFolder
 
It can instead be shortened like this:
 
Game+Mod  |GameInfo_Path|MyFolder
 
This saves you time from having to retype the directory over again.
 
 
=== 自动读取本地化文件 ===
 
Source automatically creates localized search paths. If you mount the folder <code>HL2</code>, then when your mod runs in French <code>HL2_French</code> is automatically mounted just above it, overriding any content in <code>HL2</code>. {{todo|Does this also apply for the mod folder?}}
 
=== 示例 ===
 
一个能够正常在 {{src13|4}} 游戏中使用的 GameInfo.txt
 
<source lang=ini>
 
"GameInfo"
{
game "HALF-LIFE 2"
title "HALF-LIFE'"
type singleplayer_only
supportsvr 1
 
FileSystem
{
SteamAppId 220 // This will mount all the GCFs we need (240=CS:S, 220=HL2).
//
// The code that loads this file automatically does a few things here:
//
// 1. For each "Game" search path, it adds a "GameBin" path, in <dir>\bin
// 2. For each "Game" search path, it adds another "Game" path in front of it with _<langage> at the end.
//    For example: c:\hl2\cstrike on a french machine would get a c:\hl2\cstrike_french path added to it.
// 3. For the first "Game" search path, it adds a search path called "MOD".
// 4. For the first "Game" search path, it adds a search path called "DEFAULT_WRITE_PATH".
//
 
//
// Search paths are relative to the base directory, which is where hl2.exe is found.
//
// |gameinfo_path| points at the directory where gameinfo.txt is.
// We always want to mount that directory relative to gameinfo.txt, so
// people can mount stuff in c:\mymod, and the main game resources are in
// someplace like c:\program files\valve\steam\steamapps\half-life 2.
//
SearchPaths
{
// First, mount all user customizations.  This will search for VPKs and subfolders
// and mount them in alphabetical order.  The easiest way to distribute a mod is to
// pack up the custom content into a VPK.  To "install" a mod, just drop it in this
// folder.
//
// Note that this folder is scanned only when the game is booted.
game+mod hl2/custom/*
 
// We search VPK files before ordinary folders, because most files will be found in
// VPK and we can avoid making thousands of file system calls to attempt to open files
// in folders where they don't exist.  (Searching a VPK is much faster than making an operating
// system call.)
game_lv hl2/hl2_lv.vpk
game+mod hl2/hl2_sound_vo_english.vpk
game+mod hl2/hl2_pak.vpk
game |all_source_engine_paths|hl2/hl2_textures.vpk
game |all_source_engine_paths|hl2/hl2_sound_misc.vpk
game |all_source_engine_paths|hl2/hl2_misc.vpk
platform |all_source_engine_paths|platform/platform_misc.vpk
 
// Now search loose files.  We'll set the directory containing the gameinfo.txt file
// as the first "mod" search path (after any user customizations).  This is also the one
// that's used when writing to the "mod" path.
mod+mod_write+default_write_path |gameinfo_path|.
 
// Add the HL2 directory as a game search path.  This is also where where writes
// to the "game" path go.
game+game_write hl2
 
// Where the game's binaries are
gamebin hl2/bin
 
// Last, mount in shared HL2 loose files
game |all_source_engine_paths|hl2
platform |all_source_engine_paths|platform
}
}
}
 
 
</source>
 
 
== 使用 XBLAH's Modding Tool 编辑 GameInfo 文件==
The mod information can be edited with {{L|XBLAH's Modding Tool}} through a comprehensive UI without requiring the modder to mess with text files. It includes all the major keys of Source SDK 2013 Single-player and Source SDK 2013 Multi-player, more than enough for the majority of Source modders.
 
This can be accessed within the tool through '''Modding > Game info'''.
 
<gallery>
File:XBLAH's Modding Tool - Modding - Game info 1.png|Name
File:XBLAH's Modding Tool - Modding - Game info 2.png|Options
File:XBLAH's Modding Tool - Modding - Game info 3.png|Steam games list
File:XBLAH's Modding Tool - Modding - Game info 4.png|Engine and tools
</gallery>
 
 
== 站外链接 ==
*[https://modding-assets.net/source/tools/modding/xblah-modding-tool/ XBLAH's Modding Tool Homepage]
 
{{ACategory|File formats}}
{{ACategory|Modding}}
{{ACategory|Source SDK FAQ}}

Latest revision as of 12:28, 6 April 2025

English (en)Deutsch (de)Español (es)Français (fr)日本語 (ja)한국어 (ko)Polski (pl)Русский (ru)中文 (zh)Translate (Translate)
Info content.png
This translated page needs to be updated.
You can help by updating the translation.
Also, please make sure the article complies with the alternate languages guide.(en)
This notice is put here by LanguageBar template and if you want to remove it after updating the translation you can do so on this page.


Game Definition Files
edit
关于HL1/GoldSrc(en),请查阅liblist.gam(en).

gameinfo.txt是一个描述起源游戏的配置文件。除了包含诸如模组名称或开发者网站链接之类的元数据外,它还定义了它所依赖的游戏/工具以及引擎用来读取资源的SearchPaths。它位于在MOD的根文件夹中。引擎、SDK工具和Steam都依赖于它。

SDK会在你开始制作一个MOD时,自动生成一个gameinfo文件. 这将会使得你有一个很好的开头, 但是别以为你可以一劳永逸,你还需要在适当的时候编辑它

Warning.png警告:金源游戏没有gameinfo.txt,使用Hammer 3.4版修改半条命地图
Note.png注意:布尔值表示为0或1。
Note.png注意:如果一个数值含有空格或者制表符,请使用 "引号"进行标注。

界面设置

名字

影响菜单及窗口标题的关键字

Game <字符串(en)>
ASCII编码下Mod的名字。用于Steam和游戏窗口标题。只有当Title没有被指定时才用作主界面标题
Title <字符串(en)>
显示在你mod主界面的一串Unicode字符串。你也可以通过添加另一个同名的Title键来换行菜单文本,但要在其上附加2或更高的数字。
Note.png注意:数字越大,文字就越靠后。
GameLogo <布尔值(en)> (存在于自 半衰期2:第二章 以来)
在主界面显示resource\GameLogo.res里指定的图标而不是Title里的内容,详见在菜单上添加你的logo(en)


设置

影响选项面板中显示选项卡和选项的关键字

Type <字符串(en)>
这将决定在设置选项里是否会有单人和多人模式,该值一般为MSingleplayer_OnlyMultiplayer_Only。如果您的模组同时具有单人和多人模式,请忽略此键值。
NoDifficulty <布尔值(en)>
隐藏难度设置(如果你的mod是多人游戏的话,该键值将自动生成。)
HasPortals <布尔值(en)> (存在于自 半衰期2:第二章 以来)
显示传送门漏斗选项
NoCrosshair <布尔值(en)>
隐藏多人游戏中的准星设置界面
AdvCrosshair <布尔值(en)>
启用特殊的高级准星设置。
待完善: 如何使用?
NoModels <布尔值(en)>
隐藏多人游戏的玩家模型设置界面
NoHIModel <布尔值(en)>
隐藏在金源(en)中使用的cl_himodels 切换复选框。只有在cl_himodels首先存在的情况下才会正常显示
Hidden_Maps <subkey(en)>
子键值中的地图名不会出现在“创建服务器”界面中。不过这并不阻止玩家通过控制台读取地图。语法为地图名 1,每行一个条目。不需要包括扩展名,请记住使用 { 和 } 开始和结束子键值。
CommandLine <subkey(en)> (仅存在于 Mapbase 中)
mod的启动参数列表。语法为-launchoption "value",每行一个参数。请记住使用 { 和 } 开始和结束子键值。


Steam游戏相关

影响你的游戏或MOD在Steam库上的显示方式的键值

Developer <字符串(en)> Obsolete
已弃用。 MOD的开发者。通常是MOD团队的名字,或者作者的名字。在目前的Steam版本上不起作用。
Developer_URL <字符串(en)> Obsolete
已弃用。 你的或者mod的主页链接。必须以http://为开头, 在目前的Steam版本上不起作用。
Manual <字符串(en)> Obsolete
已弃用。 模组手册的网址,也可以是一个本地文件。在目前的Steam版本上不起作用。
Icon <字符串(en)>
一个未压缩的,位于游戏目录(通常相对于gameinfo.txt的目录)下的16x16像素大的TGA,该图标将在Steam中作为你的mod图标出现。不包括扩展名。在Steam的细节视图中出现的32像素大的图标应该位于同一目录,并称为<icon>_big.tga
Note.png注意:为了使半透明部分正常显示,TGA必须在拥有Alpha通道的情况下以32位模式下保存。


引擎及工具相关

影响引擎/创作工具的键值和工具本身的一些属性。

Nodegraph <布尔值(en)> (存在于自 半衰期2:第二章 以来)
是否为地图启用路径点(en)生成(格式为.ain的文件)
GameData <字符串(en)>
FGD(en)文件的路径,相对于Hammer(en)的位置。必须指定该键值才能将实例(en)编译进地图中,Hammer本身不使用它。
InstancePath <字符串(en)> (存在于自 2013 以来)
查找实例(en)VMF的默认位置。
SupportsDX8 <布尔值(en)> (存在于自 求生之路 以来)
当被禁用时,将阻止游戏在旧版DirectX(en)中运行,例如DX8及更低版本,因为它们不支持所有的视觉效果,还会阻止Studiomdl(en)为模型生成.sw.vtx.dx80.vtx文件,因为实际游戏并不需要它们
SupportsVR <布尔值(en)> (存在于自 2013 以来)
游戏是否支持在VR模式下运行。
SupportsXBox360 <布尔值(en)> (存在于自 求生之路 以来)
游戏是否支持 Xbox 360。
证实:这是否能够让玩家在游戏中使用Xbox 360手柄?


资源读取相关

用于文件系统的键值

SteamAppID <整数(en)>
Mod本体的Steam AppID(en)。MOD可以访问该游戏/工具的所有内容,除非安装了被指定的游戏/工具,否则mod就无法运行,MOD也将和游戏本体同步运行。如果你正在将你的mod上传至Steam,则该键值应该为你mod的AppID。反之,如果你的mod本体是起源2013 多人分支 起源2013 多人分支,则该应为243750;如果你的mod本体是起源2013 起源2013,则应为243730;如果你的mod本体是异形丛生 异形丛生,则应为630。如果你不进行源代码修改,则使用你mod的本体的AppID,
Note.png注意:大多数年代久远的起源mod会使用Source 2006的AppID 215和Source 2007的AppID 218。如果你正在制作一个新mod,你不应该使用这些AppID,因为它们显然是已过时的起源引擎分支,已被Source 2013和Alien Swarm所取代。只能用它们来支持旧版的功能。
Note.png注意:如果你的mod是单人游戏,则不会受到VAC(en)的保护


AdditionalContentId <整数(en)> Obsolete
已弃用。 mod可以访问的另一游戏的AppID。此功能已添加到源代码中,但不知何故从未在V社的其他游戏中使用;您必须进行代码修改才能使用此键值。如果您需要使用它读取多个游戏的资源,请进行以下更改(en)
Icon-Bug.png错误:游戏可以理解此键值,但SDK工具不能。目前,最好的解决方案是将游戏内容复制到电脑上的某个位置并在SearchPath部分中添加其绝对路径。记得在发布mod之前删除这些路径。  [todo tested in ?]
ToolsAppId <整数(en)> Obsolete
已弃用。 这是目前正在使用的SDK的AppID。


搜索路径

SearchPathsFileSystem中的一个子键值。它将每个搜索路径储存为一个键值。当引擎需要读取一个文件时,它会按顺序遍历搜索路径,在找到所需的文件后停止遍历,因此搜索路径的顺序非常重要。


Note.png注意:要记住的一点是,搜索路径的顺序很重要,如果有2个同名的文件位于2个不同的搜索路径中,并且您将它们都写入了,则最顶部的搜索路径优先级最高


目录

The directory, which is the value of the key, will either be relative to the SteamAppID's root directory (i.e. where the executable of the game is located), relative to GameInfo.txt or absolute. A example of each one respectively would be this:

Game       |All_Source_Engine_Paths|HL2 // Go to the executable directory, and mount a folder called HL2 in it.
Game       |GameInfo_Path|. // Go to the directory of where GameInfo.txt is located, and mount the folder it's in.
Game       "C:\MyFolderOfContent\content" // Mount this absolute directory, useful for mounting content temporarily.
Note.png注意:In order to mount a VPK(en) file, you need to add the VPK's name at the end of the directory with the .vpk extension. If the VPK is a multi-chunck VPK, then put the name of the VPK in without the "_dir" or "_###" at the end.

The 2 variables above will start the search in a certain directory, |All_Source_Engine_Paths| will start the directory within the root folder, and |GameInfo_Path| will start it in the folder where GameInfo.txt is located. Both of these variables can be appended with any number of folders. There are also some special commands you can append in addition to the folders and variables, the known ones are:

  • ../
    Goes back one folder, this will useful for mounting other games' content like Portal(en), since AdditionalContentID is deprecated. If you wanted to mount Portal, and your game is in, say for example "<SteamFolder>\SteamApps\Common\MyGame\FolderWhereGameInfoIs", you would create a search path like this to mount it's content:
// Start in the executable directory, then go back one folder so we're in Common, and then go into Portal/portal and mount portal_pak.vpk
Game       |All_Source_Engine_Paths|../Portal/portal/portal_pak.vpk 


Here is also an example of how to mount a SourceMod(en):

// Start in the executable directory, then go back two folders so we're in SteamApps, and then go into SourceMods and mount the MySourceMod folder.
Game       |All_Source_Engine_Paths|../../SourceMods/MySourceMod


  • .
    This stops the search in the current directory, this should only be used if you want to directly mount where |All_Source_Engine_Paths| or |GameInfo_Path| are. An example of both:
// Mount both |All_Source_Engine_Paths| and |GameInfo_Path| variables' path.
Game       |All_Source_Engine_Paths|.
Game       |GameInfo_Path|.


  • /*
    Mount every sub-folder and VPK(en) in the current directory, this command is what makes the custom folder work in most update to date Source games. An example of it's use:
// Mount the custom folder's sub-folders and VPKs.
Game       |GameInfo_Path|custom/*

Keys

In most older Source games, the only keys for search pathing is Game and Platform, while these keys will suit most search pathing, in Source 2013 a few new keys where introduced that add more control.

Tip.png提示:Insurgency(en) and Day of Infamy(en) use the same search pathing system as Source 2013, so commands and keys that work in Source 2013 will work for them as well!

目前已知的关键字是:

  • Game
    Adds the path as a simple search path. Will add any content it finds. Also writes sound.cache file in each Game directory.
  • Game_Write Template:2013 add:zh-cn
    Marks the search path as a Game write path. It marks the directory as the default directory for writing (what exactly?) for this game.
    证实:Does this do anything?
  • GameBin Template:2013 add:zh-cn
    A special key that requires that the path lead to a game's binary files (where Server.dll and Client.dll are located), and will use any other DLL files it finds. This should lead to your own mod's Bin folder, or the game you're basing it off's Bin folder if you're not building your own DLLs.
  • Platform
    Adds a special search path to the folder containing core engine files, this will usually lead to the game's Platform folder.
  • Mod Template:2013 add:zh-cn
    Marks the search path as a Mod path. This is usually where the game executable is. Essential for displaying chapter list in New Game menu, and probably for something else.
  • Mod_Write Template:2013 add:zh-cn
    Marks the search path as a Mod write path. This is usually where GameInfo.txt is. It marks the directory as the default directory for writing save files and downloadlists for this mod.
  • Default_Write_Path
    Marks the search path as a Default write path. This is usually where GameInfo.txt is. It marks the directory as the default directory for writing config.cfg, node graphs, screenshots and some other files for this mod. Also a fallback for when either Mod_Write or Game_Write isn't specified.
  • VPK Template:Contagion add:zh-cn
    Used to mount a VPK(en) by name. Do not put .vpk at the end.


In Source 2013, you may also append keys to each other by separating each key name by a + sign, this way if you need to use one directory for multiple keys, instead of writing this:

Game      |GameInfo_Path|MyFolder
Mod       |GameInfo_Path|MyFolder

It can instead be shortened like this:

Game+Mod  |GameInfo_Path|MyFolder

This saves you time from having to retype the directory over again.


自动读取本地化文件

Source automatically creates localized search paths. If you mount the folder HL2, then when your mod runs in French HL2_French is automatically mounted just above it, overriding any content in HL2.

待完善: Does this also apply for the mod folder?

示例

一个能够正常在 起源2013 起源2013 游戏中使用的 GameInfo.txt

"GameInfo"
{
	game 		"HALF-LIFE 2"
	title 		"HALF-LIFE'"
	type		singleplayer_only
	supportsvr	1

	FileSystem
	{
		SteamAppId				220		// This will mount all the GCFs we need (240=CS:S, 220=HL2).
		
		//
		// The code that loads this file automatically does a few things here:
		//
		// 1. For each "Game" search path, it adds a "GameBin" path, in <dir>\bin
		// 2. For each "Game" search path, it adds another "Game" path in front of it with _<langage> at the end.
		//    For example: c:\hl2\cstrike on a french machine would get a c:\hl2\cstrike_french path added to it.
		// 3. For the first "Game" search path, it adds a search path called "MOD".
		// 4. For the first "Game" search path, it adds a search path called "DEFAULT_WRITE_PATH".
		//

		//
		// Search paths are relative to the base directory, which is where hl2.exe is found.
		//
		// |gameinfo_path| points at the directory where gameinfo.txt is.
		// We always want to mount that directory relative to gameinfo.txt, so
		// people can mount stuff in c:\mymod, and the main game resources are in
		// someplace like c:\program files\valve\steam\steamapps\half-life 2.
		//
		SearchPaths
		{
			// First, mount all user customizations.  This will search for VPKs and subfolders
			// and mount them in alphabetical order.  The easiest way to distribute a mod is to
			// pack up the custom content into a VPK.  To "install" a mod, just drop it in this
			// folder.
			//
			// Note that this folder is scanned only when the game is booted.
			game+mod			hl2/custom/*

			// We search VPK files before ordinary folders, because most files will be found in
			// VPK and we can avoid making thousands of file system calls to attempt to open files
			// in folders where they don't exist.  (Searching a VPK is much faster than making an operating
			// system call.)
			game_lv				hl2/hl2_lv.vpk
			game+mod			hl2/hl2_sound_vo_english.vpk
			game+mod			hl2/hl2_pak.vpk
			game				|all_source_engine_paths|hl2/hl2_textures.vpk
			game				|all_source_engine_paths|hl2/hl2_sound_misc.vpk
			game				|all_source_engine_paths|hl2/hl2_misc.vpk
			platform			|all_source_engine_paths|platform/platform_misc.vpk

			// Now search loose files.  We'll set the directory containing the gameinfo.txt file
			// as the first "mod" search path (after any user customizations).  This is also the one
			// that's used when writing to the "mod" path.
			mod+mod_write+default_write_path		|gameinfo_path|.

			// Add the HL2 directory as a game search path.  This is also where where writes
			// to the "game" path go.
			game+game_write		hl2

			// Where the game's binaries are
			gamebin				hl2/bin

			// Last, mount in shared HL2 loose files
			game				|all_source_engine_paths|hl2
			platform			|all_source_engine_paths|platform
		}
	}
}


使用 XBLAH's Modding Tool 编辑 GameInfo 文件

The mod information can be edited with XBLAH's Modding Tool(en) through a comprehensive UI without requiring the modder to mess with text files. It includes all the major keys of Source SDK 2013 Single-player and Source SDK 2013 Multi-player, more than enough for the majority of Source modders.

This can be accessed within the tool through Modding > Game info.


站外链接