######################################################
################## PORTRAIT TYPES ####################
######################################################

types PortraitTypes
{

	####################################
	######### MAIN PORTRAITS ###########
	####################################

	type widget_portrait_frame = widget {
		size = { 100% 100% }

		background = {
			visible = "[Not( Character.IsDiarchOf( Character.GetLiege ) )]"
			texture = "gfx/portraits/portrait_rank.dds"

			margin_top = -4
			margin_bottom = -3
			margin_right = -4
			margin_left = -3

			framesize = { 196 194 }
			frame = "[Character.GetPrimaryTitle.GetTierFrame]"
		}

		background = {
			visible = "[Character.IsDiarchOf( Character.GetLiege )]"
			texture = "gfx/portraits/portrait_rank_regency.dds"

			margin_top = 6
			margin_bottom = -3
			margin_right = -4
			margin_left = -3

			framesize = { 196 210 }
			frame = "[Character.GetPrimaryTitle.GetTierFrame]"
		}
	}

	# The standard portrait types. CoA, opinion and status icons are included by default; use blockoverride to disable them.

	## Extra small head portrait. These are smaller than we would like, so only use if you really, really have to.
	type portrait_head_small = widget {
		size = { 85 90 }

		background = {
			using = Background_Area_Solid

			modify_texture = {
				texture = "gfx/interface/component_masks/mask_fade_vertical.dds"
				blend_mode = alphamultiply
				alpha = 0.2
				mirror = vertical
			}
		}

		background = {
			block "empty_character" {}
			visible = "[Not( Character.HasLandedTitles )]"
			texture = "gfx/portraits/portrait_frame.dds"
			using = Color_Grey
			margin = { -4 -4 }
			alpha = 0.4
		}

		widget = {
			size = { 100% 100% }
			using = Portrait_Background_Glows

			block "empty_character" {}
		}

		portrait_button = {
			parentanchor = bottom|hcenter
			size = { 80 100 }
			using = portrait_base

			block "portrait_texture"
			{
				portrait_texture = "[Character.GetPortrait('environment_head', 'camera_head', 'idle', PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
			}

			mask = "gfx/portraits/portrait_mask_head_small.dds"
			effectname = "NoHighlight"

			highlight_icon = {
				name = "prison_bars"
				visible = "[Character.IsImprisoned]"
				visible_at_creation = no
				size = { 80 88 }
				parentanchor = center
				effectname = "NoHighlight"
				texture = "gfx/portraits/portrait_prison_head.dds"

				modify_texture = {
					name = "mask"
					texture = "gfx/portraits/portrait_mask_head_small.dds"
					spriteType = Corneredstretched
					blend_mode = alphamultiply
				}
			}

			block "portrait_button" {}
		}

		widget_portrait_frame = {}

		block "coa" {
			coa_realm_tiny = {
				visible = "[Character.HasLandedTitles]"
				parentanchor = bottom|left
				position = { 3 -2 }
				scale = 0.85
			}
		}

		widget = {
			size = { 100% 100% }
			visible = "[Not( Character.HasLandedTitles )]"
			block "empty_character" {}

			background = {
				texture = "gfx/portraits/portrait_frame.dds"
				using = Color_Grey
				margin = { -4 -4 }
				alpha = 0.4

				modify_texture = {
					texture = "gfx/interface/component_masks/mask_fade_vertical.dds"
					blend_mode = alphamultiply
					mirror = vertical
				}
			}

			background = {
				visible = "[Character.IsHovered]"
				texture = "gfx/portraits/portrait_frame.dds"
				using = Color_Grey
				alpha = 0.7
				margin = { -4 -4 }
			}
		}

		flowcontainer = {
			parentanchor = bottom|right
			ignoreinvisible = yes
			direction = vertical
			margin = { 4 0 }
			margin_bottom = 5

			portrait_status_icons_small = {
				parentanchor = right
			}

			block "opinion_box"
			{
				portrait_opinion_small = {
					name = "tutorial_highlight_character_view_opinion_heir"
				}
			}
		}


		# Portrait unknown glow
		highlight_icon = {
			name = "portrait_unknown_head_small_glow"
			parentanchor = center
			position = { 3 -9 }
			gfxtype = framedbuttongfx
			effectname = "NoHighlight"
			texture = "gfx/portraits/unknown_portraits/button_unknown_head.dds"
			size = { 80 100 }
			framesize = { 384 480 }
			upframe = 1
			overframe = 2
			block "glow_visible" {

				visible = "[Not(Character.IsValid)]"
			}

			block "glow_flip" {}

			block "onclick" {}
		}
	}

	### Portrait used in the relationship tab
	# Has extra relationship icon from the view of the current character (not necessarily the player)
	type portrait_head_small_relationship = widget {
		size = { 85 90 }

		background = {
			using = Background_Area_Solid

			modify_texture = {
				texture = "gfx/interface/component_masks/mask_fade_vertical.dds"
				blend_mode = alphamultiply
				alpha = 0.2
				mirror = vertical
			}
		}

		background = {
			block "empty_character" {}
			visible = "[Not( Character.HasLandedTitles )]"
			texture = "gfx/portraits/portrait_frame.dds"
			using = Color_Grey
			margin = { -4 -4 }
			alpha = 0.4
		}

		widget = {
			size = { 100% 100% }
			using = Portrait_Background_Glows

			block "empty_character" {}
		}

		portrait_button = {
			parentanchor = bottom|hcenter
			size = { 80 100 }
			using = portrait_base

			block "portrait_texture"
			{
				portrait_texture = "[Character.GetPortrait('environment_head', 'camera_head', 'idle', PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
			}

			mask = "gfx/portraits/portrait_mask_head_small.dds"
			effectname = "NoHighlight"

			highlight_icon = {
				name = "prison_bars"
				visible = "[Character.IsImprisoned]"
				visible_at_creation = no
				size = { 80 88 }
				parentanchor = bottom
				effectname = "NoHighlight"
				texture = "gfx/portraits/portrait_prison_head.dds"

				modify_texture = {
					name = "mask"
					texture = "gfx/portraits/portrait_mask_head_small.dds"
					spriteType = Corneredstretched
					blend_mode = alphamultiply
				}
			}

			block "portrait_button" {}
		}

		widget_portrait_frame = {}

		block "coa" {
			coa_realm_tiny = {
				visible = "[Character.HasLandedTitles]"
				parentanchor = bottom|left
				position = { 3 -2 }
				scale = 0.85
			}
		}

		widget = {
			size = { 100% 100% }
			visible = "[Not( Character.HasLandedTitles )]"
			block "empty_character" {}

			background = {
				texture = "gfx/portraits/portrait_frame.dds"
				using = Color_Grey
				margin = { -4 -4 }
				alpha = 0.4

				modify_texture = {
					texture = "gfx/interface/component_masks/mask_fade_vertical.dds"
					blend_mode = alphamultiply
					mirror = vertical
				}
			}

			background = {
				visible = "[Character.IsHovered]"
				texture = "gfx/portraits/portrait_frame.dds"
				using = Color_Grey
				alpha = 0.7
				margin = { -4 -4 }
			}
		}

		flowcontainer = {
			visible = "[Character.IsValid]"
			ignoreinvisible = yes
			parentanchor = top|right

			block "scripted_relation_status_icons"
			{
				using = Portrait_Relation_Icons_Character_Window
			}

			margin_right = 2

			blockoverride "icon_size"
			{
				size = { 24 24 }
			}

			background = {
				using = Background_Area_Dark
				margin = { 2 2 }
				alpha = 0.8

				modify_texture = {
					texture = "gfx/interface/component_masks/mask_glow.dds"
					blend_mode = alphamultiply
				}
			}
		}

		widget = {
			size = { 85 68 }
			scissor = yes
			parentanchor = bottom

			flowcontainer = {
				parentanchor = bottom|right
				ignoreinvisible = yes
				direction = vertical

				margin = { 4 0 }
				margin_bottom = 4

				flowcontainer = {
					visible = "[Character.IsValid]"
					ignoreinvisible = yes
					direction = vertical
					parentanchor = right
					spacing = 1

					margin_right = 2

					background = {
						using = Background_Area_Dark
						margin = { 2 2 }
					}

					# sorted by priority, highest prio at the bottom
					block "status_icons" {

						icon = {
							name = "relation_icon"
							visible = "[LessThan_int32(Character.GetPlayerDynastyRelationFrame, '(int32)9')]"
							size = { 14 14 }

							texture = "gfx/interface/icons/portraits/relation_small.dds"
							framesize = { 28 28 }
							frame = "[Character.GetPlayerDynastyRelationFrame]"
							tooltip = "[Character.GetPlayerDynastyRelationTooltip]"
						}

						icon = {
							name = "incapable"
							visible = "[Character.IsIncapable]"
							size = { 14 14 }
							texture = "gfx/interface/icons/portraits/incapable_small.dds"
							tooltip = "trait_incapable"
						}

						block "inspiration_status_icons"
						{
							has_inspiration_status_icon = {
								size = { 14 14 }
								texture = "gfx/interface/icons/portraits/inspiration_small.dds"
							}

							has_completed_inspiration_status_icon = {
								size = { 14 14 }
								texture = "gfx/interface/icons/portraits/inspiration_complete_small.dds"
							}
						}

						icon = {
							name = "can_be_punished"
							visible = "[Character.CanBePunished]"
							size = { 14 14 }

							texture = "gfx/interface/icons/portraits/punishment_small.dds"
							tooltip = "[Character.PunishmentTooltip]"
						}

						icon = {
							name = "hook"
							visible = "[Character.PlayerHasHooksOrHookableSecrets]"
							size = { 14 14 }

							texture = "gfx/interface/icons/portraits/hook_secret_small.dds"
							framesize = { 28 28 }
							frame = "[Character.GetHookOrHookableSecretsFrame]"
							tooltip = "[Character.HookTooltip]"
						}

						icon = {
							name = "powerful_vassal"
							visible = "[Character.IsMyPowerfulVassal]"
							size = { 14 14 }

							texture = "gfx/interface/icons/portraits/powerful_vassal_small.dds"
							framesize = { 28 28 }
							frame = "[Character.GetPowerfulVassalFrame]"
							tooltip = "[Character.GetPowerfulVassalTooltip]"
						}

						icon = {
							name = "tributary"
							datacontext = "[Character.GetTributaryContract]"
							visible = "[Character.IsTributaryOf(GetPlayer)]"
							size = { 14 14 }

							texture = "[Character.GetTributaryContract.GetPortraitIconSmall]"
							tooltip = "FRAME_RELATION_TRIBUTARY"
						}

						icon = {
							name = "obedient_to_someone_else"
							visible = "[And(Character.UsesObedience,And(Not(Character.GetOverlord.IsLocalPlayer),Character.IsObedientTo(Character.GetOverlord)))]"

							size = { 14 14 }
							enabled = no
							texture = "gfx/interface/icons/portraits/obedient_small.dds"
							tooltipwidget = widget_obedience_tooltip
						}

						icon = {
							name = "disobedient_to_me"
							visible = "[And(Character.UsesObedience,And(Character.GetOverlord.IsLocalPlayer, And(Not(Character.IsObedientTo(GetPlayer)), Not(Character.IsPlayer))))]"
							size = { 14 14 }
							texture = "gfx/interface/icons/portraits/disobedient_small.dds"
							tooltipwidget = widget_obedience_tooltip
						}

						icon = {
							name = "disobedient_to_someone_else"
							visible = "[And(Character.UsesObedience,And(Not(Character.GetOverlord.IsLocalPlayer),Not(Character.IsObedientTo(Character.GetOverlord))))]"
							size = { 14 14 }
							enabled = no
							texture = "gfx/interface/icons/portraits/disobedient_small.dds"
							tooltipwidget = widget_obedience_tooltip
						}

						flowcontainer = {
							visible = "[And(HasDlcFeature( 'all_under_heaven' ), Character.ShouldShowMovementPower)]"
							ignoreinvisible = yes
							direction = vertical
							datacontext = "[Character]"
							datacontext = "[GetSituation('dynastic_cycle')]"

							icon = {
								name = "advancement_movement"
								visible = "[ObjectsEqual( Situation.GetParticipantGroupByCharacter(Character.Self), Situation.GetTopParticipantGroupByKey('advancement_movement').Self)]"
								size = { 14 14 }

								texture = "gfx/interface/icons/portraits/dynastic_cycle_group_advance_small.dds"

								tooltip = "FRAME_ADVANCEMENT_MOVEMENT"
							}

							icon = {
								name = "expansion_movement"
								visible = "[ObjectsEqual( Situation.GetParticipantGroupByCharacter(Character.Self), Situation.GetTopParticipantGroupByKey('expansion_movement').Self)]"
								size = { 14 14 }

								texture = "gfx/interface/icons/portraits/dynastic_cycle_group_expand_small.dds"

								tooltip = "FRAME_EXPANSION_MOVEMENT"
							}

							icon = {
								name = "conservative_movement"
								visible = "[ObjectsEqual( Situation.GetParticipantGroupByCharacter(Character.Self), Situation.GetTopParticipantGroupByKey('conservative_movement').Self)]"
								size = { 14 14 }

								texture = "gfx/interface/icons/portraits/dynastic_cycle_group_anti_small.dds"

								tooltip = "FRAME_CONSERVATIVE_MOVEMENT"
							}

							icon = {
								name = "pro_hegemon_movement"
								visible = "[ObjectsEqual( Situation.GetParticipantGroupByCharacter(Character.Self), Situation.GetTopParticipantGroupByKey('pro_hegemon_movement').Self)]"
								size = { 14 14 }

								texture = "gfx/interface/icons/portraits/dynastic_cycle_group_pro_small.dds"

								tooltip = "FRAME_PRO_HEGEMON_MOVEMENT"
							}

							icon = {
								name = "undecided_movement"
								visible = "[ObjectsEqual( Situation.GetParticipantGroupByCharacter(Character.Self), Situation.GetTopParticipantGroupByKey('undecided_movement').Self)]"
								size = { 14 14 }

								texture = "gfx/interface/icons/portraits/dynastic_cycle_group_unaligned_small.dds"

								tooltip = "FRAME_UNDECIDED_MOVEMENT"
							}
						}

						icon = {
							name = "unpredictable"
							visible = "[Character.IsOtherPlayer]"
							size = { 14 14 }

							texture = "gfx/interface/icons/portraits/unpredictable.dds"

							tooltip = "PLAYER_OBEDIENCE_UNPREDICTABLE"
						}

						icon = {
							name = "head_icon"
							visible = "[LessThan_int32(Character.GetDynastyHeadRelationFrame('(bool)yes'), '(int32)9')]"
							size = { 14 14 }

							texture = "gfx/interface/icons/portraits/relation_small.dds"
							framesize = { 28 28 }
							frame = "[Character.GetDynastyHeadRelationFrame('(bool)yes')]"
							tooltip = "[Character.GetDynastyHeadRelationTooltip]"
						}

						icon = {
							name = "playable_icon"
							visible = "[ObjectsEqual( Character.Self, GetPlayer.GetPlayerHeir )]"
							size = { 14 14 }
							texture = "gfx/interface/icons/portraits/heir_small.dds"
							tooltip = "[Character.GetPlayableFrameTooltip]"
						}
					}

					block "dead_icon"
					{
						icon = {
							name = "is_dead"
							visible = "[Character.IsDeadAndValid]"
							size = { 14 14 }

							texture = "[Character.GetDeathReasonIcon]"
							tooltip = "CHARACTER_DEAD_TOOLTIP"
						}
					}
				}

				block "opinion_box"
				{
					portrait_opinion_small = {
						name = "tutorial_highlight_character_view_opinion_heir"
					}
				}
			}
		}


		# Portrait unknown glow
		highlight_icon = {
			name = "portrait_unknown_head_small_glow"
			parentanchor = center
			position = { 3 -9 }
			gfxtype = framedbuttongfx
			effectname = "NoHighlight"
			texture = "gfx/portraits/unknown_portraits/button_unknown_head.dds"
			size = { 80 100 }
			framesize = { 384 480 }
			upframe = 1
			overframe = 2

			block "glow_visible"
			{
				visible = "[Not(Character.IsValid)]"
			}

			block "glow_flip" {}

			block "onclick" {}
		}
	}

	type portrait_head_small_legend = widget {
		size = { 95 120 }

		background = {
			texture = "gfx/interface/window_legend_chronicle/marginalia_portrait_gold_bg.dds"
		}

		portrait_button = {
			datacontext = "[Legend.GetProtagonist]"
			parentanchor = bottom|hcenter
			size = { 90 120 }
			using = portrait_base

			shaderfile = "gfx/FX/gui_painterly_portrait.shader"
			pop_out = yes # Painterly shader override for `pop_out` property, it now means "add outline"
			pop_out_v = 1.2 # Painterly shader override for `pop_out_v` property, it now means "outline width"
			grayscale = no # Dead people should be painted non-gray

			block "portrait_texture"
			{
				portrait_texture = "[Character.GetPortrait('environment_head', 'camera_head', 'idle', PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
			}

			mask = "gfx/portraits/portrait_mask_head.dds"
			effectname = "NoHighlight"

			highlight_icon = {
				name = "prison_bars"
				visible = "[Character.IsImprisoned]"
				visible_at_creation = no
				size = { 80 88 }
				parentanchor = center
				effectname = "NoHighlight"
				texture = "gfx/portraits/portrait_prison_head.dds"

				modify_texture = {
					name = "mask"
					texture = "gfx/portraits/portrait_mask_head_small.dds"
					spriteType = Corneredstretched
					blend_mode = alphamultiply
				}
			}
		}

		icon = {
			size = { 95 120 }
			texture = "[GetIllustration( 'legend_chronicle_portrait_small_frame' ).GetTexture( Legend.MakeScope )]"
		}

		block "coa" {
			coa_realm_tiny = {
				visible = "[Character.HasLandedTitles]"
				parentanchor = bottom|left
				position = { 3 -2 }
				scale = 0.85
			}
		}

		widget = {
			size = { 100% 100% }
			visible = "[Not( Character.HasLandedTitles )]"
			block "empty_character" {}

			background = {
				texture = "gfx/portraits/portrait_frame.dds"
				using = Color_Grey
				margin = { -4 -4 }
				alpha = 0.4

				modify_texture = {
					texture = "gfx/interface/component_masks/mask_fade_vertical.dds"
					blend_mode = alphamultiply
					mirror = vertical
				}
			}

			background = {
				visible = "[Character.IsHovered]"
				texture = "gfx/portraits/portrait_frame.dds"
				using = Color_Grey
				alpha = 0.7
				margin = { -4 -4 }
			}
		}

		flowcontainer = {
			parentanchor = bottom|right
			ignoreinvisible = yes
			direction = vertical
			margin = { 4 0 }
			margin_bottom = 5

			portrait_status_icons_small = {
				parentanchor = right
			}

			block "opinion_box"
			{
				portrait_opinion_small = {
					name = "tutorial_highlight_character_view_opinion_heir"
				}
			}
		}
		# Portrait unknown glow
		highlight_icon = {
			name = "portrait_unknown_head_small_glow"
			parentanchor = center
			position = { 3 -9 }
			gfxtype = framedbuttongfx
			effectname = "NoHighlight"
			texture = "gfx/portraits/unknown_portraits/button_unknown_head.dds"
			size = { 80 100 }
			framesize = { 384 480 }
			upframe = 1
			overframe = 2

			block "glow_visible" {
				visible = "[Not(Character.IsValid)]"
			}

			block "glow_flip" {}

			block "onclick" {}
		}
	}

	## Standard head portrait
	type portrait_head = widget {
		size = { 110 120 }

		background = {
			using = Background_Area_Solid
		}

		widget = {
			size = { 100% 100% }
			using = Portrait_Background_Glows

			block "empty_character" {}
		}

		portrait_button = {
			parentanchor = bottom|hcenter
			size = { 100 125 }
			using = portrait_base

			block "portrait_texture" {
				portrait_texture = "[Character.GetPortrait('environment_head', 'camera_head', 'idle', PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
			}

			mask = "gfx/portraits/portrait_mask_head.dds"
			effectname = "NoHighlight"

			highlight_icon = {
				name = "prison_bars"
				visible = "[Character.IsImprisoned]"
				visible_at_creation = no
				size = { 100 118 }
				parentanchor = bottom
				effectname = "NoHighlight"
				texture = "gfx/portraits/portrait_prison_head.dds"

				modify_texture = {
					name = "mask"
					texture = "gfx/portraits/portrait_mask_head.dds"
					spriteType = Corneredstretched
					blend_mode = alphamultiply
				}
			}

			block "portrait_button" {}
		}

		widget_portrait_frame = {}

		portrait_status_icons_small = {
			parentanchor = bottom|right
			position = { -7 -8 }
		}

		block "coa" {
			coa_realm_tiny = {
				visible = "[Character.HasLandedTitles]"
				parentanchor = bottom|left
				position = { 3 -2 }
			}
		}

		block "opinion_box"
		{
			portrait_opinion = {
				parentanchor = bottom|hcenter
				position = { 1 -4 }
			}
		}

		widget = {
			visible = "[Not( Character.HasLandedTitles )]"
			size = { 100% 100%}

			background = {
				texture = "gfx/portraits/portrait_frame.dds"
				using = Color_Grey
				margin = { -4 -4 }
				alpha = 0.5
			}

			background = {
				visible = "[Character.IsHovered]"
				texture = "gfx/portraits/portrait_frame.dds"
				using = Color_Grey
				alpha = 0.7
				margin = { -4 -4 }
			}
		}


		#portrait unknown glow
		button = {
			name = "portrait_unknown_head_glow"
			parentanchor = center
			position = { 3 -7 }
			gfxtype = framedbuttongfx
			effectname = "NoHighlight"
			texture = "gfx/portraits/unknown_portraits/button_unknown_head.dds"
			size = { 98 125 }
			framesize = { 384 480 }
			upframe = 1
			overframe = 2

			block "glow_visible" {
				visible = "[Not(Character.IsValid)]"
			}

			block "glow_flip" {}

			block "onclick" {}

		}
	}

	## Standard portrait from shoulders up
	type portrait_shoulders = widget {

		size = { 125 160 }

		widget = {
			size = { 100% 100% }
			block "portrait_glows"
			{
				using = Portrait_Background_Glows
			}
		}

		portrait_button = {
			parentanchor = bottom|hcenter

			block "portrait_size"
			{
				size = { 145 175 }
			}
			using = portrait_base

			block "portrait_texture"
			{
				portrait_texture = "[Character.GetPortrait('environment_shoulders', 'camera_shoulders', 'idle', PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
			}

			mask = "gfx/portraits/portrait_mask_shoulders.dds"
			effectname = "NoHighlight"

			highlight_icon = {
				name = "prison_bars"
				visible = "[Character.IsImprisoned]"
				visible_at_creation = no
				size = { 100% 100% }
				effectname = "NoHighlight"
				texture = "gfx/portraits/portrait_prison_shoulders.dds"

				modify_texture = {
					name = "mask"
					texture = "gfx/portraits/portrait_mask_shoulders.dds"
					spriteType = Corneredstretched
					blend_mode = alphamultiply
				}
			}

			block "portrait_button" {}
		}

		block "portrait_status_icons" {
			portrait_status_icons = {
				parentanchor = bottom|right
				position = { 0 -3 }
				scale = 0.85

				background = {
					using = Background_Area_Dark
					margin = { 2 3 }
					alpha = 0.8
				}
			}
		}

		block "coa" {
			coa_realm_small_crown = {
				visible = "[Character.HasLandedTitles]"
				parentanchor = bottom|left
				position = { -5 3 }
			}
		}

		block "opinion_box"
		{
			portrait_opinion = {
				parentanchor = bottom|hcenter
				position = { 0 -2 }
			}
		}

		#portrait unknown glow
		button = {
			position = { -8 -14 }
			size = { 141 174 }
			texture = "gfx/portraits/unknown_portraits/button_unknown_shoulders.dds"
			framesize = { 471 589 }
			gfxtype = framedbuttongfx
			effectname = "NoHighlight"
			upframe = 1
			overframe = 2

			block "glow_visible" {

				visible = "[Not(Character.IsValid)]"

			}

			block "glow_flip" {}

			block "onclick" {}
		}
	}

	## Standard torso from waist up
	type portrait_torso = widget {
		size = { 165 200 }

		widget = {
			size = { 100% 100% }
			using = Portrait_Background_Glows
		}

		portrait_button = {
			parentanchor = bottom|hcenter
			size = { 195 225 }
			using = portrait_base

			block "portrait_texture"
			{
				portrait_texture = "[Character.GetPortrait('environment_torso', 'camera_torso', 'idle', PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
			}

			block "portrait_mask"
			{
				mask = "gfx/portraits/portrait_mask_torso.dds"
			}

			effectname = "NoHighlight"

			highlight_icon = {
				name = "prison_bars"
				visible = "[Character.IsImprisoned]"
				visible_at_creation = no
				size = { 100% 100% }
				effectname = "NoHighlight"
				texture = "gfx/portraits/portrait_prison_torso.dds"

				modify_texture = {
					name = "mask"
					texture = "gfx/portraits/portrait_mask_torso.dds"
					spriteType = Corneredstretched
					blend_mode = alphamultiply
				}
			}

			block "portrait_button" {}
		}

		block "portrait_status_icons" {
			portrait_status_icons = {
				parentanchor = bottom|left
				position = { 43 -6 }
				scale = 0.85

				background = {
					using = Background_Area_Dark
					margin = { 2 3 }
					alpha = 0.8
				}
			}
		}

		block "coa" {
			coa_realm_small_crown = {
				visible = "[Character.HasLandedTitles]"
				parentanchor = bottom|left
				position = { -2 1 }
			}
		}

		block "opinion_box"
		{
			portrait_opinion = {
				parentanchor = bottom|hcenter
				position = { 4 -2 }
			}
		}

		#portrait unknown glow
		button = {
			name = "portrait_unknown_torso_glow"
			parentanchor = center
			position = { 0 -12 }
			gfxtype = framedbuttongfx
			effectname = "NoHighlight"
			texture = "gfx/portraits/unknown_portraits/button_unknown.dds"
			size = { 195 225 }
			framesize = { 554 780 }
			upframe = 1
			overframe = 2

			block "glow_visible" {

				visible = "[Not(Character.IsValid)]"

			}

			block "glow_flip" {}

			block "onclick" {}
		}
	}

	## Standard full body portrait
	type portrait_body = widget {
		size = { 210 300 }

		widget = {
			size = { 100% 100% }
			using = Portrait_Background_Glows
		}

		portrait_button = {
			parentanchor = bottom|hcenter
			size = { 240 330 }
			using = portrait_base

			block "portrait_texture" {
				portrait_texture = "[Character.GetPortrait('environment_body', 'camera_body', 'idle', PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
			}
			block "mask" {
				mask = "gfx/portraits/portrait_mask_body.dds"
			}
			effectname = "NoHighlight"

			block "prison" {
				highlight_icon = {
					name = "prison_bars"
					visible = "[Character.IsImprisoned]"
					visible_at_creation = no
					size = { 100% 100% }
					effectname = "NoHighlight"
					texture = "gfx/portraits/portrait_prison_body.dds"

					modify_texture = {
						name = "mask"
						texture = "gfx/portraits/portrait_mask_body.dds"
						spriteType = Corneredstretched
						blend_mode = alphamultiply
					}
				}
			}

			block "portrait_button" {}
		}

		block "portrait_icons" {
			portrait_status_icons = {
				parentanchor = bottom|left
				position = { 60 -5 }
				scale = 0.85

				background = {
					using = Background_Area_Dark
					margin = { 3 3 }
					alpha = 0.8
				}
			}
		}

		block "coa" {
			coa_realm_medium_crown = {
				visible = "[Character.HasLandedTitles]"
				parentanchor = bottom|left
				position = { -2 4 }
			}
		}

		block "opinion_box"
		{
			portrait_opinion = {
				parentanchor = bottom|hcenter
				block "position_portrait_opinion_body" {
					position = { 0 -2 }
				}
			}
		}

		#portrait unknown glow
		button = {
			name = "portrait_unknown_body_glow"
			parentanchor = center
			position = { 0 -15 }
			gfxtype = framedbuttongfx
			effectname = "NoHighlight"
			texture = "gfx/portraits/unknown_portraits/button_unknown_small.dds"
			size = { 240 330 }
			framesize = { 564 780 }
			upframe = 1
			overframe = 2

			block "glow_visible" {

				visible = "[Not(Character.IsValid)]"

			}

			block "glow_flip" {}

			block "onclick" {}

		}
	}

	## Standard full body portrait
	type portrait_body_large = widget {
		size = { 378 540 }

		widget = {
			size = { 100% 100% }
			using = Portrait_Background_Glows
		}

		portrait_button = {
			parentanchor = bottom|hcenter
			size = { 432 594 }
			using = portrait_base

			block "portrait_texture" {
				portrait_texture = "[Character.GetPortrait('environment_body', 'camera_body', 'idle', PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
			}
			block "mask" {
				mask = "gfx/portraits/portrait_mask_body.dds"
			}
			effectname = "NoHighlight"

			block "prison" {
				highlight_icon = {
					name = "prison_bars"
					visible = "[Character.IsImprisoned]"
					visible_at_creation = no
					size = { 100% 100% }
					effectname = "NoHighlight"
					texture = "gfx/portraits/portrait_prison_body.dds"

					modify_texture = {
						name = "mask"
						texture = "gfx/portraits/portrait_mask_body.dds"
						spriteType = Corneredstretched
						blend_mode = alphamultiply
					}
				}
			}

			block "portrait_button" {}
		}

		block "portrait_icons" {
			portrait_status_icons = {
				parentanchor = bottom|left
				position = { 64 -4 }
				scale = 0.85

				background = {
					using = Background_Area_Dark
					margin = { 3 3 }
					alpha = 0.8
				}
			}
		}

		block "coa" {
			coa_realm_medium_crown = {
				visible = "[Character.HasLandedTitles]"
				parentanchor = bottom|left
				position = { -2 4 }
			}
		}

		block "opinion_box"
		{
			portrait_opinion = {
				parentanchor = bottom|hcenter
				block "position_portrait_opinion_body" {
					position = { 0 -2 }
				}
			}
		}

		#portrait unknown glow
		button = {
			name = "portrait_unknown_body_glow"
			parentanchor = center
			position = { 0 -15 }
			gfxtype = framedbuttongfx
			effectname = "NoHighlight"
			texture = "gfx/portraits/unknown_portraits/button_unknown_small.dds"
			size = { 240 330 }
			framesize = { 564 780 }
			upframe = 1
			overframe = 2

			block "glow_visible" {

				visible = "[Not(Character.IsValid)]"

			}

			block "glow_flip" {}

			block "onclick" {}

		}
	}

	####################################
	######## SPECIAL PORTRAITS #########
	####################################

	type portrait_map = widget {
		size = { 85 90 }

		portrait_button = {
			visible = "[Not(Character.IsImprisoned)]"
			parentanchor = bottom|hcenter
			size = { 80 100 }
			using = portrait_base
			portrait_texture = "[Character.GetPortrait('environment_head', 'camera_head', 'idle', PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
			mask = "gfx/portraits/portrait_mask_head.dds"
			effectname = "NoHighlight"

			block "portrait_button" {}
		}
	}

	type portrait_character_view_main = margin_widget {
		size = { 300 300 }
		margin = { 3 3 }

		widget = {
			size = { 100% 100% }
			using = Portrait_Background_Glows
		}

		blockoverride "glow_local_player" {}
		blockoverride "glow_selected" {}
		blockoverride "grayscale" {}

		portrait_button = {
			size = { 380 421 }
			position = { -30 10 }
			parentanchor = bottom|hcenter
			using = portrait_base
			visible = "[Not( And( Character.GetGovernment.HasGovernmentFlag( 'government_is_herder' ), Character.HasLandedTitles) )]"

			portrait_texture = "[Character.GetAnimatedPortrait(Illustration.GetEnvironment(Character.Self), 'camera_character_view_main', 'idle', PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
			mask = "gfx/portraits/portrait_mask_character_view.dds"
			effectname = "NoHighlight"

			highlight_icon = {
				name = "prison_bars"
				visible = "[Character.IsImprisoned]"
				visible_at_creation = no
				size = { 100% 100% }
				position = { 0 20 }

				effectname = "NoHighlight"
				texture = "gfx/portraits/portrait_prison_character_view.dds"

				modify_texture = {
					name = "mask"
					texture = "gfx/portraits/portrait_mask_character_view.dds"
					spriteType = Corneredstretched
					blend_mode = alphamultiply
				}
			}

			block "portrait_button" {}
		}

		portrait_button = {
			size = { 1000 421 }
			position = { -30 10 }
			parentanchor = bottom|hcenter
			using = portrait_base
			tooltip_offset = { -310 0 }
			portrait_texture = "[Character.GetAnimatedPortrait(Illustration.GetEnvironment(Character.Self), 'camera_character_view_main', 'idle', PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
			mask = "gfx/portraits/portrait_mask_character_view.dds"
			effectname = "NoHighlight"
			visible = "[And(Character.Character.GetGovernment.HasGovernmentFlag( 'government_is_herder', Character.HasLandedTitles)]"

			block "prison_bars" {
				highlight_icon = {
					name = "prison_bars"
					visible = "[Character.IsImprisoned]"
					visible_at_creation = no
					size = { 100% 100% }
					position = { 0 20 }

					effectname = "NoHighlight"
					texture = "gfx/portraits/portrait_prison_character_view.dds"

					modify_texture = {
						name = "mask"
						texture = "gfx/portraits/portrait_mask_character_view.dds"
						spriteType = Corneredstretched
						blend_mode = alphamultiply
					}
				}
			}

			block "portrait_button" {}
		}

		portrait_status_icons = {
			parentanchor = bottom|right
			position = { -60 0 }

			block "portrait_status_icons" {}
		}

		block "opinion_box"
		{
			portrait_opinion = {
				position = { -20 0 }
				parentanchor = bottom|hcenter

				block "portrait_opinion" {}
			}
		}
	}

	type portrait_character_view_spouse = margin_widget {
		size = { 320 300 }
		margin = { 3 3 }

		widget = {
			size = { 100% 100% }
			using = Portrait_Background_Glows
		}

		portrait_button = {
			size = { 350 338 }
			position = { 0 10 }
			parentanchor = bottom|hcenter
			using = portrait_base

			portrait_texture = "[Character.GetAnimatedPortrait(Illustration.GetEnvironment( Character.Self ), 'camera_character_view_spouse', Select_CString( Character.IsDiarchOf( Character.GetLiege ), 'chancellor', 'idle' ), PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
			mask = "gfx/portraits/portrait_mask_character_view.dds"
			effectname = "NoHighlight"

			highlight_icon = {
				name = "prison_bars"
				visible = "[Character.IsImprisoned]"
				visible_at_creation = no
				size = { 100% 100% }
				position = { 0 20 }

				effectname = "NoHighlight"
				texture = "gfx/portraits/portrait_prison_character_view.dds"

				modify_texture = {
					name = "mask"
					texture = "gfx/portraits/portrait_mask_character_view.dds"
					spriteType = Corneredstretched
					blend_mode = alphamultiply
				}
			}

			block "portrait_button" {}
		}

		portrait_status_icons = {
			parentanchor = bottom|right
			position = { -53 0 }
		}

		coa_realm_small = {
			visible = "[Character.HasLandedTitles]"
			parentanchor = bottom|right
			position = { 0 5 }
		}
	}

	type portrait_event = widget {

		widget = {
			size = { 500 490 }
			parentanchor = bottom

			icon = {
				name = "hovered"
				parentanchor = bottom|hcenter
				size = { 70% 95% }
				color = { 0.9 0.8 0.6 0.6 }

				using = Background_Portrait_Glow

				block "highlight_visible" {
					visible = no
				}

				state = {
					name = _show
					duration = 0.1
					using = Animation_Curve_Default
					alpha = 1
				}

				state = {
					name = _hide
					duration = 0.3
					using = Animation_Curve_Default
					alpha = 0
					delay = 0.05
				}
			}

			portrait_button = {
				size = { 500 558 }
				using = portrait_base
				parentanchor = hcenter|bottom

				portrait_texture = "[Character.GetAnimatedPortrait('environment_event_standard', 'environment_event_standard', 'idle', PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
				background_texture = "gfx/portraits/portrait_transparent.dds"
				texture = "gfx/portraits/portrait_transparent.dds"
				mask = "gfx/portraits/portrait_mask_event.dds"
				effectname = "NoHighlight"

				block "portrait_button" {}
			}
		}
	}

	type portrait_event_duel = widget {

		widget = {
			size = { 930 490 }
			parentanchor = bottom

			icon = {
				name = "hovered"
				parentanchor = bottom|hcenter
				size = { 40% 95% }
				color = { 0.9 0.8 0.6 0.6 }

				using = Background_Portrait_Glow

				block "highlight_visible" {
					visible = no
				}

				state = {
					name = _show
					duration = 0.1
					using = Animation_Curve_Default
					alpha = 1
				}

				state = {
					name = _hide
					duration = 0.3
					using = Animation_Curve_Default
					alpha = 0
					delay = 0.05
				}
			}

			portrait_button = {
				size = { 930 490 }
				using = portrait_base
				parentanchor = hcenter|bottom

				portrait_texture = "[Character.GetAnimatedPortrait('environment_event_standard', 'environment_event_standard', 'idle', PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
				background_texture = "gfx/portraits/portrait_transparent.dds"
				texture = "gfx/portraits/portrait_transparent.dds"
				mask = "gfx/portraits/portrait_mask_event.dds"
				effectname = "NoHighlight"

				block "portrait_button" {}
			}
		}
	}

	type portrait_event_tournament = widget {

		widget = {
			size = { 500 490 }
			parentanchor = bottom

			icon = {
				name = "hovered"
				parentanchor = bottom|hcenter
				size = { 70% 95% }
				color = { 0.9 0.8 0.6 0.6 }

				using = Background_Portrait_Glow

				block "highlight_visible" {
					visible = no
				}

				state = {
					name = _show
					duration = 0.1
					using = Animation_Curve_Default
					alpha = 1
				}

				state = {
					name = _hide
					duration = 0.3
					using = Animation_Curve_Default
					alpha = 0
					delay = 0.05
				}
			}

			portrait_button = {
				size = { 1150 900 }
				using = portrait_base
				parentanchor = hcenter|bottom

				portrait_texture = "[Character.GetAnimatedPortrait('environment_event_standard', 'environment_event_standard', 'idle', PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
				background_texture = "gfx/portraits/portrait_transparent.dds"
				texture = "gfx/portraits/portrait_transparent.dds"
				mask = "gfx/portraits/portrait_mask_event.dds"
				effectname = "NoHighlight"

				block "portrait_button" {}
			}

			icon = {
				visible = "[Character.IsDeadAndValid]"
				parentanchor = bottom|right
				position = { -80 -30 }
				size = { 30 30 }

				texture = "[Character.GetDeathReasonIcon]"

				tooltip = "CHARACTER_DEAD_TOOLTIP"
			}
		}
	}

	type portrait_event_small = widget {
		size = { 125 160 }

		icon = {
			name = "hovered"
			parentanchor = bottom|hcenter
			size = { 100% 100% }
			color = { 0.9 0.8 0.6 0.6 }

			using = Background_Portrait_Glow

			block "highlight_visible" {
				visible = no
			}

			state = {
				name = _show
				duration = 0.1
				using = Animation_Curve_Default
				alpha = 1
			}

			state = {
				name = _hide
				duration = 0.3
				using = Animation_Curve_Default
				alpha = 0
				delay = 0.05
			}
		}

		portrait_shoulders = {
			size = { 100% 100% }
			blockoverride "portrait_size"
			{
				size = { 100% 100% }
			}

			blockoverride "portrait_glows" {}
		}
	}

	type portrait_event_tiny = widget {

		size = { 85 90 }

		icon = {
			name = "hovered"
			parentanchor = bottom|hcenter
			size = { 100% 100% }
			color = { 0.9 0.8 0.6 0.6 }

			using = Background_Portrait_Glow

			block "highlight_visible" {
				visible = no
			}

			state = {
				name = _show
				duration = 0.1
				using = Animation_Curve_Default
				alpha = 1
			}

			state = {
				name = _hide
				duration = 0.3
				using = Animation_Curve_Default
				alpha = 0
				delay = 0.05
			}
		}

		portrait_shoulders = {
			size = { 100% 100% }
			blockoverride "portrait_size"
			{
				size = { 100% 100% }
			}
			blockoverride "portrait_glows" {}
			blockoverride "coa" {}
		}
	}

	type portrait_scheme_hud = widget {
		size = { 90 112 }

		portrait_button = {
			alwaystransparent = yes
			parentanchor = center
			position = { 0 -9 }
			size = { 90 112 }
			using = portrait_base

			portrait_texture = "[Character.GetPortrait('environment_shoulders', 'camera_scheme_widget_microscopic', 'idle', PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"

			mask = "gfx/portraits/scheme_hud_portrait_mask.dds"
			effectname = "NoHighlight"

			tooltip_visible = no

			highlight_icon = {
				name = "prison_bars"
				visible = "[Character.IsImprisoned]"
				visible_at_creation = no
				size = { 100% 100% }
				effectname = "NoHighlight"
				texture = "gfx/portraits/portrait_prison_shoulders.dds"

				modify_texture = {
					name = "mask"
					texture = "gfx/portraits/portrait_mask_shoulders.dds"
					spriteType = Corneredstretched
					blend_mode = alphamultiply
				}
			}

			block "portrait_button" {}
		}
	}

	type portrait_council = widget {
		size = { 260 285 }

		portrait_button = {
			block "portrait_size"
			{
				size = { 260 285 }
			}
			parentanchor = bottom|hcenter
			using = portrait_base

			portrait_texture = "[Character.GetAnimatedPortrait('environment_council', 'camera_council', CouncilPositionType.GetPortraitAnimation, PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
			mask = "gfx/portraits/portrait_mask_council.dds"
			effectname = "NoHighlight"

			block "mask" {
				mask = "gfx/portraits/portrait_mask_council.dds"
			}
		}

		#portrait unknown glow
		button = {
			name = "portrait_unknown_council_glow"
			visible = "[Not(Character.IsValid)]"
			parentanchor = center
			position = { 2 -37 }
			gfxtype = framedbuttongfx
			effectname = "NoHighlight"
			texture = "gfx/portraits/unknown_portraits/button_unknown_small.dds"
			size = { 239 312 }
			framesize = { 564 780 }
			upframe = 1
			overframe = 2

			block "glow_visible" {

				visible = "[Not(Character.IsValid)]"

			}

			block "onclick" {}
		}
	}

	type portrait_regency = widget {
		size = { 260 285 }

		widget = {
			size = { 100% 100% }
			using = Portrait_Background_Glows
		}

		portrait_button = {
			position = { 0 4 }
			block "portrait_size"
			{
				size = { 260 320 }
			}

			parentanchor = bottom|hcenter
			using = portrait_base

			portrait_texture = "[Character.GetAnimatedPortrait(Illustration.GetEnvironment(Character.Self), 'camera_body', 'idle', PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
			mask = "gfx/portraits/portrait_mask_torso.dds"
			effectname = "NoHighlight"

			block "mask" {
				mask = "gfx/portraits/portrait_mask_council.dds"
			}
		}

		portrait_status_icons = {
			parentanchor = bottom|right
			position = { -54 -10 }
		}

		coa_realm_small_crown = {
			visible = "[Character.HasLandedTitles]"
			parentanchor = bottom|right
			position = { -4 -4 }
		}

		portrait_opinion = {
			parentanchor = bottom|hcenter
			position = { 0 -10 }
		}
	}

	type portrait_war_overview = margin_widget {
		size = { 240 300 }
		allow_outside = yes

		margin = { 3 3 }

		widget = {
			using = Portrait_Background_Glows
			size = { 320 380 }

			alwaystransparent = yes
			parentanchor = bottom|hcenter
		}


		portrait_button = {
			size = { 420 632 }
			parentanchor = bottom|hcenter
			using = portrait_base

			portrait_texture = "[Character.GetAnimatedPortrait('environment_war_overview', 'camera_war_overview', Select_CString(WarParticipantItem.IsAttacker, 'war_attacker', 'war_defender'), PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
			mask = "gfx/portraits/portrait_mask_torso.dds"
			effectname = "NoHighlight"

			block "portrait_button" {}

			block "portrait_transformation"
			{
				portrait_scale = { 1 1 }
			}

			highlight_icon = {
				name = "prison_bars"
				visible = "[Character.IsImprisoned]"
				visible_at_creation = no
				size = { 100% 80% }
				position = { 30 160 }

				effectname = "NoHighlight"
				texture = "gfx/portraits/portrait_prison_body.dds"

				modify_texture = {
					name = "mask"
					texture = "gfx/portraits/portrait_mask_character_view.dds"
					spriteType = Corneredstretched
					blend_mode = alphamultiply
				}
			}
		}
	}

	### Bottom left HUD portrait
	type portrait_hud = portrait_button {
		name = "tutorial_highlight_bottom_left_portrait_button"
		visible = "[Not(GetVariableSystem.Exists( 'lifestyle_open' ))]"
		size = { 350 350 }

		gfxtype = portraitbuttongfx
		shaderfile = "gfx/FX/jomini/gui_portrait.shader"
		effectname = "NoHighlight"

		state = {
			name = _mouse_enter
			on_start = "[Character.OnMouseEnter]"
			scale = 1.35
			using = Animation_Curve_Default
			duration = 0.05
		}

		state = {
			name = _mouse_leave
			on_start = "[Character.OnMouseLeave]"
			using = Animation_Curve_Default
			duration = 0.05
			scale = 1.3
		}

		state = {
			name = _mouse_release
			start_sound = {
				soundeffect = "event:/SFX/UI/Character/sfx_ui_character_portrait_select"
			}
		}

		onclick = "[DefaultOnCharacterClick(Character.GetID)]"
		onrightclick = "[DefaultOnCharacterRightClick(Character.GetID)]"
		button_ignore = none

		clicksound = "event:/SFX/UI/Character/sfx_ui_character_portrait_select"
		oversound = "event:/SFX/UI/Character/sfx_ui_character_portrait_pointer_over"

		portrait_texture = "[Character.GetAnimatedPortrait('environment_hud', 'camera_hud', 'idle', PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
		background_texture = "gfx/portraits/portrait_transparent.dds"
		texture = "gfx/portraits/portrait_transparent.dds"
		mask = "gfx/portraits/portrait_mask_blank.dds"

		highlight_icon = {
			name = "prison_bars"
			visible = "[Character.IsImprisoned]"
			visible_at_creation = no
			size = { 100% 100% }
			effectname = "NoHighlight"
			texture = "gfx/portraits/portrait_prison_shoulders.dds"
			position = { 25 0 }

			modify_texture = {
				name = "mask"
				texture = "gfx/portraits/portrait_mask_head.dds"
				spriteType = Corneredstretched
				blend_mode = alphamultiply
				rotate_uv = 180
			}
		}

		using = tooltip_es
		# tooltip_visible = "[Not(IsInteractionMenuOpenForCharacter(Character.GetID))]"
		tooltip_visible = no

		tooltipwidget = {
			cooltip_type = {
				blockoverride "interaction_info"
				{
					text = "CHARACTER_TOOLTIP_INSTRUCTION"
				}
			}
		}

		tooltip_offset = { -10 0 }
		tooltip_verticalbehavior = slide
		tooltip_horizontalbehavior = mirror
	}

	### Lifestyles portrait
	type portrait_lifestyles = portrait_button {
		size = { 650 1000 }

		effectname = "NoHighlight"
		tooltip_visible = no

		using = portrait_base

		portrait_texture = "[Character.GetAnimatedPortrait('environment_body', 'camera_lifestyles', 'idle', PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
		mask = "gfx/portraits/portrait_mask_blank.dds"

		state = {
			name = _show
			using = Animation_Curve_Default

			duration = 0.15
			alpha = 1
		}

		state = {
			name = _hide
			using = Animation_Curve_Default

			duration = 0.15
			alpha = 0
		}

		background = {
			name = "hovered"
			visible = "[Character.IsHovered]"
			using = Background_Portrait_Glow
			color = { 0.9 0.8 0.6 0.6 }
		}
	}

	### Intent selection portrait
	type portrait_intent_selection = portrait_button {
		size = { 450 500 }

		effectname = "NoHighlight"
		tooltip_visible = no

		using = portrait_base

		onclick = "[DefaultOnCharacterClick(Character.GetID)]"

		portrait_texture = "[Character.GetAnimatedPortrait('environment_body', 'camera_lifestyles', ActivityIntent.GetAnimation( Character.Self ), PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
		mask = "gfx/portraits/portrait_mask_blank.dds"

		state = {
			name = _show
			using = Animation_Curve_Default

			duration = 0.15
			alpha = 1
		}

		state = {
			name = _hide
			using = Animation_Curve_Default

			duration = 0.15
			alpha = 0
		}

		background = {
			name = "hovered"
			visible = "[Character.IsHovered]"
			using = Background_Portrait_Glow
			color = { 0.9 0.8 0.6 0.6 }
		}
	}

	### Bottom left HUD portrait for the activity planner
	type portrait_activity_planner = portrait_button {
		size = { 250 500 }

		gfxtype = portraitbuttongfx
		shaderfile = "gfx/FX/jomini/gui_portrait.shader"
		effectname = "NoHighlight"

		button_ignore = both

		portrait_texture = "[Character.GetAnimatedPortrait('environment_hud', 'camera_event_left', 'idle', PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
		background_texture = "gfx/portraits/portrait_transparent.dds"
		texture = "gfx/portraits/portrait_transparent.dds"
		mask = "gfx/portraits/portrait_mask_blank.dds"
	}

	### Bottom left HUD portrait for the travel planner (might merge with the activity planner)
	type portrait_travel_planner = portrait_button {
		size = { 250 500 }

		gfxtype = portraitbuttongfx
		shaderfile = "gfx/FX/jomini/gui_portrait.shader"
		effectname = "NoHighlight"

		button_ignore = both

		portrait_texture = "[Character.GetAnimatedPortrait('environment_hud', 'camera_event_left', 'idle', PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
		background_texture = "gfx/portraits/portrait_transparent.dds"
		texture = "gfx/portraits/portrait_transparent.dds"
		mask = "gfx/portraits/portrait_mask_blank.dds"
	}

	type portrait_activity_locale_window = widget {
		size = { 210 300 }

		widget = {
			size = { 100% 100% }
			using = Portrait_Background_Glows
		}

		portrait_button = {
			parentanchor = bottom|hcenter
			size = { 240 330 }
			using = portrait_base

			block "portrait_texture" {
				portrait_texture = "[Character.GetAnimatedPortrait('environment_body', 'camera_body', 'idle', PdxGetWidgetScreenSize(PdxGuiWidget.Self))]"
			}
			block "mask" {
				mask = "gfx/portraits/portrait_mask_body.dds"
			}
			effectname = "NoHighlight"

			block "prison" {
				highlight_icon = {
					name = "prison_bars"
					visible = "[Character.IsImprisoned]"
					visible_at_creation = no
					size = { 100% 100% }
					effectname = "NoHighlight"
					texture = "gfx/portraits/portrait_prison_body.dds"

					modify_texture = {
						name = "mask"
						texture = "gfx/portraits/portrait_mask_body.dds"
						spriteType = Corneredstretched
						blend_mode = alphamultiply
					}
				}
			}

			block "portrait_button" {}
		}

		block "coa" {
			coa_realm_medium_crown = {
				visible = "[Character.HasLandedTitles]"
				parentanchor = bottom|left
				position = { -2 4 }
			}
		}

		#portrait unknown glow
		button = {
			name = "portrait_unknown_body_glow"
			parentanchor = center
			position = { 0 -15 }
			gfxtype = framedbuttongfx
			effectname = "NoHighlight"
			texture = "gfx/portraits/unknown_portraits/button_unknown_small.dds"
			size = { 240 330 }
			framesize = { 564 780 }
			upframe = 1
			overframe = 2

			block "glow_visible" {
				visible = "[Not(Character.IsValid)]"
			}

			block "glow_flip" {}

			block "onclick" {}
		}
	}

	####################################
	########### ACCESSORIES ############
	####################################

	## Opinion box for portraits
	type portrait_opinion = flowcontainer {
		name = "tutorial_highlight_portrait_opinion"
		visible = "[And(Character.IsValid, And(Character.IsAlive, Not(Character.IsLocalPlayer)))]"
		ignoreinvisible = yes

		background = {
			name = "portrait_opinion_bg"
			texture = "gfx/interface/component_tiles/solid_black_label.dds"
			spritetype = Corneredtiled
			spriteborder = { 20 20 }
			margin = { 3 1 }
			texture_density = 2
		}

		icon = {
			block "dread_logic" {
				visible = "[Character.ShouldShowDreadEffectIcon]"
				frame = "[Character.GetPlayerDreadEffectIconFrame]"
				tooltip = "[Character.GetPlayerDreadEffectTooltip]"
			}
			name = "dread"
			size = { 20 20 }
			texture = "gfx/interface/icons/portraits/dread_values.dds"
			framesize = { 40 40 }
		}

		icon = {
			name = "historical_info_widget"
			visible = "[GreaterThan_CFixedPoint( Character.MakeScope.Var('show_historical_gui').GetValue, '(CFixedPoint)0' )]"
			size = { 20 20 }
			texture = "gfx/interface/icons/historical_character.dds"
			tooltip = "HISTORICAL_CHARACTER_TOOLTIP"
		}

		text_single = {
			name = "tutorial_highlight_character_view_opinion"
			visible = "[Character.IsValid]"
			max_width = 45
			align = nobaseline
			margin = { 3 0 }
			tooltipwidget = character_opinion_tooltip
			using = tooltip_es
			default_format = "#true_white"

			block "opinion_text" {
				text = "[Character.GetOpinionOf( GetPlayer )|=]"
				fonttintcolor = "[Character.GetOpinionOfTint( GetPlayer )]"
			}
		}
	}

	type portrait_opinion_small = flowcontainer {
		#name = "tutorial_highlight_portrait_opinion"
		visible = "[And(Character.IsValid, And(Character.IsAlive, Not(Character.IsLocalPlayer)))]"
		ignoreinvisible = yes
		margin_right = 2

		background = {
			name = "portrait_opinion_bg"
			texture = "gfx/interface/component_tiles/solid_black_label.dds"
			spritetype = Corneredtiled
			spriteborder = { 20 20 }
			margin = { 2 2 }
			texture_density = 2
		}

		icon = {
			name = "dread"
			visible = "[Character.ShouldShowDreadEffectIcon]"
			size = { 16 16 }
			texture = "gfx/interface/icons/portraits/dread_values.dds"
			framesize = { 40 40 }
			frame = "[Character.GetPlayerDreadEffectIconFrame]"
			tooltip = "[Character.GetPlayerDreadEffectTooltip]"
		}

		text_single = {
			visible = "[Character.IsValid]"
			max_width = 45
			align = nobaseline
			fontsize = 13
			margin = { 3 0 }

			tooltipwidget = character_opinion_tooltip
			using = tooltip_es
			default_format = "#true_white"

			block "opinion_text" {
				text = "[Character.GetOpinionOf( GetPlayer )|=]"
				fonttintcolor = "[Character.GetOpinionOfTint( GetPlayer )]"
			}
		}
	}

	type has_inspiration_status_icon = icon
	{
		name = "has_inspiration"
		visible = "[Character.HasInspiration]"
		texture = "gfx/interface/icons/portraits/inspiration.dds"
		tooltip = "CHARACTER_HAS_INSPIRATION_TOOLTIP"
	}

	type has_completed_inspiration_status_icon = icon
	{
		name = "has_completed_inspiration"
		visible = "[And( Character.HasCompletedAnInspiration, Not( Character.HasInspiration ) )]" # Has an inspiration takes priority
		texture = "gfx/interface/icons/portraits/inspiration_complete.dds"
		tooltip = "CHARACTER_HAS_COMPLETED_AN_INSPIRATION_TOOLTIP"
	}

	## Status icons, shown in the bottom right on portraits
	type portrait_status_icons_small = widget {
		size = { 16 60 }
		scissor = yes

		flowcontainer = {
			visible = "[Character.IsValid]"
			ignoreinvisible = yes
			direction = vertical
			parentanchor = bottom
			spacing = 1

			background = {
				using = Background_Area_Dark
				margin = { 2 2 }
			}

			# sorted by priority, highest prio at the bottom
			block "status_icons" {

				block "scripted_relation_status_icons"
				{
					using = Portrait_Relation_Icons_Small
				}

				icon = {
					name = "relation_icon"
					visible = "[LessThan_int32(Character.GetPlayerDynastyRelationFrame, '(int32)9')]"
					size = { 14 14 }

					texture = "gfx/interface/icons/portraits/relation_small.dds"
					framesize = { 28 28 }
					frame = "[Character.GetPlayerDynastyRelationFrame]"
					tooltip = "[Character.GetPlayerDynastyRelationTooltip]"
				}

				icon = {
					name = "hostage_icon"
					visible = "[Character.IsHostage]"
					size = { 14 14 }
					texture = "gfx/interface/icons/portraits/hostage_small.dds"
					tooltip = "[Character.GetHostageTooltip]"
				}

				icon = {
					name = "traveling_icon"
					visible = "[And(Character.IsTraveling, Character.GetTravelPlan.IsInTransit)]"
					size = { 14 14 }
					texture = "gfx/interface/icons/portraits/travel_small.dds"
					tooltip = "CHARACTER_TRAVELING_TOOLTIP"
				}

				icon = {
					name = "incapable"
					visible = "[Character.IsIncapable]"
					size = { 14 14 }
					texture = "gfx/interface/icons/portraits/incapable_small.dds"
					tooltip = "CHARACTER_INCAPABLE_TOOLTIP"
				}

				block "inspiration_status_icons"
				{
					has_inspiration_status_icon = {
						size = { 14 14 }
						texture = "gfx/interface/icons/portraits/inspiration_small.dds"
					}

					has_completed_inspiration_status_icon = {
						size = { 14 14 }
						texture = "gfx/interface/icons/portraits/inspiration_complete_small.dds"
					}
				}

				icon = {
					name = "can_be_punished"
					visible = "[Character.CanBePunished]"
					size = { 14 14 }

					texture = "gfx/interface/icons/portraits/punishment_small.dds"
					tooltip = "[Character.PunishmentTooltip]"
				}

				icon = {
					name = "hook"
					visible = "[Character.PlayerHasHooksOrHookableSecrets]"
					size = { 14 14 }

					texture = "gfx/interface/icons/portraits/hook_secret_small.dds"
					framesize = { 28 28 }
					frame = "[Character.GetHookOrHookableSecretsFrame]"
					tooltip = "[Character.HookTooltip]"
				}

				icon = {
					name = "powerful_vassal"
					visible = "[Character.IsMyPowerfulVassal]"
					size = { 14 14 }

					texture = "gfx/interface/icons/portraits/powerful_vassal_small.dds"
					framesize = { 28 28 }
					frame = "[Character.GetPowerfulVassalFrame]"
					tooltip = "[Character.GetPowerfulVassalTooltip]"
				}

				icon = {
					name = "tributary"
					datacontext = "[Character.GetTributaryContract]"
					visible = "[Character.IsTributaryOf(GetPlayer)]"
					size = { 14 14 }

					texture = "[Character.GetTributaryContract.GetPortraitIconSmall]"
					tooltip = "FRAME_RELATION_TRIBUTARY"
				}

				icon = {
					name = "obedient_to_me"
					visible = "[And(Character.UsesObedience,And(Character.GetOverlord.IsLocalPlayer, And(Character.IsObedientTo(GetPlayer), Not(Character.IsPlayer))))]"
					size = { 14 14 }
					texture = "gfx/interface/icons/portraits/obedient_small.dds"
					tooltipwidget = widget_obedience_tooltip
				}

				icon = {
					name = "obedient_to_someone_else"
					visible = "[And(Not(Character.IsPlayer),And(Character.UsesObedience,And(Not(Character.GetOverlord.IsLocalPlayer),Character.IsObedientTo(Character.GetOverlord))))]"

					size = { 14 14 }
					enabled = no
					texture = "gfx/interface/icons/portraits/obedient_small.dds"
					tooltipwidget = widget_obedience_tooltip
				}

				icon = {
					name = "disobedient_to_me"
					visible = "[And(Character.UsesObedience,And(Character.GetOverlord.IsLocalPlayer, And(Not(Character.IsObedientTo(GetPlayer)), Not(Character.IsPlayer))))]"
					size = { 14 14 }
					texture = "gfx/interface/icons/portraits/disobedient_small.dds"
					tooltipwidget = widget_obedience_tooltip
				}

				icon = {
					name = "disobedient_to_someone_else"
					visible = "[And( Not(Character.IsPlayer), And(Character.UsesObedience,And(Not(Character.GetOverlord.IsLocalPlayer),Not(Character.IsObedientTo(Character.GetOverlord)))))]"
					size = { 14 14 }
					enabled = no
					texture = "gfx/interface/icons/portraits/disobedient_small.dds"
					tooltipwidget = widget_obedience_tooltip
				}

				flowcontainer = {
					visible = "[And(HasDlcFeature( 'all_under_heaven' ), Character.ShouldShowMovementPower)]"
					ignoreinvisible = yes
					direction = vertical
					datacontext = "[Character]"
					datacontext = "[GetSituation('dynastic_cycle')]"

					icon = {
						name = "advancement_movement"
						visible = "[ObjectsEqual( Situation.GetParticipantGroupByCharacter(Character.Self), Situation.GetTopParticipantGroupByKey('advancement_movement').Self)]"
						size = { 14 14 }

						texture = "gfx/interface/icons/portraits/dynastic_cycle_group_advance_small.dds"

						tooltip = "FRAME_ADVANCEMENT_MOVEMENT"
					}

					icon = {
						name = "expansion_movement"
						visible = "[ObjectsEqual( Situation.GetParticipantGroupByCharacter(Character.Self), Situation.GetTopParticipantGroupByKey('expansion_movement').Self)]"
						size = { 14 14 }

						texture = "gfx/interface/icons/portraits/dynastic_cycle_group_expand_small.dds"

						tooltip = "FRAME_EXPANSION_MOVEMENT"
					}

					icon = {
						name = "conservative_movement"
						visible = "[ObjectsEqual( Situation.GetParticipantGroupByCharacter(Character.Self), Situation.GetTopParticipantGroupByKey('conservative_movement').Self)]"
						size = { 14 14 }

						texture = "gfx/interface/icons/portraits/dynastic_cycle_group_anti_small.dds"

						tooltip = "FRAME_CONSERVATIVE_MOVEMENT"
					}

					icon = {
						name = "pro_hegemon_movement"
						visible = "[ObjectsEqual( Situation.GetParticipantGroupByCharacter(Character.Self), Situation.GetTopParticipantGroupByKey('pro_hegemon_movement').Self)]"
						size = { 14 14 }

						texture = "gfx/interface/icons/portraits/dynastic_cycle_group_pro_small.dds"

						tooltip = "FRAME_PRO_HEGEMON_MOVEMENT"
					}

					icon = {
						name = "undecided_movement"
						visible = "[ObjectsEqual( Situation.GetParticipantGroupByCharacter(Character.Self), Situation.GetTopParticipantGroupByKey('undecided_movement').Self)]"
						size = { 14 14 }

						texture = "gfx/interface/icons/portraits/dynastic_cycle_group_unaligned_small.dds"

						tooltip = "FRAME_UNDECIDED_MOVEMENT"
					}
				}

				icon = {
					name = "unpredictable_small"
					visible = "[Character.IsOtherPlayer]"
					size = { 14 14 }

					texture = "gfx/interface/icons/portraits/unpredictable_small.dds"

					tooltip = "PLAYER_OBEDIENCE_UNPREDICTABLE"
				}

				icon = {
					name = "powerful_family"
					visible = "[And( And( Character.IsHouseHead, Character.GetHouse.IsPowerful ), Character.IsVassalOf( GetPlayer ) )]"
					size = { 14 14 }

					texture = "gfx/interface/icons/portraits/powerful_family_head_small.dds"
					framesize = { 28 28 }
					tooltip = "FRAME_RELATION_POWERFUL_FAMILY"
				}

				icon = {
					name = "dominant_family"
					visible = "[And( And( Character.IsHouseHead, Character.GetHouse.IsDominant ), Character.IsVassalOf( GetPlayer ) )]"
					size = { 14 14 }

					texture = "gfx/interface/icons/portraits/powerful_family_head_small.dds"
					framesize = { 28 28 }
					frame = 2
					tooltip = "FRAME_RELATION_DOMINANT_FAMILY"
				}

				icon = {
					name = "head_icon"
					visible = "[LessThan_int32(Character.GetDynastyHeadRelationFrame('(bool)yes'), '(int32)9')]"
					size = { 14 14 }

					texture = "gfx/interface/icons/portraits/relation_small.dds"
					framesize = { 28 28 }
					frame = "[Character.GetDynastyHeadRelationFrame('(bool)yes')]"
					tooltip = "[Character.GetDynastyHeadRelationTooltip]"
				}

				icon = {
					name = "playable_icon"
					visible = "[ObjectsEqual( Character.Self, GetPlayer.GetPlayerHeir )]"
					size = { 14 14 }
					texture = "gfx/interface/icons/portraits/heir_small.dds"
					tooltip = "[Character.GetPlayableFrameTooltip]"
				}
			}

			block "dead_icon"
			{
				icon = {
					name = "is_dead"
					visible = "[Character.IsDeadAndValid]"
					size = { 14 14 }

					texture = "[Character.GetDeathReasonIcon]"
					tooltip = "CHARACTER_DEAD_TOOLTIP"
				}
			}
		}
	}

	type portrait_status_icons = flowcontainer {
		ignoreinvisible = yes
		visible = "[Character.IsValid]"

		block "direction"
		{
			direction = vertical
		}

		# sorted by priority, highest prio at the bottom
		block "status_icons" {

			block "scripted_relation_status_icons"
			{
				using = Portrait_Relation_Icons
			}

			icon = {
				name = "relation_icon"
				visible = "[LessThan_int32(Character.GetPlayerDynastyRelationFrame, '(int32)9')]"
				size = { 20 20 }

				texture = "gfx/interface/icons/portraits/relation.dds"
				framesize = { 40 40 }
				frame = "[Character.GetPlayerDynastyRelationFrame]"
				tooltip = "[Character.GetPlayerDynastyRelationTooltip]"
			}

			icon = {
				name = "hostage_icon"
				visible = "[Character.IsHostage]"
				size = { 20 20 }
				texture = "gfx/interface/icons/portraits/hostage.dds"
				tooltip = "[Character.GetHostageTooltip]"
			}

			icon = {
				name = "traveling_icon"
				visible = "[And(Character.IsTraveling, Character.GetTravelPlan.IsInTransit)]"
				size = { 20 20 }
				texture = "gfx/interface/icons/portraits/travel.dds"
				tooltip = "CHARACTER_TRAVELING_TOOLTIP"
			}

			icon = {
				name = "not_at_home_icon"
				visible = "[And( Not( Character.IsTraveling ), Character.IsAwayFromHome )]"
				size = { 20 20 }
				texture = "gfx/interface/icons/portraits/travel.dds"
				tooltip = "CHARACTER_AWAY_TOOLTIP"
			}

			icon = {
				name = "incapable"
				visible = "[Character.IsIncapable]"
				size = { 20 20 }
				texture = "gfx/interface/icons/portraits/incapable.dds"
				tooltip = "CHARACTER_INCAPABLE_TOOLTIP"
			}

			block "inspiration_status_icons"
			{
				has_inspiration_status_icon = {
					size = { 20 20 }
				}
				has_completed_inspiration_status_icon = {
					size = { 20 20 }
				}
			}

			icon = {
				name = "can_be_punished"
				visible = "[Character.CanBePunished]"
				size = { 20 20 }

				texture = "gfx/interface/icons/portraits/punishment.dds"
				tooltip = "[Character.PunishmentTooltip]"
			}

			icon = {
				name = "hook"
				visible = "[Character.PlayerHasHooksOrHookableSecrets]"
				size = { 20 20 }

				texture = "gfx/interface/icons/portraits/hook_secret.dds"
				framesize = { 40 40 }
				frame = "[Character.GetHookOrHookableSecretsFrame]"
				tooltip = "[Character.HookTooltip]"
			}

			icon = {
				name = "liege_icon"
				visible = "[And( ObjectsEqual( GetPlayer.GetLiege, Character.Self ) , Not( GetPlayer.IsIndependentRuler ) ) ]"
				size = { 20 20 }

				texture = "gfx/interface/icons/portraits/liege.dds"
				tooltip = "FRAME_RELATION_MY_LIEGE"
			}

			icon = {
				name = "powerful_vassal"
				visible = "[Character.IsMyPowerfulVassal]"
				size = { 20 20 }

				texture = "gfx/interface/icons/portraits/powerful_vassal.dds"
				framesize = { 40 40 }
				frame = "[Character.GetPowerfulVassalFrame]"
				tooltip = "[Character.GetPowerfulVassalTooltip]"
			}

			icon = {
				name = "tributary"
				datacontext = "[Character.GetTributaryContract]"
				visible = "[Character.IsTributaryOf(GetPlayer)]"
				size = { 20 20 }

				texture = "[Character.GetTributaryContract.GetPortraitIcon]"
				tooltip = "FRAME_RELATION_TRIBUTARY"
			}

			icon = {
				name = "obedient_to_me"
				visible = "[And(Character.UsesObedience,And(Character.GetOverlord.IsLocalPlayer, And(Character.IsObedientTo(GetPlayer), Not(Character.IsPlayer))))]"
				size = { 20 20 }
				texture = "gfx/interface/icons/portraits/obedient.dds"
				tooltipwidget = widget_obedience_tooltip
			}

			icon = {
				name = "obedient_to_someone_else"
				visible = "[And(Not(Character.IsPlayer),And(Character.UsesObedience,And(Not(Character.GetOverlord.IsLocalPlayer),Character.IsObedientTo(Character.GetOverlord))))]"
				size = { 20 20 }
				enabled = no
				texture = "gfx/interface/icons/portraits/obedient.dds"
				tooltipwidget = widget_obedience_tooltip
			}

			icon = {
				name = "disobedient_to_me"
				visible = "[And(Character.UsesObedience,And(Character.GetOverlord.IsLocalPlayer, And(Not(Character.IsObedientTo(GetPlayer)), Not(Character.IsPlayer))))]"
				size = { 20 20 }
				texture = "gfx/interface/icons/portraits/disobedient.dds"
				tooltipwidget = widget_obedience_tooltip
			}

			icon = {
				name = "disobedient_to_someone_else"
				visible = "[And( Not(Character.IsPlayer), And(Character.UsesObedience,And(Not(Character.GetOverlord.IsLocalPlayer),Not(Character.IsObedientTo(Character.GetOverlord)))))]"
				size = { 20 20 }
				enabled = no
				texture = "gfx/interface/icons/portraits/disobedient.dds"
				tooltipwidget = widget_obedience_tooltip
			}

			container_dynastic_cycle_group_icons = {}

			icon = {
				name = "unpredictable"
				visible = "[Character.IsOtherPlayer]"
				size = { 20 20 }

				texture = "gfx/interface/icons/portraits/unpredictable.dds"

				tooltip = "PLAYER_OBEDIENCE_UNPREDICTABLE"
			}

			icon = {
				name = "powerful_family"
				visible = "[And( And( Character.IsHouseHead, Character.GetHouse.IsPowerful ), Character.IsVassalOf( GetPlayer ) )]"
				size = { 20 20 }

				texture = "gfx/interface/icons/portraits/powerful_family_head.dds"
				framesize = { 40 40 }
				tooltip = "FRAME_RELATION_POWERFUL_FAMILY"
			}

			icon = {
				name = "dominant_family"
				visible = "[And( And( Character.IsHouseHead, Character.GetHouse.IsDominant ), Character.IsVassalOf( GetPlayer ) )]"
				size = { 20 20 }

				texture = "gfx/interface/icons/portraits/powerful_family_head.dds"
				framesize = { 40 40 }
				frame = 2
				tooltip = "FRAME_RELATION_DOMINANT_FAMILY"
			}

			icon = {
				name = "head_icon"
				visible = "[LessThan_int32(Character.GetDynastyHeadRelationFrame('(bool)yes'), '(int32)9')]"
				size = { 20 20 }

				texture = "gfx/interface/icons/portraits/relation.dds"
				framesize = { 40 40 }
				frame = "[Character.GetDynastyHeadRelationFrame('(bool)yes')]"
				tooltip = "[Character.GetDynastyHeadRelationTooltip]"
			}

			icon = {
				name = "favorite_child"
				visible = "[Character.IsFavoriteChildOf( GetPlayer )]"
				size = { 20 20 }
				texture = "gfx/interface/icons/character_interactions/designate_favorite.dds"
				tooltip = "SUCCESSION_IS_FAVORITE_CHILD_TT"
			}

			icon = {
				name = "playable_icon"
				visible = "[ObjectsEqual( Character.Self, GetPlayer.GetPlayerHeir )]"
				size = { 20 20 }
				texture = "gfx/interface/icons/portraits/heir.dds"
				tooltip = "[Character.GetPlayableFrameTooltip]"
			}
		}

		block "dead_icon"
		{
			icon = {
				name = "is_dead"
				visible = "[Character.IsDeadAndValid]"
				size = { 20 20 }

				texture = "[Character.GetDeathReasonIcon]"
				tooltip = "CHARACTER_DEAD_TOOLTIP"
			}
		}
	}
}

