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

feat: added sensor range on minimap, added facing arrow on minimap #6446

Merged
merged 6 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 4 additions & 1 deletion megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,8 @@ CommonSettingsDialog.main=Main
CommonSettingsDialog.audio=Audio
CommonSettingsDialog.miniMap=Mini Map
CommonSettingsDialog.mmSymbol=Use StratOps unit symbols in the Minimap
CommonSettingsDialog.drawFacingArrowsOnMiniMap=Draw unit facing arrows on the minimap
CommonSettingsDialog.drawSensorRangeOnMiniMap=Draw unit's active sensor range on the minimap
CommonSettingsDialog.mouseWheelZoom=Mouse wheel zooms map.
CommonSettingsDialog.mouseWheelZoomFlip=Flip mouse wheel zoom direction.
CommonSettingsDialog.moveDefaultClimbMode.tooltip=Sets the default climb mode. false = Go Thru, true = Climb Up
Expand Down Expand Up @@ -2445,7 +2447,8 @@ Minimap.menu.ShowHeightTotal=Total T
Minimap.menu.ShowSymbols=Show Symbols
Minimap.menu.ShowSymbolsNoSymbols=No Symbols N
Minimap.menu.ShowSymbolsSymbols=Symbols S

Minimap.menu.ToggleShowSensorRange=Toggle Sensors
Minimap.menu.ToggleDrawFacingArrows=Toggle Facing Arrows

