﻿# Setup on game start
on_game_started_after_lobby = {
	on_actions = {
		com_topbar_setup
	}
}

# Adding base game elements if they are missing
on_monthly_pulse = {
	on_actions = {
		com_topbar_setup
	}
}

# Adding base game elements if they are missing
com_topbar_setup = {
	effect = {
		every_country = {
			limit = {
				# We only need to do it for player countries
				is_player = yes
			}

            com_topbar_calculate_subsistence_pops = yes

			#= Prestige
			if = {
				limit = {
					NOT = {
						any_in_global_list = {
							variable = com_topbar_items
							this = flag:com_topbar_element_prestige
						}
					}
				}
				add_com_topbar_element = {
					element_name = com_topbar_element_prestige
				}
				every_country = {
					add_to_variable_list = {
						name = com_topbar_first_line
						target = scope:com_topbar_element_prestige
					}
				}
			}
			#= Power Bloc Prestige
			if = {
				limit = {
					NOT = {
						any_in_global_list = {
							variable = com_topbar_items
							this = flag:com_topbar_element_bloc_prestige
						}
					}
				}
				add_com_topbar_element = {
					element_name = com_topbar_element_bloc_prestige
				}
			}
			#= Power Bloc Cohesion
			if = {
				limit = {
					NOT = {
						any_in_global_list = {
							variable = com_topbar_items
							this = flag:com_topbar_element_bloc_cohesion
						}
					}
				}
				add_com_topbar_element = {
					element_name = com_topbar_element_bloc_cohesion
				}
			}
			#= Power Bloc Size
			if = {
				limit = {
					NOT = {
						any_in_global_list = {
							variable = com_topbar_items
							this = flag:com_topbar_element_bloc_size
						}
					}
				}
				add_com_topbar_element = {
					element_name = com_topbar_element_bloc_size
				}
			}
			#= Legitimacy
			if = {
				limit = {
					NOT = {
						any_in_global_list = {
							variable = com_topbar_items
							this = flag:com_topbar_element_legitimacy
						}
					}
				}
				add_com_topbar_element = {
					element_name = com_topbar_element_legitimacy
				}
				every_country = {
					add_to_variable_list = {
						name = com_topbar_first_line
						target = scope:com_topbar_element_legitimacy
					}
				}
			}
			#= Innovation
			if = {
				limit = {
					NOT = {
						any_in_global_list = {
							variable = com_topbar_items
							this = flag:com_topbar_element_innovation
						}
					}
				}
				add_com_topbar_element = {
					element_name = com_topbar_element_innovation
				}
				every_country = {
					add_to_variable_list = {
						name = com_topbar_first_line
						target = scope:com_topbar_element_innovation
					}
				}
			}
			#= Companies
			if = {
				limit = {
					NOT = {
						any_in_global_list = {
							variable = com_topbar_items
							this = flag:com_topbar_element_companies
						}
					}
				}
				add_com_topbar_element = {
					element_name = com_topbar_element_companies
				}
			}
			#= Charters
			if = {
				limit = {
					NOT = {
						any_in_global_list = {
							variable = com_topbar_items
							this = flag:com_topbar_element_charters
						}
					}
				}
				add_com_topbar_element = {
					element_name = com_topbar_element_charters
				}
			}
			#= Army Size
			if = {
				limit = {
					NOT = {
						any_in_global_list = {
							variable = com_topbar_items
							this = flag:com_topbar_element_army_size
						}
					}
				}
				add_com_topbar_element = {
					element_name = com_topbar_element_army_size
				}
				every_country = {
					add_to_variable_list = {
						name = com_topbar_first_line
						target = scope:com_topbar_element_army_size
					}
				}
			}
			#= Navy Size
			if = {
				limit = {
					NOT = {
						any_in_global_list = {
							variable = com_topbar_items
							this = flag:com_topbar_element_navy_size
						}
					}
				}
				add_com_topbar_element = {
					element_name = com_topbar_element_navy_size
				}
				every_country = {
					add_to_variable_list = {
						name = com_topbar_first_line
						target = scope:com_topbar_element_navy_size
					}
				}
			}
			#= Interests
			if = {
				limit = {
					NOT = {
						any_in_global_list = {
							variable = com_topbar_items
							this = flag:com_topbar_element_interests
						}
					}
				}
				add_com_topbar_element = {
					element_name = com_topbar_element_interests
				}
				every_country = {
					add_to_variable_list = {
						name = com_topbar_first_line
						target = scope:com_topbar_element_interests
					}
				}
			}
			#= Unemployed
			if = {
				limit = {
					NOT = {
						any_in_global_list = {
							variable = com_topbar_items
							this = flag:com_topbar_element_unemployed_pops
						}
					}
				}
				add_com_topbar_element = {
					element_name = com_topbar_element_unemployed_pops
				}
			}
			#= Subsistence
			if = {
				limit = {
					NOT = {
						any_in_global_list = {
							variable = com_topbar_items
							this = flag:com_topbar_element_subsistence_pops
						}
					}
				}
				add_com_topbar_element = {
					element_name = com_topbar_element_subsistence_pops
				}
				every_country = {
					add_to_variable_list = {
						name = com_topbar_first_line
						target = scope:com_topbar_element_subsistence_pops
					}
				}
			}
			#= Unrealized Taxes
			if = {
				limit = {
					NOT = {
						any_in_global_list = {
							variable = com_topbar_items
							this = flag:com_topbar_element_unrealized_taxes
						}
					}
				}
				add_com_topbar_element = {
					element_name = com_topbar_element_unrealized_taxes
				}
			}
			#= Agitators
			if = {
				limit = {
					NOT = {
						any_in_global_list = {
							variable = com_topbar_items
							this = flag:com_topbar_element_agitators
						}
					}
				}
				add_com_topbar_element = {
					element_name = com_topbar_element_agitators
				}
			}
			#= Market Balance
			if = {
				limit = {
					NOT = {
						any_in_global_list = {
							variable = com_topbar_items
							this = flag:com_topbar_element_market_balance
						}
					}
				}
				add_com_topbar_element = {
					element_name = com_topbar_element_market_balance
				}
			}
			#= Market GDP
			if = {
				limit = {
					NOT = {
						any_in_global_list = {
							variable = com_topbar_items
							this = flag:com_topbar_element_market_gdp
						}
					}
				}
				add_com_topbar_element = {
					element_name = com_topbar_element_market_gdp
				}
			}
			#= Trade Capacity
			if = {
				limit = {
					NOT = {
						any_in_global_list = {
							variable = com_topbar_items
							this = flag:com_topbar_element_trade_capacity
						}
					}
				}
				add_com_topbar_element = {
					element_name = com_topbar_element_trade_capacity
				}
			}
		}
	}
}