コード例 #1
0
 static void OnShowOptions(RoadEditorCollapsiblePanel groupPanel)
 {
     try {
         Array array  = groupPanel.GetArray();
         var   target = groupPanel.GetTarget();
         if (groupPanel.GetArray() is NetLaneProps.Prop[] m_props)
         {
             bool hasItems         = m_props.Length > 0;
             bool clipBoardHasData = ClipBoard.HasData <NetLaneProps.Prop>();
             if (hasItems || clipBoardHasData)
             {
                 var panel = MiniPanel.Display();
                 if (hasItems)
                 {
                     panel.AddButton("Copy all props", null,
                                     () => ClipBoard.SetData(m_props));
                     panel.AddButton("Clear all props", null,
                                     () => ClearAll(groupPanel));
                     panel.AddButton("Save Template", null, () => {
                         SaveTemplatePanel.Display(m_props);
                     });
                 }
                 if (clipBoardHasData)
                 {
                     panel.AddButton("Paste all props", null,
                                     () => PasteAll(groupPanel));
                 }
                 panel.AddButton(
                     "Displace all",
                     null,
                     () => DisplaceAll(m_props));
             }
         }
         else if (
             array is NetInfo.Lane[] m_lanes &&
             m_lanes.Any(_lane => _lane.HasProps()) &&
             target == NetInfoExtionsion.EditedNetInfo)
         {
             var panel = MiniPanel.Display();
             panel.AddButton(
                 "Copy props to other elevation",
                 "appends props to other elevations",
                 () => PropHelpers.CopyPropsToOtherElevations(clear: false));
             panel.AddButton(
                 "replace props to other elevation",
                 "clears props from other elevations before copying.",
                 () => PropHelpers.CopyPropsToOtherElevations(clear: true));
             panel.AddButton(
                 "Displace all",
                 null,
                 () => RoadEditorUtils.DisplaceAllProps(m_lanes));
         }
     } catch (Exception ex) {
         Log.Exception(ex);
     }
 }