Commit Graph
10 Commits
Author SHA1 Message Date
Dark98 e57315b785 feat(web): add Pause in Background option, TeaVM reflection filtering, and HUD drawImage guards
Improve webclient stability, background resource usage, and script reflection compatibility across desktop and mobile browsers.

### Web Client Features & Fixes
- `index.html` & `RSApplet.java`
  - Added a **Pause in Background** (`#opt-pause-bg`) option under **Display & Graphics** persisted in `localStorage` (`2006scape_web_options.pauseInBackground`) and synced live via `window.scapePauseInBackground`.
  - Added `visibilitychange` Web Audio suspend/resume handling in `index.html` and `isPausedInBackground()` loop throttling in `RSApplet.run()` (resetting timing buffers on resume to avoid tick bursts).
- `DesktopHooks.java`
  - Added `naturalWidth > 0` guards to `jsDrawModernMinimap` and `jsDrawModernChat` to prevent `InvalidStateError` on `drawImage` when HUD images are still loading or broken.

### TeaVM Script Reflection
- `WebReflectionSupplier.java`
  - Added `hasUnscriptableParam(...)` to exclude methods referencing `java.util.function.*`, `java.lang.Thread*`, `java.io.*`, or `java.awt.*` from TeaVM reflection metadata.
2026-12-02 17:20:27 +00:00
Dark98 ea04dfe196 feat(web): whitelist StringBuilder, LinkedHashMap, HashSet, and Set in WebReflectionSupplier
Expose `StringBuilder` and additional `java.util` collection/map types to TeaVM reflection so scripts constructing them via `new` work in `2006Scape-Web`.

### TeaVM Script Reflection
- `WebReflectionSupplier.java`
  - Added `java.lang.StringBuilder` (`append`, `toString`, `length`, `setLength`, `charAt`, `insert`, `delete`) and `java.util.LinkedHashMap`, `java.util.HashSet`, `java.util.Set` to `getAccessibleMethods`.
2026-12-02 01:56:04 +00:00
Dark98 f08736d2df feat(web): align Web audio/clipboard/screenshot hooks and reflection whitelist with Desktop and Android
Bring `2006Scape-Web` platform hooks and TeaVM reflection support in-line with the shared `2006Scape Client` and `2006Scape-Android` implementations.

### Platform Hooks & Web Audio
- `Class56_Sub1_Sub1.java` & `index.html`
  - Forwarded `boolean loop` from `method827` to `DesktopHooks.playMidiBytes(midiBytes, vol, loop)` and `window.scapeWebAudio.playMidi(bytes, volume, loop)` so FluidSynth honors `setPlayerLoop(loop ? -1 : 0)`.
  - Overrode `setLoop(boolean loop, boolean restartIfStopped)` to sync MIDI loop toggles immediately via `DesktopHooks.setMidiLoop` and `scapeWebAudio.setMidiLoop`.
- `DesktopHooks.java` & `index.html`
  - Added browser `paste` and `focus` (`navigator.clipboard.readText()`) tracking to `window.scapeClipboardText` and implemented ASCII `32..122` filtering in `DesktopHooks.getClipBoard()`.
  - Updated `takeScreenshot` to use `<username or SERVER_NAME>_<timestamp>.png` and send `"A picture has been downloaded."` to in-game chat when `sendMessage` is `true`.
  - Removed duplicate `ensureHudAssets()` call in `drawModernMinimap`.

### TeaVM Script Reflection
- `WebReflectionSupplier.java`
  - Added `WorldWebWalker` to `SCRIPTABLE_CLASSES` and expanded `isLangStr` (`lastIndexOf`, `charAt`, `split`) and `isUtilColl` (`set`, `indexOf`, `containsValue`, `keySet`, `values`).
2026-12-02 01:24:54 +00:00
Dark98 558243a3b7 fix(hd): sync web Client Options 317HD state with Plugin Hub 317 HD config
Keeps the webclient's Client Options modal (2006scape_web_options.hd), startup URL/option state, and Plugin Hub's plugin.317_HD.enabled property synchronized in both directions and at runtime.

