Changeset 624 for AE/installer2/src/net/oni2/aeinstaller/backend
- Timestamp:
- Jan 16, 2013, 12:22:28 PM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller/backend
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/backend/mods/ModManager.java
r623 r624 286 286 */ 287 287 public HashMap<Mod, HashSet<Mod>> checkDependencies(TreeSet<Mod> mods) { 288 // TODO: Verify functionality 288 // TODO: Verify functionality (checkDependencies) 289 289 HashMap<Mod, HashSet<Mod>> res = new HashMap<Mod, HashSet<Mod>>(); 290 290 … … 311 311 */ 312 312 public HashMap<Mod, HashSet<Mod>> checkIncompabitilites(TreeSet<Mod> mods) { 313 // TODO: Verify functionality 313 // TODO: Verify functionality (checkIncompatibilities) 314 314 HashMap<Mod, HashSet<Mod>> res = new HashMap<Mod, HashSet<Mod>>(); 315 315 -
AE/installer2/src/net/oni2/aeinstaller/backend/mods/download/ModDownload.java
r621 r624 72 72 zipFile = new File(Paths.getDownloadPath(), 73 73 mod.getPackageNumberString() + ".zip"); 74 targetFolder = new File(Paths.getModsPath(), 75 mod.getPackageNumberString()); 74 targetFolder = mod.getLocalPath(); 76 75 try { 77 76 downloader = new FileDownloader(mod.getFile().getUri_full(), -
AE/installer2/src/net/oni2/aeinstaller/backend/oni/Installer.java
r619 r624 3 3 import java.io.File; 4 4 import java.io.FileFilter; 5 import java.io.FileInputStream; 5 6 import java.io.FileNotFoundException; 7 import java.io.FileOutputStream; 6 8 import java.io.FilenameFilter; 7 9 import java.io.IOException; … … 10 12 import java.util.Date; 11 13 import java.util.HashMap; 14 import java.util.HashSet; 12 15 import java.util.List; 13 16 import java.util.Scanner; … … 24 27 25 28 import org.apache.commons.io.FileUtils; 29 30 import com.thoughtworks.xstream.XStream; 31 import com.thoughtworks.xstream.io.xml.StaxDriver; 26 32 27 33 /** … … 58 64 59 65 /** 66 * @return Currently installed tools 67 */ 68 @SuppressWarnings("unchecked") 69 public static TreeSet<Integer> getInstalledTools() { 70 File installCfg = new File(Paths.getInstallerPath(), 71 "installed_tools.xml"); 72 TreeSet<Integer> res = new TreeSet<Integer>(); 73 try { 74 if (installCfg.exists()) { 75 FileInputStream fis = new FileInputStream(installCfg); 76 XStream xs = new XStream(new StaxDriver()); 77 Object obj = xs.fromXML(fis); 78 if (obj instanceof TreeSet<?>) 79 res = (TreeSet<Integer>) obj; 80 fis.close(); 81 } 82 } catch (FileNotFoundException e) { 83 e.printStackTrace(); 84 } catch (IOException e) { 85 e.printStackTrace(); 86 } 87 return res; 88 } 89 90 private static void writeInstalledTools(TreeSet<Integer> tools) { 91 File installCfg = new File(Paths.getInstallerPath(), 92 "installed_tools.xml"); 93 try { 94 FileOutputStream fos = new FileOutputStream(installCfg); 95 XStream xs = new XStream(new StaxDriver()); 96 xs.toXML(tools, fos); 97 fos.close(); 98 } catch (FileNotFoundException e) { 99 e.printStackTrace(); 100 } catch (IOException e) { 101 e.printStackTrace(); 102 } 103 } 104 105 /** 60 106 * @param tools 61 107 * Tools to install 62 108 */ 63 109 public static void installTools(TreeSet<Mod> tools) { 110 TreeSet<Integer> installed = getInstalledTools(); 64 111 for (Mod m : tools) { 65 112 File plain = new File(m.getLocalPath(), "plain"); … … 80 127 } 81 128 } 82 } 129 installed.add(m.getPackageNumber()); 130 } 131 writeInstalledTools(installed); 83 132 } 84 133 … … 88 137 */ 89 138 public static void uninstallTools(TreeSet<Mod> tools) { 90 // TODO: implement this! 139 TreeSet<Integer> installed = getInstalledTools(); 140 for (Mod m : tools) { 141 if (installed.contains(m.getPackageNumber())) { 142 File plain = new File(m.getLocalPath(), "plain"); 143 if (plain.exists()) { 144 if (m.hasSeparatePlatformDirs()) { 145 File plainCommon = new File(plain, "common"); 146 File plainMac = new File(plain, "mac_only"); 147 File plainWin = new File(plain, "win_only"); 148 if (plainCommon.exists()) 149 removeToolsFiles(plainCommon, 150 Paths.getEditionBasePath()); 151 if (Settings.getPlatform() == Platform.MACOS 152 && plainMac.exists()) 153 removeToolsFiles(plainMac, 154 Paths.getEditionBasePath()); 155 else if (plainWin.exists()) 156 removeToolsFiles(plainWin, 157 Paths.getEditionBasePath()); 158 } else { 159 removeToolsFiles(plain, Paths.getEditionBasePath()); 160 } 161 } 162 } 163 installed.remove(m.getPackageNumber()); 164 } 165 writeInstalledTools(installed); 91 166 } 92 167 … … 106 181 } 107 182 183 private static void removeToolsFiles(File srcFolder, File target) { 184 for (File f : srcFolder.listFiles()) { 185 if (f.isDirectory()) 186 removeToolsFiles(f, new File(target, f.getName())); 187 else { 188 File targetFile = new File(target, f.getName()); 189 if (targetFile.exists()) 190 targetFile.delete(); 191 } 192 } 193 if (target.list().length == 0) 194 target.delete(); 195 } 196 108 197 /** 109 198 * Install the given set of mods … … 125 214 ModManager.getInstance().saveModSelection(installCfg, mods); 126 215 216 HashSet<Integer> unlockLevels = new HashSet<Integer>(); 217 127 218 Vector<File> foldersOni = new Vector<File>(); 128 219 foldersOni.add(Paths.getVanillaOnisPath()); 129 220 130 221 for (Mod m : mods) { 222 for (int lev : m.getUnlockLevels()) 223 unlockLevels.add(lev); 224 131 225 File oni = new File(m.getLocalPath(), "oni"); 132 226 if (oni.exists()) { … … 149 243 combineBinaryFiles(foldersOni, listener); 150 244 combineBSLFolders(mods, listener); 245 246 if (unlockLevels.size() > 0) { 247 File dat = new File(Paths.getEditionBasePath(), "persist.dat"); 248 if (dat.exists()) { 249 PersistDat save = new PersistDat(dat); 250 HashSet<Integer> currentlyUnlocked = save.getUnlockedLevels(); 251 currentlyUnlocked.addAll(unlockLevels); 252 save.setUnlockedLevels(currentlyUnlocked); 253 save.close(); 254 } else { 255 // TODO: what if persist.dat does not exist? 256 } 257 } 151 258 } 152 259 -
AE/installer2/src/net/oni2/aeinstaller/backend/oni/OniSplit.java
r619 r624 8 8 9 9 import net.oni2.aeinstaller.backend.Paths; 10 import net.oni2.aeinstaller.backend. QuickAppExecution;10 import net.oni2.aeinstaller.backend.AppExecution; 11 11 import net.oni2.aeinstaller.backend.Settings; 12 12 import net.oni2.aeinstaller.backend.Settings.Architecture; … … 55 55 Vector<String> res = null; 56 56 try { 57 res = QuickAppExecution.execute(cmd);57 res = AppExecution.executeAndWait(cmd); 58 58 } catch (IOException e) { 59 59 e.printStackTrace(); … … 97 97 Vector<String> res = null; 98 98 try { 99 res = QuickAppExecution.execute(cmdLine);99 res = AppExecution.executeAndWait(cmdLine); 100 100 } catch (IOException e) { 101 101 e.printStackTrace(); … … 122 122 Vector<String> res = null; 123 123 try { 124 res = QuickAppExecution.execute(cmdLine);124 res = AppExecution.executeAndWait(cmdLine); 125 125 } catch (IOException e) { 126 126 e.printStackTrace(); … … 151 151 Vector<String> res = null; 152 152 try { 153 res = QuickAppExecution.execute(cmdLine);153 res = AppExecution.executeAndWait(cmdLine); 154 154 } catch (IOException e) { 155 155 e.printStackTrace(); … … 182 182 Vector<String> res = null; 183 183 try { 184 res = QuickAppExecution.execute(cmdLine);184 res = AppExecution.executeAndWait(cmdLine); 185 185 } catch (IOException e) { 186 186 e.printStackTrace();
Note:
See TracChangeset
for help on using the changeset viewer.