Changeset 608 for AE/installer2/src/net/oni2/aeinstaller/backend
- Timestamp:
- Jan 14, 2013, 6:49:25 PM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller/backend
- Files:
-
- 4 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)) { -
AE/installer2/src/net/oni2/aeinstaller/backend/oni/Installer.java
r606 r608 9 9 import java.text.SimpleDateFormat; 10 10 import java.util.Date; 11 import java.util.HashMap; 11 12 import java.util.List; 12 13 import java.util.Scanner; … … 18 19 import net.oni2.aeinstaller.backend.Settings; 19 20 import net.oni2.aeinstaller.backend.Settings.Platform; 21 import net.oni2.aeinstaller.backend.mods.EBSLInstallType; 20 22 import net.oni2.aeinstaller.backend.mods.Mod; 21 23 import net.oni2.aeinstaller.backend.mods.ModManager; … … 27 29 */ 28 30 public class Installer { 31 private static FileFilter dirFileFilter = new FileFilter() { 32 @Override 33 public boolean accept(File pathname) { 34 return pathname.isDirectory(); 35 } 36 }; 37 29 38 /** 30 39 * @return Is Edition Core initialized … … 97 106 } 98 107 } 108 99 109 /** 100 110 * Install the given set of mods … … 116 126 ModManager.getInstance().saveModSelection(installCfg, mods); 117 127 118 Vector<File> folders = new Vector<File>();119 folders .add(Paths.getVanillaOnisPath());128 Vector<File> foldersOni = new Vector<File>(); 129 foldersOni.add(Paths.getVanillaOnisPath()); 120 130 121 131 for (Mod m : mods) { … … 127 137 File oniWin = new File(oni, "win_only"); 128 138 if (oniCommon.exists()) 129 folders .add(oniCommon);139 foldersOni.add(oniCommon); 130 140 if (Settings.getPlatform() == Platform.MACOS 131 141 && oniMac.exists()) 132 folders .add(oniMac);142 foldersOni.add(oniMac); 133 143 else if (oniWin.exists()) 134 folders .add(oniWin);144 foldersOni.add(oniWin); 135 145 } else { 136 folders.add(oni); 137 } 138 } 139 } 140 141 combineBinaryFiles(folders, listener); 142 143 // TODO: bsl() 146 foldersOni.add(oni); 147 } 148 } 149 } 150 combineBinaryFiles(foldersOni, listener); 151 combineBSLFolders(mods, listener); 152 } 153 154 private static void combineBSLFolders(TreeSet<Mod> mods, 155 InstallProgressListener listener) { 156 listener.installProgressUpdate(95, 100, "Installing BSL files"); 157 158 HashMap<EBSLInstallType, Vector<Mod>> modsToInclude = new HashMap<EBSLInstallType, Vector<Mod>>(); 159 modsToInclude.put(EBSLInstallType.NORMAL, new Vector<Mod>()); 160 modsToInclude.put(EBSLInstallType.ADDON, new Vector<Mod>()); 161 162 for (Mod m : mods.descendingSet()) { 163 File bsl = new File(m.getLocalPath(), "bsl"); 164 if (bsl.exists()) { 165 if (m.hasSeparatePlatformDirs()) { 166 File bslCommon = new File(bsl, "common"); 167 File bslMac = new File(bsl, "mac_only"); 168 File bslWin = new File(bsl, "win_only"); 169 if ((Settings.getPlatform() == Platform.MACOS && bslMac 170 .exists()) 171 || ((Settings.getPlatform() == Platform.WIN || Settings 172 .getPlatform() == Platform.LINUX) && bslWin 173 .exists()) || bslCommon.exists()) { 174 modsToInclude.get(m.getBSLInstallType()).add(m); 175 } 176 } else { 177 modsToInclude.get(m.getBSLInstallType()).add(m); 178 } 179 } 180 } 181 182 for (Mod m : modsToInclude.get(EBSLInstallType.NORMAL)) { 183 copyBSL(m, false); 184 } 185 for (Mod m : modsToInclude.get(EBSLInstallType.ADDON)) { 186 copyBSL(m, true); 187 } 188 } 189 190 private static void copyBSL(Mod sourceMod, boolean addon) { 191 File targetBaseFolder = new File(Paths.getEditionGDF(), "IGMD"); 192 if (!targetBaseFolder.exists()) 193 targetBaseFolder.mkdir(); 194 195 Vector<File> sources = new Vector<File>(); 196 File bsl = new File(sourceMod.getLocalPath(), "bsl"); 197 if (sourceMod.hasSeparatePlatformDirs()) { 198 File bslCommon = new File(bsl, "common"); 199 File bslMac = new File(bsl, "mac_only"); 200 File bslWin = new File(bsl, "win_only"); 201 if (Settings.getPlatform() == Platform.MACOS && bslMac.exists()) { 202 for (File f : bslMac.listFiles(dirFileFilter)) { 203 File targetBSL = new File(targetBaseFolder, f.getName()); 204 if (addon || !targetBSL.exists()) 205 sources.add(f); 206 } 207 } 208 if ((Settings.getPlatform() == Platform.WIN || Settings 209 .getPlatform() == Platform.LINUX) && bslWin.exists()) { 210 for (File f : bslWin.listFiles(dirFileFilter)) { 211 File targetBSL = new File(targetBaseFolder, f.getName()); 212 if (addon || !targetBSL.exists()) 213 sources.add(f); 214 } 215 } 216 if (bslCommon.exists()) { 217 for (File f : bslCommon.listFiles(dirFileFilter)) { 218 File targetBSL = new File(targetBaseFolder, f.getName()); 219 if (addon || !targetBSL.exists()) 220 sources.add(f); 221 } 222 } 223 } else { 224 for (File f : bsl.listFiles(dirFileFilter)) { 225 File targetBSL = new File(targetBaseFolder, f.getName()); 226 if (addon || !targetBSL.exists()) 227 sources.add(f); 228 } 229 } 230 231 System.out.println("For mod: " + sourceMod.getName() 232 + " install BSL folders: " + sources.toString()); 233 for (File f : sources) { 234 File targetPath = new File(targetBaseFolder, f.getName()); 235 if (!targetPath.exists()) 236 targetPath.mkdir(); 237 for (File fbsl : f.listFiles()) { 238 File targetFile = new File(targetPath, fbsl.getName()); 239 if (!targetFile.exists()) { 240 try { 241 FileUtils.copyFile(fbsl, targetFile); 242 } catch (IOException e) { 243 // TODO Auto-generated catch block 244 e.printStackTrace(); 245 } 246 } 247 } 248 } 144 249 } 145 250 … … 171 276 String s : levels.keySet()) 172 277 totalSteps++; 278 totalSteps++; 173 279 174 280 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); … … 202 308 203 309 log.println(); 310 stepsDone++; 204 311 } 205 312
Note:
See TracChangeset
for help on using the changeset viewer.