Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross-platform merge stage III #104

Merged
merged 11 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions assets/UI/Main.css
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,15 @@ ProgressBar:indeterminate>.bar {
-fx-background-color: #305890;
}

#Title-minimize-btn-mac,
#Title-close-btn-mac {
-fx-fill: inherit;
}

#Title-close-btn-mac {
-fx-background-radius: 8px 0 0 0;
}

#Title-close-btn:hover,
#Title-close-btn:focused {
-fx-background-color: #CC2211;
Expand Down
38 changes: 2 additions & 36 deletions assets/UI/RootModule.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -140,41 +140,7 @@
</AnchorPane>

<!-- ********** 3. Title Bar ********** -->
<AnchorPane id="Title-bar" fx:id="titleBar" maxHeight="-Infinity" minHeight="-Infinity"
onMouseDragged="#titleBarDragged" onMousePressed="#titleBarPressed" prefHeight="24.0"
styleClass="shadowed" StackPane.alignment="TOP_CENTER">
<HBox prefHeight="24.0" prefWidth="200.0" AnchorPane.leftAnchor="3.0">
<ImageView cache="true" fitHeight="18.0" fitWidth="18.0" pickOnBounds="true">
<HBox.margin>
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0"/>
</HBox.margin>
<Image requestedHeight="512.0" requestedWidth="512.0" url="@/icons/icon.png"/>
</ImageView>
<Text fx:id="titleText" strokeType="OUTSIDE" strokeWidth="0.0" text="ArkPets Launcher">
<HBox.margin>
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0"/>
</HBox.margin>
</Text>
</HBox>
<HBox alignment="TOP_RIGHT" prefHeight="24.0" prefWidth="200.0" AnchorPane.rightAnchor="0.0">
<JFXButton id="Title-minimize-btn" fx:id="titleMinimizeBtn" mnemonicParsing="false"
onMouseClicked="#windowMinimize" text=" ">
<graphic>
<SVGPath
content="m21 11.75c0-.414-.336-.75-.75-.75h-16.5c-.414 0-.75.336-.75.75s.336.75.75.75h16.5c.414 0 .75-.336.75-.75z"
scaleX="0.75" scaleY="0.75" translateX="-5.0"/>
</graphic>
</JFXButton>
<JFXButton id="Title-close-btn" fx:id="titleCloseBtn" mnemonicParsing="false"
onMouseClicked="#windowClose" text=" ">
<graphic>
<SVGPath
content="m12 10.93 5.719-5.72c.146-.146.339-.219.531-.219.404 0 .75.324.75.749 0 .193-.073.385-.219.532l-5.72 5.719 5.719 5.719c.147.147.22.339.22.531 0 .427-.349.75-.75.75-.192 0-.385-.073-.531-.219l-5.719-5.719-5.719 5.719c-.146.146-.339.219-.531.219-.401 0-.75-.323-.75-.75 0-.192.073-.384.22-.531l5.719-5.719-5.72-5.719c-.146-.147-.219-.339-.219-.532 0-.425.346-.749.75-.749.192 0 .385.073.531.219z"
scaleX="0.75" scaleY="0.75" translateX="-3"/>
</graphic>
</JFXButton>
</HBox>
</AnchorPane>

<Pane fx:id="wrapper4" maxHeight="-Infinity" minHeight="-Infinity" maxWidth="-Infinity" minWidth="-Infinity"
prefHeight="24.0" prefWidth="600.0" StackPane.alignment="TOP_CENTER"/>
</StackPane>
</StackPane>
3 changes: 3 additions & 0 deletions assets/UI/SettingsModule.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@
<JFXTextField fx:id="configNetworkAgent" prefHeight="23.0" prefWidth="100.0"/>
<Label fx:id="configNetworkAgentStatus" alignment="TOP_CENTER" text="-"/>
</HBox>
<HBox spacing="22.5">
<Label fx:id="runEnvCheck" styleClass="config-hyper-link" text="重新运行环境检查"/>
</HBox>
<Separator/>
<Label styleClass="config-group-title" text="关于软件"/>
<HBox spacing="22.5">
Expand Down
76 changes: 76 additions & 0 deletions assets/UI/Titlebar.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Copyright (c) 2022-2024, Litwak913
At GPL-3.0 License
-->

