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