Changeset 809
- Timestamp:
- Apr 12, 2013, 7:37:24 PM (12 years ago)
- Location:
- java/installer2/src/net/oni2/aeinstaller
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
java/installer2/src/net/oni2/aeinstaller/backend/oni/management/Installer.java
r804 r809 70 70 71 71 /** 72 * @return list of currently installed mods73 */74 public static Vector<Integer> getInstalledMods() {75 File installCfg = new File(Paths.getEditionGDF(), "installed_mods.xml");76 return PackageManager.getInstance().loadModSelection(installCfg);77 }78 79 /**80 72 * Install the given set of mods 81 73 * … … 115 107 log.println(); 116 108 117 Paths.getEditionGDF().mkdirs(); 118 for (File f : Paths.getEditionGDF().listFiles(new FilenameFilter() { 119 public boolean accept(File arg0, String arg1) { 120 String s = arg1.toLowerCase(); 121 return s.endsWith(".dat") 122 || s.endsWith(".raw") 123 || s.endsWith(".sep") 124 || (s.equals("intro.bik") && !SettingsManager 125 .getInstance().get("copyintro", false)) 126 || (s.equals("outro.bik") && !SettingsManager 127 .getInstance().get("copyoutro", false)); 128 } 129 })) { 130 f.delete(); 131 } 109 HashSet<String> levelsAffectedBefore = null; 110 if (ModInstallationList.getInstance().isLoadedFromFile()) { 111 levelsAffectedBefore = ModInstallationList.getInstance() 112 .getAffectedLevels(); 113 } 114 HashSet<String> levelsAffectedNow = new HashSet<String>(); 115 // TODO: fill set 116 132 117 File IGMD = new File(Paths.getEditionGDF(), "IGMD"); 133 118 if (IGMD.exists()) { … … 149 134 } 150 135 } 151 152 File installCfg = new File(Paths.getEditionGDF(), "installed_mods.xml");153 PackageManager.getInstance().saveModSelection(installCfg, mods);154 136 155 137 TreeSet<Integer> unlockLevels = new TreeSet<Integer>(); … … 217 199 if (levelF.isDirectory()) { 218 200 levelN = fn; 201 levelsAffectedNow.add(fn.toLowerCase()); 219 202 } else if (fn.endsWith(".dat")) { 220 203 levelN = fn.substring(0, fn.lastIndexOf('.')).toLowerCase(); … … 228 211 } 229 212 213 Paths.getEditionGDF().mkdirs(); 214 for (File f : Paths.getEditionGDF().listFiles(new FilenameFilter() { 215 public boolean accept(File arg0, String arg1) { 216 String s = arg1.toLowerCase(); 217 return s.endsWith(".dat") 218 || s.endsWith(".raw") 219 || s.endsWith(".sep") 220 || (s.equals("intro.bik") && !SettingsManager 221 .getInstance().get("copyintro", false)) 222 || (s.equals("outro.bik") && !SettingsManager 223 .getInstance().get("copyoutro", false)); 224 } 225 })) { 226 String l = f.getName().toLowerCase(); 227 l = l.substring(0, l.length() - 4); 228 if ((levelsAffectedBefore == null) 229 || levelsAffectedBefore.contains(l) 230 || levelsAffectedNow.contains(l)) 231 f.delete(); 232 } 233 230 234 applyPatches(levels, foldersPatches, listener, log); 231 235 232 combineBinaryFiles(levels, listener, log); 236 TreeSet<String> levelsAffectedBoth = new TreeSet<String>(); 237 levelsAffectedBoth.addAll(levelsAffectedBefore); 238 levelsAffectedBoth.addAll(levelsAffectedNow); 239 combineBinaryFiles(levels, levelsAffectedBoth, listener, log); 233 240 combineBSLFolders(mods, listener, log); 234 241 … … 238 245 unlockLevels(unlockLevels, log); 239 246 } 247 248 ModInstallationList mil = ModInstallationList.getInstance(); 249 mil.setAffectedLevels(levelsAffectedNow); 250 TreeSet<Integer> modsInstalled = new TreeSet<Integer>(); 251 for (Package p : mods) { 252 modsInstalled.add(p.getPackageNumber()); 253 } 254 mil.setInstalledMods(modsInstalled); 255 mil.saveList(); 240 256 241 257 log.println(); … … 509 525 private static void combineBinaryFiles( 510 526 TreeMap<String, Vector<File>> oniLevelFolders, 511 InstallProgressListener listener, Logger log) { 527 TreeSet<String> levelsUpdated, InstallProgressListener listener, 528 Logger log) { 512 529 long startMS = new Date().getTime(); 513 530 … … 522 539 "Installing level " + l); 523 540 524 ApplicationInvocationResult res = OniSplit.packLevel( 525 oniLevelFolders.get(l), new File(Paths.getEditionGDF(), 526 sanitizeLevelName(l) + ".dat")); 527 log.logAppOutput(res, true); 541 if (levelsUpdated.contains(l.toLowerCase())) { 542 ApplicationInvocationResult res = OniSplit.packLevel( 543 oniLevelFolders.get(l), new File(Paths.getEditionGDF(), 544 sanitizeLevelName(l) + ".dat")); 545 log.logAppOutput(res, true); 546 } else { 547 log.println("\t\tLevel not affected by new mod selection"); 548 log.println(); 549 } 528 550 529 551 stepsDone++; … … 539 561 if (SettingsManager.getInstance().get("copyintro", false)) { 540 562 File src = new File(Paths.getVanillaGDF(), "intro.bik"); 563 File target = new File(Paths.getEditionGDF(), "intro.bik"); 541 564 log.println("Copying intro"); 542 if (src.exists() ) {565 if (src.exists() && !target.exists()) { 543 566 try { 544 567 FileUtils.copyFileToDirectory(src, Paths.getEditionGDF()); … … 552 575 if (SettingsManager.getInstance().get("copyoutro", true)) { 553 576 File src = new File(Paths.getVanillaGDF(), "outro.bik"); 577 File target = new File(Paths.getEditionGDF(), "outro.bik"); 554 578 log.println("Copying outro"); 555 if (src.exists() ) {579 if (src.exists() && !target.exists()) { 556 580 try { 557 581 FileUtils.copyFileToDirectory(src, Paths.getEditionGDF()); -
java/installer2/src/net/oni2/aeinstaller/backend/packages/PackageManager.java
r807 r809 14 14 15 15 import net.oni2.aeinstaller.backend.Paths; 16 import net.oni2.aeinstaller.backend.oni.management. Installer;16 import net.oni2.aeinstaller.backend.oni.management.ModInstallationList; 17 17 import net.oni2.aeinstaller.backend.oni.management.tools.ToolInstallationList; 18 18 import net.oni2.moddepot.DepotManager; … … 32 32 private HashMap<Integer, Package> mods = new HashMap<Integer, Package>(); 33 33 private HashMap<Integer, Package> tools = new HashMap<Integer, Package>(); 34 35 private Vector<Integer> currentlyInstalled = new Vector<Integer>();36 34 37 35 /** … … 131 129 mods.put(m.getPackageNumber(), m); 132 130 } 133 134 updateInstalledMods();135 }136 137 /**138 * Update the list of currently installed mods139 */140 public void updateInstalledMods() {141 currentlyInstalled = Installer.getInstalledMods();142 if (currentlyInstalled == null)143 currentlyInstalled = new Vector<Integer>();144 131 } 145 132 … … 219 206 public TreeSet<Package> getInstalledMods() { 220 207 TreeSet<Package> res = new TreeSet<Package>(); 221 for (int n : Installer.getInstalledMods()) {208 for (int n : ModInstallationList.getInstance().getInstalledMods()) { 222 209 res.add(getPackageByNumber(n)); 223 210 } … … 358 345 */ 359 346 boolean isModInstalled(Package m) { 360 return currentlyInstalled.contains(m.getPackageNumber());347 return ModInstallationList.getInstance().isInstalled(m.getPackageNumber()); 361 348 } 362 349 } -
java/installer2/src/net/oni2/aeinstaller/gui/MainWin.java
r807 r809 782 782 @SuppressWarnings("unused") 783 783 private void installDone() { 784 PackageManager.getInstance().updateInstalledMods();785 784 switch (installState) { 786 785 case DONE:
Note:
See TracChangeset
for help on using the changeset viewer.