public Track(ISimulator sim, string name) { if (name == null) return; Route = new RouteCollection(); Apexes = new ApexCollection(); Sections = new SectionsCollection(); // TODO: Make possible without Telemetry.m.Sim available! if (sim.Garage != null && sim.Garage.Available && sim.Garage.Available_Tracks) { ITrack track = sim.Garage.SearchTrack(name); if (track != null) { track.Scan(); track.ScanRoute(); Location = track.Location; Type = track.Type; Name = track.Name; Route = (RouteCollection) track.Route.Clone(); } } LapLogger = new Timer(); LapLogger.Interval = 2; LapLogger.Elapsed += LapLogger_Elapsed; LapLogger.AutoReset = true; LapLogger.Start(); }
public Track(RouteCollection route) { Route = route; Apexes = new ApexCollection(); Sections = new SectionsCollection(); Location = "??"; Type = "??"; Name = "??"; // Laplogger? }
public object Clone() { RouteCollection c = new RouteCollection(); c.y_min = y_min; c.y_max = y_max; c.x_min = x_min; c.x_max = x_max; c.Racetrack = new List<TrackWaypoint>(Racetrack); c.Pitlane = new List<TrackWaypoint>(Pitlane); c.Length = Length; return c; }
public void ScanRoute() { if (!ScannedAIW) { _Route = new RouteCollection(); track_aiw = new IniScanner {IniData = masfile_aiw.Master.ExtractString(masfile_aiw)}; track_aiw.HandleCustomKeys += new Signal(Scan_AIWKey); track_aiw.FireEventsForKeys = new List<string>(); track_aiw.FireEventsForKeys.AddRange(new string[6] { "Main.wp_pos", "Main.wp_score", "Main.wp_branchid", "Main.wp_perp", "Main.wp_width", "Main.wp_ptrs" }); track_aiw.Read(); ScannedAIW = true; } }
public void ScanRoute() { if (!ScannedAIW) { _Route = new RouteCollection(); track_aiw = new IniScanner { IniFile = File.Replace("gdb","aiw") }; track_aiw.HandleCustomKeys += new Signal(Scan_AIWKey); track_aiw.FireEventsForKeys = new List<string>(); track_aiw.FireEventsForKeys.AddRange(new string[6] { "Main.wp_pos", "Main.wp_score", "Main.wp_branchid", "Main.wp_perp", "Main.wp_width", "Main.wp_ptrs" }); track_aiw.Read(); _Route.Finalize(); ScannedAIW = true; } }
//TODO: move to track class /// <summary> /// Loads route from network. /// </summary> /// <param name="routeCollection"></param> public void NetworkTrack_LoadRoute(RouteCollection routeCollection) { if (Net != null && Net.IsClient) { Track = new Track.Track(routeCollection); } }
public void Create(string file, string name, string version, RouteCollection route, int width, int height) { Pen pen_track = new Pen(brush_sector1, track_width); try { Image track_img = new Bitmap(width, height); Graphics g = Graphics.FromImage(track_img); g.FillRectangle(Brushes.Black, 0, 0, width, height); if (route == null || route.Racetrack == null) return; g.SmoothingMode = SmoothingMode.AntiAlias; pos_x_max = -100000; pos_x_min = 100000; pos_y_max = -100000; pos_y_min = 1000000; foreach (TrackWaypoint wp in route.Racetrack) { if (wp.Route == TrackRoute.MAIN) { pos_x_max = Math.Max(wp.X, pos_x_max); pos_x_min = Math.Min(wp.X, pos_x_min); pos_y_max = Math.Max(wp.Y, pos_y_max); pos_y_min = Math.Min(wp.Y, pos_y_min); } } double scale = Math.Max(pos_x_max - pos_x_min, pos_y_max - pos_y_min); double map_width = width - 12; double map_height = height - 12; double offset_x = map_width/2 - (pos_x_max - pos_x_min)/scale*map_width/2; double offset_y = 0-(scale - pos_y_max + pos_y_min)/scale*map_height/2; bool swap_xy = false; if(pos_x_max + pos_x_min < pos_y_max + pos_y_min) { swap_xy = true; } List<PointF> track = new List<PointF>(); int i = 0; foreach (TrackWaypoint wp in route.Racetrack) { if (wp.Route == TrackRoute.MAIN) { float x1 = Convert.ToSingle(6 + ((wp.X - pos_x_min)/scale*map_width) + offset_x); float y1 = Convert.ToSingle(6 + (1 - (wp.Y - pos_y_min)/scale)*map_height + offset_y); x1 = Limits.Clamp(x1, -1000, 1000); y1 = Limits.Clamp(y1, -1000, 1000); if (swap_xy) track.Add(new PointF(y1, x1)); else track.Add(new PointF(x1, y1)); } } // Draw polygons! if (track.Count > 0) g.DrawPolygon(pen_track, track.ToArray()); g.DrawString(version, font_version, Brushes.DarkRed, 5.0f, 5.0f); //g.DrawString(name, tf18, Brushes.White, 3.0f, Convert.ToSingle(map_height - 19.0f)); track_img.Save(file); } catch (Exception ex) { } }
public void Create(string file, string name, string version, RouteCollection route, int width, int height) { Pen pen_track = new Pen(brush_sector1, track_width); try { Image track_img = new Bitmap(width, height); Graphics g = Graphics.FromImage(track_img); g.Clear(Color.Transparent); //g.FillRectangle(Brushes.Black, 0, 0, width, height); if (route == null || route.Racetrack == null) return; g.SmoothingMode = SmoothingMode.AntiAlias; pos_x_max = -100000; pos_x_min = 100000; pos_y_max = -100000; pos_y_min = 1000000; foreach (TrackWaypoint wp in route.Racetrack) { if (wp.Route == TrackRoute.MAIN) { pos_x_max = Math.Max(wp.X, pos_x_max); pos_x_min = Math.Min(wp.X, pos_x_min); pos_y_max = Math.Max(wp.Z, pos_y_max); pos_y_min = Math.Min(wp.Z, pos_y_min); } } scale = Math.Max(pos_x_max - pos_x_min, pos_y_max - pos_y_min); map_width = width - 12; map_height = height - 12; offset_x = map_width / 2 - (pos_x_max - pos_x_min) / scale * map_width / 2; offset_y = 0 - (scale - pos_y_max + pos_y_min) / scale * map_height / 2; List<PointF> track = new List<PointF>(); int i = 0; foreach (TrackWaypoint wp in route.Racetrack) { if (wp.Route == TrackRoute.MAIN) { float x1 = Convert.ToSingle(6 + ((wp.X - pos_x_min) / scale * map_width) + offset_x); float y1 = Convert.ToSingle(6 + (1 - (wp.Z - pos_y_min) / scale) * map_height + offset_y); x1 = Limits.Clamp(x1, -1000, 1000); y1 = Limits.Clamp(y1, -1000, 1000); track.Add(new PointF(x1, y1)); } } // Draw polygons! if (track.Count > 0) g.DrawPolygon(pen_track, track.ToArray()); track_img.Save(file); } catch (Exception ex) { } }