[720] | 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() {
|
---|
| 19 | File exe = null;
|
---|
| 20 | switch (PlatformInformation.getPlatform()) {
|
---|
| 21 | case WIN:
|
---|
| 22 | exe = new File(Paths.getEditionBasePath(), "Oni.exe");
|
---|
| 23 | break;
|
---|
| 24 | case MACOS:
|
---|
| 25 | exe = new File(Paths.getEditionBasePath(),
|
---|
| 26 | "Oni.app/Contents/MacOS/Oni");
|
---|
| 27 | break;
|
---|
| 28 | case LINUX:
|
---|
| 29 | exe = new File(Paths.getEditionBasePath(), "Oni.exe");
|
---|
| 30 | break;
|
---|
| 31 | default:
|
---|
| 32 | }
|
---|
| 33 | if ((exe != null) && !exe.exists())
|
---|
| 34 | exe = null;
|
---|
| 35 | return exe;
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | private static EExeType getOniExeType() {
|
---|
| 39 | switch (PlatformInformation.getPlatform()) {
|
---|
| 40 | case MACOS:
|
---|
| 41 | return EExeType.OSBINARY;
|
---|
| 42 | default:
|
---|
| 43 | return EExeType.WINEXE;
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
[757] | 46 |
|
---|
[720] | 47 | /**
|
---|
| 48 | * @param windowed
|
---|
| 49 | * Run in windowed mode
|
---|
| 50 | * @throws FileNotFoundException
|
---|
| 51 | * If Oni's executable was not found
|
---|
| 52 | * @throws ERuntimeNotInstalledException
|
---|
| 53 | * If Linux and Wine not found
|
---|
| 54 | */
|
---|
| 55 | public static void launch(boolean windowed) throws FileNotFoundException,
|
---|
| 56 | ERuntimeNotInstalledException {
|
---|
| 57 | File exe = getOniExe();
|
---|
| 58 | if (exe == null)
|
---|
| 59 | throw new FileNotFoundException("Oni's executable was not found");
|
---|
| 60 | Vector<String> params = new Vector<String>();
|
---|
| 61 | params.add("-debugfiles");
|
---|
| 62 | if (windowed)
|
---|
| 63 | params.add("-noswitch");
|
---|
[757] | 64 | ApplicationInvoker.execute(getOniExeType(), Paths.getEditionBasePath(), exe,
|
---|
[720] | 65 | params);
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | }
|
---|