diff --git a/lib/Conway-Game-Of-Live.mv.db b/lib/Conway-Game-Of-Live.mv.db index 51cb2f4..306f943 100644 Binary files a/lib/Conway-Game-Of-Live.mv.db and b/lib/Conway-Game-Of-Live.mv.db differ diff --git a/src/gui/ControlWindow.java b/src/gui/ControlWindow.java index 06bcdac..22e306a 100644 --- a/src/gui/ControlWindow.java +++ b/src/gui/ControlWindow.java @@ -27,6 +27,8 @@ public class ControlWindow { private JButton jump2GenButton; private JTextField multipleGenSkipLable; private JTextField jump2GenLable; + private JTextField saveGrid; + private JLabel saveGridPlaceholder; private int velocity, minVelocity = 1 , maxVelocity = 5000; @@ -87,6 +89,7 @@ public class ControlWindow { initClearButton(); initMultibleGenSkip(); initJump2Gen(); + initSaveGrid(); } private void initHeading(){ @@ -372,9 +375,43 @@ public class ControlWindow { }); } - private void initSaveButton(){} + private void initSaveGrid(){ - private void initSaveNameField(){} + saveGridPlaceholder = new JLabel("Save Grid..."); + saveGridPlaceholder.setBounds(50, 300, 300, 50); + saveGridPlaceholder.setFont(text); + saveGridPlaceholder.setForeground(Color.decode("#121212")); + saveGridPlaceholder.setVisible(true); + + saveGrid = new JTextField(); + saveGrid.setDocument(new JTextFieldLimit(10)); + saveGrid.setOpaque(false); + saveGrid.setBackground(null); + saveGrid.setBorder(null); + saveGrid.setBounds(50, 300, 300, 50); + saveGrid.setFont(text); + saveGrid.setForeground(Color.decode("#121212")); + saveGrid.setVisible(true); + saveGrid.addKeyListener(new KeyAdapter() { + public void keyTyped(KeyEvent evt) { + if (!(Character.isDigit(evt.getKeyChar()) || Character.isLetter(evt.getKeyChar()))) { + evt.consume(); + } + } + }); + saveGrid.addFocusListener(new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + saveGridPlaceholder.setVisible(false); + } + + @Override + public void focusLost(FocusEvent e) { + saveGridPlaceholder.setVisible(true); + } + }); + + } private void addComponents(){ controlWindow.add(heading); @@ -390,6 +427,8 @@ public class ControlWindow { controlWindow.add(jump2GenLable); controlWindow.add(multipleGenSkipButton); controlWindow.add(jump2GenButton); + controlWindow.add(saveGridPlaceholder); + controlWindow.add(saveGrid); } public void setVisibility(boolean value) { diff --git a/src/gui/JTextFieldLimit.java b/src/gui/JTextFieldLimit.java new file mode 100644 index 0000000..bdf6ed0 --- /dev/null +++ b/src/gui/JTextFieldLimit.java @@ -0,0 +1,27 @@ +package gui; + +import javax.swing.text.AttributeSet; +import javax.swing.text.BadLocationException; +import javax.swing.text.PlainDocument; + +class JTextFieldLimit extends PlainDocument { + private int limit; + JTextFieldLimit(int limit) { + super(); + this.limit = limit; + } + + JTextFieldLimit(int limit, boolean upper) { + super(); + this.limit = limit; + } + + public void insertString(int offset, String str, AttributeSet attr) throws BadLocationException { + if (str == null) + return; + + if ((getLength() + str.length()) <= limit) { + super.insertString(offset, str, attr); + } + } +} \ No newline at end of file diff --git a/src/main/Main.java b/src/main/Main.java index 9adca5d..058345f 100644 --- a/src/main/Main.java +++ b/src/main/Main.java @@ -5,9 +5,18 @@ import game.Control; public class Main { - //TODO: Inputfield witch Changelistner to cange Slider, Generic ActionListener. - //TODO: Window visibility, Control window create only one time. Visibility = false when game started, Visibility = true when game quited. :DONE Need a code Check when Brain is awake. - //TODO: Database + //TODO: Database Seve Button. Alert when Name is already is taken. + //TODO: Database window to Delete Entries. + //TODO: Save Velocity in DB + //TODO: Correct generation saving in DB and read out it + //TODO: Save button + //TODO: Reset game state when closing game + //TODO: Correct new Initialisation when game starts + //TODO: Change the population Rules + //TODO: Limit input length + + //TODO: Implement Corona Virus. Infected, Vaccinated, Recovered and Normal + //TODO: Implement a war mode.