<?import com.jfoenix.controls.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.shape.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.text.*?>

<AnchorPane xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml"
fx:controller="cn.harryh.arkpets.controllers.Titlebar"
id="Title-bar" maxHeight="-Infinity" minHeight="-Infinity"
onMouseDragged="#titleBarDragged" onMousePressed="#titleBarPressed" prefHeight="24.0" prefWidth="600.0"
styleClass="shadowed" stylesheets="@Main.css">
<HBox fx:id="title" prefHeight="24.0" prefWidth="200.0" AnchorPane.leftAnchor="3.0">
<ImageView cache="true" fitHeight="18.0" fitWidth="18.0" pickOnBounds="true">
<HBox.margin>
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0"/>
</HBox.margin>
<Image requestedHeight="512.0" requestedWidth="512.0" url="@/icons/icon.png"/>
</ImageView>
<Text fx:id="titleText" strokeType="OUTSIDE" strokeWidth="0.0" text="ArkPets Launcher">
<HBox.margin>
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0"/>
</HBox.margin>
</Text>
</HBox>
<HBox fx:id="titleButtons" alignment="TOP_RIGHT" prefHeight="24.0" prefWidth="200.0" AnchorPane.rightAnchor="0.0">
<JFXButton id="Title-minimize-btn" mnemonicParsing="false"
onMouseClicked="#windowMinimize" text=" ">
<graphic>
<SVGPath
content="m21 11.75c0-.414-.336-.75-.75-.75h-16.5c-.414 0-.75.336-.75.75s.336.75.75.75h16.5c.414 0 .75-.336.75-.75z"
scaleX="0.75" scaleY="0.75" translateX="-5.0"/>
</graphic>
</JFXButton>
<JFXButton id="Title-close-btn" mnemonicParsing="false"
onMouseClicked="#windowClose" text=" ">
<graphic>
<SVGPath
content="m12 10.93 5.719-5.72c.146-.146.339-.219.531-.219.404 0 .75.324.75.749 0 .193-.073.385-.219.532l-5.72 5.719 5.719 5.719c.147.147.22.339.22.531 0 .427-.349.75-.75.75-.192 0-.385-.073-.531-.219l-5.719-5.719-5.719 5.719c-.146.146-.339.219-.531.219-.401 0-.75-.323-.75-.75 0-.192.073-.384.22-.531l5.719-5.719-5.72-5.719c-.146-.147-.219-.339-.219-.532 0-.425.346-.749.75-.749.192 0 .385.073.531.219z"
scaleX="0.75" scaleY="0.75" translateX="-3"/>
</graphic>
</JFXButton>
</HBox>
<HBox fx:id="macTitleButtons" prefHeight="24.0" prefWidth="200.0" AnchorPane.leftAnchor="0.0"
visible="false" onMouseEntered="#mouseEnterBtnBoxMac" onMouseExited="#mouseExitBtnBoxMac">
<JFXButton id="Title-close-btn-mac" mnemonicParsing="false" ripplerFill="#2A528C"
onMousePressed="#closePressedMac" onMouseReleased="#closeReleasedMac" onMouseClicked="#windowClose" text=" ">
<graphic>
<ImageView fx:id="titleMacCloseImage" translateX="-3">
<viewport>
<Rectangle2D width="16" height="16"/>
</viewport>
<Image url="@/icons/macos/close.png"/>
</ImageView>
</graphic>
</JFXButton>
<JFXButton id="Title-minimize-btn-mac" mnemonicParsing="false" ripplerFill="#2A528C"
onMousePressed="#minimizePressedMac" onMouseReleased="#minimizeReleasedMac" onMouseClicked="#windowMinimize" text=" ">
<graphic>
<ImageView translateX="-5" fx:id="titleMacMinimizeImage">
<viewport>
<Rectangle2D width="16" height="16"/>
</viewport>
<Image url="@/icons/macos/minimize.png"/>
</ImageView>
</graphic>
</JFXButton>
</HBox>
</AnchorPane>
Binary file added assets/icons/macos/close.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/macos/minimize.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions core/src/cn/harryh/arkpets/utils/IOUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,36 @@ private static void copyFileToZip(ZipOutputStream zos, File sourceFile, String z
zos.closeEntry();
}
}