#Mini round report display
MiniReportDisplay.Damage=Damage
Expand Down
21 changes: 19 additions & 2 deletions megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ private <T> void moveElement(DefaultListModel<T> srcModel, int srcIndex, int trg
private final JCheckBox aOHexShadows = new JCheckBox(Messages.getString("CommonSettingsDialog.aOHexSHadows"));
private final JCheckBox floatingIso = new JCheckBox(Messages.getString("CommonSettingsDialog.floatingIso"));
private final JCheckBox mmSymbol = new JCheckBox(Messages.getString("CommonSettingsDialog.mmSymbol"));
private final JCheckBox drawFacingArrowsOnMiniMap = new JCheckBox(Messages.getString("CommonSettingsDialog.drawFacingArrowsOnMiniMap"));
private final JCheckBox drawSensorRangeOnMiniMap = new JCheckBox(Messages.getString("CommonSettingsDialog.drawSensorRangeOnMiniMap"));
private final JCheckBox entityOwnerColor = new JCheckBox(
Messages.getString("CommonSettingsDialog.entityOwnerColor"));
private final JCheckBox teamColoring = new JCheckBox(Messages.getString("CommonSettingsDialog.teamColoring"));
Expand Down Expand Up @@ -502,6 +504,8 @@ private <T> void moveElement(DefaultListModel<T> srcModel, int srcIndex, int trg
private boolean savedLevelhighlight;
private boolean savedFloatingIso;
private boolean savedMmSymbol;
private boolean savedDrawFacingArrowsOnMiniMap;
private boolean savedDrawSensorRangeOnMiniMap;
private boolean savedTeamColoring;
private boolean savedDockOnLeft;
private boolean savedDockMultipleOnYAxis;
Expand Down Expand Up @@ -1659,6 +1663,8 @@ private JPanel getMiniMapPanel() {
comps.add(checkboxEntry(gameSummaryMM,
Messages.getString("CommonSettingsDialog.gameSummaryMM.tooltip",
Configuration.gameSummaryImagesMMDir())));
comps.add(checkboxEntry(drawFacingArrowsOnMiniMap, null));
comps.add(checkboxEntry(drawSensorRangeOnMiniMap, null));
return createSettingsPanel(comps);
}

Expand Down Expand Up @@ -2049,6 +2055,8 @@ public void setVisible(boolean visible) {
aOHexShadows.setSelected(GUIP.getAOHexShadows());
floatingIso.setSelected(GUIP.getFloatingIso());
mmSymbol.setSelected(GUIP.getMmSymbol());
drawFacingArrowsOnMiniMap.setSelected(GUIP.getDrawFacingArrowsOnMiniMap());
drawSensorRangeOnMiniMap.setSelected(GUIP.getDrawSensorRangeOnMiniMap());
levelhighlight.setSelected(GUIP.getLevelHighlight());
shadowMap.setSelected(GUIP.getShadowMap());
hexInclines.setSelected(GUIP.getHexInclines());
Expand All @@ -2070,7 +2078,7 @@ public void setVisible(boolean visible) {
}
}

minimapTheme.setSelectedItem(CLIENT_PREFERENCES.getMinimapTheme());
minimapTheme.setSelectedItem(CLIENT_PREFERENCES.getMinimapTheme().getName());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes #6464


gameSummaryBV.setSelected(GUIP.getGameSummaryBoardView());
gameSummaryMM.setSelected(GUIP.getGameSummaryMinimap());
Expand Down Expand Up @@ -2139,6 +2147,8 @@ public void setVisible(boolean visible) {
savedLevelhighlight = GUIP.getLevelHighlight();
savedFloatingIso = GUIP.getFloatingIso();
savedMmSymbol = GUIP.getMmSymbol();
savedDrawFacingArrowsOnMiniMap = GUIP.getDrawFacingArrowsOnMiniMap();
savedDrawSensorRangeOnMiniMap = GUIP.getDrawSensorRangeOnMiniMap();
savedTeamColoring = GUIP.getTeamColoring();
savedDockOnLeft = GUIP.getDockOnLeft();
savedDockMultipleOnYAxis = GUIP.getDockMultipleOnYAxis();
Expand Down Expand Up @@ -2179,6 +2189,8 @@ protected void cancelAction() {
GUIP.setLevelHighlight(savedLevelhighlight);
GUIP.setFloatingIso(savedFloatingIso);
GUIP.setMmSymbol(savedMmSymbol);
GUIP.setDrawSensorRangeOnMiniMap(savedDrawSensorRangeOnMiniMap);
GUIP.setDrawFacingArrowsOnMiniMap(savedDrawFacingArrowsOnMiniMap);
GUIP.setTeamColoring(savedTeamColoring);
GUIP.setDockOnLeft(savedDockOnLeft);
GUIP.setDockMultipleOnYAxis(savedDockMultipleOnYAxis);
Expand Down Expand Up @@ -2429,7 +2441,8 @@ protected void okAction() {

GUIP.setAttackArrowTransparency((Integer) attackArrowTransparency.getValue());
GUIP.setECMTransparency((Integer) ecmTransparency.getValue());

GUIP.setDrawFacingArrowsOnMiniMap(drawFacingArrowsOnMiniMap.isSelected());
GUIP.setDrawSensorRangeOnMiniMap(drawSensorRangeOnMiniMap.isSelected());
try {
GUIP.setButtonsPerRow(Integer.parseInt(buttonsPerRow.getText()));
} catch (Exception ex) {
Expand Down Expand Up @@ -2909,6 +2922,10 @@ public void itemStateChanged(ItemEvent event) {
GUIP.setShowDamageLevel(showDamageLevel.isSelected());
} else if (source.equals(chkHighQualityGraphics)) {
GUIP.setHighQualityGraphics(chkHighQualityGraphics.isSelected());
} else if (source.equals(drawFacingArrowsOnMiniMap)) {
GUIP.setDrawFacingArrowsOnMiniMap(drawFacingArrowsOnMiniMap.isSelected());
} else if (source.equals(drawSensorRangeOnMiniMap)) {
GUIP.setDrawFacingArrowsOnMiniMap(drawSensorRangeOnMiniMap.isSelected());
}
}

Expand Down
18 changes: 18 additions & 0 deletions megamek/src/megamek/client/ui/swing/GUIPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ public class GUIPreferences extends PreferenceStoreProxy {
public static final String MINI_MAP_SYMBOLS_DISPLAY_MODE = "MinimapSymbolsDisplayMode";
public static final String MINI_MAP_AUTO_DISPLAY_REPORT_PHASE = "MinimapAutoDisplayReportPhase";
public static final String MINI_MAP_AUTO_DISPLAY_NONREPORT_PHASE = "MinimapAutoDisplayNonReportPhase";
public static final String MINI_MAP_SHOW_SENSOR_RANGE = "MinimapShowSensorRange";
public static final String MINI_MAP_SHOW_FACING_ARROW = "MinimapShowFacingArrow";
public static final String FIRE_DISPLAY_TAB_DURING_PHASES = "FireDisplayTabDuringPhases";
public static final String MOVE_DISPLAY_TAB_DURING_PHASES = "MoveDisplayTabDuringPhases";
public static final String MINIMUM_SIZE_HEIGHT = "MinimumSizeHeight";
Expand Down Expand Up @@ -3435,4 +3437,20 @@ public File[] getMinimapThemes() {
// List all .theme files inside the minimap themes folder
return Configuration.minimapThemesDir().listFiles((dir, name) -> name.endsWith(".theme"));
}

public boolean getDrawFacingArrowsOnMiniMap() {
return getBoolean(MINI_MAP_SHOW_SENSOR_RANGE);
}

public boolean getDrawSensorRangeOnMiniMap() {
return getBoolean(MINI_MAP_SHOW_FACING_ARROW);
}

public void setDrawFacingArrowsOnMiniMap(boolean state) {
store.setValue(MINI_MAP_SHOW_SENSOR_RANGE, state);
}

public void setDrawSensorRangeOnMiniMap(boolean state) {
store.setValue(MINI_MAP_SHOW_FACING_ARROW, state);
}
}
3 changes: 3 additions & 0 deletions megamek/src/megamek/client/ui/swing/MovementDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,9 @@ private void updateMove(boolean redrawMovement) {
}

private void updateFleeButton() {
if (ce() == null) {
return;
}
boolean hasLastStep = (cmd != null) && (cmd.getLastStep() != null);
boolean fleeStart = !hasLastStep &&
ce().canFlee(ce().getPosition());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5201,7 +5201,7 @@ Entity getSelectedEntity() {
return clientgui != null ? clientgui.getDisplayedUnit() : null;
}

FovHighlightingAndDarkening getFovHighlighting() {
public FovHighlightingAndDarkening getFovHighlighting() {
return fovHighlightingAndDarkening;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
/**
* A helper class for highlighting and darkening hexes.
*/
class FovHighlightingAndDarkening {
public class FovHighlightingAndDarkening {
private static final MMLogger logger = MMLogger.create(FovHighlightingAndDarkening.class);

private final BoardView boardView1;
Expand Down Expand Up @@ -266,6 +266,14 @@ private void clearCache() {

GameListener cacheGameListner;

/**
* Returns the cached all ECM info.
* @return the cached all ECM info, nullable
*/
public @Nullable List<ECMInfo> getCachedECMInfo() {
return cachedAllECMInfo;
}

/**
* Checks for los effects, preferably from cache, if not getLosEffects
* is invoked and it's return value is cached.
Expand Down
Loading
Loading