コード例 #1
0
        private void RenderDestination(CoilListData coilListData, Rect cellRect, Action <CoilListData> updateAction)
        {
            EditorGUI.BeginChangeCheck();
            var index = (CoilDestination)EditorGUI.EnumPopup(cellRect, coilListData.Destination);

            if (EditorGUI.EndChangeCheck())
            {
                if (coilListData.Destination != index)
                {
                    if (coilListData.Destination == CoilDestination.Lamp)
                    {
                        var lampEntry = _tableComponent.MappingConfig.Lamps.FirstOrDefault(l => l.Id == coilListData.Id && l.IsCoil);
                        if (lampEntry != null)
                        {
                            _tableComponent.MappingConfig.RemoveLamp(lampEntry);
                            LampManager.Refresh();
                        }
                    }
                    else if (index == CoilDestination.Lamp)
                    {
                        _tableComponent.MappingConfig.AddLamp(new LampMapping {
                            Id          = coilListData.Id,
                            Source      = LampSource.Lamp,
                            IsCoil      = true,
                            Description = coilListData.Description
                        });
                        LampManager.Refresh();
                    }
                    coilListData.Destination = index;
                    updateAction(coilListData);
                }
            }
        }
コード例 #2
0
 private void UpdateId(CoilListData data, string id)
 {
     if (data.Destination == CoilDestination.Lamp)
     {
         var lampEntry = _tableComponent.MappingConfig.Lamps.FirstOrDefault(l => l.Id == data.Id && l.IsCoil);
         if (lampEntry != null)
         {
             lampEntry.Id = id;
             LampManager.Refresh();
         }
     }
     data.Id = id;
 }
コード例 #3
0
        protected override void RemoveData(string undoName, CoilListData data)
        {
            RecordUndo(undoName);
            TableComponent.MappingConfig.RemoveCoil(data.CoilMapping);

            // todo if it's a lamp, also delete the lamp entry.
            if (data.CoilMapping.Destination == CoilDestination.Lamp)
            {
                var lampEntry = TableComponent.MappingConfig.Lamps.FirstOrDefault(l => l.Id == data.Id && l.IsCoil);
                if (lampEntry != null)
                {
                    TableComponent.MappingConfig.RemoveLamp(lampEntry);
                    LampManager.Refresh();
                }
            }
        }
コード例 #4
0
        protected override void OnButtonBarGUI()
        {
            if (GUILayout.Button("Populate All", GUILayout.ExpandWidth(false)))
            {
                RecordUndo("Populate all coil mappings");
                TableComponent.MappingConfig.PopulateCoils(GetAvailableEngineCoils(), TableComponent);
                Reload();
                LampManager.Refresh();
            }

            if (GUILayout.Button("Remove All", GUILayout.ExpandWidth(false)))
            {
                if (EditorUtility.DisplayDialog("Coil Manager", "Are you sure want to remove all coil mappings?", "Yes", "Cancel"))
                {
                    RecordUndo("Remove all coil mappings");
                    TableComponent.MappingConfig.RemoveAllCoils();
                }
                Reload();
                LampManager.Refresh();
            }
        }