use of mod.ModList in project ParadoxosModManager by ThibautSF.
the class TestModList method setUp.
@Before
public void setUp() {
modList = new ModList("", "", Languages.ENGLISH, new ArrayList<>());
MockitoAnnotations.initMocks(this);
mod1 = Mockito.mock(Mod.class);
Mockito.when(mod1.getName()).thenReturn("mod1");
Mockito.when(mod1.getModifiedFiles()).thenReturn(getModifiedFiles(true, true));
mod2 = Mockito.mock(Mod.class);
Mockito.when(mod2.getName()).thenReturn("mod2");
Mockito.when(mod2.getModifiedFiles()).thenReturn(getModifiedFiles(true, false));
MockitoAnnotations.initMocks(this);
mod3 = Mockito.mock(Mod.class);
Mockito.when(mod3.getName()).thenReturn("mod3");
Mockito.when(mod3.getModifiedFiles()).thenReturn(getModifiedFiles(false, true));
}
use of mod.ModList in project ParadoxosModManager by ThibautSF.
the class MyXML method getSavedList.
/**
* @return
*/
public ArrayList<ModList> getSavedList(Map<String, Mod> availableMods) {
ArrayList<ModList> userLists = new ArrayList<ModList>();
List<Element> modLists = root.getChildren(LIST);
Iterator<Element> i = modLists.iterator();
while (i.hasNext()) {
ArrayList<Mod> listMods = new ArrayList<Mod>();
Element oneListElement = (Element) i.next();
String listName = oneListElement.getAttribute(NAME).getValue();
String listDescr = oneListElement.getChild(DESCR).getText();
String listLang;
try {
listLang = oneListElement.getChild(LANG).getText();
} catch (RuntimeException e) {
listLang = null;
}
List<Element> modsElements = oneListElement.getChildren(MOD);
for (Element modElement : modsElements) {
List<Attribute> modElementAttr = modElement.getAttributes();
String fileName = "", modName = "", remoteFileId = null;
for (Attribute attribute : modElementAttr) {
switch(attribute.getName()) {
case ID:
case FILE_NAME:
fileName = attribute.getValue();
break;
case MOD_NAME:
modName = attribute.getValue();
break;
case REMOTE_ID:
remoteFileId = attribute.getValue();
break;
default:
break;
}
}
Mod oneMod = availableMods.get(fileName);
if (oneMod == null) {
oneMod = new Mod(modName, fileName, remoteFileId);
if (remoteFileId != null && !"".equals(remoteFileId)) {
for (Mod mod : availableMods.values()) {
if (mod.getRemoteFileID().equals(remoteFileId)) {
oneMod = mod;
}
}
}
}
if (!listMods.contains(oneMod)) {
listMods.add(oneMod);
}
}
ModList oneList = new ModList(listName, listDescr, Languages.getLanguage(listLang), listMods);
userLists.add(oneList);
}
return userLists;
}
use of mod.ModList in project ParadoxosModManager by ThibautSF.
the class MyXML method importList.
public String importList(String xml, Map<String, Mod> availableMods) throws Exception {
SAXBuilder sxb = new SAXBuilder();
Document importDocument = sxb.build(xml);
Element importRoot = importDocument.getRootElement();
if (importRoot.getAttribute(GAME_ID).getValue().equals(ModManager.STEAM_ID.toString())) {
List<Element> modLists = importRoot.getChildren(LIST);
Iterator<Element> i = modLists.iterator();
while (i.hasNext()) {
ArrayList<Mod> listMods = new ArrayList<Mod>();
Element oneListElement = (Element) i.next();
String listName = oneListElement.getAttribute(NAME).getValue();
String listDescr = oneListElement.getChild(DESCR).getText();
String listLang = oneListElement.getChild(LANG).getText();
List<Element> modsElements = oneListElement.getChildren(MOD);
for (Element modElement : modsElements) {
List<Attribute> modElementAttr = modElement.getAttributes();
String fileName = "", modName = "", remoteFileId = null;
for (Attribute attribute : modElementAttr) {
switch(attribute.getName()) {
case ID:
case FILE_NAME:
fileName = attribute.getValue();
break;
case MOD_NAME:
modName = attribute.getValue();
break;
case REMOTE_ID:
remoteFileId = attribute.getValue();
break;
default:
break;
}
}
Mod oneMod = availableMods.get(fileName);
if (oneMod == null) {
oneMod = new Mod(modName, fileName, remoteFileId);
if (remoteFileId != null && !"".equals(remoteFileId)) {
for (Mod mod : availableMods.values()) {
if (mod.getRemoteFileID().equals(remoteFileId)) {
oneMod = mod;
}
}
}
}
if (!listMods.contains(oneMod)) {
listMods.add(oneMod);
}
}
ModList oneList = new ModList("[Imported]" + listName + "_" + System.currentTimeMillis(), listDescr, Languages.getLanguage(listLang), listMods);
modifyList(oneList);
}
return "Import done.";
}
return "Import procedure aborted, this list is not for the current game !";
}