d_eu4_style_ideas_console_commands = {
	log = D_EU4_STYLE_IDEAS_CONSOLE_COMMANDS_TT_1
	log = "   - eu4_style_ideas_console_commands"
	log = "   - unlock_all_idea_slots"
	log = "   - lock_all_idea_slots_as_normal"
	log = "   - select_idea_group"
	log = "   - remove_idea_group"
	log = "   - swap_national_idea_group"
	log = "   - open_window_for_ni_choice"
	log = "   - set_position_idea_open_button"
	log = D_EU4_STYLE_IDEAS_CONSOLE_COMMANDS_TT_2
}

d_unlock_all_idea_slots = {
	log = D_UNLOCK_ALL_IDEA_SLOTS_TT
	set_global_flag = eu4_like_ideas_test_flag
	update_main_ideas_window = yes
	refresh_eu4_like_alerts = yes
}

d_lock_all_idea_slots_as_normal = {
	log = D_LOCK_ALL_IDEA_SLOTS_AS_NORMAL_TT
	clr_global_flag = eu4_like_ideas_test_flag
	update_main_ideas_window = yes
	refresh_eu4_like_alerts = yes
}

d_select_idea_group = {
	FROM = {
		if = {
			limit = {
				check_variable = { args^num = 1 }
			}
			set_temp_variable = { v = args^0 }
			if = {
				limit = {
					NOT = { is_in_array = { selected_idea_groups = v } }
				}
				if = {
					limit = {
						check_variable = { v > 0 }
						OR = {
							is_in_array = { adm_idea_groups = v }
							is_in_array = { dip_idea_groups = v }
							is_in_array = { mil_idea_groups = v }
						}
						can_select_any_idea_group = yes
						set_temp_variable = { num_of_selected_adm = 9 }
						subtract_from_temp_variable = { num_of_selected_adm = adm_idea_groups^num }
						set_temp_variable = { num_of_selected_dip = 9 }
						subtract_from_temp_variable = { num_of_selected_dip = dip_idea_groups^num }
						set_temp_variable = { num_of_selected_mil = 9 }
						subtract_from_temp_variable = { num_of_selected_mil = mil_idea_groups^num }
						set_temp_variable = { total_num_of_selected_ideas = num_of_selected_adm }
						add_to_temp_variable = { total_num_of_selected_ideas = num_of_selected_dip }
						add_to_temp_variable = { total_num_of_selected_ideas = num_of_selected_mil }
						divide_temp_variable = { total_num_of_selected_ideas = 2 }
						OR = {
							has_global_flag = eu4_like_ideas_test_flag
							has_global_flag = eu4_like_ideas_limit_for_idea_groups_from_same_type_disabled
							AND = {
								OR = {
									check_variable = { v = 1 }
									check_variable = { v = 2 }
									check_variable = { v = 3 }
									check_variable = { v = 4 }
									check_variable = { v = 5 }
									check_variable = { v = 6 }
									check_variable = { v = 19 }
									check_variable = { v = 22 }
									check_variable = { v = 25 }
								}
								OR = {
									check_variable = { num_of_selected_adm = 0 }
									check_variable = { var = total_num_of_selected_ideas value = num_of_selected_adm compare = greater_than_or_equals }
								}
							}
							AND = {
								OR = {
									check_variable = { v = 7 }
									check_variable = { v = 8 }
									check_variable = { v = 9 }
									check_variable = { v = 10 }
									check_variable = { v = 11 }
									check_variable = { v = 12 }
									check_variable = { v = 20 }
									check_variable = { v = 23 }
									check_variable = { v = 26 }
								}
								OR = {
									check_variable = { num_of_selected_dip = 0 }
									check_variable = { var = total_num_of_selected_ideas value = num_of_selected_dip compare = greater_than_or_equals }
								}
							}
							AND = {
								OR = {
									check_variable = { v = 13 }
									check_variable = { v = 14 }
									check_variable = { v = 15 }
									check_variable = { v = 16 }
									check_variable = { v = 17 }
									check_variable = { v = 18 }
									check_variable = { v = 21 }
									check_variable = { v = 24 }
									check_variable = { v = 27 }
								}
								OR = {
									check_variable = { num_of_selected_mil = 0 }
									check_variable = { var = total_num_of_selected_ideas value = num_of_selected_mil compare = greater_than_or_equals }
								}
							}
						}
					}
					log = D_SELECT_IDEA_GROUP_TT
					select_idea_group_effect = yes
				}
				else = {
					log = D_SELECT_IDEA_GROUP_TT_CANT_SELECT_IDEA
				}
			}
			else = {
				log = D_SELECT_IDEA_GROUP_TT_CANT_SELECT_IDEA_ALREADY_SELECTED
			}
		}
		else = {
			log = D_SELECT_IDEA_GROUP_TT_INVALID_ARGUMENTS
		}
	}
}

d_remove_idea_group = {
	FROM = {
		if = {
			limit = {
				check_variable = { args^num = 1 }
			}
			set_temp_variable = { v = args^0 }
			if = {
				limit = {
					is_in_array = { selected_idea_groups = v }
				}
				if = {
					limit = {
						check_variable = { v > 0 }
					}
					log = D_REMOVE_IDEA_GROUP_TT
					remove_idea_group_effect = yes
				}
			}
			else = {
				log = D_REMOVE_IDEA_GROUP_TT_CANT_REMOVE_IDEA
			}
		}
		else = {
			log = D_REMOVE_IDEA_GROUP_TT_INVALID_ARGUMENTS
		}
	}
}

d_swap_national_idea_group = {
	FROM = {
		if = {
			limit = {
				check_variable = { args^0 = 0 }
			}
			swap_national_ideas_effect = yes
		}
		else = {
			if = {
				limit = {
					NOT = { check_variable = { national_ideas_id = 0 } }
				}
				calculate_progress_of_national_ideas = yes
				clear_national_ideas = yes
				if = {
					limit = {
						NOT = { check_variable = { national_ideas_id = 1000 } }
						NOT = { has_country_flag = swap_to_previous_national_ideas }
					}
					set_variable = { previous_national_ideas_id = national_ideas_id }
				}
			}
			set_variable = { national_ideas_id = args^0 }
			complete_national_idea_0 = yes
			calculate_progress_of_national_ideas = yes
		}
		log = D_SWAP_NATIONAL_IDEA_GROUP_TT
	}
}

d_open_window_for_ni_choice = {
	FROM = {
		if = {
			limit = {
				is_ai = no
			}
			set_variable = { show_eu4_like_ideas_custom_national_ideas_window = 1 }
			clr_country_flag = selected_custom_national_idea_group
		}
		log = D_OPEN_WINDOW_FOR_NI_CHOICE_TT
	}
}

d_set_position_idea_open_button = {
	FROM = {
		set_variable = { eu4_style_ideas_open_button_x = args^0 }
		if = {
			limit = {
				check_variable = { eu4_style_ideas_open_button_x = 0 }
			}
			clear_variable = eu4_style_ideas_open_button_x
		}
		log = D_SET_POSITION_IDEA_OPEN_BUTTON_TT
	}
}