Changeset 605 for AE/installer2/src/net/oni2/aeinstaller/gui
- Timestamp:
- Jan 13, 2013, 8:11:07 PM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller/gui
- Files:
-
- 4 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
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.