scripted_gui = {

	cheatgui_toggle = {

		context_type = player_context
		window_name = "cheatgui_toggle_container"

		visible = {
			has_country_flag = cheatgui_beta_enabled
			is_ai = no
		}

		effects = {

			toggle_button_click = {
				if = { limit = { NOT = { has_country_flag = cheatgui_enabled } }
					set_country_flag = cheatgui_enabled

				}
				else = { clr_country_flag = cheatgui_enabled }
			}

		}

	}

	cheatgui_main = {

		context_type = player_context
		window_name = "cheatgui_main_window"

		visible = { has_country_flag = cheatgui_enabled }

		effects = {

			resourcecheat_button_click = {
				if = { limit = { NOT = { has_country_flag = cheatgui_resourcecheat_enabled } }
					set_country_flag = cheatgui_resourcecheat_enabled
					set_variable = { resourcecheat_count = 0 }
					clear_array = resourcecheat_increment_array
				}
				else = { clr_country_flag = cheatgui_resourcecheat_enabled }
			}

		}

	}

	### Add Resources to State ###

	cheatgui_resourcecheat = {

		context_type = selected_state_context
		window_name = "cheatgui_resourcecheat_window"

		visible = { ROOT =  { has_country_flag = cheatgui_resourcecheat_enabled } }

		properties = {
			oil_button = {
				image = "[resourcecheat_oil_icon]"
			}
			rubber_button = {
				image = "[resourcecheat_rubber_icon]"
			}
			steel_button = {
				image = "[resourcecheat_steel_icon]"
			}
			aluminum_button = {
				image = "[resourcecheat_aluminum_icon]"
			}
			tungsten_button = {
				image = "[resourcecheat_tungsten_icon]"
			}
			chromium_button = {
				image = "[resourcecheat_chromium_icon]"
			}
		}

		effects = {

			add_counter_shift_click = {
				set_variable = { ROOT.resourcecheat_count = 0 }
				clear_array = ROOT.resourcecheat_increment_array
			}

			add_counter_up_click = { resourcecheat_increment_by_1 = yes }
			add_counter_up_control_click = { resourcecheat_increment_by_5 = yes }
			add_counter_up_shift_click = { resourcecheat_increment_by_25 = yes }
			add_counter_up_control_shift_click = { resourcecheat_increment_by_100 = yes }

			add_counter_down_click = { resourcecheat_decrement_by_1 = yes }
			add_counter_down_control_click = { resourcecheat_decrement_by_5 = yes }
			add_counter_down_shift_click = { resourcecheat_decrement_by_25 = yes }
			add_counter_down_control_shift_click = { resourcecheat_decrement_by_100 = yes }



			add_button_click = {
				for_each_loop = {
					array = ROOT.resourcecheat_increment_array

					if = { limit = { check_variable = { ROOT.oil_button_state = 1 } }
						add_resource = {
							type = oil
							amount = 1
						}
					}
					if = { limit = { check_variable = { ROOT.rubber_button_state = 1 } }
						add_resource = {
							type = rubber
							amount = 1
						}
					}
					if = { limit = { check_variable = { ROOT.steel_button_state = 1 } }
						add_resource = {
							type = steel
							amount = 1
						}
					}
					if = { limit = { check_variable = { ROOT.aluminum_button_state = 1 } }
						add_resource = {
							type = aluminium
							amount = 1
						}
					}
					if = { limit = { check_variable = { ROOT.tungsten_button_state = 1 } }
						add_resource = {
							type = tungsten
							amount = 1
						}
					}
					if = { limit = { check_variable = { ROOT.chromium_button_state = 1 } }
						add_resource = {
							type = chromium
							amount = 1
						}
					}
				}
			}



			oil_button_click = {
				if = { limit = { check_variable = { ROOT.oil_button_state = 0 } }
					set_variable = { ROOT.oil_button_state = 1 }
				}
				else = {
					set_variable = { ROOT.oil_button_state = 0 }
				}
			}
			rubber_button_click = {
				if = { limit = { check_variable = { ROOT.rubber_button_state = 0 } }
					set_variable = { ROOT.rubber_button_state = 1 }
				}
				else = {
					set_variable = { ROOT.rubber_button_state = 0 }
				}
			}
			steel_button_click = {
				if = { limit = { check_variable = { ROOT.steel_button_state = 0 } }
					set_variable = { ROOT.steel_button_state = 1 }
				}
				else = {
					set_variable = { ROOT.steel_button_state = 0 }
				}
			}
			aluminum_button_click = {
				if = { limit = { check_variable = { ROOT.aluminum_button_state = 0 } }
					set_variable = { ROOT.aluminum_button_state = 1 }
				}
				else = {
					set_variable = { ROOT.aluminum_button_state = 0 }
				}
			}
			tungsten_button_click = {
				if = { limit = { check_variable = { ROOT.tungsten_button_state = 0 } }
					set_variable = { ROOT.tungsten_button_state = 1 }
				}
				else = {
					set_variable = { ROOT.tungsten_button_state = 0 }
				}
			}
			chromium_button_click = {
				if = { limit = { check_variable = { ROOT.chromium_button_state = 0 } }
					set_variable = { ROOT.chromium_button_state = 1 }
				}
				else = {
					set_variable = { ROOT.chromium_button_state = 0 }
				}
			}
		}

	}

}
