Added *.xml.rawclobber suffix to preserve whitespace
This commit is contained in:
parent
0fa72e5779
commit
ae2cb23cbf
4 changed files with 40 additions and 5 deletions
|
@ -15,7 +15,7 @@ Changelog
|
||||||
- Added a Validate warning for junk files named '.dropbox'
|
- Added a Validate warning for junk files named '.dropbox'
|
||||||
- Added a check during patching to skip junk files
|
- Added a check during patching to skip junk files
|
||||||
- Added an error popup when the jar is double-clicked
|
- Added an error popup when the jar is double-clicked
|
||||||
- Added *.xml.rawappend suffix to preserve whitespace in 'misc.xml'
|
- Added rawappend/rawclobber suffixes to preserve whitespace in 'misc.xml'
|
||||||
- Minor optimizations to reduce memory usage
|
- Minor optimizations to reduce memory usage
|
||||||
- Added uncaught exception handling for background threads
|
- Added uncaught exception handling for background threads
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ Advanced XML
|
||||||
edit in the wake of earlier ones.
|
edit in the wake of earlier ones.
|
||||||
|
|
||||||
|
|
||||||
Raw Appending
|
Raw XML
|
||||||
|
|
||||||
FTL is quirky. Occasionally you may need to include non-standard XML in a
|
FTL is quirky. Occasionally you may need to include non-standard XML in a
|
||||||
mod without elaborate parsing. For instance, "misc.xml" defines phrases
|
mod without elaborate parsing. For instance, "misc.xml" defines phrases
|
||||||
|
@ -210,7 +210,13 @@ Raw Appending
|
||||||
(mis)understand the tags of either file.
|
(mis)understand the tags of either file.
|
||||||
|
|
||||||
You can still override existing tags by adding your own with the same
|
You can still override existing tags by adding your own with the same
|
||||||
name attribute.
|
name attribute, since FTL honors the last it sees.
|
||||||
|
|
||||||
|
Similarly a file named "misc.xml.rawclobber" will entirely replace the
|
||||||
|
original "misc.xml".
|
||||||
|
|
||||||
|
Any other mods patched afterward must either avoid that file or also treat
|
||||||
|
it as raw themselves. Hence this should be used as a last resort.
|
||||||
|
|
||||||
|
|
||||||
Commandline
|
Commandline
|
||||||
|
|
|
@ -281,6 +281,28 @@ public class ModPatchThread extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ( fileName.endsWith( ".xml.rawclobber" ) || fileName.endsWith( ".rawclobber.xml" ) ) {
|
||||||
|
innerPath = checkCase( innerPath, knownPaths, knownPathsLower );
|
||||||
|
|
||||||
|
log.warn( String.format( "Copying xml as raw text: %s", innerPath ) );
|
||||||
|
|
||||||
|
// Normalize line endings to CR-LF.
|
||||||
|
// decodeText() reads anything and returns an LF string.
|
||||||
|
String fixedText = ModUtilities.decodeText( zis, modFile.getName()+":"+parentPath+fileName ).text;
|
||||||
|
fixedText = Pattern.compile("\n").matcher( fixedText ).replaceAll( "\r\n" );
|
||||||
|
|
||||||
|
InputStream fixedStream = ModUtilities.encodeText( fixedText, "windows-1252", modFile.getName()+":"+parentPath+fileName+" (with new EOL)" );
|
||||||
|
|
||||||
|
if ( !moddedItems.contains(innerPath) ) {
|
||||||
|
moddedItems.add( innerPath );
|
||||||
|
} else {
|
||||||
|
log.warn( String.format( "Clobbering earlier mods: %s", innerPath ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ftlP.contains( innerPath ) )
|
||||||
|
ftlP.remove( innerPath );
|
||||||
|
ftlP.add( innerPath, fixedStream );
|
||||||
|
}
|
||||||
else if ( fileName.endsWith( ".xml" ) ) {
|
else if ( fileName.endsWith( ".xml" ) ) {
|
||||||
innerPath = checkCase( innerPath, knownPaths, knownPathsLower );
|
innerPath = checkCase( innerPath, knownPaths, knownPathsLower );
|
||||||
|
|
||||||
|
|
|
@ -457,11 +457,18 @@ public class ModUtilities {
|
||||||
modValid = false;
|
modValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( innerPath.matches( "^.*(?:[.]xml[.]append|[.]append[.]xml|[.]xml[.]rawappend|[.]rawappend[.]xml|[.]xml|[.]txt)$" ) ) {
|
else if ( innerPath.matches( "^.*(?:[.]xml[.]append|[.]append[.]xml)$" ) ||
|
||||||
|
innerPath.matches( "^.*(?:[.]xml[.]rawappend|[.]rawappend[.]xml)$" ) ||
|
||||||
|
innerPath.matches( "^.*(?:[.]xml[.]rawclobber|[.]rawclobber[.]xml)$" ) ||
|
||||||
|
innerPath.matches( "^.*(?:[.]xml|[.]txt)$" ) ) {
|
||||||
|
|
||||||
boolean isTxt = innerPath.matches( "^.*(?:[.]txt)$" );
|
boolean isTxt = innerPath.matches( "^.*(?:[.]txt)$" );
|
||||||
boolean isXML = innerPath.matches( "^.*(?:[.]xml[.]append|[.]append[.]xml|[.]xml)$" );
|
boolean isXML = innerPath.matches( "^.*(?:[.]xml[.]append|[.]append[.]xml|[.]xml)$" );
|
||||||
boolean isXMLAppend = innerPath.matches( "^.*(?:[.]xml[.]append|[.]append[.]xml)$" );
|
boolean isXMLAppend = innerPath.matches( "^.*(?:[.]xml[.]append|[.]append[.]xml)$" );
|
||||||
if ( innerPath.matches( "^.*(?:[.]xml[.]rawappend|[.]rawappend[.]xml)$" ) ) {
|
|
||||||
|
if ( innerPath.matches( "^.*(?:[.]xml[.]rawappend|[.]rawappend[.]xml)$" ) ||
|
||||||
|
innerPath.matches( "^.*(?:[.]xml[.]rawclobber|[.]rawclobber[.]xml)$" ) ) {
|
||||||
|
|
||||||
isXML = false; // Raw xml is exempt from normal processing.
|
isXML = false; // Raw xml is exempt from normal processing.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue