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

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

AEI2 0.99g:

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