scripted_gui = {

	r56rp_tools_container_button = {
		context_type = player_context

		window_name = "r56rp_tools_container_button"
		parent_window_token = top_bar

		visible = {
			ROOT = {
				is_ai = no
				OR = { has_country_flag = host has_country_flag = host_2 }
			}
		}

		effects = {
			r56rp_tolcon_showhide_click = {
				ROOT = { 
					IF = {
						limit = {
							has_variable = show_combined_rptools_list
						}
						clear_variable = show_combined_rptools_list
					}
					ELSE = {
						set_variable = { show_combined_rptools_list = 1 } 
					}
				}
			}
		}
		triggers = {
			r56rp_tolcon_showhide_click_enabled = {
				always = yes
			}
		}
	}
	
	r56rp_tools_container = {
		context_type = player_context
		window_name = "r56rp_tools_container"
		visible = {
			ROOT = {
				check_variable = { show_combined_rptools_list = 1 }
				is_ai = no
			}
		}
		effects = {
			# RTT Button
			rt_button_topbar_click = {
				ROOT = { 
					IF = {
						limit = {
							has_variable = rt_status
						}
						clear_variable = rt_status
					}
					ELSE = {
						set_variable = { rt_status = 1 }
						clr_country_flag = transfer_enabled
						clr_country_flag = hosttool_enabled
					}
				}
			}
			# STT Button
			open_ST_click = {
				if = {
					limit = {
						ROOT = {
							has_country_flag = transfer_enabled
						}
					}
					ROOT = { clr_country_flag = transfer_enabled }
				}
				else = {
					ROOT = { set_country_flag = transfer_enabled }
					clear_variable = rt_status
					clr_country_flag = hosttool_enabled
				}
			}
			hide_ST_click = { #investigation required on just wtf this thing actualy does
				if = {
					limit = { NOT = { has_country_flag = hidden_switch } }
					set_country_flag = hidden_switch
				}
				else = {
					clr_country_flag = hidden_switch
				}
			}
			# HTool
			tool_open_click = {
				if = {
					limit = { 
						ROOT = { 
							has_country_flag = hosttool_enabled 
						} 
					}
					ROOT = { clr_country_flag = hosttool_enabled }
				}
				else = {
					ROOT = { set_country_flag = hosttool_enabled }
					clr_country_flag = transfer_enabled
					clear_variable = rt_status
				}
			}
		}
		triggers = {
			rt_button_topbar_click_enabled = {
				always = yes
			}
			hide_ST_click_enabled = {
				always = yes
			}
			open_ST_click_enabled = {
				always = yes
			}
			tool_open_click_enabled = {
				always = yes
			}
			tool_open_visible = {
				OR = {
					is_debug = yes
					has_country_flag = host
					has_country_flag = host_2
				}
				NOT = { has_country_flag = hidden_switch }
			}
			ht_title_visible = {
				OR = {
					is_debug = yes
					has_country_flag = host
					has_country_flag = host_2
				}
				NOT = { has_country_flag = hidden_switch }
			}
		}
	}

	r56rp_selected_states_array = {
		context_type = selected_state_context
		parent_window_name = "r56rp_tools_container"
		window_name = "r56rp_tool_state_selection_window"

		visible = {
			ROOT = {
				check_variable = { show_combined_rptools_list = 1 }
				is_ai = no
			}
		}
		dynamic_lists = {
			r56rp_tool_state_selection_grid_box = {
				array = ROOT.r56rp_tool_state_array
				value = v
				index = i
				change_scope = no
				entry_container = "r56rp_tool_state_selection_array"
			}
		}
		effects = {
			# purge button to clear the state selection array
			r56rp_tool_state_selection_button_1_click = {
				clear_array = ROOT.r56rp_tool_state_array
			}
			# one button to mark and unmark states.
			# localisation is handled via scripted
			r56rp_tool_state_selection_button_2_click = {
				IF = {
					limit = {
						is_in_array = {
							array = ROOT.r56rp_tool_state_array
							value = THIS.id
						}
					}
					remove_from_array = { 
						array = ROOT.r56rp_tool_state_array
						value = THIS.id
					}
				}
				ELSE = {
					add_to_array = { 
						array = ROOT.r56rp_tool_state_array
						value = THIS.id 
					}
				}
			}
			r56rp_tool_state_selection_click = {
				remove_from_array = { 
					array = ROOT.r56rp_tool_state_array
					index = i
				}
			}
		}
		triggers = {
			r56rp_tool_state_selection_button_1_click_enable = {
				any_state = {
					is_in_array = {
						array = ROOT.r56rp_tool_state_array
						value = THIS.id
					} 
				}
			}
		}
	}

	# Resource Transfer Tool
	rt_menu_container = {
		context_type = selected_state_context

		parent_window_name = r56rp_tools_container
		window_name = "rt_menu_container"

		visible = {
			ROOT = {
				check_variable = { rt_status = 1 }
			}
			always = no
		}
		effects = {
			add_rights_button_click = {
				ROOT = {
					set_country_flag = rt_waiting
				}
				if = {
					limit = {
						check_variable = { ROOT.swap_sides = 0}
					}
					
					THIS.owner = {
						country_event = rt.1
					}
				}
				else_if = {
					limit = {
						check_variable = { ROOT.swap_sides = 1}
					}
					THIS.owner = {
						country_event = rt.2
					}
				}
			}
			swap_sides_click = {
				ROOT = {
					#resources
						set_variable = { aluminium_selected = 1 }
						set_variable = { oil_selected = 1 }
						set_variable = { rubber_selected = 1 }
						set_variable = { steel_selected = 1 }
						set_variable = { chromium_selected = 1 }
						set_variable = { tungsten_selected = 1 }
						
						set_variable = { aluminium_ammount = 0 }
						set_variable = { oil_ammount = 0 }
						set_variable = { rubber_ammount = 0 }
						set_variable = { steel_ammount = 0 }
						set_variable = { chromium_ammount = 0 }
						set_variable = { tungsten_ammount = 0 }

						clear_array = resource_list

					set_variable = { state_lock = 1 }
					if = {
						limit = { check_variable = { swap_sides = 0 } } 
						set_variable = { swap_sides = 1 }
					}
					else_if = {
						limit = { check_variable = { swap_sides = 1 } } 
						set_variable = { swap_sides = 0 }
					}
					else = {
						set_variable = { swap_sides = 1 } 
					}	
				}
			}
			state_lock_click = {
				ROOT = {
					#resources
						set_variable = { aluminium_selected = 1 }
						set_variable = { oil_selected = 1 }
						set_variable = { rubber_selected = 1 }
						set_variable = { steel_selected = 1 }
						set_variable = { chromium_selected = 1 }
						set_variable = { tungsten_selected = 1 }

						set_variable = { aluminium_ammount = 0 }
						set_variable = { oil_ammount = 0 }
						set_variable = { rubber_ammount = 0 }
						set_variable = { steel_ammount = 0 }
						set_variable = { chromium_ammount = 0 }
						set_variable = { tungsten_ammount = 0 }

						clear_array = resource_list

					if = {
						limit = { check_variable = { state_lock = 1 } } 
						set_variable = { state_lock = 2 }
						set_variable = { state_lock_id = PREV }

						set_variable = { aluminium_ammount = PREV.resource@aluminium }
						set_variable = { oil_ammount = PREV.resource@oil }
						set_variable = { rubber_ammount = PREV.resource@rubber }
						set_variable = { steel_ammount = PREV.resource@steel }
						set_variable = { chromium_ammount = PREV.resource@chromium }
						set_variable = { tungsten_ammount = PREV.resource@tungsten }
						
					}
					else_if = {
						limit = { check_variable = { state_lock = 2 } }
						set_variable = { state_lock = 1 }
						clear_variable = state_lock_id
					}
					else = {
						set_variable = { state_lock = 2 }
						set_variable = { state_lock_id = PREV }

						set_variable = { aluminium_ammount = PREV.resource@aluminium }
						set_variable = { oil_ammount = PREV.resource@oil }
						set_variable = { rubber_ammount = PREV.resource@rubber }
						set_variable = { steel_ammount = PREV.resource@steel }
						set_variable = { chromium_ammount = PREV.resource@chromium }
						set_variable = { tungsten_ammount = PREV.resource@tungsten }
					}	
				}
			}
			#resources
				resource_button_aluminium_click = {
					ROOT = {
						if = {
							limit = { check_variable = { aluminium_selected = 1 } } 
							set_variable = { aluminium_selected = 2 }
							add_to_array = { resource_list = 2}
						}
						else_if = {
							limit = { check_variable = { aluminium_selected = 2 } }
							set_variable = { aluminium_selected = 1 }
							remove_from_array = { resource_list = 2 }
						}
						else = {
							set_variable = { aluminium_selected = 2 }
							add_to_array = { resource_list = 2 }
						}	
					}
				}
				resource_button_oil_click = {
					ROOT = {
						if = {
							limit = { check_variable = { oil_selected = 1 } } 
							set_variable = { oil_selected = 2 }
							add_to_array = { resource_list = 1 }
						}
						else_if = {
							limit = { check_variable = { oil_selected = 2 } }
							set_variable = { oil_selected = 1 }
							remove_from_array = { resource_list = 1 }
						}
						else = {
							set_variable = { oil_selected = 2 }
							add_to_array = { resource_list = 1 }
						}	
					}
				}
				resource_button_steel_click = {
					ROOT = {
						if = {
							limit = { check_variable = { ROOT.steel_selected = 1 } } 
							set_variable = { ROOT.steel_selected = 2 }
							add_to_array = { resource_list = 5 }
						}
						else_if = {
							limit = { check_variable = { ROOT.steel_selected = 2 } }
							set_variable = { ROOT.steel_selected = 1 }
							remove_from_array = { resource_list = 5 }
						}
						else = {
							set_variable = { ROOT.steel_selected = 2 }
							add_to_array = { resource_list = 5 }
						}	
					}
				}
				resource_button_rubber_click = {
					ROOT = {
						if = {
							limit = { check_variable = { rubber_selected = 1 } } 
							set_variable = { rubber_selected = 2 }
							add_to_array = { resource_list = 3}
						}
						else_if = {
							limit = { check_variable = { rubber_selected = 2 } }
							set_variable = { rubber_selected = 1 }
							remove_from_array = { resource_list = 3 }
						}
						else = {
							set_variable = { rubber_selected = 2 }
							add_to_array = { resource_list = 3}
						}	
					}
				}
				resource_button_tungsten_click = {
					ROOT = {
						if = {
							limit = { check_variable = { tungsten_selected = 1 } } 
							set_variable = { tungsten_selected = 2 }
							add_to_array = { resource_list = 4}
						}
						else_if = {
							limit = { check_variable = { tungsten_selected = 2 } }
							set_variable = { tungsten_selected = 1 }
							remove_from_array = { resource_list = 4 }
						}
						else = {
							set_variable = { tungsten_selected = 2 }
							add_to_array = { resource_list = 4}
						}	
					}
				}
				resource_button_chromium_click = {
					ROOT = {
						if = {
							limit = { check_variable = { ROOT.chromium_selected = 1 } } 
							set_variable = { ROOT.chromium_selected = 2 }
							add_to_array = { resource_list = 6}
						}
						else_if = {
							limit = { check_variable = { ROOT.chromium_selected = 2 } }
							set_variable = { ROOT.chromium_selected = 1 }
							remove_from_array = { resource_list = 6 }
						}
						else = {
							set_variable = { ROOT.chromium_selected = 2 }
							add_to_array = { resource_list = 6}
						}	
					}
				}

		}
		triggers = {
			add_rights_button_click_enabled = {
				NOT = {
					ROOT = {
						has_country_flag = rt_waiting
					}
				}
				
				OR = {
					AND = {
						NOT = {
							check_variable = {
								THIS.owner = ROOT
							}
						}
						THIS.owner = {
							owns_state = root.state_lock_id
						}
					}
						NOT = {
							check_variable = {
								THIS.owner = ROOT
							}
							THIS.owner = {
								owns_state = root.state_lock_id
							}
						}
				}
				
				
				
				check_variable = {
					ROOT.state_lock = 2
				}
				check_variable = {
					ROOT.resource_list^num > 0
				}
			}
			swap_sides_click_enabled = {
				NOT = {
					ROOT = {
						has_country_flag = rt_waiting
					}
				}
				always = yes
			}
			state_lock_click_enabled = {
				NOT = {
					ROOT = {
						has_country_flag = rt_waiting
					}
				}
				OR = {
					AND = {
						check_variable = {
							THIS.owner = ROOT
						}
						check_variable = {
							ROOT.swap_sides = 1
						}
					}
					AND = {
						NOT = {
							check_variable = {
								THIS.owner = ROOT
							}
						}
						check_variable = {
							ROOT.swap_sides = 0
						}
					}
				}		
			}
			#resources
				resource_button_aluminium_click_enabled = {
					NOT = {
						ROOT = {
							has_country_flag = rt_waiting
						}
					}
					check_variable = {
						ROOT.state_lock = 2
					}
					check_variable = {
						THIS = ROOT.state_lock_id
					}
					check_variable = {
						THIS.resource@aluminium > 0
					}
				}
				resource_button_oil_click_enabled = {
					NOT = {
						ROOT = {
							has_country_flag = rt_waiting
						}
					}
					check_variable = {
						ROOT.state_lock = 2
					}
					check_variable = {
						THIS = ROOT.state_lock_id
					}
					check_variable = {
						THIS.resource@oil > 0
					}
				}
				resource_button_steel_click_enabled = {
					NOT = {
						ROOT = {
							has_country_flag = rt_waiting
						}
					}
					check_variable = {
						ROOT.state_lock = 2
					}
					check_variable = {
						THIS = ROOT.state_lock_id
					}
					check_variable = {
						THIS.resource@steel > 0
					}
				}
				resource_button_rubber_click_enabled = {
					NOT = {
						ROOT = {
							has_country_flag = rt_waiting
						}
					}
					check_variable = {
						ROOT.state_lock = 2
					}
					check_variable = {
						THIS = ROOT.state_lock_id
					}
					check_variable = {
						THIS.resource@rubber > 0
					}
				}
				resource_button_tungsten_click_enabled = {
					NOT = {
						ROOT = {
							has_country_flag = rt_waiting
						}
					}
					check_variable = {
						ROOT.state_lock = 2
					}
					check_variable = {
						THIS = ROOT.state_lock_id
					}
					check_variable = {
						THIS.resource@tungsten > 0
					}
				}
				resource_button_chromium_click_enabled = {
					NOT = {
						ROOT = {
							has_country_flag = rt_waiting
						}
					}
					check_variable = {
						ROOT.state_lock = 2
					}
					check_variable = {
						THIS = ROOT.state_lock_id
					}
					check_variable = {
						THIS.resource@chromium > 0
					}
				}
		}
		properties = {
			#resources
				resource_button_aluminium = {
					frame = ROOT.aluminium_selected
				}
				resource_button_oil = {
					frame = ROOT.oil_selected
				}
				resource_button_steel = {
					frame = ROOT.steel_selected
				}
				resource_button_rubber = {
					frame = ROOT.rubber_selected
				}
				resource_button_tungsten = {
					frame = ROOT.tungsten_selected
				}
				resource_button_chromium = {
					frame = ROOT.chromium_selected
				}

			state_lock = {
				frame = ROOT.state_lock
			}
			TAG_1 = {
				image = [receiver_img]
			}
			TAG_2 = {
				image = [provider_img]
			}
		}
	}

	# State Transfer Tool
	st_country_powers = {
	
		context_type = selected_country_context
		parent_window_name = r56rp_tools_container
		window_name = "st_subject_powers_container"
		
		visible = {
			ROOT = {
				is_ai = no
				has_country_flag = transfer_enabled
			}
		}
		
		effects = {
		
			mark_all_states_click = {
				# purge array from shit that is already there
				clear_array = ROOT.r56rp_tool_state_array
				
				var:marks = {
					every_owned_state = {
						limit = {
							NOT = { 
								is_in_array = {
									array = ROOT.r56rp_tool_state_array
									value = THIS.id
								} 
							}
						}
						add_to_array = {
							array = ROOT.r56rp_tool_state_array
							value = THIS.id
						} 
					}
				}
			}
			
			award_states_click = {
				set_temp_variable = { ROOT.taker = this}
				
				every_state = {
					limit = {
						is_in_array = {
							array = ROOT.r56rp_tool_state_array
							value = THIS.id
						}
						OR = {
							is_owned_and_controlled_by = ROOT
							any_country = {
								is_ai = yes
								is_subject_of = ROOT
								owns_state = PREV
							}
						}
					}

					IF = {
						limit = {
							owner = {
								all_owned_state = {
									is_in_array = {
										array = ROOT.r56rp_tool_state_array
										value = THIS.id
									}
								}
							}
						}
						# couldnt get the annex_country to work, so this is a workaround.
						owner = {
							transfer_units_fraction= {
								target = var:taker
								size = 1
								keep_unit_leaders_trigger = {
									always = yes
								}
							}
						}
						var:taker = { transfer_state = PREV }
					}
					ELSE = {
						var:taker = { transfer_state = PREV }
					}
				}
				# only clean the array after you transfer all the states/army
				clear_array = ROOT.r56rp_tool_state_array
			}
		}
		
		triggers = {
		
			mark_all_states_click_enabled = {
	
			}
		
			mark_colonial_states_click_enabled = {
				ROOT = {
					has_offensive_war = no
				}
				any_owned_state = {
					NOT = { is_in_home_area = yes }
					NOT = { has_state_flag = marked_for_transfer }
					NOT = { is_core_of = this }
				}
			}
			
			mark_colonial_states_visible = {
				set_temp_variable = { ROOT.taker = this}
					ROOT = { tag = var:taker }
			}
		
			award_states_click_enabled = {
				ROOT = {
					has_offensive_war = no
				}
				PREV = {
					has_offensive_war = no
				}
			}
		
		}
        
	}

	# Host Tool
	host_country_powers = {

		context_type = selected_state_context
		parent_window_name = r56rp_tools_container
		window_name = "hosttool_container"

		visible = {
			ROOT = {
				OR = {
					is_debug = yes #cause fuck doing the game option
					has_country_flag = host
					has_country_flag = host_2
				}
				has_country_flag = hosttool_enabled
			}
		}

		effects = {

			ht_TAG_1_click = {
				# lock first flag, save as country
				set_variable = {
					var = ROOT.r56rp_ht_tag_1
					value = THIS.owner
				}
			}

			ht_TAG_2_click = {
				# lock second flag, save as country
				set_variable = {
					var = ROOT.r56rp_ht_tag_2
					value = THIS.owner
				}
			}

			ht_swap_sides_click = {
				set_temp_variable = { r56rp_ht_swap_1 = ROOT.r56rp_ht_tag_1}
				set_temp_variable = { r56rp_ht_swap_2 = ROOT.r56rp_ht_tag_2}
				set_variable = { ROOT.r56rp_ht_tag_1 = r56rp_ht_swap_2 }
				set_variable = { ROOT.r56rp_ht_tag_2 = r56rp_ht_swap_1 }
			}

			## buttons using the ht_tag's for targeting.
			
			whitepeace_selected_click  = {

				var:ROOT.r56rp_ht_tag_1 = {
					white_peace = ROOT.r56rp_ht_tag_2
				}
			}
			
			annex_country_click = {

				var:ROOT.r56rp_ht_tag_2 = {
					var:ROOT.r56rp_ht_tag_1 = {
						annex_country = {
							target = PREV
							transfer_troops = yes
						}
					}
				}
			}

			puppet_country_click = {
				var:ROOT.r56rp_ht_tag_2 = {
					puppet = {
						target = ROOT.r56rp_ht_tag_1
						end_wars = no
					}
				}
			}

			move_player_click = {
				var:ROOT.r56rp_ht_tag_2 = {
					change_tag_from = ROOT.r56rp_ht_tag_1
				}
			}

			ht_declare_war_button_click = {
				var:ROOT.r56rp_ht_tag_1 = {
					declare_war_on = {
						target = var:ROOT.r56rp_ht_tag_2
						type = annex_everything
					}
				}
			}

			ht_withdraw_volunt_button_click = {
				var:ROOT.r56rp_ht_tag_1 = {
					recall_volunteers_from = ROOT.r56rp_ht_tag_2
				}
				
			}

			ht_into_faction_button_click = {
				var:ROOT.r56rp_ht_tag_1 = { add_to_faction = ROOT.r56rp_ht_tag_2 }
			}
			
		## buttons using only the currently selected state as a target
			whitepeace_click = {
				owner={
					set_temp_variable = { ROOT.marks = this}
					var:marks = {
						declare_war_on = { target = JAM type = annex_everything }
						every_enemy_country = { white_peace = PREV }
					}
				}
			}

			observer_click = { 
				owner = {
					set_temp_variable = { ROOT.marks = this}
					GER = {
						news_event={id=hosttool.5}
					}
					JAM = {change_tag_from = var:marks}
				}
			}

			free_country_click = { 
				owner = {
					set_country_flag = puppetee
					OVERLORD = {
						set_temp_variable = { ROOT.puppeteer = this}
					}
				}
				every_country = {
					limit = { has_country_flag = puppetee }
						GER = {
							news_event={id=hosttool.7}
						}
						var:puppeteer = {
							set_autonomy = {
								target = PREV
								autonomy_state = autonomy_free
							}
						}
					clr_country_flag = puppetee
				}
			}

			clear_all_markings_click = {
				ROOT = {
					for_each_scope_loop={
						array=host_marked_states
						clear_variable=host_mark_status
					}
					clear_array=host_marked_states
				}
			}

			remove_from_faction_click = {
				THIS.owner = {
					leave_faction = yes
				}
			}

			award_states_click = {
				every_state = {
					limit = {
						is_in_array = {
							array = ROOT.r56rp_tool_state_array
							value = THIS.id
						}
					}
					transfer_state_to = PREV.owner
				}
			}

			add_cores_click = {
				every_state = {
					limit = {
						is_in_array = {
							array = ROOT.r56rp_tool_state_array
							value = THIS.id
						}
					}
					add_core_of = PREV.owner
				}
			}

			buff_nation_click = {
				THIS.owner = {
					IF = {
						limit = {
							has_idea = r56rp_ht_4t_buff_idea
						}
						remove_ideas = r56rp_ht_4t_buff_idea
					}
					ELSE = {
						add_ideas = r56rp_ht_4t_buff_idea
					}
				}
			}

			lock_volunteers_click = {
				THIS.owner = {
					IF = {
						limit = {
							has_idea = r56rp_ht_no_volunteers_idea
						}
						remove_ideas = r56rp_ht_no_volunteers_idea
						every_country = {
							limit = {
								has_volunteers_amount_from = {
									tag = PREV
									count > 0
								}
							}
							recall_volunteers_from = PREV
						}
					}
					ELSE = {
						add_ideas = r56rp_ht_no_volunteers_idea
					}
				}
			}

			freeze_nation_click = {
				THIS.owner = {
					IF = {
						limit = {
							has_idea = r56rp_ht_freeze_nation_idea
						}
						remove_ideas = r56rp_ht_freeze_nation_idea
					}
					ELSE = {
						add_ideas = r56rp_ht_freeze_nation_idea
					}
				}
			}

			change_ideology_click = {
				ROOT = {
					IF = {
						limit = {
							check_variable = {
								r56rp_ht_ideology_showdropdown > 0
							}
						}
						set_variable = { r56rp_ht_ideology_showdropdown = 0 }
					}
					ELSE = {
						set_variable = { r56rp_ht_ideology_showdropdown = 1 }
					}
				}
			}

		# cheat clicks

			# shows currently selected cheat via scripted localisation
			# also shows the drop down menu for cheat selection, which is kept separate to make
			# the entire thing appear nicley
			ht_select_cheat_0_click = {
				ROOT = {
					IF = {
						limit = {
							check_variable = {
								r56rp_ht_cheat_showdropdown > 0
							}
						}
						set_variable = { r56rp_ht_cheat_showdropdown = 0 }
					}
					ELSE = {
						set_variable = { r56rp_ht_cheat_showdropdown = 1 }
					}
				}
			}

			ht_select_cheat_plus_button_click = {
				add_to_variable = {
					var = ROOT.r56rp_ht_cheat_iterations
					value = 1
				}
			}
			ht_select_cheat_plus_button_shift_click = {
				add_to_variable = {
					var = ROOT.r56rp_ht_cheat_iterations
					value = 5
				}
			}

			ht_select_cheat_minus_button_click = {
				IF = {
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheat_iterations < 2
						}
					}
					set_variable = {
						ROOT.r56rp_ht_cheat_iterations = 1
					}
				}
				ELSE = {
					subtract_from_variable = {
						var = ROOT.r56rp_ht_cheat_iterations
						value = 1
					}
				}
			}
			ht_select_cheat_minus_button_shift_click = {
				IF = {
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheat_iterations < 6
						}
					}
					set_variable = {
						ROOT.r56rp_ht_cheat_iterations = 1
					}
				}
				ELSE = {
					subtract_from_variable = {
						var = ROOT.r56rp_ht_cheat_iterations
						value = 5
					}
				}
			}


			# 1 add 10 pp
			# 2 remove 10 pp
			# 3 add 1 offmap civ
			# 4 remove 1 offmap civ
			# 5 add 1 offmap mill
			# 6 remove 1 offmap mill
			# 7 add 1 offmap dock
			# 8 remove 1 offmap dock


			ht_select_cheat_execute_button_click = {
				IF = { # "Add 10 PP"
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheatsl = 1
						}
					}
					THIS.owner = {
						set_temp_variable = { r56rp_ht_tvar_1 = 10 }
						multiply_temp_variable = { r56rp_ht_tvar_1 = ROOT.r56rp_ht_cheat_iterations }
						add_political_power = r56rp_ht_tvar_1
					}
				}
				ELSE_IF = { # "Rmv 10 PP"
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheatsl = 2
						}
					}
					THIS.owner = {
						set_temp_variable = { r56rp_ht_tvar_1 = -10 }
						multiply_temp_variable = { r56rp_ht_tvar_1 = ROOT.r56rp_ht_cheat_iterations }
						add_political_power = r56rp_ht_tvar_1
					}
				}
				ELSE_IF = { # "Add 1% Stab"
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheatsl = 3
						}
					}
					THIS.owner = {
						set_temp_variable = { r56rp_ht_tvar_1 = 0.01 }
						multiply_temp_variable = { r56rp_ht_tvar_1 = ROOT.r56rp_ht_cheat_iterations }
						add_stability = r56rp_ht_tvar_1
					}
				}

				ELSE_IF = { # "Rmv 1% Stab"
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheatsl = 4
						}
					}
					THIS.owner = {
						set_temp_variable = { r56rp_ht_tvar_1 = -0.01 }
						multiply_temp_variable = { r56rp_ht_tvar_1 = ROOT.r56rp_ht_cheat_iterations }
						add_stability = r56rp_ht_tvar_1
					}
				}
				
				ELSE_IF = { # "Add 1% WarSup"
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheatsl = 5
						}
					}
					THIS.owner = {
						set_temp_variable = { r56rp_ht_tvar_1 = 0.01 }
						multiply_temp_variable = { r56rp_ht_tvar_1 = ROOT.r56rp_ht_cheat_iterations }
						add_war_support = r56rp_ht_tvar_1
					}
				}
				
				ELSE_IF = { # "Rmv 1% WarSup"
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheatsl = 6
						}
					}
					THIS.owner = {
						set_temp_variable = { r56rp_ht_tvar_1 = -0.01 }
						multiply_temp_variable = { r56rp_ht_tvar_1 = ROOT.r56rp_ht_cheat_iterations }
						add_war_support = r56rp_ht_tvar_1
					}
				}
				
				ELSE_IF = { # "Add 50k Manpow"
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheatsl = 7
						}
					}
					THIS.owner = {
						set_temp_variable = { r56rp_ht_tvar_1 = 50000 }
						multiply_temp_variable = { r56rp_ht_tvar_1 = ROOT.r56rp_ht_cheat_iterations }
						add_manpower = r56rp_ht_tvar_1
					}
				}
				
				ELSE_IF = { # "Rmv 50k Manpow"
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheatsl = 8
						}
					}
					THIS.owner = {
						set_temp_variable = { r56rp_ht_tvar_1 = 50000 }
						multiply_temp_variable = { r56rp_ht_tvar_1 = ROOT.r56rp_ht_cheat_iterations }
						multiply_temp_variable = { r56rp_ht_tvar_1 = -1 }
						add_manpower = r56rp_ht_tvar_1
					}
					
				}
				
				ELSE_IF = { # "Add 1 Offmap Civ"
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheatsl = 9
						}
					}
					THIS.owner = {
						add_offsite_building = { 
							type = industrial_complex 
							level = ROOT.r56rp_ht_cheat_iterations 
						}
					}
				}
				
				ELSE_IF = { # "Rmv 1 Offmap Civ"
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheatsl = 10
						}
					}
					THIS.owner = {
						set_temp_variable = { r56rp_ht_tvar_1 = ROOT.r56rp_ht_cheat_iterations }
						multiply_temp_variable = { r56rp_ht_tvar_1 = -1 }
						add_offsite_building = { 
							type = industrial_complex 
							level = r56rp_ht_tvar_1
						}
					}
					
				}
				
				ELSE_IF = { # "Add 1 Offmap Mil"
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheatsl = 11
						}
					}
					THIS.owner = {
						add_offsite_building = { 
							type = arms_factory 
							level = ROOT.r56rp_ht_cheat_iterations
						}
					}
				}
				
				ELSE_IF = { # "Rmv 1 Offmap Mil"
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheatsl = 12
						}
					}
					THIS.owner = {
						set_temp_variable = { r56rp_ht_tvar_1 = ROOT.r56rp_ht_cheat_iterations }
						multiply_temp_variable = { r56rp_ht_tvar_1 = -1 }
						add_offsite_building = { 
							type = arms_factory 
							level = r56rp_ht_tvar_1
						}
					}
				}
				
				ELSE_IF = { # "Add 1 Offmap Dock"
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheatsl = 13
						}
					}
					THIS.owner = {
						add_offsite_building = { 
							type = dockyard 
							level = ROOT.r56rp_ht_cheat_iterations
						}
					}
				}
				
				ELSE_IF = { # "Rmv 1 Offmap Dock"
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheatsl = 14
						}
					}
					THIS.owner = {
						set_temp_variable = { r56rp_ht_tvar_1 = ROOT.r56rp_ht_cheat_iterations }
						multiply_temp_variable = { r56rp_ht_tvar_1 = -1 }
						add_offsite_building = { 
							type = dockyard 
							level = r56rp_ht_tvar_1
						}
					}
				}
				
				ELSE_IF = { # "Add 1 OnCore Civ"
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheatsl = 15
						}
					}
					THIS.owner = {
						set_temp_variable = { r56rp_ht_tvar_1 = ROOT.r56rp_ht_cheat_iterations }
	
						for_loop_effect = {
							end = r56rp_ht_tvar_1
							value = temp
							random_core_state = {
								limit = {
									is_controlled_by = PREV
									free_building_slots = {
										building = industrial_complex
										size > 1
										include_locked = yes
									}
								}
								add_extra_state_shared_building_slots = 1
								add_building_construction = {
									type = industrial_complex
									level = 1
									instant_build = yes
								}
							}
						}
					}
				}
				
				ELSE_IF = { # "Rmv 1 OnCore Civ"
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheatsl = 16
						}
					}
					THIS.owner = {
						set_temp_variable = { r56rp_ht_tvar_1 = ROOT.r56rp_ht_cheat_iterations }
	
						for_loop_effect = {
							end = r56rp_ht_tvar_1
							value = temp
							random_core_state = {
								limit = {
									is_controlled_by = PREV
									industrial_complex > 0
								}
								remove_building = {
									type = industrial_complex
									level = 1
								}
							}
						}
					}

				}
				
				ELSE_IF = { # "Add 1 OnCore Mil"
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheatsl = 17
						}
					}
					THIS.owner = {
						set_temp_variable = { r56rp_ht_tvar_1 = ROOT.r56rp_ht_cheat_iterations }
	
						for_loop_effect = {
							end = r56rp_ht_tvar_1
							value = temp
							random_core_state = {
								limit = {
									is_controlled_by = PREV
									free_building_slots = {
										building = arms_factory
										size > 1
										include_locked = yes
									}
								}
								add_extra_state_shared_building_slots = 1
								add_building_construction = {
									type = arms_factory
									level = 1
									instant_build = yes
								}
							}
						}
					}
				}
				
				ELSE_IF = { # "Rmv 1 OnCore Mil"
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheatsl = 18
						}
					}
					THIS.owner = {
						set_temp_variable = { r56rp_ht_tvar_1 = ROOT.r56rp_ht_cheat_iterations }
	
						for_loop_effect = {
							end = r56rp_ht_tvar_1
							value = temp
							random_core_state = {
								limit = {
									is_controlled_by = PREV
									arms_factory > 0
								}
								remove_building = {
									type = arms_factory
									level = 1
								}
							}
						}
					}

				}
				
				ELSE_IF = { # "Add 1 OnCore Dock"
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheatsl = 19
						}
					}
					THIS.owner = {
						set_temp_variable = { r56rp_ht_tvar_1 = ROOT.r56rp_ht_cheat_iterations }
	
						for_loop_effect = {
							end = r56rp_ht_tvar_1
							value = temp
							random_core_state = {
								limit = {
									is_controlled_by = PREV
									is_coastal = yes
									free_building_slots = {
										building = dockyard
										size > 1
										include_locked = yes
									}
								}
								add_extra_state_shared_building_slots = 1
								add_building_construction = {
									type = dockyard
									level = 1
									instant_build = yes
								}
							}
						}
					}
				}
				
				ELSE_IF = { # "Rmv 1 OnCore Dock"
					limit = {
						check_variable = {
							ROOT.r56rp_ht_cheatsl = 20
						}
					}
					THIS.owner = {
						set_temp_variable = { r56rp_ht_tvar_1 = ROOT.r56rp_ht_cheat_iterations }
	
						for_loop_effect = {
							end = r56rp_ht_tvar_1
							value = temp
							random_core_state = {
								limit = {
									is_controlled_by = PREV
									dockyard > 0
								}
								remove_building = {
									type = dockyard
									level = 1
								}
							}
						}
					}
				}
			}

		}
		properties = {
			toogle_mark={
				frame = host_mark_status
			}
			ht_TAG_1 = {
				image = [?ROOT.r56rp_ht_tag_1.GetFlag]
			}
			ht_TAG_2 = {
				image = [?ROOT.r56rp_ht_tag_2.GetFlag]
			}
		}

		triggers = {

			annex_country_click_enabled = {
			}

			puppet_country_click_enabled = {
			}

			move_player_click_enabled = {
				var:ROOT.r56rp_ht_tag_2 = {
					exists = yes
					is_ai = yes
				}
				var:ROOT.r56rp_ht_tag_1 = {
					exists = yes
					is_ai = no
				}
			}

			ht_withdraw_volunt_button_click_enabled = {
				var:ROOT.r56rp_ht_tag_2 = {
					has_volunteers_amount_from = {
						tag = ROOT.r56rp_ht_tag_1
						count > 0
					}
				}
			}

			ht_declare_war_button_click_enabled = {
				var:ROOT.r56rp_ht_tag_2 = {
					NOT = {
						has_war_with = ROOT.r56rp_ht_tag_1
					}
				}
			}

			whitepeace_selected_click_enabled = {
				var:ROOT.r56rp_ht_tag_2 = {
					has_war_with = ROOT.r56rp_ht_tag_1
				}
				var:ROOT.r56rp_ht_tag_1 = {
					has_war_with = ROOT.r56rp_ht_tag_2
				}
			}

			observer_click_enabled = {
				owner = {
					is_ai = no
				}
			}

			free_country_click_enabled = {
				owner = {
					is_subject = yes
				}
			}

			whitepeace_click_enabled = {
				owner = {
					has_war = yes
				}
			}

			award_states_click_enabled = {
				any_state = {
					is_in_array = {
						array = ROOT.r56rp_tool_state_array
						value = THIS.id
					} 
				}
			}

			add_cores_click_enabled = {
				any_state = {
					is_in_array = {
						array = ROOT.r56rp_tool_state_array
						value = THIS.id
					} 
				}
			}

		}

	}

	ht_change_ideology_container = {
		context_type = selected_country_context
		parent_window_name = r56rp_tools_container
		window_name = "ht_change_ideology_container"
		
		visible = {
			ROOT = {
				AND = {
					check_variable = {
						r56rp_ht_ideology_showdropdown > 0
					}
					has_country_flag = hosttool_enabled
				}
				
			}
		}
		effects = {
			select_cheat_1_click = {
				THIS = {
					set_politics = {
						ruling_party = democratic
						elections_allowed = yes
					}
				}
				
			}

			select_cheat_2_click = {
				THIS = {
					set_politics = {
						ruling_party = fascism
						elections_allowed = no
					}
				}
			}

			select_cheat_3_click = {
				THIS = {
					set_politics = {
						ruling_party = communism
						elections_allowed = no
					}
				}
			}

			select_cheat_4_click = {
				THIS = {
					set_politics = {
						ruling_party = neutrality
						elections_allowed = no
					}
				}
			}

		}
		triggers = {
			select_cheat_1_click_enabled = {
				THIS = {
					NOT = {
						has_government = democratic
					}
				}
			}
			select_cheat_2_click_enabled = {
				THIS = {
					NOT = {
						has_government = fascism
					}
				}
			}
			select_cheat_3_click_enabled = {
				THIS = {
					NOT = {
						has_government = communism
					}
				}
			}
			select_cheat_4_click_enabled = {
				THIS = {
					NOT = {
						has_government = neutrality
					}
				}
			}
		}
	}

	ht_cheats_list_container = {
		context_type = player_context
		parent_window_name = r56rp_tools_container
		window_name = "ht_cheats_list_container"
		
		visible = {
			ROOT = {
				AND = {
					check_variable = {
						r56rp_ht_cheat_showdropdown > 0
					}
					has_country_flag = hosttool_enabled
				}
				
			}
		}
		effects = {
			select_cheat_1_click = {
				set_variable = {
					ROOT.r56rp_ht_cheatsl = 1
				}
			}

			select_cheat_2_click = {
				set_variable = {
					ROOT.r56rp_ht_cheatsl = 2
				}
			}

			select_cheat_3_click = {
				set_variable = {
					ROOT.r56rp_ht_cheatsl = 3
				}
			}

			select_cheat_4_click = {
				set_variable = {
					ROOT.r56rp_ht_cheatsl = 4
				}
			}

			select_cheat_5_click = {
				set_variable = {
					ROOT.r56rp_ht_cheatsl = 5
				}
			}

			select_cheat_6_click = {
				set_variable = {
					ROOT.r56rp_ht_cheatsl = 6
				}
			}

			select_cheat_7_click = {
				set_variable = {
					ROOT.r56rp_ht_cheatsl = 7
				}
			}

			select_cheat_8_click = {
				set_variable = {
					ROOT.r56rp_ht_cheatsl = 8
				}
			}

			select_cheat_9_click = {
				set_variable = {
					ROOT.r56rp_ht_cheatsl = 9
				}
			}

			select_cheat_10_click = {
				set_variable = {
					ROOT.r56rp_ht_cheatsl = 10
				}
			}

			select_cheat_11_click = {
				set_variable = {
					ROOT.r56rp_ht_cheatsl = 11
				}
			}

			select_cheat_12_click = {
				set_variable = {
					ROOT.r56rp_ht_cheatsl = 12
				}
			}

			select_cheat_13_click = {
				set_variable = {
					ROOT.r56rp_ht_cheatsl = 13
				}
			}

			select_cheat_14_click = {
				set_variable = {
					ROOT.r56rp_ht_cheatsl = 14
				}
			}

			select_cheat_15_click = {
				set_variable = {
					ROOT.r56rp_ht_cheatsl = 15
				}
			}

			select_cheat_16_click = {
				set_variable = {
					ROOT.r56rp_ht_cheatsl = 16
				}
			}

			select_cheat_17_click = {
				set_variable = {
					ROOT.r56rp_ht_cheatsl = 17
				}
			}

			select_cheat_18_click = {
				set_variable = {
					ROOT.r56rp_ht_cheatsl = 18
				}
			}

			select_cheat_19_click = {
				set_variable = {
					ROOT.r56rp_ht_cheatsl = 19
				}
			}

			select_cheat_20_click = {
				set_variable = {
					ROOT.r56rp_ht_cheatsl = 20
				}
			}
			


		}
		triggers = {

		}
	}
}
