From 359b153460d1ed1341011e514b38e0579e6adc34 Mon Sep 17 00:00:00 2001 From: Noah Date: Tue, 30 Nov 2021 10:47:44 +0100 Subject: [PATCH] Contol Windwo Update. Velocity Change implemented. FONT and some other Var and method needs to be implemented in the GUI class not in Menu Window Update Velocity SLider to have the right Starting Value. --- src/game/Control.java | 4 ++++ src/gui/ControlWindow.java | 9 +++++---- src/gui/GUI.java | 4 ++++ src/gui/GameWindow.java | 4 ++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/game/Control.java b/src/game/Control.java index 8fefd71..48f9d13 100644 --- a/src/game/Control.java +++ b/src/game/Control.java @@ -327,6 +327,10 @@ public class Control { clock.setVelocity(velocity); } + public int getVelocity() { + return clock.getVelocity(); + } + public boolean isMouseLocked() { return mouseLocked; } diff --git a/src/gui/ControlWindow.java b/src/gui/ControlWindow.java index d370e85..ac51ecf 100644 --- a/src/gui/ControlWindow.java +++ b/src/gui/ControlWindow.java @@ -97,7 +97,7 @@ public class ControlWindow { velocitySlider.setBounds(120, 110, 230, 20); velocitySlider.setFont(text); velocitySlider.setForeground(Color.decode("#121212")); - velocitySlider.setValue(6); + velocitySlider.setValue(gui.getVelocity()); velocitySlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { @@ -117,7 +117,7 @@ public class ControlWindow { velocitySliderName.setForeground(Color.decode("#121212")); velocitySliderName.setVisible(true); - velocitySliderLabel = new JTextField("6"); + velocitySliderLabel = new JTextField(String.valueOf(gui.getVelocity())); velocitySliderLabel.setBackground(null); velocitySliderLabel.setBorder(null); velocitySliderLabel.setBounds(120, 80, 200, 30); @@ -251,7 +251,7 @@ public class ControlWindow { private void initMultibleGenSkip(){ multipleGenSkipButton = new JButton(); - multipleGenSkipButton.setText("Next Generation"); + multipleGenSkipButton.setText("Next Generation"); multipleGenSkipButton.setFont(text); multipleGenSkipButton.setForeground(Color.decode("#121212")); multipleGenSkipButton.setBorderPainted(true); @@ -270,9 +270,10 @@ public class ControlWindow { }); multipleGenSkipLable = new JTextField("6"); + multipleGenSkipLable.setOpaque(false); multipleGenSkipLable.setBackground(null); multipleGenSkipLable.setBorder(null); - multipleGenSkipLable.setBounds(50, 450, 200, 30); + multipleGenSkipLable.setBounds(160, 450, 50, 50); multipleGenSkipLable.setFont(text); multipleGenSkipLable.setForeground(Color.decode("#121212")); multipleGenSkipLable.setVisible(true); diff --git a/src/gui/GUI.java b/src/gui/GUI.java index 511c16c..a26677d 100644 --- a/src/gui/GUI.java +++ b/src/gui/GUI.java @@ -151,6 +151,10 @@ public class GUI { gameWindow.updateTitle(gen); } + public int getVelocity(){ + return control.getVelocity(); + } + //TODO: Delet this Methods. Those are shit. public void setVisibility(boolean value){ controlWindow.setVisibility(value); diff --git a/src/gui/GameWindow.java b/src/gui/GameWindow.java index a491478..2272163 100644 --- a/src/gui/GameWindow.java +++ b/src/gui/GameWindow.java @@ -27,7 +27,7 @@ public class GameWindow { this.title = title; - gameWindow = new JFrame(title + " Generation: " + gui.getGeneration()); + gameWindow = new JFrame(title + " | Generation: " + gui.getGeneration()); gameWindow.getContentPane().setPreferredSize(new Dimension(width + (2 * offset), height + (2 * offset))); gameWindow.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); @@ -161,7 +161,7 @@ public class GameWindow { return gameWindow.getLocation(); } public void updateTitle(int gen){ - gameWindow.setTitle(title + " Generation: " + gen); + gameWindow.setTitle(title + " | Generation: " + gen); }