public static class CommandUtil {
/**
* Run a command and get the output.
* @param command The command will run.
* @param env The environment variable.
* @param workdir The working directory.
* @throws IOException If I/O error occurs.
* @return The command output,Return null if failed.
*/
public static String runCommand(String command, String[] env, File workdir) throws IOException {
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(command, env, workdir);
try {
process.waitFor();
} catch (InterruptedException ignore) {
}
if (process.exitValue() == 0) {
BufferedReader reader = process.inputReader();
String line;
StringBuilder b = new StringBuilder();
while ((line = reader.readLine()) != null) {
b.append(line);
}
reader.close();
return b.toString();
} else {
return null;
}
}
}
}
8 changes: 7 additions & 1 deletion desktop/src/cn/harryh/arkpets/ArkHomeFX.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import cn.harryh.arkpets.controllers.ModelsModule;
import cn.harryh.arkpets.controllers.RootModule;
import cn.harryh.arkpets.controllers.SettingsModule;
import cn.harryh.arkpets.controllers.Titlebar;
import cn.harryh.arkpets.tray.HostTray;
import cn.harryh.arkpets.utils.FXMLHelper;
import cn.harryh.arkpets.utils.FXMLHelper.LoadFXMLResult;
Expand Down Expand Up @@ -44,6 +45,7 @@ public class ArkHomeFX extends Application {
public ModelsModule modelsModule;
public BehaviorModule behaviorModule;
public SettingsModule settingsModule;
public Titlebar titleBar;

static {
FontsConfig.loadFontsToJavafx();
Expand All @@ -60,6 +62,10 @@ public void start(Stage stage) throws Exception {
fxml0.initializeWith(this);
rootModule = (RootModule)fxml0.controller();
body = rootModule.body;
LoadFXMLResult<ArkHomeFX> fxmlTitlebar = FXMLHelper.loadFXML(getClass().getResource("/UI/Titlebar.fxml"));
fxmlTitlebar.initializeWith(this);
titleBar = (Titlebar) fxmlTitlebar.controller();
fxmlTitlebar.addToNode(rootModule.wrapper4);

// Setup scene and primary stage.
Logger.info("Launcher", "Creating main scene");
Expand All @@ -71,7 +77,7 @@ public void start(Stage stage) throws Exception {
stage.setResizable(false);
stage.setScene(scene);
stage.setTitle(desktopTitle);
rootModule.titleText.setText(desktopTitle);
titleBar.titleText.setText(desktopTitle);

// After the stage is shown, do initialization.
stage.show();
Expand Down
16 changes: 16 additions & 0 deletions desktop/src/cn/harryh/arkpets/DesktopLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*/
package cn.harryh.arkpets;

import cn.harryh.arkpets.controllers.Titlebar;
import cn.harryh.arkpets.envchecker.WinGraphicsEnvCheckTask;
import cn.harryh.arkpets.utils.ArgPending;
import cn.harryh.arkpets.utils.Logger;
import javafx.application.Application;
Expand Down Expand Up @@ -60,6 +62,20 @@ protected void process(String command, String addition) {
System.exit(0);
}
};
// Change ui style
new ArgPending("--ui-style", args) {
@Override
protected void process(String command, String addition) {
Titlebar.forceUiStyle = addition.toLowerCase();
}
};
// Remove NVIDIA settings on uninstall
new ArgPending("--remove-nvidia", args) {
@Override
protected void process(String command, String addition) {
new WinGraphicsEnvCheckTask().removeNvidiaSettings();
}
};
// Disable libdecor to avoid glfw and javafx problem
GLFW.glfwInitHint(GLFW.GLFW_WAYLAND_LIBDECOR, GLFW.GLFW_WAYLAND_DISABLE_LIBDECOR);
// Java FX bootstrap
Expand Down
Loading
Loading