######################################################
##################### TEMPLATES ######################
######################################################

## BASE TEMPLATE

template portrait_base
{
	pop_out = no
	block "grayscale" {
		grayscale = "[Not(Character.IsAlive)]"
	}

	gfxtype = portraitbuttongfx
	shaderfile = "gfx/FX/jomini/gui_portrait.shader"

	intersectionmask = no

	background_texture = "gfx/portraits/portrait_transparent.dds"
	texture = "gfx/portraits/portrait_transparent.dds"

	clicksound = "event:/SFX/UI/Character/sfx_ui_character_portrait_select"
	oversound = "event:/SFX/UI/Character/sfx_ui_character_portrait_pointer_over"

	block "portrait_button_template_onmouseenter"
	{
		state = {
			name = _mouse_enter
			trigger_when = "[Character.IsValid]"
			on_finish = "[Character.OnMouseEnter]"
		}
	}
	block "portrait_button_template_onmouseleave"
	{
		state = {
			name = _mouse_leave
			on_start = "[Character.OnMouseLeave]"
		}
	}

	block "portrait_button_template_onclick"
	{
		onclick = "[DefaultOnCharacterClick(Character.GetID)]"
	}

	block "portrait_button_template_onrightclick"
	{
		onrightclick = "[DefaultOnCharacterRightClick(Character.GetID)]"
		button_ignore = none
	}

	filter_mouse = right

	block "portrait_button_template_tooltip"
	{
		tooltip_visible = "[Not(IsInteractionMenuOpenForCharacter(Character.GetID))]"

		tooltipwidget = {
			cooltip_type = {
				blockoverride "interaction_info" {
					text = "CHARACTER_TOOLTIP_INSTRUCTION"
				}
			}
		}
	}

	using = tooltip_es
	tooltip_offset = { 0 0 }
	tooltip_verticalbehavior = slide
	tooltip_horizontalbehavior = mirror

	block "portrait_transformation"
	{
		portrait_scale = { 1.0 1.0 }
		portrait_offset = { 0.0 0.0 }
	}
}

