Пример #1
0
            /// <summary>
            /// Creates TrackSpline object from ScnTrack
            /// </summary>
            /// <param name="track"></param>
            /// <param name="switchState"></param>
            /// <returns></returns>
            public static Spline FromTrack(ScnTrack track, bool switchState = false)
            {
                var p1     = !switchState;
                var spline = new Spline {
                    A = p1 ? track.Point1 : track.Point3,
                    B = p1 ? track.Point1 + track.CVec1 : track.Point3 + track.CVec3,
                    C = p1 ? track.Point2 + track.CVec2 : track.Point4 + track.CVec4,
                    D = p1 ? track.Point2 : track.Point4,
                };
                var type = 0;

                switch (track.TrackType.ToLowerInvariant())
                {
                case "normal": type = 0; break;

                case "switch": type = 1; break;

                case "road": type = 2; break;

                case "river": type = 3; break;

                case "cross": type = 4; break;

                default: type = 0; break;
                }
                spline.T     = type;
                spline.W     = (float)track.TrackWidth;
                spline.L     = p1 ? track.CVec1.Zero && track.CVec2.Zero : track.CVec3.Zero && track.CVec4.Zero;
                spline.I1    = spline.Interpolate(0.25f);
                spline.I2    = spline.Interpolate(0.5f);
                spline.I3    = spline.Interpolate(0.75f);
                spline.Track = track;
                return(spline);
            }
Пример #2
0
 public static void FindTrack(ScnTrack track)
 {
     Main.Instance.DisableEdit();
     Status.Text = Messages.Searching;
     Application.DoEvents();
     SearchResultsPanel.Reset();
     ProcessAll(i => {
         if (i.Path == track.SourcePath)
         {
             i.Open();
             var p = i.Editor.PositionToPlace(track.SourceIndex);
             SearchResultsPanel.Add(new SearchResult {
                 Path = i.Path, File = i.FileName, Fragment = i.Text.Substring(track.SourceIndex, track.SourceLength), Line = p.iLine + 1, Column = 1
             });
         }
     });
     SearchResultsPanel.CloseIfEmpty();
     Status.Text = Messages.Ready;
     Application.DoEvents();
     Main.Instance.EnableEdit();
 }