[591] | 1 | package net.oni2.aeinstaller.gui;
|
---|
| 2 |
|
---|
[627] | 3 | import java.awt.BorderLayout;
|
---|
[608] | 4 | import java.awt.Desktop;
|
---|
[632] | 5 | import java.awt.GridLayout;
|
---|
[608] | 6 | import java.awt.event.ActionEvent;
|
---|
[627] | 7 | import java.awt.event.ItemEvent;
|
---|
| 8 | import java.awt.event.ItemListener;
|
---|
[660] | 9 | import java.awt.event.KeyAdapter;
|
---|
| 10 | import java.awt.event.KeyEvent;
|
---|
[604] | 11 | import java.io.File;
|
---|
[623] | 12 | import java.net.URL;
|
---|
[634] | 13 | import java.util.Date;
|
---|
[605] | 14 | import java.util.HashMap;
|
---|
| 15 | import java.util.HashSet;
|
---|
[591] | 16 | import java.util.ResourceBundle;
|
---|
| 17 | import java.util.TreeMap;
|
---|
[600] | 18 | import java.util.TreeSet;
|
---|
[605] | 19 | import java.util.Vector;
|
---|
[591] | 20 |
|
---|
[623] | 21 | import javax.swing.AbstractAction;
|
---|
| 22 | import javax.swing.ImageIcon;
|
---|
[600] | 23 | import javax.swing.JButton;
|
---|
[627] | 24 | import javax.swing.JCheckBox;
|
---|
[591] | 25 | import javax.swing.JComboBox;
|
---|
[604] | 26 | import javax.swing.JFileChooser;
|
---|
[591] | 27 | import javax.swing.JFrame;
|
---|
[592] | 28 | import javax.swing.JLabel;
|
---|
[593] | 29 | import javax.swing.JMenu;
|
---|
[608] | 30 | import javax.swing.JMenuItem;
|
---|
[593] | 31 | import javax.swing.JOptionPane;
|
---|
[627] | 32 | import javax.swing.JPanel;
|
---|
[630] | 33 | import javax.swing.JRadioButton;
|
---|
[658] | 34 | import javax.swing.JScrollPane;
|
---|
[592] | 35 | import javax.swing.JSplitPane;
|
---|
[660] | 36 | import javax.swing.JTextField;
|
---|
[591] | 37 | import javax.swing.SwingUtilities;
|
---|
[631] | 38 | import javax.swing.ToolTipManager;
|
---|
[604] | 39 | import javax.swing.filechooser.FileFilter;
|
---|
[591] | 40 |
|
---|
[623] | 41 | import net.oni2.aeinstaller.AEInstaller2;
|
---|
[671] | 42 | import net.oni2.aeinstaller.backend.ImageResizer;
|
---|
[604] | 43 | import net.oni2.aeinstaller.backend.Paths;
|
---|
[591] | 44 | import net.oni2.aeinstaller.backend.Settings;
|
---|
[672] | 45 | import net.oni2.aeinstaller.backend.ToolLauncher;
|
---|
[593] | 46 | import net.oni2.aeinstaller.backend.Settings.Platform;
|
---|
[600] | 47 | import net.oni2.aeinstaller.backend.SizeFormatter;
|
---|
[702] | 48 | import net.oni2.aeinstaller.backend.appexecution.AppExecution;
|
---|
[591] | 49 | import net.oni2.aeinstaller.backend.depot.DepotManager;
|
---|
[658] | 50 | import net.oni2.aeinstaller.backend.oni.InstallProgressListener;
|
---|
| 51 | import net.oni2.aeinstaller.backend.oni.Installer;
|
---|
| 52 | import net.oni2.aeinstaller.backend.oni.OniSplit;
|
---|
[648] | 53 | import net.oni2.aeinstaller.backend.packages.Package;
|
---|
| 54 | import net.oni2.aeinstaller.backend.packages.PackageManager;
|
---|
| 55 | import net.oni2.aeinstaller.backend.packages.Type;
|
---|
| 56 | import net.oni2.aeinstaller.backend.packages.download.ModDownloader;
|
---|
[658] | 57 | import net.oni2.aeinstaller.backend.packages.download.ModDownloader.State;
|
---|
[648] | 58 | import net.oni2.aeinstaller.backend.packages.download.ModDownloaderListener;
|
---|
[593] | 59 | import net.oni2.aeinstaller.gui.about.AboutDialog;
|
---|
[648] | 60 | import net.oni2.aeinstaller.gui.corepackages.CorePackagesDialog;
|
---|
[605] | 61 | import net.oni2.aeinstaller.gui.downloadwindow.Downloader;
|
---|
[673] | 62 | import net.oni2.aeinstaller.gui.modtable.ModInstallSelectionListener;
|
---|
[660] | 63 | import net.oni2.aeinstaller.gui.modtable.EApplyFilterTo;
|
---|
[631] | 64 | import net.oni2.aeinstaller.gui.modtable.ModSelectionListener;
|
---|
| 65 | import net.oni2.aeinstaller.gui.modtable.ModTable;
|
---|
[658] | 66 | import net.oni2.aeinstaller.gui.modtable.ModTable.ETableContentType;
|
---|
| 67 | import net.oni2.aeinstaller.gui.packageinfobox.PackageInfoBox;
|
---|
[591] | 68 | import net.oni2.aeinstaller.gui.settings.SettingsDialog;
|
---|
[625] | 69 | import net.oni2.aeinstaller.gui.toolmanager.ToolManager;
|
---|
[591] | 70 |
|
---|
| 71 | import org.javabuilders.BuildResult;
|
---|
| 72 | import org.javabuilders.annotations.DoInBackground;
|
---|
| 73 | import org.javabuilders.event.BackgroundEvent;
|
---|
| 74 | import org.javabuilders.swing.SwingJavaBuilder;
|
---|
[593] | 75 | import org.simplericity.macify.eawt.ApplicationEvent;
|
---|
| 76 | import org.simplericity.macify.eawt.ApplicationListener;
|
---|
[591] | 77 |
|
---|
| 78 | /**
|
---|
| 79 | * @author Christian Illy
|
---|
| 80 | */
|
---|
[600] | 81 | public class MainWin extends JFrame implements ApplicationListener,
|
---|
[673] | 82 | ModInstallSelectionListener, ModSelectionListener {
|
---|
[591] | 83 | private static final long serialVersionUID = -4027395051382659650L;
|
---|
| 84 |
|
---|
[629] | 85 | private ResourceBundle bundle = ResourceBundle
|
---|
| 86 | .getBundle("net.oni2.aeinstaller.localization."
|
---|
| 87 | + getClass().getSimpleName());
|
---|
[591] | 88 | @SuppressWarnings("unused")
|
---|
| 89 | private BuildResult result = SwingJavaBuilder.build(this, bundle);
|
---|
| 90 |
|
---|
[593] | 91 | private JMenu mainMenu;
|
---|
[623] | 92 | private JMenu toolsMenu;
|
---|
[641] | 93 | private Vector<JMenuItem> toolsMenuItems = new Vector<JMenuItem>();
|
---|
[593] | 94 |
|
---|
[592] | 95 | private JSplitPane contents;
|
---|
| 96 |
|
---|
[591] | 97 | private JComboBox cmbModTypes;
|
---|
[630] | 98 | private JRadioButton radAll;
|
---|
| 99 | private JRadioButton radOnline;
|
---|
| 100 | private JRadioButton radLocal;
|
---|
[660] | 101 | private JTextField txtShowFilter;
|
---|
| 102 | private JComboBox cmbShowFilterTo;
|
---|
[658] | 103 | private JScrollPane scrollMods;
|
---|
[631] | 104 | private ModTable tblMods;
|
---|
[673] | 105 | private JLabel lblSelectedModsVal;
|
---|
[600] | 106 | private JLabel lblDownloadSizeVal;
|
---|
[591] | 107 |
|
---|
[658] | 108 | private PackageInfoBox pkgInfo;
|
---|
[660] | 109 |
|
---|
[600] | 110 | private JButton btnInstall;
|
---|
| 111 |
|
---|
[648] | 112 | private TreeSet<Package> execCoreUpdates = new TreeSet<Package>();
|
---|
| 113 | private TreeSet<Package> execUpdates = null;
|
---|
[621] | 114 |
|
---|
[641] | 115 | private enum EInstallState {
|
---|
[621] | 116 | DONE,
|
---|
[641] | 117 | READY,
|
---|
| 118 | ABORTED,
|
---|
[621] | 119 | OFFLINE,
|
---|
[641] | 120 | INCOMPATIBLE,
|
---|
| 121 | CHECKING
|
---|
[621] | 122 | };
|
---|
| 123 |
|
---|
[641] | 124 | private EInstallState installState = EInstallState.DONE;
|
---|
[648] | 125 | private TreeSet<Package> installMods = null;
|
---|
| 126 | private TreeSet<Package> installDeps = null;
|
---|
[621] | 127 |
|
---|
[591] | 128 | /**
|
---|
| 129 | * Constructor of main window.
|
---|
| 130 | */
|
---|
| 131 | public MainWin() {
|
---|
[593] | 132 | this.setTitle(SwingJavaBuilder.getConfig().getResource("appname")
|
---|
| 133 | + " - v"
|
---|
| 134 | + SwingJavaBuilder.getConfig().getResource("appversion"));
|
---|
[591] | 135 |
|
---|
[658] | 136 | tblMods = new ModTable(ETableContentType.MODS);
|
---|
| 137 | tblMods.setVisible(false);
|
---|
| 138 | scrollMods.setViewportView(tblMods);
|
---|
| 139 |
|
---|
[701] | 140 | contents.setDividerLocation(Settings.getInstance().get("win_main_divloc", 550));
|
---|
[631] | 141 | contents.setResizeWeight(0.4);
|
---|
[593] | 142 |
|
---|
| 143 | if (Settings.getPlatform() == Platform.MACOS) {
|
---|
| 144 | mainMenu.setVisible(false);
|
---|
| 145 | }
|
---|
[600] | 146 |
|
---|
[631] | 147 | ToolTipManager.sharedInstance().setInitialDelay(250);
|
---|
| 148 |
|
---|
[600] | 149 | getRootPane().setDefaultButton(btnInstall);
|
---|
[673] | 150 | lblSelectedModsVal.setText("0");
|
---|
[605] | 151 | lblDownloadSizeVal.setText(SizeFormatter.format(0, 2));
|
---|
[630] | 152 | radAll.setSelected(true);
|
---|
[631] | 153 |
|
---|
[660] | 154 | for (EApplyFilterTo f : EApplyFilterTo.values()) {
|
---|
| 155 | cmbShowFilterTo.addItem(f);
|
---|
| 156 | }
|
---|
| 157 | txtShowFilter.addKeyListener(new KeyAdapter() {
|
---|
| 158 | @Override
|
---|
| 159 | public void keyReleased(KeyEvent e) {
|
---|
| 160 | super.keyReleased(e);
|
---|
| 161 | updateTableFilter();
|
---|
| 162 | }
|
---|
| 163 | });
|
---|
| 164 |
|
---|
[631] | 165 | tblMods.addModSelectionListener(this);
|
---|
| 166 | tblMods.addDownloadSizeListener(this);
|
---|
[701] | 167 |
|
---|
| 168 | setSize(Settings.getInstance().get("win_main_width", 950), Settings.getInstance().get("win_main_height", 600));
|
---|
| 169 | setLocationRelativeTo(null);
|
---|
[591] | 170 | }
|
---|
| 171 |
|
---|
| 172 | private void initModTypeBox() {
|
---|
[592] | 173 | cmbModTypes.removeAllItems();
|
---|
| 174 |
|
---|
[600] | 175 | TreeMap<String, Type> types = new TreeMap<String, Type>();
|
---|
[648] | 176 | for (Type t : PackageManager.getInstance().getTypesWithContent()) {
|
---|
[600] | 177 | types.put(t.getName(), t);
|
---|
[591] | 178 | }
|
---|
[630] | 179 | cmbModTypes.addItem("-All-");
|
---|
[600] | 180 | for (Type t : types.values()) {
|
---|
[591] | 181 | cmbModTypes.addItem(t);
|
---|
| 182 | }
|
---|
| 183 | cmbModTypes.setSelectedIndex(0);
|
---|
| 184 | }
|
---|
| 185 |
|
---|
| 186 | private void exit() {
|
---|
| 187 | dispose();
|
---|
[608] | 188 | System.exit(0);
|
---|
[591] | 189 | }
|
---|
| 190 |
|
---|
| 191 | private void saveLocalData() {
|
---|
[701] | 192 | Settings.getInstance().put("win_main_divloc", contents.getDividerLocation());
|
---|
| 193 | Settings.getInstance().put("win_main_width", getWidth());
|
---|
| 194 | Settings.getInstance().put("win_main_height", getHeight());
|
---|
[591] | 195 | Settings.getInstance().serializeToFile();
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 | @DoInBackground(progressMessage = "updateDepot.title", cancelable = false, indeterminateProgress = false)
|
---|
| 199 | private void execDepotUpdate(final BackgroundEvent evt) {
|
---|
[657] | 200 | if (!Settings.getInstance().isOfflineMode()
|
---|
| 201 | && !Settings.getInstance().isNoCacheUpdateMode()) {
|
---|
[634] | 202 | long start = new Date().getTime();
|
---|
| 203 |
|
---|
[621] | 204 | try {
|
---|
[662] | 205 | DepotManager.getInstance().updateInformation();
|
---|
[621] | 206 | } catch (Exception e) {
|
---|
| 207 | e.printStackTrace();
|
---|
| 208 | }
|
---|
[634] | 209 |
|
---|
| 210 | System.out.println("Took: " + (new Date().getTime() - start)
|
---|
| 211 | + " msec");
|
---|
[621] | 212 | }
|
---|
[633] | 213 |
|
---|
[648] | 214 | PackageManager.getInstance().init();
|
---|
[631] | 215 | tblMods.reloadData();
|
---|
[621] | 216 | initModTypeBox();
|
---|
[600] | 217 |
|
---|
[621] | 218 | tblMods.setVisible(true);
|
---|
| 219 | }
|
---|
| 220 |
|
---|
| 221 | @SuppressWarnings("unused")
|
---|
| 222 | private void checkUpdates(Object evtSource) {
|
---|
| 223 | if ((evtSource != this)
|
---|
| 224 | || Settings.getInstance().get("notifyupdates", true)) {
|
---|
| 225 | if (Settings.getInstance().isOfflineMode()) {
|
---|
| 226 | if (evtSource != this) {
|
---|
[657] | 227 | JOptionPane.showMessageDialog(
|
---|
| 228 | this,
|
---|
| 229 | SwingJavaBuilder.getConfig().getResource(
|
---|
| 230 | "offlineMode.text"),
|
---|
| 231 | SwingJavaBuilder.getConfig().getResource(
|
---|
| 232 | "offlineMode.title"),
|
---|
[621] | 233 | JOptionPane.WARNING_MESSAGE);
|
---|
| 234 | }
|
---|
| 235 | } else {
|
---|
[657] | 236 | TreeSet<Package> mods = PackageManager.getInstance()
|
---|
| 237 | .getUpdatableMods();
|
---|
[648] | 238 | TreeSet<Package> tools = PackageManager.getInstance()
|
---|
[621] | 239 | .getUpdatableTools();
|
---|
[632] | 240 | JPanel panPackages = new JPanel(new GridLayout(0, 1));
|
---|
[648] | 241 | execUpdates = new TreeSet<Package>();
|
---|
[632] | 242 | execUpdates.addAll(mods);
|
---|
| 243 | execUpdates.addAll(tools);
|
---|
[672] | 244 | final JLabel lblSize = new JLabel("<html>"
|
---|
| 245 | + String.format(
|
---|
| 246 | bundle.getString("updatesAvailableSize.text"),
|
---|
| 247 | SizeFormatter.format(0, 3)) + "</html>");
|
---|
| 248 | int size = 0;
|
---|
[648] | 249 | for (final Package m : mods) {
|
---|
[621] | 250 | size += m.getZipSize();
|
---|
[672] | 251 | JCheckBox check = new JCheckBox("Mod: " + m.getName()
|
---|
[698] | 252 | + " (" + SizeFormatter.format(m.getZipSize(), 1) + ")");
|
---|
[632] | 253 | check.setSelected(true);
|
---|
| 254 | check.addItemListener(new ItemListener() {
|
---|
| 255 | @Override
|
---|
| 256 | public void itemStateChanged(ItemEvent e) {
|
---|
| 257 | if (e.getStateChange() == ItemEvent.SELECTED)
|
---|
| 258 | execUpdates.add(m);
|
---|
| 259 | else
|
---|
| 260 | execUpdates.remove(m);
|
---|
[672] | 261 | int s = 0;
|
---|
| 262 | for (Package p : execUpdates)
|
---|
| 263 | s += p.getZipSize();
|
---|
| 264 | lblSize.setText("<html>"
|
---|
| 265 | + String.format(
|
---|
| 266 | bundle.getString("updatesAvailableSize.text"),
|
---|
| 267 | SizeFormatter.format(s, 3))
|
---|
| 268 | + "</html>");
|
---|
[632] | 269 | }
|
---|
| 270 | });
|
---|
| 271 | panPackages.add(check);
|
---|
[621] | 272 | }
|
---|
[648] | 273 | for (final Package m : tools) {
|
---|
[621] | 274 | size += m.getZipSize();
|
---|
[672] | 275 | JCheckBox check = new JCheckBox("Tool: " + m.getName()
|
---|
[698] | 276 | + " (" + SizeFormatter.format(m.getZipSize(), 1) + ")");
|
---|
[632] | 277 | check.setSelected(true);
|
---|
[672] | 278 | check.addItemListener(new ItemListener() {
|
---|
| 279 | @Override
|
---|
| 280 | public void itemStateChanged(ItemEvent e) {
|
---|
| 281 | if (e.getStateChange() == ItemEvent.SELECTED)
|
---|
| 282 | execUpdates.add(m);
|
---|
| 283 | else
|
---|
| 284 | execUpdates.remove(m);
|
---|
| 285 | int s = 0;
|
---|
| 286 | for (Package p : execUpdates)
|
---|
| 287 | s += p.getZipSize();
|
---|
| 288 | lblSize.setText("<html>"
|
---|
| 289 | + String.format(
|
---|
| 290 | bundle.getString("updatesAvailableSize.text"),
|
---|
| 291 | SizeFormatter.format(s, 3))
|
---|
| 292 | + "</html>");
|
---|
| 293 | }
|
---|
| 294 | });
|
---|
[632] | 295 | panPackages.add(check);
|
---|
[621] | 296 | }
|
---|
[672] | 297 | lblSize.setText("<html>"
|
---|
| 298 | + String.format(
|
---|
| 299 | bundle.getString("updatesAvailableSize.text"),
|
---|
| 300 | SizeFormatter.format(size, 3)) + "</html>");
|
---|
[622] | 301 | if (size > 0) {
|
---|
[627] | 302 | // Build info dialog content
|
---|
[632] | 303 | JPanel packages = new JPanel(new BorderLayout(0, 7));
|
---|
| 304 | JLabel lblIntro = new JLabel("<html>"
|
---|
| 305 | + bundle.getString("updatesAvailable.text")
|
---|
| 306 | + "</html>");
|
---|
| 307 | packages.add(lblIntro, BorderLayout.NORTH);
|
---|
| 308 | packages.add(panPackages, BorderLayout.CENTER);
|
---|
| 309 | packages.add(lblSize, BorderLayout.SOUTH);
|
---|
[627] | 310 |
|
---|
[632] | 311 | JPanel pan = new JPanel(new BorderLayout(0, 25));
|
---|
| 312 | pan.add(packages, BorderLayout.CENTER);
|
---|
[627] | 313 | JCheckBox checkFutureUpdates = new JCheckBox(
|
---|
| 314 | bundle.getString("checkOnStartup.text"));
|
---|
| 315 | checkFutureUpdates.setSelected(Settings.getInstance().get(
|
---|
| 316 | "notifyupdates", true));
|
---|
| 317 | checkFutureUpdates.addItemListener(new ItemListener() {
|
---|
| 318 | @Override
|
---|
| 319 | public void itemStateChanged(ItemEvent evt) {
|
---|
| 320 | Settings.getInstance().put("notifyupdates",
|
---|
| 321 | evt.getStateChange() == ItemEvent.SELECTED);
|
---|
| 322 | }
|
---|
| 323 | });
|
---|
| 324 | pan.add(checkFutureUpdates, BorderLayout.SOUTH);
|
---|
| 325 |
|
---|
| 326 | // Show dialog
|
---|
| 327 | int res = JOptionPane.showConfirmDialog(this, pan,
|
---|
[622] | 328 | bundle.getString("updatesAvailable.title"),
|
---|
| 329 | JOptionPane.YES_NO_OPTION,
|
---|
| 330 | JOptionPane.QUESTION_MESSAGE);
|
---|
[632] | 331 | if (res == JOptionPane.NO_OPTION) {
|
---|
| 332 | execUpdates = null;
|
---|
[622] | 333 | }
|
---|
[656] | 334 | } else {
|
---|
| 335 | if (evtSource != this) {
|
---|
| 336 | JOptionPane.showMessageDialog(this,
|
---|
| 337 | bundle.getString("updatesNotAvailable.text"),
|
---|
| 338 | bundle.getString("updatesNotAvailable.title"),
|
---|
| 339 | JOptionPane.INFORMATION_MESSAGE);
|
---|
| 340 | }
|
---|
[621] | 341 | }
|
---|
| 342 | }
|
---|
[591] | 343 | }
|
---|
| 344 | }
|
---|
| 345 |
|
---|
[624] | 346 | @SuppressWarnings("unused")
|
---|
| 347 | private void doUpdate() {
|
---|
[632] | 348 | if (execUpdates != null && execUpdates.size() > 0) {
|
---|
[646] | 349 | Downloader dl = new Downloader(execUpdates, null);
|
---|
[624] | 350 | try {
|
---|
| 351 | dl.setVisible(true);
|
---|
| 352 | if (dl.isFinished()) {
|
---|
| 353 | TreeSet<Integer> installed = Installer.getInstalledTools();
|
---|
[648] | 354 | TreeSet<Package> tools = new TreeSet<Package>();
|
---|
| 355 | for (Package m : execUpdates)
|
---|
[624] | 356 | if (m.isTool()
|
---|
| 357 | && installed.contains(m.getPackageNumber()))
|
---|
| 358 | tools.add(m);
|
---|
| 359 | if (tools.size() > 0) {
|
---|
[699] | 360 | Installer.installTools(tools, false);
|
---|
[624] | 361 | }
|
---|
| 362 | }
|
---|
| 363 | } finally {
|
---|
| 364 | dl.dispose();
|
---|
| 365 | }
|
---|
[591] | 366 | }
|
---|
[621] | 367 | execUpdates = null;
|
---|
[591] | 368 | }
|
---|
| 369 |
|
---|
| 370 | @SuppressWarnings("unused")
|
---|
| 371 | private void focus() {
|
---|
| 372 | SwingUtilities.invokeLater(new Runnable() {
|
---|
| 373 |
|
---|
| 374 | @Override
|
---|
| 375 | public void run() {
|
---|
| 376 | toFront();
|
---|
| 377 | repaint();
|
---|
| 378 | }
|
---|
| 379 | });
|
---|
| 380 |
|
---|
| 381 | }
|
---|
[646] | 382 |
|
---|
[645] | 383 | @SuppressWarnings("unused")
|
---|
[648] | 384 | private void showCorePackagesDialog() {
|
---|
| 385 | new CorePackagesDialog().setVisible(true);
|
---|
[645] | 386 | }
|
---|
[591] | 387 |
|
---|
| 388 | private void showSettings() {
|
---|
[593] | 389 | new SettingsDialog().setVisible(true);
|
---|
[591] | 390 | }
|
---|
| 391 |
|
---|
[593] | 392 | private void showAbout() {
|
---|
| 393 | new AboutDialog().setVisible(true);
|
---|
| 394 | }
|
---|
| 395 |
|
---|
[604] | 396 | private JFileChooser getConfigOpenSaveDialog(boolean save) {
|
---|
| 397 | JFileChooser fc = new JFileChooser();
|
---|
| 398 | fc.setCurrentDirectory(Paths.getEditionBasePath());
|
---|
| 399 | if (save)
|
---|
| 400 | fc.setDialogType(JFileChooser.SAVE_DIALOG);
|
---|
| 401 | else
|
---|
| 402 | fc.setDialogType(JFileChooser.OPEN_DIALOG);
|
---|
| 403 | fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
---|
| 404 | fc.setFileFilter(new FileFilter() {
|
---|
| 405 | @Override
|
---|
| 406 | public String getDescription() {
|
---|
| 407 | return "XML files";
|
---|
| 408 | }
|
---|
| 409 |
|
---|
| 410 | @Override
|
---|
| 411 | public boolean accept(File arg0) {
|
---|
| 412 | return (arg0.isDirectory())
|
---|
| 413 | || (arg0.getName().toLowerCase().endsWith(".xml"));
|
---|
| 414 | }
|
---|
| 415 | });
|
---|
| 416 | fc.setMultiSelectionEnabled(false);
|
---|
| 417 | return fc;
|
---|
| 418 | }
|
---|
| 419 |
|
---|
[593] | 420 | @SuppressWarnings("unused")
|
---|
| 421 | private void loadConfig() {
|
---|
[604] | 422 | JFileChooser fc = getConfigOpenSaveDialog(false);
|
---|
| 423 | int res = fc.showOpenDialog(this);
|
---|
| 424 | if (res == JFileChooser.APPROVE_OPTION) {
|
---|
| 425 | if (fc.getSelectedFile().exists())
|
---|
[631] | 426 | tblMods.reloadSelection(fc.getSelectedFile());
|
---|
[604] | 427 | }
|
---|
[593] | 428 | }
|
---|
| 429 |
|
---|
| 430 | @SuppressWarnings("unused")
|
---|
| 431 | private void saveConfig() {
|
---|
[604] | 432 | JFileChooser fc = getConfigOpenSaveDialog(true);
|
---|
| 433 | int res = fc.showSaveDialog(this);
|
---|
| 434 | if (res == JFileChooser.APPROVE_OPTION) {
|
---|
| 435 | File f = fc.getSelectedFile();
|
---|
| 436 | if (!f.getName().endsWith(".xml"))
|
---|
| 437 | f = new File(f.getParentFile(), f.getName() + ".xml");
|
---|
[648] | 438 | PackageManager.getInstance().saveModSelection(f,
|
---|
[631] | 439 | tblMods.getSelectedMods());
|
---|
[604] | 440 | }
|
---|
[593] | 441 | }
|
---|
| 442 |
|
---|
[661] | 443 | @SuppressWarnings("unused")
|
---|
| 444 | private boolean reglobalizeVerify() {
|
---|
| 445 | int res = JOptionPane.showConfirmDialog(this,
|
---|
| 446 | bundle.getString("rebuildCore.text"),
|
---|
| 447 | bundle.getString("rebuildCore.title"),
|
---|
| 448 | JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
---|
| 449 | return res == JOptionPane.YES_OPTION;
|
---|
| 450 | }
|
---|
| 451 |
|
---|
[600] | 452 | @DoInBackground(progressMessage = "initializingEdition.title", cancelable = false, indeterminateProgress = false)
|
---|
| 453 | private void reglobalize(final BackgroundEvent evt) {
|
---|
| 454 | Installer.initializeEdition(new InstallProgressListener() {
|
---|
| 455 | @Override
|
---|
| 456 | public void installProgressUpdate(int done, int total, String step) {
|
---|
| 457 | evt.setProgressEnd(total);
|
---|
| 458 | evt.setProgressValue(done);
|
---|
| 459 | evt.setProgressMessage(step);
|
---|
| 460 | }
|
---|
| 461 | });
|
---|
| 462 | }
|
---|
| 463 |
|
---|
[593] | 464 | @SuppressWarnings("unused")
|
---|
[600] | 465 | private void tools() {
|
---|
[625] | 466 | new ToolManager().setVisible(true);
|
---|
[593] | 467 | }
|
---|
[596] | 468 |
|
---|
[593] | 469 | @SuppressWarnings("unused")
|
---|
[623] | 470 | private void refreshToolsMenu() {
|
---|
| 471 | for (JMenuItem i : toolsMenuItems) {
|
---|
| 472 | toolsMenu.remove(i);
|
---|
| 473 | }
|
---|
| 474 | toolsMenuItems.clear();
|
---|
[672] | 475 | for (final Package m : PackageManager.getInstance().getInstalledTools()) {
|
---|
[640] | 476 | File exe = m.getExeFile();
|
---|
| 477 | if (exe != null && exe.exists()) {
|
---|
[623] | 478 | JMenuItem item = new JMenuItem();
|
---|
[671] | 479 | ImageIcon ico = null;
|
---|
[623] | 480 | if (m.getIconFile() != null && m.getIconFile().exists()) {
|
---|
| 481 | ico = new ImageIcon(m.getIconFile().getPath());
|
---|
| 482 | } else {
|
---|
[624] | 483 | URL icon = AEInstaller2.class
|
---|
| 484 | .getResource("images/transparent.png");
|
---|
[623] | 485 | ico = new ImageIcon(icon);
|
---|
| 486 | }
|
---|
[671] | 487 | ico = ImageResizer.resizeImage(ico, 32, 32);
|
---|
[623] | 488 | item.setAction(new AbstractAction(m.getName(), ico) {
|
---|
| 489 | private static final long serialVersionUID = 1L;
|
---|
| 490 |
|
---|
| 491 | @Override
|
---|
[672] | 492 | public void actionPerformed(ActionEvent evt) {
|
---|
| 493 | try {
|
---|
| 494 | ToolLauncher.launch(m);
|
---|
| 495 | } catch (Exception ex) {
|
---|
| 496 | if (ex.getMessage().contains("JRE"))
|
---|
| 497 | JOptionPane.showMessageDialog(null,
|
---|
| 498 | bundle.getString("jreNotFound.text"),
|
---|
| 499 | bundle.getString("jreNotFound.title"),
|
---|
| 500 | JOptionPane.ERROR_MESSAGE);
|
---|
| 501 | if (ex.getMessage().contains(".NET"))
|
---|
[673] | 502 | JOptionPane.showMessageDialog(
|
---|
| 503 | null,
|
---|
[672] | 504 | bundle.getString("dotNetNotFound.text"),
|
---|
| 505 | bundle.getString("dotNetNotFound.title"),
|
---|
| 506 | JOptionPane.ERROR_MESSAGE);
|
---|
| 507 | }
|
---|
[623] | 508 | }
|
---|
| 509 | });
|
---|
| 510 | toolsMenuItems.add(item);
|
---|
| 511 | toolsMenu.add(item);
|
---|
| 512 | }
|
---|
| 513 | }
|
---|
| 514 | }
|
---|
| 515 |
|
---|
[593] | 516 | private void revertSelection() {
|
---|
[631] | 517 | tblMods.revertSelection();
|
---|
[593] | 518 | }
|
---|
[658] | 519 |
|
---|
[657] | 520 | @SuppressWarnings("unused")
|
---|
| 521 | private void unSelectAll() {
|
---|
| 522 | tblMods.unSelectAll();
|
---|
| 523 | }
|
---|
[593] | 524 |
|
---|
[648] | 525 | @DoInBackground(progressMessage = "checkCorePackages.title", cancelable = false, indeterminateProgress = false)
|
---|
| 526 | private void checkCorePackages(final BackgroundEvent evt) {
|
---|
[621] | 527 | if (!Settings.getInstance().isOfflineMode()) {
|
---|
[648] | 528 | for (Package m : PackageManager.getInstance().getCoreTools()) {
|
---|
[621] | 529 | if (m.isNewerAvailable()) {
|
---|
[648] | 530 | execCoreUpdates.add(m);
|
---|
[621] | 531 | }
|
---|
[604] | 532 | }
|
---|
[648] | 533 | for (Package m : PackageManager.getInstance().getCoreMods()) {
|
---|
[621] | 534 | if (m.isNewerAvailable()) {
|
---|
[648] | 535 | execCoreUpdates.add(m);
|
---|
[621] | 536 | }
|
---|
[604] | 537 | }
|
---|
[648] | 538 | if (execCoreUpdates.size() > 0) {
|
---|
| 539 | ModDownloader m = new ModDownloader(execCoreUpdates,
|
---|
[621] | 540 | new ModDownloaderListener() {
|
---|
| 541 | @Override
|
---|
| 542 | public void updateStatus(ModDownloader source,
|
---|
[648] | 543 | Package currentDownload, State state,
|
---|
[646] | 544 | int filesDown, int filesTotal,
|
---|
[621] | 545 | int bytesDown, int bytesTotal,
|
---|
| 546 | int duration, int remaining, int speed) {
|
---|
| 547 | evt.setProgressEnd(filesTotal);
|
---|
| 548 | evt.setProgressValue(filesDown);
|
---|
| 549 | }
|
---|
| 550 | });
|
---|
| 551 | while (!m.isFinished()) {
|
---|
| 552 | try {
|
---|
| 553 | Thread.sleep(10);
|
---|
| 554 | } catch (InterruptedException e) {
|
---|
| 555 | e.printStackTrace();
|
---|
| 556 | }
|
---|
[604] | 557 | }
|
---|
| 558 | }
|
---|
[657] | 559 | evt.setProgressMessage(bundle.getString("coreToolsInstall.title"));
|
---|
[699] | 560 | Installer.installTools(PackageManager.getInstance().getCoreTools(), false);
|
---|
[604] | 561 | }
|
---|
[602] | 562 | }
|
---|
| 563 |
|
---|
[641] | 564 | @SuppressWarnings("unused")
|
---|
[648] | 565 | private void infoCorePackages() {
|
---|
| 566 | if (execCoreUpdates.size() > 0) {
|
---|
[645] | 567 | String packages = "";
|
---|
[648] | 568 | for (Package m : execCoreUpdates) {
|
---|
[645] | 569 | packages += String.format("\n - %s (%s)", m.getName(),
|
---|
| 570 | m.getVersion());
|
---|
| 571 | }
|
---|
| 572 | JOptionPane.showMessageDialog(this, String.format(
|
---|
[648] | 573 | bundle.getString("corePackagesUpdated.text"), packages),
|
---|
| 574 | bundle.getString("corePackagesUpdated.title"),
|
---|
[645] | 575 | JOptionPane.INFORMATION_MESSAGE);
|
---|
| 576 | }
|
---|
| 577 | }
|
---|
| 578 |
|
---|
| 579 | @SuppressWarnings("unused")
|
---|
[641] | 580 | private void install() {
|
---|
[648] | 581 | TreeSet<Package> mods = new TreeSet<Package>();
|
---|
| 582 | mods.addAll(PackageManager.getInstance().getCoreMods());
|
---|
[631] | 583 | mods.addAll(tblMods.getSelectedMods());
|
---|
[600] | 584 |
|
---|
[648] | 585 | installDeps = new TreeSet<Package>();
|
---|
[646] | 586 |
|
---|
[641] | 587 | installState = EInstallState.CHECKING;
|
---|
[605] | 588 |
|
---|
[641] | 589 | while (installState == EInstallState.CHECKING) {
|
---|
[648] | 590 | TreeSet<Package> toDownload = new TreeSet<Package>();
|
---|
| 591 | for (Package m : mods) {
|
---|
[605] | 592 | if (!m.isLocalAvailable())
|
---|
| 593 | toDownload.add(m);
|
---|
| 594 | }
|
---|
[669] | 595 |
|
---|
[657] | 596 | if (toDownload.size() > 0 && Settings.getInstance().isOfflineMode()) {
|
---|
[641] | 597 | installState = EInstallState.OFFLINE;
|
---|
[621] | 598 | break;
|
---|
| 599 | }
|
---|
[669] | 600 |
|
---|
[605] | 601 | if (toDownload.size() > 0) {
|
---|
[646] | 602 | Downloader dl = new Downloader(toDownload, installDeps);
|
---|
[617] | 603 | try {
|
---|
| 604 | dl.setVisible(true);
|
---|
[641] | 605 | if (!dl.isFinished()) {
|
---|
| 606 | installState = EInstallState.ABORTED;
|
---|
[617] | 607 | break;
|
---|
[641] | 608 | }
|
---|
[617] | 609 | } finally {
|
---|
| 610 | dl.dispose();
|
---|
| 611 | }
|
---|
[605] | 612 | }
|
---|
[669] | 613 |
|
---|
[657] | 614 | HashMap<Package, HashSet<Package>> dependencies = PackageManager
|
---|
| 615 | .getInstance().checkDependencies(mods);
|
---|
[605] | 616 | if (dependencies.size() > 0) {
|
---|
[648] | 617 | for (HashSet<Package> hm : dependencies.values()) {
|
---|
[646] | 618 | installDeps.addAll(hm);
|
---|
| 619 | }
|
---|
[647] | 620 |
|
---|
[669] | 621 | int size = 0;
|
---|
| 622 | String depsLocalString = "";
|
---|
| 623 | String depsDownloadString = "";
|
---|
| 624 | for (Package m : dependencies.keySet()) {
|
---|
| 625 | for (Package mDep : dependencies.get(m)) {
|
---|
| 626 | if (!mods.contains(mDep)) {
|
---|
| 627 | mods.add(mDep);
|
---|
| 628 | if (!mDep.isLocalAvailable()) {
|
---|
| 629 | size += mDep.getZipSize();
|
---|
| 630 | if (depsDownloadString.length() > 0)
|
---|
| 631 | depsDownloadString += "\n";
|
---|
| 632 | depsDownloadString += " - " + mDep.getName();
|
---|
| 633 | } else {
|
---|
| 634 | if (depsLocalString.length() > 0)
|
---|
| 635 | depsLocalString += "\n";
|
---|
| 636 | depsLocalString += " - " + mDep.getName();
|
---|
[641] | 637 | }
|
---|
| 638 | }
|
---|
| 639 | }
|
---|
[669] | 640 | }
|
---|
[641] | 641 |
|
---|
[669] | 642 | if (depsLocalString.length() == 0)
|
---|
| 643 | depsLocalString = bundle
|
---|
| 644 | .getString("installDependencies.none");
|
---|
| 645 | if (depsDownloadString.length() == 0)
|
---|
| 646 | depsDownloadString = bundle
|
---|
| 647 | .getString("installDependencies.none");
|
---|
| 648 |
|
---|
| 649 | if (!Settings.getInstance()
|
---|
| 650 | .get("notifyDepsAfterInstall", false)) {
|
---|
[646] | 651 | int res = JOptionPane.showConfirmDialog(this, String
|
---|
| 652 | .format(bundle
|
---|
| 653 | .getString("installDependencies.text"),
|
---|
| 654 | depsLocalString, depsDownloadString,
|
---|
| 655 | SizeFormatter.format(size, 3)), bundle
|
---|
| 656 | .getString("installDependencies.title"),
|
---|
| 657 | JOptionPane.YES_NO_OPTION,
|
---|
| 658 | JOptionPane.INFORMATION_MESSAGE);
|
---|
[669] | 659 |
|
---|
[646] | 660 | if (res == JOptionPane.NO_OPTION) {
|
---|
| 661 | installState = EInstallState.ABORTED;
|
---|
| 662 | break;
|
---|
| 663 | }
|
---|
[641] | 664 | }
|
---|
[605] | 665 | } else {
|
---|
[648] | 666 | HashMap<Package, HashSet<Package>> incompatibilities = PackageManager
|
---|
[645] | 667 | .getInstance().checkIncompabitilites(mods);
|
---|
[643] | 668 | if (incompatibilities.size() > 0) {
|
---|
[641] | 669 | installState = EInstallState.INCOMPATIBLE;
|
---|
[643] | 670 |
|
---|
| 671 | String incompatString = "";
|
---|
[648] | 672 | for (Package m : incompatibilities.keySet()) {
|
---|
[643] | 673 | if (incompatString.length() > 0)
|
---|
| 674 | incompatString += "\n";
|
---|
| 675 | incompatString += m.getName() + ": ";
|
---|
| 676 | String confMods = "";
|
---|
[648] | 677 | for (Package mConf : incompatibilities.get(m)) {
|
---|
[643] | 678 | if (confMods.length() > 0)
|
---|
| 679 | confMods += ", ";
|
---|
| 680 | confMods += mConf.getName();
|
---|
| 681 | }
|
---|
| 682 | incompatString += confMods;
|
---|
| 683 | }
|
---|
| 684 |
|
---|
| 685 | JOptionPane.showMessageDialog(this, String.format(
|
---|
| 686 | bundle.getString("installIncompatibilities.text"),
|
---|
| 687 | incompatString), bundle
|
---|
| 688 | .getString("installIncompatibilities.title"),
|
---|
| 689 | JOptionPane.ERROR_MESSAGE);
|
---|
[605] | 690 | break;
|
---|
| 691 | } else {
|
---|
[641] | 692 | installState = EInstallState.READY;
|
---|
[605] | 693 | }
|
---|
| 694 | }
|
---|
[600] | 695 | }
|
---|
[618] | 696 |
|
---|
[641] | 697 | if (installState == EInstallState.READY) {
|
---|
[648] | 698 | installMods = new TreeSet<Package>();
|
---|
| 699 | TreeSet<Package> actuallyTools = new TreeSet<Package>();
|
---|
[623] | 700 |
|
---|
[648] | 701 | for (Package m : mods) {
|
---|
[623] | 702 | if (m.isTool())
|
---|
| 703 | actuallyTools.add(m);
|
---|
| 704 | else
|
---|
[641] | 705 | installMods.add(m);
|
---|
[623] | 706 | }
|
---|
| 707 |
|
---|
| 708 | if (actuallyTools.size() > 0) {
|
---|
[699] | 709 | Installer.installTools(actuallyTools, false);
|
---|
[623] | 710 | }
|
---|
[641] | 711 | }
|
---|
| 712 | }
|
---|
| 713 |
|
---|
| 714 | @DoInBackground(progressMessage = "installing.title", cancelable = false, indeterminateProgress = false)
|
---|
| 715 | private void installExec(final BackgroundEvent evt) {
|
---|
| 716 | if (installState == EInstallState.READY) {
|
---|
| 717 | Installer.install(installMods, new InstallProgressListener() {
|
---|
[605] | 718 | @Override
|
---|
| 719 | public void installProgressUpdate(int done, int total,
|
---|
| 720 | String step) {
|
---|
| 721 | evt.setProgressEnd(total);
|
---|
| 722 | evt.setProgressValue(done);
|
---|
| 723 | evt.setProgressMessage(step);
|
---|
| 724 | }
|
---|
| 725 | });
|
---|
[641] | 726 | installState = EInstallState.DONE;
|
---|
[605] | 727 | }
|
---|
[641] | 728 | installMods = null;
|
---|
[600] | 729 | }
|
---|
[618] | 730 |
|
---|
[617] | 731 | @SuppressWarnings("unused")
|
---|
| 732 | private void installDone() {
|
---|
[648] | 733 | PackageManager.getInstance().updateInstalledMods();
|
---|
[641] | 734 | switch (installState) {
|
---|
[621] | 735 | case DONE:
|
---|
[641] | 736 | revertSelection();
|
---|
[646] | 737 | if (installDeps.size() > 0
|
---|
| 738 | && Settings.getInstance().get("notifyDepsAfterInstall",
|
---|
| 739 | false)) {
|
---|
| 740 | String installedDeps = "";
|
---|
[648] | 741 | for (Package m : installDeps) {
|
---|
[646] | 742 | if (installedDeps.length() > 0)
|
---|
| 743 | installedDeps += "\n";
|
---|
| 744 | installedDeps += " - " + m.getName();
|
---|
| 745 | }
|
---|
| 746 | JOptionPane.showMessageDialog(this, String.format(
|
---|
| 747 | bundle.getString("installDoneDeps.text"),
|
---|
| 748 | installedDeps), bundle
|
---|
| 749 | .getString("installDone.title"),
|
---|
| 750 | JOptionPane.INFORMATION_MESSAGE);
|
---|
| 751 | } else {
|
---|
| 752 | JOptionPane.showMessageDialog(this,
|
---|
| 753 | bundle.getString("installDone.text"),
|
---|
| 754 | bundle.getString("installDone.title"),
|
---|
| 755 | JOptionPane.INFORMATION_MESSAGE);
|
---|
| 756 | }
|
---|
[621] | 757 | break;
|
---|
| 758 | case OFFLINE:
|
---|
[657] | 759 | JOptionPane.showMessageDialog(
|
---|
| 760 | this,
|
---|
| 761 | SwingJavaBuilder.getConfig().getResource(
|
---|
| 762 | "offlineMode.text"),
|
---|
| 763 | SwingJavaBuilder.getConfig().getResource(
|
---|
| 764 | "offlineMode.title"),
|
---|
[621] | 765 | JOptionPane.WARNING_MESSAGE);
|
---|
| 766 | break;
|
---|
[641] | 767 | default:
|
---|
[621] | 768 | break;
|
---|
| 769 | }
|
---|
[646] | 770 | installDeps = null;
|
---|
[617] | 771 | }
|
---|
[600] | 772 |
|
---|
[631] | 773 | @Override
|
---|
[648] | 774 | public void modSelectionChanged(ModTable source, Package m) {
|
---|
[658] | 775 | pkgInfo.updateInfo(m);
|
---|
[591] | 776 | }
|
---|
| 777 |
|
---|
[630] | 778 | private void updateTableFilter() {
|
---|
| 779 | Object o = cmbModTypes.getSelectedItem();
|
---|
| 780 | Type t = null;
|
---|
| 781 | if (o instanceof Type)
|
---|
| 782 | t = (Type) o;
|
---|
| 783 | int downloadState = 0;
|
---|
| 784 | if (radOnline.isSelected())
|
---|
| 785 | downloadState = 1;
|
---|
| 786 | if (radLocal.isSelected())
|
---|
| 787 | downloadState = 2;
|
---|
[660] | 788 | tblMods.setFilter(t, downloadState, txtShowFilter.getText(),
|
---|
| 789 | (EApplyFilterTo) cmbShowFilterTo.getSelectedItem());
|
---|
[630] | 790 | }
|
---|
| 791 |
|
---|
[593] | 792 | @Override
|
---|
[673] | 793 | public void modInstallSelectionChanged(int newSize, int newCount) {
|
---|
| 794 | lblSelectedModsVal.setText(String.valueOf(newCount));
|
---|
[600] | 795 | lblDownloadSizeVal.setText(SizeFormatter.format(newSize, 2));
|
---|
| 796 | }
|
---|
| 797 |
|
---|
[616] | 798 | @SuppressWarnings("unused")
|
---|
| 799 | private void checkInitialize() {
|
---|
[600] | 800 | if (!Installer.isEditionInitialized()) {
|
---|
[621] | 801 | if (!OniSplit.isOniSplitInstalled()) {
|
---|
| 802 | JOptionPane.showMessageDialog(this,
|
---|
| 803 | bundle.getString("noOniSplit.text"),
|
---|
| 804 | bundle.getString("noOniSplit.title"),
|
---|
| 805 | JOptionPane.ERROR_MESSAGE);
|
---|
[600] | 806 | exit();
|
---|
[621] | 807 | } else {
|
---|
| 808 | int res = JOptionPane
|
---|
| 809 | .showConfirmDialog(this,
|
---|
| 810 | bundle.getString("askInitialize.text"),
|
---|
| 811 | bundle.getString("askInitialize.title"),
|
---|
| 812 | JOptionPane.YES_NO_OPTION,
|
---|
| 813 | JOptionPane.QUESTION_MESSAGE);
|
---|
| 814 | if (res == JOptionPane.NO_OPTION) {
|
---|
| 815 | saveLocalData();
|
---|
| 816 | exit();
|
---|
| 817 | }
|
---|
[600] | 818 | }
|
---|
| 819 | }
|
---|
| 820 | }
|
---|
[606] | 821 |
|
---|
[616] | 822 | @DoInBackground(progressMessage = "initializingEdition.title", cancelable = false, indeterminateProgress = false)
|
---|
| 823 | private void initialize(final BackgroundEvent evt) {
|
---|
| 824 | if (!Installer.isEditionInitialized()) {
|
---|
| 825 | Installer.initializeEdition(new InstallProgressListener() {
|
---|
| 826 | @Override
|
---|
| 827 | public void installProgressUpdate(int done, int total,
|
---|
| 828 | String step) {
|
---|
| 829 | evt.setProgressEnd(total);
|
---|
| 830 | evt.setProgressValue(done);
|
---|
| 831 | evt.setProgressMessage(step);
|
---|
| 832 | }
|
---|
| 833 | });
|
---|
| 834 | }
|
---|
| 835 | }
|
---|
| 836 |
|
---|
[605] | 837 | private Vector<String> getBasicOniLaunchParams() {
|
---|
| 838 | Vector<String> params = new Vector<String>();
|
---|
[618] | 839 | File exe = null;
|
---|
[605] | 840 | switch (Settings.getPlatform()) {
|
---|
| 841 | case WIN:
|
---|
[618] | 842 | exe = new File(Paths.getEditionBasePath(), "Oni.exe");
|
---|
| 843 | if (exe.exists())
|
---|
| 844 | params.add(exe.getPath());
|
---|
[605] | 845 | break;
|
---|
| 846 | case MACOS:
|
---|
[618] | 847 | exe = new File(Paths.getEditionBasePath(),
|
---|
| 848 | "Oni.app/Contents/MacOS/Oni");
|
---|
| 849 | if (exe.exists())
|
---|
| 850 | params.add(exe.getPath());
|
---|
[605] | 851 | break;
|
---|
| 852 | case LINUX:
|
---|
| 853 | String wine = Settings.getWinePath();
|
---|
[618] | 854 | exe = new File(Paths.getEditionBasePath(), "Oni.exe");
|
---|
| 855 | if (exe.exists()) {
|
---|
| 856 | if (wine != null) {
|
---|
| 857 | params.add(wine);
|
---|
| 858 | params.add(exe.getPath());
|
---|
| 859 | }
|
---|
[605] | 860 | }
|
---|
| 861 | break;
|
---|
| 862 | default:
|
---|
| 863 | }
|
---|
| 864 | if (params.size() > 0) {
|
---|
| 865 | params.add("-debugfiles");
|
---|
| 866 | }
|
---|
| 867 | return params;
|
---|
| 868 | }
|
---|
[600] | 869 |
|
---|
[605] | 870 | @SuppressWarnings("unused")
|
---|
| 871 | private void oniFull() {
|
---|
| 872 | Vector<String> params = getBasicOniLaunchParams();
|
---|
| 873 | if (params.size() > 0) {
|
---|
[623] | 874 | AppExecution.execute(params, Paths.getEditionBasePath());
|
---|
[605] | 875 | }
|
---|
| 876 | }
|
---|
| 877 |
|
---|
| 878 | @SuppressWarnings("unused")
|
---|
| 879 | private void oniWin() {
|
---|
| 880 | Vector<String> params = getBasicOniLaunchParams();
|
---|
| 881 | if (params.size() > 0) {
|
---|
| 882 | params.add("-noswitch");
|
---|
[623] | 883 | AppExecution.execute(params, Paths.getEditionBasePath());
|
---|
[605] | 884 | }
|
---|
| 885 | }
|
---|
| 886 |
|
---|
[608] | 887 | @SuppressWarnings("unused")
|
---|
| 888 | private void openEditionFolder() {
|
---|
| 889 | try {
|
---|
| 890 | Desktop.getDesktop().open(Paths.getEditionBasePath());
|
---|
[639] | 891 | } catch (Exception e) {
|
---|
[608] | 892 | e.printStackTrace();
|
---|
| 893 | }
|
---|
| 894 | }
|
---|
| 895 |
|
---|
[600] | 896 | @Override
|
---|
[593] | 897 | public void handleAbout(ApplicationEvent event) {
|
---|
| 898 | event.setHandled(true);
|
---|
| 899 | showAbout();
|
---|
| 900 | }
|
---|
| 901 |
|
---|
| 902 | @Override
|
---|
| 903 | public void handleOpenApplication(ApplicationEvent event) {
|
---|
| 904 | }
|
---|
| 905 |
|
---|
| 906 | @Override
|
---|
| 907 | public void handleOpenFile(ApplicationEvent event) {
|
---|
| 908 | }
|
---|
| 909 |
|
---|
| 910 | @Override
|
---|
| 911 | public void handlePreferences(ApplicationEvent event) {
|
---|
| 912 | showSettings();
|
---|
| 913 | }
|
---|
| 914 |
|
---|
| 915 | @Override
|
---|
| 916 | public void handlePrintFile(ApplicationEvent event) {
|
---|
| 917 | }
|
---|
| 918 |
|
---|
| 919 | @Override
|
---|
| 920 | public void handleQuit(ApplicationEvent event) {
|
---|
[605] | 921 | event.setHandled(true);
|
---|
| 922 | saveLocalData();
|
---|
| 923 | exit();
|
---|
[593] | 924 | }
|
---|
| 925 |
|
---|
| 926 | @Override
|
---|
| 927 | public void handleReOpenApplication(ApplicationEvent event) {
|
---|
| 928 | }
|
---|
[600] | 929 |
|
---|
[592] | 930 | }
|
---|