scripted_gui = {
    TNO_QIN_LegYuan_Open = {
        context_type = player_context
        parent_window_token = politics_tab
        window_name = "TNO_QIN_LegYuan_menu_open"
        visible = {
            tag = QIN
            has_completed_focus = QIN_demons_of_factionalism
        }
        effects = {
            TNO_QIN_LegYuan_menu_open_button_click = {
                if = {
                    limit = {
                        NOT = {
                            has_country_flag = QIN_LegYuan_GUI_Visible_Flag
                            has_country_flag = open_parliament_gui
                            has_country_flag = QIN_LegYuan_Acts_List_Visible
                        }
                    }
                    set_country_flag = QIN_LegYuan_GUI_Visible_Flag
                    set_country_flag = open_parliament_gui
                    set_country_flag = QIN_LegYuan_Acts_List_Visible
                }
                else = { 
                    clr_country_flag = QIN_LegYuan_GUI_Visible_Flag
                    clr_country_flag = open_parliament_gui
                    clr_country_flag = QIN_LegYuan_Acts_List_Visible
                }
                clr_country_flag = gui_alert_visible
            }
        }
        triggers = {
            gui_alert_visible = {
                has_country_flag = gui_alert_visible
            }
        }
    }

    TNO_QIN_LegYuan_GUI_main_menu = {
        context_type = player_context
        parent_window_token = top_bar
        window_name = "TNO_QIN_LegYuan_GUI_main"
        visible = {
            has_country_flag = QIN_LegYuan_GUI_Visible_Flag
            has_country_flag = open_parliament_gui
        }
        effects = {
            TNO_QIN_LegYuan_GUI_close_button_click = {
                clr_country_flag = QIN_LegYuan_GUI_Visible_Flag
                clr_country_flag = open_parliament_gui
            }
            refresh_button_click = {
                SAMPLE_init_parliament = yes
            }
            # NEW BUTTONS
            QIN_LegYuan_CIV_button_click = {
                set_country_flag = QIN_LegYuan_CIV
                set_variable = { var = Act_Logo_Var value = 2 }
                country_event = { id = legyuan.1 }
            }
            QIN_LegYuan_MIL_button_click = {
                set_country_flag = QIN_LegYuan_MIL
                set_variable = { var = Act_Logo_Var value = 1 }
                country_event = { id = legyuan.2 }
            }
            QIN_LegYuan_OPP_button_click = {
                set_country_flag = QIN_LegYuan_OPP
                set_variable = { var = Act_Logo_Var value = 3 }
                country_event = { id = legyuan.3 }
            }
        }
        dynamic_lists = {
            past_ordinance_list = { 
                array = QIN_ordinance_history_array
                entry_container = "Ordinance_History_Entry"
                index = ordinance_idx
            }
            LegYuan_diagram = {
                array = QIN_seat_x
                change_scope = no
                entry_container = LegYuan_GUI
                index = seat_idx
            }
        }
        triggers = {
            QIN_LegYuan_CIV_button_click_enabled = {
                NOT = { has_country_flag = QIN_LegYuan_Cooldown has_country_flag = QIN_LegYuan_Cooldown_2 }
                NOT = {
                    has_country_flag = QIN_ordinance_6_used
                    has_country_flag = QIN_ordinance_7_used
                    has_country_flag = QIN_ordinance_8_used
                }
            }
            QIN_LegYuan_MIL_button_click_enabled = {
                NOT = { has_country_flag = QIN_LegYuan_Cooldown has_country_flag = QIN_LegYuan_Cooldown_2 }
                NOT = {
                    has_country_flag = QIN_ordinance_9_used
                    has_country_flag = QIN_ordinance_10_used
                    has_country_flag = QIN_ordinance_11_used
                }
            }
            QIN_LegYuan_OPP_button_click_enabled = {
                NOT = { has_country_flag = QIN_LegYuan_Cooldown has_country_flag = QIN_LegYuan_Cooldown_2 }
                NOT = {
                    has_country_flag = QIN_ordinance_12_used
                    has_country_flag = QIN_ordinance_13_used
                    has_country_flag = QIN_ordinance_14_used
                }
            }
        }
		properties = {
            TNO_QIN_Current_Act_Logo_Image = {
                image = "[QIN_logo_stuff]"
            }
            entry_bg_dynamic = {
                image = "[GetOrdinanceHistorySprite]"
            }
            LegYuan_Seat = {
                x = QIN_seat_x^seat_idx
                y = QIN_seat_y^seat_idx
                frame = QIN_seat_frame^seat_idx
            }
		}
    }
}
