Merge remote-tracking branch 'origin/3.0' into 3.0

Conflicts:
	QuickLaunch/settings.properties
This commit is contained in:
ChococookieOS 2019-04-28 11:31:44 +02:00
commit 510cb9c295
30 changed files with 171 additions and 48 deletions

View File

@ -8,13 +8,3 @@ f
f
g
g
h
h
i
i
j
j
k
k
l
l

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -14,7 +14,7 @@ public class UpdateChecker {
public void requestServerData(){
try {
Socket socket = new Socket();
socket.connect(new InetSocketAddress(InetAddress.getByName("cookiestudios.org"), 9999), 2000);
socket.connect(new InetSocketAddress(InetAddress.getByName(/*"cookiestudios.org"*/"localhost"), 9999), 2000);
DataInputStream in = new DataInputStream(socket.getInputStream());
DataOutputStream out = new DataOutputStream(socket.getOutputStream());

View File

@ -0,0 +1,25 @@
package customNodes;
import javafx.geometry.Insets;
import javafx.scene.control.TextArea;
public class LogTextArea extends TextArea{
private final int WIDTH = 500;
private final int HEIGHT = 515;
public LogTextArea() {
this.setLayoutX(25);
this.setLayoutY(65);
this.setEditable(false);
this.setMinWidth(WIDTH);
this.setMaxWidth(WIDTH);
this.setPadding(new Insets(0,0,0,-10));
this.setMinHeight(HEIGHT);
this.setMaxHeight(HEIGHT);
this.setStyle("-fx-background-color: transparent;"
+ "-fx-control-inner-background: white;"
+ "-fx-text-fill: black");
}
}

View File

@ -0,0 +1,16 @@
package customNodes;
import javafx.scene.control.Button;
import javafx.scene.paint.Color;
public class NewUpdateButton extends Button{
public NewUpdateButton(String text) {
this.setText(text);
this.setLayoutX(550);
this.setLayoutY(400);
this.setTextFill(Color.WHITE);
this.setStyle("-fx-background-color: blue");
}
}

View File

@ -0,0 +1,5 @@
package data;
public class ServerData {
public static float version = 0.0f;
}

View File

@ -1,20 +1,26 @@
package run;
package network;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import run.Start;
import scenes.LogScene;
public class ServerThread
implements Runnable {
int PORT;
public ServerThread(int port) {
this.PORT = port;
private final int PORT = 9999;
public static float version = -1.0f;
LogScene display;
public ServerThread(LogScene scene) {
display = scene;
}
ServerSocket ses;
Socket s;
DataOutputStream out;
@ -29,8 +35,11 @@ implements Runnable {
System.out.println("Connected with: " + s.getInetAddress());
out = new DataOutputStream(s.getOutputStream());
in = new DataInputStream(s.getInputStream());
System.out.println(in.readUTF());
out.writeUTF("VERSION="+Start.version);
String data = in.readUTF();
display.appendText(data);
System.out.println(data);
out.writeUTF("VERSION="+version);
out.close();
in.close();

View File

@ -1,23 +1,12 @@
package run;
import javax.swing.JOptionPane;
import run.ServerThread;
import run.UpdateThread;
import javafx.application.Application;
import stages.AppStage;
public class Start {
public static float version = -1.0f;
private static final int PORT = 9999;
public static void main(String[] args) {
version = Float.parseFloat(JOptionPane.showInputDialog("QuickLaunch version:"));
Thread ut = new Thread(new UpdateThread());
ut.start();
System.out.println("Update thread started");
Thread st = new Thread(new ServerThread(PORT));
st.start();
System.out.println("Server listening");
Application.launch(AppStage.class);
}
}

View File

@ -1,14 +0,0 @@
package run;
import javax.swing.JOptionPane;
import run.Start;
public class UpdateThread
implements Runnable {
@Override
public void run() {
do {
Start.version = Float.parseFloat(JOptionPane.showInputDialog("QuickLaunch version (" + Start.version + "): "));
} while (true);
}
}

View File

@ -0,0 +1,78 @@
package scenes;
import java.util.Optional;
import data.ServerData;
import customNodes.LogTextArea;
import customNodes.NewUpdateButton;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Side;
import javafx.scene.chart.PieChart;
import javafx.scene.chart.PieChart.Data;
import javafx.scene.control.TextInputDialog;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
public class LogScene extends AnchorPane{
private NewUpdateButton mNewUpdate;
private LogTextArea mLogView;
private ObservableList<PieChart.Data> pieChartData;
public LogScene(Stage primaryStage) {
this.setPrefWidth(800);
this.setPrefHeight(600);
this.setMaxHeight(600);
mNewUpdate = new NewUpdateButton("New update");
mNewUpdate.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent event) {
TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("Create new update");
dialog.setHeaderText("Realese new Update");
dialog.setContentText("New version:");
Optional<String> result = dialog.showAndWait();
if (result.isPresent()){
ServerData.version = Float.parseFloat(result.get());
}
}
});
mLogView = new LogTextArea();
pieChartData =
FXCollections.observableArrayList(
new PieChart.Data("Win 7", 0),
new PieChart.Data("Win 10", 0),
new PieChart.Data("Linux", 0));
final PieChart chart = new PieChart(pieChartData);
chart.setLayoutX(500);
chart.setLayoutY(35);
chart.setMaxHeight(200);
chart.setMaxWidth(300);
chart.setLabelsVisible(true);
chart.setLegendSide(Side.RIGHT);
chart.setLabelLineLength(10);
chart.setStyle("-fx-font-size: 8pt");
this.getChildren().add(mNewUpdate);
this.getChildren().add(mLogView);
this.getChildren().add(chart);
}
public void appendText(String text) {
for(Data d : pieChartData) {
if(d.getName().equals("Linux")) {
d.setPieValue(d.getPieValue()+1);
}
}
mLogView.appendText(text+"\n");
}
}

View File

@ -0,0 +1,25 @@
package stages;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
import network.ServerThread;
import scenes.LogScene;
public class AppStage extends Application{
public void start(Stage primaryStage) throws Exception {
primaryStage.setOnCloseRequest(event -> {
System.exit(0);
});
LogScene ls = new LogScene(primaryStage);
Thread st = new Thread(new ServerThread(ls));
st.start();
primaryStage.setScene(new Scene(ls));
primaryStage.setResizable(false);
primaryStage.show();
}
}