Skip to content

Commit

Permalink
Merge pull request #4931 from Sleet01/RFE_4930_make_Searchlights_star…
Browse files Browse the repository at this point in the history
…t_on_and_toggle_state

Adds 1 new Searchlight option to MegaMek Client options.
  • Loading branch information
NickAragua authored Dec 5, 2023
2 parents 2deb0a6 + eced689 commit 94266d8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,8 @@ CommonSettingsDialog.showDamageDecal=Show damage to units on the unit icon
CommonSettingsDialog.showDamageLevel=Show damage to units on the unit label
CommonSettingsDialog.showIPAddressesInChat.tooltip=<html>If enabled, all server and client IP addresses will be logged in the public chat box.<br>Enabling this can allow information disclosure, such as private IP addresses of the server.</html>
CommonSettingsDialog.showIPAddressesInChat=Show IP Addresses in Chat (WARNING: Security Sensitive)
CommonSettingsDialog.startSearchlightsOn.tooltip=<html>If enabled, units always start with their Searchlights illuminated.</html>
CommonSettingsDialog.startSearchlightsOn=Start with Searchlights on
CommonSettingsDialog.showMapsheets=Show mapsheet borders.
CommonSettingsDialog.showPilotPortraitTT=Show pilot portrait in tooltip.
CommonSettingsDialog.showReportSprites=Show Report Sprites in Report Log
Expand Down
4 changes: 4 additions & 0 deletions megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,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 final JCheckBox startSearchlightsOn = new JCheckBox(Messages.getString("CommonSettingsDialog.startSearchlightsOn"));
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 @@ -1489,6 +1490,7 @@ private JPanel getSettingsPanel() {
addLineSpacer(comps);

comps.add(checkboxEntry(showIPAddressesInChat, Messages.getString("CommonSettingsDialog.showIPAddressesInChat.tooltip")));
comps.add(checkboxEntry(startSearchlightsOn, Messages.getString("CommonSettingsDialog.startSearchlightsOn.tooltip")));
return createSettingsPanel(comps);
}

Expand Down Expand Up @@ -1579,6 +1581,7 @@ public void setVisible(boolean visible) {
stampFormat.setText(CP.getStampFormat());
reportKeywordsTextPane.setText(CP.getReportKeywords());
showIPAddressesInChat.setSelected(CP.getShowIPAddressesInChat());
startSearchlightsOn.setSelected(CP.getStartSearchlightsOn());

defaultAutoejectDisabled.setSelected(CP.defaultAutoejectDisabled());
useAverageSkills.setSelected(CP.useAverageSkills());
Expand Down Expand Up @@ -1997,6 +2000,7 @@ protected void okAction() {
CP.setStampFormat(stampFormat.getText());
CP.setReportKeywords(reportKeywordsTextPane.getText());
CP.setShowIPAddressesInChat(showIPAddressesInChat.isSelected());
CP.setStartSearchlightsOn(startSearchlightsOn.isSelected());

CP.setDefaultAutoejectDisabled(defaultAutoejectDisabled.isSelected());
CP.setUseAverageSkills(useAverageSkills.isSelected());
Expand Down
12 changes: 11 additions & 1 deletion megamek/src/megamek/common/preference/ClientPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ public class ClientPreferences extends PreferenceStoreProxy {
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";
public static final String START_SEARCHLIGHTS_ON = "StartSearchlightsOn";
//endregion Variable Declarations

//region Constructors
public ClientPreferences(IPreferenceStore store) {
this.store = store;
Expand Down Expand Up @@ -89,6 +90,7 @@ public ClientPreferences(IPreferenceStore store) {
store.setDefault(MEMORY_DUMP_ON, false);
store.setDefault(REPORT_KEYWORDS, REPORTKEYWORDSDEFAULTS);
store.setDefault(IP_ADDRESSES_IN_CHAT, false);
store.setDefault(START_SEARCHLIGHTS_ON, true);
setLocale(store.getString(LOCALE));
setMekHitLocLog();
}
Expand Down Expand Up @@ -301,6 +303,14 @@ public void setShowIPAddressesInChat(boolean value) {
store.setValue(IP_ADDRESSES_IN_CHAT, value);
}

public boolean getStartSearchlightsOn() {
return store.getBoolean(START_SEARCHLIGHTS_ON);
}

public void setStartSearchlightsOn(boolean value) {
store.setValue(START_SEARCHLIGHTS_ON, value);
}

protected Locale locale = null;

public void setLocale(String l) {
Expand Down
7 changes: 7 additions & 0 deletions megamek/src/megamek/server/GameManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1072,8 +1072,15 @@ private void resetEntityPhase(GamePhase phase) {
}

// reset spotlights
// If deployment phase, set Searchlight state based on startSearchLightsOn;
if (phase.isDeployment()) {
boolean startSLOn = PreferenceManager.getClientPreferences().getStartSearchlightsOn();
entity.setSearchlightState(startSLOn);
entity.setIlluminated(startSLOn);
}
entity.setIlluminated(false);
entity.setUsedSearchlight(false);

entity.setCarefulStand(false);
entity.setNetworkBAP(false);

Expand Down

0 comments on commit 94266d8

Please sign in to comment.