public void CopySelectionInto(IVIStar target) { if (target.Entry is IVIFile) { Debug.Log("Won't copy selection: target is not a directory"); return; } foreach (IVIStar star in selection_star_system.Root.Children) { try { if (target.Entry.FullPath.StartsWith(star.Entry.FullPath)) { continue; } IVIEntry new_entry = star.Entry.CopyTo(target.Entry as IVIDirectory); IVIStar star_in_src_sys = null; selection_sys_to_src_sys.TryGetValue(star, out star_in_src_sys); star_in_src_sys.Entry = new_entry; SourceStarSystem.NotifyCopy(dst: target, src: star_in_src_sys); } catch (Exception e) { Console.WriteLine("Failed to copy `" + star.Entry.FullPath + "` : " + e); } } DeselectAll(); }
// L'Entry a été déplacée : Déplacer la star dans le système. public void NotifyMove(IVIStar dst, IVIStar src) { src.Parent.Children.Remove(src); src.Parent = dst; if (src.Entry.FullPath.StartsWith(dst.Entry.FullPath)) // HACK déplacement vers un parent { Destroy(src); } else { dst.Children.Add(src); dst.PlaceChildrenAround(); } /* * foreach(IVIStar s in dst.Children) * Destroy(s); * dst.Children.Clear (); * dst.Entry = new IVIDirectory (dst.Entry.FullPath, Depth); * dst.DoRecursively (s => s.RegenerateChildren (Depth, transform)); * dst.DoRecursively (s => s.PlaceChildrenAround()); * dst.DoRecursively (Depth, (s, d) => s.ResetDistanceAndScale(level:2, sys:this)); // XXX Hack !! * dst.DoRecursively (s => s.SetMaterial()); * dst.DoRecursively (s => s.SetLight ()); */ }
public void MoveSelectionIntoTrash() { IVIStar trash = new IVIStar(); trash.Entry = TrashDirectory; MoveSelectionInto(trash); }
void Start() { GameObject go = Instantiate(StarPrefab, transform); CurrentStar = go.GetComponent <IVIStar> (); CurrentStar.Scale = L0_Scale; if (InitialPath == null || InitialPath.Length <= 0) { InitialPath = Application.dataPath; } try { CurrentStar.Entry = InitialDir != null ? InitialDir : new IVIDirectory(InitialPath, Depth); } catch (System.Exception e) { Debug.Log("Failed to initialize StarSystem: " + e); if (FatalMessageBoxPrefab == null) { //UnityEditor.EditorApplication.isPlaying = false; Application.Quit(); } else { Instantiate(FatalMessageBoxPrefab); } } CurrentStar.DoRecursively(Depth, (s, depth) => s.RegenerateChildren(depth, transform)); CurrentStar.DoRecursively(s => s.PlaceChildrenAround()); CurrentStar.DoRecursively(Depth, (s, depth) => s.ResetDistanceAndScale(level: Depth - depth, sys: this)); CurrentStar.DoRecursively(s => s.SetMaterial()); CurrentStar.DoRecursively(s => s.SetLight()); CurrentStar.DoRecursively(s => s.SetName()); ApplyVisualDepth(); }
public void ApplyPinch() { if (!AllowEnteringStars) { return; } Assert.IsTrue(EnterProgress >= 1, "The transition needs to complete first!"); bool isPerformed = IVISession.PrimaryHand.gestureReleasedPinch.IsBeingPerformed && !IVISession.PrimaryHand.gestureBothHandsSweeping.IsBeingPerformed && !IVISession.PrimaryHand.gestureExtendedIndexRelaxed.IsBeingPerformed; if (!isPerformed) { return; } if (IVISession.User.Focus == null) { EnterParent(); } else { IVIStar fstar = IVISession.User.Focus.GetComponent <IVIStar> (); if (fstar != null && CurrentStar.Children.Contains(fstar) && fstar.Entry is IVIDirectory) { EnterChild(fstar); } } }
public void EnterChild(IVIStar child) { Assert.IsTrue(CurrentStar.Children.Contains(child), "`" + CurrentStar.Entry.FullPath + "' isn't an immediate child of `" + child.Entry.FullPath + "' as expected!" ); Assert.IsTrue(child.Entry is IVIDirectory, "Entering a file!"); NextCurrentStar = child; OnEnterStart(); EnteringChild = true; NextCurrentStar.DoRecursively(Depth, (s, depth) => s.GenerateNextLevel(depth, this, EnterFadeInList)); NextCurrentStar.DoRecursively(Depth, (s, depth) => s.DoIf(s_ => depth < 1, s_ => EnterFadeInList.Add(s_))); EnterFadeOutList.Add(NextCurrentStar); EnterFadeOutList.Add(CurrentStar); EnterDestroyList.Add(CurrentStar); foreach (IVIStar star in CurrentStar.Children) { if (star != NextCurrentStar) { star.DoRecursively(s => EnterFadeOutList.Add(s)); star.DoRecursively(s => EnterDestroyList.Add(s)); } } }
public override void Use() { IVIUser user = IVISession.User; IVIStar star = user.Focus == null ? null : user.Focus.GetComponent <IVIStar> (); if (user.Focus == null || star == null) { return; } IVISession.Clipboard.ToggleSelect(star); }
public override void Use() { IVIUser user = IVISession.User; if (user.Focus != null && user.Focus.GetComponent <IVIStar>() != null) { IVIStar target = user.Focus.GetComponent <IVIStar>(); if (target.Entry is IVIDirectory) { IVISession.Clipboard.CopySelectionInto(target); } } }
// L'Entry a été copiée : Placer la star dans le système. public void NotifyCopy(IVIStar dst, IVIStar src) { /* * IVIStar src_cpy = Instantiate (src).GetComponent<IVIStar> (); * src_cpy.Parent = dst; * dst.Children.Add (src_cpy); * dst.DoRecursively (s => s.RegenerateChildren (Depth, transform)); * dst.DoRecursively (s => s.PlaceChildrenAround()); * dst.DoRecursively (Depth, (s, d) => s.ResetDistanceAndScale(level:2, sys:this)); // XXX Hack !! * dst.DoRecursively (s => s.SetMaterial()); * dst.DoRecursively (s => s.SetLight ()); */ }
public override void Use() { IVIUser user = IVISession.User; if (user.Focus != null && user.Focus.GetComponent <IVIStar>() != null) { IVIStar target = user.Focus.GetComponent <IVIStar>(); if (target.Entry is IVIDirectory) { IVISession.Clipboard.MoveSelectionInto(target); // TODO Repasser en mode sélection. Il faut un lien vers le IVIToolBehaviour. } } }
public void DeselectAll() { foreach (IVIStar star in selection_star_system.Root.Children) { IVIStar star_in_src_sys = null; selection_sys_to_src_sys.TryGetValue(star, out star_in_src_sys); if (star_in_src_sys != null) { star_in_src_sys.NotifyDeselected(); } Destroy(star.gameObject); } selection_star_system.Root.Children.Clear(); selection_sys_to_src_sys.Clear(); }
/// <summary> Performs a search by checking this star, then its children, recursively. Returns a single element. </summary> public IVIStar SearchRecursively(System.Predicate <IVIStar> pred) { if (pred(this)) { return(this); } foreach (IVIStar child in Children) { IVIStar found = child.SearchRecursively(pred); if (found != null) { return(found); } } return(null); }
void OnEnterFinished() { CurrentStar = NextCurrentStar; foreach (IVIStar star in EnterDestroyList) { star.Children.ForEach(child => child.Parent = null); if (star.Parent != null) { star.Parent.Children.Remove(star); } Destroy(star.gameObject); } CurrentStar.Parent = null; CurrentStar.DoRecursively(s => s.SetName()); ApplyVisualDepth(); EnterDestroyList.Clear(); EnterFadeInList.Clear(); EnterFadeOutList.Clear(); }
public void RegenerateChildren(int depth, Transform sysTransform) { // XXX depth is unused ! SetName(); if (Entry is IVIFile) { return; } IVIDirectory dir = Entry as IVIDirectory; foreach (IVIEntry childEntry in dir.Entries) { GameObject go = Instantiate(gameObject, sysTransform); IVIStar child = go.GetComponent <IVIStar>(); child.Children.Clear(); child.Parent = this; child.Entry = childEntry; Children.Add(child); } }
public void EnterParent() { IVIDirectory curDir = CurrentStar.Entry as IVIDirectory; GameObject parentGo = Instantiate(StarPrefab, transform); NextCurrentStar = parentGo.GetComponent <IVIStar> (); NextCurrentStar.Entry = new IVIDirectory(curDir.Systemdirectory.Parent.FullName, Depth); // XXX This is done in too many places, should be compressed into a function. NextCurrentStar.DoRecursively(Depth, (s, depth) => s.RegenerateChildren(depth, transform)); NextCurrentStar.DoRecursively(s => s.PlaceChildrenAround()); NextCurrentStar.DoRecursively(Depth, (s, depth) => s.ResetDistanceAndScale(level: Depth - depth, sys: this)); NextCurrentStar.DoRecursively(s => s.SetMaterial()); NextCurrentStar.DoRecursively(s => s.SetLight()); foreach (IVIStar child in NextCurrentStar.Children) { if (CurrentStar.Entry.FullPath == child.Entry.FullPath) { child.Children.ForEach(s_ => s_.DoRecursively_ChildrenFirst(s => Destroy(s.gameObject))); child.Children = CurrentStar.Children; child.Children.ForEach(s => s.Parent = child); Destroy(CurrentStar.gameObject); CurrentStar = child; EnterFadeInList.Add(CurrentStar); } else { child.DoRecursively(s => EnterFadeInList.Add(s)); } child.DoRecursively(Depth, (s_, depth) => s_.DoIf(s => depth < 1, s => EnterFadeOutList.Add(s))); child.DoRecursively(Depth, (s_, depth) => s_.DoIf(s => depth < 1, s => EnterDestroyList.Add(s))); } NextCurrentStar.DoRecursively(s => s.SetName()); NextCurrentStar.gameObject.SetActive(false); OnEnterStart(); EnteringChild = false; }
// ToggleSelect(star) remplace Select(star). // "Select(star)" ne communique pas l'intention de déselectionner une Star // si elle est déjà sélectionnée. public void ToggleSelect(IVIStar candidate) { // Pour chaque star déjà dans la sélection foreach (IVIStar present in selection_star_system.Root.Children) { // Test si la star ne provient pas du star_system du clipboard même // (égalité de références) if (candidate == present) { Debug.Log("[Clipboard]: Ignored " + candidate.Entry.FullPath); return; } // Si la candidate est déjà présente, on la désélectionne. if (candidate.Entry.FullPath.Equals(present.Entry.FullPath)) { selection_star_system.Root.Children.Remove(present); selection_sys_to_src_sys.Remove(present); Destroy(present); candidate.NotifyDeselected(); Debug.Log("[Clipboard]: Deselected " + candidate.Entry.FullPath); OnSelectionStarSystemChanged(); // C'est mauvais d'appeler Remove() pendant qu'on itère sur la collection, // mais on est sauvés par le return. return; } // Test si un supérieur/inférieur de star est déjà dans la sélection if (candidate.Entry.FullPath.StartsWith(present.Entry.FullPath) || present.Entry.FullPath.StartsWith(candidate.Entry.FullPath)) { Debug.Log("[Clipboard]: Replaced `" + present.Entry.FullPath + "` by `" + candidate.Entry.FullPath + "` "); IVIStar present_in_src_sys; selection_sys_to_src_sys.TryGetValue(present, out present_in_src_sys); present_in_src_sys.NotifyDeselected(); candidate.NotifySelected(); var candidate_copy = Instantiate(candidate, selection_star_system.transform).GetComponent <IVIStar> (); candidate_copy.Parent = selection_star_system.Root; candidate_copy.Entry = candidate.Entry; // Nécessaire selection_star_system.Root.Children.Add(candidate_copy); selection_star_system.Root.Children.Remove(present); Destroy(present); selection_sys_to_src_sys.Add(candidate_copy, candidate); selection_sys_to_src_sys.Remove(present); OnSelectionStarSystemChanged(); // C'est mauvais d'appeler Remove() pendant qu'on itère sur la collection, // mais on est sauvés par le return. return; } } candidate.NotifySelected(); var candidate_cpy = Instantiate(candidate, selection_star_system.transform).GetComponent <IVIStar> (); candidate_cpy.Parent = selection_star_system.Root; candidate_cpy.Entry = candidate.Entry; // OK, c'est nécessaire ! selection_star_system.Root.Children.Add(candidate_cpy); selection_sys_to_src_sys.Add(candidate_cpy, candidate); Debug.Log("[Clipboard]: Selected " + candidate.Entry.FullPath); OnSelectionStarSystemChanged(); }