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
Database Update
This commit is contained in:
Binary file not shown.
@@ -1281,3 +1281,145 @@ SELECT * FROM GAMEINFO WHERE NAME="DUstinkst" [42122-200]
|
||||
org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax Fehler in SQL Befehl "SELECT * FROM GAMEINFO WHERE NAME 'DUstinkst'[*]"
|
||||
Syntax error in SQL statement "SELECT * FROM GAMEINFO WHERE NAME 'DUstinkst'[*]"; SQL statement:
|
||||
select * from gameInfo where name 'DUstinkst' [42000-200]
|
||||
2021-12-01 11:00:51 jdbc[3]: exception
|
||||
java.sql.SQLClientInfoException: Client info name 'ApplicationName' not supported.
|
||||
at org.h2.jdbc.JdbcConnection.setClientInfo(JdbcConnection.java:1749)
|
||||
at com.intellij.database.remote.jdbc.impl.RemoteConnectionImpl.setClientInfo(RemoteConnectionImpl.java:470)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
|
||||
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
|
||||
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
|
||||
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
|
||||
at java.base/java.security.AccessController.doPrivileged(Native Method)
|
||||
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
|
||||
at java.base/java.security.AccessController.doPrivileged(Native Method)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
|
||||
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
|
||||
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
|
||||
at java.base/java.lang.Thread.run(Thread.java:829)
|
||||
2021-12-01 11:00:59 jdbc[4]: exception
|
||||
java.sql.SQLClientInfoException: Client info name 'ApplicationName' not supported.
|
||||
at org.h2.jdbc.JdbcConnection.setClientInfo(JdbcConnection.java:1749)
|
||||
at com.intellij.database.remote.jdbc.impl.RemoteConnectionImpl.setClientInfo(RemoteConnectionImpl.java:470)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
|
||||
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
|
||||
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
|
||||
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
|
||||
at java.base/java.security.AccessController.doPrivileged(Native Method)
|
||||
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
|
||||
at java.base/java.security.AccessController.doPrivileged(Native Method)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
|
||||
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
|
||||
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
|
||||
at java.base/java.lang.Thread.run(Thread.java:829)
|
||||
2021-12-01 11:13:50 jdbc[3]: exception
|
||||
java.sql.SQLClientInfoException: Client info name 'ApplicationName' not supported.
|
||||
at org.h2.jdbc.JdbcConnection.setClientInfo(JdbcConnection.java:1749)
|
||||
at com.intellij.database.remote.jdbc.impl.RemoteConnectionImpl.setClientInfo(RemoteConnectionImpl.java:470)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
|
||||
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
|
||||
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
|
||||
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
|
||||
at java.base/java.security.AccessController.doPrivileged(Native Method)
|
||||
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
|
||||
at java.base/java.security.AccessController.doPrivileged(Native Method)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
|
||||
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
|
||||
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
|
||||
at java.base/java.lang.Thread.run(Thread.java:829)
|
||||
2021-12-01 11:13:50 jdbc[4]: exception
|
||||
java.sql.SQLClientInfoException: Client info name 'ApplicationName' not supported.
|
||||
at org.h2.jdbc.JdbcConnection.setClientInfo(JdbcConnection.java:1749)
|
||||
at com.intellij.database.remote.jdbc.impl.RemoteConnectionImpl.setClientInfo(RemoteConnectionImpl.java:470)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
|
||||
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
|
||||
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
|
||||
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
|
||||
at java.base/java.security.AccessController.doPrivileged(Native Method)
|
||||
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
|
||||
at java.base/java.security.AccessController.doPrivileged(Native Method)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
|
||||
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
|
||||
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
|
||||
at java.base/java.lang.Thread.run(Thread.java:829)
|
||||
2021-12-01 12:20:27 jdbc[4]: exception
|
||||
org.h2.jdbc.JdbcSQLSyntaxErrorException: Feld "GEN" nicht gefunden
|
||||
Column "GEN" not found; SQL statement:
|
||||
select gen from gameInfo where name = 'DUstinkst' [42122-200]
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:453)
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:429)
|
||||
at org.h2.message.DbException.get(DbException.java:205)
|
||||
at org.h2.message.DbException.get(DbException.java:181)
|
||||
at org.h2.expression.ExpressionColumn.getColumnException(ExpressionColumn.java:163)
|
||||
at org.h2.expression.ExpressionColumn.optimize(ExpressionColumn.java:145)
|
||||
at org.h2.command.dml.Select.prepare(Select.java:1206)
|
||||
at org.h2.command.Parser.prepareCommand(Parser.java:744)
|
||||
at org.h2.engine.Session.prepareLocal(Session.java:657)
|
||||
at org.h2.engine.Session.prepareCommand(Session.java:595)
|
||||
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1235)
|
||||
at org.h2.jdbc.JdbcStatement.executeQuery(JdbcStatement.java:78)
|
||||
at data.database.DataBase.resultSetSQL(DataBase.java:42)
|
||||
at data.database.DataBase.getGen(DataBase.java:165)
|
||||
at game.Control.getFromDatabase(Control.java:103)
|
||||
at game.Control.buildGameWindow(Control.java:68)
|
||||
at gui.GUI.buildGameWindow(GUI.java:81)
|
||||
at gui.MenuWindow$10.actionPerformed(MenuWindow.java:334)
|
||||
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
|
||||
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2313)
|
||||
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
|
||||
at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
|
||||
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
|
||||
at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
|
||||
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6626)
|
||||
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3389)
|
||||
at java.desktop/java.awt.Component.processEvent(Component.java:6391)
|
||||
at java.desktop/java.awt.Container.processEvent(Container.java:2266)
|
||||
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5001)
|
||||
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
|
||||
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4833)
|
||||
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948)
|
||||
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575)
|
||||
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516)
|
||||
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
|
||||
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2780)
|
||||
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4833)
|
||||
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
|
||||
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
|
||||
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
|
||||
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
|
||||
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
|
||||
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
|
||||
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:746)
|
||||
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:744)
|
||||
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
|
||||
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
|
||||
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:743)
|
||||
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
|
||||
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
|
||||
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
|
||||
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
|
||||
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
|
||||
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
|
||||
|
||||
@@ -121,46 +121,60 @@ public class DataBase {
|
||||
|
||||
}
|
||||
|
||||
public Boolean[][] getGrid(String gridName){
|
||||
public boolean[][] getGrid(String gridName){
|
||||
|
||||
connect();
|
||||
|
||||
|
||||
|
||||
ResultSet resultSet = resultSetSQL("select * from gameInfo where name = '"+gridName+"'");
|
||||
ResultSet resultInfo = resultSetSQL("select * from gameInfo where name = '"+gridName+"'");
|
||||
|
||||
try {
|
||||
resultSet.next();
|
||||
int id = resultSet.getInt("id");
|
||||
String name = resultSet.getString("name");
|
||||
int width = resultSet.getInt("width");
|
||||
int height = resultSet.getInt("height");
|
||||
int gen = resultSet.getInt("generation");
|
||||
resultInfo.next();
|
||||
int id = resultInfo.getInt("id");
|
||||
int width = resultInfo.getInt("width");
|
||||
int height = resultInfo.getInt("height");
|
||||
|
||||
resultInfo.close();
|
||||
|
||||
boolean[][] cells = new boolean[width][height];
|
||||
|
||||
ResultSet data = resultSetSQL("select * from gameData where id ="+id);
|
||||
data.next();
|
||||
System.out.println("");
|
||||
|
||||
ResultSet resultData = resultSetSQL("select * from gameData where id ="+id);
|
||||
|
||||
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
|
||||
cells[x][y] = false;
|
||||
}
|
||||
while (resultData.next()){
|
||||
cells[resultData.getInt("x")][resultData.getInt("y")] = true;
|
||||
}
|
||||
|
||||
return cells;
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
disconnect();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getGen(String gridName){
|
||||
connect();
|
||||
ResultSet resultSet = resultSetSQL("select generation from gameInfo where name = '"+gridName+"'");
|
||||
try {
|
||||
resultSet.next();
|
||||
int gen = resultSet.getInt("generation");
|
||||
disconnect();
|
||||
return gen;
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
disconnect();
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+16
-8
@@ -3,12 +3,9 @@ package game;
|
||||
import data.database.DataBase;
|
||||
import gui.GUI;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import static java.lang.Math.round;
|
||||
|
||||
public class Control {
|
||||
|
||||
private GUI gui;
|
||||
@@ -41,7 +38,7 @@ public class Control {
|
||||
clock.start();
|
||||
}
|
||||
|
||||
public void buildGameWindow(int xSize, int ySize, int cellCount, StartMode startMode) {
|
||||
public void buildGameWindow(int xSize, int ySize, int cellCount, String startMode) {
|
||||
this.xSize = xSize;
|
||||
this.ySize = ySize;
|
||||
this.cellCount = cellCount;
|
||||
@@ -58,15 +55,18 @@ public class Control {
|
||||
|
||||
switch (startMode) {
|
||||
|
||||
case Task1 -> {
|
||||
case "Task1" -> {
|
||||
generateTask1();
|
||||
}
|
||||
case Randomized -> {
|
||||
case "Randomized" -> {
|
||||
generateRandomized();
|
||||
}
|
||||
case Manuel -> {
|
||||
case "Manuel" -> {
|
||||
buildManuelGame();
|
||||
}
|
||||
default -> {
|
||||
getFromDatabase(startMode);
|
||||
}
|
||||
}
|
||||
|
||||
saveFirstGrid();
|
||||
@@ -76,7 +76,7 @@ public class Control {
|
||||
gui.createGameWindow(this.xSize, this.ySize, this.width, this.height);
|
||||
setRunning(true);
|
||||
|
||||
if (startMode == StartMode.Manuel) {
|
||||
if (startMode == "Manuel") {
|
||||
setRunning(false);
|
||||
gui.buildControlWindow();
|
||||
}
|
||||
@@ -97,6 +97,14 @@ public class Control {
|
||||
|
||||
}
|
||||
|
||||
private void getFromDatabase(String name){
|
||||
|
||||
cells = dataBase.getGrid(name);
|
||||
gen = dataBase.getGen(name);
|
||||
syncCells();
|
||||
|
||||
}
|
||||
|
||||
private void generateTask1() {
|
||||
for (int x = 0; x < xSize; x++) {
|
||||
for (int y = 0; y < ySize; y++) {
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ public class GUI {
|
||||
gameWindow.showGrid(grid);
|
||||
}
|
||||
|
||||
public void buildGameWindow(int xSize, int ySize, int cellCount, StartMode startMode){
|
||||
public void buildGameWindow(int xSize, int ySize, int cellCount, String startMode){
|
||||
control.buildGameWindow(xSize, ySize, cellCount, startMode);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package gui;
|
||||
|
||||
|
||||
import game.StartMode;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
@@ -333,11 +331,7 @@ public class MenuWindow {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
int index = modeBox.getSelectedIndex();
|
||||
|
||||
StartMode startMode = StartMode.values()[index + 1]; // + 1 BECAUSE MANUEL HAS THE FIRST INDEX IN ENUM
|
||||
|
||||
gui.buildGameWindow(xAxisSize, yAxisSize, cellCount, startMode);
|
||||
gui.buildGameWindow(xAxisSize, yAxisSize, cellCount, modeBox.getSelectedItem().toString());
|
||||
|
||||
menuWindow.setVisible(false);
|
||||
}
|
||||
@@ -359,7 +353,7 @@ public class MenuWindow {
|
||||
manuelStart.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gui.buildGameWindow(xAxisSize, yAxisSize, cellCount, StartMode.Manuel);
|
||||
gui.buildGameWindow(xAxisSize, yAxisSize, cellCount, "Manuel");
|
||||
menuWindow.setVisible(false);
|
||||
}
|
||||
});
|
||||
|
||||
+4
-3
@@ -2,6 +2,7 @@ package main;
|
||||
|
||||
|
||||
import data.database.DataBase;
|
||||
import game.Control;
|
||||
|
||||
public class Main {
|
||||
|
||||
@@ -13,8 +14,8 @@ public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// Control control = new Control();
|
||||
// control.start();
|
||||
Control control = new Control();
|
||||
control.start();
|
||||
DataBase dataBase = new DataBase();
|
||||
// dataBase.deleteTables();
|
||||
// dataBase.createTables();
|
||||
@@ -35,7 +36,7 @@ public class Main {
|
||||
//
|
||||
// System.out.println(dataBase.getAllGrids());
|
||||
|
||||
dataBase.getGrid("DUstinkst");
|
||||
// boolean[][] x = dataBase.getGrid("penis");
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user