Changeset 605 for AE/installer2/src/net
- Timestamp:
- Jan 13, 2013, 8:11:07 PM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller
- Files:
-
- 5 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/AEInstaller.properties
r604 r605 1 1 appname=AE Installer 2 2 appversion=0. 622 appversion=0.70 3 3 4 4 invalidPath.title=Wrong directory -
AE/installer2/src/net/oni2/aeinstaller/Images.properties
r600 r605 26 26 img.refresh=/net/oni2/aeinstaller/images/tango/view-refresh.png 27 27 img.tools=/net/oni2/aeinstaller/images/open_icon_library/tools-hammer_and_nails.png 28 img.install=/net/oni2/aeinstaller/images/open_icon_library/run-build-install-root.png 28 29 29 30 img.ae=/net/oni2/aeinstaller/images/AElogo.png 30 img. install=/net/oni2/aeinstaller/images/open_icon_library/run-build-install-root.png31 img.oni=/net/oni2/aeinstaller/images/oni.png -
AE/installer2/src/net/oni2/aeinstaller/backend/Settings.java
r604 r605 10 10 import java.util.Vector; 11 11 12 13 12 import com.thoughtworks.xstream.XStream; 14 13 import com.thoughtworks.xstream.io.xml.StaxDriver; … … 66 65 67 66 private boolean printNamesNotInMap = false; 68 67 68 /** 69 * @return path to wine 70 */ 71 public static String getWinePath() { 72 if (getPlatform() != Platform.LINUX) 73 return null; 74 75 Vector<String> cmd = new Vector<String>(); 76 cmd.add("which"); 77 cmd.add("wine"); 78 Vector<String> res = null; 79 try { 80 res = QuickAppExecution.execute(cmd); 81 } catch (IOException e) { 82 // TODO Auto-generated catch block 83 e.printStackTrace(); 84 } 85 if (res != null) { 86 if (res.get(0).startsWith("/") && res.get(0).endsWith("wine")) { 87 return res.get(0); 88 } 89 } 90 return null; 91 } 92 69 93 /** 70 94 * Get the singleton instance -
AE/installer2/src/net/oni2/aeinstaller/backend/depot/DepotManager.java
r603 r605 92 92 page = 0; 93 93 do { 94 ja = DrupalJSONQuery.getIndex("taxonomy_vocabulary", page );94 ja = DrupalJSONQuery.getIndex("taxonomy_vocabulary", page, 100); 95 95 for (int i = 0; i < ja.length(); i++) { 96 96 jo = ja.getJSONObject(i); … … 106 106 page = 0; 107 107 do { 108 ja = DrupalJSONQuery.getIndex("taxonomy_term", page );108 ja = DrupalJSONQuery.getIndex("taxonomy_term", page, 100); 109 109 for (int i = 0; i < ja.length(); i++) { 110 110 jo = ja.getJSONObject(i); … … 122 122 page = 0; 123 123 do { 124 ja = DrupalJSONQuery.getIndex("node", page );124 ja = DrupalJSONQuery.getIndex("node", page, 500); 125 125 for (int i = 0; i < ja.length(); i++) { 126 126 jo = ja.getJSONObject(i); … … 152 152 page = 0; 153 153 do { 154 ja = DrupalJSONQuery.getIndex("file", page );154 ja = DrupalJSONQuery.getIndex("file", page, 500); 155 155 for (int i = 0; i < ja.length(); i++) { 156 156 jo = ja.getJSONObject(i); -
AE/installer2/src/net/oni2/aeinstaller/backend/mods/download/ModDownload.java
r604 r605 96 96 */ 97 97 public void start() { 98 state = ModDownloadState.RUNNING; 98 99 downloader.start(); 99 100 } -
AE/installer2/src/net/oni2/aeinstaller/backend/mods/download/ModDownloader.java
r604 r605 67 67 currentDownload++; 68 68 downloadedCurrent = 0; 69 if ( currentDownload < downloads.size()) {69 if ((state == State.RUNNING) && (currentDownload < downloads.size())) { 70 70 downloads.get(currentDownload).start(); 71 71 } else { … … 74 74 } 75 75 76 /** 77 * @return Average download speed for up to now in B/s 78 */ 79 public int getDownloadSpeed() { 80 long duration = new Date().getTime() - startMS; 81 int down = downloadedComplete + downloadedCurrent; 82 return (int) (down * 1000 / duration); 76 private int getTimeElapsed() { 77 int total = (int) (new Date().getTime() - startMS) 78 / 1000; 79 return total; 83 80 } 84 81 85 /** 86 * @return Remaining time for all downloads by avg-speed in seconds 87 */ 88 public int getTimeRemaining() { 82 private int getDownloadSpeed() { 83 int elap = getTimeElapsed(); 84 int down = downloadedComplete + downloadedCurrent; 85 if (elap > 0) 86 return down / elap; 87 else 88 return 1; 89 } 90 91 private int getTimeRemaining() { 89 92 int remainingSize = totalSize 90 93 - (downloadedComplete + downloadedCurrent); … … 94 97 private void notifyListener() { 95 98 listener.updateStatus(this, state, unpacked, downloads.size(), 96 downloadedComplete + downloadedCurrent, totalSize); 99 downloadedComplete + downloadedCurrent, totalSize, 100 getTimeElapsed(), getTimeRemaining(), getDownloadSpeed()); 101 } 102 103 /** 104 * @return total download size 105 */ 106 public int getTotalSize() { 107 return totalSize; 97 108 } 98 109 … … 133 144 } 134 145 146 /** 147 * Abort download process 148 */ 149 public void abort() { 150 if (currentDownload < downloads.size()) { 151 state = State.INTERRUPTED; 152 ModDownload md = downloads.get(currentDownload); 153 md.abort(); 154 } 155 } 156 135 157 } -
AE/installer2/src/net/oni2/aeinstaller/backend/mods/download/ModDownloaderListener.java
r604 r605 22 22 * @param bytesTotal 23 23 * Bytes in total to handle 24 * @param duration 25 * Duration of downloads in seconds 26 * @param remaining 27 * Remaining time in seconds 28 * @param speed 29 * Average download speed in B/s 24 30 */ 25 31 public void updateStatus(ModDownloader source, State state, int filesDown, 26 int filesTotal, int bytesDown, int bytesTotal); 32 int filesTotal, int bytesDown, int bytesTotal, int duration, 33 int remaining, int speed); 27 34 } -
AE/installer2/src/net/oni2/aeinstaller/backend/network/DrupalJSONQuery.java
r600 r605 112 112 * Number of page to get (for limited results, e.g. nodes), -1 to 113 113 * ignore 114 * @param pagesize 115 * Maximum number of elements to return 114 116 * @return JSON structure of item 115 117 * @throws Exception 116 118 * on HTTP error 117 119 */ 118 public static JSONArray getIndex(String resource, int page )120 public static JSONArray getIndex(String resource, int page, int pagesize) 119 121 throws Exception { 120 122 String pageN = ""; 121 123 if (page >= 0) 122 124 pageN = "&page=" + Integer.toString(page); 123 return executeQuery(getDepotUrl() + resource + ".json" + pageN, null); 125 String pagesizeN = ""; 126 if (pagesize >= 0) 127 pagesizeN = "&pagesize=" + Integer.toString(pagesize); 128 return executeQuery(getDepotUrl() + resource + ".json" + pageN 129 + pagesizeN, null); 124 130 } 125 131 -
AE/installer2/src/net/oni2/aeinstaller/backend/network/FileDownloader.java
r604 r605 212 212 213 213 i++; 214 if ((i % 10) == 0)214 if ((i % 50) == 0) 215 215 updateStatus(downloaded, fileLength); 216 216 } -
AE/installer2/src/net/oni2/aeinstaller/backend/unpack/Unpacker.java
r604 r605 117 117 try { 118 118 int pathStart = 0; 119 String pathStartName = ""; 119 120 120 121 ZipFile zf = new ZipFile(zip); … … 124 125 ZipEntry ze = e.nextElement(); 125 126 if (ze.getName().toLowerCase() 126 .endsWith("mod_info.cfg")) { 127 .endsWith("/mod_info.cfg") 128 || ze.getName().toLowerCase() 129 .equals("mod_info.cfg")) { 127 130 pathStart = ze.getName().toLowerCase() 128 131 .indexOf("mod_info.cfg"); 132 pathStartName = ze.getName().substring(0, 133 pathStart); 129 134 } 130 135 } … … 136 141 ZipEntry ze = e.nextElement(); 137 142 if (!ze.isDirectory()) { 138 File targetFile = new File(target, ze.getName() 139 .substring(pathStart)); 140 targetFile.getParentFile().mkdirs(); 143 if (ze.getName().startsWith(pathStartName)) { 144 File targetFile = new File(target, ze 145 .getName().substring(pathStart)); 146 File parent = targetFile.getParentFile(); 147 parent.mkdirs(); 141 148 142 InputStream in = zf.getInputStream(ze);149 InputStream in = zf.getInputStream(ze); 143 150 144 int read = 0; 145 byte[] data = new byte[1024]; 146 FileOutputStream fileOut = new FileOutputStream( 147 targetFile); 148 while ((read = in.read(data, 0, 1024)) != -1) { 149 fileOut.write(data, 0, read); 151 int read = 0; 152 byte[] data = new byte[1024]; 153 FileOutputStream fileOut = new FileOutputStream( 154 targetFile); 155 while ((read = in.read(data, 0, 1024)) != -1) { 156 fileOut.write(data, 0, read); 157 } 158 fileOut.close(); 150 159 } 151 fileOut.close();152 160 } 153 161 } -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.java
r604 r605 2 2 3 3 import java.io.File; 4 import java.io.IOException; 4 5 import java.util.ArrayList; 6 import java.util.HashMap; 7 import java.util.HashSet; 5 8 import java.util.List; 6 9 import java.util.ResourceBundle; 7 10 import java.util.TreeMap; 8 11 import java.util.TreeSet; 12 import java.util.Vector; 9 13 10 14 import javax.swing.JButton; … … 42 46 import net.oni2.aeinstaller.backend.oni.Installer; 43 47 import net.oni2.aeinstaller.gui.about.AboutDialog; 48 import net.oni2.aeinstaller.gui.downloadwindow.Downloader; 44 49 import net.oni2.aeinstaller.gui.modtable.DownloadSizeListener; 45 50 import net.oni2.aeinstaller.gui.modtable.ModTableFilter; … … 97 102 98 103 getRootPane().setDefaultButton(btnInstall); 104 lblDownloadSizeVal.setText(SizeFormatter.format(0, 2)); 99 105 } 100 106 … … 160 166 } 161 167 162 private boolean askClose() {163 int res = JOptionPane.showConfirmDialog(this,164 bundle.getString("askClose.text"),165 bundle.getString("askClose.title"), JOptionPane.YES_NO_OPTION,166 JOptionPane.QUESTION_MESSAGE);167 return res == JOptionPane.YES_OPTION;168 }169 170 168 private void exit() { 171 169 setVisible(false); … … 319 317 public void updateStatus(ModDownloader source, 320 318 State state, int filesDown, int filesTotal, 321 int bytesDown, int bytesTotal) { 319 int bytesDown, int bytesTotal, int duration, 320 int remaining, int speed) { 322 321 evt.setProgressEnd(filesTotal); 323 322 evt.setProgressValue(filesDown); … … 339 338 @DoInBackground(progressMessage = "installing.title", cancelable = false, indeterminateProgress = false) 340 339 private void install(final BackgroundEvent evt) { 341 // TODO: Conflicts/Dependencies342 343 340 TreeSet<Mod> mods = new TreeSet<Mod>(); 344 341 mods.addAll(ModManager.getInstance().getMandatoryMods()); 345 342 mods.addAll(model.getSelectedMods()); 346 343 347 System.out.println("Install mods:"); 348 for (Mod m : mods) { 349 System.out.println(" " + m.getPackageNumberString() + ": " 350 + m.getName()); 351 } 352 353 Installer.install(mods, new InstallProgressListener() { 354 @Override 355 public void installProgressUpdate(int done, int total, String step) { 356 evt.setProgressEnd(total); 357 evt.setProgressValue(done); 358 evt.setProgressMessage(step); 359 } 360 }); 344 boolean instReady = false; 345 346 while (!instReady) { 347 System.out.println("Checking downloads:"); 348 TreeSet<Mod> toDownload = new TreeSet<Mod>(); 349 for (Mod m : mods) { 350 if (!m.isLocalAvailable()) 351 toDownload.add(m); 352 } 353 if (toDownload.size() > 0) { 354 System.out.println("Download files: " + toDownload.toString()); 355 Downloader dl = new Downloader(toDownload); 356 dl.setVisible(true); 357 if (!dl.isFinished()) 358 break; 359 } 360 HashMap<Mod, HashSet<Mod>> dependencies = ModManager.getInstance() 361 .checkDependencies(mods); 362 if (dependencies.size() > 0) { 363 System.out.println("Unmet dependencies: " 364 + dependencies.toString()); 365 for (Mod m : dependencies.keySet()) { 366 for (Mod mDep : dependencies.get(m)) 367 mods.add(mDep); 368 } 369 } else { 370 HashMap<Mod, HashSet<Mod>> conflicts = ModManager.getInstance() 371 .checkConflicts(mods); 372 if (conflicts.size() > 0) { 373 System.err.println("Conflicting mods: " 374 + conflicts.toString()); 375 break; 376 } else { 377 instReady = true; 378 } 379 } 380 } 381 382 if (instReady) { 383 Installer.install(mods, new InstallProgressListener() { 384 @Override 385 public void installProgressUpdate(int done, int total, 386 String step) { 387 evt.setProgressEnd(total); 388 evt.setProgressValue(done); 389 evt.setProgressMessage(step); 390 } 391 }); 392 } 393 394 JOptionPane.showMessageDialog(this, 395 bundle.getString("installDone.text"), 396 bundle.getString("installDone.title"), 397 JOptionPane.INFORMATION_MESSAGE); 361 398 } 362 399 … … 409 446 } 410 447 } 448 449 private Vector<String> getBasicOniLaunchParams() { 450 Vector<String> params = new Vector<String>(); 451 switch (Settings.getPlatform()) { 452 case WIN: 453 params.add(new File(Paths.getEditionBasePath(), "Oni.exe") 454 .getPath()); 455 break; 456 case MACOS: 457 params.add(new File(Paths.getEditionBasePath(), "Oni") 458 .getPath()); 459 break; 460 case LINUX: 461 String wine = Settings.getWinePath(); 462 if (wine != null) { 463 params.add(wine); 464 params.add(new File(Paths.getEditionBasePath(), "Oni.exe") 465 .getPath()); 466 } 467 break; 468 default: 469 } 470 if (params.size() > 0) { 471 params.add("-debugfiles"); 472 } 473 return params; 474 } 475 476 @SuppressWarnings("unused") 477 private void oniFull() { 478 Vector<String> params = getBasicOniLaunchParams(); 479 if (params.size() > 0) { 480 try { 481 new ProcessBuilder(params).start(); 482 } catch (IOException e) { 483 // TODO Auto-generated catch block 484 e.printStackTrace(); 485 } 486 } 487 } 488 489 @SuppressWarnings("unused") 490 private void oniWin() { 491 Vector<String> params = getBasicOniLaunchParams(); 492 if (params.size() > 0) { 493 params.add("-noswitch"); 494 try { 495 new ProcessBuilder(params).start(); 496 } catch (IOException e) { 497 // TODO Auto-generated catch block 498 e.printStackTrace(); 499 } 500 } 501 } 411 502 412 503 @Override … … 435 526 @Override 436 527 public void handleQuit(ApplicationEvent event) { 437 if (askClose()) { 438 event.setHandled(true); 439 saveLocalData(); 440 exit(); 441 } else { 442 event.setHandled(false); 443 } 528 event.setHandled(true); 529 saveLocalData(); 530 exit(); 444 531 } 445 532 -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.properties
r604 r605 11 11 12 12 menu.file=&File 13 menu.runOniFull=Run &Oni (fullscreen) 14 menu.runOniFullTooltip=Run Oni in fullscreen mode 15 menu.runOniWin=Run Oni (&window) 16 menu.runOniWinTooltip=Run Oni in windowed mode 13 17 menu.loadConfig=&Load configuration... 14 18 menu.loadConfigTooltip=Load configuration … … 35 39 updateDepot.title=Updating Mod Depot cache 36 40 41 installDone.title=Installation done 42 installDone.text=You can now play AE Oni. 43 37 44 updatesAvailable.title=Updates available 38 45 updatesAvailable.text=Some mods have newer versions available. 39 40 askClose.title=Confirm close request41 askClose.text=Are you sure you want to close the program?42 46 43 47 askInitialize.title=Initialize Edition -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.yml
r603 r605 7 7 defaultCloseOperation: doNothingOnClose 8 8 onWindowOpened: [execDepotUpdate,checkMandatoryFiles,initialize,checkUpdates,focus] 9 onWindowClosing: [ askClose,saveLocalData,exit]9 onWindowClosing: [saveLocalData,exit] 10 10 iconImage: img.ae 11 11 content: 12 - Action(name=exitAction, text=menu.exit, toolTipText=menu.exitTooltip, icon=img.exit, onAction=[ askClose,saveLocalData,exit])12 - Action(name=exitAction, text=menu.exit, toolTipText=menu.exitTooltip, icon=img.exit, onAction=[saveLocalData,exit]) 13 13 - Action(name=settings, text=menu.settings, toolTipText=menu.settingsTooltip, icon=img.settings, onAction=[showSettings]) 14 14 - Action(name=about, text=menu.about, toolTipText=menu.aboutTooltip, icon=img.about, onAction=[showAbout]) 15 - Action(name=runOniFull, text=menu.runOniFull, toolTipText=menu.runOniFullTooltip, icon=img.oni, onAction=[oniFull]) 16 - Action(name=runOniWin, text=menu.runOniWin, toolTipText=menu.runOniWinTooltip, icon=img.oni, onAction=[oniWin]) 15 17 - Action(name=loadConfig, text=menu.loadConfig, toolTipText=menu.loadConfigTooltip, icon=img.openFile, onAction=[loadConfig]) 16 18 - Action(name=saveConfig, text=menu.saveConfig, toolTipText=menu.saveConfigTooltip, icon=img.saveFile, onAction=[saveConfig]) … … 23 25 - JMenuItem(action=exitAction) 24 26 - JMenu(name=fileMenu, text=menu.file): 27 - JMenuItem(action=runOniFull) 28 - JMenuItem(action=runOniWin) 29 - JSeparator() 25 30 - JMenuItem(action=loadConfig) 26 31 - JMenuItem(action=saveConfig) -
AE/installer2/src/net/oni2/aeinstaller/gui/modtable/ModTableModel.java
r604 r605 217 217 if (install.get(i)) { 218 218 Mod m = items.get(i); 219 if (!m.isLocalAvailable() || m.isNewerAvailable())219 if (!m.isLocalAvailable()) 220 220 size += m.getZipSize(); 221 221 }
Note:
See TracChangeset
for help on using the changeset viewer.