public override void CsvToList()
        {
            StreamReader sr = new StreamReader(File);

            while (!sr.EndOfStream)
            {
                string showLine = sr.ReadLine();
                ListToDisplay.Add(showLine);
            }

            sr.Close();
        }
        public override void CsvToList()
        {
            while (true)
            {
                Console.WriteLine("\nHow many movies would you like to display?");
                string userInput = Console.ReadLine();
                int    userInputNumber;

                if (int.TryParse(userInput, out userInputNumber))
                {
                    StreamReader sr = new StreamReader(File);
                    for (int i = 0; i < userInputNumber; i++)
                    {
                        string movieLine = sr.ReadLine();
                        ListToDisplay.Add(movieLine);
                    }

                    sr.Close();
                    break;
                }

                Console.WriteLine("Please enter a number");
            }
        }
Пример #3
0
 public void SetListToDisplay(ListToDisplay t)
 {
     _currentListDisplayed = t;
 }
Пример #4
0
 public void SetListToDisplay(ListToDisplay t)
 {
     _currentListDisplayed = t;
 }
Пример #5
0
        private void DisplayOneItem(Object toDisplay, string nameInListPath, int index, float width, bool disable)
        {
            if (toDisplay == null && string.IsNullOrEmpty(nameInListPath))
            {
                return;
            }

            if (toDisplay == null && !UnityEssentialsPreferences.GetBool(UnityEssentialsPreferences.SHOW_GAMEOBJECTS_FROM_OTHER_SCENE, true))
            {
                return;
            }

            GUI.color = (PeekSerializeObject.LastSelectedObject == toDisplay && toDisplay != null) ? Color.green : Color.white;

            EditorGUI.BeginDisabledGroup(disable);
            {
                using (HorizontalScope horizontalScope = new HorizontalScope(GUILayout.Width(width), GUILayout.Height(_heightLine)))
                {
                    float widthExtent = CalculateWidthExtentOptions.CalculateWidthExtent(width, index, ListToDisplay.arraySize);
                    float widthButtonWithoutExtent = CalculateWidthExtentOptions.CalculateButtonWidthWithoutExtent(widthExtent, _heightLine, _margin);

                    if (_calculateExtent)
                    {
                        GUILayout.Label("", GUILayout.Width(widthExtent), GUILayout.Height(_heightLine));
                    }
                    //display bookmark button
                    bool clicOnBookMark = BookMarkButtonOptions.ButtonImageWithHover(WIDTH_BUTTON_HOVER, toDisplay != null, _heightLine);
                    if (clicOnBookMark)
                    {
                        OnBookMarkClic?.Invoke(index);
                        return;
                    }
                    //display main logo
                    DisplayLogoByTypeOfObject(toDisplay, _heightLine);
                    if (!disable && !_dragSettings.IsDragging)
                    {
                        Rect logoContent = GUILayoutUtility.GetLastRect();
                        if (logoContent.Contains(Event.current.mousePosition))
                        {
                            EditorGUIUtility.AddCursorRect(logoContent, MouseCursor.MoveArrow);
                            if (Event.current.type == EventType.MouseDown)
                            {
                                _listToDisplayCopy = ListToDisplay.ToObjectList();
                                _dragSettings.StartDragging(index, logoContent);
                                Event.current.Use();
                            }
                        }
                    }
                    //display main button
                    EditorGUI.BeginDisabledGroup(toDisplay == null);
                    {
                        string nameObjectToSelect;
                        if (toDisplay == null)
                        {
                            nameObjectToSelect = !string.IsNullOrEmpty(nameInListPath) ? ObjectNames.NicifyVariableName(nameInListPath) : " --- not found --- ";
                        }
                        else
                        {
                            nameObjectToSelect = ObjectNames.NicifyVariableName(toDisplay.name);
                        }


                        GUIContent buttonSelectContent = ShortenNameIfNeeded(nameObjectToSelect, width, widthButtonWithoutExtent);
                        buttonSelectContent.tooltip = "Clic to select, Right clic to Pin only";
                        if (GUILayout.Button(buttonSelectContent, BookMarkButtonOptions.GuiStyle, GUILayout.ExpandWidth(true), GUILayout.Height(_heightLine)))
                        {
                            if (Event.current.button == 0)
                            {
                                OnSelectItem?.Invoke(index);
                            }
                            else
                            {
                                OnPinItem?.Invoke(index);
                            }
                            return;
                        }
                    }
                    EditorGUI.EndDisabledGroup();

                    //display special scene buttons
                    if (toDisplay == null && OnInfoItem != null)
                    {
                        bool selectScene = false;
                        bool goToScene   = false;

                        DisplaySpecialSceneSettings(ref selectScene, ref goToScene);
                        if (goToScene)
                        {
                            OnInfoForceItem?.Invoke(index);
                            return;
                        }
                        else if (selectScene)
                        {
                            OnInfoItem?.Invoke(index);
                            return;
                        }
                    }

                    //display delete button
                    GUIContent buttonDeletContent = EditorGUIUtility.IconContent(DELETE_ICON);
                    buttonDeletContent.tooltip = "Remove from list";
                    if (GUILayout.Button(buttonDeletContent, BookMarkButtonOptions.GuiStyle, GUILayout.ExpandWidth(false), GUILayout.MaxWidth(WIDTH_BUTTON_HOVER), GUILayout.Height(_heightLine)) &&
                        Event.current.button == 0)
                    {
                        OnRemoveItem?.Invoke(index);
                        return;
                    }
                    if (_calculateExtent)
                    {
                        GUILayout.Label("", GUILayout.Width(widthExtent), GUILayout.Height(_heightLine));
                    }
                }
            }
            EditorGUI.EndDisabledGroup();
        }
