source: AE/installer2/src/net/oni2/aeinstaller/backend/oni/Installer.java@ 658

Last change on this file since 658 was 657, checked in by alloc, 12 years ago

AEI2 0.99i:

  • Added (un)select all button
  • Fixed install in offline mode
  • Added entry in mod-table-context menu to delete local package
  • Added "added" column to mod table
File size: 21.9 KB
Line 
1package net.oni2.aeinstaller.backend.oni;
2
3import java.io.File;
4import java.io.FileFilter;
5import java.io.FileInputStream;
6import java.io.FileNotFoundException;
7import java.io.FileOutputStream;
8import java.io.FilenameFilter;
9import java.io.IOException;
10import java.io.InputStream;
11import java.io.PrintWriter;
12import java.text.SimpleDateFormat;
13import java.util.Date;
14import java.util.HashMap;
15import java.util.HashSet;
16import java.util.List;
17import java.util.Scanner;
18import java.util.TreeMap;
19import java.util.TreeSet;
20import java.util.Vector;
21
22import net.oni2.aeinstaller.AEInstaller2;
23import net.oni2.aeinstaller.backend.Paths;
24import net.oni2.aeinstaller.backend.Settings;
25import net.oni2.aeinstaller.backend.Settings.Platform;
26import net.oni2.aeinstaller.backend.packages.EBSLInstallType;
27import net.oni2.aeinstaller.backend.packages.Package;
28import net.oni2.aeinstaller.backend.packages.PackageManager;
29
30import org.apache.commons.io.FileUtils;
31import org.javabuilders.swing.SwingJavaBuilder;
32
33import com.thoughtworks.xstream.XStream;
34import com.thoughtworks.xstream.io.xml.StaxDriver;
35
36/**
37 * @author Christian Illy
38 */
39public class Installer {
40 private static FileFilter dirFileFilter = new FileFilter() {
41 @Override
42 public boolean accept(File pathname) {
43 return pathname.isDirectory();
44 }
45 };
46
47 /**
48 * @return Is Edition Core initialized
49 */
50 public static boolean isEditionInitialized() {
51 return Paths.getVanillaOnisPath().exists();
52 }
53
54 private static void createEmptyPath(File path) throws IOException {
55 if (path.exists())
56 FileUtils.deleteDirectory(path);
57 path.mkdirs();
58 }
59
60 /**
61 * @return list of currently installed mods
62 */
63 public static Vector<Integer> getInstalledMods() {
64 File installCfg = new File(Paths.getEditionGDF(), "installed_mods.xml");
65 return PackageManager.getInstance().loadModSelection(installCfg);
66 }
67
68 /**
69 * @return Currently installed tools
70 */
71 @SuppressWarnings("unchecked")
72 public static TreeSet<Integer> getInstalledTools() {
73 File installCfg = new File(Paths.getInstallerPath(),
74 "installed_tools.xml");
75 TreeSet<Integer> res = new TreeSet<Integer>();
76 try {
77 if (installCfg.exists()) {
78 FileInputStream fis = new FileInputStream(installCfg);
79 XStream xs = new XStream(new StaxDriver());
80 Object obj = xs.fromXML(fis);
81 if (obj instanceof TreeSet<?>)
82 res = (TreeSet<Integer>) obj;
83 fis.close();
84 }
85 } catch (FileNotFoundException e) {
86 e.printStackTrace();
87 } catch (IOException e) {
88 e.printStackTrace();
89 }
90 return res;
91 }
92
93 private static void writeInstalledTools(TreeSet<Integer> tools) {
94 File installCfg = new File(Paths.getInstallerPath(),
95 "installed_tools.xml");
96 try {
97 FileOutputStream fos = new FileOutputStream(installCfg);
98 XStream xs = new XStream(new StaxDriver());
99 xs.toXML(tools, fos);
100 fos.close();
101 } catch (FileNotFoundException e) {
102 e.printStackTrace();
103 } catch (IOException e) {
104 e.printStackTrace();
105 }
106 }
107
108 /**
109 * @param tools
110 * Tools to install
111 */
112 public static void installTools(TreeSet<Package> tools) {
113 TreeSet<Integer> installed = getInstalledTools();
114 for (Package m : tools) {
115 File plain = new File(m.getLocalPath(), "plain");
116 if (plain.exists()) {
117 if (m.hasSeparatePlatformDirs()) {
118 File plainCommon = new File(plain, "common");
119 File plainMac = new File(plain, "mac_only");
120 File plainWin = new File(plain, "win_only");
121 if (plainCommon.exists())
122 copyToolsFiles(plainCommon);
123 if (Settings.getPlatform() == Platform.MACOS
124 && plainMac.exists())
125 copyToolsFiles(plainMac);
126 else if (plainWin.exists())
127 copyToolsFiles(plainWin);
128 } else {
129 copyToolsFiles(plain);
130 }
131 }
132 installed.add(m.getPackageNumber());
133 }
134 writeInstalledTools(installed);
135 }
136
137 /**
138 * @param tools
139 * Tools to uninstall
140 */
141 public static void uninstallTools(TreeSet<Package> tools) {
142 TreeSet<Integer> installed = getInstalledTools();
143 for (Package m : tools) {
144 if (installed.contains(m.getPackageNumber())) {
145 File plain = new File(m.getLocalPath(), "plain");
146 if (plain.exists()) {
147 if (m.hasSeparatePlatformDirs()) {
148 File plainCommon = new File(plain, "common");
149 File plainMac = new File(plain, "mac_only");
150 File plainWin = new File(plain, "win_only");
151 if (plainCommon.exists())
152 removeToolsFiles(plainCommon,
153 Paths.getEditionBasePath());
154 if (Settings.getPlatform() == Platform.MACOS
155 && plainMac.exists())
156 removeToolsFiles(plainMac,
157 Paths.getEditionBasePath());
158 else if (plainWin.exists())
159 removeToolsFiles(plainWin,
160 Paths.getEditionBasePath());
161 } else {
162 removeToolsFiles(plain, Paths.getEditionBasePath());
163 }
164 }
165 }
166 installed.remove(m.getPackageNumber());
167 }
168 writeInstalledTools(installed);
169 }
170
171 private static void copyToolsFiles(File srcFolder) {
172 for (File f : srcFolder.listFiles()) {
173 try {
174 if (f.isDirectory())
175 FileUtils.copyDirectoryToDirectory(f,
176 Paths.getEditionBasePath());
177 else
178 FileUtils
179 .copyFileToDirectory(f, Paths.getEditionBasePath());
180 } catch (IOException e) {
181 e.printStackTrace();
182 }
183 }
184 }
185
186 private static void removeToolsFiles(File srcFolder, File target) {
187 for (File f : srcFolder.listFiles()) {
188 if (f.isDirectory())
189 removeToolsFiles(f, new File(target, f.getName()));
190 else {
191 File targetFile = new File(target, f.getName());
192 if (targetFile.exists())
193 targetFile.delete();
194 }
195 }
196 if (target.list().length == 0)
197 target.delete();
198 }
199
200 /**
201 * Install the given set of mods
202 *
203 * @param mods
204 * Mods to install
205 * @param listener
206 * Listener for install progress updates
207 */
208 public static void install(TreeSet<Package> mods,
209 InstallProgressListener listener) {
210 try {
211 createEmptyPath(Paths.getEditionGDF());
212 } catch (IOException e) {
213 e.printStackTrace();
214 }
215
216 File logFile = new File(Paths.getInstallerPath(), "Installation.log");
217 PrintWriter log = null;
218 try {
219 log = new PrintWriter(logFile);
220 } catch (FileNotFoundException e) {
221 e.printStackTrace();
222 }
223 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
224 Date start = new Date();
225 log.println("Installation of mods started at " + sdf.format(start));
226
227 log.println();
228 log.println("AEI2 version: " + SwingJavaBuilder.getConfig().getResource("appversion"));
229 log.println("Installed tools:");
230 for (Package t : PackageManager.getInstance().getInstalledTools()) {
231 log.println(String.format(" - %s (%s)", t.getName(), t.getVersion()));
232 }
233 log.println("Installing mods:");
234 for (Package m : mods) {
235 log.println(String.format(" - %s (%s)", m.getName(), m.getVersion()));
236 }
237 log.println();
238
239 File installCfg = new File(Paths.getEditionGDF(), "installed_mods.xml");
240 PackageManager.getInstance().saveModSelection(installCfg, mods);
241
242 TreeSet<Integer> unlockLevels = new TreeSet<Integer>();
243
244 Vector<File> foldersOni = new Vector<File>();
245 foldersOni.add(Paths.getVanillaOnisPath());
246
247 for (Package m : mods) {
248 for (int lev : m.getUnlockLevels())
249 unlockLevels.add(lev);
250
251 File oni = new File(m.getLocalPath(), "oni");
252 if (oni.exists()) {
253 if (m.hasSeparatePlatformDirs()) {
254 File oniCommon = new File(oni, "common");
255 File oniMac = new File(oni, "mac_only");
256 File oniWin = new File(oni, "win_only");
257 if (oniCommon.exists())
258 foldersOni.add(oniCommon);
259 if (Settings.getPlatform() == Platform.MACOS
260 && oniMac.exists())
261 foldersOni.add(oniMac);
262 else if (oniWin.exists())
263 foldersOni.add(oniWin);
264 } else {
265 foldersOni.add(oni);
266 }
267 }
268 }
269
270 combineBinaryFiles(foldersOni, listener, log);
271 combineBSLFolders(mods, listener, log);
272
273 copyVideos(log);
274
275 if (unlockLevels.size() > 0) {
276 unlockLevels(unlockLevels, log);
277 }
278
279 log.println();
280 Date end = new Date();
281 log.println("Initialization ended at " + sdf.format(end));
282 log.println("Process took "
283 + ((end.getTime() - start.getTime()) / 1000) + " seconds");
284 log.close();
285 }
286
287 private static void combineBSLFolders(TreeSet<Package> mods,
288 InstallProgressListener listener, PrintWriter log) {
289 listener.installProgressUpdate(95, 100, "Installing BSL files");
290 log.println("Installing BSL files");
291
292 HashMap<EBSLInstallType, Vector<Package>> modsToInclude = new HashMap<EBSLInstallType, Vector<Package>>();
293 modsToInclude.put(EBSLInstallType.NORMAL, new Vector<Package>());
294 modsToInclude.put(EBSLInstallType.ADDON, new Vector<Package>());
295
296 for (Package m : mods.descendingSet()) {
297 File bsl = new File(m.getLocalPath(), "bsl");
298 if (bsl.exists()) {
299 if (m.hasSeparatePlatformDirs()) {
300 File bslCommon = new File(bsl, "common");
301 File bslMac = new File(bsl, "mac_only");
302 File bslWin = new File(bsl, "win_only");
303 if ((Settings.getPlatform() == Platform.MACOS && bslMac
304 .exists())
305 || ((Settings.getPlatform() == Platform.WIN || Settings
306 .getPlatform() == Platform.LINUX) && bslWin
307 .exists()) || bslCommon.exists()) {
308 modsToInclude.get(m.getBSLInstallType()).add(m);
309 }
310 } else {
311 modsToInclude.get(m.getBSLInstallType()).add(m);
312 }
313 }
314 }
315
316 for (Package m : modsToInclude.get(EBSLInstallType.NORMAL)) {
317 copyBSL(m, false);
318 }
319 Vector<Package> addons = modsToInclude.get(EBSLInstallType.ADDON);
320 for (int i = addons.size() - 1; i >= 0; i--) {
321 copyBSL(addons.get(i), true);
322 }
323 }
324
325 private static void copyBSL(Package sourceMod, boolean addon) {
326 File targetBaseFolder = new File(Paths.getEditionGDF(), "IGMD");
327 if (!targetBaseFolder.exists())
328 targetBaseFolder.mkdir();
329
330 Vector<File> sources = new Vector<File>();
331 File bsl = new File(sourceMod.getLocalPath(), "bsl");
332 if (sourceMod.hasSeparatePlatformDirs()) {
333 File bslCommon = new File(bsl, "common");
334 File bslMac = new File(bsl, "mac_only");
335 File bslWin = new File(bsl, "win_only");
336 if (Settings.getPlatform() == Platform.MACOS && bslMac.exists()) {
337 for (File f : bslMac.listFiles(dirFileFilter)) {
338 File targetBSL = new File(targetBaseFolder, f.getName());
339 if (addon || !targetBSL.exists())
340 sources.add(f);
341 }
342 }
343 if ((Settings.getPlatform() == Platform.WIN || Settings
344 .getPlatform() == Platform.LINUX) && bslWin.exists()) {
345 for (File f : bslWin.listFiles(dirFileFilter)) {
346 File targetBSL = new File(targetBaseFolder, f.getName());
347 if (addon || !targetBSL.exists())
348 sources.add(f);
349 }
350 }
351 if (bslCommon.exists()) {
352 for (File f : bslCommon.listFiles(dirFileFilter)) {
353 File targetBSL = new File(targetBaseFolder, f.getName());
354 if (addon || !targetBSL.exists())
355 sources.add(f);
356 }
357 }
358 } else {
359 for (File f : bsl.listFiles(dirFileFilter)) {
360 File targetBSL = new File(targetBaseFolder, f.getName());
361 if (addon || !targetBSL.exists())
362 sources.add(f);
363 }
364 }
365
366 System.out.println("For mod: " + sourceMod.getName()
367 + " install BSL folders: " + sources.toString());
368 for (File f : sources) {
369 File targetPath = new File(targetBaseFolder, f.getName());
370 if (!targetPath.exists())
371 targetPath.mkdir();
372 for (File fbsl : f.listFiles()) {
373 File targetFile = new File(targetPath, fbsl.getName());
374 if (addon || !targetFile.exists()) {
375 try {
376 FileUtils.copyFile(fbsl, targetFile);
377 } catch (IOException e) {
378 e.printStackTrace();
379 }
380 }
381 }
382 }
383 }
384
385 private static void combineBinaryFiles(List<File> srcFoldersFiles,
386 InstallProgressListener listener, PrintWriter log) {
387 TreeMap<String, Vector<File>> levels = new TreeMap<String, Vector<File>>();
388
389 for (File path : srcFoldersFiles) {
390 for (File levelF : path.listFiles()) {
391 String fn = levelF.getName().toLowerCase();
392 String levelN = null;
393 if (levelF.isDirectory()) {
394 levelN = fn;
395 } else if (fn.endsWith(".dat")) {
396 levelN = fn.substring(0, fn.lastIndexOf('.'));
397 }
398 if (levelN != null) {
399 if (!levels.containsKey(levelN))
400 levels.put(levelN, new Vector<File>());
401 levels.get(levelN).add(levelF);
402 }
403 }
404 }
405
406 int totalSteps = 0;
407 int stepsDone = 0;
408
409 for (@SuppressWarnings("unused")
410 String s : levels.keySet())
411 totalSteps++;
412 totalSteps++;
413
414 log.println("Importing levels");
415 for (String l : levels.keySet()) {
416 log.println("\tLevel " + l);
417 listener.installProgressUpdate(stepsDone, totalSteps,
418 "Installing level " + l);
419 for (File f : levels.get(l)) {
420 log.println("\t\t\t" + f.getPath());
421 }
422
423 Vector<String> res = OniSplit.packLevel(levels.get(l), new File(
424 Paths.getEditionGDF(), sanitizeLevelName(l) + ".dat"));
425 if (res != null && res.size() > 0) {
426 for (String s : res)
427 log.println("\t\t" + s);
428 }
429
430 log.println();
431 stepsDone++;
432 }
433 }
434
435 private static void copyVideos(PrintWriter log) {
436 if (Settings.getInstance().get("copyintro", false)) {
437 File src = new File(Paths.getVanillaGDF(), "intro.bik");
438 log.println("Copying intro");
439 if (src.exists()) {
440 try {
441 FileUtils.copyFileToDirectory(src, Paths.getEditionGDF());
442 } catch (IOException e) {
443 e.printStackTrace();
444 }
445 }
446 }
447 if (Settings.getInstance().get("copyoutro", true)) {
448 File src = new File(Paths.getVanillaGDF(), "outro.bik");
449 log.println("Copying outro");
450 if (src.exists()) {
451 try {
452 FileUtils.copyFileToDirectory(src, Paths.getEditionGDF());
453 } catch (IOException e) {
454 e.printStackTrace();
455 }
456 }
457 }
458 }
459
460 private static void unlockLevels(TreeSet<Integer> unlockLevels,
461 PrintWriter log) {
462 File dat = new File(Paths.getEditionBasePath(), "persist.dat");
463 log.println("Unlocking levels: " + unlockLevels.toString());
464 if (!dat.exists()) {
465 InputStream is = AEInstaller2.class
466 .getResourceAsStream("/net/oni2/aeinstaller/resources/persist.dat");
467 try {
468 FileUtils.copyInputStreamToFile(is, dat);
469 } catch (IOException e) {
470 // TODO Auto-generated catch block
471 e.printStackTrace();
472 }
473 }
474 PersistDat save = new PersistDat(dat);
475 HashSet<Integer> currentlyUnlocked = save.getUnlockedLevels();
476 currentlyUnlocked.addAll(unlockLevels);
477 save.setUnlockedLevels(currentlyUnlocked);
478 save.close();
479 }
480
481 /**
482 * Initializes the Edition core
483 *
484 * @param listener
485 * Listener for status updates
486 */
487 public static void initializeEdition(InstallProgressListener listener) {
488 File init = new File(Paths.getTempPath(), "init");
489
490 int totalSteps = 0;
491 int stepsDone = 0;
492
493 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
494
495 for (@SuppressWarnings("unused")
496 File f : Paths.getVanillaGDF().listFiles(new FilenameFilter() {
497 @Override
498 public boolean accept(File dir, String name) {
499 return name.endsWith(".dat");
500 }
501 })) {
502 totalSteps++;
503 }
504 totalSteps = totalSteps * 2 + 2;
505
506 try {
507 File logFile = new File(Paths.getInstallerPath(),
508 "Initialization.log");
509 PrintWriter log = new PrintWriter(logFile);
510
511 Date start = new Date();
512 log.println("Initialization of Edition core started at "
513 + sdf.format(start));
514 log.println("Cleaning directories");
515
516 listener.installProgressUpdate(stepsDone, totalSteps,
517 "Cleaning up directories");
518 createEmptyPath(Paths.getVanillaOnisPath());
519 createEmptyPath(init);
520 File level0Folder = new File(init, "level0_Final");
521 createEmptyPath(level0Folder);
522
523 stepsDone++;
524
525 log.println("Exporting levels and moving files to level0");
526
527 for (File f : Paths.getVanillaGDF().listFiles(new FilenameFilter() {
528 @Override
529 public boolean accept(File dir, String name) {
530 return name.endsWith(".dat");
531 }
532 })) {
533 String levelName = f.getName().substring(0,
534 f.getName().indexOf('.'));
535 Scanner fi = new Scanner(levelName);
536 int levelNumber = Integer.parseInt(fi.findInLine("[0-9]+"));
537
538 log.println("\t" + levelName + ":");
539 log.println("\t\tExporting");
540 listener.installProgressUpdate(stepsDone, totalSteps,
541 "Exporting vanilla level " + levelNumber);
542
543 // Edition/GameDataFolder/level*_Final/
544 File tempLevelFolder = new File(init, levelName);
545
546 // Export Vanilla-Level-Dat -> Temp/Level
547 Vector<String> res = OniSplit.export(tempLevelFolder, f);
548 if (res != null && res.size() > 0) {
549 for (String s : res)
550 log.println("\t\t\t" + s);
551 }
552
553 log.println("\t\tMoving files");
554 handleFileGlobalisation(tempLevelFolder, level0Folder,
555 levelNumber);
556 stepsDone++;
557 log.println();
558 }
559
560 log.println("Reimporting levels");
561
562 for (File f : init.listFiles()) {
563 String levelName = f.getName();
564
565 log.println("\t" + levelName);
566 listener.installProgressUpdate(stepsDone, totalSteps,
567 "Creating globalized " + levelName);
568
569 Vector<File> folders = new Vector<File>();
570 folders.add(f);
571
572 Vector<String> res = OniSplit.importLevel(folders, new File(
573 Paths.getVanillaOnisPath(), levelName + ".dat"));
574 if (res != null && res.size() > 0) {
575 for (String s : res)
576 log.println("\t\t" + s);
577 }
578
579 log.println();
580 stepsDone++;
581 }
582
583 listener.installProgressUpdate(stepsDone, totalSteps,
584 "Copying basic files");
585 // Copy Oni-configs
586 File persistVanilla = new File(Paths.getOniBasePath(),
587 "persist.dat");
588 File persistEdition = new File(Paths.getEditionBasePath(),
589 "persist.dat");
590 File keyConfVanilla = new File(Paths.getOniBasePath(),
591 "key_config.txt");
592 File keyConfEdition = new File(Paths.getEditionBasePath(),
593 "key_config.txt");
594 if (persistVanilla.exists() && !persistEdition.exists())
595 FileUtils.copyFile(persistVanilla, persistEdition);
596 if (keyConfVanilla.exists() && !keyConfEdition.exists())
597 FileUtils.copyFile(keyConfVanilla, keyConfEdition);
598
599 FileUtils.deleteDirectory(init);
600
601 Date end = new Date();
602 log.println("Initialization ended at " + sdf.format(end));
603 log.println("Process took "
604 + ((end.getTime() - start.getTime()) / 1000) + " seconds");
605 log.close();
606 } catch (IOException e) {
607 e.printStackTrace();
608 }
609 }
610
611 private static void moveFileToTargetOrDelete(File source, File target) {
612 if (source.equals(target))
613 return;
614 if (!target.exists()) {
615 if (!source.renameTo(target)) {
616 System.err.println("File " + source.getPath() + " not moved!");
617 }
618 } else if (!source.delete()) {
619 System.err.println("File " + source.getPath() + " not deleted!");
620 }
621 }
622
623 private static void handleFileGlobalisation(File tempFolder,
624 File level0Folder, int levelNumber) {
625 // Move AKEV and related files to subfolder so they're not globalized:
626 if (levelNumber != 0) {
627 File akevFolder = new File(tempFolder, "AKEV");
628 akevFolder.mkdir();
629 OniSplit.move(akevFolder, tempFolder.getPath() + "/AKEV*.oni",
630 "overwrite");
631 }
632
633 for (File f : tempFolder.listFiles(new FileFilter() {
634 @Override
635 public boolean accept(File pathname) {
636 return pathname.isFile();
637 }
638 })) {
639 // Move matching files to subfolder NoGlobal:
640 if (f.getName().startsWith("TXMPfail")
641 || f.getName().startsWith("TXMPlevel")
642 || (f.getName().startsWith("TXMP") && f.getName().contains(
643 "intro"))
644 || f.getName().startsWith("TXMB")
645 || f.getName().equals("M3GMpowerup_lsi.oni")
646 || f.getName().equals("TXMPlsi_icon.oni")
647 || (f.getName().startsWith("TXMB") && f.getName().contains(
648 "splash_screen.oni"))) {
649 File noGlobal = new File(tempFolder, "NoGlobal");
650 noGlobal.mkdir();
651 File noGlobalFile = new File(noGlobal, f.getName());
652 moveFileToTargetOrDelete(f, noGlobalFile);
653 }
654 // Move matching files to level0_Animations/level0_TRAC
655 else if (f.getName().startsWith("TRAC")) {
656 File level0File = new File(level0Folder, f.getName());
657 moveFileToTargetOrDelete(f, level0File);
658 }
659 // Move matching files to level0_Animations/level0_TRAM
660 else if (f.getName().startsWith("TRAM")) {
661 File level0File = new File(level0Folder, f.getName());
662 moveFileToTargetOrDelete(f, level0File);
663 }
664 // Move matching files to level0_Textures
665 else if (f.getName().startsWith("ONSK")
666 || f.getName().startsWith("TXMP")) {
667 File level0File = new File(level0Folder, f.getName());
668 moveFileToTargetOrDelete(f, level0File);
669 }
670 // Move matching files to *VANILLA*/level0_Characters
671 else if (f.getName().startsWith("ONCC")
672 || f.getName().startsWith("TRBS")
673 || f.getName().startsWith("ONCV")
674 || f.getName().startsWith("ONVL")
675 || f.getName().startsWith("TRMA")
676 || f.getName().startsWith("TRSC")
677 || f.getName().startsWith("TRAS")) {
678 File level0File = new File(level0Folder, f.getName());
679 moveFileToTargetOrDelete(f, level0File);
680 }
681 // Move matching files to level0_Sounds
682 else if (f.getName().startsWith("OSBD")
683 || f.getName().startsWith("SNDD")) {
684 File level0File = new File(level0Folder, f.getName());
685 moveFileToTargetOrDelete(f, level0File);
686 }
687 // Move matching files to level0_Particles
688 else if (f.getName().startsWith("BINA3")
689 || f.getName().startsWith("M3GMdebris")
690 || f.getName().equals("M3GMtoxic_bubble.oni")
691 || f.getName().startsWith("M3GMelec")
692 || f.getName().startsWith("M3GMrat")
693 || f.getName().startsWith("M3GMjet")
694 || f.getName().startsWith("M3GMbomb_")
695 || f.getName().equals("M3GMbarab_swave.oni")
696 || f.getName().equals("M3GMbloodyfoot.oni")) {
697 File level0File = new File(level0Folder, f.getName());
698 moveFileToTargetOrDelete(f, level0File);
699 }
700 // Move matching files to Archive (aka delete them)
701 else if (f.getName().startsWith("AGDB")
702 || f.getName().startsWith("TRCM")) {
703 f.delete();
704 }
705 // Move matching files to /level0_Final/
706 else if (f.getName().startsWith("ONWC")) {
707 File level0File = new File(level0Folder, f.getName());
708 moveFileToTargetOrDelete(f, level0File);
709 }
710 }
711 }
712
713 private static String sanitizeLevelName(String ln) {
714 int ind = ln.indexOf("_");
715 String res = ln.substring(0, ind + 1);
716 res += ln.substring(ind + 1, ind + 2).toUpperCase();
717 res += ln.substring(ind + 2);
718 return res;
719 }
720
721 /**
722 * Verify that the Edition is within a subfolder to vanilla Oni
723 * (..../Oni/Edition/AEInstaller)
724 *
725 * @return true if GDF can be found in the parent's parent-path
726 */
727 public static boolean verifyRunningDirectory() {
728 return Paths.getVanillaGDF().exists()
729 && Paths.getVanillaGDF().isDirectory();
730 }
731}
Note: See TracBrowser for help on using the repository browser.