音樂包製作

本頁面所適用的版本可能已經過時,最後更新於1.11

音樂文件以 *.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:未選中時和選中時。