public class JXCWindowRenderer
extends java.lang.Object
Gui
instance into a Frame
.Constructor and Description |
---|
JXCWindowRenderer(@NotNull MouseTracker mouseTracker,
@NotNull CrossfireServerConnection crossfireServerConnection,
@Nullable java.io.Writer debugScreen)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
@Nullable GUIText |
activateCommandInput()
Activates the command input text field.
|
static @Nullable GUIText |
activateCommandInput(@NotNull Gui gui)
Returns the first command text field of a gui and make it active.
|
void |
addGuiStateListener(@NotNull RendererGuiStateListener listener)
Adds a gui state listener to be notified about
rendererGuiState
changes. |
void |
clearGUI(@NotNull Gui gui)
Sets a gui to display and clears the display.
|
boolean |
closeDialog(@NotNull Gui dialog)
Closes a dialog.
|
boolean |
deactivateCommandInput()
Deactivates the command input text field.
|
void |
endRendering()
Ends rendering and reverts the display settings.
|
@Nullable Buffer |
getActiveMessageBuffer()
Returns the active message buffer.
|
@NotNull RendererGuiState |
getGuiState()
Returns the current gui state.
|
@NotNull java.lang.Iterable<Gui> |
getOpenDialogs()
Returns all open dialogs in reverse painting order; the first element is
the top-most dialog.
|
int |
getWindowHeight()
Returns the height of the client area.
|
int |
getWindowWidth()
Returns the width of the client area.
|
boolean |
handleKeyPress(@NotNull KeyEvent2 e)
Dispatches a key press
KeyEvent . |
boolean |
isDialogOpen(@NotNull Gui dialog)
Returns whether a given dialog is currently visible.
|
boolean |
openDialog(@NotNull Gui dialog,
boolean autoCloseOnDeactivate)
Opens a dialog.
|
void |
raiseDialog(@NotNull Gui dialog)
Raises an already opened dialog.
|
void |
redraw(@NotNull java.awt.Graphics g)
Paints the view into the given graphics instance.
|
void |
setCurrentGui(@NotNull Gui gui)
Sets the
Gui to display. |
boolean |
setFullScreenMode(@NotNull javax.swing.JFrame frame,
@Nullable Resolution resolution)
Tries to switch to the given resolution.
|
void |
setGuiState(@NotNull RendererGuiState rendererGuiState)
Sets the current gui state.
|
void |
setSelectedHostname(@NotNull java.lang.String serverName)
Selects a server entry.
|
void |
setTooltip(@Nullable java.awt.Component tooltip)
Sets the tooltip to use, or
null if no tooltips should be shown. |
void |
setWindowMode(@NotNull javax.swing.JFrame frame,
@Nullable Resolution resolution,
@NotNull Resolution minResolution,
boolean fixedSize)
Tries to switch to the given resolution.
|
boolean |
toggleDialog(@NotNull Gui dialog)
Toggles a dialog: if the dialog is not shown, show it; else hide it.
|
void |
updateServerSettings()
Updates server based settings to current screen size.
|
public JXCWindowRenderer(@NotNull @NotNull MouseTracker mouseTracker, @NotNull @NotNull CrossfireServerConnection crossfireServerConnection, @Nullable @Nullable java.io.Writer debugScreen)
mouseTracker
- the mouse tracker instancecrossfireServerConnection
- the server connection to monitordebugScreen
- the writer to write screen debug to or null
public boolean setFullScreenMode(@NotNull @NotNull javax.swing.JFrame frame, @Nullable @Nullable Resolution resolution)
frame
- the associated frameresolution
- the resolution to switch to; null
to keep
current resolutionpublic void setWindowMode(@NotNull @NotNull javax.swing.JFrame frame, @Nullable @Nullable Resolution resolution, @NotNull @NotNull Resolution minResolution, boolean fixedSize)
frame
- the associated frameresolution
- the resolution to switch to, null
for defaultminResolution
- the minimal supported resolutionfixedSize
- whether the window should have fixed sizepublic void endRendering()
public void redraw(@NotNull @NotNull java.awt.Graphics g)
g
- the graphics instance to paint topublic void clearGUI(@NotNull @NotNull Gui gui)
gui
- the gui to setpublic boolean openDialog(@NotNull @NotNull Gui dialog, boolean autoCloseOnDeactivate)
dialog
- the dialog to showautoCloseOnDeactivate
- whether the dialog should auto-close when it
becomes inactive; ignored if the dialog is already openfalse
if the
dialog already was opened as the topmost dialogpublic void raiseDialog(@NotNull @NotNull Gui dialog)
dialog
- the dialog to showpublic boolean isDialogOpen(@NotNull @NotNull Gui dialog)
dialog
- the dialog to check@NotNull public @NotNull java.lang.Iterable<Gui> getOpenDialogs()
public void setCurrentGui(@NotNull @NotNull Gui gui)
Gui
to display.gui
- the gui to displaypublic boolean closeDialog(@NotNull @NotNull Gui dialog)
dialog
- the dialog to closefalse
if the dialog
was not openpublic boolean toggleDialog(@NotNull @NotNull Gui dialog)
dialog
- the dialog to togglepublic void setTooltip(@Nullable @Nullable java.awt.Component tooltip)
null
if no tooltips should be shown.tooltip
- the tooltip to use, or null
public void setGuiState(@NotNull @NotNull RendererGuiState rendererGuiState)
rendererGuiState
- the gui state@NotNull public @NotNull RendererGuiState getGuiState()
public void addGuiStateListener(@NotNull @NotNull RendererGuiStateListener listener)
rendererGuiState
changes.listener
- the listener to addpublic boolean deactivateCommandInput()
@Nullable public @Nullable Buffer getActiveMessageBuffer()
null
if none is activepublic void setSelectedHostname(@NotNull @NotNull java.lang.String serverName)
serverName
- the server name to select@Nullable public @Nullable GUIText activateCommandInput()
null
if no command input
text field existspublic boolean handleKeyPress(@NotNull @NotNull KeyEvent2 e)
KeyEvent
.e
- the event to dispatchpublic int getWindowWidth()
public int getWindowHeight()
public void updateServerSettings()
@Nullable public static @Nullable GUIText activateCommandInput(@NotNull @NotNull Gui gui)
gui
- the gui to checknull
if this gui does not
contain any command text fields