Changeset 624 for AE/installer2/src/net/oni2
- Timestamp:
- Jan 16, 2013, 12:22:28 PM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/AEInstaller.properties
r623 r624 1 1 appname=AE Installer 2 2 appversion=0.8 32 appversion=0.84 3 3 4 4 invalidPath.title=Wrong directory -
AE/installer2/src/net/oni2/aeinstaller/AEInstaller2.java
r621 r624 121 121 JFrame.setDefaultLookAndFeelDecorated(true); 122 122 123 // TODO 123 // TODO: Remove debug output 124 124 System.out.println("JarPath: " + Paths.getInstallerPath()); 125 125 System.out.println("PrefsPath: " + Paths.getPrefsPath()); … … 134 134 System.out.println("Globalized:" + Installer.isEditionInitialized()); 135 135 136 // TODO: Check available space 136 137 System.out 137 138 .println("Free space on temp: " -
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(); -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.java
r623 r624 322 322 } 323 323 324 @ DoInBackground(progressMessage = "doUpdate.title", cancelable = false, indeterminateProgress = false)325 private void doUpdate( final BackgroundEvent evt) {324 @SuppressWarnings("unused") 325 private void doUpdate() { 326 326 if (execUpdates != null) { 327 // TODO 328 System.out.println("Update: " + execUpdates.toString()); 329 // TODO: install new tools if previously installed 327 Downloader dl = new Downloader(execUpdates); 328 try { 329 dl.setVisible(true); 330 if (dl.isFinished()) { 331 TreeSet<Integer> installed = Installer.getInstalledTools(); 332 TreeSet<Mod> tools = new TreeSet<Mod>(); 333 for (Mod m : execUpdates) 334 if (m.isTool() 335 && installed.contains(m.getPackageNumber())) 336 tools.add(m); 337 if (tools.size() > 0) { 338 Installer.installTools(tools); 339 } 340 } 341 } finally { 342 dl.dispose(); 343 } 330 344 } 331 345 execUpdates = null; … … 414 428 @SuppressWarnings("unused") 415 429 private void tools() { 416 // TODO method stub430 // TODO: Open tools manager 417 431 JOptionPane.showMessageDialog(this, "tools", "todo", 418 432 JOptionPane.INFORMATION_MESSAGE); … … 435 449 ico = new ImageIcon(m.getIconFile().getPath()); 436 450 } else { 437 URL icon = AEInstaller2.class.getResource("images/transparent.png"); 451 URL icon = AEInstaller2.class 452 .getResource("images/transparent.png"); 438 453 ico = new ImageIcon(icon); 439 454 }
Note:
See TracChangeset
for help on using the changeset viewer.