Ejemplo n.º 1
0
        public void Render(TableAuthoring tableAuthoring, CoilListData data, Rect cellRect, int column, Action <CoilListData> updateAction)
        {
            switch ((CoilListColumn)column)
            {
            case CoilListColumn.Id:
                RenderId(ref data.Id, id => data.Id = id, data, cellRect, updateAction);
                break;

            case CoilListColumn.Description:
                RenderDescription(data, cellRect, updateAction);
                break;

            case CoilListColumn.Destination:
                RenderDestination(data, cellRect, updateAction);
                break;

            case CoilListColumn.Element:
                RenderElement(tableAuthoring, data, cellRect, updateAction);
                break;

            case CoilListColumn.Type:
                RenderType(data, cellRect, updateAction);
                break;

            case CoilListColumn.HoldCoilId:
                if (data.Type == CoilType.DualWound)
                {
                    RenderId(ref data.HoldCoilId, id => data.HoldCoilId = id, data, cellRect, updateAction);
                }
                break;
            }
        }
Ejemplo n.º 2
0
        public void Render(TableAuthoring tableAuthoring, SwitchListData data, Rect cellRect, int column, Action <SwitchListData> updateAction)
        {
            switch ((SwitchListColumn)column)
            {
            case SwitchListColumn.ID:
                RenderID(data, cellRect, updateAction);
                break;

            case SwitchListColumn.Description:
                RenderDescription(data, cellRect, updateAction);
                break;

            case SwitchListColumn.Source:
                RenderSource(data, cellRect, updateAction);
                break;

            case SwitchListColumn.Element:
                RenderElement(tableAuthoring, data, cellRect, updateAction);
                break;

            case SwitchListColumn.Type:
                RenderType(data, cellRect, updateAction);
                break;

            case SwitchListColumn.Off:
                RenderOff(data, cellRect, updateAction);
                break;
            }
        }
Ejemplo n.º 3
0
 public ItemSearchableDropdown(AdvancedDropdownState state, TableAuthoring tableAuthoring, string title, Action <T> onElementSelected) : base(state)
 {
     _onElementSelected = onElementSelected;
     _tableAuthoring    = tableAuthoring;
     minimumSize        = new Vector2(200, 300);
     _title             = title;
 }
Ejemplo n.º 4
0
        public void Render(TableAuthoring tableAuthoring, SwitchListData data, Rect cellRect, int column, Action <SwitchListData> updateAction)
        {
            switch ((SwitchListColumn)column)
            {
            case SwitchListColumn.Id:
                RenderId(data, cellRect, updateAction);
                break;

            case SwitchListColumn.Description:
                RenderDescription(data, cellRect, updateAction);
                break;

            case SwitchListColumn.Source:
                RenderSource(data, cellRect, updateAction);
                break;

            case SwitchListColumn.Element:
                RenderElement(tableAuthoring, data, cellRect, updateAction);
                break;

            case SwitchListColumn.PulseDelay:
                RenderPulseDelay(data, cellRect, updateAction);
                break;
            }
        }
        private void RenderDestinationElement(TableAuthoring tableAuthoring, WireListData wireListData, Rect cellRect, Action <WireListData> updateAction)
        {
            var icon = GetDestinationIcon(wireListData);

            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 (wireListData.Destination)
            {
            case CoilDestination.Playfield:
                RenderDestinationElementPlayfield(tableAuthoring, wireListData, cellRect, updateAction);
                break;

            case CoilDestination.Device:
                cellRect.width = cellRect.width / 2f - 5f;
                RenderDestinationElementDevice(tableAuthoring, wireListData, cellRect, updateAction);
                cellRect.x += cellRect.width + 10f;
                RenderDestinationElementDeviceItem(wireListData, cellRect, updateAction);
                break;
            }
        }
