Moved res/quests/data references into constants.

This commit is contained in:
Doublestrike
2012-01-31 05:18:18 +00:00
parent f807969faf
commit ddcd46ac80
7 changed files with 21 additions and 43 deletions

View File

@@ -23,6 +23,8 @@ import forge.game.GameType;
import forge.gui.GuiUtils;
import forge.gui.deckeditor.DeckEditorQuest;
import forge.gui.deckeditor.DeckEditorShop;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import forge.quest.data.QuestChallenge;
import forge.quest.data.QuestData;
import forge.quest.data.QuestDataIO;
@@ -334,7 +336,7 @@ public class ControlQuest {
/** Resets quests, then retrieves and sets current quest. */
public void refreshQuests() {
File dirQuests = new File("res/quest/data/");
File dirQuests = ForgeProps.getFile(NewConstants.Quest.DATA_DIR);
// Temporary transition code between v1.2.2 and v1.2.3.
// Can be safely deleted after release of 1.2.3.

View File

@@ -200,6 +200,9 @@ public final class NewConstants {
/** The XMLDATA. */
public static final String XMLDATA = "quest/data-xml";
/** The XMLDATA. */
public static final String DATA_DIR = "quest/data-dir";
/** The OPPONENT_ICONS. */
public static final String OPPONENT_ICONS = "quest/opponent/icons";

View File

@@ -508,19 +508,6 @@ public final class QuestData {
this.difficulty = QuestPreferences.getDifficulty(i);
}
/**
* Guess difficulty index.
* NOTE: Used in old UI only, soon to be deprecated.
*/
public void guessDifficultyIndex() {
/*final String[] diffStr = QuestPreferences.getDifficulty();
for (int i = 0; i < diffStr.length; i++) {
if (this.difficulty.equals(diffStr[i])) {
this.diffIndex = i;
}
}*/
}
// Level, read-only ( note: it increments in addWin() )
/**
* Gets the level.
@@ -636,16 +623,6 @@ public final class QuestData {
return this;
}
/**
* Checks for save file.
*
* @return true, if successful
*/
public boolean hasSaveFile() {
return ForgeProps.getFile(NewConstants.Quest.DATA).exists()
|| ForgeProps.getFile(NewConstants.Quest.XMLDATA).exists();
}
/**
* Save data.
*/

View File

@@ -74,11 +74,6 @@ public class QuestDataIO {
public QuestDataIO() {
}
/** @return {@link forge.quest.data.QuestData} */
public static QuestData loadData() {
return QuestDataIO.loadData(ForgeProps.getFile(NewConstants.Quest.XMLDATA));
}
/**
* <p>
* loadData.
@@ -200,7 +195,7 @@ public class QuestDataIO {
xStream.registerConverter(new CardPoolToXml());
xStream.alias("CardPool", ItemPool.class);
final File f = new File("res/quest/data/" + qd.getName() + ".dat");
final File f = new File(ForgeProps.getFile(NewConstants.Quest.DATA_DIR) + "\\" + qd.getName() + ".dat");
final BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream(f));
final GZIPOutputStream zout = new GZIPOutputStream(bout);
xStream.toXML(qd, zout);

View File

@@ -30,7 +30,6 @@ import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
@@ -42,7 +41,6 @@ import forge.AllZone;
import forge.error.ErrorViewer;
import forge.gui.GuiUtils;
import forge.quest.data.QuestData;
import forge.quest.data.QuestDataIO;
/**
* <p>
@@ -118,9 +116,9 @@ public class QuestOptions extends JFrame {
});
// is there any saved data?
if (!this.questData.hasSaveFile()) {
this.continueQuestButton.setEnabled(false);
}
//if (!this.questData.hasSaveFile()) {
// this.continueQuestButton.setEnabled(false);
//}
} // setup()
// show total number of games for each difficulty
@@ -261,12 +259,12 @@ public class QuestOptions extends JFrame {
*/
final void continueQuestButtonActionPerformed(final ActionEvent e) {
// set global variable
AllZone.setQuestData(QuestDataIO.loadData());
/*AllZone.setQuestData(QuestDataIO.loadData());
AllZone.getQuestData().guessDifficultyIndex();
this.dispose();
new QuestFrame();
*/
}
/**
@@ -296,7 +294,7 @@ public class QuestOptions extends JFrame {
return;
}
if (this.questData.hasSaveFile()) {
/* if (this.questData.hasSaveFile()) {
// this will overwrite your save file!
final Object[] possibleValues = { "Yes", "No" };
final Object choice = JOptionPane.showOptionDialog(null,
@@ -306,7 +304,7 @@ public class QuestOptions extends JFrame {
if (!choice.equals(0)) {
return;
}
}
}*/
// give the user a few cards to build a deck
this.questData.newGame(difficulty, mode, this.cbStandardStart.isSelected());

View File

@@ -20,6 +20,8 @@ import net.miginfocom.swing.MigLayout;
import forge.Command;
import forge.Singletons;
import forge.gui.GuiUtils;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import forge.quest.data.QuestData;
import forge.view.toolbox.FLabel;
import forge.view.toolbox.FSkin;
@@ -316,8 +318,8 @@ public class QuestFileLister extends JPanel {
return;
}
else {
File newpath = new File("res/quest/data/" + questName + ".dat");
File oldpath = new File("res/quest/data/" + s0 + ".dat");
File newpath = new File(ForgeProps.getFile(NewConstants.Quest.DATA_DIR) + "\\" + questName + ".dat");
File oldpath = new File(ForgeProps.getFile(NewConstants.Quest.DATA_DIR) + "\\" + s0 + ".dat");
oldpath.renameTo(newpath);
}
@@ -336,7 +338,7 @@ public class QuestFileLister extends JPanel {
return;
}
new File("res/quest/data/" + r0.getQuestData().getName() + ".dat").delete();
new File(ForgeProps.getFile(NewConstants.Quest.DATA_DIR) + "\\" + r0.getQuestData().getName() + ".dat").delete();
if (cmdRowDelete != null) { cmdRowDelete.execute(); }