界面模组制作

本页面所适用的版本可能已经过时,最后更新于2.8

Interface modding allows to change some vanilla screens, but there are important limitations:

  • interfaces are hardcoded to match vanilla religion groups.
  • behavior of UI buttons is hardcoded and not moddable, though existing buttons can be moved or hidden.

To identify interface elements, activate interface debug mode by pressing the same keys as for opening the console while still being in the main menu (does not work anymore once you've loaded into a campaign). It will display in which file and which line the elements are defined.

List of interface files

Here is a list of the most important interface files, and what they contain:

Name Description
main.gui Main interface when running the game (minimap, chat, ...)
frontend.gui Lobby interface (choose starting era, country selection, multiplayer, ...)
domestic_overview.gui Primary title tab
domestic_dynastic.gui Character tab
domestic_court.gui Councillors tab
domestic_law.gui Laws tab
domestic_technology.gui Technology tab
domestic_military.gui Military tab
domestic_plots.gui Intrigue tab
domestic_factions.gui Factions tab
domestic_religion.gui Religion / College of Cardinal tabs
province.gui Province window, with its settlements/fort/trade post
focusview.gui Focus window
combat.gui Combat window
waroverview.gui Warscore window
unitpanel.gui Army window
domestic_diplomacy.gui Diplomacy popup
eventwindow.gui Event popups (normal, narrative, letter, ...)

Structure of .gui files



Choose starting era window

The starting era selection screen


The first two starting eras are DLC-locked, so best thing to do is to hide them by overriding interface/frontend.gui in the mod and by replacing position for picture / dlc_requirement / load_progress / label / year boxes dark_ages_window and viking_era_window windows, with:

 position = { x=-2000 y=-2000} 

In bookmarks.txt, give the hardcoded name from vanilla to the 3 bookmarks you want to see on the era screen:

  • 3rd era: name = "BM_FATE_OF_ENGLAND"
  • 4th era: name = "BM_THE_MONGOLS"
  • 5th era: name = "BM_100_YEARS_WAR"

You can, if needed move these around and center them, with some fitting positions.

Override the following hardcoded localization keys inside a .csv file in the localization folder of the mod:

  • PICK_STARTING_ERA_TEXT
  • 3rd era: BM_FATE_OF_ENGLAND, EARLY_MED, EARLY_MED_INFO
  • 4th era: BM_THE_MONGOLS, HIGH_MED, HIGH_MED_INFO
  • 5th era: BM_100_YEARS_WAR, LATE_MED, LATE_MED_INFO


For each bookmark, the 1st 6 characters defined in common/bookmarks.txt will appear, and will need to be described by adding localization keys:

ERA_CHAR_INFO_%chararcter_id%

For instance with:

bookmark =
{
	name = "BM_FATE_OF_ENGLAND"
	desc = "BM_FATE_OF_ENGLAND_DESC"
	date = 1066.9.15
	
	character = 140 # William the Conqueror
	character = 1316 # Kaiser Heinrich IV
	character = 1128 # Robert de Hauteville
	character = 3096 # Caliph Al-Mustansir of Fatimids
	character = 3040 # Alp Arslan of Seljuks
	character = 74441 # Somesvara I of Chalukyas

	character = 122 # Harold Godwinson
	character = 102531 # Harald Hårdråde
	character = 20663 # Isaac of Khazaria
	
}

then ERA_CHAR_INFO_140, ERA_CHAR_INFO_1316, ERA_CHAR_INFO_1128, ERA_CHAR_INFO_1128 and ERA_CHAR_INFO_74441 have to be localized.


Finally the era images can be customized, by overriding (or updating frontend.gui) with your own gfx: GFX_pick_era_image_3, GFX_pick_era_image_4, GFX_pick_era_image_5

Papal succession

The College of Cardinals screen

In order to use Papal succession (succ_papal_succession) for another religion, the first step is to mod the sucession laws:

succ_papal_succession = {
	potential = {
		OR = {
			title = k_papal_state
			title = d_<my_religion>
		}
	}
		
	effect = {
		succession = papal_succession
	}
	revoke_allowed = {
		always = no
	}		
}

A button to open cardinal screen should magically appear in the religion screen ! However clicking the button will cause a CTD, and a bit of interface modding is required:

  • Open domestic_religion.gui and copy the definition for window named domestic_religion_title_fraticelli_cardinal
  • Create a file <my_religion>_domestic_religion.gui and paste the code.
  • Replace occurrences of title_fraticelli_cardinal by the new religious title defined inside folder common/religious_titles (ex: title_<my_religion>_cardinal)
guiTypes = {
	windowType = {
		name = "domestic_religion_title_<my_religion>_cardinal"
		(...)

		### title cardinal entry 1
		windowType = {
			name = "title_<my_religion>_cardinal_entry_1"
			(...)
		}
		(...)
	}
}

Adding a focus

Choose focus screen

In focusview.gfx, the number of frames needs to be increased:

spriteType = {
	name = "GFX_focusicons"
	texturefile = "gfx\\interface\\focusicons.tga"
	noOfFrames = 20
	loadType = "INGAME"
}

Add a 32*32 version of your icon in gfx/ambitions/, and reference it with spriteType name GFX_<focus_name>, <focus_name> being the new focus defined in common/ambitions/00_focuses.txt

spriteType = {
	name = "GFX_<focus_name>"
	texturefile = "gfx/ambitions/<focus_name>.tga"
	noOfFrames = 1
	norefcount = yes
	effectFile = "gfx/FX/buttonstate.lua"
}

In focusview.gui, add an 11th focus, and adjust its position:

iconType = {
	name ="focusicon_11_selected"
	spriteType = "GFX_focusview_selected_focus"
	position = { x = 23 y = 154 }
}
positionType = {
	name = "focusicon_11"
	position = { x = 40 y = 171 }
}

Shortcuts

New keyboard shortcuts can be added via shortcut = "<key>".[1]

If using priority_shortcut flag, it will fire before any other shortcuts.

Minimap

主条目:Minimap modding

See also

References