public override void LoadResources() { // load icons iconsTexture = (TextureResource)devIf.GetSharedResource("file://Media/UI/InViewIconsX16.png", ref checkedOutResources, devIf); // ^need?? xAxisIcon = (TextureResource.Icon)devIf.GetSharedResource("file://Media/UI/InViewIconsX16.png:areas:icon:xAxis", ref checkedOutResources, devIf); yAxisIcon = (TextureResource.Icon)devIf.GetSharedResource("file://Media/UI/InViewIconsX16.png:areas:icon:yAxis", ref checkedOutResources, devIf); zAxisIcon = (TextureResource.Icon)devIf.GetSharedResource("file://Media/UI/InViewIconsX16.png:areas:icon:zAxis", ref checkedOutResources, devIf); tickIcon = (TextureResource.Icon)devIf.GetSharedResource("file://Media/UI/InViewIconsX16.png:areas:icon:tick", ref checkedOutResources, devIf); crossIcon = (TextureResource.Icon)devIf.GetSharedResource("file://Media/UI/InViewIconsX16.png:areas:icon:cross", ref checkedOutResources, devIf); // create GUI items // TODO: Needs layout manager support AddItem(new GUIIcon(new Point(10, 10), new Size(16, 16), xAxisIcon, true, true)); AddItem(new GUIIcon(new Point(32, 10), new Size(16, 16), yAxisIcon, true, true)); AddItem(new GUIIcon(new Point(54, 10), new Size(16, 16), zAxisIcon, true, true)); AddItem(LayoutManager.AlignItem(new GUIIcon(new Point(-48, -50), new Size(16, 16), tickIcon, true, false), LayoutRules.Positioning.Far, LayoutRules.Positioning.Far), null, null, OnTickClick); AddItem(LayoutManager.AlignItem(new GUIIcon(new Point(-32, -50), new Size(16, 16), crossIcon, true, false), LayoutRules.Positioning.Far, LayoutRules.Positioning.Far)); }
public Icon(string id, TextureResource texture, Rectangle facePixels, RectangleF faceCoords) { this.id = id; Texture = texture; FacePixels = facePixels; FaceCoords = faceCoords; }
private void ProcessSubAreas(XmlElement areas, TextureResource texRz, out TextureResource.Icon[] icons, string preamble) { XmlNodeList iconAreas = areas.SelectNodes("icon"); if (iconAreas != null && iconAreas.Count > 0) { icons = new TextureResource.Icon[iconAreas.Count]; int iconIdx = 0; foreach (XmlElement icon in iconAreas) { string id = icon.Attributes["id"].InnerText; // parse coords XmlNodeList coords = icon.SelectNodes("coords"); if (coords == null || coords.Count == 0) { throw new Exception("Icon found with no coords"); } icons[iconIdx] = new TextureResource.Icon(preamble + id, texRz, Rectangle.Empty, RectangleF.Empty); foreach (XmlElement coord in coords) { string coordId = coord.Attributes["id"].InnerText; int u = int.Parse(coord.Attributes["u"].InnerText); int v = int.Parse(coord.Attributes["v"].InnerText); int w = int.Parse(coord.Attributes["w"].InnerText); int h = int.Parse(coord.Attributes["h"].InnerText); Rectangle pixels = new Rectangle(u, v, w, h); RectangleF coordsR = new RectangleF((float)u / (float)texRz.Width, (float)v / (float)texRz.Height, (float)w / (float)texRz.Width, (float)h / (float)texRz.Height); if (coordId == "face") { icons[iconIdx].FacePixels = pixels; icons[iconIdx].FaceCoords = coordsR; } else if (coordId == "disabled") { icons[iconIdx].DisabledPixels = pixels; icons[iconIdx].DisabledCoords = coordsR; } else if (coordId == "highlight") { icons[iconIdx].HighlightPixels = pixels; icons[iconIdx].HighlightCoords = coordsR; } } iconIdx++; } } else { icons = null; } }
public override IResource LoadContent(string filePath, string rzPath, string subPath, string contentType, XmlNodeList rzNodes, out IResource[] loadedDependants, out IResource[] loadedDependancies, DeviceInterface devIf) { ILog log = devIf.CDI.GeneralLog; log.AddItem(new LogItem(string.Format("Starting loading texture rz ([{0}]{1})", contentType, rzPath), LogItem.ItemLevel.DebugInfo)); // load texture first ImageInformation imgInf = TextureLoader.ImageInformationFromFile(filePath); Texture texture = TextureLoader.FromFile(devIf.Device, filePath, imgInf.Width, imgInf.Height, 1, Usage.None, imgInf.Format, Pool.Managed, Filter.None, Filter.None, 0); log.AddItem(new LogItem(string.Format("Loaded texture rz ([{0}]{1})", contentType, rzPath), LogItem.ItemLevel.DebugInfo)); // process meta-data nodes TextureResource texRz = new TextureResource(rzPath, texture, null, imgInf.Width, imgInf.Height); TextureResource.Icon[] icons = null; foreach (XmlElement item in rzNodes) { if (item.Name == "areas") { // process sub-areas ProcessSubAreas(item, texRz, out icons, rzPath + ":areas:icon:"); } } texRz.Icons = icons; /*if (subPath != null) * { * loadedDependants = icons; * loadedDependancies = new IResource[] { texRz }; * return * } * else * {*/ loadedDependancies = null; loadedDependants = icons; return(texRz); //} }
private void ProcessSubAreas(XmlElement areas, TextureResource texRz, out TextureResource.Icon[] icons, string preamble) { XmlNodeList iconAreas = areas.SelectNodes("icon"); if (iconAreas != null && iconAreas.Count > 0) { icons = new TextureResource.Icon[iconAreas.Count]; int iconIdx = 0; foreach (XmlElement icon in iconAreas) { string id = icon.Attributes["id"].InnerText; // parse coords XmlNodeList coords = icon.SelectNodes("coords"); if (coords == null || coords.Count == 0) throw new Exception("Icon found with no coords"); icons[iconIdx] = new TextureResource.Icon(preamble + id, texRz, Rectangle.Empty, RectangleF.Empty); foreach (XmlElement coord in coords) { string coordId = coord.Attributes["id"].InnerText; int u = int.Parse(coord.Attributes["u"].InnerText); int v = int.Parse(coord.Attributes["v"].InnerText); int w = int.Parse(coord.Attributes["w"].InnerText); int h = int.Parse(coord.Attributes["h"].InnerText); Rectangle pixels = new Rectangle(u, v, w, h); RectangleF coordsR = new RectangleF((float)u / (float)texRz.Width, (float)v / (float)texRz.Height, (float)w / (float)texRz.Width, (float)h / (float)texRz.Height); if (coordId == "face") { icons[iconIdx].FacePixels = pixels; icons[iconIdx].FaceCoords = coordsR; } else if (coordId == "disabled") { icons[iconIdx].DisabledPixels = pixels; icons[iconIdx].DisabledCoords = coordsR; } else if (coordId == "highlight") { icons[iconIdx].HighlightPixels = pixels; icons[iconIdx].HighlightCoords = coordsR; } } iconIdx++; } } else icons = null; }
public override IResource LoadContent(string filePath, string rzPath, string subPath, string contentType, XmlNodeList rzNodes, out IResource[] loadedDependants, out IResource[] loadedDependancies, DeviceInterface devIf) { ILog log = devIf.CDI.GeneralLog; log.AddItem(new LogItem(string.Format("Starting loading texture rz ([{0}]{1})", contentType, rzPath), LogItem.ItemLevel.DebugInfo)); // load texture first ImageInformation imgInf = TextureLoader.ImageInformationFromFile(filePath); Texture texture = TextureLoader.FromFile(devIf.Device, filePath, imgInf.Width, imgInf.Height, 1, Usage.None, imgInf.Format, Pool.Managed, Filter.None, Filter.None, 0); log.AddItem(new LogItem(string.Format("Loaded texture rz ([{0}]{1})", contentType, rzPath), LogItem.ItemLevel.DebugInfo)); // process meta-data nodes TextureResource texRz = new TextureResource(rzPath, texture, null, imgInf.Width, imgInf.Height); TextureResource.Icon[] icons = null; foreach (XmlElement item in rzNodes) { if (item.Name == "areas") { // process sub-areas ProcessSubAreas(item, texRz, out icons, rzPath + ":areas:icon:"); } } texRz.Icons = icons; /*if (subPath != null) { loadedDependants = icons; loadedDependancies = new IResource[] { texRz }; return } else {*/ loadedDependancies = null; loadedDependants = icons; return texRz; //} }
public GUIIcon(Point origin, Size dimensions, TextureResource.Icon icon, bool highlight, bool enabled) : base(origin, dimensions, icon.Texture) { this.icon = icon; this.highlight = highlight; wantMouseOver = true; this.enabled = enabled; }
public GUIImage(Point origin, Size dimensions, TextureResource texture) : base(origin, dimensions) { this.texture = texture; }