Made the comments in boilerplace mod metadata optional

This commit is contained in:
Vhati 2017-12-26 22:22:46 -05:00
parent 1590a70627
commit 8038ba2f56
4 changed files with 84 additions and 61 deletions

View file

@ -16,6 +16,7 @@
"hidden" : true,
"changes" : [
"Edited a comment in boilerplate mod metadata to include AE ships",
"Made the comments in boilerplace mod metadata optional",
"Fixed omitted Validate warnings for PNG files",
"Added Validate warnings about FTL 1.6.1+ for TTF, MP3, and PNG files"
]

View file

@ -2,6 +2,7 @@ Changelog
1.9.1:
- Edited a comment in boilerplate mod metadata to include AE ships
- Made the comments in boilerplace mod metadata optional
- Fixed omitted Validate warnings for PNG files
- Added Validate warnings about FTL 1.6.1+ for TTF, MP3, and PNG files

View file

@ -40,6 +40,7 @@ public class CreateModDialog extends JDialog implements ActionListener {
protected static final String DATA_ROOT = "data/";
protected static final String FONTS_ROOT = "fonts/";
protected static final String IMG_ROOT = "img/";
protected static final String XML_COMMENTS = "XML Comments";
protected static final String TITLE = "Title";
protected static final String URL = "Thread URL";
protected static final String AUTHOR = "Author";
@ -77,6 +78,10 @@ public class CreateModDialog extends JDialog implements ActionListener {
editorPanel.getBoolean( IMG_ROOT ).setHorizontalAlignment( javax.swing.SwingConstants.LEFT );
editorPanel.addTextRow( "Create empty top-level directories?" );
editorPanel.addSeparatorRow();
editorPanel.addRow( XML_COMMENTS, ContentType.BOOLEAN );
editorPanel.getBoolean( XML_COMMENTS ).setHorizontalAlignment( javax.swing.SwingConstants.LEFT );
editorPanel.addTextRow( "Include XML comments about the purpose of these fields?" );
editorPanel.addSeparatorRow();
editorPanel.addRow( TITLE, ContentType.STRING );
editorPanel.addTextRow( "The title of this mod." );
editorPanel.addSeparatorRow();
@ -93,6 +98,8 @@ public class CreateModDialog extends JDialog implements ActionListener {
editorPanel.getTextArea( DESC ).setRows( 15 );
editorPanel.addTextRow( "Summary of gameplay effects; flavor; features; concerns about compatibility, recommended patch order, requirements; replaced ship slot; etc." );
editorPanel.getBoolean( XML_COMMENTS ).setSelected( true );
JPanel ctrlPanel = new JPanel();
ctrlPanel.setLayout( new BoxLayout( ctrlPanel, BoxLayout.X_AXIS ) );
ctrlPanel.setBorder( BorderFactory.createEmptyBorder( 10, 0, 10, 0 ) );
@ -141,6 +148,7 @@ public class CreateModDialog extends JDialog implements ActionListener {
String modAuthor = editorPanel.getString( AUTHOR ).getText().trim();
String modVersion = editorPanel.getString( VERSION ).getText().trim();
String modDesc = editorPanel.getTextArea( DESC ).getText().trim();
boolean xmlComments = editorPanel.getBoolean( XML_COMMENTS ).isSelected();
if ( dirName.length() == 0 ) {
JOptionPane.showMessageDialog( CreateModDialog.this, "No directory name was given.", "Nothing to do", JOptionPane.WARNING_MESSAGE );
@ -156,7 +164,7 @@ public class CreateModDialog extends JDialog implements ActionListener {
if ( appendixDir.mkdir() ) {
File metadataFile = new File( appendixDir, "metadata.xml" );
JDOMModMetadataWriter.writeMetadata( metadataFile, modTitle, modURL, modAuthor, modVersion, modDesc );
JDOMModMetadataWriter.writeMetadata( metadataFile, modTitle, modURL, modAuthor, modVersion, modDesc, xmlComments );
}
else {
throw new IOException( String.format( "Failed to create directory: %s", appendixDir.getName() ) );

View file

@ -28,8 +28,9 @@ public class JDOMModMetadataWriter {
* @param modAuthor
* @param modVersion
* @param modDesc
* @param xmlComments true to include comments describing each field, false otherwise
*/
public static void writeMetadata( File outFile, String modTitle, String modURL, String modAuthor, String modVersion, String modDesc ) throws IOException {
public static void writeMetadata( File outFile, String modTitle, String modURL, String modAuthor, String modVersion, String modDesc, boolean xmlComments ) throws IOException {
StringBuilder buf = new StringBuilder();
Element rootNode = new Element( "metadata" );
@ -37,19 +38,23 @@ public class JDOMModMetadataWriter {
rootNode.addContent( new Text( "\n" ) );
rootNode.addContent( new Text( "\t" ) );
buf.setLength( 0 );
buf.append( "\n" );
buf.append( "\t\tCDATA tags mean no need to escape special characters.\n" );
buf.append( "\t\tDon't worry about spaces at the start/end. That gets trimmed.\n" );
buf.append( "\t" );
rootNode.addContent( new Comment( buf.toString() ) );
rootNode.addContent( new Text( "\n\n\n" ) );
if ( xmlComments ) {
buf.setLength( 0 );
buf.append( "\n" );
buf.append( "\t\tCDATA tags mean no need to escape special characters.\n" );
buf.append( "\t\tDon't worry about spaces at the start/end. That gets trimmed.\n" );
buf.append( "\t" );
rootNode.addContent( new Text( "\t" ) );
rootNode.addContent( new Comment( buf.toString() ) );
rootNode.addContent( new Text( "\n\n\n" ) );
}
// title.
rootNode.addContent( new Text( "\t" ) );
rootNode.addContent( new Comment( String.format( " %s ", "The title of this mod." ) ) );
rootNode.addContent( new Text( "\n" ) );
if ( xmlComments ) {
rootNode.addContent( new Text( "\t" ) );
rootNode.addContent( new Comment( String.format( " %s ", "The title of this mod." ) ) );
rootNode.addContent( new Text( "\n" ) );
}
rootNode.addContent( new Text( "\t" ) );
Element titleNode = new Element( "title" );
@ -58,15 +63,17 @@ public class JDOMModMetadataWriter {
rootNode.addContent( new Text( "\n\n\n" ) );
// threadUrl.
rootNode.addContent( new Text( "\t" ) );
buf.setLength( 0 );
buf.append( "\n" );
buf.append( "\t\tThis mod's thread on subsetgames.com.\n" );
buf.append( "\t\tIf there's no thread yet, create one to announce your upcoming mod in the\n" );
buf.append( "\t\tforum. Then paste the url here.\n" );
buf.append( "\t" );
rootNode.addContent( new Comment( buf.toString() ) );
rootNode.addContent( new Text( "\n" ) );
if ( xmlComments ) {
buf.setLength( 0 );
buf.append( "\n" );
buf.append( "\t\tThis mod's thread on subsetgames.com.\n" );
buf.append( "\t\tIf there's no thread yet, create one to announce your upcoming mod in the\n" );
buf.append( "\t\tforum. Then paste the url here.\n" );
buf.append( "\t" );
rootNode.addContent( new Text( "\t" ) );
rootNode.addContent( new Comment( buf.toString() ) );
rootNode.addContent( new Text( "\n" ) );
}
rootNode.addContent( new Text( "\t" ) );
Element urlNode = new Element( "threadUrl" );
@ -75,9 +82,11 @@ public class JDOMModMetadataWriter {
rootNode.addContent( new Text( "\n\n\n" ) );
// author.
rootNode.addContent( new Text( "\t" ) );
rootNode.addContent( new Comment( String.format( " %s ", "Your forum user name." ) ) );
rootNode.addContent( new Text( "\n" ) );
if ( xmlComments ) {
rootNode.addContent( new Text( "\t" ) );
rootNode.addContent( new Comment( String.format( " %s ", "Your forum user name." ) ) );
rootNode.addContent( new Text( "\n" ) );
}
rootNode.addContent( new Text( "\t" ) );
Element authorNode = new Element( "author" );
@ -86,18 +95,20 @@ public class JDOMModMetadataWriter {
rootNode.addContent( new Text( "\n\n\n" ) );
// version.
rootNode.addContent( new Text( "\t" ) );
buf.setLength( 0 );
buf.append( "\n" );
buf.append( "\t\tThe revision/variant of this release, preferably at least a number.\n" );
buf.append( "\t\tExamples:\n" );
buf.append( "\t\t\t0.3\n" );
buf.append( "\t\t\t2.1c Ships Only WIP\n" );
buf.append( "\t\t\t2.4.1 Hi-res Bkgs\n" );
buf.append( "\t\t\t1.0 for FTL 1.03.1\n" );
buf.append( "\t" );
rootNode.addContent( new Comment( buf.toString() ) );
rootNode.addContent( new Text( "\n" ) );
if ( xmlComments ) {
buf.setLength( 0 );
buf.append( "\n" );
buf.append( "\t\tThe revision/variant of this release, preferably at least a number.\n" );
buf.append( "\t\tExamples:\n" );
buf.append( "\t\t\t0.3\n" );
buf.append( "\t\t\t2.1c Ships Only WIP\n" );
buf.append( "\t\t\t2.4.1 Hi-res Bkgs\n" );
buf.append( "\t\t\t1.0 for FTL 1.03.1\n" );
buf.append( "\t" );
rootNode.addContent( new Text( "\t" ) );
rootNode.addContent( new Comment( buf.toString() ) );
rootNode.addContent( new Text( "\n" ) );
}
rootNode.addContent( new Text( "\t" ) );
Element versionNode = new Element( "version" );
@ -115,30 +126,32 @@ public class JDOMModMetadataWriter {
rootNode.addContent( new Text( "\n\n" ) );
rootNode.addContent( new Text( "\t" ) );
buf.setLength( 0 );
buf.append( "\n" );
buf.append( "\t\tSuggestions for the description...\n" );
buf.append( "\n" );
buf.append( "\t\tWrite a short paragraph about the mod's effect first (what style ship, how\n" );
buf.append( "\t\tdoes it affect gameplay). No need to introduce yourself.\n" );
buf.append( "\n" );
buf.append( "\t\tOptionally add a paragraph of background flavor.\n" );
buf.append( "\n" );
buf.append( "\t\tOptionally list important features.\n" );
buf.append( "\n" );
buf.append( "\t\tList any concerns about mod compatibility, preferred order, or requirements.\n" );
buf.append( "\n" );
buf.append( "\t\tMention \"Replaces the XYZ ship.\" if relevant.\n" );
buf.append( "\t\t\tKestrel-A, Engi-A, Fed-A, Zoltan-A,\n" );
buf.append( "\t\t\tStealth-A, Rock-A, Slug-A, Mantis-A,\n" );
buf.append( "\t\t\tLanius-A, Crystal-A\n" );
buf.append( "\n" );
buf.append( "\t\tAbove all, keep the description general, so you won't have to edit\n" );
buf.append( "\t\tthat again for each new version.\n" );
buf.append( "\t" );
rootNode.addContent( new Comment( buf.toString() ) );
rootNode.addContent( new Text( "\n" ) );
if ( xmlComments ) {
buf.setLength( 0 );
buf.append( "\n" );
buf.append( "\t\tSuggestions for the description...\n" );
buf.append( "\n" );
buf.append( "\t\tWrite a short paragraph about the mod's effect first (what style ship, how\n" );
buf.append( "\t\tdoes it affect gameplay). No need to introduce yourself.\n" );
buf.append( "\n" );
buf.append( "\t\tOptionally add a paragraph of background flavor.\n" );
buf.append( "\n" );
buf.append( "\t\tOptionally list important features.\n" );
buf.append( "\n" );
buf.append( "\t\tList any concerns about mod compatibility, preferred order, or requirements.\n" );
buf.append( "\n" );
buf.append( "\t\tMention \"Replaces the XYZ ship.\" if relevant.\n" );
buf.append( "\t\t\tKestrel-A, Engi-A, Fed-A, Zoltan-A,\n" );
buf.append( "\t\t\tStealth-A, Rock-A, Slug-A, Mantis-A,\n" );
buf.append( "\t\t\tLanius-A, Crystal-A\n" );
buf.append( "\n" );
buf.append( "\t\tAbove all, keep the description general, so you won't have to edit\n" );
buf.append( "\t\tthat again for each new version.\n" );
buf.append( "\t" );
rootNode.addContent( new Text( "\t" ) );
rootNode.addContent( new Comment( buf.toString() ) );
rootNode.addContent( new Text( "\n" ) );
}
Format format = Format.getPrettyFormat();
format.setTextMode( Format.TextMode.PRESERVE );