Ejemplo n.º 1
0
        // when this is enabled and active
        private void OnEnable()
        {
            // set this instance

            // set the reference to the current inspected object
            _deckManagerEditor = DeckManagerEditor.instance;
        }
Ejemplo n.º 2
0
        // on enable
        private void OnEnable()
        {
            // set our target and editor instance
            instance    = this;
            deckManager = (DeckManager)target;

            // set up our reorderable lists
            _reorderableDeck = new ReorderableList(deckManager.deck, typeof(Card), true, true, true, true);
            _reorderableDeck.drawElementCallback  += DrawDeckElement;
            _reorderableDeck.onSelectCallback     += SelectCard;
            _reorderableDeck.onAddDropdownCallback = DrawGenericMenu;
            _reorderableDeck.onRemoveCallback      = RemoveCard;
            _reorderableDeck.drawHeaderCallback   += DrawHeader;

            _reorderableDiscardPile = new ReorderableList(deckManager.discardPile, typeof(Card), true, true, true, true);
            _reorderableDiscardPile.drawElementCallback  += DrawDiscardPileElement;
            _reorderableDiscardPile.onSelectCallback     += SelectCard;
            _reorderableDiscardPile.onAddDropdownCallback = DrawGenericMenu;
            _reorderableDiscardPile.onRemoveCallback      = RemoveCard;
            _reorderableDiscardPile.drawHeaderCallback   += DrawHeader;

            _reorderableInUsePile = new ReorderableList(deckManager.inUsePile, typeof(Card), true, true, true, true);
            _reorderableInUsePile.drawElementCallback  += DrawInUsePileElement;
            _reorderableInUsePile.onSelectCallback     += SelectCard;
            _reorderableInUsePile.onAddDropdownCallback = DrawGenericMenu;
            _reorderableInUsePile.onRemoveCallback      = RemoveCard;
            _reorderableInUsePile.drawHeaderCallback   += DrawHeader;
        }
Ejemplo n.º 3
0
        private static void Init()
        {
            // get existing open window or if none, make a new one
            DeckShuffleOptionsEditor window = (DeckShuffleOptionsEditor)EditorWindow.GetWindow(typeof(DeckShuffleOptionsEditor), false, "Deck Options");

            window.Show();

            // set the reference to the current inspected object
            _deckManagerEditor = DeckManagerEditor.instance;
        }
Ejemplo n.º 4
0
        private static void Init()
        {
            // get existing open window or if none, make a new one
            var window = (CardEditor)EditorWindow.GetWindow(typeof(CardEditor), false, "Card Editor");

            window.minSize = new Vector2(325, 140);
            window.Show();

            // set the reference to the current inspected object
            _deckManagerEditor = DeckManagerEditor.instance;
        }
