Class GeneralPage

java.lang.Object
mekhq.gui.campaignOptions.contents.GeneralPage

public class GeneralPage extends Object
Represents a page within the campaign options UI that allows the user to configure general campaign settings. This includes options for:
  • Configuring the campaign name
  • Setting the faction and faction-related options
  • Adjusting reputation and manual unit rating modifiers
  • Specifying the campaign start date
  • Choosing a camouflage pattern and unit icon

This class extends the user interface features provided by AbstractMHQTabbedPane.

  • Constructor Details

  • Method Details

    • getDate

      @Nonnull public LocalDate getDate()
      Returns:
      the currently selected date
    • getFaction

      public Faction getFaction()
      Retrieves the currently selected faction.

      If no faction is selected, the method defaults to returning the "MERC" faction.

      Returns:
      the Faction object representing the selected faction, or the "MERC" faction if no selection is made.
    • createGeneralPage

      @Nonnull public JPanel createGeneralPage()
      Creates the UI components displayed in the general page.

      The general page includes various configurable fields and panels:

      • An editable text field for setting the campaign name
      • A dropdown for selecting the campaign's faction
      • Controls for managing reputation and manual rating modifiers
      • Date selection associated with the campaign
      • Buttons for choosing camouflage and unit icons
      Returns:
      A JPanel containing the general page content.
    • loadValuesFromCampaignOptions

      public void loadValuesFromCampaignOptions()
      Loads the values from the current campaign's CampaignOptions and updates the user interface components.

      This is a convenience method that uses the default campaign options, default date, and default faction to populate the relevant data fields in the user interface. It essentially delegates the work to the overloaded method loadValuesFromCampaignOptions(LocalDate, Faction) with all parameters set to null.

    • loadValuesFromCampaignOptions

      public void loadValuesFromCampaignOptions(@Nullable LocalDate presetDate, @Nullable Faction presetFaction)
      Loads values from the specified CampaignOptions, date, and faction into the user interface components.

      This method updates the UI fields (e.g., text fields, combo boxes, and buttons) with the corresponding values from the provided options or defaults to the current campaign's settings if no presets are provided.

      Specific actions include:

      • Setting the campaign name and faction in the respective fields.
      • Updating the unit rating method and manual unit rating modifier based on the campaign options.
      • Synchronizing the date to the UI, accounting for a preset date if provided.
      • Setting the camouflage pattern and unit icon to align with the campaign's default or custom configuration.
      • Performing required UI updates (e.g., repainting date labels).

      Parameters:
      presetDate - Optional LocalDate to be used as the active date. If null, the campaign's current date is used.
      presetFaction - Optional Faction to be used in the faction selection field. If null, the campaign's default faction is used.
    • applyCampaignOptionsToCampaign

      public void applyCampaignOptionsToCampaign(boolean isStartUp, boolean isSaveAction)
      Applies the updated campaign options from the general page's UI components to the Campaign. This method ensures that any changes made in the UI are reflected in the campaign's settings.
      Parameters:
      isStartUp - A boolean indicating if the campaign is in a startup state.
      isSaveAction - A boolean indicating if this is a save action.