Added source for the BOP Conversion Patch Generator thing i've been working on :)

This commit is contained in:
Adubbz 2013-04-26 09:42:30 +10:00
parent 02d3fc104b
commit 05ebc4c1e7
9 changed files with 546 additions and 139 deletions

View file

@ -1,139 +0,0 @@
3957 -> 160:1 //Quicksand
3996 -> 162:1 //Red Rock Cobblestone
3995 -> 162:2 //Red Rock Bricks
4027 -> 1920 //Dead Grass
4026 -> 1920:1 //Desert Grass
3990 -> 1920:2 //Desert Sprouts
3991 -> 1920:3 //Dune Grass
3972 -> 1920:4 //Holy Tall Grass
4016 -> 1920:5 //Thorns
4045 -> 1920:6 //Barley
4019 -> 1920:7 //Cattail
4021 -> 1921 //Clover
4024 -> 1921:1 //Swampflower
3997 -> 1921:2 //Deathbloom
4020 -> 1921:3 //Glowflower
3994 -> 1921:4 //Hydrangea
4022 -> 1921:5 //Daisy
4052 -> 1921:6 //Tulip
4023 -> 1921:7 //Wildflower
3993 -> 1921:8 //Violet
4025 -> 1921:9 //Anenome
4015 -> 1921:10 //Toadstool
4012 -> 1921:11 //Tiny Cactus
4017 -> 1923 //Yellow Autumn Leaves
4028 -> 1923:1 //Bamboo Leaves
4036 -> 1923:2 //Magic Leaves
4050 -> 1923:3 //Dark Leaves
4034 -> 1923:4 //Dying Leaves
4056 -> 1923:5 //Fir Leaves
3969 -> 1923:6 //Holy Leaves
4038 -> 1923:7 //Orange Autumn Leaves
4062 -> 1924 //Origin Leaves
4037 -> 1924:1 //Pink Cherry Leaves
4039 -> 1924:2 //Maple Leaves
4035 -> 1924:3 //White Cherry Leaves
3959 -> 1925 //Algae
4033 -> 1925:1 //Short Grass
3992 -> 1925:2 //Medium Grass
4014 -> 1925:3 //High Grass Bottom
4030 -> 1925:4 //Bush
4031 -> 1925:5//Sprout
4013 -> 1925:6 //High Grass Top
4032 -> 1926 //Apple Leaves
//Red Rock Cobblestone Double Slab
//Red Rock Bricks Double Slab
//Mud Bricks Double Slab
//Red Rock Cobblestone Slab
//Red Rock Bricks Slab
//Mud Bricks Slab
//Acacia Wood
//Cherry Wood
//Dark Wood
//Fir Wood
//Holy Wood
//Magic Wood
//Mangrove Wood
//Palm Wood
//Redwood Wood
//Willow Wood
//Dead Wood
//Giant Flower Stem
//Giant Red Flower
//Giant Yellow Flower
//Apple Sapling
//Yellow Autumn Sapling
//Bamboo Sapling
//Magic Sapling
//Dark Sapling
//Dying Sapling
//Fir Sapling
//Holy Sapling
//Orange Autumn Sapling
//Origin Sapling
//Pink Cherry Sapling
//Maple Sapling
//White Cherry Sapling
//Acacia Sapling
//Mangrove Sapling
//Palm Sapling
//Redwood Sapling
//Willow Sapling
//Red Rock Cobblestone Stairs
//Red Rock Brick Stairs
//Acacia Wood Planks
//Cherry Wood Planks
//Dark Wood Planks
//Fir Wood Planks
//Holy Wood Planks
//Magic Wood Planks
//Mangrove Wood Planks
//Palm Wood Planks
//Redwood Wood Planks
//Willow Wood Planks
//Bamboo Thatching
//Acacia Wood Double Slab
//Cherry Wood Double Slab
//Dark Wood Double Slab
//Fir Wood Double Slab
//Holy Wood Double Slab
//Magic Wood Double Slab
//Mangrove Wood Double Slab
//Palm Wood Double Slab
//Acacia Wood Slab
//Cherry Wood Slab
//Dark Wood Slab
//Fir Wood Slab
//Holy Wood Slab
//Magic Wood Slab
//Mangrove Wood Slab
//Palm Wood Slab
//Redwood Wood Double Slab
//Willow Wood Double Slab
//Redwood Wood Slab
//Willow Wood Slab
//Acacia Leaves
//Mangrove Leaves
//Palm Leaves
//Redwood Leaves
//Willow Leaves
//Smoldering Grass
//Moss
//Amethyst Block
//Amethyst Ore
//Holy Wood Stairs
//Promised Land Portal
//Mangrove Wood Stairs
//Mud Brick Stairs
//Willow
//Bamboo
//Tree Moss
//Palm Wood Stairs
//Magic Wood Stairs
//Dark Wood Stairs
//Chery Wood Stairs
//Acacia Wood Stairs
//Fir Wood Stairs
//Willow Wood Stairs
//Redwood Wood Stairs
//Mud Bricks

