Changeset 602 for AE/installer2/src/net/oni2/aeinstaller/backend/mods
- Timestamp:
- Jan 10, 2013, 4:39:53 PM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller/backend/mods
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/backend/mods/Mod.java
r600 r602 13 13 import net.oni2.aeinstaller.backend.Settings; 14 14 import net.oni2.aeinstaller.backend.Settings.Platform; 15 import net.oni2.aeinstaller.backend.depot.DepotConfig; 15 16 import net.oni2.aeinstaller.backend.depot.DepotManager; 16 17 import net.oni2.aeinstaller.backend.depot.model.NodeMod; … … 22 23 public class Mod implements Comparable<Mod> { 23 24 // TODO: Dependencies/Conflicts 24 25 25 26 private String name = ""; 26 27 private int packageNumber = 0; … … 37 38 private net.oni2.aeinstaller.backend.depot.model.File file = null; 38 39 40 private HashSet<Integer> conflicts = new HashSet<Integer>(); 41 private HashSet<Integer> dependencies = new HashSet<Integer>(); 42 39 43 private long localTimestamp = 0; 40 44 … … 52 56 Type t = ModManager.getInstance().getTypeByName(tt.getName()); 53 57 types.add(t); 54 t.addEntry(this); 58 if (!t.getName().equals(DepotConfig.getTaxonomyName_ModType_Tool())) 59 t.addEntry(this); 55 60 } 56 61 platform = nm.getPlatform(); … … 268 273 * @return Is a mod that is always installed? 269 274 */ 270 public boolean is DefaultMod() {275 public boolean isMandatoryMod() { 271 276 return packageNumber < 10000; 272 277 } … … 282 287 public String toString() { 283 288 return name; 289 } 290 291 /** 292 * @return the conflicts 293 */ 294 public HashSet<Integer> getConflicts() { 295 return conflicts; 296 } 297 298 /** 299 * @return the dependencies 300 */ 301 public HashSet<Integer> getDependencies() { 302 return dependencies; 284 303 } 285 304 -
AE/installer2/src/net/oni2/aeinstaller/backend/mods/ModManager.java
r600 r602 5 5 import java.util.Collection; 6 6 import java.util.HashMap; 7 import java.util.HashSet; 8 import java.util.TreeSet; 7 9 import java.util.Vector; 8 10 9 11 import net.oni2.aeinstaller.backend.Paths; 12 import net.oni2.aeinstaller.backend.depot.DepotConfig; 10 13 import net.oni2.aeinstaller.backend.depot.DepotManager; 11 14 import net.oni2.aeinstaller.backend.depot.model.NodeMod; … … 23 26 private HashMap<String, Type> types = new HashMap<String, Type>(); 24 27 private HashMap<Integer, Mod> mods = new HashMap<Integer, Mod>(); 28 private HashMap<Integer, Mod> tools = new HashMap<Integer, Mod>(); 25 29 26 30 /** … … 52 56 } 53 57 58 TaxonomyTerm toolTerm = DepotManager.getInstance().getTaxonomyTerm( 59 DepotConfig.getTaxonomyName_ModType_Tool()); 54 60 for (NodeMod nm : DepotManager.getInstance().getModPackageNodes()) { 55 61 if (nm.getUploads().size() == 1) { 56 62 Mod m = new Mod(nm); 57 mods.put(m.getPackageNumber(), m); 63 if (nm.getTypes().contains(toolTerm)) 64 tools.put(m.getPackageNumber(), m); 65 else 66 mods.put(m.getPackageNumber(), m); 58 67 modFolders.remove(m.getPackageNumber()); 59 68 } … … 102 111 * @return Mods which are always installed 103 112 */ 104 public Collection<Mod> get DefaultMods() {113 public Collection<Mod> getMandatoryMods() { 105 114 Vector<Mod> res = new Vector<Mod>(); 106 115 for (Mod m : mods.values()) { 107 if (m.is DefaultMod())116 if (m.isMandatoryMod()) 108 117 res.add(m); 109 118 } 110 119 return res; 111 120 } 121 122 /** 123 * @return Collection of tools 124 */ 125 public Collection<Mod> getTools() { 126 return tools.values(); 127 } 128 129 /** 130 * @return Tools which are always installed 131 */ 132 public Collection<Mod> getMandatoryTools() { 133 Vector<Mod> res = new Vector<Mod>(); 134 for (Mod m : tools.values()) { 135 if (m.isMandatoryMod()) 136 res.add(m); 137 } 138 return res; 139 } 140 141 /** 142 * Get a mod by its package number 143 * 144 * @param number 145 * Package number 146 * @return Mod or null 147 */ 148 public Mod getModByNumber(int number) { 149 for (Mod m : mods.values()) { 150 if (m.getPackageNumber() == number) 151 return m; 152 } 153 return null; 154 } 155 156 /** 157 * Check for unresolved dependencies within the given mods 158 * 159 * @param mods 160 * Mods to check 161 * @return Unmet dependencies 162 */ 163 public HashMap<Mod, HashSet<Mod>> checkDependencies(TreeSet<Mod> mods) { 164 // TODO: Verify functionality 165 HashMap<Mod, HashSet<Mod>> res = new HashMap<Mod, HashSet<Mod>>(); 166 167 for (Mod m : mods) { 168 for (int depNum : m.getDependencies()) { 169 Mod other = getModByNumber(depNum); 170 if (!mods.contains(other)) { 171 if (!res.containsKey(m)) 172 res.put(m, new HashSet<Mod>()); 173 res.get(m).add(other); 174 } 175 } 176 } 177 178 return res; 179 } 180 181 /** 182 * Check for conflicts between given mods 183 * 184 * @param mods 185 * Mods to check 186 * @return Conflicting mods 187 */ 188 public HashMap<Mod, HashSet<Mod>> checkConflicts(TreeSet<Mod> mods) { 189 // TODO: Verify functionality 190 HashMap<Mod, HashSet<Mod>> res = new HashMap<Mod, HashSet<Mod>>(); 191 192 for (Mod m : mods) { 193 for (int confNum : m.getConflicts()) { 194 Mod other = getModByNumber(confNum); 195 if (mods.contains(other)) { 196 if (!res.containsKey(m)) 197 res.put(m, new HashSet<Mod>()); 198 res.get(m).add(other); 199 } 200 } 201 } 202 203 return res; 204 } 205 112 206 }
Note:
See TracChangeset
for help on using the changeset viewer.