-
Notifications
You must be signed in to change notification settings - Fork 178
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
Warnings on Campaign Load #5757
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a8e8442
Prevent updates with active contracts in CampaignXmlParser
IllianiCBT c8b8bef
Refactored active contract warning logic into a new method
IllianiCBT 6d9133e
Refactored active contract check in trigger warning
IllianiCBT 87d319d
Add warning for active contracts during version updates
IllianiCBT 6753b26
Merge branch 'master' into activeContractWarning
IllianiCBT d8b3041
Refactored campaign version checks and removed ActiveContractWarning.
IllianiCBT bf5fd5d
Refined campaign loading error handling
IllianiCBT edd5b66
Update copyright years to include 2025
IllianiCBT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (c) 2025 - The MegaMek Team. All Rights Reserved. | ||
* | ||
* This file is part of MekHQ. | ||
* | ||
* MegaMek is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* MegaMek is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with MegaMek. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package mekhq.gui.dialog; | ||
|
||
import mekhq.MHQConstants; | ||
import mekhq.MekHQ; | ||
|
||
import javax.swing.*; | ||
import java.util.ResourceBundle; | ||
|
||
public class ActiveContractWarning { | ||
private final String RESOURCE_KEY = "mekhq.resources.GUI"; | ||
private final transient ResourceBundle resources = | ||
ResourceBundle.getBundle(RESOURCE_KEY, MekHQ.getMHQOptions().getLocale()); | ||
|
||
/** | ||
* Displays a warning dialog to the user indicating that the campaign has | ||
* an active contract. The warning informs the user to complete the active | ||
* contract before updating to the specified version of the application. | ||
* <p> | ||
* The displayed message includes the current application version retrieved | ||
* from {@code MHQConstants.VERSION}. | ||
* <p> | ||
* The dialog uses an error message icon and is displayed in a modal popup. | ||
* | ||
* @see JOptionPane#showMessageDialog(java.awt.Component, Object, String, int) | ||
*/ | ||
public ActiveContractWarning() { | ||
String message = String.format(resources.getString("ActiveContractWarning.message"), | ||
MHQConstants.VERSION); | ||
|
||
JOptionPane.showMessageDialog( | ||
null, | ||
message, | ||
resources.getString("ActiveContractWarning.title"), | ||
JOptionPane.ERROR_MESSAGE | ||
); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion would be something like the following, but inside the CampaignFactory file, with the CampaignXMLParser returning a container with the campaign and the relevant diagnostics:
Somewhere add this:
In the CampaignFactory
This way, the place that receives the file will be able to handle it accordingly.
DataLoadingDialog.java
Otherwise we keep with the problem where we have being imported stuff inserted inside a parser class.
Sorry for not being clear the first time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "parse()" and the diagnostics can run in two different steps, this way not disrupting any tests or old files and just adding new functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I had to wait until my brain had the cycles to process this, but now that it does what you're saying makes perfect sense and will be super maintainable. I would have never thought to use Enums like this. Thanks for the feedback! :)