else if (ac.equals(COPY_SECTOR)) { pasteSector.setEnabled(true);  int[] sectorXY = gfxcontrol.getSectorxy(); for (int i = 0; i < copiedSectorTiles.length; i++) for (int j = 0; j < copiedSectorTiles[i].length; j++) { copiedSectorTiles[i][j][0] = EbMap.getTile(rom, j + sectorXY[0] * sectorWidth, i + sectorXY[1] * sectorHeight); copiedSectorTiles[i][j][1] = EbMap.getLocalTileset(rom, j + sectorXY[0] * sectorWidth, i + sectorXY[1] * sectorHeight); } copiedSector = EbMap.getSectorData(sectorXY[0], sectorXY[1]); } else if (ac.equals(PASTE_SECTOR)) { int[] sectorXY = gfxcontrol.getSectorxy(); for (int i = 0; i < copiedSectorTiles.length; i++) for (int j = 0; j < copiedSectorTiles[i].length; j++) { EbMap.changeTile(sectorXY[0] * sectorWidth + j, sectorXY[1] * sectorHeight + i, (byte) (copiedSectorTiles[i][j][0] & 0xff)); EbMap.setLocalTileset(rom, sectorXY[0] * sectorWidth + j, sectorXY[1] * sectorHeight + i, copiedSectorTiles[i][j][1]); } EbMap.setSectorData(sectorXY[0], sectorXY[1], copiedSector); gfxcontrol.reloadMap(); gfxcontrol.repaint(); gfxcontrol.updateComponents(); }
		public void actionPerformed(ActionEvent e)		{			String ac = e.getActionCommand();			if (ac.equals(SAVE))			{				writeToRom();			}			else if (ac.equals(EXIT))			{				hide();			}			else if (ac.equals(MODE0))			{				gfxcontrol.changeMode(0);	            gfxcontrol.remoteRepaint();	            gfxcontrol.getTileChooser().remoteRepaint();			}			else if (ac.equals(MODE1))			{				gfxcontrol.changeMode(1);	            gfxcontrol.remoteRepaint();	            gfxcontrol.getTileChooser().remoteRepaint();			}			else if (ac.equals(MODE2))			{				gfxcontrol.changeMode(2);				gfxcontrol.remoteRepaint();				gfxcontrol.getTileChooser().remoteRepaint();			}			else if (ac.equals(MODE6))			{				gfxcontrol.changeMode(6);				gfxcontrol.remoteRepaint();				gfxcontrol.getTileChooser().remoteRepaint();			}			else if (ac.equals(DEL_ALL_SPRITES))			{        		int sure = JOptionPane.showConfirmDialog(        			    mainWindow,        			    "Are you sure you want to "						+ "delete all of the sprites?",        			    "Are you sure?",        			    JOptionPane.YES_NO_OPTION);        		if (sure == JOptionPane.YES_OPTION)        		{        			EbMap.nullSpriteData();        			gfxcontrol.remoteRepaint();        		}			}			else if (ac.equals(RESET_TILE_IMAGES))			{				EbMap.resetTileImages();				if (gfxcontrol.getModeProps()[1] >= 2)				{					gfxcontrol.remoteRepaint();					gfxcontrol.getTileChooser().remoteRepaint();				}			}			else if (ac.equals(RESET_SPRITE_IMAGES))			{				EbMap.resetSpriteImages();				gfxcontrol.remoteRepaint();			}			else if (ac.equals(GRIDLINES))			{				gfxcontrol.toggleGrid();				gfxcontrol.remoteRepaint();			}			else if (ac.equals(SPRITEBOXES))			{				gfxcontrol.toggleSpriteBoxes();				gfxcontrol.remoteRepaint();			}			else if (ac.equals(COMPATABILITY))			{				oldCompatability = ! oldCompatability;			}			else if (ac.equals(MAPCHANGES))			{				gfxcontrol.toggleMapChanges();				gfxcontrol.remoteRepaint();			}			else if (ac.equals(MUSIC_NAMES))				gfxcontrol.reloadMusicNames();			else if (ac.equals(SECTOR_PROPS))				net.starmen.pkhack.JHack.main.showModule(						MapSectorPropertiesEditor.class, gfxcontrol.getSectorxy());			else if (ac.equals(FIND_SPRITE))			{				String tpt = JOptionPane.showInputDialog(                        mainWindow,                        "Enter TPT entry to search for.",                        Integer.toHexString(0));				if (tpt != null)				{					int tptNum = Integer.parseInt(tpt, 16);					for (int i = 0; i < (MapEditor.heightInSectors / 2) * MapEditor.widthInSectors; i++)					{						ArrayList sprites = EbMap.getSpritesData(i);						EbMap.SpriteLocation spLoc;						for (int j = 0; j < sprites.size(); j++)						{							spLoc = (EbMap.SpriteLocation) sprites.get(j);							if (spLoc.getTpt() == tptNum)							{								int areaY = i / MapEditor.widthInSectors,									areaX = i - (areaY * MapEditor.widthInSectors);								gfxcontrol.setMapXY(										(areaX * MapEditor.sectorWidth) + (spLoc.getX() / MapEditor.tileWidth),										(areaY * MapEditor.sectorHeight * 2) + (spLoc.getY() / MapEditor.tileHeight));								gfxcontrol.reloadMap();								gfxcontrol.updateComponents();								gfxcontrol.repaint();								int yesno = JOptionPane.showConfirmDialog(					    			    mainWindow,					    			    "I found a sprite with that TPT entry. Do you want to find another?",					    			    "Continue Search?",					    			    JOptionPane.YES_NO_OPTION);					    		if (yesno == JOptionPane.NO_OPTION)					    			return;							}						}					}					JOptionPane.showMessageDialog(mainWindow,							"Could not find a sprite entry using TPT entry 0x" + tpt + ".");				}			}			else if (ac.equals(DOOR_ERR))			{				ArrayList errors = EbMap.getErrors();				if (errors.size() == 0)					JOptionPane.showMessageDialog(mainWindow, "No errors encountered!");				else				{					int num = 0;					String out = "";					for (int i = 0; i < errors.size(); i++)					{						EbMap.ErrorRecord er = (EbMap.ErrorRecord) errors.get(i);						if (er.getType() == EbMap.ErrorRecord.DOOR_ERROR)						{							out = out + "#" + (num + 1) + ": " + er.getMessage()									+ System.getProperty("line.separator");							num++;						}					}										if (num == 0)						JOptionPane.showMessageDialog(mainWindow, "No door errors encountered!");					else					{						errorWindow.setTitle("Door Errors - Map Editor");						errorTitle.setText(errors.size()								+ " errors were encountered while reading door entry data.");						errorText.setText(out);						errorWindow.pack();						errorWindow.show();					}				}			}			else if (ac.equals(SPRITE_ERR))			{				ArrayList errors = EbMap.getErrors();				if (errors.size() == 0)					JOptionPane.showMessageDialog(mainWindow, "No errors encountered!");				else				{					int num = 0;					String out = "";					for (int i = 0; i < errors.size(); i++)					{						EbMap.ErrorRecord er = (EbMap.ErrorRecord) errors.get(i);						if (er.getType() == EbMap.ErrorRecord.SPRITE_ERROR)						{							out = out + "#" + (num + 1) + ": " + er.getMessage()									+ System.getProperty("line.separator");							num++;						}					}										if (num == 0)						JOptionPane.showMessageDialog(mainWindow, "No sprite errors encountered!");					else					{						errorWindow.setTitle("Sprite Errors - Map Editor");						errorTitle.setText(errors.size()								+ " errors were encountered while reading sprite entry data.");						errorText.setText(out);						errorWindow.pack();						errorWindow.show();					}				}			}		}