// Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// 	private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
// 
// 	public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// 		drcSet.add(drc);
// 	}
// 
// 	public void createReferences(GmFile gmf) {
// 		for (DeferredReferenceCreator drc : drcSet) {
// 			drc.createReferences(gmf);
// 		}
// 	}
// }
// 
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// 	public String name;
// 	public String filename;
// 	public Type type;
// 
// 	public ResourceTreeEntry(String name, String filename, Type type) {
// 		this.name = name;
// 		this.filename = filename;
// 		this.type = type;
// 	}
// 
// 	public ResourceTreeEntry() {
// 	}
// 
// 	public String getFilename() {
// 		String result;
// 		if (filename != null && !filename.isEmpty()) {
// 			result = filename;
// 		} else {
// 			result = name;
// 		}
// 		if (FileTools.isGoodFilename(result)) {
// 			return result;
// 		} else {
// 			throw new IllegalStateException("Bad filename in resource list: " + result);
// 		}
// 	}
// 
// 	public static enum Type {
// 		RESOURCE, GROUP
// 	}
// }
// 
// Path: src/com/ganggarrison/gmdec/xml/PathXmlFormat.java
// public class PathXmlFormat extends XmlFormat<Path> {
// 
// 	@Override
// 	public void write(Path path, XmlWriter writer) {
// 		writer.startElement("path");
// 		{
// 			writeIdAttribute(path, writer);
// 			writer.startElement("points");
// 			for (PathPoint pp : path.points) {
// 				writer.startElement("point");
// 				writer.putAttribute("x", pp.getX());
// 				writer.putAttribute("y", pp.getY());
// 				writer.putAttribute("speed", pp.getSpeed());
// 				writer.endElement();
// 			}
// 			writer.endElement();
// 			writeResourceRef(writer, "backgroundRoom", (ResourceReference<?>) path.get(PPath.BACKGROUND_ROOM));
// 			writer.putElement("closed", path.get(PPath.CLOSED));
// 			writer.putElement("precision", path.get(PPath.PRECISION));
// 			writer.putElement("smooth", path.get(PPath.SMOOTH));
// 
// 			int snapX = path.get(PPath.SNAP_X);
// 			int snapY = path.get(PPath.SNAP_Y);
// 			writePoint(writer, "snap", new Point(snapX, snapY));
// 		}
// 		writer.endElement();
// 	}
// 
// 	@Override
// 	public Path read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// 		Path path = new Path();
// 
// 		reader.enterElement("path");
// 		{
// 			readIdAttribute(path, reader);
// 			reader.enterElement("points");
// 			while (reader.hasNextElement()) {
// 				reader.enterElement("point");
// 				PathPoint pp = path.addPoint();
// 				pp.setX(reader.getIntAttribute("x"));
// 				pp.setY(reader.getIntAttribute("y"));
// 				pp.setSpeed(reader.getIntAttribute("speed"));
// 				reader.leaveElement();
// 			}
// 			reader.leaveElement();
// 			String backgroundRoomRef = readResourceRef(reader, "backgroundRoom");
// 			DeferredReferenceCreator rc = new DeferredPropertyReferenceCreator<PPath>(
// 					path.properties, PPath.BACKGROUND_ROOM, Room.class, backgroundRoomRef);
// 			notifier.addDeferredReferenceCreator(rc);
// 			path.put(PPath.CLOSED, reader.getBoolElement("closed"));
// 			path.put(PPath.PRECISION, reader.getIntElement("precision"));
// 			path.put(PPath.SMOOTH, reader.getBoolElement("smooth"));
// 
// 			Point snap = readPoint(reader, "snap");
// 			path.put(PPath.SNAP_X, snap.x);
// 			path.put(PPath.SNAP_Y, snap.y);
// 		}
// 		reader.leaveElement();
// 		return path;
// 	}
// }


import java.io.File;
import java.io.IOException;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Path;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.PathXmlFormat;
/*
 * Copyright (C) 2010 Medo <smaxein@googlemail.com>
 * 
 * This file is part of GmkSplitter.
 * GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
 * See LICENSE for details.
 */
package com.ganggarrison.gmdec.files;




public class PathFormat extends ResourceFormat<Path> {
	@Override
	public Path read(File filePath, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn) throws IOException {
		Path path = new PathXmlFormat().read(getXmlFile(filePath, entry), drcn);
		path.setName(entry.name);
		return path;
	}

