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

show sensor info and sensor rings when TacOps Sensors Rules are on OR … #4565

Merged
merged 3 commits into from
Jun 26, 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: 1 addition & 1 deletion megamek/i18n/megamek/common/options/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ GameOptionsInfo.option.stratops_bearings_only_velocity.description=Improves the
GameOptionsInfo.option.stratops_waypoint_launch.displayableName=StratOps Capital Missile Waypoint Launch
GameOptionsInfo.option.stratops_waypoint_launch.description=Alternate mode for capital missiles per SO pg 102. Greatly increases firing arc for capital missiles but with a +1 TH penalty
GameOptionsInfo.option.stratops_advanced_sensors.displayableName=StratOps Advanced Sensors
GameOptionsInfo.option.stratops_advanced_sensors.description=Advanced sensor rules per SO pg 117. Works correctly only if Double Blind and TacOps sensors rules are also turned on
GameOptionsInfo.option.stratops_advanced_sensors.description=Advanced sensor suite rules for aerospace combat in space. per SO 4th ed, pg 105. Works correctly only if Double Blind and TacOps sensors rules are also turned on
GameOptionsInfo.option.variable_damage_thresh.displayableName=StratOps variable damage thresholds
GameOptionsInfo.option.variable_damage_thresh.description=Damage threshold for critical hits depends depends on current armor levels rather than initial armor levels
GameOptionsInfo.option.at2_nukes.displayableName=Allow nuclear weapons
Expand Down
5 changes: 3 additions & 2 deletions megamek/src/megamek/client/ui/swing/boardview/BoardView.java
Original file line number Diff line number Diff line change
Expand Up @@ -6433,9 +6433,10 @@ public void setSensorRange(Entity entity, Coords c) {
int maxSensorRange = 0;
int minAirSensorRange = 0;
int maxAirSensorRange = 0;
GameOptions gameOptions = game.getOptions();

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

if (srh != null) {
Expand Down
11 changes: 7 additions & 4 deletions megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import megamek.common.*;
import megamek.common.alphaStrike.AlphaStrikeElement;
import megamek.common.annotations.Nullable;
import megamek.common.options.GameOptions;
import megamek.common.options.OptionsConstants;
import megamek.common.preference.PreferenceManager;
import megamek.common.templates.TROView;
Expand Down Expand Up @@ -1038,6 +1039,7 @@ private static String getDamageLevelDesc(Entity entity) {
private static StringBuilder inGameValues(Entity entity, Player localPlayer, boolean inGameValue,
boolean showBV, boolean showSensors, boolean showSeenBy) {
Game game = entity.getGame();
GameOptions gameOptions = game.getOptions();
boolean isGunEmplacement = entity instanceof GunEmplacement;
String result = "";

Expand All @@ -1049,7 +1051,7 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer, boo
// BV Info
// Hidden for invisible units when in double blind and hide enemy bv is selected
// Also not shown in the lobby as BV is shown there outside the tooltip
boolean showEnemyBV = !(game.getOptions().booleanOption(OptionsConstants.ADVANCED_SUPPRESS_DB_BV) && game.getOptions().booleanOption(OptionsConstants.ADVANCED_DOUBLE_BLIND));
boolean showEnemyBV = !(gameOptions.booleanOption(OptionsConstants.ADVANCED_SUPPRESS_DB_BV) && gameOptions.booleanOption(OptionsConstants.ADVANCED_DOUBLE_BLIND));
boolean isVisible = EntityVisibilityUtils.trackThisEntitiesVisibilityInfo(localPlayer, entity);

if (isVisible || showEnemyBV) {
Expand Down Expand Up @@ -1224,9 +1226,9 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer, boo

if (showSeenBy) {
// If Double Blind, add information about who sees this Entity
if (game.getOptions().booleanOption(OptionsConstants.ADVANCED_DOUBLE_BLIND)) {
if (gameOptions.booleanOption(OptionsConstants.ADVANCED_DOUBLE_BLIND)) {
StringBuffer tempList = new StringBuffer();
boolean teamVision = game.getOptions().booleanOption(OptionsConstants.ADVANCED_TEAM_VISION);
boolean teamVision = gameOptions.booleanOption(OptionsConstants.ADVANCED_TEAM_VISION);
int seenByResolution = GUIP.getUnitToolTipSeenByResolution();
String tmpStr = "";

Expand Down Expand Up @@ -1269,7 +1271,8 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer, boo

if (showSensors) {
// If sensors, display what sensors this unit is using
if (game.getOptions().booleanOption(OptionsConstants.ADVANCED_TACOPS_SENSORS) || game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_STRATOPS_ADVANCED_SENSORS)) {
if (gameOptions.booleanOption(OptionsConstants.ADVANCED_TACOPS_SENSORS)
|| (gameOptions.booleanOption(OptionsConstants.ADVAERORULES_STRATOPS_ADVANCED_SENSORS)) && entity.isSpaceborne()) {
String visualRange = Compute.getMaxVisualRange(entity, false) + "";
if (game.getPlanetaryConditions().isIlluminationEffective()) {
visualRange += " (" + Compute.getMaxVisualRange(entity, true) + ")";
Expand Down
134 changes: 70 additions & 64 deletions megamek/src/megamek/client/ui/swing/unitDisplay/ExtraPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import megamek.client.ui.swing.tooltip.UnitToolTip;
import megamek.common.*;
import megamek.common.enums.GamePhase;
import megamek.common.options.GameOptions;
import megamek.common.options.OptionsConstants;
import megamek.common.preference.IPreferenceChangeListener;
import megamek.common.preference.PreferenceChangeEvent;
Expand Down Expand Up @@ -333,13 +334,15 @@ public void displayMech(Entity en) {
chSensors.setEnabled(true);
dontChange = false;
}

// Walk through the list of teams. There
// can't be more teams than players.
StringBuffer buff;
if (clientgui != null) {
Enumeration<Player> loop = clientgui.getClient().getGame().getPlayers();
while (loop.hasMoreElements()) {
Player player = loop.nextElement();
Game game = clientgui.getClient().getGame();
GameOptions gameOptions = game.getOptions();

for (Player player : game.getPlayersList()) {
int team = player.getTeam();
if (en.isNarcedBy(team) && !player.isObserver()) {
buff = new StringBuffer(Messages.getString("MechDisplay.NARCedBy"));
Expand Down Expand Up @@ -467,81 +470,84 @@ public void displayMech(Entity en) {
if (narcList.getModel().getSize() == 0) {
((DefaultListModel<String>) narcList.getModel()).addElement(" ");
}
}


// transport values
String unused = en.getUnusedString();
if (unused.isBlank()) {
unused = Messages.getString("MechDisplay.None");
}
unusedR.setText(unused);
carrysR.setText(null);
// boolean hasText = false;
for (Entity other : en.getLoadedUnits()) {
carrysR.append(other.getShortName());
carrysR.append("\n");
}
// transport values
String unused = en.getUnusedString();
if (unused.isBlank()) {
unused = Messages.getString("MechDisplay.None");
}
unusedR.setText(unused);
carrysR.setText(null);
// boolean hasText = false;
for (Entity other : en.getLoadedUnits()) {
carrysR.append(other.getShortName());
carrysR.append("\n");
}

// Show club(s).
for (Mounted club : en.getClubs()) {
carrysR.append(club.getName());
carrysR.append("\n");
}
// Show club(s).
for (Mounted club : en.getClubs()) {
carrysR.append(club.getName());
carrysR.append("\n");
}

// Show searchlight
if (en.hasSearchlight()) {
if (en.isUsingSearchlight()) {
carrysR.append(Messages.getString("MechDisplay.SearchlightOn"));
} else {
carrysR.append(Messages.getString("MechDisplay.SearchlightOff"));
// Show searchlight
if (en.hasSearchlight()) {
if (en.isUsingSearchlight()) {
carrysR.append(Messages.getString("MechDisplay.SearchlightOn"));
} else {
carrysR.append(Messages.getString("MechDisplay.SearchlightOff"));
}
}
}

// Show Heat Effects, but only for Mechs.
heatR.setText("");
sinksR.setText("");
// Show Heat Effects, but only for Mechs.
heatR.setText("");
sinksR.setText("");

if (en instanceof Mech) {
Mech m = (Mech) en;
if (en instanceof Mech) {
Mech m = (Mech) en;

sinks2B.setEnabled(!dontChange);
sinks = m.getActiveSinksNextRound();
if (m.hasDoubleHeatSinks()) {
sinksR.append(Messages.getString("MechDisplay.activeSinksTextDouble",
sinks, sinks * 2));
} else {
sinksR.append(Messages.getString("MechDisplay.activeSinksTextSingle", sinks));
}
sinks2B.setEnabled(!dontChange);
sinks = m.getActiveSinksNextRound();
if (m.hasDoubleHeatSinks()) {
sinksR.append(Messages.getString("MechDisplay.activeSinksTextDouble",
sinks, sinks * 2));
} else {
sinksR.append(Messages.getString("MechDisplay.activeSinksTextSingle", sinks));
}

boolean hasTSM = false;
boolean mtHeat = false;
if (((Mech) en).hasTSM(false)) {
hasTSM = true;
}
boolean hasTSM = false;
boolean mtHeat = false;
if (((Mech) en).hasTSM(false)) {
hasTSM = true;
}

if ((clientgui != null)
&& clientgui.getClient().getGame().getOptions()
.booleanOption(OptionsConstants.ADVCOMBAT_TACOPS_HEAT)) {
mtHeat = true;
if (gameOptions.booleanOption(OptionsConstants.ADVCOMBAT_TACOPS_HEAT)) {
mtHeat = true;
}
heatR.setForeground(GUIPreferences.getInstance().getColorForHeat(en.heat));
heatR.append(HeatEffects.getHeatEffects(en.heat, mtHeat, hasTSM));
} else {
// Non-Mechs cannot configure their heat sinks
sinks2B.setEnabled(false);
}
heatR.setForeground(GUIPreferences.getInstance().getColorForHeat(en.heat));
heatR.append(HeatEffects.getHeatEffects(en.heat, mtHeat, hasTSM));
} else {
// Non-Mechs cannot configure their heat sinks
sinks2B.setEnabled(false);
}

dumpBombs.setEnabled(false);
dumpBombs.setEnabled(false);

refreshSensorChoices(en);
refreshSensorChoices(en);

if (null != en.getActiveSensor()) {
String tmpStr = Messages.getString("MechDisplay.CurrentSensors") + " " + UnitToolTip.getSensorDesc(en);
tmpStr = String.format("<html><div WIDTH=%d>%s</div></html>", 250, tmpStr);
curSensorsL.setText(tmpStr);
} else {
curSensorsL.setText((Messages.getString("MechDisplay.CurrentSensors")).concat(" "));
if (null != en.getActiveSensor()) {
String sensorDesc = "";
if (gameOptions.booleanOption(OptionsConstants.ADVANCED_TACOPS_SENSORS)
|| (gameOptions.booleanOption(OptionsConstants.ADVAERORULES_STRATOPS_ADVANCED_SENSORS)) && en.isSpaceborne()) {
sensorDesc = UnitToolTip.getSensorDesc(en);
}
String tmpStr = Messages.getString("MechDisplay.CurrentSensors") + " " + sensorDesc;
tmpStr = String.format("<html><div WIDTH=%d>%s</div></html>", 250, tmpStr);
curSensorsL.setText(tmpStr);
} else {
curSensorsL.setText((Messages.getString("MechDisplay.CurrentSensors")).concat(" "));
}
}

if (en.getLastTarget() != Entity.NONE) {
Expand Down