Ejemplo n.º 6
0
        private void RenderElement(TableAuthoring tableAuthoring, SwitchListData switchListData, Rect cellRect, Action <SwitchListData> updateAction)
        {
            var icon = GetIcon(switchListData);

            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 (switchListData.Source)
            {
            case SwitchSource.InputSystem:
                RenderInputSystemElement(switchListData, cellRect, updateAction);
                break;

            case SwitchSource.Playfield:
                RenderPlayfieldElement(tableAuthoring, switchListData, cellRect, updateAction);
                break;

            case SwitchSource.Constant:
                RenderConstantElement(switchListData, cellRect, updateAction);
                break;
            }
        }
        public void Render(TableAuthoring tableAuthoring, WireListData data, Rect cellRect, int column, Action <WireListData> updateAction)
        {
            switch ((WireListColumn)column)
            {
            case WireListColumn.Description:
                RenderDescription(data, cellRect, updateAction);
                break;

            case WireListColumn.Source:
                RenderSource(data, cellRect, updateAction);
                break;

            case WireListColumn.SourceElement:
                RenderSourceElement(tableAuthoring, data, cellRect, updateAction);
                break;

            case WireListColumn.Destination:
                RenderDestination(data, cellRect, updateAction);
                break;

            case WireListColumn.DestinationElement:
                RenderDestinationElement(tableAuthoring, data, cellRect, updateAction);
                break;

            case WireListColumn.PulseDelay:
                RenderPulseDelay(data, cellRect, updateAction);
                break;
            }
        }
Ejemplo n.º 8
0
 private void OnEnable()
 {
     _mpfEngine = target as MpfGamelogicEngine;
     if (_mpfEngine != null)
     {
         _tableAuthoring = _mpfEngine.gameObject.GetComponentInParent <TableAuthoring>();
     }
 }
Ejemplo n.º 9
0
        protected override void SetTable(TableAuthoring table)
        {
            if (_layerHandler == null)
            {
                _layerHandler = new LayerHandler();
            }

            _layerHandler.SetTable(table);
        }
Ejemplo n.º 10
0
 private void OnTableSelected(object sender, EventArgs e)
 {
     if (!_windowLocked)
     {
         _tableAuthoring = TableSelector.Instance.SelectedTable;
         SetTable(_tableAuthoring);
         Repaint();
     }
 }
Ejemplo n.º 11
0
 protected override void SetTable(TableAuthoring table)
 {
     _data.Clear();
     if (_table != null)
     {
         _data = CollectData();
     }
     _listView = new ManagerListView <T>(_treeViewState, _data, ItemSelected);
 }
Ejemplo n.º 12
0
 protected void FindTable()
 {
     SetTableFromSelection();
     if (_tableAuthoring == null)
     {
         // nothing was selected, just use the first found table
         _tableAuthoring = FindObjectOfType <TableAuthoring>();
         SetTable(_tableAuthoring);
     }
 }
