Added a config option to launch FTL via Steam, if possible (kartoFlane)
This commit is contained in:
parent
a3ab324308
commit
be8a84cd2e
8 changed files with 138 additions and 17 deletions
|
@ -677,9 +677,28 @@ public class ManagerFrame extends JFrame implements ActionListener, ModsScanObse
|
|||
|
||||
String neverRunFtl = appConfig.getProperty( "never_run_ftl", "false" );
|
||||
if ( !neverRunFtl.equals("true") ) {
|
||||
File exeFile = FTLUtilities.findGameExe( datsDir );
|
||||
File exeFile = null;
|
||||
String[] exeArgs = null;
|
||||
|
||||
if ( appConfig.getProperty( "run_steam_ftl", "false" ).equals( "true" ) ) {
|
||||
exeFile = FTLUtilities.findSteamExe();
|
||||
exeArgs = new String[] {"-applaunch", FTLUtilities.STEAM_APPID_FTL};
|
||||
|
||||
if ( exeFile == null ) {
|
||||
log.warn( "Steam executable could not be found. FTL will be launched directly." );
|
||||
}
|
||||
}
|
||||
if ( exeFile == null ) {
|
||||
exeFile = FTLUtilities.findGameExe( datsDir );
|
||||
exeArgs = new String[0];
|
||||
|
||||
if ( exeFile == null ) {
|
||||
log.warn( "FTL executable could not be found." );
|
||||
}
|
||||
}
|
||||
|
||||
if ( exeFile != null ) {
|
||||
patchDlg.setSuccessTask( new SpawnGameTask( exeFile ) );
|
||||
patchDlg.setSuccessTask( new SpawnGameTask( exeFile, exeArgs ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -951,9 +970,13 @@ public class ManagerFrame extends JFrame implements ActionListener, ModsScanObse
|
|||
|
||||
private class SpawnGameTask implements Runnable {
|
||||
private final File exeFile;
|
||||
private final String[] exeArgs;
|
||||
|
||||
public SpawnGameTask( File exeFile ) {
|
||||
public SpawnGameTask( File exeFile, String... exeArgs ) {
|
||||
if ( exeArgs == null ) exeArgs = new String[0];
|
||||
this.exeFile = exeFile;
|
||||
this.exeArgs = new String[exeArgs.length];
|
||||
System.arraycopy( exeArgs, 0, this.exeArgs, 0, exeArgs.length );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -963,7 +986,7 @@ public class ManagerFrame extends JFrame implements ActionListener, ModsScanObse
|
|||
if ( response == JOptionPane.YES_OPTION ) {
|
||||
log.info( "Running FTL..." );
|
||||
try {
|
||||
FTLUtilities.launchGame( exeFile );
|
||||
FTLUtilities.launchExe( exeFile, exeArgs );
|
||||
} catch ( Exception e ) {
|
||||
log.error( "Error launching FTL.", e );
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import net.vhati.modmanager.ui.FieldEditorPanel.ContentType;
|
|||
|
||||
public class SlipstreamConfigDialog extends JFrame implements ActionListener {
|
||||
protected static final String ALLOW_ZIP = "allow_zip";
|
||||
protected static final String RUN_STEAM_FTL = "run_steam_ftl";
|
||||
protected static final String NEVER_RUN_FTL = "never_run_ftl";
|
||||
protected static final String USE_DEFAULT_UI = "use_default_ui";
|
||||
protected static final String REMEMBER_GEOMETRY = "remember_geometry";
|
||||
|
@ -53,6 +54,9 @@ public class SlipstreamConfigDialog extends JFrame implements ActionListener {
|
|||
editorPanel.addRow( ALLOW_ZIP, ContentType.BOOLEAN );
|
||||
editorPanel.addTextRow( "Treat .zip files as .ftl files." );
|
||||
editorPanel.addSeparatorRow();
|
||||
editorPanel.addRow( RUN_STEAM_FTL, ContentType.BOOLEAN );
|
||||
editorPanel.addTextRow( "Use Steam to run FTL, if possible." );
|
||||
editorPanel.addSeparatorRow();
|
||||
editorPanel.addRow( NEVER_RUN_FTL, ContentType.BOOLEAN );
|
||||
editorPanel.addTextRow( "Don't offer to run FTL after patching." );
|
||||
editorPanel.addSeparatorRow();
|
||||
|
@ -77,6 +81,7 @@ public class SlipstreamConfigDialog extends JFrame implements ActionListener {
|
|||
editorPanel.addFillRow();
|
||||
|
||||
editorPanel.getBoolean( ALLOW_ZIP ).setSelected( appConfig.getProperty( ALLOW_ZIP, "false" ).equals( "true" ) );
|
||||
editorPanel.getBoolean( RUN_STEAM_FTL ).setSelected( appConfig.getProperty( RUN_STEAM_FTL, "false" ).equals( "true" ) );
|
||||
editorPanel.getBoolean( NEVER_RUN_FTL ).setSelected( appConfig.getProperty( NEVER_RUN_FTL, "false" ).equals( "true" ) );
|
||||
editorPanel.getBoolean( USE_DEFAULT_UI ).setSelected( appConfig.getProperty( USE_DEFAULT_UI, "false" ).equals( "true" ) );
|
||||
editorPanel.getBoolean( REMEMBER_GEOMETRY ).setSelected( appConfig.getProperty( REMEMBER_GEOMETRY, "true" ).equals( "true" ) );
|
||||
|
@ -133,6 +138,7 @@ public class SlipstreamConfigDialog extends JFrame implements ActionListener {
|
|||
if ( source == applyBtn ) {
|
||||
String tmp;
|
||||
appConfig.setProperty( ALLOW_ZIP, editorPanel.getBoolean( ALLOW_ZIP ).isSelected() ? "true" : "false" );
|
||||
appConfig.setProperty( RUN_STEAM_FTL, editorPanel.getBoolean( RUN_STEAM_FTL ).isSelected() ? "true" : "false" );
|
||||
appConfig.setProperty( NEVER_RUN_FTL, editorPanel.getBoolean( NEVER_RUN_FTL ).isSelected() ? "true" : "false" );
|
||||
appConfig.setProperty( USE_DEFAULT_UI, editorPanel.getBoolean( USE_DEFAULT_UI ).isSelected() ? "true" : "false" );
|
||||
appConfig.setProperty( REMEMBER_GEOMETRY, editorPanel.getBoolean( REMEMBER_GEOMETRY ).isSelected() ? "true" : "false" );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue