mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Quest reward cards are being presented in a much cleaner detailed view
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -9688,6 +9688,7 @@ src/main/java/forge/game/GamePlayerRating.java -text
|
|||||||
src/main/java/forge/game/GameSummary.java svneol=native#text/plain
|
src/main/java/forge/game/GameSummary.java svneol=native#text/plain
|
||||||
src/main/java/forge/game/PlayerIndex.java -text
|
src/main/java/forge/game/PlayerIndex.java -text
|
||||||
src/main/java/forge/game/package-info.java -text
|
src/main/java/forge/game/package-info.java -text
|
||||||
|
src/main/java/forge/gui/CardListViewer.java -text
|
||||||
src/main/java/forge/gui/ForgeAction.java svneol=native#text/plain
|
src/main/java/forge/gui/ForgeAction.java svneol=native#text/plain
|
||||||
src/main/java/forge/gui/GuiUtils.java svneol=native#text/plain
|
src/main/java/forge/gui/GuiUtils.java svneol=native#text/plain
|
||||||
src/main/java/forge/gui/ListChooser.java svneol=native#text/plain
|
src/main/java/forge/gui/ListChooser.java svneol=native#text/plain
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import forge.game.GameLossReason;
|
|||||||
import forge.game.GamePlayerRating;
|
import forge.game.GamePlayerRating;
|
||||||
import forge.game.GameSummary;
|
import forge.game.GameSummary;
|
||||||
import forge.game.PlayerIndex;
|
import forge.game.PlayerIndex;
|
||||||
|
import forge.gui.CardListViewer;
|
||||||
import forge.gui.GuiUtils;
|
import forge.gui.GuiUtils;
|
||||||
import forge.properties.ForgeProps;
|
import forge.properties.ForgeProps;
|
||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
@@ -27,6 +28,7 @@ import javax.swing.JPanel;
|
|||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
import javax.swing.border.Border;
|
import javax.swing.border.Border;
|
||||||
import javax.swing.border.TitledBorder;
|
import javax.swing.border.TitledBorder;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
@@ -94,7 +96,7 @@ public class Gui_WinLose extends JFrame implements NewConstants {
|
|||||||
*/
|
*/
|
||||||
private void setup() {
|
private void setup() {
|
||||||
Phase.setGameBegins(0);
|
Phase.setGameBegins(0);
|
||||||
|
|
||||||
if (model.match.isMatchOver()) {
|
if (model.match.isMatchOver()) {
|
||||||
// editDeckButton.setEnabled(false);
|
// editDeckButton.setEnabled(false);
|
||||||
continueButton.setEnabled(false);
|
continueButton.setEnabled(false);
|
||||||
@@ -109,7 +111,6 @@ public class Gui_WinLose extends JFrame implements NewConstants {
|
|||||||
statsLabel.setText(ForgeProps.getLocalized(WINLOSE_TEXT.WON) + humanWins
|
statsLabel.setText(ForgeProps.getLocalized(WINLOSE_TEXT.WON) + humanWins
|
||||||
+ ForgeProps.getLocalized(WINLOSE_TEXT.LOST) + humanLosses);
|
+ ForgeProps.getLocalized(WINLOSE_TEXT.LOST) + humanLosses);
|
||||||
|
|
||||||
|
|
||||||
//show "You Won" or "You Lost"
|
//show "You Won" or "You Lost"
|
||||||
if (model.match.hasHumanWonLastGame()) {
|
if (model.match.hasHumanWonLastGame()) {
|
||||||
titleLabel.setText(ForgeProps.getLocalized(WINLOSE_TEXT.WIN));
|
titleLabel.setText(ForgeProps.getLocalized(WINLOSE_TEXT.WIN));
|
||||||
@@ -253,7 +254,6 @@ public class Gui_WinLose extends JFrame implements NewConstants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int winTurn = game.getTurnGameEnded();
|
int winTurn = game.getTurnGameEnded();
|
||||||
|
|
||||||
int turnCredits = q.getCreditsRewardForWinByTurn(winTurn);
|
int turnCredits = q.getCreditsRewardForWinByTurn(winTurn);
|
||||||
|
|
||||||
if (winTurn == 0) { // this case should never happen - anyway, no reward if we got here
|
if (winTurn == 0) { // this case should never happen - anyway, no reward if we got here
|
||||||
@@ -391,18 +391,9 @@ public class Gui_WinLose extends JFrame implements NewConstants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<String> cardsWon = model.quest.addCards(setsToGive);
|
ArrayList<String> cardsWon = model.quest.addCards(setsToGive);
|
||||||
// TODO: Make a better presentation of cards - with pictures at least
|
ImageIcon icon = getIcon("BookIcon.png");
|
||||||
|
CardListViewer c = new CardListViewer("Booster", "You have won the following new cards", cardsWon, icon);
|
||||||
StringBuilder sb = new StringBuilder();
|
c.show();
|
||||||
sb.append("You have won the following new cards:\n");
|
|
||||||
for (String cardName : cardsWon) {
|
|
||||||
sb.append(cardName + "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
String fileName = "BookIcon.png";
|
|
||||||
ImageIcon icon = getIcon(fileName);
|
|
||||||
|
|
||||||
JOptionPane.showMessageDialog(null, sb.toString(), "", JOptionPane.INFORMATION_MESSAGE, icon);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void giveQuestRewards(final boolean wonMatch) {
|
protected void giveQuestRewards(final boolean wonMatch) {
|
||||||
@@ -428,11 +419,12 @@ public class Gui_WinLose extends JFrame implements NewConstants {
|
|||||||
int wins = model.quest.getWin();
|
int wins = model.quest.getWin();
|
||||||
if (wins > 0 && wins % 80 == 0) // at every 80 wins, give 10 random rares
|
if (wins > 0 && wins % 80 == 0) // at every 80 wins, give 10 random rares
|
||||||
{
|
{
|
||||||
model.quest.addRandomRare(10);
|
ArrayList<String> randomRares = model.quest.addRandomRare(10);
|
||||||
String fileName = "BoxIcon.png";
|
|
||||||
ImageIcon icon = getIcon(fileName);
|
ImageIcon icon = getIcon("BoxIcon.png");
|
||||||
String title = "You just won 10 random rares!";
|
String title = "You just won 10 random rares!";
|
||||||
JOptionPane.showMessageDialog(null, title, "", JOptionPane.INFORMATION_MESSAGE, icon);
|
CardListViewer c = new CardListViewer("Random rares", title, randomRares, icon);
|
||||||
|
c.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
159
src/main/java/forge/gui/CardListViewer.java
Normal file
159
src/main/java/forge/gui/CardListViewer.java
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
/**
|
||||||
|
* ListChooser.java
|
||||||
|
*
|
||||||
|
* Created on 31.08.2009
|
||||||
|
*/
|
||||||
|
|
||||||
|
package forge.gui;
|
||||||
|
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.event.ListSelectionEvent;
|
||||||
|
import javax.swing.event.ListSelectionListener;
|
||||||
|
|
||||||
|
import forge.AllZone;
|
||||||
|
import forge.Card;
|
||||||
|
import forge.CardUtil;
|
||||||
|
import forge.gui.game.CardDetailPanel;
|
||||||
|
import forge.gui.game.CardPicturePanel;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.awt.event.WindowFocusListener;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static java.util.Collections.unmodifiableList;
|
||||||
|
import static javax.swing.JOptionPane.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple class that shows a list of cards in a dialog with preview in its right part.
|
||||||
|
*
|
||||||
|
* @author Forge
|
||||||
|
* @version $Id: ListChooser.java 9708 2011-08-09 19:34:12Z jendave $
|
||||||
|
*/
|
||||||
|
public class CardListViewer {
|
||||||
|
|
||||||
|
//Data and number of choices for the list
|
||||||
|
private List<String> list;
|
||||||
|
|
||||||
|
//Decoration
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
//Flag: was the dialog already shown?
|
||||||
|
private boolean called;
|
||||||
|
//initialized before; listeners may be added to it
|
||||||
|
private JList jList;
|
||||||
|
private CardDetailPanel detail;
|
||||||
|
private CardPicturePanel picture;
|
||||||
|
|
||||||
|
//Temporarily stored for event handlers during show
|
||||||
|
private JDialog dialog;
|
||||||
|
private JOptionPane optionPane;
|
||||||
|
private Action ok;
|
||||||
|
|
||||||
|
public CardListViewer(String title, List<String> list) {
|
||||||
|
this(title, "", list, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CardListViewer(String title, String message, List<String> list) {
|
||||||
|
this(title, message, list, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CardListViewer(String title, String message, List<String> list, Icon dialogIcon) {
|
||||||
|
this.title = title;
|
||||||
|
this.list = unmodifiableList(list);
|
||||||
|
jList = new JList(new ChooserListModel());
|
||||||
|
detail = new CardDetailPanel(null);
|
||||||
|
picture = new CardPicturePanel(null);
|
||||||
|
ok = new CloseAction(OK_OPTION, "OK");
|
||||||
|
|
||||||
|
Object[] options = new Object[]{new JButton(ok)};
|
||||||
|
|
||||||
|
JPanel threeCols = new JPanel();
|
||||||
|
threeCols.add(new JScrollPane(jList));
|
||||||
|
threeCols.add(picture);
|
||||||
|
threeCols.add(detail);
|
||||||
|
threeCols.setLayout( new java.awt.GridLayout(1, 3, 6, 0) );
|
||||||
|
|
||||||
|
optionPane = new JOptionPane(new Object[]{message, threeCols},
|
||||||
|
INFORMATION_MESSAGE, DEFAULT_OPTION, dialogIcon, options, options[0]);
|
||||||
|
|
||||||
|
// selection is here
|
||||||
|
jList.getSelectionModel().addListSelectionListener(new SelListener());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows the dialog and returns after the dialog was closed.
|
||||||
|
*
|
||||||
|
* @return a boolean.
|
||||||
|
*/
|
||||||
|
public synchronized boolean show() {
|
||||||
|
if (called) throw new IllegalStateException("Already shown");
|
||||||
|
jList.setSelectedIndex(0);
|
||||||
|
|
||||||
|
dialog = optionPane.createDialog(optionPane.getParent(), title);
|
||||||
|
dialog.setSize(720,360);
|
||||||
|
dialog.addWindowFocusListener(new CardListFocuser());
|
||||||
|
dialog.setVisible(true);
|
||||||
|
|
||||||
|
dialog.dispose();
|
||||||
|
called = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ChooserListModel extends AbstractListModel {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 3871965346333840556L;
|
||||||
|
|
||||||
|
public int getSize() { return list.size(); }
|
||||||
|
public Object getElementAt(int index) { return list.get(index); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private class CloseAction extends AbstractAction {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -8426767786083886936L;
|
||||||
|
private int value;
|
||||||
|
|
||||||
|
public CloseAction(int value, String label) {
|
||||||
|
super(label);
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
optionPane.setValue(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class CardListFocuser implements WindowFocusListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void windowGainedFocus(WindowEvent e) {
|
||||||
|
jList.grabFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void windowLostFocus(WindowEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
} }
|
||||||
|
|
||||||
|
|
||||||
|
private class SelListener implements ListSelectionListener {
|
||||||
|
|
||||||
|
public void valueChanged(final ListSelectionEvent e) {
|
||||||
|
int row = jList.getSelectedIndex();
|
||||||
|
// (String) jList.getSelectedValue();
|
||||||
|
if ( row >= 0 && row < list.size() ) {
|
||||||
|
Card card = AllZone.getCardFactory().getCard( list.get(row) , null);
|
||||||
|
card.setImageFilename(CardUtil.buildFilename(card));
|
||||||
|
detail.setCard(card);
|
||||||
|
picture.setCard(card);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user