mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
add default editor preferences file so missing preferences will always have a default value
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -12512,6 +12512,7 @@ res/pics_product/tournamentpacks/TMP.jpg -text
|
||||
res/pics_product/tournamentpacks/TSP.jpg -text
|
||||
res/pics_product/tournamentpacks/USG.jpg -text
|
||||
res/preferences/.project -text
|
||||
res/preferences/editor.default.preferences -text svneol=native#application/xml
|
||||
res/preferences/editor.preferences -text
|
||||
res/preferences/main.properties -text
|
||||
res/product-images.txt -text
|
||||
|
||||
34
res/preferences/editor.default.preferences
Normal file
34
res/preferences/editor.default.preferences
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0"?>
|
||||
<preferences type="editor">
|
||||
<pref name="elastic_columns" value="false"></pref>
|
||||
<pref name="display_unique_only" value="true"></pref>
|
||||
<pref name="stats_deck" value="true"></pref>
|
||||
<col enumval="CAT_AI" identifier="AI" show="false" sortpriority="0" sortstate="NONE" width="30"></col>
|
||||
<col enumval="CAT_CMC" identifier="CMC" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
|
||||
<col enumval="CAT_COLOR" identifier="Color" show="true" sortpriority="0" sortstate="NONE" width="55"></col>
|
||||
<col enumval="CAT_COST" identifier="Cost" show="true" sortpriority="0" sortstate="NONE" width="80"></col>
|
||||
<col enumval="CAT_NAME" identifier="Name" show="true" sortpriority="2" sortstate="ASC" width="260"></col>
|
||||
<col enumval="CAT_NEW" identifier="New" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
|
||||
<col enumval="CAT_OWNED" identifier="Owned" show="true" sortpriority="1" sortstate="ASC" width="35"></col>
|
||||
<col enumval="CAT_POWER" identifier="Power" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
|
||||
<col enumval="CAT_PURCHASE_PRICE" identifier="Purchase Price" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
|
||||
<col enumval="CAT_QUANTITY" identifier="Quantity" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
|
||||
<col enumval="CAT_RARITY" identifier="Rarity" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
|
||||
<col enumval="CAT_SET" identifier="Set" show="true" sortpriority="0" sortstate="NONE" width="35"></col>
|
||||
<col enumval="CAT_TOUGHNESS" identifier="Toughness" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
|
||||
<col enumval="CAT_TYPE" identifier="Type" show="true" sortpriority="3" sortstate="ASC" width="220"></col>
|
||||
<col enumval="DECK_AI" identifier="AI" show="false" sortpriority="2" sortstate="ASC" width="30"></col>
|
||||
<col enumval="DECK_CMC" identifier="CMC" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
|
||||
<col enumval="DECK_COLOR" identifier="Color" show="true" sortpriority="0" sortstate="NONE" width="55"></col>
|
||||
<col enumval="DECK_COST" identifier="Cost" show="true" sortpriority="0" sortstate="NONE" width="80"></col>
|
||||
<col enumval="DECK_DECKS" identifier="Decks" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
|
||||
<col enumval="DECK_NAME" identifier="Name" show="true" sortpriority="2" sortstate="ASC" width="260"></col>
|
||||
<col enumval="DECK_NEW" identifier="New" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
|
||||
<col enumval="DECK_POWER" identifier="Power" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
|
||||
<col enumval="DECK_QUANTITY" identifier="Quantity" show="true" sortpriority="3" sortstate="DESC" width="30"></col>
|
||||
<col enumval="DECK_RARITY" identifier="Rarity" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
|
||||
<col enumval="DECK_SALE_PRICE" identifier="Sale Price" show="true" sortpriority="0" sortstate="NONE" width="40"></col>
|
||||
<col enumval="DECK_SET" identifier="Set" show="true" sortpriority="0" sortstate="NONE" width="35"></col>
|
||||
<col enumval="DECK_TOUGHNESS" identifier="Toughness" show="true" sortpriority="0" sortstate="NONE" width="30"></col>
|
||||
<col enumval="DECK_TYPE" identifier="Type" show="true" sortpriority="1" sortstate="ASC" width="220"></col>
|
||||
</preferences>
|
||||
@@ -16,6 +16,7 @@ import javax.xml.stream.XMLEventReader;
|
||||
import javax.xml.stream.XMLEventWriter;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLOutputFactory;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.events.Attribute;
|
||||
import javax.xml.stream.events.StartElement;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
@@ -268,12 +269,20 @@ public class SEditorIO {
|
||||
} // END TEMPORARY CONSOLIDATION FACILITATION
|
||||
|
||||
final XMLInputFactory inputFactory = XMLInputFactory.newInstance();
|
||||
final String fileAddress = NewConstants.PREFS_EDITOR_FILE;
|
||||
final XMLEventReader reader = inputFactory.createXMLEventReader(new FileInputStream(fileAddress));
|
||||
|
||||
PREFS.clear();
|
||||
COLS.clear();
|
||||
|
||||
// read in defaults
|
||||
loadPrefs(inputFactory.createXMLEventReader(new FileInputStream(NewConstants.PREFS_DEFAULT_EDITOR_FILE)));
|
||||
|
||||
// overwrite defaults with user preferences
|
||||
loadPrefs(inputFactory.createXMLEventReader(new FileInputStream(NewConstants.PREFS_EDITOR_FILE)));
|
||||
|
||||
SColumnUtil.attachSortAndDisplayFunctions();
|
||||
}
|
||||
|
||||
private static void loadPrefs(final XMLEventReader reader) throws XMLStreamException {
|
||||
XMLEvent event;
|
||||
StartElement element;
|
||||
Iterator<?> attributes;
|
||||
@@ -309,7 +318,7 @@ public class SEditorIO {
|
||||
attribute = (Attribute) attributes.next();
|
||||
if (attribute.getName().toString().equals(ColumnProperty.enumval.toString())) {
|
||||
try { COLS.put(ColumnName.valueOf(attribute.getValue()), tempcol); }
|
||||
catch (final Exception e) { }
|
||||
catch (final Exception e) { /* ignore invalid entries */ }
|
||||
|
||||
tempcol.setEnumValue(attribute.getValue());
|
||||
}
|
||||
@@ -333,7 +342,5 @@ public class SEditorIO {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SColumnUtil.attachSortAndDisplayFunctions();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,6 @@ public enum CEditorPreferences implements ICDoc {
|
||||
final ColumnName name = prefsDict.get(key);
|
||||
key.setSelected(SColumnUtil.getColumn(name).isShowing());
|
||||
key.addItemListener(new ItemListener() {
|
||||
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent arg0) {
|
||||
SColumnUtil.toggleColumn(SColumnUtil.getColumn(name));
|
||||
|
||||
@@ -47,6 +47,7 @@ public final class NewConstants {
|
||||
public static final String PREFS_GLOBAL_FILE = "res/preferences/forge.preferences";
|
||||
/** Constant <code>PREFS_GLOBAL_FILE = "editor.preferences"</code>. */
|
||||
public static final String PREFS_EDITOR_FILE = "res/preferences/editor.preferences";
|
||||
public static final String PREFS_DEFAULT_EDITOR_FILE = "res/preferences/editor.default.preferences";
|
||||
/** */
|
||||
public static final String PREFS_MAIN_PROPERTIES_FILE = "res/preferences/main.properties";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user