Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

report keywords managed in client settings #4039

Merged
merged 2 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,7 @@ CommonSettingsDialog.nagForPSR=Confirm all movement that requires a PSR.
CommonSettingsDialog.nagForWiGELanding=Confirm when WiGE does not move far enough to remain airborne.
CommonSettingsDialog.pathFiderTimeLimit=Pathfinder time limit (milliseconds):
CommonSettingsDialog.protoMechUnitCodes=ProtoMech unit codes:
CommonSettingsDialog.ReportKeywords=Report Keywords
CommonSettingsDialog.rightDragScroll=By right-clicking on the map and dragging.
CommonSettingsDialog.scrollSensitivity=Scroll sensitivity:
CommonSettingsDialog.showDamageLevel=Show damage to units on the unit label
Expand Down Expand Up @@ -1946,7 +1947,6 @@ Minimap.TotalHeightLabel=T

#Mini round report display
MiniReportDisplay.Damage=Damage
MiniReportDisplay.Destroyed=Destroyed
MiniReportDisplay.Details=Details
MiniReportDisplay.title=Round Report
MiniReportDisplay.Round=Round
Expand Down
16 changes: 15 additions & 1 deletion megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private <T> void moveElement(DefaultListModel<T> srcModel, int srcIndex, int trg
private final JCheckBox showUnitId = new JCheckBox(Messages.getString("CommonSettingsDialog.showUnitId"));
private JComboBox<String> displayLocale;
private final JCheckBox showIPAddressesInChat = new JCheckBox(Messages.getString("CommonSettingsDialog.showIPAddressesInChat"));

private JTextPane reportKeywordsTextPane;
private final JCheckBox showDamageLevel = new JCheckBox(Messages.getString("CommonSettingsDialog.showDamageLevel"));
private final JCheckBox showDamageDecal = new JCheckBox(Messages.getString("CommonSettingsDialog.showDamageDecal"));
private final JCheckBox showMapsheets = new JCheckBox(Messages.getString("CommonSettingsDialog.showMapsheets"));
Expand Down Expand Up @@ -260,6 +260,8 @@ private <T> void moveElement(DefaultListModel<T> srcModel, int srcIndex, int trg
private int savedFovHighlightAlpha;
private int savedFovDarkenAlpha;
private int savedNumStripesSlider;

private static final String MSG_REPORTKEYWORDS = Messages.getString("CommonSettingsDialog.ReportKeywords");
HashMap<String, String> savedAdvancedOpt = new HashMap<>();

/** Constructs the Client Settings Dialog with a clientgui (used within the client, i.e. in lobby and game). */
Expand Down Expand Up @@ -497,6 +499,16 @@ private JPanel getSettingsPanel() {
comps.add(row);

addLineSpacer(comps);

JLabel reportKeywordsLabel = new JLabel(MSG_REPORTKEYWORDS + ": ");
reportKeywordsTextPane = new JTextPane();
row = new ArrayList<>();
row.add(reportKeywordsLabel);
row.add(reportKeywordsTextPane);
comps.add(row);

addLineSpacer(comps);

comps.add(checkboxEntry(showIPAddressesInChat, Messages.getString("CommonSettingsDialog.showIPAddressesInChat.tooltip")));
return createSettingsPanel(comps);
}
Expand Down Expand Up @@ -581,6 +593,7 @@ public void setVisible(boolean visible) {
stampFilenames.setSelected(cs.stampFilenames());
stampFormat.setEnabled(stampFilenames.isSelected());
stampFormat.setText(cs.getStampFormat());
reportKeywordsTextPane.setText(cs.getReportKeywords());
showIPAddressesInChat.setSelected(cs.getShowIPAddressesInChat());

defaultAutoejectDisabled.setSelected(cs.defaultAutoejectDisabled());
Expand Down Expand Up @@ -789,6 +802,7 @@ protected void okAction() {
// cs.setGameLogMaxSize(Integer.parseInt(gameLogMaxSize.getText()));
cs.setStampFilenames(stampFilenames.isSelected());
cs.setStampFormat(stampFormat.getText());
cs.setReportKeywords(reportKeywordsTextPane.getText());
cs.setShowIPAddressesInChat(showIPAddressesInChat.isSelected());

cs.setDefaultAutoejectDisabled(defaultAutoejectDisabled.isSelected());
Expand Down
14 changes: 9 additions & 5 deletions megamek/src/megamek/client/ui/swing/MiniReportDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import megamek.client.ui.Messages;
import megamek.client.ui.swing.util.BASE64ToolKit;
import megamek.client.ui.swing.util.UIUtil;
import megamek.common.preference.ClientPreferences;
import megamek.common.preference.IPreferenceChangeListener;
import megamek.common.preference.PreferenceChangeEvent;
import megamek.common.Player;
Expand All @@ -25,6 +26,7 @@
import megamek.common.event.GameListener;
import megamek.common.event.GameListenerAdapter;
import megamek.common.event.GamePhaseChangeEvent;
import megamek.common.preference.PreferenceManager;

import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
Expand Down Expand Up @@ -56,7 +58,6 @@ public class MiniReportDisplay extends JDialog implements ActionListener, Hyperl
private static final String MSG_ROUND = Messages.getString("MiniReportDisplay.Round");
private static final String MSG_PHASE = Messages.getString("MiniReportDisplay.Phase");
private static final String MSG_DAMAGE = Messages.getString("MiniReportDisplay.Damage");
private static final String MSG_DESTROYED = Messages.getString("MiniReportDisplay.Destroyed");
private static final String MSG_ARROWUP = Messages.getString("MiniReportDisplay.ArrowUp");
private static final String MSG_ARROWDOWN = Messages.getString("MiniReportDisplay.ArrowDown");
private static final String MSG_DETAILS = Messages.getString("MiniReportDisplay.Details");
Expand Down Expand Up @@ -126,6 +127,7 @@ public void windowClosing(WindowEvent e) {

adaptToGUIScale();
GUIPreferences.getInstance().addPreferenceChangeListener(this);
PreferenceManager.getClientPreferences().addPreferenceChangeListener(this);
butOkay.requestFocus();
}

Expand Down Expand Up @@ -236,7 +238,6 @@ private void updateEntityChoice() {
comboEntity.setEnabled(false);
}
comboEntity.setSelectedItem(lastChoice);
comboEntity.setSelectedItem(lastChoice);
if (comboEntity.getSelectedIndex() < 0) {
comboEntity.setSelectedIndex(0);
}
Expand All @@ -247,9 +248,10 @@ private void updateQuickChoice() {
lastChoice = (lastChoice != null ? lastChoice : MSG_DAMAGE);
comboQuick.removeAllItems();
comboQuick.setEnabled(true);
comboQuick.addItem(MSG_DAMAGE);
comboQuick.addItem(MSG_DESTROYED);
comboQuick.addItem(MSG_PHASE);
String[] keywords = PreferenceManager.getClientPreferences().getReportKeywords().split("\n");
for (String keyword : keywords) {
comboQuick.addItem(keyword);
}
if (comboQuick.getItemCount() == 1) {
comboQuick.setEnabled(false);
}
Expand Down Expand Up @@ -431,6 +433,8 @@ public void preferenceChange(PreferenceChangeEvent e) {
// Update the text size when the GUI scaling changes
if (e.getName().equals(GUIPreferences.GUI_SCALE)) {
adaptToGUIScale();
} else if (e.getName().equals(ClientPreferences.REPORT_KEYWORDS)) {
updateQuickChoice();
}
}
}
11 changes: 11 additions & 0 deletions megamek/src/megamek/common/preference/ClientPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public class ClientPreferences extends PreferenceStoreProxy {
public static final String BOARD_HEIGHT = "BoardHeight";
public static final String MAP_WIDTH = "MapWidth";
public static final String MAP_HEIGHT = "MapHeight";
public static final String REPORT_KEYWORDS = "ReportKeywords";
private static final String REPORTKEYWORDSDEFAULTS = "Needs\nRolls\nTakes\nHit\nFalls\nSkill Roll\nPilot Skill\nPhase\nDestroyed\nDamage";
public static final String IP_ADDRESSES_IN_CHAT = "IPAddressesInChat";
//endregion Variable Declarations

Expand Down Expand Up @@ -86,6 +88,7 @@ public ClientPreferences(IPreferenceStore store) {
store.setDefault(MAP_HEIGHT, 1);
store.setDefault(DEBUG_OUTPUT_ON, false);
store.setDefault(MEMORY_DUMP_ON, false);
store.setDefault(REPORT_KEYWORDS, REPORTKEYWORDSDEFAULTS);
store.setDefault(IP_ADDRESSES_IN_CHAT, false);
setLocale(store.getString(LOCALE));
setMekHitLocLog();
Expand Down Expand Up @@ -283,6 +286,14 @@ public void setGUIName(String guiName) {
store.setValue(GUI_NAME, guiName);
}

public String getReportKeywords() {
return store.getString(REPORT_KEYWORDS);
}

public void setReportKeywords(String s) {
store.setValue(REPORT_KEYWORDS, s);
}

public boolean getShowIPAddressesInChat() {
return store.getBoolean(IP_ADDRESSES_IN_CHAT);
}
Expand Down