/// <summary> /// Handle a mouse move while the mouse button is held down. /// </summary> /// <param name="pxX"></param> /// <param name="pxY"></param> /// <param name="tool"></param> /// <returns>True if we need to update the map display.</returns> public bool HandleMouse(int pxX, int pxY, Toolbox.ToolType tool) { Sprite spriteSelected = m_ss.CurrentSprite; if (spriteSelected == null) { return(false); } if (pxX < 0 || pxY < 0) { return(false); } // Convert screen pixel (x,y) to map coordinate (x,y). int x = pxX / Tile.SmallBitmapScreenSize; int y = pxY / Tile.SmallBitmapScreenSize; if (x >= k_nMaxMapTilesX || y >= k_nMaxMapTilesY) { return(false); } if (tool == Toolbox.ToolType.FloodFill) { return(FloodFillClick(x, y)); } if (tool == Toolbox.ToolType.RubberStamp) { bool fUpdate = false; int nIndex = 0; for (int iy = 0; iy < spriteSelected.TileHeight; iy++) { if (y + iy >= k_nMaxMapTilesY) { nIndex++; continue; } for (int ix = 0; ix < spriteSelected.TileWidth; ix++) { if (x + ix >= k_nMaxMapTilesX) { nIndex++; continue; } m_map.SetTile(x + ix, y + iy, spriteSelected.FirstTileId + nIndex, spriteSelected.SubpaletteID); nIndex++; fUpdate = true; } } return(fUpdate); } return(false); }
private bool LoadXML_OLD_map(XmlNodeList xnl) { int x = 0; int y = 0; Map m = m_doc.BackgroundMaps.AddMap(Options.DefaultMapName, 0, "", m_doc.BackgroundSpritesets.GetSpriteset(0)); foreach (XmlNode xn in xnl) { if (xn.Name == "row") { if (y >= 32) { m_doc.ErrorString("Too many rows specified for map"); return(false); } x = 0; foreach (XmlNode xn2 in xn.ChildNodes) { int nTileID = XMLUtils.GetXMLIntegerAttribute(xn2, "tileid"); int nPaletteID = 0; // = Int32.Parse(GetXMLAttribute(xn2, "palette")); if (x < 32 && y < 32) { m.SetTile(x, y, nTileID, nPaletteID); } x++; } if (x != 32) { m_doc.ErrorString("Incorrect number of tiles ({0}) in row {1} of map (expected 32 tiles)", x, y); return(false); } y++; } } if (y != 32) { m_doc.ErrorString("Not enough rows specified for map"); return(false); } return(true); }