Ejemplo n.º 13
0
 private void FindTable()
 {
     _table = FindObjectOfType <TableAuthoring>();
     _data.Clear();
     if (_table != null)
     {
         _data = CollectData();
     }
     _listView = new ManagerListView <T>(_treeViewState, _data, ItemSelected);
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Populates the layer data from the given table
        /// </summary>
        /// <param name="tableAuthoring"></param>
        public void SetTable(TableAuthoring tableAuthoring)
        {
            var tableChanged = _tableAuthoring != tableAuthoring;

            _tableAuthoring = tableAuthoring;
            _layers.Clear();
            Rebuild();
            if (tableChanged)
            {
                TableChanged?.Invoke();
            }
        }
Ejemplo n.º 15
0
        protected void SetTableFromSelection()
        {
            if (Selection.activeGameObject == null)
            {
                return;
            }

            // check to see if the selection's table is different from the current one being used by this manager
            var selectedTable = Selection.activeGameObject.GetComponentInParent <TableAuthoring>();

            if (selectedTable != null)
            {
                _tableAuthoring = selectedTable;
                SetTable(selectedTable);
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// This is called by unity as part of the GUI pass, its an undocumented feature
        /// that gives us the ability to draw UI in the upper right of the tab bar, so we'll
        /// use it to add the little lock toggle just like inspectors
        /// </summary>
        /// <param name="position"></param>
        protected virtual void ShowButton(Rect position)
        {
            if (_lockButtonStyle == null)
            {
                _lockButtonStyle = "IN LockButton";                 // undocumented ui style for the tab bar lock button
            }
            bool wasLocked = _windowLocked;

            _windowLocked = GUI.Toggle(position, _windowLocked, GUIContent.none, _lockButtonStyle);
            if (wasLocked && !_windowLocked)
            {
                _tableAuthoring = TableSelector.Instance.SelectedTable;
                SetTable(_tableAuthoring);
                Repaint();
            }
        }
Ejemplo n.º 17
0
        protected virtual void OnEnable()
        {
#if UNITY_EDITOR
            // for convenience move item behavior to the top of the list
            // we're opting to due this here as opposed to at import time since modifying objects
            // in this way caused them to not be part of the created object undo stack
            if (target != null && target is MonoBehaviour mb)
            {
                int numComp = mb.GetComponents <MonoBehaviour>().Length;
                for (int i = 0; i <= numComp; i++)
                {
                    UnityEditorInternal.ComponentUtility.MoveComponentUp(mb);
                }
            }
#endif
            _table = (target as MonoBehaviour)?.gameObject.GetComponentInParent <TableAuthoring>();
            PopulateDropDownOptions();
        }
Ejemplo n.º 18
0
        private void RenderPlayfieldElement(TableAuthoring tableAuthoring, SwitchListData switchListData, Rect cellRect, Action <SwitchListData> updateAction)
        {
            if (GUI.Button(cellRect, switchListData.PlayfieldItem, EditorStyles.objectField) || GUI.Button(cellRect, "", GUI.skin.GetStyle("IN ObjectField")))
            {
                if (_itemPickDropdownState == null)
                {
                    _itemPickDropdownState = new AdvancedDropdownState();
                }

                var dropdown = new ItemSearchableDropdown <ISwitchableAuthoring>(
                    _itemPickDropdownState,
                    tableAuthoring,
                    "Switchable Items",
                    item => {
                    switchListData.PlayfieldItem = item.Name;
                    updateAction(switchListData);
                }
                    );
                dropdown.Show(cellRect);
            }
        }
        private void RenderSourceElementPlayfield(TableAuthoring tableAuthoring, WireListData wireListData, Rect cellRect, Action <WireListData> updateAction)
        {
            if (GUI.Button(cellRect, wireListData.SourcePlayfieldItem, EditorStyles.objectField) || GUI.Button(cellRect, "", GUI.skin.GetStyle("IN ObjectField")))
            {
                if (_sourceElementDeviceDropdownState == null)
                {
                    _sourceElementDeviceDropdownState = new AdvancedDropdownState();
                }

                var dropdown = new ItemSearchableDropdown <ISwitchAuthoring>(
                    _sourceElementDeviceDropdownState,
                    tableAuthoring,
                    "Switch Items",
                    item => {
                    wireListData.SourcePlayfieldItem = item.Name;
                    updateAction(wireListData);
                }
                    );
                dropdown.Show(cellRect);
            }
        }
        private void RenderDestinationElementDevice(TableAuthoring tableAuthoring, WireListData wireListData, Rect cellRect, Action <WireListData> updateAction)
        {
            if (GUI.Button(cellRect, wireListData.DestinationDevice, EditorStyles.objectField) || GUI.Button(cellRect, "", GUI.skin.GetStyle("IN ObjectField")))
            {
                if (_destinationElementDeviceDropdownState == null)
                {
                    _destinationElementDeviceDropdownState = new AdvancedDropdownState();
                }

                var dropdown = new ItemSearchableDropdown <ICoilDeviceAuthoring>(
                    _destinationElementDeviceDropdownState,
                    tableAuthoring,
                    "Coil Devices",
                    item => {
                    wireListData.DestinationDevice = item.Name;
                    updateAction(wireListData);
                }
                    );
                dropdown.Show(cellRect);
            }
        }
Ejemplo n.º 21
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;
            }
        }
Ejemplo n.º 22
0
 protected virtual void OnEnable()
 {
     _table = (target as MonoBehaviour)?.gameObject.GetComponentInParent <TableAuthoring>();
     PopulateDropDownOptions();
     EditorApplication.hierarchyChanged += OnHierarchyChange;
 }
Ejemplo n.º 23
0
 protected abstract void SetTable(TableAuthoring table);
Ejemplo n.º 24
0
 protected override void SetTable(TableAuthoring table)
 {
     _layerHandler.SetTable(table);
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Called when the selected table changes
 /// </summary>
 /// <param name="table"></param>
 protected override void SetTable(TableAuthoring table)
 {
 }