Add Discord button
This commit is contained in:
parent
7f6e7008e0
commit
f83d9a2554
|
@ -15,7 +15,6 @@ import javafx.scene.layout.BorderPane;
|
|||
import javafx.scene.layout.VBox;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
// import java.awt.Desktop;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -53,8 +52,12 @@ public class HelpTab extends Tab {
|
|||
Button openCfg = new Button("Open Config Dir");
|
||||
openCfg.setStyle("-fx-font-family: 'Arial'; -fx-font-size: 16px; -fx-font-weight: bold; -fx-text-fill: #ffffff; -fx-background-color: #FF9800; -fx-padding: 15 30; -fx-border-radius: 5; -fx-background-radius: 5;");
|
||||
|
||||
Button openDiscord = new Button("Discord");
|
||||
openDiscord.setStyle("-fx-font-family: 'Arial'; -fx-font-size: 16px; -fx-font-weight: bold; -fx-text-fill: #ffffff; -fx-background-color: #ff0022; -fx-padding: 15 30; -fx-border-radius: 5; -fx-background-radius: 5;");
|
||||
|
||||
File cfgDir = Config.getInstance().getConfigDir();
|
||||
String path = (cfgDir != null) ? cfgDir.getAbsolutePath() : "Unknown";
|
||||
|
||||
Label configStaticLabel = new Label("Config Dir:");
|
||||
configStaticLabel.setStyle("-fx-font-family: 'Arial'; -fx-font-size: 14px; -fx-font-weight: bold; -fx-alignment: center;");
|
||||
Label configValueLabel = new Label(path);
|
||||
|
@ -75,8 +78,9 @@ public class HelpTab extends Tab {
|
|||
VBox vbox = new VBox();
|
||||
vbox.setAlignment(Pos.CENTER);
|
||||
vbox.setSpacing(20);
|
||||
vbox.getChildren().addAll(wanLabelBox, openHelp, configLabelBox, openCfg, logLabelBox, openLog);
|
||||
vbox.getChildren().addAll(wanLabelBox, openHelp, configLabelBox, openCfg, logLabelBox, openLog, openDiscord);
|
||||
|
||||
// Set up the BorderPane layout
|
||||
BorderPane layout = new BorderPane();
|
||||
layout.setCenter(vbox);
|
||||
|
||||
|
@ -95,14 +99,13 @@ public class HelpTab extends Tab {
|
|||
File logFile = new File("ctbrec.log");
|
||||
if (logFile.exists()) {
|
||||
try {
|
||||
// Use Runtime.getRuntime().exec() to open the file in a separate process
|
||||
String osName = System.getProperty("os.name").toLowerCase();
|
||||
ProcessBuilder pb = null;
|
||||
if (osName.contains("mac")) {
|
||||
pb = new ProcessBuilder("open", logFile.getAbsolutePath());
|
||||
} else if (osName.contains("win")) {
|
||||
pb = new ProcessBuilder("explorer.exe", logFile.getAbsolutePath());
|
||||
} else { // Assume it's a Unix/Linux system
|
||||
} else {
|
||||
pb = new ProcessBuilder("xdg-open", logFile.getAbsolutePath());
|
||||
}
|
||||
pb.start();
|
||||
|
@ -118,14 +121,13 @@ public class HelpTab extends Tab {
|
|||
File configDir = Config.getInstance().getConfigDir();
|
||||
if (configDir.exists()) {
|
||||
try {
|
||||
// Use Runtime.getRuntime().exec() to open the file in a separate process
|
||||
String osName = System.getProperty("os.name").toLowerCase();
|
||||
ProcessBuilder pb = null;
|
||||
if (osName.contains("mac")) {
|
||||
pb = new ProcessBuilder("open", configDir.getAbsolutePath());
|
||||
} else if (osName.contains("win")) {
|
||||
pb = new ProcessBuilder("explorer.exe", configDir.getAbsolutePath());
|
||||
} else { // Assume it's a Unix/Linux system
|
||||
} else {
|
||||
pb = new ProcessBuilder("xdg-open", configDir.getAbsolutePath());
|
||||
}
|
||||
pb.start();
|
||||
|
@ -136,6 +138,8 @@ public class HelpTab extends Tab {
|
|||
log.warn("Config dir doesn't exist: {}", configDir.getAbsolutePath());
|
||||
}
|
||||
});
|
||||
|
||||
openDiscord.setOnAction(e -> DesktopIntegration.open("https://discord.gg/8jCXgVHzgf"));
|
||||
}
|
||||
|
||||
private void startDocumentationServer() {
|
||||
|
|
Loading…
Reference in New Issue