diff --git a/src/game/Control.java b/src/game/Control.java index 65735a8..8fefd71 100644 --- a/src/game/Control.java +++ b/src/game/Control.java @@ -2,7 +2,6 @@ package game; import gui.GUI; -import java.util.ArrayList; import java.util.concurrent.ThreadLocalRandom; public class Control { @@ -139,7 +138,7 @@ public class Control { public void nextGen() { gen++; -// System.out.println("Generation:" + gen); + System.out.println("Generation:" + gen); for (int x = 0; x < xSize; x++) { for (int y = 0; y < ySize; y++) { @@ -164,7 +163,7 @@ public class Control { cells[x][y] = newcells[x][y]; } } - + gui.updateGameWindowTitle(gen); } // public void checkN(Boolean[][] arr, Boolean[][] futureGen, int columns, int rows) { @@ -196,6 +195,7 @@ public class Control { public boolean[][] nextGenBackup() { gen++; + // System.out.println("Generation:" + gen); for (int x = 0; x < xSize; x++) { @@ -227,6 +227,7 @@ public class Control { } } + return cells; } @@ -351,6 +352,10 @@ public class Control { nextGen(); } } + + public int getGeneration(){ + return gen; + } } diff --git a/src/gui/GUI.java b/src/gui/GUI.java index 5f991f5..511c16c 100644 --- a/src/gui/GUI.java +++ b/src/gui/GUI.java @@ -143,6 +143,14 @@ public class GUI { control.multipleGenSkip(generations); } + public int getGeneration(){ + return control.getGeneration(); + } + + public void updateGameWindowTitle(int gen){ + gameWindow.updateTitle(gen); + } + //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 2b7fe92..a491478 100644 --- a/src/gui/GameWindow.java +++ b/src/gui/GameWindow.java @@ -14,6 +14,8 @@ public class GameWindow { private final int cellCountX; private final int cellCountY; + private String title; + private int width, height; private final float ratio; @@ -23,8 +25,9 @@ public class GameWindow { this.cellCountX = cellCountX; this.cellCountY = cellCountY; + this.title = title; - gameWindow = new JFrame(title); + 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); @@ -157,6 +160,9 @@ public class GameWindow { public Point getPos(){ return gameWindow.getLocation(); } + public void updateTitle(int gen){ + gameWindow.setTitle(title + " Generation: " + gen); + } }