/*
 * Created by JFormDesigner on Wed Mar 12 14:50:47 CST 2025
 */

package gui.UI_LenheartUI;

import gui.Start;
import gui.特殊控制台;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;

/**
 * @author dongj
 */
public class DropControl extends JPanel {
    public DropControl() {
        initComponents();
    }


    private void 保存配置(ActionEvent e) {
        // TODO add your code here

        特殊控制台.setTwConfig();
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents  @formatter:off
        scrollPane1 = new JScrollPane();
        table1 = new JTable();
        toggleButton1 = new JToggleButton();
        toggleButton2 = new JToggleButton();
        label1 = new JLabel();
        label2 = new JLabel();
        button19 = new JButton();

        //======== this ========
        setLayout(null);

        //======== scrollPane1 ========
        {

            //---- table1 ----
            table1.setModel(new DefaultTableModel(
                new Object[][] {
                },
                new String[] {
                    "\u9053\u5177\u4ee3\u7801", "\u91d1\u5e01\u7206\u7387", "\u7269\u54c1\u7206\u7387", "\u5f00\u59cb\u65f6\u95f4", "\u7ed3\u675f\u65f6\u95f4", "\u5355\u7269\u54c1\u6570\u91cf\u5806\u53e0"
                }
            ) {
                Class<?>[] columnTypes = new Class<?>[] {
                    Integer.class, Integer.class, Integer.class, String.class, String.class, Integer.class
                };
                @Override
                public Class<?> getColumnClass(int columnIndex) {
                    return columnTypes[columnIndex];
                }
            });
            scrollPane1.setViewportView(table1);
        }
        add(scrollPane1);
        scrollPane1.setBounds(18, 10, 1130, 550);

        //---- toggleButton1 ----
        toggleButton1.setIcon(new ImageIcon(getClass().getResource("/image/OFF3.png")));
        toggleButton1.setSelectedIcon(new ImageIcon(getClass().getResource("/image/ON3.png")));
        toggleButton1.setFocusPainted(false);
        toggleButton1.setContentAreaFilled(false);
        add(toggleButton1);
        toggleButton1.setBounds(15, 565, 100, 35);

        //---- toggleButton2 ----
        toggleButton2.setIcon(new ImageIcon(getClass().getResource("/image/OFF3.png")));
        toggleButton2.setSelectedIcon(new ImageIcon(getClass().getResource("/image/ON3.png")));
        toggleButton2.setFocusPainted(false);
        toggleButton2.setContentAreaFilled(false);
        add(toggleButton2);
        toggleButton2.setBounds(15, 605, 100, 35);

        //---- label1 ----
        label1.setText("\u591a\u500d\u7206\u7387\u5f00\u5173");
        add(label1);
        label1.setBounds(130, 570, 185, 30);

        //---- label2 ----
        label2.setText("\u591a\u7269\u54c1\u7206\u7387\u662f\u5426\u53e0\u52a0");
        add(label2);
        label2.setBounds(130, 605, 185, 30);

        //---- button19 ----
        button19.setText("\u4fdd\u5b58\u914d\u7f6e");
        button19.addActionListener(e -> 保存配置(e));
        add(button19);
        button19.setBounds(25, 645, 160, 35);

        {
            // compute preferred size
            Dimension preferredSize = new Dimension();
            for(int i = 0; i < getComponentCount(); i++) {
                Rectangle bounds = getComponent(i).getBounds();
                preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
            }
            Insets insets = getInsets();
            preferredSize.width += insets.right;
            preferredSize.height += insets.bottom;
            setMinimumSize(preferredSize);
            setPreferredSize(preferredSize);
        }
        // JFormDesigner - End of component initialization  //GEN-END:initComponents  @formatter:on


        this.toggleButton1.setSelected(Start.blkg == 1 ? true : false);
        this.toggleButton2.setSelected(Start.bldj == 1 ? true : false);

        Start.BLlist.forEach((obj) -> {
            Integer ItemId = obj.getItem_id();
            Integer GoldRate = obj.getGold_rate();
            Integer ItemRate = obj.getItem_rate();
            String Time = obj.getTime_range();
            Integer IsStack = obj.getStackableNum();

            DefaultTableModel tableModel = (DefaultTableModel) ItemTable.getModel();
            Object[] rowData = {ItemId, GiveCount ,NeedItemId, NeedCount};
            tableModel.addRow(rowData);
        });
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables  @formatter:off
    private JScrollPane scrollPane1;
    private JTable table1;
    private JToggleButton toggleButton1;
    private JToggleButton toggleButton2;
    private JLabel label1;
    private JLabel label2;
    private JButton button19;
    // JFormDesigner - End of variables declaration  //GEN-END:variables  @formatter:on
}