View file

@ -0,0 +1,92 @@
package Adubbz.CPGen;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
public class ActionHandler implements ActionListener {
public static File importConfigSelectedFile = null;
public static File outputPatchSelectedFile = null;
public void actionPerformed(ActionEvent event)
{
if (event.getSource() == Gui.btnImportConfig)
{
JFileChooser importFileChooser = new JFileChooser();
importFileChooser.setDialogTitle("Select Pre-0.5.2 Config File");
importFileChooser.setFileFilter(new ConfigFileFilter());
importFileChooser.setAcceptAllFileFilterUsed(false);
int importChecker = importFileChooser.showOpenDialog(null);
importConfigSelectedFile = importFileChooser.getSelectedFile();
if (importChecker == JFileChooser.APPROVE_OPTION)
{
System.out.println("Found file at " + importConfigSelectedFile.toString());
Gui.textFieldImportConfig.setText(importConfigSelectedFile.toString());
}
}
if (event.getSource() == Gui.btnOutputPatch)
{
JFileChooser outputFileChooser = new JFileChooser();
outputFileChooser.setDialogTitle("Select Directory to Output to");
outputFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
outputFileChooser.setFileFilter(new DirectoryFileFilter());
outputFileChooser.setAcceptAllFileFilterUsed(false);
int outputChecker = outputFileChooser.showOpenDialog(null);
outputPatchSelectedFile = outputFileChooser.getSelectedFile();
if (outputChecker == JFileChooser.APPROVE_OPTION)
{
System.out.println("Found folder at " + outputPatchSelectedFile);
Gui.textFieldOutputPatch.setText(outputPatchSelectedFile.toString());
}
}
if (event.getSource() == Gui.btnStart)
{
Gui.progressBar.setValue(0);
Gui.progressBar.setVisible(true);
if (importConfigSelectedFile != null)
{
Gui.progressBar.setValue(17);
if (outputPatchSelectedFile != null)
{
try
{
Gui.progressBar.setValue(34);
ConfigFileReader.read();
}
catch (Exception e)
{
e.printStackTrace();
}
}
else
{
JOptionPane.showMessageDialog(null, "You must select an Output Folder!", "Error", JOptionPane.ERROR_MESSAGE);
}
}
else
{
JOptionPane.showMessageDialog(null, "You must select a Config File!", "Error", JOptionPane.ERROR_MESSAGE);
}
}
}
}

View file

@ -0,0 +1,48 @@
package Adubbz.CPGen;
import java.io.File;
import javax.swing.filechooser.FileFilter;
public class ConfigFileFilter extends FileFilter {
private String ImageFormat = "CFG";
private char DotIndex = '.';
public boolean accept(File file)
{
if (file.isDirectory())
{
return true;
}
else if (extension(file).equalsIgnoreCase(ImageFormat))
{
return true;
}
else
{
return false;
}
}
@Override
public String getDescription()
{
return "Config Files Only";
}
public String extension(File file)
{
String FileName = file.getName();
int IndexFile = FileName.lastIndexOf(DotIndex);
if (IndexFile > 0 && IndexFile < FileName.length() - 1)
{
return FileName.substring(IndexFile + 1);
}
else
{
return "";
}
}
}

View file

