Package mekhq.gui

Class CampaignGUI

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class CampaignGUI extends JPanel
The application's main frame.
See Also:
  • Field Details

  • Constructor Details

    • CampaignGUI

      public CampaignGUI(MekHQ app)
  • Method Details

    • getFrame

      public JFrame getFrame()
    • getApplication

      protected MekHQ getApplication()
    • getCampaign

      public Campaign getCampaign()
    • getCampaignController

      public CampaignController getCampaignController()
    • getIconPackage

      public IconPackage getIconPackage()
    • getResourceMap

      public ResourceBundle getResourceMap()
    • getTabMain

      public megamek.common.EnhancedTabbedPane getTabMain()
    • getReportHLL

      public ReportHyperlinkListener getReportHLL()
    • getCopyForceIcon

      @Nullable public StandardForceIcon getCopyForceIcon()
      Returns:
      the force icon to paste
    • setCopyForceIcon

      public void setCopyForceIcon(@Nullable StandardForceIcon copyForceIcon)
    • refreshDynamicButtons

      @Deprecated(since="0.50.07", forRemoval=true) public void refreshDynamicButtons()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • refreshMarketButtonLabels

      public void refreshMarketButtonLabels()
    • getTab

      @Nullable public CampaignGuiTab getTab(MHQTabType tabType)
    • getCommandCenterTab

      @Nullable public CommandCenterTab getCommandCenterTab()
    • getTOETab

      @Nullable public TOETab getTOETab()
    • getMapTab

      @Nullable public MapTab getMapTab()
    • getPersonnelTab

      @Nullable public PersonnelTab getPersonnelTab()
    • getWarehouseTab

      @Nullable public WarehouseTab getWarehouseTab()
    • hasTab

      public boolean hasTab(MHQTabType tabType)
    • setSelectedTab

      public void setSelectedTab(MHQTabType tabType)
      Sets the selected tab by its MHQTabType.
      Parameters:
      tabType - The type of tab to select.
    • addStandardTab

      public void addStandardTab(MHQTabType tab)
      Adds one of the built-in tabs to the gui, if it is not already present.
      Parameters:
      tab - The type of tab to add
    • removeStandardTab

      public void removeStandardTab(MHQTabType tabType)
      Removes one of the built-in tabs from the gui.
      Parameters:
      tabType - The tab to remove
    • removeTab

      public void removeTab(CampaignGuiTab tab)
      Removes a tab from the gui.
      Parameters:
      tab - The tab to remove
    • removeTab

      public void removeTab(String tabName)
      Removes a tab from the gui.
      Parameters:
      tabName - The name of the tab to remove
    • showRetirementDefectionDialog

      public boolean showRetirementDefectionDialog()
    • showAwardEligibilityDialog

      public void showAwardEligibilityDialog()
    • focusOnUnit

      public void focusOnUnit(UUID id)
    • focusOnScenario

      public void focusOnScenario(int targetId)
      Focuses the UI on a specific scenario by its ID.

      This method first retrieves the Briefing Room tab. If the tab exists, it:

      1. Delegates to the BriefingTab's BriefingTab.focusOnScenario(int) method to select the specific scenario
      2. Switches the main tab view to display the Briefing Room tab

      If the Briefing Room tab cannot be found, no action is taken.

      Parameters:
      targetId - The unique identifier of the scenario to focus on
      Since:
      0.50.05
    • focusOnMission

      public void focusOnMission(int targetId)
      Focuses the UI on a specific mission by its ID.

      This method first retrieves the BriefingTab tab. If the tab exists, it:

      1. Delegates to the BriefingTab's BriefingTab.focusOnMission(int) method to select the specific mission
      2. Switches the main tab view to display the Briefing Room tab

      If the Briefing Room tab cannot be found, no action is taken.

      Parameters:
      targetId - The unique identifier of the mission to focus on
      Since:
      0.50.05
    • focusOnUnitInRepairBay

      public void focusOnUnitInRepairBay(UUID id)
    • focusOnPerson

      public void focusOnPerson(Person person)
    • focusOnPerson

      public void focusOnPerson(UUID id)
    • showNews

      public void showNews(int id)
    • hirePersonMarket

      public void hirePersonMarket()
      Opens the personnel market dialog to hire a person, using the appropriate market style based on campaign options.

      If the personnel market is disabled in the campaign options, a deprecated PersonnelMarketDialog is displayed. Otherwise, the new personnel market dialog is shown according to the campaign's current market style.

      If no personnel market is enabled display the bulk hiring dialog, instead.

    • showContractMarket

      public void showContractMarket()
    • showUnitMarket

      public void showUnitMarket()
    • showPartsMarket

      public void showPartsMarket()
    • saveCampaign

      public boolean saveCampaign(ActionEvent evt)
    • saveCampaign

      public static boolean saveCampaign(JFrame frame, Campaign campaign, File file)
      Attempts to save the given campaign to the given file.
      Parameters:
      frame - The parent frame in which to display the error message. May be null.
    • refitUnit

      public void refitUnit(Refit r, boolean selectModelName)
    • selectTech

      @Nullable public UUID selectTech(Unit unit, String desc, boolean ignoreMaintenance)
      Shows a dialog that lets the user select a tech for a task on a particular unit
      Parameters:
      unit - The unit to be serviced, used to filter techs for skill on the unit.
      desc - The description of the task
      ignoreMaintenance - If true, ignores the time required for maintenance tasks when displaying the tech's time available.
      Returns:
      The ID of the selected tech, or null if none is selected.
    • exportPlanets

      protected void exportPlanets(FileType format, String dialogTitle, String filename)
      Exports Planets to a file (CSV, XML, etc.)
      Parameters:
      format -
      dialogTitle -
      filename -
    • exportPersonnel

      protected void exportPersonnel(FileType format, String dialogTitle, String filename)
      Exports Personnel to a file (CSV, XML, etc.)
      Parameters:
      format - file format to export to
      dialogTitle - title of the dialog frame
      filename - file name to save to
    • exportUnits

      protected void exportUnits(FileType format, String dialogTitle, String filename)
      Exports Units to a file (CSV, XML, etc.)
      Parameters:
      format - file format to export to
      dialogTitle - title of the dialog frame
      filename - file name to save to
    • exportFinances

      protected void exportFinances(FileType format, String dialogTitle, String filename)
      Exports Finances to a file (CSV, XML, etc.)
      Parameters:
      format - file format to export to
      dialogTitle - title of the dialog frame
      filename - file name to save to
    • loadListFile

      protected void loadListFile(boolean allowNewPilots)
    • loadPersonFile

      protected void loadPersonFile()
    • savePersonFile

      public void savePersonFile()
    • loadPartsFile

      protected void loadPartsFile()
    • savePartsFile

      public void savePartsFile()
    • checkDailyLogNag

      public void checkDailyLogNag()
      Check to see if the command center tab is currently active and if not, color the tab. Should be called when items are added to daily report log panel and user is not on the command center tab in order to draw attention to it
    • refreshAllTabs

      public void refreshAllTabs()
    • refreshLab

      public void refreshLab()
    • refreshCalendar

      public void refreshCalendar()
    • refreshLocation

      public void refreshLocation()
    • getTabIndexByName

      public int getTabIndexByName(String tabTitle)
    • undeployUnit

      public void undeployUnit(Unit u)
    • undeployForce

      public void undeployForce(Force f)
    • undeployForce

      public void undeployForce(Force f, boolean killSubs)
    • handleDayEnding

      public void handleDayEnding(DayEndingEvent dayEndingEvent)
      Handles the DayEndingEvent that is published immediately before a day ends in the campaign.

      This method is subscribed to day-ending events and implements logic that can block or allow the end of the day, depending on the current campaign state and conditions. If certain criteria are met (such as outstanding loans, faction issues, overdue scenarios, or random retirement prompts), the event will be cancelled—preventing day transition.

      • Checks if daily nag dialogs should be shown and blocks day end if needed.
      • Blocks new day progression for overdue loans, invalid faction status, or due scenarios.
      • Handles the random retirement option, prompting the user and conditionally blocking end-of-day if required.

      Important: This method is not directly evoked, so IDEA will tell you it has no uses. IDEA is wrong.

      Parameters:
      dayEndingEvent - the event signaling the end of the day; may be canceled by this handler to halt day progression
    • handleLocationChanged

      public void handleLocationChanged(LocationChangedEvent locationChangedEvent)
      Handles changes to the campaign's current location.

      Invokes an update to ensure the location information is current within the user interface and data model.

      Important: This method is not directly evoked, so IDEA will tell you it has no uses. IDEA is wrong.

      Parameters:
      locationChangedEvent - the event indicating that the campaign location has changed
    • handleMissionChanged

      public void handleMissionChanged(MissionEvent missionEvent)
      Handles updates when a mission event occurs.

      Refreshes the availability of parts to ensure inventory and options reflect the latest mission context.

      Important: This method is not directly evoked, so IDEA will tell you it has no uses. IDEA is wrong.

      Parameters:
      missionEvent - the event signaling a mission change
    • handlePersonUpdate

      public void handlePersonUpdate(PersonEvent personEvent)
      Handles updates to personnel records.

      If a logistics administrator has been updated, recalculates AtB parts availability, ensuring that changes in roles are properly reflected in inventory calculations.

      Important: This method is not directly evoked, so IDEA will tell you it has no uses. IDEA is wrong.

      Parameters:
      personEvent - the event containing updates related to a person in the campaign
    • handleNewDay

      public void handleNewDay(NewDayEvent newDayEvent)
      Handles the transition to a new day in the campaign.

      Refreshes the calendar, location, funds, parts availability, and all relevant UI tabs to ensure the user interface and data are up to date at the beginning of a new day.

      Important: This method is not directly evoked, so IDEA will tell you it has no uses. IDEA is wrong.

      Parameters:
      newDayEvent - the event signalling that a new day has started
    • handle

      public void handle(OptionsChangedEvent optionsChangedEvent)
      Processes changes in campaign options.

      Updates the visibility and availability of UI tabs and menu items based on the new campaign settings. Also triggers a refresh of all tabs and schedules updates for funds and parts availability.

      Important: This method is not directly evoked, so IDEA will tell you it has no uses. IDEA is wrong.

      Parameters:
      optionsChangedEvent - the event containing the updated options
    • handle

      public void handle(TransactionEvent transactionEvent)
      Handles updates to campaign state following a transaction event.

      Schedules an update to the funds and refreshes parts availability to reflect the new state after a transaction has occurred.

      Important: This method is not directly evoked, so IDEA will tell you it has no uses. IDEA is wrong.

      Parameters:
      transactionEvent - the event signaling the completion of a transaction
    • handle

      public void handle(LoanEvent loanEvent)
      Handles changes in campaign funds due to a loan event.

      Schedules a funds update and refreshes parts availability after a loan transaction is processed.

      Important: This method is not directly evoked, so IDEA will tell you it has no uses. IDEA is wrong.

      Parameters:
      loanEvent - the event representing a loan-related action
    • handle

      public void handle(AssetEvent assetEvent)
      Handles updates related to assets within the campaign.

      Schedules a funds update to ensure the campaign's financial state is current when assets change.

      Important: This method is not directly evoked, so IDEA will tell you it has no uses. IDEA is wrong.

      Parameters:
      assetEvent - the event indicating a change in assets
    • handle

      public void handle(AstechPoolChangedEvent astechPoolChangedEvent)
      Handles updates when the pool of available astechs changes.

      Refreshes the temporary astech pool, updating the related UI and game state.

      Important: This method is not directly evoked, so IDEA will tell you it has no uses. IDEA is wrong.

      Parameters:
      astechPoolChangedEvent - the event indicating a change in the astech pool
    • handle

      public void handle(MedicPoolChangedEvent medicPoolChangedEvent)
      Handles updates when the pool of available medics changes.

      Refreshes the temporary medic pool, updating the related UI and game state.

      Important: This method is not directly evoked, so IDEA will tell you it has no uses. IDEA is wrong.

      Parameters:
      medicPoolChangedEvent - the event indicating a change in the medic pool
    • handle

      public void handle(MHQOptionsChangedEvent mhqOptionsChangedEvent)
      Handles changes to general application options.

      Updates the visibility of the company generator menu item according to the new option settings.

      Important: This method is not directly evoked, so IDEA will tell you it has no uses. IDEA is wrong.

      Parameters:
      mhqOptionsChangedEvent - the event containing the updated general options