| 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 |
if (exe.exists()) |
| 25 |
return exe; |
| 26 |
else |
| 27 |
throw new FileNotFoundException( |
| 28 |
"Oni's executable was not found"); |
| 29 |
case MACOS: |
| 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; |
| 34 |
else |
| 35 |
throw new FileNotFoundException( |
| 36 |
"Oni's executable was not found"); |
| 37 |
default: |
| 38 |
} |
| 39 |
return null; |
| 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 |
} |
| 50 |
|
| 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"); |
| 66 |
ApplicationInvoker.execute(getOniExeType(), Paths.getEditionBasePath(), |
| 67 |
exe, params, true); |
| 68 |
} |
| 69 |
|
| 70 |
} |