音乐包制作:修订间差异

本页面所适用的版本可能已经过时,最后更新于1.11
无编辑摘要
无编辑摘要
 
(未显示2个用户的4个中间版本)
第1行: 第1行:
{{Version|1.8}}
{{Version|1.11}}
{{需要翻译|译者=霜泽图书馆}}


== 添加你的音乐文件 ==
Music files are stored in the *.ogg format within the {{path|music/}} folder or one of its subfolders.
* 你的音乐文件要是OGG格式且要放入游戏的音乐文件夹。你可以在网上找到很多格式转换器。


打开文件: music.asset ({{path|Hearts of Iron IV/music/music.asset}}). 在这个文件夹中,你将把音乐添加到游戏中。在这个例子中我们将把这个文件命名为 <code>new song.ogg</code>. 我们音乐文件的 <code>ID</code>(<code>A New Song</code>) 不可以超过63个字符。(德语中带小帽子的字符例如ä, ü  ö 算两个字符 )(译者注:其实波兰语、西班牙语等等带小帽子的字符也算两个。一个汉字也是两个)否则在开始加载游戏时会加载失败。
The [https://runite-drill.github.io/music-mod-creation-tool/ Music Mod Creation Tool] is a quick and easy-to-use modding tool that will generate all the files described below to add music and a radio station to the game.


music = {
== Song definition ==
  name = "A New Song"
  file = "new song.ogg"
  volume = 0.65
}


别忘记保存这些文件
Songs are defined within files of the *.asset format, located in the same folder as the *.ogg files. A definition is formatted as following:
<pre>music = {
   name = "song_name"
   file = "song_file.ogg"
   volume = 0.65
}</pre>
''name'' is the song's ID, as well as its localisation key for name assignment within a [[Localisation]] file as <code> song_name:0 "Song's Name"</code>. It cannot contain more than 63 characters.<br/>
''file'' is the song's filename, including the *.ogg extension.<br/>
''volume'' allows to adjust the volume of the *.ogg file without editing it.


== 条件 ==
== Assigning to a station ==


在技术条件上你已经把音乐加入到游戏中了。 不过你得写歌曲的播放条件~打开songs.txt ({{path|Hearts of Iron IV/music/songs.txt}}).
In order to work properly, songs must be assigned to a station. The assignments are stored in *.txt files, within the same folder as the *.asset and *.ogg files.<br/>
*音乐条件的格式跟事件和国策等是一样的
An assignment file, before defining any songs, must be assigned to a station. Multiple files can be assigned to the same station. This is done with the following line of code:
举个例子, 若我们只希望我们在和平时扮演民主的美国时放这首歌:
<pre>music_station = "station_name"</pre>
A typical assignment of a song is formatted accordingly:
music = {
<pre>music = {
  song = "A New Song"
   song = "song_name"
  chance = {
   chance = {
   modifier = {
     factor = 1
    factor = 2
     modifier = {
    has_war = no
       factor = 0
    TAG = USA
       has_war = no
    has_government = democratic
     }
   }
   }
  }
}</pre>
}
''song'' accepts the ID of the song, defined as its name within the *.asset file.<br/>
''chance'' defines the chance for a song to be picked if the playmode is set to Weighted Shuffle. The allowed arguments are <code>factor</code>, for multiplying the chance, <code>add</code>, for adding to the chance, and <code>base</code>, replacing the chance entirely. <code>modifier = {}</code> allows the argument to modify the chance only be executed if all of the [[Conditions|triggers]] within are met.


现在你的音乐已经被完全添加到游戏中了~只要你在和平时扮演民主的美国的时候你就能听到这首歌了!你可以用上几乎所有的条件。当然别忘了再保存一次~
== Radio stations ==


== 电台 ==
A radio station is defined as an [[Interface modding|user interface]] file, {{path|interface/*.gui}}. The contents of the file are required to be the following, with <code><MUSIC STATION></code> being replaced with the music station's name:
<pre>guiTypes = {
containerWindowType = {
name = "<MUSIC STATION>_faceplate"
position = { x =0 y=0 }
size = { width = 590 height = 46 }


为了做电台,你要做下列的事:
iconType ={
name ="musicplayer_header_bg"
spriteType = "GFX_musicplayer_header_bg"
position = { x= 0 y = 0 }
alwaystransparent = yes
}


* 在这个文件夹中激活电台 common/playlists/settings.txt. 电台间用空格隔开
instantTextboxType = {
* 在 gfx\interface or gfx\interface\topbar\musicplayer, 你要做张电台封面(my-station_album_art.dds). 你还要做一个面板, 像 faceplate_my-mod.dds.
name = "track_name"
* 在 interface\ 你要两个 my-station_music.gfx 和 my-station_music.gui 文件来创建文件夹并且写入gfx的位置.确保那写入了正确的 gfx 文件的位置, 否则它们不会显示出来.
position = { x = 72 y = 20 }
* 在 localisation\ 你要写个本地化文件。 你的电台名称要写成 my-station_TITLE:0 接下来需要写入歌的名字
font = "hoi_20b"
* 在 music\每个电台都有一个文件夹, 例如 my-station. 每一个文件夹都再包含了两个文件夹 my-station_music.asset 和 my-station_soundtrack.txt ,每首音乐都需要写上触发的变量并且也需要在localisation\中的歌名. 歌曲必须要是.ogg格式.
text = "Roger Pontare - Nar vindarna viskar mitt namn"
maxWidth = 450
maxHeight = 25
format = center
}


两个Sabaton music DLC就是很好的参考.
instantTextboxType = {
name = "track_elapsed"
position = { x = 124 y = 30 }
font = "hoi_18b"
text = "00:00"
maxWidth = 50
maxHeight = 25
format = center
}


== 杂项==
instantTextboxType = {
name = "track_duration"
position = { x = 420 y = 30 }
font = "hoi_18b"
text = "02:58"
maxWidth = 50
maxHeight = 25
format = center
}


我们不能在 "radio stations" 中设置歌曲. 做一个音乐模组相对简单, 包括在songs.txt文件中多写几行代码, 创建一个新的本地化文件(来给电台命名), 甚至添加一个新的封面 (inside /interface and /interface/musicplayer).<ref>https://forum.paradoxplaza.com/forum/index.php?threads/hoi4-dev-diary-1-7-update-and-radio-armor-packs.1183035/</ref>
buttonType = {
name = "prev_button"
position = { x = 220 y = 20 }
quadTextureSprite ="GFX_musicplayer_previous_button"
buttonFont = "Main_14_black"
Orientation = "LOWER_LEFT"
clicksound = click_close
pdx_tooltip = "MUSICPLAYER_PREV"
}
 
buttonType = {
name = "play_button"
position = { x = 263 y = 20 }
quadTextureSprite ="GFX_musicplayer_play_pause_button"
buttonFont = "Main_14_black"
Orientation = "LOWER_LEFT"
clicksound = click_close
}
 
buttonType = {
name = "next_button"
position = { x = 336 y = 20 }
quadTextureSprite ="GFX_musicplayer_next_button"
buttonFont = "Main_14_black"
Orientation = "LOWER_LEFT"
clicksound = click_close
pdx_tooltip = "MUSICPLAYER_NEXT"
}
 
extendedScrollbarType = {
name = "volume_slider"
position = { x = 100 y = 45}
size = { width = 75 height = 18 }
tileSize = { width = 12 height = 12}
maxValue =100
minValue =0
stepSize =1
startValue = 50
horizontal = yes
orientation = lower_left
origo = lower_left
setTrackFrameOnChange = yes
 
slider = {
name = "Slider"
quadTextureSprite = "GFX_scroll_drager"
position = { x=0 y = 1 }
pdx_tooltip = "MUSICPLAYER_ADJUST_VOL"
}
 
track = {
name = "Track"
quadTextureSprite = "GFX_volume_track"
position = { x=0 y = 3 }
alwaystransparent = yes
pdx_tooltip = "MUSICPLAYER_ADJUST_VOL"
}
}
 
buttonType = {
name = "shuffle_button"
position = { x = 425 y = 20 }
quadTextureSprite ="GFX_toggle_shuffle_buttons"
buttonFont = "Main_14_black"
Orientation = "LOWER_LEFT"
clicksound = click_close
}
}
 
containerWindowType={
name = "<MUSIC STATION>_stations_entry"
size = { width = 162 height = 130 }
checkBoxType = {
name = "select_station_button"
position = { x = 0 y = 0 }
quadTextureSprite = "<SPRITE>"
clicksound = decisions_ui_button
}
}
}</pre>
The name is assigned by using its ID as a [[localisation]] key within {{path|localisation/<language>/*_l_<language>.yml}}: <code> <MUSIC STATION>:0 "Music station's name"</code>.<br/>
The album cover is assigned a sprite as the quadTextureSprite within select_station_button. A sprite must be defined within {{path|interface/*.gfx}} as the following:
<pre> spriteType = {
name = "<SPRITE>"
texturefile = "gfx//interface//topbar//musicplayer//<FILE NAME>.dds"
noOfFrames = 2
}</pre>The *.dds file must be split horizontally into 2 sprites: when it is unselected, and when it is selected.


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

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

Music files are stored in the *.ogg format within the /Hearts of Iron IV/music/ folder or one of its subfolders.

The Music Mod Creation Tool is a quick and easy-to-use modding tool that will generate all the files described below to add music and a radio station to the game.

Song definition

Songs are defined within files of the *.asset format, located in the same folder as the *.ogg files. A definition is formatted as following:

music = {
    name = "song_name"
    file = "song_file.ogg"
    volume = 0.65
}

name is the song's ID, as well as its localisation key for name assignment within a Localisation file as song_name:0 "Song's Name". It cannot contain more than 63 characters.
file is the song's filename, including the *.ogg extension.
volume allows to adjust the volume of the *.ogg file without editing it.

Assigning to a station

In order to work properly, songs must be assigned to a station. The assignments are stored in *.txt files, within the same folder as the *.asset and *.ogg files.
An assignment file, before defining any songs, must be assigned to a station. Multiple files can be assigned to the same station. This is done with the following line of code:

music_station = "station_name"

A typical assignment of a song is formatted accordingly:

music = {
    song = "song_name"
    chance = {
        factor = 1
        modifier = {
            factor = 0
            has_war = no
        }
    }
}

song accepts the ID of the song, defined as its name within the *.asset file.
chance defines the chance for a song to be picked if the playmode is set to Weighted Shuffle. The allowed arguments are factor, for multiplying the chance, add, for adding to the chance, and base, replacing the chance entirely. modifier = {} allows the argument to modify the chance only be executed if all of the triggers within are met.

Radio stations

A radio station is defined as an user interface file, /Hearts of Iron IV/interface/*.gui. The contents of the file are required to be the following, with <MUSIC STATION> being replaced with the music station's name:

guiTypes = {
	containerWindowType = {
		name = "<MUSIC STATION>_faceplate"
		position = { x =0 y=0 }
		size = { width = 590 height = 46 }

		iconType ={
			name ="musicplayer_header_bg"
			spriteType = "GFX_musicplayer_header_bg"
			position = { x= 0 y = 0 }
			alwaystransparent = yes
		}

		instantTextboxType = {
			name = "track_name"
			position = { x = 72 y = 20 }
			font = "hoi_20b"
			text = "Roger Pontare - Nar vindarna viskar mitt namn"
			maxWidth = 450
			maxHeight = 25
			format = center
		}

		instantTextboxType = {
			name = "track_elapsed"
			position = { x = 124 y = 30 }
			font = "hoi_18b"
			text = "00:00"
			maxWidth = 50
			maxHeight = 25
			format = center
		}

		instantTextboxType = {
			name = "track_duration"
			position = { x = 420 y = 30 }
			font = "hoi_18b"
			text = "02:58"
			maxWidth = 50
			maxHeight = 25
			format = center
		}

		buttonType = {
			name = "prev_button"
			position = { x = 220 y = 20 }
			quadTextureSprite ="GFX_musicplayer_previous_button"
			buttonFont = "Main_14_black"
			Orientation = "LOWER_LEFT"
			clicksound = click_close
			pdx_tooltip = "MUSICPLAYER_PREV"
		}

		buttonType = {
			name = "play_button"
			position = { x = 263 y = 20 }
			quadTextureSprite ="GFX_musicplayer_play_pause_button"
			buttonFont = "Main_14_black"
			Orientation = "LOWER_LEFT"
			clicksound = click_close
		}

		buttonType = {
			name = "next_button"
			position = { x = 336 y = 20 }
			quadTextureSprite ="GFX_musicplayer_next_button"
			buttonFont = "Main_14_black"
			Orientation = "LOWER_LEFT"
			clicksound = click_close
			pdx_tooltip = "MUSICPLAYER_NEXT"
		}

		extendedScrollbarType = {
			name = "volume_slider"
			position = { x = 100 y = 45}
			size = { width = 75 height = 18 }
			tileSize = { width = 12 height = 12}
			maxValue =100
			minValue =0
			stepSize =1
			startValue = 50
			horizontal = yes
			orientation = lower_left
			origo = lower_left
			setTrackFrameOnChange = yes

			slider = {
				name = "Slider"	
				quadTextureSprite = "GFX_scroll_drager"
				position = { x=0 y = 1 }
				pdx_tooltip = "MUSICPLAYER_ADJUST_VOL"
			}

			track = {
				name = "Track"
				quadTextureSprite = "GFX_volume_track"
				position = { x=0 y = 3 }
				alwaystransparent = yes
				pdx_tooltip = "MUSICPLAYER_ADJUST_VOL"
			}
		}

		buttonType = {
			name = "shuffle_button"
			position = { x = 425 y = 20 }
			quadTextureSprite ="GFX_toggle_shuffle_buttons"
			buttonFont = "Main_14_black"
			Orientation = "LOWER_LEFT"
			clicksound = click_close
		}
	}

	containerWindowType={
		name = "<MUSIC STATION>_stations_entry"
		size = { width = 162 height = 130 }
		
		checkBoxType = {
			name = "select_station_button"
			position = { x = 0 y = 0 }
			quadTextureSprite = "<SPRITE>"
			clicksound = decisions_ui_button
		}
	}
}

The name is assigned by using its ID as a localisation key within /Hearts of Iron IV/localisation/<language>/*_l_<language>.yml: <MUSIC STATION>:0 "Music station's name".
The album cover is assigned a sprite as the quadTextureSprite within select_station_button. A sprite must be defined within /Hearts of Iron IV/interface/*.gfx as the following:

	spriteType = {
		name = "<SPRITE>"
		texturefile = "gfx//interface//topbar//musicplayer//<FILE NAME>.dds"
		noOfFrames = 2
	}

The *.dds file must be split horizontally into 2 sprites: when it is unselected, and when it is selected.