Package mekhq.gui

Class StratConPanel

All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class StratConPanel extends JPanel implements ActionListener
This panel handles AtB-StratCon GUI interactions with a specific scenario track.
See Also:
  • Field Details

  • Constructor Details

    • StratConPanel

      public StratConPanel(CampaignGUI gui, JLabel infoArea)
      Constructs a StratConPanel instance, given a parent campaign GUI and a pointer to an info area.
  • Method Details

    • selectTrack

      public void selectTrack(StratConCampaignState campaignState, StratConTrackState track)
      Handler for when a specific track is selected - switches rendering to that track.
    • scoutCurrentSector

      public void scoutCurrentSector()
      Scouts (permanently reveals) every hex in the currently selected sector, then repaints. Unlike the GM sector reveal, this marks the hexes as revealed, so their contents stay visible afterward - and, as with real scouting, every point of interest found is revealed and its type's reveal hook fires.
    • regenerateCurrentSector

      public void regenerateCurrentSector()
      GM tool: clears the current sector and regenerates its terrain (and cities/roads), then repaints. Scenarios, facilities, and assigned forces are left in place.
    • openTerrainPaintDialog

      public void openTerrainPaintDialog()
      GM tool: opens the terrain palette, putting the map into paint mode until the palette is closed.
    • resizeSector

      public void resizeSector()
      GM tool: prompts for new sector dimensions and applies them, growing or shrinking at the right and bottom edges. Warns first when the new size would displace anything.
    • setPaintTerrain

      public void setPaintTerrain(String terrain)
      Sets the terrain the brush lays down. Called by the terrain palette.
    • setPaintBrushRadius

      public void setPaintBrushRadius(int radius)
      Sets the brush radius in hexes: 0 paints a single hex, 1 paints it and its neighbors, and so on.
    • isPaintingTerrain

      public boolean isPaintingTerrain()
      Named for the terrain brush rather than isPainting, which would sit confusingly beside the package-private JComponent.isPainting this panel inherits but cannot override - a reader inside the painting code would have no way to tell the two apart.
      Returns:
      true while the terrain palette is open and clicks paint rather than select.
    • exitPaintMode

      public void exitPaintMode()
      Leaves paint mode, restoring normal selection and panning. Called when the terrain palette closes.
    • getTerrainImage

      public BufferedImage getTerrainImage(String terrainType)
      Returns:
      the map sprite for a terrain type, for the terrain palette to render alongside the name.
    • resetSectorFog

      public void resetSectorFog()
      GM tool: un-reveals every hex in the current sector so scouting can be re-tested, then repaints. Open water is re-revealed, since it never holds fog of war. Points of interest are hidden again too, so they can be found afresh.
    • toggleHiddenObjects

      public void toggleHiddenObjects()
      Toggles the current sector's "GM revealed" state, which shows or hides otherwise-hidden objects (cloaked scenarios, invisible facilities, and unscouted hexes). Formerly the "Reveal/Hide Sector" right-click item.
    • paintComponent

      public void paintComponent(Graphics g)
      Renders the panel, hexes, forces, facilities and all that.
      Overrides:
      paintComponent in class JComponent
    • mouseReleasedHandler

      public void mouseReleasedHandler(MouseEvent e)
      Event handler for when a mouse button is released.
    • getSelectedScenario

      public StratConScenario getSelectedScenario()
    • getCurrentTrack

      public StratConTrackState getCurrentTrack()
    • setCurrentTrack

      public void setCurrentTrack(StratConTrackState track)
    • getSelectedCoords

      public StratConCoords getSelectedCoords()
    • setSelectedCoords

      public void setSelectedCoords(StratConCoords coords)
    • openDeploymentWizard

      public void openDeploymentWizard(StratConCampaignState campaignState, @Nullable StratConScenario scenario)
      Opens the redesigned deployment wizard for the currently selected hex, on the page appropriate to the scenario's state: the Primary page for a bare hex or an unresolved scenario (deploying primary forces), or the Reinforce page for a scenario whose primary forces are already committed (managing reinforcements, auxiliaries, and utility). Official challenges restrict the primary pick to a single force.

      A single wizard instance is reused, so repeatedly choosing "Manage Deployment" re-shows and re-populates the same window instead of stacking new ones.

      Parameters:
      campaignState - the current StratCon campaign state
      scenario - the scenario on the selected hex, or null if there is none
      Since:
      0.51.01
    • actionPerformed

      public void actionPerformed(ActionEvent evt)
      Handles action events triggered by StratCon commands from the right-click context menu, dispatching on the event's action command. Each command reads the currently selected StratConCoords and updates the currentTrack's scenarios, forces, facilities, or cities accordingly, then repaints. If no hex is selected, or the command matches no case, the method does nothing.

      The supported commands are:

      • MANAGE_FORCES / MANAGE_SCENARIO - open the deployment wizard via openDeploymentWizard(mekhq.campaign.digitalGM.stratCon.StratConCampaignState, mekhq.campaign.digitalGM.stratCon.StratConScenario), on the Primary page (bare hex or unresolved scenario) or the Reinforce page (committed scenario) as appropriate.
      • STICKY_FORCE - toggles whether a force remains deployed on the track.
      • REMOVE_FACILITY / CAPTURE_FACILITY / ADD_FACILITY - GM facility edits. Adding or removing a facility recomputes roads; capturing deliberately does not.
      • ADD_CITY / REMOVE_CITY - GM city edits, each recomputing roads.
      • ADD_POINT_OF_INTEREST / REMOVE_POINT_OF_INTEREST / TOGGLE_POINT_OF_INTEREST_REVEALED / SET_POINT_OF_INTEREST_OWNER / RESOLVE_POINT_OF_INTEREST - GM point of interest edits. Points of interest do not affect roads, so none of these recomputes them.
      • REMOVE_SCENARIO - removes the selected scenario from the campaign.
      • RESET_DEPLOYMENT - resets the selected scenario.
      Specified by:
      actionPerformed in interface ActionListener
      Parameters:
      evt - the triggering action event; its action command selects the branch and its source carries any per-item data (e.g. the sticky force ID or the facility to add)
    • getPreferredSize

      public Dimension getPreferredSize()
      Overrides:
      getPreferredSize in class JComponent