示例#1
0
 public static InputManagerSerializer LoadFromDisk(string path)
 {
     if (File.Exists(path))
     {
         FileStream file = null;
         try
         {
             BinaryFormatter bf = new BinaryFormatter();
             file = File.Open(path, FileMode.Open);
             InputManagerSerializer r = (InputManagerSerializer)bf.Deserialize(file);
             return(r);
         }
         catch (Exception e)
         {
             MsgBox.Make("Couldn't load file (" + path + ") from disk because:\n" + e.Message);
         }
         finally
         {
             if (file != null)
             {
                 file.Close();
             }
         }
     }
     return(null);
 }
示例#2
0
        private void OnSelectedRightClick(string s)
        {
            if (firstSelect)
            {
                firstSelect = false;
            }
            else
            {
                Destroy(splatRightClick.gameObject);
                switch (s)
                {
                case "doc":
                    //blabla
                    //
                    //Possible input types: blabla
                    //Possible output types: blabla
                    StringBuilder          str         = new StringBuilder(node.GetDocumentation() + "\n\n");
                    Type[]                 inputTypes  = node.GetPossibleInputTypes();
                    Type[]                 outputTypes = node.GetPossibleOutputTypes();
                    InputManagerSerializer example     = node.GetExample();

                    if (inputTypes.Length != 0)
                    {
                        str.Append("Possible input types: ");
                        for (int i = 0; i < inputTypes.Length; i++)
                        {
                            string cleanName = TabMenu.CleanClassName(inputTypes[i].ToString());
                            str.Append(cleanName);
                            if (i != inputTypes.Length - 1)
                            {
                                str.Append(", ");
                            }
                        }
                    }

                    if (outputTypes.Length != 0)
                    {
                        str.Append("\nPossible output types: ");
                        for (int i = 0; i < outputTypes.Length; i++)
                        {
                            string cleanName = TabMenu.CleanClassName(outputTypes[i].ToString());
                            str.Append(cleanName);
                            if (i != outputTypes.Length - 1)
                            {
                                str.Append(", ");
                            }
                        }
                    }
                    if (example == null)
                    {
                        MsgBox.Make(str.ToString());
                    }
                    else
                    {
                        MsgBox.Make(str.ToString(), new string[] { "Paste an example" }, new MsgBox.OnButtonClick[] {
                            (MsgBox msg, object o) => {
                                InputManagerSerializer exem = (InputManagerSerializer)o;
                                InputManager.clipboard      = exem.nodes;
                                InputManager.clipboardPos   = exem.PositionsToVector();
                                host.Paste();
                                msg.Close();
                            }
                        }, new object[] { example });
                    }
                    break;

                case "del":
                    Delete();
                    break;

                case "dis":
                    SetEnable(!node.enabled);
                    break;

                case "com":
                    StartComment();
                    break;
                }
            }
        }