### Web HD State Synchronization
- src/main/java/org/scape2006/web/WebLauncher.java:
  - Added syncHdStorageState(boolean) on startup when ?hd= or saved web options specify HD so plugin.317_HD.enabled in 2006scape_plugin_settings matches ClientSettings.HD_317 before PluginManager boots.
  - Registered window.scapeSetHd317 callback forwarding live HD toggles to game.setHD317Enabled(boolean).
- src/main/java/org/scape2006/web/DesktopHooks.java:
  - Added jsSyncWebOptionHdFromPluginConfig(String) in savePluginConfig(String) so toggling 317 HD in Plugin Hub or via ::hd updates 2006scape_web_options.hd in localStorage.
- src/main/webapp/index.html:
  - Updated saveOpts(applyLive) to mirror o.hd into plugin.317_HD.enabled in 2006scape_plugin_settings and invoke window.scapeSetHd317(o.hd) when saving live.
2026-12-02 00:36:05 +00:00
Dark98 6737a936df fix(audio): decode 8-bit PCM WAVs synchronously and preload FluidSynth assets
Eliminates per-sound async decodeAudioData latency and lazy SoundFont loading delays in the TeaVM webclient while preserving main-thread FluidSynth audio stability.

### Web Audio Pipeline
- src/main/webapp/index.html:
  - Added decodeWav8MonoSync(ctx, bytes) to decode 8-bit unsigned mono PCM WAVs from Sounds.java synchronously into an AudioBuffer with decodeAudioData fallback.
  - Added preloadFluidSynthAssets() on page load to initialize JSSynth and fetch TimGM6mb.sf2 before the first user gesture, and added midiPlaySeq cancellation across async playMidi() steps.
  - Configured AudioContext with { latencyHint: 'interactive' }, guarded playPcm() against suspended contexts, and kept FluidSynth ScriptProcessorNode at 4096 samples to avoid main-thread underruns.
- src/main/java/org/scape2006/web/DesktopHooks.java:
  - Skipped JS sound marshaling when vol <= 0.0f and forwarded delayMs to window.scapeWebAudio.playPcm(arr, vol, delayMs).
- src/main/webapp/sw.js:
  - Bumped CACHE_VERSION to 2006scape-web-v6 to invalidate stale cached web assets.
2026-12-02 00:28:48 +00:00
Dark98 02c3d8fb10 feat(web-audio): implement Class56 MIDI player with FluidSynth and TimGM6mb.sf2
Enables authentic General MIDI music playback in `2006Scape-Web` over both HTTP and HTTPS by implementing the missing `Class56_Sub1_Sub1` web adapter and wiring `js-synthesizer` (`libfluidsynth-2.3.0.js`) with the `TimGM6mb.sf2` SoundFont.

### Java MIDI Pipeline Bridge
- `Class56_Sub1_Sub1.java`:
  - Added `org.scape2006.web` implementation of `Class56` forwarding `method827`, `method828`, `method830`, `method831`, `method832`, and `method833` to `DesktopHooks.playMidiBytes`, `setSignlinkVolume`, and `stopSignlinkMidi`.
- `build.gradle`:
  - Patched `Game.constructMusic()` in `syncSharedSources` to instantiate `new Class56_Sub1_Sub1()` directly instead of `Class.forName("Class56_Sub1_Sub1").newInstance()`, preventing `musicIsntNull()` from returning `false`.

### FluidSynth Web Audio & Caching
- `src/main/webapp/libfluidsynth-2.3.0.js`, `js-synthesizer.min.js`, `TimGM6mb.sf2`:
  - Bundled FluidSynth WASM/JS synthesizer and General MIDI SoundFont (`5.8M`) locally for offline and plain-HTTP LAN compatibility.
- `src/main/webapp/index.html`:
  - Wired `window.scapeWebAudio` (`ensureFluidSynth`, `playMidi`, `setMidiVolume`, `stopMidi`) to load `TimGM6mb.sf2`, loop tracks via `setPlayerLoop(-1)`, and resume pending MIDI on first user gesture.
- `src/main/webapp/sw.js`:
  - Added `libfluidsynth-2.3.0.js`, `js-synthesizer.min.js`, and `TimGM6mb.sf2` to `SHELL_ASSETS` and bumped `CACHE_VERSION` to `2006scape-web-v5`.
2026-12-01 14:53:04 +00:00
Dark98 4bcb91c3a2 fix(web): fix Android Chrome black screen and Fixed-mode WebGL2 viewport scissor
Resolves the Android Chrome black screen after closing the welcome back interface and prevents Fixed-mode 317HD `gl.clear` from wiping surrounding HUD/border regions.

