# =============================================================================
# Giga + Age of Wonder Compatibility Patch — megastructure-filter bar events
# Shows the persistent on-screen filter button (custom_gui = compat_megatab_bar)
# for each human player, on game start and on save load. Mirrors AoW's own
# custom_gui-via-diplomatic-event pattern (cf. AOW_core.100).
# =============================================================================
namespace = compat_megatab

# Hub: fan out to all human players. Scopeless, fired from on_actions.
event = {
	id = compat_megatab.0
	hide_window = yes
	is_triggered_only = yes
	immediate = {
		every_country = {
			limit = { is_ai = no }
			country_event = { id = compat_megatab.1 }
		}
	}
}

# Persistent filter bar, one per human player.
country_event = {
	id = compat_megatab.1
	title = compat_megatab.1.t
	desc = compat_megatab.1.d
	picture = GFX_evt_megastructure_construction
	is_triggered_only = yes
	diplomatic = yes
	custom_gui = "compat_megatab_bar"
	force_open = yes
	trigger = {
		is_ai = no
		NOT = { has_active_event = { compat_megatab.1 } }
	}
	# Single option exists only for engine validity; if the window is ever closed
	# it re-opens shortly after, so the bar can't be lost (use the edict to hide it).
	option = {
		name = compat_megatab.1.a
		hidden_effect = { country_event = { id = compat_megatab.1 days = 1 } }
	}
}
