예제 #1
0
        public override void Render()
        {
            base.Render();
            if (_started)
            {
                var   diff = _end - _start;
                var   x    = diff.X;
                var   y    = diff.Y;
                Color c    = Color.FromArgb(150, 150, 150);
                if (Math.Abs(x) + Math.Abs(y) < MINIMUM_LINE)
                {
                    c = Color.Red;
                }
                switch (game.Canvas.ColorControls.Selected)
                {
                case LineType.Blue:
                    StandardLine sl = new StandardLine(_start, _end, _addflip);
                    sl.CalculateConstants();
                    GameRenderer.DrawTrackLine(sl, c, game.SettingRenderGravityWells, true, false, false);
                    break;

                case LineType.Red:
                    RedLine rl = new RedLine(_start, _end, _addflip);
                    rl.Multiplier = game.Canvas.ColorControls.RedMultiplier;
                    rl.CalculateConstants();
                    GameRenderer.DrawTrackLine(rl, c, game.SettingRenderGravityWells, true, false, false);
                    break;

                case LineType.Scenery:
                    GameRenderer.RenderRoundedLine(_start, _end, c, 1);
                    break;
                }
            }
        }
예제 #2
0
        public void MoveLine(StandardLine line, Vector2d new1, Vector2d new2)
        {
            var old  = line.Position;
            var old2 = line.Position2;

            line.Position  = new1;
            line.Position2 = new2;
            line.CalculateConstants();
            Grid.MoveLine(old, old2, line);
        }
예제 #3
0
        private void AddLine()
        {
            Line added = null;

            switch (game.Canvas.ColorControls.Selected)
            {
            case LineType.Blue:
                added = new StandardLine(_start, _end, false)
                {
                    inv = inv
                };
                added.CalculateConstants();
                break;

            case LineType.Red:
                added = new RedLine(_start, _end, false)
                {
                    inv = inv
                };
                (added as RedLine).Multiplier = game.Canvas.ColorControls.RedMultiplier;
                added.CalculateConstants();
                break;

            case LineType.Scenery:
                added = new SceneryLine(_start, _end)
                {
                    Width = game.Canvas.ColorControls.GreenMultiplier
                };
                break;
            }
            game.Track.AddLine(added);
            if (added is StandardLine)
            {
                var stl = added as StandardLine;
                game.Track.TryConnectLines(stl, _last);
                _last = stl;
            }
            if (game.Canvas.ColorControls.Selected != LineType.Scenery)
            {
                game.Track.ChangeMade(_start, _end);
                game.Track.TrackUpdated();
            }
            game.Invalidate();
        }