template Portrait_Background_Glows
{
	block "portrait_glow"
	{
		# Is Local Player
		block "glow_local_player"
		{
			background = {
				visible = "[And(Character.IsLocalPlayer, Not(Character.IsHovered))]"
				using = Background_Portrait_Glow
				color = { 0.5 0.6 0.7 0.6 }
			}
		}

		block "glow_other_player"
		{
			# Is Other Player
			background = {
				visible = "[And(Character.IsOtherPlayer, Not(Character.IsHovered))]"
				using = Background_Portrait_Glow
				color = { 0.8 0.4 0.55 0.6 }
			}
		}

		block "glow_selected"
		{
			background = {
				name = "selected"
				using = Background_Portrait_Glow
				color = { 0.8 0.7 0.5 0.6 }

				block "glow_selected_visible"
				{
					visible = "[Character.IsSelected]"
				}
			}
		}

		block "glow_hovered"
		{
			background = {
				name = "hovered"
				visible = "[Character.IsHovered]"
				using = Background_Portrait_Glow
				color = { 0.9 0.8 0.6 0.6 }
			}
		}
	}
}

template Background_Portrait_Glow
{
	texture = "gfx/portraits/portrait_glow.dds"
}

template Portrait_Relation_Icon_Normal_Size
{
	size = { 20 20 }
	framesize = { 40 40 }

	visible = "[ScriptedRelation.HasRelationBetween( GetPlayer, Character.Self )]"

	tooltipwidget = {
		scripted_relation_tooltip = {
			blockoverride "description_text"
			{
				text = "[GetScriptedRelationTooltip( ScriptedRelation, GetPlayer, Character )]"
			}
		}
	}
}

