master
ShawnieBoy 2013-12-12 03:22:25 +00:00
commit 1f63c417e7
5 changed files with 144 additions and 74 deletions

View File

@ -38,6 +38,7 @@ public class GeneralConfig {
private static final String LOG_TOPINSERT = "logTopInsert";
private static final String FULLSCREEN = "fullScreen";
private static final String PREVIEW_CARD_ON_SELECT = "previewCardOnSelect";
private static final String SHOW_LOG_MESSAGES = "showLogMessages";
private static final int DEFAULT_LEFT=0;
private static final int DEFAULT_TOP=0;
@ -66,6 +67,7 @@ public class GeneralConfig {
private static final boolean DEFAULT_LOG_TOPINSERT = false;
private static final boolean DEFAULT_FULLSCREEN = false;
private static final boolean DEFAULT_PREVIEW_CARD_ON_SELECT = false;
private static final boolean DEFAULT_SHOW_LOG_MESSAGES = true;
private int left=DEFAULT_LEFT;
private int top=DEFAULT_TOP;
@ -94,6 +96,7 @@ public class GeneralConfig {
private boolean isLogMessageAddedToTop = DEFAULT_LOG_TOPINSERT;
private boolean fullScreen = DEFAULT_FULLSCREEN;
private boolean previewCardOnSelect = DEFAULT_PREVIEW_CARD_ON_SELECT;
private boolean showLogMessages = DEFAULT_SHOW_LOG_MESSAGES;
private GeneralConfig() {}
@ -321,6 +324,13 @@ public class GeneralConfig {
this.previewCardOnSelect = b;
}
public boolean isLogMessagesVisible() {
return showLogMessages;
}
public void setLogMessagesVisible(final boolean b) {
showLogMessages = b;
}
private void load(final Properties properties) {
left=Integer.parseInt(properties.getProperty(LEFT,""+DEFAULT_LEFT));
@ -350,6 +360,7 @@ public class GeneralConfig {
isLogMessageAddedToTop = Boolean.parseBoolean(properties.getProperty(LOG_TOPINSERT, "" + DEFAULT_LOG_TOPINSERT));
fullScreen = Boolean.parseBoolean(properties.getProperty(FULLSCREEN, "" + DEFAULT_FULLSCREEN));
previewCardOnSelect = Boolean.parseBoolean(properties.getProperty(PREVIEW_CARD_ON_SELECT, "" + DEFAULT_PREVIEW_CARD_ON_SELECT));
showLogMessages = Boolean.parseBoolean(properties.getProperty(SHOW_LOG_MESSAGES, "" + DEFAULT_SHOW_LOG_MESSAGES));
}
public void load() {
@ -384,6 +395,7 @@ public class GeneralConfig {
properties.setProperty(LOG_TOPINSERT, String.valueOf(isLogMessageAddedToTop));
properties.setProperty(FULLSCREEN, String.valueOf(fullScreen));
properties.setProperty(PREVIEW_CARD_ON_SELECT, String.valueOf(previewCardOnSelect));
properties.setProperty(SHOW_LOG_MESSAGES, String.valueOf(showLogMessages));
}
public void save() {

View File

@ -142,10 +142,10 @@ public class DuelPanel extends TexturedPanel {
rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.Y_AXIS));
rightPanel.setOpaque(false);
rightPanel.add(deckDescriptionViewers[i]);
rightPanel.add(statsViewers[i]);
rightPanel.add(Box.createVerticalStrut(SPACING));
rightPanel.add(statsViewers[i]);
rightPanel.add(deckDescriptionViewers[i]);
rightPanel.add(Box.createVerticalStrut(SPACING));
if (!player.isArtificial()) {

View File

@ -52,6 +52,7 @@ public class PreferencesDialog extends JDialog implements ActionListener {
private JButton okButton;
private JButton cancelButton;
private JCheckBox previewCardOnSelectCheckBox;
private JCheckBox gameLogCheckBox;
public PreferencesDialog(final MagicFrame frame) {
@ -81,7 +82,8 @@ public class PreferencesDialog extends JDialog implements ActionListener {
private JTabbedPane getTabbedSettingsPane() {
final JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.addTab("General", getGeneralSettingsPanel());
tabbedPane.addTab("Theme", getThemeSettingsPanel());
tabbedPane.addTab("Duel", getDuelSettingsPanel());
tabbedPane.addTab("Look & Feel", getThemeSettingsPanel());
tabbedPane.addTab("Deck Editor", getDeckEditorSettingsPanel());
return tabbedPane;
}
@ -106,6 +108,85 @@ public class PreferencesDialog extends JDialog implements ActionListener {
return panel;
}
private JPanel getDuelSettingsPanel() {
final JPanel mainPanel=new JPanel();
mainPanel.setLayout(null);
int Y=10;
final int X3=25;
final int H3=20;
final int W3=350;
gameLogCheckBox = new JCheckBox("Show game log messages.", config.isLogMessagesVisible());
gameLogCheckBox.setToolTipText("<html>Clear this option if you would prefer the game log messages to be hidden by default.<br>You can still toggle visibility during a game by clicking on the log titlebar.</html>");
gameLogCheckBox.setBounds(X3,Y,W3,H3);
gameLogCheckBox.setFocusable(false);
mainPanel.add(gameLogCheckBox);
Y += 30;
soundCheckBox = new JCheckBox("Enable sound effects",config.isSound());
soundCheckBox.setBounds(X3,Y,W3,H3);
soundCheckBox.setFocusable(false);
mainPanel.add(soundCheckBox);
Y += 30;
touchscreenCheckBox = new JCheckBox("Double-click to cast or activate ability (for touchscreen)",config.isTouchscreen());
touchscreenCheckBox.setBounds(X3,Y,W3,H3);
touchscreenCheckBox.setFocusable(false);
mainPanel.add(touchscreenCheckBox);
Y += 30;
skipSingleCheckBox = new JCheckBox("Skip single option choices when appropriate",
config.getSkipSingle());
skipSingleCheckBox.setBounds(X3,Y,W3,H3);
skipSingleCheckBox.setFocusable(false);
mainPanel.add(skipSingleCheckBox);
Y += 30;
alwaysPassCheckBox = new JCheckBox("Always pass during draw and begin of combat step",
config.getAlwaysPass());
alwaysPassCheckBox.setBounds(X3,Y,W3,H3);
alwaysPassCheckBox.setFocusable(false);
mainPanel.add(alwaysPassCheckBox);
Y += 30;
smartTargetCheckBox=new JCheckBox("Remove unusual target choices",
config.getSmartTarget());
smartTargetCheckBox.setBounds(X3,Y,W3,H3);
smartTargetCheckBox.setFocusable(false);
mainPanel.add(smartTargetCheckBox);
Y += 30;
mouseWheelPopupCheckBox = new JCheckBox("Popup card image using mouse wheel (instead of delay)",
config.isMouseWheelPopup());
mouseWheelPopupCheckBox.setBounds(X3,Y,W3,H3);
mouseWheelPopupCheckBox.setFocusable(false);
mainPanel.add(mouseWheelPopupCheckBox);
Y += 30;
popupDelaySlider=new SliderPanel("Popup",
IconImages.DELAY,
0,
500,
50,
config.getPopupDelay());
popupDelaySlider.setBounds(50,Y,280,50);
mainPanel.add(popupDelaySlider);
Y += 40;
messageDelaySlider = new SliderPanel("Message",
IconImages.DELAY,
0,
3000,
500,
config.getMessageDelay());
messageDelaySlider.setBounds(50,Y,280,50);
mainPanel.add(messageDelaySlider);
return mainPanel;
}
private JPanel getThemeSettingsPanel() {
final JPanel panel = new JPanel();
@ -171,18 +252,6 @@ public class PreferencesDialog extends JDialog implements ActionListener {
confirmExitCheckBox.setFocusable(false);
mainPanel.add(confirmExitCheckBox);
Y += 30;
soundCheckBox = new JCheckBox("Enable sound effects",config.isSound());
soundCheckBox.setBounds(X3,Y,W3,H3);
soundCheckBox.setFocusable(false);
mainPanel.add(soundCheckBox);
Y += 30;
touchscreenCheckBox = new JCheckBox("Double-click to cast or activate ability (for touchscreen)",config.isTouchscreen());
touchscreenCheckBox.setBounds(X3,Y,W3,H3);
touchscreenCheckBox.setFocusable(false);
mainPanel.add(touchscreenCheckBox);
Y += 30;
highQualityCheckBox = new JCheckBox("Show card images in original size",
config.isHighQuality());
@ -190,54 +259,6 @@ public class PreferencesDialog extends JDialog implements ActionListener {
highQualityCheckBox.setFocusable(false);
mainPanel.add(highQualityCheckBox);
Y += 30;
skipSingleCheckBox = new JCheckBox("Skip single option choices when appropriate",
config.getSkipSingle());
skipSingleCheckBox.setBounds(X3,Y,W3,H3);
skipSingleCheckBox.setFocusable(false);
mainPanel.add(skipSingleCheckBox);
Y += 30;
alwaysPassCheckBox = new JCheckBox("Always pass during draw and begin of combat step",
config.getAlwaysPass());
alwaysPassCheckBox.setBounds(X3,Y,W3,H3);
alwaysPassCheckBox.setFocusable(false);
mainPanel.add(alwaysPassCheckBox);
Y += 30;
smartTargetCheckBox=new JCheckBox("Remove unusual target choices",
config.getSmartTarget());
smartTargetCheckBox.setBounds(X3,Y,W3,H3);
smartTargetCheckBox.setFocusable(false);
mainPanel.add(smartTargetCheckBox);
Y += 30;
mouseWheelPopupCheckBox = new JCheckBox("Popup using mouse wheel (instead of delay)",
config.isMouseWheelPopup());
mouseWheelPopupCheckBox.setBounds(X3,Y,W3,H3);
mouseWheelPopupCheckBox.setFocusable(false);
mainPanel.add(mouseWheelPopupCheckBox);
Y += 30;
popupDelaySlider=new SliderPanel("Popup",
IconImages.DELAY,
0,
500,
50,
config.getPopupDelay());
popupDelaySlider.setBounds(50,Y,280,50);
mainPanel.add(popupDelaySlider);
Y += 40;
messageDelaySlider = new SliderPanel("Message",
IconImages.DELAY,
0,
3000,
500,
config.getMessageDelay());
messageDelaySlider.setBounds(50,Y,280,50);
mainPanel.add(messageDelaySlider);
return mainPanel;
}
@ -260,6 +281,7 @@ public class PreferencesDialog extends JDialog implements ActionListener {
config.setPopupDelay(popupDelaySlider.getValue());
config.setMessageDelay(messageDelaySlider.getValue());
config.setPreviewCardOnSelect(previewCardOnSelectCheckBox.isSelected());
config.setLogMessagesVisible(gameLogCheckBox.isSelected());
config.save();
ThemeFactory.getInstance().setCurrentTheme(config.getTheme());
frame.repaint();

View File

@ -127,6 +127,13 @@ public class DuelDecksScreen
swapDecks();
}
}));
} else {
buttons.add(new MenuButton("Save Duel", new AbstractAction() {
@Override
public void actionPerformed(final ActionEvent e) {
saveDuel();
}
}));
}
return buttons;
}

View File

@ -1,5 +1,6 @@
package magic.ui.viewer;
import magic.data.GeneralConfig;
import magic.model.MagicLogBook;
import magic.model.MagicMessage;
import magic.ui.widget.FontsAndBorders;
@ -12,11 +13,15 @@ import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.border.CompoundBorder;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Insets;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ListIterator;
public class LogBookViewer extends JPanel {
@ -33,8 +38,9 @@ public class LogBookViewer extends JPanel {
private final MagicLogBook logBook;
private final JPanel messagePanel;
private final JScrollPane scrollPane;
private boolean isScrollbarVisible = false;
private boolean isNewMessageAddedToTop = false;
private boolean isScrollbarVisible;
private boolean isNewMessageAddedToTop;
private final TitleBar tb;
public LogBookViewer(final MagicLogBook logBook) {
@ -42,8 +48,10 @@ public class LogBookViewer extends JPanel {
setLayout(new BorderLayout());
TitleBar tb = new TitleBar("Log");
tb = new TitleBar("Log");
tb.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.BLACK));
tb.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
tb.setToolTipText("Click to hide log messages");
add(tb, BorderLayout.NORTH);
final JPanel centerPanel=new JPanel();
@ -57,6 +65,7 @@ public class LogBookViewer extends JPanel {
centerPanel.add(messagePanel,BorderLayout.NORTH);
scrollPane=new JScrollPane();
scrollPane.setVisible(GeneralConfig.getInstance().isLogMessagesVisible());
scrollPane.getViewport().setView(centerPanel);
scrollPane.getViewport().setOpaque(false);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
@ -68,13 +77,33 @@ public class LogBookViewer extends JPanel {
addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent arg0) {
public void componentResized(final ComponentEvent arg0) {
if (!isNewMessageAddedToTop) {
forceVerticalScrollbarToMax();
}
}
});
tb.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(final MouseEvent e) {
scrollPane.setVisible(!scrollPane.isVisible());
updateTitlebarCaption();
}
});
updateTitlebarCaption();
}
private void updateTitlebarCaption() {
if (!scrollPane.isVisible()) {
tb.setText("Click to show Log messages...");
tb.setToolTipText(null);
} else {
tb.setText("Log");
tb.setToolTipText("Click to hide log messages");
}
}
public MagicLogBook getLogBook() {
@ -86,13 +115,13 @@ public class LogBookViewer extends JPanel {
synchronized (logBook) {
if (!isNewMessageAddedToTop) {
// use the default order of messages in logBook list.
for (MagicMessage msg : logBook) {
for (final MagicMessage msg : logBook) {
messagePanel.add(getNewMessagePanel(msg));
}
forceVerticalScrollbarToMax();
} else {
// display messages in reverse order.
ListIterator<MagicMessage> listIterator = logBook.listIterator(logBook.size());
final ListIterator<MagicMessage> listIterator = logBook.listIterator(logBook.size());
while(listIterator.hasPrevious()){
messagePanel.add(getNewMessagePanel(listIterator.previous()));
}
@ -103,7 +132,7 @@ public class LogBookViewer extends JPanel {
}
}
public void addMagicMessage(MagicMessage magicMessage) {
public void addMagicMessage(final MagicMessage magicMessage) {
if (isNewMessageAddedToTop) {
messagePanel.add(getNewMessagePanel(magicMessage), 0);
scrollPane.getVerticalScrollBar().setValue(0);
@ -113,9 +142,9 @@ public class LogBookViewer extends JPanel {
}
}
private MessagePanel getNewMessagePanel(MagicMessage message) {
Insets s = SEPARATOR_BORDER.getInsideBorder().getBorderInsets(null);
final int maxWidth = getWidth() - (s.left + s.right);
private MessagePanel getNewMessagePanel(final MagicMessage message) {
final Insets s = SEPARATOR_BORDER.getInsideBorder().getBorderInsets(null);
final int maxWidth = getWidth() - s.left - s.right;
final MessagePanel panel = new MessagePanel(message, maxWidth);
panel.setOpaque(false);
panel.setBorder(SEPARATOR_BORDER);
@ -134,7 +163,7 @@ public class LogBookViewer extends JPanel {
public void forceVerticalScrollbarToMax() {
scrollPane.validate();
JScrollBar scrollbar = scrollPane.getVerticalScrollBar();
final JScrollBar scrollbar = scrollPane.getVerticalScrollBar();
scrollbar.setValue(scrollbar.getMaximum());
}