Skip to content

Commit

Permalink
Mek crit view: Save toggle state for auto-fill, compact and sort
Browse files Browse the repository at this point in the history
  • Loading branch information
SJuliez committed Aug 4, 2023
1 parent a48e8ba commit eb449d3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 7 additions & 2 deletions megameklab/src/megameklab/ui/mek/BMBuildTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import megameklab.ui.EntitySource;
import megameklab.ui.util.ITab;
import megameklab.ui.util.RefreshListener;
import megameklab.util.CConfig;
import megameklab.util.UnitUtil;

import javax.swing.*;
Expand All @@ -42,6 +43,9 @@ public class BMBuildTab extends ITab {

public BMBuildTab(EntitySource eSource) {
super(eSource);
autoFillUnHittables.setSelected(CConfig.getBooleanParam(CConfig.MEK_AUTOFILL));
autoSort.setSelected(CConfig.getBooleanParam(CConfig.MEK_AUTOSORT));
autoCompact.setSelected(CConfig.getBooleanParam(CConfig.MEK_AUTOCOMPACT));
critView = new BMCriticalView(eSource, refresh);
buildView = new BMBuildView(eSource, refresh, critView);

Expand All @@ -58,10 +62,8 @@ public BMBuildTab(EntitySource eSource) {
private JComponent createButtonPanel() {
autoFillUnHittables.addActionListener(e -> refresh());
autoFillUnHittables.setToolTipText(resources.getString("BuildTab.autoFillUnhittables.tooltip"));
autoFillUnHittables.setSelected(true);
autoCompact.addActionListener(e -> refresh());
autoCompact.setToolTipText(resources.getString("BuildTab.autoCompact.tooltip"));
autoCompact.setSelected(true);
autoSort.addActionListener(e -> refresh());
autoSort.addActionListener(e -> autoCompact.setEnabled(!autoSort.isSelected()));
autoSort.setToolTipText(resources.getString("BuildTab.autoSort.tooltip"));
Expand Down Expand Up @@ -111,6 +113,9 @@ private JComponent createButtonPanel() {
}

public void refresh() {
CConfig.setParam(CConfig.MEK_AUTOFILL, Boolean.toString(autoFillUnHittables.isSelected()));
CConfig.setParam(CConfig.MEK_AUTOSORT, Boolean.toString(autoSort.isSelected()));
CConfig.setParam(CConfig.MEK_AUTOCOMPACT, Boolean.toString(autoCompact.isSelected()));
autoFillUnHittables();
autoCompactCrits();
autoSortCrits();
Expand Down
8 changes: 7 additions & 1 deletion megameklab/src/megameklab/util/CConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ public String shortName() {

public static final String NAG_EQUIPMENT_CTRLCLICK = "nag_equipment_ctrlclick";

public static final String MEK_AUTOFILL = "mekAutofill";
public static final String MEK_AUTOSORT = "mekAutosort";
public static final String MEK_AUTOCOMPACT = "mekAutocompact";

/**
* Player configuration values.
*/
Expand Down Expand Up @@ -140,6 +144,9 @@ private static Properties getDefaults() {
defaults.setProperty(RS_SCALE_FACTOR, "1");
defaults.setProperty(RS_SCALE_UNITS, RSScale.HEXES.toString());
defaults.setProperty(NAG_EQUIPMENT_CTRLCLICK, Boolean.toString(true));
defaults.setProperty(MEK_AUTOFILL, Boolean.toString(true));
defaults.setProperty(MEK_AUTOSORT, Boolean.toString(true));
defaults.setProperty(MEK_AUTOCOMPACT, Boolean.toString(true));

return defaults;
}
Expand All @@ -149,7 +156,6 @@ private static Properties getDefaults() {
*/
public static void load() {
ensureConfigFileExists();

loadConfigFile();
}

Expand Down

0 comments on commit eb449d3

Please sign in to comment.