Example #1
0
 public void RemoveFile(string path)
 {
     if (Items.ContainsKey(path))
     {
         FileItemSlot fileSlot = (FileItemSlot)Items[path];
         if (fileSlot.Parent != null)
         {
             FolderItemSlot parentSlot = (FolderItemSlot)fileSlot.Parent;
             parentSlot.SubItems.Remove(fileSlot);
             if (parentSlot.Show)
             {
                 RemoveBranch(parentSlot, fileSlot.BranchCount, fileSlot.BranchIndex);
             }
             else
             {
                 for (int i = fileSlot.BranchIndex; i < parentSlot.SubItems.Count; i++)
                 {
                     RectTransform childTransform = ((Component)parentSlot.SubItems[i]).GetComponent <RectTransform>();
                     childTransform.anchoredPosition    = new Vector2(childTransform.anchoredPosition.x, childTransform.anchoredPosition.y - (SlotOffset.y * fileSlot.BranchCount));
                     parentSlot.SubItems[i].BranchIndex = i;
                 }
             }
             Destroy(fileSlot.gameObject);
             Items.Remove(path);
         }
     }
 }
Example #2
0
 public void UnloadSlot()
 {
     if (SelectedSlot)
     {
         SelectedSlot.SelectButton.interactable = true;
     }
     SelectedSlot = null;
 }
Example #3
0
        public void LoadSlot <T>(FileItemSlot fileItemSlot, IBuilder <T> builder)
        {
            if (Serializer.Load(fileItemSlot.Path, out T result) && result != null)
            {
                if (SelectedSlot)
                {
                    SelectedSlot.SelectButton.interactable = true;
                }
                SelectedSlot = fileItemSlot;
                SelectedSlot.SelectButton.interactable = false;

                builder.Load(result);
                Calculator.instance.SaveLocations[Calculator.instance.SaveState] = SelectedSlot.Path;
                Calculator.instance.FileNameInputField.text = Path.GetFileNameWithoutExtension(Calculator.instance.SaveLocations[Calculator.instance.SaveState]);
            }
        }
Example #4
0
 public void CreateFile(FolderItemSlot folderItemSlot, string path)
 {
     if (!Items.ContainsKey(path))
     {
         FileItemSlot fileSlotChild = Instantiate(FileItemTemplate, folderItemSlot.FileSlotOrigin);
         fileSlotChild.gameObject.SetActive(true);
         fileSlotChild.Path          = path;
         fileSlotChild.NameText.text = Path.GetFileNameWithoutExtension(fileSlotChild.Path);
         fileSlotChild.Parent        = folderItemSlot;
         fileSlotChild.BranchIndex   = folderItemSlot.SubItems.Count;
         fileSlotChild.GetComponent <RectTransform>().anchoredPosition = new Vector2(SlotOffset.x, SlotOffset.y * (folderItemSlot.BranchCount - 1));
         if (folderItemSlot.Show)
         {
             folderItemSlot.BranchCount += 1;
             if (folderItemSlot.ChildLine)
             {
                 folderItemSlot.ChildLine.sizeDelta = new Vector2(folderItemSlot.ChildLine.sizeDelta.x, ChildLineOffset.y * (folderItemSlot.BranchCount - 1));
             }
             if (folderItemSlot.Parent != null)
             {
                 AddBranch((FolderItemSlot)folderItemSlot.Parent, 1, folderItemSlot.BranchIndex + 1);
             }
         }
         else
         {
             int branchCount = 0;
             for (int i = 0; i < folderItemSlot.SubItems.Count; i++)
             {
                 branchCount += folderItemSlot.SubItems[i].BranchCount;
             }
             fileSlotChild.GetComponent <RectTransform>().anchoredPosition = new Vector2(SlotOffset.x, SlotOffset.y * branchCount);
         }
         folderItemSlot.SubItems.Add(fileSlotChild);
         Items.Add(path, fileSlotChild);
     }
 }