### WebGL2 Context & Fixed-Mode Scissoring
- `WebGL2.java`:
  - Enabled `preserveDrawingBuffer: true` and removed `desynchronized: true` on the `#gl-canvas` WebGL2 context to prevent Android Chrome from clearing or failing to composite between frames.
  - Added `SCISSOR_TEST` (`0x0C11`) and `scissor(x, y, width, height)` bindings.
- `WebHd317Renderer.java`:
  - Wrapped Pass 2 (`gl.clear` and 3D scene draw) in `GL_SCISSOR_TEST` (`gl.scissor(vpX, vpY, width, height)`) so Fixed-mode stone borders, chatbox, and tab areas are preserved.
  - Reused `HD317Pipeline.backend` in `ensureOverlayReady()` to avoid creating duplicate `WebHd317Renderer` instances.
- `RSImageProducer.java`:
  - Removed `desynchronized: true` from `#game-canvas`'s 2D context so Android Chrome composites `#game-canvas` transparently over `#gl-canvas`.

### Service Worker Caching
- `src/main/webapp/sw.js`:
  - Bumped `CACHE_VERSION` to `2006scape-web-v3` and switched `js/client.js` to network-first (with cache fallback) so client updates take effect immediately when online.
2026-11-30 22:41:05 +00:00
Dark98 ededb882a0 refactor(web): rename 117HD WebGL2 renderer and UI references to 317HD
Renames `WebHd117Renderer` and all remaining `117HD` symbols, build exclusions, and UI labels in `2006Scape-Web` to `317HD`.

### WebGL2 Renderer & Build
- `WebHd317Renderer.java`:
  - Renamed from `WebHd117Renderer.java` and updated class/log references to `WebHd317Renderer` / `317HD`.
- `build.gradle`, `WebLauncher.java`, `RSImageProducer.java`, `DesktopHooks.java`, `WebGL2.java`:
  - Updated `DesktopHd117Renderer.java` exclusion to `DesktopHd317Renderer.java` and updated pipeline/renderer call sites to `HD317Pipeline` and `WebHd317Renderer`.
- `src/main/webapp/index.html`:
  - Updated UI label from `117HD (WebGL2)` to `317HD (WebGL2)`.
2026-11-30 21:57:21 +00:00
Dark98 33235cec55 perf(web): eliminate putImageData via WebGL2 quad, sync frame pacing, and add PWA/Service Worker
Replaces `ctx2d.putImageData` with a WebGL2 texture quad in both 117HD and SD modes, aligns the TeaVM game loop with `requestAnimationFrame`, and adds PWA manifest and Service Worker asset caching for mobile/iOS Safari.

### WebGL2 Compositing & SD/HD Rendering
- `WebHd117Renderer.java`, `WebGL2.java`:
  - Decoupled `ensureOverlayContext()` / `ensureOverlayReady()` so the WebGL2 2D overlay quad initializes without compiling 3D shadow/scene shaders when 117HD is off.
  - Added `drawHudPixels` and `drawHudCanvas` compositing onto `#gl-canvas` with `useBlend` control (disabling `GL_BLEND` for opaque SD frames).
- `RSImageProducer.java`, `DesktopHooks.java`:
  - Routed `RSImageProducer.drawGraphics` and modern HUD draws (`drawModernMinimap`, `drawModernChat`, `drawModernTab`) through the WebGL2 quad whenever `ensureOverlayReady()` succeeds, clearing `#game-canvas` once to avoid `putImageData` overhead.

### Frame Pacing & Mobile PWA
- `RSApplet.java`:
  - Added TeaVM `@Async` `awaitAnimationFrame()` backed by `window.requestAnimationFrame` for `delay <= 16` and capped catch-up ticks per frame (`loopTicks >= 2`).
- `index.html`, `manifest.webmanifest`, `sw.js`:
  - Added Apple Web App meta tags, `manifest.webmanifest`, and `sw.js` Service Worker registration with shell precaching, network-first navigation, and stale-while-revalidate static asset caching.
2026-11-30 21:54:39 +00:00
Dark98 3331ab745b 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).
2026-11-30 20:45:03 +00:00