Revert previous change

This commit is contained in:
drdev
2016-03-21 05:22:41 +00:00
parent 56be582db4
commit e226322abc
4 changed files with 15 additions and 18 deletions

View File

@@ -45,7 +45,7 @@ import java.util.Map.Entry;
import com.google.common.base.Function;
public final class ConquestData {
private static final String XML_FILENAME = "data.xml";
private static final String XML_FILE = "data.xml";
private String name;
private PaperCard planeswalker;
@@ -55,7 +55,8 @@ public final class ConquestData {
private int aetherShards;
private int planeswalkEmblems;
private final File directory, xmlFile;
private final File directory;
private final String xmlFilename;
private final ConquestRecord chaosBattleRecord;
private final Map<String, ConquestPlaneData> planeDataMap = new HashMap<String, ConquestPlaneData>();
private final HashSet<PaperCard> unlockedCards = new HashSet<PaperCard>();
@@ -66,7 +67,7 @@ public final class ConquestData {
public ConquestData(String name0, ConquestPlane startingPlane0, PaperCard startingPlaneswalker0, PaperCard startingCommander0) {
name = name0;
directory = new File(ForgeConstants.CONQUEST_SAVE_DIR, name);
xmlFile = new File(directory, XML_FILENAME);
xmlFilename = directory.getPath() + ForgeConstants.PATH_SEPARATOR + XML_FILE;
aetherShards = FModel.getConquestPreferences().getPrefInt(CQPref.AETHER_START_SHARDS);
currentLocation = new ConquestLocation(startingPlane0, 0, 0, 0);
unlockPlane(startingPlane0);
@@ -88,11 +89,11 @@ public final class ConquestData {
public ConquestData(File directory0) {
name = directory0.getName();
directory = directory0;
xmlFile = new File(directory, XML_FILENAME);
xmlFilename = directory.getPath() + ForgeConstants.PATH_SEPARATOR + XML_FILE;
ConquestRecord chaosBattleRecord0 = null;
try {
XmlReader xml = new XmlReader(xmlFile);
XmlReader xml = new XmlReader(xmlFilename);
CardDb cardDb = FModel.getMagicDb().getCommonCards();
setPlaneswalker(xml.read("planeswalker", cardDb));
aetherShards = xml.read("aetherShards", aetherShards);
@@ -119,7 +120,7 @@ public final class ConquestData {
FileUtil.ensureDirectoryExists(directory);
try {
XmlWriter xml = new XmlWriter(xmlFile, "data");
XmlWriter xml = new XmlWriter(xmlFilename, "data");
xml.write("planeswalker", planeswalker);
xml.write("aetherShards", aetherShards);
xml.write("planeswalkEmblems", planeswalkEmblems);

View File

@@ -20,9 +20,9 @@ import forge.util.XmlWriter.IXmlWritable;
public class XmlReader {
private Element currentElement;
public XmlReader(File file0) throws Exception {
public XmlReader(String filename0) throws Exception {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
final Document document = builder.parse(file0);
final Document document = builder.parse(new File(filename0));
currentElement = (Element)document.getFirstChild();
}

View File

@@ -47,16 +47,13 @@ public class XmlUtil {
return sw.toString();
}
public static void saveDocument(final Document document, final String filename) throws TransformerException {
saveDocument(document, new File(filename));
}
public static void saveDocument(final Document document, final File file) throws TransformerException {
public static void saveDocument(final Document document, String filename) throws TransformerException {
Transformer t = TransformerFactory.newInstance().newTransformer();
t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
t.setOutputProperty(OutputKeys.INDENT, "yes");
t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
DOMSource source = new DOMSource(document);
StreamResult result = new StreamResult(file);
StreamResult result = new StreamResult(new File(filename));
t.transform(source, result);
}

View File

@@ -1,6 +1,5 @@
package forge.util;
import java.io.File;
import java.util.EnumMap;
import java.util.HashSet;
import java.util.Map;
@@ -17,17 +16,17 @@ import forge.item.PaperCard;
public class XmlWriter {
private final Document document;
private final File file;
private final String filename;
private final Stack<Element> parentElements = new Stack<Element>();
private Element currentElement;
public XmlWriter(File file0, String rootName0) throws Exception {
public XmlWriter(String filename0, String rootName0) throws Exception {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
document = builder.newDocument();
currentElement = document.createElement(rootName0);
document.appendChild(currentElement);
file = file0;
filename = filename0;
}
public void startElement(String name0) {
@@ -110,7 +109,7 @@ public class XmlWriter {
}
public void close() throws Exception {
XmlUtil.saveDocument(document, file);
XmlUtil.saveDocument(document, filename);
}
public interface IXmlWritable {