feat(web): add 2006Scape TeaVM WebGL2 client with mobile support and classic 2006 UI
Initializes the TeaVM-based 2006Scape-Web client repository with WebGL2 117HD rendering, WebSocket networking, SpessaSynth MIDI/PCM audio, and mobile-compatible touch/viewport controls. Preserves Revision 377 cache preloading via IndexedDB and localStorage-backed script and config persistence. ### Core Web Runtime & Rendering - WebLauncher & DesktopHooks: - Added TeaVM entry point with URL/localStorage option parsing, async 377 cache preloading, and WebSocket port routing. - Implemented DesktopHooks.boxReflectValue using JSWrapper.isJava/maybeUnwrap to box TeaVM reflection primitives, plus localStorage persistence for plugin settings and imported scripts. - WebHd117Renderer & RSImageProducer: - Implemented WebGL2 117HD rendering with 4x4 chunked static scenery VBOs and 0x010203 transparency sentinel so 0x000000 black UI elements stay opaque. - WebReflectionSupplier: - Exposed PluginContext, PluginGraphics, ScriptInterpreter, ID lists, and Math/System/String/collection methods for TeaVM runtime reflection. ### Mobile & Classic 2006 Web UI - index.html & RSApplet: - Styled the page to match the classic 2006 RuneScape webclient with optional classic navbar (auto-hidden below 765px), 1999-2006 Jagex footer, and responsive Fixed/Resizable/Fullscreen scaling. - Added Options modal (auto-login, server, world, 117HD, display mode, navbar) with scrollable body in mobile landscape. - Implemented Android-parity touch controls (tap, 450ms long-press right-click, 1-finger camera drag, 2-finger pinch zoom clamped to -1..8, and auto-keyboard on input fields).
This commit is contained in:
commit
3331ab745b
25 files changed
+4795
No files matched your search
@@ -0,0 +1,145 @@
|
||||
package org.scape2006.web;
|
||||
|
||||
import org.scape2006.web.net.Socket;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* Browser-safe RSSocket backed by WebSocketAdapter.
|
||||
*/
|
||||
final class RSSocket implements Runnable {
|
||||
|
||||
private final InputStream inputStream;
|
||||
private final OutputStream outputStream;
|
||||
private final Socket socket;
|
||||
private boolean closed;
|
||||
private final RSApplet rsApplet;
|
||||
private byte[] buffer;
|
||||
private int writeIndex;
|
||||
private int buffIndex;
|
||||
private boolean isWriter;
|
||||
private boolean hasIOError;
|
||||
|
||||
public RSSocket(RSApplet applet, Socket socket) throws IOException {
|
||||
this.closed = false;
|
||||
this.isWriter = false;
|
||||
this.hasIOError = false;
|
||||
this.rsApplet = applet;
|
||||
this.socket = socket;
|
||||
this.socket.setSoTimeout(30000);
|
||||
this.socket.setTcpNoDelay(true);
|
||||
this.inputStream = socket.getInputStream();
|
||||
this.outputStream = socket.getOutputStream();
|
||||
}
|
||||
|
||||
public void close() {
|
||||
closed = true;
|
||||
try {
|
||||
if (inputStream != null) inputStream.close();
|
||||
if (outputStream != null) outputStream.close();
|
||||
if (socket != null) socket.close();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
isWriter = false;
|
||||
synchronized (this) {
|
||||
notifyAll();
|
||||
}
|
||||
buffer = null;
|
||||
}
|
||||
|
||||
public int read() throws IOException {
|
||||
if (closed) return 0;
|
||||
return inputStream.read();
|
||||
}
|
||||
|
||||
public int available() throws IOException {
|
||||
if (closed) return 0;
|
||||
return inputStream.available();
|
||||
}
|
||||
|
||||
public void flushInputStream(byte[] dst, int len) throws IOException {
|
||||
int off = 0;
|
||||
if (closed) return;
|
||||
while (len > 0) {
|
||||
int n = inputStream.read(dst, off, len);
|
||||
if (n <= 0) {
|
||||
throw new IOException("EOF");
|
||||
}
|
||||
off += n;
|
||||
len -= n;
|
||||
}
|
||||
}
|
||||
|
||||
public void queueBytes(int len, byte[] src) throws IOException {
|
||||
if (closed) return;
|
||||
if (hasIOError) {
|
||||
hasIOError = false;
|
||||
throw new IOException("Error in writer thread");
|
||||
}
|
||||
if (buffer == null) {
|
||||
buffer = new byte[5000];
|
||||
}
|
||||
synchronized (this) {
|
||||
for (int i = 0; i < len; i++) {
|
||||
buffer[buffIndex] = src[i];
|
||||
buffIndex = (buffIndex + 1) % 5000;
|
||||
if (buffIndex == (writeIndex + 4900) % 5000) {
|
||||
throw new IOException("buffer overflow");
|
||||
}
|
||||
}
|
||||
if (!isWriter) {
|
||||
isWriter = true;
|
||||
rsApplet.startRunnable(this, 3);
|
||||
}
|
||||
notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (isWriter) {
|
||||
int count;
|
||||
int offset;
|
||||
synchronized (this) {
|
||||
if (buffIndex == writeIndex) {
|
||||
try {
|
||||
wait();
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
if (!isWriter) return;
|
||||
offset = writeIndex;
|
||||
count = (buffIndex >= writeIndex) ? (buffIndex - writeIndex) : (5000 - writeIndex);
|
||||
}
|
||||
if (count > 0) {
|
||||
try {
|
||||
outputStream.write(buffer, offset, count);
|
||||
} catch (IOException ex) {
|
||||
hasIOError = true;
|
||||
}
|
||||
writeIndex = (writeIndex + count) % 5000;
|
||||
try {
|
||||
if (buffIndex == writeIndex) {
|
||||
outputStream.flush();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
hasIOError = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void printDebug() {
|
||||
System.out.println("dummy:" + closed);
|
||||
System.out.println("tcycl:" + writeIndex);
|
||||
System.out.println("tnum:" + buffIndex);
|
||||
System.out.println("writer:" + isWriter);
|
||||
System.out.println("ioerror:" + hasIOError);
|
||||
try {
|
||||
System.out.println("available:" + available());
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user