1 | package net.oni2.aeinstaller.backend.oni;
|
---|
2 |
|
---|
3 | import java.io.File;
|
---|
4 | import java.io.FileNotFoundException;
|
---|
5 | import java.util.Vector;
|
---|
6 |
|
---|
7 | import net.oni2.aeinstaller.backend.Paths;
|
---|
8 | import net.oni2.platformtools.PlatformInformation;
|
---|
9 | import net.oni2.platformtools.applicationinvoker.ApplicationInvoker;
|
---|
10 | import net.oni2.platformtools.applicationinvoker.EExeType;
|
---|
11 | import net.oni2.platformtools.applicationinvoker.ERuntimeNotInstalledException;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * @author Christian Illy
|
---|
15 | */
|
---|
16 | public class OniLauncher {
|
---|
17 |
|
---|
18 | private static File getOniExe() throws FileNotFoundException {
|
---|
19 | File exe = null;
|
---|
20 | switch (PlatformInformation.getPlatform()) {
|
---|
21 | case WIN:
|
---|
22 | case LINUX:
|
---|
23 | exe = new File(Paths.getEditionBasePath(), "Oni.exe");
|
---|
24 | break;
|
---|
25 | case MACOS:
|
---|
26 | exe = new File(Paths.getEditionBasePath(),
|
---|
27 | "Oni.app/Contents/MacOS/Oni");
|
---|
28 | break;
|
---|
29 | default:
|
---|
30 | }
|
---|
31 | if (exe.exists())
|
---|
32 | return exe;
|
---|
33 | else
|
---|
34 | throw new FileNotFoundException("Oni's executable was not found");
|
---|
35 | }
|
---|
36 |
|
---|
37 | private static EExeType getOniExeType() {
|
---|
38 | switch (PlatformInformation.getPlatform()) {
|
---|
39 | case MACOS:
|
---|
40 | return EExeType.OSBINARY;
|
---|
41 | default:
|
---|
42 | return EExeType.WINEXE;
|
---|
43 | }
|
---|
44 | }
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * @param windowed
|
---|
48 | * Run in windowed mode
|
---|
49 | * @throws FileNotFoundException
|
---|
50 | * If Oni's executable was not found
|
---|
51 | * @throws ERuntimeNotInstalledException
|
---|
52 | * If Linux and Wine not found
|
---|
53 | */
|
---|
54 | public static void launch(boolean windowed) throws FileNotFoundException,
|
---|
55 | ERuntimeNotInstalledException {
|
---|
56 | File exe = getOniExe();
|
---|
57 | Vector<String> params = new Vector<String>();
|
---|
58 | params.add("-debugfiles");
|
---|
59 | if (windowed)
|
---|
60 | params.add("-noswitch");
|
---|
61 | ApplicationInvoker.execute(getOniExeType(), Paths.getEditionBasePath(),
|
---|
62 | exe, params, true);
|
---|
63 | }
|
---|
64 |
|
---|
65 | }
|
---|