-
Notifications
You must be signed in to change notification settings - Fork 176
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
Base Components #2440
Merged
Windchild292
merged 18 commits into
MegaMek:master
from
Windchild292:dev_Windchild_BaseComponents
Mar 13, 2021
Merged
Base Components #2440
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
4d83d4a
Preference code standardization and cleanup
Windchild292 308aa9b
Reordering and grouping based on IO functionality
Windchild292 209ac54
Applying changes from personal review
Windchild292 8f05ee1
Simplifying methods: removing redundant method, using computerIfAbsent
Windchild292 65b10e1
Adding new preference types (untested)
Windchild292 c4d2e83
Creating abstract baseline components
Windchild292 c983b0e
Applying abstract base changes to MekHQ Options
Windchild292 04dfa3c
Fixing NPE in MekHQ Preferences
Windchild292 ec13cca
Bugfixing phase 1
Windchild292 e5b6707
Bugfixing, phase 2
Windchild292 bc07af1
Readding AbstractScrollPane, although it does not have any preference…
Windchild292 2db5d44
Moving components and preferences to MM
Windchild292 c092e29
Fixing merge conflicts
Windchild292 56a0a0f
Applying changes from personal review
Windchild292 c328d01
Merge remote-tracking branch 'upstream/master' into dev_Windchild_Bas…
Windchild292 6bf0fb2
Applying review changes from the MM review
Windchild292 983fd3b
Fixing merge conflicts
Windchild292 c2e484a
Applying a few more changes as per MM review
Windchild292 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 was deleted.
Oops, something went wrong.
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,19 @@ | ||
# This is used to store any mekhq/gui Resources | ||
|
||
#### General GUI Resources | ||
#### These are repeated multiple times across the GUI to mean the same thing, and thus can be kept here | ||
AddGM.text=Add (GM) | ||
Apply.text=Apply | ||
Cancel.text=Cancel | ||
Cancel.toolTipText=Cancel out of the dialog. No changes made will be saved. | ||
Close.text=Close | ||
Export.text=Export | ||
Faction.text=Faction | ||
FactionSpecific.text=Faction Specific | ||
Generate.text=Generate | ||
Import.text=Import | ||
Ok.text=Ok | ||
Ok.toolTipText=Confirm the changes and close the dialog. | ||
Purchase.text=Purchase | ||
Remove.text=Remove | ||
RestoreDefaults.text=Restore Defaults |
8 changes: 5 additions & 3 deletions
8
MekHQ/resources/mekhq/resources/MekHqOptionsDialog.properties
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
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
77 changes: 77 additions & 0 deletions
77
MekHQ/src/mekhq/gui/baseComponents/AbstractMHQButtonDialog.java
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,77 @@ | ||
/* | ||
* Copyright (c) 2021 - The MegaMek Team. All Rights Reserved. | ||
* | ||
* This file is part of MekHQ. | ||
* | ||
* MekHQ 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. | ||
* | ||
* MekHQ 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 MekHQ. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package mekhq.gui.baseComponents; | ||
|
||
import megamek.client.ui.baseComponents.AbstractButtonDialog; | ||
import megamek.common.util.EncodeControl; | ||
import mekhq.MekHQ; | ||
|
||
import javax.swing.*; | ||
import java.util.ResourceBundle; | ||
|
||
/** | ||
* This is the Base Dialog for a dialog with buttons in MegaMek. It extends Base Dialog, and adds a | ||
* button panel with base Ok and Cancel buttons. It also includes an enum tracker for the result of | ||
* the dialog. | ||
* | ||
* Inheriting classes must call initialize() in their constructors and override createCenterPane() | ||
* | ||
* The resources associated with this dialog need to contain at least the following keys: | ||
* - "Ok.text" -> text for the ok button | ||
* - "Ok.toolTipText" -> toolTipText for the ok button | ||
* - "Cancel.text" -> text for the cancel button | ||
* - "Cancel.toolTipText" -> toolTipText for the cancel button | ||
*/ | ||
public abstract class AbstractMHQButtonDialog extends AbstractButtonDialog { | ||
//region Constructors | ||
/** | ||
* This creates a modal AbstractMHQButtonDialog using the default MHQ resource bundle. This is | ||
* the normal constructor to use for an AbstractMHQButtonDialog. | ||
*/ | ||
protected AbstractMHQButtonDialog(final JFrame frame, final String name, final String title) { | ||
this(frame, true, name, title); | ||
} | ||
|
||
/** | ||
* This creates an AbstractMHQButtonDialog using the default MHQ resource bundle. It allows one | ||
* to create non-modal button dialogs, which is not recommended by default. | ||
*/ | ||
protected AbstractMHQButtonDialog(final JFrame frame, final boolean modal, final String name, | ||
final String title) { | ||
this(frame, modal, ResourceBundle.getBundle("mekhq.resources.GUI", new EncodeControl()), name, title); | ||
} | ||
|
||
/** | ||
* This creates an AbstractMHQButtonDialog using the specified resource bundle. This is not | ||
* recommended by default. | ||
*/ | ||
protected AbstractMHQButtonDialog(final JFrame frame, final boolean modal, final ResourceBundle resources, | ||
final String name, final String title) { | ||
super(frame, modal, resources, name, title); | ||
} | ||
//endregion Constructors | ||
|
||
/** | ||
* This override forces the preferences for this class to be tracked in MekHQ instead of MegaMek | ||
*/ | ||
@Override | ||
protected void setPreferences() { | ||
setPreferences(MekHQ.getPreferences().forClass(getClass())); | ||
} | ||
} |
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,69 @@ | ||
/* | ||
* Copyright (c) 2021 - The MegaMek Team. All Rights Reserved. | ||
* | ||
* This file is part of MekHQ. | ||
* | ||
* MekHQ 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. | ||
* | ||
* MekHQ 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 MekHQ. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package mekhq.gui.baseComponents; | ||
|
||
import megamek.client.ui.baseComponents.AbstractDialog; | ||
import megamek.common.util.EncodeControl; | ||
import mekhq.MekHQ; | ||
|
||
import javax.swing.*; | ||
import java.util.ResourceBundle; | ||
|
||
/** | ||
* This is the base class for dialogs in MegaMek. This class handles setting the UI, managing the X | ||
* button, managing the escape key, and saving the dialog preferences. | ||
* | ||
* Inheriting classes must call initialize() in their constructors and override createCenterPane() | ||
*/ | ||
public abstract class AbstractMHQDialog extends AbstractDialog { | ||
//region Constructors | ||
/** | ||
* This creates a non-modal AbstractMHQDialog using the default MHQ resource bundle. This is | ||
* the normal constructor to use for an AbstractMHQDialog. | ||
*/ | ||
protected AbstractMHQDialog(final JFrame frame, final String name, final String title) { | ||
this(frame, false, name, title); | ||
} | ||
|
||
/** | ||
* This creates an AbstractMHQDialog using the default MHQ resource bundle. It allows one | ||
* to create modal dialogs. | ||
*/ | ||
protected AbstractMHQDialog(final JFrame frame, final boolean modal, final String name, final String title) { | ||
this(frame, modal, ResourceBundle.getBundle("mekhq.resources.GUI", new EncodeControl()), name, title); | ||
} | ||
|
||
/** | ||
* This creates an AbstractMHQDialog using the specified resource bundle. This is not recommended | ||
* by default. | ||
*/ | ||
protected AbstractMHQDialog(final JFrame frame, final boolean modal, final ResourceBundle resources, | ||
final String name, final String title) { | ||
super(frame, modal, resources, name, title); | ||
} | ||
//endregion Constructors | ||
|
||
/** | ||
* This override forces the preferences for this class to be tracked in MekHQ instead of MegaMek | ||
*/ | ||
@Override | ||
protected void setPreferences() { | ||
setPreferences(MekHQ.getPreferences().forClass(getClass())); | ||
} | ||
} |
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.
Gotta ask, what's different about a MekHQ button from a MegaMek button?
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.
Solely tracking on MHQ's preferencez instead of MM's.
Otherwise the dialogs are identical.