/// Takes the first snapshot, which is a picture of the whole form. static void FirstSnapshot(Control ctrl, ValueStore values, Lane lane) { var t = ctrl.GetType(); if (t != typeof(Form)) { WriteLine($"| ({ctrl.Name})" + $" ({t}) " + ctrl.Text); values.Set(ctrl, ctrl.Text); // As of now, we don't care abaut labels. if (t != typeof(Label)) { lane.StartingState[ctrl.Name] = ctrl.Text; } } foreach (Control c in ctrl.Controls) { FirstSnapshot(c, values, lane); } }
void Update() { bool doTryConnect = true; doTryConnect = doTryConnect && !connected && UriString != ""; if (cws != null) { doTryConnect = doTryConnect && (cws.State == WebSocketState.Closed || cws.State == WebSocketState.Aborted); } if (doTryConnect) { connected = true; cws = null; TryConnect(); } CKARNetworkState state; while (stateQueue.Dequeue(out state)) { EventManager.InvokeNetworkStateChange(state); } string msgString; while (queue.Dequeue(out msgString)) { Debug.Log(msgString); if (msgString.Contains("\"type\": \"transform\"")) { WebsocketJsonTransform msg = JsonUtility.FromJson <WebsocketJsonTransform>(msgString); TransformSpec ts = new TransformSpec(msg.position, msg.scale, msg.rotation); if (msg.tree.Contains("marker")) { EventManager.InvokeMarkerTransform(msg.tree, ts); } else if (msg.tree.Contains("master")) { EventManager.InvokeMasterTransform(ts); } else { lsysController.DispatchTransform(msg.tree, ts); } } else if (msgString.Contains("\"type\": \"shape\"")) { WebsocketJsonShape msg = JsonUtility.FromJson <WebsocketJsonShape>(msgString); lsysController.DispatchShape(msg.tree, msg.shape); } else if (msgString.Contains("\"type\": \"value\"")) { WebsocketJsonValue msg = JsonUtility.FromJson <WebsocketJsonValue>(msgString); string[] keys = msg.key.Split(','); foreach (string key in keys) { ValueStore.Set(key, msg.payload); // will also invoke event } } else { WebsocketJsonMessage msg = JsonUtility.FromJson <WebsocketJsonMessage>(msgString); if (msg.type == "lsys") { lsysController.Dispatch(msg.payload); } if (msg.type == "console") { EventManager.InvokeConsole(msg.payload); } if (msg.type == "consoleStatus") { EventManager.InvokeConsoleStatus(msg.payload); } if (msg.type == "view") { EventManager.InvokeViewChange(msg.payload); } if (msg.type == "serverEvent") { if (msg.payload == "endMarkerConfig") { EventManager.InvokeServerEventEndMarkerConfig(); } } } } }