mirror of
https://git.sanhost.net/sanasol/hytale-f2p
synced 2026-02-26 18:41:48 -03:00
Compare commits
40 Commits
v2.0.4-aut
...
v2.0.2b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b53c7f89d | ||
|
|
ff5acb5278 | ||
|
|
5d75ca80aa | ||
|
|
281aa6fcde | ||
|
|
158d0af820 | ||
|
|
503f304704 | ||
|
|
234e1e1008 | ||
|
|
d002e831cd | ||
|
|
048f2040f1 | ||
|
|
b05aeef66d | ||
|
|
30265549cf | ||
|
|
5a3efba1d6 | ||
|
|
479f24e86f | ||
|
|
611b7a7084 | ||
|
|
e472435927 | ||
|
|
f40d0105df | ||
|
|
96db9adf68 | ||
|
|
a0f49f126c | ||
|
|
f8333c09cd | ||
|
|
bcf0326763 | ||
|
|
0a5c3db710 | ||
|
|
905a9d754c | ||
|
|
99f032e9ab | ||
|
|
5e3506a9ac | ||
|
|
f2a05d2079 | ||
|
|
cece338609 | ||
|
|
261582a882 | ||
|
|
0f0f0fa308 | ||
|
|
5e6a07f0a6 | ||
|
|
713377fdc6 | ||
|
|
2671a59f38 | ||
|
|
8e9af9c768 | ||
|
|
e962a8880d | ||
|
|
c2d5536dd0 | ||
|
|
727be2ca5c | ||
|
|
64892c81e9 | ||
|
|
fffc730788 | ||
|
|
c475ec7879 | ||
|
|
7efa0d07b0 | ||
|
|
21f8527ed4 |
38
.github/workflows/release.yml
vendored
38
.github/workflows/release.yml
vendored
@@ -3,7 +3,7 @@ name: Build and Release
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- release
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
@@ -17,15 +17,20 @@ jobs:
|
||||
with:
|
||||
node-version: '22'
|
||||
cache: 'npm'
|
||||
- run: npm install
|
||||
- run: npm ci
|
||||
- run: npx electron-builder --linux --publish never
|
||||
|
||||
- name: Build Linux Packages
|
||||
run: |
|
||||
npx electron-builder --linux --x64 --arm64 --publish never
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: linux-builds
|
||||
path: |
|
||||
dist/*.AppImage
|
||||
dist/*.deb
|
||||
dist/*.rpm
|
||||
dist/*.pacman
|
||||
dist/latest.yml
|
||||
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
@@ -35,7 +40,6 @@ jobs:
|
||||
with:
|
||||
node-version: '22'
|
||||
cache: 'npm'
|
||||
- run: npm install
|
||||
- run: npm ci
|
||||
- run: npx electron-builder --win --publish never
|
||||
- uses: actions/upload-artifact@v4
|
||||
@@ -43,6 +47,7 @@ jobs:
|
||||
name: windows-builds
|
||||
path: |
|
||||
dist/*.exe
|
||||
dist/latest.yml
|
||||
|
||||
build-macos:
|
||||
runs-on: macos-latest
|
||||
@@ -52,7 +57,6 @@ jobs:
|
||||
with:
|
||||
node-version: '22'
|
||||
cache: 'npm'
|
||||
- run: npm install
|
||||
- run: npm ci
|
||||
- run: npx electron-builder --mac --publish never
|
||||
- uses: actions/upload-artifact@v4
|
||||
@@ -66,7 +70,10 @@ jobs:
|
||||
release:
|
||||
needs: [build-linux, build-windows, build-macos]
|
||||
runs-on: ubuntu-latest
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
if: |
|
||||
startsWith(github.ref, 'refs/tags/v') ||
|
||||
github.ref == 'refs/heads/release' ||
|
||||
github.event_name == 'workflow_dispatch'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -80,13 +87,22 @@ jobs:
|
||||
- name: Display structure of downloaded files
|
||||
run: ls -R artifacts
|
||||
|
||||
- name: Get version from package.json
|
||||
id: pkg_version
|
||||
run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
# If it's a tag, use the tag.
|
||||
tag_name: ${{ github.ref_type == 'tag' && github.ref_name || format('v{0}.r{1}', steps.pkg_version.outputs.VERSION, github.run_number) }}
|
||||
# If it's the 'release' branch, use 'v2.0.2-beta.r42'
|
||||
name: ${{ github.ref_type == 'tag' && github.ref_name || format('v{0}-beta.r{1})', steps.pkg_version.outputs.VERSION, github.run_number) }}
|
||||
files: |
|
||||
artifacts/linux-builds/*
|
||||
artifacts/windows-builds/*
|
||||
artifacts/macos-builds/*
|
||||
artifacts/linux-builds/**/*
|
||||
artifacts/windows-builds/**/*
|
||||
artifacts/macos-builds/**/*
|
||||
generate_release_notes: true
|
||||
draft: false
|
||||
prerelease: false
|
||||
draft: true
|
||||
# DYNAMIC FLAGS: Mark as pre-release ONLY IF it's NOT a tag (meaning it's a branch push)
|
||||
prerelease: ${{ github.ref_type != 'tag' }}
|
||||
|
||||
10
.gitignore
vendored
10
.gitignore
vendored
@@ -1,3 +1,11 @@
|
||||
dist/*
|
||||
node_modules/*
|
||||
package-lock.json
|
||||
bun.lock
|
||||
|
||||
# Build artifacts
|
||||
src/
|
||||
pkg/
|
||||
|
||||
# Package files
|
||||
*.tar.zst
|
||||
*.zst
|
||||
425
GUI/index.html
425
GUI/index.html
@@ -1,19 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Hytale F2P Launcher</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap"
|
||||
rel="stylesheet">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
|
||||
<body class="bg-black text-white overflow-hidden font-sans select-none" tabindex="-1">
|
||||
<div class="absolute inset-0 z-0">
|
||||
<img src="https://i.imgur.com/Visrk66.png" alt="Background" class="w-full h-full object-cover" />
|
||||
<div class="absolute inset-0 bg-black/60"></div>
|
||||
<div class="absolute inset-0 bg-[url('data:image/svg+xml,%3Csvg viewBox="0 0 256 256" xmlns="http://www.w3.org/2000/svg"%3E%3Cfilter id="noiseFilter"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/%3E%3C/filter%3E%3Crect width="100%25" height="100%25" filter="url(%23noiseFilter)" opacity="0.1"/%3E%3C/svg%3E')] opacity-20"></div>
|
||||
<div class="absolute inset-0 bg-[url('data:image/svg+xml,%3Csvg viewBox=" 0 0 256 256"
|
||||
xmlns="http://www.w3.org/2000/svg" %3E%3Cfilter id="noiseFilter" %3E%3CfeTurbulence type="fractalNoise"
|
||||
baseFrequency="0.65" numOctaves="3" stitchTiles="stitch" /%3E%3C/filter%3E%3Crect width="100%25"
|
||||
height="100%25" filter="url(%23noiseFilter)" opacity="0.1" /%3E%3C/svg%3E')] opacity-20"></div>
|
||||
</div>
|
||||
|
||||
<div class="flex w-full h-screen relative z-10">
|
||||
@@ -48,6 +55,10 @@
|
||||
<i class="fas fa-user"></i>
|
||||
<span class="nav-tooltip">Skins</span>
|
||||
</div>
|
||||
<div class="nav-item" data-page="logs" id="openLogsBtn" onclick="openLogs()">
|
||||
<i class="fas fa-terminal"></i>
|
||||
<span class="nav-tooltip">Logs</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -61,6 +72,24 @@
|
||||
<span id="onlineCount" class="counter-value">0</span>
|
||||
</div>
|
||||
|
||||
<div class="profile-selector" id="profileSelector">
|
||||
<button class="profile-btn" onclick="toggleProfileDropdown()">
|
||||
<i class="fas fa-user-circle"></i>
|
||||
<span id="currentProfileName">Default</span>
|
||||
<i class="fas fa-chevron-down"></i>
|
||||
</button>
|
||||
<div class="profile-dropdown" id="profileDropdown">
|
||||
<div class="profile-list" id="profileList">
|
||||
<!-- Profiles populated by JS -->
|
||||
</div>
|
||||
<div class="profile-divider"></div>
|
||||
<div class="profile-action" onclick="openProfileManager()">
|
||||
<i class="fas fa-cog"></i>
|
||||
<span>Manage Profiles</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="window-controls">
|
||||
<button class="control-btn minimize" onclick="window.electronAPI?.minimizeWindow()">
|
||||
<i class="fas fa-minus"></i>
|
||||
@@ -93,7 +122,8 @@
|
||||
<div class="install-form">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Player Name</label>
|
||||
<input type="text" id="installPlayerName" placeholder="Enter your name" class="form-input" value="Player" />
|
||||
<input type="text" id="installPlayerName" placeholder="Enter your name"
|
||||
class="form-input" value="Player" />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@@ -106,7 +136,8 @@
|
||||
<div class="form-subgroup">
|
||||
<label class="form-label">Installation Folder</label>
|
||||
<div class="input-with-button">
|
||||
<input type="text" id="installPath" placeholder="Default location" class="form-input" readonly />
|
||||
<input type="text" id="installPath" placeholder="Default location"
|
||||
class="form-input" readonly />
|
||||
<button onclick="browseInstallPath()" class="browse-btn">
|
||||
<i class="fas fa-folder-open"></i>
|
||||
</button>
|
||||
@@ -205,11 +236,17 @@
|
||||
<i class="fas fa-comments mr-2"></i>
|
||||
PLAYERS CHAT
|
||||
</h2>
|
||||
<div class="chat-header-actions">
|
||||
<button id="chatColorBtn" class="chat-color-btn">
|
||||
<i class="fas fa-palette"></i>
|
||||
<span>Color</span>
|
||||
</button>
|
||||
<div class="chat-online-badge">
|
||||
<i class="fas fa-circle"></i>
|
||||
<span id="chatOnlineCount">0</span> online
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="chat-body">
|
||||
<div id="chatMessages" class="chat-messages">
|
||||
@@ -218,13 +255,9 @@
|
||||
|
||||
<div class="chat-footer">
|
||||
<div class="chat-input-container">
|
||||
<textarea
|
||||
id="chatInput"
|
||||
class="chat-input"
|
||||
placeholder="Type your message... (Links are automatically censored)"
|
||||
rows="1"
|
||||
maxlength="500"
|
||||
></textarea>
|
||||
<textarea id="chatInput" class="chat-input"
|
||||
placeholder="Type your message... (Links are automatically censored)" rows="1"
|
||||
maxlength="500"></textarea>
|
||||
<button id="chatSendBtn" class="chat-send-btn">
|
||||
<i class="fas fa-paper-plane"></i>
|
||||
</button>
|
||||
@@ -250,6 +283,134 @@
|
||||
</div>
|
||||
|
||||
<div class="settings-content">
|
||||
|
||||
<div class="settings-section">
|
||||
<h3 class="settings-section-title">
|
||||
<i class="fas fa-gamepad"></i>
|
||||
Game Options
|
||||
</h3>
|
||||
|
||||
<div class="settings-option">
|
||||
<div class="settings-input-group">
|
||||
<label class="settings-input-label">Player Name</label>
|
||||
<input type="text" id="settingsPlayerName" class="settings-input"
|
||||
placeholder="Enter your player name" maxlength="16" />
|
||||
<p class="settings-hint">
|
||||
<i class="fas fa-user"></i>
|
||||
This name will be used in-game (1-16 characters)
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-option">
|
||||
<div class="settings-button-group">
|
||||
<button id="openGameLocationBtn" class="settings-action-btn"
|
||||
onclick="openGameLocation()">
|
||||
<i class="fas fa-folder-open"></i>
|
||||
<div class="btn-content">
|
||||
<div class="btn-title">Open Game Location</div>
|
||||
<div class="btn-description">Open the game installation folder</div>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-option">
|
||||
<div class="settings-button-group">
|
||||
<button id="repairGameBtn" class="settings-action-btn"
|
||||
onclick="repairGame()">
|
||||
<i class="fas fa-tools"></i>
|
||||
<div class="btn-content">
|
||||
<div class="btn-title">Repair Game</div>
|
||||
<div class="btn-description">Reinstall game files (preserves data)
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="settings-input-group">
|
||||
<label class="settings-input-label">GPU Preference</label>
|
||||
<div class="segmented-control">
|
||||
<input type="radio" id="gpu-auto" name="gpuPreference" value="auto"
|
||||
checked>
|
||||
<label for="gpu-auto">Auto</label>
|
||||
<input type="radio" id="gpu-integrated" name="gpuPreference"
|
||||
value="integrated">
|
||||
<label for="gpu-integrated">Integrated</label>
|
||||
<input type="radio" id="gpu-dedicated" name="gpuPreference"
|
||||
value="dedicated">
|
||||
<label for="gpu-dedicated">Dedicated</label>
|
||||
</div>
|
||||
<p class="settings-hint">
|
||||
<i class="fas fa-info-circle"></i>
|
||||
Select your preferred GPU (Linux: affects DRI_PRIME)
|
||||
</p>
|
||||
<div id="gpu-detection-info" class="gpu-detection-info"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-section">
|
||||
<h3 class="settings-section-title">
|
||||
<i class="fas fa-fingerprint"></i>
|
||||
Player UUID Management
|
||||
</h3>
|
||||
|
||||
<div class="settings-option">
|
||||
<div class="settings-input-group">
|
||||
<label class="settings-input-label">Current UUID</label>
|
||||
<div class="uuid-display-container">
|
||||
<input type="text" id="currentUuid" class="settings-input uuid-input"
|
||||
readonly placeholder="Loading UUID..." />
|
||||
<button id="copyUuidBtn" class="uuid-btn copy-btn" title="Copy UUID">
|
||||
<i class="fas fa-copy"></i>
|
||||
</button>
|
||||
<button id="regenerateUuidBtn" class="uuid-btn regenerate-btn"
|
||||
title="Generate New UUID">
|
||||
<i class="fas fa-sync-alt"></i>
|
||||
</button>
|
||||
</div>
|
||||
<p class="settings-hint">
|
||||
<i class="fas fa-info-circle"></i>
|
||||
Your unique player identifier for this username
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-option">
|
||||
<div class="settings-button-group">
|
||||
<button id="manageUuidsBtn" class="settings-action-btn">
|
||||
<i class="fas fa-list"></i>
|
||||
<div class="btn-content">
|
||||
<div class="btn-title">Manage All UUIDs</div>
|
||||
<div class="btn-description">View and manage all player UUIDs
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-section">
|
||||
<h3 class="settings-section-title">
|
||||
<i class="fab fa-discord"></i>
|
||||
Discord Integration
|
||||
</h3>
|
||||
|
||||
<div class="settings-option">
|
||||
<label class="settings-checkbox">
|
||||
<input type="checkbox" id="discordRPCCheck" checked />
|
||||
<span class="checkmark"></span>
|
||||
<div class="checkbox-content">
|
||||
<div class="checkbox-title">Enable Discord Rich Presence</div>
|
||||
<div class="checkbox-description">Show your launcher activity on Discord
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-section">
|
||||
<h3 class="settings-section-title">
|
||||
<i class="fas fa-coffee"></i>
|
||||
@@ -262,7 +423,8 @@
|
||||
<span class="checkmark"></span>
|
||||
<div class="checkbox-content">
|
||||
<div class="checkbox-title">Use Custom Java Path</div>
|
||||
<div class="checkbox-description">Override the bundled Java runtime with your own installation</div>
|
||||
<div class="checkbox-description">Override the bundled Java runtime with
|
||||
your own installation</div>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
@@ -271,13 +433,8 @@
|
||||
<div class="settings-input-group">
|
||||
<label class="settings-input-label">Java Executable Path</label>
|
||||
<div class="settings-input-with-button">
|
||||
<input
|
||||
type="text"
|
||||
id="customJavaPath"
|
||||
class="settings-input"
|
||||
placeholder="Select Java path..."
|
||||
readonly
|
||||
/>
|
||||
<input type="text" id="customJavaPath" class="settings-input"
|
||||
placeholder="Select Java path..." readonly />
|
||||
<button id="browseJavaBtn" class="settings-browse-btn">
|
||||
<i class="fas fa-folder-open"></i>
|
||||
Browse
|
||||
@@ -291,41 +448,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-section">
|
||||
<h3 class="settings-section-title">
|
||||
<i class="fas fa-gamepad"></i>
|
||||
Game Options
|
||||
</h3>
|
||||
|
||||
<div class="settings-option">
|
||||
<div class="settings-input-group">
|
||||
<label class="settings-input-label">Player Name</label>
|
||||
<input
|
||||
type="text"
|
||||
id="settingsPlayerName"
|
||||
class="settings-input"
|
||||
placeholder="Enter your player name"
|
||||
maxlength="16"
|
||||
/>
|
||||
<p class="settings-hint">
|
||||
<i class="fas fa-user"></i>
|
||||
This name will be used in-game (1-16 characters)
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-option">
|
||||
<div class="settings-button-group">
|
||||
<button id="openGameLocationBtn" class="settings-action-btn" onclick="openGameLocation()">
|
||||
<i class="fas fa-folder-open"></i>
|
||||
<div class="btn-content">
|
||||
<div class="btn-title">Open Game Location</div>
|
||||
<div class="btn-description">Open the game installation folder</div>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -337,6 +459,30 @@
|
||||
<p>Skin customization coming soon...</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="logs-page" class="page">
|
||||
<div class="logs-container">
|
||||
<div class="logs-header">
|
||||
<h2 class="logs-title">
|
||||
<i class="fas fa-terminal"></i>
|
||||
SYSTEM LOGS
|
||||
</h2>
|
||||
<div class="logs-actions">
|
||||
<button class="logs-action-btn" onclick="copyLogs()">
|
||||
<i class="fas fa-copy"></i> Copy
|
||||
</button>
|
||||
<button class="logs-action-btn" onclick="refreshLogs()">
|
||||
<i class="fas fa-sync-alt"></i> Refresh
|
||||
</button>
|
||||
<button class="logs-action-btn" onclick="openLogsFolder()">
|
||||
<i class="fas fa-folder-open"></i> Open Folder
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="logsTerminal" class="logs-terminal">
|
||||
<div class="text-gray-500 text-center mt-10">Loading logs...</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
@@ -390,14 +536,8 @@
|
||||
</p>
|
||||
<div class="chat-username-input-group">
|
||||
<label for="chatUsernameInput" class="chat-username-label">Username</label>
|
||||
<input
|
||||
type="text"
|
||||
id="chatUsernameInput"
|
||||
class="chat-username-input"
|
||||
placeholder="Enter your username..."
|
||||
maxlength="20"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<input type="text" id="chatUsernameInput" class="chat-username-input"
|
||||
placeholder="Enter your username..." maxlength="20" autocomplete="off" />
|
||||
<span class="chat-username-hint">3-20 characters, letters, numbers, - and _ only</span>
|
||||
<span id="chatUsernameError" class="chat-username-error"></span>
|
||||
</div>
|
||||
@@ -415,16 +555,117 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- UUID Management Modal -->
|
||||
<div id="uuidModal" class="uuid-modal" style="display: none;">
|
||||
<div class="uuid-modal-content">
|
||||
<div class="uuid-modal-header">
|
||||
<h2 class="uuid-modal-title">
|
||||
<i class="fas fa-fingerprint mr-2"></i>
|
||||
UUID Management
|
||||
</h2>
|
||||
<button id="uuidModalClose" class="modal-close-btn">
|
||||
<i class="fas fa-times"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="uuid-modal-body">
|
||||
<div class="uuid-current-section">
|
||||
<h3 class="uuid-section-title">Current User UUID</h3>
|
||||
<div class="uuid-current-display">
|
||||
<input type="text" id="modalCurrentUuid" class="uuid-display-input" readonly />
|
||||
<button id="modalCopyUuidBtn" class="uuid-action-btn copy-btn" title="Copy UUID">
|
||||
<i class="fas fa-copy"></i>
|
||||
</button>
|
||||
<button id="modalRegenerateUuidBtn" class="uuid-action-btn regenerate-btn"
|
||||
title="Generate New UUID">
|
||||
<i class="fas fa-sync-alt"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uuid-list-section">
|
||||
<div class="uuid-list-header">
|
||||
<h3 class="uuid-section-title">All Player UUIDs</h3>
|
||||
<button id="generateNewUuidBtn" class="uuid-generate-btn">
|
||||
<i class="fas fa-plus"></i>
|
||||
Generate New UUID
|
||||
</button>
|
||||
</div>
|
||||
<div id="uuidList" class="uuid-list">
|
||||
<div class="uuid-loading">
|
||||
<i class="fas fa-spinner fa-spin"></i>
|
||||
Loading UUIDs...
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uuid-custom-section">
|
||||
<h3 class="uuid-section-title">Set Custom UUID</h3>
|
||||
<div class="uuid-custom-form">
|
||||
<input type="text" id="customUuidInput" class="uuid-input"
|
||||
placeholder="Enter custom UUID (format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)"
|
||||
maxlength="36" />
|
||||
<button id="setCustomUuidBtn" class="uuid-set-btn">
|
||||
<i class="fas fa-check"></i>
|
||||
Set UUID
|
||||
</button>
|
||||
</div>
|
||||
<p class="uuid-custom-hint">
|
||||
<i class="fas fa-exclamation-triangle"></i>
|
||||
Warning: Setting a custom UUID will change your current player identity
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Profile Manager Modal -->
|
||||
<div id="profileManagerModal" class="profile-modal" style="display: none;">
|
||||
<div class="profile-modal-content">
|
||||
<div class="profile-modal-header">
|
||||
<h2 class="profile-modal-title">
|
||||
<i class="fas fa-users-cog mr-2"></i>
|
||||
Manage Profiles
|
||||
</h2>
|
||||
<button class="modal-close-btn" onclick="closeProfileManager()">
|
||||
<i class="fas fa-times"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="profile-modal-body">
|
||||
<div class="profile-manager-list" id="managerProfileList">
|
||||
<!-- Populated by JS -->
|
||||
</div>
|
||||
<div class="profile-create-section">
|
||||
<input type="text" id="newProfileName" placeholder="New Profile Name" class="profile-input"
|
||||
maxlength="20">
|
||||
<button class="profile-create-btn" onclick="createNewProfile()">
|
||||
<i class="fas fa-plus"></i> Create Profile
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="fixed bottom-0 left-0 right-0 z-50 bg-black/80 backdrop-blur-sm px-4 py-2">
|
||||
<div class="flex items-center justify-center text-xs text-gray-400">
|
||||
<span>Made by <a href="https://github.com/amiayweb" target="_blank" class="text-blue-400 hover:text-blue-300 transition-colors">@amiayweb</a></span>
|
||||
<span>Made by <a href="https://github.com/amiayweb" target="_blank"
|
||||
class="text-blue-400 hover:text-blue-300 transition-colors">@amiayweb</a> & <a
|
||||
href="https://github.com/Relyz1993" target="_blank"
|
||||
class="text-blue-400 hover:text-blue-300 transition-colors">@Relyz</a></span>
|
||||
<span class="mx-2">|</span>
|
||||
<span>Contributors:
|
||||
<a href="https://github.com/chasem-dev" target="_blank" class="text-blue-400 hover:text-blue-300 transition-colors">@chasem-dev</a>,
|
||||
<a href="https://github.com/crimera" target="_blank" class="text-blue-400 hover:text-blue-300 transition-colors">@crimera</a>,
|
||||
<a href="https://github.com/sanasol" target="_blank" class="text-blue-400 hover:text-blue-300 transition-colors">@sanasol</a>,
|
||||
<a href="https://github.com/Terromur" target="_blank" class="text-blue-400 hover:text-blue-300 transition-colors">@terromur</a>,
|
||||
<a href="https://github.com/ericiskoolbeans" target="_blank" class="text-blue-400 hover:text-blue-300 transition-colors">@ericiskoolbeans</a>
|
||||
<a href="https://github.com/chasem-dev" target="_blank"
|
||||
class="text-blue-400 hover:text-blue-300 transition-colors">@chasem-dev</a>,
|
||||
<a href="https://github.com/crimera" target="_blank"
|
||||
class="text-blue-400 hover:text-blue-300 transition-colors">@crimera</a>,
|
||||
<a href="https://github.com/sanasol" target="_blank"
|
||||
class="text-blue-400 hover:text-blue-300 transition-colors">@sanasol</a>,
|
||||
<a href="https://github.com/Terromur" target="_blank"
|
||||
class="text-blue-400 hover:text-blue-300 transition-colors">@terromur</a>,
|
||||
<a href="https://github.com/ericiskoolbeans" target="_blank"
|
||||
class="text-blue-400 hover:text-blue-300 transition-colors">@ericiskoolbeans</a>,
|
||||
<a href="https://github.com/fazrigading" target="_blank"
|
||||
class="text-blue-400 hover:text-blue-300 transition-colors">@fazrigading</a>
|
||||
</span>
|
||||
</div>
|
||||
</footer>
|
||||
@@ -434,7 +675,8 @@
|
||||
<div class="notification-content">
|
||||
<i class="fab fa-discord"></i>
|
||||
<span class="notification-text">Join our Discord community!</span>
|
||||
<button class="notification-action" onclick="window.electronAPI?.openExternal('https://discord.gg/n6HZ7NwSQd')">
|
||||
<button class="notification-action"
|
||||
onclick="window.electronAPI?.openExternal('https://discord.gg/n6HZ7NwSQd')">
|
||||
Join Discord
|
||||
</button>
|
||||
</div>
|
||||
@@ -442,7 +684,52 @@
|
||||
<i class="fas fa-times"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Modal pour sélectionner la couleur du chat -->
|
||||
<div id="chatColorModal" class="chat-color-modal" style="display: none;">
|
||||
<div class="chat-color-modal-content">
|
||||
<div class="chat-color-modal-header">
|
||||
<h3 class="chat-color-modal-title">
|
||||
<i class="fas fa-palette"></i>
|
||||
Customize Username Color
|
||||
</h3>
|
||||
<button class="modal-close-btn" onclick="closeChatColorModal()">
|
||||
<i class="fas fa-times"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="chat-color-modal-body">
|
||||
<div id="solidColorSection" class="color-section">
|
||||
<h4>Choose a solid color:</h4>
|
||||
<div class="predefined-colors">
|
||||
<div class="color-option" data-color="#3498db" style="background: #3498db;"></div>
|
||||
<div class="color-option" data-color="#e74c3c" style="background: #e74c3c;"></div>
|
||||
<div class="color-option" data-color="#2ecc71" style="background: #2ecc71;"></div>
|
||||
<div class="color-option" data-color="#f39c12" style="background: #f39c12;"></div>
|
||||
<div class="color-option" data-color="#9b59b6" style="background: #9b59b6;"></div>
|
||||
<div class="color-option" data-color="#1abc9c" style="background: #1abc9c;"></div>
|
||||
<div class="color-option" data-color="#e91e63" style="background: #e91e63;"></div>
|
||||
<div class="color-option" data-color="#ff5722" style="background: #ff5722;"></div>
|
||||
</div>
|
||||
<div class="custom-color-input">
|
||||
<label for="customColor">Custom color:</label>
|
||||
<input type="color" id="customColor" value="#3498db">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="color-preview">
|
||||
<h4>Preview:</h4>
|
||||
<div id="colorPreview" class="preview-username">YourUsername</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chat-color-modal-footer">
|
||||
<button class="btn-secondary" onclick="closeChatColorModal()">Cancel</button>
|
||||
<button class="btn-primary" onclick="applyChatColor()">Apply Color</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="module" src="js/update.js"></script>
|
||||
</body>
|
||||
|
||||
|
||||
</html>
|
||||
|
||||
154
GUI/js/chat.js
154
GUI/js/chat.js
@@ -3,20 +3,34 @@ let socket = null;
|
||||
let isAuthenticated = false;
|
||||
let messageQueue = [];
|
||||
let chatUsername = '';
|
||||
const SOCKET_URL = 'http://3.10.208.30:3001';
|
||||
let userColor = '#3498db';
|
||||
let userBadge = null;
|
||||
const SOCKET_URL = 'https://chat.hytalef2p.com';
|
||||
const MAX_MESSAGE_LENGTH = 500;
|
||||
|
||||
async function getOrCreatePlayerId() {
|
||||
return `user_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
||||
}
|
||||
|
||||
export async function initChat() {
|
||||
if (window.electronAPI?.loadChatUsername) {
|
||||
chatUsername = await window.electronAPI.loadChatUsername();
|
||||
}
|
||||
|
||||
if (window.electronAPI?.loadChatColor) {
|
||||
const savedColor = await window.electronAPI.loadChatColor();
|
||||
if (savedColor) {
|
||||
userColor = savedColor;
|
||||
}
|
||||
}
|
||||
|
||||
if (!chatUsername || chatUsername.trim() === '') {
|
||||
showUsernameModal();
|
||||
return;
|
||||
}
|
||||
|
||||
setupChatUI();
|
||||
setupColorSelector();
|
||||
await connectToChat();
|
||||
}
|
||||
|
||||
@@ -136,13 +150,22 @@ async function connectToChat() {
|
||||
reconnectionDelay: 1000
|
||||
});
|
||||
|
||||
socket.on('connect', () => {
|
||||
socket.on('connect', async () => {
|
||||
console.log('Connected to chat server');
|
||||
socket.emit('authenticate', { username: chatUsername, userId });
|
||||
|
||||
const uuid = await window.electronAPI?.getCurrentUuid();
|
||||
|
||||
socket.emit('authenticate', {
|
||||
username: chatUsername,
|
||||
userId,
|
||||
uuid: uuid,
|
||||
userColor: userColor
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('authenticated', (data) => {
|
||||
isAuthenticated = true;
|
||||
userBadge = data.badge;
|
||||
addSystemMessage(`Connected as ${data.username}`);
|
||||
|
||||
while (messageQueue.length > 0) {
|
||||
@@ -155,7 +178,7 @@ async function connectToChat() {
|
||||
if (data.type === 'system') {
|
||||
addSystemMessage(data.message);
|
||||
} else if (data.type === 'user') {
|
||||
addUserMessage(data.username, data.message, data.timestamp);
|
||||
addUserMessage(data.username, data.message, data.timestamp, data.userColor, data.badge);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -226,7 +249,7 @@ function sendMessage() {
|
||||
updateCharCounter();
|
||||
}
|
||||
|
||||
function addUserMessage(username, message, timestamp) {
|
||||
function addUserMessage(username, message, timestamp, userColor = '#3498db', badge = null) {
|
||||
const chatMessages = document.getElementById('chatMessages');
|
||||
if (!chatMessages) return;
|
||||
|
||||
@@ -238,14 +261,35 @@ function addUserMessage(username, message, timestamp) {
|
||||
minute: '2-digit'
|
||||
});
|
||||
|
||||
let badgeHTML = '';
|
||||
if (badge) {
|
||||
let badgeStyle = '';
|
||||
if (badge.style === 'rainbow') {
|
||||
badgeStyle = `background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4, #ffeaa7, #fab1a0, #fd79a8); background-size: 400% 400%; animation: rainbow 3s ease infinite; -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; font-weight: bold; display: inline;`;
|
||||
} else if (badge.style === 'gradient') {
|
||||
if (badge.badge === 'CONTRIBUTOR') {
|
||||
badgeStyle = `background: linear-gradient(45deg, #22c55e, #16a34a); background-size: 200% 200%; animation: contributorGlow 2s ease infinite; -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; font-weight: bold; display: inline;`;
|
||||
} else {
|
||||
badgeStyle = `color: ${badge.color}; font-weight: bold; display: inline;`;
|
||||
}
|
||||
}
|
||||
|
||||
badgeHTML = `<span class="user-badge" style="${badgeStyle}">[${badge.badge}]</span> `;
|
||||
}
|
||||
|
||||
messageDiv.innerHTML = `
|
||||
<div class="message-header">
|
||||
<span class="message-username">${escapeHtml(username)}</span>
|
||||
<span class="message-user-info">${badgeHTML}<span class="message-username" style="font-weight: bold;" data-username-color="${userColor}">${escapeHtml(username)}</span></span>
|
||||
<span class="message-time">${time}</span>
|
||||
</div>
|
||||
<div class="message-content">${message}</div>
|
||||
`;
|
||||
|
||||
const usernameElement = messageDiv.querySelector('.message-username');
|
||||
if (usernameElement) {
|
||||
applyUserColorStyle(usernameElement, userColor);
|
||||
}
|
||||
|
||||
chatMessages.appendChild(messageDiv);
|
||||
scrollToBottom();
|
||||
}
|
||||
@@ -352,6 +396,104 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
});
|
||||
|
||||
function setupColorSelector() {
|
||||
const colorBtn = document.getElementById('chatColorBtn');
|
||||
if (colorBtn) {
|
||||
colorBtn.addEventListener('click', showChatColorModal);
|
||||
}
|
||||
|
||||
const colorOptions = document.querySelectorAll('.color-option');
|
||||
colorOptions.forEach(option => {
|
||||
option.addEventListener('click', () => {
|
||||
document.querySelectorAll('.color-option').forEach(o => o.classList.remove('selected'));
|
||||
option.classList.add('selected');
|
||||
updateColorPreview();
|
||||
});
|
||||
});
|
||||
|
||||
const customColor = document.getElementById('customColor');
|
||||
if (customColor) {
|
||||
customColor.addEventListener('input', () => {
|
||||
document.querySelectorAll('.color-option').forEach(o => o.classList.remove('selected'));
|
||||
updateColorPreview();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function showChatColorModal() {
|
||||
const modal = document.getElementById('chatColorModal');
|
||||
if (modal) {
|
||||
modal.style.display = 'flex';
|
||||
updateColorPreview();
|
||||
}
|
||||
}
|
||||
|
||||
window.closeChatColorModal = function() {
|
||||
const modal = document.getElementById('chatColorModal');
|
||||
if (modal) {
|
||||
modal.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
function updateColorPreview() {
|
||||
const preview = document.getElementById('colorPreview');
|
||||
if (!preview) return;
|
||||
|
||||
const selectedOption = document.querySelector('.color-option.selected');
|
||||
let color = '#3498db';
|
||||
|
||||
if (selectedOption) {
|
||||
color = selectedOption.dataset.color;
|
||||
} else {
|
||||
const customColor = document.getElementById('customColor');
|
||||
if (customColor) color = customColor.value;
|
||||
}
|
||||
|
||||
preview.style.color = color;
|
||||
preview.style.background = 'transparent';
|
||||
preview.style.webkitBackgroundClip = 'initial';
|
||||
preview.style.webkitTextFillColor = 'initial';
|
||||
}
|
||||
|
||||
window.applyChatColor = async function() {
|
||||
let newColor;
|
||||
|
||||
const selectedOption = document.querySelector('.color-option.selected');
|
||||
if (selectedOption) {
|
||||
newColor = selectedOption.dataset.color;
|
||||
} else {
|
||||
const customColor = document.getElementById('customColor');
|
||||
newColor = customColor ? customColor.value : '#3498db';
|
||||
}
|
||||
|
||||
userColor = newColor;
|
||||
|
||||
if (window.electronAPI?.saveChatColor) {
|
||||
await window.electronAPI.saveChatColor(newColor);
|
||||
}
|
||||
|
||||
if (socket && isAuthenticated) {
|
||||
const uuid = await window.electronAPI?.getCurrentUuid();
|
||||
socket.emit('authenticate', {
|
||||
username: chatUsername,
|
||||
userId: await getOrCreatePlayerId(),
|
||||
uuid: uuid,
|
||||
userColor: userColor
|
||||
});
|
||||
|
||||
addSystemMessage('Username color updated successfully', 'success');
|
||||
}
|
||||
|
||||
closeChatColorModal();
|
||||
}
|
||||
|
||||
function applyUserColorStyle(element, color) {
|
||||
element.style.color = color;
|
||||
element.style.background = 'transparent';
|
||||
element.style.webkitBackgroundClip = 'initial';
|
||||
element.style.webkitTextFillColor = 'initial';
|
||||
}
|
||||
|
||||
window.ChatAPI = {
|
||||
send: sendMessage,
|
||||
disconnect: () => socket?.disconnect()
|
||||
|
||||
@@ -33,21 +33,12 @@ export function setupInstallation() {
|
||||
|
||||
if (window.electronAPI && window.electronAPI.onProgressUpdate) {
|
||||
window.electronAPI.onProgressUpdate((data) => {
|
||||
if (!isDownloading) return;
|
||||
if (window.LauncherUI) {
|
||||
window.LauncherUI.showProgress();
|
||||
window.LauncherUI.updateProgress(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (window.electronAPI && window.electronAPI.onProgressComplete) {
|
||||
window.electronAPI.onProgressComplete(() => {
|
||||
if (window.LauncherUI) {
|
||||
window.LauncherUI.hideProgress();
|
||||
}
|
||||
resetInstallButton();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export async function installGame() {
|
||||
@@ -75,6 +66,7 @@ export async function installGame() {
|
||||
window.LauncherUI.showLauncherOrInstall(true);
|
||||
const playerNameInput = document.getElementById('playerName');
|
||||
if (playerNameInput) playerNameInput.value = playerName;
|
||||
resetInstallButton();
|
||||
}, 2000);
|
||||
}
|
||||
} else {
|
||||
@@ -210,3 +202,9 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
setupInstallation();
|
||||
await checkGameStatusAndShowInterface();
|
||||
});
|
||||
window.browseInstallPath = browseInstallPath;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
setupInstallation();
|
||||
await checkGameStatusAndShowInterface();
|
||||
});
|
||||
|
||||
@@ -25,22 +25,169 @@ export function setupLauncher() {
|
||||
|
||||
if (window.electronAPI && window.electronAPI.onProgressUpdate) {
|
||||
window.electronAPI.onProgressUpdate((data) => {
|
||||
if (!isDownloading) return;
|
||||
if (window.LauncherUI) {
|
||||
window.LauncherUI.showProgress();
|
||||
window.LauncherUI.updateProgress(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (window.electronAPI && window.electronAPI.onProgressComplete) {
|
||||
window.electronAPI.onProgressComplete(() => {
|
||||
if (window.LauncherUI) {
|
||||
window.LauncherUI.hideProgress();
|
||||
// Initial Profile Load
|
||||
loadProfiles();
|
||||
|
||||
// Close dropdown on outside click
|
||||
document.addEventListener('click', (e) => {
|
||||
const selector = document.getElementById('profileSelector');
|
||||
if (selector && !selector.contains(e.target)) {
|
||||
const dropdown = document.getElementById('profileDropdown');
|
||||
if (dropdown) dropdown.classList.remove('show');
|
||||
}
|
||||
resetPlayButton();
|
||||
});
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// PROFILE MANAGEMENT
|
||||
// ==========================================
|
||||
|
||||
async function loadProfiles() {
|
||||
try {
|
||||
if (!window.electronAPI || !window.electronAPI.profile) return;
|
||||
|
||||
const profiles = await window.electronAPI.profile.list();
|
||||
const activeProfile = await window.electronAPI.profile.getActive();
|
||||
|
||||
renderProfileList(profiles, activeProfile);
|
||||
updateCurrentProfileUI(activeProfile);
|
||||
} catch (error) {
|
||||
console.error('Failed to load profiles:', error);
|
||||
}
|
||||
}
|
||||
|
||||
function renderProfileList(profiles, activeProfile) {
|
||||
const list = document.getElementById('profileList');
|
||||
const managerList = document.getElementById('managerProfileList');
|
||||
|
||||
if (!list) return;
|
||||
|
||||
// Dropdown List
|
||||
list.innerHTML = profiles.map(p => `
|
||||
<div class="profile-item ${p.id === activeProfile.id ? 'active' : ''}"
|
||||
onclick="switchProfile('${p.id}')">
|
||||
<span>${p.name}</span>
|
||||
${p.id === activeProfile.id ? '<i class="fas fa-check ml-auto"></i>' : ''}
|
||||
</div>
|
||||
`).join('');
|
||||
|
||||
// Manager Modal List
|
||||
if (managerList) {
|
||||
managerList.innerHTML = profiles.map(p => `
|
||||
<div class="profile-manager-item ${p.id === activeProfile.id ? 'active' : ''}">
|
||||
<div class="flex items-center gap-3">
|
||||
<i class="fas fa-user-circle text-xl text-gray-400"></i>
|
||||
<div>
|
||||
<div class="font-bold">${p.name}</div>
|
||||
<div class="text-xs text-gray-500">ID: ${p.id.substring(0, 8)}...</div>
|
||||
</div>
|
||||
</div>
|
||||
${p.id !== activeProfile.id ? `
|
||||
<button class="profile-delete-btn" onclick="deleteProfile('${p.id}')" title="Delete Profile">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
` : '<span class="text-xs text-green-500 font-bold px-2">ACTIVE</span>'}
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
}
|
||||
|
||||
function updateCurrentProfileUI(profile) {
|
||||
const nameEl = document.getElementById('currentProfileName');
|
||||
if (nameEl && profile) {
|
||||
nameEl.textContent = profile.name;
|
||||
}
|
||||
}
|
||||
|
||||
window.toggleProfileDropdown = () => {
|
||||
const dropdown = document.getElementById('profileDropdown');
|
||||
if (dropdown) {
|
||||
dropdown.classList.toggle('show');
|
||||
}
|
||||
};
|
||||
|
||||
window.openProfileManager = () => {
|
||||
const modal = document.getElementById('profileManagerModal');
|
||||
if (modal) {
|
||||
modal.style.display = 'flex';
|
||||
// Refresh list
|
||||
loadProfiles();
|
||||
}
|
||||
// Close dropdown
|
||||
const dropdown = document.getElementById('profileDropdown');
|
||||
if (dropdown) dropdown.classList.remove('show');
|
||||
};
|
||||
|
||||
window.closeProfileManager = () => {
|
||||
const modal = document.getElementById('profileManagerModal');
|
||||
if (modal) modal.style.display = 'none';
|
||||
};
|
||||
|
||||
window.createNewProfile = async () => {
|
||||
const input = document.getElementById('newProfileName');
|
||||
if (!input || !input.value.trim()) return;
|
||||
|
||||
try {
|
||||
const name = input.value.trim();
|
||||
await window.electronAPI.profile.create(name);
|
||||
input.value = '';
|
||||
await loadProfiles();
|
||||
} catch (error) {
|
||||
console.error('Failed to create profile:', error);
|
||||
alert('Failed to create profile: ' + error.message);
|
||||
}
|
||||
};
|
||||
|
||||
window.deleteProfile = async (id) => {
|
||||
if (!confirm('Are you sure you want to delete this profile? parameters and mods configuration will be lost.')) return;
|
||||
|
||||
try {
|
||||
await window.electronAPI.profile.delete(id);
|
||||
await loadProfiles();
|
||||
} catch (error) {
|
||||
console.error('Failed to delete profile:', error);
|
||||
alert('Failed to delete profile: ' + error.message);
|
||||
}
|
||||
};
|
||||
|
||||
window.switchProfile = async (id) => {
|
||||
try {
|
||||
if (window.LauncherUI) window.LauncherUI.showProgress();
|
||||
if (window.LauncherUI) window.LauncherUI.updateProgress({ message: 'Switching Profile...' });
|
||||
|
||||
await window.electronAPI.profile.activate(id);
|
||||
|
||||
// Refresh UI
|
||||
await loadProfiles();
|
||||
|
||||
// Refresh Mods
|
||||
if (window.modsManager) {
|
||||
if (window.modsManager.loadInstalledMods) await window.modsManager.loadInstalledMods();
|
||||
if (window.modsManager.loadBrowseMods) await window.modsManager.loadBrowseMods();
|
||||
}
|
||||
|
||||
// Close dropdown
|
||||
const dropdown = document.getElementById('profileDropdown');
|
||||
if (dropdown) dropdown.classList.remove('show');
|
||||
|
||||
if (window.LauncherUI) {
|
||||
window.LauncherUI.updateProgress({ message: 'Profile Switched!' });
|
||||
setTimeout(() => window.LauncherUI.hideProgress(), 1000);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('Failed to switch profile:', error);
|
||||
alert('Failed to switch profile: ' + error.message);
|
||||
if (window.LauncherUI) window.LauncherUI.hideProgress();
|
||||
}
|
||||
};
|
||||
|
||||
export async function launch() {
|
||||
if (isDownloading || (playBtn && playBtn.disabled)) return;
|
||||
@@ -57,6 +204,15 @@ export async function launch() {
|
||||
javaPath = window.SettingsAPI.getCurrentJavaPath();
|
||||
}
|
||||
|
||||
let gpuPreference = 'auto';
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.loadGpuPreference) {
|
||||
gpuPreference = await window.electronAPI.loadGpuPreference();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading GPU preference:', error);
|
||||
}
|
||||
|
||||
if (window.LauncherUI) window.LauncherUI.showProgress();
|
||||
isDownloading = true;
|
||||
if (playBtn) {
|
||||
@@ -65,49 +221,182 @@ export async function launch() {
|
||||
}
|
||||
|
||||
try {
|
||||
if (window.LauncherUI) window.LauncherUI.updateProgress({ message: 'Starting game...' });
|
||||
|
||||
if (window.electronAPI && window.electronAPI.launchGame) {
|
||||
const result = await window.electronAPI.launchGame(playerName, javaPath, '');
|
||||
const result = await window.electronAPI.launchGame(playerName, javaPath, '', gpuPreference);
|
||||
|
||||
isDownloading = false;
|
||||
|
||||
if (window.LauncherUI) {
|
||||
window.LauncherUI.hideProgress();
|
||||
}
|
||||
resetPlayButton();
|
||||
|
||||
if (result.success) {
|
||||
if (window.LauncherUI) {
|
||||
window.LauncherUI.updateProgress({ message: 'Game started successfully!' });
|
||||
setTimeout(() => {
|
||||
window.LauncherUI.hideProgress();
|
||||
if (window.electronAPI.minimizeWindow) {
|
||||
setTimeout(() => {
|
||||
window.electronAPI.minimizeWindow();
|
||||
}
|
||||
}, 2000);
|
||||
}, 500);
|
||||
}
|
||||
} else {
|
||||
throw new Error(result.error || 'Launch failed');
|
||||
console.error('Launch failed:', result.error);
|
||||
}
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
isDownloading = false;
|
||||
|
||||
if (window.LauncherUI) {
|
||||
window.LauncherUI.updateProgress({ message: 'Game started successfully!' });
|
||||
setTimeout(() => {
|
||||
window.LauncherUI.hideProgress();
|
||||
resetPlayButton();
|
||||
}, 2000);
|
||||
}
|
||||
}, 2000);
|
||||
resetPlayButton();
|
||||
}
|
||||
} catch (error) {
|
||||
isDownloading = false;
|
||||
|
||||
if (window.LauncherUI) {
|
||||
window.LauncherUI.updateProgress({ message: `Failed: ${error.message}` });
|
||||
setTimeout(() => {
|
||||
window.LauncherUI.hideProgress();
|
||||
}
|
||||
resetPlayButton();
|
||||
}, 3000);
|
||||
console.error('Launch error:', error);
|
||||
}
|
||||
}
|
||||
|
||||
function showCustomConfirm(message, title = 'Confirm Action', onConfirm, onCancel = null, confirmText = 'Confirm', cancelText = 'Cancel') {
|
||||
const existingModal = document.querySelector('.custom-confirm-modal');
|
||||
if (existingModal) {
|
||||
existingModal.remove();
|
||||
}
|
||||
|
||||
const modal = document.createElement('div');
|
||||
modal.className = 'custom-confirm-modal';
|
||||
modal.style.cssText = `
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
backdrop-filter: blur(4px);
|
||||
z-index: 20000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s ease;
|
||||
`;
|
||||
|
||||
const dialog = document.createElement('div');
|
||||
dialog.className = 'custom-confirm-dialog';
|
||||
dialog.style.cssText = `
|
||||
background: #1f2937;
|
||||
border-radius: 12px;
|
||||
padding: 0;
|
||||
min-width: 400px;
|
||||
max-width: 500px;
|
||||
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
|
||||
border: 1px solid rgba(239, 68, 68, 0.3);
|
||||
transform: scale(0.9);
|
||||
transition: transform 0.3s ease;
|
||||
`;
|
||||
|
||||
dialog.innerHTML = `
|
||||
<div style="padding: 24px; border-bottom: 1px solid rgba(255,255,255,0.1);">
|
||||
<div style="display: flex; align-items: center; gap: 12px; color: #ef4444;">
|
||||
<i class="fas fa-exclamation-triangle" style="font-size: 24px;"></i>
|
||||
<h3 style="margin: 0; font-size: 1.2rem; font-weight: 600;">${title}</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div style="padding: 24px; color: #e5e7eb;">
|
||||
<p style="margin: 0; line-height: 1.5; font-size: 1rem;">${message}</p>
|
||||
</div>
|
||||
<div style="padding: 20px 24px; display: flex; gap: 12px; justify-content: flex-end; border-top: 1px solid rgba(255,255,255,0.1);">
|
||||
<button class="custom-confirm-cancel" style="
|
||||
background: transparent;
|
||||
color: #9ca3af;
|
||||
border: 1px solid rgba(156, 163, 175, 0.3);
|
||||
padding: 10px 20px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-weight: 500;
|
||||
transition: all 0.2s;
|
||||
">${cancelText}</button>
|
||||
<button class="custom-confirm-action" style="
|
||||
background: #ef4444;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px 20px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-weight: 500;
|
||||
transition: all 0.2s;
|
||||
">${confirmText}</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
modal.appendChild(dialog);
|
||||
document.body.appendChild(modal);
|
||||
|
||||
// Animate in
|
||||
setTimeout(() => {
|
||||
modal.style.opacity = '1';
|
||||
dialog.style.transform = 'scale(1)';
|
||||
}, 10);
|
||||
|
||||
// Event handlers
|
||||
const cancelBtn = dialog.querySelector('.custom-confirm-cancel');
|
||||
const actionBtn = dialog.querySelector('.custom-confirm-action');
|
||||
|
||||
const closeModal = () => {
|
||||
modal.style.opacity = '0';
|
||||
dialog.style.transform = 'scale(0.9)';
|
||||
setTimeout(() => {
|
||||
modal.remove();
|
||||
}, 300);
|
||||
};
|
||||
|
||||
cancelBtn.onclick = () => {
|
||||
closeModal();
|
||||
if (onCancel) onCancel();
|
||||
};
|
||||
|
||||
actionBtn.onclick = () => {
|
||||
closeModal();
|
||||
onConfirm();
|
||||
};
|
||||
|
||||
modal.onclick = (e) => {
|
||||
if (e.target === modal) {
|
||||
closeModal();
|
||||
if (onCancel) onCancel();
|
||||
}
|
||||
};
|
||||
|
||||
// Escape key
|
||||
const handleEscape = (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
closeModal();
|
||||
if (onCancel) onCancel();
|
||||
document.removeEventListener('keydown', handleEscape);
|
||||
}
|
||||
};
|
||||
document.addEventListener('keydown', handleEscape);
|
||||
}
|
||||
|
||||
export async function uninstallGame() {
|
||||
if (!confirm('Are you sure you want to uninstall Hytale? All game files will be deleted.')) {
|
||||
return;
|
||||
showCustomConfirm(
|
||||
'Are you sure you want to uninstall Hytale? All game files will be deleted.',
|
||||
'Uninstall Game',
|
||||
async () => {
|
||||
await performUninstall();
|
||||
},
|
||||
null,
|
||||
'Uninstall',
|
||||
'Cancel'
|
||||
);
|
||||
}
|
||||
|
||||
async function performUninstall() {
|
||||
|
||||
if (window.LauncherUI) window.LauncherUI.showProgress();
|
||||
if (window.LauncherUI) window.LauncherUI.updateProgress({ message: 'Uninstalling game...' });
|
||||
if (uninstallBtn) uninstallBtn.disabled = true;
|
||||
@@ -148,6 +437,49 @@ export async function uninstallGame() {
|
||||
}
|
||||
}
|
||||
|
||||
export async function repairGame() {
|
||||
showCustomConfirm(
|
||||
'Are you sure you want to repair Hytale? This will reinstall the game files but keep your data (saves, screenshots, etc.).',
|
||||
'Repair Game',
|
||||
async () => {
|
||||
await performRepair();
|
||||
},
|
||||
null,
|
||||
'Repair',
|
||||
'Cancel'
|
||||
);
|
||||
}
|
||||
|
||||
async function performRepair() {
|
||||
if (window.LauncherUI) window.LauncherUI.showProgress();
|
||||
if (window.LauncherUI) window.LauncherUI.updateProgress({ message: 'Repairing game...' });
|
||||
isDownloading = true;
|
||||
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.repairGame) {
|
||||
const result = await window.electronAPI.repairGame();
|
||||
|
||||
if (result.success) {
|
||||
if (window.LauncherUI) {
|
||||
window.LauncherUI.updateProgress({ message: 'Game repaired successfully!' });
|
||||
setTimeout(() => {
|
||||
window.LauncherUI.hideProgress();
|
||||
}, 2000);
|
||||
}
|
||||
} else {
|
||||
throw new Error(result.error || 'Repair failed');
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
if (window.LauncherUI) {
|
||||
window.LauncherUI.updateProgress({ message: `Repair failed: ${error.message}` });
|
||||
setTimeout(() => window.LauncherUI.hideProgress(), 3000);
|
||||
}
|
||||
} finally {
|
||||
isDownloading = false;
|
||||
}
|
||||
}
|
||||
|
||||
function resetPlayButton() {
|
||||
isDownloading = false;
|
||||
if (playBtn) {
|
||||
@@ -240,5 +572,59 @@ async function loadCustomJavaPath() {
|
||||
|
||||
window.launch = launch;
|
||||
window.uninstallGame = uninstallGame;
|
||||
window.repairGame = repairGame;
|
||||
|
||||
window.openLogs = async () => {
|
||||
if (window.LauncherUI) {
|
||||
window.LauncherUI.showPage('logs-page');
|
||||
window.LauncherUI.setActiveNav('logs');
|
||||
}
|
||||
await refreshLogs();
|
||||
};
|
||||
|
||||
window.openLogsFolder = async () => {
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.openLogsFolder) {
|
||||
await window.electronAPI.openLogsFolder();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to open logs folder:', error);
|
||||
}
|
||||
};
|
||||
|
||||
window.refreshLogs = async () => {
|
||||
const terminal = document.getElementById('logsTerminal');
|
||||
if (!terminal) return;
|
||||
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.getRecentLogs) {
|
||||
// Fetch up to MAX_LOG_LINES lines
|
||||
const logs = await window.electronAPI.getRecentLogs(MAX_LOG_LINES);
|
||||
if (logs) {
|
||||
// Formatting for colors could be done here if needed
|
||||
terminal.textContent = logs;
|
||||
terminal.scrollTop = terminal.scrollHeight;
|
||||
} else {
|
||||
terminal.textContent = 'No logs available.';
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
terminal.textContent = 'Error loading logs: ' + error.message;
|
||||
}
|
||||
};
|
||||
|
||||
window.copyLogs = () => {
|
||||
const terminal = document.getElementById('logsTerminal');
|
||||
if (terminal) {
|
||||
navigator.clipboard.writeText(terminal.textContent)
|
||||
.then(() => alert('Logs copied to clipboard!'))
|
||||
.catch(err => console.error('Failed to copy logs:', err));
|
||||
}
|
||||
};
|
||||
|
||||
window.repairGame = repairGame;
|
||||
|
||||
// Constants
|
||||
const MAX_LOG_LINES = 500;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', setupLauncher);
|
||||
|
||||
96
GUI/js/logs.js
Normal file
96
GUI/js/logs.js
Normal file
@@ -0,0 +1,96 @@
|
||||
|
||||
// Logs Page Logic
|
||||
|
||||
async function loadLogs() {
|
||||
const terminal = document.getElementById('logsTerminal');
|
||||
if (!terminal) return;
|
||||
|
||||
terminal.innerHTML = '<div class="text-gray-500 text-center mt-10">Loading logs...</div>';
|
||||
|
||||
try {
|
||||
const logs = await window.electronAPI.getRecentLogs(500); // Fetch last 500 lines
|
||||
|
||||
if (logs) {
|
||||
// Escape HTML to prevent XSS and preserve format
|
||||
const safeLogs = logs.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'");
|
||||
|
||||
terminal.innerHTML = `<pre class="logs-content">${safeLogs}</pre>`;
|
||||
|
||||
// Auto scroll to bottom
|
||||
terminal.scrollTop = terminal.scrollHeight;
|
||||
} else {
|
||||
terminal.innerHTML = '<div class="text-gray-500 text-center mt-10">No logs found.</div>';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load logs:', error);
|
||||
terminal.innerHTML = `<div class="text-red-500 text-center mt-10">Error loading logs: ${error.message}</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshLogs() {
|
||||
const btn = document.querySelector('button[onclick="refreshLogs()"] i');
|
||||
if (btn) btn.classList.add('fa-spin');
|
||||
|
||||
await loadLogs();
|
||||
|
||||
if (btn) setTimeout(() => btn.classList.remove('fa-spin'), 500);
|
||||
}
|
||||
|
||||
async function copyLogs() {
|
||||
const terminal = document.getElementById('logsTerminal');
|
||||
if (!terminal) return;
|
||||
|
||||
const content = terminal.innerText;
|
||||
if (!content) return;
|
||||
|
||||
try {
|
||||
await navigator.clipboard.writeText(content);
|
||||
|
||||
const btn = document.querySelector('button[onclick="copyLogs()"]');
|
||||
const originalText = btn.innerHTML;
|
||||
|
||||
btn.innerHTML = '<i class="fas fa-check"></i> Copied!';
|
||||
setTimeout(() => {
|
||||
btn.innerHTML = originalText;
|
||||
}, 2000);
|
||||
} catch (err) {
|
||||
console.error('Failed to copy logs:', err);
|
||||
}
|
||||
}
|
||||
|
||||
async function openLogsFolder() {
|
||||
await window.electronAPI.openLogsFolder();
|
||||
}
|
||||
|
||||
function openLogs() {
|
||||
// Navigation is handled by sidebar logic, but we can trigger a refresh
|
||||
window.LauncherUI.showPage('logs-page');
|
||||
window.LauncherUI.setActiveNav('logs');
|
||||
refreshLogs();
|
||||
}
|
||||
|
||||
// Expose functions globally
|
||||
window.refreshLogs = refreshLogs;
|
||||
window.copyLogs = copyLogs;
|
||||
window.openLogsFolder = openLogsFolder;
|
||||
window.openLogs = openLogs;
|
||||
|
||||
// Auto-load logs when the page becomes active
|
||||
const logsObserver = new MutationObserver((mutations) => {
|
||||
mutations.forEach((mutation) => {
|
||||
if (mutation.target.classList.contains('active') && mutation.target.id === 'logs-page') {
|
||||
loadLogs();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const logsPage = document.getElementById('logs-page');
|
||||
if (logsPage) {
|
||||
logsObserver.observe(logsPage, { attributes: true, attributeFilter: ['class'] });
|
||||
}
|
||||
});
|
||||
@@ -282,10 +282,17 @@ function displayBrowseMods(mods) {
|
||||
}
|
||||
|
||||
function createBrowseModCard(mod) {
|
||||
const isInstalled = installedMods.some(installed =>
|
||||
installed.name.toLowerCase().includes(mod.name.toLowerCase()) ||
|
||||
installed.curseForgeId == mod.id
|
||||
);
|
||||
const isInstalled = installedMods.some(installed => {
|
||||
// Check by CurseForge ID (most reliable)
|
||||
if (installed.curseForgeId && installed.curseForgeId.toString() === mod.id.toString()) {
|
||||
return true;
|
||||
}
|
||||
// Check by exact name match for manually installed mods
|
||||
if (installed.name.toLowerCase() === mod.name.toLowerCase()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
return `
|
||||
<div class=\"mod-card ${isInstalled ? 'installed' : ''}\" data-mod-id=\"${mod.id}\">
|
||||
@@ -522,7 +529,6 @@ function showNotification(message, type = 'info', duration = 4000) {
|
||||
}, duration);
|
||||
}
|
||||
|
||||
// Custom confirmation modal
|
||||
function showConfirmModal(message, onConfirm, onCancel = null) {
|
||||
const existingModal = document.querySelector('.mod-confirm-modal');
|
||||
if (existingModal) {
|
||||
@@ -718,7 +724,9 @@ window.modsManager = {
|
||||
deleteMod,
|
||||
openMyModsModal,
|
||||
closeMyModsModal,
|
||||
viewModPage
|
||||
viewModPage,
|
||||
loadInstalledMods,
|
||||
loadBrowseMods
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', initModsManager);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
const API_URL = 'http://3.10.208.30/api';
|
||||
const API_URL = 'https://api.hytalef2p.com/api';
|
||||
let updateInterval = null;
|
||||
let currentUserId = null;
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ import './mods.js';
|
||||
import './players.js';
|
||||
import './chat.js';
|
||||
import './settings.js';
|
||||
import './logs.js';
|
||||
|
||||
// Discord notification functions
|
||||
window.closeDiscordNotification = function () {
|
||||
const notification = document.getElementById('discordNotification');
|
||||
if (notification) {
|
||||
@@ -18,23 +18,20 @@ window.closeDiscordNotification = function() {
|
||||
}
|
||||
};
|
||||
|
||||
// Show notification after a delay
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const notification = document.getElementById('discordNotification');
|
||||
if (notification) {
|
||||
// Check if user has previously dismissed the notification
|
||||
const dismissed = localStorage.getItem('discordNotificationDismissed');
|
||||
if (!dismissed) {
|
||||
setTimeout(() => {
|
||||
notification.style.display = 'flex';
|
||||
}, 3000); // Show after 3 seconds
|
||||
}, 3000);
|
||||
} else {
|
||||
notification.style.display = 'none';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Remember when user closes notification
|
||||
const originalClose = window.closeDiscordNotification;
|
||||
window.closeDiscordNotification = function () {
|
||||
localStorage.setItem('discordNotificationDismissed', 'true');
|
||||
|
||||
@@ -4,6 +4,145 @@ let customJavaOptions;
|
||||
let customJavaPath;
|
||||
let browseJavaBtn;
|
||||
let settingsPlayerName;
|
||||
let discordRPCCheck;
|
||||
let gpuPreferenceRadios;
|
||||
|
||||
// UUID Management elements
|
||||
let currentUuidDisplay;
|
||||
let copyUuidBtn;
|
||||
let regenerateUuidBtn;
|
||||
let manageUuidsBtn;
|
||||
let uuidModal;
|
||||
let uuidModalClose;
|
||||
let modalCurrentUuid;
|
||||
let modalCopyUuidBtn;
|
||||
let modalRegenerateUuidBtn;
|
||||
let generateNewUuidBtn;
|
||||
let uuidList;
|
||||
let customUuidInput;
|
||||
let setCustomUuidBtn;
|
||||
|
||||
function showCustomConfirm(message, title = 'Confirm Action', onConfirm, onCancel = null, confirmText = 'Confirm', cancelText = 'Cancel') {
|
||||
const existingModal = document.querySelector('.custom-confirm-modal');
|
||||
if (existingModal) {
|
||||
existingModal.remove();
|
||||
}
|
||||
|
||||
const modal = document.createElement('div');
|
||||
modal.className = 'custom-confirm-modal';
|
||||
modal.style.cssText = `
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
backdrop-filter: blur(4px);
|
||||
z-index: 20000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s ease;
|
||||
`;
|
||||
|
||||
const dialog = document.createElement('div');
|
||||
dialog.className = 'custom-confirm-dialog';
|
||||
dialog.style.cssText = `
|
||||
background: #1f2937;
|
||||
border-radius: 12px;
|
||||
padding: 0;
|
||||
min-width: 400px;
|
||||
max-width: 500px;
|
||||
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
|
||||
border: 1px solid rgba(147, 51, 234, 0.3);
|
||||
transform: scale(0.9);
|
||||
transition: transform 0.3s ease;
|
||||
`;
|
||||
|
||||
dialog.innerHTML = `
|
||||
<div style="padding: 24px; border-bottom: 1px solid rgba(255,255,255,0.1);">
|
||||
<div style="display: flex; align-items: center; gap: 12px; color: #9333ea;">
|
||||
<i class="fas fa-exclamation-triangle" style="font-size: 24px;"></i>
|
||||
<h3 style="margin: 0; font-size: 1.2rem; font-weight: 600;">${title}</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div style="padding: 24px; color: #e5e7eb;">
|
||||
<p style="margin: 0; line-height: 1.5; font-size: 1rem;">${message}</p>
|
||||
</div>
|
||||
<div style="padding: 20px 24px; display: flex; gap: 12px; justify-content: flex-end; border-top: 1px solid rgba(255,255,255,0.1);">
|
||||
<button class="custom-confirm-cancel" style="
|
||||
background: transparent;
|
||||
color: #9ca3af;
|
||||
border: 1px solid rgba(156, 163, 175, 0.3);
|
||||
padding: 10px 20px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-weight: 500;
|
||||
transition: all 0.2s;
|
||||
">${cancelText}</button>
|
||||
<button class="custom-confirm-action" style="
|
||||
background: linear-gradient(135deg, #9333ea, #3b82f6);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px 20px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-weight: 500;
|
||||
transition: all 0.2s;
|
||||
">${confirmText}</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
modal.appendChild(dialog);
|
||||
document.body.appendChild(modal);
|
||||
|
||||
// Animate in
|
||||
setTimeout(() => {
|
||||
modal.style.opacity = '1';
|
||||
dialog.style.transform = 'scale(1)';
|
||||
}, 10);
|
||||
|
||||
// Event handlers
|
||||
const cancelBtn = dialog.querySelector('.custom-confirm-cancel');
|
||||
const actionBtn = dialog.querySelector('.custom-confirm-action');
|
||||
|
||||
const closeModal = () => {
|
||||
modal.style.opacity = '0';
|
||||
dialog.style.transform = 'scale(0.9)';
|
||||
setTimeout(() => {
|
||||
modal.remove();
|
||||
}, 300);
|
||||
};
|
||||
|
||||
cancelBtn.onclick = () => {
|
||||
closeModal();
|
||||
if (onCancel) onCancel();
|
||||
};
|
||||
|
||||
actionBtn.onclick = () => {
|
||||
closeModal();
|
||||
onConfirm();
|
||||
};
|
||||
|
||||
modal.onclick = (e) => {
|
||||
if (e.target === modal) {
|
||||
closeModal();
|
||||
if (onCancel) onCancel();
|
||||
}
|
||||
};
|
||||
|
||||
// Escape key
|
||||
const handleEscape = (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
closeModal();
|
||||
if (onCancel) onCancel();
|
||||
document.removeEventListener('keydown', handleEscape);
|
||||
}
|
||||
};
|
||||
document.addEventListener('keydown', handleEscape);
|
||||
}
|
||||
|
||||
|
||||
export function initSettings() {
|
||||
setupSettingsElements();
|
||||
@@ -16,6 +155,23 @@ function setupSettingsElements() {
|
||||
customJavaPath = document.getElementById('customJavaPath');
|
||||
browseJavaBtn = document.getElementById('browseJavaBtn');
|
||||
settingsPlayerName = document.getElementById('settingsPlayerName');
|
||||
discordRPCCheck = document.getElementById('discordRPCCheck');
|
||||
gpuPreferenceRadios = document.querySelectorAll('input[name="gpuPreference"]');
|
||||
|
||||
// UUID Management elements
|
||||
currentUuidDisplay = document.getElementById('currentUuid');
|
||||
copyUuidBtn = document.getElementById('copyUuidBtn');
|
||||
regenerateUuidBtn = document.getElementById('regenerateUuidBtn');
|
||||
manageUuidsBtn = document.getElementById('manageUuidsBtn');
|
||||
uuidModal = document.getElementById('uuidModal');
|
||||
uuidModalClose = document.getElementById('uuidModalClose');
|
||||
modalCurrentUuid = document.getElementById('modalCurrentUuid');
|
||||
modalCopyUuidBtn = document.getElementById('modalCopyUuidBtn');
|
||||
modalRegenerateUuidBtn = document.getElementById('modalRegenerateUuidBtn');
|
||||
generateNewUuidBtn = document.getElementById('generateNewUuidBtn');
|
||||
uuidList = document.getElementById('uuidList');
|
||||
customUuidInput = document.getElementById('customUuidInput');
|
||||
setCustomUuidBtn = document.getElementById('setCustomUuidBtn');
|
||||
|
||||
if (customJavaCheck) {
|
||||
customJavaCheck.addEventListener('change', toggleCustomJava);
|
||||
@@ -28,6 +184,60 @@ function setupSettingsElements() {
|
||||
if (settingsPlayerName) {
|
||||
settingsPlayerName.addEventListener('change', savePlayerName);
|
||||
}
|
||||
|
||||
if (discordRPCCheck) {
|
||||
discordRPCCheck.addEventListener('change', saveDiscordRPC);
|
||||
}
|
||||
|
||||
// UUID event listeners
|
||||
if (copyUuidBtn) {
|
||||
copyUuidBtn.addEventListener('click', copyCurrentUuid);
|
||||
}
|
||||
|
||||
if (regenerateUuidBtn) {
|
||||
regenerateUuidBtn.addEventListener('click', regenerateCurrentUuid);
|
||||
}
|
||||
|
||||
if (manageUuidsBtn) {
|
||||
manageUuidsBtn.addEventListener('click', openUuidModal);
|
||||
}
|
||||
|
||||
if (uuidModalClose) {
|
||||
uuidModalClose.addEventListener('click', closeUuidModal);
|
||||
}
|
||||
|
||||
if (modalCopyUuidBtn) {
|
||||
modalCopyUuidBtn.addEventListener('click', copyCurrentUuid);
|
||||
}
|
||||
|
||||
if (modalRegenerateUuidBtn) {
|
||||
modalRegenerateUuidBtn.addEventListener('click', regenerateCurrentUuid);
|
||||
}
|
||||
|
||||
if (generateNewUuidBtn) {
|
||||
generateNewUuidBtn.addEventListener('click', generateNewUuid);
|
||||
}
|
||||
|
||||
if (setCustomUuidBtn) {
|
||||
setCustomUuidBtn.addEventListener('click', setCustomUuid);
|
||||
}
|
||||
|
||||
if (uuidModal) {
|
||||
uuidModal.addEventListener('click', (e) => {
|
||||
if (e.target === uuidModal) {
|
||||
closeUuidModal();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (gpuPreferenceRadios) {
|
||||
gpuPreferenceRadios.forEach(radio => {
|
||||
radio.addEventListener('change', async () => {
|
||||
await saveGpuPreference();
|
||||
await updateGpuLabel();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function toggleCustomJava() {
|
||||
@@ -90,33 +300,158 @@ async function loadCustomJavaPath() {
|
||||
}
|
||||
}
|
||||
|
||||
async function savePlayerName() {
|
||||
async function saveDiscordRPC() {
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.saveUsername && settingsPlayerName) {
|
||||
const playerName = settingsPlayerName.value.trim() || 'Player';
|
||||
await window.electronAPI.saveUsername(playerName);
|
||||
if (window.electronAPI && window.electronAPI.saveDiscordRPC && discordRPCCheck) {
|
||||
const enabled = discordRPCCheck.checked;
|
||||
console.log('Saving Discord RPC setting:', enabled);
|
||||
|
||||
const result = await window.electronAPI.saveDiscordRPC(enabled);
|
||||
|
||||
if (result && result.success) {
|
||||
console.log('Discord RPC setting saved successfully:', enabled);
|
||||
|
||||
// Feedback visuel pour l'utilisateur
|
||||
if (enabled) {
|
||||
showNotification('Discord Rich Presence enabled', 'success');
|
||||
} else {
|
||||
showNotification('Discord Rich Presence disabled', 'success');
|
||||
}
|
||||
} else {
|
||||
throw new Error('Failed to save Discord RPC setting');
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error saving Discord RPC setting:', error);
|
||||
showNotification('Failed to save Discord setting', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function loadDiscordRPC() {
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.loadDiscordRPC) {
|
||||
const enabled = await window.electronAPI.loadDiscordRPC();
|
||||
if (discordRPCCheck) {
|
||||
discordRPCCheck.checked = enabled;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading Discord RPC setting:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function savePlayerName() {
|
||||
try {
|
||||
if (!window.electronAPI || !settingsPlayerName) return;
|
||||
|
||||
const playerName = settingsPlayerName.value.trim();
|
||||
|
||||
if (!playerName) {
|
||||
showNotification('Please enter a valid player name', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
await window.electronAPI.saveUsername(playerName);
|
||||
showNotification('Player name saved successfully', 'success');
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error saving player name:', error);
|
||||
showNotification('Failed to save player name', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function loadPlayerName() {
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.loadUsername && settingsPlayerName) {
|
||||
if (!window.electronAPI || !settingsPlayerName) return;
|
||||
|
||||
const savedName = await window.electronAPI.loadUsername();
|
||||
if (savedName) {
|
||||
settingsPlayerName.value = savedName;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading player name:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function saveGpuPreference() {
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.saveGpuPreference && gpuPreferenceRadios) {
|
||||
const gpuPreference = Array.from(gpuPreferenceRadios).find(radio => radio.checked)?.value || 'auto';
|
||||
await window.electronAPI.saveGpuPreference(gpuPreference);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error saving GPU preference:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function updateGpuLabel() {
|
||||
const detectionInfo = document.getElementById('gpu-detection-info');
|
||||
if (!detectionInfo) return;
|
||||
|
||||
if (gpuPreferenceRadios) {
|
||||
const checked = Array.from(gpuPreferenceRadios).find(radio => radio.checked);
|
||||
if (checked) {
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.getDetectedGpu) {
|
||||
const detected = await window.electronAPI.getDetectedGpu();
|
||||
if (checked.value === 'auto') {
|
||||
if (detected.dedicatedName) {
|
||||
detectionInfo.textContent = `dGPU detected, using ${detected.dedicatedName}`;
|
||||
} else {
|
||||
detectionInfo.textContent = `dGPU not detected, using iGPU (${detected.integratedName}) instead`;
|
||||
}
|
||||
detectionInfo.style.display = 'block';
|
||||
} else if (checked.value === 'integrated') {
|
||||
detectionInfo.textContent = `Detected: ${detected.integratedName}`;
|
||||
detectionInfo.style.display = 'block';
|
||||
} else if (checked.value === 'dedicated') {
|
||||
if (detected.dedicatedName) {
|
||||
detectionInfo.textContent = `Detected: ${detected.dedicatedName}`;
|
||||
} else {
|
||||
detectionInfo.textContent = `No dedicated GPU detected`;
|
||||
}
|
||||
detectionInfo.style.display = 'block';
|
||||
} else {
|
||||
detectionInfo.style.display = 'none';
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error getting detected GPU:', error);
|
||||
detectionInfo.style.display = 'none';
|
||||
}
|
||||
} else {
|
||||
detectionInfo.style.display = 'none';
|
||||
}
|
||||
} else {
|
||||
detectionInfo.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
async function loadGpuPreference() {
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.loadGpuPreference && gpuPreferenceRadios) {
|
||||
const savedPreference = await window.electronAPI.loadGpuPreference();
|
||||
if (savedPreference) {
|
||||
for (const radio of gpuPreferenceRadios) {
|
||||
if (radio.value === savedPreference) {
|
||||
radio.checked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
await updateGpuLabel();
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading GPU preference:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadAllSettings() {
|
||||
await loadCustomJavaPath();
|
||||
await loadPlayerName();
|
||||
await loadCurrentUuid();
|
||||
await loadDiscordRPC();
|
||||
await loadGpuPreference();
|
||||
}
|
||||
|
||||
async function openGameLocation() {
|
||||
@@ -144,7 +479,6 @@ export function getCurrentPlayerName() {
|
||||
return 'Player';
|
||||
}
|
||||
|
||||
// Make openGameLocation globally available
|
||||
window.openGameLocation = openGameLocation;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', initSettings);
|
||||
@@ -153,3 +487,328 @@ window.SettingsAPI = {
|
||||
getCurrentJavaPath,
|
||||
getCurrentPlayerName
|
||||
};
|
||||
|
||||
async function loadCurrentUuid() {
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.getCurrentUuid) {
|
||||
const uuid = await window.electronAPI.getCurrentUuid();
|
||||
if (uuid) {
|
||||
if (currentUuidDisplay) currentUuidDisplay.value = uuid;
|
||||
if (modalCurrentUuid) modalCurrentUuid.value = uuid;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading current UUID:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function copyCurrentUuid() {
|
||||
try {
|
||||
const uuid = currentUuidDisplay ? currentUuidDisplay.value : modalCurrentUuid?.value;
|
||||
if (uuid && navigator.clipboard) {
|
||||
await navigator.clipboard.writeText(uuid);
|
||||
showNotification('UUID copied to clipboard!', 'success');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error copying UUID:', error);
|
||||
showNotification('Failed to copy UUID', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function regenerateCurrentUuid() {
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.resetCurrentUserUuid) {
|
||||
showCustomConfirm(
|
||||
'Are you sure you want to generate a new UUID? This will change your player identity.',
|
||||
'Generate New UUID',
|
||||
async () => {
|
||||
await performRegenerateUuid();
|
||||
},
|
||||
null,
|
||||
'Generate',
|
||||
'Cancel'
|
||||
);
|
||||
} else {
|
||||
console.error('electronAPI.resetCurrentUserUuid not available');
|
||||
showNotification('UUID regeneration not available', 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error in regenerateCurrentUuid:', error);
|
||||
showNotification('Failed to regenerate UUID', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function performRegenerateUuid() {
|
||||
try {
|
||||
const result = await window.electronAPI.resetCurrentUserUuid();
|
||||
if (result.success && result.uuid) {
|
||||
if (currentUuidDisplay) currentUuidDisplay.value = result.uuid;
|
||||
if (modalCurrentUuid) modalCurrentUuid.value = result.uuid;
|
||||
showNotification('New UUID generated successfully!', 'success');
|
||||
|
||||
if (uuidModal && uuidModal.style.display !== 'none') {
|
||||
await loadAllUuids();
|
||||
}
|
||||
} else {
|
||||
throw new Error(result.error || 'Failed to generate new UUID');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error regenerating UUID:', error);
|
||||
showNotification(`Failed to regenerate UUID: ${error.message}`, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function openUuidModal() {
|
||||
try {
|
||||
if (uuidModal) {
|
||||
uuidModal.style.display = 'flex';
|
||||
uuidModal.classList.add('active');
|
||||
await loadAllUuids();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error opening UUID modal:', error);
|
||||
}
|
||||
}
|
||||
|
||||
function closeUuidModal() {
|
||||
if (uuidModal) {
|
||||
uuidModal.classList.remove('active');
|
||||
setTimeout(() => {
|
||||
uuidModal.style.display = 'none';
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadAllUuids() {
|
||||
try {
|
||||
if (!uuidList) return;
|
||||
|
||||
uuidList.innerHTML = `
|
||||
<div class="uuid-loading">
|
||||
<i class="fas fa-spinner fa-spin"></i>
|
||||
Loading UUIDs...
|
||||
</div>
|
||||
`;
|
||||
|
||||
if (window.electronAPI && window.electronAPI.getAllUuidMappings) {
|
||||
const mappings = await window.electronAPI.getAllUuidMappings();
|
||||
|
||||
if (mappings.length === 0) {
|
||||
uuidList.innerHTML = `
|
||||
<div class="uuid-loading">
|
||||
<i class="fas fa-info-circle"></i>
|
||||
No UUIDs found
|
||||
</div>
|
||||
`;
|
||||
return;
|
||||
}
|
||||
|
||||
uuidList.innerHTML = '';
|
||||
|
||||
for (const mapping of mappings) {
|
||||
const item = document.createElement('div');
|
||||
item.className = `uuid-list-item${mapping.isCurrent ? ' current' : ''}`;
|
||||
|
||||
item.innerHTML = `
|
||||
<div class="uuid-item-info">
|
||||
<div class="uuid-item-username">${escapeHtml(mapping.username)}</div>
|
||||
<div class="uuid-item-uuid">${mapping.uuid}</div>
|
||||
</div>
|
||||
<div class="uuid-item-actions">
|
||||
${mapping.isCurrent ? '<div class="uuid-item-current-badge">Current</div>' : ''}
|
||||
<button class="uuid-item-btn copy" onclick="copyUuid('${mapping.uuid}')" title="Copy UUID">
|
||||
<i class="fas fa-copy"></i>
|
||||
</button>
|
||||
${!mapping.isCurrent ? `<button class="uuid-item-btn delete" onclick="deleteUuid('${escapeHtml(mapping.username)}')" title="Delete UUID">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>` : ''}
|
||||
</div>
|
||||
`;
|
||||
|
||||
uuidList.appendChild(item);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading UUIDs:', error);
|
||||
if (uuidList) {
|
||||
uuidList.innerHTML = `
|
||||
<div class="uuid-loading">
|
||||
<i class="fas fa-exclamation-triangle"></i>
|
||||
Error loading UUIDs
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function generateNewUuid() {
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.generateNewUuid) {
|
||||
const newUuid = await window.electronAPI.generateNewUuid();
|
||||
if (newUuid) {
|
||||
if (customUuidInput) customUuidInput.value = newUuid;
|
||||
showNotification('New UUID generated!', 'success');
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error generating new UUID:', error);
|
||||
showNotification('Failed to generate new UUID', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function setCustomUuid() {
|
||||
try {
|
||||
if (!customUuidInput || !customUuidInput.value.trim()) {
|
||||
showNotification('Please enter a UUID', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
const uuid = customUuidInput.value.trim();
|
||||
|
||||
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
if (!uuidRegex.test(uuid)) {
|
||||
showNotification('Invalid UUID format', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
showCustomConfirm(
|
||||
'Are you sure you want to set this custom UUID? This will change your player identity.',
|
||||
'Set Custom UUID',
|
||||
async () => {
|
||||
await performSetCustomUuid(uuid);
|
||||
},
|
||||
null,
|
||||
'Set UUID',
|
||||
'Cancel'
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('Error in setCustomUuid:', error);
|
||||
showNotification('Failed to set custom UUID', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function performSetCustomUuid(uuid) {
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.setUuidForUser) {
|
||||
const username = getCurrentPlayerName();
|
||||
const result = await window.electronAPI.setUuidForUser(username, uuid);
|
||||
|
||||
if (result.success) {
|
||||
if (currentUuidDisplay) currentUuidDisplay.value = uuid;
|
||||
if (modalCurrentUuid) modalCurrentUuid.value = uuid;
|
||||
if (customUuidInput) customUuidInput.value = '';
|
||||
|
||||
showNotification('Custom UUID set successfully!', 'success');
|
||||
|
||||
await loadAllUuids();
|
||||
} else {
|
||||
throw new Error(result.error || 'Failed to set custom UUID');
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error setting custom UUID:', error);
|
||||
showNotification(`Failed to set custom UUID: ${error.message}`, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
window.copyUuid = async function(uuid) {
|
||||
try {
|
||||
if (navigator.clipboard) {
|
||||
await navigator.clipboard.writeText(uuid);
|
||||
showNotification('UUID copied to clipboard!', 'success');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error copying UUID:', error);
|
||||
showNotification('Failed to copy UUID', 'error');
|
||||
}
|
||||
};
|
||||
|
||||
window.deleteUuid = async function(username) {
|
||||
try {
|
||||
showCustomConfirm(
|
||||
`Are you sure you want to delete the UUID for "${username}"? This action cannot be undone.`,
|
||||
'Delete UUID',
|
||||
async () => {
|
||||
await performDeleteUuid(username);
|
||||
},
|
||||
null,
|
||||
'Delete',
|
||||
'Cancel'
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('Error in deleteUuid:', error);
|
||||
showNotification('Failed to delete UUID', 'error');
|
||||
}
|
||||
};
|
||||
|
||||
async function performDeleteUuid(username) {
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.deleteUuidForUser) {
|
||||
const result = await window.electronAPI.deleteUuidForUser(username);
|
||||
|
||||
if (result.success) {
|
||||
showNotification('UUID deleted successfully!', 'success');
|
||||
await loadAllUuids();
|
||||
} else {
|
||||
throw new Error(result.error || 'Failed to delete UUID');
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error deleting UUID:', error);
|
||||
showNotification(`Failed to delete UUID: ${error.message}`, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
function escapeHtml(text) {
|
||||
const div = document.createElement('div');
|
||||
div.textContent = text;
|
||||
return div.innerHTML;
|
||||
}
|
||||
|
||||
function showNotification(message, type = 'info') {
|
||||
const notification = document.createElement('div');
|
||||
notification.className = `notification notification-${type}`;
|
||||
notification.style.cssText = `
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
padding: 1rem 1.5rem;
|
||||
border-radius: 8px;
|
||||
color: white;
|
||||
font-weight: 600;
|
||||
z-index: 10000;
|
||||
opacity: 0;
|
||||
transform: translateX(100%);
|
||||
transition: all 0.3s ease;
|
||||
`;
|
||||
|
||||
if (type === 'success') {
|
||||
notification.style.background = 'linear-gradient(135deg, #22c55e, #16a34a)';
|
||||
} else if (type === 'error') {
|
||||
notification.style.background = 'linear-gradient(135deg, #ef4444, #dc2626)';
|
||||
} else {
|
||||
notification.style.background = 'linear-gradient(135deg, #3b82f6, #2563eb)';
|
||||
}
|
||||
|
||||
notification.innerHTML = `
|
||||
<i class="fas fa-${type === 'success' ? 'check' : type === 'error' ? 'exclamation-triangle' : 'info-circle'}"></i>
|
||||
${message}
|
||||
`;
|
||||
|
||||
document.body.appendChild(notification);
|
||||
|
||||
setTimeout(() => {
|
||||
notification.style.opacity = '1';
|
||||
notification.style.transform = 'translateX(0)';
|
||||
}, 100);
|
||||
|
||||
setTimeout(() => {
|
||||
notification.style.opacity = '0';
|
||||
notification.style.transform = 'translateX(100%)';
|
||||
setTimeout(() => {
|
||||
if (notification.parentNode) {
|
||||
notification.parentNode.removeChild(notification);
|
||||
}
|
||||
}, 300);
|
||||
}, 3000);
|
||||
}
|
||||
10
GUI/js/ui.js
10
GUI/js/ui.js
@@ -49,6 +49,13 @@ function setupWindowControls() {
|
||||
const windowControls = document.querySelector('.window-controls');
|
||||
const header = document.querySelector('.header');
|
||||
|
||||
const profileSelector = document.querySelector('.profile-selector');
|
||||
|
||||
if (profileSelector) {
|
||||
profileSelector.style.pointerEvents = 'auto';
|
||||
profileSelector.style.zIndex = '10000';
|
||||
}
|
||||
|
||||
if (windowControls) {
|
||||
windowControls.style.pointerEvents = 'auto';
|
||||
windowControls.style.zIndex = '10000';
|
||||
@@ -59,6 +66,9 @@ function setupWindowControls() {
|
||||
if (windowControls) {
|
||||
windowControls.style.webkitAppRegion = 'no-drag';
|
||||
}
|
||||
if (profileSelector) {
|
||||
profileSelector.style.webkitAppRegion = 'no-drag';
|
||||
}
|
||||
}
|
||||
|
||||
if (window.electronAPI) {
|
||||
|
||||
1287
GUI/style.css
1287
GUI/style.css
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
||||
Type=Application
|
||||
Name=Hytale-F2P
|
||||
Comment=A modern, cross-platform launcher for Hytale with automatic updates and multi-client support
|
||||
Exec=/opt/Hytale-F2P/hytale-f2p-launcher
|
||||
Exec=/opt/Hytale-F2P/hytale-f2p-launcherv2
|
||||
Categories=Game;
|
||||
Icon=Hytale-F2P
|
||||
Terminal=false
|
||||
|
||||
12
PKGBUILD
12
PKGBUILD
@@ -1,19 +1,20 @@
|
||||
# Maintainer: Terromur <terromuroz@proton.me>
|
||||
# Maintainer: Fazri Gading <fazrigading@gmail.com>
|
||||
pkgname=Hytale-F2P-git
|
||||
_pkgname=Hytale-F2P
|
||||
pkgver=2.0.0.r47.gebcfdc4
|
||||
pkgver=2.0.2b.r120.gb05aeef
|
||||
pkgrel=1
|
||||
pkgdesc="HyLauncher - unofficial Hytale Launcher for free to play gamers"
|
||||
pkgdesc="Hytale-F2P - unofficial Hytale Launcher for free to play with multiplayer support"
|
||||
arch=('x86_64')
|
||||
url="https://github.com/amiayweb/Hytale-F2P"
|
||||
license=('custom')
|
||||
makedepends=('npm')
|
||||
makedepends=('npm' 'git' 'rpm-tools' 'libxcrypt-compat')
|
||||
source=("git+$url.git" "Hytale-F2P.desktop")
|
||||
sha256sums=('SKIP' '46488fada4775d9976d7b7b62f8d1f1f8d9a9a9d8f8aa9af4f2e2153019f6a30')
|
||||
sha256sums=('SKIP' '8c78a6931fade2b0501122980dc238e042b9f6f0292b5ca74c391d7b3c1543c0')
|
||||
|
||||
pkgver() {
|
||||
cd "$_pkgname"
|
||||
printf "2.0.0.r%s.g%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
|
||||
printf "2.0.2b.r%s.g%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
|
||||
}
|
||||
|
||||
build() {
|
||||
@@ -28,4 +29,3 @@ package() {
|
||||
install -Dm644 "$_pkgname.desktop" "$pkgdir/usr/share/applications/$_pkgname.desktop"
|
||||
install -Dm644 "$_pkgname/icon.png" "$pkgdir/usr/share/icons/hicolor/512x512/apps/$_pkgname.png"
|
||||
}
|
||||
|
||||
|
||||
46
README.md
46
README.md
@@ -1,18 +1,19 @@
|
||||
# 🎮 Hytale F2P Launcher | Multiplayer Support
|
||||
# 🎮 Hytale F2P Launcher | Multiplayer Support [Windows, MacOS, Linux]
|
||||
|
||||
<div align="center">
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
**A modern, cross-platform offline launcher for Hytale with automatic updates and multiplayer support (windows users & non-premium only)**
|
||||
**A modern, cross-platform offline launcher for Hytale with automatic updates and multiplayer support (all OS supported)**
|
||||
|
||||
[](https://github.com/amiayweb/Hytale-F2P/stargazers)
|
||||
[](https://github.com/amiayweb/Hytale-F2P/network/members)
|
||||
|
||||
⭐ **If you find this project useful, please give it a star!** ⭐
|
||||
🛑 **Found a problem? Open an issue! I’m on Windows, so I can’t test on macOS or Linux.** 🛑
|
||||
|
||||
🛑 **Found a problem? Join the Discord: https://discord.gg/gME8rUy3MB** 🛑
|
||||
|
||||
</div>
|
||||
|
||||
@@ -36,7 +37,7 @@
|
||||
- 💾 **Data Preservation** - Intelligent UserData backup and restoration during updates
|
||||
- 🌐 **Cross-Platform** - Full support for Windows, Linux (X11/Wayland), and macOS
|
||||
- ☕ **Java Management** - Automatic Java runtime detection and installation
|
||||
- 🎮 **Multiplayer Support** - Automatic multiplayer client installation (Windows)
|
||||
- 🎮 **Multiplayer Support** - Automatic multiplayer client installation (Windows, macOS & Linux !)
|
||||
|
||||
🛡️ **Advanced Features**
|
||||
- 📁 **Custom Installation** - Choose your own installation directory
|
||||
@@ -63,7 +64,7 @@ See [BUILD.md](BUILD.md) for detailed build instructions or [**Releases**](https
|
||||
#### macOS
|
||||
See [BUILD.md](BUILD.md) for detailed build instructions or [**Releases**](https://github.com/amiayweb/Hytale-F2P/releases) section.
|
||||
|
||||
#### 🖥️ How to create server (Windows Only)?
|
||||
#### 🖥️ How to play online on F2P?
|
||||
See [SERVER.md](SERVER.md)
|
||||
|
||||
|
||||
@@ -77,7 +78,25 @@ See [BUILD.md](BUILD.md) for comprehensive build instructions.
|
||||
|
||||
## 📋 Changelog
|
||||
|
||||
### 🆕 v2.0.1 *(Latest)*
|
||||
### 🆕 v2.0.ba *(Minor Update: Performance & Utilities)*
|
||||
[TODO] add features list here
|
||||
|
||||
### 🆕 v2.0.2a *(Minor Update)*
|
||||
- 🧑🚀 **Profiles System** — Added proper profile management: create, switch, and delete profiles. Each profile now has its own **isolated mod list**.
|
||||
- 🔒 **Mod Isolation** — Fixed ModManager so mods are **strictly scoped to the active profile**. Browsing and installing now only affects the selected profile.
|
||||
- 🚨 **Critical Path Fix** — Resolved a macOS bug where mods were being saved to a Windows path (`~/AppData/Local`) instead of `~/Library/Application Support`. Mods now save to the **correct location** and load properly in-game.
|
||||
- 🛡️ **Stability Improvements** — Added an **auto-sync step before every launch** to ensure the physical mods folder always matches the active profile.
|
||||
- 🎨 **UI Enhancements** — Added a **profile selector dropdown** and a **profile management modal**.
|
||||
|
||||
### 🆕 v2.0.2
|
||||
- 🎮 **Discord RPC Integration** - Added Discord Rich Presence with toggle in settings (enabled by default)
|
||||
- 🌐 **Cross-Platform Multiplayer** - Added multiplayer patch support for Windows, Linux, and macOS
|
||||
- 🎨 **Chat Improvements** - Simplified chat color system
|
||||
- 🏆 **Badge System Expansion** - Added new FOUNDER UUID to the badge system
|
||||
- 🔧 **Progress Bar Fix** - Resolved issue where download progress bar stayed active after game launch
|
||||
- 🐛 **Bug Fixes**: General fixes
|
||||
|
||||
### 🔄 v2.0.1
|
||||
- 📊 **Advanced Logging System** - Complete logging with timestamps, file rotation, and session tracking
|
||||
- 🔧 **Play Button Fix** - Resolved issue where play button could get stuck in "CHECKING..." state
|
||||
- 💬 **Discord Integration** - Added closable Discord notification for community engagement
|
||||
@@ -129,14 +148,16 @@ See [BUILD.md](BUILD.md) for comprehensive build instructions.
|
||||
|
||||
### 🏆 Project Creator
|
||||
- [**@amiayweb**](https://github.com/amiayweb) - *Lead Developer & Project Creator*
|
||||
- [**@Relyz1993**](https://github.com/Relyz1993) - *Server Helper & Second Developer & Project Creator*
|
||||
|
||||
### 🌟 Contributors
|
||||
- [**@sanasol**](https://github.com/sanasol) - *Main Issues fixer | Multiplayer Patcher*
|
||||
- [**@Terromur**](https://github.com/Terromur) - *Main Issues fixer | Beta tester*
|
||||
- [**@fazrigading**](https://github.com/fazrigading) - *Main Issues fixer | Beta tester*
|
||||
- [**@ericiskoolbeans**](https://github.com/ericiskoolbeans) - *Beta Tester*
|
||||
- [**@chasem-dev**](https://github.com/chasem-dev) - *Issues fixer*
|
||||
- [**@crimera**](https://github.com/crimera) - *Issues fixer*
|
||||
- [**@sanasol**](https://github.com/sanasol) - *Issues fixer*
|
||||
- [**@Terromur**](https://github.com/Terromur) - *Issues fixer*
|
||||
- [**@Citeli-py**](https://github.com/Citeli-py) - *Issues fixer*
|
||||
- [**@ericiskoolbeans**](https://github.com/ericiskoolbeans) - *Beta Tester*
|
||||
|
||||
---
|
||||
|
||||
@@ -156,10 +177,7 @@ See [BUILD.md](BUILD.md) for comprehensive build instructions.
|
||||
|
||||
<div align="center">
|
||||
|
||||
[](https://github.com/amiayweb/Hytale-F2P/issues)
|
||||
[](https://github.com/amiayweb/Hytale-F2P/discussions)
|
||||
|
||||
**Need help?** Open an [issue](https://github.com/amiayweb/Hytale-F2P/issues) or start a [discussion](https://github.com/amiayweb/Hytale-F2P/discussions)!
|
||||
**Need help?** Join us: https://discord.gg/gME8rUy3MB
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
473
SERVER.md
473
SERVER.md
@@ -1,87 +1,444 @@
|
||||
# Hytale F2P Server Setup Guide
|
||||
# Hytale F2P Server Guide
|
||||
|
||||
## Server File Setup
|
||||
Play with friends online! This guide covers both easy in-game hosting and advanced dedicated server setup.
|
||||
|
||||
**Download server file:**
|
||||
```
|
||||
https://files.hytalef2p.com/server
|
||||
```
|
||||
|
||||
**Replace the file here:**
|
||||
`<your_path>\HytaleF2P\release\package\game\latest\Server`
|
||||
|
||||
If you don't have any custom installation path:
|
||||
|
||||
1. Press **WIN + R**
|
||||
2. Type: `%localappdata%\HytaleF2P\release\package\game\latest\Server`
|
||||
3. Press **Enter**
|
||||
|
||||
You will be redirected to the correct folder automatically.
|
||||
|
||||
## Network Setup - Radmin VPN Required
|
||||
|
||||
**Important:** The server only supports third-party software for LAN-style connections. You must use **Radmin VPN** to connect players together.
|
||||
|
||||
1. **Download and install [Radmin VPN](https://www.radmin-vpn.com/)**
|
||||
2. **Create or join a network** in Radmin VPN
|
||||
3. **All players must be connected** to the same Radmin network
|
||||
4. **Use the Radmin VPN IP address** to connect to the server
|
||||
|
||||
This creates a virtual LAN environment that allows the Hytale server to work properly with multiple players.
|
||||
|
||||
## RAM Allocation Guide (Windows)
|
||||
|
||||
When you start a Hytale server using `start-server.bat`, Java will use very little memory by default.
|
||||
This can cause slow startup, crashes, or the server not launching at all.
|
||||
|
||||
**You should always allocate RAM in your launch command.**
|
||||
|
||||
Edit your `start-server.bat` file and use the version that matches your PC:
|
||||
DOWNLOAD SERVER FILES HERE: https://discord.gg/MEyWUxt77m
|
||||
|
||||
---
|
||||
|
||||
### PC with 4 GB RAM
|
||||
*Best for small servers / testing*
|
||||
## Part 1: Playing with Friends (Online Play)
|
||||
|
||||
The easiest way to play with friends - no manual server setup required!
|
||||
|
||||
### How It Works
|
||||
|
||||
1. **Start the game** via F2P Launcher
|
||||
2. **Click "Online Play"** in the main menu
|
||||
3. **Share the invite code** with your friends
|
||||
4. Friends enter your invite code to join
|
||||
|
||||
The game automatically handles networking using UPnP/STUN/NAT traversal.
|
||||
|
||||
### Network Requirements
|
||||
|
||||
For Online Play to work, you need:
|
||||
|
||||
- **UPnP enabled** on your router (most routers have this on by default)
|
||||
- **Public IP address** from your ISP (not behind CGNAT)
|
||||
|
||||
### Common Issues
|
||||
|
||||
#### "NAT Type: Carrier-Grade NAT (CGNAT)" Warning
|
||||
|
||||
If you see this message:
|
||||
```
|
||||
Connected via UPnP
|
||||
NAT Type: Carrier-Grade NAT (CGNAT)
|
||||
Warning: Your network configuration may prevent other players from connecting.
|
||||
```
|
||||
|
||||
**What this means:** Your ISP doesn't give you a public IP address. Multiple customers share one public IP, which blocks incoming connections.
|
||||
|
||||
**Solutions:**
|
||||
|
||||
1. **Contact your ISP** - Request a public/static IP address (may cost extra)
|
||||
2. **Use a VPN with port forwarding** - Services like Mullvad, PIA, or AirVPN offer this
|
||||
3. **Use Radmin VPN or Playit.gg** - Create a virtual LAN with friends (see below)
|
||||
4. **Have a friend with public IP host instead**
|
||||
|
||||
#### "UPnP Failed" or "Port Mapping Failed"
|
||||
|
||||
**Check your router:**
|
||||
1. Log into router admin panel (usually `192.168.1.1` or `192.168.0.1`)
|
||||
2. Find UPnP settings (often under "Advanced" or "NAT")
|
||||
3. Enable UPnP if disabled
|
||||
4. Restart your router
|
||||
|
||||
**If UPnP isn't available:**
|
||||
- Manually forward **port 5520 UDP** to your computer's local IP
|
||||
- See "Port Forwarding" section below
|
||||
|
||||
#### "Strict NAT" or "Symmetric NAT"
|
||||
|
||||
Some routers have restrictive NAT that blocks peer connections.
|
||||
|
||||
**Try:**
|
||||
1. Enable "NAT Passthrough" or "NAT Filtering: Open" in router settings
|
||||
2. Put your device in router's DMZ (temporary test only)
|
||||
3. Use Radmin VPN as workaround
|
||||
|
||||
### Workarounds for NAT/CGNAT Issues
|
||||
|
||||
#### Option 1: playit.gg (Recommended)
|
||||
|
||||
Free tunneling service - only the host needs to install it:
|
||||
|
||||
1. **Download [playit.gg](https://playit.gg/)** and run it - Connect your account from the terminal (do not close it when playing on the server)
|
||||
2. **Add a tunnel** - Select "UDP", tunnel description of "Hytale Server", port count `1`, and local port `5520`
|
||||
3. **Start the tunnel** - You'll get a public address like `xx-xx.gl.at.ply.gg:5520`
|
||||
4. **Share the address** - Friends connect directly using this address
|
||||
|
||||
Works with both Online Play and dedicated servers. No software needed for players joining.
|
||||
|
||||
#### Option 2: Radmin VPN
|
||||
|
||||
Creates a virtual LAN - all players need to install it:
|
||||
|
||||
1. **Download [Radmin VPN](https://www.radmin-vpn.com/)** - All players install it
|
||||
2. **Create a network** - One person creates, others join with network name/password
|
||||
3. **Host via Online Play** - Use your Radmin VPN IP instead
|
||||
4. **Friends connect** - They'll see you on the virtual LAN
|
||||
|
||||
Both options bypass all NAT/CGNAT issues.
|
||||
|
||||
---
|
||||
|
||||
## Part 2: Dedicated Server (Advanced)
|
||||
|
||||
For 24/7 servers, custom configurations, or hosting on a VPS/dedicated machine.
|
||||
|
||||
### Quick Start
|
||||
|
||||
#### Step 1: Get the Server JAR
|
||||
|
||||
The server scripts will automatically download the pre-patched server JAR if it's not present.
|
||||
|
||||
**Option A:** Let the scripts download automatically (requires `HYTALE_SERVER_URL` to be configured)
|
||||
|
||||
**Option B:** Manually place `HytaleServer.jar` (pre-patched for F2P) in the Server directory:
|
||||
|
||||
- **Windows:** `%localappdata%\HytaleF2P\release\package\game\latest\Server`
|
||||
- **macOS:** `~/Library/Application Support/HytaleF2P/release/package/game/latest/Server`
|
||||
- **Linux:** `~/.hytalef2p/release/package/game/latest/Server`
|
||||
|
||||
If you have a custom install path, the Server folder is inside your custom location under `HytaleF2P/release/package/game/latest/Server`.
|
||||
|
||||
#### Step 2: Run the Server
|
||||
|
||||
**Windows:**
|
||||
```batch
|
||||
cd scripts
|
||||
run_server.bat
|
||||
```
|
||||
|
||||
**macOS / Linux:**
|
||||
```bash
|
||||
cd scripts
|
||||
./run_server.sh
|
||||
```
|
||||
|
||||
The scripts will:
|
||||
1. Find your game installation automatically
|
||||
2. Download the pre-patched server JAR if needed
|
||||
3. Fetch session tokens from the auth server
|
||||
4. Start the server
|
||||
|
||||
#### Step 3: Connect Players
|
||||
|
||||
Share your server IP address with players. They connect via the F2P Launcher's server browser or direct connect.
|
||||
|
||||
---
|
||||
|
||||
## Network Setup (Dedicated Server)
|
||||
|
||||
### Local Network (LAN)
|
||||
|
||||
If all players are on the same network:
|
||||
1. Find your local IP: `ipconfig` (Windows) or `ifconfig` (Mac/Linux)
|
||||
2. Share this IP with players on your network
|
||||
3. Default port is `5520`
|
||||
|
||||
### Port Forwarding (Internet Play)
|
||||
|
||||
To allow direct internet connections:
|
||||
|
||||
1. Forward **port 5520 (UDP)** in your router
|
||||
2. Find your public IP at [whatismyip.com](https://whatismyip.com)
|
||||
3. Share your public IP with players
|
||||
|
||||
**Windows Firewall:**
|
||||
```powershell
|
||||
# Run as Administrator
|
||||
netsh advfirewall firewall add rule name="Hytale Server" dir=in action=allow protocol=UDP localport=5520
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Configuration
|
||||
|
||||
### Environment Variables
|
||||
|
||||
Set these before running to customize your server:
|
||||
|
||||
| Variable | Default | Description |
|
||||
|----------|---------|-------------|
|
||||
| `HYTALE_SERVER_URL` | (placeholder) | URL to download pre-patched server JAR |
|
||||
| `HYTALE_AUTH_DOMAIN` | `sanasol.ws` | Auth server domain |
|
||||
| `HYTALE_BIND` | `0.0.0.0:5520` | Server IP and port |
|
||||
| `HYTALE_AUTH_MODE` | `authenticated` | Auth mode (see below) |
|
||||
| `HYTALE_SERVER_NAME` | `My Hytale Server` | Server display name |
|
||||
| `HYTALE_GAME_PATH` | (auto-detected) | Override game location |
|
||||
| `JVM_XMS` | `2G` | Minimum Java memory |
|
||||
| `JVM_XMX` | `4G` | Maximum Java memory |
|
||||
|
||||
**Example (Windows):**
|
||||
```batch
|
||||
set HYTALE_SERVER_NAME=My Awesome Server
|
||||
set JVM_XMX=8G
|
||||
run_server.bat
|
||||
```
|
||||
|
||||
**Example (Linux/macOS):**
|
||||
```bash
|
||||
HYTALE_SERVER_NAME="My Awesome Server" JVM_XMX=8G ./run_server.sh
|
||||
```
|
||||
|
||||
### Authentication Modes
|
||||
|
||||
| Mode | Description | Use Case |
|
||||
|------|-------------|----------|
|
||||
| `authenticated` | Players log in via F2P Launcher | Public servers |
|
||||
| `unauthenticated` | No login required | LAN parties, testing |
|
||||
| `singleplayer` | Local play only | Solo testing |
|
||||
|
||||
---
|
||||
|
||||
## RAM Allocation Guide
|
||||
|
||||
Adjust memory based on your system:
|
||||
|
||||
| System RAM | Players | JVM_XMS | JVM_XMX |
|
||||
|------------|---------|---------|---------|
|
||||
| 4 GB | 1-3 | `512M` | `2G` |
|
||||
| 8 GB | 3-8 | `1G` | `4G` |
|
||||
| 16 GB | 8-15 | `2G` | `8G` |
|
||||
| 32 GB | 15+ | `4G` | `12G` |
|
||||
|
||||
**Example for large server:**
|
||||
```bash
|
||||
JVM_XMS=4G JVM_XMX=12G ./run_server.sh
|
||||
```
|
||||
|
||||
**Tips:**
|
||||
- `-Xms` = minimum RAM (allocated at startup)
|
||||
- `-Xmx` = maximum RAM (upper limit)
|
||||
- Never allocate all your system RAM - leave room for OS
|
||||
- Start conservative and increase if needed
|
||||
|
||||
---
|
||||
|
||||
## Server Commands
|
||||
|
||||
Once running, use these commands in the console:
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `help` | Show all commands |
|
||||
| `stop` | Stop server gracefully |
|
||||
| `save` | Force world save |
|
||||
| `list` | List online players |
|
||||
| `op <player>` | Give operator status |
|
||||
| `deop <player>` | Remove operator status |
|
||||
| `kick <player>` | Kick a player |
|
||||
| `ban <player>` | Ban a player |
|
||||
| `unban <player>` | Unban a player |
|
||||
| `tp <player> <x> <y> <z>` | Teleport player |
|
||||
|
||||
---
|
||||
|
||||
## Command Line Options
|
||||
|
||||
Pass these when starting the server:
|
||||
|
||||
```bash
|
||||
java -Xms512M -Xmx2G -jar HytaleServer.jar --assets ..\Assets.zip
|
||||
./run_server.sh [OPTIONS]
|
||||
```
|
||||
|
||||
- Uses up to **2 GB**
|
||||
- Leaves enough memory for Windows
|
||||
| Option | Description |
|
||||
|--------|-------------|
|
||||
| `--bind <ip:port>` | Server address (default: 0.0.0.0:5520) |
|
||||
| `--auth-mode <mode>` | Authentication mode |
|
||||
| `--universe <path>` | Path to world data |
|
||||
| `--mods <path>` | Path to mods folder |
|
||||
| `--backup` | Enable automatic backups |
|
||||
| `--backup-dir <path>` | Backup directory |
|
||||
| `--backup-frequency <mins>` | Backup interval |
|
||||
| `--owner-name <name>` | Server owner username |
|
||||
| `--allow-op` | Allow op commands |
|
||||
| `--disable-sentry` | Disable crash reporting |
|
||||
| `--help` | Show all options |
|
||||
|
||||
**Example:**
|
||||
```bash
|
||||
./run_server.sh --backup --backup-frequency 30 --allow-op
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### PC with 8 GB RAM
|
||||
*Good for small communities*
|
||||
## File Structure
|
||||
|
||||
```
|
||||
<game_path>/
|
||||
├── Assets.zip # Game assets (required)
|
||||
├── Client/ # Game client
|
||||
└── Server/
|
||||
├── HytaleServer.jar # Server executable (pre-patched)
|
||||
├── HytaleServer.aot # AOT cache (faster startup)
|
||||
├── universe/ # World data
|
||||
│ ├── world/ # Default world
|
||||
│ └── players/ # Player data
|
||||
├── mods/ # Server mods (optional)
|
||||
└── Licenses/ # License files
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Backups
|
||||
|
||||
### Automatic Backups
|
||||
|
||||
```bash
|
||||
java -Xms1G -Xmx4G -jar HytaleServer.jar --assets ..\Assets.zip
|
||||
./run_server.sh --backup --backup-dir ./backups --backup-frequency 30
|
||||
```
|
||||
|
||||
- Uses up to **4 GB**
|
||||
- Stable for most setups
|
||||
### Manual Backup
|
||||
|
||||
1. Use `save` command or stop the server
|
||||
2. Copy the `universe/` folder
|
||||
3. Store in a safe location
|
||||
|
||||
### Restore
|
||||
|
||||
1. Stop the server
|
||||
2. Delete/rename current `universe/`
|
||||
3. Copy backup to `universe/`
|
||||
4. Restart server
|
||||
|
||||
---
|
||||
|
||||
### PC with 16 GB RAM
|
||||
*Perfect for large or modded servers*
|
||||
## Troubleshooting
|
||||
|
||||
### "Java not found" or "Java version too old"
|
||||
|
||||
**Java 21 is REQUIRED** (the server uses class file version 65.0).
|
||||
|
||||
**Install Java 21:**
|
||||
- **Windows:** `winget install EclipseAdoptium.Temurin.21.JDK`
|
||||
- **macOS:** `brew install openjdk@21`
|
||||
- **Ubuntu:** `sudo apt install openjdk-21-jdk`
|
||||
- **Fedora:** `sudo dnf install java-21-openjdk`
|
||||
- **Arch:** `sudo pacman -S jdk21-openjdk`
|
||||
- **Download:** [adoptium.net/temurin/releases/?version=21](https://adoptium.net/temurin/releases/?version=21)
|
||||
|
||||
**macOS: Set Java 21 as default:**
|
||||
```bash
|
||||
export JAVA_HOME=$(/usr/libexec/java_home -v 21)
|
||||
export PATH="$JAVA_HOME/bin:$PATH"
|
||||
```
|
||||
Add these lines to `~/.zshrc` or `~/.bash_profile` to make permanent.
|
||||
|
||||
### "Game directory not found"
|
||||
|
||||
- Download game via F2P Launcher first
|
||||
- Or set `HYTALE_GAME_PATH` environment variable
|
||||
- Check custom install path in launcher settings
|
||||
|
||||
### "Assets.zip not found"
|
||||
|
||||
Game files incomplete. Re-download via the launcher.
|
||||
|
||||
### "Port already in use"
|
||||
|
||||
```bash
|
||||
java -Xms2G -Xmx8G -jar HytaleServer.jar --assets ..\Assets.zip
|
||||
./run_server.sh --bind 0.0.0.0:5521
|
||||
```
|
||||
|
||||
- Uses up to **8 GB**
|
||||
- Ideal for heavy worlds and plugins
|
||||
### "Out of memory"
|
||||
|
||||
Increase JVM_XMX:
|
||||
```bash
|
||||
JVM_XMX=6G ./run_server.sh
|
||||
```
|
||||
|
||||
### Players can't connect
|
||||
|
||||
1. Server shows "Server Ready"?
|
||||
2. Using F2P Launcher (not official)?
|
||||
3. Port 5520 open in firewall?
|
||||
4. Port forwarding configured (for internet)?
|
||||
5. Try `--auth-mode unauthenticated` for testing
|
||||
|
||||
### "Authentication failed"
|
||||
|
||||
- Ensure players use F2P Launcher
|
||||
- Auth server may be temporarily down
|
||||
- Test with `--auth-mode unauthenticated`
|
||||
|
||||
---
|
||||
|
||||
## Tips
|
||||
## Docker Deployment (Advanced)
|
||||
|
||||
- `-Xms` = minimum RAM allocation
|
||||
- `-Xmx` = maximum RAM allocation
|
||||
- **Never allocate all your system RAM** — Windows still needs memory to run
|
||||
- **Test your configuration** with a small world first
|
||||
- **Monitor server performance** and adjust RAM as needed
|
||||
For production servers, use Docker:
|
||||
|
||||
```bash
|
||||
docker run -d \
|
||||
--name hytale-server \
|
||||
-p 5520:5520/udp \
|
||||
-v ./data:/data \
|
||||
-e HYTALE_AUTH_DOMAIN=sanasol.ws \
|
||||
-e HYTALE_SERVER_NAME="My Server" \
|
||||
-e JVM_XMX=8G \
|
||||
ghcr.io/hybrowse/hytale-server-docker:latest
|
||||
```
|
||||
|
||||
See [Docker documentation](https://github.com/Hybrowse/hytale-server-docker) for details.
|
||||
|
||||
---
|
||||
|
||||
## Server Settings Summary
|
||||
|
||||
### Minimal Setup
|
||||
```bash
|
||||
./run_server.sh
|
||||
```
|
||||
|
||||
### Custom Memory
|
||||
```bash
|
||||
JVM_XMS=2G JVM_XMX=8G ./run_server.sh
|
||||
```
|
||||
|
||||
### Custom Port
|
||||
```bash
|
||||
HYTALE_BIND=0.0.0.0:25565 ./run_server.sh
|
||||
```
|
||||
|
||||
### LAN Party (No Auth)
|
||||
```bash
|
||||
./run_server.sh --auth-mode unauthenticated
|
||||
```
|
||||
|
||||
### Full Custom Setup
|
||||
```bash
|
||||
HYTALE_SERVER_NAME="Epic Server" \
|
||||
HYTALE_BIND=0.0.0.0:5520 \
|
||||
JVM_XMS=2G \
|
||||
JVM_XMX=8G \
|
||||
./run_server.sh --backup --backup-frequency 15 --allow-op
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Getting Help
|
||||
|
||||
- Check server console logs for errors
|
||||
- Test with `--auth-mode unauthenticated` first
|
||||
- Ensure all players have F2P Launcher
|
||||
- Join the community for support
|
||||
|
||||
---
|
||||
|
||||
## Credits
|
||||
|
||||
- Hytale F2P Project
|
||||
- [Hybrowse Docker Image](https://github.com/Hybrowse/hytale-server-docker)
|
||||
- Auth Server: sanasol.ws
|
||||
|
||||
@@ -2,6 +2,40 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
|
||||
|
||||
// Default auth domain - can be overridden by env var or config
|
||||
const DEFAULT_AUTH_DOMAIN = 'sanasol.ws';
|
||||
|
||||
// Get auth domain from env, config, or default
|
||||
function getAuthDomain() {
|
||||
// First check environment variable
|
||||
if (process.env.HYTALE_AUTH_DOMAIN) {
|
||||
return process.env.HYTALE_AUTH_DOMAIN;
|
||||
}
|
||||
// Then check config file
|
||||
const config = loadConfig();
|
||||
if (config.activeProfileId && config.profiles && config.profiles[config.activeProfileId]) {
|
||||
// Allow profile to override auth domain if ever needed
|
||||
// but for now stick to global or env
|
||||
}
|
||||
if (config.authDomain) {
|
||||
return config.authDomain;
|
||||
}
|
||||
// Fall back to default
|
||||
return DEFAULT_AUTH_DOMAIN;
|
||||
}
|
||||
|
||||
// Get full auth server URL
|
||||
function getAuthServerUrl() {
|
||||
const domain = getAuthDomain();
|
||||
return `https://sessions.${domain}`;
|
||||
}
|
||||
|
||||
// Save auth domain to config
|
||||
function saveAuthDomain(domain) {
|
||||
saveConfig({ authDomain: domain || DEFAULT_AUTH_DOMAIN });
|
||||
}
|
||||
|
||||
function getAppDir() {
|
||||
const home = os.homedir();
|
||||
if (process.platform === 'win32') {
|
||||
@@ -81,6 +115,16 @@ function saveJavaPath(javaPath) {
|
||||
|
||||
function loadJavaPath() {
|
||||
const config = loadConfig();
|
||||
|
||||
// Prefer Active Profile's Java Path
|
||||
if (config.activeProfileId && config.profiles && config.profiles[config.activeProfileId]) {
|
||||
const profile = config.profiles[config.activeProfileId];
|
||||
if (profile.javaPath && profile.javaPath.trim().length > 0) {
|
||||
return profile.javaPath;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to global setting
|
||||
return config.javaPath || '';
|
||||
}
|
||||
|
||||
@@ -94,10 +138,30 @@ function loadInstallPath() {
|
||||
return config.installPath || '';
|
||||
}
|
||||
|
||||
function saveDiscordRPC(enabled) {
|
||||
saveConfig({ discordRPC: !!enabled });
|
||||
}
|
||||
|
||||
function loadDiscordRPC() {
|
||||
const config = loadConfig();
|
||||
return config.discordRPC !== undefined ? config.discordRPC : true;
|
||||
}
|
||||
|
||||
function saveModsToConfig(mods) {
|
||||
try {
|
||||
let config = loadConfig();
|
||||
const config = loadConfig();
|
||||
|
||||
// Config migration handles structure, but mod saves must go to the ACTIVE profile.
|
||||
// Global installedMods is kept mainly for reference/migration.
|
||||
// The profile is the source of truth for enabled mods.
|
||||
|
||||
|
||||
if (config.activeProfileId && config.profiles && config.profiles[config.activeProfileId]) {
|
||||
config.profiles[config.activeProfileId].mods = mods;
|
||||
} else {
|
||||
// Fallback for legacy or no-profile state
|
||||
config.installedMods = mods;
|
||||
}
|
||||
|
||||
const configDir = path.dirname(CONFIG_FILE);
|
||||
if (!fs.existsSync(configDir)) {
|
||||
@@ -114,6 +178,12 @@ function saveModsToConfig(mods) {
|
||||
function loadModsFromConfig() {
|
||||
try {
|
||||
const config = loadConfig();
|
||||
|
||||
// Prefer Active Profile
|
||||
if (config.activeProfileId && config.profiles && config.profiles[config.activeProfileId]) {
|
||||
return config.profiles[config.activeProfileId].mods || [];
|
||||
}
|
||||
|
||||
return config.installedMods || [];
|
||||
} catch (error) {
|
||||
console.error('Error loading mods from config:', error);
|
||||
@@ -143,6 +213,79 @@ function markAsLaunched() {
|
||||
saveConfig({ hasLaunchedBefore: true, firstLaunchDate: new Date().toISOString() });
|
||||
}
|
||||
|
||||
// UUID Management Functions
|
||||
function getCurrentUuid() {
|
||||
const username = loadUsername();
|
||||
return getUuidForUser(username);
|
||||
}
|
||||
|
||||
function getAllUuidMappings() {
|
||||
const config = loadConfig();
|
||||
return config.userUuids || {};
|
||||
}
|
||||
|
||||
function setUuidForUser(username, uuid) {
|
||||
const { v4: uuidv4, validate: validateUuid } = require('uuid');
|
||||
|
||||
// Validate UUID format
|
||||
if (!validateUuid(uuid)) {
|
||||
throw new Error('Invalid UUID format');
|
||||
}
|
||||
|
||||
const config = loadConfig();
|
||||
const userUuids = config.userUuids || {};
|
||||
userUuids[username] = uuid;
|
||||
saveConfig({ userUuids });
|
||||
|
||||
return uuid;
|
||||
}
|
||||
|
||||
function generateNewUuid() {
|
||||
const { v4: uuidv4 } = require('uuid');
|
||||
return uuidv4();
|
||||
}
|
||||
|
||||
function deleteUuidForUser(username) {
|
||||
const config = loadConfig();
|
||||
const userUuids = config.userUuids || {};
|
||||
|
||||
if (userUuids[username]) {
|
||||
delete userUuids[username];
|
||||
saveConfig({ userUuids });
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function resetCurrentUserUuid() {
|
||||
const username = loadUsername();
|
||||
const { v4: uuidv4 } = require('uuid');
|
||||
const newUuid = uuidv4();
|
||||
|
||||
return setUuidForUser(username, newUuid);
|
||||
}
|
||||
|
||||
function saveChatColor(color) {
|
||||
const config = loadConfig();
|
||||
config.chatColor = color;
|
||||
saveConfig(config);
|
||||
}
|
||||
|
||||
function loadChatColor() {
|
||||
const config = loadConfig();
|
||||
return config.chatColor || '#3498db';
|
||||
}
|
||||
|
||||
function saveGpuPreference(gpuPreference) {
|
||||
saveConfig({ gpuPreference: gpuPreference || 'auto' });
|
||||
}
|
||||
|
||||
function loadGpuPreference() {
|
||||
const config = loadConfig();
|
||||
return config.gpuPreference || 'auto';
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
loadConfig,
|
||||
saveConfig,
|
||||
@@ -150,14 +293,32 @@ module.exports = {
|
||||
loadUsername,
|
||||
saveChatUsername,
|
||||
loadChatUsername,
|
||||
saveChatColor,
|
||||
loadChatColor,
|
||||
getUuidForUser,
|
||||
saveJavaPath,
|
||||
loadJavaPath,
|
||||
saveInstallPath,
|
||||
loadInstallPath,
|
||||
saveDiscordRPC,
|
||||
loadDiscordRPC,
|
||||
saveModsToConfig,
|
||||
loadModsFromConfig,
|
||||
isFirstLaunch,
|
||||
markAsLaunched,
|
||||
CONFIG_FILE
|
||||
CONFIG_FILE,
|
||||
// Auth server exports
|
||||
getAuthServerUrl,
|
||||
getAuthDomain,
|
||||
saveAuthDomain,
|
||||
// UUID Management exports
|
||||
getCurrentUuid,
|
||||
getAllUuidMappings,
|
||||
setUuidForUser,
|
||||
generateNewUuid,
|
||||
deleteUuidForUser,
|
||||
resetCurrentUserUuid,
|
||||
// GPU Preference exports
|
||||
saveGpuPreference,
|
||||
loadGpuPreference
|
||||
};
|
||||
|
||||
@@ -152,10 +152,8 @@ async function getModsPath(customInstallPath = null) {
|
||||
}
|
||||
|
||||
if (!installPath) {
|
||||
const localAppData = process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local');
|
||||
installPath = path.join(localAppData, 'HytaleF2P');
|
||||
} else {
|
||||
installPath = path.join(installPath, 'HytaleF2P');
|
||||
// Use the standard app directory logic which handles platforms correctly
|
||||
installPath = getAppDir();
|
||||
}
|
||||
|
||||
const gameLatest = path.join(installPath, 'release', 'package', 'game', 'latest');
|
||||
|
||||
@@ -7,16 +7,29 @@ const {
|
||||
loadUsername,
|
||||
saveChatUsername,
|
||||
loadChatUsername,
|
||||
saveChatColor,
|
||||
loadChatColor,
|
||||
saveJavaPath,
|
||||
loadJavaPath,
|
||||
saveInstallPath,
|
||||
loadInstallPath,
|
||||
saveDiscordRPC,
|
||||
loadDiscordRPC,
|
||||
saveModsToConfig,
|
||||
loadModsFromConfig,
|
||||
getUuidForUser,
|
||||
isFirstLaunch,
|
||||
markAsLaunched,
|
||||
CONFIG_FILE
|
||||
// UUID Management
|
||||
getCurrentUuid,
|
||||
getAllUuidMappings,
|
||||
setUuidForUser,
|
||||
generateNewUuid,
|
||||
deleteUuidForUser,
|
||||
resetCurrentUserUuid,
|
||||
// GPU Preference
|
||||
saveGpuPreference,
|
||||
loadGpuPreference
|
||||
} = require('./core/config');
|
||||
|
||||
const { getResolvedAppDir, getModsPath } = require('./core/paths');
|
||||
@@ -27,7 +40,8 @@ const {
|
||||
installGame,
|
||||
uninstallGame,
|
||||
updateGameFiles,
|
||||
checkExistingGameInstallation
|
||||
checkExistingGameInstallation,
|
||||
repairGame
|
||||
} = require('./managers/gameManager');
|
||||
|
||||
const {
|
||||
@@ -37,8 +51,6 @@ const {
|
||||
|
||||
const { getJavaDetection } = require('./managers/javaManager');
|
||||
|
||||
const { checkAndInstallMultiClient } = require('./managers/multiClientManager');
|
||||
|
||||
const {
|
||||
downloadAndReplaceHomePageUI,
|
||||
findHomePageUIPath,
|
||||
@@ -68,6 +80,9 @@ const {
|
||||
handleFirstLaunchCheck
|
||||
} = require('./services/firstLaunch');
|
||||
|
||||
// Utils
|
||||
const { detectGpu } = require('./utils/platformUtils');
|
||||
|
||||
// Re-export all functions to maintain backward compatibility
|
||||
module.exports = {
|
||||
// Game launch functions
|
||||
@@ -79,12 +94,15 @@ module.exports = {
|
||||
isGameInstalled,
|
||||
uninstallGame,
|
||||
updateGameFiles,
|
||||
repairGame,
|
||||
|
||||
// User configuration functions
|
||||
saveUsername,
|
||||
loadUsername,
|
||||
saveChatUsername,
|
||||
loadChatUsername,
|
||||
saveChatColor,
|
||||
loadChatColor,
|
||||
getUuidForUser,
|
||||
|
||||
// Java configuration functions
|
||||
@@ -96,6 +114,15 @@ module.exports = {
|
||||
saveInstallPath,
|
||||
loadInstallPath,
|
||||
|
||||
// Discord RPC functions
|
||||
saveDiscordRPC,
|
||||
loadDiscordRPC,
|
||||
|
||||
// GPU Preference functions
|
||||
saveGpuPreference,
|
||||
loadGpuPreference,
|
||||
detectGpu,
|
||||
|
||||
// Version functions
|
||||
getInstalledClientVersion,
|
||||
getLatestClientVersion,
|
||||
@@ -106,8 +133,13 @@ module.exports = {
|
||||
// Player ID functions
|
||||
getOrCreatePlayerId,
|
||||
|
||||
// Multi-client functions
|
||||
checkAndInstallMultiClient,
|
||||
// UUID Management functions
|
||||
getCurrentUuid,
|
||||
getAllUuidMappings,
|
||||
setUuidForUser,
|
||||
generateNewUuid,
|
||||
deleteUuidForUser,
|
||||
resetCurrentUserUuid,
|
||||
|
||||
// Mod management functions
|
||||
getModsPath,
|
||||
|
||||
@@ -1,18 +1,107 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const crypto = require('crypto');
|
||||
const { exec } = require('child_process');
|
||||
const { promisify } = require('util');
|
||||
const { spawn } = require('child_process');
|
||||
const { v4: uuidv4 } = require('uuid');
|
||||
const { getResolvedAppDir, findClientPath } = require('../core/paths');
|
||||
const { setupWaylandEnvironment } = require('../utils/platformUtils');
|
||||
const { saveUsername, saveInstallPath, loadJavaPath, getUuidForUser } = require('../core/config');
|
||||
const { setupWaylandEnvironment, setupGpuEnvironment } = require('../utils/platformUtils');
|
||||
const { saveUsername, saveInstallPath, loadJavaPath, getUuidForUser, getAuthServerUrl, getAuthDomain } = require('../core/config');
|
||||
const { resolveJavaPath, getJavaExec, getBundledJavaPath, detectSystemJava, JAVA_EXECUTABLE } = require('./javaManager');
|
||||
const { getInstalledClientVersion, getLatestClientVersion } = require('../services/versionManager');
|
||||
const { updateGameFiles } = require('./gameManager');
|
||||
const { syncModsForCurrentProfile } = require('./modManager');
|
||||
|
||||
// Client patcher for custom auth server (sanasol.ws)
|
||||
let clientPatcher = null;
|
||||
try {
|
||||
clientPatcher = require('../utils/clientPatcher');
|
||||
} catch (err) {
|
||||
console.log('[Launcher] Client patcher not available:', err.message);
|
||||
}
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
|
||||
async function launchGame(playerName = 'Player', progressCallback, javaPathOverride, installPathOverride) {
|
||||
// Fetch tokens from the auth server (properly signed with server's Ed25519 key)
|
||||
async function fetchAuthTokens(uuid, name) {
|
||||
const authServerUrl = getAuthServerUrl();
|
||||
try {
|
||||
console.log(`Fetching auth tokens from ${authServerUrl}/game-session/child`);
|
||||
|
||||
const response = await fetch(`${authServerUrl}/game-session/child`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
uuid: uuid,
|
||||
name: name,
|
||||
scopes: ['hytale:server', 'hytale:client']
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Auth server returned ${response.status}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
console.log('Auth tokens received from server');
|
||||
|
||||
return {
|
||||
identityToken: data.IdentityToken || data.identityToken,
|
||||
sessionToken: data.SessionToken || data.sessionToken
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch auth tokens:', error.message);
|
||||
// Fallback to local generation if server unavailable
|
||||
return generateLocalTokens(uuid, name);
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: Generate tokens locally (won't pass signature validation but allows offline testing)
|
||||
function generateLocalTokens(uuid, name) {
|
||||
console.log('Using locally generated tokens (fallback mode)');
|
||||
const authServerUrl = getAuthServerUrl();
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
const exp = now + 36000;
|
||||
|
||||
const header = Buffer.from(JSON.stringify({
|
||||
alg: 'EdDSA',
|
||||
kid: '2025-10-01',
|
||||
typ: 'JWT'
|
||||
})).toString('base64url');
|
||||
|
||||
const identityPayload = Buffer.from(JSON.stringify({
|
||||
sub: uuid,
|
||||
name: name,
|
||||
username: name,
|
||||
entitlements: ['game.base'],
|
||||
scope: 'hytale:server hytale:client',
|
||||
iat: now,
|
||||
exp: exp,
|
||||
iss: authServerUrl,
|
||||
jti: uuidv4()
|
||||
})).toString('base64url');
|
||||
|
||||
const sessionPayload = Buffer.from(JSON.stringify({
|
||||
sub: uuid,
|
||||
scope: 'hytale:server',
|
||||
iat: now,
|
||||
exp: exp,
|
||||
iss: authServerUrl,
|
||||
jti: uuidv4()
|
||||
})).toString('base64url');
|
||||
|
||||
const signature = crypto.randomBytes(64).toString('base64url');
|
||||
|
||||
return {
|
||||
identityToken: `${header}.${identityPayload}.${signature}`,
|
||||
sessionToken: `${header}.${sessionPayload}.${signature}`
|
||||
};
|
||||
}
|
||||
|
||||
async function launchGame(playerName = 'Player', progressCallback, javaPathOverride, installPathOverride, gpuPreference = 'auto') {
|
||||
const customAppDir = getResolvedAppDir(installPathOverride);
|
||||
const customGameDir = path.join(customAppDir, 'release', 'package', 'game', 'latest');
|
||||
const customJreDir = path.join(customAppDir, 'release', 'package', 'jre', 'latest');
|
||||
@@ -53,6 +142,51 @@ async function launchGame(playerName = 'Player', progressCallback, javaPathOverr
|
||||
}
|
||||
}
|
||||
|
||||
const uuid = getUuidForUser(playerName);
|
||||
|
||||
// Fetch tokens from auth server
|
||||
if (progressCallback) {
|
||||
progressCallback('Fetching authentication tokens...', null, null, null, null);
|
||||
}
|
||||
const { identityToken, sessionToken } = await fetchAuthTokens(uuid, playerName);
|
||||
|
||||
// Patch client and server binaries to use custom auth server (BEFORE signing on macOS)
|
||||
const authDomain = getAuthDomain();
|
||||
if (clientPatcher) {
|
||||
try {
|
||||
if (progressCallback) {
|
||||
progressCallback('Patching game for custom server...', null, null, null, null);
|
||||
}
|
||||
console.log(`Patching game binaries for ${authDomain}...`);
|
||||
|
||||
const patchResult = await clientPatcher.ensureClientPatched(gameLatest, (msg, percent) => {
|
||||
console.log(`[Patcher] ${msg}`);
|
||||
if (progressCallback && msg) {
|
||||
progressCallback(msg, percent, null, null, null);
|
||||
}
|
||||
});
|
||||
|
||||
if (patchResult.success) {
|
||||
if (patchResult.alreadyPatched) {
|
||||
console.log(`Game already patched for ${authDomain}`);
|
||||
} else {
|
||||
console.log(`Game patched successfully (${patchResult.patchCount} total occurrences)`);
|
||||
if (patchResult.client) {
|
||||
console.log(` Client: ${patchResult.client.patchCount || 0} occurrences`);
|
||||
}
|
||||
if (patchResult.server) {
|
||||
console.log(` Server: ${patchResult.server.patchCount || 0} occurrences`);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.warn('Game patching failed:', patchResult.error);
|
||||
}
|
||||
} catch (patchError) {
|
||||
console.warn('Game patching failed (game may not connect to custom server):', patchError.message);
|
||||
}
|
||||
}
|
||||
|
||||
// macOS: Sign binaries AFTER patching so the patched binaries have valid signatures
|
||||
if (process.platform === 'darwin') {
|
||||
try {
|
||||
const appBundle = path.join(gameLatest, 'Client', 'Hytale.app');
|
||||
@@ -66,10 +200,10 @@ async function launchGame(playerName = 'Player', progressCallback, javaPathOverr
|
||||
|
||||
if (fs.existsSync(appBundle)) {
|
||||
await signPath(appBundle, true);
|
||||
console.log('Signed macOS app bundle');
|
||||
console.log('Signed macOS app bundle (after patching)');
|
||||
} else {
|
||||
await signPath(path.dirname(clientPath), true);
|
||||
console.log('Signed macOS client binary');
|
||||
console.log('Signed macOS client binary (after patching)');
|
||||
}
|
||||
|
||||
if (javaBin && fs.existsSync(javaBin)) {
|
||||
@@ -85,7 +219,7 @@ async function launchGame(playerName = 'Player', progressCallback, javaPathOverr
|
||||
if (fs.existsSync(serverDir)) {
|
||||
await execAsync(`xattr -cr "${serverDir}"`).catch(() => { });
|
||||
await execAsync(`find "${serverDir}" -type f -perm +111 -exec codesign --force --sign - {} \\;`).catch(() => { });
|
||||
console.log('Signed server binaries');
|
||||
console.log('Signed server binaries (after patching)');
|
||||
}
|
||||
|
||||
if (javaBin && fs.existsSync(javaBin)) {
|
||||
@@ -113,19 +247,32 @@ exec "$REAL_JAVA" "\${ARGS[@]}"
|
||||
}
|
||||
}
|
||||
|
||||
const uuid = getUuidForUser(playerName);
|
||||
const args = [
|
||||
'--app-dir', gameLatest,
|
||||
'--java-exec', javaBin,
|
||||
'--auth-mode', 'offline',
|
||||
'--auth-mode', 'authenticated',
|
||||
'--uuid', uuid,
|
||||
'--name', playerName,
|
||||
'--identity-token', identityToken,
|
||||
'--session-token', sessionToken,
|
||||
'--user-dir', userDataDir
|
||||
];
|
||||
|
||||
if (progressCallback) {
|
||||
progressCallback('Starting game...', null, null, null, null);
|
||||
}
|
||||
|
||||
// Ensure mods are synced for the active profile before launching
|
||||
try {
|
||||
console.log('Syncing mods for active profile before launch...');
|
||||
if (progressCallback) progressCallback('Syncing mods...', null, null, null, null);
|
||||
await syncModsForCurrentProfile();
|
||||
} catch (syncError) {
|
||||
console.error('Failed to sync mods before launch:', syncError);
|
||||
// Continue anyway? Or fail?
|
||||
// Warn user but continue might be safer to avoid blocking play if sync is just glitchy
|
||||
}
|
||||
|
||||
console.log('Starting game...');
|
||||
console.log(`Command: "${clientPath}" ${args.join(' ')}`);
|
||||
|
||||
@@ -134,6 +281,9 @@ exec "$REAL_JAVA" "\${ARGS[@]}"
|
||||
const waylandEnv = setupWaylandEnvironment();
|
||||
Object.assign(env, waylandEnv);
|
||||
|
||||
const gpuEnv = setupGpuEnvironment(gpuPreference);
|
||||
Object.assign(env, gpuEnv);
|
||||
|
||||
try {
|
||||
let spawnOptions = {
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
@@ -205,7 +355,7 @@ exec "$REAL_JAVA" "\${ARGS[@]}"
|
||||
}
|
||||
}
|
||||
|
||||
async function launchGameWithVersionCheck(playerName = 'Player', progressCallback, javaPathOverride, installPathOverride) {
|
||||
async function launchGameWithVersionCheck(playerName = 'Player', progressCallback, javaPathOverride, installPathOverride, gpuPreference = 'auto') {
|
||||
try {
|
||||
if (progressCallback) {
|
||||
progressCallback('Checking for updates...', 0, null, null, null);
|
||||
@@ -256,7 +406,7 @@ async function launchGameWithVersionCheck(playerName = 'Player', progressCallbac
|
||||
progressCallback('Launching game...', 80, null, null, null);
|
||||
}
|
||||
|
||||
return await launchGame(playerName, progressCallback, javaPathOverride, installPathOverride);
|
||||
return await launchGame(playerName, progressCallback, javaPathOverride, installPathOverride, gpuPreference);
|
||||
} catch (error) {
|
||||
console.error('Error in version check and launch:', error);
|
||||
if (progressCallback) {
|
||||
|
||||
@@ -6,7 +6,6 @@ const { getOS, getArch } = require('../utils/platformUtils');
|
||||
const { downloadFile } = require('../utils/fileManager');
|
||||
const { getLatestClientVersion, getInstalledClientVersion } = require('../services/versionManager');
|
||||
const { installButler } = require('./butlerManager');
|
||||
const { checkAndInstallMultiClient } = require('./multiClientManager');
|
||||
const { downloadAndReplaceHomePageUI, downloadAndReplaceLogo } = require('./uiFileManager');
|
||||
const { saveUsername, saveInstallPath, loadJavaPath, CONFIG_FILE, loadConfig } = require('../core/config');
|
||||
const { resolveJavaPath, detectSystemJava, downloadJRE, getJavaExec, getBundledJavaPath } = require('./javaManager');
|
||||
@@ -165,9 +164,6 @@ async function updateGameFiles(newVersion, progressCallback, gameDir = GAME_DIR,
|
||||
|
||||
fs.renameSync(tempUpdateDir, gameDir);
|
||||
|
||||
const multiResult = await checkAndInstallMultiClient(gameDir, progressCallback);
|
||||
console.log('Multiplayer-client check result after update:', multiResult);
|
||||
|
||||
const homeUIResult = await downloadAndReplaceHomePageUI(gameDir, progressCallback);
|
||||
console.log('HomePage.ui update result after update:', homeUIResult);
|
||||
|
||||
@@ -318,9 +314,6 @@ async function installGame(playerName = 'Player', progressCallback, javaPathOver
|
||||
const pwrFile = await downloadPWR('release', latestVersion, progressCallback, customCacheDir);
|
||||
await applyPWR(pwrFile, progressCallback, customGameDir, customToolsDir);
|
||||
|
||||
const multiResult = await checkAndInstallMultiClient(customGameDir, progressCallback);
|
||||
console.log('Multiplayer check result:', multiResult);
|
||||
|
||||
const homeUIResult = await downloadAndReplaceHomePageUI(customGameDir, progressCallback);
|
||||
console.log('HomePage.ui update result after installation:', homeUIResult);
|
||||
|
||||
@@ -334,8 +327,7 @@ async function installGame(playerName = 'Player', progressCallback, javaPathOver
|
||||
|
||||
return {
|
||||
success: true,
|
||||
installed: true,
|
||||
multiClient: multiResult
|
||||
installed: true
|
||||
};
|
||||
}
|
||||
|
||||
@@ -395,6 +387,102 @@ function checkExistingGameInstallation() {
|
||||
}
|
||||
}
|
||||
|
||||
async function repairGame(progressCallback) {
|
||||
const appDir = getResolvedAppDir();
|
||||
const gameDir = path.join(appDir, 'release', 'package', 'game', 'latest');
|
||||
|
||||
// Check if game exists
|
||||
if (!fs.existsSync(gameDir)) {
|
||||
throw new Error('Game directory not found. Cannot repair.');
|
||||
}
|
||||
|
||||
// Locate UserData
|
||||
const userDataPath = findUserDataRecursive(gameDir);
|
||||
let userDataBackup = null;
|
||||
|
||||
if (progressCallback) {
|
||||
progressCallback('Backing up user data...', 10, null, null, null);
|
||||
}
|
||||
|
||||
// Backup UserData
|
||||
if (userDataPath && fs.existsSync(userDataPath)) {
|
||||
userDataBackup = path.join(appDir, 'UserData_backup_repair_' + Date.now());
|
||||
console.log(`Backing up UserData during repair from ${userDataPath} to ${userDataBackup}`);
|
||||
|
||||
// Copy function
|
||||
function copyRecursive(src, dest) {
|
||||
const stat = fs.statSync(src);
|
||||
if (stat.isDirectory()) {
|
||||
if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
|
||||
fs.readdirSync(src).forEach(child => copyRecursive(path.join(src, child), path.join(dest, child)));
|
||||
} else {
|
||||
fs.copyFileSync(src, dest);
|
||||
}
|
||||
}
|
||||
|
||||
copyRecursive(userDataPath, userDataBackup);
|
||||
}
|
||||
|
||||
if (progressCallback) {
|
||||
progressCallback('Removing old game files...', 30, null, null, null);
|
||||
}
|
||||
|
||||
// Delete Game and Cache Directory
|
||||
console.log('Removing corrupted game files...');
|
||||
fs.rmSync(gameDir, { recursive: true, force: true });
|
||||
|
||||
const cacheDir = path.join(appDir, 'cache');
|
||||
if (fs.existsSync(cacheDir)) {
|
||||
console.log('Clearing cache directory...');
|
||||
fs.rmSync(cacheDir, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
console.log('Reinstalling game files...');
|
||||
|
||||
// Passing null/undefined for overrides to use defaults/saved configs
|
||||
// installGame calls progressCallback internally
|
||||
await installGame('Player', progressCallback);
|
||||
|
||||
// Restore UserData
|
||||
if (userDataBackup && fs.existsSync(userDataBackup)) {
|
||||
if (progressCallback) {
|
||||
progressCallback('Restoring user data...', 90, null, null, null);
|
||||
}
|
||||
|
||||
// installGame creates: path.join(customGameDir, 'Client', 'UserData')
|
||||
const newGameDir = path.join(appDir, 'release', 'package', 'game', 'latest');
|
||||
const newUserDataPath = path.join(newGameDir, 'Client', 'UserData');
|
||||
|
||||
if (!fs.existsSync(newUserDataPath)) {
|
||||
fs.mkdirSync(newUserDataPath, { recursive: true });
|
||||
}
|
||||
|
||||
console.log(`Restoring UserData to ${newUserDataPath}`);
|
||||
|
||||
function copyRecursive(src, dest) {
|
||||
const stat = fs.statSync(src);
|
||||
if (stat.isDirectory()) {
|
||||
if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
|
||||
fs.readdirSync(src).forEach(child => copyRecursive(path.join(src, child), path.join(dest, child)));
|
||||
} else {
|
||||
fs.copyFileSync(src, dest);
|
||||
}
|
||||
}
|
||||
|
||||
copyRecursive(userDataBackup, newUserDataPath);
|
||||
|
||||
// Cleanup Backup
|
||||
console.log('Cleaning up repair backup...');
|
||||
fs.rmSync(userDataBackup, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
if (progressCallback) {
|
||||
progressCallback('Repair completed successfully!', 100, null, null, null);
|
||||
}
|
||||
|
||||
return { success: true, repaired: true };
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
downloadPWR,
|
||||
applyPWR,
|
||||
@@ -402,5 +490,9 @@ module.exports = {
|
||||
isGameInstalled,
|
||||
installGame,
|
||||
uninstallGame,
|
||||
checkExistingGameInstallation
|
||||
isGameInstalled,
|
||||
installGame,
|
||||
uninstallGame,
|
||||
checkExistingGameInstallation,
|
||||
repairGame
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@ const crypto = require('crypto');
|
||||
const axios = require('axios');
|
||||
const { getModsPath } = require('../core/paths');
|
||||
const { saveModsToConfig, loadModsFromConfig } = require('../core/config');
|
||||
const profileManager = require('./profileManager');
|
||||
|
||||
function generateModId(filename) {
|
||||
return crypto.createHash('md5').update(filename).digest('hex').substring(0, 8);
|
||||
@@ -26,77 +27,53 @@ function extractVersion(filename) {
|
||||
return versionMatch ? versionMatch[1] : null;
|
||||
}
|
||||
|
||||
// Helper to get mods from active profile
|
||||
function getProfileMods() {
|
||||
const profile = profileManager.getActiveProfile();
|
||||
return profile ? (profile.mods || []) : [];
|
||||
}
|
||||
|
||||
async function loadInstalledMods(modsPath) {
|
||||
try {
|
||||
const configMods = loadModsFromConfig();
|
||||
const modsMap = new Map();
|
||||
const activeProfile = profileManager.getActiveProfile();
|
||||
if (!activeProfile) return [];
|
||||
|
||||
configMods.forEach(mod => {
|
||||
modsMap.set(mod.fileName, mod);
|
||||
});
|
||||
const profileMods = activeProfile.mods || [];
|
||||
const profileModFiles = new Set(profileMods.map(m => m.fileName));
|
||||
|
||||
if (fs.existsSync(modsPath)) {
|
||||
const files = fs.readdirSync(modsPath);
|
||||
|
||||
for (const file of files) {
|
||||
const filePath = path.join(modsPath, file);
|
||||
const stats = fs.statSync(filePath);
|
||||
|
||||
if (stats.isFile() && (file.endsWith('.jar') || file.endsWith('.zip'))) {
|
||||
const configMod = modsMap.get(file);
|
||||
|
||||
const modInfo = {
|
||||
id: configMod?.id || generateModId(file),
|
||||
name: configMod?.name || extractModName(file),
|
||||
version: configMod?.version || extractVersion(file) || '1.0.0',
|
||||
description: configMod?.description || 'Installed mod',
|
||||
author: configMod?.author || 'Unknown',
|
||||
enabled: true,
|
||||
filePath: filePath,
|
||||
fileName: file,
|
||||
fileSize: configMod?.fileSize || stats.size,
|
||||
dateInstalled: configMod?.dateInstalled || stats.birthtime || stats.mtime,
|
||||
curseForgeId: configMod?.curseForgeId,
|
||||
curseForgeFileId: configMod?.curseForgeFileId
|
||||
};
|
||||
|
||||
modsMap.set(file, modInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
// We only return mods that are explicitly in the profile
|
||||
// Check which ones are physically present (either in mods/ or DisabledMods/)
|
||||
|
||||
const physicalModsPath = modsPath; // .../mods
|
||||
const disabledModsPath = path.join(path.dirname(modsPath), 'DisabledMods');
|
||||
if (fs.existsSync(disabledModsPath)) {
|
||||
const files = fs.readdirSync(disabledModsPath);
|
||||
|
||||
for (const file of files) {
|
||||
const filePath = path.join(disabledModsPath, file);
|
||||
const stats = fs.statSync(filePath);
|
||||
const validMods = [];
|
||||
|
||||
if (stats.isFile() && (file.endsWith('.jar') || file.endsWith('.zip'))) {
|
||||
const configMod = modsMap.get(file);
|
||||
for (const modConfig of profileMods) {
|
||||
// Check if file exists in either location
|
||||
const inEnabled = fs.existsSync(path.join(physicalModsPath, modConfig.fileName));
|
||||
const inDisabled = fs.existsSync(path.join(disabledModsPath, modConfig.fileName));
|
||||
|
||||
const modInfo = {
|
||||
id: configMod?.id || generateModId(file),
|
||||
name: configMod?.name || extractModName(file),
|
||||
version: configMod?.version || extractVersion(file) || '1.0.0',
|
||||
description: configMod?.description || 'Disabled mod',
|
||||
author: configMod?.author || 'Unknown',
|
||||
enabled: false,
|
||||
filePath: filePath,
|
||||
fileName: file,
|
||||
fileSize: configMod?.fileSize || stats.size,
|
||||
dateInstalled: configMod?.dateInstalled || stats.birthtime || stats.mtime,
|
||||
curseForgeId: configMod?.curseForgeId,
|
||||
curseForgeFileId: configMod?.curseForgeFileId
|
||||
};
|
||||
|
||||
modsMap.set(file, modInfo);
|
||||
}
|
||||
if (inEnabled || inDisabled) {
|
||||
validMods.push({
|
||||
...modConfig,
|
||||
// Set filePath based on physical location
|
||||
filePath: inEnabled ? path.join(physicalModsPath, modConfig.fileName) : path.join(disabledModsPath, modConfig.fileName),
|
||||
enabled: modConfig.enabled !== false // Default true
|
||||
});
|
||||
} else {
|
||||
console.warn(`[ModManager] Mod ${modConfig.fileName} listed in profile but not found on disk.`);
|
||||
// Include it so user can see it's missing or remove it
|
||||
validMods.push({
|
||||
...modConfig,
|
||||
filePath: null,
|
||||
missing: true,
|
||||
enabled: modConfig.enabled !== false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(modsMap.values());
|
||||
return validMods;
|
||||
} catch (error) {
|
||||
console.error('Error loading installed mods:', error);
|
||||
return [];
|
||||
@@ -142,7 +119,9 @@ async function downloadMod(modInfo) {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
writer.on('finish', () => {
|
||||
const configMods = loadModsFromConfig();
|
||||
// NEW: Update Active Profile instead of global config
|
||||
const activeProfile = profileManager.getActiveProfile();
|
||||
if (activeProfile) {
|
||||
const newMod = {
|
||||
id: modInfo.id || generateModId(fileName),
|
||||
name: modInfo.name || extractModName(fileName),
|
||||
@@ -157,8 +136,8 @@ async function downloadMod(modInfo) {
|
||||
curseForgeFileId: modInfo.fileId
|
||||
};
|
||||
|
||||
configMods.push(newMod);
|
||||
saveModsToConfig(configMods);
|
||||
const updatedMods = [...(activeProfile.mods || []), newMod];
|
||||
profileManager.updateProfile(activeProfile.id, { mods: updatedMods });
|
||||
|
||||
resolve({
|
||||
success: true,
|
||||
@@ -166,6 +145,9 @@ async function downloadMod(modInfo) {
|
||||
fileName: fileName,
|
||||
modInfo: newMod
|
||||
});
|
||||
} else {
|
||||
reject(new Error('No active profile to save mod to'));
|
||||
}
|
||||
});
|
||||
writer.on('error', reject);
|
||||
});
|
||||
@@ -181,11 +163,14 @@ async function downloadMod(modInfo) {
|
||||
|
||||
async function uninstallMod(modId, modsPath) {
|
||||
try {
|
||||
const configMods = loadModsFromConfig();
|
||||
const mod = configMods.find(m => m.id === modId);
|
||||
const activeProfile = profileManager.getActiveProfile();
|
||||
if (!activeProfile) throw new Error('No active profile');
|
||||
|
||||
const profileMods = activeProfile.mods || [];
|
||||
const mod = profileMods.find(m => m.id === modId);
|
||||
|
||||
if (!mod) {
|
||||
throw new Error('Mod not found in config');
|
||||
throw new Error('Mod not found in profile');
|
||||
}
|
||||
|
||||
const disabledModsPath = path.join(path.dirname(modsPath), 'DisabledMods');
|
||||
@@ -193,23 +178,23 @@ async function uninstallMod(modId, modsPath) {
|
||||
const disabledPath = path.join(disabledModsPath, mod.fileName);
|
||||
|
||||
let fileRemoved = false;
|
||||
// Try to remove file from both locations to be safe
|
||||
if (fs.existsSync(enabledPath)) {
|
||||
fs.unlinkSync(enabledPath);
|
||||
fileRemoved = true;
|
||||
console.log('Removed mod from Mods folder:', enabledPath);
|
||||
} else if (fs.existsSync(disabledPath)) {
|
||||
fs.unlinkSync(disabledPath);
|
||||
fileRemoved = true;
|
||||
console.log('Removed mod from DisabledMods folder:', disabledPath);
|
||||
}
|
||||
if (fs.existsSync(disabledPath)) {
|
||||
try { fs.unlinkSync(disabledPath); fileRemoved = true; } catch (e) { }
|
||||
}
|
||||
|
||||
if (!fileRemoved) {
|
||||
console.warn('Mod file not found on filesystem, removing from config anyway');
|
||||
console.warn('Mod file not found on filesystem, removing from profile anyway');
|
||||
}
|
||||
|
||||
const updatedMods = configMods.filter(m => m.id !== modId);
|
||||
saveModsToConfig(updatedMods);
|
||||
console.log('Mod removed from config.json');
|
||||
const updatedMods = profileMods.filter(m => m.id !== modId);
|
||||
profileManager.updateProfile(activeProfile.id, { mods: updatedMods });
|
||||
|
||||
console.log('Mod removed from profile');
|
||||
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
@@ -223,36 +208,51 @@ async function uninstallMod(modId, modsPath) {
|
||||
|
||||
async function toggleMod(modId, modsPath) {
|
||||
try {
|
||||
const mods = await loadInstalledMods(modsPath);
|
||||
const mod = mods.find(m => m.id === modId);
|
||||
const activeProfile = profileManager.getActiveProfile();
|
||||
if (!activeProfile) throw new Error('No active profile');
|
||||
|
||||
if (!mod) {
|
||||
throw new Error('Mod not found');
|
||||
const profileMods = activeProfile.mods || [];
|
||||
const modIndex = profileMods.findIndex(m => m.id === modId);
|
||||
|
||||
if (modIndex === -1) {
|
||||
throw new Error('Mod not found in profile');
|
||||
}
|
||||
|
||||
const mod = profileMods[modIndex];
|
||||
const newEnabled = !mod.enabled; // Toggle
|
||||
|
||||
// Update Profile First
|
||||
const updatedMods = [...profileMods];
|
||||
updatedMods[modIndex] = { ...mod, enabled: newEnabled };
|
||||
profileManager.updateProfile(activeProfile.id, { mods: updatedMods });
|
||||
|
||||
// Manually move the file to reflect the new state
|
||||
const disabledModsPath = path.join(path.dirname(modsPath), 'DisabledMods');
|
||||
if (!fs.existsSync(disabledModsPath)) {
|
||||
fs.mkdirSync(disabledModsPath, { recursive: true });
|
||||
}
|
||||
if (!fs.existsSync(disabledModsPath)) fs.mkdirSync(disabledModsPath, { recursive: true });
|
||||
|
||||
const currentPath = mod.filePath;
|
||||
let newPath, newEnabled;
|
||||
const currentPath = mod.enabled ? path.join(modsPath, mod.fileName) : path.join(disabledModsPath, mod.fileName);
|
||||
|
||||
if (mod.enabled) {
|
||||
newPath = path.join(disabledModsPath, path.basename(currentPath));
|
||||
newEnabled = false;
|
||||
// Determine target paths
|
||||
|
||||
const targetDir = newEnabled ? modsPath : disabledModsPath;
|
||||
const targetPath = path.join(targetDir, mod.fileName);
|
||||
|
||||
if (fs.existsSync(currentPath)) {
|
||||
fs.renameSync(currentPath, targetPath);
|
||||
} else {
|
||||
newPath = path.join(modsPath, path.basename(currentPath));
|
||||
newEnabled = true;
|
||||
// Fallback: check if it's already in target?
|
||||
|
||||
|
||||
if (fs.existsSync(targetPath)) {
|
||||
// It's already there, maybe just state was wrong.
|
||||
|
||||
console.log(`[ModManager] Mod ${mod.fileName} is already in the correct state`);
|
||||
|
||||
} else {
|
||||
// Try finding it
|
||||
const altPath = mod.enabled ? path.join(disabledModsPath, mod.fileName) : path.join(modsPath, mod.fileName);
|
||||
if (fs.existsSync(altPath)) fs.renameSync(altPath, targetPath);
|
||||
}
|
||||
|
||||
fs.renameSync(currentPath, newPath);
|
||||
|
||||
const configMods = loadModsFromConfig();
|
||||
const configModIndex = configMods.findIndex(m => m.id === modId);
|
||||
if (configModIndex !== -1) {
|
||||
configMods[configModIndex].enabled = newEnabled;
|
||||
saveModsToConfig(configMods);
|
||||
}
|
||||
|
||||
return { success: true, enabled: newEnabled };
|
||||
@@ -265,11 +265,69 @@ async function toggleMod(modId, modsPath) {
|
||||
}
|
||||
}
|
||||
|
||||
async function syncModsForCurrentProfile() {
|
||||
try {
|
||||
const activeProfile = profileManager.getActiveProfile();
|
||||
if (!activeProfile) {
|
||||
console.warn('No active profile found during mod sync');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`[ModManager] Syncing mods for profile: ${activeProfile.name}`);
|
||||
|
||||
const modsPath = await getModsPath();
|
||||
const disabledModsPath = path.join(path.dirname(modsPath), 'DisabledMods');
|
||||
|
||||
if (!fs.existsSync(disabledModsPath)) {
|
||||
fs.mkdirSync(disabledModsPath, { recursive: true });
|
||||
}
|
||||
|
||||
// Get all physical files from both folders
|
||||
const enabledFiles = fs.existsSync(modsPath) ? fs.readdirSync(modsPath).filter(f => f.endsWith('.jar') || f.endsWith('.zip')) : [];
|
||||
const disabledFiles = fs.existsSync(disabledModsPath) ? fs.readdirSync(disabledModsPath).filter(f => f.endsWith('.jar') || f.endsWith('.zip')) : [];
|
||||
|
||||
const allFiles = new Set([...enabledFiles, ...disabledFiles]);
|
||||
|
||||
// Profile.mods contains the list of ALL mods for that profile, with their enabled state.
|
||||
|
||||
const profileMods = activeProfile.mods || [];
|
||||
|
||||
for (const fileName of allFiles) {
|
||||
const modConfig = profileMods.find(m => m.fileName === fileName);
|
||||
const shouldBeEnabled = modConfig && modConfig.enabled !== false; // Default to true if in list, unless explicitly false
|
||||
|
||||
// Logic:
|
||||
// If it should be enabled -> Move to mods/
|
||||
// If it should be disabled -> Move to DisabledMods/
|
||||
|
||||
const currentPath = enabledFiles.includes(fileName) ? path.join(modsPath, fileName) : path.join(disabledModsPath, fileName);
|
||||
const targetDir = shouldBeEnabled ? modsPath : disabledModsPath;
|
||||
const targetPath = path.join(targetDir, fileName);
|
||||
|
||||
if (path.dirname(currentPath) !== targetDir) {
|
||||
console.log(`[Mod Sync] Moving ${fileName} to ${shouldBeEnabled ? 'Enabled' : 'Disabled'}`);
|
||||
try {
|
||||
fs.renameSync(currentPath, targetPath);
|
||||
} catch (err) {
|
||||
console.error(`Failed to move ${fileName}: ${err.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { success: true };
|
||||
|
||||
} catch (error) {
|
||||
console.error('[ModManager] Error syncing mods:', error);
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
loadInstalledMods,
|
||||
downloadMod,
|
||||
uninstallMod,
|
||||
toggleMod,
|
||||
syncModsForCurrentProfile,
|
||||
generateModId,
|
||||
extractModName,
|
||||
extractVersion
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { findClientPath } = require('../core/paths');
|
||||
const { downloadFile } = require('../utils/fileManager');
|
||||
const { getLatestClientVersion, getMultiClientVersion } = require('../services/versionManager');
|
||||
|
||||
async function downloadMultiClient(gameDir, progressCallback) {
|
||||
try {
|
||||
if (process.platform !== 'win32') {
|
||||
console.log('Multiplayer-client is only available for Windows');
|
||||
return { success: false, reason: 'Platform not supported' };
|
||||
}
|
||||
|
||||
const clientPath = findClientPath(gameDir);
|
||||
if (!clientPath) {
|
||||
throw new Error('Game client not found. Install game first.');
|
||||
}
|
||||
|
||||
console.log('Downloading Multiplayer from server...');
|
||||
if (progressCallback) {
|
||||
progressCallback('Downloading Multiplayer...', null, null, null, null);
|
||||
}
|
||||
|
||||
const clientUrl = 'http://3.10.208.30:3002/client';
|
||||
const tempClientPath = path.join(path.dirname(clientPath), 'HytaleClient_temp.exe');
|
||||
|
||||
await downloadFile(clientUrl, tempClientPath, progressCallback);
|
||||
|
||||
const backupPath = path.join(path.dirname(clientPath), 'HytaleClient_original.exe');
|
||||
if (!fs.existsSync(backupPath)) {
|
||||
fs.copyFileSync(clientPath, backupPath);
|
||||
console.log('Original client backed up');
|
||||
}
|
||||
|
||||
fs.renameSync(tempClientPath, clientPath);
|
||||
|
||||
if (progressCallback) {
|
||||
progressCallback('Multiplayer installed', 100, null, null, null);
|
||||
}
|
||||
console.log('Multiplayer installed successfully');
|
||||
|
||||
return { success: true, installed: true };
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error installing Multiplayer:', error);
|
||||
throw new Error(`Failed to install Multiplayer: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function checkAndInstallMultiClient(gameDir, progressCallback) {
|
||||
try {
|
||||
if (process.platform !== 'win32') {
|
||||
console.log('Multiplayer check skipped (Windows only)');
|
||||
return { success: true, skipped: true, reason: 'Windows only' };
|
||||
}
|
||||
|
||||
console.log('Checking for Multiplayer availability...');
|
||||
|
||||
const [clientVersion, multiVersion] = await Promise.all([
|
||||
getLatestClientVersion(),
|
||||
getMultiClientVersion()
|
||||
]);
|
||||
|
||||
if (!multiVersion) {
|
||||
console.log('Multiplayer not available');
|
||||
return { success: true, skipped: true, reason: 'Multiplayer not available' };
|
||||
}
|
||||
|
||||
if (clientVersion === multiVersion) {
|
||||
console.log(`Versions match (${clientVersion}), installing Multiplayer...`);
|
||||
return await downloadMultiClient(gameDir, progressCallback);
|
||||
} else {
|
||||
console.log(`Version mismatch: client=${clientVersion}, multi=${multiVersion}`);
|
||||
return { success: true, skipped: true, reason: 'Version mismatch' };
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error checking Multiplayer:', error);
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
downloadMultiClient,
|
||||
checkAndInstallMultiClient
|
||||
};
|
||||
|
||||
206
backend/managers/profileManager.js
Normal file
206
backend/managers/profileManager.js
Normal file
@@ -0,0 +1,206 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { v4: uuidv4 } = require('uuid');
|
||||
const {
|
||||
loadConfig,
|
||||
saveConfig,
|
||||
getModsPath
|
||||
} = require('../core/config');
|
||||
|
||||
// Lazy-load modManager to avoid circular deps, or keep imports structured.
|
||||
// For now, access mod paths directly or use helper helpers.
|
||||
|
||||
class ProfileManager {
|
||||
constructor() {
|
||||
this.initialized = false;
|
||||
}
|
||||
|
||||
init() {
|
||||
if (this.initialized) return;
|
||||
|
||||
const config = loadConfig();
|
||||
|
||||
// Migration: specific check to see if we have profiles yet
|
||||
if (!config.profiles || Object.keys(config.profiles).length === 0) {
|
||||
this.migrateLegacyConfig(config);
|
||||
}
|
||||
|
||||
this.initialized = true;
|
||||
console.log('[ProfileManager] Initialized');
|
||||
}
|
||||
|
||||
migrateLegacyConfig(config) {
|
||||
console.log('[ProfileManager] Migrating legacy config to profile system...');
|
||||
|
||||
// Create a default profile with current settings
|
||||
const defaultProfileId = 'default';
|
||||
const defaultProfile = {
|
||||
id: defaultProfileId,
|
||||
name: 'Default',
|
||||
created: new Date().toISOString(),
|
||||
lastUsed: new Date().toISOString(),
|
||||
|
||||
// settings specific to this profile
|
||||
// If global settings existed, we copy them here
|
||||
mods: config.installedMods || [], // Legacy mods are now part of default profile
|
||||
javaPath: config.javaPath || '',
|
||||
gameOptions: {
|
||||
minMemory: '1G',
|
||||
maxMemory: '4G',
|
||||
args: []
|
||||
}
|
||||
};
|
||||
|
||||
const updates = {
|
||||
profiles: {
|
||||
[defaultProfileId]: defaultProfile
|
||||
},
|
||||
activeProfileId: defaultProfileId,
|
||||
// Mods are currently treated as files on disk.
|
||||
// The profile's `mods` array is the source of truth for enabled/known mods per profile.
|
||||
|
||||
};
|
||||
|
||||
saveConfig(updates);
|
||||
console.log('[ProfileManager] Migration complete. Created Default profile.');
|
||||
}
|
||||
|
||||
createProfile(name) {
|
||||
if (!name || typeof name !== 'string') {
|
||||
throw new Error('Invalid profile name');
|
||||
}
|
||||
|
||||
const config = loadConfig();
|
||||
const id = uuidv4();
|
||||
|
||||
const newProfile = {
|
||||
id,
|
||||
name: name.trim(),
|
||||
created: new Date().toISOString(),
|
||||
lastUsed: null,
|
||||
mods: [], // Start with no mods enabled
|
||||
javaPath: '',
|
||||
gameOptions: {
|
||||
minMemory: '1G',
|
||||
maxMemory: '4G',
|
||||
args: []
|
||||
}
|
||||
};
|
||||
|
||||
const profiles = config.profiles || {};
|
||||
profiles[id] = newProfile;
|
||||
|
||||
saveConfig({ profiles });
|
||||
|
||||
console.log(`[ProfileManager] Created new profile: "${name}" (${id})`);
|
||||
return newProfile;
|
||||
}
|
||||
|
||||
getProfiles() {
|
||||
const config = loadConfig();
|
||||
return Object.values(config.profiles || {});
|
||||
}
|
||||
|
||||
getProfile(id) {
|
||||
const config = loadConfig();
|
||||
return (config.profiles && config.profiles[id]) || null;
|
||||
}
|
||||
|
||||
getActiveProfile() {
|
||||
const config = loadConfig();
|
||||
const activeId = config.activeProfileId;
|
||||
if (!activeId || !config.profiles || !config.profiles[activeId]) {
|
||||
// Fallback if something is corrupted
|
||||
return this.getProfiles()[0] || null;
|
||||
}
|
||||
return config.profiles[activeId];
|
||||
}
|
||||
|
||||
async activateProfile(id) {
|
||||
const config = loadConfig();
|
||||
if (!config.profiles || !config.profiles[id]) {
|
||||
throw new Error(`Profile not found: ${id}`);
|
||||
}
|
||||
|
||||
if (config.activeProfileId === id) {
|
||||
console.log(`[ProfileManager] Profile ${id} is already active.`);
|
||||
return config.profiles[id];
|
||||
}
|
||||
|
||||
console.log(`[ProfileManager] Switching to profile: ${config.profiles[id].name} (${id})`);
|
||||
|
||||
// 1. Update config first
|
||||
config.profiles[id].lastUsed = new Date().toISOString();
|
||||
saveConfig({
|
||||
activeProfileId: id,
|
||||
profiles: config.profiles
|
||||
});
|
||||
|
||||
// 2. Trigger Mod Sync
|
||||
// We need to require this here to ensure it uses the *newly saved* active profile ID
|
||||
const { syncModsForCurrentProfile } = require('./modManager');
|
||||
await syncModsForCurrentProfile();
|
||||
|
||||
return config.profiles[id];
|
||||
}
|
||||
|
||||
deleteProfile(id) {
|
||||
const config = loadConfig();
|
||||
const profiles = config.profiles || {};
|
||||
|
||||
if (!profiles[id]) {
|
||||
throw new Error('Profile not found');
|
||||
}
|
||||
|
||||
if (config.activeProfileId === id) {
|
||||
throw new Error('Cannot delete the active profile');
|
||||
}
|
||||
|
||||
// Don't allow deleting the last profile
|
||||
if (Object.keys(profiles).length <= 1) {
|
||||
throw new Error('Cannot delete the only remaining profile');
|
||||
}
|
||||
|
||||
delete profiles[id];
|
||||
saveConfig({ profiles });
|
||||
console.log(`[ProfileManager] Deleted profile: ${id}`);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
updateProfile(id, updates) {
|
||||
const config = loadConfig();
|
||||
const profiles = config.profiles || {};
|
||||
|
||||
if (!profiles[id]) {
|
||||
throw new Error('Profile not found');
|
||||
}
|
||||
|
||||
// Safety checks on updates
|
||||
const allowedFields = ['name', 'javaPath', 'gameOptions', 'mods'];
|
||||
const sanitizedUpdates = {};
|
||||
|
||||
Object.keys(updates).forEach(key => {
|
||||
if (allowedFields.includes(key)) {
|
||||
sanitizedUpdates[key] = updates[key];
|
||||
}
|
||||
});
|
||||
|
||||
profiles[id] = { ...profiles[id], ...sanitizedUpdates };
|
||||
|
||||
saveConfig({ profiles });
|
||||
console.log(`[ProfileManager] Updated profile: ${id}`);
|
||||
|
||||
// If we updated mods for the *active* profile, we might need to sync immediately
|
||||
if (config.activeProfileId === id && updates.mods) {
|
||||
// Optionally trigger sync?
|
||||
// Sync is usually triggered when toggling a single mod.
|
||||
// For bulk updates, the caller should decide when to sync.
|
||||
|
||||
}
|
||||
|
||||
return profiles[id];
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new ProfileManager();
|
||||
@@ -10,7 +10,7 @@ async function downloadAndReplaceHomePageUI(gameDir, progressCallback) {
|
||||
progressCallback('Downloading HomePage.ui...', null, null, null, null);
|
||||
}
|
||||
|
||||
const homeUIUrl = 'http://3.10.208.30:3002/api/HomeUI';
|
||||
const homeUIUrl = 'https://files.hytalef2p.com/api/HomeUI';
|
||||
const tempHomePath = path.join(path.dirname(gameDir), 'HomePage_temp.ui');
|
||||
|
||||
await downloadFile(homeUIUrl, tempHomePath);
|
||||
@@ -63,7 +63,7 @@ async function downloadAndReplaceLogo(gameDir, progressCallback) {
|
||||
progressCallback('Downloading Logo@2x.png...', null, null, null, null);
|
||||
}
|
||||
|
||||
const logoUrl = 'http://3.10.208.30:3002/api/Logo';
|
||||
const logoUrl = 'https://files.hytalef2p.com/api/Logo';
|
||||
const tempLogoPath = path.join(path.dirname(gameDir), 'Logo@2x_temp.png');
|
||||
|
||||
await downloadFile(logoUrl, tempLogoPath);
|
||||
|
||||
@@ -3,7 +3,7 @@ const axios = require('axios');
|
||||
async function getLatestClientVersion() {
|
||||
try {
|
||||
console.log('Fetching latest client version from API...');
|
||||
const response = await axios.get('http://3.10.208.30:3002/api/version_client', {
|
||||
const response = await axios.get('https://files.hytalef2p.com/api/version_client', {
|
||||
timeout: 5000,
|
||||
headers: {
|
||||
'User-Agent': 'Hytale-F2P-Launcher'
|
||||
@@ -28,7 +28,7 @@ async function getLatestClientVersion() {
|
||||
async function getInstalledClientVersion() {
|
||||
try {
|
||||
console.log('Fetching installed client version from API...');
|
||||
const response = await axios.get('http://3.10.208.30:3002/api/clientCheck', {
|
||||
const response = await axios.get('https://files.hytalef2p.com/api/clientCheck', {
|
||||
timeout: 5000,
|
||||
headers: {
|
||||
'User-Agent': 'Hytale-F2P-Launcher'
|
||||
@@ -50,33 +50,7 @@ async function getInstalledClientVersion() {
|
||||
}
|
||||
}
|
||||
|
||||
async function getMultiClientVersion() {
|
||||
try {
|
||||
console.log('Fetching Multiplayer version from API...');
|
||||
const response = await axios.get('http://3.10.208.30:3002/api/multi', {
|
||||
timeout: 5000,
|
||||
headers: {
|
||||
'User-Agent': 'Hytale-F2P-Launcher'
|
||||
}
|
||||
});
|
||||
|
||||
if (response.data && response.data.multi_version) {
|
||||
const version = response.data.multi_version;
|
||||
console.log(`Multiplayer version: ${version}`);
|
||||
return version;
|
||||
} else {
|
||||
console.log('Warning: Invalid multi API response');
|
||||
return null;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching Multiplayer version:', error.message);
|
||||
console.log('Multiplayer not available');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getLatestClientVersion,
|
||||
getInstalledClientVersion,
|
||||
getMultiClientVersion
|
||||
getInstalledClientVersion
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const axios = require('axios');
|
||||
|
||||
const UPDATE_CHECK_URL = 'http://3.10.208.30:3002/api/version_launcher';
|
||||
const CURRENT_VERSION = '2.0.1';
|
||||
const UPDATE_CHECK_URL = 'https://files.hytalef2p.com/api/version_launcher';
|
||||
const CURRENT_VERSION = '2.0.2';
|
||||
const GITHUB_DOWNLOAD_URL = 'https://github.com/amiayweb/Hytale-F2P/';
|
||||
|
||||
class UpdateManager {
|
||||
|
||||
468
backend/utils/clientPatcher.js
Normal file
468
backend/utils/clientPatcher.js
Normal file
@@ -0,0 +1,468 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const crypto = require('crypto');
|
||||
const AdmZip = require('adm-zip');
|
||||
|
||||
// Domain configuration
|
||||
const ORIGINAL_DOMAIN = 'hytale.com';
|
||||
|
||||
function getTargetDomain() {
|
||||
if (process.env.HYTALE_AUTH_DOMAIN) {
|
||||
return process.env.HYTALE_AUTH_DOMAIN;
|
||||
}
|
||||
try {
|
||||
const { getAuthDomain } = require('../core/config');
|
||||
return getAuthDomain();
|
||||
} catch (e) {
|
||||
return 'sanasol.ws';
|
||||
}
|
||||
}
|
||||
|
||||
const DEFAULT_NEW_DOMAIN = 'sanasol.ws';
|
||||
|
||||
/**
|
||||
* Patches HytaleClient and HytaleServer binaries to replace hytale.com with custom domain
|
||||
* This allows the game to connect to a custom authentication server
|
||||
*/
|
||||
class ClientPatcher {
|
||||
constructor() {
|
||||
this.patchedFlag = '.patched_custom';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the target domain for patching
|
||||
*/
|
||||
getNewDomain() {
|
||||
const domain = getTargetDomain();
|
||||
if (domain.length !== ORIGINAL_DOMAIN.length) {
|
||||
console.warn(`Warning: Domain "${domain}" length (${domain.length}) doesn't match original "${ORIGINAL_DOMAIN}" (${ORIGINAL_DOMAIN.length})`);
|
||||
console.warn(`Using default domain: ${DEFAULT_NEW_DOMAIN}`);
|
||||
return DEFAULT_NEW_DOMAIN;
|
||||
}
|
||||
return domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a string to UTF-16LE bytes (how .NET stores strings)
|
||||
*/
|
||||
stringToUtf16LE(str) {
|
||||
const buf = Buffer.alloc(str.length * 2);
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
buf.writeUInt16LE(str.charCodeAt(i), i * 2);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a string to UTF-8 bytes (how Java stores strings)
|
||||
*/
|
||||
stringToUtf8(str) {
|
||||
return Buffer.from(str, 'utf8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all occurrences of a pattern in a buffer
|
||||
*/
|
||||
findAllOccurrences(buffer, pattern) {
|
||||
const positions = [];
|
||||
let pos = 0;
|
||||
while (pos < buffer.length) {
|
||||
const index = buffer.indexOf(pattern, pos);
|
||||
if (index === -1) break;
|
||||
positions.push(index);
|
||||
pos = index + 1;
|
||||
}
|
||||
return positions;
|
||||
}
|
||||
|
||||
/**
|
||||
* UTF-8 domain replacement for Java JAR files.
|
||||
* Java stores strings in UTF-8 format in the constant pool.
|
||||
*/
|
||||
findAndReplaceDomainUtf8(data, oldDomain, newDomain) {
|
||||
let count = 0;
|
||||
const result = Buffer.from(data);
|
||||
|
||||
const oldUtf8 = this.stringToUtf8(oldDomain);
|
||||
const newUtf8 = this.stringToUtf8(newDomain);
|
||||
|
||||
const positions = this.findAllOccurrences(result, oldUtf8);
|
||||
|
||||
for (const pos of positions) {
|
||||
newUtf8.copy(result, pos);
|
||||
count++;
|
||||
console.log(` Patched UTF-8 occurrence at offset 0x${pos.toString(16)}`);
|
||||
}
|
||||
|
||||
return { buffer: result, count };
|
||||
}
|
||||
|
||||
/**
|
||||
* Smart domain replacement that handles both null-terminated and non-null-terminated strings.
|
||||
* .NET AOT stores some strings in various formats:
|
||||
* - Standard UTF-16LE (each char is 2 bytes with \x00 high byte)
|
||||
* - Length-prefixed where last char may have metadata byte instead of \x00
|
||||
*/
|
||||
findAndReplaceDomainSmart(data, oldDomain, newDomain) {
|
||||
let count = 0;
|
||||
const result = Buffer.from(data);
|
||||
|
||||
const oldUtf16NoLast = this.stringToUtf16LE(oldDomain.slice(0, -1));
|
||||
const newUtf16NoLast = this.stringToUtf16LE(newDomain.slice(0, -1));
|
||||
const oldLastChar = this.stringToUtf16LE(oldDomain.slice(-1));
|
||||
const newLastChar = this.stringToUtf16LE(newDomain.slice(-1));
|
||||
|
||||
const oldLastCharByte = oldDomain.charCodeAt(oldDomain.length - 1);
|
||||
const newLastCharByte = newDomain.charCodeAt(newDomain.length - 1);
|
||||
|
||||
const positions = this.findAllOccurrences(result, oldUtf16NoLast);
|
||||
|
||||
for (const pos of positions) {
|
||||
const lastCharPos = pos + oldUtf16NoLast.length;
|
||||
if (lastCharPos + 1 > result.length) continue;
|
||||
|
||||
const lastCharFirstByte = result[lastCharPos];
|
||||
|
||||
if (lastCharFirstByte === oldLastCharByte) {
|
||||
newUtf16NoLast.copy(result, pos);
|
||||
|
||||
result[lastCharPos] = newLastCharByte;
|
||||
|
||||
if (lastCharPos + 1 < result.length) {
|
||||
const secondByte = result[lastCharPos + 1];
|
||||
if (secondByte === 0x00) {
|
||||
console.log(` Patched UTF-16LE occurrence at offset 0x${pos.toString(16)}`);
|
||||
} else {
|
||||
console.log(` Patched length-prefixed occurrence at offset 0x${pos.toString(16)} (metadata: 0x${secondByte.toString(16)})`);
|
||||
}
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return { buffer: result, count };
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the client binary has already been patched
|
||||
*/
|
||||
isPatchedAlready(clientPath) {
|
||||
const newDomain = this.getNewDomain();
|
||||
const patchFlagFile = clientPath + this.patchedFlag;
|
||||
if (fs.existsSync(patchFlagFile)) {
|
||||
try {
|
||||
const flagData = JSON.parse(fs.readFileSync(patchFlagFile, 'utf8'));
|
||||
if (flagData.targetDomain === newDomain) {
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the client as patched
|
||||
*/
|
||||
markAsPatched(clientPath) {
|
||||
const newDomain = this.getNewDomain();
|
||||
const patchFlagFile = clientPath + this.patchedFlag;
|
||||
const flagData = {
|
||||
patchedAt: new Date().toISOString(),
|
||||
originalDomain: ORIGINAL_DOMAIN,
|
||||
targetDomain: newDomain,
|
||||
patcherVersion: '1.0.0'
|
||||
};
|
||||
fs.writeFileSync(patchFlagFile, JSON.stringify(flagData, null, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a backup of the original client binary
|
||||
*/
|
||||
backupClient(clientPath) {
|
||||
const backupPath = clientPath + '.original';
|
||||
if (!fs.existsSync(backupPath)) {
|
||||
console.log(` Creating backup at ${path.basename(backupPath)}`);
|
||||
fs.copyFileSync(clientPath, backupPath);
|
||||
return backupPath;
|
||||
}
|
||||
console.log(' Backup already exists');
|
||||
return backupPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the original client binary from backup
|
||||
*/
|
||||
restoreClient(clientPath) {
|
||||
const backupPath = clientPath + '.original';
|
||||
if (fs.existsSync(backupPath)) {
|
||||
fs.copyFileSync(backupPath, clientPath);
|
||||
const patchFlagFile = clientPath + this.patchedFlag;
|
||||
if (fs.existsSync(patchFlagFile)) {
|
||||
fs.unlinkSync(patchFlagFile);
|
||||
}
|
||||
console.log('Client restored from backup');
|
||||
return true;
|
||||
}
|
||||
console.log('No backup found to restore');
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Patch the client binary to use the custom domain
|
||||
* @param {string} clientPath - Path to the HytaleClient binary
|
||||
* @param {function} progressCallback - Optional callback for progress updates
|
||||
* @returns {object} Result object with success status and details
|
||||
*/
|
||||
async patchClient(clientPath, progressCallback) {
|
||||
const newDomain = this.getNewDomain();
|
||||
console.log('=== Client Patcher ===');
|
||||
console.log(`Target: ${clientPath}`);
|
||||
console.log(`Replacing: ${ORIGINAL_DOMAIN} -> ${newDomain}`);
|
||||
|
||||
if (!fs.existsSync(clientPath)) {
|
||||
const error = `Client binary not found: ${clientPath}`;
|
||||
console.error(error);
|
||||
return { success: false, error };
|
||||
}
|
||||
|
||||
if (this.isPatchedAlready(clientPath)) {
|
||||
console.log(`Client already patched for ${newDomain}, skipping`);
|
||||
if (progressCallback) {
|
||||
progressCallback('Client already patched', 100);
|
||||
}
|
||||
return { success: true, alreadyPatched: true, patchCount: 0 };
|
||||
}
|
||||
|
||||
if (progressCallback) {
|
||||
progressCallback('Preparing to patch client...', 10);
|
||||
}
|
||||
|
||||
console.log('Creating backup...');
|
||||
this.backupClient(clientPath);
|
||||
|
||||
if (progressCallback) {
|
||||
progressCallback('Reading client binary...', 20);
|
||||
}
|
||||
|
||||
console.log('Reading client binary...');
|
||||
const data = fs.readFileSync(clientPath);
|
||||
console.log(`Binary size: ${(data.length / 1024 / 1024).toFixed(2)} MB`);
|
||||
|
||||
if (progressCallback) {
|
||||
progressCallback('Patching domain references...', 50);
|
||||
}
|
||||
|
||||
console.log('Patching domain references...');
|
||||
const { buffer: patchedData, count } = this.findAndReplaceDomainSmart(data, ORIGINAL_DOMAIN, newDomain);
|
||||
|
||||
if (count === 0) {
|
||||
console.log('No occurrences of hytale.com found - binary may already be modified or has different format');
|
||||
return { success: true, patchCount: 0, warning: 'No domain occurrences found' };
|
||||
}
|
||||
|
||||
if (progressCallback) {
|
||||
progressCallback('Writing patched binary...', 80);
|
||||
}
|
||||
|
||||
console.log('Writing patched binary...');
|
||||
fs.writeFileSync(clientPath, patchedData);
|
||||
|
||||
this.markAsPatched(clientPath);
|
||||
|
||||
if (progressCallback) {
|
||||
progressCallback('Patching complete', 100);
|
||||
}
|
||||
|
||||
console.log(`Successfully patched ${count} occurrences`);
|
||||
console.log('=== Patching Complete ===');
|
||||
|
||||
return { success: true, patchCount: count };
|
||||
}
|
||||
|
||||
/**
|
||||
* Patch the server JAR to use the custom domain
|
||||
* JAR files are ZIP archives, so we need to extract, patch class files, and repackage
|
||||
* @param {string} serverPath - Path to the HytaleServer.jar
|
||||
* @param {function} progressCallback - Optional callback for progress updates
|
||||
* @returns {object} Result object with success status and details
|
||||
*/
|
||||
async patchServer(serverPath, progressCallback) {
|
||||
const newDomain = this.getNewDomain();
|
||||
console.log('=== Server Patcher ===');
|
||||
console.log(`Target: ${serverPath}`);
|
||||
console.log(`Replacing: ${ORIGINAL_DOMAIN} -> ${newDomain}`);
|
||||
|
||||
if (!fs.existsSync(serverPath)) {
|
||||
const error = `Server JAR not found: ${serverPath}`;
|
||||
console.error(error);
|
||||
return { success: false, error };
|
||||
}
|
||||
|
||||
if (this.isPatchedAlready(serverPath)) {
|
||||
console.log(`Server already patched for ${newDomain}, skipping`);
|
||||
if (progressCallback) {
|
||||
progressCallback('Server already patched', 100);
|
||||
}
|
||||
return { success: true, alreadyPatched: true, patchCount: 0 };
|
||||
}
|
||||
|
||||
if (progressCallback) {
|
||||
progressCallback('Preparing to patch server...', 10);
|
||||
}
|
||||
|
||||
console.log('Creating backup...');
|
||||
this.backupClient(serverPath);
|
||||
|
||||
if (progressCallback) {
|
||||
progressCallback('Extracting server JAR...', 20);
|
||||
}
|
||||
|
||||
console.log('Opening server JAR...');
|
||||
const zip = new AdmZip(serverPath);
|
||||
const entries = zip.getEntries();
|
||||
console.log(`JAR contains ${entries.length} entries`);
|
||||
|
||||
if (progressCallback) {
|
||||
progressCallback('Patching class files...', 40);
|
||||
}
|
||||
|
||||
let totalCount = 0;
|
||||
const oldUtf8 = this.stringToUtf8(ORIGINAL_DOMAIN);
|
||||
const newUtf8 = this.stringToUtf8(newDomain);
|
||||
|
||||
for (const entry of entries) {
|
||||
const name = entry.entryName;
|
||||
if (name.endsWith('.class') || name.endsWith('.properties') ||
|
||||
name.endsWith('.json') || name.endsWith('.xml') || name.endsWith('.yml')) {
|
||||
|
||||
const data = entry.getData();
|
||||
|
||||
if (data.includes(oldUtf8)) {
|
||||
const { buffer: patchedData, count } = this.findAndReplaceDomainUtf8(data, ORIGINAL_DOMAIN, newDomain);
|
||||
if (count > 0) {
|
||||
zip.updateFile(entry.entryName, patchedData);
|
||||
console.log(` Patched ${count} occurrences in ${name}`);
|
||||
totalCount += count;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (totalCount === 0) {
|
||||
console.log('No occurrences of hytale.com found in server JAR entries');
|
||||
return { success: true, patchCount: 0, warning: 'No domain occurrences found in JAR' };
|
||||
}
|
||||
|
||||
if (progressCallback) {
|
||||
progressCallback('Writing patched JAR...', 80);
|
||||
}
|
||||
|
||||
console.log('Writing patched JAR...');
|
||||
zip.writeZip(serverPath);
|
||||
|
||||
this.markAsPatched(serverPath);
|
||||
|
||||
if (progressCallback) {
|
||||
progressCallback('Server patching complete', 100);
|
||||
}
|
||||
|
||||
console.log(`Successfully patched ${totalCount} occurrences in server`);
|
||||
console.log('=== Server Patching Complete ===');
|
||||
|
||||
return { success: true, patchCount: totalCount };
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the client binary path based on platform
|
||||
*/
|
||||
findClientPath(gameDir) {
|
||||
const candidates = [];
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
candidates.push(path.join(gameDir, 'Client', 'Hytale.app', 'Contents', 'MacOS', 'HytaleClient'));
|
||||
candidates.push(path.join(gameDir, 'Client', 'HytaleClient'));
|
||||
} else if (process.platform === 'win32') {
|
||||
candidates.push(path.join(gameDir, 'Client', 'HytaleClient.exe'));
|
||||
} else {
|
||||
candidates.push(path.join(gameDir, 'Client', 'HytaleClient'));
|
||||
}
|
||||
|
||||
for (const candidate of candidates) {
|
||||
if (fs.existsSync(candidate)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
findServerPath(gameDir) {
|
||||
const candidates = [
|
||||
path.join(gameDir, 'Server', 'HytaleServer.jar'),
|
||||
path.join(gameDir, 'Server', 'server.jar')
|
||||
];
|
||||
|
||||
for (const candidate of candidates) {
|
||||
if (fs.existsSync(candidate)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure both client and server are patched before launching
|
||||
* @param {string} gameDir - Path to the game directory
|
||||
* @param {function} progressCallback - Optional callback for progress updates
|
||||
*/
|
||||
async ensureClientPatched(gameDir, progressCallback) {
|
||||
const results = {
|
||||
client: null,
|
||||
server: null,
|
||||
success: true
|
||||
};
|
||||
|
||||
const clientPath = this.findClientPath(gameDir);
|
||||
if (clientPath) {
|
||||
if (progressCallback) {
|
||||
progressCallback('Patching client binary...', 10);
|
||||
}
|
||||
results.client = await this.patchClient(clientPath, (msg, pct) => {
|
||||
if (progressCallback) {
|
||||
progressCallback(`Client: ${msg}`, pct ? pct / 2 : null);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.warn('Could not find HytaleClient binary');
|
||||
results.client = { success: false, error: 'Client binary not found' };
|
||||
}
|
||||
|
||||
const serverPath = this.findServerPath(gameDir);
|
||||
if (serverPath) {
|
||||
if (progressCallback) {
|
||||
progressCallback('Patching server JAR...', 50);
|
||||
}
|
||||
results.server = await this.patchServer(serverPath, (msg, pct) => {
|
||||
if (progressCallback) {
|
||||
progressCallback(`Server: ${msg}`, pct ? 50 + pct / 2 : null);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.warn('Could not find HytaleServer.jar');
|
||||
results.server = { success: false, error: 'Server JAR not found' };
|
||||
}
|
||||
|
||||
results.success = (results.client && results.client.success) || (results.server && results.server.success);
|
||||
results.alreadyPatched = (results.client && results.client.alreadyPatched) && (results.server && results.server.alreadyPatched);
|
||||
results.patchCount = (results.client ? results.client.patchCount || 0 : 0) + (results.server ? results.server.patchCount || 0 : 0);
|
||||
|
||||
if (progressCallback) {
|
||||
progressCallback('Patching complete', 100);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new ClientPatcher();
|
||||
@@ -2,42 +2,151 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
const axios = require('axios');
|
||||
|
||||
async function downloadFile(url, dest, progressCallback) {
|
||||
async function downloadFile(url, dest, progressCallback, maxRetries = 3) {
|
||||
let lastError = null;
|
||||
|
||||
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
||||
try {
|
||||
console.log(`Download attempt ${attempt + 1}/${maxRetries} for ${url}`);
|
||||
|
||||
if (attempt > 0 && progressCallback) {
|
||||
progressCallback(`Retry ${attempt}/${maxRetries - 1}...`, null, null, null, null);
|
||||
await new Promise(resolve => setTimeout(resolve, 2000 * attempt)); // Délai progressif
|
||||
}
|
||||
|
||||
const response = await axios({
|
||||
method: 'GET',
|
||||
url: url,
|
||||
responseType: 'stream',
|
||||
timeout: 60000, // 60 secondes timeout
|
||||
headers: {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
||||
'Accept': '*/*',
|
||||
'Accept-Language': 'en-US,en;q=0.9',
|
||||
'Referer': 'https://launcher.hytale.com/'
|
||||
}
|
||||
'Referer': 'https://launcher.hytale.com/',
|
||||
'Connection': 'keep-alive'
|
||||
},
|
||||
// Configuration Axios pour la robustesse réseau
|
||||
validateStatus: function (status) {
|
||||
return status >= 200 && status < 300;
|
||||
},
|
||||
// Retry configuration
|
||||
maxRedirects: 5,
|
||||
// Network resilience
|
||||
family: 4 // Force IPv4
|
||||
});
|
||||
|
||||
const totalSize = parseInt(response.headers['content-length'], 10);
|
||||
let downloaded = 0;
|
||||
let lastProgressTime = Date.now();
|
||||
const startTime = Date.now();
|
||||
|
||||
// Nettoyer le fichier de destination s'il existe
|
||||
if (fs.existsSync(dest)) {
|
||||
fs.unlinkSync(dest);
|
||||
}
|
||||
|
||||
const writer = fs.createWriteStream(dest);
|
||||
let downloadStalled = false;
|
||||
let stalledTimeout = null;
|
||||
|
||||
response.data.on('data', (chunk) => {
|
||||
downloaded += chunk.length;
|
||||
if (progressCallback && totalSize > 0) {
|
||||
const now = Date.now();
|
||||
|
||||
// Reset stalled timer on data received
|
||||
if (stalledTimeout) {
|
||||
clearTimeout(stalledTimeout);
|
||||
}
|
||||
|
||||
// Set new stalled timer (30 seconds without data = stalled)
|
||||
stalledTimeout = setTimeout(() => {
|
||||
downloadStalled = true;
|
||||
writer.destroy();
|
||||
response.data.destroy();
|
||||
}, 30000);
|
||||
|
||||
if (progressCallback && totalSize > 0 && (now - lastProgressTime > 100)) { // Update every 100ms max
|
||||
const percent = Math.min(100, Math.max(0, (downloaded / totalSize) * 100));
|
||||
const elapsed = (Date.now() - startTime) / 1000;
|
||||
const elapsed = (now - startTime) / 1000;
|
||||
const speed = elapsed > 0 ? downloaded / elapsed : 0;
|
||||
progressCallback(null, percent, speed, downloaded, totalSize);
|
||||
lastProgressTime = now;
|
||||
}
|
||||
});
|
||||
|
||||
response.data.on('error', (error) => {
|
||||
if (stalledTimeout) {
|
||||
clearTimeout(stalledTimeout);
|
||||
}
|
||||
console.error(`Stream error on attempt ${attempt + 1}:`, error.code || error.message);
|
||||
writer.destroy();
|
||||
});
|
||||
|
||||
response.data.pipe(writer);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
writer.on('finish', resolve);
|
||||
writer.on('error', reject);
|
||||
response.data.on('error', reject);
|
||||
await new Promise((resolve, reject) => {
|
||||
writer.on('finish', () => {
|
||||
if (stalledTimeout) {
|
||||
clearTimeout(stalledTimeout);
|
||||
}
|
||||
if (!downloadStalled) {
|
||||
console.log(`Download completed successfully on attempt ${attempt + 1}`);
|
||||
resolve();
|
||||
} else {
|
||||
reject(new Error('Download stalled'));
|
||||
}
|
||||
});
|
||||
|
||||
writer.on('error', (error) => {
|
||||
if (stalledTimeout) {
|
||||
clearTimeout(stalledTimeout);
|
||||
}
|
||||
reject(error);
|
||||
});
|
||||
|
||||
response.data.on('error', (error) => {
|
||||
if (stalledTimeout) {
|
||||
clearTimeout(stalledTimeout);
|
||||
}
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
|
||||
// Si on arrive ici, le téléchargement a réussi
|
||||
return;
|
||||
|
||||
} catch (error) {
|
||||
lastError = error;
|
||||
console.error(`Download attempt ${attempt + 1} failed:`, error.code || error.message);
|
||||
|
||||
// Nettoyer le fichier partiel en cas d'erreur
|
||||
if (fs.existsSync(dest)) {
|
||||
try {
|
||||
fs.unlinkSync(dest);
|
||||
} catch (cleanupError) {
|
||||
console.warn('Could not cleanup partial file:', cleanupError.message);
|
||||
}
|
||||
}
|
||||
|
||||
// Vérifier si c'est une erreur réseau que l'on peut retry
|
||||
const retryableErrors = ['ECONNRESET', 'ENOTFOUND', 'ECONNREFUSED', 'ETIMEDOUT', 'ESOCKETTIMEDOUT', 'EPROTO'];
|
||||
const isRetryable = retryableErrors.includes(error.code) ||
|
||||
error.message.includes('timeout') ||
|
||||
error.message.includes('stalled') ||
|
||||
(error.response && error.response.status >= 500);
|
||||
|
||||
if (!isRetryable || attempt === maxRetries - 1) {
|
||||
console.error(`Non-retryable error or max retries reached: ${error.code || error.message}`);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
console.log(`Retryable error detected, will retry in ${2000 * (attempt + 1)}ms...`);
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`Download failed after ${maxRetries} attempts. Last error: ${lastError?.code || lastError?.message || 'Unknown error'}`);
|
||||
}
|
||||
|
||||
function findHomePageUIPath(gameLatest) {
|
||||
|
||||
@@ -65,9 +65,100 @@ function setupWaylandEnvironment() {
|
||||
return envVars;
|
||||
}
|
||||
|
||||
function detectGpu() {
|
||||
if (process.platform !== 'linux') {
|
||||
return { mode: 'integrated', vendor: 'intel', integratedName: 'Unknown', dedicatedName: null };
|
||||
}
|
||||
|
||||
try {
|
||||
const output = execSync('lspci -nn | grep \'VGA\\|3D\'', { encoding: 'utf8' });
|
||||
// console.log('GPU detection raw output:', output);
|
||||
const lines = output.split('\n').filter(line => line.trim());
|
||||
// console.log('GPU detection parsed lines:', lines);
|
||||
|
||||
let integratedName = null;
|
||||
let dedicatedName = null;
|
||||
let hasNvidia = false;
|
||||
let hasAmd = false;
|
||||
|
||||
for (const line of lines) {
|
||||
// console.log('Checking line:', line);
|
||||
if (line.includes('VGA') || line.includes('3D')) {
|
||||
// console.log('Line contains VGA or 3D');
|
||||
|
||||
const match = line.match(/\[([^\]]+)\]/g);
|
||||
let modelName = null;
|
||||
if (match && match.length >= 2) {
|
||||
modelName = match[1].slice(1, -1);
|
||||
}
|
||||
|
||||
if (line.includes('10de:') || line.toLowerCase().includes('nvidia')) {
|
||||
hasNvidia = true;
|
||||
dedicatedName = "NVIDIA " + modelName || 'NVIDIA GPU';
|
||||
console.log('Detected NVIDIA GPU:', dedicatedName);
|
||||
} else if (line.includes('1002:') || line.toLowerCase().includes('amd') || line.toLowerCase().includes('radeon')) {
|
||||
hasAmd = true;
|
||||
dedicatedName = "AMD " + modelName || 'AMD GPU';
|
||||
console.log('Detected AMD GPU:', dedicatedName);
|
||||
} else if (line.includes('8086:') || line.toLowerCase().includes('intel')) {
|
||||
integratedName = "Intel " + modelName || 'Intel GPU';
|
||||
console.log('Detected Intel GPU:', integratedName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// console.log('hasNvidia:', hasNvidia, 'hasAmd:', hasAmd, 'integratedName:', integratedName, 'dedicatedName:', dedicatedName);
|
||||
|
||||
if (hasNvidia) {
|
||||
return { mode: 'dedicated', vendor: 'nvidia', integratedName: integratedName || 'Intel GPU', dedicatedName };
|
||||
} else if (hasAmd) {
|
||||
return { mode: 'dedicated', vendor: 'amd', integratedName: integratedName || 'Intel GPU', dedicatedName };
|
||||
} else {
|
||||
return { mode: 'integrated', vendor: 'intel', integratedName: integratedName || 'Intel GPU', dedicatedName: null };
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('GPU detection failed, falling back to integrated:', error.message);
|
||||
return { mode: 'integrated', vendor: 'intel', integratedName: 'Unknown', dedicatedName: null };
|
||||
}
|
||||
}
|
||||
|
||||
function setupGpuEnvironment(gpuPreference) {
|
||||
if (process.platform !== 'linux') {
|
||||
return {};
|
||||
}
|
||||
|
||||
let finalPreference = gpuPreference;
|
||||
let detected = detectGpu();
|
||||
|
||||
if (gpuPreference === 'auto') {
|
||||
finalPreference = detected.mode;
|
||||
console.log(`Auto-detected GPU: ${detected.vendor} (${detected.mode})`);
|
||||
}
|
||||
|
||||
console.log('Preferred GPU set to:', finalPreference);
|
||||
|
||||
const envVars = {};
|
||||
|
||||
if (finalPreference === 'dedicated') {
|
||||
envVars.DRI_PRIME = '1';
|
||||
if (detected.vendor === 'nvidia') {
|
||||
envVars.__NV_PRIME_RENDER_OFFLOAD = '1';
|
||||
envVars.__GLX_VENDOR_LIBRARY_NAME = 'nvidia';
|
||||
envVars.__GL_SHADER_DISK_CACHE = '1';
|
||||
envVars.__GL_SHADER_DISK_CACHE_PATH = '/tmp';
|
||||
}
|
||||
console.log('GPU environment variables:', envVars);
|
||||
} else {
|
||||
console.log('Using integrated GPU, no environment variables set');
|
||||
}
|
||||
return envVars;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getOS,
|
||||
getArch,
|
||||
isWaylandSession,
|
||||
setupWaylandEnvironment
|
||||
setupWaylandEnvironment,
|
||||
detectGpu,
|
||||
setupGpuEnvironment
|
||||
};
|
||||
|
||||
307
main.js
307
main.js
@@ -1,9 +1,10 @@
|
||||
const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { launchGame, launchGameWithVersionCheck, installGame, saveUsername, loadUsername, saveChatUsername, loadChatUsername, saveJavaPath, loadJavaPath, saveInstallPath, loadInstallPath, isGameInstalled, uninstallGame, getHytaleNews, handleFirstLaunchCheck, proposeGameUpdate, markAsLaunched } = require('./backend/launcher');
|
||||
const { launchGame, launchGameWithVersionCheck, installGame, saveUsername, loadUsername, saveChatUsername, loadChatUsername, saveChatColor, loadChatColor, saveJavaPath, loadJavaPath, saveInstallPath, loadInstallPath, saveDiscordRPC, loadDiscordRPC, isGameInstalled, uninstallGame, repairGame, getHytaleNews, handleFirstLaunchCheck, proposeGameUpdate, markAsLaunched } = require('./backend/launcher');
|
||||
const UpdateManager = require('./backend/updateManager');
|
||||
const logger = require('./backend/logger');
|
||||
const profileManager = require('./backend/managers/profileManager');
|
||||
|
||||
logger.interceptConsole();
|
||||
|
||||
@@ -16,6 +17,13 @@ const DISCORD_CLIENT_ID = '1462244937868513373';
|
||||
|
||||
function initDiscordRPC() {
|
||||
try {
|
||||
// Check if Discord RPC is enabled in settings
|
||||
const rpcEnabled = loadDiscordRPC();
|
||||
if (!rpcEnabled) {
|
||||
console.log('Discord RPC disabled in settings');
|
||||
return;
|
||||
}
|
||||
|
||||
const { Client } = require('discord-rpc');
|
||||
discordRPC = new Client({ transport: 'ipc' });
|
||||
|
||||
@@ -57,6 +65,26 @@ function setDiscordActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
function toggleDiscordRPC(enabled) {
|
||||
console.log('Toggling Discord RPC:', enabled);
|
||||
|
||||
if (enabled && !discordRPC) {
|
||||
console.log('Initializing Discord RPC...');
|
||||
initDiscordRPC();
|
||||
} else if (!enabled && discordRPC) {
|
||||
try {
|
||||
console.log('Disconnecting Discord RPC...');
|
||||
discordRPC.clearActivity();
|
||||
discordRPC.destroy();
|
||||
discordRPC = null;
|
||||
console.log('Discord RPC disconnected successfully');
|
||||
} catch (error) {
|
||||
console.error('Error disconnecting Discord RPC:', error.message);
|
||||
discordRPC = null; // Force null même en cas d'erreur
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createWindow() {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 1280,
|
||||
@@ -69,13 +97,19 @@ function createWindow() {
|
||||
preload: path.join(__dirname, 'preload.js'),
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
devTools: true,
|
||||
devTools: false,
|
||||
webSecurity: true
|
||||
}
|
||||
});
|
||||
|
||||
mainWindow.loadFile('GUI/index.html');
|
||||
|
||||
// Cleanup Discord RPC when window is closed
|
||||
mainWindow.on('closed', () => {
|
||||
console.log('Main window closed, cleaning up Discord RPC...');
|
||||
cleanupDiscordRPC();
|
||||
});
|
||||
|
||||
// Initialize Discord Rich Presence
|
||||
initDiscordRPC();
|
||||
|
||||
@@ -87,7 +121,6 @@ function createWindow() {
|
||||
}
|
||||
}, 3000);
|
||||
|
||||
|
||||
mainWindow.webContents.on('devtools-opened', () => {
|
||||
mainWindow.webContents.closeDevTools();
|
||||
});
|
||||
@@ -126,6 +159,24 @@ app.whenReady().then(async () => {
|
||||
console.log('Node.js version:', process.versions.node);
|
||||
console.log('Log directory:', logger.getLogDirectory());
|
||||
|
||||
try {
|
||||
const { loadGpuPreference, detectGpu } = require('./backend/launcher');
|
||||
const savedPreference = loadGpuPreference();
|
||||
if (savedPreference === 'auto') {
|
||||
global.detectedGpu = detectGpu(); // if 'auto' selected = preload GPU detection
|
||||
console.log('GPU auto-detection completed on startup:', global.detectedGpu);
|
||||
} else {
|
||||
console.log('GPU preference is manual, skipping auto-detection');
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Failed to preload GPU detection:', error.message);
|
||||
global.detectedGpu = { mode: 'integrated', vendor: 'intel' };
|
||||
}
|
||||
|
||||
|
||||
// Initialize Profile Manager (runs migration if needed)
|
||||
profileManager.init();
|
||||
|
||||
createWindow();
|
||||
|
||||
setTimeout(async () => {
|
||||
@@ -207,24 +258,42 @@ app.whenReady().then(async () => {
|
||||
}, 3000);
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
console.log('=== LAUNCHER CLOSING ===');
|
||||
|
||||
// Clean up Discord RPC connection
|
||||
function cleanupDiscordRPC() {
|
||||
if (discordRPC) {
|
||||
try {
|
||||
console.log('Cleaning up Discord RPC...');
|
||||
discordRPC.clearActivity();
|
||||
setTimeout(() => {
|
||||
try {
|
||||
discordRPC.destroy();
|
||||
} catch (error) {
|
||||
console.log('Error during final Discord RPC cleanup:', error.message);
|
||||
}
|
||||
}, 100);
|
||||
discordRPC = null;
|
||||
} catch (error) {
|
||||
console.log('Error cleaning up Discord RPC:', error.message);
|
||||
discordRPC = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
app.on('before-quit', () => {
|
||||
console.log('=== LAUNCHER BEFORE QUIT ===');
|
||||
cleanupDiscordRPC();
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
console.log('=== LAUNCHER CLOSING ===');
|
||||
|
||||
cleanupDiscordRPC();
|
||||
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('launch-game', async (event, playerName, javaPath, installPath) => {
|
||||
ipcMain.handle('launch-game', async (event, playerName, javaPath, installPath, gpuPreference) => {
|
||||
try {
|
||||
const progressCallback = (message, percent, speed, downloaded, total) => {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
@@ -239,7 +308,12 @@ ipcMain.handle('launch-game', async (event, playerName, javaPath, installPath) =
|
||||
}
|
||||
};
|
||||
|
||||
const result = await launchGameWithVersionCheck(playerName, progressCallback, javaPath, installPath);
|
||||
const result = await launchGameWithVersionCheck(playerName, progressCallback, javaPath, installPath, gpuPreference);
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error('Launch error:', error);
|
||||
const errorMessage = error.message || error.toString();
|
||||
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
setTimeout(() => {
|
||||
@@ -247,10 +321,6 @@ ipcMain.handle('launch-game', async (event, playerName, javaPath, installPath) =
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error('Launch error:', error);
|
||||
const errorMessage = error.message || error.toString();
|
||||
return { success: false, error: errorMessage };
|
||||
}
|
||||
});
|
||||
@@ -272,16 +342,11 @@ ipcMain.handle('install-game', async (event, playerName, javaPath, installPath)
|
||||
|
||||
const result = await installGame(playerName, progressCallback, javaPath, installPath);
|
||||
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
setTimeout(() => {
|
||||
mainWindow.webContents.send('progress-complete');
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error('Install error:', error);
|
||||
const errorMessage = error.message || error.toString();
|
||||
|
||||
return { success: false, error: errorMessage };
|
||||
}
|
||||
});
|
||||
@@ -301,6 +366,16 @@ ipcMain.handle('save-chat-username', async (event, chatUsername) => {
|
||||
ipcMain.handle('load-chat-username', async () => {
|
||||
return loadChatUsername();
|
||||
});
|
||||
|
||||
ipcMain.handle('save-chat-color', (event, color) => {
|
||||
saveChatColor(color);
|
||||
return { success: true };
|
||||
});
|
||||
|
||||
ipcMain.handle('load-chat-color', () => {
|
||||
return loadChatColor();
|
||||
});
|
||||
|
||||
ipcMain.handle('save-java-path', (event, javaPath) => {
|
||||
saveJavaPath(javaPath);
|
||||
return { success: true };
|
||||
@@ -320,6 +395,16 @@ ipcMain.handle('load-install-path', () => {
|
||||
return loadInstallPath();
|
||||
});
|
||||
|
||||
ipcMain.handle('save-discord-rpc', (event, enabled) => {
|
||||
saveDiscordRPC(enabled);
|
||||
toggleDiscordRPC(enabled);
|
||||
return { success: true };
|
||||
});
|
||||
|
||||
ipcMain.handle('load-discord-rpc', () => {
|
||||
return loadDiscordRPC();
|
||||
});
|
||||
|
||||
ipcMain.handle('select-install-path', async () => {
|
||||
const result = await dialog.showOpenDialog(mainWindow, {
|
||||
properties: ['openDirectory'],
|
||||
@@ -382,13 +467,35 @@ ipcMain.handle('is-game-installed', async () => {
|
||||
ipcMain.handle('uninstall-game', async () => {
|
||||
try {
|
||||
await uninstallGame();
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error('Uninstall error:', error);
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('repair-game', async () => {
|
||||
try {
|
||||
const progressCallback = (message, percent, speed, downloaded, total) => {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
const data = {
|
||||
message: message || null,
|
||||
percent: percent !== null && percent !== undefined ? Math.min(100, Math.max(0, percent)) : null,
|
||||
speed: speed !== null && speed !== undefined ? speed : null,
|
||||
downloaded: downloaded !== null && downloaded !== undefined ? downloaded : null,
|
||||
total: total !== null && total !== undefined ? total : null
|
||||
};
|
||||
mainWindow.webContents.send('progress-update', data);
|
||||
}
|
||||
};
|
||||
|
||||
const result = await repairGame(progressCallback);
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error('Repair error:', error);
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('get-hytale-news', async () => {
|
||||
try {
|
||||
const news = await getHytaleNews();
|
||||
@@ -503,7 +610,7 @@ ipcMain.handle('load-settings', async () => {
|
||||
}
|
||||
});
|
||||
|
||||
const { getModsPath, loadInstalledMods, downloadMod, uninstallMod, toggleMod } = require('./backend/launcher');
|
||||
const { getModsPath, loadInstalledMods, downloadMod, uninstallMod, toggleMod, getCurrentUuid, getAllUuidMappings, setUuidForUser, generateNewUuid, deleteUuidForUser, resetCurrentUserUuid } = require('./backend/launcher');
|
||||
const os = require('os');
|
||||
|
||||
ipcMain.handle('get-local-app-data', async () => {
|
||||
@@ -636,6 +743,35 @@ ipcMain.handle('get-update-info', async () => {
|
||||
return updateManager.getUpdateInfo();
|
||||
});
|
||||
|
||||
ipcMain.handle('get-gpu-info', () => {
|
||||
try {
|
||||
return app.getGPUInfo('complete');
|
||||
} catch (error) {
|
||||
console.error('Error getting GPU info:', error);
|
||||
return {};
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('save-gpu-preference', (event, gpuPreference) => {
|
||||
const { saveGpuPreference } = require('./backend/launcher');
|
||||
saveGpuPreference(gpuPreference);
|
||||
return { success: true };
|
||||
});
|
||||
|
||||
ipcMain.handle('load-gpu-preference', () => {
|
||||
const { loadGpuPreference } = require('./backend/launcher');
|
||||
return loadGpuPreference();
|
||||
});
|
||||
|
||||
ipcMain.handle('get-detected-gpu', () => {
|
||||
if (global.detectedGpu) {
|
||||
return global.detectedGpu;
|
||||
}
|
||||
const { detectGpu } = require('./backend/launcher');
|
||||
global.detectedGpu = detectGpu();
|
||||
return global.detectedGpu;
|
||||
});
|
||||
|
||||
ipcMain.handle('window-close', () => {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.close();
|
||||
@@ -652,12 +788,73 @@ ipcMain.handle('get-log-directory', () => {
|
||||
return logger.getLogDirectory();
|
||||
});
|
||||
|
||||
ipcMain.handle('get-current-uuid', async () => {
|
||||
try {
|
||||
return getCurrentUuid();
|
||||
} catch (error) {
|
||||
console.error('Error getting current UUID:', error);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('get-all-uuid-mappings', async () => {
|
||||
try {
|
||||
const mappings = getAllUuidMappings();
|
||||
return Object.entries(mappings).map(([username, uuid]) => ({
|
||||
username,
|
||||
uuid,
|
||||
isCurrent: username === require('./backend/launcher').loadUsername()
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('Error getting UUID mappings:', error);
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('set-uuid-for-user', async (event, username, uuid) => {
|
||||
try {
|
||||
await setUuidForUser(username, uuid);
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error('Error setting UUID for user:', error);
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('generate-new-uuid', async () => {
|
||||
try {
|
||||
return generateNewUuid();
|
||||
} catch (error) {
|
||||
console.error('Error generating new UUID:', error);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('delete-uuid-for-user', async (event, username) => {
|
||||
try {
|
||||
const result = deleteUuidForUser(username);
|
||||
return { success: result };
|
||||
} catch (error) {
|
||||
console.error('Error deleting UUID for user:', error);
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('reset-current-user-uuid', async () => {
|
||||
try {
|
||||
const newUuid = resetCurrentUserUuid();
|
||||
return { success: true, uuid: newUuid };
|
||||
} catch (error) {
|
||||
console.error('Error resetting current user UUID:', error);
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('get-recent-logs', async (event, maxLines = 100) => {
|
||||
try {
|
||||
const logDir = logger.getLogDirectory();
|
||||
if (!logDir) return null;
|
||||
|
||||
// Find the most recent log file
|
||||
const files = fs.readdirSync(logDir)
|
||||
.filter(file => file.startsWith('launcher-') && file.endsWith('.log'))
|
||||
.map(file => ({
|
||||
@@ -673,9 +870,73 @@ ipcMain.handle('get-recent-logs', async (event, maxLines = 100) => {
|
||||
const content = fs.readFileSync(latestLogFile, 'utf8');
|
||||
const lines = content.split('\n');
|
||||
|
||||
return lines.slice(-maxLines).join('\n');
|
||||
let result = lines.slice(-maxLines).join('\n');
|
||||
|
||||
if (lines.length > maxLines) {
|
||||
const truncatedMsg = `\n--- ⚠️ LOG TRUNCATED: Showing last ${maxLines} lines of ${lines.length}. Open Logs Folder for full history ---\n\n`;
|
||||
return result + truncatedMsg;
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error('Error reading logs:', error);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
ipcMain.handle('open-logs-folder', async () => {
|
||||
try {
|
||||
const logDir = logger.getLogDirectory();
|
||||
if (logDir && fs.existsSync(logDir)) {
|
||||
await shell.openPath(logDir);
|
||||
return { success: true };
|
||||
}
|
||||
return { success: false, error: 'Logs directory not found' };
|
||||
} catch (error) {
|
||||
console.error('Error opening logs folder:', error);
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
});
|
||||
|
||||
// Profile Management IPC
|
||||
ipcMain.handle('profile-create', async (event, name) => {
|
||||
try {
|
||||
return profileManager.createProfile(name);
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('profile-list', async () => {
|
||||
return profileManager.getProfiles();
|
||||
});
|
||||
|
||||
ipcMain.handle('profile-get-active', async () => {
|
||||
return profileManager.getActiveProfile();
|
||||
});
|
||||
|
||||
ipcMain.handle('profile-activate', async (event, id) => {
|
||||
try {
|
||||
return await profileManager.activateProfile(id);
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('profile-delete', async (event, id) => {
|
||||
try {
|
||||
return profileManager.deleteProfile(id);
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('profile-update', async (event, id, updates) => {
|
||||
try {
|
||||
return profileManager.updateProfile(id, updates);
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
}
|
||||
});
|
||||
|
||||
48
package-lock.json
generated
48
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "hytale-f2p-launcher",
|
||||
"version": "2.0.1",
|
||||
"name": "hytale-f2p-launcherv2",
|
||||
"version": "2.0.2b",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "hytale-f2p-launcher",
|
||||
"version": "2.0.1",
|
||||
"name": "hytale-f2p-launcherv2",
|
||||
"version": "2.0.2b",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"adm-zip": "^0.5.10",
|
||||
@@ -3459,15 +3459,17 @@
|
||||
}
|
||||
},
|
||||
"node_modules/mkdirp": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
|
||||
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
|
||||
"version": "0.5.6",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
|
||||
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"minimist": "^1.2.6"
|
||||
},
|
||||
"bin": {
|
||||
"mkdirp": "bin/cmd.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
@@ -4504,6 +4506,18 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/tar/node_modules/mkdirp": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
|
||||
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"mkdirp": "bin/cmd.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/temp": {
|
||||
"version": "0.9.4",
|
||||
"resolved": "https://registry.npmjs.org/temp/-/temp-0.9.4.tgz",
|
||||
@@ -4568,20 +4582,6 @@
|
||||
"node": ">= 10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/temp/node_modules/mkdirp": {
|
||||
"version": "0.5.6",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
|
||||
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"minimist": "^1.2.6"
|
||||
},
|
||||
"bin": {
|
||||
"mkdirp": "bin/cmd.js"
|
||||
}
|
||||
},
|
||||
"node_modules/tiny-async-pool": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/tiny-async-pool/-/tiny-async-pool-1.3.0.tgz",
|
||||
|
||||
68
package.json
68
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hytale-f2p-launcher",
|
||||
"version": "2.0.1",
|
||||
"name": "hytale-f2p-launcherv2",
|
||||
"version": "2.0.2b",
|
||||
"description": "A modern, cross-platform launcher for Hytale with automatic updates and multi-client support",
|
||||
"homepage": "https://github.com/amiayweb/Hytale-F2P",
|
||||
"main": "main.js",
|
||||
@@ -23,6 +23,17 @@
|
||||
"auto-update",
|
||||
"mod-manager",
|
||||
"chat"
|
||||
],
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Terromur",
|
||||
"url": "https://github.com/Terromur"
|
||||
},
|
||||
{
|
||||
"name": "Fari Gading",
|
||||
"email": "fazrigading@gmail.com",
|
||||
"url": "https://github.com/fazrigading"
|
||||
}
|
||||
],
|
||||
"author": {
|
||||
"name": "AMIAY",
|
||||
@@ -45,7 +56,8 @@
|
||||
},
|
||||
"build": {
|
||||
"appId": "com.hytalef2p.launcher",
|
||||
"productName": "Hytale F2P",
|
||||
"productName": "Hytale F2P Launcher",
|
||||
"executableName": "hytale-f2p-launcherv2",
|
||||
"directories": {
|
||||
"output": "dist"
|
||||
},
|
||||
@@ -58,54 +70,25 @@
|
||||
],
|
||||
"win": {
|
||||
"target": [
|
||||
{
|
||||
"target": "nsis",
|
||||
"arch": [
|
||||
"x64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"target": "portable",
|
||||
"arch": [
|
||||
"x64"
|
||||
]
|
||||
}
|
||||
{ "target": "nsis", "arch": ["x64", "arm64"] },
|
||||
{ "target": "portable", "arch": ["x64"] }
|
||||
],
|
||||
"icon": "icon.ico"
|
||||
},
|
||||
"linux": {
|
||||
"target": [
|
||||
{
|
||||
"target": "AppImage",
|
||||
"arch": [
|
||||
"x64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"target": "deb",
|
||||
"arch": [
|
||||
"x64"
|
||||
]
|
||||
}
|
||||
{ "target": "AppImage", "arch": ["x64", "arm64"] },
|
||||
{ "target": "deb", "arch": ["x64", "arm64"] },
|
||||
{ "target": "rpm", "arch": ["x64", "arm64"] },
|
||||
{ "target": "pacman", "arch": ["x64", "arm64"] }
|
||||
],
|
||||
"icon": "build/icon.png",
|
||||
"category": "Game",
|
||||
"description": "A modern, cross-platform launcher for Hytale with automatic updates and multi-client support"
|
||||
"category": "Game"
|
||||
},
|
||||
"mac": {
|
||||
"target": [
|
||||
{
|
||||
"target": "dmg",
|
||||
"arch": [
|
||||
"universal"
|
||||
]
|
||||
},
|
||||
{
|
||||
"target": "zip",
|
||||
"arch": [
|
||||
"universal"
|
||||
]
|
||||
}
|
||||
{ "target": "dmg", "arch": ["universal"] },
|
||||
{ "target": "zip", "arch": ["universal"] }
|
||||
],
|
||||
"icon": "build/icon.icns",
|
||||
"category": "public.app-category.games"
|
||||
@@ -118,6 +101,3 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
33
preload.js
33
preload.js
@@ -1,7 +1,7 @@
|
||||
const { contextBridge, ipcRenderer } = require('electron');
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
launchGame: (playerName, javaPath, installPath) => ipcRenderer.invoke('launch-game', playerName, javaPath, installPath),
|
||||
launchGame: (playerName, javaPath, installPath, gpuPreference) => ipcRenderer.invoke('launch-game', playerName, javaPath, installPath, gpuPreference),
|
||||
installGame: (playerName, javaPath, installPath) => ipcRenderer.invoke('install-game', playerName, javaPath, installPath),
|
||||
closeWindow: () => ipcRenderer.invoke('window-close'),
|
||||
minimizeWindow: () => ipcRenderer.invoke('window-minimize'),
|
||||
@@ -9,14 +9,19 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||
loadUsername: () => ipcRenderer.invoke('load-username'),
|
||||
saveChatUsername: (chatUsername) => ipcRenderer.invoke('save-chat-username', chatUsername),
|
||||
loadChatUsername: () => ipcRenderer.invoke('load-chat-username'),
|
||||
saveChatColor: (chatColor) => ipcRenderer.invoke('save-chat-color', chatColor),
|
||||
loadChatColor: () => ipcRenderer.invoke('load-chat-color'),
|
||||
saveJavaPath: (javaPath) => ipcRenderer.invoke('save-java-path', javaPath),
|
||||
loadJavaPath: () => ipcRenderer.invoke('load-java-path'),
|
||||
saveInstallPath: (installPath) => ipcRenderer.invoke('save-install-path', installPath),
|
||||
loadInstallPath: () => ipcRenderer.invoke('load-install-path'),
|
||||
saveDiscordRPC: (enabled) => ipcRenderer.invoke('save-discord-rpc', enabled),
|
||||
loadDiscordRPC: () => ipcRenderer.invoke('load-discord-rpc'),
|
||||
selectInstallPath: () => ipcRenderer.invoke('select-install-path'),
|
||||
browseJavaPath: () => ipcRenderer.invoke('browse-java-path'),
|
||||
isGameInstalled: () => ipcRenderer.invoke('is-game-installed'),
|
||||
uninstallGame: () => ipcRenderer.invoke('uninstall-game'),
|
||||
repairGame: () => ipcRenderer.invoke('repair-game'),
|
||||
getHytaleNews: () => ipcRenderer.invoke('get-hytale-news'),
|
||||
openExternal: (url) => ipcRenderer.invoke('open-external', url),
|
||||
openExternalLink: (url) => ipcRenderer.invoke('openExternalLink', url),
|
||||
@@ -45,6 +50,11 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||
ipcRenderer.on('show-update-popup', (event, data) => callback(data));
|
||||
},
|
||||
|
||||
getGpuInfo: () => ipcRenderer.invoke('get-gpu-info'),
|
||||
saveGpuPreference: (gpuPreference) => ipcRenderer.invoke('save-gpu-preference', gpuPreference),
|
||||
loadGpuPreference: () => ipcRenderer.invoke('load-gpu-preference'),
|
||||
getDetectedGpu: () => ipcRenderer.invoke('get-detected-gpu'),
|
||||
|
||||
acceptFirstLaunchUpdate: (existingGame) => ipcRenderer.invoke('accept-first-launch-update', existingGame),
|
||||
markAsLaunched: () => ipcRenderer.invoke('mark-as-launched'),
|
||||
onFirstLaunchUpdate: (callback) => {
|
||||
@@ -61,5 +71,24 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||
},
|
||||
|
||||
getLogDirectory: () => ipcRenderer.invoke('get-log-directory'),
|
||||
getRecentLogs: (maxLines) => ipcRenderer.invoke('get-recent-logs', maxLines)
|
||||
openLogsFolder: () => ipcRenderer.invoke('open-logs-folder'),
|
||||
getRecentLogs: (maxLines) => ipcRenderer.invoke('get-recent-logs', maxLines),
|
||||
|
||||
// UUID Management methods
|
||||
getCurrentUuid: () => ipcRenderer.invoke('get-current-uuid'),
|
||||
getAllUuidMappings: () => ipcRenderer.invoke('get-all-uuid-mappings'),
|
||||
setUuidForUser: (username, uuid) => ipcRenderer.invoke('set-uuid-for-user', username, uuid),
|
||||
generateNewUuid: () => ipcRenderer.invoke('generate-new-uuid'),
|
||||
deleteUuidForUser: (username) => ipcRenderer.invoke('delete-uuid-for-user', username),
|
||||
resetCurrentUserUuid: () => ipcRenderer.invoke('reset-current-user-uuid'),
|
||||
|
||||
// Profile API
|
||||
profile: {
|
||||
create: (name) => ipcRenderer.invoke('profile-create', name),
|
||||
list: () => ipcRenderer.invoke('profile-list'),
|
||||
getActive: () => ipcRenderer.invoke('profile-get-active'),
|
||||
activate: (id) => ipcRenderer.invoke('profile-activate', id),
|
||||
delete: (id) => ipcRenderer.invoke('profile-delete', id),
|
||||
update: (id, updates) => ipcRenderer.invoke('profile-update', id, updates)
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user