I already found the GB to SG converter, but I was looking for something to do it the reverse. Couldn't find anything so I wrote one in java. Its messy, but just open the file you want to convert and it'll do its thing. The file will be saved to the same directory where the jar file is.
Source:
Code:
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JFileChooser;
public class Main {
public static void main(String[] args) throws FileNotFoundException{
ConverterClass c = new ConverterClass();
}
static class ConverterClass{
public ConverterClass() throws FileNotFoundException{
try {
doStuff();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private static void doStuff() throws IOException{
String x;
String y;
String z;
boolean cont = true;
Pattern p = Pattern.compile(">(.*)<");
final JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(new File(new File(".").getAbsolutePath()));
fc.showOpenDialog(fc);
File f = new File(fc.getSelectedFile().getName().substring(0, fc.getSelectedFile().getName().length() - 4) + " - Converted.xml");
FileWriter fw = new FileWriter(f);
PrintWriter pw = new PrintWriter(fw);
Scanner s = new Scanner(fc.getSelectedFile());
//Write the Header for the HB Profile
pw.print("<HBProfile>\n\t<Name></Name>\n\t<MinDurability>0.4</MinDurability>\n\t<MinFreeBagSlots>1</MinFreeBagSlots>\n\n" +
"\t<MinLevel>1</MinLevel>\n\t<MaxLevel>86</MaxLevel>\n\t<Factions>99999</Factions>\n\n\t<MailGrey>False</MailGrey>\n\t<MailWhite>" +
"True</MailWhite>\n\t<MailGreen>True</MailGreen>\n\t<MailBlue>True</MailBlue>\n\t<MailPurple>True</MailPurple>\n\n\t<SellGrey>True</SellGrey>\n\t" +
"<SellWhite>True</SellWhite>\n\t<SellGreen>False</SellGreen>\n\t<SellBlue>False</SellBlue>\n\t<SellPurple>False</SellPurple>\n\n\t<Hotspots>");
//Write the hotspots
while (s.hasNext()){
String line = s.nextLine();
if (line.contains("<Position>") && cont){
line = s.nextLine();
Matcher m = p.matcher(line);
m.find();
x = m.group(1);
line = s.nextLine();
m = p.matcher(line);
m.find();
y = m.group(1);
line = s.nextLine();
m = p.matcher(line);
m.find();
z = m.group(1);
pw.print("\n\t\t<Hotspot X=\"" + x +"\" Y=\"" + y + "\" Z=\"" + z + "\" />");
}
if (line.contains("/Waypoints")){
cont = false;
}
}
//Write the footer and close
pw.print("\n\t</Hotspots>\n</HBProfile>");
pw.close();
}
}
}
And yes, my code is not the prettiest...but it works.
http://dl.dropbox.com/u/15286354/converter.jar
If you're worried about safety, compile it yourself against the source, should work fine.
Also, it wont convert the Town Waypoints or Blacklisted Nodes...I'll get around to those eventually. Town Waypoints probably wont be implemented simply because GB2 uses a different system.