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