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

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

AEI2 0.99g:

  • Forgot to add AEI version to installation.log
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 combineBinaryFiles(foldersOni, listener, log);
270 combineBSLFolders(mods, listener, log);
271
272 copyVideos(log);
273
274 if (unlockLevels.size() > 0) {
275 unlockLevels(unlockLevels, log);
276 }
277
278 Date end = new Date();
279 log.println("Initialization ended at " + sdf.format(end));
280 log.println("Process took "
281 + ((end.getTime() - start.getTime()) / 1000) + " seconds");
282 log.close();
283 }
284
285 private static void combineBSLFolders(TreeSet<Package> mods,
286 InstallProgressListener listener, PrintWriter log) {
287 listener.installProgressUpdate(95, 100, "Installing BSL files");
288 log.println("Installing BSL files");
289
290 HashMap<EBSLInstallType, Vector<Package>> modsToInclude = new HashMap<EBSLInstallType, Vector<Package>>();
291 modsToInclude.put(EBSLInstallType.NORMAL, new Vector<Package>());
292 modsToInclude.put(EBSLInstallType.ADDON, new Vector<Package>());
293
294 for (Package m : mods.descendingSet()) {
295 File bsl = new File(m.getLocalPath(), "bsl");
296 if (bsl.exists()) {
297 if (m.hasSeparatePlatformDirs()) {
298 File bslCommon = new File(bsl, "common");
299 File bslMac = new File(bsl, "mac_only");
300 File bslWin = new File(bsl, "win_only");
301 if ((Settings.getPlatform() == Platform.MACOS && bslMac
302 .exists())
303 || ((Settings.getPlatform() == Platform.WIN || Settings
304 .getPlatform() == Platform.LINUX) && bslWin
305 .exists()) || bslCommon.exists()) {
306 modsToInclude.get(m.getBSLInstallType()).add(m);
307 }
308 } else {
309 modsToInclude.get(m.getBSLInstallType()).add(m);
310 }
311 }
312 }
313
314 for (Package m : modsToInclude.get(EBSLInstallType.NORMAL)) {
315 copyBSL(m, false);
316 }
317 Vector<Package> addons = modsToInclude.get(EBSLInstallType.ADDON);
318 for (int i = addons.size() - 1; i >= 0; i--) {
319 copyBSL(addons.get(i), true);
320 }
321 }
322
323 private static void copyBSL(Package sourceMod, boolean addon) {
324 File targetBaseFolder = new File(Paths.getEditionGDF(), "IGMD");
325 if (!targetBaseFolder.exists())
326 targetBaseFolder.mkdir();
327
328 Vector<File> sources = new Vector<File>();
329 File bsl = new File(sourceMod.getLocalPath(), "bsl");
330 if (sourceMod.hasSeparatePlatformDirs()) {
331 File bslCommon = new File(bsl, "common");
332 File bslMac = new File(bsl, "mac_only");
333 File bslWin = new File(bsl, "win_only");
334 if (Settings.getPlatform() == Platform.MACOS && bslMac.exists()) {
335 for (File f : bslMac.listFiles(dirFileFilter)) {
336 File targetBSL = new File(targetBaseFolder, f.getName());
337 if (addon || !targetBSL.exists())
338 sources.add(f);
339 }
340 }
341 if ((Settings.getPlatform() == Platform.WIN || Settings
342 .getPlatform() == Platform.LINUX) && bslWin.exists()) {
343 for (File f : bslWin.listFiles(dirFileFilter)) {
344 File targetBSL = new File(targetBaseFolder, f.getName());
345 if (addon || !targetBSL.exists())
346 sources.add(f);
347 }
348 }
349 if (bslCommon.exists()) {
350 for (File f : bslCommon.listFiles(dirFileFilter)) {
351 File targetBSL = new File(targetBaseFolder, f.getName());
352 if (addon || !targetBSL.exists())
353 sources.add(f);
354 }
355 }
356 } else {
357 for (File f : bsl.listFiles(dirFileFilter)) {
358 File targetBSL = new File(targetBaseFolder, f.getName());
359 if (addon || !targetBSL.exists())
360 sources.add(f);
361 }
362 }
363
364 System.out.println("For mod: " + sourceMod.getName()
365 + " install BSL folders: " + sources.toString());
366 for (File f : sources) {
367 File targetPath = new File(targetBaseFolder, f.getName());
368 if (!targetPath.exists())
369 targetPath.mkdir();
370 for (File fbsl : f.listFiles()) {
371 File targetFile = new File(targetPath, fbsl.getName());
372 if (addon || !targetFile.exists()) {
373 try {
374 FileUtils.copyFile(fbsl, targetFile);
375 } catch (IOException e) {
376 e.printStackTrace();
377 }
378 }
379 }
380 }
381 }
382
383 private static void combineBinaryFiles(List<File> srcFoldersFiles,
384 InstallProgressListener listener, PrintWriter log) {
385 TreeMap<String, Vector<File>> levels = new TreeMap<String, Vector<File>>();
386
387 for (File path : srcFoldersFiles) {
388 for (File levelF : path.listFiles()) {
389 String fn = levelF.getName().toLowerCase();
390 String levelN = null;
391 if (levelF.isDirectory()) {
392 levelN = fn;
393 } else if (fn.endsWith(".dat")) {
394 levelN = fn.substring(0, fn.lastIndexOf('.'));
395 }
396 if (levelN != null) {
397 if (!levels.containsKey(levelN))
398 levels.put(levelN, new Vector<File>());
399 levels.get(levelN).add(levelF);
400 }
401 }
402 }
403
404 int totalSteps = 0;
405 int stepsDone = 0;
406
407 for (@SuppressWarnings("unused")
408 String s : levels.keySet())
409 totalSteps++;
410 totalSteps++;
411
412 log.println("Importing levels");
413 for (String l : levels.keySet()) {
414 log.println("\tLevel " + l);
415 listener.installProgressUpdate(stepsDone, totalSteps,
416 "Installing level " + l);
417 for (File f : levels.get(l)) {
418 log.println("\t\t\t" + f.getPath());
419 }
420
421 Vector<String> res = OniSplit.packLevel(levels.get(l), new File(
422 Paths.getEditionGDF(), sanitizeLevelName(l) + ".dat"));
423 if (res != null && res.size() > 0) {
424 for (String s : res)
425 log.println("\t\t" + s);
426 }
427
428 log.println();
429 stepsDone++;
430 }
431 }
432
433 private static void copyVideos(PrintWriter log) {
434 if (Settings.getInstance().get("copyintro", false)) {
435 File src = new File(Paths.getVanillaGDF(), "intro.bik");
436 log.println("Copying intro");
437 if (src.exists()) {
438 try {
439 FileUtils.copyFileToDirectory(src, Paths.getEditionGDF());
440 } catch (IOException e) {
441 e.printStackTrace();
442 }
443 }
444 }
445 if (Settings.getInstance().get("copyoutro", true)) {
446 File src = new File(Paths.getVanillaGDF(), "outro.bik");
447 log.println("Copying outro");
448 if (src.exists()) {
449 try {
450 FileUtils.copyFileToDirectory(src, Paths.getEditionGDF());
451 } catch (IOException e) {
452 e.printStackTrace();
453 }
454 }
455 }
456 }
457
458 private static void unlockLevels(TreeSet<Integer> unlockLevels,
459 PrintWriter log) {
460 File dat = new File(Paths.getEditionBasePath(), "persist.dat");
461 log.println("Unlocking levels: " + unlockLevels.toString());
462 if (!dat.exists()) {
463 InputStream is = AEInstaller2.class
464 .getResourceAsStream("/net/oni2/aeinstaller/resources/persist.dat");
465 try {
466 FileUtils.copyInputStreamToFile(is, dat);
467 } catch (IOException e) {
468 // TODO Auto-generated catch block
469 e.printStackTrace();
470 }
471 }
472 PersistDat save = new PersistDat(dat);
473 HashSet<Integer> currentlyUnlocked = save.getUnlockedLevels();
474 currentlyUnlocked.addAll(unlockLevels);
475 save.setUnlockedLevels(currentlyUnlocked);
476 save.close();
477 }
478
479 /**
480 * Initializes the Edition core
481 *
482 * @param listener
483 * Listener for status updates
484 */
485 public static void initializeEdition(InstallProgressListener listener) {
486 File init = new File(Paths.getTempPath(), "init");
487
488 int totalSteps = 0;
489 int stepsDone = 0;
490
491 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
492
493 for (@SuppressWarnings("unused")
494 File f : Paths.getVanillaGDF().listFiles(new FilenameFilter() {
495 @Override
496 public boolean accept(File dir, String name) {
497 return name.endsWith(".dat");
498 }
499 })) {
500 totalSteps++;
501 }
502 totalSteps = totalSteps * 2 + 2;
503
504 try {
505 File logFile = new File(Paths.getInstallerPath(),
506 "Initialization.log");
507 PrintWriter log = new PrintWriter(logFile);
508
509 Date start = new Date();
510 log.println("Initialization of Edition core started at "
511 + sdf.format(start));
512 log.println("Cleaning directories");
513
514 listener.installProgressUpdate(stepsDone, totalSteps,
515 "Cleaning up directories");
516 createEmptyPath(Paths.getVanillaOnisPath());
517 createEmptyPath(init);
518 File level0Folder = new File(init, "level0_Final");
519 createEmptyPath(level0Folder);
520
521 stepsDone++;
522
523 log.println("Exporting levels and moving files to level0");
524
525 for (File f : Paths.getVanillaGDF().listFiles(new FilenameFilter() {
526 @Override
527 public boolean accept(File dir, String name) {
528 return name.endsWith(".dat");
529 }
530 })) {
531 String levelName = f.getName().substring(0,
532 f.getName().indexOf('.'));
533 Scanner fi = new Scanner(levelName);
534 int levelNumber = Integer.parseInt(fi.findInLine("[0-9]+"));
535
536 log.println("\t" + levelName + ":");
537 log.println("\t\tExporting");
538 listener.installProgressUpdate(stepsDone, totalSteps,
539 "Exporting vanilla level " + levelNumber);
540
541 // Edition/GameDataFolder/level*_Final/
542 File tempLevelFolder = new File(init, levelName);
543
544 // Export Vanilla-Level-Dat -> Temp/Level
545 Vector<String> res = OniSplit.export(tempLevelFolder, f);
546 if (res != null && res.size() > 0) {
547 for (String s : res)
548 log.println("\t\t\t" + s);
549 }
550
551 log.println("\t\tMoving files");
552 handleFileGlobalisation(tempLevelFolder, level0Folder,
553 levelNumber);
554 stepsDone++;
555 log.println();
556 }
557
558 log.println("Reimporting levels");
559
560 for (File f : init.listFiles()) {
561 String levelName = f.getName();
562
563 log.println("\t" + levelName);
564 listener.installProgressUpdate(stepsDone, totalSteps,
565 "Creating globalized " + levelName);
566
567 Vector<File> folders = new Vector<File>();
568 folders.add(f);
569
570 Vector<String> res = OniSplit.importLevel(folders, new File(
571 Paths.getVanillaOnisPath(), levelName + ".dat"));
572 if (res != null && res.size() > 0) {
573 for (String s : res)
574 log.println("\t\t" + s);
575 }
576
577 log.println();
578 stepsDone++;
579 }
580
581 listener.installProgressUpdate(stepsDone, totalSteps,
582 "Copying basic files");
583 // Copy Oni-configs
584 File persistVanilla = new File(Paths.getOniBasePath(),
585 "persist.dat");
586 File persistEdition = new File(Paths.getEditionBasePath(),
587 "persist.dat");
588 File keyConfVanilla = new File(Paths.getOniBasePath(),
589 "key_config.txt");
590 File keyConfEdition = new File(Paths.getEditionBasePath(),
591 "key_config.txt");
592 if (persistVanilla.exists() && !persistEdition.exists())
593 FileUtils.copyFile(persistVanilla, persistEdition);
594 if (keyConfVanilla.exists() && !keyConfEdition.exists())
595 FileUtils.copyFile(keyConfVanilla, keyConfEdition);
596
597 FileUtils.deleteDirectory(init);
598
599 Date end = new Date();
600 log.println("Initialization ended at " + sdf.format(end));
601 log.println("Process took "
602 + ((end.getTime() - start.getTime()) / 1000) + " seconds");
603 log.close();
604 } catch (IOException e) {
605 e.printStackTrace();
606 }
607 }
608
609 private static void moveFileToTargetOrDelete(File source, File target) {
610 if (source.equals(target))
611 return;
612 if (!target.exists()) {
613 if (!source.renameTo(target)) {
614 System.err.println("File " + source.getPath() + " not moved!");
615 }
616 } else if (!source.delete()) {
617 System.err.println("File " + source.getPath() + " not deleted!");
618 }
619 }
620
621 private static void handleFileGlobalisation(File tempFolder,
622 File level0Folder, int levelNumber) {
623 // Move AKEV and related files to subfolder so they're not globalized:
624 if (levelNumber != 0) {
625 File akevFolder = new File(tempFolder, "AKEV");
626 akevFolder.mkdir();
627 OniSplit.move(akevFolder, tempFolder.getPath() + "/AKEV*.oni",
628 "overwrite");
629 }
630
631 for (File f : tempFolder.listFiles(new FileFilter() {
632 @Override
633 public boolean accept(File pathname) {
634 return pathname.isFile();
635 }
636 })) {
637 // Move matching files to subfolder NoGlobal:
638 if (f.getName().startsWith("TXMPfail")
639 || f.getName().startsWith("TXMPlevel")
640 || (f.getName().startsWith("TXMP") && f.getName().contains(
641 "intro"))
642 || f.getName().startsWith("TXMB")
643 || f.getName().equals("M3GMpowerup_lsi.oni")
644 || f.getName().equals("TXMPlsi_icon.oni")
645 || (f.getName().startsWith("TXMB") && f.getName().contains(
646 "splash_screen.oni"))) {
647 File noGlobal = new File(tempFolder, "NoGlobal");
648 noGlobal.mkdir();
649 File noGlobalFile = new File(noGlobal, f.getName());
650 moveFileToTargetOrDelete(f, noGlobalFile);
651 }
652 // Move matching files to level0_Animations/level0_TRAC
653 else if (f.getName().startsWith("TRAC")) {
654 File level0File = new File(level0Folder, f.getName());
655 moveFileToTargetOrDelete(f, level0File);
656 }
657 // Move matching files to level0_Animations/level0_TRAM
658 else if (f.getName().startsWith("TRAM")) {
659 File level0File = new File(level0Folder, f.getName());
660 moveFileToTargetOrDelete(f, level0File);
661 }
662 // Move matching files to level0_Textures
663 else if (f.getName().startsWith("ONSK")
664 || f.getName().startsWith("TXMP")) {
665 File level0File = new File(level0Folder, f.getName());
666 moveFileToTargetOrDelete(f, level0File);
667 }
668 // Move matching files to *VANILLA*/level0_Characters
669 else if (f.getName().startsWith("ONCC")
670 || f.getName().startsWith("TRBS")
671 || f.getName().startsWith("ONCV")
672 || f.getName().startsWith("ONVL")
673 || f.getName().startsWith("TRMA")
674 || f.getName().startsWith("TRSC")
675 || f.getName().startsWith("TRAS")) {
676 File level0File = new File(level0Folder, f.getName());
677 moveFileToTargetOrDelete(f, level0File);
678 }
679 // Move matching files to level0_Sounds
680 else if (f.getName().startsWith("OSBD")
681 || f.getName().startsWith("SNDD")) {
682 File level0File = new File(level0Folder, f.getName());
683 moveFileToTargetOrDelete(f, level0File);
684 }
685 // Move matching files to level0_Particles
686 else if (f.getName().startsWith("BINA3")
687 || f.getName().startsWith("M3GMdebris")
688 || f.getName().equals("M3GMtoxic_bubble.oni")
689 || f.getName().startsWith("M3GMelec")
690 || f.getName().startsWith("M3GMrat")
691 || f.getName().startsWith("M3GMjet")
692 || f.getName().startsWith("M3GMbomb_")
693 || f.getName().equals("M3GMbarab_swave.oni")
694 || f.getName().equals("M3GMbloodyfoot.oni")) {
695 File level0File = new File(level0Folder, f.getName());
696 moveFileToTargetOrDelete(f, level0File);
697 }
698 // Move matching files to Archive (aka delete them)
699 else if (f.getName().startsWith("AGDB")
700 || f.getName().startsWith("TRCM")) {
701 f.delete();
702 }
703 // Move matching files to /level0_Final/
704 else if (f.getName().startsWith("ONWC")) {
705 File level0File = new File(level0Folder, f.getName());
706 moveFileToTargetOrDelete(f, level0File);
707 }
708 }
709 }
710
711 private static String sanitizeLevelName(String ln) {
712 int ind = ln.indexOf("_");
713 String res = ln.substring(0, ind + 1);
714 res += ln.substring(ind + 1, ind + 2).toUpperCase();
715 res += ln.substring(ind + 2);
716 return res;
717 }
718
719 /**
720 * Verify that the Edition is within a subfolder to vanilla Oni
721 * (..../Oni/Edition/AEInstaller)
722 *
723 * @return true if GDF can be found in the parent's parent-path
724 */
725 public static boolean verifyRunningDirectory() {
726 return Paths.getVanillaGDF().exists()
727 && Paths.getVanillaGDF().isDirectory();
728 }
729}
Note: See TracBrowser for help on using the repository browser.