Added '--global-panic' commandline arg
This commit is contained in:
parent
60971d4abe
commit
2bf3860cbc
8 changed files with 49 additions and 10 deletions
|
@ -5,6 +5,8 @@ Changelog
|
|||
- Fixed advanced find tags' panic arg (was "true" all the time)
|
||||
- Fixed advanced selector tag not narrowing results when it had a value
|
||||
- Fixed perpetually green "Update" button
|
||||
- Added --global-panic commandline arg to show mod devs typoed find tags
|
||||
- Added commandline tips in readme_modders.txt
|
||||
|
||||
1.2:
|
||||
- Added a commandline interface
|
||||
|
|
|
@ -191,6 +191,25 @@ Advanced XML
|
|||
edit in the wake of earlier ones.
|
||||
|
||||
|
||||
Commandline
|
||||
|
||||
Running Slipstream from a prompt can speed up development...
|
||||
|
||||
--patch Abc.ftl Def "Ghi 1.0.ftl"
|
||||
|
||||
Patches named mod files. Dirs can also be named, so you won't have to
|
||||
re-zip for every test.
|
||||
|
||||
--global-panic
|
||||
|
||||
While patching, reveals typoed <find...> tags. Any find that yields no
|
||||
matches will cause an error, as if it had panic='true'.
|
||||
|
||||
--runftl
|
||||
|
||||
Runs the game. If used with "--patch", runs afterward if successful.
|
||||
|
||||
|
||||
Pitfalls
|
||||
|
||||
FTL Bug (fixed in 1.03.3): If a ship is modded to have level 5 shields,
|
||||
|
|
|
@ -56,11 +56,14 @@ public class SlipstreamCLI {
|
|||
.hasArg()
|
||||
.withArgName("DIR")
|
||||
.create() );
|
||||
options.addOption( OptionBuilder.withLongOpt( "global-panic" )
|
||||
.withDescription( "patch as if advanced find tags had panic='true'" )
|
||||
.create() );
|
||||
options.addOption( OptionBuilder.withLongOpt( "list-mods" )
|
||||
.withDescription( "list available mod names" )
|
||||
.create() );
|
||||
options.addOption( OptionBuilder.withLongOpt( "runftl" )
|
||||
.withDescription( "run the game" )
|
||||
.withDescription( "run the game (standalone or with 'patch')" )
|
||||
.create() );
|
||||
options.addOption( OptionBuilder.withLongOpt( "patch" )
|
||||
.withDescription( "revert to vanilla and add named mods (if any)" )
|
||||
|
@ -259,8 +262,10 @@ public class SlipstreamCLI {
|
|||
resDat.datFile = new File( datsDir, "resource.dat" );
|
||||
resDat.bakFile = new File( backupDir, "resource.dat.bak" );
|
||||
|
||||
boolean globalPanic = cmdline.hasOption( "global-panic" );
|
||||
|
||||
SilentPatchObserver patchObserver = new SilentPatchObserver();
|
||||
ModPatchThread patchThread = new ModPatchThread( modFiles, dataDat, resDat, patchObserver );
|
||||
ModPatchThread patchThread = new ModPatchThread( modFiles, dataDat, resDat, globalPanic, patchObserver );
|
||||
deleteHook.addWatchedThread( patchThread );
|
||||
|
||||
patchThread.start();
|
||||
|
|
|
@ -37,6 +37,7 @@ public class ModPatchThread extends Thread {
|
|||
private List<File> modFiles = new ArrayList<File>();
|
||||
private BackedUpDat dataDat = null;
|
||||
private BackedUpDat resDat = null;
|
||||
private boolean globalPanic = false;
|
||||
private ModPatchObserver observer = null;
|
||||
|
||||
private final int progMax = 100;
|
||||
|
@ -46,10 +47,11 @@ public class ModPatchThread extends Thread {
|
|||
private final int progRepackMax = 5;
|
||||
private int progMilestone = 0;
|
||||
|
||||
public ModPatchThread( List<File> modFiles, BackedUpDat dataDat, BackedUpDat resDat, ModPatchObserver observer ) {
|
||||
public ModPatchThread( List<File> modFiles, BackedUpDat dataDat, BackedUpDat resDat, boolean globalPanic, ModPatchObserver observer ) {
|
||||
this.modFiles.addAll( modFiles );
|
||||
this.dataDat = dataDat;
|
||||
this.resDat = resDat;
|
||||
this.globalPanic = globalPanic;
|
||||
this.observer = observer;
|
||||
}
|
||||
|
||||
|
@ -223,7 +225,7 @@ public class ModPatchThread extends Thread {
|
|||
InputStream mainStream = null;
|
||||
try {
|
||||
mainStream = ftlP.getInputStream(innerPath);
|
||||
InputStream mergedStream = ModUtilities.patchXMLFile( mainStream, zis, "windows-1252", ftlP.getName()+":"+innerPath, modFile.getName()+":"+parentPath+fileName );
|
||||
InputStream mergedStream = ModUtilities.patchXMLFile( mainStream, zis, "windows-1252", globalPanic, ftlP.getName()+":"+innerPath, modFile.getName()+":"+parentPath+fileName );
|
||||
mainStream.close();
|
||||
ftlP.remove( innerPath );
|
||||
ftlP.add( innerPath, mergedStream );
|
||||
|
|
|
@ -207,7 +207,7 @@ public class ModUtilities {
|
|||
* @see net.vhati.modmanager.core.XMLPatcher
|
||||
* @see net.vhati.modmanager.core.SloppyXMLOutputProcessor
|
||||
*/
|
||||
public static InputStream patchXMLFile( InputStream mainStream, InputStream appendStream, String encoding, String mainDescription, String appendDescription ) throws IOException, JDOMException {
|
||||
public static InputStream patchXMLFile( InputStream mainStream, InputStream appendStream, String encoding, boolean globalPanic, String mainDescription, String appendDescription ) throws IOException, JDOMException {
|
||||
Pattern xmlDeclPtn = Pattern.compile( "<[?]xml [^>]*?[?]>\n*" );
|
||||
|
||||
String mainText = decodeText( mainStream, mainDescription ).text;
|
||||
|
@ -221,6 +221,7 @@ public class ModUtilities {
|
|||
Document appendDoc = parseStrictOrSloppyXML( appendText, appendDescription+" (wrapped)" );
|
||||
|
||||
XMLPatcher patcher = new XMLPatcher();
|
||||
patcher.setGlobalPanic( globalPanic );
|
||||
Document mergedDoc = patcher.patch( mainDoc, appendDoc );
|
||||
|
||||
StringWriter writer = new StringWriter();
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.jdom2.input.SAXBuilder;
|
|||
*/
|
||||
public class XMLPatcher {
|
||||
|
||||
protected boolean globalPanic = false;
|
||||
protected Namespace modNS;
|
||||
protected Namespace modAppendNS;
|
||||
protected Namespace modOverwriteNS;
|
||||
|
@ -47,6 +48,10 @@ public class XMLPatcher {
|
|||
modOverwriteNS = Namespace.getNamespace( "mod-overwrite", "mod-overwrite" );
|
||||
}
|
||||
|
||||
public void setGlobalPanic( boolean b ) {
|
||||
globalPanic = b;
|
||||
}
|
||||
|
||||
|
||||
public Document patch( Document mainDoc, Document appendDoc ) {
|
||||
Document resultDoc = mainDoc.clone();
|
||||
|
@ -100,6 +105,7 @@ public class XMLPatcher {
|
|||
int searchStart = getAttributeIntValue( node, "start", 0 );
|
||||
int searchLimit = getAttributeIntValue( node, "limit", 1 );
|
||||
boolean panic = getAttributeBooleanValue( node, "panic", false );
|
||||
if ( globalPanic ) panic = true;
|
||||
|
||||
if ( searchName == null || searchName.length() == 0 )
|
||||
throw new IllegalArgumentException( String.format( "<%s> requires a name attribute (%s).", node.getName(), getPathToRoot(node) ) );
|
||||
|
@ -136,6 +142,7 @@ public class XMLPatcher {
|
|||
int searchStart = getAttributeIntValue( node, "start", 0 );
|
||||
int searchLimit = getAttributeIntValue( node, "limit", -1 );
|
||||
boolean panic = getAttributeBooleanValue( node, "panic", false );
|
||||
if ( globalPanic ) panic = true;
|
||||
|
||||
if ( searchType != null && searchType.length() == 0 )
|
||||
throw new IllegalArgumentException( String.format( "<%s> type attribute, when present, can't be empty (%s).", node.getName(), getPathToRoot(node) ) );
|
||||
|
@ -188,6 +195,7 @@ public class XMLPatcher {
|
|||
int searchStart = getAttributeIntValue( node, "start", 0 );
|
||||
int searchLimit = getAttributeIntValue( node, "limit", -1 );
|
||||
boolean panic = getAttributeBooleanValue( node, "panic", false );
|
||||
if ( globalPanic ) panic = true;
|
||||
|
||||
if ( searchType != null && searchType.length() == 0 )
|
||||
throw new IllegalArgumentException( String.format( "<%s> type attribute, when present, can't be empty (%s).", node.getName(), getPathToRoot(node) ) );
|
||||
|
@ -237,6 +245,7 @@ public class XMLPatcher {
|
|||
int searchStart = getAttributeIntValue( node, "start", 0 );
|
||||
int searchLimit = getAttributeIntValue( node, "limit", -1 );
|
||||
boolean panic = getAttributeBooleanValue( node, "panic", false );
|
||||
if ( globalPanic ) panic = true;
|
||||
|
||||
if ( searchStart < 0 )
|
||||
throw new IllegalArgumentException( String.format( "<%s> 'start' attribute is not >= 0 (%s).", node.getName(), getPathToRoot(node) ) );
|
||||
|
|
|
@ -818,7 +818,7 @@ public class ManagerFrame extends JFrame implements ActionListener, HashObserver
|
|||
log.info( "" );
|
||||
log.info( "Patching..." );
|
||||
log.info( "" );
|
||||
ModPatchThread patchThread = new ModPatchThread( modFiles, dataDat, resDat, patchDlg );
|
||||
ModPatchThread patchThread = new ModPatchThread( modFiles, dataDat, resDat, false, patchDlg );
|
||||
patchThread.start();
|
||||
|
||||
patchDlg.setVisible( true );
|
||||
|
|
|
@ -373,6 +373,7 @@ public class ModXMLSandbox extends JFrame implements ActionListener {
|
|||
Document appendDoc = ModUtilities.parseStrictOrSloppyXML( appendText, "Sandbox Append XML" );
|
||||
|
||||
XMLPatcher patcher = new XMLPatcher();
|
||||
patcher.setGlobalPanic( false );
|
||||
Document resultDoc = patcher.patch( mainDoc, appendDoc );
|
||||
|
||||
StringWriter writer = new StringWriter();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue