mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Cleanup Quest and Deck lister display
Fix Quest renaming
This commit is contained in:
@@ -51,7 +51,7 @@ public enum CSubmenuQuestData implements ICDoc {
|
||||
private final Command cmdQuestSelect = new Command() { @Override
|
||||
public void run() { changeQuest(); } };
|
||||
|
||||
private final Command cmdQuestDelete = new Command() { @Override
|
||||
private final Command cmdQuestUpdate = new Command() { @Override
|
||||
public void run() { update(); } };
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -139,7 +139,8 @@ public enum CSubmenuQuestData implements ICDoc {
|
||||
}
|
||||
|
||||
view.getLstQuests().setSelectCommand(cmdQuestSelect);
|
||||
view.getLstQuests().setDeleteCommand(cmdQuestDelete);
|
||||
view.getLstQuests().setDeleteCommand(cmdQuestUpdate);
|
||||
view.getLstQuests().setEditCommand(cmdQuestUpdate);
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override public void run() { view.getBtnEmbark().requestFocusInWindow(); }
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.gui.home.quest;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -10,13 +9,13 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.Command;
|
||||
import forge.gui.toolbox.FLabel;
|
||||
import forge.gui.toolbox.FMouseAdapter;
|
||||
import forge.gui.toolbox.FOptionPane;
|
||||
import forge.gui.toolbox.FSkin;
|
||||
import forge.properties.NewConstants;
|
||||
@@ -83,11 +82,9 @@ public class QuestFileLister extends JPanel {
|
||||
final JPanel rowTitle = new JPanel();
|
||||
FSkin.get(rowTitle).setBackground(FSkin.getColor(FSkin.Colors.CLR_ZEBRA));
|
||||
rowTitle.setLayout(new MigLayout("insets 0, gap 0"));
|
||||
rowTitle.add(new FLabel.Builder().text("Delete").fontAlign(SwingConstants.CENTER).build(), "w 15%!, h 20px!, gap 0 0 5px 0");
|
||||
rowTitle.add(new FLabel.Builder().text("Rename").fontAlign(SwingConstants.CENTER).build(), "w 15%!, h 20px!, gap 0 0 5px 0");
|
||||
rowTitle.add(new FLabel.Builder().text("Name").fontAlign(SwingConstants.CENTER).build(), "w 40%!, h 20px!, gap 0 0 5px 0");
|
||||
rowTitle.add(new FLabel.Builder().text("Mode").fontAlign(SwingConstants.CENTER).build(), "w 15%!, h 20px!, gap 0 0 5px 0");
|
||||
rowTitle.add(new FLabel.Builder().text("Record").fontAlign(SwingConstants.CENTER).build(), "w 15%!, h 20px!, gap 0 0 5px 0");
|
||||
rowTitle.add(new FLabel.Builder().text("Name").fontAlign(SwingConstants.LEFT).build(), "w 85%-112px!, h 20px!, gaptop 5px, gapleft 48px");
|
||||
rowTitle.add(new FLabel.Builder().text("Mode").fontAlign(SwingConstants.LEFT).build(), "w 15%!, h 20px!, gaptop 5px, gapleft 4px");
|
||||
rowTitle.add(new FLabel.Builder().text("Record").fontAlign(SwingConstants.LEFT).build(), "w 60px!, h 20px!, gaptop 5px, gapleft 4px");
|
||||
this.add(rowTitle, "w 98%!, h 30px!, gapleft 1%");
|
||||
|
||||
RowPanel row;
|
||||
@@ -95,12 +92,12 @@ public class QuestFileLister extends JPanel {
|
||||
for (QuestData qd : sorted) {
|
||||
mode = qd.getMode().toString();
|
||||
row = new RowPanel(qd);
|
||||
row.add(new DeleteButton(row), "w 15%!, h 20px!, gap 0 0 5px 0");
|
||||
row.add(new EditButton(row), "w 15%!, h 20px!, gaptop 5px");
|
||||
row.add(new FLabel.Builder().text(qd.getName()).build(), "w 40%!, h 20px!, gap 0 0 5px 0");
|
||||
row.add(new FLabel.Builder().text(mode).fontAlign(SwingConstants.CENTER).build(), "w 15%!, h 20px!, gap 0 0 5px 0");
|
||||
row.add(new DeleteButton(row), "w 22px!, h 20px!, gaptop 5px");
|
||||
row.add(new EditButton(row), "w 22px!, h 20px!, gaptop 5px");
|
||||
row.add(new FLabel.Builder().text(qd.getName()).fontAlign(SwingConstants.LEFT).build(), "w 85%-112px!, h 20px!, gaptop 5px, gapleft 4px");
|
||||
row.add(new FLabel.Builder().text(mode).fontAlign(SwingConstants.LEFT).build(), "w 15%!, h 20px!, gaptop 5px, gapleft 4px");
|
||||
row.add(new FLabel.Builder().text(qd.getAchievements().getWin() + "/" + qd.getAchievements().getLost())
|
||||
.fontAlign(SwingConstants.CENTER).build(), "w 15%!, h 20px!, gap 0 0 5px 0");
|
||||
.fontAlign(SwingConstants.LEFT).build(), "w 60px!, h 20px!, gaptop 5px, gapleft 4px");
|
||||
this.add(row, "w 98%!, h 30px!, gap 1% 0 0 0");
|
||||
tempRows.add(row);
|
||||
}
|
||||
@@ -126,25 +123,25 @@ public class QuestFileLister extends JPanel {
|
||||
setContentAreaFilled(false);
|
||||
setBorder(null);
|
||||
setBorderPainted(false);
|
||||
setToolTipText("Delete this deck");
|
||||
setToolTipText("Delete this quest");
|
||||
|
||||
this.addMouseListener(new MouseAdapter() {
|
||||
this.addMouseListener(new FMouseAdapter() {
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
public void onMouseEnter(MouseEvent e) {
|
||||
if (!r0.selected) {
|
||||
FSkin.get(r0).setBackground(clrHover);
|
||||
r0.setOpaque(true);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
public void onMouseExit(MouseEvent e) {
|
||||
if (!r0.selected) {
|
||||
FSkin.get(r0).setBackground(clrDefault);
|
||||
r0.setOpaque(false);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
public void onLeftClick(MouseEvent e) {
|
||||
deleteFile(r0);
|
||||
}
|
||||
});
|
||||
@@ -165,24 +162,24 @@ public class QuestFileLister extends JPanel {
|
||||
setBorderPainted(false);
|
||||
setToolTipText("Rename this quest");
|
||||
|
||||
this.addMouseListener(new MouseAdapter() {
|
||||
this.addMouseListener(new FMouseAdapter() {
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
public void onMouseEnter(MouseEvent e) {
|
||||
if (!r0.selected) {
|
||||
FSkin.get(r0).setBackground(clrHover);
|
||||
r0.setOpaque(true);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
public void onMouseExit(MouseEvent e) {
|
||||
if (!r0.selected) {
|
||||
FSkin.get(r0).setBackground(clrDefault);
|
||||
r0.setOpaque(false);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
editFileName(r0.getQuestData().getName());
|
||||
public void onLeftClick(MouseEvent e) {
|
||||
editQuest(r0.getQuestData());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -190,6 +187,7 @@ public class QuestFileLister extends JPanel {
|
||||
|
||||
private class RowPanel extends JPanel {
|
||||
private boolean selected = false;
|
||||
private boolean hovered = false;
|
||||
private QuestData questData;
|
||||
|
||||
public RowPanel(QuestData qd0) {
|
||||
@@ -200,32 +198,40 @@ public class QuestFileLister extends JPanel {
|
||||
FSkin.get(this).setMatteBorder(0, 0, 1, 0, clrBorders);
|
||||
questData = qd0;
|
||||
|
||||
this.addMouseListener(new MouseAdapter() {
|
||||
this.addMouseListener(new FMouseAdapter() {
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
if (!selected) {
|
||||
FSkin.get(((RowPanel) e.getSource())).setBackground(clrHover);
|
||||
public void onMouseEnter(final MouseEvent e) {
|
||||
RowPanel.this.hovered = true;
|
||||
if (!RowPanel.this.selected) {
|
||||
FSkin.get(((RowPanel) e.getSource())).setBackground(QuestFileLister.this.clrHover);
|
||||
((RowPanel) e.getSource()).setOpaque(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
if (!selected) {
|
||||
FSkin.get(((RowPanel) e.getSource())).setBackground(clrDefault);
|
||||
public void onMouseExit(final MouseEvent e) {
|
||||
RowPanel.this.hovered = false;
|
||||
if (!RowPanel.this.selected) {
|
||||
FSkin.get(((RowPanel) e.getSource())).setBackground(QuestFileLister.this.clrDefault);
|
||||
((RowPanel) e.getSource()).setOpaque(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
selectHandler((RowPanel) e.getSource());
|
||||
public void onLeftMouseDown(final MouseEvent e) {
|
||||
if (e.getClickCount() == 1) {
|
||||
QuestFileLister.this.selectHandler((RowPanel) e.getSource());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setSelected(boolean b0) {
|
||||
selected = b0;
|
||||
setOpaque(b0);
|
||||
FSkin.get(this).setBackground(b0 ? clrActive : clrHover);
|
||||
public void setSelected(final boolean b0) {
|
||||
this.selected = b0;
|
||||
this.setOpaque(b0);
|
||||
if (b0) { FSkin.get(this).setBackground(QuestFileLister.this.clrActive); }
|
||||
else if (this.hovered) { FSkin.get(this).setBackground(QuestFileLister.this.clrHover); }
|
||||
else { FSkin.get(this).setBackground(QuestFileLister.this.clrDefault); }
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
@@ -294,33 +300,36 @@ public class QuestFileLister extends JPanel {
|
||||
if (cmdRowSelect != null) { cmdRowSelect.run(); }
|
||||
}
|
||||
|
||||
private void editFileName(String s0) {
|
||||
final Object o = JOptionPane.showInputDialog(JOptionPane.getRootFrame(),
|
||||
"Rename Quest to:", "Quest Rename", JOptionPane.OK_CANCEL_OPTION);
|
||||
private void editQuest(QuestData quest) {
|
||||
String questName;
|
||||
String oldQuestName = quest.getName();
|
||||
while (true) {
|
||||
questName = FOptionPane.showInputDialog("Rename quest to:", "Quest Rename", null, oldQuestName);
|
||||
if (questName == null) { return; }
|
||||
|
||||
if (o == null) { return; }
|
||||
questName = SSubmenuQuestUtil.cleanString(questName);
|
||||
if (questName.equals(oldQuestName)) { return; } //quit if chose same name
|
||||
|
||||
final String questName = SSubmenuQuestUtil.cleanString(o.toString());
|
||||
|
||||
boolean exists = false;
|
||||
|
||||
for (RowPanel r : rows) {
|
||||
if (r.getQuestData().getName().equalsIgnoreCase(questName)) {
|
||||
exists = true;
|
||||
break;
|
||||
if (questName.isEmpty()) {
|
||||
FOptionPane.showMessageDialog("Please specify a quest name.");
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean exists = false;
|
||||
for (RowPanel r : rows) {
|
||||
if (r.getQuestData().getName().equalsIgnoreCase(questName)) {
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (exists) {
|
||||
FOptionPane.showMessageDialog("A quest already exists with that name. Please pick another quest name.");
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (exists || questName.equals("")) {
|
||||
FOptionPane.showMessageDialog("Please pick another quest name, a quest already has that name.");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
File newpath = new File(NewConstants.QUEST_SAVE_DIR, questName + ".dat");
|
||||
File oldpath = new File(NewConstants.QUEST_SAVE_DIR, s0 + ".dat");
|
||||
|
||||
oldpath.renameTo(newpath);
|
||||
}
|
||||
quest.rename(questName);
|
||||
|
||||
if (cmdRowEdit != null) { cmdRowEdit.run(); }
|
||||
}
|
||||
@@ -328,11 +337,9 @@ public class QuestFileLister extends JPanel {
|
||||
private void deleteFile(RowPanel r0) {
|
||||
final QuestData qd = r0.getQuestData();
|
||||
|
||||
final int n = JOptionPane.showConfirmDialog(JOptionPane.getRootFrame(),
|
||||
"Are you sure you want to delete \"" + qd.getName()
|
||||
+ "\" ?", "Delete Deck", JOptionPane.YES_NO_OPTION);
|
||||
|
||||
if (n == JOptionPane.NO_OPTION) {
|
||||
if (!FOptionPane.showConfirmDialog(
|
||||
"Are you sure you want to delete '" + qd.getName() + "'?",
|
||||
"Delete Quest", "Delete", "Cancel")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import java.util.List;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
@@ -47,6 +46,7 @@ import forge.gui.framework.FScreen;
|
||||
import forge.gui.framework.ILocalRepaint;
|
||||
import forge.gui.toolbox.FLabel;
|
||||
import forge.gui.toolbox.FMouseAdapter;
|
||||
import forge.gui.toolbox.FOptionPane;
|
||||
import forge.gui.toolbox.FSkin;
|
||||
import forge.gui.toolbox.FSkin.JLabelSkin;
|
||||
import forge.item.InventoryItem;
|
||||
@@ -124,20 +124,15 @@ public class DeckLister extends JPanel implements ILocalRepaint {
|
||||
FSkin.get(rowTitle).setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2));
|
||||
rowTitle.setLayout(new MigLayout("insets 0, gap 0"));
|
||||
|
||||
rowTitle.add(new FLabel.Builder().text("Delete").fontAlign(SwingConstants.CENTER).build(),
|
||||
"w 10%!, h 20px!, gaptop 5px");
|
||||
rowTitle.add(new FLabel.Builder().text("Edit")
|
||||
.fontSize(14).fontAlign(SwingConstants.CENTER).build(),
|
||||
"w 10%!, h 20px!, gaptop 5px");
|
||||
rowTitle.add(new FLabel.Builder().text("Deck Name")
|
||||
.fontSize(14).fontAlign(SwingConstants.CENTER).build(),
|
||||
"w 58%!, h 20px!, gaptop 5px");
|
||||
.fontSize(14).fontAlign(SwingConstants.LEFT).build(),
|
||||
"w 100%-128px!, h 20px!, gaptop 5px, gapleft 48px");
|
||||
rowTitle.add(new FLabel.Builder().text("Main")
|
||||
.fontSize(14).fontAlign(SwingConstants.CENTER).build(),
|
||||
"w 10%!, h 20px!, gaptop 5px");
|
||||
.fontSize(14).fontAlign(SwingConstants.LEFT).build(),
|
||||
"w 36px!, h 20px!, gaptop 5px, gapleft 4px");
|
||||
rowTitle.add(new FLabel.Builder().text("Side")
|
||||
.fontSize(14).fontAlign(SwingConstants.CENTER).build(),
|
||||
"w 10%!, h 20px!, gaptop 5px");
|
||||
.fontSize(14).fontAlign(SwingConstants.LEFT).build(),
|
||||
"w 36px!, h 20px!, gaptop 5px, gapleft 4px");
|
||||
this.add(rowTitle, "w 98%!, h 30px!, gapleft 1%");
|
||||
|
||||
RowPanel row;
|
||||
@@ -147,11 +142,11 @@ public class DeckLister extends JPanel implements ILocalRepaint {
|
||||
}
|
||||
|
||||
row = new RowPanel(d);
|
||||
row.add(new DeleteButton(row), "w 10%!, h 20px!, gaptop 5px");
|
||||
row.add(new EditButton(row), "w 10%!, h 20px!, gaptop 5px");
|
||||
row.add(new GenericLabel(d.getName()), "w 58%!, h 20px!, gaptop 5px");
|
||||
row.add(new MainLabel(String.valueOf(d.getMain().countAll())), "w 10%, h 20px!, gaptop 5px");
|
||||
row.add(new GenericLabel(d.has(DeckSection.Sideboard) ? String.valueOf(d.get(DeckSection.Sideboard).countAll()) : "none"), "w 10%!, h 20px!, gaptop 5px");
|
||||
row.add(new DeleteButton(row), "w 22px!, h 20px!, gaptop 5px");
|
||||
row.add(new EditButton(row), "w 22px!, h 20px!, gaptop 5px");
|
||||
row.add(new GenericLabel(d.getName()), "w 100%-128px!, h 20px!, gaptop 5px, gapleft 4px");
|
||||
row.add(new MainLabel(String.valueOf(d.getMain().countAll())), "w 36px!, h 20px!, gaptop 5px, gapleft 4px");
|
||||
row.add(new GenericLabel(d.has(DeckSection.Sideboard) ? String.valueOf(d.get(DeckSection.Sideboard).countAll()) : "none"), "w 36px!, h 20px!, gaptop 5px, gapleft 4px");
|
||||
this.add(row, "w 98%!, h 30px!, gapleft 1%");
|
||||
tempRows.add(row);
|
||||
}
|
||||
@@ -353,7 +348,7 @@ public class DeckLister extends JPanel implements ILocalRepaint {
|
||||
private class GenericLabel extends JLabel {
|
||||
public GenericLabel(final String txt0) {
|
||||
super(txt0);
|
||||
this.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
this.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
JLabelSkin<GenericLabel> skin = FSkin.get(this);
|
||||
skin.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
|
||||
skin.setFont(FSkin.getBoldFont(12));
|
||||
@@ -435,7 +430,6 @@ public class DeckLister extends JPanel implements ILocalRepaint {
|
||||
}
|
||||
}
|
||||
private <T extends DeckBase> void editDeck(final Deck d0) {
|
||||
|
||||
ACEditorBase<? extends InventoryItem, ? extends DeckBase> editorCtrl = null;
|
||||
FScreen screen = null;
|
||||
|
||||
@@ -471,10 +465,9 @@ public class DeckLister extends JPanel implements ILocalRepaint {
|
||||
private void deleteDeck(final RowPanel r0) {
|
||||
final Deck d0 = r0.getDeck();
|
||||
|
||||
final int n = JOptionPane.showConfirmDialog(JOptionPane.getRootFrame(), "Are you sure you want to delete \"" + d0.getName() + "\" ?",
|
||||
"Delete Deck", JOptionPane.YES_NO_OPTION);
|
||||
|
||||
if (n == JOptionPane.NO_OPTION) {
|
||||
if (!FOptionPane.showConfirmDialog(
|
||||
"Are you sure you want to delete '" + d0.getName() + "'?",
|
||||
"Delete Deck", "Delete", "Cancel")) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -482,12 +475,15 @@ public class DeckLister extends JPanel implements ILocalRepaint {
|
||||
|
||||
if (this.gametype.equals(GameType.Draft)) {
|
||||
deckManager.getDraft().delete(d0.getName());
|
||||
} else if (this.gametype.equals(GameType.Sealed)) {
|
||||
}
|
||||
else if (this.gametype.equals(GameType.Sealed)) {
|
||||
deckManager.getSealed().delete(d0.getName());
|
||||
} else if (this.gametype.equals(GameType.Quest)) {
|
||||
}
|
||||
else if (this.gametype.equals(GameType.Quest)) {
|
||||
Singletons.getModel().getQuest().getMyDecks().delete(d0.getName());
|
||||
Singletons.getModel().getQuest().save();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
deckManager.getConstructed().delete(d0.getName());
|
||||
}
|
||||
|
||||
|
||||
@@ -254,9 +254,10 @@ public class QuestController {
|
||||
|
||||
this.load(new QuestData(name, difficulty, mode, formatPrizes, allowSetUnlocks, startingWorld)); // pass awards and unlocks here
|
||||
|
||||
if (null != startingCards) {
|
||||
if (startingCards != null) {
|
||||
this.myCards.addDeck(startingCards);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Predicate<PaperCard> filter = Predicates.alwaysTrue();
|
||||
if (formatStartingPool != null) {
|
||||
filter = formatStartingPool.getFilterPrinted();
|
||||
@@ -265,7 +266,6 @@ public class QuestController {
|
||||
}
|
||||
|
||||
this.getAssets().setCredits(Singletons.getModel().getQuestPreferences().getPrefInt(DifficultyPrefs.STARTING_CREDITS, difficulty));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,11 +17,13 @@
|
||||
*/
|
||||
package forge.quest.data;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.game.GameFormat;
|
||||
import forge.properties.NewConstants;
|
||||
import forge.quest.QuestMode;
|
||||
import forge.quest.io.QuestDataIO;
|
||||
|
||||
@@ -38,7 +40,6 @@ import forge.quest.io.QuestDataIO;
|
||||
* @version $Id$
|
||||
*/
|
||||
public final class QuestData {
|
||||
|
||||
/** Holds the latest version of the Quest Data. */
|
||||
public static final int CURRENT_VERSION_NUMBER = 8;
|
||||
|
||||
@@ -49,7 +50,7 @@ public final class QuestData {
|
||||
private int versionNumber = QuestData.CURRENT_VERSION_NUMBER;
|
||||
|
||||
private GameFormatQuest format;
|
||||
private final String name;
|
||||
private String name;
|
||||
|
||||
// Quest mode - there should be an enum :(
|
||||
/** The mode. */
|
||||
@@ -64,7 +65,6 @@ public final class QuestData {
|
||||
private final Map<Integer, String> petSlots = new HashMap<Integer, String>();
|
||||
private boolean isCharmActive = false;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new quest data.
|
||||
* @param mode2
|
||||
@@ -80,18 +80,17 @@ public final class QuestData {
|
||||
* @param startingWorld
|
||||
* starting world
|
||||
*/
|
||||
public QuestData(String name2, int diff, QuestMode mode2, GameFormat userFormat,
|
||||
public QuestData(String name0, int diff, QuestMode mode0, GameFormat userFormat,
|
||||
boolean allowSetUnlocks, final String startingWorld) {
|
||||
this.name = name2;
|
||||
this.name = name0;
|
||||
|
||||
if (userFormat != null) {
|
||||
this.format = new GameFormatQuest(userFormat, allowSetUnlocks);
|
||||
}
|
||||
this.mode = mode2;
|
||||
this.mode = mode0;
|
||||
this.achievements = new QuestAchievements(diff);
|
||||
this.assets = new QuestAssets(format);
|
||||
this.worldId = startingWorld;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,6 +157,21 @@ public final class QuestData {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename this quest the name.
|
||||
*
|
||||
* @param newName
|
||||
* the new name to set
|
||||
*/
|
||||
public void rename(final String newName) {
|
||||
File newpath = new File(NewConstants.QUEST_SAVE_DIR, newName + ".dat");
|
||||
File oldpath = new File(NewConstants.QUEST_SAVE_DIR, this.name + ".dat");
|
||||
oldpath.renameTo(newpath);
|
||||
|
||||
this.name = newName;
|
||||
QuestDataIO.saveData(this);
|
||||
}
|
||||
|
||||
public QuestAssets getAssets() {
|
||||
return assets;
|
||||
}
|
||||
@@ -200,5 +214,4 @@ public final class QuestData {
|
||||
public void setCharmActive(boolean isCharmActive) {
|
||||
this.isCharmActive = isCharmActive;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -145,7 +145,8 @@ public class QuestDataIO {
|
||||
}
|
||||
|
||||
return data;
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
catch (final Exception ex) {
|
||||
BugReporter.reportException(ex, "Error loading Quest Data");
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
@@ -175,7 +176,6 @@ public class QuestDataIO {
|
||||
* @throws IllegalAccessException
|
||||
*/
|
||||
private static void updateSaveFile(final QuestData newData, final String input, String filename) throws ParserConfigurationException, SAXException, IOException, IllegalAccessException, NoSuchFieldException {
|
||||
|
||||
final DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
final InputSource is = new InputSource();
|
||||
is.setCharacterStream(new StringReader(input));
|
||||
@@ -205,8 +205,7 @@ public class QuestDataIO {
|
||||
if(saveVersion < 8) {
|
||||
QuestDataIO.setFinalField(QuestData.class, "isCharmActive", newData, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
final QuestAssets qS = newData.getAssets();
|
||||
final QuestAchievements qA = newData.getAchievements();
|
||||
|
||||
@@ -376,7 +375,8 @@ public class QuestDataIO {
|
||||
QuestDataIO.savePacked(f + ".dat", xStream, qd);
|
||||
// QuestDataIO.saveUnpacked(f + ".xml", xStream, qd);
|
||||
|
||||
} catch (final Exception ex) {
|
||||
}
|
||||
catch (final Exception ex) {
|
||||
BugReporter.reportException(ex, "Error saving Quest Data.");
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user