Added a config arg to opt out of window geometry saving

This commit is contained in:
Vhati 2013-09-04 19:50:38 -04:00
parent 6cefc144eb
commit cd040e6ecc
3 changed files with 19 additions and 12 deletions

View file

@ -46,7 +46,9 @@ public class FTLModManager {
config.setProperty( "ftl_dats_path", "" ); config.setProperty( "ftl_dats_path", "" );
config.setProperty( "never_run_ftl", "false" ); config.setProperty( "never_run_ftl", "false" );
config.setProperty( "use_default_ui", "false" ); config.setProperty( "use_default_ui", "false" );
config.setProperty( "remember_geometry", "true" );
// "update_catalog" doesn't have a default. // "update_catalog" doesn't have a default.
// "manager_geometry" doesn't have a default.
// Read the config file. // Read the config file.
InputStream in = null; InputStream in = null;

View file

@ -45,12 +45,14 @@ public class SlipstreamConfig {
out = new FileOutputStream( configFile ); out = new FileOutputStream( configFile );
String configComments = ""; String configComments = "";
configComments += "\n"; configComments += "\n";
configComments += " allow_zip - Sets whether to treat .zip files as .ftl files. Default: false.\n"; configComments += " allow_zip - Sets whether to treat .zip files as .ftl files. Default: false.\n";
configComments += " ftl_dats_path - The path to FTL's resources folder. If invalid, you'll be prompted.\n"; configComments += " ftl_dats_path - The path to FTL's resources folder. If invalid, you'll be prompted.\n";
configComments += " never_run_ftl - If true, there will be no offer to run FTL after patching. Default: false.\n"; configComments += " never_run_ftl - If true, there will be no offer to run FTL after patching. Default: false.\n";
configComments += " update_catalog - If true, periodically download descriptions for the latest mods. If invalid, you'll be prompted.\n"; configComments += " update_catalog - If true, periodically download descriptions for the latest mods.\n";
configComments += " use_default_ui - If true, no attempt will be made to resemble a native GUI. Default: false.\n"; configComments += " use_default_ui - If true, no attempt will be made to resemble a native GUI. Default: false.\n";
configComments += " manager_geometry - Saved position/size/etc of the main window.\n"; configComments += " remember_geometry - If true, window geometry will be saved on exit and restored on startup.\n";
configComments += "\n";
configComments += " manager_geometry - Last saved position/size/etc of the main window.\n";
OutputStreamWriter writer = new OutputStreamWriter( out, "UTF-8" ); OutputStreamWriter writer = new OutputStreamWriter( out, "UTF-8" );
config.store( writer, configComments ); config.store( writer, configComments );

View file

@ -241,11 +241,13 @@ public class ManagerFrame extends JFrame implements ActionListener, HashObserver
SlipstreamConfig appConfig = ManagerFrame.this.appConfig; SlipstreamConfig appConfig = ManagerFrame.this.appConfig;
if ( ManagerFrame.this.getExtendedState() == JFrame.NORMAL ) { if ( appConfig.getProperty( "remember_geometry" ).equals( "true" ) ) {
Rectangle managerBounds = ManagerFrame.this.getBounds(); if ( ManagerFrame.this.getExtendedState() == JFrame.NORMAL ) {
int dividerLoc = splitPane.getDividerLocation(); Rectangle managerBounds = ManagerFrame.this.getBounds();
String geometry = String.format( "x,%d;y,%d;w,%d;h,%d;divider,%d", managerBounds.x, managerBounds.y, managerBounds.width, managerBounds.height, dividerLoc ); int dividerLoc = splitPane.getDividerLocation();
appConfig.setProperty( "manager_geometry", geometry ); String geometry = String.format( "x,%d;y,%d;w,%d;h,%d;divider,%d", managerBounds.x, managerBounds.y, managerBounds.width, managerBounds.height, dividerLoc );
appConfig.setProperty( "manager_geometry", geometry );
}
} }
try { try {
@ -348,7 +350,8 @@ public class ManagerFrame extends JFrame implements ActionListener, HashObserver
this.setMinimumSize( new Dimension( 300, modActionsPanel.getPreferredSize().height+90 ) ); this.setMinimumSize( new Dimension( 300, modActionsPanel.getPreferredSize().height+90 ) );
this.setLocationRelativeTo(null); this.setLocationRelativeTo(null);
setGeometryFromConfig(); if ( appConfig.getProperty( "remember_geometry" ).equals( "true" ) )
setGeometryFromConfig();
showAboutInfo(); showAboutInfo();
} }