protected class NewGameMenu.PlayerPanel
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.awt.geom.Path2D |
addAI
Bounds of the add AI button.
|
private java.awt.geom.Path2D |
addPlayer
Bounds of the add (human) player button.
|
private ComboBox<AIRegistry> |
ai
Combo box used to configure an AI.
|
private static double |
BUTTON_INSET
Border inset from the outside of the button.
|
protected static double |
CONTENT_HEIGHT
Height of the panel content.
|
protected static double |
CONTENT_WIDTH
Width of the panel content.
|
private static double |
HEIGHT
The height of the panels.
|
private java.awt.Image |
icon
Current panel icon.
|
private TextField |
name
Text field used to configure a human player.
|
private java.awt.geom.Path2D |
remove
Bounds of the remove button.
|
private Theme.PlayerTheme |
theme
Panel theme.
|
private static double |
WIDTH
The width of the panels.
|
Modifier | Constructor and Description |
---|---|
protected |
PlayerPanel(Theme.PlayerTheme theme)
Constructs a new player panel with the given theme.
|
Modifier and Type | Method and Description |
---|---|
protected java.util.Optional<Player> |
getPlayer()
Gets the configured player for this panel if it exists.
|
protected void |
handleMouseClick(java.awt.geom.Point2D loc)
Handles a mouse click on this component.
|
protected boolean |
hasPlayer()
Checks if this panel has a configured player.
|
private void |
render(java.awt.Graphics2D g,
double x,
double y,
java.awt.geom.Point2D mouseLoc)
Renders this panel at the given location.
|
private void |
renderAddButtons(java.awt.Graphics2D g,
double x,
double y,
java.awt.geom.Point2D mouseLoc)
Renders the add player/AI buttons at the given location.
|
protected void |
renderRemoveButton(java.awt.Graphics2D g,
double x,
double y,
java.awt.geom.Point2D mouseLoc)
Renders the remove button at the given location.
|
protected void |
setHuman(java.lang.String name)
Sets the player currently being configured to a human
and activates the corresponding UI elements.
|
private static final double WIDTH
private static final double HEIGHT
private static final double BUTTON_INSET
protected static final double CONTENT_WIDTH
protected static final double CONTENT_HEIGHT
private java.awt.geom.Path2D addPlayer
private java.awt.geom.Path2D addAI
private Theme.PlayerTheme theme
private TextField name
private ComboBox<AIRegistry> ai
private java.awt.geom.Path2D remove
private java.awt.Image icon
protected PlayerPanel(Theme.PlayerTheme theme)
theme
- The panel theme.protected boolean hasPlayer()
protected java.util.Optional<Player> getPlayer()
private void render(java.awt.Graphics2D g, double x, double y, java.awt.geom.Point2D mouseLoc)
g
- The graphics context to use.x
- The x coordinate of the top left corner.y
- The y coordinate of the top left corner.mouseLoc
- The current cursor location.protected void setHuman(java.lang.String name)
name
- The player name to use or null
to use the default name.protected void handleMouseClick(java.awt.geom.Point2D loc)
loc
- The location that was clicked.protected void renderRemoveButton(java.awt.Graphics2D g, double x, double y, java.awt.geom.Point2D mouseLoc)
g
- The graphics context to use.x
- The x coordinate of the top left corner.y
- The y coordinate of the top left corner.mouseLoc
- The current cursor location.private void renderAddButtons(java.awt.Graphics2D g, double x, double y, java.awt.geom.Point2D mouseLoc)
g
- The graphics context to use.x
- The x coordinate of the top left corner.y
- The y coordinate of the top left corner.mouseLoc
- The current cursor location.