Skip to content

Commit

Permalink
Merge pull request #4468 from kuronekochomusuke/unitToolTipMaxWidth
Browse files Browse the repository at this point in the history
limit the width of the unit tooltip so that it does not grow really wide
  • Loading branch information
HammerGS authored Jun 4, 2023
2 parents e46d9ce + b4a0fb9 commit 0cdfc4e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
2 changes: 2 additions & 0 deletions megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,8 @@ CommonSettingsDialog.translucentHiddenUnits=Make unseen units translucent
CommonSettingsDialog.uiTheme=UI Theme:
CommonSettingsDialog.unitDisplay=Unit Tooltip / Unit Display
CommonSettingsDialog.unitDisplayHeatToolTip=Max heat value for each level
CommonSettingsDialog.unitTooltipMaxWidth=Max Width for Unit Tooltip
CommonSettingsDialog.unitTooltipMaxWidth.tooltip=keeps tool tip from growing too wide
CommonSettingsDialog.useAverageSkills=Use the current random skill settings when adding units in the lobby.
CommonSettingsDialog.useCamoOverlay=Use Camo Overlay
CommonSettingsDialog.useInclines=Show incline highlighting and shadows at hex borders
Expand Down
7 changes: 5 additions & 2 deletions megamek/src/megamek/client/ui/swing/AimedShotDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import megamek.client.ui.Messages;
import megamek.client.ui.swing.tooltip.UnitToolTip;
import megamek.client.ui.swing.util.UIUtil;
import megamek.client.ui.swing.widget.IndexedRadioButton;
import megamek.common.Targetable;
import megamek.common.annotations.Nullable;
Expand All @@ -44,6 +45,8 @@ public class AimedShotDialog extends JDialog {
private IndexedRadioButton[] checkboxes;
private boolean[] boxEnabled;

private static final GUIPreferences GUIP = GUIPreferences.getInstance();

public AimedShotDialog(JFrame parent, String title, String message,
String[] choices, boolean[] enabled, int selectedIndex,
ClientGUI clientGUI, Targetable target,
Expand All @@ -66,8 +69,8 @@ public AimedShotDialog(JFrame parent, String title, String message,
gridbag.setConstraints(labMessage, c);
getContentPane().add(labMessage);

JLabel labTarget = new JLabel("<html>" + UnitToolTip.getTargetTipDetail(target, clientGUI.getClient().getBoard(), clientGUI) + "</hmtl>",
SwingConstants.LEFT);
String div = "<DIV WIDTH=" + UIUtil.scaleForGUI(500) + ">" + UnitToolTip.getTargetTipDetail(target, clientGUI.getClient().getBoard(), clientGUI) + "</DIV>";
JLabel labTarget = new JLabel("<html>" + div + "</hmtl>", SwingConstants.LEFT);
c.weightx = 1.0;
c.weighty = 1.0;
c.gridwidth = 0;
Expand Down
5 changes: 4 additions & 1 deletion megamek/src/megamek/client/ui/swing/EntityChoiceDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import megamek.client.ui.enums.DialogResult;
import megamek.client.ui.swing.tooltip.UnitToolTip;
import megamek.client.ui.swing.util.UIUtil;
import megamek.common.Entity;
import megamek.common.annotations.Nullable;

Expand All @@ -26,6 +27,7 @@
* in brief or in detail.
*/
public class EntityChoiceDialog extends AbstractChoiceDialog<Entity> {
private static final GUIPreferences GUIP = GUIPreferences.getInstance();

/**
* This creates a modal dialog to pick one or more entities.
Expand All @@ -45,7 +47,8 @@ protected EntityChoiceDialog(JFrame frame, String title, String message,

@Override
protected void detailLabel(JToggleButton button, Entity target) {
button.setText("<html>" + UnitToolTip.getEntityTipVitals(target, null) + "</html>");
String div = "<DIV WIDTH=" + UIUtil.scaleForGUI(500) + ">" + UnitToolTip.getEntityTipVitals(target, null) + "</DIV>";
button.setText("<html>" + div + "</html>");
}

@Override
Expand Down
9 changes: 6 additions & 3 deletions megamek/src/megamek/client/ui/swing/TargetChoiceDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
package megamek.client.ui.swing;

import megamek.client.ui.enums.DialogResult;
import megamek.client.ui.swing.tooltip.HexTooltip;
import megamek.client.ui.swing.tooltip.UnitToolTip;
import megamek.client.ui.swing.util.UIUtil;
import megamek.common.*;
import megamek.common.actions.WeaponAttackAction;
import megamek.common.annotations.Nullable;
Expand All @@ -31,6 +31,8 @@ public class TargetChoiceDialog extends AbstractChoiceDialog<Targetable> {
final ClientGUI clientGUI;
Entity firingEntity;

private static final GUIPreferences GUIP = GUIPreferences.getInstance();

/**
* This creates a modal dialog to pick one or more Targetable objects.
* @param frame parent @JFrame that owns this dialog
Expand Down Expand Up @@ -73,8 +75,9 @@ protected TargetChoiceDialog(JFrame frame, String title, String message,

@Override
protected void detailLabel(JToggleButton button, Targetable target) {
button.setText("<html>" + infoText(target) + UnitToolTip.getTargetTipDetail(target,
clientGUI.getClient().getBoard(), clientGUI) + "</html>");
String div = "<DIV WIDTH=" + UIUtil.scaleForGUI(500) + ">" + infoText(target) + UnitToolTip.getTargetTipDetail(target,
clientGUI.getClient().getBoard(), clientGUI) + "</DIV>";
button.setText("<html>" + div + "</html>");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import megamek.client.ui.swing.boardview.BoardView;
import megamek.client.ui.swing.tooltip.PilotToolTip;
import megamek.client.ui.swing.tooltip.UnitToolTip;
import megamek.client.ui.swing.util.UIUtil;
import megamek.client.ui.swing.widget.*;
import megamek.common.*;
import megamek.common.util.fileUtils.MegaMekFile;
Expand Down

0 comments on commit 0cdfc4e

Please sign in to comment.