@ -0,0 +1,48 @@
package Adubbz.CPGen;
import java.io.BufferedReader;
import java.io.FileReader;
public class ConfigFileReader {
public static String text = "";
public static void read() throws Exception
{
FileReader file = new FileReader(ActionHandler.importConfigSelectedFile.toString());
BufferedReader reader = new BufferedReader(file);
String line = reader.readLine();
boolean foundBlock = false;
boolean endBlock = false;
while (line != null)
{
String currentLineText = line;
if (foundBlock && currentLineText.contains("}"))
{
endBlock = true;
}
if (foundBlock && !endBlock)
{
text += line;
}
if (currentLineText.contains("block {"))
{
foundBlock = true;
}
line = reader.readLine();
}
reader.close();
Gui.progressBar.setValue(51);
ConfigTextFilter.filter();
}
}

View file

@ -0,0 +1,176 @@
package Adubbz.CPGen;
public class ConfigTextFilter {
public static String[] splitString;
public static void filter()
{
splitString = ConfigFileReader.text.split("I:");
for (int i = 1; i < 141; ++i)
{
//splitString[i] = splitString[i].replaceAll( "[^\\d]", "" );
splitString[i] = splitString[i].replaceFirst(".*?(?=[a-z]?=)", "");
splitString[i] = splitString[i].replace("=", "");
splitString[i] = splitString[i].replace(" ", "");
splitString[i] = splitString[i] + " -> ";
}
splitString[1] = splitString[1] + "1948";
splitString[2] = splitString[2] + "1962";
splitString[3] = splitString[3] + "1933";
splitString[4] = splitString[4] + "1947";
splitString[5] = splitString[5] + "1938";
splitString[6] = splitString[6] + "1949";
splitString[7] = splitString[7] + "1952";
splitString[8] = splitString[8] + "1925";
splitString[9] = splitString[9] + "1942";
splitString[10] = splitString[10] + "1921:9";
splitString[11] = splitString[11] + "1926:3";
splitString[12] = splitString[12] + "1937";
splitString[13] = splitString[13] + "1927";
splitString[14] = splitString[14] + "1923:1";
splitString[15] = splitString[15] + "1937:2";
splitString[16] = splitString[16] + "1947:10";
splitString[17] = splitString[17] + "1920:6";
splitString[18] = splitString[18] + "1942:1";
splitString[19] = splitString[19] + "1925:4";
splitString[20] = splitString[20] + "1920:7";
splitString[21] = splitString[21] + "1948:1";
splitString[22] = splitString[22] + "1933:1";
splitString[23] = splitString[23] + "1947:1";
splitString[24] = splitString[24] + "1949:1";
splitString[25] = splitString[25] + "1953";
splitString[26] = splitString[26] + "1921";
splitString[27] = splitString[27] + "1921:5";
splitString[28] = splitString[28] + "1948:2";
splitString[29] = splitString[29] + "1923:3";
splitString[30] = splitString[30] + "1933:2";
splitString[31] = splitString[31] + "1947:2";
splitString[32] = splitString[32] + "1937:4";
splitString[33] = splitString[33] + "1949:2";
splitString[34] = splitString[34] + "1954";
splitString[35] = splitString[35] + "1920";
splitString[36] = splitString[36] + "1935:2";
splitString[37] = splitString[37] + "1921:2";
splitString[38] = splitString[38] + "1920:1";
splitString[39] = splitString[39] + "1920:2";
splitString[40] = splitString[40] + "1920:3";
splitString[41] = splitString[41] + "1920:3";
splitString[42] = splitString[42] + "1923:4";
splitString[43] = splitString[43] + "1937:5";
splitString[44] = splitString[44] + "1948:3";
splitString[45] = splitString[45] + "1923:5";
splitString[46] = splitString[46] + "1947:3";
splitString[47] = splitString[47] + "1937:6";
splitString[48] = splitString[48] + "1949:3";
splitString[49] = splitString[49] + "1926";
splitString[51] = splitString[51] + "1935:3";
splitString[52] = splitString[52] + "1936";
splitString[53] = splitString[53] + "1936:1";
splitString[54] = splitString[54] + "1921:3";
splitString[55] = splitString[55] + "1925:3";
splitString[56] = splitString[56] + "1925:6";
splitString[57] = splitString[57] + "1948:4";
splitString[58] = splitString[58] + "1923:6";
splitString[59] = splitString[59] + "1934";
splitString[60] = splitString[60] + "1947:4";
splitString[61] = splitString[61] + "1937:7";
splitString[62] = splitString[62] + "1949:4";
splitString[63] = splitString[63] + "1956";
splitString[64] = splitString[64] + "1920:4";
splitString[65] = splitString[65] + "1921:4";
splitString[66] = splitString[66] + "1948:5";
splitString[67] = splitString[67] + "1923:2";
splitString[68] = splitString[68] + "1934:1";
splitString[69] = splitString[69] + "1947:5";
splitString[70] = splitString[70] + "1937:3";
splitString[71] = splitString[71] + "1949:5";
splitString[72] = splitString[72] + "1957";
splitString[73] = splitString[73] + "1948:6";
splitString[74] = splitString[74] + "1962:1";
splitString[75] = splitString[75] + "1934:2";
splitString[76] = splitString[76] + "1947:6";
splitString[77] = splitString[77] + "1938:1";
splitString[78] = splitString[78] + "1949:6";
splitString[79] = splitString[79] + "1958"; //Correct
splitString[80] = splitString[80] + "1924:2";
splitString[81] = splitString[81] + "1937:11";
splitString[82] = splitString[82] + "1925:2";
splitString[83] = splitString[83] + "4095";
splitString[84] = splitString[84] + "1930:2";
splitString[85] = splitString[85] + "1931:2";
splitString[86] = splitString[86] + "1929";
splitString[87] = splitString[87] + "1928";
splitString[88] = splitString[88] + "1923:7";
splitString[89] = splitString[89] + "1937:8";
splitString[90] = splitString[90] + "1924";
splitString[91] = splitString[91] + "1937:9";
splitString[92] = splitString[92] + "1948:7";
splitString[93] = splitString[93] + "1962:2";
splitString[94] = splitString[94] + "1934:3";
splitString[95] = splitString[95] + "1947:7";
splitString[96] = splitString[96] + "1938:2";
splitString[97] = splitString[97] + "1949:7";
splitString[98] = splitString[98] + "1959";
splitString[99] = splitString[99] + "1924:1";
splitString[100] = splitString[100] + "1937:10";
splitString[101] = splitString[101] + "1921:6";
splitString[102] = splitString[102] + "1941";
splitString[103] = splitString[103] + "160:1";
splitString[104] = splitString[104] + "1930:1";
splitString[105] = splitString[105] + "1931:1";
splitString[106] = splitString[106] + "1940";
splitString[107] = splitString[107] + "162:2";
splitString[108] = splitString[108] + "1930";
splitString[109] = splitString[109] + "162:1";
splitString[110] = splitString[110] + "1931";
splitString[111] = splitString[111] + "1939";
splitString[112] = splitString[112] + "1950";
splitString[113] = splitString[113] + "1962:3";
splitString[114] = splitString[114] + "1935";
splitString[115] = splitString[115] + "1947:8";
splitString[116] = splitString[116] + "1938:3";
splitString[117] = splitString[117] + "1951";
splitString[118] = splitString[118] + "1960";
splitString[119] = splitString[119] + "1925:1";
splitString[120] = splitString[120] + "169:1";
splitString[121] = splitString[121] + "1925:5";
splitString[122] = splitString[122] + "1921:1";
splitString[123] = splitString[123] + "1920:5";
splitString[124] = splitString[124] + "1921:11";
splitString[125] = splitString[125] + "1921:10";
splitString[126] = splitString[126] + "1932";
splitString[127] = splitString[127] + "1921:8";
splitString[128] = splitString[128] + "1924:3";
splitString[129] = splitString[129] + "1937:12";
splitString[130] = splitString[130] + "1921:7";
splitString[131] = splitString[131] + "1950:1";
splitString[132] = splitString[132] + "1922";
splitString[133] = splitString[133] + "1962:4";
splitString[134] = splitString[134] + "1935:1";
splitString[135] = splitString[135] + "1947:9";
splitString[136] = splitString[136] + "1938:4";
splitString[137] = splitString[137] + "1951:1";
splitString[138] = splitString[138] + "1961";
splitString[139] = splitString[139] + "1923";
splitString[140] = splitString[140] + "1937:1";
for (int i = 1; i < 141; ++i)
{
System.out.println(splitString[i]);
}
try
{
Gui.progressBar.setValue(68);
TextFileWriter.write();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}

View file

@ -0,0 +1,26 @@
package Adubbz.CPGen;
import java.io.File;
import javax.swing.filechooser.FileFilter;
public class DirectoryFileFilter extends FileFilter {
public boolean accept(File file)
{
if (file.isDirectory())
{
return true;
}
else
{
return false;
}
}
@Override
public String getDescription()
{
return "Directories Only";
}
}

View file

@ -0,0 +1,73 @@
package Adubbz.CPGen;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.JProgressBar;
import javax.swing.JLabel;
import com.jgoodies.forms.factories.DefaultComponentFactory;
public class Gui extends JFrame {
public static JFrame frame;
public static JTextField textFieldImportConfig;
public static JTextField textFieldOutputPatch;
public static JButton btnImportConfig = new JButton("Import Config");
public static JButton btnOutputPatch = new JButton("Output Patch");
public static JButton btnStart = new JButton("Start");
public static JProgressBar progressBar = new JProgressBar();
public Gui() {
getContentPane().setLayout(new BorderLayout());
frame = new JFrame("BOP Converter Patch Generator");
frame.setBounds(100, 100, 556, 141);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.getContentPane().setLayout(null);
btnImportConfig.setBounds(425, 11, 115, 23);
frame.getContentPane().add(btnImportConfig);
btnOutputPatch.setBounds(425, 45, 115, 23);
frame.getContentPane().add(btnOutputPatch);
textFieldImportConfig = new JTextField();
textFieldImportConfig.setBounds(10, 12, 405, 20);
frame.getContentPane().add(textFieldImportConfig);
textFieldImportConfig.setColumns(10);
textFieldImportConfig.setEditable(false);
textFieldOutputPatch = new JTextField();
textFieldOutputPatch.setBounds(10, 46, 405, 20);
frame.getContentPane().add(textFieldOutputPatch);
textFieldOutputPatch.setColumns(10);
textFieldOutputPatch.setEditable(false);
btnStart.setBounds(425, 79, 115, 23);
frame.getContentPane().add(btnStart);
progressBar.setBounds(10, 77, 405, 25);
progressBar.setStringPainted(true);
progressBar.setVisible(false);
frame.getContentPane().add(progressBar);
ActionHandler handler = new ActionHandler();
btnImportConfig.addActionListener(handler);
btnOutputPatch.addActionListener(handler);
btnStart.addActionListener(handler);
}
}

View file

@ -0,0 +1,20 @@
package Adubbz.CPGen;
import java.awt.EventQueue;
public class Main {
public static void main(String args [])
{
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Gui window = new Gui();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}

View file

@ -0,0 +1,63 @@
package Adubbz.CPGen;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import javax.swing.JOptionPane;
public class TextFileWriter {
static int patchNo = 0;
static File newFile;
public static void write() throws Exception
{
if (patchNo == 0)
{
newFile = new File(ActionHandler.outputPatchSelectedFile.toString() + "/Patch.txt");
}
else
{
newFile = new File(ActionHandler.outputPatchSelectedFile.toString() + "/Patch" + patchNo + ".txt");
}
if (newFile.exists())
{
System.out.println("The file already exists, adding number...");
patchNo++;
write();
}
else
{
newFile.createNewFile();
create();
}
}
private static void create() throws Exception
{
Gui.progressBar.setValue(85);
FileWriter fileWriter = new FileWriter(newFile);
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
for (int i = 1; i < 141; ++i)
{
bufferedWriter.write(ConfigTextFilter.splitString[i]);
bufferedWriter.newLine();
}
bufferedWriter.close();
Gui.progressBar.setValue(100);
System.out.println("File Written to " + newFile);
JOptionPane.showMessageDialog(null, "Done!", null, JOptionPane.INFORMATION_MESSAGE);
if (JOptionPane.OK_OPTION == 1);
{
Gui.progressBar.setVisible(false);
}
}
}