Пример #6
0
        public void Display()
        {
            float widthEditorWindow = _peekWindow.position.width;
            //float widthWithoutScrollBar = widthEditorWindow - SIZE_SCROLL_BAR;
            float widthScope = widthEditorWindow - SIZE_SCROLL_BAR * 2;

            if (ExtGUILayout.Section(_listDescription, _iconList, true, _foldStateKey, 0))
            {
                return;
            }
            _dragSettings.SaveFirstItemPosition(_heightLine, _margin);

            Color oldColor = GUI.color;

            _dragSettings.CalculateEmptyCellIndexBasedOnPosition(_heightLine, _margin);


            if (_dragSettings.IsDragging && _dragSettings.CurrentIndexShouldPointEmptyCell == ListToDisplay.arraySize)
            {
                DisplayEmptyCellItem(widthScope);
                _dragSettings.RealDropIndex = ListToDisplay.arraySize - 1;
                GUI.color = oldColor;
            }

            for (int i = ListToDisplay.arraySize - 1; i >= 0; i--)
            {
                if (_dragSettings.IsDragging && i == _dragSettings.CurrentIndexSelected)
                {
                    if (i == _dragSettings.CurrentIndexShouldPointEmptyCell)
                    {
                        DisplayEmptyCellItem(widthScope);
                        _dragSettings.RealDropIndex = i;
                    }
                    continue;
                }
                string nameToShow = ListToDisplayPath?.GetArrayElementAtIndex(i).stringValue;
                if (SceneLinkedPath != null && SceneLinkedPath.GetArrayElementAtIndex(i).GetCustomObject() != null)
                {
                    nameToShow = SceneLinkedPath.GetArrayElementAtIndex(i).GetCustomObject().name + "/" + nameToShow;
                }
                DisplayOneItem(ListToDisplay.GetArrayElementAtIndex(i).GetCustomObject(), nameToShow, i, widthScope, false);
                if (_dragSettings.IsDragging && i == _dragSettings.CurrentIndexShouldPointEmptyCell)
                {
                    DisplayEmptyCellItem(widthScope);
                    _dragSettings.RealDropIndex = i - (_dragSettings.CurrentIndexSelected < i ? 1 : 0);
                }

                GUI.color = oldColor;
            }

            _dragSettings.SaveLastItemPosition();
            _dragSettings.SetHowManyCellAreDisplayed(ListToDisplay.arraySize);

            ClearList(widthScope, OnClear);



            if (_dragSettings.CanReorder && _dragSettings.IsDragging)
            {
                IsDraggingItem(ListToDisplay.GetArrayElementAtIndex(_dragSettings.CurrentIndexSelected).GetCustomObject(), ListToDisplayPath?.GetArrayElementAtIndex(_dragSettings.CurrentIndexSelected).stringValue, _dragSettings.CurrentIndexSelected);
                GUI.color = oldColor;
            }
        }