Beispiel #1
0
        private UnityEngine.Texture GetIcon(CoilListData coilListData)
        {
            Texture2D icon = null;

            switch (coilListData.Destination)
            {
            case CoilDestination.Playfield:
            {
                if (_coils.ContainsKey(coilListData.PlayfieldItem.ToLower()))
                {
                    icon = Icons.ByComponent(_coils[coilListData.PlayfieldItem.ToLower()], size: IconSize.Small);
                }
                break;
            }
            }

            return(icon);
        }
Beispiel #2
0
        private void RenderId(ref string id, Action <string> setId, CoilListData coilListData, Rect cellRect, Action <CoilListData> updateAction)
        {
            // add some padding
            cellRect.x     += 2;
            cellRect.width -= 4;

            var options = new List <string>(_gleCoils.Select(entry => entry.Id).ToArray());

            if (options.Count > 0)
            {
                options.Add("");
            }

            options.Add("Add...");

            EditorGUI.BeginChangeCheck();
            var index = EditorGUI.Popup(cellRect, options.IndexOf(id), options.ToArray());

            if (EditorGUI.EndChangeCheck())
            {
                if (index == options.Count - 1)
                {
                    PopupWindow.Show(cellRect, new ManagerListTextFieldPopup("ID", "", newId => {
                        if (_gleCoils.Exists(entry => entry.Id == newId))
                        {
                            _gleCoils.Add(new GamelogicEngineCoil
                            {
                                Id = newId
                            });
                        }

                        setId(newId);
                        updateAction(coilListData);
                    }));
                }
                else
                {
                    setId(_gleCoils[index].Id);
                    updateAction(coilListData);
                }
            }
        }
Beispiel #3
0
        private void RenderPlayfieldElement(TableAuthoring tableAuthoring, CoilListData coilListData, Rect cellRect, Action <CoilListData> updateAction)
        {
            if (GUI.Button(cellRect, coilListData.PlayfieldItem, EditorStyles.objectField) || GUI.Button(cellRect, "", GUI.skin.GetStyle("IN ObjectField")))
            {
                if (_itemPickDropdownState == null)
                {
                    _itemPickDropdownState = new AdvancedDropdownState();
                }

                var dropdown = new ItemSearchableDropdown <ICoilAuthoring>(
                    _itemPickDropdownState,
                    tableAuthoring,
                    "Coil Items",
                    item => {
                    coilListData.PlayfieldItem = item.Name;
                    updateAction(coilListData);
                }
                    );
                dropdown.Show(cellRect);
            }
        }
Beispiel #4
0
        private void RenderElement(TableAuthoring tableAuthoring, CoilListData coilListData, Rect cellRect, Action <CoilListData> updateAction)
        {
            var icon = GetIcon(coilListData);

            if (icon != null)
            {
                var iconRect = cellRect;
                iconRect.width = 20;
                var guiColor = GUI.color;
                GUI.color = Color.clear;
                EditorGUI.DrawTextureTransparent(iconRect, icon, ScaleMode.ScaleToFit);
                GUI.color = guiColor;
            }

            cellRect.x     += 25;
            cellRect.width -= 25;

            switch (coilListData.Destination)
            {
            case CoilDestination.Playfield:
                RenderPlayfieldElement(tableAuthoring, coilListData, cellRect, updateAction);
                break;
            }
        }