[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 |
|
---|
[767] | 18 | private static File getOniExe() throws FileNotFoundException {
|
---|
[720] | 19 | File exe = null;
|
---|
| 20 | switch (PlatformInformation.getPlatform()) {
|
---|
| 21 | case WIN:
|
---|
[767] | 22 | case LINUX:
|
---|
[720] | 23 | exe = new File(Paths.getEditionBasePath(), "Oni.exe");
|
---|
[772] | 24 | break;
|
---|
[720] | 25 | case MACOS:
|
---|
[785] | 26 | exe = new File(Paths.getEditionBasePath(),
|
---|
| 27 | "Oni.app/Contents/MacOS/Oni");
|
---|
[772] | 28 | break;
|
---|
[720] | 29 | default:
|
---|
| 30 | }
|
---|
[772] | 31 | if (exe.exists())
|
---|
| 32 | return exe;
|
---|
| 33 | else
|
---|
[785] | 34 | throw new FileNotFoundException("Oni's executable was not found");
|
---|
[720] | 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 | }
|
---|
[766] | 45 |
|
---|
[720] | 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");
|
---|
[766] | 61 | ApplicationInvoker.execute(getOniExeType(), Paths.getEditionBasePath(),
|
---|
[767] | 62 | exe, params, true);
|
---|
[720] | 63 | }
|
---|
| 64 |
|
---|
| 65 | }
|
---|