public void RemoveNode(IdentifiableNode r, bool verify)
 {
     if (!verify)
     {
         RemoveNode(r);
     }
 }
 public int GetColumn(IdentifiableNode id)
 {
     if (nodesInRow.Contains(id))
     {
         return(nodesInRow.IndexOf(id));
     }
     return(-1);
 }
 public void AddNode(IdentifiableNode id)
 {
     if (Rows.ValidList())
     {
         bool capped = Rows[rowIndex].AtCapacity(rowCapacity);
         AddNode(id, capped);
     }
 }
    private void OnCreateItem(object sender, CreateItemArgs e)
    {
        IdentifiableNode created = new IdentifiableNode();

        created.SetInfo(e.displayName);
        sessionData.AddNode(created);
        sessionData.PrintAllNodes();
    }
 public void Add(IdentifiableNode id)
 {
     if (nodesInRow == null)
     {
         nodesInRow = new List <IdentifiableNode>();
     }
     id.SetNode((rowIndex, nodesInRow.Count));
     nodesInRow.Add(id);
 }
 public void RemoveNode(IdentifiableNode r)
 {
     NodeRemoved -= r.OnNodeDeleted;
     Rows[r.position.Item1].Remove(r.position.Item2);
     if (NodeRemoved != null)
     {
         NodeRemoved(this, new NodeDeletedArgs {
             deletedNodePosition = r.position
         });
     }
     ShiftRows();
 }
 void AddNode(IdentifiableNode id, bool withRow)
 {
     if (Rows.ValidList())
     {
         if (withRow)
         {
             int     n  = rowIndex + 1;
             NodeRow nr = new NodeRow(n);
             Rows.Add(nr);
         }
         Rows[rowIndex].Add(id);
     }
 }
    void AppendModeToolbar()
    {
        using (new GUILayout.HorizontalScope("helpbox", GUILayout.MaxWidth(685)))
        {
            using (new GUILayout.VerticalScope())
            {
                GUILayout.Label("Manage Nodes:", GUILayout.MaxWidth(100));
                using (new GUILayout.HorizontalScope())
                {
                    if (GUILayout.Button("+", GUILayout.MaxWidth(50)))
                    {
                        IdentifiableNode id = new IdentifiableNode();
                        sessionData.AddNode(id);
                    }
                    if (GUILayout.Button("-", GUILayout.MaxWidth(50)))
                    {
                        sessionData.RemoveAtLast();
                    }
                }
                if (GUILayout.Button("Clear Nodes"))
                {
                    foreach (NodeRow r in sessionData.Rows)
                    {
                        r.Clear();
                    }
                    sessionData.Clear();
                }
            }

            using (new GUILayout.VerticalScope())
            {
                GUILayout.Label("Columns per Row:");
                RowCapacity = EditorGUILayout.IntSlider(rowCap, 3, 10);
            }
            using (new GUILayout.VerticalScope())
            {
                using (new GUILayout.HorizontalScope())
                {
                    if (GUILayout.Button("Write To JSON"))
                    {
                        BroadcastAddData(SaveToJSON);
                        string saveItems = EditorJsonUtility.ToJson(SaveToJSON, true);
                        Debug.Log(saveItems);
                        File.WriteAllText("Assets/Resources/Databases/SampleItemDatabase.json", saveItems);
                    }
                }
                using (new GUILayout.HorizontalScope())
                {
                    if (GUILayout.Button("Append From JSON"))
                    {
                        if (SaveToJSON == null)
                        {
                            SaveToJSON = jsonPath.InitializeFromJSON <GameData>();
                        }

                        /*if (SaveToJSON.GetItemData().ValidList())
                         * {
                         *  foreach (Item i in SaveToJSON.GetItemData())
                         *  {
                         *      sessionData.AddNode(new IdentifiableNode(i, SaveToJSON));
                         *  }
                         * }*/
                    }

                    if (GUILayout.Button("Update Game Data"))
                    {
                        BroadcastAddData(SaveToJSON);
                    }
                }
            }
        }
    }