Changeset 608 for AE/installer2/src/net/oni2/aeinstaller/backend/mods
- Timestamp:
- Jan 14, 2013, 6:49:25 PM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller/backend/mods
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/backend/mods/EBSLInstallType.java
r600 r608 5 5 */ 6 6 public enum EBSLInstallType { 7 /**8 * No BSL files9 */10 NONE,11 7 /** 12 8 * Normal BSL install mode -
AE/installer2/src/net/oni2/aeinstaller/backend/mods/Mod.java
r604 r608 29 29 private String version = ""; 30 30 private String creator = ""; 31 private EBSLInstallType bslInstallType = null;31 private EBSLInstallType bslInstallType = EBSLInstallType.NORMAL; 32 32 private String description = ""; 33 33 private double aeVersion = 0; … … 36 36 private net.oni2.aeinstaller.backend.depot.model.File file = null; 37 37 38 private HashSet<Integer> conflicts = new HashSet<Integer>();38 private HashSet<Integer> incompatibilities = new HashSet<Integer>(); 39 39 private HashSet<Integer> dependencies = new HashSet<Integer>(); 40 40 … … 51 51 name = nm.getTitle(); 52 52 packageNumber = nm.getPackageNumber(); 53 platform = nm.getPlatform(); 53 54 for (TaxonomyTerm tt : nm.getTypes()) { 54 55 Type t = ModManager.getInstance().getTypeByName(tt.getName()); 55 56 types.add(t); 56 if (!nm.isTool() )57 if (!nm.isTool() && isValidOnPlatform()) 57 58 t.addEntry(this); 58 59 } 59 platform = nm.getPlatform();60 60 version = nm.getVersion(); 61 61 creator = nm.getCreator(); … … 101 101 if (sVal.equalsIgnoreCase("addon")) 102 102 bslInstallType = EBSLInstallType.ADDON; 103 else if (sVal.equalsIgnoreCase("yes"))104 bslInstallType = EBSLInstallType.NORMAL;105 else106 bslInstallType = EBSLInstallType.NONE;107 103 } else if (sName.equalsIgnoreCase("ModVersion")) { 108 104 if (node == null) … … 111 107 if (node == null) 112 108 description = sVal.replaceAll("\\\\n", "<br>"); 113 } else if (sName.equalsIgnoreCase("Depends ")) {109 } else if (sName.equalsIgnoreCase("DependsOn")) { 114 110 String[] depsS = sVal.split(","); 115 111 for (String s : depsS) { … … 123 119 } 124 120 } 125 } else if (sName.equalsIgnoreCase(" Conflicts")) {121 } else if (sName.equalsIgnoreCase("IncompatibleWith")) { 126 122 String[] confS = sVal.split(","); 127 123 for (String s : confS) { 128 124 try { 129 125 int conf = Integer.parseInt(s); 130 conflicts.add(conf);126 incompatibilities.add(conf); 131 127 } catch (NumberFormatException e) { 132 128 System.err 133 .format("Mod %05d does contain a non-number dependency: '%s'\n",129 .format("Mod %05d does contain a non-number incompatibility: '%s'\n", 134 130 packageNumber, s); 135 131 } … … 182 178 updateLocalData(); 183 179 184 Type t = ModManager.getInstance().getTypeByName("-Local-");185 types.add(t);186 t.addEntry(this);187 188 180 platform = ECompatiblePlatform.BOTH; 189 181 } … … 323 315 324 316 /** 325 * @return the conflicts326 */ 327 public HashSet<Integer> get Conflicts() {328 return conflicts;317 * @return the incompabitilities 318 */ 319 public HashSet<Integer> getIncompabitilities() { 320 return incompatibilities; 329 321 } 330 322 … … 339 331 * @return Is this mod valid on the running platform? 340 332 */ 341 public boolean validOnPlatform() { 342 ECompatiblePlatform plat = platform; 343 switch (plat) { 333 public boolean isValidOnPlatform() { 334 switch (platform) { 344 335 case BOTH: 345 336 return true; -
AE/installer2/src/net/oni2/aeinstaller/backend/mods/ModManager.java
r604 r608 43 43 Vector<Integer> res = new Vector<Integer>(); 44 44 try { 45 FileInputStream fis = new FileInputStream(f); 46 XStream xs = new XStream(new StaxDriver()); 47 Object obj = xs.fromXML(fis); 48 if (obj instanceof Vector<?>) 49 res = (Vector<Integer>) obj; 50 fis.close(); 45 if (f.exists()) { 46 FileInputStream fis = new FileInputStream(f); 47 XStream xs = new XStream(new StaxDriver()); 48 Object obj = xs.fromXML(fis); 49 if (obj instanceof Vector<?>) 50 res = (Vector<Integer>) obj; 51 fis.close(); 52 } 51 53 } catch (FileNotFoundException e) { 52 54 e.printStackTrace(); … … 87 89 mods = new HashMap<Integer, Mod>(); 88 90 89 types.put("-Local-", new Type("-Local-", null)); 91 Type localType = new Type("-Local-", null); 92 types.put("-Local-", localType); 90 93 91 94 for (TaxonomyTerm tt : DepotManager.getInstance() … … 120 123 121 124 for (Mod m : modFolders.values()) { 125 if (!m.isMandatoryMod()) { 126 localType.addEntry(m); 127 m.getTypes().add(localType); 128 } 122 129 mods.put(m.getPackageNumber(), m); 123 130 } … … 152 159 153 160 /** 154 * @return Collection of mods 155 */ 156 public Collection<Mod> getMods() { 157 return mods.values(); 158 } 159 160 /** 161 * @return Mods which are always installed 161 * @return Collection of mods valid on this platform and not mandatory 162 */ 163 public Collection<Mod> getModsValidAndNotMandatory() { 164 Vector<Mod> res = new Vector<Mod>(); 165 for (Mod m : mods.values()) 166 if (m.isValidOnPlatform() && !m.isMandatoryMod()) 167 res.add(m); 168 return res; 169 } 170 171 /** 172 * @return Mods which are always installed and valid on this platform 162 173 */ 163 174 public TreeSet<Mod> getMandatoryMods() { 164 175 TreeSet<Mod> res = new TreeSet<Mod>(); 165 176 for (Mod m : mods.values()) { 166 if (m.is MandatoryMod())167 res.add(m); 168 } 169 return res; 170 } 171 172 /** 173 * @return Collection of tools 177 if (m.isValidOnPlatform() && m.isMandatoryMod()) 178 res.add(m); 179 } 180 return res; 181 } 182 183 /** 184 * @return Collection of tools valid on this platform and not mandatory 174 185 */ 175 186 public Collection<Mod> getTools() { 176 return tools.values(); 177 } 178 179 /** 180 * @return Tools which are always installed 187 Vector<Mod> res = new Vector<Mod>(); 188 for (Mod m : tools.values()) 189 if (m.isValidOnPlatform() && !m.isMandatoryMod()) 190 res.add(m); 191 return res; 192 } 193 194 /** 195 * @return Tools which are always installed and valid on this platform 181 196 */ 182 197 public TreeSet<Mod> getMandatoryTools() { 183 198 TreeSet<Mod> res = new TreeSet<Mod>(); 184 199 for (Mod m : tools.values()) { 185 if (m.is MandatoryMod())200 if (m.isValidOnPlatform() && m.isMandatoryMod()) 186 201 res.add(m); 187 202 } … … 230 245 231 246 /** 232 * Check for conflicts between given mods247 * Check for incompabitilites between given mods 233 248 * 234 249 * @param mods 235 250 * Mods to check 236 * @return Conflictingmods237 */ 238 public HashMap<Mod, HashSet<Mod>> check Conflicts(TreeSet<Mod> mods) {251 * @return Incompatible mods 252 */ 253 public HashMap<Mod, HashSet<Mod>> checkIncompabitilites(TreeSet<Mod> mods) { 239 254 // TODO: Verify functionality 240 255 HashMap<Mod, HashSet<Mod>> res = new HashMap<Mod, HashSet<Mod>>(); 241 256 242 257 for (Mod m : mods) { 243 for (int confNum : m.get Conflicts()) {258 for (int confNum : m.getIncompabitilities()) { 244 259 Mod other = getModByNumber(confNum); 245 260 if (mods.contains(other)) {
Note:
See TracChangeset
for help on using the changeset viewer.