scripted_gui = {

	mst_C_main_container = {
	
		context_type = selected_country_context
		
		window_name = "mst_C_main_container"
		
		visible = {
			ROOT = {
				is_ai = no
				has_global_flag = mst_C_enabled
				OR = {
					has_country_flag = tp_is_host
					NOT = {
						has_global_flag = tp_is_multiplayer
					}
				}
			}
		}

		effects = {
			mst_help_button_click = {
				ROOT = { country_event = toolpack.5 }
			}
			mst_marker_click = {
				set_country_flag = mst_marked
			}
			mst_unmarker_click = {
				clr_country_flag = mst_marked
			}
			mst_unmark_all_click = {
				every_country = {
					clr_country_flag = mst_marked
				}
			}
			mst_select_country_off_click = {
				clr_global_flag = mst_variable_C1_enabled
				clr_global_flag = mst_variable_C2_enabled
			}
			mst_select_variable_1_off_click = {
				set_global_flag = mst_variable_C1_enabled
				clr_global_flag = mst_variable_C2_enabled
			}
			mst_select_variable_2_off_click = {
				set_global_flag = mst_variable_C2_enabled
				clr_global_flag = mst_variable_C1_enabled
			}
			mst_add_1_click = {
				if = {
					limit = {
						NOT = {
							OR = {
								has_global_flag = mst_variable_C1_enabled
								has_global_flag = mst_variable_C2_enabled
							}
						}
					}
					toolpack_cycle_action_log_variables = yes
					add_to_array = { global.toolpack_mp_action_array_targets = THIS }
					add_to_array = { global.toolpack_mp_action_array = 16 }
					if = {
						limit = {
							any_country = { has_country_flag = mst_marked }
						}
						every_country = {
							limit = { has_country_flag = mst_marked }
							add_manpower = 1000
						}
					}
					if = {
						limit = {
							all_country = {
								NOT = { has_country_flag = mst_marked }
							}
						}
						add_manpower = 1000
					}
				}
				if = {
					limit = { has_global_flag = mst_variable_C1_enabled }
					add_to_variable = { global.mst_variable_C1 = 1000 }
					mst_reformat_variables = yes
				}
				if = {
					limit = { has_global_flag = mst_variable_C2_enabled }
					add_to_variable = { global.mst_variable_C2 = 1000 }
					mst_reformat_variables = yes
				}
			}
			mst_add_10_click = {
				if = {
					limit = {
						NOT = {
							OR = {
								has_global_flag = mst_variable_C1_enabled
								has_global_flag = mst_variable_C2_enabled
							}
						}
					}
					toolpack_cycle_action_log_variables = yes
					add_to_array = { global.toolpack_mp_action_array_targets = THIS }
					add_to_array = { global.toolpack_mp_action_array = 16 }
					if = {
						limit = {
							any_country = { has_country_flag = mst_marked }
						}
						every_country = {
							limit = { has_country_flag = mst_marked }
							add_manpower = 10000
						}
					}
					if = {
						limit = {
							all_country = {
								NOT = { has_country_flag = mst_marked }
							}
						}
						add_manpower = 10000
					}
				}
				if = {
					limit = { has_global_flag = mst_variable_C1_enabled }
					add_to_variable = { global.mst_variable_C1 = 10000 }
					mst_reformat_variables = yes
				}
				if = {
					limit = { has_global_flag = mst_variable_C2_enabled }
					add_to_variable = { global.mst_variable_C2 = 10000 }
					mst_reformat_variables = yes
				}
			}
			mst_add_100_click = {
				if = {
					limit = {
						NOT = {
							OR = {
								has_global_flag = mst_variable_C1_enabled
								has_global_flag = mst_variable_C2_enabled
							}
						}
					}
					toolpack_cycle_action_log_variables = yes
					add_to_array = { global.toolpack_mp_action_array_targets = THIS }
					add_to_array = { global.toolpack_mp_action_array = 16 }
					if = {
						limit = {
							any_country = { has_country_flag = mst_marked }
						}
						every_country = {
							limit = { has_country_flag = mst_marked }
							add_manpower = 100000
						}
					}
					if = {
						limit = {
							all_country = {
								NOT = { has_country_flag = mst_marked }
							}
						}
						add_manpower = 100000
					}
				}
				if = {
					limit = { has_global_flag = mst_variable_C1_enabled }
					add_to_variable = { global.mst_variable_C1 = 100000 }
					mst_reformat_variables = yes
				}
				if = {
					limit = { has_global_flag = mst_variable_C2_enabled }
					add_to_variable = { global.mst_variable_C2 = 100000 }
					mst_reformat_variables = yes
				}
			}
			mst_add_1000_click = {
				if = {
					limit = {
						NOT = {
							OR = {
								has_global_flag = mst_variable_C1_enabled
								has_global_flag = mst_variable_C2_enabled
							}
						}
					}
					toolpack_cycle_action_log_variables = yes
					add_to_array = { global.toolpack_mp_action_array_targets = THIS }
					add_to_array = { global.toolpack_mp_action_array = 16 }
					if = {
						limit = {
							any_country = { has_country_flag = mst_marked }
						}
						every_country = {
							limit = { has_country_flag = mst_marked }
							add_manpower = 1000000
						}
					}
					if = {
						limit = {
							all_country = {
								NOT = { has_country_flag = mst_marked }
							}
						}
						add_manpower = 1000000
					}
				}
				if = {
					limit = { has_global_flag = mst_variable_C1_enabled }
					add_to_variable = { global.mst_variable_C1 = 1000000 }
					mst_reformat_variables = yes
				}
				if = {
					limit = { has_global_flag = mst_variable_C2_enabled }
					add_to_variable = { global.mst_variable_C2 = 1000000 }
					mst_reformat_variables = yes
				}
			}
			mst_sub_1_click = {
				if = {
					limit = {
						NOT = {
							OR = {
								has_global_flag = mst_variable_C1_enabled
								has_global_flag = mst_variable_C2_enabled
							}
						}
					}
					toolpack_cycle_action_log_variables = yes
					add_to_array = { global.toolpack_mp_action_array_targets = THIS }
					add_to_array = { global.toolpack_mp_action_array = 16 }
					if = {
						limit = {
							any_country = { has_country_flag = mst_marked }
						}
						every_country = {
							limit = { has_country_flag = mst_marked }
							add_manpower = -1000
						}
					}
					if = {
						limit = {
							all_country = {
								NOT = { has_country_flag = mst_marked }
							}
						}
						add_manpower = -1000
					}
				}
				if = {
					limit = { has_global_flag = mst_variable_C1_enabled }
					subtract_from_variable = { global.mst_variable_C1 = 1000 }
					mst_reformat_variables = yes
				}
				if = {
					limit = { has_global_flag = mst_variable_C2_enabled }
					subtract_from_variable = { global.mst_variable_C2 = 1000 }
					mst_reformat_variables = yes
				}
			}
			mst_sub_10_click = {
				if = {
					limit = {
						NOT = {
							OR = {
								has_global_flag = mst_variable_C1_enabled
								has_global_flag = mst_variable_C2_enabled
							}
						}
					}
					toolpack_cycle_action_log_variables = yes
					add_to_array = { global.toolpack_mp_action_array_targets = THIS }
					add_to_array = { global.toolpack_mp_action_array = 16 }
					if = {
						limit = {
							any_country = { has_country_flag = mst_marked }
						}
						every_country = {
							limit = { has_country_flag = mst_marked }
							add_manpower = -10000
						}
					}
					if = {
						limit = {
							all_country = {
								NOT = { has_country_flag = mst_marked }
							}
						}
						add_manpower = -10000
					}
				}
				if = {
					limit = { has_global_flag = mst_variable_C1_enabled }
					subtract_from_variable = { global.mst_variable_C1 = 10000 }
					mst_reformat_variables = yes
				}
				if = {
					limit = { has_global_flag = mst_variable_C2_enabled }
					subtract_from_variable = { global.mst_variable_C2 = 10000 }
					mst_reformat_variables = yes
				}
			}
			mst_sub_100_click = {
				if = {
					limit = {
						NOT = {
							OR = {
								has_global_flag = mst_variable_C1_enabled
								has_global_flag = mst_variable_C2_enabled
							}
						}
					}
					toolpack_cycle_action_log_variables = yes
					add_to_array = { global.toolpack_mp_action_array_targets = THIS }
					add_to_array = { global.toolpack_mp_action_array = 16 }
					if = {
						limit = {
							any_country = { has_country_flag = mst_marked }
						}
						every_country = {
							limit = { has_country_flag = mst_marked }
							add_manpower = -100000
						}
					}
					if = {
						limit = {
							all_country = {
								NOT = { has_country_flag = mst_marked }
							}
						}
						add_manpower = -100000
					}
				}
				if = {
					limit = { has_global_flag = mst_variable_C1_enabled }
					subtract_from_variable = { global.mst_variable_C1 = 100000 }
					mst_reformat_variables = yes
				}
				if = {
					limit = { has_global_flag = mst_variable_C2_enabled }
					subtract_from_variable = { global.mst_variable_C2 = 100000 }
					mst_reformat_variables = yes
				}
			}
			mst_sub_1000_click = {
				if = {
					limit = {
						NOT = {
							OR = {
								has_global_flag = mst_variable_C1_enabled
								has_global_flag = mst_variable_C2_enabled
							}
						}
					}
					toolpack_cycle_action_log_variables = yes
					add_to_array = { global.toolpack_mp_action_array_targets = THIS }
					add_to_array = { global.toolpack_mp_action_array = 16 }
					if = {
						limit = {
							any_country = { has_country_flag = mst_marked }
						}
						every_country = {
							limit = { has_country_flag = mst_marked }
							add_manpower = -1000000
						}
					}
					if = {
						limit = {
							all_country = {
								NOT = { has_country_flag = mst_marked }
							}
						}
						add_manpower = -1000000
					}
				}
				if = {
					limit = { has_global_flag = mst_variable_C1_enabled }
					subtract_from_variable = { global.mst_variable_C1 = 1000000 }
					mst_reformat_variables = yes
				}
				if = {
					limit = { has_global_flag = mst_variable_C2_enabled }
					subtract_from_variable = { global.mst_variable_C2 = 1000000 }
					mst_reformat_variables = yes
				}
			}
			mst_add_variable_C_click = {
				toolpack_cycle_action_log_variables = yes
				add_to_array = { global.toolpack_mp_action_array_targets = THIS }
				add_to_array = { global.toolpack_mp_action_array = 16 }
				if = {
					limit = { has_global_flag = mst_variable_C1_enabled }
					if = {
						limit = {
							any_country = { has_country_flag = mst_marked }
						}
						every_country = {
							limit = { has_country_flag = mst_marked }
							add_manpower = global.mst_variable_C1
						}
					}
					if = {
						limit = {
							all_country = {
								NOT = { has_country_flag = mst_marked }
							}
						}
						add_manpower = global.mst_variable_C1
					}
					
				}
				if = {
					limit = { has_global_flag = mst_variable_C2_enabled }
					if = {
						limit = {
							any_country = { has_country_flag = mst_marked }
						}
						every_country = {
							limit = { has_country_flag = mst_marked }
							add_manpower = global.mst_variable_C2
						}
					}
					if = {
						limit = {
							all_country = {
								NOT = { has_country_flag = mst_marked }
							}
						}
						add_manpower = global.mst_variable_C2
					}
					
				}
			}
			mst_sub_variable_C_click = {
				toolpack_cycle_action_log_variables = yes
				add_to_array = { global.toolpack_mp_action_array_targets = THIS }
				add_to_array = { global.toolpack_mp_action_array = 16 }
				if = {
					limit = {
						any_country = { has_country_flag = mst_marked }
					}
					every_country = {
						limit = { has_country_flag = mst_marked }
						if = {
							limit = { has_global_flag = mst_variable_C1_enabled }
							set_variable = { global.mst_subber_variable = global.mst_variable_C1 }
							multiply_variable = { global.mst_subber_variable = -1 }
							add_manpower = global.mst_subber_variable
						}
						if = {
							limit = { has_global_flag = mst_variable_C2_enabled }
							set_variable = { global.mst_subber_variable = global.mst_variable_C2 }
							multiply_variable = { global.mst_subber_variable = -1 }
							add_manpower = global.mst_subber_variable
						}
					}
				}
				if = {
					limit = {
						all_country = {
							NOT = { has_country_flag = mst_marked }
						}
					}
					if = {
						limit = { has_global_flag = mst_variable_C1_enabled }
						set_variable = { global.mst_subber_variable = global.mst_variable_C1 }
						multiply_variable = { global.mst_subber_variable = -1 }
						add_manpower = global.mst_subber_variable
					}
					if = {
						limit = { has_global_flag = mst_variable_C2_enabled }
						set_variable = { global.mst_subber_variable = global.mst_variable_C2 }
						multiply_variable = { global.mst_subber_variable = -1 }
						add_manpower = global.mst_subber_variable
					}
				}
			}
		}

		triggers = {
			mst_marker_visible = {
				NOT = { has_country_flag = mst_marked }
			}
			mst_unmarker_visible = {
				has_country_flag = mst_marked
			}
			mst_unmark_all_click_enabled = {
				any_country = {
					has_country_flag = mst_marked
				}
			}

			mst_select_country_on_visible = {
				NOT = {
					OR = {
						has_global_flag = mst_variable_C1_enabled
						has_global_flag = mst_variable_C2_enabled
					}
				}
			}
			mst_select_country_off_visible = {
				OR = {
					has_global_flag = mst_variable_C1_enabled
					has_global_flag = mst_variable_C2_enabled
				}
			}
			mst_select_variable_1_on_visible = {
				has_global_flag = mst_variable_C1_enabled
				NOT = { has_global_flag = mst_variable_C2_enabled }
			}
			mst_select_variable_1_off_visible = {
				NOT = { has_global_flag = mst_variable_C1_enabled }
			}
			mst_select_variable_2_on_visible = {
				has_global_flag = mst_variable_C2_enabled
				NOT = { has_global_flag = mst_variable_C1_enabled }
			}
			mst_select_variable_2_off_visible = {
				NOT = { has_global_flag = mst_variable_C2_enabled }
			}
			mst_add_1_click_enabled = {
				OR = {
					AND = {
						NOT = { has_global_flag = mst_variable_C1_enabled }
						NOT = { has_global_flag = mst_variable_C2_enabled }
					}
					AND = {
						has_global_flag = mst_variable_C1_enabled
						NOT = { has_global_flag = mst_variable_C2_enabled }
						check_variable = { global.mst_variable_C1 < 2147000 }
					}
					AND = {
						has_global_flag = mst_variable_C2_enabled
						NOT = { has_global_flag = mst_variable_C1_enabled }
						check_variable = { global.mst_variable_C2 < 2147000 }
					}
				}
			}
			mst_add_10_click_enabled = {
				OR = {
					AND = {
						NOT = { has_global_flag = mst_variable_C1_enabled }
						NOT = { has_global_flag = mst_variable_C2_enabled }
					}
					AND = {
						has_global_flag = mst_variable_C1_enabled
						NOT = { has_global_flag = mst_variable_C2_enabled }
						check_variable = { global.mst_variable_C1 < 2137000 }
					}
					AND = {
						has_global_flag = mst_variable_C2_enabled
						NOT = { has_global_flag = mst_variable_C1_enabled }
						check_variable = { global.mst_variable_C2 < 2137000 }
					}
				}
			}
			mst_add_100_click_enabled = {
				OR = {
					AND = {
						NOT = { has_global_flag = mst_variable_C1_enabled }
						NOT = { has_global_flag = mst_variable_C2_enabled }
					}
					AND = {
						has_global_flag = mst_variable_C1_enabled
						NOT = { has_global_flag = mst_variable_C2_enabled }
						check_variable = { global.mst_variable_C1 < 2047000 }
					}
					AND = {
						has_global_flag = mst_variable_C2_enabled
						NOT = { has_global_flag = mst_variable_C1_enabled }
						check_variable = { global.mst_variable_C2 < 2047000 }
					}
				}
			}
			mst_add_1000_click_enabled = {
				OR = {
					AND = {
						NOT = { has_global_flag = mst_variable_C1_enabled }
						NOT = { has_global_flag = mst_variable_C2_enabled }
					}
					AND = {
						has_global_flag = mst_variable_C1_enabled
						NOT = { has_global_flag = mst_variable_C2_enabled }
						check_variable = { global.mst_variable_C1 < 1147000 }
					}
					AND = {
						has_global_flag = mst_variable_C2_enabled
						NOT = { has_global_flag = mst_variable_C1_enabled }
						check_variable = { global.mst_variable_C2 < 1147000 }
					}
				}
			}
			mst_sub_1_click_enabled = {
				OR = {
					AND = {
						NOT = { has_global_flag = mst_variable_C1_enabled }
						NOT = { has_global_flag = mst_variable_C2_enabled }
					}
					AND = {
						has_global_flag = mst_variable_C1_enabled
						NOT = { has_global_flag = mst_variable_C2_enabled }
						check_variable = { global.mst_variable_C1 > -2147000 }
					}
					AND = {
						has_global_flag = mst_variable_C2_enabled
						NOT = { has_global_flag = mst_variable_C1_enabled }
						check_variable = { global.mst_variable_C2 > -2147000 }
					}
				}
			}
			mst_sub_10_click_enabled = {
				OR = {
					AND = {
						NOT = { has_global_flag = mst_variable_C1_enabled }
						NOT = { has_global_flag = mst_variable_C2_enabled }
					}
					AND = {
						has_global_flag = mst_variable_C1_enabled
						NOT = { has_global_flag = mst_variable_C2_enabled }
						check_variable = { global.mst_variable_C1 > -2137000 }
					}
					AND = {
						has_global_flag = mst_variable_C2_enabled
						NOT = { has_global_flag = mst_variable_C1_enabled }
						check_variable = { global.mst_variable_C2 > -2137000 }
					}
				}
			}
			mst_sub_100_click_enabled = {
				OR = {
					AND = {
						NOT = { has_global_flag = mst_variable_C1_enabled }
						NOT = { has_global_flag = mst_variable_C2_enabled }
					}
					AND = {
						has_global_flag = mst_variable_C1_enabled
						NOT = { has_global_flag = mst_variable_C2_enabled }
						check_variable = { global.mst_variable_C1 > -2047000 }
					}
					AND = {
						has_global_flag = mst_variable_C2_enabled
						NOT = { has_global_flag = mst_variable_C1_enabled }
						check_variable = { global.mst_variable_C2 > -2047000 }
					}
				}
			}
			mst_sub_1000_click_enabled = {
				OR = {
					AND = {
						NOT = { has_global_flag = mst_variable_C1_enabled }
						NOT = { has_global_flag = mst_variable_C2_enabled }
					}
					AND = {
						has_global_flag = mst_variable_C1_enabled
						NOT = { has_global_flag = mst_variable_C2_enabled }
						check_variable = { global.mst_variable_C1 > -1147000 }
					}
					AND = {
						has_global_flag = mst_variable_C2_enabled
						NOT = { has_global_flag = mst_variable_C1_enabled }
						check_variable = { global.mst_variable_C2 > -1147000 }
					}
				}
			}
			mst_add_variable_C_click_enabled = {
				OR = {
					has_global_flag = mst_variable_C1_enabled
					has_global_flag = mst_variable_C2_enabled
				}
			}
			mst_sub_variable_C_click_enabled = {
				OR = {
					has_global_flag = mst_variable_C1_enabled
					has_global_flag = mst_variable_C2_enabled
				}
			}
		}
	}
}