use of mod.Mod in project ParadoxosModManager by ThibautSF.
the class MyXML method modifyList.
/**
* @param list
* @param listName
* @throws Exception
*/
public void modifyList(ModList list, String listName) throws Exception {
Element oneListElement = null, listDescrElement, listArgsElement, listLangElement, listModElement;
List<Mod> listMods;
boolean isNew = (listName != null) ? false : true;
if (!isNew) {
List<Element> modLists = root.getChildren(LIST);
Iterator<Element> i = modLists.iterator();
while (i.hasNext()) {
Element oneListElementIterated = (Element) i.next();
String listElementName = oneListElementIterated.getAttribute(NAME).getValue();
if (listElementName.equals(listName)) {
oneListElement = oneListElementIterated;
break;
}
}
}
if (oneListElement != null) {
oneListElement.removeChildren(MOD);
} else {
oneListElement = new Element(LIST);
root.addContent(oneListElement);
}
listDescrElement = oneListElement.getChild(DESCR);
if (listDescrElement == null) {
listDescrElement = new Element(DESCR);
oneListElement.addContent(listDescrElement);
}
listLangElement = oneListElement.getChild(LANG);
if (listLangElement == null) {
listLangElement = new Element(LANG);
oneListElement.addContent(listLangElement);
}
listArgsElement = oneListElement.getChild(LAUNCHARGS);
if (listArgsElement == null) {
listArgsElement = new Element(LAUNCHARGS);
oneListElement.addContent(listArgsElement);
}
oneListElement.setAttribute(NAME, list.getName());
oneListElement.setAttribute(CUSTOM_ORDER, list.isCustomOrder() + "");
listDescrElement.setText(list.getDescription());
listArgsElement.setText(list.getLaunchArgs());
listLangElement.setText(list.getLanguageName());
listMods = list.getModlist();
for (int i = 0; i < listMods.size(); i++) {
Mod mod = listMods.get(i);
listModElement = new Element(MOD);
listModElement.setAttribute(MOD_NAME, mod.getName());
listModElement.setAttribute(FILE_NAME, mod.getFileName());
listModElement.setAttribute(REMOTE_ID, mod.getRemoteFileID());
listModElement.setAttribute(MOD_ORDER, i + "");
oneListElement.addContent(listModElement);
}
this.saveFile();
}
use of mod.Mod in project ParadoxosModManager by ThibautSF.
the class ListManager method modPrint.
/**
* @param applyMods
* @param writer
* @throws IOException
*/
private void modPrint(List<Mod> applyMods, BufferedWriter writer) throws IOException {
for (Mod mod : applyMods) {
String addLine = "\t\"mod/" + mod.getFileName() + "\"";
writer.write(addLine + System.getProperty("line.separator"));
}
}
use of mod.Mod in project ParadoxosModManager by ThibautSF.
the class ListCreator method readMods.
private void readMods(String trimmedLine) {
while (trimmedLine.indexOf("/") >= 0) {
String oneModStr = trimmedLine.substring(trimmedLine.indexOf("/") + 1, trimmedLine.indexOf(".mod") + 4);
Mod oneMod = availableMods.get(oneModStr);
if (oneMod == null) {
oneMod = new Mod(oneModStr);
if (!missingMods.contains(oneMod)) {
missingMods.add(oneMod);
list.addMod(oneMod);
}
} else {
if (!selectedModsList.contains(oneMod)) {
selectedModsList.add(oneMod);
list.addMod(oneMod);
}
}
trimmedLine = trimmedLine.substring(trimmedLine.indexOf(".mod") + 4, trimmedLine.length());
}
}
use of mod.Mod in project ParadoxosModManager by ThibautSF.
the class ListManager method loadModFilesArray.
/**
*/
private void loadModFilesArray() {
String workLabel = ModManager.isConflictComputed() ? "Generate mods and conflicts..." : "Generate mods...";
wd = new WorkIndicatorDialog<String>(window.getScene().getWindow(), workLabel);
wd.addTaskEndNotification(result -> {
try {
updateList();
} catch (Exception eCreate) {
ErrorPrint.printError(eCreate, "When update ListView of ModLists on window creation");
eCreate.printStackTrace();
}
refreshTexts();
// don't keep the object, cleanup
wd = null;
});
wd.exec("LoadMods", inputParam -> {
// String sep = File.separator;
File userDir = new File(absolutePath);
File[] childs = userDir.listFiles();
for (int i = 0; i < childs.length; i++) {
File modDir = childs[i];
// if (modDir.isDirectory() && ListManager.modFileNames.contains(modDir.getName().toLowerCase())) {
if (modDir.isDirectory() && modDir.getName().toLowerCase().equals("mod")) {
// Clean customModFiles
deleteCustomModFiles();
String[] modFiles = modDir.list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.toLowerCase().endsWith(".mod");
}
});
wd.maxProgress = modFiles.length;
int j = 0;
for (String modFile : modFiles) {
availableMods.put(modFile, new Mod(modFile, ModManager.isConflictComputed()));
j++;
wd.currentProgress = j;
}
} else {
// throw new FileNotFoundException("The folder '"+modFile.getAbsolutePath()+"' is missing, please check the path.\nBe sure to have started the game launcher once !");
}
}
return new Integer(1);
});
}
use of mod.Mod in project ParadoxosModManager by ThibautSF.
the class ListManager method modPrint.
/**
* @param applyMods
* @param writer
* @param prefix
* @param modfolder
* @throws IOException
*/
private void modPrint(List<Mod> applyMods, BufferedWriter writer, String prefix, String modfolder) throws IOException {
if (!(modfolder.lastIndexOf("/") == modfolder.length() - 1))
modfolder += "/";
for (Mod mod : applyMods) {
String addLine = "\t\"" + modfolder + prefix + mod.getFileName() + "\"";
writer.write(addLine + System.getProperty("line.separator"));
}
}
Aggregations