Ignore:
Timestamp:
Jan 18, 2013, 4:45:11 PM (12 years ago)
Author:
alloc
Message:

AEI2 0.90:

  • Added blank persist.dat for UnlockLevel to always work
  • Made local paths use the sanitized mod-name
  • Added mod-state column to mod table
File:
1 edited

Legend:

Unmodified
Added
Removed
  • AE/installer2/src/net/oni2/aeinstaller/backend/oni/Installer.java

    r625 r631  
    88import java.io.FilenameFilter;
    99import java.io.IOException;
     10import java.io.InputStream;
    1011import java.io.PrintWriter;
    1112import java.text.SimpleDateFormat;
     
    1920import java.util.Vector;
    2021
     22import net.oni2.aeinstaller.AEInstaller2;
    2123import net.oni2.aeinstaller.backend.Paths;
    2224import net.oni2.aeinstaller.backend.Settings;
     
    244246                combineBSLFolders(mods, listener);
    245247
    246                 if (Settings.getInstance().get("copyintro", false)) {
    247                         File src = new File(Paths.getVanillaGDF(), "intro.bik");
    248                         if (src.exists()) {
    249                                 try {
    250                                         FileUtils.copyFileToDirectory(src, Paths.getEditionGDF());
    251                                 } catch (IOException e) {
    252                                         e.printStackTrace();
    253                                 }
    254                         }
    255                 }
    256                 if (Settings.getInstance().get("copyoutro", true)) {
    257                         File src = new File(Paths.getVanillaGDF(), "outro.bik");
    258                         if (src.exists()) {
    259                                 try {
    260                                         FileUtils.copyFileToDirectory(src, Paths.getEditionGDF());
    261                                 } catch (IOException e) {
    262                                         e.printStackTrace();
    263                                 }
    264                         }
    265                 }
     248                copyVideos();
    266249
    267250                if (unlockLevels.size() > 0) {
    268                         File dat = new File(Paths.getEditionBasePath(), "persist.dat");
    269                         if (dat.exists()) {
    270                                 PersistDat save = new PersistDat(dat);
    271                                 HashSet<Integer> currentlyUnlocked = save.getUnlockedLevels();
    272                                 currentlyUnlocked.addAll(unlockLevels);
    273                                 save.setUnlockedLevels(currentlyUnlocked);
    274                                 save.close();
    275                         } else {
    276                                 // TODO: what if persist.dat does not exist?
    277                         }
     251                        unlockLevels(unlockLevels);
    278252                }
    279253        }
     
    445419        }
    446420
     421        private static void copyVideos() {
     422                if (Settings.getInstance().get("copyintro", false)) {
     423                        File src = new File(Paths.getVanillaGDF(), "intro.bik");
     424                        if (src.exists()) {
     425                                try {
     426                                        FileUtils.copyFileToDirectory(src, Paths.getEditionGDF());
     427                                } catch (IOException e) {
     428                                        e.printStackTrace();
     429                                }
     430                        }
     431                }
     432                if (Settings.getInstance().get("copyoutro", true)) {
     433                        File src = new File(Paths.getVanillaGDF(), "outro.bik");
     434                        if (src.exists()) {
     435                                try {
     436                                        FileUtils.copyFileToDirectory(src, Paths.getEditionGDF());
     437                                } catch (IOException e) {
     438                                        e.printStackTrace();
     439                                }
     440                        }
     441                }
     442        }
     443
     444        private static void unlockLevels(HashSet<Integer> unlockLevels) {
     445                File dat = new File(Paths.getEditionBasePath(), "persist.dat");
     446                if (!dat.exists()) {
     447                        InputStream is = AEInstaller2.class.getResourceAsStream("/net/oni2/aeinstaller/resources/persist.dat");
     448                        try {
     449                                FileUtils.copyInputStreamToFile(is, dat);
     450                        } catch (IOException e) {
     451                                // TODO Auto-generated catch block
     452                                e.printStackTrace();
     453                        }
     454                }
     455                PersistDat save = new PersistDat(dat);
     456                HashSet<Integer> currentlyUnlocked = save.getUnlockedLevels();
     457                currentlyUnlocked.addAll(unlockLevels);
     458                save.setUnlockedLevels(currentlyUnlocked);
     459                save.close();
     460        }
     461
    447462        /**
    448463         * Initializes the Edition core
Note: See TracChangeset for help on using the changeset viewer.