Class ImmersiveDialogCore
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
,RootPaneContainer
,WindowConstants
- Direct Known Subclasses:
DefectionOffer
,GrayMondayDialog
,ImmersiveDialogSimple
,MercenaryAuctionDialog
,MissionEndPrisonerDefectorDialog
,MissionEndPrisonerDialog
,NewsDialog
,PrisonerEscapeeScenarioDialog
,PrisonerEventDialog
,PrisonerEventResultsDialog
,PrisonerRansomEventDialog
,PrisonerWarningDialog
,PrisonerWarningResultsDialog
,ReplacementLimbDialog
,VocationalExperienceAwardDialog
It allows displaying one or more speakers in a dialog alongside a central message, optional out-of-character notes, and UI buttons for user interaction.
The dialog is flexible in terms of panel layout and width adjustments, allowing for dynamic configurations based on the input parameters.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
Represents a label-tooltip pair for constructing UI buttons.Nested classes/interfaces inherited from class javax.swing.JDialog
JDialog.AccessibleJDialog
Nested classes/interfaces inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityType
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow, Window.Type
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 String
protected static final int
static final String
static final String
static final String
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
Fields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPE
Fields inherited from class java.awt.Component
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
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
-
Constructor Summary
ConstructorsConstructorDescriptionImmersiveDialogCore
(Campaign campaign, Person leftSpeaker, Person rightSpeaker, String centerMessage, List<ImmersiveDialogCore.ButtonLabelTooltipPair> buttons, String outOfCharacterMessage, Integer centerWidth, boolean isVerticalLayout, JPanel supplementalPanel, ImageIcon imageIcon, boolean isModal) Constructs and initializes an immersive dialog with configurable layouts, speakers, actions, and messages. -
Method Summary
Modifier and TypeMethodDescriptionprotected JPanel
buildSpeakerPanel
(Person speaker, Campaign campaign) Builds a panel for displaying a speaker's image, name, and role.int
Retrieves the current index of the combo box choice.int
Retrieves the user's selected dialog choice.protected int
Retrieves the padding value defined in this object.static StringBuilder
getSpeakerDescription
(Campaign campaign, Person speaker, String speakerName) Assembles the speaker description based on the provided speaker and campaign details.static ImageIcon
getSpeakerIcon
(Campaign campaign, Person speaker) Retrieves the speaker's icon for dialogs.int
Retrieves the current value of the spinner.static void
handleImmersiveHyperlinkClick
(JDialog parent, Campaign campaign, String reference) Handles hyperlink clicks from HTML content dialog.protected void
Handles actions triggered by hyperlink events, such as clicks on hyperlinks.protected JPanel
populateButtonPanel
(List<ImmersiveDialogCore.ButtonLabelTooltipPair> buttons, boolean isVerticalLayout, JPanel supplementalPanel) Populates a button panel with a list of buttons, each defined by a label and an optional tooltip.void
setComboBoxChoiceIndex
(int comboBoxChoiceIndex) Sets a new index for the combo box choice.void
setDialogChoice
(int dialogChoice) Sets the dialog choice for the current object.void
setSpinnerValue
(int spinnerValue) Sets a new value for the spinner.protected void
setTitle()
Sets the title of the dialog window using localized text.Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
Methods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, setVisible, show, toBack
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, toFront
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
GLOSSARY_COMMAND_STRING
- See Also:
-
PERSON_COMMAND_STRING
- See Also:
-
MISSION_COMMAND_STRING
- See Also:
-
SCENARIO_COMMAND_STRING
- See Also:
-
IMAGE_WIDTH
protected static final int IMAGE_WIDTH
-
-
Constructor Details
-
ImmersiveDialogCore
public ImmersiveDialogCore(Campaign campaign, @Nullable Person leftSpeaker, @Nullable Person rightSpeaker, String centerMessage, List<ImmersiveDialogCore.ButtonLabelTooltipPair> buttons, @Nullable String outOfCharacterMessage, @Nullable Integer centerWidth, boolean isVerticalLayout, @Nullable JPanel supplementalPanel, @Nullable ImageIcon imageIcon, boolean isModal) Constructs and initializes an immersive dialog with configurable layouts, speakers, actions, and messages.This dialog is designed to provide a rich, immersive interface featuring optional speakers on the left and right, a central message panel with configurable width, a spinner panel, and a list of actionable buttons. An optional out-of-character message can also be displayed below the buttons.
- Parameters:
campaign
- TheCampaign
instance tied to the dialog, providing contextual information.leftSpeaker
- Optional left-sidePerson
; usenull
if no left speaker is present.rightSpeaker
- Optional right-sidePerson
; usenull
if no right speaker is present.centerMessage
- The mainString
message displayed in the center panel of the dialog.buttons
- AList
ofImmersiveDialogCore.ButtonLabelTooltipPair
instances representing actions available in the dialog (displayed as buttons). The default option is used if the user closes or cancels the dialog.outOfCharacterMessage
- An optionalString
message displayed below the buttons; usenull
if not applicable.centerWidth
- An optional width for the center panel; uses the default value ifnull
.isVerticalLayout
- Aboolean
determining the button layout:true
for vertical stacking,false
for horizontal layout.supplementalPanel
- An optionalJPanel
containing aJSpinner
and/or aMMComboBox
to be displayed in the center panel; usenull
if not applicable.
-
-
Method Details
-
getDialogChoice
public int getDialogChoice()Retrieves the user's selected dialog choice.Usage: This allows us to keep function code out of the GUI element, making it far easier to test what's happening for any given option selection. Create the dialog, as normal, then fetch whatever decision the user made and perform any code actions required.
- Returns:
- An integer representing the index of the button selected by the user. If the dialog is closed without
selection, this will return the
defaultChoiceIndex
defined during construction.
-
setDialogChoice
public void setDialogChoice(int dialogChoice) Sets the dialog choice for the current object.- Parameters:
dialogChoice
- The integer value representing the dialog choice to set.
-
getSpinnerValue
public int getSpinnerValue()Retrieves the current value of the spinner.Note: will return 0 if the dialog does not contain a
JSpinner
in the supplemental panel.- Returns:
- The integer value of the spinner.
-
setSpinnerValue
public void setSpinnerValue(int spinnerValue) Sets a new value for the spinner.Note: will return 0 if the dialog does not contain a
MMComboBox
in the supplemental panel.- Parameters:
spinnerValue
- The integer value to set for the spinner.
-
getComboBoxChoiceIndex
public int getComboBoxChoiceIndex()Retrieves the current index of the combo box choice.- Returns:
- The integer value representing the current selected index of the combo box.
-
setComboBoxChoiceIndex
public void setComboBoxChoiceIndex(int comboBoxChoiceIndex) Sets a new index for the combo box choice.- Parameters:
comboBoxChoiceIndex
- The integer value to set as the combo box's selected index.
-
getPADDING
protected int getPADDING()Retrieves the padding value defined in this object.- Returns:
- The padding value as an integer.
-
setTitle
protected void setTitle()Sets the title of the dialog window using localized text. -
handleImmersiveHyperlinkClick
public static void handleImmersiveHyperlinkClick(JDialog parent, Campaign campaign, String reference) Handles hyperlink clicks from HTML content dialog.This method processes the provided hyperlink reference to determine the type of command and executes the appropriate action. It supports commands for displaying a glossary entry or focusing on a specific person in the campaign.
Supported Commands:GLOSSARY_COMMAND_STRING
: Opens a newGlossaryDialog
to display the referenced glossary entry.PERSON_COMMAND_STRING
: Focuses on a specific person in the campaign using their unique identifier (UUID). If using this, you will need to ensure your dialog has modal set tofalse
If the command is not recognized, no action is performed.
- Parameters:
parent
- The parentJDialog
instance to associate with the new dialog, if created.campaign
- TheCampaign
instance that contains application and campaign data.reference
- The hyperlink reference used to determine the command and additional information (e.g., a specific glossary term key or a person's UUID).
-
hyperlinkEventListenerActions
Handles actions triggered by hyperlink events, such as clicks on hyperlinks. This method identifies when the event type isHyperlinkEvent.EventType.ACTIVATED
and processes the event accordingly by delegating to the specified handler.- Parameters:
evt
- theHyperlinkEvent
which contains details about the hyperlink interaction. It could represent events such as entering, exiting, or activating a hyperlink.
-
populateButtonPanel
protected JPanel populateButtonPanel(List<ImmersiveDialogCore.ButtonLabelTooltipPair> buttons, boolean isVerticalLayout, @Nullable JPanel supplementalPanel) Populates a button panel with a list of buttons, each defined by a label and an optional tooltip.This method dynamically creates buttons based on the provided
ImmersiveDialogCore.ButtonLabelTooltipPair
objects. Each button is added to the specifiedJPanel
(`buttonPanel`) and arranged according to the selected layout style (`isVerticalLayout`).- Parameters:
buttons
- AList
ofImmersiveDialogCore.ButtonLabelTooltipPair
instances, where each pair defines the label and tooltip for a button.isVerticalLayout
- Aboolean
value indicating the layout style:true
for vertical stacking,false
for horizontal arrangement.
-
buildSpeakerPanel
Builds a panel for displaying a speaker's image, name, and role.This method creates a vertically stacked panel that includes the person's icon, title, and any additional descriptive information (e.g., roles, forces, or campaign affiliations).
- Parameters:
speaker
- The character shown in the dialog, can benull
for no speakercampaign
- The current campaign.- Returns:
- A
JPanel
forming the speaker's dialog box.
-
getSpeakerDescription
public static StringBuilder getSpeakerDescription(Campaign campaign, Person speaker, String speakerName) Assembles the speaker description based on the provided speaker and campaign details.The description includes:
- The speaker's title and roles (both primary and secondary, if applicable).
- The force associated with the speaker.
- A fallback to the campaign name if the speaker is not available.
- Parameters:
campaign
- The current campaign.speaker
- ThePerson
representing the speaker, ornull
to use fallback data.speakerName
- The name/title to use for the speaker if one exists.- Returns:
- A
StringBuilder
containing the formatted HTML description of the speaker.
-
getSpeakerIcon
@Nullable public static ImageIcon getSpeakerIcon(@Nullable Campaign campaign, @Nullable Person speaker) Retrieves the speaker's icon for dialogs. If no speaker is supplied, the faction icon for the campaign is returned instead.
-