音乐包制作

本页面所适用的版本可能已经过时,最后更新于1.11
(重定向自Music modding

音乐文件以 *.ogg 格式存储在/Hearts of Iron IV/music/文件夹或其子文件夹之一中。

Music Mod Creation Tool是一种快速且易于使用的 Mod 工具,它将生成下面描述的所有文件,以将音乐和广播电台添加到游戏中。

歌曲定义

歌曲在 *.asset 格式的文件中定义,与 *.ogg 文件位于同一文件夹中。定义的格式如下:

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

name是歌曲的 ID,以及用于在本地化文件中分配名称的 本地化 song_name:0 "Song's Name"。它不能包含超过 63 个字符。
file是歌曲的文件名,包括 *.ogg 扩展名。
volume 允许调整 *.ogg 文件的音量,而无需对其进行编辑。

分配电台

为了正常工作,歌曲必须分配给一个电台。分配存储在 *.txt 文件中,与 *.asset 和 *.ogg 文件位于同一文件夹中。
在定义任何歌曲之前,必须将分配文件分配给一个电台。可以将多个文件分配给同一个电台。这是通过以下代码行完成的:

music_station = "station_name"

典型的歌曲分配格式如下:

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

song 接受歌曲的 ID,在 *.asset 文件中为其定义名称。
chance 定义了在播放模式设置为加权随机播放时歌曲被选中的几率。允许的参数有 factor,用于乘以几率,add,用于增加几率,以及base,完全替换几率。modifier = {} 允许参数仅在满足所有触发条件时修改几率。

广播电台

广播电台被定义为一个 用户页面文件,位于/Hearts of Iron IV/interface/*.gui.中。文件内容需要如下所示,将<MUSIC STATION>替换为音乐电台的名称:

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
		}
	}
}

名称通过在/Hearts of Iron IV/localisation/<language>/*_l_<language>.yml中使用其 ID 作为本地化键来分配:: <MUSIC STATION>:0 "Music station's name".
专辑封面被分配为 select_station_button 中的 quadTextureSprite。必须在/Hearts of Iron IV/interface/*.gfx中定义一个 sprite,如下所示:

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

*.dds 文件必须垂直分割成两个sprite:未选中时和选中时。