コード例 #1
0
 public void LoadContent(string filename, string content)
 {
     yap.Clear();
     patcher.Clear();
     patcher.ParseJSON(content);
     yap.Load();
     currentFileName = filename;
     YapView.Interface.PerformanceMode = true;
 }
コード例 #2
0
ファイル: PatcherModule.cs プロジェクト: yvanvds/interact
        public override void LoadContent()
        {
            if (Global.Yse == null)
            {
                return;
            }

            if (osc == null)
            {
                osc = new OscTree.Object(new OscTree.Address(Name, ID), typeof(object));
                Global.OscLocal.Add(osc);
            }

            sound.Stop();
            patcher.Clear();
            patcher.ParseJSON(Content);

            osc.Endpoints.List.Clear();
            for (uint i = 0; i < patcher.NumObjects(); i++)
            {
                object obj  = patcher.GetHandleFromList(i);
                string name = ((IYse.IHandle)obj).Name;
                if (name.Equals(".r"))
                {
                    string args = ((IYse.IHandle)obj).GetArgs();
                    osc.Endpoints.Add(new OscTree.Endpoint(args, (values) =>
                    {
                        if (values == null)
                        {
                            ((IYse.IHandle)obj).SetBang(0);
                        }
                        else if (values[0] is int)
                        {
                            ((IYse.IHandle)obj).SetIntData(0, (int)values[0]);
                        }
                        else if (values[0] is float)
                        {
                            ((IYse.IHandle)obj).SetFloatData(0, (float)values[0]);
                        }
                        else if (values[0] is bool)
                        {
                            ((IYse.IHandle)obj).SetIntData(0, (bool)values[0] == true ? 1 : 0);
                        }
                        else if (values[0] is string)
                        {
                            ((IYse.IHandle)obj).SetListData(0, (string)values[0]);
                        }
                    }));
                }
            }
        }