else if (gfxcontrol.getModeProps()[4] == 2)
else if ((gfxcontrol.getModeProps()[4] == 2) && (! movingDoor))
        public void mouseClicked(MouseEvent e)        {            // System.out.println("Mouse clicked! Button: " + e.getButton());        	// System.out.println("Mouse clicked! Data: " + e);        	if (e.getButton() == 1)        	{        		if (editbox.knowsTsetPal()         				&& (gfxcontrol.getModeProps()[2] == 1))        		{            		int mapx = e.getX() / MapEditor.tileWidth;            		int mapy = e.getY() / MapEditor.tileHeight;            		if (e.getModifiers() == 17)            		{            			int selected = EbMap.getTile(rom,            					mapx + gfxcontrol.getMapX(),								mapy + gfxcontrol.getMapY());            			int selectedPos;                		if (selected > (1024 / (editHeight + 1)) - editWidth)                			selectedPos = (selected / (editHeight + 1)) - editWidth;                		else                			selectedPos = selected / (editHeight + 1);            			editbox.setSelected(selected);            			scrollh2.setValue(selectedPos);            			editbox.remoteRepaint();            		}            		else if (editbox.isSelected())            		{                		int tile = editbox.getSelected();                		int localtset = 0;                		for (int i = 1; editbox.getSelected() - (i << 8) >= 0; i++)                		{                			tile -= (1 << 8);                			localtset++;                		}                		                		EbMap.changeTile(rom,                				gfxcontrol.getMapX() + mapx,    							gfxcontrol.getMapY() + mapy, tile);                		gfxcontrol.changeMapArray(mapx, mapy, tile);                		EbMap.setLocalTileset(rom,                				gfxcontrol.getMapX() + mapx,    							gfxcontrol.getMapY() + mapy,                				localtset);                		gfxcontrol.remoteRepaint();            		}        		}        		else if (gfxcontrol.getMode() == 3)        		{        			doorEditor.setDestXY(        					(gfxcontrol.getMapX() * 4) + (e.getX() / 8),							(gfxcontrol.getMapY() * 4) + (e.getY() / 8));        			doorEditor.enableSetXY();        			gfxcontrol.changeMode(gfxcontrol.getOldMode());        			gfxcontrol.remoteRepaint();        		}        		else if (gfxcontrol.getMode() == 4)        		{        			gfxcontrol.getSeekSource().returnSeek(        					e.getX(), e.getY(),        					gfxcontrol.getMapX(), gfxcontrol.getMapY());        			gfxcontrol.changeMode(gfxcontrol.getOldMode());        			if (userShown)        				gfxcontrol.remoteRepaint();        			else        				hide();        		}        	}            else if (e.getButton() == 3)            {            	if ((gfxcontrol.getModeProps()[3] == 1)            			&& (! movingSprite))            	{            		JPopupMenu popup = new JPopupMenu();                	int spNum = gfxcontrol.getSpriteNum(                			e.getX(), e.getY());                	if (spNum != -1)                	{                		int[] spLoc =                			gfxcontrol.getCoords(e.getX(), e.getY());                		PopupListener popupListener =                			new PopupListener(spLoc[0], spLoc[1],                					spLoc[2], spLoc[3], spNum);                		popup.add(EbHackModule.createJMenuItem(                        		"Add sprite", 'a', null, 								PopupListener.ADD_SPRITE, 								popupListener));                		popup.add(EbHackModule.createJMenuItem(                        		"Delete sprite", 'd', null, 								PopupListener.DEL_SPRITE, 								popupListener));                		popup.add(EbHackModule.createJMenuItem(                        		"Cut sprite", 'u', null, 								PopupListener.CUT_SPRITE, 								popupListener));                		popup.add(EbHackModule.createJMenuItem(                        		"Copy sprite", 'c', null, 								PopupListener.COPY_SPRITE, 								popupListener));                		if (copyTpt >= 0)                			popup.add(EbHackModule.createJMenuItem(                            		"Paste sprite", 'p', null,     								PopupListener.PASTE_SPRITE,     								popupListener));                		String tpt = addZeros(Integer.toHexString(                				EbMap.getSpriteTpt(                				spLoc[0], spLoc[1], spNum)),4);                		popup.add(EbHackModule.createJMenuItem(                				"Switch TPT entry (" + tpt + ")",								's', null,								PopupListener.CHANGE_TPT, 								popupListener));                		popup.add(EbHackModule.createJMenuItem(                				"Edit TPT entry (" + tpt + ")",								'e', null,								PopupListener.EDIT_TPT, 								popupListener));                	}                	else                	{                		int[] spLoc =                			gfxcontrol.getCoords(e.getX(), e.getY());                		PopupListener popupListener =                			new PopupListener(spLoc[0], spLoc[1],                					spLoc[2], spLoc[3]);                		popup.add(EbHackModule.createJMenuItem(                        		"Add sprite", 'a', null, 								PopupListener.ADD_SPRITE, 								popupListener));                		if (copyTpt >= 0)                			popup.add(EbHackModule.createJMenuItem(                            		"Paste sprite", 'p', null,     								PopupListener.PASTE_SPRITE,     								popupListener));                	}                    popup.show(gfxcontrol,                     		e.getX(), 							e.getY());            	}            	else if (gfxcontrol.getModeProps()[4] == 2)            	{               		JPopupMenu popup = new JPopupMenu();                	int num = gfxcontrol.getDoorNum(                			e.getX(), e.getY());                	int[] doorCoords =            			gfxcontrol.getCoords(e.getX(), e.getY());                	if (num != -1)                	{                		PopupListener popupListener =                			new PopupListener(doorCoords[0], doorCoords[1],                					doorCoords[2], doorCoords[3], num);                		popup.add(EbHackModule.createJMenuItem(                        		"Add door", 'a', null, 								PopupListener.ADD_DOOR, 								popupListener));                		popup.add(EbHackModule.createJMenuItem(                        		"Delete door", 'd', null, 								PopupListener.DEL_DOOR, 								popupListener));                		/*popup.add(EbHackModule.createJMenuItem(                        		"Cut sprite", 'u', null, 								PopupListener.CUT_SPRITE, 								popupListener));                		popup.add(EbHackModule.createJMenuItem(                        		"Copy sprite", 'c', null, 								PopupListener.COPY_SPRITE, 								popupListener));                		if (copyTpt >= 0)                			popup.add(EbHackModule.createJMenuItem(                            		"Paste sprite", 'p', null,     								PopupListener.PASTE_SPRITE,     								popupListener));*/                		String dest = Integer.toString(                				EbMap.getDoorLocation(                						doorCoords[0], doorCoords[1], num)										.getDestIndex());                		popup.add(EbHackModule.createJMenuItem(                				"Edit entry (Destination #" + dest + ")",								's', null,								PopupListener.EDIT_DEST, 								popupListener));                	}                	else                	{                		PopupListener popupListener =                			new PopupListener(doorCoords[0], doorCoords[1],                					doorCoords[2], doorCoords[3]);                		popup.add(EbHackModule.createJMenuItem(                        		"Add door", 'a', null, 								PopupListener.ADD_DOOR, 								popupListener));                		/*if (copyTpt >= 0)                			popup.add(EbHackModule.createJMenuItem(                            		"Paste sprite", 'p', null,     								PopupListener.PASTE_SPRITE,     								popupListener));*/                	}                    popup.show(gfxcontrol,                     		e.getX(), 							e.getY());            	}            	else if (gfxcontrol.getModeProps()[0] == 2)            	{            		changingSectors = true;                    int mousex = e.getX();                    int mousey = e.getY();                    int sectorx = getSectorXorY(getTileXorY(mousex,                        MapEditor.tileWidth) + gfxcontrol.getMapX(), sectorWidth);                    int sectory = getSectorXorY(getTileXorY(mousey,                        MapEditor.tileHeight) + gfxcontrol.getMapY(), MapEditor.sectorHeight);                                        int tset = EbMap.getTset(sectorx, sectory);                    int pal = EbMap.getPal(sectorx, sectory);                    int music = EbMap.getMusic(sectorx, sectory);                    int[] modeprops = gfxcontrol.getModeProps();                    tilesetList.setSelectedIndex(tset);                    paletteField.setValue(new Integer(pal));                    musicField.setValue(new Integer(music));                                        palette = pal;                                        if (modeprops[2] == 1)                    {                    	boolean isSame = editbox.setTsetPal(                    			EbMap.getDrawTileset(rom, tset),                                TileEditor.tilesets[EbMap.getDrawTileset(rom,                                 		tset)].getPaletteNum(tset,                                				pal));                    	if (! isSame)                    	{                    		editbox.remoteRepaint();                    	}                    }                    gfxcontrol.setSector(sectorx, sectory);                    gfxcontrol.remoteRepaint();                    changingSectors = false;            	}            }        }