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:
Dark98 committed 2026-11-30 20:45:03 +00:00
commit 3331ab745b
25 files changed
+4795

No files matched your search

@@ -0,0 +1,101 @@
package org.scape2006.web;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSByRef;
import org.teavm.jso.canvas.CanvasRenderingContext2D;
import org.teavm.jso.canvas.ImageData;
import org.teavm.jso.dom.html.HTMLCanvasElement;
import org.teavm.jso.dom.html.HTMLDocument;
/**
* Web RSImageProducer backed by HTML5 Canvas 2D ImageData.
*/
public final class RSImageProducer {
public static final int GAME_WIDTH = 765;
public static final int GAME_HEIGHT = 503;
public static final int[] masterScreenBuffer = new int[GAME_WIDTH * GAME_HEIGHT];
public static final Object masterBufferLock = new Object();
public final int[] anIntArray315;
public final int anInt316; // width
public final int anInt317; // height
private static HTMLCanvasElement canvas;
private static CanvasRenderingContext2D ctx2d;
private ImageData imageData;
public RSImageProducer(int width, int height, Object component) {
this.anInt316 = width;
this.anInt317 = height;
this.anIntArray315 = new int[width * height];
ensureCanvas();
if (ctx2d != null) {
this.imageData = ctx2d.createImageData(width, height);
}
initDrawingArea();
}
public static HTMLCanvasElement getCanvas() {
ensureCanvas();
return canvas;
}
private static void ensureCanvas() {
if (canvas == null) {
HTMLDocument doc = HTMLDocument.current();
canvas = (HTMLCanvasElement) doc.getElementById("game-canvas");
if (canvas != null) {
ctx2d = (CanvasRenderingContext2D) canvas.getContext("2d");
}
}
}
public void initDrawingArea() {
DrawingArea.initDrawingArea(anInt317, anInt316, anIntArray315);
Texture.textureInt1 = anInt316 / 2;
if (ClientSettings.RESIZABLE && anInt316 < anInt317) {
Texture.textureInt2 = (int) (anInt317 * 0.38f);
} else {
Texture.textureInt2 = anInt317 / 2;
}
}
public void drawGraphics(int y, Object graphics, int x) {
if (anIntArray315 == null) return;
if (ClientSettings.isDesktopModern() && !ModernLayout.inGame) {
DesktopHooks.drawScaledLoginTile(graphics, anIntArray315, x, y, anInt316, anInt317);
return;
}
ensureCanvas();
if (ctx2d == null) return;
if (imageData == null || imageData.getWidth() != anInt316 || imageData.getHeight() != anInt317) {
imageData = ctx2d.createImageData(anInt316, anInt317);
}
boolean gpuViewport = HD117Pipeline.isGpuActive() && anInt316 == ClientSettings.VIEWPORT_WIDTH && anInt317 == ClientSettings.VIEWPORT_HEIGHT;
if (gpuViewport) {
blitOverlayPixelsToImageData(anIntArray315, imageData);
} else {
blitPixelsToImageData(anIntArray315, imageData);
}
ctx2d.putImageData(imageData, x, y);
}
@JSBody(params = {"pixels", "imgData"}, script =
"var dst = new Uint32Array(imgData.data.buffer);\n" +
"var len = pixels.length;\n" +
"for (var i = 0; i < len; i++) {\n" +
" var c = pixels[i];\n" +
" dst[i] = -16777216 | ((c & 255) << 16) | (c & 65280) | ((c >> 16) & 255);\n" +
"}")
private static native void blitPixelsToImageData(@JSByRef int[] pixels, ImageData imgData);
@JSBody(params = {"pixels", "imgData"}, script =
"var dst = new Uint32Array(imgData.data.buffer);\n" +
"var len = pixels.length;\n" +
"for (var i = 0; i < len; i++) {\n" +
" var c = pixels[i];\n" +
" dst[i] = (c === 66051) ? 0 : (-16777216 | ((c & 255) << 16) | (c & 65280) | ((c >> 16) & 255));\n" +
"}")
private static native void blitOverlayPixelsToImageData(@JSByRef int[] pixels, ImageData imgData);
}