Interface modding:修订间差异

本页面讲述的内容长期有效
(文本替换 - 替换“[[Category:”为“[[分类:”)
无编辑摘要
 
第1行: 第1行:
{{Version|Timeless}}
{{Version|Timeless}}
在《钢铁雄心IV》中,界面是指玩家用来与游戏交互的用户界面。
{{需要翻译|译者=霜泽图书馆}}
The graphical user interface elements are defined within {{path|interface/*.gui}} files, as typical code formatting. The files only decide on the positions of how elements are arranged, [[Scripted GUI modding|scripted GUI]] is used to assign effects to newly-created interface elements.


== 概述 ==
== Overview ==
界面文件的组件可以分为两组:容器和元素。例如,''containerWindowType'' 是一个容器,而 ''iconType'' 是一个元素。
The interface consists of [[#Containers|container windows (or containers)]] and elements within them. Each element, other than containers, must reside in a container. Containers can be nested in other elements to organise their positions. Gridboxes are used to clone the same container several times, with different details specified for each one. Newly-added elements can have their effects defined in [[Scripted GUI modding|scripted GUI]], while the effects of base game's GUI are hard-coded, that is, it's impossible to modify what it does directly.


界面文件使用 .gui 文件类型。 所有界面文件都可以在 {{path|interface/}} 中找到。
The elements are shown in the order that they are defined in the file: what's placed later will be shown on top of what's placed earlier. The files are contained within a <code>guiTypes = { ... }</code> block overarching the entire file.


  当出现 ''internal''  字样时,这个部分的源代码是只有P社可以修改的,即它所指的主题是不可修改的。
== Constants ==
{{Hatnote|This section is transcluded from [[Data structures#Constants|Data structures § Constants]]}}
{{#section-h:Data structures|Constants}}
== Containers ==
{{anchor|ContainerWindowType}}
Containers are used to group together elements and associate them with an internal function, written as a <code>containerWindowType = { ... }</code> block.


== 宏 ==
New containers that are independent (not inside of any other container) will not show up in-game by default. For one to show up, it is required for it to be tied to a function, such as [[Scripted GUI modding|scripted GUI]], which decides where it should show and when. In some cases, new containers can be created for the internally-defined functions, such as [[Technology modding#Graphical user interface|new technology folders]] or [[Music modding#Radio stations|getting a music station to show up]]. In most cases, however, a scripted GUI would be required to make a new container show up.
可以在界面文件中使用宏,以便更轻松地调整位置。


例如,这将使一个名为 WINDOW_X_POS 的宏,其值为 10。
If a container is defined within another container, it will appear at the same time as the window containing it unless more information is defined within the function. A scripted GUI cannot be assigned to such a container, however. In some cases, it's not necessary for a container to be visible to be useful, for example, an empty container can be used as an anchor, that is, used as the [[Scripted GUI modding#Parent Window Token|parent window name]] for Scripted GUI to place another container on the same place as the anchor is defined. This can allow placing containers with higher precision than normally possible with <code>parent_window_name</code>, allowing the parent window to have elements drawn on top of the scripted GUI.
<pre>@WINDOW_X_POS = 10</pre>


  可以在元素中这样引用它:
=== Arguments ===
<pre>
The following attributes are commonly used:
containerWindowType = {
* <code>name = "my_container"</code> – The name of the container, used to tie a function to the container. Independent containers must have unique names. While nested containers may have name overlap when defined in different independent containers, it's still preferable to avoid overlap, such as to ensure unambiguity when using <code>parent_window_name</code> in scripted GUI.
   name = "my_container"
* <code>size = { height = 300 width = 100%% }</code>  – The bounding box for the container. If this container is placed inside of another one, either directly or through a gridbox, then only this size is used to create the scrollbar, without taking into account elements inside. This boundary also sets the size that the scrollbar must use. Either in pixels or in percentages relative to the size of the parent container (the entire screen if independent).
   position = { x = @WINDOW_X_POS y = -600 }
* <code>background = { ... }</code> – The background of the container. This is required for a scrollbar to work, as otherwise the boundaries will get ignored. There are the following arguments inside:
** <code>name = "Background"</code> – The name for handling the background in other functions. Commonly just set to "Background".
** <code>spriteType = "GFX_tiled_window"</code> or <code>quadTextureSprite = "GFX_tiled_window_transparent"</code> – Refers to a [[Graphical asset modding#corneredTileSpriteType|corneredTileSpriteType]] definition that would automatically get resized to fit the container's set size.
* <code>clipping = yes</code> – If true (and if a background exists), the elements inside of the container will not be able to go outside of the boundary box, and what doesn't fit will get cropped. Defaults to true. This being true is mandatory for a scrollbar to work.
* <code>position = { x = 100 y = 100 }</code> – The position of the container in pixels relative to the set orientation.
* <code>orientation = center</code> – Sets the origin that the position is measured relative to, such as <code>upper_left</code>, <code>center_down</code>, or <code>lower_right</code>.
* <code>moveable = yes</code> – If set, the container can be moved by the player with their cursor.
* <code>fullScreen = yes</code> – If set, the container will be considered to cover the entire screen.


   # ...
Animation can be assigned to containers with these attributes:
}
* <code>show_position = { x = 300 y = 100 }</code> – The screen position where the container will show up to the player after the 'show' animation finishes.
</pre>
* <code>hide_position = { x = 100 y = 100 }</code> – The screen position the container aims for during the 'hide' animation.
* <code>show_animation_type = linear</code> – The animation type used to show the container (<code>decelerated</code> or <code>linear</code>).
* <code>hide_animation_type = accelerated</code> – The animation type used to hide the container (<code>accelerated</code> or <code>linear</code>).
* <code>animation_type = decelerated</code> – The animation if both show and hide animations are supposed to be the same (<code>accelerated</code>, <code>decelerated</code>, or <code>linear</code>).
* <code>animation_time = 1000</code> – The animation time in milliseconds.
* <code>show_sound = menu_open_window</code> – The [[Sound modding|sound]] to play during the 'show' animation.
* <code>hide_sound = menu_close_window</code> – The [[Sound modding|sound]] to play during the 'hide' animation.
* <code>fade_time = 300</code>  – The time it takes for the container to fade in, in milliseconds.
* <code>fade_type = linear</code> – The type of fade in: either <code>accelerated</code> or <code>linear</code>.


== 容器 ==
=== Scrolling ===
容器用于将元素组合在一起,并将它们与内部函数相关联。
Scrolling can be done via scrollbars. If scrollbars are enabled, it's also possible to enabled it with dragging the screen. Since the game has to know what should be inside of the container, there are some attributes which must be used in the container. <code>size = { ... }</code> has to be defined using pixels instead of percentage values (for directions where scrolling is enabled) to ensure that it doesn't stretch to fit all elements. <code>clipping = yes</code> should be true (or unset, making it default to true). A <code>background = { ... }</code> also has to be defined for the container, since it establishes the boundaries.


除非通过[[Scripted GUI modding| 脚本化 GUI,]] 否则无法添加新容器。这是因为容器的 ''name'' 属性在内部链接到容器所需的任何数据。常见的例外是,您可以在 ''countrytechtreeview.gui'' 中为自定义技术文件夹添加新容器。
Scrollbars use [[#extendedScrollbarType|extendedScrollbarType]] definitions. If this definition is inside of a container, in which case it will be automatically assigned to the container without needing to assign it manually, however it can't be used for any other container. If the definition is entirely independent, it will not be assigned to any by default, but can be re-used in multiple containers.


容器定义的顺序和嵌套会影响它们的显示方式。
In particular, these arguments enable scrolling, assuming the conditions are fulfilled:
* <code>verticalScrollbar = scrollbar_name</code> assigns an external ExtendedScrollbarType to act as the vertical scrollbar. The scrollbar can't have <code>horizontal = yes</code> in its definition.
* <code>horizontalScrollbar = scrollbar_name</code> assigns an external ExtendedScrollbarType to act as the horizontal scrollbar. The scrollbar must have <code>horizontal = yes</code> in its definition.
* <code>drag_scroll = { left middle right }</code> enables drag scrolling. The drag scrolling will only work if there exists a scrollbar for the same axis. The direction represent the mouse button that the scrolling can be done with, however only <code>left</code> seems to work in-game. If there's only one button, it can be shortened as <code>drag_scroll = left</code>.


== containerWindowType ==
In addition, there are optional attributes that can be used to refine the scrollbar:
最常见的容器类型,用于保存任何一组元素。
* <code>margin = { top = 10 bottom = 10 left = 20 right = 20 }</code> is used to determine the margins of the container. These areas will be taken as the border of the window, unaffected by the scrollbar; only what's inside of the margin's border will be modified by the scrollbar.
 
* <code>autohide_scrollbars = no</code> – By default, a scrollbar will not appear if it isn't necessary due to all elements being inside of the container's <code>size</code>. If this is set to false, then it will always appear.
通常使用以下属性:
* <code>scroll_wheel_factor = 40</code> determines how much a single mouse scroll will affect the scrollbar.
* '''name''' - 容器的名称。
* <code>smooth_scrolling = yes</code> enables a smoother scrolling animation.
* '''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 ==
== scrollbarType ==
'' 滚动条'' 用于定义滚动条由哪些元素组成。
The '''scrollbarType''' is used to define which elements a scrollbar is composed of.


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


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


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


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


== iconType ==
== iconType ==
'' 图标'' 元素用于向界面添加图像。它的用法与 ''buttonType'' 重叠,但后者作为按钮运行。
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.


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


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


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


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


可用的 ''format'' :
Valid ''format'' values:
* left
* left
* centre
* center
* right
* right


== buttonType ==
== buttonType ==
'' 按钮'' 元素用于向界面添加按钮。按钮由图像和文本组成,因此它们的操作方式与 ''iconType'' ''instantTextBoxType'' 类似。
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''.


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


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


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


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


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


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


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


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


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


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


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


可用的 ''format'' 值:
== OverlappingElementsBoxType ==
* left
The ''OverlappingElementsBoxType'' element is used to define a special kind of listbox that dynamically overlaps sub-elements within itself.
* centre
* right


== OverlappingElementsBoxType ==
The following attributes are used:
'' 重叠元素框'' 元素用于定义一种特殊类型的列表框,该列表框在其内部动态重叠子元素。
* '''name''' - The listbox name.
* '''position''' - The screen position of the listbox.
* '''orientation''' - Sets the orientation origin for the ''position'' attribute.
* '''size''' - The bounding box for the listbox.
* '''spacing''' - The spacing to use between listbox entries.
* '''horizontal'' - Whether the listbox is horizontal (1) or vertical (0).
* '''bordersize''' - The bounding box for the border for the listbox.
* '''alwaystransparent''' - Forces the listbox to allow click through, i.e. clicking on an element behind another element.


使用以下属性:
The following attributes are rarely or never used:
* '''name''' - 列表框名称。
* '''textureFile''' - Never used for anything.
* '''position''' - 列表框的屏幕位置。
* '''orientation''' - 设置''位置''属性的方向原点。
* '''size''' - 列表框的边界框。
* '''spacing''' - 列表框条目的间距。
* '''horizontal''' - 列表框是水平 (1) 还是垂直 (0)。
* '''bordersize''' - 列表框边框的边界框。
* '''alwaystransparent''' - 强制列表框透明,如点击只能一个元素后面的另一个元素。


以下属性很少或从不使用:
Valid ''format'' values:
* '''textureFile''' - 从不使用。
* left
* center
* right


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


元素(或容器)使用的 ''orientation'' 属性会通知您元素的锚点所在位置。例如,''UPPER_LEFT'' 表示位于屏幕的左上角的 (''0, 0)'' 位置,而 ''LOWER_RIGHT'' 是右下角。
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/container, whereas ''LOWER_RIGHT'' is the bottom right.


然后,''position'' 属性从此锚点位置工作。因此,如果您希望元素位于屏幕的另一侧,则需要先更改 ''orientation''
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.


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


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


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


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


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


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

2024年9月21日 (六) 19:00的最新版本

The graphical user interface elements are defined within /Hearts of Iron IV/interface/*.gui files, as typical code formatting. The files only decide on the positions of how elements are arranged, scripted GUI is used to assign effects to newly-created interface elements.

Overview

The interface consists of container windows (or containers) and elements within them. Each element, other than containers, must reside in a container. Containers can be nested in other elements to organise their positions. Gridboxes are used to clone the same container several times, with different details specified for each one. Newly-added elements can have their effects defined in scripted GUI, while the effects of base game's GUI are hard-coded, that is, it's impossible to modify what it does directly.

The elements are shown in the order that they are defined in the file: what's placed later will be shown on top of what's placed earlier. The files are contained within a guiTypes = { ... } block overarching the entire file.

Constants

This section is transcluded from Data structures § Constants

Constants serve as a way to use the same value with a reference. The constants are marked with the @ symbol when defining or using them. An example definition is the following:

@CONSTANT_1 = 10
@CONSTANT_2 = "TAG_my_idea"

This can later be used in the file as, for example, cost = @CONSTANT_1. These definitions can be in any point of the file.

Constants are available in the vast majority of game files, including most, if not all, *.txt and *.gui files. Constants can be used as a way to link several values to be the same if they can easily be changed at any point in the development. However, constants that store a string for its value can only be used in triggers and the attributes of elements and windows, trying to use them in an effect will result in an "invalid database object for effect/trigger" error.
For example, if there is a large decision system where every decision is intended to have the same cost, then these constants may be used if the political power cost gets changed mid-development for better balance.
Another example would be a scripted GUI container: if a large multitude of elements are to be at the same X or Y position, it might be worth it to link them to be a constant in case their position could be changed for better appearance or to fit in another GUI element.

Example decision file that utilises constants:

@CONSTANT_1 = 10
@CONSTANT_2 = "TAG_my_idea"
TAG_decision_category = {
    TAG_decision = {
        icon = test_icon
        cost = @CONSTANT_1
        complete_effect = {
            if = {
                limit = {
                    has_ideas = @CONSTANT_2
                }
                add_stability = 0.1
            }
        }
    }
}

Containers

Containers are used to group together elements and associate them with an internal function, written as a containerWindowType = { ... } block.

New containers that are independent (not inside of any other container) will not show up in-game by default. For one to show up, it is required for it to be tied to a function, such as scripted GUI, which decides where it should show and when. In some cases, new containers can be created for the internally-defined functions, such as new technology folders or getting a music station to show up. In most cases, however, a scripted GUI would be required to make a new container show up.

If a container is defined within another container, it will appear at the same time as the window containing it unless more information is defined within the function. A scripted GUI cannot be assigned to such a container, however. In some cases, it's not necessary for a container to be visible to be useful, for example, an empty container can be used as an anchor, that is, used as the parent window name for Scripted GUI to place another container on the same place as the anchor is defined. This can allow placing containers with higher precision than normally possible with parent_window_name, allowing the parent window to have elements drawn on top of the scripted GUI.

Arguments

The following attributes are commonly used:

  • name = "my_container" – The name of the container, used to tie a function to the container. Independent containers must have unique names. While nested containers may have name overlap when defined in different independent containers, it's still preferable to avoid overlap, such as to ensure unambiguity when using parent_window_name in scripted GUI.
  • size = { height = 300 width = 100%% } – The bounding box for the container. If this container is placed inside of another one, either directly or through a gridbox, then only this size is used to create the scrollbar, without taking into account elements inside. This boundary also sets the size that the scrollbar must use. Either in pixels or in percentages relative to the size of the parent container (the entire screen if independent).
  • background = { ... } – The background of the container. This is required for a scrollbar to work, as otherwise the boundaries will get ignored. There are the following arguments inside:
    • name = "Background" – The name for handling the background in other functions. Commonly just set to "Background".
    • spriteType = "GFX_tiled_window" or quadTextureSprite = "GFX_tiled_window_transparent" – Refers to a corneredTileSpriteType definition that would automatically get resized to fit the container's set size.
  • clipping = yes – If true (and if a background exists), the elements inside of the container will not be able to go outside of the boundary box, and what doesn't fit will get cropped. Defaults to true. This being true is mandatory for a scrollbar to work.
  • position = { x = 100 y = 100 } – The position of the container in pixels relative to the set orientation.
  • orientation = center – Sets the origin that the position is measured relative to, such as upper_left, center_down, or lower_right.
  • moveable = yes – If set, the container can be moved by the player with their cursor.
  • fullScreen = yes – If set, the container will be considered to cover the entire screen.

Animation can be assigned to containers with these attributes:

  • show_position = { x = 300 y = 100 } – The screen position where the container will show up to the player after the 'show' animation finishes.
  • hide_position = { x = 100 y = 100 } – The screen position the container aims for during the 'hide' animation.
  • show_animation_type = linear – The animation type used to show the container (decelerated or linear).
  • hide_animation_type = accelerated – The animation type used to hide the container (accelerated or linear).
  • animation_type = decelerated – The animation if both show and hide animations are supposed to be the same (accelerated, decelerated, or linear).
  • animation_time = 1000 – The animation time in milliseconds.
  • show_sound = menu_open_window – The sound to play during the 'show' animation.
  • hide_sound = menu_close_window – The sound to play during the 'hide' animation.
  • fade_time = 300 – The time it takes for the container to fade in, in milliseconds.
  • fade_type = linear – The type of fade in: either accelerated or linear.

Scrolling

Scrolling can be done via scrollbars. If scrollbars are enabled, it's also possible to enabled it with dragging the screen. Since the game has to know what should be inside of the container, there are some attributes which must be used in the container. size = { ... } has to be defined using pixels instead of percentage values (for directions where scrolling is enabled) to ensure that it doesn't stretch to fit all elements. clipping = yes should be true (or unset, making it default to true). A background = { ... } also has to be defined for the container, since it establishes the boundaries.

Scrollbars use extendedScrollbarType definitions. If this definition is inside of a container, in which case it will be automatically assigned to the container without needing to assign it manually, however it can't be used for any other container. If the definition is entirely independent, it will not be assigned to any by default, but can be re-used in multiple containers.

In particular, these arguments enable scrolling, assuming the conditions are fulfilled:

  • verticalScrollbar = scrollbar_name assigns an external ExtendedScrollbarType to act as the vertical scrollbar. The scrollbar can't have horizontal = yes in its definition.
  • horizontalScrollbar = scrollbar_name assigns an external ExtendedScrollbarType to act as the horizontal scrollbar. The scrollbar must have horizontal = yes in its definition.
  • drag_scroll = { left middle right } enables drag scrolling. The drag scrolling will only work if there exists a scrollbar for the same axis. The direction represent the mouse button that the scrolling can be done with, however only left seems to work in-game. If there's only one button, it can be shortened as drag_scroll = left.

In addition, there are optional attributes that can be used to refine the scrollbar:

  • margin = { top = 10 bottom = 10 left = 20 right = 20 } is used to determine the margins of the container. These areas will be taken as the border of the window, unaffected by the scrollbar; only what's inside of the margin's border will be modified by the scrollbar.
  • autohide_scrollbars = no – By default, a scrollbar will not appear if it isn't necessary due to all elements being inside of the container's size. If this is set to false, then it will always appear.
  • scroll_wheel_factor = 40 determines how much a single mouse scroll will affect the scrollbar.
  • smooth_scrolling = yes enables a smoother scrolling animation.

scrollbarType

The scrollbarType is used to define which elements a scrollbar is composed of.

The following attributes are used:

  • name - The scrollbar name.
  • slider - The button element to use as the scrollbar slider.
  • track - The button element to use as the scrollbar tracker.
  • leftbutton - The button element to use as the scrollbar left increment button.
  • rightbutton - The button element to use as the scrollbar right increment button.
  • position - The screen position of the scrollbar.
  • size - The bounding box for the scrollbar.
  • priority - The priority the scrollbar has over other elements.
  • borderSize - The bounding box for border of the scrollbar.
  • maxValue - The maximum value the scrollbar moves to (used to control the increments).
  • minValue - The minimum value the scrollbar moves to (used to control the increments).
  • stepSize - The size of increments using the increment button.
  • startValue - The initial size the slider for the scrollbar starts at.
  • horizontal - Sets whether the scrollbar is horizontal (1) or vertical (0).

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.

  • iconType - Used for static images.
  • instantTextBoxType - Used for text.
  • buttonType - Used for buttons

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.
  • listboxType - Used for scrollable lists.
  • checkboxType - Used for checkboxes.
  • OverlappingElementsBoxType - Used for overlapping many elements.
  • editBoxType - Used for editable textboxes.
  • shieldtype - Used for to display country flags.

The following elements are legacy:

  • guiButtonType - Same as buttonType.
  • textBoxType - Same as instantTextBoxType.
  • eu3dialogtype - Same as windowType.
  • shieldtype - Only used within eu3dialogtype. Different elements are used for flags in more recent files.

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.

The following attributes are used:

  • name - The icon name.
  • position - The screen position of the icon.
  • orientation - Sets the orientation origin for the position attribute.
  • spriteType - The image to use for the icon. Refers to a spriteType definition.
  • quadTextureSprite - The image to use for the icon. Refers to a dynamic spriteType definitions (i.e. flags) or multi-frame spriteType definitions.
  • frame - Which frame to use for the icon when using a multi-frame image.
  • alwaystransparent - Forces the icon to allow click through, i.e. clicking on an element behind another element.
  • hint_tag - Set the hint key the icon uses to display a hint tooltip with when hovered over.
  • pdx_tooltip - The tooltip that is shown when hovering over the button.
  • pdx_tooltip_delayed - Sets the delayed tooltip to display to the player. Takes a localization key.
  • centerposition - Sets whether the position is from the center of the icon.

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.

The following attributes are used:

  • name - The textbox name.
  • position - The screen position of the textbox.
  • orientation - Sets the orientation origin for the position attribute.
  • text - The text displayed by the textbox.
  • font - The font to use for the text.
  • maxWidth - The total width in pixels at which text is displayed.
  • maxHeight - The total height in pixels at which text is displayed.
  • format - How the text is aligned.
  • fixedsize - Whether the textbox should truncate text that exceeds its limits.
  • borderSize - The bounding box for the border of the textbox.
  • alwaystransparent - Forces the text to allow click through, i.e. clicking on an element behind another element.
  • scrollbarType - which kind of scrollbar to use (for example standardtext_slider)
  • pdx_tooltip - Sets the tooltip to display to the player. Takes a localization key.
  • pdx_tooltip_delayed - Sets the delayed tooltip to display to the player. Takes a localization key.

The following attributes are rarely or never used:

  • textureFile - Never used for anything.

Valid format values:

  • left
  • center
  • right

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.

The following attributes are used:

  • name - The button name.
  • position - The screen position of the button.
  • orientation - Sets the orientation origin for the position attribute.
  • spriteType - The image to use for the button. Refers to a spriteType definition.
  • quadTextureSprite - The image to use for the button. Refers to a dynamic spriteType definitions (i.e. flags) or multi-frame spriteType definitions.
  • frame - Which frame to use for the button when using a multi-frame image.
  • alwaystransparent - Forces the button to allow click through, i.e. clicking on an element behind another element.
  • buttonText - The text displayed by the button.
  • buttonFont - The font to display the button text in.
  • shortcut - The shortcut to add for this button.
  • clicksound - The sound to use when clicked.
  • oversound - The sound to play when hovered over.
  • hint_tag - Set the hint key the icon uses to display a hint tooltip with when hovered over.
  • pdx_tooltip - The tooltip that is shown when hovering over the button.
  • pdx_tooltip_delayed - Sets the delayed tooltip to display to the player. Takes a localization key.
  • scale - Scales the button size.
  • web_link - URL to open in browser

The following attributes are rarely or never used:

  • tooltip - Never used.
  • tooltipText - Never used.
  • delayedTooltipText - Never used.

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.
  • position - The screen position of the listbox.
  • orientation - Sets the orientation origin for the position attribute.
  • size - The bounding box for the listbox.
  • spacing - The spacing to use between listbox entries.
  • 'horizontal - Whether the listbox is horizontal (1) or vertical (0).
  • scrollbartype - The scrollbar to use for the listbox.
  • bordersize - The bounding box for the border for the listbox.
  • alwaystransparent - Forces the listbox to allow click through, i.e. clicking on an element behind another element.

The following attributes are rarely or never used:

  • background - Never used.

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.
  • position - The screen position of the listbox.
  • orientation - Sets the orientation origin for the position attribute.
  • size - The bounding box for the listbox.
  • spacing - The spacing to use between listbox entries.
  • horizontal - Whether the listbox is horizontal (1) or vertical (0).
  • scrollbartype - The scrollbar to use for the listbox.
  • bordersize - The bounding box for the border for the listbox.
  • alwaystransparent - Forces the listbox to allow click through, i.e. clicking on an element behind another element.

The following attributes are rarely or never used:

  • background - Never used.

checkboxType

The checkboxType element is used to add checkboxes to the interface. The actual effect of the checkbox is defined internally.

The following attributes are used:

  • name - The checkbox name.
  • position - The screen position of the checkbox.
  • orientation - Sets the orientation origin for the position attribute.
  • spriteType - The image to use for the checkbox. Refers to a spriteType definition.
  • quadTextureSprite - The image to use for the checkbox. Refers to a dynamic spriteType definitions (i.e. flags) or multi-frame spriteType definitions.
  • frame - Which frame to use for the checkbox when using a multi-frame image.
  • alwaystransparent - Forces the checkbox to allow click through, i.e. clicking on an element behind another element.
  • buttonText - The text displayed by the checkbox.
  • buttonFont - The font to display the checkbox text in.
  • shortcut - The shortcut to add for this checkbox.
  • clicksound - The sound to use when clicked.
  • hint_tag - Set the hint key the checkbox uses to display a hint tooltip with when hovered over.
  • pdx_tooltip - Set the short tooltip this checkbox uses.
  • pdx_tooltip_delayed - Set the full tooltip this checkbox uses.
  • scale - Scales the checkbox size.

The following attributes are rarely or never used:

  • tooltip - Never used.
  • tooltipText - Never used.
  • delayedTooltipText - Never used.

editBoxType

The editBoxType element is used to add editable textboxes to the interface.

The following attributes are used:

  • name - The textbox name.
  • position - The screen position of the textbox.
  • orientation - Sets the orientation origin for the position attribute.
  • text - The text displayed by the textbox.
  • font - The font to use for the text.
  • maxWidth - The total width in pixels at which text is displayed.
  • maxHeight - The total height in pixels at which text is displayed.
  • format - How the text is aligned.
  • fixedsize - Whether the textbox should truncate text that exceeds its limits.
  • borderSize - The bounding box for the border of the textbox.
  • alwaystransparent - Forces the text to allow click through, i.e. clicking on an element behind another element.
  • ignore_tab_navigation - Makes the element ignore tab navigation.

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.
  • position - The screen position of the listbox.
  • orientation - Sets the orientation origin for the position attribute.
  • size - The bounding box for the listbox.
  • spacing - The spacing to use between listbox entries.
  • 'horizontal - Whether the listbox is horizontal (1) or vertical (0).
  • bordersize - The bounding box for the border for the listbox.
  • alwaystransparent - Forces the listbox to allow click through, i.e. clicking on an element behind another element.

The following attributes are rarely or never used:

  • textureFile - Never used for anything.

Valid format values:

  • left
  • center
  • 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/container, whereas LOWER_RIGHT is the bottom 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.

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.

An mistake would be to edit the position solely, for example position = { x = 1800 y = 200 }. 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.

Valid orientation values (can be upper or lowercase):

  • CENTER
  • UPPER_LEFT
  • LOWER_LEFT
  • UPPER_RIGHT
  • LOWER_RIGHT

Fonts

See also: Font modding

The following fonts are usable in Hearts of Iron 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