From 3103db693b00bdcfb5d8502e585bcd7dddaa214e Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Sun, 29 Sep 2024 14:07:25 -0500 Subject: [PATCH 001/117] Added New Campaign Preset Selection Dialog Introduced a new dialog for selecting campaign presets within the campaign options. Updated `CampaignPreset` to include a `getTitle()` method and added resource strings for dialog configuration. --- .../NEWCampaignOptionsDialog.properties | 15 ++ MekHQ/src/mekhq/campaign/CampaignPreset.java | 42 ++--- .../campaignOptions/SelectPresetDialog.java | 165 ++++++++++++++++++ 3 files changed, 195 insertions(+), 27 deletions(-) create mode 100644 MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties new file mode 100644 index 0000000000..6079b0bf4d --- /dev/null +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -0,0 +1,15 @@ +## SelectPresetDialog Class +# SelectPresetDialog +presetDialog.title=Select Campaign Preset +presetDialog.description=
Lorem ipsum odor amet,\ + \ consectetuer adipiscing elit. Duis velit cubilia integer massa arcu elementum congue varius.\ + \ Posuere natoque ante nulla bibendum ad ultrices nunc eu. Habitasse magna in hac felis leo\ + \ scelerisque aliquet. Semper scelerisque magna ornare, dis turpis eu curae. Commodo diam ut nostra\ + \ molestie facilisis feugiat, fermentum duis. Ligula elit vivamus in aenean magna nullam. Leo orci\ + \ venenatis quam cursus; varius vel.
+presetDialogSelect.name=Select Preset +presetDialogSelect.tooltip=This is placeholder text for a tooltip +presetDialogCustomize.name=Customize Preset +presetDialogCustomize.tooltip=This is placeholder text for a tooltip +presetDialogCancel.name=Cancel +presetDialogCancel.tooltip=This is placeholder text for a tooltip diff --git a/MekHQ/src/mekhq/campaign/CampaignPreset.java b/MekHQ/src/mekhq/campaign/CampaignPreset.java index 4b996ad4e3..522cfccee6 100644 --- a/MekHQ/src/mekhq/campaign/CampaignPreset.java +++ b/MekHQ/src/mekhq/campaign/CampaignPreset.java @@ -18,33 +18,6 @@ */ package mekhq.campaign; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.nio.charset.StandardCharsets; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.ResourceBundle; -import java.util.stream.Collectors; - -import javax.swing.JFrame; -import javax.swing.JOptionPane; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.Version; import megamek.common.annotations.Nullable; import megamek.common.options.GameOptions; @@ -64,6 +37,17 @@ import mekhq.campaign.universe.Systems; import mekhq.campaign.universe.companyGeneration.CompanyGenerationOptions; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import javax.swing.*; +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.time.LocalDate; +import java.util.*; +import java.util.stream.Collectors; /** * This is an object which holds a set of objects that collectively define the @@ -166,6 +150,10 @@ public void setTitle(final String title) { this.title = title; } + public String getTitle() { + return title; + } + public String getDescription() { return description; } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java new file mode 100644 index 0000000000..6b089c8042 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java @@ -0,0 +1,165 @@ +package mekhq.gui.panes.campaignOptions; + +import megamek.logging.MMLogger; +import mekhq.MekHQ; +import mekhq.campaign.CampaignPreset; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import javax.swing.*; +import javax.swing.GroupLayout.Alignment; +import java.awt.*; +import java.util.ResourceBundle; + +import static megamek.client.ui.WrapLayout.wordWrap; + +/** + * A dialog for selecting campaign presets. + */ +public class SelectPresetDialog extends JDialog { + private static final Logger log = LogManager.getLogger(SelectPresetDialog.class); + // region Variable Declarations + private static String RESOURCE_PACKAGE = "mekhq/resources/NEWCampaignOptionsDialog"; + private static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE, + MekHQ.getMHQOptions().getLocale()); + + final static String OPTION_SELECT_PRESET = resources.getString("presetDialogSelect.name"); + final static String OPTION_CUSTOMIZE_PRESET = resources.getString("presetDialogCustomize.name"); + final static String OPTION_CANCEL = resources.getString("presetDialogCancel.name"); + + private static final MMLogger logger = MMLogger.create(SelectPresetDialog.class); + // endregion Variable Declarations + + // region Constructors + + /** + * A dialog for selecting campaign presets. + * + * @param frame The parent {@link JFrame}. + */ + private SelectPresetDialog(JFrame frame) { + super(frame, resources.getString("presetDialog.title"), true); // make the dialog modal + + setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); + + ImageIcon image = new ImageIcon("data/images/misc/megamek-splash.png"); + JLabel imageLabel = new JLabel(image); + add(imageLabel, BorderLayout.NORTH); + + JPanel centerPanel = new JPanel(); + final GroupLayout layout = new GroupLayout(centerPanel); + layout.setAutoCreateGaps(true); + layout.setAutoCreateContainerGaps(true); + centerPanel.setLayout(layout); + + JLabel descriptionLabel = new JLabel(resources.getString("presetDialog.description")); + + final DefaultListModel campaignPresets = new DefaultListModel<>(); + campaignPresets.addAll(CampaignPreset.getCampaignPresets()); + + if (campaignPresets.isEmpty()) { + logger.error("No campaign presets found", "Error"); + } + + JComboBox comboBox = new JComboBox<>(); + comboBox.setModel(convertPresetListModelToComboBoxModel(campaignPresets)); + + DefaultListCellRenderer listRenderer = new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, + boolean cellHasFocus) { + if (value instanceof CampaignPreset preset) { + setText(preset.getTitle()); // Set the name as the display text + setToolTipText(wordWrap(preset.getDescription())); // Set the description as the tooltip + } + + // Align the text to the center + setHorizontalAlignment(JLabel.CENTER); + + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + return this; + } + }; + comboBox.setRenderer(listRenderer); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(descriptionLabel) + .addComponent(comboBox) + ); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(descriptionLabel) + .addComponent(comboBox) + ); + + add(centerPanel, BorderLayout.CENTER); + JPanel buttonPanel = new JPanel(); + + JButton button1 = new JButton(OPTION_SELECT_PRESET); + button1.setToolTipText(resources.getString("presetDialogSelect.tooltip")); + button1.addActionListener(e -> { + applyPreset((CampaignPreset) comboBox.getSelectedItem()); + dispose(); + }); + buttonPanel.add(button1); + + JButton button2 = new JButton(OPTION_CUSTOMIZE_PRESET); + button2.setToolTipText(resources.getString("presetDialogCustomize.tooltip")); + button2.addActionListener(e -> { + // handle button 2 click + // TODO initialize campaign options dialog + dispose(); + }); + buttonPanel.add(button2); + + JButton button3 = new JButton(OPTION_CANCEL); + button3.setToolTipText(resources.getString("presetDialogCancel.tooltip")); + button3.addActionListener(e -> dispose()); + buttonPanel.add(button3); + + add(buttonPanel, BorderLayout.PAGE_END); + + pack(); + } + + /** + * Converts a {@link DefaultListModel} of {@link CampaignPreset} objects to a {@link DefaultComboBoxModel}. + * + * @param listModel The {@link DefaultListModel} to convert. + * @return The converted {@link DefaultComboBoxModel}. + */ + private DefaultComboBoxModel convertPresetListModelToComboBoxModel( + DefaultListModel listModel) { + // Create a new DefaultComboBoxModel + DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel<>(); + + // Populate the DefaultComboBoxModel with the elements from the DefaultListModel + for (int i = 0; i < listModel.size(); i++) { + comboBoxModel.addElement(listModel.get(i)); + } + + return comboBoxModel; + } + + /** + * Displays the dialog for selecting campaign presets. + */ + public static void displayPresetDialog() { + JFrame frame = new JFrame(); + SelectPresetDialog dialog = new SelectPresetDialog(frame); + dialog.setLocationRelativeTo(frame); + dialog.setVisible(true); + } + + /** + * Applies the chosen preset to the campaign. + * + * @param preset The {@link CampaignPreset} to apply. + */ + public void applyPreset(final CampaignPreset preset) { + // TODO: apply chosen preset + } +} From 14bef772738aa6061bb93f4f67d3929be5fd818c Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Sun, 29 Sep 2024 14:09:41 -0500 Subject: [PATCH 002/117] Remove unused logger and format comments. Eliminated the unused logger variable in SelectPresetDialog.java to reduce clutter. Additionally, formatted comments in CampaignPreset.java to improve readability and follow documentation standards. --- MekHQ/src/mekhq/campaign/CampaignPreset.java | 4 ++-- .../mekhq/gui/panes/campaignOptions/SelectPresetDialog.java | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/CampaignPreset.java b/MekHQ/src/mekhq/campaign/CampaignPreset.java index 522cfccee6..6ff9c7815a 100644 --- a/MekHQ/src/mekhq/campaign/CampaignPreset.java +++ b/MekHQ/src/mekhq/campaign/CampaignPreset.java @@ -52,11 +52,11 @@ /** * This is an object which holds a set of objects that collectively define the * initial options setup for a campaign. - * + *

* It includes both startup values, which are only used on initial startup (the * date, starting planet, and rank system), and continuous options, which can be * applied at any time (campaign options, skills, SPAs). - * + *

* It also includes a short title and description that allows one to create and * save different presets. The goal is to allow users to create and load various * different presets. diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java index 6b089c8042..4d74cbd994 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java @@ -3,8 +3,6 @@ import megamek.logging.MMLogger; import mekhq.MekHQ; import mekhq.campaign.CampaignPreset; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import javax.swing.*; import javax.swing.GroupLayout.Alignment; @@ -17,7 +15,6 @@ * A dialog for selecting campaign presets. */ public class SelectPresetDialog extends JDialog { - private static final Logger log = LogManager.getLogger(SelectPresetDialog.class); // region Variable Declarations private static String RESOURCE_PACKAGE = "mekhq/resources/NEWCampaignOptionsDialog"; private static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE, From 693499930b98dd1e64653d6461fac071d88e6643 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Sun, 29 Sep 2024 18:29:14 -0500 Subject: [PATCH 003/117] Restructure CampaignOptions package Moved CampaignOptions and related classes to a new package structure under mekhq.campaign.campaignOptions. This improves code organization and clarity. Updated all references to reflect the new package structure. --- MekHQ/src/mekhq/Utilities.java | 2 +- MekHQ/src/mekhq/campaign/Campaign.java | 1 + MekHQ/src/mekhq/campaign/Quartermaster.java | 1 + .../campaign/RandomSkillPreferences.java | 10 +-- .../CampaignOptions.java | 3 +- .../{ => campaignOptions}/CampaignPreset.java | 4 +- .../campaign/event/OptionsChangedEvent.java | 6 +- .../mekhq/campaign/finances/Accountant.java | 6 +- .../campaign/finances/FinancialReport.java | 2 +- .../mekhq/campaign/io/CampaignXmlParser.java | 5 +- .../mission/AtBDynamicScenarioFactory.java | 2 +- MekHQ/src/mekhq/campaign/personnel/Award.java | 2 +- .../src/mekhq/campaign/personnel/Person.java | 2 +- .../campaign/personnel/SpecialAbility.java | 2 +- .../personnel/death/AbstractDeath.java | 2 +- .../personnel/death/AgeRangeRandomDeath.java | 2 +- .../personnel/death/DisabledRandomDeath.java | 2 +- .../death/ExponentialRandomDeath.java | 2 +- .../death/PercentageRandomDeath.java | 2 +- .../personnel/divorce/AbstractDivorce.java | 2 +- .../divorce/DisabledRandomDivorce.java | 2 +- .../personnel/divorce/RandomDivorce.java | 2 +- .../education/EducationController.java | 2 +- .../personnel/enums/RandomDeathMethod.java | 2 +- .../personnel/enums/RandomDivorceMethod.java | 2 +- .../personnel/enums/RandomMarriageMethod.java | 2 +- .../enums/RandomProcreationMethod.java | 2 +- .../personnel/marriage/AbstractMarriage.java | 2 +- .../marriage/DisabledRandomMarriage.java | 2 +- .../personnel/marriage/RandomMarriage.java | 2 +- .../procreation/AbstractProcreation.java | 2 +- .../DisabledRandomProcreation.java | 2 +- .../procreation/RandomProcreation.java | 2 +- .../CamOpsReputation/CommandRating.java | 10 +-- MekHQ/src/mekhq/campaign/universe/Planet.java | 24 ++----- MekHQ/src/mekhq/gui/CampaignGUI.java | 6 +- MekHQ/src/mekhq/gui/CampaignGuiTab.java | 7 +- MekHQ/src/mekhq/gui/CommandCenterTab.java | 2 +- MekHQ/src/mekhq/gui/FileDialogs.java | 15 ++-- .../gui/dialog/CampaignOptionsDialog.java | 2 +- .../dialog/CampaignPresetSelectionDialog.java | 2 +- .../dialog/CreateCampaignPresetDialog.java | 4 +- .../mekhq/gui/dialog/DataLoadingDialog.java | 29 +++----- MekHQ/src/mekhq/gui/dialog/MRMSDialog.java | 33 +++------ .../mekhq/gui/panels/CampaignPresetPanel.java | 2 +- .../mekhq/gui/panes/CampaignOptionsPane.java | 4 +- .../mekhq/gui/panes/CampaignPresetPane.java | 14 ++-- .../campaignOptions/SelectPresetDialog.java | 2 +- .../gui/renderers/CampaignPresetRenderer.java | 2 +- .../service/mrms/MRMSConfiguredOptions.java | 2 +- .../mekhq/campaign/QuartermasterTest.java | 1 + .../ContractMarketAtBGenerationTests.java | 6 +- .../market/ContractMarketIntegrationTest.java | 2 +- .../mekhq/campaign/mission/ContractTest.java | 2 +- .../mekhq/campaign/parts/AmmoStorageTest.java | 2 +- .../mekhq/campaign/parts/MekLocationTest.java | 68 +++++++------------ .../mekhq/campaign/parts/RefitTest.java | 1 + .../campaign/parts/equipment/AmmoBinTest.java | 2 +- .../parts/equipment/EquipmentPartTest.java | 4 +- .../parts/equipment/InfantryAmmoBinTest.java | 2 +- .../equipment/LargeCraftAmmoBinTest.java | 2 +- .../mekhq/campaign/personnel/PersonTest.java | 27 ++++---- .../personnel/death/AbstractDeathTest.java | 9 ++- .../death/AgeRangeRandomDeathTest.java | 2 +- .../death/DisabledRandomDeathTest.java | 2 +- .../death/ExponentialRandomDeathTest.java | 2 +- .../death/PercentageRandomDeathTest.java | 2 +- .../divorce/AbstractDivorceTest.java | 2 +- .../divorce/DisabledRandomDivorceTest.java | 2 +- .../divorce/PercentageRandomDivorceTest.java | 2 +- .../enums/MergingSurnameStyleTest.java | 37 +++++----- .../enums/RandomDeathMethodTest.java | 2 +- .../enums/RandomDivorceMethodTest.java | 2 +- .../enums/RandomMarriageMethodTest.java | 2 +- .../enums/RandomProcreationMethodTest.java | 2 +- .../enums/SplittingSurnameStyleTest.java | 2 +- .../marriage/AbstractMarriageTest.java | 2 +- .../marriage/DisabledRandomMarriageTest.java | 2 +- .../PercentageRandomMarriageTest.java | 2 +- .../procreation/AbstractProcreationTest.java | 2 +- .../DisabledRandomProcreationTest.java | 2 +- .../procreation/RandomProcreationTest.java | 2 +- .../FieldManualMercRevDragoonsRatingTest.java | 39 ++++++----- .../actions/HirePersonnelUnitActionTest.java | 2 +- .../UnableToAffordExpensesNagDialogTest.java | 4 +- .../UnableToAffordJumpNagDialogTest.java | 4 +- ...resolvedStratConContactsNagDialogTest.java | 4 +- 87 files changed, 227 insertions(+), 273 deletions(-) rename MekHQ/src/mekhq/campaign/{ => campaignOptions}/CampaignOptions.java (99%) rename MekHQ/src/mekhq/campaign/{ => campaignOptions}/CampaignPreset.java (99%) diff --git a/MekHQ/src/mekhq/Utilities.java b/MekHQ/src/mekhq/Utilities.java index c72f553e68..657a8ee9ab 100644 --- a/MekHQ/src/mekhq/Utilities.java +++ b/MekHQ/src/mekhq/Utilities.java @@ -32,7 +32,7 @@ import megamek.common.options.OptionsConstants; import megamek.logging.MMLogger; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.finances.Money; import mekhq.campaign.mission.IPlayerSettings; import mekhq.campaign.personnel.Person; diff --git a/MekHQ/src/mekhq/campaign/Campaign.java b/MekHQ/src/mekhq/campaign/Campaign.java index f79729e96c..6397cf6067 100644 --- a/MekHQ/src/mekhq/campaign/Campaign.java +++ b/MekHQ/src/mekhq/campaign/Campaign.java @@ -47,6 +47,7 @@ import mekhq.Utilities; import mekhq.campaign.Quartermaster.PartAcquisitionResult; import mekhq.campaign.againstTheBot.AtBConfiguration; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.event.*; import mekhq.campaign.finances.*; import mekhq.campaign.finances.enums.TransactionType; diff --git a/MekHQ/src/mekhq/campaign/Quartermaster.java b/MekHQ/src/mekhq/campaign/Quartermaster.java index f0b6e9d378..44e596f15b 100644 --- a/MekHQ/src/mekhq/campaign/Quartermaster.java +++ b/MekHQ/src/mekhq/campaign/Quartermaster.java @@ -23,6 +23,7 @@ import megamek.common.annotations.Nullable; import megamek.common.weapons.infantry.InfantryWeapon; import mekhq.MekHQ; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.event.PartArrivedEvent; import mekhq.campaign.event.PartChangedEvent; import mekhq.campaign.finances.Money; diff --git a/MekHQ/src/mekhq/campaign/RandomSkillPreferences.java b/MekHQ/src/mekhq/campaign/RandomSkillPreferences.java index 3dc85adc99..df8b3ad314 100644 --- a/MekHQ/src/mekhq/campaign/RandomSkillPreferences.java +++ b/MekHQ/src/mekhq/campaign/RandomSkillPreferences.java @@ -20,15 +20,15 @@ */ package mekhq.campaign; -import java.io.PrintWriter; - -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.Version; import megamek.logging.MMLogger; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.enums.PersonnelRole; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import java.io.PrintWriter; /** * @author Jay Lawson diff --git a/MekHQ/src/mekhq/campaign/CampaignOptions.java b/MekHQ/src/mekhq/campaign/campaignOptions/CampaignOptions.java similarity index 99% rename from MekHQ/src/mekhq/campaign/CampaignOptions.java rename to MekHQ/src/mekhq/campaign/campaignOptions/CampaignOptions.java index 3f5360364f..41718ecc69 100644 --- a/MekHQ/src/mekhq/campaign/CampaignOptions.java +++ b/MekHQ/src/mekhq/campaign/campaignOptions/CampaignOptions.java @@ -17,7 +17,7 @@ * You should have received a copy of the GNU General Public License * along with MekHQ. If not, see . */ -package mekhq.campaign; +package mekhq.campaign.campaignOptions; import megamek.Version; import megamek.codeUtilities.MathUtility; @@ -27,6 +27,7 @@ import megamek.logging.MMLogger; import mekhq.MekHQ; import mekhq.Utilities; +import mekhq.campaign.RandomOriginOptions; import mekhq.campaign.enums.PlanetaryAcquisitionFactionLimit; import mekhq.campaign.finances.Money; import mekhq.campaign.finances.enums.FinancialYearDuration; diff --git a/MekHQ/src/mekhq/campaign/CampaignPreset.java b/MekHQ/src/mekhq/campaign/campaignOptions/CampaignPreset.java similarity index 99% rename from MekHQ/src/mekhq/campaign/CampaignPreset.java rename to MekHQ/src/mekhq/campaign/campaignOptions/CampaignPreset.java index 6ff9c7815a..0766601170 100644 --- a/MekHQ/src/mekhq/campaign/CampaignPreset.java +++ b/MekHQ/src/mekhq/campaign/campaignOptions/CampaignPreset.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU General Public License * along with MekHQ. If not, see . */ -package mekhq.campaign; +package mekhq.campaign.campaignOptions; import megamek.Version; import megamek.common.annotations.Nullable; @@ -26,6 +26,8 @@ import megamek.utilities.xml.MMXMLUtility; import mekhq.MHQConstants; import mekhq.MekHQ; +import mekhq.campaign.Campaign; +import mekhq.campaign.RandomSkillPreferences; import mekhq.campaign.event.OptionsChangedEvent; import mekhq.campaign.personnel.PersonnelOptions; import mekhq.campaign.personnel.SkillType; diff --git a/MekHQ/src/mekhq/campaign/event/OptionsChangedEvent.java b/MekHQ/src/mekhq/campaign/event/OptionsChangedEvent.java index d1058415b3..c68ed38ac6 100644 --- a/MekHQ/src/mekhq/campaign/event/OptionsChangedEvent.java +++ b/MekHQ/src/mekhq/campaign/event/OptionsChangedEvent.java @@ -18,10 +18,10 @@ */ package mekhq.campaign.event; -import java.util.Objects; - import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; + +import java.util.Objects; /** * An event thrown after the campaign options were changed. The event handlers aren't supposed diff --git a/MekHQ/src/mekhq/campaign/finances/Accountant.java b/MekHQ/src/mekhq/campaign/finances/Accountant.java index f436fe7d50..08f55681ea 100644 --- a/MekHQ/src/mekhq/campaign/finances/Accountant.java +++ b/MekHQ/src/mekhq/campaign/finances/Accountant.java @@ -20,17 +20,17 @@ */ package mekhq.campaign.finances; -import java.util.UUID; - import megamek.common.Entity; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; import mekhq.campaign.Hangar; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.parts.Part; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.enums.PersonnelRole; import mekhq.campaign.unit.Unit; +import java.util.UUID; + /** * Provides accounting for a Campaign. */ diff --git a/MekHQ/src/mekhq/campaign/finances/FinancialReport.java b/MekHQ/src/mekhq/campaign/finances/FinancialReport.java index 8446e18d28..1c57ad8669 100644 --- a/MekHQ/src/mekhq/campaign/finances/FinancialReport.java +++ b/MekHQ/src/mekhq/campaign/finances/FinancialReport.java @@ -20,7 +20,7 @@ import megamek.common.*; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.mission.Contract; import java.util.stream.Collectors; diff --git a/MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java b/MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java index e9ddb64378..a3cf3ca49d 100644 --- a/MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java +++ b/MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java @@ -33,14 +33,15 @@ import mekhq.Utilities; import mekhq.campaign.*; import mekhq.campaign.againstTheBot.AtBConfiguration; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.finances.Finances; import mekhq.campaign.force.Force; import mekhq.campaign.force.Lance; import mekhq.campaign.icons.UnitIcon; -import mekhq.campaign.market.contractMarket.AbstractContractMarket; -import mekhq.campaign.market.contractMarket.AtbMonthlyContractMarket; import mekhq.campaign.market.PersonnelMarket; import mekhq.campaign.market.ShoppingList; +import mekhq.campaign.market.contractMarket.AbstractContractMarket; +import mekhq.campaign.market.contractMarket.AtbMonthlyContractMarket; import mekhq.campaign.mission.AtBContract; import mekhq.campaign.mission.Mission; import mekhq.campaign.mission.Scenario; diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java index 743fe2606b..49999a0f27 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java @@ -38,8 +38,8 @@ import mekhq.MHQConstants; import mekhq.MekHQ; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; import mekhq.campaign.againstTheBot.AtBConfiguration; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.force.Force; import mekhq.campaign.mission.AtBDynamicScenario.BenchedEntityData; import mekhq.campaign.mission.ScenarioForceTemplate.ForceAlignment; diff --git a/MekHQ/src/mekhq/campaign/personnel/Award.java b/MekHQ/src/mekhq/campaign/personnel/Award.java index 00a6df5a5c..1a5a41a02d 100644 --- a/MekHQ/src/mekhq/campaign/personnel/Award.java +++ b/MekHQ/src/mekhq/campaign/personnel/Award.java @@ -23,7 +23,7 @@ import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlRootElement; import mekhq.MekHQ; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.utilities.MHQXMLUtility; import java.io.PrintWriter; diff --git a/MekHQ/src/mekhq/campaign/personnel/Person.java b/MekHQ/src/mekhq/campaign/personnel/Person.java index 934c25bc0a..25a901207c 100644 --- a/MekHQ/src/mekhq/campaign/personnel/Person.java +++ b/MekHQ/src/mekhq/campaign/personnel/Person.java @@ -35,8 +35,8 @@ import mekhq.MekHQ; import mekhq.Utilities; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; import mekhq.campaign.ExtraData; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.event.PersonChangedEvent; import mekhq.campaign.event.PersonStatusChangedEvent; import mekhq.campaign.finances.Money; diff --git a/MekHQ/src/mekhq/campaign/personnel/SpecialAbility.java b/MekHQ/src/mekhq/campaign/personnel/SpecialAbility.java index 9d1bf878fe..03fe8c9f17 100644 --- a/MekHQ/src/mekhq/campaign/personnel/SpecialAbility.java +++ b/MekHQ/src/mekhq/campaign/personnel/SpecialAbility.java @@ -53,7 +53,7 @@ import megamek.common.weapons.infantry.InfantryWeapon; import megamek.logging.MMLogger; import mekhq.Utilities; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.enums.PersonnelRole; import mekhq.utilities.MHQXMLUtility; diff --git a/MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java b/MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java index 5da721ba6a..e9b21793c1 100644 --- a/MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java +++ b/MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java @@ -26,7 +26,7 @@ import mekhq.MHQConstants; import mekhq.MekHQ; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.enums.AgeGroup; import mekhq.campaign.personnel.enums.PersonnelStatus; diff --git a/MekHQ/src/mekhq/campaign/personnel/death/AgeRangeRandomDeath.java b/MekHQ/src/mekhq/campaign/personnel/death/AgeRangeRandomDeath.java index 4f9f59315a..5c999f1c78 100644 --- a/MekHQ/src/mekhq/campaign/personnel/death/AgeRangeRandomDeath.java +++ b/MekHQ/src/mekhq/campaign/personnel/death/AgeRangeRandomDeath.java @@ -20,7 +20,7 @@ import megamek.common.Compute; import megamek.common.enums.Gender; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.enums.RandomDeathMethod; import mekhq.campaign.personnel.enums.TenYearAgeRange; diff --git a/MekHQ/src/mekhq/campaign/personnel/death/DisabledRandomDeath.java b/MekHQ/src/mekhq/campaign/personnel/death/DisabledRandomDeath.java index d201319798..e4eaa438d4 100644 --- a/MekHQ/src/mekhq/campaign/personnel/death/DisabledRandomDeath.java +++ b/MekHQ/src/mekhq/campaign/personnel/death/DisabledRandomDeath.java @@ -19,7 +19,7 @@ package mekhq.campaign.personnel.death; import megamek.common.enums.Gender; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.enums.RandomDeathMethod; public class DisabledRandomDeath extends AbstractDeath { diff --git a/MekHQ/src/mekhq/campaign/personnel/death/ExponentialRandomDeath.java b/MekHQ/src/mekhq/campaign/personnel/death/ExponentialRandomDeath.java index a3a65ce270..ef8c8b8f05 100644 --- a/MekHQ/src/mekhq/campaign/personnel/death/ExponentialRandomDeath.java +++ b/MekHQ/src/mekhq/campaign/personnel/death/ExponentialRandomDeath.java @@ -20,7 +20,7 @@ import megamek.common.Compute; import megamek.common.enums.Gender; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.enums.RandomDeathMethod; public class ExponentialRandomDeath extends AbstractDeath { diff --git a/MekHQ/src/mekhq/campaign/personnel/death/PercentageRandomDeath.java b/MekHQ/src/mekhq/campaign/personnel/death/PercentageRandomDeath.java index e097f00668..8b3130d8ac 100644 --- a/MekHQ/src/mekhq/campaign/personnel/death/PercentageRandomDeath.java +++ b/MekHQ/src/mekhq/campaign/personnel/death/PercentageRandomDeath.java @@ -20,7 +20,7 @@ import megamek.common.Compute; import megamek.common.enums.Gender; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.enums.RandomDeathMethod; public class PercentageRandomDeath extends AbstractDeath { diff --git a/MekHQ/src/mekhq/campaign/personnel/divorce/AbstractDivorce.java b/MekHQ/src/mekhq/campaign/personnel/divorce/AbstractDivorce.java index 1d4642f854..fe0b053b23 100644 --- a/MekHQ/src/mekhq/campaign/personnel/divorce/AbstractDivorce.java +++ b/MekHQ/src/mekhq/campaign/personnel/divorce/AbstractDivorce.java @@ -22,7 +22,7 @@ import megamek.common.annotations.Nullable; import mekhq.MekHQ; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.event.PersonChangedEvent; import mekhq.campaign.log.PersonalLogger; import mekhq.campaign.personnel.Person; diff --git a/MekHQ/src/mekhq/campaign/personnel/divorce/DisabledRandomDivorce.java b/MekHQ/src/mekhq/campaign/personnel/divorce/DisabledRandomDivorce.java index f24ea6d52f..9149e87d58 100644 --- a/MekHQ/src/mekhq/campaign/personnel/divorce/DisabledRandomDivorce.java +++ b/MekHQ/src/mekhq/campaign/personnel/divorce/DisabledRandomDivorce.java @@ -18,7 +18,7 @@ */ package mekhq.campaign.personnel.divorce; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.enums.RandomDivorceMethod; public class DisabledRandomDivorce extends AbstractDivorce { diff --git a/MekHQ/src/mekhq/campaign/personnel/divorce/RandomDivorce.java b/MekHQ/src/mekhq/campaign/personnel/divorce/RandomDivorce.java index 5226acc6c6..d221b8a647 100644 --- a/MekHQ/src/mekhq/campaign/personnel/divorce/RandomDivorce.java +++ b/MekHQ/src/mekhq/campaign/personnel/divorce/RandomDivorce.java @@ -19,7 +19,7 @@ package mekhq.campaign.personnel.divorce; import megamek.common.Compute; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.enums.RandomDivorceMethod; /** diff --git a/MekHQ/src/mekhq/campaign/personnel/education/EducationController.java b/MekHQ/src/mekhq/campaign/personnel/education/EducationController.java index cc4fc58969..b4f5d69099 100644 --- a/MekHQ/src/mekhq/campaign/personnel/education/EducationController.java +++ b/MekHQ/src/mekhq/campaign/personnel/education/EducationController.java @@ -22,7 +22,7 @@ import megamek.logging.MMLogger; import mekhq.MekHQ; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.event.PersonChangedEvent; import mekhq.campaign.finances.Money; import mekhq.campaign.finances.enums.TransactionType; diff --git a/MekHQ/src/mekhq/campaign/personnel/enums/RandomDeathMethod.java b/MekHQ/src/mekhq/campaign/personnel/enums/RandomDeathMethod.java index 7de03f69d3..36e6e55331 100644 --- a/MekHQ/src/mekhq/campaign/personnel/enums/RandomDeathMethod.java +++ b/MekHQ/src/mekhq/campaign/personnel/enums/RandomDeathMethod.java @@ -19,7 +19,7 @@ package mekhq.campaign.personnel.enums; import mekhq.MekHQ; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.death.*; import java.util.ResourceBundle; diff --git a/MekHQ/src/mekhq/campaign/personnel/enums/RandomDivorceMethod.java b/MekHQ/src/mekhq/campaign/personnel/enums/RandomDivorceMethod.java index db526631d2..41c8eb6e7e 100644 --- a/MekHQ/src/mekhq/campaign/personnel/enums/RandomDivorceMethod.java +++ b/MekHQ/src/mekhq/campaign/personnel/enums/RandomDivorceMethod.java @@ -19,7 +19,7 @@ package mekhq.campaign.personnel.enums; import mekhq.MekHQ; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.divorce.AbstractDivorce; import mekhq.campaign.personnel.divorce.DisabledRandomDivorce; import mekhq.campaign.personnel.divorce.RandomDivorce; diff --git a/MekHQ/src/mekhq/campaign/personnel/enums/RandomMarriageMethod.java b/MekHQ/src/mekhq/campaign/personnel/enums/RandomMarriageMethod.java index aa9bd9d8dc..f632ac3c59 100644 --- a/MekHQ/src/mekhq/campaign/personnel/enums/RandomMarriageMethod.java +++ b/MekHQ/src/mekhq/campaign/personnel/enums/RandomMarriageMethod.java @@ -19,7 +19,7 @@ package mekhq.campaign.personnel.enums; import mekhq.MekHQ; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.marriage.AbstractMarriage; import mekhq.campaign.personnel.marriage.DisabledRandomMarriage; import mekhq.campaign.personnel.marriage.RandomMarriage; diff --git a/MekHQ/src/mekhq/campaign/personnel/enums/RandomProcreationMethod.java b/MekHQ/src/mekhq/campaign/personnel/enums/RandomProcreationMethod.java index 2cef0e7441..19fbe605ac 100644 --- a/MekHQ/src/mekhq/campaign/personnel/enums/RandomProcreationMethod.java +++ b/MekHQ/src/mekhq/campaign/personnel/enums/RandomProcreationMethod.java @@ -19,7 +19,7 @@ package mekhq.campaign.personnel.enums; import mekhq.MekHQ; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.procreation.AbstractProcreation; import mekhq.campaign.personnel.procreation.DisabledRandomProcreation; import mekhq.campaign.personnel.procreation.RandomProcreation; diff --git a/MekHQ/src/mekhq/campaign/personnel/marriage/AbstractMarriage.java b/MekHQ/src/mekhq/campaign/personnel/marriage/AbstractMarriage.java index 3f5ef99913..97560991f9 100644 --- a/MekHQ/src/mekhq/campaign/personnel/marriage/AbstractMarriage.java +++ b/MekHQ/src/mekhq/campaign/personnel/marriage/AbstractMarriage.java @@ -24,7 +24,7 @@ import megamek.common.enums.Gender; import mekhq.MekHQ; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.event.PersonChangedEvent; import mekhq.campaign.log.PersonalLogger; import mekhq.campaign.personnel.Person; diff --git a/MekHQ/src/mekhq/campaign/personnel/marriage/DisabledRandomMarriage.java b/MekHQ/src/mekhq/campaign/personnel/marriage/DisabledRandomMarriage.java index c54825bffd..0ab5f301f3 100644 --- a/MekHQ/src/mekhq/campaign/personnel/marriage/DisabledRandomMarriage.java +++ b/MekHQ/src/mekhq/campaign/personnel/marriage/DisabledRandomMarriage.java @@ -18,7 +18,7 @@ */ package mekhq.campaign.personnel.marriage; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.enums.RandomMarriageMethod; public class DisabledRandomMarriage extends AbstractMarriage { diff --git a/MekHQ/src/mekhq/campaign/personnel/marriage/RandomMarriage.java b/MekHQ/src/mekhq/campaign/personnel/marriage/RandomMarriage.java index dbb82764c0..ecafca563e 100644 --- a/MekHQ/src/mekhq/campaign/personnel/marriage/RandomMarriage.java +++ b/MekHQ/src/mekhq/campaign/personnel/marriage/RandomMarriage.java @@ -19,7 +19,7 @@ package mekhq.campaign.personnel.marriage; import megamek.common.Compute; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.enums.RandomMarriageMethod; /** diff --git a/MekHQ/src/mekhq/campaign/personnel/procreation/AbstractProcreation.java b/MekHQ/src/mekhq/campaign/personnel/procreation/AbstractProcreation.java index 7d2794d92e..52f158e69b 100644 --- a/MekHQ/src/mekhq/campaign/personnel/procreation/AbstractProcreation.java +++ b/MekHQ/src/mekhq/campaign/personnel/procreation/AbstractProcreation.java @@ -26,9 +26,9 @@ import mekhq.MHQConstants; import mekhq.MekHQ; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; import mekhq.campaign.ExtraData.IntKey; import mekhq.campaign.ExtraData.StringKey; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.log.MedicalLogger; import mekhq.campaign.log.PersonalLogger; import mekhq.campaign.personnel.Person; diff --git a/MekHQ/src/mekhq/campaign/personnel/procreation/DisabledRandomProcreation.java b/MekHQ/src/mekhq/campaign/personnel/procreation/DisabledRandomProcreation.java index 0c3cb78e9e..769706c8cc 100644 --- a/MekHQ/src/mekhq/campaign/personnel/procreation/DisabledRandomProcreation.java +++ b/MekHQ/src/mekhq/campaign/personnel/procreation/DisabledRandomProcreation.java @@ -18,7 +18,7 @@ */ package mekhq.campaign.personnel.procreation; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.enums.RandomProcreationMethod; diff --git a/MekHQ/src/mekhq/campaign/personnel/procreation/RandomProcreation.java b/MekHQ/src/mekhq/campaign/personnel/procreation/RandomProcreation.java index 8a30e6ecc2..716c135b1e 100644 --- a/MekHQ/src/mekhq/campaign/personnel/procreation/RandomProcreation.java +++ b/MekHQ/src/mekhq/campaign/personnel/procreation/RandomProcreation.java @@ -19,7 +19,7 @@ package mekhq.campaign.personnel.procreation; import megamek.common.Compute; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.enums.RandomProcreationMethod; diff --git a/MekHQ/src/mekhq/campaign/rating/CamOpsReputation/CommandRating.java b/MekHQ/src/mekhq/campaign/rating/CamOpsReputation/CommandRating.java index d9f22a4ee6..8ac67aae52 100644 --- a/MekHQ/src/mekhq/campaign/rating/CamOpsReputation/CommandRating.java +++ b/MekHQ/src/mekhq/campaign/rating/CamOpsReputation/CommandRating.java @@ -18,13 +18,9 @@ */ package mekhq.campaign.rating.CamOpsReputation; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Collectors; - import megamek.logging.MMLogger; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.randomEvents.enums.personalities.Aggression; @@ -32,6 +28,10 @@ import mekhq.campaign.personnel.randomEvents.enums.personalities.Greed; import mekhq.campaign.personnel.randomEvents.enums.personalities.Social; +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Collectors; + public class CommandRating { private static final MMLogger logger = MMLogger.create(CommandRating.class); diff --git a/MekHQ/src/mekhq/campaign/universe/Planet.java b/MekHQ/src/mekhq/campaign/universe/Planet.java index bc701e358d..fe435760c0 100644 --- a/MekHQ/src/mekhq/campaign/universe/Planet.java +++ b/MekHQ/src/mekhq/campaign/universe/Planet.java @@ -19,16 +19,9 @@ */ package mekhq.campaign.universe; -import java.time.LocalDate; -import java.util.*; - import jakarta.xml.bind.Marshaller; import jakarta.xml.bind.Unmarshaller; -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlTransient; +import jakarta.xml.bind.annotation.*; import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import megamek.codeUtilities.ObjectUtility; import megamek.common.EquipmentType; @@ -36,18 +29,13 @@ import megamek.common.TargetRoll; import megamek.logging.MMLogger; import mekhq.Utilities; -import mekhq.adapter.AtmosphereAdapter; -import mekhq.adapter.BooleanValueAdapter; -import mekhq.adapter.ClimateAdapter; -import mekhq.adapter.DateAdapter; -import mekhq.adapter.HPGRatingAdapter; -import mekhq.adapter.LifeFormAdapter; -import mekhq.adapter.PressureAdapter; -import mekhq.adapter.SocioIndustrialDataAdapter; -import mekhq.adapter.StringListAdapter; -import mekhq.campaign.CampaignOptions; +import mekhq.adapter.*; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.universe.Faction.Tag; +import java.time.LocalDate; +import java.util.*; + /** * This is the start of a planet object that will keep lots of information about * planets that can be displayed on the interstellar map. diff --git a/MekHQ/src/mekhq/gui/CampaignGUI.java b/MekHQ/src/mekhq/gui/CampaignGUI.java index 645e8ad867..831e3257e6 100644 --- a/MekHQ/src/mekhq/gui/CampaignGUI.java +++ b/MekHQ/src/mekhq/gui/CampaignGUI.java @@ -37,8 +37,8 @@ import mekhq.*; import mekhq.campaign.Campaign; import mekhq.campaign.CampaignController; -import mekhq.campaign.CampaignOptions; -import mekhq.campaign.CampaignPreset; +import mekhq.campaign.campaignOptions.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignPreset; import mekhq.campaign.event.*; import mekhq.campaign.finances.Money; import mekhq.campaign.finances.financialInstitutions.FinancialInstitutions; @@ -1545,7 +1545,7 @@ private void menuOptionsActionPerformed(final ActionEvent evt) { getCampaign().getUnitMarket().setOffers(unitMarket.getOffers()); miUnitMarket.setVisible(!getCampaign().getUnitMarket().getMethod().isNone()); } - + AbstractContractMarket contractMarket = getCampaign().getContractMarket(); if (contractMarket.getMethod() != newOptions.getContractMarketMethod()) { getCampaign().setContractMarket(newOptions.getContractMarketMethod().getContractMarket()); diff --git a/MekHQ/src/mekhq/gui/CampaignGuiTab.java b/MekHQ/src/mekhq/gui/CampaignGuiTab.java index 07777ad8b7..517882907c 100644 --- a/MekHQ/src/mekhq/gui/CampaignGuiTab.java +++ b/MekHQ/src/mekhq/gui/CampaignGuiTab.java @@ -18,15 +18,14 @@ */ package mekhq.gui; -import javax.swing.JFrame; -import javax.swing.JPanel; - import mekhq.IconPackage; import mekhq.MekHQ; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.gui.enums.MHQTabType; +import javax.swing.*; + /** * Abstract base class for CampaignGUI tab components. Custom tabs should extend * CustomCampaignGuiTab instead of this one. diff --git a/MekHQ/src/mekhq/gui/CommandCenterTab.java b/MekHQ/src/mekhq/gui/CommandCenterTab.java index ab303b19bf..7fe509920c 100644 --- a/MekHQ/src/mekhq/gui/CommandCenterTab.java +++ b/MekHQ/src/mekhq/gui/CommandCenterTab.java @@ -25,8 +25,8 @@ import mekhq.MHQOptionsChangedEvent; import mekhq.MekHQ; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; import mekhq.campaign.CampaignSummary; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.event.*; import mekhq.campaign.finances.FinancialReport; import mekhq.campaign.mission.Mission; diff --git a/MekHQ/src/mekhq/gui/FileDialogs.java b/MekHQ/src/mekhq/gui/FileDialogs.java index 873f9f325e..1ced724396 100644 --- a/MekHQ/src/mekhq/gui/FileDialogs.java +++ b/MekHQ/src/mekhq/gui/FileDialogs.java @@ -18,20 +18,19 @@ */ package mekhq.gui; -import java.io.File; -import java.time.format.DateTimeFormatter; -import java.util.Optional; - -import javax.swing.JFrame; - -import mekhq.MekHQ; import mekhq.MHQConstants; +import mekhq.MekHQ; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignPreset; +import mekhq.campaign.campaignOptions.CampaignPreset; import mekhq.campaign.mission.Scenario; import mekhq.campaign.mission.ScenarioTemplate; import mekhq.io.FileType; +import javax.swing.*; +import java.io.File; +import java.time.format.DateTimeFormatter; +import java.util.Optional; + /** * Utility class with methods to show the various open/save file dialogs */ diff --git a/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java b/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java index 5ecc984881..aff9308063 100644 --- a/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java @@ -24,7 +24,7 @@ import megamek.common.annotations.Nullable; import mekhq.MekHQ; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignPreset; +import mekhq.campaign.campaignOptions.CampaignPreset; import mekhq.gui.FileDialogs; import mekhq.gui.baseComponents.AbstractMHQValidationButtonDialog; import mekhq.gui.panes.CampaignOptionsPane; diff --git a/MekHQ/src/mekhq/gui/dialog/CampaignPresetSelectionDialog.java b/MekHQ/src/mekhq/gui/dialog/CampaignPresetSelectionDialog.java index 848be08b22..38c6ce8b8b 100644 --- a/MekHQ/src/mekhq/gui/dialog/CampaignPresetSelectionDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/CampaignPresetSelectionDialog.java @@ -19,7 +19,7 @@ package mekhq.gui.dialog; import megamek.common.annotations.Nullable; -import mekhq.campaign.CampaignPreset; +import mekhq.campaign.campaignOptions.CampaignPreset; import mekhq.gui.baseComponents.AbstractMHQButtonDialog; import mekhq.gui.panes.CampaignPresetPane; diff --git a/MekHQ/src/mekhq/gui/dialog/CreateCampaignPresetDialog.java b/MekHQ/src/mekhq/gui/dialog/CreateCampaignPresetDialog.java index 0697cd47ed..9838821e5f 100644 --- a/MekHQ/src/mekhq/gui/dialog/CreateCampaignPresetDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/CreateCampaignPresetDialog.java @@ -30,9 +30,9 @@ import megamek.common.util.sorter.NaturalOrderComparator; import mekhq.MekHQ; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; -import mekhq.campaign.CampaignPreset; import mekhq.campaign.RandomSkillPreferences; +import mekhq.campaign.campaignOptions.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignPreset; import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.SpecialAbility; import mekhq.campaign.personnel.ranks.RankSystem; diff --git a/MekHQ/src/mekhq/gui/dialog/DataLoadingDialog.java b/MekHQ/src/mekhq/gui/dialog/DataLoadingDialog.java index 090f7a0702..462770b209 100644 --- a/MekHQ/src/mekhq/gui/dialog/DataLoadingDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/DataLoadingDialog.java @@ -18,23 +18,6 @@ */ package mekhq.gui.dialog; -import java.awt.BorderLayout; -import java.awt.Container; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.io.File; -import java.io.FileInputStream; -import java.time.LocalDate; -import java.util.concurrent.CancellationException; -import java.util.concurrent.ExecutionException; - -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JProgressBar; -import javax.swing.SwingWorker; - import megamek.client.generator.RandomCallsignGenerator; import megamek.client.generator.RandomNameGenerator; import megamek.client.ui.swing.util.UIUtil; @@ -47,7 +30,7 @@ import mekhq.NullEntityException; import mekhq.campaign.Campaign; import mekhq.campaign.CampaignFactory; -import mekhq.campaign.CampaignPreset; +import mekhq.campaign.campaignOptions.CampaignPreset; import mekhq.campaign.event.OptionsChangedEvent; import mekhq.campaign.finances.CurrencyManager; import mekhq.campaign.finances.financialInstitutions.FinancialInstitutions; @@ -67,6 +50,16 @@ import mekhq.campaign.universe.eras.Eras; import mekhq.gui.baseComponents.AbstractMHQDialog; +import javax.swing.*; +import java.awt.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.File; +import java.io.FileInputStream; +import java.time.LocalDate; +import java.util.concurrent.CancellationException; +import java.util.concurrent.ExecutionException; + public class DataLoadingDialog extends AbstractMHQDialog implements PropertyChangeListener { private static final MMLogger logger = MMLogger.create(DataLoadingDialog.class); diff --git a/MekHQ/src/mekhq/gui/dialog/MRMSDialog.java b/MekHQ/src/mekhq/gui/dialog/MRMSDialog.java index 680e61d88d..c7e5a1a60b 100644 --- a/MekHQ/src/mekhq/gui/dialog/MRMSDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/MRMSDialog.java @@ -18,33 +18,12 @@ */ package mekhq.gui.dialog; -import java.awt.BorderLayout; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.ResourceBundle; - -import javax.swing.*; -import javax.swing.JSpinner.DefaultEditor; -import javax.swing.table.TableColumn; -import javax.swing.table.TableRowSorter; - import megamek.client.ui.models.XTableColumnModel; import megamek.client.ui.preferences.JWindowPreference; import megamek.client.ui.preferences.PreferencesNode; import megamek.logging.MMLogger; import mekhq.MekHQ; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.event.OptionsChangedEvent; import mekhq.campaign.parts.Part; import mekhq.campaign.parts.enums.PartRepairType; @@ -66,6 +45,16 @@ import mekhq.service.mrms.MRMSService; import mekhq.service.mrms.MRMSService.MRMSPartSet; +import javax.swing.*; +import javax.swing.JSpinner.DefaultEditor; +import javax.swing.table.TableColumn; +import javax.swing.table.TableRowSorter; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.text.MessageFormat; +import java.util.List; +import java.util.*; + /** * @author Kipsta */ diff --git a/MekHQ/src/mekhq/gui/panels/CampaignPresetPanel.java b/MekHQ/src/mekhq/gui/panels/CampaignPresetPanel.java index 709d27d070..e018962dc6 100644 --- a/MekHQ/src/mekhq/gui/panels/CampaignPresetPanel.java +++ b/MekHQ/src/mekhq/gui/panels/CampaignPresetPanel.java @@ -21,7 +21,7 @@ import megamek.client.ui.baseComponents.MMButton; import megamek.common.annotations.Nullable; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignPreset; +import mekhq.campaign.campaignOptions.CampaignPreset; import mekhq.gui.baseComponents.AbstractMHQPanel; import mekhq.gui.dialog.CreateCampaignPresetDialog; diff --git a/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java index 9385b8513d..eba57e06ca 100644 --- a/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java @@ -40,9 +40,9 @@ import megamek.logging.MMLogger; import mekhq.MekHQ; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; -import mekhq.campaign.CampaignPreset; import mekhq.campaign.RandomSkillPreferences; +import mekhq.campaign.campaignOptions.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignPreset; import mekhq.campaign.enums.PlanetaryAcquisitionFactionLimit; import mekhq.campaign.event.OptionsChangedEvent; import mekhq.campaign.finances.enums.FinancialYearDuration; diff --git a/MekHQ/src/mekhq/gui/panes/CampaignPresetPane.java b/MekHQ/src/mekhq/gui/panes/CampaignPresetPane.java index 864bf8f89f..58488a25a5 100644 --- a/MekHQ/src/mekhq/gui/panes/CampaignPresetPane.java +++ b/MekHQ/src/mekhq/gui/panes/CampaignPresetPane.java @@ -18,25 +18,19 @@ */ package mekhq.gui.panes; -import java.awt.Dimension; -import java.awt.GridLayout; - -import javax.swing.DefaultListModel; -import javax.swing.JFrame; -import javax.swing.JList; -import javax.swing.JScrollPane; -import javax.swing.ListSelectionModel; - import megamek.client.ui.preferences.JListPreference; import megamek.client.ui.preferences.PreferencesNode; import megamek.common.annotations.Nullable; import megamek.logging.MMLogger; -import mekhq.campaign.CampaignPreset; +import mekhq.campaign.campaignOptions.CampaignPreset; import mekhq.gui.baseComponents.AbstractMHQScrollPane; import mekhq.gui.baseComponents.AbstractMHQScrollablePanel; import mekhq.gui.baseComponents.DefaultMHQScrollablePanel; import mekhq.gui.renderers.CampaignPresetRenderer; +import javax.swing.*; +import java.awt.*; + public class CampaignPresetPane extends AbstractMHQScrollPane { private static final MMLogger logger = MMLogger.create(CampaignPresetPane.class); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java index 4d74cbd994..c2911b2940 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java @@ -2,7 +2,7 @@ import megamek.logging.MMLogger; import mekhq.MekHQ; -import mekhq.campaign.CampaignPreset; +import mekhq.campaign.campaignOptions.CampaignPreset; import javax.swing.*; import javax.swing.GroupLayout.Alignment; diff --git a/MekHQ/src/mekhq/gui/renderers/CampaignPresetRenderer.java b/MekHQ/src/mekhq/gui/renderers/CampaignPresetRenderer.java index 25b81fe3d7..7a7a3dc0cc 100644 --- a/MekHQ/src/mekhq/gui/renderers/CampaignPresetRenderer.java +++ b/MekHQ/src/mekhq/gui/renderers/CampaignPresetRenderer.java @@ -18,7 +18,7 @@ */ package mekhq.gui.renderers; -import mekhq.campaign.CampaignPreset; +import mekhq.campaign.campaignOptions.CampaignPreset; import mekhq.gui.panels.CampaignPresetPanel; import javax.swing.*; diff --git a/MekHQ/src/mekhq/service/mrms/MRMSConfiguredOptions.java b/MekHQ/src/mekhq/service/mrms/MRMSConfiguredOptions.java index 6abfe87810..f87e11badd 100644 --- a/MekHQ/src/mekhq/service/mrms/MRMSConfiguredOptions.java +++ b/MekHQ/src/mekhq/service/mrms/MRMSConfiguredOptions.java @@ -19,7 +19,7 @@ package mekhq.service.mrms; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.parts.enums.PartRepairType; import mekhq.gui.dialog.MRMSDialog; import mekhq.gui.dialog.MRMSDialog.MRMSOptionControl; diff --git a/MekHQ/unittests/mekhq/campaign/QuartermasterTest.java b/MekHQ/unittests/mekhq/campaign/QuartermasterTest.java index 769fbe7754..bbac0a6eff 100644 --- a/MekHQ/unittests/mekhq/campaign/QuartermasterTest.java +++ b/MekHQ/unittests/mekhq/campaign/QuartermasterTest.java @@ -24,6 +24,7 @@ import megamek.common.Infantry; import megamek.common.weapons.infantry.InfantryWeapon; import mekhq.EventSpy; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.event.PartArrivedEvent; import mekhq.campaign.event.PartChangedEvent; import mekhq.campaign.finances.Finances; diff --git a/MekHQ/unittests/mekhq/campaign/market/ContractMarketAtBGenerationTests.java b/MekHQ/unittests/mekhq/campaign/market/ContractMarketAtBGenerationTests.java index 4c2583889b..a2dfa7f399 100644 --- a/MekHQ/unittests/mekhq/campaign/market/ContractMarketAtBGenerationTests.java +++ b/MekHQ/unittests/mekhq/campaign/market/ContractMarketAtBGenerationTests.java @@ -18,7 +18,11 @@ */ package mekhq.campaign.market; -import mekhq.campaign.*; +import mekhq.campaign.Campaign; +import mekhq.campaign.CurrentLocation; +import mekhq.campaign.Hangar; +import mekhq.campaign.JumpPath; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.finances.Accountant; import mekhq.campaign.finances.Money; import mekhq.campaign.force.Force; diff --git a/MekHQ/unittests/mekhq/campaign/market/ContractMarketIntegrationTest.java b/MekHQ/unittests/mekhq/campaign/market/ContractMarketIntegrationTest.java index 58f934e72c..d8fa94eb29 100644 --- a/MekHQ/unittests/mekhq/campaign/market/ContractMarketIntegrationTest.java +++ b/MekHQ/unittests/mekhq/campaign/market/ContractMarketIntegrationTest.java @@ -20,7 +20,7 @@ import megamek.common.*; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.force.Force; import mekhq.campaign.market.contractMarket.AtbMonthlyContractMarket; import mekhq.campaign.mission.AtBContract; diff --git a/MekHQ/unittests/mekhq/campaign/mission/ContractTest.java b/MekHQ/unittests/mekhq/campaign/mission/ContractTest.java index 2963087ff6..cd72ebc998 100644 --- a/MekHQ/unittests/mekhq/campaign/mission/ContractTest.java +++ b/MekHQ/unittests/mekhq/campaign/mission/ContractTest.java @@ -21,8 +21,8 @@ package mekhq.campaign.mission; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; import mekhq.campaign.JumpPath; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.finances.Accountant; import mekhq.campaign.finances.Money; import mekhq.campaign.rating.UnitRatingMethod; diff --git a/MekHQ/unittests/mekhq/campaign/parts/AmmoStorageTest.java b/MekHQ/unittests/mekhq/campaign/parts/AmmoStorageTest.java index 6d7dcedf32..5dfc0e22d9 100644 --- a/MekHQ/unittests/mekhq/campaign/parts/AmmoStorageTest.java +++ b/MekHQ/unittests/mekhq/campaign/parts/AmmoStorageTest.java @@ -22,7 +22,7 @@ import megamek.common.AmmoType; import megamek.common.BombType; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.finances.Money; import mekhq.campaign.parts.equipment.AmmoBin; import mekhq.campaign.work.IAcquisitionWork; diff --git a/MekHQ/unittests/mekhq/campaign/parts/MekLocationTest.java b/MekHQ/unittests/mekhq/campaign/parts/MekLocationTest.java index a3e07fe36f..bc2c86c4f4 100644 --- a/MekHQ/unittests/mekhq/campaign/parts/MekLocationTest.java +++ b/MekHQ/unittests/mekhq/campaign/parts/MekLocationTest.java @@ -18,54 +18,12 @@ */ package mekhq.campaign.parts; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doCallRealMethod; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Arrays; -import java.util.Collections; -import java.util.function.Predicate; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.ParserConfigurationException; - -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; - import megamek.Version; -import megamek.common.CriticalSlot; -import megamek.common.Entity; -import megamek.common.EquipmentType; -import megamek.common.ILocationExposureStatus; -import megamek.common.LandAirMek; -import megamek.common.Mek; -import megamek.common.Mounted; -import megamek.common.TargetRoll; +import megamek.common.*; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; import mekhq.campaign.Quartermaster; import mekhq.campaign.Warehouse; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.parts.enums.PartRepairType; import mekhq.campaign.parts.equipment.EquipmentPart; import mekhq.campaign.personnel.Person; @@ -74,6 +32,28 @@ import mekhq.campaign.unit.Unit; import mekhq.campaign.work.WorkTime; import mekhq.utilities.MHQXMLUtility; +import org.junit.jupiter.api.Test; +import org.mockito.ArgumentCaptor; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.xml.sax.SAXException; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.ParserConfigurationException; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Arrays; +import java.util.Collections; +import java.util.function.Predicate; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.*; class MekLocationTest { @Test diff --git a/MekHQ/unittests/mekhq/campaign/parts/RefitTest.java b/MekHQ/unittests/mekhq/campaign/parts/RefitTest.java index c121e3b70f..08ee21135e 100644 --- a/MekHQ/unittests/mekhq/campaign/parts/RefitTest.java +++ b/MekHQ/unittests/mekhq/campaign/parts/RefitTest.java @@ -23,6 +23,7 @@ import megamek.common.loaders.EntityLoadingException; import megamek.common.options.GameOptions; import megamek.common.options.OptionsConstants; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.utilities.MHQXMLUtility; import mekhq.campaign.*; import mekhq.campaign.finances.Money; diff --git a/MekHQ/unittests/mekhq/campaign/parts/equipment/AmmoBinTest.java b/MekHQ/unittests/mekhq/campaign/parts/equipment/AmmoBinTest.java index af05dbcbc1..5a682c6e8d 100644 --- a/MekHQ/unittests/mekhq/campaign/parts/equipment/AmmoBinTest.java +++ b/MekHQ/unittests/mekhq/campaign/parts/equipment/AmmoBinTest.java @@ -25,9 +25,9 @@ import megamek.common.ProtoMek; import megamek.common.equipment.AmmoMounted; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; import mekhq.campaign.Quartermaster; import mekhq.campaign.Warehouse; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.parts.AmmoStorage; import mekhq.campaign.parts.Part; import mekhq.campaign.parts.enums.PartRepairType; diff --git a/MekHQ/unittests/mekhq/campaign/parts/equipment/EquipmentPartTest.java b/MekHQ/unittests/mekhq/campaign/parts/equipment/EquipmentPartTest.java index 3338f87168..0ea0c98253 100644 --- a/MekHQ/unittests/mekhq/campaign/parts/equipment/EquipmentPartTest.java +++ b/MekHQ/unittests/mekhq/campaign/parts/equipment/EquipmentPartTest.java @@ -22,13 +22,13 @@ import megamek.common.*; import megamek.common.equipment.WeaponMounted; import megamek.common.weapons.bayweapons.BayWeapon; -import mekhq.utilities.MHQXMLUtility; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; import mekhq.campaign.Quartermaster; import mekhq.campaign.Warehouse; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.parts.Part; import mekhq.campaign.unit.Unit; +import mekhq.utilities.MHQXMLUtility; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.w3c.dom.Document; diff --git a/MekHQ/unittests/mekhq/campaign/parts/equipment/InfantryAmmoBinTest.java b/MekHQ/unittests/mekhq/campaign/parts/equipment/InfantryAmmoBinTest.java index 9910ec11c3..d38f3c1cec 100644 --- a/MekHQ/unittests/mekhq/campaign/parts/equipment/InfantryAmmoBinTest.java +++ b/MekHQ/unittests/mekhq/campaign/parts/equipment/InfantryAmmoBinTest.java @@ -23,9 +23,9 @@ import megamek.common.equipment.AmmoMounted; import megamek.common.weapons.infantry.InfantryWeapon; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; import mekhq.campaign.Quartermaster; import mekhq.campaign.Warehouse; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.parts.InfantryAmmoStorage; import mekhq.campaign.parts.Part; import mekhq.campaign.unit.Unit; diff --git a/MekHQ/unittests/mekhq/campaign/parts/equipment/LargeCraftAmmoBinTest.java b/MekHQ/unittests/mekhq/campaign/parts/equipment/LargeCraftAmmoBinTest.java index 43c8688920..6d45b50392 100644 --- a/MekHQ/unittests/mekhq/campaign/parts/equipment/LargeCraftAmmoBinTest.java +++ b/MekHQ/unittests/mekhq/campaign/parts/equipment/LargeCraftAmmoBinTest.java @@ -25,9 +25,9 @@ import megamek.common.equipment.AmmoMounted; import megamek.common.equipment.WeaponMounted; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; import mekhq.campaign.Quartermaster; import mekhq.campaign.Warehouse; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.parts.AmmoStorage; import mekhq.campaign.parts.Part; import mekhq.campaign.unit.Unit; diff --git a/MekHQ/unittests/mekhq/campaign/personnel/PersonTest.java b/MekHQ/unittests/mekhq/campaign/personnel/PersonTest.java index 1def0b6c4c..b26520a4a1 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/PersonTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/PersonTest.java @@ -18,27 +18,26 @@ */ package mekhq.campaign.personnel; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; - -import java.time.LocalDate; -import java.util.UUID; - -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; - import megamek.common.Entity; import megamek.common.EntityWeightClass; import megamek.common.TechConstants; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.enums.AwardBonus; import mekhq.campaign.personnel.enums.PrisonerStatus; import mekhq.campaign.unit.Unit; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; + +import java.time.LocalDate; +import java.util.UUID; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; public class PersonTest { private Person mockPerson; diff --git a/MekHQ/unittests/mekhq/campaign/personnel/death/AbstractDeathTest.java b/MekHQ/unittests/mekhq/campaign/personnel/death/AbstractDeathTest.java index 5fecc7eca6..b1544dcfb6 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/death/AbstractDeathTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/death/AbstractDeathTest.java @@ -19,7 +19,7 @@ package mekhq.campaign.personnel.death; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.enums.AgeGroup; import mekhq.campaign.personnel.enums.PersonnelStatus; @@ -37,7 +37,10 @@ import java.util.HashMap; import java.util.Map; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; @@ -144,7 +147,7 @@ public void testCanDie() { when(mockPerson.getStatus()).thenReturn(PersonnelStatus.ACTIVE); when(mockPerson.isImmortal()).thenReturn(true); assertNotNull(mockDeath.canDie(mockPerson, AgeGroup.ADULT, true)); - + // Age Group must be enabled when(mockPerson.isImmortal()).thenReturn(false); assertNotNull(mockDeath.canDie(mockPerson, AgeGroup.CHILD, true)); diff --git a/MekHQ/unittests/mekhq/campaign/personnel/death/AgeRangeRandomDeathTest.java b/MekHQ/unittests/mekhq/campaign/personnel/death/AgeRangeRandomDeathTest.java index bf4b1c288a..650ef614f1 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/death/AgeRangeRandomDeathTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/death/AgeRangeRandomDeathTest.java @@ -20,7 +20,7 @@ import megamek.common.Compute; import megamek.common.enums.Gender; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.enums.TenYearAgeRange; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/MekHQ/unittests/mekhq/campaign/personnel/death/DisabledRandomDeathTest.java b/MekHQ/unittests/mekhq/campaign/personnel/death/DisabledRandomDeathTest.java index 09ae70a532..d3e128f6dc 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/death/DisabledRandomDeathTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/death/DisabledRandomDeathTest.java @@ -19,7 +19,7 @@ package mekhq.campaign.personnel.death; import megamek.common.enums.Gender; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/MekHQ/unittests/mekhq/campaign/personnel/death/ExponentialRandomDeathTest.java b/MekHQ/unittests/mekhq/campaign/personnel/death/ExponentialRandomDeathTest.java index 149e23b761..937cda46db 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/death/ExponentialRandomDeathTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/death/ExponentialRandomDeathTest.java @@ -20,7 +20,7 @@ import megamek.common.Compute; import megamek.common.enums.Gender; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/MekHQ/unittests/mekhq/campaign/personnel/death/PercentageRandomDeathTest.java b/MekHQ/unittests/mekhq/campaign/personnel/death/PercentageRandomDeathTest.java index 1096281654..f62502a998 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/death/PercentageRandomDeathTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/death/PercentageRandomDeathTest.java @@ -20,7 +20,7 @@ import megamek.common.Compute; import megamek.common.enums.Gender; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/MekHQ/unittests/mekhq/campaign/personnel/divorce/AbstractDivorceTest.java b/MekHQ/unittests/mekhq/campaign/personnel/divorce/AbstractDivorceTest.java index 773a4198c6..4855321f9f 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/divorce/AbstractDivorceTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/divorce/AbstractDivorceTest.java @@ -19,7 +19,7 @@ package mekhq.campaign.personnel.divorce; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.enums.PrisonerStatus; import org.junit.jupiter.api.BeforeEach; diff --git a/MekHQ/unittests/mekhq/campaign/personnel/divorce/DisabledRandomDivorceTest.java b/MekHQ/unittests/mekhq/campaign/personnel/divorce/DisabledRandomDivorceTest.java index 103c1b7c2d..85cfffc492 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/divorce/DisabledRandomDivorceTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/divorce/DisabledRandomDivorceTest.java @@ -18,7 +18,7 @@ */ package mekhq.campaign.personnel.divorce; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.Person; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/MekHQ/unittests/mekhq/campaign/personnel/divorce/PercentageRandomDivorceTest.java b/MekHQ/unittests/mekhq/campaign/personnel/divorce/PercentageRandomDivorceTest.java index 15b7e0da1d..503617eb80 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/divorce/PercentageRandomDivorceTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/divorce/PercentageRandomDivorceTest.java @@ -19,7 +19,7 @@ package mekhq.campaign.personnel.divorce; import megamek.common.Compute; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.Person; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/MekHQ/unittests/mekhq/campaign/personnel/enums/MergingSurnameStyleTest.java b/MekHQ/unittests/mekhq/campaign/personnel/enums/MergingSurnameStyleTest.java index 8a2cd23d59..d13a7c5ca5 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/enums/MergingSurnameStyleTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/enums/MergingSurnameStyleTest.java @@ -18,6 +18,24 @@ */ package mekhq.campaign.personnel.enums; +import megamek.client.generator.RandomNameGenerator; +import megamek.common.enums.Gender; +import megamek.common.util.weightedMaps.WeightedIntMap; +import mekhq.MekHQ; +import mekhq.campaign.Campaign; +import mekhq.campaign.campaignOptions.CampaignOptions; +import mekhq.campaign.personnel.Person; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.time.LocalDate; +import java.util.HashMap; +import java.util.Map; +import java.util.ResourceBundle; + import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -27,25 +45,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import java.time.LocalDate; -import java.util.HashMap; -import java.util.Map; -import java.util.ResourceBundle; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import megamek.client.generator.RandomNameGenerator; -import megamek.common.enums.Gender; -import megamek.common.util.weightedMaps.WeightedIntMap; -import mekhq.MekHQ; -import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; -import mekhq.campaign.personnel.Person; - @ExtendWith(value = MockitoExtension.class) class MergingSurnameStyleTest { // region Variable Declarations diff --git a/MekHQ/unittests/mekhq/campaign/personnel/enums/RandomDeathMethodTest.java b/MekHQ/unittests/mekhq/campaign/personnel/enums/RandomDeathMethodTest.java index 52c2693324..855c140a98 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/enums/RandomDeathMethodTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/enums/RandomDeathMethodTest.java @@ -19,7 +19,7 @@ package mekhq.campaign.personnel.enums; import mekhq.MekHQ; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.death.AgeRangeRandomDeath; import mekhq.campaign.personnel.death.DisabledRandomDeath; import mekhq.campaign.personnel.death.ExponentialRandomDeath; diff --git a/MekHQ/unittests/mekhq/campaign/personnel/enums/RandomDivorceMethodTest.java b/MekHQ/unittests/mekhq/campaign/personnel/enums/RandomDivorceMethodTest.java index f4fa738809..dbba5f23f2 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/enums/RandomDivorceMethodTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/enums/RandomDivorceMethodTest.java @@ -19,7 +19,7 @@ package mekhq.campaign.personnel.enums; import mekhq.MekHQ; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.divorce.DisabledRandomDivorce; import mekhq.campaign.personnel.divorce.RandomDivorce; import org.junit.jupiter.api.Test; diff --git a/MekHQ/unittests/mekhq/campaign/personnel/enums/RandomMarriageMethodTest.java b/MekHQ/unittests/mekhq/campaign/personnel/enums/RandomMarriageMethodTest.java index 425bcdf869..873fde3d64 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/enums/RandomMarriageMethodTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/enums/RandomMarriageMethodTest.java @@ -19,7 +19,7 @@ package mekhq.campaign.personnel.enums; import mekhq.MekHQ; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.marriage.DisabledRandomMarriage; import mekhq.campaign.personnel.marriage.RandomMarriage; import org.junit.jupiter.api.Test; diff --git a/MekHQ/unittests/mekhq/campaign/personnel/enums/RandomProcreationMethodTest.java b/MekHQ/unittests/mekhq/campaign/personnel/enums/RandomProcreationMethodTest.java index a3f93be194..2662e123cc 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/enums/RandomProcreationMethodTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/enums/RandomProcreationMethodTest.java @@ -19,7 +19,7 @@ package mekhq.campaign.personnel.enums; import mekhq.MekHQ; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.procreation.DisabledRandomProcreation; import mekhq.campaign.personnel.procreation.RandomProcreation; import org.junit.jupiter.api.Test; diff --git a/MekHQ/unittests/mekhq/campaign/personnel/enums/SplittingSurnameStyleTest.java b/MekHQ/unittests/mekhq/campaign/personnel/enums/SplittingSurnameStyleTest.java index 8fabcc71a1..6faca93fbb 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/enums/SplittingSurnameStyleTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/enums/SplittingSurnameStyleTest.java @@ -22,7 +22,7 @@ import megamek.common.util.weightedMaps.WeightedIntMap; import mekhq.MekHQ; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.Person; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/MekHQ/unittests/mekhq/campaign/personnel/marriage/AbstractMarriageTest.java b/MekHQ/unittests/mekhq/campaign/personnel/marriage/AbstractMarriageTest.java index b2bcd479ab..5730d87279 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/marriage/AbstractMarriageTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/marriage/AbstractMarriageTest.java @@ -20,7 +20,7 @@ import megamek.common.enums.Gender; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.enums.MergingSurnameStyle; import mekhq.campaign.personnel.enums.PersonnelStatus; diff --git a/MekHQ/unittests/mekhq/campaign/personnel/marriage/DisabledRandomMarriageTest.java b/MekHQ/unittests/mekhq/campaign/personnel/marriage/DisabledRandomMarriageTest.java index 499f13de52..2ef97bd832 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/marriage/DisabledRandomMarriageTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/marriage/DisabledRandomMarriageTest.java @@ -18,7 +18,7 @@ */ package mekhq.campaign.personnel.marriage; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.Person; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/MekHQ/unittests/mekhq/campaign/personnel/marriage/PercentageRandomMarriageTest.java b/MekHQ/unittests/mekhq/campaign/personnel/marriage/PercentageRandomMarriageTest.java index 021ae51cba..7a0c243a38 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/marriage/PercentageRandomMarriageTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/marriage/PercentageRandomMarriageTest.java @@ -19,7 +19,7 @@ package mekhq.campaign.personnel.marriage; import megamek.common.Compute; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.Person; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/MekHQ/unittests/mekhq/campaign/personnel/procreation/AbstractProcreationTest.java b/MekHQ/unittests/mekhq/campaign/personnel/procreation/AbstractProcreationTest.java index 7cdafedfae..5d5d5af1c5 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/procreation/AbstractProcreationTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/procreation/AbstractProcreationTest.java @@ -21,7 +21,7 @@ import megamek.common.Compute; import megamek.common.enums.Gender; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.enums.PersonnelStatus; import mekhq.campaign.personnel.enums.PrisonerStatus; diff --git a/MekHQ/unittests/mekhq/campaign/personnel/procreation/DisabledRandomProcreationTest.java b/MekHQ/unittests/mekhq/campaign/personnel/procreation/DisabledRandomProcreationTest.java index 72ce804322..f1f87e6b64 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/procreation/DisabledRandomProcreationTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/procreation/DisabledRandomProcreationTest.java @@ -18,7 +18,7 @@ */ package mekhq.campaign.personnel.procreation; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.Person; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/MekHQ/unittests/mekhq/campaign/personnel/procreation/RandomProcreationTest.java b/MekHQ/unittests/mekhq/campaign/personnel/procreation/RandomProcreationTest.java index b54eb39a98..6c9ee37bed 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/procreation/RandomProcreationTest.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/procreation/RandomProcreationTest.java @@ -19,7 +19,7 @@ package mekhq.campaign.personnel.procreation; import megamek.common.Compute; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.familyTree.Genealogy; import org.junit.jupiter.api.BeforeEach; diff --git a/MekHQ/unittests/mekhq/campaign/rating/FieldManualMercRevDragoonsRatingTest.java b/MekHQ/unittests/mekhq/campaign/rating/FieldManualMercRevDragoonsRatingTest.java index d2e26bd10e..5736a93045 100644 --- a/MekHQ/unittests/mekhq/campaign/rating/FieldManualMercRevDragoonsRatingTest.java +++ b/MekHQ/unittests/mekhq/campaign/rating/FieldManualMercRevDragoonsRatingTest.java @@ -20,35 +20,34 @@ */ package mekhq.campaign.rating; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.ArrayList; -import java.util.List; -import java.util.Vector; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - import megamek.common.*; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; import mekhq.campaign.Hangar; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.Skill; import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.PersonnelRole; import mekhq.campaign.personnel.enums.PersonnelStatus; import mekhq.campaign.unit.Unit; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.ArrayList; +import java.util.List; +import java.util.Vector; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; /** * @author Deric Page (deric (dot) page (at) usa.net) diff --git a/MekHQ/unittests/mekhq/campaign/unit/actions/HirePersonnelUnitActionTest.java b/MekHQ/unittests/mekhq/campaign/unit/actions/HirePersonnelUnitActionTest.java index 17b405ce56..2d4fd01829 100644 --- a/MekHQ/unittests/mekhq/campaign/unit/actions/HirePersonnelUnitActionTest.java +++ b/MekHQ/unittests/mekhq/campaign/unit/actions/HirePersonnelUnitActionTest.java @@ -20,7 +20,7 @@ import megamek.common.*; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.enums.PersonnelRole; import mekhq.campaign.unit.Unit; diff --git a/MekHQ/unittests/mekhq/gui/dialog/nagDialogs/UnableToAffordExpensesNagDialogTest.java b/MekHQ/unittests/mekhq/gui/dialog/nagDialogs/UnableToAffordExpensesNagDialogTest.java index f74dce5be0..4d7d282a8b 100644 --- a/MekHQ/unittests/mekhq/gui/dialog/nagDialogs/UnableToAffordExpensesNagDialogTest.java +++ b/MekHQ/unittests/mekhq/gui/dialog/nagDialogs/UnableToAffordExpensesNagDialogTest.java @@ -19,7 +19,7 @@ package mekhq.gui.dialog.nagDialogs; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.Hangar; import mekhq.campaign.Warehouse; import mekhq.campaign.finances.Finances; @@ -95,4 +95,4 @@ void cannotAffordExpenses() { assertFalse(isUnableToAffordExpenses(campaign)); } -} \ No newline at end of file +} diff --git a/MekHQ/unittests/mekhq/gui/dialog/nagDialogs/UnableToAffordJumpNagDialogTest.java b/MekHQ/unittests/mekhq/gui/dialog/nagDialogs/UnableToAffordJumpNagDialogTest.java index 70cbe2cb4f..d6c4c5a11c 100644 --- a/MekHQ/unittests/mekhq/gui/dialog/nagDialogs/UnableToAffordJumpNagDialogTest.java +++ b/MekHQ/unittests/mekhq/gui/dialog/nagDialogs/UnableToAffordJumpNagDialogTest.java @@ -19,7 +19,7 @@ package mekhq.gui.dialog.nagDialogs; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.finances.Money; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -72,4 +72,4 @@ void cannotAffordNextJump() { assertTrue(isUnableToAffordNextJump(campaign)); } -} \ No newline at end of file +} diff --git a/MekHQ/unittests/mekhq/gui/dialog/nagDialogs/UnresolvedStratConContactsNagDialogTest.java b/MekHQ/unittests/mekhq/gui/dialog/nagDialogs/UnresolvedStratConContactsNagDialogTest.java index b62254caf8..2a34a21335 100644 --- a/MekHQ/unittests/mekhq/gui/dialog/nagDialogs/UnresolvedStratConContactsNagDialogTest.java +++ b/MekHQ/unittests/mekhq/gui/dialog/nagDialogs/UnresolvedStratConContactsNagDialogTest.java @@ -19,7 +19,7 @@ package mekhq.gui.dialog.nagDialogs; import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.mission.AtBContract; import mekhq.campaign.stratcon.StratconCampaignState; import mekhq.campaign.stratcon.StratconCoords; @@ -147,4 +147,4 @@ void scenarioDue() { assertEquals("Scenario Due, Test Track\n", nagUnresolvedContacts(campaign)); } -} \ No newline at end of file +} From 3532c96736bdec365555e24a088753060c3a306a Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Sun, 29 Sep 2024 18:31:20 -0500 Subject: [PATCH 004/117] Add new empty classes for campaign options panes Created 20 new empty classes under the campaignOptions and campaignOptions.panes packages. These classes will serve as placeholders for future implementation of various campaign option functionalities. --- .../campaignOptions/campaignOptionsDialogController.java | 4 ++++ .../src/mekhq/gui/panes/campaignOptions/panes/Experience.java | 4 ++++ MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Finances.java | 4 ++++ MekHQ/src/mekhq/gui/panes/campaignOptions/panes/General.java | 4 ++++ .../src/mekhq/gui/panes/campaignOptions/panes/LifePaths.java | 4 ++++ MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Markets.java | 4 ++++ .../src/mekhq/gui/panes/campaignOptions/panes/Mercenary.java | 4 ++++ .../campaignOptions/panes/NameAndPortraitGeneration.java | 4 ++++ .../src/mekhq/gui/panes/campaignOptions/panes/Personnel.java | 4 ++++ .../panes/campaignOptions/panes/RandomAssignmentTables.java | 4 ++++ .../mekhq/gui/panes/campaignOptions/panes/RankSystems.java | 4 ++++ .../gui/panes/campaignOptions/panes/RepairAndMaintenance.java | 4 ++++ MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Rulesets.java | 4 ++++ MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SPAs.java | 4 ++++ .../gui/panes/campaignOptions/panes/SkillRandomization.java | 4 ++++ MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Skills.java | 4 ++++ .../panes/campaignOptions/panes/SuppliesAndAcquisition.java | 4 ++++ .../src/mekhq/gui/panes/campaignOptions/panes/TechLimits.java | 4 ++++ .../gui/panes/campaignOptions/panes/TurnoverAndRetention.java | 4 ++++ 19 files changed, 76 insertions(+) create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/campaignOptionsDialogController.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Experience.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Finances.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/General.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/LifePaths.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Markets.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Mercenary.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/NameAndPortraitGeneration.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Personnel.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RandomAssignmentTables.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RankSystems.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RepairAndMaintenance.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Rulesets.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SPAs.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SkillRandomization.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Skills.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SuppliesAndAcquisition.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/TechLimits.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/TurnoverAndRetention.java diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/campaignOptionsDialogController.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/campaignOptionsDialogController.java new file mode 100644 index 0000000000..b53cb5522d --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/campaignOptionsDialogController.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions; + +public class campaignOptionsDialogController { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Experience.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Experience.java new file mode 100644 index 0000000000..20915fef5d --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Experience.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.panes; + +public class Experience { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Finances.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Finances.java new file mode 100644 index 0000000000..416354dc5a --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Finances.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.panes; + +public class Finances { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/General.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/General.java new file mode 100644 index 0000000000..cabea3930f --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/General.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.panes; + +public class General { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/LifePaths.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/LifePaths.java new file mode 100644 index 0000000000..85a3341a04 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/LifePaths.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.panes; + +public class LifePaths { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Markets.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Markets.java new file mode 100644 index 0000000000..bb233047f3 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Markets.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.panes; + +public class Markets { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Mercenary.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Mercenary.java new file mode 100644 index 0000000000..be52b82fdd --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Mercenary.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.panes; + +public class Mercenary { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/NameAndPortraitGeneration.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/NameAndPortraitGeneration.java new file mode 100644 index 0000000000..be1fe0f447 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/NameAndPortraitGeneration.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.panes; + +public class NameAndPortraitGeneration { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Personnel.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Personnel.java new file mode 100644 index 0000000000..00945dfc3a --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Personnel.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.panes; + +public class Personnel { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RandomAssignmentTables.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RandomAssignmentTables.java new file mode 100644 index 0000000000..32eec20c88 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RandomAssignmentTables.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.panes; + +public class RandomAssignmentTables { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RankSystems.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RankSystems.java new file mode 100644 index 0000000000..cf5d2d84bd --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RankSystems.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.panes; + +public class RankSystems { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RepairAndMaintenance.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RepairAndMaintenance.java new file mode 100644 index 0000000000..e3dacee96b --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RepairAndMaintenance.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.panes; + +public class RepairAndMaintenance { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Rulesets.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Rulesets.java new file mode 100644 index 0000000000..86f38918af --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Rulesets.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.panes; + +public class Rulesets { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SPAs.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SPAs.java new file mode 100644 index 0000000000..57d7565004 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SPAs.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.panes; + +public class SPAs { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SkillRandomization.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SkillRandomization.java new file mode 100644 index 0000000000..3c7fbe381a --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SkillRandomization.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.panes; + +public class SkillRandomization { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Skills.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Skills.java new file mode 100644 index 0000000000..74d69ab1a2 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Skills.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.panes; + +public class Skills { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SuppliesAndAcquisition.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SuppliesAndAcquisition.java new file mode 100644 index 0000000000..b42c9d3785 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SuppliesAndAcquisition.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.panes; + +public class SuppliesAndAcquisition { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/TechLimits.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/TechLimits.java new file mode 100644 index 0000000000..365ba2bac3 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/TechLimits.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.panes; + +public class TechLimits { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/TurnoverAndRetention.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/TurnoverAndRetention.java new file mode 100644 index 0000000000..62107f73da --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/TurnoverAndRetention.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.panes; + +public class TurnoverAndRetention { +} From fdc6335630db18f2d0c869315f4258d3420ae7e5 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Sun, 29 Sep 2024 22:50:15 -0500 Subject: [PATCH 005/117] Rename controller and add GeneralTab class Renamed `campaignOptionsDialogController.java` to `CampaignOptionsDialogController.java` and implemented `CampaignOptionsDialogController` with added functionalities. Included new `GeneralTab` class for campaign's general settings and updated resources for localization. --- MekHQ/data/images/misc/MekHQ.png | Bin 0 -> 26635 bytes .../NEWCampaignOptionsDialog.properties | 22 ++ .../CampaignOptionsDialogController.java | 233 +++++++++++++ .../campaignOptionsDialogController.java | 4 - .../panes/campaignOptions/panes/General.java | 4 - .../campaignOptions/panes/GeneralTab.java | 309 ++++++++++++++++++ 6 files changed, 564 insertions(+), 8 deletions(-) create mode 100644 MekHQ/data/images/misc/MekHQ.png create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsDialogController.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/campaignOptionsDialogController.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/General.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/GeneralTab.java diff --git a/MekHQ/data/images/misc/MekHQ.png b/MekHQ/data/images/misc/MekHQ.png new file mode 100644 index 0000000000000000000000000000000000000000..e3fe50fe9b98a6994be1bf3a53c7b87ab782212f GIT binary patch literal 26635 zcmV)aK&roqP)R35*rc_>h0Jk92OxK6CfB99~TiN8x$)Z7#$T6 zBN-GsG%P6{6*n&?JU1>hEhQxy7CSmMKRGZmDkALf*)J(0G9w#AJTf;ZA2%^6KRPon zAsB#wfD8!;FDxf1BOY;TU=R)tA{r7_P(?H)9h#AbWnWcvZDIog0!2SHK|M8IS4&w` zOE)wvCLkK1oti{NL^?4kD<&a8HY_4yT{tWvR82vho0(BcKct|Y zT2n`2T1|{AVNKjZrOjB=V zSafr7dU|*#CL^Sqk2W|tP(m|qY-np~W1*g%IX^;pb8J~lJ4;nwv#FgvKtNz#SEZhm zw6U;3M@>aFC_O|-tDux=U{tiNqL7ApOifH~Z*EOmXj4>Dyt1f7Dj^gR4U&z8O)(|H zxUFJ9FlA$d>C}RAV32ZI;pEYqig<-(O3%^2w6>>lOE-I3L2P+|lz?l%pL)^6wv(Wz z*381KjcuTOT3c{~e2taQu!-EjoAKSRskp(n#moKq)9CB(R;T}30000ObW%=J0QH3F z#044+#0}U#Dr}rqvf($ojbWJGHqf9Vt380)U zpD(^6E0;x~Q=5Pj;~x+Q85-Fhit@{INiDNr$Rat+QPm~$?6k4!Yz@(b@m6=6?AWQ= zG|dVVQhszOkf5-zKv5&{$3{S@Knj{7G->>`=Y8M1^BwA+jV(?7Cib1}i*uj%dG7f> z?|aWZS5QF(6;x0`1r=0KK?N05P(cO#|7lB6UbH3O+(kQf@BVfkR9sxVeOq4Xi*|qh z#p{3l?WtVr+@Gs%pWeLb`8=ZUe*KHje|@f_D(4y>zkQ+FvMGP$J5Ig(iO^(P=52XP_u^B37`J`8yj+ueEiW%yN=kl^uaw`_acpTihkR>s zOUJ!Wt4s2!7q;dFeP>6@^}p0u@`|3HO1I<1mfz2x$uD_H$#=e+hbC@kN5}0GHTgy_ z`CiT&n=L!4TE=b5c_+_Z)=`8{Oi6* zVJbN{xLs8(pG=8Cuhw!jO{-KCMX6|-!eZeEo>>;ZO{rAyi57|DH9W_0v=*LfYhee! z&9EwlQK6%>u%Y2#I-RER7JW1N0KSBw$!oc-ShnZb*j{X@TKJCu80_$@Skf?T=0pJ%Q}mX*m2Axbb?CD+0h=WqQs$r%b8OgLMzZ|G{o?`m?wkV zB{#NeiWS1A6|P813_5J!oddjzK#SE50xxhg2!`W?5-DT_`k0no=A_`^4B+sw=m1Kd z^0{l}v9XEGyJeAOC3bXv8d|^*(9;B+lCy|lsNiFXzCfwu0TMucEDz=zmb5gwBt5Yt$IN~d-B%;92X7?B)09Edyeb{IZ}uqwz^ zqP3x6!#@~Z+1G5!gRuc3qm{}QL(8so3cbKhj#^4(vFlT-fs-NZDC2Qo1JaTXPF5J; z(#WExTk+tL4=g!uM<0zrIA@z#Wv>koJZ*>h?4OXAQ z-`_QK=%u{}c+wCF?5K^Ug+ea1G$K0Bx9NC-4hJa=E(fi=vU$h8q($8*gCb7zIy%cP zGkJ=yd}+u(oqBWT+6~aPYu9cpE#0^_`R+h(-0N!mQ7gxYQ5Vq_?oWwPC&Fce=j4@c z;|;DzzA9x=p>7jSv=%BfDZv~qro7bE@RhH0bzVCE&YL%X_NSXS<3YRK9})i=Dg&GXaf8(bH{sE5B22Y&9AIozB`1 zykN5A{QmO5z3%Iuq%K~(bg3Kt>dhW^$Q_CVL5>*KC=9_&uVbWX53iESI4X8Lk1@qE zDHV8>8Gv4?$>j`AX>1xY{p84mggl|GknyTxee?J3-CJ1boSq&AZhb1{)tkb4XEbVx zM#CdXyW0+t&t!mn;$}P^4CxIOP{G@Hfl%z?vX-CbII+8dsPl?Sx4{OdFt)`u4bKx= zt`tNzLfF|O^|pnD`K~~q%Q`(g+}%AK4Li+xcz8`wf57iEx#xmzeZ(HJ+e4v8sm6gVmGT5w11cp#QP&V@DyI z(n@e?xkEPVfxdvvmBC?S6IZ25)EJfkYs$*XM0QBYV?*=v{apyW3z0**JN0IBD&+Ne zy_cQ-!9bV4-;|65=R6)`+?|XVCnjcQGDgQ}%x&uI9yMOAAX8R`%;yyBsBt3ck47L@ z2KS7yp=Lygv_?nBQ3`O}p8om%{y-qnmk9Vf2Yu7dv9Z-)A+M z>P%smVPqs6%VaXZJ^>q}G1=c3cHEfgX;tCr`?KiTx5y+hM>Dvs#Vu7?W1}F~5jqJr z2|B*&5478CLxDu156I_zoqpd~^9Oa!&2^o_gFdUF(PirCxpU{v-Me?|uIly8<_BY$ z3F31DNHcRIVP|Z8J!8-aGaebNO4&0YE#}1F(Crp!RjL|cVsZ`1cp>U-4O4vxyRW=& zC}0bqtnWJf%eUTo|G2)}WO7jKsKR!rJJI$93Un1_uj~+dG{Mcm<2E9FZR>tPs$>hqHXh?3YtlYi7I@Sa1 zPoK_y$P1BXg+*RUS^^V8&$5ac+{Ua`ZBeXBEplRYL#a--Wo4~XA5E1f8tNN>x#7hA z`lCPA?K`;d;P3u^uCo7Ly{by{5}aIVlh@ll7-nCXq#!}@qoe>~i69*vkiNcW+;pX;5S zeK>NpscvLqa%ug^WTUhS&!LKrVTCnJ0i9Xg;F~eX*s`lqrKGA0*oa)W$JSSQ>|{BR zx9{JN2B0C4NCa?8;|KgspJCADYH~TfAwci#bwun=ue-;Uj5)k!W8Ca^d)#PZ3h*1-$}4ZTuu>l*kn36xA3FJVdpRm_?d|R5 zh2%cNq*-jPgi2pU=v^nrodjD4)G zM?W_^FuU|*sfPnbm9(sh&>5C22vTGqlxtO6zj2gAjs$4l-^q|BLayN+jVASjh0lYKpa+&n{u&cS*(CCcJ#bOVQ#u4wpBy_UL5wj-- z_BJySGe_&f$qab?lP61IPPUv2+>C%OtOzoSn=zJe+TfI{QjCa>BCk7m@YVm(YQC{) z+-Dqrl}&xI7kit?#la-8!I9O3N%#c2qs8E*D!sd;E|$X>{|;@q_!@|)+W0JX;6Q~V zST-3h67nRlIMuFZP&->bdcr0kMW~kFOv@CkNUJ9GUFG=2G_BH}-$6Z-w`xg6!Ef13b9;no&IQ+ZZ+ga^W@~%JlBUl^0EzIcy(gTx&Et^qLCWA_?Okc zxNSe$&F5>iTK+olW;~uiz+eaj;D4BEvS4g@#Tha|%+n0na+$GppNN7RMtF0ILiU`C zN4WQ4mTPx9hskzZYP7Jp&B`xkXXm z;vCL6OY-}T=3xie+lTFTlEco4P+dEAbwJdCuuL?{&WvQ8rCed88UmN{}AEBScD9&5oImxDS- zu9HIPK$bfvos*MJvMtGStVo-n!F5g!<%-m(#AY-j=XGSR{Pbx@XtxC}DXdS;%r=gXn-aQX$_Fcc#lNakxmBf{ z^Sk$Z)!N@*NrQVyZUL8HRI7)2Lk;BlK9GayEVhi@RW~58G1n5FK$j4%mAV`|CZW zPV@Q?;LFP&ypmg0zuYo1tTH0>p`jjmeSdo!svMAeG9GsT+-~r6ejF%&L{xPS@LNvDlVofG*V@Fu0=j;S=qN$6_bK1|}A zRdpU|7CmmHTqxIj)tcMA=I^^z4XVNQH?|9au2B}Y%Rp}1-QC>YN91{(&XdWw4an=u z(BXi+5R4XdfowRMV6W@HT6{YZnK7jqyk(BlB^S@Td_Eqsy-1^>Uc@QvzT9bkdH{Zx zpLRMY?J_nsbF0`&cG@WBo1DlcRHx_{wO!Rl<6p~ExBM#b{orp^FUc*cVN}|+T0mE; z$2Oj9)c0%K+qIfqaXJ)tcff$qA={(D!qVuNUVmjg93AyqE-hNEj#(_{iW8WNbU{}y z6(QMupSKWtjw|t8k}EyxbdF`Hbx_`zS(Axw9Cq50B(B_yWVEEjoB=h^p>#q zlKzdiLQL98lNdpiAijNA#B7F$C*v)gLJJME%Hi-|r6I|v$2DkgU?maZ{I-Vbs*1IZI*y1<6btvYk6yH za&2vLB4Eqv?Y4kTueY#^CU16hG(qxAkx3K8DplqL^TSe+j0vuI4Be;7m7NlY488

UPN@D@f6PxX@ce{ zjuXBhFdx)-7oEbNb2ulvzQoIA4n=@~C#7aXB+U-T6sqx}ki#p0U(QuReg$2tou16p z_dU1OmxnGQomR2FTh-47(%3#Y-Pn}EdU5FXRYt?+y!RcM^eBJ)zD&8(5Kz?{mj^$8eM{sJP(dH8b=1%;Lf4O<~e;p zPNnIlIqGeBDDM0DD%gA`Z=aYz4xd~`0S~_c7-wpQgw-2dgnE~?%vi!!uij#Hh6uu$ zHm5}DAeQ3Aa+zwSXcB*p&{Gc&%J|MokTtPv&`HB?>mnRe>rmv#G;L;leZXK)u`5~QKd%-ukjD^xvD<7<;@ZFlxNR8;PUFcLhhc2;eA<&b;Fe_V}Zcf zm`&N%Zv@$})pA`|U`NNipq{fP4o#aH}&%b$Bj{TAFPfyg3YS*t`?amfMiZkXE1*|XRe_Vs>lUv^W z8j-8j>SNy?${mcjJ?rL z|A(z?}1KX zkAB5Qvuq;4vQcD~pfh4FF+QI3F)jfIw@Xc_=sHFJ&v!fg4i$*nRdl zgkH_Kp}AV@RS$T5;@Y)4JNHZXckV9iJ<#iv`&2Yxjl$xBxYGnAxd6R-vYob@edZ8W-y%tH)Rr3z=AudyoVzF%ZLT4RI5!ZUh^)_#_X?WywN0 z`rx43Ev5IM2mO3!%;w_5>`2n1e!e!V|GCZ9i`brIJ2pD#5U`{q&lzHU<>Q`L>1 z{`+tL_~tQ`y2TqJ`k-`IEuCWBlyuh1@8qtkZ`~rsl!QL~s?qrZ$SZ5}9`JVqs2MQ2 zYicU^?DI$lpIP{`QbK={i$Z*xmZQ1oayWRv=Fz4d2fOb@4l)d&*XtxlQ$EI)5H_7o z%BTZ}&*%BP?tstCzWGvPxAS#jiN*^;D)rY-fBma(PQS7}O9+nh6KPS%N$eo6Ei&2Y zcd?A=Tepbh78L7quD`r$Hum>B`+)97=pbi2ZkOxsRCwl5c>3YO!taz4IhZ|~TMmYo zmxCq~8_A%mjuy^-B0_E0(&cJOOVNuwM^O}S1QRCge;L!aZW%nU=yR?q>#It$)@W>X zn&9xy*PbX;ZWQXSyK_0UHn()Ig%Z5Y7*_d6UDW$j=P9zGcdU@}YkN))A!=$c|+8h{q zN8Urf0qzd<=hA`A)s``r*DWu_Br2gRfEg5QWq-f6>&`Zx6y>TFK*wBDt|c z`r{ciibqyA%Zoksa4=8PB0Sg~&qMcC(2{%%PbSJF8Bfqgf5Mh*Gt5SW0qgx_R!*cSCH~Q=$}gUq{A)6R&5K~mgZKcvAgTZRsh}X zUU7Rcm+H>korgh|9sUrZiyIho0F#Ra9&Mn)8J1-M9?oh6c~`9H3ideVOhm z1rCY#i^4W^uHFY!ThD9zl}e*osnm8oSgq158qC=h@OW_eIhQwR%1wW`AUV839>B1k zs71w%WlaE2BX(S@?(3V|b}pGNl>HjbIv~YMM=g96!2KJ3f@#skJ3Y1{Z|;i22%u!{2;>eA0rpU@zZmR@FC^8XCOWyCZmBnFm*|tnIFWkah1? z8a0IO-ho)3yE`?fx;;JpF`!FEw*~^(NWf|^Na4=1!Jvr+v-4o}4IksDaNfZ)$poWu z@M+Mt(7GN*@~8k1ew;mPrTv86?(4SB&TK)=?4r&O%^R6`nqKA8f>C-?3e71edpFiS zv(L%iN6PoDThJXW^oj$wZcS{}b~{klYVIs@_hz$JE2;r~Wk*Dxx-&98JbZgxDP}n< zYU8o-fEAg2NjxJ913Rrl#hqC9a~#FT7D3;bLbJYvh+aC>;;fG2BQ(ux&up87#_mVx zXKBjmBuJ0}+CoyB$S2E`W$^s8d{C6M52QRdA(Q>&hwstB^}XGKj-LVDa_dI6vRmuy zcRCG^+mqd`0r~Ts8qFhjRsE}5z2CLPq@PNl-(84}3fZ4yLd=dPLpNmX%9;_f-nMl3eZWR-GGD&C&mq;<#o$-^v}_7#A313n!6Q*-l;U9z%@m5MRp$0cOc#sYip9DqjjU%>aluM zszBhL3fRHtqstFbbvI>bp5wR(YR@>`BL`)SDUIt)j~#lrR4U%>9@n+?RvV#H-8!H{ zeuF>N>q4QtipIBP-^kF9uJzt0I7c5Hu#Cz^Ed#P^SAGYuZ{2c1jx}m)9fS@tb{}+2 z4WTOmJ-Y(v*)>$dpIFg&5(8!^Z4l^DwP<%kQNOeVI$nx)Is?Y%d7jpfg<@lJr_bj@ z>;f9t9HzA0)6?U4szv&V*$^E+DxFnZt+L;yZ5_u8<>XT>Nvtv>(o26g-#udSMV5!3 z53ab3>07s4kWXZrwdM&T{{oRCqXW7Xji|um-5#r1+_GXSk=<&=0>zwFoihYfBUZIq zE|(k7i6|Ieqk*r$NiXVVl}i2am?lQ~e4^b+E$ZjAZ{MDFOGif~W^*>SNX6?w&hWg` z=v*g-PoE~Wqz_NJ#A{LUwV{dgQ(bYAf<7j%IIFs}Zuy`W=kVNH0V%UDqDwYkL+C|7 z2ea>dwt{{80fS=!Yc6NCDx$f7N;NK*o5$q_z1OSP8w~J!DHLQ&8!N zbsMC*QmS5kd-}FpI_}onj4`yx5!ItO&e^nN8rS)giS#N-3i#7u>7@ZtYF$`fn%u~+ z-(01@egAS{`!TeJ4+aqV#7gs@TeXvuEeQ23@O%Ug3Epc)==1K+Ca{1Ajb`v>d0-sF z%!+6fZJUb*7oaQUO0_}cj(O!v4u@ve$Spn^kuPN^isLB?*YRmo+*_%`E(Ck2dwNXT z{y4UXJMqLekv>Bs>8jR;@A(Ci+}vYDa)hq3jGmupk4h7IPr!1O0@t^05eEV{!0Hnd z?vwv@D*rv%hq~Tet4aRe1TlwVeLjobgW3+%9?$&ze2!I*i`PV6g+dLmBXamCE_s)L zd`z#QV;NQhWsdhdr}d!Jc+}DPH+5-2&{pe5_0;k4QS0a^)h0qS_7|Fvb6o(RZ=uOX zoS|r2Tj1zb8S;0O+XAxDckBp#0#gkPT))CHrf=Ocd2_Po@H@L-e_c5N^etd+HqX&} zR?p6h%}9k$ckypNe>pDM5Qtp0yW&h9mhH4Wf* z`!_5sHpjFYjfzQ~vd(O*aT7lm_Fc$i-R`~qY#B~0)+v>6v@ZKOjblzaM@OO0 zIZ^6xG%6LcKbl&a_ai$W(EAIM#rWen>S2Ph3*L4PF9zjst_-hl+gxjWDj7KF_1bL+ zZt%ao)x1!v1p>@-UN&{vu?;I^bPzc`ilZ^bjcX5Mz8bd-_1Rr?_-rfu=Ijh7jLl~A z@X%c@#X4QxbOg}>+q_~l8i}c!S?S4B8QnwJ=Tz{5K3?TSc4`UG=lvFl@kRY2l(O-M zkLMoqSw|j+EZYG6`t|l}ME@xj_1|x`Qro>YM7VkzT;M7v)VNkwU^2ru&i&dj{E^XJ zX0z*jBB=h;HHR@6*bcw{64)SNdNA}r36755JBvu5?{Bbn`TODF3mwQB@-|AsVjU-q zD=cf2ogCyd%YB8{=>T0rO;h0Eow#J6(&*>LmzEY5{T55SNIkOie35_luvjeEEA1UL z=-0h%IAHB>-?jzI{T76`-VUTRfS#*+gdPe3DuRwf2>2qzY=o7sOCtKM>jgN{ zmAW);0rKxjScjVJ*iAc+jv%Zx_nL?9P6sr+6z;xQCfMN!+jD7fW62hiuPH^U~#v`>V@R3y;BF1?{OBC`fEsL z5q&3Dw*t3Ku-USl<%ZlZ96cXJxXfX?AK7tj`Fg{cfvyw;HY^5R51=$qD#|Azbs77x zAoX3W+rY1ffu3r4001BWNklo9Vr=RO7>w0B0?Bn-D0n1K;WN0d^m+7#_EL%77X87y@yi&Y5V;tJd}D53ih<%+pk5L zf-e)iMVe+r(8DZRxnlH!T>aG@z;6V&!N7KN=q9Pt$*Nd+7anc%4d(84f2Q zFp({lI!YH4A9(Lbx73ouo& zFl))?tvG2v{q*7VA1Nr^5?mczURy{mqQa*W$zmXB&DGbv`KXT zcPF=9ukKs+Td7>e<}2_H+fKc*o))vSwQ9jp%*+qr*a@g5R z5Zxq8U2-}lqY1>W0+)|sxA@1G0?FCgEH2VjI4Io^{eX*d)kLDwM)ag*f8UzRycBH= z^Qvx5uOHZa_8JpscwrJNbtMUDiZ6E)02~j>U47MF)nM{Iq!?Aoi;;lNo=EUUB{1}@ zW}^Ww%|^3RxxCMO&>J!o{-EI)Nvi#;`4|}m#xHX!am!w|qqL~A_ zP8ajY=rIrOkV(KUX(dTUmmsuDl7`Y~am5DM$MrLsA9%4QR-=MY5xCXWUq1nQJ>?Z_ zOy0Yi^40)7>CJHki2H~htuk4k-Oh_b!X}1*+$EVu`{}#9ppWQx3A#GCcBKF}*p=ikjwCn$4`7j;cLGn{ga{?trj@m z6^_v7M%llEh3I$hqS)`;F{#EbH!c4BKLXrfS4wdi-P~Z&Zq(q|w;Ef3z6I#u=F6RM zS5|nrJGW-m>A=II{8z#oQ;Z>6@sIF(GMdjcPiJABdhs*wNfmlh8;Qq5$AS7o#EGP$yE>@vGS z1^hpMvsX13*uI1J2!X=L?A9Q@qTF`!dW!R&%x+dG_g#&E{GvbMIdW`>6l zi-||k+ZRgU3 z`%t-Y^;eT|-T}6ruZgXHwtV)iP2`y8e>F`^{1>4UW4}9Q&;>#A%5Mg^!K>*QD?=nU z0=v1%5_I~cxp{mnOI@?O3)WtO%FQW}ay<;_D`8M~0NyaKY@p0n=m+uvcp`omX?eI@ zp&-txgTc@+C_e-`YPRL`*+feqD&!AV0o}XP>*eZD$ap7J>DA!5Hh=OjOTE5Ho~wh8(1Dach-SFSzo_x#6~#e`wv)};>*Am|X$ z5&iaUYA!?qy!!vA@`K}+Kd9x$r$%%|tVxsmi~r{9{9n_^(>Mu+VrZ~MaVDoUEW1p9;U{Ok4IPG+@k}O6HUZcbiIZ|U83*@GEbjKz-0|9+o8tvR zktNFJPp8xV6cq3GCo#!0||zP@k@UDvvB7<`@4 zB%VR9Hvl_Ds~jgulJ+ZK+9`>pK;9e3(E_XRiX`W9xfGw{#2PsKqut#lQS^2ni0beH z($L#+cCeSBieM~y~SP@Clb(2NAH?Y%{0mWL!;TKbf7ndVr6@} zUBTpr=z9ck57pi^2GF>~GkZ~sbk~3%UOGHMPe2E>BC|*Du$;jlZ=ReqJNrxhZ6VH~5rn~)Lg1*9ZXFpEdnuM9MP3@uLbI)*rmh+%SUY|>y5Yz7S- z$PqlH06a?>m6Q~4i=}Qiu7cJ5hd=aqe?d~XfNw6gG%_OaZ!&TN>3H76%FPgx!1hY3nA!yq}TU(TKFN|Bv#N#1*kvUkHo!!7r6`652M1+`01w1uUWE)7<75>~p92?A^Z7Xb3(r$@?+_=5vKe`n^(NJ&z{saV zX|p8I%s@)56J%?DM5EDj?_H}pyDCMLGJ#%$L1Oo7eSjA0N6n+x?MsIzczOy~D>U@1 zE3AXN!0g&(031#;mN$gm1l<~Kx7$(3o-5Cv^F}I5R;Gg#&8w7&Rg{#PlOUz%JkmZ}x7gDV8#rz(tG{pF?zgVS)rTcs3$aA%o8R?Afy@ z8H?68?@4eU|LXHo+b!quczwd6)&CYD6t!yT3CBnlOx|p?D$uj_u!0BhPN!I;vf=Qw zlW1IcRoiWZlHR!*c0xQeq-Dtl(dN*hr`OXw*oy_bnTV=6okliCnP^2({+&{xb^*VZ zpqa^JGS#_~w_KKElDLUiK<`gwcK-v3Pf~d!NTE>>A_e);sAD*Yi-W17A$yVtOjD4YZDU(8wYQ1J&6Ux5(imc;Xx5-nJYXBoJQAuJe`gLHlRm= ze3`re-TJ%#J2?FDZ@%9h7Vqcv#jOO92`aP*AJzBx@uSxrTy_TTdQ&%gXMcLt<#Jw{ z$Njb$vh_l^aU+H?7z~V)(R7WV`|aSYCI$;xT(W`=--PJPCK|+C;#DqQ^7-6S60ZYI z+^v?9rBW^ynA*V8!+-kwL|G2_%2G;UX%^x{x*jVmahj_;EPA&F?2&tmXz?fkk1XRr z^r+=Cak7{MEN#e06o>;J__O<=9Hvuduu~DNBLCbxB*2 zAb*I_pIKM@@P(~9`SPns9~{Qz%L{{t`J=~w^xMlnel~dA%%|9RW8+!|(8cTA4Li$M52|ji z5P{zGu~m0U3rd_2609C;A05fj==fTWopChjE`7v_0HEJ(UeQNj`T1It<9@tesVI>O(>3qZ_nn zfXc>hn@kT^V$^DHBi!CU*V+EovIk% zmMxygkM-|H#68-h|Hsz(hqTe(ahz>D&jw>Z{vTs7mR-aPawc>&jn| zY)+`6j1JSgG#JW7nl`egtX`eojr`h~5ANzx_KYZ{<>KYm_ zt$!G>LfPm0O={!wJYO|}Vsfv0e|~>2XSIYu=x;SgpByEBvb1tizEtY?Z`YQ$UsOy7 z{W+LUW91Ca!SmxBR z;C>7()Q*sdn?OqF55<^`Y1iGf`%mU3Oo7!2YnTp8&k(dMH=XEZ>&+Hes!@6foT9~$uX6#63v)V2yAu+rL{m!H_gz%z%_Mipa6%-YAlvq9T8;nZTV)YQFp9TG@Zm zj(NRPdiP27@0A7GbNBg^{L13W)2*%5kC(q(UEP{TR)6nvq>fAS<>EEG!l6uh|GOHvbFKcy*(5LeMWhT`goI^+-rTtQq! zWgq9@C^V#iu2m6X*|$S$@T!6grK~7P`TX8sm{n*OpwEl~x)czk34lI_uqP(GQNM4Q zM7UThgpBz?{0M4}?$q4%xOOW0!`evq6NFBjH@V$aa7c-fM09;U6B7hp93FN$E&Y~4 z(HRPD?XHEE2XyW27wYSw0goLWA03tpFRs`H8ck^x&uG9b(IP9diYi!LSy%I@0?FSh zsDKQ?Z4N2!&uD8*HHmvqtlfbWSK)=mY9?@}-U4XSCd&h5%kB$ytmG__gH{*4K=Q?oh=H@6yrPNd+ zl1Qb~@f<8EDdm#Mc#Ky$J;gCH=&fo3FK9|o5Cb>=er?)3Gcz;20RC;2T-iV%D~fzj zrKMQXHL6)%)<7J~jf~w3-leSgBK}Izig-D1RdNP0i$*WjOyEvmO!b4>j_wNx<>&Pi zmF32dQ6NuDTR!^ivs-PCAK!ld>c!yo#iyY)xo_mkxXEB>nbP=N;oyI7-W9^OM&JO5R zZ-uAPyFsRB79@Ta(P%04k{YOhv&~kws$EGcPm~T)i}hBhJ1>^^XaR# z6S&j+Zl@F6FB_?G@5H+mMVe>g=H@QvGiTfFofkVh4H-s2 zft^EM&L}+1r=_Ku3EWpNoIIW2+%`WpBoG~)R{Z3tKsMlN?h4QBZSEI$9{%e;k9S@; zyQYU(F%Ammb0y4vd~|SFNGgoUq;Kh|Yk`NeMm-7M&9VjfRT)A+F;~i`LGoBihPX!a z08Nq%$=HHH4Jw=Q-Ipu7_Azr;#}GyzbUFvyEE^je&Pk_hnAAh~4`_fc+S8CjGF5ip z%PR?>PN}gIAlp+-a)6fT&wqdZ3=|A(;`Mm^%c6C>KkBp3lc1 z??L#1H~^iSEocMtsMGiL0eau|%k2@Lz1K60t{v=0H+FCiTKYF;XPvWMgF`f4u!)T(^k!s zrAeC>Gsqmr!Hz&C-7E_V2G>zJM;3>$6P_4A=&2fUbiw{%k{QYn{WN zh^6zz1BieHOrDPORD=RQFhKX#L{Oc+AgR+EO~Jmkr`wmuJfcQAbc|^E<9*9u2Z-N) z8{M>}YiM?`xi?6AM(x0+@qt9NN}jPlRk7xX9P)rxQJ$1}){_meuG)Vx`3;-Q@4bI2 z!JUiZ*p|TGqN(AVcdvD116}=-)@)!Qt0HVD8Qhup=H9b%xwO|m>Ad1I4_%(BN9Z<$ z4nPJZA2k-qv@oYth<>sz^0REY&THg|Tmo|eu+Z7LP&#*|=YCgT z7z(?S!?Zlk7ZEnZHf8az3fkPTBu!@+Gs7{rCeECh2s7cSsjzyZ;U<&&Y<~J$Q-W)s zn_EMBXQm@RT}orpU0YKxS2f9Gcv+K0`8{`|&JF*9kw+W&;&M;tjZP z$^sojVh3K=)pM+u>BfU=#xog2j$Z!hs%*S;cZN6hOmH$8o}BEQ0?OB`j$Zt)E^OcP z2b&VyBYUbBhlb@fy_;|W0XHXl_DqA4B|WVN2}#Xx8Q{?zq-X2t(^_O|W##O{vtWN- zQy|Z!hb63bS%Ol>xwB3LDD2Gfu<_zWj2IuQDu zf4rEVzyGkSY;JAwx(06U#J2M|Pvs43VW8k5B|z))Bee_Q3QRvj$LbAR)`>*)0o0qU zK{&)ze%3xx-FR$S_V;6>V)q%1czj`?TA;==!IAS(*Ysqv)57U3FMj$T$danxsTsM_u)W2;BbT_axkIZ(V5d z*6p81qhzrtw1je%*?Jcl`>E^e#`^l4FBB3}h8cINRgR*;q4B(vA*fw7bn}^28+MuF zbln7ZXZXp^$RIp>?#j8ofxcUfg6CK5^!wigSE2gJqEzSyicP25J(A28H#DfO6iyLE zMP1pkik7)$Zf-n(ajbM~`+gOY7+2Pdnr;sXODPuSIq)il2HH}G9sp(^Cm;xT5|?5f ziNkk4|G40aQtVud!&s`azx~68uGFg!F!;t-niCxB^b;)UjJw^=l%qv( z5_wCJ#}!(#in&}xErSn~O?~UxvwyuvcKvx7%aU|j*UAW-<0uH!wwcKQKqvi9yB`nG zad49JvH$=e07*naR1L-}coQA5OCP>_?b`7KO$O+q?+tO*c)Y&0X7^ouS3~XaKvjz< z=5?Le+%YL92i4oi*vQxrkZN7if=i?LY3q8%z96Kwo2yGd`6Rh;`B={{uDo;XVuRrM zHOE#o_o~E7(d9>ln+Hi*Nc6;=aV!a_oVHu5)vO$ZaaK`ub#rI0HZZ@SmbJ2#*5EyG zP?WK86oTUH28ymIQG|}A96ShA(Eyu?#XkJ#_rC_WC!?-H(bwY3m!EB{BlLD`G{TSX zpjcHDE2eDhY)K>?OsApB85=wG{=lHAaf_?Ar^77A#ty{y-qpob2)Ct`mF>M!=|ZF6 z`869rzS>0Pzc*KLx)1)&fekbO;dV+g#Y(b7Qs#iFmgIv6MPH7!pz?mP-LqXQRx}0d zJq|B$#?h``w=I?cs{=WMeC9-f90ouS&hc0*cIouJyQj0USk_Ow3Y6$bRm|tl*1_&; zSL=%lAqVQ4Lq4M_J>AiZRFEqaXc~%~Q;~rSeEG&99WDrdZUT`($sKcZ>0(mdjjY^X z-oD<~cjnE8#P+&oqFQaw;FB{RxzS6ZRGWCoZd#0ZJkLb)gXcIgve*J<^)J^zOamPad_kwI1-&u70w` zk;^|t=!iX3?>CAevE4U2YgLuaO^TE=K!+&0&|ly>-=E-T-t5J&Zrb6^M$U}hyzx{& z^UmHsm-o8f>ul78z5d*Wre4)|=ZuOUrn?g;SscC8Dt)>_sOJp1S9^#S~Gryo(?JHm)rn2I$!%2U<_xy?f~qj3)=$Vo?|Ef1^E@ z+jzF|c&$Fb@N07-PI%u{pf{TmtMF;uJV1lpgUQ}x_|Q$XIKu;E8$Qoum^;&(GdF)Z zzx>5^?YB$&cBS@7aE(+x3#=mGbjST3K|r~qCl(XLm?)4VL({YXflnav@i@iF(&dtA z>IBOL{g9|pMI*TFjysYWgbx1&C=5dPc6d8bO!$Y}AN}~zleR}~+3bNV%!5R`eMgv$ z4cp-n`c=b%IM*(UArFz3Su)7T1+;oJI>scYXAT{*ogB+j#BJ;Bn3?`h2ZP)q~dH*=R1=;b;5&`+=EOdQ8%*ls4LJP0OT$N zjoV+GuDDxBymjr~>DZ;Zjt+t$A!Ltq2*D|%S9|q&3qcvlX*>NKr5}6StvRTbq8?vM{+G1N9NNF|;UfJ7N zDvd*;EL%4Syb`D+B|_@HP>F}l!#?ae2iG$V zup7v62LgJ1kKcb7M`q&#qi;7stOXhY*hs>qZ)DlPDu6H4PW8z!&Zz-gry8*5%cR%p zsC3~kH^0P8tVZUHL{f2+J_k^T`ja|7`ctp3)Zo*3VsNkx_VoS^mQ^x3WC^6!{hv&v zE1%q%Mc$gw7L7Ac(sZ^`sVGX3=Aup)*Z$IU%j?%Z2lvkgL2fJnKQX}@n?lDzO-)#X z9|Gv4o5vI*NL7o|!|2vdodV&b3YfI^HZvjeTECYWJDQ1mw?F-BOPC!VMkXT)*3_+A z17}DlIat?_1N2(G_GE2-raC_zJv0CPa*lJ5>25A&0NY|<_@tDMxBot&5q5xGtyV|1 z6^~bhiX?Lp?=VTcD&6vW2e*&P`^!L7v<28bBB^uw96mVqCOua8`dsCm?K3gU@#7eV zY74DE$br?rEm%rq*82HG6~5awQo}yn{35L5k&SXVs3lvvbobKf)3kxS_N0NmUb|MW zEfj3Mw)raOF5JEJ;KL+IrAsziVhqL>vn7&#w3pYA18mTAh-IwS(Rg+>lN5xcj&!?Y zkyoW#4&vZu8n_X8IV)H|b`BF}$X$9O>h^3rfBH1%foP1im`$2(2T7ZJCZ|hlRo4+@ zl!EwLlz9TUJ4CMc*4H13!^4UqQ36F}=yW`P<=m}Hmr4dhO@j{Ztp-vr+XCKhZ=v71 zol9JQFl8YiaPW@O@jk|ApyMyvwG$4|QPnXKXR|I=Dj6lI$OK7o)`L2>m)=!5%H{t{ zy_|jgvDs*HfLVvwbtuulo%?QQ+crBrjF0xQ_ApA>=>l&s=yXA>qQim_R^miP79mK7 zgFbS5cehK&Fk04~AhC9oFt}4wU)@R(#a#W`Mlk^Y30r@;4&)f2ko(Y-Autz47k>TR2(=7*aa3tm!8tbN41da3QV(>pz ztMkjt%em>n&bFbbs7N9YR@~Vr?1lq@!3sh*@S-U4st9^vV7oTgw<-eYdXiNhUpR!rN^;)DbedsMPrsZN0EJW(9*@MMdw%V{Wq*N_SRaOT`Ro zJ{@^&y5#^={#S-xAd0heMFcWxYI@tJBW4TZ%jZs?A)G#ATU*;7u1%E7&uIqS7Dg); zOfZ@eIL4^JXmDn-sE%}P{%1=Z!MDC7AtK4|N)#vYyecbH)|#ITGEJSR@OaKw780`o zgQ;!FrE`(PZjUjr5k1t=5i*i}S8iR&@4aWs4HRtJ(tz85S3kPU$ch-xUwphasa2m^hx_*tR8Ek|l8Xj0K_`GnPs<7(6da zk}AqytZ#NbR(K1bRU}SOM9xd8I{34~akRA*WIBfsHejD2b+U)hV`kq6aW8m``bI+Q zCNPrpjSqgi7pDhOS^+U^06-sr)w{R~$OW9zXG0rzaL4xYyQ(m{&*C$MH2@yJ&XYKM z*!h?8GY?IOVk&r_tqf>W5}r<`$zt$HW{&U%`j{6%HqvegD57 zrMhWrKfa^UkJ87U&|I0@5-CNABlP@Fq+5PMDDwTm^F-&G|Ete%kRi%9f9 zg3jkr){XH%X`U*myo9ldMaKUA_n^jgyb~r4&qa$?K5jNa=(O#M?m8{v~jj^$_DeVoF z{$OyCXTf#!Wg@u&+h;$zm3pIxfA&*(u{)dC_;(@_^*0~$@v(r1OL(i*Sd=*8cUiZW z?>_kY>2g0MdB9+ciY%)P&=($cU6y(I@%rvFNl{duFt>#50M>XCYo|laN3jRa&gy-q z^k#@m8&XH-);c%WdSYoIkTmEmWJElA^l-CR~CA|BhD^e=u7mL~A#j6*`#%|mI z*@L_P*ib2Qkt|)x4YdD^bjtx8+;6hk>c(1chV(Tb@?*O_6Jzui=aB1!iJZ0OwwFKu z@a_~&^Opnx&an*f6_`6#mBpyEx_em>I7$Gq8^T(1jHA)(+K5@heYD!*2(_;CEX~yM zsMk^It*t8y0gor_aFN-8Q*XU>2pfo6PTt=8D9b8YfF94@Isd^`L=U1*tty1Tk}IvF{P{obpXCG!+*U*o6j=>K zqgX5v6`$?yUIxy}p(|%C_C^(L*lfn}1z|JZ)Dd((E1BDBgG)QB)(v#e6=0^>=?dfAyj!`bEJKk;oWZOiliH>hYVt2eB_1 z^RG%K5~)xSSrc(i=Qn9x_hb*5UFAvdXm0ub*Y|?}o#HYXAXRYUJ)QtbFv`~M>SKTn zfeI(d>i<}~x}P?(EB=SnuPBM+Wn~3jtV(K3p8~EyvUk-$ldMSq15i1tG{#@90S?f%v zEXm_#gB_5WmfBXEqCkx}b@uI{2 zK{#v+Sw8sD&(L7kpE@7@@ZAroYQ4&eg2XfkpR;ldUTPJK_J~6j*jJryIYTP{UOMFP z=UlFj9HJzNvfOO7)RqboF=1CW*S`AZ_FW1}r%*^$L!fz!*K0{kcRC5bf2iEAm#1J3 zC<^r0f&S2%dnQ|#5n^K6V!U8a&zHN5OXzwhJf5B(y5Kr*nz+$C zdW_aDd;g9cuTM?ovm}E%ec1}fM{!b3^w?7gRc2p#y5)Na?sTO4#NxMk7bd$f37~^0 zO^Ry4D;2?rk%3FM*9wY)VHky0{#PjA8MSlNOpWLKjxy4^Y7IFc4uZo&QVR*54U&6f zCY>l^V?FPtLRUsI7mX7uPgkFwz&E+heQI1-a8FF!n78)WZul+DLoIEwSRj&aC?fBf z%lmi^kozhi)xq@}sfE4}WrmKjl4aSj)`GxIRBK*r#Cd zqLPqqg6x*T@4@;VYPl>VjEMcpYNqJWSI%GUT^d_n?p>XkA6#9z-_?~KEZZ~Mq1jRN zClVB~*$`NqcLH=@HjALwQ8UUmh+ynY(=BHhtNO9YW^#+Qnhsq9l>_wVt}SAP>S<}< z=GtckK>ZX%5im-n)a0(rU=aEoX)AaJ(Q8XMdJEA_ zS!pnEhIM#;aCv!Y_U_%Uzn;A{JGOd#J(O-8cH|Hm&ZAg@VMv~?AiPM9-z!|4$IY)f zD)kDf{14u7rOef8HD;C=WbL5#ro(9JpRrnd?~N4(SWy9Figa{X4MLt(fMgrMFjub% zy}g2<$V>t7Lx5Bjl5BwUhZ1FojBFuY4q+HW=j%LN#mGs^jL^3XnfVfwWlJw!yqKM3 z4-YpSedR>5tdKZf!s#rsa|Hgl11fd+iJcmi`stf*-}v%a)dw!Q8jr_oF_s0rYl5aU zlRd8SAqZxx!!rY<*4%jfxYg-s5(&r~iXQHTzCNrB#9jt{gP)3$sH!4L!?AKIl}V+k z2HGeAEPa9vkyK0;J~068BE>h@dSL%Kt2$t2au`P zb#D*UopJM-r(4dD%Ktv60CX-M1ni;);T()Nf<|8_C&P>Dmr9~Wu;yy5M97T-BQu)> z$R;7n>^+oiLajxVqBJWJWN9Y{7)!E+0>=9CPM$BpNupH3p%a9A+1t0* z9x_7h?^AR(>kLeJev4$(GnGfsoyX8Cm8=h1v9nLNd{3l%iQw!Zk*ib?b~Bi~C{t9~ z|B>76a$obWWBI7Y?zIi=c6*yq8iM)=HQR;*MLB?$L4UOkJEHaseL;i6?4twQw6p_X zZ4<$%(LAR&@e*HSrTl)|(A{ll@8oM{wnS&AJfncxGdcxm`6?ghIL^maxLPU5`RW1w z|33u$#sv50kcC0M#YKZ8sEQF3HR(qG(-R&JId0)vY|o%eKn9Q4(VN`|ntaf0__yrH zt!MDDjW=7+H_&j3`kC9M>fC5Oh?;wNuxiHl|8vbgA+tEm^HpEn7p+G5YAIH#LD1nj zE?%wS;QCHb`kRbOy~1S7`?(~C=)^~(^pRx+%Hf(=T=e?;hQki&Ce9>F2U1Fz5epnBtDr#6{~1_lD6@&^n8f$W1fJc8VGF}s10W2PK2*b&1s=b3q}t6Xz;nG)T_JNquq(fZ&# zokDgrGFCrC!c-DBjHC~)?BLL&*o9d`G$yfQ&;H=FYgxLM?0J9ZWcJ8d+}Qg?k>ryQ zdVcTwKJW9sucTu@*4R4MTw0}v*tV?5#qL;az-c_Eg7EO_J6p6n+EqjO;)|s`+a#yO z<9JR%Xk!bE_W(Oa#BN5#SjKMo?&Fq&NcknxFwp)+$Hn2dZlxwK z^^^(>`mX|pt+Ajn=x>hHLxvv&!zW6s3oP^-EVnhg`ecVeUxAG)Lqp8M<3FUQoY-FY zOnv4J&C&%qKy^cUSe7JD;fZFWu(=s)dBt(d0TSHtzV)5;ot;OIE?w*X=G&H@lfS#s zd-L`AKELQN=*P!580ITFyBQgoC9LulcJ9hVCA7M+%51HcoP05aUda|$L+Cvnog|0W zwy)}8WUL(v+I%fV`q96jrRH-H$1MlxRo!~{C9SXe;@^JL-QRWY;*FCh zKS=gZ4P`!|%U;bL`T!iq9DS`cRT~ATbm$vKy~#|C`}YG)jx%#w=WAifya7SYgopzFZ{b zv%7ab{oCeB`1FwU*HRyK(wPz_A3a*X0Dp&ewPR&7T8qcUfq?^j2>8_#+^0|ei5&g3 zG5h8H%?DHGhHrk@`_`=+=Y5S?-7ji*wd5$E-y`g%N{iGDb*H-bj9X5>b~MQM zOZkt3d-rBXt21-;>b1+4e|h;v+nJ8ONW^noxjUnZJW8sv$Y%u98CE&wbr7n4ANKuowc-DpM~9%k+VUNOKDmP z2d8aR4xCNXRV2A$qC#`7{GP7V=^uRWsMfv&_v1W54zX4f{ZsAzw|zl&TGMA0L8R>< z=%UJ(%c2UM9mPJNz*RuZo((-lfFa1j`LIsvgy(p^T2<^IsZ^;Z1nSxP>>O^YJbWQY z(dpVFL6Fw9EE{fB#;KJ(GFUmhamxXEReundX~h+Ps6U+w6xX@dspW)t*f^nU4}4|jUe!Xw53Fn;EAfrVW*{jCH%kqBpdL+zD(_o0nj4)V>IB>=D0M4|PRALJxX&$hL8ITo3`R*Uisxk>{P z3q-~PKj6a?)H3Yv8Lp#4mB0n0fS~I}fV9PdzD6lh%=o=pJ*v)Br`fmm0ewun;5dDL zwv?#QIFrU(H2P^d#Bs|3dR4#8Ai30d+i4%~cZ`_sC)%<$rCNl#%Cq*B4bw`3M2%!} zet11h8Wp)r*lQBv(cR6Vg)QO~LJtzbwPh>J$J1$9PSMAu94sFfnrakWN7FQ?aH!*! z14#KrSUqm?hF^NURhOtetJyrLFB&I&F^=LIlmwp^Jb1c-I#Vpi%Af)A2@fpC@pdLg zYzc0_A#4|~R^cL|intFb7s^Bn-~?*n5imqkvxaIpti+q2A`>A7l$j~~t znoQvPz9tI_FLFE)m*pYSEuZ4<3>V%`T(^ zWWtSHhzH!m9=9B181obQ4pQ&$M+S#_dL~K`BeJJJ&%kj7o8!wKq#Ou78s#hw`w&;b zcZ8cSBgjRhd;o{s!x5FYBpnfxg*oX%A_UE|89)PpL6PISj)P=K{x8MA6_T{4D|PxP z6WfbFI6Rb~GfQ`Ml@cYqFBwu5l*TKvVMA(iplU9o*sv|Qz0A@U96KK8EY&RUx&&fh zBo{D24F;GGh-IC88YGEVvvCyLq5Bgf?W-l%5Hhv^Eo5LP+#~Ety~)1~zyJUQen~_@ zR79`piiXsTf3D`}5L-Mvk$6pKyAqrR505EeA+&9~WYP5VIshGYktXW+^se z5ypbgV<*Z02^urQ2#>OPA&`n9F*(jwdzCDP@rgG$n(8r#uFY zALS(Yd(Bibg7L5Ru9&B7APT3cC{>Xtza|XXyqU$*$xL~{k{lxCGgPG7zR{PJ1V0y@RcG>h_8;B(Of z>23PA+=aVw9LZc~+=$3MEfD3joPhDJ8$llcT4t%+9S*9 z_lPYn&XPt;5Qr<{W^uk;at8-TP*vO=Ny||OQ>iCi#_+vou97LVJNJ>jpy@O+mZ4zF zJp?t{k<ggY%tIWd8R}jAS`kdC>&;J&5@38)<4aH zPzuMhu7OxeJP}%|avqn+gQB>*ZgJkd>D2Ul0;dpzDLc^;nTgbN;V_v;+RZcH2zX9? zXF4D;Qr7nosyBu}z%;j91VqHEGOoBbQI$&JTzR#M^Hs{##V)T~o-?aj zf0<6=(9E1JMi--LT*O?jtBR0oPO};XikcayVpi0Xx7ZWPcMI2-mS3R7dXc`9&gS% z#AY+T`yh{DAC_;;s+>;o$B(7!EZetA`99z{?+5*0OW=Az_rmt*tf~jRJ{a_dt^Zfm zeY_9*vwW~W>@nS64flIAeXw_Mc=Wax9339)4SL4jelO_VZVL+w3kwSi3kwSi3kwU2 a9pEPmi;gPP<3w@*0000Welcome, Commander +lblWelcome.tooltip=Blake is watching. +Name.text=Unit Name +Name.tooltip=Name +btnNameGenerator.text=Regenerate Name +btnNameGenerator.tooltip=Name Generator +lblFaction.text=Unit Faction +lblFaction.tooltip=Faction +lblReputation.text=Reputation +lblReputation.tooltip=Reputation +ManualUnitRatingModifier.text=Manual Modifier +ManualUnitRatingModifier.tooltip=ManualUnitRatingModifier +lblDate.text=Start Date +lblDate.tooltip=lblDate +lblCamo.text=Unit Camouflage +lblCamo.tooltip=lblCamo +lblIcon.text=Unit Insignia +lblIcon.tooltip=lblIcon diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsDialogController.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsDialogController.java new file mode 100644 index 0000000000..7f037e76ab --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsDialogController.java @@ -0,0 +1,233 @@ +package mekhq.gui.panes.campaignOptions; + +import megamek.common.annotations.Nullable; +import megamek.logging.MMLogger; +import mekhq.campaign.Campaign; +import mekhq.gui.baseComponents.AbstractMHQTabbedPane; +import mekhq.gui.panes.campaignOptions.panes.GeneralTab; + +import javax.swing.*; +import java.awt.*; +import java.util.Map; +import java.util.ResourceBundle; + +import static megamek.client.ui.WrapLayout.wordWrap; + +public class CampaignOptionsDialogController extends AbstractMHQTabbedPane { + private static final MMLogger logger = MMLogger.create(CampaignOptionsDialogController.class); + private static final String RESOURCE_PACKAGE = "mekhq/resources/NEWCampaignOptionsDialog"; + private static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE); + + private final Campaign campaign; + + public CampaignOptionsDialogController(final JFrame frame, final Campaign campaign, final boolean startup) { + super(frame, resources, "campaignOptionsDialog"); + this.campaign = campaign; + + initialize(); + } + + @Override + protected void initialize() { + GeneralTab generalTab = new GeneralTab(campaign, getFrame(), "generalTab"); + addTab(String.format("%s", resources.getString("generalPanel.title")), + generalTab.createGeneralTab()); + + setPreferences(); + } + + private void setOptions() { + // TODO this is where we update the dialog based on current campaign settings. + } + + private void updateOptions() { + // TODO this is where we update campaign values based on the dialog values + } + + /** + * Returns a new {@link JCheckBox} object with the specified name, label, and tooltip. + *

+ * Please note that 'name' is also used to fetch the resources associated with this object. + * For the label text 'name' is appended by '.text'. + * For the tooltip 'name' is appended with '.tooltip'. + * These values must exist in the resource bundle otherwise an error will be thrown. + * + * @param name the name of the checkbox + * @param customWrapSize the maximum number of characters (including whitespaces) on each + * line of the tooltip (or 100, if {@code null}). + * @return a new {@link JCheckBox} object with the specified name, label, and tooltip + */ + public static JCheckBox createCheckBox(String name, @Nullable Integer customWrapSize) { + customWrapSize = processWrapSize(customWrapSize); + + JCheckBox checkBox = new JCheckBox(String.format("%s", + resources.getString(name + ".text"))); + checkBox.setToolTipText(wordWrap(resources.getString(name + ".tooltip"), customWrapSize)); + checkBox.setName(name); + + return checkBox; + } + + /** + * Creates a map containing a {@link JLabel} and a {@link JSpinner} object. + *

+ * Please note that 'name' is also used to fetch the resources associated with these objects. + * For the label text 'name' is appended by '.text'. + * For the tooltips 'name' is appended with '.tooltip'. + * These values must exist in the resource bundle otherwise an error will be thrown. + * + * @param name a string representing the name of the objects. + * The {@link JLabel} will have 'lbl' appended. + * The {@link JSpinner} is appended with 'spn'. + * @param customWrapSize the maximum number of characters (including whitespaces) on each + * line of the tooltip (or 100, if {@code null}). + * @param defaultValue a double representing the default value of the spinner + * @param minimum a double representing the minimum value of the spinner + * @param maximum a double representing the maximum value of the spinner + * @param stepSize a double representing the step size of the spinner + * @return a map containing a {@link JLabel} key and a {@link JSpinner} value. + */ + public static Map createLabeledSpinner(String name, @Nullable Integer customWrapSize, + double defaultValue, double minimum, + double maximum, double stepSize) { + customWrapSize = processWrapSize(customWrapSize); + + final JLabel jLabel = new JLabel(String.format("%s", + resources.getString(name + ".text"))); + jLabel.setToolTipText(wordWrap(resources.getString(name + ".tooltip"), customWrapSize)); + jLabel.setName("lbl" + name); + + JSpinner jSpinner = new JSpinner(new SpinnerNumberModel(defaultValue, minimum, maximum, stepSize)); + jSpinner.setToolTipText(wordWrap(resources.getString(name + ".tooltip"), customWrapSize)); + jSpinner.setName("spn" + name); + + return Map.of(jLabel, jSpinner); + } + + /** + * Creates a {@link JLabel} with the specified name and optional customWrapSize. + *

+ * Please note that 'name' is also used to fetch the resources associated with this label. + * For the label text 'name' is appended by '.text'. + * For the label tooltip 'name' is appended with '.tooltip'. + * These values must exist in the resource bundle otherwise an error will be thrown. + * + * @param name the name of the label + * @param customWrapSize the maximum number of characters (including whitespaces) on each line + * of the tooltip; defaults to 100 if {@code null} + * @return a new {@link JLabel} object + */ + public static JLabel createLabel(String name, @Nullable Integer customWrapSize) { + customWrapSize = processWrapSize(customWrapSize); + + JLabel jLabel = new JLabel(String.format("%s", + resources.getString(name + ".text"))); + jLabel.setToolTipText(wordWrap(resources.getString(name + ".tooltip"), customWrapSize)); + jLabel.setName(name); + + return jLabel; + } + + /** + * Creates a map containing a {@link JLabel} and a {@link JTextField} object. + *

+ * Please note that 'name' is also used to fetch the resources associated with these objects. + * For the label text 'name' is appended by '.text'. + * For the tooltips 'name' is appended with '.tooltip'. + * These values must exist in the resource bundle otherwise an error will be thrown. + * + * @param name the name of the objects. + * The {@link JLabel} will have 'lbl' appended. + * The {@link JTextField} is appended with 'txt'. + * @param customWrapSize the maximum number of characters (including whitespaces) on each + * line of the tooltip. + * If {@code null}, the default wrap size of 100 is used. + * @param minimumSizeWidth the minimum width of the {@link JTextField}. + * @param minimumSizeHeight the minimum height of the {@link JTextField}. + * @param maximumSizeWidth the maximum width of the {@link JTextField}. + * If {@code null}, the minimum size width is used. + * @param maximumSizeHeight the maximum height of the {@link JTextField}. + * If {@code null}, the minimum size height is used. + * @return a map containing a {@link JLabel} key and a {@link JTextField} value. + */ + public static Map createLabeledTextField(String name, + @Nullable Integer customWrapSize, int minimumSizeWidth, + int minimumSizeHeight, @Nullable Integer maximumSizeWidth, + @Nullable Integer maximumSizeHeight) { + customWrapSize = processWrapSize(customWrapSize); + + JLabel jLabel = new JLabel(String.format("%s", + resources.getString(name + ".text"))); + jLabel.setToolTipText(wordWrap(resources.getString(name + ".tooltip"), customWrapSize)); + jLabel.setName("lbl" + name); + + JTextField jTextField = new JTextField(); + jTextField.setToolTipText(wordWrap(resources.getString(name + ".tooltip"), customWrapSize)); + jTextField.setName("txt" + name); + + jTextField.setMinimumSize(new Dimension(minimumSizeWidth, minimumSizeHeight)); + + maximumSizeWidth = maximumSizeWidth == null ? minimumSizeWidth : maximumSizeWidth; + maximumSizeHeight = maximumSizeHeight == null ? minimumSizeHeight : maximumSizeHeight; + jTextField.setPreferredSize(new Dimension(maximumSizeWidth, maximumSizeHeight)); + + return Map.of(jLabel, jTextField); + } + + /** + * Returns the maximum number of characters on each line of a tooltip. + * If a custom wrap size is provided, it is returned. + * Otherwise, the default wrap size of 100 is returned. + * + * @param customWrapSize the maximum number of characters (including whitespaces) on each line + * of the tooltip, or {@code null} if no custom wrap size is specified + * @return the maximum number of characters on each line of a tooltip + */ + private static int processWrapSize(@Nullable Integer customWrapSize) { + return customWrapSize == null ? 100 : customWrapSize; + } + + /** + * Creates a standard {@link JPanel} with a titled border. + *

+ * {@code createStandardLayout} should also be called and the resulting {@link GroupLayout} + * assigned to the panel via {@code setLayout}. + * + * @param name the name of the panel. + * @param includeBorder whether the panel should have a border. + * @param borderTitle The resource string that should be used as the title of the border. + * Can be empty to generate an untitled border. + * + * @return a JPanel with a titled border and GroupLayout as its layout manager + */ + public static JPanel createStandardPanel(String name, boolean includeBorder, String borderTitle) { + borderTitle = borderTitle.isBlank() ? "" : resources.getString(borderTitle); + + JPanel panel = new JPanel(); + + if (includeBorder) { + panel.setBorder(BorderFactory.createTitledBorder( + String.format(String.format("%s", borderTitle)))); + } + + panel.setName(name); + + return panel; + } + + /** + * Creates a {@link GroupLayout} object for the specified {@link JPanel}. + *

+ * Written to be paired with {@code createStandardPanel}. + * + * @param panel the {@link JPanel} for which the {@link GroupLayout} is created + * @return the created {@link GroupLayout} object + */ + public static GroupLayout createStandardLayout(JPanel panel) { + final GroupLayout layout = new GroupLayout(panel); + layout.setAutoCreateGaps(true); + layout.setAutoCreateContainerGaps(true); + + return layout; + } +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/campaignOptionsDialogController.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/campaignOptionsDialogController.java deleted file mode 100644 index b53cb5522d..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/campaignOptionsDialogController.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions; - -public class campaignOptionsDialogController { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/General.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/General.java deleted file mode 100644 index cabea3930f..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/General.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.panes; - -public class General { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/GeneralTab.java new file mode 100644 index 0000000000..b35ab0e07d --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/GeneralTab.java @@ -0,0 +1,309 @@ +package mekhq.gui.panes.campaignOptions.panes; + +import megamek.client.ui.baseComponents.MMComboBox; +import megamek.client.ui.dialogs.CamoChooserDialog; +import megamek.common.annotations.Nullable; +import megamek.common.icons.Camouflage; +import mekhq.MekHQ; +import mekhq.campaign.Campaign; +import mekhq.campaign.icons.StandardForceIcon; +import mekhq.campaign.personnel.backgrounds.BackgroundsController; +import mekhq.campaign.rating.UnitRatingMethod; +import mekhq.campaign.universe.Factions; +import mekhq.gui.baseComponents.AbstractMHQScrollablePanel; +import mekhq.gui.baseComponents.AbstractMHQTabbedPane; +import mekhq.gui.baseComponents.DefaultMHQScrollablePanel; +import mekhq.gui.dialog.DateChooser; +import mekhq.gui.dialog.iconDialogs.UnitIconDialog; +import mekhq.gui.displayWrappers.FactionDisplay; + +import javax.swing.*; +import javax.swing.GroupLayout.Alignment; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.time.LocalDate; +import java.util.Map; +import java.util.Map.Entry; +import java.util.ResourceBundle; + +import static mekhq.gui.panes.campaignOptions.CampaignOptionsDialogController.*; + +public class GeneralTab extends AbstractMHQTabbedPane { + // region Variable Declarations + private static String RESOURCE_PACKAGE = "mekhq/resources/NEWCampaignOptionsDialog"; + private static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE, + MekHQ.getMHQOptions().getLocale()); + + private final Campaign campaign; + + private JLabel lblName; + private JTextField txtName; + private JButton btnNameGenerator; + private JLabel lblFaction; + private DefaultComboBoxModel factionModel; + private MMComboBox comboFaction; + private JLabel lblReputation; + private MMComboBox unitRatingMethodCombo; + private JLabel lblManualUnitRatingModifier; + private JSpinner manualUnitRatingModifier; + private JLabel lblDate; + private JButton btnDate; + private LocalDate date; + private JLabel lblCamo; + private JButton btnCamo; + private Camouflage camouflage; + private JLabel lblIcon; + private JButton btnIcon; + private StandardForceIcon unitIcon; + + public GeneralTab(Campaign campaign, JFrame frame, String name) { + super(frame, name); + + this.campaign = campaign; + this.date = campaign.getLocalDate(); + this.camouflage = campaign.getCamouflage(); + this.unitIcon = campaign.getUnitIcon(); + + initialize(); + } + + /** + * Creates the general tab for a campaign. + * + * @return the created general tab as an AbstractMHQScrollablePanel + */ + public AbstractMHQScrollablePanel createGeneralTab() { + // Promotional Image + JPanel imagePanel = createImagePanel(); + + // Campaign name + Map nameFields = createLabeledTextField("Name", null, + 300, 30, null, null); + for (Entry entry : nameFields.entrySet()) { + lblName = entry.getKey(); + txtName = entry.getValue(); + } + + // Generate new random campaign name + btnNameGenerator = new JButton(resources.getString("btnNameGenerator.text")); + btnNameGenerator.setToolTipText(resources.getString("btnNameGenerator.tooltip")); + btnNameGenerator.setName("btnNameGenerator"); + btnNameGenerator.addActionListener(e -> txtName.setText(BackgroundsController + .randomMercenaryCompanyNameGenerator(campaign.getFlaggedCommander()))); + + // Campaign faction + lblFaction = createLabel("lblFaction", null); + comboFaction.setSelectedItem(new FactionDisplay(campaign.getFaction(), campaign.getLocalDate())); + comboFaction.setMinimumSize(new Dimension(200, 30)); + comboFaction.setPreferredSize(new Dimension(200, 30)); + + // Reputation + lblReputation = createLabel("lblReputation", null); + Map manualReputationModifierFields = createLabeledSpinner( + "ManualUnitRatingModifier", null, 0, -200, + 200, 1); + for (Entry entry : manualReputationModifierFields.entrySet()) { + lblManualUnitRatingModifier = entry.getKey(); + manualUnitRatingModifier = entry.getValue(); + } + + // Date + lblDate = createLabel("lblDate", null); + btnDate.setName("btnDate"); + btnDate.setMinimumSize(new Dimension(200, 30)); + btnDate.setPreferredSize(new Dimension(200, 30)); + btnDate.addActionListener(this::btnDateActionPerformed); + + // Camouflage + lblCamo = createLabel("lblCamo", null); + btnCamo.setName("btnCamo"); + btnCamo.setMinimumSize(new Dimension(84, 72)); + btnCamo.setPreferredSize(new Dimension(84, 72)); + btnCamo.setMaximumSize(new Dimension(84, 72)); + btnCamo.addActionListener(this::btnCamoActionPerformed); + + // Unit icon + lblIcon = createLabel("lblIcon", null); + btnIcon.setMinimumSize(new Dimension(84, 72)); + btnIcon.setPreferredSize(new Dimension(84, 72)); + btnIcon.setMaximumSize(new Dimension(84, 72)); + btnIcon.addActionListener(evt -> { + final UnitIconDialog unitIconDialog = new UnitIconDialog(getFrame(), unitIcon); + if (unitIconDialog.showDialog().isConfirmed() && (unitIconDialog.getSelectedItem() != null)) { + unitIcon = unitIconDialog.getSelectedItem(); + btnIcon.setIcon(unitIcon.getImageIcon(75)); + } + }); + + // Initialize the parent panel + AbstractMHQScrollablePanel generalPanel = new DefaultMHQScrollablePanel(getFrame(), "generalPanel", + new GridBagLayout()); + + // Layout the Panel + final JPanel panel = createStandardPanel("generalTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(imagePanel) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblName) + .addComponent(txtName, Alignment.LEADING) + .addComponent(btnNameGenerator)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblFaction) + .addComponent(comboFaction, Alignment.LEADING)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblReputation) + .addComponent(unitRatingMethodCombo, Alignment.LEADING)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblManualUnitRatingModifier) + .addComponent(manualUnitRatingModifier, Alignment.LEADING)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblDate) + .addComponent(btnDate, Alignment.LEADING)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblCamo) + .addComponent(btnCamo, Alignment.LEADING) + .addComponent(lblIcon) + .addComponent(btnIcon, Alignment.LEADING))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(125) + .addComponent(imagePanel)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblName) + .addComponent(txtName) + .addComponent(btnNameGenerator)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblFaction) + .addComponent(comboFaction)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblReputation) + .addComponent(unitRatingMethodCombo)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblManualUnitRatingModifier) + .addComponent(manualUnitRatingModifier)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblDate) + .addComponent(btnDate)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblCamo) + .addComponent(btnCamo) + .addGap(100) + .addComponent(lblIcon) + .addComponent(btnIcon))); + + generalPanel.add(panel); + + return generalPanel; + } + + public JPanel createImagePanel() { + ImageIcon imageIcon = new ImageIcon("data/images/misc/MekHQ.png"); + JLabel imageLabel = new JLabel(imageIcon); + + final JLabel lblWelcome = createLabel("lblWelcome", null); + + final JPanel panel = createStandardPanel("imagePanel", false, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(lblWelcome) + .addComponent(imageLabel)); // Added imageLabel instead + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(lblWelcome) + .addComponent(imageLabel)); // Added imageLabel instead + + return panel; + } + + @Override + protected void initialize() { + lblName = new JLabel(); + txtName = new JTextField(); + + btnNameGenerator = new JButton(); + + lblFaction = new JLabel(); + factionModel = new DefaultComboBoxModel<>(); + factionModel.addAll(FactionDisplay.getSortedValidFactionDisplays( + Factions.getInstance().getChoosableFactions(), campaign.getLocalDate())); + comboFaction = new MMComboBox<>("comboFaction", factionModel); + + lblReputation = new JLabel(); + unitRatingMethodCombo = new MMComboBox<>("unitRatingMethodCombo", UnitRatingMethod.values()); + + lblManualUnitRatingModifier = new JLabel(); + manualUnitRatingModifier = new JSpinner(); + + lblDate = new JLabel(); + btnDate = new JButton(); + + lblCamo = new JLabel(); + btnCamo = new JButton(); + + lblIcon = new JLabel(); + btnIcon = new JButton(); + } + + + /** + * This method is called when the "btnDate" button is clicked. + * It shows a date chooser dialog and sets the selected date if the user chooses a date. + * + * @param actionEvent The action event that triggered the method. + */ + private void btnDateActionPerformed(ActionEvent actionEvent) { + // show the date chooser + DateChooser dateChooser = new DateChooser(getFrame(), date); + // user can either choose a date or cancel by closing + if (dateChooser.showDateChooser() == DateChooser.OK_OPTION) { + setDate(dateChooser.getDate()); + } + } + + /** + * Sets the date for the {@link GeneralTab}. + * This method is called when the "btnDate" button is clicked. + * It shows a date chooser dialog and sets the selected date if the user chooses a date. + * + * @param date The selected date. This parameter may contain a null value. + */ + private void setDate(final @Nullable LocalDate date) { + if (date == null) { + return; + } + + this.date = date; + btnDate.setText(MekHQ.getMHQOptions().getDisplayFormattedDate(date)); + + final FactionDisplay factionDisplay = comboFaction.getSelectedItem(); + comboFaction.removeAllItems(); + ((DefaultComboBoxModel) comboFaction.getModel()).addAll(FactionDisplay + .getSortedValidFactionDisplays(Factions.getInstance().getChoosableFactions(), date)); + comboFaction.setSelectedItem(factionDisplay); + } + + /** + * This method is called when the "btnCamo" button is clicked. + * It opens a {@link CamoChooserDialog} and sets the selected camouflage if the user confirms the + * dialog. + * + * @param actionEvent The action event that triggered this method. + */ + private void btnCamoActionPerformed(ActionEvent actionEvent) { + CamoChooserDialog camoChooserDialog = new CamoChooserDialog(getFrame(), camouflage); + if (camoChooserDialog.showDialog().isConfirmed()) { + camouflage = camoChooserDialog.getSelectedItem(); + btnCamo.setIcon(camouflage.getImageIcon()); + } + } +} From 6da4a245c268610af99ab7a7ca18c7476bc4d2be Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 30 Sep 2024 14:23:11 -0500 Subject: [PATCH 006/117] Rename campaign option classes and delete empty class Changed the package name of all campaign option classes from 'panes' to 'tabs' for consistency. Removed the empty `RepairAndMaintenance` class. Updated the `CampaignOptionsDialogController` to reflect these changes. --- .../NEWCampaignOptionsDialog.properties | 3 ++ .../CampaignOptionsDialogController.java | 42 ++++++++++++++++++- .../campaignOptions/panes/Experience.java | 4 -- .../panes/campaignOptions/panes/Finances.java | 4 -- .../campaignOptions/panes/LifePaths.java | 4 -- .../panes/campaignOptions/panes/Markets.java | 4 -- .../campaignOptions/panes/Mercenary.java | 4 -- .../panes/NameAndPortraitGeneration.java | 4 -- .../campaignOptions/panes/Personnel.java | 4 -- .../panes/RandomAssignmentTables.java | 4 -- .../campaignOptions/panes/RankSystems.java | 4 -- .../panes/RepairAndMaintenance.java | 4 -- .../panes/campaignOptions/panes/Rulesets.java | 4 -- .../gui/panes/campaignOptions/panes/SPAs.java | 4 -- .../panes/SkillRandomization.java | 4 -- .../panes/campaignOptions/panes/Skills.java | 4 -- .../panes/SuppliesAndAcquisition.java | 4 -- .../campaignOptions/panes/TechLimits.java | 4 -- .../panes/TurnoverAndRetention.java | 4 -- .../campaignOptions/tabs/Experience.java | 4 ++ .../panes/campaignOptions/tabs/Finances.java | 4 ++ .../{panes => tabs}/GeneralTab.java | 21 ++++++---- .../panes/campaignOptions/tabs/LifePaths.java | 4 ++ .../panes/campaignOptions/tabs/Markets.java | 4 ++ .../panes/campaignOptions/tabs/Mercenary.java | 4 ++ .../tabs/NameAndPortraitGeneration.java | 4 ++ .../panes/campaignOptions/tabs/Personnel.java | 4 ++ .../tabs/RandomAssignmentTables.java | 4 ++ .../campaignOptions/tabs/RankSystems.java | 4 ++ .../panes/campaignOptions/tabs/Rulesets.java | 4 ++ .../gui/panes/campaignOptions/tabs/SPAs.java | 4 ++ .../tabs/SkillRandomization.java | 4 ++ .../panes/campaignOptions/tabs/Skills.java | 4 ++ .../tabs/SuppliesAndAcquisition.java | 4 ++ .../campaignOptions/tabs/TechLimits.java | 4 ++ .../tabs/TurnoverAndRetention.java | 4 ++ 36 files changed, 121 insertions(+), 77 deletions(-) delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Experience.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Finances.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/LifePaths.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Markets.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Mercenary.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/NameAndPortraitGeneration.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Personnel.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RandomAssignmentTables.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RankSystems.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RepairAndMaintenance.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Rulesets.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SPAs.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SkillRandomization.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Skills.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SuppliesAndAcquisition.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/TechLimits.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/panes/TurnoverAndRetention.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Experience.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Finances.java rename MekHQ/src/mekhq/gui/panes/campaignOptions/{panes => tabs}/GeneralTab.java (95%) create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePaths.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Markets.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Mercenary.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/NameAndPortraitGeneration.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Personnel.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RandomAssignmentTables.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RankSystems.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Rulesets.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SPAs.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SkillRandomization.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Skills.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisition.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimits.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetention.java diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index a7d12d87ab..38c4bb6ac4 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -35,3 +35,6 @@ lblCamo.text=Unit Camouflage lblCamo.tooltip=lblCamo lblIcon.text=Unit Insignia lblIcon.tooltip=lblIcon + +## RepairAndMaintenanceTab +# create diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsDialogController.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsDialogController.java index 7f037e76ab..9b0246aee9 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsDialogController.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsDialogController.java @@ -4,7 +4,8 @@ import megamek.logging.MMLogger; import mekhq.campaign.Campaign; import mekhq.gui.baseComponents.AbstractMHQTabbedPane; -import mekhq.gui.panes.campaignOptions.panes.GeneralTab; +import mekhq.gui.panes.campaignOptions.tabs.GeneralTab; +import mekhq.gui.panes.campaignOptions.tabs.RepairAndMaintenanceTab; import javax.swing.*; import java.awt.*; @@ -215,6 +216,45 @@ public static JPanel createStandardPanel(String name, boolean includeBorder, Str return panel; } + + /** + * Creates a {@link JPanel} consisting of a {@link JLabel} above an image. + * + * @param name the name of the header panel. + * The {@link JLabel} will have 'lbl' appended. This will be appended with + * '.text' to fetch the label contents from the resource bundle. + * The {@link JPanel} is appended with 'txt'. + * @param imageAddress the file path of the image to be displayed in the panel + * @param customWrapSize the maximum number of characters (including whitespaces) on each line + * of the tooltip; defaults to 100 if {@code null} + * @param includeBorder whether the panel should have a border + * @param borderTitle the title of the border; can be empty for an untitled border + * @return a JPanel representing the header panel + */ + public static JPanel createHeaderPanel(String name, String imageAddress, Integer customWrapSize, + boolean includeBorder, String borderTitle) { + ImageIcon imageIcon = new ImageIcon(imageAddress); + JLabel imageLabel = new JLabel(imageIcon); + + final JLabel lblWelcome = createLabel("lbl" + name, customWrapSize); + + final JPanel panel = createStandardPanel("pnl" + name, includeBorder, borderTitle); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(lblWelcome) + .addComponent(imageLabel)); + + layout.setHorizontalGroup( + layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(lblWelcome) + .addComponent(imageLabel)); + + return panel; + } + /** * Creates a {@link GroupLayout} object for the specified {@link JPanel}. *

diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Experience.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Experience.java deleted file mode 100644 index 20915fef5d..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Experience.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.panes; - -public class Experience { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Finances.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Finances.java deleted file mode 100644 index 416354dc5a..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Finances.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.panes; - -public class Finances { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/LifePaths.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/LifePaths.java deleted file mode 100644 index 85a3341a04..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/LifePaths.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.panes; - -public class LifePaths { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Markets.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Markets.java deleted file mode 100644 index bb233047f3..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Markets.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.panes; - -public class Markets { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Mercenary.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Mercenary.java deleted file mode 100644 index be52b82fdd..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Mercenary.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.panes; - -public class Mercenary { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/NameAndPortraitGeneration.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/NameAndPortraitGeneration.java deleted file mode 100644 index be1fe0f447..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/NameAndPortraitGeneration.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.panes; - -public class NameAndPortraitGeneration { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Personnel.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Personnel.java deleted file mode 100644 index 00945dfc3a..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Personnel.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.panes; - -public class Personnel { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RandomAssignmentTables.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RandomAssignmentTables.java deleted file mode 100644 index 32eec20c88..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RandomAssignmentTables.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.panes; - -public class RandomAssignmentTables { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RankSystems.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RankSystems.java deleted file mode 100644 index cf5d2d84bd..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RankSystems.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.panes; - -public class RankSystems { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RepairAndMaintenance.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RepairAndMaintenance.java deleted file mode 100644 index e3dacee96b..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/RepairAndMaintenance.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.panes; - -public class RepairAndMaintenance { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Rulesets.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Rulesets.java deleted file mode 100644 index 86f38918af..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Rulesets.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.panes; - -public class Rulesets { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SPAs.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SPAs.java deleted file mode 100644 index 57d7565004..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SPAs.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.panes; - -public class SPAs { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SkillRandomization.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SkillRandomization.java deleted file mode 100644 index 3c7fbe381a..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SkillRandomization.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.panes; - -public class SkillRandomization { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Skills.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Skills.java deleted file mode 100644 index 74d69ab1a2..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/Skills.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.panes; - -public class Skills { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SuppliesAndAcquisition.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SuppliesAndAcquisition.java deleted file mode 100644 index b42c9d3785..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/SuppliesAndAcquisition.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.panes; - -public class SuppliesAndAcquisition { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/TechLimits.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/TechLimits.java deleted file mode 100644 index 365ba2bac3..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/TechLimits.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.panes; - -public class TechLimits { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/TurnoverAndRetention.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/TurnoverAndRetention.java deleted file mode 100644 index 62107f73da..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/TurnoverAndRetention.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.panes; - -public class TurnoverAndRetention { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Experience.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Experience.java new file mode 100644 index 0000000000..9eaf5e2c92 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Experience.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +public class Experience { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Finances.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Finances.java new file mode 100644 index 0000000000..f9731c7db1 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Finances.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +public class Finances { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java similarity index 95% rename from MekHQ/src/mekhq/gui/panes/campaignOptions/panes/GeneralTab.java rename to MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java index b35ab0e07d..f46b15fca4 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/panes/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java @@ -1,4 +1,4 @@ -package mekhq.gui.panes.campaignOptions.panes; +package mekhq.gui.panes.campaignOptions.tabs; import megamek.client.ui.baseComponents.MMComboBox; import megamek.client.ui.dialogs.CamoChooserDialog; @@ -40,7 +40,6 @@ public class GeneralTab extends AbstractMHQTabbedPane { private JTextField txtName; private JButton btnNameGenerator; private JLabel lblFaction; - private DefaultComboBoxModel factionModel; private MMComboBox comboFaction; private JLabel lblReputation; private MMComboBox unitRatingMethodCombo; @@ -74,7 +73,8 @@ public GeneralTab(Campaign campaign, JFrame frame, String name) { */ public AbstractMHQScrollablePanel createGeneralTab() { // Promotional Image - JPanel imagePanel = createImagePanel(); + JPanel imagePanel = createHeaderPanel("General", "data/images/misc/MekHQ.png", + null, false, ""); // Campaign name Map nameFields = createLabeledTextField("Name", null, @@ -202,7 +202,12 @@ public AbstractMHQScrollablePanel createGeneralTab() { return generalPanel; } - public JPanel createImagePanel() { + /** + * Creates a header panel with an image and a label. + * + * @return the created header panel as a {@link JPanel} + */ + private JPanel () { ImageIcon imageIcon = new ImageIcon("data/images/misc/MekHQ.png"); JLabel imageLabel = new JLabel(imageIcon); @@ -215,12 +220,12 @@ public JPanel createImagePanel() { layout.setVerticalGroup( layout.createSequentialGroup() .addComponent(lblWelcome) - .addComponent(imageLabel)); // Added imageLabel instead + .addComponent(imageLabel)); layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) .addComponent(lblWelcome) - .addComponent(imageLabel)); // Added imageLabel instead + .addComponent(imageLabel)); return panel; } @@ -233,7 +238,7 @@ protected void initialize() { btnNameGenerator = new JButton(); lblFaction = new JLabel(); - factionModel = new DefaultComboBoxModel<>(); + DefaultComboBoxModel factionModel = new DefaultComboBoxModel<>(); factionModel.addAll(FactionDisplay.getSortedValidFactionDisplays( Factions.getInstance().getChoosableFactions(), campaign.getLocalDate())); comboFaction = new MMComboBox<>("comboFaction", factionModel); @@ -271,7 +276,7 @@ private void btnDateActionPerformed(ActionEvent actionEvent) { } /** - * Sets the date for the {@link GeneralTab}. + * Sets the date for the {@link RepairAndMaintenanceTab}. * This method is called when the "btnDate" button is clicked. * It shows a date chooser dialog and sets the selected date if the user chooses a date. * diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePaths.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePaths.java new file mode 100644 index 0000000000..6f9addcc18 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePaths.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +public class LifePaths { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Markets.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Markets.java new file mode 100644 index 0000000000..9b9a90d454 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Markets.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +public class Markets { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Mercenary.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Mercenary.java new file mode 100644 index 0000000000..b68a33b17d --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Mercenary.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +public class Mercenary { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/NameAndPortraitGeneration.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/NameAndPortraitGeneration.java new file mode 100644 index 0000000000..562c863d63 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/NameAndPortraitGeneration.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +public class NameAndPortraitGeneration { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Personnel.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Personnel.java new file mode 100644 index 0000000000..3de0271fde --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Personnel.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +public class Personnel { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RandomAssignmentTables.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RandomAssignmentTables.java new file mode 100644 index 0000000000..0438307d3c --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RandomAssignmentTables.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +public class RandomAssignmentTables { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RankSystems.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RankSystems.java new file mode 100644 index 0000000000..8c2b309489 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RankSystems.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +public class RankSystems { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Rulesets.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Rulesets.java new file mode 100644 index 0000000000..03b348d23f --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Rulesets.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +public class Rulesets { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SPAs.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SPAs.java new file mode 100644 index 0000000000..999f496294 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SPAs.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +public class SPAs { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SkillRandomization.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SkillRandomization.java new file mode 100644 index 0000000000..8ab0fecf3f --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SkillRandomization.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +public class SkillRandomization { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Skills.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Skills.java new file mode 100644 index 0000000000..467e2df132 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Skills.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +public class Skills { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisition.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisition.java new file mode 100644 index 0000000000..74cda2c8c9 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisition.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +public class SuppliesAndAcquisition { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimits.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimits.java new file mode 100644 index 0000000000..bd62eb0dae --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimits.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +public class TechLimits { +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetention.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetention.java new file mode 100644 index 0000000000..93f1a71445 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetention.java @@ -0,0 +1,4 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +public class TurnoverAndRetention { +} From bcd4f2dff8d629dd07e035c88343e56f8031ffea Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 30 Sep 2024 23:19:24 -0500 Subject: [PATCH 007/117] Add Repair and Maintenance tab with detailed options Enhanced campaign options dialog by adding a Repair and Maintenance tab. Implemented detailed options for repair and maintenance settings, including various checkboxes and spinners. --- .../NEWCampaignOptionsDialog.properties | 95 ++++-- .../CampaignOptionsDialogController.java | 118 +++++-- .../campaignOptions/tabs/GeneralTab.java | 54 +-- .../tabs/RepairAndMaintenanceTab.java | 320 ++++++++++++++++++ 4 files changed, 507 insertions(+), 80 deletions(-) create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 38c4bb6ac4..e841041121 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -15,26 +15,81 @@ presetDialogCancel.name=Cancel presetDialogCancel.tooltip=This is placeholder text for a tooltip ## General Tab Class -# createGeneralTab generalPanel.title=General Information -lblWelcome.text=Welcome, Commander -lblWelcome.tooltip=Blake is watching. -Name.text=Unit Name -Name.tooltip=Name -btnNameGenerator.text=Regenerate Name -btnNameGenerator.tooltip=Name Generator -lblFaction.text=Unit Faction -lblFaction.tooltip=Faction -lblReputation.text=Reputation -lblReputation.tooltip=Reputation -ManualUnitRatingModifier.text=Manual Modifier -ManualUnitRatingModifier.tooltip=ManualUnitRatingModifier -lblDate.text=Start Date -lblDate.tooltip=lblDate -lblCamo.text=Unit Camouflage -lblCamo.tooltip=lblCamo -lblIcon.text=Unit Insignia -lblIcon.tooltip=lblIcon + +# createGeneralTab +lblGeneral.text=Welcome, Commander +Name.text=Unit Name +Name.tooltip=PLACEHOLDER +btnNameGenerator.text=Regenerate Name +btnNameGenerator.tooltip=PLACEHOLDER +lblFaction.text=Unit Faction +lblFaction.tooltip=PLACEHOLDER +lblReputation.text=Reputation +lblReputation.tooltip=PLACEHOLDER +ManualUnitRatingModifier.text=Manual Modifier +ManualUnitRatingModifier.tooltip=PLACEHOLDER +lblDate.text=Start Date +lblDate.tooltip=PLACEHOLDER +lblCamo.text=Unit Camouflage +lblCamo.tooltip=PLACEHOLDER +lblIcon.text=Unit Insignia +lblIcon.tooltip=PLACEHOLDER ## RepairAndMaintenanceTab -# create +RepairAndMaintenancePanel.title=Repairs and Maintenance + +# createRepairTab +repairTab.title=Repairs +lblRepairTab.text=Repair Options +lblRepairTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Nisl senectus neque sem maximus\ + \ accumsan nibh curae dapibus. Asuspendisse ullamcorper aliquet aliquet pretium duis litora porttitor.\ + \ Tristique ex per aptent cras augue mus suspendisse inceptos hac. Amet ultricies sem dui etiam justo.\ + \ Efficitur ac nisl maecenas eu ac tincidunt. Eget felis hendrerit lacinia commodo eu natoque id\ + \ himenaeos nibh. +useEraModsCheckBox.text=Use Era Modifiers for Repair Rolls +useEraModsCheckBox.tooltip=PLACEHOLDER +assignedTechFirstCheckBox.text=Place Assigned Technicians to the Top of the List +assignedTechFirstCheckBox.tooltip=PLACEHOLDER +resetToFirstTechCheckBox.text=After Repairs Jump to the Technician at the Top of the List +resetToFirstTechCheckBox.tooltip=PLACEHOLDER +useQuirksBox.text=Use Quirks +useQuirksBox.tooltip=PLACEHOLDER +useAeroSystemHitsBox.text=Damage Aero System Parts by Hits Taken +useAeroSystemHitsBox.tooltip=PLACEHOLDER +useDamageMargin.text=Damage Parts by Margin of Failure +useDamageMargin.tooltip=PLACEHOLDER +DamageMargin.text=Margin +DamageMargin.tooltip=PLACEHOLDER +DestroyPartTarget.text=Equipment hit in battle survive on a +DestroyPartTarget.tooltip=PLACEHOLDER + +# createMaintenanceTab +maintenanceTab.title=Maintenance +lblMaintenanceTab.text=Maintenance Options +lblMaintenanceTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Nisl senectus neque\ + \ sem maximus accumsan nibh curae dapibus. Asuspendisse ullamcorper aliquet aliquet pretium duis\ + \ litora porttitor.Tristique ex per aptent cras augue mus suspendisse inceptos hac. Amet ultricies\ + \ sem dui etiam justo. Efficitur ac nisl maecenas eu ac tincidunt. Eget felis hendrerit lacinia\ + \ commodo eu natoque id himenaeos nibh. +checkMaintenance.text=Enable Unit Maintenance +checkMaintenance.tooltip=PLACEHOLDER +MaintenanceDays.text=Base Maintenance Cycle +MaintenanceDays.tooltip=PLACEHOLDER +MaintenanceBonus.text=Maintenance Modifier +MaintenanceBonus.tooltip=PLACEHOLDER +DefaultMaintenanceTime.text=Default Maintenance Time +DefaultMaintenanceTime.tooltip=PLACEHOLDER +useQualityMaintenance.text=Use Quality Modifiers +useQualityMaintenance.tooltip=PLACEHOLDER +reverseQualityNames.text=Reverse Quality Names +reverseQualityNames.tooltip=PLACEHOLDER +chkUseRandomUnitQualities.text=Random New Unit Quality +chkUseRandomUnitQualities.tooltip=PLACEHOLDER +chkUsePlanetaryModifiers.text=Use Planetary Modifiers +chkUsePlanetaryModifiers.tooltip=PLACEHOLDER +useUnofficialMaintenance.text=Only Damage F-Rated Equipment +useUnofficialMaintenance.tooltip=PLACEHOLDER +logMaintenance.text=Write Maintenance Results to MekHQ.log +logMaintenance.tooltip=PLACEHOLDER + diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsDialogController.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsDialogController.java index 9b0246aee9..824ba8056e 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsDialogController.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsDialogController.java @@ -8,7 +8,10 @@ import mekhq.gui.panes.campaignOptions.tabs.RepairAndMaintenanceTab; import javax.swing.*; +import javax.swing.GroupLayout.Alignment; import java.awt.*; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.ResourceBundle; @@ -20,8 +23,9 @@ public class CampaignOptionsDialogController extends AbstractMHQTabbedPane { private static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE); private final Campaign campaign; + final static int WIDTH_MULTIPLIER = 3; // This seems to be the sweet spot - public CampaignOptionsDialogController(final JFrame frame, final Campaign campaign, final boolean startup) { + public CampaignOptionsDialogController(final JFrame frame, final Campaign campaign) { super(frame, resources, "campaignOptionsDialog"); this.campaign = campaign; @@ -30,11 +34,19 @@ public CampaignOptionsDialogController(final JFrame frame, final Campaign campai @Override protected void initialize() { + // General GeneralTab generalTab = new GeneralTab(campaign, getFrame(), "generalTab"); - addTab(String.format("%s", resources.getString("generalPanel.title")), - generalTab.createGeneralTab()); - - setPreferences(); + addTab(String.format("%s", 4, + resources.getString("generalPanel.title")), generalTab.createGeneralTab()); + + // Repair and Maintenance + RepairAndMaintenanceTab repairAndMaintenanceTab = new RepairAndMaintenanceTab(getFrame(), + "repairAndMaintenanceTab"); + JTabbedPane repairAndMaintenanceContentTabs = createSubTabs(Map.of( + "repairTab", repairAndMaintenanceTab.createRepairTab(), + "maintenanceTab", repairAndMaintenanceTab.createMaintenanceTab())); + addTab(String.format("%s", 4, + resources.getString("RepairAndMaintenancePanel.title")), repairAndMaintenanceContentTabs); } private void setOptions() { @@ -61,7 +73,7 @@ private void updateOptions() { public static JCheckBox createCheckBox(String name, @Nullable Integer customWrapSize) { customWrapSize = processWrapSize(customWrapSize); - JCheckBox checkBox = new JCheckBox(String.format("%s", + JCheckBox checkBox = new JCheckBox(String.format("%s", resources.getString(name + ".text"))); checkBox.setToolTipText(wordWrap(resources.getString(name + ".tooltip"), customWrapSize)); checkBox.setName(name); @@ -93,7 +105,7 @@ public static Map createLabeledSpinner(String name, @Nullable double maximum, double stepSize) { customWrapSize = processWrapSize(customWrapSize); - final JLabel jLabel = new JLabel(String.format("%s", + final JLabel jLabel = new JLabel(String.format("%s", resources.getString(name + ".text"))); jLabel.setToolTipText(wordWrap(resources.getString(name + ".tooltip"), customWrapSize)); jLabel.setName("lbl" + name); @@ -102,6 +114,13 @@ public static Map createLabeledSpinner(String name, @Nullable jSpinner.setToolTipText(wordWrap(resources.getString(name + ".tooltip"), customWrapSize)); jSpinner.setName("spn" + name); + FontMetrics fontMetrics = jSpinner.getFontMetrics(jSpinner.getFont()); + int width = fontMetrics.stringWidth(Double.toString(maximum)); + width = width * WIDTH_MULTIPLIER; + + jSpinner.setMaximumSize(new Dimension(width, 30)); + jSpinner.setMinimumSize(new Dimension(width, 30)); + return Map.of(jLabel, jSpinner); } @@ -121,7 +140,7 @@ public static Map createLabeledSpinner(String name, @Nullable public static JLabel createLabel(String name, @Nullable Integer customWrapSize) { customWrapSize = processWrapSize(customWrapSize); - JLabel jLabel = new JLabel(String.format("%s", + JLabel jLabel = new JLabel(String.format("%s", resources.getString(name + ".text"))); jLabel.setToolTipText(wordWrap(resources.getString(name + ".tooltip"), customWrapSize)); jLabel.setName(name); @@ -157,7 +176,7 @@ public static Map createLabeledTextField(String name, @Nullable Integer maximumSizeHeight) { customWrapSize = processWrapSize(customWrapSize); - JLabel jLabel = new JLabel(String.format("%s", + JLabel jLabel = new JLabel(String.format("%s", resources.getString(name + ".text"))); jLabel.setToolTipText(wordWrap(resources.getString(name + ".tooltip"), customWrapSize)); jLabel.setName("lbl" + name); @@ -208,7 +227,7 @@ public static JPanel createStandardPanel(String name, boolean includeBorder, Str if (includeBorder) { panel.setBorder(BorderFactory.createTitledBorder( - String.format(String.format("%s", borderTitle)))); + String.format(String.format("%s", borderTitle)))); } panel.setName(name); @@ -216,27 +235,36 @@ public static JPanel createStandardPanel(String name, boolean includeBorder, Str return panel; } - /** * Creates a {@link JPanel} consisting of a {@link JLabel} above an image. + * If {@code includeBodyText} is {@code true} a second {@link JLabel} is placed after the first. * * @param name the name of the header panel. * The {@link JLabel} will have 'lbl' appended. This will be appended with * '.text' to fetch the label contents from the resource bundle. * The {@link JPanel} is appended with 'txt'. * @param imageAddress the file path of the image to be displayed in the panel - * @param customWrapSize the maximum number of characters (including whitespaces) on each line - * of the tooltip; defaults to 100 if {@code null} * @param includeBorder whether the panel should have a border * @param borderTitle the title of the border; can be empty for an untitled border + * @param includeBodyText if {@code true}, include a second {@link JLabel} named {@code name + "Body"}. + * The resource bundle reference is {@code name + "Body.text"} * @return a JPanel representing the header panel */ - public static JPanel createHeaderPanel(String name, String imageAddress, Integer customWrapSize, - boolean includeBorder, String borderTitle) { + public static JPanel createHeaderPanel(String name, String imageAddress, boolean includeBorder, + String borderTitle, boolean includeBodyText) { ImageIcon imageIcon = new ImageIcon(imageAddress); JLabel imageLabel = new JLabel(imageIcon); - final JLabel lblWelcome = createLabel("lbl" + name, customWrapSize); + final JLabel lblHeader = new JLabel(String.format("%s", + resources.getString("lbl" + name + ".text")), SwingConstants.CENTER); + lblHeader.setName("lbl" + name); + + JLabel lblBody = new JLabel(); + if (includeBodyText) { + lblBody = new JLabel(String.format("%s", + resources.getString("lbl" + name + "Body.text")), SwingConstants.CENTER); + lblHeader.setName("lbl" + name); + } final JPanel panel = createStandardPanel("pnl" + name, includeBorder, borderTitle); final GroupLayout layout = createStandardLayout(panel); @@ -244,12 +272,14 @@ public static JPanel createHeaderPanel(String name, String imageAddress, Integer layout.setVerticalGroup( layout.createSequentialGroup() - .addComponent(lblWelcome) + .addComponent(lblHeader) + .addComponent(lblBody) .addComponent(imageLabel)); layout.setHorizontalGroup( - layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(lblWelcome) + layout.createParallelGroup(Alignment.CENTER) + .addComponent(lblHeader) + .addComponent(lblBody) .addComponent(imageLabel)); return panel; @@ -270,4 +300,54 @@ public static GroupLayout createStandardLayout(JPanel panel) { return layout; } + /** + * Creates a parent panel for the provided {@link JPanel} with a specified name, maximum width, + * and maximum height. + * + * @param panel the panel to be added to the parent panel + * @param name the name of the parent panel + * @param maximumWidth the maximum width of the parent panel + * @param maximumHeight the maximum height of the parent panel + * @return the created {@link JPanel} + */ + public static JPanel createParentPanel(JPanel panel, String name, int maximumWidth, int maximumHeight) { + final JPanel parentPanel = createStandardPanel(name, true, ""); + final GroupLayout parentLayout = createStandardLayout(parentPanel); + Dimension preferredSize = new Dimension(maximumWidth, maximumHeight); + panel.setMaximumSize(preferredSize); + parentPanel.setLayout(parentLayout); + + parentLayout.setVerticalGroup( + parentLayout.createSequentialGroup() + .addComponent(panel)); + + parentLayout.setHorizontalGroup( + parentLayout.createParallelGroup(Alignment.LEADING) + .addComponent(panel)); + + return parentPanel; + } + + /** + * Creates a new instance of {@link JTabbedPane} with the supplied panels as tabs. + * + * @param panels a map containing the names of the panels as keys and the corresponding + * {@link JPanel} objects as values + * @return a {@link JTabbedPane} with the supplied panels as tabs + */ + public static JTabbedPane createSubTabs(Map panels) { + // We use a list here to ensure that the tabs always display in the same order, + // and that order might as well be alphabetic. + List tabNames = new ArrayList<>(panels.keySet()); + tabNames.sort(String.CASE_INSENSITIVE_ORDER); + + JTabbedPane tabbedPane = new JTabbedPane(); + + for (String tabName : tabNames) { + JPanel panel = panels.get(tabName); + tabbedPane.addTab(resources.getString(panel.getName() + ".title"), panel); + } + + return tabbedPane; + } } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java index f46b15fca4..5c01342781 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java @@ -74,7 +74,7 @@ public GeneralTab(Campaign campaign, JFrame frame, String name) { public AbstractMHQScrollablePanel createGeneralTab() { // Promotional Image JPanel imagePanel = createHeaderPanel("General", "data/images/misc/MekHQ.png", - null, false, ""); + false, "", false); // Campaign name Map nameFields = createLabeledTextField("Name", null, @@ -94,11 +94,14 @@ public AbstractMHQScrollablePanel createGeneralTab() { // Campaign faction lblFaction = createLabel("lblFaction", null); comboFaction.setSelectedItem(new FactionDisplay(campaign.getFaction(), campaign.getLocalDate())); - comboFaction.setMinimumSize(new Dimension(200, 30)); - comboFaction.setPreferredSize(new Dimension(200, 30)); + comboFaction.setMinimumSize(new Dimension(275, 30)); + comboFaction.setMaximumSize(new Dimension(275, 30)); // Reputation lblReputation = createLabel("lblReputation", null); + unitRatingMethodCombo.setMinimumSize(new Dimension(150, 30)); + unitRatingMethodCombo.setMaximumSize(new Dimension(150, 30)); + Map manualReputationModifierFields = createLabeledSpinner( "ManualUnitRatingModifier", null, 0, -200, 200, 1); @@ -110,22 +113,20 @@ public AbstractMHQScrollablePanel createGeneralTab() { // Date lblDate = createLabel("lblDate", null); btnDate.setName("btnDate"); - btnDate.setMinimumSize(new Dimension(200, 30)); - btnDate.setPreferredSize(new Dimension(200, 30)); + btnDate.setMinimumSize(new Dimension(100, 30)); + btnDate.setMaximumSize(new Dimension(100, 30)); btnDate.addActionListener(this::btnDateActionPerformed); // Camouflage lblCamo = createLabel("lblCamo", null); btnCamo.setName("btnCamo"); btnCamo.setMinimumSize(new Dimension(84, 72)); - btnCamo.setPreferredSize(new Dimension(84, 72)); btnCamo.setMaximumSize(new Dimension(84, 72)); btnCamo.addActionListener(this::btnCamoActionPerformed); // Unit icon lblIcon = createLabel("lblIcon", null); btnIcon.setMinimumSize(new Dimension(84, 72)); - btnIcon.setPreferredSize(new Dimension(84, 72)); btnIcon.setMaximumSize(new Dimension(84, 72)); btnIcon.addActionListener(evt -> { final UnitIconDialog unitIconDialog = new UnitIconDialog(getFrame(), unitIcon); @@ -165,15 +166,14 @@ public AbstractMHQScrollablePanel createGeneralTab() { .addComponent(btnDate, Alignment.LEADING)) .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(lblCamo) - .addComponent(btnCamo, Alignment.LEADING) + .addComponent(btnCamo, Alignment.LEADING)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(lblIcon) .addComponent(btnIcon, Alignment.LEADING))); layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGap(125) - .addComponent(imagePanel)) + .addComponent(imagePanel) .addGroup(layout.createSequentialGroup() .addComponent(lblName) .addComponent(txtName) @@ -192,8 +192,8 @@ public AbstractMHQScrollablePanel createGeneralTab() { .addComponent(btnDate)) .addGroup(layout.createSequentialGroup() .addComponent(lblCamo) - .addComponent(btnCamo) - .addGap(100) + .addComponent(btnCamo)) + .addGroup(layout.createSequentialGroup() .addComponent(lblIcon) .addComponent(btnIcon))); @@ -202,34 +202,6 @@ public AbstractMHQScrollablePanel createGeneralTab() { return generalPanel; } - /** - * Creates a header panel with an image and a label. - * - * @return the created header panel as a {@link JPanel} - */ - private JPanel () { - ImageIcon imageIcon = new ImageIcon("data/images/misc/MekHQ.png"); - JLabel imageLabel = new JLabel(imageIcon); - - final JLabel lblWelcome = createLabel("lblWelcome", null); - - final JPanel panel = createStandardPanel("imagePanel", false, ""); - final GroupLayout layout = createStandardLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(lblWelcome) - .addComponent(imageLabel)); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(lblWelcome) - .addComponent(imageLabel)); - - return panel; - } - @Override protected void initialize() { lblName = new JLabel(); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java new file mode 100644 index 0000000000..3090560ade --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java @@ -0,0 +1,320 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +import mekhq.MekHQ; +import mekhq.gui.baseComponents.AbstractMHQScrollablePanel; +import mekhq.gui.baseComponents.AbstractMHQTabbedPane; + +import javax.swing.*; +import javax.swing.GroupLayout.Alignment; +import java.util.Map; +import java.util.Map.Entry; +import java.util.ResourceBundle; + +import static mekhq.gui.panes.campaignOptions.CampaignOptionsDialogController.*; + +public class RepairAndMaintenanceTab extends AbstractMHQTabbedPane { + // region Variable Declarations + private static String RESOURCE_PACKAGE = "mekhq/resources/NEWCampaignOptionsDialog"; + private static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE, + MekHQ.getMHQOptions().getLocale()); + + //start Repair Tab + private JCheckBox useEraModsCheckBox; + private JCheckBox assignedTechFirstCheckBox; + private JCheckBox resetToFirstTechCheckBox; + private JCheckBox useQuirksBox; + private JCheckBox useAeroSystemHitsBox; + private JCheckBox useDamageMargin; + private JLabel lblDamageMargin; + private JSpinner spnDamageMargin; + private JLabel lblDestroyPartTarget; + private JSpinner spnDestroyPartTarget; + //end Repair Tab + + //start Maintenance Tab + private JCheckBox checkMaintenance; + private JLabel lblMaintenanceDays; + private JSpinner spnMaintenanceDays; + private JLabel lblMaintenanceBonus; + private JSpinner spnMaintenanceBonus; + private JLabel lblDefaultMaintenanceTime; + private JSpinner spnDefaultMaintenanceTime; + private JCheckBox useQualityMaintenance; + private JCheckBox reverseQualityNames; + private JCheckBox chkUseRandomUnitQualities; + private JCheckBox chkUsePlanetaryModifiers; + private JCheckBox useUnofficialMaintenance; + private JCheckBox logMaintenance; + //end Maintenance Tab + + public RepairAndMaintenanceTab(JFrame frame, String name) { + super(frame, name); + + initialize(); + } + + /** + * Creates the general tab. + * + * @return the created general tab as an {@link AbstractMHQScrollablePanel} + */ + public JTabbedPane createRepairAndMaintenanceTab() { + JTabbedPane tabbedPane = new JTabbedPane(); + + JPanel repairPanel = createRepairTab(); + tabbedPane.addTab("Repair", repairPanel); + + JPanel maintenancePanel = createMaintenanceTab(); + tabbedPane.addTab("Maintenance", maintenancePanel); + + return tabbedPane; + } + + /** + * Creates the repair tab panel. + * + * @return the created repair tab panel as a {@link JPanel} + */ + public JPanel createRepairTab() { + // Header + JPanel imagePanel = createHeaderPanel("RepairTab", + "data/images/universe/factions/logo_aurigan_coalition.png", false, + "", true); + + // Era Mods + useEraModsCheckBox = createCheckBox("useEraModsCheckBox", null); + + // Tech Placement + assignedTechFirstCheckBox = createCheckBox("assignedTechFirstCheckBox", null); + resetToFirstTechCheckBox = createCheckBox("resetToFirstTechCheckBox", null); + + // Use Quirks + useQuirksBox = createCheckBox("useQuirksBox", null); + + // Aero System Damage + useAeroSystemHitsBox = createCheckBox("useAeroSystemHitsBox", null); + + // Damage by Margin + useDamageMargin = createCheckBox("useDamageMargin", null); + useDamageMargin.addActionListener(evt -> spnDamageMargin.setEnabled(useDamageMargin.isSelected())); + Map damageMarginFields = createLabeledSpinner("DamageMargin", + null, 1, 1, 20, 1); + for (Entry entry : damageMarginFields.entrySet()) { + lblDamageMargin = entry.getKey(); + spnDamageMargin = entry.getValue(); + } + + // Equipment Survival + Map DestroyPartTargetFields = createLabeledSpinner("DestroyPartTarget", + null, 2, 2, 13, 1); + for (Entry entry : DestroyPartTargetFields.entrySet()) { + lblDestroyPartTarget = entry.getKey(); + spnDestroyPartTarget = entry.getValue(); + } + + // Layout the Panel + final JPanel panel = createStandardPanel("repairTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(imagePanel) + .addComponent(useEraModsCheckBox) + .addComponent(assignedTechFirstCheckBox) + .addComponent(resetToFirstTechCheckBox) + .addComponent(useQuirksBox) + .addComponent(useAeroSystemHitsBox) + .addComponent(useDamageMargin) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(spnDamageMargin) + .addComponent(lblDamageMargin, Alignment.LEADING)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(spnDestroyPartTarget) + .addComponent(lblDestroyPartTarget, Alignment.LEADING))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(imagePanel) + .addComponent(useEraModsCheckBox) + .addComponent(assignedTechFirstCheckBox) + .addComponent(resetToFirstTechCheckBox) + .addComponent(useQuirksBox) + .addComponent(useAeroSystemHitsBox) + .addComponent(useDamageMargin) + .addGroup(layout.createSequentialGroup() + .addComponent(spnDamageMargin) + .addComponent(lblDamageMargin)) + .addGroup(layout.createSequentialGroup() + .addComponent(spnDestroyPartTarget) + .addComponent(lblDestroyPartTarget))); + + // Create Parent Panel and return + return createParentPanel(panel, "repairTab", 500, 500); + } + + /** + * Creates the maintenance tab panel. + * + * @return The created maintenance tab panel as a {@link JPanel}. + */ + public JPanel createMaintenanceTab() { + // Promotional Image + JPanel imagePanel = createHeaderPanel("MaintenanceTab", + "data/images/universe/factions/logo_clan_blood_spirit.png", + false, "", true); + + // Check Maintenance + checkMaintenance = createCheckBox("checkMaintenance", null); + + // Maintenance Cycle Duration + Map maintenanceDaysFields = createLabeledSpinner("MaintenanceDays", + null, 7, 1, 365, 1); + for (Entry entry : maintenanceDaysFields.entrySet()) { + lblMaintenanceDays = entry.getKey(); + spnMaintenanceDays = entry.getValue(); + } + + // Maintenance Bonus + Map maintenanceBonusFields = createLabeledSpinner("MaintenanceBonus", + null, 0, -13, 13, 1); + for (Entry entry : maintenanceBonusFields.entrySet()) { + lblMaintenanceBonus = entry.getKey(); + spnMaintenanceBonus = entry.getValue(); + } + + // Default Maintenance Time + Map defaultMaintenanceTimeFields = createLabeledSpinner("DefaultMaintenanceTime", + null, 1, 1, 4, 1); + for (Entry entry : defaultMaintenanceTimeFields.entrySet()) { + lblDefaultMaintenanceTime = entry.getKey(); + spnDefaultMaintenanceTime = entry.getValue(); + } + + // Use Quality Modifiers + useQualityMaintenance = createCheckBox("useQualityMaintenance", null); + + // Reverse Quality names + reverseQualityNames = createCheckBox("reverseQualityNames", null); + + // Use Random Unit Qualities + chkUseRandomUnitQualities = createCheckBox("chkUseRandomUnitQualities", null); + + // Use Planetary Modifiers + chkUsePlanetaryModifiers = createCheckBox("chkUsePlanetaryModifiers", null); + + // Only Damage F-Rated Equipment + useUnofficialMaintenance = createCheckBox("useUnofficialMaintenance", null); + + // Report Maintenance checks to Log + logMaintenance = createCheckBox("logMaintenance", null); + + // Layout the Panel + final JPanel panel = createStandardPanel("repairTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(imagePanel) + .addComponent(checkMaintenance) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(spnMaintenanceDays) + .addComponent(lblMaintenanceDays, Alignment.LEADING)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(spnMaintenanceBonus) + .addComponent(lblMaintenanceBonus, Alignment.LEADING)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(spnDefaultMaintenanceTime) + .addComponent(lblDefaultMaintenanceTime, Alignment.LEADING)) + .addComponent(useQualityMaintenance) + .addComponent(reverseQualityNames) + .addComponent(chkUseRandomUnitQualities) + .addComponent(chkUsePlanetaryModifiers) + .addComponent(useUnofficialMaintenance) + .addComponent(logMaintenance)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(imagePanel) + .addComponent(checkMaintenance) + .addGroup(layout.createSequentialGroup() + .addComponent(spnMaintenanceDays) + .addComponent(lblMaintenanceDays)) + .addGroup(layout.createSequentialGroup() + .addComponent(spnMaintenanceBonus) + .addComponent(lblMaintenanceBonus)) + .addGroup(layout.createSequentialGroup() + .addComponent(spnDefaultMaintenanceTime) + .addComponent(lblDefaultMaintenanceTime)) + .addComponent(useQualityMaintenance) + .addComponent(reverseQualityNames) + .addComponent(chkUseRandomUnitQualities) + .addComponent(chkUsePlanetaryModifiers) + .addComponent(useUnofficialMaintenance) + .addComponent(logMaintenance)); + + // Create Parent Panel and return + return createParentPanel(panel, "maintenanceTab", 500, 500); + } + + private void recreateFinancesPanel(boolean isReversingQualityNames) { + // TODO handle this + } + + @Override + protected void initialize() { + initializeRepairTab(); + initializeMaintenanceTab(); + } + + /** + * Initializes the repair tab by creating and initializing various UI components. + */ + private void initializeRepairTab() { + useEraModsCheckBox = new JCheckBox(); + + assignedTechFirstCheckBox = new JCheckBox(); + + resetToFirstTechCheckBox = new JCheckBox(); + + useQuirksBox = new JCheckBox(); + + useAeroSystemHitsBox = new JCheckBox(); + + useDamageMargin = new JCheckBox(); + lblDamageMargin = new JLabel(); + spnDamageMargin = new JSpinner(); + + lblDestroyPartTarget = new JLabel(); + spnDestroyPartTarget = new JSpinner(); + } + + /** + * Initializes the maintenance tab by creating and initializing various UI components. + */ + private void initializeMaintenanceTab() { + checkMaintenance = new JCheckBox(); + + lblMaintenanceDays = new JLabel(); + spnMaintenanceDays = new JSpinner(); + + lblMaintenanceBonus = new JLabel(); + spnMaintenanceBonus = new JSpinner(); + + lblDefaultMaintenanceTime = new JLabel(); + spnDefaultMaintenanceTime = new JSpinner(); + + useQualityMaintenance = new JCheckBox(); + + reverseQualityNames = new JCheckBox(); + + chkUseRandomUnitQualities = new JCheckBox(); + + chkUsePlanetaryModifiers = new JCheckBox(); + + useUnofficialMaintenance = new JCheckBox(); + + logMaintenance = new JCheckBox(); + } +} From 71396a0838be2b874b4f6e21fd5e3e1c7dd7f2aa Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 1 Oct 2024 08:29:34 -0500 Subject: [PATCH 008/117] Refactor CampaignOptionsDialog for new Controller Replaced CampaignOptionsPane with CampaignOptionsDialogController to streamline campaign options management. Commented out methods related to the old pane's options handling to avoid conflicts. Added Javadoc comments to GeneralTab to improve code documentation. --- .../gui/dialog/CampaignOptionsDialog.java | 23 ++++++++++--------- .../campaignOptions/tabs/GeneralTab.java | 11 +++++++++ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java b/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java index aff9308063..14f9fa92ba 100644 --- a/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java @@ -27,7 +27,7 @@ import mekhq.campaign.campaignOptions.CampaignPreset; import mekhq.gui.FileDialogs; import mekhq.gui.baseComponents.AbstractMHQValidationButtonDialog; -import mekhq.gui.panes.CampaignOptionsPane; +import mekhq.gui.panes.campaignOptions.CampaignOptionsDialogController; import javax.swing.*; import java.awt.*; @@ -42,7 +42,7 @@ public class CampaignOptionsDialog extends AbstractMHQValidationButtonDialog { //region Variable Declarations private final Campaign campaign; private final boolean startup; - private CampaignOptionsPane campaignOptionsPane; + private CampaignOptionsDialogController campaignOptionsPane; //endregion Variable Declarations //region Constructors @@ -77,11 +77,11 @@ public boolean isStartup() { return startup; } - public CampaignOptionsPane getCampaignOptionsPane() { + public CampaignOptionsDialogController getCampaignOptionsPane() { return campaignOptionsPane; } - public void setCampaignOptionsPane(final CampaignOptionsPane campaignOptionsPane) { + public void setCampaignOptionsPane(final CampaignOptionsDialogController campaignOptionsPane) { this.campaignOptionsPane = campaignOptionsPane; } //endregion Getters/Setters @@ -89,7 +89,7 @@ public void setCampaignOptionsPane(final CampaignOptionsPane campaignOptionsPane //region Initialization @Override protected Container createCenterPane() { - setCampaignOptionsPane(new CampaignOptionsPane(getFrame(), getCampaign(), isStartup())); + setCampaignOptionsPane(new CampaignOptionsDialogController(getFrame(), getCampaign())); return getCampaignOptionsPane(); } @@ -168,8 +168,8 @@ private void showStratConNotice() { @Override protected void finalizeInitialization() throws Exception { - getCampaignOptionsPane().setOptions(getCampaign().getCampaignOptions(), - getCampaign().getRandomSkillPreferences()); +// getCampaignOptionsPane().setOptions(getCampaign().getCampaignOptions(), +// getCampaign().getRandomSkillPreferences()); super.finalizeInitialization(); } //endregion Initialization @@ -177,19 +177,20 @@ protected void finalizeInitialization() throws Exception { //region Button Actions @Override protected void okAction() { - getCampaignOptionsPane().updateOptions(); +// getCampaignOptionsPane().updateOptions(); } @Override protected ValidationState validateAction(final boolean display) { - return getCampaignOptionsPane().validateOptions(display); +// return getCampaignOptionsPane().validateOptions(display); + return null; } private void btnSaveActionPerformed() { if (validateAction(true).isFailure()) { return; } - getCampaignOptionsPane().updateOptions(); +// getCampaignOptionsPane().updateOptions(); setResult(DialogResult.CONFIRMED); final CreateCampaignPresetDialog createCampaignPresetDialog @@ -210,6 +211,6 @@ private void btnSaveActionPerformed() { //endregion Button Actions public void applyPreset(final @Nullable CampaignPreset preset) { - getCampaignOptionsPane().applyPreset(preset); +// getCampaignOptionsPane().applyPreset(preset); } } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java index 5c01342781..853c6afff4 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java @@ -28,6 +28,10 @@ import static mekhq.gui.panes.campaignOptions.CampaignOptionsDialogController.*; +/** + * Represents a tab that allows the user to configure general settings for a campaign. + * Extends the {@link AbstractMHQTabbedPane} class. + */ public class GeneralTab extends AbstractMHQTabbedPane { // region Variable Declarations private static String RESOURCE_PACKAGE = "mekhq/resources/NEWCampaignOptionsDialog"; @@ -55,6 +59,13 @@ public class GeneralTab extends AbstractMHQTabbedPane { private JButton btnIcon; private StandardForceIcon unitIcon; + /** + * Constructs a new {@link GeneralTab} object. + * + * @param campaign the campaign object associated with the tab + * @param frame the {@link JFrame} object that contains the tab + * @param name the name of the tab + */ public GeneralTab(Campaign campaign, JFrame frame, String name) { super(frame, name); From 269bd3d45fb5b65a1ab18a43e78a48e1a2e21f2a Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 1 Oct 2024 09:08:14 -0500 Subject: [PATCH 009/117] Refactored CampaignOptionsDialogController removal Removed CampaignOptionsDialogController and replaced its functionality with CampaignOptionsPane and CampaignOptionsUtilities. This change aimed at modularizing the code, improving maintainability and readability. Updated relevant imports and class usages accordingly. --- .../gui/dialog/CampaignOptionsDialog.java | 10 ++-- .../campaignOptions/CampaignOptionsPane.java | 54 +++++++++++++++++++ ...ler.java => CampaignOptionsUtilities.java} | 51 +++--------------- .../campaignOptions/tabs/GeneralTab.java | 2 +- .../tabs/RepairAndMaintenanceTab.java | 2 +- 5 files changed, 68 insertions(+), 51 deletions(-) create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java rename MekHQ/src/mekhq/gui/panes/campaignOptions/{CampaignOptionsDialogController.java => CampaignOptionsUtilities.java} (86%) diff --git a/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java b/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java index 14f9fa92ba..99b40e7d54 100644 --- a/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java @@ -27,7 +27,7 @@ import mekhq.campaign.campaignOptions.CampaignPreset; import mekhq.gui.FileDialogs; import mekhq.gui.baseComponents.AbstractMHQValidationButtonDialog; -import mekhq.gui.panes.campaignOptions.CampaignOptionsDialogController; +import mekhq.gui.panes.campaignOptions.CampaignOptionsPane; import javax.swing.*; import java.awt.*; @@ -42,7 +42,7 @@ public class CampaignOptionsDialog extends AbstractMHQValidationButtonDialog { //region Variable Declarations private final Campaign campaign; private final boolean startup; - private CampaignOptionsDialogController campaignOptionsPane; + private CampaignOptionsPane campaignOptionsPane; //endregion Variable Declarations //region Constructors @@ -77,11 +77,11 @@ public boolean isStartup() { return startup; } - public CampaignOptionsDialogController getCampaignOptionsPane() { + public CampaignOptionsPane getCampaignOptionsPane() { return campaignOptionsPane; } - public void setCampaignOptionsPane(final CampaignOptionsDialogController campaignOptionsPane) { + public void setCampaignOptionsPane(final CampaignOptionsPane campaignOptionsPane) { this.campaignOptionsPane = campaignOptionsPane; } //endregion Getters/Setters @@ -89,7 +89,7 @@ public void setCampaignOptionsPane(final CampaignOptionsDialogController campaig //region Initialization @Override protected Container createCenterPane() { - setCampaignOptionsPane(new CampaignOptionsDialogController(getFrame(), getCampaign())); + setCampaignOptionsPane(new CampaignOptionsPane(getFrame(), getCampaign())); return getCampaignOptionsPane(); } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java new file mode 100644 index 0000000000..9f0b5f1ee0 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java @@ -0,0 +1,54 @@ +package mekhq.gui.panes.campaignOptions; + +import megamek.logging.MMLogger; +import mekhq.campaign.Campaign; +import mekhq.gui.baseComponents.AbstractMHQTabbedPane; +import mekhq.gui.panes.campaignOptions.tabs.GeneralTab; +import mekhq.gui.panes.campaignOptions.tabs.RepairAndMaintenanceTab; + +import javax.swing.*; +import java.util.Map; +import java.util.ResourceBundle; + +import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.createSubTabs; + +public class CampaignOptionsPane extends AbstractMHQTabbedPane { + private static final MMLogger logger = MMLogger.create(CampaignOptionsPane.class); + private static final String RESOURCE_PACKAGE = "mekhq/resources/NEWCampaignOptionsDialog"; + private static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE); + + private final Campaign campaign; + final static int WIDTH_MULTIPLIER = 3; // This seems to be the sweet spot + + public CampaignOptionsPane(final JFrame frame, final Campaign campaign) { + super(frame, resources, "campaignOptionsDialog"); + this.campaign = campaign; + + initialize(); + } + + @Override + protected void initialize() { + // General + GeneralTab generalTab = new GeneralTab(campaign, getFrame(), "generalTab"); + addTab(String.format("%s", 4, + resources.getString("generalPanel.title")), generalTab.createGeneralTab()); + + // Repair and Maintenance + RepairAndMaintenanceTab repairAndMaintenanceTab = new RepairAndMaintenanceTab(getFrame(), + "repairAndMaintenanceTab"); + JTabbedPane repairAndMaintenanceContentTabs = createSubTabs(Map.of( + "repairTab", repairAndMaintenanceTab.createRepairTab(), + "maintenanceTab", repairAndMaintenanceTab.createMaintenanceTab())); + addTab(String.format("%s", 4, + resources.getString("RepairAndMaintenancePanel.title")), repairAndMaintenanceContentTabs); + } + + private void setOptions() { + // TODO this is where we update the dialog based on current campaign settings. + } + + private void updateOptions() { + // TODO this is where we update campaign values based on the dialog values + } +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsDialogController.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java similarity index 86% rename from MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsDialogController.java rename to MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java index 824ba8056e..b97b07d31c 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsDialogController.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java @@ -2,10 +2,6 @@ import megamek.common.annotations.Nullable; import megamek.logging.MMLogger; -import mekhq.campaign.Campaign; -import mekhq.gui.baseComponents.AbstractMHQTabbedPane; -import mekhq.gui.panes.campaignOptions.tabs.GeneralTab; -import mekhq.gui.panes.campaignOptions.tabs.RepairAndMaintenanceTab; import javax.swing.*; import javax.swing.GroupLayout.Alignment; @@ -17,46 +13,13 @@ import static megamek.client.ui.WrapLayout.wordWrap; -public class CampaignOptionsDialogController extends AbstractMHQTabbedPane { - private static final MMLogger logger = MMLogger.create(CampaignOptionsDialogController.class); +public class CampaignOptionsUtilities { + private static final MMLogger logger = MMLogger.create(CampaignOptionsPane.class); private static final String RESOURCE_PACKAGE = "mekhq/resources/NEWCampaignOptionsDialog"; private static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE); - private final Campaign campaign; final static int WIDTH_MULTIPLIER = 3; // This seems to be the sweet spot - public CampaignOptionsDialogController(final JFrame frame, final Campaign campaign) { - super(frame, resources, "campaignOptionsDialog"); - this.campaign = campaign; - - initialize(); - } - - @Override - protected void initialize() { - // General - GeneralTab generalTab = new GeneralTab(campaign, getFrame(), "generalTab"); - addTab(String.format("%s", 4, - resources.getString("generalPanel.title")), generalTab.createGeneralTab()); - - // Repair and Maintenance - RepairAndMaintenanceTab repairAndMaintenanceTab = new RepairAndMaintenanceTab(getFrame(), - "repairAndMaintenanceTab"); - JTabbedPane repairAndMaintenanceContentTabs = createSubTabs(Map.of( - "repairTab", repairAndMaintenanceTab.createRepairTab(), - "maintenanceTab", repairAndMaintenanceTab.createMaintenanceTab())); - addTab(String.format("%s", 4, - resources.getString("RepairAndMaintenancePanel.title")), repairAndMaintenanceContentTabs); - } - - private void setOptions() { - // TODO this is where we update the dialog based on current campaign settings. - } - - private void updateOptions() { - // TODO this is where we update campaign values based on the dialog values - } - /** * Returns a new {@link JCheckBox} object with the specified name, label, and tooltip. *

@@ -101,8 +64,8 @@ public static JCheckBox createCheckBox(String name, @Nullable Integer customWrap * @return a map containing a {@link JLabel} key and a {@link JSpinner} value. */ public static Map createLabeledSpinner(String name, @Nullable Integer customWrapSize, - double defaultValue, double minimum, - double maximum, double stepSize) { + double defaultValue, double minimum, + double maximum, double stepSize) { customWrapSize = processWrapSize(customWrapSize); final JLabel jLabel = new JLabel(String.format("%s", @@ -171,9 +134,9 @@ public static JLabel createLabel(String name, @Nullable Integer customWrapSize) * @return a map containing a {@link JLabel} key and a {@link JTextField} value. */ public static Map createLabeledTextField(String name, - @Nullable Integer customWrapSize, int minimumSizeWidth, - int minimumSizeHeight, @Nullable Integer maximumSizeWidth, - @Nullable Integer maximumSizeHeight) { + @Nullable Integer customWrapSize, int minimumSizeWidth, + int minimumSizeHeight, @Nullable Integer maximumSizeWidth, + @Nullable Integer maximumSizeHeight) { customWrapSize = processWrapSize(customWrapSize); JLabel jLabel = new JLabel(String.format("%s", diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java index 853c6afff4..4ae9ecf59d 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java @@ -26,7 +26,7 @@ import java.util.Map.Entry; import java.util.ResourceBundle; -import static mekhq.gui.panes.campaignOptions.CampaignOptionsDialogController.*; +import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; /** * Represents a tab that allows the user to configure general settings for a campaign. diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java index 3090560ade..2a251e847e 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java @@ -10,7 +10,7 @@ import java.util.Map.Entry; import java.util.ResourceBundle; -import static mekhq.gui.panes.campaignOptions.CampaignOptionsDialogController.*; +import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; public class RepairAndMaintenanceTab extends AbstractMHQTabbedPane { // region Variable Declarations From aa0a91528bbe0d61fefbe342d22b9278ad177feb Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 1 Oct 2024 09:18:47 -0500 Subject: [PATCH 010/117] Refactor: Remove inheritance from AbstractMHQTabbedPane Removed the inheritance from AbstractMHQTabbedPane in RepairAndMaintenanceTab and GeneralTab. Adjusted constructors and methods to accommodate this change and updated utility imports to reflect the new package structure. --- .../campaignOptions/CampaignOptionsPane.java | 2 +- .../{ => tabs}/CampaignOptionsUtilities.java | 21 ++++++++-------- .../campaignOptions/tabs/GeneralTab.java | 24 +++++++++++-------- .../tabs/RepairAndMaintenanceTab.java | 23 +++++++++--------- 4 files changed, 38 insertions(+), 32 deletions(-) rename MekHQ/src/mekhq/gui/panes/campaignOptions/{ => tabs}/CampaignOptionsUtilities.java (94%) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java index 9f0b5f1ee0..5c821b5332 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java @@ -10,7 +10,7 @@ import java.util.Map; import java.util.ResourceBundle; -import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.createSubTabs; +import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.createSubTabs; public class CampaignOptionsPane extends AbstractMHQTabbedPane { private static final MMLogger logger = MMLogger.create(CampaignOptionsPane.class); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java similarity index 94% rename from MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java rename to MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index b97b07d31c..ff9a0ba7d9 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -1,7 +1,8 @@ -package mekhq.gui.panes.campaignOptions; +package mekhq.gui.panes.campaignOptions.tabs; import megamek.common.annotations.Nullable; import megamek.logging.MMLogger; +import mekhq.gui.panes.campaignOptions.CampaignOptionsPane; import javax.swing.*; import javax.swing.GroupLayout.Alignment; @@ -33,7 +34,7 @@ public class CampaignOptionsUtilities { * line of the tooltip (or 100, if {@code null}). * @return a new {@link JCheckBox} object with the specified name, label, and tooltip */ - public static JCheckBox createCheckBox(String name, @Nullable Integer customWrapSize) { + static JCheckBox createCheckBox(String name, @Nullable Integer customWrapSize) { customWrapSize = processWrapSize(customWrapSize); JCheckBox checkBox = new JCheckBox(String.format("%s", @@ -63,7 +64,7 @@ public static JCheckBox createCheckBox(String name, @Nullable Integer customWrap * @param stepSize a double representing the step size of the spinner * @return a map containing a {@link JLabel} key and a {@link JSpinner} value. */ - public static Map createLabeledSpinner(String name, @Nullable Integer customWrapSize, + static Map createLabeledSpinner(String name, @Nullable Integer customWrapSize, double defaultValue, double minimum, double maximum, double stepSize) { customWrapSize = processWrapSize(customWrapSize); @@ -100,7 +101,7 @@ public static Map createLabeledSpinner(String name, @Nullable * of the tooltip; defaults to 100 if {@code null} * @return a new {@link JLabel} object */ - public static JLabel createLabel(String name, @Nullable Integer customWrapSize) { + static JLabel createLabel(String name, @Nullable Integer customWrapSize) { customWrapSize = processWrapSize(customWrapSize); JLabel jLabel = new JLabel(String.format("%s", @@ -133,7 +134,7 @@ public static JLabel createLabel(String name, @Nullable Integer customWrapSize) * If {@code null}, the minimum size height is used. * @return a map containing a {@link JLabel} key and a {@link JTextField} value. */ - public static Map createLabeledTextField(String name, + static Map createLabeledTextField(String name, @Nullable Integer customWrapSize, int minimumSizeWidth, int minimumSizeHeight, @Nullable Integer maximumSizeWidth, @Nullable Integer maximumSizeHeight) { @@ -183,7 +184,7 @@ private static int processWrapSize(@Nullable Integer customWrapSize) { * * @return a JPanel with a titled border and GroupLayout as its layout manager */ - public static JPanel createStandardPanel(String name, boolean includeBorder, String borderTitle) { + static JPanel createStandardPanel(String name, boolean includeBorder, String borderTitle) { borderTitle = borderTitle.isBlank() ? "" : resources.getString(borderTitle); JPanel panel = new JPanel(); @@ -213,7 +214,7 @@ public static JPanel createStandardPanel(String name, boolean includeBorder, Str * The resource bundle reference is {@code name + "Body.text"} * @return a JPanel representing the header panel */ - public static JPanel createHeaderPanel(String name, String imageAddress, boolean includeBorder, + static JPanel createHeaderPanel(String name, String imageAddress, boolean includeBorder, String borderTitle, boolean includeBodyText) { ImageIcon imageIcon = new ImageIcon(imageAddress); JLabel imageLabel = new JLabel(imageIcon); @@ -256,7 +257,7 @@ public static JPanel createHeaderPanel(String name, String imageAddress, boolean * @param panel the {@link JPanel} for which the {@link GroupLayout} is created * @return the created {@link GroupLayout} object */ - public static GroupLayout createStandardLayout(JPanel panel) { + static GroupLayout createStandardLayout(JPanel panel) { final GroupLayout layout = new GroupLayout(panel); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); @@ -273,7 +274,7 @@ public static GroupLayout createStandardLayout(JPanel panel) { * @param maximumHeight the maximum height of the parent panel * @return the created {@link JPanel} */ - public static JPanel createParentPanel(JPanel panel, String name, int maximumWidth, int maximumHeight) { + static JPanel createParentPanel(JPanel panel, String name, int maximumWidth, int maximumHeight) { final JPanel parentPanel = createStandardPanel(name, true, ""); final GroupLayout parentLayout = createStandardLayout(parentPanel); Dimension preferredSize = new Dimension(maximumWidth, maximumHeight); @@ -298,7 +299,7 @@ public static JPanel createParentPanel(JPanel panel, String name, int maximumWid * {@link JPanel} objects as values * @return a {@link JTabbedPane} with the supplied panels as tabs */ - public static JTabbedPane createSubTabs(Map panels) { + static JTabbedPane createSubTabs(Map panels) { // We use a list here to ensure that the tabs always display in the same order, // and that order might as well be alphabetic. List tabNames = new ArrayList<>(panels.keySet()); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java index 4ae9ecf59d..b6a5cbbc62 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java @@ -26,18 +26,21 @@ import java.util.Map.Entry; import java.util.ResourceBundle; -import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; +import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; /** * Represents a tab that allows the user to configure general settings for a campaign. * Extends the {@link AbstractMHQTabbedPane} class. */ -public class GeneralTab extends AbstractMHQTabbedPane { +public class GeneralTab { // region Variable Declarations private static String RESOURCE_PACKAGE = "mekhq/resources/NEWCampaignOptionsDialog"; private static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE, MekHQ.getMHQOptions().getLocale()); + JFrame frame; + String name; + private final Campaign campaign; private JLabel lblName; @@ -67,8 +70,8 @@ public class GeneralTab extends AbstractMHQTabbedPane { * @param name the name of the tab */ public GeneralTab(Campaign campaign, JFrame frame, String name) { - super(frame, name); - + this.frame = frame; + this.name = name; this.campaign = campaign; this.date = campaign.getLocalDate(); this.camouflage = campaign.getCamouflage(); @@ -140,7 +143,7 @@ public AbstractMHQScrollablePanel createGeneralTab() { btnIcon.setMinimumSize(new Dimension(84, 72)); btnIcon.setMaximumSize(new Dimension(84, 72)); btnIcon.addActionListener(evt -> { - final UnitIconDialog unitIconDialog = new UnitIconDialog(getFrame(), unitIcon); + final UnitIconDialog unitIconDialog = new UnitIconDialog(frame, unitIcon); if (unitIconDialog.showDialog().isConfirmed() && (unitIconDialog.getSelectedItem() != null)) { unitIcon = unitIconDialog.getSelectedItem(); btnIcon.setIcon(unitIcon.getImageIcon(75)); @@ -148,7 +151,7 @@ public AbstractMHQScrollablePanel createGeneralTab() { }); // Initialize the parent panel - AbstractMHQScrollablePanel generalPanel = new DefaultMHQScrollablePanel(getFrame(), "generalPanel", + AbstractMHQScrollablePanel generalPanel = new DefaultMHQScrollablePanel(frame, "generalPanel", new GridBagLayout()); // Layout the Panel @@ -213,7 +216,9 @@ public AbstractMHQScrollablePanel createGeneralTab() { return generalPanel; } - @Override + /** + * Initialize the components of the {@link GeneralTab} class. + */ protected void initialize() { lblName = new JLabel(); txtName = new JTextField(); @@ -242,7 +247,6 @@ protected void initialize() { btnIcon = new JButton(); } - /** * This method is called when the "btnDate" button is clicked. * It shows a date chooser dialog and sets the selected date if the user chooses a date. @@ -251,7 +255,7 @@ protected void initialize() { */ private void btnDateActionPerformed(ActionEvent actionEvent) { // show the date chooser - DateChooser dateChooser = new DateChooser(getFrame(), date); + DateChooser dateChooser = new DateChooser(frame, date); // user can either choose a date or cancel by closing if (dateChooser.showDateChooser() == DateChooser.OK_OPTION) { setDate(dateChooser.getDate()); @@ -288,7 +292,7 @@ private void setDate(final @Nullable LocalDate date) { * @param actionEvent The action event that triggered this method. */ private void btnCamoActionPerformed(ActionEvent actionEvent) { - CamoChooserDialog camoChooserDialog = new CamoChooserDialog(getFrame(), camouflage); + CamoChooserDialog camoChooserDialog = new CamoChooserDialog(frame, camouflage); if (camoChooserDialog.showDialog().isConfirmed()) { camouflage = camoChooserDialog.getSelectedItem(); btnCamo.setIcon(camouflage.getImageIcon()); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java index 2a251e847e..932c44506c 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java @@ -1,22 +1,17 @@ package mekhq.gui.panes.campaignOptions.tabs; -import mekhq.MekHQ; import mekhq.gui.baseComponents.AbstractMHQScrollablePanel; -import mekhq.gui.baseComponents.AbstractMHQTabbedPane; import javax.swing.*; import javax.swing.GroupLayout.Alignment; import java.util.Map; import java.util.Map.Entry; -import java.util.ResourceBundle; -import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; +import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; -public class RepairAndMaintenanceTab extends AbstractMHQTabbedPane { - // region Variable Declarations - private static String RESOURCE_PACKAGE = "mekhq/resources/NEWCampaignOptionsDialog"; - private static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE, - MekHQ.getMHQOptions().getLocale()); +public class RepairAndMaintenanceTab { + JFrame frame; + String name; //start Repair Tab private JCheckBox useEraModsCheckBox; @@ -47,8 +42,12 @@ public class RepairAndMaintenanceTab extends AbstractMHQTabbedPane { private JCheckBox logMaintenance; //end Maintenance Tab + /** + * Represents a tab for repair and maintenance in an application. + */ public RepairAndMaintenanceTab(JFrame frame, String name) { - super(frame, name); + this.frame = frame; + this.name = name; initialize(); } @@ -262,7 +261,9 @@ private void recreateFinancesPanel(boolean isReversingQualityNames) { // TODO handle this } - @Override + /** + * Initializes the repair and maintenance tab by creating and initializing various UI components. + */ protected void initialize() { initializeRepairTab(); initializeMaintenanceTab(); From 86b8f511312529a84810437a43b4d28733549a83 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 1 Oct 2024 09:20:50 -0500 Subject: [PATCH 011/117] Rename CampaignOptionsPane to supports subpackage structure Moved CampaignOptionsPane to the "tabs" subpackage for better organization. Updated the import statements in relevant classes to reflect the new package path. --- MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java | 2 +- .../campaignOptions/{ => tabs}/CampaignOptionsPane.java | 5 +---- .../panes/campaignOptions/tabs/CampaignOptionsUtilities.java | 1 - 3 files changed, 2 insertions(+), 6 deletions(-) rename MekHQ/src/mekhq/gui/panes/campaignOptions/{ => tabs}/CampaignOptionsPane.java (89%) diff --git a/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java b/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java index 99b40e7d54..ec395eb860 100644 --- a/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java @@ -27,7 +27,7 @@ import mekhq.campaign.campaignOptions.CampaignPreset; import mekhq.gui.FileDialogs; import mekhq.gui.baseComponents.AbstractMHQValidationButtonDialog; -import mekhq.gui.panes.campaignOptions.CampaignOptionsPane; +import mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsPane; import javax.swing.*; import java.awt.*; diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java similarity index 89% rename from MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java rename to MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 5c821b5332..a5a90987e3 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -1,10 +1,8 @@ -package mekhq.gui.panes.campaignOptions; +package mekhq.gui.panes.campaignOptions.tabs; import megamek.logging.MMLogger; import mekhq.campaign.Campaign; import mekhq.gui.baseComponents.AbstractMHQTabbedPane; -import mekhq.gui.panes.campaignOptions.tabs.GeneralTab; -import mekhq.gui.panes.campaignOptions.tabs.RepairAndMaintenanceTab; import javax.swing.*; import java.util.Map; @@ -18,7 +16,6 @@ public class CampaignOptionsPane extends AbstractMHQTabbedPane { private static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE); private final Campaign campaign; - final static int WIDTH_MULTIPLIER = 3; // This seems to be the sweet spot public CampaignOptionsPane(final JFrame frame, final Campaign campaign) { super(frame, resources, "campaignOptionsDialog"); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index ff9a0ba7d9..de57e451ee 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -2,7 +2,6 @@ import megamek.common.annotations.Nullable; import megamek.logging.MMLogger; -import mekhq.gui.panes.campaignOptions.CampaignOptionsPane; import javax.swing.*; import javax.swing.GroupLayout.Alignment; From a95b7f310e14a7c70921ca10abdcd9ecc210a844 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 1 Oct 2024 20:17:11 -0500 Subject: [PATCH 012/117] Add Supplies and Acquisition Tab to Campaign Options Reorganized properties and labels in various tabs. Introduced a new Supplies and Acquisition tab with Acquisition, Delivery, and Planetary Acquisition sub-tabs while maintaining existing functionality for Repair and Maintenance. --- .../NEWCampaignOptionsDialog.properties | 169 +++-- .../tabs/CampaignOptionsPane.java | 16 +- .../tabs/CampaignOptionsUtilities.java | 110 ++- .../campaignOptions/tabs/GeneralTab.java | 96 ++- .../tabs/RepairAndMaintenanceTab.java | 89 +-- .../tabs/SuppliesAndAcquisition.java | 4 - .../tabs/SuppliesAndAcquisitionTab.java | 704 ++++++++++++++++++ 7 files changed, 1024 insertions(+), 164 deletions(-) delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisition.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index e841041121..75ac17b4ea 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -19,16 +19,16 @@ generalPanel.title=General Information # createGeneralTab lblGeneral.text=Welcome, Commander -Name.text=Unit Name -Name.tooltip=PLACEHOLDER -btnNameGenerator.text=Regenerate Name -btnNameGenerator.tooltip=PLACEHOLDER +lblName.text=Unit Name +lblName.tooltip=PLACEHOLDER +lblNameGenerator.text=Regenerate Name +lblNameGenerator.tooltip=PLACEHOLDER lblFaction.text=Unit Faction lblFaction.tooltip=PLACEHOLDER lblReputation.text=Reputation lblReputation.tooltip=PLACEHOLDER -ManualUnitRatingModifier.text=Manual Modifier -ManualUnitRatingModifier.tooltip=PLACEHOLDER +lblManualUnitRatingModifier.text=Manual Modifier +lblManualUnitRatingModifier.tooltip=PLACEHOLDER lblDate.text=Start Date lblDate.tooltip=PLACEHOLDER lblCamo.text=Unit Camouflage @@ -37,59 +37,138 @@ lblIcon.text=Unit Insignia lblIcon.tooltip=PLACEHOLDER ## RepairAndMaintenanceTab -RepairAndMaintenancePanel.title=Repairs and Maintenance +repairAndMaintenanceContentTabs.title=Repairs and Maintenance +repairTab.title=Repairs +maintenanceTab.title=Maintenance # createRepairTab -repairTab.title=Repairs lblRepairTab.text=Repair Options lblRepairTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Nisl senectus neque sem maximus\ \ accumsan nibh curae dapibus. Asuspendisse ullamcorper aliquet aliquet pretium duis litora porttitor.\ \ Tristique ex per aptent cras augue mus suspendisse inceptos hac. Amet ultricies sem dui etiam justo.\ \ Efficitur ac nisl maecenas eu ac tincidunt. Eget felis hendrerit lacinia commodo eu natoque id\ \ himenaeos nibh. -useEraModsCheckBox.text=Use Era Modifiers for Repair Rolls -useEraModsCheckBox.tooltip=PLACEHOLDER -assignedTechFirstCheckBox.text=Place Assigned Technicians to the Top of the List -assignedTechFirstCheckBox.tooltip=PLACEHOLDER -resetToFirstTechCheckBox.text=After Repairs Jump to the Technician at the Top of the List -resetToFirstTechCheckBox.tooltip=PLACEHOLDER -useQuirksBox.text=Use Quirks -useQuirksBox.tooltip=PLACEHOLDER -useAeroSystemHitsBox.text=Damage Aero System Parts by Hits Taken -useAeroSystemHitsBox.tooltip=PLACEHOLDER -useDamageMargin.text=Damage Parts by Margin of Failure -useDamageMargin.tooltip=PLACEHOLDER -DamageMargin.text=Margin -DamageMargin.tooltip=PLACEHOLDER -DestroyPartTarget.text=Equipment hit in battle survive on a -DestroyPartTarget.tooltip=PLACEHOLDER +lblUseEraModsCheckBox.text=Use Era Modifiers for Repair Rolls +lblUseEraModsCheckBox.tooltip=PLACEHOLDER +lblAssignedTechFirstCheckBox.text=Place Assigned Technicians to the Top of the List +lblAssignedTechFirstCheckBox.tooltip=PLACEHOLDER +lblResetToFirstTechCheckBox.text=After Repairs Jump to the Technician at the Top of the List +lblResetToFirstTechCheckBox.tooltip=PLACEHOLDER +lblUseQuirksBox.text=Use Quirks +lblUseQuirksBox.tooltip=PLACEHOLDER +lblUseAeroSystemHitsBox.text=Damage Aero System Parts by Hits Taken +lblUseAeroSystemHitsBox.tooltip=PLACEHOLDER +lblUseDamageMargin.text=Damage Parts by Margin of Failure +lblUseDamageMargin.tooltip=PLACEHOLDER +lblDamageMargin.text=Margin +lblDamageMargin.tooltip=PLACEHOLDER +lblDestroyPartTarget.text=Equipment hit in battle survive on a +lblDestroyPartTarget.tooltip=PLACEHOLDER # createMaintenanceTab -maintenanceTab.title=Maintenance lblMaintenanceTab.text=Maintenance Options lblMaintenanceTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Nisl senectus neque\ \ sem maximus accumsan nibh curae dapibus. Asuspendisse ullamcorper aliquet aliquet pretium duis\ \ litora porttitor.Tristique ex per aptent cras augue mus suspendisse inceptos hac. Amet ultricies\ \ sem dui etiam justo. Efficitur ac nisl maecenas eu ac tincidunt. Eget felis hendrerit lacinia\ \ commodo eu natoque id himenaeos nibh. -checkMaintenance.text=Enable Unit Maintenance -checkMaintenance.tooltip=PLACEHOLDER -MaintenanceDays.text=Base Maintenance Cycle -MaintenanceDays.tooltip=PLACEHOLDER -MaintenanceBonus.text=Maintenance Modifier -MaintenanceBonus.tooltip=PLACEHOLDER -DefaultMaintenanceTime.text=Default Maintenance Time -DefaultMaintenanceTime.tooltip=PLACEHOLDER -useQualityMaintenance.text=Use Quality Modifiers -useQualityMaintenance.tooltip=PLACEHOLDER -reverseQualityNames.text=Reverse Quality Names -reverseQualityNames.tooltip=PLACEHOLDER -chkUseRandomUnitQualities.text=Random New Unit Quality -chkUseRandomUnitQualities.tooltip=PLACEHOLDER -chkUsePlanetaryModifiers.text=Use Planetary Modifiers -chkUsePlanetaryModifiers.tooltip=PLACEHOLDER -useUnofficialMaintenance.text=Only Damage F-Rated Equipment -useUnofficialMaintenance.tooltip=PLACEHOLDER -logMaintenance.text=Write Maintenance Results to MekHQ.log -logMaintenance.tooltip=PLACEHOLDER +lblCheckMaintenance.text=Enable Unit Maintenance +lblCheckMaintenance.tooltip=PLACEHOLDER +lblMaintenanceDays.text=Base Maintenance Cycle +lblMaintenanceDays.tooltip=PLACEHOLDER +lblMaintenanceBonus.text=Maintenance Modifier +lblMaintenanceBonus.tooltip=PLACEHOLDER +lblDefaultMaintenanceTime.text=Default Maintenance Time +lblDefaultMaintenanceTime.tooltip=PLACEHOLDER +lblUseQualityMaintenance.text=Use Quality Modifiers +lblUseQualityMaintenance.tooltip=PLACEHOLDER +lblReverseQualityNames.text=Reverse Quality Names +lblReverseQualityNames.tooltip=PLACEHOLDER +lblUseRandomUnitQualities.text=Random New Unit Quality +lblUseRandomUnitQualities.tooltip=PLACEHOLDER +lblUsePlanetaryModifiers.text=Use Planetary Modifiers +lblUsePlanetaryModifiers.tooltip=PLACEHOLDER +lblUseUnofficialMaintenance.text=Only Damage F-Rated Equipment +lblUseUnofficialMaintenance.tooltip=PLACEHOLDER +lblLogMaintenance.text=Write Maintenance Results to MekHQ.log +lblLogMaintenance.tooltip=PLACEHOLDER + +## SuppliesAndAcquisitionTab +suppliesAndAcquisitionTab.title=Supplies and Acquisition +acquisitionsTab.title=Acquisitions +deliveryTab.title=Deliveries +PlanetaryAcquisitionTab.title=Planetary Acquisitions + +# createAcquisitionTab +lblAcquisitionTab.text=Acquisition Options +lblAcquisitionTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Tristique non elit\ + \ potenti suscipit lobortis sollicitudin. Iaculis dis ultrices cursus litora iaculis. Commodo blandit\ + \ penatibus vitae leo quisque lectus dictum. Duis conubia nisi aliquet phasellus risus nullam massa\ + \ at. Elementum natoque torquent phasellus suspendisse per aliquet scelerisque. Justo integer\ + \ faucibus penatibus sem class. +lblChoiceAcquireSkill.text=Acquisitions Skill +lblChoiceAcquireSkill.tooltip=PLACEHOLDER +lblSupportStaffOnly.text=Only Support Personnel Make Acquisition Rolls +lblSupportStaffOnly.tooltip=PLACEHOLDER +lblAcquireClanPenalty.text=Penalty for Clan Equipment +lblAcquireClanPenalty.tooltip=PLACEHOLDER +lblAcquireISPenalty.text=Penalty for Inner Sphere Equipment +lblAcquireISPenalty.tooltip=PLACEHOLDER +lblAcquireWaitingPeriod.text=Acquisition Roll Period Frequency (in days) +lblAcquireWaitingPeriod.tooltip=PLACEHOLDER +lblMaxAcquisitions.text=Max Acquisition Rolls per Period +lblMaxAcquisitions.tooltip=PLACEHOLDER + +# createDeliveryTab +lblDeliveryTab.text=Delivery Options +lblDeliveryTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod varius congue\ + \ rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam maximus. Morbi\ + \ gravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat turpis semper\ + \ morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida primis\ + \ vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin porttitor\ + \ dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam. +lblNDiceTransitTime.text=Delivery Time +lblNDiceTransitTime.tooltip=PLACEHOLDER +lblConstantTransitTime.text=d6+ +lblConstantTransitTime.tooltip=PLACEHOLDER +lblAcquireMosBonus.text=Delivery Time Reduction (per Margin of Success) +lblAcquireMosBonus.tooltip=PLACEHOLDER +lblAcquireMinimum.text=Minimum Delivery Time +lblAcquireMinimum.tooltip=PLACEHOLDER +transitUnitNamesDays.text=Days +transitUnitNamesWeeks.text=Weeks +transitUnitNamesMonths.text=Months + +# createPlanetaryAcquisitionTab +lblPlanetaryAcquisitionTab.text=Planetary Acquisition Options +lblPlanetaryAcquisitionTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam. + +# createOptionsPanel +lblUsePlanetaryAcquisitions.text=Use Planetary Acquisitions +lblUsePlanetaryAcquisitions.tooltip=PLACEHOLDER +lblMaxJumpPlanetaryAcquisitions.text=Maximum Jump Distance +lblMaxJumpPlanetaryAcquisitions.tooltip=PLACEHOLDER +lblPlanetaryAcquisitionsFactionLimits.text=Faction Supply Limits +lblPlanetaryAcquisitionsFactionLimits.tooltip=PLACEHOLDER +lblDisallowPlanetaryAcquisitionClanCrossover.text=No Clan-Inner Sphere Supply Sharing +lblDisallowPlanetaryAcquisitionClanCrossover.tooltip=PLACEHOLDER +lblDisallowClanPartsFromIS.text=Disallow Clan Parts from Non-Clan Factions +lblDisallowClanPartsFromIS.tooltip=PLACEHOLDER +lblPenaltyClanPartsFromIS.text=Non-Clan Acquisition Penalty +lblPenaltyClanPartsFromIS.tooltip=PLACEHOLDER +lblUsePlanetaryAcquisitionsVerbose.text=Enable Verbose Reporting +lblUsePlanetaryAcquisitionsVerbose.tooltip=PLACEHOLDER +# createModifiersPanel +lblModifiersPanel.text=Modifiers +lblTechLabel.text=Tech +lblTechLabel.tooltip=PLACEHOLDER +lblIndustryLabel.text=Industry +lblIndustryLabel.tooltip=PLACEHOLDER +lblOutputLabel.text=Output +lblOutputLabel.tooltip=PLACEHOLDER \ No newline at end of file diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index a5a90987e3..458b9f338c 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -34,11 +34,25 @@ protected void initialize() { // Repair and Maintenance RepairAndMaintenanceTab repairAndMaintenanceTab = new RepairAndMaintenanceTab(getFrame(), "repairAndMaintenanceTab"); + JTabbedPane repairAndMaintenanceContentTabs = createSubTabs(Map.of( "repairTab", repairAndMaintenanceTab.createRepairTab(), "maintenanceTab", repairAndMaintenanceTab.createMaintenanceTab())); + + addTab(String.format("%s", 4, + resources.getString("repairAndMaintenanceContentTabs.title")), repairAndMaintenanceContentTabs); + + // Supplies and Acquisition + SuppliesAndAcquisitionTab suppliesAndAcquisitionTab = new SuppliesAndAcquisitionTab(getFrame(), + "suppliesAndAcquisitionTab"); + + JTabbedPane suppliesAndAcquisitionContentTabs = createSubTabs(Map.of( + "acquisitionTab", suppliesAndAcquisitionTab.createAcquisitionTab(), + "deliveryTab", suppliesAndAcquisitionTab.createDeliveryTab(), + "planetaryAcquisitionTab", suppliesAndAcquisitionTab.createPlanetaryAcquisitionTab())); + addTab(String.format("%s", 4, - resources.getString("RepairAndMaintenancePanel.title")), repairAndMaintenanceContentTabs); + resources.getString("suppliesAndAcquisitionTab.title")), suppliesAndAcquisitionContentTabs); } private void setOptions() { diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index de57e451ee..9f6ff98974 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -18,7 +18,15 @@ public class CampaignOptionsUtilities { private static final String RESOURCE_PACKAGE = "mekhq/resources/NEWCampaignOptionsDialog"; private static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE); - final static int WIDTH_MULTIPLIER = 3; // This seems to be the sweet spot + final static int WIDTH_MULTIPLIER_NUMBER = 3; // This seems to be the sweet spot + final static String IMAGE_DIRECTORY = "data/images/universe/factions/"; + + /** + * @return the image directory + */ + static String getImageDirectory() { + return IMAGE_DIRECTORY; + } /** * Returns a new {@link JCheckBox} object with the specified name, label, and tooltip. @@ -37,9 +45,9 @@ static JCheckBox createCheckBox(String name, @Nullable Integer customWrapSize) { customWrapSize = processWrapSize(customWrapSize); JCheckBox checkBox = new JCheckBox(String.format("%s", - resources.getString(name + ".text"))); - checkBox.setToolTipText(wordWrap(resources.getString(name + ".tooltip"), customWrapSize)); - checkBox.setName(name); + resources.getString("lbl" + name + ".text"))); + checkBox.setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), customWrapSize)); + checkBox.setName("chk" + name); return checkBox; } @@ -67,19 +75,15 @@ static Map createLabeledSpinner(String name, @Nullable Integer double defaultValue, double minimum, double maximum, double stepSize) { customWrapSize = processWrapSize(customWrapSize); - - final JLabel jLabel = new JLabel(String.format("%s", - resources.getString(name + ".text"))); - jLabel.setToolTipText(wordWrap(resources.getString(name + ".tooltip"), customWrapSize)); - jLabel.setName("lbl" + name); + final JLabel jLabel = createLabel(name, customWrapSize); JSpinner jSpinner = new JSpinner(new SpinnerNumberModel(defaultValue, minimum, maximum, stepSize)); - jSpinner.setToolTipText(wordWrap(resources.getString(name + ".tooltip"), customWrapSize)); + jSpinner.setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), customWrapSize)); jSpinner.setName("spn" + name); FontMetrics fontMetrics = jSpinner.getFontMetrics(jSpinner.getFont()); int width = fontMetrics.stringWidth(Double.toString(maximum)); - width = width * WIDTH_MULTIPLIER; + width = width * WIDTH_MULTIPLIER_NUMBER; jSpinner.setMaximumSize(new Dimension(width, 30)); jSpinner.setMinimumSize(new Dimension(width, 30)); @@ -104,13 +108,56 @@ static JLabel createLabel(String name, @Nullable Integer customWrapSize) { customWrapSize = processWrapSize(customWrapSize); JLabel jLabel = new JLabel(String.format("%s", - resources.getString(name + ".text"))); - jLabel.setToolTipText(wordWrap(resources.getString(name + ".tooltip"), customWrapSize)); - jLabel.setName(name); + resources.getString("lbl" + name + ".text"))); + jLabel.setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), customWrapSize)); + jLabel.setName("lbl" + name); + + FontMetrics fontMetrics = jLabel.getFontMetrics(jLabel.getFont()); + // The whitespaces create a consistent buffer that will scale with different fonts. + int width = fontMetrics.stringWidth(removeHtmlTags(jLabel.getText()) + " "); + + jLabel.setMinimumSize(new Dimension(width, 30)); + jLabel.setMaximumSize(new Dimension(width, 30)); return jLabel; } + /** + * Calculates the optimal width for a {@link JComboBox} based on the text of its items. + * + * @param comboBox the {@link JComboBox} for which to calculate the width of each item's text + * @return the width of the widest item's text in the {@link JComboBox}, including a buffer space + */ + static int getDimensionWidthForComboBox(JComboBox comboBox) { + int width = 0; + + FontMetrics fontMetrics = comboBox.getFontMetrics(comboBox.getFont()); + + for (int i = 0; i < comboBox.getItemCount(); i++) { + String itemText = comboBox.getItemAt(i).toString(); + int workingWidth = fontMetrics.stringWidth(itemText); + + if (workingWidth > width) { + width = workingWidth; + } + } + + return (int) (width * 1.25); + } + + /** + * Calculates the width of the text on a {@link JButton}. + * + * @param jButton the {@link JButton} to calculate the width for + * @return the adjusted width of the button text + */ + static int getDimensionWidthForButton(JButton jButton) { + FontMetrics fontMetrics = jButton.getFontMetrics(jButton.getFont()); + + // The whitespaces create a consistent buffer that will scale with different fonts. + return fontMetrics.stringWidth(removeHtmlTags(" " + jButton.getText() + " ")); + } + /** * Creates a map containing a {@link JLabel} and a {@link JTextField} object. *

@@ -138,21 +185,17 @@ static Map createLabeledTextField(String name, int minimumSizeHeight, @Nullable Integer maximumSizeWidth, @Nullable Integer maximumSizeHeight) { customWrapSize = processWrapSize(customWrapSize); - - JLabel jLabel = new JLabel(String.format("%s", - resources.getString(name + ".text"))); - jLabel.setToolTipText(wordWrap(resources.getString(name + ".tooltip"), customWrapSize)); - jLabel.setName("lbl" + name); + JLabel jLabel = createLabel(name, customWrapSize); JTextField jTextField = new JTextField(); - jTextField.setToolTipText(wordWrap(resources.getString(name + ".tooltip"), customWrapSize)); + jTextField.setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), customWrapSize)); jTextField.setName("txt" + name); jTextField.setMinimumSize(new Dimension(minimumSizeWidth, minimumSizeHeight)); maximumSizeWidth = maximumSizeWidth == null ? minimumSizeWidth : maximumSizeWidth; maximumSizeHeight = maximumSizeHeight == null ? minimumSizeHeight : maximumSizeHeight; - jTextField.setPreferredSize(new Dimension(maximumSizeWidth, maximumSizeHeight)); + jTextField.setMaximumSize(new Dimension(maximumSizeWidth, maximumSizeHeight)); return Map.of(jLabel, jTextField); } @@ -184,7 +227,7 @@ private static int processWrapSize(@Nullable Integer customWrapSize) { * @return a JPanel with a titled border and GroupLayout as its layout manager */ static JPanel createStandardPanel(String name, boolean includeBorder, String borderTitle) { - borderTitle = borderTitle.isBlank() ? "" : resources.getString(borderTitle); + borderTitle = borderTitle.isBlank() ? "" : resources.getString("lbl" + borderTitle + ".text"); JPanel panel = new JPanel(); @@ -205,7 +248,7 @@ static JPanel createStandardPanel(String name, boolean includeBorder, String bor * @param name the name of the header panel. * The {@link JLabel} will have 'lbl' appended. This will be appended with * '.text' to fetch the label contents from the resource bundle. - * The {@link JPanel} is appended with 'txt'. + * The {@link JPanel} is appended with 'pnl'. * @param imageAddress the file path of the image to be displayed in the panel * @param includeBorder whether the panel should have a border * @param borderTitle the title of the border; can be empty for an untitled border @@ -270,14 +313,17 @@ static GroupLayout createStandardLayout(JPanel panel) { * @param panel the panel to be added to the parent panel * @param name the name of the parent panel * @param maximumWidth the maximum width of the parent panel - * @param maximumHeight the maximum height of the parent panel * @return the created {@link JPanel} */ - static JPanel createParentPanel(JPanel panel, String name, int maximumWidth, int maximumHeight) { + static JPanel createParentPanel(JPanel panel, String name, int maximumWidth) { final JPanel parentPanel = createStandardPanel(name, true, ""); final GroupLayout parentLayout = createStandardLayout(parentPanel); - Dimension preferredSize = new Dimension(maximumWidth, maximumHeight); - panel.setMaximumSize(preferredSize); + + int preferredHeight = (int) (panel.getPreferredSize().height * 1.25); + Dimension size = new Dimension(maximumWidth, preferredHeight); + panel.setMinimumSize(size); + panel.setMaximumSize(size); + parentPanel.setLayout(parentLayout); parentLayout.setVerticalGroup( @@ -313,4 +359,14 @@ static JTabbedPane createSubTabs(Map panels) { return tabbedPane; } + + /** + * Removes HTML tags from the given string. + * + * @param htmlString the string containing HTML tags + * @return the string without HTML tags + */ + private static String removeHtmlTags(String htmlString) { + return htmlString.replaceAll("\\<.*?\\>", ""); + } } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java index b6a5cbbc62..6670b73dad 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java @@ -99,22 +99,27 @@ public AbstractMHQScrollablePanel createGeneralTab() { } // Generate new random campaign name - btnNameGenerator = new JButton(resources.getString("btnNameGenerator.text")); - btnNameGenerator.setToolTipText(resources.getString("btnNameGenerator.tooltip")); + btnNameGenerator = new JButton(resources.getString("lblNameGenerator.text")); + btnNameGenerator.setToolTipText(resources.getString("lblNameGenerator.tooltip")); btnNameGenerator.setName("btnNameGenerator"); + int btnNameGeneratorWidth = getDimensionWidthForButton(btnNameGenerator); + btnNameGenerator.setMinimumSize(new Dimension(btnNameGeneratorWidth, 30)); + btnNameGenerator.setMaximumSize(new Dimension(btnNameGeneratorWidth, 30)); btnNameGenerator.addActionListener(e -> txtName.setText(BackgroundsController .randomMercenaryCompanyNameGenerator(campaign.getFlaggedCommander()))); // Campaign faction - lblFaction = createLabel("lblFaction", null); + lblFaction = createLabel("Faction", null); comboFaction.setSelectedItem(new FactionDisplay(campaign.getFaction(), campaign.getLocalDate())); - comboFaction.setMinimumSize(new Dimension(275, 30)); - comboFaction.setMaximumSize(new Dimension(275, 30)); + int comboFactionWidth = getDimensionWidthForComboBox(comboFaction); + comboFaction.setMinimumSize(new Dimension(comboFactionWidth, 30)); + comboFaction.setMaximumSize(new Dimension(comboFactionWidth, 30)); // Reputation - lblReputation = createLabel("lblReputation", null); - unitRatingMethodCombo.setMinimumSize(new Dimension(150, 30)); - unitRatingMethodCombo.setMaximumSize(new Dimension(150, 30)); + lblReputation = createLabel("Reputation", null); + int unitRatingMethodComboWidth = getDimensionWidthForComboBox(unitRatingMethodCombo); + unitRatingMethodCombo.setMinimumSize(new Dimension(unitRatingMethodComboWidth, 30)); + unitRatingMethodCombo.setMaximumSize(new Dimension(unitRatingMethodComboWidth, 30)); Map manualReputationModifierFields = createLabeledSpinner( "ManualUnitRatingModifier", null, 0, -200, @@ -125,23 +130,26 @@ public AbstractMHQScrollablePanel createGeneralTab() { } // Date - lblDate = createLabel("lblDate", null); + lblDate = createLabel("Date", null); btnDate.setName("btnDate"); - btnDate.setMinimumSize(new Dimension(100, 30)); - btnDate.setMaximumSize(new Dimension(100, 30)); + + int btnDateWidth = getDimensionWidthForButton(btnNameGenerator); + btnDate.setMinimumSize(new Dimension(btnDateWidth, 30)); + btnDate.setMaximumSize(new Dimension(btnDateWidth, 30)); btnDate.addActionListener(this::btnDateActionPerformed); // Camouflage - lblCamo = createLabel("lblCamo", null); + lblCamo = createLabel("Camo", null); btnCamo.setName("btnCamo"); - btnCamo.setMinimumSize(new Dimension(84, 72)); - btnCamo.setMaximumSize(new Dimension(84, 72)); + btnCamo.setMinimumSize(new Dimension(100, 100)); + btnCamo.setMaximumSize(new Dimension(100, 100)); btnCamo.addActionListener(this::btnCamoActionPerformed); // Unit icon - lblIcon = createLabel("lblIcon", null); - btnIcon.setMinimumSize(new Dimension(84, 72)); - btnIcon.setMaximumSize(new Dimension(84, 72)); + lblIcon = createLabel("Icon", null); + btnIcon.setName("btnIcon"); + btnIcon.setMinimumSize(new Dimension(100, 100)); + btnIcon.setMaximumSize(new Dimension(100, 100)); btnIcon.addActionListener(evt -> { final UnitIconDialog unitIconDialog = new UnitIconDialog(frame, unitIcon); if (unitIconDialog.showDialog().isConfirmed() && (unitIconDialog.getSelectedItem() != null)) { @@ -164,26 +172,25 @@ public AbstractMHQScrollablePanel createGeneralTab() { .addComponent(imagePanel) .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(lblName) - .addComponent(txtName, Alignment.LEADING) + .addComponent(txtName) .addComponent(btnNameGenerator)) .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(lblFaction) - .addComponent(comboFaction, Alignment.LEADING)) + .addComponent(comboFaction)) .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(lblReputation) - .addComponent(unitRatingMethodCombo, Alignment.LEADING)) + .addComponent(unitRatingMethodCombo)) .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(lblManualUnitRatingModifier) - .addComponent(manualUnitRatingModifier, Alignment.LEADING)) + .addComponent(manualUnitRatingModifier)) .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(lblDate) - .addComponent(btnDate, Alignment.LEADING)) + .addComponent(btnDate)) .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(lblCamo) - .addComponent(btnCamo, Alignment.LEADING)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(btnCamo) .addComponent(lblIcon) - .addComponent(btnIcon, Alignment.LEADING))); + .addComponent(btnIcon))); layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) @@ -191,25 +198,31 @@ public AbstractMHQScrollablePanel createGeneralTab() { .addGroup(layout.createSequentialGroup() .addComponent(lblName) .addComponent(txtName) - .addComponent(btnNameGenerator)) + .addComponent(btnNameGenerator) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(lblFaction) - .addComponent(comboFaction)) + .addComponent(comboFaction) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(lblReputation) - .addComponent(unitRatingMethodCombo)) + .addComponent(unitRatingMethodCombo) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(lblManualUnitRatingModifier) - .addComponent(manualUnitRatingModifier)) + .addComponent(manualUnitRatingModifier) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(lblDate) - .addComponent(btnDate)) + .addComponent(btnDate) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(lblCamo) - .addComponent(btnCamo)) - .addGroup(layout.createSequentialGroup() + .addComponent(btnCamo) + .addGap(50) .addComponent(lblIcon) - .addComponent(btnIcon))); + .addComponent(btnIcon) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); generalPanel.add(panel); @@ -226,10 +239,7 @@ protected void initialize() { btnNameGenerator = new JButton(); lblFaction = new JLabel(); - DefaultComboBoxModel factionModel = new DefaultComboBoxModel<>(); - factionModel.addAll(FactionDisplay.getSortedValidFactionDisplays( - Factions.getInstance().getChoosableFactions(), campaign.getLocalDate())); - comboFaction = new MMComboBox<>("comboFaction", factionModel); + comboFaction = new MMComboBox<>("comboFaction", buildFactionDisplayOptions()); lblReputation = new JLabel(); unitRatingMethodCombo = new MMComboBox<>("unitRatingMethodCombo", UnitRatingMethod.values()); @@ -247,6 +257,18 @@ protected void initialize() { btnIcon = new JButton(); } + /** + * Builds a {@link DefaultComboBoxModel} of {@link FactionDisplay} options. + */ + private DefaultComboBoxModel buildFactionDisplayOptions() { + DefaultComboBoxModel factionModel = new DefaultComboBoxModel<>(); + + factionModel.addAll(FactionDisplay.getSortedValidFactionDisplays( + Factions.getInstance().getChoosableFactions(), campaign.getLocalDate())); + + return factionModel; + } + /** * This method is called when the "btnDate" button is clicked. * It shows a date chooser dialog and sets the selected date if the user chooses a date. diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java index 932c44506c..bfcd3cc3e4 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java @@ -1,7 +1,5 @@ package mekhq.gui.panes.campaignOptions.tabs; -import mekhq.gui.baseComponents.AbstractMHQScrollablePanel; - import javax.swing.*; import javax.swing.GroupLayout.Alignment; import java.util.Map; @@ -52,23 +50,6 @@ public RepairAndMaintenanceTab(JFrame frame, String name) { initialize(); } - /** - * Creates the general tab. - * - * @return the created general tab as an {@link AbstractMHQScrollablePanel} - */ - public JTabbedPane createRepairAndMaintenanceTab() { - JTabbedPane tabbedPane = new JTabbedPane(); - - JPanel repairPanel = createRepairTab(); - tabbedPane.addTab("Repair", repairPanel); - - JPanel maintenancePanel = createMaintenanceTab(); - tabbedPane.addTab("Maintenance", maintenancePanel); - - return tabbedPane; - } - /** * Creates the repair tab panel. * @@ -77,24 +58,24 @@ public JTabbedPane createRepairAndMaintenanceTab() { public JPanel createRepairTab() { // Header JPanel imagePanel = createHeaderPanel("RepairTab", - "data/images/universe/factions/logo_aurigan_coalition.png", false, + getImageDirectory() + "logo_aurigan_coalition.png", false, "", true); // Era Mods - useEraModsCheckBox = createCheckBox("useEraModsCheckBox", null); + useEraModsCheckBox = createCheckBox("UseEraModsCheckBox", null); // Tech Placement - assignedTechFirstCheckBox = createCheckBox("assignedTechFirstCheckBox", null); - resetToFirstTechCheckBox = createCheckBox("resetToFirstTechCheckBox", null); + assignedTechFirstCheckBox = createCheckBox("AssignedTechFirstCheckBox", null); + resetToFirstTechCheckBox = createCheckBox("ResetToFirstTechCheckBox", null); // Use Quirks - useQuirksBox = createCheckBox("useQuirksBox", null); + useQuirksBox = createCheckBox("UseQuirksBox", null); // Aero System Damage - useAeroSystemHitsBox = createCheckBox("useAeroSystemHitsBox", null); + useAeroSystemHitsBox = createCheckBox("UseAeroSystemHitsBox", null); // Damage by Margin - useDamageMargin = createCheckBox("useDamageMargin", null); + useDamageMargin = createCheckBox("UseDamageMargin", null); useDamageMargin.addActionListener(evt -> spnDamageMargin.setEnabled(useDamageMargin.isSelected())); Map damageMarginFields = createLabeledSpinner("DamageMargin", null, 1, 1, 20, 1); @@ -110,6 +91,7 @@ public JPanel createRepairTab() { lblDestroyPartTarget = entry.getKey(); spnDestroyPartTarget = entry.getValue(); } + JLabel lblDestroyPartTargetPost = new JLabel("+"); // Layout the Panel final JPanel panel = createStandardPanel("repairTab", true, ""); @@ -126,11 +108,12 @@ public JPanel createRepairTab() { .addComponent(useAeroSystemHitsBox) .addComponent(useDamageMargin) .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(spnDamageMargin) - .addComponent(lblDamageMargin, Alignment.LEADING)) + .addComponent(lblDamageMargin) + .addComponent(spnDamageMargin)) .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblDestroyPartTarget) .addComponent(spnDestroyPartTarget) - .addComponent(lblDestroyPartTarget, Alignment.LEADING))); + .addComponent(lblDestroyPartTargetPost))); layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) @@ -142,14 +125,17 @@ public JPanel createRepairTab() { .addComponent(useAeroSystemHitsBox) .addComponent(useDamageMargin) .addGroup(layout.createSequentialGroup() + .addComponent(lblDamageMargin) .addComponent(spnDamageMargin) - .addComponent(lblDamageMargin)) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() + .addComponent(lblDestroyPartTarget) .addComponent(spnDestroyPartTarget) - .addComponent(lblDestroyPartTarget))); + .addComponent(lblDestroyPartTargetPost) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); // Create Parent Panel and return - return createParentPanel(panel, "repairTab", 500, 500); + return createParentPanel(panel, "repairTab", 500); } /** @@ -160,11 +146,11 @@ public JPanel createRepairTab() { public JPanel createMaintenanceTab() { // Promotional Image JPanel imagePanel = createHeaderPanel("MaintenanceTab", - "data/images/universe/factions/logo_clan_blood_spirit.png", + getImageDirectory() + "logo_clan_blood_spirit.png", false, "", true); // Check Maintenance - checkMaintenance = createCheckBox("checkMaintenance", null); + checkMaintenance = createCheckBox("CheckMaintenance", null); // Maintenance Cycle Duration Map maintenanceDaysFields = createLabeledSpinner("MaintenanceDays", @@ -191,22 +177,22 @@ public JPanel createMaintenanceTab() { } // Use Quality Modifiers - useQualityMaintenance = createCheckBox("useQualityMaintenance", null); + useQualityMaintenance = createCheckBox("UseQualityMaintenance", null); // Reverse Quality names - reverseQualityNames = createCheckBox("reverseQualityNames", null); + reverseQualityNames = createCheckBox("ReverseQualityNames", null); // Use Random Unit Qualities - chkUseRandomUnitQualities = createCheckBox("chkUseRandomUnitQualities", null); + chkUseRandomUnitQualities = createCheckBox("UseRandomUnitQualities", null); // Use Planetary Modifiers - chkUsePlanetaryModifiers = createCheckBox("chkUsePlanetaryModifiers", null); + chkUsePlanetaryModifiers = createCheckBox("UsePlanetaryModifiers", null); // Only Damage F-Rated Equipment - useUnofficialMaintenance = createCheckBox("useUnofficialMaintenance", null); + useUnofficialMaintenance = createCheckBox("UseUnofficialMaintenance", null); // Report Maintenance checks to Log - logMaintenance = createCheckBox("logMaintenance", null); + logMaintenance = createCheckBox("LogMaintenance", null); // Layout the Panel final JPanel panel = createStandardPanel("repairTab", true, ""); @@ -218,14 +204,14 @@ public JPanel createMaintenanceTab() { .addComponent(imagePanel) .addComponent(checkMaintenance) .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(spnMaintenanceDays) - .addComponent(lblMaintenanceDays, Alignment.LEADING)) + .addComponent(lblMaintenanceDays) + .addComponent(spnMaintenanceDays)) .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(spnMaintenanceBonus) - .addComponent(lblMaintenanceBonus, Alignment.LEADING)) + .addComponent(lblMaintenanceBonus) + .addComponent(spnMaintenanceBonus)) .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(spnDefaultMaintenanceTime) - .addComponent(lblDefaultMaintenanceTime, Alignment.LEADING)) + .addComponent(lblDefaultMaintenanceTime) + .addComponent(spnDefaultMaintenanceTime)) .addComponent(useQualityMaintenance) .addComponent(reverseQualityNames) .addComponent(chkUseRandomUnitQualities) @@ -238,14 +224,17 @@ public JPanel createMaintenanceTab() { .addComponent(imagePanel) .addComponent(checkMaintenance) .addGroup(layout.createSequentialGroup() + .addComponent(lblMaintenanceDays) .addComponent(spnMaintenanceDays) - .addComponent(lblMaintenanceDays)) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() + .addComponent(lblMaintenanceBonus) .addComponent(spnMaintenanceBonus) - .addComponent(lblMaintenanceBonus)) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() + .addComponent(lblDefaultMaintenanceTime) .addComponent(spnDefaultMaintenanceTime) - .addComponent(lblDefaultMaintenanceTime)) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) .addComponent(useQualityMaintenance) .addComponent(reverseQualityNames) .addComponent(chkUseRandomUnitQualities) @@ -254,7 +243,7 @@ public JPanel createMaintenanceTab() { .addComponent(logMaintenance)); // Create Parent Panel and return - return createParentPanel(panel, "maintenanceTab", 500, 500); + return createParentPanel(panel, "maintenanceTab", 500); } private void recreateFinancesPanel(boolean isReversingQualityNames) { diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisition.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisition.java deleted file mode 100644 index 74cda2c8c9..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisition.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.tabs; - -public class SuppliesAndAcquisition { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java new file mode 100644 index 0000000000..1cbf6b27cf --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java @@ -0,0 +1,704 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +import megamek.client.ui.baseComponents.MMComboBox; +import megamek.common.EquipmentType; +import mekhq.MekHQ; +import mekhq.campaign.campaignOptions.CampaignOptions; +import mekhq.campaign.enums.PlanetaryAcquisitionFactionLimit; +import mekhq.campaign.personnel.SkillType; + +import javax.swing.*; +import javax.swing.GroupLayout.Alignment; +import java.awt.*; +import java.util.Map; +import java.util.Map.Entry; +import java.util.ResourceBundle; + +import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; + +public class SuppliesAndAcquisitionTab { + // region Variable Declarations + private static String RESOURCE_PACKAGE = "mekhq/resources/NEWCampaignOptionsDialog"; + private static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE, + MekHQ.getMHQOptions().getLocale()); + + JFrame frame; + String name; + + //start Acquisition Tab + private JLabel lblChoiceAcquireSkill; + private MMComboBox choiceAcquireSkill; + private JCheckBox chkSupportStaffOnly; + private JLabel lblAcquireClanPenalty; + private JSpinner spnAcquireClanPenalty; + private JLabel lblAcquireIsPenalty; + private JSpinner spnAcquireIsPenalty; + private JLabel lblAcquireWaitingPeriod; + private JSpinner spnAcquireWaitingPeriod; + private JLabel lblMaxAcquisitions; + private JSpinner spnMaxAcquisitions; + //end Acquisition Tab + + //start Delivery Tab + private JLabel lblNDiceTransitTime; + private JSpinner spnNDiceTransitTime; + private JLabel lblConstantTransitTime; + private JSpinner spnConstantTransitTime; + private JLabel lblAcquireMosBonus; + private JSpinner spnAcquireMosBonus; + private JLabel lblAcquireMinimum; + private JSpinner spnAcquireMinimum; + private MMComboBox choiceTransitTimeUnits; + private MMComboBox choiceAcquireMosUnits; + private MMComboBox choiceAcquireMinimumUnit; + private static final int TRANSIT_UNIT_DAY = 0; + private static final int TRANSIT_UNIT_WEEK = 1; + private static final int TRANSIT_UNIT_MONTH = 2; + private static final int TRANSIT_UNIT_NUM = 3; + //end Delivery Tab + + //start Planetary Acquisition Tab + private JCheckBox usePlanetaryAcquisitions; + private JLabel lblMaxJumpPlanetaryAcquisitions; + private JSpinner spnMaxJumpPlanetaryAcquisitions; + private JLabel lblPlanetaryAcquisitionsFactionLimits; + private MMComboBox comboPlanetaryAcquisitionsFactionLimits; + private JCheckBox disallowClanPartsFromIS; + private JCheckBox disallowPlanetaryAcquisitionClanCrossover; + private JLabel lblPenaltyClanPartsFromIS; + private JSpinner spnPenaltyClanPartsFromIS; + private JCheckBox usePlanetaryAcquisitionsVerbose; + private JLabel[] lblPlanetAcquireTechBonus; + private JSpinner[] spnPlanetAcquireTechBonus; + private JLabel[] lblPlanetAcquireIndustryBonus; + private JSpinner[] spnPlanetAcquireIndustryBonus; + private JLabel[] lblPlanetAcquireOutputBonus; + private JSpinner[] spnPlanetAcquireOutputBonus; + //end Planetary Acquisition Tab + + public SuppliesAndAcquisitionTab(JFrame frame, String name) { + this.frame = frame; + this.name = name; + + initialize(); + } + + /** + * Creates the acquisition tab panel. + * + * @return the created tab panel as a {@link JPanel} + */ + public JPanel createAcquisitionTab() { + // Header + JPanel headerPanel = createHeaderPanel("AcquisitionTab", + getImageDirectory() + "logo_calderon_protectorate.png", false, + "", true); + + // Acquisitions skill + lblChoiceAcquireSkill = createLabel("ChoiceAcquireSkill", null); + int choiceAcquireSkillWidth = getDimensionWidthForComboBox(choiceAcquireSkill); + choiceAcquireSkill.setMinimumSize(new Dimension(choiceAcquireSkillWidth, 30)); + choiceAcquireSkill.setMaximumSize(new Dimension(choiceAcquireSkillWidth , 30)); + + // Support personnel only + chkSupportStaffOnly = createCheckBox("SupportStaffOnly", null); + + // Clan Acquisition penalty + Map acquireClanPenaltyFields = createLabeledSpinner("AcquireClanPenalty", + null, 0, 0, 13, 1); + for (Entry entry : acquireClanPenaltyFields.entrySet()) { + lblAcquireClanPenalty = entry.getKey(); + spnAcquireClanPenalty = entry.getValue(); + } + + // IS Acquisition penalty + Map acquireIsPenaltyFields = createLabeledSpinner("AcquireISPenalty", + null, 0, 0, 13, 1); + for (Entry entry : acquireIsPenaltyFields.entrySet()) { + lblAcquireIsPenalty = entry.getKey(); + spnAcquireIsPenalty = entry.getValue(); + } + + // Waiting Period + Map acquireWaitingPeriodFields = createLabeledSpinner("AcquireWaitingPeriod", + null, 1, 1, 365, 1); + for (Entry entry : acquireWaitingPeriodFields.entrySet()) { + lblAcquireWaitingPeriod = entry.getKey(); + spnAcquireWaitingPeriod = entry.getValue(); + } + + // Maximum Acquisitions + Map maxAcquisitionsFields = createLabeledSpinner("MaxAcquisitions", + null, 0,0, 100, 1); + for (Entry entry : maxAcquisitionsFields.entrySet()) { + lblMaxAcquisitions = entry.getKey(); + spnMaxAcquisitions = entry.getValue(); + } + + // Layout the Panel + final JPanel panel = createStandardPanel("acquisitionTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblChoiceAcquireSkill) + .addComponent(choiceAcquireSkill)) + .addComponent(chkSupportStaffOnly) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblAcquireClanPenalty) + .addComponent(spnAcquireClanPenalty)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblAcquireIsPenalty) + .addComponent(spnAcquireIsPenalty)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblAcquireWaitingPeriod) + .addComponent(spnAcquireWaitingPeriod)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblMaxAcquisitions) + .addComponent(spnMaxAcquisitions))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel) + .addGroup(layout.createSequentialGroup() + .addComponent(lblChoiceAcquireSkill) + .addComponent(choiceAcquireSkill) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkSupportStaffOnly) + .addGroup(layout.createSequentialGroup() + .addComponent(lblAcquireClanPenalty) + .addComponent(spnAcquireClanPenalty) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblAcquireIsPenalty) + .addComponent(spnAcquireIsPenalty) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblAcquireWaitingPeriod) + .addComponent(spnAcquireWaitingPeriod) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblMaxAcquisitions) + .addComponent(spnMaxAcquisitions) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + // Create Parent Panel and return + return createParentPanel(panel, "acquisitionsTab", 500); + } + + public JPanel createPlanetaryAcquisitionTab() { + // Header + JPanel headerPanel = createHeaderPanel("PlanetaryAcquisitionTab", + getImageDirectory() + "logo_capellan_confederation.png", false, + "", true); + + // Sub-Panels + JPanel options = createOptionsPanel(); + JPanel modifiers = createModifiersPanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("PlanetaryAcquisitionTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(options) + .addComponent(modifiers))); + + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel) + .addGroup(layout.createSequentialGroup() + .addComponent(options) + .addComponent(modifiers))); + + // Create Parent Panel and return + return createParentPanel(panel, "PlanetaryAcquisitionTab", 800); + } + + + /** + * Creates the planetary acquisition options panel. + * + * @return the created tab panel as a {@link JPanel} + */ + private JPanel createOptionsPanel() { + // Use Planetary Acquisitions + usePlanetaryAcquisitions = createCheckBox("UsePlanetaryAcquisitions", null); + + // Max Jump Distance + Map maxJumpPlanetaryAcquisitionsFields = createLabeledSpinner( + "MaxJumpPlanetaryAcquisitions", null, 2, 0, + 5, 1); + for (Entry entry : maxJumpPlanetaryAcquisitionsFields.entrySet()) { + lblMaxJumpPlanetaryAcquisitions = entry.getKey(); + spnMaxJumpPlanetaryAcquisitions = entry.getValue(); + } + + // Faction Limits + lblPlanetaryAcquisitionsFactionLimits = createLabel("PlanetaryAcquisitionsFactionLimits", null); + int comboPlanetaryAcquisitionsFactionLimitsWidth = getDimensionWidthForComboBox(comboPlanetaryAcquisitionsFactionLimits); + comboPlanetaryAcquisitionsFactionLimits.setMinimumSize(new Dimension(comboPlanetaryAcquisitionsFactionLimitsWidth, + 30)); + comboPlanetaryAcquisitionsFactionLimits.setMaximumSize(new Dimension(comboPlanetaryAcquisitionsFactionLimitsWidth, + 30)); + + // Disallow Resource Sharing (Inner Sphere) + disallowPlanetaryAcquisitionClanCrossover = createCheckBox("DisallowPlanetaryAcquisitionClanCrossover", null); + + // Disallow Resource Sharing (Clans) + disallowClanPartsFromIS = createCheckBox("DisallowClanPartsFromIS", null); + + // Acquisition Penalty + Map penaltyClanPartsFromISFields = createLabeledSpinner( + "PenaltyClanPartsFromIS", null, 0, 0, 12, + 1); + for (Entry entry : penaltyClanPartsFromISFields.entrySet()) { + lblPenaltyClanPartsFromIS = entry.getKey(); + spnPenaltyClanPartsFromIS = entry.getValue(); + } + + // Verbose Reporting + usePlanetaryAcquisitionsVerbose = createCheckBox("UsePlanetaryAcquisitionsVerbose", null); + + // Layout the Panel + final JPanel panel = new JPanel(); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(usePlanetaryAcquisitions) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(spnMaxJumpPlanetaryAcquisitions) + .addComponent(lblMaxJumpPlanetaryAcquisitions)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(comboPlanetaryAcquisitionsFactionLimits) + .addComponent(lblPlanetaryAcquisitionsFactionLimits)) + .addComponent(disallowPlanetaryAcquisitionClanCrossover) + .addComponent(disallowClanPartsFromIS) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(spnPenaltyClanPartsFromIS) + .addComponent(lblPenaltyClanPartsFromIS)) + .addComponent(usePlanetaryAcquisitionsVerbose)); + + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(usePlanetaryAcquisitions) + .addGroup(layout.createSequentialGroup() + .addComponent(lblMaxJumpPlanetaryAcquisitions) + .addComponent(spnMaxJumpPlanetaryAcquisitions) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(comboPlanetaryAcquisitionsFactionLimits) + .addComponent(lblPlanetaryAcquisitionsFactionLimits) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(disallowPlanetaryAcquisitionClanCrossover) + .addComponent(disallowClanPartsFromIS) + .addGroup(layout.createSequentialGroup() + .addComponent(lblPenaltyClanPartsFromIS) + .addComponent(spnPenaltyClanPartsFromIS) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(usePlanetaryAcquisitionsVerbose)); + + return panel; + } + + /** + * Creates the planetary acquisition modifiers panel. + * + * @return the created tab panel as a {@link JPanel} + */ + private JPanel createModifiersPanel() { + JLabel techLabel = createLabel("TechLabel", null); + JLabel industryLabel = createLabel("IndustryLabel", null); + JLabel outputLabel = createLabel("OutputLabel", null); + + // Modifier Spinners + for (int i = EquipmentType.RATING_A; i <= EquipmentType.RATING_F; i++) { + String modifierLabel = getModifierLabel(i); + + lblPlanetAcquireTechBonus[i] = new JLabel(String.format("%s", + modifierLabel)); + spnPlanetAcquireTechBonus[i] = new JSpinner(new SpinnerNumberModel( + 0, -12, 12, 1)); + setSpinnerWidth(spnPlanetAcquireTechBonus[i]); + + lblPlanetAcquireIndustryBonus[i] = new JLabel(String.format("%s", + modifierLabel)); + spnPlanetAcquireIndustryBonus[i] = new JSpinner(new SpinnerNumberModel( + 0, -12, 12, 1)); + setSpinnerWidth(spnPlanetAcquireIndustryBonus[i]); + + lblPlanetAcquireOutputBonus[i] = new JLabel(String.format("%s", + modifierLabel)); + spnPlanetAcquireOutputBonus[i] = new JSpinner(new SpinnerNumberModel( + 0, -12, 12, 1)); + setSpinnerWidth(spnPlanetAcquireOutputBonus[i]); + } + + // Layout the Panel + final JPanel panel = createStandardPanel("PlanetaryAcquisitionTabModifiers", + true, "ModifiersPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(techLabel) + .addComponent(industryLabel) + .addComponent(outputLabel)) + // There has to be a better way of doing this, but I couldn't fathom it + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPlanetAcquireTechBonus[0]) + .addComponent(spnPlanetAcquireTechBonus[0]) + .addComponent(lblPlanetAcquireIndustryBonus[0]) + .addComponent(spnPlanetAcquireIndustryBonus[0]) + .addComponent(lblPlanetAcquireOutputBonus[0]) + .addComponent(spnPlanetAcquireOutputBonus[0])) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPlanetAcquireTechBonus[1]) + .addComponent(spnPlanetAcquireTechBonus[1]) + .addComponent(lblPlanetAcquireIndustryBonus[1]) + .addComponent(spnPlanetAcquireIndustryBonus[1]) + .addComponent(lblPlanetAcquireOutputBonus[1]) + .addComponent(spnPlanetAcquireOutputBonus[1])) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPlanetAcquireTechBonus[2]) + .addComponent(spnPlanetAcquireTechBonus[2]) + .addComponent(lblPlanetAcquireIndustryBonus[2]) + .addComponent(spnPlanetAcquireIndustryBonus[2]) + .addComponent(lblPlanetAcquireOutputBonus[2]) + .addComponent(spnPlanetAcquireOutputBonus[2])) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPlanetAcquireTechBonus[3]) + .addComponent(spnPlanetAcquireTechBonus[3]) + .addComponent(lblPlanetAcquireIndustryBonus[3]) + .addComponent(spnPlanetAcquireIndustryBonus[3]) + .addComponent(lblPlanetAcquireOutputBonus[3]) + .addComponent(spnPlanetAcquireOutputBonus[3])) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPlanetAcquireTechBonus[4]) + .addComponent(spnPlanetAcquireTechBonus[4]) + .addComponent(lblPlanetAcquireIndustryBonus[4]) + .addComponent(spnPlanetAcquireIndustryBonus[4]) + .addComponent(lblPlanetAcquireOutputBonus[4]) + .addComponent(spnPlanetAcquireOutputBonus[4])) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPlanetAcquireTechBonus[5]) + .addComponent(spnPlanetAcquireTechBonus[5]) + .addComponent(lblPlanetAcquireIndustryBonus[5]) + .addComponent(spnPlanetAcquireIndustryBonus[5]) + .addComponent(lblPlanetAcquireOutputBonus[5]) + .addComponent(spnPlanetAcquireOutputBonus[5]))); + + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(35) + .addComponent(techLabel) + .addGap(40) + .addComponent(industryLabel) + .addGap(40) + .addComponent(outputLabel)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblPlanetAcquireTechBonus[0]) + .addComponent(spnPlanetAcquireTechBonus[0]) + .addComponent(lblPlanetAcquireIndustryBonus[0]) + .addComponent(spnPlanetAcquireIndustryBonus[0]) + .addComponent(lblPlanetAcquireOutputBonus[0]) + .addComponent(spnPlanetAcquireOutputBonus[0])) + .addGroup(layout.createSequentialGroup() + .addComponent(lblPlanetAcquireTechBonus[1]) + .addComponent(spnPlanetAcquireTechBonus[1]) + .addComponent(lblPlanetAcquireIndustryBonus[1]) + .addComponent(spnPlanetAcquireIndustryBonus[1]) + .addComponent(lblPlanetAcquireOutputBonus[1]) + .addComponent(spnPlanetAcquireOutputBonus[1])) + .addGroup(layout.createSequentialGroup() + .addComponent(lblPlanetAcquireTechBonus[2]) + .addComponent(spnPlanetAcquireTechBonus[2]) + .addComponent(lblPlanetAcquireIndustryBonus[2]) + .addComponent(spnPlanetAcquireIndustryBonus[2]) + .addComponent(lblPlanetAcquireOutputBonus[2]) + .addComponent(spnPlanetAcquireOutputBonus[2])) + .addGroup(layout.createSequentialGroup() + .addComponent(lblPlanetAcquireTechBonus[3]) + .addComponent(spnPlanetAcquireTechBonus[3]) + .addComponent(lblPlanetAcquireIndustryBonus[3]) + .addComponent(spnPlanetAcquireIndustryBonus[3]) + .addComponent(lblPlanetAcquireOutputBonus[3]) + .addComponent(spnPlanetAcquireOutputBonus[3])) + .addGroup(layout.createSequentialGroup() + .addComponent(lblPlanetAcquireTechBonus[4]) + .addComponent(spnPlanetAcquireTechBonus[4]) + .addComponent(lblPlanetAcquireIndustryBonus[4]) + .addComponent(spnPlanetAcquireIndustryBonus[4]) + .addComponent(lblPlanetAcquireOutputBonus[4]) + .addComponent(spnPlanetAcquireOutputBonus[4])) + .addGroup(layout.createSequentialGroup() + .addComponent(lblPlanetAcquireTechBonus[5]) + .addComponent(spnPlanetAcquireTechBonus[5]) + .addComponent(lblPlanetAcquireIndustryBonus[5]) + .addComponent(spnPlanetAcquireIndustryBonus[5]) + .addComponent(lblPlanetAcquireOutputBonus[5]) + .addComponent(spnPlanetAcquireOutputBonus[5]))); + + return panel; + } + + /** + * Sets the width of a {@link JSpinner} component based on the width of the text that would be + * displayed in it. + * + * @param spinner the {@link JSpinner} to set the width for + */ + private void setSpinnerWidth(JSpinner spinner) { + FontMetrics fontMetrics = spinner.getFontMetrics(spinner.getFont()); + int width = fontMetrics.stringWidth(Double.toString(12)); + width = width * WIDTH_MULTIPLIER_NUMBER; + + spinner.setMaximumSize(new Dimension(width, 30)); + spinner.setMinimumSize(new Dimension(width, 30)); + } + + /** + * Retrieves the label for a given quality modifier. + * + * @param quality The quality modifier represented by an integer value. + * @return The label corresponding to the quality modifier. + */ + private String getModifierLabel(int quality) { + return switch (quality) { + case EquipmentType.RATING_A -> "A"; + case EquipmentType.RATING_B -> "B"; + case EquipmentType.RATING_C -> "C"; + case EquipmentType.RATING_D -> "D"; + case EquipmentType.RATING_E -> "E"; + case EquipmentType.RATING_F -> "F"; + default -> "ERROR"; + }; + } + + /** + * Creates the delivery tab panel. + * + * @return the created tab panel as a {@link JPanel} + */ + public JPanel createDeliveryTab() { + // Header + JPanel headerPanel = createHeaderPanel("DeliveryTab", + getImageDirectory() + "logo_clan_burrock.png", false, + "", true); + + // Delivery Time + Map nDiceTransitTimeFields = createLabeledSpinner("NDiceTransitTime", + null, 0, 0, 365, 1); + for (Entry entry : nDiceTransitTimeFields.entrySet()) { + lblNDiceTransitTime = entry.getKey(); + spnNDiceTransitTime = entry.getValue(); + } + + Map constantTransitTimeFields = createLabeledSpinner("ConstantTransitTime", + null, 0, 0, 365, 1); + for (Entry entry : constantTransitTimeFields.entrySet()) { + lblConstantTransitTime = entry.getKey(); + spnConstantTransitTime = entry.getValue(); + } + + int choiceTimeUnitsWidth = getDimensionWidthForComboBox(choiceTransitTimeUnits); + choiceTransitTimeUnits.setMinimumSize(new Dimension(choiceTimeUnitsWidth, 30)); + choiceTransitTimeUnits.setMaximumSize(new Dimension(choiceTimeUnitsWidth, 30)); + + // Margin of Success Reductions + Map acquireMosBonusFields = createLabeledSpinner("AcquireMosBonus", + null, 0, 0, 365, 1); + for (Entry entry : acquireMosBonusFields.entrySet()) { + lblAcquireMosBonus = entry.getKey(); + spnAcquireMosBonus = entry.getValue(); + } + + choiceAcquireMosUnits.setMinimumSize(new Dimension(choiceTimeUnitsWidth, 30)); + choiceAcquireMosUnits.setMaximumSize(new Dimension(choiceTimeUnitsWidth, 30)); + + // Minimum Transit Time + Map acquireMinimumFields = createLabeledSpinner("AcquireMinimum", + null, 0, 0, 365, 1); + for (Entry entry : acquireMinimumFields.entrySet()) { + lblAcquireMinimum = entry.getKey(); + spnAcquireMinimum = entry.getValue(); + } + + choiceAcquireMinimumUnit.setMinimumSize(new Dimension(choiceTimeUnitsWidth, 30)); + choiceAcquireMinimumUnit.setMaximumSize(new Dimension(choiceTimeUnitsWidth, 30)); + + // Layout the Panel + final JPanel panel = createStandardPanel("deliveryTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblNDiceTransitTime) + .addComponent(spnNDiceTransitTime) + .addComponent(lblConstantTransitTime) + .addComponent(spnConstantTransitTime) + .addComponent(choiceTransitTimeUnits)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblAcquireMosBonus) + .addComponent(spnAcquireMosBonus) + .addComponent(choiceAcquireMosUnits)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblAcquireMinimum) + .addComponent(spnAcquireMinimum) + .addComponent(choiceAcquireMinimumUnit))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel) + .addGroup(layout.createSequentialGroup() + .addComponent(lblNDiceTransitTime) + .addComponent(spnNDiceTransitTime) + .addComponent(lblConstantTransitTime) + .addComponent(spnConstantTransitTime) + .addComponent(choiceTransitTimeUnits) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblAcquireMosBonus) + .addComponent(spnAcquireMosBonus) + .addComponent(choiceAcquireMosUnits) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblAcquireMinimum) + .addComponent(spnAcquireMinimum) + .addComponent(choiceAcquireMinimumUnit) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + // Create Parent Panel and return + return createParentPanel(panel, "deliveryTab", 600); + } + + /** + * Retrieves the transit unit options as a {@link DefaultComboBoxModel}. + * + * @return The {@link DefaultComboBoxModel} containing the transit unit options with labels fetched + * from {@code getTransitUnitName()}. + */ + private static DefaultComboBoxModel getTransitUnitOptions() { + DefaultComboBoxModel transitUnitModel = new DefaultComboBoxModel<>(); + + for (int i = 0; i < TRANSIT_UNIT_NUM; i++) { + transitUnitModel.addElement(getTransitUnitName(i)); + } + return transitUnitModel; + } + + /** + * Returns the name of the transit unit based on the given unit value. + * + * @param unit the unit value representing the transit unit + * @return the name of the transit unit as a {@link String} + */ + private static String getTransitUnitName(final int unit) { + return switch (unit) { + case TRANSIT_UNIT_DAY -> resources.getString("transitUnitNamesDays.text"); + case TRANSIT_UNIT_WEEK -> resources.getString("transitUnitNamesWeeks.text"); + case TRANSIT_UNIT_MONTH -> resources.getString("transitUnitNamesMonths.text"); + default -> "ERROR"; + }; + } + + /** + * Builds the options for the acquisition skill combo box. + * + * @return the default combo box model containing the acquisition skill options + */ + private static DefaultComboBoxModel buildAcquireSkillComboOptions() { + DefaultComboBoxModel acquireSkillModel = new DefaultComboBoxModel<>(); + + acquireSkillModel.addElement(CampaignOptions.S_TECH); + acquireSkillModel.addElement(SkillType.S_ADMIN); + acquireSkillModel.addElement(SkillType.S_SCROUNGE); + acquireSkillModel.addElement(SkillType.S_NEG); + acquireSkillModel.addElement(CampaignOptions.S_AUTO); + + return acquireSkillModel; + } + + protected void initialize() { + // Acquisition Tab + lblChoiceAcquireSkill = new JLabel(); + choiceAcquireSkill = new MMComboBox<>("choiceAcquireSkill", buildAcquireSkillComboOptions()); + + chkSupportStaffOnly = new JCheckBox(); + + lblAcquireClanPenalty = new JLabel(); + spnAcquireClanPenalty = new JSpinner(); + + lblAcquireIsPenalty = new JLabel(); + spnAcquireIsPenalty = new JSpinner(); + + lblAcquireWaitingPeriod = new JLabel(); + spnAcquireWaitingPeriod = new JSpinner(); + + lblMaxAcquisitions = new JLabel(); + spnMaxAcquisitions = new JSpinner(); + + // Delivery Tab + lblNDiceTransitTime = new JLabel(); + spnNDiceTransitTime = new JSpinner(); + lblConstantTransitTime = new JLabel(); + spnConstantTransitTime = new JSpinner(); + choiceTransitTimeUnits = new MMComboBox<>("choiceTransitTimeUnits", getTransitUnitOptions()); + + lblAcquireMosBonus = new JLabel(); + spnAcquireMosBonus = new JSpinner(); + choiceAcquireMosUnits = new MMComboBox<>("choiceAcquireMosUnits", getTransitUnitOptions()); + + lblAcquireMinimum = new JLabel(); + spnAcquireMinimum = new JSpinner(); + choiceAcquireMinimumUnit = new MMComboBox<>("choiceAcquireMinimumUnit", getTransitUnitOptions()); + + // Planetary Acquisition Tab + // Options + usePlanetaryAcquisitions = new JCheckBox(); + + lblMaxJumpPlanetaryAcquisitions = new JLabel(); + spnMaxJumpPlanetaryAcquisitions = new JSpinner(); + + lblPlanetaryAcquisitionsFactionLimits = new JLabel(); + comboPlanetaryAcquisitionsFactionLimits = new MMComboBox<>("comboPlanetaryAcquisitionsFactionLimits", + PlanetaryAcquisitionFactionLimit.values()); + + disallowPlanetaryAcquisitionClanCrossover = new JCheckBox(); + + disallowClanPartsFromIS = new JCheckBox(); + + lblPenaltyClanPartsFromIS = new JLabel(); + spnPenaltyClanPartsFromIS = new JSpinner(); + + usePlanetaryAcquisitionsVerbose = new JCheckBox(); + + // Modifiers + lblPlanetAcquireTechBonus = new JLabel[6]; + spnPlanetAcquireTechBonus = new JSpinner[6]; + + lblPlanetAcquireIndustryBonus = new JLabel[6]; + spnPlanetAcquireIndustryBonus = new JSpinner[6]; + + lblPlanetAcquireOutputBonus = new JLabel[6]; + spnPlanetAcquireOutputBonus = new JSpinner[6]; + } +} From 95f6c04c09bdef82d000764d8dd7d66cea60e40a Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 2 Oct 2024 15:21:24 -0500 Subject: [PATCH 013/117] Simplify checkbox and spinner creation methods Replaced the createLabeledSpinner method with distinct createSpinner and createLabel methods to simplify spinner creation. This change reduced redundancy by removing the need for label creation in spinner methods and updated relevant sections across multiple files. Additionally, the getDimensionWidthForComboBox and getDimensionWidthForButton helper methods were removed to streamline the codebase. --- .../tabs/CampaignOptionsUtilities.java | 208 ++++++++---------- .../campaignOptions/tabs/GeneralTab.java | 45 +--- .../tabs/RepairAndMaintenanceTab.java | 48 ++-- .../tabs/SuppliesAndAcquisitionTab.java | 117 +++------- 4 files changed, 148 insertions(+), 270 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index 9f6ff98974..e4cf79f393 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -17,8 +17,6 @@ public class CampaignOptionsUtilities { private static final MMLogger logger = MMLogger.create(CampaignOptionsPane.class); private static final String RESOURCE_PACKAGE = "mekhq/resources/NEWCampaignOptionsDialog"; private static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE); - - final static int WIDTH_MULTIPLIER_NUMBER = 3; // This seems to be the sweet spot final static String IMAGE_DIRECTORY = "data/images/universe/factions/"; /** @@ -29,12 +27,10 @@ static String getImageDirectory() { } /** - * Returns a new {@link JCheckBox} object with the specified name, label, and tooltip. + * Returns a new {@link JCheckBox} object. *

- * Please note that 'name' is also used to fetch the resources associated with this object. - * For the label text 'name' is appended by '.text'. - * For the tooltip 'name' is appended with '.tooltip'. - * These values must exist in the resource bundle otherwise an error will be thrown. + * The {@link JCheckBox} will be named {@code "chk" + name}, and use the following resource bundle references: + * {@code "lbl" + name + ".text"} and {@code "lbl" + name + ".tooltip"}. * * @param name the name of the checkbox * @param customWrapSize the maximum number of characters (including whitespaces) on each @@ -53,42 +49,35 @@ static JCheckBox createCheckBox(String name, @Nullable Integer customWrapSize) { } /** - * Creates a map containing a {@link JLabel} and a {@link JSpinner} object. + * Creates a {@link JSpinner} object. *

- * Please note that 'name' is also used to fetch the resources associated with these objects. - * For the label text 'name' is appended by '.text'. - * For the tooltips 'name' is appended with '.tooltip'. - * These values must exist in the resource bundle otherwise an error will be thrown. + * The name of the {@link JSpinner} will be {@code "spn" + name}, + * and it will use the {@code "lbl" + name + ".tooltip"} resource bundle item * * @param name a string representing the name of the objects. - * The {@link JLabel} will have 'lbl' appended. - * The {@link JSpinner} is appended with 'spn'. * @param customWrapSize the maximum number of characters (including whitespaces) on each * line of the tooltip (or 100, if {@code null}). - * @param defaultValue a double representing the default value of the spinner - * @param minimum a double representing the minimum value of the spinner - * @param maximum a double representing the maximum value of the spinner - * @param stepSize a double representing the step size of the spinner - * @return a map containing a {@link JLabel} key and a {@link JSpinner} value. + * @param defaultValue The default value of the spinner + * @param minimum The minimum value of the spinner + * @param maximum The maximum value of the spinner + * @param stepSize The step size of the spinner + * @return The created {@link JSpinner}. */ - static Map createLabeledSpinner(String name, @Nullable Integer customWrapSize, + static JSpinner createSpinner(String name, @Nullable Integer customWrapSize, double defaultValue, double minimum, double maximum, double stepSize) { customWrapSize = processWrapSize(customWrapSize); - final JLabel jLabel = createLabel(name, customWrapSize); - JSpinner jSpinner = new JSpinner(new SpinnerNumberModel(defaultValue, minimum, maximum, stepSize)); + JSpinner jSpinner = new JSpinner(); + jSpinner.setModel(new SpinnerNumberModel(defaultValue, minimum, maximum, stepSize)); jSpinner.setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), customWrapSize)); jSpinner.setName("spn" + name); - FontMetrics fontMetrics = jSpinner.getFontMetrics(jSpinner.getFont()); - int width = fontMetrics.stringWidth(Double.toString(maximum)); - width = width * WIDTH_MULTIPLIER_NUMBER; - - jSpinner.setMaximumSize(new Dimension(width, 30)); - jSpinner.setMinimumSize(new Dimension(width, 30)); + Dimension size = jSpinner.getPreferredSize(); + jSpinner.setMaximumSize(size); + jSpinner.setMinimumSize(size); - return Map.of(jLabel, jSpinner); + return jSpinner; } /** @@ -112,92 +101,38 @@ static JLabel createLabel(String name, @Nullable Integer customWrapSize) { jLabel.setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), customWrapSize)); jLabel.setName("lbl" + name); - FontMetrics fontMetrics = jLabel.getFontMetrics(jLabel.getFont()); - // The whitespaces create a consistent buffer that will scale with different fonts. - int width = fontMetrics.stringWidth(removeHtmlTags(jLabel.getText()) + " "); - - jLabel.setMinimumSize(new Dimension(width, 30)); - jLabel.setMaximumSize(new Dimension(width, 30)); + Dimension size = jLabel.getPreferredSize(); + jLabel.setMinimumSize(size); + jLabel.setMaximumSize(size); return jLabel; } /** - * Calculates the optimal width for a {@link JComboBox} based on the text of its items. - * - * @param comboBox the {@link JComboBox} for which to calculate the width of each item's text - * @return the width of the widest item's text in the {@link JComboBox}, including a buffer space - */ - static int getDimensionWidthForComboBox(JComboBox comboBox) { - int width = 0; - - FontMetrics fontMetrics = comboBox.getFontMetrics(comboBox.getFont()); - - for (int i = 0; i < comboBox.getItemCount(); i++) { - String itemText = comboBox.getItemAt(i).toString(); - int workingWidth = fontMetrics.stringWidth(itemText); - - if (workingWidth > width) { - width = workingWidth; - } - } - - return (int) (width * 1.25); - } - - /** - * Calculates the width of the text on a {@link JButton}. - * - * @param jButton the {@link JButton} to calculate the width for - * @return the adjusted width of the button text - */ - static int getDimensionWidthForButton(JButton jButton) { - FontMetrics fontMetrics = jButton.getFontMetrics(jButton.getFont()); - - // The whitespaces create a consistent buffer that will scale with different fonts. - return fontMetrics.stringWidth(removeHtmlTags(" " + jButton.getText() + " ")); - } - - /** - * Creates a map containing a {@link JLabel} and a {@link JTextField} object. + * Creates a {@link JTextField} object. *

- * Please note that 'name' is also used to fetch the resources associated with these objects. - * For the label text 'name' is appended by '.text'. - * For the tooltips 'name' is appended with '.tooltip'. - * These values must exist in the resource bundle otherwise an error will be thrown. + * The name of the {@link JTextField} will be {@code}, and it will use the following resource bundle reference: + * {@code "lbl" + name + ".tooltip"}. * - * @param name the name of the objects. - * The {@link JLabel} will have 'lbl' appended. - * The {@link JTextField} is appended with 'txt'. - * @param customWrapSize the maximum number of characters (including whitespaces) on each + * @param name the name of the object. + * @param customWrapSize the maximum number of characters (including whitespaces) on each * line of the tooltip. * If {@code null}, the default wrap size of 100 is used. - * @param minimumSizeWidth the minimum width of the {@link JTextField}. - * @param minimumSizeHeight the minimum height of the {@link JTextField}. - * @param maximumSizeWidth the maximum width of the {@link JTextField}. - * If {@code null}, the minimum size width is used. - * @param maximumSizeHeight the maximum height of the {@link JTextField}. - * If {@code null}, the minimum size height is used. + * @param width The width of the {@link JTextField}. + * @param height The height of the {@link JTextField}. * @return a map containing a {@link JLabel} key and a {@link JTextField} value. */ - static Map createLabeledTextField(String name, - @Nullable Integer customWrapSize, int minimumSizeWidth, - int minimumSizeHeight, @Nullable Integer maximumSizeWidth, - @Nullable Integer maximumSizeHeight) { + static JTextField createTextField(String name, @Nullable Integer customWrapSize, int width, int height) { customWrapSize = processWrapSize(customWrapSize); - JLabel jLabel = createLabel(name, customWrapSize); JTextField jTextField = new JTextField(); jTextField.setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), customWrapSize)); jTextField.setName("txt" + name); - jTextField.setMinimumSize(new Dimension(minimumSizeWidth, minimumSizeHeight)); - - maximumSizeWidth = maximumSizeWidth == null ? minimumSizeWidth : maximumSizeWidth; - maximumSizeHeight = maximumSizeHeight == null ? minimumSizeHeight : maximumSizeHeight; - jTextField.setMaximumSize(new Dimension(maximumSizeWidth, maximumSizeHeight)); + jTextField.setMinimumSize(new Dimension(width, height)); + jTextField.setMaximumSize(new Dimension(width, height)); - return Map.of(jLabel, jTextField); + return jTextField; } /** @@ -218,13 +153,16 @@ private static int processWrapSize(@Nullable Integer customWrapSize) { *

* {@code createStandardLayout} should also be called and the resulting {@link GroupLayout} * assigned to the panel via {@code setLayout}. + *

+ * If {@code borderTitle} isn't empty the resource bundle reference, used to fetch the border's + * title, will be {@code "lbl" + borderTitle + ".text"} * * @param name the name of the panel. * @param includeBorder whether the panel should have a border. * @param borderTitle The resource string that should be used as the title of the border. * Can be empty to generate an untitled border. * - * @return a JPanel with a titled border and GroupLayout as its layout manager + * @return a {@link JPanel} with a titled border and {@link GroupLayout} as its layout manager */ static JPanel createStandardPanel(String name, boolean includeBorder, String borderTitle) { borderTitle = borderTitle.isBlank() ? "" : resources.getString("lbl" + borderTitle + ".text"); @@ -244,17 +182,18 @@ static JPanel createStandardPanel(String name, boolean includeBorder, String bor /** * Creates a {@link JPanel} consisting of a {@link JLabel} above an image. * If {@code includeBodyText} is {@code true} a second {@link JLabel} is placed after the first. + *

+ * The {@link JPanel} will be named {@code "pnl" + name + "HeaderPanel"}. + * The resource bundle references for the first {@link JLabel} will be {@code "lbl" + name + ".text"}. + * The optional second {@link JLabel} is assigned the name {@code ""lbl" + name + "HeaderBody"} + * and uses the following resource bundle reference: {@code "lbl" + name + "Body.text"}. * * @param name the name of the header panel. - * The {@link JLabel} will have 'lbl' appended. This will be appended with - * '.text' to fetch the label contents from the resource bundle. - * The {@link JPanel} is appended with 'pnl'. * @param imageAddress the file path of the image to be displayed in the panel * @param includeBorder whether the panel should have a border * @param borderTitle the title of the border; can be empty for an untitled border - * @param includeBodyText if {@code true}, include a second {@link JLabel} named {@code name + "Body"}. - * The resource bundle reference is {@code name + "Body.text"} - * @return a JPanel representing the header panel + * @param includeBodyText if {@code true}, include a second {@link JLabel}. + * @return a {@link JPanel} representing the header panel */ static JPanel createHeaderPanel(String name, String imageAddress, boolean includeBorder, String borderTitle, boolean includeBodyText) { @@ -269,10 +208,12 @@ static JPanel createHeaderPanel(String name, String imageAddress, boolean includ if (includeBodyText) { lblBody = new JLabel(String.format("%s", resources.getString("lbl" + name + "Body.text")), SwingConstants.CENTER); - lblHeader.setName("lbl" + name); + lblBody.setName("lbl" + name + "HeaderBody"); + Dimension size = lblBody.getPreferredSize(); + lblBody.setMaximumSize(new Dimension(500, size.height)); } - final JPanel panel = createStandardPanel("pnl" + name, includeBorder, borderTitle); + final JPanel panel = createStandardPanel("pnl" + name + "HeaderPanel", includeBorder, borderTitle); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -307,12 +248,11 @@ static GroupLayout createStandardLayout(JPanel panel) { return layout; } /** - * Creates a parent panel for the provided {@link JPanel} with a specified name, maximum width, - * and maximum height. + * Creates a parent panel for the provided {@link JPanel}. * * @param panel the panel to be added to the parent panel * @param name the name of the parent panel - * @param maximumWidth the maximum width of the parent panel + * @param width the maximum width of the parent panel * @return the created {@link JPanel} */ static JPanel createParentPanel(JPanel panel, String name, int maximumWidth) { @@ -337,8 +277,36 @@ static JPanel createParentPanel(JPanel panel, String name, int maximumWidth) { return parentPanel; } + public static List getPanelSizeValues(JPanel panel) { + List sizeValues = new ArrayList<>(); + + int width = 0; + int height = 0; + + for (Component component : panel.getComponents()) { + String componentName = component.getName(); + logger.info(componentName); + + if (componentName != null && componentName.contains("HeaderPanel")) { + continue; + } + + Dimension componentSize = component.getPreferredSize(); + + width += componentSize.width; + height += componentSize.height; + } + + sizeValues.add(width); + sizeValues.add(height); + + return sizeValues; + } + /** * Creates a new instance of {@link JTabbedPane} with the supplied panels as tabs. + *

+ * The resource bundle reference for the individual tabs will be {@code panel.getName() + ".title"} * * @param panels a map containing the names of the panels as keys and the corresponding * {@link JPanel} objects as values @@ -361,12 +329,24 @@ static JTabbedPane createSubTabs(Map panels) { } /** - * Removes HTML tags from the given string. + * Creates a new {@link JButton}. + *

+ * The name of the created {@link JButton} is {@code "btn" + name} + * The resource bundle references for the created {@link JButton} are {@code "lbl" + name + ".text"} + * and {@code "lbl" + name + ".tooltip"}. * - * @param htmlString the string containing HTML tags - * @return the string without HTML tags + * @param name the name of the button, used to generate the button's name and resource bundle references + * @return a new {@link JButton} object */ - private static String removeHtmlTags(String htmlString) { - return htmlString.replaceAll("\\<.*?\\>", ""); + static JButton createButton(String name) { + JButton jButton = new JButton(resources.getString("lbl" + name + ".text")); + jButton.setToolTipText(resources.getString("lbl" + name + ".tooltip")); + jButton.setName("btn" + name); + + Dimension size = jButton.getPreferredSize(); + jButton.setMinimumSize(size); + jButton.setMaximumSize(size); + + return jButton; } } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java index 6670b73dad..490ca4add1 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java @@ -22,9 +22,6 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.time.LocalDate; -import java.util.Map; -import java.util.Map.Entry; -import java.util.ResourceBundle; import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; @@ -34,10 +31,6 @@ */ public class GeneralTab { // region Variable Declarations - private static String RESOURCE_PACKAGE = "mekhq/resources/NEWCampaignOptionsDialog"; - private static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE, - MekHQ.getMHQOptions().getLocale()); - JFrame frame; String name; @@ -91,51 +84,27 @@ public AbstractMHQScrollablePanel createGeneralTab() { false, "", false); // Campaign name - Map nameFields = createLabeledTextField("Name", null, - 300, 30, null, null); - for (Entry entry : nameFields.entrySet()) { - lblName = entry.getKey(); - txtName = entry.getValue(); - } + lblName = createLabel("Name", null); + txtName = createTextField("Name", null, 300, 45); // Generate new random campaign name - btnNameGenerator = new JButton(resources.getString("lblNameGenerator.text")); - btnNameGenerator.setToolTipText(resources.getString("lblNameGenerator.tooltip")); - btnNameGenerator.setName("btnNameGenerator"); - int btnNameGeneratorWidth = getDimensionWidthForButton(btnNameGenerator); - btnNameGenerator.setMinimumSize(new Dimension(btnNameGeneratorWidth, 30)); - btnNameGenerator.setMaximumSize(new Dimension(btnNameGeneratorWidth, 30)); + btnNameGenerator = createButton("NameGenerator"); btnNameGenerator.addActionListener(e -> txtName.setText(BackgroundsController .randomMercenaryCompanyNameGenerator(campaign.getFlaggedCommander()))); // Campaign faction lblFaction = createLabel("Faction", null); comboFaction.setSelectedItem(new FactionDisplay(campaign.getFaction(), campaign.getLocalDate())); - int comboFactionWidth = getDimensionWidthForComboBox(comboFaction); - comboFaction.setMinimumSize(new Dimension(comboFactionWidth, 30)); - comboFaction.setMaximumSize(new Dimension(comboFactionWidth, 30)); // Reputation lblReputation = createLabel("Reputation", null); - int unitRatingMethodComboWidth = getDimensionWidthForComboBox(unitRatingMethodCombo); - unitRatingMethodCombo.setMinimumSize(new Dimension(unitRatingMethodComboWidth, 30)); - unitRatingMethodCombo.setMaximumSize(new Dimension(unitRatingMethodComboWidth, 30)); - - Map manualReputationModifierFields = createLabeledSpinner( - "ManualUnitRatingModifier", null, 0, -200, - 200, 1); - for (Entry entry : manualReputationModifierFields.entrySet()) { - lblManualUnitRatingModifier = entry.getKey(); - manualUnitRatingModifier = entry.getValue(); - } + lblManualUnitRatingModifier = createLabel("ManualUnitRatingModifier", null); + manualUnitRatingModifier = createSpinner("ManualUnitRatingModifier", null, + 0, -200, 200, 1); // Date lblDate = createLabel("Date", null); - btnDate.setName("btnDate"); - - int btnDateWidth = getDimensionWidthForButton(btnNameGenerator); - btnDate.setMinimumSize(new Dimension(btnDateWidth, 30)); - btnDate.setMaximumSize(new Dimension(btnDateWidth, 30)); + btnDate = createButton("Date"); btnDate.addActionListener(this::btnDateActionPerformed); // Camouflage diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java index bfcd3cc3e4..bf34fe3b52 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java @@ -2,8 +2,6 @@ import javax.swing.*; import javax.swing.GroupLayout.Alignment; -import java.util.Map; -import java.util.Map.Entry; import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; @@ -77,20 +75,15 @@ public JPanel createRepairTab() { // Damage by Margin useDamageMargin = createCheckBox("UseDamageMargin", null); useDamageMargin.addActionListener(evt -> spnDamageMargin.setEnabled(useDamageMargin.isSelected())); - Map damageMarginFields = createLabeledSpinner("DamageMargin", - null, 1, 1, 20, 1); - for (Entry entry : damageMarginFields.entrySet()) { - lblDamageMargin = entry.getKey(); - spnDamageMargin = entry.getValue(); - } + + lblDamageMargin = createLabel("DamageMargin", null); + spnDamageMargin = createSpinner("DamageMargin", null, + 1, 1, 20, 1); // Equipment Survival - Map DestroyPartTargetFields = createLabeledSpinner("DestroyPartTarget", - null, 2, 2, 13, 1); - for (Entry entry : DestroyPartTargetFields.entrySet()) { - lblDestroyPartTarget = entry.getKey(); - spnDestroyPartTarget = entry.getValue(); - } + lblDestroyPartTarget = createLabel("DestroyPartTarget", null); + spnDestroyPartTarget = createSpinner("DestroyPartTarget", null, + 2, 2, 13, 1); JLabel lblDestroyPartTargetPost = new JLabel("+"); // Layout the Panel @@ -153,28 +146,19 @@ public JPanel createMaintenanceTab() { checkMaintenance = createCheckBox("CheckMaintenance", null); // Maintenance Cycle Duration - Map maintenanceDaysFields = createLabeledSpinner("MaintenanceDays", - null, 7, 1, 365, 1); - for (Entry entry : maintenanceDaysFields.entrySet()) { - lblMaintenanceDays = entry.getKey(); - spnMaintenanceDays = entry.getValue(); - } + lblMaintenanceDays = createLabel("MaintenanceDays", null); + spnDamageMargin = createSpinner("MaintenanceDays", null, + 7, 1, 365, 1); // Maintenance Bonus - Map maintenanceBonusFields = createLabeledSpinner("MaintenanceBonus", - null, 0, -13, 13, 1); - for (Entry entry : maintenanceBonusFields.entrySet()) { - lblMaintenanceBonus = entry.getKey(); - spnMaintenanceBonus = entry.getValue(); - } + lblMaintenanceBonus = createLabel("MaintenanceBonus", null); + spnMaintenanceBonus = createSpinner("MaintenanceBonus", null, + 0, -13, 13, 1); // Default Maintenance Time - Map defaultMaintenanceTimeFields = createLabeledSpinner("DefaultMaintenanceTime", - null, 1, 1, 4, 1); - for (Entry entry : defaultMaintenanceTimeFields.entrySet()) { - lblDefaultMaintenanceTime = entry.getKey(); - spnDefaultMaintenanceTime = entry.getValue(); - } + lblDefaultMaintenanceTime = createLabel("DefaultMaintenanceTime", null); + spnDefaultMaintenanceTime = createSpinner("DefaultMaintenanceTime", null, + 1, 1, 4, 1); // Use Quality Modifiers useQualityMaintenance = createCheckBox("UseQualityMaintenance", null); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java index 1cbf6b27cf..dda3d25431 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java @@ -10,8 +10,6 @@ import javax.swing.*; import javax.swing.GroupLayout.Alignment; import java.awt.*; -import java.util.Map; -import java.util.Map.Entry; import java.util.ResourceBundle; import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; @@ -96,44 +94,29 @@ public JPanel createAcquisitionTab() { // Acquisitions skill lblChoiceAcquireSkill = createLabel("ChoiceAcquireSkill", null); - int choiceAcquireSkillWidth = getDimensionWidthForComboBox(choiceAcquireSkill); - choiceAcquireSkill.setMinimumSize(new Dimension(choiceAcquireSkillWidth, 30)); - choiceAcquireSkill.setMaximumSize(new Dimension(choiceAcquireSkillWidth , 30)); // Support personnel only chkSupportStaffOnly = createCheckBox("SupportStaffOnly", null); // Clan Acquisition penalty - Map acquireClanPenaltyFields = createLabeledSpinner("AcquireClanPenalty", - null, 0, 0, 13, 1); - for (Entry entry : acquireClanPenaltyFields.entrySet()) { - lblAcquireClanPenalty = entry.getKey(); - spnAcquireClanPenalty = entry.getValue(); - } + lblAcquireClanPenalty = createLabel("AcquireClanPenalty", null); + spnAcquireClanPenalty = createSpinner("AcquireClanPenalty", null, + 0, 0, 13, 1); // IS Acquisition penalty - Map acquireIsPenaltyFields = createLabeledSpinner("AcquireISPenalty", - null, 0, 0, 13, 1); - for (Entry entry : acquireIsPenaltyFields.entrySet()) { - lblAcquireIsPenalty = entry.getKey(); - spnAcquireIsPenalty = entry.getValue(); - } + lblAcquireIsPenalty = createLabel("AcquireISPenalty", null); + spnAcquireIsPenalty = createSpinner("AcquireISPenalty", null, + 0, 0, 13, 1); // Waiting Period - Map acquireWaitingPeriodFields = createLabeledSpinner("AcquireWaitingPeriod", - null, 1, 1, 365, 1); - for (Entry entry : acquireWaitingPeriodFields.entrySet()) { - lblAcquireWaitingPeriod = entry.getKey(); - spnAcquireWaitingPeriod = entry.getValue(); - } + lblAcquireWaitingPeriod = createLabel("AcquireWaitingPeriod", null); + spnAcquireWaitingPeriod = createSpinner("AcquireWaitingPeriod", null, + 1, 1, 365, 1); // Maximum Acquisitions - Map maxAcquisitionsFields = createLabeledSpinner("MaxAcquisitions", - null, 0,0, 100, 1); - for (Entry entry : maxAcquisitionsFields.entrySet()) { - lblMaxAcquisitions = entry.getKey(); - spnMaxAcquisitions = entry.getValue(); - } + lblMaxAcquisitions = createLabel("MaxAcquisitions", null); + spnMaxAcquisitions = createSpinner("MaxAcquisitions", null, + 0,0, 100, 1); // Layout the Panel final JPanel panel = createStandardPanel("acquisitionTab", true, ""); @@ -234,21 +217,12 @@ private JPanel createOptionsPanel() { usePlanetaryAcquisitions = createCheckBox("UsePlanetaryAcquisitions", null); // Max Jump Distance - Map maxJumpPlanetaryAcquisitionsFields = createLabeledSpinner( - "MaxJumpPlanetaryAcquisitions", null, 2, 0, - 5, 1); - for (Entry entry : maxJumpPlanetaryAcquisitionsFields.entrySet()) { - lblMaxJumpPlanetaryAcquisitions = entry.getKey(); - spnMaxJumpPlanetaryAcquisitions = entry.getValue(); - } + lblMaxJumpPlanetaryAcquisitions = createLabel("MaxJumpPlanetaryAcquisitions", null); + spnMaxJumpPlanetaryAcquisitions = createSpinner("MaxJumpPlanetaryAcquisitions", null, + 2, 0, 5, 1); // Faction Limits lblPlanetaryAcquisitionsFactionLimits = createLabel("PlanetaryAcquisitionsFactionLimits", null); - int comboPlanetaryAcquisitionsFactionLimitsWidth = getDimensionWidthForComboBox(comboPlanetaryAcquisitionsFactionLimits); - comboPlanetaryAcquisitionsFactionLimits.setMinimumSize(new Dimension(comboPlanetaryAcquisitionsFactionLimitsWidth, - 30)); - comboPlanetaryAcquisitionsFactionLimits.setMaximumSize(new Dimension(comboPlanetaryAcquisitionsFactionLimitsWidth, - 30)); // Disallow Resource Sharing (Inner Sphere) disallowPlanetaryAcquisitionClanCrossover = createCheckBox("DisallowPlanetaryAcquisitionClanCrossover", null); @@ -257,13 +231,9 @@ private JPanel createOptionsPanel() { disallowClanPartsFromIS = createCheckBox("DisallowClanPartsFromIS", null); // Acquisition Penalty - Map penaltyClanPartsFromISFields = createLabeledSpinner( - "PenaltyClanPartsFromIS", null, 0, 0, 12, - 1); - for (Entry entry : penaltyClanPartsFromISFields.entrySet()) { - lblPenaltyClanPartsFromIS = entry.getKey(); - spnPenaltyClanPartsFromIS = entry.getValue(); - } + lblPenaltyClanPartsFromIS = createLabel("PenaltyClanPartsFromIS", null); + spnPenaltyClanPartsFromIS = createSpinner("PenaltyClanPartsFromIS", null, + 0, 0, 12, 1); // Verbose Reporting usePlanetaryAcquisitionsVerbose = createCheckBox("UsePlanetaryAcquisitionsVerbose", null); @@ -464,12 +434,9 @@ private JPanel createModifiersPanel() { * @param spinner the {@link JSpinner} to set the width for */ private void setSpinnerWidth(JSpinner spinner) { - FontMetrics fontMetrics = spinner.getFontMetrics(spinner.getFont()); - int width = fontMetrics.stringWidth(Double.toString(12)); - width = width * WIDTH_MULTIPLIER_NUMBER; - - spinner.setMaximumSize(new Dimension(width, 30)); - spinner.setMinimumSize(new Dimension(width, 30)); + Dimension size = spinner.getPreferredSize(); + spinner.setMaximumSize(size); + spinner.setMinimumSize(size); } /** @@ -502,45 +469,23 @@ public JPanel createDeliveryTab() { "", true); // Delivery Time - Map nDiceTransitTimeFields = createLabeledSpinner("NDiceTransitTime", - null, 0, 0, 365, 1); - for (Entry entry : nDiceTransitTimeFields.entrySet()) { - lblNDiceTransitTime = entry.getKey(); - spnNDiceTransitTime = entry.getValue(); - } - - Map constantTransitTimeFields = createLabeledSpinner("ConstantTransitTime", - null, 0, 0, 365, 1); - for (Entry entry : constantTransitTimeFields.entrySet()) { - lblConstantTransitTime = entry.getKey(); - spnConstantTransitTime = entry.getValue(); - } + lblNDiceTransitTime = createLabel("NDiceTransitTime", null); + spnNDiceTransitTime = createSpinner("NDiceTransitTime", null, 0, + 0, 365, 1); - int choiceTimeUnitsWidth = getDimensionWidthForComboBox(choiceTransitTimeUnits); - choiceTransitTimeUnits.setMinimumSize(new Dimension(choiceTimeUnitsWidth, 30)); - choiceTransitTimeUnits.setMaximumSize(new Dimension(choiceTimeUnitsWidth, 30)); + lblConstantTransitTime = createLabel("ConstantTransitTime", null); + spnConstantTransitTime = createSpinner("ConstantTransitTime", null, + 0, 0, 365, 1); // Margin of Success Reductions - Map acquireMosBonusFields = createLabeledSpinner("AcquireMosBonus", + lblAcquireMosBonus = createLabel("AcquireMosBonus", null); + spnAcquireMosBonus = createSpinner("AcquireMosBonus", null, 0, 0, 365, 1); - for (Entry entry : acquireMosBonusFields.entrySet()) { - lblAcquireMosBonus = entry.getKey(); - spnAcquireMosBonus = entry.getValue(); - } - - choiceAcquireMosUnits.setMinimumSize(new Dimension(choiceTimeUnitsWidth, 30)); - choiceAcquireMosUnits.setMaximumSize(new Dimension(choiceTimeUnitsWidth, 30)); // Minimum Transit Time - Map acquireMinimumFields = createLabeledSpinner("AcquireMinimum", + lblAcquireMinimum = createLabel("AcquireMinimum", null); + spnAcquireMinimum = createSpinner("AcquireMinimum", null, 0, 0, 365, 1); - for (Entry entry : acquireMinimumFields.entrySet()) { - lblAcquireMinimum = entry.getKey(); - spnAcquireMinimum = entry.getValue(); - } - - choiceAcquireMinimumUnit.setMinimumSize(new Dimension(choiceTimeUnitsWidth, 30)); - choiceAcquireMinimumUnit.setMaximumSize(new Dimension(choiceTimeUnitsWidth, 30)); // Layout the Panel final JPanel panel = createStandardPanel("deliveryTab", true, ""); From b2220be6eb0053ff01fcc27dddb7c412af9bc7f5 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 2 Oct 2024 17:11:16 -0500 Subject: [PATCH 014/117] Remove hardcoded panel width parameters Removed explicit maximum width parameters in the createParentPanel method. Adjusted width handling to dynamically ensure a minimum width of 500 for the parent panels. Simplified the import statements by consolidating them. Deleted an unused utility method related to panel size calculation. --- .../tabs/CampaignOptionsUtilities.java | 44 ++++++------------- .../tabs/RepairAndMaintenanceTab.java | 4 +- .../tabs/SuppliesAndAcquisitionTab.java | 6 +-- 3 files changed, 19 insertions(+), 35 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index e4cf79f393..a370858795 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -247,23 +247,33 @@ static GroupLayout createStandardLayout(JPanel panel) { return layout; } + /** * Creates a parent panel for the provided {@link JPanel}. * * @param panel the panel to be added to the parent panel * @param name the name of the parent panel - * @param width the maximum width of the parent panel * @return the created {@link JPanel} */ - static JPanel createParentPanel(JPanel panel, String name, int maximumWidth) { + static JPanel createParentPanel(JPanel panel, String name) { + // Create Panel final JPanel parentPanel = createStandardPanel(name, true, ""); final GroupLayout parentLayout = createStandardLayout(parentPanel); - int preferredHeight = (int) (panel.getPreferredSize().height * 1.25); - Dimension size = new Dimension(maximumWidth, preferredHeight); + // Set Dimensions + int widthNew = panel.getMinimumSize().width; + + if (widthNew < 500) { + widthNew = 500; + } + + // I don't know why 1.25 works, it just does, and I've given up questioning it. + int height = (int) (panel.getPreferredSize().height * 1.25); + Dimension size = new Dimension(widthNew, height); panel.setMinimumSize(size); panel.setMaximumSize(size); + // Layout parentPanel.setLayout(parentLayout); parentLayout.setVerticalGroup( @@ -277,32 +287,6 @@ static JPanel createParentPanel(JPanel panel, String name, int maximumWidth) { return parentPanel; } - public static List getPanelSizeValues(JPanel panel) { - List sizeValues = new ArrayList<>(); - - int width = 0; - int height = 0; - - for (Component component : panel.getComponents()) { - String componentName = component.getName(); - logger.info(componentName); - - if (componentName != null && componentName.contains("HeaderPanel")) { - continue; - } - - Dimension componentSize = component.getPreferredSize(); - - width += componentSize.width; - height += componentSize.height; - } - - sizeValues.add(width); - sizeValues.add(height); - - return sizeValues; - } - /** * Creates a new instance of {@link JTabbedPane} with the supplied panels as tabs. *

diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java index bf34fe3b52..07f47629df 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java @@ -128,7 +128,7 @@ public JPanel createRepairTab() { .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); // Create Parent Panel and return - return createParentPanel(panel, "repairTab", 500); + return createParentPanel(panel, "repairTab"); } /** @@ -227,7 +227,7 @@ public JPanel createMaintenanceTab() { .addComponent(logMaintenance)); // Create Parent Panel and return - return createParentPanel(panel, "maintenanceTab", 500); + return createParentPanel(panel, "maintenanceTab"); } private void recreateFinancesPanel(boolean isReversingQualityNames) { diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java index dda3d25431..ed86b02a72 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java @@ -169,7 +169,7 @@ public JPanel createAcquisitionTab() { .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); // Create Parent Panel and return - return createParentPanel(panel, "acquisitionsTab", 500); + return createParentPanel(panel, "acquisitionsTab"); } public JPanel createPlanetaryAcquisitionTab() { @@ -203,7 +203,7 @@ public JPanel createPlanetaryAcquisitionTab() { .addComponent(modifiers))); // Create Parent Panel and return - return createParentPanel(panel, "PlanetaryAcquisitionTab", 800); + return createParentPanel(panel, "PlanetaryAcquisitionTab"); } @@ -532,7 +532,7 @@ public JPanel createDeliveryTab() { .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); // Create Parent Panel and return - return createParentPanel(panel, "deliveryTab", 600); + return createParentPanel(panel, "deliveryTab"); } /** From 839f706829d9e7f3941f4de2c8886e9b36a54f61 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 2 Oct 2024 20:29:34 -0500 Subject: [PATCH 015/117] Add new tabs for various campaign options categories Added new tabs for Combat Readiness, Human Resources, Unit Development, Logistics and Maintenance, and Strategic Operations to the Campaign Options Pane. Updated the resource file with corresponding titles for the new tabs. These changes enhance the structure and organization of the campaign options interface. --- .../NEWCampaignOptionsDialog.properties | 9 +- .../tabs/CampaignOptionsPane.java | 85 ++++++++++++++++++- 2 files changed, 91 insertions(+), 3 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 75ac17b4ea..2fd6e5cd0b 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -14,9 +14,16 @@ presetDialogCustomize.tooltip=This is placeholder text for a tooltip presetDialogCancel.name=Cancel presetDialogCancel.tooltip=This is placeholder text for a tooltip -## General Tab Class +## Campaign Options Pane generalPanel.title=General Information +combatReadinessParentTab.title=Combat Readiness +humanResourcesParentTab.title=Human Resources +unitDevelopmentParentTab.title=Unit Development +logisticsAndMaintenanceParentTab.title=Logistics and Maintenance +strategicOperationsParentTab.title=Strategic Operations + +## General Tab Class # createGeneralTab lblGeneral.text=Welcome, Commander lblName.text=Unit Name diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 458b9f338c..775aacda81 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -31,6 +31,66 @@ protected void initialize() { addTab(String.format("%s", 4, resources.getString("generalPanel.title")), generalTab.createGeneralTab()); + // Combat Readiness + addTab(String.format("%s", 4, + resources.getString("combatReadinessParentTab.title")), createCombatReadinessParentTab()); + + // Human Resources + addTab(String.format("%s", 4, + resources.getString("humanResourcesParentTab.title")), createHumanResourcesParentTab()); + + // Unit Development + addTab(String.format("%s", 4, + resources.getString("unitDevelopmentParentTab.title")), createUnitDevelopmentParentTab()); + + // Logistics and Maintenance + addTab(String.format("%s", 4, + resources.getString("logisticsAndMaintenanceParentTab.title")), createLogisticsAndMaintenanceParentTab()); + + // Strategic Operations + addTab(String.format("%s", 4, + resources.getString("strategicOperationsParentTab.title")), createStrategicOperationsParentTab()); + } + + + + private JTabbedPane createCombatReadinessParentTab() { + // TODO Combat Readiness + // Tech Limits + // Rulesets + // Random Assignment Tables + JTabbedPane combatReadinessParentTab = new JTabbedPane(); + + return combatReadinessParentTab; + } + + private JTabbedPane createHumanResourcesParentTab() { + // TODO Human Resources + // Personnel + // Life Paths + // Turnover and Retention + // Name and Portrait Generation + // Rank Systems + JTabbedPane humanResourcesParentTab = new JTabbedPane(); + + return humanResourcesParentTab; + } + + private JTabbedPane createUnitDevelopmentParentTab() { + // TODO Unit Development + // Experience + // Skills + // Skill Randomization + // SPAs + JTabbedPane unitDevelopmentParentTab = new JTabbedPane(); + + return unitDevelopmentParentTab; + } + + private JTabbedPane createLogisticsAndMaintenanceParentTab() { + // Parent Tab + JTabbedPane logisticsAndMaintenanceParentTab = new JTabbedPane(); + // Repair and Maintenance RepairAndMaintenanceTab repairAndMaintenanceTab = new RepairAndMaintenanceTab(getFrame(), "repairAndMaintenanceTab"); @@ -39,7 +99,7 @@ protected void initialize() { "repairTab", repairAndMaintenanceTab.createRepairTab(), "maintenanceTab", repairAndMaintenanceTab.createMaintenanceTab())); - addTab(String.format("%s", 4, + logisticsAndMaintenanceParentTab.addTab(String.format("%s", 4, resources.getString("repairAndMaintenanceContentTabs.title")), repairAndMaintenanceContentTabs); // Supplies and Acquisition @@ -51,8 +111,29 @@ protected void initialize() { "deliveryTab", suppliesAndAcquisitionTab.createDeliveryTab(), "planetaryAcquisitionTab", suppliesAndAcquisitionTab.createPlanetaryAcquisitionTab())); - addTab(String.format("%s", 4, + logisticsAndMaintenanceParentTab.addTab(String.format("%s", 4, resources.getString("suppliesAndAcquisitionTab.title")), suppliesAndAcquisitionContentTabs); + logisticsAndMaintenanceParentTab.addTab(String.format("%s", 4, + resources.getString("repairAndMaintenanceContentTabs.title")), repairAndMaintenanceContentTabs); + + logisticsAndMaintenanceParentTab.addTab(String.format("%s", 4, + resources.getString("suppliesAndAcquisitionTab.title")), suppliesAndAcquisitionContentTabs); + + addTab(String.format("%s", 4, + resources.getString("logisticsAndMaintenanceParentTab.title")), logisticsAndMaintenanceParentTab); + + return logisticsAndMaintenanceParentTab; + } + + private JTabbedPane createStrategicOperationsParentTab() { + // TODO Strategic Operations + // Finances + // Mercenary + // Markets + // Parent Tab + JTabbedPane strategicOperationsParentTab = new JTabbedPane(); + + return strategicOperationsParentTab; } private void setOptions() { From 3c08d2c079f21b30c47b3ca7fae520e8654cb775 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 2 Oct 2024 20:32:36 -0500 Subject: [PATCH 016/117] Remove TODO comments for parent tab creation methods The TODO comments for creating various parent tabs in different sections were removed. This cleanup helps to reduce clutter and improves the readability of the code. It also indicates that the initial implementation for these tabs is complete. --- .../campaignOptions/tabs/CampaignOptionsPane.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 775aacda81..2a14571a48 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -53,35 +53,37 @@ protected void initialize() { } - private JTabbedPane createCombatReadinessParentTab() { - // TODO Combat Readiness // Tech Limits // Rulesets // Random Assignment Tables + + // Parent Tab JTabbedPane combatReadinessParentTab = new JTabbedPane(); return combatReadinessParentTab; } private JTabbedPane createHumanResourcesParentTab() { - // TODO Human Resources // Personnel // Life Paths // Turnover and Retention // Name and Portrait Generation // Rank Systems + + // Parent Tab JTabbedPane humanResourcesParentTab = new JTabbedPane(); return humanResourcesParentTab; } private JTabbedPane createUnitDevelopmentParentTab() { - // TODO Unit Development // Experience // Skills // Skill Randomization // SPAs + + // Parent Tab JTabbedPane unitDevelopmentParentTab = new JTabbedPane(); return unitDevelopmentParentTab; @@ -126,10 +128,10 @@ private JTabbedPane createLogisticsAndMaintenanceParentTab() { } private JTabbedPane createStrategicOperationsParentTab() { - // TODO Strategic Operations // Finances // Mercenary // Markets + // Parent Tab JTabbedPane strategicOperationsParentTab = new JTabbedPane(); From 89f8df0df4182d1b66c84e7dae3eb81992fe0f54 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 2 Oct 2024 22:29:03 -0500 Subject: [PATCH 017/117] Refactor tab creation for better alignment and UI enhancements Refactored the creation of campaign option tabs to use wrapper panels for better alignment and added decorative borders with contextual quotes. Also, centralized tab creation into a utility method for improved readability and maintainability of the code. --- .../CampaignOptionsDialog.properties | 4 +- .../NEWCampaignOptionsDialog.properties | 12 ++++ .../tabs/CampaignOptionsPane.java | 65 ++++++++++++++----- .../tabs/CampaignOptionsUtilities.java | 17 ++++- 4 files changed, 79 insertions(+), 19 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties index c0561a6fc8..c8c5d35332 100644 --- a/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties @@ -982,9 +982,9 @@ chkAeroRecruitsHaveUnits.toolTipText=Aerospace pilot recruits can have fighters, ## Button Panel btnOkay.text=Confirm -btnSavePreset.text=Confirm and Save as Preset +btnSavePreset.text=Save Preset btnSavePreset.toolTipText=Confirm the changes in the dialog and save it as a Campaign Preset. -btnLoadPreset.text=Load a Preset +btnLoadPreset.text=Load Preset btnLoadPreset.toolTipText=Load a Campaign Preset and apply it to the current dialog. If it is during startup, it will apply all values outside of starting planet, contract count, and game options. Otherwise, it will only apply continuous preset values outside of game options. ##end Button Panel diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 2fd6e5cd0b..a2b66eb490 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -16,6 +16,8 @@ presetDialogCancel.tooltip=This is placeholder text for a tooltip ## Campaign Options Pane generalPanel.title=General Information +generalPanel.border="Mercenary life is freedom with a price. Every contract is a choice, but every choice comes with a consequence."\ +
- Captain Rex "Ironclad" Harper, Black Fang Company combatReadinessParentTab.title=Combat Readiness humanResourcesParentTab.title=Human Resources unitDevelopmentParentTab.title=Unit Development @@ -46,7 +48,11 @@ lblIcon.tooltip=PLACEHOLDER ## RepairAndMaintenanceTab repairAndMaintenanceContentTabs.title=Repairs and Maintenance repairTab.title=Repairs +repairTab.border="Sure, I can fix it. But next time, maybe don't play chicken with an Atlas."\ +
- Chief Tech Mara "Wrench" Kell, Black Hammer Company maintenanceTab.title=Maintenance +maintenanceTab.border="I've yet to see a battle won by duct tape, but we've gotten pretty close."\ +
- Commander Erik Drahn, Sunder Lance # createRepairTab lblRepairTab.text=Repair Options @@ -103,8 +109,14 @@ lblLogMaintenance.tooltip=PLACEHOLDER ## SuppliesAndAcquisitionTab suppliesAndAcquisitionTab.title=Supplies and Acquisition acquisitionsTab.title=Acquisitions +acquisitionsTab.border="It's not about what you need - it's about what you can get. In acquisitions, creativity beats credits."\ +
- Quartermaster Jonas "Scrounger" Voss, Red Talon Mercenaries deliveryTab.title=Deliveries +deliveryTab.border="Every part I deliver is a promise that a mech will rise again. Speed is my weapon, and time is the enemy."\ +
- Captain Horace "Hot Wheels" Drake, Midnight Express PlanetaryAcquisitionTab.title=Planetary Acquisitions +PlanetaryAcquisitionTab.border="On a guerrilla contract, parts are as valuable as ammo. Get what you can, while you can, because tomorrow, it might be gone."\ +
- Lieutenant Jaxon "Jackpot" Hale, Horizon Raiders # createAcquisitionTab lblAcquisitionTab.text=Acquisition Options diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 2a14571a48..f7aefd061a 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -7,6 +7,7 @@ import javax.swing.*; import java.util.Map; import java.util.ResourceBundle; +import java.util.function.Supplier; import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.createSubTabs; @@ -27,31 +28,60 @@ public CampaignOptionsPane(final JFrame frame, final Campaign campaign) { @Override protected void initialize() { // General - GeneralTab generalTab = new GeneralTab(campaign, getFrame(), "generalTab"); - addTab(String.format("%s", 4, - resources.getString("generalPanel.title")), generalTab.createGeneralTab()); + addTab(String.format("%s", 5, + resources.getString("generalPanel.title")), createGeneralTab()); // Combat Readiness - addTab(String.format("%s", 4, - resources.getString("combatReadinessParentTab.title")), createCombatReadinessParentTab()); + createTab("combatReadinessParentTab", this::createCombatReadinessParentTab); // Human Resources - addTab(String.format("%s", 4, - resources.getString("humanResourcesParentTab.title")), createHumanResourcesParentTab()); + createTab("humanResourcesParentTab", this::createHumanResourcesParentTab); // Unit Development - addTab(String.format("%s", 4, - resources.getString("unitDevelopmentParentTab.title")), createUnitDevelopmentParentTab()); + createTab("unitDevelopmentParentTab", this::createUnitDevelopmentParentTab); // Logistics and Maintenance - addTab(String.format("%s", 4, - resources.getString("logisticsAndMaintenanceParentTab.title")), createLogisticsAndMaintenanceParentTab()); + createTab("logisticsAndMaintenanceParentTab", this::createLogisticsAndMaintenanceParentTab); // Strategic Operations - addTab(String.format("%s", 4, - resources.getString("strategicOperationsParentTab.title")), createStrategicOperationsParentTab()); + createTab("strategicOperationsParentTab", this::createStrategicOperationsParentTab); + } + + /** + * Creates a tab and adds it to the {@link TabbedPane}. + * + * @param resourceName the name of the resource used to create the tab's title + * @param tabCreator a supplier that creates the {@link TabbedPane} for the tab + */ + private void createTab(String resourceName, Supplier tabCreator) { + JTabbedPane createdTab = tabCreator.get(); + + JScrollPane tabScrollPane = new JScrollPane(createdTab, + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + + addTab(String.format("%s", 5, + resources.getString(resourceName + ".title")), tabScrollPane); } + /** + * Creates the General tab. + * + * @return a {@link JScrollPane} containing the General tab + */ + private JScrollPane createGeneralTab() { + GeneralTab generalTab = new GeneralTab(campaign, getFrame(), "generalTab"); + JPanel createdGeneralTab = generalTab.createGeneralTab(); + + // Add a titled border + String borderTitle = String.format("%s", + resources.getString("generalPanel.border")); + createdGeneralTab.setBorder(BorderFactory.createTitledBorder(borderTitle)); + + return new JScrollPane(createdGeneralTab, + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + } private JTabbedPane createCombatReadinessParentTab() { // Tech Limits @@ -89,6 +119,11 @@ private JTabbedPane createUnitDevelopmentParentTab() { return unitDevelopmentParentTab; } + /** + * Creates the Logistics and Maintenance parent tab for the Campaign Options Pane. + * + * @return the created {@link JTabbedPane} representing the Logistics and Maintenance parent tab + */ private JTabbedPane createLogisticsAndMaintenanceParentTab() { // Parent Tab JTabbedPane logisticsAndMaintenanceParentTab = new JTabbedPane(); @@ -113,14 +148,12 @@ private JTabbedPane createLogisticsAndMaintenanceParentTab() { "deliveryTab", suppliesAndAcquisitionTab.createDeliveryTab(), "planetaryAcquisitionTab", suppliesAndAcquisitionTab.createPlanetaryAcquisitionTab())); + // Add tabs logisticsAndMaintenanceParentTab.addTab(String.format("%s", 4, resources.getString("suppliesAndAcquisitionTab.title")), suppliesAndAcquisitionContentTabs); logisticsAndMaintenanceParentTab.addTab(String.format("%s", 4, resources.getString("repairAndMaintenanceContentTabs.title")), repairAndMaintenanceContentTabs); - logisticsAndMaintenanceParentTab.addTab(String.format("%s", 4, - resources.getString("suppliesAndAcquisitionTab.title")), suppliesAndAcquisitionContentTabs); - addTab(String.format("%s", 4, resources.getString("logisticsAndMaintenanceParentTab.title")), logisticsAndMaintenanceParentTab); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index a370858795..04b4e49a61 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -306,7 +306,22 @@ static JTabbedPane createSubTabs(Map panels) { for (String tabName : tabNames) { JPanel panel = panels.get(tabName); - tabbedPane.addTab(resources.getString(panel.getName() + ".title"), panel); + + // Create a wrapper panel for its easy alignment controls + JPanel wrapperPanel = new JPanel(new GridBagLayout()); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.anchor = GridBagConstraints.NORTH; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + + wrapperPanel.add(panel, gbc); + + // Set a titled border on the wrapper panel + String borderTitle = String.format("%s", + resources.getString(panel.getName() + ".border")); + wrapperPanel.setBorder(BorderFactory.createTitledBorder(borderTitle)); + + tabbedPane.addTab(resources.getString(panel.getName() + ".title"), wrapperPanel); } return tabbedPane; From 4a5c7209d11cd4357af2c1d9a4bf4b92eb87f57c Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 2 Oct 2024 22:37:32 -0500 Subject: [PATCH 018/117] Refactored comments for code clarity Updated Javadoc comments in CampaignOptionsPane.java to remove unnecessary link annotations and improve readability. --- .../gui/panes/campaignOptions/tabs/CampaignOptionsPane.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index f7aefd061a..541eb89b41 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -48,10 +48,10 @@ protected void initialize() { } /** - * Creates a tab and adds it to the {@link TabbedPane}. + * Creates a tab and adds it to the TabbedPane. * * @param resourceName the name of the resource used to create the tab's title - * @param tabCreator a supplier that creates the {@link TabbedPane} for the tab + * @param tabCreator a supplier that creates the TabbedPane for the tab */ private void createTab(String resourceName, Supplier tabCreator) { JTabbedPane createdTab = tabCreator.get(); From e30aee30bae4f99e0df70096008cc247d39be190 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 3 Oct 2024 00:25:11 -0500 Subject: [PATCH 019/117] Refactor and reorganize campaign options tabs Moved header creation to a separate method for better readability and reusability. Updated text field dimensions to be dynamically set based on preferred height. Enhanced scroll speeds for better user experience and added quotes to tabs for improved UI aesthetics. --- .../NEWCampaignOptionsDialog.properties | 22 ++++++---- .../tabs/CampaignOptionsPane.java | 13 +++--- .../tabs/CampaignOptionsUtilities.java | 34 ++++++++------ .../campaignOptions/tabs/GeneralTab.java | 44 +++++++++++++++++-- 4 files changed, 84 insertions(+), 29 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index a2b66eb490..4c4cbc06e7 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -16,8 +16,6 @@ presetDialogCancel.tooltip=This is placeholder text for a tooltip ## Campaign Options Pane generalPanel.title=General Information -generalPanel.border="Mercenary life is freedom with a price. Every contract is a choice, but every choice comes with a consequence."\ -
- Captain Rex "Ironclad" Harper, Black Fang Company combatReadinessParentTab.title=Combat Readiness humanResourcesParentTab.title=Human Resources unitDevelopmentParentTab.title=Unit Development @@ -26,8 +24,12 @@ strategicOperationsParentTab.title=Strategic Operations ## General Tab Class + # createGeneralTab lblGeneral.text=Welcome, Commander +lblGeneralBody.text=

"Mercenary life is freedom with a price.\ +
Every contract is a choice, but every choice comes with a consequence."\ +
- Captain Rex "Ironclad" Harper, Black Fang Company
lblName.text=Unit Name lblName.tooltip=PLACEHOLDER lblNameGenerator.text=Regenerate Name @@ -48,7 +50,8 @@ lblIcon.tooltip=PLACEHOLDER ## RepairAndMaintenanceTab repairAndMaintenanceContentTabs.title=Repairs and Maintenance repairTab.title=Repairs -repairTab.border="Sure, I can fix it. But next time, maybe don't play chicken with an Atlas."\ +repairTab.border="Sure, I can fix it.\ +
But next time, maybe don't play chicken with an Atlas."\
- Chief Tech Mara "Wrench" Kell, Black Hammer Company maintenanceTab.title=Maintenance maintenanceTab.border="I've yet to see a battle won by duct tape, but we've gotten pretty close."\ @@ -108,14 +111,17 @@ lblLogMaintenance.tooltip=PLACEHOLDER ## SuppliesAndAcquisitionTab suppliesAndAcquisitionTab.title=Supplies and Acquisition -acquisitionsTab.title=Acquisitions -acquisitionsTab.border="It's not about what you need - it's about what you can get. In acquisitions, creativity beats credits."\ +acquisitionTab.title=Acquisitions +acquisitionTab.border="It's not about what you need - it's about what you can get.\ +
In acquisitions, creativity beats C-Bills."\
- Quartermaster Jonas "Scrounger" Voss, Red Talon Mercenaries deliveryTab.title=Deliveries -deliveryTab.border="Every part I deliver is a promise that a mech will rise again. Speed is my weapon, and time is the enemy."\ +deliveryTab.border="Every part I deliver is a promise that a mek will rise again.\ +
Speed is my weapon, and time is the enemy."\
- Captain Horace "Hot Wheels" Drake, Midnight Express -PlanetaryAcquisitionTab.title=Planetary Acquisitions -PlanetaryAcquisitionTab.border="On a guerrilla contract, parts are as valuable as ammo. Get what you can, while you can, because tomorrow, it might be gone."\ +planetaryAcquisitionTab.title=Planetary Acquisitions +planetaryAcquisitionTab.border="On a guerrilla contract, parts are as valuable as ammo.\ +
Get what you can, while you can, because tomorrow, it might be gone."\
- Lieutenant Jaxon "Jackpot" Hale, Horizon Raiders # createAcquisitionTab diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 541eb89b41..6328baa295 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -60,6 +60,14 @@ private void createTab(String resourceName, Supplier tabCreator) { JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + // Increase vertical scroll speed + int verticalScrollSpeed = 20; + tabScrollPane.getVerticalScrollBar().setUnitIncrement(verticalScrollSpeed); + + // Increase horizontal scroll speed + int horizontalScrollSpeed = 20; + tabScrollPane.getHorizontalScrollBar().setUnitIncrement(horizontalScrollSpeed); + addTab(String.format("%s", 5, resources.getString(resourceName + ".title")), tabScrollPane); } @@ -73,11 +81,6 @@ private JScrollPane createGeneralTab() { GeneralTab generalTab = new GeneralTab(campaign, getFrame(), "generalTab"); JPanel createdGeneralTab = generalTab.createGeneralTab(); - // Add a titled border - String borderTitle = String.format("%s", - resources.getString("generalPanel.border")); - createdGeneralTab.setBorder(BorderFactory.createTitledBorder(borderTitle)); - return new JScrollPane(createdGeneralTab, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index 04b4e49a61..2b3035aea8 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -16,7 +16,7 @@ public class CampaignOptionsUtilities { private static final MMLogger logger = MMLogger.create(CampaignOptionsPane.class); private static final String RESOURCE_PACKAGE = "mekhq/resources/NEWCampaignOptionsDialog"; - private static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE); + static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE); final static String IMAGE_DIRECTORY = "data/images/universe/factions/"; /** @@ -119,18 +119,18 @@ static JLabel createLabel(String name, @Nullable Integer customWrapSize) { * line of the tooltip. * If {@code null}, the default wrap size of 100 is used. * @param width The width of the {@link JTextField}. - * @param height The height of the {@link JTextField}. * @return a map containing a {@link JLabel} key and a {@link JTextField} value. */ - static JTextField createTextField(String name, @Nullable Integer customWrapSize, int width, int height) { + static JTextField createTextField(String name, @Nullable Integer customWrapSize, int width) { customWrapSize = processWrapSize(customWrapSize); JTextField jTextField = new JTextField(); jTextField.setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), customWrapSize)); jTextField.setName("txt" + name); - jTextField.setMinimumSize(new Dimension(width, height)); - jTextField.setMaximumSize(new Dimension(width, height)); + int preferredHeight = jTextField.getPreferredSize().height; + jTextField.setMinimumSize(new Dimension(width, preferredHeight)); + jTextField.setMaximumSize(new Dimension(width, preferredHeight)); return jTextField; } @@ -305,7 +305,20 @@ static JTabbedPane createSubTabs(Map panels) { JTabbedPane tabbedPane = new JTabbedPane(); for (String tabName : tabNames) { - JPanel panel = panels.get(tabName); + JPanel mainPanel = panels.get(tabName); + + // Create a panel for the quote + JPanel quotePanel = new JPanel(); + JLabel quote = new JLabel(String.format("
%s
", + resources.getString(tabName + ".border"))); + quotePanel.add(mainPanel); + quotePanel.add(quote); + + // Reorganize mainPanel to include quotePanel at bottom + JPanel contentPanel = new JPanel(new BorderLayout()); + contentPanel.setName(tabName); + contentPanel.add(mainPanel, BorderLayout.CENTER); + contentPanel.add(quotePanel, BorderLayout.SOUTH); // Create a wrapper panel for its easy alignment controls JPanel wrapperPanel = new JPanel(new GridBagLayout()); @@ -314,14 +327,9 @@ static JTabbedPane createSubTabs(Map panels) { gbc.weightx = 1.0; gbc.weighty = 1.0; - wrapperPanel.add(panel, gbc); - - // Set a titled border on the wrapper panel - String borderTitle = String.format("%s", - resources.getString(panel.getName() + ".border")); - wrapperPanel.setBorder(BorderFactory.createTitledBorder(borderTitle)); + wrapperPanel.add(contentPanel, gbc); - tabbedPane.addTab(resources.getString(panel.getName() + ".title"), wrapperPanel); + tabbedPane.addTab(resources.getString(tabName + ".title"), wrapperPanel); } return tabbedPane; diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java index 490ca4add1..036129bd4f 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java @@ -80,12 +80,11 @@ public GeneralTab(Campaign campaign, JFrame frame, String name) { */ public AbstractMHQScrollablePanel createGeneralTab() { // Promotional Image - JPanel imagePanel = createHeaderPanel("General", "data/images/misc/MekHQ.png", - false, "", false); + JPanel imagePanel = createGeneralHeader(); // Campaign name lblName = createLabel("Name", null); - txtName = createTextField("Name", null, 300, 45); + txtName = createTextField("Name", null, 300); // Generate new random campaign name btnNameGenerator = createButton("NameGenerator"); @@ -198,6 +197,45 @@ public AbstractMHQScrollablePanel createGeneralTab() { return generalPanel; } + /** + * Creates a {@link JPanel} with a header containing an image, title, and body text. + * + * @return the created {@link JPanel} with the header + */ + private static JPanel createGeneralHeader() { + ImageIcon imageIcon = new ImageIcon("data/images/misc/MekHQ.png"); + JLabel imageLabel = new JLabel(imageIcon); + + final JLabel lblHeader = new JLabel(String.format("%s", + resources.getString("lblGeneral.text")), SwingConstants.CENTER); + lblHeader.setName("lblGeneral"); + + JLabel lblBody = new JLabel(String.format("%s", + resources.getString("lblGeneralBody.text")), SwingConstants.CENTER); + lblBody.setName("lblGeneralHeaderBody"); + Dimension size = lblBody.getPreferredSize(); + lblBody.setMaximumSize(new Dimension(500, size.height)); + + final JPanel panel = createStandardPanel("pnlGeneralHeaderPanel", false, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(lblHeader) + .addComponent(imageLabel) + .addComponent(lblBody) + .addGap(20)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.CENTER) + .addComponent(lblHeader) + .addComponent(imageLabel) + .addComponent(lblBody)); + + return panel; + } + /** * Initialize the components of the {@link GeneralTab} class. */ From e5af9517a7d9bec6275de6765718937cce73e893 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 7 Oct 2024 13:10:46 -0500 Subject: [PATCH 020/117] Add TechLimitsTab to campaign options Replaced the empty TechLimits class with a fully implemented TechLimitsTab to manage technical limit settings within the campaign options. Updated the properties for the new tab and made minor adjustments to CampaignOptionsUtilities and CampaignOptionsPane for integration. --- .../NEWCampaignOptionsDialog.properties | 36 +++- .../tabs/CampaignOptionsPane.java | 6 + .../tabs/CampaignOptionsUtilities.java | 4 +- .../tabs/RepairAndMaintenanceTab.java | 3 + .../campaignOptions/tabs/TechLimits.java | 4 - .../campaignOptions/tabs/TechLimitsTab.java | 171 ++++++++++++++++++ 6 files changed, 216 insertions(+), 8 deletions(-) delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimits.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 4c4cbc06e7..d53b91f05a 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -24,7 +24,6 @@ strategicOperationsParentTab.title=Strategic Operations ## General Tab Class - # createGeneralTab lblGeneral.text=Welcome, Commander lblGeneralBody.text=
"Mercenary life is freedom with a price.\ @@ -196,4 +195,37 @@ lblTechLabel.tooltip=PLACEHOLDER lblIndustryLabel.text=Industry lblIndustryLabel.tooltip=PLACEHOLDER lblOutputLabel.text=Output -lblOutputLabel.tooltip=PLACEHOLDER \ No newline at end of file +lblOutputLabel.tooltip=PLACEHOLDER + +## Tech Limits Tab +TechLimitsParentTab.title=Tech Limits +TechLimitsTab.border="In a universe where we fight with the ghosts of a golden age, technology is a reminder:\ +
we are bound by history, but not defined by it."\ +
- Engineer Talia "Patch" Kessler, Stormhounds + +# createTechLimitsTab +lblTechLimitsTab.text=Tech Limit Options +lblTechLimitsTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblLimitByYearBox.text=Limit Tech Purchases by Game Year +lblLimitByYearBox.tooltip=PLACEHOLDER +lblDisallowExtinctStuffBox.text=Disallow Purchasing of Extinct Tech +lblDisallowExtinctStuffBox.tooltip=PLACEHOLDER +lblAllowClanPurchasesBox.text=Allow Purchase of Clan Tech +lblAllowClanPurchasesBox.tooltip=PLACEHOLDER +lblAllowISPurchasesBox.text=Allow Purchase of Inner Sphere Tech +lblAllowISPurchasesBox.tooltip=PLACEHOLDER +lblAllowCanonOnlyBox.text=Canon Tech Purchases Only +lblAllowCanonOnlyBox.tooltip=PLACEHOLDER +lblAllowCanonRefitOnlyBox.text=Canon Refits Only +lblAllowCanonRefitOnlyBox.tooltip=PLACEHOLDER +lblChoiceTechLevel.text=Maximum Tech Level +lblChoiceTechLevel.tooltip=PLACEHOLDER +lblVariableTechLevelBox.text=Vary Introduction Date by Tech Level +lblVariableTechLevelBox.tooltip=PLACEHOLDER +lblUseAmmoByTypeBox.text=Use Ammo Cross-Weapon Compatibility +lblUseAmmoByTypeBox.tooltip=PLACEHOLDER \ No newline at end of file diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 6328baa295..3c96940a85 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -94,6 +94,12 @@ private JTabbedPane createCombatReadinessParentTab() { // Parent Tab JTabbedPane combatReadinessParentTab = new JTabbedPane(); + TechLimitsTab techLimitsTab = new TechLimitsTab(getFrame(), + "techLimitsTab"); + + combatReadinessParentTab.addTab(String.format("%s", 4, + resources.getString("TechLimitsParentTab.title")), techLimitsTab.createTechLimitsTab()); + return combatReadinessParentTab; } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index 2b3035aea8..583e0eb9b6 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -185,7 +185,7 @@ static JPanel createStandardPanel(String name, boolean includeBorder, String bor *

* The {@link JPanel} will be named {@code "pnl" + name + "HeaderPanel"}. * The resource bundle references for the first {@link JLabel} will be {@code "lbl" + name + ".text"}. - * The optional second {@link JLabel} is assigned the name {@code ""lbl" + name + "HeaderBody"} + * The optional second {@link JLabel} is assigned the name {@code ""lbl" + name + "Body"} * and uses the following resource bundle reference: {@code "lbl" + name + "Body.text"}. * * @param name the name of the header panel. @@ -208,7 +208,7 @@ static JPanel createHeaderPanel(String name, String imageAddress, boolean includ if (includeBodyText) { lblBody = new JLabel(String.format("%s", resources.getString("lbl" + name + "Body.text")), SwingConstants.CENTER); - lblBody.setName("lbl" + name + "HeaderBody"); + lblBody.setName("lbl" + name + "Body"); Dimension size = lblBody.getPreferredSize(); lblBody.setMaximumSize(new Dimension(500, size.height)); } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java index 07f47629df..e318c8d883 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java @@ -5,6 +5,9 @@ import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; +/** + * This class represents the tab for repair and maintenance settings. + */ public class RepairAndMaintenanceTab { JFrame frame; String name; diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimits.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimits.java deleted file mode 100644 index bd62eb0dae..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimits.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.tabs; - -public class TechLimits { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java new file mode 100644 index 0000000000..d053f5e508 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java @@ -0,0 +1,171 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +import megamek.client.ui.baseComponents.MMComboBox; +import mekhq.campaign.campaignOptions.CampaignOptions; + +import javax.swing.*; +import javax.swing.GroupLayout.Alignment; +import java.awt.*; + +import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; + +public class TechLimitsTab { + JFrame frame; + String name; + + //start Tech Limits Tab + private JCheckBox limitByYearBox; + private JCheckBox disallowExtinctStuffBox; + private JCheckBox allowClanPurchasesBox; + private JCheckBox allowISPurchasesBox; + private JCheckBox allowCanonOnlyBox; + private JCheckBox allowCanonRefitOnlyBox; + private JLabel lblChoiceTechLevel; + private MMComboBox choiceTechLevel; + private JCheckBox variableTechLevelBox; + private JCheckBox useAmmoByTypeBox; + //end Tech Limits Tab + + //start Random Assignment Tables Tab + //end Random Assignment Tables Tab + + //start Rulesets Tab + //end Rulesets Tab + + public TechLimitsTab(JFrame frame, String name) { + this.frame = frame; + this.name = name; + + initialize(); + } + + /** + * Creates a {@link JPanel} representing the tech limits tab. + * This method constructs various components including checkboxes, labels, and combo boxes + * to customize the tech limit settings. + * + * @return a {@link JPanel} containing the technical limits tab with all its configured components + */ + JPanel createTechLimitsTab() { + // Header + JPanel headerPanel = createHeaderPanel("TechLimitsTab", + getImageDirectory() + "logo_clan_cloud_cobra.png", false, + "", true); + + // Limit Parts/Units by Year + limitByYearBox = createCheckBox("LimitByYearBox", null); + + // Disallow Extinct Units/Parts + disallowExtinctStuffBox = createCheckBox("DisallowExtinctStuffBox", null); + + // Allow Clan/Inner Sphere Purchases + allowClanPurchasesBox = createCheckBox("AllowClanPurchasesBox", null); + allowISPurchasesBox = createCheckBox("AllowISPurchasesBox", null); + + // Canon Purchases/Refits + allowCanonOnlyBox = createCheckBox("AllowCanonOnlyBox", null); + allowCanonRefitOnlyBox = createCheckBox("AllowCanonRefitOnlyBox", null); + + // Maximum Tech Level + lblChoiceTechLevel = createLabel("ChoiceTechLevel", null); + choiceTechLevel = new MMComboBox<>("choiceTechLevel", getMaximumTechLevelOptions()); + + // Variable Tech Level + variableTechLevelBox = createCheckBox("VariableTechLevelBox", null); + + // Ammo by Type + useAmmoByTypeBox = createCheckBox("UseAmmoByTypeBox", null); + + // Layout the Panel + final JPanel panel = createStandardPanel("TechLimitsTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addComponent(limitByYearBox) + .addComponent(disallowExtinctStuffBox) + .addComponent(allowClanPurchasesBox) + .addComponent(allowCanonRefitOnlyBox) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblChoiceTechLevel) + .addComponent(choiceTechLevel)) + .addComponent(variableTechLevelBox) + .addComponent(useAmmoByTypeBox)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel) + .addComponent(limitByYearBox) + .addComponent(disallowExtinctStuffBox) + .addComponent(allowClanPurchasesBox) + .addComponent(allowCanonRefitOnlyBox) + .addGroup(layout.createSequentialGroup() + .addComponent(lblChoiceTechLevel) + .addComponent(choiceTechLevel) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(variableTechLevelBox) + .addComponent(useAmmoByTypeBox)); + + // Create Parent Panel and return + JPanel parentPanel = createParentPanel(panel, "TechLimitsTab"); + + // Create a panel for the quote + JPanel quotePanel = new JPanel(); + JLabel quote = new JLabel(String.format("

%s
", + resources.getString("TechLimitsTab.border"))); + quotePanel.add(parentPanel); + quotePanel.add(quote); + + // Reorganize mainPanel to include quotePanel at bottom + JPanel contentPanel = new JPanel(new BorderLayout()); + contentPanel.setName("TechLimitsTab"); + contentPanel.add(parentPanel, BorderLayout.CENTER); + contentPanel.add(quotePanel, BorderLayout.SOUTH); + + // Create a wrapper panel for its easy alignment controls + JPanel wrapperPanel = new JPanel(new GridBagLayout()); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.anchor = GridBagConstraints.NORTH; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + + wrapperPanel.add(contentPanel, gbc); + + return wrapperPanel; + } + + protected void initialize() { + // Tech Limits Tab + limitByYearBox = new JCheckBox(); + disallowExtinctStuffBox = new JCheckBox(); + allowClanPurchasesBox = new JCheckBox(); + allowISPurchasesBox = new JCheckBox(); + allowCanonOnlyBox = new JCheckBox(); + allowCanonRefitOnlyBox = new JCheckBox(); + lblChoiceTechLevel = new JLabel(); + choiceTechLevel = new MMComboBox<>("choiceTechLevel", getMaximumTechLevelOptions()); + variableTechLevelBox = new JCheckBox(); + useAmmoByTypeBox = new JCheckBox(); + + // Random Assignment Tables Tab + + // Rulesets Tab + } + + /** + * @return a {@link DefaultComboBoxModel} containing options for maximum technology levels. + */ + private static DefaultComboBoxModel getMaximumTechLevelOptions() { + DefaultComboBoxModel maximumTechLevelModel = new DefaultComboBoxModel<>(); + + maximumTechLevelModel.addElement(CampaignOptions.getTechLevelName(CampaignOptions.TECH_INTRO)); + maximumTechLevelModel.addElement(CampaignOptions.getTechLevelName(CampaignOptions.TECH_STANDARD)); + maximumTechLevelModel.addElement(CampaignOptions.getTechLevelName(CampaignOptions.TECH_ADVANCED)); + maximumTechLevelModel.addElement(CampaignOptions.getTechLevelName(CampaignOptions.TECH_EXPERIMENTAL)); + maximumTechLevelModel.addElement(CampaignOptions.getTechLevelName(CampaignOptions.TECH_UNOFFICIAL)); + + return maximumTechLevelModel; + } +} From 0347435b519f3f98842c93e5094cd14f9747d2aa Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 7 Oct 2024 13:21:02 -0500 Subject: [PATCH 021/117] Add new tech limit options to TechLimitsTab Included 'allowISPurchasesBox' and 'allowCanonOnlyBox' components in the TechLimitsTab for enhanced configuration of tech limit options. Also organized comments in CampaignOptionsPane for better readability. --- .../gui/panes/campaignOptions/tabs/CampaignOptionsPane.java | 2 +- .../mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 3c96940a85..00a3e1aa9a 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -88,8 +88,8 @@ private JScrollPane createGeneralTab() { private JTabbedPane createCombatReadinessParentTab() { // Tech Limits - // Rulesets // Random Assignment Tables + // Rulesets // Parent Tab JTabbedPane combatReadinessParentTab = new JTabbedPane(); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java index d053f5e508..a549523966 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java @@ -87,6 +87,8 @@ JPanel createTechLimitsTab() { .addComponent(limitByYearBox) .addComponent(disallowExtinctStuffBox) .addComponent(allowClanPurchasesBox) + .addComponent(allowISPurchasesBox) + .addComponent(allowCanonOnlyBox) .addComponent(allowCanonRefitOnlyBox) .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(lblChoiceTechLevel) @@ -100,6 +102,8 @@ JPanel createTechLimitsTab() { .addComponent(limitByYearBox) .addComponent(disallowExtinctStuffBox) .addComponent(allowClanPurchasesBox) + .addComponent(allowISPurchasesBox) + .addComponent(allowCanonOnlyBox) .addComponent(allowCanonRefitOnlyBox) .addGroup(layout.createSequentialGroup() .addComponent(lblChoiceTechLevel) From 7aa9fcffa855c978ba89c0d122bf8bf4ab65f57c Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 7 Oct 2024 13:43:58 -0500 Subject: [PATCH 022/117] Refactor imports for CampaignPreset Moved CampaignPreset from campaignOptions to campaign package. --- .../campaignOptions/CampaignPreset.java | 39 ++++++------------- MekHQ/src/mekhq/gui/CampaignGUI.java | 2 +- MekHQ/src/mekhq/gui/FileDialogs.java | 2 +- .../gui/dialog/CampaignOptionsDialog.java | 18 +++++---- .../dialog/CreateCampaignPresetDialog.java | 39 ++++++++++--------- .../mekhq/gui/dialog/DataLoadingDialog.java | 12 +----- .../mekhq/gui/panels/CampaignPresetPanel.java | 2 +- .../mekhq/gui/panes/CampaignOptionsPane.java | 2 +- .../gui/renderers/CampaignPresetRenderer.java | 2 +- 9 files changed, 48 insertions(+), 70 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/campaignOptions/CampaignPreset.java b/MekHQ/src/mekhq/campaign/campaignOptions/CampaignPreset.java index a02a59d1d3..e215594869 100644 --- a/MekHQ/src/mekhq/campaign/campaignOptions/CampaignPreset.java +++ b/MekHQ/src/mekhq/campaign/campaignOptions/CampaignPreset.java @@ -18,33 +18,6 @@ */ package mekhq.campaign; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.nio.charset.StandardCharsets; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.ResourceBundle; -import java.util.stream.Collectors; - -import javax.swing.JFrame; -import javax.swing.JOptionPane; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.Version; import megamek.common.annotations.Nullable; import megamek.common.options.GameOptions; @@ -53,6 +26,7 @@ import megamek.utilities.xml.MMXMLUtility; import mekhq.MHQConstants; import mekhq.MekHQ; +import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.event.OptionsChangedEvent; import mekhq.campaign.personnel.PersonnelOptions; import mekhq.campaign.personnel.SkillType; @@ -64,6 +38,17 @@ import mekhq.campaign.universe.Systems; import mekhq.campaign.universe.companyGeneration.CompanyGenerationOptions; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import javax.swing.*; +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.time.LocalDate; +import java.util.*; +import java.util.stream.Collectors; /** * This is an object which holds a set of objects that collectively define the diff --git a/MekHQ/src/mekhq/gui/CampaignGUI.java b/MekHQ/src/mekhq/gui/CampaignGUI.java index a8ec6c5d5c..6debcbdd2c 100644 --- a/MekHQ/src/mekhq/gui/CampaignGUI.java +++ b/MekHQ/src/mekhq/gui/CampaignGUI.java @@ -37,8 +37,8 @@ import mekhq.*; import mekhq.campaign.Campaign; import mekhq.campaign.CampaignController; +import mekhq.campaign.CampaignPreset; import mekhq.campaign.campaignOptions.CampaignOptions; -import mekhq.campaign.campaignOptions.CampaignPreset; import mekhq.campaign.event.*; import mekhq.campaign.finances.Money; import mekhq.campaign.finances.financialInstitutions.FinancialInstitutions; diff --git a/MekHQ/src/mekhq/gui/FileDialogs.java b/MekHQ/src/mekhq/gui/FileDialogs.java index 1ced724396..2dd555c8dd 100644 --- a/MekHQ/src/mekhq/gui/FileDialogs.java +++ b/MekHQ/src/mekhq/gui/FileDialogs.java @@ -21,7 +21,7 @@ import mekhq.MHQConstants; import mekhq.MekHQ; import mekhq.campaign.Campaign; -import mekhq.campaign.campaignOptions.CampaignPreset; +import mekhq.campaign.CampaignPreset; import mekhq.campaign.mission.Scenario; import mekhq.campaign.mission.ScenarioTemplate; import mekhq.io.FileType; diff --git a/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java b/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java index 608c82d705..899912d1f0 100644 --- a/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java @@ -28,12 +28,15 @@ import mekhq.gui.FileDialogs; import mekhq.gui.baseComponents.AbstractMHQValidationButtonDialog; import mekhq.gui.panes.CampaignOptionsPane; +import mekhq.gui.panes.campaignOptions.SelectPresetDialog; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.util.ResourceBundle; +import static mekhq.gui.panes.campaignOptions.SelectPresetDialog.PRESET_SELECTION_CANCELLED; + /** * @author Jay Lawson (jaylawson39 at yahoo.com) (Original Version, now largely CampaignOptionsPane) * @author Justin 'Windchild' Bowen (Current Version) @@ -89,7 +92,7 @@ public void setCampaignOptionsPane(final CampaignOptionsPane campaignOptionsPane //region Initialization @Override protected Container createCenterPane() { - setCampaignOptionsPane(new CampaignOptionsPane(getFrame(), getCampaign())); + setCampaignOptionsPane(new CampaignOptionsPane(getFrame(), getCampaign(), isStartup())); return getCampaignOptionsPane(); } @@ -169,8 +172,8 @@ private void showStratConNotice() { @Override protected void finalizeInitialization() throws Exception { -// getCampaignOptionsPane().setOptions(getCampaign().getCampaignOptions(), -// getCampaign().getRandomSkillPreferences()); + getCampaignOptionsPane().setOptions(getCampaign().getCampaignOptions(), + getCampaign().getRandomSkillPreferences()); super.finalizeInitialization(); } //endregion Initialization @@ -178,20 +181,19 @@ protected void finalizeInitialization() throws Exception { //region Button Actions @Override protected void okAction() { -// getCampaignOptionsPane().updateOptions(); + getCampaignOptionsPane().updateOptions(); } @Override protected ValidationState validateAction(final boolean display) { -// return getCampaignOptionsPane().validateOptions(display); - return null; + return getCampaignOptionsPane().validateOptions(display); } private void btnSaveActionPerformed() { if (validateAction(true).isFailure()) { return; } -// getCampaignOptionsPane().updateOptions(); + getCampaignOptionsPane().updateOptions(); setResult(DialogResult.CONFIRMED); final CreateCampaignPresetDialog createCampaignPresetDialog @@ -212,6 +214,6 @@ private void btnSaveActionPerformed() { //endregion Button Actions public void applyPreset(final @Nullable CampaignPreset preset) { -// getCampaignOptionsPane().applyPreset(preset); + getCampaignOptionsPane().applyPreset(preset); } } diff --git a/MekHQ/src/mekhq/gui/dialog/CreateCampaignPresetDialog.java b/MekHQ/src/mekhq/gui/dialog/CreateCampaignPresetDialog.java index 9838821e5f..6560bb5288 100644 --- a/MekHQ/src/mekhq/gui/dialog/CreateCampaignPresetDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/CreateCampaignPresetDialog.java @@ -30,9 +30,9 @@ import megamek.common.util.sorter.NaturalOrderComparator; import mekhq.MekHQ; import mekhq.campaign.Campaign; +import mekhq.campaign.CampaignPreset; import mekhq.campaign.RandomSkillPreferences; import mekhq.campaign.campaignOptions.CampaignOptions; -import mekhq.campaign.campaignOptions.CampaignPreset; import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.SpecialAbility; import mekhq.campaign.personnel.ranks.RankSystem; @@ -47,6 +47,7 @@ import mekhq.gui.displayWrappers.FactionDisplay; import javax.swing.*; +import javax.swing.GroupLayout.Alignment; import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; @@ -538,32 +539,32 @@ public Component getListCellRendererComponent(final JList list, final Object layout.setVerticalGroup( layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(getChkSpecifyDate()) - .addComponent(btnDate, GroupLayout.Alignment.LEADING)) - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(btnDate, Alignment.LEADING)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(getChkSpecifyFaction()) - .addComponent(getComboFaction(), GroupLayout.Alignment.LEADING)) - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(getComboFaction(), Alignment.LEADING)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(getChkSpecifyPlanet()) - .addComponent(getChkStartingSystemFactionSpecific(), GroupLayout.Alignment.LEADING)) - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(getChkStartingSystemFactionSpecific(), Alignment.LEADING)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(getComboStartingSystem()) - .addComponent(getComboStartingPlanet(), GroupLayout.Alignment.LEADING)) - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(getComboStartingPlanet(), Alignment.LEADING)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(getChkSpecifyRankSystem()) - .addComponent(getComboRankSystem(), GroupLayout.Alignment.LEADING)) - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(getComboRankSystem(), Alignment.LEADING)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(lblContractCount) - .addComponent(getSpnContractCount(), GroupLayout.Alignment.LEADING)) + .addComponent(getSpnContractCount(), Alignment.LEADING)) .addComponent(getChkGM()) - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(getChkSpecifyCompanyGenerationOptions()) - .addComponent(btnCompanyGenerationOptions, GroupLayout.Alignment.LEADING)) + .addComponent(btnCompanyGenerationOptions, Alignment.LEADING)) ); layout.setHorizontalGroup( - layout.createParallelGroup(GroupLayout.Alignment.LEADING) + layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(getChkSpecifyDate()) .addComponent(btnDate)) @@ -623,14 +624,14 @@ private JPanel createContinuousPanel() { layout.setVerticalGroup( layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(getChkSpecifyGameOptions()) - .addComponent(btnGameOptions, GroupLayout.Alignment.LEADING)) + .addComponent(btnGameOptions, Alignment.LEADING)) .addComponent(getChkSpecifyCampaignOptions()) ); layout.setHorizontalGroup( - layout.createParallelGroup(GroupLayout.Alignment.LEADING) + layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(getChkSpecifyGameOptions()) .addComponent(btnGameOptions)) diff --git a/MekHQ/src/mekhq/gui/dialog/DataLoadingDialog.java b/MekHQ/src/mekhq/gui/dialog/DataLoadingDialog.java index 8c5962774f..db6a62606b 100644 --- a/MekHQ/src/mekhq/gui/dialog/DataLoadingDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/DataLoadingDialog.java @@ -30,7 +30,7 @@ import mekhq.NullEntityException; import mekhq.campaign.Campaign; import mekhq.campaign.CampaignFactory; -import mekhq.campaign.campaignOptions.CampaignPreset; +import mekhq.campaign.CampaignPreset; import mekhq.campaign.event.OptionsChangedEvent; import mekhq.campaign.finances.CurrencyManager; import mekhq.campaign.finances.financialInstitutions.FinancialInstitutions; @@ -65,16 +65,6 @@ import static mekhq.gui.panes.campaignOptions.SelectPresetDialog.PRESET_SELECTION_CUSTOMIZE; import static mekhq.gui.panes.campaignOptions.SelectPresetDialog.PRESET_SELECTION_SELECT; -import javax.swing.*; -import java.awt.*; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.io.File; -import java.io.FileInputStream; -import java.time.LocalDate; -import java.util.concurrent.CancellationException; -import java.util.concurrent.ExecutionException; - public class DataLoadingDialog extends AbstractMHQDialog implements PropertyChangeListener { private static final MMLogger logger = MMLogger.create(DataLoadingDialog.class); diff --git a/MekHQ/src/mekhq/gui/panels/CampaignPresetPanel.java b/MekHQ/src/mekhq/gui/panels/CampaignPresetPanel.java index e018962dc6..709d27d070 100644 --- a/MekHQ/src/mekhq/gui/panels/CampaignPresetPanel.java +++ b/MekHQ/src/mekhq/gui/panels/CampaignPresetPanel.java @@ -21,7 +21,7 @@ import megamek.client.ui.baseComponents.MMButton; import megamek.common.annotations.Nullable; import mekhq.campaign.Campaign; -import mekhq.campaign.campaignOptions.CampaignPreset; +import mekhq.campaign.CampaignPreset; import mekhq.gui.baseComponents.AbstractMHQPanel; import mekhq.gui.dialog.CreateCampaignPresetDialog; diff --git a/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java index eba57e06ca..34b052c65f 100644 --- a/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java @@ -40,9 +40,9 @@ import megamek.logging.MMLogger; import mekhq.MekHQ; import mekhq.campaign.Campaign; +import mekhq.campaign.CampaignPreset; import mekhq.campaign.RandomSkillPreferences; import mekhq.campaign.campaignOptions.CampaignOptions; -import mekhq.campaign.campaignOptions.CampaignPreset; import mekhq.campaign.enums.PlanetaryAcquisitionFactionLimit; import mekhq.campaign.event.OptionsChangedEvent; import mekhq.campaign.finances.enums.FinancialYearDuration; diff --git a/MekHQ/src/mekhq/gui/renderers/CampaignPresetRenderer.java b/MekHQ/src/mekhq/gui/renderers/CampaignPresetRenderer.java index 7a7a3dc0cc..25b81fe3d7 100644 --- a/MekHQ/src/mekhq/gui/renderers/CampaignPresetRenderer.java +++ b/MekHQ/src/mekhq/gui/renderers/CampaignPresetRenderer.java @@ -18,7 +18,7 @@ */ package mekhq.gui.renderers; -import mekhq.campaign.campaignOptions.CampaignPreset; +import mekhq.campaign.CampaignPreset; import mekhq.gui.panels.CampaignPresetPanel; import javax.swing.*; From 31381573c1bbbf59a0e10e634c6aa901a15e52a3 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 7 Oct 2024 13:55:39 -0500 Subject: [PATCH 023/117] Refactored CampaignOptionsDialog to disable option interactions Commented out methods and imports related to campaign options handling via the CampaignOptionsPane. This change disables the updating, validation, and application of campaign options while keeping the overall structure intact. --- .../mekhq/gui/dialog/CampaignOptionsDialog.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java b/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java index 899912d1f0..b25f1f8858 100644 --- a/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java @@ -27,8 +27,8 @@ import mekhq.campaign.CampaignPreset; import mekhq.gui.FileDialogs; import mekhq.gui.baseComponents.AbstractMHQValidationButtonDialog; -import mekhq.gui.panes.CampaignOptionsPane; import mekhq.gui.panes.campaignOptions.SelectPresetDialog; +import mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsPane; import javax.swing.*; import java.awt.*; @@ -92,7 +92,7 @@ public void setCampaignOptionsPane(final CampaignOptionsPane campaignOptionsPane //region Initialization @Override protected Container createCenterPane() { - setCampaignOptionsPane(new CampaignOptionsPane(getFrame(), getCampaign(), isStartup())); + setCampaignOptionsPane(new CampaignOptionsPane(getFrame(), getCampaign())); return getCampaignOptionsPane(); } @@ -172,8 +172,8 @@ private void showStratConNotice() { @Override protected void finalizeInitialization() throws Exception { - getCampaignOptionsPane().setOptions(getCampaign().getCampaignOptions(), - getCampaign().getRandomSkillPreferences()); +// getCampaignOptionsPane().setOptions(getCampaign().getCampaignOptions(), +// getCampaign().getRandomSkillPreferences()); super.finalizeInitialization(); } //endregion Initialization @@ -181,19 +181,20 @@ protected void finalizeInitialization() throws Exception { //region Button Actions @Override protected void okAction() { - getCampaignOptionsPane().updateOptions(); +// getCampaignOptionsPane().updateOptions(); } @Override protected ValidationState validateAction(final boolean display) { - return getCampaignOptionsPane().validateOptions(display); +// return getCampaignOptionsPane().validateOptions(display); + return null; } private void btnSaveActionPerformed() { if (validateAction(true).isFailure()) { return; } - getCampaignOptionsPane().updateOptions(); +// getCampaignOptionsPane().updateOptions(); setResult(DialogResult.CONFIRMED); final CreateCampaignPresetDialog createCampaignPresetDialog @@ -214,6 +215,6 @@ private void btnSaveActionPerformed() { //endregion Button Actions public void applyPreset(final @Nullable CampaignPreset preset) { - getCampaignOptionsPane().applyPreset(preset); +// getCampaignOptionsPane().applyPreset(preset); } } From 0f3497b9153cf77be010a13d401c8a90eeb9491b Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 7 Oct 2024 14:53:17 -0500 Subject: [PATCH 024/117] Refactor campaign options GUI: delete unused class, rename and expand PersonnelTab Deleted the unused RandomAssignmentTables class. Renamed Personnel to PersonnelTab and expanded its contents with multiple new tabs for different settings. Modified comments and reorganized imports in RepairAndMaintenanceTab and GeneralTab. Updated properties file with new labels and placeholders. --- .../NEWCampaignOptionsDialog.properties | 57 +++- .../campaignOptions/tabs/GeneralTab.java | 2 +- .../panes/campaignOptions/tabs/Personnel.java | 4 - .../campaignOptions/tabs/PersonnelTab.java | 290 ++++++++++++++++++ .../tabs/RandomAssignmentTables.java | 4 - .../tabs/RepairAndMaintenanceTab.java | 4 +- 6 files changed, 349 insertions(+), 12 deletions(-) delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Personnel.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RandomAssignmentTables.java diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 2b32f05233..692806b628 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -224,4 +224,59 @@ lblChoiceTechLevel.tooltip=PLACEHOLDER lblVariableTechLevelBox.text=Vary Introduction Date by Tech Level lblVariableTechLevelBox.tooltip=PLACEHOLDER lblUseAmmoByTypeBox.text=Use Ammo Cross-Weapon Compatibility -lblUseAmmoByTypeBox.tooltip=PLACEHOLDER \ No newline at end of file +lblUseAmmoByTypeBox.tooltip=PLACEHOLDER + +## Personnel Tab +# createGeneralTab +lblGeneralTab.text=General Options +lblGeneralTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblUseTactics.text=Use Commander Initiative Bonus +lblUseTactics.tooltip=PLACEHOLDER +lblUseInitiativeBonus.text=Use Individual Initiative Bonus +lblUseInitiativeBonus.tooltip=PLACEHOLDER +lblUseToughness.text=Use Toughness +lblUseToughness.tooltip=PLACEHOLDER +lblUseRandomToughness.text=Randomize Toughness +lblUseRandomToughness.tooltip=PLACEHOLDER +lblUseArtillery.text=Use Artillery Skill +lblUseArtillery.tooltip=PLACEHOLDER +lblUseAbilities.text=Use Special Pilot Abilities (SPAs) +lblUseAbilities.tooltip=PLACEHOLDER +lblUseEdge.text=use Edge +lblUseEdge.tooltip=PLACEHOLDER +lblUseSupportEdge.text=Support Personnel Use Edge +lblUseSupportEdge.tooltip=PLACEHOLDER +lblUseImplants.text=Use Implants +lblUseImplants.tooltip=PLACEHOLDER +lblUseAlternativeQualityAveraging.text=Use Higher-Precision Skill Averaging +lblUseAlternativeQualityAveraging.tooltip=PLACEHOLDER + +# createPersonnelLogsTab +lblPersonnelLogsTab.text=Personnel Log Options +lblPersonnelLogsTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblUseTransfers.text=Use Reassign for Logging +lblUseTransfers.tooltip=PLACEHOLDER +lblUseExtendedTOEForceName.text=Use Extended TO&E Names in Log +lblUseExtendedTOEForceName.tooltip=PLACEHOLDER +lblPersonnelLogSkillGain.text=Log Skill Gains +lblPersonnelLogSkillGain.tooltip=PLACEHOLDER +lblPersonnelLogAbilityGain.text=Log SPA Gains +lblPersonnelLogAbilityGain.tooltip=PLACEHOLDER +lblPersonnelLogEdgeGain.text=Log Edge Gains +lblPersonnelLogEdgeGain.tooltip=PLACEHOLDER +lblDisplayPersonnelLog.text=Expand Personal Log by Default +lblDisplayPersonnelLog.tooltip=PLACEHOLDER +lblDisplayScenarioLog.text=Expand Scenario Log by Default +lblDisplayScenarioLog.tooltip=PLACEHOLDER +lblDisplayKillRecord.text=Expand Kill Log by Default +lblDisplayKillRecord.tooltip=PLACEHOLDER \ No newline at end of file diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java index 036129bd4f..b2d2ce8fde 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java @@ -79,7 +79,7 @@ public GeneralTab(Campaign campaign, JFrame frame, String name) { * @return the created general tab as an AbstractMHQScrollablePanel */ public AbstractMHQScrollablePanel createGeneralTab() { - // Promotional Image + // Header JPanel imagePanel = createGeneralHeader(); // Campaign name diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Personnel.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Personnel.java deleted file mode 100644 index 3de0271fde..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Personnel.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.tabs; - -public class Personnel { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java new file mode 100644 index 0000000000..819d92f4c2 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java @@ -0,0 +1,290 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +import megamek.client.ui.baseComponents.MMComboBox; +import mekhq.campaign.personnel.enums.TimeInDisplayFormat; + +import javax.swing.*; +import javax.swing.GroupLayout.Alignment; + +import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; + +public class PersonnelTab { + JFrame frame; + String name; + + //start General Tab + private JCheckBox chkUseTactics; + private JCheckBox chkUseInitiativeBonus; + private JCheckBox chkUseToughness; + private JCheckBox chkUseRandomToughness; + private JCheckBox chkUseArtillery; + private JCheckBox chkUseAbilities; + private JCheckBox chkUseEdge; + private JCheckBox chkUseSupportEdge; + private JCheckBox chkUseImplants; + private JCheckBox chkUseAlternativeQualityAveraging; + //end General Tab + + //start Personnel Logs Tab + private JCheckBox chkUseTransfers; + private JCheckBox chkUseExtendedTOEForceName; + private JCheckBox chkPersonnelLogSkillGain; + private JCheckBox chkPersonnelLogAbilityGain; + private JCheckBox chkPersonnelLogEdgeGain; + private JCheckBox chkDisplayPersonnelLog; + private JCheckBox chkDisplayScenarioLog; + private JCheckBox chkDisplayKillRecord; + //end Personnel Logs Tab + + //start Personnel Information Tab + private JCheckBox chkUseTimeInService; + private JLabel lblTimeInServiceDisplayFormat; + private MMComboBox comboTimeInServiceDisplayFormat; + private JCheckBox chkUseTimeInRank; + private JLabel lblTimeInRankDisplayFormat; + private MMComboBox comboTimeInRankDisplayFormat; + private JCheckBox chkTrackTotalEarnings; + private JCheckBox chkTrackTotalXPEarnings; + private JCheckBox chkShowOriginFaction; + //end Personnel Information Tab + + //start Awards Tab + //end Awards Tab + + //start Administrators Tab + //end Administrators Tab + + //start Medical Tab + //end Medical Tab + + //start Prisoners & Dependents Tab + //end Prisoners & Dependents Tab + + //start Salaries Tab + //end Salaries Tab + + /** + * Represents a tab for repair and maintenance in an application. + */ + public PersonnelTab(JFrame frame, String name) { + this.frame = frame; + this.name = name; + + initialize(); + } + + protected void initialize() { + //start General Tab + chkUseTactics = new JCheckBox(); + chkUseInitiativeBonus = new JCheckBox(); + chkUseToughness = new JCheckBox(); + chkUseRandomToughness = new JCheckBox(); + chkUseArtillery = new JCheckBox(); + chkUseAbilities = new JCheckBox(); + chkUseEdge = new JCheckBox(); + chkUseSupportEdge = new JCheckBox(); + chkUseImplants = new JCheckBox(); + chkUseAlternativeQualityAveraging = new JCheckBox(); + //end General Tab + + //start Personnel Logs Tab + chkUseTransfers = new JCheckBox(); + chkUseExtendedTOEForceName = new JCheckBox(); + chkPersonnelLogSkillGain = new JCheckBox(); + chkPersonnelLogAbilityGain = new JCheckBox(); + chkPersonnelLogEdgeGain = new JCheckBox(); + chkDisplayPersonnelLog = new JCheckBox(); + chkDisplayScenarioLog = new JCheckBox(); + chkDisplayKillRecord = new JCheckBox(); + //end Personnel Logs Tab + + //start Awards Tab + chkUseTimeInService = new JCheckBox(); + lblTimeInServiceDisplayFormat = new JLabel(); + comboTimeInServiceDisplayFormat = new MMComboBox<>("comboTimeInServiceDisplayFormat", + TimeInDisplayFormat.values()); + chkUseTimeInRank = new JCheckBox(); + lblTimeInRankDisplayFormat = new JLabel(); + comboTimeInRankDisplayFormat = new MMComboBox<>("comboTimeInRankDisplayFormat", + TimeInDisplayFormat.values()); + chkTrackTotalEarnings = new JCheckBox(); + chkTrackTotalXPEarnings = new JCheckBox(); + chkShowOriginFaction = new JCheckBox(); + //end Awards Tab + + //start Personnel Information Tab + //end Personnel Information Tab + + //start Administrators Tab + //end Administrators Tab + + //start Medical Tab + //end Medical Tab + + //start Prisoners & Dependents Tab + //end Prisoners & Dependents Tab + + //start Salaries Tab + //end Salaries Tab + } + + public JPanel createGeneralTab() { + // Header + JPanel headerPanel = createHeaderPanel("GeneralTab", + getImageDirectory() + "logo_circinus_federation.png", + false, "", true); + + // Contents + chkUseTactics = createCheckBox("UseTactics", null); + chkUseInitiativeBonus = createCheckBox("UseInitiativeBonus", null); + chkUseToughness = createCheckBox("UseToughness", null); + chkUseRandomToughness = createCheckBox("UseRandomToughness", null); + chkUseArtillery = createCheckBox("UseArtillery", null); + chkUseAbilities = createCheckBox("UseAbilities", null); + chkUseEdge = createCheckBox("UseEdge", null); + chkUseSupportEdge = createCheckBox("UseSupportEdge", null); + chkUseImplants = createCheckBox("UseImplants", null); + chkUseAlternativeQualityAveraging = createCheckBox("UseAlternativeQualityAveraging", null); + + // Layout the Panel + final JPanel panel = createStandardPanel("GeneralTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addComponent(chkUseTactics) + .addComponent(chkUseInitiativeBonus) + .addComponent(chkUseToughness) + .addComponent(chkUseRandomToughness) + .addComponent(chkUseArtillery) + .addComponent(chkUseAbilities) + .addComponent(chkUseEdge) + .addComponent(chkUseSupportEdge) + .addComponent(chkUseImplants) + .addComponent(chkUseAlternativeQualityAveraging)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel) + .addComponent(chkUseTactics) + .addComponent(chkUseInitiativeBonus) + .addComponent(chkUseToughness) + .addComponent(chkUseRandomToughness) + .addComponent(chkUseArtillery) + .addComponent(chkUseAbilities) + .addComponent(chkUseEdge) + .addComponent(chkUseSupportEdge) + .addComponent(chkUseImplants) + .addComponent(chkUseAlternativeQualityAveraging)); + + // Create Parent Panel and return + return createParentPanel(panel, "GeneralTab"); + } + + public JPanel createPersonnelLogsTab() { + // Header + JPanel headerPanel = createHeaderPanel("PersonnelLogsTab", + getImageDirectory() + "logo_clan_coyote.png", + false, "", true); + + // Contents + chkUseTransfers = createCheckBox("UseTransfers", null); + chkUseExtendedTOEForceName = createCheckBox("UseExtendedTOEForceName", null); + chkPersonnelLogSkillGain = createCheckBox("PersonnelLogSkillGain", null); + chkPersonnelLogAbilityGain = createCheckBox("PersonnelLogAbilityGain", null); + chkPersonnelLogEdgeGain = createCheckBox("PersonnelLogEdgeGain", null); + chkDisplayPersonnelLog = createCheckBox("DisplayPersonnelLog", null); + chkDisplayScenarioLog = createCheckBox("DisplayScenarioLog", null); + chkDisplayKillRecord = createCheckBox("DisplayKillRecord", null); + + // Layout the Panel + final JPanel panel = createStandardPanel("PersonnelLogsTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addComponent(chkUseTransfers) + .addComponent(chkUseExtendedTOEForceName) + .addComponent(chkPersonnelLogSkillGain) + .addComponent(chkPersonnelLogAbilityGain) + .addComponent(chkPersonnelLogEdgeGain) + .addComponent(chkDisplayPersonnelLog) + .addComponent(chkDisplayScenarioLog) + .addComponent(chkDisplayKillRecord)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel) + .addComponent(chkUseTransfers) + .addComponent(chkUseExtendedTOEForceName) + .addComponent(chkPersonnelLogSkillGain) + .addComponent(chkPersonnelLogAbilityGain) + .addComponent(chkPersonnelLogEdgeGain) + .addComponent(chkDisplayPersonnelLog) + .addComponent(chkDisplayScenarioLog) + .addComponent(chkDisplayKillRecord)); + + // Create Parent Panel and return + return createParentPanel(panel, "PersonnelLogsTab"); + } + + public JPanel createPersonnelInformationTab() { + // Header + JPanel headerPanel = createHeaderPanel("PersonnelInformation", + getImageDirectory() + "logo_comstar.png", + false, "", true); + + // Contents + chkUseTimeInService = createCheckBox("UseTimeInService", null); + lblTimeInServiceDisplayFormat = createLabel("TimeInServiceDisplayFormat", null); + chkUseTimeInRank = createCheckBox("UseTimeInRank", null); + lblTimeInRankDisplayFormat = createLabel("TimeInRankDisplayFormat", null); + chkTrackTotalEarnings = createCheckBox("TrackTotalEarnings", null); + chkTrackTotalXPEarnings = createCheckBox("TrackTotalXPEarnings", null); + chkShowOriginFaction = createCheckBox("ShowOriginFaction", null); + + // Layout the Panel + final JPanel panel = createStandardPanel("PersonnelInformation", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addComponent(chkUseTimeInService) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblTimeInServiceDisplayFormat) + .addComponent(comboTimeInServiceDisplayFormat)) + .addComponent(chkUseTimeInRank) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblTimeInRankDisplayFormat) + .addComponent(comboTimeInRankDisplayFormat)) + .addComponent(chkTrackTotalEarnings) + .addComponent(chkTrackTotalXPEarnings) + .addComponent(chkShowOriginFaction)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel) + .addComponent(chkUseTimeInService) + .addGroup(layout.createSequentialGroup() + .addComponent(lblTimeInServiceDisplayFormat) + .addComponent(comboTimeInServiceDisplayFormat) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkUseTimeInRank) + .addGroup(layout.createSequentialGroup() + .addComponent(lblTimeInRankDisplayFormat) + .addComponent(comboTimeInRankDisplayFormat) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkTrackTotalEarnings) + .addComponent(chkTrackTotalXPEarnings) + .addComponent(chkShowOriginFaction)); + + // Create Parent Panel and return + return createParentPanel(panel, "PersonnelInformation"); + } +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RandomAssignmentTables.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RandomAssignmentTables.java deleted file mode 100644 index 0438307d3c..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RandomAssignmentTables.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.tabs; - -public class RandomAssignmentTables { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java index e318c8d883..b9a3c34d59 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java @@ -140,7 +140,7 @@ public JPanel createRepairTab() { * @return The created maintenance tab panel as a {@link JPanel}. */ public JPanel createMaintenanceTab() { - // Promotional Image + // Header JPanel imagePanel = createHeaderPanel("MaintenanceTab", getImageDirectory() + "logo_clan_blood_spirit.png", false, "", true); @@ -221,7 +221,7 @@ public JPanel createMaintenanceTab() { .addGroup(layout.createSequentialGroup() .addComponent(lblDefaultMaintenanceTime) .addComponent(spnDefaultMaintenanceTime) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) .addComponent(useQualityMaintenance) .addComponent(reverseQualityNames) .addComponent(chkUseRandomUnitQualities) From 3ce82e9c606d0961372dd7c1da3722cf9e20eab7 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 7 Oct 2024 16:00:50 -0500 Subject: [PATCH 025/117] Add tabs for Administrators and Awards in PersonnelTab Implemented new tabs within PersonnelTab for administrators and awards. Added respective UI elements and layout configurations to support negotiation, scrounge, and award options. --- .../NEWCampaignOptionsDialog.properties | 69 ++++- .../campaignOptions/tabs/PersonnelTab.java | 274 +++++++++++++++++- 2 files changed, 334 insertions(+), 9 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 692806b628..838d642509 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -279,4 +279,71 @@ lblDisplayPersonnelLog.tooltip=PLACEHOLDER lblDisplayScenarioLog.text=Expand Scenario Log by Default lblDisplayScenarioLog.tooltip=PLACEHOLDER lblDisplayKillRecord.text=Expand Kill Log by Default -lblDisplayKillRecord.tooltip=PLACEHOLDER \ No newline at end of file +lblDisplayKillRecord.tooltip=PLACEHOLDER + +# createAdministratorsTab +lblAdministratorsTab.text=Administrator Options +lblAdministratorsTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblAdminsHaveNegotiation.text=Admins Have Negotiation +lblAdminsHaveNegotiation.tooltip=PLACEHOLDER +lblAdminExperienceLevelIncludeNegotiation.text=Negotiation Factored into Experience Level +lblAdminExperienceLevelIncludeNegotiation.tooltip=PLACEHOLDER +lblAdminsHaveScrounge.text=Admins Have Scrounge +lblAdminsHaveScrounge.tooltip=PLACEHOLDER +lblAdminExperienceLevelIncludeScrounge.text=Scrounge Factored into Experience Level +lblAdminExperienceLevelIncludeScrounge.tooltip=PLACEHOLDER + +# createAwardsTab +lblAwardsTab.text=Awards Options +lblAwardsTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblAwardBonusStyle.text=Bonuses +lblAwardBonusStyle.tooltip=PLACEHOLDER +lblAwardTierSize.text=Tier Size +lblAwardTierSize.tooltip=PLACEHOLDER +lblEnableAutoAwards.text=Enable autoAwards +lblEnableAutoAwards.tooltip=PLACEHOLDER +lblIssuePosthumousAwards.text=Issue Posthumous Awards +lblIssuePosthumousAwards.tooltip=PLACEHOLDER +lblIssueBestAwardOnly.text=Issue Best Award Only +lblIssueBestAwardOnly.tooltip=PLACEHOLDER +lblIgnoreStandardSet.text=Ignore the Standard Set +lblIgnoreStandardSet.tooltip=PLACEHOLDER +lblAwardSetFilterList.text=Award Set Filter +lblAwardSetFilterList.tooltip=PLACEHOLDER + +# createAutoAwardsFilterPanel +autoAwardsFilterPanel.title=autoAwards Award Tracking +lblEnableContractAwards.text=Contract +lblEnableContractAwards.tooltip=PLACEHOLDER +lblEnableFactionHunterAwards.text=Faction Hunter +lblEnableFactionHunterAwards.tooltip=PLACEHOLDER +lblEnableInjuryAwards.text=Injury +lblEnableInjuryAwards.tooltip=PLACEHOLDER +lblEnableIndividualKillAwards.text=Kill (Individual) +lblEnableIndividualKillAwards.tooltip=PLACEHOLDER +lblEnableFormationKillAwards.text=Kill (Formation) +lblEnableFormationKillAwards.tooltip=PLACEHOLDER +lblEnableRankAwards.text=Rank +lblEnableRankAwards.tooltip=PLACEHOLDER +lblEnableScenarioAwards.text=Scenario +lblEnableScenarioAwards.tooltip=PLACEHOLDER +lblEnableSkillAwards.text=Skill +lblEnableSkillAwards.tooltip=PLACEHOLDER +lblEnableTheatreOfWarAwards.text=Theatre of War +lblEnableTheatreOfWarAwards.tooltip=PLACEHOLDER +lblEnableTimeAwards.text=Time +lblEnableTimeAwards.tooltip=PLACEHOLDER +lblEnableTrainingAwards.text=Training +lblEnableTrainingAwards.tooltip=PLACEHOLDER +lblEnableMiscAwards.text=Misc +lblEnableMiscAwards.tooltip=PLACEHOLDER \ No newline at end of file diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java index 819d92f4c2..60acab7e82 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java @@ -1,11 +1,14 @@ package mekhq.gui.panes.campaignOptions.tabs; import megamek.client.ui.baseComponents.MMComboBox; +import mekhq.campaign.personnel.enums.AwardBonus; import mekhq.campaign.personnel.enums.TimeInDisplayFormat; import javax.swing.*; import javax.swing.GroupLayout.Alignment; +import java.awt.*; +import static megamek.client.ui.WrapLayout.wordWrap; import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; public class PersonnelTab { @@ -48,12 +51,40 @@ public class PersonnelTab { private JCheckBox chkShowOriginFaction; //end Personnel Information Tab - //start Awards Tab - //end Awards Tab - //start Administrators Tab + private JCheckBox chkAdminsHaveNegotiation; + private JCheckBox chkAdminExperienceLevelIncludeNegotiation; + private JCheckBox chkAdminsHaveScrounge; + private JCheckBox chkAdminExperienceLevelIncludeScrounge; //end Administrators Tab + //start Awards Tab + private JLabel lblAwardBonusStyle; + private MMComboBox comboAwardBonusStyle; + private JLabel lblAwardTierSize; + private JSpinner spnAwardTierSize; + private JCheckBox chkEnableAutoAwards; + private JCheckBox chkIssuePosthumousAwards; + private JCheckBox chkIssueBestAwardOnly; + private JCheckBox chkIgnoreStandardSet; + + private JPanel autoAwardsFilterPanel; + private JCheckBox chkEnableContractAwards; + private JCheckBox chkEnableFactionHunterAwards; + private JCheckBox chkEnableInjuryAwards; + private JCheckBox chkEnableIndividualKillAwards; + private JCheckBox chkEnableFormationKillAwards; + private JCheckBox chkEnableRankAwards; + private JCheckBox chkEnableScenarioAwards; + private JCheckBox chkEnableSkillAwards; + private JCheckBox chkEnableTheatreOfWarAwards; + private JCheckBox chkEnableTimeAwards; + private JCheckBox chkEnableTrainingAwards; + private JCheckBox chkEnableMiscAwards; + private JLabel lblAwardSetFilterList; + private JTextArea txtAwardSetFilterList; + //end Awards Tab + //start Medical Tab //end Medical Tab @@ -98,11 +129,11 @@ protected void initialize() { chkDisplayKillRecord = new JCheckBox(); //end Personnel Logs Tab - //start Awards Tab + //start Personnel Information Tab chkUseTimeInService = new JCheckBox(); lblTimeInServiceDisplayFormat = new JLabel(); comboTimeInServiceDisplayFormat = new MMComboBox<>("comboTimeInServiceDisplayFormat", - TimeInDisplayFormat.values()); + TimeInDisplayFormat.values()); chkUseTimeInRank = new JCheckBox(); lblTimeInRankDisplayFormat = new JLabel(); comboTimeInRankDisplayFormat = new MMComboBox<>("comboTimeInRankDisplayFormat", @@ -110,14 +141,40 @@ protected void initialize() { chkTrackTotalEarnings = new JCheckBox(); chkTrackTotalXPEarnings = new JCheckBox(); chkShowOriginFaction = new JCheckBox(); - //end Awards Tab - - //start Personnel Information Tab //end Personnel Information Tab //start Administrators Tab + chkAdminsHaveNegotiation = new JCheckBox(); + chkAdminExperienceLevelIncludeNegotiation = new JCheckBox(); + chkAdminsHaveScrounge = new JCheckBox(); + chkAdminExperienceLevelIncludeScrounge = new JCheckBox(); //end Administrators Tab + //start Awards Tab + lblAwardBonusStyle = new JLabel(); + comboAwardBonusStyle = new MMComboBox<>("comboAwardBonusStyle", AwardBonus.values()); + lblAwardTierSize = new JLabel(); + spnAwardTierSize = new JSpinner(); + chkEnableAutoAwards = new JCheckBox(); + chkIssuePosthumousAwards = new JCheckBox(); + chkIssueBestAwardOnly = new JCheckBox(); + chkIgnoreStandardSet = new JCheckBox(); + chkEnableContractAwards = new JCheckBox(); + chkEnableFactionHunterAwards = new JCheckBox(); + chkEnableInjuryAwards = new JCheckBox(); + chkEnableIndividualKillAwards = new JCheckBox(); + chkEnableFormationKillAwards = new JCheckBox(); + chkEnableRankAwards = new JCheckBox(); + chkEnableScenarioAwards = new JCheckBox(); + chkEnableSkillAwards = new JCheckBox(); + chkEnableTheatreOfWarAwards = new JCheckBox(); + chkEnableTimeAwards = new JCheckBox(); + chkEnableTrainingAwards = new JCheckBox(); + chkEnableMiscAwards = new JCheckBox(); + lblAwardSetFilterList = new JLabel(); + txtAwardSetFilterList = new JTextArea(); + //end Awards Tab + //start Medical Tab //end Medical Tab @@ -287,4 +344,205 @@ public JPanel createPersonnelInformationTab() { // Create Parent Panel and return return createParentPanel(panel, "PersonnelInformation"); } + + public JPanel createAdministratorsTab() { + // Header + JPanel headerPanel = createHeaderPanel("AdministratorsTab", + getImageDirectory() + "logo_clan_diamond_sharks.png", + false, "", true); + + // Contents + chkAdminsHaveNegotiation = createCheckBox("AdminsHaveNegotiation", null); + chkAdminExperienceLevelIncludeNegotiation = createCheckBox("AdminExperienceLevelIncludeNegotiation", null); + chkAdminsHaveScrounge = createCheckBox("AdminsHaveScrounge", null); + chkAdminExperienceLevelIncludeScrounge = createCheckBox("AdminExperienceLevelIncludeScrounge", null); + + // Layout the Panel + final JPanel panel = createStandardPanel("AdministratorsTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addComponent(chkAdminsHaveNegotiation) + .addComponent(chkAdminExperienceLevelIncludeNegotiation) + .addComponent(chkAdminsHaveScrounge) + .addComponent(chkAdminExperienceLevelIncludeScrounge)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel) + .addComponent(chkAdminsHaveNegotiation) + .addComponent(chkAdminExperienceLevelIncludeNegotiation) + .addComponent(chkAdminsHaveScrounge) + .addComponent(chkAdminExperienceLevelIncludeScrounge)); + + // Create Parent Panel and return + return createParentPanel(panel, "AdministratorsTab"); + } + + public JPanel createAwardsTab() { + // Header + JPanel headerPanel = createHeaderPanel("AwardsTab", + getImageDirectory() + "logo_draconis_combine.png", + false, "", true); + + // Contents + lblAwardBonusStyle = createLabel("AwardBonusStyle", null); + comboAwardBonusStyle.setRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(final JList list, final Object value, + final int index, final boolean isSelected, + final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof AwardBonus) { + list.setToolTipText(((AwardBonus) value).getToolTipText()); + } + return this; + } + }); + + lblAwardTierSize = createLabel("", null); + spnAwardTierSize = createSpinner("AwardTierSize", null, + 5, 1, 100, 1); + + chkEnableAutoAwards = createCheckBox("EnableAutoAwards", null); + + chkIssuePosthumousAwards = createCheckBox("IssuePosthumousAwards", null); + + chkIssueBestAwardOnly = createCheckBox("IssueBestAwardOnly", null); + + chkIgnoreStandardSet = createCheckBox("IgnoreStandardSet", null); + + autoAwardsFilterPanel = createAutoAwardsFilterPanel(); + + lblAwardSetFilterList = createLabel("AwardSetFilterList", null); + txtAwardSetFilterList = new JTextArea(5, 20); + txtAwardSetFilterList.setLineWrap(true); + txtAwardSetFilterList.setWrapStyleWord(true); + txtAwardSetFilterList.setToolTipText( + wordWrap(resources.getString("lblAwardSetFilterList.toolTipText"))); + txtAwardSetFilterList.setName("txtAwardSetFilterList"); + txtAwardSetFilterList.setText(""); + JScrollPane scrollAwardSetFilterList = new JScrollPane(txtAwardSetFilterList); + scrollAwardSetFilterList.setHorizontalScrollBarPolicy( + ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + scrollAwardSetFilterList.setVerticalScrollBarPolicy( + ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); + + // Layout the Panel + final JPanel panel = createStandardPanel("AwardsTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblAwardBonusStyle) + .addComponent(comboAwardBonusStyle)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblAwardTierSize) + .addComponent(spnAwardTierSize)) + .addComponent(chkEnableAutoAwards) + .addComponent(chkIssuePosthumousAwards) + .addComponent(chkIssueBestAwardOnly) + .addComponent(chkIgnoreStandardSet) + .addComponent(autoAwardsFilterPanel) + .addComponent(lblAwardSetFilterList) + .addComponent(txtAwardSetFilterList)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel) + .addGroup(layout.createSequentialGroup() + .addComponent(lblAwardBonusStyle) + .addComponent(comboAwardBonusStyle) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblAwardTierSize) + .addComponent(spnAwardTierSize) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkEnableAutoAwards) + .addComponent(chkIssuePosthumousAwards) + .addComponent(chkIssueBestAwardOnly) + .addComponent(chkIgnoreStandardSet) + .addComponent(autoAwardsFilterPanel) + .addComponent(lblAwardSetFilterList) + .addComponent(txtAwardSetFilterList)); + + // Create Parent Panel and return + return createParentPanel(panel, "AwardsTab"); + } + + /** + * Creates a panel with checkboxes for various types of autoAwards award filter options. + *

+ * This method creates checkboxes for different types of awards filters such as contract awards, + * faction hunter awards, injury awards, individual kill awards, etc. + * + * @return a {@link JPanel} containing checkboxes for various types of autoAwards award filter + * options + */ + public JPanel createAutoAwardsFilterPanel() { + // Contents + chkEnableContractAwards = createCheckBox("EnableContractAwards", null); + chkEnableFactionHunterAwards = createCheckBox("EnableFactionHunterAwards", null); + chkEnableInjuryAwards = createCheckBox("EnableInjuryAwards", null); + chkEnableIndividualKillAwards = createCheckBox("EnableIndividualKillAwards", null); + chkEnableFormationKillAwards = createCheckBox("EnableFormationKillAwards", null); + chkEnableRankAwards = createCheckBox("EnableRankAwards", null); + chkEnableScenarioAwards = createCheckBox("EnableScenarioAwards", null); + chkEnableSkillAwards = createCheckBox("EnableSkillAwards", null); + chkEnableTheatreOfWarAwards = createCheckBox("EnableTheatreOfWarAwards", null); + chkEnableTimeAwards = createCheckBox("EnableTimeAwards", null); + chkEnableTrainingAwards = createCheckBox("EnableTrainingAwards", null); + chkEnableMiscAwards = createCheckBox("EnableMiscAwards", null); + + // Layout the Panel + final JPanel panel = createStandardPanel("AutoAwardsFilterPanel", true, ""); + panel.setBorder(BorderFactory.createTitledBorder(resources.getString("autoAwardsFilterPanel.title"))); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createParallelGroup(Alignment.BASELINE) + .addGroup(layout.createSequentialGroup() + .addComponent(chkEnableContractAwards) + .addComponent(chkEnableFactionHunterAwards) + .addComponent(chkEnableInjuryAwards) + .addComponent(chkEnableIndividualKillAwards)) + .addGroup(layout.createSequentialGroup() + .addComponent(chkEnableRankAwards) + .addComponent(chkEnableScenarioAwards) + .addComponent(chkEnableSkillAwards) + .addComponent(chkEnableFormationKillAwards)) + .addGroup(layout.createSequentialGroup() + .addComponent(chkEnableTheatreOfWarAwards) + .addComponent(chkEnableTimeAwards) + .addComponent(chkEnableTrainingAwards) + .addComponent(chkEnableMiscAwards))); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup() + .addComponent(chkEnableContractAwards) + .addComponent(chkEnableFactionHunterAwards) + .addComponent(chkEnableInjuryAwards) + .addComponent(chkEnableIndividualKillAwards)) + .addGroup(layout.createParallelGroup() + .addComponent(chkEnableFormationKillAwards) + .addComponent(chkEnableRankAwards) + .addComponent(chkEnableScenarioAwards) + .addComponent(chkEnableSkillAwards)) + .addGroup(layout.createParallelGroup() + .addComponent(chkEnableTheatreOfWarAwards) + .addComponent(chkEnableTimeAwards) + .addComponent(chkEnableTrainingAwards) + .addComponent(chkEnableMiscAwards))); + + // Create Parent Panel and return + return createParentPanel(panel, "AutoAwardsFilterPanel"); + } } From a869a76f276ac4596d0f64259c41a0eb0a28add2 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 8 Oct 2024 11:37:21 -0500 Subject: [PATCH 026/117] Add Personnel and Prisoner/Dependent Management Features Implemented new UI components and functionality for personnel cleanup and prisoner/dependent management in the campaign options dialog. This includes new panels and options for enabling/disabling personnel removal, managing prisoner statuses, and handling dependents. --- .../NEWCampaignOptionsDialog.properties | 40 ++- .../campaignOptions/tabs/PersonnelTab.java | 239 +++++++++++++++++- 2 files changed, 269 insertions(+), 10 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 838d642509..87a01d2ff5 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -256,6 +256,15 @@ lblUseImplants.tooltip=PLACEHOLDER lblUseAlternativeQualityAveraging.text=Use Higher-Precision Skill Averaging lblUseAlternativeQualityAveraging.tooltip=PLACEHOLDER +# createPersonnelCleanUpPanel +PersonnelCleanUpPanel.title=Personnel Cleanup +lblUsePersonnelRemoval.text=Enable Personnel Cleanup +lblUsePersonnelRemoval.tooltip=PLACEHOLDER +lblUseRemovalExemptCemetery.text=Exempt Dead Personnel +lblUseRemovalExemptCemetery.tooltip=PLACEHOLDER +lblUseRemovalExemptRetirees.text=Exempt Retirees +lblUseRemovalExemptRetirees.tooltip=PLACEHOLDER + # createPersonnelLogsTab lblPersonnelLogsTab.text=Personnel Log Options lblPersonnelLogsTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ @@ -346,4 +355,33 @@ lblEnableTimeAwards.tooltip=PLACEHOLDER lblEnableTrainingAwards.text=Training lblEnableTrainingAwards.tooltip=PLACEHOLDER lblEnableMiscAwards.text=Misc -lblEnableMiscAwards.tooltip=PLACEHOLDER \ No newline at end of file +lblEnableMiscAwards.tooltip=PLACEHOLDER + +# createPrisonersAndDependentsTab +lblPrisonersAndDependentsTab.text=Dependent & Prisoner Options +lblPrisonersAndDependentsTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam + +# createPrisonersPanel +PrisonersPanel.title=Prisoners +lblPrisonerCaptureStyle.text=Capture Style +lblPrisonerCaptureStyle.tooltip=PLACEHOLDER +lblPrisonerStatus.text=Default Status +lblPrisonerStatus.tooltip=PLACEHOLDER +lblPrisonerBabyStatus.text=Prisoner Babies Share Mother's Status +lblPrisonerBabyStatus.tooltip=PLACEHOLDER +lblAtBPrisonerDefection.text=Enable Defection +lblAtBPrisonerDefection.tooltip=PLACEHOLDER +lblAtBPrisonerRansom.text=Enable Prisoner Ransoms +lblAtBPrisonerRansom.tooltip=PLACEHOLDER + +# createDependentsPanel +DependentsPanel.title=Dependents +lblUseRandomDependentAddition.text= +lblUseRandomDependentAddition.tooltip=PLACEHOLDER +lblUseRandomDependentRemoval.text= +lblUseRandomDependentRemoval.tooltip=PLACEHOLDER diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java index 60acab7e82..8f0b108323 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java @@ -2,6 +2,8 @@ import megamek.client.ui.baseComponents.MMComboBox; import mekhq.campaign.personnel.enums.AwardBonus; +import mekhq.campaign.personnel.enums.PrisonerCaptureStyle; +import mekhq.campaign.personnel.enums.PrisonerStatus; import mekhq.campaign.personnel.enums.TimeInDisplayFormat; import javax.swing.*; @@ -26,6 +28,11 @@ public class PersonnelTab { private JCheckBox chkUseSupportEdge; private JCheckBox chkUseImplants; private JCheckBox chkUseAlternativeQualityAveraging; + + private JPanel personnelCleanUpPanel; + private JCheckBox chkUsePersonnelRemoval; + private JCheckBox chkUseRemovalExemptCemetery; + private JCheckBox chkUseRemovalExemptRetirees; //end General Tab //start Personnel Logs Tab @@ -89,6 +96,18 @@ public class PersonnelTab { //end Medical Tab //start Prisoners & Dependents Tab + private JPanel prisonerPanel; + private JLabel lblPrisonerCaptureStyle; + private MMComboBox comboPrisonerCaptureStyle; + private JLabel lblPrisonerStatus; + private MMComboBox comboPrisonerStatus; + private JCheckBox chkPrisonerBabyStatus; + private JCheckBox chkAtBPrisonerDefection; + private JCheckBox chkAtBPrisonerRansom; + + private JPanel dependentsPanel; + private JCheckBox chkUseRandomDependentAddition; + private JCheckBox chkUseRandomDependentRemoval; //end Prisoners & Dependents Tab //start Salaries Tab @@ -97,7 +116,7 @@ public class PersonnelTab { /** * Represents a tab for repair and maintenance in an application. */ - public PersonnelTab(JFrame frame, String name) { + private PersonnelTab(JFrame frame, String name) { this.frame = frame; this.name = name; @@ -116,6 +135,11 @@ protected void initialize() { chkUseSupportEdge = new JCheckBox(); chkUseImplants = new JCheckBox(); chkUseAlternativeQualityAveraging = new JCheckBox(); + + personnelCleanUpPanel = new JPanel(); + chkUsePersonnelRemoval = new JCheckBox(); + chkUseRemovalExemptCemetery = new JCheckBox(); + chkUseRemovalExemptRetirees = new JCheckBox(); //end General Tab //start Personnel Logs Tab @@ -131,13 +155,17 @@ protected void initialize() { //start Personnel Information Tab chkUseTimeInService = new JCheckBox(); + lblTimeInServiceDisplayFormat = new JLabel(); comboTimeInServiceDisplayFormat = new MMComboBox<>("comboTimeInServiceDisplayFormat", TimeInDisplayFormat.values()); + chkUseTimeInRank = new JCheckBox(); + lblTimeInRankDisplayFormat = new JLabel(); comboTimeInRankDisplayFormat = new MMComboBox<>("comboTimeInRankDisplayFormat", TimeInDisplayFormat.values()); + chkTrackTotalEarnings = new JCheckBox(); chkTrackTotalXPEarnings = new JCheckBox(); chkShowOriginFaction = new JCheckBox(); @@ -153,6 +181,7 @@ protected void initialize() { //start Awards Tab lblAwardBonusStyle = new JLabel(); comboAwardBonusStyle = new MMComboBox<>("comboAwardBonusStyle", AwardBonus.values()); + lblAwardTierSize = new JLabel(); spnAwardTierSize = new JSpinner(); chkEnableAutoAwards = new JCheckBox(); @@ -171,6 +200,7 @@ protected void initialize() { chkEnableTimeAwards = new JCheckBox(); chkEnableTrainingAwards = new JCheckBox(); chkEnableMiscAwards = new JCheckBox(); + lblAwardSetFilterList = new JLabel(); txtAwardSetFilterList = new JTextArea(); //end Awards Tab @@ -179,13 +209,42 @@ protected void initialize() { //end Medical Tab //start Prisoners & Dependents Tab + prisonerPanel = new JPanel(); + lblPrisonerCaptureStyle = new JLabel(); + comboPrisonerCaptureStyle = new MMComboBox<>("comboPrisonerCaptureStyle", + PrisonerCaptureStyle.values()); + + lblPrisonerStatus = new JLabel(); + comboPrisonerStatus = new MMComboBox<>("comboPrisonerStatus", + getPrisonerStatusOptions()); + + chkPrisonerBabyStatus = new JCheckBox(); + chkAtBPrisonerDefection = new JCheckBox(); + chkAtBPrisonerRansom = new JCheckBox(); + + dependentsPanel = new JPanel(); + chkUseRandomDependentAddition = new JCheckBox(); + chkUseRandomDependentRemoval = new JCheckBox(); //end Prisoners & Dependents Tab //start Salaries Tab //end Salaries Tab } - public JPanel createGeneralTab() { + /** + * @return a {@link DefaultComboBoxModel} containing all {@link PrisonerStatus} options except + * {@code PrisonerStatus.FREE} + */ + private DefaultComboBoxModel getPrisonerStatusOptions() { + final DefaultComboBoxModel prisonerStatusModel = new DefaultComboBoxModel<>( + PrisonerStatus.values()); + // we don't want this as a standard use case for prisoners + prisonerStatusModel.removeElement(PrisonerStatus.FREE); + + return prisonerStatusModel; + } + + private JPanel createGeneralTab() { // Header JPanel headerPanel = createHeaderPanel("GeneralTab", getImageDirectory() + "logo_circinus_federation.png", @@ -203,6 +262,8 @@ public JPanel createGeneralTab() { chkUseImplants = createCheckBox("UseImplants", null); chkUseAlternativeQualityAveraging = createCheckBox("UseAlternativeQualityAveraging", null); + personnelCleanUpPanel = createPersonnelCleanUpPanel(); + // Layout the Panel final JPanel panel = createStandardPanel("GeneralTab", true, ""); final GroupLayout layout = createStandardLayout(panel); @@ -220,7 +281,8 @@ public JPanel createGeneralTab() { .addComponent(chkUseEdge) .addComponent(chkUseSupportEdge) .addComponent(chkUseImplants) - .addComponent(chkUseAlternativeQualityAveraging)); + .addComponent(chkUseAlternativeQualityAveraging) + .addComponent(personnelCleanUpPanel)); layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) @@ -234,13 +296,50 @@ public JPanel createGeneralTab() { .addComponent(chkUseEdge) .addComponent(chkUseSupportEdge) .addComponent(chkUseImplants) - .addComponent(chkUseAlternativeQualityAveraging)); + .addComponent(chkUseAlternativeQualityAveraging) + .addComponent(personnelCleanUpPanel)); // Create Parent Panel and return return createParentPanel(panel, "GeneralTab"); } - public JPanel createPersonnelLogsTab() { + /** + * Creates a panel for personnel cleanup settings. + *

+ * This method creates checkboxes for personnel cleanup options such as personnel removal, exempt + * cemetery personnel, and exempt retirees. + * + * @return a {@link JPanel} containing the personnel cleanup checkboxes + */ + private JPanel createPersonnelCleanUpPanel() { + // Contents + chkUsePersonnelRemoval = createCheckBox("UsePersonnelRemoval", null); + chkUseRemovalExemptCemetery = createCheckBox("UseRemovalExemptCemetery", null); + chkUseRemovalExemptRetirees = createCheckBox("UseRemovalExemptRetirees", null); + + // Layout the Panel + final JPanel panel = createStandardPanel("PersonnelCleanUpPanel", true, ""); + panel.setBorder(BorderFactory.createTitledBorder(resources.getString("PersonnelCleanUpPanel.title"))); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(chkUsePersonnelRemoval) + .addComponent(chkUseRemovalExemptCemetery) + .addComponent(chkUseRemovalExemptRetirees)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(chkUsePersonnelRemoval) + .addComponent(chkUseRemovalExemptCemetery) + .addComponent(chkUseRemovalExemptRetirees)); + + // Create Parent Panel and return + return createParentPanel(panel, "PersonnelCleanUpPanel"); + } + + private JPanel createPersonnelLogsTab() { // Header JPanel headerPanel = createHeaderPanel("PersonnelLogsTab", getImageDirectory() + "logo_clan_coyote.png", @@ -289,7 +388,7 @@ public JPanel createPersonnelLogsTab() { return createParentPanel(panel, "PersonnelLogsTab"); } - public JPanel createPersonnelInformationTab() { + private JPanel createPersonnelInformationTab() { // Header JPanel headerPanel = createHeaderPanel("PersonnelInformation", getImageDirectory() + "logo_comstar.png", @@ -345,7 +444,7 @@ public JPanel createPersonnelInformationTab() { return createParentPanel(panel, "PersonnelInformation"); } - public JPanel createAdministratorsTab() { + private JPanel createAdministratorsTab() { // Header JPanel headerPanel = createHeaderPanel("AdministratorsTab", getImageDirectory() + "logo_clan_diamond_sharks.png", @@ -382,7 +481,7 @@ public JPanel createAdministratorsTab() { return createParentPanel(panel, "AdministratorsTab"); } - public JPanel createAwardsTab() { + private JPanel createAwardsTab() { // Header JPanel headerPanel = createHeaderPanel("AwardsTab", getImageDirectory() + "logo_draconis_combine.png", @@ -485,7 +584,7 @@ public Component getListCellRendererComponent(final JList list, final Object * @return a {@link JPanel} containing checkboxes for various types of autoAwards award filter * options */ - public JPanel createAutoAwardsFilterPanel() { + private JPanel createAutoAwardsFilterPanel() { // Contents chkEnableContractAwards = createCheckBox("EnableContractAwards", null); chkEnableFactionHunterAwards = createCheckBox("EnableFactionHunterAwards", null); @@ -545,4 +644,126 @@ public JPanel createAutoAwardsFilterPanel() { // Create Parent Panel and return return createParentPanel(panel, "AutoAwardsFilterPanel"); } + + private JPanel createPrisonersAndDependentsTab() { + // Header + JPanel headerPanel = createHeaderPanel("PrisonersAndDependentsTab", + getImageDirectory() + "logo_clan_fire_mandrills.png", + false, "", true); + + // Contents + prisonerPanel = createPrisonersPanel(); + dependentsPanel = createDependentsPanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("PrisonersAndDependentsTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(prisonerPanel) + .addComponent(dependentsPanel))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel) + .addGroup(layout.createSequentialGroup() + .addComponent(prisonerPanel) + .addComponent(dependentsPanel) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + // Create Parent Panel and return + return createParentPanel(panel, "PrisonersAndDependentsTab"); + } + + private JPanel createPrisonersPanel() { + // Contents + lblPrisonerCaptureStyle = createLabel("PrisonerCaptureStyle", null); + comboPrisonerCaptureStyle.setRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(final JList list, final Object value, + final int index, final boolean isSelected, + final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof PrisonerCaptureStyle) { + list.setToolTipText(((PrisonerCaptureStyle) value).getToolTipText()); + } + return this; + } + }); + + lblPrisonerStatus = createLabel("PrisonerStatus", null); + + chkPrisonerBabyStatus = createCheckBox("PrisonerBabyStatus", null); + chkAtBPrisonerDefection = createCheckBox("AtBPrisonerDefection", null); + chkAtBPrisonerRansom = createCheckBox("AtBPrisonerRansom", null); + + // Layout the Panel + final JPanel panel = createStandardPanel("PrisonersPanel", true, ""); + panel.setBorder(BorderFactory.createTitledBorder(resources.getString("PrisonersPanel.title"))); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPrisonerCaptureStyle) + .addComponent(comboPrisonerCaptureStyle)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPrisonerStatus) + .addComponent(comboPrisonerStatus)) + .addComponent(chkPrisonerBabyStatus) + .addComponent(chkAtBPrisonerDefection) + .addComponent(chkAtBPrisonerRansom)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblPrisonerCaptureStyle) + .addComponent(comboPrisonerCaptureStyle) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblPrisonerStatus) + .addComponent(comboPrisonerStatus) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkPrisonerBabyStatus) + .addComponent(chkAtBPrisonerDefection) + .addComponent(chkAtBPrisonerRansom)); + + // Create Parent Panel and return + return createParentPanel(panel, "PrisonersPanel"); + } + + /** + * Creates a panel with checkboxes for setting dependent options. + * + * @return a {@link JPanel} containing checkboxes for setting dependent options + */ + private JPanel createDependentsPanel() { + // Contents + chkUseRandomDependentAddition = createCheckBox("UseRandomDependentAddition", null); + chkUseRandomDependentRemoval = createCheckBox("UseRandomDependentRemoval", null); + + // Layout the Panel + final JPanel panel = createStandardPanel("DependentsPanel", true, ""); + panel.setBorder(BorderFactory.createTitledBorder(resources.getString("DependentsPanel.title"))); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(chkUseRandomDependentAddition) + .addComponent(chkUseRandomDependentRemoval)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(chkUseRandomDependentAddition) + .addComponent(chkUseRandomDependentRemoval)); + + // Create Parent Panel and return + return createParentPanel(panel, "DependentsPanel"); + } } From 77d885a64134dc4ac18d0c82695c374af04c9adc Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 8 Oct 2024 14:27:52 -0500 Subject: [PATCH 027/117] Implement comprehensive Personnel Tab features Added multiple sub-tabs within the Personnel Tab to streamline various functionalities including general information, logs, awards, medical, prisoners, dependents, and salaries. Updated tooltips and configured new UI elements with appropriate settings for improved user experience. This structure enhances the management and display of essential personnel data. --- .../NEWCampaignOptionsDialog.properties | 142 +++++++- .../tabs/CampaignOptionsPane.java | 34 +- .../tabs/CampaignOptionsUtilities.java | 4 + .../campaignOptions/tabs/PersonnelTab.java | 316 ++++++++++++++++-- 4 files changed, 457 insertions(+), 39 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 87a01d2ff5..2b15b3e664 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -227,6 +227,49 @@ lblUseAmmoByTypeBox.text=Use Ammo Cross-Weapon Compatibility lblUseAmmoByTypeBox.tooltip=PLACEHOLDER ## Personnel Tab +personnelContentTabs.title=Personnel +generalTab.title=General +generalTab.border="You can replace a mech.\ +
You can't replace a veteran pilot.\ +
Personnel are your most valuable asset, even when they come with attitude."\ +
- Major Helena "Steelheart" Graves, Valiant Shields + +personnelLogsTab.title=Personnel Logs +personnelLogsTab.border="You think piloting a 'mek is stressful?\ +
Try keeping a personnel log for a lance full of trigger-happy maniacs."\ +
- Sergeant Dana "Firestorm" Watts, Broken Sword Regiment + +personnelInformationTab.title=Personnel Information +personnelInformationTab.border="Every log entry isn't just data - it's the history of our survival, our victories, and our failures.\ +
Keep them well, because one day they'll save us again."\ +
- Sergeant Vic "Crash" Helman, Ironclad Hawks + +administratorsTab.title=Administrators +administratorsTab.border="Administrators don't need medals.\ +
They just need enough coffee to survive the paperwork."\ +
- Sergeant Bobby "Scrapheap" Martinez, Steel Raptor Battalion + +awardsTab.title=Awards +awardsTab.border="An award is just metal and ribbon,\ +
but the courage it represents is what keeps us fighting when everything else says we should fall."\ +
- Lieutenant Marcus "Viper" Hayes, Storm Bear Company + +prisonersAndDependentsTab.title=Prisoners & Dependents +prisonersAndDependentsTab.border="The strength of a MekWarrior isn't just in the battlefield\ +
- it's in how we protect those who can't fight for themselves.\ +
Dependents are the reason we fight, not the burden."\ +
- Major Trina "Stormrider" Valdez, Crimson Flame Division + +medicalTab.title=Medical +medicalTab.border="You know it's a bad day when the medbay looks like the hangar bay\ +
- bodies and mechs, both in for repairs."\ +
- Sergeant Alex "Stitches" Boyd, Ironclad Lancers + +salariesTab.title=Salaries +salariesTab.border="A pilot's salary pays for more than just a mech\ +
- it pays for loyalty, and that's the one thing you can't afford to lose."\ +
-Captain Valen "Hardline" Pierce, Black Talon Mercs + # createGeneralTab lblGeneralTab.text=General Options lblGeneralTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ @@ -257,7 +300,7 @@ lblUseAlternativeQualityAveraging.text=Use Higher-Precision Skill Averaging lblUseAlternativeQualityAveraging.tooltip=PLACEHOLDER # createPersonnelCleanUpPanel -PersonnelCleanUpPanel.title=Personnel Cleanup +lblPersonnelCleanUpPanel.text=Personnel Cleanup lblUsePersonnelRemoval.text=Enable Personnel Cleanup lblUsePersonnelRemoval.tooltip=PLACEHOLDER lblUseRemovalExemptCemetery.text=Exempt Dead Personnel @@ -290,6 +333,29 @@ lblDisplayScenarioLog.tooltip=PLACEHOLDER lblDisplayKillRecord.text=Expand Kill Log by Default lblDisplayKillRecord.tooltip=PLACEHOLDER +# createPersonnelInformationTab +lblPersonnelInformation.text=Personnel Information Options +lblPersonnelInformationBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblUseTimeInService.text=Track Time in Service +lblUseTimeInService.tooltip=PLACEHOLDER +lblTimeInServiceDisplayFormat.text=Display Time in Service +lblTimeInServiceDisplayFormat.tooltip=PLACEHOLDER +lblUseTimeInRank.text=Track Time in Rank +lblUseTimeInRank.tooltip=PLACEHOLDER +lblTimeInRankDisplayFormat.text=Display Time in Rank +lblTimeInRankDisplayFormat.tooltip=PLACEHOLDER +lblTrackTotalEarnings.text=Track Total Earnings +lblTrackTotalEarnings.tooltip=PLACEHOLDER +lblTrackTotalXPEarnings.text=Display Total Earnings +lblTrackTotalXPEarnings.tooltip=PLACEHOLDER +lblShowOriginFaction.text=Display Origin Faction +lblShowOriginFaction.tooltip=PLACEHOLDER + # createAdministratorsTab lblAdministratorsTab.text=Administrator Options lblAdministratorsTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ @@ -331,7 +397,7 @@ lblAwardSetFilterList.text=Award Set Filter lblAwardSetFilterList.tooltip=PLACEHOLDER # createAutoAwardsFilterPanel -autoAwardsFilterPanel.title=autoAwards Award Tracking +lblAutoAwardsFilterPanel.text=Award Tracking lblEnableContractAwards.text=Contract lblEnableContractAwards.tooltip=PLACEHOLDER lblEnableFactionHunterAwards.text=Faction Hunter @@ -367,10 +433,10 @@ lblPrisonersAndDependentsTabBody.text=Lorem ipsum odor amet, consectetuer adipis \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam # createPrisonersPanel -PrisonersPanel.title=Prisoners -lblPrisonerCaptureStyle.text=Capture Style +lblPrisonersPanel.text=Prisoners +lblPrisonerCaptureStyle.text=Capture Style lblPrisonerCaptureStyle.tooltip=PLACEHOLDER -lblPrisonerStatus.text=Default Status +lblPrisonerStatus.text=Default Status lblPrisonerStatus.tooltip=PLACEHOLDER lblPrisonerBabyStatus.text=Prisoner Babies Share Mother's Status lblPrisonerBabyStatus.tooltip=PLACEHOLDER @@ -380,8 +446,68 @@ lblAtBPrisonerRansom.text=Enable Prisoner Ransoms lblAtBPrisonerRansom.tooltip=PLACEHOLDER # createDependentsPanel -DependentsPanel.title=Dependents -lblUseRandomDependentAddition.text= +lblDependentsPanel.text=Dependents +lblUseRandomDependentAddition.text=Random Addition lblUseRandomDependentAddition.tooltip=PLACEHOLDER -lblUseRandomDependentRemoval.text= +lblUseRandomDependentRemoval.text=Random Removal lblUseRandomDependentRemoval.tooltip=PLACEHOLDER + +# createMedicalTab +lblMedicalTab.text=Medical Options +lblMedicalTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblUseAdvancedMedical.text=Use Advanced Medical +lblUseAdvancedMedical.tooltip=PLACEHOLDER +lblHealWaitingPeriod.text=Days Between Healing Checks +lblHealWaitingPeriod.tooltip=PLACEHOLDER +lblNaturalHealWaitingPeriod.text=Days Between Natural Healing Checks +lblNaturalHealWaitingPeriod.tooltip=PLACEHOLDER +lblMinimumHitsForVehicles.text=Minimum Number of Hits for Vehicle Crew +lblMinimumHitsForVehicles.tooltip=PLACEHOLDER +lblUseRandomHitsForVehicles.text=Randomized Vehicle Crew Hits +lblUseRandomHitsForVehicles.tooltip=PLACEHOLDER +lblUseTougherHealing.text=Use Tougher Healing +lblUseTougherHealing.tooltip=PLACEHOLDER +lblMaximumPatients.text=Beds per Doctor +lblMaximumPatients.tooltip=PLACEHOLDER + +# createSalariesTab +lblSalariesTab.text=Salary Options +lblSalariesTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblDisableSecondaryRoleSalary.text=Disable Secondary Role Salaries +lblDisableSecondaryRoleSalary.tooltip=PLACEHOLDER + +# createSalaryMultipliersPanel +lblSalaryMultipliersPanel.text=Role Multipliers +lblAntiMekSalary.text=Anti-Mek +lblAntiMekSalary.tooltip=PLACEHOLDER +lblSpecialistInfantrySalary.text=Specialist Infantry +lblSpecialistInfantrySalary.tooltip=PLACEHOLDER + +#createExperienceMultipliersPanel +lblExperienceMultipliersPanel.text=Experience Multipliers +lblSkillLevelNone.text=None +lblSkillLevelNone.tooltip=PLACEHOLDER +lblSkillLevelUltra-Green.text=Ultra-Green +lblSkillLevelUltra-Green.tooltip=PLACEHOLDER +lblSkillLevelGreen.text=Green +lblSkillLevelGreen.tooltip=PLACEHOLDER +lblSkillLevelRegular.text=Regular +lblSkillLevelRegular.tooltip=PLACEHOLDER +lblSkillLevelVeteran.text=Veteran +lblSkillLevelVeteran.tooltip=PLACEHOLDER +lblSkillLevelElite.text=Elite +lblSkillLevelElite.tooltip=PLACEHOLDER +lblSkillLevelHeroic.text=Heroic +lblSkillLevelHeroic.tooltip=PLACEHOLDER +lblSkillLevelLegendary.text=Legendary +lblSkillLevelLegendary.tooltip=PLACEHOLDER \ No newline at end of file diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 00a3e1aa9a..65312238b7 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -104,15 +104,34 @@ private JTabbedPane createCombatReadinessParentTab() { } private JTabbedPane createHumanResourcesParentTab() { - // Personnel - // Life Paths - // Turnover and Retention - // Name and Portrait Generation - // Rank Systems - // Parent Tab JTabbedPane humanResourcesParentTab = new JTabbedPane(); + // Personnel + PersonnelTab personnelTab = new PersonnelTab(getFrame(), "personnelTab"); + + JTabbedPane personnelContentTabs = createSubTabs(Map.of( + "generalTab", personnelTab.createGeneralTab(), + "personnelLogsTab", personnelTab.createPersonnelLogsTab(), + "personnelInformationTab", personnelTab.createPersonnelInformationTab(), + "administratorsTab", personnelTab.createAdministratorsTab(), + "awardsTab", personnelTab.createAwardsTab(), + "prisonersAndDependentsTab", personnelTab.createPrisonersAndDependentsTab(), + "medicalTab", personnelTab.createMedicalTab(), + "salariesTab", personnelTab.createSalariesTab())); + + // Life Paths + // Turnover and Retention + // Name and Portrait Generation + // Rank Systems + + // Add Tabs + humanResourcesParentTab.addTab(String.format("%s", 4, + resources.getString("personnelContentTabs.title")), personnelContentTabs); + + addTab(String.format("%s", 4, + resources.getString("humanResourcesParentTab.title")), humanResourcesParentTab); + return humanResourcesParentTab; } @@ -145,9 +164,6 @@ private JTabbedPane createLogisticsAndMaintenanceParentTab() { "repairTab", repairAndMaintenanceTab.createRepairTab(), "maintenanceTab", repairAndMaintenanceTab.createMaintenanceTab())); - logisticsAndMaintenanceParentTab.addTab(String.format("%s", 4, - resources.getString("repairAndMaintenanceContentTabs.title")), repairAndMaintenanceContentTabs); - // Supplies and Acquisition SuppliesAndAcquisitionTab suppliesAndAcquisitionTab = new SuppliesAndAcquisitionTab(getFrame(), "suppliesAndAcquisitionTab"); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index 583e0eb9b6..7b58c92daf 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -45,6 +45,10 @@ static JCheckBox createCheckBox(String name, @Nullable Integer customWrapSize) { checkBox.setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), customWrapSize)); checkBox.setName("chk" + name); + Dimension size = checkBox.getPreferredSize(); + checkBox.setMaximumSize(size); + checkBox.setMinimumSize(size); + return checkBox; } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java index 8f0b108323..f030b0b040 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java @@ -1,6 +1,8 @@ package mekhq.gui.panes.campaignOptions.tabs; import megamek.client.ui.baseComponents.MMComboBox; +import megamek.common.enums.SkillLevel; +import mekhq.campaign.personnel.Skills; import mekhq.campaign.personnel.enums.AwardBonus; import mekhq.campaign.personnel.enums.PrisonerCaptureStyle; import mekhq.campaign.personnel.enums.PrisonerStatus; @@ -9,6 +11,8 @@ import javax.swing.*; import javax.swing.GroupLayout.Alignment; import java.awt.*; +import java.util.HashMap; +import java.util.Map; import static megamek.client.ui.WrapLayout.wordWrap; import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; @@ -93,6 +97,17 @@ public class PersonnelTab { //end Awards Tab //start Medical Tab + private JCheckBox chkUseAdvancedMedical; + private JLabel lblHealWaitingPeriod; + private JSpinner spnHealWaitingPeriod; + private JLabel lblNaturalHealWaitingPeriod; + private JSpinner spnNaturalHealWaitingPeriod; + private JLabel lblMinimumHitsForVehicles; + private JSpinner spnMinimumHitsForVehicles; + private JCheckBox chkUseRandomHitsForVehicles; + private JCheckBox chkUseTougherHealing; + private JLabel lblMaximumPatients; + private JSpinner spnMaximumPatients; //end Medical Tab //start Prisoners & Dependents Tab @@ -111,12 +126,23 @@ public class PersonnelTab { //end Prisoners & Dependents Tab //start Salaries Tab + private JCheckBox chkDisableSecondaryRoleSalary; + + private JPanel pnlSalaryMultipliersPanel; + private JLabel lblAntiMekSalary; + private JSpinner spnAntiMekSalary; + private JLabel lblSpecialistInfantrySalary; + private JSpinner spnSpecialistInfantrySalary; + + private JPanel pnlSalaryExperienceMultipliersPanel; + private Map lblSalaryExperienceMultipliers; + private Map spnSalaryExperienceMultipliers; //end Salaries Tab /** * Represents a tab for repair and maintenance in an application. */ - private PersonnelTab(JFrame frame, String name) { + PersonnelTab(JFrame frame, String name) { this.frame = frame; this.name = name; @@ -206,6 +232,22 @@ protected void initialize() { //end Awards Tab //start Medical Tab + chkUseAdvancedMedical = new JCheckBox(); + + lblHealWaitingPeriod = new JLabel(); + spnHealWaitingPeriod = new JSpinner(); + + lblNaturalHealWaitingPeriod = new JLabel(); + spnNaturalHealWaitingPeriod = new JSpinner(); + + lblMinimumHitsForVehicles = new JLabel(); + spnMinimumHitsForVehicles = new JSpinner(); + + chkUseRandomHitsForVehicles = new JCheckBox(); + chkUseTougherHealing = new JCheckBox(); + + lblMaximumPatients = new JLabel(); + spnMaximumPatients = new JSpinner(); //end Medical Tab //start Prisoners & Dependents Tab @@ -228,6 +270,19 @@ protected void initialize() { //end Prisoners & Dependents Tab //start Salaries Tab + chkDisableSecondaryRoleSalary = new JCheckBox(); + + pnlSalaryMultipliersPanel = new JPanel(); + + lblAntiMekSalary = new JLabel(); + spnAntiMekSalary = new JSpinner(); + + lblSpecialistInfantrySalary = new JLabel(); + spnSpecialistInfantrySalary = new JSpinner(); + + pnlSalaryExperienceMultipliersPanel = new JPanel(); + lblSalaryExperienceMultipliers = new HashMap<>(); + spnSalaryExperienceMultipliers = new HashMap<>(); //end Salaries Tab } @@ -244,7 +299,7 @@ private DefaultComboBoxModel getPrisonerStatusOptions() { return prisonerStatusModel; } - private JPanel createGeneralTab() { + JPanel createGeneralTab() { // Header JPanel headerPanel = createHeaderPanel("GeneralTab", getImageDirectory() + "logo_circinus_federation.png", @@ -318,8 +373,8 @@ private JPanel createPersonnelCleanUpPanel() { chkUseRemovalExemptRetirees = createCheckBox("UseRemovalExemptRetirees", null); // Layout the Panel - final JPanel panel = createStandardPanel("PersonnelCleanUpPanel", true, ""); - panel.setBorder(BorderFactory.createTitledBorder(resources.getString("PersonnelCleanUpPanel.title"))); + final JPanel panel = createStandardPanel("PersonnelCleanUpPanel", true, + "PersonnelCleanUpPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -339,7 +394,7 @@ private JPanel createPersonnelCleanUpPanel() { return createParentPanel(panel, "PersonnelCleanUpPanel"); } - private JPanel createPersonnelLogsTab() { + JPanel createPersonnelLogsTab() { // Header JPanel headerPanel = createHeaderPanel("PersonnelLogsTab", getImageDirectory() + "logo_clan_coyote.png", @@ -388,7 +443,7 @@ private JPanel createPersonnelLogsTab() { return createParentPanel(panel, "PersonnelLogsTab"); } - private JPanel createPersonnelInformationTab() { + JPanel createPersonnelInformationTab() { // Header JPanel headerPanel = createHeaderPanel("PersonnelInformation", getImageDirectory() + "logo_comstar.png", @@ -444,7 +499,7 @@ private JPanel createPersonnelInformationTab() { return createParentPanel(panel, "PersonnelInformation"); } - private JPanel createAdministratorsTab() { + JPanel createAdministratorsTab() { // Header JPanel headerPanel = createHeaderPanel("AdministratorsTab", getImageDirectory() + "logo_clan_diamond_sharks.png", @@ -481,7 +536,7 @@ private JPanel createAdministratorsTab() { return createParentPanel(panel, "AdministratorsTab"); } - private JPanel createAwardsTab() { + JPanel createAwardsTab() { // Header JPanel headerPanel = createHeaderPanel("AwardsTab", getImageDirectory() + "logo_draconis_combine.png", @@ -502,7 +557,7 @@ public Component getListCellRendererComponent(final JList list, final Object } }); - lblAwardTierSize = createLabel("", null); + lblAwardTierSize = createLabel("AwardTierSize", null); spnAwardTierSize = createSpinner("AwardTierSize", null, 5, 1, 100, 1); @@ -521,7 +576,7 @@ public Component getListCellRendererComponent(final JList list, final Object txtAwardSetFilterList.setLineWrap(true); txtAwardSetFilterList.setWrapStyleWord(true); txtAwardSetFilterList.setToolTipText( - wordWrap(resources.getString("lblAwardSetFilterList.toolTipText"))); + wordWrap(resources.getString("lblAwardSetFilterList.tooltip"))); txtAwardSetFilterList.setName("txtAwardSetFilterList"); txtAwardSetFilterList.setText(""); JScrollPane scrollAwardSetFilterList = new JScrollPane(txtAwardSetFilterList); @@ -600,8 +655,7 @@ private JPanel createAutoAwardsFilterPanel() { chkEnableMiscAwards = createCheckBox("EnableMiscAwards", null); // Layout the Panel - final JPanel panel = createStandardPanel("AutoAwardsFilterPanel", true, ""); - panel.setBorder(BorderFactory.createTitledBorder(resources.getString("autoAwardsFilterPanel.title"))); + final JPanel panel = createStandardPanel("AutoAwardsFilterPanel", true, "AutoAwardsFilterPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -641,11 +695,10 @@ private JPanel createAutoAwardsFilterPanel() { .addComponent(chkEnableTrainingAwards) .addComponent(chkEnableMiscAwards))); - // Create Parent Panel and return - return createParentPanel(panel, "AutoAwardsFilterPanel"); + return panel; } - private JPanel createPrisonersAndDependentsTab() { + JPanel createPrisonersAndDependentsTab() { // Header JPanel headerPanel = createHeaderPanel("PrisonersAndDependentsTab", getImageDirectory() + "logo_clan_fire_mandrills.png", @@ -702,8 +755,7 @@ public Component getListCellRendererComponent(final JList list, final Object chkAtBPrisonerRansom = createCheckBox("AtBPrisonerRansom", null); // Layout the Panel - final JPanel panel = createStandardPanel("PrisonersPanel", true, ""); - panel.setBorder(BorderFactory.createTitledBorder(resources.getString("PrisonersPanel.title"))); + final JPanel panel = createStandardPanel("PrisonersPanel", true, "PrisonersPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -733,8 +785,7 @@ public Component getListCellRendererComponent(final JList list, final Object .addComponent(chkAtBPrisonerDefection) .addComponent(chkAtBPrisonerRansom)); - // Create Parent Panel and return - return createParentPanel(panel, "PrisonersPanel"); + return panel; } /** @@ -748,8 +799,7 @@ private JPanel createDependentsPanel() { chkUseRandomDependentRemoval = createCheckBox("UseRandomDependentRemoval", null); // Layout the Panel - final JPanel panel = createStandardPanel("DependentsPanel", true, ""); - panel.setBorder(BorderFactory.createTitledBorder(resources.getString("DependentsPanel.title"))); + final JPanel panel = createStandardPanel("DependentsPanel", true, "DependentsPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -763,7 +813,229 @@ private JPanel createDependentsPanel() { .addComponent(chkUseRandomDependentAddition) .addComponent(chkUseRandomDependentRemoval)); + return panel; + } + + JPanel createMedicalTab() { + // Header + JPanel headerPanel = createHeaderPanel("MedicalTab", + getImageDirectory() + "logo_duchy_of_tamarind_abbey.png", + false, "", true); + + // Contents + chkUseAdvancedMedical = createCheckBox("UseAdvancedMedical", null); + + lblHealWaitingPeriod = createLabel("HealWaitingPeriod", null); + spnHealWaitingPeriod = createSpinner("HealWaitingPeriod", null, + 1, 1, 30, 1); + + lblNaturalHealWaitingPeriod = createLabel("NaturalHealWaitingPeriod", null); + spnNaturalHealWaitingPeriod = createSpinner("NaturalHealWaitingPeriod", null, + 1, 1, 365, 1); + + lblMinimumHitsForVehicles = createLabel("MinimumHitsForVehicles", null); + spnMinimumHitsForVehicles = createSpinner("MinimumHitsForVehicles", null, + 1, 1, 5, 1); + + chkUseRandomHitsForVehicles = createCheckBox("UseRandomHitsForVehicles", null); + + chkUseTougherHealing = createCheckBox("UseTougherHealing", null); + + lblMaximumPatients = createLabel("MaximumPatients", null); + spnMaximumPatients = createSpinner("MaximumPatients", null, + 25, 1, 100, 1); + + // Layout the Panel + final JPanel panel = createStandardPanel("MedicalTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addComponent(chkUseAdvancedMedical) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblHealWaitingPeriod) + .addComponent(spnHealWaitingPeriod)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblNaturalHealWaitingPeriod) + .addComponent(spnNaturalHealWaitingPeriod)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblMinimumHitsForVehicles) + .addComponent(spnMinimumHitsForVehicles)) + .addComponent(chkUseRandomHitsForVehicles) + .addComponent(chkUseTougherHealing) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblMaximumPatients) + .addComponent(spnMaximumPatients))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel) + .addComponent(chkUseAdvancedMedical) + .addGroup(layout.createSequentialGroup() + .addComponent(lblHealWaitingPeriod) + .addComponent(spnHealWaitingPeriod) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblNaturalHealWaitingPeriod) + .addComponent(spnNaturalHealWaitingPeriod) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblMinimumHitsForVehicles) + .addComponent(spnMinimumHitsForVehicles) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkUseRandomHitsForVehicles) + .addComponent(chkUseTougherHealing) + .addGroup(layout.createSequentialGroup() + .addComponent(lblMaximumPatients) + .addComponent(spnMaximumPatients) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + // Create Parent Panel and return + return createParentPanel(panel, "MedicalTab"); + } + + JPanel createSalariesTab() { + // Header + JPanel headerPanel = createHeaderPanel("SalariesTab", + getImageDirectory() + "logo_clan_ghost_bear.png", + false, "", true); + + // Contents + chkDisableSecondaryRoleSalary = createCheckBox("DisableSecondaryRoleSalary", null); + pnlSalaryMultipliersPanel = createSalaryMultipliersPanel(); + pnlSalaryExperienceMultipliersPanel = createExperienceMultipliersPanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("SalariesTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addComponent(chkDisableSecondaryRoleSalary) + .addComponent(pnlSalaryMultipliersPanel) + .addComponent(pnlSalaryExperienceMultipliersPanel)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel) + .addComponent(chkDisableSecondaryRoleSalary) + .addComponent(pnlSalaryMultipliersPanel) + .addComponent(pnlSalaryExperienceMultipliersPanel)); + // Create Parent Panel and return - return createParentPanel(panel, "DependentsPanel"); + return createParentPanel(panel, "SalariesTab"); + } + + private JPanel createSalaryMultipliersPanel() { + // Contents + lblAntiMekSalary = createLabel("AntiMekSalary", null); + spnAntiMekSalary = createSpinner("AntiMekSalary", null, + 0, 0, 100, 0.05); + + lblSpecialistInfantrySalary = createLabel("SpecialistInfantrySalary", null); + spnSpecialistInfantrySalary = createSpinner("SpecialistInfantrySalary", null, + 0, 0, 100, 0.05); + + // Layout the Panel + final JPanel panel = createStandardPanel("SalaryMultipliersPanel", true, + "SalaryMultipliersPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblAntiMekSalary) + .addComponent(spnAntiMekSalary) + .addComponent(lblSpecialistInfantrySalary) + .addComponent(spnSpecialistInfantrySalary))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblAntiMekSalary) + .addComponent(spnAntiMekSalary) + .addComponent(lblSpecialistInfantrySalary) + .addComponent(spnSpecialistInfantrySalary) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + return panel; + } + + private JPanel createExperienceMultipliersPanel() { + // Contents + lblAntiMekSalary = createLabel("AntiMekSalary", null); + spnAntiMekSalary = createSpinner("AntiMekSalary", null, + 0, 0, 100, 0.05); + + lblSpecialistInfantrySalary = createLabel("SpecialistInfantrySalary", null); + spnSpecialistInfantrySalary = createSpinner("SpecialistInfantrySalary", null, + 0, 0, 100, 0.05); + + for (final SkillLevel skillLevel : Skills.SKILL_LEVELS) { + final JLabel label = createLabel("SkillLevel" + skillLevel.toString(), null); + lblSalaryExperienceMultipliers.put(skillLevel, label); + + final JSpinner spinner = createSpinner("SkillLevel" + skillLevel, null, + 0, 0, 10, 0.05); + spnSalaryExperienceMultipliers.put(skillLevel, spinner); + + } + + // Layout the Panel + final JPanel panel = createStandardPanel("ExperienceMultipliersPanel", true, + "ExperienceMultipliersPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.NONE)) + .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.NONE)) + .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.ULTRA_GREEN)) + .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.ULTRA_GREEN)) + .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.GREEN)) + .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.GREEN)) + .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.REGULAR)) + .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.REGULAR))) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.VETERAN)) + .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.VETERAN)) + .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.ELITE)) + .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.ELITE)) + .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.HEROIC)) + .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.HEROIC)) + .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.LEGENDARY)) + .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.LEGENDARY)))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.NONE)) + .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.NONE)) + .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.ULTRA_GREEN)) + .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.ULTRA_GREEN)) + .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.GREEN)) + .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.GREEN)) + .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.REGULAR)) + .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.REGULAR)) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.VETERAN)) + .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.VETERAN)) + .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.ELITE)) + .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.ELITE)) + .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.HEROIC)) + .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.HEROIC)) + .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.LEGENDARY)) + .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.LEGENDARY)) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + return panel; } } From ae1d24488c77f17f417725bc77fd72798dd96ba4 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 8 Oct 2024 14:40:32 -0500 Subject: [PATCH 028/117] Prioritize General Options Tab in Campaign Options Ensured that the 'generalTab' always appears first in the campaign options tabs. This change improves the user experience by making general options more accessible. The sorting logic was adjusted to handle this special case. --- .../campaignOptions/tabs/CampaignOptionsUtilities.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index 7b58c92daf..f6aaabe0e6 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -306,6 +306,12 @@ static JTabbedPane createSubTabs(Map panels) { List tabNames = new ArrayList<>(panels.keySet()); tabNames.sort(String.CASE_INSENSITIVE_ORDER); + // This is a special case handler to ensure 'general options' tabs always appear first + if (tabNames.contains("generalTab")) { + tabNames.remove("generalTab"); + tabNames.add(0, "generalTab"); + } + JTabbedPane tabbedPane = new JTabbedPane(); for (String tabName : tabNames) { From a0976811d62a4a8ed59c1b0e9e24af0f9490000f Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 8 Oct 2024 17:37:15 -0500 Subject: [PATCH 029/117] Add base salaries configuration to PersonnelTab Expanded PersonnelTab to include configuration for base salaries. Added labels and spinners for various personnel roles, and updated layout handling to dynamically accommodate the new elements. --- .../NEWCampaignOptionsDialog.properties | 65 ++++- .../tabs/CampaignOptionsUtilities.java | 5 +- .../campaignOptions/tabs/PersonnelTab.java | 268 ++++++++++++++---- 3 files changed, 276 insertions(+), 62 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 2b15b3e664..dc55411f27 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -493,7 +493,7 @@ lblAntiMekSalary.tooltip=PLACEHOLDER lblSpecialistInfantrySalary.text=Specialist Infantry lblSpecialistInfantrySalary.tooltip=PLACEHOLDER -#createExperienceMultipliersPanel +# createExperienceMultipliersPanel lblExperienceMultipliersPanel.text=Experience Multipliers lblSkillLevelNone.text=None lblSkillLevelNone.tooltip=PLACEHOLDER @@ -510,4 +510,65 @@ lblSkillLevelElite.tooltip=PLACEHOLDER lblSkillLevelHeroic.text=Heroic lblSkillLevelHeroic.tooltip=PLACEHOLDER lblSkillLevelLegendary.text=Legendary -lblSkillLevelLegendary.tooltip=PLACEHOLDER \ No newline at end of file +lblSkillLevelLegendary.tooltip=PLACEHOLDER + +# createBaseSalariesPanel +lblBaseSalariesPanel.text=Base Salaries +lblBaseSalaryMekWarrior.text=MekWarrior +lblBaseSalaryMekWarrior.tooltip=PLACEHOLDER +lblBaseSalaryLAMPilot.text=LAM Pilot +lblBaseSalaryLAMPilot.tooltip=PLACEHOLDER +lblBaseSalaryVehicleDriver.text=Vehicle Driver +lblBaseSalaryVehicleDriver.tooltip=PLACEHOLDER +lblBaseSalaryNavalDriver.text=Naval Driver +lblBaseSalaryNavalDriver.tooltip=PLACEHOLDER +lblBaseSalaryVTOLPilot.text=VTOL Pilot +lblBaseSalaryVTOLPilot.tooltip=PLACEHOLDER +lblBaseSalaryVehicleGunner.text=Vehicle Gunner +lblBaseSalaryVehicleGunner.tooltip=PLACEHOLDER +lblBaseSalaryVehicleCrewmember.text=Vehicle Crewmember +lblBaseSalaryVehicleCrewmember.tooltip=PLACEHOLDER +lblBaseSalaryAerospacePilot.text=Aerospace Pilot +lblBaseSalaryAerospacePilot.tooltip=PLACEHOLDER +lblBaseSalaryConventionalAircraftPilot.text=Conventional Aircraft Pilot +lblBaseSalaryConventionalAircraftPilot.tooltip=PLACEHOLDER +lblBaseSalaryProtoMekPilot.text=ProtoMek Pilot +lblBaseSalaryProtoMekPilot.tooltip=PLACEHOLDER +lblBaseSalaryBattleArmorPilot.text=Armor Pilot +lblBaseSalaryBattleArmorPilot.tooltip=PLACEHOLDER +lblBaseSalarySoldier.text=Soldier +lblBaseSalarySoldier.tooltip=PLACEHOLDER +lblBaseSalaryVesselPilot.text=Vessel Pilot +lblBaseSalaryVesselPilot.tooltip=PLACEHOLDER +lblBaseSalaryVesselGunner.text=Vessel Gunner +lblBaseSalaryVesselGunner.tooltip=PLACEHOLDER +lblBaseSalaryVesselCrewmember.text=Vessel Crewmember +lblBaseSalaryVesselCrewmember.tooltip=PLACEHOLDER +lblBaseSalaryHyperspaceNavigator.text=Hyperspace Navigator +lblBaseSalaryHyperspaceNavigator.tooltip=PLACEHOLDER +lblBaseSalaryMekTech.text=MekTech +lblBaseSalaryMekTech.tooltip=PLACEHOLDER +lblBaseSalaryMechanic.text=Mechanic +lblBaseSalaryMechanic.tooltip=PLACEHOLDER +lblBaseSalaryAerospaceTech.text=Aerospace Tech +lblBaseSalaryAerospaceTech.tooltip=PLACEHOLDER +lblBaseSalaryBattleArmorTech.text=Battle Armor Tech +lblBaseSalaryBattleArmorTech.tooltip=PLACEHOLDER +lblBaseSalaryAstech.text=Astech +lblBaseSalaryAstech.tooltip=PLACEHOLDER +lblBaseSalaryDoctor.text=Doctor +lblBaseSalaryDoctor.tooltip=PLACEHOLDER +lblBaseSalaryMedic.text=Medic +lblBaseSalaryMedic.tooltip=PLACEHOLDER +lblBaseSalaryAdmin/Command.text=Admin/Command +lblBaseSalaryAdmin/Command.tooltip=PLACEHOLDER +lblBaseSalaryAdmin/Logistical.text=Admin/Logistics +lblBaseSalaryAdmin/Logistical.tooltip=PLACEHOLDER +lblBaseSalaryAdmin/Transport.text=Admin/Transport +lblBaseSalaryAdmin/Transport.tooltip=PLACEHOLDER +lblBaseSalaryAdmin/HR.text=Admin/HR +lblBaseSalaryAdmin/HR.tooltip=PLACEHOLDER +lblBaseSalaryDependent.text=Dependent +lblBaseSalaryDependent.tooltip=PLACEHOLDER +lblBaseSalaryNone.text=None +lblBaseSalaryNone.tooltip=PLACEHOLDER \ No newline at end of file diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index f6aaabe0e6..01ffa98d08 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -67,9 +67,8 @@ static JCheckBox createCheckBox(String name, @Nullable Integer customWrapSize) { * @param stepSize The step size of the spinner * @return The created {@link JSpinner}. */ - static JSpinner createSpinner(String name, @Nullable Integer customWrapSize, - double defaultValue, double minimum, - double maximum, double stepSize) { + static JSpinner createSpinner(String name, @Nullable Integer customWrapSize, double defaultValue, + double minimum, double maximum, double stepSize) { customWrapSize = processWrapSize(customWrapSize); JSpinner jSpinner = new JSpinner(); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java index f030b0b040..a40b1b8b7e 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java @@ -3,13 +3,14 @@ import megamek.client.ui.baseComponents.MMComboBox; import megamek.common.enums.SkillLevel; import mekhq.campaign.personnel.Skills; -import mekhq.campaign.personnel.enums.AwardBonus; -import mekhq.campaign.personnel.enums.PrisonerCaptureStyle; -import mekhq.campaign.personnel.enums.PrisonerStatus; -import mekhq.campaign.personnel.enums.TimeInDisplayFormat; +import mekhq.campaign.personnel.enums.*; import javax.swing.*; import javax.swing.GroupLayout.Alignment; +import javax.swing.GroupLayout.Group; +import javax.swing.GroupLayout.ParallelGroup; +import javax.swing.GroupLayout.SequentialGroup; +import javax.swing.LayoutStyle.ComponentPlacement; import java.awt.*; import java.util.HashMap; import java.util.Map; @@ -17,6 +18,9 @@ import static megamek.client.ui.WrapLayout.wordWrap; import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; +/** + * Handles the Personnel tab of campaign options + */ public class PersonnelTab { JFrame frame; String name; @@ -137,6 +141,10 @@ public class PersonnelTab { private JPanel pnlSalaryExperienceMultipliersPanel; private Map lblSalaryExperienceMultipliers; private Map spnSalaryExperienceMultipliers; + + private JPanel pnlSalaryBaseSalaryPanel; + private JLabel[] lblBaseSalary; + private JSpinner[] spnBaseSalary; //end Salaries Tab /** @@ -149,6 +157,13 @@ public class PersonnelTab { initialize(); } + + /** + * This method initializes the various checkboxes, labels, spinners, combo boxes, panels, and + * other GUI components for different tabs. + * It sets up the components for the General Tab, Personnel Logs Tab, Personnel Information Tab, + * Administrators Tab, Awards Tab, Medical Tab, Prisoners & Dependents Tab, and the Salaries Tab. + */ protected void initialize() { //start General Tab chkUseTactics = new JCheckBox(); @@ -227,6 +242,7 @@ protected void initialize() { chkEnableTrainingAwards = new JCheckBox(); chkEnableMiscAwards = new JCheckBox(); + autoAwardsFilterPanel = new JPanel(); lblAwardSetFilterList = new JLabel(); txtAwardSetFilterList = new JTextArea(); //end Awards Tab @@ -283,6 +299,10 @@ protected void initialize() { pnlSalaryExperienceMultipliersPanel = new JPanel(); lblSalaryExperienceMultipliers = new HashMap<>(); spnSalaryExperienceMultipliers = new HashMap<>(); + + pnlSalaryBaseSalaryPanel = new JPanel(); + lblBaseSalary = new JLabel[29]; + spnBaseSalary = new JSpinner[29]; //end Salaries Tab } @@ -394,6 +414,11 @@ private JPanel createPersonnelCleanUpPanel() { return createParentPanel(panel, "PersonnelCleanUpPanel"); } + /** + * Creates a tab for managing personnel logs. + * + * @return a {@link JPanel} representing the Personnel Logs Tab panel + */ JPanel createPersonnelLogsTab() { // Header JPanel headerPanel = createHeaderPanel("PersonnelLogsTab", @@ -443,6 +468,11 @@ JPanel createPersonnelLogsTab() { return createParentPanel(panel, "PersonnelLogsTab"); } + /** + * Creates a panel for the Personnel Information Tab in the application. + * + * @return a {@link JPanel} representing the Personnel Information Tab panel + */ JPanel createPersonnelInformationTab() { // Header JPanel headerPanel = createHeaderPanel("PersonnelInformation", @@ -499,6 +529,14 @@ JPanel createPersonnelInformationTab() { return createParentPanel(panel, "PersonnelInformation"); } + /** + * Creates a panel for the Administrators Tab in the application. + *

+ * This method constructs the header panel and checkbox components for administrator settings + * including negotiation and scrounging options. + * + * @return a {@link JPanel} representing the Administrators Tab panel + */ JPanel createAdministratorsTab() { // Header JPanel headerPanel = createHeaderPanel("AdministratorsTab", @@ -536,6 +574,11 @@ JPanel createAdministratorsTab() { return createParentPanel(panel, "AdministratorsTab"); } + /** + * Creates the Awards Tab panel with various components like labels, checkboxes, and filter options. + * + * @return the {@link JPanel} representing the Awards Tab panel + */ JPanel createAwardsTab() { // Header JPanel headerPanel = createHeaderPanel("AwardsTab", @@ -698,6 +741,16 @@ private JPanel createAutoAwardsFilterPanel() { return panel; } + /** + * Creates a panel for configuring settings related to prisoners and dependents. + *

+ * This method constructs a panel with different components such as header, prisoners panel, and + * dependents panel. + * The layout is set up with the header on top followed by the prisoners and dependents panels + * side by side. + * + * @return a {@link JPanel} representing the prisoners and dependents configuration settings + */ JPanel createPrisonersAndDependentsTab() { // Header JPanel headerPanel = createHeaderPanel("PrisonersAndDependentsTab", @@ -709,7 +762,8 @@ JPanel createPrisonersAndDependentsTab() { dependentsPanel = createDependentsPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("PrisonersAndDependentsTab", true, ""); + final JPanel panel = createStandardPanel("PrisonersAndDependentsTab", true, + ""); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -732,6 +786,13 @@ JPanel createPrisonersAndDependentsTab() { return createParentPanel(panel, "PrisonersAndDependentsTab"); } + /** + * Creates a panel for configuring settings related to prisoners in the application. + *

+ * This method sets up various components such as prisoner capture style, status, and related checkboxes. + * + * @return a {@link JPanel} containing the prisoner configuration settings + */ private JPanel createPrisonersPanel() { // Contents lblPrisonerCaptureStyle = createLabel("PrisonerCaptureStyle", null); @@ -816,6 +877,11 @@ private JPanel createDependentsPanel() { return panel; } + /** + * Creates a panel for the Medical Tab in the application. + * + * @return a {@link JPanel} representing the Medical Tab containing settings for medical options. + */ JPanel createMedicalTab() { // Header JPanel headerPanel = createHeaderPanel("MedicalTab", @@ -896,6 +962,11 @@ JPanel createMedicalTab() { return createParentPanel(panel, "MedicalTab"); } + /** + * Creates a salary configuration tab for managing salary settings such as multipliers and base salaries. + * + * @return a {@link JPanel} representing the salary tab + */ JPanel createSalariesTab() { // Header JPanel headerPanel = createHeaderPanel("SalariesTab", @@ -906,6 +977,7 @@ JPanel createSalariesTab() { chkDisableSecondaryRoleSalary = createCheckBox("DisableSecondaryRoleSalary", null); pnlSalaryMultipliersPanel = createSalaryMultipliersPanel(); pnlSalaryExperienceMultipliersPanel = createExperienceMultipliersPanel(); + pnlSalaryBaseSalaryPanel = createBaseSalariesPanel(); // Layout the Panel final JPanel panel = createStandardPanel("SalariesTab", true, ""); @@ -917,19 +989,26 @@ JPanel createSalariesTab() { .addComponent(headerPanel) .addComponent(chkDisableSecondaryRoleSalary) .addComponent(pnlSalaryMultipliersPanel) - .addComponent(pnlSalaryExperienceMultipliersPanel)); + .addComponent(pnlSalaryExperienceMultipliersPanel) + .addComponent(pnlSalaryBaseSalaryPanel)); layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) .addComponent(headerPanel) .addComponent(chkDisableSecondaryRoleSalary) .addComponent(pnlSalaryMultipliersPanel) - .addComponent(pnlSalaryExperienceMultipliersPanel)); + .addComponent(pnlSalaryExperienceMultipliersPanel) + .addComponent(pnlSalaryBaseSalaryPanel)); // Create Parent Panel and return return createParentPanel(panel, "SalariesTab"); } + /** + * Creates a panel for configuring salary multipliers for different personnel roles. + * + * @return a {@link JPanel} containing the salary multipliers configuration panel + */ private JPanel createSalaryMultipliersPanel() { // Contents lblAntiMekSalary = createLabel("AntiMekSalary", null); @@ -966,16 +1045,17 @@ private JPanel createSalaryMultipliersPanel() { return panel; } + /** + * Creates a panel for configuring experience multipliers for different skill levels. + *

+ * This method dynamically generates labels and spinners for each skill level based on the values + * in the {@link SkillLevel} enum. + *

+ * + * @return a {@link JPanel} containing the experience multipliers configuration panel + */ private JPanel createExperienceMultipliersPanel() { // Contents - lblAntiMekSalary = createLabel("AntiMekSalary", null); - spnAntiMekSalary = createSpinner("AntiMekSalary", null, - 0, 0, 100, 0.05); - - lblSpecialistInfantrySalary = createLabel("SpecialistInfantrySalary", null); - spnSpecialistInfantrySalary = createSpinner("SpecialistInfantrySalary", null, - 0, 0, 100, 0.05); - for (final SkillLevel skillLevel : Skills.SKILL_LEVELS) { final JLabel label = createLabel("SkillLevel" + skillLevel.toString(), null); lblSalaryExperienceMultipliers.put(skillLevel, label); @@ -992,49 +1072,123 @@ private JPanel createExperienceMultipliersPanel() { final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.NONE)) - .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.NONE)) - .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.ULTRA_GREEN)) - .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.ULTRA_GREEN)) - .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.GREEN)) - .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.GREEN)) - .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.REGULAR)) - .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.REGULAR))) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.VETERAN)) - .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.VETERAN)) - .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.ELITE)) - .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.ELITE)) - .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.HEROIC)) - .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.HEROIC)) - .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.LEGENDARY)) - .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.LEGENDARY)))); + SkillLevel[] skillLevels = SkillLevel.values(); + int rows = 2; + int columns = 4; - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.NONE)) - .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.NONE)) - .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.ULTRA_GREEN)) - .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.ULTRA_GREEN)) - .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.GREEN)) - .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.GREEN)) - .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.REGULAR)) - .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.REGULAR)) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.VETERAN)) - .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.VETERAN)) - .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.ELITE)) - .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.ELITE)) - .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.HEROIC)) - .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.HEROIC)) - .addComponent(lblSalaryExperienceMultipliers.get(SkillLevel.LEGENDARY)) - .addComponent(spnSalaryExperienceMultipliers.get(SkillLevel.LEGENDARY)) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + SequentialGroup horizontalGroups = layout.createSequentialGroup(); + ParallelGroup[] verticalGroups = new ParallelGroup[rows]; + + for (int j = 0; j < rows; j++) { + verticalGroups[j] = layout.createParallelGroup(Alignment.BASELINE); + } + + for (int i = 0; i < columns; i++) { + ParallelGroup horizontalParallelGroup = layout.createParallelGroup(); + + for (int j = 0; j < rows; j++) { + int index = i * rows + j; + + SequentialGroup horizontalSequentialGroup = layout.createSequentialGroup(); + horizontalSequentialGroup.addComponent(lblSalaryExperienceMultipliers.get(skillLevels[index])); + horizontalSequentialGroup.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE); + horizontalSequentialGroup.addComponent(spnSalaryExperienceMultipliers.get(skillLevels[index])); + if (i != (columns - 1)) { + horizontalSequentialGroup.addGap(200); + } + + horizontalParallelGroup.addGroup(horizontalSequentialGroup); + verticalGroups[j].addComponent(lblSalaryExperienceMultipliers.get(skillLevels[index])); + verticalGroups[j].addComponent(spnSalaryExperienceMultipliers.get(skillLevels[index])); + } + + horizontalGroups.addGroup(horizontalParallelGroup); + } + + layout.setHorizontalGroup(horizontalGroups); + SequentialGroup verticalGroup = layout.createSequentialGroup(); + for (Group group: verticalGroups) { + verticalGroup.addGroup(group); + } + layout.setVerticalGroup(verticalGroup); + + return panel; + } + + /** + * Creates a panel for configuring base salaries for different personnel roles. + *

+ * This method dynamically generates labels and spinners for each personnel role + * based on the values in the PersonnelRole enum. + * + * @return a {@link JPanel} containing the base salaries configuration panel + */ + private JPanel createBaseSalariesPanel() { + // Contents + for (final PersonnelRole personnelRole : PersonnelRole.values()) { + String componentName = "BaseSalary" + personnelRole.toString(); + componentName = componentName.replaceAll(" ", ""); + + final JLabel label = createLabel(componentName, null); + + final JSpinner spinner = createSpinner(componentName, null, + 0.0, 0.0, 1000000, 10.0); + + // Component Tracking Assignment + lblBaseSalary[personnelRole.ordinal()] = label; + spnBaseSalary[personnelRole.ordinal()] = spinner; + } + + // Layout the Panel + final JPanel panel = createStandardPanel("BaseSalariesPanel", true, + "BaseSalariesPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + SequentialGroup mainHorizontalGroup = layout.createSequentialGroup(); + SequentialGroup mainVerticalGroup = layout.createSequentialGroup(); + + int columns = 3; + int rows = (int) Math.ceil((double) lblBaseSalary.length / columns); + + // Create an array to store ParallelGroups for each column + ParallelGroup[] columnGroups = new ParallelGroup[columns]; + for (int i = 0; i < columns; i++) { + columnGroups[i] = layout.createParallelGroup(); + } + + for (int j = 0; j < rows; j++) { + ParallelGroup verticalGroup = layout.createParallelGroup(Alignment.BASELINE); + + for (int i = 0; i < columns; i++) { + int index = i * rows + j; + + if (index < lblBaseSalary.length) { + // Create a SequentialGroup for the label and spinner + SequentialGroup horizontalSequentialGroup = layout.createSequentialGroup(); + + horizontalSequentialGroup.addComponent(lblBaseSalary[index]); + horizontalSequentialGroup.addPreferredGap(ComponentPlacement.RELATED, Short.MAX_VALUE, Short.MAX_VALUE); + horizontalSequentialGroup.addComponent(spnBaseSalary[index]); + if (i != (columns - 1)) { + horizontalSequentialGroup.addGap(100); + } + + // Add the SequentialGroup to the column's ParallelGroup + columnGroups[i].addGroup(horizontalSequentialGroup); + + verticalGroup.addComponent(lblBaseSalary[index]); + verticalGroup.addComponent(spnBaseSalary[index]); + } + } + mainVerticalGroup.addGroup(verticalGroup); + } + for (ParallelGroup columnGroup : columnGroups) { + mainHorizontalGroup.addGroup(columnGroup); + } + + layout.setHorizontalGroup(mainHorizontalGroup); + layout.setVerticalGroup(mainVerticalGroup); return panel; } From 4bb8702add62e0e8d2ed73c30b217c372adc797b Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 8 Oct 2024 17:43:19 -0500 Subject: [PATCH 030/117] Corrected PersonnelTab comments Replaced ampersand with "and" in "Prisoners & Dependents Tab" for clarity and consistency with the rest of the text. This improves readability and maintains a uniform style throughout the documentation. --- .../src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java index a40b1b8b7e..b5814842ff 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java @@ -162,7 +162,7 @@ public class PersonnelTab { * This method initializes the various checkboxes, labels, spinners, combo boxes, panels, and * other GUI components for different tabs. * It sets up the components for the General Tab, Personnel Logs Tab, Personnel Information Tab, - * Administrators Tab, Awards Tab, Medical Tab, Prisoners & Dependents Tab, and the Salaries Tab. + * Administrators Tab, Awards Tab, Medical Tab, Prisoners and Dependents Tab, and the Salaries Tab. */ protected void initialize() { //start General Tab From 99c55a94302731877b14baaefeff9eba435b3b4d Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 9 Oct 2024 12:52:15 -0500 Subject: [PATCH 031/117] Fix UI layout and header component references Updated the reference from imagePanel to headerPanel across multiple tabs to ensure consistent header naming conventions. Adjusted alignment for headerPanel components to CENTER for better UI consistency. Enhanced panel dimensions setup to improve layout appearance. Standardized label text formatting by removing HTML tags. --- .../NEWCampaignOptionsDialog.properties | 22 ++++---- .../tabs/CampaignOptionsUtilities.java | 53 +++++++++++++++---- .../campaignOptions/tabs/GeneralTab.java | 6 +-- .../campaignOptions/tabs/PersonnelTab.java | 52 +++++++++--------- .../tabs/RepairAndMaintenanceTab.java | 12 ++--- .../tabs/SuppliesAndAcquisitionTab.java | 6 +-- .../campaignOptions/tabs/TechLimitsTab.java | 2 +- 7 files changed, 94 insertions(+), 59 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index dc55411f27..dac614bcd1 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -290,7 +290,7 @@ lblUseArtillery.text=Use Artillery Skill lblUseArtillery.tooltip=PLACEHOLDER lblUseAbilities.text=Use Special Pilot Abilities (SPAs) lblUseAbilities.tooltip=PLACEHOLDER -lblUseEdge.text=use Edge +lblUseEdge.text=Use Edge lblUseEdge.tooltip=PLACEHOLDER lblUseSupportEdge.text=Support Personnel Use Edge lblUseSupportEdge.tooltip=PLACEHOLDER @@ -488,28 +488,28 @@ lblDisableSecondaryRoleSalary.tooltip=PLACEHOLDER # createSalaryMultipliersPanel lblSalaryMultipliersPanel.text=Role Multipliers -lblAntiMekSalary.text=Anti-Mek +lblAntiMekSalary.text=Anti-Mek lblAntiMekSalary.tooltip=PLACEHOLDER -lblSpecialistInfantrySalary.text=Specialist Infantry +lblSpecialistInfantrySalary.text=Specialist Infantry lblSpecialistInfantrySalary.tooltip=PLACEHOLDER # createExperienceMultipliersPanel lblExperienceMultipliersPanel.text=Experience Multipliers -lblSkillLevelNone.text=None +lblSkillLevelNone.text=None lblSkillLevelNone.tooltip=PLACEHOLDER -lblSkillLevelUltra-Green.text=Ultra-Green +lblSkillLevelUltra-Green.text=Ultra-Green lblSkillLevelUltra-Green.tooltip=PLACEHOLDER -lblSkillLevelGreen.text=Green +lblSkillLevelGreen.text=Green lblSkillLevelGreen.tooltip=PLACEHOLDER -lblSkillLevelRegular.text=Regular +lblSkillLevelRegular.text=Regular lblSkillLevelRegular.tooltip=PLACEHOLDER -lblSkillLevelVeteran.text=Veteran +lblSkillLevelVeteran.text=Veteran lblSkillLevelVeteran.tooltip=PLACEHOLDER -lblSkillLevelElite.text=Elite +lblSkillLevelElite.text=Elite lblSkillLevelElite.tooltip=PLACEHOLDER -lblSkillLevelHeroic.text=Heroic +lblSkillLevelHeroic.text=Heroic lblSkillLevelHeroic.tooltip=PLACEHOLDER -lblSkillLevelLegendary.text=Legendary +lblSkillLevelLegendary.text=Legendary lblSkillLevelLegendary.tooltip=PLACEHOLDER # createBaseSalariesPanel diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index 01ffa98d08..ecc6bdc517 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -179,6 +179,20 @@ static JPanel createStandardPanel(String name, boolean includeBorder, String bor panel.setName(name); + Dimension size = panel.getPreferredSize(); + int sizeHeight = size.height; + int sizeWidth = size.width; + for (Component component : panel.getComponents()) { + sizeHeight += component.getPreferredSize().height; + sizeWidth += component.getPreferredSize().width; + } + + if (sizeWidth < 500) { + sizeWidth = 500; + } + + panel.setMaximumSize(new Dimension(sizeWidth, sizeHeight)); + return panel; } @@ -217,6 +231,9 @@ static JPanel createHeaderPanel(String name, String imageAddress, boolean includ } final JPanel panel = createStandardPanel("pnl" + name + "HeaderPanel", includeBorder, borderTitle); + Dimension size = panel.getPreferredSize(); + panel.setPreferredSize(new Dimension(500, size.height)); + final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -260,21 +277,27 @@ static GroupLayout createStandardLayout(JPanel panel) { */ static JPanel createParentPanel(JPanel panel, String name) { // Create Panel - final JPanel parentPanel = createStandardPanel(name, true, ""); + final JPanel parentPanel = createStandardPanel(name, false, ""); final GroupLayout parentLayout = createStandardLayout(parentPanel); // Set Dimensions - int widthNew = panel.getMinimumSize().width; + int widthNew = parentPanel.getMinimumSize().width; if (widthNew < 500) { widthNew = 500; } // I don't know why 1.25 works, it just does, and I've given up questioning it. - int height = (int) (panel.getPreferredSize().height * 1.25); + int height = parentPanel.getPreferredSize().height; + for (Component component : panel.getComponents()) { + if (component instanceof JPanel) { + height += component.getPreferredSize().height; + } + } + Dimension size = new Dimension(widthNew, height); - panel.setMinimumSize(size); - panel.setMaximumSize(size); + parentPanel.setMinimumSize(size); + parentPanel.setMaximumSize(size); // Layout parentPanel.setLayout(parentLayout); @@ -284,7 +307,7 @@ static JPanel createParentPanel(JPanel panel, String name) { .addComponent(panel)); parentLayout.setHorizontalGroup( - parentLayout.createParallelGroup(Alignment.LEADING) + parentLayout.createParallelGroup(Alignment.CENTER) .addComponent(panel)); return parentPanel; @@ -317,16 +340,26 @@ static JTabbedPane createSubTabs(Map panels) { JPanel mainPanel = panels.get(tabName); // Create a panel for the quote - JPanel quotePanel = new JPanel(); + JPanel quotePanel = new JPanel(new GridBagLayout()); JLabel quote = new JLabel(String.format("

%s
", resources.getString(tabName + ".border"))); - quotePanel.add(mainPanel); - quotePanel.add(quote); + + GridBagConstraints quoteConstraints = new GridBagConstraints(); + quoteConstraints.gridx = GridBagConstraints.RELATIVE; + quoteConstraints.gridy = GridBagConstraints.RELATIVE; + quotePanel.add(quote, quoteConstraints); + + // Create a BorderLayout panel for mainPanel + JPanel mainPanelHolder = new JPanel(new GridBagLayout()); + GridBagConstraints mainConstraints = new GridBagConstraints(); + mainConstraints.gridx = GridBagConstraints.RELATIVE; + mainConstraints.gridy = GridBagConstraints.RELATIVE; + mainPanelHolder.add(mainPanel, mainConstraints); // Reorganize mainPanel to include quotePanel at bottom JPanel contentPanel = new JPanel(new BorderLayout()); contentPanel.setName(tabName); - contentPanel.add(mainPanel, BorderLayout.CENTER); + contentPanel.add(mainPanelHolder, BorderLayout.CENTER); contentPanel.add(quotePanel, BorderLayout.SOUTH); // Create a wrapper panel for its easy alignment controls diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java index b2d2ce8fde..449d7f5f4e 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java @@ -80,7 +80,7 @@ public GeneralTab(Campaign campaign, JFrame frame, String name) { */ public AbstractMHQScrollablePanel createGeneralTab() { // Header - JPanel imagePanel = createGeneralHeader(); + JPanel headerPanel = createGeneralHeader(); // Campaign name lblName = createLabel("Name", null); @@ -137,7 +137,7 @@ public AbstractMHQScrollablePanel createGeneralTab() { layout.setVerticalGroup( layout.createSequentialGroup() - .addComponent(imagePanel) + .addComponent(headerPanel) .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(lblName) .addComponent(txtName) @@ -162,7 +162,7 @@ public AbstractMHQScrollablePanel createGeneralTab() { layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) - .addComponent(imagePanel) + .addComponent(headerPanel, Alignment.CENTER) .addGroup(layout.createSequentialGroup() .addComponent(lblName) .addComponent(txtName) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java index b5814842ff..c9a8118007 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java @@ -360,19 +360,21 @@ JPanel createGeneralTab() { .addComponent(personnelCleanUpPanel)); layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel) - .addComponent(chkUseTactics) - .addComponent(chkUseInitiativeBonus) - .addComponent(chkUseToughness) - .addComponent(chkUseRandomToughness) - .addComponent(chkUseArtillery) - .addComponent(chkUseAbilities) - .addComponent(chkUseEdge) - .addComponent(chkUseSupportEdge) - .addComponent(chkUseImplants) - .addComponent(chkUseAlternativeQualityAveraging) - .addComponent(personnelCleanUpPanel)); + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addComponent(chkUseTactics) + .addComponent(chkUseInitiativeBonus) + .addComponent(chkUseToughness) + .addComponent(chkUseRandomToughness) + .addComponent(chkUseArtillery) + .addComponent(chkUseAbilities) + .addComponent(chkUseEdge) + .addComponent(chkUseSupportEdge) + .addComponent(chkUseImplants) + .addComponent(chkUseAlternativeQualityAveraging) + .addComponent(personnelCleanUpPanel)) + ); // Create Parent Panel and return return createParentPanel(panel, "GeneralTab"); @@ -410,8 +412,7 @@ private JPanel createPersonnelCleanUpPanel() { .addComponent(chkUseRemovalExemptCemetery) .addComponent(chkUseRemovalExemptRetirees)); - // Create Parent Panel and return - return createParentPanel(panel, "PersonnelCleanUpPanel"); + return panel; } /** @@ -454,7 +455,7 @@ JPanel createPersonnelLogsTab() { layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel) + .addComponent(headerPanel, Alignment.CENTER) .addComponent(chkUseTransfers) .addComponent(chkUseExtendedTOEForceName) .addComponent(chkPersonnelLogSkillGain) @@ -462,7 +463,8 @@ JPanel createPersonnelLogsTab() { .addComponent(chkPersonnelLogEdgeGain) .addComponent(chkDisplayPersonnelLog) .addComponent(chkDisplayScenarioLog) - .addComponent(chkDisplayKillRecord)); + .addComponent(chkDisplayKillRecord) + ); // Create Parent Panel and return return createParentPanel(panel, "PersonnelLogsTab"); @@ -510,7 +512,7 @@ JPanel createPersonnelInformationTab() { layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel) + .addComponent(headerPanel, Alignment.CENTER) .addComponent(chkUseTimeInService) .addGroup(layout.createSequentialGroup() .addComponent(lblTimeInServiceDisplayFormat) @@ -564,7 +566,7 @@ JPanel createAdministratorsTab() { layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel) + .addComponent(headerPanel, Alignment.CENTER) .addComponent(chkAdminsHaveNegotiation) .addComponent(chkAdminExperienceLevelIncludeNegotiation) .addComponent(chkAdminsHaveScrounge) @@ -652,7 +654,7 @@ public Component getListCellRendererComponent(final JList list, final Object layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel) + .addComponent(headerPanel, Alignment.CENTER) .addGroup(layout.createSequentialGroup() .addComponent(lblAwardBonusStyle) .addComponent(comboAwardBonusStyle) @@ -776,7 +778,7 @@ JPanel createPrisonersAndDependentsTab() { layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel) + .addComponent(headerPanel, Alignment.CENTER) .addGroup(layout.createSequentialGroup() .addComponent(prisonerPanel) .addComponent(dependentsPanel) @@ -937,7 +939,7 @@ JPanel createMedicalTab() { layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel) + .addComponent(headerPanel, Alignment.CENTER) .addComponent(chkUseAdvancedMedical) .addGroup(layout.createSequentialGroup() .addComponent(lblHealWaitingPeriod) @@ -994,7 +996,7 @@ JPanel createSalariesTab() { layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel) + .addComponent(headerPanel, Alignment.CENTER) .addComponent(chkDisableSecondaryRoleSalary) .addComponent(pnlSalaryMultipliersPanel) .addComponent(pnlSalaryExperienceMultipliersPanel) @@ -1094,7 +1096,7 @@ private JPanel createExperienceMultipliersPanel() { horizontalSequentialGroup.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE); horizontalSequentialGroup.addComponent(spnSalaryExperienceMultipliers.get(skillLevels[index])); if (i != (columns - 1)) { - horizontalSequentialGroup.addGap(200); + horizontalSequentialGroup.addGap(10); } horizontalParallelGroup.addGroup(horizontalSequentialGroup); @@ -1171,7 +1173,7 @@ private JPanel createBaseSalariesPanel() { horizontalSequentialGroup.addPreferredGap(ComponentPlacement.RELATED, Short.MAX_VALUE, Short.MAX_VALUE); horizontalSequentialGroup.addComponent(spnBaseSalary[index]); if (i != (columns - 1)) { - horizontalSequentialGroup.addGap(100); + horizontalSequentialGroup.addGap(10); } // Add the SequentialGroup to the column's ParallelGroup diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java index b9a3c34d59..e828cb354f 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java @@ -58,7 +58,7 @@ public RepairAndMaintenanceTab(JFrame frame, String name) { */ public JPanel createRepairTab() { // Header - JPanel imagePanel = createHeaderPanel("RepairTab", + JPanel headerPanel = createHeaderPanel("RepairTab", getImageDirectory() + "logo_aurigan_coalition.png", false, "", true); @@ -96,7 +96,7 @@ public JPanel createRepairTab() { layout.setVerticalGroup( layout.createSequentialGroup() - .addComponent(imagePanel) + .addComponent(headerPanel) .addComponent(useEraModsCheckBox) .addComponent(assignedTechFirstCheckBox) .addComponent(resetToFirstTechCheckBox) @@ -113,7 +113,7 @@ public JPanel createRepairTab() { layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) - .addComponent(imagePanel) + .addComponent(headerPanel, Alignment.CENTER) .addComponent(useEraModsCheckBox) .addComponent(assignedTechFirstCheckBox) .addComponent(resetToFirstTechCheckBox) @@ -141,7 +141,7 @@ public JPanel createRepairTab() { */ public JPanel createMaintenanceTab() { // Header - JPanel imagePanel = createHeaderPanel("MaintenanceTab", + JPanel headerPanel = createHeaderPanel("MaintenanceTab", getImageDirectory() + "logo_clan_blood_spirit.png", false, "", true); @@ -188,7 +188,7 @@ public JPanel createMaintenanceTab() { layout.setVerticalGroup( layout.createSequentialGroup() - .addComponent(imagePanel) + .addComponent(headerPanel) .addComponent(checkMaintenance) .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(lblMaintenanceDays) @@ -208,7 +208,7 @@ public JPanel createMaintenanceTab() { layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) - .addComponent(imagePanel) + .addComponent(headerPanel, Alignment.CENTER) .addComponent(checkMaintenance) .addGroup(layout.createSequentialGroup() .addComponent(lblMaintenanceDays) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java index ed86b02a72..d96f6b5076 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java @@ -145,7 +145,7 @@ public JPanel createAcquisitionTab() { layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel) + .addComponent(headerPanel, Alignment.CENTER) .addGroup(layout.createSequentialGroup() .addComponent(lblChoiceAcquireSkill) .addComponent(choiceAcquireSkill) @@ -197,7 +197,7 @@ public JPanel createPlanetaryAcquisitionTab() { layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel) + .addComponent(headerPanel, Alignment.CENTER) .addGroup(layout.createSequentialGroup() .addComponent(options) .addComponent(modifiers))); @@ -512,7 +512,7 @@ public JPanel createDeliveryTab() { layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel) + .addComponent(headerPanel, Alignment.CENTER) .addGroup(layout.createSequentialGroup() .addComponent(lblNDiceTransitTime) .addComponent(spnNDiceTransitTime) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java index a549523966..b824094842 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java @@ -98,7 +98,7 @@ JPanel createTechLimitsTab() { layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel) + .addComponent(headerPanel, Alignment.CENTER) .addComponent(limitByYearBox) .addComponent(disallowExtinctStuffBox) .addComponent(allowClanPurchasesBox) From 2b886194eff4a46b45b3c7e9930afb363190467c Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 9 Oct 2024 13:09:31 -0500 Subject: [PATCH 032/117] Refactored campaign options UI quotes for better readability. Condensed multi-line quotes into single lines in the properties file to improve consistency. Updated the UI code to enhance the layout and presentation of the quotes in the campaign options dialog. --- .../NEWCampaignOptionsDialog.properties | 53 +++++++++---------- .../tabs/CampaignOptionsUtilities.java | 4 +- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index dac614bcd1..6e07333abc 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -45,8 +45,7 @@ lblIcon.tooltip=PLACEHOLDER ## RepairAndMaintenanceTab repairAndMaintenanceContentTabs.title=Repairs and Maintenance repairTab.title=Repairs -repairTab.border="Sure, I can fix it.\ -
But next time, maybe don't play chicken with an Atlas."\ +repairTab.border="Sure, I can fix it. But next time, maybe don't play chicken with an Atlas."\
- Chief Tech Mara "Wrench" Kell, Black Hammer Company maintenanceTab.title=Maintenance maintenanceTab.border="I've yet to see a battle won by duct tape, but we've gotten pretty close."\ @@ -107,16 +106,16 @@ lblLogMaintenance.tooltip=PLACEHOLDER ## SuppliesAndAcquisitionTab suppliesAndAcquisitionTab.title=Supplies and Acquisition acquisitionTab.title=Acquisitions -acquisitionTab.border="It's not about what you need - it's about what you can get.\ -
In acquisitions, creativity beats C-Bills."\ +acquisitionTab.border="It's not about what you need - it's about what you can get. In acquisitions,\ + \ creativity beats C-Bills."\
- Quartermaster Jonas "Scrounger" Voss, Red Talon Mercenaries deliveryTab.title=Deliveries -deliveryTab.border="Every part I deliver is a promise that a mek will rise again.\ -
Speed is my weapon, and time is the enemy."\ +deliveryTab.border="Every part I deliver is a promise that a mek will rise again. Speed is my weapon,\ + \ and time is the enemy."\
- Captain Horace "Hot Wheels" Drake, Midnight Express planetaryAcquisitionTab.title=Planetary Acquisitions -planetaryAcquisitionTab.border="On a guerrilla contract, parts are as valuable as ammo.\ -
Get what you can, while you can, because tomorrow, it might be gone."\ +planetaryAcquisitionTab.border="On a guerrilla contract, parts are as valuable as ammo. Get what you\ + \ can, while you can, because tomorrow, it might be gone."\
- Lieutenant Jaxon "Jackpot" Hale, Horizon Raiders # createAcquisitionTab @@ -195,8 +194,8 @@ lblOutputLabel.tooltip=PLACEHOLDER ## Tech Limits Tab TechLimitsParentTab.title=Tech Limits -TechLimitsTab.border="In a universe where we fight with the ghosts of a golden age, technology is a reminder:\ -
we are bound by history, but not defined by it."\ +TechLimitsTab.border="In a universe where we fight with the ghosts of a golden age, technology is a\ + \ reminder: we are bound by history, but not defined by it."\
- Engineer Talia "Patch" Kessler, Stormhounds # createTechLimitsTab @@ -229,45 +228,43 @@ lblUseAmmoByTypeBox.tooltip=PLACEHOLDER ## Personnel Tab personnelContentTabs.title=Personnel generalTab.title=General -generalTab.border="You can replace a mech.\ -
You can't replace a veteran pilot.\ -
Personnel are your most valuable asset, even when they come with attitude."\ +generalTab.border="You can replace a mech. You can't replace a veteran pilot. Personnel are your most\ + \ valuable asset, even when they come with attitude."\
- Major Helena "Steelheart" Graves, Valiant Shields personnelLogsTab.title=Personnel Logs -personnelLogsTab.border="You think piloting a 'mek is stressful?\ -
Try keeping a personnel log for a lance full of trigger-happy maniacs."\ +personnelLogsTab.border="You think piloting a 'mek is stressful? Try keeping a personnel log for a\ + \ lance full of trigger-happy maniacs."\
- Sergeant Dana "Firestorm" Watts, Broken Sword Regiment personnelInformationTab.title=Personnel Information -personnelInformationTab.border="Every log entry isn't just data - it's the history of our survival, our victories, and our failures.\ -
Keep them well, because one day they'll save us again."\ +personnelInformationTab.border="Every log entry isn't just data - it's the history of our survival,\ + \ our victories, and our failures. Keep them well, because one day they'll save us again."\
- Sergeant Vic "Crash" Helman, Ironclad Hawks administratorsTab.title=Administrators -administratorsTab.border="Administrators don't need medals.\ -
They just need enough coffee to survive the paperwork."\ +administratorsTab.border="Administrators don't need medals. They just need enough coffee to survive\ + \ the paperwork."\
- Sergeant Bobby "Scrapheap" Martinez, Steel Raptor Battalion awardsTab.title=Awards -awardsTab.border="An award is just metal and ribbon,\ -
but the courage it represents is what keeps us fighting when everything else says we should fall."\ +awardsTab.border="An award is just metal and ribbon, but the courage it represents is what keeps us\ + \ fighting when everything else says we should fall."\
- Lieutenant Marcus "Viper" Hayes, Storm Bear Company prisonersAndDependentsTab.title=Prisoners & Dependents -prisonersAndDependentsTab.border="The strength of a MekWarrior isn't just in the battlefield\ -
- it's in how we protect those who can't fight for themselves.\ -
Dependents are the reason we fight, not the burden."\ +prisonersAndDependentsTab.border="The strength of a MekWarrior isn't just in the battlefield - it's\ + \ in how we protect those who can't fight for themselves. Dependents are the reason we fight, not the burden."\
- Major Trina "Stormrider" Valdez, Crimson Flame Division medicalTab.title=Medical -medicalTab.border="You know it's a bad day when the medbay looks like the hangar bay\ -
- bodies and mechs, both in for repairs."\ +medicalTab.border="You know it's a bad day when the medbay looks like the hangar bay - bodies and mechs,\ + \ both in for repairs."\
- Sergeant Alex "Stitches" Boyd, Ironclad Lancers salariesTab.title=Salaries -salariesTab.border="A pilot's salary pays for more than just a mech\ -
- it pays for loyalty, and that's the one thing you can't afford to lose."\ +salariesTab.border="A pilot's salary pays for more than just a mech - it pays for loyalty, and that's\ + \ the one thing you can't afford to lose."\
-Captain Valen "Hardline" Pierce, Black Talon Mercs # createGeneralTab diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index ecc6bdc517..8cee9b547b 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -341,7 +341,8 @@ static JTabbedPane createSubTabs(Map panels) { // Create a panel for the quote JPanel quotePanel = new JPanel(new GridBagLayout()); - JLabel quote = new JLabel(String.format("
%s
", + JLabel quote = new JLabel(String.format( + "
%s
", resources.getString(tabName + ".border"))); GridBagConstraints quoteConstraints = new GridBagConstraints(); @@ -360,6 +361,7 @@ static JTabbedPane createSubTabs(Map panels) { JPanel contentPanel = new JPanel(new BorderLayout()); contentPanel.setName(tabName); contentPanel.add(mainPanelHolder, BorderLayout.CENTER); + contentPanel.add(quotePanel, BorderLayout.SOUTH); // Create a wrapper panel for its easy alignment controls From 2bac6e8f10b855f290d6582b4899facafd32ff11 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 9 Oct 2024 15:29:51 -0500 Subject: [PATCH 033/117] Add Life Paths tab and enhance personnel tab in Campaign Options Renamed 'Personnel Tab' as 'Human Resources Tab' and included tooltips and checkboxes for various options. Added new Life Paths tab with General and Background sub-tabs, introducing options for random gender, family display, random personalities, and origins. --- .../NEWCampaignOptionsDialog.properties | 177 ++++++-- .../tabs/CampaignOptionsPane.java | 10 +- .../tabs/CampaignOptionsUtilities.java | 14 +- .../panes/campaignOptions/tabs/LifePaths.java | 4 - .../campaignOptions/tabs/LifePathsTab.java | 405 ++++++++++++++++++ .../campaignOptions/tabs/PersonnelTab.java | 6 +- 6 files changed, 558 insertions(+), 58 deletions(-) delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePaths.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 6e07333abc..98016e6dd3 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -225,10 +225,12 @@ lblVariableTechLevelBox.tooltip=PLACEHOLDER lblUseAmmoByTypeBox.text=Use Ammo Cross-Weapon Compatibility lblUseAmmoByTypeBox.tooltip=PLACEHOLDER -## Personnel Tab +## Human Resources Tab personnelContentTabs.title=Personnel -generalTab.title=General -generalTab.border="You can replace a mech. You can't replace a veteran pilot. Personnel are your most\ + +# Personnel Tab +personnelGeneralTab.title=General +personnelGeneralTab.border="You can replace a 'mek. You can't replace a veteran pilot. Personnel are your most\ \ valuable asset, even when they come with attitude."\
- Major Helena "Steelheart" Graves, Valiant Shields @@ -258,18 +260,18 @@ prisonersAndDependentsTab.border="The strength of a MekWarrior isn't just in the
- Major Trina "Stormrider" Valdez, Crimson Flame Division medicalTab.title=Medical -medicalTab.border="You know it's a bad day when the medbay looks like the hangar bay - bodies and mechs,\ +medicalTab.border="You know it's a bad day when the medbay looks like the hangar bay - bodies and 'meks,\ \ both in for repairs."\
- Sergeant Alex "Stitches" Boyd, Ironclad Lancers salariesTab.title=Salaries -salariesTab.border="A pilot's salary pays for more than just a mech - it pays for loyalty, and that's\ +salariesTab.border="A pilot's salary pays for more than just a 'mek - it pays for loyalty, and that's\ \ the one thing you can't afford to lose."\
-Captain Valen "Hardline" Pierce, Black Talon Mercs # createGeneralTab -lblGeneralTab.text=General Options -lblGeneralTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ +lblPersonnelGeneralTab.text=General Options +lblPersonnelGeneralTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ @@ -485,87 +487,168 @@ lblDisableSecondaryRoleSalary.tooltip=PLACEHOLDER # createSalaryMultipliersPanel lblSalaryMultipliersPanel.text=Role Multipliers -lblAntiMekSalary.text=Anti-Mek +lblAntiMekSalary.text=Anti-Mek lblAntiMekSalary.tooltip=PLACEHOLDER -lblSpecialistInfantrySalary.text=Specialist Infantry +lblSpecialistInfantrySalary.text=Specialist Infantry lblSpecialistInfantrySalary.tooltip=PLACEHOLDER # createExperienceMultipliersPanel lblExperienceMultipliersPanel.text=Experience Multipliers -lblSkillLevelNone.text=None +lblSkillLevelNone.text=None lblSkillLevelNone.tooltip=PLACEHOLDER -lblSkillLevelUltra-Green.text=Ultra-Green +lblSkillLevelUltra-Green.text=Ultra-Green lblSkillLevelUltra-Green.tooltip=PLACEHOLDER -lblSkillLevelGreen.text=Green +lblSkillLevelGreen.text=Green lblSkillLevelGreen.tooltip=PLACEHOLDER -lblSkillLevelRegular.text=Regular +lblSkillLevelRegular.text=Regular lblSkillLevelRegular.tooltip=PLACEHOLDER -lblSkillLevelVeteran.text=Veteran +lblSkillLevelVeteran.text=Veteran lblSkillLevelVeteran.tooltip=PLACEHOLDER -lblSkillLevelElite.text=Elite +lblSkillLevelElite.text=Elite lblSkillLevelElite.tooltip=PLACEHOLDER -lblSkillLevelHeroic.text=Heroic +lblSkillLevelHeroic.text=Heroic lblSkillLevelHeroic.tooltip=PLACEHOLDER -lblSkillLevelLegendary.text=Legendary +lblSkillLevelLegendary.text=Legendary lblSkillLevelLegendary.tooltip=PLACEHOLDER # createBaseSalariesPanel lblBaseSalariesPanel.text=Base Salaries -lblBaseSalaryMekWarrior.text=MekWarrior +lblBaseSalaryMekWarrior.text=MekWarrior lblBaseSalaryMekWarrior.tooltip=PLACEHOLDER -lblBaseSalaryLAMPilot.text=LAM Pilot +lblBaseSalaryLAMPilot.text=LAM Pilot lblBaseSalaryLAMPilot.tooltip=PLACEHOLDER -lblBaseSalaryVehicleDriver.text=Vehicle Driver +lblBaseSalaryVehicleDriver.text=Vehicle Driver lblBaseSalaryVehicleDriver.tooltip=PLACEHOLDER -lblBaseSalaryNavalDriver.text=Naval Driver +lblBaseSalaryNavalDriver.text=Naval Driver lblBaseSalaryNavalDriver.tooltip=PLACEHOLDER -lblBaseSalaryVTOLPilot.text=VTOL Pilot +lblBaseSalaryVTOLPilot.text=VTOL Pilot lblBaseSalaryVTOLPilot.tooltip=PLACEHOLDER -lblBaseSalaryVehicleGunner.text=Vehicle Gunner +lblBaseSalaryVehicleGunner.text=Vehicle Gunner lblBaseSalaryVehicleGunner.tooltip=PLACEHOLDER -lblBaseSalaryVehicleCrewmember.text=Vehicle Crewmember +lblBaseSalaryVehicleCrewmember.text=Vehicle Crewmember lblBaseSalaryVehicleCrewmember.tooltip=PLACEHOLDER -lblBaseSalaryAerospacePilot.text=Aerospace Pilot +lblBaseSalaryAerospacePilot.text=Aerospace Pilot lblBaseSalaryAerospacePilot.tooltip=PLACEHOLDER -lblBaseSalaryConventionalAircraftPilot.text=Conventional Aircraft Pilot +lblBaseSalaryConventionalAircraftPilot.text=Aircraft Pilot lblBaseSalaryConventionalAircraftPilot.tooltip=PLACEHOLDER -lblBaseSalaryProtoMekPilot.text=ProtoMek Pilot +lblBaseSalaryProtoMekPilot.text=ProtoMek Pilot lblBaseSalaryProtoMekPilot.tooltip=PLACEHOLDER -lblBaseSalaryBattleArmorPilot.text=Armor Pilot +lblBaseSalaryBattleArmorPilot.text=Armor Pilot lblBaseSalaryBattleArmorPilot.tooltip=PLACEHOLDER -lblBaseSalarySoldier.text=Soldier +lblBaseSalarySoldier.text=Soldier lblBaseSalarySoldier.tooltip=PLACEHOLDER -lblBaseSalaryVesselPilot.text=Vessel Pilot +lblBaseSalaryVesselPilot.text=Vessel Pilot lblBaseSalaryVesselPilot.tooltip=PLACEHOLDER -lblBaseSalaryVesselGunner.text=Vessel Gunner +lblBaseSalaryVesselGunner.text=Vessel Gunner lblBaseSalaryVesselGunner.tooltip=PLACEHOLDER -lblBaseSalaryVesselCrewmember.text=Vessel Crewmember +lblBaseSalaryVesselCrewmember.text=Vessel Crewmember lblBaseSalaryVesselCrewmember.tooltip=PLACEHOLDER -lblBaseSalaryHyperspaceNavigator.text=Hyperspace Navigator +lblBaseSalaryHyperspaceNavigator.text=Hyperspace Navigator lblBaseSalaryHyperspaceNavigator.tooltip=PLACEHOLDER -lblBaseSalaryMekTech.text=MekTech +lblBaseSalaryMekTech.text=MekTech lblBaseSalaryMekTech.tooltip=PLACEHOLDER -lblBaseSalaryMechanic.text=Mechanic +lblBaseSalaryMechanic.text=Mechanic lblBaseSalaryMechanic.tooltip=PLACEHOLDER -lblBaseSalaryAerospaceTech.text=Aerospace Tech +lblBaseSalaryAerospaceTech.text=Aerospace Tech lblBaseSalaryAerospaceTech.tooltip=PLACEHOLDER -lblBaseSalaryBattleArmorTech.text=Battle Armor Tech +lblBaseSalaryBattleArmorTech.text=Battle Armor Tech lblBaseSalaryBattleArmorTech.tooltip=PLACEHOLDER -lblBaseSalaryAstech.text=Astech +lblBaseSalaryAstech.text=Astech lblBaseSalaryAstech.tooltip=PLACEHOLDER -lblBaseSalaryDoctor.text=Doctor +lblBaseSalaryDoctor.text=Doctor lblBaseSalaryDoctor.tooltip=PLACEHOLDER -lblBaseSalaryMedic.text=Medic +lblBaseSalaryMedic.text=Medic lblBaseSalaryMedic.tooltip=PLACEHOLDER -lblBaseSalaryAdmin/Command.text=Admin/Command +lblBaseSalaryAdmin/Command.text=Admin/Command lblBaseSalaryAdmin/Command.tooltip=PLACEHOLDER -lblBaseSalaryAdmin/Logistical.text=Admin/Logistics +lblBaseSalaryAdmin/Logistical.text=Admin/Logistics lblBaseSalaryAdmin/Logistical.tooltip=PLACEHOLDER -lblBaseSalaryAdmin/Transport.text=Admin/Transport +lblBaseSalaryAdmin/Transport.text=Admin/Transport lblBaseSalaryAdmin/Transport.tooltip=PLACEHOLDER -lblBaseSalaryAdmin/HR.text=Admin/HR +lblBaseSalaryAdmin/HR.text=Admin/HR lblBaseSalaryAdmin/HR.tooltip=PLACEHOLDER -lblBaseSalaryDependent.text=Dependent +lblBaseSalaryDependent.text=Dependent lblBaseSalaryDependent.tooltip=PLACEHOLDER -lblBaseSalaryNone.text=None -lblBaseSalaryNone.tooltip=PLACEHOLDER \ No newline at end of file +lblBaseSalaryNone.text=None +lblBaseSalaryNone.tooltip=PLACEHOLDER + +# Life Paths Tab +lifePathsContentTabs.title=Life Paths + +lifePathsGeneralTab.title=General +lifePathsGeneralTab.border="Every MekWarrior starts somewhere different, but we all end up the same:\ + \ in the cockpit, staring down the impossible, and finding a way through."\ +
- Lieutenant Adam "Burnout" Keller, Blackthorn Marauders + +backgroundsTab.title=Backgrounds +backgroundsTab.border="From noble houses to street gangs, once you're in the cockpit, we're all the\ + \ same. Your past might shape you, but your future is yours to command."\ +
- Lieutenant Marcus "Ghost" Walker, Onyx Fang Company + +# createGeneralTab +lblLifePathsGeneralTab.text=General Options +lblLifePathsGeneralTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblUseDylansRandomXP.text=Use Random XP +lblUseDylansRandomXP.tooltip=PLACEHOLDER +lblGender.text=Percent Female +lblGender.tooltip=PLACEHOLDER +lblNonBinaryDiceSize.text=Non-Binary Personnel Chance: 1-in- +lblNonBinaryDiceSize.tooltip=PLACEHOLDER +lblFamilyDisplayLevel.text=Family Display Depth +lblFamilyDisplayLevel.tooltip=PLACEHOLDER + +# createAnniversariesPanel +lblAnniversariesPanel.text=Anniversaries +lblAnnounceBirthdays.text=Announce Birthdays +lblAnnounceBirthdays.tooltip=PLACEHOLDER +lblAnnounceRecruitmentAnniversaries.text=Announce Recruitment Anniversaries +lblAnnounceRecruitmentAnniversaries.tooltip=PLACEHOLDER +lblAnnounceOfficersOnly.text=Officers Only +lblAnnounceOfficersOnly.tooltip=PLACEHOLDER +lblAnnounceChildBirthdays.text=Always Announce 18th Birthdays +lblAnnounceChildBirthdays.tooltip=PLACEHOLDER + +# createBackgroundsTab +lblBackgroundsTab.text=Background Options +lblBackgroundsTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblUseRandomPersonalities.text=Assign Random Personalities +lblUseRandomPersonalities.tooltip=PLACEHOLDER +lblUseRandomPersonalityReputation.text=Personality Influences Reputation +lblUseRandomPersonalityReputation.tooltip=PLACEHOLDER +lblUseIntelligenceXpMultiplier.text=Intelligence Influences XP Costs +lblUseIntelligenceXpMultiplier.tooltip=PLACEHOLDER +lblUseSimulatedRelationships.text=Simulate Background Relationships +lblUseSimulatedRelationships.tooltip=PLACEHOLDER + +# createRandomOriginOptionsPanel +lblRandomOriginOptionsPanel.text=Origins +lblRandomizeOrigin.text=Randomize Origin +lblRandomizeOrigin.tooltip=PLACEHOLDER +lblRandomizeDependentsOrigin.text=Randomize Dependent Origins +lblRandomizeDependentsOrigin.tooltip=PLACEHOLDER +lblRandomizeAroundSpecifiedPlanet.text=Randomize Around Specific Planet +lblRandomizeAroundSpecifiedPlanet.tooltip=PLACEHOLDER +lblSpecifiedSystemFactionSpecific.text=Faction Specific +lblSpecifiedSystemFactionSpecific.tooltip=PLACEHOLDER +lblSpecifiedSystem.text=System +lblSpecifiedSystem.tooltip=PLACEHOLDER +lblSpecifiedPlanet.text=Planet +lblSpecifiedPlanet.tooltip=PLACEHOLDER +lblOriginSearchRadius.text=Random Origin Radius +lblOriginSearchRadius.tooltip=PLACEHOLDER +lblOriginDistanceScale.text=Distance Scale +lblOriginDistanceScale.tooltip=PLACEHOLDER +lblAllowClanOrigins.text=Allow Clan Origins +lblAllowClanOrigins.tooltip=PLACEHOLDER +lblExtraRandomOrigin.text=Extra Random Origins +lblExtraRandomOrigin.tooltip=PLACEHOLDER \ No newline at end of file diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 65312238b7..064ce81891 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -111,7 +111,7 @@ private JTabbedPane createHumanResourcesParentTab() { PersonnelTab personnelTab = new PersonnelTab(getFrame(), "personnelTab"); JTabbedPane personnelContentTabs = createSubTabs(Map.of( - "generalTab", personnelTab.createGeneralTab(), + "personnelGeneralTab", personnelTab.createGeneralTab(), "personnelLogsTab", personnelTab.createPersonnelLogsTab(), "personnelInformationTab", personnelTab.createPersonnelInformationTab(), "administratorsTab", personnelTab.createAdministratorsTab(), @@ -121,6 +121,12 @@ private JTabbedPane createHumanResourcesParentTab() { "salariesTab", personnelTab.createSalariesTab())); // Life Paths + LifePathsTab lifePathsTab = new LifePathsTab(campaign, getFrame(), "lifePathsTab"); + + JTabbedPane lifePathsContentTabs = createSubTabs(Map.of( + "lifePathsGeneralTab", lifePathsTab.createGeneralTab(), + "backgroundsTab", lifePathsTab.createBackgroundsTab())); + // Turnover and Retention // Name and Portrait Generation // Rank Systems @@ -128,6 +134,8 @@ private JTabbedPane createHumanResourcesParentTab() { // Add Tabs humanResourcesParentTab.addTab(String.format("%s", 4, resources.getString("personnelContentTabs.title")), personnelContentTabs); + humanResourcesParentTab.addTab(String.format("%s", 4, + resources.getString("lifePathsContentTabs.title")), lifePathsContentTabs); addTab(String.format("%s", 4, resources.getString("humanResourcesParentTab.title")), humanResourcesParentTab); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index 8cee9b547b..233970cf35 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -329,9 +329,17 @@ static JTabbedPane createSubTabs(Map panels) { tabNames.sort(String.CASE_INSENSITIVE_ORDER); // This is a special case handler to ensure 'general options' tabs always appear first - if (tabNames.contains("generalTab")) { - tabNames.remove("generalTab"); - tabNames.add(0, "generalTab"); + int indexToMoveToFront = -1; + for (int i=0; i comboFamilyDisplayLevel; + private JPanel pnlAnniversariesPanel; + private JCheckBox chkAnnounceOfficersOnly; + private JCheckBox chkAnnounceBirthdays; + private JCheckBox chkAnnounceChildBirthdays; + private JCheckBox chkAnnounceRecruitmentAnniversaries; + //end General Tab + + //start Backgrounds Tab + private JCheckBox chkUseRandomPersonalities; + private JCheckBox chkUseRandomPersonalityReputation; + private JCheckBox chkUseIntelligenceXpMultiplier; + private JCheckBox chkUseSimulatedRelationships; + private JPanel pnlRandomOriginOptions; + private JCheckBox chkRandomizeOrigin; + private JCheckBox chkRandomizeDependentsOrigin; + private JCheckBox chkRandomizeAroundSpecifiedPlanet; + private JCheckBox chkSpecifiedSystemFactionSpecific; + private JLabel lblSpecifiedSystem; + private MMComboBox comboSpecifiedSystem; + private JLabel lblSpecifiedPlanet; + private MMComboBox comboSpecifiedPlanet; + private JLabel lblOriginSearchRadius; + private JSpinner spnOriginSearchRadius; + private JLabel lblOriginDistanceScale; + private JSpinner spnOriginDistanceScale; + private JCheckBox chkAllowClanOrigins; + private JCheckBox chkExtraRandomOrigin; + //end Backgrounds Tab + + /** + * Represents a tab for repair and maintenance in an application. + */ + LifePathsTab(Campaign campaign, JFrame frame, String name) { + this.campaign = campaign; + this.frame = frame; + this.name = name; + + initialize(); + } + + protected void initialize() { + // General Tab + chkUseDylansRandomXP = new JCheckBox(); + lblGender = new JLabel(); + sldGender = new JSlider(); + lblNonBinaryDiceSize = new JLabel(); + spnNonBinaryDiceSize = new JSpinner(); + lblFamilyDisplayLevel = new JLabel(); + comboFamilyDisplayLevel = new MMComboBox<>("comboFamilyDisplayLevel", + FamilialRelationshipDisplayLevel.values()); + + pnlAnniversariesPanel = new JPanel(); + chkAnnounceOfficersOnly = new JCheckBox(); + chkAnnounceBirthdays = new JCheckBox(); + chkAnnounceChildBirthdays = new JCheckBox(); + chkAnnounceRecruitmentAnniversaries = new JCheckBox(); + + // Backgrounds Tab + chkUseRandomPersonalities = new JCheckBox(); + chkUseRandomPersonalityReputation = new JCheckBox(); + chkUseIntelligenceXpMultiplier = new JCheckBox(); + chkUseSimulatedRelationships = new JCheckBox(); + + pnlRandomOriginOptions = new JPanel(); + chkRandomizeOrigin = new JCheckBox(); + chkRandomizeDependentsOrigin = new JCheckBox(); + chkRandomizeAroundSpecifiedPlanet = new JCheckBox(); + chkSpecifiedSystemFactionSpecific = new JCheckBox(); + lblSpecifiedSystem = new JLabel(); + comboSpecifiedSystem = new MMComboBox<>("comboSpecifiedSystem"); + lblSpecifiedPlanet = new JLabel(); + comboSpecifiedPlanet = new MMComboBox<>("comboSpecifiedPlanet"); + lblOriginSearchRadius = new JLabel(); + spnOriginSearchRadius = new JSpinner(); + lblOriginDistanceScale = new JLabel(); + spnOriginDistanceScale = new JSpinner(); + chkAllowClanOrigins = new JCheckBox(); + chkExtraRandomOrigin = new JCheckBox(); + } + + JPanel createGeneralTab() { + // Header + JPanel headerPanel = createHeaderPanel("LifePathsGeneralTab", + getImageDirectory() + "logo_escorpion_imperio.png", + false, "", true); + + // Contents + chkUseDylansRandomXP = createCheckBox("UseDylansRandomXP", null); + + lblGender = createLabel("Gender", null); + sldGender = new JSlider(SwingConstants.HORIZONTAL, 0, 100, RandomGenderGenerator.getPercentFemale()); + sldGender.setMajorTickSpacing(25); + sldGender.setPaintTicks(true); + sldGender.setPaintLabels(true); + + lblNonBinaryDiceSize = createLabel("NonBinaryDiceSize", null); + spnNonBinaryDiceSize = createSpinner("NonBinaryDiceSize", null, + 60, 0, 100000, 1); + + lblFamilyDisplayLevel = createLabel("FamilyDisplayLevel", null); + + pnlAnniversariesPanel = createAnniversariesPanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("LifePathsGeneralTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addComponent(chkUseDylansRandomXP) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblGender) + .addComponent(sldGender)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblNonBinaryDiceSize) + .addComponent(spnNonBinaryDiceSize)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblFamilyDisplayLevel) + .addComponent(comboFamilyDisplayLevel)) + .addComponent(pnlAnniversariesPanel)); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addComponent(chkUseDylansRandomXP) + .addGroup(layout.createSequentialGroup() + .addComponent(lblGender) + .addComponent(sldGender)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblNonBinaryDiceSize) + .addComponent(spnNonBinaryDiceSize) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblFamilyDisplayLevel) + .addComponent(comboFamilyDisplayLevel) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(pnlAnniversariesPanel))); + + // Create Parent Panel and return + return createParentPanel(panel, "LifePathsGeneralTab"); + } + + private JPanel createAnniversariesPanel() { + // Contents + chkAnnounceBirthdays = createCheckBox("AnnounceBirthdays", null); + chkAnnounceRecruitmentAnniversaries = createCheckBox("AnnounceRecruitmentAnniversaries", null); + chkAnnounceOfficersOnly = createCheckBox("AnnounceOfficersOnly", null); + chkAnnounceChildBirthdays = createCheckBox("AnnounceChildBirthdays", null); + + // Layout the Panel + final JPanel panel = createStandardPanel("AnniversariesPanel", true, + "AnniversariesPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(chkAnnounceOfficersOnly) + .addComponent(chkAnnounceBirthdays) + .addComponent(chkAnnounceChildBirthdays) + .addComponent(chkAnnounceRecruitmentAnniversaries)); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(chkAnnounceOfficersOnly) + .addComponent(chkAnnounceBirthdays) + .addComponent(chkAnnounceChildBirthdays) + .addComponent(chkAnnounceRecruitmentAnniversaries))); + + return panel; + } + + JPanel createBackgroundsTab() { + // Header + JPanel headerPanel = createHeaderPanel("BackgroundsTab", + getImageDirectory() + "logo_clan_goliath_scorpion.png", + false, "", true); + + // Contents + chkUseRandomPersonalities = createCheckBox("UseRandomPersonalities", null); + chkUseRandomPersonalityReputation = createCheckBox("UseRandomPersonalityReputation", null); + chkUseIntelligenceXpMultiplier = createCheckBox("UseIntelligenceXpMultiplier", null); + chkUseSimulatedRelationships = createCheckBox("UseSimulatedRelationships", null); + + pnlRandomOriginOptions = createRandomOriginOptionsPanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("BackgroundsTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addComponent(chkUseRandomPersonalities) + .addComponent(chkUseRandomPersonalityReputation) + .addComponent(chkUseIntelligenceXpMultiplier) + .addComponent(chkUseSimulatedRelationships) + .addComponent(pnlRandomOriginOptions)); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addComponent(chkUseRandomPersonalities) + .addComponent(chkUseRandomPersonalityReputation) + .addComponent(chkUseIntelligenceXpMultiplier) + .addComponent(chkUseSimulatedRelationships) + .addComponent(pnlRandomOriginOptions))); + + // Create Parent Panel and return + return createParentPanel(panel, "BackgroundsTab"); + } + + private JPanel createRandomOriginOptionsPanel() { + // Contents + chkRandomizeOrigin = createCheckBox("RandomizeOrigin", null); + chkRandomizeDependentsOrigin = createCheckBox("RandomizeDependentsOrigin", null); + chkRandomizeAroundSpecifiedPlanet = createCheckBox("RandomizeAroundSpecifiedPlanet", null); + + chkSpecifiedSystemFactionSpecific = createCheckBox("SpecifiedSystemFactionSpecific", null); + chkSpecifiedSystemFactionSpecific.addActionListener(evt -> { + final PlanetarySystem planetarySystem = comboSpecifiedSystem.getSelectedItem(); + if ((planetarySystem == null) + || !planetarySystem.getFactionSet(campaign.getLocalDate()).contains(campaign.getFaction())) { + restoreComboSpecifiedSystem(); + } + }); + + + lblSpecifiedSystem = createLabel("SpecifiedSystem", null); + comboSpecifiedSystem.setRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(final JList list, final Object value, + final int index, final boolean isSelected, + final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof PlanetarySystem) { + setText(((PlanetarySystem) value).getName(campaign.getLocalDate())); + } + return this; + } + }); + comboSpecifiedSystem.addActionListener(evt -> { + final PlanetarySystem planetarySystem = comboSpecifiedSystem.getSelectedItem(); + final Planet planet = comboSpecifiedPlanet.getSelectedItem(); + if ((planetarySystem == null) + || ((planet != null) && !planet.getParentSystem().equals(planetarySystem))) { + restoreComboSpecifiedPlanet(); + } + }); + + lblSpecifiedPlanet = createLabel("SpecifiedPlanet", null); + comboSpecifiedPlanet.setRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(final JList list, final Object value, + final int index, final boolean isSelected, + final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof Planet) { + setText(((Planet) value).getName(campaign.getLocalDate())); + } + return this; + } + }); + + lblOriginSearchRadius = createLabel("OriginSearchRadius", null); + spnOriginSearchRadius = createSpinner("OriginSearchRadius", null, + 0, 0, 2000, 25); + + lblOriginDistanceScale = createLabel("OriginDistanceScale", null); + spnOriginDistanceScale = createSpinner("OriginDistanceScale", null, + 0.6, 0.1, 2.0, 0.1); + + chkAllowClanOrigins = createCheckBox("AllowClanOrigins", null); + chkExtraRandomOrigin = createCheckBox("ExtraRandomOrigin", null); + + // Layout the Panel + final JPanel panel = createStandardPanel("RandomOriginOptionsPanel", true, + "RandomOriginOptionsPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(chkRandomizeOrigin) + .addComponent(chkRandomizeDependentsOrigin) + .addComponent(chkRandomizeAroundSpecifiedPlanet) + .addComponent(chkSpecifiedSystemFactionSpecific) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblSpecifiedSystem) + .addComponent(comboSpecifiedSystem) + .addComponent(lblSpecifiedPlanet) + .addComponent(comboSpecifiedPlanet)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblOriginSearchRadius) + .addComponent(spnOriginSearchRadius) + .addComponent(lblOriginDistanceScale) + .addComponent(spnOriginDistanceScale)) + .addComponent(chkAllowClanOrigins) + .addComponent(chkExtraRandomOrigin)); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(chkRandomizeOrigin) + .addComponent(chkRandomizeDependentsOrigin) + .addComponent(chkRandomizeAroundSpecifiedPlanet) + .addComponent(chkSpecifiedSystemFactionSpecific) + .addGroup(layout.createSequentialGroup() + .addComponent(lblSpecifiedSystem) + .addComponent(comboSpecifiedSystem) + .addComponent(lblSpecifiedPlanet) + .addComponent(comboSpecifiedPlanet) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblOriginSearchRadius) + .addComponent(spnOriginSearchRadius) + .addComponent(lblOriginDistanceScale) + .addComponent(spnOriginDistanceScale) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkAllowClanOrigins) + .addComponent(chkExtraRandomOrigin))); + + return panel; + } + + /** + * Restores the list of planets in the combo box based on the selected planetary system. + * If no planetary system is selected, clear the combo box. + * If a planetary system is selected, populates the combo box with the planets from that system, + * and selects the primary planet of the system. + */ + private void restoreComboSpecifiedPlanet() { + final PlanetarySystem planetarySystem = comboSpecifiedSystem.getSelectedItem(); + if (planetarySystem == null) { + comboSpecifiedPlanet.removeAllItems(); + } else { + comboSpecifiedPlanet.setModel(new DefaultComboBoxModel<>( + planetarySystem.getPlanets().toArray(new Planet[] {}))); + comboSpecifiedPlanet.setSelectedItem(planetarySystem.getPrimaryPlanet()); + } + } + + private void restoreComboSpecifiedSystem() { + comboSpecifiedSystem.removeAllItems(); + comboSpecifiedSystem.setModel(new DefaultComboBoxModel<>(getPlanetarySystems( + chkSpecifiedSystemFactionSpecific.isSelected() ? campaign.getFaction() : null))); + restoreComboSpecifiedPlanet(); + } + + private PlanetarySystem[] getPlanetarySystems(final @Nullable Faction faction) { + ArrayList systems = campaign.getSystems(); + ArrayList filteredSystems = new ArrayList<>(); + + // Filter systems + for (PlanetarySystem planetarySystem : systems) { + if ((faction == null) || planetarySystem.getFactionSet(campaign.getLocalDate()).contains(faction)) { + filteredSystems.add(planetarySystem); + } + } + + // Sort systems + filteredSystems.sort(Comparator.comparing(p -> p.getName(campaign.getLocalDate()))); + + // Convert to array + return filteredSystems.toArray(new PlanetarySystem[0]); + } +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java index c9a8118007..2d54c789d6 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java @@ -321,7 +321,7 @@ private DefaultComboBoxModel getPrisonerStatusOptions() { JPanel createGeneralTab() { // Header - JPanel headerPanel = createHeaderPanel("GeneralTab", + JPanel headerPanel = createHeaderPanel("PersonnelGeneralTab", getImageDirectory() + "logo_circinus_federation.png", false, "", true); @@ -340,7 +340,7 @@ JPanel createGeneralTab() { personnelCleanUpPanel = createPersonnelCleanUpPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("GeneralTab", true, ""); + final JPanel panel = createStandardPanel("PersonnelGeneralTab", true, ""); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -377,7 +377,7 @@ JPanel createGeneralTab() { ); // Create Parent Panel and return - return createParentPanel(panel, "GeneralTab"); + return createParentPanel(panel, "PersonnelGeneralTab"); } /** From 0814741075910a01125e32c2c865e1369fc0de7f Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 10 Oct 2024 13:13:52 -0500 Subject: [PATCH 034/117] Add Marriage Tab to Life Paths Configuration Introduced a new Marriage Tab in the Life Paths configuration panel, including options for manual, clan personnel, and prisoner marriages. Enhanced random marriage settings with various input components and panels to customize marriage characteristics, logging, and random generation methods. Adjusted spinners in CampaignOptionsUtilities to align text to the left for improved readability. --- .../NEWCampaignOptionsDialog.properties | 50 ++- .../tabs/CampaignOptionsPane.java | 3 +- .../tabs/CampaignOptionsUtilities.java | 4 + .../campaignOptions/tabs/LifePathsTab.java | 325 +++++++++++++++++- 4 files changed, 377 insertions(+), 5 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 98016e6dd3..3e54e69cda 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -585,6 +585,11 @@ backgroundsTab.border="From noble houses to street gangs, once you're in the coc \ same. Your past might shape you, but your future is yours to command."\
- Lieutenant Marcus "Ghost" Walker, Onyx Fang Company +marriageTab.title=Marriage +marriageTab.border="In a universe filled with war and chaos, marriage is the one alliance that keeps\ + \ you grounded. When the battles end, it's the bond you fight to protect."\ +
- Lieutenant Elara "Sunburst" Tate, Steelclaw Company + # createGeneralTab lblLifePathsGeneralTab.text=General Options lblLifePathsGeneralTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ @@ -597,7 +602,7 @@ lblUseDylansRandomXP.text=Use Random XP lblUseDylansRandomXP.tooltip=PLACEHOLDER lblGender.text=Percent Female lblGender.tooltip=PLACEHOLDER -lblNonBinaryDiceSize.text=Non-Binary Personnel Chance: 1-in- +lblNonBinaryDiceSize.text=Non-Binary Personnel Chance: 1 in lblNonBinaryDiceSize.tooltip=PLACEHOLDER lblFamilyDisplayLevel.text=Family Display Depth lblFamilyDisplayLevel.tooltip=PLACEHOLDER @@ -651,4 +656,45 @@ lblOriginDistanceScale.tooltip=PLACEHOLDER lblAllowClanOrigins.text=Allow Clan Origins lblAllowClanOrigins.tooltip=PLACEHOLDER lblExtraRandomOrigin.text=Extra Random Origins -lblExtraRandomOrigin.tooltip=PLACEHOLDER \ No newline at end of file +lblExtraRandomOrigin.tooltip=PLACEHOLDER + +# createMarriageTab +lblMarriageTab.text=Marriage Options +lblMarriageTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblUseManualMarriages.text=Enable Manual Marriages +lblUseManualMarriages.tooltip=PLACEHOLDER +lblUseClanPersonnelMarriages.text=Enable Clan Marriages +lblUseClanPersonnelMarriages.tooltip=PLACEHOLDER +lblUsePrisonerMarriages.text=Enable Prisoner Marriages +lblUsePrisonerMarriages.tooltip=PLACEHOLDER +lblNoInterestInMarriageDiceSize.text=No Interest in Marriage Chance: 1 in +lblNoInterestInMarriageDiceSize.tooltip=PLACEHOLDER +lblCheckMutualAncestorsDepth.text=Minimum Ancestor Depth +lblCheckMutualAncestorsDepth.tooltip=PLACEHOLDER +lblLogMarriageNameChanges.text=Log Name Changes +lblLogMarriageNameChanges.tooltip=PLACEHOLDER + +# createRandomMarriagePanel +lblRandomMarriages.text=Random Marriages +lblRandomMarriageMethod.text=Random Marriage Method +lblRandomMarriageMethod.tooltip=PLACEHOLDER +lblUseRandomClanPersonnelMarriages.text=Enable Random Clan Marriages +lblUseRandomClanPersonnelMarriages.tooltip=PLACEHOLDER +lblUseRandomPrisonerMarriages.text=Enable Random Prisoner Marriages +lblUseRandomPrisonerMarriages.tooltip=PLACEHOLDER +lblRandomMarriageAgeRange.text=Random Marriage Age Band +lblRandomMarriageAgeRange.tooltip=PLACEHOLDER + +# createPercentageRandomMarriagePanel +lblPercentageRandomMarriagePanel.text=Marriage Dice +lblRandomMarriageOppositeSexDiceSize.text=Opposite Sex Marriage Chance: 1 in +lblRandomMarriageOppositeSexDiceSize.tooltip=PLACEHOLDER +lblRandomSameSexMarriageDiceSize.text=Same Sex Marriage Chance: 1 in +lblRandomSameSexMarriageDiceSize.tooltip=PLACEHOLDER +lblRandomNewDependentMarriage.text=Inter-Unit Marriage Chance: 1 in +lblRandomNewDependentMarriage.tooltip=PLACEHOLDER \ No newline at end of file diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 064ce81891..94ce11950f 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -125,7 +125,8 @@ private JTabbedPane createHumanResourcesParentTab() { JTabbedPane lifePathsContentTabs = createSubTabs(Map.of( "lifePathsGeneralTab", lifePathsTab.createGeneralTab(), - "backgroundsTab", lifePathsTab.createBackgroundsTab())); + "backgroundsTab", lifePathsTab.createBackgroundsTab(), + "marriageTab", lifePathsTab.createMarriageTab())); // Turnover and Retention // Name and Portrait Generation diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index 233970cf35..9c1c6c7d3c 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -5,6 +5,7 @@ import javax.swing.*; import javax.swing.GroupLayout.Alignment; +import javax.swing.JSpinner.DefaultEditor; import java.awt.*; import java.util.ArrayList; import java.util.List; @@ -76,6 +77,9 @@ static JSpinner createSpinner(String name, @Nullable Integer customWrapSize, dou jSpinner.setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), customWrapSize)); jSpinner.setName("spn" + name); + DefaultEditor editor = (DefaultEditor) jSpinner.getEditor(); + editor.getTextField().setHorizontalAlignment(JTextField.LEFT); + Dimension size = jSpinner.getPreferredSize(); jSpinner.setMaximumSize(size); jSpinner.setMinimumSize(size); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java index c16f5503fa..c3f0c227dd 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java @@ -5,6 +5,7 @@ import megamek.common.annotations.Nullable; import mekhq.campaign.Campaign; import mekhq.campaign.personnel.enums.FamilialRelationshipDisplayLevel; +import mekhq.campaign.personnel.enums.RandomMarriageMethod; import mekhq.campaign.universe.Faction; import mekhq.campaign.universe.Planet; import mekhq.campaign.universe.PlanetarySystem; @@ -59,6 +60,34 @@ public class LifePathsTab { private JCheckBox chkExtraRandomOrigin; //end Backgrounds Tab + //start Marriage Tab + private JPanel pnlMarriageGeneralOptions; + private JCheckBox chkUseManualMarriages; + private JCheckBox chkUseClanPersonnelMarriages; + private JCheckBox chkUsePrisonerMarriages; + private JLabel lblNoInterestInMarriageDiceSize; + private JSpinner spnNoInterestInMarriageDiceSize; + private JLabel lblCheckMutualAncestorsDepth; + private JSpinner spnCheckMutualAncestorsDepth; + private JCheckBox chkLogMarriageNameChanges; + + private JPanel pnlRandomMarriage; + private JLabel lblRandomMarriageMethod; + private MMComboBox comboRandomMarriageMethod; + private JCheckBox chkUseRandomClanPersonnelMarriages; + private JCheckBox chkUseRandomPrisonerMarriages; + private JLabel lblRandomMarriageAgeRange; + private JSpinner spnRandomMarriageAgeRange; + + private JPanel pnlPercentageRandomMarriage; + private JLabel lblRandomMarriageOppositeSexDiceSize; + private JSpinner spnRandomMarriageDiceSize; + private JLabel lblRandomSameSexMarriageDiceSize; + private JSpinner spnRandomSameSexMarriageDiceSize; + private JLabel lblRandomNewDependentMarriage; + private JSpinner spnRandomNewDependentMarriage; + //end Marriage Tab + /** * Represents a tab for repair and maintenance in an application. */ @@ -108,8 +137,45 @@ protected void initialize() { spnOriginDistanceScale = new JSpinner(); chkAllowClanOrigins = new JCheckBox(); chkExtraRandomOrigin = new JCheckBox(); + + // Marriage Tab + pnlMarriageGeneralOptions = new JPanel(); + chkUseManualMarriages = new JCheckBox(); + chkUseClanPersonnelMarriages = new JCheckBox(); + chkUsePrisonerMarriages = new JCheckBox(); + lblNoInterestInMarriageDiceSize = new JLabel(); + spnNoInterestInMarriageDiceSize = new JSpinner(); + lblCheckMutualAncestorsDepth = new JLabel(); + spnCheckMutualAncestorsDepth = new JSpinner(); + chkLogMarriageNameChanges = new JCheckBox(); + + pnlRandomMarriage = new JPanel(); + comboRandomMarriageMethod = new MMComboBox<>("comboRandomMarriageMethod", + RandomMarriageMethod.values()); + + pnlRandomMarriage = new JPanel(); + lblRandomMarriageMethod = new JLabel(); + comboRandomMarriageMethod = new MMComboBox<>("comboRandomMarriageMethod", + RandomMarriageMethod.values()); + chkUseRandomClanPersonnelMarriages = new JCheckBox(); + chkUseRandomPrisonerMarriages = new JCheckBox(); + lblRandomMarriageAgeRange = new JLabel(); + spnRandomMarriageAgeRange = new JSpinner(); + + pnlPercentageRandomMarriage = new JPanel(); + lblRandomMarriageOppositeSexDiceSize = new JLabel(); + spnRandomMarriageDiceSize = new JSpinner(); + lblRandomSameSexMarriageDiceSize = new JLabel(); + spnRandomSameSexMarriageDiceSize = new JSpinner(); + lblRandomNewDependentMarriage = new JLabel(); + spnRandomNewDependentMarriage = new JSpinner(); } + /** + * Creates a general tab for the Life Paths category containing various components + * + * @return a {@link JPanel} representing the general tab with multiple input components and panels + */ JPanel createGeneralTab() { // Header JPanel headerPanel = createHeaderPanel("LifePathsGeneralTab", @@ -175,6 +241,10 @@ JPanel createGeneralTab() { return createParentPanel(panel, "LifePathsGeneralTab"); } + /** + * @return a {@link JPanel} representing the Anniversaries panel with checkboxes for different + * anniversary options + */ private JPanel createAnniversariesPanel() { // Contents chkAnnounceBirthdays = createCheckBox("AnnounceBirthdays", null); @@ -206,6 +276,10 @@ private JPanel createAnniversariesPanel() { return panel; } + /** + * @return a JPanel representing the Backgrounds tab with specific components like checkboxes and + * options panel + */ JPanel createBackgroundsTab() { // Header JPanel headerPanel = createHeaderPanel("BackgroundsTab", @@ -248,13 +322,20 @@ JPanel createBackgroundsTab() { return createParentPanel(panel, "BackgroundsTab"); } + /** + * Creates a panel containing options for randomizing personnel origins. + * + * @return a {@link JPanel} containing the random origin options, configured with the necessary components + */ private JPanel createRandomOriginOptionsPanel() { // Contents chkRandomizeOrigin = createCheckBox("RandomizeOrigin", null); chkRandomizeDependentsOrigin = createCheckBox("RandomizeDependentsOrigin", null); - chkRandomizeAroundSpecifiedPlanet = createCheckBox("RandomizeAroundSpecifiedPlanet", null); + chkRandomizeAroundSpecifiedPlanet = createCheckBox("RandomizeAroundSpecifiedPlanet", + null); - chkSpecifiedSystemFactionSpecific = createCheckBox("SpecifiedSystemFactionSpecific", null); + chkSpecifiedSystemFactionSpecific = createCheckBox("SpecifiedSystemFactionSpecific", + null); chkSpecifiedSystemFactionSpecific.addActionListener(evt -> { final PlanetarySystem planetarySystem = comboSpecifiedSystem.getSelectedItem(); if ((planetarySystem == null) @@ -369,6 +450,7 @@ public Component getListCellRendererComponent(final JList list, final Object */ private void restoreComboSpecifiedPlanet() { final PlanetarySystem planetarySystem = comboSpecifiedSystem.getSelectedItem(); + if (planetarySystem == null) { comboSpecifiedPlanet.removeAllItems(); } else { @@ -378,13 +460,28 @@ private void restoreComboSpecifiedPlanet() { } } + /** + * Removes all items from the combo box, then populates it with planetary systems + * based on the selected faction filter. + * Restores the combo box for specified planets after updating the specified system combo box. + */ private void restoreComboSpecifiedSystem() { comboSpecifiedSystem.removeAllItems(); + comboSpecifiedSystem.setModel(new DefaultComboBoxModel<>(getPlanetarySystems( chkSpecifiedSystemFactionSpecific.isSelected() ? campaign.getFaction() : null))); + restoreComboSpecifiedPlanet(); } + /** + * Retrieves an array of {@link PlanetarySystem} objects based on the provided {@link Faction}. + * + * @param faction The {@link Faction} to filter the {@link PlanetarySystem} by. Specify null for + * no filtering. + * @return An array of {@link PlanetarySystem} objects that match the filtering criteria, sorted + * by system name. + */ private PlanetarySystem[] getPlanetarySystems(final @Nullable Faction faction) { ArrayList systems = campaign.getSystems(); ArrayList filteredSystems = new ArrayList<>(); @@ -402,4 +499,228 @@ private PlanetarySystem[] getPlanetarySystems(final @Nullable Faction faction) { // Convert to array return filteredSystems.toArray(new PlanetarySystem[0]); } + + /** + * Creates a panel for the Marriage tab with various input components and panels related to marriage settings. + * + * @return a {@link} representing the Marriage tab with checkboxes for manual, clan personnel, + * prisoner marriages, options for marriage characteristics, logging marriage name changes, surname + * weight settings, and random marriage generation. + */ + JPanel createMarriageTab() { + // Header + JPanel headerPanel = createHeaderPanel("MarriageTab", + getImageDirectory() + "logo_federated_commonwealth.png", + false, "", true); + + // Contents + pnlMarriageGeneralOptions = createMarriageGeneralOptionsPanel(); + pnlRandomMarriage = createRandomMarriagePanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("MarriageTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(pnlMarriageGeneralOptions) + .addComponent(pnlRandomMarriage))); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addGroup(layout.createSequentialGroup() + .addComponent(pnlMarriageGeneralOptions) + .addComponent(pnlRandomMarriage)))); + + // Create Parent Panel and return + return createParentPanel(panel, "MarriageTab"); + } + + + JPanel createMarriageGeneralOptionsPanel() { + // Contents + chkUseManualMarriages = createCheckBox("UseManualMarriages", null); + chkUseClanPersonnelMarriages = createCheckBox("UseClanPersonnelMarriages", null); + chkUsePrisonerMarriages = createCheckBox("UsePrisonerMarriages", null); + + lblNoInterestInMarriageDiceSize = createLabel("NoInterestInMarriageDiceSize", null); + spnNoInterestInMarriageDiceSize = createSpinner("NoInterestInMarriageDiceSize", null, + 10, 1, 100000, 1); + + lblCheckMutualAncestorsDepth = createLabel("CheckMutualAncestorsDepth", null); + spnCheckMutualAncestorsDepth = createSpinner("CheckMutualAncestorsDepth", null, + 4, 0, 20, 1); + + chkLogMarriageNameChanges = createCheckBox("LogMarriageNameChanges", null); + + // Layout the Panel + final JPanel panel = createStandardPanel("MarriageGeneralOptionsPanel", + false, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(chkUseManualMarriages) + .addComponent(chkUseClanPersonnelMarriages) + .addComponent(chkUsePrisonerMarriages) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblNoInterestInMarriageDiceSize) + .addComponent(spnNoInterestInMarriageDiceSize)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblCheckMutualAncestorsDepth) + .addComponent(spnCheckMutualAncestorsDepth)) + .addComponent(chkLogMarriageNameChanges)); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(chkUseManualMarriages) + .addComponent(chkUseClanPersonnelMarriages) + .addComponent(chkUsePrisonerMarriages) + .addGroup(layout.createSequentialGroup() + .addComponent(lblNoInterestInMarriageDiceSize) + .addComponent(spnNoInterestInMarriageDiceSize) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblCheckMutualAncestorsDepth) + .addComponent(spnCheckMutualAncestorsDepth) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkLogMarriageNameChanges))); + + return panel; + } + + /** + * Creates a panel for random marriage settings, including options for different marriage methods, + * using random clan personnel and prisoner marriages, setting age range for marriages, and + * percentage settings. + * + * @return a {@link JPanel} representing the random marriage panel with various input components + * and panels for configuring random marriage settings + */ + JPanel createRandomMarriagePanel() { + // Contents + lblRandomMarriageMethod = createLabel("RandomMarriageMethod", null); + comboRandomMarriageMethod.setRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(final JList list, final Object value, + final int index, final boolean isSelected, + final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof RandomMarriageMethod) { + list.setToolTipText(((RandomMarriageMethod) value).getToolTipText()); + } + return this; + } + }); + + chkUseRandomClanPersonnelMarriages = createCheckBox("UseRandomClanPersonnelMarriages", null); + chkUseRandomPrisonerMarriages = createCheckBox("UseRandomPrisonerMarriages", null); + + lblRandomMarriageAgeRange = createLabel("RandomMarriageAgeRange", null); + spnRandomMarriageAgeRange = createSpinner("RandomMarriageAgeRange", null, + 10, 0, 100, 1.0); + + pnlPercentageRandomMarriage = createPercentageRandomMarriagePanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("RandomMarriages", true, + "RandomMarriages"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblRandomMarriageMethod) + .addComponent(comboRandomMarriageMethod)) + .addComponent(chkUseRandomClanPersonnelMarriages) + .addComponent(chkUseRandomPrisonerMarriages) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblRandomMarriageAgeRange) + .addComponent(spnRandomMarriageAgeRange)) + .addComponent(pnlPercentageRandomMarriage)); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblRandomMarriageMethod) + .addComponent(comboRandomMarriageMethod) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkUseRandomClanPersonnelMarriages) + .addComponent(chkUseRandomPrisonerMarriages) + .addGroup(layout.createSequentialGroup() + .addComponent(lblRandomMarriageAgeRange) + .addComponent(spnRandomMarriageAgeRange) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(pnlPercentageRandomMarriage))); + + return panel; + } + + /** + * Creates a panel for setting percentage-based random marriage settings. + * + * @return a {@link JPanel} representing the Percentage Random Marriage panel with input components + * for setting opposite-sex marriage dice size, same-sex marriage dice size, and new dependent + * marriage dice size + */ + JPanel createPercentageRandomMarriagePanel() { + // Contents + lblRandomMarriageOppositeSexDiceSize = createLabel("RandomMarriageOppositeSexDiceSize", + null); + spnRandomMarriageDiceSize = createSpinner("RandomMarriageOppositeSexDiceSize", + null, 5000, 0, 100000, 1); + + lblRandomSameSexMarriageDiceSize = createLabel("RandomSameSexMarriageDiceSize", null); + spnRandomSameSexMarriageDiceSize = createSpinner("RandomSameSexMarriageDiceSize", + null, 14, 0, 100000, 1); + + lblRandomNewDependentMarriage = createLabel("RandomNewDependentMarriage", null); + spnRandomNewDependentMarriage = createSpinner("RandomSameSexMarriageDiceSize", + null, 20, 0, 100000, 1); + + // Layout the Panel + final JPanel panel = createStandardPanel("PercentageRandomMarriagePanel", true, + "PercentageRandomMarriagePanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblRandomMarriageOppositeSexDiceSize) + .addComponent(spnRandomMarriageDiceSize)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblRandomSameSexMarriageDiceSize) + .addComponent(spnRandomSameSexMarriageDiceSize)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblRandomNewDependentMarriage) + .addComponent(spnRandomNewDependentMarriage))); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblRandomMarriageOppositeSexDiceSize) + .addComponent(spnRandomMarriageDiceSize) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblRandomSameSexMarriageDiceSize) + .addComponent(spnRandomSameSexMarriageDiceSize) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblRandomNewDependentMarriage) + .addComponent(spnRandomNewDependentMarriage) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + + return panel; + } } From d2f7b2cc757e312be5c4753c553bb31630a5efef Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 10 Oct 2024 13:37:00 -0500 Subject: [PATCH 035/117] Add divorce options tab in campaign settings Included a new Divorce tab with various settings such as manual, clan personnel, and prisoner divorces, along with random divorce configurations. Updated the campaign options pane to integrate the new tab and revised related resource files. --- .../NEWCampaignOptionsDialog.properties | 37 ++++- .../tabs/CampaignOptionsPane.java | 3 +- .../campaignOptions/tabs/LifePathsTab.java | 155 +++++++++++++++++- 3 files changed, 191 insertions(+), 4 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 3e54e69cda..8fb9d55c52 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -590,6 +590,11 @@ marriageTab.border="In a universe filled with war and chaos, marriage is the one \ you grounded. When the battles end, it's the bond you fight to protect."\
- Lieutenant Elara "Sunburst" Tate, Steelclaw Company +divorceTab.title=Divorce +divorceTab.border="Divorce is just like ejecting from a 'mek: it's messy, expensive, and you're lucky\ + \ if you escape in one piece."\ +
- Sergeant Quinn "Deadeye" Mallory, Crimson Fang Mercs + # createGeneralTab lblLifePathsGeneralTab.text=General Options lblLifePathsGeneralTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ @@ -697,4 +702,34 @@ lblRandomMarriageOppositeSexDiceSize.tooltip=PLACEHOLDER lblRandomSameSexMarriageDiceSize.text=Same Sex Marriage Chance: 1 in lblRandomSameSexMarriageDiceSize.tooltip=PLACEHOLDER lblRandomNewDependentMarriage.text=Inter-Unit Marriage Chance: 1 in -lblRandomNewDependentMarriage.tooltip=PLACEHOLDER \ No newline at end of file +lblRandomNewDependentMarriage.tooltip=PLACEHOLDER + +# createDivorceTab +lblDivorceTab.text=Divorce Options +lblDivorceTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblUseManualDivorce.text=Enable Manual Divorce +lblUseManualDivorce.tooltip=PLACEHOLDER +lblUseClanPersonnelDivorce.text=Enable Manual Clan Divorce +lblUseClanPersonnelDivorce.tooltip=PLACEHOLDER +lblUsePrisonerDivorce.text=Enable Manual Prisoner Divorce +lblUsePrisonerDivorce.tooltip=PLACEHOLDER + +# createRandomDivorcePanel +lblRandomDivorcePanel.text=Random Divorce +lblRandomDivorceMethod.text=Random Divorce Method +lblRandomDivorceMethod.tooltip=PLACEHOLDER +lblUseRandomOppositeSexDivorce.text=Use Random Opposite Sex Divorce +lblUseRandomOppositeSexDivorce.tooltip=PLACEHOLDER +lblUseRandomSameSexDivorce.text=Use Random Same Sex Divorce +lblUseRandomSameSexDivorce.tooltip=PLACEHOLDER +lblUseRandomClanPersonnelDivorce.text=Use Random Clan Divorce +lblUseRandomClanPersonnelDivorce.tooltip=PLACEHOLDER +lblUseRandomPrisonerDivorce.text=Use Random Prisoner Divorce +lblUseRandomPrisonerDivorce.tooltip=PLACEHOLDER +lblRandomDivorceDiceSize.text=Random Divorce Chance: 1 in +lblRandomDivorceDiceSize.tooltip=PLACEHOLDER \ No newline at end of file diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 94ce11950f..7b6023f1bc 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -126,7 +126,8 @@ private JTabbedPane createHumanResourcesParentTab() { JTabbedPane lifePathsContentTabs = createSubTabs(Map.of( "lifePathsGeneralTab", lifePathsTab.createGeneralTab(), "backgroundsTab", lifePathsTab.createBackgroundsTab(), - "marriageTab", lifePathsTab.createMarriageTab())); + "marriageTab", lifePathsTab.createMarriageTab(), + "divorceTab", lifePathsTab.createDivorceTab())); // Turnover and Retention // Name and Portrait Generation diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java index c3f0c227dd..7c18789f68 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java @@ -5,6 +5,7 @@ import megamek.common.annotations.Nullable; import mekhq.campaign.Campaign; import mekhq.campaign.personnel.enums.FamilialRelationshipDisplayLevel; +import mekhq.campaign.personnel.enums.RandomDivorceMethod; import mekhq.campaign.personnel.enums.RandomMarriageMethod; import mekhq.campaign.universe.Faction; import mekhq.campaign.universe.Planet; @@ -88,6 +89,23 @@ public class LifePathsTab { private JSpinner spnRandomNewDependentMarriage; //end Marriage Tab + //start Divorce Tab + private JCheckBox chkUseManualDivorce; + private JCheckBox chkUseClanPersonnelDivorce; + private JCheckBox chkUsePrisonerDivorce; + + private JPanel pnlRandomDivorce; + + private JLabel lblRandomDivorceMethod; + private MMComboBox comboRandomDivorceMethod; + private JCheckBox chkUseRandomOppositeSexDivorce; + private JCheckBox chkUseRandomSameSexDivorce; + private JCheckBox chkUseRandomClanPersonnelDivorce; + private JCheckBox chkUseRandomPrisonerDivorce; + private JLabel lblRandomDivorceDiceSize; + private JSpinner spnRandomDivorceDiceSize; + //end Divorce Tab + /** * Represents a tab for repair and maintenance in an application. */ @@ -169,6 +187,21 @@ protected void initialize() { spnRandomSameSexMarriageDiceSize = new JSpinner(); lblRandomNewDependentMarriage = new JLabel(); spnRandomNewDependentMarriage = new JSpinner(); + + // Divorce Tab + chkUseManualDivorce = new JCheckBox(); + chkUseClanPersonnelDivorce = new JCheckBox(); + chkUsePrisonerDivorce = new JCheckBox(); + + pnlRandomDivorce = new JPanel(); + lblRandomDivorceMethod = new JLabel(); + comboRandomDivorceMethod = new MMComboBox<>("comboRandomDivorceMethod", RandomDivorceMethod.values()); + chkUseRandomOppositeSexDivorce = new JCheckBox(); + chkUseRandomSameSexDivorce = new JCheckBox(); + chkUseRandomClanPersonnelDivorce = new JCheckBox(); + chkUseRandomPrisonerDivorce = new JCheckBox(); + lblRandomDivorceDiceSize = new JLabel(); + spnRandomDivorceDiceSize = new JSpinner(); } /** @@ -179,7 +212,7 @@ protected void initialize() { JPanel createGeneralTab() { // Header JPanel headerPanel = createHeaderPanel("LifePathsGeneralTab", - getImageDirectory() + "logo_escorpion_imperio.png", + getImageDirectory() + "logo_federated_suns.png", false, "", true); // Contents @@ -541,7 +574,11 @@ JPanel createMarriageTab() { return createParentPanel(panel, "MarriageTab"); } - + /** + * Creates a panel for general marriage options with checkboxes and input components. + * + * @return a {@link JPanel} representing the general marriage options panel + */ JPanel createMarriageGeneralOptionsPanel() { // Contents chkUseManualMarriages = createCheckBox("UseManualMarriages", null); @@ -723,4 +760,118 @@ JPanel createPercentageRandomMarriagePanel() { return panel; } + + /** + * Creates a tab for divorce settings with various checkboxes and panels for manual, clan personnel, + * and prisoner divorces. + * + * @return a {@link JPanel} representing the Divorce tab with checkboxes for manual divorce, + * clan personnel divorce, prisoner divorce, and a panel for configuring random divorce settings. + */ + JPanel createDivorceTab() { + // Header + JPanel headerPanel = createHeaderPanel("DivorceTab", + getImageDirectory() + "logo_clan_hells_horses.png", + false, "", true); + + // Contents + chkUseManualDivorce = createCheckBox("UseManualDivorce", null); + chkUseClanPersonnelDivorce = createCheckBox("UseClanPersonnelDivorce", null); + chkUsePrisonerDivorce = createCheckBox("UsePrisonerDivorce", null); + + pnlRandomDivorce = createRandomDivorcePanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("DivorceTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addComponent(chkUseManualDivorce) + .addComponent(chkUseClanPersonnelDivorce) + .addComponent(chkUsePrisonerDivorce) + .addComponent(pnlRandomDivorce)); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addComponent(chkUseManualDivorce) + .addComponent(chkUseClanPersonnelDivorce) + .addComponent(chkUsePrisonerDivorce) + .addComponent(pnlRandomDivorce))); + + // Create Parent Panel and return + return createParentPanel(panel, "DivorceTab"); + } + + /** + * Creates a panel for the Divorce tab with checkboxes for manual divorce, clan personnel divorce, + * prisoner divorce, and a panel for configuring random divorce settings. + * + * @return a {@link JPanel} representing the Divorce tab with various components for configuring divorce settings + */ + JPanel createRandomDivorcePanel() { + // Contents + lblRandomDivorceMethod = createLabel("RandomDivorceMethod", null); + comboRandomDivorceMethod.setRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(final JList list, final Object value, + final int index, final boolean isSelected, + final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof RandomDivorceMethod) { + list.setToolTipText(((RandomDivorceMethod) value).getToolTipText()); + } + return this; + } + }); + + chkUseRandomOppositeSexDivorce = createCheckBox("UseRandomOppositeSexDivorce", null); + chkUseRandomSameSexDivorce = createCheckBox("UseRandomSameSexDivorce", null); + chkUseRandomClanPersonnelDivorce = createCheckBox("UseRandomClanPersonnelDivorce", null); + chkUseRandomPrisonerDivorce = createCheckBox("UseRandomPrisonerDivorce", null); + + lblRandomDivorceDiceSize = createLabel("RandomDivorceDiceSize", null); + spnRandomDivorceDiceSize = createSpinner("RandomDivorceDiceSize", null, + 900, 0, 100000, 1); + + // Layout the Panel + final JPanel panel = createStandardPanel("RandomDivorcePanel", true, "RandomDivorcePanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblRandomDivorceMethod) + .addComponent(comboRandomDivorceMethod)) + .addComponent(chkUseRandomOppositeSexDivorce) + .addComponent(chkUseRandomSameSexDivorce) + .addComponent(chkUseRandomClanPersonnelDivorce) + .addComponent(chkUseRandomPrisonerDivorce) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblRandomDivorceDiceSize) + .addComponent(spnRandomDivorceDiceSize))); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblRandomDivorceMethod) + .addComponent(comboRandomDivorceMethod) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkUseRandomOppositeSexDivorce) + .addComponent(chkUseRandomSameSexDivorce) + .addComponent(chkUseRandomClanPersonnelDivorce) + .addComponent(chkUseRandomPrisonerDivorce) + .addGroup(layout.createSequentialGroup() + .addComponent(lblRandomDivorceDiceSize) + .addComponent(spnRandomDivorceDiceSize) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + + return panel; + } } From c61476fecb5811dddb0e7218efb01665f32f8102 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 10 Oct 2024 13:41:37 -0500 Subject: [PATCH 036/117] Add procreation tab with divorce options Implemented a new procreation tab in the LifePathsTab with various divorce options, including manual, clan personnel, and prisoner divorces. Updated the campaign options dialog properties to reflect the inclusion of new relationship categories for marriage and divorce. --- .../NEWCampaignOptionsDialog.properties | 4 +- .../campaignOptions/tabs/LifePathsTab.java | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 8fb9d55c52..ab4fbdc8f4 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -585,12 +585,12 @@ backgroundsTab.border="From noble houses to street gangs, once you're in the coc \ same. Your past might shape you, but your future is yours to command."\
- Lieutenant Marcus "Ghost" Walker, Onyx Fang Company -marriageTab.title=Marriage +marriageTab.title=Relationships - Marriage marriageTab.border="In a universe filled with war and chaos, marriage is the one alliance that keeps\ \ you grounded. When the battles end, it's the bond you fight to protect."\
- Lieutenant Elara "Sunburst" Tate, Steelclaw Company -divorceTab.title=Divorce +divorceTab.title=Relationships - Divorce divorceTab.border="Divorce is just like ejecting from a 'mek: it's messy, expensive, and you're lucky\ \ if you escape in one piece."\
- Sergeant Quinn "Deadeye" Mallory, Crimson Fang Mercs diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java index 7c18789f68..60206a7dd9 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java @@ -874,4 +874,43 @@ public Component getListCellRendererComponent(final JList list, final Object return panel; } + + JPanel createProcreationTab() { + // Header + JPanel headerPanel = createHeaderPanel("ProcreationTab", + getImageDirectory() + "logo_clan_ice_hellion.png", + false, "", true); + + // Contents + chkUseManualDivorce = createCheckBox("UseManualDivorce", null); + chkUseClanPersonnelDivorce = createCheckBox("UseClanPersonnelDivorce", null); + chkUsePrisonerDivorce = createCheckBox("UsePrisonerDivorce", null); + + pnlRandomDivorce = createRandomDivorcePanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("DivorceTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addComponent(chkUseManualDivorce) + .addComponent(chkUseClanPersonnelDivorce) + .addComponent(chkUsePrisonerDivorce) + .addComponent(pnlRandomDivorce)); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addComponent(chkUseManualDivorce) + .addComponent(chkUseClanPersonnelDivorce) + .addComponent(chkUsePrisonerDivorce) + .addComponent(pnlRandomDivorce))); + + // Create Parent Panel and return + return createParentPanel(panel, "DivorceTab"); + } } From e2c660bc6f9ebe69a449eae3a176643de105dcdc Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 10 Oct 2024 14:45:39 -0500 Subject: [PATCH 037/117] Add Procreation Tab to Campaign Options Implemented a new Procreation Tab in the Campaign Options dialog. This includes various settings related to manual, clan, and random procreation methods, as well as options for managing offspring attributes and maternity leave. --- .../NEWCampaignOptionsDialog.properties | 57 +++- .../tabs/CampaignOptionsPane.java | 3 +- .../campaignOptions/tabs/LifePathsTab.java | 275 ++++++++++++++++-- 3 files changed, 314 insertions(+), 21 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index ab4fbdc8f4..7e4a1b41f2 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -595,6 +595,11 @@ divorceTab.border="Divorce is just like ejecting from a 'mek: it's messy, expens \ if you escape in one piece."\
- Sergeant Quinn "Deadeye" Mallory, Crimson Fang Mercs +procreationTab.title=Relationships - Procreation +procreationTab.border="In this galaxy, raising kids is tougher than raising a lance. At least 'meks\ + \ come with an instruction manual."\ +
- Captain Dani "Ironheart" Cole, Steel Talon Company + # createGeneralTab lblLifePathsGeneralTab.text=General Options lblLifePathsGeneralTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ @@ -732,4 +737,54 @@ lblUseRandomClanPersonnelDivorce.tooltip=PLACEHOLDER lblUseRandomPrisonerDivorce.text=Use Random Prisoner Divorce lblUseRandomPrisonerDivorce.tooltip=PLACEHOLDER lblRandomDivorceDiceSize.text=Random Divorce Chance: 1 in -lblRandomDivorceDiceSize.tooltip=PLACEHOLDER \ No newline at end of file +lblRandomDivorceDiceSize.tooltip=PLACEHOLDER + +# createProcreationTab +lblProcreationTab.text=Procreation Options +lblProcreationTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam + +# createProcreationGeneralOptionsPanel +lblUseManualProcreation.text=Enable Manual Procreation +lblUseManualProcreation.tooltip=PLACEHOLDER +lblUseClanPersonnelProcreation.text=Enable Clan Procreation +lblUseClanPersonnelProcreation.tooltip=PLACEHOLDER +lblUsePrisonerProcreation.text=Enable Prisoner Procreation +lblUsePrisonerProcreation.tooltip=PLACEHOLDER +lblMultiplePregnancyOccurrences.text=Multiple Pregnancy Chance: 1 in +lblMultiplePregnancyOccurrences.tooltip=PLACEHOLDER +lblBabySurnameStyle.text=Baby Surname Style +lblBabySurnameStyle.tooltip=PLACEHOLDER +lblAssignNonPrisonerBabiesFounderTag.text=Non-Prisoner Babies are Founders +lblAssignNonPrisonerBabiesFounderTag.tooltip=PLACEHOLDER +lblAssignChildrenOfFoundersFounderTag.text=Children of Founders are Founders +lblAssignChildrenOfFoundersFounderTag.tooltip=PLACEHOLDER +lblDetermineFatherAtBirth.text=Determine Father at Birth +lblDetermineFatherAtBirth.tooltip=PLACEHOLDER +lblDisplayTrueDueDate.text=Display True Due Date +lblDisplayTrueDueDate.tooltip=PLACEHOLDER +lblNoInterestInChildrenDiceSize.text=No Interest in Children Chance: 1 in +lblNoInterestInChildrenDiceSize.tooltip=PLACEHOLDER +lblUseMaternityLeave.text=Enable Automatic Maternity Leave +lblUseMaternityLeave.tooltip=PLACEHOLDER +lblLogProcreation.text=Log Procreation +lblLogProcreation.tooltip=PLACEHOLDER + +# createRandomProcreationPanel +lblRandomProcreationPanel.text=Random Procreation +lblRandomProcreationMethod.text=Random Procreation Method +lblRandomProcreationMethod.tooltip=PLACEHOLDER +lblUseRelationshiplessRandomProcreation.text=Enable Random Relationshipless Procreation +lblUseRelationshiplessRandomProcreation.tooltip=PLACEHOLDER +lblUseRandomClanPersonnelProcreation.text=Enable Random Clan Procreation +lblUseRandomClanPersonnelProcreation.tooltip=PLACEHOLDER +lblUseRandomPrisonerProcreation.text=Enable Random Prisoner Procreation +lblUseRandomPrisonerProcreation.tooltip=PLACEHOLDER +lblRandomProcreationRelationshipDiceSize.text=Normal Procreation Chance: 1 in +lblRandomProcreationRelationshipDiceSize.tooltip=PLACEHOLDER +lblRandomProcreationRelationshiplessDiceSize.text=Relationshipless Procreation Chance: 1 in +lblRandomProcreationRelationshiplessDiceSize.tooltip=PLACEHOLDER \ No newline at end of file diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 7b6023f1bc..e552ee8a9a 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -127,7 +127,8 @@ private JTabbedPane createHumanResourcesParentTab() { "lifePathsGeneralTab", lifePathsTab.createGeneralTab(), "backgroundsTab", lifePathsTab.createBackgroundsTab(), "marriageTab", lifePathsTab.createMarriageTab(), - "divorceTab", lifePathsTab.createDivorceTab())); + "divorceTab", lifePathsTab.createDivorceTab(), + "procreationTab", lifePathsTab.createProcreationTab())); // Turnover and Retention // Name and Portrait Generation diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java index 60206a7dd9..f5ce23af03 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java @@ -4,9 +4,7 @@ import megamek.client.ui.baseComponents.MMComboBox; import megamek.common.annotations.Nullable; import mekhq.campaign.Campaign; -import mekhq.campaign.personnel.enums.FamilialRelationshipDisplayLevel; -import mekhq.campaign.personnel.enums.RandomDivorceMethod; -import mekhq.campaign.personnel.enums.RandomMarriageMethod; +import mekhq.campaign.personnel.enums.*; import mekhq.campaign.universe.Faction; import mekhq.campaign.universe.Planet; import mekhq.campaign.universe.PlanetarySystem; @@ -106,6 +104,36 @@ public class LifePathsTab { private JSpinner spnRandomDivorceDiceSize; //end Divorce Tab + //start Procreation Tab + private JCheckBox chkUseManualProcreation; + private JCheckBox chkUseClanPersonnelProcreation; + private JCheckBox chkUsePrisonerProcreation; + private JLabel lblMultiplePregnancyOccurrences; + private JSpinner spnMultiplePregnancyOccurrences; + private JLabel lblBabySurnameStyle; + private MMComboBox comboBabySurnameStyle; + private JCheckBox chkAssignNonPrisonerBabiesFounderTag; + private JCheckBox chkAssignChildrenOfFoundersFounderTag; + private JCheckBox chkDetermineFatherAtBirth; + private JCheckBox chkDisplayTrueDueDate; + private JLabel lblNoInterestInChildrenDiceSize; + private JSpinner spnNoInterestInChildrenDiceSize; + private JCheckBox chkUseMaternityLeave; + private JCheckBox chkLogProcreation; + + private JPanel pnlProcreationGeneralOptionsPanel; + private JPanel pnlRandomProcreationPanel; + private JLabel lblRandomProcreationMethod; + private MMComboBox comboRandomProcreationMethod; + private JCheckBox chkUseRelationshiplessRandomProcreation; + private JCheckBox chkUseRandomClanPersonnelProcreation; + private JCheckBox chkUseRandomPrisonerProcreation; + private JLabel lblRandomProcreationRelationshipDiceSize; + private JSpinner spnRandomProcreationRelationshipDiceSize; + private JLabel lblRandomProcreationRelationshiplessDiceSize; + private JSpinner spnRandomProcreationRelationshiplessDiceSize; + //end Procreation Tab + /** * Represents a tab for repair and maintenance in an application. */ @@ -202,6 +230,36 @@ protected void initialize() { chkUseRandomPrisonerDivorce = new JCheckBox(); lblRandomDivorceDiceSize = new JLabel(); spnRandomDivorceDiceSize = new JSpinner(); + + // Procreation Tab + pnlProcreationGeneralOptionsPanel = new JPanel(); + chkUseManualProcreation = new JCheckBox(); + chkUseClanPersonnelProcreation = new JCheckBox(); + chkUsePrisonerProcreation = new JCheckBox(); + lblMultiplePregnancyOccurrences = new JLabel(); + spnMultiplePregnancyOccurrences = new JSpinner(); + lblBabySurnameStyle = new JLabel(); + comboBabySurnameStyle = new MMComboBox<>("comboBabySurnameStyle", BabySurnameStyle.values()); + chkAssignNonPrisonerBabiesFounderTag = new JCheckBox(); + chkAssignChildrenOfFoundersFounderTag = new JCheckBox(); + chkDetermineFatherAtBirth = new JCheckBox(); + chkDisplayTrueDueDate = new JCheckBox(); + lblNoInterestInChildrenDiceSize = new JLabel(); + spnNoInterestInChildrenDiceSize = new JSpinner(); + chkUseMaternityLeave = new JCheckBox(); + chkLogProcreation = new JCheckBox(); + + pnlRandomProcreationPanel = new JPanel(); + lblRandomProcreationMethod = new JLabel(); + comboRandomProcreationMethod = new MMComboBox<>("comboRandomProcreationMethod", + RandomProcreationMethod.values()); + chkUseRelationshiplessRandomProcreation = new JCheckBox(); + chkUseRandomClanPersonnelProcreation = new JCheckBox(); + chkUseRandomPrisonerProcreation = new JCheckBox(); + lblRandomProcreationRelationshipDiceSize = new JLabel(); + spnRandomProcreationRelationshipDiceSize = new JSpinner(); + lblRandomProcreationRelationshiplessDiceSize = new JLabel(); + spnRandomProcreationRelationshiplessDiceSize = new JSpinner(); } /** @@ -568,7 +626,8 @@ JPanel createMarriageTab() { .addComponent(headerPanel, Alignment.CENTER) .addGroup(layout.createSequentialGroup() .addComponent(pnlMarriageGeneralOptions) - .addComponent(pnlRandomMarriage)))); + .addComponent(pnlRandomMarriage) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); // Create Parent Panel and return return createParentPanel(panel, "MarriageTab"); @@ -875,6 +934,12 @@ public Component getListCellRendererComponent(final JList list, final Object return panel; } + /** + * Creates a panel for the Procreation tab with header, general options panel, and random procreation panel. + * + * @return a {@link JPanel} representing the Procreation tab with header, general options panel, + * and random procreation panel + */ JPanel createProcreationTab() { // Header JPanel headerPanel = createHeaderPanel("ProcreationTab", @@ -882,35 +947,207 @@ JPanel createProcreationTab() { false, "", true); // Contents - chkUseManualDivorce = createCheckBox("UseManualDivorce", null); - chkUseClanPersonnelDivorce = createCheckBox("UseClanPersonnelDivorce", null); - chkUsePrisonerDivorce = createCheckBox("UsePrisonerDivorce", null); - - pnlRandomDivorce = createRandomDivorcePanel(); + pnlProcreationGeneralOptionsPanel = createProcreationGeneralOptionsPanel(); + pnlRandomProcreationPanel = createRandomProcreationPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("DivorceTab", true, ""); + final JPanel panel = createStandardPanel("ProcreationTab", true, ""); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( layout.createSequentialGroup() .addComponent(headerPanel) - .addComponent(chkUseManualDivorce) - .addComponent(chkUseClanPersonnelDivorce) - .addComponent(chkUsePrisonerDivorce) - .addComponent(pnlRandomDivorce)); + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(pnlProcreationGeneralOptionsPanel) + .addComponent(pnlRandomProcreationPanel))); layout.setHorizontalGroup( layout.createSequentialGroup() .addGroup(layout.createParallelGroup(Alignment.LEADING) .addComponent(headerPanel, Alignment.CENTER) - .addComponent(chkUseManualDivorce) - .addComponent(chkUseClanPersonnelDivorce) - .addComponent(chkUsePrisonerDivorce) - .addComponent(pnlRandomDivorce))); + .addGroup(layout.createSequentialGroup() + .addComponent(pnlProcreationGeneralOptionsPanel) + .addComponent(pnlRandomProcreationPanel) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); // Create Parent Panel and return - return createParentPanel(panel, "DivorceTab"); + return createParentPanel(panel, "ProcreationTab"); + } + + /** + * @return the {@link JPanel} containing the procreation settings components + */ + JPanel createProcreationGeneralOptionsPanel() { + // Contents + chkUseManualProcreation = createCheckBox("UseManualProcreation", null); + chkUseClanPersonnelProcreation = createCheckBox("UseClanPersonnelProcreation", null); + chkUsePrisonerProcreation = createCheckBox("UsePrisonerProcreation", null); + + lblMultiplePregnancyOccurrences = createLabel("MultiplePregnancyOccurrences", null); + spnMultiplePregnancyOccurrences = createSpinner("MultiplePregnancyOccurrences", null, + 50, 1, 1000, 1); + + lblBabySurnameStyle = createLabel("BabySurnameStyle", null); + comboBabySurnameStyle.setRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(final JList list, final Object value, + final int index, final boolean isSelected, + final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof BabySurnameStyle) { + list.setToolTipText(((BabySurnameStyle) value).getToolTipText()); + } + return this; + } + }); + + chkAssignNonPrisonerBabiesFounderTag = createCheckBox("AssignNonPrisonerBabiesFounderTag", + null); + chkAssignChildrenOfFoundersFounderTag = createCheckBox("AssignChildrenOfFoundersFounderTag", + null); + chkDetermineFatherAtBirth = createCheckBox("DetermineFatherAtBirth", null); + chkDisplayTrueDueDate = createCheckBox("DisplayTrueDueDate", null); + + lblNoInterestInChildrenDiceSize = createLabel("NoInterestInChildrenDiceSize", null); + spnNoInterestInChildrenDiceSize = createSpinner("NoInterestInChildrenDiceSize", null, + 3, 1, 100000, 1); + + chkUseMaternityLeave = createCheckBox("UseMaternityLeave", null); + chkLogProcreation = createCheckBox("LogProcreation", null); + + pnlRandomProcreationPanel = createRandomProcreationPanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("ProcreationGeneralOptionsPanel", + false, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(chkUseManualProcreation) + .addComponent(chkUseClanPersonnelProcreation) + .addComponent(chkUsePrisonerProcreation) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblMultiplePregnancyOccurrences) + .addComponent(spnMultiplePregnancyOccurrences)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblBabySurnameStyle) + .addComponent(comboBabySurnameStyle)) + .addComponent(chkAssignNonPrisonerBabiesFounderTag) + .addComponent(chkAssignChildrenOfFoundersFounderTag) + .addComponent(chkDetermineFatherAtBirth) + .addComponent(chkDisplayTrueDueDate) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblNoInterestInChildrenDiceSize) + .addComponent(spnNoInterestInChildrenDiceSize)) + .addComponent(chkUseMaternityLeave) + .addComponent(chkLogProcreation)); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(chkUseManualProcreation) + .addComponent(chkUseClanPersonnelProcreation) + .addComponent(chkUsePrisonerProcreation) + .addGroup(layout.createSequentialGroup() + .addComponent(lblMultiplePregnancyOccurrences) + .addComponent(spnMultiplePregnancyOccurrences) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblBabySurnameStyle) + .addComponent(comboBabySurnameStyle) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkAssignNonPrisonerBabiesFounderTag) + .addComponent(chkAssignChildrenOfFoundersFounderTag) + .addComponent(chkDetermineFatherAtBirth) + .addComponent(chkDisplayTrueDueDate) + .addGroup(layout.createSequentialGroup() + .addComponent(lblNoInterestInChildrenDiceSize) + .addComponent(spnNoInterestInChildrenDiceSize) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkUseMaternityLeave) + .addComponent(chkLogProcreation))); + + return panel; + } + + /** + * @return a {@link JPanel} containing the configured components for random procreation settings + */ + JPanel createRandomProcreationPanel() { + // Contents + lblRandomProcreationMethod = createLabel("RandomProcreationMethod", null); + comboRandomProcreationMethod.setRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(final JList list, final Object value, + final int index, final boolean isSelected, + final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof RandomProcreationMethod) { + list.setToolTipText(((RandomProcreationMethod) value).getToolTipText()); + } + return this; + } + }); + + chkUseRelationshiplessRandomProcreation =createCheckBox("UseRelationshiplessRandomProcreation", + null); + chkUseRandomClanPersonnelProcreation = createCheckBox("UseRandomClanPersonnelProcreation", + null); + chkUseRandomPrisonerProcreation = createCheckBox("UseRandomPrisonerProcreation", null); + + lblRandomProcreationRelationshipDiceSize = createLabel("RandomProcreationRelationshipDiceSize", + null); + spnRandomProcreationRelationshipDiceSize = createSpinner("RandomProcreationRelationshipDiceSize", + null, 621, 0, 100000, 1); + + lblRandomProcreationRelationshiplessDiceSize = createLabel("RandomProcreationRelationshiplessDiceSize", + null); + spnRandomProcreationRelationshiplessDiceSize = createSpinner("RandomProcreationRelationshiplessDiceSize", + null, 1861, 0, 100000, 1); + + // Layout the Panel + final JPanel panel = createStandardPanel("RandomProcreationPanel", true, + "RandomProcreationPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblRandomProcreationMethod) + .addComponent(comboRandomProcreationMethod)) + .addComponent(chkUseRelationshiplessRandomProcreation) + .addComponent(chkUseRandomClanPersonnelProcreation) + .addComponent(chkUseRandomPrisonerProcreation) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblRandomProcreationRelationshipDiceSize) + .addComponent(spnRandomProcreationRelationshipDiceSize)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblRandomProcreationRelationshiplessDiceSize) + .addComponent(spnRandomProcreationRelationshiplessDiceSize))); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblRandomProcreationMethod) + .addComponent(comboRandomProcreationMethod) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkUseRelationshiplessRandomProcreation) + .addComponent(chkUseRandomClanPersonnelProcreation) + .addComponent(chkUseRandomPrisonerProcreation) + .addGroup(layout.createSequentialGroup() + .addComponent(lblRandomProcreationRelationshipDiceSize) + .addComponent(spnRandomProcreationRelationshipDiceSize) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblRandomProcreationRelationshiplessDiceSize) + .addComponent(spnRandomProcreationRelationshiplessDiceSize) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + + return panel; } } From c7533e7f9bb35cd3e47480021162985b39059c86 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 10 Oct 2024 17:58:07 -0500 Subject: [PATCH 038/117] Add Death Tab to Campaign Options Introduced a new Death tab in the Campaign Options pane, including various settings for simulating character deaths such as random death methods and death by age group. Implemented corresponding UI components and placeholders in the properties file. --- .../NEWCampaignOptionsDialog.properties | 38 ++++- .../tabs/CampaignOptionsPane.java | 3 +- .../campaignOptions/tabs/LifePathsTab.java | 138 ++++++++++++++++++ 3 files changed, 177 insertions(+), 2 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 7e4a1b41f2..0482dac602 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -600,6 +600,11 @@ procreationTab.border="In this galaxy, raising kids is tougher than raising a la \ come with an instruction manual."\
- Captain Dani "Ironheart" Cole, Steel Talon Company +deathTab.title=Death +deathTab.border="In the cockpit, death is never far away, but neither is life. Every battle reminds us\ + \ that it's the moments in between that matter most."
- Colonel Viktor "Ironhand" Selwyn, Stormguard\ + \ Command + # createGeneralTab lblLifePathsGeneralTab.text=General Options lblLifePathsGeneralTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ @@ -787,4 +792,35 @@ lblUseRandomPrisonerProcreation.tooltip=PLACEHOLDER lblRandomProcreationRelationshipDiceSize.text=Normal Procreation Chance: 1 in lblRandomProcreationRelationshipDiceSize.tooltip=PLACEHOLDER lblRandomProcreationRelationshiplessDiceSize.text=Relationshipless Procreation Chance: 1 in -lblRandomProcreationRelationshiplessDiceSize.tooltip=PLACEHOLDER \ No newline at end of file +lblRandomProcreationRelationshiplessDiceSize.tooltip=PLACEHOLDER + +# createDeathTab +lblDeathTab.text=Death Options +lblDeathTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblKeepMarriedNameUponSpouseDeath.text=Keep Married Name on Spouse Death +lblKeepMarriedNameUponSpouseDeath.tooltip=PLACEHOLDER +lblRandomDeathMethod.text=Random Death Method +lblRandomDeathMethod.tooltip=PLACEHOLDER +lblUseRandomClanPersonnelDeath.text=Enable Random Clan Death +lblUseRandomClanPersonnelDeath.tooltip=PLACEHOLDER +lblUseRandomPrisonerDeath.text=Enable Random Prisoner Death +lblUseRandomPrisonerDeath.tooltip=PLACEHOLDER +lblUseRandomDeathSuicideCause.text=Enable Cause of Death: Suicide +lblUseRandomDeathSuicideCause.tooltip=PLACEHOLDER +lblPercentageRandomDeathChance.text=Random Death Percentage +lblPercentageRandomDeathChance.tooltip=PLACEHOLDER + +# createDeathAgeGroupsPanel +lblDeathAgeGroupsPanel.text=Enable Death by Age Group +lblBaby.text=Baby +lblToddler.text=Toddler +lblChild.text=Child +lblPre-teen.text=Pre-Teen +lblTeenager.text=Teenager +lblAdult.text=Adult +lblElder.text=Elder \ No newline at end of file diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index e552ee8a9a..6bbf8bd443 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -128,7 +128,8 @@ private JTabbedPane createHumanResourcesParentTab() { "backgroundsTab", lifePathsTab.createBackgroundsTab(), "marriageTab", lifePathsTab.createMarriageTab(), "divorceTab", lifePathsTab.createDivorceTab(), - "procreationTab", lifePathsTab.createProcreationTab())); + "procreationTab", lifePathsTab.createProcreationTab(), + "deathTab", lifePathsTab.createDeathTab())); // Turnover and Retention // Name and Portrait Generation diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java index f5ce23af03..d10d4501bf 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java @@ -14,6 +14,8 @@ import java.awt.*; import java.util.ArrayList; import java.util.Comparator; +import java.util.HashMap; +import java.util.Map; import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; @@ -134,6 +136,20 @@ public class LifePathsTab { private JSpinner spnRandomProcreationRelationshiplessDiceSize; //end Procreation Tab + //start Death Tab + private JCheckBox chkKeepMarriedNameUponSpouseDeath; + private JLabel lblRandomDeathMethod; + private MMComboBox comboRandomDeathMethod; + private JCheckBox chkUseRandomClanPersonnelDeath; + private JCheckBox chkUseRandomPrisonerDeath; + private JCheckBox chkUseRandomDeathSuicideCause; + private JLabel lblPercentageRandomDeathChance; + private JSpinner spnPercentageRandomDeathChance; + + private JPanel pnlDeathAgeGroup; + private Map chkEnabledRandomDeathAgeGroups; + //end Death Tab + /** * Represents a tab for repair and maintenance in an application. */ @@ -260,6 +276,19 @@ protected void initialize() { spnRandomProcreationRelationshipDiceSize = new JSpinner(); lblRandomProcreationRelationshiplessDiceSize = new JLabel(); spnRandomProcreationRelationshiplessDiceSize = new JSpinner(); + + // Death Tab + chkKeepMarriedNameUponSpouseDeath = new JCheckBox(); + lblRandomDeathMethod = new JLabel(); + comboRandomDeathMethod = new MMComboBox<>("comboRandomDeathMethod", RandomDeathMethod.values()); + chkUseRandomClanPersonnelDeath = new JCheckBox(); + chkUseRandomPrisonerDeath = new JCheckBox(); + chkUseRandomDeathSuicideCause = new JCheckBox(); + lblPercentageRandomDeathChance = new JLabel(); + spnPercentageRandomDeathChance = new JSpinner(); + + pnlDeathAgeGroup = new JPanel(); + chkEnabledRandomDeathAgeGroups = new HashMap<>(); } /** @@ -1150,4 +1179,113 @@ public Component getListCellRendererComponent(final JList list, final Object return panel; } + + /** + * Creates and returns a {@link JPanel} for the Death Tab. + * The panel includes header, various checkboxes, labels, spinners, and a custom combo box. + * + * @return {@link JPanel} representing the Death Tab with all its components + */ + JPanel createDeathTab() { + // Header + JPanel headerPanel = createHeaderPanel("DeathTab", + getImageDirectory() + "logo_filtvelt_coalition.png", + false, "", true); + + // Contents + chkKeepMarriedNameUponSpouseDeath = createCheckBox("KeepMarriedNameUponSpouseDeath", + null); + + lblRandomDeathMethod = createLabel("RandomDeathMethod", null); + comboRandomDeathMethod.setRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(final JList list, final Object value, + final int index, final boolean isSelected, + final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof RandomDeathMethod) { + list.setToolTipText(((RandomDeathMethod) value).getToolTipText()); + } + return this; + } + }); + + chkUseRandomClanPersonnelDeath = createCheckBox("UseRandomClanPersonnelDeath", + null); + chkUseRandomPrisonerDeath = createCheckBox("UseRandomPrisonerDeath", null); + chkUseRandomDeathSuicideCause = createCheckBox("UseRandomDeathSuicideCause", null); + + pnlDeathAgeGroup = createDeathAgeGroupsPanel(); + + lblPercentageRandomDeathChance = createLabel("PercentageRandomDeathChance", null); + spnPercentageRandomDeathChance = createSpinner("PercentageRandomDeathChance", null, + 0, 0, 100, 0.000001); + + // Layout the Panel + final JPanel panel = createStandardPanel("DeathTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addComponent(chkKeepMarriedNameUponSpouseDeath) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblRandomDeathMethod) + .addComponent(comboRandomDeathMethod)) + .addComponent(chkUseRandomClanPersonnelDeath) + .addComponent(chkUseRandomPrisonerDeath) + .addComponent(chkUseRandomDeathSuicideCause) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPercentageRandomDeathChance) + .addComponent(spnPercentageRandomDeathChance)) + .addComponent(pnlDeathAgeGroup)); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addComponent(chkKeepMarriedNameUponSpouseDeath) + .addGroup(layout.createSequentialGroup() + .addComponent(lblRandomDeathMethod) + .addComponent(comboRandomDeathMethod) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkUseRandomClanPersonnelDeath) + .addComponent(chkUseRandomPrisonerDeath) + .addComponent(chkUseRandomDeathSuicideCause) + .addGroup(layout.createSequentialGroup() + .addComponent(lblPercentageRandomDeathChance) + .addComponent(spnPercentageRandomDeathChance) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(pnlDeathAgeGroup))); + + // Create Parent Panel and return + return createParentPanel(panel, "DeathTab"); + } + + /** + * Creates a panel for the Death Age Groups tab with checkboxes for different age groups + * + * @return a {@link JPanel} representing the Death Age Groups tab with checkboxes for each age group + */ + JPanel createDeathAgeGroupsPanel() { + final AgeGroup[] ageGroups = AgeGroup.values(); + + // Create the Panel + final JPanel panel = createStandardPanel("DeathAgeGroupsPanel", true, + "DeathAgeGroupsPanel"); + panel.setLayout(new GridLayout(1, ageGroups.length)); + + // Contents + for (final AgeGroup ageGroup : ageGroups) { + final JCheckBox checkBox = new JCheckBox(ageGroup.toString()); + checkBox.setToolTipText(ageGroup.getToolTipText()); + checkBox.setName("chk" + ageGroup); + + panel.add(checkBox); + chkEnabledRandomDeathAgeGroups.put(ageGroup, checkBox); + } + + return panel; + } } From 42d188a3c3077a1821b83628362005fb026b964e Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 10 Oct 2024 19:58:37 -0500 Subject: [PATCH 039/117] Rename and expand TurnoverAndRetention class Renamed TurnoverAndRetention.java to TurnoverAndRetentionTab.java to better reflect its extended functionality. Added comprehensive GUI elements for configuring turnover and fatigue settings, including numerous panels, checkboxes, labels, and spinners. Enhanced the structure and layout using Swing components to provide a detailed and user-friendly experience. --- .../NEWCampaignOptionsDialog.properties | 130 ++- .../tabs/CampaignOptionsPane.java | 8 + .../campaignOptions/tabs/LifePathsTab.java | 15 +- .../tabs/TurnoverAndRetention.java | 4 - .../tabs/TurnoverAndRetentionTab.java | 816 ++++++++++++++++++ 5 files changed, 967 insertions(+), 6 deletions(-) delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetention.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 0482dac602..1ee75d06c1 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -823,4 +823,132 @@ lblChild.text=Child lblPre-teen.text=Pre-Teen lblTeenager.text=Teenager lblAdult.text=Adult -lblElder.text=Elder \ No newline at end of file +lblElder.text=Elder + +# Life Paths Tab +turnoverAndRetentionContentTabs.title=Turnover & Retention + +turnoverTab.title=Turnover +turnoverTab.border="For a MekWarrior, retirement is a strange thing. We spend our lives in battle,\ + \ and when the guns go silent, we find out who we are without them."\ +
- Colonel Sofia "Whisper" Talon, Ironclad Irregulars + +fatigueTab.title=Fatigue +fatigueTab.border="Fatigue doesn't just slow you down; it makes you sloppy. And sloppy gets you killed."\ +
- Lieutenant Kayla "Quickdraw" Frost, Shadow Talon Mercs + +# createTurnoverTab +lblTurnoverTab.text=Turnover Options +lblTurnoverTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblUseRandomRetirement.text=Enable Random Turnover +lblUseRandomRetirement.tooltip=PLACEHOLDER + +# createSettingsPanel +lblSettingsPanel.text=Settings +lblTurnoverFixedTargetNumber.text=Target Number +lblTurnoverFixedTargetNumber.tooltip=PLACEHOLDER +lblTurnoverFrequency.text=Frequency +lblTurnoverFrequency.tooltip=PLACEHOLDER +lblUseContractCompletionRandomRetirement.text=Enable End of Contract Turnover +lblUseContractCompletionRandomRetirement.tooltip=PLACEHOLDER +lblUseRandomFounderTurnover.text=Enable Founder Turnover +lblUseRandomFounderTurnover.tooltip=PLACEHOLDER +lblTrackOriginalUnit.text=Track Original Unit +lblTrackOriginalUnit.tooltip=PLACEHOLDER +lblAeroRecruitsHaveUnits.text=AeroTek Recruits Have Units +lblAeroRecruitsHaveUnits.tooltip=PLACEHOLDER +lblUseSubContractSoldiers.text=Sub-Contract Soldiers +lblUseSubContractSoldiers.tooltip=PLACEHOLDER +lblServiceContractDuration.text=Service Contract Duration +lblServiceContractDuration.tooltip=PLACEHOLDER +lblServiceContractModifier.text=Service Contract Modifier +lblServiceContractModifier.tooltip=PLACEHOLDER +lblPayBonusDefault.text=Automate Retention Bonuses +lblPayBonusDefault.tooltip=PLACEHOLDER +lblPayBonusDefaultThreshold.text=Bonus Threshold +lblPayBonusDefaultThreshold.tooltip=PLACEHOLDER + +# createModifiersPanel +lblTurnoverModifiersPanel.text=Modifiers +lblUseCustomRetirementModifiers.text=Custom +lblUseCustomRetirementModifiers.tooltip=PLACEHOLDER +lblUseFatigueModifiers.text=Fatigue Modifiers +lblUseFatigueModifiers.tooltip=PLACEHOLDER +lblUseSkillModifiers.text=Desirability +lblUseSkillModifiers.tooltip=PLACEHOLDER +lblUseAgeModifiers.text=Age +lblUseAgeModifiers.tooltip=PLACEHOLDER +lblUseUnitRatingModifiers.text=Unit Reputation +lblUseUnitRatingModifiers.tooltip=PLACEHOLDER +lblUseFactionModifiers.text=Faction +lblUseFactionModifiers.tooltip=PLACEHOLDER +lblUseMissionStatusModifiers.text=Mission Status +lblUseMissionStatusModifiers.tooltip=PLACEHOLDER +lblUseHostileTerritoryModifiers.text=Hostile Territory +lblUseHostileTerritoryModifiers.tooltip=PLACEHOLDER +lblUseFamilyModifiers.text=Family +lblUseFamilyModifiers.tooltip=PLACEHOLDER +lblUseLoyaltyModifiers.text=Loyalty +lblUseLoyaltyModifiers.tooltip=PLACEHOLDER +lblUseHideLoyalty.text=Hide Loyalty +lblUseHideLoyalty.tooltip=PLACEHOLDER + +# createPayoutsPanel +lblPayoutsPanel.text=Payouts +lblPayoutRateOfficer.text=Officer Rate +lblPayoutRateOfficer.tooltip=PLACEHOLDER +lblPayoutRateEnlisted.text=Enlisted Rate +lblPayoutRateEnlisted.tooltip=PLACEHOLDER +lblPayoutRetirementMultiplier.text=Retirement Multiplier +lblPayoutRetirementMultiplier.tooltip=PLACEHOLDER +lblUsePayoutServiceBonus.text=Enable Service Bonuses +lblUsePayoutServiceBonus.tooltip=PLACEHOLDER +lblPayoutServiceBonusRate.text=Bonus % +lblPayoutServiceBonusRate.tooltip=PLACEHOLDER + +# createUnitCohesionPanel +lblUnitCohesionPanel.text=Unit Cohesion +lblUseAdministrativeStrain.text=Enable Administrative Strain +lblUseAdministrativeStrain.tooltip=PLACEHOLDER +lblUseManagementSkill.text=Enable Management Skill +lblUseManagementSkill.tooltip=PLACEHOLDER + +# createAdministrativeStrainPanel +lblAdministrativeStrain.text=Administrative Strain +lblAdministrativeCapacity.text=Administrative Capacity +lblAdministrativeCapacity.tooltip=PLACEHOLDER +lblMultiCrewStrainDivider.text=Multi-Crew Strain Divider +lblMultiCrewStrainDivider.tooltip=PLACEHOLDER + +# createManagementSkill +lblManagementSkill.text=Management Skill +lblUseCommanderLeadershipOnly.text=Use Commander's Leadership Only +lblUseCommanderLeadershipOnly.tooltip=PLACEHOLDER +lblManagementSkillPenalty.text=Unskilled Penalty +lblManagementSkillPenalty.tooltip=PLACEHOLDER + +# createFatigueTab +lblFatigueTab.text=Fatigue Options +lblFatigueTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblUseFatigue.text=Enable Fatigue +lblUseFatigue.tooltip=PLACEHOLDER +lblFatigueRate.text=Fatigue Rate +lblFatigueRate.tooltip=PLACEHOLDER +lblUseInjuryFatigue.text=Injuries Increase Fatigue +lblUseInjuryFatigue.tooltip=PLACEHOLDER +lblFieldKitchenCapacity.text=Field Kitchen Capacity +lblFieldKitchenCapacity.tooltip=PLACEHOLDER +lblFieldKitchenIgnoreNonCombatants.text=Ignore Non-Combatants +lblFieldKitchenIgnoreNonCombatants.tooltip=PLACEHOLDER +lblFatigueLeaveThreshold.text=Automatic Leave Threshold +lblFatigueLeaveThreshold.tooltip=PLACEHOLDER \ No newline at end of file diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 6bbf8bd443..cc2b602715 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -132,6 +132,12 @@ private JTabbedPane createHumanResourcesParentTab() { "deathTab", lifePathsTab.createDeathTab())); // Turnover and Retention + TurnoverAndRetentionTab turnoverAndRetentionTab = new TurnoverAndRetentionTab(getFrame(), + "turnoverAndRetentionTab"); + + JTabbedPane turnoverAndRetentionContentTabs = createSubTabs(Map.of( + "turnoverTab", turnoverAndRetentionTab.createTurnoverTab(), + "fatigueTab", turnoverAndRetentionTab.createFatigueTab())); // Name and Portrait Generation // Rank Systems @@ -140,6 +146,8 @@ private JTabbedPane createHumanResourcesParentTab() { resources.getString("personnelContentTabs.title")), personnelContentTabs); humanResourcesParentTab.addTab(String.format("%s", 4, resources.getString("lifePathsContentTabs.title")), lifePathsContentTabs); + humanResourcesParentTab.addTab(String.format("%s", 4, + resources.getString("turnoverAndRetentionContentTabs.title")), turnoverAndRetentionContentTabs); addTab(String.format("%s", 4, resources.getString("humanResourcesParentTab.title")), humanResourcesParentTab); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java index d10d4501bf..3f014db3f2 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java @@ -151,7 +151,11 @@ public class LifePathsTab { //end Death Tab /** - * Represents a tab for repair and maintenance in an application. + * Initializes a new {@link LifePathsTab} with the specified campaign, frame, and name. + * + * @param campaign the campaign associated with the {@link LifePathsTab} + * @param frame the {@link JFrame} used for displaying the {@link LifePathsTab} + * @param name the name of the {@link LifePathsTab} */ LifePathsTab(Campaign campaign, JFrame frame, String name) { this.campaign = campaign; @@ -161,6 +165,15 @@ public class LifePathsTab { initialize(); } + /** + * Initializes the state and the UI components for the settings panels. + * This includes General, Backgrounds, Marriage, Divorce, Procreation, and Death panels. + * Each panel contains multiple aspects of settings such as Randomization, Dice Size, Display of + * Anniversaries, Handling of Origin Options, Marriage & Divorce parameters, Probabilities related + * to Procreation, and settings for Death scenarios among others. + * {@link JCheckBox}, {@link JLabel}, {@link JSlider}, {@link JSpinner} and {@link MMComboBox} + * components are thoroughly initialized in this method for handling various settings options. + */ protected void initialize() { // General Tab chkUseDylansRandomXP = new JCheckBox(); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetention.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetention.java deleted file mode 100644 index 93f1a71445..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetention.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.tabs; - -public class TurnoverAndRetention { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java new file mode 100644 index 0000000000..7214f4e2d0 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java @@ -0,0 +1,816 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +import megamek.client.ui.baseComponents.MMComboBox; +import mekhq.campaign.personnel.enums.TurnoverFrequency; + +import javax.swing.*; +import javax.swing.GroupLayout.Alignment; +import java.awt.*; + +import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; + +/** + * This class represents a GUI configuration form with two main tabs: 'Turnover' and 'Fatigue'. + *

+ * These tabs contain various controls for user input and selection including checkboxes, spinners + * and combo boxes. These configurations cover a wide range of settings, categorized into panels that + * include settings, modifiers, payouts, unit cohesion, administrative strain, and management skill + * panels for the 'Turnover' tab, and fatigue configurations for the 'Fatigue' tab. + *

+ * The class uses Swing, a Java GUI toolkit, to create these controls. A {@link JFrame} object is used + * to contain the tab structure, which itself contains various {@link JPanel} instances to group related + * settings. + *

+ * Use of this class involves calling the constructor with a {@link JFrame} parent and the name of the + * tab, and then adding the resulting object to a Swing container. The various public methods in the + * class are then called in response to user interactions with the GUI. + */ +public class TurnoverAndRetentionTab { + JFrame frame; + String name; + + //start Turnover Tab + private JCheckBox chkUseRandomRetirement; + + private JPanel pnlSettings; + private JLabel lblTurnoverFixedTargetNumber; + private JSpinner spnTurnoverFixedTargetNumber; + private JLabel lblTurnoverFrequency; + private MMComboBox comboTurnoverFrequency; + private JCheckBox chkUseContractCompletionRandomRetirement; + private JCheckBox chkUseRandomFounderTurnover; + private JCheckBox chkTrackOriginalUnit; + private JCheckBox chkAeroRecruitsHaveUnits; + private JCheckBox chkUseSubContractSoldiers; + private JLabel lblServiceContractDuration; + private JSpinner spnServiceContractDuration; + private JLabel lblServiceContractModifier; + private JSpinner spnServiceContractModifier; + private JCheckBox chkPayBonusDefault; + private JLabel lblPayBonusDefaultThreshold; + private JSpinner spnPayBonusDefaultThreshold; + + private JPanel pnlModifiers; + private JCheckBox chkUseCustomRetirementModifiers; + private JCheckBox chkUseFatigueModifiers; + private JCheckBox chkUseSkillModifiers; + private JCheckBox chkUseAgeModifiers; + private JCheckBox chkUseUnitRatingModifiers; + private JCheckBox chkUseFactionModifiers; + private JCheckBox chkUseMissionStatusModifiers; + private JCheckBox chkUseHostileTerritoryModifiers; + private JCheckBox chkUseFamilyModifiers; + private JCheckBox chkUseLoyaltyModifiers; + private JCheckBox chkUseHideLoyalty; + + private JPanel pnlPayout; + private JLabel lblPayoutRateOfficer; + private JSpinner spnPayoutRateOfficer; + private JLabel lblPayoutRateEnlisted; + private JSpinner spnPayoutRateEnlisted; + private JLabel lblPayoutRetirementMultiplier; + private JSpinner spnPayoutRetirementMultiplier; + private JCheckBox chkUsePayoutServiceBonus; + private JLabel lblPayoutServiceBonusRate; + private JSpinner spnPayoutServiceBonusRate; + + private JPanel pnlUnitCohesion; + + private JPanel pnlAdministrativeStrainWrapper; + private JCheckBox chkUseAdministrativeStrain; + + private JPanel pnlAdministrativeStrain; + private JLabel lblAdministrativeCapacity; + private JSpinner spnAdministrativeCapacity; + private JLabel lblMultiCrewStrainDivider; + private JSpinner spnMultiCrewStrainDivider; + + private JPanel pnlManagementSkillWrapper; + private JCheckBox chkUseManagementSkill; + + private JPanel pnlManagementSkill; + private JCheckBox chkUseCommanderLeadershipOnly; + private JLabel lblManagementSkillPenalty; + private JSpinner spnManagementSkillPenalty; + //end Turnover Tab + + //start Fatigue Tab + private JCheckBox chkUseFatigue; + private JLabel lblFatigueRate; + private JSpinner spnFatigueRate; + private JCheckBox chkUseInjuryFatigue; + private JLabel lblFieldKitchenCapacity; + private JSpinner spnFieldKitchenCapacity; + private JCheckBox chkFieldKitchenIgnoreNonCombatants; + private JLabel lblFatigueLeaveThreshold; + private JSpinner spnFatigueLeaveThreshold; + //end Fatigue Tab + + /** + * Constructs and configures a {@link TurnoverAndRetentionTab} instance. + * This constructor receives a {@link JFrame} and a name string, assigns them to the instance + * variables 'frame' and 'name', and then calls the initilize method to initialize the components + * of the tabs. + * + * @param frame the {@link JFrame} to be assigned to this tab's frame + * @param name the name to be assigned to this tab's name + */ + TurnoverAndRetentionTab(JFrame frame, String name) { + this.frame = frame; + this.name = name; + + initialize(); + } + + /** + * Initializes and configures the components that will be used in the Turnover and Fatigue tabs. + *

+ * Components initialized include various check boxes, labels, spinners and panels necessary for + * the configuration of these tab panels. Almost all components necessary in these tabs are + * initialized here. + */ + protected void initialize() { + // Turnover Tab + chkUseRandomRetirement = new JCheckBox(); + + pnlSettings = new JPanel(); + lblTurnoverFixedTargetNumber = new JLabel(); + spnTurnoverFixedTargetNumber = new JSpinner(); + lblTurnoverFrequency = new JLabel(); + comboTurnoverFrequency = new MMComboBox<>("comboTurnoverFrequency", TurnoverFrequency.values()); + chkUseContractCompletionRandomRetirement = new JCheckBox(); + chkUseRandomFounderTurnover = new JCheckBox(); + chkTrackOriginalUnit = new JCheckBox(); + chkAeroRecruitsHaveUnits = new JCheckBox(); + chkUseSubContractSoldiers = new JCheckBox(); + lblServiceContractDuration = new JLabel(); + spnServiceContractDuration = new JSpinner(); + lblServiceContractModifier = new JLabel(); + spnServiceContractModifier = new JSpinner(); + chkPayBonusDefault = new JCheckBox(); + lblPayBonusDefaultThreshold = new JLabel(); + spnPayBonusDefaultThreshold = new JSpinner(); + + pnlModifiers = new JPanel(); + chkUseCustomRetirementModifiers = new JCheckBox(); + chkUseFatigueModifiers = new JCheckBox(); + chkUseSkillModifiers = new JCheckBox(); + chkUseAgeModifiers = new JCheckBox(); + chkUseUnitRatingModifiers = new JCheckBox(); + chkUseFactionModifiers = new JCheckBox(); + chkUseMissionStatusModifiers = new JCheckBox(); + chkUseHostileTerritoryModifiers = new JCheckBox(); + chkUseFamilyModifiers = new JCheckBox(); + chkUseLoyaltyModifiers = new JCheckBox(); + chkUseHideLoyalty = new JCheckBox(); + + pnlPayout = new JPanel(); + lblPayoutRateOfficer = new JLabel(); + spnPayoutRateOfficer = new JSpinner(); + lblPayoutRateEnlisted = new JLabel(); + spnPayoutRateEnlisted = new JSpinner(); + lblPayoutRetirementMultiplier = new JLabel(); + spnPayoutRetirementMultiplier = new JSpinner(); + chkUsePayoutServiceBonus = new JCheckBox(); + lblPayoutServiceBonusRate = new JLabel(); + spnPayoutServiceBonusRate = new JSpinner(); + + pnlUnitCohesion = new JPanel(); + + pnlAdministrativeStrainWrapper = new JPanel(); + chkUseAdministrativeStrain = new JCheckBox(); + + pnlAdministrativeStrain = new JPanel(); + lblAdministrativeCapacity = new JLabel(); + spnAdministrativeCapacity = new JSpinner(); + lblMultiCrewStrainDivider = new JLabel(); + spnMultiCrewStrainDivider = new JSpinner(); + + pnlManagementSkillWrapper = new JPanel(); + chkUseManagementSkill = new JCheckBox(); + + pnlManagementSkill = new JPanel(); + chkUseCommanderLeadershipOnly = new JCheckBox(); + lblManagementSkillPenalty = new JLabel(); + spnManagementSkillPenalty = new JSpinner(); + + // Fatigue Tab + chkUseFatigue = new JCheckBox(); + lblFatigueRate = new JLabel(); + spnFatigueRate = new JSpinner(); + chkUseInjuryFatigue = new JCheckBox(); + lblFieldKitchenCapacity = new JLabel(); + spnFieldKitchenCapacity = new JSpinner(); + chkFieldKitchenIgnoreNonCombatants = new JCheckBox(); + lblFatigueLeaveThreshold = new JLabel(); + spnFatigueLeaveThreshold = new JSpinner(); + } + + /** + * Constructs and configures a panel for the Turnover tab. + * This tab contains a header panel, a checkbox for activating random retirement, settings, + * modifiers, payout, and unit cohesion panels. + *

+ * The layout of the tab panel is organized with a {@link GroupLayout} for clean vertical and + * horizontal alignment. + * + * @return panel the configured {@link JPanel} for the Turnover tab + */ + JPanel createTurnoverTab() { + // Header + JPanel headerPanel = createHeaderPanel("TurnoverTab", + getImageDirectory() + "logo_clan_jade_falcon.png", + false, "", true); + + // Contents + chkUseRandomRetirement = createCheckBox("UseRandomRetirement", null); + pnlSettings = createSettingsPanel(); + pnlModifiers = createModifiersPanel(); + pnlPayout = createPayoutsPanel(); + pnlUnitCohesion = createUnitCohesionPanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("TurnoverTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addComponent(chkUseRandomRetirement) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(pnlSettings) + .addComponent(pnlModifiers) + .addComponent(pnlPayout)) + .addComponent(pnlUnitCohesion)); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addComponent(chkUseRandomRetirement) + .addGroup(layout.createSequentialGroup() + .addComponent(pnlSettings) + .addComponent(pnlModifiers) + .addComponent(pnlPayout) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(pnlUnitCohesion))); + + // Create Parent Panel and return + return createParentPanel(panel, "TurnoverTab"); + } + + /** + * Constructs and configures a settings panel for controlling various turnover settings. + * This panel allows for configuration of turnover fixed target number, turnover frequency, + * contract completion, random retirement, random founder turnover, tracking of original unit, + * aero recruits having units, subcontracted soldiers, service contract duration and modifier, + * default payment bonus and payment bonus threshold. + *

+ * Each of these settings is either controlled by a checkbox or a spinner with a specific range. + * The turnover frequency selection is handled by a combo box. + * The layout of the panel is organized with a {@link GroupLayout}, ensuring organized vertical + * and horizontal alignment. + * + * @return panel the configured {@link JPanel} with various turnover settings + */ + JPanel createSettingsPanel() { + // Contents + lblTurnoverFixedTargetNumber = createLabel("TurnoverFixedTargetNumber", null); + spnTurnoverFixedTargetNumber = createSpinner("TurnoverFixedTargetNumber", null, + 3, 0, 10, 1); + + lblTurnoverFrequency = createLabel("TurnoverFrequency", null); + comboTurnoverFrequency.setRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(final JList list, final Object value, + final int index, final boolean isSelected, + final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof TurnoverFrequency) { + list.setToolTipText(((TurnoverFrequency) value).getToolTipText()); + } + return this; + } + }); + + chkUseContractCompletionRandomRetirement = createCheckBox( + "UseContractCompletionRandomRetirement", null); + + chkUseRandomFounderTurnover = createCheckBox("UseRandomFounderTurnover", null); + + chkTrackOriginalUnit = createCheckBox("TrackOriginalUnit", null); + + chkAeroRecruitsHaveUnits = createCheckBox("AeroRecruitsHaveUnits", null); + + chkUseSubContractSoldiers = createCheckBox("UseSubContractSoldiers", null); + + lblServiceContractDuration = createLabel("ServiceContractDuration", null); + spnServiceContractDuration = createSpinner("ServiceContractDuration", null, + 36, 0, 120, 1); + + lblServiceContractModifier = createLabel("ServiceContractModifier", null); + spnServiceContractModifier = createSpinner("ServiceContractModifier", null, + 3, 0, 10, 1); + + chkPayBonusDefault = createCheckBox("PayBonusDefault", null); + + lblPayBonusDefaultThreshold = createLabel("PayBonusDefaultThreshold", null); + spnPayBonusDefaultThreshold = createSpinner("PayBonusDefaultThreshold", null, + 3, 0, 12, 1); + + // Layout the Panel + final JPanel panel = createStandardPanel("SettingsPanel", true, + "SettingsPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblTurnoverFixedTargetNumber) + .addComponent(spnTurnoverFixedTargetNumber)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblTurnoverFrequency) + .addComponent(comboTurnoverFrequency)) + .addComponent(chkUseContractCompletionRandomRetirement) + .addComponent(chkUseRandomFounderTurnover) + .addComponent(chkTrackOriginalUnit) + .addComponent(chkAeroRecruitsHaveUnits) + .addComponent(chkUseSubContractSoldiers) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblServiceContractDuration) + .addComponent(spnServiceContractDuration)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblServiceContractModifier) + .addComponent(spnServiceContractModifier)) + .addComponent(chkPayBonusDefault) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPayBonusDefaultThreshold) + .addComponent(spnPayBonusDefaultThreshold))); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblTurnoverFixedTargetNumber) + .addComponent(spnTurnoverFixedTargetNumber) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblTurnoverFrequency) + .addComponent(comboTurnoverFrequency) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkUseContractCompletionRandomRetirement) + .addComponent(chkUseRandomFounderTurnover) + .addComponent(chkTrackOriginalUnit) + .addComponent(chkAeroRecruitsHaveUnits) + .addComponent(chkUseSubContractSoldiers) + .addGroup(layout.createSequentialGroup() + .addComponent(lblServiceContractDuration) + .addComponent(spnServiceContractDuration) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblServiceContractModifier) + .addComponent(spnServiceContractModifier) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkPayBonusDefault) + .addGroup(layout.createSequentialGroup() + .addComponent(lblPayBonusDefaultThreshold) + .addComponent(spnPayBonusDefaultThreshold) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + + return panel; + } + + /** + * Constructs and configures a settings panel for controlling various status modifiers. + * This panel offers checkboxes for toggling the use of custom retirement modifiers, fatigue modifiers, + * skill modifiers, age modifiers, unit rating modifiers, faction modifiers, mission status modifiers, + * hostile territory modifiers, family modifiers, loyalty modifiers, and the hiding of loyalty. + *

+ * Each of these settings is represented by a checkbox, allowing for them to be easily toggled + * on or off. The layout of the panel is organized with a {@link GroupLayout} for clean vertical + * and horizontal alignment. + * + * @return panel the configured {@link JPanel} with modifier settings + */ + JPanel createModifiersPanel() { + // Contents + chkUseCustomRetirementModifiers = createCheckBox("UseCustomRetirementModifiers", null); + chkUseFatigueModifiers = createCheckBox("UseFatigueModifiers", null); + chkUseSkillModifiers = createCheckBox("UseSkillModifiers", null); + chkUseAgeModifiers = createCheckBox("UseAgeModifiers", null); + chkUseUnitRatingModifiers = createCheckBox("UseUnitRatingModifiers", null); + chkUseFactionModifiers = createCheckBox("UseFactionModifiers", null); + chkUseMissionStatusModifiers = createCheckBox("UseMissionStatusModifiers", null); + chkUseHostileTerritoryModifiers = createCheckBox("UseHostileTerritoryModifiers", null); + chkUseFamilyModifiers = createCheckBox("UseFamilyModifiers", null); + chkUseLoyaltyModifiers = createCheckBox("UseLoyaltyModifiers", null); + chkUseHideLoyalty = createCheckBox("UseHideLoyalty", null); + + + // Layout the Panel + final JPanel panel = createStandardPanel("TurnoverModifiersPanel", true, + "ModifiersPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(chkUseCustomRetirementModifiers) + .addComponent(chkUseFatigueModifiers) + .addComponent(chkUseSkillModifiers) + .addComponent(chkUseAgeModifiers) + .addComponent(chkUseUnitRatingModifiers) + .addComponent(chkUseFactionModifiers) + .addComponent(chkUseMissionStatusModifiers) + .addComponent(chkUseHostileTerritoryModifiers) + .addComponent(chkUseFamilyModifiers) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(chkUseLoyaltyModifiers) + .addComponent(chkUseHideLoyalty))); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(chkUseCustomRetirementModifiers) + .addComponent(chkUseFatigueModifiers) + .addComponent(chkUseSkillModifiers) + .addComponent(chkUseAgeModifiers) + .addComponent(chkUseUnitRatingModifiers) + .addComponent(chkUseFactionModifiers) + .addComponent(chkUseMissionStatusModifiers) + .addComponent(chkUseHostileTerritoryModifiers) + .addComponent(chkUseFamilyModifiers) + .addGroup(layout.createSequentialGroup() + .addComponent(chkUseLoyaltyModifiers) + .addComponent(chkUseHideLoyalty) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + + return panel; + } + + /** + * Constructs and configures a settings panel for controlling payouts. + * This panel allows for configuration of officer and enlisted payout rates, as well as retirement + * multipliers and service bonus (if enabled). + *

+ * Each configurable setting is controlled by a spinner with a different acceptable range. + * The layout of the panel is organized with a {@link GroupLayout}, ensuring organized vertical + * and horizontal alignment. + * + * @return panel the configured {@link JPanel} with payout settings + */ + JPanel createPayoutsPanel() { + // Contents + lblPayoutRateOfficer = createLabel("PayoutRateOfficer", null); + spnPayoutRateOfficer = createSpinner("PayoutRateOfficer", null, + 3, 0, 12, 1); + + lblPayoutRateEnlisted = createLabel("PayoutRateEnlisted", null); + spnPayoutRateEnlisted = createSpinner("PayoutRateEnlisted", null, + 3, 0, 12, 1); + + lblPayoutRetirementMultiplier = createLabel("PayoutRetirementMultiplier", null); + spnPayoutRetirementMultiplier = createSpinner("PayoutRetirementMultiplier", null, + 24, 1, 120, 1); + + chkUsePayoutServiceBonus = createCheckBox("UsePayoutServiceBonus", null); + + lblPayoutServiceBonusRate = createLabel("PayoutServiceBonusRate", null); + spnPayoutServiceBonusRate = createSpinner("PayoutServiceBonusRate", null, + 10, 1, 100, 1); + + // Layout the Panel + final JPanel panel = createStandardPanel("PayoutsPanel", true, + "PayoutsPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPayoutRateOfficer) + .addComponent(spnPayoutRateOfficer)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPayoutRateEnlisted) + .addComponent(spnPayoutRateEnlisted)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPayoutRetirementMultiplier) + .addComponent(spnPayoutRetirementMultiplier)) + .addComponent(chkUsePayoutServiceBonus) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPayoutServiceBonusRate) + .addComponent(spnPayoutServiceBonusRate))); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblPayoutRateOfficer) + .addComponent(spnPayoutRateOfficer) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblPayoutRateEnlisted) + .addComponent(spnPayoutRateEnlisted) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblPayoutRetirementMultiplier) + .addComponent(spnPayoutRetirementMultiplier) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkUsePayoutServiceBonus) + .addGroup(layout.createSequentialGroup() + .addComponent(lblPayoutServiceBonusRate) + .addComponent(spnPayoutServiceBonusRate) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + + return panel; + } + + /** + * Constructs and configures a settings panel for controlling unit cohesion. + * This panel contains check boxes which toggle usage of administrative strain and management skill, + * along with their associated settings panels. + *

+ * The layout of the panel is organized with a {@link GroupLayout}, placing the components in a + * sequential order for vertical alignment and in a parallel formation for horizontal alignment. + * + * @return panel the configured {@link JPanel} with unit cohesion settings + */ + JPanel createUnitCohesionPanel() { + // Contents + pnlAdministrativeStrainWrapper = createAdministrativeStrainWrapperPanel(); + pnlManagementSkillWrapper = createManagementSkillWrapperPanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("UnitCohesionPanel", true, + "UnitCohesionPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(pnlAdministrativeStrainWrapper) + .addComponent(pnlManagementSkillWrapper))); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(pnlAdministrativeStrainWrapper) + .addComponent(pnlManagementSkillWrapper) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + + return panel; + } + + /** + * Constructs and configures an administrative strain wrapper {@link JPanel} with a checkbox and + * associated settings panel. + *

+ * The layout of the panel is organized in a {@link GroupLayout}, placing the checkbox and the + * settings panel sequentially for vertical alignment and in parallel for horizontal alignment. + * + * @return {@link JPanel} The newly created and configured JPanel containing administrative strain + * settings + */ + JPanel createAdministrativeStrainWrapperPanel() { + // Contents + chkUseAdministrativeStrain = createCheckBox("UseAdministrativeStrain", null); + pnlAdministrativeStrain = createAdministrativeStrainPanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("AdministrativeStrainPanel", false, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(chkUseAdministrativeStrain) + .addComponent(pnlAdministrativeStrain)); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(chkUseAdministrativeStrain) + .addComponent(pnlAdministrativeStrain))); + + return panel; + } + + /** + * Creates a settings panel for controlling administrative strain parameters. + * This panel includes settings for administrative capacity and multi-crew strain divider. + *

+ * The administrative capacity is a customizable setting, allowing selection between 1 and 30. + * The multi-crew strain divider is also a customizable setting, allowing selection between 1 and 25. + *

+ * The panel uses a {@link GroupLayout} for layout management, organizing the components in sequential + * and parallel groups for vertical and horizontal alignment respectively. + * + * @return panel the configured {@link JPanel} with administrative strain settings + */ + JPanel createAdministrativeStrainPanel() { + // Contents + lblAdministrativeCapacity = createLabel("AdministrativeCapacity", null); + spnAdministrativeCapacity = createSpinner("AdministrativeCapacity", null, + 10, 1, 30, 1); + + lblMultiCrewStrainDivider = createLabel("MultiCrewStrainDivider", null); + spnMultiCrewStrainDivider = createSpinner("MultiCrewStrainDivider", null, + 5, 1, 25, 1); + + // Layout the Panel + final JPanel panel = createStandardPanel("AdministrativeStrain", true, + "AdministrativeStrain"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblAdministrativeCapacity) + .addComponent(spnAdministrativeCapacity)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblMultiCrewStrainDivider) + .addComponent(spnMultiCrewStrainDivider))); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblAdministrativeCapacity) + .addComponent(spnAdministrativeCapacity) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblMultiCrewStrainDivider) + .addComponent(spnMultiCrewStrainDivider) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + + return panel; + } + + /** + * Creates and configures a settings panel for controlling management skills. + *

+ * This panel contains a checkbox for toggling management skill usage, along with an associated + * settings panel. + *

+ * The layout of the panel is organized with a {@link GroupLayout}, placing the components in a + * sequential order for vertical alignment and in a parallel formation for horizontal alignment. + * + * @return {@link JPanel} The constructed and configured jPanel containing the management skill settings + */ + JPanel createManagementSkillWrapperPanel() { + // Contents + chkUseManagementSkill = createCheckBox("UseManagementSkill", null); + pnlManagementSkill = createManagementSkill(); + + // Layout the Panel + final JPanel panel = createStandardPanel("UnitCohesionPanel", false, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(chkUseManagementSkill) + .addComponent(pnlManagementSkill)); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(chkUseManagementSkill) + .addComponent(pnlManagementSkill))); + + return panel; + } + + /** + * Creates a panel for management skill settings. + * This panel consists of a checkbox to enable/disable use of commander leadership only and + * a spinner to control the management skill penalty. + *

+ * The panel uses a {@link GroupLayout} for layout management, organizing its components + * in a sequential group for vertical alignment and a parallel group for horizontal alignment. + *

+ * The management skill penalty is a customizable setting, with the possibility + * to choose a value between -10 and 10. + * + * @return panel the configured {@link JPanel} with management skill settings + */ + JPanel createManagementSkill() { + // Contents + chkUseCommanderLeadershipOnly = createCheckBox("UseCommanderLeadershipOnly", null); + + lblManagementSkillPenalty = createLabel("ManagementSkillPenalty", null); + spnManagementSkillPenalty = createSpinner("ManagementSkillPenalty", null, + 0, -10, 10, 1); + + // Layout the Panel + final JPanel panel = createStandardPanel("ManagementSkill", true, + "ManagementSkill"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(chkUseCommanderLeadershipOnly) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblManagementSkillPenalty) + .addComponent(spnManagementSkillPenalty))); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(chkUseCommanderLeadershipOnly) + .addGroup(layout.createSequentialGroup() + .addComponent(lblManagementSkillPenalty) + .addComponent(spnManagementSkillPenalty) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + + return panel; + } + + /** + * Constructs and configures a panel for the Fatigue tab. + * This tab contains a header panel, a checkbox for activating fatigue, + * a spinner for adjusting the fatigue rate, a checkbox for toggling fatigue from injury, + * a spinner for adjusting field kitchen capacity, a checkbox for making field kitchens ignore + * non-combatants and a spinner for adjusting the fatigue leave threshold. + *

+ * The layout of the tab panel is organized with a {@link GroupLayout}, ensuring organized vertical + * and horizontal alignment. + * + * @return panel the configured {@link JPanel} for the Fatigue tab + */ + JPanel createFatigueTab() { + // Header + JPanel headerPanel = createHeaderPanel("FatigueTab", + getImageDirectory() + "logo_free_rasalhague_republic.png", + false, "", true); + + // Contents + chkUseFatigue = createCheckBox("UseFatigue", null); + + lblFatigueRate = createLabel("FatigueRate", null); + spnFatigueRate = createSpinner("FatigueRate", null, + 1, 1, 10, 1); + + chkUseInjuryFatigue = createCheckBox("UseInjuryFatigue", null); + + lblFieldKitchenCapacity = createLabel("FieldKitchenCapacity", null); + spnFieldKitchenCapacity = createSpinner("FieldKitchenCapacity", null, + 150, 0, 450, 1); + + chkFieldKitchenIgnoreNonCombatants = createCheckBox("FieldKitchenIgnoreNonCombatants", null); + + lblFatigueLeaveThreshold = createLabel("FatigueLeaveThreshold", null); + spnFatigueLeaveThreshold = createSpinner("FatigueLeaveThreshold", null, + 13, 0, 17, 1); + + // Layout the Panel + final JPanel panel = createStandardPanel("FatigueTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addComponent(chkUseFatigue) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblFatigueRate) + .addComponent(spnFatigueRate) + .addComponent(chkUseInjuryFatigue)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblFieldKitchenCapacity) + .addComponent(spnFieldKitchenCapacity) + .addComponent(chkFieldKitchenIgnoreNonCombatants)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblFatigueLeaveThreshold) + .addComponent(spnFatigueLeaveThreshold))); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addComponent(chkUseFatigue) + .addGroup(layout.createSequentialGroup() + .addComponent(lblFatigueRate) + .addComponent(spnFatigueRate) + .addComponent(chkUseInjuryFatigue) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblFieldKitchenCapacity) + .addComponent(spnFieldKitchenCapacity) + .addComponent(chkFieldKitchenIgnoreNonCombatants) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblFatigueLeaveThreshold) + .addComponent(spnFatigueLeaveThreshold) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + + // Create Parent Panel and return + return createParentPanel(panel, "FatigueTab"); + } +} From 56155f9c418c8b6bbaa80f06071b9a065b9a33f0 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 10 Oct 2024 20:22:35 -0500 Subject: [PATCH 040/117] Remove HTML formatting from text strings Replaced HTML tags with plain text in various labels to improve readability and maintain consistency across the user interface. Also updated component creation and layout handling in PersonnelTab.java to ensure proper alignment and sizing of labels and spinners. --- .../NEWCampaignOptionsDialog.properties | 179 ++++++------------ .../tabs/CampaignOptionsUtilities.java | 4 +- .../campaignOptions/tabs/PersonnelTab.java | 29 ++- 3 files changed, 81 insertions(+), 131 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 1ee75d06c1..9c7a41eb26 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -25,21 +25,21 @@ lblGeneral.text=Welcome, Commander lblGeneralBody.text=

"Mercenary life is freedom with a price.\
Every contract is a choice, but every choice comes with a consequence."\
- Captain Rex "Ironclad" Harper, Black Fang Company
-lblName.text=Unit Name +lblName.text=Unit Name lblName.tooltip=PLACEHOLDER -lblNameGenerator.text=Regenerate Name +lblNameGenerator.text=Regenerate Name lblNameGenerator.tooltip=PLACEHOLDER -lblFaction.text=Unit Faction +lblFaction.text=Unit Faction lblFaction.tooltip=PLACEHOLDER -lblReputation.text=Reputation +lblReputation.text=Reputation lblReputation.tooltip=PLACEHOLDER -lblManualUnitRatingModifier.text=Manual Modifier +lblManualUnitRatingModifier.text=Manual Modifier lblManualUnitRatingModifier.tooltip=PLACEHOLDER -lblDate.text=Start Date +lblDate.text=Start Date lblDate.tooltip=PLACEHOLDER -lblCamo.text=Unit Camouflage +lblCamo.text=Unit Camouflage lblCamo.tooltip=PLACEHOLDER -lblIcon.text=Unit Insignia +lblIcon.text=Unit Insignia lblIcon.tooltip=PLACEHOLDER ## RepairAndMaintenanceTab @@ -70,9 +70,9 @@ lblUseAeroSystemHitsBox.text=Damage Aero System Parts by Hits Taken lblUseAeroSystemHitsBox.tooltip=PLACEHOLDER lblUseDamageMargin.text=Damage Parts by Margin of Failure lblUseDamageMargin.tooltip=PLACEHOLDER -lblDamageMargin.text=Margin +lblDamageMargin.text=Margin lblDamageMargin.tooltip=PLACEHOLDER -lblDestroyPartTarget.text=Equipment hit in battle survive on a +lblDestroyPartTarget.text=Equipment hit in battle survive on a lblDestroyPartTarget.tooltip=PLACEHOLDER # createMaintenanceTab @@ -125,7 +125,7 @@ lblAcquisitionTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. \ penatibus vitae leo quisque lectus dictum. Duis conubia nisi aliquet phasellus risus nullam massa\ \ at. Elementum natoque torquent phasellus suspendisse per aliquet scelerisque. Justo integer\ \ faucibus penatibus sem class. -lblChoiceAcquireSkill.text=Acquisitions Skill +lblChoiceAcquireSkill.text=Acquisitions Skill lblChoiceAcquireSkill.tooltip=PLACEHOLDER lblSupportStaffOnly.text=Only Support Personnel Make Acquisition Rolls lblSupportStaffOnly.tooltip=PLACEHOLDER @@ -172,7 +172,7 @@ lblUsePlanetaryAcquisitions.text=Use Planetary Acquisitions lblUsePlanetaryAcquisitions.tooltip=PLACEHOLDER lblMaxJumpPlanetaryAcquisitions.text=Maximum Jump Distance lblMaxJumpPlanetaryAcquisitions.tooltip=PLACEHOLDER -lblPlanetaryAcquisitionsFactionLimits.text=Faction Supply Limits +lblPlanetaryAcquisitionsFactionLimits.text=Faction Supply Limits lblPlanetaryAcquisitionsFactionLimits.tooltip=PLACEHOLDER lblDisallowPlanetaryAcquisitionClanCrossover.text=No Clan-Inner Sphere Supply Sharing lblDisallowPlanetaryAcquisitionClanCrossover.tooltip=PLACEHOLDER @@ -184,12 +184,12 @@ lblUsePlanetaryAcquisitionsVerbose.text=Enable Verbose Reporting lblUsePlanetaryAcquisitionsVerbose.tooltip=PLACEHOLDER # createModifiersPanel -lblModifiersPanel.text=Modifiers -lblTechLabel.text=Tech +lblModifiersPanel.text=Modifiers +lblTechLabel.text=Tech lblTechLabel.tooltip=PLACEHOLDER -lblIndustryLabel.text=Industry +lblIndustryLabel.text=Industry lblIndustryLabel.tooltip=PLACEHOLDER -lblOutputLabel.text=Output +lblOutputLabel.text=Output lblOutputLabel.tooltip=PLACEHOLDER ## Tech Limits Tab @@ -218,7 +218,7 @@ lblAllowCanonOnlyBox.text=Canon Tech Purchases Only lblAllowCanonOnlyBox.tooltip=PLACEHOLDER lblAllowCanonRefitOnlyBox.text=Canon Refits Only lblAllowCanonRefitOnlyBox.tooltip=PLACEHOLDER -lblChoiceTechLevel.text=Maximum Tech Level +lblChoiceTechLevel.text=Maximum Tech Level lblChoiceTechLevel.tooltip=PLACEHOLDER lblVariableTechLevelBox.text=Vary Introduction Date by Tech Level lblVariableTechLevelBox.tooltip=PLACEHOLDER @@ -342,11 +342,11 @@ lblPersonnelInformationBody.text=Lorem ipsum odor amet, consectetuer adipiscing \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam lblUseTimeInService.text=Track Time in Service lblUseTimeInService.tooltip=PLACEHOLDER -lblTimeInServiceDisplayFormat.text=Display Time in Service +lblTimeInServiceDisplayFormat.text=Display Time in Service lblTimeInServiceDisplayFormat.tooltip=PLACEHOLDER lblUseTimeInRank.text=Track Time in Rank lblUseTimeInRank.tooltip=PLACEHOLDER -lblTimeInRankDisplayFormat.text=Display Time in Rank +lblTimeInRankDisplayFormat.text=Display Time in Rank lblTimeInRankDisplayFormat.tooltip=PLACEHOLDER lblTrackTotalEarnings.text=Track Total Earnings lblTrackTotalEarnings.tooltip=PLACEHOLDER @@ -433,9 +433,9 @@ lblPrisonersAndDependentsTabBody.text=Lorem ipsum odor amet, consectetuer adipis # createPrisonersPanel lblPrisonersPanel.text=Prisoners -lblPrisonerCaptureStyle.text=Capture Style +lblPrisonerCaptureStyle.text=Capture Style lblPrisonerCaptureStyle.tooltip=PLACEHOLDER -lblPrisonerStatus.text=Default Status +lblPrisonerStatus.text=Default Status lblPrisonerStatus.tooltip=PLACEHOLDER lblPrisonerBabyStatus.text=Prisoner Babies Share Mother's Status lblPrisonerBabyStatus.tooltip=PLACEHOLDER @@ -461,17 +461,17 @@ lblMedicalTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euis \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam lblUseAdvancedMedical.text=Use Advanced Medical lblUseAdvancedMedical.tooltip=PLACEHOLDER -lblHealWaitingPeriod.text=Days Between Healing Checks +lblHealWaitingPeriod.text=Days Between Healing Checks lblHealWaitingPeriod.tooltip=PLACEHOLDER -lblNaturalHealWaitingPeriod.text=Days Between Natural Healing Checks +lblNaturalHealWaitingPeriod.text=Days Between Natural Healing Checks lblNaturalHealWaitingPeriod.tooltip=PLACEHOLDER -lblMinimumHitsForVehicles.text=Minimum Number of Hits for Vehicle Crew +lblMinimumHitsForVehicles.text=Minimum Number of Hits for Vehicle Crew lblMinimumHitsForVehicles.tooltip=PLACEHOLDER lblUseRandomHitsForVehicles.text=Randomized Vehicle Crew Hits lblUseRandomHitsForVehicles.tooltip=PLACEHOLDER lblUseTougherHealing.text=Use Tougher Healing lblUseTougherHealing.tooltip=PLACEHOLDER -lblMaximumPatients.text=Beds per Doctor +lblMaximumPatients.text=Beds per Doctor lblMaximumPatients.tooltip=PLACEHOLDER # createSalariesTab @@ -487,90 +487,32 @@ lblDisableSecondaryRoleSalary.tooltip=PLACEHOLDER # createSalaryMultipliersPanel lblSalaryMultipliersPanel.text=Role Multipliers -lblAntiMekSalary.text=Anti-Mek +lblAntiMekSalary.text=Anti-Mek lblAntiMekSalary.tooltip=PLACEHOLDER -lblSpecialistInfantrySalary.text=Specialist Infantry +lblSpecialistInfantrySalary.text=Specialist Infantry lblSpecialistInfantrySalary.tooltip=PLACEHOLDER # createExperienceMultipliersPanel lblExperienceMultipliersPanel.text=Experience Multipliers -lblSkillLevelNone.text=None +lblSkillLevelNone.text=None lblSkillLevelNone.tooltip=PLACEHOLDER -lblSkillLevelUltra-Green.text=Ultra-Green +lblSkillLevelUltra-Green.text=Ultra-Green lblSkillLevelUltra-Green.tooltip=PLACEHOLDER -lblSkillLevelGreen.text=Green +lblSkillLevelGreen.text=Green lblSkillLevelGreen.tooltip=PLACEHOLDER -lblSkillLevelRegular.text=Regular +lblSkillLevelRegular.text=Regular lblSkillLevelRegular.tooltip=PLACEHOLDER -lblSkillLevelVeteran.text=Veteran +lblSkillLevelVeteran.text=Veteran lblSkillLevelVeteran.tooltip=PLACEHOLDER -lblSkillLevelElite.text=Elite +lblSkillLevelElite.text=Elite lblSkillLevelElite.tooltip=PLACEHOLDER -lblSkillLevelHeroic.text=Heroic +lblSkillLevelHeroic.text=Heroic lblSkillLevelHeroic.tooltip=PLACEHOLDER -lblSkillLevelLegendary.text=Legendary +lblSkillLevelLegendary.text=Legendary lblSkillLevelLegendary.tooltip=PLACEHOLDER # createBaseSalariesPanel lblBaseSalariesPanel.text=Base Salaries -lblBaseSalaryMekWarrior.text=MekWarrior -lblBaseSalaryMekWarrior.tooltip=PLACEHOLDER -lblBaseSalaryLAMPilot.text=LAM Pilot -lblBaseSalaryLAMPilot.tooltip=PLACEHOLDER -lblBaseSalaryVehicleDriver.text=Vehicle Driver -lblBaseSalaryVehicleDriver.tooltip=PLACEHOLDER -lblBaseSalaryNavalDriver.text=Naval Driver -lblBaseSalaryNavalDriver.tooltip=PLACEHOLDER -lblBaseSalaryVTOLPilot.text=VTOL Pilot -lblBaseSalaryVTOLPilot.tooltip=PLACEHOLDER -lblBaseSalaryVehicleGunner.text=Vehicle Gunner -lblBaseSalaryVehicleGunner.tooltip=PLACEHOLDER -lblBaseSalaryVehicleCrewmember.text=Vehicle Crewmember -lblBaseSalaryVehicleCrewmember.tooltip=PLACEHOLDER -lblBaseSalaryAerospacePilot.text=Aerospace Pilot -lblBaseSalaryAerospacePilot.tooltip=PLACEHOLDER -lblBaseSalaryConventionalAircraftPilot.text=Aircraft Pilot -lblBaseSalaryConventionalAircraftPilot.tooltip=PLACEHOLDER -lblBaseSalaryProtoMekPilot.text=ProtoMek Pilot -lblBaseSalaryProtoMekPilot.tooltip=PLACEHOLDER -lblBaseSalaryBattleArmorPilot.text=Armor Pilot -lblBaseSalaryBattleArmorPilot.tooltip=PLACEHOLDER -lblBaseSalarySoldier.text=Soldier -lblBaseSalarySoldier.tooltip=PLACEHOLDER -lblBaseSalaryVesselPilot.text=Vessel Pilot -lblBaseSalaryVesselPilot.tooltip=PLACEHOLDER -lblBaseSalaryVesselGunner.text=Vessel Gunner -lblBaseSalaryVesselGunner.tooltip=PLACEHOLDER -lblBaseSalaryVesselCrewmember.text=Vessel Crewmember -lblBaseSalaryVesselCrewmember.tooltip=PLACEHOLDER -lblBaseSalaryHyperspaceNavigator.text=Hyperspace Navigator -lblBaseSalaryHyperspaceNavigator.tooltip=PLACEHOLDER -lblBaseSalaryMekTech.text=MekTech -lblBaseSalaryMekTech.tooltip=PLACEHOLDER -lblBaseSalaryMechanic.text=Mechanic -lblBaseSalaryMechanic.tooltip=PLACEHOLDER -lblBaseSalaryAerospaceTech.text=Aerospace Tech -lblBaseSalaryAerospaceTech.tooltip=PLACEHOLDER -lblBaseSalaryBattleArmorTech.text=Battle Armor Tech -lblBaseSalaryBattleArmorTech.tooltip=PLACEHOLDER -lblBaseSalaryAstech.text=Astech -lblBaseSalaryAstech.tooltip=PLACEHOLDER -lblBaseSalaryDoctor.text=Doctor -lblBaseSalaryDoctor.tooltip=PLACEHOLDER -lblBaseSalaryMedic.text=Medic -lblBaseSalaryMedic.tooltip=PLACEHOLDER -lblBaseSalaryAdmin/Command.text=Admin/Command -lblBaseSalaryAdmin/Command.tooltip=PLACEHOLDER -lblBaseSalaryAdmin/Logistical.text=Admin/Logistics -lblBaseSalaryAdmin/Logistical.tooltip=PLACEHOLDER -lblBaseSalaryAdmin/Transport.text=Admin/Transport -lblBaseSalaryAdmin/Transport.tooltip=PLACEHOLDER -lblBaseSalaryAdmin/HR.text=Admin/HR -lblBaseSalaryAdmin/HR.tooltip=PLACEHOLDER -lblBaseSalaryDependent.text=Dependent -lblBaseSalaryDependent.tooltip=PLACEHOLDER -lblBaseSalaryNone.text=None -lblBaseSalaryNone.tooltip=PLACEHOLDER # Life Paths Tab lifePathsContentTabs.title=Life Paths @@ -615,11 +557,11 @@ lblLifePathsGeneralTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing e \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam lblUseDylansRandomXP.text=Use Random XP lblUseDylansRandomXP.tooltip=PLACEHOLDER -lblGender.text=Percent Female +lblGender.text=Percent Female lblGender.tooltip=PLACEHOLDER -lblNonBinaryDiceSize.text=Non-Binary Personnel Chance: 1 in +lblNonBinaryDiceSize.text=Non-Binary Personnel Chance: 1 in lblNonBinaryDiceSize.tooltip=PLACEHOLDER -lblFamilyDisplayLevel.text=Family Display Depth +lblFamilyDisplayLevel.text=Family Display Depth lblFamilyDisplayLevel.tooltip=PLACEHOLDER # createAnniversariesPanel @@ -660,13 +602,13 @@ lblRandomizeAroundSpecifiedPlanet.text=Randomize Around Specific Planet lblRandomizeAroundSpecifiedPlanet.tooltip=PLACEHOLDER lblSpecifiedSystemFactionSpecific.text=Faction Specific lblSpecifiedSystemFactionSpecific.tooltip=PLACEHOLDER -lblSpecifiedSystem.text=System +lblSpecifiedSystem.text=System lblSpecifiedSystem.tooltip=PLACEHOLDER -lblSpecifiedPlanet.text=Planet +lblSpecifiedPlanet.text=Planet lblSpecifiedPlanet.tooltip=PLACEHOLDER -lblOriginSearchRadius.text=Random Origin Radius +lblOriginSearchRadius.text=Random Origin Radius lblOriginSearchRadius.tooltip=PLACEHOLDER -lblOriginDistanceScale.text=Distance Scale +lblOriginDistanceScale.text=Distance Scale lblOriginDistanceScale.tooltip=PLACEHOLDER lblAllowClanOrigins.text=Allow Clan Origins lblAllowClanOrigins.tooltip=PLACEHOLDER @@ -687,31 +629,31 @@ lblUseClanPersonnelMarriages.text=Enable Clan Marriages lblUseClanPersonnelMarriages.tooltip=PLACEHOLDER lblUsePrisonerMarriages.text=Enable Prisoner Marriages lblUsePrisonerMarriages.tooltip=PLACEHOLDER -lblNoInterestInMarriageDiceSize.text=No Interest in Marriage Chance: 1 in +lblNoInterestInMarriageDiceSize.text=No Interest in Marriage Chance: 1 in lblNoInterestInMarriageDiceSize.tooltip=PLACEHOLDER -lblCheckMutualAncestorsDepth.text=Minimum Ancestor Depth +lblCheckMutualAncestorsDepth.text=Minimum Ancestor Depth lblCheckMutualAncestorsDepth.tooltip=PLACEHOLDER lblLogMarriageNameChanges.text=Log Name Changes lblLogMarriageNameChanges.tooltip=PLACEHOLDER # createRandomMarriagePanel lblRandomMarriages.text=Random Marriages -lblRandomMarriageMethod.text=Random Marriage Method +lblRandomMarriageMethod.text=Random Marriage Method lblRandomMarriageMethod.tooltip=PLACEHOLDER lblUseRandomClanPersonnelMarriages.text=Enable Random Clan Marriages lblUseRandomClanPersonnelMarriages.tooltip=PLACEHOLDER lblUseRandomPrisonerMarriages.text=Enable Random Prisoner Marriages lblUseRandomPrisonerMarriages.tooltip=PLACEHOLDER -lblRandomMarriageAgeRange.text=Random Marriage Age Band +lblRandomMarriageAgeRange.text=Random Marriage Age Band lblRandomMarriageAgeRange.tooltip=PLACEHOLDER # createPercentageRandomMarriagePanel lblPercentageRandomMarriagePanel.text=Marriage Dice -lblRandomMarriageOppositeSexDiceSize.text=Opposite Sex Marriage Chance: 1 in +lblRandomMarriageOppositeSexDiceSize.text=Opposite Sex Marriage Chance: 1 in lblRandomMarriageOppositeSexDiceSize.tooltip=PLACEHOLDER -lblRandomSameSexMarriageDiceSize.text=Same Sex Marriage Chance: 1 in +lblRandomSameSexMarriageDiceSize.text=Same-Sex Marriage Chance: 1 in lblRandomSameSexMarriageDiceSize.tooltip=PLACEHOLDER -lblRandomNewDependentMarriage.text=Inter-Unit Marriage Chance: 1 in +lblRandomNewDependentMarriage.text=Inter-Unit Marriage Chance: 1 in lblRandomNewDependentMarriage.tooltip=PLACEHOLDER # createDivorceTab @@ -741,7 +683,7 @@ lblUseRandomClanPersonnelDivorce.text=Use Random Clan Divorce lblUseRandomClanPersonnelDivorce.tooltip=PLACEHOLDER lblUseRandomPrisonerDivorce.text=Use Random Prisoner Divorce lblUseRandomPrisonerDivorce.tooltip=PLACEHOLDER -lblRandomDivorceDiceSize.text=Random Divorce Chance: 1 in +lblRandomDivorceDiceSize.text=Random Divorce Chance: 1 in lblRandomDivorceDiceSize.tooltip=PLACEHOLDER # createProcreationTab @@ -760,7 +702,7 @@ lblUseClanPersonnelProcreation.text=Enable Clan Procreation lblUseClanPersonnelProcreation.tooltip=PLACEHOLDER lblUsePrisonerProcreation.text=Enable Prisoner Procreation lblUsePrisonerProcreation.tooltip=PLACEHOLDER -lblMultiplePregnancyOccurrences.text=Multiple Pregnancy Chance: 1 in +lblMultiplePregnancyOccurrences.text=Multiple Pregnancy Chance: 1 in lblMultiplePregnancyOccurrences.tooltip=PLACEHOLDER lblBabySurnameStyle.text=Baby Surname Style lblBabySurnameStyle.tooltip=PLACEHOLDER @@ -772,7 +714,7 @@ lblDetermineFatherAtBirth.text=Determine Father at Birth lblDetermineFatherAtBirth.tooltip=PLACEHOLDER lblDisplayTrueDueDate.text=Display True Due Date lblDisplayTrueDueDate.tooltip=PLACEHOLDER -lblNoInterestInChildrenDiceSize.text=No Interest in Children Chance: 1 in +lblNoInterestInChildrenDiceSize.text=No Interest in Children Chance: 1 in lblNoInterestInChildrenDiceSize.tooltip=PLACEHOLDER lblUseMaternityLeave.text=Enable Automatic Maternity Leave lblUseMaternityLeave.tooltip=PLACEHOLDER @@ -789,9 +731,9 @@ lblUseRandomClanPersonnelProcreation.text=Enable Random Clan Procreation lblUseRandomClanPersonnelProcreation.tooltip=PLACEHOLDER lblUseRandomPrisonerProcreation.text=Enable Random Prisoner Procreation lblUseRandomPrisonerProcreation.tooltip=PLACEHOLDER -lblRandomProcreationRelationshipDiceSize.text=Normal Procreation Chance: 1 in +lblRandomProcreationRelationshipDiceSize.text=Normal Procreation Chance: 1 in lblRandomProcreationRelationshipDiceSize.tooltip=PLACEHOLDER -lblRandomProcreationRelationshiplessDiceSize.text=Relationshipless Procreation Chance: 1 in +lblRandomProcreationRelationshiplessDiceSize.text=Relationshipless Procreation Chance: 1 in lblRandomProcreationRelationshiplessDiceSize.tooltip=PLACEHOLDER # createDeathTab @@ -817,13 +759,6 @@ lblPercentageRandomDeathChance.tooltip=PLACEHOLDER # createDeathAgeGroupsPanel lblDeathAgeGroupsPanel.text=Enable Death by Age Group -lblBaby.text=Baby -lblToddler.text=Toddler -lblChild.text=Child -lblPre-teen.text=Pre-Teen -lblTeenager.text=Teenager -lblAdult.text=Adult -lblElder.text=Elder # Life Paths Tab turnoverAndRetentionContentTabs.title=Turnover & Retention @@ -942,13 +877,13 @@ lblFatigueTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euis \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam lblUseFatigue.text=Enable Fatigue lblUseFatigue.tooltip=PLACEHOLDER -lblFatigueRate.text=Fatigue Rate +lblFatigueRate.text=Fatigue Rate lblFatigueRate.tooltip=PLACEHOLDER lblUseInjuryFatigue.text=Injuries Increase Fatigue lblUseInjuryFatigue.tooltip=PLACEHOLDER -lblFieldKitchenCapacity.text=Field Kitchen Capacity +lblFieldKitchenCapacity.text=Field Kitchen Capacity lblFieldKitchenCapacity.tooltip=PLACEHOLDER lblFieldKitchenIgnoreNonCombatants.text=Ignore Non-Combatants lblFieldKitchenIgnoreNonCombatants.tooltip=PLACEHOLDER -lblFatigueLeaveThreshold.text=Automatic Leave Threshold +lblFatigueLeaveThreshold.text=Automatic Leave Threshold lblFatigueLeaveThreshold.tooltip=PLACEHOLDER \ No newline at end of file diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index 9c1c6c7d3c..eab1a163c3 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -41,7 +41,7 @@ static String getImageDirectory() { static JCheckBox createCheckBox(String name, @Nullable Integer customWrapSize) { customWrapSize = processWrapSize(customWrapSize); - JCheckBox checkBox = new JCheckBox(String.format("%s", + JCheckBox checkBox = new JCheckBox(String.format("%s", resources.getString("lbl" + name + ".text"))); checkBox.setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), customWrapSize)); checkBox.setName("chk" + name); @@ -178,7 +178,7 @@ static JPanel createStandardPanel(String name, boolean includeBorder, String bor if (includeBorder) { panel.setBorder(BorderFactory.createTitledBorder( - String.format(String.format("%s", borderTitle)))); + String.format(String.format("%s", borderTitle)))); } panel.setName(name); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java index 2d54c789d6..ed291ee271 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java @@ -10,6 +10,7 @@ import javax.swing.GroupLayout.Group; import javax.swing.GroupLayout.ParallelGroup; import javax.swing.GroupLayout.SequentialGroup; +import javax.swing.JSpinner.DefaultEditor; import javax.swing.LayoutStyle.ComponentPlacement; import java.awt.*; import java.util.HashMap; @@ -1128,17 +1129,31 @@ private JPanel createExperienceMultipliersPanel() { private JPanel createBaseSalariesPanel() { // Contents for (final PersonnelRole personnelRole : PersonnelRole.values()) { - String componentName = "BaseSalary" + personnelRole.toString(); - componentName = componentName.replaceAll(" ", ""); + String componentName = personnelRole.toString().replaceAll(" ", ""); - final JLabel label = createLabel(componentName, null); + // JLabel + JLabel jLabel = new JLabel(personnelRole.toString()); + jLabel.setName("lbl" + componentName); - final JSpinner spinner = createSpinner(componentName, null, - 0.0, 0.0, 1000000, 10.0); + Dimension labelSize = jLabel.getPreferredSize(); + jLabel.setMinimumSize(labelSize); + jLabel.setMaximumSize(labelSize); + + // JSpinner + JSpinner jSpinner = new JSpinner(); + jSpinner.setModel(new SpinnerNumberModel(0.0, 0.0, 1000000, 10.0)); + jSpinner.setName("spn" + componentName); + + DefaultEditor editor = (DefaultEditor) jSpinner.getEditor(); + editor.getTextField().setHorizontalAlignment(JTextField.LEFT); + + Dimension spinnerSize = jSpinner.getPreferredSize(); + jSpinner.setMaximumSize(spinnerSize); + jSpinner.setMinimumSize(spinnerSize); // Component Tracking Assignment - lblBaseSalary[personnelRole.ordinal()] = label; - spnBaseSalary[personnelRole.ordinal()] = spinner; + lblBaseSalary[personnelRole.ordinal()] = jLabel; + spnBaseSalary[personnelRole.ordinal()] = jSpinner; } // Layout the Panel From e2b28a27e966af77c3e97bfedc8d97f7ac4ee347 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 10 Oct 2024 21:23:56 -0500 Subject: [PATCH 041/117] Add new Education tab to campaign options Renamed relationship-related tabs and integrated a comprehensive Education tab. This includes various education settings such as XP rates, dropout chances, and accident rates, as well as new configuration panels and controls. --- .../NEWCampaignOptionsDialog.properties | 81 +++- .../tabs/CampaignOptionsPane.java | 9 +- .../campaignOptions/tabs/LifePathsTab.java | 352 ++++++++++++++++++ 3 files changed, 426 insertions(+), 16 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 9c7a41eb26..4e08ea802c 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -527,25 +527,29 @@ backgroundsTab.border="From noble houses to street gangs, once you're in the coc \ same. Your past might shape you, but your future is yours to command."\
- Lieutenant Marcus "Ghost" Walker, Onyx Fang Company -marriageTab.title=Relationships - Marriage -marriageTab.border="In a universe filled with war and chaos, marriage is the one alliance that keeps\ - \ you grounded. When the battles end, it's the bond you fight to protect."\ +relationshipsMarriageTab.title=Relationships - Marriage +relationshipsMarriageTab.border="In a universe filled with war and chaos, marriage is the one alliance\ + \ that keeps you grounded. When the battles end, it's the bond you fight to protect."\
- Lieutenant Elara "Sunburst" Tate, Steelclaw Company -divorceTab.title=Relationships - Divorce -divorceTab.border="Divorce is just like ejecting from a 'mek: it's messy, expensive, and you're lucky\ - \ if you escape in one piece."\ +relationshipsDivorceTab.title=Relationships - Divorce +relationshipsDivorceTab.border="Divorce is just like ejecting from a 'mek: it's messy, expensive, and\ + \ you're lucky if you escape in one piece."\
- Sergeant Quinn "Deadeye" Mallory, Crimson Fang Mercs -procreationTab.title=Relationships - Procreation -procreationTab.border="In this galaxy, raising kids is tougher than raising a lance. At least 'meks\ - \ come with an instruction manual."\ +relationshipsProcreationTab.title=Relationships - Procreation +relationshipsProcreationTab.border="In this galaxy, raising kids is tougher than raising a lance. At\ + \ least 'meks come with an instruction manual."\
- Captain Dani "Ironheart" Cole, Steel Talon Company deathTab.title=Death -deathTab.border="In the cockpit, death is never far away, but neither is life. Every battle reminds us\ - \ that it's the moments in between that matter most."
- Colonel Viktor "Ironhand" Selwyn, Stormguard\ - \ Command +deathTab.border="School didn't teach me how to explode, but I learn fast."\ +
- Sergeant Pete "Wildfire" Watson, Steel Viper Unit + +educationTab.title=Education +educationTab.border="You can teach someone to pilot a 'mek, but you can't teach them how to survive\ + \ a battlefield. That education comes with time - and scars."\ +
- Lieutenant Hannah "Stinger" Quinn, Ironclad Rangers # createGeneralTab lblLifePathsGeneralTab.text=General Options @@ -760,6 +764,59 @@ lblPercentageRandomDeathChance.tooltip=PLACEHOLDER # createDeathAgeGroupsPanel lblDeathAgeGroupsPanel.text=Enable Death by Age Group +# createEducationTab +lblEducationTab.text=Education Options +lblEducationTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblUseEducationModule.text=Enable Education +lblUseEducationModule.tooltip=PLACEHOLDER +lblCurriculumXpRate.text=Base XP Rate +lblCurriculumXpRate.tooltip=PLACEHOLDER +lblMaximumJumpCount.text=Maximum Jump Radius +lblMaximumJumpCount.tooltip=PLACEHOLDER +lblUseReeducationCamps.text=Enable Reeducation Camp Faction Changes +lblUseReeducationCamps.tooltip=PLACEHOLDER +lblEnableOverrideRequirements.text=Override Requirements +lblEnableOverrideRequirements.tooltip=PLACEHOLDER +lblShowIneligibleAcademies.text=Show Ineligible Academies +lblShowIneligibleAcademies.tooltip=PLACEHOLDER +lblEntranceExamBaseTargetNumber.text=Entrance Exam Target Number +lblEntranceExamBaseTargetNumber.tooltip=PLACEHOLDER + +# createEnableStandardSetsPanel +lblEnableStandardSetsPanel.text=Standard Sets +lblEnableLocalAcademies.text=Local Academies +lblEnableLocalAcademies.tooltip=PLACEHOLDER +lblEnablePrestigiousAcademies.text=Prestigious Academies +lblEnablePrestigiousAcademies.tooltip=PLACEHOLDER +lblEnableUnitEducation.text=Unit Education +lblEnableUnitEducation.tooltip=PLACEHOLDER + +# createXpAndSkillBonusesPanel +lblXpAndSkillBonusesPanel.text=Faculty XP & Skill Bonuses +lblEnableBonuses.text=Enable Graduation Bonuses +lblEnableBonuses.tooltip=PLACEHOLDER +lblFacultyXpMultiplier.text=Faculty XP Multiplier +lblFacultyXpMultiplier.tooltip=PLACEHOLDER + +# createDropoutChancePanel +lblDropoutChancePanel.text=Weekly Dropout Chances +lblAdultDropoutChance.text=Adult Dropout Chance: 1 in +lblAdultDropoutChance.tooltip=PLACEHOLDER +lblChildrenDropoutChance.text=Child Dropout Chance: 1 in +lblChildrenDropoutChance.tooltip=PLACEHOLDER + +# createAccidentsAndEventsPanel +lblAccidentsAndEventsPanel.text=Accidents & Events +lblAllAges.text=All Ages Affected +lblAllAges.tooltip=PLACEHOLDER +lblMilitaryAcademyAccidents.text=Military Accidents Chance: 1 in +lblMilitaryAcademyAccidents.tooltip=PLACEHOLDER + # Life Paths Tab turnoverAndRetentionContentTabs.title=Turnover & Retention diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index cc2b602715..45cf35f106 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -126,10 +126,11 @@ private JTabbedPane createHumanResourcesParentTab() { JTabbedPane lifePathsContentTabs = createSubTabs(Map.of( "lifePathsGeneralTab", lifePathsTab.createGeneralTab(), "backgroundsTab", lifePathsTab.createBackgroundsTab(), - "marriageTab", lifePathsTab.createMarriageTab(), - "divorceTab", lifePathsTab.createDivorceTab(), - "procreationTab", lifePathsTab.createProcreationTab(), - "deathTab", lifePathsTab.createDeathTab())); + "relationshipsMarriageTab", lifePathsTab.createMarriageTab(), + "relationshipsDivorceTab", lifePathsTab.createDivorceTab(), + "relationshipsProcreationTab", lifePathsTab.createProcreationTab(), + "deathTab", lifePathsTab.createDeathTab(), + "educationTab", lifePathsTab.createEducationTab())); // Turnover and Retention TurnoverAndRetentionTab turnoverAndRetentionTab = new TurnoverAndRetentionTab(getFrame(), diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java index 3f014db3f2..0f2282acbe 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java @@ -150,6 +150,40 @@ public class LifePathsTab { private Map chkEnabledRandomDeathAgeGroups; //end Death Tab + //start Education Tab + private JCheckBox chkUseEducationModule; + private JLabel lblCurriculumXpRate; + private JSpinner spnCurriculumXpRate; + private JLabel lblMaximumJumpCount; + private JSpinner spnMaximumJumpCount; + private JCheckBox chkUseReeducationCamps; + private JCheckBox chkEnableOverrideRequirements; + private JCheckBox chkShowIneligibleAcademies; + private JLabel lblEntranceExamBaseTargetNumber; + private JSpinner spnEntranceExamBaseTargetNumber; + + private JPanel pnlEnableStandardSets; + private JCheckBox chkEnableLocalAcademies; + private JCheckBox chkEnablePrestigiousAcademies; + private JCheckBox chkEnableUnitEducation; + + private JPanel pnlXpAndSkillBonuses; + private JCheckBox chkEnableBonuses; + private JLabel lblFacultyXpMultiplier; + private JSpinner spnFacultyXpMultiplier; + + private JPanel pnlDropoutChance; + private JLabel lblAdultDropoutChance; + private JSpinner spnAdultDropoutChance; + private JLabel lblChildrenDropoutChance; + private JSpinner spnChildrenDropoutChance; + + private JPanel pnlAccidentsAndEvents; + private JCheckBox chkAllAges; + private JLabel lblMilitaryAcademyAccidents; + private JSpinner spnMilitaryAcademyAccidents; + //end Education Tab + /** * Initializes a new {@link LifePathsTab} with the specified campaign, frame, and name. * @@ -302,6 +336,39 @@ protected void initialize() { pnlDeathAgeGroup = new JPanel(); chkEnabledRandomDeathAgeGroups = new HashMap<>(); + + // Education Tab + chkUseEducationModule = new JCheckBox(); + lblCurriculumXpRate = new JLabel(); + spnCurriculumXpRate = new JSpinner(); + lblMaximumJumpCount = new JLabel(); + spnMaximumJumpCount = new JSpinner(); + chkUseReeducationCamps = new JCheckBox(); + chkEnableOverrideRequirements = new JCheckBox(); + chkShowIneligibleAcademies = new JCheckBox(); + lblEntranceExamBaseTargetNumber = new JLabel(); + spnEntranceExamBaseTargetNumber = new JSpinner(); + + pnlEnableStandardSets = new JPanel(); + chkEnableLocalAcademies = new JCheckBox(); + chkEnablePrestigiousAcademies = new JCheckBox(); + chkEnableUnitEducation = new JCheckBox(); + + pnlXpAndSkillBonuses = new JPanel(); + chkEnableBonuses = new JCheckBox(); + lblFacultyXpMultiplier = new JLabel(); + spnFacultyXpMultiplier = new JSpinner(); + + pnlDropoutChance = new JPanel(); + lblAdultDropoutChance = new JLabel(); + spnAdultDropoutChance = new JSpinner(); + lblChildrenDropoutChance = new JLabel(); + spnChildrenDropoutChance = new JSpinner(); + + pnlAccidentsAndEvents = new JPanel(); + chkAllAges = new JCheckBox(); + lblMilitaryAcademyAccidents = new JLabel(); + spnMilitaryAcademyAccidents = new JSpinner(); } /** @@ -1301,4 +1368,289 @@ JPanel createDeathAgeGroupsPanel() { return panel; } + + /** + * Constructs and configures an "Education" {@link JPanel}. + * The panel includes various controls related to education settings, + * including checkboxes for enabling specific modules and settings, + * spinners for configuring values such as XP rate and jump count, + * and separate panels for managing standard sets, XP and skill bonuses, + * dropout chances, accidents, and events. + *

+ * The JPanel configuration is done using a {@link GroupLayout}, setting up + * the components in a structured layout with optimized vertical and + * horizontal alignments. + * + * @return {@link JPanel} The newly created and configured parent JPanel for + * the Education tab, containing all the educational settings controls. + */ + JPanel createEducationTab() { + // Header + JPanel headerPanel = createHeaderPanel("EducationTab", + getImageDirectory() + "logo_free_worlds_league.png", + false, "", true); + + // Contents + chkUseEducationModule = createCheckBox("UseEducationModule", null); + + lblCurriculumXpRate = createLabel("CurriculumXpRate", null); + spnCurriculumXpRate = createSpinner("CurriculumXpRate", null, + 3, 1, 10, 1); + + lblMaximumJumpCount = createLabel("MaximumJumpCount", null); + spnMaximumJumpCount = createSpinner("MaximumJumpCount", null, + 5, 1, 200, 1); + + chkUseReeducationCamps = createCheckBox("UseReeducationCamps", null); + + pnlEnableStandardSets = createEnableStandardSetsPanel(); + + chkEnableOverrideRequirements = createCheckBox("EnableOverrideRequirements", null); + + chkShowIneligibleAcademies = createCheckBox("ShowIneligibleAcademies", null); + + lblEntranceExamBaseTargetNumber = createLabel("EntranceExamBaseTargetNumber", null); + spnEntranceExamBaseTargetNumber = createSpinner("EntranceExamBaseTargetNumber", null, + 14, 0, 20, 1); + + pnlXpAndSkillBonuses = createXpAndSkillBonusesPanel(); + + pnlDropoutChance = createDropoutChancePanel(); + + pnlAccidentsAndEvents = createAccidentsAndEventsPanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("EducationTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addComponent(chkUseEducationModule) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblCurriculumXpRate) + .addComponent(spnCurriculumXpRate) + .addComponent(lblMaximumJumpCount) + .addComponent(spnMaximumJumpCount)) + .addComponent(chkUseReeducationCamps) + .addComponent(pnlEnableStandardSets) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(chkShowIneligibleAcademies) + .addComponent(chkEnableOverrideRequirements)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblEntranceExamBaseTargetNumber) + .addComponent(spnEntranceExamBaseTargetNumber)) + .addComponent(pnlXpAndSkillBonuses) + .addComponent(pnlDropoutChance) + .addComponent(pnlAccidentsAndEvents)); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addComponent(chkUseEducationModule) + .addGroup(layout.createSequentialGroup() + .addComponent(lblCurriculumXpRate) + .addComponent(spnCurriculumXpRate) + .addComponent(lblMaximumJumpCount) + .addComponent(spnMaximumJumpCount) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkUseReeducationCamps) + .addComponent(pnlEnableStandardSets) + .addGroup(layout.createSequentialGroup() + .addComponent(chkShowIneligibleAcademies) + .addComponent(chkEnableOverrideRequirements) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblEntranceExamBaseTargetNumber) + .addComponent(spnEntranceExamBaseTargetNumber) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(pnlXpAndSkillBonuses) + .addComponent(pnlDropoutChance) + .addComponent(pnlAccidentsAndEvents))); + + // Create Parent Panel and return + return createParentPanel(panel, "EducationTab"); + } + + /** + * Constructs and configures an "Enable Standard Sets" {@link JPanel}. + * The panel consists of three checkboxes: to enable local academies, + * prestigious academies, and unit education. + *

+ * A {@link GroupLayout} is used to arrange these components in an + * optimal manner, ensuring good readability and usability in both + * vertical and horizontal alignments. + * + * @return {@link JPanel} The newly constructed and configured JPanel for + * Enable Standard Sets settings. + */ + JPanel createEnableStandardSetsPanel() { + // Contents + chkEnableLocalAcademies = createCheckBox("EnableLocalAcademies", null); + chkEnablePrestigiousAcademies = createCheckBox("EnablePrestigiousAcademies", null); + chkEnableUnitEducation = createCheckBox("EnableUnitEducation", null); + + // Layout the Panel + final JPanel panel = createStandardPanel("EnableStandardSetsPanel", true, + "EnableStandardSetsPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(chkEnableLocalAcademies) + .addComponent(chkEnablePrestigiousAcademies) + .addComponent(chkEnableUnitEducation))); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(chkEnableLocalAcademies) + .addComponent(chkEnablePrestigiousAcademies) + .addComponent(chkEnableUnitEducation) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + + return panel; + } + + /** + * Constructs and configures an "XP and Skill Bonuses" {@link JPanel}. + * The panel includes a checkbox to enable or disable bonuses, a label + * for faculty XP multiplier, and a spinner to adjust the faculty XP multiplier value. + *

+ * The layout of the panel is set up with a {@link GroupLayout}, arranging + * the checkbox, label, and spinner for optimal vertical and horizontal alignment. + * + * @return {@link JPanel} The newly created and configured JPanel + * containing the XP and Skill Bonuses settings. + */ + JPanel createXpAndSkillBonusesPanel() { + // Contents + chkEnableBonuses = createCheckBox("EnableBonuses", null); + lblFacultyXpMultiplier = createLabel("FacultyXpMultiplier", null); + spnFacultyXpMultiplier = createSpinner("FacultyXpMultiplier", null, + 1.00, 0.00, 10.00, 0.01); + + // Layout the Panel + final JPanel panel = createStandardPanel("XpAndSkillBonusesPanel", true, + "XpAndSkillBonusesPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(chkEnableBonuses) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblFacultyXpMultiplier) + .addComponent(spnFacultyXpMultiplier))); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(chkEnableBonuses) + .addGroup(layout.createSequentialGroup() + .addComponent(lblFacultyXpMultiplier) + .addComponent(spnFacultyXpMultiplier) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + + return panel; + } + + /** + * Constructs and configures a "Dropout Chance" {@link JPanel}. + * The created panel includes two labels and spinners: one set for adult dropout chances, + * and the other for child dropout chances. + *

+ * The JPanel layout is arranged using a {@link GroupLayout}, positioning the labels and spinners + * in a way that optimizes horizontal and vertical alignments. + * + * @return {@link JPanel} The newly constructed and configured JPanel that contains the Dropout Chance settings. + */ + JPanel createDropoutChancePanel() { + // Contents + lblAdultDropoutChance = createLabel("AdultDropoutChance", null); + spnAdultDropoutChance = createSpinner("AdultDropoutChance", null, + 1000, 0, 100000, 1); + lblChildrenDropoutChance = createLabel("ChildrenDropoutChance", null); + spnChildrenDropoutChance = createSpinner("ChildrenDropoutChance", null, + 10000, 0, 100000, 1); + + // Layout the Panel + final JPanel panel = createStandardPanel("DropoutChancePanel", true, + "DropoutChancePanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblAdultDropoutChance) + .addComponent(spnAdultDropoutChance)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblChildrenDropoutChance) + .addComponent(spnChildrenDropoutChance))); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblAdultDropoutChance) + .addComponent(spnAdultDropoutChance) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblChildrenDropoutChance) + .addComponent(spnChildrenDropoutChance) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + + return panel; + } + + /** + * Constructs and configures an "Accidents and Events" {@link JPanel}. + * The panel includes a checkbox indicating whether to include all ages, + * a label for military academy accidents, and also a spinner for adjusting + * the count of military academy accidents. + *

+ * The layout of the panel is configured with a {@link GroupLayout}, + * organizing the checkbox and other components for optimized alignments + * in vertical and horizontal layouts. + * + * @return {@link JPanel} The constructed, configured JPanel containing + * "Accidents and Events" settings + */ + JPanel createAccidentsAndEventsPanel() { + // Contents + chkAllAges = createCheckBox("AllAges", null); + lblMilitaryAcademyAccidents = createLabel("MilitaryAcademyAccidents", null); + spnMilitaryAcademyAccidents = createSpinner("MilitaryAcademyAccidents", null, + 10000, 0, 100000, 1); + + // Layout the Panel + final JPanel panel = createStandardPanel("AccidentsAndEventsPanel", true, + "AccidentsAndEventsPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(chkAllAges) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblMilitaryAcademyAccidents) + .addComponent(spnMilitaryAcademyAccidents))); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(chkAllAges) + .addGroup(layout.createSequentialGroup() + .addComponent(lblMilitaryAcademyAccidents) + .addComponent(spnMilitaryAcademyAccidents) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + + return panel; + } } From 0272552a35f4b37224e95c9d99d58e3e1c3050d3 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 10 Oct 2024 21:29:56 -0500 Subject: [PATCH 042/117] Add entrance exam modifier label to LifePathsTab Added a new label to display the entrance exam modifier in the LifePathsTab for better clarity. Also updated the properties file to accommodate this new label and adjusted related UI components accordingly. --- .../mekhq/resources/NEWCampaignOptionsDialog.properties | 4 +++- .../mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 4e08ea802c..7e16d46457 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -786,6 +786,8 @@ lblShowIneligibleAcademies.text=Show Ineligible Academies lblShowIneligibleAcademies.tooltip=PLACEHOLDER lblEntranceExamBaseTargetNumber.text=Entrance Exam Target Number lblEntranceExamBaseTargetNumber.tooltip=PLACEHOLDER +lblEntranceExamBaseTargetNumberPost.text=- Faculty Skill + Intelligence Modifier +lblEntranceExamBaseTargetNumberPost.tooltip=PLACEHOLDER # createEnableStandardSetsPanel lblEnableStandardSetsPanel.text=Standard Sets @@ -811,7 +813,7 @@ lblChildrenDropoutChance.text=Child Dropout Chance: 1 in lblChildrenDropoutChance.tooltip=PLACEHOLDER # createAccidentsAndEventsPanel -lblAccidentsAndEventsPanel.text=Accidents & Events +lblAccidentsAndEventsPanel.text=Weekly Accidents & Events lblAllAges.text=All Ages Affected lblAllAges.tooltip=PLACEHOLDER lblMilitaryAcademyAccidents.text=Military Accidents Chance: 1 in diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java index 0f2282acbe..8202b27136 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java @@ -161,6 +161,7 @@ public class LifePathsTab { private JCheckBox chkShowIneligibleAcademies; private JLabel lblEntranceExamBaseTargetNumber; private JSpinner spnEntranceExamBaseTargetNumber; + private JLabel lblEntranceExamBaseTargetNumberPost; private JPanel pnlEnableStandardSets; private JCheckBox chkEnableLocalAcademies; @@ -348,6 +349,7 @@ protected void initialize() { chkShowIneligibleAcademies = new JCheckBox(); lblEntranceExamBaseTargetNumber = new JLabel(); spnEntranceExamBaseTargetNumber = new JSpinner(); + lblEntranceExamBaseTargetNumberPost = new JLabel(); pnlEnableStandardSets = new JPanel(); chkEnableLocalAcademies = new JCheckBox(); @@ -1412,6 +1414,7 @@ JPanel createEducationTab() { lblEntranceExamBaseTargetNumber = createLabel("EntranceExamBaseTargetNumber", null); spnEntranceExamBaseTargetNumber = createSpinner("EntranceExamBaseTargetNumber", null, 14, 0, 20, 1); + lblEntranceExamBaseTargetNumberPost = createLabel("EntranceExamBaseTargetNumberPost", null); pnlXpAndSkillBonuses = createXpAndSkillBonusesPanel(); @@ -1440,7 +1443,8 @@ JPanel createEducationTab() { .addComponent(chkEnableOverrideRequirements)) .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(lblEntranceExamBaseTargetNumber) - .addComponent(spnEntranceExamBaseTargetNumber)) + .addComponent(spnEntranceExamBaseTargetNumber) + .addComponent(lblEntranceExamBaseTargetNumberPost)) .addComponent(pnlXpAndSkillBonuses) .addComponent(pnlDropoutChance) .addComponent(pnlAccidentsAndEvents)); @@ -1465,6 +1469,7 @@ JPanel createEducationTab() { .addGroup(layout.createSequentialGroup() .addComponent(lblEntranceExamBaseTargetNumber) .addComponent(spnEntranceExamBaseTargetNumber) + .addComponent(lblEntranceExamBaseTargetNumberPost) .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) .addComponent(pnlXpAndSkillBonuses) .addComponent(pnlDropoutChance) From 97bcd5b28920d4a4090e2bbeea62ca4780e1bb2c Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 10 Oct 2024 21:50:22 -0500 Subject: [PATCH 043/117] Add RelationshipsTab for campaign options Created a new `RelationshipsTab` class in the campaign options GUI, featuring separate tabs for marriage, divorce, and procreation settings. Each tab includes options for manual, clan personnel, and prisoner actions, along with configurations for randomization. --- .../NEWCampaignOptionsDialog.properties | 276 ++++--- .../tabs/CampaignOptionsPane.java | 33 +- .../tabs/RelationshipsTab.java | 737 ++++++++++++++++++ .../{LifePathsTab.java => biographyTab.java} | 736 +---------------- 4 files changed, 918 insertions(+), 864 deletions(-) create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java rename MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/{LifePathsTab.java => biographyTab.java} (54%) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 7e16d46457..ac2a474105 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -514,11 +514,11 @@ lblSkillLevelLegendary.tooltip=PLACEHOLDER # createBaseSalariesPanel lblBaseSalariesPanel.text=Base Salaries -# Life Paths Tab -lifePathsContentTabs.title=Life Paths +# Biography Tab +biographyContentTabs.title=Biography -lifePathsGeneralTab.title=General -lifePathsGeneralTab.border="Every MekWarrior starts somewhere different, but we all end up the same:\ +biographyGeneralTab.title=General +biographyGeneralTab.border="Every MekWarrior starts somewhere different, but we all end up the same:\ \ in the cockpit, staring down the impossible, and finding a way through."\
- Lieutenant Adam "Burnout" Keller, Blackthorn Marauders @@ -552,8 +552,8 @@ educationTab.border="You can teach someone to pilot a 'mek, but you can't teach
- Lieutenant Hannah "Stinger" Quinn, Ironclad Rangers # createGeneralTab -lblLifePathsGeneralTab.text=General Options -lblLifePathsGeneralTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ +lblBiographyGeneralTab.text=General Options +lblBiographyGeneralTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ @@ -619,127 +619,6 @@ lblAllowClanOrigins.tooltip=PLACEHOLDER lblExtraRandomOrigin.text=Extra Random Origins lblExtraRandomOrigin.tooltip=PLACEHOLDER -# createMarriageTab -lblMarriageTab.text=Marriage Options -lblMarriageTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ - \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ - \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ - \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ - \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ - \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam -lblUseManualMarriages.text=Enable Manual Marriages -lblUseManualMarriages.tooltip=PLACEHOLDER -lblUseClanPersonnelMarriages.text=Enable Clan Marriages -lblUseClanPersonnelMarriages.tooltip=PLACEHOLDER -lblUsePrisonerMarriages.text=Enable Prisoner Marriages -lblUsePrisonerMarriages.tooltip=PLACEHOLDER -lblNoInterestInMarriageDiceSize.text=No Interest in Marriage Chance: 1 in -lblNoInterestInMarriageDiceSize.tooltip=PLACEHOLDER -lblCheckMutualAncestorsDepth.text=Minimum Ancestor Depth -lblCheckMutualAncestorsDepth.tooltip=PLACEHOLDER -lblLogMarriageNameChanges.text=Log Name Changes -lblLogMarriageNameChanges.tooltip=PLACEHOLDER - -# createRandomMarriagePanel -lblRandomMarriages.text=Random Marriages -lblRandomMarriageMethod.text=Random Marriage Method -lblRandomMarriageMethod.tooltip=PLACEHOLDER -lblUseRandomClanPersonnelMarriages.text=Enable Random Clan Marriages -lblUseRandomClanPersonnelMarriages.tooltip=PLACEHOLDER -lblUseRandomPrisonerMarriages.text=Enable Random Prisoner Marriages -lblUseRandomPrisonerMarriages.tooltip=PLACEHOLDER -lblRandomMarriageAgeRange.text=Random Marriage Age Band -lblRandomMarriageAgeRange.tooltip=PLACEHOLDER - -# createPercentageRandomMarriagePanel -lblPercentageRandomMarriagePanel.text=Marriage Dice -lblRandomMarriageOppositeSexDiceSize.text=Opposite Sex Marriage Chance: 1 in -lblRandomMarriageOppositeSexDiceSize.tooltip=PLACEHOLDER -lblRandomSameSexMarriageDiceSize.text=Same-Sex Marriage Chance: 1 in -lblRandomSameSexMarriageDiceSize.tooltip=PLACEHOLDER -lblRandomNewDependentMarriage.text=Inter-Unit Marriage Chance: 1 in -lblRandomNewDependentMarriage.tooltip=PLACEHOLDER - -# createDivorceTab -lblDivorceTab.text=Divorce Options -lblDivorceTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ - \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ - \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ - \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ - \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ - \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam -lblUseManualDivorce.text=Enable Manual Divorce -lblUseManualDivorce.tooltip=PLACEHOLDER -lblUseClanPersonnelDivorce.text=Enable Manual Clan Divorce -lblUseClanPersonnelDivorce.tooltip=PLACEHOLDER -lblUsePrisonerDivorce.text=Enable Manual Prisoner Divorce -lblUsePrisonerDivorce.tooltip=PLACEHOLDER - -# createRandomDivorcePanel -lblRandomDivorcePanel.text=Random Divorce -lblRandomDivorceMethod.text=Random Divorce Method -lblRandomDivorceMethod.tooltip=PLACEHOLDER -lblUseRandomOppositeSexDivorce.text=Use Random Opposite Sex Divorce -lblUseRandomOppositeSexDivorce.tooltip=PLACEHOLDER -lblUseRandomSameSexDivorce.text=Use Random Same Sex Divorce -lblUseRandomSameSexDivorce.tooltip=PLACEHOLDER -lblUseRandomClanPersonnelDivorce.text=Use Random Clan Divorce -lblUseRandomClanPersonnelDivorce.tooltip=PLACEHOLDER -lblUseRandomPrisonerDivorce.text=Use Random Prisoner Divorce -lblUseRandomPrisonerDivorce.tooltip=PLACEHOLDER -lblRandomDivorceDiceSize.text=Random Divorce Chance: 1 in -lblRandomDivorceDiceSize.tooltip=PLACEHOLDER - -# createProcreationTab -lblProcreationTab.text=Procreation Options -lblProcreationTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ - \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ - \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ - \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ - \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ - \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam - -# createProcreationGeneralOptionsPanel -lblUseManualProcreation.text=Enable Manual Procreation -lblUseManualProcreation.tooltip=PLACEHOLDER -lblUseClanPersonnelProcreation.text=Enable Clan Procreation -lblUseClanPersonnelProcreation.tooltip=PLACEHOLDER -lblUsePrisonerProcreation.text=Enable Prisoner Procreation -lblUsePrisonerProcreation.tooltip=PLACEHOLDER -lblMultiplePregnancyOccurrences.text=Multiple Pregnancy Chance: 1 in -lblMultiplePregnancyOccurrences.tooltip=PLACEHOLDER -lblBabySurnameStyle.text=Baby Surname Style -lblBabySurnameStyle.tooltip=PLACEHOLDER -lblAssignNonPrisonerBabiesFounderTag.text=Non-Prisoner Babies are Founders -lblAssignNonPrisonerBabiesFounderTag.tooltip=PLACEHOLDER -lblAssignChildrenOfFoundersFounderTag.text=Children of Founders are Founders -lblAssignChildrenOfFoundersFounderTag.tooltip=PLACEHOLDER -lblDetermineFatherAtBirth.text=Determine Father at Birth -lblDetermineFatherAtBirth.tooltip=PLACEHOLDER -lblDisplayTrueDueDate.text=Display True Due Date -lblDisplayTrueDueDate.tooltip=PLACEHOLDER -lblNoInterestInChildrenDiceSize.text=No Interest in Children Chance: 1 in -lblNoInterestInChildrenDiceSize.tooltip=PLACEHOLDER -lblUseMaternityLeave.text=Enable Automatic Maternity Leave -lblUseMaternityLeave.tooltip=PLACEHOLDER -lblLogProcreation.text=Log Procreation -lblLogProcreation.tooltip=PLACEHOLDER - -# createRandomProcreationPanel -lblRandomProcreationPanel.text=Random Procreation -lblRandomProcreationMethod.text=Random Procreation Method -lblRandomProcreationMethod.tooltip=PLACEHOLDER -lblUseRelationshiplessRandomProcreation.text=Enable Random Relationshipless Procreation -lblUseRelationshiplessRandomProcreation.tooltip=PLACEHOLDER -lblUseRandomClanPersonnelProcreation.text=Enable Random Clan Procreation -lblUseRandomClanPersonnelProcreation.tooltip=PLACEHOLDER -lblUseRandomPrisonerProcreation.text=Enable Random Prisoner Procreation -lblUseRandomPrisonerProcreation.tooltip=PLACEHOLDER -lblRandomProcreationRelationshipDiceSize.text=Normal Procreation Chance: 1 in -lblRandomProcreationRelationshipDiceSize.tooltip=PLACEHOLDER -lblRandomProcreationRelationshiplessDiceSize.text=Relationshipless Procreation Chance: 1 in -lblRandomProcreationRelationshiplessDiceSize.tooltip=PLACEHOLDER - # createDeathTab lblDeathTab.text=Death Options lblDeathTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ @@ -819,7 +698,7 @@ lblAllAges.tooltip=PLACEHOLDER lblMilitaryAcademyAccidents.text=Military Accidents Chance: 1 in lblMilitaryAcademyAccidents.tooltip=PLACEHOLDER -# Life Paths Tab +# Turnover and Rention Tab turnoverAndRetentionContentTabs.title=Turnover & Retention turnoverTab.title=Turnover @@ -945,4 +824,143 @@ lblFieldKitchenCapacity.tooltip=PLACEHOLDER lblFieldKitchenIgnoreNonCombatants.text=Ignore Non-Combatants lblFieldKitchenIgnoreNonCombatants.tooltip=PLACEHOLDER lblFatigueLeaveThreshold.text=Automatic Leave Threshold -lblFatigueLeaveThreshold.tooltip=PLACEHOLDER \ No newline at end of file +lblFatigueLeaveThreshold.tooltip=PLACEHOLDER + +## Relationships Tab +relationshipsContentTabs.title=Relationships + +marriageTab.title=Marriage +marriageTab.border="In a universe filled with war and chaos, marriage is the one alliance\ + \ that keeps you grounded. When the battles end, it's the bond you fight to protect."\ +
- Lieutenant Elara "Sunburst" Tate, Steelclaw Company + +divorceTab.title=Divorce +divorceTab.border="Divorce is just like ejecting from a 'mek: it's messy, expensive, and\ + \ you're lucky if you escape in one piece."\ +
- Sergeant Quinn "Deadeye" Mallory, Crimson Fang Mercs + +procreationTab.title=Procreation +procreationTab.border="In this galaxy, raising kids is tougher than raising a lance. At\ + \ least 'meks come with an instruction manual."\ +
- Captain Dani "Ironheart" Cole, Steel Talon Company + +# createMarriageTab +lblMarriageTab.text=Marriage Options +lblMarriageTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblUseManualMarriages.text=Enable Manual Marriages +lblUseManualMarriages.tooltip=PLACEHOLDER +lblUseClanPersonnelMarriages.text=Enable Clan Marriages +lblUseClanPersonnelMarriages.tooltip=PLACEHOLDER +lblUsePrisonerMarriages.text=Enable Prisoner Marriages +lblUsePrisonerMarriages.tooltip=PLACEHOLDER +lblNoInterestInMarriageDiceSize.text=No Interest in Marriage Chance: 1 in +lblNoInterestInMarriageDiceSize.tooltip=PLACEHOLDER +lblCheckMutualAncestorsDepth.text=Minimum Ancestor Depth +lblCheckMutualAncestorsDepth.tooltip=PLACEHOLDER +lblLogMarriageNameChanges.text=Log Name Changes +lblLogMarriageNameChanges.tooltip=PLACEHOLDER + +# createRandomMarriagePanel +lblRandomMarriages.text=Random Marriages +lblRandomMarriageMethod.text=Random Marriage Method +lblRandomMarriageMethod.tooltip=PLACEHOLDER +lblUseRandomClanPersonnelMarriages.text=Enable Random Clan Marriages +lblUseRandomClanPersonnelMarriages.tooltip=PLACEHOLDER +lblUseRandomPrisonerMarriages.text=Enable Random Prisoner Marriages +lblUseRandomPrisonerMarriages.tooltip=PLACEHOLDER +lblRandomMarriageAgeRange.text=Random Marriage Age Band +lblRandomMarriageAgeRange.tooltip=PLACEHOLDER + +# createPercentageRandomMarriagePanel +lblPercentageRandomMarriagePanel.text=Marriage Dice +lblRandomMarriageOppositeSexDiceSize.text=Opposite Sex Marriage Chance: 1 in +lblRandomMarriageOppositeSexDiceSize.tooltip=PLACEHOLDER +lblRandomSameSexMarriageDiceSize.text=Same-Sex Marriage Chance: 1 in +lblRandomSameSexMarriageDiceSize.tooltip=PLACEHOLDER +lblRandomNewDependentMarriage.text=Inter-Unit Marriage Chance: 1 in +lblRandomNewDependentMarriage.tooltip=PLACEHOLDER + +# createDivorceTab +lblDivorceTab.text=Divorce Options +lblDivorceTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblUseManualDivorce.text=Enable Manual Divorce +lblUseManualDivorce.tooltip=PLACEHOLDER +lblUseClanPersonnelDivorce.text=Enable Manual Clan Divorce +lblUseClanPersonnelDivorce.tooltip=PLACEHOLDER +lblUsePrisonerDivorce.text=Enable Manual Prisoner Divorce +lblUsePrisonerDivorce.tooltip=PLACEHOLDER + +# createRandomDivorcePanel +lblRandomDivorcePanel.text=Random Divorce +lblRandomDivorceMethod.text=Random Divorce Method +lblRandomDivorceMethod.tooltip=PLACEHOLDER +lblUseRandomOppositeSexDivorce.text=Use Random Opposite Sex Divorce +lblUseRandomOppositeSexDivorce.tooltip=PLACEHOLDER +lblUseRandomSameSexDivorce.text=Use Random Same Sex Divorce +lblUseRandomSameSexDivorce.tooltip=PLACEHOLDER +lblUseRandomClanPersonnelDivorce.text=Use Random Clan Divorce +lblUseRandomClanPersonnelDivorce.tooltip=PLACEHOLDER +lblUseRandomPrisonerDivorce.text=Use Random Prisoner Divorce +lblUseRandomPrisonerDivorce.tooltip=PLACEHOLDER +lblRandomDivorceDiceSize.text=Random Divorce Chance: 1 in +lblRandomDivorceDiceSize.tooltip=PLACEHOLDER + +# createProcreationTab +lblProcreationTab.text=Procreation Options +lblProcreationTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam + +# createProcreationGeneralOptionsPanel +lblUseManualProcreation.text=Enable Manual Procreation +lblUseManualProcreation.tooltip=PLACEHOLDER +lblUseClanPersonnelProcreation.text=Enable Clan Procreation +lblUseClanPersonnelProcreation.tooltip=PLACEHOLDER +lblUsePrisonerProcreation.text=Enable Prisoner Procreation +lblUsePrisonerProcreation.tooltip=PLACEHOLDER +lblMultiplePregnancyOccurrences.text=Multiple Pregnancy Chance: 1 in +lblMultiplePregnancyOccurrences.tooltip=PLACEHOLDER +lblBabySurnameStyle.text=Baby Surname Style +lblBabySurnameStyle.tooltip=PLACEHOLDER +lblAssignNonPrisonerBabiesFounderTag.text=Non-Prisoner Babies are Founders +lblAssignNonPrisonerBabiesFounderTag.tooltip=PLACEHOLDER +lblAssignChildrenOfFoundersFounderTag.text=Children of Founders are Founders +lblAssignChildrenOfFoundersFounderTag.tooltip=PLACEHOLDER +lblDetermineFatherAtBirth.text=Determine Father at Birth +lblDetermineFatherAtBirth.tooltip=PLACEHOLDER +lblDisplayTrueDueDate.text=Display True Due Date +lblDisplayTrueDueDate.tooltip=PLACEHOLDER +lblNoInterestInChildrenDiceSize.text=No Interest in Children Chance: 1 in +lblNoInterestInChildrenDiceSize.tooltip=PLACEHOLDER +lblUseMaternityLeave.text=Enable Automatic Maternity Leave +lblUseMaternityLeave.tooltip=PLACEHOLDER +lblLogProcreation.text=Log Procreation +lblLogProcreation.tooltip=PLACEHOLDER + +# createRandomProcreationPanel +lblRandomProcreationPanel.text=Random Procreation +lblRandomProcreationMethod.text=Random Procreation Method +lblRandomProcreationMethod.tooltip=PLACEHOLDER +lblUseRelationshiplessRandomProcreation.text=Enable Random Relationshipless Procreation +lblUseRelationshiplessRandomProcreation.tooltip=PLACEHOLDER +lblUseRandomClanPersonnelProcreation.text=Enable Random Clan Procreation +lblUseRandomClanPersonnelProcreation.tooltip=PLACEHOLDER +lblUseRandomPrisonerProcreation.text=Enable Random Prisoner Procreation +lblUseRandomPrisonerProcreation.tooltip=PLACEHOLDER +lblRandomProcreationRelationshipDiceSize.text=Normal Procreation Chance: 1 in +lblRandomProcreationRelationshipDiceSize.tooltip=PLACEHOLDER +lblRandomProcreationRelationshiplessDiceSize.text=Relationshipless Procreation Chance: 1 in +lblRandomProcreationRelationshiplessDiceSize.tooltip=PLACEHOLDER \ No newline at end of file diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 45cf35f106..0858378a5b 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -120,17 +120,22 @@ private JTabbedPane createHumanResourcesParentTab() { "medicalTab", personnelTab.createMedicalTab(), "salariesTab", personnelTab.createSalariesTab())); - // Life Paths - LifePathsTab lifePathsTab = new LifePathsTab(campaign, getFrame(), "lifePathsTab"); - - JTabbedPane lifePathsContentTabs = createSubTabs(Map.of( - "lifePathsGeneralTab", lifePathsTab.createGeneralTab(), - "backgroundsTab", lifePathsTab.createBackgroundsTab(), - "relationshipsMarriageTab", lifePathsTab.createMarriageTab(), - "relationshipsDivorceTab", lifePathsTab.createDivorceTab(), - "relationshipsProcreationTab", lifePathsTab.createProcreationTab(), - "deathTab", lifePathsTab.createDeathTab(), - "educationTab", lifePathsTab.createEducationTab())); + // Biography + biographyTab biographyTab = new biographyTab(campaign, getFrame(), "biographyTab"); + + JTabbedPane biographyContentTabs = createSubTabs(Map.of( + "biographyGeneralTab", biographyTab.createGeneralTab(), + "backgroundsTab", biographyTab.createBackgroundsTab(), + "deathTab", biographyTab.createDeathTab(), + "educationTab", biographyTab.createEducationTab())); + + // Relationships + RelationshipsTab relationshipsTab = new RelationshipsTab(getFrame(), "relationshipsTab"); + + JTabbedPane relationshipsContentTabs = createSubTabs(Map.of( + "marriageTab", relationshipsTab.createMarriageTab(), + "divorceTab", relationshipsTab.createDivorceTab(), + "procreationTab", relationshipsTab.createProcreationTab())); // Turnover and Retention TurnoverAndRetentionTab turnoverAndRetentionTab = new TurnoverAndRetentionTab(getFrame(), @@ -139,14 +144,18 @@ private JTabbedPane createHumanResourcesParentTab() { JTabbedPane turnoverAndRetentionContentTabs = createSubTabs(Map.of( "turnoverTab", turnoverAndRetentionTab.createTurnoverTab(), "fatigueTab", turnoverAndRetentionTab.createFatigueTab())); + // Name and Portrait Generation + // Rank Systems // Add Tabs humanResourcesParentTab.addTab(String.format("%s", 4, resources.getString("personnelContentTabs.title")), personnelContentTabs); humanResourcesParentTab.addTab(String.format("%s", 4, - resources.getString("lifePathsContentTabs.title")), lifePathsContentTabs); + resources.getString("biographyContentTabs.title")), biographyContentTabs); + humanResourcesParentTab.addTab(String.format("%s", 4, + resources.getString("relationshipsContentTabs.title")), relationshipsContentTabs); humanResourcesParentTab.addTab(String.format("%s", 4, resources.getString("turnoverAndRetentionContentTabs.title")), turnoverAndRetentionContentTabs); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java new file mode 100644 index 0000000000..31eb79ddd7 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java @@ -0,0 +1,737 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +import megamek.client.ui.baseComponents.MMComboBox; +import mekhq.campaign.personnel.enums.BabySurnameStyle; +import mekhq.campaign.personnel.enums.RandomDivorceMethod; +import mekhq.campaign.personnel.enums.RandomMarriageMethod; +import mekhq.campaign.personnel.enums.RandomProcreationMethod; + +import javax.swing.*; +import javax.swing.GroupLayout.Alignment; +import java.awt.*; + +import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; + +public class RelationshipsTab { + JFrame frame; + String name; + + //start Marriage Tab + private JPanel pnlMarriageGeneralOptions; + private JCheckBox chkUseManualMarriages; + private JCheckBox chkUseClanPersonnelMarriages; + private JCheckBox chkUsePrisonerMarriages; + private JLabel lblNoInterestInMarriageDiceSize; + private JSpinner spnNoInterestInMarriageDiceSize; + private JLabel lblCheckMutualAncestorsDepth; + private JSpinner spnCheckMutualAncestorsDepth; + private JCheckBox chkLogMarriageNameChanges; + + private JPanel pnlRandomMarriage; + private JLabel lblRandomMarriageMethod; + private MMComboBox comboRandomMarriageMethod; + private JCheckBox chkUseRandomClanPersonnelMarriages; + private JCheckBox chkUseRandomPrisonerMarriages; + private JLabel lblRandomMarriageAgeRange; + private JSpinner spnRandomMarriageAgeRange; + + private JPanel pnlPercentageRandomMarriage; + private JLabel lblRandomMarriageOppositeSexDiceSize; + private JSpinner spnRandomMarriageDiceSize; + private JLabel lblRandomSameSexMarriageDiceSize; + private JSpinner spnRandomSameSexMarriageDiceSize; + private JLabel lblRandomNewDependentMarriage; + private JSpinner spnRandomNewDependentMarriage; + //end Marriage Tab + + //start Divorce Tab + private JCheckBox chkUseManualDivorce; + private JCheckBox chkUseClanPersonnelDivorce; + private JCheckBox chkUsePrisonerDivorce; + + private JPanel pnlRandomDivorce; + + private JLabel lblRandomDivorceMethod; + private MMComboBox comboRandomDivorceMethod; + private JCheckBox chkUseRandomOppositeSexDivorce; + private JCheckBox chkUseRandomSameSexDivorce; + private JCheckBox chkUseRandomClanPersonnelDivorce; + private JCheckBox chkUseRandomPrisonerDivorce; + private JLabel lblRandomDivorceDiceSize; + private JSpinner spnRandomDivorceDiceSize; + //end Divorce Tab + + //start Procreation Tab + private JCheckBox chkUseManualProcreation; + private JCheckBox chkUseClanPersonnelProcreation; + private JCheckBox chkUsePrisonerProcreation; + private JLabel lblMultiplePregnancyOccurrences; + private JSpinner spnMultiplePregnancyOccurrences; + private JLabel lblBabySurnameStyle; + private MMComboBox comboBabySurnameStyle; + private JCheckBox chkAssignNonPrisonerBabiesFounderTag; + private JCheckBox chkAssignChildrenOfFoundersFounderTag; + private JCheckBox chkDetermineFatherAtBirth; + private JCheckBox chkDisplayTrueDueDate; + private JLabel lblNoInterestInChildrenDiceSize; + private JSpinner spnNoInterestInChildrenDiceSize; + private JCheckBox chkUseMaternityLeave; + private JCheckBox chkLogProcreation; + + private JPanel pnlProcreationGeneralOptionsPanel; + private JPanel pnlRandomProcreationPanel; + private JLabel lblRandomProcreationMethod; + private MMComboBox comboRandomProcreationMethod; + private JCheckBox chkUseRelationshiplessRandomProcreation; + private JCheckBox chkUseRandomClanPersonnelProcreation; + private JCheckBox chkUseRandomPrisonerProcreation; + private JLabel lblRandomProcreationRelationshipDiceSize; + private JSpinner spnRandomProcreationRelationshipDiceSize; + private JLabel lblRandomProcreationRelationshiplessDiceSize; + private JSpinner spnRandomProcreationRelationshiplessDiceSize; + //end Procreation Tab + + RelationshipsTab(JFrame frame, String name) { + this.frame = frame; + this.name = name; + + initialize(); + } + + protected void initialize() { + // Marriage Tab + pnlMarriageGeneralOptions = new JPanel(); + chkUseManualMarriages = new JCheckBox(); + chkUseClanPersonnelMarriages = new JCheckBox(); + chkUsePrisonerMarriages = new JCheckBox(); + lblNoInterestInMarriageDiceSize = new JLabel(); + spnNoInterestInMarriageDiceSize = new JSpinner(); + lblCheckMutualAncestorsDepth = new JLabel(); + spnCheckMutualAncestorsDepth = new JSpinner(); + chkLogMarriageNameChanges = new JCheckBox(); + + pnlRandomMarriage = new JPanel(); + comboRandomMarriageMethod = new MMComboBox<>("comboRandomMarriageMethod", + RandomMarriageMethod.values()); + + pnlRandomMarriage = new JPanel(); + lblRandomMarriageMethod = new JLabel(); + comboRandomMarriageMethod = new MMComboBox<>("comboRandomMarriageMethod", + RandomMarriageMethod.values()); + chkUseRandomClanPersonnelMarriages = new JCheckBox(); + chkUseRandomPrisonerMarriages = new JCheckBox(); + lblRandomMarriageAgeRange = new JLabel(); + spnRandomMarriageAgeRange = new JSpinner(); + + pnlPercentageRandomMarriage = new JPanel(); + lblRandomMarriageOppositeSexDiceSize = new JLabel(); + spnRandomMarriageDiceSize = new JSpinner(); + lblRandomSameSexMarriageDiceSize = new JLabel(); + spnRandomSameSexMarriageDiceSize = new JSpinner(); + lblRandomNewDependentMarriage = new JLabel(); + spnRandomNewDependentMarriage = new JSpinner(); + + // Divorce Tab + chkUseManualDivorce = new JCheckBox(); + chkUseClanPersonnelDivorce = new JCheckBox(); + chkUsePrisonerDivorce = new JCheckBox(); + + pnlRandomDivorce = new JPanel(); + lblRandomDivorceMethod = new JLabel(); + comboRandomDivorceMethod = new MMComboBox<>("comboRandomDivorceMethod", RandomDivorceMethod.values()); + chkUseRandomOppositeSexDivorce = new JCheckBox(); + chkUseRandomSameSexDivorce = new JCheckBox(); + chkUseRandomClanPersonnelDivorce = new JCheckBox(); + chkUseRandomPrisonerDivorce = new JCheckBox(); + lblRandomDivorceDiceSize = new JLabel(); + spnRandomDivorceDiceSize = new JSpinner(); + + // Procreation Tab + pnlProcreationGeneralOptionsPanel = new JPanel(); + chkUseManualProcreation = new JCheckBox(); + chkUseClanPersonnelProcreation = new JCheckBox(); + chkUsePrisonerProcreation = new JCheckBox(); + lblMultiplePregnancyOccurrences = new JLabel(); + spnMultiplePregnancyOccurrences = new JSpinner(); + lblBabySurnameStyle = new JLabel(); + comboBabySurnameStyle = new MMComboBox<>("comboBabySurnameStyle", BabySurnameStyle.values()); + chkAssignNonPrisonerBabiesFounderTag = new JCheckBox(); + chkAssignChildrenOfFoundersFounderTag = new JCheckBox(); + chkDetermineFatherAtBirth = new JCheckBox(); + chkDisplayTrueDueDate = new JCheckBox(); + lblNoInterestInChildrenDiceSize = new JLabel(); + spnNoInterestInChildrenDiceSize = new JSpinner(); + chkUseMaternityLeave = new JCheckBox(); + chkLogProcreation = new JCheckBox(); + + pnlRandomProcreationPanel = new JPanel(); + lblRandomProcreationMethod = new JLabel(); + comboRandomProcreationMethod = new MMComboBox<>("comboRandomProcreationMethod", + RandomProcreationMethod.values()); + chkUseRelationshiplessRandomProcreation = new JCheckBox(); + chkUseRandomClanPersonnelProcreation = new JCheckBox(); + chkUseRandomPrisonerProcreation = new JCheckBox(); + lblRandomProcreationRelationshipDiceSize = new JLabel(); + spnRandomProcreationRelationshipDiceSize = new JSpinner(); + lblRandomProcreationRelationshiplessDiceSize = new JLabel(); + spnRandomProcreationRelationshiplessDiceSize = new JSpinner(); + }/** + * Creates a panel for the Marriage tab with various input components and panels related to marriage settings. + * + * @return a {@link} representing the Marriage tab with checkboxes for manual, clan personnel, + * prisoner marriages, options for marriage characteristics, logging marriage name changes, surname + * weight settings, and random marriage generation. + */ + JPanel createMarriageTab() { + // Header + JPanel headerPanel = createHeaderPanel("MarriageTab", + getImageDirectory() + "logo_federated_commonwealth.png", + false, "", true); + + // Contents + pnlMarriageGeneralOptions = createMarriageGeneralOptionsPanel(); + pnlRandomMarriage = createRandomMarriagePanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("MarriageTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(pnlMarriageGeneralOptions) + .addComponent(pnlRandomMarriage))); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addGroup(layout.createSequentialGroup() + .addComponent(pnlMarriageGeneralOptions) + .addComponent(pnlRandomMarriage) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + + // Create Parent Panel and return + return createParentPanel(panel, "MarriageTab"); + } + + /** + * Creates a panel for general marriage options with checkboxes and input components. + * + * @return a {@link JPanel} representing the general marriage options panel + */ + JPanel createMarriageGeneralOptionsPanel() { + // Contents + chkUseManualMarriages = createCheckBox("UseManualMarriages", null); + chkUseClanPersonnelMarriages = createCheckBox("UseClanPersonnelMarriages", null); + chkUsePrisonerMarriages = createCheckBox("UsePrisonerMarriages", null); + + lblNoInterestInMarriageDiceSize = createLabel("NoInterestInMarriageDiceSize", null); + spnNoInterestInMarriageDiceSize = createSpinner("NoInterestInMarriageDiceSize", null, + 10, 1, 100000, 1); + + lblCheckMutualAncestorsDepth = createLabel("CheckMutualAncestorsDepth", null); + spnCheckMutualAncestorsDepth = createSpinner("CheckMutualAncestorsDepth", null, + 4, 0, 20, 1); + + chkLogMarriageNameChanges = createCheckBox("LogMarriageNameChanges", null); + + // Layout the Panel + final JPanel panel = createStandardPanel("MarriageGeneralOptionsPanel", + false, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(chkUseManualMarriages) + .addComponent(chkUseClanPersonnelMarriages) + .addComponent(chkUsePrisonerMarriages) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblNoInterestInMarriageDiceSize) + .addComponent(spnNoInterestInMarriageDiceSize)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblCheckMutualAncestorsDepth) + .addComponent(spnCheckMutualAncestorsDepth)) + .addComponent(chkLogMarriageNameChanges)); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(chkUseManualMarriages) + .addComponent(chkUseClanPersonnelMarriages) + .addComponent(chkUsePrisonerMarriages) + .addGroup(layout.createSequentialGroup() + .addComponent(lblNoInterestInMarriageDiceSize) + .addComponent(spnNoInterestInMarriageDiceSize) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblCheckMutualAncestorsDepth) + .addComponent(spnCheckMutualAncestorsDepth) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkLogMarriageNameChanges))); + + return panel; + } + + /** + * Creates a panel for random marriage settings, including options for different marriage methods, + * using random clan personnel and prisoner marriages, setting age range for marriages, and + * percentage settings. + * + * @return a {@link JPanel} representing the random marriage panel with various input components + * and panels for configuring random marriage settings + */ + JPanel createRandomMarriagePanel() { + // Contents + lblRandomMarriageMethod = createLabel("RandomMarriageMethod", null); + comboRandomMarriageMethod.setRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(final JList list, final Object value, + final int index, final boolean isSelected, + final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof RandomMarriageMethod) { + list.setToolTipText(((RandomMarriageMethod) value).getToolTipText()); + } + return this; + } + }); + + chkUseRandomClanPersonnelMarriages = createCheckBox("UseRandomClanPersonnelMarriages", null); + chkUseRandomPrisonerMarriages = createCheckBox("UseRandomPrisonerMarriages", null); + + lblRandomMarriageAgeRange = createLabel("RandomMarriageAgeRange", null); + spnRandomMarriageAgeRange = createSpinner("RandomMarriageAgeRange", null, + 10, 0, 100, 1.0); + + pnlPercentageRandomMarriage = createPercentageRandomMarriagePanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("RandomMarriages", true, + "RandomMarriages"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblRandomMarriageMethod) + .addComponent(comboRandomMarriageMethod)) + .addComponent(chkUseRandomClanPersonnelMarriages) + .addComponent(chkUseRandomPrisonerMarriages) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblRandomMarriageAgeRange) + .addComponent(spnRandomMarriageAgeRange)) + .addComponent(pnlPercentageRandomMarriage)); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblRandomMarriageMethod) + .addComponent(comboRandomMarriageMethod) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkUseRandomClanPersonnelMarriages) + .addComponent(chkUseRandomPrisonerMarriages) + .addGroup(layout.createSequentialGroup() + .addComponent(lblRandomMarriageAgeRange) + .addComponent(spnRandomMarriageAgeRange) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(pnlPercentageRandomMarriage))); + + return panel; + } + + /** + * Creates a panel for setting percentage-based random marriage settings. + * + * @return a {@link JPanel} representing the Percentage Random Marriage panel with input components + * for setting opposite-sex marriage dice size, same-sex marriage dice size, and new dependent + * marriage dice size + */ + JPanel createPercentageRandomMarriagePanel() { + // Contents + lblRandomMarriageOppositeSexDiceSize = createLabel("RandomMarriageOppositeSexDiceSize", + null); + spnRandomMarriageDiceSize = createSpinner("RandomMarriageOppositeSexDiceSize", + null, 5000, 0, 100000, 1); + + lblRandomSameSexMarriageDiceSize = createLabel("RandomSameSexMarriageDiceSize", null); + spnRandomSameSexMarriageDiceSize = createSpinner("RandomSameSexMarriageDiceSize", + null, 14, 0, 100000, 1); + + lblRandomNewDependentMarriage = createLabel("RandomNewDependentMarriage", null); + spnRandomNewDependentMarriage = createSpinner("RandomSameSexMarriageDiceSize", + null, 20, 0, 100000, 1); + + // Layout the Panel + final JPanel panel = createStandardPanel("PercentageRandomMarriagePanel", true, + "PercentageRandomMarriagePanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblRandomMarriageOppositeSexDiceSize) + .addComponent(spnRandomMarriageDiceSize)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblRandomSameSexMarriageDiceSize) + .addComponent(spnRandomSameSexMarriageDiceSize)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblRandomNewDependentMarriage) + .addComponent(spnRandomNewDependentMarriage))); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblRandomMarriageOppositeSexDiceSize) + .addComponent(spnRandomMarriageDiceSize) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblRandomSameSexMarriageDiceSize) + .addComponent(spnRandomSameSexMarriageDiceSize) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblRandomNewDependentMarriage) + .addComponent(spnRandomNewDependentMarriage) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + + return panel; + } + + /** + * Creates a tab for divorce settings with various checkboxes and panels for manual, clan personnel, + * and prisoner divorces. + * + * @return a {@link JPanel} representing the Divorce tab with checkboxes for manual divorce, + * clan personnel divorce, prisoner divorce, and a panel for configuring random divorce settings. + */ + JPanel createDivorceTab() { + // Header + JPanel headerPanel = createHeaderPanel("DivorceTab", + getImageDirectory() + "logo_clan_hells_horses.png", + false, "", true); + + // Contents + chkUseManualDivorce = createCheckBox("UseManualDivorce", null); + chkUseClanPersonnelDivorce = createCheckBox("UseClanPersonnelDivorce", null); + chkUsePrisonerDivorce = createCheckBox("UsePrisonerDivorce", null); + + pnlRandomDivorce = createRandomDivorcePanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("DivorceTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addComponent(chkUseManualDivorce) + .addComponent(chkUseClanPersonnelDivorce) + .addComponent(chkUsePrisonerDivorce) + .addComponent(pnlRandomDivorce)); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addComponent(chkUseManualDivorce) + .addComponent(chkUseClanPersonnelDivorce) + .addComponent(chkUsePrisonerDivorce) + .addComponent(pnlRandomDivorce))); + + // Create Parent Panel and return + return createParentPanel(panel, "DivorceTab"); + } + + /** + * Creates a panel for the Divorce tab with checkboxes for manual divorce, clan personnel divorce, + * prisoner divorce, and a panel for configuring random divorce settings. + * + * @return a {@link JPanel} representing the Divorce tab with various components for configuring divorce settings + */ + JPanel createRandomDivorcePanel() { + // Contents + lblRandomDivorceMethod = createLabel("RandomDivorceMethod", null); + comboRandomDivorceMethod.setRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(final JList list, final Object value, + final int index, final boolean isSelected, + final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof RandomDivorceMethod) { + list.setToolTipText(((RandomDivorceMethod) value).getToolTipText()); + } + return this; + } + }); + + chkUseRandomOppositeSexDivorce = createCheckBox("UseRandomOppositeSexDivorce", null); + chkUseRandomSameSexDivorce = createCheckBox("UseRandomSameSexDivorce", null); + chkUseRandomClanPersonnelDivorce = createCheckBox("UseRandomClanPersonnelDivorce", null); + chkUseRandomPrisonerDivorce = createCheckBox("UseRandomPrisonerDivorce", null); + + lblRandomDivorceDiceSize = createLabel("RandomDivorceDiceSize", null); + spnRandomDivorceDiceSize = createSpinner("RandomDivorceDiceSize", null, + 900, 0, 100000, 1); + + // Layout the Panel + final JPanel panel = createStandardPanel("RandomDivorcePanel", true, "RandomDivorcePanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblRandomDivorceMethod) + .addComponent(comboRandomDivorceMethod)) + .addComponent(chkUseRandomOppositeSexDivorce) + .addComponent(chkUseRandomSameSexDivorce) + .addComponent(chkUseRandomClanPersonnelDivorce) + .addComponent(chkUseRandomPrisonerDivorce) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblRandomDivorceDiceSize) + .addComponent(spnRandomDivorceDiceSize))); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblRandomDivorceMethod) + .addComponent(comboRandomDivorceMethod) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkUseRandomOppositeSexDivorce) + .addComponent(chkUseRandomSameSexDivorce) + .addComponent(chkUseRandomClanPersonnelDivorce) + .addComponent(chkUseRandomPrisonerDivorce) + .addGroup(layout.createSequentialGroup() + .addComponent(lblRandomDivorceDiceSize) + .addComponent(spnRandomDivorceDiceSize) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + + return panel; + } + + /** + * Creates a panel for the Procreation tab with header, general options panel, and random procreation panel. + * + * @return a {@link JPanel} representing the Procreation tab with header, general options panel, + * and random procreation panel + */ + JPanel createProcreationTab() { + // Header + JPanel headerPanel = createHeaderPanel("ProcreationTab", + getImageDirectory() + "logo_clan_ice_hellion.png", + false, "", true); + + // Contents + pnlProcreationGeneralOptionsPanel = createProcreationGeneralOptionsPanel(); + pnlRandomProcreationPanel = createRandomProcreationPanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("ProcreationTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(pnlProcreationGeneralOptionsPanel) + .addComponent(pnlRandomProcreationPanel))); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addGroup(layout.createSequentialGroup() + .addComponent(pnlProcreationGeneralOptionsPanel) + .addComponent(pnlRandomProcreationPanel) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + + // Create Parent Panel and return + return createParentPanel(panel, "ProcreationTab"); + } + + /** + * @return the {@link JPanel} containing the procreation settings components + */ + JPanel createProcreationGeneralOptionsPanel() { + // Contents + chkUseManualProcreation = createCheckBox("UseManualProcreation", null); + chkUseClanPersonnelProcreation = createCheckBox("UseClanPersonnelProcreation", null); + chkUsePrisonerProcreation = createCheckBox("UsePrisonerProcreation", null); + + lblMultiplePregnancyOccurrences = createLabel("MultiplePregnancyOccurrences", null); + spnMultiplePregnancyOccurrences = createSpinner("MultiplePregnancyOccurrences", null, + 50, 1, 1000, 1); + + lblBabySurnameStyle = createLabel("BabySurnameStyle", null); + comboBabySurnameStyle.setRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(final JList list, final Object value, + final int index, final boolean isSelected, + final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof BabySurnameStyle) { + list.setToolTipText(((BabySurnameStyle) value).getToolTipText()); + } + return this; + } + }); + + chkAssignNonPrisonerBabiesFounderTag = createCheckBox("AssignNonPrisonerBabiesFounderTag", + null); + chkAssignChildrenOfFoundersFounderTag = createCheckBox("AssignChildrenOfFoundersFounderTag", + null); + chkDetermineFatherAtBirth = createCheckBox("DetermineFatherAtBirth", null); + chkDisplayTrueDueDate = createCheckBox("DisplayTrueDueDate", null); + + lblNoInterestInChildrenDiceSize = createLabel("NoInterestInChildrenDiceSize", null); + spnNoInterestInChildrenDiceSize = createSpinner("NoInterestInChildrenDiceSize", null, + 3, 1, 100000, 1); + + chkUseMaternityLeave = createCheckBox("UseMaternityLeave", null); + chkLogProcreation = createCheckBox("LogProcreation", null); + + pnlRandomProcreationPanel = createRandomProcreationPanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("ProcreationGeneralOptionsPanel", + false, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(chkUseManualProcreation) + .addComponent(chkUseClanPersonnelProcreation) + .addComponent(chkUsePrisonerProcreation) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblMultiplePregnancyOccurrences) + .addComponent(spnMultiplePregnancyOccurrences)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblBabySurnameStyle) + .addComponent(comboBabySurnameStyle)) + .addComponent(chkAssignNonPrisonerBabiesFounderTag) + .addComponent(chkAssignChildrenOfFoundersFounderTag) + .addComponent(chkDetermineFatherAtBirth) + .addComponent(chkDisplayTrueDueDate) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblNoInterestInChildrenDiceSize) + .addComponent(spnNoInterestInChildrenDiceSize)) + .addComponent(chkUseMaternityLeave) + .addComponent(chkLogProcreation)); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(chkUseManualProcreation) + .addComponent(chkUseClanPersonnelProcreation) + .addComponent(chkUsePrisonerProcreation) + .addGroup(layout.createSequentialGroup() + .addComponent(lblMultiplePregnancyOccurrences) + .addComponent(spnMultiplePregnancyOccurrences) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblBabySurnameStyle) + .addComponent(comboBabySurnameStyle) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkAssignNonPrisonerBabiesFounderTag) + .addComponent(chkAssignChildrenOfFoundersFounderTag) + .addComponent(chkDetermineFatherAtBirth) + .addComponent(chkDisplayTrueDueDate) + .addGroup(layout.createSequentialGroup() + .addComponent(lblNoInterestInChildrenDiceSize) + .addComponent(spnNoInterestInChildrenDiceSize) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkUseMaternityLeave) + .addComponent(chkLogProcreation))); + + return panel; + } + + /** + * @return a {@link JPanel} containing the configured components for random procreation settings + */ + JPanel createRandomProcreationPanel() { + // Contents + lblRandomProcreationMethod = createLabel("RandomProcreationMethod", null); + comboRandomProcreationMethod.setRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(final JList list, final Object value, + final int index, final boolean isSelected, + final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof RandomProcreationMethod) { + list.setToolTipText(((RandomProcreationMethod) value).getToolTipText()); + } + return this; + } + }); + + chkUseRelationshiplessRandomProcreation =createCheckBox("UseRelationshiplessRandomProcreation", + null); + chkUseRandomClanPersonnelProcreation = createCheckBox("UseRandomClanPersonnelProcreation", + null); + chkUseRandomPrisonerProcreation = createCheckBox("UseRandomPrisonerProcreation", null); + + lblRandomProcreationRelationshipDiceSize = createLabel("RandomProcreationRelationshipDiceSize", + null); + spnRandomProcreationRelationshipDiceSize = createSpinner("RandomProcreationRelationshipDiceSize", + null, 621, 0, 100000, 1); + + lblRandomProcreationRelationshiplessDiceSize = createLabel("RandomProcreationRelationshiplessDiceSize", + null); + spnRandomProcreationRelationshiplessDiceSize = createSpinner("RandomProcreationRelationshiplessDiceSize", + null, 1861, 0, 100000, 1); + + // Layout the Panel + final JPanel panel = createStandardPanel("RandomProcreationPanel", true, + "RandomProcreationPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblRandomProcreationMethod) + .addComponent(comboRandomProcreationMethod)) + .addComponent(chkUseRelationshiplessRandomProcreation) + .addComponent(chkUseRandomClanPersonnelProcreation) + .addComponent(chkUseRandomPrisonerProcreation) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblRandomProcreationRelationshipDiceSize) + .addComponent(spnRandomProcreationRelationshipDiceSize)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblRandomProcreationRelationshiplessDiceSize) + .addComponent(spnRandomProcreationRelationshiplessDiceSize))); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblRandomProcreationMethod) + .addComponent(comboRandomProcreationMethod) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkUseRelationshiplessRandomProcreation) + .addComponent(chkUseRandomClanPersonnelProcreation) + .addComponent(chkUseRandomPrisonerProcreation) + .addGroup(layout.createSequentialGroup() + .addComponent(lblRandomProcreationRelationshipDiceSize) + .addComponent(spnRandomProcreationRelationshipDiceSize) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblRandomProcreationRelationshiplessDiceSize) + .addComponent(spnRandomProcreationRelationshiplessDiceSize) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + + return panel; + } +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java similarity index 54% rename from MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java rename to MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java index 8202b27136..228527702f 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/LifePathsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java @@ -4,7 +4,9 @@ import megamek.client.ui.baseComponents.MMComboBox; import megamek.common.annotations.Nullable; import mekhq.campaign.Campaign; -import mekhq.campaign.personnel.enums.*; +import mekhq.campaign.personnel.enums.AgeGroup; +import mekhq.campaign.personnel.enums.FamilialRelationshipDisplayLevel; +import mekhq.campaign.personnel.enums.RandomDeathMethod; import mekhq.campaign.universe.Faction; import mekhq.campaign.universe.Planet; import mekhq.campaign.universe.PlanetarySystem; @@ -19,7 +21,7 @@ import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; -public class LifePathsTab { +public class biographyTab { Campaign campaign; JFrame frame; String name; @@ -61,81 +63,6 @@ public class LifePathsTab { private JCheckBox chkExtraRandomOrigin; //end Backgrounds Tab - //start Marriage Tab - private JPanel pnlMarriageGeneralOptions; - private JCheckBox chkUseManualMarriages; - private JCheckBox chkUseClanPersonnelMarriages; - private JCheckBox chkUsePrisonerMarriages; - private JLabel lblNoInterestInMarriageDiceSize; - private JSpinner spnNoInterestInMarriageDiceSize; - private JLabel lblCheckMutualAncestorsDepth; - private JSpinner spnCheckMutualAncestorsDepth; - private JCheckBox chkLogMarriageNameChanges; - - private JPanel pnlRandomMarriage; - private JLabel lblRandomMarriageMethod; - private MMComboBox comboRandomMarriageMethod; - private JCheckBox chkUseRandomClanPersonnelMarriages; - private JCheckBox chkUseRandomPrisonerMarriages; - private JLabel lblRandomMarriageAgeRange; - private JSpinner spnRandomMarriageAgeRange; - - private JPanel pnlPercentageRandomMarriage; - private JLabel lblRandomMarriageOppositeSexDiceSize; - private JSpinner spnRandomMarriageDiceSize; - private JLabel lblRandomSameSexMarriageDiceSize; - private JSpinner spnRandomSameSexMarriageDiceSize; - private JLabel lblRandomNewDependentMarriage; - private JSpinner spnRandomNewDependentMarriage; - //end Marriage Tab - - //start Divorce Tab - private JCheckBox chkUseManualDivorce; - private JCheckBox chkUseClanPersonnelDivorce; - private JCheckBox chkUsePrisonerDivorce; - - private JPanel pnlRandomDivorce; - - private JLabel lblRandomDivorceMethod; - private MMComboBox comboRandomDivorceMethod; - private JCheckBox chkUseRandomOppositeSexDivorce; - private JCheckBox chkUseRandomSameSexDivorce; - private JCheckBox chkUseRandomClanPersonnelDivorce; - private JCheckBox chkUseRandomPrisonerDivorce; - private JLabel lblRandomDivorceDiceSize; - private JSpinner spnRandomDivorceDiceSize; - //end Divorce Tab - - //start Procreation Tab - private JCheckBox chkUseManualProcreation; - private JCheckBox chkUseClanPersonnelProcreation; - private JCheckBox chkUsePrisonerProcreation; - private JLabel lblMultiplePregnancyOccurrences; - private JSpinner spnMultiplePregnancyOccurrences; - private JLabel lblBabySurnameStyle; - private MMComboBox comboBabySurnameStyle; - private JCheckBox chkAssignNonPrisonerBabiesFounderTag; - private JCheckBox chkAssignChildrenOfFoundersFounderTag; - private JCheckBox chkDetermineFatherAtBirth; - private JCheckBox chkDisplayTrueDueDate; - private JLabel lblNoInterestInChildrenDiceSize; - private JSpinner spnNoInterestInChildrenDiceSize; - private JCheckBox chkUseMaternityLeave; - private JCheckBox chkLogProcreation; - - private JPanel pnlProcreationGeneralOptionsPanel; - private JPanel pnlRandomProcreationPanel; - private JLabel lblRandomProcreationMethod; - private MMComboBox comboRandomProcreationMethod; - private JCheckBox chkUseRelationshiplessRandomProcreation; - private JCheckBox chkUseRandomClanPersonnelProcreation; - private JCheckBox chkUseRandomPrisonerProcreation; - private JLabel lblRandomProcreationRelationshipDiceSize; - private JSpinner spnRandomProcreationRelationshipDiceSize; - private JLabel lblRandomProcreationRelationshiplessDiceSize; - private JSpinner spnRandomProcreationRelationshiplessDiceSize; - //end Procreation Tab - //start Death Tab private JCheckBox chkKeepMarriedNameUponSpouseDeath; private JLabel lblRandomDeathMethod; @@ -186,13 +113,13 @@ public class LifePathsTab { //end Education Tab /** - * Initializes a new {@link LifePathsTab} with the specified campaign, frame, and name. + * Initializes a new {@link biographyTab} with the specified campaign, frame, and name. * - * @param campaign the campaign associated with the {@link LifePathsTab} - * @param frame the {@link JFrame} used for displaying the {@link LifePathsTab} - * @param name the name of the {@link LifePathsTab} + * @param campaign the campaign associated with the {@link biographyTab} + * @param frame the {@link JFrame} used for displaying the {@link biographyTab} + * @param name the name of the {@link biographyTab} */ - LifePathsTab(Campaign campaign, JFrame frame, String name) { + biographyTab(Campaign campaign, JFrame frame, String name) { this.campaign = campaign; this.frame = frame; this.name = name; @@ -248,83 +175,6 @@ protected void initialize() { chkAllowClanOrigins = new JCheckBox(); chkExtraRandomOrigin = new JCheckBox(); - // Marriage Tab - pnlMarriageGeneralOptions = new JPanel(); - chkUseManualMarriages = new JCheckBox(); - chkUseClanPersonnelMarriages = new JCheckBox(); - chkUsePrisonerMarriages = new JCheckBox(); - lblNoInterestInMarriageDiceSize = new JLabel(); - spnNoInterestInMarriageDiceSize = new JSpinner(); - lblCheckMutualAncestorsDepth = new JLabel(); - spnCheckMutualAncestorsDepth = new JSpinner(); - chkLogMarriageNameChanges = new JCheckBox(); - - pnlRandomMarriage = new JPanel(); - comboRandomMarriageMethod = new MMComboBox<>("comboRandomMarriageMethod", - RandomMarriageMethod.values()); - - pnlRandomMarriage = new JPanel(); - lblRandomMarriageMethod = new JLabel(); - comboRandomMarriageMethod = new MMComboBox<>("comboRandomMarriageMethod", - RandomMarriageMethod.values()); - chkUseRandomClanPersonnelMarriages = new JCheckBox(); - chkUseRandomPrisonerMarriages = new JCheckBox(); - lblRandomMarriageAgeRange = new JLabel(); - spnRandomMarriageAgeRange = new JSpinner(); - - pnlPercentageRandomMarriage = new JPanel(); - lblRandomMarriageOppositeSexDiceSize = new JLabel(); - spnRandomMarriageDiceSize = new JSpinner(); - lblRandomSameSexMarriageDiceSize = new JLabel(); - spnRandomSameSexMarriageDiceSize = new JSpinner(); - lblRandomNewDependentMarriage = new JLabel(); - spnRandomNewDependentMarriage = new JSpinner(); - - // Divorce Tab - chkUseManualDivorce = new JCheckBox(); - chkUseClanPersonnelDivorce = new JCheckBox(); - chkUsePrisonerDivorce = new JCheckBox(); - - pnlRandomDivorce = new JPanel(); - lblRandomDivorceMethod = new JLabel(); - comboRandomDivorceMethod = new MMComboBox<>("comboRandomDivorceMethod", RandomDivorceMethod.values()); - chkUseRandomOppositeSexDivorce = new JCheckBox(); - chkUseRandomSameSexDivorce = new JCheckBox(); - chkUseRandomClanPersonnelDivorce = new JCheckBox(); - chkUseRandomPrisonerDivorce = new JCheckBox(); - lblRandomDivorceDiceSize = new JLabel(); - spnRandomDivorceDiceSize = new JSpinner(); - - // Procreation Tab - pnlProcreationGeneralOptionsPanel = new JPanel(); - chkUseManualProcreation = new JCheckBox(); - chkUseClanPersonnelProcreation = new JCheckBox(); - chkUsePrisonerProcreation = new JCheckBox(); - lblMultiplePregnancyOccurrences = new JLabel(); - spnMultiplePregnancyOccurrences = new JSpinner(); - lblBabySurnameStyle = new JLabel(); - comboBabySurnameStyle = new MMComboBox<>("comboBabySurnameStyle", BabySurnameStyle.values()); - chkAssignNonPrisonerBabiesFounderTag = new JCheckBox(); - chkAssignChildrenOfFoundersFounderTag = new JCheckBox(); - chkDetermineFatherAtBirth = new JCheckBox(); - chkDisplayTrueDueDate = new JCheckBox(); - lblNoInterestInChildrenDiceSize = new JLabel(); - spnNoInterestInChildrenDiceSize = new JSpinner(); - chkUseMaternityLeave = new JCheckBox(); - chkLogProcreation = new JCheckBox(); - - pnlRandomProcreationPanel = new JPanel(); - lblRandomProcreationMethod = new JLabel(); - comboRandomProcreationMethod = new MMComboBox<>("comboRandomProcreationMethod", - RandomProcreationMethod.values()); - chkUseRelationshiplessRandomProcreation = new JCheckBox(); - chkUseRandomClanPersonnelProcreation = new JCheckBox(); - chkUseRandomPrisonerProcreation = new JCheckBox(); - lblRandomProcreationRelationshipDiceSize = new JLabel(); - spnRandomProcreationRelationshipDiceSize = new JSpinner(); - lblRandomProcreationRelationshiplessDiceSize = new JLabel(); - spnRandomProcreationRelationshiplessDiceSize = new JSpinner(); - // Death Tab chkKeepMarriedNameUponSpouseDeath = new JCheckBox(); lblRandomDeathMethod = new JLabel(); @@ -374,13 +224,13 @@ protected void initialize() { } /** - * Creates a general tab for the Life Paths category containing various components + * Creates a general tab for the Biography category containing various components * * @return a {@link JPanel} representing the general tab with multiple input components and panels */ JPanel createGeneralTab() { // Header - JPanel headerPanel = createHeaderPanel("LifePathsGeneralTab", + JPanel headerPanel = createHeaderPanel("BiographyGeneralTab", getImageDirectory() + "logo_federated_suns.png", false, "", true); @@ -402,7 +252,7 @@ JPanel createGeneralTab() { pnlAnniversariesPanel = createAnniversariesPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("LifePathsGeneralTab", true, ""); + final JPanel panel = createStandardPanel("BiographyGeneralTab", true, ""); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -440,7 +290,7 @@ JPanel createGeneralTab() { .addComponent(pnlAnniversariesPanel))); // Create Parent Panel and return - return createParentPanel(panel, "LifePathsGeneralTab"); + return createParentPanel(panel, "BiographyGeneralTab"); } /** @@ -702,566 +552,6 @@ private PlanetarySystem[] getPlanetarySystems(final @Nullable Faction faction) { return filteredSystems.toArray(new PlanetarySystem[0]); } - /** - * Creates a panel for the Marriage tab with various input components and panels related to marriage settings. - * - * @return a {@link} representing the Marriage tab with checkboxes for manual, clan personnel, - * prisoner marriages, options for marriage characteristics, logging marriage name changes, surname - * weight settings, and random marriage generation. - */ - JPanel createMarriageTab() { - // Header - JPanel headerPanel = createHeaderPanel("MarriageTab", - getImageDirectory() + "logo_federated_commonwealth.png", - false, "", true); - - // Contents - pnlMarriageGeneralOptions = createMarriageGeneralOptionsPanel(); - pnlRandomMarriage = createRandomMarriagePanel(); - - // Layout the Panel - final JPanel panel = createStandardPanel("MarriageTab", true, ""); - final GroupLayout layout = createStandardLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(pnlMarriageGeneralOptions) - .addComponent(pnlRandomMarriage))); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addGroup(layout.createSequentialGroup() - .addComponent(pnlMarriageGeneralOptions) - .addComponent(pnlRandomMarriage) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); - - // Create Parent Panel and return - return createParentPanel(panel, "MarriageTab"); - } - - /** - * Creates a panel for general marriage options with checkboxes and input components. - * - * @return a {@link JPanel} representing the general marriage options panel - */ - JPanel createMarriageGeneralOptionsPanel() { - // Contents - chkUseManualMarriages = createCheckBox("UseManualMarriages", null); - chkUseClanPersonnelMarriages = createCheckBox("UseClanPersonnelMarriages", null); - chkUsePrisonerMarriages = createCheckBox("UsePrisonerMarriages", null); - - lblNoInterestInMarriageDiceSize = createLabel("NoInterestInMarriageDiceSize", null); - spnNoInterestInMarriageDiceSize = createSpinner("NoInterestInMarriageDiceSize", null, - 10, 1, 100000, 1); - - lblCheckMutualAncestorsDepth = createLabel("CheckMutualAncestorsDepth", null); - spnCheckMutualAncestorsDepth = createSpinner("CheckMutualAncestorsDepth", null, - 4, 0, 20, 1); - - chkLogMarriageNameChanges = createCheckBox("LogMarriageNameChanges", null); - - // Layout the Panel - final JPanel panel = createStandardPanel("MarriageGeneralOptionsPanel", - false, ""); - final GroupLayout layout = createStandardLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(chkUseManualMarriages) - .addComponent(chkUseClanPersonnelMarriages) - .addComponent(chkUsePrisonerMarriages) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblNoInterestInMarriageDiceSize) - .addComponent(spnNoInterestInMarriageDiceSize)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblCheckMutualAncestorsDepth) - .addComponent(spnCheckMutualAncestorsDepth)) - .addComponent(chkLogMarriageNameChanges)); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(chkUseManualMarriages) - .addComponent(chkUseClanPersonnelMarriages) - .addComponent(chkUsePrisonerMarriages) - .addGroup(layout.createSequentialGroup() - .addComponent(lblNoInterestInMarriageDiceSize) - .addComponent(spnNoInterestInMarriageDiceSize) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblCheckMutualAncestorsDepth) - .addComponent(spnCheckMutualAncestorsDepth) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) - .addComponent(chkLogMarriageNameChanges))); - - return panel; - } - - /** - * Creates a panel for random marriage settings, including options for different marriage methods, - * using random clan personnel and prisoner marriages, setting age range for marriages, and - * percentage settings. - * - * @return a {@link JPanel} representing the random marriage panel with various input components - * and panels for configuring random marriage settings - */ - JPanel createRandomMarriagePanel() { - // Contents - lblRandomMarriageMethod = createLabel("RandomMarriageMethod", null); - comboRandomMarriageMethod.setRenderer(new DefaultListCellRenderer() { - @Override - public Component getListCellRendererComponent(final JList list, final Object value, - final int index, final boolean isSelected, - final boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (value instanceof RandomMarriageMethod) { - list.setToolTipText(((RandomMarriageMethod) value).getToolTipText()); - } - return this; - } - }); - - chkUseRandomClanPersonnelMarriages = createCheckBox("UseRandomClanPersonnelMarriages", null); - chkUseRandomPrisonerMarriages = createCheckBox("UseRandomPrisonerMarriages", null); - - lblRandomMarriageAgeRange = createLabel("RandomMarriageAgeRange", null); - spnRandomMarriageAgeRange = createSpinner("RandomMarriageAgeRange", null, - 10, 0, 100, 1.0); - - pnlPercentageRandomMarriage = createPercentageRandomMarriagePanel(); - - // Layout the Panel - final JPanel panel = createStandardPanel("RandomMarriages", true, - "RandomMarriages"); - final GroupLayout layout = createStandardLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblRandomMarriageMethod) - .addComponent(comboRandomMarriageMethod)) - .addComponent(chkUseRandomClanPersonnelMarriages) - .addComponent(chkUseRandomPrisonerMarriages) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblRandomMarriageAgeRange) - .addComponent(spnRandomMarriageAgeRange)) - .addComponent(pnlPercentageRandomMarriage)); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblRandomMarriageMethod) - .addComponent(comboRandomMarriageMethod) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) - .addComponent(chkUseRandomClanPersonnelMarriages) - .addComponent(chkUseRandomPrisonerMarriages) - .addGroup(layout.createSequentialGroup() - .addComponent(lblRandomMarriageAgeRange) - .addComponent(spnRandomMarriageAgeRange) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) - .addComponent(pnlPercentageRandomMarriage))); - - return panel; - } - - /** - * Creates a panel for setting percentage-based random marriage settings. - * - * @return a {@link JPanel} representing the Percentage Random Marriage panel with input components - * for setting opposite-sex marriage dice size, same-sex marriage dice size, and new dependent - * marriage dice size - */ - JPanel createPercentageRandomMarriagePanel() { - // Contents - lblRandomMarriageOppositeSexDiceSize = createLabel("RandomMarriageOppositeSexDiceSize", - null); - spnRandomMarriageDiceSize = createSpinner("RandomMarriageOppositeSexDiceSize", - null, 5000, 0, 100000, 1); - - lblRandomSameSexMarriageDiceSize = createLabel("RandomSameSexMarriageDiceSize", null); - spnRandomSameSexMarriageDiceSize = createSpinner("RandomSameSexMarriageDiceSize", - null, 14, 0, 100000, 1); - - lblRandomNewDependentMarriage = createLabel("RandomNewDependentMarriage", null); - spnRandomNewDependentMarriage = createSpinner("RandomSameSexMarriageDiceSize", - null, 20, 0, 100000, 1); - - // Layout the Panel - final JPanel panel = createStandardPanel("PercentageRandomMarriagePanel", true, - "PercentageRandomMarriagePanel"); - final GroupLayout layout = createStandardLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblRandomMarriageOppositeSexDiceSize) - .addComponent(spnRandomMarriageDiceSize)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblRandomSameSexMarriageDiceSize) - .addComponent(spnRandomSameSexMarriageDiceSize)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblRandomNewDependentMarriage) - .addComponent(spnRandomNewDependentMarriage))); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblRandomMarriageOppositeSexDiceSize) - .addComponent(spnRandomMarriageDiceSize) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblRandomSameSexMarriageDiceSize) - .addComponent(spnRandomSameSexMarriageDiceSize) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblRandomNewDependentMarriage) - .addComponent(spnRandomNewDependentMarriage) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); - - return panel; - } - - /** - * Creates a tab for divorce settings with various checkboxes and panels for manual, clan personnel, - * and prisoner divorces. - * - * @return a {@link JPanel} representing the Divorce tab with checkboxes for manual divorce, - * clan personnel divorce, prisoner divorce, and a panel for configuring random divorce settings. - */ - JPanel createDivorceTab() { - // Header - JPanel headerPanel = createHeaderPanel("DivorceTab", - getImageDirectory() + "logo_clan_hells_horses.png", - false, "", true); - - // Contents - chkUseManualDivorce = createCheckBox("UseManualDivorce", null); - chkUseClanPersonnelDivorce = createCheckBox("UseClanPersonnelDivorce", null); - chkUsePrisonerDivorce = createCheckBox("UsePrisonerDivorce", null); - - pnlRandomDivorce = createRandomDivorcePanel(); - - // Layout the Panel - final JPanel panel = createStandardPanel("DivorceTab", true, ""); - final GroupLayout layout = createStandardLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(chkUseManualDivorce) - .addComponent(chkUseClanPersonnelDivorce) - .addComponent(chkUsePrisonerDivorce) - .addComponent(pnlRandomDivorce)); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(chkUseManualDivorce) - .addComponent(chkUseClanPersonnelDivorce) - .addComponent(chkUsePrisonerDivorce) - .addComponent(pnlRandomDivorce))); - - // Create Parent Panel and return - return createParentPanel(panel, "DivorceTab"); - } - - /** - * Creates a panel for the Divorce tab with checkboxes for manual divorce, clan personnel divorce, - * prisoner divorce, and a panel for configuring random divorce settings. - * - * @return a {@link JPanel} representing the Divorce tab with various components for configuring divorce settings - */ - JPanel createRandomDivorcePanel() { - // Contents - lblRandomDivorceMethod = createLabel("RandomDivorceMethod", null); - comboRandomDivorceMethod.setRenderer(new DefaultListCellRenderer() { - @Override - public Component getListCellRendererComponent(final JList list, final Object value, - final int index, final boolean isSelected, - final boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (value instanceof RandomDivorceMethod) { - list.setToolTipText(((RandomDivorceMethod) value).getToolTipText()); - } - return this; - } - }); - - chkUseRandomOppositeSexDivorce = createCheckBox("UseRandomOppositeSexDivorce", null); - chkUseRandomSameSexDivorce = createCheckBox("UseRandomSameSexDivorce", null); - chkUseRandomClanPersonnelDivorce = createCheckBox("UseRandomClanPersonnelDivorce", null); - chkUseRandomPrisonerDivorce = createCheckBox("UseRandomPrisonerDivorce", null); - - lblRandomDivorceDiceSize = createLabel("RandomDivorceDiceSize", null); - spnRandomDivorceDiceSize = createSpinner("RandomDivorceDiceSize", null, - 900, 0, 100000, 1); - - // Layout the Panel - final JPanel panel = createStandardPanel("RandomDivorcePanel", true, "RandomDivorcePanel"); - final GroupLayout layout = createStandardLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblRandomDivorceMethod) - .addComponent(comboRandomDivorceMethod)) - .addComponent(chkUseRandomOppositeSexDivorce) - .addComponent(chkUseRandomSameSexDivorce) - .addComponent(chkUseRandomClanPersonnelDivorce) - .addComponent(chkUseRandomPrisonerDivorce) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblRandomDivorceDiceSize) - .addComponent(spnRandomDivorceDiceSize))); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblRandomDivorceMethod) - .addComponent(comboRandomDivorceMethod) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) - .addComponent(chkUseRandomOppositeSexDivorce) - .addComponent(chkUseRandomSameSexDivorce) - .addComponent(chkUseRandomClanPersonnelDivorce) - .addComponent(chkUseRandomPrisonerDivorce) - .addGroup(layout.createSequentialGroup() - .addComponent(lblRandomDivorceDiceSize) - .addComponent(spnRandomDivorceDiceSize) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); - - return panel; - } - - /** - * Creates a panel for the Procreation tab with header, general options panel, and random procreation panel. - * - * @return a {@link JPanel} representing the Procreation tab with header, general options panel, - * and random procreation panel - */ - JPanel createProcreationTab() { - // Header - JPanel headerPanel = createHeaderPanel("ProcreationTab", - getImageDirectory() + "logo_clan_ice_hellion.png", - false, "", true); - - // Contents - pnlProcreationGeneralOptionsPanel = createProcreationGeneralOptionsPanel(); - pnlRandomProcreationPanel = createRandomProcreationPanel(); - - // Layout the Panel - final JPanel panel = createStandardPanel("ProcreationTab", true, ""); - final GroupLayout layout = createStandardLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(pnlProcreationGeneralOptionsPanel) - .addComponent(pnlRandomProcreationPanel))); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addGroup(layout.createSequentialGroup() - .addComponent(pnlProcreationGeneralOptionsPanel) - .addComponent(pnlRandomProcreationPanel) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); - - // Create Parent Panel and return - return createParentPanel(panel, "ProcreationTab"); - } - - /** - * @return the {@link JPanel} containing the procreation settings components - */ - JPanel createProcreationGeneralOptionsPanel() { - // Contents - chkUseManualProcreation = createCheckBox("UseManualProcreation", null); - chkUseClanPersonnelProcreation = createCheckBox("UseClanPersonnelProcreation", null); - chkUsePrisonerProcreation = createCheckBox("UsePrisonerProcreation", null); - - lblMultiplePregnancyOccurrences = createLabel("MultiplePregnancyOccurrences", null); - spnMultiplePregnancyOccurrences = createSpinner("MultiplePregnancyOccurrences", null, - 50, 1, 1000, 1); - - lblBabySurnameStyle = createLabel("BabySurnameStyle", null); - comboBabySurnameStyle.setRenderer(new DefaultListCellRenderer() { - @Override - public Component getListCellRendererComponent(final JList list, final Object value, - final int index, final boolean isSelected, - final boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (value instanceof BabySurnameStyle) { - list.setToolTipText(((BabySurnameStyle) value).getToolTipText()); - } - return this; - } - }); - - chkAssignNonPrisonerBabiesFounderTag = createCheckBox("AssignNonPrisonerBabiesFounderTag", - null); - chkAssignChildrenOfFoundersFounderTag = createCheckBox("AssignChildrenOfFoundersFounderTag", - null); - chkDetermineFatherAtBirth = createCheckBox("DetermineFatherAtBirth", null); - chkDisplayTrueDueDate = createCheckBox("DisplayTrueDueDate", null); - - lblNoInterestInChildrenDiceSize = createLabel("NoInterestInChildrenDiceSize", null); - spnNoInterestInChildrenDiceSize = createSpinner("NoInterestInChildrenDiceSize", null, - 3, 1, 100000, 1); - - chkUseMaternityLeave = createCheckBox("UseMaternityLeave", null); - chkLogProcreation = createCheckBox("LogProcreation", null); - - pnlRandomProcreationPanel = createRandomProcreationPanel(); - - // Layout the Panel - final JPanel panel = createStandardPanel("ProcreationGeneralOptionsPanel", - false, ""); - final GroupLayout layout = createStandardLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(chkUseManualProcreation) - .addComponent(chkUseClanPersonnelProcreation) - .addComponent(chkUsePrisonerProcreation) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblMultiplePregnancyOccurrences) - .addComponent(spnMultiplePregnancyOccurrences)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblBabySurnameStyle) - .addComponent(comboBabySurnameStyle)) - .addComponent(chkAssignNonPrisonerBabiesFounderTag) - .addComponent(chkAssignChildrenOfFoundersFounderTag) - .addComponent(chkDetermineFatherAtBirth) - .addComponent(chkDisplayTrueDueDate) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblNoInterestInChildrenDiceSize) - .addComponent(spnNoInterestInChildrenDiceSize)) - .addComponent(chkUseMaternityLeave) - .addComponent(chkLogProcreation)); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(chkUseManualProcreation) - .addComponent(chkUseClanPersonnelProcreation) - .addComponent(chkUsePrisonerProcreation) - .addGroup(layout.createSequentialGroup() - .addComponent(lblMultiplePregnancyOccurrences) - .addComponent(spnMultiplePregnancyOccurrences) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblBabySurnameStyle) - .addComponent(comboBabySurnameStyle) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) - .addComponent(chkAssignNonPrisonerBabiesFounderTag) - .addComponent(chkAssignChildrenOfFoundersFounderTag) - .addComponent(chkDetermineFatherAtBirth) - .addComponent(chkDisplayTrueDueDate) - .addGroup(layout.createSequentialGroup() - .addComponent(lblNoInterestInChildrenDiceSize) - .addComponent(spnNoInterestInChildrenDiceSize) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) - .addComponent(chkUseMaternityLeave) - .addComponent(chkLogProcreation))); - - return panel; - } - - /** - * @return a {@link JPanel} containing the configured components for random procreation settings - */ - JPanel createRandomProcreationPanel() { - // Contents - lblRandomProcreationMethod = createLabel("RandomProcreationMethod", null); - comboRandomProcreationMethod.setRenderer(new DefaultListCellRenderer() { - @Override - public Component getListCellRendererComponent(final JList list, final Object value, - final int index, final boolean isSelected, - final boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (value instanceof RandomProcreationMethod) { - list.setToolTipText(((RandomProcreationMethod) value).getToolTipText()); - } - return this; - } - }); - - chkUseRelationshiplessRandomProcreation =createCheckBox("UseRelationshiplessRandomProcreation", - null); - chkUseRandomClanPersonnelProcreation = createCheckBox("UseRandomClanPersonnelProcreation", - null); - chkUseRandomPrisonerProcreation = createCheckBox("UseRandomPrisonerProcreation", null); - - lblRandomProcreationRelationshipDiceSize = createLabel("RandomProcreationRelationshipDiceSize", - null); - spnRandomProcreationRelationshipDiceSize = createSpinner("RandomProcreationRelationshipDiceSize", - null, 621, 0, 100000, 1); - - lblRandomProcreationRelationshiplessDiceSize = createLabel("RandomProcreationRelationshiplessDiceSize", - null); - spnRandomProcreationRelationshiplessDiceSize = createSpinner("RandomProcreationRelationshiplessDiceSize", - null, 1861, 0, 100000, 1); - - // Layout the Panel - final JPanel panel = createStandardPanel("RandomProcreationPanel", true, - "RandomProcreationPanel"); - final GroupLayout layout = createStandardLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblRandomProcreationMethod) - .addComponent(comboRandomProcreationMethod)) - .addComponent(chkUseRelationshiplessRandomProcreation) - .addComponent(chkUseRandomClanPersonnelProcreation) - .addComponent(chkUseRandomPrisonerProcreation) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblRandomProcreationRelationshipDiceSize) - .addComponent(spnRandomProcreationRelationshipDiceSize)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblRandomProcreationRelationshiplessDiceSize) - .addComponent(spnRandomProcreationRelationshiplessDiceSize))); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblRandomProcreationMethod) - .addComponent(comboRandomProcreationMethod) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) - .addComponent(chkUseRelationshiplessRandomProcreation) - .addComponent(chkUseRandomClanPersonnelProcreation) - .addComponent(chkUseRandomPrisonerProcreation) - .addGroup(layout.createSequentialGroup() - .addComponent(lblRandomProcreationRelationshipDiceSize) - .addComponent(spnRandomProcreationRelationshipDiceSize) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblRandomProcreationRelationshiplessDiceSize) - .addComponent(spnRandomProcreationRelationshiplessDiceSize) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); - - return panel; - } - /** * Creates and returns a {@link JPanel} for the Death Tab. * The panel includes header, various checkboxes, labels, spinners, and a custom combo box. From e40404c21c5fd3b0fd4106cad549656fe17947c4 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 10 Oct 2024 22:00:36 -0500 Subject: [PATCH 044/117] Remove unused NameAndPortraitGeneration.java file This file was no longer needed and its presence could cause confusion. The removal helps in maintaining a cleaner and more understandable codebase. --- .../panes/campaignOptions/tabs/NameAndPortraitGeneration.java | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/NameAndPortraitGeneration.java diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/NameAndPortraitGeneration.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/NameAndPortraitGeneration.java deleted file mode 100644 index 562c863d63..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/NameAndPortraitGeneration.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.tabs; - -public class NameAndPortraitGeneration { -} From 47ad105b6473dbe5f1f736a406311d780ce6974f Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 10 Oct 2024 22:24:04 -0500 Subject: [PATCH 045/117] Make methods private in various campaign options tabs Updated method visibility to private in several campaign options tabs to encapsulate functionality and improve code maintainability. This change affects multiple panels related to relationships, supplies, biographies, repairs, turnovers, technical limits, and more. --- .../campaignOptions/tabs/RelationshipsTab.java | 12 ++++++------ .../tabs/RepairAndMaintenanceTab.java | 6 +++--- .../tabs/SuppliesAndAcquisitionTab.java | 8 ++++---- .../campaignOptions/tabs/TechLimitsTab.java | 2 +- .../tabs/TurnoverAndRetentionTab.java | 18 +++++++++--------- .../campaignOptions/tabs/biographyTab.java | 10 +++++----- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java index 31eb79ddd7..7c115e65f7 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java @@ -222,7 +222,7 @@ JPanel createMarriageTab() { * * @return a {@link JPanel} representing the general marriage options panel */ - JPanel createMarriageGeneralOptionsPanel() { + private JPanel createMarriageGeneralOptionsPanel() { // Contents chkUseManualMarriages = createCheckBox("UseManualMarriages", null); chkUseClanPersonnelMarriages = createCheckBox("UseClanPersonnelMarriages", null); @@ -284,7 +284,7 @@ JPanel createMarriageGeneralOptionsPanel() { * @return a {@link JPanel} representing the random marriage panel with various input components * and panels for configuring random marriage settings */ - JPanel createRandomMarriagePanel() { + private JPanel createRandomMarriagePanel() { // Contents lblRandomMarriageMethod = createLabel("RandomMarriageMethod", null); comboRandomMarriageMethod.setRenderer(new DefaultListCellRenderer() { @@ -352,7 +352,7 @@ public Component getListCellRendererComponent(final JList list, final Object * for setting opposite-sex marriage dice size, same-sex marriage dice size, and new dependent * marriage dice size */ - JPanel createPercentageRandomMarriagePanel() { + private JPanel createPercentageRandomMarriagePanel() { // Contents lblRandomMarriageOppositeSexDiceSize = createLabel("RandomMarriageOppositeSexDiceSize", null); @@ -456,7 +456,7 @@ JPanel createDivorceTab() { * * @return a {@link JPanel} representing the Divorce tab with various components for configuring divorce settings */ - JPanel createRandomDivorcePanel() { + private JPanel createRandomDivorcePanel() { // Contents lblRandomDivorceMethod = createLabel("RandomDivorceMethod", null); comboRandomDivorceMethod.setRenderer(new DefaultListCellRenderer() { @@ -562,7 +562,7 @@ JPanel createProcreationTab() { /** * @return the {@link JPanel} containing the procreation settings components */ - JPanel createProcreationGeneralOptionsPanel() { + private JPanel createProcreationGeneralOptionsPanel() { // Contents chkUseManualProcreation = createCheckBox("UseManualProcreation", null); chkUseClanPersonnelProcreation = createCheckBox("UseClanPersonnelProcreation", null); @@ -660,7 +660,7 @@ public Component getListCellRendererComponent(final JList list, final Object /** * @return a {@link JPanel} containing the configured components for random procreation settings */ - JPanel createRandomProcreationPanel() { + private JPanel createRandomProcreationPanel() { // Contents lblRandomProcreationMethod = createLabel("RandomProcreationMethod", null); comboRandomProcreationMethod.setRenderer(new DefaultListCellRenderer() { diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java index e828cb354f..300e204f23 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java @@ -56,7 +56,7 @@ public RepairAndMaintenanceTab(JFrame frame, String name) { * * @return the created repair tab panel as a {@link JPanel} */ - public JPanel createRepairTab() { + JPanel createRepairTab() { // Header JPanel headerPanel = createHeaderPanel("RepairTab", getImageDirectory() + "logo_aurigan_coalition.png", false, @@ -139,7 +139,7 @@ public JPanel createRepairTab() { * * @return The created maintenance tab panel as a {@link JPanel}. */ - public JPanel createMaintenanceTab() { + JPanel createMaintenanceTab() { // Header JPanel headerPanel = createHeaderPanel("MaintenanceTab", getImageDirectory() + "logo_clan_blood_spirit.png", @@ -240,7 +240,7 @@ private void recreateFinancesPanel(boolean isReversingQualityNames) { /** * Initializes the repair and maintenance tab by creating and initializing various UI components. */ - protected void initialize() { + void initialize() { initializeRepairTab(); initializeMaintenanceTab(); } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java index d96f6b5076..e177319876 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java @@ -86,7 +86,7 @@ public SuppliesAndAcquisitionTab(JFrame frame, String name) { * * @return the created tab panel as a {@link JPanel} */ - public JPanel createAcquisitionTab() { + JPanel createAcquisitionTab() { // Header JPanel headerPanel = createHeaderPanel("AcquisitionTab", getImageDirectory() + "logo_calderon_protectorate.png", false, @@ -172,7 +172,7 @@ public JPanel createAcquisitionTab() { return createParentPanel(panel, "acquisitionsTab"); } - public JPanel createPlanetaryAcquisitionTab() { + JPanel createPlanetaryAcquisitionTab() { // Header JPanel headerPanel = createHeaderPanel("PlanetaryAcquisitionTab", getImageDirectory() + "logo_capellan_confederation.png", false, @@ -462,7 +462,7 @@ private String getModifierLabel(int quality) { * * @return the created tab panel as a {@link JPanel} */ - public JPanel createDeliveryTab() { + JPanel createDeliveryTab() { // Header JPanel headerPanel = createHeaderPanel("DeliveryTab", getImageDirectory() + "logo_clan_burrock.png", false, @@ -582,7 +582,7 @@ private static DefaultComboBoxModel buildAcquireSkillComboOptions() { return acquireSkillModel; } - protected void initialize() { + void initialize() { // Acquisition Tab lblChoiceAcquireSkill = new JLabel(); choiceAcquireSkill = new MMComboBox<>("choiceAcquireSkill", buildAcquireSkillComboOptions()); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java index b824094842..6bfcd17d6a 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java @@ -140,7 +140,7 @@ JPanel createTechLimitsTab() { return wrapperPanel; } - protected void initialize() { + void initialize() { // Tech Limits Tab limitByYearBox = new JCheckBox(); disallowExtinctStuffBox = new JCheckBox(); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java index 7214f4e2d0..0949e86316 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java @@ -274,7 +274,7 @@ JPanel createTurnoverTab() { * * @return panel the configured {@link JPanel} with various turnover settings */ - JPanel createSettingsPanel() { + private JPanel createSettingsPanel() { // Contents lblTurnoverFixedTargetNumber = createLabel("TurnoverFixedTargetNumber", null); spnTurnoverFixedTargetNumber = createSpinner("TurnoverFixedTargetNumber", null, @@ -394,7 +394,7 @@ public Component getListCellRendererComponent(final JList list, final Object * * @return panel the configured {@link JPanel} with modifier settings */ - JPanel createModifiersPanel() { + private JPanel createModifiersPanel() { // Contents chkUseCustomRetirementModifiers = createCheckBox("UseCustomRetirementModifiers", null); chkUseFatigueModifiers = createCheckBox("UseFatigueModifiers", null); @@ -461,7 +461,7 @@ JPanel createModifiersPanel() { * * @return panel the configured {@link JPanel} with payout settings */ - JPanel createPayoutsPanel() { + private JPanel createPayoutsPanel() { // Contents lblPayoutRateOfficer = createLabel("PayoutRateOfficer", null); spnPayoutRateOfficer = createSpinner("PayoutRateOfficer", null, @@ -537,7 +537,7 @@ JPanel createPayoutsPanel() { * * @return panel the configured {@link JPanel} with unit cohesion settings */ - JPanel createUnitCohesionPanel() { + private JPanel createUnitCohesionPanel() { // Contents pnlAdministrativeStrainWrapper = createAdministrativeStrainWrapperPanel(); pnlManagementSkillWrapper = createManagementSkillWrapperPanel(); @@ -575,7 +575,7 @@ JPanel createUnitCohesionPanel() { * @return {@link JPanel} The newly created and configured JPanel containing administrative strain * settings */ - JPanel createAdministrativeStrainWrapperPanel() { + private JPanel createAdministrativeStrainWrapperPanel() { // Contents chkUseAdministrativeStrain = createCheckBox("UseAdministrativeStrain", null); pnlAdministrativeStrain = createAdministrativeStrainPanel(); @@ -611,7 +611,7 @@ JPanel createAdministrativeStrainWrapperPanel() { * * @return panel the configured {@link JPanel} with administrative strain settings */ - JPanel createAdministrativeStrainPanel() { + private JPanel createAdministrativeStrainPanel() { // Contents lblAdministrativeCapacity = createLabel("AdministrativeCapacity", null); spnAdministrativeCapacity = createSpinner("AdministrativeCapacity", null, @@ -662,10 +662,10 @@ JPanel createAdministrativeStrainPanel() { * * @return {@link JPanel} The constructed and configured jPanel containing the management skill settings */ - JPanel createManagementSkillWrapperPanel() { + private JPanel createManagementSkillWrapperPanel() { // Contents chkUseManagementSkill = createCheckBox("UseManagementSkill", null); - pnlManagementSkill = createManagementSkill(); + pnlManagementSkill = createManagementSkillPanel(); // Layout the Panel final JPanel panel = createStandardPanel("UnitCohesionPanel", false, ""); @@ -699,7 +699,7 @@ JPanel createManagementSkillWrapperPanel() { * * @return panel the configured {@link JPanel} with management skill settings */ - JPanel createManagementSkill() { + private JPanel createManagementSkillPanel() { // Contents chkUseCommanderLeadershipOnly = createCheckBox("UseCommanderLeadershipOnly", null); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java index 228527702f..5fd566da96 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java @@ -640,7 +640,7 @@ public Component getListCellRendererComponent(final JList list, final Object * * @return a {@link JPanel} representing the Death Age Groups tab with checkboxes for each age group */ - JPanel createDeathAgeGroupsPanel() { + private JPanel createDeathAgeGroupsPanel() { final AgeGroup[] ageGroups = AgeGroup.values(); // Create the Panel @@ -781,7 +781,7 @@ JPanel createEducationTab() { * @return {@link JPanel} The newly constructed and configured JPanel for * Enable Standard Sets settings. */ - JPanel createEnableStandardSetsPanel() { + private JPanel createEnableStandardSetsPanel() { // Contents chkEnableLocalAcademies = createCheckBox("EnableLocalAcademies", null); chkEnablePrestigiousAcademies = createCheckBox("EnablePrestigiousAcademies", null); @@ -823,7 +823,7 @@ JPanel createEnableStandardSetsPanel() { * @return {@link JPanel} The newly created and configured JPanel * containing the XP and Skill Bonuses settings. */ - JPanel createXpAndSkillBonusesPanel() { + private JPanel createXpAndSkillBonusesPanel() { // Contents chkEnableBonuses = createCheckBox("EnableBonuses", null); lblFacultyXpMultiplier = createLabel("FacultyXpMultiplier", null); @@ -865,7 +865,7 @@ JPanel createXpAndSkillBonusesPanel() { * * @return {@link JPanel} The newly constructed and configured JPanel that contains the Dropout Chance settings. */ - JPanel createDropoutChancePanel() { + private JPanel createDropoutChancePanel() { // Contents lblAdultDropoutChance = createLabel("AdultDropoutChance", null); spnAdultDropoutChance = createSpinner("AdultDropoutChance", null, @@ -917,7 +917,7 @@ JPanel createDropoutChancePanel() { * @return {@link JPanel} The constructed, configured JPanel containing * "Accidents and Events" settings */ - JPanel createAccidentsAndEventsPanel() { + private JPanel createAccidentsAndEventsPanel() { // Contents chkAllAges = createCheckBox("AllAges", null); lblMilitaryAcademyAccidents = createLabel("MilitaryAcademyAccidents", null); From 8c2d68775b288d24ca16e2585135715bbbcd1a25 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 10 Oct 2024 23:14:43 -0500 Subject: [PATCH 046/117] Add "Name and Portrait Generation" tab Introduced a new "Name and Portrait Generation" tab in campaign options. This includes functionality for assigning names based on origin faction and managing portrait generation/settings. Updated related UI components and properties accordingly. --- .../NEWCampaignOptionsDialog.properties | 26 +++ .../tabs/CampaignOptionsPane.java | 3 +- .../campaignOptions/tabs/biographyTab.java | 184 +++++++++++++++++- 3 files changed, 203 insertions(+), 10 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index ac2a474105..e6c517aba7 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -551,6 +551,11 @@ educationTab.border="You can teach someone to pilot a 'mek, but you can't teach \ a battlefield. That education comes with time - and scars."\
- Lieutenant Hannah "Stinger" Quinn, Ironclad Rangers +nameAndPortraitGenerationTab.title=Name & Portraits +nameAndPortraitGenerationTab.border="Your name might get you noticed, but it's your actions that make\ + \ them remember your face. Make every battle count."\ +
- Lieutenant Sara "Nightshade" Grey, Ravenheart Company + # createGeneralTab lblBiographyGeneralTab.text=General Options lblBiographyGeneralTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ @@ -698,6 +703,27 @@ lblAllAges.tooltip=PLACEHOLDER lblMilitaryAcademyAccidents.text=Military Accidents Chance: 1 in lblMilitaryAcademyAccidents.tooltip=PLACEHOLDER +# createNameAndPortraitGenerationTab +lblNameAndPortraitGenerationTab.text=Name and Portrait Generation Options +lblNameAndPortraitGenerationTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblUseOriginFactionForNames.text=Assign Names Based on Origin Faction +lblUseOriginFactionForNames.tooltip=PLACEHOLDER +lblFactionNames.text=Faction +lblFactionNames.tooltip=PLACEHOLDER +lblAssignPortraitOnRoleChange.text=Reassign Portrait on Role Change +lblAssignPortraitOnRoleChange.tooltip=PLACEHOLDER + +# createRandomPortraitPanel +lblRandomPortraitPanel.text=Portrait Assignment +lblAllPortraitsBox.text=All Roles +lblNoPortraitsBox.text=No Roles + + # Turnover and Rention Tab turnoverAndRetentionContentTabs.title=Turnover & Retention diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 0858378a5b..cdbef95100 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -127,7 +127,8 @@ private JTabbedPane createHumanResourcesParentTab() { "biographyGeneralTab", biographyTab.createGeneralTab(), "backgroundsTab", biographyTab.createBackgroundsTab(), "deathTab", biographyTab.createDeathTab(), - "educationTab", biographyTab.createEducationTab())); + "educationTab", biographyTab.createEducationTab(), + "nameAndPortraitGenerationTab", biographyTab.createNameAndPortraitGenerationTab())); // Relationships RelationshipsTab relationshipsTab = new RelationshipsTab(getFrame(), "relationshipsTab"); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java index 5fd566da96..dd415094e0 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java @@ -1,11 +1,13 @@ package mekhq.gui.panes.campaignOptions.tabs; import megamek.client.generator.RandomGenderGenerator; +import megamek.client.generator.RandomNameGenerator; import megamek.client.ui.baseComponents.MMComboBox; import megamek.common.annotations.Nullable; import mekhq.campaign.Campaign; import mekhq.campaign.personnel.enums.AgeGroup; import mekhq.campaign.personnel.enums.FamilialRelationshipDisplayLevel; +import mekhq.campaign.personnel.enums.PersonnelRole; import mekhq.campaign.personnel.enums.RandomDeathMethod; import mekhq.campaign.universe.Faction; import mekhq.campaign.universe.Planet; @@ -112,6 +114,18 @@ public class biographyTab { private JSpinner spnMilitaryAcademyAccidents; //end Education Tab + //start Name and Portrait Tab + private JCheckBox chkUseOriginFactionForNames; + private JLabel lblFactionNames; + private MMComboBox comboFactionNames; + + private JPanel pnlRandomPortrait; + private JCheckBox[] chkUsePortrait; + private JCheckBox allPortraitsBox; + private JCheckBox noPortraitsBox; + private JCheckBox chkAssignPortraitOnRoleChange; + //end Name and Portrait Tab + /** * Initializes a new {@link biographyTab} with the specified campaign, frame, and name. * @@ -221,6 +235,32 @@ protected void initialize() { chkAllAges = new JCheckBox(); lblMilitaryAcademyAccidents = new JLabel(); spnMilitaryAcademyAccidents = new JSpinner(); + + // Name and Portrait Generation + chkUseOriginFactionForNames = new JCheckBox(); + lblFactionNames = new JLabel(); + comboFactionNames = new MMComboBox<>("comboFactionNames", getFactionNamesModel()); + chkAssignPortraitOnRoleChange = new JCheckBox(); + + pnlRandomPortrait = new JPanel(); + chkUsePortrait = new JCheckBox[1]; // We're going to properly initialize this later + allPortraitsBox = new JCheckBox(); + noPortraitsBox = new JCheckBox(); + } + + /** + * Retrieves a {@link DefaultComboBoxModel} containing faction names generated by the + * {@link RandomNameGenerator} instance. + * + * @return DefaultComboBoxModel containing faction names + */ + private static DefaultComboBoxModel getFactionNamesModel() { + DefaultComboBoxModel factionNamesModel = new DefaultComboBoxModel<>(); + for (final String faction : RandomNameGenerator.getInstance().getFactions()) { + factionNamesModel.addElement(faction); + } + factionNamesModel.setSelectedItem(RandomNameGenerator.getInstance().getChosenFaction()); + return factionNamesModel; } /** @@ -905,17 +945,15 @@ private JPanel createDropoutChancePanel() { } /** - * Constructs and configures an "Accidents and Events" {@link JPanel}. - * The panel includes a checkbox indicating whether to include all ages, - * a label for military academy accidents, and also a spinner for adjusting - * the count of military academy accidents. + * Constructs and configures an "Accidents and Events" {@link JPanel}. The panel includes a checkbox + * indicating whether to include all ages, a label for military academy accidents, and also a spinner + * for adjusting the count of military academy accidents. *

- * The layout of the panel is configured with a {@link GroupLayout}, - * organizing the checkbox and other components for optimized alignments - * in vertical and horizontal layouts. + * The layout of the panel is configured with a {@link GroupLayout}, organizing the checkbox and + * other components for optimized alignments in vertical and horizontal layouts. * - * @return {@link JPanel} The constructed, configured JPanel containing - * "Accidents and Events" settings + * @return {@link JPanel} The constructed, configured JPanel containing "Accidents and Events" + * settings */ private JPanel createAccidentsAndEventsPanel() { // Contents @@ -948,4 +986,132 @@ private JPanel createAccidentsAndEventsPanel() { return panel; } + + /** + * Constructs and configures a "Name and Portrait Generation" {@link JPanel}. This panel contains + * various components for managing how names and portraits are generated. It includes a checkbox + * for using the origin faction for names, a label and combo box for faction names, a panel for + * random portrait selection, and a checkbox for assigning a portrait on role change. + *

+ * A {@link GroupLayout} is used to optimally arrange these components for effective vertical + * and horizontal alignment. + * + * @return {@link JPanel} The newly created and configured parent JPanel for the Name and Portrait + * Generation tab, containing all relevant name and portrait generation controls. + */ + JPanel createNameAndPortraitGenerationTab() { + // Header + JPanel headerPanel = createHeaderPanel("NameAndPortraitGenerationTab", + getImageDirectory() + "logo_clan_mongoose.png", + false, "", true); + + // Contents + chkUseOriginFactionForNames = createCheckBox("UseOriginFactionForNames", null); + + lblFactionNames = createLabel("FactionNames", null); + + pnlRandomPortrait = createRandomPortraitPanel(); + + chkAssignPortraitOnRoleChange = createCheckBox("AssignPortraitOnRoleChange", null); + + // Layout the Panel + final JPanel panel = createStandardPanel("NameAndPortraitGenerationTab", true, + ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addComponent(chkUseOriginFactionForNames) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblFactionNames) + .addComponent(comboFactionNames)) + .addComponent(pnlRandomPortrait) + .addComponent(chkAssignPortraitOnRoleChange)); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addComponent(chkUseOriginFactionForNames) + .addGroup(layout.createSequentialGroup() + .addComponent(lblFactionNames) + .addComponent(comboFactionNames) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(pnlRandomPortrait) + .addComponent(chkAssignPortraitOnRoleChange))); + + // Create Parent Panel and return + return createParentPanel(panel, "NameAndPortraitGenerationTab"); + } + + /** + * Constructs and configures a {@link JPanel} for managing random portrait settings. + * The panel contains individual checkboxes for each personnel role defined in {@link PersonnelRole}, + * as well as two special checkboxes: one for selecting all portraits, and one for selecting none. + * Selecting either of these special checkboxes will override the individual role selections and + * disable them. + *

+ * The panel uses a grid layout, arranging the checkboxes in a grid that extends up to 4 columns, + * with each checkbox + * representing a particular role. It also has a border around it, titled with the panel's name. + * + * @return {@link JPanel} The newly constructed and configured JPanel for managing random portrait + * settings. + */ + private JPanel createRandomPortraitPanel() { + // Contents + final PersonnelRole[] personnelRoles = PersonnelRole.values(); + + chkUsePortrait = new JCheckBox[personnelRoles.length]; + + allPortraitsBox = new JCheckBox(resources.getString("lblAllPortraitsBox.text")); + allPortraitsBox.addActionListener(evt -> { + final boolean selected = allPortraitsBox.isSelected(); + for (final JCheckBox box : chkUsePortrait) { + if (selected) { + box.setSelected(true); + } + box.setEnabled(!selected); + } + if (selected) { + noPortraitsBox.setSelected(false); + } + }); + + noPortraitsBox = new JCheckBox(resources.getString("lblNoPortraitsBox.text")); + noPortraitsBox.addActionListener(evt -> { + final boolean selected = noPortraitsBox.isSelected(); + for (final JCheckBox box : chkUsePortrait) { + if (selected) { + box.setSelected(false); + } + box.setEnabled(!selected); + } + if (selected) { + allPortraitsBox.setSelected(false); + } + }); + + // Layout the Panel + JPanel panel = new JPanel( + new GridLayout((int) Math.ceil((personnelRoles.length + 2) / 4.0), 4)); + panel.setBorder(BorderFactory.createTitledBorder( + String.format(String.format("%s", + resources.getString("lblRandomPortraitPanel.text"))))); + + panel.add(allPortraitsBox); + panel.add(noPortraitsBox); + + // Add remaining checkboxes + JCheckBox jCheckBox; + for (final PersonnelRole role : PersonnelRole.values()) { + jCheckBox = new JCheckBox(role.toString()); + panel.add(jCheckBox); + chkUsePortrait[role.ordinal()] = jCheckBox; + } + + return panel; + } } From ca95042d8a2a6d94c8a8a3a8088809977b3d50df Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 11 Oct 2024 10:14:47 -0500 Subject: [PATCH 047/117] Add Rank System tab and adjust panel dimensions to 750px Implemented a new Rank System tab in the campaign options and adjusted various panel dimensions from 500px to 750px for better layout consistency. Removed redundant instruction text for rank systems to streamline the user interface. --- .../resources/mekhq/resources/GUI.properties | 2 - .../NEWCampaignOptionsDialog.properties | 38 ++++++++++------- .../src/mekhq/gui/panes/RankSystemsPane.java | 39 +++++------------- .../tabs/CampaignOptionsPane.java | 3 +- .../tabs/CampaignOptionsUtilities.java | 14 +++---- .../campaignOptions/tabs/GeneralTab.java | 2 +- .../campaignOptions/tabs/biographyTab.java | 41 +++++++++++++++++++ 7 files changed, 85 insertions(+), 54 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/GUI.properties b/MekHQ/resources/mekhq/resources/GUI.properties index e3dae29a9d..ba8875326a 100644 --- a/MekHQ/resources/mekhq/resources/GUI.properties +++ b/MekHQ/resources/mekhq/resources/GUI.properties @@ -1315,8 +1315,6 @@ btnLoadStoryArc.text=Load a Story Arc #### RankSystemsPane Class ### Rank System rankSystemPanel.title=Rank System -txtInstructionsRanks.title=Customizing Ranks -txtInstructionsRanks.text=You can use the table here to assign ranks for your campaign. You can use one of the preset rank systems from the pull-down menu, or you can design your own by creating a custom rank system. \nYou can save a single rank system as part of the campaign, with any additional custom rank systems to be saved in the user data file instead. Any additional campaign rank systems will be deleted. \nYou can also assign custom multipliers for salary. These multipliers don't need to take into account the officer multiplier which is addressed elsewhere. \n\nWARNING: \n1) This dialog doesn't warn about the deletion of any campaign custom rank systems that aren't the selected rank system for the campaign at this time. \n2) All personnel ranks will be revalidated when this is changed, to migrate them to the proper setup for their new rank system. \n3) This dialog does not validate the data at this time, so be careful with circular logic and ensure you have a valid E0 rank (one MUST be a name like "None" or "Grunt", with "None" specifically handled in code to show as a blank string when the rank name is displayed). lblRankSystem.text=Rank System lblRankSystem.toolTipText=This is the standard rank system used in this campaign. comboRankSystemType.toolTipText=This is the type of rank system selected, which is where the information about the rank system is stored. diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index e6c517aba7..e0f22e2c39 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -527,21 +527,6 @@ backgroundsTab.border="From noble houses to street gangs, once you're in the coc \ same. Your past might shape you, but your future is yours to command."\
- Lieutenant Marcus "Ghost" Walker, Onyx Fang Company -relationshipsMarriageTab.title=Relationships - Marriage -relationshipsMarriageTab.border="In a universe filled with war and chaos, marriage is the one alliance\ - \ that keeps you grounded. When the battles end, it's the bond you fight to protect."\ -
- Lieutenant Elara "Sunburst" Tate, Steelclaw Company - -relationshipsDivorceTab.title=Relationships - Divorce -relationshipsDivorceTab.border="Divorce is just like ejecting from a 'mek: it's messy, expensive, and\ - \ you're lucky if you escape in one piece."\ -
- Sergeant Quinn "Deadeye" Mallory, Crimson Fang Mercs - -relationshipsProcreationTab.title=Relationships - Procreation -relationshipsProcreationTab.border="In this galaxy, raising kids is tougher than raising a lance. At\ - \ least 'meks come with an instruction manual."\ -
- Captain Dani "Ironheart" Cole, Steel Talon Company - deathTab.title=Death deathTab.border="School didn't teach me how to explode, but I learn fast."\
- Sergeant Pete "Wildfire" Watson, Steel Viper Unit @@ -556,6 +541,11 @@ nameAndPortraitGenerationTab.border="Your name might get you noticed, but it's y \ them remember your face. Make every battle count."\
- Lieutenant Sara "Nightshade" Grey, Ravenheart Company +rankTab.title=Rank Systems +rankTab.border="Rank isn't about authority - it's about responsibility. Every step up means you're\ + \ carrying more than your own survival."\ +
-Captain Maya "Wildcard" Hayes, Black Viper Squadron + # createGeneralTab lblBiographyGeneralTab.text=General Options lblBiographyGeneralTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ @@ -723,6 +713,24 @@ lblRandomPortraitPanel.text=Portrait Assignment lblAllPortraitsBox.text=All Roles lblNoPortraitsBox.text=No Roles +# createRankTab +lblRankTab.text=Rank Systems +lblRankTabBody.text=You can use the table here to assign ranks for your campaign. You can use one of\ + \ the preset rank systems from the pull-down menu, or you can design your own by creating a custom\ + \ rank system.\ +
You can save a single rank system as part of the campaign, with any additional custom rank systems\ + \ to be saved in the user data file instead. Any additional campaign rank systems will be deleted.\ +
You can also assign custom multipliers for salary. These multipliers don't need to take into\ + \ account the officer multiplier which is addressed elsewhere.\ +
\ +
WARNING:\ +
1) This dialog doesn't warn about the deletion of any campaign custom rank systems that aren't\ + \ the selected rank system for the campaign at this time.\ +
2) All personnel ranks will be revalidated when this is changed, to migrate them to the proper\ + \ setup for their new rank system.\ +
3) This dialog does not validate the data at this time, so be careful with circular logic and\ + \ ensure you have a valid E0 rank (one MUST be a name like "None" or "Grunt", with "None" specifically\ + \ handled in code to show as a blank string when the rank name is displayed). # Turnover and Rention Tab turnoverAndRetentionContentTabs.title=Turnover & Retention diff --git a/MekHQ/src/mekhq/gui/panes/RankSystemsPane.java b/MekHQ/src/mekhq/gui/panes/RankSystemsPane.java index e890477e0c..130375b69d 100644 --- a/MekHQ/src/mekhq/gui/panes/RankSystemsPane.java +++ b/MekHQ/src/mekhq/gui/panes/RankSystemsPane.java @@ -18,21 +18,6 @@ */ package mekhq.gui.panes; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.io.File; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.swing.*; -import javax.swing.table.TableColumn; - import megamek.client.ui.baseComponents.MMButton; import megamek.client.ui.baseComponents.MMComboBox; import megamek.client.ui.baseComponents.SpinnerCellEditor; @@ -53,6 +38,14 @@ import mekhq.gui.dialog.CustomRankSystemCreationDialog; import mekhq.gui.model.RankTableModel; +import javax.swing.*; +import javax.swing.GroupLayout.Alignment; +import javax.swing.table.TableColumn; +import java.awt.*; +import java.io.File; +import java.util.List; +import java.util.*; + public class RankSystemsPane extends AbstractMHQScrollPane { private static final MMLogger logger = MMLogger.create(RankSystemsPane.class); @@ -179,16 +172,6 @@ protected void initialize() { gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTHWEST; - final JTextArea txtInstructionsRanks = new JTextArea(resources.getString("txtInstructionsRanks.text")); - txtInstructionsRanks.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createTitledBorder(resources.getString("txtInstructionsRanks.title")), - BorderFactory.createEmptyBorder(5, 5, 5, 5))); - txtInstructionsRanks.setOpaque(false); - txtInstructionsRanks.setEditable(false); - txtInstructionsRanks.setLineWrap(true); - txtInstructionsRanks.setWrapStyleWord(true); - rankSystemsPanel.add(txtInstructionsRanks, gbc); - gbc.gridy++; rankSystemsPanel.add(createRankSystemPanel(), gbc); @@ -287,14 +270,14 @@ public Component getListCellRendererComponent(final JList list, final Object layout.setVerticalGroup( layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(lblRankSystem) .addComponent(getComboRankSystems()) .addComponent(getComboRankSystemType()) - .addComponent(btnCreateCustomRankSystem, GroupLayout.Alignment.LEADING))); + .addComponent(btnCreateCustomRankSystem, Alignment.LEADING))); layout.setHorizontalGroup( - layout.createParallelGroup(GroupLayout.Alignment.LEADING) + layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(lblRankSystem) .addComponent(getComboRankSystems()) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index cdbef95100..3d66e44280 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -128,7 +128,8 @@ private JTabbedPane createHumanResourcesParentTab() { "backgroundsTab", biographyTab.createBackgroundsTab(), "deathTab", biographyTab.createDeathTab(), "educationTab", biographyTab.createEducationTab(), - "nameAndPortraitGenerationTab", biographyTab.createNameAndPortraitGenerationTab())); + "nameAndPortraitGenerationTab", biographyTab.createNameAndPortraitGenerationTab(), + "rankTab", biographyTab.createRankTab())); // Relationships RelationshipsTab relationshipsTab = new RelationshipsTab(getFrame(), "relationshipsTab"); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index eab1a163c3..0950e4d6ab 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -191,8 +191,8 @@ static JPanel createStandardPanel(String name, boolean includeBorder, String bor sizeWidth += component.getPreferredSize().width; } - if (sizeWidth < 500) { - sizeWidth = 500; + if (sizeWidth < 750) { + sizeWidth = 750; } panel.setMaximumSize(new Dimension(sizeWidth, sizeHeight)); @@ -227,16 +227,16 @@ static JPanel createHeaderPanel(String name, String imageAddress, boolean includ JLabel lblBody = new JLabel(); if (includeBodyText) { - lblBody = new JLabel(String.format("%s", + lblBody = new JLabel(String.format("

%s

", resources.getString("lbl" + name + "Body.text")), SwingConstants.CENTER); lblBody.setName("lbl" + name + "Body"); Dimension size = lblBody.getPreferredSize(); - lblBody.setMaximumSize(new Dimension(500, size.height)); + lblBody.setMaximumSize(new Dimension(750, size.height)); } final JPanel panel = createStandardPanel("pnl" + name + "HeaderPanel", includeBorder, borderTitle); Dimension size = panel.getPreferredSize(); - panel.setPreferredSize(new Dimension(500, size.height)); + panel.setPreferredSize(new Dimension(750, size.height)); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -287,8 +287,8 @@ static JPanel createParentPanel(JPanel panel, String name) { // Set Dimensions int widthNew = parentPanel.getMinimumSize().width; - if (widthNew < 500) { - widthNew = 500; + if (widthNew < 750) { + widthNew = 750; } // I don't know why 1.25 works, it just does, and I've given up questioning it. diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java index 449d7f5f4e..5f8c70a213 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java @@ -214,7 +214,7 @@ private static JPanel createGeneralHeader() { resources.getString("lblGeneralBody.text")), SwingConstants.CENTER); lblBody.setName("lblGeneralHeaderBody"); Dimension size = lblBody.getPreferredSize(); - lblBody.setMaximumSize(new Dimension(500, size.height)); + lblBody.setMaximumSize(new Dimension(750, size.height)); final JPanel panel = createStandardPanel("pnlGeneralHeaderPanel", false, ""); final GroupLayout layout = createStandardLayout(panel); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java index dd415094e0..3650e60ebe 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java @@ -12,6 +12,7 @@ import mekhq.campaign.universe.Faction; import mekhq.campaign.universe.Planet; import mekhq.campaign.universe.PlanetarySystem; +import mekhq.gui.panes.RankSystemsPane; import javax.swing.*; import javax.swing.GroupLayout.Alignment; @@ -126,6 +127,10 @@ public class biographyTab { private JCheckBox chkAssignPortraitOnRoleChange; //end Name and Portrait Tab + //start Rank Tab + private RankSystemsPane rankSystemsPane; + //end Rank Tab + /** * Initializes a new {@link biographyTab} with the specified campaign, frame, and name. * @@ -1114,4 +1119,40 @@ private JPanel createRandomPortraitPanel() { return panel; } + + + JPanel createRankTab() { + // Header + JPanel headerPanel = createHeaderPanel("RankTab", + getImageDirectory() + "logo_hanseatic_league.png", + false, "", true); + + // Contents + rankSystemsPane = new RankSystemsPane(frame, campaign); + Component component = rankSystemsPane.getViewport().getView(); + + Dimension size = rankSystemsPane.getPreferredSize(); + rankSystemsPane.setMinimumSize(size); + rankSystemsPane.setMaximumSize(size); + + // Layout the Panel + final JPanel panel = createStandardPanel("RankTab", true, + ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addComponent(component)); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addComponent(component))); + + // Create Parent Panel and return + return createParentPanel(panel, "RankTab"); + } } From 1093707df0e4474764c236d170b71cab40b3b62e Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 11 Oct 2024 10:27:13 -0500 Subject: [PATCH 048/117] Add Javadoc for createRankTab method The Javadoc was added to the createRankTab method to describe its purpose and functionality. Also, a variable name in the layout setup was changed for better readability. This improves the code documentation and clarity for future maintenance. --- .../campaignOptions/tabs/biographyTab.java | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java index 3650e60ebe..d83694fbee 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java @@ -1120,7 +1120,22 @@ private JPanel createRandomPortraitPanel() { return panel; } - + /** + * This method is responsible for creating and setting up the RankTab + * and its components. + * + *

The method creates a header panel with a specified logo and then initializes + * {@code rankSystemsPane} with a {@code RankSystemsPane} object. The preferred size of the + * {@code rankSystemsPane} is set as its minimum and maximum size. + * + *

The layout is created with a vertical and horizontal group, + * to which the components are added sequentially. The {@code headerPanel} and + * the view-port component of {@code rankSystemsPane} are added to both layout groups. + * + *

Finally, the layout components are added to a parent panel which is then returned. + * + * @return JPanel The parent panel with all the layout components added. + */ JPanel createRankTab() { // Header JPanel headerPanel = createHeaderPanel("RankTab", @@ -1129,11 +1144,7 @@ JPanel createRankTab() { // Contents rankSystemsPane = new RankSystemsPane(frame, campaign); - Component component = rankSystemsPane.getViewport().getView(); - - Dimension size = rankSystemsPane.getPreferredSize(); - rankSystemsPane.setMinimumSize(size); - rankSystemsPane.setMaximumSize(size); + Component rankSystemsViewport = rankSystemsPane.getViewport().getView(); // Layout the Panel final JPanel panel = createStandardPanel("RankTab", true, @@ -1144,13 +1155,13 @@ JPanel createRankTab() { layout.setVerticalGroup( layout.createSequentialGroup() .addComponent(headerPanel) - .addComponent(component)); + .addComponent(rankSystemsViewport)); layout.setHorizontalGroup( layout.createSequentialGroup() .addGroup(layout.createParallelGroup(Alignment.LEADING) .addComponent(headerPanel, Alignment.CENTER) - .addComponent(component))); + .addComponent(rankSystemsViewport))); // Create Parent Panel and return return createParentPanel(panel, "RankTab"); From e071ed0342b5119d4a0e934e83a589ec1faaa9eb Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 11 Oct 2024 10:49:59 -0500 Subject: [PATCH 049/117] Refactor tab initialization methods Reorganized initialization of components into separate methods for better readability and maintainability. This change involves splitting the initialization logic for each tab into distinct methods across multiple files, enhancing code modularity. --- .../campaignOptions/tabs/PersonnelTab.java | 239 ++++++++++-------- .../tabs/RelationshipsTab.java | 116 +++++---- .../tabs/RepairAndMaintenanceTab.java | 116 ++++----- .../tabs/SuppliesAndAcquisitionTab.java | 152 ++++++----- .../campaignOptions/tabs/TechLimitsTab.java | 58 +++-- .../tabs/TurnoverAndRetentionTab.java | 43 ++-- .../campaignOptions/tabs/biographyTab.java | 156 +++++++----- 7 files changed, 510 insertions(+), 370 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java index ed291ee271..f5bb067581 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java @@ -158,69 +158,95 @@ public class PersonnelTab { initialize(); } - /** - * This method initializes the various checkboxes, labels, spinners, combo boxes, panels, and - * other GUI components for different tabs. - * It sets up the components for the General Tab, Personnel Logs Tab, Personnel Information Tab, - * Administrators Tab, Awards Tab, Medical Tab, Prisoners and Dependents Tab, and the Salaries Tab. + * Initializes the components of all tabs within the frame. */ protected void initialize() { - //start General Tab - chkUseTactics = new JCheckBox(); - chkUseInitiativeBonus = new JCheckBox(); - chkUseToughness = new JCheckBox(); - chkUseRandomToughness = new JCheckBox(); - chkUseArtillery = new JCheckBox(); - chkUseAbilities = new JCheckBox(); - chkUseEdge = new JCheckBox(); - chkUseSupportEdge = new JCheckBox(); - chkUseImplants = new JCheckBox(); - chkUseAlternativeQualityAveraging = new JCheckBox(); + initializeGeneralTab(); + initializePersonnelLogsTab(); + initializePersonnelInformationTab(); + initializeAdministratorsTab(); + initializeAwardsTab(); + initializeMedicalTab(); + initializePrisonersAndDependentsTab(); + initializeSalariesTab(); + } - personnelCleanUpPanel = new JPanel(); - chkUsePersonnelRemoval = new JCheckBox(); - chkUseRemovalExemptCemetery = new JCheckBox(); - chkUseRemovalExemptRetirees = new JCheckBox(); - //end General Tab + /** + * Initializes the components of the SalariesTab. + * The panel contains settings related to personnel salaries. + */ + private void initializeSalariesTab() { + chkDisableSecondaryRoleSalary = new JCheckBox(); - //start Personnel Logs Tab - chkUseTransfers = new JCheckBox(); - chkUseExtendedTOEForceName = new JCheckBox(); - chkPersonnelLogSkillGain = new JCheckBox(); - chkPersonnelLogAbilityGain = new JCheckBox(); - chkPersonnelLogEdgeGain = new JCheckBox(); - chkDisplayPersonnelLog = new JCheckBox(); - chkDisplayScenarioLog = new JCheckBox(); - chkDisplayKillRecord = new JCheckBox(); - //end Personnel Logs Tab + pnlSalaryMultipliersPanel = new JPanel(); - //start Personnel Information Tab - chkUseTimeInService = new JCheckBox(); + lblAntiMekSalary = new JLabel(); + spnAntiMekSalary = new JSpinner(); - lblTimeInServiceDisplayFormat = new JLabel(); - comboTimeInServiceDisplayFormat = new MMComboBox<>("comboTimeInServiceDisplayFormat", - TimeInDisplayFormat.values()); + lblSpecialistInfantrySalary = new JLabel(); + spnSpecialistInfantrySalary = new JSpinner(); - chkUseTimeInRank = new JCheckBox(); + pnlSalaryExperienceMultipliersPanel = new JPanel(); + lblSalaryExperienceMultipliers = new HashMap<>(); + spnSalaryExperienceMultipliers = new HashMap<>(); - lblTimeInRankDisplayFormat = new JLabel(); - comboTimeInRankDisplayFormat = new MMComboBox<>("comboTimeInRankDisplayFormat", - TimeInDisplayFormat.values()); + pnlSalaryBaseSalaryPanel = new JPanel(); + lblBaseSalary = new JLabel[29]; + spnBaseSalary = new JSpinner[29]; + } - chkTrackTotalEarnings = new JCheckBox(); - chkTrackTotalXPEarnings = new JCheckBox(); - chkShowOriginFaction = new JCheckBox(); - //end Personnel Information Tab + /** + * Initializes the components of the PrisonersAndDependentsTab. + * The panel contains settings related to prisoners and dependents. + */ + private void initializePrisonersAndDependentsTab() { + prisonerPanel = new JPanel(); + lblPrisonerCaptureStyle = new JLabel(); + comboPrisonerCaptureStyle = new MMComboBox<>("comboPrisonerCaptureStyle", + PrisonerCaptureStyle.values()); - //start Administrators Tab - chkAdminsHaveNegotiation = new JCheckBox(); - chkAdminExperienceLevelIncludeNegotiation = new JCheckBox(); - chkAdminsHaveScrounge = new JCheckBox(); - chkAdminExperienceLevelIncludeScrounge = new JCheckBox(); - //end Administrators Tab + lblPrisonerStatus = new JLabel(); + comboPrisonerStatus = new MMComboBox<>("comboPrisonerStatus", + getPrisonerStatusOptions()); + + chkPrisonerBabyStatus = new JCheckBox(); + chkAtBPrisonerDefection = new JCheckBox(); + chkAtBPrisonerRansom = new JCheckBox(); + + dependentsPanel = new JPanel(); + chkUseRandomDependentAddition = new JCheckBox(); + chkUseRandomDependentRemoval = new JCheckBox(); + } + + /** + * Initializes the components of the MedicalTab. + * The panel contains settings related to medical recovery and checks. + */ + private void initializeMedicalTab() { + chkUseAdvancedMedical = new JCheckBox(); + + lblHealWaitingPeriod = new JLabel(); + spnHealWaitingPeriod = new JSpinner(); + + lblNaturalHealWaitingPeriod = new JLabel(); + spnNaturalHealWaitingPeriod = new JSpinner(); - //start Awards Tab + lblMinimumHitsForVehicles = new JLabel(); + spnMinimumHitsForVehicles = new JSpinner(); + + chkUseRandomHitsForVehicles = new JCheckBox(); + chkUseTougherHealing = new JCheckBox(); + + lblMaximumPatients = new JLabel(); + spnMaximumPatients = new JSpinner(); + } + + /** + * Initializes the components of the AwardsTab. + * The panel contains settings related to award allocation. + */ + private void initializeAwardsTab() { lblAwardBonusStyle = new JLabel(); comboAwardBonusStyle = new MMComboBox<>("comboAwardBonusStyle", AwardBonus.values()); @@ -246,65 +272,76 @@ protected void initialize() { autoAwardsFilterPanel = new JPanel(); lblAwardSetFilterList = new JLabel(); txtAwardSetFilterList = new JTextArea(); - //end Awards Tab - - //start Medical Tab - chkUseAdvancedMedical = new JCheckBox(); - - lblHealWaitingPeriod = new JLabel(); - spnHealWaitingPeriod = new JSpinner(); - - lblNaturalHealWaitingPeriod = new JLabel(); - spnNaturalHealWaitingPeriod = new JSpinner(); - - lblMinimumHitsForVehicles = new JLabel(); - spnMinimumHitsForVehicles = new JSpinner(); - - chkUseRandomHitsForVehicles = new JCheckBox(); - chkUseTougherHealing = new JCheckBox(); - - lblMaximumPatients = new JLabel(); - spnMaximumPatients = new JSpinner(); - //end Medical Tab - - //start Prisoners & Dependents Tab - prisonerPanel = new JPanel(); - lblPrisonerCaptureStyle = new JLabel(); - comboPrisonerCaptureStyle = new MMComboBox<>("comboPrisonerCaptureStyle", - PrisonerCaptureStyle.values()); + } - lblPrisonerStatus = new JLabel(); - comboPrisonerStatus = new MMComboBox<>("comboPrisonerStatus", - getPrisonerStatusOptions()); + /** + * Initializes the components of the AdministratorsTab. + * The panel contains settings related to administrator abilities. + */ + private void initializeAdministratorsTab() { + chkAdminsHaveNegotiation = new JCheckBox(); + chkAdminExperienceLevelIncludeNegotiation = new JCheckBox(); + chkAdminsHaveScrounge = new JCheckBox(); + chkAdminExperienceLevelIncludeScrounge = new JCheckBox(); + } - chkPrisonerBabyStatus = new JCheckBox(); - chkAtBPrisonerDefection = new JCheckBox(); - chkAtBPrisonerRansom = new JCheckBox(); + /** + * Initializes the components of the PersonnelInformationTab. + * The panel contains settings related to personnel information display. + */ + private void initializePersonnelInformationTab() { + chkUseTimeInService = new JCheckBox(); - dependentsPanel = new JPanel(); - chkUseRandomDependentAddition = new JCheckBox(); - chkUseRandomDependentRemoval = new JCheckBox(); - //end Prisoners & Dependents Tab + lblTimeInServiceDisplayFormat = new JLabel(); + comboTimeInServiceDisplayFormat = new MMComboBox<>("comboTimeInServiceDisplayFormat", + TimeInDisplayFormat.values()); - //start Salaries Tab - chkDisableSecondaryRoleSalary = new JCheckBox(); + chkUseTimeInRank = new JCheckBox(); - pnlSalaryMultipliersPanel = new JPanel(); + lblTimeInRankDisplayFormat = new JLabel(); + comboTimeInRankDisplayFormat = new MMComboBox<>("comboTimeInRankDisplayFormat", + TimeInDisplayFormat.values()); - lblAntiMekSalary = new JLabel(); - spnAntiMekSalary = new JSpinner(); + chkTrackTotalEarnings = new JCheckBox(); + chkTrackTotalXPEarnings = new JCheckBox(); + chkShowOriginFaction = new JCheckBox(); + } - lblSpecialistInfantrySalary = new JLabel(); - spnSpecialistInfantrySalary = new JSpinner(); + /** + * Initializes components of the PersonnelLogsTab. + * Panel consists of settings related to personnel log keeping. + */ + private void initializePersonnelLogsTab() { + chkUseTransfers = new JCheckBox(); + chkUseExtendedTOEForceName = new JCheckBox(); + chkPersonnelLogSkillGain = new JCheckBox(); + chkPersonnelLogAbilityGain = new JCheckBox(); + chkPersonnelLogEdgeGain = new JCheckBox(); + chkDisplayPersonnelLog = new JCheckBox(); + chkDisplayScenarioLog = new JCheckBox(); + chkDisplayKillRecord = new JCheckBox(); + } - pnlSalaryExperienceMultipliersPanel = new JPanel(); - lblSalaryExperienceMultipliers = new HashMap<>(); - spnSalaryExperienceMultipliers = new HashMap<>(); + /** + * Initializes components of the GeneralTab. + * The panel contains general settings. + */ + private void initializeGeneralTab() { + chkUseTactics = new JCheckBox(); + chkUseInitiativeBonus = new JCheckBox(); + chkUseToughness = new JCheckBox(); + chkUseRandomToughness = new JCheckBox(); + chkUseArtillery = new JCheckBox(); + chkUseAbilities = new JCheckBox(); + chkUseEdge = new JCheckBox(); + chkUseSupportEdge = new JCheckBox(); + chkUseImplants = new JCheckBox(); + chkUseAlternativeQualityAveraging = new JCheckBox(); - pnlSalaryBaseSalaryPanel = new JPanel(); - lblBaseSalary = new JLabel[29]; - spnBaseSalary = new JSpinner[29]; - //end Salaries Tab + personnelCleanUpPanel = new JPanel(); + chkUsePersonnelRemoval = new JCheckBox(); + chkUseRemovalExemptCemetery = new JCheckBox(); + chkUseRemovalExemptRetirees = new JCheckBox(); } /** diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java index 7c115e65f7..fb87df894c 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java @@ -98,8 +98,75 @@ public class RelationshipsTab { initialize(); } + /** + * Calls the initialization methods for all the tab panels. + */ protected void initialize() { - // Marriage Tab + initializeMarriageTab(); + initializeDivorceTab(); + initializeProcreationTab(); + } + + /** + * Initializes the components of the ProcreationTab. + * The panel contains settings related to character procreation in the simulation. + */ + private void initializeProcreationTab() { + pnlProcreationGeneralOptionsPanel = new JPanel(); + chkUseManualProcreation = new JCheckBox(); + chkUseClanPersonnelProcreation = new JCheckBox(); + chkUsePrisonerProcreation = new JCheckBox(); + lblMultiplePregnancyOccurrences = new JLabel(); + spnMultiplePregnancyOccurrences = new JSpinner(); + lblBabySurnameStyle = new JLabel(); + comboBabySurnameStyle = new MMComboBox<>("comboBabySurnameStyle", BabySurnameStyle.values()); + chkAssignNonPrisonerBabiesFounderTag = new JCheckBox(); + chkAssignChildrenOfFoundersFounderTag = new JCheckBox(); + chkDetermineFatherAtBirth = new JCheckBox(); + chkDisplayTrueDueDate = new JCheckBox(); + lblNoInterestInChildrenDiceSize = new JLabel(); + spnNoInterestInChildrenDiceSize = new JSpinner(); + chkUseMaternityLeave = new JCheckBox(); + chkLogProcreation = new JCheckBox(); + + pnlRandomProcreationPanel = new JPanel(); + lblRandomProcreationMethod = new JLabel(); + comboRandomProcreationMethod = new MMComboBox<>("comboRandomProcreationMethod", + RandomProcreationMethod.values()); + chkUseRelationshiplessRandomProcreation = new JCheckBox(); + chkUseRandomClanPersonnelProcreation = new JCheckBox(); + chkUseRandomPrisonerProcreation = new JCheckBox(); + lblRandomProcreationRelationshipDiceSize = new JLabel(); + spnRandomProcreationRelationshipDiceSize = new JSpinner(); + lblRandomProcreationRelationshiplessDiceSize = new JLabel(); + spnRandomProcreationRelationshiplessDiceSize = new JSpinner(); + } + + /** + * Initializes the components of the DivorceTab. + * The panel contains settings related to divorce mechanics within the simulation. + */ + private void initializeDivorceTab() { + chkUseManualDivorce = new JCheckBox(); + chkUseClanPersonnelDivorce = new JCheckBox(); + chkUsePrisonerDivorce = new JCheckBox(); + + pnlRandomDivorce = new JPanel(); + lblRandomDivorceMethod = new JLabel(); + comboRandomDivorceMethod = new MMComboBox<>("comboRandomDivorceMethod", RandomDivorceMethod.values()); + chkUseRandomOppositeSexDivorce = new JCheckBox(); + chkUseRandomSameSexDivorce = new JCheckBox(); + chkUseRandomClanPersonnelDivorce = new JCheckBox(); + chkUseRandomPrisonerDivorce = new JCheckBox(); + lblRandomDivorceDiceSize = new JLabel(); + spnRandomDivorceDiceSize = new JSpinner(); + } + + /** + * Initializes the components of the MarriageTab. + * The panel contains various settings related to marriage mechanics within the simulation. + */ + private void initializeMarriageTab() { pnlMarriageGeneralOptions = new JPanel(); chkUseManualMarriages = new JCheckBox(); chkUseClanPersonnelMarriages = new JCheckBox(); @@ -130,52 +197,9 @@ protected void initialize() { spnRandomSameSexMarriageDiceSize = new JSpinner(); lblRandomNewDependentMarriage = new JLabel(); spnRandomNewDependentMarriage = new JSpinner(); + } - // Divorce Tab - chkUseManualDivorce = new JCheckBox(); - chkUseClanPersonnelDivorce = new JCheckBox(); - chkUsePrisonerDivorce = new JCheckBox(); - - pnlRandomDivorce = new JPanel(); - lblRandomDivorceMethod = new JLabel(); - comboRandomDivorceMethod = new MMComboBox<>("comboRandomDivorceMethod", RandomDivorceMethod.values()); - chkUseRandomOppositeSexDivorce = new JCheckBox(); - chkUseRandomSameSexDivorce = new JCheckBox(); - chkUseRandomClanPersonnelDivorce = new JCheckBox(); - chkUseRandomPrisonerDivorce = new JCheckBox(); - lblRandomDivorceDiceSize = new JLabel(); - spnRandomDivorceDiceSize = new JSpinner(); - - // Procreation Tab - pnlProcreationGeneralOptionsPanel = new JPanel(); - chkUseManualProcreation = new JCheckBox(); - chkUseClanPersonnelProcreation = new JCheckBox(); - chkUsePrisonerProcreation = new JCheckBox(); - lblMultiplePregnancyOccurrences = new JLabel(); - spnMultiplePregnancyOccurrences = new JSpinner(); - lblBabySurnameStyle = new JLabel(); - comboBabySurnameStyle = new MMComboBox<>("comboBabySurnameStyle", BabySurnameStyle.values()); - chkAssignNonPrisonerBabiesFounderTag = new JCheckBox(); - chkAssignChildrenOfFoundersFounderTag = new JCheckBox(); - chkDetermineFatherAtBirth = new JCheckBox(); - chkDisplayTrueDueDate = new JCheckBox(); - lblNoInterestInChildrenDiceSize = new JLabel(); - spnNoInterestInChildrenDiceSize = new JSpinner(); - chkUseMaternityLeave = new JCheckBox(); - chkLogProcreation = new JCheckBox(); - - pnlRandomProcreationPanel = new JPanel(); - lblRandomProcreationMethod = new JLabel(); - comboRandomProcreationMethod = new MMComboBox<>("comboRandomProcreationMethod", - RandomProcreationMethod.values()); - chkUseRelationshiplessRandomProcreation = new JCheckBox(); - chkUseRandomClanPersonnelProcreation = new JCheckBox(); - chkUseRandomPrisonerProcreation = new JCheckBox(); - lblRandomProcreationRelationshipDiceSize = new JLabel(); - spnRandomProcreationRelationshipDiceSize = new JSpinner(); - lblRandomProcreationRelationshiplessDiceSize = new JLabel(); - spnRandomProcreationRelationshiplessDiceSize = new JSpinner(); - }/** + /** * Creates a panel for the Marriage tab with various input components and panels related to marriage settings. * * @return a {@link} representing the Marriage tab with checkboxes for manual, clan personnel, diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java index 300e204f23..43d3d205d7 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java @@ -51,6 +51,64 @@ public RepairAndMaintenanceTab(JFrame frame, String name) { initialize(); } + /** + * Initializes the repair and maintenance tab by creating and initializing various UI components. + */ + void initialize() { + initializeRepairTab(); + initializeMaintenanceTab(); + } + + /** + * Initializes the repair tab by creating and initializing various UI components. + */ + private void initializeRepairTab() { + useEraModsCheckBox = new JCheckBox(); + + assignedTechFirstCheckBox = new JCheckBox(); + + resetToFirstTechCheckBox = new JCheckBox(); + + useQuirksBox = new JCheckBox(); + + useAeroSystemHitsBox = new JCheckBox(); + + useDamageMargin = new JCheckBox(); + lblDamageMargin = new JLabel(); + spnDamageMargin = new JSpinner(); + + lblDestroyPartTarget = new JLabel(); + spnDestroyPartTarget = new JSpinner(); + } + + /** + * Initializes the maintenance tab by creating and initializing various UI components. + */ + private void initializeMaintenanceTab() { + checkMaintenance = new JCheckBox(); + + lblMaintenanceDays = new JLabel(); + spnMaintenanceDays = new JSpinner(); + + lblMaintenanceBonus = new JLabel(); + spnMaintenanceBonus = new JSpinner(); + + lblDefaultMaintenanceTime = new JLabel(); + spnDefaultMaintenanceTime = new JSpinner(); + + useQualityMaintenance = new JCheckBox(); + + reverseQualityNames = new JCheckBox(); + + chkUseRandomUnitQualities = new JCheckBox(); + + chkUsePlanetaryModifiers = new JCheckBox(); + + useUnofficialMaintenance = new JCheckBox(); + + logMaintenance = new JCheckBox(); + } + /** * Creates the repair tab panel. * @@ -236,62 +294,4 @@ JPanel createMaintenanceTab() { private void recreateFinancesPanel(boolean isReversingQualityNames) { // TODO handle this } - - /** - * Initializes the repair and maintenance tab by creating and initializing various UI components. - */ - void initialize() { - initializeRepairTab(); - initializeMaintenanceTab(); - } - - /** - * Initializes the repair tab by creating and initializing various UI components. - */ - private void initializeRepairTab() { - useEraModsCheckBox = new JCheckBox(); - - assignedTechFirstCheckBox = new JCheckBox(); - - resetToFirstTechCheckBox = new JCheckBox(); - - useQuirksBox = new JCheckBox(); - - useAeroSystemHitsBox = new JCheckBox(); - - useDamageMargin = new JCheckBox(); - lblDamageMargin = new JLabel(); - spnDamageMargin = new JSpinner(); - - lblDestroyPartTarget = new JLabel(); - spnDestroyPartTarget = new JSpinner(); - } - - /** - * Initializes the maintenance tab by creating and initializing various UI components. - */ - private void initializeMaintenanceTab() { - checkMaintenance = new JCheckBox(); - - lblMaintenanceDays = new JLabel(); - spnMaintenanceDays = new JSpinner(); - - lblMaintenanceBonus = new JLabel(); - spnMaintenanceBonus = new JSpinner(); - - lblDefaultMaintenanceTime = new JLabel(); - spnDefaultMaintenanceTime = new JSpinner(); - - useQualityMaintenance = new JCheckBox(); - - reverseQualityNames = new JCheckBox(); - - chkUseRandomUnitQualities = new JCheckBox(); - - chkUsePlanetaryModifiers = new JCheckBox(); - - useUnofficialMaintenance = new JCheckBox(); - - logMaintenance = new JCheckBox(); - } } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java index e177319876..65296d0892 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java @@ -81,6 +81,93 @@ public SuppliesAndAcquisitionTab(JFrame frame, String name) { initialize(); } + /** + * Calls the initialization methods for all the tab panels. + */ + void initialize() { + initializeAcquisitionTab(); + initializeDelivery(); + initializePlanetaryAcquisitionsTab(); + } + + /** + * Initializes the components of the ProcreationTab. + * The panel contains settings related to character procreation in the simulation. + */ + private void initializePlanetaryAcquisitionsTab() { + // Options + usePlanetaryAcquisitions = new JCheckBox(); + + lblMaxJumpPlanetaryAcquisitions = new JLabel(); + spnMaxJumpPlanetaryAcquisitions = new JSpinner(); + + lblPlanetaryAcquisitionsFactionLimits = new JLabel(); + comboPlanetaryAcquisitionsFactionLimits = new MMComboBox<>("comboPlanetaryAcquisitionsFactionLimits", + PlanetaryAcquisitionFactionLimit.values()); + + disallowPlanetaryAcquisitionClanCrossover = new JCheckBox(); + + disallowClanPartsFromIS = new JCheckBox(); + + lblPenaltyClanPartsFromIS = new JLabel(); + spnPenaltyClanPartsFromIS = new JSpinner(); + + usePlanetaryAcquisitionsVerbose = new JCheckBox(); + + // Modifiers + lblPlanetAcquireTechBonus = new JLabel[6]; + spnPlanetAcquireTechBonus = new JSpinner[6]; + + lblPlanetAcquireIndustryBonus = new JLabel[6]; + spnPlanetAcquireIndustryBonus = new JSpinner[6]; + + lblPlanetAcquireOutputBonus = new JLabel[6]; + spnPlanetAcquireOutputBonus = new JSpinner[6]; + } + + /** + * Initializes the components of the DivorceTab. + * The panel contains settings related to divorce mechanics within the simulation. + */ + private void initializeDelivery() { + lblNDiceTransitTime = new JLabel(); + spnNDiceTransitTime = new JSpinner(); + lblConstantTransitTime = new JLabel(); + spnConstantTransitTime = new JSpinner(); + choiceTransitTimeUnits = new MMComboBox<>("choiceTransitTimeUnits", getTransitUnitOptions()); + + lblAcquireMosBonus = new JLabel(); + spnAcquireMosBonus = new JSpinner(); + choiceAcquireMosUnits = new MMComboBox<>("choiceAcquireMosUnits", getTransitUnitOptions()); + + lblAcquireMinimum = new JLabel(); + spnAcquireMinimum = new JSpinner(); + choiceAcquireMinimumUnit = new MMComboBox<>("choiceAcquireMinimumUnit", getTransitUnitOptions()); + } + + /** + * Initializes the components of the MarriageTab. + * The panel contains various settings related to marriage mechanics within the simulation. + */ + private void initializeAcquisitionTab() { + lblChoiceAcquireSkill = new JLabel(); + choiceAcquireSkill = new MMComboBox<>("choiceAcquireSkill", buildAcquireSkillComboOptions()); + + chkSupportStaffOnly = new JCheckBox(); + + lblAcquireClanPenalty = new JLabel(); + spnAcquireClanPenalty = new JSpinner(); + + lblAcquireIsPenalty = new JLabel(); + spnAcquireIsPenalty = new JSpinner(); + + lblAcquireWaitingPeriod = new JLabel(); + spnAcquireWaitingPeriod = new JSpinner(); + + lblMaxAcquisitions = new JLabel(); + spnMaxAcquisitions = new JSpinner(); + } + /** * Creates the acquisition tab panel. * @@ -581,69 +668,4 @@ private static DefaultComboBoxModel buildAcquireSkillComboOptions() { return acquireSkillModel; } - - void initialize() { - // Acquisition Tab - lblChoiceAcquireSkill = new JLabel(); - choiceAcquireSkill = new MMComboBox<>("choiceAcquireSkill", buildAcquireSkillComboOptions()); - - chkSupportStaffOnly = new JCheckBox(); - - lblAcquireClanPenalty = new JLabel(); - spnAcquireClanPenalty = new JSpinner(); - - lblAcquireIsPenalty = new JLabel(); - spnAcquireIsPenalty = new JSpinner(); - - lblAcquireWaitingPeriod = new JLabel(); - spnAcquireWaitingPeriod = new JSpinner(); - - lblMaxAcquisitions = new JLabel(); - spnMaxAcquisitions = new JSpinner(); - - // Delivery Tab - lblNDiceTransitTime = new JLabel(); - spnNDiceTransitTime = new JSpinner(); - lblConstantTransitTime = new JLabel(); - spnConstantTransitTime = new JSpinner(); - choiceTransitTimeUnits = new MMComboBox<>("choiceTransitTimeUnits", getTransitUnitOptions()); - - lblAcquireMosBonus = new JLabel(); - spnAcquireMosBonus = new JSpinner(); - choiceAcquireMosUnits = new MMComboBox<>("choiceAcquireMosUnits", getTransitUnitOptions()); - - lblAcquireMinimum = new JLabel(); - spnAcquireMinimum = new JSpinner(); - choiceAcquireMinimumUnit = new MMComboBox<>("choiceAcquireMinimumUnit", getTransitUnitOptions()); - - // Planetary Acquisition Tab - // Options - usePlanetaryAcquisitions = new JCheckBox(); - - lblMaxJumpPlanetaryAcquisitions = new JLabel(); - spnMaxJumpPlanetaryAcquisitions = new JSpinner(); - - lblPlanetaryAcquisitionsFactionLimits = new JLabel(); - comboPlanetaryAcquisitionsFactionLimits = new MMComboBox<>("comboPlanetaryAcquisitionsFactionLimits", - PlanetaryAcquisitionFactionLimit.values()); - - disallowPlanetaryAcquisitionClanCrossover = new JCheckBox(); - - disallowClanPartsFromIS = new JCheckBox(); - - lblPenaltyClanPartsFromIS = new JLabel(); - spnPenaltyClanPartsFromIS = new JSpinner(); - - usePlanetaryAcquisitionsVerbose = new JCheckBox(); - - // Modifiers - lblPlanetAcquireTechBonus = new JLabel[6]; - spnPlanetAcquireTechBonus = new JSpinner[6]; - - lblPlanetAcquireIndustryBonus = new JLabel[6]; - spnPlanetAcquireIndustryBonus = new JSpinner[6]; - - lblPlanetAcquireOutputBonus = new JLabel[6]; - spnPlanetAcquireOutputBonus = new JSpinner[6]; - } } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java index 6bfcd17d6a..f85cd5c5cc 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java @@ -39,6 +39,46 @@ public TechLimitsTab(JFrame frame, String name) { initialize(); } + /** + * Calls the initialization methods for the different tabs. + */ + void initialize() { + initializeTechLimitsTab(); + initializeRandomAssignmentTablesTab(); + initializeCustomRulesetsTab(); + } + + /** + * Initializes the components of the TechLimitsTab. + * This panel contains various controls for setting technological limits. + */ + private void initializeTechLimitsTab() { + limitByYearBox = new JCheckBox(); + disallowExtinctStuffBox = new JCheckBox(); + allowClanPurchasesBox = new JCheckBox(); + allowISPurchasesBox = new JCheckBox(); + allowCanonOnlyBox = new JCheckBox(); + allowCanonRefitOnlyBox = new JCheckBox(); + lblChoiceTechLevel = new JLabel(); + choiceTechLevel = new MMComboBox<>("choiceTechLevel", getMaximumTechLevelOptions()); + variableTechLevelBox = new JCheckBox(); + useAmmoByTypeBox = new JCheckBox(); + } + + /** + * Initializes the components of the RandomAssignmentTablesTab. + * This panel would typically contain controls related to random assignment tables. + */ + private void initializeRandomAssignmentTablesTab() { + } + + /** + * Initializes the components of the CustomRulesetsTab. + * This panel would typically contain controls related to custom rulesets. + */ + private void initializeCustomRulesetsTab() { + } + /** * Creates a {@link JPanel} representing the tech limits tab. * This method constructs various components including checkboxes, labels, and combo boxes @@ -140,24 +180,6 @@ JPanel createTechLimitsTab() { return wrapperPanel; } - void initialize() { - // Tech Limits Tab - limitByYearBox = new JCheckBox(); - disallowExtinctStuffBox = new JCheckBox(); - allowClanPurchasesBox = new JCheckBox(); - allowISPurchasesBox = new JCheckBox(); - allowCanonOnlyBox = new JCheckBox(); - allowCanonRefitOnlyBox = new JCheckBox(); - lblChoiceTechLevel = new JLabel(); - choiceTechLevel = new MMComboBox<>("choiceTechLevel", getMaximumTechLevelOptions()); - variableTechLevelBox = new JCheckBox(); - useAmmoByTypeBox = new JCheckBox(); - - // Random Assignment Tables Tab - - // Rulesets Tab - } - /** * @return a {@link DefaultComboBoxModel} containing options for maximum technology levels. */ diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java index 0949e86316..57213cbeae 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java @@ -123,14 +123,34 @@ public class TurnoverAndRetentionTab { } /** - * Initializes and configures the components that will be used in the Turnover and Fatigue tabs. - *

- * Components initialized include various check boxes, labels, spinners and panels necessary for - * the configuration of these tab panels. Almost all components necessary in these tabs are - * initialized here. + * Initializes all tab components. */ protected void initialize() { - // Turnover Tab + initializeTurnoverTab(); + initializeFatigueTab(); + } + + /** + * Initializes the components for the FatigueTab panel. + * This panel contains settings related to fatigue mechanics in the game. + */ + private void initializeFatigueTab() { + chkUseFatigue = new JCheckBox(); + lblFatigueRate = new JLabel(); + spnFatigueRate = new JSpinner(); + chkUseInjuryFatigue = new JCheckBox(); + lblFieldKitchenCapacity = new JLabel(); + spnFieldKitchenCapacity = new JSpinner(); + chkFieldKitchenIgnoreNonCombatants = new JCheckBox(); + lblFatigueLeaveThreshold = new JLabel(); + spnFatigueLeaveThreshold = new JSpinner(); + } + + /** + * Initializes the components for the TurnoverTab panel. + * This panel contains various settings influencing unit turnover in the game. + */ + private void initializeTurnoverTab() { chkUseRandomRetirement = new JCheckBox(); pnlSettings = new JPanel(); @@ -193,17 +213,6 @@ protected void initialize() { chkUseCommanderLeadershipOnly = new JCheckBox(); lblManagementSkillPenalty = new JLabel(); spnManagementSkillPenalty = new JSpinner(); - - // Fatigue Tab - chkUseFatigue = new JCheckBox(); - lblFatigueRate = new JLabel(); - spnFatigueRate = new JSpinner(); - chkUseInjuryFatigue = new JCheckBox(); - lblFieldKitchenCapacity = new JLabel(); - spnFieldKitchenCapacity = new JSpinner(); - chkFieldKitchenIgnoreNonCombatants = new JCheckBox(); - lblFatigueLeaveThreshold = new JLabel(); - spnFatigueLeaveThreshold = new JSpinner(); } /** diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java index d83694fbee..ac9ea71901 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java @@ -147,67 +147,38 @@ public class biographyTab { } /** - * Initializes the state and the UI components for the settings panels. - * This includes General, Backgrounds, Marriage, Divorce, Procreation, and Death panels. - * Each panel contains multiple aspects of settings such as Randomization, Dice Size, Display of - * Anniversaries, Handling of Origin Options, Marriage & Divorce parameters, Probabilities related - * to Procreation, and settings for Death scenarios among others. - * {@link JCheckBox}, {@link JLabel}, {@link JSlider}, {@link JSpinner} and {@link MMComboBox} - * components are thoroughly initialized in this method for handling various settings options. + * Initializes the components for the NameAndPortraitTab panel. + * The panel contains various settings related to names and portraits. */ protected void initialize() { - // General Tab - chkUseDylansRandomXP = new JCheckBox(); - lblGender = new JLabel(); - sldGender = new JSlider(); - lblNonBinaryDiceSize = new JLabel(); - spnNonBinaryDiceSize = new JSpinner(); - lblFamilyDisplayLevel = new JLabel(); - comboFamilyDisplayLevel = new MMComboBox<>("comboFamilyDisplayLevel", - FamilialRelationshipDisplayLevel.values()); - - pnlAnniversariesPanel = new JPanel(); - chkAnnounceOfficersOnly = new JCheckBox(); - chkAnnounceBirthdays = new JCheckBox(); - chkAnnounceChildBirthdays = new JCheckBox(); - chkAnnounceRecruitmentAnniversaries = new JCheckBox(); - - // Backgrounds Tab - chkUseRandomPersonalities = new JCheckBox(); - chkUseRandomPersonalityReputation = new JCheckBox(); - chkUseIntelligenceXpMultiplier = new JCheckBox(); - chkUseSimulatedRelationships = new JCheckBox(); - - pnlRandomOriginOptions = new JPanel(); - chkRandomizeOrigin = new JCheckBox(); - chkRandomizeDependentsOrigin = new JCheckBox(); - chkRandomizeAroundSpecifiedPlanet = new JCheckBox(); - chkSpecifiedSystemFactionSpecific = new JCheckBox(); - lblSpecifiedSystem = new JLabel(); - comboSpecifiedSystem = new MMComboBox<>("comboSpecifiedSystem"); - lblSpecifiedPlanet = new JLabel(); - comboSpecifiedPlanet = new MMComboBox<>("comboSpecifiedPlanet"); - lblOriginSearchRadius = new JLabel(); - spnOriginSearchRadius = new JSpinner(); - lblOriginDistanceScale = new JLabel(); - spnOriginDistanceScale = new JSpinner(); - chkAllowClanOrigins = new JCheckBox(); - chkExtraRandomOrigin = new JCheckBox(); + initializeGeneralTab(); + initializeBackgroundsTab(); + initializeDeathTab(); + initializeEducationTab(); + initializeNameAndPortraitTab(); + } - // Death Tab - chkKeepMarriedNameUponSpouseDeath = new JCheckBox(); - lblRandomDeathMethod = new JLabel(); - comboRandomDeathMethod = new MMComboBox<>("comboRandomDeathMethod", RandomDeathMethod.values()); - chkUseRandomClanPersonnelDeath = new JCheckBox(); - chkUseRandomPrisonerDeath = new JCheckBox(); - chkUseRandomDeathSuicideCause = new JCheckBox(); - lblPercentageRandomDeathChance = new JLabel(); - spnPercentageRandomDeathChance = new JSpinner(); + /** + * Initializes the components for the EducationTab panel. + * The panel contains various settings related to the educational module. + */ + private void initializeNameAndPortraitTab() { + chkUseOriginFactionForNames = new JCheckBox(); + lblFactionNames = new JLabel(); + comboFactionNames = new MMComboBox<>("comboFactionNames", getFactionNamesModel()); + chkAssignPortraitOnRoleChange = new JCheckBox(); - pnlDeathAgeGroup = new JPanel(); - chkEnabledRandomDeathAgeGroups = new HashMap<>(); + pnlRandomPortrait = new JPanel(); + chkUsePortrait = new JCheckBox[1]; // We're going to properly initialize this later + allPortraitsBox = new JCheckBox(); + noPortraitsBox = new JCheckBox(); + } - // Education Tab + /** + * Initializes the components for the DeathTab panel. + * The panel deals with various settings related to in-game character death. + */ + private void initializeEducationTab() { chkUseEducationModule = new JCheckBox(); lblCurriculumXpRate = new JLabel(); spnCurriculumXpRate = new JSpinner(); @@ -240,17 +211,72 @@ protected void initialize() { chkAllAges = new JCheckBox(); lblMilitaryAcademyAccidents = new JLabel(); spnMilitaryAcademyAccidents = new JSpinner(); + } - // Name and Portrait Generation - chkUseOriginFactionForNames = new JCheckBox(); - lblFactionNames = new JLabel(); - comboFactionNames = new MMComboBox<>("comboFactionNames", getFactionNamesModel()); - chkAssignPortraitOnRoleChange = new JCheckBox(); + /** + * Initializes the components for the BackgroundsTab panel. + * The panel contains various settings related to backgrounds and origins. + */ + private void initializeDeathTab() { + chkKeepMarriedNameUponSpouseDeath = new JCheckBox(); + lblRandomDeathMethod = new JLabel(); + comboRandomDeathMethod = new MMComboBox<>("comboRandomDeathMethod", RandomDeathMethod.values()); + chkUseRandomClanPersonnelDeath = new JCheckBox(); + chkUseRandomPrisonerDeath = new JCheckBox(); + chkUseRandomDeathSuicideCause = new JCheckBox(); + lblPercentageRandomDeathChance = new JLabel(); + spnPercentageRandomDeathChance = new JSpinner(); - pnlRandomPortrait = new JPanel(); - chkUsePortrait = new JCheckBox[1]; // We're going to properly initialize this later - allPortraitsBox = new JCheckBox(); - noPortraitsBox = new JCheckBox(); + pnlDeathAgeGroup = new JPanel(); + chkEnabledRandomDeathAgeGroups = new HashMap<>(); + } + + /** + * Initializes the components for the GeneralTab panel. + * The panel contains various general settings. + */ + private void initializeBackgroundsTab() { + chkUseRandomPersonalities = new JCheckBox(); + chkUseRandomPersonalityReputation = new JCheckBox(); + chkUseIntelligenceXpMultiplier = new JCheckBox(); + chkUseSimulatedRelationships = new JCheckBox(); + + pnlRandomOriginOptions = new JPanel(); + chkRandomizeOrigin = new JCheckBox(); + chkRandomizeDependentsOrigin = new JCheckBox(); + chkRandomizeAroundSpecifiedPlanet = new JCheckBox(); + chkSpecifiedSystemFactionSpecific = new JCheckBox(); + lblSpecifiedSystem = new JLabel(); + comboSpecifiedSystem = new MMComboBox<>("comboSpecifiedSystem"); + lblSpecifiedPlanet = new JLabel(); + comboSpecifiedPlanet = new MMComboBox<>("comboSpecifiedPlanet"); + lblOriginSearchRadius = new JLabel(); + spnOriginSearchRadius = new JSpinner(); + lblOriginDistanceScale = new JLabel(); + spnOriginDistanceScale = new JSpinner(); + chkAllowClanOrigins = new JCheckBox(); + chkExtraRandomOrigin = new JCheckBox(); + } + + /** + * Initializes components of the GeneralTab. + * The panel contains general settings. + */ + private void initializeGeneralTab() { + chkUseDylansRandomXP = new JCheckBox(); + lblGender = new JLabel(); + sldGender = new JSlider(); + lblNonBinaryDiceSize = new JLabel(); + spnNonBinaryDiceSize = new JSpinner(); + lblFamilyDisplayLevel = new JLabel(); + comboFamilyDisplayLevel = new MMComboBox<>("comboFamilyDisplayLevel", + FamilialRelationshipDisplayLevel.values()); + + pnlAnniversariesPanel = new JPanel(); + chkAnnounceOfficersOnly = new JCheckBox(); + chkAnnounceBirthdays = new JCheckBox(); + chkAnnounceChildBirthdays = new JCheckBox(); + chkAnnounceRecruitmentAnniversaries = new JCheckBox(); } /** From 27ab0b239f98366b9a26115592f49387f2419201 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 11 Oct 2024 10:53:35 -0500 Subject: [PATCH 050/117] Rename biographyTab.java to BiographyTab.java Renamed the biographyTab class and its references to BiographyTab to follow Java naming conventions. Updated Javadocs and comments to reflect the new class name and added an explanatory class header. --- .../{biographyTab.java => BiographyTab.java} | 32 +++++++++++++++---- .../tabs/CampaignOptionsPane.java | 2 +- 2 files changed, 27 insertions(+), 7 deletions(-) rename MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/{biographyTab.java => BiographyTab.java} (97%) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java similarity index 97% rename from MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java rename to MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java index ac9ea71901..9d4bdb56b4 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/biographyTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java @@ -24,7 +24,27 @@ import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; -public class biographyTab { +/** + * The `BiographyTab` class represents the biography settings tab in campaign options. + * It is responsible for maintaining and allowing updates to the settings related to biographies + * in a campaign. This includes general settings, name and portrait settings, rank settings, + * background settings, death settings, and education settings. + *

+ * Each area of settings is initialized and managed in its own tab, which allows for organization + * and easy navigation settings related to biographic information. + *

+ * The class also has a set of fields that dictate the state of the individual settings. + *

+ * Some of the key settings managed by this tab include: + * - Random XP: a setting that controls the use of Dylan's random XP. + * - Gender settings: a set of settings that controls the gender ratio and non-binary dice size. + * - Name and portrait settings: a set of settings to control the use of origin factions for names, + * and the behavior of random portraits. + * - Education settings: a set of settings to control the usage and specifics of the educational module. + *

+ * And many more settings are controlled within this class. + */ +public class BiographyTab { Campaign campaign; JFrame frame; String name; @@ -132,13 +152,13 @@ public class biographyTab { //end Rank Tab /** - * Initializes a new {@link biographyTab} with the specified campaign, frame, and name. + * Initializes a new {@link BiographyTab} with the specified campaign, frame, and name. * - * @param campaign the campaign associated with the {@link biographyTab} - * @param frame the {@link JFrame} used for displaying the {@link biographyTab} - * @param name the name of the {@link biographyTab} + * @param campaign the campaign associated with the {@link BiographyTab} + * @param frame the {@link JFrame} used for displaying the {@link BiographyTab} + * @param name the name of the {@link BiographyTab} */ - biographyTab(Campaign campaign, JFrame frame, String name) { + BiographyTab(Campaign campaign, JFrame frame, String name) { this.campaign = campaign; this.frame = frame; this.name = name; diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 3d66e44280..fabd2c5e40 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -121,7 +121,7 @@ private JTabbedPane createHumanResourcesParentTab() { "salariesTab", personnelTab.createSalariesTab())); // Biography - biographyTab biographyTab = new biographyTab(campaign, getFrame(), "biographyTab"); + BiographyTab biographyTab = new BiographyTab(campaign, getFrame(), "biographyTab"); JTabbedPane biographyContentTabs = createSubTabs(Map.of( "biographyGeneralTab", biographyTab.createGeneralTab(), From d0a393e0afb38b7c7616c161d6507ca3eaf9fd90 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 11 Oct 2024 13:44:08 -0500 Subject: [PATCH 051/117] Refactor and simplify campaign options UI components Refactored various campaign option tabs to use cleaner and more consistent styles. Eliminated HTML tags in labels, standardized panel creation methods, and integrated utility scaling methods where necessary. This improves readability, maintainability, and ensures UI scalability. --- .../NEWCampaignOptionsDialog.properties | 52 ++-- .../tabs/CampaignOptionsPane.java | 70 +++--- .../tabs/CampaignOptionsUtilities.java | 19 +- .../campaignOptions/tabs/GeneralTab.java | 11 +- .../tabs/RepairAndMaintenanceTab.java | 2 +- .../tabs/SuppliesAndAcquisitionTab.java | 230 +++++++++++++----- 6 files changed, 245 insertions(+), 139 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index e0f22e2c39..1bc81680d3 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -21,7 +21,7 @@ strategicOperationsParentTab.title=Strategic Operations ## General Tab Class # createGeneralTab -lblGeneral.text=Welcome, Commander +lblGeneral.text=Welcome, Commander lblGeneralBody.text=

"Mercenary life is freedom with a price.\
Every contract is a choice, but every choice comes with a consequence."\
- Captain Rex "Ironclad" Harper, Black Fang Company
@@ -52,7 +52,7 @@ maintenanceTab.border="I've yet to see a battle won by duct tape, but we've gott
- Commander Erik Drahn, Sunder Lance # createRepairTab -lblRepairTab.text=Repair Options +lblRepairTab.text=Repair Options lblRepairTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Nisl senectus neque sem maximus\ \ accumsan nibh curae dapibus. Asuspendisse ullamcorper aliquet aliquet pretium duis litora porttitor.\ \ Tristique ex per aptent cras augue mus suspendisse inceptos hac. Amet ultricies sem dui etiam justo.\ @@ -76,7 +76,7 @@ lblDestroyPartTarget.text=Equipment hit in battle survive on a lblDestroyPartTarget.tooltip=PLACEHOLDER # createMaintenanceTab -lblMaintenanceTab.text=Maintenance Options +lblMaintenanceTab.text=Maintenance Options lblMaintenanceTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Nisl senectus neque\ \ sem maximus accumsan nibh curae dapibus. Asuspendisse ullamcorper aliquet aliquet pretium duis\ \ litora porttitor.Tristique ex per aptent cras augue mus suspendisse inceptos hac. Amet ultricies\ @@ -119,7 +119,7 @@ planetaryAcquisitionTab.border="On a guerrilla contract, parts are as valuable a
- Lieutenant Jaxon "Jackpot" Hale, Horizon Raiders # createAcquisitionTab -lblAcquisitionTab.text=Acquisition Options +lblAcquisitionTab.text=Acquisition Options lblAcquisitionTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Tristique non elit\ \ potenti suscipit lobortis sollicitudin. Iaculis dis ultrices cursus litora iaculis. Commodo blandit\ \ penatibus vitae leo quisque lectus dictum. Duis conubia nisi aliquet phasellus risus nullam massa\ @@ -139,7 +139,7 @@ lblMaxAcquisitions.text=Max Acquisition Rolls per Period lblMaxAcquisitions.tooltip=PLACEHOLDER # createDeliveryTab -lblDeliveryTab.text=Delivery Options +lblDeliveryTab.text=Delivery Options lblDeliveryTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod varius congue\ \ rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam maximus. Morbi\ \ gravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat turpis semper\ @@ -159,7 +159,7 @@ transitUnitNamesWeeks.text=Weeks transitUnitNamesMonths.text=Months # createPlanetaryAcquisitionTab -lblPlanetaryAcquisitionTab.text=Planetary Acquisition Options +lblPlanetaryAcquisitionTab.text=Planetary Acquisition Options lblPlanetaryAcquisitionTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ @@ -199,7 +199,7 @@ TechLimitsTab.border="In a universe where we fight with the ghosts of a golden a
- Engineer Talia "Patch" Kessler, Stormhounds # createTechLimitsTab -lblTechLimitsTab.text=Tech Limit Options +lblTechLimitsTab.text=Tech Limit Options lblTechLimitsTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ @@ -270,7 +270,7 @@ salariesTab.border="A pilot's salary pays for more than just a 'mek - it pays fo
-Captain Valen "Hardline" Pierce, Black Talon Mercs # createGeneralTab -lblPersonnelGeneralTab.text=General Options +lblPersonnelGeneralTab.text=General Options lblPersonnelGeneralTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ @@ -308,7 +308,7 @@ lblUseRemovalExemptRetirees.text=Exempt Retirees lblUseRemovalExemptRetirees.tooltip=PLACEHOLDER # createPersonnelLogsTab -lblPersonnelLogsTab.text=Personnel Log Options +lblPersonnelLogsTab.text=Personnel Log Options lblPersonnelLogsTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ @@ -333,7 +333,7 @@ lblDisplayKillRecord.text=Expand Kill Log by Default lblDisplayKillRecord.tooltip=PLACEHOLDER # createPersonnelInformationTab -lblPersonnelInformation.text=Personnel Information Options +lblPersonnelInformation.text=Personnel Information Options lblPersonnelInformationBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ @@ -356,7 +356,7 @@ lblShowOriginFaction.text=Display Origin Faction lblShowOriginFaction.tooltip=PLACEHOLDER # createAdministratorsTab -lblAdministratorsTab.text=Administrator Options +lblAdministratorsTab.text=Administrator Options lblAdministratorsTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ @@ -373,7 +373,7 @@ lblAdminExperienceLevelIncludeScrounge.text=Scrounge Factored into Experience Le lblAdminExperienceLevelIncludeScrounge.tooltip=PLACEHOLDER # createAwardsTab -lblAwardsTab.text=Awards Options +lblAwardsTab.text=Awards Options lblAwardsTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ @@ -423,7 +423,7 @@ lblEnableMiscAwards.text=Misc lblEnableMiscAwards.tooltip=PLACEHOLDER # createPrisonersAndDependentsTab -lblPrisonersAndDependentsTab.text=Dependent & Prisoner Options +lblPrisonersAndDependentsTab.text=Dependent & Prisoner Options lblPrisonersAndDependentsTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ @@ -452,7 +452,7 @@ lblUseRandomDependentRemoval.text=Random Removal lblUseRandomDependentRemoval.tooltip=PLACEHOLDER # createMedicalTab -lblMedicalTab.text=Medical Options +lblMedicalTab.text=Medical Options lblMedicalTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ @@ -475,7 +475,7 @@ lblMaximumPatients.text=Beds per Doctor lblMaximumPatients.tooltip=PLACEHOLDER # createSalariesTab -lblSalariesTab.text=Salary Options +lblSalariesTab.text=Salary Options lblSalariesTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ @@ -547,7 +547,7 @@ rankTab.border="Rank isn't about authority - it's about responsibility. Every st
-Captain Maya "Wildcard" Hayes, Black Viper Squadron # createGeneralTab -lblBiographyGeneralTab.text=General Options +lblBiographyGeneralTab.text=General Options lblBiographyGeneralTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ @@ -575,7 +575,7 @@ lblAnnounceChildBirthdays.text=Always Announce 18th Birthdays lblAnnounceChildBirthdays.tooltip=PLACEHOLDER # createBackgroundsTab -lblBackgroundsTab.text=Background Options +lblBackgroundsTab.text=Background Options lblBackgroundsTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ @@ -615,7 +615,7 @@ lblExtraRandomOrigin.text=Extra Random Origins lblExtraRandomOrigin.tooltip=PLACEHOLDER # createDeathTab -lblDeathTab.text=Death Options +lblDeathTab.text=Death Options lblDeathTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ @@ -639,7 +639,7 @@ lblPercentageRandomDeathChance.tooltip=PLACEHOLDER lblDeathAgeGroupsPanel.text=Enable Death by Age Group # createEducationTab -lblEducationTab.text=Education Options +lblEducationTab.text=Education Options lblEducationTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ @@ -694,7 +694,7 @@ lblMilitaryAcademyAccidents.text=Military Accidents Chance: 1 in lblMilitaryAcademyAccidents.tooltip=PLACEHOLDER # createNameAndPortraitGenerationTab -lblNameAndPortraitGenerationTab.text=Name and Portrait Generation Options +lblNameAndPortraitGenerationTab.text=Name and Portrait Generation Options lblNameAndPortraitGenerationTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ @@ -714,7 +714,7 @@ lblAllPortraitsBox.text=All Roles lblNoPortraitsBox.text=No Roles # createRankTab -lblRankTab.text=Rank Systems +lblRankTab.text=Rank Systems lblRankTabBody.text=You can use the table here to assign ranks for your campaign. You can use one of\ \ the preset rank systems from the pull-down menu, or you can design your own by creating a custom\ \ rank system.\ @@ -745,7 +745,7 @@ fatigueTab.border="Fatigue doesn't just slow you down; it makes you sloppy. And
- Lieutenant Kayla "Quickdraw" Frost, Shadow Talon Mercs # createTurnoverTab -lblTurnoverTab.text=Turnover Options +lblTurnoverTab.text=Turnover Options lblTurnoverTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ @@ -840,7 +840,7 @@ lblManagementSkillPenalty.text=Unskilled Penalty lblManagementSkillPenalty.tooltip=PLACEHOLDER # createFatigueTab -lblFatigueTab.text=Fatigue Options +lblFatigueTab.text=Fatigue Options lblFatigueTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ @@ -879,7 +879,7 @@ procreationTab.border="In this galaxy, raising kids is tougher than raising a la
- Captain Dani "Ironheart" Cole, Steel Talon Company # createMarriageTab -lblMarriageTab.text=Marriage Options +lblMarriageTab.text=Marriage Options lblMarriageTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ @@ -920,7 +920,7 @@ lblRandomNewDependentMarriage.text=Inter-Unit Marriage Chance: 1 in lblRandomNewDependentMarriage.tooltip=PLACEHOLDER # createDivorceTab -lblDivorceTab.text=Divorce Options +lblDivorceTab.text=Divorce Options lblDivorceTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ @@ -950,7 +950,7 @@ lblRandomDivorceDiceSize.text=Random Divorce Chance: 1 in lblRandomDivorceDiceSize.tooltip=PLACEHOLDER # createProcreationTab -lblProcreationTab.text=Procreation Options +lblProcreationTab.text=Procreation Options lblProcreationTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index fabd2c5e40..38e7075b55 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -7,8 +7,8 @@ import javax.swing.*; import java.util.Map; import java.util.ResourceBundle; -import java.util.function.Supplier; +import static java.lang.Math.round; import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.createSubTabs; public class CampaignOptionsPane extends AbstractMHQTabbedPane { @@ -16,6 +16,8 @@ public class CampaignOptionsPane extends AbstractMHQTabbedPane { private static final String RESOURCE_PACKAGE = "mekhq/resources/NEWCampaignOptionsDialog"; private static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE); + private static final int SCROLL_SPEED = 16; + private final Campaign campaign; public CampaignOptionsPane(final JFrame frame, final Campaign campaign) { @@ -27,48 +29,39 @@ public CampaignOptionsPane(final JFrame frame, final Campaign campaign) { @Override protected void initialize() { - // General - addTab(String.format("%s", 5, - resources.getString("generalPanel.title")), createGeneralTab()); - - // Combat Readiness - createTab("combatReadinessParentTab", this::createCombatReadinessParentTab); + int fontSize = 5; + double uiScale = Double.parseDouble(System.getProperty("flatlaf.uiScale")); - // Human Resources - createTab("humanResourcesParentTab", this::createHumanResourcesParentTab); - - // Unit Development - createTab("unitDevelopmentParentTab", this::createUnitDevelopmentParentTab); - - // Logistics and Maintenance - createTab("logisticsAndMaintenanceParentTab", this::createLogisticsAndMaintenanceParentTab); + addTab(String.format("%s", round(fontSize * uiScale), + resources.getString("generalPanel.title")), createGeneralTab()); - // Strategic Operations - createTab("strategicOperationsParentTab", this::createStrategicOperationsParentTab); + createTab("combatReadinessParentTab", createCombatReadinessParentTab()); + createTab("humanResourcesParentTab", createHumanResourcesParentTab()); + createTab("unitDevelopmentParentTab", createUnitDevelopmentParentTab()); + createTab("logisticsAndMaintenanceParentTab", createLogisticsAndMaintenanceParentTab()); + createTab("strategicOperationsParentTab", createStrategicOperationsParentTab()); } /** * Creates a tab and adds it to the TabbedPane. * * @param resourceName the name of the resource used to create the tab's title - * @param tabCreator a supplier that creates the TabbedPane for the tab + * @param tab the tab to be added */ - private void createTab(String resourceName, Supplier tabCreator) { - JTabbedPane createdTab = tabCreator.get(); - - JScrollPane tabScrollPane = new JScrollPane(createdTab, + private void createTab(String resourceName, JTabbedPane tab) { + JScrollPane tabScrollPane = new JScrollPane(tab, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - // Increase vertical scroll speed - int verticalScrollSpeed = 20; - tabScrollPane.getVerticalScrollBar().setUnitIncrement(verticalScrollSpeed); + // Increase scroll speed + tabScrollPane.getVerticalScrollBar().setUnitIncrement(SCROLL_SPEED); + tabScrollPane.getHorizontalScrollBar().setUnitIncrement(SCROLL_SPEED); - // Increase horizontal scroll speed - int horizontalScrollSpeed = 20; - tabScrollPane.getHorizontalScrollBar().setUnitIncrement(horizontalScrollSpeed); + // Dynamically adjust font size based on the GUI scale + int fontSize = 5; + double uiScale = Double.parseDouble(System.getProperty("flatlaf.uiScale")); - addTab(String.format("%s", 5, + addTab(String.format("%s", round(fontSize * uiScale), resources.getString(resourceName + ".title")), tabScrollPane); } @@ -103,6 +96,16 @@ private JTabbedPane createCombatReadinessParentTab() { return combatReadinessParentTab; } + /** + * The `createHumanResourcesParentTab` method creates and returns a `JTabbedPane` object, + * which represents the overarching "Human Resources" tab in the user interface. + *

+ * Under the "Human Resources" tab, there are several sub-tabs for different categories, including + * Personnel, Biography, Relationships, and Turnover and Retention. Each sub-tab contains various + * settings related to its category. + * + * @return JTabbedPane representing the "Human Resources" tab. + */ private JTabbedPane createHumanResourcesParentTab() { // Parent Tab JTabbedPane humanResourcesParentTab = new JTabbedPane(); @@ -147,10 +150,6 @@ private JTabbedPane createHumanResourcesParentTab() { "turnoverTab", turnoverAndRetentionTab.createTurnoverTab(), "fatigueTab", turnoverAndRetentionTab.createFatigueTab())); - // Name and Portrait Generation - - // Rank Systems - // Add Tabs humanResourcesParentTab.addTab(String.format("%s", 4, resources.getString("personnelContentTabs.title")), personnelContentTabs); @@ -180,9 +179,10 @@ private JTabbedPane createUnitDevelopmentParentTab() { } /** - * Creates the Logistics and Maintenance parent tab for the Campaign Options Pane. + * This `createLogisticsAndMaintenanceParentTab` method creates and returns a `JTabbedPane` object. + * This represents the "Logistics and Maintenance" parent tab in the user interface. * - * @return the created {@link JTabbedPane} representing the Logistics and Maintenance parent tab + * @return JTabbedPane representing the "Logistics and Maintenance" tab. */ private JTabbedPane createLogisticsAndMaintenanceParentTab() { // Parent Tab diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index 0950e4d6ab..ca38828045 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -1,7 +1,10 @@ package mekhq.gui.panes.campaignOptions.tabs; +import megamek.client.ui.swing.util.FlatLafStyleBuilder; +import megamek.client.ui.swing.util.UIUtil; import megamek.common.annotations.Nullable; import megamek.logging.MMLogger; +import mekhq.MHQConstants; import javax.swing.*; import javax.swing.GroupLayout.Alignment; @@ -191,8 +194,8 @@ static JPanel createStandardPanel(String name, boolean includeBorder, String bor sizeWidth += component.getPreferredSize().width; } - if (sizeWidth < 750) { - sizeWidth = 750; + if (sizeWidth < UIUtil.scaleForGUI(750)) { + sizeWidth = UIUtil.scaleForGUI(750); } panel.setMaximumSize(new Dimension(sizeWidth, sizeHeight)); @@ -221,8 +224,8 @@ static JPanel createHeaderPanel(String name, String imageAddress, boolean includ ImageIcon imageIcon = new ImageIcon(imageAddress); JLabel imageLabel = new JLabel(imageIcon); - final JLabel lblHeader = new JLabel(String.format("%s", - resources.getString("lbl" + name + ".text")), SwingConstants.CENTER); + final JLabel lblHeader = new JLabel(resources.getString("lbl" + name + ".text"), SwingConstants.CENTER); + new FlatLafStyleBuilder().font(MHQConstants.PROJECT_NAME).bold().size(3).apply(lblHeader); lblHeader.setName("lbl" + name); JLabel lblBody = new JLabel(); @@ -231,12 +234,12 @@ static JPanel createHeaderPanel(String name, String imageAddress, boolean includ resources.getString("lbl" + name + "Body.text")), SwingConstants.CENTER); lblBody.setName("lbl" + name + "Body"); Dimension size = lblBody.getPreferredSize(); - lblBody.setMaximumSize(new Dimension(750, size.height)); + lblBody.setMaximumSize(new Dimension(UIUtil.scaleForGUI(750), size.height)); } final JPanel panel = createStandardPanel("pnl" + name + "HeaderPanel", includeBorder, borderTitle); Dimension size = panel.getPreferredSize(); - panel.setPreferredSize(new Dimension(750, size.height)); + panel.setPreferredSize(new Dimension(UIUtil.scaleForGUI(750), size.height)); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -287,8 +290,8 @@ static JPanel createParentPanel(JPanel panel, String name) { // Set Dimensions int widthNew = parentPanel.getMinimumSize().width; - if (widthNew < 750) { - widthNew = 750; + if (widthNew < UIUtil.scaleForGUI(750)) { + widthNew = UIUtil.scaleForGUI(750); } // I don't know why 1.25 works, it just does, and I've given up questioning it. diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java index 5f8c70a213..b4589ce083 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java @@ -2,8 +2,11 @@ import megamek.client.ui.baseComponents.MMComboBox; import megamek.client.ui.dialogs.CamoChooserDialog; +import megamek.client.ui.swing.util.FlatLafStyleBuilder; +import megamek.client.ui.swing.util.UIUtil; import megamek.common.annotations.Nullable; import megamek.common.icons.Camouflage; +import mekhq.MHQConstants; import mekhq.MekHQ; import mekhq.campaign.Campaign; import mekhq.campaign.icons.StandardForceIcon; @@ -206,15 +209,15 @@ private static JPanel createGeneralHeader() { ImageIcon imageIcon = new ImageIcon("data/images/misc/MekHQ.png"); JLabel imageLabel = new JLabel(imageIcon); - final JLabel lblHeader = new JLabel(String.format("%s", - resources.getString("lblGeneral.text")), SwingConstants.CENTER); + final JLabel lblHeader = new JLabel(resources.getString("lblGeneral.text"), SwingConstants.CENTER); + new FlatLafStyleBuilder().font(MHQConstants.PROJECT_NAME).bold().size(3).apply(lblHeader); lblHeader.setName("lblGeneral"); JLabel lblBody = new JLabel(String.format("%s", resources.getString("lblGeneralBody.text")), SwingConstants.CENTER); lblBody.setName("lblGeneralHeaderBody"); Dimension size = lblBody.getPreferredSize(); - lblBody.setMaximumSize(new Dimension(750, size.height)); + lblBody.setMaximumSize(new Dimension(UIUtil.scaleForGUI(750), size.height)); final JPanel panel = createStandardPanel("pnlGeneralHeaderPanel", false, ""); final GroupLayout layout = createStandardLayout(panel); @@ -225,7 +228,7 @@ private static JPanel createGeneralHeader() { .addComponent(lblHeader) .addComponent(imageLabel) .addComponent(lblBody) - .addGap(20)); + .addGap(UIUtil.scaleForGUI(20))); layout.setHorizontalGroup( layout.createParallelGroup(Alignment.CENTER) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java index 43d3d205d7..265c91ecde 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java @@ -145,7 +145,7 @@ JPanel createRepairTab() { lblDestroyPartTarget = createLabel("DestroyPartTarget", null); spnDestroyPartTarget = createSpinner("DestroyPartTarget", null, 2, 2, 13, 1); - JLabel lblDestroyPartTargetPost = new JLabel("+"); + JLabel lblDestroyPartTargetPost = new JLabel("+"); // Layout the Panel final JPanel panel = createStandardPanel("repairTab", true, ""); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java index 65296d0892..2dfd43f7b7 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java @@ -66,10 +66,16 @@ public class SuppliesAndAcquisitionTab { private JLabel lblPenaltyClanPartsFromIS; private JSpinner spnPenaltyClanPartsFromIS; private JCheckBox usePlanetaryAcquisitionsVerbose; + + private JPanel pnlTechModifiers; private JLabel[] lblPlanetAcquireTechBonus; private JSpinner[] spnPlanetAcquireTechBonus; + + private JPanel pnlIndustryModifiers; private JLabel[] lblPlanetAcquireIndustryBonus; private JSpinner[] spnPlanetAcquireIndustryBonus; + + private JPanel pnlOutputModifiers; private JLabel[] lblPlanetAcquireOutputBonus; private JSpinner[] spnPlanetAcquireOutputBonus; //end Planetary Acquisition Tab @@ -115,12 +121,15 @@ private void initializePlanetaryAcquisitionsTab() { usePlanetaryAcquisitionsVerbose = new JCheckBox(); // Modifiers + pnlTechModifiers = new JPanel(); lblPlanetAcquireTechBonus = new JLabel[6]; spnPlanetAcquireTechBonus = new JSpinner[6]; + pnlIndustryModifiers = new JPanel(); lblPlanetAcquireIndustryBonus = new JLabel[6]; spnPlanetAcquireIndustryBonus = new JSpinner[6]; + pnlOutputModifiers = new JPanel(); lblPlanetAcquireOutputBonus = new JLabel[6]; spnPlanetAcquireOutputBonus = new JSpinner[6]; } @@ -375,33 +384,34 @@ private JPanel createOptionsPanel() { * @return the created tab panel as a {@link JPanel} */ private JPanel createModifiersPanel() { - JLabel techLabel = createLabel("TechLabel", null); - JLabel industryLabel = createLabel("IndustryLabel", null); - JLabel outputLabel = createLabel("OutputLabel", null); - // Modifier Spinners for (int i = EquipmentType.RATING_A; i <= EquipmentType.RATING_F; i++) { String modifierLabel = getModifierLabel(i); - lblPlanetAcquireTechBonus[i] = new JLabel(String.format("%s", + lblPlanetAcquireTechBonus[i] = new JLabel(String.format("%s", modifierLabel)); spnPlanetAcquireTechBonus[i] = new JSpinner(new SpinnerNumberModel( 0, -12, 12, 1)); setSpinnerWidth(spnPlanetAcquireTechBonus[i]); - lblPlanetAcquireIndustryBonus[i] = new JLabel(String.format("%s", + lblPlanetAcquireIndustryBonus[i] = new JLabel(String.format("%s", modifierLabel)); spnPlanetAcquireIndustryBonus[i] = new JSpinner(new SpinnerNumberModel( 0, -12, 12, 1)); setSpinnerWidth(spnPlanetAcquireIndustryBonus[i]); - lblPlanetAcquireOutputBonus[i] = new JLabel(String.format("%s", + lblPlanetAcquireOutputBonus[i] = new JLabel(String.format("%s", modifierLabel)); spnPlanetAcquireOutputBonus[i] = new JSpinner(new SpinnerNumberModel( 0, -12, 12, 1)); setSpinnerWidth(spnPlanetAcquireOutputBonus[i]); } + // Panels + pnlIndustryModifiers = createIndustryModifiersPanel(); + pnlTechModifiers = createTechModifiersPanel(); + pnlOutputModifiers = createOutputModifiersPanel(); + // Layout the Panel final JPanel panel = createStandardPanel("PlanetaryAcquisitionTabModifiers", true, "ModifiersPanel"); @@ -411,103 +421,193 @@ private JPanel createModifiersPanel() { layout.setVerticalGroup( layout.createSequentialGroup() .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(techLabel) - .addComponent(industryLabel) - .addComponent(outputLabel)) - // There has to be a better way of doing this, but I couldn't fathom it + .addComponent(pnlIndustryModifiers) + .addComponent(pnlTechModifiers) + .addComponent(pnlOutputModifiers))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(pnlIndustryModifiers) + .addComponent(pnlTechModifiers) + .addComponent(pnlOutputModifiers) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + return panel; + } + + /** + * Creates the planetary acquisition modifiers panel. + * + * @return the created tab panel as a {@link JPanel} + */ + private JPanel createTechModifiersPanel() { + JLabel techLabel = createLabel("TechLabel", null); + techLabel.setName(String.format("

%s
%s
%s
Date: Fri, 11 Oct 2024 13:50:35 -0500 Subject: [PATCH 052/117] Remove unnecessary comments and simplify JScrollPane usage Removed a non-informative comment from CampaignOptionsUtilities.java for cleaner code. Simplified JScrollPane constructor usage in CampaignOptionsPane.java by using default scrollbar policy. --- .../panes/campaignOptions/tabs/CampaignOptionsPane.java | 8 ++------ .../campaignOptions/tabs/CampaignOptionsUtilities.java | 1 - 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 38e7075b55..381386ab4d 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -49,9 +49,7 @@ protected void initialize() { * @param tab the tab to be added */ private void createTab(String resourceName, JTabbedPane tab) { - JScrollPane tabScrollPane = new JScrollPane(tab, - JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, - JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + JScrollPane tabScrollPane = new JScrollPane(tab); // Increase scroll speed tabScrollPane.getVerticalScrollBar().setUnitIncrement(SCROLL_SPEED); @@ -74,9 +72,7 @@ private JScrollPane createGeneralTab() { GeneralTab generalTab = new GeneralTab(campaign, getFrame(), "generalTab"); JPanel createdGeneralTab = generalTab.createGeneralTab(); - return new JScrollPane(createdGeneralTab, - JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, - JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + return new JScrollPane(createdGeneralTab); } private JTabbedPane createCombatReadinessParentTab() { diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index ca38828045..2f62d8759f 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -294,7 +294,6 @@ static JPanel createParentPanel(JPanel panel, String name) { widthNew = UIUtil.scaleForGUI(750); } - // I don't know why 1.25 works, it just does, and I've given up questioning it. int height = parentPanel.getPreferredSize().height; for (Component component : panel.getComponents()) { if (component instanceof JPanel) { From def629d95316eb4b6c38b8fd2fdae36f0cd5d550 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 11 Oct 2024 13:56:53 -0500 Subject: [PATCH 053/117] Fix component alignment in SuppliesAndAcquisitionTab Corrected the order of combo and label components to ensure proper alignment in the UI layout. This change enhances the readability and consistency of the user interface. --- .../campaignOptions/tabs/SuppliesAndAcquisitionTab.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java index 2dfd43f7b7..48a1389da3 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java @@ -346,8 +346,8 @@ private JPanel createOptionsPanel() { .addComponent(spnMaxJumpPlanetaryAcquisitions) .addComponent(lblMaxJumpPlanetaryAcquisitions)) .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(comboPlanetaryAcquisitionsFactionLimits) - .addComponent(lblPlanetaryAcquisitionsFactionLimits)) + .addComponent(lblPlanetaryAcquisitionsFactionLimits) + .addComponent(comboPlanetaryAcquisitionsFactionLimits)) .addComponent(disallowPlanetaryAcquisitionClanCrossover) .addComponent(disallowClanPartsFromIS) .addGroup(layout.createParallelGroup(Alignment.BASELINE) @@ -364,8 +364,8 @@ private JPanel createOptionsPanel() { .addComponent(spnMaxJumpPlanetaryAcquisitions) .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() - .addComponent(comboPlanetaryAcquisitionsFactionLimits) .addComponent(lblPlanetaryAcquisitionsFactionLimits) + .addComponent(comboPlanetaryAcquisitionsFactionLimits) .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) .addComponent(disallowPlanetaryAcquisitionClanCrossover) .addComponent(disallowClanPartsFromIS) From 8af5dec3c8d5ad652d7e1bec5b1f0eddb228c831 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 11 Oct 2024 14:31:37 -0500 Subject: [PATCH 054/117] Refactored font size initialization and added error handling Simplified the font size initialization by using a constant and added error handling for missing UI scale property. This ensures consistent font size usage across tabs and improves code readability and robustness. --- .../tabs/CampaignOptionsPane.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 381386ab4d..d9f1fceb04 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -17,6 +17,7 @@ public class CampaignOptionsPane extends AbstractMHQTabbedPane { private static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE); private static final int SCROLL_SPEED = 16; + private static final int HEADER_FONT_SIZE = 5; private final Campaign campaign; @@ -29,10 +30,12 @@ public CampaignOptionsPane(final JFrame frame, final Campaign campaign) { @Override protected void initialize() { - int fontSize = 5; - double uiScale = Double.parseDouble(System.getProperty("flatlaf.uiScale")); + double uiScale = 1; + try { + uiScale = Double.parseDouble(System.getProperty("flatlaf.uiScale")); + } catch (Exception ignored) {} - addTab(String.format("%s", round(fontSize * uiScale), + addTab(String.format("%s", round(HEADER_FONT_SIZE * uiScale), resources.getString("generalPanel.title")), createGeneralTab()); createTab("combatReadinessParentTab", createCombatReadinessParentTab()); @@ -56,10 +59,13 @@ private void createTab(String resourceName, JTabbedPane tab) { tabScrollPane.getHorizontalScrollBar().setUnitIncrement(SCROLL_SPEED); // Dynamically adjust font size based on the GUI scale - int fontSize = 5; - double uiScale = Double.parseDouble(System.getProperty("flatlaf.uiScale")); + double uiScale = 1; + try { + uiScale = Double.parseDouble(System.getProperty("flatlaf.uiScale")); + } catch (Exception ignored) {} - addTab(String.format("%s", round(fontSize * uiScale), + addTab(String.format("%s", + round(HEADER_FONT_SIZE * uiScale), resources.getString(resourceName + ".title")), tabScrollPane); } From 48729791e5bb0614201306c2afdbeb15dd11a820 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 11 Oct 2024 15:09:06 -0500 Subject: [PATCH 055/117] Refactor tab and class names for consistency Renamed several parent and content tabs to align with new naming conventions for better clarity and maintainability. Adjusted class names and method calls accordingly, ensuring application consistency and code readability. --- .../NEWCampaignOptionsDialog.properties | 19 ++++--- .../tabs/CampaignOptionsPane.java | 49 ++++++++----------- ...nTab.java => EquipmentAndSuppliesTab.java} | 4 +- .../{TechLimitsTab.java => EquipmentTab.java} | 39 ++------------- 4 files changed, 38 insertions(+), 73 deletions(-) rename MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/{SuppliesAndAcquisitionTab.java => EquipmentAndSuppliesTab.java} (99%) rename MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/{TechLimitsTab.java => EquipmentTab.java} (82%) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 1bc81680d3..cc6b7ddcb6 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -12,10 +12,9 @@ presetDialogCancel.tooltip=Return to the prior screen. ## Campaign Options Pane generalPanel.title=General Information -combatReadinessParentTab.title=Combat Readiness humanResourcesParentTab.title=Human Resources unitDevelopmentParentTab.title=Unit Development -logisticsAndMaintenanceParentTab.title=Logistics and Maintenance +logisticsAndMaintenanceParentTab.title=Equipment and Supplies strategicOperationsParentTab.title=Strategic Operations @@ -43,10 +42,12 @@ lblIcon.text=Unit Insignia lblIcon.tooltip=PLACEHOLDER ## RepairAndMaintenanceTab -repairAndMaintenanceContentTabs.title=Repairs and Maintenance +repairsAndMaintenanceContentTabs.title=Maintenance & Repairs + repairTab.title=Repairs repairTab.border="Sure, I can fix it. But next time, maybe don't play chicken with an Atlas."\
- Chief Tech Mara "Wrench" Kell, Black Hammer Company + maintenanceTab.title=Maintenance maintenanceTab.border="I've yet to see a battle won by duct tape, but we've gotten pretty close."\
- Commander Erik Drahn, Sunder Lance @@ -105,14 +106,17 @@ lblLogMaintenance.tooltip=PLACEHOLDER ## SuppliesAndAcquisitionTab suppliesAndAcquisitionTab.title=Supplies and Acquisition + acquisitionTab.title=Acquisitions acquisitionTab.border="It's not about what you need - it's about what you can get. In acquisitions,\ \ creativity beats C-Bills."\
- Quartermaster Jonas "Scrounger" Voss, Red Talon Mercenaries + deliveryTab.title=Deliveries deliveryTab.border="Every part I deliver is a promise that a mek will rise again. Speed is my weapon,\ \ and time is the enemy."\
- Captain Horace "Hot Wheels" Drake, Midnight Express + planetaryAcquisitionTab.title=Planetary Acquisitions planetaryAcquisitionTab.border="On a guerrilla contract, parts are as valuable as ammo. Get what you\ \ can, while you can, because tomorrow, it might be gone."\ @@ -192,12 +196,15 @@ lblIndustryLabel.tooltip=PLACEHOLDER lblOutputLabel.text=Output lblOutputLabel.tooltip=PLACEHOLDER -## Tech Limits Tab -TechLimitsParentTab.title=Tech Limits -TechLimitsTab.border="In a universe where we fight with the ghosts of a golden age, technology is a\ +# Equipment Tab +equipmentContentTabs.title=Equipment + +techLimitsTab.title=Tech Limits +techLimitsTab.border="In a universe where we fight with the ghosts of a golden age, technology is a\ \ reminder: we are bound by history, but not defined by it."\
- Engineer Talia "Patch" Kessler, Stormhounds + # createTechLimitsTab lblTechLimitsTab.text=Tech Limit Options lblTechLimitsTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index d9f1fceb04..19411157a7 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -38,10 +38,9 @@ protected void initialize() { addTab(String.format("%s", round(HEADER_FONT_SIZE * uiScale), resources.getString("generalPanel.title")), createGeneralTab()); - createTab("combatReadinessParentTab", createCombatReadinessParentTab()); createTab("humanResourcesParentTab", createHumanResourcesParentTab()); createTab("unitDevelopmentParentTab", createUnitDevelopmentParentTab()); - createTab("logisticsAndMaintenanceParentTab", createLogisticsAndMaintenanceParentTab()); + createTab("logisticsAndMaintenanceParentTab", createEquipmentAndSuppliesParentTab()); createTab("strategicOperationsParentTab", createStrategicOperationsParentTab()); } @@ -81,23 +80,6 @@ private JScrollPane createGeneralTab() { return new JScrollPane(createdGeneralTab); } - private JTabbedPane createCombatReadinessParentTab() { - // Tech Limits - // Random Assignment Tables - // Rulesets - - // Parent Tab - JTabbedPane combatReadinessParentTab = new JTabbedPane(); - - TechLimitsTab techLimitsTab = new TechLimitsTab(getFrame(), - "techLimitsTab"); - - combatReadinessParentTab.addTab(String.format("%s", 4, - resources.getString("TechLimitsParentTab.title")), techLimitsTab.createTechLimitsTab()); - - return combatReadinessParentTab; - } - /** * The `createHumanResourcesParentTab` method creates and returns a `JTabbedPane` object, * which represents the overarching "Human Resources" tab in the user interface. @@ -181,25 +163,25 @@ private JTabbedPane createUnitDevelopmentParentTab() { } /** - * This `createLogisticsAndMaintenanceParentTab` method creates and returns a `JTabbedPane` object. + * This `createEquipmentAndSuppliesParentTab` method creates and returns a `JTabbedPane` object. * This represents the "Logistics and Maintenance" parent tab in the user interface. * * @return JTabbedPane representing the "Logistics and Maintenance" tab. */ - private JTabbedPane createLogisticsAndMaintenanceParentTab() { + private JTabbedPane createEquipmentAndSuppliesParentTab() { // Parent Tab - JTabbedPane logisticsAndMaintenanceParentTab = new JTabbedPane(); + JTabbedPane equipmentAndSuppliesParentTab = new JTabbedPane(); // Repair and Maintenance RepairAndMaintenanceTab repairAndMaintenanceTab = new RepairAndMaintenanceTab(getFrame(), "repairAndMaintenanceTab"); - JTabbedPane repairAndMaintenanceContentTabs = createSubTabs(Map.of( + JTabbedPane repairsAndMaintenanceContentTabs = createSubTabs(Map.of( "repairTab", repairAndMaintenanceTab.createRepairTab(), "maintenanceTab", repairAndMaintenanceTab.createMaintenanceTab())); // Supplies and Acquisition - SuppliesAndAcquisitionTab suppliesAndAcquisitionTab = new SuppliesAndAcquisitionTab(getFrame(), + EquipmentAndSuppliesTab suppliesAndAcquisitionTab = new EquipmentAndSuppliesTab(getFrame(), "suppliesAndAcquisitionTab"); JTabbedPane suppliesAndAcquisitionContentTabs = createSubTabs(Map.of( @@ -207,22 +189,31 @@ private JTabbedPane createLogisticsAndMaintenanceParentTab() { "deliveryTab", suppliesAndAcquisitionTab.createDeliveryTab(), "planetaryAcquisitionTab", suppliesAndAcquisitionTab.createPlanetaryAcquisitionTab())); + // Equipment + EquipmentTab equipmentTab = new EquipmentTab(getFrame(), "equipmentTab"); + + JTabbedPane equipmentContentTabs = createSubTabs(Map.of( + "techLimitsTab", equipmentTab.createTechLimitsTab())); + // Add tabs - logisticsAndMaintenanceParentTab.addTab(String.format("%s", 4, + equipmentAndSuppliesParentTab.addTab(String.format("%s", 4, resources.getString("suppliesAndAcquisitionTab.title")), suppliesAndAcquisitionContentTabs); - logisticsAndMaintenanceParentTab.addTab(String.format("%s", 4, - resources.getString("repairAndMaintenanceContentTabs.title")), repairAndMaintenanceContentTabs); + equipmentAndSuppliesParentTab.addTab(String.format("%s", 4, + resources.getString("repairsAndMaintenanceContentTabs.title")), repairsAndMaintenanceContentTabs); + equipmentAndSuppliesParentTab.addTab(String.format("%s", 4, + resources.getString("equipmentContentTabs.title")), equipmentContentTabs); addTab(String.format("%s", 4, - resources.getString("logisticsAndMaintenanceParentTab.title")), logisticsAndMaintenanceParentTab); + resources.getString("logisticsAndMaintenanceParentTab.title")), equipmentAndSuppliesParentTab); - return logisticsAndMaintenanceParentTab; + return equipmentAndSuppliesParentTab; } private JTabbedPane createStrategicOperationsParentTab() { // Finances // Mercenary // Markets + // Rulesets // Parent Tab JTabbedPane strategicOperationsParentTab = new JTabbedPane(); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java similarity index 99% rename from MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java rename to MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java index 48a1389da3..775a280a6c 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SuppliesAndAcquisitionTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java @@ -14,7 +14,7 @@ import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; -public class SuppliesAndAcquisitionTab { +public class EquipmentAndSuppliesTab { // region Variable Declarations private static String RESOURCE_PACKAGE = "mekhq/resources/NEWCampaignOptionsDialog"; private static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE, @@ -80,7 +80,7 @@ public class SuppliesAndAcquisitionTab { private JSpinner[] spnPlanetAcquireOutputBonus; //end Planetary Acquisition Tab - public SuppliesAndAcquisitionTab(JFrame frame, String name) { + public EquipmentAndSuppliesTab(JFrame frame, String name) { this.frame = frame; this.name = name; diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentTab.java similarity index 82% rename from MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java rename to MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentTab.java index f85cd5c5cc..3bfa1c1e08 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TechLimitsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentTab.java @@ -5,11 +5,10 @@ import javax.swing.*; import javax.swing.GroupLayout.Alignment; -import java.awt.*; import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; -public class TechLimitsTab { +public class EquipmentTab { JFrame frame; String name; @@ -32,7 +31,7 @@ public class TechLimitsTab { //start Rulesets Tab //end Rulesets Tab - public TechLimitsTab(JFrame frame, String name) { + public EquipmentTab(JFrame frame, String name) { this.frame = frame; this.name = name; @@ -45,7 +44,6 @@ public TechLimitsTab(JFrame frame, String name) { void initialize() { initializeTechLimitsTab(); initializeRandomAssignmentTablesTab(); - initializeCustomRulesetsTab(); } /** @@ -72,13 +70,6 @@ private void initializeTechLimitsTab() { private void initializeRandomAssignmentTablesTab() { } - /** - * Initializes the components of the CustomRulesetsTab. - * This panel would typically contain controls related to custom rulesets. - */ - private void initializeCustomRulesetsTab() { - } - /** * Creates a {@link JPanel} representing the tech limits tab. * This method constructs various components including checkboxes, labels, and combo boxes @@ -153,31 +144,7 @@ JPanel createTechLimitsTab() { .addComponent(useAmmoByTypeBox)); // Create Parent Panel and return - JPanel parentPanel = createParentPanel(panel, "TechLimitsTab"); - - // Create a panel for the quote - JPanel quotePanel = new JPanel(); - JLabel quote = new JLabel(String.format("
%s
", - resources.getString("TechLimitsTab.border"))); - quotePanel.add(parentPanel); - quotePanel.add(quote); - - // Reorganize mainPanel to include quotePanel at bottom - JPanel contentPanel = new JPanel(new BorderLayout()); - contentPanel.setName("TechLimitsTab"); - contentPanel.add(parentPanel, BorderLayout.CENTER); - contentPanel.add(quotePanel, BorderLayout.SOUTH); - - // Create a wrapper panel for its easy alignment controls - JPanel wrapperPanel = new JPanel(new GridBagLayout()); - GridBagConstraints gbc = new GridBagConstraints(); - gbc.anchor = GridBagConstraints.NORTH; - gbc.weightx = 1.0; - gbc.weighty = 1.0; - - wrapperPanel.add(contentPanel, gbc); - - return wrapperPanel; + return createParentPanel(panel, "TechLimitsTab"); } /** From fc98d5bc27d62177148b2c40817a9a13fba001f2 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 11 Oct 2024 15:14:33 -0500 Subject: [PATCH 056/117] Merge EquipmentTab into EquipmentAndSuppliesTab Consolidated the functionality of EquipmentTab into EquipmentAndSuppliesTab and removed the obsolete EquipmentTab class. This simplifies the structure and reduces redundancy by having all related settings under a single tab. --- .../NEWCampaignOptionsDialog.properties | 14 +- .../tabs/CampaignOptionsPane.java | 11 +- .../tabs/EquipmentAndSuppliesTab.java | 122 +++++++++++++ .../campaignOptions/tabs/EquipmentTab.java | 164 ------------------ 4 files changed, 129 insertions(+), 182 deletions(-) delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentTab.java diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index cc6b7ddcb6..4b97cee02a 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -122,6 +122,11 @@ planetaryAcquisitionTab.border="On a guerrilla contract, parts are as valuable a \ can, while you can, because tomorrow, it might be gone."\
- Lieutenant Jaxon "Jackpot" Hale, Horizon Raiders +techLimitsTab.title=Tech Limits +techLimitsTab.border="In a universe where we fight with the ghosts of a golden age, technology is a\ + \ reminder: we are bound by history, but not defined by it."\ +
- Engineer Talia "Patch" Kessler, Stormhounds + # createAcquisitionTab lblAcquisitionTab.text=Acquisition Options lblAcquisitionTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Tristique non elit\ @@ -196,15 +201,6 @@ lblIndustryLabel.tooltip=PLACEHOLDER lblOutputLabel.text=Output lblOutputLabel.tooltip=PLACEHOLDER -# Equipment Tab -equipmentContentTabs.title=Equipment - -techLimitsTab.title=Tech Limits -techLimitsTab.border="In a universe where we fight with the ghosts of a golden age, technology is a\ - \ reminder: we are bound by history, but not defined by it."\ -
- Engineer Talia "Patch" Kessler, Stormhounds - - # createTechLimitsTab lblTechLimitsTab.text=Tech Limit Options lblTechLimitsTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 19411157a7..91a8808aad 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -187,21 +187,14 @@ private JTabbedPane createEquipmentAndSuppliesParentTab() { JTabbedPane suppliesAndAcquisitionContentTabs = createSubTabs(Map.of( "acquisitionTab", suppliesAndAcquisitionTab.createAcquisitionTab(), "deliveryTab", suppliesAndAcquisitionTab.createDeliveryTab(), - "planetaryAcquisitionTab", suppliesAndAcquisitionTab.createPlanetaryAcquisitionTab())); - - // Equipment - EquipmentTab equipmentTab = new EquipmentTab(getFrame(), "equipmentTab"); - - JTabbedPane equipmentContentTabs = createSubTabs(Map.of( - "techLimitsTab", equipmentTab.createTechLimitsTab())); + "planetaryAcquisitionTab", suppliesAndAcquisitionTab.createPlanetaryAcquisitionTab(), + "techLimitsTab", suppliesAndAcquisitionTab.createTechLimitsTab())); // Add tabs equipmentAndSuppliesParentTab.addTab(String.format("%s", 4, resources.getString("suppliesAndAcquisitionTab.title")), suppliesAndAcquisitionContentTabs); equipmentAndSuppliesParentTab.addTab(String.format("%s", 4, resources.getString("repairsAndMaintenanceContentTabs.title")), repairsAndMaintenanceContentTabs); - equipmentAndSuppliesParentTab.addTab(String.format("%s", 4, - resources.getString("equipmentContentTabs.title")), equipmentContentTabs); addTab(String.format("%s", 4, resources.getString("logisticsAndMaintenanceParentTab.title")), equipmentAndSuppliesParentTab); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java index 775a280a6c..7f41a90b04 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java @@ -80,6 +80,19 @@ public class EquipmentAndSuppliesTab { private JSpinner[] spnPlanetAcquireOutputBonus; //end Planetary Acquisition Tab + //start Tech Limits Tab + private JCheckBox limitByYearBox; + private JCheckBox disallowExtinctStuffBox; + private JCheckBox allowClanPurchasesBox; + private JCheckBox allowISPurchasesBox; + private JCheckBox allowCanonOnlyBox; + private JCheckBox allowCanonRefitOnlyBox; + private JLabel lblChoiceTechLevel; + private MMComboBox choiceTechLevel; + private JCheckBox variableTechLevelBox; + private JCheckBox useAmmoByTypeBox; + //end Tech Limits Tab + public EquipmentAndSuppliesTab(JFrame frame, String name) { this.frame = frame; this.name = name; @@ -177,6 +190,23 @@ private void initializeAcquisitionTab() { spnMaxAcquisitions = new JSpinner(); } + /** + * Initializes the components of the TechLimitsTab. + * This panel contains various controls for setting technological limits. + */ + private void initializeTechLimitsTab() { + limitByYearBox = new JCheckBox(); + disallowExtinctStuffBox = new JCheckBox(); + allowClanPurchasesBox = new JCheckBox(); + allowISPurchasesBox = new JCheckBox(); + allowCanonOnlyBox = new JCheckBox(); + allowCanonRefitOnlyBox = new JCheckBox(); + lblChoiceTechLevel = new JLabel(); + choiceTechLevel = new MMComboBox<>("choiceTechLevel", getMaximumTechLevelOptions()); + variableTechLevelBox = new JCheckBox(); + useAmmoByTypeBox = new JCheckBox(); + } + /** * Creates the acquisition tab panel. * @@ -768,4 +798,96 @@ private static DefaultComboBoxModel buildAcquireSkillComboOptions() { return acquireSkillModel; } + + /** + * Creates a {@link JPanel} representing the tech limits tab. + * This method constructs various components including checkboxes, labels, and combo boxes + * to customize the tech limit settings. + * + * @return a {@link JPanel} containing the technical limits tab with all its configured components + */ + JPanel createTechLimitsTab() { + // Header + JPanel headerPanel = createHeaderPanel("TechLimitsTab", + getImageDirectory() + "logo_clan_cloud_cobra.png", false, + "", true); + + // Limit Parts/Units by Year + limitByYearBox = createCheckBox("LimitByYearBox", null); + + // Disallow Extinct Units/Parts + disallowExtinctStuffBox = createCheckBox("DisallowExtinctStuffBox", null); + + // Allow Clan/Inner Sphere Purchases + allowClanPurchasesBox = createCheckBox("AllowClanPurchasesBox", null); + allowISPurchasesBox = createCheckBox("AllowISPurchasesBox", null); + + // Canon Purchases/Refits + allowCanonOnlyBox = createCheckBox("AllowCanonOnlyBox", null); + allowCanonRefitOnlyBox = createCheckBox("AllowCanonRefitOnlyBox", null); + + // Maximum Tech Level + lblChoiceTechLevel = createLabel("ChoiceTechLevel", null); + choiceTechLevel = new MMComboBox<>("choiceTechLevel", getMaximumTechLevelOptions()); + + // Variable Tech Level + variableTechLevelBox = createCheckBox("VariableTechLevelBox", null); + + // Ammo by Type + useAmmoByTypeBox = createCheckBox("UseAmmoByTypeBox", null); + + // Layout the Panel + final JPanel panel = createStandardPanel("TechLimitsTab", true, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addComponent(limitByYearBox) + .addComponent(disallowExtinctStuffBox) + .addComponent(allowClanPurchasesBox) + .addComponent(allowISPurchasesBox) + .addComponent(allowCanonOnlyBox) + .addComponent(allowCanonRefitOnlyBox) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblChoiceTechLevel) + .addComponent(choiceTechLevel)) + .addComponent(variableTechLevelBox) + .addComponent(useAmmoByTypeBox)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addComponent(limitByYearBox) + .addComponent(disallowExtinctStuffBox) + .addComponent(allowClanPurchasesBox) + .addComponent(allowISPurchasesBox) + .addComponent(allowCanonOnlyBox) + .addComponent(allowCanonRefitOnlyBox) + .addGroup(layout.createSequentialGroup() + .addComponent(lblChoiceTechLevel) + .addComponent(choiceTechLevel) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(variableTechLevelBox) + .addComponent(useAmmoByTypeBox)); + + // Create Parent Panel and return + return createParentPanel(panel, "TechLimitsTab"); + } + + /** + * @return a {@link DefaultComboBoxModel} containing options for maximum technology levels. + */ + private static DefaultComboBoxModel getMaximumTechLevelOptions() { + DefaultComboBoxModel maximumTechLevelModel = new DefaultComboBoxModel<>(); + + maximumTechLevelModel.addElement(CampaignOptions.getTechLevelName(CampaignOptions.TECH_INTRO)); + maximumTechLevelModel.addElement(CampaignOptions.getTechLevelName(CampaignOptions.TECH_STANDARD)); + maximumTechLevelModel.addElement(CampaignOptions.getTechLevelName(CampaignOptions.TECH_ADVANCED)); + maximumTechLevelModel.addElement(CampaignOptions.getTechLevelName(CampaignOptions.TECH_EXPERIMENTAL)); + maximumTechLevelModel.addElement(CampaignOptions.getTechLevelName(CampaignOptions.TECH_UNOFFICIAL)); + + return maximumTechLevelModel; + } } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentTab.java deleted file mode 100644 index 3bfa1c1e08..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentTab.java +++ /dev/null @@ -1,164 +0,0 @@ -package mekhq.gui.panes.campaignOptions.tabs; - -import megamek.client.ui.baseComponents.MMComboBox; -import mekhq.campaign.campaignOptions.CampaignOptions; - -import javax.swing.*; -import javax.swing.GroupLayout.Alignment; - -import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; - -public class EquipmentTab { - JFrame frame; - String name; - - //start Tech Limits Tab - private JCheckBox limitByYearBox; - private JCheckBox disallowExtinctStuffBox; - private JCheckBox allowClanPurchasesBox; - private JCheckBox allowISPurchasesBox; - private JCheckBox allowCanonOnlyBox; - private JCheckBox allowCanonRefitOnlyBox; - private JLabel lblChoiceTechLevel; - private MMComboBox choiceTechLevel; - private JCheckBox variableTechLevelBox; - private JCheckBox useAmmoByTypeBox; - //end Tech Limits Tab - - //start Random Assignment Tables Tab - //end Random Assignment Tables Tab - - //start Rulesets Tab - //end Rulesets Tab - - public EquipmentTab(JFrame frame, String name) { - this.frame = frame; - this.name = name; - - initialize(); - } - - /** - * Calls the initialization methods for the different tabs. - */ - void initialize() { - initializeTechLimitsTab(); - initializeRandomAssignmentTablesTab(); - } - - /** - * Initializes the components of the TechLimitsTab. - * This panel contains various controls for setting technological limits. - */ - private void initializeTechLimitsTab() { - limitByYearBox = new JCheckBox(); - disallowExtinctStuffBox = new JCheckBox(); - allowClanPurchasesBox = new JCheckBox(); - allowISPurchasesBox = new JCheckBox(); - allowCanonOnlyBox = new JCheckBox(); - allowCanonRefitOnlyBox = new JCheckBox(); - lblChoiceTechLevel = new JLabel(); - choiceTechLevel = new MMComboBox<>("choiceTechLevel", getMaximumTechLevelOptions()); - variableTechLevelBox = new JCheckBox(); - useAmmoByTypeBox = new JCheckBox(); - } - - /** - * Initializes the components of the RandomAssignmentTablesTab. - * This panel would typically contain controls related to random assignment tables. - */ - private void initializeRandomAssignmentTablesTab() { - } - - /** - * Creates a {@link JPanel} representing the tech limits tab. - * This method constructs various components including checkboxes, labels, and combo boxes - * to customize the tech limit settings. - * - * @return a {@link JPanel} containing the technical limits tab with all its configured components - */ - JPanel createTechLimitsTab() { - // Header - JPanel headerPanel = createHeaderPanel("TechLimitsTab", - getImageDirectory() + "logo_clan_cloud_cobra.png", false, - "", true); - - // Limit Parts/Units by Year - limitByYearBox = createCheckBox("LimitByYearBox", null); - - // Disallow Extinct Units/Parts - disallowExtinctStuffBox = createCheckBox("DisallowExtinctStuffBox", null); - - // Allow Clan/Inner Sphere Purchases - allowClanPurchasesBox = createCheckBox("AllowClanPurchasesBox", null); - allowISPurchasesBox = createCheckBox("AllowISPurchasesBox", null); - - // Canon Purchases/Refits - allowCanonOnlyBox = createCheckBox("AllowCanonOnlyBox", null); - allowCanonRefitOnlyBox = createCheckBox("AllowCanonRefitOnlyBox", null); - - // Maximum Tech Level - lblChoiceTechLevel = createLabel("ChoiceTechLevel", null); - choiceTechLevel = new MMComboBox<>("choiceTechLevel", getMaximumTechLevelOptions()); - - // Variable Tech Level - variableTechLevelBox = createCheckBox("VariableTechLevelBox", null); - - // Ammo by Type - useAmmoByTypeBox = createCheckBox("UseAmmoByTypeBox", null); - - // Layout the Panel - final JPanel panel = createStandardPanel("TechLimitsTab", true, ""); - final GroupLayout layout = createStandardLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(limitByYearBox) - .addComponent(disallowExtinctStuffBox) - .addComponent(allowClanPurchasesBox) - .addComponent(allowISPurchasesBox) - .addComponent(allowCanonOnlyBox) - .addComponent(allowCanonRefitOnlyBox) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblChoiceTechLevel) - .addComponent(choiceTechLevel)) - .addComponent(variableTechLevelBox) - .addComponent(useAmmoByTypeBox)); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(limitByYearBox) - .addComponent(disallowExtinctStuffBox) - .addComponent(allowClanPurchasesBox) - .addComponent(allowISPurchasesBox) - .addComponent(allowCanonOnlyBox) - .addComponent(allowCanonRefitOnlyBox) - .addGroup(layout.createSequentialGroup() - .addComponent(lblChoiceTechLevel) - .addComponent(choiceTechLevel) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) - .addComponent(variableTechLevelBox) - .addComponent(useAmmoByTypeBox)); - - // Create Parent Panel and return - return createParentPanel(panel, "TechLimitsTab"); - } - - /** - * @return a {@link DefaultComboBoxModel} containing options for maximum technology levels. - */ - private static DefaultComboBoxModel getMaximumTechLevelOptions() { - DefaultComboBoxModel maximumTechLevelModel = new DefaultComboBoxModel<>(); - - maximumTechLevelModel.addElement(CampaignOptions.getTechLevelName(CampaignOptions.TECH_INTRO)); - maximumTechLevelModel.addElement(CampaignOptions.getTechLevelName(CampaignOptions.TECH_STANDARD)); - maximumTechLevelModel.addElement(CampaignOptions.getTechLevelName(CampaignOptions.TECH_ADVANCED)); - maximumTechLevelModel.addElement(CampaignOptions.getTechLevelName(CampaignOptions.TECH_EXPERIMENTAL)); - maximumTechLevelModel.addElement(CampaignOptions.getTechLevelName(CampaignOptions.TECH_UNOFFICIAL)); - - return maximumTechLevelModel; - } -} From 806a40fc749a5d8ca7e627a6f1f9a5f81d8dbd02 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 11 Oct 2024 17:50:07 -0500 Subject: [PATCH 057/117] Rename Logistics Parent Tab Changed the title of the 'logisticsAndMaintenanceParentTab' to 'Logistics' in the campaign options dialog. Also, standardized comment formatting in CampaignOptionsPane.java for better readability. --- .../resources/NEWCampaignOptionsDialog.properties | 2 +- .../campaignOptions/tabs/CampaignOptionsPane.java | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 4b97cee02a..5d163ddac5 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -14,7 +14,7 @@ presetDialogCancel.tooltip=Return to the prior screen. generalPanel.title=General Information humanResourcesParentTab.title=Human Resources unitDevelopmentParentTab.title=Unit Development -logisticsAndMaintenanceParentTab.title=Equipment and Supplies +logisticsAndMaintenanceParentTab.title=Logistics strategicOperationsParentTab.title=Strategic Operations diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 91a8808aad..486972c278 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -151,10 +151,10 @@ private JTabbedPane createHumanResourcesParentTab() { } private JTabbedPane createUnitDevelopmentParentTab() { - // Experience - // Skills - // Skill Randomization - // SPAs + // Experience + // Skills + // Skill Randomization + // SPAs // Parent Tab JTabbedPane unitDevelopmentParentTab = new JTabbedPane(); @@ -203,9 +203,9 @@ private JTabbedPane createEquipmentAndSuppliesParentTab() { } private JTabbedPane createStrategicOperationsParentTab() { - // Finances - // Mercenary - // Markets + // Finances + // Mercenary + // Markets // Rulesets // Parent Tab From 248dcda91820319b19890e4cc895840d9df1d9bf Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 11 Oct 2024 20:36:30 -0500 Subject: [PATCH 058/117] Delete unused classes and change initialize methods to private Removed redundant classes in the campaignOptions package to streamline the codebase. Also modified the accessibility of initialize methods from protected to private in various tabs for better encapsulation and maintenance. --- .../campaignOptions/tabs/BiographyTab.java | 2 +- .../campaignOptions/tabs/Experience.java | 4 -- .../panes/campaignOptions/tabs/Finances.java | 4 -- .../campaignOptions/tabs/FinancesTab.java | 40 +++++++++++++++++++ .../campaignOptions/tabs/GeneralTab.java | 2 +- .../panes/campaignOptions/tabs/Markets.java | 4 -- .../panes/campaignOptions/tabs/Mercenary.java | 4 -- .../campaignOptions/tabs/PersonnelTab.java | 2 +- .../campaignOptions/tabs/RankSystems.java | 4 -- .../tabs/RelationshipsTab.java | 2 +- .../panes/campaignOptions/tabs/Rulesets.java | 4 -- .../gui/panes/campaignOptions/tabs/SPAs.java | 4 -- .../tabs/SkillRandomization.java | 4 -- .../panes/campaignOptions/tabs/Skills.java | 4 -- .../tabs/TurnoverAndRetentionTab.java | 2 +- 15 files changed, 45 insertions(+), 41 deletions(-) delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Experience.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Finances.java create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Markets.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Mercenary.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RankSystems.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Rulesets.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SPAs.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SkillRandomization.java delete mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Skills.java diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java index 9d4bdb56b4..e37cd92bcf 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java @@ -170,7 +170,7 @@ public class BiographyTab { * Initializes the components for the NameAndPortraitTab panel. * The panel contains various settings related to names and portraits. */ - protected void initialize() { + private void initialize() { initializeGeneralTab(); initializeBackgroundsTab(); initializeDeathTab(); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Experience.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Experience.java deleted file mode 100644 index 9eaf5e2c92..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Experience.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.tabs; - -public class Experience { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Finances.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Finances.java deleted file mode 100644 index f9731c7db1..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Finances.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.tabs; - -public class Finances { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java new file mode 100644 index 0000000000..ab78c8e063 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java @@ -0,0 +1,40 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +import javax.swing.*; + +public class FinancesTab { + JFrame frame; + String name; + + //start General Options + //end General Options + + //start Price Multipliers + //end Price Multipliers + + FinancesTab(JFrame frame, String name) { + this.frame = frame; + this.name = name; + + initialize(); + } + + private void initialize() { + createFinancesGeneralOptionsTab(); + createPriceMultipliersTab(); + } + + private void initializeGeneralOptionsTab() { + } + + JPanel createFinancesGeneralOptionsTab() { + + } + + private void initializePriceMultipliersTab() { + } + + JPanel createPriceMultipliersTab() { + + } +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java index b4589ce083..ef3364c12b 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java @@ -242,7 +242,7 @@ private static JPanel createGeneralHeader() { /** * Initialize the components of the {@link GeneralTab} class. */ - protected void initialize() { + private void initialize() { lblName = new JLabel(); txtName = new JTextField(); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Markets.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Markets.java deleted file mode 100644 index 9b9a90d454..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Markets.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.tabs; - -public class Markets { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Mercenary.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Mercenary.java deleted file mode 100644 index b68a33b17d..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Mercenary.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.tabs; - -public class Mercenary { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java index f5bb067581..8fcc5b0c2f 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java @@ -161,7 +161,7 @@ public class PersonnelTab { /** * Initializes the components of all tabs within the frame. */ - protected void initialize() { + private void initialize() { initializeGeneralTab(); initializePersonnelLogsTab(); initializePersonnelInformationTab(); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RankSystems.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RankSystems.java deleted file mode 100644 index 8c2b309489..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RankSystems.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.tabs; - -public class RankSystems { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java index fb87df894c..31ce30d6e1 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java @@ -101,7 +101,7 @@ public class RelationshipsTab { /** * Calls the initialization methods for all the tab panels. */ - protected void initialize() { + private void initialize() { initializeMarriageTab(); initializeDivorceTab(); initializeProcreationTab(); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Rulesets.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Rulesets.java deleted file mode 100644 index 03b348d23f..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Rulesets.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.tabs; - -public class Rulesets { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SPAs.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SPAs.java deleted file mode 100644 index 999f496294..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SPAs.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.tabs; - -public class SPAs { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SkillRandomization.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SkillRandomization.java deleted file mode 100644 index 8ab0fecf3f..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/SkillRandomization.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.tabs; - -public class SkillRandomization { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Skills.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Skills.java deleted file mode 100644 index 467e2df132..0000000000 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/Skills.java +++ /dev/null @@ -1,4 +0,0 @@ -package mekhq.gui.panes.campaignOptions.tabs; - -public class Skills { -} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java index 57213cbeae..dc699a2475 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java @@ -125,7 +125,7 @@ public class TurnoverAndRetentionTab { /** * Initializes all tab components. */ - protected void initialize() { + private void initialize() { initializeTurnoverTab(); initializeFatigueTab(); } From d02cf4d61e298d2fb6db5e926988600993812733 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 11 Oct 2024 22:01:10 -0500 Subject: [PATCH 059/117] Add new financial options to FinancesTab Enhanced the FinancesTab with detailed financial settings including loan limits, percentage maintenance costs, taxation, and share system options. Created separate panels for payments, sales, taxes, and other systems, and updated resource properties to reflect these changes. --- .../NEWCampaignOptionsDialog.properties | 76 +++- .../tabs/CampaignOptionsPane.java | 18 +- .../campaignOptions/tabs/FinancesTab.java | 337 +++++++++++++++++- 3 files changed, 424 insertions(+), 7 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 5d163ddac5..9122e5240b 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -105,7 +105,7 @@ lblLogMaintenance.text=Write Maintenance Results to MekHQ.log lblLogMaintenance.tooltip=PLACEHOLDER ## SuppliesAndAcquisitionTab -suppliesAndAcquisitionTab.title=Supplies and Acquisition +suppliesAndAcquisitionContentTabs.title=Supplies and Acquisition acquisitionTab.title=Acquisitions acquisitionTab.border="It's not about what you need - it's about what you can get. In acquisitions,\ @@ -1000,4 +1000,76 @@ lblUseRandomPrisonerProcreation.tooltip=PLACEHOLDER lblRandomProcreationRelationshipDiceSize.text=Normal Procreation Chance: 1 in lblRandomProcreationRelationshipDiceSize.tooltip=PLACEHOLDER lblRandomProcreationRelationshiplessDiceSize.text=Relationshipless Procreation Chance: 1 in -lblRandomProcreationRelationshiplessDiceSize.tooltip=PLACEHOLDER \ No newline at end of file +lblRandomProcreationRelationshiplessDiceSize.tooltip=PLACEHOLDER + +# Finances Tab +financesContentTabs.title=Finances + +financesGeneralTab.title=General +financesGeneralTab.border="War is expensive. If the enemy doesn't kill you, the repair bills might."\ +
- Sergeant Tara "Grease" Hall, Red Star Mercenaries + +# createFinancesGeneralOptionsTab +lblFinancesGeneralTab.text=General Options +lblFinancesGeneralTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam + +# createPaymentsPanel +lblPaymentsPanel.text=Payments +lblPayForPartsBox.text=Pay For Parts +lblPayForPartsBox.tooltip=PLACEHOLDER +lblPayForRepairsBox.text=Pay For Repairs +lblPayForRepairsBox.tooltip=PLACEHOLDER +lblPayForUnitsBox.text=Pay For Units +lblPayForUnitsBox.tooltip=PLACEHOLDER +lblPayForSalariesBox.text=Pay For Salaries +lblPayForSalariesBox.tooltip=PLACEHOLDER +lblPayForOverheadBox.text=Pay For Overhead +lblPayForOverheadBox.tooltip=PLACEHOLDER +lblPayForMaintainBox.text=Pay For Maintenance +lblPayForMaintainBox.tooltip=PLACEHOLDER +lblPayForTransportBox.text=Transport +lblPayForTransportBox.tooltip=PLACEHOLDER +lblPayForRecruitmentBox.text=Recruitment +lblPayForRecruitmentBox.tooltip=PLACEHOLDER + +# createGeneralOptionsPanel +lblUseLoanLimitsBox.text=Available Loans Based on Unit Reputation +lblUseLoanLimitsBox.tooltip=PLACEHOLDER +lblUsePercentageMaintenanceBox.text=Enable Percentage-Based Maintenance Costs +lblUsePercentageMaintenanceBox.tooltip=PLACEHOLDER +lblUseExtendedPartsModifierBox.text=Enabled Extended Spare Parts Modifiers +lblUseExtendedPartsModifierBox.tooltip=PLACEHOLDER +lblUsePeacetimeCostBox.text=Enable Peacetime Operating Costs +lblUsePeacetimeCostBox.tooltip=PLACEHOLDER +lblShowPeacetimeCostBox.text=Breakdown Operating Costs +lblShowPeacetimeCostBox.tooltip=PLACEHOLDER +lblFinancialYearDuration.text=Financial Year Duration +lblFinancialYearDuration.tooltip=PLACEHOLDER +lblNewFinancialYearFinancesToCSVExportBox.text=Export Finances as CSV Table on Term End +lblNewFinancialYearFinancesToCSVExportBox.tooltip=PLACEHOLDER + +# createSalesPanel +lblSalesPanel.text=Sales +lblSellUnitsBox.text=Enable the Sale of Units +lblSellUnitsBox.tooltip=PLACEHOLDER +lblSellPartsBox.text=Enable the Sale of Parts +lblSellPartsBox.tooltip=PLACEHOLDER + +# createTaxesPanel +lblTaxesPanel.text=Taxes +lblUseTaxesBox.text=Enable Taxes +lblUseTaxesBox.tooltip=PLACEHOLDER +lblTaxesPercentage.text=Tax Percentage +lblTaxesPercentage.tooltip=PLACEHOLDER + +# createSharesPanel +lblSharesPanel.text=Shares +lblUseShareSystem.text=Enable Shares +lblUseShareSystem.tooltip=PLACEHOLDER +lblSharesForAll.text=All Personnel Have Shares +lblSharesForAll.tooltip=PLACEHOLDER \ No newline at end of file diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 486972c278..24afcae0d4 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -192,7 +192,7 @@ private JTabbedPane createEquipmentAndSuppliesParentTab() { // Add tabs equipmentAndSuppliesParentTab.addTab(String.format("%s", 4, - resources.getString("suppliesAndAcquisitionTab.title")), suppliesAndAcquisitionContentTabs); + resources.getString("suppliesAndAcquisitionContentTabs.title")), suppliesAndAcquisitionContentTabs); equipmentAndSuppliesParentTab.addTab(String.format("%s", 4, resources.getString("repairsAndMaintenanceContentTabs.title")), repairsAndMaintenanceContentTabs); @@ -203,13 +203,23 @@ private JTabbedPane createEquipmentAndSuppliesParentTab() { } private JTabbedPane createStrategicOperationsParentTab() { + // Parent Tab + JTabbedPane strategicOperationsParentTab = new JTabbedPane(); + // Finances - // Mercenary + FinancesTab financesTab = new FinancesTab(getFrame(), "financesTab"); + + JTabbedPane financesContentTabs = createSubTabs(Map.of( + "financesGeneralTab", financesTab.createFinancesGeneralOptionsTab()));// Mercenary // Markets // Rulesets - // Parent Tab - JTabbedPane strategicOperationsParentTab = new JTabbedPane(); + // Add tabs + strategicOperationsParentTab.addTab(String.format("%s", 4, + resources.getString("financesContentTabs.title")), financesContentTabs); + + addTab(String.format("%s", 4, + resources.getString("strategicOperationsParentTab.title")), strategicOperationsParentTab); return strategicOperationsParentTab; } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java index ab78c8e063..e2c9d966f8 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java @@ -1,12 +1,54 @@ package mekhq.gui.panes.campaignOptions.tabs; +import megamek.client.ui.baseComponents.MMComboBox; +import megamek.client.ui.swing.util.UIUtil; +import mekhq.campaign.finances.enums.FinancialYearDuration; + import javax.swing.*; +import javax.swing.GroupLayout.Alignment; + +import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; public class FinancesTab { JFrame frame; String name; //start General Options + private JPanel pnlGeneralOptions; + private JCheckBox useLoanLimitsBox; + private JCheckBox usePercentageMaintenanceBox; + private JCheckBox useExtendedPartsModifierBox; + private JCheckBox usePeacetimeCostBox; + private JCheckBox showPeacetimeCostBox; + private JLabel lblFinancialYearDuration; + private MMComboBox comboFinancialYearDuration; + private JCheckBox newFinancialYearFinancesToCSVExportBox; + + private JPanel pnlPayments; + private JCheckBox payForPartsBox; + private JCheckBox payForRepairsBox; + private JCheckBox payForUnitsBox; + private JCheckBox payForSalariesBox; + private JCheckBox payForOverheadBox; + private JCheckBox payForMaintainBox; + private JCheckBox payForTransportBox; + private JCheckBox payForRecruitmentBox; + + + private JPanel pnlSales; + private JCheckBox sellUnitsBox; + private JCheckBox sellPartsBox; + + private JPanel pnlOtherSystems; + + private JPanel pnlTaxes; + private JCheckBox chkUseTaxes; + private JLabel lblTaxesPercentage; + private JSpinner spnTaxesPercentage; + + private JPanel pnlShares; + private JCheckBox chkUseShareSystem; + private JCheckBox chkSharesForAll; //end General Options //start Price Multipliers @@ -20,21 +62,314 @@ public class FinancesTab { } private void initialize() { + initializeGeneralOptionsTab(); createFinancesGeneralOptionsTab(); createPriceMultipliersTab(); } private void initializeGeneralOptionsTab() { + // General Options + pnlGeneralOptions = new JPanel(); + useLoanLimitsBox = new JCheckBox(); + usePercentageMaintenanceBox = new JCheckBox(); + useExtendedPartsModifierBox = new JCheckBox(); + usePeacetimeCostBox = new JCheckBox(); + showPeacetimeCostBox = new JCheckBox(); + + lblFinancialYearDuration = new JLabel(); + comboFinancialYearDuration = new MMComboBox<>("comboFinancialYearDuration", + getFinancialYearDurationOptions()); + + newFinancialYearFinancesToCSVExportBox = new JCheckBox(); + + // Payments + pnlPayments = new JPanel(); + payForPartsBox = new JCheckBox(); + payForRepairsBox = new JCheckBox(); + payForUnitsBox = new JCheckBox(); + payForSalariesBox = new JCheckBox(); + payForOverheadBox = new JCheckBox(); + payForMaintainBox = new JCheckBox(); + payForTransportBox = new JCheckBox(); + payForRecruitmentBox = new JCheckBox(); + + // Sales + pnlSales = new JPanel(); + sellUnitsBox = new JCheckBox(); + sellPartsBox = new JCheckBox(); + + pnlOtherSystems = new JPanel(); + + // Taxes + pnlTaxes = new JPanel(); + chkUseTaxes = new JCheckBox(); + lblTaxesPercentage = new JLabel(); + spnTaxesPercentage = new JSpinner(); + + // Shares + pnlShares= new JPanel(); + chkUseShareSystem = new JCheckBox(); + chkSharesForAll = new JCheckBox(); + } + + private static DefaultComboBoxModel getFinancialYearDurationOptions() { + return new DefaultComboBoxModel<>(FinancialYearDuration.values()); } JPanel createFinancesGeneralOptionsTab() { + // Header + JPanel headerPanel = createHeaderPanel("FinancesGeneralTab", + getImageDirectory() + "logo_clan_nova_cat.png", + false, "", true); + + // Contents + pnlGeneralOptions = createGeneralOptionsPanel(); + pnlPayments = createPaymentsPanel(); + pnlSales = createSalesPanel(); + + pnlOtherSystems = createOtherSystemsPanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("FinancesGeneralTab", true, + ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(pnlGeneralOptions) + .addComponent(pnlOtherSystems)) + .addComponent(pnlSales) + .addComponent(pnlPayments)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addGroup(layout.createSequentialGroup() + .addComponent(pnlGeneralOptions) + .addComponent(pnlOtherSystems) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(pnlSales) + .addComponent(pnlPayments)); + + // Create Parent Panel and return + return createParentPanel(panel, "FinancesGeneralTab"); + } + + JPanel createPaymentsPanel() { + // Contents + payForPartsBox = createCheckBox("PayForPartsBox", null); + payForRepairsBox = createCheckBox("PayForRepairsBox", null); + payForUnitsBox = createCheckBox("PayForUnitsBox", null); + payForSalariesBox = createCheckBox("PayForSalariesBox", null); + payForOverheadBox = createCheckBox("PayForOverheadBox", null); + payForMaintainBox = createCheckBox("PayForMaintainBox", null); + payForTransportBox = createCheckBox("PayForTransportBox", null); + payForRecruitmentBox = createCheckBox("PayForRecruitmentBox", null); + + // Layout the Panel + final JPanel panel = createStandardPanel("PaymentsPanel", true, + "PaymentsPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(payForPartsBox) + .addComponent(payForRepairsBox) + .addComponent(payForUnitsBox) + .addComponent(payForSalariesBox)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(payForOverheadBox) + .addComponent(payForMaintainBox) + .addComponent(payForTransportBox) + .addComponent(payForRecruitmentBox))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(payForPartsBox) + .addGap(UIUtil.scaleForGUI(5)) + .addComponent(payForRepairsBox) + .addGap(UIUtil.scaleForGUI(5)) + .addComponent(payForUnitsBox) + .addGap(UIUtil.scaleForGUI(5)) + .addComponent(payForSalariesBox) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGap(UIUtil.scaleForGUI(5)) + .addGroup(layout.createSequentialGroup() + .addComponent(payForOverheadBox) + .addGap(UIUtil.scaleForGUI(5)) + .addComponent(payForMaintainBox) + .addGap(UIUtil.scaleForGUI(5)) + .addComponent(payForTransportBox) + .addGap(UIUtil.scaleForGUI(5)) + .addComponent(payForRecruitmentBox) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + return panel; + } + + JPanel createOtherSystemsPanel() { + // Contents + pnlTaxes = createTaxesPanel(); + pnlShares = createSharesPanel(); + // Layout the Panel + final JPanel panel = createStandardPanel("OtherSystemsPanel", false, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(pnlTaxes) + .addComponent(pnlShares)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(pnlTaxes) + .addComponent(pnlShares)); + + return panel; + } + + JPanel createGeneralOptionsPanel() { + // Contents + useLoanLimitsBox = createCheckBox("UseLoanLimitsBox", null); + usePercentageMaintenanceBox = createCheckBox("UsePercentageMaintenanceBox", null); + useExtendedPartsModifierBox = createCheckBox("UseExtendedPartsModifierBox", null); + usePeacetimeCostBox = createCheckBox("UsePeacetimeCostBox", null); + showPeacetimeCostBox = createCheckBox("ShowPeacetimeCostBox", null); + + lblFinancialYearDuration = createLabel("FinancialYearDuration", null); + + newFinancialYearFinancesToCSVExportBox = createCheckBox("NewFinancialYearFinancesToCSVExportBox", + null); + + // Layout the Panel + final JPanel panel = createStandardPanel("GeneralOptionsPanel", false, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(useLoanLimitsBox) + .addComponent(usePercentageMaintenanceBox) + .addComponent(useExtendedPartsModifierBox) + .addComponent(usePeacetimeCostBox) + .addComponent(showPeacetimeCostBox) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblFinancialYearDuration) + .addComponent(comboFinancialYearDuration)) + .addComponent(newFinancialYearFinancesToCSVExportBox)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(useLoanLimitsBox) + .addComponent(usePercentageMaintenanceBox) + .addComponent(useExtendedPartsModifierBox) + .addComponent(usePeacetimeCostBox) + .addComponent(showPeacetimeCostBox) + .addGroup(layout.createSequentialGroup() + .addComponent(lblFinancialYearDuration) + .addComponent(comboFinancialYearDuration) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(newFinancialYearFinancesToCSVExportBox)); + + return panel; + } + + JPanel createSalesPanel() { + // Contents + sellUnitsBox = createCheckBox("SellUnitsBox", null); + sellPartsBox = createCheckBox("SellPartsBox", null); + + // Layout the Panel + final JPanel panel = createStandardPanel("SalesPanel", true, + "SalesPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(sellUnitsBox) + .addComponent(sellPartsBox))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(sellUnitsBox) + .addGap(UIUtil.scaleForGUI(5)) + .addComponent(sellPartsBox) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + return panel; + } + + JPanel createTaxesPanel() { + // Contents + chkUseTaxes = createCheckBox("UseTaxesBox", null); + + lblTaxesPercentage = createLabel("TaxesPercentage", null); + spnTaxesPercentage = createSpinner("TaxesPercentage", null, + 30, 1, 100, 1); + + // Layout the Panel + final JPanel panel = createStandardPanel("TaxesPanel", true, + "TaxesPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(chkUseTaxes) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblTaxesPercentage) + .addComponent(spnTaxesPercentage))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(chkUseTaxes) + .addGroup(layout.createSequentialGroup() + .addComponent(lblTaxesPercentage) + .addComponent(spnTaxesPercentage) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + return panel; + } + + JPanel createSharesPanel() { + // Contents + chkUseShareSystem = createCheckBox("UseShareSystem", null); + chkSharesForAll = createCheckBox("SharesForAll", null); + + // Layout the Panel + final JPanel panel = createStandardPanel("SharesPanel", true, + "SharesPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(chkUseShareSystem) + .addComponent(chkSharesForAll)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(chkUseShareSystem) + .addComponent(chkSharesForAll)); + + return panel; } private void initializePriceMultipliersTab() { } JPanel createPriceMultipliersTab() { - + return null; } } From bb1acf95823a10f38c86a4df38accec02ac6a6a5 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 11 Oct 2024 23:37:54 -0500 Subject: [PATCH 060/117] Add price multipliers tab to finances options Introduced a new "Price Multipliers" tab within the finances options of the campaign settings. This tab includes configurable multipliers for various parts, units, and conditions, enhancing customization and economic control. Adjusted related methods and integrated new labels and properties accordingly. --- .../NEWCampaignOptionsDialog.properties | 43 ++- .../tabs/CampaignOptionsPane.java | 9 +- .../tabs/CampaignOptionsUtilities.java | 4 +- .../campaignOptions/tabs/FinancesTab.java | 323 +++++++++++++++++- 4 files changed, 363 insertions(+), 16 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 9122e5240b..90189cc6a6 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -1009,6 +1009,11 @@ financesGeneralTab.title=General financesGeneralTab.border="War is expensive. If the enemy doesn't kill you, the repair bills might."\
- Sergeant Tara "Grease" Hall, Red Star Mercenaries +priceMultipliersTab.title=Price Multipliers +priceMultipliersTab.border="The used parts market is where dreams are built - and nightmares are patched\ + \ together. Just make sure the part you're buying doesn't come with someone else's curse."\ +
- Captain Nia "Jackal" Thorne, Shadowblade Lancers + # createFinancesGeneralOptionsTab lblFinancesGeneralTab.text=General Options lblFinancesGeneralTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ @@ -1072,4 +1077,40 @@ lblSharesPanel.text=Shares lblUseShareSystem.text=Enable Shares lblUseShareSystem.tooltip=PLACEHOLDER lblSharesForAll.text=All Personnel Have Shares -lblSharesForAll.tooltip=PLACEHOLDER \ No newline at end of file +lblSharesForAll.tooltip=PLACEHOLDER + +# createFinancesGeneralOptionsTab +lblPriceMultipliersTab.text=Price Multiplier Options +lblPriceMultipliersTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam + +# createGeneralMultipliersPanel +lblGeneralMultipliersPanel.text=General +lblCommonPartPriceMultiplier.text=Common Parts +lblCommonPartPriceMultiplier.tooltip=PLACEHOLDER +lblInnerSphereUnitPriceMultiplier.text=Inner Sphere Units +lblInnerSphereUnitPriceMultiplier.tooltip=PLACEHOLDER +lblInnerSpherePartPriceMultiplier.text=Inner Sphere Parts +lblInnerSpherePartPriceMultiplier.tooltip=PLACEHOLDER +lblClanUnitPriceMultiplier.text=Clan Units +lblClanUnitPriceMultiplier.tooltip=PLACEHOLDER +lblClanPartPriceMultiplier.text=Clan Parts +lblClanPartPriceMultiplier.tooltip=PLACEHOLDER +lblMixedTechUnitPriceMultiplier.text=Mixed Units +lblMixedTechUnitPriceMultiplier.tooltip=PLACEHOLDER + +# createUsedPartsMultiplierPanel +lblUsedPartsMultiplierPanel.text=Used Parts + +# createOtherMultipliersPanel +lblOtherMultipliersPanel.text=Other +lblDamagedPartsValueMultiplier.text=Damaged Parts +lblDamagedPartsValueMultiplier.tooltip=PLACEHOLDER +lblUnrepairablePartsValueMultiplier.text=Irreparable Parts +lblUnrepairablePartsValueMultiplier.tooltip=PLACEHOLDER +lblCancelledOrderRefundMultiplier.text=Cancelled Order Refund +lblCancelledOrderRefundMultiplier.tooltip=PLACEHOLDER \ No newline at end of file diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 24afcae0d4..2f1d579e88 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -207,11 +207,14 @@ private JTabbedPane createStrategicOperationsParentTab() { JTabbedPane strategicOperationsParentTab = new JTabbedPane(); // Finances - FinancesTab financesTab = new FinancesTab(getFrame(), "financesTab"); + FinancesTab financesTab = new FinancesTab(campaign, getFrame(), "financesTab"); JTabbedPane financesContentTabs = createSubTabs(Map.of( - "financesGeneralTab", financesTab.createFinancesGeneralOptionsTab()));// Mercenary - // Markets + "financesGeneralTab", financesTab.createFinancesGeneralOptionsTab(), + "priceMultipliersTab", financesTab.createPriceMultipliersTab())); + + // Markets + Mercenary (don't forget useInfantryDoseNotCountBox) + // Rulesets // Add tabs diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index 2f62d8759f..6e1739946d 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -356,8 +356,8 @@ static JTabbedPane createSubTabs(Map panels) { // Create a panel for the quote JPanel quotePanel = new JPanel(new GridBagLayout()); JLabel quote = new JLabel(String.format( - "
%s
", - resources.getString(tabName + ".border"))); + "
%s
", + UIUtil.scaleForGUI(650), resources.getString(tabName + ".border"))); GridBagConstraints quoteConstraints = new GridBagConstraints(); quoteConstraints.gridx = GridBagConstraints.RELATIVE; diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java index e2c9d966f8..5a16674b28 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java @@ -2,14 +2,19 @@ import megamek.client.ui.baseComponents.MMComboBox; import megamek.client.ui.swing.util.UIUtil; +import mekhq.campaign.Campaign; import mekhq.campaign.finances.enums.FinancialYearDuration; +import mekhq.campaign.parts.Part; import javax.swing.*; import javax.swing.GroupLayout.Alignment; +import javax.swing.JSpinner.DefaultEditor; +import javax.swing.JSpinner.NumberEditor; import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; public class FinancesTab { + Campaign campaign; JFrame frame; String name; @@ -52,9 +57,36 @@ public class FinancesTab { //end General Options //start Price Multipliers + private JPanel pnlGeneralMultipliers; + private JLabel lblCommonPartPriceMultiplier; + private JSpinner spnCommonPartPriceMultiplier; + private JLabel lblInnerSphereUnitPriceMultiplier; + private JSpinner spnInnerSphereUnitPriceMultiplier; + private JLabel lblInnerSpherePartPriceMultiplier; + private JSpinner spnInnerSpherePartPriceMultiplier; + private JLabel lblClanUnitPriceMultiplier; + private JSpinner spnClanUnitPriceMultiplier; + private JLabel lblClanPartPriceMultiplier; + private JSpinner spnClanPartPriceMultiplier; + private JLabel lblMixedTechUnitPriceMultiplier; + private JSpinner spnMixedTechUnitPriceMultiplier; + + private JPanel pnlUsedPartsMultipliers; + private JLabel[] lblUsedPartPriceMultipliers; + private JSpinner[] spnUsedPartPriceMultipliers; + + private JPanel pnlOtherMultipliers; + private JLabel lblDamagedPartsValueMultiplier; + private JSpinner spnDamagedPartsValueMultiplier; + private JLabel lblUnrepairablePartsValueMultiplier; + private JSpinner spnUnrepairablePartsValueMultiplier; + private JLabel lblCancelledOrderRefundMultiplier; + private JSpinner spnCancelledOrderRefundMultiplier; + //end Price Multipliers - FinancesTab(JFrame frame, String name) { + FinancesTab(Campaign campaign, JFrame frame, String name) { + this.campaign = campaign; this.frame = frame; this.name = name; @@ -63,8 +95,7 @@ public class FinancesTab { private void initialize() { initializeGeneralOptionsTab(); - createFinancesGeneralOptionsTab(); - createPriceMultipliersTab(); + initializePriceMultipliersTab(); } private void initializeGeneralOptionsTab() { @@ -158,7 +189,7 @@ JPanel createFinancesGeneralOptionsTab() { return createParentPanel(panel, "FinancesGeneralTab"); } - JPanel createPaymentsPanel() { + private JPanel createPaymentsPanel() { // Contents payForPartsBox = createCheckBox("PayForPartsBox", null); payForRepairsBox = createCheckBox("PayForRepairsBox", null); @@ -213,7 +244,7 @@ JPanel createPaymentsPanel() { return panel; } - JPanel createOtherSystemsPanel() { + private JPanel createOtherSystemsPanel() { // Contents pnlTaxes = createTaxesPanel(); pnlShares = createSharesPanel(); @@ -236,7 +267,7 @@ JPanel createOtherSystemsPanel() { return panel; } - JPanel createGeneralOptionsPanel() { + private JPanel createGeneralOptionsPanel() { // Contents useLoanLimitsBox = createCheckBox("UseLoanLimitsBox", null); usePercentageMaintenanceBox = createCheckBox("UsePercentageMaintenanceBox", null); @@ -282,7 +313,7 @@ JPanel createGeneralOptionsPanel() { return panel; } - JPanel createSalesPanel() { + private JPanel createSalesPanel() { // Contents sellUnitsBox = createCheckBox("SellUnitsBox", null); sellPartsBox = createCheckBox("SellPartsBox", null); @@ -310,7 +341,7 @@ JPanel createSalesPanel() { return panel; } - JPanel createTaxesPanel() { + private JPanel createTaxesPanel() { // Contents chkUseTaxes = createCheckBox("UseTaxesBox", null); @@ -342,7 +373,7 @@ JPanel createTaxesPanel() { return panel; } - JPanel createSharesPanel() { + private JPanel createSharesPanel() { // Contents chkUseShareSystem = createCheckBox("UseShareSystem", null); chkSharesForAll = createCheckBox("SharesForAll", null); @@ -367,9 +398,281 @@ JPanel createSharesPanel() { } private void initializePriceMultipliersTab() { + pnlGeneralMultipliers = new JPanel(); + lblCommonPartPriceMultiplier = new JLabel(); + spnCommonPartPriceMultiplier = new JSpinner(); + lblInnerSphereUnitPriceMultiplier = new JLabel(); + spnInnerSphereUnitPriceMultiplier = new JSpinner(); + lblInnerSpherePartPriceMultiplier = new JLabel(); + spnInnerSpherePartPriceMultiplier = new JSpinner(); + lblClanUnitPriceMultiplier = new JLabel(); + spnClanUnitPriceMultiplier = new JSpinner(); + lblClanPartPriceMultiplier = new JLabel(); + spnClanPartPriceMultiplier = new JSpinner(); + lblMixedTechUnitPriceMultiplier = new JLabel(); + spnMixedTechUnitPriceMultiplier = new JSpinner(); + + pnlUsedPartsMultipliers = new JPanel(); + lblUsedPartPriceMultipliers = new JLabel[1]; // we initialize this properly later + spnUsedPartPriceMultipliers = new JSpinner[1]; // we initialize this properly later + + pnlOtherMultipliers = new JPanel(); + lblDamagedPartsValueMultiplier = new JLabel(); + spnDamagedPartsValueMultiplier = new JSpinner(); + lblUnrepairablePartsValueMultiplier = new JLabel(); + spnUnrepairablePartsValueMultiplier = new JSpinner(); + lblCancelledOrderRefundMultiplier = new JLabel(); + spnCancelledOrderRefundMultiplier = new JSpinner(); } JPanel createPriceMultipliersTab() { - return null; + // Header + JPanel headerPanel = createHeaderPanel("PriceMultipliersTab", + getImageDirectory() + "logo_illyrian_palatinate.png", + false, "", true); + + // Contents + pnlGeneralMultipliers = createGeneralMultipliersPanel(); + pnlUsedPartsMultipliers = createUsedPartsMultiplierPanel(); + pnlOtherMultipliers = createOtherMultipliersPanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("PriceMultipliersTab", true, + ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(pnlGeneralMultipliers) + .addComponent(pnlUsedPartsMultipliers) + .addComponent(pnlOtherMultipliers))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addGroup(layout.createSequentialGroup() + .addComponent(pnlGeneralMultipliers) + .addComponent(pnlUsedPartsMultipliers) + .addComponent(pnlOtherMultipliers) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + // Create Parent Panel and return + return createParentPanel(panel, "PriceMultipliersTab"); + } + + private JPanel createGeneralMultipliersPanel() { + // Contents + lblCommonPartPriceMultiplier = createLabel("CommonPartPriceMultiplier", null); + spnCommonPartPriceMultiplier = createSpinner("CommonPartPriceMultiplier", null, + 1.0, 0.1, 100, 0.1); + + lblInnerSphereUnitPriceMultiplier = createLabel("InnerSphereUnitPriceMultiplier", null); + spnInnerSphereUnitPriceMultiplier = createSpinner("InnerSphereUnitPriceMultiplier", null, + 1.0, 0.1, 100, 0.1); + + lblInnerSpherePartPriceMultiplier = createLabel("InnerSpherePartPriceMultiplier", null); + spnInnerSpherePartPriceMultiplier = createSpinner("InnerSpherePartPriceMultiplier", null, + 1.0, 0.1, 100, 0.1); + + lblClanUnitPriceMultiplier = createLabel("ClanUnitPriceMultiplier", null); + spnClanUnitPriceMultiplier = createSpinner("ClanUnitPriceMultiplier", null, + 1.0, 0.1, 100, 0.1); + + lblClanPartPriceMultiplier = createLabel("ClanPartPriceMultiplier", null); + spnClanPartPriceMultiplier = createSpinner("ClanPartPriceMultiplier", null, + 1.0, 0.1, 100, 0.1); + + lblMixedTechUnitPriceMultiplier = createLabel("MixedTechUnitPriceMultiplier", null); + spnMixedTechUnitPriceMultiplier = createSpinner("MixedTechUnitPriceMultiplier", null, + 1.0, 0.1, 100, 0.1); + + // Layout the Panel + final JPanel panel = createStandardPanel("GeneralMultipliersPanel", true, + "GeneralMultipliersPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblCommonPartPriceMultiplier) + .addComponent(spnCommonPartPriceMultiplier)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblInnerSphereUnitPriceMultiplier) + .addComponent(spnInnerSphereUnitPriceMultiplier)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblInnerSpherePartPriceMultiplier) + .addComponent(spnInnerSpherePartPriceMultiplier)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblClanUnitPriceMultiplier) + .addComponent(spnClanUnitPriceMultiplier)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblClanPartPriceMultiplier) + .addComponent(spnClanPartPriceMultiplier)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblMixedTechUnitPriceMultiplier) + .addComponent(spnMixedTechUnitPriceMultiplier))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblCommonPartPriceMultiplier) + .addComponent(spnCommonPartPriceMultiplier) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblInnerSphereUnitPriceMultiplier) + .addComponent(spnInnerSphereUnitPriceMultiplier) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblInnerSpherePartPriceMultiplier) + .addComponent(spnInnerSpherePartPriceMultiplier) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblClanUnitPriceMultiplier) + .addComponent(spnClanUnitPriceMultiplier) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblClanPartPriceMultiplier) + .addComponent(spnClanPartPriceMultiplier) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblMixedTechUnitPriceMultiplier) + .addComponent(spnMixedTechUnitPriceMultiplier) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + return panel; + } + + private JPanel createUsedPartsMultiplierPanel() { + boolean reverseQualities = campaign.getCampaignOptions().isReverseQualityNames(); + + // Contents + lblUsedPartPriceMultipliers = new JLabel[Part.QUALITY_F + 1]; + spnUsedPartPriceMultipliers = new JSpinner[Part.QUALITY_F + 1]; + + for (int i = Part.QUALITY_A; i <= Part.QUALITY_F; i++) { + final String qualityLevel = Part.getQualityName(i, reverseQualities); + + lblUsedPartPriceMultipliers[i] = new JLabel(qualityLevel); + lblUsedPartPriceMultipliers[i].setName("lbl" + qualityLevel); + + spnUsedPartPriceMultipliers[i] = new JSpinner( + new SpinnerNumberModel(0.00, 0.00, 1.00, 0.05)); + spnUsedPartPriceMultipliers[i].setName("spn" + qualityLevel); + spnUsedPartPriceMultipliers[i] + .setEditor(new NumberEditor(spnUsedPartPriceMultipliers[i], "0.00")); + + DefaultEditor editor = (DefaultEditor) spnUsedPartPriceMultipliers[i].getEditor(); + editor.getTextField().setHorizontalAlignment(JTextField.LEFT); + } + + // Layout the Panel + final JPanel panel = createStandardPanel("UsedPartsMultiplierPanel", true, + "UsedPartsMultiplierPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblUsedPartPriceMultipliers[0]) + .addComponent(spnUsedPartPriceMultipliers[0])) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblUsedPartPriceMultipliers[1]) + .addComponent(spnUsedPartPriceMultipliers[1])) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblUsedPartPriceMultipliers[2]) + .addComponent(spnUsedPartPriceMultipliers[2])) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblUsedPartPriceMultipliers[3]) + .addComponent(spnUsedPartPriceMultipliers[3])) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblUsedPartPriceMultipliers[4]) + .addComponent(spnUsedPartPriceMultipliers[4])) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblUsedPartPriceMultipliers[5]) + .addComponent(spnUsedPartPriceMultipliers[5]))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblUsedPartPriceMultipliers[0]) + .addComponent(spnUsedPartPriceMultipliers[0]) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblUsedPartPriceMultipliers[1]) + .addComponent(spnUsedPartPriceMultipliers[1]) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblUsedPartPriceMultipliers[2]) + .addComponent(spnUsedPartPriceMultipliers[2]) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblUsedPartPriceMultipliers[3]) + .addComponent(spnUsedPartPriceMultipliers[3]) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblUsedPartPriceMultipliers[4]) + .addComponent(spnUsedPartPriceMultipliers[4]) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblUsedPartPriceMultipliers[5]) + .addComponent(spnUsedPartPriceMultipliers[5]) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + return panel; + } + + private JPanel createOtherMultipliersPanel() { + // Contents + lblDamagedPartsValueMultiplier = createLabel("DamagedPartsValueMultiplier", null); + spnDamagedPartsValueMultiplier = createSpinner("DamagedPartsValueMultiplier", null, + 0.33, 0.00, 1.00, 0.05); + + lblUnrepairablePartsValueMultiplier = createLabel("UnrepairablePartsValueMultiplier", null); + spnUnrepairablePartsValueMultiplier = createSpinner("UnrepairablePartsValueMultiplier", null, + 0.10, 0.00, 1.00, 0.05); + + lblCancelledOrderRefundMultiplier = createLabel("CancelledOrderRefundMultiplier", null); + spnCancelledOrderRefundMultiplier = createSpinner("CancelledOrderRefundMultiplier", null, + 0.50, 0.00, 1.00, 0.05); + + // Layout the Panel + final JPanel panel = createStandardPanel("OtherMultipliersPanel", true, + "OtherMultipliersPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblDamagedPartsValueMultiplier) + .addComponent(spnDamagedPartsValueMultiplier)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblUnrepairablePartsValueMultiplier) + .addComponent(spnUnrepairablePartsValueMultiplier)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblCancelledOrderRefundMultiplier) + .addComponent(spnCancelledOrderRefundMultiplier))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblDamagedPartsValueMultiplier) + .addComponent(spnDamagedPartsValueMultiplier) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblUnrepairablePartsValueMultiplier) + .addComponent(spnUnrepairablePartsValueMultiplier) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblCancelledOrderRefundMultiplier) + .addComponent(spnCancelledOrderRefundMultiplier) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + return panel; } } From 478f0fcbbda39e3e65eb9dee692c5ae0fc65182c Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Sat, 12 Oct 2024 14:00:20 -0500 Subject: [PATCH 061/117] Add Javadoc comments for methods in `FinancesTab.java` Enhanced code documentation by adding comprehensive Javadoc comments to methods in the `FinancesTab.java` file. This includes detailed explanations for the `FinancesTab` class and its methods, improving code readability and maintainability by providing clear descriptions of their functionality and parameters. --- .../campaignOptions/tabs/FinancesTab.java | 140 +++++++++++++++++- 1 file changed, 134 insertions(+), 6 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java index 5a16674b28..8fdea951d0 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java @@ -13,6 +13,20 @@ import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; +/** + * This class represents the FinancesTab campaign options, configuring finance-related settings. + * It provides panels including: + *
    + *
  • {@code GeneralOptions}
  • + *
  • {@code Payments}
  • + *
  • {@code Sales}
  • + *
  • {@code OtherSystems}
  • + *
  • {@code PriceMultipliers}
  • + *
+ * Each panel has form components for user input. + *

+ * Requires a valid {@link Campaign} and {@link JFrame} instances. + */ public class FinancesTab { Campaign campaign; JFrame frame; @@ -82,9 +96,15 @@ public class FinancesTab { private JSpinner spnUnrepairablePartsValueMultiplier; private JLabel lblCancelledOrderRefundMultiplier; private JSpinner spnCancelledOrderRefundMultiplier; - //end Price Multipliers + /** + * Constructs a new 'FinancesTab' instance, initializes its internal state, and sets up its user interface. + * + * @param campaign The {@link Campaign} instance associated with this tab. + * @param frame The parent {@link JFrame} in which this tab is displayed. + * @param name The name to be given to this tab. + */ FinancesTab(Campaign campaign, JFrame frame, String name) { this.campaign = campaign; this.frame = frame; @@ -93,11 +113,21 @@ public class FinancesTab { initialize(); } + /** + * Initializes the user interface elements of the component. + * It calls other initialization methods such as {@link #initializeGeneralOptionsTab()} and {@link #initializePriceMultipliersTab()} + * for setting up specific parts of the interface. + */ private void initialize() { initializeGeneralOptionsTab(); initializePriceMultipliersTab(); } + /** + * Initializes all components for the 'GeneralOptionsTab'. + * This includes setting up panels for General Options, Payments, Sales and Other Systems. + * Each panel contains various checkboxes and user interface elements for user interaction. + */ private void initializeGeneralOptionsTab() { // General Options pnlGeneralOptions = new JPanel(); @@ -109,7 +139,7 @@ private void initializeGeneralOptionsTab() { lblFinancialYearDuration = new JLabel(); comboFinancialYearDuration = new MMComboBox<>("comboFinancialYearDuration", - getFinancialYearDurationOptions()); + FinancialYearDuration.values()); newFinancialYearFinancesToCSVExportBox = new JCheckBox(); @@ -143,10 +173,13 @@ private void initializeGeneralOptionsTab() { chkSharesForAll = new JCheckBox(); } - private static DefaultComboBoxModel getFinancialYearDurationOptions() { - return new DefaultComboBoxModel<>(FinancialYearDuration.values()); - } - + /** + * Constructs and returns a {@link JPanel} for the 'FinancesGeneralTab'. + * This tab includes 'GeneralOptions', 'Payments', 'Sales', and 'OtherSystems' panels that are + * organized using {@link GroupLayout}. A header is also included in the layout. + * + * @return {@link JPanel} representing the 'Finances General' tab. + */ JPanel createFinancesGeneralOptionsTab() { // Header JPanel headerPanel = createHeaderPanel("FinancesGeneralTab", @@ -189,6 +222,13 @@ JPanel createFinancesGeneralOptionsTab() { return createParentPanel(panel, "FinancesGeneralTab"); } + /** + * Constructs and returns a {@link JPanel} for the 'PaymentsPanel'. + * This panel contains checkboxes for different payment categories, organized into two rows + * within a {@link GroupLayout}. + * + * @return {@link JPanel} representing the 'Payments' panel. + */ private JPanel createPaymentsPanel() { // Contents payForPartsBox = createCheckBox("PayForPartsBox", null); @@ -244,6 +284,12 @@ private JPanel createPaymentsPanel() { return panel; } + /** + * Constructs and returns a {@link JPanel} for the 'OtherSystemsPanel'. + * This panel includes 'Taxes' and 'Shares' panels, arranged vertically within a {@link GroupLayout}. + * + * @return {@link JPanel} representing the 'Other Systems' panel. + */ private JPanel createOtherSystemsPanel() { // Contents pnlTaxes = createTaxesPanel(); @@ -267,6 +313,14 @@ private JPanel createOtherSystemsPanel() { return panel; } + /** + * Constructs and returns a {@link JPanel} for the 'GeneralOptionsPanel'. This panel contains + * checkboxes for various options, a label displaying financial year duration, + * and a combo box to select the financial year duration. + * The components are arranged vertically within a {@link GroupLayout}. + * + * @return {@link JPanel} representing the 'General Options' panel. + */ private JPanel createGeneralOptionsPanel() { // Contents useLoanLimitsBox = createCheckBox("UseLoanLimitsBox", null); @@ -313,6 +367,13 @@ private JPanel createGeneralOptionsPanel() { return panel; } + /** + * Constructs and returns a {@link JPanel} for the 'SalesPanel'. + * This panel contains two checkboxes - 'SellUnitsBox' and 'SellPartsBox', + * organized in a horizontal arrangement within a {@link GroupLayout}. + * + * @return {@link JPanel} representing the 'Sales' panel. + */ private JPanel createSalesPanel() { // Contents sellUnitsBox = createCheckBox("SellUnitsBox", null); @@ -341,6 +402,14 @@ private JPanel createSalesPanel() { return panel; } + /** + * Creates and returns a {@link JPanel} for the 'TaxesPanel'. + * This panel includes a checkbox for activating/deactivating taxes and + * a label and spinner for adjusting the tax percentage. These components are organized + * vertically in a {@link GroupLayout}. + * + * @return {@link JPanel} representing the 'Taxes' panel. + */ private JPanel createTaxesPanel() { // Contents chkUseTaxes = createCheckBox("UseTaxesBox", null); @@ -373,6 +442,13 @@ private JPanel createTaxesPanel() { return panel; } + /** + * Creates and returns a {@link JPanel} for the 'SharesPanel'. + * This panel includes two check boxes - 'UseShareSystem', and 'SharesForAll' arranged vertically + * in a {@link GroupLayout}. + * + * @return {@link JPanel} representing the 'Shares' panel. + */ private JPanel createSharesPanel() { // Contents chkUseShareSystem = createCheckBox("UseShareSystem", null); @@ -397,6 +473,12 @@ private JPanel createSharesPanel() { return panel; } + /** + * Initializes the components of the 'PriceMultipliersTab'. + * This method assigns new instances of {@link JPanel}, {@link JLabel}, and {@link JSpinner} + * to the panel and its accompanying components for 'General Multipliers', + * 'Used Parts Multipliers', and 'Other Multipliers'. + */ private void initializePriceMultipliersTab() { pnlGeneralMultipliers = new JPanel(); lblCommonPartPriceMultiplier = new JLabel(); @@ -425,6 +507,14 @@ private void initializePriceMultipliersTab() { spnCancelledOrderRefundMultiplier = new JSpinner(); } + /** + * Constructs and returns a {@link JPanel} for the 'PriceMultipliersTab'. + * This tab comprises a header panel and three individual sections - 'General Multipliers', + * 'Used Parts Multipliers', and 'Other Multipliers'. These sections are vertically aligned + * using a {@link GroupLayout}. + * + * @return {@link JPanel} that constitutes the 'Price Multipliers' tab. + */ JPanel createPriceMultipliersTab() { // Header JPanel headerPanel = createHeaderPanel("PriceMultipliersTab", @@ -463,6 +553,14 @@ JPanel createPriceMultipliersTab() { return createParentPanel(panel, "PriceMultipliersTab"); } + /** + * Creates a {@link JPanel} for entering general multipliers with labeled spinners. + * The panel groups together spinners for entering multipliers for multiple categories like 'CommonPart', + * 'InnerSphereUnit', 'InnerSpherePart', 'ClanUnit', 'ClanPart', and 'MixedTechUnit'. + * Each category has its own row with the respective label and spinner. + * + * @return {@link JPanel} representing the 'General Multipliers' panel. + */ private JPanel createGeneralMultipliersPanel() { // Contents lblCommonPartPriceMultiplier = createLabel("CommonPartPriceMultiplier", null); @@ -546,6 +644,24 @@ private JPanel createGeneralMultipliersPanel() { return panel; } + /** + * Creates and returns a {@link JPanel} representing the 'Used Parts Multiplier' panel. + *

+ * The {@link JPanel} includes numerous pairs of {@link JLabel} and {@link JSpinner} components, + * each associated with a particular 'quality' level of the used parts. + * Each {@link JLabel} is named according to the quality level. + * Each {@link JSpinner} is initialized with a {@link SpinnerNumberModel} for inputting numbers with + * a range of 0.00 to 1.00, and a step increment of 0.05. + *

+ * The 'quality' levels range from 'QUALITY_A' to 'QUALITY_F', as defined in the Part class. + * These different quality levels represent different conditions of used parts. + *

+ * The {@link JPanel} uses a {@link GroupLayout} to arrange its components. + * Vertically, each {@link JLabel} is paired alongside its corresponding {@link JSpinner}. + * Horizontally, each {@link JLabel}-{@link JSpinner} pair is in a row of its own. + * + * @return {@link JPanel} representing the 'Used Parts Multiplier' panel. + */ private JPanel createUsedPartsMultiplierPanel() { boolean reverseQualities = campaign.getCampaignOptions().isReverseQualityNames(); @@ -626,6 +742,18 @@ private JPanel createUsedPartsMultiplierPanel() { return panel; } + /** + * Creates and returns a {@link JPanel} that includes various spinners associated with different multipliers. + * These multipliers include "Damaged Parts Value Multiplier", "Unrepairable Parts Value Multiplier", + * and "Cancelled Order Refund Multiplier". Each of these multipliers has their own label and + * corresponding spinner for input. + *

+ * The layout of the panel is organized so that each label is directly paired with its corresponding + * spinner horizontally. Vertically, the pairs are stacked on top of each other in the order that they + * were added to the panel. + * + * @return {@link JPanel} representing the 'Other Multipliers' panel. + */ private JPanel createOtherMultipliersPanel() { // Contents lblDamagedPartsValueMultiplier = createLabel("DamagedPartsValueMultiplier", null); From 01a7bac754fa2bf483308405d002fa227f5e3e19 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Sat, 12 Oct 2024 14:50:03 -0500 Subject: [PATCH 062/117] Add MarketsTab functionality Implemented a new MarketsTab in the CampaignOptionsPane, including a Personnel Market options panel with various configuration settings. Updated the relevant properties file to support the new tab and its features. --- .../NEWCampaignOptionsDialog.properties | 32 +- .../tabs/CampaignOptionsPane.java | 8 + .../campaignOptions/tabs/MarketsTab.java | 298 ++++++++++++++++++ 3 files changed, 337 insertions(+), 1 deletion(-) create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 90189cc6a6..99c67d3ab5 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -1113,4 +1113,34 @@ lblDamagedPartsValueMultiplier.tooltip=PLACEHOLDER lblUnrepairablePartsValueMultiplier.text=Irreparable Parts lblUnrepairablePartsValueMultiplier.tooltip=PLACEHOLDER lblCancelledOrderRefundMultiplier.text=Cancelled Order Refund -lblCancelledOrderRefundMultiplier.tooltip=PLACEHOLDER \ No newline at end of file +lblCancelledOrderRefundMultiplier.tooltip=PLACEHOLDER + +# Markets Tab +marketsContentTabs.title=Markets + +personnelMarketTab.title=Personnel +personnelMarketTab.border="Every hiring hall is filled with possibilities. Behind every handshake is\ + \ a story waiting to unfold - and sometimes, those stories shape the galaxy."\ +
- Sergeant Max "Rustbucket" Carver, Steel Fangs Mercenaries + +# createPersonnelMarketTab +lblPersonnelMarketTab.text=Personnel Market Options +lblPersonnelMarketTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam + +# createPersonnelMarketGeneralOptionsPanel +lblPersonnelMarketType.text=Market Method +lblPersonnelMarketType.tooltip=PLACEHOLDER +lblPersonnelMarketDylansWeight.text=Common Unit Type Weight +lblPersonnelMarketDylansWeight.tooltip=PLACEHOLDER +lblPersonnelMarketReportRefresh.text=Post Report on Market Refresh +lblPersonnelMarketReportRefresh.tooltip=PLACEHOLDER +lblUsePersonnelHireHiringHallOnly.text=Hiring Halls & Capitals Only +lblUsePersonnelHireHiringHallOnly.tooltip=PLACEHOLDER + +# createPersonnelMarketRemovalOptionsPanel +lblPersonnelMarketRemovalOptionsPanel.text=Removal Target Numbers \ No newline at end of file diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index 2f1d579e88..d085d2401c 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -213,6 +213,12 @@ private JTabbedPane createStrategicOperationsParentTab() { "financesGeneralTab", financesTab.createFinancesGeneralOptionsTab(), "priceMultipliersTab", financesTab.createPriceMultipliersTab())); + // Markets + MarketsTab marketsTab = new MarketsTab(getFrame(), "marketsTab"); + + JTabbedPane marketsContentTabs = createSubTabs(Map.of( + "personnelMarketTab", marketsTab.createPersonnelMarketTab())); + // Markets + Mercenary (don't forget useInfantryDoseNotCountBox) // Rulesets @@ -220,6 +226,8 @@ private JTabbedPane createStrategicOperationsParentTab() { // Add tabs strategicOperationsParentTab.addTab(String.format("%s", 4, resources.getString("financesContentTabs.title")), financesContentTabs); + strategicOperationsParentTab.addTab(String.format("%s", 4, + resources.getString("marketsContentTabs.title")), marketsContentTabs); addTab(String.format("%s", 4, resources.getString("strategicOperationsParentTab.title")), strategicOperationsParentTab); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java new file mode 100644 index 0000000000..87da57bdc8 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java @@ -0,0 +1,298 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +import megamek.client.ui.baseComponents.MMComboBox; +import megamek.common.enums.SkillLevel; +import mekhq.campaign.personnel.Skills; +import mekhq.module.PersonnelMarketServiceManager; +import mekhq.module.api.PersonnelMarketMethod; + +import javax.swing.*; +import javax.swing.GroupLayout.Alignment; +import javax.swing.JSpinner.DefaultEditor; +import java.util.HashMap; +import java.util.Map; + +import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; + +public class MarketsTab { + JFrame frame; + String name; + + //start Personnel Market + private JPanel pnlPersonnelMarketGeneralOptions; + private JLabel lblPersonnelMarketType; + private MMComboBox comboPersonnelMarketType; + private JCheckBox chkPersonnelMarketReportRefresh; + private JCheckBox chkUsePersonnelHireHiringHallOnly; + + private JPanel pnlRemovalTargets; + private JLabel lblPersonnelMarketDylansWeight; + private JSpinner spnPersonnelMarketDylansWeight; + private Map lblPersonnelMarketRandomRemovalTargets; + private Map spnPersonnelMarketRandomRemovalTargets; + //end Personnel Market + + //start Unit Market + //end Unit Market + + //start Contract Market + //end Contract Market + + MarketsTab(JFrame frame, String name) { + this.frame = frame; + this.name = name; + + initialize(); + } + + private void initialize() { + initializePersonnelMarket(); + initializeUnitMarket(); + initializeContractMarket(); + } + + private void initializePersonnelMarket() { + pnlPersonnelMarketGeneralOptions = new JPanel(); + lblPersonnelMarketType = new JLabel(); + comboPersonnelMarketType = new MMComboBox<>("comboPersonnelMarketType", + getPersonnelMarketTypeOptions()); + chkPersonnelMarketReportRefresh = new JCheckBox(); + chkUsePersonnelHireHiringHallOnly = new JCheckBox(); + + pnlRemovalTargets = new JPanel(); + lblPersonnelMarketDylansWeight = new JLabel(); + spnPersonnelMarketDylansWeight = new JSpinner(); + lblPersonnelMarketRandomRemovalTargets = new HashMap<>(); + spnPersonnelMarketRandomRemovalTargets = new HashMap<>(); + } + + private static DefaultComboBoxModel getPersonnelMarketTypeOptions() { + final DefaultComboBoxModel personnelMarketTypeModel = new DefaultComboBoxModel<>(); + for (final PersonnelMarketMethod method : PersonnelMarketServiceManager.getInstance() + .getAllServices(true)) { + personnelMarketTypeModel.addElement(method.getModuleName()); + } + return personnelMarketTypeModel; + } + + JPanel createPersonnelMarketTab() { + // Header + JPanel headerPanel = createHeaderPanel("PersonnelMarketTab", + getImageDirectory() + "logo_clan_sea_fox.png", + false, "", true); + + // Contents + pnlPersonnelMarketGeneralOptions = createPersonnelMarketGeneralOptionsPanel(); + pnlRemovalTargets = createPersonnelMarketRemovalOptionsPanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("PersonnelMarketTab", true, + ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(pnlPersonnelMarketGeneralOptions) + .addComponent(pnlRemovalTargets))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addGroup(layout.createSequentialGroup() + .addComponent(pnlPersonnelMarketGeneralOptions) + .addComponent(pnlRemovalTargets) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + // Create Parent Panel and return + return createParentPanel(panel, "PersonnelMarketTab"); + } + + private JPanel createPersonnelMarketGeneralOptionsPanel() { + // Contents + lblPersonnelMarketType = createLabel("PersonnelMarketType", null); + comboPersonnelMarketType = new MMComboBox<>("comboPersonnelMarketType", + getPersonnelMarketTypeOptions()); + + lblPersonnelMarketDylansWeight = createLabel("PersonnelMarketDylansWeight", null); + spnPersonnelMarketDylansWeight = createSpinner("PersonnelMarketDylansWeight", null, + 0.3, 0, 1, 0.1); + + chkPersonnelMarketReportRefresh = createCheckBox("PersonnelMarketReportRefresh", null); + + chkUsePersonnelHireHiringHallOnly = createCheckBox("UsePersonnelHireHiringHallOnly", null); + + // Layout the Panel + final JPanel panel = createStandardPanel("PersonnelMarketGeneralOptionsPanel", false, + ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPersonnelMarketType) + .addComponent(comboPersonnelMarketType)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPersonnelMarketDylansWeight) + .addComponent(spnPersonnelMarketDylansWeight)) + .addComponent(chkPersonnelMarketReportRefresh) + .addComponent(chkUsePersonnelHireHiringHallOnly)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblPersonnelMarketType) + .addComponent(comboPersonnelMarketType) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblPersonnelMarketDylansWeight) + .addComponent(spnPersonnelMarketDylansWeight) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkPersonnelMarketReportRefresh) + .addComponent(chkUsePersonnelHireHiringHallOnly)); + + return panel; + } + + private JPanel createPersonnelMarketRemovalOptionsPanel() { + // Contents + for (final SkillLevel skillLevel : Skills.SKILL_LEVELS) { + final JLabel jLabel = new JLabel(skillLevel.toString()); + lblPersonnelMarketRandomRemovalTargets.put(skillLevel, jLabel); + + final JSpinner jSpinner = new JSpinner( + new SpinnerNumberModel(0, 0, 12, 1)); + + DefaultEditor editor = (DefaultEditor) jSpinner.getEditor(); + editor.getTextField().setHorizontalAlignment(JTextField.LEFT); + + spnPersonnelMarketRandomRemovalTargets.put(skillLevel, jSpinner); + } + + // Layout the Panels + final JPanel leftPanel = createStandardPanel("LeftPanel", false, ""); + final GroupLayout leftLayout = createStandardLayout(leftPanel); + leftPanel.setLayout(leftLayout); + + leftLayout.setVerticalGroup( + leftLayout.createSequentialGroup() + .addGroup(leftLayout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.NONE)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.NONE))) + .addGroup(leftLayout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.ULTRA_GREEN)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.ULTRA_GREEN))) + .addGroup(leftLayout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.GREEN)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.GREEN))) + .addGroup(leftLayout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.REGULAR)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.REGULAR)))); + + leftLayout.setHorizontalGroup( + leftLayout.createParallelGroup(Alignment.LEADING) + .addGroup(leftLayout.createSequentialGroup() + .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.NONE)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.NONE)) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(leftLayout.createSequentialGroup() + .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.ULTRA_GREEN)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.ULTRA_GREEN)) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(leftLayout.createSequentialGroup() + .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.GREEN)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.GREEN)) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(leftLayout.createSequentialGroup() + .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.REGULAR)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.REGULAR)) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + final JPanel rightPanel = createStandardPanel("RightPanel", false, ""); + final GroupLayout rightLayout = createStandardLayout(rightPanel); + rightPanel.setLayout(rightLayout); + + rightLayout.setVerticalGroup( + rightLayout.createSequentialGroup() + .addGroup(rightLayout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.VETERAN)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.VETERAN))) + .addGroup(rightLayout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.ELITE)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.ELITE))) + .addGroup(rightLayout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.HEROIC)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.HEROIC))) + .addGroup(rightLayout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.LEGENDARY)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.LEGENDARY)))); + + rightLayout.setHorizontalGroup( + rightLayout.createParallelGroup(Alignment.LEADING) + .addGroup(rightLayout.createSequentialGroup() + .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.VETERAN)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.VETERAN)) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(rightLayout.createSequentialGroup() + .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.ELITE)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.ELITE)) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(rightLayout.createSequentialGroup() + .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.HEROIC)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.HEROIC)) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(rightLayout.createSequentialGroup() + .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.LEGENDARY)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.LEGENDARY)) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + final JPanel parentPanel = createStandardPanel("PersonnelMarketRemovalOptionsPanel", + true, "PersonnelMarketRemovalOptionsPanel"); + final GroupLayout parentLayout = createStandardLayout(parentPanel); + parentPanel.setLayout(parentLayout); + + parentLayout.setVerticalGroup( + parentLayout.createSequentialGroup() + .addGroup(parentLayout.createParallelGroup(Alignment.BASELINE) + .addComponent(leftPanel) + .addComponent(rightPanel))); + + parentLayout.setHorizontalGroup( + parentLayout.createParallelGroup(Alignment.LEADING) + .addGroup(parentLayout.createSequentialGroup() + .addComponent(leftPanel) + .addComponent(rightPanel) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + return parentPanel; + } + + private void initializeUnitMarket() { + + } + + JPanel createUnitMarketTab() { + // Header + JPanel headerPanel = createHeaderPanel("PriceMultipliersTab", + getImageDirectory() + "logo_clan_sea_fox.png", + false, "", true); + + return null; + } + + private void initializeContractMarket() { + + } + + JPanel createContractMarketTab() { + // Header + JPanel headerPanel = createHeaderPanel("PriceMultipliersTab", + getImageDirectory() + "logo_loathian_league.png", + false, "", true); + + return null; + } +} From 30f38f382e48559e74b415a696537aa65208fccf Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Sat, 12 Oct 2024 15:14:20 -0500 Subject: [PATCH 063/117] Refactor checkbox and spinner creation methods Updated the methods for creating checkboxes and spinners to remove redundant arguments. Refactored the relevant code in the GUI panels to use these streamlined methods for clarity and simplicity. This change improves code readability and maintainability. --- .../campaignOptions/tabs/BiographyTab.java | 122 +++++++------- .../tabs/CampaignOptionsUtilities.java | 23 ++- .../tabs/EquipmentAndSuppliesTab.java | 74 ++++----- .../campaignOptions/tabs/FinancesTab.java | 39 +++-- .../campaignOptions/tabs/PersonnelTab.java | 156 +++++++++--------- .../tabs/RelationshipsTab.java | 78 ++++----- .../tabs/RepairAndMaintenanceTab.java | 46 +++--- .../tabs/TurnoverAndRetentionTab.java | 108 ++++++------ 8 files changed, 328 insertions(+), 318 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java index e37cd92bcf..8efe9b490c 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java @@ -326,19 +326,19 @@ JPanel createGeneralTab() { false, "", true); // Contents - chkUseDylansRandomXP = createCheckBox("UseDylansRandomXP", null); + chkUseDylansRandomXP = createCheckBox("UseDylansRandomXP"); - lblGender = createLabel("Gender", null); + lblGender = createLabel("Gender"); sldGender = new JSlider(SwingConstants.HORIZONTAL, 0, 100, RandomGenderGenerator.getPercentFemale()); sldGender.setMajorTickSpacing(25); sldGender.setPaintTicks(true); sldGender.setPaintLabels(true); - lblNonBinaryDiceSize = createLabel("NonBinaryDiceSize", null); - spnNonBinaryDiceSize = createSpinner("NonBinaryDiceSize", null, + lblNonBinaryDiceSize = createLabel("NonBinaryDiceSize"); + spnNonBinaryDiceSize = createSpinner("NonBinaryDiceSize", 60, 0, 100000, 1); - lblFamilyDisplayLevel = createLabel("FamilyDisplayLevel", null); + lblFamilyDisplayLevel = createLabel("FamilyDisplayLevel"); pnlAnniversariesPanel = createAnniversariesPanel(); @@ -390,10 +390,10 @@ JPanel createGeneralTab() { */ private JPanel createAnniversariesPanel() { // Contents - chkAnnounceBirthdays = createCheckBox("AnnounceBirthdays", null); - chkAnnounceRecruitmentAnniversaries = createCheckBox("AnnounceRecruitmentAnniversaries", null); - chkAnnounceOfficersOnly = createCheckBox("AnnounceOfficersOnly", null); - chkAnnounceChildBirthdays = createCheckBox("AnnounceChildBirthdays", null); + chkAnnounceBirthdays = createCheckBox("AnnounceBirthdays"); + chkAnnounceRecruitmentAnniversaries = createCheckBox("AnnounceRecruitmentAnniversaries"); + chkAnnounceOfficersOnly = createCheckBox("AnnounceOfficersOnly"); + chkAnnounceChildBirthdays = createCheckBox("AnnounceChildBirthdays"); // Layout the Panel final JPanel panel = createStandardPanel("AnniversariesPanel", true, @@ -430,10 +430,10 @@ JPanel createBackgroundsTab() { false, "", true); // Contents - chkUseRandomPersonalities = createCheckBox("UseRandomPersonalities", null); - chkUseRandomPersonalityReputation = createCheckBox("UseRandomPersonalityReputation", null); - chkUseIntelligenceXpMultiplier = createCheckBox("UseIntelligenceXpMultiplier", null); - chkUseSimulatedRelationships = createCheckBox("UseSimulatedRelationships", null); + chkUseRandomPersonalities = createCheckBox("UseRandomPersonalities"); + chkUseRandomPersonalityReputation = createCheckBox("UseRandomPersonalityReputation"); + chkUseIntelligenceXpMultiplier = createCheckBox("UseIntelligenceXpMultiplier"); + chkUseSimulatedRelationships = createCheckBox("UseSimulatedRelationships"); pnlRandomOriginOptions = createRandomOriginOptionsPanel(); @@ -472,13 +472,11 @@ JPanel createBackgroundsTab() { */ private JPanel createRandomOriginOptionsPanel() { // Contents - chkRandomizeOrigin = createCheckBox("RandomizeOrigin", null); - chkRandomizeDependentsOrigin = createCheckBox("RandomizeDependentsOrigin", null); - chkRandomizeAroundSpecifiedPlanet = createCheckBox("RandomizeAroundSpecifiedPlanet", - null); + chkRandomizeOrigin = createCheckBox("RandomizeOrigin"); + chkRandomizeDependentsOrigin = createCheckBox("RandomizeDependentsOrigin"); + chkRandomizeAroundSpecifiedPlanet = createCheckBox("RandomizeAroundSpecifiedPlanet"); - chkSpecifiedSystemFactionSpecific = createCheckBox("SpecifiedSystemFactionSpecific", - null); + chkSpecifiedSystemFactionSpecific = createCheckBox("SpecifiedSystemFactionSpecific"); chkSpecifiedSystemFactionSpecific.addActionListener(evt -> { final PlanetarySystem planetarySystem = comboSpecifiedSystem.getSelectedItem(); if ((planetarySystem == null) @@ -488,7 +486,7 @@ private JPanel createRandomOriginOptionsPanel() { }); - lblSpecifiedSystem = createLabel("SpecifiedSystem", null); + lblSpecifiedSystem = createLabel("SpecifiedSystem"); comboSpecifiedSystem.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, @@ -510,7 +508,7 @@ public Component getListCellRendererComponent(final JList list, final Object } }); - lblSpecifiedPlanet = createLabel("SpecifiedPlanet", null); + lblSpecifiedPlanet = createLabel("SpecifiedPlanet"); comboSpecifiedPlanet.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, @@ -524,16 +522,16 @@ public Component getListCellRendererComponent(final JList list, final Object } }); - lblOriginSearchRadius = createLabel("OriginSearchRadius", null); - spnOriginSearchRadius = createSpinner("OriginSearchRadius", null, + lblOriginSearchRadius = createLabel("OriginSearchRadius"); + spnOriginSearchRadius = createSpinner("OriginSearchRadius", 0, 0, 2000, 25); - lblOriginDistanceScale = createLabel("OriginDistanceScale", null); - spnOriginDistanceScale = createSpinner("OriginDistanceScale", null, + lblOriginDistanceScale = createLabel("OriginDistanceScale"); + spnOriginDistanceScale = createSpinner("OriginDistanceScale", 0.6, 0.1, 2.0, 0.1); - chkAllowClanOrigins = createCheckBox("AllowClanOrigins", null); - chkExtraRandomOrigin = createCheckBox("ExtraRandomOrigin", null); + chkAllowClanOrigins = createCheckBox("AllowClanOrigins"); + chkExtraRandomOrigin = createCheckBox("ExtraRandomOrigin"); // Layout the Panel final JPanel panel = createStandardPanel("RandomOriginOptionsPanel", true, @@ -656,10 +654,9 @@ JPanel createDeathTab() { false, "", true); // Contents - chkKeepMarriedNameUponSpouseDeath = createCheckBox("KeepMarriedNameUponSpouseDeath", - null); + chkKeepMarriedNameUponSpouseDeath = createCheckBox("KeepMarriedNameUponSpouseDeath"); - lblRandomDeathMethod = createLabel("RandomDeathMethod", null); + lblRandomDeathMethod = createLabel("RandomDeathMethod"); comboRandomDeathMethod.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, @@ -673,15 +670,14 @@ public Component getListCellRendererComponent(final JList list, final Object } }); - chkUseRandomClanPersonnelDeath = createCheckBox("UseRandomClanPersonnelDeath", - null); - chkUseRandomPrisonerDeath = createCheckBox("UseRandomPrisonerDeath", null); - chkUseRandomDeathSuicideCause = createCheckBox("UseRandomDeathSuicideCause", null); + chkUseRandomClanPersonnelDeath = createCheckBox("UseRandomClanPersonnelDeath"); + chkUseRandomPrisonerDeath = createCheckBox("UseRandomPrisonerDeath"); + chkUseRandomDeathSuicideCause = createCheckBox("UseRandomDeathSuicideCause"); pnlDeathAgeGroup = createDeathAgeGroupsPanel(); - lblPercentageRandomDeathChance = createLabel("PercentageRandomDeathChance", null); - spnPercentageRandomDeathChance = createSpinner("PercentageRandomDeathChance", null, + lblPercentageRandomDeathChance = createLabel("PercentageRandomDeathChance"); + spnPercentageRandomDeathChance = createSpinner("PercentageRandomDeathChance", 0, 0, 100, 0.000001); // Layout the Panel @@ -774,28 +770,28 @@ JPanel createEducationTab() { false, "", true); // Contents - chkUseEducationModule = createCheckBox("UseEducationModule", null); + chkUseEducationModule = createCheckBox("UseEducationModule"); - lblCurriculumXpRate = createLabel("CurriculumXpRate", null); - spnCurriculumXpRate = createSpinner("CurriculumXpRate", null, + lblCurriculumXpRate = createLabel("CurriculumXpRate"); + spnCurriculumXpRate = createSpinner("CurriculumXpRate", 3, 1, 10, 1); - lblMaximumJumpCount = createLabel("MaximumJumpCount", null); - spnMaximumJumpCount = createSpinner("MaximumJumpCount", null, + lblMaximumJumpCount = createLabel("MaximumJumpCount"); + spnMaximumJumpCount = createSpinner("MaximumJumpCount", 5, 1, 200, 1); - chkUseReeducationCamps = createCheckBox("UseReeducationCamps", null); + chkUseReeducationCamps = createCheckBox("UseReeducationCamps"); pnlEnableStandardSets = createEnableStandardSetsPanel(); - chkEnableOverrideRequirements = createCheckBox("EnableOverrideRequirements", null); + chkEnableOverrideRequirements = createCheckBox("EnableOverrideRequirements"); - chkShowIneligibleAcademies = createCheckBox("ShowIneligibleAcademies", null); + chkShowIneligibleAcademies = createCheckBox("ShowIneligibleAcademies"); - lblEntranceExamBaseTargetNumber = createLabel("EntranceExamBaseTargetNumber", null); - spnEntranceExamBaseTargetNumber = createSpinner("EntranceExamBaseTargetNumber", null, + lblEntranceExamBaseTargetNumber = createLabel("EntranceExamBaseTargetNumber"); + spnEntranceExamBaseTargetNumber = createSpinner("EntranceExamBaseTargetNumber", 14, 0, 20, 1); - lblEntranceExamBaseTargetNumberPost = createLabel("EntranceExamBaseTargetNumberPost", null); + lblEntranceExamBaseTargetNumberPost = createLabel("EntranceExamBaseTargetNumberPost"); pnlXpAndSkillBonuses = createXpAndSkillBonusesPanel(); @@ -874,9 +870,9 @@ JPanel createEducationTab() { */ private JPanel createEnableStandardSetsPanel() { // Contents - chkEnableLocalAcademies = createCheckBox("EnableLocalAcademies", null); - chkEnablePrestigiousAcademies = createCheckBox("EnablePrestigiousAcademies", null); - chkEnableUnitEducation = createCheckBox("EnableUnitEducation", null); + chkEnableLocalAcademies = createCheckBox("EnableLocalAcademies"); + chkEnablePrestigiousAcademies = createCheckBox("EnablePrestigiousAcademies"); + chkEnableUnitEducation = createCheckBox("EnableUnitEducation"); // Layout the Panel final JPanel panel = createStandardPanel("EnableStandardSetsPanel", true, @@ -916,9 +912,9 @@ private JPanel createEnableStandardSetsPanel() { */ private JPanel createXpAndSkillBonusesPanel() { // Contents - chkEnableBonuses = createCheckBox("EnableBonuses", null); - lblFacultyXpMultiplier = createLabel("FacultyXpMultiplier", null); - spnFacultyXpMultiplier = createSpinner("FacultyXpMultiplier", null, + chkEnableBonuses = createCheckBox("EnableBonuses"); + lblFacultyXpMultiplier = createLabel("FacultyXpMultiplier"); + spnFacultyXpMultiplier = createSpinner("FacultyXpMultiplier", 1.00, 0.00, 10.00, 0.01); // Layout the Panel @@ -958,11 +954,11 @@ private JPanel createXpAndSkillBonusesPanel() { */ private JPanel createDropoutChancePanel() { // Contents - lblAdultDropoutChance = createLabel("AdultDropoutChance", null); - spnAdultDropoutChance = createSpinner("AdultDropoutChance", null, + lblAdultDropoutChance = createLabel("AdultDropoutChance"); + spnAdultDropoutChance = createSpinner("AdultDropoutChance", 1000, 0, 100000, 1); - lblChildrenDropoutChance = createLabel("ChildrenDropoutChance", null); - spnChildrenDropoutChance = createSpinner("ChildrenDropoutChance", null, + lblChildrenDropoutChance = createLabel("ChildrenDropoutChance"); + spnChildrenDropoutChance = createSpinner("ChildrenDropoutChance", 10000, 0, 100000, 1); // Layout the Panel @@ -1008,9 +1004,9 @@ private JPanel createDropoutChancePanel() { */ private JPanel createAccidentsAndEventsPanel() { // Contents - chkAllAges = createCheckBox("AllAges", null); - lblMilitaryAcademyAccidents = createLabel("MilitaryAcademyAccidents", null); - spnMilitaryAcademyAccidents = createSpinner("MilitaryAcademyAccidents", null, + chkAllAges = createCheckBox("AllAges"); + lblMilitaryAcademyAccidents = createLabel("MilitaryAcademyAccidents"); + spnMilitaryAcademyAccidents = createSpinner("MilitaryAcademyAccidents", 10000, 0, 100000, 1); // Layout the Panel @@ -1057,13 +1053,13 @@ JPanel createNameAndPortraitGenerationTab() { false, "", true); // Contents - chkUseOriginFactionForNames = createCheckBox("UseOriginFactionForNames", null); + chkUseOriginFactionForNames = createCheckBox("UseOriginFactionForNames"); - lblFactionNames = createLabel("FactionNames", null); + lblFactionNames = createLabel("FactionNames"); pnlRandomPortrait = createRandomPortraitPanel(); - chkAssignPortraitOnRoleChange = createCheckBox("AssignPortraitOnRoleChange", null); + chkAssignPortraitOnRoleChange = createCheckBox("AssignPortraitOnRoleChange"); // Layout the Panel final JPanel panel = createStandardPanel("NameAndPortraitGenerationTab", true, diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index 6e1739946d..96f77005eb 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -3,7 +3,6 @@ import megamek.client.ui.swing.util.FlatLafStyleBuilder; import megamek.client.ui.swing.util.UIUtil; import megamek.common.annotations.Nullable; -import megamek.logging.MMLogger; import mekhq.MHQConstants; import javax.swing.*; @@ -18,7 +17,6 @@ import static megamek.client.ui.WrapLayout.wordWrap; public class CampaignOptionsUtilities { - private static final MMLogger logger = MMLogger.create(CampaignOptionsPane.class); private static final String RESOURCE_PACKAGE = "mekhq/resources/NEWCampaignOptionsDialog"; static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE); final static String IMAGE_DIRECTORY = "data/images/universe/factions/"; @@ -30,6 +28,10 @@ static String getImageDirectory() { return IMAGE_DIRECTORY; } + static JCheckBox createCheckBox(String name) { + return createCheckBox(name, null); + } + /** * Returns a new {@link JCheckBox} object. *

@@ -56,6 +58,11 @@ static JCheckBox createCheckBox(String name, @Nullable Integer customWrapSize) { return checkBox; } + static JSpinner createSpinner(String name, double defaultValue, double minimum, double maximum, + double stepSize) { + return createSpinner(name, null, defaultValue, minimum, maximum, stepSize); + } + /** * Creates a {@link JSpinner} object. *

@@ -90,6 +97,10 @@ static JSpinner createSpinner(String name, @Nullable Integer customWrapSize, dou return jSpinner; } + static JLabel createLabel(String name) { + return createLabel(name, null); + } + /** * Creates a {@link JLabel} with the specified name and optional customWrapSize. *

@@ -118,6 +129,10 @@ static JLabel createLabel(String name, @Nullable Integer customWrapSize) { return jLabel; } + static JTextField createTextField(String name, int width) { + return createTextField(name, null, width); + } + /** * Creates a {@link JTextField} object. *

@@ -139,8 +154,8 @@ static JTextField createTextField(String name, @Nullable Integer customWrapSize, jTextField.setName("txt" + name); int preferredHeight = jTextField.getPreferredSize().height; - jTextField.setMinimumSize(new Dimension(width, preferredHeight)); - jTextField.setMaximumSize(new Dimension(width, preferredHeight)); + jTextField.setMinimumSize(new Dimension(UIUtil.scaleForGUI(width), preferredHeight)); + jTextField.setMaximumSize(new Dimension(UIUtil.scaleForGUI(width), preferredHeight)); return jTextField; } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java index 7f41a90b04..c7f8288a15 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java @@ -219,29 +219,29 @@ JPanel createAcquisitionTab() { "", true); // Acquisitions skill - lblChoiceAcquireSkill = createLabel("ChoiceAcquireSkill", null); + lblChoiceAcquireSkill = createLabel("ChoiceAcquireSkill"); // Support personnel only - chkSupportStaffOnly = createCheckBox("SupportStaffOnly", null); + chkSupportStaffOnly = createCheckBox("SupportStaffOnly"); // Clan Acquisition penalty - lblAcquireClanPenalty = createLabel("AcquireClanPenalty", null); - spnAcquireClanPenalty = createSpinner("AcquireClanPenalty", null, + lblAcquireClanPenalty = createLabel("AcquireClanPenalty"); + spnAcquireClanPenalty = createSpinner("AcquireClanPenalty", 0, 0, 13, 1); // IS Acquisition penalty - lblAcquireIsPenalty = createLabel("AcquireISPenalty", null); - spnAcquireIsPenalty = createSpinner("AcquireISPenalty", null, + lblAcquireIsPenalty = createLabel("AcquireISPenalty"); + spnAcquireIsPenalty = createSpinner("AcquireISPenalty", 0, 0, 13, 1); // Waiting Period - lblAcquireWaitingPeriod = createLabel("AcquireWaitingPeriod", null); - spnAcquireWaitingPeriod = createSpinner("AcquireWaitingPeriod", null, + lblAcquireWaitingPeriod = createLabel("AcquireWaitingPeriod"); + spnAcquireWaitingPeriod = createSpinner("AcquireWaitingPeriod", 1, 1, 365, 1); // Maximum Acquisitions - lblMaxAcquisitions = createLabel("MaxAcquisitions", null); - spnMaxAcquisitions = createSpinner("MaxAcquisitions", null, + lblMaxAcquisitions = createLabel("MaxAcquisitions"); + spnMaxAcquisitions = createSpinner("MaxAcquisitions", 0,0, 100, 1); // Layout the Panel @@ -340,29 +340,29 @@ JPanel createPlanetaryAcquisitionTab() { */ private JPanel createOptionsPanel() { // Use Planetary Acquisitions - usePlanetaryAcquisitions = createCheckBox("UsePlanetaryAcquisitions", null); + usePlanetaryAcquisitions = createCheckBox("UsePlanetaryAcquisitions"); // Max Jump Distance - lblMaxJumpPlanetaryAcquisitions = createLabel("MaxJumpPlanetaryAcquisitions", null); - spnMaxJumpPlanetaryAcquisitions = createSpinner("MaxJumpPlanetaryAcquisitions", null, + lblMaxJumpPlanetaryAcquisitions = createLabel("MaxJumpPlanetaryAcquisitions"); + spnMaxJumpPlanetaryAcquisitions = createSpinner("MaxJumpPlanetaryAcquisitions", 2, 0, 5, 1); // Faction Limits - lblPlanetaryAcquisitionsFactionLimits = createLabel("PlanetaryAcquisitionsFactionLimits", null); + lblPlanetaryAcquisitionsFactionLimits = createLabel("PlanetaryAcquisitionsFactionLimits"); // Disallow Resource Sharing (Inner Sphere) - disallowPlanetaryAcquisitionClanCrossover = createCheckBox("DisallowPlanetaryAcquisitionClanCrossover", null); + disallowPlanetaryAcquisitionClanCrossover = createCheckBox("DisallowPlanetaryAcquisitionClanCrossover"); // Disallow Resource Sharing (Clans) - disallowClanPartsFromIS = createCheckBox("DisallowClanPartsFromIS", null); + disallowClanPartsFromIS = createCheckBox("DisallowClanPartsFromIS"); // Acquisition Penalty - lblPenaltyClanPartsFromIS = createLabel("PenaltyClanPartsFromIS", null); - spnPenaltyClanPartsFromIS = createSpinner("PenaltyClanPartsFromIS", null, + lblPenaltyClanPartsFromIS = createLabel("PenaltyClanPartsFromIS"); + spnPenaltyClanPartsFromIS = createSpinner("PenaltyClanPartsFromIS", 0, 0, 12, 1); // Verbose Reporting - usePlanetaryAcquisitionsVerbose = createCheckBox("UsePlanetaryAcquisitionsVerbose", null); + usePlanetaryAcquisitionsVerbose = createCheckBox("UsePlanetaryAcquisitionsVerbose"); // Layout the Panel final JPanel panel = new JPanel(); @@ -472,7 +472,7 @@ private JPanel createModifiersPanel() { * @return the created tab panel as a {@link JPanel} */ private JPanel createTechModifiersPanel() { - JLabel techLabel = createLabel("TechLabel", null); + JLabel techLabel = createLabel("TechLabel"); techLabel.setName(String.format("

%s
%s
%s
("choiceTechLevel", getMaximumTechLevelOptions()); // Variable Tech Level - variableTechLevelBox = createCheckBox("VariableTechLevelBox", null); + variableTechLevelBox = createCheckBox("VariableTechLevelBox"); // Ammo by Type - useAmmoByTypeBox = createCheckBox("UseAmmoByTypeBox", null); + useAmmoByTypeBox = createCheckBox("UseAmmoByTypeBox"); // Layout the Panel final JPanel panel = createStandardPanel("TechLimitsTab", true, ""); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java index 8fdea951d0..b57c9093a9 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java @@ -231,14 +231,14 @@ JPanel createFinancesGeneralOptionsTab() { */ private JPanel createPaymentsPanel() { // Contents - payForPartsBox = createCheckBox("PayForPartsBox", null); - payForRepairsBox = createCheckBox("PayForRepairsBox", null); - payForUnitsBox = createCheckBox("PayForUnitsBox", null); - payForSalariesBox = createCheckBox("PayForSalariesBox", null); - payForOverheadBox = createCheckBox("PayForOverheadBox", null); - payForMaintainBox = createCheckBox("PayForMaintainBox", null); - payForTransportBox = createCheckBox("PayForTransportBox", null); - payForRecruitmentBox = createCheckBox("PayForRecruitmentBox", null); + payForPartsBox = createCheckBox("PayForPartsBox"); + payForRepairsBox = createCheckBox("PayForRepairsBox"); + payForUnitsBox = createCheckBox("PayForUnitsBox"); + payForSalariesBox = createCheckBox("PayForSalariesBox"); + payForOverheadBox = createCheckBox("PayForOverheadBox"); + payForMaintainBox = createCheckBox("PayForMaintainBox"); + payForTransportBox = createCheckBox("PayForTransportBox"); + payForRecruitmentBox = createCheckBox("PayForRecruitmentBox"); // Layout the Panel final JPanel panel = createStandardPanel("PaymentsPanel", true, @@ -323,16 +323,15 @@ private JPanel createOtherSystemsPanel() { */ private JPanel createGeneralOptionsPanel() { // Contents - useLoanLimitsBox = createCheckBox("UseLoanLimitsBox", null); - usePercentageMaintenanceBox = createCheckBox("UsePercentageMaintenanceBox", null); - useExtendedPartsModifierBox = createCheckBox("UseExtendedPartsModifierBox", null); - usePeacetimeCostBox = createCheckBox("UsePeacetimeCostBox", null); - showPeacetimeCostBox = createCheckBox("ShowPeacetimeCostBox", null); + useLoanLimitsBox = createCheckBox("UseLoanLimitsBox"); + usePercentageMaintenanceBox = createCheckBox("UsePercentageMaintenanceBox"); + useExtendedPartsModifierBox = createCheckBox("UseExtendedPartsModifierBox"); + usePeacetimeCostBox = createCheckBox("UsePeacetimeCostBox"); + showPeacetimeCostBox = createCheckBox("ShowPeacetimeCostBox"); lblFinancialYearDuration = createLabel("FinancialYearDuration", null); - newFinancialYearFinancesToCSVExportBox = createCheckBox("NewFinancialYearFinancesToCSVExportBox", - null); + newFinancialYearFinancesToCSVExportBox = createCheckBox("NewFinancialYearFinancesToCSVExportBox"); // Layout the Panel final JPanel panel = createStandardPanel("GeneralOptionsPanel", false, ""); @@ -376,8 +375,8 @@ private JPanel createGeneralOptionsPanel() { */ private JPanel createSalesPanel() { // Contents - sellUnitsBox = createCheckBox("SellUnitsBox", null); - sellPartsBox = createCheckBox("SellPartsBox", null); + sellUnitsBox = createCheckBox("SellUnitsBox"); + sellPartsBox = createCheckBox("SellPartsBox"); // Layout the Panel final JPanel panel = createStandardPanel("SalesPanel", true, @@ -412,7 +411,7 @@ private JPanel createSalesPanel() { */ private JPanel createTaxesPanel() { // Contents - chkUseTaxes = createCheckBox("UseTaxesBox", null); + chkUseTaxes = createCheckBox("UseTaxesBox"); lblTaxesPercentage = createLabel("TaxesPercentage", null); spnTaxesPercentage = createSpinner("TaxesPercentage", null, @@ -451,8 +450,8 @@ private JPanel createTaxesPanel() { */ private JPanel createSharesPanel() { // Contents - chkUseShareSystem = createCheckBox("UseShareSystem", null); - chkSharesForAll = createCheckBox("SharesForAll", null); + chkUseShareSystem = createCheckBox("UseShareSystem"); + chkSharesForAll = createCheckBox("SharesForAll"); // Layout the Panel final JPanel panel = createStandardPanel("SharesPanel", true, diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java index 8fcc5b0c2f..45d57aefbc 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java @@ -364,16 +364,16 @@ JPanel createGeneralTab() { false, "", true); // Contents - chkUseTactics = createCheckBox("UseTactics", null); - chkUseInitiativeBonus = createCheckBox("UseInitiativeBonus", null); - chkUseToughness = createCheckBox("UseToughness", null); - chkUseRandomToughness = createCheckBox("UseRandomToughness", null); - chkUseArtillery = createCheckBox("UseArtillery", null); - chkUseAbilities = createCheckBox("UseAbilities", null); - chkUseEdge = createCheckBox("UseEdge", null); - chkUseSupportEdge = createCheckBox("UseSupportEdge", null); - chkUseImplants = createCheckBox("UseImplants", null); - chkUseAlternativeQualityAveraging = createCheckBox("UseAlternativeQualityAveraging", null); + chkUseTactics = createCheckBox("UseTactics"); + chkUseInitiativeBonus = createCheckBox("UseInitiativeBonus"); + chkUseToughness = createCheckBox("UseToughness"); + chkUseRandomToughness = createCheckBox("UseRandomToughness"); + chkUseArtillery = createCheckBox("UseArtillery"); + chkUseAbilities = createCheckBox("UseAbilities"); + chkUseEdge = createCheckBox("UseEdge"); + chkUseSupportEdge = createCheckBox("UseSupportEdge"); + chkUseImplants = createCheckBox("UseImplants"); + chkUseAlternativeQualityAveraging = createCheckBox("UseAlternativeQualityAveraging"); personnelCleanUpPanel = createPersonnelCleanUpPanel(); @@ -428,9 +428,9 @@ JPanel createGeneralTab() { */ private JPanel createPersonnelCleanUpPanel() { // Contents - chkUsePersonnelRemoval = createCheckBox("UsePersonnelRemoval", null); - chkUseRemovalExemptCemetery = createCheckBox("UseRemovalExemptCemetery", null); - chkUseRemovalExemptRetirees = createCheckBox("UseRemovalExemptRetirees", null); + chkUsePersonnelRemoval = createCheckBox("UsePersonnelRemoval"); + chkUseRemovalExemptCemetery = createCheckBox("UseRemovalExemptCemetery"); + chkUseRemovalExemptRetirees = createCheckBox("UseRemovalExemptRetirees"); // Layout the Panel final JPanel panel = createStandardPanel("PersonnelCleanUpPanel", true, @@ -465,14 +465,14 @@ JPanel createPersonnelLogsTab() { false, "", true); // Contents - chkUseTransfers = createCheckBox("UseTransfers", null); - chkUseExtendedTOEForceName = createCheckBox("UseExtendedTOEForceName", null); - chkPersonnelLogSkillGain = createCheckBox("PersonnelLogSkillGain", null); - chkPersonnelLogAbilityGain = createCheckBox("PersonnelLogAbilityGain", null); - chkPersonnelLogEdgeGain = createCheckBox("PersonnelLogEdgeGain", null); - chkDisplayPersonnelLog = createCheckBox("DisplayPersonnelLog", null); - chkDisplayScenarioLog = createCheckBox("DisplayScenarioLog", null); - chkDisplayKillRecord = createCheckBox("DisplayKillRecord", null); + chkUseTransfers = createCheckBox("UseTransfers"); + chkUseExtendedTOEForceName = createCheckBox("UseExtendedTOEForceName"); + chkPersonnelLogSkillGain = createCheckBox("PersonnelLogSkillGain"); + chkPersonnelLogAbilityGain = createCheckBox("PersonnelLogAbilityGain"); + chkPersonnelLogEdgeGain = createCheckBox("PersonnelLogEdgeGain"); + chkDisplayPersonnelLog = createCheckBox("DisplayPersonnelLog"); + chkDisplayScenarioLog = createCheckBox("DisplayScenarioLog"); + chkDisplayKillRecord = createCheckBox("DisplayKillRecord"); // Layout the Panel final JPanel panel = createStandardPanel("PersonnelLogsTab", true, ""); @@ -520,13 +520,13 @@ JPanel createPersonnelInformationTab() { false, "", true); // Contents - chkUseTimeInService = createCheckBox("UseTimeInService", null); - lblTimeInServiceDisplayFormat = createLabel("TimeInServiceDisplayFormat", null); - chkUseTimeInRank = createCheckBox("UseTimeInRank", null); - lblTimeInRankDisplayFormat = createLabel("TimeInRankDisplayFormat", null); - chkTrackTotalEarnings = createCheckBox("TrackTotalEarnings", null); - chkTrackTotalXPEarnings = createCheckBox("TrackTotalXPEarnings", null); - chkShowOriginFaction = createCheckBox("ShowOriginFaction", null); + chkUseTimeInService = createCheckBox("UseTimeInService"); + lblTimeInServiceDisplayFormat = createLabel("TimeInServiceDisplayFormat"); + chkUseTimeInRank = createCheckBox("UseTimeInRank"); + lblTimeInRankDisplayFormat = createLabel("TimeInRankDisplayFormat"); + chkTrackTotalEarnings = createCheckBox("TrackTotalEarnings"); + chkTrackTotalXPEarnings = createCheckBox("TrackTotalXPEarnings"); + chkShowOriginFaction = createCheckBox("ShowOriginFaction"); // Layout the Panel final JPanel panel = createStandardPanel("PersonnelInformation", true, ""); @@ -584,10 +584,10 @@ JPanel createAdministratorsTab() { false, "", true); // Contents - chkAdminsHaveNegotiation = createCheckBox("AdminsHaveNegotiation", null); - chkAdminExperienceLevelIncludeNegotiation = createCheckBox("AdminExperienceLevelIncludeNegotiation", null); - chkAdminsHaveScrounge = createCheckBox("AdminsHaveScrounge", null); - chkAdminExperienceLevelIncludeScrounge = createCheckBox("AdminExperienceLevelIncludeScrounge", null); + chkAdminsHaveNegotiation = createCheckBox("AdminsHaveNegotiation"); + chkAdminExperienceLevelIncludeNegotiation = createCheckBox("AdminExperienceLevelIncludeNegotiation"); + chkAdminsHaveScrounge = createCheckBox("AdminsHaveScrounge"); + chkAdminExperienceLevelIncludeScrounge = createCheckBox("AdminExperienceLevelIncludeScrounge"); // Layout the Panel final JPanel panel = createStandardPanel("AdministratorsTab", true, ""); @@ -626,7 +626,7 @@ JPanel createAwardsTab() { false, "", true); // Contents - lblAwardBonusStyle = createLabel("AwardBonusStyle", null); + lblAwardBonusStyle = createLabel("AwardBonusStyle"); comboAwardBonusStyle.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, @@ -640,21 +640,21 @@ public Component getListCellRendererComponent(final JList list, final Object } }); - lblAwardTierSize = createLabel("AwardTierSize", null); - spnAwardTierSize = createSpinner("AwardTierSize", null, + lblAwardTierSize = createLabel("AwardTierSize"); + spnAwardTierSize = createSpinner("AwardTierSize", 5, 1, 100, 1); - chkEnableAutoAwards = createCheckBox("EnableAutoAwards", null); + chkEnableAutoAwards = createCheckBox("EnableAutoAwards"); - chkIssuePosthumousAwards = createCheckBox("IssuePosthumousAwards", null); + chkIssuePosthumousAwards = createCheckBox("IssuePosthumousAwards"); - chkIssueBestAwardOnly = createCheckBox("IssueBestAwardOnly", null); + chkIssueBestAwardOnly = createCheckBox("IssueBestAwardOnly"); - chkIgnoreStandardSet = createCheckBox("IgnoreStandardSet", null); + chkIgnoreStandardSet = createCheckBox("IgnoreStandardSet"); autoAwardsFilterPanel = createAutoAwardsFilterPanel(); - lblAwardSetFilterList = createLabel("AwardSetFilterList", null); + lblAwardSetFilterList = createLabel("AwardSetFilterList"); txtAwardSetFilterList = new JTextArea(5, 20); txtAwardSetFilterList.setLineWrap(true); txtAwardSetFilterList.setWrapStyleWord(true); @@ -724,18 +724,18 @@ public Component getListCellRendererComponent(final JList list, final Object */ private JPanel createAutoAwardsFilterPanel() { // Contents - chkEnableContractAwards = createCheckBox("EnableContractAwards", null); - chkEnableFactionHunterAwards = createCheckBox("EnableFactionHunterAwards", null); - chkEnableInjuryAwards = createCheckBox("EnableInjuryAwards", null); - chkEnableIndividualKillAwards = createCheckBox("EnableIndividualKillAwards", null); - chkEnableFormationKillAwards = createCheckBox("EnableFormationKillAwards", null); - chkEnableRankAwards = createCheckBox("EnableRankAwards", null); - chkEnableScenarioAwards = createCheckBox("EnableScenarioAwards", null); - chkEnableSkillAwards = createCheckBox("EnableSkillAwards", null); - chkEnableTheatreOfWarAwards = createCheckBox("EnableTheatreOfWarAwards", null); - chkEnableTimeAwards = createCheckBox("EnableTimeAwards", null); - chkEnableTrainingAwards = createCheckBox("EnableTrainingAwards", null); - chkEnableMiscAwards = createCheckBox("EnableMiscAwards", null); + chkEnableContractAwards = createCheckBox("EnableContractAwards"); + chkEnableFactionHunterAwards = createCheckBox("EnableFactionHunterAwards"); + chkEnableInjuryAwards = createCheckBox("EnableInjuryAwards"); + chkEnableIndividualKillAwards = createCheckBox("EnableIndividualKillAwards"); + chkEnableFormationKillAwards = createCheckBox("EnableFormationKillAwards"); + chkEnableRankAwards = createCheckBox("EnableRankAwards"); + chkEnableScenarioAwards = createCheckBox("EnableScenarioAwards"); + chkEnableSkillAwards = createCheckBox("EnableSkillAwards"); + chkEnableTheatreOfWarAwards = createCheckBox("EnableTheatreOfWarAwards"); + chkEnableTimeAwards = createCheckBox("EnableTimeAwards"); + chkEnableTrainingAwards = createCheckBox("EnableTrainingAwards"); + chkEnableMiscAwards = createCheckBox("EnableMiscAwards"); // Layout the Panel final JPanel panel = createStandardPanel("AutoAwardsFilterPanel", true, "AutoAwardsFilterPanel"); @@ -835,7 +835,7 @@ JPanel createPrisonersAndDependentsTab() { */ private JPanel createPrisonersPanel() { // Contents - lblPrisonerCaptureStyle = createLabel("PrisonerCaptureStyle", null); + lblPrisonerCaptureStyle = createLabel("PrisonerCaptureStyle"); comboPrisonerCaptureStyle.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, @@ -849,11 +849,11 @@ public Component getListCellRendererComponent(final JList list, final Object } }); - lblPrisonerStatus = createLabel("PrisonerStatus", null); + lblPrisonerStatus = createLabel("PrisonerStatus"); - chkPrisonerBabyStatus = createCheckBox("PrisonerBabyStatus", null); - chkAtBPrisonerDefection = createCheckBox("AtBPrisonerDefection", null); - chkAtBPrisonerRansom = createCheckBox("AtBPrisonerRansom", null); + chkPrisonerBabyStatus = createCheckBox("PrisonerBabyStatus"); + chkAtBPrisonerDefection = createCheckBox("AtBPrisonerDefection"); + chkAtBPrisonerRansom = createCheckBox("AtBPrisonerRansom"); // Layout the Panel final JPanel panel = createStandardPanel("PrisonersPanel", true, "PrisonersPanel"); @@ -896,8 +896,8 @@ public Component getListCellRendererComponent(final JList list, final Object */ private JPanel createDependentsPanel() { // Contents - chkUseRandomDependentAddition = createCheckBox("UseRandomDependentAddition", null); - chkUseRandomDependentRemoval = createCheckBox("UseRandomDependentRemoval", null); + chkUseRandomDependentAddition = createCheckBox("UseRandomDependentAddition"); + chkUseRandomDependentRemoval = createCheckBox("UseRandomDependentRemoval"); // Layout the Panel final JPanel panel = createStandardPanel("DependentsPanel", true, "DependentsPanel"); @@ -929,26 +929,26 @@ JPanel createMedicalTab() { false, "", true); // Contents - chkUseAdvancedMedical = createCheckBox("UseAdvancedMedical", null); + chkUseAdvancedMedical = createCheckBox("UseAdvancedMedical"); - lblHealWaitingPeriod = createLabel("HealWaitingPeriod", null); - spnHealWaitingPeriod = createSpinner("HealWaitingPeriod", null, + lblHealWaitingPeriod = createLabel("HealWaitingPeriod"); + spnHealWaitingPeriod = createSpinner("HealWaitingPeriod", 1, 1, 30, 1); - lblNaturalHealWaitingPeriod = createLabel("NaturalHealWaitingPeriod", null); - spnNaturalHealWaitingPeriod = createSpinner("NaturalHealWaitingPeriod", null, + lblNaturalHealWaitingPeriod = createLabel("NaturalHealWaitingPeriod"); + spnNaturalHealWaitingPeriod = createSpinner("NaturalHealWaitingPeriod", 1, 1, 365, 1); - lblMinimumHitsForVehicles = createLabel("MinimumHitsForVehicles", null); - spnMinimumHitsForVehicles = createSpinner("MinimumHitsForVehicles", null, + lblMinimumHitsForVehicles = createLabel("MinimumHitsForVehicles"); + spnMinimumHitsForVehicles = createSpinner("MinimumHitsForVehicles", 1, 1, 5, 1); - chkUseRandomHitsForVehicles = createCheckBox("UseRandomHitsForVehicles", null); + chkUseRandomHitsForVehicles = createCheckBox("UseRandomHitsForVehicles"); - chkUseTougherHealing = createCheckBox("UseTougherHealing", null); + chkUseTougherHealing = createCheckBox("UseTougherHealing"); - lblMaximumPatients = createLabel("MaximumPatients", null); - spnMaximumPatients = createSpinner("MaximumPatients", null, + lblMaximumPatients = createLabel("MaximumPatients"); + spnMaximumPatients = createSpinner("MaximumPatients", 25, 1, 100, 1); // Layout the Panel @@ -1014,7 +1014,7 @@ JPanel createSalariesTab() { false, "", true); // Contents - chkDisableSecondaryRoleSalary = createCheckBox("DisableSecondaryRoleSalary", null); + chkDisableSecondaryRoleSalary = createCheckBox("DisableSecondaryRoleSalary"); pnlSalaryMultipliersPanel = createSalaryMultipliersPanel(); pnlSalaryExperienceMultipliersPanel = createExperienceMultipliersPanel(); pnlSalaryBaseSalaryPanel = createBaseSalariesPanel(); @@ -1047,16 +1047,16 @@ JPanel createSalariesTab() { /** * Creates a panel for configuring salary multipliers for different personnel roles. * - * @return a {@link JPanel} containing the salary multipliers configuration panel + * @return a {@link JPanel} containing the salary multiplier configuration panel */ private JPanel createSalaryMultipliersPanel() { // Contents - lblAntiMekSalary = createLabel("AntiMekSalary", null); - spnAntiMekSalary = createSpinner("AntiMekSalary", null, + lblAntiMekSalary = createLabel("AntiMekSalary"); + spnAntiMekSalary = createSpinner("AntiMekSalary", 0, 0, 100, 0.05); - lblSpecialistInfantrySalary = createLabel("SpecialistInfantrySalary", null); - spnSpecialistInfantrySalary = createSpinner("SpecialistInfantrySalary", null, + lblSpecialistInfantrySalary = createLabel("SpecialistInfantrySalary"); + spnSpecialistInfantrySalary = createSpinner("SpecialistInfantrySalary", 0, 0, 100, 0.05); // Layout the Panel @@ -1097,10 +1097,10 @@ private JPanel createSalaryMultipliersPanel() { private JPanel createExperienceMultipliersPanel() { // Contents for (final SkillLevel skillLevel : Skills.SKILL_LEVELS) { - final JLabel label = createLabel("SkillLevel" + skillLevel.toString(), null); + final JLabel label = createLabel("SkillLevel" + skillLevel.toString()); lblSalaryExperienceMultipliers.put(skillLevel, label); - final JSpinner spinner = createSpinner("SkillLevel" + skillLevel, null, + final JSpinner spinner = createSpinner("SkillLevel" + skillLevel, 0, 0, 10, 0.05); spnSalaryExperienceMultipliers.put(skillLevel, spinner); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java index 31ce30d6e1..9bf44eb3fa 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java @@ -248,19 +248,19 @@ JPanel createMarriageTab() { */ private JPanel createMarriageGeneralOptionsPanel() { // Contents - chkUseManualMarriages = createCheckBox("UseManualMarriages", null); - chkUseClanPersonnelMarriages = createCheckBox("UseClanPersonnelMarriages", null); - chkUsePrisonerMarriages = createCheckBox("UsePrisonerMarriages", null); + chkUseManualMarriages = createCheckBox("UseManualMarriages"); + chkUseClanPersonnelMarriages = createCheckBox("UseClanPersonnelMarriages"); + chkUsePrisonerMarriages = createCheckBox("UsePrisonerMarriages"); - lblNoInterestInMarriageDiceSize = createLabel("NoInterestInMarriageDiceSize", null); - spnNoInterestInMarriageDiceSize = createSpinner("NoInterestInMarriageDiceSize", null, + lblNoInterestInMarriageDiceSize = createLabel("NoInterestInMarriageDiceSize"); + spnNoInterestInMarriageDiceSize = createSpinner("NoInterestInMarriageDiceSize", 10, 1, 100000, 1); - lblCheckMutualAncestorsDepth = createLabel("CheckMutualAncestorsDepth", null); - spnCheckMutualAncestorsDepth = createSpinner("CheckMutualAncestorsDepth", null, + lblCheckMutualAncestorsDepth = createLabel("CheckMutualAncestorsDepth"); + spnCheckMutualAncestorsDepth = createSpinner("CheckMutualAncestorsDepth", 4, 0, 20, 1); - chkLogMarriageNameChanges = createCheckBox("LogMarriageNameChanges", null); + chkLogMarriageNameChanges = createCheckBox("LogMarriageNameChanges"); // Layout the Panel final JPanel panel = createStandardPanel("MarriageGeneralOptionsPanel", @@ -310,7 +310,7 @@ private JPanel createMarriageGeneralOptionsPanel() { */ private JPanel createRandomMarriagePanel() { // Contents - lblRandomMarriageMethod = createLabel("RandomMarriageMethod", null); + lblRandomMarriageMethod = createLabel("RandomMarriageMethod"); comboRandomMarriageMethod.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, @@ -324,11 +324,11 @@ public Component getListCellRendererComponent(final JList list, final Object } }); - chkUseRandomClanPersonnelMarriages = createCheckBox("UseRandomClanPersonnelMarriages", null); - chkUseRandomPrisonerMarriages = createCheckBox("UseRandomPrisonerMarriages", null); + chkUseRandomClanPersonnelMarriages = createCheckBox("UseRandomClanPersonnelMarriages"); + chkUseRandomPrisonerMarriages = createCheckBox("UseRandomPrisonerMarriages"); - lblRandomMarriageAgeRange = createLabel("RandomMarriageAgeRange", null); - spnRandomMarriageAgeRange = createSpinner("RandomMarriageAgeRange", null, + lblRandomMarriageAgeRange = createLabel("RandomMarriageAgeRange"); + spnRandomMarriageAgeRange = createSpinner("RandomMarriageAgeRange", 10, 0, 100, 1.0); pnlPercentageRandomMarriage = createPercentageRandomMarriagePanel(); @@ -383,11 +383,11 @@ private JPanel createPercentageRandomMarriagePanel() { spnRandomMarriageDiceSize = createSpinner("RandomMarriageOppositeSexDiceSize", null, 5000, 0, 100000, 1); - lblRandomSameSexMarriageDiceSize = createLabel("RandomSameSexMarriageDiceSize", null); + lblRandomSameSexMarriageDiceSize = createLabel("RandomSameSexMarriageDiceSize"); spnRandomSameSexMarriageDiceSize = createSpinner("RandomSameSexMarriageDiceSize", null, 14, 0, 100000, 1); - lblRandomNewDependentMarriage = createLabel("RandomNewDependentMarriage", null); + lblRandomNewDependentMarriage = createLabel("RandomNewDependentMarriage"); spnRandomNewDependentMarriage = createSpinner("RandomSameSexMarriageDiceSize", null, 20, 0, 100000, 1); @@ -442,9 +442,9 @@ JPanel createDivorceTab() { false, "", true); // Contents - chkUseManualDivorce = createCheckBox("UseManualDivorce", null); - chkUseClanPersonnelDivorce = createCheckBox("UseClanPersonnelDivorce", null); - chkUsePrisonerDivorce = createCheckBox("UsePrisonerDivorce", null); + chkUseManualDivorce = createCheckBox("UseManualDivorce"); + chkUseClanPersonnelDivorce = createCheckBox("UseClanPersonnelDivorce"); + chkUsePrisonerDivorce = createCheckBox("UsePrisonerDivorce"); pnlRandomDivorce = createRandomDivorcePanel(); @@ -482,7 +482,7 @@ JPanel createDivorceTab() { */ private JPanel createRandomDivorcePanel() { // Contents - lblRandomDivorceMethod = createLabel("RandomDivorceMethod", null); + lblRandomDivorceMethod = createLabel("RandomDivorceMethod"); comboRandomDivorceMethod.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, @@ -496,13 +496,13 @@ public Component getListCellRendererComponent(final JList list, final Object } }); - chkUseRandomOppositeSexDivorce = createCheckBox("UseRandomOppositeSexDivorce", null); - chkUseRandomSameSexDivorce = createCheckBox("UseRandomSameSexDivorce", null); - chkUseRandomClanPersonnelDivorce = createCheckBox("UseRandomClanPersonnelDivorce", null); - chkUseRandomPrisonerDivorce = createCheckBox("UseRandomPrisonerDivorce", null); + chkUseRandomOppositeSexDivorce = createCheckBox("UseRandomOppositeSexDivorce"); + chkUseRandomSameSexDivorce = createCheckBox("UseRandomSameSexDivorce"); + chkUseRandomClanPersonnelDivorce = createCheckBox("UseRandomClanPersonnelDivorce"); + chkUseRandomPrisonerDivorce = createCheckBox("UseRandomPrisonerDivorce"); - lblRandomDivorceDiceSize = createLabel("RandomDivorceDiceSize", null); - spnRandomDivorceDiceSize = createSpinner("RandomDivorceDiceSize", null, + lblRandomDivorceDiceSize = createLabel("RandomDivorceDiceSize"); + spnRandomDivorceDiceSize = createSpinner("RandomDivorceDiceSize", 900, 0, 100000, 1); // Layout the Panel @@ -588,15 +588,15 @@ JPanel createProcreationTab() { */ private JPanel createProcreationGeneralOptionsPanel() { // Contents - chkUseManualProcreation = createCheckBox("UseManualProcreation", null); - chkUseClanPersonnelProcreation = createCheckBox("UseClanPersonnelProcreation", null); - chkUsePrisonerProcreation = createCheckBox("UsePrisonerProcreation", null); + chkUseManualProcreation = createCheckBox("UseManualProcreation"); + chkUseClanPersonnelProcreation = createCheckBox("UseClanPersonnelProcreation"); + chkUsePrisonerProcreation = createCheckBox("UsePrisonerProcreation"); - lblMultiplePregnancyOccurrences = createLabel("MultiplePregnancyOccurrences", null); - spnMultiplePregnancyOccurrences = createSpinner("MultiplePregnancyOccurrences", null, + lblMultiplePregnancyOccurrences = createLabel("MultiplePregnancyOccurrences"); + spnMultiplePregnancyOccurrences = createSpinner("MultiplePregnancyOccurrences", 50, 1, 1000, 1); - lblBabySurnameStyle = createLabel("BabySurnameStyle", null); + lblBabySurnameStyle = createLabel("BabySurnameStyle"); comboBabySurnameStyle.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, @@ -614,15 +614,15 @@ public Component getListCellRendererComponent(final JList list, final Object null); chkAssignChildrenOfFoundersFounderTag = createCheckBox("AssignChildrenOfFoundersFounderTag", null); - chkDetermineFatherAtBirth = createCheckBox("DetermineFatherAtBirth", null); - chkDisplayTrueDueDate = createCheckBox("DisplayTrueDueDate", null); + chkDetermineFatherAtBirth = createCheckBox("DetermineFatherAtBirth"); + chkDisplayTrueDueDate = createCheckBox("DisplayTrueDueDate"); - lblNoInterestInChildrenDiceSize = createLabel("NoInterestInChildrenDiceSize", null); - spnNoInterestInChildrenDiceSize = createSpinner("NoInterestInChildrenDiceSize", null, + lblNoInterestInChildrenDiceSize = createLabel("NoInterestInChildrenDiceSize"); + spnNoInterestInChildrenDiceSize = createSpinner("NoInterestInChildrenDiceSize", 3, 1, 100000, 1); - chkUseMaternityLeave = createCheckBox("UseMaternityLeave", null); - chkLogProcreation = createCheckBox("LogProcreation", null); + chkUseMaternityLeave = createCheckBox("UseMaternityLeave"); + chkLogProcreation = createCheckBox("LogProcreation"); pnlRandomProcreationPanel = createRandomProcreationPanel(); @@ -686,7 +686,7 @@ public Component getListCellRendererComponent(final JList list, final Object */ private JPanel createRandomProcreationPanel() { // Contents - lblRandomProcreationMethod = createLabel("RandomProcreationMethod", null); + lblRandomProcreationMethod = createLabel("RandomProcreationMethod"); comboRandomProcreationMethod.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, @@ -704,7 +704,7 @@ public Component getListCellRendererComponent(final JList list, final Object null); chkUseRandomClanPersonnelProcreation = createCheckBox("UseRandomClanPersonnelProcreation", null); - chkUseRandomPrisonerProcreation = createCheckBox("UseRandomPrisonerProcreation", null); + chkUseRandomPrisonerProcreation = createCheckBox("UseRandomPrisonerProcreation"); lblRandomProcreationRelationshipDiceSize = createLabel("RandomProcreationRelationshipDiceSize", null); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java index 265c91ecde..f4815a1643 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java @@ -121,29 +121,29 @@ JPanel createRepairTab() { "", true); // Era Mods - useEraModsCheckBox = createCheckBox("UseEraModsCheckBox", null); + useEraModsCheckBox = createCheckBox("UseEraModsCheckBox"); // Tech Placement - assignedTechFirstCheckBox = createCheckBox("AssignedTechFirstCheckBox", null); - resetToFirstTechCheckBox = createCheckBox("ResetToFirstTechCheckBox", null); + assignedTechFirstCheckBox = createCheckBox("AssignedTechFirstCheckBox"); + resetToFirstTechCheckBox = createCheckBox("ResetToFirstTechCheckBox"); // Use Quirks - useQuirksBox = createCheckBox("UseQuirksBox", null); + useQuirksBox = createCheckBox("UseQuirksBox"); // Aero System Damage - useAeroSystemHitsBox = createCheckBox("UseAeroSystemHitsBox", null); + useAeroSystemHitsBox = createCheckBox("UseAeroSystemHitsBox"); // Damage by Margin - useDamageMargin = createCheckBox("UseDamageMargin", null); + useDamageMargin = createCheckBox("UseDamageMargin"); useDamageMargin.addActionListener(evt -> spnDamageMargin.setEnabled(useDamageMargin.isSelected())); - lblDamageMargin = createLabel("DamageMargin", null); - spnDamageMargin = createSpinner("DamageMargin", null, + lblDamageMargin = createLabel("DamageMargin"); + spnDamageMargin = createSpinner("DamageMargin", 1, 1, 20, 1); // Equipment Survival - lblDestroyPartTarget = createLabel("DestroyPartTarget", null); - spnDestroyPartTarget = createSpinner("DestroyPartTarget", null, + lblDestroyPartTarget = createLabel("DestroyPartTarget"); + spnDestroyPartTarget = createSpinner("DestroyPartTarget", 2, 2, 13, 1); JLabel lblDestroyPartTargetPost = new JLabel("+"); @@ -204,40 +204,40 @@ JPanel createMaintenanceTab() { false, "", true); // Check Maintenance - checkMaintenance = createCheckBox("CheckMaintenance", null); + checkMaintenance = createCheckBox("CheckMaintenance"); // Maintenance Cycle Duration - lblMaintenanceDays = createLabel("MaintenanceDays", null); - spnDamageMargin = createSpinner("MaintenanceDays", null, + lblMaintenanceDays = createLabel("MaintenanceDays"); + spnDamageMargin = createSpinner("MaintenanceDays", 7, 1, 365, 1); // Maintenance Bonus - lblMaintenanceBonus = createLabel("MaintenanceBonus", null); - spnMaintenanceBonus = createSpinner("MaintenanceBonus", null, + lblMaintenanceBonus = createLabel("MaintenanceBonus"); + spnMaintenanceBonus = createSpinner("MaintenanceBonus", 0, -13, 13, 1); // Default Maintenance Time - lblDefaultMaintenanceTime = createLabel("DefaultMaintenanceTime", null); - spnDefaultMaintenanceTime = createSpinner("DefaultMaintenanceTime", null, + lblDefaultMaintenanceTime = createLabel("DefaultMaintenanceTime"); + spnDefaultMaintenanceTime = createSpinner("DefaultMaintenanceTime", 1, 1, 4, 1); // Use Quality Modifiers - useQualityMaintenance = createCheckBox("UseQualityMaintenance", null); + useQualityMaintenance = createCheckBox("UseQualityMaintenance"); // Reverse Quality names - reverseQualityNames = createCheckBox("ReverseQualityNames", null); + reverseQualityNames = createCheckBox("ReverseQualityNames"); // Use Random Unit Qualities - chkUseRandomUnitQualities = createCheckBox("UseRandomUnitQualities", null); + chkUseRandomUnitQualities = createCheckBox("UseRandomUnitQualities"); // Use Planetary Modifiers - chkUsePlanetaryModifiers = createCheckBox("UsePlanetaryModifiers", null); + chkUsePlanetaryModifiers = createCheckBox("UsePlanetaryModifiers"); // Only Damage F-Rated Equipment - useUnofficialMaintenance = createCheckBox("UseUnofficialMaintenance", null); + useUnofficialMaintenance = createCheckBox("UseUnofficialMaintenance"); // Report Maintenance checks to Log - logMaintenance = createCheckBox("LogMaintenance", null); + logMaintenance = createCheckBox("LogMaintenance"); // Layout the Panel final JPanel panel = createStandardPanel("repairTab", true, ""); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java index dc699a2475..4df4f4d42c 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java @@ -232,7 +232,7 @@ JPanel createTurnoverTab() { false, "", true); // Contents - chkUseRandomRetirement = createCheckBox("UseRandomRetirement", null); + chkUseRandomRetirement = createCheckBox("UseRandomRetirement"); pnlSettings = createSettingsPanel(); pnlModifiers = createModifiersPanel(); pnlPayout = createPayoutsPanel(); @@ -285,11 +285,11 @@ JPanel createTurnoverTab() { */ private JPanel createSettingsPanel() { // Contents - lblTurnoverFixedTargetNumber = createLabel("TurnoverFixedTargetNumber", null); - spnTurnoverFixedTargetNumber = createSpinner("TurnoverFixedTargetNumber", null, + lblTurnoverFixedTargetNumber = createLabel("TurnoverFixedTargetNumber"); + spnTurnoverFixedTargetNumber = createSpinner("TurnoverFixedTargetNumber", 3, 0, 10, 1); - lblTurnoverFrequency = createLabel("TurnoverFrequency", null); + lblTurnoverFrequency = createLabel("TurnoverFrequency"); comboTurnoverFrequency.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, @@ -304,28 +304,28 @@ public Component getListCellRendererComponent(final JList list, final Object }); chkUseContractCompletionRandomRetirement = createCheckBox( - "UseContractCompletionRandomRetirement", null); + "UseContractCompletionRandomRetirement"); - chkUseRandomFounderTurnover = createCheckBox("UseRandomFounderTurnover", null); + chkUseRandomFounderTurnover = createCheckBox("UseRandomFounderTurnover"); - chkTrackOriginalUnit = createCheckBox("TrackOriginalUnit", null); + chkTrackOriginalUnit = createCheckBox("TrackOriginalUnit"); - chkAeroRecruitsHaveUnits = createCheckBox("AeroRecruitsHaveUnits", null); + chkAeroRecruitsHaveUnits = createCheckBox("AeroRecruitsHaveUnits"); - chkUseSubContractSoldiers = createCheckBox("UseSubContractSoldiers", null); + chkUseSubContractSoldiers = createCheckBox("UseSubContractSoldiers"); - lblServiceContractDuration = createLabel("ServiceContractDuration", null); - spnServiceContractDuration = createSpinner("ServiceContractDuration", null, + lblServiceContractDuration = createLabel("ServiceContractDuration"); + spnServiceContractDuration = createSpinner("ServiceContractDuration", 36, 0, 120, 1); - lblServiceContractModifier = createLabel("ServiceContractModifier", null); - spnServiceContractModifier = createSpinner("ServiceContractModifier", null, + lblServiceContractModifier = createLabel("ServiceContractModifier"); + spnServiceContractModifier = createSpinner("ServiceContractModifier", 3, 0, 10, 1); - chkPayBonusDefault = createCheckBox("PayBonusDefault", null); + chkPayBonusDefault = createCheckBox("PayBonusDefault"); - lblPayBonusDefaultThreshold = createLabel("PayBonusDefaultThreshold", null); - spnPayBonusDefaultThreshold = createSpinner("PayBonusDefaultThreshold", null, + lblPayBonusDefaultThreshold = createLabel("PayBonusDefaultThreshold"); + spnPayBonusDefaultThreshold = createSpinner("PayBonusDefaultThreshold", 3, 0, 12, 1); // Layout the Panel @@ -405,17 +405,17 @@ public Component getListCellRendererComponent(final JList list, final Object */ private JPanel createModifiersPanel() { // Contents - chkUseCustomRetirementModifiers = createCheckBox("UseCustomRetirementModifiers", null); - chkUseFatigueModifiers = createCheckBox("UseFatigueModifiers", null); - chkUseSkillModifiers = createCheckBox("UseSkillModifiers", null); - chkUseAgeModifiers = createCheckBox("UseAgeModifiers", null); - chkUseUnitRatingModifiers = createCheckBox("UseUnitRatingModifiers", null); - chkUseFactionModifiers = createCheckBox("UseFactionModifiers", null); - chkUseMissionStatusModifiers = createCheckBox("UseMissionStatusModifiers", null); - chkUseHostileTerritoryModifiers = createCheckBox("UseHostileTerritoryModifiers", null); - chkUseFamilyModifiers = createCheckBox("UseFamilyModifiers", null); - chkUseLoyaltyModifiers = createCheckBox("UseLoyaltyModifiers", null); - chkUseHideLoyalty = createCheckBox("UseHideLoyalty", null); + chkUseCustomRetirementModifiers = createCheckBox("UseCustomRetirementModifiers"); + chkUseFatigueModifiers = createCheckBox("UseFatigueModifiers"); + chkUseSkillModifiers = createCheckBox("UseSkillModifiers"); + chkUseAgeModifiers = createCheckBox("UseAgeModifiers"); + chkUseUnitRatingModifiers = createCheckBox("UseUnitRatingModifiers"); + chkUseFactionModifiers = createCheckBox("UseFactionModifiers"); + chkUseMissionStatusModifiers = createCheckBox("UseMissionStatusModifiers"); + chkUseHostileTerritoryModifiers = createCheckBox("UseHostileTerritoryModifiers"); + chkUseFamilyModifiers = createCheckBox("UseFamilyModifiers"); + chkUseLoyaltyModifiers = createCheckBox("UseLoyaltyModifiers"); + chkUseHideLoyalty = createCheckBox("UseHideLoyalty"); // Layout the Panel @@ -472,22 +472,22 @@ private JPanel createModifiersPanel() { */ private JPanel createPayoutsPanel() { // Contents - lblPayoutRateOfficer = createLabel("PayoutRateOfficer", null); - spnPayoutRateOfficer = createSpinner("PayoutRateOfficer", null, + lblPayoutRateOfficer = createLabel("PayoutRateOfficer"); + spnPayoutRateOfficer = createSpinner("PayoutRateOfficer", 3, 0, 12, 1); - lblPayoutRateEnlisted = createLabel("PayoutRateEnlisted", null); - spnPayoutRateEnlisted = createSpinner("PayoutRateEnlisted", null, + lblPayoutRateEnlisted = createLabel("PayoutRateEnlisted"); + spnPayoutRateEnlisted = createSpinner("PayoutRateEnlisted", 3, 0, 12, 1); - lblPayoutRetirementMultiplier = createLabel("PayoutRetirementMultiplier", null); - spnPayoutRetirementMultiplier = createSpinner("PayoutRetirementMultiplier", null, + lblPayoutRetirementMultiplier = createLabel("PayoutRetirementMultiplier"); + spnPayoutRetirementMultiplier = createSpinner("PayoutRetirementMultiplier", 24, 1, 120, 1); - chkUsePayoutServiceBonus = createCheckBox("UsePayoutServiceBonus", null); + chkUsePayoutServiceBonus = createCheckBox("UsePayoutServiceBonus"); - lblPayoutServiceBonusRate = createLabel("PayoutServiceBonusRate", null); - spnPayoutServiceBonusRate = createSpinner("PayoutServiceBonusRate", null, + lblPayoutServiceBonusRate = createLabel("PayoutServiceBonusRate"); + spnPayoutServiceBonusRate = createSpinner("PayoutServiceBonusRate", 10, 1, 100, 1); // Layout the Panel @@ -586,7 +586,7 @@ private JPanel createUnitCohesionPanel() { */ private JPanel createAdministrativeStrainWrapperPanel() { // Contents - chkUseAdministrativeStrain = createCheckBox("UseAdministrativeStrain", null); + chkUseAdministrativeStrain = createCheckBox("UseAdministrativeStrain"); pnlAdministrativeStrain = createAdministrativeStrainPanel(); // Layout the Panel @@ -622,12 +622,12 @@ private JPanel createAdministrativeStrainWrapperPanel() { */ private JPanel createAdministrativeStrainPanel() { // Contents - lblAdministrativeCapacity = createLabel("AdministrativeCapacity", null); - spnAdministrativeCapacity = createSpinner("AdministrativeCapacity", null, + lblAdministrativeCapacity = createLabel("AdministrativeCapacity"); + spnAdministrativeCapacity = createSpinner("AdministrativeCapacity", 10, 1, 30, 1); - lblMultiCrewStrainDivider = createLabel("MultiCrewStrainDivider", null); - spnMultiCrewStrainDivider = createSpinner("MultiCrewStrainDivider", null, + lblMultiCrewStrainDivider = createLabel("MultiCrewStrainDivider"); + spnMultiCrewStrainDivider = createSpinner("MultiCrewStrainDivider", 5, 1, 25, 1); // Layout the Panel @@ -673,7 +673,7 @@ private JPanel createAdministrativeStrainPanel() { */ private JPanel createManagementSkillWrapperPanel() { // Contents - chkUseManagementSkill = createCheckBox("UseManagementSkill", null); + chkUseManagementSkill = createCheckBox("UseManagementSkill"); pnlManagementSkill = createManagementSkillPanel(); // Layout the Panel @@ -710,10 +710,10 @@ private JPanel createManagementSkillWrapperPanel() { */ private JPanel createManagementSkillPanel() { // Contents - chkUseCommanderLeadershipOnly = createCheckBox("UseCommanderLeadershipOnly", null); + chkUseCommanderLeadershipOnly = createCheckBox("UseCommanderLeadershipOnly"); - lblManagementSkillPenalty = createLabel("ManagementSkillPenalty", null); - spnManagementSkillPenalty = createSpinner("ManagementSkillPenalty", null, + lblManagementSkillPenalty = createLabel("ManagementSkillPenalty"); + spnManagementSkillPenalty = createSpinner("ManagementSkillPenalty", 0, -10, 10, 1); // Layout the Panel @@ -760,22 +760,22 @@ JPanel createFatigueTab() { false, "", true); // Contents - chkUseFatigue = createCheckBox("UseFatigue", null); + chkUseFatigue = createCheckBox("UseFatigue"); - lblFatigueRate = createLabel("FatigueRate", null); - spnFatigueRate = createSpinner("FatigueRate", null, + lblFatigueRate = createLabel("FatigueRate"); + spnFatigueRate = createSpinner("FatigueRate", 1, 1, 10, 1); - chkUseInjuryFatigue = createCheckBox("UseInjuryFatigue", null); + chkUseInjuryFatigue = createCheckBox("UseInjuryFatigue"); - lblFieldKitchenCapacity = createLabel("FieldKitchenCapacity", null); - spnFieldKitchenCapacity = createSpinner("FieldKitchenCapacity", null, + lblFieldKitchenCapacity = createLabel("FieldKitchenCapacity"); + spnFieldKitchenCapacity = createSpinner("FieldKitchenCapacity", 150, 0, 450, 1); - chkFieldKitchenIgnoreNonCombatants = createCheckBox("FieldKitchenIgnoreNonCombatants", null); + chkFieldKitchenIgnoreNonCombatants = createCheckBox("FieldKitchenIgnoreNonCombatants"); - lblFatigueLeaveThreshold = createLabel("FatigueLeaveThreshold", null); - spnFatigueLeaveThreshold = createSpinner("FatigueLeaveThreshold", null, + lblFatigueLeaveThreshold = createLabel("FatigueLeaveThreshold"); + spnFatigueLeaveThreshold = createSpinner("FatigueLeaveThreshold", 13, 0, 17, 1); // Layout the Panel From f6a929032354b45359dd7c3e05adc87b778e2c45 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Sat, 12 Oct 2024 15:15:57 -0500 Subject: [PATCH 064/117] Add Javadoc comments and implement Unit Market in GUI Added detailed Javadoc comments to utility methods in CampaignOptionsUtilities.java for better code documentation. Implemented the Unit Market tab in MarketsTab.java, including new UI components and layout adjustments. Simplified label and text field creation in GeneralTab.java by removing redundant parameters. --- .../tabs/CampaignOptionsUtilities.java | 34 +++++++++ .../campaignOptions/tabs/GeneralTab.java | 18 ++--- .../campaignOptions/tabs/MarketsTab.java | 70 +++++++++++++++++-- 3 files changed, 106 insertions(+), 16 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index 96f77005eb..532807e87c 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -58,6 +58,19 @@ static JCheckBox createCheckBox(String name, @Nullable Integer customWrapSize) { return checkBox; } + /** + * Creates a {@link JSpinner} object. + *

+ * The name of the {@link JSpinner} will be {@code "spn" + name}, + * and it will use the {@code "lbl" + name + ".tooltip"} resource bundle item + * + * @param name a string representing the name of the objects. + * @param defaultValue The default value of the spinner + * @param minimum The minimum value of the spinner + * @param maximum The maximum value of the spinner + * @param stepSize The step size of the spinner + * @return The created {@link JSpinner}. + */ static JSpinner createSpinner(String name, double defaultValue, double minimum, double maximum, double stepSize) { return createSpinner(name, null, defaultValue, minimum, maximum, stepSize); @@ -97,6 +110,17 @@ static JSpinner createSpinner(String name, @Nullable Integer customWrapSize, dou return jSpinner; } + /** + * Creates a {@link JLabel} with the specified name and optional customWrapSize. + *

+ * Please note that 'name' is also used to fetch the resources associated with this label. + * For the label text 'name' is appended by '.text'. + * For the label tooltip 'name' is appended with '.tooltip'. + * These values must exist in the resource bundle otherwise an error will be thrown. + * + * @param name the name of the label + * @return a new {@link JLabel} object + */ static JLabel createLabel(String name) { return createLabel(name, null); } @@ -129,6 +153,16 @@ static JLabel createLabel(String name, @Nullable Integer customWrapSize) { return jLabel; } + /** + * Creates a {@link JTextField} object. + *

+ * The name of the {@link JTextField} will be {@code}, and it will use the following resource bundle reference: + * {@code "lbl" + name + ".tooltip"}. + * + * @param name the name of the object. + * @param width The width of the {@link JTextField}. + * @return a map containing a {@link JLabel} key and a {@link JTextField} value. + */ static JTextField createTextField(String name, int width) { return createTextField(name, null, width); } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java index ef3364c12b..fc560265e5 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java @@ -86,8 +86,8 @@ public AbstractMHQScrollablePanel createGeneralTab() { JPanel headerPanel = createGeneralHeader(); // Campaign name - lblName = createLabel("Name", null); - txtName = createTextField("Name", null, 300); + lblName = createLabel("Name"); + txtName = createTextField("Name", 300); // Generate new random campaign name btnNameGenerator = createButton("NameGenerator"); @@ -95,29 +95,29 @@ public AbstractMHQScrollablePanel createGeneralTab() { .randomMercenaryCompanyNameGenerator(campaign.getFlaggedCommander()))); // Campaign faction - lblFaction = createLabel("Faction", null); + lblFaction = createLabel("Faction"); comboFaction.setSelectedItem(new FactionDisplay(campaign.getFaction(), campaign.getLocalDate())); // Reputation - lblReputation = createLabel("Reputation", null); - lblManualUnitRatingModifier = createLabel("ManualUnitRatingModifier", null); - manualUnitRatingModifier = createSpinner("ManualUnitRatingModifier", null, + lblReputation = createLabel("Reputation"); + lblManualUnitRatingModifier = createLabel("ManualUnitRatingModifier"); + manualUnitRatingModifier = createSpinner("ManualUnitRatingModifier", 0, -200, 200, 1); // Date - lblDate = createLabel("Date", null); + lblDate = createLabel("Date"); btnDate = createButton("Date"); btnDate.addActionListener(this::btnDateActionPerformed); // Camouflage - lblCamo = createLabel("Camo", null); + lblCamo = createLabel("Camo"); btnCamo.setName("btnCamo"); btnCamo.setMinimumSize(new Dimension(100, 100)); btnCamo.setMaximumSize(new Dimension(100, 100)); btnCamo.addActionListener(this::btnCamoActionPerformed); // Unit icon - lblIcon = createLabel("Icon", null); + lblIcon = createLabel("Icon"); btnIcon.setName("btnIcon"); btnIcon.setMinimumSize(new Dimension(100, 100)); btnIcon.setMaximumSize(new Dimension(100, 100)); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java index 87da57bdc8..9028aee31f 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java @@ -2,6 +2,7 @@ import megamek.client.ui.baseComponents.MMComboBox; import megamek.common.enums.SkillLevel; +import mekhq.campaign.market.enums.UnitMarketMethod; import mekhq.campaign.personnel.Skills; import mekhq.module.PersonnelMarketServiceManager; import mekhq.module.api.PersonnelMarketMethod; @@ -33,6 +34,15 @@ public class MarketsTab { //end Personnel Market //start Unit Market + private JLabel lblUnitMarketMethod; + private MMComboBox comboUnitMarketMethod; + private JCheckBox chkUnitMarketRegionalMekVariations; + private JLabel lblUnitMarketSpecialUnitChance; + private JSpinner spnUnitMarketSpecialUnitChance; + private JLabel lblUnitMarketRarityModifier; + private JSpinner spnUnitMarketRarityModifier; + private JCheckBox chkInstantUnitMarketDelivery; + private JCheckBox chkUnitMarketReportRefresh; //end Unit Market //start Contract Market @@ -120,9 +130,9 @@ private JPanel createPersonnelMarketGeneralOptionsPanel() { spnPersonnelMarketDylansWeight = createSpinner("PersonnelMarketDylansWeight", null, 0.3, 0, 1, 0.1); - chkPersonnelMarketReportRefresh = createCheckBox("PersonnelMarketReportRefresh", null); + chkPersonnelMarketReportRefresh = createCheckBox("PersonnelMarketReportRefresh"); - chkUsePersonnelHireHiringHallOnly = createCheckBox("UsePersonnelHireHiringHallOnly", null); + chkUsePersonnelHireHiringHallOnly = createCheckBox("UsePersonnelHireHiringHallOnly"); // Layout the Panel final JPanel panel = createStandardPanel("PersonnelMarketGeneralOptionsPanel", false, @@ -271,16 +281,62 @@ private JPanel createPersonnelMarketRemovalOptionsPanel() { } private void initializeUnitMarket() { - + lblUnitMarketMethod = new JLabel(); + comboUnitMarketMethod = new MMComboBox<>("comboUnitMarketMethod", UnitMarketMethod.values()); + chkUnitMarketRegionalMekVariations = new JCheckBox(); + lblUnitMarketSpecialUnitChance = new JLabel(); + spnUnitMarketSpecialUnitChance = new JSpinner(); + lblUnitMarketRarityModifier = new JLabel(); + spnUnitMarketRarityModifier = new JSpinner(); + chkInstantUnitMarketDelivery = new JCheckBox(); + chkUnitMarketReportRefresh = new JCheckBox(); } JPanel createUnitMarketTab() { // Header - JPanel headerPanel = createHeaderPanel("PriceMultipliersTab", - getImageDirectory() + "logo_clan_sea_fox.png", + JPanel headerPanel = createHeaderPanel("UnitMarketTab", + getImageDirectory() + "logo_loathian_league.png", false, "", true); - return null; + // Contents + lblUnitMarketMethod = createLabel("UnitMarketMethod", null); + comboUnitMarketMethod = new MMComboBox<>("comboUnitMarketMethod", UnitMarketMethod.values()); + + chkUnitMarketRegionalMekVariations = createCheckBox("UnitMarketRegionalMekVariations"); + + lblUnitMarketSpecialUnitChance = createLabel("UnitMarketSpecialUnitChance", null); + spnUnitMarketSpecialUnitChance = new JSpinner(); + + lblUnitMarketRarityModifier = createLabel("UnitMarketRarityModifier", null); + spnUnitMarketRarityModifier = new JSpinner(); + + chkInstantUnitMarketDelivery = new JCheckBox(); + + chkUnitMarketReportRefresh = new JCheckBox(); + + // Layout the Panel + final JPanel panel = createStandardPanel("UnitMarketTab", true, + ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(pnlPersonnelMarketGeneralOptions) + .addComponent(pnlRemovalTargets))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addGroup(layout.createSequentialGroup() + .addComponent(pnlPersonnelMarketGeneralOptions) + .addComponent(pnlRemovalTargets) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + // Create Parent Panel and return + return createParentPanel(panel, "UnitMarketTab"); } private void initializeContractMarket() { @@ -290,7 +346,7 @@ private void initializeContractMarket() { JPanel createContractMarketTab() { // Header JPanel headerPanel = createHeaderPanel("PriceMultipliersTab", - getImageDirectory() + "logo_loathian_league.png", + getImageDirectory() + "logo_clan_smoke_jaguar.png", false, "", true); return null; From 848ecdd0f6601eb63a4cbbe7039a8ce98c68d93e Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Sat, 12 Oct 2024 15:27:08 -0500 Subject: [PATCH 065/117] Add Unit Market Tab in Campaign Options This commit introduced a new Unit Market Tab in the Campaign Options screen. The new tab allows users to configure various settings related to unit markets, including special unit chances, rarity modifiers, and instant delivery options. Labels and tooltips for these new options were also added to the resource file. --- .../NEWCampaignOptionsDialog.properties | 28 +++++++++- .../tabs/CampaignOptionsPane.java | 3 +- .../campaignOptions/tabs/MarketsTab.java | 52 +++++++++++++------ 3 files changed, 66 insertions(+), 17 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 99c67d3ab5..09a2a2b2d1 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -1123,6 +1123,11 @@ personnelMarketTab.border="Every hiring hall is filled with possibilities. Behin \ a story waiting to unfold - and sometimes, those stories shape the galaxy."\
- Sergeant Max "Rustbucket" Carver, Steel Fangs Mercenaries +unitMarketTab.title=Units +unitMarketTab.border="Buying a new mech is exciting - right up until you see the repair bill after\ + \ your first mission. Then it's just another hole in your wallet."\ +
- Sergeant Kyle "Scrapheap" Carter, Black Talon Mercenaries + # createPersonnelMarketTab lblPersonnelMarketTab.text=Personnel Market Options lblPersonnelMarketTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ @@ -1143,4 +1148,25 @@ lblUsePersonnelHireHiringHallOnly.text=Hiring Halls & Capitals Only lblUsePersonnelHireHiringHallOnly.tooltip=PLACEHOLDER # createPersonnelMarketRemovalOptionsPanel -lblPersonnelMarketRemovalOptionsPanel.text=Removal Target Numbers \ No newline at end of file +lblPersonnelMarketRemovalOptionsPanel.text=Removal Target Numbers + +# createUnitMarketTab +lblUnitMarketTab.text=Unit Market Options +lblUnitMarketTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblUnitMarketMethod.text=Market Method +lblUnitMarketMethod.tooltip=PLACEHOLDER +lblUnitMarketRegionalMekVariations.text=Enable Faction 'Mek Weight Variance +lblUnitMarketRegionalMekVariations.tooltip=PLACEHOLDER +lblUnitMarketSpecialUnitChance.text=Special Vehicle Chance: 1 in +lblUnitMarketSpecialUnitChance.tooltip=PLACEHOLDER +lblUnitMarketRarityModifier.text=Unit Rarity Modifier +lblUnitMarketRarityModifier.tooltip=PLACEHOLDER +lblInstantUnitMarketDelivery.text=Enable Instant Deliveries +lblInstantUnitMarketDelivery.tooltip=PLACEHOLDER +lblUnitMarketReportRefresh.text=Post Report on Market Refresh +lblUnitMarketReportRefresh.tooltip=PLACEHOLDER \ No newline at end of file diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index d085d2401c..c62056ac99 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -217,7 +217,8 @@ private JTabbedPane createStrategicOperationsParentTab() { MarketsTab marketsTab = new MarketsTab(getFrame(), "marketsTab"); JTabbedPane marketsContentTabs = createSubTabs(Map.of( - "personnelMarketTab", marketsTab.createPersonnelMarketTab())); + "personnelMarketTab", marketsTab.createPersonnelMarketTab(), + "unitMarketTab", marketsTab.createUnitMarketTab())); // Markets + Mercenary (don't forget useInfantryDoseNotCountBox) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java index 9028aee31f..2ad8a29930 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java @@ -122,12 +122,12 @@ JPanel createPersonnelMarketTab() { private JPanel createPersonnelMarketGeneralOptionsPanel() { // Contents - lblPersonnelMarketType = createLabel("PersonnelMarketType", null); + lblPersonnelMarketType = createLabel("PersonnelMarketType"); comboPersonnelMarketType = new MMComboBox<>("comboPersonnelMarketType", getPersonnelMarketTypeOptions()); - lblPersonnelMarketDylansWeight = createLabel("PersonnelMarketDylansWeight", null); - spnPersonnelMarketDylansWeight = createSpinner("PersonnelMarketDylansWeight", null, + lblPersonnelMarketDylansWeight = createLabel("PersonnelMarketDylansWeight"); + spnPersonnelMarketDylansWeight = createSpinner("PersonnelMarketDylansWeight", 0.3, 0, 1, 0.1); chkPersonnelMarketReportRefresh = createCheckBox("PersonnelMarketReportRefresh"); @@ -299,20 +299,22 @@ JPanel createUnitMarketTab() { false, "", true); // Contents - lblUnitMarketMethod = createLabel("UnitMarketMethod", null); + lblUnitMarketMethod = createLabel("UnitMarketMethod"); comboUnitMarketMethod = new MMComboBox<>("comboUnitMarketMethod", UnitMarketMethod.values()); chkUnitMarketRegionalMekVariations = createCheckBox("UnitMarketRegionalMekVariations"); - lblUnitMarketSpecialUnitChance = createLabel("UnitMarketSpecialUnitChance", null); - spnUnitMarketSpecialUnitChance = new JSpinner(); + lblUnitMarketSpecialUnitChance = createLabel("UnitMarketSpecialUnitChance"); + spnUnitMarketSpecialUnitChance = createSpinner("UnitMarketSpecialUnitChance", + 30, 0, 100, 1); - lblUnitMarketRarityModifier = createLabel("UnitMarketRarityModifier", null); - spnUnitMarketRarityModifier = new JSpinner(); + lblUnitMarketRarityModifier = createLabel("UnitMarketRarityModifier"); + spnUnitMarketRarityModifier = createSpinner("UnitMarketRarityModifier", + 0, -10, 10, 1); - chkInstantUnitMarketDelivery = new JCheckBox(); + chkInstantUnitMarketDelivery = createCheckBox("InstantUnitMarketDelivery"); - chkUnitMarketReportRefresh = new JCheckBox(); + chkUnitMarketReportRefresh = createCheckBox("UnitMarketReportRefresh"); // Layout the Panel final JPanel panel = createStandardPanel("UnitMarketTab", true, @@ -324,16 +326,36 @@ JPanel createUnitMarketTab() { layout.createSequentialGroup() .addComponent(headerPanel) .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(pnlPersonnelMarketGeneralOptions) - .addComponent(pnlRemovalTargets))); + .addComponent(lblUnitMarketMethod) + .addComponent(comboUnitMarketMethod)) + .addComponent(chkUnitMarketRegionalMekVariations) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblUnitMarketSpecialUnitChance) + .addComponent(spnUnitMarketSpecialUnitChance)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblUnitMarketRarityModifier) + .addComponent(spnUnitMarketRarityModifier)) + .addComponent(chkInstantUnitMarketDelivery) + .addComponent(chkUnitMarketReportRefresh)); layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) .addComponent(headerPanel, Alignment.CENTER) .addGroup(layout.createSequentialGroup() - .addComponent(pnlPersonnelMarketGeneralOptions) - .addComponent(pnlRemovalTargets) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(lblUnitMarketMethod) + .addComponent(comboUnitMarketMethod) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkUnitMarketRegionalMekVariations) + .addGroup(layout.createSequentialGroup() + .addComponent(lblUnitMarketSpecialUnitChance) + .addComponent(spnUnitMarketSpecialUnitChance) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblUnitMarketRarityModifier) + .addComponent(spnUnitMarketRarityModifier) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkInstantUnitMarketDelivery) + .addComponent(chkUnitMarketReportRefresh)); // Create Parent Panel and return return createParentPanel(panel, "UnitMarketTab"); From 9c268b36c3a418e324de1185b296b9cea4fa9ff3 Mon Sep 17 00:00:00 2001 From: HammerGS Date: Sun, 13 Oct 2024 16:18:20 -0600 Subject: [PATCH 066/117] Update history.txt also a few boards --- MekHQ/docs/history.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/MekHQ/docs/history.txt b/MekHQ/docs/history.txt index 1b027d1bf1..b0139a2eeb 100644 --- a/MekHQ/docs/history.txt +++ b/MekHQ/docs/history.txt @@ -91,7 +91,12 @@ MEKHQ VERSION HISTORY: + PR #4931: Reworked AtB Bonus Rolls, Fixed Bug in Bulk Hire + PR #4981: Implemented Campaign Options IIC Preset Picker #4981 + PR #4984: Refactored Daily Personnel Processing Logic. -+ PR #4989: Adaptation to MM #6068 Replace Manual GUI scaling with FlatLaf Scaling ++ PR #4989 #4990: Adaptation to MM #6068 Replace Manual GUI scaling with FlatLaf Scaling ++ PR #5022: Better Current Location / Travel Status ++ PR #4946: Adds Recent Promotion Modifier to Turnover System ++ Fix #5010: Makes StratCon Scenario Generation Respect Non-Combat Flag in TO&E ++ Fix #4986: Camops Paid Recrutiment Removal ++ PR #5029: Better visual distinction for GM mode / overtime toggles + PR #5002: Correct issues with fixed map generation #5002 + PR #4992: Add Customization Option to Refit Dialog + PR #5030: Replaced autoAwards Award Ceremony Placeholder Image @@ -99,6 +104,9 @@ MEKHQ VERSION HISTORY: + PR #5017: Display Advanced Medical Injuries in UI + PR #5024: Add option to show unit images in TO&E + PR #5025: Pin/sticky force view tab on TO&E panel ++ PR #5040: Clarify map dimensions in scenario displays ++ PR #5042: Multiple FG3 Improvements ++ PF #5043: New names cleanup and potential bugfixes 0.50.0 (2024-09-01 2000 UTC) (THIS MARKS THE START OF JAVA 17 AS THE MINIMUM REQUIRED) + PR #4332: CI Updates for windows build and normalizing From 0d8c8f67f213ad7855c62fc4770e2322f4be864d Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 14 Oct 2024 11:41:07 -0500 Subject: [PATCH 067/117] Add contract market tab in campaign options Integrated a new contract market tab into the campaign options pane. This included creating various input elements and labels for managing contract details and configurations. --- .../NEWCampaignOptionsDialog.properties | 53 +++- .../tabs/CampaignOptionsPane.java | 3 +- .../campaignOptions/tabs/MarketsTab.java | 253 +++++++++++++++++- 3 files changed, 304 insertions(+), 5 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 09a2a2b2d1..f8ef692971 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -1128,6 +1128,11 @@ unitMarketTab.border="Buying a new mech is exciting - right up until you see the \ your first mission. Then it's just another hole in your wallet."\
- Sergeant Kyle "Scrapheap" Carter, Black Talon Mercenaries +contractMarketTab.title=Contracts +contractMarketTab.border="Accepting a contract isn't just about the money - it's about knowing when\ + \ to walk away and when to take the risk. Every deal comes with strings attached."\ +
- Captain Mika "Frostbite" Kline, Iceheart Marauders + # createPersonnelMarketTab lblPersonnelMarketTab.text=Personnel Market Options lblPersonnelMarketTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ @@ -1169,4 +1174,50 @@ lblUnitMarketRarityModifier.tooltip=PLACEHOLDER lblInstantUnitMarketDelivery.text=Enable Instant Deliveries lblInstantUnitMarketDelivery.tooltip=PLACEHOLDER lblUnitMarketReportRefresh.text=Post Report on Market Refresh -lblUnitMarketReportRefresh.tooltip=PLACEHOLDER \ No newline at end of file +lblUnitMarketReportRefresh.tooltip=PLACEHOLDER + +# createContractMarketTab +lblContractMarketTab.text=Contract Market Options +lblContractMarketTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam + +# createContractMarketGeneralOptionsPanel +lblContractMarketMethod.text=Market Method +lblContractMarketMethod.tooltip=PLACEHOLDER +lblContractSearchRadius.text=Search Radius +lblContractSearchRadius.tooltip=PLACEHOLDER +lblVariableContractLength.text=Vary Contract Lengths +lblVariableContractLength.tooltip=PLACEHOLDER +lblContractMarketReportRefresh.text=Post Report on Market Refresh +lblContractMarketReportRefresh.tooltip=PLACEHOLDER +lblCoontractMaxSalvagePercentage.text=Max Salvage Percent +lblCoontractMaxSalvagePercentage.tooltip=PLACEHOLDER +lblDropShipBonusPercentage.text=DropShip Bonus Percent +lblDropShipBonusPercentage.tooltip=PLACEHOLDER + +# createMercenaryPanel +lblContractPayPanel.text=Contract Pay +lblContractEquipment.text=TO&E Value Influences Pay +lblContractEquipment.tooltip=PLACEHOLDER +lblEquipContractSaleValue.text=Base on Sale Value +lblEquipContractSaleValue.tooltip=PLACEHOLDER +lblEquipPercent.text=Combat Unit % +lblEquipPercent.tooltip=PLACEHOLDER +lblDropShipPercent.text=DropShip % +lblDropShipPercent.tooltip=PLACEHOLDER +lblJumpShipPercent.text=JumpShip Percent +lblJumpShipPercent.tooltip=PLACEHOLDER +lblWarShipPercent.text=WarShip Percent +lblWarShipPercent.tooltip=PLACEHOLDER +lblContractPersonnel.text=Payroll Influences Pay +lblContractPersonnel.tooltip=PLACEHOLDER +lblBLCSaleValue.text=Battle Loss Compensation uses Sale Value +lblBLCSaleValue.tooltip=PLACEHOLDER +lblUseInfantryDoseNotCountBox.text=Infantry Not Counted Towards Contract Pay +lblUseInfantryDoseNotCountBox.tooltip=PLACEHOLDER +lblOverageRepaymentInFinalPayment.text=Repay Salvage Overages on Contract End +lblOverageRepaymentInFinalPayment.tooltip=PLACEHOLDER \ No newline at end of file diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index c62056ac99..a0b4d37fee 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -218,7 +218,8 @@ private JTabbedPane createStrategicOperationsParentTab() { JTabbedPane marketsContentTabs = createSubTabs(Map.of( "personnelMarketTab", marketsTab.createPersonnelMarketTab(), - "unitMarketTab", marketsTab.createUnitMarketTab())); + "unitMarketTab", marketsTab.createUnitMarketTab(), + "contractMarketTab", marketsTab.createContractMarketTab())); // Markets + Mercenary (don't forget useInfantryDoseNotCountBox) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java index 2ad8a29930..0e1a9e49ab 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java @@ -1,7 +1,10 @@ package mekhq.gui.panes.campaignOptions.tabs; import megamek.client.ui.baseComponents.MMComboBox; +import megamek.client.ui.swing.util.UIUtil; import megamek.common.enums.SkillLevel; +import mekhq.campaign.campaignOptions.CampaignOptions; +import mekhq.campaign.market.enums.ContractMarketMethod; import mekhq.campaign.market.enums.UnitMarketMethod; import mekhq.campaign.personnel.Skills; import mekhq.module.PersonnelMarketServiceManager; @@ -46,6 +49,33 @@ public class MarketsTab { //end Unit Market //start Contract Market + private JPanel pnlContractMarketGeneralOptions; + private JLabel lblContractMarketMethod; + private MMComboBox comboContractMarketMethod; + private JLabel lblContractSearchRadius; + private JSpinner spnContractSearchRadius; + private JCheckBox chkVariableContractLength; + private JCheckBox chkContractMarketReportRefresh; + private JLabel lblCoontractMaxSalvagePercentage; + private JSpinner spnContractMaxSalvagePercentage; + private JLabel lblDropShipBonusPercentage; + private JSpinner spnDropShipBonusPercentage; + + private JPanel pnlContractPay; + private JRadioButton btnContractEquipment; + private JLabel lblEquipPercent; + private JSpinner spnEquipPercent; + private JCheckBox chkEquipContractSaleValue; + private JLabel lblDropShipPercent; + private JSpinner spnDropShipPercent; + private JLabel lblJumpShipPercent; + private JSpinner spnJumpShipPercent; + private JLabel lblWarShipPercent; + private JSpinner spnWarShipPercent; + private JRadioButton btnContractPersonnel; + private JCheckBox useInfantryDoseNotCountBox; + private JCheckBox chkBLCSaleValue; + private JCheckBox chkOverageRepaymentInFinalPayment; //end Contract Market MarketsTab(JFrame frame, String name) { @@ -362,15 +392,232 @@ JPanel createUnitMarketTab() { } private void initializeContractMarket() { - + pnlContractMarketGeneralOptions = new JPanel(); + lblContractMarketMethod = new JLabel(); + comboContractMarketMethod = new MMComboBox<>("comboContractMarketMethod", + ContractMarketMethod.values()); + lblContractSearchRadius = new JLabel(); + spnContractSearchRadius = new JSpinner(); + chkVariableContractLength = new JCheckBox(); + chkContractMarketReportRefresh = new JCheckBox(); + lblCoontractMaxSalvagePercentage = new JLabel(); + spnContractMaxSalvagePercentage = new JSpinner(); + lblDropShipBonusPercentage = new JLabel(); + spnDropShipBonusPercentage = new JSpinner(); + + pnlContractPay = new JPanel(); + btnContractEquipment = new JRadioButton(); + lblEquipPercent = new JLabel(); + spnEquipPercent = new JSpinner(); + chkEquipContractSaleValue = new JCheckBox(); + lblDropShipPercent = new JLabel(); + spnDropShipPercent = new JSpinner(); + lblJumpShipPercent = new JLabel(); + spnJumpShipPercent = new JSpinner(); + lblWarShipPercent = new JLabel(); + spnWarShipPercent = new JSpinner(); + btnContractPersonnel = new JRadioButton(); + useInfantryDoseNotCountBox = new JCheckBox(); + chkBLCSaleValue = new JCheckBox(); + chkOverageRepaymentInFinalPayment = new JCheckBox(); } JPanel createContractMarketTab() { // Header - JPanel headerPanel = createHeaderPanel("PriceMultipliersTab", + JPanel headerPanel = createHeaderPanel("ContractMarketTab", getImageDirectory() + "logo_clan_smoke_jaguar.png", false, "", true); - return null; + // Contents + pnlContractMarketGeneralOptions = createContractMarketGeneralOptionsPanel(); + pnlContractPay = createContractPayPanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("ContractMarketTab", true, + ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(pnlContractMarketGeneralOptions) + .addComponent(pnlContractPay))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addGroup(layout.createSequentialGroup() + .addComponent(pnlContractMarketGeneralOptions) + .addComponent(pnlContractPay) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + // Create Parent Panel and return + return createParentPanel(panel, "ContractMarketTab"); + } + + private JPanel createContractMarketGeneralOptionsPanel() { + // Contents + lblContractMarketMethod = createLabel("ContractMarketMethod"); + comboContractMarketMethod = new MMComboBox<>("comboContractMarketMethod", + ContractMarketMethod.values()); + + lblContractSearchRadius = createLabel("ContractSearchRadius"); + spnContractSearchRadius = createSpinner("ContractSearchRadius", + 300, 100, 2500, 100); + + chkVariableContractLength = createCheckBox("VariableContractLength"); + + chkContractMarketReportRefresh = createCheckBox("ContractMarketReportRefresh"); + + lblCoontractMaxSalvagePercentage = createLabel("CoontractMaxSalvagePercentage"); + spnContractMaxSalvagePercentage = createSpinner("CoontractMaxSalvagePercentage", + 100, 0, 100, 10); + + lblDropShipBonusPercentage = createLabel("DropShipBonusPercentage"); + spnDropShipBonusPercentage = createSpinner("DropShipBonusPercentage", + 0, 0, 20, 5); + + // Layout the Panel + final JPanel panel = createStandardPanel("ContractMarketGeneralOptionsPanel", + false, ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblContractMarketMethod) + .addComponent(comboContractMarketMethod)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblContractSearchRadius) + .addComponent(spnContractSearchRadius)) + .addComponent(chkVariableContractLength) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblCoontractMaxSalvagePercentage) + .addComponent(spnContractMaxSalvagePercentage)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblDropShipBonusPercentage) + .addComponent(spnDropShipBonusPercentage)) + .addComponent(chkContractMarketReportRefresh)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblContractMarketMethod) + .addComponent(comboContractMarketMethod) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblContractSearchRadius) + .addComponent(spnContractSearchRadius) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkVariableContractLength) + .addGroup(layout.createSequentialGroup() + .addComponent(lblCoontractMaxSalvagePercentage) + .addComponent(spnContractMaxSalvagePercentage) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblDropShipBonusPercentage) + .addComponent(spnDropShipBonusPercentage) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkContractMarketReportRefresh)); + + return panel; + } + + private JPanel createContractPayPanel() { + // Contents + btnContractEquipment = new JRadioButton(resources.getString("lblContractEquipment.text")); + btnContractEquipment.setToolTipText(resources.getString("lblContractEquipment.tooltip")); + + chkEquipContractSaleValue = createCheckBox("EquipContractSaleValue"); + + lblEquipPercent = createLabel("EquipPercent"); + spnEquipPercent = createSpinner("EquipPercent", + 0.1, 0.1, CampaignOptions.MAXIMUM_COMBAT_EQUIPMENT_PERCENT, 0.1); + + lblDropShipPercent = createLabel("DropShipPercent"); + spnDropShipPercent = createSpinner("DropShipPercent", + 0.1, 0.1, CampaignOptions.MAXIMUM_COMBAT_EQUIPMENT_PERCENT, 0.1); + + lblJumpShipPercent = createLabel("JumpShipPercent"); + spnJumpShipPercent = createSpinner("JumpShipPercent", + 0.1, 0.1, CampaignOptions.MAXIMUM_COMBAT_EQUIPMENT_PERCENT, 0.1); + + lblWarShipPercent = createLabel("WarShipPercent"); + spnWarShipPercent = createSpinner("WarShipPercent", + 0.1, 0.1, CampaignOptions.MAXIMUM_COMBAT_EQUIPMENT_PERCENT, 0.1); + + btnContractPersonnel = new JRadioButton(resources.getString("lblContractPersonnel.text")); + btnContractPersonnel.setToolTipText(resources.getString("lblContractPersonnel.tooltip")); + + chkBLCSaleValue = createCheckBox("BLCSaleValue"); + + useInfantryDoseNotCountBox = createCheckBox("UseInfantryDoseNotCountBox"); + + chkOverageRepaymentInFinalPayment = createCheckBox("OverageRepaymentInFinalPayment"); + + // Layout the Panel + final JPanel panel = createStandardPanel("ContractPayPanel", + true, "ContractPayPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(btnContractEquipment) + .addComponent(chkEquipContractSaleValue) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblEquipPercent) + .addComponent(spnEquipPercent)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblDropShipPercent) + .addComponent(spnDropShipPercent)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblJumpShipPercent) + .addComponent(spnJumpShipPercent)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblWarShipPercent) + .addComponent(spnWarShipPercent)) + .addComponent(btnContractPersonnel) + .addGap(UIUtil.scaleForGUI(15)) + .addComponent(chkBLCSaleValue) + .addComponent(useInfantryDoseNotCountBox) + .addComponent(chkOverageRepaymentInFinalPayment)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(btnContractEquipment) + .addGroup(layout.createSequentialGroup() + .addGap(UIUtil.scaleForGUI(25)) + .addComponent(chkEquipContractSaleValue) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGap(UIUtil.scaleForGUI(25)) + .addComponent(lblEquipPercent) + .addComponent(spnEquipPercent) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGap(UIUtil.scaleForGUI(25)) + .addComponent(lblDropShipPercent) + .addComponent(spnDropShipPercent) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGap(UIUtil.scaleForGUI(25)) + .addComponent(lblJumpShipPercent) + .addComponent(spnJumpShipPercent) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGap(UIUtil.scaleForGUI(25)) + .addComponent(lblWarShipPercent) + .addComponent(spnWarShipPercent) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(btnContractPersonnel) + .addComponent(chkBLCSaleValue) + .addComponent(useInfantryDoseNotCountBox) + .addComponent(chkOverageRepaymentInFinalPayment)); + + return panel; } } From 1586bb3b247ebb78b3fc71940df2b2e63db3c941 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 14 Oct 2024 12:16:10 -0500 Subject: [PATCH 068/117] Add checkbox for limiting mercenary size Introduced a new checkbox `chkMercSizeLimited` to the MarketsTab. This checkbox allows users to set a limit on the size of mercenary units. Updated the layout and initialization code to include this new component. --- .../src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java index 0e1a9e49ab..877ca5555b 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java @@ -74,6 +74,7 @@ public class MarketsTab { private JSpinner spnWarShipPercent; private JRadioButton btnContractPersonnel; private JCheckBox useInfantryDoseNotCountBox; + private JCheckBox chkMercSizeLimited; private JCheckBox chkBLCSaleValue; private JCheckBox chkOverageRepaymentInFinalPayment; //end Contract Market @@ -418,6 +419,7 @@ private void initializeContractMarket() { spnWarShipPercent = new JSpinner(); btnContractPersonnel = new JRadioButton(); useInfantryDoseNotCountBox = new JCheckBox(); + chkMercSizeLimited = new JCheckBox(); chkBLCSaleValue = new JCheckBox(); chkOverageRepaymentInFinalPayment = new JCheckBox(); } @@ -555,6 +557,7 @@ private JPanel createContractPayPanel() { chkBLCSaleValue = createCheckBox("BLCSaleValue"); useInfantryDoseNotCountBox = createCheckBox("UseInfantryDoseNotCountBox"); + chkMercSizeLimited = createCheckBox("MercSizeLimited"); chkOverageRepaymentInFinalPayment = createCheckBox("OverageRepaymentInFinalPayment"); @@ -584,6 +587,7 @@ private JPanel createContractPayPanel() { .addGap(UIUtil.scaleForGUI(15)) .addComponent(chkBLCSaleValue) .addComponent(useInfantryDoseNotCountBox) + .addComponent(chkMercSizeLimited) .addComponent(chkOverageRepaymentInFinalPayment)); layout.setHorizontalGroup( @@ -616,6 +620,7 @@ private JPanel createContractPayPanel() { .addComponent(btnContractPersonnel) .addComponent(chkBLCSaleValue) .addComponent(useInfantryDoseNotCountBox) + .addComponent(chkMercSizeLimited) .addComponent(chkOverageRepaymentInFinalPayment)); return panel; From b9a199eb90f8df6ab4e575d2dd10a86573a45723 Mon Sep 17 00:00:00 2001 From: HammerGS Date: Mon, 14 Oct 2024 17:18:41 -0600 Subject: [PATCH 069/117] Update history.txt --- MekHQ/docs/history.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MekHQ/docs/history.txt b/MekHQ/docs/history.txt index b0139a2eeb..0df176788a 100644 --- a/MekHQ/docs/history.txt +++ b/MekHQ/docs/history.txt @@ -106,7 +106,9 @@ MEKHQ VERSION HISTORY: + PR #5025: Pin/sticky force view tab on TO&E panel + PR #5040: Clarify map dimensions in scenario displays + PR #5042: Multiple FG3 Improvements -+ PF #5043: New names cleanup and potential bugfixes ++ PR #5043: New names cleanup and potential bugfixes ++ PR #5046: Prevent StratCon from Pulling in Player DropShips, when Option is Disabled ++ PR #5044: Add Check for StratCon Usage in getAtBBattleChance Method 0.50.0 (2024-09-01 2000 UTC) (THIS MARKS THE START OF JAVA 17 AS THE MINIMUM REQUIRED) + PR #4332: CI Updates for windows build and normalizing From 7afcb1469a4cb2bebd8939d202f6d4edc0fac70a Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 14 Oct 2024 18:53:01 -0500 Subject: [PATCH 070/117] Add RulesetsTab.java for campaign options Introduced a new `RulesetsTab` class to handle various campaign options in MekHQ. This tab includes universal options, legacy AtB options, and StratCon options for enhanced scenario and map generation configuration. --- .../NEWCampaignOptionsDialog.properties | 143 +++- .../campaignOptions/CampaignOptions.java | 8 +- .../campaignOptions/tabs/BiographyTab.java | 21 +- .../tabs/CampaignOptionsPane.java | 9 +- .../tabs/CampaignOptionsUtilities.java | 25 +- .../tabs/EquipmentAndSuppliesTab.java | 26 +- .../campaignOptions/tabs/FinancesTab.java | 8 +- .../campaignOptions/tabs/GeneralTab.java | 4 +- .../campaignOptions/tabs/MarketsTab.java | 12 +- .../campaignOptions/tabs/PersonnelTab.java | 30 +- .../tabs/RelationshipsTab.java | 16 +- .../tabs/RepairAndMaintenanceTab.java | 10 +- .../campaignOptions/tabs/RulesetsTab.java | 800 ++++++++++++++++++ .../tabs/TurnoverAndRetentionTab.java | 12 +- 14 files changed, 1041 insertions(+), 83 deletions(-) create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RulesetsTab.java diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index f8ef692971..8ac8b3e96c 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -1219,5 +1219,146 @@ lblBLCSaleValue.text=Battle Loss Compensation uses Sale Value lblBLCSaleValue.tooltip=PLACEHOLDER lblUseInfantryDoseNotCountBox.text=Infantry Not Counted Towards Contract Pay lblUseInfantryDoseNotCountBox.tooltip=PLACEHOLDER +lblMercSizeLimited.text=Mercenary Campaign Size Impacts Pay +lblMercSizeLimited.tooltip=PLACEHOLDER lblOverageRepaymentInFinalPayment.text=Repay Salvage Overages on Contract End -lblOverageRepaymentInFinalPayment.tooltip=PLACEHOLDER \ No newline at end of file +lblOverageRepaymentInFinalPayment.tooltip=PLACEHOLDER + +# Markets Tab +rulesetsContentTabs.title=Custom Rulesets + +stratConGeneralTab.title=General +stratConGeneralTab.border="Strategy is just a fancy way of saying, 'I'm going to send you in first\ + \ and see what happens.'"\ +
- Sergeant Milo "Wildcard" Trent, Raven's Fury Mercenaries + +legacyTab.title=Legacy Options +legacyTab.border="In the end, your legacy is the sum of every decision you made in the cockpit. What\ + \ you fought for and who you stood beside is what remains."\ +
- Colonel Elias "Warhound" Drake, Jade Falcon Guard + +# substantializeUniversalOptions +lblSkillLevel.text=Difficulty +lblSkillLevel.tooltip=PLACEHOLDER +lblOpForLanceTypeMeks.text=Meks +lblOpForLanceTypeMeks.tooltip=PLACEHOLDER +lblOpForLanceTypeMixed.text=Mixed +lblOpForLanceTypeMixed.tooltip=PLACEHOLDER +lblOpForLanceTypeVehicle.text=Vehicles +lblOpForLanceTypeVehicle.tooltip=PLACEHOLDER +lblUseDropShips.text=Use Player DropShips +lblUseDropShips.tooltip=PLACEHOLDER +lblOpForUsesVTOLs.text=Enable OpFor VTOLs +lblOpForUsesVTOLs.tooltip=PLACEHOLDER +lblClanVehicles.text=Enable Clan Vehicles +lblClanVehicles.tooltip=PLACEHOLDER +lblRegionalMekVariations.text=Faction Influences Mek Weights +lblRegionalMekVariations.tooltip=PLACEHOLDER +lblAttachedPlayerCamouflage.text=Attached Units use Campaign Camouflage +lblAttachedPlayerCamouflage.tooltip=PLACEHOLDER +lblPlayerControlsAttachedUnits.text=Player Controls Attached Units +lblPlayerControlsAttachedUnits.tooltip=PLACEHOLDER +lblSPAUpgradeIntensity.text=SPA Chance +lblSPAUpgradeIntensity.tooltip=PLACEHOLDER +lblAutoConfigMunitions.text=OpFor Equip Special Munitions +lblAutoConfigMunitions.tooltip=PLACEHOLDER +lblScenarioModMax.text=Maximum Count +lblScenarioModMax.tooltip=PLACEHOLDER +lblScenarioModChance.text=Chance +lblScenarioModChance.tooltip=PLACEHOLDER +lblScenarioModBV.text=Battle Value Percent +lblScenarioModBV.tooltip=PLACEHOLDER +lblUseWeatherConditions.text=Enable Weather Conditions +lblUseWeatherConditions.tooltip=PLACEHOLDER +lblUseLightConditions.text=Enable Light Conditions +lblUseLightConditions.tooltip=PLACEHOLDER +lblUsePlanetaryConditions.text=Enable Planetary Conditions +lblUsePlanetaryConditions.tooltip=PLACEHOLDER +lblFixedMapChance.text=User-Made Map Chance +lblFixedMapChance.tooltip=PLACEHOLDER +lblRestrictPartsByMission.text=Missions Influence Availability +lblRestrictPartsByMission.tooltip=PLACEHOLDER +lblBonusPartExchangeValue.text=Enable Bonus Part Exchange +lblBonusPartExchangeValue.tooltip=PLACEHOLDER +lblBonusPartMaxExchangeCount.text=Exchange Maximum +lblBonusPartMaxExchangeCount.tooltip=PLACEHOLDER +lblLimitLanceWeight.text=Limit Player Drop Weights +lblLimitLanceWeight.tooltip=PLACEHOLDER +lblLimitLanceNumUnits.text=Limit Player Drop Sizes +lblLimitLanceNumUnits.tooltip=PLACEHOLDER +lblUseStrategy.text=Commander Strategy Influences Lance Counts +lblUseStrategy.tooltip=PLACEHOLDER +lblBaseStrategyDeployment.text=Base Force Count +lblBaseStrategyDeployment.tooltip=PLACEHOLDER +lblAdditionalStrategyDeployment.text=Per Rank in Strategy +lblAdditionalStrategyDeployment.tooltip=PLACEHOLDER +lblAdjustPaymentForStrategy.text=Adjust Contract Pay by Maximum Force Count +lblAdjustPaymentForStrategy.tooltip=PLACEHOLDER + +# createUniversalScenarioGenerationPanel +lblUniversalScenarioGenerationPanel.text=Scenario Generation + +# createUniversalUnitRatioPanel +lblUniversalUnitRatioPanel.text=Unit Ratios + +# createUniversalModifiersPanel +lblUniversalModifiersPanel.text=Random Modifiers + +# createUniversalMapGenerationPanel +lblUniversalMapGenerationPanel.text=Map Generation + +# createUniversalPartsPanel +lblUniversalPartsPanel.text=Parts Availability + +# createUniversalLancePanel +lblUniversalLancePanel.text=Force Organization + +# createStratConTab +lblStratConTab.text=General Options +lblStratConTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblUseStratCon.text=Enable StratCon +lblUseStratCon.tooltip=PLACEHOLDER +lblUseGenericBattleValue.text=Enable Force Generation 3 +lblUseGenericBattleValue.tooltip=PLACEHOLDER +lblUseVerboseBidding.text=Enable Verbose Clan Bidding +lblUseVerboseBidding.tooltip=PLACEHOLDER + +# initializeLegacyTab +lblLegacyTab.text=Legacy Options +lblLegacyTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblUseAtB.text=Enable AtB (Deprecated) +lblUseAtB.tooltip=PLACEHOLDER + +# createLegacyOpForGenerationPanel +lblLegacyOpForGenerationPanel.text=Force Generation +lblUseVehicles.text=Enable NPC Vehicles +lblUseVehicles.tooltip=PLACEHOLDER +lblDoubleVehicles.text=Double NPC Vehicles +lblDoubleVehicles.tooltip=PLACEHOLDER +lblOpForUsesAero.text=Enable NPC Aerospace Fighters +lblOpForUsesAero.tooltip=PLACEHOLDER +lblOpForAeroChance.text=Aerospace Chance +lblOpForAeroChance.tooltip=PLACEHOLDER +lblOpForUsesLocalForces.text=Enable NPC Infantry & Turrets +lblOpForUsesLocalForces.tooltip=PLACEHOLDER +lblAdjustPlayerVehicles.text=Treat Player Vehicles as Half Weight +lblAdjustPlayerVehicles.tooltip=PLACEHOLDER + +# createLegacyScenarioGenerationPanel +lblLegacyScenarioGenerationPanel.text=Scenario Generation +lblGenerateChases.text=Generate Chase Scenarios +lblGenerateChases.tooltip=PLACEHOLDER +lblAtBBattleIntensity.text=Battle Frequency +lblAtBBattleIntensity.tooltip=PLACEHOLDER +lblIntensityUpdate.text=Update Battle Frequency +lblIntensityUpdate.tooltip=PLACEHOLDER \ No newline at end of file diff --git a/MekHQ/src/mekhq/campaign/campaignOptions/CampaignOptions.java b/MekHQ/src/mekhq/campaign/campaignOptions/CampaignOptions.java index 41718ecc69..eb5dcf8e6a 100644 --- a/MekHQ/src/mekhq/campaign/campaignOptions/CampaignOptions.java +++ b/MekHQ/src/mekhq/campaign/campaignOptions/CampaignOptions.java @@ -4275,18 +4275,22 @@ public void setUseStratCon(final boolean useStratCon) { this.useStratCon = useStratCon; } + @Deprecated public boolean isUseAero() { - return useAero; + return true; } + @Deprecated public void setUseAero(final boolean useAero) { this.useAero = useAero; } + @Deprecated public boolean isUseVehicles() { - return useVehicles; + return true; } + @Deprecated public void setUseVehicles(final boolean useVehicles) { this.useVehicles = useVehicles; } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java index 8efe9b490c..ab98a2c404 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java @@ -323,7 +323,7 @@ JPanel createGeneralTab() { // Header JPanel headerPanel = createHeaderPanel("BiographyGeneralTab", getImageDirectory() + "logo_federated_suns.png", - false, "", true); + true); // Contents chkUseDylansRandomXP = createCheckBox("UseDylansRandomXP"); @@ -343,7 +343,7 @@ JPanel createGeneralTab() { pnlAnniversariesPanel = createAnniversariesPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("BiographyGeneralTab", true, ""); + final JPanel panel = createStandardPanel("BiographyGeneralTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -426,8 +426,7 @@ private JPanel createAnniversariesPanel() { JPanel createBackgroundsTab() { // Header JPanel headerPanel = createHeaderPanel("BackgroundsTab", - getImageDirectory() + "logo_clan_goliath_scorpion.png", - false, "", true); + getImageDirectory() + "logo_clan_goliath_scorpion.png", true); // Contents chkUseRandomPersonalities = createCheckBox("UseRandomPersonalities"); @@ -438,7 +437,7 @@ JPanel createBackgroundsTab() { pnlRandomOriginOptions = createRandomOriginOptionsPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("BackgroundsTab", true, ""); + final JPanel panel = createStandardPanel("BackgroundsTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -651,7 +650,7 @@ JPanel createDeathTab() { // Header JPanel headerPanel = createHeaderPanel("DeathTab", getImageDirectory() + "logo_filtvelt_coalition.png", - false, "", true); + true); // Contents chkKeepMarriedNameUponSpouseDeath = createCheckBox("KeepMarriedNameUponSpouseDeath"); @@ -681,7 +680,7 @@ public Component getListCellRendererComponent(final JList list, final Object 0, 0, 100, 0.000001); // Layout the Panel - final JPanel panel = createStandardPanel("DeathTab", true, ""); + final JPanel panel = createStandardPanel("DeathTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -767,7 +766,7 @@ JPanel createEducationTab() { // Header JPanel headerPanel = createHeaderPanel("EducationTab", getImageDirectory() + "logo_free_worlds_league.png", - false, "", true); + true); // Contents chkUseEducationModule = createCheckBox("UseEducationModule"); @@ -800,7 +799,7 @@ JPanel createEducationTab() { pnlAccidentsAndEvents = createAccidentsAndEventsPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("EducationTab", true, ""); + final JPanel panel = createStandardPanel("EducationTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -1050,7 +1049,7 @@ JPanel createNameAndPortraitGenerationTab() { // Header JPanel headerPanel = createHeaderPanel("NameAndPortraitGenerationTab", getImageDirectory() + "logo_clan_mongoose.png", - false, "", true); + true); // Contents chkUseOriginFactionForNames = createCheckBox("UseOriginFactionForNames"); @@ -1182,7 +1181,7 @@ JPanel createRankTab() { // Header JPanel headerPanel = createHeaderPanel("RankTab", getImageDirectory() + "logo_hanseatic_league.png", - false, "", true); + true); // Contents rankSystemsPane = new RankSystemsPane(frame, campaign); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java index a0b4d37fee..b6a818f7c0 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java @@ -221,15 +221,20 @@ private JTabbedPane createStrategicOperationsParentTab() { "unitMarketTab", marketsTab.createUnitMarketTab(), "contractMarketTab", marketsTab.createContractMarketTab())); - // Markets + Mercenary (don't forget useInfantryDoseNotCountBox) - // Rulesets + RulesetsTab rulesetsTab = new RulesetsTab(getFrame(), "rulesetsTab"); + + JTabbedPane rulesetsContentTabs = createSubTabs(Map.of( + "stratConGeneralTab", rulesetsTab.createStratConTab(), + "legacyTab", rulesetsTab.createLegacyTab())); // Add tabs strategicOperationsParentTab.addTab(String.format("%s", 4, resources.getString("financesContentTabs.title")), financesContentTabs); strategicOperationsParentTab.addTab(String.format("%s", 4, resources.getString("marketsContentTabs.title")), marketsContentTabs); + strategicOperationsParentTab.addTab(String.format("%s", 4, + resources.getString("rulesetsContentTabs.title")), rulesetsContentTabs); addTab(String.format("%s", 4, resources.getString("strategicOperationsParentTab.title")), strategicOperationsParentTab); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index 532807e87c..f91619fad4 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -207,6 +207,24 @@ private static int processWrapSize(@Nullable Integer customWrapSize) { return customWrapSize == null ? 100 : customWrapSize; } + /** + * Creates a standard {@link JPanel} with a titled border. + *

+ * {@code createStandardLayout} should also be called and the resulting {@link GroupLayout} + * assigned to the panel via {@code setLayout}. + *

+ * If {@code borderTitle} isn't empty the resource bundle reference, used to fetch the border's + * title, will be {@code "lbl" + borderTitle + ".text"} + * + * @param name the name of the panel. + * @param includeBorder whether the panel should have a border. + * + * @return a {@link JPanel} with a titled border and {@link GroupLayout} as its layout manager + */ + static JPanel createStandardPanel(String name, boolean includeBorder) { + return createStandardPanel(name, includeBorder, ""); + } + /** * Creates a standard {@link JPanel} with a titled border. *

@@ -263,13 +281,10 @@ static JPanel createStandardPanel(String name, boolean includeBorder, String bor * * @param name the name of the header panel. * @param imageAddress the file path of the image to be displayed in the panel - * @param includeBorder whether the panel should have a border - * @param borderTitle the title of the border; can be empty for an untitled border * @param includeBodyText if {@code true}, include a second {@link JLabel}. * @return a {@link JPanel} representing the header panel */ - static JPanel createHeaderPanel(String name, String imageAddress, boolean includeBorder, - String borderTitle, boolean includeBodyText) { + static JPanel createHeaderPanel(String name, String imageAddress, boolean includeBodyText) { ImageIcon imageIcon = new ImageIcon(imageAddress); JLabel imageLabel = new JLabel(imageIcon); @@ -286,7 +301,7 @@ static JPanel createHeaderPanel(String name, String imageAddress, boolean includ lblBody.setMaximumSize(new Dimension(UIUtil.scaleForGUI(750), size.height)); } - final JPanel panel = createStandardPanel("pnl" + name + "HeaderPanel", includeBorder, borderTitle); + final JPanel panel = createStandardPanel("pnl" + name + "HeaderPanel", false, ""); Dimension size = panel.getPreferredSize(); panel.setPreferredSize(new Dimension(UIUtil.scaleForGUI(750), size.height)); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java index c7f8288a15..e6d87a2aa5 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java @@ -215,8 +215,7 @@ private void initializeTechLimitsTab() { JPanel createAcquisitionTab() { // Header JPanel headerPanel = createHeaderPanel("AcquisitionTab", - getImageDirectory() + "logo_calderon_protectorate.png", false, - "", true); + getImageDirectory() + "logo_calderon_protectorate.png", true); // Acquisitions skill lblChoiceAcquireSkill = createLabel("ChoiceAcquireSkill"); @@ -245,7 +244,7 @@ JPanel createAcquisitionTab() { 0,0, 100, 1); // Layout the Panel - final JPanel panel = createStandardPanel("acquisitionTab", true, ""); + final JPanel panel = createStandardPanel("acquisitionTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -301,15 +300,14 @@ JPanel createAcquisitionTab() { JPanel createPlanetaryAcquisitionTab() { // Header JPanel headerPanel = createHeaderPanel("PlanetaryAcquisitionTab", - getImageDirectory() + "logo_capellan_confederation.png", false, - "", true); + getImageDirectory() + "logo_capellan_confederation.png", true); // Sub-Panels JPanel options = createOptionsPanel(); JPanel modifiers = createModifiersPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("PlanetaryAcquisitionTab", true, ""); + final JPanel panel = createStandardPanel("PlanetaryAcquisitionTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -476,7 +474,7 @@ private JPanel createTechModifiersPanel() { techLabel.setName(String.format("

%s
%s
%s
buildAcquireSkillComboOptions() { JPanel createTechLimitsTab() { // Header JPanel headerPanel = createHeaderPanel("TechLimitsTab", - getImageDirectory() + "logo_clan_cloud_cobra.png", false, - "", true); + getImageDirectory() + "logo_clan_cloud_cobra.png", true); // Limit Parts/Units by Year limitByYearBox = createCheckBox("LimitByYearBox"); @@ -837,7 +833,7 @@ JPanel createTechLimitsTab() { useAmmoByTypeBox = createCheckBox("UseAmmoByTypeBox"); // Layout the Panel - final JPanel panel = createStandardPanel("TechLimitsTab", true, ""); + final JPanel panel = createStandardPanel("TechLimitsTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java index b57c9093a9..4275e61998 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java @@ -184,7 +184,7 @@ JPanel createFinancesGeneralOptionsTab() { // Header JPanel headerPanel = createHeaderPanel("FinancesGeneralTab", getImageDirectory() + "logo_clan_nova_cat.png", - false, "", true); + true); // Contents pnlGeneralOptions = createGeneralOptionsPanel(); @@ -296,7 +296,7 @@ private JPanel createOtherSystemsPanel() { pnlShares = createSharesPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("OtherSystemsPanel", false, ""); + final JPanel panel = createStandardPanel("OtherSystemsPanel", false); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -334,7 +334,7 @@ private JPanel createGeneralOptionsPanel() { newFinancialYearFinancesToCSVExportBox = createCheckBox("NewFinancialYearFinancesToCSVExportBox"); // Layout the Panel - final JPanel panel = createStandardPanel("GeneralOptionsPanel", false, ""); + final JPanel panel = createStandardPanel("GeneralOptionsPanel", false); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -518,7 +518,7 @@ JPanel createPriceMultipliersTab() { // Header JPanel headerPanel = createHeaderPanel("PriceMultipliersTab", getImageDirectory() + "logo_illyrian_palatinate.png", - false, "", true); + true); // Contents pnlGeneralMultipliers = createGeneralMultipliersPanel(); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java index fc560265e5..3feb4a3d18 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java @@ -134,7 +134,7 @@ public AbstractMHQScrollablePanel createGeneralTab() { new GridBagLayout()); // Layout the Panel - final JPanel panel = createStandardPanel("generalTab", true, ""); + final JPanel panel = createStandardPanel("generalTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -219,7 +219,7 @@ private static JPanel createGeneralHeader() { Dimension size = lblBody.getPreferredSize(); lblBody.setMaximumSize(new Dimension(UIUtil.scaleForGUI(750), size.height)); - final JPanel panel = createStandardPanel("pnlGeneralHeaderPanel", false, ""); + final JPanel panel = createStandardPanel("pnlGeneralHeaderPanel", false); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java index 877ca5555b..cfa5450fe7 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java @@ -120,7 +120,7 @@ JPanel createPersonnelMarketTab() { // Header JPanel headerPanel = createHeaderPanel("PersonnelMarketTab", getImageDirectory() + "logo_clan_sea_fox.png", - false, "", true); + true); // Contents pnlPersonnelMarketGeneralOptions = createPersonnelMarketGeneralOptionsPanel(); @@ -214,7 +214,7 @@ private JPanel createPersonnelMarketRemovalOptionsPanel() { } // Layout the Panels - final JPanel leftPanel = createStandardPanel("LeftPanel", false, ""); + final JPanel leftPanel = createStandardPanel("LeftPanel", false); final GroupLayout leftLayout = createStandardLayout(leftPanel); leftPanel.setLayout(leftLayout); @@ -252,7 +252,7 @@ private JPanel createPersonnelMarketRemovalOptionsPanel() { .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.REGULAR)) .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); - final JPanel rightPanel = createStandardPanel("RightPanel", false, ""); + final JPanel rightPanel = createStandardPanel("RightPanel", false); final GroupLayout rightLayout = createStandardLayout(rightPanel); rightPanel.setLayout(rightLayout); @@ -327,7 +327,7 @@ JPanel createUnitMarketTab() { // Header JPanel headerPanel = createHeaderPanel("UnitMarketTab", getImageDirectory() + "logo_loathian_league.png", - false, "", true); + true); // Contents lblUnitMarketMethod = createLabel("UnitMarketMethod"); @@ -428,7 +428,7 @@ JPanel createContractMarketTab() { // Header JPanel headerPanel = createHeaderPanel("ContractMarketTab", getImageDirectory() + "logo_clan_smoke_jaguar.png", - false, "", true); + true); // Contents pnlContractMarketGeneralOptions = createContractMarketGeneralOptionsPanel(); @@ -483,7 +483,7 @@ private JPanel createContractMarketGeneralOptionsPanel() { // Layout the Panel final JPanel panel = createStandardPanel("ContractMarketGeneralOptionsPanel", - false, ""); + false); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java index 45d57aefbc..3815f2a082 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java @@ -361,7 +361,7 @@ JPanel createGeneralTab() { // Header JPanel headerPanel = createHeaderPanel("PersonnelGeneralTab", getImageDirectory() + "logo_circinus_federation.png", - false, "", true); + true); // Contents chkUseTactics = createCheckBox("UseTactics"); @@ -378,7 +378,7 @@ JPanel createGeneralTab() { personnelCleanUpPanel = createPersonnelCleanUpPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("PersonnelGeneralTab", true, ""); + final JPanel panel = createStandardPanel("PersonnelGeneralTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -462,7 +462,7 @@ JPanel createPersonnelLogsTab() { // Header JPanel headerPanel = createHeaderPanel("PersonnelLogsTab", getImageDirectory() + "logo_clan_coyote.png", - false, "", true); + true); // Contents chkUseTransfers = createCheckBox("UseTransfers"); @@ -475,7 +475,7 @@ JPanel createPersonnelLogsTab() { chkDisplayKillRecord = createCheckBox("DisplayKillRecord"); // Layout the Panel - final JPanel panel = createStandardPanel("PersonnelLogsTab", true, ""); + final JPanel panel = createStandardPanel("PersonnelLogsTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -517,7 +517,7 @@ JPanel createPersonnelInformationTab() { // Header JPanel headerPanel = createHeaderPanel("PersonnelInformation", getImageDirectory() + "logo_comstar.png", - false, "", true); + true); // Contents chkUseTimeInService = createCheckBox("UseTimeInService"); @@ -529,7 +529,7 @@ JPanel createPersonnelInformationTab() { chkShowOriginFaction = createCheckBox("ShowOriginFaction"); // Layout the Panel - final JPanel panel = createStandardPanel("PersonnelInformation", true, ""); + final JPanel panel = createStandardPanel("PersonnelInformation", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -581,7 +581,7 @@ JPanel createAdministratorsTab() { // Header JPanel headerPanel = createHeaderPanel("AdministratorsTab", getImageDirectory() + "logo_clan_diamond_sharks.png", - false, "", true); + true); // Contents chkAdminsHaveNegotiation = createCheckBox("AdminsHaveNegotiation"); @@ -590,7 +590,7 @@ JPanel createAdministratorsTab() { chkAdminExperienceLevelIncludeScrounge = createCheckBox("AdminExperienceLevelIncludeScrounge"); // Layout the Panel - final JPanel panel = createStandardPanel("AdministratorsTab", true, ""); + final JPanel panel = createStandardPanel("AdministratorsTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -623,7 +623,7 @@ JPanel createAwardsTab() { // Header JPanel headerPanel = createHeaderPanel("AwardsTab", getImageDirectory() + "logo_draconis_combine.png", - false, "", true); + true); // Contents lblAwardBonusStyle = createLabel("AwardBonusStyle"); @@ -669,7 +669,7 @@ public Component getListCellRendererComponent(final JList list, final Object ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); // Layout the Panel - final JPanel panel = createStandardPanel("AwardsTab", true, ""); + final JPanel panel = createStandardPanel("AwardsTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -795,7 +795,7 @@ JPanel createPrisonersAndDependentsTab() { // Header JPanel headerPanel = createHeaderPanel("PrisonersAndDependentsTab", getImageDirectory() + "logo_clan_fire_mandrills.png", - false, "", true); + true); // Contents prisonerPanel = createPrisonersPanel(); @@ -926,7 +926,7 @@ JPanel createMedicalTab() { // Header JPanel headerPanel = createHeaderPanel("MedicalTab", getImageDirectory() + "logo_duchy_of_tamarind_abbey.png", - false, "", true); + true); // Contents chkUseAdvancedMedical = createCheckBox("UseAdvancedMedical"); @@ -952,7 +952,7 @@ JPanel createMedicalTab() { 25, 1, 100, 1); // Layout the Panel - final JPanel panel = createStandardPanel("MedicalTab", true, ""); + final JPanel panel = createStandardPanel("MedicalTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -1011,7 +1011,7 @@ JPanel createSalariesTab() { // Header JPanel headerPanel = createHeaderPanel("SalariesTab", getImageDirectory() + "logo_clan_ghost_bear.png", - false, "", true); + true); // Contents chkDisableSecondaryRoleSalary = createCheckBox("DisableSecondaryRoleSalary"); @@ -1020,7 +1020,7 @@ JPanel createSalariesTab() { pnlSalaryBaseSalaryPanel = createBaseSalariesPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("SalariesTab", true, ""); + final JPanel panel = createStandardPanel("SalariesTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java index 9bf44eb3fa..15220ac8ef 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java @@ -210,14 +210,14 @@ JPanel createMarriageTab() { // Header JPanel headerPanel = createHeaderPanel("MarriageTab", getImageDirectory() + "logo_federated_commonwealth.png", - false, "", true); + true); // Contents pnlMarriageGeneralOptions = createMarriageGeneralOptionsPanel(); pnlRandomMarriage = createRandomMarriagePanel(); // Layout the Panel - final JPanel panel = createStandardPanel("MarriageTab", true, ""); + final JPanel panel = createStandardPanel("MarriageTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -264,7 +264,7 @@ private JPanel createMarriageGeneralOptionsPanel() { // Layout the Panel final JPanel panel = createStandardPanel("MarriageGeneralOptionsPanel", - false, ""); + false); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -439,7 +439,7 @@ JPanel createDivorceTab() { // Header JPanel headerPanel = createHeaderPanel("DivorceTab", getImageDirectory() + "logo_clan_hells_horses.png", - false, "", true); + true); // Contents chkUseManualDivorce = createCheckBox("UseManualDivorce"); @@ -449,7 +449,7 @@ JPanel createDivorceTab() { pnlRandomDivorce = createRandomDivorcePanel(); // Layout the Panel - final JPanel panel = createStandardPanel("DivorceTab", true, ""); + final JPanel panel = createStandardPanel("DivorceTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -552,14 +552,14 @@ JPanel createProcreationTab() { // Header JPanel headerPanel = createHeaderPanel("ProcreationTab", getImageDirectory() + "logo_clan_ice_hellion.png", - false, "", true); + true); // Contents pnlProcreationGeneralOptionsPanel = createProcreationGeneralOptionsPanel(); pnlRandomProcreationPanel = createRandomProcreationPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("ProcreationTab", true, ""); + final JPanel panel = createStandardPanel("ProcreationTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -628,7 +628,7 @@ public Component getListCellRendererComponent(final JList list, final Object // Layout the Panel final JPanel panel = createStandardPanel("ProcreationGeneralOptionsPanel", - false, ""); + false); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java index f4815a1643..908ee59411 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java @@ -117,8 +117,7 @@ private void initializeMaintenanceTab() { JPanel createRepairTab() { // Header JPanel headerPanel = createHeaderPanel("RepairTab", - getImageDirectory() + "logo_aurigan_coalition.png", false, - "", true); + getImageDirectory() + "logo_aurigan_coalition.png", true); // Era Mods useEraModsCheckBox = createCheckBox("UseEraModsCheckBox"); @@ -148,7 +147,7 @@ JPanel createRepairTab() { JLabel lblDestroyPartTargetPost = new JLabel("+"); // Layout the Panel - final JPanel panel = createStandardPanel("repairTab", true, ""); + final JPanel panel = createStandardPanel("repairTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -200,8 +199,7 @@ JPanel createRepairTab() { JPanel createMaintenanceTab() { // Header JPanel headerPanel = createHeaderPanel("MaintenanceTab", - getImageDirectory() + "logo_clan_blood_spirit.png", - false, "", true); + getImageDirectory() + "logo_clan_blood_spirit.png", true); // Check Maintenance checkMaintenance = createCheckBox("CheckMaintenance"); @@ -240,7 +238,7 @@ JPanel createMaintenanceTab() { logMaintenance = createCheckBox("LogMaintenance"); // Layout the Panel - final JPanel panel = createStandardPanel("repairTab", true, ""); + final JPanel panel = createStandardPanel("repairTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RulesetsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RulesetsTab.java new file mode 100644 index 0000000000..23f5e96c57 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RulesetsTab.java @@ -0,0 +1,800 @@ +package mekhq.gui.panes.campaignOptions.tabs; + +import megamek.client.ui.baseComponents.MMComboBox; +import megamek.client.ui.swing.util.UIUtil; +import megamek.common.enums.SkillLevel; +import mekhq.campaign.mission.AtBContract; +import mekhq.campaign.mission.enums.AtBLanceRole; +import mekhq.campaign.personnel.Skills; + +import javax.swing.*; +import javax.swing.GroupLayout.Alignment; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; + +public class RulesetsTab { + JFrame frame; + String name; + + //start Universal Options + private JLabel lblSkillLevel; + private MMComboBox comboSkillLevel; + private JPanel pnlScenarioGenerationPanel; + private JPanel pnlCampaignOptions; + + private JPanel pnlUnitRatioPanel; + private JLabel lblOpForLanceTypeMeks; + private JSpinner spnOpForLanceTypeMeks; + private JLabel lblOpForLanceTypeMixed; + private JSpinner spnOpForLanceTypeMixed; + private JLabel lblOpForLanceTypeVehicle; + private JSpinner spnOpForLanceTypeVehicles; + + private JCheckBox chkUseDropShips; + private JCheckBox chkOpForUsesVTOLs; + + private JCheckBox chkClanVehicles; + private JCheckBox chkRegionalMekVariations; + + private JCheckBox chkAttachedPlayerCamouflage; + private JCheckBox chkPlayerControlsAttachedUnits; + private JLabel lblSPAUpgradeIntensity; + private JSpinner spnSPAUpgradeIntensity; + private JCheckBox chkAutoConfigMunitions; + + private JPanel pnlScenarioModifiers; + private JLabel lblScenarioModMax; + private JSpinner spnScenarioModMax; + private JLabel lblScenarioModChance; + private JSpinner spnScenarioModChance; + private JLabel lblScenarioModBV; + private JSpinner spnScenarioModBV; + + private JPanel pnlMapGenerationPanel; + private JCheckBox chkUseWeatherConditions; + private JCheckBox chkUseLightConditions; + private JCheckBox chkUsePlanetaryConditions; + private JLabel lblFixedMapChance; + private JSpinner spnFixedMapChance; + + private JPanel pnlPartsPanel; + private JCheckBox chkRestrictPartsByMission; + private JLabel lblBonusPartExchangeValue; + private JSpinner spnBonusPartExchangeValue; + private JLabel lblBonusPartMaxExchangeCount; + private JSpinner spnBonusPartMaxExchangeCount; + + private JPanel pnlLancePanel; + private JCheckBox chkLimitLanceWeight; + private JCheckBox chkLimitLanceNumUnits; + private JCheckBox chkUseStrategy; + private JLabel lblBaseStrategyDeployment; + private JSpinner spnBaseStrategyDeployment; + private JLabel lblAdditionalStrategyDeployment; + private JSpinner spnAdditionalStrategyDeployment; + private JCheckBox chkAdjustPaymentForStrategy; + //end Universal Options + + //start Legacy AtB + private JCheckBox chkUseAtB; + + private JPanel pnlLegacyOpForGenerationPanel; + private JCheckBox chkUseVehicles; + private JCheckBox chkDoubleVehicles; + private JCheckBox chkOpForUsesAero; + private JLabel lblOpForAeroChance; + private JSpinner spnOpForAeroChance; + private JCheckBox chkOpForUsesLocalForces; + private JCheckBox chkAdjustPlayerVehicles; + + private JPanel pnlLegacyScenarioGenerationPanel; + private JLabel lblIntensity; + private JSpinner spnAtBBattleIntensity; + private JLabel lblFightChance; + private JLabel lblDefendChance; + private JLabel lblScoutChance; + private JLabel lblTrainingChance; + private JSpinner[] spnAtBBattleChance; + private JButton btnIntensityUpdate; + private JCheckBox chkGenerateChases; + //end Legacy AtB + + //start StratCon + private JCheckBox chkUseStratCon; + private JCheckBox chkUseGenericBattleValue; + private JCheckBox chkUseVerboseBidding; + //end StratCon + + RulesetsTab(JFrame frame, String name) { + this.frame = frame; + this.name = name; + + initialize(); + } + + private void initialize() { + initializeUniversalOptions(); + initializeStratConTab(); + initializeLegacyTab(); + } + + private void initializeUniversalOptions() { + // General + lblSkillLevel = new JLabel(); + comboSkillLevel = new MMComboBox<>("comboSkillLevel", getSkillLevelOptions()); + pnlScenarioGenerationPanel = new JPanel(); + + // OpFor Generation + pnlUnitRatioPanel = new JPanel(); + lblOpForLanceTypeMeks = new JLabel(); + spnOpForLanceTypeMeks = new JSpinner(); + lblOpForLanceTypeMixed = new JLabel(); + spnOpForLanceTypeMixed = new JSpinner(); + lblOpForLanceTypeVehicle = new JLabel(); + spnOpForLanceTypeVehicles = new JSpinner(); + + chkUseDropShips = new JCheckBox(); + chkOpForUsesVTOLs = new JCheckBox(); + chkClanVehicles = new JCheckBox(); + chkRegionalMekVariations = new JCheckBox(); + + chkAttachedPlayerCamouflage = new JCheckBox(); + chkPlayerControlsAttachedUnits = new JCheckBox(); + + lblSPAUpgradeIntensity = new JLabel(); + spnSPAUpgradeIntensity = new JSpinner(); + chkAutoConfigMunitions = new JCheckBox(); + + pnlScenarioModifiers = new JPanel(); + lblScenarioModMax = new JLabel(); + spnScenarioModMax = new JSpinner(); + lblScenarioModChance = new JLabel(); + spnScenarioModChance = new JSpinner(); + lblScenarioModBV = new JLabel(); + spnScenarioModBV = new JSpinner(); + + // Map Generation + pnlMapGenerationPanel = new JPanel(); + chkUseWeatherConditions = new JCheckBox(); + chkUseLightConditions = new JCheckBox(); + chkUsePlanetaryConditions = new JCheckBox(); + lblFixedMapChance = new JLabel(); + spnFixedMapChance = new JSpinner(); + + // Parts + pnlPartsPanel = new JPanel(); + chkRestrictPartsByMission = new JCheckBox(); + lblBonusPartExchangeValue = new JLabel(); + spnBonusPartExchangeValue = new JSpinner(); + lblBonusPartMaxExchangeCount = new JLabel(); + spnBonusPartMaxExchangeCount = new JSpinner(); + + // Lances + pnlLancePanel = new JPanel(); + chkLimitLanceWeight = new JCheckBox(); + chkLimitLanceNumUnits = new JCheckBox(); + chkUseStrategy = new JCheckBox(); + lblBaseStrategyDeployment = new JLabel(); + spnBaseStrategyDeployment = new JSpinner(); + lblAdditionalStrategyDeployment = new JLabel(); + spnAdditionalStrategyDeployment = new JSpinner(); + chkAdjustPaymentForStrategy = new JCheckBox(); + + // Here we set up the options, so they can be used across both the AtB and StratCon tabs + substantializeUniversalOptions(); + } + + private void substantializeUniversalOptions() { + // General + lblSkillLevel = createLabel("SkillLevel"); + comboSkillLevel.setToolTipText(resources.getString("lblSkillLevel.tooltip")); + + // OpFor Generation + pnlUnitRatioPanel = createUniversalUnitRatioPanel(); + + chkUseDropShips = createCheckBox("UseDropShips"); + chkOpForUsesVTOLs = createCheckBox("OpForUsesVTOLs"); + chkClanVehicles = createCheckBox("ClanVehicles"); + chkRegionalMekVariations = createCheckBox("RegionalMekVariations"); + + chkAttachedPlayerCamouflage = createCheckBox("AttachedPlayerCamouflage"); + chkPlayerControlsAttachedUnits = createCheckBox("PlayerControlsAttachedUnits"); + lblSPAUpgradeIntensity = createLabel("SPAUpgradeIntensity"); + spnSPAUpgradeIntensity = createSpinner("SPAUpgradeIntensity", + 0, -1, 3, 1); + chkAutoConfigMunitions = createCheckBox("AutoConfigMunitions"); + + // Other + pnlScenarioModifiers = createUniversalModifiersPanel(); + pnlMapGenerationPanel = createUniversalMapGenerationPanel(); + pnlPartsPanel = createUniversalPartsPanel(); + pnlLancePanel = createUniversalLancePanel(); + + + pnlScenarioGenerationPanel = createUniversalScenarioGenerationPanel(); + pnlCampaignOptions = createUniversalCampaignOptionsPanel(); + } + + private static DefaultComboBoxModel getSkillLevelOptions() { + final DefaultComboBoxModel skillLevelModel = new DefaultComboBoxModel<>( + Skills.SKILL_LEVELS); + + skillLevelModel.removeElement(SkillLevel.NONE); + + return skillLevelModel; + } + + private JPanel createUniversalScenarioGenerationPanel() { + // Layout the panel + final JPanel panel = createStandardPanel("UniversalScenarioGenerationPanel", true, + "UniversalScenarioGenerationPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(pnlUnitRatioPanel) + .addComponent(chkUseDropShips) + .addComponent(chkOpForUsesVTOLs) + .addComponent(chkClanVehicles) + .addComponent(chkRegionalMekVariations) + .addComponent(chkAttachedPlayerCamouflage) + .addComponent(chkPlayerControlsAttachedUnits) + .addComponent(chkAutoConfigMunitions) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblSPAUpgradeIntensity) + .addComponent(spnSPAUpgradeIntensity)) + .addComponent(pnlScenarioModifiers)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(pnlUnitRatioPanel) + .addComponent(chkUseDropShips) + .addComponent(chkOpForUsesVTOLs) + .addComponent(chkClanVehicles) + .addComponent(chkRegionalMekVariations) + .addComponent(chkAttachedPlayerCamouflage) + .addComponent(chkPlayerControlsAttachedUnits) + .addComponent(chkAutoConfigMunitions) + .addGroup(layout.createSequentialGroup() + .addComponent(lblSPAUpgradeIntensity) + .addComponent(spnSPAUpgradeIntensity) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(pnlScenarioModifiers)); + + return panel; + } + + private JPanel createUniversalUnitRatioPanel() { + // Content + lblOpForLanceTypeMeks = createLabel("OpForLanceTypeMeks"); + spnOpForLanceTypeMeks = createSpinner("OpForLanceTypeMeks", + 0, 0, 10, 1); + lblOpForLanceTypeMixed = createLabel("OpForLanceTypeMixed"); + spnOpForLanceTypeMixed = createSpinner("OpForLanceTypeMixed", + 0, 0, 10, 1); + lblOpForLanceTypeVehicle = createLabel("OpForLanceTypeVehicle"); + spnOpForLanceTypeVehicles = createSpinner("OpForLanceTypeVehicle", + 0, 0, 10, 1); + + // Layout the panel + final JPanel panel = createStandardPanel("UniversalUnitRatioPanel", true, + "UniversalUnitRatioPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblOpForLanceTypeMeks) + .addComponent(spnOpForLanceTypeMeks) + .addComponent(lblOpForLanceTypeMixed) + .addComponent(spnOpForLanceTypeMixed) + .addComponent(lblOpForLanceTypeVehicle) + .addComponent(spnOpForLanceTypeVehicles))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblOpForLanceTypeMeks) + .addComponent(spnOpForLanceTypeMeks) + .addComponent(lblOpForLanceTypeMixed) + .addComponent(spnOpForLanceTypeMixed) + .addComponent(lblOpForLanceTypeVehicle) + .addComponent(spnOpForLanceTypeVehicles) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + return panel; + } + + private JPanel createUniversalModifiersPanel() { + //Content + lblScenarioModMax = createLabel("ScenarioModMax"); + spnScenarioModMax = createSpinner("ScenarioModMax", + 3, 0, 10, 1); + lblScenarioModChance = createLabel("ScenarioModChance"); + spnScenarioModChance = createSpinner("ScenarioModChance", + 25, 5, 100, 5); + lblScenarioModBV = createLabel("ScenarioModBV"); + spnScenarioModBV = createSpinner("ScenarioModBV", + 50, 5, 100, 5); + + // Layout the panel + final JPanel panel = createStandardPanel("UniversalModifiersPanel", true, + "UniversalModifiersPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblScenarioModMax) + .addComponent(spnScenarioModMax)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblScenarioModChance) + .addComponent(spnScenarioModChance)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblScenarioModBV) + .addComponent(spnScenarioModBV))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblScenarioModMax) + .addComponent(spnScenarioModMax) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblScenarioModChance) + .addComponent(spnScenarioModChance) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblScenarioModBV) + .addComponent(spnScenarioModBV) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + return panel; + } + + private JPanel createUniversalMapGenerationPanel() { + // Content + chkUseWeatherConditions = createCheckBox("UseWeatherConditions"); + chkUseLightConditions = createCheckBox("UseLightConditions"); + chkUsePlanetaryConditions = createCheckBox("UsePlanetaryConditions"); + lblFixedMapChance = createLabel("FixedMapChance"); + spnFixedMapChance = createSpinner("FixedMapChance", + 0, 0, 100, 1); + + // Layout the panel + final JPanel panel = createStandardPanel("UniversalMapGenerationPanel", true, + "UniversalMapGenerationPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(chkUseWeatherConditions) + .addComponent(chkUseLightConditions) + .addComponent(chkUsePlanetaryConditions) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblFixedMapChance) + .addComponent(spnFixedMapChance))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(chkUseWeatherConditions) + .addComponent(chkUseLightConditions) + .addComponent(chkUsePlanetaryConditions) + .addGroup(layout.createSequentialGroup() + .addComponent(lblFixedMapChance) + .addComponent(spnFixedMapChance) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + return panel; + } + + private JPanel createUniversalCampaignOptionsPanel() { + // Layout the panel + final JPanel panel = createStandardPanel("UniversalCampaignOptionsPanel", false, + ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(pnlPartsPanel) + .addComponent(pnlLancePanel)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(pnlPartsPanel) + .addComponent(pnlLancePanel)); + + return panel; + } + + private JPanel createUniversalPartsPanel() { + // Content + chkRestrictPartsByMission = createCheckBox("RestrictPartsByMission"); + lblBonusPartExchangeValue = createLabel("BonusPartExchangeValue"); + spnBonusPartExchangeValue = createSpinner("BonusPartExchangeValue", + 500000, 0, 1000000, 1); + lblBonusPartMaxExchangeCount = createLabel("BonusPartMaxExchangeCount"); + spnBonusPartMaxExchangeCount = createSpinner("BonusPartMaxExchangeCount", + 10, 0, 100, 1); + + // Layout the panel + final JPanel panel = createStandardPanel("UniversalPartsPanel", true, + "UniversalPartsPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(chkRestrictPartsByMission) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblBonusPartExchangeValue) + .addComponent(spnBonusPartExchangeValue)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblBonusPartMaxExchangeCount) + .addComponent(spnBonusPartMaxExchangeCount))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(chkRestrictPartsByMission) + .addGroup(layout.createSequentialGroup() + .addComponent(lblBonusPartExchangeValue) + .addComponent(spnBonusPartExchangeValue) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblBonusPartMaxExchangeCount) + .addComponent(spnBonusPartMaxExchangeCount) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + return panel; + } + + private JPanel createUniversalLancePanel() { + // Content + chkLimitLanceWeight = createCheckBox("LimitLanceWeight"); + chkLimitLanceNumUnits = createCheckBox("LimitLanceNumUnits"); + chkUseStrategy = createCheckBox("UseStrategy"); + lblBaseStrategyDeployment = createLabel("BaseStrategyDeployment"); + spnBaseStrategyDeployment = createSpinner("BaseStrategyDeployment", + 0, 0, 10, 1); + lblAdditionalStrategyDeployment = createLabel("AdditionalStrategyDeployment"); + spnAdditionalStrategyDeployment = createSpinner("AdditionalStrategyDeployment", + 0, 0, 10, 1); + chkAdjustPaymentForStrategy = createCheckBox("AdjustPaymentForStrategy"); + + // Layout the panel + final JPanel panel = createStandardPanel("UniversalLancePanel", true, + "UniversalLancePanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(chkLimitLanceWeight) + .addComponent(chkLimitLanceNumUnits) + .addComponent(chkUseStrategy) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblBaseStrategyDeployment) + .addComponent(spnBaseStrategyDeployment)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblAdditionalStrategyDeployment) + .addComponent(spnAdditionalStrategyDeployment)) + .addComponent(chkAdjustPaymentForStrategy)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(chkLimitLanceWeight) + .addComponent(chkLimitLanceNumUnits) + .addComponent(chkUseStrategy) + .addGroup(layout.createSequentialGroup() + .addComponent(lblBaseStrategyDeployment) + .addComponent(spnBaseStrategyDeployment) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblAdditionalStrategyDeployment) + .addComponent(spnAdditionalStrategyDeployment) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkAdjustPaymentForStrategy)); + + return panel; + } + + private void initializeStratConTab() { + chkUseStratCon = new JCheckBox(); + chkUseGenericBattleValue = new JCheckBox(); + chkUseVerboseBidding = new JCheckBox(); + } + + JPanel createStratConTab() { + // Header + JPanel headerPanel = createHeaderPanel("StratConTab", + getImageDirectory() + "logo_lyran_alliance.png", + true); + + // Content + chkUseStratCon = createCheckBox("UseStratCon"); + chkUseGenericBattleValue = createCheckBox("UseGenericBattleValue"); + chkUseVerboseBidding = createCheckBox("UseVerboseBidding"); + + // Layout the Panel + final JPanel panel = createStandardPanel("StratConTab", true); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addComponent(chkUseStratCon) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblSkillLevel) + .addComponent(comboSkillLevel)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(chkUseGenericBattleValue) + .addComponent(chkUseVerboseBidding)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(pnlScenarioGenerationPanel) + .addComponent(pnlCampaignOptions))); + + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addComponent(chkUseStratCon) + .addGroup(layout.createSequentialGroup() + .addComponent(lblSkillLevel) + .addComponent(comboSkillLevel) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(chkUseGenericBattleValue) + .addComponent(chkUseVerboseBidding) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(pnlScenarioGenerationPanel) + .addComponent(pnlCampaignOptions) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + // Create panel and return + return createParentPanel(panel, "StratConTab"); + } + + private void initializeLegacyTab() { + // General + chkUseAtB = new JCheckBox(); + + // OpFor Generation + pnlLegacyOpForGenerationPanel = new JPanel(); + chkUseVehicles = new JCheckBox(); + chkDoubleVehicles = new JCheckBox(); + chkOpForUsesAero = new JCheckBox(); + lblOpForAeroChance = new JLabel(); + spnOpForAeroChance = new JSpinner(); + chkOpForUsesLocalForces = new JCheckBox(); + chkAdjustPlayerVehicles = new JCheckBox(); + + // Scenarios + pnlLegacyScenarioGenerationPanel = new JPanel(); + chkGenerateChases = new JCheckBox(); + lblIntensity = new JLabel(); + spnAtBBattleIntensity = new JSpinner(); + lblFightChance = new JLabel(); + lblDefendChance = new JLabel(); + lblScoutChance = new JLabel(); + lblTrainingChance = new JLabel(); + spnAtBBattleChance = new JSpinner[AtBLanceRole.values().length - 1]; + btnIntensityUpdate = new JButton(); + } + + JPanel createLegacyTab() { + // Header + JPanel headerPanel = createHeaderPanel("LegacyTab", + getImageDirectory() + "logo_clan_snow_raven.png", + true); + + chkUseAtB = createCheckBox("UseAtB"); + pnlLegacyOpForGenerationPanel = createLegacyOpForGenerationPanel(); + pnlLegacyScenarioGenerationPanel = createLegacyScenarioGenerationPanel(); + + // Layout the Panel + final JPanel panel = createStandardPanel("LegacyTab", true, + ""); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(headerPanel) + .addComponent(chkUseAtB) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(pnlLegacyOpForGenerationPanel) + .addComponent(pnlLegacyScenarioGenerationPanel))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(headerPanel, Alignment.CENTER) + .addComponent(chkUseAtB) + .addGroup(layout.createSequentialGroup() + .addComponent(pnlLegacyOpForGenerationPanel) + .addComponent(pnlLegacyScenarioGenerationPanel) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + + // Create panel and return + return createParentPanel(panel, "LegacyTab"); + } + + private JPanel createLegacyOpForGenerationPanel() { + // Content + chkUseVehicles = createCheckBox("UseVehicles"); + chkDoubleVehicles = createCheckBox("DoubleVehicles"); + chkOpForUsesAero = createCheckBox("OpForUsesAero"); + lblOpForAeroChance = createLabel("OpForAeroChance"); + spnOpForAeroChance = createSpinner("OpForAeroChance", + 0, 0, 6, 1); + chkOpForUsesLocalForces = createCheckBox("OpForUsesLocalForces"); + chkAdjustPlayerVehicles = createCheckBox("AdjustPlayerVehicles"); + + // Layout the Panel + final JPanel panel = createStandardPanel("LegacyOpForGenerationPanel", true, + "LegacyOpForGenerationPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(chkUseVehicles) + .addComponent(chkDoubleVehicles) + .addComponent(chkOpForUsesAero) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblOpForAeroChance) + .addComponent(spnOpForAeroChance)) + .addComponent(chkOpForUsesLocalForces) + .addComponent(chkAdjustPlayerVehicles)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(chkUseVehicles) + .addComponent(chkDoubleVehicles) + .addComponent(chkOpForUsesAero) + .addGroup(layout.createSequentialGroup() + .addComponent(lblOpForAeroChance) + .addComponent(spnOpForAeroChance) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkOpForUsesLocalForces) + .addComponent(chkAdjustPlayerVehicles)); + + return panel; + } + + private JPanel createLegacyScenarioGenerationPanel() { + // Content + chkGenerateChases = createCheckBox("GenerateChases"); + lblIntensity = createLabel("AtBBattleIntensity"); + spnAtBBattleIntensity = createSpinner("AtBBattleIntensity", + 0.0, 0.0, 100.0, 0.1); + + lblFightChance = new JLabel(AtBLanceRole.FIGHTING.toString()); + lblDefendChance = new JLabel(AtBLanceRole.DEFENCE.toString()); + lblScoutChance = new JLabel(AtBLanceRole.SCOUTING.toString()); + lblTrainingChance = new JLabel(AtBLanceRole.TRAINING.toString()); + spnAtBBattleChance = new JSpinner[AtBLanceRole.values().length - 1]; + + for (int i = 0; i < spnAtBBattleChance.length; i++) { + spnAtBBattleChance[i] = new JSpinner( + new SpinnerNumberModel(0, 0, 100, 1)); + } + + btnIntensityUpdate = createButton("IntensityUpdate"); + + // Layout the Panel + final JPanel panel = createStandardPanel("LegacyScenarioGenerationPanel", true, + "LegacyScenarioGenerationPanel"); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(chkGenerateChases) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblIntensity) + .addComponent(spnAtBBattleIntensity)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblFightChance) + .addComponent(spnAtBBattleChance[AtBLanceRole.FIGHTING.ordinal()])) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblDefendChance) + .addComponent(spnAtBBattleChance[AtBLanceRole.DEFENCE.ordinal()])) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblScoutChance) + .addComponent(spnAtBBattleChance[AtBLanceRole.SCOUTING.ordinal()])) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblTrainingChance) + .addComponent(spnAtBBattleChance[AtBLanceRole.TRAINING.ordinal()])) + .addComponent(btnIntensityUpdate)); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) + .addComponent(chkGenerateChases) + .addGroup(layout.createSequentialGroup() + .addComponent(lblIntensity) + .addComponent(spnAtBBattleIntensity) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGap(UIUtil.scaleForGUI(25)) + .addComponent(lblFightChance) + .addComponent(spnAtBBattleChance[AtBLanceRole.FIGHTING.ordinal()]) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGap(UIUtil.scaleForGUI(25)) + .addComponent(lblDefendChance) + .addComponent(spnAtBBattleChance[AtBLanceRole.DEFENCE.ordinal()]) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGap(UIUtil.scaleForGUI(25)) + .addComponent(lblScoutChance) + .addComponent(spnAtBBattleChance[AtBLanceRole.SCOUTING.ordinal()]) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGap(UIUtil.scaleForGUI(25)) + .addComponent(lblTrainingChance) + .addComponent(spnAtBBattleChance[AtBLanceRole.TRAINING.ordinal()]) + .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(btnIntensityUpdate)); + + return panel; + } + + private double determineAtBBattleIntensity() { + double intensity = 0.0; + + int x = (Integer) spnAtBBattleChance[AtBLanceRole.FIGHTING.ordinal()].getValue(); + intensity += ((-3.0 / 2.0) * (2.0 * x - 1.0)) / (2.0 * x - 201.0); + + x = (Integer) spnAtBBattleChance[AtBLanceRole.DEFENCE.ordinal()].getValue(); + intensity += ((-4.0) * (2.0 * x - 1.0)) / (2.0 * x - 201.0); + + x = (Integer) spnAtBBattleChance[AtBLanceRole.SCOUTING.ordinal()].getValue(); + intensity += ((-2.0 / 3.0) * (2.0 * x - 1.0)) / (2.0 * x - 201.0); + + x = (Integer) spnAtBBattleChance[AtBLanceRole.TRAINING.ordinal()].getValue(); + intensity += ((-9.0) * (2.0 * x - 1.0)) / (2.0 * x - 201.0); + + intensity = intensity / 4.0; + + if (intensity > 100.0) { + intensity = 100.0; + } + + return Math.round(intensity * 10.0) / 10.0; + } + + private class AtBBattleIntensityChangeListener implements ChangeListener { + @Override + public void stateChanged(ChangeEvent e) { + double intensity = (Double) spnAtBBattleIntensity.getValue(); + + if (intensity >= AtBContract.MINIMUM_INTENSITY) { + int value = (int) Math.min( + Math.round(400.0 * intensity / (4.0 * intensity + 6.0) + 0.05), 100); + spnAtBBattleChance[AtBLanceRole.FIGHTING.ordinal()].setValue(value); + value = (int) Math.min(Math.round(200.0 * intensity / (2.0 * intensity + 8.0) + 0.05), + 100); + spnAtBBattleChance[AtBLanceRole.DEFENCE.ordinal()].setValue(value); + value = (int) Math.min(Math.round(600.0 * intensity / (6.0 * intensity + 4.0) + 0.05), + 100); + spnAtBBattleChance[AtBLanceRole.SCOUTING.ordinal()].setValue(value); + value = (int) Math.min(Math.round(100.0 * intensity / (intensity + 9.0) + 0.05), 100); + spnAtBBattleChance[AtBLanceRole.TRAINING.ordinal()].setValue(value); + } else { + spnAtBBattleChance[AtBLanceRole.FIGHTING.ordinal()].setValue(0); + spnAtBBattleChance[AtBLanceRole.DEFENCE.ordinal()].setValue(0); + spnAtBBattleChance[AtBLanceRole.SCOUTING.ordinal()].setValue(0); + spnAtBBattleChance[AtBLanceRole.TRAINING.ordinal()].setValue(0); + } + } + } +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java index 4df4f4d42c..5d1d610331 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java @@ -229,7 +229,7 @@ JPanel createTurnoverTab() { // Header JPanel headerPanel = createHeaderPanel("TurnoverTab", getImageDirectory() + "logo_clan_jade_falcon.png", - false, "", true); + true); // Contents chkUseRandomRetirement = createCheckBox("UseRandomRetirement"); @@ -239,7 +239,7 @@ JPanel createTurnoverTab() { pnlUnitCohesion = createUnitCohesionPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("TurnoverTab", true, ""); + final JPanel panel = createStandardPanel("TurnoverTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -590,7 +590,7 @@ private JPanel createAdministrativeStrainWrapperPanel() { pnlAdministrativeStrain = createAdministrativeStrainPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("AdministrativeStrainPanel", false, ""); + final JPanel panel = createStandardPanel("AdministrativeStrainPanel", false); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -677,7 +677,7 @@ private JPanel createManagementSkillWrapperPanel() { pnlManagementSkill = createManagementSkillPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("UnitCohesionPanel", false, ""); + final JPanel panel = createStandardPanel("UnitCohesionPanel", false); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -757,7 +757,7 @@ JPanel createFatigueTab() { // Header JPanel headerPanel = createHeaderPanel("FatigueTab", getImageDirectory() + "logo_free_rasalhague_republic.png", - false, "", true); + true); // Contents chkUseFatigue = createCheckBox("UseFatigue"); @@ -779,7 +779,7 @@ JPanel createFatigueTab() { 13, 0, 17, 1); // Layout the Panel - final JPanel panel = createStandardPanel("FatigueTab", true, ""); + final JPanel panel = createStandardPanel("FatigueTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); From be3d92f8a1b1021afe99dbeb2522e0dcd3c13ab1 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 14 Oct 2024 19:37:19 -0500 Subject: [PATCH 071/117] Refactored UI components to use scaleForGUI for size adjustments This change updated various UI components in different tabs to use the `UIUtil.scaleForGUI` method for setting their sizes. The adjustment ensures that the components scale appropriately, improving the application's compatibility with different display settings and resolutions. --- .../tabs/CampaignOptionsUtilities.java | 30 +++++++++---------- .../tabs/EquipmentAndSuppliesTab.java | 5 ++-- .../campaignOptions/tabs/GeneralTab.java | 12 ++++---- .../campaignOptions/tabs/PersonnelTab.java | 9 +++--- 4 files changed, 29 insertions(+), 27 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index f91619fad4..5382ecd889 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -52,8 +52,8 @@ static JCheckBox createCheckBox(String name, @Nullable Integer customWrapSize) { checkBox.setName("chk" + name); Dimension size = checkBox.getPreferredSize(); - checkBox.setMaximumSize(size); - checkBox.setMinimumSize(size); + checkBox.setMaximumSize(UIUtil.scaleForGUI(size.width, size.height)); + checkBox.setMinimumSize(UIUtil.scaleForGUI(size.width, size.height)); return checkBox; } @@ -104,8 +104,8 @@ static JSpinner createSpinner(String name, @Nullable Integer customWrapSize, dou editor.getTextField().setHorizontalAlignment(JTextField.LEFT); Dimension size = jSpinner.getPreferredSize(); - jSpinner.setMaximumSize(size); - jSpinner.setMinimumSize(size); + jSpinner.setMaximumSize(UIUtil.scaleForGUI(size.width, size.height)); + jSpinner.setMinimumSize(UIUtil.scaleForGUI(size.width, size.height)); return jSpinner; } @@ -147,8 +147,8 @@ static JLabel createLabel(String name, @Nullable Integer customWrapSize) { jLabel.setName("lbl" + name); Dimension size = jLabel.getPreferredSize(); - jLabel.setMinimumSize(size); - jLabel.setMaximumSize(size); + jLabel.setMinimumSize(UIUtil.scaleForGUI(size.width, size.height)); + jLabel.setMaximumSize(UIUtil.scaleForGUI(size.width, size.height)); return jLabel; } @@ -188,8 +188,8 @@ static JTextField createTextField(String name, @Nullable Integer customWrapSize, jTextField.setName("txt" + name); int preferredHeight = jTextField.getPreferredSize().height; - jTextField.setMinimumSize(new Dimension(UIUtil.scaleForGUI(width), preferredHeight)); - jTextField.setMaximumSize(new Dimension(UIUtil.scaleForGUI(width), preferredHeight)); + jTextField.setMinimumSize(UIUtil.scaleForGUI(width, preferredHeight)); + jTextField.setMaximumSize(UIUtil.scaleForGUI(width, preferredHeight)); return jTextField; } @@ -265,7 +265,7 @@ static JPanel createStandardPanel(String name, boolean includeBorder, String bor sizeWidth = UIUtil.scaleForGUI(750); } - panel.setMaximumSize(new Dimension(sizeWidth, sizeHeight)); + panel.setMaximumSize(UIUtil.scaleForGUI(sizeWidth, sizeHeight)); return panel; } @@ -298,12 +298,12 @@ static JPanel createHeaderPanel(String name, String imageAddress, boolean includ resources.getString("lbl" + name + "Body.text")), SwingConstants.CENTER); lblBody.setName("lbl" + name + "Body"); Dimension size = lblBody.getPreferredSize(); - lblBody.setMaximumSize(new Dimension(UIUtil.scaleForGUI(750), size.height)); + lblBody.setMaximumSize(UIUtil.scaleForGUI(750, size.height)); } final JPanel panel = createStandardPanel("pnl" + name + "HeaderPanel", false, ""); Dimension size = panel.getPreferredSize(); - panel.setPreferredSize(new Dimension(UIUtil.scaleForGUI(750), size.height)); + panel.setPreferredSize(UIUtil.scaleForGUI(750, size.height)); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -366,8 +366,8 @@ static JPanel createParentPanel(JPanel panel, String name) { } Dimension size = new Dimension(widthNew, height); - parentPanel.setMinimumSize(size); - parentPanel.setMaximumSize(size); + parentPanel.setMinimumSize(UIUtil.scaleForGUI(size.width, size.height)); + parentPanel.setMaximumSize(UIUtil.scaleForGUI(size.width, size.height)); // Layout parentPanel.setLayout(parentLayout); @@ -473,8 +473,8 @@ static JButton createButton(String name) { jButton.setName("btn" + name); Dimension size = jButton.getPreferredSize(); - jButton.setMinimumSize(size); - jButton.setMaximumSize(size); + jButton.setMinimumSize(UIUtil.scaleForGUI(size.width, size.height)); + jButton.setMaximumSize(UIUtil.scaleForGUI(size.width, size.height)); return jButton; } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java index e6d87a2aa5..bea22f786a 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java @@ -1,6 +1,7 @@ package mekhq.gui.panes.campaignOptions.tabs; import megamek.client.ui.baseComponents.MMComboBox; +import megamek.client.ui.swing.util.UIUtil; import megamek.common.EquipmentType; import mekhq.MekHQ; import mekhq.campaign.campaignOptions.CampaignOptions; @@ -650,8 +651,8 @@ private JPanel createOutputModifiersPanel() { */ private void setSpinnerWidth(JSpinner spinner) { Dimension size = spinner.getPreferredSize(); - spinner.setMaximumSize(size); - spinner.setMinimumSize(size); + spinner.setMaximumSize(UIUtil.scaleForGUI(size.width, size.height)); + spinner.setMinimumSize(UIUtil.scaleForGUI(size.width, size.height)); } /** diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java index 3feb4a3d18..b55507cd61 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java @@ -112,20 +112,20 @@ public AbstractMHQScrollablePanel createGeneralTab() { // Camouflage lblCamo = createLabel("Camo"); btnCamo.setName("btnCamo"); - btnCamo.setMinimumSize(new Dimension(100, 100)); - btnCamo.setMaximumSize(new Dimension(100, 100)); + btnCamo.setMinimumSize(UIUtil.scaleForGUI(100, 100)); + btnCamo.setMaximumSize(UIUtil.scaleForGUI(100, 100)); btnCamo.addActionListener(this::btnCamoActionPerformed); // Unit icon lblIcon = createLabel("Icon"); btnIcon.setName("btnIcon"); - btnIcon.setMinimumSize(new Dimension(100, 100)); - btnIcon.setMaximumSize(new Dimension(100, 100)); + btnIcon.setMinimumSize(UIUtil.scaleForGUI(100, 100)); + btnIcon.setMaximumSize(UIUtil.scaleForGUI(100, 100)); btnIcon.addActionListener(evt -> { final UnitIconDialog unitIconDialog = new UnitIconDialog(frame, unitIcon); if (unitIconDialog.showDialog().isConfirmed() && (unitIconDialog.getSelectedItem() != null)) { unitIcon = unitIconDialog.getSelectedItem(); - btnIcon.setIcon(unitIcon.getImageIcon(75)); + btnIcon.setIcon(unitIcon.getImageIcon(UIUtil.scaleForGUI(75))); } }); @@ -217,7 +217,7 @@ private static JPanel createGeneralHeader() { resources.getString("lblGeneralBody.text")), SwingConstants.CENTER); lblBody.setName("lblGeneralHeaderBody"); Dimension size = lblBody.getPreferredSize(); - lblBody.setMaximumSize(new Dimension(UIUtil.scaleForGUI(750), size.height)); + lblBody.setMaximumSize(UIUtil.scaleForGUI(750, size.height)); final JPanel panel = createStandardPanel("pnlGeneralHeaderPanel", false); final GroupLayout layout = createStandardLayout(panel); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java index 3815f2a082..e4f7490b88 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java @@ -1,6 +1,7 @@ package mekhq.gui.panes.campaignOptions.tabs; import megamek.client.ui.baseComponents.MMComboBox; +import megamek.client.ui.swing.util.UIUtil; import megamek.common.enums.SkillLevel; import mekhq.campaign.personnel.Skills; import mekhq.campaign.personnel.enums.*; @@ -1173,8 +1174,8 @@ private JPanel createBaseSalariesPanel() { jLabel.setName("lbl" + componentName); Dimension labelSize = jLabel.getPreferredSize(); - jLabel.setMinimumSize(labelSize); - jLabel.setMaximumSize(labelSize); + jLabel.setMinimumSize(UIUtil.scaleForGUI(labelSize.width, labelSize.height)); + jLabel.setMaximumSize(UIUtil.scaleForGUI(labelSize.width, labelSize.height)); // JSpinner JSpinner jSpinner = new JSpinner(); @@ -1185,8 +1186,8 @@ private JPanel createBaseSalariesPanel() { editor.getTextField().setHorizontalAlignment(JTextField.LEFT); Dimension spinnerSize = jSpinner.getPreferredSize(); - jSpinner.setMaximumSize(spinnerSize); - jSpinner.setMinimumSize(spinnerSize); + jSpinner.setMaximumSize(UIUtil.scaleForGUI(spinnerSize.width, spinnerSize.height)); + jSpinner.setMinimumSize(UIUtil.scaleForGUI(spinnerSize.width, spinnerSize.height)); // Component Tracking Assignment lblBaseSalary[personnelRole.ordinal()] = jLabel; From 3b31e4cc8599cc76f341ef2424b5345e303e1268 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 14 Oct 2024 19:51:24 -0500 Subject: [PATCH 072/117] Remove maximum size constraints from GUI components Removed maximum size constraints to allow GUI components to scale more dynamically based on window size and user settings. This change ensures a more flexible and responsive user interface. Adjusted size comparison directly to enhance code readability and simplicity. --- .../campaignOptions/tabs/CampaignOptionsUtilities.java | 8 ++------ .../campaignOptions/tabs/EquipmentAndSuppliesTab.java | 1 - .../gui/panes/campaignOptions/tabs/PersonnelTab.java | 2 -- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index 5382ecd889..16e1905453 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -52,7 +52,6 @@ static JCheckBox createCheckBox(String name, @Nullable Integer customWrapSize) { checkBox.setName("chk" + name); Dimension size = checkBox.getPreferredSize(); - checkBox.setMaximumSize(UIUtil.scaleForGUI(size.width, size.height)); checkBox.setMinimumSize(UIUtil.scaleForGUI(size.width, size.height)); return checkBox; @@ -104,7 +103,6 @@ static JSpinner createSpinner(String name, @Nullable Integer customWrapSize, dou editor.getTextField().setHorizontalAlignment(JTextField.LEFT); Dimension size = jSpinner.getPreferredSize(); - jSpinner.setMaximumSize(UIUtil.scaleForGUI(size.width, size.height)); jSpinner.setMinimumSize(UIUtil.scaleForGUI(size.width, size.height)); return jSpinner; @@ -148,7 +146,6 @@ static JLabel createLabel(String name, @Nullable Integer customWrapSize) { Dimension size = jLabel.getPreferredSize(); jLabel.setMinimumSize(UIUtil.scaleForGUI(size.width, size.height)); - jLabel.setMaximumSize(UIUtil.scaleForGUI(size.width, size.height)); return jLabel; } @@ -261,8 +258,8 @@ static JPanel createStandardPanel(String name, boolean includeBorder, String bor sizeWidth += component.getPreferredSize().width; } - if (sizeWidth < UIUtil.scaleForGUI(750)) { - sizeWidth = UIUtil.scaleForGUI(750); + if (sizeWidth < 750) { + sizeWidth = 750; } panel.setMaximumSize(UIUtil.scaleForGUI(sizeWidth, sizeHeight)); @@ -474,7 +471,6 @@ static JButton createButton(String name) { Dimension size = jButton.getPreferredSize(); jButton.setMinimumSize(UIUtil.scaleForGUI(size.width, size.height)); - jButton.setMaximumSize(UIUtil.scaleForGUI(size.width, size.height)); return jButton; } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java index bea22f786a..9f469a9b07 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java @@ -651,7 +651,6 @@ private JPanel createOutputModifiersPanel() { */ private void setSpinnerWidth(JSpinner spinner) { Dimension size = spinner.getPreferredSize(); - spinner.setMaximumSize(UIUtil.scaleForGUI(size.width, size.height)); spinner.setMinimumSize(UIUtil.scaleForGUI(size.width, size.height)); } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java index e4f7490b88..410219d857 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java @@ -1175,7 +1175,6 @@ private JPanel createBaseSalariesPanel() { Dimension labelSize = jLabel.getPreferredSize(); jLabel.setMinimumSize(UIUtil.scaleForGUI(labelSize.width, labelSize.height)); - jLabel.setMaximumSize(UIUtil.scaleForGUI(labelSize.width, labelSize.height)); // JSpinner JSpinner jSpinner = new JSpinner(); @@ -1186,7 +1185,6 @@ private JPanel createBaseSalariesPanel() { editor.getTextField().setHorizontalAlignment(JTextField.LEFT); Dimension spinnerSize = jSpinner.getPreferredSize(); - jSpinner.setMaximumSize(UIUtil.scaleForGUI(spinnerSize.width, spinnerSize.height)); jSpinner.setMinimumSize(UIUtil.scaleForGUI(spinnerSize.width, spinnerSize.height)); // Component Tracking Assignment From 2c4aa5eb7ea57f7f5e2230469fc4c27eeff4dc24 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 14 Oct 2024 21:28:35 -0500 Subject: [PATCH 073/117] Add font scaling utility method Introduced setFontScaling method to apply font scaling to JComponents. This method allows customization of text attributes, including boldness and size. --- .../tabs/CampaignOptionsUtilities.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index 16e1905453..10418ae8df 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -474,4 +474,20 @@ static JButton createButton(String name) { return jButton; } + + /** + * Applies font scaling to a given {@link JComponent}. + * + * @param component The JComponent to which the font scaling is applied. + * @param boldText A boolean that sets whether the text should be bolded. + * If {@code true}, the text will be bolded, else, it will be regular. + * @param size An integer representing the size of the font to be set. + */ + static void setFontScaling(JComponent component, boolean boldText, int size) { + if (boldText) { + new FlatLafStyleBuilder().font(MHQConstants.PROJECT_NAME).bold().size(size).apply(component); + } else { + new FlatLafStyleBuilder().font(MHQConstants.PROJECT_NAME).size(size).apply(component); + } + } } From 7701ddc5bb12d83ca617456aa2aedbc243b88e9d Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 14 Oct 2024 21:45:10 -0500 Subject: [PATCH 074/117] Add font scaling to UI components in campaign options Implemented the setFontScaling method for various UI components such as checkboxes, spinners, labels, text fields, and buttons. This update ensured consistent font scaling across different UI elements, improving readability and visual consistency in the campaign options interface. --- .../tabs/CampaignOptionsUtilities.java | 14 +++++++++++++- .../gui/panes/campaignOptions/tabs/GeneralTab.java | 5 ++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index 10418ae8df..e642519f2c 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -51,6 +51,8 @@ static JCheckBox createCheckBox(String name, @Nullable Integer customWrapSize) { checkBox.setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), customWrapSize)); checkBox.setName("chk" + name); + setFontScaling(checkBox, false, 1); + Dimension size = checkBox.getPreferredSize(); checkBox.setMinimumSize(UIUtil.scaleForGUI(size.width, size.height)); @@ -99,6 +101,8 @@ static JSpinner createSpinner(String name, @Nullable Integer customWrapSize, dou jSpinner.setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), customWrapSize)); jSpinner.setName("spn" + name); + setFontScaling(jSpinner, false, 1); + DefaultEditor editor = (DefaultEditor) jSpinner.getEditor(); editor.getTextField().setHorizontalAlignment(JTextField.LEFT); @@ -144,6 +148,8 @@ static JLabel createLabel(String name, @Nullable Integer customWrapSize) { jLabel.setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), customWrapSize)); jLabel.setName("lbl" + name); + setFontScaling(jLabel, false, 1); + Dimension size = jLabel.getPreferredSize(); jLabel.setMinimumSize(UIUtil.scaleForGUI(size.width, size.height)); @@ -184,6 +190,8 @@ static JTextField createTextField(String name, @Nullable Integer customWrapSize, jTextField.setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), customWrapSize)); jTextField.setName("txt" + name); + setFontScaling(jTextField, false, 1); + int preferredHeight = jTextField.getPreferredSize().height; jTextField.setMinimumSize(UIUtil.scaleForGUI(width, preferredHeight)); jTextField.setMaximumSize(UIUtil.scaleForGUI(width, preferredHeight)); @@ -286,14 +294,15 @@ static JPanel createHeaderPanel(String name, String imageAddress, boolean includ JLabel imageLabel = new JLabel(imageIcon); final JLabel lblHeader = new JLabel(resources.getString("lbl" + name + ".text"), SwingConstants.CENTER); - new FlatLafStyleBuilder().font(MHQConstants.PROJECT_NAME).bold().size(3).apply(lblHeader); lblHeader.setName("lbl" + name); + setFontScaling(lblHeader, true, 2); JLabel lblBody = new JLabel(); if (includeBodyText) { lblBody = new JLabel(String.format("

%s

", resources.getString("lbl" + name + "Body.text")), SwingConstants.CENTER); lblBody.setName("lbl" + name + "Body"); + setFontScaling(lblBody, false, 1); Dimension size = lblBody.getPreferredSize(); lblBody.setMaximumSize(UIUtil.scaleForGUI(750, size.height)); } @@ -419,6 +428,7 @@ static JTabbedPane createSubTabs(Map panels) { JLabel quote = new JLabel(String.format( "
%s
", UIUtil.scaleForGUI(650), resources.getString(tabName + ".border"))); + setFontScaling(quote, false, 1); GridBagConstraints quoteConstraints = new GridBagConstraints(); quoteConstraints.gridx = GridBagConstraints.RELATIVE; @@ -469,6 +479,8 @@ static JButton createButton(String name) { jButton.setToolTipText(resources.getString("lbl" + name + ".tooltip")); jButton.setName("btn" + name); + setFontScaling(jButton, false, 1); + Dimension size = jButton.getPreferredSize(); jButton.setMinimumSize(UIUtil.scaleForGUI(size.width, size.height)); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java index b55507cd61..1e67e9d4e5 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java @@ -2,11 +2,9 @@ import megamek.client.ui.baseComponents.MMComboBox; import megamek.client.ui.dialogs.CamoChooserDialog; -import megamek.client.ui.swing.util.FlatLafStyleBuilder; import megamek.client.ui.swing.util.UIUtil; import megamek.common.annotations.Nullable; import megamek.common.icons.Camouflage; -import mekhq.MHQConstants; import mekhq.MekHQ; import mekhq.campaign.Campaign; import mekhq.campaign.icons.StandardForceIcon; @@ -210,12 +208,13 @@ private static JPanel createGeneralHeader() { JLabel imageLabel = new JLabel(imageIcon); final JLabel lblHeader = new JLabel(resources.getString("lblGeneral.text"), SwingConstants.CENTER); - new FlatLafStyleBuilder().font(MHQConstants.PROJECT_NAME).bold().size(3).apply(lblHeader); + setFontScaling(lblHeader, true, 2); lblHeader.setName("lblGeneral"); JLabel lblBody = new JLabel(String.format("%s", resources.getString("lblGeneralBody.text")), SwingConstants.CENTER); lblBody.setName("lblGeneralHeaderBody"); + setFontScaling(lblBody, false, 1); Dimension size = lblBody.getPreferredSize(); lblBody.setMaximumSize(UIUtil.scaleForGUI(750, size.height)); From 25d0b50bbb4e34f3959162da702ed2678ac53a9b Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 14 Oct 2024 21:51:58 -0500 Subject: [PATCH 075/117] Remove redundant UI scaling code Removed unnecessary setting of minimum and maximum sizes for various UI components in multiple tabs to clean up the code. This improves code readability and may prevent potential UI bugs related to fixed component sizes. --- .../campaignOptions/tabs/BiographyTab.java | 30 ++++---- .../tabs/CampaignOptionsUtilities.java | 34 +-------- .../tabs/EquipmentAndSuppliesTab.java | 39 ++++------ .../campaignOptions/tabs/FinancesTab.java | 66 ++++++---------- .../campaignOptions/tabs/GeneralTab.java | 18 ++--- .../campaignOptions/tabs/MarketsTab.java | 75 +++++++------------ .../campaignOptions/tabs/PersonnelTab.java | 39 +++------- .../tabs/RelationshipsTab.java | 34 ++++----- .../tabs/RepairAndMaintenanceTab.java | 15 ++-- .../campaignOptions/tabs/RulesetsTab.java | 60 +++++---------- .../tabs/TurnoverAndRetentionTab.java | 36 ++++----- 11 files changed, 154 insertions(+), 292 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java index ab98a2c404..9a44a569dc 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java @@ -373,11 +373,11 @@ JPanel createGeneralTab() { .addGroup(layout.createSequentialGroup() .addComponent(lblNonBinaryDiceSize) .addComponent(spnNonBinaryDiceSize) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addGroup(layout.createSequentialGroup() .addComponent(lblFamilyDisplayLevel) .addComponent(comboFamilyDisplayLevel) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addComponent(pnlAnniversariesPanel))); // Create Parent Panel and return @@ -569,13 +569,13 @@ public Component getListCellRendererComponent(final JList list, final Object .addComponent(comboSpecifiedSystem) .addComponent(lblSpecifiedPlanet) .addComponent(comboSpecifiedPlanet) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addGroup(layout.createSequentialGroup() .addComponent(lblOriginSearchRadius) .addComponent(spnOriginSearchRadius) .addComponent(lblOriginDistanceScale) .addComponent(spnOriginDistanceScale) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addComponent(chkAllowClanOrigins) .addComponent(chkExtraRandomOrigin))); @@ -707,14 +707,14 @@ public Component getListCellRendererComponent(final JList list, final Object .addGroup(layout.createSequentialGroup() .addComponent(lblRandomDeathMethod) .addComponent(comboRandomDeathMethod) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addComponent(chkUseRandomClanPersonnelDeath) .addComponent(chkUseRandomPrisonerDeath) .addComponent(chkUseRandomDeathSuicideCause) .addGroup(layout.createSequentialGroup() .addComponent(lblPercentageRandomDeathChance) .addComponent(spnPercentageRandomDeathChance) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addComponent(pnlDeathAgeGroup))); // Create Parent Panel and return @@ -835,18 +835,18 @@ JPanel createEducationTab() { .addComponent(spnCurriculumXpRate) .addComponent(lblMaximumJumpCount) .addComponent(spnMaximumJumpCount) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addComponent(chkUseReeducationCamps) .addComponent(pnlEnableStandardSets) .addGroup(layout.createSequentialGroup() .addComponent(chkShowIneligibleAcademies) .addComponent(chkEnableOverrideRequirements) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addGroup(layout.createSequentialGroup() .addComponent(lblEntranceExamBaseTargetNumber) .addComponent(spnEntranceExamBaseTargetNumber) .addComponent(lblEntranceExamBaseTargetNumberPost) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addComponent(pnlXpAndSkillBonuses) .addComponent(pnlDropoutChance) .addComponent(pnlAccidentsAndEvents))); @@ -893,7 +893,7 @@ private JPanel createEnableStandardSetsPanel() { .addComponent(chkEnableLocalAcademies) .addComponent(chkEnablePrestigiousAcademies) .addComponent(chkEnableUnitEducation) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + ))); return panel; } @@ -936,7 +936,7 @@ private JPanel createXpAndSkillBonusesPanel() { .addGroup(layout.createSequentialGroup() .addComponent(lblFacultyXpMultiplier) .addComponent(spnFacultyXpMultiplier) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + ))); return panel; } @@ -981,11 +981,11 @@ private JPanel createDropoutChancePanel() { .addGroup(layout.createSequentialGroup() .addComponent(lblAdultDropoutChance) .addComponent(spnAdultDropoutChance) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addGroup(layout.createSequentialGroup() .addComponent(lblChildrenDropoutChance) .addComponent(spnChildrenDropoutChance) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + ))); return panel; } @@ -1028,7 +1028,7 @@ private JPanel createAccidentsAndEventsPanel() { .addGroup(layout.createSequentialGroup() .addComponent(lblMilitaryAcademyAccidents) .addComponent(spnMilitaryAcademyAccidents) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + ))); return panel; } @@ -1084,7 +1084,7 @@ JPanel createNameAndPortraitGenerationTab() { .addGroup(layout.createSequentialGroup() .addComponent(lblFactionNames) .addComponent(comboFactionNames) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addComponent(pnlRandomPortrait) .addComponent(chkAssignPortraitOnRoleChange))); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index e642519f2c..9bcfb177a2 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -53,9 +53,6 @@ static JCheckBox createCheckBox(String name, @Nullable Integer customWrapSize) { setFontScaling(checkBox, false, 1); - Dimension size = checkBox.getPreferredSize(); - checkBox.setMinimumSize(UIUtil.scaleForGUI(size.width, size.height)); - return checkBox; } @@ -106,9 +103,6 @@ static JSpinner createSpinner(String name, @Nullable Integer customWrapSize, dou DefaultEditor editor = (DefaultEditor) jSpinner.getEditor(); editor.getTextField().setHorizontalAlignment(JTextField.LEFT); - Dimension size = jSpinner.getPreferredSize(); - jSpinner.setMinimumSize(UIUtil.scaleForGUI(size.width, size.height)); - return jSpinner; } @@ -150,9 +144,6 @@ static JLabel createLabel(String name, @Nullable Integer customWrapSize) { setFontScaling(jLabel, false, 1); - Dimension size = jLabel.getPreferredSize(); - jLabel.setMinimumSize(UIUtil.scaleForGUI(size.width, size.height)); - return jLabel; } @@ -192,10 +183,6 @@ static JTextField createTextField(String name, @Nullable Integer customWrapSize, setFontScaling(jTextField, false, 1); - int preferredHeight = jTextField.getPreferredSize().height; - jTextField.setMinimumSize(UIUtil.scaleForGUI(width, preferredHeight)); - jTextField.setMaximumSize(UIUtil.scaleForGUI(width, preferredHeight)); - return jTextField; } @@ -258,20 +245,6 @@ static JPanel createStandardPanel(String name, boolean includeBorder, String bor panel.setName(name); - Dimension size = panel.getPreferredSize(); - int sizeHeight = size.height; - int sizeWidth = size.width; - for (Component component : panel.getComponents()) { - sizeHeight += component.getPreferredSize().height; - sizeWidth += component.getPreferredSize().width; - } - - if (sizeWidth < 750) { - sizeWidth = 750; - } - - panel.setMaximumSize(UIUtil.scaleForGUI(sizeWidth, sizeHeight)); - return panel; } @@ -308,8 +281,6 @@ static JPanel createHeaderPanel(String name, String imageAddress, boolean includ } final JPanel panel = createStandardPanel("pnl" + name + "HeaderPanel", false, ""); - Dimension size = panel.getPreferredSize(); - panel.setPreferredSize(UIUtil.scaleForGUI(750, size.height)); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -354,7 +325,7 @@ static GroupLayout createStandardLayout(JPanel panel) { */ static JPanel createParentPanel(JPanel panel, String name) { // Create Panel - final JPanel parentPanel = createStandardPanel(name, false, ""); + final JPanel parentPanel = createStandardPanel(name, false); final GroupLayout parentLayout = createStandardLayout(parentPanel); // Set Dimensions @@ -481,9 +452,6 @@ static JButton createButton(String name) { setFontScaling(jButton, false, 1); - Dimension size = jButton.getPreferredSize(); - jButton.setMinimumSize(UIUtil.scaleForGUI(size.width, size.height)); - return jButton; } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java index 9f469a9b07..46dd6eff9e 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java @@ -274,25 +274,20 @@ JPanel createAcquisitionTab() { .addComponent(headerPanel, Alignment.CENTER) .addGroup(layout.createSequentialGroup() .addComponent(lblChoiceAcquireSkill) - .addComponent(choiceAcquireSkill) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(choiceAcquireSkill)) .addComponent(chkSupportStaffOnly) .addGroup(layout.createSequentialGroup() .addComponent(lblAcquireClanPenalty) - .addComponent(spnAcquireClanPenalty) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnAcquireClanPenalty)) .addGroup(layout.createSequentialGroup() .addComponent(lblAcquireIsPenalty) - .addComponent(spnAcquireIsPenalty) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnAcquireIsPenalty)) .addGroup(layout.createSequentialGroup() .addComponent(lblAcquireWaitingPeriod) - .addComponent(spnAcquireWaitingPeriod) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnAcquireWaitingPeriod)) .addGroup(layout.createSequentialGroup() .addComponent(lblMaxAcquisitions) - .addComponent(spnMaxAcquisitions) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(spnMaxAcquisitions))); // Create Parent Panel and return return createParentPanel(panel, "acquisitionsTab"); @@ -390,18 +385,15 @@ private JPanel createOptionsPanel() { .addComponent(usePlanetaryAcquisitions) .addGroup(layout.createSequentialGroup() .addComponent(lblMaxJumpPlanetaryAcquisitions) - .addComponent(spnMaxJumpPlanetaryAcquisitions) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnMaxJumpPlanetaryAcquisitions)) .addGroup(layout.createSequentialGroup() .addComponent(lblPlanetaryAcquisitionsFactionLimits) - .addComponent(comboPlanetaryAcquisitionsFactionLimits) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(comboPlanetaryAcquisitionsFactionLimits)) .addComponent(disallowPlanetaryAcquisitionClanCrossover) .addComponent(disallowClanPartsFromIS) .addGroup(layout.createSequentialGroup() .addComponent(lblPenaltyClanPartsFromIS) - .addComponent(spnPenaltyClanPartsFromIS) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnPenaltyClanPartsFromIS)) .addComponent(usePlanetaryAcquisitionsVerbose)); return panel; @@ -459,8 +451,7 @@ private JPanel createModifiersPanel() { .addGroup(layout.createSequentialGroup() .addComponent(pnlIndustryModifiers) .addComponent(pnlTechModifiers) - .addComponent(pnlOutputModifiers) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(pnlOutputModifiers))); return panel; } @@ -732,18 +723,15 @@ JPanel createDeliveryTab() { .addComponent(spnNDiceTransitTime) .addComponent(lblConstantTransitTime) .addComponent(spnConstantTransitTime) - .addComponent(choiceTransitTimeUnits) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(choiceTransitTimeUnits)) .addGroup(layout.createSequentialGroup() .addComponent(lblAcquireMosBonus) .addComponent(spnAcquireMosBonus) - .addComponent(choiceAcquireMosUnits) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(choiceAcquireMosUnits)) .addGroup(layout.createSequentialGroup() .addComponent(lblAcquireMinimum) .addComponent(spnAcquireMinimum) - .addComponent(choiceAcquireMinimumUnit) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(choiceAcquireMinimumUnit))); // Create Parent Panel and return return createParentPanel(panel, "deliveryTab"); @@ -863,8 +851,7 @@ JPanel createTechLimitsTab() { .addComponent(allowCanonRefitOnlyBox) .addGroup(layout.createSequentialGroup() .addComponent(lblChoiceTechLevel) - .addComponent(choiceTechLevel) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(choiceTechLevel)) .addComponent(variableTechLevelBox) .addComponent(useAmmoByTypeBox)); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java index 4275e61998..f7608b6027 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java @@ -213,8 +213,7 @@ JPanel createFinancesGeneralOptionsTab() { .addComponent(headerPanel, Alignment.CENTER) .addGroup(layout.createSequentialGroup() .addComponent(pnlGeneralOptions) - .addComponent(pnlOtherSystems) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(pnlOtherSystems)) .addComponent(pnlSales) .addComponent(pnlPayments)); @@ -268,8 +267,7 @@ private JPanel createPaymentsPanel() { .addGap(UIUtil.scaleForGUI(5)) .addComponent(payForUnitsBox) .addGap(UIUtil.scaleForGUI(5)) - .addComponent(payForSalariesBox) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(payForSalariesBox)) .addGap(UIUtil.scaleForGUI(5)) .addGroup(layout.createSequentialGroup() .addComponent(payForOverheadBox) @@ -278,8 +276,7 @@ private JPanel createPaymentsPanel() { .addGap(UIUtil.scaleForGUI(5)) .addComponent(payForTransportBox) .addGap(UIUtil.scaleForGUI(5)) - .addComponent(payForRecruitmentBox) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(payForRecruitmentBox))); return panel; } @@ -359,8 +356,7 @@ private JPanel createGeneralOptionsPanel() { .addComponent(showPeacetimeCostBox) .addGroup(layout.createSequentialGroup() .addComponent(lblFinancialYearDuration) - .addComponent(comboFinancialYearDuration) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(comboFinancialYearDuration)) .addComponent(newFinancialYearFinancesToCSVExportBox)); return panel; @@ -395,8 +391,7 @@ private JPanel createSalesPanel() { .addGroup(layout.createSequentialGroup() .addComponent(sellUnitsBox) .addGap(UIUtil.scaleForGUI(5)) - .addComponent(sellPartsBox) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(sellPartsBox))); return panel; } @@ -435,8 +430,7 @@ private JPanel createTaxesPanel() { .addComponent(chkUseTaxes) .addGroup(layout.createSequentialGroup() .addComponent(lblTaxesPercentage) - .addComponent(spnTaxesPercentage) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(spnTaxesPercentage))); return panel; } @@ -545,8 +539,7 @@ JPanel createPriceMultipliersTab() { .addGroup(layout.createSequentialGroup() .addComponent(pnlGeneralMultipliers) .addComponent(pnlUsedPartsMultipliers) - .addComponent(pnlOtherMultipliers) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(pnlOtherMultipliers))); // Create Parent Panel and return return createParentPanel(panel, "PriceMultipliersTab"); @@ -617,28 +610,22 @@ private JPanel createGeneralMultipliersPanel() { layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(lblCommonPartPriceMultiplier) - .addComponent(spnCommonPartPriceMultiplier) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnCommonPartPriceMultiplier)) .addGroup(layout.createSequentialGroup() .addComponent(lblInnerSphereUnitPriceMultiplier) - .addComponent(spnInnerSphereUnitPriceMultiplier) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnInnerSphereUnitPriceMultiplier)) .addGroup(layout.createSequentialGroup() .addComponent(lblInnerSpherePartPriceMultiplier) - .addComponent(spnInnerSpherePartPriceMultiplier) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnInnerSpherePartPriceMultiplier)) .addGroup(layout.createSequentialGroup() .addComponent(lblClanUnitPriceMultiplier) - .addComponent(spnClanUnitPriceMultiplier) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnClanUnitPriceMultiplier)) .addGroup(layout.createSequentialGroup() .addComponent(lblClanPartPriceMultiplier) - .addComponent(spnClanPartPriceMultiplier) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnClanPartPriceMultiplier)) .addGroup(layout.createSequentialGroup() .addComponent(lblMixedTechUnitPriceMultiplier) - .addComponent(spnMixedTechUnitPriceMultiplier) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(spnMixedTechUnitPriceMultiplier))); return panel; } @@ -715,28 +702,22 @@ private JPanel createUsedPartsMultiplierPanel() { layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(lblUsedPartPriceMultipliers[0]) - .addComponent(spnUsedPartPriceMultipliers[0]) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnUsedPartPriceMultipliers[0])) .addGroup(layout.createSequentialGroup() .addComponent(lblUsedPartPriceMultipliers[1]) - .addComponent(spnUsedPartPriceMultipliers[1]) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnUsedPartPriceMultipliers[1])) .addGroup(layout.createSequentialGroup() .addComponent(lblUsedPartPriceMultipliers[2]) - .addComponent(spnUsedPartPriceMultipliers[2]) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnUsedPartPriceMultipliers[2])) .addGroup(layout.createSequentialGroup() .addComponent(lblUsedPartPriceMultipliers[3]) - .addComponent(spnUsedPartPriceMultipliers[3]) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnUsedPartPriceMultipliers[3])) .addGroup(layout.createSequentialGroup() .addComponent(lblUsedPartPriceMultipliers[4]) - .addComponent(spnUsedPartPriceMultipliers[4]) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnUsedPartPriceMultipliers[4])) .addGroup(layout.createSequentialGroup() .addComponent(lblUsedPartPriceMultipliers[5]) - .addComponent(spnUsedPartPriceMultipliers[5]) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(spnUsedPartPriceMultipliers[5]))); return panel; } @@ -789,16 +770,13 @@ private JPanel createOtherMultipliersPanel() { layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(lblDamagedPartsValueMultiplier) - .addComponent(spnDamagedPartsValueMultiplier) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnDamagedPartsValueMultiplier)) .addGroup(layout.createSequentialGroup() .addComponent(lblUnrepairablePartsValueMultiplier) - .addComponent(spnUnrepairablePartsValueMultiplier) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnUnrepairablePartsValueMultiplier)) .addGroup(layout.createSequentialGroup() .addComponent(lblCancelledOrderRefundMultiplier) - .addComponent(spnCancelledOrderRefundMultiplier) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(spnCancelledOrderRefundMultiplier))); return panel; } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java index 1e67e9d4e5..186ec8a523 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java @@ -167,31 +167,25 @@ public AbstractMHQScrollablePanel createGeneralTab() { .addGroup(layout.createSequentialGroup() .addComponent(lblName) .addComponent(txtName) - .addComponent(btnNameGenerator) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(btnNameGenerator)) .addGroup(layout.createSequentialGroup() .addComponent(lblFaction) - .addComponent(comboFaction) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(comboFaction)) .addGroup(layout.createSequentialGroup() .addComponent(lblReputation) - .addComponent(unitRatingMethodCombo) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(unitRatingMethodCombo)) .addGroup(layout.createSequentialGroup() .addComponent(lblManualUnitRatingModifier) - .addComponent(manualUnitRatingModifier) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(manualUnitRatingModifier)) .addGroup(layout.createSequentialGroup() .addComponent(lblDate) - .addComponent(btnDate) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(btnDate)) .addGroup(layout.createSequentialGroup() .addComponent(lblCamo) .addComponent(btnCamo) .addGap(50) .addComponent(lblIcon) - .addComponent(btnIcon) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(btnIcon))); generalPanel.add(panel); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java index cfa5450fe7..fa1eb32829 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java @@ -144,8 +144,7 @@ JPanel createPersonnelMarketTab() { .addComponent(headerPanel, Alignment.CENTER) .addGroup(layout.createSequentialGroup() .addComponent(pnlPersonnelMarketGeneralOptions) - .addComponent(pnlRemovalTargets) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(pnlRemovalTargets))); // Create Parent Panel and return return createParentPanel(panel, "PersonnelMarketTab"); @@ -186,12 +185,10 @@ private JPanel createPersonnelMarketGeneralOptionsPanel() { layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(lblPersonnelMarketType) - .addComponent(comboPersonnelMarketType) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(comboPersonnelMarketType)) .addGroup(layout.createSequentialGroup() .addComponent(lblPersonnelMarketDylansWeight) - .addComponent(spnPersonnelMarketDylansWeight) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnPersonnelMarketDylansWeight)) .addComponent(chkPersonnelMarketReportRefresh) .addComponent(chkUsePersonnelHireHiringHallOnly)); @@ -237,20 +234,16 @@ private JPanel createPersonnelMarketRemovalOptionsPanel() { leftLayout.createParallelGroup(Alignment.LEADING) .addGroup(leftLayout.createSequentialGroup() .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.NONE)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.NONE)) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.NONE))) .addGroup(leftLayout.createSequentialGroup() .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.ULTRA_GREEN)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.ULTRA_GREEN)) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.ULTRA_GREEN))) .addGroup(leftLayout.createSequentialGroup() .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.GREEN)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.GREEN)) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.GREEN))) .addGroup(leftLayout.createSequentialGroup() .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.REGULAR)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.REGULAR)) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.REGULAR)))); final JPanel rightPanel = createStandardPanel("RightPanel", false); final GroupLayout rightLayout = createStandardLayout(rightPanel); @@ -275,20 +268,16 @@ private JPanel createPersonnelMarketRemovalOptionsPanel() { rightLayout.createParallelGroup(Alignment.LEADING) .addGroup(rightLayout.createSequentialGroup() .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.VETERAN)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.VETERAN)) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.VETERAN))) .addGroup(rightLayout.createSequentialGroup() .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.ELITE)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.ELITE)) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.ELITE))) .addGroup(rightLayout.createSequentialGroup() .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.HEROIC)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.HEROIC)) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.HEROIC))) .addGroup(rightLayout.createSequentialGroup() .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.LEGENDARY)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.LEGENDARY)) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.LEGENDARY)))); final JPanel parentPanel = createStandardPanel("PersonnelMarketRemovalOptionsPanel", true, "PersonnelMarketRemovalOptionsPanel"); @@ -305,8 +294,7 @@ private JPanel createPersonnelMarketRemovalOptionsPanel() { parentLayout.createParallelGroup(Alignment.LEADING) .addGroup(parentLayout.createSequentialGroup() .addComponent(leftPanel) - .addComponent(rightPanel) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(rightPanel))); return parentPanel; } @@ -374,17 +362,14 @@ JPanel createUnitMarketTab() { .addComponent(headerPanel, Alignment.CENTER) .addGroup(layout.createSequentialGroup() .addComponent(lblUnitMarketMethod) - .addComponent(comboUnitMarketMethod) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(comboUnitMarketMethod)) .addComponent(chkUnitMarketRegionalMekVariations) .addGroup(layout.createSequentialGroup() .addComponent(lblUnitMarketSpecialUnitChance) - .addComponent(spnUnitMarketSpecialUnitChance) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnUnitMarketSpecialUnitChance)) .addGroup(layout.createSequentialGroup() .addComponent(lblUnitMarketRarityModifier) - .addComponent(spnUnitMarketRarityModifier) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnUnitMarketRarityModifier)) .addComponent(chkInstantUnitMarketDelivery) .addComponent(chkUnitMarketReportRefresh)); @@ -452,8 +437,7 @@ JPanel createContractMarketTab() { .addComponent(headerPanel, Alignment.CENTER) .addGroup(layout.createSequentialGroup() .addComponent(pnlContractMarketGeneralOptions) - .addComponent(pnlContractPay) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(pnlContractPay))); // Create Parent Panel and return return createParentPanel(panel, "ContractMarketTab"); @@ -508,21 +492,17 @@ private JPanel createContractMarketGeneralOptionsPanel() { layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(lblContractMarketMethod) - .addComponent(comboContractMarketMethod) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(comboContractMarketMethod)) .addGroup(layout.createSequentialGroup() .addComponent(lblContractSearchRadius) - .addComponent(spnContractSearchRadius) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnContractSearchRadius)) .addComponent(chkVariableContractLength) .addGroup(layout.createSequentialGroup() .addComponent(lblCoontractMaxSalvagePercentage) - .addComponent(spnContractMaxSalvagePercentage) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnContractMaxSalvagePercentage)) .addGroup(layout.createSequentialGroup() .addComponent(lblDropShipBonusPercentage) - .addComponent(spnDropShipBonusPercentage) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnDropShipBonusPercentage)) .addComponent(chkContractMarketReportRefresh)); return panel; @@ -595,28 +575,23 @@ private JPanel createContractPayPanel() { .addComponent(btnContractEquipment) .addGroup(layout.createSequentialGroup() .addGap(UIUtil.scaleForGUI(25)) - .addComponent(chkEquipContractSaleValue) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkEquipContractSaleValue)) .addGroup(layout.createSequentialGroup() .addGap(UIUtil.scaleForGUI(25)) .addComponent(lblEquipPercent) - .addComponent(spnEquipPercent) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnEquipPercent)) .addGroup(layout.createSequentialGroup() .addGap(UIUtil.scaleForGUI(25)) .addComponent(lblDropShipPercent) - .addComponent(spnDropShipPercent) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnDropShipPercent)) .addGroup(layout.createSequentialGroup() .addGap(UIUtil.scaleForGUI(25)) .addComponent(lblJumpShipPercent) - .addComponent(spnJumpShipPercent) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnJumpShipPercent)) .addGroup(layout.createSequentialGroup() .addGap(UIUtil.scaleForGUI(25)) .addComponent(lblWarShipPercent) - .addComponent(spnWarShipPercent) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnWarShipPercent)) .addComponent(btnContractPersonnel) .addComponent(chkBLCSaleValue) .addComponent(useInfantryDoseNotCountBox) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java index 410219d857..55d0124983 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java @@ -12,7 +12,6 @@ import javax.swing.GroupLayout.ParallelGroup; import javax.swing.GroupLayout.SequentialGroup; import javax.swing.JSpinner.DefaultEditor; -import javax.swing.LayoutStyle.ComponentPlacement; import java.awt.*; import java.util.HashMap; import java.util.Map; @@ -555,13 +554,11 @@ JPanel createPersonnelInformationTab() { .addComponent(chkUseTimeInService) .addGroup(layout.createSequentialGroup() .addComponent(lblTimeInServiceDisplayFormat) - .addComponent(comboTimeInServiceDisplayFormat) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(comboTimeInServiceDisplayFormat)) .addComponent(chkUseTimeInRank) .addGroup(layout.createSequentialGroup() .addComponent(lblTimeInRankDisplayFormat) - .addComponent(comboTimeInRankDisplayFormat) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(comboTimeInRankDisplayFormat)) .addComponent(chkTrackTotalEarnings) .addComponent(chkTrackTotalXPEarnings) .addComponent(chkShowOriginFaction)); @@ -696,12 +693,10 @@ public Component getListCellRendererComponent(final JList list, final Object .addComponent(headerPanel, Alignment.CENTER) .addGroup(layout.createSequentialGroup() .addComponent(lblAwardBonusStyle) - .addComponent(comboAwardBonusStyle) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(comboAwardBonusStyle)) .addGroup(layout.createSequentialGroup() .addComponent(lblAwardTierSize) - .addComponent(spnAwardTierSize) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnAwardTierSize)) .addComponent(chkEnableAutoAwards) .addComponent(chkIssuePosthumousAwards) .addComponent(chkIssueBestAwardOnly) @@ -820,8 +815,7 @@ JPanel createPrisonersAndDependentsTab() { .addComponent(headerPanel, Alignment.CENTER) .addGroup(layout.createSequentialGroup() .addComponent(prisonerPanel) - .addComponent(dependentsPanel) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(dependentsPanel))); // Create Parent Panel and return return createParentPanel(panel, "PrisonersAndDependentsTab"); @@ -877,12 +871,10 @@ public Component getListCellRendererComponent(final JList list, final Object layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(lblPrisonerCaptureStyle) - .addComponent(comboPrisonerCaptureStyle) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(comboPrisonerCaptureStyle)) .addGroup(layout.createSequentialGroup() .addComponent(lblPrisonerStatus) - .addComponent(comboPrisonerStatus) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(comboPrisonerStatus)) .addComponent(chkPrisonerBabyStatus) .addComponent(chkAtBPrisonerDefection) .addComponent(chkAtBPrisonerRansom)); @@ -982,22 +974,18 @@ JPanel createMedicalTab() { .addComponent(chkUseAdvancedMedical) .addGroup(layout.createSequentialGroup() .addComponent(lblHealWaitingPeriod) - .addComponent(spnHealWaitingPeriod) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnHealWaitingPeriod)) .addGroup(layout.createSequentialGroup() .addComponent(lblNaturalHealWaitingPeriod) - .addComponent(spnNaturalHealWaitingPeriod) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnNaturalHealWaitingPeriod)) .addGroup(layout.createSequentialGroup() .addComponent(lblMinimumHitsForVehicles) - .addComponent(spnMinimumHitsForVehicles) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnMinimumHitsForVehicles)) .addComponent(chkUseRandomHitsForVehicles) .addComponent(chkUseTougherHealing) .addGroup(layout.createSequentialGroup() .addComponent(lblMaximumPatients) - .addComponent(spnMaximumPatients) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(spnMaximumPatients))); // Create Parent Panel and return return createParentPanel(panel, "MedicalTab"); @@ -1080,8 +1068,7 @@ private JPanel createSalaryMultipliersPanel() { .addComponent(lblAntiMekSalary) .addComponent(spnAntiMekSalary) .addComponent(lblSpecialistInfantrySalary) - .addComponent(spnSpecialistInfantrySalary) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(spnSpecialistInfantrySalary))); return panel; } @@ -1132,7 +1119,6 @@ private JPanel createExperienceMultipliersPanel() { SequentialGroup horizontalSequentialGroup = layout.createSequentialGroup(); horizontalSequentialGroup.addComponent(lblSalaryExperienceMultipliers.get(skillLevels[index])); - horizontalSequentialGroup.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE); horizontalSequentialGroup.addComponent(spnSalaryExperienceMultipliers.get(skillLevels[index])); if (i != (columns - 1)) { horizontalSequentialGroup.addGap(10); @@ -1221,7 +1207,6 @@ private JPanel createBaseSalariesPanel() { SequentialGroup horizontalSequentialGroup = layout.createSequentialGroup(); horizontalSequentialGroup.addComponent(lblBaseSalary[index]); - horizontalSequentialGroup.addPreferredGap(ComponentPlacement.RELATED, Short.MAX_VALUE, Short.MAX_VALUE); horizontalSequentialGroup.addComponent(spnBaseSalary[index]); if (i != (columns - 1)) { horizontalSequentialGroup.addGap(10); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java index 15220ac8ef..d731beef3b 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java @@ -235,7 +235,7 @@ JPanel createMarriageTab() { .addGroup(layout.createSequentialGroup() .addComponent(pnlMarriageGeneralOptions) .addComponent(pnlRandomMarriage) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + ))); // Create Parent Panel and return return createParentPanel(panel, "MarriageTab"); @@ -290,11 +290,11 @@ private JPanel createMarriageGeneralOptionsPanel() { .addGroup(layout.createSequentialGroup() .addComponent(lblNoInterestInMarriageDiceSize) .addComponent(spnNoInterestInMarriageDiceSize) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addGroup(layout.createSequentialGroup() .addComponent(lblCheckMutualAncestorsDepth) .addComponent(spnCheckMutualAncestorsDepth) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addComponent(chkLogMarriageNameChanges))); return panel; @@ -357,13 +357,13 @@ public Component getListCellRendererComponent(final JList list, final Object .addGroup(layout.createSequentialGroup() .addComponent(lblRandomMarriageMethod) .addComponent(comboRandomMarriageMethod) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addComponent(chkUseRandomClanPersonnelMarriages) .addComponent(chkUseRandomPrisonerMarriages) .addGroup(layout.createSequentialGroup() .addComponent(lblRandomMarriageAgeRange) .addComponent(spnRandomMarriageAgeRange) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addComponent(pnlPercentageRandomMarriage))); return panel; @@ -415,15 +415,15 @@ private JPanel createPercentageRandomMarriagePanel() { .addGroup(layout.createSequentialGroup() .addComponent(lblRandomMarriageOppositeSexDiceSize) .addComponent(spnRandomMarriageDiceSize) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addGroup(layout.createSequentialGroup() .addComponent(lblRandomSameSexMarriageDiceSize) .addComponent(spnRandomSameSexMarriageDiceSize) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addGroup(layout.createSequentialGroup() .addComponent(lblRandomNewDependentMarriage) .addComponent(spnRandomNewDependentMarriage) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + ))); return panel; } @@ -529,7 +529,7 @@ public Component getListCellRendererComponent(final JList list, final Object .addGroup(layout.createSequentialGroup() .addComponent(lblRandomDivorceMethod) .addComponent(comboRandomDivorceMethod) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addComponent(chkUseRandomOppositeSexDivorce) .addComponent(chkUseRandomSameSexDivorce) .addComponent(chkUseRandomClanPersonnelDivorce) @@ -537,7 +537,7 @@ public Component getListCellRendererComponent(final JList list, final Object .addGroup(layout.createSequentialGroup() .addComponent(lblRandomDivorceDiceSize) .addComponent(spnRandomDivorceDiceSize) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + ))); return panel; } @@ -577,7 +577,7 @@ JPanel createProcreationTab() { .addGroup(layout.createSequentialGroup() .addComponent(pnlProcreationGeneralOptionsPanel) .addComponent(pnlRandomProcreationPanel) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + ))); // Create Parent Panel and return return createParentPanel(panel, "ProcreationTab"); @@ -662,11 +662,11 @@ public Component getListCellRendererComponent(final JList list, final Object .addGroup(layout.createSequentialGroup() .addComponent(lblMultiplePregnancyOccurrences) .addComponent(spnMultiplePregnancyOccurrences) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addGroup(layout.createSequentialGroup() .addComponent(lblBabySurnameStyle) .addComponent(comboBabySurnameStyle) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addComponent(chkAssignNonPrisonerBabiesFounderTag) .addComponent(chkAssignChildrenOfFoundersFounderTag) .addComponent(chkDetermineFatherAtBirth) @@ -674,7 +674,7 @@ public Component getListCellRendererComponent(final JList list, final Object .addGroup(layout.createSequentialGroup() .addComponent(lblNoInterestInChildrenDiceSize) .addComponent(spnNoInterestInChildrenDiceSize) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addComponent(chkUseMaternityLeave) .addComponent(chkLogProcreation))); @@ -743,18 +743,18 @@ public Component getListCellRendererComponent(final JList list, final Object .addGroup(layout.createSequentialGroup() .addComponent(lblRandomProcreationMethod) .addComponent(comboRandomProcreationMethod) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addComponent(chkUseRelationshiplessRandomProcreation) .addComponent(chkUseRandomClanPersonnelProcreation) .addComponent(chkUseRandomPrisonerProcreation) .addGroup(layout.createSequentialGroup() .addComponent(lblRandomProcreationRelationshipDiceSize) .addComponent(spnRandomProcreationRelationshipDiceSize) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addGroup(layout.createSequentialGroup() .addComponent(lblRandomProcreationRelationshiplessDiceSize) .addComponent(spnRandomProcreationRelationshiplessDiceSize) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + ))); return panel; } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java index 908ee59411..c745b4f37d 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java @@ -179,13 +179,11 @@ JPanel createRepairTab() { .addComponent(useDamageMargin) .addGroup(layout.createSequentialGroup() .addComponent(lblDamageMargin) - .addComponent(spnDamageMargin) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnDamageMargin)) .addGroup(layout.createSequentialGroup() .addComponent(lblDestroyPartTarget) .addComponent(spnDestroyPartTarget) - .addComponent(lblDestroyPartTargetPost) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(lblDestroyPartTargetPost))); // Create Parent Panel and return return createParentPanel(panel, "repairTab"); @@ -268,16 +266,13 @@ JPanel createMaintenanceTab() { .addComponent(checkMaintenance) .addGroup(layout.createSequentialGroup() .addComponent(lblMaintenanceDays) - .addComponent(spnMaintenanceDays) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnMaintenanceDays)) .addGroup(layout.createSequentialGroup() .addComponent(lblMaintenanceBonus) - .addComponent(spnMaintenanceBonus) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnMaintenanceBonus)) .addGroup(layout.createSequentialGroup() .addComponent(lblDefaultMaintenanceTime) - .addComponent(spnDefaultMaintenanceTime) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnDefaultMaintenanceTime)) .addComponent(useQualityMaintenance) .addComponent(reverseQualityNames) .addComponent(chkUseRandomUnitQualities) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RulesetsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RulesetsTab.java index 23f5e96c57..8fcb9c5b82 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RulesetsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RulesetsTab.java @@ -260,8 +260,7 @@ private JPanel createUniversalScenarioGenerationPanel() { .addComponent(chkAutoConfigMunitions) .addGroup(layout.createSequentialGroup() .addComponent(lblSPAUpgradeIntensity) - .addComponent(spnSPAUpgradeIntensity) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnSPAUpgradeIntensity)) .addComponent(pnlScenarioModifiers)); return panel; @@ -303,8 +302,7 @@ private JPanel createUniversalUnitRatioPanel() { .addComponent(lblOpForLanceTypeMixed) .addComponent(spnOpForLanceTypeMixed) .addComponent(lblOpForLanceTypeVehicle) - .addComponent(spnOpForLanceTypeVehicles) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(spnOpForLanceTypeVehicles))); return panel; } @@ -343,16 +341,13 @@ private JPanel createUniversalModifiersPanel() { layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(lblScenarioModMax) - .addComponent(spnScenarioModMax) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnScenarioModMax)) .addGroup(layout.createSequentialGroup() .addComponent(lblScenarioModChance) - .addComponent(spnScenarioModChance) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnScenarioModChance)) .addGroup(layout.createSequentialGroup() .addComponent(lblScenarioModBV) - .addComponent(spnScenarioModBV) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(spnScenarioModBV))); return panel; } @@ -388,8 +383,7 @@ private JPanel createUniversalMapGenerationPanel() { .addComponent(chkUsePlanetaryConditions) .addGroup(layout.createSequentialGroup() .addComponent(lblFixedMapChance) - .addComponent(spnFixedMapChance) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(spnFixedMapChance))); return panel; } @@ -445,12 +439,10 @@ private JPanel createUniversalPartsPanel() { .addComponent(chkRestrictPartsByMission) .addGroup(layout.createSequentialGroup() .addComponent(lblBonusPartExchangeValue) - .addComponent(spnBonusPartExchangeValue) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnBonusPartExchangeValue)) .addGroup(layout.createSequentialGroup() .addComponent(lblBonusPartMaxExchangeCount) - .addComponent(spnBonusPartMaxExchangeCount) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(spnBonusPartMaxExchangeCount))); return panel; } @@ -494,12 +486,10 @@ private JPanel createUniversalLancePanel() { .addComponent(chkUseStrategy) .addGroup(layout.createSequentialGroup() .addComponent(lblBaseStrategyDeployment) - .addComponent(spnBaseStrategyDeployment) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnBaseStrategyDeployment)) .addGroup(layout.createSequentialGroup() .addComponent(lblAdditionalStrategyDeployment) - .addComponent(spnAdditionalStrategyDeployment) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnAdditionalStrategyDeployment)) .addComponent(chkAdjustPaymentForStrategy)); return panel; @@ -548,16 +538,13 @@ JPanel createStratConTab() { .addComponent(chkUseStratCon) .addGroup(layout.createSequentialGroup() .addComponent(lblSkillLevel) - .addComponent(comboSkillLevel) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(comboSkillLevel)) .addGroup(layout.createSequentialGroup() .addComponent(chkUseGenericBattleValue) - .addComponent(chkUseVerboseBidding) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(chkUseVerboseBidding)) .addGroup(layout.createSequentialGroup() .addComponent(pnlScenarioGenerationPanel) - .addComponent(pnlCampaignOptions) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(pnlCampaignOptions))); // Create panel and return return createParentPanel(panel, "StratConTab"); @@ -620,8 +607,7 @@ JPanel createLegacyTab() { .addComponent(chkUseAtB) .addGroup(layout.createSequentialGroup() .addComponent(pnlLegacyOpForGenerationPanel) - .addComponent(pnlLegacyScenarioGenerationPanel) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); + .addComponent(pnlLegacyScenarioGenerationPanel))); // Create panel and return return createParentPanel(panel, "LegacyTab"); @@ -662,8 +648,7 @@ private JPanel createLegacyOpForGenerationPanel() { .addComponent(chkOpForUsesAero) .addGroup(layout.createSequentialGroup() .addComponent(lblOpForAeroChance) - .addComponent(spnOpForAeroChance) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnOpForAeroChance)) .addComponent(chkOpForUsesLocalForces) .addComponent(chkAdjustPlayerVehicles)); @@ -721,28 +706,23 @@ private JPanel createLegacyScenarioGenerationPanel() { .addComponent(chkGenerateChases) .addGroup(layout.createSequentialGroup() .addComponent(lblIntensity) - .addComponent(spnAtBBattleIntensity) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnAtBBattleIntensity)) .addGroup(layout.createSequentialGroup() .addGap(UIUtil.scaleForGUI(25)) .addComponent(lblFightChance) - .addComponent(spnAtBBattleChance[AtBLanceRole.FIGHTING.ordinal()]) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnAtBBattleChance[AtBLanceRole.FIGHTING.ordinal()])) .addGroup(layout.createSequentialGroup() .addGap(UIUtil.scaleForGUI(25)) .addComponent(lblDefendChance) - .addComponent(spnAtBBattleChance[AtBLanceRole.DEFENCE.ordinal()]) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnAtBBattleChance[AtBLanceRole.DEFENCE.ordinal()])) .addGroup(layout.createSequentialGroup() .addGap(UIUtil.scaleForGUI(25)) .addComponent(lblScoutChance) - .addComponent(spnAtBBattleChance[AtBLanceRole.SCOUTING.ordinal()]) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnAtBBattleChance[AtBLanceRole.SCOUTING.ordinal()])) .addGroup(layout.createSequentialGroup() .addGap(UIUtil.scaleForGUI(25)) .addComponent(lblTrainingChance) - .addComponent(spnAtBBattleChance[AtBLanceRole.TRAINING.ordinal()]) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + .addComponent(spnAtBBattleChance[AtBLanceRole.TRAINING.ordinal()])) .addComponent(btnIntensityUpdate)); return panel; diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java index 5d1d610331..fa9074dbf3 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java @@ -262,7 +262,7 @@ JPanel createTurnoverTab() { .addComponent(pnlSettings) .addComponent(pnlModifiers) .addComponent(pnlPayout) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addComponent(pnlUnitCohesion))); // Create Parent Panel and return @@ -364,11 +364,11 @@ public Component getListCellRendererComponent(final JList list, final Object .addGroup(layout.createSequentialGroup() .addComponent(lblTurnoverFixedTargetNumber) .addComponent(spnTurnoverFixedTargetNumber) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addGroup(layout.createSequentialGroup() .addComponent(lblTurnoverFrequency) .addComponent(comboTurnoverFrequency) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addComponent(chkUseContractCompletionRandomRetirement) .addComponent(chkUseRandomFounderTurnover) .addComponent(chkTrackOriginalUnit) @@ -377,16 +377,16 @@ public Component getListCellRendererComponent(final JList list, final Object .addGroup(layout.createSequentialGroup() .addComponent(lblServiceContractDuration) .addComponent(spnServiceContractDuration) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addGroup(layout.createSequentialGroup() .addComponent(lblServiceContractModifier) .addComponent(spnServiceContractModifier) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addComponent(chkPayBonusDefault) .addGroup(layout.createSequentialGroup() .addComponent(lblPayBonusDefaultThreshold) .addComponent(spnPayBonusDefaultThreshold) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + ))); return panel; } @@ -454,7 +454,7 @@ private JPanel createModifiersPanel() { .addGroup(layout.createSequentialGroup() .addComponent(chkUseLoyaltyModifiers) .addComponent(chkUseHideLoyalty) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + ))); return panel; } @@ -518,20 +518,20 @@ private JPanel createPayoutsPanel() { .addGroup(layout.createSequentialGroup() .addComponent(lblPayoutRateOfficer) .addComponent(spnPayoutRateOfficer) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addGroup(layout.createSequentialGroup() .addComponent(lblPayoutRateEnlisted) .addComponent(spnPayoutRateEnlisted) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addGroup(layout.createSequentialGroup() .addComponent(lblPayoutRetirementMultiplier) .addComponent(spnPayoutRetirementMultiplier) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addComponent(chkUsePayoutServiceBonus) .addGroup(layout.createSequentialGroup() .addComponent(lblPayoutServiceBonusRate) .addComponent(spnPayoutServiceBonusRate) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + ))); return panel; } @@ -569,7 +569,7 @@ private JPanel createUnitCohesionPanel() { .addGroup(layout.createSequentialGroup() .addComponent(pnlAdministrativeStrainWrapper) .addComponent(pnlManagementSkillWrapper) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + ))); return panel; } @@ -651,11 +651,11 @@ private JPanel createAdministrativeStrainPanel() { .addGroup(layout.createSequentialGroup() .addComponent(lblAdministrativeCapacity) .addComponent(spnAdministrativeCapacity) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addGroup(layout.createSequentialGroup() .addComponent(lblMultiCrewStrainDivider) .addComponent(spnMultiCrewStrainDivider) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + ))); return panel; } @@ -736,7 +736,7 @@ private JPanel createManagementSkillPanel() { .addGroup(layout.createSequentialGroup() .addComponent(lblManagementSkillPenalty) .addComponent(spnManagementSkillPenalty) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + ))); return panel; } @@ -808,16 +808,16 @@ JPanel createFatigueTab() { .addComponent(lblFatigueRate) .addComponent(spnFatigueRate) .addComponent(chkUseInjuryFatigue) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addGroup(layout.createSequentialGroup() .addComponent(lblFieldKitchenCapacity) .addComponent(spnFieldKitchenCapacity) .addComponent(chkFieldKitchenIgnoreNonCombatants) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) + ) .addGroup(layout.createSequentialGroup() .addComponent(lblFatigueLeaveThreshold) .addComponent(spnFatigueLeaveThreshold) - .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)))); + ))); // Create Parent Panel and return return createParentPanel(panel, "FatigueTab"); From 4e7d2ba3ab11133df597c1dd2b58bdde6295eb64 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 14 Oct 2024 22:11:00 -0500 Subject: [PATCH 076/117] Refactor panel layout in CampaignOptionsUtilities.java Removed unnecessary GroupLayout configuration in favor of BoxLayout for a simpler and more flexible layout management. This change enhances code readability and maintains consistent GUI scaling across different components. --- .../tabs/CampaignOptionsUtilities.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index 9bcfb177a2..85080f3473 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -281,7 +281,6 @@ static JPanel createHeaderPanel(String name, String imageAddress, boolean includ } final JPanel panel = createStandardPanel("pnl" + name + "HeaderPanel", false, ""); - final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -326,7 +325,6 @@ static GroupLayout createStandardLayout(JPanel panel) { static JPanel createParentPanel(JPanel panel, String name) { // Create Panel final JPanel parentPanel = createStandardPanel(name, false); - final GroupLayout parentLayout = createStandardLayout(parentPanel); // Set Dimensions int widthNew = parentPanel.getMinimumSize().width; @@ -347,15 +345,11 @@ static JPanel createParentPanel(JPanel panel, String name) { parentPanel.setMaximumSize(UIUtil.scaleForGUI(size.width, size.height)); // Layout - parentPanel.setLayout(parentLayout); - - parentLayout.setVerticalGroup( - parentLayout.createSequentialGroup() - .addComponent(panel)); + parentPanel.setLayout(new BoxLayout(parentPanel, BoxLayout.Y_AXIS)); - parentLayout.setHorizontalGroup( - parentLayout.createParallelGroup(Alignment.CENTER) - .addComponent(panel)); + parentPanel.add(Box.createVerticalGlue()); + parentPanel.add(panel); + parentPanel.add(Box.createVerticalGlue()); return parentPanel; } From 28d76891d80bc627ff20d6e7460321bafc6e3c0d Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 14 Oct 2024 22:37:20 -0500 Subject: [PATCH 077/117] Scale and smooth header panel images Scaled and smoothed header panel images to improve UI appearance. Updated `CampaignOptionsUtilities` and `GeneralTab` to adjust image sizes dynamically and enhance display quality. --- .../tabs/CampaignOptionsUtilities.java | 13 +++++++++++++ .../gui/panes/campaignOptions/tabs/GeneralTab.java | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java index 85080f3473..427e7fd688 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java @@ -263,13 +263,25 @@ static JPanel createStandardPanel(String name, boolean includeBorder, String bor * @return a {@link JPanel} representing the header panel */ static JPanel createHeaderPanel(String name, String imageAddress, boolean includeBodyText) { + // Fetch and scale image ImageIcon imageIcon = new ImageIcon(imageAddress); + + int width = UIUtil.scaleForGUI(imageIcon.getIconWidth()); + int height = UIUtil.scaleForGUI(imageIcon.getIconHeight()); + + Image image = imageIcon.getImage(); + Image newImg = image.getScaledInstance(width, height, Image.SCALE_SMOOTH); + + imageIcon = new ImageIcon(newImg); + JLabel imageLabel = new JLabel(imageIcon); + // Create header text final JLabel lblHeader = new JLabel(resources.getString("lbl" + name + ".text"), SwingConstants.CENTER); lblHeader.setName("lbl" + name); setFontScaling(lblHeader, true, 2); + // Create body text JLabel lblBody = new JLabel(); if (includeBodyText) { lblBody = new JLabel(String.format("

%s

", @@ -280,6 +292,7 @@ static JPanel createHeaderPanel(String name, String imageAddress, boolean includ lblBody.setMaximumSize(UIUtil.scaleForGUI(750, size.height)); } + // Layout panel final JPanel panel = createStandardPanel("pnl" + name + "HeaderPanel", false, ""); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java index 186ec8a523..452c6a9934 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java @@ -199,6 +199,15 @@ public AbstractMHQScrollablePanel createGeneralTab() { */ private static JPanel createGeneralHeader() { ImageIcon imageIcon = new ImageIcon("data/images/misc/MekHQ.png"); + + int width = UIUtil.scaleForGUI(imageIcon.getIconWidth()); + int height = UIUtil.scaleForGUI(imageIcon.getIconHeight()); + + Image image = imageIcon.getImage(); + Image newImg = image.getScaledInstance(width, height, Image.SCALE_SMOOTH); + + imageIcon = new ImageIcon(newImg); + JLabel imageLabel = new JLabel(imageIcon); final JLabel lblHeader = new JLabel(resources.getString("lblGeneral.text"), SwingConstants.CENTER); From 0836a8ef58620f4cfacfd2f62e4a9807d905ae91 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 14 Oct 2024 22:39:16 -0500 Subject: [PATCH 078/117] Refactor campaignOptions tabs to a higher package level Moved all CampaignOptions tabs from the 'tabs' subpackage to the parent 'campaignOptions' package for better organization. Updated imports accordingly to reflect the new package structure. --- MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java | 2 +- .../gui/panes/campaignOptions/{tabs => }/BiographyTab.java | 4 ++-- .../panes/campaignOptions/{tabs => }/CampaignOptionsPane.java | 4 ++-- .../campaignOptions/{tabs => }/CampaignOptionsUtilities.java | 2 +- .../campaignOptions/{tabs => }/EquipmentAndSuppliesTab.java | 4 ++-- .../gui/panes/campaignOptions/{tabs => }/FinancesTab.java | 4 ++-- .../gui/panes/campaignOptions/{tabs => }/GeneralTab.java | 4 ++-- .../gui/panes/campaignOptions/{tabs => }/MarketsTab.java | 4 ++-- .../gui/panes/campaignOptions/{tabs => }/PersonnelTab.java | 4 ++-- .../panes/campaignOptions/{tabs => }/RelationshipsTab.java | 4 ++-- .../campaignOptions/{tabs => }/RepairAndMaintenanceTab.java | 4 ++-- .../gui/panes/campaignOptions/{tabs => }/RulesetsTab.java | 4 ++-- .../campaignOptions/{tabs => }/TurnoverAndRetentionTab.java | 4 ++-- 13 files changed, 24 insertions(+), 24 deletions(-) rename MekHQ/src/mekhq/gui/panes/campaignOptions/{tabs => }/BiographyTab.java (99%) rename MekHQ/src/mekhq/gui/panes/campaignOptions/{tabs => }/CampaignOptionsPane.java (98%) rename MekHQ/src/mekhq/gui/panes/campaignOptions/{tabs => }/CampaignOptionsUtilities.java (99%) rename MekHQ/src/mekhq/gui/panes/campaignOptions/{tabs => }/EquipmentAndSuppliesTab.java (99%) rename MekHQ/src/mekhq/gui/panes/campaignOptions/{tabs => }/FinancesTab.java (99%) rename MekHQ/src/mekhq/gui/panes/campaignOptions/{tabs => }/GeneralTab.java (99%) rename MekHQ/src/mekhq/gui/panes/campaignOptions/{tabs => }/MarketsTab.java (99%) rename MekHQ/src/mekhq/gui/panes/campaignOptions/{tabs => }/PersonnelTab.java (99%) rename MekHQ/src/mekhq/gui/panes/campaignOptions/{tabs => }/RelationshipsTab.java (99%) rename MekHQ/src/mekhq/gui/panes/campaignOptions/{tabs => }/RepairAndMaintenanceTab.java (98%) rename MekHQ/src/mekhq/gui/panes/campaignOptions/{tabs => }/RulesetsTab.java (99%) rename MekHQ/src/mekhq/gui/panes/campaignOptions/{tabs => }/TurnoverAndRetentionTab.java (99%) diff --git a/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java b/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java index b25f1f8858..1dd9db2d05 100644 --- a/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/CampaignOptionsDialog.java @@ -27,8 +27,8 @@ import mekhq.campaign.CampaignPreset; import mekhq.gui.FileDialogs; import mekhq.gui.baseComponents.AbstractMHQValidationButtonDialog; +import mekhq.gui.panes.campaignOptions.CampaignOptionsPane; import mekhq.gui.panes.campaignOptions.SelectPresetDialog; -import mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsPane; import javax.swing.*; import java.awt.*; diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java similarity index 99% rename from MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java rename to MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java index 9a44a569dc..cc9f07436b 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/BiographyTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java @@ -1,4 +1,4 @@ -package mekhq.gui.panes.campaignOptions.tabs; +package mekhq.gui.panes.campaignOptions; import megamek.client.generator.RandomGenderGenerator; import megamek.client.generator.RandomNameGenerator; @@ -22,7 +22,7 @@ import java.util.HashMap; import java.util.Map; -import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; +import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; /** * The `BiographyTab` class represents the biography settings tab in campaign options. diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java similarity index 98% rename from MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java rename to MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java index b6a818f7c0..d892e2389b 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java @@ -1,4 +1,4 @@ -package mekhq.gui.panes.campaignOptions.tabs; +package mekhq.gui.panes.campaignOptions; import megamek.logging.MMLogger; import mekhq.campaign.Campaign; @@ -9,7 +9,7 @@ import java.util.ResourceBundle; import static java.lang.Math.round; -import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.createSubTabs; +import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.createSubTabs; public class CampaignOptionsPane extends AbstractMHQTabbedPane { private static final MMLogger logger = MMLogger.create(CampaignOptionsPane.class); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java similarity index 99% rename from MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java rename to MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java index 427e7fd688..fdffd78dc5 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java @@ -1,4 +1,4 @@ -package mekhq.gui.panes.campaignOptions.tabs; +package mekhq.gui.panes.campaignOptions; import megamek.client.ui.swing.util.FlatLafStyleBuilder; import megamek.client.ui.swing.util.UIUtil; diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java similarity index 99% rename from MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java rename to MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java index 46dd6eff9e..f05a28942b 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/EquipmentAndSuppliesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java @@ -1,4 +1,4 @@ -package mekhq.gui.panes.campaignOptions.tabs; +package mekhq.gui.panes.campaignOptions; import megamek.client.ui.baseComponents.MMComboBox; import megamek.client.ui.swing.util.UIUtil; @@ -13,7 +13,7 @@ import java.awt.*; import java.util.ResourceBundle; -import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; +import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; public class EquipmentAndSuppliesTab { // region Variable Declarations diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/FinancesTab.java similarity index 99% rename from MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java rename to MekHQ/src/mekhq/gui/panes/campaignOptions/FinancesTab.java index f7608b6027..8eee98f016 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/FinancesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/FinancesTab.java @@ -1,4 +1,4 @@ -package mekhq.gui.panes.campaignOptions.tabs; +package mekhq.gui.panes.campaignOptions; import megamek.client.ui.baseComponents.MMComboBox; import megamek.client.ui.swing.util.UIUtil; @@ -11,7 +11,7 @@ import javax.swing.JSpinner.DefaultEditor; import javax.swing.JSpinner.NumberEditor; -import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; +import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; /** * This class represents the FinancesTab campaign options, configuring finance-related settings. diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java similarity index 99% rename from MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java rename to MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java index 452c6a9934..7620026330 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java @@ -1,4 +1,4 @@ -package mekhq.gui.panes.campaignOptions.tabs; +package mekhq.gui.panes.campaignOptions; import megamek.client.ui.baseComponents.MMComboBox; import megamek.client.ui.dialogs.CamoChooserDialog; @@ -24,7 +24,7 @@ import java.awt.event.ActionEvent; import java.time.LocalDate; -import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; +import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; /** * Represents a tab that allows the user to configure general settings for a campaign. diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/MarketsTab.java similarity index 99% rename from MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java rename to MekHQ/src/mekhq/gui/panes/campaignOptions/MarketsTab.java index fa1eb32829..32e26b1ee3 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/MarketsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/MarketsTab.java @@ -1,4 +1,4 @@ -package mekhq.gui.panes.campaignOptions.tabs; +package mekhq.gui.panes.campaignOptions; import megamek.client.ui.baseComponents.MMComboBox; import megamek.client.ui.swing.util.UIUtil; @@ -16,7 +16,7 @@ import java.util.HashMap; import java.util.Map; -import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; +import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; public class MarketsTab { JFrame frame; diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java similarity index 99% rename from MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java rename to MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java index 55d0124983..657aec0f08 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java @@ -1,4 +1,4 @@ -package mekhq.gui.panes.campaignOptions.tabs; +package mekhq.gui.panes.campaignOptions; import megamek.client.ui.baseComponents.MMComboBox; import megamek.client.ui.swing.util.UIUtil; @@ -17,7 +17,7 @@ import java.util.Map; import static megamek.client.ui.WrapLayout.wordWrap; -import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; +import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; /** * Handles the Personnel tab of campaign options diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java similarity index 99% rename from MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java rename to MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java index d731beef3b..9a89aa316a 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RelationshipsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java @@ -1,4 +1,4 @@ -package mekhq.gui.panes.campaignOptions.tabs; +package mekhq.gui.panes.campaignOptions; import megamek.client.ui.baseComponents.MMComboBox; import mekhq.campaign.personnel.enums.BabySurnameStyle; @@ -10,7 +10,7 @@ import javax.swing.GroupLayout.Alignment; import java.awt.*; -import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; +import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; public class RelationshipsTab { JFrame frame; diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java similarity index 98% rename from MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java rename to MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java index c745b4f37d..0922d5fed3 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java @@ -1,9 +1,9 @@ -package mekhq.gui.panes.campaignOptions.tabs; +package mekhq.gui.panes.campaignOptions; import javax.swing.*; import javax.swing.GroupLayout.Alignment; -import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; +import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; /** * This class represents the tab for repair and maintenance settings. diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RulesetsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/RulesetsTab.java similarity index 99% rename from MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RulesetsTab.java rename to MekHQ/src/mekhq/gui/panes/campaignOptions/RulesetsTab.java index 8fcb9c5b82..fb529b91ab 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/RulesetsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/RulesetsTab.java @@ -1,4 +1,4 @@ -package mekhq.gui.panes.campaignOptions.tabs; +package mekhq.gui.panes.campaignOptions; import megamek.client.ui.baseComponents.MMComboBox; import megamek.client.ui.swing.util.UIUtil; @@ -12,7 +12,7 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; +import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; public class RulesetsTab { JFrame frame; diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java similarity index 99% rename from MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java rename to MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java index fa9074dbf3..040d0a55c8 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/tabs/TurnoverAndRetentionTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java @@ -1,4 +1,4 @@ -package mekhq.gui.panes.campaignOptions.tabs; +package mekhq.gui.panes.campaignOptions; import megamek.client.ui.baseComponents.MMComboBox; import mekhq.campaign.personnel.enums.TurnoverFrequency; @@ -7,7 +7,7 @@ import javax.swing.GroupLayout.Alignment; import java.awt.*; -import static mekhq.gui.panes.campaignOptions.tabs.CampaignOptionsUtilities.*; +import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; /** * This class represents a GUI configuration form with two main tabs: 'Turnover' and 'Fatigue'. From cfbbeda9fa07e7d7906f7f75adfce78a2e25a2b4 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 14 Oct 2024 23:16:20 -0500 Subject: [PATCH 079/117] Refactor scaling logic and button creation Renamed variables for clarity in image scaling methods across various files. Updated font scaling function to accept double instead of int. Refactored button creation and layout setup in SelectPresetDialog.java for better code reuse and consistency. --- .../NEWCampaignOptionsDialog.properties | 12 ++--- .../CampaignOptionsUtilities.java | 8 ++-- .../gui/panes/campaignOptions/GeneralTab.java | 4 +- .../campaignOptions/SelectPresetDialog.java | 47 ++++++++++++------- 4 files changed, 41 insertions(+), 30 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 8ac8b3e96c..7e62bcc5ab 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -3,12 +3,12 @@ presetDialog.title=Select a Campaign Preset presetDialog.description=Choose a preset to tailor your experience. Each option provides a\ \ well-balanced challenge, suitable for both newcomers and seasoned players. -presetDialogSelect.name=Confirm -presetDialogSelect.tooltip=Confirm the currently selected preset. -presetDialogCustomize.name=Customize -presetDialogCustomize.tooltip=Select a preset, then open the campaign options menu. -presetDialogCancel.name=Cancel -presetDialogCancel.tooltip=Return to the prior screen. +lblPresetDialogSelect.text=Confirm +lblPresetDialogSelect.tooltip=Confirm the currently selected preset. +lblPresetDialogCustomize.text=Customize +lblPresetDialogCustomize.tooltip=Select a preset, then open the campaign options menu. +lblPresetDialogCancel.text=Cancel +lblPresetDialogCancel.tooltip=Return to the prior screen. ## Campaign Options Pane generalPanel.title=General Information diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java index fdffd78dc5..0a27f9c4fd 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java @@ -270,9 +270,9 @@ static JPanel createHeaderPanel(String name, String imageAddress, boolean includ int height = UIUtil.scaleForGUI(imageIcon.getIconHeight()); Image image = imageIcon.getImage(); - Image newImg = image.getScaledInstance(width, height, Image.SCALE_SMOOTH); + Image scaledImage = image.getScaledInstance(width, height, Image.SCALE_SMOOTH); - imageIcon = new ImageIcon(newImg); + imageIcon = new ImageIcon(scaledImage); JLabel imageLabel = new JLabel(imageIcon); @@ -468,9 +468,9 @@ static JButton createButton(String name) { * @param component The JComponent to which the font scaling is applied. * @param boldText A boolean that sets whether the text should be bolded. * If {@code true}, the text will be bolded, else, it will be regular. - * @param size An integer representing the size of the font to be set. + * @param size A double representing the size of the font to be set. */ - static void setFontScaling(JComponent component, boolean boldText, int size) { + static void setFontScaling(JComponent component, boolean boldText, double size) { if (boldText) { new FlatLafStyleBuilder().font(MHQConstants.PROJECT_NAME).bold().size(size).apply(component); } else { diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java index 7620026330..e8935df003 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java @@ -204,9 +204,9 @@ private static JPanel createGeneralHeader() { int height = UIUtil.scaleForGUI(imageIcon.getIconHeight()); Image image = imageIcon.getImage(); - Image newImg = image.getScaledInstance(width, height, Image.SCALE_SMOOTH); + Image scaledImage = image.getScaledInstance(width, height, Image.SCALE_SMOOTH); - imageIcon = new ImageIcon(newImg); + imageIcon = new ImageIcon(scaledImage); JLabel imageLabel = new JLabel(imageIcon); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java index 342da2a033..5d5c5ba7ca 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java @@ -18,6 +18,7 @@ */ package mekhq.gui.panes.campaignOptions; +import megamek.client.ui.swing.util.UIUtil; import megamek.logging.MMLogger; import mekhq.MekHQ; import mekhq.campaign.CampaignPreset; @@ -28,6 +29,9 @@ import java.util.ResourceBundle; import static megamek.client.ui.WrapLayout.wordWrap; +import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.createButton; +import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.createStandardLayout; +import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.setFontScaling; /** * A dialog for selecting campaign presets. Extends {@link JDialog}. @@ -39,10 +43,6 @@ public class SelectPresetDialog extends JDialog { private static final ResourceBundle resources = ResourceBundle.getBundle(RESOURCE_PACKAGE, MekHQ.getMHQOptions().getLocale()); - final static String OPTION_SELECT_PRESET = resources.getString("presetDialogSelect.name"); - final static String OPTION_CUSTOMIZE_PRESET = resources.getString("presetDialogCustomize.name"); - final static String OPTION_CANCEL = resources.getString("presetDialogCancel.name"); - private static final MMLogger logger = MMLogger.create(SelectPresetDialog.class); private int returnState; @@ -83,19 +83,27 @@ public SelectPresetDialog(JFrame frame, boolean includePresetSelectOption, boole setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); - ImageIcon image = new ImageIcon("data/images/misc/megamek-splash.png"); - JLabel imageLabel = new JLabel(image); + ImageIcon imageIcon = new ImageIcon("data/images/misc/megamek-splash.png"); + + int width = UIUtil.scaleForGUI(imageIcon.getIconWidth()); + int height = UIUtil.scaleForGUI(imageIcon.getIconHeight()); + + Image image = imageIcon.getImage(); + Image scaledImage = image.getScaledInstance(width, height, Image.SCALE_SMOOTH); + + imageIcon = new ImageIcon(scaledImage); + JLabel imageLabel = new JLabel(imageIcon); add(imageLabel, BorderLayout.NORTH); JPanel centerPanel = new JPanel(); - final GroupLayout layout = new GroupLayout(centerPanel); - layout.setAutoCreateGaps(true); - layout.setAutoCreateContainerGaps(true); + final GroupLayout layout = createStandardLayout(centerPanel); centerPanel.setLayout(layout); JLabel descriptionLabel = new JLabel(String.format( - "
%s
", + "
%s
", + UIUtil.scaleForGUI(400), resources.getString("presetDialog.description"))); + setFontScaling(descriptionLabel, false, 1); final DefaultListModel campaignPresets = new DefaultListModel<>(); campaignPresets.addAll(CampaignPreset.getCampaignPresets()); @@ -132,16 +140,20 @@ public Component getListCellRendererComponent(JList list, Object value, ); layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) + layout.createParallelGroup(Alignment.CENTER) .addComponent(descriptionLabel) .addComponent(comboBox) ); - add(centerPanel, BorderLayout.CENTER); + JPanel outerPanel = new JPanel(new GridBagLayout()); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.anchor = GridBagConstraints.CENTER; + outerPanel.add(centerPanel,gbc); + + add(outerPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); - JButton buttonSelect = new JButton(OPTION_SELECT_PRESET); - buttonSelect.setToolTipText(resources.getString("presetDialogSelect.tooltip")); + JButton buttonSelect = createButton("PresetDialogSelect"); buttonSelect.addActionListener(e -> { selectedPreset = (CampaignPreset) comboBox.getSelectedItem(); returnState = PRESET_SELECTION_SELECT; @@ -150,8 +162,7 @@ public Component getListCellRendererComponent(JList list, Object value, buttonSelect.setEnabled(includePresetSelectOption); buttonPanel.add(buttonSelect); - JButton buttonCustomize = new JButton(OPTION_CUSTOMIZE_PRESET); - buttonCustomize.setToolTipText(resources.getString("presetDialogCustomize.tooltip")); + JButton buttonCustomize = createButton("PresetDialogCustomize"); buttonCustomize.addActionListener(e -> { selectedPreset = (CampaignPreset) comboBox.getSelectedItem(); returnState = PRESET_SELECTION_CUSTOMIZE; @@ -160,8 +171,7 @@ public Component getListCellRendererComponent(JList list, Object value, buttonCustomize.setEnabled(includeCustomizePresetOption); buttonPanel.add(buttonCustomize); - JButton buttonCancel = new JButton(OPTION_CANCEL); - buttonCancel.setToolTipText(resources.getString("presetDialogCancel.tooltip")); + JButton buttonCancel = createButton("PresetDialogCancel"); buttonCancel.addActionListener(e -> { returnState = PRESET_SELECTION_CANCELLED; dispose(); @@ -173,6 +183,7 @@ public Component getListCellRendererComponent(JList list, Object value, pack(); setAlwaysOnTop(true); setResizable(false); + setSize(UIUtil.scaleForGUI(575, 250)); setLocationRelativeTo(null); setVisible(true); } From 70300bde106b6290e86f843933238069119069f2 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 14 Oct 2024 23:41:55 -0500 Subject: [PATCH 080/117] Set dialogs to always be on top Ensured that the main date chooser dialog and turning points dialog are always on top of other windows. This change helps maintain visibility and user workflow by preventing these dialogs from being obscured by other windows. --- MekHQ/src/mekhq/gui/dialog/DateChooser.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MekHQ/src/mekhq/gui/dialog/DateChooser.java b/MekHQ/src/mekhq/gui/dialog/DateChooser.java index eb4cd93766..1cf843593a 100644 --- a/MekHQ/src/mekhq/gui/dialog/DateChooser.java +++ b/MekHQ/src/mekhq/gui/dialog/DateChooser.java @@ -273,6 +273,7 @@ public String valueToString(Object value) { // center this dialog over the owner setLocationRelativeTo(owner); setUserPreferences(); + setAlwaysOnTop(true); } @Deprecated // These need to be migrated to the Suite Constants / Suite Options Setup @@ -676,7 +677,8 @@ private void turningPointsDialog(int era, String reference) { turningPointsDialog.getContentPane().add(descriptionAndButtonsPanel, BorderLayout.CENTER); // set turningPointsDialog size and location, and make it visible - setResizable(false); + turningPointsDialog.setResizable(false); + turningPointsDialog.setAlwaysOnTop(true); turningPointsDialog.pack(); turningPointsDialog.setMinimumSize(turningPointsDialog.getSize()); turningPointsDialog.setLocationRelativeTo(null); From c22eeba7cd43a39dd3c33fc2eaed776ab6aebcd1 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 15 Oct 2024 00:12:45 -0500 Subject: [PATCH 081/117] Refactored GeneralTab layout and added utility methods Separated the GeneralTab panel layout into a distinct method for better organization. Added new utility methods to handle text field sizing and creating empty panels to manage whitespace. --- .../CampaignOptionsUtilities.java | 21 ++++ .../gui/panes/campaignOptions/GeneralTab.java | 96 +++++++++++-------- 2 files changed, 79 insertions(+), 38 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java index 0a27f9c4fd..4c24511587 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java @@ -181,6 +181,10 @@ static JTextField createTextField(String name, @Nullable Integer customWrapSize, jTextField.setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), customWrapSize)); jTextField.setName("txt" + name); + Dimension size = jTextField.getPreferredSize(); + jTextField.setMinimumSize(UIUtil.scaleForGUI(width, size.height)); + jTextField.setMaximumSize(UIUtil.scaleForGUI(width, size.height)); + setFontScaling(jTextField, false, 1); return jTextField; @@ -248,6 +252,23 @@ static JPanel createStandardPanel(String name, boolean includeBorder, String bor return panel; } + + /** + * Creates an empty {@link JPanel} with the specified name and minimum width. + * This is used to occupy whitespace to stop GUI elements from getting overly spread out. + * Its inclusion is not ideal, but after a couple of days of throwing our heads against a wall, + * this was the best solution we could find. + * + * @param width the minimum width of the {@link JPanel} + * @return a new {@link JPanel} with the specified name and minimum width + */ + static JPanel createEmptyPanel(int width) { + JPanel panel = new JPanel(); + panel.setMinimumSize(UIUtil.scaleForGUI(width, 25)); + + return panel; + } + /** * Creates a {@link JPanel} consisting of a {@link JLabel} above an image. * If {@code includeBodyText} is {@code true} a second {@link JLabel} is placed after the first. diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java index e8935df003..ee2f04abe3 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java @@ -55,6 +55,7 @@ public class GeneralTab { private JLabel lblIcon; private JButton btnIcon; private StandardForceIcon unitIcon; + private JPanel createGeneralOptionsPanel; /** * Constructs a new {@link GeneralTab} object. @@ -83,29 +84,15 @@ public AbstractMHQScrollablePanel createGeneralTab() { // Header JPanel headerPanel = createGeneralHeader(); - // Campaign name lblName = createLabel("Name"); txtName = createTextField("Name", 300); - // Generate new random campaign name btnNameGenerator = createButton("NameGenerator"); btnNameGenerator.addActionListener(e -> txtName.setText(BackgroundsController - .randomMercenaryCompanyNameGenerator(campaign.getFlaggedCommander()))); + .randomMercenaryCompanyNameGenerator(campaign.getFlaggedCommander()))); - // Campaign faction - lblFaction = createLabel("Faction"); - comboFaction.setSelectedItem(new FactionDisplay(campaign.getFaction(), campaign.getLocalDate())); - - // Reputation - lblReputation = createLabel("Reputation"); - lblManualUnitRatingModifier = createLabel("ManualUnitRatingModifier"); - manualUnitRatingModifier = createSpinner("ManualUnitRatingModifier", - 0, -200, 200, 1); - - // Date - lblDate = createLabel("Date"); - btnDate = createButton("Date"); - btnDate.addActionListener(this::btnDateActionPerformed); + createGeneralOptionsPanel = createGeneralOptionsPanel(); + JPanel emptyPanel = createEmptyPanel(0); // Camouflage lblCamo = createLabel("Camo"); @@ -144,17 +131,8 @@ public AbstractMHQScrollablePanel createGeneralTab() { .addComponent(txtName) .addComponent(btnNameGenerator)) .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblFaction) - .addComponent(comboFaction)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblReputation) - .addComponent(unitRatingMethodCombo)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblManualUnitRatingModifier) - .addComponent(manualUnitRatingModifier)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblDate) - .addComponent(btnDate)) + .addComponent(createGeneralOptionsPanel) + .addComponent(emptyPanel)) .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(lblCamo) .addComponent(btnCamo) @@ -168,6 +146,56 @@ public AbstractMHQScrollablePanel createGeneralTab() { .addComponent(lblName) .addComponent(txtName) .addComponent(btnNameGenerator)) + .addGroup(layout.createSequentialGroup() + .addComponent(createGeneralOptionsPanel) + .addComponent(emptyPanel)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblCamo) + .addComponent(btnCamo) + .addGap(UIUtil.scaleForGUI(50)) + .addComponent(lblIcon) + .addComponent(btnIcon))); + + generalPanel.add(panel); + + return generalPanel; + } + + private JPanel createGeneralOptionsPanel() { + lblFaction = createLabel("Faction"); + comboFaction.setSelectedItem(new FactionDisplay(campaign.getFaction(), campaign.getLocalDate())); + + lblReputation = createLabel("Reputation"); + lblManualUnitRatingModifier = createLabel("ManualUnitRatingModifier"); + manualUnitRatingModifier = createSpinner("ManualUnitRatingModifier", + 0, -200, 200, 1); + + lblDate = createLabel("Date"); + btnDate = createButton("Date"); + btnDate.addActionListener(this::btnDateActionPerformed); + + // Layout the Panel + final JPanel panel = createStandardPanel("GeneralOptionsPanel", false); + final GroupLayout layout = createStandardLayout(panel); + panel.setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblFaction) + .addComponent(comboFaction)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblReputation) + .addComponent(unitRatingMethodCombo)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblManualUnitRatingModifier) + .addComponent(manualUnitRatingModifier)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblDate) + .addComponent(btnDate))); + + layout.setHorizontalGroup( + layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(lblFaction) .addComponent(comboFaction)) @@ -179,17 +207,9 @@ public AbstractMHQScrollablePanel createGeneralTab() { .addComponent(manualUnitRatingModifier)) .addGroup(layout.createSequentialGroup() .addComponent(lblDate) - .addComponent(btnDate)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblCamo) - .addComponent(btnCamo) - .addGap(50) - .addComponent(lblIcon) - .addComponent(btnIcon))); + .addComponent(btnDate))); - generalPanel.add(panel); - - return generalPanel; + return panel; } /** From cdded51982d7cacbad843ecea41fff25b7ccc8c1 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 15 Oct 2024 12:55:38 -0500 Subject: [PATCH 082/117] Remove unused method createEmptyPanel Deleted the createEmptyPanel method and its associated documentation from CampaignOptionsUtilities.java. Also removed references to this method in GeneralTab.java as it was no longer necessary. --- .../CampaignOptionsUtilities.java | 17 ----------------- .../gui/panes/campaignOptions/GeneralTab.java | 7 ++----- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java index 4c24511587..0ba633f483 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java @@ -252,23 +252,6 @@ static JPanel createStandardPanel(String name, boolean includeBorder, String bor return panel; } - - /** - * Creates an empty {@link JPanel} with the specified name and minimum width. - * This is used to occupy whitespace to stop GUI elements from getting overly spread out. - * Its inclusion is not ideal, but after a couple of days of throwing our heads against a wall, - * this was the best solution we could find. - * - * @param width the minimum width of the {@link JPanel} - * @return a new {@link JPanel} with the specified name and minimum width - */ - static JPanel createEmptyPanel(int width) { - JPanel panel = new JPanel(); - panel.setMinimumSize(UIUtil.scaleForGUI(width, 25)); - - return panel; - } - /** * Creates a {@link JPanel} consisting of a {@link JLabel} above an image. * If {@code includeBodyText} is {@code true} a second {@link JLabel} is placed after the first. diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java index ee2f04abe3..be0935a5e1 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java @@ -92,7 +92,6 @@ public AbstractMHQScrollablePanel createGeneralTab() { .randomMercenaryCompanyNameGenerator(campaign.getFlaggedCommander()))); createGeneralOptionsPanel = createGeneralOptionsPanel(); - JPanel emptyPanel = createEmptyPanel(0); // Camouflage lblCamo = createLabel("Camo"); @@ -131,8 +130,7 @@ public AbstractMHQScrollablePanel createGeneralTab() { .addComponent(txtName) .addComponent(btnNameGenerator)) .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(createGeneralOptionsPanel) - .addComponent(emptyPanel)) + .addComponent(createGeneralOptionsPanel)) .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(lblCamo) .addComponent(btnCamo) @@ -147,8 +145,7 @@ public AbstractMHQScrollablePanel createGeneralTab() { .addComponent(txtName) .addComponent(btnNameGenerator)) .addGroup(layout.createSequentialGroup() - .addComponent(createGeneralOptionsPanel) - .addComponent(emptyPanel)) + .addComponent(createGeneralOptionsPanel)) .addGroup(layout.createSequentialGroup() .addComponent(lblCamo) .addComponent(btnCamo) From a7f1c646367fecb3eaf14c40a6c9668510779e98 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 15 Oct 2024 18:32:54 -0500 Subject: [PATCH 083/117] Refactor UI element creation to use nested static classes Unified the creation of UI components like JCheckBox, JSpinner, JLabel, JTextField, and JButton into nested static classes. These changes streamline the code by encapsulating the creation logic within dedicated classes, improving readability and maintainability. Additionally, all resource fetching and tooltip handling are kept consistent across the various components. --- .../panes/campaignOptions/BiographyTab.java | 156 ++--- .../CampaignOptionsUtilities.java | 616 +++++++++--------- .../EquipmentAndSuppliesTab.java | 106 +-- .../panes/campaignOptions/FinancesTab.java | 106 +-- .../gui/panes/campaignOptions/GeneralTab.java | 288 ++++---- .../gui/panes/campaignOptions/MarketsTab.java | 94 +-- .../panes/campaignOptions/PersonnelTab.java | 200 +++--- .../campaignOptions/RelationshipsTab.java | 143 ++-- .../RepairAndMaintenanceTab.java | 54 +- .../panes/campaignOptions/RulesetsTab.java | 136 ++-- .../campaignOptions/SelectPresetDialog.java | 10 +- .../TurnoverAndRetentionTab.java | 132 ++-- 12 files changed, 1049 insertions(+), 992 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java index cc9f07436b..7ed9f89e9a 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java @@ -321,29 +321,29 @@ private static DefaultComboBoxModel getFactionNamesModel() { */ JPanel createGeneralTab() { // Header - JPanel headerPanel = createHeaderPanel("BiographyGeneralTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("BiographyGeneralTab", getImageDirectory() + "logo_federated_suns.png", true); // Contents - chkUseDylansRandomXP = createCheckBox("UseDylansRandomXP"); + chkUseDylansRandomXP = new CampaignOptionsCheckBox("UseDylansRandomXP"); - lblGender = createLabel("Gender"); + lblGender = new CampaignOptionsLabel("Gender"); sldGender = new JSlider(SwingConstants.HORIZONTAL, 0, 100, RandomGenderGenerator.getPercentFemale()); sldGender.setMajorTickSpacing(25); sldGender.setPaintTicks(true); sldGender.setPaintLabels(true); - lblNonBinaryDiceSize = createLabel("NonBinaryDiceSize"); - spnNonBinaryDiceSize = createSpinner("NonBinaryDiceSize", + lblNonBinaryDiceSize = new CampaignOptionsLabel("NonBinaryDiceSize"); + spnNonBinaryDiceSize = new CampaignOptionsSpinner("NonBinaryDiceSize", 60, 0, 100000, 1); - lblFamilyDisplayLevel = createLabel("FamilyDisplayLevel"); + lblFamilyDisplayLevel = new CampaignOptionsLabel("FamilyDisplayLevel"); pnlAnniversariesPanel = createAnniversariesPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("BiographyGeneralTab", true); + final JPanel panel = new CampaignOptionsStandardPanel("BiographyGeneralTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -390,13 +390,13 @@ JPanel createGeneralTab() { */ private JPanel createAnniversariesPanel() { // Contents - chkAnnounceBirthdays = createCheckBox("AnnounceBirthdays"); - chkAnnounceRecruitmentAnniversaries = createCheckBox("AnnounceRecruitmentAnniversaries"); - chkAnnounceOfficersOnly = createCheckBox("AnnounceOfficersOnly"); - chkAnnounceChildBirthdays = createCheckBox("AnnounceChildBirthdays"); + chkAnnounceBirthdays = new CampaignOptionsCheckBox("AnnounceBirthdays"); + chkAnnounceRecruitmentAnniversaries = new CampaignOptionsCheckBox("AnnounceRecruitmentAnniversaries"); + chkAnnounceOfficersOnly = new CampaignOptionsCheckBox("AnnounceOfficersOnly"); + chkAnnounceChildBirthdays = new CampaignOptionsCheckBox("AnnounceChildBirthdays"); // Layout the Panel - final JPanel panel = createStandardPanel("AnniversariesPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("AnniversariesPanel", true, "AnniversariesPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -425,19 +425,19 @@ private JPanel createAnniversariesPanel() { */ JPanel createBackgroundsTab() { // Header - JPanel headerPanel = createHeaderPanel("BackgroundsTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("BackgroundsTab", getImageDirectory() + "logo_clan_goliath_scorpion.png", true); // Contents - chkUseRandomPersonalities = createCheckBox("UseRandomPersonalities"); - chkUseRandomPersonalityReputation = createCheckBox("UseRandomPersonalityReputation"); - chkUseIntelligenceXpMultiplier = createCheckBox("UseIntelligenceXpMultiplier"); - chkUseSimulatedRelationships = createCheckBox("UseSimulatedRelationships"); + chkUseRandomPersonalities = new CampaignOptionsCheckBox("UseRandomPersonalities"); + chkUseRandomPersonalityReputation = new CampaignOptionsCheckBox("UseRandomPersonalityReputation"); + chkUseIntelligenceXpMultiplier = new CampaignOptionsCheckBox("UseIntelligenceXpMultiplier"); + chkUseSimulatedRelationships = new CampaignOptionsCheckBox("UseSimulatedRelationships"); pnlRandomOriginOptions = createRandomOriginOptionsPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("BackgroundsTab", true); + final JPanel panel = new CampaignOptionsStandardPanel("BackgroundsTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -471,11 +471,11 @@ JPanel createBackgroundsTab() { */ private JPanel createRandomOriginOptionsPanel() { // Contents - chkRandomizeOrigin = createCheckBox("RandomizeOrigin"); - chkRandomizeDependentsOrigin = createCheckBox("RandomizeDependentsOrigin"); - chkRandomizeAroundSpecifiedPlanet = createCheckBox("RandomizeAroundSpecifiedPlanet"); + chkRandomizeOrigin = new CampaignOptionsCheckBox("RandomizeOrigin"); + chkRandomizeDependentsOrigin = new CampaignOptionsCheckBox("RandomizeDependentsOrigin"); + chkRandomizeAroundSpecifiedPlanet = new CampaignOptionsCheckBox("RandomizeAroundSpecifiedPlanet"); - chkSpecifiedSystemFactionSpecific = createCheckBox("SpecifiedSystemFactionSpecific"); + chkSpecifiedSystemFactionSpecific = new CampaignOptionsCheckBox("SpecifiedSystemFactionSpecific"); chkSpecifiedSystemFactionSpecific.addActionListener(evt -> { final PlanetarySystem planetarySystem = comboSpecifiedSystem.getSelectedItem(); if ((planetarySystem == null) @@ -485,7 +485,7 @@ private JPanel createRandomOriginOptionsPanel() { }); - lblSpecifiedSystem = createLabel("SpecifiedSystem"); + lblSpecifiedSystem = new CampaignOptionsLabel("SpecifiedSystem"); comboSpecifiedSystem.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, @@ -507,7 +507,7 @@ public Component getListCellRendererComponent(final JList list, final Object } }); - lblSpecifiedPlanet = createLabel("SpecifiedPlanet"); + lblSpecifiedPlanet = new CampaignOptionsLabel("SpecifiedPlanet"); comboSpecifiedPlanet.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, @@ -521,19 +521,19 @@ public Component getListCellRendererComponent(final JList list, final Object } }); - lblOriginSearchRadius = createLabel("OriginSearchRadius"); - spnOriginSearchRadius = createSpinner("OriginSearchRadius", + lblOriginSearchRadius = new CampaignOptionsLabel("OriginSearchRadius"); + spnOriginSearchRadius = new CampaignOptionsSpinner("OriginSearchRadius", 0, 0, 2000, 25); - lblOriginDistanceScale = createLabel("OriginDistanceScale"); - spnOriginDistanceScale = createSpinner("OriginDistanceScale", + lblOriginDistanceScale = new CampaignOptionsLabel("OriginDistanceScale"); + spnOriginDistanceScale = new CampaignOptionsSpinner("OriginDistanceScale", 0.6, 0.1, 2.0, 0.1); - chkAllowClanOrigins = createCheckBox("AllowClanOrigins"); - chkExtraRandomOrigin = createCheckBox("ExtraRandomOrigin"); + chkAllowClanOrigins = new CampaignOptionsCheckBox("AllowClanOrigins"); + chkExtraRandomOrigin = new CampaignOptionsCheckBox("ExtraRandomOrigin"); // Layout the Panel - final JPanel panel = createStandardPanel("RandomOriginOptionsPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("RandomOriginOptionsPanel", true, "RandomOriginOptionsPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -648,14 +648,14 @@ private PlanetarySystem[] getPlanetarySystems(final @Nullable Faction faction) { */ JPanel createDeathTab() { // Header - JPanel headerPanel = createHeaderPanel("DeathTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("DeathTab", getImageDirectory() + "logo_filtvelt_coalition.png", true); // Contents - chkKeepMarriedNameUponSpouseDeath = createCheckBox("KeepMarriedNameUponSpouseDeath"); + chkKeepMarriedNameUponSpouseDeath = new CampaignOptionsCheckBox("KeepMarriedNameUponSpouseDeath"); - lblRandomDeathMethod = createLabel("RandomDeathMethod"); + lblRandomDeathMethod = new CampaignOptionsLabel("RandomDeathMethod"); comboRandomDeathMethod.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, @@ -669,18 +669,18 @@ public Component getListCellRendererComponent(final JList list, final Object } }); - chkUseRandomClanPersonnelDeath = createCheckBox("UseRandomClanPersonnelDeath"); - chkUseRandomPrisonerDeath = createCheckBox("UseRandomPrisonerDeath"); - chkUseRandomDeathSuicideCause = createCheckBox("UseRandomDeathSuicideCause"); + chkUseRandomClanPersonnelDeath = new CampaignOptionsCheckBox("UseRandomClanPersonnelDeath"); + chkUseRandomPrisonerDeath = new CampaignOptionsCheckBox("UseRandomPrisonerDeath"); + chkUseRandomDeathSuicideCause = new CampaignOptionsCheckBox("UseRandomDeathSuicideCause"); pnlDeathAgeGroup = createDeathAgeGroupsPanel(); - lblPercentageRandomDeathChance = createLabel("PercentageRandomDeathChance"); - spnPercentageRandomDeathChance = createSpinner("PercentageRandomDeathChance", + lblPercentageRandomDeathChance = new CampaignOptionsLabel("PercentageRandomDeathChance"); + spnPercentageRandomDeathChance = new CampaignOptionsSpinner("PercentageRandomDeathChance", 0, 0, 100, 0.000001); // Layout the Panel - final JPanel panel = createStandardPanel("DeathTab", true); + final JPanel panel = new CampaignOptionsStandardPanel("DeathTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -730,7 +730,7 @@ private JPanel createDeathAgeGroupsPanel() { final AgeGroup[] ageGroups = AgeGroup.values(); // Create the Panel - final JPanel panel = createStandardPanel("DeathAgeGroupsPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("DeathAgeGroupsPanel", true, "DeathAgeGroupsPanel"); panel.setLayout(new GridLayout(1, ageGroups.length)); @@ -764,33 +764,33 @@ private JPanel createDeathAgeGroupsPanel() { */ JPanel createEducationTab() { // Header - JPanel headerPanel = createHeaderPanel("EducationTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("EducationTab", getImageDirectory() + "logo_free_worlds_league.png", true); // Contents - chkUseEducationModule = createCheckBox("UseEducationModule"); + chkUseEducationModule = new CampaignOptionsCheckBox("UseEducationModule"); - lblCurriculumXpRate = createLabel("CurriculumXpRate"); - spnCurriculumXpRate = createSpinner("CurriculumXpRate", + lblCurriculumXpRate = new CampaignOptionsLabel("CurriculumXpRate"); + spnCurriculumXpRate = new CampaignOptionsSpinner("CurriculumXpRate", 3, 1, 10, 1); - lblMaximumJumpCount = createLabel("MaximumJumpCount"); - spnMaximumJumpCount = createSpinner("MaximumJumpCount", + lblMaximumJumpCount = new CampaignOptionsLabel("MaximumJumpCount"); + spnMaximumJumpCount = new CampaignOptionsSpinner("MaximumJumpCount", 5, 1, 200, 1); - chkUseReeducationCamps = createCheckBox("UseReeducationCamps"); + chkUseReeducationCamps = new CampaignOptionsCheckBox("UseReeducationCamps"); pnlEnableStandardSets = createEnableStandardSetsPanel(); - chkEnableOverrideRequirements = createCheckBox("EnableOverrideRequirements"); + chkEnableOverrideRequirements = new CampaignOptionsCheckBox("EnableOverrideRequirements"); - chkShowIneligibleAcademies = createCheckBox("ShowIneligibleAcademies"); + chkShowIneligibleAcademies = new CampaignOptionsCheckBox("ShowIneligibleAcademies"); - lblEntranceExamBaseTargetNumber = createLabel("EntranceExamBaseTargetNumber"); - spnEntranceExamBaseTargetNumber = createSpinner("EntranceExamBaseTargetNumber", + lblEntranceExamBaseTargetNumber = new CampaignOptionsLabel("EntranceExamBaseTargetNumber"); + spnEntranceExamBaseTargetNumber = new CampaignOptionsSpinner("EntranceExamBaseTargetNumber", 14, 0, 20, 1); - lblEntranceExamBaseTargetNumberPost = createLabel("EntranceExamBaseTargetNumberPost"); + lblEntranceExamBaseTargetNumberPost = new CampaignOptionsLabel("EntranceExamBaseTargetNumberPost"); pnlXpAndSkillBonuses = createXpAndSkillBonusesPanel(); @@ -799,7 +799,7 @@ JPanel createEducationTab() { pnlAccidentsAndEvents = createAccidentsAndEventsPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("EducationTab", true); + final JPanel panel = new CampaignOptionsStandardPanel("EducationTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -869,12 +869,12 @@ JPanel createEducationTab() { */ private JPanel createEnableStandardSetsPanel() { // Contents - chkEnableLocalAcademies = createCheckBox("EnableLocalAcademies"); - chkEnablePrestigiousAcademies = createCheckBox("EnablePrestigiousAcademies"); - chkEnableUnitEducation = createCheckBox("EnableUnitEducation"); + chkEnableLocalAcademies = new CampaignOptionsCheckBox("EnableLocalAcademies"); + chkEnablePrestigiousAcademies = new CampaignOptionsCheckBox("EnablePrestigiousAcademies"); + chkEnableUnitEducation = new CampaignOptionsCheckBox("EnableUnitEducation"); // Layout the Panel - final JPanel panel = createStandardPanel("EnableStandardSetsPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("EnableStandardSetsPanel", true, "EnableStandardSetsPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -911,13 +911,13 @@ private JPanel createEnableStandardSetsPanel() { */ private JPanel createXpAndSkillBonusesPanel() { // Contents - chkEnableBonuses = createCheckBox("EnableBonuses"); - lblFacultyXpMultiplier = createLabel("FacultyXpMultiplier"); - spnFacultyXpMultiplier = createSpinner("FacultyXpMultiplier", + chkEnableBonuses = new CampaignOptionsCheckBox("EnableBonuses"); + lblFacultyXpMultiplier = new CampaignOptionsLabel("FacultyXpMultiplier"); + spnFacultyXpMultiplier = new CampaignOptionsSpinner("FacultyXpMultiplier", 1.00, 0.00, 10.00, 0.01); // Layout the Panel - final JPanel panel = createStandardPanel("XpAndSkillBonusesPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("XpAndSkillBonusesPanel", true, "XpAndSkillBonusesPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -953,15 +953,15 @@ private JPanel createXpAndSkillBonusesPanel() { */ private JPanel createDropoutChancePanel() { // Contents - lblAdultDropoutChance = createLabel("AdultDropoutChance"); - spnAdultDropoutChance = createSpinner("AdultDropoutChance", + lblAdultDropoutChance = new CampaignOptionsLabel("AdultDropoutChance"); + spnAdultDropoutChance = new CampaignOptionsSpinner("AdultDropoutChance", 1000, 0, 100000, 1); - lblChildrenDropoutChance = createLabel("ChildrenDropoutChance"); - spnChildrenDropoutChance = createSpinner("ChildrenDropoutChance", + lblChildrenDropoutChance = new CampaignOptionsLabel("ChildrenDropoutChance"); + spnChildrenDropoutChance = new CampaignOptionsSpinner("ChildrenDropoutChance", 10000, 0, 100000, 1); // Layout the Panel - final JPanel panel = createStandardPanel("DropoutChancePanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("DropoutChancePanel", true, "DropoutChancePanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -1003,13 +1003,13 @@ private JPanel createDropoutChancePanel() { */ private JPanel createAccidentsAndEventsPanel() { // Contents - chkAllAges = createCheckBox("AllAges"); - lblMilitaryAcademyAccidents = createLabel("MilitaryAcademyAccidents"); - spnMilitaryAcademyAccidents = createSpinner("MilitaryAcademyAccidents", + chkAllAges = new CampaignOptionsCheckBox("AllAges"); + lblMilitaryAcademyAccidents = new CampaignOptionsLabel("MilitaryAcademyAccidents"); + spnMilitaryAcademyAccidents = new CampaignOptionsSpinner("MilitaryAcademyAccidents", 10000, 0, 100000, 1); // Layout the Panel - final JPanel panel = createStandardPanel("AccidentsAndEventsPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("AccidentsAndEventsPanel", true, "AccidentsAndEventsPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -1047,21 +1047,21 @@ private JPanel createAccidentsAndEventsPanel() { */ JPanel createNameAndPortraitGenerationTab() { // Header - JPanel headerPanel = createHeaderPanel("NameAndPortraitGenerationTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("NameAndPortraitGenerationTab", getImageDirectory() + "logo_clan_mongoose.png", true); // Contents - chkUseOriginFactionForNames = createCheckBox("UseOriginFactionForNames"); + chkUseOriginFactionForNames = new CampaignOptionsCheckBox("UseOriginFactionForNames"); - lblFactionNames = createLabel("FactionNames"); + lblFactionNames = new CampaignOptionsLabel("FactionNames"); pnlRandomPortrait = createRandomPortraitPanel(); - chkAssignPortraitOnRoleChange = createCheckBox("AssignPortraitOnRoleChange"); + chkAssignPortraitOnRoleChange = new CampaignOptionsCheckBox("AssignPortraitOnRoleChange"); // Layout the Panel - final JPanel panel = createStandardPanel("NameAndPortraitGenerationTab", true, + final JPanel panel = new CampaignOptionsStandardPanel("NameAndPortraitGenerationTab", true, ""); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -1179,7 +1179,7 @@ private JPanel createRandomPortraitPanel() { */ JPanel createRankTab() { // Header - JPanel headerPanel = createHeaderPanel("RankTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("RankTab", getImageDirectory() + "logo_hanseatic_league.png", true); @@ -1188,7 +1188,7 @@ JPanel createRankTab() { Component rankSystemsViewport = rankSystemsPane.getViewport().getView(); // Layout the Panel - final JPanel panel = createStandardPanel("RankTab", true, + final JPanel panel = new CampaignOptionsStandardPanel("RankTab", true, ""); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java index 0ba633f483..0a54a7479d 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java @@ -1,13 +1,10 @@ package mekhq.gui.panes.campaignOptions; -import megamek.client.ui.swing.util.FlatLafStyleBuilder; import megamek.client.ui.swing.util.UIUtil; import megamek.common.annotations.Nullable; -import mekhq.MHQConstants; import javax.swing.*; import javax.swing.GroupLayout.Alignment; -import javax.swing.JSpinner.DefaultEditor; import java.awt.*; import java.util.ArrayList; import java.util.List; @@ -15,6 +12,7 @@ import java.util.ResourceBundle; import static megamek.client.ui.WrapLayout.wordWrap; +import static megamek.client.ui.swing.util.FlatLafStyleBuilder.setFontScaling; public class CampaignOptionsUtilities { private static final String RESOURCE_PACKAGE = "mekhq/resources/NEWCampaignOptionsDialog"; @@ -28,298 +26,339 @@ static String getImageDirectory() { return IMAGE_DIRECTORY; } - static JCheckBox createCheckBox(String name) { - return createCheckBox(name, null); - } - /** - * Returns a new {@link JCheckBox} object. - *

- * The {@link JCheckBox} will be named {@code "chk" + name}, and use the following resource bundle references: - * {@code "lbl" + name + ".text"} and {@code "lbl" + name + ".tooltip"}. - * - * @param name the name of the checkbox - * @param customWrapSize the maximum number of characters (including whitespaces) on each - * line of the tooltip (or 100, if {@code null}). - * @return a new {@link JCheckBox} object with the specified name, label, and tooltip + * This class provides a custom {@link JCheckBox} for campaign options. + * The checkbox name and tooltips are fetched from a resource bundle based on the provided name. */ - static JCheckBox createCheckBox(String name, @Nullable Integer customWrapSize) { - customWrapSize = processWrapSize(customWrapSize); - - JCheckBox checkBox = new JCheckBox(String.format("%s", - resources.getString("lbl" + name + ".text"))); - checkBox.setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), customWrapSize)); - checkBox.setName("chk" + name); - - setFontScaling(checkBox, false, 1); - - return checkBox; - } + static class CampaignOptionsCheckBox extends JCheckBox { + /** + * Returns a new {@link JCheckBox} object. + *

+ * The {@link JCheckBox} will be named {@code "chk" + name}, and use the following resource + * bundle references: {@code "lbl" + name + ".text"} and {@code "lbl" + name + ".tooltip"}. + * + * @param name the name of the checkbox + */ + public CampaignOptionsCheckBox(String name) { + this(name, null); + } - /** - * Creates a {@link JSpinner} object. - *

- * The name of the {@link JSpinner} will be {@code "spn" + name}, - * and it will use the {@code "lbl" + name + ".tooltip"} resource bundle item - * - * @param name a string representing the name of the objects. - * @param defaultValue The default value of the spinner - * @param minimum The minimum value of the spinner - * @param maximum The maximum value of the spinner - * @param stepSize The step size of the spinner - * @return The created {@link JSpinner}. - */ - static JSpinner createSpinner(String name, double defaultValue, double minimum, double maximum, - double stepSize) { - return createSpinner(name, null, defaultValue, minimum, maximum, stepSize); + /** + * Returns a new {@link JCheckBox} object with a custom wrap size. + *

+ * The {@link JCheckBox} will be named {@code "chk" + name}, and use the following resource + * bundle references: {@code "lbl" + name + ".text"} and {@code "lbl" + name + ".tooltip"}. + * + * @param name the name of the checkbox + * @param customWrapSize the maximum number of characters (including whitespaces) on each + * line of the tooltip (or 100, if {@code null}). + */ + public CampaignOptionsCheckBox(String name, @Nullable Integer customWrapSize) { + super(String.format("%s", resources.getString("lbl" + name + ".text"))); + setName("chk" + name); + setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), + processWrapSize(customWrapSize))); + + setFontScaling(this, false, 1); + } } /** - * Creates a {@link JSpinner} object. - *

- * The name of the {@link JSpinner} will be {@code "spn" + name}, - * and it will use the {@code "lbl" + name + ".tooltip"} resource bundle item - * - * @param name a string representing the name of the objects. - * @param customWrapSize the maximum number of characters (including whitespaces) on each - * line of the tooltip (or 100, if {@code null}). - * @param defaultValue The default value of the spinner - * @param minimum The minimum value of the spinner - * @param maximum The maximum value of the spinner - * @param stepSize The step size of the spinner - * @return The created {@link JSpinner}. + * This class provides a custom {@link JSpinner} for campaign options. + * The spinner name and tooltips are fetched from a resource bundle based on the provided name. */ - static JSpinner createSpinner(String name, @Nullable Integer customWrapSize, double defaultValue, - double minimum, double maximum, double stepSize) { - customWrapSize = processWrapSize(customWrapSize); - - JSpinner jSpinner = new JSpinner(); - jSpinner.setModel(new SpinnerNumberModel(defaultValue, minimum, maximum, stepSize)); - jSpinner.setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), customWrapSize)); - jSpinner.setName("spn" + name); - - setFontScaling(jSpinner, false, 1); - - DefaultEditor editor = (DefaultEditor) jSpinner.getEditor(); - editor.getTextField().setHorizontalAlignment(JTextField.LEFT); - - return jSpinner; - } + static class CampaignOptionsSpinner extends JSpinner { + /** + * Creates a {@link JSpinner} object. + *

+ * The name of the {@link JSpinner} will be {@code "spn" + name}, + * and it will use the {@code "lbl" + name + ".tooltip"} resource bundle item + * + * @param name a string representing the name of the objects. + * @param defaultValue The default value of the spinner + * @param minimum The minimum value of the spinner + * @param maximum The maximum value of the spinner + * @param stepSize The step size of the spinner + */ + public CampaignOptionsSpinner(String name, double defaultValue, double minimum, double maximum, + double stepSize) { + this(name, null, defaultValue, minimum, maximum, stepSize); + } - /** - * Creates a {@link JLabel} with the specified name and optional customWrapSize. - *

- * Please note that 'name' is also used to fetch the resources associated with this label. - * For the label text 'name' is appended by '.text'. - * For the label tooltip 'name' is appended with '.tooltip'. - * These values must exist in the resource bundle otherwise an error will be thrown. - * - * @param name the name of the label - * @return a new {@link JLabel} object - */ - static JLabel createLabel(String name) { - return createLabel(name, null); + /** + * Creates a {@link JSpinner} object with a custom wrap width. + *

+ * The name of the {@link JSpinner} will be {@code "spn" + name}, + * and it will use the {@code "lbl" + name + ".tooltip"} resource bundle item + * + * @param name a string representing the name of the objects. + * @param customWrapSize the maximum number of characters (including whitespaces) on each + * line of the tooltip (or 100, if {@code null}). + * @param defaultValue The default value of the spinner + * @param minimum The minimum value of the spinner + * @param maximum The maximum value of the spinner + * @param stepSize The step size of the spinner + */ + public CampaignOptionsSpinner(String name, @Nullable Integer customWrapSize, double defaultValue, + double minimum, double maximum, double stepSize) { + super(new SpinnerNumberModel(defaultValue, minimum, maximum, stepSize)); + setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), + processWrapSize(customWrapSize))); + setName("spn" + name); + + setFontScaling(this, false, 1); + + DefaultEditor editor = (DefaultEditor) this.getEditor(); + editor.getTextField().setHorizontalAlignment(JTextField.LEFT); + } } /** - * Creates a {@link JLabel} with the specified name and optional customWrapSize. - *

- * Please note that 'name' is also used to fetch the resources associated with this label. - * For the label text 'name' is appended by '.text'. - * For the label tooltip 'name' is appended with '.tooltip'. - * These values must exist in the resource bundle otherwise an error will be thrown. - * - * @param name the name of the label - * @param customWrapSize the maximum number of characters (including whitespaces) on each line - * of the tooltip; defaults to 100 if {@code null} - * @return a new {@link JLabel} object + * This class provides a custom {@link JLabel} for campaign options. + * The label name and tooltips are fetched from a resource bundle based on the provided name. */ - static JLabel createLabel(String name, @Nullable Integer customWrapSize) { - customWrapSize = processWrapSize(customWrapSize); - - JLabel jLabel = new JLabel(String.format("%s", - resources.getString("lbl" + name + ".text"))); - jLabel.setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), customWrapSize)); - jLabel.setName("lbl" + name); - - setFontScaling(jLabel, false, 1); + static class CampaignOptionsLabel extends JLabel { + /** + * Creates a {@link JLabel} with the specified name. + *

+ * Please note that 'name' is also used to fetch the resources associated with this label. + * For the label text 'name' is appended by '.text'. + * For the label tooltip 'name' is appended with '.tooltip'. + * These values must exist in the resource bundle otherwise an error will be thrown. + * + * @param name the name of the label + */ + public CampaignOptionsLabel(String name) { + this(name, null); + } - return jLabel; + /** + * Creates a {@link JLabel} with the specified name and optional customWrapSize. + *

+ * Please note that 'name' is also used to fetch the resources associated with this label. + * For the label text 'name' is appended by '.text'. + * For the label tooltip 'name' is appended with '.tooltip'. + * These values must exist in the resource bundle otherwise an error will be thrown. + * + * @param name the name of the label + * @param customWrapSize the maximum number of characters (including whitespaces) on each line + * of the tooltip; defaults to 100 if {@code null} + */ + public CampaignOptionsLabel(String name, @Nullable Integer customWrapSize) { + super(String.format("%s", + resources.getString("lbl" + name + ".text"))); + setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), + processWrapSize(customWrapSize))); + setName("lbl" + name); + + setFontScaling(this, false, 1); + } } /** - * Creates a {@link JTextField} object. - *

- * The name of the {@link JTextField} will be {@code}, and it will use the following resource bundle reference: - * {@code "lbl" + name + ".tooltip"}. - * - * @param name the name of the object. - * @param width The width of the {@link JTextField}. - * @return a map containing a {@link JLabel} key and a {@link JTextField} value. + * This class provides a custom {@link JTextField} for campaign options. + * The text field name and tooltips are fetched from a resource bundle based on the provided name. */ - static JTextField createTextField(String name, int width) { - return createTextField(name, null, width); - } - - /** - * Creates a {@link JTextField} object. - *

- * The name of the {@link JTextField} will be {@code}, and it will use the following resource bundle reference: - * {@code "lbl" + name + ".tooltip"}. - * - * @param name the name of the object. - * @param customWrapSize the maximum number of characters (including whitespaces) on each - * line of the tooltip. - * If {@code null}, the default wrap size of 100 is used. - * @param width The width of the {@link JTextField}. - * @return a map containing a {@link JLabel} key and a {@link JTextField} value. - */ - static JTextField createTextField(String name, @Nullable Integer customWrapSize, int width) { - customWrapSize = processWrapSize(customWrapSize); - - JTextField jTextField = new JTextField(); - jTextField.setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), customWrapSize)); - jTextField.setName("txt" + name); - - Dimension size = jTextField.getPreferredSize(); - jTextField.setMinimumSize(UIUtil.scaleForGUI(width, size.height)); - jTextField.setMaximumSize(UIUtil.scaleForGUI(width, size.height)); - - setFontScaling(jTextField, false, 1); + static class CampaignOptionsTextField extends JTextField { + /** + * Creates a {@link JTextField} object. + *

+ * The name of the {@link JTextField} will be {@code}, and it will use the following resource + * bundle reference: {@code "lbl" + name + ".tooltip"}. + * + * @param name the name of the object. + */ + public CampaignOptionsTextField(String name) { + this(name, null); + } - return jTextField; + /** + * Creates a {@link JTextField} object with a custom word wrap width. + *

+ * The name of the {@link JTextField} will be {@code}, and it will use the following resource + * bundle reference: {@code "lbl" + name + ".tooltip"}. + * + * @param name the name of the object. + * @param customWrapSize the maximum number of characters (including whitespaces) on each + * line of the tooltip. + * If {@code null}, the default wrap size of 100 is used. + */ + public CampaignOptionsTextField(String name, @Nullable Integer customWrapSize) { + super(); + setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), + processWrapSize(customWrapSize))); + setName("lbl" + name); + + setFontScaling(this, false, 1); + } } /** - * Returns the maximum number of characters on each line of a tooltip. - * If a custom wrap size is provided, it is returned. - * Otherwise, the default wrap size of 100 is returned. - * - * @param customWrapSize the maximum number of characters (including whitespaces) on each line - * of the tooltip, or {@code null} if no custom wrap size is specified - * @return the maximum number of characters on each line of a tooltip + * This class provides a custom {@link JButton} for campaign options. + * The button name and tooltips are fetched from a resource bundle based on the provided name. */ - private static int processWrapSize(@Nullable Integer customWrapSize) { - return customWrapSize == null ? 100 : customWrapSize; - } + static class CampaignOptionsButton extends JButton { + /** + * Creates a new {@link JButton}. + *

+ * The name of the created {@link JButton} is {@code "btn" + name} + * The resource bundle references for the created {@link JButton} are {@code "lbl" + name + ".text"} + * and {@code "lbl" + name + ".tooltip"}. + * + * @param name the name of the button, used to generate the button's name and resource bundle references + */ + public CampaignOptionsButton(String name) { + this(name, null); + } - /** - * Creates a standard {@link JPanel} with a titled border. - *

- * {@code createStandardLayout} should also be called and the resulting {@link GroupLayout} - * assigned to the panel via {@code setLayout}. - *

- * If {@code borderTitle} isn't empty the resource bundle reference, used to fetch the border's - * title, will be {@code "lbl" + borderTitle + ".text"} - * - * @param name the name of the panel. - * @param includeBorder whether the panel should have a border. - * - * @return a {@link JPanel} with a titled border and {@link GroupLayout} as its layout manager - */ - static JPanel createStandardPanel(String name, boolean includeBorder) { - return createStandardPanel(name, includeBorder, ""); + /** + * Creates a new {@link JButton} with a custom tooltip wrap size. + *

+ * The name of the created {@link JButton} is {@code "btn" + name} + * The resource bundle references for the created {@link JButton} are {@code "lbl" + name + ".text"} + * and {@code "lbl" + name + ".tooltip"}. + * + * @param name the name of the button, used for text and tooltip generation + * @param customWrapSize the maximum number of characters for line wrapping in the tooltip, + * or {@code null} if the default wrap size is to be used + */ + public CampaignOptionsButton(String name, @Nullable Integer customWrapSize) { + super(resources.getString("lbl" + name + ".text")); + setToolTipText(wordWrap(resources.getString("lbl" + name + ".tooltip"), + processWrapSize(customWrapSize))); + setName("btn" + name); + + setFontScaling(this, false, 1); + } } /** - * Creates a standard {@link JPanel} with a titled border. - *

- * {@code createStandardLayout} should also be called and the resulting {@link GroupLayout} - * assigned to the panel via {@code setLayout}. - *

- * If {@code borderTitle} isn't empty the resource bundle reference, used to fetch the border's - * title, will be {@code "lbl" + borderTitle + ".text"} - * - * @param name the name of the panel. - * @param includeBorder whether the panel should have a border. - * @param borderTitle The resource string that should be used as the title of the border. - * Can be empty to generate an untitled border. - * - * @return a {@link JPanel} with a titled border and {@link GroupLayout} as its layout manager + * This class provides a custom {@link JPanel} for campaign options. + * Offers an optional untitled border, and the panel name is set to "pnl" + name. */ - static JPanel createStandardPanel(String name, boolean includeBorder, String borderTitle) { - borderTitle = borderTitle.isBlank() ? "" : resources.getString("lbl" + borderTitle + ".text"); - - JPanel panel = new JPanel(); - - if (includeBorder) { - panel.setBorder(BorderFactory.createTitledBorder( - String.format(String.format("%s", borderTitle)))); + static class CampaignOptionsStandardPanel extends JPanel { + /** + * Creates a standardized {@link JPanel} with an untitled border. + *

+ * {@code createStandardLayout} should also be called and the resulting {@link GroupLayout} + * assigned to the panel via {@code setLayout}. + *

+ * If {@code borderTitle} isn't empty the resource bundle reference, used to fetch the border's + * title, will be {@code "lbl" + borderTitle + ".text"} + * + * @param name the name of the panel. + * @param includeBorder whether the panel should have a border. + */ + public CampaignOptionsStandardPanel(String name, boolean includeBorder) { + this(name, includeBorder, ""); } - panel.setName(name); + /** + * Creates a standardized {@link JPanel} with a titled border. + *

+ * {@code createStandardLayout} should also be called and the resulting {@link GroupLayout} + * assigned to the panel via {@code setLayout}. + *

+ * If {@code borderTitle} isn't empty the resource bundle reference, used to fetch the border's + * title, will be {@code "lbl" + borderTitle + ".text"} + * + * @param name the name of the panel. + * @param includeBorder whether the panel should have a border. + */ + public CampaignOptionsStandardPanel(String name, boolean includeBorder, String borderTitle) { + borderTitle = borderTitle.isBlank() ? "" : resources.getString("lbl" + borderTitle + ".text"); + + JPanel panel = new JPanel() { + @Override + public Dimension getPreferredSize() { + Dimension standardSize = super.getPreferredSize(); + return UIUtil.scaleForGUI((Math.max(standardSize.width, 500)), standardSize.height); + } + }; + + if (includeBorder) { + panel.setBorder(BorderFactory.createTitledBorder( + String.format(String.format("%s", borderTitle)))); + } - return panel; + panel.setName("pnl" + name); + } } /** - * Creates a {@link JPanel} consisting of a {@link JLabel} above an image. - * If {@code includeBodyText} is {@code true} a second {@link JLabel} is placed after the first. - *

- * The {@link JPanel} will be named {@code "pnl" + name + "HeaderPanel"}. - * The resource bundle references for the first {@link JLabel} will be {@code "lbl" + name + ".text"}. - * The optional second {@link JLabel} is assigned the name {@code ""lbl" + name + "Body"} - * and uses the following resource bundle reference: {@code "lbl" + name + "Body.text"}. - * - * @param name the name of the header panel. - * @param imageAddress the file path of the image to be displayed in the panel - * @param includeBodyText if {@code true}, include a second {@link JLabel}. - * @return a {@link JPanel} representing the header panel + * This class provides a custom {@link JPanel} for campaign options, consisting of a label and an image. + * The panel, label and optional body label names are set based on the provided name parameter. + * The text for the label(s) is fetched from a resource bundle. */ - static JPanel createHeaderPanel(String name, String imageAddress, boolean includeBodyText) { - // Fetch and scale image - ImageIcon imageIcon = new ImageIcon(imageAddress); - - int width = UIUtil.scaleForGUI(imageIcon.getIconWidth()); - int height = UIUtil.scaleForGUI(imageIcon.getIconHeight()); - - Image image = imageIcon.getImage(); - Image scaledImage = image.getScaledInstance(width, height, Image.SCALE_SMOOTH); - - imageIcon = new ImageIcon(scaledImage); - - JLabel imageLabel = new JLabel(imageIcon); - - // Create header text - final JLabel lblHeader = new JLabel(resources.getString("lbl" + name + ".text"), SwingConstants.CENTER); - lblHeader.setName("lbl" + name); - setFontScaling(lblHeader, true, 2); - - // Create body text - JLabel lblBody = new JLabel(); - if (includeBodyText) { - lblBody = new JLabel(String.format("

%s

", - resources.getString("lbl" + name + "Body.text")), SwingConstants.CENTER); - lblBody.setName("lbl" + name + "Body"); - setFontScaling(lblBody, false, 1); - Dimension size = lblBody.getPreferredSize(); - lblBody.setMaximumSize(UIUtil.scaleForGUI(750, size.height)); + static class CampaignOptionsHeaderPanel extends JPanel { + /** + * Creates a {@link JPanel} consisting of a {@link JLabel} above an image. + *

+ * The {@link JPanel} will be named {@code "pnl" + name + "HeaderPanel"}. + * The resource bundle references for the {@link JLabel} will be {@code "lbl" + name + ".text"}. + * + * @param name the name of the header panel. + * @param imageAddress the file path of the image to be displayed in the panel + */ + public CampaignOptionsHeaderPanel(String name, String imageAddress) { + this(name, imageAddress, false); } - // Layout panel - final JPanel panel = createStandardPanel("pnl" + name + "HeaderPanel", false, ""); - final GroupLayout layout = createStandardLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(lblHeader) - .addComponent(lblBody) - .addComponent(imageLabel)); + /** + * Creates a {@link JPanel} consisting of a {@link JLabel} above an image. + * If {@code includeBodyText} is {@code true} a second {@link JLabel} is placed after the first. + *

+ * The {@link JPanel} will be named {@code "pnl" + name + "HeaderPanel"}. + * The resource bundle references for the first {@link JLabel} will be {@code "lbl" + name + ".text"}. + * The optional second {@link JLabel} is assigned the name {@code ""lbl" + name + "Body"} + * and uses the following resource bundle reference: {@code "lbl" + name + "Body.text"}. + * + * @param name the name of the header panel. + * @param imageAddress the file path of the image to be displayed in the panel + * @param includeBodyText if {@code true}, include a second {@link JLabel}. + */ + public CampaignOptionsHeaderPanel(String name, String imageAddress, boolean includeBodyText) { + // Fetch and scale image + ImageIcon imageIcon = new ImageIcon(imageAddress); + + int width = UIUtil.scaleForGUI(imageIcon.getIconWidth()); + int height = UIUtil.scaleForGUI(imageIcon.getIconHeight()); + + Image image = imageIcon.getImage(); + Image scaledImage = image.getScaledInstance(width, height, Image.SCALE_SMOOTH); + + imageIcon = new ImageIcon(scaledImage); + + JLabel imageLabel = new JLabel(imageIcon); + + // Create header text + final JLabel lblHeader = new JLabel(resources.getString("lbl" + name + ".text"), SwingConstants.CENTER); + lblHeader.setName("lbl" + name); + setFontScaling(lblHeader, true, 2); + + JLabel lblBody = new JLabel(); + if (includeBodyText) { + lblBody = new JLabel(String.format("

%s

", + resources.getString("lbl" + name + "Body.text")), SwingConstants.CENTER); + lblBody.setName("lbl" + name + "Body"); + setFontScaling(lblBody, false, 1); + } - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.CENTER) - .addComponent(lblHeader) - .addComponent(lblBody) - .addComponent(imageLabel)); + // Layout panel + final JPanel panel = new CampaignOptionsStandardPanel("pnl" + name + "HeaderPanel", + false); + panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); - return panel; + panel.add(lblHeader); + panel.add(lblBody); + panel.add(imageLabel); + } } /** * Creates a {@link GroupLayout} object for the specified {@link JPanel}. *

- * Written to be paired with {@code createStandardPanel}. + * Written to be paired with {@code new CampaignOptionsStandardPanel}. * * @param panel the {@link JPanel} for which the {@link GroupLayout} is created * @return the created {@link GroupLayout} object @@ -341,32 +380,19 @@ static GroupLayout createStandardLayout(JPanel panel) { */ static JPanel createParentPanel(JPanel panel, String name) { // Create Panel - final JPanel parentPanel = createStandardPanel(name, false); - - // Set Dimensions - int widthNew = parentPanel.getMinimumSize().width; - - if (widthNew < UIUtil.scaleForGUI(750)) { - widthNew = UIUtil.scaleForGUI(750); - } - - int height = parentPanel.getPreferredSize().height; - for (Component component : panel.getComponents()) { - if (component instanceof JPanel) { - height += component.getPreferredSize().height; - } - } - - Dimension size = new Dimension(widthNew, height); - parentPanel.setMinimumSize(UIUtil.scaleForGUI(size.width, size.height)); - parentPanel.setMaximumSize(UIUtil.scaleForGUI(size.width, size.height)); + final JPanel parentPanel = new CampaignOptionsStandardPanel(name, false); + final GroupLayout parentLayout = createStandardLayout(parentPanel); // Layout - parentPanel.setLayout(new BoxLayout(parentPanel, BoxLayout.Y_AXIS)); + parentPanel.setLayout(parentLayout); - parentPanel.add(Box.createVerticalGlue()); - parentPanel.add(panel); - parentPanel.add(Box.createVerticalGlue()); + parentLayout.setVerticalGroup( + parentLayout.createSequentialGroup() + .addComponent(panel)); + + parentLayout.setHorizontalGroup( + parentLayout.createParallelGroup(Alignment.CENTER) + .addComponent(panel)); return parentPanel; } @@ -410,7 +436,6 @@ static JTabbedPane createSubTabs(Map panels) { JLabel quote = new JLabel(String.format( "

%s
", UIUtil.scaleForGUI(650), resources.getString(tabName + ".border"))); - setFontScaling(quote, false, 1); GridBagConstraints quoteConstraints = new GridBagConstraints(); quoteConstraints.gridx = GridBagConstraints.RELATIVE; @@ -447,38 +472,15 @@ static JTabbedPane createSubTabs(Map panels) { } /** - * Creates a new {@link JButton}. - *

- * The name of the created {@link JButton} is {@code "btn" + name} - * The resource bundle references for the created {@link JButton} are {@code "lbl" + name + ".text"} - * and {@code "lbl" + name + ".tooltip"}. - * - * @param name the name of the button, used to generate the button's name and resource bundle references - * @return a new {@link JButton} object - */ - static JButton createButton(String name) { - JButton jButton = new JButton(resources.getString("lbl" + name + ".text")); - jButton.setToolTipText(resources.getString("lbl" + name + ".tooltip")); - jButton.setName("btn" + name); - - setFontScaling(jButton, false, 1); - - return jButton; - } - - /** - * Applies font scaling to a given {@link JComponent}. + * Returns the maximum number of characters on each line of a tooltip. + * If a custom wrap size is provided, it is returned. + * Otherwise, the default wrap size of 100 is returned. * - * @param component The JComponent to which the font scaling is applied. - * @param boldText A boolean that sets whether the text should be bolded. - * If {@code true}, the text will be bolded, else, it will be regular. - * @param size A double representing the size of the font to be set. + * @param customWrapSize the maximum number of characters (including whitespaces) on each line + * of the tooltip, or {@code null} if no custom wrap size is specified + * @return the maximum number of characters on each line of a tooltip */ - static void setFontScaling(JComponent component, boolean boldText, double size) { - if (boldText) { - new FlatLafStyleBuilder().font(MHQConstants.PROJECT_NAME).bold().size(size).apply(component); - } else { - new FlatLafStyleBuilder().font(MHQConstants.PROJECT_NAME).size(size).apply(component); - } + private static int processWrapSize(@Nullable Integer customWrapSize) { + return customWrapSize == null ? 100 : customWrapSize; } } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java index f05a28942b..af943c4d9e 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java @@ -215,37 +215,37 @@ private void initializeTechLimitsTab() { */ JPanel createAcquisitionTab() { // Header - JPanel headerPanel = createHeaderPanel("AcquisitionTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("AcquisitionTab", getImageDirectory() + "logo_calderon_protectorate.png", true); // Acquisitions skill - lblChoiceAcquireSkill = createLabel("ChoiceAcquireSkill"); + lblChoiceAcquireSkill = new CampaignOptionsLabel("ChoiceAcquireSkill"); // Support personnel only - chkSupportStaffOnly = createCheckBox("SupportStaffOnly"); + chkSupportStaffOnly = new CampaignOptionsCheckBox("SupportStaffOnly"); // Clan Acquisition penalty - lblAcquireClanPenalty = createLabel("AcquireClanPenalty"); - spnAcquireClanPenalty = createSpinner("AcquireClanPenalty", + lblAcquireClanPenalty = new CampaignOptionsLabel("AcquireClanPenalty"); + spnAcquireClanPenalty = new CampaignOptionsSpinner("AcquireClanPenalty", 0, 0, 13, 1); // IS Acquisition penalty - lblAcquireIsPenalty = createLabel("AcquireISPenalty"); - spnAcquireIsPenalty = createSpinner("AcquireISPenalty", + lblAcquireIsPenalty = new CampaignOptionsLabel("AcquireISPenalty"); + spnAcquireIsPenalty = new CampaignOptionsSpinner("AcquireISPenalty", 0, 0, 13, 1); // Waiting Period - lblAcquireWaitingPeriod = createLabel("AcquireWaitingPeriod"); - spnAcquireWaitingPeriod = createSpinner("AcquireWaitingPeriod", + lblAcquireWaitingPeriod = new CampaignOptionsLabel("AcquireWaitingPeriod"); + spnAcquireWaitingPeriod = new CampaignOptionsSpinner("AcquireWaitingPeriod", 1, 1, 365, 1); // Maximum Acquisitions - lblMaxAcquisitions = createLabel("MaxAcquisitions"); - spnMaxAcquisitions = createSpinner("MaxAcquisitions", + lblMaxAcquisitions = new CampaignOptionsLabel("MaxAcquisitions"); + spnMaxAcquisitions = new CampaignOptionsSpinner("MaxAcquisitions", 0,0, 100, 1); // Layout the Panel - final JPanel panel = createStandardPanel("acquisitionTab", true); + final JPanel panel = new CampaignOptionsStandardPanel("acquisitionTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -295,7 +295,7 @@ JPanel createAcquisitionTab() { JPanel createPlanetaryAcquisitionTab() { // Header - JPanel headerPanel = createHeaderPanel("PlanetaryAcquisitionTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("PlanetaryAcquisitionTab", getImageDirectory() + "logo_capellan_confederation.png", true); // Sub-Panels @@ -303,7 +303,7 @@ JPanel createPlanetaryAcquisitionTab() { JPanel modifiers = createModifiersPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("PlanetaryAcquisitionTab", true); + final JPanel panel = new CampaignOptionsStandardPanel("PlanetaryAcquisitionTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -334,29 +334,29 @@ JPanel createPlanetaryAcquisitionTab() { */ private JPanel createOptionsPanel() { // Use Planetary Acquisitions - usePlanetaryAcquisitions = createCheckBox("UsePlanetaryAcquisitions"); + usePlanetaryAcquisitions = new CampaignOptionsCheckBox("UsePlanetaryAcquisitions"); // Max Jump Distance - lblMaxJumpPlanetaryAcquisitions = createLabel("MaxJumpPlanetaryAcquisitions"); - spnMaxJumpPlanetaryAcquisitions = createSpinner("MaxJumpPlanetaryAcquisitions", + lblMaxJumpPlanetaryAcquisitions = new CampaignOptionsLabel("MaxJumpPlanetaryAcquisitions"); + spnMaxJumpPlanetaryAcquisitions = new CampaignOptionsSpinner("MaxJumpPlanetaryAcquisitions", 2, 0, 5, 1); // Faction Limits - lblPlanetaryAcquisitionsFactionLimits = createLabel("PlanetaryAcquisitionsFactionLimits"); + lblPlanetaryAcquisitionsFactionLimits = new CampaignOptionsLabel("PlanetaryAcquisitionsFactionLimits"); // Disallow Resource Sharing (Inner Sphere) - disallowPlanetaryAcquisitionClanCrossover = createCheckBox("DisallowPlanetaryAcquisitionClanCrossover"); + disallowPlanetaryAcquisitionClanCrossover = new CampaignOptionsCheckBox("DisallowPlanetaryAcquisitionClanCrossover"); // Disallow Resource Sharing (Clans) - disallowClanPartsFromIS = createCheckBox("DisallowClanPartsFromIS"); + disallowClanPartsFromIS = new CampaignOptionsCheckBox("DisallowClanPartsFromIS"); // Acquisition Penalty - lblPenaltyClanPartsFromIS = createLabel("PenaltyClanPartsFromIS"); - spnPenaltyClanPartsFromIS = createSpinner("PenaltyClanPartsFromIS", + lblPenaltyClanPartsFromIS = new CampaignOptionsLabel("PenaltyClanPartsFromIS"); + spnPenaltyClanPartsFromIS = new CampaignOptionsSpinner("PenaltyClanPartsFromIS", 0, 0, 12, 1); // Verbose Reporting - usePlanetaryAcquisitionsVerbose = createCheckBox("UsePlanetaryAcquisitionsVerbose"); + usePlanetaryAcquisitionsVerbose = new CampaignOptionsCheckBox("UsePlanetaryAcquisitionsVerbose"); // Layout the Panel final JPanel panel = new JPanel(); @@ -434,7 +434,7 @@ private JPanel createModifiersPanel() { pnlOutputModifiers = createOutputModifiersPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("PlanetaryAcquisitionTabModifiers", + final JPanel panel = new CampaignOptionsStandardPanel("PlanetaryAcquisitionTabModifiers", true, "ModifiersPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -462,11 +462,11 @@ private JPanel createModifiersPanel() { * @return the created tab panel as a {@link JPanel} */ private JPanel createTechModifiersPanel() { - JLabel techLabel = createLabel("TechLabel"); + JLabel techLabel = new CampaignOptionsLabel("TechLabel"); techLabel.setName(String.format("

%s
%s
%s
buildAcquireSkillComboOptions() { */ JPanel createTechLimitsTab() { // Header - JPanel headerPanel = createHeaderPanel("TechLimitsTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("TechLimitsTab", getImageDirectory() + "logo_clan_cloud_cobra.png", true); // Limit Parts/Units by Year - limitByYearBox = createCheckBox("LimitByYearBox"); + limitByYearBox = new CampaignOptionsCheckBox("LimitByYearBox"); // Disallow Extinct Units/Parts - disallowExtinctStuffBox = createCheckBox("DisallowExtinctStuffBox"); + disallowExtinctStuffBox = new CampaignOptionsCheckBox("DisallowExtinctStuffBox"); // Allow Clan/Inner Sphere Purchases - allowClanPurchasesBox = createCheckBox("AllowClanPurchasesBox"); - allowISPurchasesBox = createCheckBox("AllowISPurchasesBox"); + allowClanPurchasesBox = new CampaignOptionsCheckBox("AllowClanPurchasesBox"); + allowISPurchasesBox = new CampaignOptionsCheckBox("AllowISPurchasesBox"); // Canon Purchases/Refits - allowCanonOnlyBox = createCheckBox("AllowCanonOnlyBox"); - allowCanonRefitOnlyBox = createCheckBox("AllowCanonRefitOnlyBox"); + allowCanonOnlyBox = new CampaignOptionsCheckBox("AllowCanonOnlyBox"); + allowCanonRefitOnlyBox = new CampaignOptionsCheckBox("AllowCanonRefitOnlyBox"); // Maximum Tech Level - lblChoiceTechLevel = createLabel("ChoiceTechLevel"); + lblChoiceTechLevel = new CampaignOptionsLabel("ChoiceTechLevel"); choiceTechLevel = new MMComboBox<>("choiceTechLevel", getMaximumTechLevelOptions()); // Variable Tech Level - variableTechLevelBox = createCheckBox("VariableTechLevelBox"); + variableTechLevelBox = new CampaignOptionsCheckBox("VariableTechLevelBox"); // Ammo by Type - useAmmoByTypeBox = createCheckBox("UseAmmoByTypeBox"); + useAmmoByTypeBox = new CampaignOptionsCheckBox("UseAmmoByTypeBox"); // Layout the Panel - final JPanel panel = createStandardPanel("TechLimitsTab", true); + final JPanel panel = new CampaignOptionsStandardPanel("TechLimitsTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/FinancesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/FinancesTab.java index 8eee98f016..71ef641f68 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/FinancesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/FinancesTab.java @@ -182,7 +182,7 @@ private void initializeGeneralOptionsTab() { */ JPanel createFinancesGeneralOptionsTab() { // Header - JPanel headerPanel = createHeaderPanel("FinancesGeneralTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("FinancesGeneralTab", getImageDirectory() + "logo_clan_nova_cat.png", true); @@ -194,7 +194,7 @@ JPanel createFinancesGeneralOptionsTab() { pnlOtherSystems = createOtherSystemsPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("FinancesGeneralTab", true, + final JPanel panel = new CampaignOptionsStandardPanel("FinancesGeneralTab", true, ""); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -230,17 +230,17 @@ JPanel createFinancesGeneralOptionsTab() { */ private JPanel createPaymentsPanel() { // Contents - payForPartsBox = createCheckBox("PayForPartsBox"); - payForRepairsBox = createCheckBox("PayForRepairsBox"); - payForUnitsBox = createCheckBox("PayForUnitsBox"); - payForSalariesBox = createCheckBox("PayForSalariesBox"); - payForOverheadBox = createCheckBox("PayForOverheadBox"); - payForMaintainBox = createCheckBox("PayForMaintainBox"); - payForTransportBox = createCheckBox("PayForTransportBox"); - payForRecruitmentBox = createCheckBox("PayForRecruitmentBox"); + payForPartsBox = new CampaignOptionsCheckBox("PayForPartsBox"); + payForRepairsBox = new CampaignOptionsCheckBox("PayForRepairsBox"); + payForUnitsBox = new CampaignOptionsCheckBox("PayForUnitsBox"); + payForSalariesBox = new CampaignOptionsCheckBox("PayForSalariesBox"); + payForOverheadBox = new CampaignOptionsCheckBox("PayForOverheadBox"); + payForMaintainBox = new CampaignOptionsCheckBox("PayForMaintainBox"); + payForTransportBox = new CampaignOptionsCheckBox("PayForTransportBox"); + payForRecruitmentBox = new CampaignOptionsCheckBox("PayForRecruitmentBox"); // Layout the Panel - final JPanel panel = createStandardPanel("PaymentsPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("PaymentsPanel", true, "PaymentsPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -293,7 +293,7 @@ private JPanel createOtherSystemsPanel() { pnlShares = createSharesPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("OtherSystemsPanel", false); + final JPanel panel = new CampaignOptionsStandardPanel("OtherSystemsPanel", false); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -320,18 +320,18 @@ private JPanel createOtherSystemsPanel() { */ private JPanel createGeneralOptionsPanel() { // Contents - useLoanLimitsBox = createCheckBox("UseLoanLimitsBox"); - usePercentageMaintenanceBox = createCheckBox("UsePercentageMaintenanceBox"); - useExtendedPartsModifierBox = createCheckBox("UseExtendedPartsModifierBox"); - usePeacetimeCostBox = createCheckBox("UsePeacetimeCostBox"); - showPeacetimeCostBox = createCheckBox("ShowPeacetimeCostBox"); + useLoanLimitsBox = new CampaignOptionsCheckBox("UseLoanLimitsBox"); + usePercentageMaintenanceBox = new CampaignOptionsCheckBox("UsePercentageMaintenanceBox"); + useExtendedPartsModifierBox = new CampaignOptionsCheckBox("UseExtendedPartsModifierBox"); + usePeacetimeCostBox = new CampaignOptionsCheckBox("UsePeacetimeCostBox"); + showPeacetimeCostBox = new CampaignOptionsCheckBox("ShowPeacetimeCostBox"); - lblFinancialYearDuration = createLabel("FinancialYearDuration", null); + lblFinancialYearDuration = new CampaignOptionsLabel("FinancialYearDuration"); - newFinancialYearFinancesToCSVExportBox = createCheckBox("NewFinancialYearFinancesToCSVExportBox"); + newFinancialYearFinancesToCSVExportBox = new CampaignOptionsCheckBox("NewFinancialYearFinancesToCSVExportBox"); // Layout the Panel - final JPanel panel = createStandardPanel("GeneralOptionsPanel", false); + final JPanel panel = new CampaignOptionsStandardPanel("GeneralOptionsPanel", false); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -371,11 +371,11 @@ private JPanel createGeneralOptionsPanel() { */ private JPanel createSalesPanel() { // Contents - sellUnitsBox = createCheckBox("SellUnitsBox"); - sellPartsBox = createCheckBox("SellPartsBox"); + sellUnitsBox = new CampaignOptionsCheckBox("SellUnitsBox"); + sellPartsBox = new CampaignOptionsCheckBox("SellPartsBox"); // Layout the Panel - final JPanel panel = createStandardPanel("SalesPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("SalesPanel", true, "SalesPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -406,14 +406,14 @@ private JPanel createSalesPanel() { */ private JPanel createTaxesPanel() { // Contents - chkUseTaxes = createCheckBox("UseTaxesBox"); + chkUseTaxes = new CampaignOptionsCheckBox("UseTaxesBox"); - lblTaxesPercentage = createLabel("TaxesPercentage", null); - spnTaxesPercentage = createSpinner("TaxesPercentage", null, + lblTaxesPercentage = new CampaignOptionsLabel("TaxesPercentage"); + spnTaxesPercentage = new CampaignOptionsSpinner("TaxesPercentage", 30, 1, 100, 1); // Layout the Panel - final JPanel panel = createStandardPanel("TaxesPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("TaxesPanel", true, "TaxesPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -444,11 +444,11 @@ private JPanel createTaxesPanel() { */ private JPanel createSharesPanel() { // Contents - chkUseShareSystem = createCheckBox("UseShareSystem"); - chkSharesForAll = createCheckBox("SharesForAll"); + chkUseShareSystem = new CampaignOptionsCheckBox("UseShareSystem"); + chkSharesForAll = new CampaignOptionsCheckBox("SharesForAll"); // Layout the Panel - final JPanel panel = createStandardPanel("SharesPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("SharesPanel", true, "SharesPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -510,7 +510,7 @@ private void initializePriceMultipliersTab() { */ JPanel createPriceMultipliersTab() { // Header - JPanel headerPanel = createHeaderPanel("PriceMultipliersTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("PriceMultipliersTab", getImageDirectory() + "logo_illyrian_palatinate.png", true); @@ -520,7 +520,7 @@ JPanel createPriceMultipliersTab() { pnlOtherMultipliers = createOtherMultipliersPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("PriceMultipliersTab", true, + final JPanel panel = new CampaignOptionsStandardPanel("PriceMultipliersTab", true, ""); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -555,32 +555,32 @@ JPanel createPriceMultipliersTab() { */ private JPanel createGeneralMultipliersPanel() { // Contents - lblCommonPartPriceMultiplier = createLabel("CommonPartPriceMultiplier", null); - spnCommonPartPriceMultiplier = createSpinner("CommonPartPriceMultiplier", null, + lblCommonPartPriceMultiplier = new CampaignOptionsLabel("CommonPartPriceMultiplier"); + spnCommonPartPriceMultiplier = new CampaignOptionsSpinner("CommonPartPriceMultiplier", 1.0, 0.1, 100, 0.1); - lblInnerSphereUnitPriceMultiplier = createLabel("InnerSphereUnitPriceMultiplier", null); - spnInnerSphereUnitPriceMultiplier = createSpinner("InnerSphereUnitPriceMultiplier", null, + lblInnerSphereUnitPriceMultiplier = new CampaignOptionsLabel("InnerSphereUnitPriceMultiplier"); + spnInnerSphereUnitPriceMultiplier = new CampaignOptionsSpinner("InnerSphereUnitPriceMultiplier", 1.0, 0.1, 100, 0.1); - lblInnerSpherePartPriceMultiplier = createLabel("InnerSpherePartPriceMultiplier", null); - spnInnerSpherePartPriceMultiplier = createSpinner("InnerSpherePartPriceMultiplier", null, + lblInnerSpherePartPriceMultiplier = new CampaignOptionsLabel("InnerSpherePartPriceMultiplier"); + spnInnerSpherePartPriceMultiplier = new CampaignOptionsSpinner("InnerSpherePartPriceMultiplier", 1.0, 0.1, 100, 0.1); - lblClanUnitPriceMultiplier = createLabel("ClanUnitPriceMultiplier", null); - spnClanUnitPriceMultiplier = createSpinner("ClanUnitPriceMultiplier", null, + lblClanUnitPriceMultiplier = new CampaignOptionsLabel("ClanUnitPriceMultiplier"); + spnClanUnitPriceMultiplier = new CampaignOptionsSpinner("ClanUnitPriceMultiplier", 1.0, 0.1, 100, 0.1); - lblClanPartPriceMultiplier = createLabel("ClanPartPriceMultiplier", null); - spnClanPartPriceMultiplier = createSpinner("ClanPartPriceMultiplier", null, + lblClanPartPriceMultiplier = new CampaignOptionsLabel("ClanPartPriceMultiplier"); + spnClanPartPriceMultiplier = new CampaignOptionsSpinner("ClanPartPriceMultiplier", 1.0, 0.1, 100, 0.1); - lblMixedTechUnitPriceMultiplier = createLabel("MixedTechUnitPriceMultiplier", null); - spnMixedTechUnitPriceMultiplier = createSpinner("MixedTechUnitPriceMultiplier", null, + lblMixedTechUnitPriceMultiplier = new CampaignOptionsLabel("MixedTechUnitPriceMultiplier"); + spnMixedTechUnitPriceMultiplier = new CampaignOptionsSpinner("MixedTechUnitPriceMultiplier", 1.0, 0.1, 100, 0.1); // Layout the Panel - final JPanel panel = createStandardPanel("GeneralMultipliersPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("GeneralMultipliersPanel", true, "GeneralMultipliersPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -672,7 +672,7 @@ private JPanel createUsedPartsMultiplierPanel() { } // Layout the Panel - final JPanel panel = createStandardPanel("UsedPartsMultiplierPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("UsedPartsMultiplierPanel", true, "UsedPartsMultiplierPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -736,20 +736,20 @@ private JPanel createUsedPartsMultiplierPanel() { */ private JPanel createOtherMultipliersPanel() { // Contents - lblDamagedPartsValueMultiplier = createLabel("DamagedPartsValueMultiplier", null); - spnDamagedPartsValueMultiplier = createSpinner("DamagedPartsValueMultiplier", null, + lblDamagedPartsValueMultiplier = new CampaignOptionsLabel("DamagedPartsValueMultiplier"); + spnDamagedPartsValueMultiplier = new CampaignOptionsSpinner("DamagedPartsValueMultiplier", 0.33, 0.00, 1.00, 0.05); - lblUnrepairablePartsValueMultiplier = createLabel("UnrepairablePartsValueMultiplier", null); - spnUnrepairablePartsValueMultiplier = createSpinner("UnrepairablePartsValueMultiplier", null, + lblUnrepairablePartsValueMultiplier = new CampaignOptionsLabel("UnrepairablePartsValueMultiplier"); + spnUnrepairablePartsValueMultiplier = new CampaignOptionsSpinner("UnrepairablePartsValueMultiplier", 0.10, 0.00, 1.00, 0.05); - lblCancelledOrderRefundMultiplier = createLabel("CancelledOrderRefundMultiplier", null); - spnCancelledOrderRefundMultiplier = createSpinner("CancelledOrderRefundMultiplier", null, + lblCancelledOrderRefundMultiplier = new CampaignOptionsLabel("CancelledOrderRefundMultiplier"); + spnCancelledOrderRefundMultiplier = new CampaignOptionsSpinner("CancelledOrderRefundMultiplier", 0.50, 0.00, 1.00, 0.05); // Layout the Panel - final JPanel panel = createStandardPanel("OtherMultipliersPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("OtherMultipliersPanel", true, "OtherMultipliersPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java index be0935a5e1..8d329e323a 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java @@ -2,9 +2,11 @@ import megamek.client.ui.baseComponents.MMComboBox; import megamek.client.ui.dialogs.CamoChooserDialog; +import megamek.client.ui.swing.util.FlatLafStyleBuilder; import megamek.client.ui.swing.util.UIUtil; import megamek.common.annotations.Nullable; import megamek.common.icons.Camouflage; +import mekhq.MHQConstants; import mekhq.MekHQ; import mekhq.campaign.Campaign; import mekhq.campaign.icons.StandardForceIcon; @@ -55,7 +57,6 @@ public class GeneralTab { private JLabel lblIcon; private JButton btnIcon; private StandardForceIcon unitIcon; - private JPanel createGeneralOptionsPanel; /** * Constructs a new {@link GeneralTab} object. @@ -84,27 +85,49 @@ public AbstractMHQScrollablePanel createGeneralTab() { // Header JPanel headerPanel = createGeneralHeader(); - lblName = createLabel("Name"); - txtName = createTextField("Name", 300); + // Campaign name + lblName = new CampaignOptionsLabel("Name"); + txtName = new CampaignOptionsTextField("Name"); - btnNameGenerator = createButton("NameGenerator"); + // Generate new random campaign name + btnNameGenerator = new CampaignOptionsButton("NameGenerator"); btnNameGenerator.addActionListener(e -> txtName.setText(BackgroundsController - .randomMercenaryCompanyNameGenerator(campaign.getFlaggedCommander()))); + .randomMercenaryCompanyNameGenerator(campaign.getFlaggedCommander()))); - createGeneralOptionsPanel = createGeneralOptionsPanel(); + // Campaign faction + lblFaction = new CampaignOptionsLabel("Faction"); + comboFaction.setSelectedItem(new FactionDisplay(campaign.getFaction(), campaign.getLocalDate())); + + // Reputation + lblReputation = new CampaignOptionsLabel("Reputation"); + lblManualUnitRatingModifier = new CampaignOptionsLabel("ManualUnitRatingModifier"); + manualUnitRatingModifier = new CampaignOptionsSpinner("ManualUnitRatingModifier", + 0, -200, 200, 1); + + // Date + lblDate = new CampaignOptionsLabel("Date"); + btnDate = new CampaignOptionsButton("Date"); + btnDate.addActionListener(this::btnDateActionPerformed); // Camouflage - lblCamo = createLabel("Camo"); + lblCamo = new CampaignOptionsLabel("Camo") { + @Override + public Dimension getPreferredSize() { + return UIUtil.scaleForGUI(100, 100); + } + }; + +// lblCamo = new CampaignOptionsLabel("Camo"); btnCamo.setName("btnCamo"); - btnCamo.setMinimumSize(UIUtil.scaleForGUI(100, 100)); - btnCamo.setMaximumSize(UIUtil.scaleForGUI(100, 100)); +// btnCamo.setMinimumSize(UIUtil.scaleForGUI(100, 100)); +// btnCamo.setMaximumSize(UIUtil.scaleForGUI(100, 100)); btnCamo.addActionListener(this::btnCamoActionPerformed); // Unit icon - lblIcon = createLabel("Icon"); + lblIcon = new CampaignOptionsLabel("Icon"); btnIcon.setName("btnIcon"); - btnIcon.setMinimumSize(UIUtil.scaleForGUI(100, 100)); - btnIcon.setMaximumSize(UIUtil.scaleForGUI(100, 100)); +// btnIcon.setMinimumSize(UIUtil.scaleForGUI(100, 100)); +// btnIcon.setMaximumSize(UIUtil.scaleForGUI(100, 100)); btnIcon.addActionListener(evt -> { final UnitIconDialog unitIconDialog = new UnitIconDialog(frame, unitIcon); if (unitIconDialog.showDialog().isConfirmed() && (unitIconDialog.getSelectedItem() != null)) { @@ -118,97 +141,140 @@ public AbstractMHQScrollablePanel createGeneralTab() { new GridBagLayout()); // Layout the Panel - final JPanel panel = createStandardPanel("generalTab", true); - final GroupLayout layout = createStandardLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblName) - .addComponent(txtName) - .addComponent(btnNameGenerator)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(createGeneralOptionsPanel)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblCamo) - .addComponent(btnCamo) - .addComponent(lblIcon) - .addComponent(btnIcon))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addGroup(layout.createSequentialGroup() - .addComponent(lblName) - .addComponent(txtName) - .addComponent(btnNameGenerator)) - .addGroup(layout.createSequentialGroup() - .addComponent(createGeneralOptionsPanel)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblCamo) - .addComponent(btnCamo) - .addGap(UIUtil.scaleForGUI(50)) - .addComponent(lblIcon) - .addComponent(btnIcon))); - - generalPanel.add(panel); - + JPanel panel = new JPanel(); + GridBagConstraints gbc = new GridBagConstraints(); + panel.setLayout(new GridBagLayout()); + + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(5, 5, 5, 5); + gbc.fill = GridBagConstraints.HORIZONTAL; + + gbc.gridy = 0; + gbc.gridwidth = 5; + panel.add(headerPanel, gbc); + + gbc.gridwidth = 1; + gbc.gridy++; + panel.add(lblName, gbc); + + gbc.gridwidth = 2; + gbc.weightx = 1; + panel.add(txtName, gbc); + + gbc.gridwidth = 1; + gbc.weightx = 0; + gbc.fill = GridBagConstraints.NONE; + panel.add(btnNameGenerator, gbc); + gbc.fill = GridBagConstraints.HORIZONTAL; + + gbc.gridy++; + panel.add(lblFaction, gbc); + gbc.gridwidth = 2; + panel.add(comboFaction, gbc); + + gbc.gridwidth = 1; + gbc.gridy++; + panel.add(lblReputation, gbc); + gbc.gridwidth = 2; + panel.add(unitRatingMethodCombo, gbc); + + gbc.gridwidth = 1; + gbc.gridy++; + panel.add(lblManualUnitRatingModifier, gbc); + panel.add(manualUnitRatingModifier, gbc); + + gbc.gridy++; + panel.add(lblDate, gbc); + panel.add(btnDate, gbc); + + gbc.gridy++; + gbc.gridwidth = 5; + gbc.gridx = GridBagConstraints.RELATIVE; + JPanel iconsPanel = new JPanel(); + + iconsPanel.add(lblCamo); + iconsPanel.add(btnCamo); + iconsPanel.add(Box.createHorizontalStrut(50)); + iconsPanel.add(lblIcon); + iconsPanel.add(btnIcon); + + panel.add(iconsPanel, gbc); + + + + +// final GroupLayout layout = createStandardLayout(panel); +// panel.setLayout(layout); +// +// layout.setVerticalGroup( +// layout.createSequentialGroup() +// .addComponent(headerPanel) +// .addGroup(layout.createParallelGroup(Alignment.TRAILING) +// .addComponent(lblName) +// .addComponent(txtName) +// .addComponent(btnNameGenerator)) +// .addGroup(layout.createParallelGroup(Alignment.BASELINE) +// .addComponent(lblFaction) +// .addComponent(comboFaction)) +// .addGroup(layout.createParallelGroup(Alignment.BASELINE) +// .addComponent(lblReputation) +// .addComponent(unitRatingMethodCombo)) +// .addGroup(layout.createParallelGroup(Alignment.BASELINE) +// .addComponent(lblManualUnitRatingModifier) +// .addComponent(manualUnitRatingModifier)) +// .addGroup(layout.createParallelGroup(Alignment.BASELINE) +// .addComponent(lblDate) +// .addComponent(btnDate)) +// .addGroup(layout.createParallelGroup(Alignment.BASELINE) +// .addComponent(lblCamo) +// .addComponent(btnCamo) +// .addComponent(lblIcon) +// .addComponent(btnIcon))); +// +// layout.setHorizontalGroup( +// layout.createParallelGroup(Alignment.LEADING) +// .addComponent(headerPanel, Alignment.CENTER) +// .addGroup(layout.createSequentialGroup() +// .addComponent(lblName) +// .addComponent(txtName) +// .addComponent(btnNameGenerator) +// .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) +// .addGroup(layout.createSequentialGroup() +// .addComponent(lblFaction) +// .addComponent(comboFaction) +// .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) +// .addGroup(layout.createSequentialGroup() +// .addComponent(lblReputation) +// .addComponent(unitRatingMethodCombo) +// .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) +// .addGroup(layout.createSequentialGroup() +// .addComponent(lblManualUnitRatingModifier) +// .addComponent(manualUnitRatingModifier) +// .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) +// .addGroup(layout.createSequentialGroup() +// .addComponent(lblDate) +// .addComponent(btnDate) +// .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) +// .addGroup(layout.createSequentialGroup() +// .addComponent(lblCamo) +// .addComponent(btnCamo) +// .addGap(50) +// .addComponent(lblIcon) +// .addComponent(btnIcon) +// .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); +// + + final JPanel outerPanel = new CampaignOptionsStandardPanel("generalTab", true); + // Add some padding left and right (inside the border!) + outerPanel.setLayout(new BorderLayout()); + outerPanel.add(Box.createHorizontalStrut(25), BorderLayout.LINE_START); + outerPanel.add(Box.createHorizontalStrut(25), BorderLayout.LINE_END); + outerPanel.add(panel, BorderLayout.CENTER); + + generalPanel.add(outerPanel); return generalPanel; } - private JPanel createGeneralOptionsPanel() { - lblFaction = createLabel("Faction"); - comboFaction.setSelectedItem(new FactionDisplay(campaign.getFaction(), campaign.getLocalDate())); - - lblReputation = createLabel("Reputation"); - lblManualUnitRatingModifier = createLabel("ManualUnitRatingModifier"); - manualUnitRatingModifier = createSpinner("ManualUnitRatingModifier", - 0, -200, 200, 1); - - lblDate = createLabel("Date"); - btnDate = createButton("Date"); - btnDate.addActionListener(this::btnDateActionPerformed); - - // Layout the Panel - final JPanel panel = createStandardPanel("GeneralOptionsPanel", false); - final GroupLayout layout = createStandardLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblFaction) - .addComponent(comboFaction)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblReputation) - .addComponent(unitRatingMethodCombo)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblManualUnitRatingModifier) - .addComponent(manualUnitRatingModifier)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblDate) - .addComponent(btnDate))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblFaction) - .addComponent(comboFaction)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblReputation) - .addComponent(unitRatingMethodCombo)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblManualUnitRatingModifier) - .addComponent(manualUnitRatingModifier)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblDate) - .addComponent(btnDate))); - - return panel; - } - /** * Creates a {@link JPanel} with a header containing an image, title, and body text. * @@ -216,29 +282,19 @@ private JPanel createGeneralOptionsPanel() { */ private static JPanel createGeneralHeader() { ImageIcon imageIcon = new ImageIcon("data/images/misc/MekHQ.png"); - - int width = UIUtil.scaleForGUI(imageIcon.getIconWidth()); - int height = UIUtil.scaleForGUI(imageIcon.getIconHeight()); - - Image image = imageIcon.getImage(); - Image scaledImage = image.getScaledInstance(width, height, Image.SCALE_SMOOTH); - - imageIcon = new ImageIcon(scaledImage); - JLabel imageLabel = new JLabel(imageIcon); final JLabel lblHeader = new JLabel(resources.getString("lblGeneral.text"), SwingConstants.CENTER); - setFontScaling(lblHeader, true, 2); + new FlatLafStyleBuilder().font(MHQConstants.PROJECT_NAME).bold().size(3).apply(lblHeader); lblHeader.setName("lblGeneral"); JLabel lblBody = new JLabel(String.format("%s", resources.getString("lblGeneralBody.text")), SwingConstants.CENTER); lblBody.setName("lblGeneralHeaderBody"); - setFontScaling(lblBody, false, 1); Dimension size = lblBody.getPreferredSize(); lblBody.setMaximumSize(UIUtil.scaleForGUI(750, size.height)); - final JPanel panel = createStandardPanel("pnlGeneralHeaderPanel", false); + final JPanel panel = new CampaignOptionsStandardPanel("pnlGeneralHeaderPanel", false); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -280,7 +336,13 @@ private void initialize() { btnDate = new JButton(); lblCamo = new JLabel(); - btnCamo = new JButton(); + btnCamo = new JButton() { + + @Override + public Dimension getPreferredSize() { + return UIUtil.scaleForGUI(100, 100); + } + }; lblIcon = new JLabel(); btnIcon = new JButton(); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/MarketsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/MarketsTab.java index 32e26b1ee3..b0cbef42a4 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/MarketsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/MarketsTab.java @@ -118,7 +118,7 @@ private static DefaultComboBoxModel getPersonnelMarketTypeOptions() { JPanel createPersonnelMarketTab() { // Header - JPanel headerPanel = createHeaderPanel("PersonnelMarketTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("PersonnelMarketTab", getImageDirectory() + "logo_clan_sea_fox.png", true); @@ -127,7 +127,7 @@ JPanel createPersonnelMarketTab() { pnlRemovalTargets = createPersonnelMarketRemovalOptionsPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("PersonnelMarketTab", true, + final JPanel panel = new CampaignOptionsStandardPanel("PersonnelMarketTab", true, ""); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -152,20 +152,20 @@ JPanel createPersonnelMarketTab() { private JPanel createPersonnelMarketGeneralOptionsPanel() { // Contents - lblPersonnelMarketType = createLabel("PersonnelMarketType"); + lblPersonnelMarketType = new CampaignOptionsLabel("PersonnelMarketType"); comboPersonnelMarketType = new MMComboBox<>("comboPersonnelMarketType", getPersonnelMarketTypeOptions()); - lblPersonnelMarketDylansWeight = createLabel("PersonnelMarketDylansWeight"); - spnPersonnelMarketDylansWeight = createSpinner("PersonnelMarketDylansWeight", + lblPersonnelMarketDylansWeight = new CampaignOptionsLabel("PersonnelMarketDylansWeight"); + spnPersonnelMarketDylansWeight = new CampaignOptionsSpinner("PersonnelMarketDylansWeight", 0.3, 0, 1, 0.1); - chkPersonnelMarketReportRefresh = createCheckBox("PersonnelMarketReportRefresh"); + chkPersonnelMarketReportRefresh = new CampaignOptionsCheckBox("PersonnelMarketReportRefresh"); - chkUsePersonnelHireHiringHallOnly = createCheckBox("UsePersonnelHireHiringHallOnly"); + chkUsePersonnelHireHiringHallOnly = new CampaignOptionsCheckBox("UsePersonnelHireHiringHallOnly"); // Layout the Panel - final JPanel panel = createStandardPanel("PersonnelMarketGeneralOptionsPanel", false, + final JPanel panel = new CampaignOptionsStandardPanel("PersonnelMarketGeneralOptionsPanel", false, ""); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -211,7 +211,7 @@ private JPanel createPersonnelMarketRemovalOptionsPanel() { } // Layout the Panels - final JPanel leftPanel = createStandardPanel("LeftPanel", false); + final JPanel leftPanel = new CampaignOptionsStandardPanel("LeftPanel", false); final GroupLayout leftLayout = createStandardLayout(leftPanel); leftPanel.setLayout(leftLayout); @@ -245,7 +245,7 @@ private JPanel createPersonnelMarketRemovalOptionsPanel() { .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.REGULAR)) .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.REGULAR)))); - final JPanel rightPanel = createStandardPanel("RightPanel", false); + final JPanel rightPanel = new CampaignOptionsStandardPanel("RightPanel", false); final GroupLayout rightLayout = createStandardLayout(rightPanel); rightPanel.setLayout(rightLayout); @@ -279,7 +279,7 @@ private JPanel createPersonnelMarketRemovalOptionsPanel() { .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.LEGENDARY)) .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.LEGENDARY)))); - final JPanel parentPanel = createStandardPanel("PersonnelMarketRemovalOptionsPanel", + final JPanel parentPanel = new CampaignOptionsStandardPanel("PersonnelMarketRemovalOptionsPanel", true, "PersonnelMarketRemovalOptionsPanel"); final GroupLayout parentLayout = createStandardLayout(parentPanel); parentPanel.setLayout(parentLayout); @@ -313,30 +313,30 @@ private void initializeUnitMarket() { JPanel createUnitMarketTab() { // Header - JPanel headerPanel = createHeaderPanel("UnitMarketTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("UnitMarketTab", getImageDirectory() + "logo_loathian_league.png", true); // Contents - lblUnitMarketMethod = createLabel("UnitMarketMethod"); + lblUnitMarketMethod = new CampaignOptionsLabel("UnitMarketMethod"); comboUnitMarketMethod = new MMComboBox<>("comboUnitMarketMethod", UnitMarketMethod.values()); - chkUnitMarketRegionalMekVariations = createCheckBox("UnitMarketRegionalMekVariations"); + chkUnitMarketRegionalMekVariations = new CampaignOptionsCheckBox("UnitMarketRegionalMekVariations"); - lblUnitMarketSpecialUnitChance = createLabel("UnitMarketSpecialUnitChance"); - spnUnitMarketSpecialUnitChance = createSpinner("UnitMarketSpecialUnitChance", + lblUnitMarketSpecialUnitChance = new CampaignOptionsLabel("UnitMarketSpecialUnitChance"); + spnUnitMarketSpecialUnitChance = new CampaignOptionsSpinner("UnitMarketSpecialUnitChance", 30, 0, 100, 1); - lblUnitMarketRarityModifier = createLabel("UnitMarketRarityModifier"); - spnUnitMarketRarityModifier = createSpinner("UnitMarketRarityModifier", + lblUnitMarketRarityModifier = new CampaignOptionsLabel("UnitMarketRarityModifier"); + spnUnitMarketRarityModifier = new CampaignOptionsSpinner("UnitMarketRarityModifier", 0, -10, 10, 1); - chkInstantUnitMarketDelivery = createCheckBox("InstantUnitMarketDelivery"); + chkInstantUnitMarketDelivery = new CampaignOptionsCheckBox("InstantUnitMarketDelivery"); - chkUnitMarketReportRefresh = createCheckBox("UnitMarketReportRefresh"); + chkUnitMarketReportRefresh = new CampaignOptionsCheckBox("UnitMarketReportRefresh"); // Layout the Panel - final JPanel panel = createStandardPanel("UnitMarketTab", true, + final JPanel panel = new CampaignOptionsStandardPanel("UnitMarketTab", true, ""); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -411,7 +411,7 @@ private void initializeContractMarket() { JPanel createContractMarketTab() { // Header - JPanel headerPanel = createHeaderPanel("ContractMarketTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("ContractMarketTab", getImageDirectory() + "logo_clan_smoke_jaguar.png", true); @@ -420,7 +420,7 @@ JPanel createContractMarketTab() { pnlContractPay = createContractPayPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("ContractMarketTab", true, + final JPanel panel = new CampaignOptionsStandardPanel("ContractMarketTab", true, ""); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -445,28 +445,28 @@ JPanel createContractMarketTab() { private JPanel createContractMarketGeneralOptionsPanel() { // Contents - lblContractMarketMethod = createLabel("ContractMarketMethod"); + lblContractMarketMethod = new CampaignOptionsLabel("ContractMarketMethod"); comboContractMarketMethod = new MMComboBox<>("comboContractMarketMethod", ContractMarketMethod.values()); - lblContractSearchRadius = createLabel("ContractSearchRadius"); - spnContractSearchRadius = createSpinner("ContractSearchRadius", + lblContractSearchRadius = new CampaignOptionsLabel("ContractSearchRadius"); + spnContractSearchRadius = new CampaignOptionsSpinner("ContractSearchRadius", 300, 100, 2500, 100); - chkVariableContractLength = createCheckBox("VariableContractLength"); + chkVariableContractLength = new CampaignOptionsCheckBox("VariableContractLength"); - chkContractMarketReportRefresh = createCheckBox("ContractMarketReportRefresh"); + chkContractMarketReportRefresh = new CampaignOptionsCheckBox("ContractMarketReportRefresh"); - lblCoontractMaxSalvagePercentage = createLabel("CoontractMaxSalvagePercentage"); - spnContractMaxSalvagePercentage = createSpinner("CoontractMaxSalvagePercentage", + lblCoontractMaxSalvagePercentage = new CampaignOptionsLabel("CoontractMaxSalvagePercentage"); + spnContractMaxSalvagePercentage = new CampaignOptionsSpinner("CoontractMaxSalvagePercentage", 100, 0, 100, 10); - lblDropShipBonusPercentage = createLabel("DropShipBonusPercentage"); - spnDropShipBonusPercentage = createSpinner("DropShipBonusPercentage", + lblDropShipBonusPercentage = new CampaignOptionsLabel("DropShipBonusPercentage"); + spnDropShipBonusPercentage = new CampaignOptionsSpinner("DropShipBonusPercentage", 0, 0, 20, 5); // Layout the Panel - final JPanel panel = createStandardPanel("ContractMarketGeneralOptionsPanel", + final JPanel panel = new CampaignOptionsStandardPanel("ContractMarketGeneralOptionsPanel", false); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -513,36 +513,36 @@ private JPanel createContractPayPanel() { btnContractEquipment = new JRadioButton(resources.getString("lblContractEquipment.text")); btnContractEquipment.setToolTipText(resources.getString("lblContractEquipment.tooltip")); - chkEquipContractSaleValue = createCheckBox("EquipContractSaleValue"); + chkEquipContractSaleValue = new CampaignOptionsCheckBox("EquipContractSaleValue"); - lblEquipPercent = createLabel("EquipPercent"); - spnEquipPercent = createSpinner("EquipPercent", + lblEquipPercent = new CampaignOptionsLabel("EquipPercent"); + spnEquipPercent = new CampaignOptionsSpinner("EquipPercent", 0.1, 0.1, CampaignOptions.MAXIMUM_COMBAT_EQUIPMENT_PERCENT, 0.1); - lblDropShipPercent = createLabel("DropShipPercent"); - spnDropShipPercent = createSpinner("DropShipPercent", + lblDropShipPercent = new CampaignOptionsLabel("DropShipPercent"); + spnDropShipPercent = new CampaignOptionsSpinner("DropShipPercent", 0.1, 0.1, CampaignOptions.MAXIMUM_COMBAT_EQUIPMENT_PERCENT, 0.1); - lblJumpShipPercent = createLabel("JumpShipPercent"); - spnJumpShipPercent = createSpinner("JumpShipPercent", + lblJumpShipPercent = new CampaignOptionsLabel("JumpShipPercent"); + spnJumpShipPercent = new CampaignOptionsSpinner("JumpShipPercent", 0.1, 0.1, CampaignOptions.MAXIMUM_COMBAT_EQUIPMENT_PERCENT, 0.1); - lblWarShipPercent = createLabel("WarShipPercent"); - spnWarShipPercent = createSpinner("WarShipPercent", + lblWarShipPercent = new CampaignOptionsLabel("WarShipPercent"); + spnWarShipPercent = new CampaignOptionsSpinner("WarShipPercent", 0.1, 0.1, CampaignOptions.MAXIMUM_COMBAT_EQUIPMENT_PERCENT, 0.1); btnContractPersonnel = new JRadioButton(resources.getString("lblContractPersonnel.text")); btnContractPersonnel.setToolTipText(resources.getString("lblContractPersonnel.tooltip")); - chkBLCSaleValue = createCheckBox("BLCSaleValue"); + chkBLCSaleValue = new CampaignOptionsCheckBox("BLCSaleValue"); - useInfantryDoseNotCountBox = createCheckBox("UseInfantryDoseNotCountBox"); - chkMercSizeLimited = createCheckBox("MercSizeLimited"); + useInfantryDoseNotCountBox = new CampaignOptionsCheckBox("UseInfantryDoseNotCountBox"); + chkMercSizeLimited = new CampaignOptionsCheckBox("MercSizeLimited"); - chkOverageRepaymentInFinalPayment = createCheckBox("OverageRepaymentInFinalPayment"); + chkOverageRepaymentInFinalPayment = new CampaignOptionsCheckBox("OverageRepaymentInFinalPayment"); // Layout the Panel - final JPanel panel = createStandardPanel("ContractPayPanel", + final JPanel panel = new CampaignOptionsStandardPanel("ContractPayPanel", true, "ContractPayPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java index 657aec0f08..25d0fe5fe9 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java @@ -359,26 +359,26 @@ private DefaultComboBoxModel getPrisonerStatusOptions() { JPanel createGeneralTab() { // Header - JPanel headerPanel = createHeaderPanel("PersonnelGeneralTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("PersonnelGeneralTab", getImageDirectory() + "logo_circinus_federation.png", true); // Contents - chkUseTactics = createCheckBox("UseTactics"); - chkUseInitiativeBonus = createCheckBox("UseInitiativeBonus"); - chkUseToughness = createCheckBox("UseToughness"); - chkUseRandomToughness = createCheckBox("UseRandomToughness"); - chkUseArtillery = createCheckBox("UseArtillery"); - chkUseAbilities = createCheckBox("UseAbilities"); - chkUseEdge = createCheckBox("UseEdge"); - chkUseSupportEdge = createCheckBox("UseSupportEdge"); - chkUseImplants = createCheckBox("UseImplants"); - chkUseAlternativeQualityAveraging = createCheckBox("UseAlternativeQualityAveraging"); + chkUseTactics = new CampaignOptionsCheckBox("UseTactics"); + chkUseInitiativeBonus = new CampaignOptionsCheckBox("UseInitiativeBonus"); + chkUseToughness = new CampaignOptionsCheckBox("UseToughness"); + chkUseRandomToughness = new CampaignOptionsCheckBox("UseRandomToughness"); + chkUseArtillery = new CampaignOptionsCheckBox("UseArtillery"); + chkUseAbilities = new CampaignOptionsCheckBox("UseAbilities"); + chkUseEdge = new CampaignOptionsCheckBox("UseEdge"); + chkUseSupportEdge = new CampaignOptionsCheckBox("UseSupportEdge"); + chkUseImplants = new CampaignOptionsCheckBox("UseImplants"); + chkUseAlternativeQualityAveraging = new CampaignOptionsCheckBox("UseAlternativeQualityAveraging"); personnelCleanUpPanel = createPersonnelCleanUpPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("PersonnelGeneralTab", true); + final JPanel panel = new CampaignOptionsStandardPanel("PersonnelGeneralTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -428,12 +428,12 @@ JPanel createGeneralTab() { */ private JPanel createPersonnelCleanUpPanel() { // Contents - chkUsePersonnelRemoval = createCheckBox("UsePersonnelRemoval"); - chkUseRemovalExemptCemetery = createCheckBox("UseRemovalExemptCemetery"); - chkUseRemovalExemptRetirees = createCheckBox("UseRemovalExemptRetirees"); + chkUsePersonnelRemoval = new CampaignOptionsCheckBox("UsePersonnelRemoval"); + chkUseRemovalExemptCemetery = new CampaignOptionsCheckBox("UseRemovalExemptCemetery"); + chkUseRemovalExemptRetirees = new CampaignOptionsCheckBox("UseRemovalExemptRetirees"); // Layout the Panel - final JPanel panel = createStandardPanel("PersonnelCleanUpPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("PersonnelCleanUpPanel", true, "PersonnelCleanUpPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -460,22 +460,22 @@ private JPanel createPersonnelCleanUpPanel() { */ JPanel createPersonnelLogsTab() { // Header - JPanel headerPanel = createHeaderPanel("PersonnelLogsTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("PersonnelLogsTab", getImageDirectory() + "logo_clan_coyote.png", true); // Contents - chkUseTransfers = createCheckBox("UseTransfers"); - chkUseExtendedTOEForceName = createCheckBox("UseExtendedTOEForceName"); - chkPersonnelLogSkillGain = createCheckBox("PersonnelLogSkillGain"); - chkPersonnelLogAbilityGain = createCheckBox("PersonnelLogAbilityGain"); - chkPersonnelLogEdgeGain = createCheckBox("PersonnelLogEdgeGain"); - chkDisplayPersonnelLog = createCheckBox("DisplayPersonnelLog"); - chkDisplayScenarioLog = createCheckBox("DisplayScenarioLog"); - chkDisplayKillRecord = createCheckBox("DisplayKillRecord"); + chkUseTransfers = new CampaignOptionsCheckBox("UseTransfers"); + chkUseExtendedTOEForceName = new CampaignOptionsCheckBox("UseExtendedTOEForceName"); + chkPersonnelLogSkillGain = new CampaignOptionsCheckBox("PersonnelLogSkillGain"); + chkPersonnelLogAbilityGain = new CampaignOptionsCheckBox("PersonnelLogAbilityGain"); + chkPersonnelLogEdgeGain = new CampaignOptionsCheckBox("PersonnelLogEdgeGain"); + chkDisplayPersonnelLog = new CampaignOptionsCheckBox("DisplayPersonnelLog"); + chkDisplayScenarioLog = new CampaignOptionsCheckBox("DisplayScenarioLog"); + chkDisplayKillRecord = new CampaignOptionsCheckBox("DisplayKillRecord"); // Layout the Panel - final JPanel panel = createStandardPanel("PersonnelLogsTab", true); + final JPanel panel = new CampaignOptionsStandardPanel("PersonnelLogsTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -515,21 +515,21 @@ JPanel createPersonnelLogsTab() { */ JPanel createPersonnelInformationTab() { // Header - JPanel headerPanel = createHeaderPanel("PersonnelInformation", + JPanel headerPanel = new CampaignOptionsHeaderPanel("PersonnelInformation", getImageDirectory() + "logo_comstar.png", true); // Contents - chkUseTimeInService = createCheckBox("UseTimeInService"); - lblTimeInServiceDisplayFormat = createLabel("TimeInServiceDisplayFormat"); - chkUseTimeInRank = createCheckBox("UseTimeInRank"); - lblTimeInRankDisplayFormat = createLabel("TimeInRankDisplayFormat"); - chkTrackTotalEarnings = createCheckBox("TrackTotalEarnings"); - chkTrackTotalXPEarnings = createCheckBox("TrackTotalXPEarnings"); - chkShowOriginFaction = createCheckBox("ShowOriginFaction"); + chkUseTimeInService = new CampaignOptionsCheckBox("UseTimeInService"); + lblTimeInServiceDisplayFormat = new CampaignOptionsLabel("TimeInServiceDisplayFormat"); + chkUseTimeInRank = new CampaignOptionsCheckBox("UseTimeInRank"); + lblTimeInRankDisplayFormat = new CampaignOptionsLabel("TimeInRankDisplayFormat"); + chkTrackTotalEarnings = new CampaignOptionsCheckBox("TrackTotalEarnings"); + chkTrackTotalXPEarnings = new CampaignOptionsCheckBox("TrackTotalXPEarnings"); + chkShowOriginFaction = new CampaignOptionsCheckBox("ShowOriginFaction"); // Layout the Panel - final JPanel panel = createStandardPanel("PersonnelInformation", true); + final JPanel panel = new CampaignOptionsStandardPanel("PersonnelInformation", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -577,18 +577,18 @@ JPanel createPersonnelInformationTab() { */ JPanel createAdministratorsTab() { // Header - JPanel headerPanel = createHeaderPanel("AdministratorsTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("AdministratorsTab", getImageDirectory() + "logo_clan_diamond_sharks.png", true); // Contents - chkAdminsHaveNegotiation = createCheckBox("AdminsHaveNegotiation"); - chkAdminExperienceLevelIncludeNegotiation = createCheckBox("AdminExperienceLevelIncludeNegotiation"); - chkAdminsHaveScrounge = createCheckBox("AdminsHaveScrounge"); - chkAdminExperienceLevelIncludeScrounge = createCheckBox("AdminExperienceLevelIncludeScrounge"); + chkAdminsHaveNegotiation = new CampaignOptionsCheckBox("AdminsHaveNegotiation"); + chkAdminExperienceLevelIncludeNegotiation = new CampaignOptionsCheckBox("AdminExperienceLevelIncludeNegotiation"); + chkAdminsHaveScrounge = new CampaignOptionsCheckBox("AdminsHaveScrounge"); + chkAdminExperienceLevelIncludeScrounge = new CampaignOptionsCheckBox("AdminExperienceLevelIncludeScrounge"); // Layout the Panel - final JPanel panel = createStandardPanel("AdministratorsTab", true); + final JPanel panel = new CampaignOptionsStandardPanel("AdministratorsTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -619,12 +619,12 @@ JPanel createAdministratorsTab() { */ JPanel createAwardsTab() { // Header - JPanel headerPanel = createHeaderPanel("AwardsTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("AwardsTab", getImageDirectory() + "logo_draconis_combine.png", true); // Contents - lblAwardBonusStyle = createLabel("AwardBonusStyle"); + lblAwardBonusStyle = new CampaignOptionsLabel("AwardBonusStyle"); comboAwardBonusStyle.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, @@ -638,21 +638,21 @@ public Component getListCellRendererComponent(final JList list, final Object } }); - lblAwardTierSize = createLabel("AwardTierSize"); - spnAwardTierSize = createSpinner("AwardTierSize", + lblAwardTierSize = new CampaignOptionsLabel("AwardTierSize"); + spnAwardTierSize = new CampaignOptionsSpinner("AwardTierSize", 5, 1, 100, 1); - chkEnableAutoAwards = createCheckBox("EnableAutoAwards"); + chkEnableAutoAwards = new CampaignOptionsCheckBox("EnableAutoAwards"); - chkIssuePosthumousAwards = createCheckBox("IssuePosthumousAwards"); + chkIssuePosthumousAwards = new CampaignOptionsCheckBox("IssuePosthumousAwards"); - chkIssueBestAwardOnly = createCheckBox("IssueBestAwardOnly"); + chkIssueBestAwardOnly = new CampaignOptionsCheckBox("IssueBestAwardOnly"); - chkIgnoreStandardSet = createCheckBox("IgnoreStandardSet"); + chkIgnoreStandardSet = new CampaignOptionsCheckBox("IgnoreStandardSet"); autoAwardsFilterPanel = createAutoAwardsFilterPanel(); - lblAwardSetFilterList = createLabel("AwardSetFilterList"); + lblAwardSetFilterList = new CampaignOptionsLabel("AwardSetFilterList"); txtAwardSetFilterList = new JTextArea(5, 20); txtAwardSetFilterList.setLineWrap(true); txtAwardSetFilterList.setWrapStyleWord(true); @@ -667,7 +667,7 @@ public Component getListCellRendererComponent(final JList list, final Object ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); // Layout the Panel - final JPanel panel = createStandardPanel("AwardsTab", true); + final JPanel panel = new CampaignOptionsStandardPanel("AwardsTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -720,21 +720,21 @@ public Component getListCellRendererComponent(final JList list, final Object */ private JPanel createAutoAwardsFilterPanel() { // Contents - chkEnableContractAwards = createCheckBox("EnableContractAwards"); - chkEnableFactionHunterAwards = createCheckBox("EnableFactionHunterAwards"); - chkEnableInjuryAwards = createCheckBox("EnableInjuryAwards"); - chkEnableIndividualKillAwards = createCheckBox("EnableIndividualKillAwards"); - chkEnableFormationKillAwards = createCheckBox("EnableFormationKillAwards"); - chkEnableRankAwards = createCheckBox("EnableRankAwards"); - chkEnableScenarioAwards = createCheckBox("EnableScenarioAwards"); - chkEnableSkillAwards = createCheckBox("EnableSkillAwards"); - chkEnableTheatreOfWarAwards = createCheckBox("EnableTheatreOfWarAwards"); - chkEnableTimeAwards = createCheckBox("EnableTimeAwards"); - chkEnableTrainingAwards = createCheckBox("EnableTrainingAwards"); - chkEnableMiscAwards = createCheckBox("EnableMiscAwards"); + chkEnableContractAwards = new CampaignOptionsCheckBox("EnableContractAwards"); + chkEnableFactionHunterAwards = new CampaignOptionsCheckBox("EnableFactionHunterAwards"); + chkEnableInjuryAwards = new CampaignOptionsCheckBox("EnableInjuryAwards"); + chkEnableIndividualKillAwards = new CampaignOptionsCheckBox("EnableIndividualKillAwards"); + chkEnableFormationKillAwards = new CampaignOptionsCheckBox("EnableFormationKillAwards"); + chkEnableRankAwards = new CampaignOptionsCheckBox("EnableRankAwards"); + chkEnableScenarioAwards = new CampaignOptionsCheckBox("EnableScenarioAwards"); + chkEnableSkillAwards = new CampaignOptionsCheckBox("EnableSkillAwards"); + chkEnableTheatreOfWarAwards = new CampaignOptionsCheckBox("EnableTheatreOfWarAwards"); + chkEnableTimeAwards = new CampaignOptionsCheckBox("EnableTimeAwards"); + chkEnableTrainingAwards = new CampaignOptionsCheckBox("EnableTrainingAwards"); + chkEnableMiscAwards = new CampaignOptionsCheckBox("EnableMiscAwards"); // Layout the Panel - final JPanel panel = createStandardPanel("AutoAwardsFilterPanel", true, "AutoAwardsFilterPanel"); + final JPanel panel = new CampaignOptionsStandardPanel("AutoAwardsFilterPanel", true, "AutoAwardsFilterPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -789,7 +789,7 @@ private JPanel createAutoAwardsFilterPanel() { */ JPanel createPrisonersAndDependentsTab() { // Header - JPanel headerPanel = createHeaderPanel("PrisonersAndDependentsTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("PrisonersAndDependentsTab", getImageDirectory() + "logo_clan_fire_mandrills.png", true); @@ -798,7 +798,7 @@ JPanel createPrisonersAndDependentsTab() { dependentsPanel = createDependentsPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("PrisonersAndDependentsTab", true, + final JPanel panel = new CampaignOptionsStandardPanel("PrisonersAndDependentsTab", true, ""); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -830,7 +830,7 @@ JPanel createPrisonersAndDependentsTab() { */ private JPanel createPrisonersPanel() { // Contents - lblPrisonerCaptureStyle = createLabel("PrisonerCaptureStyle"); + lblPrisonerCaptureStyle = new CampaignOptionsLabel("PrisonerCaptureStyle"); comboPrisonerCaptureStyle.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, @@ -844,14 +844,14 @@ public Component getListCellRendererComponent(final JList list, final Object } }); - lblPrisonerStatus = createLabel("PrisonerStatus"); + lblPrisonerStatus = new CampaignOptionsLabel("PrisonerStatus"); - chkPrisonerBabyStatus = createCheckBox("PrisonerBabyStatus"); - chkAtBPrisonerDefection = createCheckBox("AtBPrisonerDefection"); - chkAtBPrisonerRansom = createCheckBox("AtBPrisonerRansom"); + chkPrisonerBabyStatus = new CampaignOptionsCheckBox("PrisonerBabyStatus"); + chkAtBPrisonerDefection = new CampaignOptionsCheckBox("AtBPrisonerDefection"); + chkAtBPrisonerRansom = new CampaignOptionsCheckBox("AtBPrisonerRansom"); // Layout the Panel - final JPanel panel = createStandardPanel("PrisonersPanel", true, "PrisonersPanel"); + final JPanel panel = new CampaignOptionsStandardPanel("PrisonersPanel", true, "PrisonersPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -889,11 +889,11 @@ public Component getListCellRendererComponent(final JList list, final Object */ private JPanel createDependentsPanel() { // Contents - chkUseRandomDependentAddition = createCheckBox("UseRandomDependentAddition"); - chkUseRandomDependentRemoval = createCheckBox("UseRandomDependentRemoval"); + chkUseRandomDependentAddition = new CampaignOptionsCheckBox("UseRandomDependentAddition"); + chkUseRandomDependentRemoval = new CampaignOptionsCheckBox("UseRandomDependentRemoval"); // Layout the Panel - final JPanel panel = createStandardPanel("DependentsPanel", true, "DependentsPanel"); + final JPanel panel = new CampaignOptionsStandardPanel("DependentsPanel", true, "DependentsPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -917,35 +917,35 @@ private JPanel createDependentsPanel() { */ JPanel createMedicalTab() { // Header - JPanel headerPanel = createHeaderPanel("MedicalTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("MedicalTab", getImageDirectory() + "logo_duchy_of_tamarind_abbey.png", true); // Contents - chkUseAdvancedMedical = createCheckBox("UseAdvancedMedical"); + chkUseAdvancedMedical = new CampaignOptionsCheckBox("UseAdvancedMedical"); - lblHealWaitingPeriod = createLabel("HealWaitingPeriod"); - spnHealWaitingPeriod = createSpinner("HealWaitingPeriod", + lblHealWaitingPeriod = new CampaignOptionsLabel("HealWaitingPeriod"); + spnHealWaitingPeriod = new CampaignOptionsSpinner("HealWaitingPeriod", 1, 1, 30, 1); - lblNaturalHealWaitingPeriod = createLabel("NaturalHealWaitingPeriod"); - spnNaturalHealWaitingPeriod = createSpinner("NaturalHealWaitingPeriod", + lblNaturalHealWaitingPeriod = new CampaignOptionsLabel("NaturalHealWaitingPeriod"); + spnNaturalHealWaitingPeriod = new CampaignOptionsSpinner("NaturalHealWaitingPeriod", 1, 1, 365, 1); - lblMinimumHitsForVehicles = createLabel("MinimumHitsForVehicles"); - spnMinimumHitsForVehicles = createSpinner("MinimumHitsForVehicles", + lblMinimumHitsForVehicles = new CampaignOptionsLabel("MinimumHitsForVehicles"); + spnMinimumHitsForVehicles = new CampaignOptionsSpinner("MinimumHitsForVehicles", 1, 1, 5, 1); - chkUseRandomHitsForVehicles = createCheckBox("UseRandomHitsForVehicles"); + chkUseRandomHitsForVehicles = new CampaignOptionsCheckBox("UseRandomHitsForVehicles"); - chkUseTougherHealing = createCheckBox("UseTougherHealing"); + chkUseTougherHealing = new CampaignOptionsCheckBox("UseTougherHealing"); - lblMaximumPatients = createLabel("MaximumPatients"); - spnMaximumPatients = createSpinner("MaximumPatients", + lblMaximumPatients = new CampaignOptionsLabel("MaximumPatients"); + spnMaximumPatients = new CampaignOptionsSpinner("MaximumPatients", 25, 1, 100, 1); // Layout the Panel - final JPanel panel = createStandardPanel("MedicalTab", true); + final JPanel panel = new CampaignOptionsStandardPanel("MedicalTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -998,18 +998,18 @@ JPanel createMedicalTab() { */ JPanel createSalariesTab() { // Header - JPanel headerPanel = createHeaderPanel("SalariesTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("SalariesTab", getImageDirectory() + "logo_clan_ghost_bear.png", true); // Contents - chkDisableSecondaryRoleSalary = createCheckBox("DisableSecondaryRoleSalary"); + chkDisableSecondaryRoleSalary = new CampaignOptionsCheckBox("DisableSecondaryRoleSalary"); pnlSalaryMultipliersPanel = createSalaryMultipliersPanel(); pnlSalaryExperienceMultipliersPanel = createExperienceMultipliersPanel(); pnlSalaryBaseSalaryPanel = createBaseSalariesPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("SalariesTab", true); + final JPanel panel = new CampaignOptionsStandardPanel("SalariesTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -1040,16 +1040,16 @@ JPanel createSalariesTab() { */ private JPanel createSalaryMultipliersPanel() { // Contents - lblAntiMekSalary = createLabel("AntiMekSalary"); - spnAntiMekSalary = createSpinner("AntiMekSalary", + lblAntiMekSalary = new CampaignOptionsLabel("AntiMekSalary"); + spnAntiMekSalary = new CampaignOptionsSpinner("AntiMekSalary", 0, 0, 100, 0.05); - lblSpecialistInfantrySalary = createLabel("SpecialistInfantrySalary"); - spnSpecialistInfantrySalary = createSpinner("SpecialistInfantrySalary", + lblSpecialistInfantrySalary = new CampaignOptionsLabel("SpecialistInfantrySalary"); + spnSpecialistInfantrySalary = new CampaignOptionsSpinner("SpecialistInfantrySalary", 0, 0, 100, 0.05); // Layout the Panel - final JPanel panel = createStandardPanel("SalaryMultipliersPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("SalaryMultipliersPanel", true, "SalaryMultipliersPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -1085,17 +1085,17 @@ private JPanel createSalaryMultipliersPanel() { private JPanel createExperienceMultipliersPanel() { // Contents for (final SkillLevel skillLevel : Skills.SKILL_LEVELS) { - final JLabel label = createLabel("SkillLevel" + skillLevel.toString()); + final JLabel label = new CampaignOptionsLabel("SkillLevel" + skillLevel.toString()); lblSalaryExperienceMultipliers.put(skillLevel, label); - final JSpinner spinner = createSpinner("SkillLevel" + skillLevel, + final JSpinner spinner = new CampaignOptionsSpinner("SkillLevel" + skillLevel, 0, 0, 10, 0.05); spnSalaryExperienceMultipliers.put(skillLevel, spinner); } // Layout the Panel - final JPanel panel = createStandardPanel("ExperienceMultipliersPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("ExperienceMultipliersPanel", true, "ExperienceMultipliersPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -1179,7 +1179,7 @@ private JPanel createBaseSalariesPanel() { } // Layout the Panel - final JPanel panel = createStandardPanel("BaseSalariesPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("BaseSalariesPanel", true, "BaseSalariesPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java index 9a89aa316a..e8393fe928 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java @@ -208,7 +208,7 @@ private void initializeMarriageTab() { */ JPanel createMarriageTab() { // Header - JPanel headerPanel = createHeaderPanel("MarriageTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("MarriageTab", getImageDirectory() + "logo_federated_commonwealth.png", true); @@ -217,7 +217,7 @@ JPanel createMarriageTab() { pnlRandomMarriage = createRandomMarriagePanel(); // Layout the Panel - final JPanel panel = createStandardPanel("MarriageTab", true); + final JPanel panel = new CampaignOptionsStandardPanel("MarriageTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -248,22 +248,22 @@ JPanel createMarriageTab() { */ private JPanel createMarriageGeneralOptionsPanel() { // Contents - chkUseManualMarriages = createCheckBox("UseManualMarriages"); - chkUseClanPersonnelMarriages = createCheckBox("UseClanPersonnelMarriages"); - chkUsePrisonerMarriages = createCheckBox("UsePrisonerMarriages"); + chkUseManualMarriages = new CampaignOptionsCheckBox("UseManualMarriages"); + chkUseClanPersonnelMarriages = new CampaignOptionsCheckBox("UseClanPersonnelMarriages"); + chkUsePrisonerMarriages = new CampaignOptionsCheckBox("UsePrisonerMarriages"); - lblNoInterestInMarriageDiceSize = createLabel("NoInterestInMarriageDiceSize"); - spnNoInterestInMarriageDiceSize = createSpinner("NoInterestInMarriageDiceSize", + lblNoInterestInMarriageDiceSize = new CampaignOptionsLabel("NoInterestInMarriageDiceSize"); + spnNoInterestInMarriageDiceSize = new CampaignOptionsSpinner("NoInterestInMarriageDiceSize", 10, 1, 100000, 1); - lblCheckMutualAncestorsDepth = createLabel("CheckMutualAncestorsDepth"); - spnCheckMutualAncestorsDepth = createSpinner("CheckMutualAncestorsDepth", + lblCheckMutualAncestorsDepth = new CampaignOptionsLabel("CheckMutualAncestorsDepth"); + spnCheckMutualAncestorsDepth = new CampaignOptionsSpinner("CheckMutualAncestorsDepth", 4, 0, 20, 1); - chkLogMarriageNameChanges = createCheckBox("LogMarriageNameChanges"); + chkLogMarriageNameChanges = new CampaignOptionsCheckBox("LogMarriageNameChanges"); // Layout the Panel - final JPanel panel = createStandardPanel("MarriageGeneralOptionsPanel", + final JPanel panel = new CampaignOptionsStandardPanel("MarriageGeneralOptionsPanel", false); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -310,7 +310,7 @@ private JPanel createMarriageGeneralOptionsPanel() { */ private JPanel createRandomMarriagePanel() { // Contents - lblRandomMarriageMethod = createLabel("RandomMarriageMethod"); + lblRandomMarriageMethod = new CampaignOptionsLabel("RandomMarriageMethod"); comboRandomMarriageMethod.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, @@ -324,17 +324,17 @@ public Component getListCellRendererComponent(final JList list, final Object } }); - chkUseRandomClanPersonnelMarriages = createCheckBox("UseRandomClanPersonnelMarriages"); - chkUseRandomPrisonerMarriages = createCheckBox("UseRandomPrisonerMarriages"); + chkUseRandomClanPersonnelMarriages = new CampaignOptionsCheckBox("UseRandomClanPersonnelMarriages"); + chkUseRandomPrisonerMarriages = new CampaignOptionsCheckBox("UseRandomPrisonerMarriages"); - lblRandomMarriageAgeRange = createLabel("RandomMarriageAgeRange"); - spnRandomMarriageAgeRange = createSpinner("RandomMarriageAgeRange", + lblRandomMarriageAgeRange = new CampaignOptionsLabel("RandomMarriageAgeRange"); + spnRandomMarriageAgeRange = new CampaignOptionsSpinner("RandomMarriageAgeRange", 10, 0, 100, 1.0); pnlPercentageRandomMarriage = createPercentageRandomMarriagePanel(); // Layout the Panel - final JPanel panel = createStandardPanel("RandomMarriages", true, + final JPanel panel = new CampaignOptionsStandardPanel("RandomMarriages", true, "RandomMarriages"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -378,21 +378,20 @@ public Component getListCellRendererComponent(final JList list, final Object */ private JPanel createPercentageRandomMarriagePanel() { // Contents - lblRandomMarriageOppositeSexDiceSize = createLabel("RandomMarriageOppositeSexDiceSize", - null); - spnRandomMarriageDiceSize = createSpinner("RandomMarriageOppositeSexDiceSize", - null, 5000, 0, 100000, 1); + lblRandomMarriageOppositeSexDiceSize = new CampaignOptionsLabel("RandomMarriageOppositeSexDiceSize"); + spnRandomMarriageDiceSize = new CampaignOptionsSpinner("RandomMarriageOppositeSexDiceSize", + 5000, 0, 100000, 1); - lblRandomSameSexMarriageDiceSize = createLabel("RandomSameSexMarriageDiceSize"); - spnRandomSameSexMarriageDiceSize = createSpinner("RandomSameSexMarriageDiceSize", - null, 14, 0, 100000, 1); + lblRandomSameSexMarriageDiceSize = new CampaignOptionsLabel("RandomSameSexMarriageDiceSize"); + spnRandomSameSexMarriageDiceSize = new CampaignOptionsSpinner("RandomSameSexMarriageDiceSize", + 14, 0, 100000, 1); - lblRandomNewDependentMarriage = createLabel("RandomNewDependentMarriage"); - spnRandomNewDependentMarriage = createSpinner("RandomSameSexMarriageDiceSize", - null, 20, 0, 100000, 1); + lblRandomNewDependentMarriage = new CampaignOptionsLabel("RandomNewDependentMarriage"); + spnRandomNewDependentMarriage = new CampaignOptionsSpinner("RandomSameSexMarriageDiceSize", + 20, 0, 100000, 1); // Layout the Panel - final JPanel panel = createStandardPanel("PercentageRandomMarriagePanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("PercentageRandomMarriagePanel", true, "PercentageRandomMarriagePanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -437,19 +436,19 @@ private JPanel createPercentageRandomMarriagePanel() { */ JPanel createDivorceTab() { // Header - JPanel headerPanel = createHeaderPanel("DivorceTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("DivorceTab", getImageDirectory() + "logo_clan_hells_horses.png", true); // Contents - chkUseManualDivorce = createCheckBox("UseManualDivorce"); - chkUseClanPersonnelDivorce = createCheckBox("UseClanPersonnelDivorce"); - chkUsePrisonerDivorce = createCheckBox("UsePrisonerDivorce"); + chkUseManualDivorce = new CampaignOptionsCheckBox("UseManualDivorce"); + chkUseClanPersonnelDivorce = new CampaignOptionsCheckBox("UseClanPersonnelDivorce"); + chkUsePrisonerDivorce = new CampaignOptionsCheckBox("UsePrisonerDivorce"); pnlRandomDivorce = createRandomDivorcePanel(); // Layout the Panel - final JPanel panel = createStandardPanel("DivorceTab", true); + final JPanel panel = new CampaignOptionsStandardPanel("DivorceTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -482,7 +481,7 @@ JPanel createDivorceTab() { */ private JPanel createRandomDivorcePanel() { // Contents - lblRandomDivorceMethod = createLabel("RandomDivorceMethod"); + lblRandomDivorceMethod = new CampaignOptionsLabel("RandomDivorceMethod"); comboRandomDivorceMethod.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, @@ -496,17 +495,17 @@ public Component getListCellRendererComponent(final JList list, final Object } }); - chkUseRandomOppositeSexDivorce = createCheckBox("UseRandomOppositeSexDivorce"); - chkUseRandomSameSexDivorce = createCheckBox("UseRandomSameSexDivorce"); - chkUseRandomClanPersonnelDivorce = createCheckBox("UseRandomClanPersonnelDivorce"); - chkUseRandomPrisonerDivorce = createCheckBox("UseRandomPrisonerDivorce"); + chkUseRandomOppositeSexDivorce = new CampaignOptionsCheckBox("UseRandomOppositeSexDivorce"); + chkUseRandomSameSexDivorce = new CampaignOptionsCheckBox("UseRandomSameSexDivorce"); + chkUseRandomClanPersonnelDivorce = new CampaignOptionsCheckBox("UseRandomClanPersonnelDivorce"); + chkUseRandomPrisonerDivorce = new CampaignOptionsCheckBox("UseRandomPrisonerDivorce"); - lblRandomDivorceDiceSize = createLabel("RandomDivorceDiceSize"); - spnRandomDivorceDiceSize = createSpinner("RandomDivorceDiceSize", + lblRandomDivorceDiceSize = new CampaignOptionsLabel("RandomDivorceDiceSize"); + spnRandomDivorceDiceSize = new CampaignOptionsSpinner("RandomDivorceDiceSize", 900, 0, 100000, 1); // Layout the Panel - final JPanel panel = createStandardPanel("RandomDivorcePanel", true, "RandomDivorcePanel"); + final JPanel panel = new CampaignOptionsStandardPanel("RandomDivorcePanel", true, "RandomDivorcePanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -550,7 +549,7 @@ public Component getListCellRendererComponent(final JList list, final Object */ JPanel createProcreationTab() { // Header - JPanel headerPanel = createHeaderPanel("ProcreationTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("ProcreationTab", getImageDirectory() + "logo_clan_ice_hellion.png", true); @@ -559,7 +558,7 @@ JPanel createProcreationTab() { pnlRandomProcreationPanel = createRandomProcreationPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("ProcreationTab", true); + final JPanel panel = new CampaignOptionsStandardPanel("ProcreationTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -588,15 +587,15 @@ JPanel createProcreationTab() { */ private JPanel createProcreationGeneralOptionsPanel() { // Contents - chkUseManualProcreation = createCheckBox("UseManualProcreation"); - chkUseClanPersonnelProcreation = createCheckBox("UseClanPersonnelProcreation"); - chkUsePrisonerProcreation = createCheckBox("UsePrisonerProcreation"); + chkUseManualProcreation = new CampaignOptionsCheckBox("UseManualProcreation"); + chkUseClanPersonnelProcreation = new CampaignOptionsCheckBox("UseClanPersonnelProcreation"); + chkUsePrisonerProcreation = new CampaignOptionsCheckBox("UsePrisonerProcreation"); - lblMultiplePregnancyOccurrences = createLabel("MultiplePregnancyOccurrences"); - spnMultiplePregnancyOccurrences = createSpinner("MultiplePregnancyOccurrences", + lblMultiplePregnancyOccurrences = new CampaignOptionsLabel("MultiplePregnancyOccurrences"); + spnMultiplePregnancyOccurrences = new CampaignOptionsSpinner("MultiplePregnancyOccurrences", 50, 1, 1000, 1); - lblBabySurnameStyle = createLabel("BabySurnameStyle"); + lblBabySurnameStyle = new CampaignOptionsLabel("BabySurnameStyle"); comboBabySurnameStyle.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, @@ -610,24 +609,22 @@ public Component getListCellRendererComponent(final JList list, final Object } }); - chkAssignNonPrisonerBabiesFounderTag = createCheckBox("AssignNonPrisonerBabiesFounderTag", - null); - chkAssignChildrenOfFoundersFounderTag = createCheckBox("AssignChildrenOfFoundersFounderTag", - null); - chkDetermineFatherAtBirth = createCheckBox("DetermineFatherAtBirth"); - chkDisplayTrueDueDate = createCheckBox("DisplayTrueDueDate"); + chkAssignNonPrisonerBabiesFounderTag = new CampaignOptionsCheckBox("AssignNonPrisonerBabiesFounderTag"); + chkAssignChildrenOfFoundersFounderTag = new CampaignOptionsCheckBox("AssignChildrenOfFoundersFounderTag"); + chkDetermineFatherAtBirth = new CampaignOptionsCheckBox("DetermineFatherAtBirth"); + chkDisplayTrueDueDate = new CampaignOptionsCheckBox("DisplayTrueDueDate"); - lblNoInterestInChildrenDiceSize = createLabel("NoInterestInChildrenDiceSize"); - spnNoInterestInChildrenDiceSize = createSpinner("NoInterestInChildrenDiceSize", + lblNoInterestInChildrenDiceSize = new CampaignOptionsLabel("NoInterestInChildrenDiceSize"); + spnNoInterestInChildrenDiceSize = new CampaignOptionsSpinner("NoInterestInChildrenDiceSize", 3, 1, 100000, 1); - chkUseMaternityLeave = createCheckBox("UseMaternityLeave"); - chkLogProcreation = createCheckBox("LogProcreation"); + chkUseMaternityLeave = new CampaignOptionsCheckBox("UseMaternityLeave"); + chkLogProcreation = new CampaignOptionsCheckBox("LogProcreation"); pnlRandomProcreationPanel = createRandomProcreationPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("ProcreationGeneralOptionsPanel", + final JPanel panel = new CampaignOptionsStandardPanel("ProcreationGeneralOptionsPanel", false); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -686,7 +683,7 @@ public Component getListCellRendererComponent(final JList list, final Object */ private JPanel createRandomProcreationPanel() { // Contents - lblRandomProcreationMethod = createLabel("RandomProcreationMethod"); + lblRandomProcreationMethod = new CampaignOptionsLabel("RandomProcreationMethod"); comboRandomProcreationMethod.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, @@ -700,24 +697,20 @@ public Component getListCellRendererComponent(final JList list, final Object } }); - chkUseRelationshiplessRandomProcreation =createCheckBox("UseRelationshiplessRandomProcreation", - null); - chkUseRandomClanPersonnelProcreation = createCheckBox("UseRandomClanPersonnelProcreation", - null); - chkUseRandomPrisonerProcreation = createCheckBox("UseRandomPrisonerProcreation"); + chkUseRelationshiplessRandomProcreation =new CampaignOptionsCheckBox("UseRelationshiplessRandomProcreation"); + chkUseRandomClanPersonnelProcreation = new CampaignOptionsCheckBox("UseRandomClanPersonnelProcreation"); + chkUseRandomPrisonerProcreation = new CampaignOptionsCheckBox("UseRandomPrisonerProcreation"); - lblRandomProcreationRelationshipDiceSize = createLabel("RandomProcreationRelationshipDiceSize", - null); - spnRandomProcreationRelationshipDiceSize = createSpinner("RandomProcreationRelationshipDiceSize", - null, 621, 0, 100000, 1); + lblRandomProcreationRelationshipDiceSize = new CampaignOptionsLabel("RandomProcreationRelationshipDiceSize"); + spnRandomProcreationRelationshipDiceSize = new CampaignOptionsSpinner("RandomProcreationRelationshipDiceSize", + 621, 0, 100000, 1); - lblRandomProcreationRelationshiplessDiceSize = createLabel("RandomProcreationRelationshiplessDiceSize", - null); - spnRandomProcreationRelationshiplessDiceSize = createSpinner("RandomProcreationRelationshiplessDiceSize", - null, 1861, 0, 100000, 1); + lblRandomProcreationRelationshiplessDiceSize = new CampaignOptionsLabel("RandomProcreationRelationshiplessDiceSize"); + spnRandomProcreationRelationshiplessDiceSize = new CampaignOptionsSpinner("RandomProcreationRelationshiplessDiceSize", + 1861, 0, 100000, 1); // Layout the Panel - final JPanel panel = createStandardPanel("RandomProcreationPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("RandomProcreationPanel", true, "RandomProcreationPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java index 0922d5fed3..c9060a4ad3 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java @@ -116,38 +116,38 @@ private void initializeMaintenanceTab() { */ JPanel createRepairTab() { // Header - JPanel headerPanel = createHeaderPanel("RepairTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("RepairTab", getImageDirectory() + "logo_aurigan_coalition.png", true); // Era Mods - useEraModsCheckBox = createCheckBox("UseEraModsCheckBox"); + useEraModsCheckBox = new CampaignOptionsCheckBox("UseEraModsCheckBox"); // Tech Placement - assignedTechFirstCheckBox = createCheckBox("AssignedTechFirstCheckBox"); - resetToFirstTechCheckBox = createCheckBox("ResetToFirstTechCheckBox"); + assignedTechFirstCheckBox = new CampaignOptionsCheckBox("AssignedTechFirstCheckBox"); + resetToFirstTechCheckBox = new CampaignOptionsCheckBox("ResetToFirstTechCheckBox"); // Use Quirks - useQuirksBox = createCheckBox("UseQuirksBox"); + useQuirksBox = new CampaignOptionsCheckBox("UseQuirksBox"); // Aero System Damage - useAeroSystemHitsBox = createCheckBox("UseAeroSystemHitsBox"); + useAeroSystemHitsBox = new CampaignOptionsCheckBox("UseAeroSystemHitsBox"); // Damage by Margin - useDamageMargin = createCheckBox("UseDamageMargin"); + useDamageMargin = new CampaignOptionsCheckBox("UseDamageMargin"); useDamageMargin.addActionListener(evt -> spnDamageMargin.setEnabled(useDamageMargin.isSelected())); - lblDamageMargin = createLabel("DamageMargin"); - spnDamageMargin = createSpinner("DamageMargin", + lblDamageMargin = new CampaignOptionsLabel("DamageMargin"); + spnDamageMargin = new CampaignOptionsSpinner("DamageMargin", 1, 1, 20, 1); // Equipment Survival - lblDestroyPartTarget = createLabel("DestroyPartTarget"); - spnDestroyPartTarget = createSpinner("DestroyPartTarget", + lblDestroyPartTarget = new CampaignOptionsLabel("DestroyPartTarget"); + spnDestroyPartTarget = new CampaignOptionsSpinner("DestroyPartTarget", 2, 2, 13, 1); JLabel lblDestroyPartTargetPost = new JLabel("+"); // Layout the Panel - final JPanel panel = createStandardPanel("repairTab", true); + final JPanel panel = new CampaignOptionsStandardPanel("repairTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -196,47 +196,47 @@ JPanel createRepairTab() { */ JPanel createMaintenanceTab() { // Header - JPanel headerPanel = createHeaderPanel("MaintenanceTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("MaintenanceTab", getImageDirectory() + "logo_clan_blood_spirit.png", true); // Check Maintenance - checkMaintenance = createCheckBox("CheckMaintenance"); + checkMaintenance = new CampaignOptionsCheckBox("CheckMaintenance"); // Maintenance Cycle Duration - lblMaintenanceDays = createLabel("MaintenanceDays"); - spnDamageMargin = createSpinner("MaintenanceDays", + lblMaintenanceDays = new CampaignOptionsLabel("MaintenanceDays"); + spnDamageMargin = new CampaignOptionsSpinner("MaintenanceDays", 7, 1, 365, 1); // Maintenance Bonus - lblMaintenanceBonus = createLabel("MaintenanceBonus"); - spnMaintenanceBonus = createSpinner("MaintenanceBonus", + lblMaintenanceBonus = new CampaignOptionsLabel("MaintenanceBonus"); + spnMaintenanceBonus = new CampaignOptionsSpinner("MaintenanceBonus", 0, -13, 13, 1); // Default Maintenance Time - lblDefaultMaintenanceTime = createLabel("DefaultMaintenanceTime"); - spnDefaultMaintenanceTime = createSpinner("DefaultMaintenanceTime", + lblDefaultMaintenanceTime = new CampaignOptionsLabel("DefaultMaintenanceTime"); + spnDefaultMaintenanceTime = new CampaignOptionsSpinner("DefaultMaintenanceTime", 1, 1, 4, 1); // Use Quality Modifiers - useQualityMaintenance = createCheckBox("UseQualityMaintenance"); + useQualityMaintenance = new CampaignOptionsCheckBox("UseQualityMaintenance"); // Reverse Quality names - reverseQualityNames = createCheckBox("ReverseQualityNames"); + reverseQualityNames = new CampaignOptionsCheckBox("ReverseQualityNames"); // Use Random Unit Qualities - chkUseRandomUnitQualities = createCheckBox("UseRandomUnitQualities"); + chkUseRandomUnitQualities = new CampaignOptionsCheckBox("UseRandomUnitQualities"); // Use Planetary Modifiers - chkUsePlanetaryModifiers = createCheckBox("UsePlanetaryModifiers"); + chkUsePlanetaryModifiers = new CampaignOptionsCheckBox("UsePlanetaryModifiers"); // Only Damage F-Rated Equipment - useUnofficialMaintenance = createCheckBox("UseUnofficialMaintenance"); + useUnofficialMaintenance = new CampaignOptionsCheckBox("UseUnofficialMaintenance"); // Report Maintenance checks to Log - logMaintenance = createCheckBox("LogMaintenance"); + logMaintenance = new CampaignOptionsCheckBox("LogMaintenance"); // Layout the Panel - final JPanel panel = createStandardPanel("repairTab", true); + final JPanel panel = new CampaignOptionsStandardPanel("repairTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/RulesetsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/RulesetsTab.java index fb529b91ab..16341ed189 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/RulesetsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/RulesetsTab.java @@ -188,23 +188,23 @@ private void initializeUniversalOptions() { private void substantializeUniversalOptions() { // General - lblSkillLevel = createLabel("SkillLevel"); + lblSkillLevel = new CampaignOptionsLabel("SkillLevel"); comboSkillLevel.setToolTipText(resources.getString("lblSkillLevel.tooltip")); // OpFor Generation pnlUnitRatioPanel = createUniversalUnitRatioPanel(); - chkUseDropShips = createCheckBox("UseDropShips"); - chkOpForUsesVTOLs = createCheckBox("OpForUsesVTOLs"); - chkClanVehicles = createCheckBox("ClanVehicles"); - chkRegionalMekVariations = createCheckBox("RegionalMekVariations"); + chkUseDropShips = new CampaignOptionsCheckBox("UseDropShips"); + chkOpForUsesVTOLs = new CampaignOptionsCheckBox("OpForUsesVTOLs"); + chkClanVehicles = new CampaignOptionsCheckBox("ClanVehicles"); + chkRegionalMekVariations = new CampaignOptionsCheckBox("RegionalMekVariations"); - chkAttachedPlayerCamouflage = createCheckBox("AttachedPlayerCamouflage"); - chkPlayerControlsAttachedUnits = createCheckBox("PlayerControlsAttachedUnits"); - lblSPAUpgradeIntensity = createLabel("SPAUpgradeIntensity"); - spnSPAUpgradeIntensity = createSpinner("SPAUpgradeIntensity", + chkAttachedPlayerCamouflage = new CampaignOptionsCheckBox("AttachedPlayerCamouflage"); + chkPlayerControlsAttachedUnits = new CampaignOptionsCheckBox("PlayerControlsAttachedUnits"); + lblSPAUpgradeIntensity = new CampaignOptionsLabel("SPAUpgradeIntensity"); + spnSPAUpgradeIntensity = new CampaignOptionsSpinner("SPAUpgradeIntensity", 0, -1, 3, 1); - chkAutoConfigMunitions = createCheckBox("AutoConfigMunitions"); + chkAutoConfigMunitions = new CampaignOptionsCheckBox("AutoConfigMunitions"); // Other pnlScenarioModifiers = createUniversalModifiersPanel(); @@ -228,7 +228,7 @@ private static DefaultComboBoxModel getSkillLevelOptions() { private JPanel createUniversalScenarioGenerationPanel() { // Layout the panel - final JPanel panel = createStandardPanel("UniversalScenarioGenerationPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("UniversalScenarioGenerationPanel", true, "UniversalScenarioGenerationPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -268,18 +268,18 @@ private JPanel createUniversalScenarioGenerationPanel() { private JPanel createUniversalUnitRatioPanel() { // Content - lblOpForLanceTypeMeks = createLabel("OpForLanceTypeMeks"); - spnOpForLanceTypeMeks = createSpinner("OpForLanceTypeMeks", + lblOpForLanceTypeMeks = new CampaignOptionsLabel("OpForLanceTypeMeks"); + spnOpForLanceTypeMeks = new CampaignOptionsSpinner("OpForLanceTypeMeks", 0, 0, 10, 1); - lblOpForLanceTypeMixed = createLabel("OpForLanceTypeMixed"); - spnOpForLanceTypeMixed = createSpinner("OpForLanceTypeMixed", + lblOpForLanceTypeMixed = new CampaignOptionsLabel("OpForLanceTypeMixed"); + spnOpForLanceTypeMixed = new CampaignOptionsSpinner("OpForLanceTypeMixed", 0, 0, 10, 1); - lblOpForLanceTypeVehicle = createLabel("OpForLanceTypeVehicle"); - spnOpForLanceTypeVehicles = createSpinner("OpForLanceTypeVehicle", + lblOpForLanceTypeVehicle = new CampaignOptionsLabel("OpForLanceTypeVehicle"); + spnOpForLanceTypeVehicles = new CampaignOptionsSpinner("OpForLanceTypeVehicle", 0, 0, 10, 1); // Layout the panel - final JPanel panel = createStandardPanel("UniversalUnitRatioPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("UniversalUnitRatioPanel", true, "UniversalUnitRatioPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -309,18 +309,18 @@ private JPanel createUniversalUnitRatioPanel() { private JPanel createUniversalModifiersPanel() { //Content - lblScenarioModMax = createLabel("ScenarioModMax"); - spnScenarioModMax = createSpinner("ScenarioModMax", + lblScenarioModMax = new CampaignOptionsLabel("ScenarioModMax"); + spnScenarioModMax = new CampaignOptionsSpinner("ScenarioModMax", 3, 0, 10, 1); - lblScenarioModChance = createLabel("ScenarioModChance"); - spnScenarioModChance = createSpinner("ScenarioModChance", + lblScenarioModChance = new CampaignOptionsLabel("ScenarioModChance"); + spnScenarioModChance = new CampaignOptionsSpinner("ScenarioModChance", 25, 5, 100, 5); - lblScenarioModBV = createLabel("ScenarioModBV"); - spnScenarioModBV = createSpinner("ScenarioModBV", + lblScenarioModBV = new CampaignOptionsLabel("ScenarioModBV"); + spnScenarioModBV = new CampaignOptionsSpinner("ScenarioModBV", 50, 5, 100, 5); // Layout the panel - final JPanel panel = createStandardPanel("UniversalModifiersPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("UniversalModifiersPanel", true, "UniversalModifiersPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -354,15 +354,15 @@ private JPanel createUniversalModifiersPanel() { private JPanel createUniversalMapGenerationPanel() { // Content - chkUseWeatherConditions = createCheckBox("UseWeatherConditions"); - chkUseLightConditions = createCheckBox("UseLightConditions"); - chkUsePlanetaryConditions = createCheckBox("UsePlanetaryConditions"); - lblFixedMapChance = createLabel("FixedMapChance"); - spnFixedMapChance = createSpinner("FixedMapChance", + chkUseWeatherConditions = new CampaignOptionsCheckBox("UseWeatherConditions"); + chkUseLightConditions = new CampaignOptionsCheckBox("UseLightConditions"); + chkUsePlanetaryConditions = new CampaignOptionsCheckBox("UsePlanetaryConditions"); + lblFixedMapChance = new CampaignOptionsLabel("FixedMapChance"); + spnFixedMapChance = new CampaignOptionsSpinner("FixedMapChance", 0, 0, 100, 1); // Layout the panel - final JPanel panel = createStandardPanel("UniversalMapGenerationPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("UniversalMapGenerationPanel", true, "UniversalMapGenerationPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -390,7 +390,7 @@ private JPanel createUniversalMapGenerationPanel() { private JPanel createUniversalCampaignOptionsPanel() { // Layout the panel - final JPanel panel = createStandardPanel("UniversalCampaignOptionsPanel", false, + final JPanel panel = new CampaignOptionsStandardPanel("UniversalCampaignOptionsPanel", false, ""); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -410,16 +410,16 @@ private JPanel createUniversalCampaignOptionsPanel() { private JPanel createUniversalPartsPanel() { // Content - chkRestrictPartsByMission = createCheckBox("RestrictPartsByMission"); - lblBonusPartExchangeValue = createLabel("BonusPartExchangeValue"); - spnBonusPartExchangeValue = createSpinner("BonusPartExchangeValue", + chkRestrictPartsByMission = new CampaignOptionsCheckBox("RestrictPartsByMission"); + lblBonusPartExchangeValue = new CampaignOptionsLabel("BonusPartExchangeValue"); + spnBonusPartExchangeValue = new CampaignOptionsSpinner("BonusPartExchangeValue", 500000, 0, 1000000, 1); - lblBonusPartMaxExchangeCount = createLabel("BonusPartMaxExchangeCount"); - spnBonusPartMaxExchangeCount = createSpinner("BonusPartMaxExchangeCount", + lblBonusPartMaxExchangeCount = new CampaignOptionsLabel("BonusPartMaxExchangeCount"); + spnBonusPartMaxExchangeCount = new CampaignOptionsSpinner("BonusPartMaxExchangeCount", 10, 0, 100, 1); // Layout the panel - final JPanel panel = createStandardPanel("UniversalPartsPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("UniversalPartsPanel", true, "UniversalPartsPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -449,19 +449,19 @@ private JPanel createUniversalPartsPanel() { private JPanel createUniversalLancePanel() { // Content - chkLimitLanceWeight = createCheckBox("LimitLanceWeight"); - chkLimitLanceNumUnits = createCheckBox("LimitLanceNumUnits"); - chkUseStrategy = createCheckBox("UseStrategy"); - lblBaseStrategyDeployment = createLabel("BaseStrategyDeployment"); - spnBaseStrategyDeployment = createSpinner("BaseStrategyDeployment", + chkLimitLanceWeight = new CampaignOptionsCheckBox("LimitLanceWeight"); + chkLimitLanceNumUnits = new CampaignOptionsCheckBox("LimitLanceNumUnits"); + chkUseStrategy = new CampaignOptionsCheckBox("UseStrategy"); + lblBaseStrategyDeployment = new CampaignOptionsLabel("BaseStrategyDeployment"); + spnBaseStrategyDeployment = new CampaignOptionsSpinner("BaseStrategyDeployment", 0, 0, 10, 1); - lblAdditionalStrategyDeployment = createLabel("AdditionalStrategyDeployment"); - spnAdditionalStrategyDeployment = createSpinner("AdditionalStrategyDeployment", + lblAdditionalStrategyDeployment = new CampaignOptionsLabel("AdditionalStrategyDeployment"); + spnAdditionalStrategyDeployment = new CampaignOptionsSpinner("AdditionalStrategyDeployment", 0, 0, 10, 1); - chkAdjustPaymentForStrategy = createCheckBox("AdjustPaymentForStrategy"); + chkAdjustPaymentForStrategy = new CampaignOptionsCheckBox("AdjustPaymentForStrategy"); // Layout the panel - final JPanel panel = createStandardPanel("UniversalLancePanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("UniversalLancePanel", true, "UniversalLancePanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -503,17 +503,17 @@ private void initializeStratConTab() { JPanel createStratConTab() { // Header - JPanel headerPanel = createHeaderPanel("StratConTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("StratConTab", getImageDirectory() + "logo_lyran_alliance.png", true); // Content - chkUseStratCon = createCheckBox("UseStratCon"); - chkUseGenericBattleValue = createCheckBox("UseGenericBattleValue"); - chkUseVerboseBidding = createCheckBox("UseVerboseBidding"); + chkUseStratCon = new CampaignOptionsCheckBox("UseStratCon"); + chkUseGenericBattleValue = new CampaignOptionsCheckBox("UseGenericBattleValue"); + chkUseVerboseBidding = new CampaignOptionsCheckBox("UseVerboseBidding"); // Layout the Panel - final JPanel panel = createStandardPanel("StratConTab", true); + final JPanel panel = new CampaignOptionsStandardPanel("StratConTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -579,16 +579,16 @@ private void initializeLegacyTab() { JPanel createLegacyTab() { // Header - JPanel headerPanel = createHeaderPanel("LegacyTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("LegacyTab", getImageDirectory() + "logo_clan_snow_raven.png", true); - chkUseAtB = createCheckBox("UseAtB"); + chkUseAtB = new CampaignOptionsCheckBox("UseAtB"); pnlLegacyOpForGenerationPanel = createLegacyOpForGenerationPanel(); pnlLegacyScenarioGenerationPanel = createLegacyScenarioGenerationPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("LegacyTab", true, + final JPanel panel = new CampaignOptionsStandardPanel("LegacyTab", true, ""); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -615,17 +615,17 @@ JPanel createLegacyTab() { private JPanel createLegacyOpForGenerationPanel() { // Content - chkUseVehicles = createCheckBox("UseVehicles"); - chkDoubleVehicles = createCheckBox("DoubleVehicles"); - chkOpForUsesAero = createCheckBox("OpForUsesAero"); - lblOpForAeroChance = createLabel("OpForAeroChance"); - spnOpForAeroChance = createSpinner("OpForAeroChance", + chkUseVehicles = new CampaignOptionsCheckBox("UseVehicles"); + chkDoubleVehicles = new CampaignOptionsCheckBox("DoubleVehicles"); + chkOpForUsesAero = new CampaignOptionsCheckBox("OpForUsesAero"); + lblOpForAeroChance = new CampaignOptionsLabel("OpForAeroChance"); + spnOpForAeroChance = new CampaignOptionsSpinner("OpForAeroChance", 0, 0, 6, 1); - chkOpForUsesLocalForces = createCheckBox("OpForUsesLocalForces"); - chkAdjustPlayerVehicles = createCheckBox("AdjustPlayerVehicles"); + chkOpForUsesLocalForces = new CampaignOptionsCheckBox("OpForUsesLocalForces"); + chkAdjustPlayerVehicles = new CampaignOptionsCheckBox("AdjustPlayerVehicles"); // Layout the Panel - final JPanel panel = createStandardPanel("LegacyOpForGenerationPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("LegacyOpForGenerationPanel", true, "LegacyOpForGenerationPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -657,9 +657,9 @@ private JPanel createLegacyOpForGenerationPanel() { private JPanel createLegacyScenarioGenerationPanel() { // Content - chkGenerateChases = createCheckBox("GenerateChases"); - lblIntensity = createLabel("AtBBattleIntensity"); - spnAtBBattleIntensity = createSpinner("AtBBattleIntensity", + chkGenerateChases = new CampaignOptionsCheckBox("GenerateChases"); + lblIntensity = new CampaignOptionsLabel("AtBBattleIntensity"); + spnAtBBattleIntensity = new CampaignOptionsSpinner("AtBBattleIntensity", 0.0, 0.0, 100.0, 0.1); lblFightChance = new JLabel(AtBLanceRole.FIGHTING.toString()); @@ -673,10 +673,10 @@ private JPanel createLegacyScenarioGenerationPanel() { new SpinnerNumberModel(0, 0, 100, 1)); } - btnIntensityUpdate = createButton("IntensityUpdate"); + btnIntensityUpdate = new CampaignOptionsButton("IntensityUpdate"); // Layout the Panel - final JPanel panel = createStandardPanel("LegacyScenarioGenerationPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("LegacyScenarioGenerationPanel", true, "LegacyScenarioGenerationPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java index 5d5c5ba7ca..6f0f8dbd1d 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java @@ -22,6 +22,7 @@ import megamek.logging.MMLogger; import mekhq.MekHQ; import mekhq.campaign.CampaignPreset; +import mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.CampaignOptionsButton; import javax.swing.*; import javax.swing.GroupLayout.Alignment; @@ -29,9 +30,8 @@ import java.util.ResourceBundle; import static megamek.client.ui.WrapLayout.wordWrap; -import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.createButton; +import static megamek.client.ui.swing.util.FlatLafStyleBuilder.setFontScaling; import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.createStandardLayout; -import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.setFontScaling; /** * A dialog for selecting campaign presets. Extends {@link JDialog}. @@ -153,7 +153,7 @@ public Component getListCellRendererComponent(JList list, Object value, add(outerPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); - JButton buttonSelect = createButton("PresetDialogSelect"); + JButton buttonSelect = new CampaignOptionsButton("PresetDialogSelect"); buttonSelect.addActionListener(e -> { selectedPreset = (CampaignPreset) comboBox.getSelectedItem(); returnState = PRESET_SELECTION_SELECT; @@ -162,7 +162,7 @@ public Component getListCellRendererComponent(JList list, Object value, buttonSelect.setEnabled(includePresetSelectOption); buttonPanel.add(buttonSelect); - JButton buttonCustomize = createButton("PresetDialogCustomize"); + JButton buttonCustomize = new CampaignOptionsButton("PresetDialogCustomize"); buttonCustomize.addActionListener(e -> { selectedPreset = (CampaignPreset) comboBox.getSelectedItem(); returnState = PRESET_SELECTION_CUSTOMIZE; @@ -171,7 +171,7 @@ public Component getListCellRendererComponent(JList list, Object value, buttonCustomize.setEnabled(includeCustomizePresetOption); buttonPanel.add(buttonCustomize); - JButton buttonCancel = createButton("PresetDialogCancel"); + JButton buttonCancel = new CampaignOptionsButton("PresetDialogCancel"); buttonCancel.addActionListener(e -> { returnState = PRESET_SELECTION_CANCELLED; dispose(); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java index 040d0a55c8..c0d13bad8f 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java @@ -227,19 +227,19 @@ private void initializeTurnoverTab() { */ JPanel createTurnoverTab() { // Header - JPanel headerPanel = createHeaderPanel("TurnoverTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("TurnoverTab", getImageDirectory() + "logo_clan_jade_falcon.png", true); // Contents - chkUseRandomRetirement = createCheckBox("UseRandomRetirement"); + chkUseRandomRetirement = new CampaignOptionsCheckBox("UseRandomRetirement"); pnlSettings = createSettingsPanel(); pnlModifiers = createModifiersPanel(); pnlPayout = createPayoutsPanel(); pnlUnitCohesion = createUnitCohesionPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("TurnoverTab", true); + final JPanel panel = new CampaignOptionsStandardPanel("TurnoverTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -285,11 +285,11 @@ JPanel createTurnoverTab() { */ private JPanel createSettingsPanel() { // Contents - lblTurnoverFixedTargetNumber = createLabel("TurnoverFixedTargetNumber"); - spnTurnoverFixedTargetNumber = createSpinner("TurnoverFixedTargetNumber", + lblTurnoverFixedTargetNumber = new CampaignOptionsLabel("TurnoverFixedTargetNumber"); + spnTurnoverFixedTargetNumber = new CampaignOptionsSpinner("TurnoverFixedTargetNumber", 3, 0, 10, 1); - lblTurnoverFrequency = createLabel("TurnoverFrequency"); + lblTurnoverFrequency = new CampaignOptionsLabel("TurnoverFrequency"); comboTurnoverFrequency.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, @@ -303,33 +303,33 @@ public Component getListCellRendererComponent(final JList list, final Object } }); - chkUseContractCompletionRandomRetirement = createCheckBox( + chkUseContractCompletionRandomRetirement = new CampaignOptionsCheckBox( "UseContractCompletionRandomRetirement"); - chkUseRandomFounderTurnover = createCheckBox("UseRandomFounderTurnover"); + chkUseRandomFounderTurnover = new CampaignOptionsCheckBox("UseRandomFounderTurnover"); - chkTrackOriginalUnit = createCheckBox("TrackOriginalUnit"); + chkTrackOriginalUnit = new CampaignOptionsCheckBox("TrackOriginalUnit"); - chkAeroRecruitsHaveUnits = createCheckBox("AeroRecruitsHaveUnits"); + chkAeroRecruitsHaveUnits = new CampaignOptionsCheckBox("AeroRecruitsHaveUnits"); - chkUseSubContractSoldiers = createCheckBox("UseSubContractSoldiers"); + chkUseSubContractSoldiers = new CampaignOptionsCheckBox("UseSubContractSoldiers"); - lblServiceContractDuration = createLabel("ServiceContractDuration"); - spnServiceContractDuration = createSpinner("ServiceContractDuration", + lblServiceContractDuration = new CampaignOptionsLabel("ServiceContractDuration"); + spnServiceContractDuration = new CampaignOptionsSpinner("ServiceContractDuration", 36, 0, 120, 1); - lblServiceContractModifier = createLabel("ServiceContractModifier"); - spnServiceContractModifier = createSpinner("ServiceContractModifier", + lblServiceContractModifier = new CampaignOptionsLabel("ServiceContractModifier"); + spnServiceContractModifier = new CampaignOptionsSpinner("ServiceContractModifier", 3, 0, 10, 1); - chkPayBonusDefault = createCheckBox("PayBonusDefault"); + chkPayBonusDefault = new CampaignOptionsCheckBox("PayBonusDefault"); - lblPayBonusDefaultThreshold = createLabel("PayBonusDefaultThreshold"); - spnPayBonusDefaultThreshold = createSpinner("PayBonusDefaultThreshold", + lblPayBonusDefaultThreshold = new CampaignOptionsLabel("PayBonusDefaultThreshold"); + spnPayBonusDefaultThreshold = new CampaignOptionsSpinner("PayBonusDefaultThreshold", 3, 0, 12, 1); // Layout the Panel - final JPanel panel = createStandardPanel("SettingsPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("SettingsPanel", true, "SettingsPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -405,21 +405,21 @@ public Component getListCellRendererComponent(final JList list, final Object */ private JPanel createModifiersPanel() { // Contents - chkUseCustomRetirementModifiers = createCheckBox("UseCustomRetirementModifiers"); - chkUseFatigueModifiers = createCheckBox("UseFatigueModifiers"); - chkUseSkillModifiers = createCheckBox("UseSkillModifiers"); - chkUseAgeModifiers = createCheckBox("UseAgeModifiers"); - chkUseUnitRatingModifiers = createCheckBox("UseUnitRatingModifiers"); - chkUseFactionModifiers = createCheckBox("UseFactionModifiers"); - chkUseMissionStatusModifiers = createCheckBox("UseMissionStatusModifiers"); - chkUseHostileTerritoryModifiers = createCheckBox("UseHostileTerritoryModifiers"); - chkUseFamilyModifiers = createCheckBox("UseFamilyModifiers"); - chkUseLoyaltyModifiers = createCheckBox("UseLoyaltyModifiers"); - chkUseHideLoyalty = createCheckBox("UseHideLoyalty"); + chkUseCustomRetirementModifiers = new CampaignOptionsCheckBox("UseCustomRetirementModifiers"); + chkUseFatigueModifiers = new CampaignOptionsCheckBox("UseFatigueModifiers"); + chkUseSkillModifiers = new CampaignOptionsCheckBox("UseSkillModifiers"); + chkUseAgeModifiers = new CampaignOptionsCheckBox("UseAgeModifiers"); + chkUseUnitRatingModifiers = new CampaignOptionsCheckBox("UseUnitRatingModifiers"); + chkUseFactionModifiers = new CampaignOptionsCheckBox("UseFactionModifiers"); + chkUseMissionStatusModifiers = new CampaignOptionsCheckBox("UseMissionStatusModifiers"); + chkUseHostileTerritoryModifiers = new CampaignOptionsCheckBox("UseHostileTerritoryModifiers"); + chkUseFamilyModifiers = new CampaignOptionsCheckBox("UseFamilyModifiers"); + chkUseLoyaltyModifiers = new CampaignOptionsCheckBox("UseLoyaltyModifiers"); + chkUseHideLoyalty = new CampaignOptionsCheckBox("UseHideLoyalty"); // Layout the Panel - final JPanel panel = createStandardPanel("TurnoverModifiersPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("TurnoverModifiersPanel", true, "ModifiersPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -472,26 +472,26 @@ private JPanel createModifiersPanel() { */ private JPanel createPayoutsPanel() { // Contents - lblPayoutRateOfficer = createLabel("PayoutRateOfficer"); - spnPayoutRateOfficer = createSpinner("PayoutRateOfficer", + lblPayoutRateOfficer = new CampaignOptionsLabel("PayoutRateOfficer"); + spnPayoutRateOfficer = new CampaignOptionsSpinner("PayoutRateOfficer", 3, 0, 12, 1); - lblPayoutRateEnlisted = createLabel("PayoutRateEnlisted"); - spnPayoutRateEnlisted = createSpinner("PayoutRateEnlisted", + lblPayoutRateEnlisted = new CampaignOptionsLabel("PayoutRateEnlisted"); + spnPayoutRateEnlisted = new CampaignOptionsSpinner("PayoutRateEnlisted", 3, 0, 12, 1); - lblPayoutRetirementMultiplier = createLabel("PayoutRetirementMultiplier"); - spnPayoutRetirementMultiplier = createSpinner("PayoutRetirementMultiplier", + lblPayoutRetirementMultiplier = new CampaignOptionsLabel("PayoutRetirementMultiplier"); + spnPayoutRetirementMultiplier = new CampaignOptionsSpinner("PayoutRetirementMultiplier", 24, 1, 120, 1); - chkUsePayoutServiceBonus = createCheckBox("UsePayoutServiceBonus"); + chkUsePayoutServiceBonus = new CampaignOptionsCheckBox("UsePayoutServiceBonus"); - lblPayoutServiceBonusRate = createLabel("PayoutServiceBonusRate"); - spnPayoutServiceBonusRate = createSpinner("PayoutServiceBonusRate", + lblPayoutServiceBonusRate = new CampaignOptionsLabel("PayoutServiceBonusRate"); + spnPayoutServiceBonusRate = new CampaignOptionsSpinner("PayoutServiceBonusRate", 10, 1, 100, 1); // Layout the Panel - final JPanel panel = createStandardPanel("PayoutsPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("PayoutsPanel", true, "PayoutsPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -552,7 +552,7 @@ private JPanel createUnitCohesionPanel() { pnlManagementSkillWrapper = createManagementSkillWrapperPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("UnitCohesionPanel", true, + final JPanel panel = new CampaignOptionsStandardPanel("UnitCohesionPanel", true, "UnitCohesionPanel"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -586,11 +586,11 @@ private JPanel createUnitCohesionPanel() { */ private JPanel createAdministrativeStrainWrapperPanel() { // Contents - chkUseAdministrativeStrain = createCheckBox("UseAdministrativeStrain"); + chkUseAdministrativeStrain = new CampaignOptionsCheckBox("UseAdministrativeStrain"); pnlAdministrativeStrain = createAdministrativeStrainPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("AdministrativeStrainPanel", false); + final JPanel panel = new CampaignOptionsStandardPanel("AdministrativeStrainPanel", false); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -622,16 +622,16 @@ private JPanel createAdministrativeStrainWrapperPanel() { */ private JPanel createAdministrativeStrainPanel() { // Contents - lblAdministrativeCapacity = createLabel("AdministrativeCapacity"); - spnAdministrativeCapacity = createSpinner("AdministrativeCapacity", + lblAdministrativeCapacity = new CampaignOptionsLabel("AdministrativeCapacity"); + spnAdministrativeCapacity = new CampaignOptionsSpinner("AdministrativeCapacity", 10, 1, 30, 1); - lblMultiCrewStrainDivider = createLabel("MultiCrewStrainDivider"); - spnMultiCrewStrainDivider = createSpinner("MultiCrewStrainDivider", + lblMultiCrewStrainDivider = new CampaignOptionsLabel("MultiCrewStrainDivider"); + spnMultiCrewStrainDivider = new CampaignOptionsSpinner("MultiCrewStrainDivider", 5, 1, 25, 1); // Layout the Panel - final JPanel panel = createStandardPanel("AdministrativeStrain", true, + final JPanel panel = new CampaignOptionsStandardPanel("AdministrativeStrain", true, "AdministrativeStrain"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -673,11 +673,11 @@ private JPanel createAdministrativeStrainPanel() { */ private JPanel createManagementSkillWrapperPanel() { // Contents - chkUseManagementSkill = createCheckBox("UseManagementSkill"); + chkUseManagementSkill = new CampaignOptionsCheckBox("UseManagementSkill"); pnlManagementSkill = createManagementSkillPanel(); // Layout the Panel - final JPanel panel = createStandardPanel("UnitCohesionPanel", false); + final JPanel panel = new CampaignOptionsStandardPanel("UnitCohesionPanel", false); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -710,14 +710,14 @@ private JPanel createManagementSkillWrapperPanel() { */ private JPanel createManagementSkillPanel() { // Contents - chkUseCommanderLeadershipOnly = createCheckBox("UseCommanderLeadershipOnly"); + chkUseCommanderLeadershipOnly = new CampaignOptionsCheckBox("UseCommanderLeadershipOnly"); - lblManagementSkillPenalty = createLabel("ManagementSkillPenalty"); - spnManagementSkillPenalty = createSpinner("ManagementSkillPenalty", + lblManagementSkillPenalty = new CampaignOptionsLabel("ManagementSkillPenalty"); + spnManagementSkillPenalty = new CampaignOptionsSpinner("ManagementSkillPenalty", 0, -10, 10, 1); // Layout the Panel - final JPanel panel = createStandardPanel("ManagementSkill", true, + final JPanel panel = new CampaignOptionsStandardPanel("ManagementSkill", true, "ManagementSkill"); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); @@ -755,31 +755,31 @@ private JPanel createManagementSkillPanel() { */ JPanel createFatigueTab() { // Header - JPanel headerPanel = createHeaderPanel("FatigueTab", + JPanel headerPanel = new CampaignOptionsHeaderPanel("FatigueTab", getImageDirectory() + "logo_free_rasalhague_republic.png", true); // Contents - chkUseFatigue = createCheckBox("UseFatigue"); + chkUseFatigue = new CampaignOptionsCheckBox("UseFatigue"); - lblFatigueRate = createLabel("FatigueRate"); - spnFatigueRate = createSpinner("FatigueRate", + lblFatigueRate = new CampaignOptionsLabel("FatigueRate"); + spnFatigueRate = new CampaignOptionsSpinner("FatigueRate", 1, 1, 10, 1); - chkUseInjuryFatigue = createCheckBox("UseInjuryFatigue"); + chkUseInjuryFatigue = new CampaignOptionsCheckBox("UseInjuryFatigue"); - lblFieldKitchenCapacity = createLabel("FieldKitchenCapacity"); - spnFieldKitchenCapacity = createSpinner("FieldKitchenCapacity", + lblFieldKitchenCapacity = new CampaignOptionsLabel("FieldKitchenCapacity"); + spnFieldKitchenCapacity = new CampaignOptionsSpinner("FieldKitchenCapacity", 150, 0, 450, 1); - chkFieldKitchenIgnoreNonCombatants = createCheckBox("FieldKitchenIgnoreNonCombatants"); + chkFieldKitchenIgnoreNonCombatants = new CampaignOptionsCheckBox("FieldKitchenIgnoreNonCombatants"); - lblFatigueLeaveThreshold = createLabel("FatigueLeaveThreshold"); - spnFatigueLeaveThreshold = createSpinner("FatigueLeaveThreshold", + lblFatigueLeaveThreshold = new CampaignOptionsLabel("FatigueLeaveThreshold"); + spnFatigueLeaveThreshold = new CampaignOptionsSpinner("FatigueLeaveThreshold", 13, 0, 17, 1); // Layout the Panel - final JPanel panel = createStandardPanel("FatigueTab", true); + final JPanel panel = new CampaignOptionsStandardPanel("FatigueTab", true); final GroupLayout layout = createStandardLayout(panel); panel.setLayout(layout); From 2ddfbd57a042cbb0c93657768c024fe34ed3b1bd Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 15 Oct 2024 18:55:10 -0500 Subject: [PATCH 084/117] Refactor panel and label initialization Replaced direct JPanel and JLabel initialization with anonymous class instantiation. Converted layout setting to GroupLayout for better alignment control and updated HTML structuring for label text. --- .../CampaignOptionsUtilities.java | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java index 0a54a7479d..904c07086d 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java @@ -268,7 +268,7 @@ public CampaignOptionsStandardPanel(String name, boolean includeBorder) { public CampaignOptionsStandardPanel(String name, boolean includeBorder, String borderTitle) { borderTitle = borderTitle.isBlank() ? "" : resources.getString("lbl" + borderTitle + ".text"); - JPanel panel = new JPanel() { + new JPanel() { @Override public Dimension getPreferredSize() { Dimension standardSize = super.getPreferredSize(); @@ -277,11 +277,11 @@ public Dimension getPreferredSize() { }; if (includeBorder) { - panel.setBorder(BorderFactory.createTitledBorder( + setBorder(BorderFactory.createTitledBorder( String.format(String.format("%s", borderTitle)))); } - panel.setName("pnl" + name); + setName("pnl" + name); } } @@ -329,7 +329,7 @@ public CampaignOptionsHeaderPanel(String name, String imageAddress, boolean incl imageIcon = new ImageIcon(scaledImage); - JLabel imageLabel = new JLabel(imageIcon); + JLabel lblImage = new JLabel(imageIcon); // Create header text final JLabel lblHeader = new JLabel(resources.getString("lbl" + name + ".text"), SwingConstants.CENTER); @@ -338,20 +338,30 @@ public CampaignOptionsHeaderPanel(String name, String imageAddress, boolean incl JLabel lblBody = new JLabel(); if (includeBodyText) { - lblBody = new JLabel(String.format("

%s

", + lblBody = new JLabel(String.format("
%s
", + UIUtil.scaleForGUI(750), resources.getString("lbl" + name + "Body.text")), SwingConstants.CENTER); lblBody.setName("lbl" + name + "Body"); setFontScaling(lblBody, false, 1); } // Layout panel - final JPanel panel = new CampaignOptionsStandardPanel("pnl" + name + "HeaderPanel", - false); - panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); - - panel.add(lblHeader); - panel.add(lblBody); - panel.add(imageLabel); + new CampaignOptionsStandardPanel("pnl" + name + "HeaderPanel", false); + final GroupLayout layout = createStandardLayout(this); + setLayout(layout); + + layout.setVerticalGroup( + layout.createSequentialGroup() + .addComponent(lblHeader) + .addComponent(lblBody) + .addComponent(lblImage)); + + layout.setHorizontalGroup( + layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(Alignment.LEADING) + .addComponent(lblHeader, Alignment.CENTER) + .addComponent(lblBody, Alignment.CENTER) + .addComponent(lblImage, Alignment.CENTER))); } } From 790dd3d5e511879e0e2463316ba6ad41415ef4f7 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 15 Oct 2024 19:03:24 -0500 Subject: [PATCH 085/117] Refactor icon button action and clean up code Replaced inline icon button action listener with a dedicated method. Removed commented-out legacy code to improve readability and maintainability of GeneralTab.java. --- .../gui/panes/campaignOptions/GeneralTab.java | 93 ++----------------- 1 file changed, 10 insertions(+), 83 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java index 8d329e323a..00a32dbea7 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java @@ -110,31 +110,14 @@ public AbstractMHQScrollablePanel createGeneralTab() { btnDate.addActionListener(this::btnDateActionPerformed); // Camouflage - lblCamo = new CampaignOptionsLabel("Camo") { - @Override - public Dimension getPreferredSize() { - return UIUtil.scaleForGUI(100, 100); - } - }; - -// lblCamo = new CampaignOptionsLabel("Camo"); + lblCamo = new CampaignOptionsLabel("Camo"); btnCamo.setName("btnCamo"); -// btnCamo.setMinimumSize(UIUtil.scaleForGUI(100, 100)); -// btnCamo.setMaximumSize(UIUtil.scaleForGUI(100, 100)); btnCamo.addActionListener(this::btnCamoActionPerformed); // Unit icon lblIcon = new CampaignOptionsLabel("Icon"); btnIcon.setName("btnIcon"); -// btnIcon.setMinimumSize(UIUtil.scaleForGUI(100, 100)); -// btnIcon.setMaximumSize(UIUtil.scaleForGUI(100, 100)); - btnIcon.addActionListener(evt -> { - final UnitIconDialog unitIconDialog = new UnitIconDialog(frame, unitIcon); - if (unitIconDialog.showDialog().isConfirmed() && (unitIconDialog.getSelectedItem() != null)) { - unitIcon = unitIconDialog.getSelectedItem(); - btnIcon.setIcon(unitIcon.getImageIcon(UIUtil.scaleForGUI(75))); - } - }); + btnIcon.addActionListener(this::btnIconActionPerformed); // Initialize the parent panel AbstractMHQScrollablePanel generalPanel = new DefaultMHQScrollablePanel(frame, "generalPanel", @@ -200,70 +183,6 @@ public Dimension getPreferredSize() { panel.add(iconsPanel, gbc); - - - -// final GroupLayout layout = createStandardLayout(panel); -// panel.setLayout(layout); -// -// layout.setVerticalGroup( -// layout.createSequentialGroup() -// .addComponent(headerPanel) -// .addGroup(layout.createParallelGroup(Alignment.TRAILING) -// .addComponent(lblName) -// .addComponent(txtName) -// .addComponent(btnNameGenerator)) -// .addGroup(layout.createParallelGroup(Alignment.BASELINE) -// .addComponent(lblFaction) -// .addComponent(comboFaction)) -// .addGroup(layout.createParallelGroup(Alignment.BASELINE) -// .addComponent(lblReputation) -// .addComponent(unitRatingMethodCombo)) -// .addGroup(layout.createParallelGroup(Alignment.BASELINE) -// .addComponent(lblManualUnitRatingModifier) -// .addComponent(manualUnitRatingModifier)) -// .addGroup(layout.createParallelGroup(Alignment.BASELINE) -// .addComponent(lblDate) -// .addComponent(btnDate)) -// .addGroup(layout.createParallelGroup(Alignment.BASELINE) -// .addComponent(lblCamo) -// .addComponent(btnCamo) -// .addComponent(lblIcon) -// .addComponent(btnIcon))); -// -// layout.setHorizontalGroup( -// layout.createParallelGroup(Alignment.LEADING) -// .addComponent(headerPanel, Alignment.CENTER) -// .addGroup(layout.createSequentialGroup() -// .addComponent(lblName) -// .addComponent(txtName) -// .addComponent(btnNameGenerator) -// .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) -// .addGroup(layout.createSequentialGroup() -// .addComponent(lblFaction) -// .addComponent(comboFaction) -// .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) -// .addGroup(layout.createSequentialGroup() -// .addComponent(lblReputation) -// .addComponent(unitRatingMethodCombo) -// .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) -// .addGroup(layout.createSequentialGroup() -// .addComponent(lblManualUnitRatingModifier) -// .addComponent(manualUnitRatingModifier) -// .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) -// .addGroup(layout.createSequentialGroup() -// .addComponent(lblDate) -// .addComponent(btnDate) -// .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE)) -// .addGroup(layout.createSequentialGroup() -// .addComponent(lblCamo) -// .addComponent(btnCamo) -// .addGap(50) -// .addComponent(lblIcon) -// .addComponent(btnIcon) -// .addContainerGap(Short.MAX_VALUE, Short.MAX_VALUE))); -// - final JPanel outerPanel = new CampaignOptionsStandardPanel("generalTab", true); // Add some padding left and right (inside the border!) outerPanel.setLayout(new BorderLayout()); @@ -411,4 +330,12 @@ private void btnCamoActionPerformed(ActionEvent actionEvent) { btnCamo.setIcon(camouflage.getImageIcon()); } } + + private void btnIconActionPerformed(ActionEvent actionEvent) { + final UnitIconDialog unitIconDialog = new UnitIconDialog(frame, unitIcon); + if (unitIconDialog.showDialog().isConfirmed() && (unitIconDialog.getSelectedItem() != null)) { + unitIcon = unitIconDialog.getSelectedItem(); + btnIcon.setIcon(unitIcon.getImageIcon(UIUtil.scaleForGUI(75))); + } + } } From e73d72b35fc95029c91d38beccf8bf6bef34d66b Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 15 Oct 2024 19:31:14 -0500 Subject: [PATCH 086/117] Fix border title formatting and UI layout issues Fixed the nested String.format issue for border titles in CampaignOptionsUtilities. Adjusted the GeneralTab layout to use FlowLayout and added a titled border for the icons panel. Also set preferred sizes for button components to enhance UI consistency. --- .../campaignOptions/CampaignOptionsUtilities.java | 2 +- .../mekhq/gui/panes/campaignOptions/GeneralTab.java | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java index 904c07086d..fe4d70ccef 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java @@ -278,7 +278,7 @@ public Dimension getPreferredSize() { if (includeBorder) { setBorder(BorderFactory.createTitledBorder( - String.format(String.format("%s", borderTitle)))); + String.format("%s", borderTitle))); } setName("pnl" + name); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java index 00a32dbea7..ca22dadf90 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java @@ -173,7 +173,9 @@ public AbstractMHQScrollablePanel createGeneralTab() { gbc.gridy++; gbc.gridwidth = 5; gbc.gridx = GridBagConstraints.RELATIVE; - JPanel iconsPanel = new JPanel(); + + JPanel iconsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + iconsPanel.setBorder(BorderFactory.createTitledBorder("")); iconsPanel.add(lblCamo); iconsPanel.add(btnCamo); @@ -256,7 +258,6 @@ private void initialize() { lblCamo = new JLabel(); btnCamo = new JButton() { - @Override public Dimension getPreferredSize() { return UIUtil.scaleForGUI(100, 100); @@ -264,7 +265,12 @@ public Dimension getPreferredSize() { }; lblIcon = new JLabel(); - btnIcon = new JButton(); + btnIcon = new JButton() { + @Override + public Dimension getPreferredSize() { + return UIUtil.scaleForGUI(100, 100); + } + }; } /** From 403cb16ecb49439d1aa9ed7e4562464271d9665c Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 15 Oct 2024 20:51:50 -0500 Subject: [PATCH 087/117] Update layouts and remove administrators tab Replaced `createStandardLayout` with `createGroupLayout` across multiple panels to streamline layout management. Removed the unused administrators tab and added a new `CampaignOptionsGridBagConstraints` class for more flexible layout handling. --- .../NEWCampaignOptionsDialog.properties | 13 +- .../panes/campaignOptions/BiographyTab.java | 24 +- .../campaignOptions/CampaignOptionsPane.java | 1 - .../CampaignOptionsUtilities.java | 53 +++- .../EquipmentAndSuppliesTab.java | 18 +- .../panes/campaignOptions/FinancesTab.java | 22 +- .../gui/panes/campaignOptions/GeneralTab.java | 95 +++---- .../gui/panes/campaignOptions/MarketsTab.java | 18 +- .../panes/campaignOptions/PersonnelTab.java | 257 ++++++++++-------- .../campaignOptions/RelationshipsTab.java | 18 +- .../RepairAndMaintenanceTab.java | 4 +- .../panes/campaignOptions/RulesetsTab.java | 22 +- .../campaignOptions/SelectPresetDialog.java | 4 +- .../TurnoverAndRetentionTab.java | 20 +- 14 files changed, 306 insertions(+), 263 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 7e62bcc5ab..9aaf5846ee 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -247,11 +247,6 @@ personnelInformationTab.border="Every log entry isn't just data - it's the histo \ our victories, and our failures. Keep them well, because one day they'll save us again."\
- Sergeant Vic "Crash" Helman, Ironclad Hawks -administratorsTab.title=Administrators -administratorsTab.border="Administrators don't need medals. They just need enough coffee to survive\ - \ the paperwork."\ -
- Sergeant Bobby "Scrapheap" Martinez, Steel Raptor Battalion - awardsTab.title=Awards awardsTab.border="An award is just metal and ribbon, but the courage it represents is what keeps us\ \ fighting when everything else says we should fall."\ @@ -359,13 +354,7 @@ lblShowOriginFaction.text=Display Origin Faction lblShowOriginFaction.tooltip=PLACEHOLDER # createAdministratorsTab -lblAdministratorsTab.text=Administrator Options -lblAdministratorsTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ - \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ - \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ - \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ - \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ - \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblAdministratorsPanel.text=Administrators lblAdminsHaveNegotiation.text=Admins Have Negotiation lblAdminsHaveNegotiation.tooltip=PLACEHOLDER lblAdminExperienceLevelIncludeNegotiation.text=Negotiation Factored into Experience Level diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java index 7ed9f89e9a..6b6e4f8d7e 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java @@ -344,7 +344,7 @@ JPanel createGeneralTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("BiographyGeneralTab", true); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -398,7 +398,7 @@ private JPanel createAnniversariesPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("AnniversariesPanel", true, "AnniversariesPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -438,7 +438,7 @@ JPanel createBackgroundsTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("BackgroundsTab", true); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -535,7 +535,7 @@ public Component getListCellRendererComponent(final JList list, final Object // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("RandomOriginOptionsPanel", true, "RandomOriginOptionsPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -681,7 +681,7 @@ public Component getListCellRendererComponent(final JList list, final Object // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("DeathTab", true); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -800,7 +800,7 @@ JPanel createEducationTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("EducationTab", true); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -876,7 +876,7 @@ private JPanel createEnableStandardSetsPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("EnableStandardSetsPanel", true, "EnableStandardSetsPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -919,7 +919,7 @@ private JPanel createXpAndSkillBonusesPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("XpAndSkillBonusesPanel", true, "XpAndSkillBonusesPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -963,7 +963,7 @@ private JPanel createDropoutChancePanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("DropoutChancePanel", true, "DropoutChancePanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -1011,7 +1011,7 @@ private JPanel createAccidentsAndEventsPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("AccidentsAndEventsPanel", true, "AccidentsAndEventsPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -1063,7 +1063,7 @@ JPanel createNameAndPortraitGenerationTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("NameAndPortraitGenerationTab", true, ""); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -1190,7 +1190,7 @@ JPanel createRankTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("RankTab", true, ""); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java index d892e2389b..800f64dd30 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java @@ -101,7 +101,6 @@ private JTabbedPane createHumanResourcesParentTab() { "personnelGeneralTab", personnelTab.createGeneralTab(), "personnelLogsTab", personnelTab.createPersonnelLogsTab(), "personnelInformationTab", personnelTab.createPersonnelInformationTab(), - "administratorsTab", personnelTab.createAdministratorsTab(), "awardsTab", personnelTab.createAwardsTab(), "prisonersAndDependentsTab", personnelTab.createPrisonersAndDependentsTab(), "medicalTab", personnelTab.createMedicalTab(), diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java index fe4d70ccef..ddd5a904ef 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java @@ -6,10 +6,8 @@ import javax.swing.*; import javax.swing.GroupLayout.Alignment; import java.awt.*; -import java.util.ArrayList; import java.util.List; -import java.util.Map; -import java.util.ResourceBundle; +import java.util.*; import static megamek.client.ui.WrapLayout.wordWrap; import static megamek.client.ui.swing.util.FlatLafStyleBuilder.setFontScaling; @@ -240,7 +238,7 @@ static class CampaignOptionsStandardPanel extends JPanel { /** * Creates a standardized {@link JPanel} with an untitled border. *

- * {@code createStandardLayout} should also be called and the resulting {@link GroupLayout} + * {@code createGroupLayout} should also be called and the resulting {@link GroupLayout} * assigned to the panel via {@code setLayout}. *

* If {@code borderTitle} isn't empty the resource bundle reference, used to fetch the border's @@ -256,7 +254,7 @@ public CampaignOptionsStandardPanel(String name, boolean includeBorder) { /** * Creates a standardized {@link JPanel} with a titled border. *

- * {@code createStandardLayout} should also be called and the resulting {@link GroupLayout} + * {@code createGroupLayout} should also be called and the resulting {@link GroupLayout} * assigned to the panel via {@code setLayout}. *

* If {@code borderTitle} isn't empty the resource bundle reference, used to fetch the border's @@ -347,7 +345,7 @@ public CampaignOptionsHeaderPanel(String name, String imageAddress, boolean incl // Layout panel new CampaignOptionsStandardPanel("pnl" + name + "HeaderPanel", false); - final GroupLayout layout = createStandardLayout(this); + final GroupLayout layout = createGroupLayout(this); setLayout(layout); layout.setVerticalGroup( @@ -368,12 +366,12 @@ public CampaignOptionsHeaderPanel(String name, String imageAddress, boolean incl /** * Creates a {@link GroupLayout} object for the specified {@link JPanel}. *

- * Written to be paired with {@code new CampaignOptionsStandardPanel}. + * Written to be paired with {@code CampaignOptionsStandardPanel}. * * @param panel the {@link JPanel} for which the {@link GroupLayout} is created * @return the created {@link GroupLayout} object */ - static GroupLayout createStandardLayout(JPanel panel) { + static GroupLayout createGroupLayout(JPanel panel) { final GroupLayout layout = new GroupLayout(panel); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); @@ -381,6 +379,41 @@ static GroupLayout createStandardLayout(JPanel panel) { return layout; } + static class CampaignOptionsGridBagConstraints extends GridBagConstraints { + /** + * Creates a {@link GridBagConstraints} object for the specified {@link JPanel}. + *

+ * Written to be paired with {@code CampaignOptionsStandardPanel}. + * + * @param panel the {@link JPanel} for which the {@link GridBagConstraints} is created + */ + public CampaignOptionsGridBagConstraints(JPanel panel) { + this(panel, null, null); + } + + /** + * Creates a {@link GridBagConstraints} object for the specified {@link JPanel} according to the + * provided settings. + *

+ * Written to be paired with {@code CampaignOptionsStandardPanel}. + * + * @param panel the {@link JPanel} for which the {@link GridBagConstraints} is created + * @param anchor the anchor setting for the {@link GridBagConstraints}, or {@code null} to use + * the default value {@link GridBagConstraints#NORTHWEST} + * @param fill the fill setting for the {@link GridBagConstraints}, or {@code null} to use the + * default value {@link GridBagConstraints#NORTHWEST} + */ + public CampaignOptionsGridBagConstraints(JPanel panel, @Nullable Integer anchor, @Nullable Integer fill) { + super(); + panel.setLayout(new GridBagLayout()); + + this.anchor = Objects.requireNonNullElse(anchor, GridBagConstraints.NORTHWEST); + this.fill = Objects.requireNonNullElse(fill, GridBagConstraints.HORIZONTAL); + + this.insets = new Insets(5, 5, 5, 5); + } + } + /** * Creates a parent panel for the provided {@link JPanel}. * @@ -391,7 +424,7 @@ static GroupLayout createStandardLayout(JPanel panel) { static JPanel createParentPanel(JPanel panel, String name) { // Create Panel final JPanel parentPanel = new CampaignOptionsStandardPanel(name, false); - final GroupLayout parentLayout = createStandardLayout(parentPanel); + final GroupLayout parentLayout = createGroupLayout(parentPanel); // Layout parentPanel.setLayout(parentLayout); @@ -445,7 +478,7 @@ static JTabbedPane createSubTabs(Map panels) { JPanel quotePanel = new JPanel(new GridBagLayout()); JLabel quote = new JLabel(String.format( "

%s
", - UIUtil.scaleForGUI(650), resources.getString(tabName + ".border"))); + UIUtil.scaleForGUI(mainPanel.getPreferredSize().width), resources.getString(tabName + ".border"))); GridBagConstraints quoteConstraints = new GridBagConstraints(); quoteConstraints.gridx = GridBagConstraints.RELATIVE; diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java index af943c4d9e..241dae8ce1 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java @@ -246,7 +246,7 @@ JPanel createAcquisitionTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("acquisitionTab", true); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -304,7 +304,7 @@ JPanel createPlanetaryAcquisitionTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("PlanetaryAcquisitionTab", true); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -360,7 +360,7 @@ private JPanel createOptionsPanel() { // Layout the Panel final JPanel panel = new JPanel(); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -436,7 +436,7 @@ private JPanel createModifiersPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("PlanetaryAcquisitionTabModifiers", true, "ModifiersPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -467,7 +467,7 @@ private JPanel createTechModifiersPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("createTechModifiersPanel", false); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -528,7 +528,7 @@ private JPanel createIndustryModifiersPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("IndustryModifiersPanel", false); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -584,7 +584,7 @@ private JPanel createOutputModifiersPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("OutputModifiersPanel", false); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -694,7 +694,7 @@ JPanel createDeliveryTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("deliveryTab", true); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -822,7 +822,7 @@ JPanel createTechLimitsTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("TechLimitsTab", true); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/FinancesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/FinancesTab.java index 71ef641f68..03afa3c64a 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/FinancesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/FinancesTab.java @@ -196,7 +196,7 @@ JPanel createFinancesGeneralOptionsTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("FinancesGeneralTab", true, ""); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -242,7 +242,7 @@ private JPanel createPaymentsPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("PaymentsPanel", true, "PaymentsPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -294,7 +294,7 @@ private JPanel createOtherSystemsPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("OtherSystemsPanel", false); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -332,7 +332,7 @@ private JPanel createGeneralOptionsPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("GeneralOptionsPanel", false); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -377,7 +377,7 @@ private JPanel createSalesPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("SalesPanel", true, "SalesPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -415,7 +415,7 @@ private JPanel createTaxesPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("TaxesPanel", true, "TaxesPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -450,7 +450,7 @@ private JPanel createSharesPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("SharesPanel", true, "SharesPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -522,7 +522,7 @@ JPanel createPriceMultipliersTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("PriceMultipliersTab", true, ""); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -582,7 +582,7 @@ private JPanel createGeneralMultipliersPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("GeneralMultipliersPanel", true, "GeneralMultipliersPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -674,7 +674,7 @@ private JPanel createUsedPartsMultiplierPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("UsedPartsMultiplierPanel", true, "UsedPartsMultiplierPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -751,7 +751,7 @@ private JPanel createOtherMultipliersPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("OtherMultipliersPanel", true, "OtherMultipliersPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java index ca22dadf90..47111a95c9 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java @@ -125,54 +125,49 @@ public AbstractMHQScrollablePanel createGeneralTab() { // Layout the Panel JPanel panel = new JPanel(); - GridBagConstraints gbc = new GridBagConstraints(); - panel.setLayout(new GridBagLayout()); - - gbc.anchor = GridBagConstraints.WEST; - gbc.insets = new Insets(5, 5, 5, 5); - gbc.fill = GridBagConstraints.HORIZONTAL; - - gbc.gridy = 0; - gbc.gridwidth = 5; - panel.add(headerPanel, gbc); - - gbc.gridwidth = 1; - gbc.gridy++; - panel.add(lblName, gbc); - - gbc.gridwidth = 2; - gbc.weightx = 1; - panel.add(txtName, gbc); - - gbc.gridwidth = 1; - gbc.weightx = 0; - gbc.fill = GridBagConstraints.NONE; - panel.add(btnNameGenerator, gbc); - gbc.fill = GridBagConstraints.HORIZONTAL; - - gbc.gridy++; - panel.add(lblFaction, gbc); - gbc.gridwidth = 2; - panel.add(comboFaction, gbc); - - gbc.gridwidth = 1; - gbc.gridy++; - panel.add(lblReputation, gbc); - gbc.gridwidth = 2; - panel.add(unitRatingMethodCombo, gbc); - - gbc.gridwidth = 1; - gbc.gridy++; - panel.add(lblManualUnitRatingModifier, gbc); - panel.add(manualUnitRatingModifier, gbc); - - gbc.gridy++; - panel.add(lblDate, gbc); - panel.add(btnDate, gbc); - - gbc.gridy++; - gbc.gridwidth = 5; - gbc.gridx = GridBagConstraints.RELATIVE; + GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridy = 0; + layout.gridwidth = 5; + panel.add(headerPanel, layout); + + layout.gridwidth = 1; + layout.gridy++; + panel.add(lblName, layout); + + layout.gridwidth = 2; + layout.weightx = 1; + panel.add(txtName, layout); + + layout.gridwidth = 1; + layout.weightx = 0; + layout.fill = GridBagConstraints.NONE; + panel.add(btnNameGenerator, layout); + layout.fill = GridBagConstraints.HORIZONTAL; + + layout.gridy++; + panel.add(lblFaction, layout); + layout.gridwidth = 2; + panel.add(comboFaction, layout); + + layout.gridwidth = 1; + layout.gridy++; + panel.add(lblReputation, layout); + layout.gridwidth = 2; + panel.add(unitRatingMethodCombo, layout); + + layout.gridwidth = 1; + layout.gridy++; + panel.add(lblManualUnitRatingModifier, layout); + panel.add(manualUnitRatingModifier, layout); + + layout.gridy++; + panel.add(lblDate, layout); + panel.add(btnDate, layout); + + layout.gridy++; + layout.gridwidth = 5; + layout.gridx = GridBagConstraints.RELATIVE; JPanel iconsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); iconsPanel.setBorder(BorderFactory.createTitledBorder("")); @@ -183,7 +178,7 @@ public AbstractMHQScrollablePanel createGeneralTab() { iconsPanel.add(lblIcon); iconsPanel.add(btnIcon); - panel.add(iconsPanel, gbc); + panel.add(iconsPanel, layout); final JPanel outerPanel = new CampaignOptionsStandardPanel("generalTab", true); // Add some padding left and right (inside the border!) @@ -216,7 +211,7 @@ private static JPanel createGeneralHeader() { lblBody.setMaximumSize(UIUtil.scaleForGUI(750, size.height)); final JPanel panel = new CampaignOptionsStandardPanel("pnlGeneralHeaderPanel", false); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/MarketsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/MarketsTab.java index b0cbef42a4..b4e51358db 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/MarketsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/MarketsTab.java @@ -129,7 +129,7 @@ JPanel createPersonnelMarketTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("PersonnelMarketTab", true, ""); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -167,7 +167,7 @@ private JPanel createPersonnelMarketGeneralOptionsPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("PersonnelMarketGeneralOptionsPanel", false, ""); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -212,7 +212,7 @@ private JPanel createPersonnelMarketRemovalOptionsPanel() { // Layout the Panels final JPanel leftPanel = new CampaignOptionsStandardPanel("LeftPanel", false); - final GroupLayout leftLayout = createStandardLayout(leftPanel); + final GroupLayout leftLayout = createGroupLayout(leftPanel); leftPanel.setLayout(leftLayout); leftLayout.setVerticalGroup( @@ -246,7 +246,7 @@ private JPanel createPersonnelMarketRemovalOptionsPanel() { .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.REGULAR)))); final JPanel rightPanel = new CampaignOptionsStandardPanel("RightPanel", false); - final GroupLayout rightLayout = createStandardLayout(rightPanel); + final GroupLayout rightLayout = createGroupLayout(rightPanel); rightPanel.setLayout(rightLayout); rightLayout.setVerticalGroup( @@ -281,7 +281,7 @@ private JPanel createPersonnelMarketRemovalOptionsPanel() { final JPanel parentPanel = new CampaignOptionsStandardPanel("PersonnelMarketRemovalOptionsPanel", true, "PersonnelMarketRemovalOptionsPanel"); - final GroupLayout parentLayout = createStandardLayout(parentPanel); + final GroupLayout parentLayout = createGroupLayout(parentPanel); parentPanel.setLayout(parentLayout); parentLayout.setVerticalGroup( @@ -338,7 +338,7 @@ JPanel createUnitMarketTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("UnitMarketTab", true, ""); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -422,7 +422,7 @@ JPanel createContractMarketTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("ContractMarketTab", true, ""); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -468,7 +468,7 @@ private JPanel createContractMarketGeneralOptionsPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("ContractMarketGeneralOptionsPanel", false); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -544,7 +544,7 @@ private JPanel createContractPayPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("ContractPayPanel", true, "ContractPayPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java index 25d0fe5fe9..9918b4b55d 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java @@ -27,6 +27,7 @@ public class PersonnelTab { String name; //start General Tab + private JPanel pnlPersonnelGeneralOptions; private JCheckBox chkUseTactics; private JCheckBox chkUseInitiativeBonus; private JCheckBox chkUseToughness; @@ -38,10 +39,16 @@ public class PersonnelTab { private JCheckBox chkUseImplants; private JCheckBox chkUseAlternativeQualityAveraging; - private JPanel personnelCleanUpPanel; + private JPanel pnlPersonnelCleanup; private JCheckBox chkUsePersonnelRemoval; private JCheckBox chkUseRemovalExemptCemetery; private JCheckBox chkUseRemovalExemptRetirees; + + private JPanel pnlAdministrators; + private JCheckBox chkAdminsHaveNegotiation; + private JCheckBox chkAdminExperienceLevelIncludeNegotiation; + private JCheckBox chkAdminsHaveScrounge; + private JCheckBox chkAdminExperienceLevelIncludeScrounge; //end General Tab //start Personnel Logs Tab @@ -67,13 +74,6 @@ public class PersonnelTab { private JCheckBox chkShowOriginFaction; //end Personnel Information Tab - //start Administrators Tab - private JCheckBox chkAdminsHaveNegotiation; - private JCheckBox chkAdminExperienceLevelIncludeNegotiation; - private JCheckBox chkAdminsHaveScrounge; - private JCheckBox chkAdminExperienceLevelIncludeScrounge; - //end Administrators Tab - //start Awards Tab private JLabel lblAwardBonusStyle; private MMComboBox comboAwardBonusStyle; @@ -327,6 +327,7 @@ private void initializePersonnelLogsTab() { * The panel contains general settings. */ private void initializeGeneralTab() { + pnlPersonnelGeneralOptions = new JPanel(); chkUseTactics = new JCheckBox(); chkUseInitiativeBonus = new JCheckBox(); chkUseToughness = new JCheckBox(); @@ -338,7 +339,7 @@ private void initializeGeneralTab() { chkUseImplants = new JCheckBox(); chkUseAlternativeQualityAveraging = new JCheckBox(); - personnelCleanUpPanel = new JPanel(); + pnlPersonnelCleanup = new JPanel(); chkUsePersonnelRemoval = new JCheckBox(); chkUseRemovalExemptCemetery = new JCheckBox(); chkUseRemovalExemptRetirees = new JCheckBox(); @@ -363,6 +364,42 @@ JPanel createGeneralTab() { getImageDirectory() + "logo_circinus_federation.png", true); + // Contents + pnlPersonnelGeneralOptions = createGeneralOptionsPanel(); + pnlPersonnelCleanup = createPersonnelCleanUpPanel(); + pnlAdministrators = createAdministratorsPanel(); + + // Layout the Panels + final JPanel panelRight = new CampaignOptionsStandardPanel("RightPanel", false); + GridBagConstraints layoutRight = new CampaignOptionsGridBagConstraints(panelRight, null, GridBagConstraints.NONE); + + layoutRight.gridx = 0; + layoutRight.gridy = 0; + panelRight.add(pnlPersonnelCleanup, layoutRight); + + layoutRight.gridy++; + panelRight.add(pnlAdministrators, layoutRight); + + final JPanel panelParent = new CampaignOptionsStandardPanel("PersonnelGeneralTab", true); + GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panelParent); + + layoutParent.gridwidth = 5; + layoutParent.gridy = 0; + panelParent.add(headerPanel, layoutParent); + + layoutParent.gridx = 0; + layoutParent.gridy++; + layoutParent.gridwidth = 1; + panelParent.add(pnlPersonnelGeneralOptions, layoutParent); + + layoutParent.gridx++; + panelParent.add(panelRight, layoutParent); + + // Create Parent Panel and return + return createParentPanel(panelParent, "PersonnelGeneralTab"); + } + + private JPanel createGeneralOptionsPanel() { // Contents chkUseTactics = new CampaignOptionsCheckBox("UseTactics"); chkUseInitiativeBonus = new CampaignOptionsCheckBox("UseInitiativeBonus"); @@ -375,47 +412,47 @@ JPanel createGeneralTab() { chkUseImplants = new CampaignOptionsCheckBox("UseImplants"); chkUseAlternativeQualityAveraging = new CampaignOptionsCheckBox("UseAlternativeQualityAveraging"); - personnelCleanUpPanel = createPersonnelCleanUpPanel(); - // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("PersonnelGeneralTab", true); - final GroupLayout layout = createStandardLayout(panel); - panel.setLayout(layout); + final JPanel panel = new CampaignOptionsStandardPanel("PersonnelGeneralTab", false); + GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(chkUseTactics) - .addComponent(chkUseInitiativeBonus) - .addComponent(chkUseToughness) - .addComponent(chkUseRandomToughness) - .addComponent(chkUseArtillery) - .addComponent(chkUseAbilities) - .addComponent(chkUseEdge) - .addComponent(chkUseSupportEdge) - .addComponent(chkUseImplants) - .addComponent(chkUseAlternativeQualityAveraging) - .addComponent(personnelCleanUpPanel)); + layout.gridy = 0; + layout.gridwidth = 1; + layout.gridy++; + panel.add(chkUseTactics, layout); - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(chkUseTactics) - .addComponent(chkUseInitiativeBonus) - .addComponent(chkUseToughness) - .addComponent(chkUseRandomToughness) - .addComponent(chkUseArtillery) - .addComponent(chkUseAbilities) - .addComponent(chkUseEdge) - .addComponent(chkUseSupportEdge) - .addComponent(chkUseImplants) - .addComponent(chkUseAlternativeQualityAveraging) - .addComponent(personnelCleanUpPanel)) - ); + layout.gridy++; + panel.add(chkUseInitiativeBonus, layout); - // Create Parent Panel and return - return createParentPanel(panel, "PersonnelGeneralTab"); + layout.gridy++; + panel.add(chkUseToughness, layout); + + layout.gridy++; + panel.add(chkUseRandomToughness, layout); + + layout.gridy++; + panel.add(chkUseArtillery, layout); + + layout.gridy++; + panel.add(chkUseAbilities, layout); + + layout.gridy++; + panel.add(chkUseEdge, layout); + + layout.gridy++; + panel.add(chkUseSupportEdge, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkUseImplants, layout); + + layout.gridy++; + panel.add(chkUseImplants, layout); + + layout.gridy++; + panel.add(chkUseAlternativeQualityAveraging, layout); + + return panel; } /** @@ -435,20 +472,55 @@ private JPanel createPersonnelCleanUpPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("PersonnelCleanUpPanel", true, "PersonnelCleanUpPanel"); - final GroupLayout layout = createStandardLayout(panel); - panel.setLayout(layout); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(chkUsePersonnelRemoval) - .addComponent(chkUseRemovalExemptCemetery) - .addComponent(chkUseRemovalExemptRetirees)); + layout.gridy = 0; + layout.gridwidth = 1; + layout.gridy++; + panel.add(chkUsePersonnelRemoval, layout); - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(chkUsePersonnelRemoval) - .addComponent(chkUseRemovalExemptCemetery) - .addComponent(chkUseRemovalExemptRetirees)); + layout.gridy++; + panel.add(chkUseRemovalExemptCemetery, layout); + + layout.gridy++; + panel.add(chkUseRemovalExemptRetirees, layout); + + return panel; + } + + /** + * Creates a panel for the Administrators Tab in the application. + *

+ * This method constructs the header panel and checkbox components for administrator settings + * including negotiation and scrounging options. + * + * @return a {@link JPanel} representing the Administrators Tab panel + */ + private JPanel createAdministratorsPanel() { + // Contents + chkAdminsHaveNegotiation = new CampaignOptionsCheckBox("AdminsHaveNegotiation"); + chkAdminExperienceLevelIncludeNegotiation = new CampaignOptionsCheckBox("AdminExperienceLevelIncludeNegotiation"); + chkAdminsHaveScrounge = new CampaignOptionsCheckBox("AdminsHaveScrounge"); + chkAdminExperienceLevelIncludeScrounge = new CampaignOptionsCheckBox("AdminExperienceLevelIncludeScrounge"); + + // Layout the Panel + final JPanel panel = new CampaignOptionsStandardPanel("AdministratorsPanel", true, + "AdministratorsPanel"); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridy = 0; + layout.gridwidth = 1; + layout.gridy++; + panel.add(chkAdminsHaveNegotiation, layout); + + layout.gridy++; + panel.add(chkAdminExperienceLevelIncludeNegotiation, layout); + + layout.gridy++; + panel.add(chkAdminsHaveScrounge, layout); + + layout.gridy++; + panel.add(chkAdminExperienceLevelIncludeScrounge, layout); return panel; } @@ -476,7 +548,7 @@ JPanel createPersonnelLogsTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("PersonnelLogsTab", true); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -530,7 +602,7 @@ JPanel createPersonnelInformationTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("PersonnelInformation", true); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -567,51 +639,6 @@ JPanel createPersonnelInformationTab() { return createParentPanel(panel, "PersonnelInformation"); } - /** - * Creates a panel for the Administrators Tab in the application. - *

- * This method constructs the header panel and checkbox components for administrator settings - * including negotiation and scrounging options. - * - * @return a {@link JPanel} representing the Administrators Tab panel - */ - JPanel createAdministratorsTab() { - // Header - JPanel headerPanel = new CampaignOptionsHeaderPanel("AdministratorsTab", - getImageDirectory() + "logo_clan_diamond_sharks.png", - true); - - // Contents - chkAdminsHaveNegotiation = new CampaignOptionsCheckBox("AdminsHaveNegotiation"); - chkAdminExperienceLevelIncludeNegotiation = new CampaignOptionsCheckBox("AdminExperienceLevelIncludeNegotiation"); - chkAdminsHaveScrounge = new CampaignOptionsCheckBox("AdminsHaveScrounge"); - chkAdminExperienceLevelIncludeScrounge = new CampaignOptionsCheckBox("AdminExperienceLevelIncludeScrounge"); - - // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("AdministratorsTab", true); - final GroupLayout layout = createStandardLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(chkAdminsHaveNegotiation) - .addComponent(chkAdminExperienceLevelIncludeNegotiation) - .addComponent(chkAdminsHaveScrounge) - .addComponent(chkAdminExperienceLevelIncludeScrounge)); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(chkAdminsHaveNegotiation) - .addComponent(chkAdminExperienceLevelIncludeNegotiation) - .addComponent(chkAdminsHaveScrounge) - .addComponent(chkAdminExperienceLevelIncludeScrounge)); - - // Create Parent Panel and return - return createParentPanel(panel, "AdministratorsTab"); - } - /** * Creates the Awards Tab panel with various components like labels, checkboxes, and filter options. * @@ -668,7 +695,7 @@ public Component getListCellRendererComponent(final JList list, final Object // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("AwardsTab", true); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -735,7 +762,7 @@ private JPanel createAutoAwardsFilterPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("AutoAwardsFilterPanel", true, "AutoAwardsFilterPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -800,7 +827,7 @@ JPanel createPrisonersAndDependentsTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("PrisonersAndDependentsTab", true, ""); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -852,7 +879,7 @@ public Component getListCellRendererComponent(final JList list, final Object // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("PrisonersPanel", true, "PrisonersPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -894,7 +921,7 @@ private JPanel createDependentsPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("DependentsPanel", true, "DependentsPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -946,7 +973,7 @@ JPanel createMedicalTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("MedicalTab", true); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -1010,7 +1037,7 @@ JPanel createSalariesTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("SalariesTab", true); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -1051,7 +1078,7 @@ private JPanel createSalaryMultipliersPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("SalaryMultipliersPanel", true, "SalaryMultipliersPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -1097,7 +1124,7 @@ private JPanel createExperienceMultipliersPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("ExperienceMultipliersPanel", true, "ExperienceMultipliersPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); SkillLevel[] skillLevels = SkillLevel.values(); @@ -1181,7 +1208,7 @@ private JPanel createBaseSalariesPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("BaseSalariesPanel", true, "BaseSalariesPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); SequentialGroup mainHorizontalGroup = layout.createSequentialGroup(); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java index e8393fe928..b6b2505b69 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java @@ -218,7 +218,7 @@ JPanel createMarriageTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("MarriageTab", true); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -265,7 +265,7 @@ private JPanel createMarriageGeneralOptionsPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("MarriageGeneralOptionsPanel", false); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -336,7 +336,7 @@ public Component getListCellRendererComponent(final JList list, final Object // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("RandomMarriages", true, "RandomMarriages"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -393,7 +393,7 @@ private JPanel createPercentageRandomMarriagePanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("PercentageRandomMarriagePanel", true, "PercentageRandomMarriagePanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -449,7 +449,7 @@ JPanel createDivorceTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("DivorceTab", true); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -506,7 +506,7 @@ public Component getListCellRendererComponent(final JList list, final Object // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("RandomDivorcePanel", true, "RandomDivorcePanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -559,7 +559,7 @@ JPanel createProcreationTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("ProcreationTab", true); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -626,7 +626,7 @@ public Component getListCellRendererComponent(final JList list, final Object // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("ProcreationGeneralOptionsPanel", false); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -712,7 +712,7 @@ public Component getListCellRendererComponent(final JList list, final Object // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("RandomProcreationPanel", true, "RandomProcreationPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java index c9060a4ad3..92344e79a4 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java @@ -148,7 +148,7 @@ JPanel createRepairTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("repairTab", true); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -237,7 +237,7 @@ JPanel createMaintenanceTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("repairTab", true); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/RulesetsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/RulesetsTab.java index 16341ed189..8be2512e31 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/RulesetsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/RulesetsTab.java @@ -230,7 +230,7 @@ private JPanel createUniversalScenarioGenerationPanel() { // Layout the panel final JPanel panel = new CampaignOptionsStandardPanel("UniversalScenarioGenerationPanel", true, "UniversalScenarioGenerationPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -281,7 +281,7 @@ private JPanel createUniversalUnitRatioPanel() { // Layout the panel final JPanel panel = new CampaignOptionsStandardPanel("UniversalUnitRatioPanel", true, "UniversalUnitRatioPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -322,7 +322,7 @@ private JPanel createUniversalModifiersPanel() { // Layout the panel final JPanel panel = new CampaignOptionsStandardPanel("UniversalModifiersPanel", true, "UniversalModifiersPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -364,7 +364,7 @@ private JPanel createUniversalMapGenerationPanel() { // Layout the panel final JPanel panel = new CampaignOptionsStandardPanel("UniversalMapGenerationPanel", true, "UniversalMapGenerationPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -392,7 +392,7 @@ private JPanel createUniversalCampaignOptionsPanel() { // Layout the panel final JPanel panel = new CampaignOptionsStandardPanel("UniversalCampaignOptionsPanel", false, ""); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -421,7 +421,7 @@ private JPanel createUniversalPartsPanel() { // Layout the panel final JPanel panel = new CampaignOptionsStandardPanel("UniversalPartsPanel", true, "UniversalPartsPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -463,7 +463,7 @@ private JPanel createUniversalLancePanel() { // Layout the panel final JPanel panel = new CampaignOptionsStandardPanel("UniversalLancePanel", true, "UniversalLancePanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -514,7 +514,7 @@ JPanel createStratConTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("StratConTab", true); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -590,7 +590,7 @@ JPanel createLegacyTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("LegacyTab", true, ""); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -627,7 +627,7 @@ private JPanel createLegacyOpForGenerationPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("LegacyOpForGenerationPanel", true, "LegacyOpForGenerationPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -678,7 +678,7 @@ private JPanel createLegacyScenarioGenerationPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("LegacyScenarioGenerationPanel", true, "LegacyScenarioGenerationPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java index 6f0f8dbd1d..1e6026d408 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/SelectPresetDialog.java @@ -31,7 +31,7 @@ import static megamek.client.ui.WrapLayout.wordWrap; import static megamek.client.ui.swing.util.FlatLafStyleBuilder.setFontScaling; -import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.createStandardLayout; +import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.createGroupLayout; /** * A dialog for selecting campaign presets. Extends {@link JDialog}. @@ -96,7 +96,7 @@ public SelectPresetDialog(JFrame frame, boolean includePresetSelectOption, boole add(imageLabel, BorderLayout.NORTH); JPanel centerPanel = new JPanel(); - final GroupLayout layout = createStandardLayout(centerPanel); + final GroupLayout layout = createGroupLayout(centerPanel); centerPanel.setLayout(layout); JLabel descriptionLabel = new JLabel(String.format( diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java index c0d13bad8f..6f05261490 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java @@ -240,7 +240,7 @@ JPanel createTurnoverTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("TurnoverTab", true); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -331,7 +331,7 @@ public Component getListCellRendererComponent(final JList list, final Object // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("SettingsPanel", true, "SettingsPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -421,7 +421,7 @@ private JPanel createModifiersPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("TurnoverModifiersPanel", true, "ModifiersPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -493,7 +493,7 @@ private JPanel createPayoutsPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("PayoutsPanel", true, "PayoutsPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -554,7 +554,7 @@ private JPanel createUnitCohesionPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("UnitCohesionPanel", true, "UnitCohesionPanel"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -591,7 +591,7 @@ private JPanel createAdministrativeStrainWrapperPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("AdministrativeStrainPanel", false); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -633,7 +633,7 @@ private JPanel createAdministrativeStrainPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("AdministrativeStrain", true, "AdministrativeStrain"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -678,7 +678,7 @@ private JPanel createManagementSkillWrapperPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("UnitCohesionPanel", false); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -719,7 +719,7 @@ private JPanel createManagementSkillPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("ManagementSkill", true, "ManagementSkill"); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( @@ -780,7 +780,7 @@ JPanel createFatigueTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("FatigueTab", true); - final GroupLayout layout = createStandardLayout(panel); + final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); layout.setVerticalGroup( From 81ddd9da5948c87a29da656d63dc49ebfca81324 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 15 Oct 2024 21:26:03 -0500 Subject: [PATCH 088/117] Refactor Awards Tab initialization Renamed and reorganized variables and methods for better clarity and maintainability. Updated the initialization process in `createAwardsTab` and related methods to create more structured and readable code. Eliminated redundant code blocks to enhance readability. --- .../panes/campaignOptions/PersonnelTab.java | 365 ++++++++++-------- 1 file changed, 195 insertions(+), 170 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java index 9918b4b55d..f0764f7288 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java @@ -75,6 +75,7 @@ public class PersonnelTab { //end Personnel Information Tab //start Awards Tab + private JPanel pnlAwardsGeneralOptions; private JLabel lblAwardBonusStyle; private MMComboBox comboAwardBonusStyle; private JLabel lblAwardTierSize; @@ -84,7 +85,7 @@ public class PersonnelTab { private JCheckBox chkIssueBestAwardOnly; private JCheckBox chkIgnoreStandardSet; - private JPanel autoAwardsFilterPanel; + private JPanel pnlAutoAwardsFilter; private JCheckBox chkEnableContractAwards; private JCheckBox chkEnableFactionHunterAwards; private JCheckBox chkEnableInjuryAwards; @@ -247,6 +248,7 @@ private void initializeMedicalTab() { * The panel contains settings related to award allocation. */ private void initializeAwardsTab() { + pnlAwardsGeneralOptions = new JPanel(); lblAwardBonusStyle = new JLabel(); comboAwardBonusStyle = new MMComboBox<>("comboAwardBonusStyle", AwardBonus.values()); @@ -269,7 +271,7 @@ private void initializeAwardsTab() { chkEnableTrainingAwards = new JCheckBox(); chkEnableMiscAwards = new JCheckBox(); - autoAwardsFilterPanel = new JPanel(); + pnlAutoAwardsFilter = new JPanel(); lblAwardSetFilterList = new JLabel(); txtAwardSetFilterList = new JTextArea(); } @@ -418,7 +420,6 @@ private JPanel createGeneralOptionsPanel() { layout.gridy = 0; layout.gridwidth = 1; - layout.gridy++; panel.add(chkUseTactics, layout); layout.gridy++; @@ -476,7 +477,6 @@ private JPanel createPersonnelCleanUpPanel() { layout.gridy = 0; layout.gridwidth = 1; - layout.gridy++; panel.add(chkUsePersonnelRemoval, layout); layout.gridy++; @@ -510,7 +510,6 @@ private JPanel createAdministratorsPanel() { layout.gridy = 0; layout.gridwidth = 1; - layout.gridy++; panel.add(chkAdminsHaveNegotiation, layout); layout.gridy++; @@ -525,6 +524,197 @@ private JPanel createAdministratorsPanel() { return panel; } + /** + * Creates the Awards Tab panel with various components like labels, checkboxes, and filter options. + * + * @return the {@link JPanel} representing the Awards Tab panel + */ + JPanel createAwardsTab() { + // Header + JPanel headerPanel = new CampaignOptionsHeaderPanel("AwardsTab", + getImageDirectory() + "logo_draconis_combine.png", + true); + + // Contents + pnlAwardsGeneralOptions = createAwardsGeneralOptionsPanel(); + pnlAutoAwardsFilter = createAutoAwardsFilterPanel(); + + lblAwardSetFilterList = new CampaignOptionsLabel("AwardSetFilterList"); + txtAwardSetFilterList = new JTextArea(5, 20); + txtAwardSetFilterList.setLineWrap(true); + txtAwardSetFilterList.setWrapStyleWord(true); + txtAwardSetFilterList.setToolTipText( + wordWrap(resources.getString("lblAwardSetFilterList.tooltip"))); + txtAwardSetFilterList.setName("txtAwardSetFilterList"); + txtAwardSetFilterList.setText(""); + JScrollPane scrollAwardSetFilterList = new JScrollPane(txtAwardSetFilterList); + scrollAwardSetFilterList.setHorizontalScrollBarPolicy( + ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + scrollAwardSetFilterList.setVerticalScrollBarPolicy( + ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); + + // Layout the Panel + final JPanel panelRight = new CampaignOptionsStandardPanel("AwardsTab", false); + final GridBagConstraints layoutRight = new CampaignOptionsGridBagConstraints(panelRight); + + layoutRight.gridy = 0; + layoutRight.gridwidth = 1; + layoutRight.gridy++; + panelRight.add(pnlAutoAwardsFilter, layoutRight); + + layoutRight.gridx = 0; + layoutRight.gridy++; + panelRight.add(lblAwardSetFilterList, layoutRight); + layoutRight.gridy++; + panelRight.add(txtAwardSetFilterList, layoutRight); + + final JPanel panelParent = new CampaignOptionsStandardPanel("AwardsTabRight", true); + final GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panelParent); + + layoutParent.gridwidth = 5; + layoutParent.gridy = 0; + panelParent.add(headerPanel, layoutParent); + + layoutParent.gridx = 0; + layoutParent.gridy++; + layoutParent.gridwidth = 1; + panelParent.add(pnlAwardsGeneralOptions, layoutParent); + + layoutParent.gridx++; + panelParent.add(panelRight, layoutParent); + + // Create Parent Panel and return + return createParentPanel(panelParent, "AwardsTab"); + } + + JPanel createAwardsGeneralOptionsPanel() { + // Contents + lblAwardBonusStyle = new CampaignOptionsLabel("AwardBonusStyle"); + comboAwardBonusStyle.setRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(final JList list, final Object value, + final int index, final boolean isSelected, + final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof AwardBonus) { + list.setToolTipText(((AwardBonus) value).getToolTipText()); + } + return this; + } + }); + + lblAwardTierSize = new CampaignOptionsLabel("AwardTierSize"); + spnAwardTierSize = new CampaignOptionsSpinner("AwardTierSize", + 5, 1, 100, 1); + + chkEnableAutoAwards = new CampaignOptionsCheckBox("EnableAutoAwards"); + + chkIssuePosthumousAwards = new CampaignOptionsCheckBox("IssuePosthumousAwards"); + + chkIssueBestAwardOnly = new CampaignOptionsCheckBox("IssueBestAwardOnly"); + + chkIgnoreStandardSet = new CampaignOptionsCheckBox("IgnoreStandardSet"); + + // Layout the Panel + final JPanel panel = new CampaignOptionsStandardPanel("AwardsGeneralOptionsPanel", false); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 1; + panel.add(lblAwardBonusStyle, layout); + layout.gridx++; + layout.gridwidth = 2; + panel.add(comboAwardBonusStyle, layout); + + layout.gridx = 0; + layout.gridy++; + layout.gridwidth = 1; + panel.add(lblAwardTierSize, layout); + layout.gridx++; + layout.gridwidth = 2; + panel.add(spnAwardTierSize, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkEnableAutoAwards, layout); + + layout.gridy++; + panel.add(chkIssuePosthumousAwards, layout); + + layout.gridy++; + panel.add(chkIssueBestAwardOnly, layout); + + layout.gridy++; + panel.add(chkIgnoreStandardSet, layout); + + return panel; + } + + /** + * Creates a panel with checkboxes for various types of autoAwards award filter options. + *

+ * This method creates checkboxes for different types of awards filters such as contract awards, + * faction hunter awards, injury awards, individual kill awards, etc. + * + * @return a {@link JPanel} containing checkboxes for various types of autoAwards award filter + * options + */ + private JPanel createAutoAwardsFilterPanel() { + // Contents + chkEnableContractAwards = new CampaignOptionsCheckBox("EnableContractAwards"); + chkEnableFactionHunterAwards = new CampaignOptionsCheckBox("EnableFactionHunterAwards"); + chkEnableInjuryAwards = new CampaignOptionsCheckBox("EnableInjuryAwards"); + chkEnableIndividualKillAwards = new CampaignOptionsCheckBox("EnableIndividualKillAwards"); + chkEnableFormationKillAwards = new CampaignOptionsCheckBox("EnableFormationKillAwards"); + chkEnableRankAwards = new CampaignOptionsCheckBox("EnableRankAwards"); + chkEnableScenarioAwards = new CampaignOptionsCheckBox("EnableScenarioAwards"); + chkEnableSkillAwards = new CampaignOptionsCheckBox("EnableSkillAwards"); + chkEnableTheatreOfWarAwards = new CampaignOptionsCheckBox("EnableTheatreOfWarAwards"); + chkEnableTimeAwards = new CampaignOptionsCheckBox("EnableTimeAwards"); + chkEnableTrainingAwards = new CampaignOptionsCheckBox("EnableTrainingAwards"); + chkEnableMiscAwards = new CampaignOptionsCheckBox("EnableMiscAwards"); + + // Layout the Panel + final JPanel panel = new CampaignOptionsStandardPanel("AutoAwardsFilterPanel", true, "AutoAwardsFilterPanel"); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 1; + panel.add(chkEnableContractAwards, layout); + layout.gridx++; + panel.add(chkEnableFactionHunterAwards, layout); + layout.gridx++; + panel.add(chkEnableInjuryAwards, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkEnableIndividualKillAwards, layout); + layout.gridx++; + panel.add(chkEnableFormationKillAwards, layout); + layout.gridx++; + panel.add(chkEnableRankAwards, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkEnableScenarioAwards, layout); + layout.gridx++; + panel.add(chkEnableSkillAwards, layout); + layout.gridx++; + panel.add(chkEnableTheatreOfWarAwards, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkEnableTimeAwards, layout); + layout.gridx++; + panel.add(chkEnableTrainingAwards, layout); + layout.gridx++; + panel.add(chkEnableMiscAwards, layout); + + return panel; + } + /** * Creates a tab for managing personnel logs. * @@ -639,171 +829,6 @@ JPanel createPersonnelInformationTab() { return createParentPanel(panel, "PersonnelInformation"); } - /** - * Creates the Awards Tab panel with various components like labels, checkboxes, and filter options. - * - * @return the {@link JPanel} representing the Awards Tab panel - */ - JPanel createAwardsTab() { - // Header - JPanel headerPanel = new CampaignOptionsHeaderPanel("AwardsTab", - getImageDirectory() + "logo_draconis_combine.png", - true); - - // Contents - lblAwardBonusStyle = new CampaignOptionsLabel("AwardBonusStyle"); - comboAwardBonusStyle.setRenderer(new DefaultListCellRenderer() { - @Override - public Component getListCellRendererComponent(final JList list, final Object value, - final int index, final boolean isSelected, - final boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (value instanceof AwardBonus) { - list.setToolTipText(((AwardBonus) value).getToolTipText()); - } - return this; - } - }); - - lblAwardTierSize = new CampaignOptionsLabel("AwardTierSize"); - spnAwardTierSize = new CampaignOptionsSpinner("AwardTierSize", - 5, 1, 100, 1); - - chkEnableAutoAwards = new CampaignOptionsCheckBox("EnableAutoAwards"); - - chkIssuePosthumousAwards = new CampaignOptionsCheckBox("IssuePosthumousAwards"); - - chkIssueBestAwardOnly = new CampaignOptionsCheckBox("IssueBestAwardOnly"); - - chkIgnoreStandardSet = new CampaignOptionsCheckBox("IgnoreStandardSet"); - - autoAwardsFilterPanel = createAutoAwardsFilterPanel(); - - lblAwardSetFilterList = new CampaignOptionsLabel("AwardSetFilterList"); - txtAwardSetFilterList = new JTextArea(5, 20); - txtAwardSetFilterList.setLineWrap(true); - txtAwardSetFilterList.setWrapStyleWord(true); - txtAwardSetFilterList.setToolTipText( - wordWrap(resources.getString("lblAwardSetFilterList.tooltip"))); - txtAwardSetFilterList.setName("txtAwardSetFilterList"); - txtAwardSetFilterList.setText(""); - JScrollPane scrollAwardSetFilterList = new JScrollPane(txtAwardSetFilterList); - scrollAwardSetFilterList.setHorizontalScrollBarPolicy( - ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); - scrollAwardSetFilterList.setVerticalScrollBarPolicy( - ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); - - // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("AwardsTab", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblAwardBonusStyle) - .addComponent(comboAwardBonusStyle)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblAwardTierSize) - .addComponent(spnAwardTierSize)) - .addComponent(chkEnableAutoAwards) - .addComponent(chkIssuePosthumousAwards) - .addComponent(chkIssueBestAwardOnly) - .addComponent(chkIgnoreStandardSet) - .addComponent(autoAwardsFilterPanel) - .addComponent(lblAwardSetFilterList) - .addComponent(txtAwardSetFilterList)); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addGroup(layout.createSequentialGroup() - .addComponent(lblAwardBonusStyle) - .addComponent(comboAwardBonusStyle)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblAwardTierSize) - .addComponent(spnAwardTierSize)) - .addComponent(chkEnableAutoAwards) - .addComponent(chkIssuePosthumousAwards) - .addComponent(chkIssueBestAwardOnly) - .addComponent(chkIgnoreStandardSet) - .addComponent(autoAwardsFilterPanel) - .addComponent(lblAwardSetFilterList) - .addComponent(txtAwardSetFilterList)); - - // Create Parent Panel and return - return createParentPanel(panel, "AwardsTab"); - } - - /** - * Creates a panel with checkboxes for various types of autoAwards award filter options. - *

- * This method creates checkboxes for different types of awards filters such as contract awards, - * faction hunter awards, injury awards, individual kill awards, etc. - * - * @return a {@link JPanel} containing checkboxes for various types of autoAwards award filter - * options - */ - private JPanel createAutoAwardsFilterPanel() { - // Contents - chkEnableContractAwards = new CampaignOptionsCheckBox("EnableContractAwards"); - chkEnableFactionHunterAwards = new CampaignOptionsCheckBox("EnableFactionHunterAwards"); - chkEnableInjuryAwards = new CampaignOptionsCheckBox("EnableInjuryAwards"); - chkEnableIndividualKillAwards = new CampaignOptionsCheckBox("EnableIndividualKillAwards"); - chkEnableFormationKillAwards = new CampaignOptionsCheckBox("EnableFormationKillAwards"); - chkEnableRankAwards = new CampaignOptionsCheckBox("EnableRankAwards"); - chkEnableScenarioAwards = new CampaignOptionsCheckBox("EnableScenarioAwards"); - chkEnableSkillAwards = new CampaignOptionsCheckBox("EnableSkillAwards"); - chkEnableTheatreOfWarAwards = new CampaignOptionsCheckBox("EnableTheatreOfWarAwards"); - chkEnableTimeAwards = new CampaignOptionsCheckBox("EnableTimeAwards"); - chkEnableTrainingAwards = new CampaignOptionsCheckBox("EnableTrainingAwards"); - chkEnableMiscAwards = new CampaignOptionsCheckBox("EnableMiscAwards"); - - // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("AutoAwardsFilterPanel", true, "AutoAwardsFilterPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createParallelGroup(Alignment.BASELINE) - .addGroup(layout.createSequentialGroup() - .addComponent(chkEnableContractAwards) - .addComponent(chkEnableFactionHunterAwards) - .addComponent(chkEnableInjuryAwards) - .addComponent(chkEnableIndividualKillAwards)) - .addGroup(layout.createSequentialGroup() - .addComponent(chkEnableRankAwards) - .addComponent(chkEnableScenarioAwards) - .addComponent(chkEnableSkillAwards) - .addComponent(chkEnableFormationKillAwards)) - .addGroup(layout.createSequentialGroup() - .addComponent(chkEnableTheatreOfWarAwards) - .addComponent(chkEnableTimeAwards) - .addComponent(chkEnableTrainingAwards) - .addComponent(chkEnableMiscAwards))); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup() - .addComponent(chkEnableContractAwards) - .addComponent(chkEnableFactionHunterAwards) - .addComponent(chkEnableInjuryAwards) - .addComponent(chkEnableIndividualKillAwards)) - .addGroup(layout.createParallelGroup() - .addComponent(chkEnableFormationKillAwards) - .addComponent(chkEnableRankAwards) - .addComponent(chkEnableScenarioAwards) - .addComponent(chkEnableSkillAwards)) - .addGroup(layout.createParallelGroup() - .addComponent(chkEnableTheatreOfWarAwards) - .addComponent(chkEnableTimeAwards) - .addComponent(chkEnableTrainingAwards) - .addComponent(chkEnableMiscAwards))); - - return panel; - } - /** * Creates a panel for configuring settings related to prisoners and dependents. *

From 9e1a678e5bb41bc0e217a0aceb6f6fafe671a96b Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 15 Oct 2024 21:58:24 -0500 Subject: [PATCH 089/117] Refactor medical and personnel tab creation Separated the creation logic for medical and personnel logs panels into distinct methods. This improves the manageability and readability of the code. Additionally, adjusted the tab structure to reflect the new panel separations. --- .../NEWCampaignOptionsDialog.properties | 13 +- .../campaignOptions/CampaignOptionsPane.java | 1 - .../CampaignOptionsUtilities.java | 7 +- .../panes/campaignOptions/PersonnelTab.java | 331 ++++++++++-------- 4 files changed, 182 insertions(+), 170 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 9aaf5846ee..7933a54846 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -237,11 +237,6 @@ personnelGeneralTab.border="You can replace a 'mek. You can't replace a veteran \ valuable asset, even when they come with attitude."\
- Major Helena "Steelheart" Graves, Valiant Shields -personnelLogsTab.title=Personnel Logs -personnelLogsTab.border="You think piloting a 'mek is stressful? Try keeping a personnel log for a\ - \ lance full of trigger-happy maniacs."\ -
- Sergeant Dana "Firestorm" Watts, Broken Sword Regiment - personnelInformationTab.title=Personnel Information personnelInformationTab.border="Every log entry isn't just data - it's the history of our survival,\ \ our victories, and our failures. Keep them well, because one day they'll save us again."\ @@ -306,13 +301,7 @@ lblUseRemovalExemptRetirees.text=Exempt Retirees lblUseRemovalExemptRetirees.tooltip=PLACEHOLDER # createPersonnelLogsTab -lblPersonnelLogsTab.text=Personnel Log Options -lblPersonnelLogsTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ - \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ - \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ - \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ - \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ - \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblPersonnelLogsPanel.text=Personnel Logs lblUseTransfers.text=Use Reassign for Logging lblUseTransfers.tooltip=PLACEHOLDER lblUseExtendedTOEForceName.text=Use Extended TO&E Names in Log diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java index 800f64dd30..bf35f0146e 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java @@ -99,7 +99,6 @@ private JTabbedPane createHumanResourcesParentTab() { JTabbedPane personnelContentTabs = createSubTabs(Map.of( "personnelGeneralTab", personnelTab.createGeneralTab(), - "personnelLogsTab", personnelTab.createPersonnelLogsTab(), "personnelInformationTab", personnelTab.createPersonnelInformationTab(), "awardsTab", personnelTab.createAwardsTab(), "prisonersAndDependentsTab", personnelTab.createPrisonersAndDependentsTab(), diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java index ddd5a904ef..0812ecefe2 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java @@ -9,6 +9,7 @@ import java.util.List; import java.util.*; +import static java.lang.Math.round; import static megamek.client.ui.WrapLayout.wordWrap; import static megamek.client.ui.swing.util.FlatLafStyleBuilder.setFontScaling; @@ -319,8 +320,8 @@ public CampaignOptionsHeaderPanel(String name, String imageAddress, boolean incl // Fetch and scale image ImageIcon imageIcon = new ImageIcon(imageAddress); - int width = UIUtil.scaleForGUI(imageIcon.getIconWidth()); - int height = UIUtil.scaleForGUI(imageIcon.getIconHeight()); + int width = (int) UIUtil.scaleForGUI(round(imageIcon.getIconWidth() * .75)); + int height = (int) UIUtil.scaleForGUI(round(imageIcon.getIconHeight() * .75)); Image image = imageIcon.getImage(); Image scaledImage = image.getScaledInstance(width, height, Image.SCALE_SMOOTH); @@ -336,7 +337,7 @@ public CampaignOptionsHeaderPanel(String name, String imageAddress, boolean incl JLabel lblBody = new JLabel(); if (includeBodyText) { - lblBody = new JLabel(String.format("

%s
", + lblBody = new JLabel(String.format("
%s
", UIUtil.scaleForGUI(750), resources.getString("lbl" + name + "Body.text")), SwingConstants.CENTER); lblBody.setName("lbl" + name + "Body"); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java index f0764f7288..8e11ab47ef 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java @@ -5,6 +5,7 @@ import megamek.common.enums.SkillLevel; import mekhq.campaign.personnel.Skills; import mekhq.campaign.personnel.enums.*; +import mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; import javax.swing.*; import javax.swing.GroupLayout.Alignment; @@ -716,58 +717,101 @@ private JPanel createAutoAwardsFilterPanel() { } /** - * Creates a tab for managing personnel logs. + * Creates a panel for the Medical Tab in the application. * - * @return a {@link JPanel} representing the Personnel Logs Tab panel + * @return a {@link JPanel} representing the Medical Tab containing settings for medical options. */ - JPanel createPersonnelLogsTab() { + JPanel createMedicalTab() { // Header - JPanel headerPanel = new CampaignOptionsHeaderPanel("PersonnelLogsTab", - getImageDirectory() + "logo_clan_coyote.png", + JPanel headerPanel = new CampaignOptionsHeaderPanel("MedicalTab", + getImageDirectory() + "logo_duchy_of_tamarind_abbey.png", true); // Contents - chkUseTransfers = new CampaignOptionsCheckBox("UseTransfers"); - chkUseExtendedTOEForceName = new CampaignOptionsCheckBox("UseExtendedTOEForceName"); - chkPersonnelLogSkillGain = new CampaignOptionsCheckBox("PersonnelLogSkillGain"); - chkPersonnelLogAbilityGain = new CampaignOptionsCheckBox("PersonnelLogAbilityGain"); - chkPersonnelLogEdgeGain = new CampaignOptionsCheckBox("PersonnelLogEdgeGain"); - chkDisplayPersonnelLog = new CampaignOptionsCheckBox("DisplayPersonnelLog"); - chkDisplayScenarioLog = new CampaignOptionsCheckBox("DisplayScenarioLog"); - chkDisplayKillRecord = new CampaignOptionsCheckBox("DisplayKillRecord"); + chkUseAdvancedMedical = new CampaignOptionsCheckBox("UseAdvancedMedical"); - // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("PersonnelLogsTab", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + lblHealWaitingPeriod = new CampaignOptionsLabel("HealWaitingPeriod"); + spnHealWaitingPeriod = new CampaignOptionsSpinner("HealWaitingPeriod", + 1, 1, 30, 1); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(chkUseTransfers) - .addComponent(chkUseExtendedTOEForceName) - .addComponent(chkPersonnelLogSkillGain) - .addComponent(chkPersonnelLogAbilityGain) - .addComponent(chkPersonnelLogEdgeGain) - .addComponent(chkDisplayPersonnelLog) - .addComponent(chkDisplayScenarioLog) - .addComponent(chkDisplayKillRecord)); + lblNaturalHealWaitingPeriod = new CampaignOptionsLabel("NaturalHealWaitingPeriod"); + spnNaturalHealWaitingPeriod = new CampaignOptionsSpinner("NaturalHealWaitingPeriod", + 1, 1, 365, 1); - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(chkUseTransfers) - .addComponent(chkUseExtendedTOEForceName) - .addComponent(chkPersonnelLogSkillGain) - .addComponent(chkPersonnelLogAbilityGain) - .addComponent(chkPersonnelLogEdgeGain) - .addComponent(chkDisplayPersonnelLog) - .addComponent(chkDisplayScenarioLog) - .addComponent(chkDisplayKillRecord) - ); + lblMinimumHitsForVehicles = new CampaignOptionsLabel("MinimumHitsForVehicles"); + spnMinimumHitsForVehicles = new CampaignOptionsSpinner("MinimumHitsForVehicles", + 1, 1, 5, 1); + + chkUseRandomHitsForVehicles = new CampaignOptionsCheckBox("UseRandomHitsForVehicles"); + + chkUseTougherHealing = new CampaignOptionsCheckBox("UseTougherHealing"); + + lblMaximumPatients = new CampaignOptionsLabel("MaximumPatients"); + spnMaximumPatients = new CampaignOptionsSpinner("MaximumPatients", + 25, 1, 100, 1); + + final JPanel panelLeft = new CampaignOptionsStandardPanel("MedicalTabLeft", false); + final GridBagConstraints layoutLeft = new CampaignOptionsGridBagConstraints(panelLeft); + + layoutLeft.gridy = 0; + layoutLeft.gridx = 0; + layoutLeft.gridwidth = 1; + panelLeft.add(lblMaximumPatients, layoutLeft); + layoutLeft.gridx++; + panelLeft.add(spnMaximumPatients, layoutLeft); + + layoutLeft.gridx = 0; + layoutLeft.gridy++; + panelLeft.add(lblHealWaitingPeriod, layoutLeft); + layoutLeft.gridx++; + panelLeft.add(spnHealWaitingPeriod, layoutLeft); + + layoutLeft.gridx = 0; + layoutLeft.gridy++; + panelLeft.add(lblNaturalHealWaitingPeriod, layoutLeft); + layoutLeft.gridx++; + panelLeft.add(spnNaturalHealWaitingPeriod, layoutLeft); + + layoutLeft.gridx = 0; + layoutLeft.gridy++; + panelLeft.add(chkUseRandomHitsForVehicles, layoutLeft); + + layoutLeft.gridx = 0; + layoutLeft.gridy++; + panelLeft.add(lblMinimumHitsForVehicles, layoutLeft); + layoutLeft.gridx++; + panelLeft.add(spnMinimumHitsForVehicles, layoutLeft); + + // Layout the Panels + final JPanel panelRight = new CampaignOptionsStandardPanel("MedicalTabRight", false); + final GridBagConstraints layoutRight = new CampaignOptionsGridBagConstraints(panelRight); + + layoutRight.gridy++; + layoutRight.gridwidth = 1; + panelRight.add(chkUseAdvancedMedical, layoutRight); + + layoutRight.gridx = 0; + layoutRight.gridy++; + panelRight.add(chkUseTougherHealing, layoutRight); + + // Layout the Panels + final JPanel panelParent = new CampaignOptionsStandardPanel("MedicalTab", true); + final GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panelParent); + + layoutParent.gridwidth = 5; + layoutParent.gridx = 0; + layoutParent.gridy = 0; + panelParent.add(headerPanel, layoutParent); + + layoutParent.gridy++; + layoutParent.gridwidth = 1; + panelParent.add(panelLeft, layoutParent); + + layoutParent.gridx++; + panelParent.add(panelRight, layoutParent); // Create Parent Panel and return - return createParentPanel(panel, "PersonnelLogsTab"); + return createParentPanel(panelParent, "MedicalTab"); } /** @@ -790,43 +834,103 @@ JPanel createPersonnelInformationTab() { chkTrackTotalXPEarnings = new CampaignOptionsCheckBox("TrackTotalXPEarnings"); chkShowOriginFaction = new CampaignOptionsCheckBox("ShowOriginFaction"); + JPanel pnlPersonnelLogs = createPersonnelLogsPanel(); + // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("PersonnelInformation", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + final JPanel panelLeft = new CampaignOptionsStandardPanel("PersonnelInformationLeft", false); + final GridBagConstraints layoutLeft = new CampaignOptionsGridBagConstraints(panelLeft); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(chkUseTimeInService) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblTimeInServiceDisplayFormat) - .addComponent(comboTimeInServiceDisplayFormat)) - .addComponent(chkUseTimeInRank) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblTimeInRankDisplayFormat) - .addComponent(comboTimeInRankDisplayFormat)) - .addComponent(chkTrackTotalEarnings) - .addComponent(chkTrackTotalXPEarnings) - .addComponent(chkShowOriginFaction)); + layoutLeft.gridy++; + layoutLeft.gridwidth = 1; + panelLeft.add(chkUseTimeInService, layoutLeft); - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(chkUseTimeInService) - .addGroup(layout.createSequentialGroup() - .addComponent(lblTimeInServiceDisplayFormat) - .addComponent(comboTimeInServiceDisplayFormat)) - .addComponent(chkUseTimeInRank) - .addGroup(layout.createSequentialGroup() - .addComponent(lblTimeInRankDisplayFormat) - .addComponent(comboTimeInRankDisplayFormat)) - .addComponent(chkTrackTotalEarnings) - .addComponent(chkTrackTotalXPEarnings) - .addComponent(chkShowOriginFaction)); + layoutLeft.gridx = 0; + layoutLeft.gridy++; + panelLeft.add(lblTimeInServiceDisplayFormat, layoutLeft); + layoutLeft.gridx++; + panelLeft.add(comboTimeInServiceDisplayFormat, layoutLeft); + + layoutLeft.gridx = 0; + layoutLeft.gridy++; + panelLeft.add(chkUseTimeInRank, layoutLeft); + + layoutLeft.gridx = 0; + layoutLeft.gridy++; + panelLeft.add(lblTimeInRankDisplayFormat, layoutLeft); + layoutLeft.gridx++; + panelLeft.add(comboTimeInRankDisplayFormat, layoutLeft); + + layoutLeft.gridx = 0; + layoutLeft.gridy++; + panelLeft.add(chkTrackTotalEarnings, layoutLeft); + + layoutLeft.gridy++; + panelLeft.add(chkTrackTotalXPEarnings, layoutLeft); + + layoutLeft.gridy++; + panelLeft.add(chkShowOriginFaction, layoutLeft); + + final JPanel panelParent = new CampaignOptionsStandardPanel("PersonnelInformation", true); + final GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panelParent); + + layoutParent.gridwidth = 5; + layoutParent.gridx = 0; + layoutParent.gridy = 0; + panelParent.add(headerPanel, layoutParent); + + layoutParent.gridy++; + layoutParent.gridwidth = 1; + panelParent.add(panelLeft, layoutParent); + + layoutParent.gridx++; + panelParent.add(pnlPersonnelLogs, layoutParent); // Create Parent Panel and return - return createParentPanel(panel, "PersonnelInformation"); + return createParentPanel(panelParent, "PersonnelInformation"); + } + + JPanel createPersonnelLogsPanel() { + // Contents + chkUseTransfers = new CampaignOptionsCheckBox("UseTransfers"); + chkUseExtendedTOEForceName = new CampaignOptionsCheckBox("UseExtendedTOEForceName"); + chkPersonnelLogSkillGain = new CampaignOptionsCheckBox("PersonnelLogSkillGain"); + chkPersonnelLogAbilityGain = new CampaignOptionsCheckBox("PersonnelLogAbilityGain"); + chkPersonnelLogEdgeGain = new CampaignOptionsCheckBox("PersonnelLogEdgeGain"); + chkDisplayPersonnelLog = new CampaignOptionsCheckBox("DisplayPersonnelLog"); + chkDisplayScenarioLog = new CampaignOptionsCheckBox("DisplayScenarioLog"); + chkDisplayKillRecord = new CampaignOptionsCheckBox("DisplayKillRecord"); + + // Layout the Panel + final JPanel panel = new CampaignOptionsStandardPanel("PersonnelLogsPanel", true, + "PersonnelLogsPanel"); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + panel.add(chkUseTransfers, layout); + + layout.gridy++; + panel.add(chkUseExtendedTOEForceName, layout); + + layout.gridy++; + panel.add(chkPersonnelLogSkillGain, layout); + + layout.gridy++; + panel.add(chkPersonnelLogAbilityGain, layout); + + layout.gridy++; + panel.add(chkPersonnelLogEdgeGain, layout); + + layout.gridy++; + panel.add(chkDisplayPersonnelLog, layout); + + layout.gridy++; + panel.add(chkDisplayScenarioLog, layout); + + layout.gridy++; + panel.add(chkDisplayKillRecord, layout); + + return panel; } /** @@ -962,87 +1066,6 @@ private JPanel createDependentsPanel() { return panel; } - /** - * Creates a panel for the Medical Tab in the application. - * - * @return a {@link JPanel} representing the Medical Tab containing settings for medical options. - */ - JPanel createMedicalTab() { - // Header - JPanel headerPanel = new CampaignOptionsHeaderPanel("MedicalTab", - getImageDirectory() + "logo_duchy_of_tamarind_abbey.png", - true); - - // Contents - chkUseAdvancedMedical = new CampaignOptionsCheckBox("UseAdvancedMedical"); - - lblHealWaitingPeriod = new CampaignOptionsLabel("HealWaitingPeriod"); - spnHealWaitingPeriod = new CampaignOptionsSpinner("HealWaitingPeriod", - 1, 1, 30, 1); - - lblNaturalHealWaitingPeriod = new CampaignOptionsLabel("NaturalHealWaitingPeriod"); - spnNaturalHealWaitingPeriod = new CampaignOptionsSpinner("NaturalHealWaitingPeriod", - 1, 1, 365, 1); - - lblMinimumHitsForVehicles = new CampaignOptionsLabel("MinimumHitsForVehicles"); - spnMinimumHitsForVehicles = new CampaignOptionsSpinner("MinimumHitsForVehicles", - 1, 1, 5, 1); - - chkUseRandomHitsForVehicles = new CampaignOptionsCheckBox("UseRandomHitsForVehicles"); - - chkUseTougherHealing = new CampaignOptionsCheckBox("UseTougherHealing"); - - lblMaximumPatients = new CampaignOptionsLabel("MaximumPatients"); - spnMaximumPatients = new CampaignOptionsSpinner("MaximumPatients", - 25, 1, 100, 1); - - // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("MedicalTab", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(chkUseAdvancedMedical) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblHealWaitingPeriod) - .addComponent(spnHealWaitingPeriod)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblNaturalHealWaitingPeriod) - .addComponent(spnNaturalHealWaitingPeriod)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblMinimumHitsForVehicles) - .addComponent(spnMinimumHitsForVehicles)) - .addComponent(chkUseRandomHitsForVehicles) - .addComponent(chkUseTougherHealing) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblMaximumPatients) - .addComponent(spnMaximumPatients))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(chkUseAdvancedMedical) - .addGroup(layout.createSequentialGroup() - .addComponent(lblHealWaitingPeriod) - .addComponent(spnHealWaitingPeriod)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblNaturalHealWaitingPeriod) - .addComponent(spnNaturalHealWaitingPeriod)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblMinimumHitsForVehicles) - .addComponent(spnMinimumHitsForVehicles)) - .addComponent(chkUseRandomHitsForVehicles) - .addComponent(chkUseTougherHealing) - .addGroup(layout.createSequentialGroup() - .addComponent(lblMaximumPatients) - .addComponent(spnMaximumPatients))); - - // Create Parent Panel and return - return createParentPanel(panel, "MedicalTab"); - } - /** * Creates a salary configuration tab for managing salary settings such as multipliers and base salaries. * From 6ee716798c5d49874f00d9fe7aeaeff3b79689a2 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 15 Oct 2024 22:05:34 -0500 Subject: [PATCH 090/117] Switch PersonnelTab layout from GroupLayout to GridBagLayout Converted the layout management in PersonnelTab.java from GroupLayout to GridBagLayout. This improves the organization of UI components and allows for more flexible layout configurations. Simplified the code by removing unnecessary GroupLayout definitions. --- .../panes/campaignOptions/PersonnelTab.java | 92 +++++++++---------- 1 file changed, 42 insertions(+), 50 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java index 8e11ab47ef..67a46f5f8c 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java @@ -5,7 +5,6 @@ import megamek.common.enums.SkillLevel; import mekhq.campaign.personnel.Skills; import mekhq.campaign.personnel.enums.*; -import mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; import javax.swing.*; import javax.swing.GroupLayout.Alignment; @@ -956,22 +955,19 @@ JPanel createPrisonersAndDependentsTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("PrisonersAndDependentsTab", true, ""); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + final GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panel); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(prisonerPanel) - .addComponent(dependentsPanel))); + layoutParent.gridwidth = 5; + layoutParent.gridx = 0; + layoutParent.gridy = 0; + panel.add(headerPanel, layoutParent); - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addGroup(layout.createSequentialGroup() - .addComponent(prisonerPanel) - .addComponent(dependentsPanel))); + layoutParent.gridy++; + layoutParent.gridwidth = 1; + panel.add(prisonerPanel, layoutParent); + + layoutParent.gridx++; + panel.add(dependentsPanel, layoutParent); // Create Parent Panel and return return createParentPanel(panel, "PrisonersAndDependentsTab"); @@ -1007,33 +1003,32 @@ public Component getListCellRendererComponent(final JList list, final Object chkAtBPrisonerRansom = new CampaignOptionsCheckBox("AtBPrisonerRansom"); // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("PrisonersPanel", true, "PrisonersPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + final JPanel panel = new CampaignOptionsStandardPanel("PrisonersPanel", true, + "PrisonersPanel"); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPrisonerCaptureStyle) - .addComponent(comboPrisonerCaptureStyle)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPrisonerStatus) - .addComponent(comboPrisonerStatus)) - .addComponent(chkPrisonerBabyStatus) - .addComponent(chkAtBPrisonerDefection) - .addComponent(chkAtBPrisonerRansom)); + layout.gridy = 0; + layout.gridx = 0; + layout.gridwidth = 1; + panel.add(lblPrisonerCaptureStyle, layout); + layout.gridx++; + panel.add(comboPrisonerCaptureStyle, layout); - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPrisonerCaptureStyle) - .addComponent(comboPrisonerCaptureStyle)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPrisonerStatus) - .addComponent(comboPrisonerStatus)) - .addComponent(chkPrisonerBabyStatus) - .addComponent(chkAtBPrisonerDefection) - .addComponent(chkAtBPrisonerRansom)); + layout.gridx = 0; + layout.gridy++; + panel.add(lblPrisonerStatus, layout); + layout.gridx++; + panel.add(comboPrisonerStatus, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkPrisonerBabyStatus, layout); + + layout.gridy++; + panel.add(chkAtBPrisonerDefection, layout); + + layout.gridy++; + panel.add(chkAtBPrisonerRansom, layout); return panel; } @@ -1050,18 +1045,15 @@ private JPanel createDependentsPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("DependentsPanel", true, "DependentsPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(chkUseRandomDependentAddition) - .addComponent(chkUseRandomDependentRemoval)); + layout.gridy = 0; + layout.gridx = 0; + layout.gridwidth = 1; + panel.add(chkUseRandomDependentAddition, layout); - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(chkUseRandomDependentAddition) - .addComponent(chkUseRandomDependentRemoval)); + layout.gridy++; + panel.add(chkUseRandomDependentRemoval, layout); return panel; } From 3382dcbddf8247c6e937c21cdde925554d7493e8 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 15 Oct 2024 22:11:14 -0500 Subject: [PATCH 091/117] Switch PersonnelTab layouts to GridBagConstraints Replaced GroupLayout with GridBagConstraints in PersonnelTab and SalaryMultipliersPanel. This change provides more flexibility in component positioning and alignment, improving overall layout management. The modifications ensure that UI elements are better organized and maintainable. --- .../panes/campaignOptions/PersonnelTab.java | 66 +++++++++---------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java index 67a46f5f8c..099fc6c4d8 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java @@ -1077,24 +1077,26 @@ JPanel createSalariesTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("SalariesTab", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(chkDisableSecondaryRoleSalary) - .addComponent(pnlSalaryMultipliersPanel) - .addComponent(pnlSalaryExperienceMultipliersPanel) - .addComponent(pnlSalaryBaseSalaryPanel)); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(chkDisableSecondaryRoleSalary) - .addComponent(pnlSalaryMultipliersPanel) - .addComponent(pnlSalaryExperienceMultipliersPanel) - .addComponent(pnlSalaryBaseSalaryPanel)); + layout.gridwidth = 5; + layout.gridy = 0; + panel.add(headerPanel, layout); + + layout.gridx = 0; + layout.gridy++; + layout.gridwidth = 1; + panel.add(chkDisableSecondaryRoleSalary, layout); + + layout.gridy++; + panel.add(pnlSalaryMultipliersPanel, layout); + layout.gridx++; + panel.add(pnlSalaryExperienceMultipliersPanel, layout); + + layout.gridx = 0; + layout.gridy++; + layout.gridwidth = 2; + panel.add(pnlSalaryBaseSalaryPanel, layout); // Create Parent Panel and return return createParentPanel(panel, "SalariesTab"); @@ -1118,24 +1120,20 @@ private JPanel createSalaryMultipliersPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("SalaryMultipliersPanel", true, "SalaryMultipliersPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblAntiMekSalary) - .addComponent(spnAntiMekSalary) - .addComponent(lblSpecialistInfantrySalary) - .addComponent(spnSpecialistInfantrySalary))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblAntiMekSalary) - .addComponent(spnAntiMekSalary) - .addComponent(lblSpecialistInfantrySalary) - .addComponent(spnSpecialistInfantrySalary))); + layout.gridy = 0; + layout.gridx = 0; + layout.gridwidth = 1; + panel.add(lblAntiMekSalary, layout); + layout.gridx++; + panel.add(spnAntiMekSalary, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblSpecialistInfantrySalary, layout); + layout.gridx++; + panel.add(spnSpecialistInfantrySalary, layout); return panel; } From 141c6e77b08b053417f2f8086178d1c423a8a7ec Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 15 Oct 2024 22:34:20 -0500 Subject: [PATCH 092/117] Remove AdministratorsTab and reorder icons in GeneralTab The AdministratorsTab initialization was removed and its components were relocated. Also, reordered the layout of icons in the GeneralTab for better organization. --- .../gui/panes/campaignOptions/GeneralTab.java | 6 ++--- .../panes/campaignOptions/PersonnelTab.java | 22 +++++-------------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java index 47111a95c9..13198c902a 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java @@ -172,11 +172,11 @@ public AbstractMHQScrollablePanel createGeneralTab() { JPanel iconsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); iconsPanel.setBorder(BorderFactory.createTitledBorder("")); - iconsPanel.add(lblCamo); - iconsPanel.add(btnCamo); - iconsPanel.add(Box.createHorizontalStrut(50)); iconsPanel.add(lblIcon); iconsPanel.add(btnIcon); + iconsPanel.add(Box.createHorizontalStrut(50)); + iconsPanel.add(lblCamo); + iconsPanel.add(btnCamo); panel.add(iconsPanel, layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java index 099fc6c4d8..5deb570b30 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java @@ -166,7 +166,6 @@ private void initialize() { initializeGeneralTab(); initializePersonnelLogsTab(); initializePersonnelInformationTab(); - initializeAdministratorsTab(); initializeAwardsTab(); initializeMedicalTab(); initializePrisonersAndDependentsTab(); @@ -276,17 +275,6 @@ private void initializeAwardsTab() { txtAwardSetFilterList = new JTextArea(); } - /** - * Initializes the components of the AdministratorsTab. - * The panel contains settings related to administrator abilities. - */ - private void initializeAdministratorsTab() { - chkAdminsHaveNegotiation = new JCheckBox(); - chkAdminExperienceLevelIncludeNegotiation = new JCheckBox(); - chkAdminsHaveScrounge = new JCheckBox(); - chkAdminExperienceLevelIncludeScrounge = new JCheckBox(); - } - /** * Initializes the components of the PersonnelInformationTab. * The panel contains settings related to personnel information display. @@ -345,6 +333,12 @@ private void initializeGeneralTab() { chkUsePersonnelRemoval = new JCheckBox(); chkUseRemovalExemptCemetery = new JCheckBox(); chkUseRemovalExemptRetirees = new JCheckBox(); + + pnlAdministrators = new JPanel(); + chkAdminsHaveNegotiation = new JCheckBox(); + chkAdminExperienceLevelIncludeNegotiation = new JCheckBox(); + chkAdminsHaveScrounge = new JCheckBox(); + chkAdminExperienceLevelIncludeScrounge = new JCheckBox(); } /** @@ -621,18 +615,14 @@ public Component getListCellRendererComponent(final JList list, final Object layout.gridx = 0; layout.gridy = 0; - layout.gridwidth = 1; panel.add(lblAwardBonusStyle, layout); layout.gridx++; - layout.gridwidth = 2; panel.add(comboAwardBonusStyle, layout); layout.gridx = 0; layout.gridy++; - layout.gridwidth = 1; panel.add(lblAwardTierSize, layout); layout.gridx++; - layout.gridwidth = 2; panel.add(spnAwardTierSize, layout); layout.gridx = 0; From 34f4a20d4c94b7359505866b3691fc51fc8a0d3e Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 15 Oct 2024 23:12:58 -0500 Subject: [PATCH 093/117] Add motivational quote to campaign options dialog Inserted a quote "No job too tough, no fee too high!" into the campaign options UI for better user engagement. The quote was added as a new label at the bottom of the relevant panel. --- .../mekhq/resources/NEWCampaignOptionsDialog.properties | 1 + MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 7933a54846..6a56b13109 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -543,6 +543,7 @@ lblNonBinaryDiceSize.text=Non-Binary Personnel Chance: 1 in lblNonBinaryDiceSize.tooltip=PLACEHOLDER lblFamilyDisplayLevel.text=Family Display Depth lblFamilyDisplayLevel.tooltip=PLACEHOLDER +lblQuote01.text=No job too tough, no fee too high! # createAnniversariesPanel lblAnniversariesPanel.text=Anniversaries diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java index 13198c902a..2fde47bea5 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java @@ -186,8 +186,12 @@ public AbstractMHQScrollablePanel createGeneralTab() { outerPanel.add(Box.createHorizontalStrut(25), BorderLayout.LINE_START); outerPanel.add(Box.createHorizontalStrut(25), BorderLayout.LINE_END); outerPanel.add(panel, BorderLayout.CENTER); + JLabel label = new JLabel(resources.getString("lblQuote01.text")); + label.setHorizontalAlignment(SwingConstants.CENTER); + outerPanel.add(label, BorderLayout.SOUTH); generalPanel.add(outerPanel); + return generalPanel; } From 9d89b9e8e05496118a6755c6afdf0a0e3ae460a4 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 16 Oct 2024 10:54:00 -0500 Subject: [PATCH 094/117] Add panel for Random Backgrounds in Biography Tab This commit integrated a new "Random Backgrounds" panel into the Biography Tab. It included the UI elements and layout adjustments to accommodate the new panel, ensuring consistency with existing design patterns. All related properties and labels were also updated to support the new feature. --- .../NEWCampaignOptionsDialog.properties | 3 + .../panes/campaignOptions/BiographyTab.java | 261 ++++++++++-------- 2 files changed, 147 insertions(+), 117 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 6a56b13109..214f866dbf 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -564,6 +564,9 @@ lblBackgroundsTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam + +# createRandomBackgroundsPanel +lblRandomBackgroundsPanel.text=Random Backgrounds lblUseRandomPersonalities.text=Assign Random Personalities lblUseRandomPersonalities.tooltip=PLACEHOLDER lblUseRandomPersonalityReputation.text=Personality Influences Reputation diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java index 6b6e4f8d7e..b5e222e914 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java @@ -65,6 +65,7 @@ public class BiographyTab { //end General Tab //start Backgrounds Tab + private JPanel pnlRandomBackgrounds; private JCheckBox chkUseRandomPersonalities; private JCheckBox chkUseRandomPersonalityReputation; private JCheckBox chkUseIntelligenceXpMultiplier; @@ -256,6 +257,7 @@ private void initializeDeathTab() { * The panel contains various general settings. */ private void initializeBackgroundsTab() { + pnlRandomBackgrounds = new JPanel(); chkUseRandomPersonalities = new JCheckBox(); chkUseRandomPersonalityReputation = new JCheckBox(); chkUseIntelligenceXpMultiplier = new JCheckBox(); @@ -343,45 +345,47 @@ JPanel createGeneralTab() { pnlAnniversariesPanel = createAnniversariesPanel(); // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("BiographyGeneralTab", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(chkUseDylansRandomXP) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblGender) - .addComponent(sldGender)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblNonBinaryDiceSize) - .addComponent(spnNonBinaryDiceSize)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblFamilyDisplayLevel) - .addComponent(comboFamilyDisplayLevel)) - .addComponent(pnlAnniversariesPanel)); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(chkUseDylansRandomXP) - .addGroup(layout.createSequentialGroup() - .addComponent(lblGender) - .addComponent(sldGender)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblNonBinaryDiceSize) - .addComponent(spnNonBinaryDiceSize) - ) - .addGroup(layout.createSequentialGroup() - .addComponent(lblFamilyDisplayLevel) - .addComponent(comboFamilyDisplayLevel) - ) - .addComponent(pnlAnniversariesPanel))); + final JPanel panelLeft = new CampaignOptionsStandardPanel("BiographyGeneralTabLeft", true); + final GridBagConstraints layoutLeft = new CampaignOptionsGridBagConstraints(panelLeft); + + layoutLeft.gridy = 0; + layoutLeft.gridx = 0; + layoutLeft.gridwidth = 1; + panelLeft.add(chkUseDylansRandomXP, layoutLeft); + + layoutLeft.gridx = 0; + layoutLeft.gridy++; + panelLeft.add(lblGender, layoutLeft); + layoutLeft.gridx++; + panelLeft.add(sldGender, layoutLeft); + + layoutLeft.gridx = 0; + layoutLeft.gridy++; + panelLeft.add(lblNonBinaryDiceSize, layoutLeft); + layoutLeft.gridx++; + panelLeft.add(spnNonBinaryDiceSize, layoutLeft); + + layoutLeft.gridx = 0; + layoutLeft.gridy++; + panelLeft.add(lblFamilyDisplayLevel, layoutLeft); + layoutLeft.gridx++; + panelLeft.add(comboFamilyDisplayLevel, layoutLeft); + + final JPanel panelParent = new CampaignOptionsStandardPanel("BiographyGeneralTab", true); + final GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panelParent); + layoutParent.gridwidth = 5; + layoutParent.gridx = 0; + layoutParent.gridy = 0; + panelParent.add(headerPanel, layoutParent); + + layoutParent.gridy++; + layoutParent.gridwidth = 1; + panelParent.add(panelLeft, layoutParent); + layoutParent.gridx++; + panelParent.add(pnlAnniversariesPanel, layoutParent); // Create Parent Panel and return - return createParentPanel(panel, "BiographyGeneralTab"); + return createParentPanel(panelParent, "BiographyGeneralTab"); } /** @@ -398,23 +402,22 @@ private JPanel createAnniversariesPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("AnniversariesPanel", true, "AnniversariesPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + final GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panel); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(chkAnnounceOfficersOnly) - .addComponent(chkAnnounceBirthdays) - .addComponent(chkAnnounceChildBirthdays) - .addComponent(chkAnnounceRecruitmentAnniversaries)); + layoutParent.gridwidth = 5; + layoutParent.gridx = 0; + layoutParent.gridy = 0; + panel.add(chkAnnounceBirthdays, layoutParent); - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(chkAnnounceOfficersOnly) - .addComponent(chkAnnounceBirthdays) - .addComponent(chkAnnounceChildBirthdays) - .addComponent(chkAnnounceRecruitmentAnniversaries))); + layoutParent.gridy++; + layoutParent.gridwidth = 1; + panel.add(chkAnnounceRecruitmentAnniversaries, layoutParent); + + layoutParent.gridy++; + panel.add(chkAnnounceOfficersOnly, layoutParent); + + layoutParent.gridy++; + panel.add(chkAnnounceChildBirthdays, layoutParent); return panel; } @@ -428,40 +431,57 @@ JPanel createBackgroundsTab() { JPanel headerPanel = new CampaignOptionsHeaderPanel("BackgroundsTab", getImageDirectory() + "logo_clan_goliath_scorpion.png", true); + // Contents + pnlRandomOriginOptions = createRandomOriginOptionsPanel(); + pnlRandomBackgrounds = createRandomBackgroundsPanel(); + + // Layout the Panels + final JPanel panel = new CampaignOptionsStandardPanel("BackgroundsTab", true); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridwidth = 5; + layout.gridx = 0; + layout.gridy = 0; + panel.add(headerPanel, layout); + + layout.gridy++; + layout.gridwidth = 1; + panel.add(pnlRandomOriginOptions, layout); + + layout.gridx++; + panel.add(pnlRandomBackgrounds, layout); + + // Create Parent Panel and return + return createParentPanel(panel, "BackgroundsTab"); + } + + JPanel createRandomBackgroundsPanel() { // Contents chkUseRandomPersonalities = new CampaignOptionsCheckBox("UseRandomPersonalities"); chkUseRandomPersonalityReputation = new CampaignOptionsCheckBox("UseRandomPersonalityReputation"); chkUseIntelligenceXpMultiplier = new CampaignOptionsCheckBox("UseIntelligenceXpMultiplier"); chkUseSimulatedRelationships = new CampaignOptionsCheckBox("UseSimulatedRelationships"); - pnlRandomOriginOptions = createRandomOriginOptionsPanel(); + // Layout the Panels + final JPanel panel = new CampaignOptionsStandardPanel("RandomBackgroundsPanel", true, + "RandomBackgroundsPanel"); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); - // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("BackgroundsTab", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + layout.gridwidth = 1; + layout.gridx = 0; + layout.gridy = 0; + panel.add(chkUseRandomPersonalities, layout); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(chkUseRandomPersonalities) - .addComponent(chkUseRandomPersonalityReputation) - .addComponent(chkUseIntelligenceXpMultiplier) - .addComponent(chkUseSimulatedRelationships) - .addComponent(pnlRandomOriginOptions)); + layout.gridy++; + panel.add(chkUseRandomPersonalityReputation, layout); - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(chkUseRandomPersonalities) - .addComponent(chkUseRandomPersonalityReputation) - .addComponent(chkUseIntelligenceXpMultiplier) - .addComponent(chkUseSimulatedRelationships) - .addComponent(pnlRandomOriginOptions))); + layout.gridy++; + panel.add(chkUseIntelligenceXpMultiplier, layout); - // Create Parent Panel and return - return createParentPanel(panel, "BackgroundsTab"); + layout.gridy++; + panel.add(chkUseSimulatedRelationships, layout); + + return panel; } /** @@ -533,51 +553,58 @@ public Component getListCellRendererComponent(final JList list, final Object chkExtraRandomOrigin = new CampaignOptionsCheckBox("ExtraRandomOrigin"); // Layout the Panel + final JPanel panelSystemPlanetOrigins = new CampaignOptionsStandardPanel( + "RandomOriginOptionsPanelSystemPlanetOrigins", false, ""); + final GridBagConstraints layoutSystemPlanetOrigins = new CampaignOptionsGridBagConstraints(panelSystemPlanetOrigins); + + layoutSystemPlanetOrigins.gridwidth = 1; + layoutSystemPlanetOrigins.gridx = 0; + layoutSystemPlanetOrigins.gridy = 0; + panelSystemPlanetOrigins.add(lblSpecifiedSystem, layoutSystemPlanetOrigins); + layoutSystemPlanetOrigins.gridx++; + panelSystemPlanetOrigins.add(comboSpecifiedSystem, layoutSystemPlanetOrigins); + layoutSystemPlanetOrigins.gridx++; + panelSystemPlanetOrigins.add(lblSpecifiedPlanet, layoutSystemPlanetOrigins); + layoutSystemPlanetOrigins.gridx++; + panelSystemPlanetOrigins.add(comboSpecifiedPlanet, layoutSystemPlanetOrigins); + + layoutSystemPlanetOrigins.gridx = 0; + layoutSystemPlanetOrigins.gridy++; + panelSystemPlanetOrigins.add(lblOriginSearchRadius, layoutSystemPlanetOrigins); + layoutSystemPlanetOrigins.gridx++; + panelSystemPlanetOrigins.add(spnOriginSearchRadius, layoutSystemPlanetOrigins); + layoutSystemPlanetOrigins.gridx++; + panelSystemPlanetOrigins.add(lblOriginDistanceScale, layoutSystemPlanetOrigins); + layoutSystemPlanetOrigins.gridx++; + panelSystemPlanetOrigins.add(spnOriginDistanceScale, layoutSystemPlanetOrigins); + final JPanel panel = new CampaignOptionsStandardPanel("RandomOriginOptionsPanel", true, "RandomOriginOptionsPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(chkRandomizeOrigin) - .addComponent(chkRandomizeDependentsOrigin) - .addComponent(chkRandomizeAroundSpecifiedPlanet) - .addComponent(chkSpecifiedSystemFactionSpecific) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblSpecifiedSystem) - .addComponent(comboSpecifiedSystem) - .addComponent(lblSpecifiedPlanet) - .addComponent(comboSpecifiedPlanet)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblOriginSearchRadius) - .addComponent(spnOriginSearchRadius) - .addComponent(lblOriginDistanceScale) - .addComponent(spnOriginDistanceScale)) - .addComponent(chkAllowClanOrigins) - .addComponent(chkExtraRandomOrigin)); + layout.gridwidth = 1; + layout.gridx = 0; + layout.gridy = 0; + panel.add(chkRandomizeOrigin, layout); - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(chkRandomizeOrigin) - .addComponent(chkRandomizeDependentsOrigin) - .addComponent(chkRandomizeAroundSpecifiedPlanet) - .addComponent(chkSpecifiedSystemFactionSpecific) - .addGroup(layout.createSequentialGroup() - .addComponent(lblSpecifiedSystem) - .addComponent(comboSpecifiedSystem) - .addComponent(lblSpecifiedPlanet) - .addComponent(comboSpecifiedPlanet) - ) - .addGroup(layout.createSequentialGroup() - .addComponent(lblOriginSearchRadius) - .addComponent(spnOriginSearchRadius) - .addComponent(lblOriginDistanceScale) - .addComponent(spnOriginDistanceScale) - ) - .addComponent(chkAllowClanOrigins) - .addComponent(chkExtraRandomOrigin))); + layout.gridy++; + panel.add(chkRandomizeDependentsOrigin, layout); + + layout.gridy++; + panel.add(chkRandomizeAroundSpecifiedPlanet, layout); + + layout.gridy++; + panel.add(chkSpecifiedSystemFactionSpecific, layout); + + layout.gridy++; + panel.add(panelSystemPlanetOrigins, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkAllowClanOrigins, layout); + + layout.gridy++; + panel.add(chkExtraRandomOrigin, layout); return panel; } From 21e282f1a1bc484c319b48cb0644c55048480e61 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 16 Oct 2024 11:16:02 -0500 Subject: [PATCH 095/117] Refactor campaign options panel layouts Revised grid layout configuration for PersonnelTab and BiographyTab to improve readability and maintainability. Moved component initialization and layout setup for better logical grouping and updated layout constraints to align with standard practices. --- .../panes/campaignOptions/BiographyTab.java | 81 ++++++++++--------- .../panes/campaignOptions/PersonnelTab.java | 4 +- 2 files changed, 45 insertions(+), 40 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java index b5e222e914..c49cb390b1 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java @@ -700,52 +700,57 @@ public Component getListCellRendererComponent(final JList list, final Object chkUseRandomPrisonerDeath = new CampaignOptionsCheckBox("UseRandomPrisonerDeath"); chkUseRandomDeathSuicideCause = new CampaignOptionsCheckBox("UseRandomDeathSuicideCause"); - pnlDeathAgeGroup = createDeathAgeGroupsPanel(); - lblPercentageRandomDeathChance = new CampaignOptionsLabel("PercentageRandomDeathChance"); spnPercentageRandomDeathChance = new CampaignOptionsSpinner("PercentageRandomDeathChance", 0, 0, 100, 0.000001); + pnlDeathAgeGroup = createDeathAgeGroupsPanel(); + // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("DeathTab", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + final JPanel panelLeft = new CampaignOptionsStandardPanel("DeathTabLeft", true); + final GridBagConstraints layoutLeft = new CampaignOptionsGridBagConstraints(panelLeft); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(chkKeepMarriedNameUponSpouseDeath) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblRandomDeathMethod) - .addComponent(comboRandomDeathMethod)) - .addComponent(chkUseRandomClanPersonnelDeath) - .addComponent(chkUseRandomPrisonerDeath) - .addComponent(chkUseRandomDeathSuicideCause) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPercentageRandomDeathChance) - .addComponent(spnPercentageRandomDeathChance)) - .addComponent(pnlDeathAgeGroup)); + layoutLeft.gridy = 0; + layoutLeft.gridx = 0; + layoutLeft.gridwidth = 1; + panelLeft.add(chkKeepMarriedNameUponSpouseDeath, layoutLeft); + layoutLeft.gridy++; + panelLeft.add(lblRandomDeathMethod, layoutLeft); + layoutLeft.gridx++; + panelLeft.add(comboRandomDeathMethod, layoutLeft); - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(chkKeepMarriedNameUponSpouseDeath) - .addGroup(layout.createSequentialGroup() - .addComponent(lblRandomDeathMethod) - .addComponent(comboRandomDeathMethod) - ) - .addComponent(chkUseRandomClanPersonnelDeath) - .addComponent(chkUseRandomPrisonerDeath) - .addComponent(chkUseRandomDeathSuicideCause) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPercentageRandomDeathChance) - .addComponent(spnPercentageRandomDeathChance) - ) - .addComponent(pnlDeathAgeGroup))); + layoutLeft.gridx = 0; + layoutLeft.gridy++; + panelLeft.add(chkUseRandomClanPersonnelDeath, layoutLeft); + + layoutLeft.gridy++; + panelLeft.add(chkUseRandomPrisonerDeath, layoutLeft); + + layoutLeft.gridy++; + panelLeft.add(chkUseRandomDeathSuicideCause, layoutLeft); + + layoutLeft.gridy++; + panelLeft.add(lblPercentageRandomDeathChance, layoutLeft); + layoutLeft.gridx++; + panelLeft.add(spnPercentageRandomDeathChance, layoutLeft); + + final JPanel panelParent = new CampaignOptionsStandardPanel("DeathTab", true); + final GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panelParent); + + layoutParent.gridwidth = 5; + layoutParent.gridx = 0; + layoutParent.gridy = 0; + panelParent.add(headerPanel, layoutParent); + + layoutParent.gridy++; + layoutParent.gridwidth = 1; + panelParent.add(panelLeft, layoutParent); + + layoutParent.gridx++; + panelParent.add(pnlDeathAgeGroup, layoutParent); // Create Parent Panel and return - return createParentPanel(panel, "DeathTab"); + return createParentPanel(panelParent, "DeathTab"); } /** @@ -759,7 +764,7 @@ private JPanel createDeathAgeGroupsPanel() { // Create the Panel final JPanel panel = new CampaignOptionsStandardPanel("DeathAgeGroupsPanel", true, "DeathAgeGroupsPanel"); - panel.setLayout(new GridLayout(1, ageGroups.length)); + panel.setLayout(new GridLayout(ageGroups.length / 2, 1)); // Contents for (final AgeGroup ageGroup : ageGroups) { diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java index 5deb570b30..18522ba84b 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java @@ -829,11 +829,11 @@ JPanel createPersonnelInformationTab() { final JPanel panelLeft = new CampaignOptionsStandardPanel("PersonnelInformationLeft", false); final GridBagConstraints layoutLeft = new CampaignOptionsGridBagConstraints(panelLeft); - layoutLeft.gridy++; + layoutLeft.gridx = 0; + layoutLeft.gridy = 0; layoutLeft.gridwidth = 1; panelLeft.add(chkUseTimeInService, layoutLeft); - layoutLeft.gridx = 0; layoutLeft.gridy++; panelLeft.add(lblTimeInServiceDisplayFormat, layoutLeft); layoutLeft.gridx++; From 9a56bcb428ab886ab85c73f102fb75d6c2bcaa0e Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 16 Oct 2024 11:56:06 -0500 Subject: [PATCH 096/117] Remove unnecessary boolean parameters from panel constructors Eliminated the redundant boolean parameters from the `CampaignOptionsStandardPanel` and `CampaignOptionsGridBagConstraints` constructors to simplify the code. Adjusted the layout creation accordingly and made minor updates to related property labels and method documentation. --- .../NEWCampaignOptionsDialog.properties | 6 +- .../panes/campaignOptions/BiographyTab.java | 206 +++++++++--------- .../CampaignOptionsUtilities.java | 21 +- .../EquipmentAndSuppliesTab.java | 6 +- .../panes/campaignOptions/FinancesTab.java | 4 +- .../gui/panes/campaignOptions/GeneralTab.java | 4 +- .../gui/panes/campaignOptions/MarketsTab.java | 7 +- .../panes/campaignOptions/PersonnelTab.java | 17 +- .../campaignOptions/RelationshipsTab.java | 6 +- .../TurnoverAndRetentionTab.java | 4 +- 10 files changed, 140 insertions(+), 141 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 214f866dbf..fe139cc5d9 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -637,7 +637,7 @@ lblCurriculumXpRate.text=Base XP Rate lblCurriculumXpRate.tooltip=PLACEHOLDER lblMaximumJumpCount.text=Maximum Jump Radius lblMaximumJumpCount.tooltip=PLACEHOLDER -lblUseReeducationCamps.text=Enable Reeducation Camp Faction Changes +lblUseReeducationCamps.text=Enable Faction Changes lblUseReeducationCamps.tooltip=PLACEHOLDER lblEnableOverrideRequirements.text=Override Requirements lblEnableOverrideRequirements.tooltip=PLACEHOLDER @@ -645,11 +645,9 @@ lblShowIneligibleAcademies.text=Show Ineligible Academies lblShowIneligibleAcademies.tooltip=PLACEHOLDER lblEntranceExamBaseTargetNumber.text=Entrance Exam Target Number lblEntranceExamBaseTargetNumber.tooltip=PLACEHOLDER -lblEntranceExamBaseTargetNumberPost.text=- Faculty Skill + Intelligence Modifier -lblEntranceExamBaseTargetNumberPost.tooltip=PLACEHOLDER # createEnableStandardSetsPanel -lblEnableStandardSetsPanel.text=Standard Sets +lblEnableStandardSetsPanel.text=Enable Academy Sets lblEnableLocalAcademies.text=Local Academies lblEnableLocalAcademies.tooltip=PLACEHOLDER lblEnablePrestigiousAcademies.text=Prestigious Academies diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java index c49cb390b1..07ee24fe8e 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java @@ -112,7 +112,6 @@ public class BiographyTab { private JCheckBox chkShowIneligibleAcademies; private JLabel lblEntranceExamBaseTargetNumber; private JSpinner spnEntranceExamBaseTargetNumber; - private JLabel lblEntranceExamBaseTargetNumberPost; private JPanel pnlEnableStandardSets; private JCheckBox chkEnableLocalAcademies; @@ -210,7 +209,6 @@ private void initializeEducationTab() { chkShowIneligibleAcademies = new JCheckBox(); lblEntranceExamBaseTargetNumber = new JLabel(); spnEntranceExamBaseTargetNumber = new JSpinner(); - lblEntranceExamBaseTargetNumberPost = new JLabel(); pnlEnableStandardSets = new JPanel(); chkEnableLocalAcademies = new JCheckBox(); @@ -813,8 +811,6 @@ JPanel createEducationTab() { chkUseReeducationCamps = new CampaignOptionsCheckBox("UseReeducationCamps"); - pnlEnableStandardSets = createEnableStandardSetsPanel(); - chkEnableOverrideRequirements = new CampaignOptionsCheckBox("EnableOverrideRequirements"); chkShowIneligibleAcademies = new CampaignOptionsCheckBox("ShowIneligibleAcademies"); @@ -822,7 +818,8 @@ JPanel createEducationTab() { lblEntranceExamBaseTargetNumber = new CampaignOptionsLabel("EntranceExamBaseTargetNumber"); spnEntranceExamBaseTargetNumber = new CampaignOptionsSpinner("EntranceExamBaseTargetNumber", 14, 0, 20, 1); - lblEntranceExamBaseTargetNumberPost = new CampaignOptionsLabel("EntranceExamBaseTargetNumberPost"); + + pnlEnableStandardSets = createEnableStandardSetsPanel(); pnlXpAndSkillBonuses = createXpAndSkillBonusesPanel(); @@ -830,61 +827,81 @@ JPanel createEducationTab() { pnlAccidentsAndEvents = createAccidentsAndEventsPanel(); - // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("EducationTab", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + // Layout the Panels + final JPanel panelLeft = new CampaignOptionsStandardPanel("EducationTabLeft"); + final GridBagConstraints layoutLeft = new CampaignOptionsGridBagConstraints(panelLeft); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(chkUseEducationModule) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblCurriculumXpRate) - .addComponent(spnCurriculumXpRate) - .addComponent(lblMaximumJumpCount) - .addComponent(spnMaximumJumpCount)) - .addComponent(chkUseReeducationCamps) - .addComponent(pnlEnableStandardSets) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(chkShowIneligibleAcademies) - .addComponent(chkEnableOverrideRequirements)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblEntranceExamBaseTargetNumber) - .addComponent(spnEntranceExamBaseTargetNumber) - .addComponent(lblEntranceExamBaseTargetNumberPost)) - .addComponent(pnlXpAndSkillBonuses) - .addComponent(pnlDropoutChance) - .addComponent(pnlAccidentsAndEvents)); + layoutLeft.gridwidth = 5; + layoutLeft.gridx = 0; + layoutLeft.gridy = 0; + panelLeft.add(headerPanel, layoutLeft); - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(chkUseEducationModule) - .addGroup(layout.createSequentialGroup() - .addComponent(lblCurriculumXpRate) - .addComponent(spnCurriculumXpRate) - .addComponent(lblMaximumJumpCount) - .addComponent(spnMaximumJumpCount) - ) - .addComponent(chkUseReeducationCamps) - .addComponent(pnlEnableStandardSets) - .addGroup(layout.createSequentialGroup() - .addComponent(chkShowIneligibleAcademies) - .addComponent(chkEnableOverrideRequirements) - ) - .addGroup(layout.createSequentialGroup() - .addComponent(lblEntranceExamBaseTargetNumber) - .addComponent(spnEntranceExamBaseTargetNumber) - .addComponent(lblEntranceExamBaseTargetNumberPost) - ) - .addComponent(pnlXpAndSkillBonuses) - .addComponent(pnlDropoutChance) - .addComponent(pnlAccidentsAndEvents))); + layoutLeft.gridy++; + layoutLeft.gridwidth = 1; + panelLeft.add(chkUseEducationModule, layoutLeft); + + layoutLeft.gridy++; + panelLeft.add(lblCurriculumXpRate, layoutLeft); + layoutLeft.gridx++; + panelLeft.add(spnCurriculumXpRate, layoutLeft); + + layoutLeft.gridx = 0; + layoutLeft.gridy++; + panelLeft.add(lblMaximumJumpCount, layoutLeft); + layoutLeft.gridx++; + panelLeft.add(spnMaximumJumpCount, layoutLeft); + + layoutLeft.gridx = 0; + layoutLeft.gridy++; + panelLeft.add(chkUseReeducationCamps, layoutLeft); + + layoutLeft.gridy++; + panelLeft.add(chkEnableOverrideRequirements, layoutLeft); + + layoutLeft.gridy++; + panelLeft.add(chkShowIneligibleAcademies, layoutLeft); + + layoutLeft.gridy++; + panelLeft.add(lblEntranceExamBaseTargetNumber, layoutLeft); + layoutLeft.gridx++; + panelLeft.add(spnEntranceExamBaseTargetNumber, layoutLeft); + + layoutLeft.gridx = 0; + layoutLeft.gridy++; + panelLeft.add(pnlEnableStandardSets, layoutLeft); + + final JPanel panelRight = new CampaignOptionsStandardPanel("EducationTabRight"); + final GridBagConstraints layoutRight = new CampaignOptionsGridBagConstraints(panelRight); + + layoutRight.gridy++; + layoutRight.gridwidth = 1; + panelRight.add(panelLeft, layoutRight); + layoutRight.gridy++; + panelRight.add(pnlXpAndSkillBonuses, layoutRight); + + layoutRight.gridy++; + panelRight.add(pnlDropoutChance, layoutRight); + + layoutRight.gridy++; + panelRight.add(pnlAccidentsAndEvents, layoutRight); + + final JPanel panelParent = new CampaignOptionsStandardPanel("EducationTab", true); + final GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panelParent); + + layoutParent.gridwidth = 5; + layoutParent.gridx = 0; + layoutParent.gridy = 0; + panelParent.add(headerPanel, layoutParent); + + layoutParent.gridy++; + layoutParent.gridwidth = 1; + panelParent.add(panelLeft, layoutParent); + + layoutParent.gridx++; + panelParent.add(panelRight, layoutParent); // Create Parent Panel and return - return createParentPanel(panel, "EducationTab"); + return createParentPanel(panelParent, "EducationTab"); } /** @@ -900,32 +917,25 @@ JPanel createEducationTab() { * Enable Standard Sets settings. */ private JPanel createEnableStandardSetsPanel() { - // Contents chkEnableLocalAcademies = new CampaignOptionsCheckBox("EnableLocalAcademies"); chkEnablePrestigiousAcademies = new CampaignOptionsCheckBox("EnablePrestigiousAcademies"); chkEnableUnitEducation = new CampaignOptionsCheckBox("EnableUnitEducation"); - // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("EnableStandardSetsPanel", true, "EnableStandardSetsPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(chkEnableLocalAcademies) - .addComponent(chkEnablePrestigiousAcademies) - .addComponent(chkEnableUnitEducation))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(chkEnableLocalAcademies) - .addComponent(chkEnablePrestigiousAcademies) - .addComponent(chkEnableUnitEducation) - ))); + layout.gridwidth = 1; + layout.gridx = 0; + layout.gridy = 0; + panel.add(chkEnableLocalAcademies, layout); + + layout.gridy++; + panel.add(chkEnablePrestigiousAcademies, layout); + + layout.gridy++; + panel.add(chkEnableUnitEducation, layout); return panel; } @@ -951,24 +961,16 @@ private JPanel createXpAndSkillBonusesPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("XpAndSkillBonusesPanel", true, "XpAndSkillBonusesPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(chkEnableBonuses) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblFacultyXpMultiplier) - .addComponent(spnFacultyXpMultiplier))); + layout.gridx = 0; + layout.gridy = 0; + panel.add(chkEnableBonuses, layout); - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(chkEnableBonuses) - .addGroup(layout.createSequentialGroup() - .addComponent(lblFacultyXpMultiplier) - .addComponent(spnFacultyXpMultiplier) - ))); + layout.gridy++; + panel.add(lblFacultyXpMultiplier, layout); + layout.gridx++; + panel.add(spnFacultyXpMultiplier, layout); return panel; } @@ -1043,24 +1045,16 @@ private JPanel createAccidentsAndEventsPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("AccidentsAndEventsPanel", true, "AccidentsAndEventsPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(chkAllAges) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblMilitaryAcademyAccidents) - .addComponent(spnMilitaryAcademyAccidents))); + layout.gridx = 0; + layout.gridy = 0; + panel.add(chkAllAges, layout); - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(chkAllAges) - .addGroup(layout.createSequentialGroup() - .addComponent(lblMilitaryAcademyAccidents) - .addComponent(spnMilitaryAcademyAccidents) - ))); + layout.gridy++; + panel.add(lblMilitaryAcademyAccidents, layout); + layout.gridx++; + panel.add(spnMilitaryAcademyAccidents, layout); return panel; } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java index 0812ecefe2..9a1300373a 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java @@ -237,13 +237,22 @@ public CampaignOptionsButton(String name, @Nullable Integer customWrapSize) { */ static class CampaignOptionsStandardPanel extends JPanel { /** - * Creates a standardized {@link JPanel} with an untitled border. + * Creates a standardized {@link JPanel} without a border. *

* {@code createGroupLayout} should also be called and the resulting {@link GroupLayout} * assigned to the panel via {@code setLayout}. + * + * @param name the name of the panel. + */ + public CampaignOptionsStandardPanel(String name) { + this(name, false, ""); + } + + /** + * Creates a standardized {@link JPanel} with an untitled border. *

- * If {@code borderTitle} isn't empty the resource bundle reference, used to fetch the border's - * title, will be {@code "lbl" + borderTitle + ".text"} + * {@code createGroupLayout} should also be called and the resulting {@link GroupLayout} + * assigned to the panel via {@code setLayout}. * * @param name the name of the panel. * @param includeBorder whether the panel should have a border. @@ -345,7 +354,7 @@ public CampaignOptionsHeaderPanel(String name, String imageAddress, boolean incl } // Layout panel - new CampaignOptionsStandardPanel("pnl" + name + "HeaderPanel", false); + new CampaignOptionsStandardPanel("pnl" + name + "HeaderPanel"); final GroupLayout layout = createGroupLayout(this); setLayout(layout); @@ -409,7 +418,7 @@ public CampaignOptionsGridBagConstraints(JPanel panel, @Nullable Integer anchor, panel.setLayout(new GridBagLayout()); this.anchor = Objects.requireNonNullElse(anchor, GridBagConstraints.NORTHWEST); - this.fill = Objects.requireNonNullElse(fill, GridBagConstraints.HORIZONTAL); + this.fill = Objects.requireNonNullElse(fill, GridBagConstraints.NONE); this.insets = new Insets(5, 5, 5, 5); } @@ -424,7 +433,7 @@ public CampaignOptionsGridBagConstraints(JPanel panel, @Nullable Integer anchor, */ static JPanel createParentPanel(JPanel panel, String name) { // Create Panel - final JPanel parentPanel = new CampaignOptionsStandardPanel(name, false); + final JPanel parentPanel = new CampaignOptionsStandardPanel(name); final GroupLayout parentLayout = createGroupLayout(parentPanel); // Layout diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java index 241dae8ce1..2765357c45 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java @@ -466,7 +466,7 @@ private JPanel createTechModifiersPanel() { techLabel.setName(String.format("

%s
%s
%s
list, final Object chkIgnoreStandardSet = new CampaignOptionsCheckBox("IgnoreStandardSet"); // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("AwardsGeneralOptionsPanel", false); + final JPanel panel = new CampaignOptionsStandardPanel("AwardsGeneralOptionsPanel"); final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); layout.gridx = 0; @@ -739,7 +739,7 @@ JPanel createMedicalTab() { spnMaximumPatients = new CampaignOptionsSpinner("MaximumPatients", 25, 1, 100, 1); - final JPanel panelLeft = new CampaignOptionsStandardPanel("MedicalTabLeft", false); + final JPanel panelLeft = new CampaignOptionsStandardPanel("MedicalTabLeft"); final GridBagConstraints layoutLeft = new CampaignOptionsGridBagConstraints(panelLeft); layoutLeft.gridy = 0; @@ -772,7 +772,7 @@ JPanel createMedicalTab() { panelLeft.add(spnMinimumHitsForVehicles, layoutLeft); // Layout the Panels - final JPanel panelRight = new CampaignOptionsStandardPanel("MedicalTabRight", false); + final JPanel panelRight = new CampaignOptionsStandardPanel("MedicalTabRight"); final GridBagConstraints layoutRight = new CampaignOptionsGridBagConstraints(panelRight); layoutRight.gridy++; @@ -826,7 +826,7 @@ JPanel createPersonnelInformationTab() { JPanel pnlPersonnelLogs = createPersonnelLogsPanel(); // Layout the Panel - final JPanel panelLeft = new CampaignOptionsStandardPanel("PersonnelInformationLeft", false); + final JPanel panelLeft = new CampaignOptionsStandardPanel("PersonnelInformationLeft"); final GridBagConstraints layoutLeft = new CampaignOptionsGridBagConstraints(panelLeft); layoutLeft.gridx = 0; @@ -894,6 +894,7 @@ JPanel createPersonnelLogsPanel() { "PersonnelLogsPanel"); final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + layout.gridwidth = 1; layout.gridx = 0; layout.gridy = 0; panel.add(chkUseTransfers, layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java index b6b2505b69..65659bd7d5 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java @@ -263,8 +263,7 @@ private JPanel createMarriageGeneralOptionsPanel() { chkLogMarriageNameChanges = new CampaignOptionsCheckBox("LogMarriageNameChanges"); // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("MarriageGeneralOptionsPanel", - false); + final JPanel panel = new CampaignOptionsStandardPanel("MarriageGeneralOptionsPanel"); final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); @@ -624,8 +623,7 @@ public Component getListCellRendererComponent(final JList list, final Object pnlRandomProcreationPanel = createRandomProcreationPanel(); // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("ProcreationGeneralOptionsPanel", - false); + final JPanel panel = new CampaignOptionsStandardPanel("ProcreationGeneralOptionsPanel"); final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java index 6f05261490..fe67f71866 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java @@ -590,7 +590,7 @@ private JPanel createAdministrativeStrainWrapperPanel() { pnlAdministrativeStrain = createAdministrativeStrainPanel(); // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("AdministrativeStrainPanel", false); + final JPanel panel = new CampaignOptionsStandardPanel("AdministrativeStrainPanel"); final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); @@ -677,7 +677,7 @@ private JPanel createManagementSkillWrapperPanel() { pnlManagementSkill = createManagementSkillPanel(); // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("UnitCohesionPanel", false); + final JPanel panel = new CampaignOptionsStandardPanel("UnitCohesionPanel"); final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); From 254505ea171ccfb6a16fb5ec8e995d876558a41d Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 16 Oct 2024 12:15:30 -0500 Subject: [PATCH 097/117] Refactor layout and scaling logic in campaign options UI Updated the GUI layout for several panels to use GridBagLayout for enhanced flexibility and clarity. Adjusted scaling logic using `UIUtil.scaleForGUI` to ensure consistent UI appearance across different resolutions. Also made minor text label changes for better clarity. --- .../NEWCampaignOptionsDialog.properties | 6 +- .../panes/campaignOptions/BiographyTab.java | 97 +++++++++---------- .../CampaignOptionsUtilities.java | 2 +- .../gui/panes/campaignOptions/GeneralTab.java | 11 +-- 4 files changed, 56 insertions(+), 60 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index fe139cc5d9..b3b7c4250a 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -686,15 +686,15 @@ lblNameAndPortraitGenerationTabBody.text=Lorem ipsum odor amet, consectetuer adi \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam lblUseOriginFactionForNames.text=Assign Names Based on Origin Faction lblUseOriginFactionForNames.tooltip=PLACEHOLDER -lblFactionNames.text=Faction +lblFactionNames.text=Fixed Faction lblFactionNames.tooltip=PLACEHOLDER lblAssignPortraitOnRoleChange.text=Reassign Portrait on Role Change lblAssignPortraitOnRoleChange.tooltip=PLACEHOLDER # createRandomPortraitPanel lblRandomPortraitPanel.text=Portrait Assignment -lblAllPortraitsBox.text=All Roles -lblNoPortraitsBox.text=No Roles +lblAllPortraitsBox.text=All Roles +lblNoPortraitsBox.text=No Roles # createRankTab lblRankTab.text=Rank Systems diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java index 07ee24fe8e..b6876de199 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java @@ -3,6 +3,7 @@ import megamek.client.generator.RandomGenderGenerator; import megamek.client.generator.RandomNameGenerator; import megamek.client.ui.baseComponents.MMComboBox; +import megamek.client.ui.swing.util.UIUtil; import megamek.common.annotations.Nullable; import mekhq.campaign.Campaign; import mekhq.campaign.personnel.enums.AgeGroup; @@ -997,29 +998,20 @@ private JPanel createDropoutChancePanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("DropoutChancePanel", true, "DropoutChancePanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblAdultDropoutChance) - .addComponent(spnAdultDropoutChance)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblChildrenDropoutChance) - .addComponent(spnChildrenDropoutChance))); + layout.gridwidth = 1; + layout.gridx = 0; + layout.gridy = 0; + panel.add(lblAdultDropoutChance, layout); + layout.gridx++; + panel.add(spnAdultDropoutChance, layout); - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblAdultDropoutChance) - .addComponent(spnAdultDropoutChance) - ) - .addGroup(layout.createSequentialGroup() - .addComponent(lblChildrenDropoutChance) - .addComponent(spnChildrenDropoutChance) - ))); + layout.gridx = 0; + layout.gridy++; + panel.add(lblChildrenDropoutChance, layout); + layout.gridx++; + panel.add(spnChildrenDropoutChance, layout); return panel; } @@ -1078,41 +1070,47 @@ JPanel createNameAndPortraitGenerationTab() { true); // Contents + chkAssignPortraitOnRoleChange = new CampaignOptionsCheckBox("AssignPortraitOnRoleChange"); + chkUseOriginFactionForNames = new CampaignOptionsCheckBox("UseOriginFactionForNames"); lblFactionNames = new CampaignOptionsLabel("FactionNames"); pnlRandomPortrait = createRandomPortraitPanel(); - chkAssignPortraitOnRoleChange = new CampaignOptionsCheckBox("AssignPortraitOnRoleChange"); + // Layout the Panels + final JPanel panelTop = new CampaignOptionsStandardPanel("NameAndPortraitGenerationTab"); + final GridBagConstraints layoutTop = new CampaignOptionsGridBagConstraints(panelTop); + + layoutTop.gridwidth = 1; + layoutTop.gridx = 0; + layoutTop.gridy = 0; + panelTop.add(chkAssignPortraitOnRoleChange, layoutTop); + + layoutTop.gridy++; + panelTop.add(chkUseOriginFactionForNames, layoutTop); + layoutTop.gridx++; + panelTop.add(Box.createHorizontalStrut(UIUtil.scaleForGUI(25))); + layoutTop.gridx++; + panelTop.add(lblFactionNames, layoutTop); + layoutTop.gridx++; + panelTop.add(comboFactionNames, layoutTop); + + final JPanel panel = new CampaignOptionsStandardPanel("NameAndPortraitGenerationTab", true); + final GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panel); - // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("NameAndPortraitGenerationTab", true, - ""); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + layoutParent.gridwidth = 5; + layoutParent.gridx = 0; + layoutParent.gridy = 0; + panel.add(headerPanel, layoutParent); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(chkUseOriginFactionForNames) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblFactionNames) - .addComponent(comboFactionNames)) - .addComponent(pnlRandomPortrait) - .addComponent(chkAssignPortraitOnRoleChange)); + layoutParent.gridy++; + layoutParent.gridwidth = 1; + panel.add(panelTop, layoutParent); + + layoutParent.gridy++; + panel.add(pnlRandomPortrait, layoutParent); - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(chkUseOriginFactionForNames) - .addGroup(layout.createSequentialGroup() - .addComponent(lblFactionNames) - .addComponent(comboFactionNames) - ) - .addComponent(pnlRandomPortrait) - .addComponent(chkAssignPortraitOnRoleChange))); // Create Parent Panel and return return createParentPanel(panel, "NameAndPortraitGenerationTab"); @@ -1168,7 +1166,7 @@ private JPanel createRandomPortraitPanel() { // Layout the Panel JPanel panel = new JPanel( - new GridLayout((int) Math.ceil((personnelRoles.length + 2) / 4.0), 4)); + new GridLayout((int) Math.ceil((personnelRoles.length + 2) / 5.0), 5)); panel.setBorder(BorderFactory.createTitledBorder( String.format(String.format("%s", resources.getString("lblRandomPortraitPanel.text"))))); @@ -1214,8 +1212,7 @@ JPanel createRankTab() { Component rankSystemsViewport = rankSystemsPane.getViewport().getView(); // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("RankTab", true, - ""); + final JPanel panel = new CampaignOptionsStandardPanel("RankTab", true); final GroupLayout layout = createGroupLayout(panel); panel.setLayout(layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java index 9a1300373a..c43fa49195 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java @@ -418,7 +418,7 @@ public CampaignOptionsGridBagConstraints(JPanel panel, @Nullable Integer anchor, panel.setLayout(new GridBagLayout()); this.anchor = Objects.requireNonNullElse(anchor, GridBagConstraints.NORTHWEST); - this.fill = Objects.requireNonNullElse(fill, GridBagConstraints.NONE); + this.fill = Objects.requireNonNullElse(fill, GridBagConstraints.VERTICAL); this.insets = new Insets(5, 5, 5, 5); } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java index 574d1b43aa..3026abaf58 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java @@ -2,11 +2,9 @@ import megamek.client.ui.baseComponents.MMComboBox; import megamek.client.ui.dialogs.CamoChooserDialog; -import megamek.client.ui.swing.util.FlatLafStyleBuilder; import megamek.client.ui.swing.util.UIUtil; import megamek.common.annotations.Nullable; import megamek.common.icons.Camouflage; -import mekhq.MHQConstants; import mekhq.MekHQ; import mekhq.campaign.Campaign; import mekhq.campaign.icons.StandardForceIcon; @@ -26,6 +24,7 @@ import java.awt.event.ActionEvent; import java.time.LocalDate; +import static megamek.client.ui.swing.util.FlatLafStyleBuilder.setFontScaling; import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; /** @@ -174,7 +173,7 @@ public AbstractMHQScrollablePanel createGeneralTab() { iconsPanel.add(lblIcon); iconsPanel.add(btnIcon); - iconsPanel.add(Box.createHorizontalStrut(50)); + iconsPanel.add(Box.createHorizontalStrut(UIUtil.scaleForGUI(50))); iconsPanel.add(lblCamo); iconsPanel.add(btnCamo); @@ -183,8 +182,8 @@ public AbstractMHQScrollablePanel createGeneralTab() { final JPanel outerPanel = new CampaignOptionsStandardPanel("generalTab", true); // Add some padding left and right (inside the border!) outerPanel.setLayout(new BorderLayout()); - outerPanel.add(Box.createHorizontalStrut(25), BorderLayout.LINE_START); - outerPanel.add(Box.createHorizontalStrut(25), BorderLayout.LINE_END); + outerPanel.add(Box.createHorizontalStrut(UIUtil.scaleForGUI(25)), BorderLayout.LINE_START); + outerPanel.add(Box.createHorizontalStrut(UIUtil.scaleForGUI(25)), BorderLayout.LINE_END); outerPanel.add(panel, BorderLayout.CENTER); JLabel label = new JLabel(resources.getString("lblQuote01.text")); label.setHorizontalAlignment(SwingConstants.CENTER); @@ -205,7 +204,7 @@ private static JPanel createGeneralHeader() { JLabel imageLabel = new JLabel(imageIcon); final JLabel lblHeader = new JLabel(resources.getString("lblGeneral.text"), SwingConstants.CENTER); - new FlatLafStyleBuilder().font(MHQConstants.PROJECT_NAME).bold().size(3).apply(lblHeader); + setFontScaling(lblHeader, true, 2); lblHeader.setName("lblGeneral"); JLabel lblBody = new JLabel(String.format("%s", From db0cbb36092044913d20d2a8d8a72463547b9a57 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 16 Oct 2024 12:22:33 -0500 Subject: [PATCH 098/117] Refactor layout configurations for consistency Updated layout configurations in GeneralTab, BiographyTab, and CampaignOptionsUtilities to ensure consistency across panels. Replaced GroupLayout with GridBagConstraints in BiographyTab and adjusted layout settings for better alignment. --- .../panes/campaignOptions/BiographyTab.java | 25 ++++++++----------- .../CampaignOptionsUtilities.java | 2 +- .../gui/panes/campaignOptions/GeneralTab.java | 2 +- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java index b6876de199..a750e028b2 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java @@ -16,7 +16,6 @@ import mekhq.gui.panes.RankSystemsPane; import javax.swing.*; -import javax.swing.GroupLayout.Alignment; import java.awt.*; import java.util.ArrayList; import java.util.Comparator; @@ -1213,19 +1212,17 @@ JPanel createRankTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("RankTab", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(rankSystemsViewport)); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(rankSystemsViewport))); + final GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panel); + + layoutParent.gridwidth = 5; + layoutParent.gridx = 0; + layoutParent.gridy = 0; + panel.add(headerPanel, layoutParent); + + layoutParent.gridy++; + layoutParent.gridwidth = 1; + panel.add(rankSystemsViewport, layoutParent); + // Create Parent Panel and return return createParentPanel(panel, "RankTab"); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java index c43fa49195..a2c56ca583 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java @@ -418,7 +418,7 @@ public CampaignOptionsGridBagConstraints(JPanel panel, @Nullable Integer anchor, panel.setLayout(new GridBagLayout()); this.anchor = Objects.requireNonNullElse(anchor, GridBagConstraints.NORTHWEST); - this.fill = Objects.requireNonNullElse(fill, GridBagConstraints.VERTICAL); + this.fill = Objects.requireNonNullElse(fill, GridBagConstraints.BOTH); this.insets = new Insets(5, 5, 5, 5); } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java index 3026abaf58..595bffb3fe 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/GeneralTab.java @@ -124,7 +124,7 @@ public AbstractMHQScrollablePanel createGeneralTab() { // Layout the Panel JPanel panel = new JPanel(); - GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel, null, GridBagConstraints.HORIZONTAL); + GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); layout.gridy = 0; layout.gridwidth = 5; From f4232c100ef190af5576d0b503b098bbf214d2cd Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 16 Oct 2024 13:15:04 -0500 Subject: [PATCH 099/117] Refactor layout management in RelationshipsTab.java Replaced GroupLayout with GridBagLayout for more flexible and concise layout management. Simplified panel structure by removing unnecessary intermediate containers, which reduces code duplication and enhances readability. --- .../campaignOptions/RelationshipsTab.java | 522 ++++++++---------- 1 file changed, 233 insertions(+), 289 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java index 65659bd7d5..1f3ae54353 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java @@ -7,7 +7,6 @@ import mekhq.campaign.personnel.enums.RandomProcreationMethod; import javax.swing.*; -import javax.swing.GroupLayout.Alignment; import java.awt.*; import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; @@ -34,8 +33,6 @@ public class RelationshipsTab { private JCheckBox chkUseRandomPrisonerMarriages; private JLabel lblRandomMarriageAgeRange; private JSpinner spnRandomMarriageAgeRange; - - private JPanel pnlPercentageRandomMarriage; private JLabel lblRandomMarriageOppositeSexDiceSize; private JSpinner spnRandomMarriageDiceSize; private JLabel lblRandomSameSexMarriageDiceSize; @@ -190,7 +187,6 @@ private void initializeMarriageTab() { lblRandomMarriageAgeRange = new JLabel(); spnRandomMarriageAgeRange = new JSpinner(); - pnlPercentageRandomMarriage = new JPanel(); lblRandomMarriageOppositeSexDiceSize = new JLabel(); spnRandomMarriageDiceSize = new JSpinner(); lblRandomSameSexMarriageDiceSize = new JLabel(); @@ -218,24 +214,19 @@ JPanel createMarriageTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("MarriageTab", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(pnlMarriageGeneralOptions) - .addComponent(pnlRandomMarriage))); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addGroup(layout.createSequentialGroup() - .addComponent(pnlMarriageGeneralOptions) - .addComponent(pnlRandomMarriage) - ))); + final GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panel); + + layoutParent.gridwidth = 5; + layoutParent.gridx = 0; + layoutParent.gridy = 0; + panel.add(headerPanel, layoutParent); + + layoutParent.gridy++; + layoutParent.gridwidth = 1; + panel.add(pnlMarriageGeneralOptions, layoutParent); + + layoutParent.gridx++; + panel.add(pnlRandomMarriage, layoutParent); // Create Parent Panel and return return createParentPanel(panel, "MarriageTab"); @@ -264,37 +255,33 @@ private JPanel createMarriageGeneralOptionsPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("MarriageGeneralOptionsPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(chkUseManualMarriages) - .addComponent(chkUseClanPersonnelMarriages) - .addComponent(chkUsePrisonerMarriages) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblNoInterestInMarriageDiceSize) - .addComponent(spnNoInterestInMarriageDiceSize)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblCheckMutualAncestorsDepth) - .addComponent(spnCheckMutualAncestorsDepth)) - .addComponent(chkLogMarriageNameChanges)); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(chkUseManualMarriages) - .addComponent(chkUseClanPersonnelMarriages) - .addComponent(chkUsePrisonerMarriages) - .addGroup(layout.createSequentialGroup() - .addComponent(lblNoInterestInMarriageDiceSize) - .addComponent(spnNoInterestInMarriageDiceSize) - ) - .addGroup(layout.createSequentialGroup() - .addComponent(lblCheckMutualAncestorsDepth) - .addComponent(spnCheckMutualAncestorsDepth) - ) - .addComponent(chkLogMarriageNameChanges))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridy = 0; + layout.gridx = 0; + layout.gridwidth = 1; + panel.add(chkUseManualMarriages, layout); + + layout.gridy++; + panel.add(chkUseClanPersonnelMarriages, layout); + + layout.gridy++; + panel.add(chkUsePrisonerMarriages, layout); + + layout.gridy++; + panel.add(lblNoInterestInMarriageDiceSize, layout); + layout.gridx++; + panel.add(spnNoInterestInMarriageDiceSize, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblCheckMutualAncestorsDepth, layout); + layout.gridx++; + panel.add(spnCheckMutualAncestorsDepth, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkLogMarriageNameChanges, layout); return panel; } @@ -330,53 +317,6 @@ public Component getListCellRendererComponent(final JList list, final Object spnRandomMarriageAgeRange = new CampaignOptionsSpinner("RandomMarriageAgeRange", 10, 0, 100, 1.0); - pnlPercentageRandomMarriage = createPercentageRandomMarriagePanel(); - - // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("RandomMarriages", true, - "RandomMarriages"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblRandomMarriageMethod) - .addComponent(comboRandomMarriageMethod)) - .addComponent(chkUseRandomClanPersonnelMarriages) - .addComponent(chkUseRandomPrisonerMarriages) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblRandomMarriageAgeRange) - .addComponent(spnRandomMarriageAgeRange)) - .addComponent(pnlPercentageRandomMarriage)); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblRandomMarriageMethod) - .addComponent(comboRandomMarriageMethod) - ) - .addComponent(chkUseRandomClanPersonnelMarriages) - .addComponent(chkUseRandomPrisonerMarriages) - .addGroup(layout.createSequentialGroup() - .addComponent(lblRandomMarriageAgeRange) - .addComponent(spnRandomMarriageAgeRange) - ) - .addComponent(pnlPercentageRandomMarriage))); - - return panel; - } - - /** - * Creates a panel for setting percentage-based random marriage settings. - * - * @return a {@link JPanel} representing the Percentage Random Marriage panel with input components - * for setting opposite-sex marriage dice size, same-sex marriage dice size, and new dependent - * marriage dice size - */ - private JPanel createPercentageRandomMarriagePanel() { - // Contents lblRandomMarriageOppositeSexDiceSize = new CampaignOptionsLabel("RandomMarriageOppositeSexDiceSize"); spnRandomMarriageDiceSize = new CampaignOptionsSpinner("RandomMarriageOppositeSexDiceSize", 5000, 0, 100000, 1); @@ -390,38 +330,47 @@ private JPanel createPercentageRandomMarriagePanel() { 20, 0, 100000, 1); // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("PercentageRandomMarriagePanel", true, - "PercentageRandomMarriagePanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblRandomMarriageOppositeSexDiceSize) - .addComponent(spnRandomMarriageDiceSize)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblRandomSameSexMarriageDiceSize) - .addComponent(spnRandomSameSexMarriageDiceSize)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblRandomNewDependentMarriage) - .addComponent(spnRandomNewDependentMarriage))); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblRandomMarriageOppositeSexDiceSize) - .addComponent(spnRandomMarriageDiceSize) - ) - .addGroup(layout.createSequentialGroup() - .addComponent(lblRandomSameSexMarriageDiceSize) - .addComponent(spnRandomSameSexMarriageDiceSize) - ) - .addGroup(layout.createSequentialGroup() - .addComponent(lblRandomNewDependentMarriage) - .addComponent(spnRandomNewDependentMarriage) - ))); + final JPanel panel = new CampaignOptionsStandardPanel("RandomMarriages", true, + "RandomMarriages"); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridy = 0; + layout.gridx = 0; + layout.gridwidth = 1; + panel.add(lblRandomMarriageMethod, layout); + layout.gridx++; + panel.add(comboRandomMarriageMethod, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkUseRandomClanPersonnelMarriages, layout); + + layout.gridy++; + panel.add(chkUseRandomPrisonerMarriages, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblRandomMarriageAgeRange, layout); + layout.gridx++; + panel.add(spnRandomMarriageAgeRange, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblRandomMarriageOppositeSexDiceSize, layout); + layout.gridx++; + panel.add(spnRandomMarriageDiceSize, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblRandomSameSexMarriageDiceSize, layout); + layout.gridx++; + panel.add(spnRandomSameSexMarriageDiceSize, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblRandomNewDependentMarriage, layout); + layout.gridx++; + panel.add(spnRandomNewDependentMarriage, layout); return panel; } @@ -447,29 +396,37 @@ JPanel createDivorceTab() { pnlRandomDivorce = createRandomDivorcePanel(); // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("DivorceTab", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(chkUseManualDivorce) - .addComponent(chkUseClanPersonnelDivorce) - .addComponent(chkUsePrisonerDivorce) - .addComponent(pnlRandomDivorce)); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(chkUseManualDivorce) - .addComponent(chkUseClanPersonnelDivorce) - .addComponent(chkUsePrisonerDivorce) - .addComponent(pnlRandomDivorce))); + final JPanel panelLeft = new CampaignOptionsStandardPanel("DivorceTabLeft"); + final GridBagConstraints layoutLeft = new CampaignOptionsGridBagConstraints(panelLeft); + + layoutLeft.gridwidth = 1; + layoutLeft.gridx = 0; + layoutLeft.gridy = 0; + panelLeft.add(chkUseManualDivorce, layoutLeft); + + layoutLeft.gridy++; + panelLeft.add(chkUseClanPersonnelDivorce, layoutLeft); + + layoutLeft.gridy++; + panelLeft.add(chkUsePrisonerDivorce, layoutLeft); + + final JPanel panelParent = new CampaignOptionsStandardPanel("DivorceTab", true); + final GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panelParent); + + layoutParent.gridwidth = 5; + layoutParent.gridx = 0; + layoutParent.gridy = 0; + panelParent.add(headerPanel, layoutParent); + + layoutParent.gridy++; + layoutParent.gridwidth = 1; + panelParent.add(panelLeft, layoutParent); + + layoutParent.gridx++; + panelParent.add(pnlRandomDivorce, layoutParent); // Create Parent Panel and return - return createParentPanel(panel, "DivorceTab"); + return createParentPanel(panelParent, "DivorceTab"); } /** @@ -504,38 +461,36 @@ public Component getListCellRendererComponent(final JList list, final Object 900, 0, 100000, 1); // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("RandomDivorcePanel", true, "RandomDivorcePanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblRandomDivorceMethod) - .addComponent(comboRandomDivorceMethod)) - .addComponent(chkUseRandomOppositeSexDivorce) - .addComponent(chkUseRandomSameSexDivorce) - .addComponent(chkUseRandomClanPersonnelDivorce) - .addComponent(chkUseRandomPrisonerDivorce) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblRandomDivorceDiceSize) - .addComponent(spnRandomDivorceDiceSize))); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblRandomDivorceMethod) - .addComponent(comboRandomDivorceMethod) - ) - .addComponent(chkUseRandomOppositeSexDivorce) - .addComponent(chkUseRandomSameSexDivorce) - .addComponent(chkUseRandomClanPersonnelDivorce) - .addComponent(chkUseRandomPrisonerDivorce) - .addGroup(layout.createSequentialGroup() - .addComponent(lblRandomDivorceDiceSize) - .addComponent(spnRandomDivorceDiceSize) - ))); + final JPanel panel = new CampaignOptionsStandardPanel("RandomDivorcePanel", true, + "RandomDivorcePanel"); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridy = 0; + layout.gridx = 0; + layout.gridwidth = 1; + panel.add(lblRandomDivorceMethod, layout); + layout.gridx++; + panel.add(comboRandomDivorceMethod, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkUseRandomOppositeSexDivorce, layout); + + layout.gridy++; + panel.add(chkUseRandomSameSexDivorce, layout); + + layout.gridy++; + panel.add(chkUseRandomClanPersonnelDivorce, layout); + + + layout.gridy++; + panel.add(chkUseRandomPrisonerDivorce, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblRandomDivorceDiceSize, layout); + layout.gridx++; + panel.add(spnRandomDivorceDiceSize, layout); return panel; } @@ -558,24 +513,19 @@ JPanel createProcreationTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("ProcreationTab", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(pnlProcreationGeneralOptionsPanel) - .addComponent(pnlRandomProcreationPanel))); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addGroup(layout.createSequentialGroup() - .addComponent(pnlProcreationGeneralOptionsPanel) - .addComponent(pnlRandomProcreationPanel) - ))); + final GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panel); + + layoutParent.gridwidth = 5; + layoutParent.gridx = 0; + layoutParent.gridy = 0; + panel.add(headerPanel, layoutParent); + + layoutParent.gridy++; + layoutParent.gridwidth = 1; + panel.add(pnlProcreationGeneralOptionsPanel, layoutParent); + + layoutParent.gridx++; + panel.add(pnlRandomProcreationPanel, layoutParent); // Create Parent Panel and return return createParentPanel(panel, "ProcreationTab"); @@ -620,58 +570,58 @@ public Component getListCellRendererComponent(final JList list, final Object chkUseMaternityLeave = new CampaignOptionsCheckBox("UseMaternityLeave"); chkLogProcreation = new CampaignOptionsCheckBox("LogProcreation"); - pnlRandomProcreationPanel = createRandomProcreationPanel(); - // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("ProcreationGeneralOptionsPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(chkUseManualProcreation) - .addComponent(chkUseClanPersonnelProcreation) - .addComponent(chkUsePrisonerProcreation) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblMultiplePregnancyOccurrences) - .addComponent(spnMultiplePregnancyOccurrences)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblBabySurnameStyle) - .addComponent(comboBabySurnameStyle)) - .addComponent(chkAssignNonPrisonerBabiesFounderTag) - .addComponent(chkAssignChildrenOfFoundersFounderTag) - .addComponent(chkDetermineFatherAtBirth) - .addComponent(chkDisplayTrueDueDate) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblNoInterestInChildrenDiceSize) - .addComponent(spnNoInterestInChildrenDiceSize)) - .addComponent(chkUseMaternityLeave) - .addComponent(chkLogProcreation)); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(chkUseManualProcreation) - .addComponent(chkUseClanPersonnelProcreation) - .addComponent(chkUsePrisonerProcreation) - .addGroup(layout.createSequentialGroup() - .addComponent(lblMultiplePregnancyOccurrences) - .addComponent(spnMultiplePregnancyOccurrences) - ) - .addGroup(layout.createSequentialGroup() - .addComponent(lblBabySurnameStyle) - .addComponent(comboBabySurnameStyle) - ) - .addComponent(chkAssignNonPrisonerBabiesFounderTag) - .addComponent(chkAssignChildrenOfFoundersFounderTag) - .addComponent(chkDetermineFatherAtBirth) - .addComponent(chkDisplayTrueDueDate) - .addGroup(layout.createSequentialGroup() - .addComponent(lblNoInterestInChildrenDiceSize) - .addComponent(spnNoInterestInChildrenDiceSize) - ) - .addComponent(chkUseMaternityLeave) - .addComponent(chkLogProcreation))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridy = 0; + layout.gridx = 0; + layout.gridwidth = 1; + panel.add(chkUseManualProcreation, layout); + + layout.gridy++; + panel.add(chkUseClanPersonnelProcreation, layout); + + layout.gridy++; + panel.add(chkUsePrisonerProcreation, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblMultiplePregnancyOccurrences, layout); + layout.gridx++; + panel.add(spnMultiplePregnancyOccurrences, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblBabySurnameStyle, layout); + layout.gridx++; + panel.add(comboBabySurnameStyle, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkAssignNonPrisonerBabiesFounderTag, layout); + + layout.gridy++; + panel.add(chkAssignChildrenOfFoundersFounderTag, layout); + + layout.gridy++; + panel.add(chkDetermineFatherAtBirth, layout); + + layout.gridy++; + panel.add(chkDisplayTrueDueDate, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblNoInterestInChildrenDiceSize, layout); + layout.gridx++; + panel.add(spnNoInterestInChildrenDiceSize, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkUseMaternityLeave, layout); + + layout.gridy++; + panel.add(chkLogProcreation, layout); return panel; } @@ -710,42 +660,36 @@ public Component getListCellRendererComponent(final JList list, final Object // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("RandomProcreationPanel", true, "RandomProcreationPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblRandomProcreationMethod) - .addComponent(comboRandomProcreationMethod)) - .addComponent(chkUseRelationshiplessRandomProcreation) - .addComponent(chkUseRandomClanPersonnelProcreation) - .addComponent(chkUseRandomPrisonerProcreation) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblRandomProcreationRelationshipDiceSize) - .addComponent(spnRandomProcreationRelationshipDiceSize)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblRandomProcreationRelationshiplessDiceSize) - .addComponent(spnRandomProcreationRelationshiplessDiceSize))); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblRandomProcreationMethod) - .addComponent(comboRandomProcreationMethod) - ) - .addComponent(chkUseRelationshiplessRandomProcreation) - .addComponent(chkUseRandomClanPersonnelProcreation) - .addComponent(chkUseRandomPrisonerProcreation) - .addGroup(layout.createSequentialGroup() - .addComponent(lblRandomProcreationRelationshipDiceSize) - .addComponent(spnRandomProcreationRelationshipDiceSize) - ) - .addGroup(layout.createSequentialGroup() - .addComponent(lblRandomProcreationRelationshiplessDiceSize) - .addComponent(spnRandomProcreationRelationshiplessDiceSize) - ))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridy = 0; + layout.gridx = 0; + layout.gridwidth = 1; + panel.add(lblRandomProcreationMethod, layout); + layout.gridx++; + panel.add(comboRandomProcreationMethod, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkUseRelationshiplessRandomProcreation, layout); + + layout.gridy++; + panel.add(chkUseRandomClanPersonnelProcreation, layout); + + layout.gridy++; + panel.add(chkUseRandomPrisonerProcreation, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblRandomProcreationRelationshipDiceSize, layout); + layout.gridx++; + panel.add(spnRandomProcreationRelationshipDiceSize, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblRandomProcreationRelationshiplessDiceSize, layout); + layout.gridx++; + panel.add(spnRandomProcreationRelationshiplessDiceSize, layout); return panel; } From e2c86d9663850d899708c2c879fa06cfd5ac1a8c Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 16 Oct 2024 13:17:54 -0500 Subject: [PATCH 100/117] Add initialization for Tech Limits and Rank Systems Added the initialization of the Tech Limits Tab in EquipmentAndSuppliesTab and moved the initialization of the Rank Systems Pane in BiographyTab. This ensures that both tabs are set up correctly, improving the UI consistency and functionality. --- MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java | 3 ++- .../gui/panes/campaignOptions/EquipmentAndSuppliesTab.java | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java index a750e028b2..9b9074f84d 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java @@ -176,6 +176,8 @@ private void initialize() { initializeDeathTab(); initializeEducationTab(); initializeNameAndPortraitTab(); + + rankSystemsPane = new RankSystemsPane(frame, campaign); } /** @@ -1207,7 +1209,6 @@ JPanel createRankTab() { true); // Contents - rankSystemsPane = new RankSystemsPane(frame, campaign); Component rankSystemsViewport = rankSystemsPane.getViewport().getView(); // Layout the Panel diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java index 2765357c45..ae29ead6c8 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java @@ -108,6 +108,7 @@ void initialize() { initializeAcquisitionTab(); initializeDelivery(); initializePlanetaryAcquisitionsTab(); + initializeTechLimitsTab(); } /** From 4997f83b034e2aae7e425731a3482a6c15d85dc7 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 16 Oct 2024 13:46:05 -0500 Subject: [PATCH 101/117] Switch TurnoverAndRetentionTab.java layout to GridBagLayout Refactored the campaign options pane to use GridBagLayout for better alignment and consistent spacing. This change impacts multiple panels, providing a more maintainable and visually organized layout structure for the UI components. --- .../TurnoverAndRetentionTab.java | 605 +++++++++--------- 1 file changed, 288 insertions(+), 317 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java index fe67f71866..15f97a3a80 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java @@ -4,7 +4,6 @@ import mekhq.campaign.personnel.enums.TurnoverFrequency; import javax.swing.*; -import javax.swing.GroupLayout.Alignment; import java.awt.*; import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; @@ -215,6 +214,98 @@ private void initializeTurnoverTab() { spnManagementSkillPenalty = new JSpinner(); } + /** + * Constructs and configures a panel for the Fatigue tab. + * This tab contains a header panel, a checkbox for activating fatigue, + * a spinner for adjusting the fatigue rate, a checkbox for toggling fatigue from injury, + * a spinner for adjusting field kitchen capacity, a checkbox for making field kitchens ignore + * non-combatants and a spinner for adjusting the fatigue leave threshold. + *

+ * The layout of the tab panel is organized with a {@link GroupLayout}, ensuring organized vertical + * and horizontal alignment. + * + * @return panel the configured {@link JPanel} for the Fatigue tab + */ + JPanel createFatigueTab() { + // Header + JPanel headerPanel = new CampaignOptionsHeaderPanel("FatigueTab", + getImageDirectory() + "logo_free_rasalhague_republic.png", + true); + + // Contents + chkUseFatigue = new CampaignOptionsCheckBox("UseFatigue"); + + lblFatigueRate = new CampaignOptionsLabel("FatigueRate"); + spnFatigueRate = new CampaignOptionsSpinner("FatigueRate", + 1, 1, 10, 1); + + chkUseInjuryFatigue = new CampaignOptionsCheckBox("UseInjuryFatigue"); + + lblFieldKitchenCapacity = new CampaignOptionsLabel("FieldKitchenCapacity"); + spnFieldKitchenCapacity = new CampaignOptionsSpinner("FieldKitchenCapacity", + 150, 0, 450, 1); + + chkFieldKitchenIgnoreNonCombatants = new CampaignOptionsCheckBox("FieldKitchenIgnoreNonCombatants"); + + lblFatigueLeaveThreshold = new CampaignOptionsLabel("FatigueLeaveThreshold"); + spnFatigueLeaveThreshold = new CampaignOptionsSpinner("FatigueLeaveThreshold", + 13, 0, 17, 1); + + // Layout the Panels + final JPanel panelLeft = new CampaignOptionsStandardPanel("FatigueTabLeft"); + final GridBagConstraints layoutLeft = new CampaignOptionsGridBagConstraints(panelLeft); + + layoutLeft.gridx = 0; + layoutLeft.gridy = 0; + layoutLeft.gridwidth = 1; + panelLeft.add(chkUseFatigue, layoutLeft); + + layoutLeft.gridy++; + panelLeft.add(chkUseInjuryFatigue, layoutLeft); + + layoutLeft.gridy++; + panelLeft.add(chkFieldKitchenIgnoreNonCombatants, layoutLeft); + + final JPanel panelRight = new CampaignOptionsStandardPanel("FatigueTabRight"); + final GridBagConstraints layoutRight = new CampaignOptionsGridBagConstraints(panelRight); + + layoutRight.gridx = 0; + layoutRight.gridy = 0; + layoutRight.gridwidth = 1; + panelRight.add(lblFatigueRate, layoutRight); + layoutRight.gridx++; + panelRight.add(spnFatigueRate, layoutRight); + + layoutRight.gridx = 0; + layoutRight.gridy++; + panelRight.add(lblFieldKitchenCapacity, layoutRight); + layoutRight.gridx++; + panelRight.add(spnFieldKitchenCapacity, layoutRight); + + layoutRight.gridx = 0; + layoutRight.gridy++; + panelRight.add(lblFatigueLeaveThreshold, layoutRight); + layoutRight.gridx++; + panelRight.add(spnFatigueLeaveThreshold, layoutRight); + + final JPanel panelParent = new CampaignOptionsStandardPanel("FatigueTab", true); + final GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panelParent); + + layoutParent.gridwidth = 5; + layoutParent.gridx = 0; + layoutParent.gridy = 0; + panelParent.add(headerPanel, layoutParent); + + layoutParent.gridwidth = 1; + layoutParent.gridy++; + panelParent.add(panelLeft, layoutParent); + layoutParent.gridx++; + panelParent.add(panelRight, layoutParent); + + // Create Parent Panel and return + return createParentPanel(panelParent, "FatigueTab"); + } + /** * Constructs and configures a panel for the Turnover tab. * This tab contains a header panel, a checkbox for activating random retirement, settings, @@ -239,34 +330,40 @@ JPanel createTurnoverTab() { pnlUnitCohesion = createUnitCohesionPanel(); // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("TurnoverTab", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(chkUseRandomRetirement) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(pnlSettings) - .addComponent(pnlModifiers) - .addComponent(pnlPayout)) - .addComponent(pnlUnitCohesion)); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(chkUseRandomRetirement) - .addGroup(layout.createSequentialGroup() - .addComponent(pnlSettings) - .addComponent(pnlModifiers) - .addComponent(pnlPayout) - ) - .addComponent(pnlUnitCohesion))); + final JPanel panelTop = new CampaignOptionsStandardPanel("TurnoverTabTop"); + final GridBagConstraints layoutTop = new CampaignOptionsGridBagConstraints(panelTop); + + layoutTop.gridwidth = 1; + layoutTop.gridx = 0; + layoutTop.gridy = 0; + panelTop.add(chkUseRandomRetirement, layoutTop); + + layoutTop.gridy++; + panelTop.add(pnlSettings, layoutTop); + layoutTop.gridx++; + panelTop.add(pnlModifiers, layoutTop); + layoutTop.gridx++; + panelTop.add(pnlPayout, layoutTop); + + // Layout the Panel + final JPanel panelParent = new CampaignOptionsStandardPanel("TurnoverTab", true); + final GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panelParent); + + layoutParent.gridwidth = 5; + layoutParent.gridx = 0; + layoutParent.gridy = 0; + panelParent.add(headerPanel, layoutParent); + + layoutParent.gridy++; + layoutParent.gridwidth = 1; + panelParent.add(panelTop, layoutParent); + + layoutParent.gridy++; + panelParent.add(pnlUnitCohesion, layoutParent); + // Create Parent Panel and return - return createParentPanel(panel, "TurnoverTab"); + return createParentPanel(panelParent, "TurnoverTab"); } /** @@ -331,62 +428,58 @@ public Component getListCellRendererComponent(final JList list, final Object // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("SettingsPanel", true, "SettingsPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblTurnoverFixedTargetNumber) - .addComponent(spnTurnoverFixedTargetNumber)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblTurnoverFrequency) - .addComponent(comboTurnoverFrequency)) - .addComponent(chkUseContractCompletionRandomRetirement) - .addComponent(chkUseRandomFounderTurnover) - .addComponent(chkTrackOriginalUnit) - .addComponent(chkAeroRecruitsHaveUnits) - .addComponent(chkUseSubContractSoldiers) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblServiceContractDuration) - .addComponent(spnServiceContractDuration)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblServiceContractModifier) - .addComponent(spnServiceContractModifier)) - .addComponent(chkPayBonusDefault) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPayBonusDefaultThreshold) - .addComponent(spnPayBonusDefaultThreshold))); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblTurnoverFixedTargetNumber) - .addComponent(spnTurnoverFixedTargetNumber) - ) - .addGroup(layout.createSequentialGroup() - .addComponent(lblTurnoverFrequency) - .addComponent(comboTurnoverFrequency) - ) - .addComponent(chkUseContractCompletionRandomRetirement) - .addComponent(chkUseRandomFounderTurnover) - .addComponent(chkTrackOriginalUnit) - .addComponent(chkAeroRecruitsHaveUnits) - .addComponent(chkUseSubContractSoldiers) - .addGroup(layout.createSequentialGroup() - .addComponent(lblServiceContractDuration) - .addComponent(spnServiceContractDuration) - ) - .addGroup(layout.createSequentialGroup() - .addComponent(lblServiceContractModifier) - .addComponent(spnServiceContractModifier) - ) - .addComponent(chkPayBonusDefault) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPayBonusDefaultThreshold) - .addComponent(spnPayBonusDefaultThreshold) - ))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridy = 0; + layout.gridx = 0; + layout.gridwidth = 1; + panel.add(lblTurnoverFixedTargetNumber, layout); + layout.gridx++; + panel.add(spnTurnoverFixedTargetNumber, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblTurnoverFrequency, layout); + layout.gridx++; + panel.add(comboTurnoverFrequency, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkUseContractCompletionRandomRetirement, layout); + + layout.gridy++; + panel.add(chkUseRandomFounderTurnover, layout); + + layout.gridy++; + panel.add(chkTrackOriginalUnit, layout); + + layout.gridy++; + panel.add(chkAeroRecruitsHaveUnits, layout); + + layout.gridy++; + panel.add(chkUseSubContractSoldiers, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblServiceContractDuration, layout); + layout.gridx++; + panel.add(spnServiceContractDuration, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblServiceContractModifier, layout); + layout.gridx++; + panel.add(spnServiceContractModifier, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkPayBonusDefault, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblPayBonusDefaultThreshold, layout); + layout.gridx++; + panel.add(spnPayBonusDefaultThreshold, layout); return panel; } @@ -417,44 +510,45 @@ private JPanel createModifiersPanel() { chkUseLoyaltyModifiers = new CampaignOptionsCheckBox("UseLoyaltyModifiers"); chkUseHideLoyalty = new CampaignOptionsCheckBox("UseHideLoyalty"); - // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("TurnoverModifiersPanel", true, "ModifiersPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(chkUseCustomRetirementModifiers) - .addComponent(chkUseFatigueModifiers) - .addComponent(chkUseSkillModifiers) - .addComponent(chkUseAgeModifiers) - .addComponent(chkUseUnitRatingModifiers) - .addComponent(chkUseFactionModifiers) - .addComponent(chkUseMissionStatusModifiers) - .addComponent(chkUseHostileTerritoryModifiers) - .addComponent(chkUseFamilyModifiers) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(chkUseLoyaltyModifiers) - .addComponent(chkUseHideLoyalty))); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(chkUseCustomRetirementModifiers) - .addComponent(chkUseFatigueModifiers) - .addComponent(chkUseSkillModifiers) - .addComponent(chkUseAgeModifiers) - .addComponent(chkUseUnitRatingModifiers) - .addComponent(chkUseFactionModifiers) - .addComponent(chkUseMissionStatusModifiers) - .addComponent(chkUseHostileTerritoryModifiers) - .addComponent(chkUseFamilyModifiers) - .addGroup(layout.createSequentialGroup() - .addComponent(chkUseLoyaltyModifiers) - .addComponent(chkUseHideLoyalty) - ))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridy = 0; + layout.gridx = 0; + layout.gridwidth = 1; + panel.add(chkUseCustomRetirementModifiers, layout); + + layout.gridy++; + panel.add(chkUseFatigueModifiers, layout); + + layout.gridy++; + panel.add(chkUseSkillModifiers, layout); + + layout.gridy++; + panel.add(chkUseAgeModifiers, layout); + + layout.gridy++; + panel.add(chkUseUnitRatingModifiers, layout); + + layout.gridy++; + panel.add(chkUseFactionModifiers, layout); + + layout.gridy++; + panel.add(chkUseMissionStatusModifiers, layout); + + layout.gridy++; + panel.add(chkUseHostileTerritoryModifiers, layout); + + layout.gridy++; + panel.add(chkUseFamilyModifiers, layout); + + layout.gridy++; + panel.add(chkUseLoyaltyModifiers, layout); + + layout.gridy++; + panel.add(chkUseHideLoyalty, layout); return panel; } @@ -493,45 +587,36 @@ private JPanel createPayoutsPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("PayoutsPanel", true, "PayoutsPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPayoutRateOfficer) - .addComponent(spnPayoutRateOfficer)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPayoutRateEnlisted) - .addComponent(spnPayoutRateEnlisted)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPayoutRetirementMultiplier) - .addComponent(spnPayoutRetirementMultiplier)) - .addComponent(chkUsePayoutServiceBonus) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPayoutServiceBonusRate) - .addComponent(spnPayoutServiceBonusRate))); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPayoutRateOfficer) - .addComponent(spnPayoutRateOfficer) - ) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPayoutRateEnlisted) - .addComponent(spnPayoutRateEnlisted) - ) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPayoutRetirementMultiplier) - .addComponent(spnPayoutRetirementMultiplier) - ) - .addComponent(chkUsePayoutServiceBonus) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPayoutServiceBonusRate) - .addComponent(spnPayoutServiceBonusRate) - ))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridy = 0; + layout.gridx = 0; + layout.gridwidth = 1; + panel.add(lblPayoutRateOfficer, layout); + layout.gridx++; + panel.add(spnPayoutRateOfficer, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblPayoutRateEnlisted, layout); + layout.gridx++; + panel.add(spnPayoutRateEnlisted, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblPayoutRetirementMultiplier, layout); + layout.gridx++; + panel.add(spnPayoutRetirementMultiplier, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkUsePayoutServiceBonus, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblPayoutServiceBonusRate, layout); + layout.gridx++; + panel.add(spnPayoutServiceBonusRate, layout); return panel; } @@ -554,22 +639,14 @@ private JPanel createUnitCohesionPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("UnitCohesionPanel", true, "UnitCohesionPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(pnlAdministrativeStrainWrapper) - .addComponent(pnlManagementSkillWrapper))); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(pnlAdministrativeStrainWrapper) - .addComponent(pnlManagementSkillWrapper) - ))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridy = 0; + layout.gridx = 0; + layout.gridwidth = 1; + panel.add(pnlAdministrativeStrainWrapper, layout); + layout.gridx++; + panel.add(pnlManagementSkillWrapper, layout); return panel; } @@ -591,19 +668,15 @@ private JPanel createAdministrativeStrainWrapperPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("AdministrativeStrainPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(chkUseAdministrativeStrain) - .addComponent(pnlAdministrativeStrain)); + layout.gridy = 0; + layout.gridx = 0; + layout.gridwidth = 1; + panel.add(chkUseAdministrativeStrain, layout); - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(chkUseAdministrativeStrain) - .addComponent(pnlAdministrativeStrain))); + layout.gridy++; + panel.add(pnlAdministrativeStrain, layout); return panel; } @@ -633,29 +706,20 @@ private JPanel createAdministrativeStrainPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("AdministrativeStrain", true, "AdministrativeStrain"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblAdministrativeCapacity) - .addComponent(spnAdministrativeCapacity)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblMultiCrewStrainDivider) - .addComponent(spnMultiCrewStrainDivider))); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblAdministrativeCapacity) - .addComponent(spnAdministrativeCapacity) - ) - .addGroup(layout.createSequentialGroup() - .addComponent(lblMultiCrewStrainDivider) - .addComponent(spnMultiCrewStrainDivider) - ))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridy = 0; + layout.gridx = 0; + layout.gridwidth = 1; + panel.add(lblAdministrativeCapacity, layout); + layout.gridx++; + panel.add(spnAdministrativeCapacity, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblMultiCrewStrainDivider, layout); + layout.gridx++; + panel.add(spnMultiCrewStrainDivider, layout); return panel; } @@ -678,19 +742,15 @@ private JPanel createManagementSkillWrapperPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("UnitCohesionPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(chkUseManagementSkill) - .addComponent(pnlManagementSkill)); + layout.gridy = 0; + layout.gridx = 0; + layout.gridwidth = 1; + panel.add(chkUseManagementSkill, layout); - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(chkUseManagementSkill) - .addComponent(pnlManagementSkill))); + layout.gridy++; + panel.add(pnlManagementSkill, layout); return panel; } @@ -719,107 +779,18 @@ private JPanel createManagementSkillPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("ManagementSkill", true, "ManagementSkill"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(chkUseCommanderLeadershipOnly) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblManagementSkillPenalty) - .addComponent(spnManagementSkillPenalty))); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(chkUseCommanderLeadershipOnly) - .addGroup(layout.createSequentialGroup() - .addComponent(lblManagementSkillPenalty) - .addComponent(spnManagementSkillPenalty) - ))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); - return panel; - } + layout.gridy = 0; + layout.gridx = 0; + layout.gridwidth = 1; + panel.add(chkUseCommanderLeadershipOnly, layout); - /** - * Constructs and configures a panel for the Fatigue tab. - * This tab contains a header panel, a checkbox for activating fatigue, - * a spinner for adjusting the fatigue rate, a checkbox for toggling fatigue from injury, - * a spinner for adjusting field kitchen capacity, a checkbox for making field kitchens ignore - * non-combatants and a spinner for adjusting the fatigue leave threshold. - *

- * The layout of the tab panel is organized with a {@link GroupLayout}, ensuring organized vertical - * and horizontal alignment. - * - * @return panel the configured {@link JPanel} for the Fatigue tab - */ - JPanel createFatigueTab() { - // Header - JPanel headerPanel = new CampaignOptionsHeaderPanel("FatigueTab", - getImageDirectory() + "logo_free_rasalhague_republic.png", - true); - - // Contents - chkUseFatigue = new CampaignOptionsCheckBox("UseFatigue"); - - lblFatigueRate = new CampaignOptionsLabel("FatigueRate"); - spnFatigueRate = new CampaignOptionsSpinner("FatigueRate", - 1, 1, 10, 1); - - chkUseInjuryFatigue = new CampaignOptionsCheckBox("UseInjuryFatigue"); - - lblFieldKitchenCapacity = new CampaignOptionsLabel("FieldKitchenCapacity"); - spnFieldKitchenCapacity = new CampaignOptionsSpinner("FieldKitchenCapacity", - 150, 0, 450, 1); + layout.gridy++; + panel.add(lblManagementSkillPenalty, layout); + layout.gridx++; + panel.add(spnManagementSkillPenalty, layout); - chkFieldKitchenIgnoreNonCombatants = new CampaignOptionsCheckBox("FieldKitchenIgnoreNonCombatants"); - - lblFatigueLeaveThreshold = new CampaignOptionsLabel("FatigueLeaveThreshold"); - spnFatigueLeaveThreshold = new CampaignOptionsSpinner("FatigueLeaveThreshold", - 13, 0, 17, 1); - - // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("FatigueTab", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(chkUseFatigue) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblFatigueRate) - .addComponent(spnFatigueRate) - .addComponent(chkUseInjuryFatigue)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblFieldKitchenCapacity) - .addComponent(spnFieldKitchenCapacity) - .addComponent(chkFieldKitchenIgnoreNonCombatants)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblFatigueLeaveThreshold) - .addComponent(spnFatigueLeaveThreshold))); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(chkUseFatigue) - .addGroup(layout.createSequentialGroup() - .addComponent(lblFatigueRate) - .addComponent(spnFatigueRate) - .addComponent(chkUseInjuryFatigue) - ) - .addGroup(layout.createSequentialGroup() - .addComponent(lblFieldKitchenCapacity) - .addComponent(spnFieldKitchenCapacity) - .addComponent(chkFieldKitchenIgnoreNonCombatants) - ) - .addGroup(layout.createSequentialGroup() - .addComponent(lblFatigueLeaveThreshold) - .addComponent(spnFatigueLeaveThreshold) - ))); - - // Create Parent Panel and return - return createParentPanel(panel, "FatigueTab"); + return panel; } } From 28909e73821714c83aa3d73ad8a3ed21b8a9d4cd Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 16 Oct 2024 14:35:35 -0500 Subject: [PATCH 102/117] Combine Acquisition and Delivery Tabs Merged acquisition and delivery panels into a single tab for consistency and better user experience. Removed the redundant initialization and layout code, and updated related resource strings to reflect the changes. --- .../NEWCampaignOptionsDialog.properties | 36 +-- .../campaignOptions/CampaignOptionsPane.java | 1 - .../CampaignOptionsUtilities.java | 5 +- .../EquipmentAndSuppliesTab.java | 262 ++++++++++-------- .../panes/campaignOptions/PersonnelTab.java | 28 +- 5 files changed, 173 insertions(+), 159 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index b3b7c4250a..4edc3ff883 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -107,16 +107,11 @@ lblLogMaintenance.tooltip=PLACEHOLDER ## SuppliesAndAcquisitionTab suppliesAndAcquisitionContentTabs.title=Supplies and Acquisition -acquisitionTab.title=Acquisitions +acquisitionTab.title=Acquisitions & Deliveries acquisitionTab.border="It's not about what you need - it's about what you can get. In acquisitions,\ \ creativity beats C-Bills."\
- Quartermaster Jonas "Scrounger" Voss, Red Talon Mercenaries -deliveryTab.title=Deliveries -deliveryTab.border="Every part I deliver is a promise that a mek will rise again. Speed is my weapon,\ - \ and time is the enemy."\ -
- Captain Horace "Hot Wheels" Drake, Midnight Express - planetaryAcquisitionTab.title=Planetary Acquisitions planetaryAcquisitionTab.border="On a guerrilla contract, parts are as valuable as ammo. Get what you\ \ can, while you can, because tomorrow, it might be gone."\ @@ -128,12 +123,15 @@ techLimitsTab.border="In a universe where we fight with the ghosts of a golden a
- Engineer Talia "Patch" Kessler, Stormhounds # createAcquisitionTab -lblAcquisitionTab.text=Acquisition Options -lblAcquisitionTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Tristique non elit\ - \ potenti suscipit lobortis sollicitudin. Iaculis dis ultrices cursus litora iaculis. Commodo blandit\ - \ penatibus vitae leo quisque lectus dictum. Duis conubia nisi aliquet phasellus risus nullam massa\ - \ at. Elementum natoque torquent phasellus suspendisse per aliquet scelerisque. Justo integer\ - \ faucibus penatibus sem class. +lblAcquisitionTab.text=Acquisition & Delivery Options +lblAcquisitionTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Nisl senectus neque\ + \ sem maximus accumsan nibh curae dapibus. Asuspendisse ullamcorper aliquet aliquet pretium duis\ + \ litora porttitor.Tristique ex per aptent cras augue mus suspendisse inceptos hac. Amet ultricies\ + \ sem dui etiam justo. Efficitur ac nisl maecenas eu ac tincidunt. Eget felis hendrerit lacinia\ + \ commodo eu natoque id himenaeos nibh. + +# createAcquisitionPanel +lblAcquisitionPanel.text=Acquisitions lblChoiceAcquireSkill.text=Acquisitions Skill lblChoiceAcquireSkill.tooltip=PLACEHOLDER lblSupportStaffOnly.text=Only Support Personnel Make Acquisition Rolls @@ -147,19 +145,13 @@ lblAcquireWaitingPeriod.tooltip=PLACEHOLDER lblMaxAcquisitions.text=Max Acquisition Rolls per Period lblMaxAcquisitions.tooltip=PLACEHOLDER -# createDeliveryTab -lblDeliveryTab.text=Delivery Options -lblDeliveryTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod varius congue\ - \ rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam maximus. Morbi\ - \ gravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat turpis semper\ - \ morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida primis\ - \ vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin porttitor\ - \ dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam. +# createDeliveryPanel +lblDeliveryPanel.text=Deliveries lblNDiceTransitTime.text=Delivery Time lblNDiceTransitTime.tooltip=PLACEHOLDER lblConstantTransitTime.text=d6+ lblConstantTransitTime.tooltip=PLACEHOLDER -lblAcquireMosBonus.text=Delivery Time Reduction (per Margin of Success) +lblAcquireMosBonus.text=Delivery Time Reduction lblAcquireMosBonus.tooltip=PLACEHOLDER lblAcquireMinimum.text=Minimum Delivery Time lblAcquireMinimum.tooltip=PLACEHOLDER @@ -373,7 +365,7 @@ lblIssueBestAwardOnly.text=Issue Best Award Only lblIssueBestAwardOnly.tooltip=PLACEHOLDER lblIgnoreStandardSet.text=Ignore the Standard Set lblIgnoreStandardSet.tooltip=PLACEHOLDER -lblAwardSetFilterList.text=Award Set Filter +lblAwardsTabBottom.text=Award Set Filter lblAwardSetFilterList.tooltip=PLACEHOLDER # createAutoAwardsFilterPanel diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java index bf35f0146e..cfc93fbba5 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java @@ -184,7 +184,6 @@ private JTabbedPane createEquipmentAndSuppliesParentTab() { JTabbedPane suppliesAndAcquisitionContentTabs = createSubTabs(Map.of( "acquisitionTab", suppliesAndAcquisitionTab.createAcquisitionTab(), - "deliveryTab", suppliesAndAcquisitionTab.createDeliveryTab(), "planetaryAcquisitionTab", suppliesAndAcquisitionTab.createPlanetaryAcquisitionTab(), "techLimitsTab", suppliesAndAcquisitionTab.createTechLimitsTab())); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java index a2c56ca583..7533a0b77b 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java @@ -418,7 +418,7 @@ public CampaignOptionsGridBagConstraints(JPanel panel, @Nullable Integer anchor, panel.setLayout(new GridBagLayout()); this.anchor = Objects.requireNonNullElse(anchor, GridBagConstraints.NORTHWEST); - this.fill = Objects.requireNonNullElse(fill, GridBagConstraints.BOTH); + this.fill = Objects.requireNonNullElse(fill, GridBagConstraints.NONE); this.insets = new Insets(5, 5, 5, 5); } @@ -488,7 +488,8 @@ static JTabbedPane createSubTabs(Map panels) { JPanel quotePanel = new JPanel(new GridBagLayout()); JLabel quote = new JLabel(String.format( "

%s
", - UIUtil.scaleForGUI(mainPanel.getPreferredSize().width), resources.getString(tabName + ".border"))); + UIUtil.scaleForGUI(mainPanel.getPreferredSize().width), + resources.getString(tabName + ".border"))); GridBagConstraints quoteConstraints = new GridBagConstraints(); quoteConstraints.gridx = GridBagConstraints.RELATIVE; diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java index ae29ead6c8..a02a382f2a 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java @@ -25,6 +25,7 @@ public class EquipmentAndSuppliesTab { String name; //start Acquisition Tab + private JPanel pnlAcquisitions; private JLabel lblChoiceAcquireSkill; private MMComboBox choiceAcquireSkill; private JCheckBox chkSupportStaffOnly; @@ -39,6 +40,7 @@ public class EquipmentAndSuppliesTab { //end Acquisition Tab //start Delivery Tab + private JPanel pnlDeliveries; private JLabel lblNDiceTransitTime; private JSpinner spnNDiceTransitTime; private JLabel lblConstantTransitTime; @@ -154,6 +156,7 @@ private void initializePlanetaryAcquisitionsTab() { * The panel contains settings related to divorce mechanics within the simulation. */ private void initializeDelivery() { + pnlDeliveries = new JPanel(); lblNDiceTransitTime = new JLabel(); spnNDiceTransitTime = new JSpinner(); lblConstantTransitTime = new JLabel(); @@ -174,6 +177,7 @@ private void initializeDelivery() { * The panel contains various settings related to marriage mechanics within the simulation. */ private void initializeAcquisitionTab() { + pnlAcquisitions = new JPanel(); lblChoiceAcquireSkill = new JLabel(); choiceAcquireSkill = new MMComboBox<>("choiceAcquireSkill", buildAcquireSkillComboOptions()); @@ -219,79 +223,165 @@ JPanel createAcquisitionTab() { JPanel headerPanel = new CampaignOptionsHeaderPanel("AcquisitionTab", getImageDirectory() + "logo_calderon_protectorate.png", true); - // Acquisitions skill + pnlAcquisitions = createAcquisitionPanel(); + pnlDeliveries = createDeliveryPanel(); + + // Layout the Panel + final JPanel panel = new CampaignOptionsStandardPanel("acquisitionTab", true); + final GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panel); + + layoutParent.gridwidth = 5; + layoutParent.gridx = 0; + layoutParent.gridy = 0; + panel.add(headerPanel, layoutParent); + + layoutParent.gridy++; + layoutParent.gridwidth = 1; + panel.add(pnlAcquisitions, layoutParent); + + layoutParent.gridy++; + panel.add(pnlDeliveries, layoutParent); + + + // Create Parent Panel and return + return createParentPanel(panel, "acquisitionsTab"); + } + + /** + * Creates the acquisition tab panel. + * + * @return the created tab panel as a {@link JPanel} + */ + private JPanel createAcquisitionPanel() { + // Content lblChoiceAcquireSkill = new CampaignOptionsLabel("ChoiceAcquireSkill"); - // Support personnel only chkSupportStaffOnly = new CampaignOptionsCheckBox("SupportStaffOnly"); - // Clan Acquisition penalty lblAcquireClanPenalty = new CampaignOptionsLabel("AcquireClanPenalty"); spnAcquireClanPenalty = new CampaignOptionsSpinner("AcquireClanPenalty", 0, 0, 13, 1); - // IS Acquisition penalty lblAcquireIsPenalty = new CampaignOptionsLabel("AcquireISPenalty"); spnAcquireIsPenalty = new CampaignOptionsSpinner("AcquireISPenalty", 0, 0, 13, 1); - // Waiting Period lblAcquireWaitingPeriod = new CampaignOptionsLabel("AcquireWaitingPeriod"); spnAcquireWaitingPeriod = new CampaignOptionsSpinner("AcquireWaitingPeriod", 1, 1, 365, 1); - // Maximum Acquisitions lblMaxAcquisitions = new CampaignOptionsLabel("MaxAcquisitions"); spnMaxAcquisitions = new CampaignOptionsSpinner("MaxAcquisitions", 0,0, 100, 1); // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("acquisitionTab", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + final JPanel panel = new CampaignOptionsStandardPanel("AcquisitionPanel", true, + "AcquisitionPanel"); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridy = 0; + layout.gridx = 0; + layout.gridwidth = 1; + panel.add(lblChoiceAcquireSkill, layout); + layout.gridx++; + panel.add(choiceAcquireSkill, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkSupportStaffOnly, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblAcquireClanPenalty, layout); + layout.gridx++; + panel.add(spnAcquireClanPenalty, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblAcquireIsPenalty, layout); + layout.gridx++; + panel.add(spnAcquireIsPenalty, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblAcquireWaitingPeriod, layout); + layout.gridx++; + panel.add(spnAcquireWaitingPeriod, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblMaxAcquisitions, layout); + layout.gridx++; + panel.add(spnMaxAcquisitions, layout); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblChoiceAcquireSkill) - .addComponent(choiceAcquireSkill)) - .addComponent(chkSupportStaffOnly) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblAcquireClanPenalty) - .addComponent(spnAcquireClanPenalty)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblAcquireIsPenalty) - .addComponent(spnAcquireIsPenalty)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblAcquireWaitingPeriod) - .addComponent(spnAcquireWaitingPeriod)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblMaxAcquisitions) - .addComponent(spnMaxAcquisitions))); + return panel; + } - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addGroup(layout.createSequentialGroup() - .addComponent(lblChoiceAcquireSkill) - .addComponent(choiceAcquireSkill)) - .addComponent(chkSupportStaffOnly) - .addGroup(layout.createSequentialGroup() - .addComponent(lblAcquireClanPenalty) - .addComponent(spnAcquireClanPenalty)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblAcquireIsPenalty) - .addComponent(spnAcquireIsPenalty)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblAcquireWaitingPeriod) - .addComponent(spnAcquireWaitingPeriod)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblMaxAcquisitions) - .addComponent(spnMaxAcquisitions))); + /** + * Creates the delivery tab panel. + * + * @return the created tab panel as a {@link JPanel} + */ + private JPanel createDeliveryPanel() { + lblNDiceTransitTime = new CampaignOptionsLabel("NDiceTransitTime"); + spnNDiceTransitTime = new CampaignOptionsSpinner("NDiceTransitTime", 0, + 0, 365, 1); - // Create Parent Panel and return - return createParentPanel(panel, "acquisitionsTab"); + lblConstantTransitTime = new CampaignOptionsLabel("ConstantTransitTime"); + spnConstantTransitTime = new CampaignOptionsSpinner("ConstantTransitTime", + 0, 0, 365, 1); + + lblAcquireMosBonus = new CampaignOptionsLabel("AcquireMosBonus"); + spnAcquireMosBonus = new CampaignOptionsSpinner("AcquireMosBonus", + 0, 0, 365, 1); + + lblAcquireMinimum = new CampaignOptionsLabel("AcquireMinimum"); + spnAcquireMinimum = new CampaignOptionsSpinner("AcquireMinimum", + 0, 0, 365, 1); + + // Layout the Panel + final JPanel panelTransit = new CampaignOptionsStandardPanel("DeliveryPanelTransit"); + final GridBagConstraints layoutTransit = new CampaignOptionsGridBagConstraints(panelTransit); + + layoutTransit.gridy = 0; + layoutTransit.gridx = 0; + layoutTransit.gridwidth = 1; + panelTransit.add(lblNDiceTransitTime, layoutTransit); + layoutTransit.gridx++; + panelTransit.add(spnNDiceTransitTime, layoutTransit); + layoutTransit.gridx++; + panelTransit.add(lblConstantTransitTime, layoutTransit); + layoutTransit.gridx++; + panelTransit.add(spnConstantTransitTime, layoutTransit); + layoutTransit.gridx++; + panelTransit.add(choiceTransitTimeUnits, layoutTransit); + + final JPanel panel = new CampaignOptionsStandardPanel("DeliveryPanel", true, + "DeliveryPanel"); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridy = 0; + layout.gridx = 0; + layout.gridwidth = 2; + panel.add(panelTransit, layout); + + layout.gridwidth = 1; + layout.gridy++; + panel.add(lblAcquireMosBonus, layout); + layout.gridx++; + panel.add(spnAcquireMosBonus, layout); + layout.gridx++; + panel.add(choiceAcquireMosUnits, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblAcquireMinimum, layout); + layout.gridx++; + panel.add(spnAcquireMinimum, layout); + layout.gridx++; + panel.add(choiceAcquireMinimumUnit, layout); + + return panel; } JPanel createPlanetaryAcquisitionTab() { @@ -664,80 +754,6 @@ private String getModifierLabel(int quality) { }; } - /** - * Creates the delivery tab panel. - * - * @return the created tab panel as a {@link JPanel} - */ - JPanel createDeliveryTab() { - // Header - JPanel headerPanel = new CampaignOptionsHeaderPanel("DeliveryTab", - getImageDirectory() + "logo_clan_burrock.png", true); - - // Delivery Time - lblNDiceTransitTime = new CampaignOptionsLabel("NDiceTransitTime"); - spnNDiceTransitTime = new CampaignOptionsSpinner("NDiceTransitTime", 0, - 0, 365, 1); - - lblConstantTransitTime = new CampaignOptionsLabel("ConstantTransitTime"); - spnConstantTransitTime = new CampaignOptionsSpinner("ConstantTransitTime", - 0, 0, 365, 1); - - // Margin of Success Reductions - lblAcquireMosBonus = new CampaignOptionsLabel("AcquireMosBonus"); - spnAcquireMosBonus = new CampaignOptionsSpinner("AcquireMosBonus", - 0, 0, 365, 1); - - // Minimum Transit Time - lblAcquireMinimum = new CampaignOptionsLabel("AcquireMinimum"); - spnAcquireMinimum = new CampaignOptionsSpinner("AcquireMinimum", - 0, 0, 365, 1); - - // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("deliveryTab", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblNDiceTransitTime) - .addComponent(spnNDiceTransitTime) - .addComponent(lblConstantTransitTime) - .addComponent(spnConstantTransitTime) - .addComponent(choiceTransitTimeUnits)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblAcquireMosBonus) - .addComponent(spnAcquireMosBonus) - .addComponent(choiceAcquireMosUnits)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblAcquireMinimum) - .addComponent(spnAcquireMinimum) - .addComponent(choiceAcquireMinimumUnit))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addGroup(layout.createSequentialGroup() - .addComponent(lblNDiceTransitTime) - .addComponent(spnNDiceTransitTime) - .addComponent(lblConstantTransitTime) - .addComponent(spnConstantTransitTime) - .addComponent(choiceTransitTimeUnits)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblAcquireMosBonus) - .addComponent(spnAcquireMosBonus) - .addComponent(choiceAcquireMosUnits)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblAcquireMinimum) - .addComponent(spnAcquireMinimum) - .addComponent(choiceAcquireMinimumUnit))); - - // Create Parent Panel and return - return createParentPanel(panel, "deliveryTab"); - } - /** * Retrieves the transit unit options as a {@link DefaultComboBoxModel}. * diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java index 560a62b6c0..e90ab5ffc5 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java @@ -98,7 +98,6 @@ public class PersonnelTab { private JCheckBox chkEnableTimeAwards; private JCheckBox chkEnableTrainingAwards; private JCheckBox chkEnableMiscAwards; - private JLabel lblAwardSetFilterList; private JTextArea txtAwardSetFilterList; //end Awards Tab @@ -271,7 +270,6 @@ private void initializeAwardsTab() { chkEnableMiscAwards = new JCheckBox(); pnlAutoAwardsFilter = new JPanel(); - lblAwardSetFilterList = new JLabel(); txtAwardSetFilterList = new JTextArea(); } @@ -369,12 +367,13 @@ JPanel createGeneralTab() { final JPanel panelRight = new CampaignOptionsStandardPanel("RightPanel"); GridBagConstraints layoutRight = new CampaignOptionsGridBagConstraints(panelRight); + layoutRight.gridwidth = 1; layoutRight.gridx = 0; layoutRight.gridy = 0; panelRight.add(pnlPersonnelCleanup, layoutRight); layoutRight.gridy++; - panelRight.add(pnlAdministrators, layoutRight); + layoutRight.gridwidth = 1; panelRight.add(pnlAdministrators, layoutRight); final JPanel panelParent = new CampaignOptionsStandardPanel("PersonnelGeneralTab", true); GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panelParent); @@ -533,8 +532,7 @@ JPanel createAwardsTab() { pnlAwardsGeneralOptions = createAwardsGeneralOptionsPanel(); pnlAutoAwardsFilter = createAutoAwardsFilterPanel(); - lblAwardSetFilterList = new CampaignOptionsLabel("AwardSetFilterList"); - txtAwardSetFilterList = new JTextArea(5, 20); + txtAwardSetFilterList = new JTextArea(10, 60); txtAwardSetFilterList.setLineWrap(true); txtAwardSetFilterList.setWrapStyleWord(true); txtAwardSetFilterList.setToolTipText( @@ -548,7 +546,7 @@ JPanel createAwardsTab() { ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); // Layout the Panel - final JPanel panelRight = new CampaignOptionsStandardPanel("AwardsTab"); + final JPanel panelRight = new CampaignOptionsStandardPanel("AwardsTabRight"); final GridBagConstraints layoutRight = new CampaignOptionsGridBagConstraints(panelRight); layoutRight.gridy = 0; @@ -556,11 +554,14 @@ JPanel createAwardsTab() { layoutRight.gridy++; panelRight.add(pnlAutoAwardsFilter, layoutRight); - layoutRight.gridx = 0; - layoutRight.gridy++; - panelRight.add(lblAwardSetFilterList, layoutRight); - layoutRight.gridy++; - panelRight.add(txtAwardSetFilterList, layoutRight); + final JPanel panelBottom = new CampaignOptionsStandardPanel("AwardsTabBottom", true, + "AwardsTabBottom"); + final GridBagConstraints layoutBottom = new CampaignOptionsGridBagConstraints(panelBottom, + null, GridBagConstraints.HORIZONTAL); + + layoutBottom.gridx = 0; + layoutBottom.gridy++; + panelBottom.add(txtAwardSetFilterList, layoutBottom); final JPanel panelParent = new CampaignOptionsStandardPanel("AwardsTabRight", true); final GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panelParent); @@ -577,6 +578,11 @@ JPanel createAwardsTab() { layoutParent.gridx++; panelParent.add(panelRight, layoutParent); + layoutParent.gridx = 0; + layoutParent.gridy++; + layoutParent.gridwidth = 2; + panelParent.add(panelBottom, layoutParent); + // Create Parent Panel and return return createParentPanel(panelParent, "AwardsTab"); } From 8c074c23aab1b7a0318a9a18b21073a17806668e Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 16 Oct 2024 14:53:22 -0500 Subject: [PATCH 103/117] Switch to GridBagLayout for Campaign Options Tabs Replaced GroupLayout with GridBagLayout for better control over component positioning and layout consistency across the Campaign Options tabs. Adjusted component placements and grid constraints accordingly to ensure all elements are arranged properly. --- .../NEWCampaignOptionsDialog.properties | 2 +- .../EquipmentAndSuppliesTab.java | 361 ++++++------------ 2 files changed, 116 insertions(+), 247 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 4edc3ff883..1bcaaf0aae 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -175,7 +175,7 @@ lblMaxJumpPlanetaryAcquisitions.text=Maximum Jump Distance lblMaxJumpPlanetaryAcquisitions.tooltip=PLACEHOLDER lblPlanetaryAcquisitionsFactionLimits.text=Faction Supply Limits lblPlanetaryAcquisitionsFactionLimits.tooltip=PLACEHOLDER -lblDisallowPlanetaryAcquisitionClanCrossover.text=No Clan-Inner Sphere Supply Sharing +lblDisallowPlanetaryAcquisitionClanCrossover.text=Disallow Clan-Inner Sphere Supply Sharing lblDisallowPlanetaryAcquisitionClanCrossover.tooltip=PLACEHOLDER lblDisallowClanPartsFromIS.text=Disallow Clan Parts from Non-Clan Factions lblDisallowClanPartsFromIS.tooltip=PLACEHOLDER diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java index a02a382f2a..a06d29111d 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java @@ -9,7 +9,6 @@ import mekhq.campaign.personnel.SkillType; import javax.swing.*; -import javax.swing.GroupLayout.Alignment; import java.awt.*; import java.util.ResourceBundle; @@ -395,23 +394,19 @@ JPanel createPlanetaryAcquisitionTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("PlanetaryAcquisitionTab", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + final GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panel); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(options) - .addComponent(modifiers))); + layoutParent.gridwidth = 5; + layoutParent.gridy = 0; + panel.add(headerPanel, layoutParent); + layoutParent.gridx = 0; + layoutParent.gridy++; + layoutParent.gridwidth = 1; + panel.add(options, layoutParent); - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addGroup(layout.createSequentialGroup() - .addComponent(options) - .addComponent(modifiers))); + layoutParent.gridx++; + panel.add(modifiers, layoutParent); // Create Parent Panel and return return createParentPanel(panel, "PlanetaryAcquisitionTab"); @@ -424,68 +419,58 @@ JPanel createPlanetaryAcquisitionTab() { * @return the created tab panel as a {@link JPanel} */ private JPanel createOptionsPanel() { - // Use Planetary Acquisitions usePlanetaryAcquisitions = new CampaignOptionsCheckBox("UsePlanetaryAcquisitions"); - // Max Jump Distance lblMaxJumpPlanetaryAcquisitions = new CampaignOptionsLabel("MaxJumpPlanetaryAcquisitions"); spnMaxJumpPlanetaryAcquisitions = new CampaignOptionsSpinner("MaxJumpPlanetaryAcquisitions", 2, 0, 5, 1); - // Faction Limits lblPlanetaryAcquisitionsFactionLimits = new CampaignOptionsLabel("PlanetaryAcquisitionsFactionLimits"); - // Disallow Resource Sharing (Inner Sphere) disallowPlanetaryAcquisitionClanCrossover = new CampaignOptionsCheckBox("DisallowPlanetaryAcquisitionClanCrossover"); - // Disallow Resource Sharing (Clans) disallowClanPartsFromIS = new CampaignOptionsCheckBox("DisallowClanPartsFromIS"); - // Acquisition Penalty lblPenaltyClanPartsFromIS = new CampaignOptionsLabel("PenaltyClanPartsFromIS"); spnPenaltyClanPartsFromIS = new CampaignOptionsSpinner("PenaltyClanPartsFromIS", 0, 0, 12, 1); - // Verbose Reporting usePlanetaryAcquisitionsVerbose = new CampaignOptionsCheckBox("UsePlanetaryAcquisitionsVerbose"); // Layout the Panel final JPanel panel = new JPanel(); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(usePlanetaryAcquisitions) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(spnMaxJumpPlanetaryAcquisitions) - .addComponent(lblMaxJumpPlanetaryAcquisitions)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPlanetaryAcquisitionsFactionLimits) - .addComponent(comboPlanetaryAcquisitionsFactionLimits)) - .addComponent(disallowPlanetaryAcquisitionClanCrossover) - .addComponent(disallowClanPartsFromIS) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(spnPenaltyClanPartsFromIS) - .addComponent(lblPenaltyClanPartsFromIS)) - .addComponent(usePlanetaryAcquisitionsVerbose)); - - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(usePlanetaryAcquisitions) - .addGroup(layout.createSequentialGroup() - .addComponent(lblMaxJumpPlanetaryAcquisitions) - .addComponent(spnMaxJumpPlanetaryAcquisitions)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPlanetaryAcquisitionsFactionLimits) - .addComponent(comboPlanetaryAcquisitionsFactionLimits)) - .addComponent(disallowPlanetaryAcquisitionClanCrossover) - .addComponent(disallowClanPartsFromIS) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPenaltyClanPartsFromIS) - .addComponent(spnPenaltyClanPartsFromIS)) - .addComponent(usePlanetaryAcquisitionsVerbose)); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + panel.add(usePlanetaryAcquisitions, layout); + layout.gridx++; + panel.add(usePlanetaryAcquisitionsVerbose, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblMaxJumpPlanetaryAcquisitions, layout); + layout.gridx++; + panel.add(spnMaxJumpPlanetaryAcquisitions, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblPlanetaryAcquisitionsFactionLimits, layout); + layout.gridx++; + panel.add(comboPlanetaryAcquisitionsFactionLimits, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(disallowPlanetaryAcquisitionClanCrossover, layout); + + layout.gridy++; + panel.add(disallowClanPartsFromIS, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblPenaltyClanPartsFromIS, layout); + layout.gridx++; + panel.add(spnPenaltyClanPartsFromIS, layout); return panel; } @@ -527,22 +512,15 @@ private JPanel createModifiersPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("PlanetaryAcquisitionTabModifiers", true, "ModifiersPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(pnlIndustryModifiers) - .addComponent(pnlTechModifiers) - .addComponent(pnlOutputModifiers))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(pnlIndustryModifiers) - .addComponent(pnlTechModifiers) - .addComponent(pnlOutputModifiers))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + panel.add(pnlIndustryModifiers, layout); + layout.gridx++; + panel.add(pnlTechModifiers, layout); + layout.gridx++; + panel.add(pnlOutputModifiers, layout); return panel; } @@ -558,52 +536,15 @@ private JPanel createTechModifiersPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("createTechModifiersPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(techLabel) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPlanetAcquireTechBonus[0]) - .addComponent(spnPlanetAcquireTechBonus[0])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPlanetAcquireTechBonus[1]) - .addComponent(spnPlanetAcquireTechBonus[1])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPlanetAcquireTechBonus[2]) - .addComponent(spnPlanetAcquireTechBonus[2])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPlanetAcquireTechBonus[3]) - .addComponent(spnPlanetAcquireTechBonus[3])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPlanetAcquireTechBonus[4]) - .addComponent(spnPlanetAcquireTechBonus[4])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPlanetAcquireTechBonus[5]) - .addComponent(spnPlanetAcquireTechBonus[5]))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(techLabel) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPlanetAcquireTechBonus[0]) - .addComponent(spnPlanetAcquireTechBonus[0])) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPlanetAcquireTechBonus[1]) - .addComponent(spnPlanetAcquireTechBonus[1])) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPlanetAcquireTechBonus[2]) - .addComponent(spnPlanetAcquireTechBonus[2])) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPlanetAcquireTechBonus[3]) - .addComponent(spnPlanetAcquireTechBonus[3])) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPlanetAcquireTechBonus[4]) - .addComponent(spnPlanetAcquireTechBonus[4])) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPlanetAcquireTechBonus[5]) - .addComponent(spnPlanetAcquireTechBonus[5]))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + for (int i = 0; i < 6; i++) { + layout.gridx = 0; + layout.gridy = i; + panel.add(lblPlanetAcquireTechBonus[i], layout); + layout.gridx++; + panel.add(spnPlanetAcquireTechBonus[i], layout); + } return panel; } @@ -619,52 +560,15 @@ private JPanel createIndustryModifiersPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("IndustryModifiersPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(industryLabel) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPlanetAcquireIndustryBonus[0]) - .addComponent(spnPlanetAcquireIndustryBonus[0])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPlanetAcquireIndustryBonus[1]) - .addComponent(spnPlanetAcquireIndustryBonus[1])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPlanetAcquireIndustryBonus[2]) - .addComponent(spnPlanetAcquireIndustryBonus[2])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPlanetAcquireIndustryBonus[3]) - .addComponent(spnPlanetAcquireIndustryBonus[3])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPlanetAcquireIndustryBonus[4]) - .addComponent(spnPlanetAcquireIndustryBonus[4])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPlanetAcquireIndustryBonus[5]) - .addComponent(spnPlanetAcquireIndustryBonus[5]))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(industryLabel) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPlanetAcquireIndustryBonus[0]) - .addComponent(spnPlanetAcquireIndustryBonus[0])) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPlanetAcquireIndustryBonus[1]) - .addComponent(spnPlanetAcquireIndustryBonus[1])) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPlanetAcquireIndustryBonus[2]) - .addComponent(spnPlanetAcquireIndustryBonus[2])) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPlanetAcquireIndustryBonus[3]) - .addComponent(spnPlanetAcquireIndustryBonus[3])) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPlanetAcquireIndustryBonus[4]) - .addComponent(spnPlanetAcquireIndustryBonus[4])) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPlanetAcquireIndustryBonus[5]) - .addComponent(spnPlanetAcquireIndustryBonus[5]))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + for (int i = 0; i < 6; i++) { + layout.gridx = 0; + layout.gridy = i; + panel.add(lblPlanetAcquireIndustryBonus[i], layout); + layout.gridx++; + panel.add(spnPlanetAcquireIndustryBonus[i], layout); + } return panel; } @@ -675,52 +579,15 @@ private JPanel createOutputModifiersPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("OutputModifiersPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(outputLabel) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPlanetAcquireOutputBonus[0]) - .addComponent(spnPlanetAcquireOutputBonus[0])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPlanetAcquireOutputBonus[1]) - .addComponent(spnPlanetAcquireOutputBonus[1])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPlanetAcquireOutputBonus[2]) - .addComponent(spnPlanetAcquireOutputBonus[2])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPlanetAcquireOutputBonus[3]) - .addComponent(spnPlanetAcquireOutputBonus[3])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPlanetAcquireOutputBonus[4]) - .addComponent(spnPlanetAcquireOutputBonus[4])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPlanetAcquireOutputBonus[5]) - .addComponent(spnPlanetAcquireOutputBonus[5]))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(outputLabel) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPlanetAcquireOutputBonus[0]) - .addComponent(spnPlanetAcquireOutputBonus[0])) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPlanetAcquireOutputBonus[1]) - .addComponent(spnPlanetAcquireOutputBonus[1])) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPlanetAcquireOutputBonus[2]) - .addComponent(spnPlanetAcquireOutputBonus[2])) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPlanetAcquireOutputBonus[3]) - .addComponent(spnPlanetAcquireOutputBonus[3])) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPlanetAcquireOutputBonus[4]) - .addComponent(spnPlanetAcquireOutputBonus[4])) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPlanetAcquireOutputBonus[5]) - .addComponent(spnPlanetAcquireOutputBonus[5]))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + for (int i = 0; i < 6; i++) { + layout.gridx = 0; + layout.gridy = i; + panel.add(lblPlanetAcquireOutputBonus[i], layout); + layout.gridx++; + panel.add(spnPlanetAcquireOutputBonus[i], layout); + } return panel; } @@ -813,13 +680,10 @@ JPanel createTechLimitsTab() { JPanel headerPanel = new CampaignOptionsHeaderPanel("TechLimitsTab", getImageDirectory() + "logo_clan_cloud_cobra.png", true); - // Limit Parts/Units by Year limitByYearBox = new CampaignOptionsCheckBox("LimitByYearBox"); - // Disallow Extinct Units/Parts disallowExtinctStuffBox = new CampaignOptionsCheckBox("DisallowExtinctStuffBox"); - // Allow Clan/Inner Sphere Purchases allowClanPurchasesBox = new CampaignOptionsCheckBox("AllowClanPurchasesBox"); allowISPurchasesBox = new CampaignOptionsCheckBox("AllowISPurchasesBox"); @@ -839,38 +703,43 @@ JPanel createTechLimitsTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("TechLimitsTab", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(limitByYearBox) - .addComponent(disallowExtinctStuffBox) - .addComponent(allowClanPurchasesBox) - .addComponent(allowISPurchasesBox) - .addComponent(allowCanonOnlyBox) - .addComponent(allowCanonRefitOnlyBox) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblChoiceTechLevel) - .addComponent(choiceTechLevel)) - .addComponent(variableTechLevelBox) - .addComponent(useAmmoByTypeBox)); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(limitByYearBox) - .addComponent(disallowExtinctStuffBox) - .addComponent(allowClanPurchasesBox) - .addComponent(allowISPurchasesBox) - .addComponent(allowCanonOnlyBox) - .addComponent(allowCanonRefitOnlyBox) - .addGroup(layout.createSequentialGroup() - .addComponent(lblChoiceTechLevel) - .addComponent(choiceTechLevel)) - .addComponent(variableTechLevelBox) - .addComponent(useAmmoByTypeBox)); + final GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panel); + + layoutParent.gridwidth = 5; + layoutParent.gridx = 0; + layoutParent.gridy = 0; + panel.add(headerPanel, layoutParent); + + layoutParent.gridx = 0; + layoutParent.gridy++; + layoutParent.gridwidth = 1; + panel.add(lblChoiceTechLevel, layoutParent); + layoutParent.gridx++; + panel.add(choiceTechLevel, layoutParent); + + layoutParent.gridx = 0; + layoutParent.gridy++; + panel.add(limitByYearBox, layoutParent); + layoutParent.gridx++; + panel.add(disallowExtinctStuffBox, layoutParent); + + layoutParent.gridx = 0; + layoutParent.gridy++; + panel.add(allowClanPurchasesBox, layoutParent); + layoutParent.gridx++; + panel.add(allowISPurchasesBox, layoutParent); + + layoutParent.gridx = 0; + layoutParent.gridy++; + panel.add(allowCanonOnlyBox, layoutParent); + layoutParent.gridx++; + panel.add(allowCanonRefitOnlyBox, layoutParent); + + layoutParent.gridx = 0; + layoutParent.gridy++; + panel.add(variableTechLevelBox, layoutParent); + layoutParent.gridx++; + panel.add(useAmmoByTypeBox, layoutParent); // Create Parent Panel and return return createParentPanel(panel, "TechLimitsTab"); From 0848b5a595ce24b534784fd79d08651412ce1872 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 16 Oct 2024 15:02:23 -0500 Subject: [PATCH 104/117] Refactor Repair and Maintenance tab layout Separated the Repair and Maintenance tab into two panels using GridBagLayout. This change improves the layout structure and readability of the GUI code, making it easier to manage and extend in the future. Updated relevant properties file with new labels and tooltips. --- .../NEWCampaignOptionsDialog.properties | 3 +- .../RepairAndMaintenanceTab.java | 93 +++++++++++-------- 2 files changed, 57 insertions(+), 39 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 1bcaaf0aae..4669e085cf 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -69,9 +69,10 @@ lblUseQuirksBox.text=Use Quirks lblUseQuirksBox.tooltip=PLACEHOLDER lblUseAeroSystemHitsBox.text=Damage Aero System Parts by Hits Taken lblUseAeroSystemHitsBox.tooltip=PLACEHOLDER +lblRepairTabRight.text=Component Damage lblUseDamageMargin.text=Damage Parts by Margin of Failure lblUseDamageMargin.tooltip=PLACEHOLDER -lblDamageMargin.text=Margin +lblDamageMargin.text=Margin of Failure lblDamageMargin.tooltip=PLACEHOLDER lblDestroyPartTarget.text=Equipment hit in battle survive on a lblDestroyPartTarget.tooltip=PLACEHOLDER diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java index 92344e79a4..e088753221 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java @@ -2,6 +2,7 @@ import javax.swing.*; import javax.swing.GroupLayout.Alignment; +import java.awt.*; import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; @@ -120,7 +121,7 @@ JPanel createRepairTab() { getImageDirectory() + "logo_aurigan_coalition.png", true); // Era Mods - useEraModsCheckBox = new CampaignOptionsCheckBox("UseEraModsCheckBox"); + useEraModsCheckBox = new CampaignOptionsCheckBox("UseEraModsCheckBox"); // Tech Placement assignedTechFirstCheckBox = new CampaignOptionsCheckBox("AssignedTechFirstCheckBox"); @@ -144,49 +145,65 @@ JPanel createRepairTab() { lblDestroyPartTarget = new CampaignOptionsLabel("DestroyPartTarget"); spnDestroyPartTarget = new CampaignOptionsSpinner("DestroyPartTarget", 2, 2, 13, 1); - JLabel lblDestroyPartTargetPost = new JLabel("+"); // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("repairTab", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + final JPanel panelLeft = new CampaignOptionsStandardPanel("repairTabLeft"); + final GridBagConstraints layoutLeft = new CampaignOptionsGridBagConstraints(panelLeft); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(useEraModsCheckBox) - .addComponent(assignedTechFirstCheckBox) - .addComponent(resetToFirstTechCheckBox) - .addComponent(useQuirksBox) - .addComponent(useAeroSystemHitsBox) - .addComponent(useDamageMargin) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblDamageMargin) - .addComponent(spnDamageMargin)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblDestroyPartTarget) - .addComponent(spnDestroyPartTarget) - .addComponent(lblDestroyPartTargetPost))); + layoutLeft.gridx = 0; + layoutLeft.gridy = 0; + layoutLeft.gridwidth = 1; + panelLeft.add(useEraModsCheckBox, layoutLeft); - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(useEraModsCheckBox) - .addComponent(assignedTechFirstCheckBox) - .addComponent(resetToFirstTechCheckBox) - .addComponent(useQuirksBox) - .addComponent(useAeroSystemHitsBox) - .addComponent(useDamageMargin) - .addGroup(layout.createSequentialGroup() - .addComponent(lblDamageMargin) - .addComponent(spnDamageMargin)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblDestroyPartTarget) - .addComponent(spnDestroyPartTarget) - .addComponent(lblDestroyPartTargetPost))); + layoutLeft.gridy++; + panelLeft.add(assignedTechFirstCheckBox, layoutLeft); + + layoutLeft.gridy++; + panelLeft.add(resetToFirstTechCheckBox, layoutLeft); + + layoutLeft.gridy++; + panelLeft.add(useQuirksBox, layoutLeft); + + final JPanel panelRight = new CampaignOptionsStandardPanel("RepairTabRight", true, + "RepairTabRight"); + final GridBagConstraints layoutRight = new CampaignOptionsGridBagConstraints(panelRight); + + layoutRight.gridx = 0; + layoutRight.gridy = 0; + layoutRight.gridwidth = 1; + panelRight.add(useAeroSystemHitsBox, layoutRight); + + layoutRight.gridy++; + panelRight.add(useDamageMargin, layoutRight); + + layoutRight.gridy++; + panelRight.add(lblDamageMargin, layoutRight); + layoutRight.gridx++; + panelRight.add(spnDamageMargin, layoutRight); + + layoutRight.gridx = 0; + layoutRight.gridy++; + panelRight.add(lblDestroyPartTarget, layoutRight); + layoutRight.gridx++; + panelRight.add(spnDestroyPartTarget, layoutRight); + + final JPanel panelParent = new CampaignOptionsStandardPanel("RepairTab", true); + final GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panelParent); + + layoutParent.gridwidth = 5; + layoutParent.gridx = 0; + layoutParent.gridy = 0; + panelParent.add(headerPanel, layoutParent); + + layoutParent.gridy++; + layoutParent.gridwidth = 1; + panelParent.add(panelLeft, layoutParent); + + layoutParent.gridx++; + panelParent.add(panelRight, layoutParent); // Create Parent Panel and return - return createParentPanel(panel, "repairTab"); + return createParentPanel(panelParent, "repairTab"); } /** From c900b81d47349600e9f4c76db7ac03f3aee57fd6 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 16 Oct 2024 15:24:32 -0500 Subject: [PATCH 105/117] Refactor layout management for campaign options panels Reorganized the layout configurations in PersonnelTab, EquipmentAndSuppliesTab, and CampaignOptionsUtilities to improve code readability and maintainability. Adjusted the use of GridBagConstraints and other layout constraints to ensure consistent GUI element alignment and spacing. --- .../CampaignOptionsUtilities.java | 31 +++++------ .../EquipmentAndSuppliesTab.java | 55 +++++++++++-------- .../panes/campaignOptions/PersonnelTab.java | 13 ++++- 3 files changed, 57 insertions(+), 42 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java index 7533a0b77b..d124689932 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java @@ -355,21 +355,20 @@ public CampaignOptionsHeaderPanel(String name, String imageAddress, boolean incl // Layout panel new CampaignOptionsStandardPanel("pnl" + name + "HeaderPanel"); - final GroupLayout layout = createGroupLayout(this); - setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(lblHeader) - .addComponent(lblBody) - .addComponent(lblImage)); - - layout.setHorizontalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.LEADING) - .addComponent(lblHeader, Alignment.CENTER) - .addComponent(lblBody, Alignment.CENTER) - .addComponent(lblImage, Alignment.CENTER))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(this); + + layout.gridwidth = 5; + layout.gridx = 0; + layout.gridy = 0; + this.add(lblHeader, layout); + + layout.gridy++; + layout.gridwidth = 1; + this.add(lblBody, layout); + + layout.gridy++; + layout.gridwidth = 1; + this.add(lblImage, layout); } } @@ -418,7 +417,7 @@ public CampaignOptionsGridBagConstraints(JPanel panel, @Nullable Integer anchor, panel.setLayout(new GridBagLayout()); this.anchor = Objects.requireNonNullElse(anchor, GridBagConstraints.NORTHWEST); - this.fill = Objects.requireNonNullElse(fill, GridBagConstraints.NONE); + this.fill = Objects.requireNonNullElse(fill, GridBagConstraints.HORIZONTAL); this.insets = new Insets(5, 5, 5, 5); } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java index a06d29111d..dee0f525fc 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java @@ -238,7 +238,7 @@ JPanel createAcquisitionTab() { layoutParent.gridwidth = 1; panel.add(pnlAcquisitions, layoutParent); - layoutParent.gridy++; + layoutParent.gridx++; panel.add(pnlDeliveries, layoutParent); @@ -355,32 +355,39 @@ private JPanel createDeliveryPanel() { layoutTransit.gridx++; panelTransit.add(choiceTransitTimeUnits, layoutTransit); - final JPanel panel = new CampaignOptionsStandardPanel("DeliveryPanel", true, + // Layout the Panel + final JPanel panelDeliveries = new CampaignOptionsStandardPanel("DeliveryPanelDeliveries"); + final GridBagConstraints layoutDeliveries = new CampaignOptionsGridBagConstraints(panelDeliveries); + + layoutDeliveries.gridy = 0; + layoutDeliveries.gridx = 0; + layoutDeliveries.gridwidth = 1; + panelDeliveries.add(lblAcquireMosBonus, layoutDeliveries); + layoutDeliveries.gridx++; + panelDeliveries.add(spnAcquireMosBonus, layoutDeliveries); + layoutDeliveries.gridx++; + panelDeliveries.add(choiceAcquireMosUnits, layoutDeliveries); + + layoutDeliveries.gridx = 0; + layoutDeliveries.gridy++; + panelDeliveries.add(lblAcquireMinimum, layoutDeliveries); + layoutDeliveries.gridx++; + panelDeliveries.add(spnAcquireMinimum, layoutDeliveries); + layoutDeliveries.gridx++; + panelDeliveries.add(choiceAcquireMinimumUnit, layoutDeliveries); + + final JPanel panelParent = new CampaignOptionsStandardPanel("DeliveryPanel", true, "DeliveryPanel"); - final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); - - layout.gridy = 0; - layout.gridx = 0; - layout.gridwidth = 2; - panel.add(panelTransit, layout); - - layout.gridwidth = 1; - layout.gridy++; - panel.add(lblAcquireMosBonus, layout); - layout.gridx++; - panel.add(spnAcquireMosBonus, layout); - layout.gridx++; - panel.add(choiceAcquireMosUnits, layout); + final GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panelParent); - layout.gridx = 0; - layout.gridy++; - panel.add(lblAcquireMinimum, layout); - layout.gridx++; - panel.add(spnAcquireMinimum, layout); - layout.gridx++; - panel.add(choiceAcquireMinimumUnit, layout); + layoutParent.gridy = 0; + layoutParent.gridx = 0; + layoutParent.gridwidth = 2; + panelParent.add(panelTransit, layoutParent); + layoutParent.gridy++; + panelParent.add(panelDeliveries, layoutParent); - return panel; + return panelParent; } JPanel createPlanetaryAcquisitionTab() { diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java index e90ab5ffc5..aeab2a9fd3 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java @@ -373,7 +373,7 @@ JPanel createGeneralTab() { panelRight.add(pnlPersonnelCleanup, layoutRight); layoutRight.gridy++; - layoutRight.gridwidth = 1; panelRight.add(pnlAdministrators, layoutRight); + panelRight.add(pnlAdministrators, layoutRight); final JPanel panelParent = new CampaignOptionsStandardPanel("PersonnelGeneralTab", true); GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panelParent); @@ -466,17 +466,26 @@ private JPanel createPersonnelCleanUpPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("PersonnelCleanUpPanel", true, "PersonnelCleanUpPanel"); - final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel, null, GridBagConstraints.NONE); + layout.gridx = 0; layout.gridy = 0; layout.gridwidth = 1; panel.add(chkUsePersonnelRemoval, layout); + layout.gridx++; + panel.add(Box.createHorizontalStrut(UIUtil.scaleForGUI(35))); + layout.gridx = 0; layout.gridy++; panel.add(chkUseRemovalExemptCemetery, layout); + layout.gridx++; + panel.add(Box.createHorizontalStrut(UIUtil.scaleForGUI(35))); + layout.gridx = 0; layout.gridy++; panel.add(chkUseRemovalExemptRetirees, layout); + layout.gridx++; + panel.add(Box.createHorizontalStrut(UIUtil.scaleForGUI(35))); return panel; } From 02e021807917da088405276e7cee00dbf62e90f1 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 16 Oct 2024 15:42:12 -0500 Subject: [PATCH 106/117] Refactor RepairAndMaintenanceTab layout Replaced GroupLayout with GridBagLayout for improved readability and maintainability. This change also standardized the panel layout code and simplified adding components to the panel. --- .../RepairAndMaintenanceTab.java | 94 ++++++++----------- 1 file changed, 41 insertions(+), 53 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java index e088753221..917dfc39e2 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java @@ -1,7 +1,6 @@ package mekhq.gui.panes.campaignOptions; import javax.swing.*; -import javax.swing.GroupLayout.Alignment; import java.awt.*; import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; @@ -216,86 +215,75 @@ JPanel createMaintenanceTab() { JPanel headerPanel = new CampaignOptionsHeaderPanel("MaintenanceTab", getImageDirectory() + "logo_clan_blood_spirit.png", true); - // Check Maintenance + // Contents checkMaintenance = new CampaignOptionsCheckBox("CheckMaintenance"); - // Maintenance Cycle Duration lblMaintenanceDays = new CampaignOptionsLabel("MaintenanceDays"); spnDamageMargin = new CampaignOptionsSpinner("MaintenanceDays", 7, 1, 365, 1); - // Maintenance Bonus lblMaintenanceBonus = new CampaignOptionsLabel("MaintenanceBonus"); spnMaintenanceBonus = new CampaignOptionsSpinner("MaintenanceBonus", 0, -13, 13, 1); - // Default Maintenance Time lblDefaultMaintenanceTime = new CampaignOptionsLabel("DefaultMaintenanceTime"); spnDefaultMaintenanceTime = new CampaignOptionsSpinner("DefaultMaintenanceTime", 1, 1, 4, 1); - // Use Quality Modifiers useQualityMaintenance = new CampaignOptionsCheckBox("UseQualityMaintenance"); - // Reverse Quality names reverseQualityNames = new CampaignOptionsCheckBox("ReverseQualityNames"); - // Use Random Unit Qualities chkUseRandomUnitQualities = new CampaignOptionsCheckBox("UseRandomUnitQualities"); - // Use Planetary Modifiers chkUsePlanetaryModifiers = new CampaignOptionsCheckBox("UsePlanetaryModifiers"); - // Only Damage F-Rated Equipment useUnofficialMaintenance = new CampaignOptionsCheckBox("UseUnofficialMaintenance"); - // Report Maintenance checks to Log logMaintenance = new CampaignOptionsCheckBox("LogMaintenance"); // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("repairTab", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(checkMaintenance) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblMaintenanceDays) - .addComponent(spnMaintenanceDays)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblMaintenanceBonus) - .addComponent(spnMaintenanceBonus)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblDefaultMaintenanceTime) - .addComponent(spnDefaultMaintenanceTime)) - .addComponent(useQualityMaintenance) - .addComponent(reverseQualityNames) - .addComponent(chkUseRandomUnitQualities) - .addComponent(chkUsePlanetaryModifiers) - .addComponent(useUnofficialMaintenance) - .addComponent(logMaintenance)); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(checkMaintenance) - .addGroup(layout.createSequentialGroup() - .addComponent(lblMaintenanceDays) - .addComponent(spnMaintenanceDays)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblMaintenanceBonus) - .addComponent(spnMaintenanceBonus)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblDefaultMaintenanceTime) - .addComponent(spnDefaultMaintenanceTime)) - .addComponent(useQualityMaintenance) - .addComponent(reverseQualityNames) - .addComponent(chkUseRandomUnitQualities) - .addComponent(chkUsePlanetaryModifiers) - .addComponent(useUnofficialMaintenance) - .addComponent(logMaintenance)); + GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panel); + + layoutParent.gridwidth = 5; + layoutParent.gridy = 0; + panel.add(headerPanel, layoutParent); + + layoutParent.gridx = 0; + layoutParent.gridy++; + layoutParent.gridwidth = 1; + panel.add(checkMaintenance, layoutParent); + + layoutParent.gridy++; + panel.add(lblMaintenanceDays, layoutParent); + layoutParent.gridx++; + panel.add(spnDamageMargin, layoutParent); + + layoutParent.gridx = 0; + layoutParent.gridy++; + panel.add(lblDefaultMaintenanceTime, layoutParent); + layoutParent.gridx++; + panel.add(spnDefaultMaintenanceTime, layoutParent); + + layoutParent.gridx = 0; + layoutParent.gridy++; + panel.add(useQualityMaintenance, layoutParent); + + layoutParent.gridy++; + panel.add(reverseQualityNames, layoutParent); + + layoutParent.gridy++; + panel.add(chkUseRandomUnitQualities, layoutParent); + + layoutParent.gridy++; + panel.add(chkUseRandomUnitQualities, layoutParent); + + layoutParent.gridy++; + panel.add(chkUsePlanetaryModifiers, layoutParent); + + layoutParent.gridy++; + panel.add(useUnofficialMaintenance, layoutParent); // Create Parent Panel and return return createParentPanel(panel, "maintenanceTab"); From 7067d9a0e92c8d7b564da63ae1a27325b1737a6f Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 16 Oct 2024 15:45:51 -0500 Subject: [PATCH 107/117] Rename maintenance spinner variable Renamed `spnDamageMargin` to `spnMaintenanceDays` in `RepairAndMaintenanceTab.java` for clarity and consistency. Additionally, rearranged UI elements to properly display `spnMaintenanceDays` and added new maintenance logging component. --- .../campaignOptions/RepairAndMaintenanceTab.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java index 917dfc39e2..372a41369d 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java @@ -219,7 +219,7 @@ JPanel createMaintenanceTab() { checkMaintenance = new CampaignOptionsCheckBox("CheckMaintenance"); lblMaintenanceDays = new CampaignOptionsLabel("MaintenanceDays"); - spnDamageMargin = new CampaignOptionsSpinner("MaintenanceDays", + spnMaintenanceDays = new CampaignOptionsSpinner("MaintenanceDays", 7, 1, 365, 1); lblMaintenanceBonus = new CampaignOptionsLabel("MaintenanceBonus"); @@ -258,7 +258,12 @@ JPanel createMaintenanceTab() { layoutParent.gridy++; panel.add(lblMaintenanceDays, layoutParent); layoutParent.gridx++; - panel.add(spnDamageMargin, layoutParent); + panel.add(spnMaintenanceDays, layoutParent); + + layoutParent.gridy++; + panel.add(lblMaintenanceBonus, layoutParent); + layoutParent.gridx++; + panel.add(spnMaintenanceBonus, layoutParent); layoutParent.gridx = 0; layoutParent.gridy++; @@ -285,6 +290,9 @@ JPanel createMaintenanceTab() { layoutParent.gridy++; panel.add(useUnofficialMaintenance, layoutParent); + layoutParent.gridy++; + panel.add(logMaintenance, layoutParent); + // Create Parent Panel and return return createParentPanel(panel, "maintenanceTab"); } From bfc34dc1ddeade847ab2affd060bcf65e2d9bc43 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 16 Oct 2024 15:53:53 -0500 Subject: [PATCH 108/117] Fix layout issue in RepairAndMaintenanceTab Reset the gridx value before adding lblMaintenanceBonus. This ensured that the layout of the panel elements aligned correctly, avoiding UI misalignment in the campaign options. --- .../mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java | 1 + 1 file changed, 1 insertion(+) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java index 372a41369d..72f0961533 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java @@ -260,6 +260,7 @@ JPanel createMaintenanceTab() { layoutParent.gridx++; panel.add(spnMaintenanceDays, layoutParent); + layoutParent.gridx = 0; layoutParent.gridy++; panel.add(lblMaintenanceBonus, layoutParent); layoutParent.gridx++; From 6b27cc4a6950338c5b1f14ac75ca47b179b71ba5 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 16 Oct 2024 18:37:15 -0500 Subject: [PATCH 109/117] Switch to GridBagLayout in FinancesTab.java Replaced GroupLayout with GridBagLayout in various panels within FinancesTab.java for improved layout management. Adjusted the positions and alignments of UI components to maintain the visual structure. Updated properties file for Strategic Operations tab title. --- .../NEWCampaignOptionsDialog.properties | 2 +- .../panes/campaignOptions/FinancesTab.java | 476 ++++++++---------- 2 files changed, 205 insertions(+), 273 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 4669e085cf..604775ecbc 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -15,7 +15,7 @@ generalPanel.title=General Information humanResourcesParentTab.title=Human Resources unitDevelopmentParentTab.title=Unit Development logisticsAndMaintenanceParentTab.title=Logistics -strategicOperationsParentTab.title=Strategic Operations +strategicOperationsParentTab.title=Operations ## General Tab Class diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/FinancesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/FinancesTab.java index 42b5e00787..cd41a15b13 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/FinancesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/FinancesTab.java @@ -1,15 +1,14 @@ package mekhq.gui.panes.campaignOptions; import megamek.client.ui.baseComponents.MMComboBox; -import megamek.client.ui.swing.util.UIUtil; import mekhq.campaign.Campaign; import mekhq.campaign.finances.enums.FinancialYearDuration; import mekhq.campaign.parts.Part; import javax.swing.*; -import javax.swing.GroupLayout.Alignment; import javax.swing.JSpinner.DefaultEditor; import javax.swing.JSpinner.NumberEditor; +import java.awt.*; import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; @@ -188,34 +187,40 @@ JPanel createFinancesGeneralOptionsTab() { // Contents pnlGeneralOptions = createGeneralOptionsPanel(); + pnlOtherSystems = createOtherSystemsPanel(); + pnlPayments = createPaymentsPanel(); pnlSales = createSalesPanel(); - pnlOtherSystems = createOtherSystemsPanel(); - // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("FinancesGeneralTab", true, - ""); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(pnlGeneralOptions) - .addComponent(pnlOtherSystems)) - .addComponent(pnlSales) - .addComponent(pnlPayments)); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addGroup(layout.createSequentialGroup() - .addComponent(pnlGeneralOptions) - .addComponent(pnlOtherSystems)) - .addComponent(pnlSales) - .addComponent(pnlPayments)); + final JPanel panelTransactions = new CampaignOptionsStandardPanel("FinancesGeneralTabTransactions"); + GridBagConstraints layoutTransactions = new CampaignOptionsGridBagConstraints(panelTransactions); + + layoutTransactions.gridwidth = 2; + layoutTransactions.gridy = 0; + layoutTransactions.gridx = 0; + panelTransactions.add(pnlPayments, layoutTransactions); + layoutTransactions.gridx += 2; + panelTransactions.add(pnlSales, layoutTransactions); + + final JPanel panel = new CampaignOptionsStandardPanel("FinancesGeneralTab", true); + GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panel); + + layoutParent.gridwidth = 5; + layoutParent.gridy = 0; + panel.add(headerPanel, layoutParent); + + layoutParent.gridx = 0; + layoutParent.gridy++; + layoutParent.gridwidth = 1; + panel.add(pnlGeneralOptions, layoutParent); + layoutParent.gridx++; + panel.add(pnlOtherSystems, layoutParent); + + layoutParent.gridwidth = 2; + layoutParent.gridx = 0; + layoutParent.gridy++; + panel.add(panelTransactions, layoutParent); // Create Parent Panel and return return createParentPanel(panel, "FinancesGeneralTab"); @@ -242,41 +247,32 @@ private JPanel createPaymentsPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("PaymentsPanel", true, "PaymentsPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(payForPartsBox) - .addComponent(payForRepairsBox) - .addComponent(payForUnitsBox) - .addComponent(payForSalariesBox)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(payForOverheadBox) - .addComponent(payForMaintainBox) - .addComponent(payForTransportBox) - .addComponent(payForRecruitmentBox))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(payForPartsBox) - .addGap(UIUtil.scaleForGUI(5)) - .addComponent(payForRepairsBox) - .addGap(UIUtil.scaleForGUI(5)) - .addComponent(payForUnitsBox) - .addGap(UIUtil.scaleForGUI(5)) - .addComponent(payForSalariesBox)) - .addGap(UIUtil.scaleForGUI(5)) - .addGroup(layout.createSequentialGroup() - .addComponent(payForOverheadBox) - .addGap(UIUtil.scaleForGUI(5)) - .addComponent(payForMaintainBox) - .addGap(UIUtil.scaleForGUI(5)) - .addComponent(payForTransportBox) - .addGap(UIUtil.scaleForGUI(5)) - .addComponent(payForRecruitmentBox))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 1; + panel.add(payForPartsBox, layout); + layout.gridx++; + panel.add(payForRepairsBox, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(payForUnitsBox, layout); + layout.gridx++; + panel.add(payForSalariesBox, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(payForOverheadBox, layout); + layout.gridx++; + panel.add(payForMaintainBox, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(payForTransportBox, layout); + layout.gridx++; + panel.add(payForRecruitmentBox, layout); return panel; } @@ -294,18 +290,15 @@ private JPanel createOtherSystemsPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("OtherSystemsPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(pnlTaxes) - .addComponent(pnlShares)); + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 1; + panel.add(pnlTaxes, layout); - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(pnlTaxes) - .addComponent(pnlShares)); + layout.gridy++; + panel.add(pnlShares, layout); return panel; } @@ -331,33 +324,42 @@ private JPanel createGeneralOptionsPanel() { newFinancialYearFinancesToCSVExportBox = new CampaignOptionsCheckBox("NewFinancialYearFinancesToCSVExportBox"); // Layout the Panel + final JPanel panelFinancialDuration = new CampaignOptionsStandardPanel("GeneralOptionsPanelFinancialDuration"); + final GridBagConstraints layoutFinancialDuration = new CampaignOptionsGridBagConstraints(panelFinancialDuration); + + layoutFinancialDuration.gridx = 0; + layoutFinancialDuration.gridy = 0; + layoutFinancialDuration.gridwidth = 1; + panelFinancialDuration.add(lblFinancialYearDuration, layoutFinancialDuration); + layoutFinancialDuration.gridx++; + panelFinancialDuration.add(comboFinancialYearDuration, layoutFinancialDuration); + final JPanel panel = new CampaignOptionsStandardPanel("GeneralOptionsPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(useLoanLimitsBox) - .addComponent(usePercentageMaintenanceBox) - .addComponent(useExtendedPartsModifierBox) - .addComponent(usePeacetimeCostBox) - .addComponent(showPeacetimeCostBox) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblFinancialYearDuration) - .addComponent(comboFinancialYearDuration)) - .addComponent(newFinancialYearFinancesToCSVExportBox)); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(useLoanLimitsBox) - .addComponent(usePercentageMaintenanceBox) - .addComponent(useExtendedPartsModifierBox) - .addComponent(usePeacetimeCostBox) - .addComponent(showPeacetimeCostBox) - .addGroup(layout.createSequentialGroup() - .addComponent(lblFinancialYearDuration) - .addComponent(comboFinancialYearDuration)) - .addComponent(newFinancialYearFinancesToCSVExportBox)); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 1; + panel.add(useLoanLimitsBox, layout); + + layout.gridy++; + panel.add(usePercentageMaintenanceBox, layout); + + layout.gridy++; + panel.add(useExtendedPartsModifierBox, layout); + + layout.gridy++; + panel.add(usePeacetimeCostBox, layout); + + layout.gridy++; + panel.add(showPeacetimeCostBox, layout); + + layout.gridy++; + panel.add(panelFinancialDuration, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(newFinancialYearFinancesToCSVExportBox, layout); return panel; } @@ -377,21 +379,15 @@ private JPanel createSalesPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("SalesPanel", true, "SalesPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(sellUnitsBox) - .addComponent(sellPartsBox))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(sellUnitsBox) - .addGap(UIUtil.scaleForGUI(5)) - .addComponent(sellPartsBox))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 1; + panel.add(sellUnitsBox, layout); + + layout.gridy++; + panel.add(sellPartsBox, layout); return panel; } @@ -415,22 +411,17 @@ private JPanel createTaxesPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("TaxesPanel", true, "TaxesPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(chkUseTaxes) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblTaxesPercentage) - .addComponent(spnTaxesPercentage))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(chkUseTaxes) - .addGroup(layout.createSequentialGroup() - .addComponent(lblTaxesPercentage) - .addComponent(spnTaxesPercentage))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 1; + panel.add(chkUseTaxes, layout); + + layout.gridy++; + panel.add(lblTaxesPercentage, layout); + layout.gridx++; + panel.add(spnTaxesPercentage, layout); return panel; } @@ -450,18 +441,15 @@ private JPanel createSharesPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("SharesPanel", true, "SharesPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(chkUseShareSystem) - .addComponent(chkSharesForAll)); + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 1; + panel.add(chkUseShareSystem, layout); - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(chkUseShareSystem) - .addComponent(chkSharesForAll)); + layout.gridy++; + panel.add(chkSharesForAll, layout); return panel; } @@ -520,26 +508,21 @@ JPanel createPriceMultipliersTab() { pnlOtherMultipliers = createOtherMultipliersPanel(); // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("PriceMultipliersTab", true, - ""); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(pnlGeneralMultipliers) - .addComponent(pnlUsedPartsMultipliers) - .addComponent(pnlOtherMultipliers))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addGroup(layout.createSequentialGroup() - .addComponent(pnlGeneralMultipliers) - .addComponent(pnlUsedPartsMultipliers) - .addComponent(pnlOtherMultipliers))); + final JPanel panel = new CampaignOptionsStandardPanel("PriceMultipliersTab", true); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridwidth = 5; + layout.gridx = 0; + layout.gridy = 0; + panel.add(headerPanel, layout); + + layout.gridy++; + layout.gridwidth = 1; + panel.add(pnlGeneralMultipliers, layout); + layout.gridx++; + panel.add(pnlUsedPartsMultipliers, layout); + layout.gridx++; + panel.add(pnlOtherMultipliers, layout); // Create Parent Panel and return return createParentPanel(panel, "PriceMultipliersTab"); @@ -582,50 +565,38 @@ private JPanel createGeneralMultipliersPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("GeneralMultipliersPanel", true, "GeneralMultipliersPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblCommonPartPriceMultiplier) - .addComponent(spnCommonPartPriceMultiplier)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblInnerSphereUnitPriceMultiplier) - .addComponent(spnInnerSphereUnitPriceMultiplier)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblInnerSpherePartPriceMultiplier) - .addComponent(spnInnerSpherePartPriceMultiplier)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblClanUnitPriceMultiplier) - .addComponent(spnClanUnitPriceMultiplier)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblClanPartPriceMultiplier) - .addComponent(spnClanPartPriceMultiplier)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblMixedTechUnitPriceMultiplier) - .addComponent(spnMixedTechUnitPriceMultiplier))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblCommonPartPriceMultiplier) - .addComponent(spnCommonPartPriceMultiplier)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblInnerSphereUnitPriceMultiplier) - .addComponent(spnInnerSphereUnitPriceMultiplier)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblInnerSpherePartPriceMultiplier) - .addComponent(spnInnerSpherePartPriceMultiplier)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblClanUnitPriceMultiplier) - .addComponent(spnClanUnitPriceMultiplier)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblClanPartPriceMultiplier) - .addComponent(spnClanPartPriceMultiplier)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblMixedTechUnitPriceMultiplier) - .addComponent(spnMixedTechUnitPriceMultiplier))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 1; + panel.add(lblCommonPartPriceMultiplier, layout); + layout.gridx++; + panel.add(spnCommonPartPriceMultiplier, layout); + layout.gridx++; + panel.add(lblMixedTechUnitPriceMultiplier, layout); + layout.gridx++; + panel.add(spnMixedTechUnitPriceMultiplier, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblInnerSphereUnitPriceMultiplier, layout); + layout.gridx++; + panel.add(spnInnerSphereUnitPriceMultiplier, layout); + layout.gridx++; + panel.add(lblInnerSpherePartPriceMultiplier, layout); + layout.gridx++; + panel.add(spnInnerSpherePartPriceMultiplier, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblClanUnitPriceMultiplier, layout); + layout.gridx++; + panel.add(spnClanUnitPriceMultiplier, layout); + layout.gridx++; + panel.add(lblClanPartPriceMultiplier, layout); + layout.gridx++; + panel.add(spnClanPartPriceMultiplier, layout); return panel; } @@ -674,50 +645,17 @@ private JPanel createUsedPartsMultiplierPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("UsedPartsMultiplierPanel", true, "UsedPartsMultiplierPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblUsedPartPriceMultipliers[0]) - .addComponent(spnUsedPartPriceMultipliers[0])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblUsedPartPriceMultipliers[1]) - .addComponent(spnUsedPartPriceMultipliers[1])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblUsedPartPriceMultipliers[2]) - .addComponent(spnUsedPartPriceMultipliers[2])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblUsedPartPriceMultipliers[3]) - .addComponent(spnUsedPartPriceMultipliers[3])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblUsedPartPriceMultipliers[4]) - .addComponent(spnUsedPartPriceMultipliers[4])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblUsedPartPriceMultipliers[5]) - .addComponent(spnUsedPartPriceMultipliers[5]))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblUsedPartPriceMultipliers[0]) - .addComponent(spnUsedPartPriceMultipliers[0])) - .addGroup(layout.createSequentialGroup() - .addComponent(lblUsedPartPriceMultipliers[1]) - .addComponent(spnUsedPartPriceMultipliers[1])) - .addGroup(layout.createSequentialGroup() - .addComponent(lblUsedPartPriceMultipliers[2]) - .addComponent(spnUsedPartPriceMultipliers[2])) - .addGroup(layout.createSequentialGroup() - .addComponent(lblUsedPartPriceMultipliers[3]) - .addComponent(spnUsedPartPriceMultipliers[3])) - .addGroup(layout.createSequentialGroup() - .addComponent(lblUsedPartPriceMultipliers[4]) - .addComponent(spnUsedPartPriceMultipliers[4])) - .addGroup(layout.createSequentialGroup() - .addComponent(lblUsedPartPriceMultipliers[5]) - .addComponent(spnUsedPartPriceMultipliers[5]))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridwidth = 1; + + for (int i = 0; i < 6; i++) { + layout.gridx = 0; + layout.gridy = i; + panel.add(lblUsedPartPriceMultipliers[i], layout); + layout.gridx++; + panel.add(spnUsedPartPriceMultipliers[i], layout); + } return panel; } @@ -751,32 +689,26 @@ private JPanel createOtherMultipliersPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("OtherMultipliersPanel", true, "OtherMultipliersPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblDamagedPartsValueMultiplier) - .addComponent(spnDamagedPartsValueMultiplier)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblUnrepairablePartsValueMultiplier) - .addComponent(spnUnrepairablePartsValueMultiplier)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblCancelledOrderRefundMultiplier) - .addComponent(spnCancelledOrderRefundMultiplier))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblDamagedPartsValueMultiplier) - .addComponent(spnDamagedPartsValueMultiplier)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblUnrepairablePartsValueMultiplier) - .addComponent(spnUnrepairablePartsValueMultiplier)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblCancelledOrderRefundMultiplier) - .addComponent(spnCancelledOrderRefundMultiplier))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 1; + panel.add(lblDamagedPartsValueMultiplier, layout); + layout.gridx++; + panel.add(spnDamagedPartsValueMultiplier, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblUnrepairablePartsValueMultiplier, layout); + layout.gridx++; + panel.add(spnUnrepairablePartsValueMultiplier, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblCancelledOrderRefundMultiplier, layout); + layout.gridx++; + panel.add(spnCancelledOrderRefundMultiplier, layout); return panel; } From 1ac79c084b02fb2b1a124147ec71d90e76f0b2e1 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 16 Oct 2024 18:59:50 -0500 Subject: [PATCH 110/117] Switch to GridBagLayout for market options panels Replaced GroupLayout with GridBagLayout in `MarketsTab` and related panels. Simplified the layout management, making the panels more flexible and easier to maintain. Adjusted constraints and component placements to ensure a consistent user interface. --- .../gui/panes/campaignOptions/MarketsTab.java | 485 ++++++++---------- 1 file changed, 219 insertions(+), 266 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/MarketsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/MarketsTab.java index 5ddecc56d9..b5e627e358 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/MarketsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/MarketsTab.java @@ -1,7 +1,6 @@ package mekhq.gui.panes.campaignOptions; import megamek.client.ui.baseComponents.MMComboBox; -import megamek.client.ui.swing.util.UIUtil; import megamek.common.enums.SkillLevel; import mekhq.campaign.campaignOptions.CampaignOptions; import mekhq.campaign.market.enums.ContractMarketMethod; @@ -11,8 +10,8 @@ import mekhq.module.api.PersonnelMarketMethod; import javax.swing.*; -import javax.swing.GroupLayout.Alignment; import javax.swing.JSpinner.DefaultEditor; +import java.awt.*; import java.util.HashMap; import java.util.Map; @@ -129,25 +128,22 @@ JPanel createPersonnelMarketTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("PersonnelMarketTab", true, ""); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(pnlPersonnelMarketGeneralOptions) - .addComponent(pnlRemovalTargets))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addGroup(layout.createSequentialGroup() - .addComponent(pnlPersonnelMarketGeneralOptions) - .addComponent(pnlRemovalTargets))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridwidth = 5; + layout.gridx = 0; + layout.gridy = 0; + panel.add(headerPanel, layout); + + layout.gridy++; + layout.gridwidth = 1; + panel.add(pnlPersonnelMarketGeneralOptions, layout); + layout.gridx++; + panel.add(pnlRemovalTargets, layout); // Create Parent Panel and return return createParentPanel(panel, "PersonnelMarketTab"); + } private JPanel createPersonnelMarketGeneralOptionsPanel() { @@ -167,30 +163,27 @@ private JPanel createPersonnelMarketGeneralOptionsPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("PersonnelMarketGeneralOptionsPanel", false, ""); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPersonnelMarketType) - .addComponent(comboPersonnelMarketType)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPersonnelMarketDylansWeight) - .addComponent(spnPersonnelMarketDylansWeight)) - .addComponent(chkPersonnelMarketReportRefresh) - .addComponent(chkUsePersonnelHireHiringHallOnly)); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPersonnelMarketType) - .addComponent(comboPersonnelMarketType)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblPersonnelMarketDylansWeight) - .addComponent(spnPersonnelMarketDylansWeight)) - .addComponent(chkPersonnelMarketReportRefresh) - .addComponent(chkUsePersonnelHireHiringHallOnly)); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 1; + panel.add(lblPersonnelMarketType, layout); + layout.gridx++; + panel.add(comboPersonnelMarketType, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblPersonnelMarketDylansWeight, layout); + layout.gridx++; + panel.add(spnPersonnelMarketDylansWeight, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkPersonnelMarketReportRefresh, layout); + + layout.gridy++; + panel.add(chkUsePersonnelHireHiringHallOnly, layout); return panel; } @@ -211,92 +204,52 @@ private JPanel createPersonnelMarketRemovalOptionsPanel() { } // Layout the Panels - final JPanel leftPanel = new CampaignOptionsStandardPanel("LeftPanel"); - final GroupLayout leftLayout = createGroupLayout(leftPanel); - leftPanel.setLayout(leftLayout); - - leftLayout.setVerticalGroup( - leftLayout.createSequentialGroup() - .addGroup(leftLayout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.NONE)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.NONE))) - .addGroup(leftLayout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.ULTRA_GREEN)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.ULTRA_GREEN))) - .addGroup(leftLayout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.GREEN)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.GREEN))) - .addGroup(leftLayout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.REGULAR)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.REGULAR)))); - - leftLayout.setHorizontalGroup( - leftLayout.createParallelGroup(Alignment.LEADING) - .addGroup(leftLayout.createSequentialGroup() - .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.NONE)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.NONE))) - .addGroup(leftLayout.createSequentialGroup() - .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.ULTRA_GREEN)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.ULTRA_GREEN))) - .addGroup(leftLayout.createSequentialGroup() - .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.GREEN)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.GREEN))) - .addGroup(leftLayout.createSequentialGroup() - .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.REGULAR)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.REGULAR)))); - - final JPanel rightPanel = new CampaignOptionsStandardPanel("RightPanel"); - final GroupLayout rightLayout = createGroupLayout(rightPanel); - rightPanel.setLayout(rightLayout); - - rightLayout.setVerticalGroup( - rightLayout.createSequentialGroup() - .addGroup(rightLayout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.VETERAN)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.VETERAN))) - .addGroup(rightLayout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.ELITE)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.ELITE))) - .addGroup(rightLayout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.HEROIC)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.HEROIC))) - .addGroup(rightLayout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.LEGENDARY)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.LEGENDARY)))); - - rightLayout.setHorizontalGroup( - rightLayout.createParallelGroup(Alignment.LEADING) - .addGroup(rightLayout.createSequentialGroup() - .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.VETERAN)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.VETERAN))) - .addGroup(rightLayout.createSequentialGroup() - .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.ELITE)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.ELITE))) - .addGroup(rightLayout.createSequentialGroup() - .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.HEROIC)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.HEROIC))) - .addGroup(rightLayout.createSequentialGroup() - .addComponent(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.LEGENDARY)) - .addComponent(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.LEGENDARY)))); - - final JPanel parentPanel = new CampaignOptionsStandardPanel("PersonnelMarketRemovalOptionsPanel", + final JPanel panel = new CampaignOptionsStandardPanel("PersonnelMarketRemovalOptionsPanel", true, "PersonnelMarketRemovalOptionsPanel"); - final GroupLayout parentLayout = createGroupLayout(parentPanel); - parentPanel.setLayout(parentLayout); - - parentLayout.setVerticalGroup( - parentLayout.createSequentialGroup() - .addGroup(parentLayout.createParallelGroup(Alignment.BASELINE) - .addComponent(leftPanel) - .addComponent(rightPanel))); - - parentLayout.setHorizontalGroup( - parentLayout.createParallelGroup(Alignment.LEADING) - .addGroup(parentLayout.createSequentialGroup() - .addComponent(leftPanel) - .addComponent(rightPanel))); - - return parentPanel; + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 1; + panel.add(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.NONE), layout); + layout.gridx++; + panel.add(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.NONE), layout); + layout.gridx++; + panel.add(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.VETERAN), layout); + layout.gridx++; + panel.add(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.VETERAN), layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.ULTRA_GREEN), layout); + layout.gridx++; + panel.add(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.ULTRA_GREEN), layout); + layout.gridx++; + panel.add(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.ELITE), layout); + layout.gridx++; + panel.add(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.ELITE), layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.GREEN), layout); + layout.gridx++; + panel.add(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.GREEN), layout); + layout.gridx++; + panel.add(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.HEROIC), layout); + layout.gridx++; + panel.add(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.HEROIC), layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.REGULAR), layout); + layout.gridx++; + panel.add(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.REGULAR), layout); + layout.gridx++; + panel.add(lblPersonnelMarketRandomRemovalTargets.get(SkillLevel.LEGENDARY), layout); + layout.gridx++; + panel.add(spnPersonnelMarketRandomRemovalTargets.get(SkillLevel.LEGENDARY), layout); + + return panel; } private void initializeUnitMarket() { @@ -338,40 +291,40 @@ JPanel createUnitMarketTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("UnitMarketTab", true, ""); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblUnitMarketMethod) - .addComponent(comboUnitMarketMethod)) - .addComponent(chkUnitMarketRegionalMekVariations) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblUnitMarketSpecialUnitChance) - .addComponent(spnUnitMarketSpecialUnitChance)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblUnitMarketRarityModifier) - .addComponent(spnUnitMarketRarityModifier)) - .addComponent(chkInstantUnitMarketDelivery) - .addComponent(chkUnitMarketReportRefresh)); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addGroup(layout.createSequentialGroup() - .addComponent(lblUnitMarketMethod) - .addComponent(comboUnitMarketMethod)) - .addComponent(chkUnitMarketRegionalMekVariations) - .addGroup(layout.createSequentialGroup() - .addComponent(lblUnitMarketSpecialUnitChance) - .addComponent(spnUnitMarketSpecialUnitChance)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblUnitMarketRarityModifier) - .addComponent(spnUnitMarketRarityModifier)) - .addComponent(chkInstantUnitMarketDelivery) - .addComponent(chkUnitMarketReportRefresh)); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridwidth = 5; + layout.gridy = 0; + panel.add(headerPanel, layout); + + layout.gridwidth = 1; + layout.gridx = 0; + layout.gridy++; + panel.add(lblUnitMarketMethod, layout); + layout.gridx++; + panel.add(comboUnitMarketMethod, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkUnitMarketRegionalMekVariations, layout); + + layout.gridy++; + panel.add(lblUnitMarketSpecialUnitChance, layout); + layout.gridx++; + panel.add(spnUnitMarketSpecialUnitChance, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblUnitMarketRarityModifier, layout); + layout.gridx++; + panel.add(spnUnitMarketRarityModifier, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkInstantUnitMarketDelivery, layout); + + layout.gridy++; + panel.add(chkUnitMarketReportRefresh, layout); // Create Parent Panel and return return createParentPanel(panel, "UnitMarketTab"); @@ -422,22 +375,18 @@ JPanel createContractMarketTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("ContractMarketTab", true, ""); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(pnlContractMarketGeneralOptions) - .addComponent(pnlContractPay))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addGroup(layout.createSequentialGroup() - .addComponent(pnlContractMarketGeneralOptions) - .addComponent(pnlContractPay))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridwidth = 5; + layout.gridx = 0; + layout.gridy = 0; + panel.add(headerPanel, layout); + + layout.gridy++; + layout.gridwidth = 1; + panel.add(pnlContractMarketGeneralOptions, layout); + layout.gridx++; + panel.add(pnlContractPay, layout); // Create Parent Panel and return return createParentPanel(panel, "ContractMarketTab"); @@ -467,42 +416,38 @@ private JPanel createContractMarketGeneralOptionsPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("ContractMarketGeneralOptionsPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblContractMarketMethod) - .addComponent(comboContractMarketMethod)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblContractSearchRadius) - .addComponent(spnContractSearchRadius)) - .addComponent(chkVariableContractLength) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblCoontractMaxSalvagePercentage) - .addComponent(spnContractMaxSalvagePercentage)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblDropShipBonusPercentage) - .addComponent(spnDropShipBonusPercentage)) - .addComponent(chkContractMarketReportRefresh)); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblContractMarketMethod) - .addComponent(comboContractMarketMethod)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblContractSearchRadius) - .addComponent(spnContractSearchRadius)) - .addComponent(chkVariableContractLength) - .addGroup(layout.createSequentialGroup() - .addComponent(lblCoontractMaxSalvagePercentage) - .addComponent(spnContractMaxSalvagePercentage)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblDropShipBonusPercentage) - .addComponent(spnDropShipBonusPercentage)) - .addComponent(chkContractMarketReportRefresh)); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 1; + panel.add(lblContractMarketMethod, layout); + layout.gridx++; + panel.add(comboContractMarketMethod, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblContractSearchRadius, layout); + layout.gridx++; + panel.add(spnContractSearchRadius, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkVariableContractLength, layout); + + layout.gridy++; + panel.add(chkContractMarketReportRefresh, layout); + + layout.gridy++; + panel.add(lblCoontractMaxSalvagePercentage, layout); + layout.gridx++; + panel.add(spnContractMaxSalvagePercentage, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblDropShipBonusPercentage, layout); + layout.gridx++; + panel.add(spnDropShipBonusPercentage, layout); return panel; } @@ -536,66 +481,74 @@ private JPanel createContractPayPanel() { chkBLCSaleValue = new CampaignOptionsCheckBox("BLCSaleValue"); useInfantryDoseNotCountBox = new CampaignOptionsCheckBox("UseInfantryDoseNotCountBox"); + chkMercSizeLimited = new CampaignOptionsCheckBox("MercSizeLimited"); chkOverageRepaymentInFinalPayment = new CampaignOptionsCheckBox("OverageRepaymentInFinalPayment"); // Layout the Panel + final JPanel panelValuePercent = new CampaignOptionsStandardPanel("ContractPayPanelValuePercent", + false); + final GridBagConstraints layoutValuePercent = new CampaignOptionsGridBagConstraints(panelValuePercent); + + layoutValuePercent.gridx = 0; + layoutValuePercent.gridy = 0; + layoutValuePercent.gridwidth = 1; + panelValuePercent.add(chkEquipContractSaleValue, layoutValuePercent); + + layoutValuePercent.gridy++; + panelValuePercent.add(lblEquipPercent, layoutValuePercent); + layoutValuePercent.gridx++; + panelValuePercent.add(spnEquipPercent, layoutValuePercent); + + layoutValuePercent.gridx = 0; + layoutValuePercent.gridy++; + panelValuePercent.add(lblDropShipPercent, layoutValuePercent); + layoutValuePercent.gridx++; + panelValuePercent.add(spnDropShipPercent, layoutValuePercent); + + layoutValuePercent.gridx = 0; + layoutValuePercent.gridy++; + panelValuePercent.add(lblJumpShipPercent, layoutValuePercent); + layoutValuePercent.gridx++; + panelValuePercent.add(spnJumpShipPercent, layoutValuePercent); + + layoutValuePercent.gridx = 0; + layoutValuePercent.gridy++; + panelValuePercent.add(lblWarShipPercent, layoutValuePercent); + layoutValuePercent.gridx++; + panelValuePercent.add(spnWarShipPercent, layoutValuePercent); + final JPanel panel = new CampaignOptionsStandardPanel("ContractPayPanel", true, "ContractPayPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(btnContractEquipment) - .addComponent(chkEquipContractSaleValue) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblEquipPercent) - .addComponent(spnEquipPercent)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblDropShipPercent) - .addComponent(spnDropShipPercent)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblJumpShipPercent) - .addComponent(spnJumpShipPercent)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblWarShipPercent) - .addComponent(spnWarShipPercent)) - .addComponent(btnContractPersonnel) - .addGap(UIUtil.scaleForGUI(15)) - .addComponent(chkBLCSaleValue) - .addComponent(useInfantryDoseNotCountBox) - .addComponent(chkMercSizeLimited) - .addComponent(chkOverageRepaymentInFinalPayment)); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(btnContractEquipment) - .addGroup(layout.createSequentialGroup() - .addGap(UIUtil.scaleForGUI(25)) - .addComponent(chkEquipContractSaleValue)) - .addGroup(layout.createSequentialGroup() - .addGap(UIUtil.scaleForGUI(25)) - .addComponent(lblEquipPercent) - .addComponent(spnEquipPercent)) - .addGroup(layout.createSequentialGroup() - .addGap(UIUtil.scaleForGUI(25)) - .addComponent(lblDropShipPercent) - .addComponent(spnDropShipPercent)) - .addGroup(layout.createSequentialGroup() - .addGap(UIUtil.scaleForGUI(25)) - .addComponent(lblJumpShipPercent) - .addComponent(spnJumpShipPercent)) - .addGroup(layout.createSequentialGroup() - .addGap(UIUtil.scaleForGUI(25)) - .addComponent(lblWarShipPercent) - .addComponent(spnWarShipPercent)) - .addComponent(btnContractPersonnel) - .addComponent(chkBLCSaleValue) - .addComponent(useInfantryDoseNotCountBox) - .addComponent(chkMercSizeLimited) - .addComponent(chkOverageRepaymentInFinalPayment)); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 1; + panel.add(btnContractEquipment, layout); + + layout.gridy++; + panel.add(panelValuePercent, layout); + + layout.gridy++; + panel.add(btnContractPersonnel, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkBLCSaleValue, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(useInfantryDoseNotCountBox, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkMercSizeLimited, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(chkOverageRepaymentInFinalPayment, layout); return panel; } From 14f643c7eab11f611e89ede5d7274dd945528ee9 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 16 Oct 2024 20:28:24 -0500 Subject: [PATCH 111/117] Standardize GridBagLayout usage Revised layout configurations to consistently use GridBagLayout across various campaign options tabs. This ensures uniformity in the layout management and improves maintainability of the UI code. --- .../panes/campaignOptions/BiographyTab.java | 6 +- .../EquipmentAndSuppliesTab.java | 4 + .../panes/campaignOptions/FinancesTab.java | 21 +- .../gui/panes/campaignOptions/MarketsTab.java | 6 + .../panes/campaignOptions/PersonnelTab.java | 2 + .../campaignOptions/RelationshipsTab.java | 8 +- .../RepairAndMaintenanceTab.java | 95 +-- .../panes/campaignOptions/RulesetsTab.java | 559 +++++++++--------- .../TurnoverAndRetentionTab.java | 12 +- 9 files changed, 368 insertions(+), 345 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java index 9b9074f84d..e5c6dd22a7 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/BiographyTab.java @@ -712,9 +712,11 @@ public Component getListCellRendererComponent(final JList list, final Object layoutLeft.gridy = 0; layoutLeft.gridx = 0; - layoutLeft.gridwidth = 1; + layoutLeft.gridwidth = 2; panelLeft.add(chkKeepMarriedNameUponSpouseDeath, layoutLeft); + layoutLeft.gridy++; + layoutLeft.gridwidth = 1; panelLeft.add(lblRandomDeathMethod, layoutLeft); layoutLeft.gridx++; panelLeft.add(comboRandomDeathMethod, layoutLeft); @@ -967,9 +969,11 @@ private JPanel createXpAndSkillBonusesPanel() { layout.gridx = 0; layout.gridy = 0; + layout.gridwidth = 2; panel.add(chkEnableBonuses, layout); layout.gridy++; + layout.gridwidth = 1; panel.add(lblFacultyXpMultiplier, layout); layout.gridx++; panel.add(spnFacultyXpMultiplier, layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java index dee0f525fc..918b28510f 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/EquipmentAndSuppliesTab.java @@ -287,10 +287,12 @@ private JPanel createAcquisitionPanel() { layout.gridx = 0; layout.gridy++; + layout.gridwidth = 2; panel.add(chkSupportStaffOnly, layout); layout.gridx = 0; layout.gridy++; + layout.gridwidth = 1; panel.add(lblAcquireClanPenalty, layout); layout.gridx++; panel.add(spnAcquireClanPenalty, layout); @@ -468,6 +470,7 @@ private JPanel createOptionsPanel() { layout.gridx = 0; layout.gridy++; + layout.gridwidth = 2; panel.add(disallowPlanetaryAcquisitionClanCrossover, layout); layout.gridy++; @@ -475,6 +478,7 @@ private JPanel createOptionsPanel() { layout.gridx = 0; layout.gridy++; + layout.gridwidth = 1; panel.add(lblPenaltyClanPartsFromIS, layout); layout.gridx++; panel.add(spnPenaltyClanPartsFromIS, layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/FinancesTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/FinancesTab.java index cd41a15b13..5af10332a2 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/FinancesTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/FinancesTab.java @@ -324,22 +324,12 @@ private JPanel createGeneralOptionsPanel() { newFinancialYearFinancesToCSVExportBox = new CampaignOptionsCheckBox("NewFinancialYearFinancesToCSVExportBox"); // Layout the Panel - final JPanel panelFinancialDuration = new CampaignOptionsStandardPanel("GeneralOptionsPanelFinancialDuration"); - final GridBagConstraints layoutFinancialDuration = new CampaignOptionsGridBagConstraints(panelFinancialDuration); - - layoutFinancialDuration.gridx = 0; - layoutFinancialDuration.gridy = 0; - layoutFinancialDuration.gridwidth = 1; - panelFinancialDuration.add(lblFinancialYearDuration, layoutFinancialDuration); - layoutFinancialDuration.gridx++; - panelFinancialDuration.add(comboFinancialYearDuration, layoutFinancialDuration); - final JPanel panel = new CampaignOptionsStandardPanel("GeneralOptionsPanel"); final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); layout.gridx = 0; layout.gridy = 0; - layout.gridwidth = 1; + layout.gridwidth = 2; panel.add(useLoanLimitsBox, layout); layout.gridy++; @@ -355,10 +345,14 @@ private JPanel createGeneralOptionsPanel() { panel.add(showPeacetimeCostBox, layout); layout.gridy++; - panel.add(panelFinancialDuration, layout); + layout.gridwidth = 1; + panel.add(lblFinancialYearDuration, layout); + layout.gridx++; + panel.add(comboFinancialYearDuration, layout); layout.gridx = 0; layout.gridy++; + layout.gridwidth = 2; panel.add(newFinancialYearFinancesToCSVExportBox, layout); return panel; @@ -415,10 +409,11 @@ private JPanel createTaxesPanel() { layout.gridx = 0; layout.gridy = 0; - layout.gridwidth = 1; + layout.gridwidth = 2; panel.add(chkUseTaxes, layout); layout.gridy++; + layout.gridwidth = 1; panel.add(lblTaxesPercentage, layout); layout.gridx++; panel.add(spnTaxesPercentage, layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/MarketsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/MarketsTab.java index b5e627e358..4e8e73f2cc 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/MarketsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/MarketsTab.java @@ -180,6 +180,7 @@ private JPanel createPersonnelMarketGeneralOptionsPanel() { layout.gridx = 0; layout.gridy++; + layout.gridwidth = 2; panel.add(chkPersonnelMarketReportRefresh, layout); layout.gridy++; @@ -306,9 +307,11 @@ JPanel createUnitMarketTab() { layout.gridx = 0; layout.gridy++; + layout.gridwidth = 2; panel.add(chkUnitMarketRegionalMekVariations, layout); layout.gridy++; + layout.gridwidth = 1; panel.add(lblUnitMarketSpecialUnitChance, layout); layout.gridx++; panel.add(spnUnitMarketSpecialUnitChance, layout); @@ -321,6 +324,7 @@ JPanel createUnitMarketTab() { layout.gridx = 0; layout.gridy++; + layout.gridwidth = 2; panel.add(chkInstantUnitMarketDelivery, layout); layout.gridy++; @@ -433,12 +437,14 @@ private JPanel createContractMarketGeneralOptionsPanel() { layout.gridx = 0; layout.gridy++; + layout.gridwidth = 2; panel.add(chkVariableContractLength, layout); layout.gridy++; panel.add(chkContractMarketReportRefresh, layout); layout.gridy++; + layout.gridwidth = 1; panel.add(lblCoontractMaxSalvagePercentage, layout); layout.gridx++; panel.add(spnContractMaxSalvagePercentage, layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java index aeab2a9fd3..67b155d631 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/PersonnelTab.java @@ -642,6 +642,7 @@ public Component getListCellRendererComponent(final JList list, final Object layout.gridx = 0; layout.gridy++; + layout.gridwidth = 2; panel.add(chkEnableAutoAwards, layout); layout.gridy++; @@ -1028,6 +1029,7 @@ public Component getListCellRendererComponent(final JList list, final Object layout.gridx = 0; layout.gridy++; + layout.gridwidth = 2; panel.add(chkPrisonerBabyStatus, layout); layout.gridy++; diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java index 1f3ae54353..3526f1ec3c 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/RelationshipsTab.java @@ -47,7 +47,6 @@ public class RelationshipsTab { private JCheckBox chkUsePrisonerDivorce; private JPanel pnlRandomDivorce; - private JLabel lblRandomDivorceMethod; private MMComboBox comboRandomDivorceMethod; private JCheckBox chkUseRandomOppositeSexDivorce; @@ -343,6 +342,7 @@ public Component getListCellRendererComponent(final JList list, final Object layout.gridx = 0; layout.gridy++; + layout.gridwidth = 2; panel.add(chkUseRandomClanPersonnelMarriages, layout); layout.gridy++; @@ -350,6 +350,7 @@ public Component getListCellRendererComponent(final JList list, final Object layout.gridx = 0; layout.gridy++; + layout.gridwidth = 1; panel.add(lblRandomMarriageAgeRange, layout); layout.gridx++; panel.add(spnRandomMarriageAgeRange, layout); @@ -474,6 +475,7 @@ public Component getListCellRendererComponent(final JList list, final Object layout.gridx = 0; layout.gridy++; + layout.gridwidth = 2; panel.add(chkUseRandomOppositeSexDivorce, layout); layout.gridy++; @@ -482,12 +484,12 @@ public Component getListCellRendererComponent(final JList list, final Object layout.gridy++; panel.add(chkUseRandomClanPersonnelDivorce, layout); - layout.gridy++; panel.add(chkUseRandomPrisonerDivorce, layout); layout.gridx = 0; layout.gridy++; + layout.gridwidth = 1; panel.add(lblRandomDivorceDiceSize, layout); layout.gridx++; panel.add(spnRandomDivorceDiceSize, layout); @@ -671,6 +673,7 @@ public Component getListCellRendererComponent(final JList list, final Object layout.gridx = 0; layout.gridy++; + layout.gridwidth = 2; panel.add(chkUseRelationshiplessRandomProcreation, layout); layout.gridy++; @@ -681,6 +684,7 @@ public Component getListCellRendererComponent(final JList list, final Object layout.gridx = 0; layout.gridy++; + layout.gridwidth = 1; panel.add(lblRandomProcreationRelationshipDiceSize, layout); layout.gridx++; panel.add(spnRandomProcreationRelationshipDiceSize, layout); diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java index 72f0961533..14fbeec11f 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/RepairAndMaintenanceTab.java @@ -169,13 +169,14 @@ JPanel createRepairTab() { layoutRight.gridx = 0; layoutRight.gridy = 0; - layoutRight.gridwidth = 1; + layoutRight.gridwidth = 2; panelRight.add(useAeroSystemHitsBox, layoutRight); layoutRight.gridy++; panelRight.add(useDamageMargin, layoutRight); layoutRight.gridy++; + layoutRight.gridwidth = 1; panelRight.add(lblDamageMargin, layoutRight); layoutRight.gridx++; panelRight.add(spnDamageMargin, layoutRight); @@ -243,59 +244,75 @@ JPanel createMaintenanceTab() { logMaintenance = new CampaignOptionsCheckBox("LogMaintenance"); // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("repairTab", true); - GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panel); + final JPanel panelLeft = new CampaignOptionsStandardPanel("repairTabLeft"); + GridBagConstraints layoutLeft = new CampaignOptionsGridBagConstraints(panelLeft); - layoutParent.gridwidth = 5; - layoutParent.gridy = 0; - panel.add(headerPanel, layoutParent); + layoutLeft.gridx = 0; + layoutLeft.gridy = 0; + layoutLeft.gridwidth = 1; + panelLeft.add(checkMaintenance, layoutLeft); - layoutParent.gridx = 0; - layoutParent.gridy++; - layoutParent.gridwidth = 1; - panel.add(checkMaintenance, layoutParent); + layoutLeft.gridy++; + panelLeft.add(lblMaintenanceDays, layoutLeft); + layoutLeft.gridx++; + panelLeft.add(spnMaintenanceDays, layoutLeft); - layoutParent.gridy++; - panel.add(lblMaintenanceDays, layoutParent); - layoutParent.gridx++; - panel.add(spnMaintenanceDays, layoutParent); + layoutLeft.gridx = 0; + layoutLeft.gridy++; + panelLeft.add(lblMaintenanceBonus, layoutLeft); + layoutLeft.gridx++; + panelLeft.add(spnMaintenanceBonus, layoutLeft); - layoutParent.gridx = 0; - layoutParent.gridy++; - panel.add(lblMaintenanceBonus, layoutParent); - layoutParent.gridx++; - panel.add(spnMaintenanceBonus, layoutParent); + layoutLeft.gridx = 0; + layoutLeft.gridy++; + panelLeft.add(lblDefaultMaintenanceTime, layoutLeft); + layoutLeft.gridx++; + panelLeft.add(spnDefaultMaintenanceTime, layoutLeft); - layoutParent.gridx = 0; - layoutParent.gridy++; - panel.add(lblDefaultMaintenanceTime, layoutParent); - layoutParent.gridx++; - panel.add(spnDefaultMaintenanceTime, layoutParent); + layoutLeft.gridx = 0; + layoutLeft.gridy++; + layoutLeft.gridwidth = 2; + panelLeft.add(logMaintenance, layoutLeft); - layoutParent.gridx = 0; - layoutParent.gridy++; - panel.add(useQualityMaintenance, layoutParent); + final JPanel panelRight = new CampaignOptionsStandardPanel("repairTabRight", true); + GridBagConstraints layoutRight = new CampaignOptionsGridBagConstraints(panelRight); - layoutParent.gridy++; - panel.add(reverseQualityNames, layoutParent); + layoutLeft.gridx = 0; + layoutLeft.gridy = 0; + layoutLeft.gridwidth = 1; + panelRight.add(useQualityMaintenance, layoutRight); - layoutParent.gridy++; - panel.add(chkUseRandomUnitQualities, layoutParent); + layoutRight.gridy++; + panelRight.add(reverseQualityNames, layoutRight); - layoutParent.gridy++; - panel.add(chkUseRandomUnitQualities, layoutParent); + layoutRight.gridy++; + panelRight.add(chkUseRandomUnitQualities, layoutRight); - layoutParent.gridy++; - panel.add(chkUsePlanetaryModifiers, layoutParent); + layoutRight.gridy++; + panelRight.add(chkUseRandomUnitQualities, layoutRight); - layoutParent.gridy++; - panel.add(useUnofficialMaintenance, layoutParent); + layoutRight.gridy++; + panelRight.add(chkUsePlanetaryModifiers, layoutRight); + + layoutRight.gridy++; + panelRight.add(useUnofficialMaintenance, layoutRight); + + final JPanel panelParent = new CampaignOptionsStandardPanel("repairTab", true); + GridBagConstraints layoutParent = new CampaignOptionsGridBagConstraints(panelParent); + layoutParent.gridwidth = 5; + layoutParent.gridy = 0; + panelParent.add(headerPanel, layoutParent); + + layoutParent.gridx = 0; layoutParent.gridy++; - panel.add(logMaintenance, layoutParent); + layoutParent.gridwidth = 1; + panelParent.add(panelLeft, layoutParent); + layoutParent.gridx++; + panelParent.add(panelRight, layoutParent); // Create Parent Panel and return - return createParentPanel(panel, "maintenanceTab"); + return createParentPanel(panelParent, "maintenanceTab"); } private void recreateFinancesPanel(boolean isReversingQualityNames) { diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/RulesetsTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/RulesetsTab.java index 8be2512e31..2389b32904 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/RulesetsTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/RulesetsTab.java @@ -1,16 +1,15 @@ package mekhq.gui.panes.campaignOptions; import megamek.client.ui.baseComponents.MMComboBox; -import megamek.client.ui.swing.util.UIUtil; import megamek.common.enums.SkillLevel; import mekhq.campaign.mission.AtBContract; import mekhq.campaign.mission.enums.AtBLanceRole; import mekhq.campaign.personnel.Skills; import javax.swing.*; -import javax.swing.GroupLayout.Alignment; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import java.awt.*; import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; @@ -212,7 +211,6 @@ private void substantializeUniversalOptions() { pnlPartsPanel = createUniversalPartsPanel(); pnlLancePanel = createUniversalLancePanel(); - pnlScenarioGenerationPanel = createUniversalScenarioGenerationPanel(); pnlCampaignOptions = createUniversalCampaignOptionsPanel(); } @@ -230,38 +228,45 @@ private JPanel createUniversalScenarioGenerationPanel() { // Layout the panel final JPanel panel = new CampaignOptionsStandardPanel("UniversalScenarioGenerationPanel", true, "UniversalScenarioGenerationPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(pnlUnitRatioPanel) - .addComponent(chkUseDropShips) - .addComponent(chkOpForUsesVTOLs) - .addComponent(chkClanVehicles) - .addComponent(chkRegionalMekVariations) - .addComponent(chkAttachedPlayerCamouflage) - .addComponent(chkPlayerControlsAttachedUnits) - .addComponent(chkAutoConfigMunitions) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblSPAUpgradeIntensity) - .addComponent(spnSPAUpgradeIntensity)) - .addComponent(pnlScenarioModifiers)); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(pnlUnitRatioPanel) - .addComponent(chkUseDropShips) - .addComponent(chkOpForUsesVTOLs) - .addComponent(chkClanVehicles) - .addComponent(chkRegionalMekVariations) - .addComponent(chkAttachedPlayerCamouflage) - .addComponent(chkPlayerControlsAttachedUnits) - .addComponent(chkAutoConfigMunitions) - .addGroup(layout.createSequentialGroup() - .addComponent(lblSPAUpgradeIntensity) - .addComponent(spnSPAUpgradeIntensity)) - .addComponent(pnlScenarioModifiers)); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 3; + panel.add(pnlUnitRatioPanel, layout); + + layout.gridy++; + layout.gridwidth = 2; + panel.add(chkUseDropShips, layout); + + layout.gridy++; + panel.add(chkOpForUsesVTOLs, layout); + + layout.gridy++; + panel.add(chkClanVehicles, layout); + + layout.gridy++; + panel.add(chkRegionalMekVariations, layout); + + layout.gridy++; + panel.add(chkAttachedPlayerCamouflage, layout); + + layout.gridy++; + panel.add(chkPlayerControlsAttachedUnits, layout); + + layout.gridy++; + panel.add(chkAutoConfigMunitions, layout); + + layout.gridy++; + layout.gridwidth = 1; + panel.add(lblSPAUpgradeIntensity, layout); + layout.gridx++; + panel.add(spnSPAUpgradeIntensity, layout); + + layout.gridx = 0; + layout.gridy++; + layout.gridwidth = 3; + panel.add(pnlScenarioModifiers, layout); return panel; } @@ -281,28 +286,22 @@ private JPanel createUniversalUnitRatioPanel() { // Layout the panel final JPanel panel = new CampaignOptionsStandardPanel("UniversalUnitRatioPanel", true, "UniversalUnitRatioPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblOpForLanceTypeMeks) - .addComponent(spnOpForLanceTypeMeks) - .addComponent(lblOpForLanceTypeMixed) - .addComponent(spnOpForLanceTypeMixed) - .addComponent(lblOpForLanceTypeVehicle) - .addComponent(spnOpForLanceTypeVehicles))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblOpForLanceTypeMeks) - .addComponent(spnOpForLanceTypeMeks) - .addComponent(lblOpForLanceTypeMixed) - .addComponent(spnOpForLanceTypeMixed) - .addComponent(lblOpForLanceTypeVehicle) - .addComponent(spnOpForLanceTypeVehicles))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 1; + panel.add(lblOpForLanceTypeMeks, layout); + layout.gridx++; + panel.add(spnOpForLanceTypeMeks, layout); + layout.gridx++; + panel.add(lblOpForLanceTypeMixed, layout); + layout.gridx++; + panel.add(spnOpForLanceTypeMixed, layout); + layout.gridx++; + panel.add(lblOpForLanceTypeVehicle, layout); + layout.gridx++; + panel.add(spnOpForLanceTypeVehicles, layout); return panel; } @@ -322,32 +321,26 @@ private JPanel createUniversalModifiersPanel() { // Layout the panel final JPanel panel = new CampaignOptionsStandardPanel("UniversalModifiersPanel", true, "UniversalModifiersPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblScenarioModMax) - .addComponent(spnScenarioModMax)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblScenarioModChance) - .addComponent(spnScenarioModChance)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblScenarioModBV) - .addComponent(spnScenarioModBV))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(lblScenarioModMax) - .addComponent(spnScenarioModMax)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblScenarioModChance) - .addComponent(spnScenarioModChance)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblScenarioModBV) - .addComponent(spnScenarioModBV))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 1; + panel.add(lblScenarioModMax, layout); + layout.gridx++; + panel.add(spnScenarioModMax, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblScenarioModChance, layout); + layout.gridx++; + panel.add(spnScenarioModChance, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblScenarioModBV, layout); + layout.gridx++; + panel.add(spnScenarioModBV, layout); return panel; } @@ -364,46 +357,41 @@ private JPanel createUniversalMapGenerationPanel() { // Layout the panel final JPanel panel = new CampaignOptionsStandardPanel("UniversalMapGenerationPanel", true, "UniversalMapGenerationPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(chkUseWeatherConditions) - .addComponent(chkUseLightConditions) - .addComponent(chkUsePlanetaryConditions) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblFixedMapChance) - .addComponent(spnFixedMapChance))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(chkUseWeatherConditions) - .addComponent(chkUseLightConditions) - .addComponent(chkUsePlanetaryConditions) - .addGroup(layout.createSequentialGroup() - .addComponent(lblFixedMapChance) - .addComponent(spnFixedMapChance))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 2; + panel.add(chkUseWeatherConditions, layout); + + layout.gridy++; + panel.add(chkUseLightConditions, layout); + + layout.gridy++; + panel.add(chkUsePlanetaryConditions, layout); + + layout.gridy++; + layout.gridwidth = 1; + panel.add(lblFixedMapChance, layout); + layout.gridx++; + panel.add(spnFixedMapChance, layout); return panel; } private JPanel createUniversalCampaignOptionsPanel() { // Layout the panel - final JPanel panel = new CampaignOptionsStandardPanel("UniversalCampaignOptionsPanel", false, - ""); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(pnlPartsPanel) - .addComponent(pnlLancePanel)); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(pnlPartsPanel) - .addComponent(pnlLancePanel)); + final JPanel panel = new CampaignOptionsStandardPanel("UniversalCampaignOptionsPanel"); + GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridwidth = 2; + layout.gridy = 0; + layout.gridx = 0; + panel.add(pnlPartsPanel, layout); + layout.gridy++; + panel.add(pnlLancePanel, layout); + layout.gridy++; + panel.add(pnlMapGenerationPanel, layout); return panel; } @@ -421,28 +409,24 @@ private JPanel createUniversalPartsPanel() { // Layout the panel final JPanel panel = new CampaignOptionsStandardPanel("UniversalPartsPanel", true, "UniversalPartsPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(chkRestrictPartsByMission) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblBonusPartExchangeValue) - .addComponent(spnBonusPartExchangeValue)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblBonusPartMaxExchangeCount) - .addComponent(spnBonusPartMaxExchangeCount))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(chkRestrictPartsByMission) - .addGroup(layout.createSequentialGroup() - .addComponent(lblBonusPartExchangeValue) - .addComponent(spnBonusPartExchangeValue)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblBonusPartMaxExchangeCount) - .addComponent(spnBonusPartMaxExchangeCount))); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 2; + panel.add(chkRestrictPartsByMission, layout); + + layout.gridy++; + layout.gridwidth = 1; + panel.add(lblBonusPartExchangeValue, layout); + layout.gridx++; + panel.add(spnBonusPartExchangeValue, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblBonusPartMaxExchangeCount, layout); + layout.gridx++; + panel.add(spnBonusPartMaxExchangeCount, layout); return panel; } @@ -463,34 +447,36 @@ private JPanel createUniversalLancePanel() { // Layout the panel final JPanel panel = new CampaignOptionsStandardPanel("UniversalLancePanel", true, "UniversalLancePanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(chkLimitLanceWeight) - .addComponent(chkLimitLanceNumUnits) - .addComponent(chkUseStrategy) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblBaseStrategyDeployment) - .addComponent(spnBaseStrategyDeployment)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblAdditionalStrategyDeployment) - .addComponent(spnAdditionalStrategyDeployment)) - .addComponent(chkAdjustPaymentForStrategy)); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(chkLimitLanceWeight) - .addComponent(chkLimitLanceNumUnits) - .addComponent(chkUseStrategy) - .addGroup(layout.createSequentialGroup() - .addComponent(lblBaseStrategyDeployment) - .addComponent(spnBaseStrategyDeployment)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblAdditionalStrategyDeployment) - .addComponent(spnAdditionalStrategyDeployment)) - .addComponent(chkAdjustPaymentForStrategy)); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 2; + panel.add(chkLimitLanceWeight, layout); + + layout.gridy++; + panel.add(chkLimitLanceNumUnits, layout); + + layout.gridy++; + panel.add(chkUseStrategy, layout); + + layout.gridx = 0; + layout.gridy++; + layout.gridwidth = 1; + panel.add(lblBaseStrategyDeployment, layout); + layout.gridx++; + panel.add(spnBaseStrategyDeployment, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblAdditionalStrategyDeployment, layout); + layout.gridx++; + panel.add(spnAdditionalStrategyDeployment, layout); + + layout.gridx = 0; + layout.gridy++; + layout.gridwidth = 2; + panel.add(chkAdjustPaymentForStrategy, layout); return panel; } @@ -514,37 +500,32 @@ JPanel createStratConTab() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("StratConTab", true); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(chkUseStratCon) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblSkillLevel) - .addComponent(comboSkillLevel)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(chkUseGenericBattleValue) - .addComponent(chkUseVerboseBidding)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(pnlScenarioGenerationPanel) - .addComponent(pnlCampaignOptions))); - - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(chkUseStratCon) - .addGroup(layout.createSequentialGroup() - .addComponent(lblSkillLevel) - .addComponent(comboSkillLevel)) - .addGroup(layout.createSequentialGroup() - .addComponent(chkUseGenericBattleValue) - .addComponent(chkUseVerboseBidding)) - .addGroup(layout.createSequentialGroup() - .addComponent(pnlScenarioGenerationPanel) - .addComponent(pnlCampaignOptions))); + GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridwidth = 5; + layout.gridy = 0; + panel.add(headerPanel, layout); + + layout.gridwidth = 1; + layout.gridy++; + panel.add(chkUseStratCon, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(lblSkillLevel, layout); + layout.gridx++; + panel.add(comboSkillLevel, layout); + layout.gridx++; + panel.add(chkUseGenericBattleValue, layout); + layout.gridx++; + panel.add(chkUseVerboseBidding, layout); + + layout.gridwidth = 2; + layout.gridx = 0; + layout.gridy++; + panel.add(pnlScenarioGenerationPanel, layout); + layout.gridx += 2; + panel.add(pnlCampaignOptions, layout); // Create panel and return return createParentPanel(panel, "StratConTab"); @@ -588,26 +569,22 @@ JPanel createLegacyTab() { pnlLegacyScenarioGenerationPanel = createLegacyScenarioGenerationPanel(); // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("LegacyTab", true, - ""); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(headerPanel) - .addComponent(chkUseAtB) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(pnlLegacyOpForGenerationPanel) - .addComponent(pnlLegacyScenarioGenerationPanel))); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(headerPanel, Alignment.CENTER) - .addComponent(chkUseAtB) - .addGroup(layout.createSequentialGroup() - .addComponent(pnlLegacyOpForGenerationPanel) - .addComponent(pnlLegacyScenarioGenerationPanel))); + final JPanel panel = new CampaignOptionsStandardPanel("LegacyTab", true); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridwidth = 5; + layout.gridx = 0; + layout.gridy = 0; + panel.add(headerPanel, layout); + + layout.gridy++; + layout.gridwidth = 1; + panel.add(chkUseAtB, layout); + + layout.gridy++; + panel.add(pnlLegacyOpForGenerationPanel, layout); + layout.gridx++; + panel.add(pnlLegacyScenarioGenerationPanel, layout); // Create panel and return return createParentPanel(panel, "LegacyTab"); @@ -627,30 +604,33 @@ private JPanel createLegacyOpForGenerationPanel() { // Layout the Panel final JPanel panel = new CampaignOptionsStandardPanel("LegacyOpForGenerationPanel", true, "LegacyOpForGenerationPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(chkUseVehicles) - .addComponent(chkDoubleVehicles) - .addComponent(chkOpForUsesAero) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblOpForAeroChance) - .addComponent(spnOpForAeroChance)) - .addComponent(chkOpForUsesLocalForces) - .addComponent(chkAdjustPlayerVehicles)); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(chkUseVehicles) - .addComponent(chkDoubleVehicles) - .addComponent(chkOpForUsesAero) - .addGroup(layout.createSequentialGroup() - .addComponent(lblOpForAeroChance) - .addComponent(spnOpForAeroChance)) - .addComponent(chkOpForUsesLocalForces) - .addComponent(chkAdjustPlayerVehicles)); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 2; + panel.add(chkUseVehicles, layout); + + layout.gridy++; + panel.add(chkDoubleVehicles, layout); + + layout.gridy++; + panel.add(chkOpForUsesAero, layout); + + layout.gridx = 0; + layout.gridy++; + layout.gridwidth = 1; + panel.add(lblOpForAeroChance, layout); + layout.gridx++; + panel.add(spnOpForAeroChance, layout); + + layout.gridx = 0; + layout.gridy++; + layout.gridwidth = 2; + panel.add(chkOpForUsesLocalForces, layout); + + layout.gridy++; + panel.add(chkAdjustPlayerVehicles, layout); return panel; } @@ -676,54 +656,57 @@ private JPanel createLegacyScenarioGenerationPanel() { btnIntensityUpdate = new CampaignOptionsButton("IntensityUpdate"); // Layout the Panel + final JPanel panelBattleChance = new CampaignOptionsStandardPanel("LegacyScenarioGenerationPanel"); + final GridBagConstraints layoutBattleChance = new CampaignOptionsGridBagConstraints(panelBattleChance); + + layoutBattleChance.gridx = 0; + layoutBattleChance.gridy = 0; + layoutBattleChance.gridwidth = 1; + panelBattleChance.add(lblFightChance, layoutBattleChance); + layoutBattleChance.gridx++; + panelBattleChance.add(spnAtBBattleChance[AtBLanceRole.FIGHTING.ordinal()], layoutBattleChance); + + layoutBattleChance.gridx = 0; + layoutBattleChance.gridy++; + panelBattleChance.add(lblDefendChance, layoutBattleChance); + layoutBattleChance.gridx++; + panelBattleChance.add(spnAtBBattleChance[AtBLanceRole.DEFENCE.ordinal()], layoutBattleChance); + + layoutBattleChance.gridx = 0; + layoutBattleChance.gridy++; + panelBattleChance.add(lblScoutChance, layoutBattleChance); + layoutBattleChance.gridx++; + panelBattleChance.add(spnAtBBattleChance[AtBLanceRole.SCOUTING.ordinal()], layoutBattleChance); + + layoutBattleChance.gridx = 0; + layoutBattleChance.gridy++; + panelBattleChance.add(lblTrainingChance, layoutBattleChance); + layoutBattleChance.gridx++; + panelBattleChance.add(spnAtBBattleChance[AtBLanceRole.TRAINING.ordinal()], layoutBattleChance); + final JPanel panel = new CampaignOptionsStandardPanel("LegacyScenarioGenerationPanel", true, "LegacyScenarioGenerationPanel"); - final GroupLayout layout = createGroupLayout(panel); - panel.setLayout(layout); - - layout.setVerticalGroup( - layout.createSequentialGroup() - .addComponent(chkGenerateChases) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblIntensity) - .addComponent(spnAtBBattleIntensity)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblFightChance) - .addComponent(spnAtBBattleChance[AtBLanceRole.FIGHTING.ordinal()])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblDefendChance) - .addComponent(spnAtBBattleChance[AtBLanceRole.DEFENCE.ordinal()])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblScoutChance) - .addComponent(spnAtBBattleChance[AtBLanceRole.SCOUTING.ordinal()])) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblTrainingChance) - .addComponent(spnAtBBattleChance[AtBLanceRole.TRAINING.ordinal()])) - .addComponent(btnIntensityUpdate)); - - layout.setHorizontalGroup( - layout.createParallelGroup(Alignment.LEADING) - .addComponent(chkGenerateChases) - .addGroup(layout.createSequentialGroup() - .addComponent(lblIntensity) - .addComponent(spnAtBBattleIntensity)) - .addGroup(layout.createSequentialGroup() - .addGap(UIUtil.scaleForGUI(25)) - .addComponent(lblFightChance) - .addComponent(spnAtBBattleChance[AtBLanceRole.FIGHTING.ordinal()])) - .addGroup(layout.createSequentialGroup() - .addGap(UIUtil.scaleForGUI(25)) - .addComponent(lblDefendChance) - .addComponent(spnAtBBattleChance[AtBLanceRole.DEFENCE.ordinal()])) - .addGroup(layout.createSequentialGroup() - .addGap(UIUtil.scaleForGUI(25)) - .addComponent(lblScoutChance) - .addComponent(spnAtBBattleChance[AtBLanceRole.SCOUTING.ordinal()])) - .addGroup(layout.createSequentialGroup() - .addGap(UIUtil.scaleForGUI(25)) - .addComponent(lblTrainingChance) - .addComponent(spnAtBBattleChance[AtBLanceRole.TRAINING.ordinal()])) - .addComponent(btnIntensityUpdate)); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + + layout.gridx = 0; + layout.gridy = 0; + layout.gridwidth = 2; + panel.add(chkGenerateChases, layout); + + layout.gridy++; + layout.gridwidth = 1; + panel.add(lblIntensity, layout); + layout.gridx++; + panel.add(spnAtBBattleIntensity, layout); + + layout.gridx = 0; + layout.gridy++; + layout.gridwidth = 1; + panel.add(panelBattleChance, layout); + + layout.gridy++; + layout.gridwidth = 1; + panel.add(btnIntensityUpdate, layout); return panel; } diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java index 15f97a3a80..2292913b00 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/TurnoverAndRetentionTab.java @@ -445,6 +445,7 @@ public Component getListCellRendererComponent(final JList list, final Object layout.gridx = 0; layout.gridy++; + layout.gridwidth = 2; panel.add(chkUseContractCompletionRandomRetirement, layout); layout.gridy++; @@ -461,6 +462,7 @@ public Component getListCellRendererComponent(final JList list, final Object layout.gridx = 0; layout.gridy++; + layout.gridwidth = 1; panel.add(lblServiceContractDuration, layout); layout.gridx++; panel.add(spnServiceContractDuration, layout); @@ -473,10 +475,12 @@ public Component getListCellRendererComponent(final JList list, final Object layout.gridx = 0; layout.gridy++; + layout.gridwidth = 2; panel.add(chkPayBonusDefault, layout); layout.gridx = 0; layout.gridy++; + layout.gridwidth = 1; panel.add(lblPayBonusDefaultThreshold, layout); layout.gridx++; panel.add(spnPayBonusDefaultThreshold, layout); @@ -610,10 +614,12 @@ private JPanel createPayoutsPanel() { layout.gridx = 0; layout.gridy++; + layout.gridwidth = 2; panel.add(chkUsePayoutServiceBonus, layout); layout.gridx = 0; layout.gridy++; + layout.gridwidth = 1; panel.add(lblPayoutServiceBonusRate, layout); layout.gridx++; panel.add(spnPayoutServiceBonusRate, layout); @@ -746,10 +752,11 @@ private JPanel createManagementSkillWrapperPanel() { layout.gridy = 0; layout.gridx = 0; - layout.gridwidth = 1; + layout.gridwidth = 2; panel.add(chkUseManagementSkill, layout); layout.gridy++; + layout.gridwidth = 1; panel.add(pnlManagementSkill, layout); return panel; @@ -783,10 +790,11 @@ private JPanel createManagementSkillPanel() { layout.gridy = 0; layout.gridx = 0; - layout.gridwidth = 1; + layout.gridwidth = 2; panel.add(chkUseCommanderLeadershipOnly, layout); layout.gridy++; + layout.gridwidth = 1; panel.add(lblManagementSkillPenalty, layout); layout.gridx++; panel.add(spnManagementSkillPenalty, layout); From 93c2ab0b73665bf6c8f54b95f21d536b23729a0d Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 16 Oct 2024 20:32:49 -0500 Subject: [PATCH 112/117] Simplify General Panel Title Changed "General Information" to "General" for the general panel title in the campaign options dialog. This makes the title more concise and aligns with the naming convention of other panels. --- .../mekhq/resources/NEWCampaignOptionsDialog.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 604775ecbc..3afe807f4b 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -11,7 +11,7 @@ lblPresetDialogCancel.text=Cancel lblPresetDialogCancel.tooltip=Return to the prior screen. ## Campaign Options Pane -generalPanel.title=General Information +generalPanel.title=General humanResourcesParentTab.title=Human Resources unitDevelopmentParentTab.title=Unit Development logisticsAndMaintenanceParentTab.title=Logistics From 8a767aa3c86202fa8f0d1ca0df7a781029018dbd Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 16 Oct 2024 20:47:37 -0500 Subject: [PATCH 113/117] Rename Unit Development Tab to Advancement Changed the "Unit Development" tab title to "Advancement" in the campaign options dialog. This update makes the tab name more concise and better reflects its content. It also ensures consistency with the naming convention of other panels. --- .../mekhq/resources/NEWCampaignOptionsDialog.properties | 2 +- .../mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index 3afe807f4b..ff777e4af4 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -13,7 +13,7 @@ lblPresetDialogCancel.tooltip=Return to the prior screen. ## Campaign Options Pane generalPanel.title=General humanResourcesParentTab.title=Human Resources -unitDevelopmentParentTab.title=Unit Development +advancementTab.title=Advancement logisticsAndMaintenanceParentTab.title=Logistics strategicOperationsParentTab.title=Operations diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java index cfc93fbba5..739b75fe27 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java @@ -149,9 +149,7 @@ private JTabbedPane createHumanResourcesParentTab() { } private JTabbedPane createUnitDevelopmentParentTab() { - // Experience - // Skills - // Skill Randomization + // Experience + Skills + Skill Randomization // SPAs // Parent Tab From 3c11d6f5f861cb97081e1450775ee988ef03f998 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 17 Oct 2024 12:59:17 -0500 Subject: [PATCH 114/117] Update comments to include additional skill categories Clarified the categorization of skills in the comments section by adding "Combat Skills," "Non-Combat Skills," and "Roleplay Skills." This improves code readability and provides better insight into the skill classification system. --- .../mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java index 739b75fe27..8ef7168c79 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java @@ -149,7 +149,8 @@ private JTabbedPane createHumanResourcesParentTab() { } private JTabbedPane createUnitDevelopmentParentTab() { - // Experience + Skills + Skill Randomization + // Experience + Skill Randomization + // Combat Skills + Non-Combat Skills + Roleplay Skills // SPAs // Parent Tab From 08fe1e356013cd491c2d604253a86d17eef86dc9 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 17 Oct 2024 14:33:01 -0500 Subject: [PATCH 115/117] Rename unit development tab and add AdvancementTab Renamed the "unitDevelopmentParentTab" to "advancementParentTab" and introduced the new "AdvancementTab" class. Added comprehensive components for managing experience awards and skill randomization within the advancement tab, enhancing the campaign options functionality. --- .../NEWCampaignOptionsDialog.properties | 71 +++- .../panes/campaignOptions/AdvancementTab.java | 352 ++++++++++++++++++ .../campaignOptions/CampaignOptionsPane.java | 23 +- .../CampaignOptionsUtilities.java | 2 +- 4 files changed, 439 insertions(+), 9 deletions(-) create mode 100644 MekHQ/src/mekhq/gui/panes/campaignOptions/AdvancementTab.java diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index ff777e4af4..cd2793f616 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -13,11 +13,10 @@ lblPresetDialogCancel.tooltip=Return to the prior screen. ## Campaign Options Pane generalPanel.title=General humanResourcesParentTab.title=Human Resources -advancementTab.title=Advancement +advancementParentTab.title=Advancement logisticsAndMaintenanceParentTab.title=Logistics strategicOperationsParentTab.title=Operations - ## General Tab Class # createGeneralTab lblGeneral.text=Welcome, Commander @@ -1334,4 +1333,70 @@ lblGenerateChases.tooltip=PLACEHOLDER lblAtBBattleIntensity.text=Battle Frequency lblAtBBattleIntensity.tooltip=PLACEHOLDER lblIntensityUpdate.text=Update Battle Frequency -lblIntensityUpdate.tooltip=PLACEHOLDER \ No newline at end of file +lblIntensityUpdate.tooltip=PLACEHOLDER + +## Advancement Tab +awardsAndRandomizationContentTabs.title=Awards & Randomization + +xpAwardsTab.title=Experience Awards +xpAwardsTab.border="Experience isn't about knowing what to do next - it's about understanding what's\ + \ at stake when you do it."\ +
- Colonel Zara "Hawk" Larsen, Black Sun Battalion + +randomizationTab.title=Randomization +randomizationTab.border="Every skill has its moment. What seems trivial today may save lives tomorrow,\ + \ because out in the stars, survival favors the adaptable."\ +
- Colonel Drake "Ironjaw" Valen, Jade Wolf Battalion + +# xpAwardsTab +lblXpAwardsTab.text=Experience Award Options +lblXpAwardsTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Euismod\ + \ varius congue rhoncus netus nostra tortor varius mi. Consequat in nunc turpis cras eget nam\ + \ maximus. Morbigravida laoreet auctor consequat porta ex donec habitasse. Lacinia quis placerat\ + \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ + \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ + \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam + +# createTasksPanel +lblTasksPanel.text=Tasks +lblTaskXP.text=XP per +lblTaskXP.tooltip=PLACEHOLDER +lblNTasksXP.text=Successful Tasks (Deprecated) +lblNTasksXP.tooltip=PLACEHOLDER +lblSuccessXP.text=XP per Successful Natural 12 +lblSuccessXP.tooltip=PLACEHOLDER +lblMistakeXP.text=XP per Unsuccessful Natural 2 +lblMistakeXP.tooltip=PLACEHOLDER + +# createScenariosPanel +lblScenariosPanel.text=Scenarios +lblScenarioXP.text=XP per Scenario +lblScenarioXP.tooltip=PLACEHOLDER +lblKillXP.text=XP per +lblKillXP.tooltip=PLACEHOLDER +lblKills.text=Kills (Deprecated) +lblKills.tooltip=PLACEHOLDER + +# createMissionsPanel +lblMissionsPanel.text=Missions +lblIdleXP.text=XP per +lblIdleXP.tooltip=PLACEHOLDER +lblMonthsIdleXP.text=Months Idle +lblMonthsIdleXP.tooltip=PLACEHOLDER +lblTargetIdleXP.text=Idle XP Target Number +lblTargetIdleXP.tooltip=PLACEHOLDER +lblMissionXpFail.text=Failure +lblMissionXpFail.tooltip=PLACEHOLDER +lblMissionXpSuccess.text=Success +lblMissionXpSuccess.tooltip=PLACEHOLDER +lblMissionXpOutstandingSuccess.text=Outstanding Success +lblMissionXpOutstandingSuccess.tooltip=PLACEHOLDER + +# createAdministratorsPanel +lblAdministratorsXpPanel.text=Administrators (Deprecated) +lblAdminWeeklyXP.text=XP per +lblAdminWeeklyXP.tooltip=PLACEHOLDER +lblAdminWeeklyXPPeriod.text=Weeks +lblAdminWeeklyXPPeriod.tooltip=PLACEHOLDER +lblContractNegotiationXP.text=XP to Negotiator +lblContractNegotiationXP.tooltip=PLACEHOLDER \ No newline at end of file diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/AdvancementTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/AdvancementTab.java new file mode 100644 index 0000000000..996507f120 --- /dev/null +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/AdvancementTab.java @@ -0,0 +1,352 @@ +package mekhq.gui.panes.campaignOptions; + +import mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; + +import javax.swing.*; +import java.awt.*; + +import static mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; + +public class AdvancementTab { + JFrame frame; + String name; + + //start XP Awards Tab + private JLabel lblXpCostMultiplier; + private JSpinner spnXpCostMultiplier; + + private JPanel pnlTasks; + private JLabel lblTaskXP; + private JSpinner spnTaskXP; + private JLabel lblNTasksXP; + private JSpinner spnNTasksXP; + private JLabel lblSuccessXP; + private JSpinner spnSuccessXP; + private JLabel lblMistakeXP; + private JSpinner spnMistakeXP; + + private JPanel pnlScenarios; + private JLabel lblScenarioXP; + private JSpinner spnScenarioXP; + private JLabel lblKillXP; + private JSpinner spnKillXP; + private JLabel lblKills; + private JSpinner spnKills; + + private JPanel pnlMissions; + private JLabel lblIdleXP; + private JSpinner spnIdleXP; + private JLabel lblMonthsIdleXP; + private JSpinner spnMonthsIdleXP; + private JLabel lblTargetIdleXP; + private JSpinner spnTargetIdleXP; + private JLabel lblMissionXpFail; + private JSpinner spnMissionXpFail; + private JLabel lblMissionXpSuccess; + private JSpinner spnMissionXpSuccess; + private JLabel lblMissionXpOutstandingSuccess; + private JSpinner spnMissionXpOutstandingSuccess; + + private JPanel pnlAdministrators; + private JLabel lblContractNegotiationXP; + private JSpinner spnContractNegotiationXP; + private JLabel lblAdminWeeklyXP; + private JSpinner spnAdminWeeklyXP; + private JLabel lblAdminWeeklyXPPeriod; + private JSpinner spnAdminWeeklyXPPeriod; + //end XP Awards Tab + + //start Skill Randomization Tab + //end Skill Randomization Tab + + AdvancementTab(JFrame frame, String name) { + this.frame = frame; + this.name = name; + + initialize(); + } + + private void initialize() { + initializeXPAwardsTab(); + initializeSkillRandomizationTab(); + } + + private void initializeXPAwardsTab() { + pnlTasks = new JPanel(); + lblTaskXP = new JLabel(); + spnTaskXP = new JSpinner(); + lblNTasksXP = new JLabel(); + spnNTasksXP = new JSpinner(); + lblSuccessXP = new JLabel(); + spnSuccessXP = new JSpinner(); + lblMistakeXP = new JLabel(); + spnMistakeXP = new JSpinner(); + + pnlScenarios = new JPanel(); + lblScenarioXP = new JLabel(); + spnScenarioXP = new JSpinner(); + lblKillXP = new JLabel(); + spnKillXP = new JSpinner(); + lblKills = new JLabel(); + spnKills = new JSpinner(); + + pnlMissions = new JPanel(); + lblIdleXP = new JLabel(); + spnIdleXP = new JSpinner(); + lblMonthsIdleXP = new JLabel(); + spnMonthsIdleXP = new JSpinner(); + lblTargetIdleXP = new JLabel(); + spnTargetIdleXP = new JSpinner(); + lblMissionXpFail = new JLabel(); + spnMissionXpFail = new JSpinner(); + lblMissionXpSuccess = new JLabel(); + spnMissionXpSuccess = new JSpinner(); + lblMissionXpOutstandingSuccess = new JLabel(); + spnMissionXpOutstandingSuccess = new JSpinner(); + + pnlAdministrators = new JPanel(); + lblContractNegotiationXP = new JLabel(); + spnContractNegotiationXP = new JSpinner(); + lblAdminWeeklyXP = new JLabel(); + spnAdminWeeklyXP = new JSpinner(); + lblAdminWeeklyXPPeriod = new JLabel(); + spnAdminWeeklyXPPeriod = new JSpinner(); + } + + JPanel xpAwardsTab() { + // Header + JPanel headerPanel = new CampaignOptionsHeaderPanel("XpAwardsTab", + getImageDirectory() + "logo_federated_suns.png", + true); + + // Contents + pnlTasks = createTasksPanel(); + pnlScenarios = createScenariosPanel(); + pnlAdministrators = createAdministratorsPanel(); + pnlMissions = createMissionsPanel(); + + // Layout the Panel + final JPanel panel = new CampaignOptionsStandardPanel("XpAwardsTab", true); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + layout.gridwidth = 5; + layout.gridx = 0; + layout.gridy = 0; + panel.add(headerPanel, layout); + + layout.gridy++; + layout.gridwidth = 1; + panel.add(pnlTasks, layout); + layout.gridx++; + panel.add(pnlMissions, layout); + + layout.gridx = 0; + layout.gridy++; + layout.gridwidth = 1; + panel.add(pnlScenarios, layout); + layout.gridx++; + panel.add(pnlAdministrators, layout); + + // Create Parent Panel and return + return createParentPanel(panel, "XpAwardsTab"); + } + + private JPanel createTasksPanel() { + // Contents + lblTaskXP = new CampaignOptionsLabel("TaskXP"); + spnTaskXP = new CampaignOptionsSpinner("TaskXP", + 0, 0, 10000, 1); + + lblNTasksXP = new CampaignOptionsLabel("NTasksXP"); + spnNTasksXP = new CampaignOptionsSpinner("NTasksXP", + 0, 0, 10000, 1); + + lblSuccessXP = new CampaignOptionsLabel("SuccessXP"); + spnSuccessXP = new CampaignOptionsSpinner("SuccessXP", + 0, 0, 10000, 1); + + lblMistakeXP = new CampaignOptionsLabel("MistakeXP"); + spnMistakeXP = new CampaignOptionsSpinner("MistakeXP", + 0, 0, 10000, 1); + + // Layout the Panel + final JPanel panel = new CampaignOptionsStandardPanel("TasksPanel", true, + "TasksPanel"); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + layout.gridwidth = 1; + layout.gridx = 0; + layout.gridy = 0; + panel.add(spnTaskXP, layout); + layout.gridx++; + panel.add(lblTaskXP, layout); + layout.gridx++; + panel.add(spnNTasksXP, layout); + layout.gridx++; + panel.add(lblNTasksXP, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(spnSuccessXP, layout); + layout.gridx++; + layout.gridwidth = 2; + panel.add(lblSuccessXP, layout); + + layout.gridx = 0; + layout.gridy++; + layout.gridwidth = 1; + panel.add(spnMistakeXP, layout); + layout.gridx++; + layout.gridwidth = 2; + panel.add(lblMistakeXP, layout); + + return panel; + } + + private JPanel createScenariosPanel() { + // Contents + lblScenarioXP = new CampaignOptionsLabel("ScenarioXP"); + spnScenarioXP = new CampaignOptionsSpinner("ScenarioXP", + 0, 0, 10000, 1); + lblKillXP = new CampaignOptionsLabel("KillXP"); + spnKillXP = new CampaignOptionsSpinner("KillXP", + 0, 0, 10000, 1); + + lblKills = new CampaignOptionsLabel("Kills"); + spnKills = new CampaignOptionsSpinner("Kills", + 0, 0, 10000, 1); + + // Layout the Panel + final JPanel panel = new CampaignOptionsStandardPanel("ScenariosPanel", true, + "ScenariosPanel"); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + layout.gridwidth = 1; + layout.gridx = 0; + layout.gridy = 0; + panel.add(spnScenarioXP, layout); + layout.gridx++; + layout.gridwidth = 2; + panel.add(lblScenarioXP, layout); + + layout.gridx = 0; + layout.gridy++; + layout.gridwidth = 1; + panel.add(spnKillXP, layout); + layout.gridx++; + panel.add(lblKillXP, layout); + layout.gridx++; + panel.add(spnKills, layout); + layout.gridx++; + panel.add(lblKills, layout); + + return panel; + } + + private JPanel createMissionsPanel() { + // Contents + lblIdleXP = new CampaignOptionsLabel("IdleXP"); + spnIdleXP = new CampaignOptionsSpinner("IdleXP", + 0, 0, 10000, 1); + lblMonthsIdleXP = new CampaignOptionsLabel("MonthsIdleXP"); + spnMonthsIdleXP = new CampaignOptionsSpinner("MonthsIdleXP", + 0, 0, 36, 1); + lblTargetIdleXP = new CampaignOptionsLabel("TargetIdleXP"); + spnTargetIdleXP = new CampaignOptionsSpinner("TargetIdleXP", + 2, 2, 13, 1); + + lblMissionXpFail = new CampaignOptionsLabel("MissionXpFail"); + spnMissionXpFail = new CampaignOptionsSpinner("MissionXpFail", + 1, 0, 10, 1); + + lblMissionXpSuccess = new CampaignOptionsLabel("MissionXpSuccess"); + spnMissionXpSuccess = new CampaignOptionsSpinner("MissionXpSuccess", + 1, 0, 10, 1); + + lblMissionXpOutstandingSuccess = new CampaignOptionsLabel("MissionXpOutstandingSuccess"); + spnMissionXpOutstandingSuccess = new CampaignOptionsSpinner("MissionXpOutstandingSuccess", + 1, 0, 10, 1); + + // Layout the Panel + final JPanel panel = new CampaignOptionsStandardPanel("MissionsPanel", true, + "MissionsPanel"); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + layout.gridwidth = 1; + layout.gridx = 0; + layout.gridy = 0; + panel.add(spnIdleXP, layout); + layout.gridx++; + panel.add(lblIdleXP, layout); + layout.gridx++; + panel.add(spnMonthsIdleXP, layout); + layout.gridx++; + panel.add(lblMonthsIdleXP, layout); + + layout.gridx = 0; + layout.gridy++; + layout.gridwidth = 2; + panel.add(lblTargetIdleXP, layout); + layout.gridx += 2; + layout.gridwidth = 1; + panel.add(spnTargetIdleXP, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(spnMissionXpFail, layout); + layout.gridx++; + panel.add(lblMissionXpFail, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(spnMissionXpSuccess, layout); + layout.gridx++; + panel.add(lblMissionXpSuccess, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(spnMissionXpOutstandingSuccess, layout); + layout.gridx++; + layout.gridwidth = 2; + panel.add(lblMissionXpOutstandingSuccess, layout); + + return panel; + } + + private JPanel createAdministratorsPanel() { + // Contents + lblAdminWeeklyXP = new CampaignOptionsLabel("AdminWeeklyXP"); + spnAdminWeeklyXP = new CampaignOptionsSpinner("AdminWeeklyXP", + 0, 0, 10000, 1); + lblAdminWeeklyXPPeriod = new CampaignOptionsLabel("AdminWeeklyXPPeriod"); + spnAdminWeeklyXPPeriod = new CampaignOptionsSpinner("AdminWeeklyXPPeriod", + 1, 1, 100, 1); + + lblContractNegotiationXP = new CampaignOptionsLabel("ContractNegotiationXP"); + spnContractNegotiationXP = new CampaignOptionsSpinner("ContractNegotiationXP", + 0, 0, 10000, 1); + // Layout the Panel + final JPanel panel = new CampaignOptionsStandardPanel("AdministratorsXpPanel", true, + "AdministratorsXpPanel"); + final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); + layout.gridwidth = 1; + layout.gridx = 0; + layout.gridy = 0; + panel.add(spnAdminWeeklyXP, layout); + layout.gridx++; + panel.add(lblAdminWeeklyXP, layout); + layout.gridx++; + panel.add(spnAdminWeeklyXPPeriod, layout); + layout.gridx++; + panel.add(lblAdminWeeklyXPPeriod, layout); + + layout.gridx = 0; + layout.gridy++; + panel.add(spnContractNegotiationXP, layout); + layout.gridx++; + layout.gridwidth = 2; + panel.add(lblContractNegotiationXP, layout); + + return panel; + } + + private void initializeSkillRandomizationTab() { + + } +} diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java index 8ef7168c79..08226b30a5 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsPane.java @@ -39,7 +39,7 @@ protected void initialize() { resources.getString("generalPanel.title")), createGeneralTab()); createTab("humanResourcesParentTab", createHumanResourcesParentTab()); - createTab("unitDevelopmentParentTab", createUnitDevelopmentParentTab()); + createTab("advancementParentTab", createAdvancementParentTab()); createTab("logisticsAndMaintenanceParentTab", createEquipmentAndSuppliesParentTab()); createTab("strategicOperationsParentTab", createStrategicOperationsParentTab()); } @@ -148,15 +148,28 @@ private JTabbedPane createHumanResourcesParentTab() { return humanResourcesParentTab; } - private JTabbedPane createUnitDevelopmentParentTab() { + private JTabbedPane createAdvancementParentTab() { + // Parent Tab + JTabbedPane advancementParentTab = new JTabbedPane(); + // Experience + Skill Randomization + AdvancementTab advancementTab = new AdvancementTab(getFrame(), "advancementTab"); + + JTabbedPane awardsAndRandomizationContentTabs = createSubTabs(Map.of( + "xpAwardsTab", advancementTab.xpAwardsTab())); + // Combat Skills + Non-Combat Skills + Roleplay Skills + // SPAs - // Parent Tab - JTabbedPane unitDevelopmentParentTab = new JTabbedPane(); + // Add Tabs + advancementParentTab.addTab(String.format("%s", 4, + resources.getString("awardsAndRandomizationContentTabs.title")), awardsAndRandomizationContentTabs); + + addTab(String.format("%s", 4, + resources.getString("advancementParentTab.title")), advancementParentTab); - return unitDevelopmentParentTab; + return advancementParentTab; } /** diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java index d124689932..579981ae2d 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/CampaignOptionsUtilities.java @@ -417,7 +417,7 @@ public CampaignOptionsGridBagConstraints(JPanel panel, @Nullable Integer anchor, panel.setLayout(new GridBagLayout()); this.anchor = Objects.requireNonNullElse(anchor, GridBagConstraints.NORTHWEST); - this.fill = Objects.requireNonNullElse(fill, GridBagConstraints.HORIZONTAL); + this.fill = Objects.requireNonNullElse(fill, GridBagConstraints.BOTH); this.insets = new Insets(5, 5, 5, 5); } From 01ae0aa7b56937c36fe63fe71cbfecb5146a7e1a Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 17 Oct 2024 14:34:41 -0500 Subject: [PATCH 116/117] Remove unused variables from AdvancementTab.java Deleted unused JLabel and JSpinner variables associated with XP cost multipliers to clean up the code. This reduces memory footprint and potentially improves maintainability and readability. --- .../src/mekhq/gui/panes/campaignOptions/AdvancementTab.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/AdvancementTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/AdvancementTab.java index 996507f120..c50cc85e64 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/AdvancementTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/AdvancementTab.java @@ -1,7 +1,5 @@ package mekhq.gui.panes.campaignOptions; -import mekhq.gui.panes.campaignOptions.CampaignOptionsUtilities.*; - import javax.swing.*; import java.awt.*; @@ -12,9 +10,6 @@ public class AdvancementTab { String name; //start XP Awards Tab - private JLabel lblXpCostMultiplier; - private JSpinner spnXpCostMultiplier; - private JPanel pnlTasks; private JLabel lblTaskXP; private JSpinner spnTaskXP; From 97ccf22c324ea3fee14e9d39f0842a65359cd6e2 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 17 Oct 2024 14:42:35 -0500 Subject: [PATCH 117/117] Added XP Cost Multiplier to Advancement Tab Included a new XP Cost Multiplier label and spinner in the AdvancementTab. Updated the layout to accommodate these new components and added corresponding entries in the resource file. --- .../NEWCampaignOptionsDialog.properties | 2 ++ .../panes/campaignOptions/AdvancementTab.java | 25 ++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties index cd2793f616..847aff377e 100644 --- a/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/NEWCampaignOptionsDialog.properties @@ -1356,6 +1356,8 @@ lblXpAwardsTabBody.text=Lorem ipsum odor amet, consectetuer adipiscing elit. Eui \ turpis semper morbi blandit sapien a. Duis netus nibh cras malesuada libero; bibendum hac. Gravida\ \ primis vivamus est pulvinar ut? Amet nostra ante a facilisis integer mus ad nisl. Semper proin\ \ porttitor dis taciti phasellus, quisque massa. Facilisi rutrum nulla magnis cubilia at est nullam +lblXpCostMultiplier.text=Advancement Multiplier +lblXpCostMultiplier.tooltip=PLACEHOLDER # createTasksPanel lblTasksPanel.text=Tasks diff --git a/MekHQ/src/mekhq/gui/panes/campaignOptions/AdvancementTab.java b/MekHQ/src/mekhq/gui/panes/campaignOptions/AdvancementTab.java index c50cc85e64..1299c5aa73 100644 --- a/MekHQ/src/mekhq/gui/panes/campaignOptions/AdvancementTab.java +++ b/MekHQ/src/mekhq/gui/panes/campaignOptions/AdvancementTab.java @@ -10,6 +10,9 @@ public class AdvancementTab { String name; //start XP Awards Tab + private JLabel lblXpCostMultiplier; + private JSpinner spnXpCostMultiplier; + private JPanel pnlTasks; private JLabel lblTaskXP; private JSpinner spnTaskXP; @@ -67,6 +70,9 @@ private void initialize() { } private void initializeXPAwardsTab() { + lblXpCostMultiplier = new JLabel(); + spnXpCostMultiplier = new JSpinner(); + pnlTasks = new JPanel(); lblTaskXP = new JLabel(); spnTaskXP = new JSpinner(); @@ -115,6 +121,10 @@ JPanel xpAwardsTab() { true); // Contents + lblXpCostMultiplier = new CampaignOptionsLabel("XpCostMultiplier"); + spnXpCostMultiplier = new CampaignOptionsSpinner("XpCostMultiplier", + 1, 0, 5, 0.05); + pnlTasks = createTasksPanel(); pnlScenarios = createScenariosPanel(); pnlAdministrators = createAdministratorsPanel(); @@ -130,15 +140,24 @@ JPanel xpAwardsTab() { layout.gridy++; layout.gridwidth = 1; - panel.add(pnlTasks, layout); + panel.add(lblXpCostMultiplier, layout); layout.gridx++; - panel.add(pnlMissions, layout); + panel.add(spnXpCostMultiplier, layout); layout.gridx = 0; layout.gridy++; + layout.gridwidth = 3; + panel.add(pnlTasks, layout); + layout.gridx += 3; layout.gridwidth = 1; + panel.add(pnlMissions, layout); + + layout.gridx = 0; + layout.gridy++; + layout.gridwidth = 3; panel.add(pnlScenarios, layout); - layout.gridx++; + layout.gridx += 3; + layout.gridwidth = 1; panel.add(pnlAdministrators, layout); // Create Parent Panel and return