public bool LoadXML_bgmaps(XmlNode xnode) { foreach (XmlNode xn in xnode.ChildNodes) { switch (xn.Name) { case "map16": string strName = XMLUtils.GetXMLAttribute(xn, "name"); int id = XMLUtils.GetXMLIntegerAttribute(xn, "id"); string strDesc = XMLUtils.GetXMLAttribute(xn, "desc"); string strSize = XMLUtils.GetXMLAttribute(xn, "size"); int nSpritesetId = XMLUtils.GetXMLIntegerAttribute(xn, "bgspriteset_id"); int nDefaultSubpaletteId = XMLUtils.GetXMLIntegerAttribute(xn, "default_subpalette_id"); string[] aSize = strSize.Split('x'); int nWidth = XMLUtils.ParseInteger(aSize[0]); int nHeight = XMLUtils.ParseInteger(aSize[1]); Spriteset ts = m_doc.BackgroundSpritesets.GetSpriteset(nSpritesetId); Map m = AddMap(strName, id, strDesc, ts); if (!m.LoadXML_map16(xn, nDefaultSubpaletteId)) { return(false); } break; } } return(true); }
public void Test_LoadXML_map16_32x32() { Palette p = m_doc.BackgroundPalettes.AddPalette16(Options.DefaultBgPaletteName, 0, ""); Assert.IsNotNull(p); Spriteset ss = m_doc.BackgroundSpritesets.AddSpriteset(Options.DefaultBgTilesetName, 0, "", p); Assert.IsNotNull(ss); Map m = m_doc.BackgroundMaps.AddMap("map", 0, "", ss); Assert.AreEqual(1, m_doc.BackgroundMaps.NumMaps); Assert.IsNotNull(m); // Valid map. XmlElement xnMap = m_xd.CreateElement("map16"); Test_LoadXML_map16_AddBlock(xnMap, 0, 32, 32); // <map16> attributes are not needed for test. Assert.IsTrue(m.LoadXML_map16(xnMap, 0)); int nTileId, nSubpaletteId; bool fHorizontal, fVertical; m.GetTile(2, 4, out nTileId, out nSubpaletteId); m.GetFlip(2, 4, out fHorizontal, out fVertical); Assert.AreEqual(6, nTileId); Assert.AreEqual(0, nSubpaletteId); m.GetTile(7, 9, out nTileId, out nSubpaletteId); Assert.AreEqual(16, nTileId); Assert.AreEqual(0, nSubpaletteId); m.GetTile(31, 31, out nTileId, out nSubpaletteId); Assert.AreEqual(62, nTileId); Assert.AreEqual(1, nSubpaletteId); // x==y, so subpalette=1 m.GetFlip(0, 0, out fHorizontal, out fVertical); Assert.IsTrue(fHorizontal); Assert.IsTrue(fVertical); m.GetFlip(0, 5, out fHorizontal, out fVertical); Assert.IsFalse(fHorizontal); Assert.IsTrue(fVertical); m.GetFlip(5, 0, out fHorizontal, out fVertical); Assert.IsTrue(fHorizontal); Assert.IsFalse(fVertical); m.GetFlip(5, 5, out fHorizontal, out fVertical); Assert.IsFalse(fHorizontal); Assert.IsFalse(fVertical); }
public void Test_LoadXML_map16_32x32_33columns() { Palette p = m_doc.BackgroundPalettes.AddPalette16(Options.DefaultBgPaletteName, 0, ""); Assert.IsNotNull(p); Spriteset ss = m_doc.BackgroundSpritesets.AddSpriteset(Options.DefaultBgTilesetName, 0, "", p); Assert.IsNotNull(ss); Map m = m_doc.BackgroundMaps.AddMap("map", 0, "", ss); Assert.AreEqual(1, m_doc.BackgroundMaps.NumMaps); Assert.IsNotNull(m); // Valid map. XmlElement xnMap = m_xd.CreateElement("map16"); Test_LoadXML_map16_AddBlock(xnMap, 0, 33, 32); Assert.IsFalse(m.LoadXML_map16(xnMap, 0)); }