Hologram calls, HaulOS phone, Enhanced lighting, smoother camera; Blender remaster review files
Game: - Assistant and Director portraits: GPT backgrounds and a holographic appear/disappear shader (Talk/TalkHolo) instead of on/off - Phone redesigned (HaulOS home, address bar, dock, error/loading states) and the browser link made sturdier - Settings > Graphics > Lighting: Classic / Enhanced (runtime volume, no project assets changed); Enhanced SSAO uses the smooth interleaved-gradient method at high samples so flat panels don't speckle - Painted board textures (T_HullPanel, T_BarnRed) keep only edge wear: the big bare-wood patches read as dirty smudges - The head leans into a sidestep smoothly instead of snapping with A / D - New keys in all 11 languages Review only (nothing swapped into the game yet): ArtSource/Blender/remaster (v1 paint pass of our own models, Synty-built ones left out), remaster/crew (crew repaint with arm, colour-edge and face fixes), remaster_v2 (smooth-geometry pilot). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -22,7 +22,7 @@ namespace GrassCutter
|
||||
/// </summary>
|
||||
public class PhoneWeb
|
||||
{
|
||||
const int TallW = 390, WideH = 390, FrameTall = 540, FrameWide = 1120;
|
||||
const int TallW = 390, WideH = 390, FrameTall = 640, FrameWide = 1120;
|
||||
const int Retries = 4;
|
||||
// our eyes in every document and frame: the game's volume, quiet when the phone goes away, and new windows in the one tab
|
||||
const string Keep =
|
||||
@ -64,6 +64,7 @@ namespace GrassCutter
|
||||
public readonly CancellationTokenSource Stop = new CancellationTokenSource();
|
||||
public readonly BlockingCollection<string> Out = new BlockingCollection<string>();
|
||||
public volatile bool Ready;
|
||||
public bool Dressed;
|
||||
}
|
||||
|
||||
/// <summary>A frame on its way to the screen. Reused: at 30 a second, fresh arrays of half a megabyte would be a garbage collection a second.</summary>
|
||||
@ -114,8 +115,9 @@ namespace GrassCutter
|
||||
_mute = CommandLine.Has("-autodemo");
|
||||
_profile = Path.Combine(_mute ? Application.temporaryCachePath : Application.persistentDataPath, "PhoneWeb");
|
||||
_decoded = new Texture2D(FrameTall, FrameTall, TextureFormat.RGB24, false);
|
||||
_rt = new RenderTexture(1024, 1024, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB) { name = "PhoneWeb" };
|
||||
_rt = new RenderTexture(FrameTall, FrameTall * _pageH / TallW, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB) { name = "PhoneWeb" };
|
||||
_rt.Create();
|
||||
ClearPicture();
|
||||
}
|
||||
|
||||
// ───────────────────────── what the phone asks of it ─────────────────────────
|
||||
@ -130,6 +132,7 @@ namespace GrassCutter
|
||||
_pending = url;
|
||||
_loading = true;
|
||||
_restarts = 0;
|
||||
ClearPicture();
|
||||
Boot();
|
||||
}
|
||||
|
||||
@ -140,9 +143,31 @@ namespace GrassCutter
|
||||
_pending = _wanted = _last = null;
|
||||
_loading = false;
|
||||
_url = null;
|
||||
ClearPicture();
|
||||
if (Ready) Cmd("Page.navigate", "{\"url\":\"about:blank\"}");
|
||||
}
|
||||
|
||||
/// <summary>Black, so the last site's last frame isn't what the next one opens on.</summary>
|
||||
void ClearPicture()
|
||||
{
|
||||
var was = RenderTexture.active;
|
||||
RenderTexture.active = _rt;
|
||||
GL.Clear(false, true, Color.black);
|
||||
RenderTexture.active = was;
|
||||
var s = Interlocked.Exchange(ref _shot, null);
|
||||
if (s != null) Ack(s);
|
||||
}
|
||||
|
||||
public void Stop() { if (Ready) { Cmd("Page.stopLoading"); _loading = false; } }
|
||||
|
||||
/// <summary>Something else has the phone's screen (a call): whatever plays on the page is paused under it.</summary>
|
||||
public bool Hold
|
||||
{
|
||||
get => _hold;
|
||||
set { if (_hold != value) { _hold = value; _nextState = 0f; } }
|
||||
}
|
||||
bool _hold;
|
||||
|
||||
public void Back() { if (Ready) Cmd("Runtime.evaluate", "{\"expression\":\"void history.back()\"}"); }
|
||||
public void Forward() { if (Ready) Cmd("Runtime.evaluate", "{\"expression\":\"void history.forward()\"}"); }
|
||||
public void Reload() { if (Ready) { _loading = true; Cmd("Page.reload"); } }
|
||||
@ -160,14 +185,15 @@ namespace GrassCutter
|
||||
{
|
||||
if (_wide == on) return;
|
||||
_wide = on;
|
||||
ClearPicture();
|
||||
if (Ready) { Metrics(); if (_shown) { Cmd("Page.stopScreencast"); Screencast(true); } }
|
||||
}
|
||||
|
||||
void Screencast(bool on)
|
||||
{
|
||||
if (on) Cmd("Page.startScreencast", _wide
|
||||
? $"{{\"format\":\"jpeg\",\"quality\":62,\"maxWidth\":{FrameWide},\"maxHeight\":{FrameWide * WideH / _fullW},\"everyNthFrame\":1}}"
|
||||
: $"{{\"format\":\"jpeg\",\"quality\":58,\"maxWidth\":{FrameTall},\"maxHeight\":{FrameTall * _pageH / TallW},\"everyNthFrame\":1}}");
|
||||
? $"{{\"format\":\"jpeg\",\"quality\":70,\"maxWidth\":{FrameWide},\"maxHeight\":{FrameWide * WideH / _fullW},\"everyNthFrame\":1}}"
|
||||
: $"{{\"format\":\"jpeg\",\"quality\":68,\"maxWidth\":{FrameTall},\"maxHeight\":{FrameTall * _pageH / TallW},\"everyNthFrame\":1}}");
|
||||
else Cmd("Page.stopScreencast");
|
||||
}
|
||||
|
||||
@ -226,7 +252,10 @@ namespace GrassCutter
|
||||
}
|
||||
|
||||
/// <summary>The mouse wheel, one notch at a time. Positive is on down the page.</summary>
|
||||
public void Wheel(int dir)
|
||||
public void Wheel(int dir) => Wheel(dir, CssW / 2f, CssH / 2f);
|
||||
|
||||
/// <summary>The wheel over a point of the page: what's under it scrolls (a chat beside a stream, a list in a menu).</summary>
|
||||
public void Wheel(int dir, float x, float y)
|
||||
{
|
||||
if (!Ready) return;
|
||||
if (OnFeed)
|
||||
@ -236,23 +265,30 @@ namespace GrassCutter
|
||||
Flick(dir);
|
||||
return;
|
||||
}
|
||||
Cmd("Input.dispatchMouseEvent", string.Format(CultureInfo.InvariantCulture, "{{\"type\":\"mouseWheel\",\"x\":{0},\"y\":{1},\"deltaX\":0,\"deltaY\":{2}}}", CssW / 2, CssH / 2, dir * 260));
|
||||
Cmd("Input.dispatchMouseEvent", string.Format(CultureInfo.InvariantCulture, "{{\"type\":\"mouseWheel\",\"x\":{0:0.#},\"y\":{1:0.#},\"deltaX\":0,\"deltaY\":{2}}}", x, y, dir * 220));
|
||||
}
|
||||
|
||||
public void Insert(string text) { if (Ready) Cmd("Input.insertText", "{\"text\":" + Str(text) + "}"); }
|
||||
|
||||
public void Key(string name, int code, string text)
|
||||
/// <param name="modifiers">CDP's: 1 Alt, 2 Ctrl, 4 Meta, 8 Shift.</param>
|
||||
public void Key(string name, int code, string text, int modifiers = 0)
|
||||
{
|
||||
if (!Ready) return;
|
||||
string common = $"\"key\":\"{name}\",\"code\":\"{name}\",\"windowsVirtualKeyCode\":{code}";
|
||||
string common = $"\"key\":\"{name}\",\"code\":\"{name}\",\"windowsVirtualKeyCode\":{code},\"modifiers\":{modifiers}";
|
||||
Cmd("Input.dispatchKeyEvent", "{\"type\":\"" + (text != null ? "keyDown" : "rawKeyDown") + "\"," + common + (text != null ? ",\"text\":\"" + text + "\"" : "") + "}");
|
||||
Cmd("Input.dispatchKeyEvent", "{\"type\":\"keyUp\"," + common + "}");
|
||||
}
|
||||
|
||||
/// <summary>An editing command on the focused text box: selectAll, undo, redo.</summary>
|
||||
public void Command(string name)
|
||||
{
|
||||
if (Ready) Cmd("Input.dispatchKeyEvent", "{\"type\":\"rawKeyDown\",\"key\":\"\",\"windowsVirtualKeyCode\":0,\"commands\":[\"" + name + "\"]}");
|
||||
}
|
||||
|
||||
/// <summary>Is the page waiting for typing?</summary>
|
||||
public async Task<bool> FieldActive()
|
||||
{
|
||||
const string js = "(()=>{const e=document.activeElement;return String(!!e&&(e.isContentEditable||e.tagName==='TEXTAREA'||e.tagName==='IFRAME'||(e.tagName==='INPUT'&&!/^(checkbox|radio|button|submit|range|file)$/.test(e.type))))})()";
|
||||
const string js = "(()=>{const e=document.activeElement;return String(!!e&&(e.isContentEditable||e.tagName==='TEXTAREA'||(e.tagName==='INPUT'&&!/^(checkbox|radio|button|submit|range|file)$/.test(e.type))))})()";
|
||||
return await Ask(js) == "true";
|
||||
}
|
||||
|
||||
@ -288,6 +324,13 @@ namespace GrassCutter
|
||||
_link = null;
|
||||
}
|
||||
if (_died) Revive();
|
||||
if (Ready && !_link.Dressed)
|
||||
{
|
||||
// the page's shape and the frames, as they are now: a Show or a turn while it started can't be lost
|
||||
_link.Dressed = true;
|
||||
Metrics();
|
||||
if (_shown) Screencast(true);
|
||||
}
|
||||
if (Ready)
|
||||
{
|
||||
if (_pending != null)
|
||||
@ -314,6 +357,14 @@ namespace GrassCutter
|
||||
float started = Time.realtimeSinceStartup;
|
||||
if (_decoded.LoadImage(s.Jpeg, false))
|
||||
{
|
||||
// the texture takes the frame's own size: no squeezing a 1120-wide frame into less and back
|
||||
if (_rt.width != _decoded.width || _rt.height != _decoded.height)
|
||||
{
|
||||
_rt.Release();
|
||||
_rt.width = _decoded.width;
|
||||
_rt.height = _decoded.height;
|
||||
_rt.Create();
|
||||
}
|
||||
Graphics.Blit(_decoded, _rt);
|
||||
Fresh = true;
|
||||
}
|
||||
@ -361,7 +412,7 @@ namespace GrassCutter
|
||||
if (Time.unscaledTime < _nextState) return;
|
||||
_nextState = Time.unscaledTime + 0.5f;
|
||||
string v = (GameSettings.Master * GameSettings.PhoneVolume).ToString("0.00", CultureInfo.InvariantCulture);
|
||||
Cmd("Runtime.evaluate", "{\"expression\":\"void(window.__gc&&(__gc.vol=" + v + ",__gc.hold=" + (_shown ? "false" : "true") + "))\"}");
|
||||
Cmd("Runtime.evaluate", "{\"expression\":\"void(window.__gc&&(__gc.vol=" + v + ",__gc.hold=" + (_shown && !_hold ? "false" : "true") + "))\"}");
|
||||
}
|
||||
|
||||
void Revive()
|
||||
@ -393,7 +444,7 @@ namespace GrassCutter
|
||||
foreach (var root in new[] { pf86, pf, local })
|
||||
{
|
||||
if (string.IsNullOrEmpty(root)) continue;
|
||||
foreach (var exe in new[] { @"Microsoft\Edge\Application\msedge.exe", @"Google\Chrome\Application\chrome.exe" })
|
||||
foreach (var exe in new[] { @"Microsoft\Edge\Application\msedge.exe", @"Google\Chrome\Application\chrome.exe", @"BraveSoftware\Brave-Browser\Application\brave.exe", @"Chromium\Application\chrome.exe" })
|
||||
{
|
||||
var path = Path.Combine(root, exe);
|
||||
if (File.Exists(path)) return path;
|
||||
@ -440,7 +491,7 @@ namespace GrassCutter
|
||||
if (port == null) throw new TimeoutException("The browser didn't start.");
|
||||
|
||||
string ws, ua, chrome;
|
||||
using (var http = new HttpClient(new HttpClientHandler { UseProxy = false }))
|
||||
using (var http = new HttpClient(new HttpClientHandler { UseProxy = false }) { Timeout = TimeSpan.FromSeconds(10) })
|
||||
{
|
||||
// the debug server hangs up after each answer, so no reusing the connection
|
||||
http.DefaultRequestHeaders.ConnectionClose = true;
|
||||
@ -461,7 +512,11 @@ namespace GrassCutter
|
||||
|
||||
link.Ws = new ClientWebSocket();
|
||||
link.Ws.Options.Proxy = null;
|
||||
await link.Ws.ConnectAsync(new Uri(ws), link.Stop.Token);
|
||||
using (var limit = CancellationTokenSource.CreateLinkedTokenSource(link.Stop.Token))
|
||||
{
|
||||
limit.CancelAfter(TimeSpan.FromSeconds(10));
|
||||
await link.Ws.ConnectAsync(new Uri(ws), limit.Token);
|
||||
}
|
||||
_ = Task.Run(() => Sender(link));
|
||||
_ = Task.Run(() => Receiver(link));
|
||||
|
||||
@ -478,8 +533,6 @@ namespace GrassCutter
|
||||
int win = Interlocked.Increment(ref _id);
|
||||
_winAsk = win;
|
||||
Send(link, "{\"id\":" + win + ",\"method\":\"Browser.getWindowForTarget\",\"params\":{}}");
|
||||
Metrics();
|
||||
if (_shown) Screencast(true);
|
||||
link.Ready = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -609,7 +662,13 @@ namespace GrassCutter
|
||||
}
|
||||
else if (m.method == "Page.frameNavigated")
|
||||
{
|
||||
if (string.IsNullOrEmpty(m.@params?.frame?.parentId)) _url = m.@params?.frame?.url;
|
||||
if (string.IsNullOrEmpty(m.@params?.frame?.parentId))
|
||||
{
|
||||
var u = m.@params?.frame?.url;
|
||||
// the blank page from going home, landing after the next site was asked for
|
||||
if (u == "about:blank" && (_wanted != null || _pending != null)) return;
|
||||
_url = u;
|
||||
}
|
||||
}
|
||||
else if (m.method == "Page.navigatedWithinDocument") _url = m.@params?.url;
|
||||
else if (m.method == "Page.frameStartedLoading") { if (m.@params?.frameId == link.Tab) _loading = true; }
|
||||
@ -660,8 +719,10 @@ namespace GrassCutter
|
||||
_died = true;
|
||||
}
|
||||
|
||||
/// <summary>Closed properly, so the logins from this session make it to disk.</summary>
|
||||
public void Close()
|
||||
/// <summary>Closed properly, so the logins from this session make it to disk. The game doesn't wait for it, unless it's quitting.</summary>
|
||||
public void Close() => Close(true);
|
||||
|
||||
public void Close(bool quitting)
|
||||
{
|
||||
Application.quitting -= Close;
|
||||
var link = _link;
|
||||
@ -675,6 +736,15 @@ namespace GrassCutter
|
||||
{
|
||||
link.Ready = false;
|
||||
Send(link, "Browser.close", "{}");
|
||||
if (!quitting)
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
try { link.Proc?.WaitForExit(4000); } catch (InvalidOperationException) { }
|
||||
Drop(link);
|
||||
});
|
||||
return;
|
||||
}
|
||||
try { link.Proc?.WaitForExit(1500); } catch (InvalidOperationException) { }
|
||||
}
|
||||
Drop(link);
|
||||
|
||||
Reference in New Issue
Block a user