mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
- New Game Log Verbosity setting.
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -14914,6 +14914,7 @@ src/main/java/forge/gui/package-info.java svneol=native#text/plain
|
||||
src/main/java/forge/gui/toolbox/CardFaceSymbols.java svneol=native#text/plain
|
||||
src/main/java/forge/gui/toolbox/FButton.java -text
|
||||
src/main/java/forge/gui/toolbox/FCheckBox.java -text
|
||||
src/main/java/forge/gui/toolbox/FComboBoxPanel.java -text
|
||||
src/main/java/forge/gui/toolbox/FLabel.java -text
|
||||
src/main/java/forge/gui/toolbox/FList.java -text
|
||||
src/main/java/forge/gui/toolbox/FOverlay.java -text
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.Observable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import forge.game.event.IGameEventVisitor;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
|
||||
|
||||
/**
|
||||
@@ -104,6 +105,11 @@ public class GameLog extends Observable {
|
||||
return result;
|
||||
}
|
||||
|
||||
public GameLogEntryType getGameLogEntryTypeSetting() {
|
||||
String logEntryType = Singletons.getModel().getPreferences().getPref(FPref.DEV_LOG_ENTRY_TYPE);
|
||||
return GameLogEntryType.valueOf(logEntryType);
|
||||
}
|
||||
|
||||
public IGameEventVisitor<?> getEventVisitor() {
|
||||
return formatter;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import forge.Command;
|
||||
import forge.Constant.Preferences;
|
||||
import forge.GameLogEntryType;
|
||||
import forge.Singletons;
|
||||
import forge.control.FControl.Screens;
|
||||
import forge.control.RestartUtil;
|
||||
@@ -74,6 +75,15 @@ public enum CSubmenuPreferences implements ICDoc {
|
||||
}
|
||||
});
|
||||
|
||||
view.getCboLogEntryType().addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(final ItemEvent e) {
|
||||
GameLogEntryType selectedType = (GameLogEntryType) view.getCboLogEntryType().getSelectedItem();
|
||||
prefs.setPref(FPref.DEV_LOG_ENTRY_TYPE, selectedType.toString());
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
lstControls.clear(); // just in case
|
||||
lstControls.add(Pair.of(view.getCbCompactMainMenu(), FPref.UI_COMPACT_MAIN_MENU));
|
||||
lstControls.add(Pair.of(view.getCbAnte(), FPref.UI_ANTE));
|
||||
@@ -145,6 +155,7 @@ public enum CSubmenuPreferences implements ICDoc {
|
||||
updateAIProfiles();
|
||||
|
||||
view.getCbDevMode().setSelected(prefs.getPrefBoolean(FPref.DEV_MODE_ENABLED));
|
||||
view.getCboLogEntryType().setSelectedItem(GameLogEntryType.valueOf(prefs.getPref(FPref.DEV_LOG_ENTRY_TYPE)));
|
||||
|
||||
for(Pair<JCheckBox, FPref> kv: lstControls) {
|
||||
kv.getKey().setSelected(prefs.getPrefBoolean(kv.getValue()));
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
@@ -26,6 +27,7 @@ import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.GameLogEntryType;
|
||||
import forge.Singletons;
|
||||
import forge.control.KeyboardShortcuts;
|
||||
import forge.control.KeyboardShortcuts.Shortcut;
|
||||
@@ -36,6 +38,7 @@ import forge.gui.home.EMenuGroup;
|
||||
import forge.gui.home.IVSubmenu;
|
||||
import forge.gui.home.VHomeUI;
|
||||
import forge.gui.toolbox.FCheckBox;
|
||||
import forge.gui.toolbox.FComboBoxPanel;
|
||||
import forge.gui.toolbox.FLabel;
|
||||
import forge.gui.toolbox.FList;
|
||||
import forge.gui.toolbox.FScrollPane;
|
||||
@@ -92,6 +95,8 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
||||
private final JCheckBox cbStackLand = new OptionsCheckBox("Stack AI Land");
|
||||
private final JCheckBox cbManaBurn = new OptionsCheckBox("Mana Burn");
|
||||
private final JCheckBox cbDevMode = new OptionsCheckBox("Developer Mode");
|
||||
private final FComboBoxPanel<GameLogEntryType> cbpLogEntryType =
|
||||
new FComboBoxPanel<GameLogEntryType>(GameLogEntryType.values(), "Game Log Verbosity:");
|
||||
private final JCheckBox cbEnforceDeckLegality = new OptionsCheckBox("Deck Conformance");
|
||||
private final JCheckBox cbCloneImgSource = new OptionsCheckBox("Clones use original card art");
|
||||
private final JCheckBox cbOverlayCardName = new OptionsCheckBox("Card Name");
|
||||
@@ -153,6 +158,9 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
||||
pnlPrefs.add(cbDevMode, regularConstraints);
|
||||
pnlPrefs.add(new NoteLabel("Enables menu with functions for testing during development."), regularConstraints);
|
||||
|
||||
pnlPrefs.add(cbpLogEntryType, "w 80%!, gap 10% 0 0 10px, span 2 1");
|
||||
pnlPrefs.add(new NoteLabel("Changes how much information is displayed in the game log. Sorted by least to most verbose."), regularConstraints);
|
||||
|
||||
pnlPrefs.add(cbEnforceDeckLegality, regularConstraints);
|
||||
pnlPrefs.add(new NoteLabel("Enforces deck legality relevant to each environment (minimum deck sizes, max card count etc)"), regularConstraints);
|
||||
|
||||
@@ -493,6 +501,11 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
||||
return cbDevMode;
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JComboBox} */
|
||||
public JComboBox<GameLogEntryType> getCboLogEntryType() {
|
||||
return cbpLogEntryType.getJComboBox();
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JCheckBox} */
|
||||
public JCheckBox getCbEnforceDeckLegality() {
|
||||
return cbEnforceDeckLegality;
|
||||
|
||||
@@ -27,7 +27,6 @@ import javax.swing.border.EmptyBorder;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.GameLog;
|
||||
import forge.GameLogEntry;
|
||||
import forge.GameLogEntryType;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
import forge.gui.framework.EDocID;
|
||||
@@ -117,9 +116,7 @@ public enum VLog implements IVDoc<CLog> {
|
||||
// No need to update this unless it's showing
|
||||
if (!parentCell.getSelected().equals(this)) { return; }
|
||||
|
||||
// TODO - some option to make this configurable is probably desirable
|
||||
// By default, grab everything log level 3 or less.
|
||||
final List<GameLogEntry> data = model.getLogEntries(GameLogEntryType.DAMAGE);
|
||||
final List<GameLogEntry> data = model.getLogEntries(model.getGameLogEntryTypeSetting());
|
||||
final int size = data.size();
|
||||
|
||||
pnl.removeAll();
|
||||
|
||||
85
src/main/java/forge/gui/toolbox/FComboBoxPanel.java
Normal file
85
src/main/java/forge/gui/toolbox/FComboBoxPanel.java
Normal file
@@ -0,0 +1,85 @@
|
||||
package forge.gui.toolbox;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.FlowLayout;
|
||||
import javax.swing.DefaultListCellRenderer;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.ListCellRenderer;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class FComboBoxPanel<E> extends JPanel {
|
||||
|
||||
private String comboBoxCaption = "";
|
||||
private final JComboBox<E> comboBox;
|
||||
|
||||
public FComboBoxPanel(E[] comboBoxItems, String comboBoxCaption) {
|
||||
super();
|
||||
this.comboBox = new JComboBox<E>(comboBoxItems);
|
||||
this.comboBoxCaption = comboBoxCaption;
|
||||
applyLayoutAndSkin();
|
||||
}
|
||||
|
||||
public final JComboBox<E> getJComboBox() {
|
||||
return this.comboBox;
|
||||
}
|
||||
|
||||
private void applyLayoutAndSkin() {
|
||||
|
||||
FlowLayout panelLayout = new FlowLayout(FlowLayout.LEFT);
|
||||
panelLayout.setVgap(0);
|
||||
this.setLayout(panelLayout);
|
||||
this.setOpaque(false);
|
||||
|
||||
if (this.comboBoxCaption != "") {
|
||||
JLabel comboLabel;
|
||||
comboLabel = new JLabel(this.comboBoxCaption);
|
||||
comboLabel.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
|
||||
comboLabel.setFont(FSkin.getBoldFont(12));
|
||||
this.add(comboLabel);
|
||||
}
|
||||
|
||||
this.comboBox.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2));
|
||||
this.comboBox.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
|
||||
this.comboBox.setFont(FSkin.getFont(12));
|
||||
this.comboBox.setEditable(false);
|
||||
this.comboBox.setFocusable(true);
|
||||
this.comboBox.setOpaque(true);
|
||||
this.comboBox.setRenderer(new ComplexCellRenderer<E>());
|
||||
this.add(this.comboBox);
|
||||
|
||||
}
|
||||
|
||||
private class ComplexCellRenderer<E1> implements ListCellRenderer<E1> {
|
||||
|
||||
private DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
|
||||
*/
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<? extends E1> lst0, E1 val0, int i0,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
|
||||
JLabel lblItem = (JLabel) defaultRenderer.getListCellRendererComponent(
|
||||
lst0, val0, i0, isSelected, cellHasFocus);
|
||||
|
||||
lblItem.setBorder(new EmptyBorder(4, 3, 4, 3));
|
||||
lblItem.setBackground(FSkin.getColor(hasFocus() ? FSkin.Colors.CLR_ACTIVE : FSkin.Colors.CLR_INACTIVE));
|
||||
lblItem.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
|
||||
lblItem.setFont(FSkin.getFont(12));
|
||||
lblItem.setOpaque(isSelected);
|
||||
return lblItem;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import java.util.List;
|
||||
|
||||
import forge.Constant;
|
||||
import forge.Constant.Preferences;
|
||||
import forge.GameLogEntryType;
|
||||
import forge.game.ai.AiProfileUtil;
|
||||
import forge.gui.home.EMenuItem;
|
||||
import forge.gui.match.VMatchUI;
|
||||
@@ -74,6 +75,7 @@ public class ForgePreferences extends PreferencesStore<ForgePreferences.FPref> {
|
||||
DEV_MODE_ENABLED ("false"),
|
||||
DEV_MILLING_LOSS ("true"),
|
||||
DEV_UNLIMITED_LAND ("false"),
|
||||
DEV_LOG_ENTRY_TYPE (GameLogEntryType.DAMAGE.toString()),
|
||||
|
||||
DECKGEN_SINGLETONS ("false"),
|
||||
DECKGEN_ARTIFACTS ("false"),
|
||||
|
||||
Reference in New Issue
Block a user