Changeset 1082 for java/installer2/src/net/oni2/aeinstaller/backend
- Timestamp:
- Oct 21, 2017, 2:12:34 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/installer2/src/net/oni2/aeinstaller/backend/oni/management/Installer.java
r1076 r1082 13 13 import java.text.SimpleDateFormat; 14 14 import java.util.Date; 15 import java.util.HashMap;16 15 import java.util.HashSet; 17 16 import java.util.List; … … 268 267 269 268 combineBinaryFiles(levels, levelsAffectedBoth, listener, log); 270 combineBSLFolders(mods, listener, log); 269 270 try { 271 combineBSLFolders(mods, listener, log); 272 } catch (IOException e) { 273 log.println("Failed installing BSL files, see aei-output.log for stacktrace"); 274 e.printStackTrace(); 275 } 271 276 272 277 copyPlainFiles (log, mods, listener); … … 296 301 297 302 private static void combineBSLFolders(TreeSet<Package> mods, 298 InstallProgressListener listener, Logger log) {303 InstallProgressListener listener, Logger log) throws IOException { 299 304 listener.installProgressUpdate(95, 100, AEInstaller2.globalBundle.getString("modInstaller.installBsl")); 300 305 log.println(); 301 306 log.println("Installing BSL files"); 302 303 HashMap<EBSLInstallType, Vector<Package>> modsToInclude = new HashMap<EBSLInstallType, Vector<Package>>(); 304 modsToInclude.put(EBSLInstallType.NORMAL, new Vector<Package>()); 305 modsToInclude.put(EBSLInstallType.ADDON, new Vector<Package>()); 306 307 for (Package m : mods.descendingSet()) { 308 File bsl = CaseInsensitiveFile.getCaseInsensitiveFile( 309 m.getLocalPath(), "bsl"); 310 if (bsl.exists()) { 311 if (m.hasSeparatePlatformDirs()) { 312 File bslCommon = CaseInsensitiveFile 313 .getCaseInsensitiveFile(bsl, "common"); 314 File bslMac = CaseInsensitiveFile.getCaseInsensitiveFile( 315 bsl, "mac_only"); 316 File bslWin = CaseInsensitiveFile.getCaseInsensitiveFile( 317 bsl, "win_only"); 318 if ((PlatformInformation.getPlatform() == Platform.MACOS && bslMac 319 .exists()) 320 || ((PlatformInformation.getPlatform() == Platform.WIN || PlatformInformation 321 .getPlatform() == Platform.LINUX) && bslWin 322 .exists()) || bslCommon.exists()) { 323 modsToInclude.get(m.getBSLInstallType()).add(m); 307 308 // First install core non-addon mods 309 log.println("\tCore, non-addon"); 310 for (Package m : mods) { 311 if (m.isCorePackage() && m.getBSLInstallType() == EBSLInstallType.NORMAL) { 312 handleModBsl (m, log, null); 313 } 314 } 315 316 // Now overwrite / add files coming from core addons 317 log.println("\tCore, addon"); 318 for (Package m : mods) { 319 if (m.isCorePackage() && m.getBSLInstallType() == EBSLInstallType.ADDON) { 320 handleModBsl (m, log, null); 321 } 322 } 323 324 // Install non-core non-addon mods (levels affected here are first cleaned up) 325 log.println("\tNon-core, non-addon"); 326 HashSet<String> clearedFolders = new HashSet<String>(); 327 for (Package m : mods) { 328 if (!m.isCorePackage() && m.getBSLInstallType() == EBSLInstallType.NORMAL) { 329 handleModBsl (m, log, clearedFolders); 330 } 331 } 332 333 // Lastly overwrite / add files coming from non-core addons 334 log.println("\tNon-core, addon"); 335 for (Package m : mods) { 336 if (!m.isCorePackage() && m.getBSLInstallType() == EBSLInstallType.ADDON) { 337 handleModBsl (m, log, null); 338 } 339 } 340 341 342 343 } 344 345 private static void handleModBsl(Package sourceMod, Logger log, HashSet<String> clearedFolders) throws IOException { 346 File bslFolder = CaseInsensitiveFile.getCaseInsensitiveFile( 347 sourceMod.getLocalPath(), "bsl"); 348 if (bslFolder.exists()) { 349 if (sourceMod.hasSeparatePlatformDirs()) { 350 File bslCommonFolder = CaseInsensitiveFile 351 .getCaseInsensitiveFile(bslFolder, "common"); 352 File bslMacFolder = CaseInsensitiveFile.getCaseInsensitiveFile( 353 bslFolder, "mac_only"); 354 File bslWinFolder = CaseInsensitiveFile.getCaseInsensitiveFile( 355 bslFolder, "win_only"); 356 357 if (bslCommonFolder.exists()) { 358 copyBsl(sourceMod, log, bslCommonFolder, sourceMod.getBSLInstallType() == EBSLInstallType.ADDON, clearedFolders); 359 } 360 361 if (bslWinFolder.exists() && (PlatformInformation.getPlatform() == Platform.WIN || PlatformInformation 362 .getPlatform() == Platform.LINUX)) { 363 copyBsl(sourceMod, log, bslCommonFolder, sourceMod.getBSLInstallType() == EBSLInstallType.ADDON, clearedFolders); 364 } 365 366 if (bslMacFolder.exists() && PlatformInformation.getPlatform() == Platform.MACOS) { 367 copyBsl(sourceMod, log, bslCommonFolder, sourceMod.getBSLInstallType() == EBSLInstallType.ADDON, clearedFolders); 368 } 369 } else { 370 copyBsl(sourceMod, log, bslFolder, sourceMod.getBSLInstallType() == EBSLInstallType.ADDON, clearedFolders); 371 } 372 } 373 374 } 375 376 private static void copyBsl(Package sourceMod, Logger log, File sourceModFolder, boolean overwriteFiles, HashSet<String> clearedFolders) throws IOException { 377 File targetBaseFolder = new File(Paths.getEditionGDF(), "IGMD"); 378 if (!targetBaseFolder.exists()) 379 targetBaseFolder.mkdir(); 380 381 log.println("\t\tMod \"" + sourceMod.getName() + "\""); 382 for (File sourceLevelFolder : sourceModFolder.listFiles(dirFileFilter)) { 383 log.println("\t\t\t" + sourceLevelFolder.getName() + " (from " + sourceModFolder.getName() + ")"); 384 385 File targetLevelFolder = new File(targetBaseFolder, sourceLevelFolder.getName()); 386 387 if (!(CaseInsensitiveFile.getCaseInsensitiveFile(targetLevelFolder, 388 "ignore.txt").exists())) { 389 // Ignore feature: Don't apply any changes to the target level folder if it contains an "ignore.txt" file 390 log.println("\t\t\t\tSkipping level, target contains an \"ignore.txt\" file"); 391 continue; 392 } 393 394 if (clearedFolders != null && targetLevelFolder.exists() && !clearedFolders.contains(targetLevelFolder.getName())) { 395 // We are in a clear-folders step and this target folder hasn't been cleared so far -> clear (aka delete) the target folder 396 log.println("\t\t\t\tClearing target, first non-core mod that applies changes to this level"); 397 FileUtils.deleteDirectory(targetLevelFolder); 398 } 399 400 if (!targetLevelFolder.exists()) { 401 targetLevelFolder.mkdir(); 402 if (clearedFolders != null) { 403 // Clear-folders step and the target folder did not exist (or was removed for clearing) -> this folder counts as cleared 404 clearedFolders.add(targetLevelFolder.getName()); 405 } 406 } 407 408 for (File sourceBslFile : sourceLevelFolder.listFiles()) { 409 if (sourceBslFile.getName().toLowerCase().endsWith(".bsl")) { 410 File targetFile = new File(targetLevelFolder, sourceBslFile.getName()); 411 if (overwriteFiles || !targetFile.exists()) { 412 // Copy every BSL file from source to target if it either does not yet exist in target or we're currently applying addons (thus overwriting files): 413 if (targetFile.exists()) { 414 log.println("\t\t\t\tOverwriting file from addon: \"" + sourceBslFile.getName() + "\""); 415 } 416 FileUtils.copyFile(sourceBslFile, targetFile); 417 } else { 418 // Non-addon mod, target already exists, skip file 419 log.println("\t\t\t\tSkipping file \"" + sourceBslFile.getName() + "\", target already exists"); 324 420 } 325 } else { 326 modsToInclude.get(m.getBSLInstallType()).add(m); 327 } 328 } 329 } 330 331 for (Package m : modsToInclude.get(EBSLInstallType.NORMAL)) { 332 copyBSL(m, false, log); 333 } 334 Vector<Package> addons = modsToInclude.get(EBSLInstallType.ADDON); 335 for (int i = addons.size() - 1; i >= 0; i--) { 336 copyBSL(addons.get(i), true, log); 337 } 338 } 339 421 } 422 } 423 424 } 425 426 } 427 428 /* 340 429 private static void copyBSL(Package sourceMod, boolean addon, Logger log) { 341 430 File targetBaseFolder = new File(Paths.getEditionGDF(), "IGMD"); … … 407 496 } 408 497 } 498 */ 409 499 410 500 private static void applyPatches(
Note:
See TracChangeset
for help on using the changeset viewer.