Class GeneralPage
- 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 Summary
ConstructorsConstructorDescriptionGeneralPage(Campaign campaign, JFrame frame, CampaignOptionsDialog.CampaignOptionsDialogMode mode) -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyCampaignOptionsToCampaign(boolean isStartUp, boolean isSaveAction) Applies the updated campaign options from the general page's UI components to theCampaign.Creates the UI components displayed in the general page.getDate()Retrieves the currently selected faction.voidLoads the values from the current campaign'sCampaignOptionsand updates the user interface components.voidloadValuesFromCampaignOptions(LocalDate presetDate, Faction presetFaction) Loads values from the specifiedCampaignOptions, date, and faction into the user interface components.
-
Constructor Details
-
GeneralPage
public GeneralPage(@Nonnull Campaign campaign, JFrame frame, CampaignOptionsDialog.CampaignOptionsDialogMode mode) - Parameters:
campaign- TheCampaignassociated with this page, which contains the core game data.frame- The parentJFrameused to display this page.mode- TheCampaignOptionsDialog.CampaignOptionsDialogModeenum determining what state caused the dialog to be triggered.
-
-
Method Details
-
getDate
- Returns:
- the currently selected date
-
getFaction
Retrieves the currently selected faction.If no faction is selected, the method defaults to returning the "MERC" faction.
- Returns:
- the
Factionobject representing the selected faction, or the "MERC" faction if no selection is made.
-
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
JPanelcontaining the general page content.
-
loadValuesFromCampaignOptions
public void loadValuesFromCampaignOptions()Loads the values from the current campaign'sCampaignOptionsand 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 tonull. -
loadValuesFromCampaignOptions
public void loadValuesFromCampaignOptions(@Nullable LocalDate presetDate, @Nullable Faction presetFaction) Loads values from the specifiedCampaignOptions, 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).
-
applyCampaignOptionsToCampaign
public void applyCampaignOptionsToCampaign(boolean isStartUp, boolean isSaveAction) Applies the updated campaign options from the general page's UI components to theCampaign. 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.
-