public override void Render(UiContext context, RectangleF parentRectangle) { if (!Visible) { return; } var myRectangle = GetMyRectangle(context, parentRectangle); Background?.Draw(context, myRectangle); ItemA?.Render(context, myRectangle); ItemB?.Render(context, myRectangle); UiRenderable border = Border; if (Enabled) { if (Selected) { border = SelectedBorder ?? border; } if (rectangleA.Contains(context.MouseX, context.MouseY) || rectangleB.Contains(context.MouseX, context.MouseY)) { border = HoverBorder ?? border; } } if (ItemA != null) { border?.Draw(context, rectangleA); } if (ItemB != null) { border?.Draw(context, rectangleB); } }
public UiRenderable GetBackground() { if (background == null) { background = new UiRenderable(); background.AddElement(new DisplayImage() { Image = new InterfaceImage() { TexName = "NAV_zoomedliberty.tga" } }); } return(background); }
public UiRenderable GetSystemObject(string name) { var type = ini.Type?.Type ?? NavIconType.Model; if (string.IsNullOrEmpty(name)) { return(GetSystemObject("nav_depot")); } if (!renderables.TryGetValue(name, out var renderable)) { if (!ini.Icons.Map.TryGetValue(name, out var model)) { return(GetSystemObject("nav_depot")); } renderable = new UiRenderable(); if (type == NavIconType.Model) { renderable.AddElement(new DisplayModel() { Model = new InterfaceModel() { Name = name, Path = model, XScale = 50, YScale = 50 } }); } else if (type == NavIconType.Texture) { renderable.AddElement(new DisplayImage() { Image = new InterfaceImage() { Name = model, TexName = model } }); } renderables.Add(name, renderable); } return(renderable); }
public UiRenderable GetSystemObject(string name) { if (string.IsNullOrEmpty(name)) { return(GetSystemObject("nav_depot")); } if (!renderables.TryGetValue(name, out var renderable)) { if (!models.TryGetValue(name, out var model)) { return(GetSystemObject("nav_depot")); } renderable = new UiRenderable(); renderable.AddElement(new DisplayModel() { Model = new InterfaceModel() { Name = name, Path = model, XScale = 50, YScale = 50 } }); renderables.Add(name, renderable); } return(renderable); }
public void PopulateIcons(UiContext ctx, GameData.StarSystem sys) { foreach (var l in ctx.Data.NavmapIcons.Libraries()) { ctx.Data.ResourceManager.LoadResourceFile(ctx.Data.FileSystem.Resolve(l)); } objects = new List <DrawObject>(); tradelanes = new List <Tradelanes>(); navmapscale = sys.NavMapScale; foreach (var obj in sys.Objects) { if (obj.Dock != null && obj.Dock.Kind == DockKinds.Tradelane) { if (!string.IsNullOrEmpty(obj.Dock.Target) && string.IsNullOrEmpty(obj.Dock.TargetLeft)) { var start = obj; var end = obj; while (!string.IsNullOrEmpty(end.Dock.Target)) { var e = sys.Objects.FirstOrDefault(x => x.Nickname.Equals(end.Dock.Target)); if (e == null) { break; } end = e; } if (start != end) { tradelanes.Add(new Tradelanes() { StartXZ = new Vector2(start.Position.X, start.Position.Z), EndXZ = new Vector2(end.Position.X, end.Position.Z) }); } } } if ((obj.Visit & 128) == 128) { continue; } if ((obj.Archetype.SolarRadius <= 0)) { continue; } UiRenderable renderable = null; renderable = ctx.Data.NavmapIcons.GetSystemObject(obj.Archetype.NavmapIcon); string nm = obj.DisplayName; if (obj.Archetype.Type != ArchetypeType.planet && obj.Archetype.Type != ArchetypeType.station && obj.Archetype.Type != ArchetypeType.jump_gate && obj.Archetype.Type != ArchetypeType.jump_hole && obj.Archetype.Type != ArchetypeType.jumphole) { nm = null; } bool iconZoomOut = ( obj.Archetype.Type == ArchetypeType.planet || obj.Archetype.Type == ArchetypeType.sun || obj.Archetype.Type == ArchetypeType.mission_satellite ); objects.Add(new DrawObject() { Renderable = renderable, Name = nm, XZ = new Vector2(obj.Position.X, obj.Position.Z), SolarRadius = obj.Archetype.SolarRadius, IconZoomedOut = iconZoomOut }); } zones = new List <DrawZone>(); foreach (var zone in sys.Zones) { if ((zone.VisitFlags & 128) == 128) { continue; } Vector2 xz = new Vector2(zone.Position.X, zone.Position.Z); Vector2 dimensions; float rotSign = -1; if (Math.Abs(zone.RotationAngles.X - Math.PI) < 0.001f || Math.Abs(zone.RotationAngles.X + Math.PI) < 0.001f) { rotSign = 1; } float angle = rotSign * zone.RotationAngles.Y; if (zone.Shape is ZoneSphere sph) { dimensions = new Vector2(sph.Radius * 2); } else if (zone.Shape is ZoneEllipsoid elp) { dimensions = new Vector2(elp.Size.X, elp.Size.Z) * 2; } else { continue; } var tint = zone.PropertyFogColor; string tex = null; if ((zone.PropertyFlags & ZonePropFlags.Badlands) == ZonePropFlags.Badlands) { tex = "nav_terrain_badlands"; } if ((zone.PropertyFlags & ZonePropFlags.Crystal) == ZonePropFlags.Crystal || (zone.PropertyFlags & ZonePropFlags.Ice) == ZonePropFlags.Ice) { tex = "nav_terrain_ice"; } if ((zone.PropertyFlags & ZonePropFlags.Lava) == ZonePropFlags.Lava) { tex = "nav_terrain_lava"; } if ((zone.PropertyFlags & ZonePropFlags.Mines) == ZonePropFlags.Mines) { tex = "nav_terrain_mines"; } if ((zone.PropertyFlags & ZonePropFlags.Debris) == ZonePropFlags.Debris) { tex = "nav_terrain_debris"; } if ((zone.PropertyFlags & ZonePropFlags.Nomad) == ZonePropFlags.Nomad) { tex = "nav_terrain_nomadast"; } if ((zone.PropertyFlags & ZonePropFlags.Rock) == ZonePropFlags.Rock) { tex = "asteroidtest"; } if ((zone.PropertyFlags & ZonePropFlags.Cloud) == ZonePropFlags.Cloud) { tex = "dustcloud"; } if ((zone.PropertyFlags & ZonePropFlags.Exclusion1) == ZonePropFlags.Exclusion1 || (zone.PropertyFlags & ZonePropFlags.Exclusion2) == ZonePropFlags.Exclusion2) { tex = ""; tint = new Color4(0, 0, 0, 0.6f); } if (tex == null) { continue; } zones.Add(new DrawZone() { XZ = xz, Dimensions = dimensions, Texture = tex, Angle = angle, Tint = tint, Sort = zone.Sort }); } zones.Sort((x, y) => x.Sort.CompareTo(y.Sort)); systemName = sys.Name.ToUpper(); }