Class JXCWindowRenderer
java.lang.Object
com.realtime.crossfire.jxclient.gui.misc.JXCWindowRenderer
-
Constructor Summary
ConstructorsConstructorDescriptionJXCWindowRenderer(@NotNull MouseTracker mouseTracker, @NotNull CrossfireServerConnection crossfireServerConnection, @Nullable Writer debugScreen) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescription@Nullable GUITextActivates the command input text field.static @Nullable GUITextactivateCommandInput(@NotNull Gui gui) Returns the first command text field of a gui and make it active.voidaddGuiStateListener(@NotNull RendererGuiStateListener listener) Adds a gui state listener to be notified aboutrendererGuiStatechanges.voidSets a gui to display and clears the display.booleancloseDialog(@NotNull Gui dialog) Closes a dialog.booleanDeactivates the command input text field.voidEnds rendering and reverts the display settings.@Nullable BufferReturns the active message buffer.@NotNull RendererGuiStateReturns the current gui state.Returns all open dialogs in reverse painting order; the first element is the top-most dialog.intReturns the height of the client area.intReturns the width of the client area.booleanhandleKeyPress(@NotNull KeyEvent2 e) Dispatches a key pressKeyEvent.booleanisDialogOpen(@NotNull Gui dialog) Returns whether a given dialog is currently visible.booleanopenDialog(@NotNull Gui dialog, boolean autoCloseOnDeactivate) Opens a dialog.voidraiseDialog(@NotNull Gui dialog) Raises an already opened dialog.voidPaints the view into the given graphics instance.voidsetCurrentGui(@NotNull Gui gui) Sets theGuito display.booleansetFullScreenMode(@NotNull JFrame frame, @Nullable Resolution resolution) Tries to switch to the given resolution.voidsetGuiState(@NotNull RendererGuiState rendererGuiState) Sets the current gui state.voidsetSelectedHostname(@NotNull String serverName) Selects a server entry.voidsetTooltip(@Nullable Component tooltip) Sets the tooltip to use, ornullif no tooltips should be shown.voidsetWindowMode(@NotNull JFrame frame, @Nullable Resolution resolution, @NotNull Resolution minResolution, boolean fixedSize) Tries to switch to the given resolution.booleantoggleDialog(@NotNull Gui dialog) Toggles a dialog: if the dialog is not shown, show it; else hide it.voidUpdates server based settings to current screen size.
-
Constructor Details
-
JXCWindowRenderer
public JXCWindowRenderer(@NotNull @NotNull MouseTracker mouseTracker, @NotNull @NotNull CrossfireServerConnection crossfireServerConnection, @Nullable @Nullable Writer debugScreen) Creates a new instance.- Parameters:
mouseTracker- the mouse tracker instancecrossfireServerConnection- the server connection to monitordebugScreen- the writer to write screen debug to ornull
-
-
Method Details
-
setFullScreenMode
public boolean setFullScreenMode(@NotNull @NotNull JFrame frame, @Nullable @Nullable Resolution resolution) Tries to switch to the given resolution. If resolution switching fails, the window might be invisible.- Parameters:
frame- the associated frameresolution- the resolution to switch to;nullto keep current resolution- Returns:
- whether the resolution has been changed
-
setWindowMode
public void setWindowMode(@NotNull @NotNull JFrame frame, @Nullable @Nullable Resolution resolution, @NotNull @NotNull Resolution minResolution, boolean fixedSize) Tries to switch to the given resolution. If resolution switching fails, the window might be invisible.- Parameters:
frame- the associated frameresolution- the resolution to switch to,nullfor defaultminResolution- the minimal supported resolutionfixedSize- whether the window should have fixed size
-
endRendering
public void endRendering()Ends rendering and reverts the display settings. -
redraw
Paints the view into the given graphics instance.- Parameters:
g- the graphics instance to paint to
-
clearGUI
Sets a gui to display and clears the display.- Parameters:
gui- the gui to set
-
openDialog
Opens a dialog. Raises an already opened dialog.- Parameters:
dialog- the dialog to showautoCloseOnDeactivate- whether the dialog should auto-close when it becomes inactive; ignored if the dialog is already open- Returns:
- whether the dialog was opened or raised;
falseif the dialog already was opened as the topmost dialog
-
raiseDialog
Raises an already opened dialog. Does nothing if the dialog is not open.- Parameters:
dialog- the dialog to show
-
isDialogOpen
Returns whether a given dialog is currently visible.- Parameters:
dialog- the dialog to check- Returns:
- whether the dialog is visible
-
getOpenDialogs
Returns all open dialogs in reverse painting order; the first element is the top-most dialog.- Returns:
- the open dialogs; client code must not modify this list
-
setCurrentGui
Sets theGuito display.- Parameters:
gui- the gui to display
-
closeDialog
Closes a dialog. Does nothing if the given dialog is not open.- Parameters:
dialog- the dialog to close- Returns:
- whether the dialog has been closed;
falseif the dialog was not open
-
toggleDialog
Toggles a dialog: if the dialog is not shown, show it; else hide it.- Parameters:
dialog- the dialog to toggle- Returns:
- whether the dialog is shown
-
setTooltip
Sets the tooltip to use, ornullif no tooltips should be shown.- Parameters:
tooltip- the tooltip to use, ornull
-
setGuiState
Sets the current gui state.- Parameters:
rendererGuiState- the gui state
-
getGuiState
Returns the current gui state.- Returns:
- the gui state
-
addGuiStateListener
Adds a gui state listener to be notified aboutrendererGuiStatechanges.- Parameters:
listener- the listener to add
-
deactivateCommandInput
public boolean deactivateCommandInput()Deactivates the command input text field. Does nothing if the command input text field is not active.- Returns:
- whether the command input text field has been deactivated
-
getActiveMessageBuffer
Returns the active message buffer.- Returns:
- the active message buffer or
nullif none is active
-
setSelectedHostname
Selects a server entry.- Parameters:
serverName- the server name to select
-
activateCommandInput
Activates the command input text field. If more than one input field exists, the first matching one is selected.- Returns:
- the command input text field or
nullif no command input text field exists
-
handleKeyPress
Dispatches a key pressKeyEvent.- Parameters:
e- the event to dispatch- Returns:
- whether a gui element did handle the event
-
getWindowWidth
public int getWindowWidth()Returns the width of the client area.- Returns:
- the width in pixels
-
getWindowHeight
public int getWindowHeight()Returns the height of the client area.- Returns:
- the height in pixels
-
updateServerSettings
public void updateServerSettings()Updates server based settings to current screen size. Does nothing if the main window is not visible. -
activateCommandInput
Returns the first command text field of a gui and make it active.- Parameters:
gui- the gui to check- Returns:
- the comment text field, or
nullif this gui does not contain any command text fields
-