diff --git a/megamek/docs/history.txt b/megamek/docs/history.txt index 51954debb8a..4f7ef15bd18 100644 --- a/megamek/docs/history.txt +++ b/megamek/docs/history.txt @@ -51,6 +51,7 @@ VERSION HISTORY: + Issue #4949: return impossible instead of raising an error + PR #4957: More tooltips colors (set FG color and BG color for more tooltips, add highlight, weapon, quirk client settings, consolidate some colors into existing client setting colors) + PR #4922: Add deployment options (There is a lot in this one see note from PR link for specifics) ++ PR #4981: Add unit readout button (Warbook) that displays the unit summary, TRO entry, and AS card in Game 0.49.15 (2023-10-21 1530 UTC) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index 96cdfed9273..4cc8eded1ec 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -899,6 +899,7 @@ ClientGUI.targetMenuItem=Target ClientGUI.title=MegaMek Client ClientGUI.TransmittingData=Transmitting game data... ClientGUI.viewMenuItem=View +ClientGUI.viewReadoutMenuItem=View Readout ClientGUI.doneMenuItem=Done ClientGUI.waitingOnTheServer=Waiting on the server... ClientGUI.PointBlankShot.Message={0} has moved adjacent to the hidden {1}. Take pointblank shot? @@ -1985,6 +1986,7 @@ MechDisplay.Target=Target: MechDisplay.ToHit=To Hit: MechDisplay.Turretlocked=Turret locked MechDisplay.Unit=Unit +MechDisplay.UnitReadout=Unit Readout MechDisplay.UnusedSpace=Unused Space: MechDisplay.Weapon=Weapon MechDisplay.Variable=Variable diff --git a/megamek/src/megamek/client/ui/swing/MapMenu.java b/megamek/src/megamek/client/ui/swing/MapMenu.java index 74b3f4658f4..0efb665fdb6 100644 --- a/megamek/src/megamek/client/ui/swing/MapMenu.java +++ b/megamek/src/megamek/client/ui/swing/MapMenu.java @@ -22,6 +22,7 @@ import megamek.client.Client; import megamek.client.event.BoardViewEvent; import megamek.client.ui.Messages; +import megamek.client.ui.swing.lobby.LobbyUtility; import megamek.common.*; import megamek.common.Building.DemolitionCharge; import megamek.common.actions.BAVibroClawAttackAction; @@ -330,6 +331,23 @@ private JMenuItem viewJMenuItem(Entity en) { return item; } + private JMenuItem viewReadoutJMenuItem(Entity en) { + JMenuItem item = new JMenuItem(Messages.getString("ClientGUI.viewReadoutMenuItem") + + en.getDisplayName()); + + item.setActionCommand(Integer.toString(en.getId())); + item.addActionListener(evt -> { + try { + selectedEntity = game.getEntity(Integer.parseInt(evt.getActionCommand())); + LobbyUtility.mechReadout(selectedEntity, 0, false, gui.getFrame()); + } catch (Exception ex) { + LogManager.getLogger().error("", ex); + } + }); + + return item; + } + private JMenu touchOffExplosivesMenu() { JMenu menu = new JMenu("Touch off explosives"); @@ -467,6 +485,7 @@ private JMenu createViewMenu() { // With double blind on, the game may unseen units if (!entity.isSensorReturn(localPlayer) && entity.hasSeenEntity(localPlayer)) { menu.add(viewJMenuItem(entity)); + menu.add(viewReadoutJMenuItem(entity)); } } return menu; diff --git a/megamek/src/megamek/client/ui/swing/unitDisplay/ExtraPanel.java b/megamek/src/megamek/client/ui/swing/unitDisplay/ExtraPanel.java index 1e776a2efcd..3bb5c56588c 100644 --- a/megamek/src/megamek/client/ui/swing/unitDisplay/ExtraPanel.java +++ b/megamek/src/megamek/client/ui/swing/unitDisplay/ExtraPanel.java @@ -3,10 +3,8 @@ import megamek.MMConstants; import megamek.client.ui.Messages; import megamek.client.ui.baseComponents.MMComboBox; -import megamek.client.ui.swing.ClientGUI; -import megamek.client.ui.swing.GUIPreferences; -import megamek.client.ui.swing.HeatEffects; -import megamek.client.ui.swing.Slider; +import megamek.client.ui.swing.*; +import megamek.client.ui.swing.lobby.LobbyUtility; import megamek.client.ui.swing.util.UIUtil; import megamek.client.ui.swing.widget.*; import megamek.client.ui.swing.tooltip.UnitToolTip; @@ -24,7 +22,6 @@ import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; -import java.util.Enumeration; /** * This class shows information about a unit that doesn't belong elsewhere. @@ -48,6 +45,7 @@ class ExtraPanel extends PicMap implements ActionListener, ItemListener, IPrefer private JTextArea sinksR; private JButton sinks2B; private JButton dumpBombs; + private JButton unitReadout; private JList narcList; private int myMechId; @@ -155,6 +153,10 @@ public Component getListCellRendererComponent(JList list, Object value, int i } }); + unitReadout = new JButton(Messages.getString("MechDisplay.UnitReadout")); + unitReadout.setActionCommand("UnitReadout"); + unitReadout.addActionListener(this); + // layout choice panel GridBagLayout gridbag; GridBagConstraints c; @@ -163,77 +165,75 @@ public Component getListCellRendererComponent(JList list, Object value, int i c = new GridBagConstraints(); panelMain = new JPanel(gridbag); - c.fill = GridBagConstraints.BOTH; - c.insets = new Insets(15, 9, 1, 9); + c.fill = GridBagConstraints.HORIZONTAL; + c.insets = new Insets(5, 9, 1, 9); c.gridwidth = GridBagConstraints.REMAINDER; - c.anchor = GridBagConstraints.CENTER; - c.weighty = 1.0; - - gridbag.setConstraints(curSensorsL, c); - panelMain.add(curSensorsL); - - gridbag.setConstraints(chSensors, c); - panelMain.add(chSensors); - - gridbag.setConstraints(narcLabel, c); - panelMain.add(narcLabel); - + c.anchor = GridBagConstraints.NORTHWEST; + c.weighty = 0; + c.gridy = 0; + c.gridx = 0; + panelMain.add(curSensorsL, c); + c.gridy++; + panelMain.add(chSensors, c); + + c.gridy++; + panelMain.add(narcLabel, c); + c.gridy++; c.insets = new Insets(1, 9, 1, 9); scrollPane = new JScrollPane(narcList); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - gridbag.setConstraints(scrollPane, c); - panelMain.add(scrollPane); - - gridbag.setConstraints(unusedL, c); - panelMain.add(unusedL); - - gridbag.setConstraints(unusedR, c); - panelMain.add(unusedR); - - gridbag.setConstraints(carrysL, c); - panelMain.add(carrysL); - - gridbag.setConstraints(carrysR, c); - panelMain.add(carrysR); - - gridbag.setConstraints(dumpBombs, c); - panelMain.add(dumpBombs); - - gridbag.setConstraints(sinksL, c); - panelMain.add(sinksL); - - gridbag.setConstraints(sinksR, c); - panelMain.add(sinksR); - - gridbag.setConstraints(sinks2B, c); - panelMain.add(sinks2B); - - gridbag.setConstraints(heatL, c); - panelMain.add(heatL); - - c.insets = new Insets(1, 9, 18, 9); - gridbag.setConstraints(heatR, c); - panelMain.add(heatR); - + panelMain.add(scrollPane, c); + + c.gridy++; + panelMain.add(unusedL, c); + c.gridy++; + panelMain.add(unusedR, c); + + c.gridy++; + panelMain.add(carrysL, c); + c.gridy++; + panelMain.add(carrysR, c); + + c.gridy++; + panelMain.add(dumpBombs, c); + + c.gridy++; + panelMain.add(sinksL, c); + c.gridy++; + panelMain.add(sinksR, c); + c.gridy++; + panelMain.add(sinks2B, c); + + c.gridy++; + panelMain.add(heatL, c); + c.gridy++; + c.insets = new Insets(1, 9, 5, 9); + panelMain.add(heatR, c); + + c.gridy++; c.insets = new Insets(0, 0, 0, 0); - gridbag.setConstraints(lblLastTarget, c); - panelMain.add(lblLastTarget); - - c.insets = new Insets(1, 9, 18, 9); - gridbag.setConstraints(lastTargetR, c); - panelMain.add(lastTargetR); + panelMain.add(lblLastTarget, c); + c.gridy++; + c.insets = new Insets(1, 9, 5, 9); + panelMain.add(lastTargetR, c); - c.insets = new Insets(1, 9, 1, 9); - gridbag.setConstraints(activateHidden, c); + c.gridy++; c.insets = new Insets(1, 9, 6, 9); - gridbag.setConstraints(comboActivateHiddenPhase, c); - panelMain.add(activateHidden); - panelMain.add(comboActivateHiddenPhase); + panelMain.add(activateHidden, c); + c.gridy++; + panelMain.add(comboActivateHiddenPhase, c); + + c.gridy++; + panelMain.add(unitReadout, c); + + c.weightx = 1; + c.weighty = 1; + panelMain.add(new Label(" "), c); adaptToGUIScale(); GUIPreferences.getInstance().addPreferenceChangeListener(this); setLayout(new BorderLayout()); - add(panelMain); + add(panelMain, BorderLayout.NORTH); panelMain.setOpaque(false); setBackGround(); @@ -626,6 +626,9 @@ public void actionPerformed(ActionEvent ae) { } else if (activateHidden.equals(ae.getSource()) && !dontChange) { final GamePhase phase = comboActivateHiddenPhase.getSelectedItem(); clientgui.getClient().sendActivateHidden(myMechId, (phase == null) ? GamePhase.UNKNOWN : phase); + } else if (unitReadout.equals(ae.getSource())) { + Entity entity = clientgui.getClient().getGame().getEntity(myMechId); + LobbyUtility.mechReadout(entity, 0, false, clientgui.getFrame()); } }