using System; using System.Collections.Generic; using System.Text.RegularExpressions; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.UIElements; namespace GrassCutter { /// /// What's on the phone: HaulOS, a UI Toolkit panel drawn into a texture on the display. /// Home: the wallpaper, a big clock, a widget with how much of the planet is mown and the company's money, a search /// bar, app icons for the sites and a dock (map, notebook, browser). /// Uplink, a page: the address bar on top (reload / stop in it), the page, a navigation bar under it; a splash with /// the app's icon until the page's first frame is in, and a card with "try again" when it can't be reached. /// Tapping goes through our own hit test, because the phone is a 3D object swinging about: a button is an element with /// an Action in its userData. A button gives under the finger when pressed and acts when let go over it, like a phone's. /// public class PhoneScreen { public const int W = 720, H = 1578; // the same shape as Phone.ScreenW and ScreenH const int StatusH = 62, TopH = 150, DockH = 132, WebH = H - TopH - DockH; static readonly Color Ink = new Color(0.97f, 0.98f, 1f), Dim = new Color(0.8f, 0.86f, 0.92f, 0.78f); static readonly Color Mint = new Color(0.45f, 1f, 0.72f), Hay = new Color(1f, 0.8f, 0.36f), Red = new Color(1f, 0.38f, 0.34f); static readonly Color Bar = new Color(0.035f, 0.05f, 0.075f, 0.96f), Card = new Color(0.05f, 0.08f, 0.13f, 0.62f); static readonly Color Line = new Color(1f, 1f, 1f, 0.1f), Deep = new Color(0.02f, 0.035f, 0.06f); static readonly (string name, string url, Color colour, Action glyph)[] Sites = { ("YouTube", "https://m.youtube.com/", new Color(0.93f, 0.2f, 0.2f), Play), ("Shorts", "https://m.youtube.com/shorts", new Color(1f, 0.42f, 0.2f), Feed), ("Twitch", "https://m.twitch.tv/", new Color(0.55f, 0.34f, 0.95f), Live), ("TikTok", "https://www.tiktok.com/foryou", new Color(0.1f, 0.12f, 0.16f), Note2), ("Instagram", "https://www.instagram.com/reels/", new Color(0.88f, 0.28f, 0.6f), Lens), ("Reddit", "https://www.reddit.com/", new Color(1f, 0.45f, 0.12f), Talk), ("Google", "https://www.google.com/", new Color(0.26f, 0.52f, 0.96f), Find), ("Wikipedia", "https://www.wikipedia.org/", new Color(0.5f, 0.55f, 0.6f), Book), }; public RenderTexture Tex { get; } /// The display's root, for whatever takes the whole screen over (a call). public VisualElement Root => _root; public PhoneWeb Web { get; } /// A page is up, rather than the home screen. public bool ShowingPage => _page; public bool Wide => _wide; /// A text box has the keyboard. public bool Typing => _addressing || _editing; readonly VisualElement _root, _home, _top, _dock, _view, _progress, _status, _unturn, _splash, _error, _chip, _spinner, _splashIcon; readonly VisualElement _ring, _reload, _signal, _homeGrid; readonly Label _clock, _homeClock, _homeDate, _address, _search, _note, _mown, _money, _shipped, _link, _splashName, _errorText, _chipText, _toast; readonly Label _mownTitle, _fundsTitle, _retryLabel, _homeLabel; readonly List