package eu.smoser.dungeongenerator.main;

import eu.smoser.dungeongenerator.dungeon.Dungeon;
import eu.smoser.dungeongenerator.dungeon.objects.Encounters;

import javax.swing.*;
import java.util.Objects;

/**
 *
 * @author MrMcX
 */
public class EncounterGenerator extends AGenerator {
    private static final long serialVersionUID = 1L;

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @Override
    void cInitComponents(JButton jButtonStart, JLabel jLabel1, JPanel jPanel1) {
        JLabel jLabel2 = new JLabel();
        Box.Filler filler3 = new Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 0));
        jCombo = new JComboBox<>();
        setTitle("Zufallsbegegnungen generieren");
        setMinimumSize(new java.awt.Dimension(800, 600));
        setName("Zufallsbegegnungen");
        jButtonStart.setText("Zufallsbegegnungen starten");
        jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
        jLabel1.setText("Begegnungen");
        jPanel1.add(jLabel1);
        jPanel1.add(filler3);
        jLabel2.setText("Dungeonart");
        jPanel1.add(jLabel2);
        jCombo.setModel(new DefaultComboBoxModel<>(new String[] { "Natürlich", "Künstlich" }));
        jPanel1.add(jCombo);
    }

    @Override
    String getText() {
        Encounters e = new Encounters((int) jSpinner.getValue(), Objects.equals(jCombo.getSelectedItem(), "Natürlich") ? Dungeon.Type.NATURAL : Dungeon.Type.ARTIFICIAL);
        return e.toString();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        /* Set the Nimbus look and feel */
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(EncounterGenerator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        /* Create and display the form */
        java.awt.EventQueue.invokeLater(() -> new EncounterGenerator().setVisible(true));
    }

    private JComboBox<String> jCombo;
}
