Exemplo n.º 1
0
        private List <SfbEntryWrapper> GetChildRange(SfbEntryWrapper first, SfbEntryWrapper last)
        {
            int lo = Mathf.Min(wrappers.IndexOf(first), wrappers.IndexOf(last));
            int hi = Mathf.Max(wrappers.IndexOf(first), wrappers.IndexOf(last));

            return(wrappers.GetRange(lo, hi + 1 - lo));
        }
Exemplo n.º 2
0
        private SfbEntry BrowserEntryFromFileSystemEntry(SfbEntryWrapper wrapper)
        {
            GameObject go = Instantiate(entryPrefabs.First(a => a.type == wrapper.fileSystemEntry.type.Convert()).gameObject);

            go.name = wrapper.fileSystemEntry.name.Replace("/", "\\");
            go.transform.SetParent(wrapper.transform, false);

            go.GetComponentInChildren <Text>().text = wrapper.fileSystemEntry.name;

            if (wrapper.fileSystemEntry.hidden)
            {
                Image[] images = go.GetComponentsInChildren <Image>();
                if (images.Length >= 2)
                {
                    images[1].color = new Color(images[1].color.r, images[1].color.g, images[1].color.b,
                                                fileBrowser.settings.HiddenOpacity);
                }
                Text text = go.GetComponentInChildren <Text>();
                if (text != null)
                {
                    text.color = new Color(text.color.r, text.color.g, text.color.b, fileBrowser.settings.HiddenOpacity);
                }
            }

            var entry = go.GetComponent <SfbEntry>();

            entry.fileSystemEntry = wrapper.fileSystemEntry;
            entry.wrapper         = wrapper;

            return(entry);
        }
        private void CreateWrapper(SfbSavedLocationEntry entry)
        {
            var wrapper = SfbEntryWrapper.CreateEmpty((entryPrefabs.First(a => a.type == entry.type.Convert()).transform as RectTransform).rect.height);

            wrapper.fileSystemEntry = entry;
            wrapper.rectTransform.SetParent(content, false);
            wrapper.parent = this;
            wrappers.Add(wrapper);
        }
Exemplo n.º 4
0
        private void CreateWrappers(IEnumerable <SfbFileSystemEntry> entries)
        {
            wrappers.Clear();

            foreach (var entry in entries)
            {
                var entry1  = entry;
                var wrapper = SfbEntryWrapper.CreateEmpty((entryPrefabs.First(a => a.type == entry1.type.Convert()).transform as RectTransform).rect.height);
                wrapper.fileSystemEntry = entry;
                wrapper.rectTransform.SetParent(content, false);
                wrapper.parent = this;
                wrappers.Add(wrapper);
            }
        }
Exemplo n.º 5
0
        private void Click(SfbEntryWrapper wrapper)
        {
            RuntimePlatform rp    = Application.platform;
            bool            isMac = (rp == RuntimePlatform.OSXEditor || rp == RuntimePlatform.OSXPlayer || rp == RuntimePlatform.OSXWebPlayer);
            bool            ctrl  = isMac
                                                        ? fileBrowser.GetHeldKeys().Contains(KeyCode.LeftCommand) || fileBrowser.GetHeldKeys().Contains(KeyCode.RightCommand)
                                                        : fileBrowser.GetHeldKeys().Any(a => a == KeyCode.LeftControl || a == KeyCode.RightControl);

            if (clickStopwatch.ElapsedMilliseconds < fileBrowser.settings.DoubleClickTime)
            {
                DoubleClick(wrapper);
                clickStopwatch = Stopwatch.StartNew();
                return;
            }

            clickStopwatch = Stopwatch.StartNew();
            if (ctrl)
            {
                wrapper.Selected = !wrapper.Selected;
                if (wrapper.Selected)
                {
                    lastClickedWrapper = wrapper;
                }
            }
            else if (fileBrowser.GetHeldKeys().Any(a => a == KeyCode.LeftShift || a == KeyCode.RightShift))
            {
                if (lastClickedWrapper != null && lastClickedWrapper.Selected)
                {
                    GetChildRange(wrapper, lastClickedWrapper).ForEach(a => a.Selected = true);
                }
            }
            else
            {
                lastClickedWrapper = wrapper;
                bool newState = true;

                if (wrappers.Count(a => a.BrowserEntry != null && a.Selected) <= 1)
                {
                    newState = !wrapper.Selected;
                }

                fileBrowser.DeselectAllEntries();
                wrapper.Selected = newState;

                fileBrowser.SelectedEntry(wrapper.fileSystemEntry);
            }
        }
        private void AddHeader(SfbEntryType type)
        {
            var go      = Instantiate(entryPrefabs.First(a => a.type == type).gameObject);
            var wrapper = SfbEntryWrapper.CreateEmpty((go.transform as RectTransform).rect.height);

            wrapper.transform.SetParent(content, false);
            wrapper.parent       = this;
            wrapper.interactable = false;
            wrappers.Add(wrapper);

            go.name = type.ToString().Replace("Header", "") + ":";
            go.transform.SetParent(wrapper.transform, false);
            go.GetComponentInChildren <Text>().text = type.ToString().Replace("Header", "") + ":";

            var entry = go.GetComponent <SfbEntry>();

            entry.wrapper        = wrapper;
            wrapper.BrowserEntry = entry;
        }