template Portrait_Relation_Icon_Small_Size
{
	size = { 14 14 }
	framesize = { 28 28 }

	visible = "[ScriptedRelation.HasRelationBetween( GetPlayer, Character.Self )]"

	tooltipwidget = {
		scripted_relation_tooltip = {
			blockoverride "description_text"
			{
				text = "[GetScriptedRelationTooltip( ScriptedRelation, GetPlayer, Character )]"
			}
		}
	}
}

types portrait_icons
{
	type scripted_relation_tooltip = container
	{
		alwaystransparent = no

		object_tooltip_pop_out = {
			blockoverride "title_text" {
				margin = { 0 8 }
				text = "[ScriptedRelation.GetName]"
			}

			blockoverride "concept_link" {
				text = "[relation|E]"
			}
		}
	}

	# Normal size icons
	type lover_relation_icon = icon
	{
		name = "lover"

		datacontext = "[GetRelation( 'lover' )]"

		texture = "gfx/interface/icons/portraits/lover_soulmate.dds"
		frame = 1

		block "icon_template" {
			using = Portrait_Relation_Icon_Normal_Size
		}
	}

	type friend_relation_icon = icon
	{
		name = "friend"

		datacontext = "[GetRelation( 'friend' )]"

		texture = "gfx/interface/icons/portraits/friend_bestfriend.dds"
		frame = 1

		block "icon_template" {
			using = Portrait_Relation_Icon_Normal_Size
		}
	}

	type rival_relation_icon = icon
	{
		name = "rival"

		datacontext = "[GetRelation( 'rival' )]"

		texture = "gfx/interface/icons/portraits/rival_nemesis.dds"
		frame = 1

		block "icon_template" {
			using = Portrait_Relation_Icon_Normal_Size
		}
	}

	type soulmate_relation_icon = icon
	{
		name = "soulmate"

		datacontext = "[GetRelation( 'soulmate' )]"

		texture = "gfx/interface/icons/portraits/lover_soulmate.dds"
		frame = 2

		block "icon_template" {
			using = Portrait_Relation_Icon_Normal_Size
		}
	}

	type best_friend_relation_icon = icon
	{
		name = "best_friend"

		datacontext = "[GetRelation( 'best_friend' )]"

		texture = "gfx/interface/icons/portraits/friend_bestfriend.dds"
		frame = 2

		block "icon_template" {
			using = Portrait_Relation_Icon_Normal_Size
		}
	}

	type nemesis_relation_icon = icon
	{
		name = "nemesis"

		datacontext = "[GetRelation( 'nemesis' )]"

		texture = "gfx/interface/icons/portraits/rival_nemesis.dds"
		frame = 2

		block "icon_template" {
			using = Portrait_Relation_Icon_Normal_Size
		}
	}

	type grudge_relation_icon = icon
	{
		name = "grudge"

		datacontext = "[GetRelation( 'grudge' )]"

		texture = "gfx/interface/icons/portraits/rival_grudge.dds"
		frame = 1

		block "icon_template" {
			using = Portrait_Relation_Icon_Normal_Size
		}
	}

	type blood_brother_relation_icon = icon
	{
		name = "blood_brother"

		datacontext = "[GetRelation( 'blood_brother' )]"

		texture = "gfx/interface/icons/portraits/blood_brother.dds"
		frame = 2

		block "icon_template" {
			using = Portrait_Relation_Icon_Normal_Size
		}
	}

	type elder_relation_icon = icon
	{
		name = "elder"

		datacontext = "[GetRelation( 'elder' )]"

		texture = "gfx/interface/icons/portraits/elder.dds"
		frame = 2

		block "icon_template" {
			using = Portrait_Relation_Icon_Normal_Size
		}
	}

	type disciple_relation_icon = icon
	{
		name = "disciple"

		datacontext = "[GetRelation( 'disciple' )]"

		texture = "gfx/interface/icons/portraits/disciple.dds"
		frame = 2

		block "icon_template" {
			using = Portrait_Relation_Icon_Normal_Size
		}
	}

	# Small size icons
	type lover_relation_icon_small = icon
	{
		name = "lover"

		datacontext = "[GetRelation( 'lover' )]"

		texture = "gfx/interface/icons/portraits/lover_soulmate_small.dds"
		frame = 1

		using = Portrait_Relation_Icon_Small_Size
	}

	type friend_relation_icon_small = icon
	{
		name = "friend"

		datacontext = "[GetRelation( 'friend' )]"

		texture = "gfx/interface/icons/portraits/friend_bestfriend_small.dds"
		frame = 1

		using = Portrait_Relation_Icon_Small_Size
	}

	type rival_relation_icon_small = icon
	{
		name = "rival"

		datacontext = "[GetRelation( 'rival' )]"

		texture = "gfx/interface/icons/portraits/rival_nemesis_small.dds"
		frame = 1

		using = Portrait_Relation_Icon_Small_Size
	}

	type soulmate_relation_icon_small = icon
	{
		name = "soulmate"

		datacontext = "[GetRelation( 'soulmate' )]"

		texture = "gfx/interface/icons/portraits/lover_soulmate_small.dds"
		frame = 2

		using = Portrait_Relation_Icon_Small_Size
	}

	type best_friend_relation_icon_small = icon
	{
		name = "best_friend"

		datacontext = "[GetRelation( 'best_friend' )]"

		texture = "gfx/interface/icons/portraits/friend_bestfriend_small.dds"
		frame = 2

		using = Portrait_Relation_Icon_Small_Size
	}

	type nemesis_relation_icon_small = icon
	{
		name = "nemesis"

		datacontext = "[GetRelation( 'nemesis' )]"

		texture = "gfx/interface/icons/portraits/rival_nemesis_small.dds"
		frame = 2

		using = Portrait_Relation_Icon_Small_Size
	}

	type grudge_relation_icon_small = icon
	{
		name = "grudge"

		datacontext = "[GetRelation( 'grudge' )]"

		texture = "gfx/interface/icons/portraits/rival_grudge_small.dds"
		frame = 1

		using = Portrait_Relation_Icon_Small_Size
	}

	type blood_brother_relation_icon_small = icon
	{
		name = "blood_brother"

		datacontext = "[GetRelation( 'blood_brother')]"

		texture = "gfx/interface/icons/portraits/blood_brother_small.dds"
		frame = 1

		using = Portrait_Relation_Icon_Small_Size
	}

	type elder_relation_icon_small = icon
	{
		name = "elder"

		datacontext = "[GetRelation( 'elder' )]"

		texture = "gfx/interface/icons/portraits/elder_small.dds"
		frame = 1

		block "icon_template" {
			using = Portrait_Relation_Icon_Small_Size
		}
	}

	type disciple_relation_icon_small = icon
	{
		name = "disciple"

		datacontext = "[GetRelation( 'disciple' )]"

		texture = "gfx/interface/icons/portraits/disciple_small.dds"
		frame = 1

		block "icon_template" {
			using = Portrait_Relation_Icon_Small_Size
		}
	}

	type container_dynastic_cycle_group_icons = container {
		name = "container_dynastic_cycle_group_icons"
		visible = "[And(HasDlcFeature( 'all_under_heaven' ), Character.ShouldShowMovementPower)]"
		datacontext = "[Character]"
		datacontext = "[GetSituation('dynastic_cycle')]"
		ignoreinvisible = yes

		icon = {
			name = "advancement_movement"
			visible = "[ObjectsEqual( Situation.GetParticipantGroupByCharacter(Character.Self), Situation.GetTopParticipantGroupByKey('advancement_movement').Self)]"
			size = { 20 20 }

			texture = "gfx/interface/icons/portraits/dynastic_cycle_group_advance.dds"

			block "dynastic_cycle_group_icon_tooltip"
			{
				tooltip = "FRAME_ADVANCEMENT_MOVEMENT"
			}
		}

		icon = {
			name = "expansion_movement"
			visible = "[ObjectsEqual( Situation.GetParticipantGroupByCharacter(Character.Self), Situation.GetTopParticipantGroupByKey('expansion_movement').Self)]"
			size = { 20 20 }

			texture = "gfx/interface/icons/portraits/dynastic_cycle_group_expand.dds"

			block "dynastic_cycle_group_icon_tooltip"
			{
				tooltip = "FRAME_EXPANSION_MOVEMENT"
			}
		}

		icon = {
			name = "conservative_movement"
			visible = "[ObjectsEqual( Situation.GetParticipantGroupByCharacter(Character.Self), Situation.GetTopParticipantGroupByKey('conservative_movement').Self)]"
			size = { 20 20 }

			texture = "gfx/interface/icons/portraits/dynastic_cycle_group_anti.dds"

			block "dynastic_cycle_group_icon_tooltip"
			{
				tooltip = "FRAME_CONSERVATIVE_MOVEMENT"
			}
		}

		icon = {
			name = "pro_hegemon_movement"
			visible = "[ObjectsEqual( Situation.GetParticipantGroupByCharacter(Character.Self), Situation.GetTopParticipantGroupByKey('pro_hegemon_movement').Self)]"
			size = { 20 20 }

			texture = "gfx/interface/icons/portraits/dynastic_cycle_group_pro.dds"

			block "dynastic_cycle_group_icon_tooltip"
			{
				tooltip = "FRAME_PRO_HEGEMON_MOVEMENT"
			}
		}

		icon = {
			name = "undecided_movement"
			visible = "[ObjectsEqual( Situation.GetParticipantGroupByCharacter(Character.Self), Situation.GetTopParticipantGroupByKey('undecided_movement').Self)]"
			size = { 20 20 }

			texture = "gfx/interface/icons/portraits/dynastic_cycle_group_unaligned.dds"

			block "dynastic_cycle_group_icon_tooltip"
			{
				tooltip = "FRAME_UNDECIDED_MOVEMENT"
			}
		}
	}
}

