-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
118 lines (103 loc) · 5.36 KB
/
index.html
File metadata and controls
118 lines (103 loc) · 5.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<title>Starsector 2 - GitHub Pages Deployment</title>
<script src='https://cjrtnc.leaningtech.com/20260129_2897/loader.js'></script>
<style>
body { background: #000; color: #fff; font-family: 'Segoe UI', sans-serif; text-align: center; }
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }
#game-container { margin: 20px auto; width: 1024px; height: 768px; border: 2px solid #00d9ff; position: relative; background: #111; }
#log { background: #111; padding: 15px; height: 250px; overflow-y: auto; text-align: left; font-family: monospace; font-size: 12px; border-left: 4px solid #00ff88; margin-top: 20px; }
.btn { padding: 15px 30px; font-size: 18px; font-weight: bold; border: none; border-radius: 8px; cursor: pointer; background: #00d9ff; color: #000; text-transform: uppercase; transition: 0.3s; }
.btn:hover { background: #00b8e6; transform: translateY(-2px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
</style>
</head>
<body>
<script>
// Keep the GH Pages root URL on the maintained launcher implementation.
window.location.replace(new URL('./launch.html', window.location.href).toString());
</script>
<noscript>
<p>JavaScript is required. Open <a href="./launch.html">launch.html</a>.</p>
</noscript>
<div class="container">
<h1>🚀 Starsector 2 Web (v45)</h1>
<p>Running Java via CheerpJ & WebAssembly on GitHub Pages</p>
<div style="margin: 20px 0;">
<button id='startBtn' class="btn">🚀 LAUNCH STARSECTOR</button>
</div>
<div id='game-container'></div>
<div id='log'>
<div style="color: #888;">[SYSTEM] Waiting for initialization...</div>
</div>
</div>
<script>
function log(m, color = '#fff') {
const l = document.getElementById('log');
if (l) {
const entry = document.createElement('div');
entry.style.color = color;
entry.textContent = `[${new Date().toLocaleTimeString()}] ${m}`;
l.appendChild(entry);
l.scrollTop = l.scrollHeight;
}
console.log(m);
}
document.getElementById('startBtn').addEventListener('click', async () => {
const btn = document.getElementById('startBtn');
btn.disabled = true;
btn.textContent = '⌛ INITIALIZING...';
log('Initializing CheerpJ 4.2 Runtime (Java 17)...', '#00d9ff');
try {
// Use repo-relative base so GitHub Pages subpath deployments resolve correctly.
const prefix = new URL('./', window.location.href).href;
await cheerpjInit({
version: 17,
enableX11: true,
javaProperties: [
`-Djava.library.path=${prefix}build/final/wasm-modules/`,
`-Duser.dir=${prefix}starsector/starsector`,
`-Dcom.fs.starfarer.settings.linux=true`,
`-Dorg.lwjgl.opengl.Display.allowSoftwareOpenGL=true`,
`-Dcom.fs.starfarer.settings.paths.logs=${prefix}starsector/starsector/`
],
libraries: {
'libGL.so.1': `${prefix}build/final/wasm-modules/gl4es.wasm`,
'liblwjgl.so': `${prefix}build/final/wasm-modules/lwjgl.js`,
'liblwjgl64.so': `${prefix}build/final/wasm-modules/lwjgl.js`,
'libsun_misc_Unsafe.so': `${prefix}build/final/wasm-modules/unsafe.wasm`
}
});
log('Mounting Display to Canvas...', '#00ff88');
cheerpjCreateDisplay(1024, 768, document.getElementById('game-container'));
const jarFiles = [
'resources.jar',
'janino.jar', 'commons-compiler.jar', 'starfarer.api.jar',
'starfarer_obf.jar', 'jogg-0.0.7.jar', 'jorbis-0.0.15.jar',
'json.jar', 'lwjgl.jar', 'jinput.jar', 'log4j-1.2.9.jar',
'lwjgl_util.jar', 'fs.sound_obf.jar', 'fs.common_obf.jar',
'xstream-1.4.10.jar'
];
const cp = jarFiles.map(j => prefix + 'jars/' + j).concat([
prefix,
prefix + 'starsector/starsector/',
prefix + 'starsector/starsector/data/config/'
]).join(':');
log('Final ClassPath: ' + cp);
log('Starting Main Class: com.fs.starfarer.StarfarerLauncher', '#ff9f43');
btn.textContent = '🚀 RUNNING';
await cheerpjRunMain('com.fs.starfarer.StarfarerLauncher', cp, '-nosound');
log('Execution loop started. Watch for Java output.', '#00ff88');
} catch (e) {
log(`CRITICAL ERROR: ${e ? e.message : 'Unknown'}`, '#ff4444');
console.error(e);
btn.disabled = false;
btn.textContent = '❌ RETRY LAUNCH';
}
});
log('Welcome to Starsector Web Edition. System ready.');
</script>
</body>
</html>