mReplace.add(miFixLines);
}
// action listener
public void actionPerformed(ActionEvent e) {
adt obj;
openedFile os = fm.getActiveFile();
if(os.obj instanceof adt) {
obj = (adt)os.obj;
}
else return;
// kill all waters
if(e.getSource()==miKillWater) {
if(obj.getVersion()==adt.ADT_VERSION_NORMAL
|| obj.getVersion()==adt.ADT_VERSION_EXPANSION_TBC) {
for(int c=0; c<256; c++) {
obj.mcnk[c].mclq = new MCLQ();
obj.mcnk[c].setFlags(obj.mcnk[c].getFlags() & 0x3);
}
}
else {
System.err.println("ADT Version is not suported jet.");
}
}
// kill all shadows
else if(e.getSource()==miKillShadows) {
if(obj.getVersion()==adt.ADT_VERSION_NORMAL
|| obj.getVersion()==adt.ADT_VERSION_EXPANSION_TBC) {
for(int c=0; c<256; c++) {
obj.mcnk[c].mcsh= new MCSH();
}
}
else {
System.err.println("ADT Version is not suported jet.");
}
}
else if(e.getSource()==miInjectAlpha) {
Vector<openedFile> choices = fm.getFileList();
openedFile result = (openedFile) JOptionPane.showInputDialog(
miInjectAlpha.getComponent(),
"Chose a Source File:\n",
"Inject",
JOptionPane.PLAIN_MESSAGE,
null,
choices.toArray(),
null);
if(result==null) return;
if(result.obj instanceof adt) {
adt injObj = (adt) result.obj;
obj.mtex=injObj.mtex;
for(int c=0; c<256; c++) {
obj.mcnk[c].setNLayers(injObj.mcnk[c].getNLayers());
obj.mcnk[c].mcal=injObj.mcnk[c].mcal;
obj.mcnk[c].mcly=injObj.mcnk[c].mcly;
}
}
}
else if(e.getSource()==miInjectDoodads) {
Vector<openedFile> choices = fm.getFileList();
openedFile result = (openedFile) JOptionPane.showInputDialog(
miInject.getComponent(),
"Chose a Source File:\n",
"Inject",
JOptionPane.PLAIN_MESSAGE,
null,
choices.toArray(),
null);
if(result==null) return;
float xpos,ypos,oldy,oldx;
//get new position
ypos=533.33f*Integer.parseInt(os.f.getAbsolutePath().substring(os.f.getAbsolutePath().length()-6, os.f.getAbsolutePath().length()-4));
xpos=533.33f*Integer.parseInt(os.f.getAbsolutePath().substring(os.f.getAbsolutePath().length()-9, os.f.getAbsolutePath().length()-7));
//get old position
oldy=533.33f*Integer.parseInt(result.f.getAbsolutePath().substring(result.f.getAbsolutePath().length()-6, result.f.getAbsolutePath().length()-4));
oldx=533.33f*Integer.parseInt(result.f.getAbsolutePath().substring(result.f.getAbsolutePath().length()-9, result.f.getAbsolutePath().length()-7));
if(result.obj instanceof adt) {
adt injObj = (adt) result.obj;
injObj.mddf.render();
injObj.modf.render();
injObj.mwmo.render();
injObj.mmdx.render();
injObj.mmid.render();
injObj.mwid.render();
try {
MDDF mddf=new MDDF(injObj.mddf.buff);
MODF modf=new MODF(injObj.modf.buff);
MWMO mwmo=new MWMO(injObj.mwmo.buff);
MMDX mmdx=new MMDX(injObj.mmdx.buff);
MMID mmid=new MMID(injObj.mmid.buff);
MWID mwid=new MWID(injObj.mwid.buff);
{
obj.mddf=mddf;
obj.modf=modf;
obj.mwmo=mwmo;
obj.mmdx=mmdx;
obj.mmid=mmid;
obj.mwid=mwid;
}
for(int i=0;i<obj.mddf.entrys.length;i++)
{
float newval;
newval=(obj.mddf.entrys[i].translate(obj.mddf.entrys[i].getY())-(xpos-oldx));
obj.mddf.entrys[i].setY(obj.mddf.entrys[i].translate(newval));
newval=(obj.mddf.entrys[i].translate(obj.mddf.entrys[i].getX())-(ypos-oldy));
obj.mddf.entrys[i].setX(obj.mddf.entrys[i].translate(newval));
}
for(int i=0;i<obj.modf.entrys.length;i++)
{
float newval;
newval=(obj.modf.entrys[i].translate(obj.modf.entrys[i].getY())-(xpos-oldx));
obj.modf.entrys[i].setY(obj.modf.entrys[i].translate(newval));
newval=(obj.modf.entrys[i].translate(obj.modf.entrys[i].getX())-(ypos-oldy));
obj.modf.entrys[i].setX(obj.modf.entrys[i].translate(newval));
}
} catch (ChunkNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
for(int c=0; c<256; c++) {
obj.mcnk[c].setNDoodad(injObj.mcnk[c].getNDoodad());
injObj.mcnk[c].mcrf.render();
try{
MCRF mcrf=new MCRF(injObj.mcnk[c].mcrf.buff);
obj.mcnk[c].mcrf=mcrf;
}
catch (ChunkNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
}
// inject heightmap
else if(e.getSource()==miInject) {
Vector<openedFile> choices = fm.getFileList();
openedFile result = (openedFile) JOptionPane.showInputDialog(
miInject.getComponent(),
"Chose a Source File:\n",
"Inject",
JOptionPane.PLAIN_MESSAGE,
null,
choices.toArray(),
null);
if(result==null) return;
if(result.obj instanceof adt) {
adt injObj = (adt) result.obj;
for(int c=0; c<256; c++) {
obj.mcnk[c].mcvt = injObj.mcnk[c].mcvt;
obj.mcnk[c].setHeightOffs(
injObj.mcnk[c].getHeightOffs()
);