[591] | 1 | package net.oni2.aeinstaller;
|
---|
| 2 |
|
---|
| 3 | import java.io.File;
|
---|
| 4 | import java.io.FileNotFoundException;
|
---|
| 5 | import java.io.PrintStream;
|
---|
[592] | 6 | import java.util.ResourceBundle;
|
---|
[591] | 7 |
|
---|
| 8 | import javax.swing.JFrame;
|
---|
[592] | 9 | import javax.swing.JOptionPane;
|
---|
[591] | 10 | import javax.swing.JToolBar;
|
---|
| 11 | import javax.swing.SwingUtilities;
|
---|
| 12 | import javax.swing.UIManager;
|
---|
| 13 | import javax.swing.UIManager.LookAndFeelInfo;
|
---|
| 14 |
|
---|
| 15 | import net.oni2.aeinstaller.backend.Settings;
|
---|
| 16 | import net.oni2.aeinstaller.backend.StuffToRefactorLater;
|
---|
| 17 | import net.oni2.aeinstaller.backend.depot.DepotManager;
|
---|
| 18 | import net.oni2.aeinstaller.gui.MainWin;
|
---|
| 19 |
|
---|
| 20 | import org.javabuilders.swing.SwingJavaBuilder;
|
---|
| 21 |
|
---|
| 22 | /**
|
---|
| 23 | * @author Christian Illy
|
---|
| 24 | * @version 0.1
|
---|
| 25 | */
|
---|
| 26 | public class AEInstaller2 {
|
---|
| 27 |
|
---|
| 28 | /**
|
---|
| 29 | * @param args
|
---|
| 30 | * Command line arguments
|
---|
| 31 | */
|
---|
| 32 | public static void main(String[] args) {
|
---|
| 33 | new File(Settings.getPrefsPath()).mkdirs();
|
---|
| 34 | new File(Settings.getDownloadPath()).mkdirs();
|
---|
| 35 |
|
---|
| 36 | boolean debug = false;
|
---|
| 37 | for (String a : args)
|
---|
| 38 | if (a.equalsIgnoreCase("-debug"))
|
---|
| 39 | debug = true;
|
---|
| 40 | if (!debug) {
|
---|
| 41 | try {
|
---|
| 42 | System.setOut(new PrintStream(Settings.getPrefsPath()
|
---|
| 43 | + "aei_output.log"));
|
---|
| 44 | System.setErr(new PrintStream(Settings.getPrefsPath()
|
---|
| 45 | + "aei_error.log"));
|
---|
| 46 | } catch (FileNotFoundException e1) {
|
---|
| 47 | e1.printStackTrace();
|
---|
| 48 | }
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | Settings.deserializeFromFile();
|
---|
| 52 | Settings.setDebug(debug);
|
---|
| 53 | DepotManager.getInstance().loadFromFile(
|
---|
| 54 | new File(Settings.getDepotCacheFilename()));
|
---|
| 55 |
|
---|
[592] | 56 | ResourceBundle imagesBundle = ResourceBundle
|
---|
| 57 | .getBundle(AEInstaller2.class.getPackage().getName()
|
---|
| 58 | + ".Images");
|
---|
| 59 | ResourceBundle basicBundle = ResourceBundle
|
---|
| 60 | .getBundle(AEInstaller2.class.getPackage().getName()
|
---|
| 61 | + ".AEInstaller");
|
---|
| 62 |
|
---|
| 63 | SwingJavaBuilder.getConfig().addResourceBundle(imagesBundle);
|
---|
| 64 | SwingJavaBuilder.getConfig().addResourceBundle(basicBundle);
|
---|
[591] | 65 | SwingJavaBuilder.getConfig().setMarkInvalidResourceBundleKeys(true);
|
---|
| 66 | SwingJavaBuilder.getConfig().addType("JToolBarSeparator",
|
---|
| 67 | JToolBar.Separator.class);
|
---|
| 68 | // SwingJavaBuilder.getConfig().addType("ScreenshotBrowser",
|
---|
| 69 | // ScreenshotBrowser.class);
|
---|
| 70 | // SwingJavaBuilder.getConfig().addType("HTMLLinkLabel",
|
---|
| 71 | // HTMLLinkLabel.class);
|
---|
| 72 |
|
---|
| 73 | System.setProperty("networkaddress.cache.ttl", "5");
|
---|
| 74 | System.setProperty("networkaddress.cache.negative.ttl", "1");
|
---|
| 75 |
|
---|
| 76 | try {
|
---|
| 77 | String laf = Settings.getInstance().get("lookandfeel",
|
---|
| 78 | (String) null);
|
---|
| 79 | if (laf == null) {
|
---|
| 80 | for (LookAndFeelInfo lafInfo : UIManager
|
---|
| 81 | .getInstalledLookAndFeels()) {
|
---|
| 82 | if (lafInfo.getName().equals("Nimbus"))
|
---|
| 83 | laf = lafInfo.getClassName();
|
---|
| 84 | }
|
---|
| 85 | }
|
---|
| 86 | if (laf == null)
|
---|
| 87 | laf = UIManager.getSystemLookAndFeelClassName();
|
---|
| 88 | UIManager.setLookAndFeel(laf);
|
---|
| 89 | } catch (Exception e) {
|
---|
| 90 | e.printStackTrace();
|
---|
| 91 | }
|
---|
| 92 | JFrame.setDefaultLookAndFeelDecorated(true);
|
---|
| 93 |
|
---|
| 94 | // TODO
|
---|
| 95 | System.out.println("JarPath: " + Settings.getJarPath());
|
---|
| 96 | System.out.println("PrefsPath: " + Settings.getPrefsPath());
|
---|
| 97 | System.out.println("DataPath: " + Settings.getDataPath());
|
---|
| 98 | System.out.println("DownPath: " + Settings.getDownloadPath());
|
---|
| 99 | System.out.println("TempPath: " + Settings.getTempPath());
|
---|
| 100 | System.out.println("ValidPath: "
|
---|
| 101 | + StuffToRefactorLater.verifyRunningDirectory());
|
---|
| 102 |
|
---|
[592] | 103 | if (!StuffToRefactorLater.verifyRunningDirectory()) {
|
---|
| 104 | JOptionPane.showMessageDialog(null,
|
---|
| 105 | basicBundle.getString("invalidPath.text"),
|
---|
| 106 | basicBundle.getString("invalidPath.title"),
|
---|
| 107 | JOptionPane.ERROR_MESSAGE);
|
---|
| 108 | if (!Settings.getDebug()) {
|
---|
| 109 | return;
|
---|
| 110 | }
|
---|
| 111 | }
|
---|
| 112 |
|
---|
[591] | 113 | SwingUtilities.invokeLater(new Runnable() {
|
---|
| 114 |
|
---|
| 115 | public void run() {
|
---|
| 116 | try {
|
---|
| 117 | new MainWin().setVisible(true);
|
---|
| 118 | } catch (Exception e) {
|
---|
| 119 | e.printStackTrace();
|
---|
| 120 | }
|
---|
| 121 | }
|
---|
| 122 | });
|
---|
| 123 |
|
---|
| 124 | }
|
---|
| 125 | }
|
---|