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

Disable Advance Day Button While Advance Day is in Progress #5355

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Changes from 1 commit
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
31 changes: 15 additions & 16 deletions MekHQ/src/mekhq/gui/CampaignGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,19 @@ private void initTopButtons() {
String padding = " ";
JButton btnAdvanceDay = new JButton(padding + resourceMap.getString("btnAdvanceDay.text") + padding);
btnAdvanceDay.setToolTipText(resourceMap.getString("btnAdvanceDay.toolTipText"));
btnAdvanceDay.addActionListener(evt -> getCampaignController().advanceDay());
btnAdvanceDay.addActionListener(evt -> {
// We disable the button here, as we don't want the user to be able to advance day
// again, until after Advance Day has completed.
btnAdvanceDay.setEnabled(false);

SwingUtilities.invokeLater(() -> {
try {
getCampaignController().advanceDay();
} finally {
btnAdvanceDay.setEnabled(true);
}
});
});
btnAdvanceDay.setMnemonic(KeyEvent.VK_A);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 2;
Expand Down Expand Up @@ -1623,21 +1635,8 @@ public void refitUnit(Refit r, boolean selectModelName) {
if (getCampaign().isWorkingOnRefit(tech) || tech.isEngineer()) {
continue;
}
StringBuilder nameBuilder = new StringBuilder(128);
nameBuilder.append("<html>")
.append(tech.getFullName())
.append(", <b>")
.append(SkillType.getColoredExperienceLevelName(tech.getSkillLevel(getCampaign(), false)))
.append("</b> ")
.append(tech.getPrimaryRoleDesc())
.append(" (")
.append(getCampaign().getTargetFor(r, tech).getValueAsString())
.append("+), ")
.append(tech.getMinutesLeft())
.append('/')
.append(tech.getDailyAvailableTechTime())
.append(" minutes</html>");
name = nameBuilder.toString();
String nameBuilder = "<html>" + tech.getFullName() + ", <b>" + SkillType.getColoredExperienceLevelName(tech.getSkillLevel(getCampaign(), false)) + "</b> " + tech.getPrimaryRoleDesc() + " (" + getCampaign().getTargetFor(r, tech).getValueAsString() + "+), " + tech.getMinutesLeft() + '/' + tech.getDailyAvailableTechTime() + " minutes</html>";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems less clean, plus if we're not using a StringBuilder you can just concatenate everything into name and skip the second line.

Was this an IDE-suggested change? Apparently most will turn this form into the StringBuilder form under the hood, so I'm not sure this change gets us anything.

name = nameBuilder;
techHash.put(name, tech);
if (tech.isRightTechTypeFor(r)) {
techList.add(lastRightTech++, name);
Expand Down
Loading