Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.vhati.modmanager</groupId>
<artifactId>ftl-mod-manager</artifactId>
<version>1.9.1</version>
<version>1.9.1.1</version>
<name>Slipstream Mod Manager</name>

<!-- Determined by mvn versions:display-plugin-updates -->
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/vhati/modmanager/FTLModManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ private static void guiInit() {
props.setProperty( SlipstreamConfig.ALLOW_ZIP, "false" );
props.setProperty( SlipstreamConfig.FTL_DATS_PATH, "" ); // Prompt.
props.setProperty( SlipstreamConfig.STEAM_DISTRO, "" ); // Prompt.
props.setProperty( SlipstreamConfig.ASSUME_FTL_1_6_9, "true" );
props.setProperty( SlipstreamConfig.STEAM_EXE_PATH, "" ); // Prompt.
props.setProperty( SlipstreamConfig.RUN_STEAM_FTL, "" ); // Prompt.
props.setProperty( SlipstreamConfig.NEVER_RUN_FTL, "false" );
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/vhati/modmanager/cli/SlipstreamCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ public void uncaughtException( Thread t, Throwable e ) {
DelayedDeleteHook deleteHook = new DelayedDeleteHook();
Runtime.getRuntime().addShutdownHook( deleteHook );

File configFile = new File( "modman.cfg" );
SlipstreamConfig appConfig = getConfig( configFile );

if ( slipstreamCmd.validate ) { // Exits (0/1).
log.info( "Validating..." );

Expand Down Expand Up @@ -117,7 +120,7 @@ public void uncaughtException( Thread t, Throwable e ) {
}
}

Report validateReport = ModUtilities.validateModFile( modFile );
Report validateReport = ModUtilities.validateModFile( modFile, appConfig );

formatter.format( validateReport.messages, resultBuf, 0 );
resultBuf.append( "\n" );
Expand All @@ -133,13 +136,10 @@ public void uncaughtException( Thread t, Throwable e ) {
System.exit( anyInvalid ? 1 : 0 );
}

File configFile = new File( "modman.cfg" );
SlipstreamConfig appConfig = getConfig( configFile );

if ( slipstreamCmd.listMods ) { // Exits.
log.info( "Listing mods..." );

boolean allowZip = appConfig.getProperty( SlipstreamConfig.ALLOW_ZIP, "false" ).equals( "true" );
boolean allowZip = appConfig.getProperyAsBoolean( SlipstreamConfig.ALLOW_ZIP );
File[] modFiles = modsDir.listFiles( new ModAndDirFileFilter( allowZip, true ) );
List<String> dirList = new ArrayList<String>();
List<String> fileList = new ArrayList<String>();
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/net/vhati/modmanager/core/ModUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.zip.ZipInputStream;

import ar.com.hjg.pngj.PngReader;
import java.nio.Buffer;

import org.jdom2.Content;
import org.jdom2.Document;
Expand Down Expand Up @@ -128,7 +129,7 @@ public static DecodeResult decodeText( InputStream is, String description ) thro
Map<String,Exception> errorMap = new LinkedHashMap<String,Exception>();
for ( String guess : new String[] {"UTF-8", "windows-1252"} ) {
try {
byteBuffer.rewind();
((Buffer)byteBuffer).rewind();
byteBuffer.limit( allBytes.length );
CharsetDecoder decoder = Charset.forName( guess ).newDecoder();
result = decoder.decode( byteBuffer ).toString();
Expand Down Expand Up @@ -433,8 +434,9 @@ public static boolean isJunkFile( String innerPath ) {
* Checks a mod file for common problems.
*
* @param modFile an *.ftl file to check
* @param config app configuration
*/
public static Report validateModFile( File modFile ) {
public static Report validateModFile( File modFile, SlipstreamConfig config ) {

List<ReportMessage> messages = new ArrayList<ReportMessage>();
List<ReportMessage> pendingMsgs = new ArrayList<ReportMessage>();
Expand Down Expand Up @@ -499,7 +501,8 @@ else if ( isJunkFile( innerPath ) ) {
) );
modValid = false;
}
else if ( innerPath.matches( "^.*[.]font$" ) ) {
else if ( ! config.getProperyAsBoolean(SlipstreamConfig.ASSUME_FTL_1_6_9)
&& innerPath.matches( "^.*[.]font$" ) ) {
pendingMsgs.add( new ReportMessage(
ReportMessage.WARNING,
String.format( "The *.font files introduced with FTL 1.6.1 won't work in FTL 1.01-1.5.13, which used TTF fonts." )
Expand Down Expand Up @@ -624,7 +627,7 @@ else if ( isTxt ) {
String.format( "Windows-1252 encoding with fancy non-ASCII chars (UTF-8 is recommended for clarity): %s", charBuf.toString() )
) );
}
else {
else if (! config.getProperyAsBoolean(SlipstreamConfig.ASSUME_FTL_1_6_9)) {
// Not windows-1252.
// Nag if there are chars that can't be converted to
// windows-1252 (for FTL 1.01-1.5.13).
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/net/vhati/modmanager/core/SlipstreamConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class SlipstreamConfig {
public static final String ALLOW_ZIP = "allow_zip";
public static final String FTL_DATS_PATH = "ftl_dats_path";
public static final String STEAM_DISTRO = "steam_distro";
public static final String ASSUME_FTL_1_6_9 = "assume_ftl_1_6_9";
public static final String STEAM_EXE_PATH = "steam_exe_path";
public static final String RUN_STEAM_FTL = "run_steam_ftl";
public static final String NEVER_RUN_FTL = "never_run_ftl";
Expand Down Expand Up @@ -62,6 +63,10 @@ public int getPropertyAsInt( String key, int defaultValue ) {
return defaultValue;
}

public boolean getProperyAsBoolean( String key ) {
return config.getProperty( key, "false" ).equals( "true" );
}

public String getProperty( String key, String defaultValue ) {
return config.getProperty( key, defaultValue );
}
Expand All @@ -83,6 +88,7 @@ public void writeConfig() throws IOException {
userFieldsMap.put( ALLOW_ZIP, "Sets whether to treat .zip files as .ftl files. Default: false." );
userFieldsMap.put( FTL_DATS_PATH, "The path to FTL's resources folder. If invalid, you'll be prompted." );
userFieldsMap.put( STEAM_DISTRO, "If true, FTL was installed via Steam. Stops the GUI asking for a path." );
userFieldsMap.put( ASSUME_FTL_1_6_9, "Only perform checks that are relevant to FTL 1.6.9+" );
userFieldsMap.put( STEAM_EXE_PATH, "The path to Steam's executable, if FTL was installed via Steam." );
userFieldsMap.put( RUN_STEAM_FTL, "If true, SMM will use Steam to launch FTL, if possible." );
userFieldsMap.put( NEVER_RUN_FTL, "If true, there will be no offer to run FTL after patching. Default: false." );
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/vhati/modmanager/ui/ManagerFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ else if ( source == validateBtn ) {
boolean anyInvalid = false;

for ( ModFileInfo modFileInfo : modsTablePanel.getSelectedItems() ) {
Report validateReport = ModUtilities.validateModFile( modFileInfo.getFile() );
Report validateReport = ModUtilities.validateModFile( modFileInfo.getFile(), appConfig );

ReportFormatter formatter = new ReportFormatter();
formatter.format( validateReport.messages, resultBuf, 0 );
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/vhati/modmanager/ui/ModXMLSandbox.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import javax.swing.text.Caret;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import javax.swing.undo.CannotRedoException;
import javax.swing.undo.UndoManager;
Expand Down Expand Up @@ -535,9 +536,9 @@ private void buildTreeFromString( DefaultTreeModel treeModel, String path ) {
chunk += "/";

boolean found = false;
Enumeration<DefaultMutableTreeNode> enumIt = currentNode.children();
Enumeration<TreeNode> enumIt = currentNode.children();
while ( enumIt.hasMoreElements() ) {
DefaultMutableTreeNode tmpNode = enumIt.nextElement();
DefaultMutableTreeNode tmpNode = (DefaultMutableTreeNode)enumIt.nextElement();
if ( chunk.equals( tmpNode.getUserObject() ) ) {
found = true;
currentNode = tmpNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
public class SlipstreamConfigDialog extends JDialog implements ActionListener {

protected static final String ALLOW_ZIP = SlipstreamConfig.ALLOW_ZIP;
protected static final String ASSUME_FTL_1_6_9 = SlipstreamConfig.ASSUME_FTL_1_6_9;
protected static final String RUN_STEAM_FTL = SlipstreamConfig.RUN_STEAM_FTL;
protected static final String NEVER_RUN_FTL = SlipstreamConfig.NEVER_RUN_FTL;
protected static final String USE_DEFAULT_UI = SlipstreamConfig.USE_DEFAULT_UI;
Expand Down Expand Up @@ -58,6 +59,9 @@ public SlipstreamConfigDialog( Frame owner, SlipstreamConfig appConfig ) {
editorPanel.addRow( ALLOW_ZIP, ContentType.BOOLEAN );
editorPanel.addTextRow( "Treat .zip files as .ftl files." );
editorPanel.addSeparatorRow();
editorPanel.addRow( ASSUME_FTL_1_6_9, ContentType.BOOLEAN );
editorPanel.addTextRow( "Only perform checks that are relevant to FTL 1.6.9+." );
editorPanel.addSeparatorRow();
editorPanel.addRow( RUN_STEAM_FTL, ContentType.BOOLEAN );
editorPanel.addTextRow( "Use Steam to run FTL, if possible." );
editorPanel.addSeparatorRow();
Expand Down Expand Up @@ -88,6 +92,7 @@ public SlipstreamConfigDialog( Frame owner, SlipstreamConfig appConfig ) {
editorPanel.addFillRow();

editorPanel.getBoolean( ALLOW_ZIP ).setSelected( "true".equals( appConfig.getProperty( SlipstreamConfig.ALLOW_ZIP, "false" ) ) );
editorPanel.getBoolean( ASSUME_FTL_1_6_9 ).setSelected( "true".equals( appConfig.getProperty( SlipstreamConfig.ASSUME_FTL_1_6_9, "true" ) ) );
editorPanel.getBoolean( RUN_STEAM_FTL ).setSelected( "true".equals( appConfig.getProperty( SlipstreamConfig.RUN_STEAM_FTL, "false" ) ) );
editorPanel.getBoolean( NEVER_RUN_FTL ).setSelected( "true".equals( appConfig.getProperty( SlipstreamConfig.NEVER_RUN_FTL, "false" ) ) );
editorPanel.getBoolean( USE_DEFAULT_UI ).setSelected( "true".equals( appConfig.getProperty( SlipstreamConfig.USE_DEFAULT_UI, "false" ) ) );
Expand Down Expand Up @@ -149,6 +154,7 @@ public void actionPerformed( ActionEvent e ) {
if ( source == applyBtn ) {
String tmp;
appConfig.setProperty( SlipstreamConfig.ALLOW_ZIP, editorPanel.getBoolean( ALLOW_ZIP ).isSelected() ? "true" : "false" );
appConfig.setProperty( SlipstreamConfig.ASSUME_FTL_1_6_9, editorPanel.getBoolean( ASSUME_FTL_1_6_9 ).isSelected() ? "true" : "false" );
appConfig.setProperty( SlipstreamConfig.RUN_STEAM_FTL, editorPanel.getBoolean( RUN_STEAM_FTL ).isSelected() ? "true" : "false" );
appConfig.setProperty( SlipstreamConfig.NEVER_RUN_FTL, editorPanel.getBoolean( NEVER_RUN_FTL ).isSelected() ? "true" : "false" );
appConfig.setProperty( SlipstreamConfig.USE_DEFAULT_UI, editorPanel.getBoolean( USE_DEFAULT_UI ).isSelected() ? "true" : "false" );
Expand Down