private WebJSON.Script GetScriptJSON(BaseScriptComponent script, bool includeScriptContents) { if (script == null) { return(null); } WebJSON.Script scriptJSON = new WebJSON.Script(); scriptJSON.Offset = script.Offset; if (includeScriptContents) { scriptJSON.Translation = script.TranslatedScript; } return(scriptJSON); }
private void ParseRequestJSON(WebJSON.Request msg) { switch (msg.Type) { case WebJSON.RequestType.Script: BaseScriptComponent s = GetScriptFromRequest(msg); if (s != null) { Send(new WebJSON.Message() { Type = WebJSON.MessageType.Script, Script = GetScriptJSON(s, true) }); } break; case WebJSON.RequestType.Comport: BrainComponent.Comport c = GetComportFromRequest(msg); if (c != null) { Send(new WebJSON.Message() { Type = WebJSON.MessageType.Comport, Comport = GetComportJSON(c, includeScriptContents: true) }); } break; case WebJSON.RequestType.Macro: BrainComponent.Macro m = GetMacroFromRequest(msg); if (m != null) { Send(new WebJSON.Message() { Type = WebJSON.MessageType.Macro, Macro = GetMacroJSON(m, includeScriptContents: true) }); } break; case WebJSON.RequestType.TransitionExport: if (selectedPerso_ != null && selectedPerso_ is PersoBehaviour) { MindComponent mc = selectedPerso_.GetComponent <MindComponent>(); if (mc != null) { try { var export = mc.TransitionExport; if (export != null) { Send(new WebJSON.Message() { Type = WebJSON.MessageType.TransitionExport, TransitionExport = export }); } } catch (Exception) { } } } break; case WebJSON.RequestType.Screenshot: TakeScreenshot(msg.Screenshot).Forget(); // Start the async task for taking a screenshot break; } }