-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlaunch_v88.html
More file actions
149 lines (128 loc) Β· 6.8 KB
/
launch_v88.html
File metadata and controls
149 lines (128 loc) Β· 6.8 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
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<title>Starsector 2 - Definitive WebLauncher (v88)</title>
<script src='https://cjrtnc.leaningtech.com/4.2/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: 300px; 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>
<div class="container">
<h1>π Starsector 2 Web (v88 - SMART PATCH FIXED)</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 {
const origin = 'https://adybag14-cyber.github.io/';
const projectUrl = origin + 'starsectorquick/';
await cheerpjInit({
version: 17,
enableX11: true,
javaProperties: [
`java.library.path=/app/starsectorquick/build/final/wasm-modules/`,
`user.dir=/files/`,
`com.fs.starfarer.settings.linux=true`,
`org.lwjgl.opengl.Display.allowSoftwareOpenGL=true`,
`com.fs.starfarer.settings.paths.logs=/files/`
],
libraries: {
'libGL.so.1': `/app/starsectorquick/build/final/wasm-modules/gl4es.wasm`,
'liblwjgl.so': `/app/starsectorquick/build/final/wasm-modules/lwjgl.js`,
'liblwjgl64.so': `/app/starsectorquick/build/final/wasm-modules/lwjgl.js`,
'libsun_misc_Unsafe.so': `/app/starsectorquick/build/final/wasm-modules/unsafe.wasm`
},
mounts: [
{ type: 'http', path: '/app/', url: origin }
]
});
log('Fetching and patching settings.json...', '#ff9f43');
const fetchText = async (path) => {
const r = await fetch(projectUrl + path);
if (!r.ok) throw new Error(`Failed to fetch ${path}: ${r.status}`);
return await r.text();
};
let text = await fetchText('starsector/starsector/data/config/settings.json');
const log4jProps = await fetchText('starsector/starsector/log4j.properties');
const patchKeys = [
{ key: 'autosaveEnabledByDefault', val: 'true' },
{ key: 'autosaveFeatureEnabled', val: 'true' },
{ key: 'requireTypingDeleteToDeleteSave', val: 'true' }
];
let patchedText = text.trim();
const lastBrace = patchedText.lastIndexOf('}');
if (lastBrace !== -1) {
let pre = patchedText.substring(0, lastBrace).trim();
if (!pre.endsWith(',')) pre += ',';
let additions = [];
for (const p of patchKeys) {
if (text.indexOf('"' + p.key + '"') === -1) {
additions.push('"' + p.key + '": ' + p.val);
log('Patching missing key: ' + p.key);
}
}
if (additions.length > 0) {
patchedText = pre + '\n // --- WEB PATCH ---\n ' + additions.join(',\n ') + '\n}';
log('Settings patched successfully.');
} else {
log('No patching needed.');
}
}
log('Mounting Display to Canvas...', '#00ff88');
cheerpjCreateDisplay(1024, 768, document.getElementById('game-container'));
const jarFiles = [
'stubs.jar',
'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 => '/app/starsectorquick/jars/' + j).concat(['/files/']).join(':');
log('Final ClassPath: ' + cp);
log('Starting Definitive Main...', '#ff9f43');
btn.textContent = 'π RUNNING';
await cheerpjRunMain('WebLauncher', cp, '/files', patchedText, log4jProps);
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>