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

Always check GUIPrefs if incline highlighting is on #6111

Merged
merged 1 commit into from
Oct 17, 2024
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
6 changes: 3 additions & 3 deletions megamek/src/megamek/client/ui/swing/boardview/BoardView.java
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ public void preferenceChange(PreferenceChangeEvent e) {
break;

case GUIPreferences.INCLINES:
game.getBoard().initializeAllAutomaticTerrain((boolean) e.getNewValue());
game.getBoard().initializeAllAutomaticTerrain();
clearHexImageCache();
boardPanel.repaint();
break;
Expand Down Expand Up @@ -4197,7 +4197,7 @@ public void mouseAction(Coords coords, int mtype, int modifiers, int mouseButton
@Override
public void boardNewBoard(BoardEvent b) {
updateBoard();
game.getBoard().initializeAllAutomaticTerrain(GUIP.getHexInclines());
game.getBoard().initializeAllAutomaticTerrain();
clearHexImageCache();
clearShadowMap();
boardPanel.repaint();
Expand Down Expand Up @@ -4296,7 +4296,7 @@ public void gameBoardNew(GameBoardNewEvent e) {
if (b != null) {
b.addBoardListener(BoardView.this);
}
game.getBoard().initializeAllAutomaticTerrain(GUIP.getHexInclines());
game.getBoard().initializeAllAutomaticTerrain();
clearHexImageCache();
updateBoard();
clearShadowMap();
Expand Down
16 changes: 7 additions & 9 deletions megamek/src/megamek/common/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.io.*;
import java.util.*;

import megamek.client.ui.swing.GUIPreferences;
import megamek.common.annotations.Nullable;
import megamek.common.enums.BasementType;
import megamek.common.event.BoardEvent;
Expand Down Expand Up @@ -492,7 +493,7 @@ private void initializeHex(int x, int y, boolean event) {
}

// Internally handled terrain (inclines, cliff-bottoms)
initializeAutomaticTerrain(x, y, /* useInclines: */ true);
initializeAutomaticTerrain(x, y);

// Add woods/jungle elevation where none was saved
initializeFoliageElev(x, y);
Expand Down Expand Up @@ -528,9 +529,8 @@ private void initializeFoliageElev(int x, int y) {
*
* @param x The hex X-coord.
* @param y The hex Y-coord.
* @param useInclines Indicates whether or not to include inclines at hex exits.
*/
private void initializeAutomaticTerrain(int x, int y, boolean useInclines) {
private void initializeAutomaticTerrain(int x, int y) {
Hex hex = getHex(x, y);
int origCliffTopExits = 0;
int correctedCliffTopExits = 0;
Expand Down Expand Up @@ -606,7 +606,7 @@ private void initializeAutomaticTerrain(int x, int y, boolean useInclines) {
}
addOrRemoveAutoTerrain(hex, Terrains.CLIFF_TOP, correctedCliffTopExits);
addOrRemoveAutoTerrain(hex, Terrains.CLIFF_BOTTOM, cliffBotExits);
if (useInclines) {
if (GUIPreferences.getInstance().getHexInclines()) {
addOrRemoveAutoTerrain(hex, Terrains.INCLINE_TOP, inclineTopExits);
addOrRemoveAutoTerrain(hex, Terrains.INCLINE_BOTTOM, inclineBotExits);
addOrRemoveAutoTerrain(hex, Terrains.INCLINE_HIGH_TOP, highInclineTopExits);
Expand All @@ -632,14 +632,12 @@ private void addOrRemoveAutoTerrain(Hex hex, int terrainType, int exits) {
}

/**
* Rebuilds automatic terrains for the whole board.
*
* @param useInclines Indicates whether to use inclines on hex exits.
* Rebuilds automatic terrains for the whole board, such as incline highlighting. Also fires a BOARD_CHANGED_ALL_HEXES event.
*/
public void initializeAllAutomaticTerrain(boolean useInclines) {
public void initializeAllAutomaticTerrain() {
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
initializeAutomaticTerrain(x, y, useInclines);
initializeAutomaticTerrain(x, y);
}
}
processBoardEvent(new BoardEvent(this, null, BoardEvent.BOARD_CHANGED_ALL_HEXES));
Expand Down