	@Override
	public void write(File filePath, Path path, GmFile gmf) throws IOException {
// Path: src/com/ganggarrison/gmdec/DeferredReferenceCreatorNotifier.java
// public class DeferredReferenceCreatorNotifier {
// 	private Set<DeferredReferenceCreator> drcSet = new HashSet<DeferredReferenceCreator>();
// 
// 	public void addDeferredReferenceCreator(DeferredReferenceCreator drc) {
// 		drcSet.add(drc);
// 	}
// 
// 	public void createReferences(GmFile gmf) {
// 		for (DeferredReferenceCreator drc : drcSet) {
// 			drc.createReferences(gmf);
// 		}
// 	}
// }
// 
// Path: src/com/ganggarrison/gmdec/ResourceTreeEntry.java
// public class ResourceTreeEntry {
// 	public String name;
// 	public String filename;
// 	public Type type;
// 
// 	public ResourceTreeEntry(String name, String filename, Type type) {
// 		this.name = name;
// 		this.filename = filename;
// 		this.type = type;
// 	}
// 
// 	public ResourceTreeEntry() {
// 	}
// 
// 	public String getFilename() {
// 		String result;
// 		if (filename != null && !filename.isEmpty()) {
// 			result = filename;
// 		} else {
// 			result = name;
// 		}
// 		if (FileTools.isGoodFilename(result)) {
// 			return result;
// 		} else {
// 			throw new IllegalStateException("Bad filename in resource list: " + result);
// 		}
// 	}
// 
// 	public static enum Type {
// 		RESOURCE, GROUP
// 	}
// }
// 
// Path: src/com/ganggarrison/gmdec/xml/PathXmlFormat.java
// public class PathXmlFormat extends XmlFormat<Path> {
// 
// 	@Override
// 	public void write(Path path, XmlWriter writer) {
// 		writer.startElement("path");
// 		{
// 			writeIdAttribute(path, writer);
// 			writer.startElement("points");
// 			for (PathPoint pp : path.points) {
// 				writer.startElement("point");
// 				writer.putAttribute("x", pp.getX());
// 				writer.putAttribute("y", pp.getY());
// 				writer.putAttribute("speed", pp.getSpeed());
// 				writer.endElement();
// 			}
// 			writer.endElement();
// 			writeResourceRef(writer, "backgroundRoom", (ResourceReference<?>) path.get(PPath.BACKGROUND_ROOM));
// 			writer.putElement("closed", path.get(PPath.CLOSED));
// 			writer.putElement("precision", path.get(PPath.PRECISION));
// 			writer.putElement("smooth", path.get(PPath.SMOOTH));
// 
// 			int snapX = path.get(PPath.SNAP_X);
// 			int snapY = path.get(PPath.SNAP_Y);
// 			writePoint(writer, "snap", new Point(snapX, snapY));
// 		}
// 		writer.endElement();
// 	}
// 
// 	@Override
// 	public Path read(XmlReader reader, DeferredReferenceCreatorNotifier notifier) {
// 		Path path = new Path();
// 
// 		reader.enterElement("path");
// 		{
// 			readIdAttribute(path, reader);
// 			reader.enterElement("points");
// 			while (reader.hasNextElement()) {
// 				reader.enterElement("point");
// 				PathPoint pp = path.addPoint();
// 				pp.setX(reader.getIntAttribute("x"));
// 				pp.setY(reader.getIntAttribute("y"));
// 				pp.setSpeed(reader.getIntAttribute("speed"));
// 				reader.leaveElement();
// 			}
// 			reader.leaveElement();
// 			String backgroundRoomRef = readResourceRef(reader, "backgroundRoom");
// 			DeferredReferenceCreator rc = new DeferredPropertyReferenceCreator<PPath>(
// 					path.properties, PPath.BACKGROUND_ROOM, Room.class, backgroundRoomRef);
// 			notifier.addDeferredReferenceCreator(rc);
// 			path.put(PPath.CLOSED, reader.getBoolElement("closed"));
// 			path.put(PPath.PRECISION, reader.getIntElement("precision"));
// 			path.put(PPath.SMOOTH, reader.getBoolElement("smooth"));
// 
// 			Point snap = readPoint(reader, "snap");
// 			path.put(PPath.SNAP_X, snap.x);
// 			path.put(PPath.SNAP_Y, snap.y);
// 		}
// 		reader.leaveElement();
// 		return path;
// 	}
// }


// Path: src/com/ganggarrison/gmdec/files/PathFormat.java
import java.io.File;
import java.io.IOException;
import org.lateralgm.file.GmFile;
import org.lateralgm.resources.Path;
import com.ganggarrison.gmdec.DeferredReferenceCreatorNotifier;
import com.ganggarrison.gmdec.ResourceTreeEntry;
import com.ganggarrison.gmdec.xml.PathXmlFormat;

/*
 * Copyright (C) 2010 Medo <smaxein@googlemail.com>
 * 
 * This file is part of GmkSplitter.
 * GmkSplitter is free software and comes with ABSOLUTELY NO WARRANTY.
 * See LICENSE for details.
 */
package com.ganggarrison.gmdec.files;




public class PathFormat extends ResourceFormat<Path> {
	@Override
	public Path read(File filePath, ResourceTreeEntry entry, DeferredReferenceCreatorNotifier drcn) throws IOException {
		Path path = new PathXmlFormat().read(getXmlFile(filePath, entry), drcn);
		path.setName(entry.name);
		return path;
	}

	@Override
	public void write(File filePath, Path path, GmFile gmf) throws IOException {
		new PathXmlFormat().write(path, getXmlFile(filePath, path));