Class GuiManager
java.lang.Object
com.realtime.crossfire.jxclient.window.GuiManager
Maintains the application's main GUI state.
-
Constructor Summary
ConstructorsConstructorDescriptionGuiManager
(@NotNull GuiStateManager guiStateManager, @NotNull TooltipManagerImpl tooltipManager, @NotNull Settings settings, @NotNull CrossfireServerConnection server, @NotNull JXCWindowRenderer windowRenderer, @NotNull GuiFactory guiFactory, @NotNull KeybindingsManager keybindingsManager, @NotNull JXCConnection connection) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
activateCommandInput
(@Nullable String newText) Activates the command input text field.void
Adds a dialog for name based lookup.void
closeDialog
(@NotNull String name) Closes the given dialog.void
Closes the keybinding dialog.void
Closes the "query" dialog.boolean
createKeyBinding
(boolean perCharacter, @NotNull CommandList cmdList) Adds a key binding.escPressed
(boolean connected) The ESC key has been pressed.@NotNull CommandList
getCommandList
(@NotNull String args) Returns a named command list.@NotNull Collection<String>
Returns all names of command lists.void
Hides all account-related windows.void
Displays the main account dialog, to let the player login or create a new account.void
openDialog
(@NotNull String name) Opens a dialog by name.void
openQueryDialog
(@NotNull String prompt, int queryType) Opens the "query" dialog.boolean
Opens the "quit" dialog.void
A "player" protocol command has been received.boolean
removeKeyBinding
(boolean perCharacter) Removes a key binding.void
selectCharacter
(@NotNull String accountName, @NotNull String characterName) Updates the selected character name in an account.void
setAccountName
(@NotNull String accountName) Updates the current account name.void
setOpaqueDialogBackground
(boolean opaque) Sets whether the dialog's background is opaque.void
setShowSentCommands
(boolean showSentCommands) Sets whether the commands sent to the server should be shown in the messages dialog.void
setShowTimestamps
(boolean showTimestamps) Sets whether timestamps shown in the messages dialog.void
Sets a new skin.void
showCharacters
(int count) Displays the window with the characters for an account.void
term()
Terminates the GUI.void
toggleDialog
(@NotNull String name) Toggles a dialog.void
Unsets the current skin.void
updatePlayerName
(@NotNull String playerName) Sets the current player name.void
updateWindowSize
(int width, int height) Sets a new window size.
-
Constructor Details
-
GuiManager
public GuiManager(@NotNull @NotNull GuiStateManager guiStateManager, @NotNull @NotNull TooltipManagerImpl tooltipManager, @NotNull @NotNull Settings settings, @NotNull @NotNull CrossfireServerConnection server, @NotNull @NotNull JXCWindowRenderer windowRenderer, @NotNull @NotNull GuiFactory guiFactory, @NotNull @NotNull KeybindingsManager keybindingsManager, @NotNull @NotNull JXCConnection connection) Creates a new instance.- Parameters:
guiStateManager
- the gui state manager to watchtooltipManager
- the tooltip manager to updatesettings
- the settings to useserver
- the crossfire server connection to monitorwindowRenderer
- the window renderer to useguiFactory
- the gui factory for creating gui instanceskeybindingsManager
- the keybindings manager to useconnection
- the connection to use
-
-
Method Details
-
addDialog
Adds a dialog for name based lookup.- Parameters:
name
- the name of the dialogdialog
- the dialog
-
playerReceived
public void playerReceived()A "player" protocol command has been received. -
manageAccount
public void manageAccount()Displays the main account dialog, to let the player login or create a new account. -
showCharacters
public void showCharacters(int count) Displays the window with the characters for an account.- Parameters:
count
- how many characters the account has
-
hideAccountWindows
public void hideAccountWindows()Hides all account-related windows. -
openQuitDialog
public boolean openQuitDialog()Opens the "quit" dialog. Does nothing if the dialog is open.- Returns:
- whether the dialog has been opened
-
escPressed
The ESC key has been pressed.- Parameters:
connected
- whether a connection to the server is active- Returns:
- whether how the key has been consumed: 0=ignore key, 1=disconnect from server, quit=quit application
-
openQueryDialog
Opens the "query" dialog.- Parameters:
prompt
- the query promptqueryType
- the query type
-
openDialog
Opens a dialog by name. Raises the dialog if open. Does nothing if the dialog is undefined.- Parameters:
name
- the name of the dialog
-
toggleDialog
Toggles a dialog.- Parameters:
name
- the name of the dialog
-
closeQueryDialog
public void closeQueryDialog()Closes the "query" dialog. Does nothing if the dialog is not open. -
closeKeybindDialog
public void closeKeybindDialog()Closes the keybinding dialog. Does nothing if the dialog is not opened. -
closeDialog
Closes the given dialog. Does nothing if the dialog is not opened.- Parameters:
name
- the name of the dialog
-
updatePlayerName
Sets the current player name. Does nothing if not currently in the character name prompt.- Parameters:
playerName
- the player name
-
activateCommandInput
Activates the command input text field. If the skin defines more than one input field, the first matching one is selected.If neither the main gui nor any visible dialog has an input text field, invisible GUIs are checked as well. If one is found, it is made visible.
- Parameters:
newText
- the new command text if non-null
-
unsetSkin
public void unsetSkin()Unsets the current skin. -
setSkin
Sets a new skin.- Parameters:
skin
- the new skin
-
term
public void term()Terminates the GUI. Stops display updates and saves the display state. -
createKeyBinding
Adds a key binding.- Parameters:
perCharacter
- whether a per-character key binding should be addedcmdList
- the command list to execute on key press- Returns:
- whether the key bindings dialog should be opened
-
removeKeyBinding
public boolean removeKeyBinding(boolean perCharacter) Removes a key binding.- Parameters:
perCharacter
- whether a per-character key binding should be removed- Returns:
- whether the key bindings dialog should be opened
-
updateWindowSize
public void updateWindowSize(int width, int height) Sets a new window size.- Parameters:
width
- the new window widthheight
- the new window height
-
getCommandList
@NotNull public @NotNull CommandList getCommandList(@NotNull @NotNull String args) throws NoSuchCommandException Returns a named command list.- Parameters:
args
- the name of the command list- Returns:
- the command list
- Throws:
NoSuchCommandException
- if the command list does not exist
-
getCommandListNames
Returns all names of command lists.- Returns:
- the names in alphabetical order
-
setAccountName
Updates the current account name.- Parameters:
accountName
- the current account name
-
selectCharacter
public void selectCharacter(@NotNull @NotNull String accountName, @NotNull @NotNull String characterName) Updates the selected character name in an account.- Parameters:
accountName
- the account namecharacterName
- the character name
-
setOpaqueDialogBackground
public void setOpaqueDialogBackground(boolean opaque) Sets whether the dialog's background is opaque.- Parameters:
opaque
- whether the background is opaque
-
setShowSentCommands
public void setShowSentCommands(boolean showSentCommands) Sets whether the commands sent to the server should be shown in the messages dialog.- Parameters:
showSentCommands
- whether to show the commands
-
setShowTimestamps
public void setShowTimestamps(boolean showTimestamps) Sets whether timestamps shown in the messages dialog.- Parameters:
showTimestamps
- whether to show timestamps
-