Resources modding:修订间差异

本页面所适用的版本可能已经过时,最后更新于1.10
(文本替换 - 替换“[[Category:”为“[[分类:”)
无编辑摘要
 
第1行: 第1行:
{{version|1.5}}
{{version|1.10}}
{{需要翻译|译者=霜泽图书馆}}


== Resources ==
== Resources ==
{{SVersion|1.9}}
{{SVersion|1.10}}
游戏中用到的资源可以在{{path|common/resources/00_resources.txt}} 中找到。
The resources used by the game are found in {{path|common/resources/00_resources.txt}}.


资源文件遵循以下格式:
The resource file follows this format:
<pre>
<pre>
resources = {
resources = {
第17行: 第18行:


=== Icon frame ===
=== Icon frame ===
{{SVersion|1.7}}
{{SVersion|1.10}}
Icon frame controls which frame from the resource image strip is used for the resource icon. A 'frame' is the 27 by 27 pixel square the icon occupies in the image. 
Icon frame controls which frame from the resource image strip is used for the resource icon. A 'frame' is the 27 by 27 pixel square the icon occupies in the image. 


The resource image strip is defined by the '''GFX_resources_strip''' spritetype, which points to {{path|gfx/interface/resources_strip.dds}} by default. By default 1 will refer to the Oil icon, 2 to Aluminium, etc.
The resource image strip is defined by the '''GFX_resources_strip''' spritetype, which points to {{path|gfx/interface/resources_strip.dds}} by default. By default 1 will refer to the Oil icon, 2 to Aluminium, etc.


For the resources to have their own icons you must make a <code>.gfx</code> file and place it in the {{path|gfx/interface/}}. After this is made in the <code>.gfx</code> file you must define a sprite and number of icons. For example:
The icons are defined in {{path|interface/general_stuff.gfx}}. Their definition must be changed if you're adding or removing resources
<pre> spriteType = {
<pre>
spriteType = {
name = "GFX_resources_strip"
name = "GFX_resources_strip"
texturefile = "gfx/interface/resources_strip.dds"
texturefile = "gfx/interface/resources_strip.dds"
第35行: 第34行:
texturefile = "gfx/interface/missing_resources_strip.dds"
texturefile = "gfx/interface/missing_resources_strip.dds"
noOfFrames = X
noOfFrames = X
}
}</pre>The number of frames strictly corresponds to the amount of resources.
}
</pre>


=== CIC ===
=== CIC ===
{{SVersion|1.5}}
{{SVersion|1.5}}


CIC defines the amount of resources needed to trade for 1 Civilian Factory. By default, this is 0.125, meaning 8 units of that resource are traded for 1 factory.
CIC defines the amount of resources needed to trade for 1 Civilian Factory. By default, this is 0.125, meaning 8 units of that resource are traded for 1 factory. Value can not be larger than 1.


=== Convoys ===
=== Convoys ===
第52行: 第49行:
{{SVersion|1.9}}
{{SVersion|1.9}}


Resources use the following localization keys:
Localisation is defined in {{path|localisation/*_l_<language>.yml}} with the following localization keys:
<pre>
<pre>
PRODUCTION_MATERIAL_<RESOURCE>:0 "Name of resource"
PRODUCTION_MATERIALS_<RESOURCE>:0 "Name of resource"
<resource>_desc:0 "Description of resource"
<resource>_desc:0 "Description of resource"
</pre>
</pre>
第85行: 第82行:
}
}
</pre>
</pre>
=== Additional notes ===
A fuel can also correspond to the fuel dynamic, however only one resource at a time can do that. This is decided by the FUEL_RESOURCE [[Defines|define]]. <br/>
Infrastructure's bonus on resource gain is decided by the INFRASTRUCTURE_RESOURCE_BONUS define and applies to all resources the same.


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

2024年8月31日 (六) 20:32的最新版本

Resources

The resources used by the game are found in /Hearts of Iron IV/common/resources/00_resources.txt.

The resource file follows this format:

resources = {
    <resource> = {
        icon_frame = <frame>
        cic = <float>
        convoys = <float>
    }
}

Icon frame

Icon frame controls which frame from the resource image strip is used for the resource icon. A 'frame' is the 27 by 27 pixel square the icon occupies in the image.

The resource image strip is defined by the GFX_resources_strip spritetype, which points to /Hearts of Iron IV/gfx/interface/resources_strip.dds by default. By default 1 will refer to the Oil icon, 2 to Aluminium, etc.

The icons are defined in /Hearts of Iron IV/interface/general_stuff.gfx. Their definition must be changed if you're adding or removing resources:

	spriteType = {
		name = "GFX_resources_strip"
		texturefile = "gfx/interface/resources_strip.dds"
		noOfFrames = X #X being the number of resources you have, 
	}

	spriteType = {
		name = "GFX_missing_resources_strip"
		texturefile = "gfx/interface/missing_resources_strip.dds"
		noOfFrames = X
	}

The number of frames strictly corresponds to the amount of resources.

CIC

CIC defines the amount of resources needed to trade for 1 Civilian Factory. By default, this is 0.125, meaning 8 units of that resource are traded for 1 factory. Value can not be larger than 1.

Convoys

Convoys controls the maximum amount of this resource a single convoy carries. By default, this is 0.1, meaning a convoy can carry 10 of the resource.

Localization

Localisation is defined in /Hearts of Iron IV/localisation/*_l_<language>.yml with the following localization keys:

PRODUCTION_MATERIALS_<RESOURCE>:0 "Name of resource"
<resource>_desc:0 "Description of resource"

Interface

If implementing different resources, you will need to edit the interface so the game understands how to display the new resource. /Hearts of Iron IV/interface/countryproductionlineview.gui is the relevant file here.

Each resource is utilised two GUI elements: <resource>_icon and <resource>_value, which are found under the resources windowtype.

buttonType = {
    name = "<resource>_icon"
    position = { x=0 y=2 }
    spriteType = "GFX_resources_strip"
    frame = 1 # Which icon is used from the spriteType image referred to above.
}
					
instantTextboxType = {
    name = "<resource>_value"
    position = { x = 31 y = 5 }
    textureFile = ""
    font = "hoi_18mbs"
    borderSize = {x = 0 y = 0}
    text = "999"
    maxWidth = 50
    maxHeight = 20
    format = left
}

Additional notes

A fuel can also correspond to the fuel dynamic, however only one resource at a time can do that. This is decided by the FUEL_RESOURCE define.
Infrastructure's bonus on resource gain is decided by the INFRASTRUCTURE_RESOURCE_BONUS define and applies to all resources the same.