scripted_gui = {

    dating_gui = {
        window_name = "dating_gui_window"
        context_type = player_context

        ai_test_interval = 500
        ai_test_variance = 0.5

        visible = {
            has_country_flag = dating_gui_open
        }

        effects = {
            dating_close_click = {
                clr_country_flag = dating_gui_open
            }
            stalin_click = {
                set_variable = { datingLeader = 1 }
            }
            fdr_click = {
                set_variable = { datingLeader = 2 }
            }
            vargas_click = {
                set_variable = { datingLeader = 3 }
            }
            linlithgow_click = {
                set_variable = { datingLeader = 4 }
            }
            hirohito_click = {
                set_variable = { datingLeader = 5 }
            }


            #Give Buttons
            gift_guns_click = {
                add_equipment_to_stockpile = {
                    type = infantry_equipment
                    amount = -10000
                }
                set_variable = {
                    conf_box_var = 1
                }
                increase_opinion_10 = yes
            }
            gift_planes_click = {
                if = {
                    limit = {
                        has_dlc = "By Blood Alone"
                    }
                    add_equipment_to_stockpile = {
                        type = small_plane_airframe_1
                        amount = -100
                    }
                }
                else = {
                    add_equipment_to_stockpile = {
                        type = fighter_equipment_1
                        amount = -100
                    }
                }
                set_variable = {
                    conf_box_var = 1
                }
                increase_opinion_10 = yes
            }
            gift_tanks_click = {
                if = {
                    limit = {
                        has_dlc = "No Step Back"
                    }
                    add_equipment_to_stockpile = {
                        type = light_tank_chassis_1
                        amount = -150
                    }
                }
                if = {
                    limit = {
                        NOT = {
                            has_dlc = "No Step Back"
                        }
                    }
                    add_equipment_to_stockpile = {
                        type = light_tank_equipment_1
                        amount = -150
                    }
                }
                set_variable = {
                    conf_box_var = 1
                }
                increase_opinion_10 = yes
            }
            gift_meds_click = {
                if = {
                    limit = {
                        has_dlc = "No Step Back"
                    }
                    add_equipment_to_stockpile = {
                        type = medium_tank_chassis_1
                        amount = -110
                    }
                }
                if = {
                    limit = {
                        NOT = {
                            has_dlc = "No Step Back"
                        }
                    }
                    add_equipment_to_stockpile = {
                        type = medium_tank_equipment_1
                        amount = -110
                    }
                }
                set_variable = {
                    conf_box_var = 1
                }
                increase_opinion_10 = yes
            }
            gift_heavies_click = {
                if = {
                    limit = {
                        has_dlc = "No Step Back"
                    }
                    add_equipment_to_stockpile = {
                        type = heavy_tank_chassis_1
                        amount = -150
                    }
                }
                if = {
                    limit = {
                        NOT = {
                            has_dlc = "No Step Back"
                        }
                    }
                    add_equipment_to_stockpile = {
                        type = heavy_tank_equipment_1
                        amount = -70
                    }
                }
                set_variable = {
                    conf_box_var = 1
                }
                increase_opinion_10 = yes
            }
            gift_pp_click = {
                add_political_power = -100
                set_variable = {
                    conf_box_var = 1
                }
                increase_opinion_10 = yes
            }
            give_headpat_click = {
                set_global_flag = used_headpat
                give_action = yes
            }
            give_hug_click = {
                set_global_flag = used_hug
                give_action = yes
            }
            give_smile_click = {
                set_global_flag = used_smile
                give_action = yes
            }
            give_wink_click = {
                set_global_flag = used_wink
                give_action = yes
            }
            conf_box_x_click = {
                set_variable = { conf_box_var = 0 }
            }

            ask_on_date_click = {
                set_global_flag = used_date
                set_variable = { success_var = 0 }
                set_variable = { datingLeader_ask = datingLeader }
                if = {
                    limit = {
                        check_variable = { datingLeader_ask = 1 }
                    }
                    set_variable = { opinion_check = one_opinion }
                    subtract_from_variable = {
                        var = one_opinion
                        value = 1
                    }
                }
                else_if = {
                    limit = {
                        check_variable = { datingLeader_ask = 2 }
                    }
                    set_variable = { opinion_check = two_opinion }
                    subtract_from_variable = {
                        var = two_opinion
                        value = 1
                    }
                }
                else_if = {
                    limit = {
                        check_variable = { datingLeader_ask = 3 }
                    }
                    set_variable = { opinion_check = three_opinion }
                    subtract_from_variable = {
                        var = three_opinion
                        value = 1
                    }
                }
                else_if = {
                    limit = {
                        check_variable = { datingLeader_ask = 4 }
                    }
                    set_variable = { opinion_check = four_opinion }
                    subtract_from_variable = {
                        var = four_opinion
                        value = 1
                    }
                }
                else_if = {
                    limit = {
                        check_variable = { datingLeader_ask = 5 }
                    }
                    set_variable = { opinion_check = five_opinion }
                    subtract_from_variable = {
                        var = five_opinion
                        value = 1
                    }
                }

                if = {
                    limit = {
                        check_variable = { opinion_check > 99 }
                    }
                    set_variable = { success_var = 1 }
                }
                else_if = {
                    limit = {
                        check_variable = { opinion_check > 74 }
                    }
                    random_list = {
                        60 = {
                            set_variable = { success_var = 1 }
                        }
                        40 = {
                            set_variable = { success_var = 0 }
                        }
                    }
                }
                else_if = {
                    limit = {
                        check_variable = { opinion_check > 49 }
                    }
                    random_list = {
                        50 = {
                            set_variable = { success_var = 1 }
                        }
                        50 = {
                            set_variable = { success_var = 0 }
                        }
                    }
                }
                else_if = {
                    limit = {
                        check_variable = { opinion_check > 39 }
                    }
                    random_list = {
                        40 = {
                            set_variable = { success_var = 1 }
                        }
                        60 = {
                            set_variable = { success_var = 0 }
                        }
                    }
                }
                else_if = {
                    limit = {
                        check_variable = { opinion_check > 29 }
                    }
                    random_list = {
                        35 = {
                            set_variable = { success_var = 1 }
                        }
                        65 = {
                            set_variable = { success_var = 0 }
                        }
                    }
                }
                else_if = {
                    limit = {
                        check_variable = { opinion_check > 19 }
                    }
                    random_list = {
                        10 = {
                            set_variable = { success_var = 1 }
                        }
                        90 = {
                            set_variable = { success_var = 0 }
                        }
                    }
                }

                if = {
                    limit = {
                        check_variable = { success_var = 1 }
                    }
                    if = {
                        limit = {
                            check_variable = { datingLeader_ask = 1 }
                        }
                        if = {
                            limit = {
                                check_variable = { oneHearts = 0 }
                            }
                            country_event = { id = fbavariad.1 }
                        }
                        else_if = {
                            limit = {
                                check_variable = { oneHearts = 1 }
                            }
                            country_event = { id = fbavariad.2 }
                        }
                        else_if = {
                            limit = {
                                check_variable = { oneHearts = 2 }
                            }
                            country_event = { id = fbavariad.4 }
                        }
                        add_to_variable = {
                            var = oneHearts
                            value = 1
                        }
                        subtract_from_variable = {
                            var = one_opinion
                            value = 30
                        }
                    }
                    else_if = {
                        limit = {
                            check_variable = { datingLeader_ask = 2 }
                        }
                        if = {
                            limit = {
                                check_variable = { twoHearts = 0 }
                            }
                            country_event = { id = fbavariad.7 }
                        }
                        else_if = {
                            limit = {
                                check_variable = { twoHearts = 1 }
                            }
                            country_event = { id = fbavariad.8 }
                        }
                        else_if = {
                            limit = {
                                check_variable = { twoHearts = 2 }
                            }
                            country_event = { id = fbavariad.10 }
                        }
                        add_to_variable = {
                            var = twoHearts
                            value = 1
                        }
                        subtract_from_variable = {
                            var = two_opinion
                            value = 30
                        }
                        
                    }
                    else_if = {
                        limit = {
                            check_variable = { datingLeader_ask = 3 }
                        }
                        if = {
                            limit = {
                                check_variable = { threeHearts = 0 }
                            }
                            country_event = { id = fbavariad.13 }
                        }
                        else_if = {
                            limit = {
                                check_variable = { threeHearts = 1 }
                            }
                            country_event = { id = fbavariad.14 }
                        }
                        else_if = {
                            limit = {
                                check_variable = { threeHearts = 2 }
                            }
                            country_event = { id = fbavariad.16 }
                        }
                        add_to_variable = {
                            var = threeHearts
                            value = 1
                        }
                        subtract_from_variable = {
                            var = three_opinion
                            value = 30
                        }
                        
                    }
                    else_if = {
                        limit = {
                            check_variable = { datingLeader_ask = 4 }
                        }
                        if = {
                            limit = {
                                check_variable = { fourHearts = 0 }
                            }
                            country_event = { id = fbavariad.19 }
                        }
                        else_if = {
                            limit = {
                                check_variable = { fourHearts = 1 }
                            }
                            country_event = { id = fbavariad.20 }
                        }
                        else_if = {
                            limit = {
                                check_variable = { fourHearts = 2 }
                            }
                           country_event = { id = fbavariad.22 }
                        }
                        add_to_variable = {
                            var = fourHearts
                            value = 1
                        }
                        subtract_from_variable = {
                            var = four_opinion
                            value = 30
                        }
                        
                    }
                    else_if = {
                        limit = {
                            check_variable = { datingLeader_ask = 5 }
                        }
                        if = {
                            limit = {
                                check_variable = { fiveHearts = 0 }
                            }
                            country_event = { id = fbavariad.25 }
                        }
                        else_if = {
                            limit = {
                                check_variable = { fiveHearts = 1 }
                            }
                            country_event = { id = fbavariad.26 }
                        }
                        else_if = {
                            limit = {
                                check_variable = { fiveHearts = 2 }
                            }
                            country_event = { id = fbavariad.28 }
                        }
                        add_to_variable = {
                            var = fiveHearts
                            value = 1
                        }
                        subtract_from_variable = {
                            var = five_opinion
                            value = 30
                        }
                    }
                }
                else = {
                    random_list = {
                        20 = {
                            set_variable = {
                                var = conf_box_title_var
                                value = 6
                            }
                        }
                        20 = {
                            set_variable = {
                                var = conf_box_title_var
                                value = 7
                            }
                        }
                        20 = {
                            set_variable = {
                                var = conf_box_title_var
                                value = 8
                            }
                        }
                        20 = {
                            set_variable = {
                                var = conf_box_title_var
                                value = 9
                            }
                        }
                        20 = {
                            set_variable = {
                                var = conf_box_title_var
                                value = 10
                            }
                        }
                    }
                    set_variable = {
                        var = conf_box_var
                        value = 5
                    }
                }
                
            }




        }

        triggers = {
            stalin_selected_visible = {
                check_variable = { datingLeader = 1 }
            }
            fdr_selected_visible = {
                check_variable = { datingLeader = 2 }
            }
            vargas_selected_visible = {
                check_variable = { datingLeader = 3 }
            }
            linlithgow_selected_visible = {
                check_variable = { datingLeader = 4 }
            }
            hirohito_selected_visible = {
                check_variable = { datingLeader = 5 }
            }

            stalin_gone_visible = {
                NOT = {
                    SOV = {
                        has_country_leader = {
                            name = "Iosif Stalin"
                            ruling_only = yes
                        }
                    }
                }
            }
            fdr_gone_visible = {
                NOT = {
                    USA = {
                        has_country_leader = {
                            name = "Franklin Delano Roosevelt"
                            ruling_only = yes
                        }
                    }
                }
            }
            vargas_gone_visible = {
                NOT = {
                    BRA = {
                        has_country_leader = {
                            name = "Getúlio Vargas"
                            ruling_only = yes
                        }
                    }
                }
            }
            linlithgow_gone_visible = {
                NOT = {
                    RAJ = {
                        has_country_leader = {
                            name = "Lord Linlithgow"
                            ruling_only = yes
                        }
                    }
                }
            }
            hirohito_gone_visible = {
                NOT = {
                    JAP = {
                        has_country_leader = {
                            name = "Hirohito"
                            ruling_only = yes
                        }
                    }
                }
            }
            ask_on_date_off_visible = {
                OR = {
                    has_global_flag = {
                        flag = used_date
                        days < 10
                    }
                    check_variable = { datingLeader = 0 }
                    AND = {
                        check_variable = { datingLeader = 5 }
                        check_variable = { fiveHearts = 3 }
                    }
                    AND = {
                        check_variable = { datingLeader = 4 }
                        check_variable = { fourHearts = 3 }
                    }
                    AND = {
                        check_variable = { datingLeader = 3 }
                        check_variable = { threeHearts = 3 }
                    }
                    AND = {
                        check_variable = { datingLeader = 2 }
                        check_variable = { twoHearts = 3 }
                    }
                    AND = {
                        check_variable = { datingLeader = 1 }
                        check_variable = { oneHearts = 3 }
                    }
                }
            }

            stalin_portrait_visible = {
                check_variable = { datingLeader = 1 }
            }
            fdr_portrait_visible = {
                check_variable = { datingLeader = 2 }
            }
            vargas_portrait_visible = {
                check_variable = { datingLeader = 3 }
            }
            linlithgow_portrait_visible = {
                check_variable = { datingLeader = 4 }
            }
            hirohito_portrait_visible = {
                check_variable = { datingLeader = 5 }
            }
            dating_frame_visible = {
                check_variable = { datingLeader > 0 }
            }
            stalin_text_visible = {
                check_variable = { datingLeader = 1 }
            }
            fdr_text_visible = {
                check_variable = { datingLeader = 2 }
            }
            vargas_text_visible = {
                check_variable = { datingLeader = 3 }
            }
            linlithgow_text_visible = {
                check_variable = { datingLeader = 4 }
            }
            hirohito_text_visible = {
                check_variable = { datingLeader = 5 }
            }

            #Hearts
            hearts_visible = {
                OR = {
                    AND = {
                        check_variable = { datingLeader = 5 }
                        check_variable = { fiveHearts = 3 }
                    }
                    AND = {
                        check_variable = { datingLeader = 4 }
                        check_variable = { fourHearts = 3 }
                    }
                    AND = {
                        check_variable = { datingLeader = 3 }
                        check_variable = { threeHearts = 3 }
                    }
                    AND = {
                        check_variable = { datingLeader = 2 }
                        check_variable = { twoHearts = 3 }
                    }
                    AND = {
                        check_variable = { datingLeader = 1 }
                        check_variable = { oneHearts = 3 }
                    }
                }
            }
            hearts2_visible = {
                OR = {
                    AND = {
                        check_variable = { datingLeader = 5 }
                        check_variable = { fiveHearts = 2 }
                    }
                    AND = {
                        check_variable = { datingLeader = 4 }
                        check_variable = { fourHearts = 2 }
                    }
                    AND = {
                        check_variable = { datingLeader = 3 }
                        check_variable = { threeHearts = 2 }
                    }
                    AND = {
                        check_variable = { datingLeader = 2 }
                        check_variable = { twoHearts = 2 }
                    }
                    AND = {
                        check_variable = { datingLeader = 1 }
                        check_variable = { oneHearts = 2 }
                    }
                }
            }
            hearts1_visible = {
                OR = {
                    AND = {
                        check_variable = { datingLeader = 5 }
                        check_variable = { fiveHearts = 1 }
                    }
                    AND = {
                        check_variable = { datingLeader = 4 }
                        check_variable = { fourHearts = 1 }
                    }
                    AND = {
                        check_variable = { datingLeader = 3 }
                        check_variable = { threeHearts = 1 }
                    }
                    AND = {
                        check_variable = { datingLeader = 2 }
                        check_variable = { twoHearts = 1 }
                    }
                    AND = {
                        check_variable = { datingLeader = 1 }
                        check_variable = { oneHearts = 1 }
                    }
                }
            }
            hearts0_visible = {
                OR = {
                    AND = {
                        check_variable = { datingLeader = 5 }
                        check_variable = { fiveHearts = 0 }
                    }
                    AND = {
                        check_variable = { datingLeader = 4 }
                        check_variable = { fourHearts = 0 }
                    }
                    AND = {
                        check_variable = { datingLeader = 3 }
                        check_variable = { threeHearts = 0 }
                    }
                    AND = {
                        check_variable = { datingLeader = 2 }
                        check_variable = { twoHearts = 0 }
                    }
                    AND = {
                        check_variable = { datingLeader = 1 }
                        check_variable = { oneHearts = 0 }
                    }
                }
            }


            #Buttons Off
            gift_guns0_visible = {
                OR = {
                    NOT = {
                        has_equipment = {
                            infantry_equipment > 9999
                        }
                    }
                    check_variable = { datingLeader = 0 }
                }
            }
            gift_planes0_visible = {
                OR = {
                    NOT = {
                        if = {
                            limit = {
                                has_dlc = "By Blood Alone"
                            }
                            has_equipment = {
                                small_plane_airframe_1 > 99
                            }
                        }
                        else = {
                            has_equipment = {
                                fighter_equipment_1 > 99
                            }
                        }
                    }
                    check_variable = { datingLeader = 0 }
                }
            }
            gift_tanks0_visible = {
                OR = {
                    NOT = {
                        if = {
                            limit = {
                                has_dlc = "No Step Back"
                            }
                            has_equipment = {
                                light_tank_chassis_1 > 149
                            }
                        }
                        else = {
                            has_equipment = {
                                light_tank_equipment_1 > 149
                            }
                        }
                    }
                    check_variable = { datingLeader = 0 }
                }
            }
            gift_meds0_visible = {
                OR = {
                    NOT = {
                        if = {
                            limit = {
                                has_dlc = "No Step Back"
                            }
                            has_equipment = {
                                medium_tank_chassis_1 > 109
                            }
                        }
                        else = {
                            has_equipment = {
                                medium_tank_equipment_1 > 109
                            }
                        }
                    }
                    check_variable = { datingLeader = 0 }
                }
            }
            gift_heavies0_visible = {
                OR = {
                    NOT = {
                        if = {
                            limit = {
                                has_dlc = "No Step Back"
                            }
                            has_equipment = {
                                heavy_tank_chassis_1 > 109
                            }
                        }
                        else = {
                            has_equipment = {
                                heavy_tank_equipment_1 > 109
                            }
                        }
                    }
                    check_variable = { datingLeader = 0 }
                }
            }
            gift_pp0_visible = {
                OR = {
                has_political_power < 100
                check_variable = { datingLeader = 0 }
                }
            }
            give_headpat0_visible = {
                OR = {
                    has_global_flag = {
                        flag = used_headpat
                        days < 30
                    }
                check_variable = { datingLeader = 0 }
                }
            }
            give_hug0_visible = {
                OR = {
                    has_global_flag = {
                        flag = used_hug
                        days < 30
                    }
                check_variable = { datingLeader = 0 }
                }
            }
            give_smile0_visible = {
                OR = {
                    has_global_flag = {
                        flag = used_smile
                        days < 30
                    }
                check_variable = { datingLeader = 0 }
                }
            }
            give_wink0_visible = {
                OR = {
                    has_global_flag = {
                        flag = used_wink
                        days < 30
                    }
                    check_variable = { datingLeader = 0 }
                }
            }



            #Conf Box
            conf_box_visible = {
                check_variable = { conf_box_var > 0 }
            }

            conf_box_x_visible = {
                check_variable = { conf_box_var > 0 }
            }

            conf_box_text_1_visible = {
                check_variable = { conf_box_var = 1 }
            }
            conf_box_text_2_visible = {
                check_variable = { conf_box_var = 2 }
            } 
            conf_box_text_3_visible = {
                check_variable = { conf_box_var = 3 }
            } 
            conf_box_text_4_visible = {
                check_variable = { conf_box_var = 4 }
            }
            conf_box_text_5_visible = {
                check_variable = { conf_box_var = 5 }
            }

            

            conf_box_title_1_visible = {
                check_variable = { conf_box_title_var = 1 }
                check_variable = { conf_box_var > 0 }
            }
            conf_box_title_2_visible = {
                check_variable = { conf_box_title_var = 2 }
                check_variable = { conf_box_var > 0 }
            } 
            conf_box_title_3_visible = {
                check_variable = { conf_box_title_var = 3 }
                check_variable = { conf_box_var > 0 }
            } 
            conf_box_title_4_visible = {
                check_variable = { conf_box_title_var = 4 }
                check_variable = { conf_box_var > 0 }
            } 
            conf_box_title_5_visible = {
                check_variable = { conf_box_title_var = 5 }
                check_variable = { conf_box_var > 0 }
            }
            conf_box_title_6_visible = {
                check_variable = { conf_box_title_var = 6 }
                check_variable = { conf_box_var > 0 }
            }
            conf_box_title_7_visible = {
                check_variable = { conf_box_title_var = 7 }
                check_variable = { conf_box_var > 0 }
            } 
            conf_box_title_8_visible = {
                check_variable = { conf_box_title_var = 8 }
                check_variable = { conf_box_var > 0 }
            } 
            conf_box_title_9_visible = {
                check_variable = { conf_box_title_var = 9 }
                check_variable = { conf_box_var > 0 }
            } 
            conf_box_title_10_visible = {
                check_variable = { conf_box_title_var = 10 }
                check_variable = { conf_box_var > 0 }
            }
            conf_box_title_11_visible = {
                check_variable = { conf_box_title_var = 11 }
                check_variable = { conf_box_var > 0 }
            }



            #Tips
            tip1_visible = {
                check_variable = { tip_var = 1 }
            }
            tip2_visible = {
                check_variable = { tip_var = 2 }
            }
            tip3_visible = {
                check_variable = { tip_var = 3 }
            }
            tip4_visible = {
                check_variable = { tip_var = 4 }
            }
            tip5_visible = {
                check_variable = { tip_var = 5 }
            }
            tip6_visible = {
                check_variable = { tip_var = 6 }
            }
            tip7_visible = {
                check_variable = { tip_var = 7 }
            }
            tip8_visible = {
                check_variable = { tip_var = 8 }
            }
            tip9_visible = {
                check_variable = { tip_var = 9 }
            }
            tip10_visible = {
                check_variable = { tip_var = 10 }
            }
            tip11_visible = {
                check_variable = { tip_var = 11 }
            }
            tip12_visible = {
                check_variable = { tip_var = 12 }
            }
        }




        dynamic_lists = {
        }

        properties = {
        }

        ai_enabled = {
            always = no
        }

        ai_check = {
        }

        ai_check_scope = {
        }

        ai_weights = {
        }
    }

}
