Class CampaignGUI
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addStandardTab
(MHQTabType tab) Adds one of the built-in tabs to the gui, if it is not already present.void
Check to see if the command center tab is currently active and if not, color the tab.protected void
exportFinances
(FileType format, String dialogTitle, String filename) Exports Finances to a file (CSV, XML, etc.)protected void
exportPersonnel
(FileType format, String dialogTitle, String filename) Exports Personnel to a file (CSV, XML, etc.)protected void
exportPlanets
(FileType format, String dialogTitle, String filename) Exports Planets to a file (CSV, XML, etc.)protected void
exportUnits
(FileType format, String dialogTitle, String filename) Exports Units to a file (CSV, XML, etc.)void
focusOnMission
(int targetId) Focuses the UI on a specific mission by its ID.void
focusOnPerson
(UUID id) void
focusOnPerson
(Person person) void
focusOnScenario
(int targetId) Focuses the UI on a specific scenario by its ID.void
focusOnUnit
(UUID id) void
protected MekHQ
getFrame()
getTab
(MHQTabType tabType) int
getTabIndexByName
(String tabTitle) megamek.common.EnhancedTabbedPane
void
handle
(AssetEvent assetEvent) Handles updates related to assets within the campaign.void
handle
(AstechPoolChangedEvent astechPoolChangedEvent) Handles updates when the pool of available astechs changes.void
Handles changes in campaign funds due to a loan event.void
handle
(MedicPoolChangedEvent medicPoolChangedEvent) Handles updates when the pool of available medics changes.void
handle
(OptionsChangedEvent optionsChangedEvent) Processes changes in campaign options.void
handle
(TransactionEvent transactionEvent) Handles updates to campaign state following a transaction event.void
handle
(MHQOptionsChangedEvent mhqOptionsChangedEvent) Handles changes to general application options.void
handleDayEnding
(DayEndingEvent dayEndingEvent) Handles theDayEndingEvent
that is published immediately before a day ends in the campaign.void
handleLocationChanged
(LocationChangedEvent locationChangedEvent) Handles changes to the campaign's current location.void
handleMissionChanged
(MissionEvent missionEvent) Handles updates when a mission event occurs.void
handleNewDay
(NewDayEvent newDayEvent) Handles the transition to a new day in the campaign.void
handlePersonUpdate
(PersonEvent personEvent) Handles updates to personnel records.boolean
hasTab
(MHQTabType tabType) void
Opens the personnel market dialog to hire a person, using the appropriate market style based on campaign options.protected void
loadListFile
(boolean allowNewPilots) protected void
protected void
void
void
void
void
Deprecated, for removal: This API element is subject to removal in a future version.void
void
void
void
removeStandardTab
(MHQTabType tabType) Removes one of the built-in tabs from the gui.void
Removes a tab from the gui.void
removeTab
(CampaignGuiTab tab) Removes a tab from the gui.boolean
saveCampaign
(ActionEvent evt) static boolean
saveCampaign
(JFrame frame, Campaign campaign, File file) Attempts to save the given campaign to the given file.void
void
selectTech
(Unit unit, String desc, boolean ignoreMaintenance) Shows a dialog that lets the user select a tech for a task on a particular unitvoid
setCopyForceIcon
(StandardForceIcon copyForceIcon) void
setSelectedTab
(MHQTabType tabType) Sets the selected tab by itsMHQTabType
.void
void
void
showNews
(int id) void
boolean
void
void
void
undeployForce
(Force f, boolean killSubs) void
undeployUnit
(Unit u) Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
MAX_START_WIDTH
public static final int MAX_START_WIDTH- See Also:
-
MAX_START_HEIGHT
public static final int MAX_START_HEIGHT- See Also:
-
MAX_QUANTITY_SPINNER
public static final int MAX_QUANTITY_SPINNER- See Also:
-
-
Constructor Details
-
CampaignGUI
-
-
Method Details
-
getFrame
-
getApplication
-
getCampaign
-
getCampaignController
-
getIconPackage
-
getResourceMap
-
getTabMain
public megamek.common.EnhancedTabbedPane getTabMain() -
getReportHLL
-
getCopyForceIcon
- Returns:
- the force icon to paste
-
setCopyForceIcon
-
refreshDynamicButtons
Deprecated, for removal: This API element is subject to removal in a future version. -
refreshMarketButtonLabels
public void refreshMarketButtonLabels() -
getTab
-
getCommandCenterTab
-
getTOETab
-
getMapTab
-
getPersonnelTab
-
getWarehouseTab
-
hasTab
-
setSelectedTab
Sets the selected tab by itsMHQTabType
.- Parameters:
tabType
- The type of tab to select.
-
addStandardTab
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
Removes one of the built-in tabs from the gui.- Parameters:
tabType
- The tab to remove
-
removeTab
Removes a tab from the gui.- Parameters:
tab
- The tab to remove
-
removeTab
Removes a tab from the gui.- Parameters:
tabName
- The name of the tab to remove
-
showRetirementDefectionDialog
public boolean showRetirementDefectionDialog() -
showAwardEligibilityDialog
public void showAwardEligibilityDialog() -
focusOnUnit
-
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:
- Delegates to the
BriefingTab
'sBriefingTab.focusOnScenario(int)
method to select the specific scenario - 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
- Delegates to the
-
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:- Delegates to the
BriefingTab
'sBriefingTab.focusOnMission(int)
method to select the specific mission - 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
- Delegates to the
-
focusOnUnitInRepairBay
-
focusOnPerson
-
focusOnPerson
-
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
-
saveCampaign
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
-
selectTech
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 taskignoreMaintenance
- 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
Exports Planets to a file (CSV, XML, etc.)- Parameters:
format
-dialogTitle
-filename
-
-
exportPersonnel
Exports Personnel to a file (CSV, XML, etc.)- Parameters:
format
- file format to export todialogTitle
- title of the dialog framefilename
- file name to save to
-
exportUnits
Exports Units to a file (CSV, XML, etc.)- Parameters:
format
- file format to export todialogTitle
- title of the dialog framefilename
- file name to save to
-
exportFinances
Exports Finances to a file (CSV, XML, etc.)- Parameters:
format
- file format to export todialogTitle
- title of the dialog framefilename
- 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
-
undeployUnit
-
undeployForce
-
undeployForce
-
handleDayEnding
Handles theDayEndingEvent
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
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
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
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
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
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
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
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
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
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
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
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
-