Exemplo n.º 7
0
        private void DoubleClick(SfbEntryWrapper wrapper)
        {
            if (wrapper.BrowserEntry.type == SfbEntryType.Folder)
            {
                fileBrowser.ChangeDirectory(wrapper.fileSystemEntry);
            }
            else if (wrapper.BrowserEntry.type == SfbEntryType.File)
            {
                if (fileBrowser.Mode == SfbMode.Open)
                {
                    fileBrowser.ListenerSubmitOpenSelection();
                }
                else
                {
                    fileBrowser.ListenerSubmitSaveFile();
                }
            }

            wrapper.Selected = false;
        }
Exemplo n.º 8
0
 private List<SfbEntryWrapper> GetChildRange(SfbEntryWrapper first, SfbEntryWrapper last)
 {
     int lo = Mathf.Min(wrappers.IndexOf(first), wrappers.IndexOf(last));
     int hi = Mathf.Max(wrappers.IndexOf(first), wrappers.IndexOf(last));
     return wrappers.GetRange(lo, hi + 1 - lo);
 }
Exemplo n.º 9
0
        private void DoubleClick(SfbEntryWrapper wrapper)
        {
            if (wrapper.BrowserEntry.type == SfbEntryType.Folder) {
                fileBrowser.ChangeDirectory(wrapper.fileSystemEntry);
            }
            else if (wrapper.BrowserEntry.type == SfbEntryType.File) {
                if (fileBrowser.Mode == SfbMode.Open) {
                    fileBrowser.ListenerSubmitOpenSelection();
                }
                else {
                    fileBrowser.ListenerSubmitSaveFile();
                }
            }

            wrapper.Selected = false;
        }
Exemplo n.º 10
0
        private void Click(SfbEntryWrapper wrapper)
        {
            RuntimePlatform rp = Application.platform;
            bool isMac = (rp == RuntimePlatform.OSXEditor || rp == RuntimePlatform.OSXPlayer || rp == RuntimePlatform.OSXWebPlayer);
            bool ctrl = isMac
                            ? fileBrowser.GetHeldKeys().Contains(KeyCode.LeftCommand) || fileBrowser.GetHeldKeys().Contains(KeyCode.RightCommand)
                            : fileBrowser.GetHeldKeys().Any(a => a == KeyCode.LeftControl || a == KeyCode.RightControl);

            if (clickStopwatch.ElapsedMilliseconds < fileBrowser.settings.DoubleClickTime) {
                DoubleClick(wrapper);
                clickStopwatch = Stopwatch.StartNew();
                return;
            }

            clickStopwatch = Stopwatch.StartNew();
            if (ctrl) {
                wrapper.Selected = !wrapper.Selected;
                if (wrapper.Selected) {
                    lastClickedWrapper = wrapper;
                }
            }
            else if (fileBrowser.GetHeldKeys().Any(a => a == KeyCode.LeftShift || a == KeyCode.RightShift)) {
                if (lastClickedWrapper != null && lastClickedWrapper.Selected) {
                    GetChildRange(wrapper, lastClickedWrapper).ForEach(a => a.Selected = true);
                }
            }
            else {
                lastClickedWrapper = wrapper;
                bool newState = true;

                if (wrappers.Count(a => a.BrowserEntry != null && a.Selected) <= 1) {
                    newState = !wrapper.Selected;
                }

                fileBrowser.DeselectAllEntries();
                wrapper.Selected = newState;

                fileBrowser.SelectedEntry(wrapper.fileSystemEntry);
            }
        }
Exemplo n.º 11
0
        private SfbEntry BrowserEntryFromFileSystemEntry(SfbEntryWrapper wrapper)
        {
            GameObject go = Instantiate(entryPrefabs.First(a => a.type == wrapper.fileSystemEntry.type.Convert()).gameObject);
            go.name = wrapper.fileSystemEntry.name.Replace("/", "\\");
            go.transform.SetParent(wrapper.transform, false);

            go.GetComponentInChildren<Text>().text = wrapper.fileSystemEntry.name;

            if (wrapper.fileSystemEntry.hidden) {
                Image[] images = go.GetComponentsInChildren<Image>();
                if (images.Length >= 2) {
                    images[1].color = new Color(images[1].color.r, images[1].color.g, images[1].color.b,
                                                fileBrowser.settings.HiddenOpacity);
                }
                Text text = go.GetComponentInChildren<Text>();
                if (text != null) {
                    text.color = new Color(text.color.r, text.color.g, text.color.b, fileBrowser.settings.HiddenOpacity);
                }
            }

            var entry = go.GetComponent<SfbEntry>();
            entry.fileSystemEntry = wrapper.fileSystemEntry;
            entry.wrapper = wrapper;

            return entry;
        }