Centered game selector window, small fixes.

This commit is contained in:
Bas de Jong
2025-09-18 12:48:16 +02:00
parent 0f6f8baee7
commit 74bd636239
3 changed files with 36 additions and 22 deletions

View File

@@ -9,7 +9,9 @@ import org.toop.server.backend.ServerManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.toop.server.backend.tictactoe.TicTacToeServer;
import org.toop.server.frontend.ConnectionManager; import org.toop.server.frontend.ConnectionManager;
import org.toop.server.frontend.TcpClient;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
@@ -19,7 +21,10 @@ public class Main {
public static void main(String[] args) throws ExecutionException, InterruptedException { public static void main(String[] args) throws ExecutionException, InterruptedException {
Logging.disableAllLogs(); Logging.disableAllLogs();
Logging.enableLogsForClass(ServerManager.class, Level.ALL); // Logging.enableLogsForClass(ServerManager.class, Level.ALL);
// Logging.enableLogsForClass(TicTacToeServer.class, Level.ALL);
// Logging.enableLogsForClass(TcpClient.class, Level.ALL);
// Logging.enableLogsForClass(ConnectionManager.class, Level.ALL);
initSystems(); initSystems();
registerEvents(); registerEvents();
@@ -39,9 +44,6 @@ public class Main {
Window.start(""); Window.start("");
*/ */
new Thread(() -> {
GameSelectorWindow gameSelectorWindow = new GameSelectorWindow();
}).start();
} }
/** /**

View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.toop.UI.GameSelectorWindow"> <form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.toop.UI.GameSelectorWindow">
<grid id="27dc6" binding="mainMenu" layout-manager="GridLayoutManager" row-count="9" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <grid id="27dc6" binding="mainMenu" layout-manager="GridLayoutManager" row-count="10" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/> <margin top="10" left="10" bottom="10" right="10"/>
<constraints> <constraints>
<xy x="20" y="20" width="500" height="400"/> <xy x="20" y="20" width="482" height="404"/>
</constraints> </constraints>
<properties> <properties>
<opaque value="true"/> <opaque value="true"/>
@@ -13,7 +13,7 @@
<children> <children>
<component id="ed019" class="javax.swing.JTextField" binding="nameTextField"> <component id="ed019" class="javax.swing.JTextField" binding="nameTextField">
<constraints> <constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"> <grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/> <preferred-size width="150" height="-1"/>
</grid> </grid>
</constraints> </constraints>
@@ -23,12 +23,12 @@
</component> </component>
<vspacer id="4e05c"> <vspacer id="4e05c">
<constraints> <constraints>
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> <grid row="9" column="2" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
</vspacer> </vspacer>
<component id="1d2f1" class="javax.swing.JLabel"> <component id="1d2f1" class="javax.swing.JLabel">
<constraints> <constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<text value="Name:"/> <text value="Name:"/>
@@ -36,7 +36,7 @@
</component> </component>
<component id="70d8c" class="javax.swing.JLabel"> <component id="70d8c" class="javax.swing.JLabel">
<constraints> <constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<text value="Welcome to ISY games selector!"/> <text value="Welcome to ISY games selector!"/>
@@ -44,7 +44,7 @@
</component> </component>
<component id="5cc82" class="javax.swing.JTextField" binding="name2TextField"> <component id="5cc82" class="javax.swing.JTextField" binding="name2TextField">
<constraints> <constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"> <grid row="3" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/> <preferred-size width="150" height="-1"/>
</grid> </grid>
</constraints> </constraints>
@@ -54,12 +54,12 @@
</component> </component>
<hspacer id="27f2a"> <hspacer id="27f2a">
<constraints> <constraints>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/> <grid row="3" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
</hspacer> </hspacer>
<component id="3874e" class="javax.swing.JLabel" binding="fillAllFields"> <component id="3874e" class="javax.swing.JLabel" binding="fillAllFields">
<constraints> <constraints>
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <grid row="8" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<enabled value="true"/> <enabled value="true"/>
@@ -70,7 +70,7 @@
</component> </component>
<component id="a2f0" class="javax.swing.JButton" binding="connectButton" default-binding="true"> <component id="a2f0" class="javax.swing.JButton" binding="connectButton" default-binding="true">
<constraints> <constraints>
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> <grid row="7" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<text value="Connect"/> <text value="Connect"/>
@@ -78,7 +78,7 @@
</component> </component>
<component id="6a4c6" class="javax.swing.JTextField" binding="ipTextField"> <component id="6a4c6" class="javax.swing.JTextField" binding="ipTextField">
<constraints> <constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"> <grid row="4" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/> <preferred-size width="150" height="-1"/>
</grid> </grid>
</constraints> </constraints>
@@ -86,7 +86,7 @@
</component> </component>
<component id="4214e" class="javax.swing.JComboBox" binding="gameSelectorBox"> <component id="4214e" class="javax.swing.JComboBox" binding="gameSelectorBox">
<constraints> <constraints>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/> <grid row="6" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<model/> <model/>
@@ -94,7 +94,7 @@
</component> </component>
<component id="4225c" class="javax.swing.JTextField" binding="portTextField"> <component id="4225c" class="javax.swing.JTextField" binding="portTextField">
<constraints> <constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"> <grid row="5" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/> <preferred-size width="150" height="-1"/>
</grid> </grid>
</constraints> </constraints>
@@ -102,7 +102,7 @@
</component> </component>
<component id="43a89" class="javax.swing.JLabel"> <component id="43a89" class="javax.swing.JLabel">
<constraints> <constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<text value="Select game:"/> <text value="Select game:"/>
@@ -110,7 +110,7 @@
</component> </component>
<component id="3abc3" class="javax.swing.JLabel"> <component id="3abc3" class="javax.swing.JLabel">
<constraints> <constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<text value="Port:"/> <text value="Port:"/>
@@ -118,7 +118,7 @@
</component> </component>
<component id="514db" class="javax.swing.JLabel"> <component id="514db" class="javax.swing.JLabel">
<constraints> <constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<text value="IP:"/> <text value="IP:"/>
@@ -126,12 +126,22 @@
</component> </component>
<component id="5723c" class="javax.swing.JLabel"> <component id="5723c" class="javax.swing.JLabel">
<constraints> <constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<text value="Name 2:"/> <text value="Name 2:"/>
</properties> </properties>
</component> </component>
<hspacer id="2e34c">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<vspacer id="93fc6">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
</children> </children>
</grid> </grid>
</form> </form>

View File

@@ -118,9 +118,11 @@ public class TicTacToeServer extends TcpServer {
this.endGame((String) command.arguments.getFirst()); this.endGame((String) command.arguments.getFirst());
this.sendQueue.offer("svr game ended successfully"); this.sendQueue.offer("svr game ended successfully");
} else if (command.command == TicTacToeServerCommand.LOGIN) { } else if (command.command == TicTacToeServerCommand.LOGIN) {
this.endGame((String) command.arguments.getFirst());
this.sendQueue.offer("svr login successful"); this.sendQueue.offer("svr login successful");
} else if (command.command == TicTacToeServerCommand.SUBSCRIBE) { } else if (command.command == TicTacToeServerCommand.SUBSCRIBE) {
this.sendQueue.offer("svr added to "); this.endGame((String) command.arguments.getFirst());
this.sendQueue.offer("svr added {} to the queue");
} }
} }