Пример #1
0
        public static void OnDragEnd(UICustomControl dpt, UIDragEventParameter e)
        {
            try {
                LogCalled();
                e.Use();
                GameObject.Destroy(Bar?.gameObject);
                Bar = null;
                foreach (var selectedDPT in RoadEditorUtils.SelectedDPTsSorted)
                {
                    selectedDPT.component.isEnabled = true;
                    selectedDPT.component.opacity   = 1;
                }

                var groupPanel = dpt.GetComponentInParent <RoadEditorCollapsiblePanel>();
                groupPanel.m_Panel.eventDragLeave -= OnLeave;
                groupPanel.m_Panel.eventDragEnter -= OnEnter;
                groupPanel.m_Panel.eventDragOver  -= OnOver;
                groupPanel.m_Panel.eventDragDrop  -= OnDrop;
            } catch (Exception ex) {
                Log.Exception(ex);
            }
        }
Пример #2
0
        public static void OnDragStart(UICustomControl dpt, UIDragEventParameter eventParam)
        {
            if (RoadEditorUtils.IsDPTSelected(dpt))
            {
                LogCalled();
                eventParam.Use();
                eventParam.state = UIDragDropState.Dragging;

                var groupPanel = dpt.GetComponentInParent <RoadEditorCollapsiblePanel>();
                groupPanel.m_Panel.eventDragLeave -= OnLeave;
                groupPanel.m_Panel.eventDragEnter -= OnEnter;
                groupPanel.m_Panel.eventDragOver  -= OnOver;
                groupPanel.m_Panel.eventDragDrop  -= OnDrop;
                groupPanel.m_Panel.eventDragLeave += OnLeave;
                groupPanel.m_Panel.eventDragEnter += OnEnter;
                groupPanel.m_Panel.eventDragOver  += OnOver;
                groupPanel.m_Panel.eventDragDrop  += OnDrop;

                Log.Debug("creating `Add from template` button");
                Bar                  = groupPanel.Container.AddUIComponent <UIPanel>();
                Bar.width            = groupPanel.m_Panel.width;
                Bar.height           = 1;
                Bar.backgroundSprite = "TextFieldPanel";
                Bar.atlas            = KianCommons.UI.TextureUtil.Ingame;
                Bar.color            = Color.red;
                Bar.name             = "ARDragPointer";
                Bar.Show();
                Bar.zOrder = CalculateZOrder(groupPanel, eventParam);
                Bar.zOrder = CalculateZOrder(groupPanel, eventParam);

                // disable moving dpts
                foreach (var selectedDPT in RoadEditorUtils.SelectedDPTs)
                {
                    selectedDPT.component.isEnabled = false;
                    selectedDPT.component.opacity   = 0.5f;
                }
            }
        }
Пример #3
0
        public static void OnDPTMoreOptions(UICustomControl dpt)
        {
            Log.Debug("OnDPTMoreOptions() called");
            VerifySelectedDPTs(dpt);
            if (!SelectedDPTs.Contains(dpt))
            {
                DeselectAllDPTs();
            }

            var groupPanel = dpt.GetComponentInParent <RoadEditorCollapsiblePanel>();
            var sidePanel  = dpt.GetComponentInParent <RoadEditorPanel>();

            Log.Debug($"dpt={dpt} " +
                      $"groupPanel={groupPanel} " +
                      $"sidePanel={sidePanel}");

            object target  = GetDPTTargetObject(dpt);
            object element = GetDPTTargetElement(dpt);
            IEnumerable <object> elements;

            if (SelectedDPTs.Any())
            {
                elements = SelectedDPTs.Select(_dpt => GetDPTTargetElement(_dpt));
            }
            else
            {
                elements = new object[] { element }
            };

            if (target is NetLaneProps netLaneProps &&
                element is NetLaneProps.Prop)
            {
                var lane = sidePanel.GetTarget() as NetInfo.Lane;
                Assertion.AssertNotNull(lane, "sidePanel.target is lane");
                bool forward        = lane.IsGoingForward();
                bool backward       = lane.IsGoingBackward();
                bool unidirectional = forward || backward;

                var    panel          = MiniPanel.Display();
                var    f_props        = typeof(NetLaneProps).GetField(nameof(NetLaneProps.m_props));
                var    original_props = elements.Select(_p => _p as NetLaneProps.Prop);
                var    cloned_props   = original_props.Select(_p => _p.Clone());
                string strAll         = cloned_props.Count() > 1 ? " all" : "";

                panel.AddButton("Duplicate" + strAll, null, delegate() {
                    AddProps(groupPanel, cloned_props.ToArray());
                });

                if (cloned_props.Any(_p => _p.CanInvert()))
                {
                    string hint = HintExtension.GetHintSwichLHT_RHT(unidirectional);
                    panel.AddButton(
                        "LHT duplicate" + strAll,
                        hint,
                        delegate() {
                        try {
                            var arProsp = cloned_props.ToArray();
                            foreach (var item in arProsp)
                            {
                                item.ToggleRHT_LHT(unidirectional);
                            }
                            AddProps(groupPanel, arProsp);
                        } catch (Exception ex) {
                            Log.Exception(ex);
                        }
                    });
                }
                panel.AddButton("Copy" + strAll, null, delegate() {
                    ClipBoard.SetData(cloned_props);
                });
                panel.AddButton("Copy" + strAll + " to other elevations", null, delegate() {
                    foreach (var item in cloned_props)
                    {
                        PropHelpers.CopyPropsToOtherElevations(item);
                    }
                });
                panel.AddButton("Add" + strAll + " to Template", null, delegate() {
                    SaveTemplatePanel.Display(cloned_props);
                });
                if (cloned_props.Count() >= 2)
                {
                    panel.AddButton("Displace all", null, delegate() {
                        DisplaceAll(original_props);
                    });
                }
            }