Made ServerGui usable and prepared for 3.0
This commit is contained in:
parent
510cb9c295
commit
ffdd3e6dee
Binary file not shown.
|
@ -1,4 +1,4 @@
|
||||||
#Mon Apr 15 11:15:43 CEST 2019
|
#Sun Apr 28 11:53:19 CEST 2019
|
||||||
Load-File-on-startup=true
|
Load-File-on-startup=true
|
||||||
key2=44
|
key2=44
|
||||||
key1=29
|
key1=29
|
||||||
|
|
|
@ -14,7 +14,7 @@ public class UpdateChecker {
|
||||||
public void requestServerData(){
|
public void requestServerData(){
|
||||||
try {
|
try {
|
||||||
Socket socket = new Socket();
|
Socket socket = new Socket();
|
||||||
socket.connect(new InetSocketAddress(InetAddress.getByName(/*"cookiestudios.org"*/"localhost"), 9999), 2000);
|
socket.connect(new InetSocketAddress(InetAddress.getByName("cookiestudios.org"), 9999), 2000);
|
||||||
DataInputStream in = new DataInputStream(socket.getInputStream());
|
DataInputStream in = new DataInputStream(socket.getInputStream());
|
||||||
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
|
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package data;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
public class ServerTime {
|
||||||
|
public static String getTimestamp() {
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd HH:mm");
|
||||||
|
LocalDateTime ldt = LocalDateTime.now();
|
||||||
|
return formatter.format(ldt);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -6,13 +6,13 @@ import java.io.IOException;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
|
||||||
|
import data.ServerData;
|
||||||
import scenes.LogScene;
|
import scenes.LogScene;
|
||||||
|
|
||||||
public class ServerThread
|
public class ServerThread
|
||||||
implements Runnable {
|
implements Runnable {
|
||||||
|
|
||||||
private final int PORT = 9999;
|
private final int PORT = 9999;
|
||||||
public static float version = -1.0f;
|
|
||||||
|
|
||||||
LogScene display;
|
LogScene display;
|
||||||
|
|
||||||
|
@ -36,10 +36,10 @@ implements Runnable {
|
||||||
out = new DataOutputStream(s.getOutputStream());
|
out = new DataOutputStream(s.getOutputStream());
|
||||||
in = new DataInputStream(s.getInputStream());
|
in = new DataInputStream(s.getInputStream());
|
||||||
String data = in.readUTF();
|
String data = in.readUTF();
|
||||||
display.appendText(data);
|
display.appendText(data, data.split(";")[0]);
|
||||||
System.out.println(data);
|
System.out.println(data);
|
||||||
|
|
||||||
out.writeUTF("VERSION="+version);
|
out.writeUTF("VERSION="+ServerData.version);
|
||||||
|
|
||||||
out.close();
|
out.close();
|
||||||
in.close();
|
in.close();
|
||||||
|
|
|
@ -3,6 +3,7 @@ package scenes;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import data.ServerData;
|
import data.ServerData;
|
||||||
|
import data.ServerTime;
|
||||||
import customNodes.LogTextArea;
|
import customNodes.LogTextArea;
|
||||||
import customNodes.NewUpdateButton;
|
import customNodes.NewUpdateButton;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
|
@ -14,6 +15,7 @@ import javafx.scene.chart.PieChart;
|
||||||
import javafx.scene.chart.PieChart.Data;
|
import javafx.scene.chart.PieChart.Data;
|
||||||
import javafx.scene.control.TextInputDialog;
|
import javafx.scene.control.TextInputDialog;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
|
import javafx.scene.text.Text;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
public class LogScene extends AnchorPane{
|
public class LogScene extends AnchorPane{
|
||||||
|
@ -28,6 +30,11 @@ public class LogScene extends AnchorPane{
|
||||||
this.setPrefHeight(600);
|
this.setPrefHeight(600);
|
||||||
this.setMaxHeight(600);
|
this.setMaxHeight(600);
|
||||||
|
|
||||||
|
Text versionText = new Text();
|
||||||
|
versionText.setLayoutX(10);
|
||||||
|
versionText.setLayoutY(30);
|
||||||
|
versionText.setText("Current version: "+ServerData.version);
|
||||||
|
|
||||||
mNewUpdate = new NewUpdateButton("New update");
|
mNewUpdate = new NewUpdateButton("New update");
|
||||||
mNewUpdate.setOnAction(new EventHandler<ActionEvent>() {
|
mNewUpdate.setOnAction(new EventHandler<ActionEvent>() {
|
||||||
|
|
||||||
|
@ -41,6 +48,7 @@ public class LogScene extends AnchorPane{
|
||||||
Optional<String> result = dialog.showAndWait();
|
Optional<String> result = dialog.showAndWait();
|
||||||
if (result.isPresent()){
|
if (result.isPresent()){
|
||||||
ServerData.version = Float.parseFloat(result.get());
|
ServerData.version = Float.parseFloat(result.get());
|
||||||
|
versionText.setText("Current version: "+ServerData.version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -48,30 +56,29 @@ public class LogScene extends AnchorPane{
|
||||||
mLogView = new LogTextArea();
|
mLogView = new LogTextArea();
|
||||||
pieChartData =
|
pieChartData =
|
||||||
FXCollections.observableArrayList(
|
FXCollections.observableArrayList(
|
||||||
new PieChart.Data("Win 7", 0),
|
new PieChart.Data("Windows 7", 0),
|
||||||
new PieChart.Data("Win 10", 0),
|
new PieChart.Data("Windows 10", 0),
|
||||||
new PieChart.Data("Linux", 0));
|
new PieChart.Data("Linux", 0));
|
||||||
final PieChart chart = new PieChart(pieChartData);
|
final PieChart chart = new PieChart(pieChartData);
|
||||||
chart.setLayoutX(500);
|
chart.setLayoutX(500);
|
||||||
chart.setLayoutY(35);
|
chart.setLayoutY(35);
|
||||||
chart.setMaxHeight(200);
|
chart.setMaxHeight(150);
|
||||||
chart.setMaxWidth(300);
|
chart.setMaxWidth(300);
|
||||||
chart.setLabelsVisible(true);
|
|
||||||
chart.setLegendSide(Side.RIGHT);
|
chart.setLegendSide(Side.RIGHT);
|
||||||
chart.setLabelLineLength(10);
|
|
||||||
chart.setStyle("-fx-font-size: 8pt");
|
chart.setStyle("-fx-font-size: 8pt");
|
||||||
this.getChildren().add(mNewUpdate);
|
this.getChildren().add(mNewUpdate);
|
||||||
this.getChildren().add(mLogView);
|
this.getChildren().add(mLogView);
|
||||||
this.getChildren().add(chart);
|
this.getChildren().add(chart);
|
||||||
|
this.getChildren().add(versionText);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void appendText(String text) {
|
public void appendText(String text, String osName) {
|
||||||
for(Data d : pieChartData) {
|
for(Data d : pieChartData) {
|
||||||
if(d.getName().equals("Linux")) {
|
if(d.getName().equals(osName)) {
|
||||||
d.setPieValue(d.getPieValue()+1);
|
d.setPieValue(d.getPieValue()+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mLogView.appendText(text+"\n");
|
mLogView.appendText(ServerTime.getTimestamp()+" "+text+"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue