Example #1
0
        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 = UIWindow2.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 = UIWindow2.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;
        }
Example #2
0
        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 = UIWindow2.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;
        }
        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;
        }