scripted_gui = {

	SBI_kanaris_operation_decision_ui = {
		context_type = decision_category
		window_name = "SBI_kanaris_operation_decision_ui_window"

		properties = {
		
			GFX_Germany_stability = { frame = Germany_stability_Progress }
		
			OMS_Gauntlet_NewGuardImage = { frame = guard_val }
			
			GFX_Kanaris_strength_bar = { frame = OMS_Gauntlet_NewGuard_Entrenchment^guard_val }
			
		}
		
		effects = {
			OMS_ISD_button_click = {
				if = {
					limit = {
						check_variable = { guard_val = 1 }
					}
					
					hidden_effect = {
						set_variable = { sbi_kanaris_operation_YES = 0 }
						add_to_variable = { sbi_kanaris_operation_yes = var:OMS_Gauntlet_NewGuard_Entrenchment^1 }
						set_variable = { sbi_kanaris_operation_NO = 100 }
						set_variable = { sbi_kanaris_operation_MINUS = var:sbi_kanaris_operation_yes }
						multiply_variable = { sbi_kanaris_operation_MINUS = -1 }
						add_to_variable = { sbi_kanaris_operation_NO = var:sbi_kanaris_operation_MINUS }
						
						random_list = {
							var:sbi_kanaris_operation_YES = {
								country_event = {
									id = SBI.8101
									days = 1
								}
							}
							var:sbi_kanaris_operation_NO = {
								country_event = {
									id = SBI.8100
									days = 1
								}
							}
						}
					}
				}
				
				else_if = {
					limit = {
						check_variable = { guard_val = 2 }
					}
					
					hidden_effect = {
						set_variable = { sbi_kanaris_operation_YES = 0 }
						add_to_variable = { sbi_kanaris_operation_yes = var:OMS_Gauntlet_NewGuard_Entrenchment^2 }
						set_variable = { sbi_kanaris_operation_NO = 100 }
						set_variable = { sbi_kanaris_operation_MINUS = var:sbi_kanaris_operation_yes }
						multiply_variable = { sbi_kanaris_operation_MINUS = -1 }
						add_to_variable = { sbi_kanaris_operation_NO = var:sbi_kanaris_operation_MINUS }
						
						random_list = {
							var:sbi_kanaris_operation_YES = {
								country_event = {
									id = SBI.8102
									days = 1
								}
							}
							var:sbi_kanaris_operation_NO = {
								country_event = {
									id = SBI.8100
									days = 1
								}
							}
						}
					}
				}
				
				else_if = {
					limit = {
						check_variable = { guard_val = 3 }
					}
					
					hidden_effect = {
						set_variable = { sbi_kanaris_operation_YES = 0 }
						add_to_variable = { sbi_kanaris_operation_yes = var:OMS_Gauntlet_NewGuard_Entrenchment^3 }
						set_variable = { sbi_kanaris_operation_NO = 100 }
						set_variable = { sbi_kanaris_operation_MINUS = var:sbi_kanaris_operation_yes }
						multiply_variable = { sbi_kanaris_operation_MINUS = -1 }
						add_to_variable = { sbi_kanaris_operation_NO = var:sbi_kanaris_operation_MINUS }
						
						random_list = {
							var:sbi_kanaris_operation_YES = {
								country_event = {
									id = SBI.8103
									days = 1
								}
							}
							var:sbi_kanaris_operation_NO = {
								country_event = {
									id = SBI.8100
									days = 1
								}
							}
						}
					}
				}
				
				else_if = {
					limit = {
						check_variable = { guard_val = 4 }
					}
					
					hidden_effect = {
						set_variable = { sbi_kanaris_operation_YES = 0 }
						add_to_variable = { sbi_kanaris_operation_yes = var:OMS_Gauntlet_NewGuard_Entrenchment^4 }
						set_variable = { sbi_kanaris_operation_NO = 100 }
						set_variable = { sbi_kanaris_operation_MINUS = var:sbi_kanaris_operation_yes }
						multiply_variable = { sbi_kanaris_operation_MINUS = -1 }
						add_to_variable = { sbi_kanaris_operation_NO = var:sbi_kanaris_operation_MINUS }
						
						random_list = {
							var:sbi_kanaris_operation_YES = {
								country_event = {
									id = SBI.8104
									days = 1
								}
							}
							var:sbi_kanaris_operation_NO = {
								country_event = {
									id = SBI.8100
									days = 1
								}
							}
						}
					}
				}
				
				else_if = {
					limit = {
						check_variable = { guard_val = 5 }
					}
					
					hidden_effect = {
						set_variable = { sbi_kanaris_operation_YES = 0 }
						add_to_variable = { sbi_kanaris_operation_yes = var:OMS_Gauntlet_NewGuard_Entrenchment^5 }
						set_variable = { sbi_kanaris_operation_NO = 100 }
						set_variable = { sbi_kanaris_operation_MINUS = var:sbi_kanaris_operation_yes }
						multiply_variable = { sbi_kanaris_operation_MINUS = -1 }
						add_to_variable = { sbi_kanaris_operation_NO = var:sbi_kanaris_operation_MINUS }
						
						random_list = {
							var:sbi_kanaris_operation_YES = {
								country_event = {
									id = SBI.8105
									days = 1
								}
							}
							var:sbi_kanaris_operation_NO = {
								country_event = {
									id = SBI.8100
									days = 1
								}
							}
						}
					}
				}
				
				else_if = {
					limit = {
						check_variable = { guard_val = 6 }
					}
					
					hidden_effect = {
						set_variable = { sbi_kanaris_operation_YES = 0 }
						add_to_variable = { sbi_kanaris_operation_yes = var:OMS_Gauntlet_NewGuard_Entrenchment^6 }
						set_variable = { sbi_kanaris_operation_NO = 100 }
						set_variable = { sbi_kanaris_operation_MINUS = var:sbi_kanaris_operation_yes }
						multiply_variable = { sbi_kanaris_operation_MINUS = -1 }
						add_to_variable = { sbi_kanaris_operation_NO = var:sbi_kanaris_operation_MINUS }
						
						random_list = {
							var:sbi_kanaris_operation_YES = {
								country_event = {
									id = SBI.8106
									days = 1
								}
							}
							var:sbi_kanaris_operation_NO = {
								country_event = {
									id = SBI.8100
									days = 1
								}
							}
						}
					}
				}
				
				else_if = {
					limit = {
						check_variable = { guard_val = 7 }
					}
					
					hidden_effect = {
						set_variable = { sbi_kanaris_operation_YES = 0 }
						add_to_variable = { sbi_kanaris_operation_yes = var:OMS_Gauntlet_NewGuard_Entrenchment^7 }
						set_variable = { sbi_kanaris_operation_NO = 100 }
						set_variable = { sbi_kanaris_operation_MINUS = var:sbi_kanaris_operation_yes }
						multiply_variable = { sbi_kanaris_operation_MINUS = -1 }
						add_to_variable = { sbi_kanaris_operation_NO = var:sbi_kanaris_operation_MINUS }
						
						random_list = {
							var:sbi_kanaris_operation_YES = {
								country_event = {
									id = SBI.8107
									days = 1
								}
							}
							var:sbi_kanaris_operation_NO = {
								country_event = {
									id = SBI.8100
									days = 1
								}
							}
						}
					}
				}
				
				else_if = {
					limit = {
						check_variable = { guard_val = 8 }
					}
					
					hidden_effect = {
						set_variable = { sbi_kanaris_operation_YES = 0 }
						add_to_variable = { sbi_kanaris_operation_yes = var:OMS_Gauntlet_NewGuard_Entrenchment^8 }
						set_variable = { sbi_kanaris_operation_NO = 100 }
						set_variable = { sbi_kanaris_operation_MINUS = var:sbi_kanaris_operation_yes }
						multiply_variable = { sbi_kanaris_operation_MINUS = -1 }
						add_to_variable = { sbi_kanaris_operation_NO = var:sbi_kanaris_operation_MINUS }
						
						random_list = {
							var:sbi_kanaris_operation_YES = {
								country_event = {
									id = SBI.8108
									days = 1
								}
							}
							var:sbi_kanaris_operation_NO = {
								country_event = {
									id = SBI.8100
									days = 1
								}
							}
						}
					}
				}
				
				set_variable = { OMS_Gauntlet_NewGuard_ID^guard_idx = 0 }
			}
		}
		
		triggers = {
			GFX_Kanaris_Operation_Empty_visible = {
				check_variable = { guard_val = 0 }
			}
			OMS_ISD_button_visible = {
				check_variable = { guard_val > 0 }
			}
			OMS_Gauntlet_NewGuardImage_visible = {
				check_variable = { guard_val > 0 }
			}
			GFX_Kanaris_strength_bar_visible = {
				check_variable = { guard_val > 0 }
			}
			GFX_Kanaris_Operation_Foreground_visible = {
				check_variable = { guard_val > 0 }
			}
			
			OMS_ISD_button_click_enabled = {
				if = {
					limit = {
						check_variable = { guard_val = 1 }
					}
					custom_trigger_tooltip = {
						tooltip = KAN_OPERATION_AVAILABLE_tt
						has_completed_focus = KAN_cold_reception_exit_routes
					}
					has_completed_focus = KAN_cold_reception_exit_routes
				}
				else_if = {
					limit = {
						check_variable = { guard_val = 2 }
					}
					custom_trigger_tooltip = {
						tooltip = KAN_OPERATION_AVAILABLE_tt
						has_completed_focus = KAN_IRON_ANSWER_set_trap
					}
					has_completed_focus = KAN_IRON_ANSWER_set_trap
				}
				else_if = {
					limit = {
						check_variable = { guard_val = 3 }
					}
					custom_trigger_tooltip = {
						tooltip = KAN_OPERATION_AVAILABLE_tt
						has_completed_focus = KAN_OPERATION_GRAY_CARRION_enable_action
					}
					has_completed_focus = KAN_OPERATION_GRAY_CARRION_enable_action
				}
				else_if = {
					limit = {
						check_variable = { guard_val = 4 }
					}
					custom_trigger_tooltip = {
						tooltip = KAN_OPERATION_AVAILABLE_tt
						has_completed_focus = KAN_OPERATION_STONE_ROAD_cover_story
					}
					has_completed_focus = KAN_OPERATION_STONE_ROAD_cover_story
				}
				else_if = {
					limit = {
						check_variable = { guard_val = 5 }
					}
					custom_trigger_tooltip = {
						tooltip = KAN_OPERATION_AVAILABLE_tt
						has_completed_focus = KAN_OPERATION_CHILD_CRY_surgical_strike
					}
					has_completed_focus = KAN_OPERATION_CHILD_CRY_surgical_strike
				}
				else_if = {
					limit = {
						check_variable = { guard_val = 6 }
					}
					custom_trigger_tooltip = {
						tooltip = KAN_OPERATION_AVAILABLE_tt
						has_completed_focus = KAN_OPERATION_RED_WAVE_signal_distraction
					}
					has_completed_focus = KAN_OPERATION_RED_WAVE_signal_distraction
				}
				else_if = {
					limit = {
						check_variable = { guard_val = 7 }
					}
					custom_trigger_tooltip = {
						tooltip = KAN_OPERATION_AVAILABLE_tt
						has_completed_focus = KAN_GREYACCOUNTS_strangle_wire
					}
					has_completed_focus = KAN_GREYACCOUNTS_strangle_wire
				}
				else_if = {
					limit = {
						check_variable = { guard_val = 8 }
					}
					custom_trigger_tooltip = {
						tooltip = KAN_OPERATION_AVAILABLE_tt
						has_completed_focus = KAN_EMPTYTRAINS_dummy_wagon
					}
					has_completed_focus = KAN_EMPTYTRAINS_dummy_wagon
				}
			}
		}
		
		#dirty = OMS_Gauntlet_Dirty
		
		dynamic_lists = {
			OMS_Gauntlet_NewGuardList = {
				array = OMS_Gauntlet_NewGuard_ID
				index = guard_idx
				value = guard_val
				entry_container = "TNO_OMS_Gauntlet_NewGuardList_Entry"
			}
		}
		
		visible = {
			AND = {
				original_tag = SBI
			}
		}
	}
	
}