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

add client setting for Max Range to Draw Sensor / Visual Rings #4470

Merged
merged 6 commits into from
Jun 7, 2023
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: 2 additions & 0 deletions megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,8 @@ CommonSettingsDialog.seenby.PlayerDetailed=Player Detailed
CommonSettingsDialog.seenby.Someone=Someone
CommonSettingsDialog.seenby.Team=Team
CommonSettingsDialog.seenby.label=Seen by Resolution:
CommonSettingsDialog.sensorMaxDrawRange=Max Range to Draw Sensor / Visual Rings
CommonSettingsDialog.sensorMaxDrawRange.tooltip=large values will slow down game, can set to 0 to turn off completely
CommonSettingsDialog.showArmorMiniVisTT=Show mini armor visualization in the tooltip.
CommonSettingsDialog.showDamageDecal=Show damage to units on the unit icon
CommonSettingsDialog.showDamageLevel=Show damage to units on the unit label
Expand Down
2 changes: 1 addition & 1 deletion megamek/src/megamek/client/ui/swing/GUIPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ protected GUIPreferences() {
setDefault(BOARD_FIELD_OF_FIRE_LONG_COLOR, new Color(60, 150, 60));
setDefault(BOARD_FIELD_OF_FIRE_EXTREME_COLOR, new Color(40, 100, 40));
setDefault(BOARD_SENSOR_RANGE_COLOR, new Color(105, 105, 245));
setDefault(BOARD_VISUAL_RANGE_COLOR, new Color(100, 100, 150));
setDefault(BOARD_VISUAL_RANGE_COLOR, new Color(255, 204, 255));
setDefault(BOARD_UNIT_SELECTED_COLOR, DEFAULT_MAGENTA);
setDefault(BOARD_UNIT_VALID_COLOR, DEFAULT_CYAN);
setDefault(BOARD_UNIT_TEXT_COLOR, Color.white);
Expand Down
17 changes: 13 additions & 4 deletions megamek/src/megamek/client/ui/swing/boardview/BoardView.java
Original file line number Diff line number Diff line change
Expand Up @@ -6442,7 +6442,7 @@ public RangeHelper(int min, int max) {

// prepares the sprites for visual and sensor ranges
public void setSensorRange(Entity entity, Coords c) {
if (entity == null || c == null) {
if (entity == null || c == null || !GUIP.getShowSensorRange()) {
clearSensorsRanges();
return;
}
Expand All @@ -6459,7 +6459,8 @@ public void setSensorRange(Entity entity, Coords c) {
int minAirSensorRange = 0;
int maxAirSensorRange = 0;

if (game.getOptions().booleanOption(OptionsConstants.ADVANCED_TACOPS_SENSORS)) {
if (game.getOptions().booleanOption(OptionsConstants.ADVANCED_TACOPS_SENSORS)
|| game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_STRATOPS_ADVANCED_SENSORS)) {
Compute.SensorRangeHelper srh = Compute.getSensorRanges(entity.getGame(), entity);

if (srh != null) {
Expand Down Expand Up @@ -6497,11 +6498,19 @@ public void setSensorRange(Entity entity, Coords c) {
List<Set<Coords>> sensorRanges = new ArrayList<>(1);
int j = 0;

// find max range possible on map, no need to check beyond it
int rangeToCorner = (new Coords(0, game.getBoard().getHeight())).distance(c);
rangeToCorner = Math.max(rangeToCorner, (new Coords(0, 0)).distance(c));
rangeToCorner = Math.max(rangeToCorner, (new Coords(game.getBoard().getWidth(), 0)).distance(c));
rangeToCorner = Math.max(rangeToCorner, (new Coords(game.getBoard().getWidth(), game.getBoard().getHeight())).distance(c));

for (RangeHelper rangeH : lBrackets) {
sensorRanges.add(new HashSet<>());
int rangeMin = Math.min(rangeH.min, rangeToCorner);
int rangeMax = Math.min(rangeH.max, rangeToCorner);

if (rangeH.max > 0) {
for (int i = rangeH.min; i <= rangeH.max; i++) {
if (rangeMin != rangeMax) {
for (int i = rangeMin; i <= rangeMax; i++) {
// Add all hexes up to the range to separate lists
sensorRanges.get(j).addAll(c.allAtDistance(i));
}
Expand Down