public override void Start()
        {
            float cumulativeHeight = 0;

            UILabel labelRadius = AddUIComponent <UILabel>();

            labelRadius.textScale        = 0.9f;
            labelRadius.text             = "Main axis:";
            labelRadius.relativePosition = new Vector2(8, cumulativeHeight);
            labelRadius.tooltip          = "Press SHIFT +/- to adjust";
            labelRadius.SendToBack();

            Radius1tf = AddUIComponent <NumericTextField>();
            Radius1tf.relativePosition = new Vector2(width - Radius1tf.width - 8, cumulativeHeight);
            Radius1tf.tooltip          = "Press SHIFT +/- to adjust";
            Radius1tf.DefaultVal       = RADIUS1_DEF;
            Radius1tf.text             = RADIUS1_DEF.ToString();
            cumulativeHeight          += Radius1tf.height + 8;

            labelRadius                  = AddUIComponent <UILabel>();
            labelRadius.textScale        = 0.9f;
            labelRadius.text             = "Minor axis:";
            labelRadius.relativePosition = new Vector2(8, cumulativeHeight);
            labelRadius.tooltip          = "Press CTRL +/- to adjust";
            labelRadius.SendToBack();

            Radius2tf = AddUIComponent <NumericTextField>();
            Radius2tf.relativePosition = new Vector2(204 - Radius1tf.width - 8, cumulativeHeight);
            Radius2tf.tooltip          = "Press CTRL +/- to adjust";
            Radius2tf.DefaultVal       = RADIUS2_DEF;
            Radius2tf.text             = RADIUS2_DEF.ToString();
            cumulativeHeight          += Radius2tf.height + 8;

            var buildButton = UIUtil.CreateButton(this);

            buildButton.text             = "Build";
            buildButton.relativePosition = new Vector2(8, cumulativeHeight);
            buildButton.playAudioEvents  = false;
            buildButton.eventClick      += (c, p) =>
            {
                EllipseTool.Instance.BuildEllipse();
            };
            cumulativeHeight += buildButton.height + 8;

            var controlVertices = UIUtil.CreateCheckBox(this);

            controlVertices.name               = "RAB_controlVertices";
            controlVertices.label.text         = "Insert control points";
            controlVertices.tooltip            = "Control points are inserted on main axes to keep the ellipse in shape. See workshop page";
            controlVertices.isChecked          = EllipseTool.Instance.ControlVertices;
            controlVertices.relativePosition   = new Vector3(8, cumulativeHeight);
            controlVertices.eventCheckChanged += (c, state) =>
            {
                EllipseTool.Instance.ControlVertices = state;
            };
            cumulativeHeight += controlVertices.height + 8;

            height = cumulativeHeight;
        }
        public override void Start()
        {
            float cumulativeHeight = 8;

            UILabel label = AddUIComponent <UILabel>();

            label.textScale        = 0.9f;
            label.width            = width;
            label.text             = "TMPE settings";
            label.relativePosition = new Vector2(8, cumulativeHeight);
            label.SendToBack();
            cumulativeHeight += label.height + 8;

            var checkBox = UIUtil.CreateCheckBox(this);

            checkBox.name               = "RAB_enterBlockedJunctionMainRoad";
            checkBox.label.text         = "Enter junct. main r.";
            checkBox.tooltip            = "Allow vehicles on the roundabout to enter blocked junctions (TMPE policy)";
            checkBox.isChecked          = SavedEnterBlockedMainRoad;
            checkBox.relativePosition   = new Vector3(8, cumulativeHeight);
            checkBox.eventCheckChanged += (c, state) =>
            {
                SavedEnterBlockedMainRoad.value = state;
            };
            cumulativeHeight += checkBox.height + 8;

            checkBox                    = UIUtil.CreateCheckBox(this);
            checkBox.name               = "RAB_enterBlockedJunctionYieldingRoad";
            checkBox.label.text         = "Enter junct. yield. r.";
            checkBox.tooltip            = "Allow vehicles entering the roundabout to enter blocked junction (TMPE policy)";
            checkBox.isChecked          = SavedEnterBlockedYieldingRoad;
            checkBox.relativePosition   = new Vector3(8, cumulativeHeight);
            checkBox.eventCheckChanged += (c, state) =>
            {
                SavedEnterBlockedYieldingRoad.value = state;
            };
            cumulativeHeight += checkBox.height + 8;

            checkBox                    = UIUtil.CreateCheckBox(this);
            checkBox.name               = "RAB_noParking";
            checkBox.label.text         = "No parking";
            checkBox.tooltip            = "Restrict parking on the roundabout (TMPE policy)";
            checkBox.isChecked          = SavedNoParking;
            checkBox.relativePosition   = new Vector3(8, cumulativeHeight);
            checkBox.eventCheckChanged += (c, state) =>
            {
                SavedNoParking.value = state;
            };
            cumulativeHeight += checkBox.height + 8;

            checkBox                    = UIUtil.CreateCheckBox(this);
            checkBox.name               = "RAB_prioritySigns";
            checkBox.label.text         = "Priority signs";
            checkBox.tooltip            = "Vehicles on the roundabout will have right-of-way";
            checkBox.isChecked          = SavedPrioritySigns;
            checkBox.relativePosition   = new Vector3(8, cumulativeHeight);
            checkBox.eventCheckChanged += (c, state) =>
            {
                SavedPrioritySigns.value = state;
            };
            cumulativeHeight += checkBox.height + 8;

            checkBox                    = UIUtil.CreateCheckBox(this);
            checkBox.name               = "RAB_noCrossings";
            checkBox.label.text         = "Disable crosswalks";
            checkBox.tooltip            = "Disallow pedestrians to cross to inner ring of the roundabout (Does not change visual appearance)";
            checkBox.isChecked          = SavedNoCrossings;
            checkBox.relativePosition   = new Vector3(8, cumulativeHeight);
            checkBox.eventCheckChanged += (c, state) =>
            {
                SavedNoCrossings.value = state;
            };
            cumulativeHeight += checkBox.height + 8;

            checkBox                    = UIUtil.CreateCheckBox(this);
            checkBox.name               = "RAB_laneChanging";
            checkBox.label.text         = "Allow lane changing";
            checkBox.tooltip            = "Allow vehicles to change lanes at the junction (both on the main and entering roads)";
            checkBox.isChecked          = SavedAllowLaneChanging;
            checkBox.relativePosition   = new Vector3(8, cumulativeHeight);
            checkBox.eventCheckChanged += (c, state) =>
            {
                SavedAllowLaneChanging.value = state;
            };
            cumulativeHeight += checkBox.height + 8;

            /*label = AddUIComponent<UILabel>();
             * label.text = "Would you like to see more TMPE features (eg. automatic lane connector)? Please visit the workshop page and let me know your usual " +
             *  "roundabout TMPE setup. Please, be as concrete as possible. ( You can include screenshots ;) )\n- Your Strad. PS: I don't promise anything :D";
             * label.wordWrap = true;
             * label.textScale = 0.65f;
             * label.autoSize = false;
             * label.width = width - 16;
             * label.relativePosition = new Vector2(8, cumulativeHeight);
             * label.SendToBack();
             * cumulativeHeight += label.height + 8;*/
        }
        public override void Start()
        {
            float   cumulativeHeight = 0;
            UILabel labelRadius      = AddUIComponent <UILabel>();

            labelRadius.textScale        = 0.9f;
            labelRadius.text             = "Radius:";
            labelRadius.relativePosition = new Vector2(8, cumulativeHeight);
            labelRadius.tooltip          = "Press +/- to adjust";
            labelRadius.SendToBack();

            RadiusField = AddUIComponent <NumericTextField>();
            RadiusField.relativePosition = new Vector2(width - RadiusField.width - 8, cumulativeHeight);
            RadiusField.tooltip          = "Press +/- to adjust";
            RadiusField.MaxVal           = RoundAboutBuilder.UnlimitedRadius.value ? RADIUS_MAX_VAL_UNLIMITED : RADIUS_MAX_VAL;
            cumulativeHeight            += RadiusField.height + 8;

            UILabel labelElevation = AddUIComponent <UILabel>();

            labelElevation.textScale        = 0.9f;
            labelElevation.text             = "Elevation:";
            labelElevation.relativePosition = new Vector2(8, cumulativeHeight);
            labelElevation.tooltip          = "Press PgUp/PgDn to adjust";
            labelElevation.SendToBack();

            ElevationField = AddUIComponent <NumericTextField>();
            ElevationField.relativePosition        = new Vector2(width - ElevationField.width - 8, cumulativeHeight);
            ElevationField.tooltip                 = "Press PgUp/PgDn/Home to adjust - set elevation in Road Tool";
            ElevationField.MinVal                  = -500;
            ElevationField.MaxVal                  = 1000;
            ElevationField.Increment               = NetUtil.DEFAULT_ELEVATTION_STEP;
            ElevationField.DefaultVal              = 0;
            ElevationField.text                    = "0";
            ElevationField.eventVisibilityChanged += (c, state) =>
            {
                if (state)
                {
                    RefreshElevation();
                }
            };

            cumulativeHeight += ElevationField.height + 8;

            UILabel label = AddUIComponent <UILabel>();

            label.text             = "Roads won't be removed or connected\nUse Fine Road Tool for elevated roads";
            label.wordWrap         = true;
            label.textScale        = 0.9f;
            label.autoSize         = false;
            label.width            = width - 16;
            label.height           = 96;
            label.relativePosition = new Vector2(8, cumulativeHeight);
            label.SendToBack();
            cumulativeHeight += label.height;

            var absoluteElevation = UIUtil.CreateCheckBox(this);

            absoluteElevation.name               = "RAB_absoluteElevation";
            absoluteElevation.label.text         = "Absolute elevation";
            absoluteElevation.tooltip            = "Elevation will be measured from zero level instead of terrain level";
            absoluteElevation.relativePosition   = new Vector3(8, cumulativeHeight);
            absoluteElevation.isChecked          = false;
            absoluteElevation.eventCheckChanged += (c, state) =>
            {
                if (state)
                {
                    previousElevation_ = ElevationField.Value ?? 0;
                    var center = new Vector3(Screen.width / 2, Screen.height / 2, 0);
                    center = Camera.main.ScreenToWorldPoint(center);
                    ElevationField.Value = previousElevation_ + (int)NetUtil.TerrainHeight(center);
                }
                else
                {
                    ElevationField.Value = previousElevation_;
                }
                FreeCursorTool.Instance.AbsoluteElevation = state;
            };
            cumulativeHeight += absoluteElevation.height + 8;

            height = cumulativeHeight;
        }
        public override void Start()
        {
            float   cumulativeHeight = 0;
            UILabel labelRadius      = AddUIComponent <UILabel>();

            labelRadius.textScale        = 0.9f;
            labelRadius.text             = "Radius:";
            labelRadius.relativePosition = new Vector2(8, cumulativeHeight);
            labelRadius.tooltip          = "Press +/- to adjust";
            labelRadius.SendToBack();

            RadiusField = AddUIComponent <NumericTextField>();
            RadiusField.relativePosition = new Vector2(width - RadiusField.width - 8, cumulativeHeight);
            RadiusField.tooltip          = "Press +/- to adjust";
            cumulativeHeight            += RadiusField.height + 8;

            UILabel labelElevation = AddUIComponent <UILabel>();

            labelElevation.textScale        = 0.9f;
            labelElevation.text             = "Elevation:";
            labelElevation.relativePosition = new Vector2(8, cumulativeHeight);
            labelElevation.tooltip          = "Press PgUp/PgDn to adjust";
            labelElevation.SendToBack();

            ElevationField = AddUIComponent <NumericTextField>();
            ElevationField.relativePosition = new Vector2(width - ElevationField.width - 8, cumulativeHeight);
            ElevationField.tooltip          = "Press PgUp/PgDn to adjust";
            ElevationField.MinVal           = -500f;
            ElevationField.MaxVal           = 1000f;
            ElevationField.Increment        = 3;
            ElevationField.DefaultVal       = 0;
            ElevationField.text             = "0";
            cumulativeHeight += ElevationField.height + 8;

            UILabel label = AddUIComponent <UILabel>();

            label.text             = "Roads won't be removed or connected\nUse Fine Road Tool for elevated roads";
            label.wordWrap         = true;
            label.textScale        = 0.9f;
            label.autoSize         = false;
            label.width            = width - 16;
            label.height           = 96;
            label.relativePosition = new Vector2(8, cumulativeHeight);
            label.SendToBack();
            cumulativeHeight += label.height;

            var absoluteElevation = UIUtil.CreateCheckBox(this);

            absoluteElevation.name               = "RAB_absoluteElevation";
            absoluteElevation.label.text         = "Absolute elevation";
            absoluteElevation.tooltip            = "Elevation will be measured from zero level instead of terrain level";
            absoluteElevation.isChecked          = EllipseTool.Instance.ControlVertices;
            absoluteElevation.relativePosition   = new Vector3(8, cumulativeHeight);
            absoluteElevation.isChecked          = false;
            absoluteElevation.eventCheckChanged += (c, state) =>
            {
                FreeCursorTool.Instance.AbsoluteElevation = state;
            };
            cumulativeHeight += absoluteElevation.height + 8;

            height = cumulativeHeight;
        }
        private void CreateOptionPanel()
        {
            name             = "RAB_ToolOptionsPanel";
            atlas            = ResourceLoader.GetAtlas("Ingame");
            backgroundSprite = "SubcategoriesPanel";
            size             = new Vector2(204, 180);
            absolutePosition = new Vector3(RoundAboutBuilder.savedWindowX.value, RoundAboutBuilder.savedWindowY.value);

            isVisible = false;

            //DebugUtils.Log("absolutePosition: " + absolutePosition);

            eventPositionChanged += (c, p) =>
            {
                if (absolutePosition.x < 0)
                {
                    absolutePosition = RoundAboutBuilder.defWindowPosition;
                }

                Vector2 resolution = GetUIView().GetScreenResolution();

                absolutePosition = new Vector2(
                    Mathf.Clamp(absolutePosition.x, 0, resolution.x - width),
                    Mathf.Clamp(absolutePosition.y, 0, resolution.y - height));

                RoundAboutBuilder.savedWindowX.value = (int)absolutePosition.x;
                RoundAboutBuilder.savedWindowY.value = (int)absolutePosition.y;
            };

            UIDragHandle dragHandle = AddUIComponent <UIDragHandle>();

            dragHandle.width            = width;
            dragHandle.relativePosition = Vector3.zero;
            dragHandle.target           = parent;

            P_TmpeSetupPanel = AddUIComponent <TmpeSetupPanel>();
            InitPanels();

            // From Elektrix's Road Tools
            UIButton openDescription = AddUIComponent <UIButton>();

            openDescription.relativePosition = new Vector3(width - 24f, 8f);
            openDescription.size             = new Vector3(15f, 15f);
            openDescription.normalFgSprite   = "ToolbarIconHelp";
            openDescription.name             = "RAB_workshopButton";
            openDescription.tooltip          = "Roundabout Builder [" + RoundAboutBuilder.VERSION + "] by Strad\nOpen in Steam Workshop";
            UIUtil.SetupButtonStateSprites(ref openDescription, "OptionBase", true);
            if (!PlatformService.IsOverlayEnabled())
            {
                openDescription.isVisible = false;
                openDescription.isEnabled = false;
            }
            openDescription.eventClicked += delegate(UIComponent component, UIMouseEventParameter click)
            {
                if (PlatformService.IsOverlayEnabled() && RoundAboutBuilder.WORKSHOP_FILE_ID != null)
                {
                    PlatformService.ActivateGameOverlayToWorkshopItem(RoundAboutBuilder.WORKSHOP_FILE_ID);
                }
                openDescription.Unfocus();
            };
            // -- Elektrix

            float cummulativeHeight = 8;

            /* Top section */
            m_topSection = AddUIComponent <UIPanel>();
            m_topSection.relativePosition = new Vector2(0, 0);
            m_topSection.SendToBack();

            UILabel label = m_topSection.AddUIComponent <UILabel>();

            label.textScale        = 0.9f;
            label.text             = "Roundabout Builder";
            label.relativePosition = new Vector2(8, cummulativeHeight);
            label.SendToBack();
            cummulativeHeight += label.height + 8;

            m_topSection.height = cummulativeHeight;
            m_topSection.width  = width;
            dragHandle.height   = cummulativeHeight;

            dropDown = AddUIComponent <UINetInfoDropDown>();
            //dropDown.relativePosition = new Vector2(8, cummulativeHeight);
            dropDown.width = width - 16;
            //cummulativeHeight += dropDown.height + 8;


            /* Bottom section */

            m_followTerrainSection              = AddUIComponent <UIPanel>();
            m_followTerrainSection.width        = 204f;
            m_followTerrainSection.clipChildren = true;
            var chbFollowTerrain = UIUtil.CreateCheckBox(m_followTerrainSection);

            chbFollowTerrain.name               = "RAB_followTerrain";
            chbFollowTerrain.label.text         = "Level terrain";
            chbFollowTerrain.tooltip            = "Make the roundabout the same height everywhere";
            chbFollowTerrain.isChecked          = !SavedFollowTerrain;
            chbFollowTerrain.relativePosition   = new Vector3(8, 0);
            chbFollowTerrain.eventCheckChanged += (c, state) =>
            {
                // Let's make it confusing - the variable and the chackbox will have opposite values
                SavedFollowTerrain.value = !state;
            };
            m_followTerrainSection.height = chbFollowTerrain.height + 8;

            m_setupTmpeSection              = AddUIComponent <UIPanel>();
            m_setupTmpeSection.width        = 204f;
            m_setupTmpeSection.clipChildren = true;
            var setupTmpe = UIUtil.CreateCheckBox(m_setupTmpeSection);

            setupTmpe.name               = "RAB_setupTmpe";
            setupTmpe.label.text         = "Set up TMPE";
            setupTmpe.tooltip            = "Apply TMPE policies to the roundabout";
            setupTmpe.isChecked          = SavedSetupTmpe;
            setupTmpe.relativePosition   = new Vector3(8, 0);
            setupTmpe.eventCheckChanged += (c, state) =>
            {
                SavedSetupTmpe.value = state;
            };
            var tmpeButton = UIUtil.CreateButton(m_setupTmpeSection);

            tmpeButton.text             = "...";
            tmpeButton.tooltip          = "TMPE settings";
            tmpeButton.height           = setupTmpe.height;
            tmpeButton.width            = 30;
            tmpeButton.relativePosition = new Vector2(width - tmpeButton.width - 8, 0);
            tmpeButton.eventClick      += (c, p) =>
            {
                toolOnUI.enabled = false;
                SwitchWindow(P_TmpeSetupPanel);
            };
            m_setupTmpeSection.height = setupTmpe.height + 8;
            //cummulativeHeight += keepOpen.height + 8;

            cummulativeHeight = 0;
            m_bottomSection   = AddUIComponent <UIPanel>();

            var keepOpen = UIUtil.CreateCheckBox(m_bottomSection);

            keepOpen.name               = "RAB_keepOpen";
            keepOpen.label.text         = "Keep open";
            keepOpen.tooltip            = "Keep the window open after roundabout is built";
            keepOpen.isChecked          = SavedKeepOpen.value;
            keepOpen.relativePosition   = new Vector3(8, cummulativeHeight);
            keepOpen.width              = 196; // width - padding
            keepOpen.eventCheckChanged += (c, state) =>
            {
                SavedKeepOpen.value = state;
            };
            cummulativeHeight += keepOpen.height + 8;

            // Back button
            backButton                  = UIUtil.CreateButton(m_bottomSection);
            backButton.text             = "Back";
            backButton.relativePosition = new Vector2(8, cummulativeHeight);
            backButton.width            = width - 16;
            backButton.eventClick      += (c, p) =>
            {
                if (backButton.isVisible)
                {
                    if (m_panelOnUI.IsSpecialWindow)
                    {
                        SwitchWindow(m_lastStandardPanel);
                        toolOnUI.enabled = true;
                    }
                    else
                    {
                        toolOnUI.GoToFirstStage();
                        SwitchTool(RoundaboutTool.Instance);
                    }
                }
            };

            cummulativeHeight += backButton.height + 8;

            closeButton                  = UIUtil.CreateButton(m_bottomSection);
            closeButton.text             = "Close";
            closeButton.relativePosition = new Vector2(8, cummulativeHeight);
            closeButton.eventClick      += (c, p) =>
            {
                enabled = false;
                if (toolOnUI != null)
                {
                    toolOnUI.enabled = false;
                }
            };

            undoButton                  = UIUtil.CreateButton(m_bottomSection);
            undoButton.text             = "Undo";
            undoButton.tooltip          = "Remove last built roundabout (CTRL+Z). Warning: Use only right after the roundabout has been built";
            undoButton.relativePosition = new Vector2(16 + closeButton.width, cummulativeHeight);
            undoButton.isEnabled        = false;
            undoButton.eventClick      += (c, p) =>
            {
                ModThreading.UndoAction();
            };

            cummulativeHeight += closeButton.height + 8;

            m_bottomSection.height = cummulativeHeight;
            m_bottomSection.width  = width;

            m_hoveringLabel           = AddUIComponent <HoveringLabel>();
            m_hoveringLabel.isVisible = false;

            /* Enable roundabout tool as default */
            SwitchTool(RoundaboutTool.Instance);

            // Is done by modthreading from 1.5.3 on

            /*try
             * {
             *  if(RoundAboutBuilder.ShowUIButton)
             *     UIPanelButton.CreateButton();
             * }
             * catch(Exception e)
             * {
             *  Debug.LogWarning("Failed to create UI button.");
             *  Debug.LogWarning(e);
             * }*/


            enabled = false;
        }