Skip to content

Commit 27be84b

Browse files
committed
Merge branch 'tipoftheday' of https://github.com/exeea/megamek into tipoftheday
2 parents 213cfe1 + 668cc13 commit 27be84b

28 files changed

+469
-221
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @MegaMek/developers

megamek/data/forcegenerator/2950.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6035,7 +6035,7 @@
60356035
</model>
60366036
<model name='RFL-3N'>
60376037
<roles>fire_support,anti_aircraft</roles>
6038-
<availability>IS:8,CLAN:2-,HL:8,Periphery.Deep:8,BAN:3</availability>
6038+
<availability>IS:8,CLAN:2-,Periphery:8,HL:8,Periphery.Deep:8,BAN:3</availability>
60396039
</model>
60406040
</chassis>
60416041
<chassis name='Ripper Infantry Transport' unitType='VTOL'>

megamek/data/forcegenerator/3019.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6311,7 +6311,7 @@
63116311
</model>
63126312
<model name='RFL-3N'>
63136313
<roles>fire_support,anti_aircraft</roles>
6314-
<availability>IS:8,CLAN:1-,HL:8,Periphery.Deep:8,BAN:2</availability>
6314+
<availability>IS:8,CLAN:1-,Periphery:8,HL:8,Periphery.Deep:8,BAN:2</availability>
63156315
</model>
63166316
<model name='RFL-4D'>
63176317
<roles>fire_support,anti_aircraft</roles>

megamek/data/forcegenerator/3028.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6692,7 +6692,7 @@
66926692
</model>
66936693
<model name='RFL-3N'>
66946694
<roles>fire_support,anti_aircraft</roles>
6695-
<availability>IS:8,FC:6,CLAN:1-,HL:8,Periphery.Deep:8,BAN:2</availability>
6695+
<availability>IS:8,FC:6,CLAN:1-,Periphery:8,HL:8,Periphery.Deep:8,BAN:2</availability>
66966696
</model>
66976697
<model name='RFL-4D'>
66986698
<roles>fire_support,anti_aircraft</roles>

megamek/data/forcegenerator/3039.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7600,7 +7600,7 @@
76007600
</model>
76017601
<model name='RFL-3N'>
76027602
<roles>fire_support,anti_aircraft</roles>
7603-
<availability>IS:8,FC:6,CLAN:1-,HL:8,Periphery.Deep:8,BAN:2</availability>
7603+
<availability>IS:8,FC:6,CLAN:1-,Periphery:8,HL:8,Periphery.Deep:8,BAN:2</availability>
76047604
</model>
76057605
<model name='RFL-4D'>
76067606
<roles>fire_support,anti_aircraft</roles>

megamek/data/forcegenerator/3049.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8815,7 +8815,7 @@
88158815
</model>
88168816
<model name='RFL-3N'>
88178817
<roles>fire_support,anti_aircraft</roles>
8818-
<availability>IS:8,DC:6,FC:6,CLAN.IS:1-,CIR:8,HL:8,Periphery.Deep:8,BAN:1</availability>
8818+
<availability>IS:8,DC:6,FC:6,CLAN.IS:1-,Periphery:8,CIR:8,HL:8,Periphery.Deep:8,BAN:1</availability>
88198819
</model>
88208820
<model name='RFL-4D'>
88218821
<roles>fire_support,anti_aircraft</roles>

megamek/docs/history.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ MEGAMEK VERSION HISTORY:
66
+ PR #6864: Added Heroic and Legendary Skill Levels
77
+ Fix #6915: Fixed Status of Uncrewed Vehicles
88
+ Fix: #6931: Fixes duplicated score key for score logging on basic path ranker
9+
+ PR #6937: Calculate heat for vibroblades
910

1011

1112
0.50.05 (2025-04-25 1800 UTC)

megamek/src/megamek/client/ui/dialogs/UnitDisplayDialog.java

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,52 @@
1818
*/
1919
package megamek.client.ui.dialogs;
2020

