public ContributionReference(HalfVoxelContribution hvc, int color, int hilight, Direction front, PlaceSide side) { this.contrib = hvc; this.colorIdx = color; this.hilightIdx = hilight; this.placeSide = side; this.frontface = front; this.patternIdx = SpriteSet.getIndexOf(front, side); }
protected virtual void loadHighSprites(XmlElement e, XmlElement hle) { Picture pic = getPicture(hle, "HL"); if (pic == null || hle.Attributes["src"] == null) { throw new FormatException("highlight picture not found."); } string baseFileName = XmlUtil.resolve(hle, hle.Attributes["src"].Value).LocalPath; using (Bitmap bit = new Bitmap(baseFileName)) { for (int i = 0; i < hl_patterns; i++) { hilights[i] = new SpriteSet(8); } XmlNode cn = e.FirstChild; while (cn != null) { if (cn.Name.Equals("pattern")) { SideStored ss = parseSide(cn); Direction d = parseDirection(cn); Point orgn = XmlUtil.parsePoint(cn.Attributes["origin"].Value); Point offF = getOffset(d, PlaceSide.Fore); Point offB = getOffset(d, PlaceSide.Back); Size sz = new Size(24, 8 + height * 16); // create highlight patterns XmlNode hlp = cn.SelectSingleNode("highlight"); if (hlp != null) { HueShiftSpriteFactory factory = new HueShiftSpriteFactory(hl_patterns); if ((ss & SideStored.Fore) != 0) { Sprite[] arr = factory.createSprites(bit, pic, offF, orgn, sz); for (int i = 0; i < hl_patterns; i++) { hilights[i][d, PlaceSide.Fore] = arr[i]; } } if ((ss & SideStored.Back) != 0) { Sprite[] arr = factory.createSprites(bit, pic, offB, orgn, sz); for (int i = 0; i < hl_patterns; i++) { hilights[i][d, PlaceSide.Back] = arr[i]; } } } } //if(cn.Name.Equals("pattern")) cn = cn.NextSibling; } //while } //using }
/// <summary> /// Parses a commercial structure contribution from a DOM node. /// </summary> /// <exception cref="XmlException">If the parsing fails</exception> public HalfVoxelContribution(XmlElement e) : base(e) { _price = int.Parse(XmlUtil.selectSingleNode(e, "price").InnerText); height = int.Parse(XmlUtil.selectSingleNode(e, "height").InnerText); subgroup = XmlUtil.selectSingleNode(e, "subgroup").InnerText; XmlElement spr = (XmlElement)XmlUtil.selectSingleNode(e, "sprite"); XmlElement pic = (XmlElement)XmlUtil.selectSingleNode(spr, "picture"); variation = spr.SelectSingleNode("map"); if (variation != null) { String idc = variation.Attributes["to"].Value; colors = PluginManager.theInstance.getContribution(idc) as ColorLibrary; sprites = new SpriteSet[colors.size]; for (int i = 0; i < colors.size; i++) { sprites[i] = new SpriteSet(8); } } else { colors = ColorLibrary.NullLibrary; sprites = new SpriteSet[1]; sprites[0] = new SpriteSet(8); } loadSprites(spr, pic); XmlElement hle = (XmlElement)spr.SelectSingleNode("highlight"); if (hle != null) { hilights = new SpriteSet[hl_patterns]; loadHighSprites(spr, hle); } else { hilights = null; } }
public SpriteSet(SpriteSet org, Color variation) { }