com.daxie.xops.xgs.XGSWriter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xopsmanipulator Show documentation
Show all versions of xopsmanipulator Show documentation
XOPSManipulator is a Java library that offers several functions to manipulate matters relating to X operations.
The newest version!
package com.daxie.xops.xgs;
import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import com.daxie.basis.vector.Vector;
import com.daxie.log.LogFile;
import com.daxie.tool.ByteFunctions;
import com.daxie.tool.ExceptionFunctions;
import com.daxie.xops.XOPSConstants;
import com.daxie.xops.weapon.WeaponBinSpecifierAndEnumConverter;
import com.daxie.xops.weapon.WeaponData;
import com.daxie.xops.weapon.WeaponModelFilenamesStock;
import com.daxie.xops.weapon.WeaponModelType;
import com.daxie.xops.weapon.WeaponScopeMode;
import com.daxie.xops.weapon.WeaponShootingStance;
import com.daxie.xops.weapon.WeaponTextureFilenamesStock;
import com.daxie.xops.weapon.WeaponTextureType;
/**
* Writes data to a XGS file.
* @author Daba
*
*/
class XGSWriter {
private WeaponData[] weapon_data_array=null;
public XGSWriter(WeaponData[] weapon_data_array) {
this.weapon_data_array=weapon_data_array;
}
public void Write(String xgs_filename) throws FileNotFoundException{
if(weapon_data_array==null) {
LogFile.WriteWarn("[XGSWriter-Write] Data is null.",true);
return;
}
if(weapon_data_array.length!=XOPSConstants.WEAPON_NUM) {
LogFile.WriteWarn("[XGSWriter-Write] Invalid number of data. data_num:"+weapon_data_array.length,true);
return;
}
DataOutputStream dos;
dos=new DataOutputStream(
new BufferedOutputStream(
new FileOutputStream(xgs_filename)));
try {
dos.writeByte(0x58);//X
dos.writeByte(0x47);//G
dos.writeByte(0x53);//S
dos.writeByte(0x00);
dos.writeByte(0x01);
dos.writeByte(0x00);
dos.writeByte(0x0E);
dos.writeByte(0x00);
dos.writeByte(0x17);
dos.writeByte(0x00);
dos.writeByte(0x1D);
dos.writeByte(0x00);
dos.writeByte(0x08);
dos.writeByte(0x00);
for(int i=0;i=15)break;
name_buffer[j]=(byte)name.charAt(j);
}
dos.write(name_buffer);
}
for(int i=0;i<16;i++) {
dos.writeByte(0x00);
}
}
catch(IOException e) {
String str=ExceptionFunctions.GetPrintStackTraceString(e);
LogFile.WriteWarn("[XGSWriter-Write] Below is the stack trace.",true);
LogFile.WriteWarn(str,false);
return;
}
finally {
try {
dos.close();
}
catch(IOException e) {
String str=ExceptionFunctions.GetPrintStackTraceString(e);
LogFile.WriteWarn("[XGSWriter-Write] Below is the stack trace.",true);
LogFile.WriteWarn(str,false);
return;
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy