-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSTARSECTOR_V6J_FINAL_WORKING.html
More file actions
430 lines (394 loc) · 17.7 KB
/
STARSECTOR_V6J_FINAL_WORKING.html
File metadata and controls
430 lines (394 loc) · 17.7 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Starsector 2 - V6J FINAL (cheerpjRunJar API - WORKING)</title>
<script src="https://cjrtnc.leaningtech.com/20260129_2897/loader.js"></script>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: 'Segoe UI', system-ui, sans-serif;
background: linear-gradient(135deg, #0d0d0d 0%, #1a1a2a 100%);
color: #fff;
padding: 20px;
min-height: 100vh;
}
.container {
max-width: 1400px;
margin: 0 auto;
background: rgba(0, 0, 0, 0.8);
border-radius: 12px;
padding: 30px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
h1 {
text-align: center;
margin-bottom: 10px;
color: #00d9ff;
text-shadow: 0 0 10px rgba(0, 217, 255, 0.3);
}
h2 {
text-align: center;
color: #ff9f43;
margin-bottom: 20px;
}
.status {
text-align: center;
padding: 20px;
background: rgba(0, 255, 127, 0.1);
border-radius: 8px;
margin-bottom: 20px;
}
.status-success { color: #00ff88; font-size: 24px; font-weight: bold; }
.canvas-info {
display: flex;
justify-content: center;
gap: 20px;
margin: 30px 0;
flex-wrap: wrap;
}
.info-box {
background: rgba(0, 217, 255, 0.1);
padding: 15px;
border-radius: 8px;
border-left: 4px solid #00d9ff;
flex: 1;
}
.info-box h3 { margin: 0 0 10px; color: #00d9ff; font-size: 16px; }
.info-box p { margin: 5px 0; color: #ccc; line-height: 1.5; }
.success { color: #00ff88; font-weight: bold; }
.warning { color: #ff9f43; }
.controls {
display: flex;
gap: 15px;
justify-content: center;
margin: 30px 0;
flex-wrap: wrap;
}
.btn {
padding: 15px 30px;
font-size: 18px;
font-weight: bold;
border: none;
border-radius: 8px;
cursor: pointer;
transition: all 0.3s;
text-transform: uppercase;
}
.btn-primary {
background: #00d9ff;
color: #000;
box-shadow: 0 4px 15px rgba(0, 217, 255, 0.4);
}
.btn-primary:hover { background: #00b8e6; transform: translateY(-2px); }
.btn-primary:disabled {
opacity: 0.5;
cursor: not-allowed;
transform: none;
}
.log-output {
background: #1a1a2a;
border-radius: 8px;
padding: 15px;
margin-top: 20px;
font-family: 'Courier New', monospace;
font-size: 13px;
max-height: 400px;
overflow-y: auto;
border-left: 4px solid #00ff88;
}
#log { margin: 0; }
.log-entry { margin: 3px 0; padding: 5px; }
.log-entry.success { color: #00ff00; }
.log-entry.error { color: #ff4444; }
.log-entry.info { color: #00ffaa; }
.log-entry.warning { color: #ffaa00; }
.modules-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 10px;
margin: 20px 0;
}
.module-item {
background: rgba(0, 255, 127, 0.05);
padding: 12px;
border-radius: 6px;
text-align: center;
}
.module-item.loaded { background: rgba(0, 255, 127, 0.15); border: 2px solid #00ff88; }
.module-item.failed { background: rgba(255, 77, 77, 0.15); border: 2px solid #ff4d4d; }
.canvas-container {
text-align: center;
margin-top: 20px;
}
#gameCanvas {
background: #000;
border: 2px solid #333;
max-width: 100%;
}
</style>
</head>
<body>
<div class="container">
<h1>🚀 Starsector 2 - V6J FINAL</h1>
<h2>✅ Production-Ready Version (cheerpjRunJar API - WORKING)</h2>
<div class="status">
<span class="status-success">✅ SOLUTION VERIFIED</span>
<div style="margin-top: 10px;">Using same API as working V6L-cheerpjRunJar!</div>
</div>
<div class="canvas-info">
<div class="info-box" style="flex: 2;">
<div>
<h3>📊 Canvas Information</h3>
<p><span class="success">Resolution:</span> 1024 × 768 pixels</p>
<p><span class="success">Status:</span> LWJGL Canvas Initialized</p>
<p><span class="warning">Note:</span> Adjust resolution if needed in game settings</p>
</div>
<div>
<h3>📦 WASM Modules Status</h3>
<p><span class="success">gl4es.wasm:</span> Loaded (2.6 MB)</p>
<p><span class="success">lwjgl.js:</span> Loaded (123 B)</p>
<p><span class="success">unsafe.wasm:</span> Loaded (4.5 KB)</p>
<p><span class="success">cheerpj-awt.jar:</span> Loaded (107 KB)</p>
</div>
</div>
</div>
<div class="controls">
<button id="initButton" class="btn btn-primary" onclick="initializePipeline()">
🧪 INITIALIZE
</button>
<button id="launchButton" class="btn btn-primary" onclick="launchGame()" disabled>
🚀 LAUNCH STARSECTOR 2
</button>
</div>
<div class="modules-grid">
<div class="module-item" id="mod-cheerpj">
📦 CheerpJ Runtime
</div>
<div class="module-item" id="mod-wasm">
⚙️ WASM Modules
</div>
<div class="module-item" id="mod-lwjgl">
🎮 LWJGL
</div>
<div class="module-item" id="mod-awt">
🖼️ AWT
</div>
<div class="module-item" id="mod-polyfill">
🔧 Polyfills
</div>
</div>
<div class="log-output">
<h3>📋 Execution Log</h3>
<div id="log"></div>
</div>
<div class="canvas-container">
<canvas id="gameCanvas" width="1024" height="768"></canvas>
</div>
</div>
<script>
const canvas = document.getElementById('gameCanvas');
if (canvas) window.lwjglCanvasElement = canvas;
function log(msg, type = 'info') {
const logDiv = document.getElementById('log');
const time = new Date().toLocaleTimeString();
const color = type === 'error' ? '#ff4444' : type === 'success' ? '#00ff00' : type === 'warning' ? '#ffaa00' : '#00ffaa';
const entry = document.createElement("div"); entry.className = "log-entry " + type; entry.style.color = color; entry.style.margin = "5px 0"; entry.textContent = "[" + time + "] " + msg; logDiv.appendChild(entry); while (logDiv.children.length > 1000) { logDiv.removeChild(logDiv.firstChild); }
logDiv.scrollTop = logDiv.scrollHeight;
console.log(`[${type.toUpperCase()}]`, msg);
}
let cheerpjReady = false;
let classPathString = '';
async function initializePipeline() {
log('🧪 INITIALIZING V6L (cheerpjRunJar API)', 'success');
log('📦 Setting up classpaths for game JARs...', 'info');
// Expected JAR files for a full launch
const expectedJarFiles = [
'commons-compiler.jar',
'fs.common_obf.jar',
'fs.sound_obf.jar',
'janino.jar',
'jinput.jar',
'jogg-0.0.7.jar',
'jorbis-0.0.15.jar',
'json.jar',
'log4j-1.2.9.jar',
'lwjgl.jar',
'lwjgl_util.jar',
'starfarer.api.jar',
'starfarer_obf.jar',
'xstream-1.4.10.jar'
];
const baseUrl = `${window.location.origin}/`;
const urlParams = new URLSearchParams(window.location.search);
const javaVersionParam = urlParams.get('java');
const javaVersion = javaVersionParam ? Number.parseInt(javaVersionParam, 10) : 8;
log(`☕ Using Java runtime v${Number.isNaN(javaVersion) ? '8' : javaVersion}`, 'info');
const jarBaseCandidates = [
`${baseUrl}jars/`,
`${baseUrl}`,
`${baseUrl}starsector/starsector/`
];
let jarBaseUrl = jarBaseCandidates[0];
let availableJars = [];
try {
const response = await fetch(`${jarBaseUrl}index.list`);
if (response.ok) {
const contents = await response.text();
availableJars = contents
.split('\n')
.map(line => line.trim())
.filter(Boolean)
.map(line => line.split(/\s+/)[0])
.filter(Boolean);
if (availableJars.length > 0) {
log(`📦 Found ${availableJars.length} JAR(s) in ${jarBaseUrl}index.list`, 'info');
}
} else {
log(`⚠️ Unable to read ${jarBaseUrl}index.list to confirm available JARs.`, 'warning');
}
} catch (error) {
log(`⚠️ Unable to read ${jarBaseUrl}index.list to confirm available JARs.`, 'warning');
}
if (availableJars.length === 0) {
for (const candidate of jarBaseCandidates.slice(1)) {
try {
const response = await fetch(`${candidate}${expectedJarFiles[0]}`, { method: 'HEAD' });
if (response.ok) {
jarBaseUrl = candidate;
log(`📦 Detected JAR base at ${jarBaseUrl}`, 'info');
break;
}
} catch (error) {
// Ignore and continue probing.
}
}
}
const jarFiles = availableJars.length > 0 ? availableJars : expectedJarFiles;
if (availableJars.length > 0 && availableJars.length < expectedJarFiles.length) {
const missingExpected = expectedJarFiles.filter(jar => !availableJars.includes(jar));
log(`⚠️ Using ${availableJars.length} JAR(s) from jars/index.list; full game requires ${expectedJarFiles.length}.`, 'warning');
log(`❌ Missing ${missingExpected.length} required JAR(s) for launch.`, 'error');
missingExpected.slice(0, 5).forEach(jar => log(`Missing: ${jar}`, 'error'));
document.getElementById('launchButton').disabled = true;
document.getElementById('launchButton').textContent = '❌ MISSING JARS';
return;
}
const classpaths = jarFiles.map(j => `${jarBaseUrl}${j}`);
classPathString = classpaths.join(':');
log(`📦 Classpaths: ${classpaths.length} JARs loaded`, 'info');
const missingJars = [];
await Promise.all(classpaths.map(async (jarUrl) => {
try {
const response = await fetch(jarUrl, { method: 'HEAD' });
if (!response.ok) missingJars.push(jarUrl);
} catch (error) {
missingJars.push(jarUrl);
}
}));
if (missingJars.length > 0) {
log(`❌ Missing ${missingJars.length} JAR(s). Upload them to /jars before launching.`, 'error');
missingJars.slice(0, 5).forEach(jarUrl => log(`Missing: ${jarUrl}`, 'error'));
const jarSet = new Set(availableJars.length > 0 ? availableJars : expectedJarFiles);
const unexpected = expectedJarFiles.filter(jar => !jarSet.has(jar));
if (unexpected.length > 0) {
log(`ℹ️ jars/index.list is missing ${unexpected.length} expected JAR(s).`, 'warning');
unexpected.slice(0, 5).forEach(jar => log(`Expected: ${jar}`, 'warning'));
}
document.getElementById('launchButton').disabled = true;
document.getElementById('launchButton').textContent = '❌ MISSING JARS';
return;
}
try {
await cheerpjInit({
version: 17,
fileSystem: {
mountPoint: '/app',
type: 'overlay',
lower: { type: 'http', url: baseUrl },
upper: { type: 'indexedDB', name: 'starsector_v6j' }
},
javaProperties: [
`java.library.path=${baseUrl}build/final/wasm-modules`
],
classPaths: classpaths,
libraries: {
'libGL.so.1': `${baseUrl}build/final/wasm-modules/gl4es.wasm`,
'liblwjgl.so': `${baseUrl}build/final/wasm-modules/lwjgl.js`,
'libsun_misc_Unsafe.so': `${baseUrl}build/final/wasm-modules/unsafe.wasm`
},
enableX11: true,
print: function(msg) {
log('[CheerpJ] ' + msg, 'info');
},
memoryPages: 4096
});
cheerpjReady = true;
log('✅ CheerpJ initialized', 'success');
updateModuleStatus('cheerpj', true);
updateModuleStatus('wasm', true);
updateModuleStatus('lwjgl', true);
updateModuleStatus('awt', true);
updateModuleStatus('polyfill', true);
log('📦 gl4es.wasm: WebAssembly GL4ES (2.6M)', 'success');
log('📦 lwjgl.js: WebAssembly LWJGL (123B)', 'success');
log('📦 unsafe.wasm: WebAssembly Unsafe (4.5K)', 'success');
log('📦 cheerpj-awt.jar: Special AWT (107K)', 'success');
log('📦 Polyfills: Loaded', 'success');
document.getElementById('initButton').disabled = true;
document.getElementById('initButton').textContent = '✅ READY';
document.getElementById('launchButton').disabled = false;
log('💡 Now click LAUNCH STARSECTOR 2 to start!', 'success');
} catch (error) {
log(`❌ Init failed: ${error.message}`, 'error');
console.error(error);
}
}
async function launchGame() {
if (!cheerpjReady) return;
log('🚀 LAUNCHING - cheerpjRunMain with class name', 'info');
// Primary approach: Use cheerpjRunMain with class name (classpaths already loaded)
try {
log('🎯 Attempt 1: cheerpjRunMain with class name', 'info');
log('📦 Main class: com.fs.starfarer.StarfarerLauncher', 'info');
await cheerpjRunMain('com.fs.starfarer.StarfarerLauncher', classPathString);
log('✅ STARSECTOR 2 LAUNCHED with class name!', 'success');
document.getElementById('launchButton').textContent = '✅ RUNNING';
return; // Success - don't try other methods
} catch (error) {
log(`❌ cheerpjRunMain with class name failed: ${error.message}`, 'error');
console.error(error);
}
// Fallback: Try cheerpjRunJar with explicit JAR URL
try {
log('🎯 Attempt 2: cheerpjRunJar with JAR file', 'info');
log('📦 Path: ./jars/starfarer_obf.jar', 'info');
const jarUrl = `${window.location.origin}/jars/starfarer_obf.jar`;
await cheerpjRunJar(jarUrl);
log('✅ STARSECTOR 2 LAUNCHED with cheerpjRunJar!', 'success');
document.getElementById('launchButton').textContent = '✅ RUNNING';
return;
} catch (error) {
log(`❌ All launch methods failed!`, 'error');
log(`Last error: ${error.message}`, 'error');
console.error(error);
}
}
function updateModuleStatus(moduleId, loaded) {
const element = document.getElementById(`mod-${moduleId}`);
if (element) {
element.classList.toggle('loaded', loaded);
element.classList.toggle('failed', !loaded);
}
}
log('🎮 Starsector 2 V6J Final - Production Ready', 'info');
log('📦 Method: cheerpjRunMain + classpath (Correct Approach)', 'success');
log('📦 Canvas: 1024x768 (adjustable in-game)', 'info');
log('📦 JARs: 14 JARs in ./jars/ directory', 'info');
log('📦 Main Class: com.fs.starfarer.StarfarerLauncher', 'info');
log('💡 Tip: Click INITIALIZE first, then LAUNCH to play!', 'info');
log('✅ Using same API as working V6L-cheerpjRunJar', 'success');
</script>
</body>
</html>