21+
import java.awt.BorderLayout;
2122
import java.awt.event.KeyEvent;
2223
import java.awt.event.WindowAdapter;
2324
import java.awt.event.WindowEvent;
2425

2526
import javax.swing.JDialog;
2627
import javax.swing.JFrame;
2728

29+
import megamek.client.Client;
2830
import megamek.client.ui.Messages;
2931
import megamek.client.ui.swing.ClientGUI;
3032
import megamek.client.ui.swing.GUIPreferences;
33+
import megamek.client.ui.swing.unitDisplay.UnitDisplay;
3134
import megamek.client.ui.swing.util.UIUtil;
35+
import megamek.common.Entity;
3236

3337
public class UnitDisplayDialog extends JDialog {
38+
static private UnitDisplayDialog dialogInstance = null;
39+
static private UnitDisplay unitDisplay = null;
40+
3441
//region Variable Declarations
3542
private final ClientGUI clientGUI;
3643
private static final GUIPreferences GUIP = GUIPreferences.getInstance();
3744
//endregion Variable Declarations
3845

46+
public static void showEntity(final JFrame frame, Entity entity, final boolean newInstance) {
47+
UnitDisplayDialog localDialogInstance = null;
48+
UnitDisplay localUnitDisplay = null;
49+
if (!newInstance) {
50+
localDialogInstance = dialogInstance;
51+
localUnitDisplay = unitDisplay;
52+
}
53+
if (localDialogInstance == null || unitDisplay == null) {
54+
localDialogInstance = new UnitDisplayDialog(frame, null);
55+
localUnitDisplay = new UnitDisplay(null, null);
56+
localDialogInstance.add(localUnitDisplay, BorderLayout.CENTER);
57+
localDialogInstance.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
58+
if (!newInstance) {
59+
dialogInstance = localDialogInstance;
60+
unitDisplay = localUnitDisplay;
61+
}
62+
}
63+
localUnitDisplay.displayEntity(entity);
64+
localDialogInstance.setVisible(true);
65+
}
66+
3967
//region Constructors
4068
public UnitDisplayDialog(final JFrame frame, final ClientGUI clientGUI) {
4169
super(frame, "", false);
@@ -76,7 +104,9 @@ public void saveSettings() {
76104
GUIP.setUnitDisplayNontabbedPosY(getLocation().y);
77105
GUIP.setUnitDisplayNonTabbedSizeWidth(getSize().width);
78106
GUIP.setUnitDisplayNonTabbedSizeHeight(getSize().height);
79-
clientGUI.getUnitDisplay().saveSplitterLoc();
107+
if (clientGUI != null) {
108+
clientGUI.getUnitDisplay().saveSplitterLoc();
109+
}
80110
}
81111
}
82112
}
@@ -96,11 +126,13 @@ protected void processWindowEvent(WindowEvent e) {
96126
*/
97127
@Override
98128
protected void processKeyEvent(KeyEvent evt) {
99-
evt.setSource(clientGUI);
100-
clientGUI.getMenuBar().dispatchEvent(evt);
101-
// Make the source be the ClientGUI and not the dialog
102-
// This prevents a ClassCastException in ToolTipManager
103-
clientGUI.getCurrentPanel().dispatchEvent(evt);
129+
if (clientGUI != null) {
130+
evt.setSource(clientGUI);
131+
clientGUI.getMenuBar().dispatchEvent(evt);
132+
// Make the source be the ClientGUI and not the dialog
133+
// This prevents a ClassCastException in ToolTipManager
134+
clientGUI.getCurrentPanel().dispatchEvent(evt);
135+
}
104136
if (!evt.isConsumed()) {
105137
super.processKeyEvent(evt);
106138
}

megamek/src/megamek/client/ui/swing/CustomMekDialog.java

Lines changed: 63 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ public class CustomMekDialog extends AbstractButtonDialog
160160
private boolean okay;
161161
private int status = CustomMekDialog.DONE;
162162

163-
private final ClientGUI clientGUI;
163+
private ClientGUI clientGUI;
164164
private final Client client;
165-
private final boolean space;
165+
private boolean space;
166166

167167
private PilotOptions options;
168168
private PartialRepairs partReps;
@@ -188,12 +188,19 @@ public CustomMekDialog(ClientGUI clientgui, Client client, List<Entity> entities
188188
*/
189189
public CustomMekDialog(ClientGUI clientgui, Client client, List<Entity> entities, boolean editable,
190190
boolean editableDeployment) {
191-
super(clientgui.getFrame(), "CustomizeMekDialog", "CustomMekDialog.title");
191+
this(clientgui.getFrame(), client, entities, editable, editableDeployment);
192+
this.clientGUI = clientgui;
193+
this.space = clientgui.getClient().getMapSettings().getMedium() == Board.T_SPACE;
194+
}
195+
196+
public CustomMekDialog(JFrame frame, Client client, List<Entity> entities, boolean editable,
197+
boolean editableDeployment) {
198+
super(frame, "CustomizeMekDialog", "CustomMekDialog.title");
192199

193200
this.entities = entities;
194-
this.clientGUI = clientgui;
201+
this.clientGUI = null;
195202
this.client = client;
196-
this.space = clientgui.getClient().getMapSettings().getMedium() == Board.T_SPACE;
203+
this.space = false;
197204
this.editable = editable;
198205
this.editableDeployment = editableDeployment;
199206

@@ -231,6 +238,14 @@ public ClientGUI getClientGUI() {
231238
return clientGUI;
232239
}
233240

241+
public Client getClient() {
242+
if (clientGUI != null) {
243+
return clientGUI.getClient();
244+
} else {
245+
return client;
246+
}
247+
}
248+
234249
private void setOptions() {
235250
Entity entity = entities.get(0);
236251
IOption option;
@@ -437,6 +452,9 @@ public int getStatus() {
437452
}
438453

439454
private void refreshDeployment() {
455+
if (this.clientGUI == null) {
456+
return;
457+
}
440458
Entity entity = entities.get(0);
441459

442460
if (entity instanceof QuadVee) {
@@ -707,25 +725,25 @@ protected void okAction() {
707725
if ((velocity > (2 * entities.get(0).getWalkMP())) || (velocity < 0)) {
708726
msg = Messages.getString("CustomMekDialog.EnterCorrectVelocity");
709727
title = Messages.getString("CustomMekDialog.NumberFormatError");
710-
JOptionPane.showMessageDialog(clientGUI.frame, msg, title, JOptionPane.ERROR_MESSAGE);
728+
JOptionPane.showMessageDialog(clientGUI == null ? this : clientGUI.frame, msg, title, JOptionPane.ERROR_MESSAGE);
711729
return;
712730
} else if ((altitude < 0) || (altitude > 10)) {
713731
msg = Messages.getString("CustomMekDialog.EnterCorrectAltitude");
714732
title = Messages.getString("CustomMekDialog.NumberFormatError");
715-
JOptionPane.showMessageDialog(clientGUI.frame, msg, title, JOptionPane.ERROR_MESSAGE);
733+
JOptionPane.showMessageDialog(clientGUI == null ? this : clientGUI.frame, msg, title, JOptionPane.ERROR_MESSAGE);
716734
return;
717735
} else if ((currentFuel < 0) || (currentFuel > fuel)) {
718736
msg = (Messages.getString("CustomMekDialog.EnterCorrectFuel") + fuel + ".");
719737
title = Messages.getString("CustomMekDialog.NumberFormatError");
720-
JOptionPane.showMessageDialog(clientGUI.frame, msg, title, JOptionPane.ERROR_MESSAGE);
738+
JOptionPane.showMessageDialog(clientGUI == null ? this : clientGUI.frame, msg, title, JOptionPane.ERROR_MESSAGE);
721739
return;
722740
}
723741
}
724742

725743
if ((isVTOL && height > 50) || (isAirMek && height > 25) || (isGlider && height > 12)) {
726744
msg = Messages.getString("CustomMekDialog.EnterCorrectHeight");
727745
title = Messages.getString("CustomMekDialog.NumberFormatError");
728-
JOptionPane.showMessageDialog(clientGUI.frame, msg, title, JOptionPane.ERROR_MESSAGE);
746+
JOptionPane.showMessageDialog(clientGUI == null ? this : clientGUI.frame, msg, title, JOptionPane.ERROR_MESSAGE);
729747
return;
730748
}
731749
// Apply single-entity settings
@@ -795,7 +813,7 @@ protected void okAction() {
795813
(artillery > 8)) {
796814
msg = Messages.getString("CustomMekDialog.EnterSkillsBetween0_8");
797815
title = Messages.getString("CustomMekDialog.NumberFormatError");
798-
JOptionPane.showMessageDialog(clientGUI.frame, msg, title, JOptionPane.ERROR_MESSAGE);
816+
JOptionPane.showMessageDialog(clientGUI == null ? this : clientGUI.frame, msg, title, JOptionPane.ERROR_MESSAGE);
799817
return;
800818
}
801819

@@ -849,7 +867,9 @@ protected void okAction() {
849867
entity.getCrew().setHits(MathUtility.parseInt(hits, 0), i);
850868
entity.getCrew().setGender(gender, i);
851869
entity.getCrew().setClanPilot(panCrewMember[i].isClanPilot(), i);
852-
entity.getCrew().setPortrait(panCrewMember[i].getPortrait().clone(), i);
870+
if (clientGUI != null) {
871+
entity.getCrew().setPortrait(panCrewMember[i].getPortrait().clone(), i);
872+
}
853873
if (backup >= 0) {
854874
if (i == entity.getCrew().getCrewType().getPilotPos()) {
855875
entity.getCrew().setBackupPilotPos(backup);
@@ -899,7 +919,7 @@ protected void okAction() {
899919
if (offBoardDistance < 17) {
900920
msg = Messages.getString("CustomMekDialog.OffboardDistance");
901921
title = Messages.getString("CustomMekDialog.NumberFormatError");
902-
JOptionPane.showMessageDialog(clientGUI.frame, msg, title, JOptionPane.ERROR_MESSAGE);
922+
JOptionPane.showMessageDialog(clientGUI == null ? this : clientGUI.frame, msg, title, JOptionPane.ERROR_MESSAGE);
903923
return;
904924
}
905925
entity.setOffBoard(offBoardDistance,
@@ -989,7 +1009,7 @@ protected void okAction() {
9891009
}
9901010

9911011
okay = true;
992-
if (clientGUI.chatlounge != null) {
1012+
if ((clientGUI != null) && (clientGUI.chatlounge != null)) {
9931013
clientGUI.chatlounge.refreshEntities();
9941014
}
9951015

@@ -1115,10 +1135,17 @@ protected Container createCenterPane() {
11151135
final boolean isGlider = entities.stream()
11161136
.allMatch(e -> (e instanceof ProtoMek) && e.getMovementMode().isWiGE());
11171137
final boolean hasStealth = entities.stream().allMatch(Entity::hasStealth);
1118-
boolean eligibleForOffBoard = true;
11191138

1120-
int bh = clientGUI.getClient().getMapSettings().getBoardHeight();
1121-
int bw = clientGUI.getClient().getMapSettings().getBoardWidth();
1139+
boolean eligibleForOffBoard = true;
1140+
int bh = 0;
1141+
int bw = 0;
1142+
if (this.clientGUI != null) {
1143+
bh = clientGUI.getClient().getMapSettings().getBoardHeight();
1144+
bw = clientGUI.getClient().getMapSettings().getBoardWidth();
1145+
} else {
1146+
bh = client.getMapSettings().getBoardHeight();
1147+
bw = client.getMapSettings().getBoardWidth();
1148+
}
11221149
int x = Math.min(entity.getStartingAnyNWx(false) + 1, bw);
11231150
SpinnerNumberModel mStartingAnyNWx = new SpinnerNumberModel(x, 0, bw, 1);
11241151
spinStartingAnyNWx = new JSpinner(mStartingAnyNWx);
@@ -1135,7 +1162,6 @@ protected Container createCenterPane() {
11351162
SpinnerNumberModel mStartingAnySEy = new SpinnerNumberModel(y, 0, bh, 1);
11361163
spinStartingAnySEy = new JSpinner(mStartingAnySEy);
11371164
spinStartingAnySEy.setValue(y);
1138-
11391165
for (Entity e : entities) {
11401166
// TODO : This check is good for now, but at some point we want atmospheric flying droppers to be able to
11411167
// lob offboard missiles and we could use it in space for extreme range bearings-only fights, plus
@@ -1145,13 +1171,12 @@ protected Container createCenterPane() {
11451171
(e.getAltitude() == 0) &&
11461172
!(e instanceof GunEmplacement) &&
11471173
e.getWeaponList()
1148-
.stream()
1149-
.map(Mounted::getType)
1150-
.anyMatch(weaponType -> weaponType.hasFlag(WeaponType.F_ARTILLERY) ||
1174+
.stream()
1175+
.map(Mounted::getType)
1176+
.anyMatch(weaponType -> weaponType.hasFlag(WeaponType.F_ARTILLERY) ||
11511177
(weaponType instanceof CapitalMissileBayWeapon));
11521178
eligibleForOffBoard &= entityEligibleForOffBoard;
11531179
}
1154-
11551180
// set up the panels
11561181
JPanel mainPanel = new JPanel(new GridBagLayout());
11571182
tabAll = new JTabbedPane();
@@ -1189,17 +1214,20 @@ protected Container createCenterPane() {
11891214
}
11901215
tabAll.addTab(Messages.getString("CustomMekDialog.tabEquipment"), scrEquip);
11911216
}
1192-
tabAll.addTab(Messages.getString(editableDeployment ?
1193-
"CustomMekDialog.tabDeployment" :
1194-
"CustomMekDialog.tabState"), new JScrollPane(panDeploy));
1195-
if (quirksEnabled && !multipleEntities) {
1196-
JScrollPane scrQuirks = new JScrollPane(panQuirks);
1197-
scrQuirks.getVerticalScrollBar().setUnitIncrement(16);
1198-
scrQuirks.setPreferredSize(scrEquip.getPreferredSize());
1199-
tabAll.addTab("Quirks", scrQuirks);
1200-
}
1201-
if (partialRepairsEnabled && !multipleEntities) {
1202-
tabAll.addTab(Messages.getString("CustomMekDialog.tabPartialRepairs"), new JScrollPane(panPartReps));
1217+
1218+
if (this.clientGUI != null) {
1219+
tabAll.addTab(Messages.getString(editableDeployment ?
1220+
"CustomMekDialog.tabDeployment" :
1221+
"CustomMekDialog.tabState"), new JScrollPane(panDeploy));
1222+
if (quirksEnabled && !multipleEntities) {
1223+
JScrollPane scrQuirks = new JScrollPane(panQuirks);
1224+
scrQuirks.getVerticalScrollBar().setUnitIncrement(16);
1225+
scrQuirks.setPreferredSize(scrEquip.getPreferredSize());
1226+
tabAll.addTab("Quirks", scrQuirks);
1227+
}
1228+
if (partialRepairsEnabled && !multipleEntities) {
1229+
tabAll.addTab(Messages.getString("CustomMekDialog.tabPartialRepairs"), new JScrollPane(panPartReps));
1230+
}
12031231
}
12041232

12051233
options = entity.getCrew().getOptions();
@@ -1422,6 +1450,9 @@ protected JPanel createButtonPanel() {
14221450
}
14231451

14241452
private GameOptions gameOptions() {
1453+
if (clientGUI == null) {
1454+
return client.getGame().getOptions();
1455+
}
14251456
return clientGUI.getClient().getGame().getOptions();
14261457
}
14271458
}

0 commit comments

Comments
 (0)