Ejemplo n.º 5
0
        // draw the ui
        private void OnGUI()
        {
            // header styles
            var styleRowHeader = new GUIStyle
            {
                padding = new RectOffset(0, 0, 3, 3),
                normal  = { background = SetBackground(1, 1, new Color(0.1f, 0.1f, 0.1f, 0.2f)) }
            };

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal(styleRowHeader);
            EditorGUILayout.LabelField("Edit Selected Card", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();

            // inform our user no card is selected;
            if (!blnEditingCardFromDeck && !blnEditingCardFromDiscard && !blnEditingCardFromInUse)
            {
                try
                {
                    EditorGUILayout.HelpBox(
                        "There is no card currently selected. Please select a card from the Deck Manager to edit.",
                        MessageType.Info);
                }
                catch
                {
                    return;
                }
            }

            // if the deck manager editor is null
            if (_deckManagerEditor == null)
            {
                // try and find a reference to the deck manager editor
                if (DeckManagerEditor.instance)
                {
                    _deckManagerEditor = DeckManagerEditor.instance;
                }
                else
                {
                    blnEditingCardFromDeck    = false;
                    blnEditingCardFromDiscard = false;
                    blnEditingCardFromInUse   = false;
                    return;
                }
            }

            // if we are editing the card
            if (blnEditingCardFromDeck)
            {
                DrawFields(_deckManagerEditor.deckManager.deck);
            }
            else if (blnEditingCardFromDiscard)
            {
                DrawFields(_deckManagerEditor.deckManager.discardPile);
            }
            else if (blnEditingCardFromInUse)
            {
                DrawFields(_deckManagerEditor.deckManager.inUsePile);
            }

            EditorGUILayout.Space();
        }
Ejemplo n.º 6
0
        // draw the ui
        private void OnGUI()
        {
            EditorGUILayout.Space();

            // if the deck manager editor is empty
            if (_deckManagerEditor == null)
            {
                // try and find a reference to the deck manager editor
                if (DeckManagerEditor.instance)
                {
                    _deckManagerEditor = DeckManagerEditor.instance;
                }
                else
                {
                    // if there isn't display a warning
                    EditorGUILayout.HelpBox("No instance of the Deck Manager found. Please make sure you have an object selected with the Deck Manager script attached to it.", MessageType.Info);
                    EditorGUILayout.Space();
                    return;
                }
            }

            // header styles
            var styleRowHeader = new GUIStyle
            {
                padding = new RectOffset(0, 0, 3, 3),
                normal  = { background = SetBackground(1, 1, new Color(0.1f, 0.1f, 0.1f, 0.2f)) }
            };

            _mVecScrollPos = EditorGUILayout.BeginScrollView(_mVecScrollPos);

            EditorGUILayout.BeginHorizontal(styleRowHeader);
            EditorGUILayout.LabelField("Shuffle Individual Decks", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            // shuffle the deck
            if (GUILayout.Button("Deck"))
            {
                Undo.RecordObjects(_deckManagerEditor.targets, "Deck shuffled.");
                _deckManagerEditor.deckManager.ShuffleDeck();
                PrefabUtility.RecordPrefabInstancePropertyModifications(_deckManagerEditor.target);
            }

            // shuffle the discard pile
            if (GUILayout.Button("Discard Pile"))
            {
                Undo.RecordObjects(_deckManagerEditor.targets, "Discard pile shuffled.");
                _deckManagerEditor.deckManager.ShuffleDiscardPile();
                PrefabUtility.RecordPrefabInstancePropertyModifications(_deckManagerEditor.target);
            }

            // shuffle the in use pile
            if (GUILayout.Button("In Use Pile"))
            {
                Undo.RecordObjects(_deckManagerEditor.targets, "In use pile shuffled.");
                _deckManagerEditor.deckManager.ShuffleInUsePile();
                PrefabUtility.RecordPrefabInstancePropertyModifications(_deckManagerEditor.target);
            }

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal(styleRowHeader);
            EditorGUILayout.LabelField("Shuffle Decks Together", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Deck with:");

            // shuffle the deck with the discard pile
            if (GUILayout.Button("Discard Pile"))
            {
                Undo.RecordObjects(_deckManagerEditor.targets, "Deck shuffled with discard pile.");
                _deckManagerEditor.deckManager.ShuffleDecksTogether(_deckManagerEditor.deckManager.deck, _deckManagerEditor.deckManager.discardPile);
                PrefabUtility.RecordPrefabInstancePropertyModifications(_deckManagerEditor.target);
            }

            // shuffle the deck with the in use pile
            if (GUILayout.Button("In Use Pile"))
            {
                Undo.RecordObjects(_deckManagerEditor.targets, "Deck shuffled with in use pile.");
                _deckManagerEditor.deckManager.ShuffleDecksTogether(_deckManagerEditor.deckManager.deck, _deckManagerEditor.deckManager.inUsePile);
                PrefabUtility.RecordPrefabInstancePropertyModifications(_deckManagerEditor.target);
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Discard Pile with:");

            // shuffle the discard and deck
            if (GUILayout.Button("Deck"))
            {
                Undo.RecordObjects(_deckManagerEditor.targets, "Discard pile shuffled with deck.");
                _deckManagerEditor.deckManager.ShuffleDecksTogether(_deckManagerEditor.deckManager.discardPile, _deckManagerEditor.deckManager.deck);
                PrefabUtility.RecordPrefabInstancePropertyModifications(_deckManagerEditor.target);
            }

            // shuffle the discard and in use pile
            if (GUILayout.Button("In Use Pile"))
            {
                Undo.RecordObjects(_deckManagerEditor.targets, "Discard pile shuffled with in use pile.");
                _deckManagerEditor.deckManager.ShuffleDecksTogether(_deckManagerEditor.deckManager.discardPile, _deckManagerEditor.deckManager.inUsePile);
                PrefabUtility.RecordPrefabInstancePropertyModifications(_deckManagerEditor.target);
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("In Use Pile with:");

            // shuffle the in use pile and deck
            if (GUILayout.Button("Deck"))
            {
                Undo.RecordObjects(_deckManagerEditor.targets, "In use pile shuffled with deck.");
                _deckManagerEditor.deckManager.ShuffleDecksTogether(_deckManagerEditor.deckManager.inUsePile, _deckManagerEditor.deckManager.deck);
                PrefabUtility.RecordPrefabInstancePropertyModifications(_deckManagerEditor.target);
            }

            // shuffle the in use pile and discard pile
            if (GUILayout.Button("Discard Pile"))
            {
                Undo.RecordObjects(_deckManagerEditor.targets, "In use pile shuffled with discard pile.");
                _deckManagerEditor.deckManager.ShuffleDecksTogether(_deckManagerEditor.deckManager.inUsePile, _deckManagerEditor.deckManager.discardPile);
                PrefabUtility.RecordPrefabInstancePropertyModifications(_deckManagerEditor.target);
            }

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal(styleRowHeader);
            EditorGUILayout.LabelField("Shuffle To Top Deck", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("To Top of Deck");

            // shuffle the discard pile and add it to the top of the deck
            if (GUILayout.Button("Discard Pile"))
            {
                Undo.RecordObjects(_deckManagerEditor.targets, "Shuffled discard pile to top of deck.");
                _deckManagerEditor.deckManager.ShuffleToTopOfDeck(_deckManagerEditor.deckManager.discardPile, _deckManagerEditor.deckManager.deck);
                PrefabUtility.RecordPrefabInstancePropertyModifications(_deckManagerEditor.target);
            }

            // shuffle the in use pile and add it to the top of the deck
            if (GUILayout.Button("In Use Pile"))
            {
                Undo.RecordObjects(_deckManagerEditor.targets, "Shuffled in use pile to top of deck.");
                _deckManagerEditor.deckManager.ShuffleToTopOfDeck(_deckManagerEditor.deckManager.inUsePile, _deckManagerEditor.deckManager.deck);
                PrefabUtility.RecordPrefabInstancePropertyModifications(_deckManagerEditor.target);
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("To Top of Discard Pile");

            // shuffle the deck and add it to the top of the discard pile
            if (GUILayout.Button("Deck"))
            {
                Undo.RecordObjects(_deckManagerEditor.targets, "Shuffled deck to top of discard pile.");
                _deckManagerEditor.deckManager.ShuffleToTopOfDeck(_deckManagerEditor.deckManager.deck, _deckManagerEditor.deckManager.discardPile);
                PrefabUtility.RecordPrefabInstancePropertyModifications(_deckManagerEditor.target);
            }

            // shuffle the in use pile and add it to the top of the discard pile
            if (GUILayout.Button("In Use Pile"))
            {
                Undo.RecordObjects(_deckManagerEditor.targets, "Shuffled in use pile to top of discard pile.");
                _deckManagerEditor.deckManager.ShuffleToTopOfDeck(_deckManagerEditor.deckManager.inUsePile, _deckManagerEditor.deckManager.discardPile);
                PrefabUtility.RecordPrefabInstancePropertyModifications(_deckManagerEditor.target);
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("To Top of In Use Pile");

            // shuffle the deck and add it to the top of the in use pile
            if (GUILayout.Button("Deck"))
            {
                Undo.RecordObjects(_deckManagerEditor.targets, "Shuffled deck to top of in use pile.");
                _deckManagerEditor.deckManager.ShuffleToTopOfDeck(_deckManagerEditor.deckManager.deck, _deckManagerEditor.deckManager.inUsePile);
                PrefabUtility.RecordPrefabInstancePropertyModifications(_deckManagerEditor.target);
            }

            // shuffle the discard pile and add it to the top of the in use pile
            if (GUILayout.Button("Discard Pile"))
            {
                Undo.RecordObjects(_deckManagerEditor.targets, "Shuffled discard pile to top of in use pile.");
                _deckManagerEditor.deckManager.ShuffleToTopOfDeck(_deckManagerEditor.deckManager.discardPile, _deckManagerEditor.deckManager.inUsePile);
                PrefabUtility.RecordPrefabInstancePropertyModifications(_deckManagerEditor.target);
            }

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal(styleRowHeader);
            EditorGUILayout.LabelField("Shuffle To Bottom of Deck", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("To Bottom of Deck");

            // shuffle the discard pile and add it to the bottom of the deck
            if (GUILayout.Button("Discard Pile"))
            {
                Undo.RecordObjects(_deckManagerEditor.targets, "Shuffled discard pile to bottom of deck.");
                _deckManagerEditor.deckManager.ShuffleToBottomOfDeck(_deckManagerEditor.deckManager.discardPile, _deckManagerEditor.deckManager.deck);
                PrefabUtility.RecordPrefabInstancePropertyModifications(_deckManagerEditor.target);
            }

            // shuffle the in use pile and add it to the bottom of the deck
            if (GUILayout.Button("In Use Pile"))
            {
                Undo.RecordObjects(_deckManagerEditor.targets, "Shuffled in use pile to bottom of deck.");
                _deckManagerEditor.deckManager.ShuffleToBottomOfDeck(_deckManagerEditor.deckManager.inUsePile, _deckManagerEditor.deckManager.deck);
                PrefabUtility.RecordPrefabInstancePropertyModifications(_deckManagerEditor.target);
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("To Bottom of Discard Pile");

            // shuffle the deck and add it to the bottom of the discard pile
            if (GUILayout.Button("Deck"))
            {
                Undo.RecordObjects(_deckManagerEditor.targets, "Shuffled deck to bottom of discard pile.");
                _deckManagerEditor.deckManager.ShuffleToBottomOfDeck(_deckManagerEditor.deckManager.deck, _deckManagerEditor.deckManager.discardPile);
                PrefabUtility.RecordPrefabInstancePropertyModifications(_deckManagerEditor.target);
            }

            // shuffle the in use pile and add it to the bottom of the discard pile
            if (GUILayout.Button("In Use Pile"))
            {
                Undo.RecordObjects(_deckManagerEditor.targets, "Shuffled in use pile to bottom of discard pile.");
                _deckManagerEditor.deckManager.ShuffleToBottomOfDeck(_deckManagerEditor.deckManager.inUsePile, _deckManagerEditor.deckManager.discardPile);
                PrefabUtility.RecordPrefabInstancePropertyModifications(_deckManagerEditor.target);
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("To Bottom of In Use Pile");

            // shuffle the deck and add it to the bottom of the in use pile
            if (GUILayout.Button("Deck"))
            {
                Undo.RecordObjects(_deckManagerEditor.targets, "Shuffled deck to bottom of in use pile.");
                _deckManagerEditor.deckManager.ShuffleToBottomOfDeck(_deckManagerEditor.deckManager.deck, _deckManagerEditor.deckManager.inUsePile);
                PrefabUtility.RecordPrefabInstancePropertyModifications(_deckManagerEditor.target);
            }

            // shuffle the discard pile and add it to the bottom of the in use pile
            if (GUILayout.Button("Discard Pile"))
            {
                Undo.RecordObjects(_deckManagerEditor.targets, "Shuffled discard pile to bottom of in use pile.");
                _deckManagerEditor.deckManager.ShuffleToBottomOfDeck(_deckManagerEditor.deckManager.discardPile, _deckManagerEditor.deckManager.inUsePile);
                PrefabUtility.RecordPrefabInstancePropertyModifications(_deckManagerEditor.target);
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.EndScrollView();
        }
Ejemplo n.º 7
0
 // on destroy
 private void OnDestroy()
 {
     // remove the reference to this editor
     instance = null;
 }
Ejemplo n.º 8
0
        // override our inspector interface
        public override void OnInspectorGUI()
        {
            // update serialized object representation
            serializedObject.Update();

            // if the instance is empty
            if (instance == null)
            {
                // set this instance
                instance = this;
            }

            // GUI STYLES

            // header styles
            var styleRowHeader = new GUIStyle
            {
                padding = new RectOffset(0, 0, 3, 3),
                normal  = { background = SetBackground(1, 1, new Color(0.1f, 0.1f, 0.1f, 0.2f)) }
            };

            // EDITOR

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal(styleRowHeader);
            EditorGUILayout.LabelField("Tools and Options", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            // open the card editor window
            if (GUILayout.Button("Open Card Editor Window"))
            {
                // get existing open window or if none, make a new one
                var window = (CardEditor)EditorWindow.GetWindow(typeof(CardEditor), false, "Card Editor");
                window.minSize = new Vector2(325, 140);
                window.Show();
            }

            // get existing open window or if none, make a new one
            if (GUILayout.Button("Open Deck Shuffle Options"))
            {
                var window = (DeckShuffleOptionsEditor)EditorWindow.GetWindow(typeof(DeckShuffleOptionsEditor), false, "Deck Options");
                window.Show();
            }

            // remove everything and create a new standard deck
            if (GUILayout.Button("Generate a New Deck"))
            {
                RemoveAllAndCreateNew();
            }

            // remove everything
            if (GUILayout.Button("Remove All Cards"))
            {
                RemoveAll();
            }

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal(styleRowHeader);
            EditorGUILayout.LabelField("Deck / Discard Pile / In Use Pile", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            // if the deck panel is expanded try and show our reorderable list
            deckManager.blnExpandDeckPnl = EditorGUILayout.Foldout(deckManager.blnExpandDeckPnl, "Deck [" + deckManager.deck.Count + "]");
            if (deckManager.blnExpandDeckPnl)
            {
                try
                {
                    _reorderableDeck.DoLayoutList();
                }
                catch
                {
                    return;
                }
            }

            // if the discard panel is expanded try and show our reorderable list
            deckManager.blnExpandDiscardPnl = EditorGUILayout.Foldout(deckManager.blnExpandDiscardPnl, "Discard Pile [" + deckManager.discardPile.Count + "]");
            if (deckManager.blnExpandDiscardPnl)
            {
                try
                {
                    _reorderableDiscardPile.DoLayoutList();
                }
                catch
                {
                    return;
                }
            }

            // if the in use panel is expanded try and show our reorderable list
            deckManager.blnExpandInUsePnl = EditorGUILayout.Foldout(deckManager.blnExpandInUsePnl, "In Use Pile [" + deckManager.inUsePile.Count + "]");
            if (deckManager.blnExpandInUsePnl)
            {
                try
                {
                    _reorderableInUsePile.DoLayoutList();
                }
                catch
                {
                    return;
                }
            }

            EditorGUILayout.Space();

            // apply property modifications
            serializedObject.ApplyModifiedProperties();
        }