template Portrait_Relation_Icons
{
	lover_relation_icon = {}
	friend_relation_icon = {}
	rival_relation_icon = {}
	soulmate_relation_icon = {}
	best_friend_relation_icon = {}
	nemesis_relation_icon = {}
	grudge_relation_icon = {}
	blood_brother_relation_icon = {}
	elder_relation_icon = {}
	disciple_relation_icon = {}
}

template Portrait_Relation_Icons_Small
{
	lover_relation_icon_small = {}
	friend_relation_icon_small = {}
	rival_relation_icon_small = {}
	soulmate_relation_icon_small = {}
	best_friend_relation_icon_small = {}
	nemesis_relation_icon_small = {}
	grudge_relation_icon_small = {}
	blood_brother_relation_icon_small = {}
	elder_relation_icon_small = {}
	disciple_relation_icon_small = {}
}

template Portrait_Relation_Icons_Character_Window
{
	lover_relation_icon = {
		blockoverride "icon_template"
		{
			using = Character_Window_Relation_Icon
		}
	}
	friend_relation_icon = {
		blockoverride "icon_template"
		{
			using = Character_Window_Relation_Icon
		}
	}
	rival_relation_icon = {
		blockoverride "icon_template"
		{
			using = Character_Window_Relation_Icon
		}
	}
	soulmate_relation_icon = {
		blockoverride "icon_template"
		{
			using = Character_Window_Relation_Icon
		}
	}
	best_friend_relation_icon = {
		blockoverride "icon_template"
		{
			using = Character_Window_Relation_Icon
		}
	}
	nemesis_relation_icon = {
		blockoverride "icon_template"
		{
			using = Character_Window_Relation_Icon
		}
	}
	grudge_relation_icon = {
		blockoverride "icon_template"
		{
			using = Character_Window_Relation_Icon
		}
	}
	blood_brother_relation_icon = {
		blockoverride "icon_template"
		{
			using = Character_Window_Relation_Icon
		}
	}
	elder_relation_icon = {
		blockoverride "icon_template"
		{
			using = Character_Window_Relation_Icon
		}
	}
	disciple_relation_icon = {
		blockoverride "icon_template"
		{
			using = Character_Window_Relation_Icon
		}
	}
}
