Skip to content

Commit f7f2fc0

Browse files
authored
Merge pull request #18 from lillithkt/lillith-changes-to-pr
Many changes, see description
2 parents c18637f + 803b687 commit f7f2fc0

File tree

9 files changed

+111
-187
lines changed

9 files changed

+111
-187
lines changed

.github/workflows/build-mac-arm64.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/build-mac-x64.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/build-ubuntu.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

.github/workflows/build-windows.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Build application
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
create:
7+
8+
jobs:
9+
build:
10+
strategy:
11+
matrix:
12+
os: [ubuntu-latest, windows-latest, macos-latest]
13+
runs-on: ${{ matrix.os }}
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: "20"
23+
24+
25+
- name: Install dependencies on Ubuntu
26+
if: matrix.os == 'ubuntu-latest'
27+
run: |
28+
sudo apt-get update
29+
sudo apt-get install -y libudev-dev
30+
- name: Install Node.js dependencies
31+
run: npm install
32+
33+
- name: Build the application
34+
run: npm run build
35+
36+
- name: Compress Linux build artifacts (x64)
37+
if: matrix.os == 'ubuntu-latest'
38+
run: |
39+
zip -r build/SlimeTora-linux-x64.zip build/SlimeTora-linux-x64
40+
zip -r build/SlimeTora-linux-arm64.zip build/SlimeTora-linux-arm64
41+
- name: Compress Windows build artifacts
42+
if: matrix.os == 'windows-latest'
43+
run: |
44+
powershell Compress-Archive -Path build\SlimeTora-win32-arm64\* -DestinationPath build\SlimeTora-win32-arm64.zip
45+
powershell Compress-Archive -Path build\SlimeTora-win32-x64\* -DestinationPath build\SlimeTora-win32-x64.zip
46+
- name: Compress macOS build artifacts
47+
if: matrix.os == 'macos-latest'
48+
run: |
49+
zip -r build/SlimeTora-darwin-arm64.zip build/SlimeTora-darwin-arm64
50+
zip -r build/SlimeTora-darwin-x64.zip build/SlimeTora-darwin-x64
51+
- name: Archive build artifacts for Linux (x64)
52+
if: matrix.os == 'ubuntu-latest'
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: build-artifacts-linux-x64
56+
path: build/SlimeTora-linux-x64.zip
57+
- name: Archive build artifacts for Linux (arm64)
58+
if: matrix.os == 'ubuntu-latest'
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: build-artifacts-linux-arm64
62+
path: build/SlimeTora-linux-arm64.zip
63+
64+
- name: Archive build artifacts for Windows (x64)
65+
if: matrix.os == 'windows-latest'
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: build-artifacts-win32-x64
69+
path: build/SlimeTora-win32-x64.zip
70+
- name: Archive build artifacts for Windows (arm64)
71+
if: matrix.os == 'windows-latest'
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: build-artifacts-win32-arm64
75+
path: build/SlimeTora-win32-arm64.zip
76+
77+
- name: Archive build artifacts for macOS (arm64)
78+
if: matrix.os == 'macos-latest'
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: build-artifacts-macos-arm64
82+
path: build/SlimeTora-darwin-arm64.zip
83+
- name: Archive build artifacts for macOS (x64)
84+
if: matrix.os == 'macos-latest'
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: build-artifacts-macos-x64
88+
path: build/SlimeTora-darwin-x64.zip

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,5 @@ out/
103103
notes.txt
104104
src/static/css/index.css
105105
src/static/css/index.css.map
106+
107+
config.json

