Add Java path configuration and input handling

- Introduced a new input field for Java path in the launcher UI.
- Updated the main process to handle saving and loading of the Java path.
- Enhanced game launch functionality to accept a Java path parameter.
- Added Java detection logic to find the Java executable on the system.
- Created a .gitignore file to exclude build artifacts and dependencies.
This commit is contained in:
chasem-dev
2026-01-14 10:11:01 -05:00
parent b90eeb344b
commit 6873e2e4bf
6 changed files with 458 additions and 123 deletions

View File

@@ -242,19 +242,31 @@
<p class="font-mono text-sm text-gray-400 tracking-widest">F2P LAUNCHER</p>
</div>
<div class="w-80">
<label class="block font-mono text-xs text-gray-400 mb-2 uppercase tracking-wider">
Player Name
</label>
<input
type="text"
<div class="w-80">
<label class="block font-mono text-xs text-gray-400 mb-2 uppercase tracking-wider">
Player Name
</label>
<input
type="text"
id="playerName"
value="Player"
class="input-field w-full rounded-lg px-4 py-3 text-white font-mono text-base focus:outline-none"
placeholder="Enter your name"
>
</div>
placeholder="Enter your name"
>
</div>
<div class="w-[28rem]">
<label class="block font-mono text-xs text-gray-400 mb-2 uppercase tracking-wider">
Java Path (optional)
</label>
<input
type="text"
id="javaPath"
class="input-field w-full rounded-lg px-4 py-3 text-white font-mono text-sm focus:outline-none"
placeholder="/Library/Java/JavaVirtualMachines/.../bin/java"
>
</div>
<button
id="playBtn"
onclick="launch()"
@@ -307,25 +319,32 @@
let isDownloading = false;
const playBtn = document.getElementById('playBtn');
const playText = document.getElementById('playText');
const playerNameInput = document.getElementById('playerName');
const progressText = document.getElementById('progressText');
const progressPercent = document.getElementById('progressPercent');
const progressSpeed = document.getElementById('progressSpeed');
const progressSize = document.getElementById('progressSize');
const progressBar = document.getElementById('progressBar');
const loadingScreen = document.getElementById('loadingScreen');
async function init() {
try {
const savedUsername = await window.electronAPI.loadUsername();
if (savedUsername) {
playerNameInput.value = savedUsername;
username = savedUsername;
}
} catch (error) {
console.error('Failed to load username:', error);
} finally {
const playText = document.getElementById('playText');
const playerNameInput = document.getElementById('playerName');
const javaPathInput = document.getElementById('javaPath');
const progressText = document.getElementById('progressText');
const progressPercent = document.getElementById('progressPercent');
const progressSpeed = document.getElementById('progressSpeed');
const progressSize = document.getElementById('progressSize');
const progressBar = document.getElementById('progressBar');
const loadingScreen = document.getElementById('loadingScreen');
async function init() {
try {
const [savedUsername, javaPath] = await Promise.all([
window.electronAPI.loadUsername(),
window.electronAPI.loadJavaPath()
]);
if (savedUsername) {
playerNameInput.value = savedUsername;
username = savedUsername;
}
if (typeof javaPath === 'string') {
javaPathInput.value = javaPath;
}
} catch (error) {
console.error('Failed to load username:', error);
} finally {
setTimeout(() => {
loadingScreen.style.opacity = '0';
loadingScreen.style.transition = 'opacity 0.5s ease';
@@ -367,29 +386,34 @@
updateProgress(data);
});
playerNameInput.addEventListener('input', async () => {
const playerName = playerNameInput.value.trim();
if (playerName) {
await window.electronAPI.saveUsername(playerName);
}
});
async function launch() {
const playerName = playerNameInput.value.trim() || 'Player';
await window.electronAPI.saveUsername(playerName);
if (isDownloading || playBtn.disabled) return;
playerNameInput.addEventListener('input', async () => {
const playerName = playerNameInput.value.trim();
if (playerName) {
await window.electronAPI.saveUsername(playerName);
}
});
javaPathInput.addEventListener('input', async () => {
await window.electronAPI.saveJavaPath(javaPathInput.value.trim());
});
async function launch() {
const playerName = playerNameInput.value.trim() || 'Player';
const javaPath = javaPathInput.value.trim();
await window.electronAPI.saveUsername(playerName);
if (isDownloading || playBtn.disabled) return;
isDownloading = true;
playBtn.disabled = true;
playText.textContent = 'PROCESSING...';
try {
const result = await window.electronAPI.launchGame(playerName);
if (result.success) {
progressText.textContent = 'Game started!';
const result = await window.electronAPI.launchGame(playerName, javaPath);
if (result.success) {
progressText.textContent = 'Game started!';
setTimeout(() => {
window.electronAPI.closeWindow();
}, 2000);