Interface modding:修订间差异

本页面讲述的内容长期有效
无编辑摘要
(文本替换 - 替换“[[Category:”为“[[分类:”)
 
(未显示1个用户的5个中间版本)
第1行: 第1行:
{{Version|Timeless}}
{{Version|Timeless}}
 在《钢铁雄心IV》中, 接口 是指玩家用来与游戏交互的用户界面。
 在《钢铁雄心IV》中, 界面 是指玩家用来与游戏交互的用户界面。


== 概述 ==
== 概述 ==
  接口 文件的组件可以分为两组:容器和元素。例如,''containerWindowType'' 是一个容器,而 ''iconType'' 是一个元素。
  界面 文件的组件可以分为两组:容器和元素。例如,''containerWindowType'' 是一个容器,而 ''iconType'' 是一个元素。


  接口 文件使用 .gui 文件类型。 所有 接口 文件都可以在 {{path|interface/}} 中找到。
  界面 文件使用 .gui 文件类型。 所有 界面 文件都可以在 {{path|interface/}} 中找到。


 当出现 ''internal''  字样时,这个部分的源代码是只有P社可以修改的,即它所指的主题是不可修改的。
 当出现 ''internal''  字样时,这个部分的源代码是只有P社可以修改的,即它所指的主题是不可修改的。
第43行: 第43行:
* '''fullscreen''' -设置是否将容器全屏化。
* '''fullscreen''' -设置是否将容器全屏化。
* '''orientation''' - 设置 ''position'' 属性的方向原点。
* '''orientation''' - 设置 ''position'' 属性的方向原点。
* '''clipping''' - 设置容器是否将修剪其他元素 如在边界处剪切其元素
* '''clipping''' - 设置容器是否将修剪其他元素( 如在边界处剪切其元素)


 以下属性用于动画容器:
 以下属性用于动画容器:
* '''show_position''' - 容器在''显示''模式下移动到的屏幕位置。
* '''show_position''' - 容器在''显示''模式下移动到的屏幕位置。
* '''hide_position''' - 容器在''隐藏''模式下移动到的屏幕位置。
* '''hide_position''' - 容器在''隐藏''模式下移动到的屏幕位置。
* '''show_animation_type''' - The animation type used to show the container (always ''decelerated''). 用于显示容器的动画类型 始终''减速 ''。
* '''show_animation_type''' - 用于显示容器的动画类型( 始终''减速)''。
* '''hide_animation_type''' - The animation type used to hide the container (always ''accelerated''). 用于隐藏容器的动画类型 始终''加速 。''
* '''hide_animation_type''' - 用于隐藏容器的动画类型( 始终''加速) 。''
* '''animation_time''' - 动画播放时间 始终''为 300''
* '''animation_time''' - 动画播放时间( 始终''为 300'')
* '''upsound''' - 当容器移动到''显示''位置时要播放的声音。
* '''upsound''' - 当容器移动到''显示''位置时要播放的声音。
* '''downsound''' - 当容器移动到''隐藏''位置时要播放的声音。
* '''downsound''' - 当容器移动到''隐藏''位置时要播放的声音。
* '''fade_time''' - 淡入淡出的时间。
* '''fade_time''' - 淡入淡出的时间。
* '''fade_type''' - 淡入的类型 始终为''线性''
* '''fade_type''' - 淡入的类型( 始终为''线性'')


 以下属性很少或从不使用:
 以下属性很少或从不使用:
第62行: 第62行:


== scrollbarType ==
== scrollbarType ==
The '''scrollbarType''' is used to define which elements a scrollbar is composed of.
'' 滚动条'' 用于定义滚动条由哪些元素组成。


The following attributes are used:
使用以下属性:
* '''name''' - The scrollbar name.
* '''name''' - 滚动条名称。
* '''slider''' - The button element to use as the scrollbar slider.
* '''slider''' - 用作滚动条滑块的按钮元素。
* '''track''' - The button element to use as the scrollbar tracker.
* '''track''' - 用作滚动条跟踪器的按钮元素。
* '''leftbutton''' - The button element to use as the scrollbar left increment button.
* '''leftbutton''' - 用作滚动条左增量按钮的按钮元素。
* '''rightbutton''' - The button element to use as the scrollbar right increment button.
* '''rightbutton''' - 用作滚动条右增量按钮的按钮元素。
* '''position''' - The screen position of the scrollbar.
* '''position''' - 滚动条的屏幕位置。
* '''size''' - The bounding box for the scrollbar.
* '''size''' - 滚动条的边界框。
* '''priority''' - The priority the scrollbar has over other elements.
* '''priority''' - 滚动条相对于其他元素的优先级。
* '''borderSize''' - The bounding box for border of the scrollbar.
* '''borderSize''' - 滚动条边框的边界框。
* '''maxValue''' - The maximum value the scrollbar moves to (used to control the increments).
* '''maxValue''' - 滚动条能移动的最大值( 用于控制增量)
* '''minValue''' - The minimum value the scrollbar moves to (used to control the increments).
* '''minValue''' - 滚动条能移动的最小值( 用于控制增量)
* '''stepSize''' - The size of increments using the increment button.
* '''stepSize''' - 使用增量按钮的单次增量大小。
* '''startValue''' - The initial size the slider for the scrollbar starts at.
* '''startValue''' - 滚动条滑块的初始大小。
* '''horizontal''' - Sets whether the scrollbar is horizontal (1) or vertical (0).
* '''horizontal''' - 设置滚动条是水平 (1) 还是垂直 (0)


== Elements ==
== Elements ==
There are multiple element types used within containers. All elements must be used within containers, they will not work outside of one.
容器中使用了多种元素类型。所有元素都必须在容器内使用,它们不会在容器之外工作。


Elements will inherit the orientation of the containers they are located in unless the orientation is specified for the element itself.
元素将继承它们所在的容器的方向,除非为自己指定了方向。


The following elements can be freely added and are usable with scripted GUIs.
以下元素可以自由添加,并可用于脚本化 GUI。
* '''iconType''' - Used for static images.
* '''iconType''' - 用于静态图像。
* '''instantTextBoxType''' - Used for text.
* '''instantTextBoxType''' - 用于文本。
* '''buttonType''' - Used for buttons
* '''buttonType''' - 用于按钮。


The following elements do rely on internal code. You can add new elements, they will not be populated with data.
以下元素依赖于内部代码。您可以添加新元素,它们不会填充数据。
* '''smoothListboxType''' - Used for smooth scrollable lists.
* '''smoothListboxType''' - 用于平滑滚动列表。
* '''listboxType''' - Used for scrollable lists.
* '''listboxType''' - 用于滚动列表。
* '''checkboxType''' - Used for checkboxes.
* '''checkboxType''' - 用于复选框。
* '''OverlappingElementsBoxType''' - Used for overlapping many elements.
* '''OverlappingElementsBoxType''' - 用于重叠元素。
* '''editBoxType''' - Used for editable textboxes.
* '''editBoxType''' - 用于可编辑的文本框。
* '''shieldtype''' - Used for to display country flags.
* '''shieldtype''' - 用于显示国家/地区旗帜。


The following elements are legacy:
以下元素已过时:
* '''guiButtonType''' - Same as ''buttonType''.
* '''guiButtonType''' - ''buttonType'' 相同。
* '''textBoxType''' - Same as ''instantTextBoxType''.
* '''textBoxType''' - ''instantTextBoxType'' 相同。
* '''eu3dialogtype''' - Same as ''windowType''.
* '''eu3dialogtype''' - ''windowType'' 相同。
* '''shieldtype''' - Only used within ''eu3dialogtype''. Different elements are used for flags in more recent files.
* '''shieldtype''' - 仅在 ''eu3dialogtype'' 中使用。 较新的文件中的标志使用不同的元素。


== iconType ==
== iconType ==
The ''iconType'' element is used to add images to the interface. It's usage overlaps with ''buttonType'', which is similar but operates as a button.
'' 图标'' 元素用于向界面添加图像。它的用法与 ''buttonType'' 重叠,但后者作为按钮运行。


The following attributes are used:
使用以下属性:
* '''name''' - The icon name.
* '''name''' - 图标名称。
* '''position''' - The screen position of the icon.
* '''position''' - 图标的屏幕位置。
* '''orientation''' - Sets the orientation origin for the ''position'' attribute.
* '''orientation''' - 设置'' 位置'' 属性的方向原点。
* '''spriteType''' - The image to use for the icon. Refers to a ''spriteType'' definition.
* '''spriteType''' - 用于图标的图像。引用 ''spriteType'' 定义。
* '''quadTextureSprite''' - The image to use for the icon. Refers to a dynamic ''spriteType'' definitions (i.e. flags) or multi-frame ''spriteType'' definitions.
* '''quadTextureSprite''' - 用于图标的图像。引用动态的 ''spriteType'' 定义( 例如旗帜) 或多帧的 ''spriteType'' 定义。
* '''frame''' - Which frame to use for the icon when using a multi-frame image.
* '''frame''' - 使用多帧图像时要用于图标的帧。
* '''alwaystransparent''' - Forces the icon to allow click through, i.e. clicking on an element behind another element.
* '''alwaystransparent''' -  强制图标透明,如点击只能一个元素后面的另一个元素。
* '''hint_tag''' - Set the hint key the icon uses to display a hint tooltip with when hovered over.
* '''hint_tag''' - 设置鼠标悬停在图标上方时用于显示提示的关键字。
* '''pdx_tooltip''' - Sets the tooltip to display to the player. Takes a localization key.
* '''pdx_tooltip''' - 设置要向玩家显示的提示。采用本地化关键字。
* '''pdx_tooltip_delayed''' - Sets the delayed tooltip to display to the player. Takes a localization key.
* '''pdx_tooltip_delayed''' - 设置要向玩家延迟显示的提示。采用本地化关键字。
* '''centerposition''' - Sets whether the position is from the center of the icon.
* '''centerposition''' - 设置位置是否以图标的中心为原点。


== instantTextBoxType ==
== instantTextBoxType ==
The ''instantTextBoxType'' element is used to add text to the interface. In some instances, the text for the element is generated internally (i.e. ''regiment_count''). In these instances you cannot edit the text unless it is exposed in an localized string.
'' 实例文本框'' 元素用于向界面添加文本。在某些情况下,元素的文本是在内部生成的( ''regiment_count'') 。在这些情况下,除非文本在本地化字符串中公开,否则无法对其进行编辑。


The following attributes are used:
使用以下属性:
* '''name''' - The textbox name.
* '''name''' - 文本框名称。
* '''position''' - The screen position of the textbox.
* '''position''' - 文本框的屏幕位置。
* '''orientation''' - Sets the orientation origin for the ''position'' attribute.
* '''orientation''' - 设置'' 位置'' 属性的方向原点。
* '''text''' - The text displayed by the textbox.
* '''text''' - 文本框显示的文本。
* '''font''' - The font to use for the text.
* '''font''' - 用于文本的字体。
* '''maxWidth''' - The total width in pixels at which text is displayed.
* '''maxWidth''' - 显示文本的总宽度,以像素为单位。
* '''maxHeight''' - The total height in pixels at which text is displayed.
* '''maxHeight''' - 显示文本的总高度,以像素为单位。
* '''format''' - How the text is aligned.
* '''format''' - 文本的对齐方式。
* '''fixedsize''' - Whether the textbox should truncate text that exceeds its limits.
* '''fixedsize''' - 文本框是否截断超出其边框的文本。
* '''borderSize''' - The bounding box for the border of the textbox.
* '''borderSize''' - 文本框边框的边界框。
* '''alwaystransparent''' - Forces the text to allow click through, i.e. clicking on an element behind another element.
* '''alwaystransparent''' - 强制文本透明,如点击只能一个元素后面的另一个元素。
* '''pdx_tooltip''' - Sets the tooltip to display to the player. Takes a localization key.
* '''pdx_tooltip''' - 设置要向玩家显示的提示。采用本地化关键字。
* '''pdx_tooltip_delayed''' - Sets the delayed tooltip to display to the player. Takes a localization key.
* '''pdx_tooltip_delayed''' - 设置要向玩家延迟显示的提示。采用本地化关键字。


The following attributes are rarely or never used:
以下属性很少或从不使用:
* '''textureFile''' - Never used for anything.
* '''textureFile''' - 从不使用。


Valid ''format'' values:
可用的 ''format'' :
* left
* left
* centre
* centre
第147行: 第147行:


== buttonType ==
== buttonType ==
The ''guiButtonType''' element is used to add buttons to the interface. Buttons are composed of an image and text, so they operate in a similar manner to ''iconType'' and ''instantTextBoxType''.
'' 按钮'' 元素用于向界面添加按钮。按钮由图像和文本组成,因此它们的操作方式与 ''iconType'' ''instantTextBoxType'' 类似。


The following attributes are used:
使用以下属性:
* '''name''' - The button name.
* '''name''' - 按钮名称。
* '''position''' - The screen position of the button.
* '''position''' - 按钮名称。
* '''orientation''' - Sets the orientation origin for the ''position'' attribute.
* '''orientation''' - 设置'' 位置'' 属性的方向原点。
* '''spriteType''' - The image to use for the button. Refers to a ''spriteType'' definition.
* '''spriteType''' - 用于按钮的图像。引用 ''spriteType''  定义。
* '''quadTextureSprite''' - The image to use for the button. Refers to a dynamic ''spriteType'' definitions (i.e. flags) or multi-frame ''spriteType'' definitions.
* '''quadTextureSprite''' - 用于按钮的图像。引用动态的 ''spriteType'' 定义( 如旗帜) 或多帧的 ''spriteType'' 定义。
* '''frame''' - Which frame to use for the button when using a multi-frame image.
* '''frame''' - 使用多帧图像时要用于按钮的帧。
* '''alwaystransparent''' - Forces the button to allow click through, i.e. clicking on an element behind another element.
* '''alwaystransparent''' - 强制按钮透明,如点击只能一个元素后面的另一个元素。
* '''buttonText''' - The text displayed by the button.
* '''buttonText''' - 按钮显示的文本。
* '''buttonFont''' - The font to display the button text in.
* '''buttonFont''' - 用于文本的字体。
* '''shortcut''' - The shortcut to add for this button.
* '''shortcut''' -  为此按钮添加的快捷方式。
* '''clicksound''' - The sound to use when clicked.
* '''clicksound''' - 点击时要播放的声音。
* '''oversound''' - The sound to play when hovered over.
* '''oversound''' - 悬停时要播放的声音。
* '''hint_tag''' - Set the hint key the icon uses to display a hint tooltip with when hovered over.
* '''hint_tag''' - 设置鼠标悬停在按钮上方时用于显示提示的关键字。
* '''pdx_tooltip''' - Sets the tooltip to display to the player. Takes a localization key.
* '''pdx_tooltip''' - 设置要向玩家显示的提示。采用本地化关键字。
* '''pdx_tooltip_delayed''' - Sets the delayed tooltip to display to the player. Takes a localization key.
* '''pdx_tooltip_delayed''' - 设置要向玩家延迟显示的提示。采用本地化关键字。
* '''scale''' - Scales the button size.
* '''scale''' - 缩放按钮大小。


The following attributes are rarely or never used:
以下属性很少或从不使用:
* '''tooltip''' - Never used.
* '''tooltip''' - 从未使用过。
* '''tooltipText''' - Never used.
* '''tooltipText''' - 从未使用过。
* '''delayedTooltipText''' - Never used.
* '''delayedTooltipText''' - 从未使用过。


== smoothListboxType ==
== smoothListboxType ==
The ''smoothListboxType'' element is used to define a listbox, which is a scrollable list that is populated with entries. Typically these elements are internally linked with another container, which composes the actual entry used in the list box.
'' 平滑列表框'' 元素用于定义列表框,该列表框是用条目填充的可滚动列表。 通常,这些元素在内部与另一个容器链接,来构成列表框中使用的实际条目。


The following attributes are used:
使用以下属性:
* '''name''' - The listbox name.
* '''name''' - 列表框名称。
* '''position''' - The screen position of the listbox.
* '''position''' - 列表框的屏幕位置。
* '''orientation''' - Sets the orientation origin for the ''position'' attribute.
* '''orientation''' - 设置'' 位置'' 属性的方向原点。
* '''size''' - The bounding box for the listbox.
* '''size''' - 列表框的边界框。
* '''spacing''' - The spacing to use between listbox entries.
* '''spacing''' - 列表框条目的间距。
* '''horizontal'' - Whether the listbox is horizontal (1) or vertical (0).
* '''horizontal''' - 列表框是水平 (1) 还是垂直 (0)
* '''scrollbartype''' - The scrollbar to use for the listbox.
* '''scrollbartype''' - 用于列表框的滚动条。
* '''bordersize''' - The bounding box for the border for the listbox.
* '''bordersize''' - 列表框边框的边界框。
* '''alwaystransparent''' - Forces the listbox to allow click through, i.e. clicking on an element behind another element.
* '''alwaystransparent''' - 强制列表框透明,如点击只能一个元素后面的另一个元素。


The following attributes are rarely or never used:
以下属性很少或从不使用:
* '''background''' - Never used.
* '''background''' - 从不使用。


== listboxType ==
== listboxType ==
The ''listboxType '' element is used to define a listbox, which is a scrollable list that is populated with entries. Typically these elements are internally linked with another container, which composes the actual entry used in the list box.
'' 列表框'' 元素用于定义列表框,列表框是用条目填充的可滚动列表。通常,这些元素在内部与另一个容器链接,该容器构成列表框中使用的实际条目。


The following attributes are used:
使用以下属性:
* '''name''' - The listbox name.
* '''name''' - 列表框名称。
* '''position''' - The screen position of the listbox.
* '''position''' - 列表框的屏幕位置。
* '''orientation''' - Sets the orientation origin for the ''position'' attribute.
* '''orientation''' - 设置'' 位置'' 属性的方向原点。
* '''size''' - The bounding box for the listbox.
* '''size''' - 列表框的边界框。
* '''spacing''' - The spacing to use between listbox entries.
* '''spacing''' - 列表框条目的间距。
* '''horizontal'' - Whether the listbox is horizontal (1) or vertical (0).
* '''horizontal''' - 列表框是水平 (1) 还是垂直 (0)
* '''scrollbartype''' - The scrollbar to use for the listbox.
* '''scrollbartype''' - 用于列表框的滚动条。
* '''bordersize''' - The bounding box for the border for the listbox.
* '''bordersize''' - 列表框边框的边界框。
* '''alwaystransparent''' - Forces the listbox to allow click through, i.e. clicking on an element behind another element.
* '''alwaystransparent''' - 强制列表框透明,如点击只能一个元素后面的另一个元素。


The following attributes are rarely or never used:
以下属性很少或从不使用:
* '''background''' - Never used.
* '''background''' - 从未使用过。


== checkboxType ==
== checkboxType ==
The ''checkboxType '' element is used to add checkboxes to the interface. The actual effect of the checkbox is defined internally.
'' 复选框'' 元素用于向界面添加复选框。复选框的实际效果在内部( ''internal'' )定义。


The following attributes are used:
使用以下属性:
* '''name''' - The checkbox name.
* '''name''' - 复选框名称。
* '''position''' - The screen position of the checkbox.
* '''position''' - 复选框的屏幕位置。
* '''orientation''' - Sets the orientation origin for the ''position'' attribute.
* '''orientation''' - 设置'' 位置'' 属性的方向原点。
* '''spriteType''' - The image to use for the checkbox. Refers to a ''spriteType'' definition.
* '''spriteType''' - 用于复选框的图像。引用 ''spriteType''  定义。
* '''quadTextureSprite''' - The image to use for the checkbox. Refers to a dynamic ''spriteType'' definitions (i.e. flags) or multi-frame ''spriteType'' definitions.
* '''quadTextureSprite''' - 用于复选框的图像。 引用动态的 ''spriteType'' 定义(例如旗帜)或多帧的 ''spriteType'' 定义。
* '''frame''' - Which frame to use for the checkbox when using a multi-frame image.
* '''frame''' - 使用多帧图像时要用于图标的帧。
* '''alwaystransparent''' - Forces the checkbox to allow click through, i.e. clicking on an element behind another element.
* '''alwaystransparent''' - 强制复选框透明,如点击只能一个元素后面的另一个元素。
* '''buttonText''' - The text displayed by the checkbox.
* '''buttonText''' - 复选框显示的文本。
* '''buttonFont''' - The font to display the checkbox text in.
* '''buttonFont''' - 用于文本的字体。
* '''shortcut''' - The shortcut to add for this checkbox.
* '''shortcut''' - 要为此复选框添加的快捷方式。
* '''clicksound''' - The sound to use when clicked.
* '''clicksound''' - 点击时要使用的声音。
* '''hint_tag''' - Set the hint key the checkbox uses to display a hint tooltip with when hovered over.
* '''hint_tag''' - 设置鼠标悬停在复选框上方时用于显示提示的关键字。
* '''pdx_tooltip''' - Set the short tooltip this checkbox uses.
* '''pdx_tooltip''' - 设置要向玩家显示的提示。
* '''pdx_tooltip_delayed''' - Set the full tooltip this checkbox uses.
* '''pdx_tooltip_delayed''' - 设置要向玩家延迟显示的提示。
* '''scale''' - Scales the checkbox size.
* '''scale''' - 缩放复选框大小。


The following attributes are rarely or never used:
以下属性很少或从不使用:
* '''tooltip''' - Never used.
* '''tooltip''' - 从未使用过。
* '''tooltipText''' - Never used.
* '''tooltipText''' - 从未使用过。
* '''delayedTooltipText''' - Never used.
* '''delayedTooltipText''' - 从未使用过。


== editBoxType ==
== editBoxType ==
The ''editBoxType'' element is used to add editable textboxes to the interface.
'' 编辑文本框'' 元素用于将可编辑的文本框添加到界面。


The following attributes are used:
使用以下属性:
* '''name''' - The textbox name.
* '''name''' - 文本框名称。
* '''position''' - The screen position of the textbox.
* '''position''' - 文本框的屏幕位置。
* '''orientation''' - Sets the orientation origin for the ''position'' attribute.
* '''orientation''' - 设置'' 位置'' 属性的方向原点。
* '''text''' - The text displayed by the textbox.
* '''text''' - 文本框显示的文本。
* '''font''' - The font to use for the text.
* '''font''' - 用于文本的字体。
* '''maxWidth''' - The total width in pixels at which text is displayed.
* '''maxWidth''' - 显示文本的总宽度,以像素为单位。
* '''maxHeight''' - The total height in pixels at which text is displayed.
* '''maxHeight''' - 显示文本的总高度,以像素为单位。
* '''format''' - How the text is aligned.
* '''format''' - 文本的对齐方式。
* '''fixedsize''' - Whether the textbox should truncate text that exceeds its limits.
* '''fixedsize''' - 文本框是否截断超出其边框的文本。
* '''borderSize''' - The bounding box for the border of the textbox.
* '''borderSize''' - 文本框边框的边界框。
* '''alwaystransparent''' - Forces the text to allow click through, i.e. clicking on an element behind another element.
* '''alwaystransparent''' - 强制文本框透明,如点击只能一个元素后面的另一个元素。
* '''ignore_tab_navigation''' - Makes the element ignore tab navigation.
* '''ignore_tab_navigation''' - 使元素忽略选项卡导航。
 
可用的 ''format'' 值:
* left
* centre
* right


== OverlappingElementsBoxType ==
== OverlappingElementsBoxType ==
The ''OverlappingElementsBoxType'' element is used to define a special kind of listbox that dynamically overlaps sub-elements within itself.
'' 重叠元素框'' 元素用于定义一种特殊类型的列表框,该列表框在其内部动态重叠子元素。


The following attributes are used:
使用以下属性:
* '''name''' - The listbox name.
* '''name''' - 列表框名称。
* '''position''' - The screen position of the listbox.
* '''position''' - 列表框的屏幕位置。
* '''orientation''' - Sets the orientation origin for the ''position'' attribute.
* '''orientation''' - 设置'' 位置'' 属性的方向原点。
* '''size''' - The bounding box for the listbox.
* '''size''' - 列表框的边界框。
* '''spacing''' - The spacing to use between listbox entries.
* '''spacing''' - 列表框条目的间距。
* '''horizontal'' - Whether the listbox is horizontal (1) or vertical (0).
* '''horizontal''' - 列表框是水平 (1) 还是垂直 (0)
* '''bordersize''' - The bounding box for the border for the listbox.
* '''bordersize''' - 列表框边框的边界框。
* '''alwaystransparent''' - Forces the listbox to allow click through, i.e. clicking on an element behind another element.
* '''alwaystransparent''' - 强制列表框透明,如点击只能一个元素后面的另一个元素。


The following attributes are rarely or never used:
以下属性很少或从不使用:
* '''textureFile''' - Never used for anything.
* '''textureFile''' - 从不使用。
 
Valid ''format'' values:
* left
* centre
* right


== Position and Orientation ==
== 位置与方向原点 ==
Understanding how the position coordinates work is important to understanding how to edit interfaces correctly.
了解位置坐标如何工作对于正确编辑界面非常重要。


The ''orientation'' attribute used by an element (or container) informs you where the anchor point for the element is. For example, ''UPPER_LEFT'' means the ''( 0, 0 )'' position is in the top left corner of the screen, whereas ''LOWER_RIGHT'' is the bottom right.
元素(或容器)使用的 ''orientation'' 属性会通知您元素的锚点所在位置。例如,''UPPER_LEFT'' 表示位于屏幕的左上角的 (''0, 0)'' 位置,而 ''LOWER_RIGHT'' 是右下角。


The ''position'' attribute then works from this origin position. Therefore if you want an element to be on the opposite side of the screen, you'd want to change the ''orientation'' first.
然后,''position'' 属性从此锚点位置工作。因此,如果您希望元素位于屏幕的另一侧,则需要先更改 ''orientation''


This is system is used because it allows the interface to adapt to different resolutions. Because all positions are tied to a specific origin that is dynamically calculated from the player's screen resolution, the placement of containers and elements are kept consistent.
使用这个系统是因为它允许界面适应不同的分辨率。因为所有的位置都与一个特定的原点相联系,这个原点是根据玩家的屏幕分辨率动态计算的,所以容器和元素的位置保持稳定。


So, if you want to ensure your interface edits are consistent, you must use the ''orientation'' attribute properly.
所以,如果你想确保你的界面编辑是稳定的,你必须正确使用 ''orientation'' 属性。


An mistake would be to edit the ''position'' solely, for example <code>position = { x = 1800 y = 200 }</code>. This would look fine for anybody with a screen width greater than 1800px (i.e. 1900 x 1200 upwards), but the element would be off screen for those with smaller screens.
一个错误的做法是只编辑 ''position'' , 例如 <code>position = { x = 1800 y = 200 }</code> 。这在拥有1800以上像素的显示器( 如1900 x 1200 以上) 中能正常工作,但在更小的显示器上就看不到了。


Valid ''orientation'' values (can be upper or lowercase):
可用的 ''orientation'' ( 大小写不敏感):
* CENTER
* CENTER
* UPPER_LEFT
* UPPER_LEFT
第289行: 第289行:
* LOWER_RIGHT
* LOWER_RIGHT


== Fonts ==
== 字体 ==
''See also: [[Font modding]]''
'' 参考: [[Font modding|Font Modding]]''


The following fonts are usable in Hearts of Iron IV:
在《钢铁雄心IV》中可用的字体如下:
* Arial12
* Arial12
* Arial12_bold
* Arial12_bold
第339行: 第339行:


{{Modding navbox}}
{{Modding navbox}}
[[Category:Modding]]
[[ 分类:Modding]]

2022年12月5日 (一) 15:55的最新版本

在《钢铁雄心IV》中,界面是指玩家用来与游戏交互的用户界面。

概述

界面文件的组件可以分为两组:容器和元素。例如,containerWindowType 是一个容器,而 iconType 是一个元素。

界面文件使用 .gui 文件类型。 所有界面文件都可以在 /Hearts of Iron IV/interface/ 中找到。

当出现 internal 字样时,这个部分的源代码是只有P社可以修改的,即它所指的主题是不可修改的。

可以在界面文件中使用宏,以便更轻松地调整位置。

例如,这将使一个名为 WINDOW_X_POS 的宏,其值为 10。

@WINDOW_X_POS = 10

可以在元素中这样引用它:

containerWindowType = {
    name = "my_container"
    position = { x = @WINDOW_X_POS y = -600 }

    # ...
}

容器

容器用于将元素组合在一起,并将它们与内部函数相关联。

除非通过脚本化 GUI,否则无法添加新容器。这是因为容器的 name 属性在内部链接到容器所需的任何数据。常见的例外是,您可以在 countrytechtreeview.gui 中为自定义技术文件夹添加新容器。

容器定义的顺序和嵌套会影响它们的显示方式。

containerWindowType

最常见的容器类型,用于保存任何一组元素。

通常使用以下属性:

  • name - 容器的名称。
  • background - 容器的背景。
  • position - 容器的屏幕位置。
  • size - 容器的边界框。接受百分数( 如 100%% )。
  • moveable - 设置是否可以拖动容器。
  • fullscreen -设置是否将容器全屏化。
  • orientation - 设置 position 属性的方向原点。
  • clipping - 设置容器是否将修剪其他元素(如在边界处剪切其元素)。

以下属性用于动画容器:

  • show_position - 容器在显示模式下移动到的屏幕位置。
  • hide_position - 容器在隐藏模式下移动到的屏幕位置。
  • show_animation_type - 用于显示容器的动画类型(始终减速)
  • hide_animation_type - 用于隐藏容器的动画类型(始终加速)。
  • animation_time - 动画播放时间(始终为 300)。
  • upsound - 当容器移动到显示位置时要播放的声音。
  • downsound - 当容器移动到隐藏位置时要播放的声音。
  • fade_time - 淡入淡出的时间。
  • fade_type - 淡入的类型(始终为线性)。

以下属性很少或从不使用:

  • dontRender - 不渲染
  • horizontalBorder - 水平边界
  • verticalBorder - 垂直边界

scrollbarType

滚动条用于定义滚动条由哪些元素组成。

使用以下属性:

  • name - 滚动条名称。
  • slider - 用作滚动条滑块的按钮元素。
  • track - 用作滚动条跟踪器的按钮元素。
  • leftbutton - 用作滚动条左增量按钮的按钮元素。
  • rightbutton - 用作滚动条右增量按钮的按钮元素。
  • position - 滚动条的屏幕位置。
  • size - 滚动条的边界框。
  • priority - 滚动条相对于其他元素的优先级。
  • borderSize - 滚动条边框的边界框。
  • maxValue - 滚动条能移动的最大值(用于控制增量)。
  • minValue - 滚动条能移动的最小值(用于控制增量)。
  • stepSize - 使用增量按钮的单次增量大小。
  • startValue - 滚动条滑块的初始大小。
  • horizontal - 设置滚动条是水平 (1) 还是垂直 (0)。

Elements

容器中使用了多种元素类型。所有元素都必须在容器内使用,它们不会在容器之外工作。

元素将继承它们所在的容器的方向,除非为自己指定了方向。

以下元素可以自由添加,并可用于脚本化 GUI。

  • iconType - 用于静态图像。
  • instantTextBoxType - 用于文本。
  • buttonType - 用于按钮。

以下元素依赖于内部代码。您可以添加新元素,它们不会填充数据。

  • smoothListboxType - 用于平滑滚动列表。
  • listboxType - 用于滚动列表。
  • checkboxType - 用于复选框。
  • OverlappingElementsBoxType - 用于重叠元素。
  • editBoxType - 用于可编辑的文本框。
  • shieldtype - 用于显示国家/地区旗帜。

以下元素已过时:

  • guiButtonType - 与 buttonType 相同。
  • textBoxType -与 instantTextBoxType 相同。
  • eu3dialogtype - 与 windowType 相同。
  • shieldtype - 仅在 eu3dialogtype 中使用。 较新的文件中的标志使用不同的元素。

iconType

图标元素用于向界面添加图像。它的用法与 buttonType 重叠,但后者作为按钮运行。

使用以下属性:

  • name - 图标名称。
  • position - 图标的屏幕位置。
  • orientation - 设置位置属性的方向原点。
  • spriteType - 用于图标的图像。引用 spriteType 定义。
  • quadTextureSprite - 用于图标的图像。引用动态的 spriteType 定义(例如旗帜)或多帧的 spriteType 定义。
  • frame - 使用多帧图像时要用于图标的帧。
  • alwaystransparent - 强制图标透明,如点击只能一个元素后面的另一个元素。
  • hint_tag - 设置鼠标悬停在图标上方时用于显示提示的关键字。
  • pdx_tooltip - 设置要向玩家显示的提示。采用本地化关键字。
  • pdx_tooltip_delayed - 设置要向玩家延迟显示的提示。采用本地化关键字。
  • centerposition - 设置位置是否以图标的中心为原点。

instantTextBoxType

实例文本框元素用于向界面添加文本。在某些情况下,元素的文本是在内部生成的(如regiment_count)。在这些情况下,除非文本在本地化字符串中公开,否则无法对其进行编辑。

使用以下属性:

  • name - 文本框名称。
  • position - 文本框的屏幕位置。
  • orientation - 设置位置属性的方向原点。
  • text - 文本框显示的文本。
  • font - 用于文本的字体。
  • maxWidth - 显示文本的总宽度,以像素为单位。
  • maxHeight - 显示文本的总高度,以像素为单位。
  • format - 文本的对齐方式。
  • fixedsize - 文本框是否截断超出其边框的文本。
  • borderSize - 文本框边框的边界框。
  • alwaystransparent - 强制文本透明,如点击只能一个元素后面的另一个元素。
  • pdx_tooltip - 设置要向玩家显示的提示。采用本地化关键字。
  • pdx_tooltip_delayed - 设置要向玩家延迟显示的提示。采用本地化关键字。

以下属性很少或从不使用:

  • textureFile - 从不使用。

可用的 format 值:

  • left
  • centre
  • right

buttonType

按钮元素用于向界面添加按钮。按钮由图像和文本组成,因此它们的操作方式与 iconTypeinstantTextBoxType 类似。

使用以下属性:

  • name - 按钮名称。
  • position - 按钮名称。
  • orientation - 设置位置属性的方向原点。
  • spriteType - 用于按钮的图像。引用 spriteType 定义。
  • quadTextureSprite - 用于按钮的图像。引用动态的 spriteType 定义(如旗帜)或多帧的 spriteType 定义。
  • frame - 使用多帧图像时要用于按钮的帧。
  • alwaystransparent - 强制按钮透明,如点击只能一个元素后面的另一个元素。
  • buttonText - 按钮显示的文本。
  • buttonFont - 用于文本的字体。
  • shortcut - 为此按钮添加的快捷方式。
  • clicksound - 点击时要播放的声音。
  • oversound - 悬停时要播放的声音。
  • hint_tag - 设置鼠标悬停在按钮上方时用于显示提示的关键字。
  • pdx_tooltip - 设置要向玩家显示的提示。采用本地化关键字。
  • pdx_tooltip_delayed - 设置要向玩家延迟显示的提示。采用本地化关键字。
  • scale - 缩放按钮大小。

以下属性很少或从不使用:

  • tooltip - 从未使用过。
  • tooltipText - 从未使用过。
  • delayedTooltipText - 从未使用过。

smoothListboxType

平滑列表框元素用于定义列表框,该列表框是用条目填充的可滚动列表。 通常,这些元素在内部与另一个容器链接,来构成列表框中使用的实际条目。

使用以下属性:

  • name - 列表框名称。
  • position - 列表框的屏幕位置。
  • orientation - 设置位置属性的方向原点。
  • size - 列表框的边界框。
  • spacing - 列表框条目的间距。
  • horizontal - 列表框是水平 (1) 还是垂直 (0)。
  • scrollbartype - 用于列表框的滚动条。
  • bordersize - 列表框边框的边界框。
  • alwaystransparent - 强制列表框透明,如点击只能一个元素后面的另一个元素。

以下属性很少或从不使用:

  • background - 从不使用。

listboxType

列表框元素用于定义列表框,列表框是用条目填充的可滚动列表。通常,这些元素在内部与另一个容器链接,该容器构成列表框中使用的实际条目。

使用以下属性:

  • name - 列表框名称。
  • position - 列表框的屏幕位置。
  • orientation - 设置位置属性的方向原点。
  • size - 列表框的边界框。
  • spacing - 列表框条目的间距。
  • horizontal - 列表框是水平 (1) 还是垂直 (0)。
  • scrollbartype - 用于列表框的滚动条。
  • bordersize - 列表框边框的边界框。
  • alwaystransparent - 强制列表框透明,如点击只能一个元素后面的另一个元素。

以下属性很少或从不使用:

  • background - 从未使用过。

checkboxType

复选框元素用于向界面添加复选框。复选框的实际效果在内部( internal )定义。

使用以下属性:

  • name - 复选框名称。
  • position - 复选框的屏幕位置。
  • orientation - 设置位置属性的方向原点。
  • spriteType - 用于复选框的图像。引用 spriteType 定义。
  • quadTextureSprite - 用于复选框的图像。 引用动态的 spriteType 定义(例如旗帜)或多帧的 spriteType 定义。
  • frame - 使用多帧图像时要用于图标的帧。
  • alwaystransparent - 强制复选框透明,如点击只能一个元素后面的另一个元素。
  • buttonText - 复选框显示的文本。
  • buttonFont - 用于文本的字体。
  • shortcut - 要为此复选框添加的快捷方式。
  • clicksound - 点击时要使用的声音。
  • hint_tag - 设置鼠标悬停在复选框上方时用于显示提示的关键字。
  • pdx_tooltip - 设置要向玩家显示的提示。
  • pdx_tooltip_delayed - 设置要向玩家延迟显示的提示。
  • scale - 缩放复选框大小。

以下属性很少或从不使用:

  • tooltip - 从未使用过。
  • tooltipText - 从未使用过。
  • delayedTooltipText - 从未使用过。

editBoxType

编辑文本框元素用于将可编辑的文本框添加到界面。

使用以下属性:

  • name - 文本框名称。
  • position - 文本框的屏幕位置。
  • orientation - 设置位置属性的方向原点。
  • text - 文本框显示的文本。
  • font - 用于文本的字体。
  • maxWidth - 显示文本的总宽度,以像素为单位。
  • maxHeight - 显示文本的总高度,以像素为单位。
  • format - 文本的对齐方式。
  • fixedsize - 文本框是否截断超出其边框的文本。
  • borderSize - 文本框边框的边界框。
  • alwaystransparent - 强制文本框透明,如点击只能一个元素后面的另一个元素。
  • ignore_tab_navigation - 使元素忽略选项卡导航。

可用的 format 值:

  • left
  • centre
  • right

OverlappingElementsBoxType

重叠元素框元素用于定义一种特殊类型的列表框,该列表框在其内部动态重叠子元素。

使用以下属性:

  • name - 列表框名称。
  • position - 列表框的屏幕位置。
  • orientation - 设置位置属性的方向原点。
  • size - 列表框的边界框。
  • spacing - 列表框条目的间距。
  • horizontal - 列表框是水平 (1) 还是垂直 (0)。
  • bordersize - 列表框边框的边界框。
  • alwaystransparent - 强制列表框透明,如点击只能一个元素后面的另一个元素。

以下属性很少或从不使用:

  • textureFile - 从不使用。

位置与方向原点

了解位置坐标如何工作对于正确编辑界面非常重要。

元素(或容器)使用的 orientation 属性会通知您元素的锚点所在位置。例如,UPPER_LEFT 表示位于屏幕的左上角的 (0, 0) 位置,而 LOWER_RIGHT 是右下角。

然后,position 属性从此锚点位置工作。因此,如果您希望元素位于屏幕的另一侧,则需要先更改 orientation

使用这个系统是因为它允许界面适应不同的分辨率。因为所有的位置都与一个特定的原点相联系,这个原点是根据玩家的屏幕分辨率动态计算的,所以容器和元素的位置保持稳定。

所以,如果你想确保你的界面编辑是稳定的,你必须正确使用 orientation 属性。

一个错误的做法是只编辑 position , 例如 position = { x = 1800 y = 200 }。这在拥有1800以上像素的显示器(如1900 x 1200 以上)中能正常工作,但在更小的显示器上就看不到了。

可用的 orientation 值 (大小写不敏感):

  • CENTER
  • UPPER_LEFT
  • LOWER_LEFT
  • UPPER_RIGHT
  • LOWER_RIGHT

字体

参考: Font Modding

在《钢铁雄心IV》中可用的字体如下:

  • Arial12
  • Arial12_bold
  • cg_16b
  • cg_18b
  • garamond_12
  • garamond_14
  • garamond_14_bold
  • garamond_16
  • garamond_16_bold
  • garamond_24
  • hoi_16mbs
  • hoi_16tooltip3
  • hoi_16typewriter
  • hoi_18
  • hoi_18b
  • hoi_18mbs
  • hoi_20b
  • hoi_20bs
  • hoi_22tech
  • hoi_22typewriter
  • hoi_24header
  • hoi_26mbs
  • hoi_30header
  • hoi_33
  • hoi_36header
  • hoi4_typewriter16
  • hoi4_typewriter22
  • hoi_mapfont4
  • hoi_arrow_font
  • newsfeed_body
  • newsfeed_title
  • standard
  • standard_18
  • standard_22
  • tahoma_20_bold
  • vic_18
  • vic_18_grey
  • vic_18s
  • vic_22
  • vic_22_bl
  • vic_22s
  • vic_36
  • vic_36s