scripted_gui = {

	# ============================================================
	# MAIN WAR COLLEGE WINDOW
	# Visible whenever the wc_window_open flag is set on the player
	# country (set/cleared by the debug decision and the close button).
	# ============================================================
	# ============================================================
	# WAR COLLEGE LAUNCHER BUTTON
	# Lives inside the vanilla Officer Corps view (parent container
	# "officer_core_view" - confirmed at countryofficercorpview.gui:583).
	# Clicking the button toggles the wc_window_open country flag, so a
	# second click closes the war college window. Replaces the old debug
	# decision as the only entry point.
	# ============================================================
	wc_button_gui_window = {
		window_name = "wc_button_gui_window"
		parent_window_name = "officer_core_view"
		context_type = player_context

		visible = {
			always = yes
		}

		effects = {
			# Toggle the main war college window. Both branches clear every
			# WC sub-flag so the player always opens fresh on the War Games
			# tab with no stale picker / sub-window state. Without this, a
			# previously-set wc_academy_tab would leave wc_main_window
			# hidden on re-open (since wc_main_window's visibility gates
			# on NOT academy_tab).
			wc_launcher_button_click = {
				if = {
					limit = { has_country_flag = wc_window_open }
					clr_country_flag = wc_window_open
					clr_country_flag = wc_picker_open
					clr_country_flag = wc_academy_tab
					clr_country_flag = wc_headmaster_picker_open
					clr_country_flag = wc_officer_picker_open
				}
				else = {
					set_country_flag = wc_window_open
					clr_country_flag = wc_picker_open
					clr_country_flag = wc_academy_tab
					clr_country_flag = wc_headmaster_picker_open
					clr_country_flag = wc_officer_picker_open
				}
			}
		}

		ai_enabled = { always = no }
	}
	wc_main_gui = {
		window_name = "wc_main_window"
		context_type = player_context

		# wc_main_window only shows on the War Games tab. The academy tab
		# is handled by wc_academy_gui targeting wc_academy_window.
		visible = {
			has_country_flag = wc_window_open
			NOT = { has_country_flag = wc_academy_tab }
		}

		effects = {
			# Close
			wc_main_close_button_click = {
				clr_country_flag = wc_window_open
				clr_country_flag = wc_picker_open
				clr_country_flag = wc_academy_tab
				clr_country_flag = wc_headmaster_picker_open
				clr_country_flag = wc_officer_picker_open
			}

			# Tab swap. Setting wc_academy_tab hides every War-Games inner element
			# via the trigger gates added below; clearing it restores them.
			wc_open_war_games_menu_click = {
				clr_country_flag = wc_academy_tab
			}
			wc_open_academy_menu_click = {
				set_country_flag = wc_academy_tab
				clr_country_flag = wc_picker_open
			}

			# Build the college (5 civs / 90 days, modeled as a productivity-loss timed idea)
			wc_build_college_button_click = {
				wc_build_college_effect = yes
			}

			# Open the picker sub-window
			wc_open_picker_button_click = {
				set_country_flag = wc_picker_open
			}

			# Advance the active training by one phase
			wc_advance_phase_button_click = {
				wc_advance_active_training_effect = yes
			}

			# Conclude a completed training - clears the slot and closes out
			wc_conclude_button_click = {
				wc_conclude_active_training_effect = yes
			}

			# Toggle auto-advance. The frame variable feeds the sprite
			# (1 = unchecked, 2 = checked) via the properties block, so
			# the checkbox visually reflects the toggle state.
			wc_checkmark_box_frame_click = {
				if = {
					limit = { check_variable = { wc_auto_advance_enabled = 1 } }
					set_variable = { wc_auto_advance_enabled = 0 }
					set_variable = { wc_auto_advance_frame = 1 }
				}
				else = {
					set_variable = { wc_auto_advance_enabled = 1 }
					set_variable = { wc_auto_advance_frame = 2 }
				}
			}
		}

		triggers = {
			# All War-Games inner elements share the same tab gate. When
			# wc_academy_tab is set, every gate here returns false and the
			# academy view (further down) takes over inside wc_main_inner.

			# Top tab buttons: always visible (they live above wc_main_inner
			# and switch tabs). Frame is selected via the properties block.
			wc_open_war_games_menu_visible = { always = yes }
			wc_open_academy_menu_visible = { always = yes }

			# Build button: visible while the college isn't built (so the
			# button stays on screen during construction, alongside the
			# progress bar). HOI4 auto-greys the button while
			# _click_enabled is false, which is what we want.
			wc_build_college_button_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				NOT = { check_variable = { wc_built = 1 } }
			}

			# Build button: clickable only when not already constructing
			# AND the country has at least 5 civs total. With the cost
			# model on consumer_goods_factor (not civilian_factory_use),
			# we don't need *idle* civs - the modifier just shifts the
			# allocation - but a minimum industrial base still gates the
			# project so a 1-civ minor can't trivially build it.
			wc_build_college_button_click_enabled = {
				NOT = { check_variable = { wc_construction_active = 1 } }
				num_of_civilian_factories > 4
			}

			# Construction progress bar visible only while building.
			# wc_construction_bar_clip is the clipping container that wraps
			# the bar sprite; gating its visibility hides the inner
			# wc_construction_progress_bar with it (no need to gate the
			# inner sprite separately).
			wc_construction_progress_bar_frame_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				check_variable = { wc_construction_active = 1 }
			}
			wc_construction_bar_clip_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				check_variable = { wc_construction_active = 1 }
			}
			wc_construction_progress_text_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				check_variable = { wc_construction_active = 1 }
			}

			# Open-picker button: visible when built and no training is active
			wc_open_picker_button_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				check_variable = { wc_built = 1 }
				NOT = { check_variable = { wc_training_active = 1 } }
			}

			# Advance-phase button: visible when a training is active and not yet at phase 3
			wc_advance_phase_button_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				check_variable = { wc_training_active = 1 }
				check_variable = { wc_training_phase < 3 }
			}

			# Advance-phase button: enabled only after the per-phase cooldown
			# elapses AND the player has enough equipment for the next payment.
			# The button stays visible-but-greyed in either failure case.
			# (HOI4 wants the _click_enabled suffix for click-gating; plain
			# _enabled is silently ignored.)
			wc_advance_phase_button_click_enabled = {
				check_variable = { wc_phase_cooldown_days < 1 }
				wc_can_pay_current_phase = yes
			}

			# Conclude button: visible only at phase 3 AND only after the final
			# training period has elapsed (cooldown < 1). While the final period
			# runs, neither Advance nor Conclude are visible - the action label
			# below the slot tells the player to wait.
			wc_conclude_button_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				check_variable = { wc_training_active = 1 }
				check_variable = { wc_training_phase = 3 }
				check_variable = { wc_phase_cooldown_days < 1 }
			}

			# The track panel only makes sense once the college is built.
			# Hiding the parent container hides every child icon/textbox with
			# it - no need to gate the inner reward icons or progress fills
			# again on the academy tab flag.
			wc_track_panel_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				check_variable = { wc_built = 1 }
			}

			# Auto-advance checkbox: only meaningful once the college is
			# built. Lives inside wc_track_panel but per-element gates
			# don't always inherit reliably from container visibility.
			wc_checkmark_box_frame_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				check_variable = { wc_built = 1 }
			}

			# Reward icons + level numbers visible only while a training is active
			wc_reward_frame_t1_visible = { check_variable = { wc_training_active = 1 } }
			wc_reward_icon_t1_visible  = { check_variable = { wc_training_active = 1 } }
			wc_reward_level_t1_visible = { check_variable = { wc_training_active = 1 } }
			wc_reward_frame_t2_visible = { check_variable = { wc_training_active = 1 } }
			wc_reward_icon_t2_visible  = { check_variable = { wc_training_active = 1 } }
			wc_reward_level_t2_visible = { check_variable = { wc_training_active = 1 } }
			wc_reward_frame_t3_visible = { check_variable = { wc_training_active = 1 } }
			wc_reward_icon_t3_visible  = { check_variable = { wc_training_active = 1 } }
			wc_reward_level_t3_visible = { check_variable = { wc_training_active = 1 } }

			# Each progress bar is "lit" when its corresponding phase has been paid.
			# Bar 1 lights at phase >= 1, bar 2 at phase >= 2, bar 3 at phase >= 3.
			wc_progress_fill_visible = {
				check_variable = { wc_training_phase > 0 }
			}
			wc_progress_fill_2_visible = {
				check_variable = { wc_training_phase > 1 }
			}
			wc_progress_fill_3_visible = {
				check_variable = { wc_training_phase > 2 }
			}

			# wc_track_name lives inside wc_track_panel - parent gate hides it.
			wc_track_name_visible = { check_variable = { wc_built = 1 } }

			# Right-side text blocks at the wc_main_inner level all need their
			# own academy-tab gate (parent isn't hidden, only sibling content
			# swaps). wc_status_text and wc_reward_text had no triggers
			# before - added below.
			wc_status_text_visible = {
				NOT = { has_country_flag = wc_academy_tab }
			}
			wc_reward_text_visible = {
				NOT = { has_country_flag = wc_academy_tab }
			}

			# Generic-blurb visible only on built+idle (no training, not constructing)
			wc_cost_text_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				NOT = { check_variable = { wc_construction_active = 1 } }
				NOT = { check_variable = { wc_training_active = 1 } }
			}

			# Construction countdown visible only while constructing
			wc_construction_text_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				check_variable = { wc_construction_active = 1 }
			}

			# Per-phase info: only one of these is visible at a time, and only
			# when a training is active. p0/p1/p2 show the cost for the next
			# Advance click. Phase 3 is split:
			#   p3_pending = final 30-day period running, mastery not yet granted
			#   p3         = cooldown ended, mastery running, awaiting Conclude
			wc_phase_info_p0_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				check_variable = { wc_training_active = 1 }
				check_variable = { wc_training_phase = 0 }
			}
			wc_phase_info_p1_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				check_variable = { wc_training_active = 1 }
				check_variable = { wc_training_phase = 1 }
			}
			wc_phase_info_p2_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				check_variable = { wc_training_active = 1 }
				check_variable = { wc_training_phase = 2 }
			}
			wc_phase_info_p3_pending_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				check_variable = { wc_training_active = 1 }
				check_variable = { wc_training_phase = 3 }
				check_variable = { wc_phase_cooldown_days > 0 }
			}
			wc_phase_info_p3_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				check_variable = { wc_training_active = 1 }
				check_variable = { wc_training_phase = 3 }
				check_variable = { wc_phase_cooldown_days < 1 }
			}

			# Doctrine-slot overlay (icon + name + phase pill) - shown only
			# when a training is assigned. The underlying advance/conclude
			# button stays clickable; these are decoration on top.
			wc_active_training_icon_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				check_variable = { wc_training_active = 1 }
			}
			wc_active_training_phase_pill_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				check_variable = { wc_training_active = 1 }
			}
			wc_active_training_name_text_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				check_variable = { wc_training_active = 1 }
			}

			# Action label below the slot - mutually exclusive across four states.
			# "Select" fires only when built+idle; "Advance" when actively
			# trainable (cooldown done, phase < 3); "Cooldown" while waiting on
			# any phase including the phase 3 final period; "Conclude" when
			# the final period has elapsed and mastery is active.
			wc_action_label_select_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				check_variable = { wc_built = 1 }
				NOT = { check_variable = { wc_training_active = 1 } }
			}
			wc_action_label_advance_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				check_variable = { wc_training_active = 1 }
				check_variable = { wc_training_phase < 3 }
				check_variable = { wc_phase_cooldown_days < 1 }
			}
			wc_action_label_cooldown_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				check_variable = { wc_training_active = 1 }
				check_variable = { wc_phase_cooldown_days > 0 }
			}
			wc_action_label_conclude_visible = {
				NOT = { has_country_flag = wc_academy_tab }
				check_variable = { wc_training_active = 1 }
				check_variable = { wc_training_phase = 3 }
				check_variable = { wc_phase_cooldown_days < 1 }
			}

		}

		properties = {
			# Light up reward frames as phases complete.
			# frame = 1 (locked) until that phase is paid; frame = 2 (active) once phase >= tier.
			wc_reward_frame_t1 = { frame = wc_reward_t1_frame }
			wc_reward_frame_t2 = { frame = wc_reward_t2_frame }
			wc_reward_frame_t3 = { frame = wc_reward_t3_frame }

			# Slide the construction bar sprite right as days remaining
			# decrease. wc_construction_bar_x is -377..0 (see on_daily).
			wc_construction_progress_bar = { x = wc_construction_bar_x }

			# Auto-advance checkbox - frame 1 = unchecked, frame 2 = checked.
			wc_checkmark_box_frame = { frame = wc_auto_advance_frame }

      wc_active_training_icon = {
        image = "[GetWcTrainingIcon]"
      }
		}

		ai_enabled = { always = no }
	}

	# ============================================================
	# ACADEMY VIEW
	# Targets the standalone wc_academy_window. Visibility gated on
	# wc_window_open AND wc_academy_tab; clearing wc_academy_tab
	# (via the War Games tab button) hides this window and reveals
	# wc_main_window.
	# ============================================================
	wc_academy_gui = {
		window_name = "wc_academy_window"
		context_type = player_context

		visible = {
			has_country_flag = wc_window_open
			has_country_flag = wc_academy_tab
		}

		effects = {
			# Close - mirrors wc_main_close_button: clear all WC flags so
			# the window stays closed on next open.
			wc_academy_main_close_button_click = {
				clr_country_flag = wc_window_open
				clr_country_flag = wc_picker_open
				clr_country_flag = wc_academy_tab
				clr_country_flag = wc_headmaster_picker_open
				clr_country_flag = wc_officer_picker_open
			}

			# Tab swap - clearing the academy_tab flag hides this window
			# and reveals wc_main_window (which gates on NOT academy_tab).
			wc_academy_tab_war_games_click = {
				clr_country_flag = wc_academy_tab
			}
			# Currently-active tab - no-op on click (already on this tab).
			wc_academy_tab_academy_click = { }

			# Faculty pickers
			wc_academy_headmaster_button_click = {
				wc_open_headmaster_picker_effect = yes
			}
			wc_academy_officer_1_button_click = {
				set_variable = { wc_officer_target_slot = 1 }
				wc_open_officer_picker_effect = yes
			}
			wc_academy_officer_2_button_click = {
				set_variable = { wc_officer_target_slot = 2 }
				wc_open_officer_picker_effect = yes
			}
			wc_academy_officer_3_button_click = {
				set_variable = { wc_officer_target_slot = 3 }
				wc_open_officer_picker_effect = yes
			}

			# Training tier upgrades. Each click sets wc_pending_upgrade_id
			# then calls the dispatcher. Variable-based dispatch is used
			# because parameterized scripted_effects ({ ID = N } syntax)
			# aren't accepted inside scripted_gui effect blocks.
			wc_academy_inf_tier_button_click = {
				set_variable = { wc_pending_upgrade_id = 1 }
				wc_start_upgrade_effect = yes
			}
			wc_academy_art_tier_button_click = {
				set_variable = { wc_pending_upgrade_id = 4 }
				wc_start_upgrade_effect = yes
			}
			wc_academy_arm_tier_button_click = {
				set_variable = { wc_pending_upgrade_id = 7 }
				wc_start_upgrade_effect = yes
			}
			wc_academy_ops_tier_button_click = {
				set_variable = { wc_pending_upgrade_id = 10 }
				wc_start_upgrade_effect = yes
			}

			# Placeholder slots - currently no-ops, click_enabled = no
			# below keeps them visible-but-greyed.
			wc_academy_inf_slot2_button_click = { }
			wc_academy_inf_slot3_button_click = { }
			wc_academy_art_slot2_button_click = { }
			wc_academy_art_slot3_button_click = { }
			wc_academy_arm_slot2_button_click = { }
			wc_academy_arm_slot3_button_click = { }
			wc_academy_ops_slot2_button_click = { }
			wc_academy_ops_slot3_button_click = { }

			# Academy global upgrades
			wc_academy_unlock_slots_button_click = {
				set_variable = { wc_pending_upgrade_id = 13 }
				wc_start_upgrade_effect = yes
			}
			wc_academy_unlock_spirit_button_click = {
				set_variable = { wc_pending_upgrade_id = 14 }
				wc_start_upgrade_effect = yes
			}
			wc_academy_unlock_theorist_button_click = {
				set_variable = { wc_pending_upgrade_id = 15 }
				wc_start_upgrade_effect = yes
			}
			wc_academy_speed_upgrade_button_click = {
				set_variable = { wc_pending_upgrade_id = 16 }
				wc_start_upgrade_effect = yes
			}
		}

		triggers = {
			# Tab buttons always visible inside the academy window.
			wc_academy_tab_war_games_visible = { always = yes }
			wc_academy_tab_academy_visible = { always = yes }

			# Banner: one or the other depending on whether an upgrade
			# is running. Mutually exclusive.
			wc_academy_active_upgrade_text_visible = {
				check_variable = { wc_active_upgrade_id > 0 }
			}
			wc_academy_idle_banner_text_visible = {
				check_variable = { wc_active_upgrade_id = 0 }
			}

			# Tier upgrade buttons: enabled when no upgrade is running
			# AND the track's current tier is below 3. Visible always.
			wc_academy_inf_tier_button_click_enabled = {
				check_variable = { wc_active_upgrade_id = 0 }
				check_variable = { wc_infantry_tier < 3 }
			}
			wc_academy_art_tier_button_click_enabled = {
				check_variable = { wc_active_upgrade_id = 0 }
				check_variable = { wc_artillery_tier < 3 }
			}
			wc_academy_arm_tier_button_click_enabled = {
				check_variable = { wc_active_upgrade_id = 0 }
				check_variable = { wc_armor_tier < 3 }
			}
			wc_academy_ops_tier_button_click_enabled = {
				check_variable = { wc_active_upgrade_id = 0 }
				check_variable = { wc_operational_tier < 3 }
			}

			# Placeholder slot buttons - visible but always disabled.
			wc_academy_inf_slot2_button_click_enabled = { always = no }
			wc_academy_inf_slot3_button_click_enabled = { always = no }
			wc_academy_art_slot2_button_click_enabled = { always = no }
			wc_academy_art_slot3_button_click_enabled = { always = no }
			wc_academy_arm_slot2_button_click_enabled = { always = no }
			wc_academy_arm_slot3_button_click_enabled = { always = no }
			wc_academy_ops_slot2_button_click_enabled = { always = no }
			wc_academy_ops_slot3_button_click_enabled = { always = no }

			# Academy globals - one-shot unlocks; speed_level repeats up to 3.
			wc_academy_unlock_slots_button_click_enabled = {
				check_variable = { wc_active_upgrade_id = 0 }
				NOT = { check_variable = { wc_academy_slots_unlocked = 1 } }
			}
			wc_academy_unlock_spirit_button_click_enabled = {
				check_variable = { wc_active_upgrade_id = 0 }
				NOT = { check_variable = { wc_academy_spirit_unlocked = 1 } }
			}
			wc_academy_unlock_theorist_button_click_enabled = {
				check_variable = { wc_active_upgrade_id = 0 }
				NOT = { check_variable = { wc_academy_theorist_unlocked = 1 } }
			}
			wc_academy_speed_upgrade_button_click_enabled = {
				check_variable = { wc_active_upgrade_id = 0 }
				check_variable = { wc_academy_speed_level < 3 }
			}
		}

		ai_enabled = { always = no }
	}

	# ============================================================
	# TRAINING PICKER
	# Visible when wc_picker_open flag is set.
	# Four T1 trainings wired up; extend by copying a row block
	# in the .gui plus its assign effect / scripted_loc / yml entry.
	# ============================================================

	wc_picker_gui = {
		window_name = "wc_picker_window"
		context_type = player_context

		visible = {
			has_country_flag = wc_picker_open
		}

		effects = {
			wc_picker_close_button_click = {
				clr_country_flag = wc_picker_open
			}

			wc_picker_t1_infantry_studies_assign_button_click = {
				wc_assign_t1_infantry_studies_effect = yes
			}
			wc_picker_t1_artillery_support_studies_assign_button_click = {
				wc_assign_t1_artillery_support_studies_effect = yes
			}
			wc_picker_t1_armor_studies_assign_button_click = {
				wc_assign_t1_armor_studies_effect = yes
			}
			wc_picker_t1_operational_studies_assign_button_click = {
				wc_assign_t1_operational_studies_effect = yes
			}
		}

		triggers = {
			# Common gating across all picker rows: college built, no active
			# training, 50 XP available. Per-training equipment requirements
			# are not pre-checked at assign time - they're checked at each
			# advance click via the cooldown + button gating loop.
			wc_picker_t1_infantry_studies_assign_button_click_enabled = {
				check_variable = { wc_built = 1 }
				NOT = { check_variable = { wc_training_active = 1 } }
				has_army_experience > 49
			}
			wc_picker_t1_artillery_support_studies_assign_button_click_enabled = {
				check_variable = { wc_built = 1 }
				NOT = { check_variable = { wc_training_active = 1 } }
				has_army_experience > 49
			}
			wc_picker_t1_armor_studies_assign_button_click_enabled = {
				check_variable = { wc_built = 1 }
				NOT = { check_variable = { wc_training_active = 1 } }
				has_army_experience > 49
			}
			wc_picker_t1_operational_studies_assign_button_click_enabled = {
				check_variable = { wc_built = 1 }
				NOT = { check_variable = { wc_training_active = 1 } }
				has_army_experience > 49
			}
		}

		ai_enabled = { always = no }
	}

	# ============================================================
	# HEADMASTER PICKER
	# Visible when wc_headmaster_picker_open flag is set. The
	# wc_academy_leaders_array is populated at open time with every
	# army leader of the player country. Each gridbox entry is
	# scoped to one character via the dynamic_lists block; clicking
	# the assign button sets wc_headmaster_id to that character.
	# ============================================================
	wc_headmaster_picker_gui = {
		window_name = "wc_headmaster_picker_window"
		context_type = player_context

		visible = {
			has_country_flag = wc_headmaster_picker_open
		}

		effects = {
			wc_headmaster_picker_close_button_click = {
				wc_close_headmaster_picker_effect = yes
			}

			# Dismiss the current headmaster - clears the assignment.
			# Picker stays open so the player can pick a replacement
			# without re-opening; the close button cleans up if not.
			wc_headmaster_dismiss_button_click = {
				wc_dismiss_headmaster_effect = yes
			}

			# Assign the row's character. wc_headmaster_pick_value is
			# the loop variable named in the dynamic_lists block below.
			# Because dynamic_lists has change_scope = yes, this click
			# fires inside character scope - so the country-scope
			# set_variable inside the assign effect needs ROOT to land
			# the variable on the country, not the character.
			wc_headmaster_picker_entry_assign_button_click = {
				ROOT = {
					wc_assign_headmaster_effect = yes
				}
			}
		}

		triggers = {
			wc_headmaster_dismiss_button_click_enabled = {
				has_variable = wc_headmaster_id
			}
		}

		dynamic_lists = {
			wc_headmaster_picker_gridbox = {
				array = ROOT.wc_academy_leaders_array
				value = wc_headmaster_pick_value
				index = wc_headmaster_pick_index
				change_scope = yes
				entry_container = wc_headmaster_picker_entry
			}
		}

		ai_enabled = { always = no }
	}

	# ============================================================
	# OFFICER PICKER
	# Same pattern as the headmaster picker. The slot being filled
	# is in wc_officer_target_slot, set at open time by whichever
	# slot button was clicked (1, 2, or 3).
	# ============================================================
	wc_officer_picker_gui = {
		window_name = "wc_officer_picker_window"
		context_type = player_context

		visible = {
			has_country_flag = wc_officer_picker_open
		}

		effects = {
			wc_officer_picker_close_button_click = {
				wc_close_officer_picker_effect = yes
			}

			wc_officer_dismiss_button_click = {
				wc_dismiss_officer_effect = yes
			}

			# ROOT wrapping is required - dynamic_lists has change_scope =
			# yes, so this click fires in character scope. The assign
			# effect needs country scope to set country variables.
			wc_officer_picker_entry_assign_button_click = {
				ROOT = {
					wc_assign_officer_effect = yes
				}
			}
		}

		triggers = {
			# Dismiss enabled only if the targeted slot currently holds someone.
			wc_officer_dismiss_button_click_enabled = {
				OR = {
					AND = { check_variable = { wc_officer_target_slot = 1 } has_variable = wc_officer_1_id }
					AND = { check_variable = { wc_officer_target_slot = 2 } has_variable = wc_officer_2_id }
					AND = { check_variable = { wc_officer_target_slot = 3 } has_variable = wc_officer_3_id }
				}
			}
		}

		dynamic_lists = {
			wc_officer_picker_gridbox = {
				array = ROOT.wc_academy_leaders_array
				value = wc_officer_pick_value
				index = wc_officer_pick_index
				change_scope = yes
				entry_container = wc_officer_picker_entry
			}
		}

		ai_enabled = { always = no }
	}
}