예제 #4
0
        public void Select(StandardLine line, Vector2d position)
        {
            if (selectionwindow != null)
            {
                if (selectionwindow.UserData != line)
                {
                    selectionwindow.Close();
                    selectionwindow = null;
                }
            }
            if (selectionwindow == null)
            {
                selectionwindow = new WindowControl(game.Canvas, "Line Settings", false);
                selectionwindow.MakeModal(true);
                selectionwindow.UserData      = line;
                selectionwindow.DeleteOnClose = true;
                selectionwindow.DisableResizing();
                selectionwindow.Height = 170;
                selectionwindow.Width  = 150;

                ControlBase container1 = new ControlBase(selectionwindow);
                container1.Dock = Gwen.Pos.Fill;
                if (line.GetLineType() != LineType.Scenery)
                {
                    LabeledCheckBox btn = new LabeledCheckBox(container1);
                    btn.Dock          = Gwen.Pos.Top;
                    btn.Text          = "Inverse";
                    btn.IsChecked     = line.inv;
                    btn.CheckChanged += (o, e) =>
                    {
                        var caller = (LabeledCheckBox)o;
                        line.inv = caller.IsChecked;
                        line.CalculateConstants();
                        game.Track.TrackUpdated();
                        game.Invalidate();
                    };
                    LineTrigger tr = (LineTrigger)line.Trigger ?? new LineTrigger();

                    var gb = new PropertyTree(container1);
                    gb.Height = 110;
                    gb.Dock   = Gwen.Pos.Top;

                    PropertyTree table = new PropertyTree(gb);

                    table.Name   = "triggers";
                    table.Dock   = Gwen.Pos.Fill;
                    table.Height = 100;

                    var row     = table.Add("Zoom Trigger");
                    var enabled = row.Add("Enabled", new Gwen.Controls.Property.Check(table));
                    enabled.Value         = tr.Zoomtrigger ? "1" : "0";
                    enabled.ValueChanged += (o, e) =>
                    {
                        if (enabled.Value == "1")
                        {
                            tr.Zoomtrigger = true;
                            tr.ZoomTarget  = float.Parse(((PropertyRow)container1.FindChildByName("Zoom", true)).Value);
                            tr.ZoomFrames  = int.Parse(((PropertyRow)container1.FindChildByName("ZoomFrames", true)).Value);
                            line.Trigger   = tr;
                        }
                        else
                        {
                            tr.Zoomtrigger = false;
                            if (!tr.Enabled)
                            {
                                line.Trigger = null;
                            }
                        }
                        game.Track.LineChanged(line);
                    };
                    var prop = row.Add("Zoom");
                    prop.Name          = "Zoom";
                    prop.Value         = (enabled.Value == "1" ? tr.ZoomTarget : 1).ToString();
                    prop.ValueChanged += (o, e) =>
                    {
                        var   caller = (PropertyRow)o;
                        float val    = 0;
                        if (float.TryParse(caller.Value, out val) && val >= 0.1 && val <= 24)
                        {
                            caller.LabelColor = System.Drawing.Color.Black;
                            tr.ZoomTarget     = val;
                        }
                        else
                        {
                            caller.LabelColor = System.Drawing.Color.Red;
                        }
                    };
                    prop               = row.Add("Frames");
                    prop.Name          = "ZoomFrames";
                    prop.Value         = (enabled.Value == "1" ? tr.ZoomFrames : 40).ToString();
                    prop.ValueChanged += (o, e) =>
                    {
                        var caller = (PropertyRow)o;
                        int val    = 0;
                        if (int.TryParse(caller.Value, out val) && val >= 1 && val < 10000)
                        {
                            caller.LabelColor = System.Drawing.Color.Black;
                            tr.ZoomFrames     = val;
                        }
                        else
                        {
                            caller.LabelColor = System.Drawing.Color.Red;
                        }
                    };
                }

                if (line.GetLineType() == LineType.Red)
                {
                    selectionwindow.Height += 30;
                    NoDecimalNUD nud  = new NoDecimalNUD(container1);
                    var          marg = nud.Margin;
                    marg.Top          = 5;
                    marg.Left         = marg.Right = 1;
                    marg.Left         = 70;
                    marg.Bottom       = 10;
                    nud.Margin        = marg;
                    nud.Dock          = Gwen.Pos.Top;
                    nud.Min           = 1;
                    nud.Max           = 3;
                    nud.Value         = (line as RedLine).Multiplier;
                    nud.ValueChanged += nud_redlinemultiplier_ValueChanged;
                    nud.UserData      = line;
                    Label l = new Label(container1);
                    l.Y    = 137;
                    l.Text = "Multiplier";
                    selectionwindow.Height += 25;


                    nud         = new NoDecimalNUD(container1);
                    marg        = nud.Margin;
                    marg.Top    = 5;
                    marg.Left   = marg.Right = 1;
                    marg.Left   = 70;
                    marg.Bottom = 10;
                    nud.Margin  = marg;
                    nud.Dock    = Gwen.Pos.Top;
                    var         lines    = game.Track.GetLinesInRect(new FloatRect((Vector2)line.Position, new Vector2(1, 1)), false);
                    List <Line> redlines = new List <Line>();
                    foreach (var red in lines)
                    {
                        if (red.Position == line.Position && red.Position2 == line.Position2)
                        {
                            redlines.Add(red);
                        }
                    }
                    nud.Min = 1;
                    nud.Max = 50;
                    redlines.Sort(new Track.Linecomparer());
                    nud.Value         = redlines.Count;
                    nud.ValueChanged += (o, e) =>
                    {
                        var diff = nud.Value - redlines.Count;
                        if (diff < 0)
                        {
                            for (int i = 0; i > diff; i--)
                            {
                                game.Track.RemoveLine(redlines[(int)((redlines.Count - 1))]);
                                redlines.RemoveAt(redlines.Count - 1);
                            }
                        }
                        else
                        {
                            for (int i = 0; i < diff; i++)
                            {
                                var red = new RedLine(line.Position, line.Position2, line.inv)
                                {
                                    Multiplier = ((RedLine)line).Multiplier
                                };
                                game.Track.AddLine(red);
                                redlines.Add(red);
                            }
                        }
                        game.Track.TrackUpdated();
                    };
                    nud.UserData = line;
                    l            = new Label(container1);
                    l.Y          = 137 + 35;
                    l.Text       = "Multilines";
                }
                selectionwindow.IsHiddenChanged += Selectionwindow_IsHiddenChanged;
                selectionwindow.Show();
                selectionwindow.X = (int)position.X;
                selectionwindow.Y = (int)position.Y;
                game.Cursor       = MouseCursor.Default;
            }
        }