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