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.
    • 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()
    • getSelectedCoords

      public StratConCoords getSelectedCoords()
    • actionPerformed

      public void actionPerformed(ActionEvent evt)
      Handles action events triggered by various StratCon-related commands from the right-click context menu. This method processes user interactions to update the game state, scenarios, facilities, and UI elements based on the selected command and inputs from the context menu.

      The supported commands and their effects are as follows:

      • RIGHT_CLICK_COMMAND_MANAGE_FORCES: Displays the force management UI for the selected coordinates.
        • If no scenario exists at the selected coordinates, the force management UI is directly displayed.
        • If a scenario exists, it only displays the UI if the scenario is unresolved.
      • RIGHT_CLICK_COMMAND_MANAGE_SCENARIO: Displays the scenario wizard with the current scenario at the selected coordinates if the scenario's state is PRIMARY_FORCES_COMMITTED.
      • RIGHT_CLICK_COMMAND_REVEAL_TRACK: Toggles the "GM revealed" state for the current track and updates the menu text to reflect the state ("Hide Track" or "Reveal Track").
      • RIGHT_CLICK_COMMAND_STICKY_FORCE: Toggles the sticky force assignment for a given force ID at the selected track. When toggled:
      • -- If selected, the force is added to the track as sticky.
      • -- If deselected, the force is removed from the track's sticky forces.
      • RIGHT_CLICK_COMMAND_REMOVE_FACILITY: Deletes the facility present at the selected coordinates.
      • RIGHT_CLICK_COMMAND_CAPTURE_FACILITY: Changes the ownership of the facility at the selected coordinates to a different faction or player, as per the rules defined in StratConRulesManager.
      • RIGHT_CLICK_COMMAND_ADD_FACILITY: Adds a new facility to the selected coordinates. The facility's properties (visibility, type, etc.) are copied from the provided source facility.
      • RIGHT_CLICK_COMMAND_REMOVE_SCENARIO: Deletes the currently selected scenario from the campaign.
      Specified by:
      actionPerformed in interface ActionListener
      Parameters:
      evt - the ActionEvent representing the user's action. Contains information about the triggering source and command (e.g., which menu item was selected).

      Behavior:

      • The method retrieves the StratConCoords currently selected by the user, and performs actions based on the provided command string in the event.
      • The scenarios, forces, and facilities of the currentTrack are modified based on the command type, and updates are visually reflected in the UI.
      • If a UI-related command is processed (e.g., displaying the scenario wizard or force assignment UI), the appropriate UI components are updated and made visible to the user.

      General Information: If no valid StratConCoords are selected at the time of the event, the method will terminate with no further action. Certain commands (e.g., RIGHT_CLICK_COMMAND_REVEAL_TRACK, RIGHT_CLICK_COMMAND_ADD_FACILITY) require valid coordinates or source properties to execute successfully.

      If no specific actions from the above list are matched (no corresponding `case`), the method performs no effect.

    • getPreferredSize

      public Dimension getPreferredSize()
      Overrides:
      getPreferredSize in class JComponent
    • isCommitForces

      public boolean isCommitForces()
    • setCommitForces

      public void setCommitForces(boolean commitForces)