package-lock.json

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121
"start": "npm run preload && cross-env DEVELOPMENT=true && electron .",
2222
"dev": "cross-env DEVELOPMENT=true && tsc && npm run copy-files && electron .",
2323
"build": "npm run preload && npx @electron/packager . SlimeTora --arch=x64,arm64 --overwrite --out=build/ --icon=src/static/images/icon.ico --asar --extra-resource=src/languages --prune --ignore=\"^/(src|docs|.vscode|.eslintrc.cjs|.prettierrc|tsconfig.json|README.md|.gitignore|notes.txt|.github)$\"",
24-
"build-bulma": "npx sass ./src/static/css/index.scss ./src/static/css/index.css",
25-
"build-bulma:watch": "npx sass --watch ./src/static/css/index.scss ./src/static/css/index.css",
26-
"preload": "npm run build-bulma && npx @electron/rebuild && npx del-cli dist/ && tsc && npm run copy-files",
27-
"copy-files": "npx copyfiles -u 1 \"src/**/*.js\" \"src/**/*.html\" \"src/**/*.css\" \"src/**/*.ico\" \"src/**/*.png\" \"src/**/*.webp\" \"src/**/*.webm\" \"src/**/*.svg\" \"src/**/*.fbx\" src/languages/* dist/",
24+
"preload": "npx @electron/rebuild && npx del-cli dist/ && tsc && npm run copy-files && npm run build-bulma",
25+
"copy-files": "npx copyfiles -u 1 src/static/**/* src/languages/**/* dist/",
26+
"build-bulma": "npx sass ./src/static/css/index.scss ./dist/static/css/index.css",
2827
"lint": "eslint ./src/**/*.ts"
2928
},
3029
"keywords": [],
@@ -54,6 +53,7 @@
5453
"loc-i18next": "^0.1.6",
5554
"lodash-es": "^4.17.21",
5655
"quaternion": "2.0.1",
56+
"rand-seed": "^2.1.7",
5757
"three": "^0.174.0"
5858
}
5959
}

src/main.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ const __filename = fileURLToPath(import.meta.url);
1313
const __dirname = dirname(__filename);
1414

1515
const mainPath = app.isPackaged ? path.dirname(app.getPath("exe")) : __dirname;
16-
const configPath = path.resolve(mainPath, "config.json");
16+
const configPath = app.isPackaged ? path.resolve(mainPath, "config.json") : path.resolve(path.join(mainPath, ".."), "config.json")
1717
const isMac = process.platform === "darwin";
1818
// don't mess with this or languages will fail to load cause of how the project is structured, lol
1919
// i hate how this is done.
2020
const languagesPath = path.resolve(
2121
mainPath,
22-
isMac ? ".." : "",
22+
(isMac && app.isPackaged) ? ".." : "",
2323
app.isPackaged ? (isMac ? "Resources/languages" : "resources/languages") : "languages"
2424
);
2525
let mainWindow: BrowserWindow;
@@ -692,7 +692,7 @@ ipcMain.on("fix-trackers", async () => {
692692
};
693693

694694
const intervalId = setInterval(sendCommands, 100);
695-
await dialog.showMessageBox(dialogOptions);
695+
await dialog.showMessageBox(mainWindow, dialogOptions);
696696
clearInterval(intervalId);
697697

698698
const endTime = Date.now();
@@ -1166,6 +1166,7 @@ import { EmulatedTracker } from "@slimevr/tracker-emulation";
11661166
import { ActivePorts } from "haritorax-interpreter/dist/mode/com";
11671167
import BetterQuaternion from "quaternion";
11681168
import { ParsedUrlQueryInput } from "querystring";
1169+
import Rand from "rand-seed"
11691170

11701171
// For haritorax-interpreter
11711172
// Used to handle errors coming from haritorax-interpreter and display them to the user if wanted
@@ -1239,6 +1240,11 @@ async function addTracker(trackerName: string) {
12391240
processQueue();
12401241
}
12411242

1243+
function MacAddressFromName(name: string) {
1244+
const rand = new Rand(name);
1245+
return new MACAddress(new Array(6).fill(0).map(() => Math.floor(rand.next() * 256)) as any)
1246+
}
1247+
12421248
async function processQueue() {
12431249
if (isProcessingQueue || trackerQueue.length === 0) return;
12441250
isProcessingQueue = true;
@@ -1251,7 +1257,7 @@ async function processQueue() {
12511257
if (connectedDevices.get(trackerName) !== undefined) return;
12521258

12531259
// Check if tracker has a MAC address assigned already in the config
1254-
let macAddress = MACAddress.random();
1260+
let macAddress = MacAddressFromName(trackerName);
12551261
let macBytes = config.trackers?.[trackerName]?.macAddress?.bytes;
12561262
if (macBytes && macBytes.length === 6) {
12571263
macAddress = new MACAddress(macBytes);

0 commit comments

Comments
 (0)