I just started playing around with mGalaxy since it's the only one I like that runs on my XP machine.
With all frontends before, I was lacking a way to filter by game age. I really want to be able to run all my games but when I just browse games, I just want to see some wow titles with huge sprites.
So I made small .java program that parses the enriched xmlout.xml from mgalaxy and outputs 3 .xml files with selected games.
You just need to create 3 systems by copying the mame system (C:\Program Files (x86)\mGalaxy\Data\UserSystems) changing the keys in the folders and the UserSystems.xml (I did Multi-system [MAME]-I2zbZe7o, 80 Multi-system [MAME]-I2zbZe8o, 70 Multi-system [MAME]-I2zbZe9o) and replacing the games in the xmlout.xml with the corresponding output file, leaving the header and dbase elements as they are so make this
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<dbase name="Multi-system [MAME]" version="0.200 (mame0200)" update="8/18/2018" comment="">
</dbase>
My Java program - feel free to use and change as you wish.
One word of advice though:
All my systems use the same video and snapshot directories now but each uses only a part of it. I'm afraid to update the lists now because I'm afraid each part-system will delete the files of the other systems -.-
I think I should improve it so it also divides the files of the asset directories into 3 asset directories
Now if anyone finds a way to put different icons and texts to my 3 different mames, that would be awesome ^^
Code: Select all
package mGalaxyListSplitter;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
public class Splitter {
public static void writeXml(Node n, OutputStream os) throws TransformerException {
TransformerFactory tf = TransformerFactory.newInstance();
// identity
Transformer t = tf.newTransformer();
t.setOutputProperty(OutputKeys.INDENT, "yes");
t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
t.transform(new DOMSource(n), new StreamResult(os));
}
public static void main(String[] args) throws Throwable {
List<Node> rom70 = new ArrayList<Node>();
List<Node> rom80 = new ArrayList<Node>();
List<Node> rom90 = new ArrayList<Node>();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(new File(
"C:\\Program Files (x86)\\mGalaxy\\Data - Kopie\\UserSystems\\Multi-system [MAME]-I2zbZe7o\\xmlout.xml"));
Element root = document.getDocumentElement();
for (int i = 0; i < root.getChildNodes().getLength(); i++) {
Node node = root.getChildNodes().item(i);
if (node.getAttributes() == null) {
continue;
}
Element elt = (Element) node;
String yearString = elt.getElementsByTagName("release").item(0).getTextContent();
int year = Integer.parseInt(yearString.replaceAll("\\?", "0").replaceAll("X", "0"));
if (year < 1981) {
rom70.add(node);
} else if (year < 1988) {
rom80.add(node);
} else {
rom90.add(node);
}
}
FileOutputStream stream = new FileOutputStream("70.xml");
for (Node node : rom70) {
writeXml(node, stream);
}
stream.flush();
stream.close();
stream = new FileOutputStream("80.xml");
for (Node node : rom80) {
writeXml(node, stream);
}
stream.flush();
stream.close();
stream = new FileOutputStream("90.xml");
for (Node node : rom90) {
writeXml(node, stream);
}
stream.flush();
stream.close();
}
}