public void UpdateDefaults(ushort segmentId, bool startNode, ref NetNode node)
        {
            IJunctionRestrictionsManager junctionRestrictionsManager = Constants.ManagerFactory.JunctionRestrictionsManager;

            if (!junctionRestrictionsManager.IsUturnAllowedConfigurable(segmentId, startNode, ref node))
            {
                uturnAllowed = TernaryBool.Undefined;
            }

            if (!junctionRestrictionsManager.IsLaneChangingAllowedWhenGoingStraightConfigurable(segmentId, startNode, ref node))
            {
                straightLaneChangingAllowed = TernaryBool.Undefined;
            }

            if (!junctionRestrictionsManager.IsEnteringBlockedJunctionAllowedConfigurable(segmentId, startNode, ref node))
            {
                enterWhenBlockedAllowed = TernaryBool.Undefined;
            }

            if (!junctionRestrictionsManager.IsPedestrianCrossingAllowedConfigurable(segmentId, startNode, ref node))
            {
                pedestrianCrossingAllowed = TernaryBool.Undefined;
            }

            defaultUturnAllowed = junctionRestrictionsManager.GetDefaultUturnAllowed(segmentId, startNode, ref node);
            defaultStraightLaneChangingAllowed = junctionRestrictionsManager.GetDefaultLaneChangingAllowedWhenGoingStraight(segmentId, startNode, ref node);
            defaultEnterWhenBlockedAllowed     = junctionRestrictionsManager.GetDefaultEnteringBlockedJunctionAllowed(segmentId, startNode, ref node);
            defaultPedestrianCrossingAllowed   = junctionRestrictionsManager.GetDefaultPedestrianCrossingAllowed(segmentId, startNode, ref node);
#if DEBUG
            if (GlobalConfig.Instance.Debug.Switches[11])
            {
                Log._Debug($"SegmentEndFlags.UpdateDefaults({segmentId}, {startNode}): Set defaults: defaultUturnAllowed={defaultUturnAllowed}, defaultStraightLaneChangingAllowed={defaultStraightLaneChangingAllowed}, defaultEnterWhenBlockedAllowed={defaultEnterWhenBlockedAllowed}, defaultPedestrianCrossingAllowed={defaultPedestrianCrossingAllowed}");
            }
#endif
        }
        private bool drawSignHandles(bool debug,
                                     ushort nodeId,
                                     ref NetNode node,
                                     bool viewOnly,
                                     bool handleClick,
                                     ref Vector3 camPos,
                                     out bool stateUpdated)
        {
            bool hovered = false;

            stateUpdated = false;

            if (viewOnly && !(Options.junctionRestrictionsOverlay || PrioritySignsTool.showMassEditOverlay) &&
                (MainTool.GetToolMode() != ToolMode.JunctionRestrictions))
            {
                return(false);
            }

            // NetManager netManager = Singleton<NetManager>.instance;
            Color   guiColor = GUI.color;
            Vector3 nodePos  = Singleton <NetManager> .instance.m_nodes.m_buffer[nodeId].m_position;
            IExtSegmentEndManager segEndMan = Constants.ManagerFactory.ExtSegmentEndManager;

            for (int i = 0; i < 8; ++i)
            {
                ushort segmentId = node.GetSegment(i);

                if (segmentId == 0)
                {
                    continue;
                }

                bool startNode = (bool)Constants.ServiceFactory.NetService.IsStartNode(segmentId, nodeId);
                bool incoming  = segEndMan.ExtSegmentEnds[segEndMan.GetIndex(segmentId, startNode)].incoming;

                int numSignsPerRow = incoming ? 2 : 1;

                NetInfo segmentInfo = Singleton <NetManager> .instance.m_segments.m_buffer[segmentId].Info;

                ItemClass connectionClass = segmentInfo.GetConnectionClass();

                if (connectionClass.m_service != ItemClass.Service.Road)
                {
                    continue; // only for road junctions
                }

                // draw all junction restriction signs
                Vector3 segmentCenterPos = Singleton <NetManager> .instance.m_segments.m_buffer[segmentId]
                                           .m_bounds.center;
                Vector3 yu = (segmentCenterPos - nodePos).normalized;
                Vector3 xu = Vector3.Cross(yu, new Vector3(0, 1f, 0)).normalized;
                float   f  = viewOnly ? 6f : 7f; // reserved sign size in game coordinates

                Vector3 centerStart = nodePos + (yu * (viewOnly ? 5f : 14f));
                Vector3 zero        = centerStart - (0.5f * (numSignsPerRow - 1) * f * xu); // "top left"
                if (viewOnly)
                {
                    if (Constants.ServiceFactory.SimulationService.TrafficDrivesOnLeft)
                    {
                        zero -= xu * 8f;
                    }
                    else
                    {
                        zero += xu * 8f;
                    }
                }

                bool signHovered;
                int  x = 0;
                int  y = 0;
                bool hasSignInPrevRow = false;

                // draw "lane-changing when going straight allowed" sign at (0; 0)
                bool allowed =
                    JunctionRestrictionsManager.Instance.IsLaneChangingAllowedWhenGoingStraight(
                        segmentId,
                        startNode);

                bool configurable =
                    Constants.ManagerFactory.JunctionRestrictionsManager
                    .IsLaneChangingAllowedWhenGoingStraightConfigurable(
                        segmentId,
                        startNode,
                        ref node);

                if (debug ||
                    (configurable &&
                     (!viewOnly ||
                      (allowed != Constants.ManagerFactory
                       .JunctionRestrictionsManager
                       .GetDefaultLaneChangingAllowedWhenGoingStraight(
                           segmentId,
                           startNode,
                           ref node)))))
                {
                    DrawSign(
                        viewOnly,
                        !configurable,
                        ref camPos,
                        ref xu,
                        ref yu,
                        f,
                        ref zero,
                        x,
                        y,
                        guiColor,
                        allowed
                            ? JunctionRestrictions.LaneChangeAllowed
                            : JunctionRestrictions.LaneChangeForbidden,
                        out signHovered);

                    if (signHovered && handleClick)
                    {
                        hovered = true;
                        if (MainTool.CheckClicked())
                        {
                            JunctionRestrictionsManager.Instance.ToggleLaneChangingAllowedWhenGoingStraight(
                                segmentId,
                                startNode);
                            stateUpdated = true;
                        }
                    }

                    ++x;
                    hasSignInPrevRow = true;
                }

                // draw "u-turns allowed" sign at (1; 0)
                allowed      = JunctionRestrictionsManager.Instance.IsUturnAllowed(segmentId, startNode);
                configurable =
                    Constants.ManagerFactory.JunctionRestrictionsManager.IsUturnAllowedConfigurable(
                        segmentId,
                        startNode,
                        ref node);
                if (debug ||
                    (configurable &&
                     (!viewOnly ||
                      (allowed != Constants.ManagerFactory
                       .JunctionRestrictionsManager
                       .GetDefaultUturnAllowed(
                           segmentId,
                           startNode,
                           ref node)))))
                {
                    DrawSign(
                        viewOnly,
                        !configurable,
                        ref camPos,
                        ref xu,
                        ref yu,
                        f,
                        ref zero,
                        x,
                        y,
                        guiColor,
                        allowed
                            ? JunctionRestrictions.UturnAllowed
                            : JunctionRestrictions.UturnForbidden,
                        out signHovered);

                    if (signHovered && handleClick)
                    {
                        hovered = true;

                        if (MainTool.CheckClicked())
                        {
                            if (!JunctionRestrictionsManager.Instance.ToggleUturnAllowed(
                                    segmentId,
                                    startNode))
                            {
                                // TODO MainTool.ShowTooltip(Translation.GetString("..."), Singleton<NetManager>.instance.m_nodes.m_buffer[nodeId].m_position);
                            }
                            else
                            {
                                stateUpdated = true;
                            }
                        }
                    }

                    x++;
                    hasSignInPrevRow = true;
                }

                x = 0;
                if (hasSignInPrevRow)
                {
                    ++y;
                    hasSignInPrevRow = false;
                }

                // draw "entering blocked junctions allowed" sign at (0; 1)
                allowed = JunctionRestrictionsManager.Instance.IsEnteringBlockedJunctionAllowed(
                    segmentId,
                    startNode);
                configurable =
                    Constants.ManagerFactory.JunctionRestrictionsManager
                    .IsEnteringBlockedJunctionAllowedConfigurable(
                        segmentId,
                        startNode,
                        ref node);

                if (debug ||
                    (configurable &&
                     (!viewOnly ||
                      (allowed != Constants.ManagerFactory
                       .JunctionRestrictionsManager
                       .GetDefaultEnteringBlockedJunctionAllowed(
                           segmentId,
                           startNode,
                           ref node)))))
                {
                    DrawSign(
                        viewOnly,
                        !configurable,
                        ref camPos,
                        ref xu,
                        ref yu,
                        f,
                        ref zero,
                        x,
                        y,
                        guiColor,
                        allowed
                            ? JunctionRestrictions.EnterBlockedJunctionAllowed
                            : JunctionRestrictions.EnterBlockedJunctionForbidden,
                        out signHovered);

                    if (signHovered && handleClick)
                    {
                        hovered = true;

                        if (MainTool.CheckClicked())
                        {
                            JunctionRestrictionsManager
                            .Instance
                            .ToggleEnteringBlockedJunctionAllowed(segmentId, startNode);
                            stateUpdated = true;
                        }
                    }

                    ++x;
                    hasSignInPrevRow = true;
                }

                // draw "pedestrian crossing allowed" sign at (1; 1)
                allowed = JunctionRestrictionsManager.Instance.IsPedestrianCrossingAllowed(
                    segmentId,
                    startNode);
                configurable =
                    Constants.ManagerFactory.JunctionRestrictionsManager
                    .IsPedestrianCrossingAllowedConfigurable(
                        segmentId,
                        startNode,
                        ref node);

                if (debug ||
                    (configurable &&
                     (!viewOnly || !allowed)))
                {
                    DrawSign(
                        viewOnly,
                        !configurable,
                        ref camPos,
                        ref xu,
                        ref yu,
                        f,
                        ref zero,
                        x,
                        y,
                        guiColor,
                        allowed
                            ? JunctionRestrictions.PedestrianCrossingAllowed
                            : JunctionRestrictions.PedestrianCrossingForbidden,
                        out signHovered);

                    if (signHovered && handleClick)
                    {
                        hovered = true;

                        if (MainTool.CheckClicked())
                        {
                            JunctionRestrictionsManager.Instance.TogglePedestrianCrossingAllowed(segmentId, startNode);
                            stateUpdated = true;
                        }
                    }

                    x++;
                    hasSignInPrevRow = true;
                }

                x = 0;

                if (hasSignInPrevRow)
                {
                    ++y;
                    hasSignInPrevRow = false;
                }

                if (!Options.turnOnRedEnabled)
                {
                    continue;
                }

                //--------------------------------
                // TURN ON RED ENABLED
                //--------------------------------
                IJunctionRestrictionsManager junctionRestrictionsManager =
                    Constants.ManagerFactory.JunctionRestrictionsManager;
                bool lht = Constants.ServiceFactory.SimulationService.TrafficDrivesOnLeft;

                // draw "turn-left-on-red allowed" sign at (2; 0)
                allowed      = junctionRestrictionsManager.IsTurnOnRedAllowed(lht, segmentId, startNode);
                configurable = junctionRestrictionsManager.IsTurnOnRedAllowedConfigurable(
                    lht,
                    segmentId,
                    startNode,
                    ref node);

                if (debug ||
                    (configurable &&
                     (!viewOnly ||
                      (allowed != junctionRestrictionsManager
                       .GetDefaultTurnOnRedAllowed(
                           lht,
                           segmentId,
                           startNode,
                           ref node)))))
                {
                    DrawSign(
                        viewOnly,
                        !configurable,
                        ref camPos,
                        ref xu,
                        ref yu,
                        f,
                        ref zero,
                        x,
                        y,
                        guiColor,
                        allowed
                            ? JunctionRestrictions.LeftOnRedAllowed
                            : JunctionRestrictions.LeftOnRedForbidden,
                        out signHovered);

                    if (signHovered && handleClick)
                    {
                        hovered = true;

                        if (MainTool.CheckClicked())
                        {
                            junctionRestrictionsManager.ToggleTurnOnRedAllowed(
                                lht,
                                segmentId,
                                startNode);
                            stateUpdated = true;
                        }
                    }

                    hasSignInPrevRow = true;
                }

                x++;

                // draw "turn-right-on-red allowed" sign at (2; 1)
                allowed = junctionRestrictionsManager.IsTurnOnRedAllowed(
                    !lht,
                    segmentId,
                    startNode);
                configurable = junctionRestrictionsManager.IsTurnOnRedAllowedConfigurable(
                    !lht,
                    segmentId,
                    startNode,
                    ref node);

                if (debug ||
                    (configurable &&
                     (!viewOnly ||
                      (allowed != junctionRestrictionsManager
                       .GetDefaultTurnOnRedAllowed(
                           !lht,
                           segmentId,
                           startNode,
                           ref node)))))
                {
                    DrawSign(
                        viewOnly,
                        !configurable,
                        ref camPos,
                        ref xu,
                        ref yu,
                        f,
                        ref zero,
                        x,
                        y,
                        guiColor,
                        allowed
                            ? JunctionRestrictions.RightOnRedAllowed
                            : JunctionRestrictions.RightOnRedForbidden,
                        out signHovered);

                    if (signHovered && handleClick)
                    {
                        hovered = true;

                        if (MainTool.CheckClicked())
                        {
                            junctionRestrictionsManager.ToggleTurnOnRedAllowed(
                                !lht,
                                segmentId,
                                startNode);
                            stateUpdated = true;
                        }
                    }

                    hasSignInPrevRow = true;
                }
            }

            guiColor.a = 1f;
            GUI.color  = guiColor;

            return(hovered);
        }