Class GuiManager
- java.lang.Object
-
- com.realtime.crossfire.jxclient.window.GuiManager
-
public class GuiManager extends java.lang.ObjectMaintains the application's main GUI state.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGuiManager.EscActionAction after ESC has been pressed.
-
Constructor Summary
Constructors Constructor Description GuiManager(@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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivateCommandInput(@Nullable java.lang.String newText)Activates the command input text field.voidaddDialog(@NotNull java.lang.String name, @NotNull Gui dialog)Adds a dialog for name based lookup.booleancloseDialog(@NotNull Gui dialog)Closes the given dialog.voidcloseDialog(@NotNull java.lang.String name)Closes the given dialog.voidcloseKeybindDialog()Closes the keybinding dialog.voidcloseQueryDialog()Closes the "query" dialog.booleancreateKeyBinding(boolean perCharacter, @NotNull CommandList cmdList)Adds a key binding.GuiManager.EscActionescPressed(boolean connected)The ESC key has been pressed.@NotNull CommandListgetCommandList(@NotNull java.lang.String args)Returns a named command list.voidhideAccountWindows()Hides all account-related windows.voidmanageAccount()Displays the main account dialog, to let the player login or create a new account.voidopenDialog(@NotNull java.lang.String name)Opens a dialog by name.voidopenQueryDialog(@NotNull java.lang.String prompt, int queryType)Opens the "query" dialog.booleanopenQuitDialog()Opens the "quit" dialog.voidplayerReceived()A "player" protocol command has been received.booleanremoveKeyBinding(boolean perCharacter)Removes a key binding.voidselectCharacter(@NotNull java.lang.String accountName, @NotNull java.lang.String characterName)Updates the selected character name in an account.voidsetAccountName(@NotNull java.lang.String accountName)Updates the current account name.voidsetSkin(@NotNull JXCSkin skin)Sets a new skin.voidshowCharacters(int count)Displays the window with the characters for an account.voidterm()Terminates the GUI.voidtoggleDialog(@NotNull java.lang.String name)Toggles a dialog.voidunsetSkin()Unsets the current skin.voidupdatePlayerName(@NotNull java.lang.String playerName)Sets the current player name.voidupdateWindowSize(int width, int height)Sets a new window size.
-
-
-
Constructor Detail
-
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 Detail
-
addDialog
public void addDialog(@NotNull @NotNull java.lang.String name, @NotNull @NotNull Gui dialog)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
public GuiManager.EscAction escPressed(boolean connected)
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
public void openQueryDialog(@NotNull @NotNull java.lang.String prompt, int queryType)Opens the "query" dialog.- Parameters:
prompt- the query promptqueryType- the query type
-
openDialog
public void openDialog(@NotNull @NotNull java.lang.String name)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
public void toggleDialog(@NotNull @NotNull java.lang.String name)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
public void closeDialog(@NotNull @NotNull java.lang.String name)Closes the given dialog. Does nothing if the dialog is not opened.- Parameters:
name- the name of the dialog
-
closeDialog
public boolean closeDialog(@NotNull @NotNull Gui dialog)Closes the given dialog. Does nothing if the dialog is not opened.- Parameters:
dialog- the dialog to close- Returns:
- whether the dialog has been closed;
falseif the dialog was not open
-
updatePlayerName
public void updatePlayerName(@NotNull @NotNull java.lang.String playerName)Sets the current player name. Does nothing if not currently in the character name prompt.- Parameters:
playerName- the player name
-
activateCommandInput
public void activateCommandInput(@Nullable @Nullable java.lang.String newText)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
public void setSkin(@NotNull @NotNull JXCSkin skin)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
public boolean createKeyBinding(boolean perCharacter, @NotNull @NotNull CommandList cmdList)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 java.lang.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
-
setAccountName
public void setAccountName(@NotNull @NotNull java.lang.String accountName)Updates the current account name.- Parameters:
accountName- the current account name
-
selectCharacter
public void selectCharacter(@NotNull @NotNull java.lang.String accountName, @NotNull @NotNull java.lang.String characterName)Updates the selected character name in an account.- Parameters:
accountName- the account namecharacterName- the character name
-
-